@netless/appliance-plugin 1.1.5 → 1.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/cdn/cdn.js +1 -1
- package/cdn/{fullWorker-XdMBFp.js → fullWorker-CIRArL.js} +64 -64
- package/cdn/{subWorker-ChVI4C.js → subWorker-C_XI7b.js} +64 -64
- package/dist/appliance-plugin.js +1 -1
- package/dist/appliance-plugin.mjs +1 -1
- package/dist/component/miniMap/manager.d.ts +1 -0
- package/dist/core/renderCotrol.d.ts +2 -0
- package/dist/core/worker/base.d.ts +1 -1
- package/dist/fullWorker.js +64 -64
- package/dist/index-BNqxsoBb.js +1 -0
- package/dist/{index-CDANfmmw.mjs → index-BkXgi5s7.mjs} +1 -1
- package/dist/{index-CcOhAM6h.js → index-CVBczavT.js} +1 -1
- package/dist/{index-Dkg_PdHZ.mjs → index-DeePQlzi.mjs} +1631 -1612
- package/dist/plugin/baseApplianceManager.d.ts +1 -0
- package/dist/plugin/types.d.ts +26 -1
- package/dist/subWorker.js +64 -64
- package/dist/undo/index.d.ts +2 -2
- package/package.json +4 -4
- package/dist/index-VnPTZ-8D.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var js=Object.defineProperty;var As=(a,o,t)=>o in a?js(a,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[o]=t;var M=(a,o,t)=>As(a,typeof o!="symbol"?o+"":o,t);const et=require("white-web-sdk"),lt=require("spritejs"),Ai=require("lz-string"),Do=require("lineclip"),vo=require("eventemitter2"),L=require("lodash"),g=require("react"),oo=require("react-dom"),ve=require("react-draggable"),Es=require("re-resizable"),Os="/fullWorker.js",Rs="/subWorker.js";var st=(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))(st||{}),_=(a=>(a.Normal="Normal",a.Stroke="Stroke",a.Dotted="Dotted",a.LongDotted="LongDotted",a))(_||{}),Yt=(a=>(a.Triangle="triangle",a.Rhombus="rhombus",a.Pentagram="pentagram",a.SpeechBalloon="speechBalloon",a.Star="star",a.Polygon="polygon",a))(Yt||{}),R=(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))(R||{}),q=(a=>(a.DisplayState="DisplayState",a.MainEngine="MainEngine",a.Cursor="Cursor",a.BindMainView="BindMainView",a))(q||{}),Ei=(a=>(a[a.MainView=0]="MainView",a[a.Plugin=1]="Plugin",a[a.Both=2]="Both",a))(Ei||{}),C=(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))(C||{}),H=(a=>(a[a.Local=1]="Local",a[a.Service=2]="Service",a[a.Worker=3]="Worker",a))(H||{}),D=(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))(D||{}),b=(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))(b||{}),$t=(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))($t||{}),Pe=(a=>(a[a.Cursor=1]="Cursor",a[a.TextCreate=2]="TextCreate",a))(Pe||{}),ae=(a=>(a[a.Top=1]="Top",a[a.Bottom=2]="Bottom",a))(ae||{}),ct=(a=>(a[a.none=1]="none",a[a.all=2]="all",a[a.both=3]="both",a[a.proportional=4]="proportional",a))(ct||{}),Oi=(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))(Oi||{}),Le=(a=>(a[a.inside=0]="inside",a[a.outside=1]="outside",a[a.intersect=2]="intersect",a))(Le||{}),xt=(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))(xt||{}),Ut=(a=>(a.setAuth="setAuth",a.setShow="addShow",a.setHide="setHide",a.setClear="setClear",a))(Ut||{});const Ys={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 k{constructor(o=0,t=0,e=1){this.x=o,this.y=t,this.z=e}get XY(){return[this.x,this.y]}setz(o){return this.z=o,this}setXY(o=this.x,t=this.y){return this.x=o,this.y=t,this}set(o=this.x,t=this.y,e=this.z){return this.x=o,this.y=t,this.z=e,this}setTo({x:o=0,y:t=0,z:e=1}){return this.x=o,this.y=t,this.z=e,this}rot(o){if(o===0)return this;const{x:t,y:e}=this,i=Math.sin(o),s=Math.cos(o);return this.x=t*s-e*i,this.y=t*i+e*s,this}rotWith(o,t){if(t===0)return this;const e=this.x-o.x,i=this.y-o.y,s=Math.sin(t),n=Math.cos(t);return this.x=o.x+(e*n-i*s),this.y=o.y+(e*s+i*n),this}clone(){const{x:o,y:t,z:e}=this;return new k(o,t,e)}sub(o){return this.x-=o.x,this.y-=o.y,this}subXY(o,t){return this.x-=o,this.y-=t,this}subScalar(o){return this.x-=o,this.y-=o,this}add(o){return this.x+=o.x,this.y+=o.y,this}addXY(o,t){return this.x+=o,this.y+=t,this}addScalar(o){return this.x+=o,this.y+=o,this}clamp(o,t){return this.x=Math.max(this.x,o),this.y=Math.max(this.y,o),t!==void 0&&(this.x=Math.min(this.x,t),this.y=Math.min(this.y,t)),this}div(o){return this.x/=o,this.y/=o,this}divV(o){return this.x/=o.x,this.y/=o.y,this}mul(o){return this.x*=o,this.y*=o,this}mulV(o){return this.x*=o.x,this.y*=o.y,this}abs(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this}nudge(o,t){const e=k.Tan(o,this);return this.add(e.mul(t))}neg(){return this.x*=-1,this.y*=-1,this}cross(o){return this.x=this.y*o.z-this.z*o.y,this.y=this.z*o.x-this.x*o.z,this}dpr(o){return k.Dpr(this,o)}cpr(o){return k.Cpr(this,o)}len2(){return k.Len2(this)}len(){return k.Len(this)}pry(o){return k.Pry(this,o)}per(){const{x:o,y:t}=this;return this.x=t,this.y=-o,this}uni(){return k.Uni(this)}tan(o){return k.Tan(this,o)}dist(o){return k.Dist(this,o)}distanceToLineSegment(o,t){return k.DistanceToLineSegment(o,t,this)}slope(o){return k.Slope(this,o)}snapToGrid(o){return this.x=Math.round(this.x/o)*o,this.y=Math.round(this.y/o)*o,this}angle(o){return k.Angle(this,o)}toAngle(){return k.ToAngle(this)}lrp(o,t){return this.x=this.x+(o.x-this.x)*t,this.y=this.y+(o.y-this.y)*t,this}equals(o,t){return k.Equals(this,o,t)}equalsXY(o,t){return k.EqualsXY(this,o,t)}norm(){const o=this.len();return this.x=o===0?0:this.x/o,this.y=o===0?0:this.y/o,this}toFixed(){return k.ToFixed(this)}toString(){return k.ToString(k.ToFixed(this))}toJson(){return k.ToJson(this)}toArray(){return k.ToArray(this)}static Add(o,t){return new k(o.x+t.x,o.y+t.y)}static AddXY(o,t,e){return new k(o.x+t,o.y+e)}static Sub(o,t){return new k(o.x-t.x,o.y-t.y)}static SubXY(o,t,e){return new k(o.x-t,o.y-e)}static AddScalar(o,t){return new k(o.x+t,o.y+t)}static SubScalar(o,t){return new k(o.x-t,o.y-t)}static Div(o,t){return new k(o.x/t,o.y/t)}static Mul(o,t){return new k(o.x*t,o.y*t)}static DivV(o,t){return new k(o.x/t.x,o.y/t.y)}static MulV(o,t){return new k(o.x*t.x,o.y*t.y)}static Neg(o){return new k(-o.x,-o.y)}static Per(o){return new k(o.y,-o.x)}static Dist2(o,t){return k.Sub(o,t).len2()}static Abs(o){return new k(Math.abs(o.x),Math.abs(o.y))}static Dist(o,t){return Math.hypot(o.y-t.y,o.x-t.x)}static Dpr(o,t){return o.x*t.x+o.y*t.y}static Cross(o,t){return new k(o.y*t.z-o.z*t.y,o.z*t.x-o.x*t.z)}static Cpr(o,t){return o.x*t.y-t.x*o.y}static Len2(o){return o.x*o.x+o.y*o.y}static Len(o){return Math.hypot(o.x,o.y)}static Pry(o,t){return k.Dpr(o,t)/k.Len(t)}static Uni(o){return k.Div(o,k.Len(o))}static Tan(o,t){return k.Uni(k.Sub(o,t))}static Min(o,t){return new k(Math.min(o.x,t.x),Math.min(o.y,t.y))}static Max(o,t){return new k(Math.max(o.x,t.x),Math.max(o.y,t.y))}static From(o){return new k().add(o)}static FromArray(o){return new k(o[0],o[1])}static Rot(o,t=0){const e=Math.sin(t),i=Math.cos(t);return new k(o.x*i-o.y*e,o.x*e+o.y*i)}static RotWith(o,t,e){const i=o.x-t.x,s=o.y-t.y,n=Math.sin(e),r=Math.cos(e);return new k(t.x+(i*r-s*n),t.y+(i*n+s*r))}static NearestPointOnLineThroughPoint(o,t,e){return k.Mul(t,k.Sub(e,o).pry(t)).add(o)}static NearestPointOnLineSegment(o,t,e,i=!0){const s=k.Tan(t,o),n=k.Add(o,k.Mul(s,k.Sub(e,o).pry(s)));if(i){if(n.x<Math.min(o.x,t.x))return k.Cast(o.x<t.x?o:t);if(n.x>Math.max(o.x,t.x))return k.Cast(o.x>t.x?o:t);if(n.y<Math.min(o.y,t.y))return k.Cast(o.y<t.y?o:t);if(n.y>Math.max(o.y,t.y))return k.Cast(o.y>t.y?o:t)}return n}static DistanceToLineThroughPoint(o,t,e){return k.Dist(e,k.NearestPointOnLineThroughPoint(o,t,e))}static DistanceToLineSegment(o,t,e,i=!0){return k.Dist(e,k.NearestPointOnLineSegment(o,t,e,i))}static Snap(o,t=1){return new k(Math.round(o.x/t)*t,Math.round(o.y/t)*t)}static Cast(o){return o instanceof k?o:k.From(o)}static Slope(o,t){return o.x===t.y?NaN:(o.y-t.y)/(o.x-t.x)}static Angle(o,t){return Math.atan2(t.y-o.y,t.x-o.x)}static Lrp(o,t,e){return k.Sub(t,o).mul(e).add(o)}static Med(o,t){return new k((o.x+t.x)/2,(o.y+t.y)/2)}static Equals(o,t,e=1e-4){return Math.abs(o.x-t.x)<e&&Math.abs(o.y-t.y)<e}static EqualsXY(o,t,e){return o.x===t&&o.y===e}static EqualsXYZ(o,t,e=1e-4){return k.Equals(o,t,e)&&Math.abs((o.z||0)-(t.z||0))<e}static Clockwise(o,t,e){return(e.x-o.x)*(t.y-o.y)-(t.x-o.x)*(e.y-o.y)<0}static Rescale(o,t){const e=k.Len(o);return new k(t*o.x/e,t*o.y/e)}static ScaleWithOrigin(o,t,e){return k.Sub(o,e).mul(t).add(e)}static ScaleWOrigin(o,t,e){return k.Sub(o,e).mulV(t).add(e)}static ToFixed(o,t=2){return new k(+o.x.toFixed(t),+o.y.toFixed(t),+o.z.toFixed(t))}static Nudge(o,t,e){return k.Add(o,k.Tan(t,o).mul(e))}static ToString(o){return`${o.x}, ${o.y}`}static ToAngle(o){let t=Math.atan2(o.y,o.x);return t<0&&(t+=Math.PI*2),t}static FromAngle(o,t=1){return new k(Math.cos(o)*t,Math.sin(o)*t)}static ToArray(o){return[o.x,o.y,o.z]}static ToJson(o){const{x:t,y:e,z:i}=o;return{x:t,y:e,z:i}}static Average(o){const t=o.length,e=new k(0,0);for(let i=0;i<t;i++)e.add(o[i]);return e.div(t)}static Clamp(o,t,e){return e===void 0?new k(Math.min(Math.max(o.x,t)),Math.min(Math.max(o.y,t))):new k(Math.min(Math.max(o.x,t),e),Math.min(Math.max(o.y,t),e))}static PointsBetween(o,t,e=6){const i=[];for(let s=0;s<e;s++){const n=Ys.easeInQuad(s/(e-1)),r=k.Lrp(o,t,n);r.z=Math.min(1,.5+Math.abs(.5-Ws(n))*.65),i.push(r)}return i}static SnapToGrid(o,t=8){return new k(Math.round(o.x/t)*t,Math.round(o.y/t)*t)}}const Ws=a=>a<.5?2*a*a:-1+(4-2*a)*a;class F extends k{constructor(o=0,t=0,e=0,i={x:0,y:0},s=0,n=0){super(o,t,e),this.x=o,this.y=t,this.z=e,this.v=i,this.t=s,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(o){this.a=o}setT(o){this.t=o}setv(o){return this.v={x:o.x,y:o.y},this}set(o=this.x,t=this.y,e=this.z,i=this.v,s=this.t,n=this.a){return this.x=o,this.y=t,this.z=e,this.v=i,this.t=s,this.a=n,this}clone(){const{x:o,y:t,z:e,v:i,t:s,a:n}=this,r={x:i.x,y:i.y};return new F(o,t,e,r,s,n)}distance(o){return F.GetDistance(this,o)}isNear(o,t){return F.IsNear(this,o,t)}getAngleByPoints(o,t){return F.GetAngleByPoints(o,this,t)}static Sub(o,t){return new F(o.x-t.x,o.y-t.y)}static Add(o,t){return new F(o.x+t.x,o.y+t.y)}static GetDistance(o,t){return F.Len(o.clone().sub(t))}static GetAngleByPoints(o,t,e){const i=t.x-o.x,s=e.x-t.x,n=t.y-o.y,r=e.y-t.y;let c=0;const l=Math.sqrt(i*i+n*n),h=Math.sqrt(s*s+r*r);if(l&&h){const u=i*s+n*r;c=Math.acos(u/(l*h)),c=c/Math.PI*180;let d=i*r-n*s;d=d>0?1:-1,c=180+d*c}return c}static IsNear(o,t,e){return F.Len(o.clone().sub(t))<e}static RotWith(o,t,e,i=2){const s=o.x-t.x,n=o.y-t.y,r=Math.sin(e),c=Math.cos(e),l=Math.pow(10,i),h=Math.floor((t.x+(s*c-n*r))*l)/l,u=Math.floor((t.y+(s*r+n*c))*l)/l;return new F(h,u)}static GetDotStroke(o,t,e=16){const i=new k(1,1),s=Math.PI+.001,n=F.Add(o,F.Sub(o,i).uni().per().mul(-t)),r=[];for(let c=1/e,l=c;l<=1;l+=c)r.push(F.RotWith(n,o,s*2*l));return r}static GetSemicircleStroke(o,t,e=-1,i=8){const s=e*(Math.PI+.001),n=[];for(let r=1/i,c=r;c<=1;c+=r)n.push(F.RotWith(t,o,s*c));return n}}var Re=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ie(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var Us=typeof Re=="object"&&Re&&Re.Object===Object&&Re,Ri=Us,Bs=Ri,Vs=typeof self=="object"&&self&&self.Object===Object&&self,Fs=Bs||Vs||Function("return this")(),Ft=Fs,Hs=Ft,$s=Hs.Symbol,io=$s,Go=io,Yi=Object.prototype,Qs=Yi.hasOwnProperty,Gs=Yi.toString,be=Go?Go.toStringTag:void 0;function Zs(a){var o=Qs.call(a,be),t=a[be];try{a[be]=void 0;var e=!0}catch{}var i=Gs.call(a);return e&&(o?a[be]=t:delete a[be]),i}var qs=Zs,Js=Object.prototype,Xs=Js.toString;function Ks(a){return Xs.call(a)}var _s=Ks,Zo=io,tn=qs,en=_s,on="[object Null]",sn="[object Undefined]",qo=Zo?Zo.toStringTag:void 0;function nn(a){return a==null?a===void 0?sn:on:qo&&qo in Object(a)?tn(a):en(a)}var ce=nn;function rn(a){return a!=null&&typeof a=="object"}var qt=rn,an=ce,cn=qt,ln="[object Number]";function hn(a){return typeof a=="number"||cn(a)&&an(a)==ln}var un=hn;const Qt=Ie(un);function dn(){this.__data__=[],this.size=0}var pn=dn;function fn(a,o){return a===o||a!==a&&o!==o}var jo=fn,gn=jo;function Mn(a,o){for(var t=a.length;t--;)if(gn(a[t][0],o))return t;return-1}var so=Mn,yn=so,mn=Array.prototype,wn=mn.splice;function vn(a){var o=this.__data__,t=yn(o,a);if(t<0)return!1;var e=o.length-1;return t==e?o.pop():wn.call(o,t,1),--this.size,!0}var In=vn,Nn=so;function Tn(a){var o=this.__data__,t=Nn(o,a);return t<0?void 0:o[t][1]}var Sn=Tn,Cn=so;function kn(a){return Cn(this.__data__,a)>-1}var xn=kn,zn=so;function bn(a,o){var t=this.__data__,e=zn(t,a);return e<0?(++this.size,t.push([a,o])):t[e][1]=o,this}var Pn=bn,Ln=pn,Dn=In,jn=Sn,An=xn,En=Pn;function Ne(a){var o=-1,t=a==null?0:a.length;for(this.clear();++o<t;){var e=a[o];this.set(e[0],e[1])}}Ne.prototype.clear=Ln;Ne.prototype.delete=Dn;Ne.prototype.get=jn;Ne.prototype.has=An;Ne.prototype.set=En;var no=Ne,On=no;function Rn(){this.__data__=new On,this.size=0}var Yn=Rn;function Wn(a){var o=this.__data__,t=o.delete(a);return this.size=o.size,t}var Un=Wn;function Bn(a){return this.__data__.get(a)}var Vn=Bn;function Fn(a){return this.__data__.has(a)}var Hn=Fn;function $n(a){var o=typeof a;return a!=null&&(o=="object"||o=="function")}var ee=$n,Qn=ce,Gn=ee,Zn="[object AsyncFunction]",qn="[object Function]",Jn="[object GeneratorFunction]",Xn="[object Proxy]";function Kn(a){if(!Gn(a))return!1;var o=Qn(a);return o==qn||o==Jn||o==Zn||o==Xn}var Wi=Kn,_n=Ft,tr=_n["__core-js_shared__"],er=tr,go=er,Jo=function(){var a=/[^.]+$/.exec(go&&go.keys&&go.keys.IE_PROTO||"");return a?"Symbol(src)_1."+a:""}();function or(a){return!!Jo&&Jo in a}var ir=or,sr=Function.prototype,nr=sr.toString;function rr(a){if(a!=null){try{return nr.call(a)}catch{}try{return a+""}catch{}}return""}var Ui=rr,ar=Wi,cr=ir,lr=ee,hr=Ui,ur=/[\\^$.*+?()[\]{}|]/g,dr=/^\[object .+?Constructor\]$/,pr=Function.prototype,fr=Object.prototype,gr=pr.toString,Mr=fr.hasOwnProperty,yr=RegExp("^"+gr.call(Mr).replace(ur,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function mr(a){if(!lr(a)||cr(a))return!1;var o=ar(a)?yr:dr;return o.test(hr(a))}var wr=mr;function vr(a,o){return a==null?void 0:a[o]}var Ir=vr,Nr=wr,Tr=Ir;function Sr(a,o){var t=Tr(a,o);return Nr(t)?t:void 0}var le=Sr,Cr=le,kr=Ft,xr=Cr(kr,"Map"),Ao=xr,zr=le,br=zr(Object,"create"),ro=br,Xo=ro;function Pr(){this.__data__=Xo?Xo(null):{},this.size=0}var Lr=Pr;function Dr(a){var o=this.has(a)&&delete this.__data__[a];return this.size-=o?1:0,o}var jr=Dr,Ar=ro,Er="__lodash_hash_undefined__",Or=Object.prototype,Rr=Or.hasOwnProperty;function Yr(a){var o=this.__data__;if(Ar){var t=o[a];return t===Er?void 0:t}return Rr.call(o,a)?o[a]:void 0}var Wr=Yr,Ur=ro,Br=Object.prototype,Vr=Br.hasOwnProperty;function Fr(a){var o=this.__data__;return Ur?o[a]!==void 0:Vr.call(o,a)}var Hr=Fr,$r=ro,Qr="__lodash_hash_undefined__";function Gr(a,o){var t=this.__data__;return this.size+=this.has(a)?0:1,t[a]=$r&&o===void 0?Qr:o,this}var Zr=Gr,qr=Lr,Jr=jr,Xr=Wr,Kr=Hr,_r=Zr;function Te(a){var o=-1,t=a==null?0:a.length;for(this.clear();++o<t;){var e=a[o];this.set(e[0],e[1])}}Te.prototype.clear=qr;Te.prototype.delete=Jr;Te.prototype.get=Xr;Te.prototype.has=Kr;Te.prototype.set=_r;var ta=Te,Ko=ta,ea=no,oa=Ao;function ia(){this.size=0,this.__data__={hash:new Ko,map:new(oa||ea),string:new Ko}}var sa=ia;function na(a){var o=typeof a;return o=="string"||o=="number"||o=="symbol"||o=="boolean"?a!=="__proto__":a===null}var ra=na,aa=ra;function ca(a,o){var t=a.__data__;return aa(o)?t[typeof o=="string"?"string":"hash"]:t.map}var ao=ca,la=ao;function ha(a){var o=la(this,a).delete(a);return this.size-=o?1:0,o}var ua=ha,da=ao;function pa(a){return da(this,a).get(a)}var fa=pa,ga=ao;function Ma(a){return ga(this,a).has(a)}var ya=Ma,ma=ao;function wa(a,o){var t=ma(this,a),e=t.size;return t.set(a,o),this.size+=t.size==e?0:1,this}var va=wa,Ia=sa,Na=ua,Ta=fa,Sa=ya,Ca=va;function Se(a){var o=-1,t=a==null?0:a.length;for(this.clear();++o<t;){var e=a[o];this.set(e[0],e[1])}}Se.prototype.clear=Ia;Se.prototype.delete=Na;Se.prototype.get=Ta;Se.prototype.has=Sa;Se.prototype.set=Ca;var Bi=Se,ka=no,xa=Ao,za=Bi,ba=200;function Pa(a,o){var t=this.__data__;if(t instanceof ka){var e=t.__data__;if(!xa||e.length<ba-1)return e.push([a,o]),this.size=++t.size,this;t=this.__data__=new za(e)}return t.set(a,o),this.size=t.size,this}var La=Pa,Da=no,ja=Yn,Aa=Un,Ea=Vn,Oa=Hn,Ra=La;function Ce(a){var o=this.__data__=new Da(a);this.size=o.size}Ce.prototype.clear=ja;Ce.prototype.delete=Aa;Ce.prototype.get=Ea;Ce.prototype.has=Oa;Ce.prototype.set=Ra;var Vi=Ce;function Ya(a,o){for(var t=-1,e=a==null?0:a.length;++t<e&&o(a[t],t,a)!==!1;);return a}var Wa=Ya,Ua=le,Ba=function(){try{var a=Ua(Object,"defineProperty");return a({},"",{}),a}catch{}}(),Va=Ba,_o=Va;function Fa(a,o,t){o=="__proto__"&&_o?_o(a,o,{configurable:!0,enumerable:!0,value:t,writable:!0}):a[o]=t}var Fi=Fa,Ha=Fi,$a=jo,Qa=Object.prototype,Ga=Qa.hasOwnProperty;function Za(a,o,t){var e=a[o];(!(Ga.call(a,o)&&$a(e,t))||t===void 0&&!(o in a))&&Ha(a,o,t)}var Hi=Za,qa=Hi,Ja=Fi;function Xa(a,o,t,e){var i=!t;t||(t={});for(var s=-1,n=o.length;++s<n;){var r=o[s],c=e?e(t[r],a[r],r,t,a):void 0;c===void 0&&(c=a[r]),i?Ja(t,r,c):qa(t,r,c)}return t}var co=Xa;function Ka(a,o){for(var t=-1,e=Array(a);++t<a;)e[t]=o(t);return e}var _a=Ka,tc=ce,ec=qt,oc="[object Arguments]";function ic(a){return ec(a)&&tc(a)==oc}var sc=ic,ti=sc,nc=qt,$i=Object.prototype,rc=$i.hasOwnProperty,ac=$i.propertyIsEnumerable,cc=ti(function(){return arguments}())?ti:function(a){return nc(a)&&rc.call(a,"callee")&&!ac.call(a,"callee")},lc=cc,hc=Array.isArray,lo=hc,He={exports:{}};function uc(){return!1}var dc=uc;He.exports;(function(a,o){var t=Ft,e=dc,i=o&&!o.nodeType&&o,s=i&&!0&&a&&!a.nodeType&&a,n=s&&s.exports===i,r=n?t.Buffer:void 0,c=r?r.isBuffer:void 0,l=c||e;a.exports=l})(He,He.exports);var Eo=He.exports,pc=9007199254740991,fc=/^(?:0|[1-9]\d*)$/;function gc(a,o){var t=typeof a;return o=o??pc,!!o&&(t=="number"||t!="symbol"&&fc.test(a))&&a>-1&&a%1==0&&a<o}var Mc=gc,yc=9007199254740991;function mc(a){return typeof a=="number"&&a>-1&&a%1==0&&a<=yc}var Qi=mc,wc=ce,vc=Qi,Ic=qt,Nc="[object Arguments]",Tc="[object Array]",Sc="[object Boolean]",Cc="[object Date]",kc="[object Error]",xc="[object Function]",zc="[object Map]",bc="[object Number]",Pc="[object Object]",Lc="[object RegExp]",Dc="[object Set]",jc="[object String]",Ac="[object WeakMap]",Ec="[object ArrayBuffer]",Oc="[object DataView]",Rc="[object Float32Array]",Yc="[object Float64Array]",Wc="[object Int8Array]",Uc="[object Int16Array]",Bc="[object Int32Array]",Vc="[object Uint8Array]",Fc="[object Uint8ClampedArray]",Hc="[object Uint16Array]",$c="[object Uint32Array]",ft={};ft[Rc]=ft[Yc]=ft[Wc]=ft[Uc]=ft[Bc]=ft[Vc]=ft[Fc]=ft[Hc]=ft[$c]=!0;ft[Nc]=ft[Tc]=ft[Ec]=ft[Sc]=ft[Oc]=ft[Cc]=ft[kc]=ft[xc]=ft[zc]=ft[bc]=ft[Pc]=ft[Lc]=ft[Dc]=ft[jc]=ft[Ac]=!1;function Qc(a){return Ic(a)&&vc(a.length)&&!!ft[wc(a)]}var Gc=Qc;function Zc(a){return function(o){return a(o)}}var Oo=Zc,$e={exports:{}};$e.exports;(function(a,o){var t=Ri,e=o&&!o.nodeType&&o,i=e&&!0&&a&&!a.nodeType&&a,s=i&&i.exports===e,n=s&&t.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})($e,$e.exports);var Ro=$e.exports,qc=Gc,Jc=Oo,ei=Ro,oi=ei&&ei.isTypedArray,Xc=oi?Jc(oi):qc,Gi=Xc,Kc=_a,_c=lc,tl=lo,el=Eo,ol=Mc,il=Gi,sl=Object.prototype,nl=sl.hasOwnProperty;function rl(a,o){var t=tl(a),e=!t&&_c(a),i=!t&&!e&&el(a),s=!t&&!e&&!i&&il(a),n=t||e||i||s,r=n?Kc(a.length,String):[],c=r.length;for(var l in a)(o||nl.call(a,l))&&!(n&&(l=="length"||i&&(l=="offset"||l=="parent")||s&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||ol(l,c)))&&r.push(l);return r}var Zi=rl,al=Object.prototype;function cl(a){var o=a&&a.constructor,t=typeof o=="function"&&o.prototype||al;return a===t}var Yo=cl;function ll(a,o){return function(t){return a(o(t))}}var qi=ll,hl=qi,ul=hl(Object.keys,Object),dl=ul,pl=Yo,fl=dl,gl=Object.prototype,Ml=gl.hasOwnProperty;function yl(a){if(!pl(a))return fl(a);var o=[];for(var t in Object(a))Ml.call(a,t)&&t!="constructor"&&o.push(t);return o}var ml=yl,wl=Wi,vl=Qi;function Il(a){return a!=null&&vl(a.length)&&!wl(a)}var Ji=Il,Nl=Zi,Tl=ml,Sl=Ji;function Cl(a){return Sl(a)?Nl(a):Tl(a)}var Wo=Cl,kl=co,xl=Wo;function zl(a,o){return a&&kl(o,xl(o),a)}var bl=zl;function Pl(a){var o=[];if(a!=null)for(var t in Object(a))o.push(t);return o}var Ll=Pl,Dl=ee,jl=Yo,Al=Ll,El=Object.prototype,Ol=El.hasOwnProperty;function Rl(a){if(!Dl(a))return Al(a);var o=jl(a),t=[];for(var e in a)e=="constructor"&&(o||!Ol.call(a,e))||t.push(e);return t}var Yl=Rl,Wl=Zi,Ul=Yl,Bl=Ji;function Vl(a){return Bl(a)?Wl(a,!0):Ul(a)}var Uo=Vl,Fl=co,Hl=Uo;function $l(a,o){return a&&Fl(o,Hl(o),a)}var Ql=$l,Qe={exports:{}};Qe.exports;(function(a,o){var t=Ft,e=o&&!o.nodeType&&o,i=e&&!0&&a&&!a.nodeType&&a,s=i&&i.exports===e,n=s?t.Buffer:void 0,r=n?n.allocUnsafe:void 0;function c(l,h){if(h)return l.slice();var u=l.length,d=r?r(u):new l.constructor(u);return l.copy(d),d}a.exports=c})(Qe,Qe.exports);var Gl=Qe.exports;function Zl(a,o){var t=-1,e=a.length;for(o||(o=Array(e));++t<e;)o[t]=a[t];return o}var ql=Zl;function Jl(a,o){for(var t=-1,e=a==null?0:a.length,i=0,s=[];++t<e;){var n=a[t];o(n,t,a)&&(s[i++]=n)}return s}var Xl=Jl;function Kl(){return[]}var Xi=Kl,_l=Xl,th=Xi,eh=Object.prototype,oh=eh.propertyIsEnumerable,ii=Object.getOwnPropertySymbols,ih=ii?function(a){return a==null?[]:(a=Object(a),_l(ii(a),function(o){return oh.call(a,o)}))}:th,Bo=ih,sh=co,nh=Bo;function rh(a,o){return sh(a,nh(a),o)}var ah=rh;function ch(a,o){for(var t=-1,e=o.length,i=a.length;++t<e;)a[i+t]=o[t];return a}var Ki=ch,lh=qi,hh=lh(Object.getPrototypeOf,Object),_i=hh,uh=Ki,dh=_i,ph=Bo,fh=Xi,gh=Object.getOwnPropertySymbols,Mh=gh?function(a){for(var o=[];a;)uh(o,ph(a)),a=dh(a);return o}:fh,ts=Mh,yh=co,mh=ts;function wh(a,o){return yh(a,mh(a),o)}var vh=wh,Ih=Ki,Nh=lo;function Th(a,o,t){var e=o(a);return Nh(a)?e:Ih(e,t(a))}var es=Th,Sh=es,Ch=Bo,kh=Wo;function xh(a){return Sh(a,kh,Ch)}var os=xh,zh=es,bh=ts,Ph=Uo;function Lh(a){return zh(a,Ph,bh)}var Dh=Lh,jh=le,Ah=Ft,Eh=jh(Ah,"DataView"),Oh=Eh,Rh=le,Yh=Ft,Wh=Rh(Yh,"Promise"),Uh=Wh,Bh=le,Vh=Ft,Fh=Bh(Vh,"Set"),Hh=Fh,$h=le,Qh=Ft,Gh=$h(Qh,"WeakMap"),Zh=Gh,Io=Oh,No=Ao,To=Uh,So=Hh,Co=Zh,is=ce,ke=Ui,si="[object Map]",qh="[object Object]",ni="[object Promise]",ri="[object Set]",ai="[object WeakMap]",ci="[object DataView]",Jh=ke(Io),Xh=ke(No),Kh=ke(To),_h=ke(So),tu=ke(Co),ie=is;(Io&&ie(new Io(new ArrayBuffer(1)))!=ci||No&&ie(new No)!=si||To&&ie(To.resolve())!=ni||So&&ie(new So)!=ri||Co&&ie(new Co)!=ai)&&(ie=function(a){var o=is(a),t=o==qh?a.constructor:void 0,e=t?ke(t):"";if(e)switch(e){case Jh:return ci;case Xh:return si;case Kh:return ni;case _h:return ri;case tu:return ai}return o});var ho=ie,eu=Object.prototype,ou=eu.hasOwnProperty;function iu(a){var o=a.length,t=new a.constructor(o);return o&&typeof a[0]=="string"&&ou.call(a,"index")&&(t.index=a.index,t.input=a.input),t}var su=iu,nu=Ft,ru=nu.Uint8Array,ss=ru,li=ss;function au(a){var o=new a.constructor(a.byteLength);return new li(o).set(new li(a)),o}var Vo=au,cu=Vo;function lu(a,o){var t=o?cu(a.buffer):a.buffer;return new a.constructor(t,a.byteOffset,a.byteLength)}var hu=lu,uu=/\w*$/;function du(a){var o=new a.constructor(a.source,uu.exec(a));return o.lastIndex=a.lastIndex,o}var pu=du,hi=io,ui=hi?hi.prototype:void 0,di=ui?ui.valueOf:void 0;function fu(a){return di?Object(di.call(a)):{}}var gu=fu,Mu=Vo;function yu(a,o){var t=o?Mu(a.buffer):a.buffer;return new a.constructor(t,a.byteOffset,a.length)}var mu=yu,wu=Vo,vu=hu,Iu=pu,Nu=gu,Tu=mu,Su="[object Boolean]",Cu="[object Date]",ku="[object Map]",xu="[object Number]",zu="[object RegExp]",bu="[object Set]",Pu="[object String]",Lu="[object Symbol]",Du="[object ArrayBuffer]",ju="[object DataView]",Au="[object Float32Array]",Eu="[object Float64Array]",Ou="[object Int8Array]",Ru="[object Int16Array]",Yu="[object Int32Array]",Wu="[object Uint8Array]",Uu="[object Uint8ClampedArray]",Bu="[object Uint16Array]",Vu="[object Uint32Array]";function Fu(a,o,t){var e=a.constructor;switch(o){case Du:return wu(a);case Su:case Cu:return new e(+a);case ju:return vu(a,t);case Au:case Eu:case Ou:case Ru:case Yu:case Wu:case Uu:case Bu:case Vu:return Tu(a,t);case ku:return new e;case xu:case Pu:return new e(a);case zu:return Iu(a);case bu:return new e;case Lu:return Nu(a)}}var Hu=Fu,$u=ee,pi=Object.create,Qu=function(){function a(){}return function(o){if(!$u(o))return{};if(pi)return pi(o);a.prototype=o;var t=new a;return a.prototype=void 0,t}}(),Gu=Qu,Zu=Gu,qu=_i,Ju=Yo;function Xu(a){return typeof a.constructor=="function"&&!Ju(a)?Zu(qu(a)):{}}var Ku=Xu,_u=ho,td=qt,ed="[object Map]";function od(a){return td(a)&&_u(a)==ed}var id=od,sd=id,nd=Oo,fi=Ro,gi=fi&&fi.isMap,rd=gi?nd(gi):sd,ad=rd,cd=ho,ld=qt,hd="[object Set]";function ud(a){return ld(a)&&cd(a)==hd}var dd=ud,pd=dd,fd=Oo,Mi=Ro,yi=Mi&&Mi.isSet,gd=yi?fd(yi):pd,ns=gd;const Md=Ie(ns);var yd=Vi,md=Wa,wd=Hi,vd=bl,Id=Ql,Nd=Gl,Td=ql,Sd=ah,Cd=vh,kd=os,xd=Dh,zd=ho,bd=su,Pd=Hu,Ld=Ku,Dd=lo,jd=Eo,Ad=ad,Ed=ee,Od=ns,Rd=Wo,Yd=Uo,Wd=1,Ud=2,Bd=4,rs="[object Arguments]",Vd="[object Array]",Fd="[object Boolean]",Hd="[object Date]",$d="[object Error]",as="[object Function]",Qd="[object GeneratorFunction]",Gd="[object Map]",Zd="[object Number]",cs="[object Object]",qd="[object RegExp]",Jd="[object Set]",Xd="[object String]",Kd="[object Symbol]",_d="[object WeakMap]",tp="[object ArrayBuffer]",ep="[object DataView]",op="[object Float32Array]",ip="[object Float64Array]",sp="[object Int8Array]",np="[object Int16Array]",rp="[object Int32Array]",ap="[object Uint8Array]",cp="[object Uint8ClampedArray]",lp="[object Uint16Array]",hp="[object Uint32Array]",pt={};pt[rs]=pt[Vd]=pt[tp]=pt[ep]=pt[Fd]=pt[Hd]=pt[op]=pt[ip]=pt[sp]=pt[np]=pt[rp]=pt[Gd]=pt[Zd]=pt[cs]=pt[qd]=pt[Jd]=pt[Xd]=pt[Kd]=pt[ap]=pt[cp]=pt[lp]=pt[hp]=!0;pt[$d]=pt[as]=pt[_d]=!1;function Ve(a,o,t,e,i,s){var n,r=o&Wd,c=o&Ud,l=o&Bd;if(t&&(n=i?t(a,e,i,s):t(a)),n!==void 0)return n;if(!Ed(a))return a;var h=Dd(a);if(h){if(n=bd(a),!r)return Td(a,n)}else{var u=zd(a),d=u==as||u==Qd;if(jd(a))return Nd(a,r);if(u==cs||u==rs||d&&!i){if(n=c||d?{}:Ld(a),!r)return c?Cd(a,Id(n,a)):Sd(a,vd(n,a))}else{if(!pt[u])return i?a:{};n=Pd(a,u,r)}}s||(s=new yd);var p=s.get(a);if(p)return p;s.set(a,n),Od(a)?a.forEach(function(m){n.add(Ve(m,o,t,m,a,s))}):Ad(a)&&a.forEach(function(m,S){n.set(S,Ve(m,o,t,S,a,s))});var f=l?c?xd:kd:c?Yd:Rd,y=h?void 0:f(a);return md(y||a,function(m,S){y&&(S=m,m=a[S]),wd(n,S,Ve(m,o,t,S,a,s))}),n}var up=Ve,dp=up,pp=1,fp=4;function gp(a){return dp(a,pp|fp)}var Mp=gp;const Jt=Ie(Mp),ls="1.1.6",yp="@netless/appliance-plugin",hs=typeof OffscreenCanvas=="function"?"worker":"mainThread";if(typeof window<"u"){let a=window.__netlessUA||"";a+=` ${yp}@${ls}_${hs}`,window.__netlessUA=a}const Lt={syncOpt:{interval:500},cdn:{subWorkerUrl:"https://cdn.jsdelivr.net/npm/@netless/appliance-plugin@latest/dist/subWorker.js",fullWorkerUrl:"https://cdn.jsdelivr.net/npm/@netless/appliance-plugin@latest/dist/fullWorker.js"},cursor:{expirationTime:5e3},bufferSize:{full:2e4,sub:1e3},bezier:{combineUnitTime:100},pencilEraser:{useBitMap:!0}};function _t(a,o=!0){const t=a.length;if(t<2)return"";let e=a[0],i=a[1];if(t===2)return`M${he(e)}L${he(i)}`;let s="";for(let n=2,r=t-1;n<r;n++)e=a[n],i=a[n+1],s+=ue(e,i);return o?`M${ue(a[0],a[1])}Q${he(a[1])}${ue(a[1],a[2])}T${s}${ue(a[t-1],a[0])}${ue(a[0],a[1])}Z`:`M${he(a[0])}Q${he(a[1])}${ue(a[1],a[2])}${a.length>3?"T":""}${s}L${he(a[t-1])}`}const Pt=class Pt{constructor(o){M(this,"syncUnitTime",Lt.syncOpt.interval);M(this,"vNodes");M(this,"drawLayer");M(this,"fullLayer");M(this,"workId");const{vNodes:t,fullLayer:e,drawLayer:i,workId:s,toolsOpt:n}=o;this.vNodes=t,this.fullLayer=e,this.drawLayer=i,this.workId=s,this.syncUnitTime=n.syncUnitTime||this.syncUnitTime}get baseConsumeResult(){return{workId:this.workId,toolsType:this.toolsType,opt:this.workOptions}}filterSamePoints(o,t=.01){return o.reduce((e,i)=>{const s=e[e.length-1];return(i&&!s||i&&s&&!i.isNear(s,t))&&e.push(i),e},[])}setWorkId(o){this.workId=o}getWorkId(){return this.workId}getWorkOptions(){return this.workOptions}setWorkOptions(o){var i,s,n;this.workOptions=o,this.syncUnitTime=o.syncUnitTime||this.syncUnitTime;const t=(i=this.workId)==null?void 0:i.toString(),e=t&&((s=this.vNodes)==null?void 0:s.get(t))||void 0;t&&e&&(e.opt=o,(n=this.vNodes)==null||n.setInfo(t,e))}updataOptService(o){var i,s;let t;const e=(i=this.workId)==null?void 0:i.toString();if(e&&o){const n=this.fullLayer.getElementsByName(e)||this.drawLayer&&this.drawLayer.getElementsByName(e)||[];if(n.length!==1)return;const r=n[0],{pos:c,zIndex:l,scale:h,angle:u,translate:d}=o,p={};Qt(l)&&(p.zIndex=l),c&&(p.pos=[c[0],c[1]]),h&&(p.scale=h),u&&(p.rotate=u),d&&(p.translate=d),r.attr(p);const f=r==null?void 0:r.getBoundingClientRect();return f&&(t=ut(t,{x:Math.floor(f.x-Pt.SafeBorderPadding),y:Math.floor(f.y-Pt.SafeBorderPadding),w:Math.floor(f.width+Pt.SafeBorderPadding*2),h:Math.floor(f.height+Pt.SafeBorderPadding*2)})),(s=this.vNodes)==null||s.setInfo(e,{rect:t,centerPos:c}),t}}drawEraserlines(o){const{group:t,eraserlines:e,pos:i,layer:s,isClear:n=!0}=o,r=!!s.parent.gl;for(const c of e){const{thickness:l,op:h}=c;for(const u of h){const d=u.map((S,w)=>w%2?S-i[1]:S-i[0]),p=this.computEraserPoints(d,l),f=_t(p,!0),y={pos:[0,0],d:f,fillColor:"rgba(0,0,0,1)"},m=new lt.Path(y);n&&(m.addEventListener("beforerender",({detail:S})=>{const w=S.context;r?w.blendFuncSeparate(w.ZERO,w.ZERO,w.ZERO,w.ZERO):w.globalCompositeOperation="destination-out"}),m.addEventListener("afterrender",({detail:S})=>{const w=S.context;r?w.blendFuncSeparate(w.SRC_ALPHA,w.ONE_MINUS_SRC_ALPHA,w.ONE,w.ONE_MINUS_SRC_ALPHA):w.globalCompositeOperation="source-over"})),t.append(m)}}}computEraserPoints(o,t){const e=Math.ceil(t/2);return o.length===2?this.computDot(o,e):this.computLine(o,e)}computDot(o,t){const e=new F(o[0],o[1]);return F.GetDotStroke(e,t,8)}computLine(o,t){const e=[],i=[];let s,n;for(let r=0;r<o.length;r+=2){const c=new F(o[r],o[r+1]);let l;if(r==o.length-2){const h=new F(o[r-2],o[r-1]);l=k.Sub(c,h).uni(),s=c}else{r===0&&(n=c);const h=new F(o[r+2],o[r+3]);l=k.Sub(h,c).uni()}if(l){const h=k.Per(l).mul(t);e.push(F.Sub(c,h)),i.push(F.Add(c,h))}}if(s&&n){const r=F.GetSemicircleStroke(s,e[e.length-1],-1,8),c=F.GetSemicircleStroke(n,i[0],-1,8);return e.concat(r,i.reverse(),c)}return[]}replace(o,t,e){var r;const i=o.getElementsByName(t),s=i.length;if(s){if(s>1)for(let c=1;c<i.length;c++)o.removeChild(i[c]),i[c].disconnect();e?o.replaceChild(e,i[0]):o.removeChild(i[0]),i[0].disconnect()}else e&&o.append(e);this.fullLayer===o?(r=this.drawLayer)==null||r.getElementsByName(t).forEach(c=>{var l;(l=this.drawLayer)==null||l.removeChild(c),c.disconnect()}):this.fullLayer.getElementsByName(t).forEach(c=>{this.fullLayer.removeChild(c),c.disconnect()})}static updateNodeOpt(o){var w;const{node:t,opt:e,vNodes:i,willSerializeData:s,targetNode:n}=o,{zIndex:r,translate:c,angle:l,originPoint:h,scenePoint:u,scale:d,pointMap:p,thickness:f}=e;let y;const m=n&&Jt(n)||i.get(t.name);if(!m)return;Qt(r)&&(t.setAttribute("zIndex",r),m.opt.zIndex=r);const S=t.parent;if(S){if(h&&d&&n){const v=[m.op[0],m.op[1]];Ho(m.op,u,d,c);const T=[m.op[0],m.op[1]],N=[T[0]-v[0],T[1]-v[1]];if(m.centerPos=[m.centerPos[0]+N[0],m.centerPos[1]+N[1]],m.opt.translate=void 0,m.opt.scale=void 0,m.opt.eraserlines)for(const I of Object.values(m.opt.eraserlines)){const{op:x,thickness:z}=I;I.thickness=z*Math.max(d[0],d[1]);for(let A=0;A<x.length;A++)$o(x[A],u,d,c)}}else if(c)if(t.setAttribute("translate",c),m.opt.translate=c,n){const v=[c[0]*S.worldScaling[0],c[1]*S.worldScaling[1]];y=ko(m.rect,v),m.rect=y}else{const v=Pt.getRectFromLayer(S,t.name);m.rect=v||m.rect}else if(Qt(l))if(t.setAttribute("rotate",l),m.opt.rotate=l,n)y=Cs(m.rect,l),m.rect=y;else{const v=Pt.getRectFromLayer(S,t.name);m.rect=v||m.rect}if(p){const v=p.get(t.name);if(v)for(let T=0,N=0;T<m.op.length;T+=3,N++)m.op[T]=v[N][0],m.op[T+1]=v[N][1]}if(f&&((w=m==null?void 0:m.opt)!=null&&w.thickness)&&(m.opt.thickness=f),s&&!(h&&d&&n)){if(c){const v=m.op.map((T,N)=>{const I=N%3;return I===0?T+c[0]:I===1?T+c[1]:T});if(m.op=v,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 T of Object.values(m.opt.eraserlines)){const{op:N}=T;for(let I=0;I<N.length;I++){const x=N[I].map((z,A)=>A%2?z+c[1]:z+c[0]);T.op[I]=x}}}else if(Qt(l)){const v=m.op;if(Df(v,m.centerPos,l),m.op=v,m!=null&&m.opt&&(m.opt.rotate=void 0),m.opt.eraserlines)for(const T of Object.values(m.opt.eraserlines)){const{op:N}=T;for(let I=0;I<N.length;I++)jf(N[I],m.centerPos,l)}}}m&&i.setInfo(t.name,m)}}static getCenterPos(o,t){const{worldPosition:e,worldScaling:i}=t;return[(o.x+o.w/2-e[0])/i[0],(o.y+o.h/2-e[1])/i[1]]}static getRectFromLayer(o,t){const e=o.getElementsByName(t)[0];if(e){const i=e.getBoundingClientRect();return{x:Math.floor(i.x-Pt.SafeBorderPadding),y:Math.floor(i.y-Pt.SafeBorderPadding),w:Math.floor(i.width+Pt.SafeBorderPadding*2),h:Math.floor(i.height+Pt.SafeBorderPadding*2)}}}};M(Pt,"SafeBorderPadding",10);let W=Pt;function xe(a){return JSON.parse(Ai.decompress(a))}function Dt(a){return Ai.compress(JSON.stringify(a))}const Ct=Object.keys;class us extends W{constructor(t){super(t);M(this,"canRotate",!0);M(this,"scaleType",ct.all);M(this,"toolsType",C.Pencil);M(this,"syncTimestamp");M(this,"syncIndex",0);M(this,"tmpPoints",[]);M(this,"MAX_REPEAR",10);M(this,"uniThickness");M(this,"workOptions");M(this,"centerPos",[0,0]);this.workOptions=t.toolsOpt,this.uniThickness=this.MAX_REPEAR/this.workOptions.thickness/10,this.syncTimestamp=0}combineConsume(){var r;const t=(r=this.workId)==null?void 0:r.toString();if(this.tmpPoints.length<2)return{type:b.None};const e=this.transformDataAll(!0),i={name:t};let s;const n=this.drawLayer||this.fullLayer;return e.length&&(s=this.draw({attrs:i,tasks:e,replaceId:t,layer:n})),{rect:s,type:b.DrawWork,dataType:H.Local}}setWorkOptions(t){super.setWorkOptions(t),this.syncTimestamp=Date.now()}consume(t){const{data:e,isFullWork:i,isSubWorker:s,isMainThread:n,drawCount:r,replaceId:c}=t,{workId:l}=e,{tasks:h,effects:u,consumeIndex:d}=this.transformData(e,!1);this.syncIndex=Math.min(this.syncIndex,d,Math.max(0,this.tmpPoints.length-2));const p={name:l,id:r==null?void 0:r.toString()};let f,y=!1;const m=this.syncIndex;if(this.syncTimestamp===0&&(this.syncTimestamp=Date.now()),h.length&&(h[0].taskId-this.syncTimestamp>this.syncUnitTime&&(y=!0,this.syncTimestamp=h[0].taskId,this.syncIndex=this.tmpPoints.length),s||n)){const w=i?this.fullLayer:this.drawLayer||this.fullLayer;f=this.draw({attrs:p,tasks:h,effects:u,layer:w,replaceId:c})}if(s)return d>10&&this.tmpPoints.splice(0,d-10),{rect:f,type:b.DrawWork,dataType:H.Local};const S=[];return this.tmpPoints.slice(m).forEach(w=>{S.push(w.x,w.y,this.computRadius(w.z,this.workOptions.thickness))}),{...this.baseConsumeResult,type:b.DrawWork,dataType:H.Local,rect:f,op:y?S:void 0,index:y?m*3:void 0,updateNodeOpt:{useAnimation:!0}}}consumeAll(t){var h;const e=this.workId;if(t.data){const{op:u,workState:d}=t.data;u!=null&&u.length&&d===D.Done&&this.workOptions.strokeType===_.Stroke&&this.updateTempPointsWithPressureWhenDone(u)}const i=this.transformDataAll(!0),s={name:e};let n;const r=this.fullLayer;if(i.length&&(n=this.draw({attrs:s,tasks:i,replaceId:e,layer:r})),this.tmpPoints.length<2)return this.replace(r,e),{type:b.RemoveNode,removeIds:[e],rect:n};const c=[];this.tmpPoints.map(u=>{c.push(u.x,u.y,u.z)}),this.syncTimestamp=0,delete this.workOptions.syncUnitTime;const l=Dt(c);return(h=this.vNodes)==null||h.setInfo(e,{rect:n,op:c,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:n&&W.getCenterPos(n,r)}),{...this.baseConsumeResult,rect:n,type:b.FullWork,dataType:H.Local,ops:l,updateNodeOpt:{pos:this.centerPos,useAnimation:!0}}}clearTmpPoints(){this.tmpPoints.length=0,this.syncTimestamp=0,this.syncIndex=0}consumeService(t){var h,u;const{op:e,isFullWork:i,replaceId:s}=t;this.tmpPoints.length=0;for(let d=0;d<e.length;d+=3){const p=new F(e[d],e[d+1],e[d+2]);if(this.tmpPoints.length>0){const f=this.tmpPoints[this.tmpPoints.length-1],y=k.Sub(p,f).uni();p.setv(y)}this.tmpPoints.push(p)}if(this.tmpPoints.length<2)return;const n=this.transformDataAll(!0),r=(h=this.workId)==null?void 0:h.toString(),c={name:r};let l;if(r&&n.length){const d=i?this.fullLayer:this.drawLayer||this.fullLayer;l=this.draw({attrs:c,tasks:n,replaceId:s,layer:d}),(u=this.vNodes)==null||u.setInfo(r,{rect:l,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:l&&W.getCenterPos(l,d)})}return l}transformDataAll(t=!0){const e=this.filterSamePoints(this.tmpPoints,this.workOptions.thickness);return this.getTaskPoints(e,t&&this.workOptions.thickness||void 0)}draw(t){const{attrs:e,tasks:i,replaceId:s,effects:n,layer:r}=t,{strokeColor:c,strokeType:l,thickness:h,zIndex:u,scale:d,rotate:p,translate:f,eraserlines:y}=this.workOptions;n!=null&&n.size&&(n.forEach(N=>{var I;(I=r.getElementById(N+""))==null||I.remove()}),n.clear());let m;const S=[],w=r.worldPosition,v=r.worldScaling;for(let N=0;N<i.length;N++){const{pos:I,points:x}=i[N],{ps:z,rect:A}=this.computDrawPoints(x);let E;const j=x.length===1;l===_.Stroke||j?E=_t(z,!0):E=_t(z,!1);const O={pos:I,d:E,fillColor:l===_.Stroke||j?c:void 0,lineDash:l===_.Dotted&&!j?[1,h*2]:l===_.LongDotted&&!j?[h,h*2]:void 0,strokeColor:c,lineCap:l===_.Stroke||j?void 0:"round",lineWidth:l===_.Stroke||j?0:h};m=ut(m,{x:Math.floor((A.x+I[0])*v[0]+w[0]-W.SafeBorderPadding),y:Math.floor((A.y+I[1])*v[1]+w[1]-W.SafeBorderPadding),w:Math.floor(A.w*v[0]+2*W.SafeBorderPadding),h:Math.floor(A.h*v[1]+2*W.SafeBorderPadding)}),S.push(O)}d&&(e.scale=d),p&&(e.rotate=p),f&&(e.translate=f);const T=new lt.Group;if(m){this.centerPos=W.getCenterPos(m,r);const N=l===_.Stroke&&!y;T.attr({...e,normalize:!0,anchor:[.5,.5],bgcolor:N?c:void 0,pos:this.centerPos,size:[(m.w-2*W.SafeBorderPadding)/v[0],(m.h-2*W.SafeBorderPadding)/v[1]],zIndex:u});const I=S.map(x=>(x.pos=[x.pos[0]-this.centerPos[0],x.pos[1]-this.centerPos[1]],new lt.Path(x)));T.append(...I),N&&T.seal(),y&&this.drawEraserlines({group:T,eraserlines:y,pos:this.centerPos,layer:r}),this.replace(r,s||e.workId,T)}if(d||p||f){const N=T==null?void 0:T.getBoundingClientRect();if(N)return{x:Math.floor(N.x-W.SafeBorderPadding),y:Math.floor(N.y-W.SafeBorderPadding),w:Math.floor(N.width+W.SafeBorderPadding*2),h:Math.floor(N.height+W.SafeBorderPadding*2)}}return m}computDrawPoints(t){return this.workOptions.strokeType===_.Stroke||t.length===1?this.computStroke(t):this.computNomal(t)}computNomal(t){let e=this.workOptions.thickness;const i=t.map(s=>(e=Math.max(e,s.radius),s.point));return{ps:i,rect:dt(i,e)}}computStroke(t){return t.length===1?this.computDotStroke(t[0]):this.computLineStroke(t)}computLineStroke(t){const e=[],i=[];for(let l=0;l<t.length;l++){const{point:h,radius:u}=t[l];let d=h.v;l===0&&t.length>1&&(d=t[l+1].point.v);const p=k.Per(d).mul(u);e.push(F.Sub(h,p)),i.push(F.Add(h,p))}const s=t[t.length-1],n=F.GetSemicircleStroke(s.point,e[e.length-1],-1,8),r=F.GetSemicircleStroke(t[0].point,i[0],-1,8),c=e.concat(n,i.reverse(),r);return{ps:c,rect:dt(c)}}computDotStroke(t){const{point:e,radius:i}=t,s={x:e.x-i,y:e.y-i,w:i*2,h:i*2};return{ps:F.GetDotStroke(e,i,8),rect:s}}transformData(t,e){const{op:i,workState:s}=t;let n=this.tmpPoints.length-1,r=[];if(i!=null&&i.length&&s){const{strokeType:c,thickness:l}=this.workOptions,h=new Set;n=c===_.Stroke?this.updateTempPointsWithPressure(i,l,h):this.updateTempPoints(i,l,h);const u=e?this.tmpPoints:this.tmpPoints.slice(n);return r=this.getTaskPoints(u,l),{tasks:r,effects:h,consumeIndex:n}}return{tasks:r,consumeIndex:n}}computRadius(t,e){return t*.03*e+e*.5}getMinZ(t,e){return((e||Math.max(1,Math.floor(t*.3)))-t*.5)*100/t/3}getTaskPoints(t,e){var u;const i=[];if(t.length===0)return[];let s=0,n=t[0].x,r=t[0].y,c=[n,r],l=[],h=t[0].t;for(;s<t.length;){const d=t[s],p=d.x-n,f=d.y-r,y=d.z,m=e?this.computRadius(y,e):y;if(l.push({point:new F(p,f,y,t[s].v),radius:m}),s>0&&s<t.length-1){const S=t[s].getAngleByPoints(t[s-1],t[s+1]);if(S<90||S>270){const w=(u=l.pop())==null?void 0:u.point.clone();w&&i.push({taskId:h,pos:c,points:[...l,{point:w,radius:m}]}),n=t[s].x,r=t[s].y,c=[n,r];const v=d.x-n,T=d.y-r;l=[{point:new F(v,T,y),radius:m}],h=Date.now()}}s++}return i.push({taskId:h,pos:c,points:l}),i}updateTempPointsWithPressure(t,e,i){const s=Date.now(),n=this.tmpPoints.length;let r=n;for(let l=0;l<t.length;l+=2){r=Math.min(r,n);const h=this.tmpPoints.length,u=new F(t[l],t[l+1]);if(h===0){this.tmpPoints.push(u);continue}const d=h-1,p=this.tmpPoints[d],f=k.Sub(u,p).uni();if(u.isNear(p,e)){if(p.z<this.MAX_REPEAR){if(p.setz(Math.min(p.z+1,this.MAX_REPEAR)),r=Math.min(r,d),h>1){let S=h-1;for(;S>0;){const w=this.tmpPoints[S].distance(this.tmpPoints[S-1]),v=Math.max(this.tmpPoints[S].z-this.uniThickness*w,0);if(this.tmpPoints[S-1].z>=v)break;this.tmpPoints[S-1].setz(v),r=Math.min(r,S-1),S--}}}else r=1/0;continue}u.setv(f);const y=u.distance(p),m=Math.max(p.z-this.uniThickness*y,0);h>1&&k.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)),u.setz(m),this.tmpPoints.push(u)}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 h=this.tmpPoints[l].t;if(h&&(i==null||i.add(h),l<=r)){c=l,l=-1;break}l--}}return this.tmpPoints[c].setT(s),c}updateTempPoints(t,e,i){var l;const s=Date.now(),n=this.tmpPoints.length;let r=n;for(let h=0;h<t.length;h+=2){const u=this.tmpPoints.length,d=new F(t[h],t[h+1]);if(u===0){this.tmpPoints.push(d);continue}const p=u-1,f=this.tmpPoints[p],y=k.Sub(d,f).uni();if(d.isNear(f,e/2)){r=Math.min(p,r);continue}k.Equals(y,f.v,.02)&&(i&&f.t&&i.add(f.t),this.tmpPoints.pop(),r=Math.min(p,r)),d.setv(y),this.tmpPoints.push(d)}let c=n;if(r===n){c=Math.max(c-1,0);const h=this.tmpPoints[c].t;h&&(i==null||i.add(h))}else{let h=Math.min(n-1,r);for(c=r;h>=0;){const u=(l=this.tmpPoints[h])==null?void 0:l.t;if(u&&(i==null||i.add(u),h<=r)){c=h,h=-1;break}h--}}return this.tmpPoints[c].setT(s),c}updateTempPointsWithPressureWhenDone(t){const{thickness:e}=this.workOptions,i=t.length,s=this.getMinZ(e);for(let n=0;n<i;n+=2){const r=this.tmpPoints.length,c=new F(t[n],t[n+1]);if(r===0){this.tmpPoints.push(c);continue}const l=r-1,h=this.tmpPoints[l],u=k.Sub(c,h).uni(),d=c.distance(h);if(r>1&&h.z===s)break;if(c.isNear(h,e/2)){if(i<3&&h.z<this.MAX_REPEAR&&(h.setz(Math.min(h.z+1,this.MAX_REPEAR)),r>1)){let f=r-1;for(;f>0;){const y=this.tmpPoints[f].distance(this.tmpPoints[f-1]),m=Math.max(this.tmpPoints[f].z-this.uniThickness*y,-e/4);if(this.tmpPoints[f-1].z>=m)break;this.tmpPoints[f-1].setz(m),f--}}continue}c.setv(u);const p=Math.max(h.z-this.uniThickness*d,s);r>1&&k.Equals(u,h.v,.02)&&h.z<=0&&this.tmpPoints.pop(),c.setz(p),this.tmpPoints.push(c)}}static updateNodeOpt(t){var l,h;const{node:e,opt:i,vNodes:s}=t,{strokeColor:n,strokeType:r}=i,c=s.get(e.name);return n&&(e.tagName==="GROUP"?Ef(e)?e.setAttribute("bgcolor",n):e.children.forEach(u=>{u.setAttribute("strokeColor",n),u.getAttribute("fillColor")&&u.setAttribute("fillColor",n)}):(e.setAttribute("strokeColor",n),e.setAttribute("fillColor",n)),(l=c==null?void 0:c.opt)!=null&&l.strokeColor&&(c.opt.strokeColor=n)),r&&(c!=null&&c.opt)&&((h=c.opt)!=null&&h.strokeType)&&(c.opt.strokeType=r),c&&s.setInfo(e.name,c),W.updateNodeOpt(t)}}class ds extends W{constructor(t){super(t);M(this,"toolsType",C.LaserPen);M(this,"canRotate",!1);M(this,"scaleType",ct.none);M(this,"syncTimestamp");M(this,"syncIndex",0);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"consumeIndex",0);this.workOptions=t.toolsOpt,this.syncTimestamp=0}combineConsume(){}setWorkOptions(t){super.setWorkOptions(t),this.syncTimestamp=Date.now()}consume(t){const{data:e,isSubWorker:i}=t,{workId:s,op:n}=e;if((n==null?void 0:n.length)===0)return{type:b.None};if(this.updateTempPoints(n||[]),this.consumeIndex>this.tmpPoints.length-4)return{type:b.None};const{strokeColor:r,thickness:c,strokeType:l}=this.workOptions,h=dt(this.tmpPoints,c);let u=!1;const d=this.syncIndex,p=this.tmpPoints.slice(this.consumeIndex);this.consumeIndex=this.tmpPoints.length-1,this.syncTimestamp===0&&(this.syncTimestamp=Date.now());const f={name:s==null?void 0:s.toString(),opacity:1,lineDash:l===_.Dotted?[1,c*2]:l===_.LongDotted?[c,c*2]:void 0,strokeColor:r,lineCap:"round",lineWidth:c,anchor:[.5,.5]},y=this.getTaskPoints(p);if(y.length){const S=Date.now();S-this.syncTimestamp>this.syncUnitTime&&(u=!0,this.syncTimestamp=S,this.syncIndex=this.tmpPoints.length),i&&this.draw({attrs:f,tasks:y,isDot:!1,layer:this.drawLayer||this.fullLayer})}const m=[];return this.tmpPoints.slice(d).forEach(S=>{m.push(S.x,S.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:b.DrawWork,dataType:H.Local,op:u?m:void 0,index:u?d*2:void 0,...this.baseConsumeResult}}consumeAll(){var n;const t=(n=this.workId)==null?void 0:n.toString();let e;if(this.tmpPoints.length-1>this.consumeIndex){let r=this.tmpPoints.slice(this.consumeIndex);const c=r.length===1,{strokeColor:l,thickness:h,strokeType:u}=this.workOptions;if(c){const f=this.computDotStroke({point:r[0],radius:h/2});r=f.ps,e=f.rect}else e=dt(this.tmpPoints,h);const d={name:t==null?void 0:t.toString(),fillColor:c?l:void 0,opacity:1,lineDash:u===_.Dotted&&!c?[1,h*2]:u===_.LongDotted&&!c?[h,h*2]:void 0,strokeColor:l,lineCap:c?void 0:"round",lineWidth:c?0:h,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 s=Dt(i);return{rect:e&&{x:e.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:e.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:e.w*this.fullLayer.worldScaling[0],h:e.h*this.fullLayer.worldScaling[1]},type:b.FullWork,dataType:H.Local,ops:s,index:this.syncIndex*2,...this.baseConsumeResult}}clearTmpPoints(){this.tmpPoints.length=0,this.syncTimestamp=0,this.syncIndex=0}consumeService(t){var y;const{op:e,replaceId:i,isFullWork:s}=t,{strokeColor:n,thickness:r,strokeType:c}=this.workOptions;if(!e.length){const m=dt(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(e||[]);let h,u=this.tmpPoints.slice(l);const d=u.length===1;if(d){const m=this.computDotStroke({point:u[0],radius:r/2});u=m.ps,h=m.rect}else h=dt(this.tmpPoints,r);const p={name:(y=this.workId)==null?void 0:y.toString(),fillColor:d?n:void 0,opacity:1,lineDash:c===_.Dotted&&!d?[1,r*2]:c===_.LongDotted&&!d?[r,r*2]:void 0,strokeColor:n,lineCap:d?void 0:"round",lineWidth:d?0:r,anchor:[.5,.5]},f=this.getTaskPoints(u);if(f.length){const m=s?this.fullLayer:this.drawLayer||this.fullLayer;this.draw({attrs:p,tasks:f,isDot:d,replaceId:i,layer:m})}return{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]}}computDotStroke(t){const{point:e,radius:i}=t,s={x:e.x-i,y:e.y-i,w:i*2,h:i*2};return{ps:F.GetDotStroke(e,i,8),rect:s}}updateTempPoints(t){const e=this.tmpPoints.length;for(let i=0;i<t.length;i+=2){if(e){const s=this.tmpPoints.slice(-1)[0];s&&s.x===t[i]&&s.y===t[i+1]&&this.tmpPoints.pop()}this.tmpPoints.push(new F(t[i],t[i+1]))}}async draw(t){const{attrs:e,tasks:i,isDot:s,layer:n}=t,{duration:r}=this.workOptions;for(const c of i){const l=new lt.Path,{pos:h,points:u}=c;let d;s?d=_t(u,!0):d=_t(u,!1),l.attr({...e,pos:h,d});const{vertex:p,fragment:f}=this.workOptions;if(p&&f){const y=n.renderer.createProgram({vertex:p,fragment:f}),{width:m,height:S}=n.getResolution();l.setUniforms({u_time:0,u_resolution:[m,S]}),l.setProgram(y)}n.appendChild(l),l.transition(r).attr({scale:s?[.1,.1]:[1,1],lineWidth:s?0:1}).then(()=>{l.remove()})}}getTaskPoints(t){var l;const e=[];if(t.length===0)return[];let i=0,s=t[0].x,n=t[0].y,r=[s,n],c=[];for(;i<t.length;){const h=t[i],u=h.x-s,d=h.y-n;if(c.push(new F(u,d)),i>0&&i<t.length-1){const p=t[i].getAngleByPoints(t[i-1],t[i+1]);if(p<90||p>270){const f=(l=c.pop())==null?void 0:l.clone();f&&e.push({pos:r,points:[...c,f]}),s=t[i].x,n=t[i].y,r=[s,n];const y=h.x-s,m=h.y-n;c=[new F(y,m)]}}i++}return e.push({pos:r,points:c}),e}removeLocal(){}removeService(t){let e;const i=[];return this.fullLayer.getElementsByName(t).forEach(s=>{if(s.name===t){const n=s.getBoundingClientRect();e=ut(e,{x:n.x,y:n.y,w:n.width,h:n.height}),i.push(s)}}),i.length&&i.forEach(s=>s.remove()),e}}const ge=class ge extends W{constructor(t,e){super(t);M(this,"canRotate",!1);M(this,"scaleType",ct.none);M(this,"toolsType",C.Eraser);M(this,"serviceWork");M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"worldPosition");M(this,"worldScaling");M(this,"eraserRect");M(this,"eraserPolyline");this.serviceWork=e,this.workOptions=t.toolsOpt,this.worldPosition=this.fullLayer.worldPosition,this.worldScaling=this.fullLayer.worldScaling}combineConsume(){}consumeService(){}setWorkOptions(t){super.setWorkOptions(t)}createEraserRect(t){const e=t[0]*this.worldScaling[0]+this.worldPosition[0],i=t[1]*this.worldScaling[1]+this.worldPosition[1],{width:s,height:n}=ge.eraserSizes[this.workOptions.thickness];this.eraserRect={x:e-s*.5,y:i-n*.5,w:s,h:n},this.eraserPolyline=[this.eraserRect.x,this.eraserRect.y,this.eraserRect.x+this.eraserRect.w,this.eraserRect.y+this.eraserRect.h]}computRectCenterPoints(){const t=this.tmpPoints.slice(-2);if(this.tmpPoints.length===4){const e=new k(this.tmpPoints[0],this.tmpPoints[1]),i=new k(this.tmpPoints[2],this.tmpPoints[3]),s=k.Sub(i,e).uni(),n=k.Dist(e,i),{width:r,height:c}=ge.eraserSizes[this.workOptions.thickness],l=Math.min(r,c),h=Math.round(n/l);if(h>1){const u=[];for(let d=0;d<h;d++){const p=k.Mul(s,d*l);u.push(this.tmpPoints[0]+p.x,this.tmpPoints[1]+p.y)}return u.concat(t)}}return t}isNear(t,e){const i=new k(t[0],t[1]),s=new k(e[0],e[1]),{width:n,height:r}=ge.eraserSizes[this.workOptions.thickness];return k.Dist(i,s)<Math.hypot(n,r)*.5}remove(t){const{curNodeMap:e,removeIds:i}=t;let s;for(const n of e.values())if(n.rect&&this.eraserRect&&this.eraserPolyline&&Ae(this.eraserRect,n.rect)){const{op:r}=n,c=[],l=[];for(let u=0;u<r.length;u+=3){const d=new k(r[u]*this.worldScaling[0]+this.worldPosition[0],r[u+1]*this.worldScaling[1]+this.worldPosition[1],r[u+2]);l.push(d),c.push(new F(d.x,d.y))}const h=c.length&&dt(c)||n.rect;Ae(h,this.eraserRect)&&(l.length>1?Do.polyline(l.map(d=>d.XY),this.eraserPolyline).length&&i.add(n.name):i.add(n.name),s=ut(s,h))}return i.forEach(n=>{var c;const r=this.fullLayer.getElementsByName(n);this.fullLayer.removeChild(r[0]),(c=this.vNodes)==null||c.delete(n)}),s&&(s.x-=W.SafeBorderPadding,s.y-=W.SafeBorderPadding,s.w+=W.SafeBorderPadding*2,s.h+=W.SafeBorderPadding*2),s}consume(t){const{op:e}=t.data;if(!e||e.length===0)return{type:b.None,...this.baseConsumeResult};const i=this.tmpPoints.length;if(i>1&&this.isNear([e[0],e[1]],[this.tmpPoints[i-2],this.tmpPoints[i-1]]))return{type:b.None,...this.baseConsumeResult};i<3?this.tmpPoints.push(e[0],e[1]):this.tmpPoints.splice(2,2,e[0],e[1]);const s=this.computRectCenterPoints();let n;const r=new Set;if(!this.vNodes)return{type:b.None,...this.baseConsumeResult};const c=this.getCanEraserNodeMap(this.vNodes.getCanEraserNodes(this.vNodes.curNodeMap));for(let l=0;l<s.length-1;l+=2){this.createEraserRect(s.slice(l,l+2));const h=this.remove({curNodeMap:c,removeIds:r});n=ut(n,h)}return n&&r.size?{type:b.RemoveNode,rect:n,removeIds:[...r]}:{type:b.None,...this.baseConsumeResult}}consumeAll(t){return this.consume(t)}clearTmpPoints(){this.tmpPoints.length=0}getCanEraserNodeMap(t){var e;if(this.serviceWork){const i=new Map(t),s=this.serviceWork.selectorWorkShapes,n=this.serviceWork.workShapes;for(const r of s.values())if((e=r.selectIds)!=null&&e.length)for(const c of r.selectIds)i.delete(c);for(const r of n.keys())i.delete(r);return i}return t}};M(ge,"eraserSizes",Object.freeze([Object.freeze({width:18,height:26}),Object.freeze({width:26,height:34}),Object.freeze({width:34,height:50})]));let Ge=ge;const Vt="++",$="selector",Fe="all";var mp="__lodash_hash_undefined__";function wp(a){return this.__data__.set(a,mp),this}var vp=wp;function Ip(a){return this.__data__.has(a)}var Np=Ip,Tp=Bi,Sp=vp,Cp=Np;function Ze(a){var o=-1,t=a==null?0:a.length;for(this.__data__=new Tp;++o<t;)this.add(a[o])}Ze.prototype.add=Ze.prototype.push=Sp;Ze.prototype.has=Cp;var kp=Ze;function xp(a,o){for(var t=-1,e=a==null?0:a.length;++t<e;)if(o(a[t],t,a))return!0;return!1}var zp=xp;function bp(a,o){return a.has(o)}var Pp=bp,Lp=kp,Dp=zp,jp=Pp,Ap=1,Ep=2;function Op(a,o,t,e,i,s){var n=t&Ap,r=a.length,c=o.length;if(r!=c&&!(n&&c>r))return!1;var l=s.get(a),h=s.get(o);if(l&&h)return l==o&&h==a;var u=-1,d=!0,p=t&Ep?new Lp:void 0;for(s.set(a,o),s.set(o,a);++u<r;){var f=a[u],y=o[u];if(e)var m=n?e(y,f,u,o,a,s):e(f,y,u,a,o,s);if(m!==void 0){if(m)continue;d=!1;break}if(p){if(!Dp(o,function(S,w){if(!jp(p,w)&&(f===S||i(f,S,t,e,s)))return p.push(w)})){d=!1;break}}else if(!(f===y||i(f,y,t,e,s))){d=!1;break}}return s.delete(a),s.delete(o),d}var ps=Op;function Rp(a){var o=-1,t=Array(a.size);return a.forEach(function(e,i){t[++o]=[i,e]}),t}var Yp=Rp;function Wp(a){var o=-1,t=Array(a.size);return a.forEach(function(e){t[++o]=e}),t}var Up=Wp,mi=io,wi=ss,Bp=jo,Vp=ps,Fp=Yp,Hp=Up,$p=1,Qp=2,Gp="[object Boolean]",Zp="[object Date]",qp="[object Error]",Jp="[object Map]",Xp="[object Number]",Kp="[object RegExp]",_p="[object Set]",tf="[object String]",ef="[object Symbol]",of="[object ArrayBuffer]",sf="[object DataView]",vi=mi?mi.prototype:void 0,Mo=vi?vi.valueOf:void 0;function nf(a,o,t,e,i,s,n){switch(t){case sf:if(a.byteLength!=o.byteLength||a.byteOffset!=o.byteOffset)return!1;a=a.buffer,o=o.buffer;case of:return!(a.byteLength!=o.byteLength||!s(new wi(a),new wi(o)));case Gp:case Zp:case Xp:return Bp(+a,+o);case qp:return a.name==o.name&&a.message==o.message;case Kp:case tf:return a==o+"";case Jp:var r=Fp;case _p:var c=e&$p;if(r||(r=Hp),a.size!=o.size&&!c)return!1;var l=n.get(a);if(l)return l==o;e|=Qp,n.set(a,o);var h=Vp(r(a),r(o),e,i,s,n);return n.delete(a),h;case ef:if(Mo)return Mo.call(a)==Mo.call(o)}return!1}var rf=nf,Ii=os,af=1,cf=Object.prototype,lf=cf.hasOwnProperty;function hf(a,o,t,e,i,s){var n=t&af,r=Ii(a),c=r.length,l=Ii(o),h=l.length;if(c!=h&&!n)return!1;for(var u=c;u--;){var d=r[u];if(!(n?d in o:lf.call(o,d)))return!1}var p=s.get(a),f=s.get(o);if(p&&f)return p==o&&f==a;var y=!0;s.set(a,o),s.set(o,a);for(var m=n;++u<c;){d=r[u];var S=a[d],w=o[d];if(e)var v=n?e(w,S,d,o,a,s):e(S,w,d,a,o,s);if(!(v===void 0?S===w||i(S,w,t,e,s):v)){y=!1;break}m||(m=d=="constructor")}if(y&&!m){var T=a.constructor,N=o.constructor;T!=N&&"constructor"in a&&"constructor"in o&&!(typeof T=="function"&&T instanceof T&&typeof N=="function"&&N instanceof N)&&(y=!1)}return s.delete(a),s.delete(o),y}var uf=hf,yo=Vi,df=ps,pf=rf,ff=uf,Ni=ho,Ti=lo,Si=Eo,gf=Gi,Mf=1,Ci="[object Arguments]",ki="[object Array]",Ye="[object Object]",yf=Object.prototype,xi=yf.hasOwnProperty;function mf(a,o,t,e,i,s){var n=Ti(a),r=Ti(o),c=n?ki:Ni(a),l=r?ki:Ni(o);c=c==Ci?Ye:c,l=l==Ci?Ye:l;var h=c==Ye,u=l==Ye,d=c==l;if(d&&Si(a)){if(!Si(o))return!1;n=!0,h=!1}if(d&&!h)return s||(s=new yo),n||gf(a)?df(a,o,t,e,i,s):pf(a,o,c,t,e,i,s);if(!(t&Mf)){var p=h&&xi.call(a,"__wrapped__"),f=u&&xi.call(o,"__wrapped__");if(p||f){var y=p?a.value():a,m=f?o.value():o;return s||(s=new yo),i(y,m,t,e,s)}}return d?(s||(s=new yo),ff(a,o,t,e,i,s)):!1}var wf=mf,vf=wf,zi=qt;function fs(a,o,t,e,i){return a===o?!0:a==null||o==null||!zi(a)&&!zi(o)?a!==a&&o!==o:vf(a,o,t,e,fs,i)}var If=fs,Nf=If;function Tf(a,o){return Nf(a,o)}var Sf=Tf;const pe=Ie(Sf),eo=class eo extends W{constructor(t){super(t);M(this,"toolsType",C.Selector);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"vNodes");M(this,"selectIds");M(this,"selectorColor");M(this,"strokeColor");M(this,"fillColor");M(this,"oldSelectRect");M(this,"canRotate",!1);M(this,"canTextEdit",!1);M(this,"canLock",!1);M(this,"scaleType",ct.all);M(this,"toolsTypes");M(this,"shapeOpt");M(this,"textOpt");M(this,"isLocked");M(this,"thickness");M(this,"strokeType");M(this,"useStroke");this.workOptions=t.toolsOpt,this.vNodes=t.vNodes}computSelector(t=!0){const e=dt(this.tmpPoints);if(e.w===0||e.h===0)return{selectIds:[],intersectRect:void 0,subNodeMap:new Map};const{rectRange:i,nodeRange:s}=this.vNodes.getRectIntersectRange(e,t);return{selectIds:[...s.keys()],intersectRect:i,subNodeMap:s}}updateTempPoints(t){const e=this.tmpPoints.length,i=t.length;if(i>1){const s=new F(t[i-2]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],t[i-1]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[1]);e===2?this.tmpPoints.splice(1,1,s):this.tmpPoints.push(s)}}drawSelector(t){const{drawRect:e,subNodeMap:i,selectorId:s,layer:n,isService:r}=t,c=new lt.Group({pos:[e.x,e.y],anchor:[0,0],size:[e.w,e.h],id:s,name:s,zIndex:9999}),l=[];if(r){const h=new lt.Rect({normalize:!0,pos:[e.w/2,e.h/2],lineWidth:1,strokeColor:this.selectorColor||this.workOptions.strokeColor,width:e.w,height:e.h,name:eo.selectorBorderId});l.push(h)}i.forEach((h,u)=>{const d=[h.rect.x+h.rect.w/2-e.x,h.rect.y+h.rect.h/2-e.y],p=new lt.Rect({normalize:!0,pos:d,lineWidth:1,strokeColor:i.size>1?this.selectorColor||this.workOptions.strokeColor:void 0,width:h.rect.w,height:h.rect.h,id:`selector-${u}`,name:`selector-${u}`});l.push(p)}),l&&c.append(...l),(n==null?void 0:n.parent).appendChild(c)}draw(t,e,i,s=!1){var c,l;const{intersectRect:n,subNodeMap:r}=i;(l=(c=e.parent)==null?void 0:c.getElementById(t))==null||l.remove(),n&&this.drawSelector({drawRect:n,subNodeMap:r,selectorId:t,layer:e,isService:s})}getSelecteorInfo(t){this.scaleType=ct.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 e=new Set;let i,s=!0;for(const n of t.values()){const{opt:r,canRotate:c,scaleType:l,toolsType:h}=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),h!==C.Pencil&&(s=!1),r.strokeType&&(this.strokeType=r.strokeType),h===C.SpeechBalloon&&(e.add(h),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.placement=r.placement),h===C.Polygon&&(e.add(h),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=r.vertices),h===C.Star&&(e.add(h),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=r.vertices,this.shapeOpt.innerRatio=r.innerRatio,this.shapeOpt.innerVerticeStep=r.innerVerticeStep),h===C.Text&&(this.textOpt=r),t.size===1&&(this.textOpt&&(this.canTextEdit=!0),this.canRotate=c,this.scaleType=l),l===ct.none&&(this.scaleType=l),h===C.Image&&(i=n)}s&&(this.useStroke=!0),e.size&&(this.toolsTypes=[...e]),i&&(t.size===1?(this.canLock=!0,i.opt.locked&&(this.isLocked=!0,this.scaleType=ct.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)):t.size>1&&!i.opt.locked&&(this.canLock=!1,this.canRotate=!1))}getChildrenPoints(){var t,e;if(this.scaleType===ct.both&&((t=this.selectIds)==null?void 0:t.length)===1){const i=this.selectIds[0],s=(e=this.vNodes.get(i))==null?void 0:e.op;if(s){const n=[];for(let r=0;r<s.length;r+=3)n.push([s[r],s[r+1]]);return n}}}consume(t){const{op:e,workState:i}=t.data;let s=this.oldSelectRect;if(i===D.Start&&(s=this.unSelectedAllIds()),!(e!=null&&e.length)||!this.vNodes.curNodeMap.size)return{type:b.None};this.updateTempPoints(e);const n=this.computSelector();if(this.selectIds&&pe(this.selectIds,n.selectIds))return{type:b.None};this.selectIds=n.selectIds;const r=n.intersectRect;this.getSelecteorInfo(n.subNodeMap),this.draw($,this.fullLayer,n),this.oldSelectRect=r;const c=this.getChildrenPoints();return{type:b.Select,dataType:H.Local,rect:ut(r,s),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 e,i;let t=this.oldSelectRect;if(!((e=this.selectIds)!=null&&e.length)&&this.tmpPoints[0]&&this.selectSingleTool(this.tmpPoints[0].XY,$,!1),(i=this.selectIds)!=null&&i.length&&(t=this.selectedByIds(this.selectIds)),t){const s=this.getChildrenPoints();return{type:b.Select,dataType:H.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:s,isLocked:this.isLocked,toolsTypes:this.toolsTypes,shapeOpt:this.shapeOpt,thickness:this.thickness,useStroke:this.useStroke,strokeType:this.strokeType,...this.baseConsumeResult}}return{type:b.None}}consumeService(){}clearTmpPoints(){this.tmpPoints.length=0}clearSelectData(){this.selectIds=void 0,this.oldSelectRect=void 0}selectSingleTool(t,e=$,i=!1){if(t.length===2){const s=t[0],n=t[1];let r;const{nodeRange:c}=this.vNodes.getRectIntersectRange({x:s,y:n,w:0,h:0},!1),l=[...c.values()].sort((h,u)=>(u.opt.zIndex||0)-(h.opt.zIndex||0));for(const h of l){const u=this.fullLayer.getElementsByName(h.name);if(Ss(u).find(p=>p.isPointCollision(s,n))){r=h;break}}if(r){const h=r.name;if(!pe(this.oldSelectRect,r.rect)){const u=new Map([[h,r]]);this.getSelecteorInfo(u),this.draw(e,this.fullLayer,{intersectRect:r.rect,subNodeMap:u,selectIds:this.selectIds||[]},i)}this.selectIds=[h],this.oldSelectRect=r.rect}}}unSelectedAllIds(){let t;for(const[e,i]of this.vNodes.curNodeMap.entries())i.isSelected&&(t=ut(t,i.rect),this.vNodes.unSelected(e));return t}unSelectedByIds(t){let e;for(const i of t){const s=this.vNodes.get(i);s&&s.isSelected&&(e=ut(e,s.rect),this.vNodes.unSelected(i))}return e}selectedByIds(t){let e;for(const i of t){const s=this.vNodes.get(i);s&&(e=ut(e,s.rect),this.vNodes.selected(i))}return e}getSelectorRect(t,e){var r;let i;const s=(r=t.parent)==null?void 0:r.getElementById(e),n=s==null?void 0:s.getBoundingClientRect();return n&&(i=ut(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(t){return t===C.Ellipse||t===C.Triangle||t===C.Rectangle||t===C.Polygon||t===C.Star||t===C.SpeechBalloon}async updateSelector(t){var N;const{updateSelectorOpt:e,selectIds:i,vNodes:s,willSerializeData:n,worker:r,offset:c}=t,l=this.fullLayer;if(!l)return;let h;const u=new Map,{originPoint:d,workState:p,angle:f,translate:y,dir:m,scale:S}=e;c&&(y?e.translate=[y[0]+c[0],y[1]+c[1]]:e.translate=c);let w;if(d||y||Qt(f)){if(p===D.Start&&i)return s.setTargetAssignKeys(i),{type:b.Select,dataType:H.Local,selectRect:this.oldSelectRect,rect:this.oldSelectRect};w=s.getLastTarget()}if(i)for(const I of i){const x=s.get(I);if(x){const{toolsType:z}=x,A=(l==null?void 0:l.getElementsByName(I))[0];if(A){let E=!1,j=!1;const O={...e};let P;if(z){O.thickness&&x.opt.thickness&&(E=x.opt.thickness!==O.thickness),O.strokeType&&((N=x.opt)!=null&&N.strokeType)&&(j=x.opt.strokeType!==O.strokeType),P=w==null?void 0:w.get(I);const Y=Ns(z);if(Y==null||Y.updateNodeOpt({node:A,opt:O,vNodes:s,willSerializeData:n,targetNode:P}),x&&r&&(n&&(O.angle||O.translate)||O.originPoint&&O.scenePoint&&O.scale||O.pointMap&&O.pointMap.has(I)||z===C.Text&&(O.fontSize||O.translate||O.textInfos&&O.textInfos.get(I))||z===C.Image&&(O.angle||O.translate||O.scale)||z===O.toolsType&&O.willRefresh||E||j)){const ot=r.createWorkShapeNode({workId:I,toolsType:z,toolsOpt:x.opt});ot==null||ot.setWorkId(I);let tt;if(z===C.Image)tt=await ot.consumeServiceAsync({isFullWork:!0,replaceId:I,worker:r});else if(z===C.Text)tt=await ot.consumeServiceAsync({isFullWork:!0,replaceId:I});else try{tt=ot==null?void 0:ot.consumeService({op:x.op,isFullWork:!0,replaceId:I})}catch{continue}tt&&(x.rect=tt)}x&&(u.set(I,x),h=ut(h,x.rect))}}}}w&&p===D.Done&&(s.deleteLastTarget(),w=void 0);const v=h;if(d&&y&&S&&m&&v&&!c){const I=[[v.x,v.y],[v.x+v.w,v.y],[v.x+v.w,v.y+v.h],[v.x,v.y+v.h]];let x;switch(m){case"top":case"topLeft":case"left":y[0]>0&&y[1]>0?x=I[0]:y[0]>0?x=I[3]:y[1]>0?x=I[1]:x=I[2];break;case"topRight":y[0]<0&&y[1]>0?x=I[1]:y[0]<0?x=I[2]:y[1]>0?x=I[0]:x=I[3];break;case"right":case"bottomRight":case"bottom":y[0]<0&&y[1]<0?x=I[2]:y[0]<0?x=I[1]:y[1]<0?x=I[3]:x=I[0];break;case"bottomLeft":y[0]>0&&y[1]<0?x=I[3]:y[0]>0?x=I[0]:y[1]<0?x=I[2]:x=I[1];break}const z=x&&[d[0]-x[0],d[1]-x[1]]||[0,0];if(!pe(z,[0,0]))return await this.updateSelector({...t,updateSelectorOpt:{},offset:z})}this.getSelecteorInfo(u),this.draw($,l,{selectIds:i||[],subNodeMap:u,intersectRect:v});const T=ut(this.oldSelectRect,v);return this.oldSelectRect=v,{type:b.Select,dataType:H.Local,selectRect:v,renderRect:h,rect:ut(T,v),selectIds:i}}blurSelector(){const t=this.unSelectedAllIds();return{type:b.Select,dataType:H.Local,rect:t,selectIds:[],willSyncService:!0}}getRightServiceId(t){return t.replace(Vt,"-")}selectServiceNode(t,e,i){const{selectIds:s}=e,n=this.getRightServiceId(t),r=this.getSelectorRect(this.fullLayer,n);let c;const l=new Map;return s==null||s.forEach(h=>{const u=this.vNodes.get(h);u&&(c=ut(c,u.rect),l.set(h,u))}),this.getSelecteorInfo(l),this.draw(n,this.fullLayer,{intersectRect:c,selectIds:s||[],subNodeMap:l},i),ut(c,r)}reRenderSelector(){var i;let t;const e=new Map;return(i=this.selectIds)==null||i.forEach(s=>{const n=this.vNodes.get(s);n&&(t=ut(t,n.rect),e.set(s,n))},this),this.getSelecteorInfo(e),this.draw($,this.fullLayer,{intersectRect:t,subNodeMap:e,selectIds:this.selectIds||[]}),this.oldSelectRect=t,t}updateSelectIds(t){var n;let e;const i=(n=this.selectIds)==null?void 0:n.filter(r=>!t.includes(r));if(i!=null&&i.length&&(e=this.unSelectedByIds(i)),t.length){const r=this.selectedByIds(t);e=ut(e,r)}this.selectIds=t;const s=this.reRenderSelector();return{bgRect:e,selectRect:s}}cursorHover(t){var n,r;const e=this.oldSelectRect;this.selectIds=[];const i=(n=this.workId)==null?void 0:n.toString(),s=[t[0]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],t[1]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[1]];if(this.selectSingleTool(s,i,!0),this.oldSelectRect&&!pe(e,this.oldSelectRect))return{type:b.CursorHover,dataType:H.Local,rect:ut(e,this.oldSelectRect),selectorColor:this.selectorColor,willSyncService:!1};if((r=this.selectIds)!=null&&r.length||(this.oldSelectRect=void 0),e&&!this.oldSelectRect)return this.cursorBlur(),{type:b.CursorHover,dataType:H.Local,rect:e,selectorColor:this.selectorColor,willSyncService:!1}}cursorBlur(){var e,i;this.selectIds=[];const t=(e=this.workId)==null?void 0:e.toString();((i=this.fullLayer)==null?void 0:i.parent).children.forEach(s=>{s.name===t&&s.remove()})}};M(eo,"selectorBorderId","selector-border");let qe=eo;class gs extends W{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",ct.both);M(this,"toolsType",C.Arrow);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"arrowTipWidth");M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.arrowTipWidth=this.workOptions.thickness*4,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){const{data:e,isFullWork:i,isSubWorker:s,isMainThread:n}=t,r=this.workId,{op:c}=e,l=c==null?void 0:c.length;if(!l||l<2)return{type:b.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new F(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:b.None};let u;if(s||n){const p=i?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({workId:r,layer:p})}if(!s){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{...this.baseConsumeResult,type:b.DrawWork,dataType:H.Local,op:this.tmpPoints.map(f=>[...f.XY,0]).flat(1),isSync:!0,index:0}):{type:b.None}}const d=ut(u,this.oldRect);return this.oldRect=u,{rect:d,...this.baseConsumeResult,type:b.DrawWork,dataType:H.Local}}consumeAll(){var r;const t=this.workId;if(this.tmpPoints.length<2)return{type:b.RemoveNode,removeIds:[t]};const e=this.fullLayer,i=this.draw({workId:t,layer:e});this.oldRect=i;const s=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=Dt(s);return(r=this.vNodes)==null||r.setInfo(t,{rect:i,op:s,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:W.getCenterPos(i,e)}),{rect:i,...this.baseConsumeResult,type:b.FullWork,dataType:H.Local,ops:n,isSync:!0}}draw(t){const{workId:e,layer:i}=t,{strokeColor:s,thickness:n,zIndex:r,scale:c,rotate:l,translate:h,strokeType:u,eraserlines:d}=this.workOptions,p=i.worldPosition,f=i.worldScaling,{points:y,pos:m,rect:S,isTriangle:w,trianglePoints:v,trianglePos:T}=this.computDrawPoints(n),N=[S.x+S.w/2,S.y+S.h/2],I={pos:N,name:e,id:e,zIndex:r,anchor:[.5,.5],size:[S.w,S.h]};c&&(I.scale=c),l&&(I.rotate=l),h&&(I.translate=h);const x=new lt.Group(I),z={points:v,pos:[T[0]-N[0],T[1]-N[1]],fillColor:s,strokeColor:s,lineWidth:0,normalize:!1},A=new lt.Polyline(z);if(x.append(A),!w&&y&&m){const E={points:y,pos:[m[0]-N[0],m[1]-N[1]],fillColor:s,strokeColor:s,lineDash:u===_.Dotted&&!w?[1,n*2]:u===_.LongDotted&&!w?[n,n*2]:void 0,lineCap:u===_.Normal?void 0:"round",lineWidth:n,normalize:!1},j=new lt.Polyline(E);x.append(j)}if(d&&this.drawEraserlines({group:x,eraserlines:d,pos:N,layer:i}),this.replace(i,e,x),c||l||h){const E=x.getBoundingClientRect();return{x:Math.floor(E.x-W.SafeBorderPadding),y:Math.floor(E.y-W.SafeBorderPadding),w:Math.floor(E.width+W.SafeBorderPadding*2),h:Math.floor(E.height+W.SafeBorderPadding*2)}}return{x:Math.floor(S.x*f[0]+p[0]-W.SafeBorderPadding),y:Math.floor(S.y*f[1]+p[1]-W.SafeBorderPadding),w:Math.floor(S.w*f[0]+2*W.SafeBorderPadding),h:Math.floor(S.h*f[1]+2*W.SafeBorderPadding)}}computDrawPoints(t){return this.tmpPoints[1].distance(this.tmpPoints[0])>this.arrowTipWidth?this.computFullArrowPoints(t):this.computTrianglePoints()}computFullArrowPoints(t){const e=k.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),i=k.Per(e).mul(t/2),s=F.Sub(this.tmpPoints[0],i),n=F.Add(this.tmpPoints[0],i),r=k.Mul(e,this.arrowTipWidth),c=k.Sub(this.tmpPoints[1],r),l=F.Sub(c,i),h=F.Add(c,i),u=k.Per(e).mul(t*1.5),d=F.Sub(c,u),p=F.Add(c,u),f=[this.tmpPoints[0],c],y=[d,this.tmpPoints[1],p],m=[s,n,...y,l,h];return{trianglePoints:y.map(S=>F.Sub(S,this.tmpPoints[1]).XY).flat(1),trianglePos:this.tmpPoints[1].XY,points:f.map(S=>F.Sub(S,this.tmpPoints[0]).XY).flat(1),rect:dt(m),isTriangle:!1,pos:this.tmpPoints[0].XY}}computTrianglePoints(){const t=k.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),e=this.tmpPoints[1].distance(this.tmpPoints[0]),i=k.Per(t).mul(Math.floor(e*3/8)),s=F.Sub(this.tmpPoints[0],i),n=F.Add(this.tmpPoints[0],i),r=[s,this.tmpPoints[1],n];return{trianglePoints:r.map(c=>F.Sub(c,this.tmpPoints[1]).XY).flat(1),trianglePos:this.tmpPoints[1].XY,rect:dt(r),isTriangle:!0}}updateTempPoints(t){const e=t.slice(-2),i=new F(e[0],e[1]),s=this.tmpPoints[0],{thickness:n}=this.workOptions;if(s.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(t){var c,l;const{op:e,isFullWork:i}=t,s=(c=this.workId)==null?void 0:c.toString();if(!s)return;this.tmpPoints.length=0;for(let h=0;h<e.length;h+=3)this.tmpPoints.push(new F(e[h],e[h+1],e[h+2]));const n=i?this.fullLayer:this.drawLayer||this.fullLayer,r=this.draw({workId:s,layer:n});return this.oldRect=r,(l=this.vNodes)==null||l.setInfo(s,{rect:r,op:e,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:W.getCenterPos(r,n)}),r}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var l,h;const{node:e,opt:i,vNodes:s}=t,{strokeColor:n,strokeType:r}=i,c=s.get(e.name);return n&&(e.tagName==="GROUP"?e.children.forEach(u=>{u.setAttribute("strokeColor",n),u.getAttribute("fillColor")&&u.setAttribute("fillColor",n)}):(e.setAttribute("strokeColor",n),e.setAttribute("fillColor",n)),(l=c==null?void 0:c.opt)!=null&&l.strokeColor&&(c.opt.strokeColor=n)),r&&(c!=null&&c.opt)&&((h=c.opt)!=null&&h.strokeType)&&(c.opt.strokeType=r),c&&s.setInfo(e.name,c),W.updateNodeOpt(t)}}class Ms extends W{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",ct.all);M(this,"toolsType",C.Ellipse);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){const{data:e,isFullWork:i,isSubWorker:s,isMainThread:n}=t,r=this.workId,{op:c}=e,l=c==null?void 0:c.length;if(!l||l<2)return{type:b.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new F(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:b.None};let u;if(s||n){const p=i?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({workId:r,layer:p,isDrawing:!0})}if(!s){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{type:b.DrawWork,dataType:H.Local,...this.baseConsumeResult,op:this.tmpPoints.map(f=>[...f.XY,0]).flat(1),isSync:!0,index:0}):{type:b.None}}const d=ut(u,this.oldRect);return this.oldRect=u,{rect:d,type:b.DrawWork,dataType:H.Local,...this.baseConsumeResult}}consumeAll(){var r;const t=this.workId;if(this.tmpPoints.length<2)return{type:b.RemoveNode,removeIds:[t]};const e=this.fullLayer,i=this.draw({workId:t,layer:e,isDrawing:!1});this.oldRect=i;const s=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=Dt(s);return(r=this.vNodes)==null||r.setInfo(t,{rect:i,op:s,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:i&&W.getCenterPos(i,e)}),{rect:i,type:b.FullWork,dataType:H.Local,...this.baseConsumeResult,ops:n,isSync:!0}}draw(t){const{workId:e,layer:i,isDrawing:s}=t,{strokeColor:n,fillColor:r,thickness:c,zIndex:l,scale:h,rotate:u,translate:d,strokeType:p,eraserlines:f}=this.workOptions,y=i.worldScaling,{radius:m,rect:S,pos:w}=this.computDrawPoints(c),v={pos:w,name:e,id:e,radius:m,lineWidth:c,fillColor:r!=="transparent"&&r||void 0,strokeColor:n,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:p===_.Dotted?[1,c*2]:p===_.LongDotted?[c,c*2]:void 0},T={name:e,id:e,zIndex:l,pos:w,anchor:[.5,.5],size:[S.w,S.h]};h&&(T.scale=h),u&&(T.rotate=u),d&&(T.translate=d);const N=new lt.Group(T);if(s){const z=new lt.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:n,lineWidth:1,scale:[1/y[0],1/y[1]]});N.append(z)}const I=new lt.Ellipse({...v,pos:[0,0]});N.append(I),f&&this.drawEraserlines({group:N,eraserlines:f,pos:w,layer:i}),this.replace(i,e,N);const x=N.getBoundingClientRect();return{x:Math.floor(x.x-W.SafeBorderPadding),y:Math.floor(x.y-W.SafeBorderPadding),w:Math.floor(x.width+W.SafeBorderPadding*2),h:Math.floor(x.height+W.SafeBorderPadding*2)}}computDrawPoints(t){const e=dt(this.tmpPoints),i=dt(this.tmpPoints,t),s=[Math.floor(e.x+e.w/2),Math.floor(e.y+e.h/2)];return{rect:i,pos:s,radius:[Math.floor(e.w/2),Math.floor(e.h/2)]}}updateTempPoints(t){const e=t.slice(-2),i=new F(e[0],e[1]),s=this.tmpPoints[0],{thickness:n}=this.workOptions;if(s.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(t){var c,l;const{op:e,isFullWork:i}=t,s=(c=this.workId)==null?void 0:c.toString();if(!s)return;this.tmpPoints.length=0;for(let h=0;h<e.length;h+=3)this.tmpPoints.push(new F(e[h],e[h+1],e[h+2]));const n=i?this.fullLayer:this.drawLayer||this.fullLayer,r=this.draw({workId:s,layer:n,isDrawing:!1});return this.oldRect=r,(l=this.vNodes)==null||l.setInfo(s,{rect:r,op:e,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:W.getCenterPos(r,n)}),r}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var u,d,p;const{node:e,opt:i,vNodes:s}=t,{strokeColor:n,fillColor:r,strokeType:c}=i,l=s.get(e.name);let h=e;return e.tagName==="GROUP"&&(h=e.children[0]),n&&(h.setAttribute("strokeColor",n),(u=l==null?void 0:l.opt)!=null&&u.strokeColor&&(l.opt.strokeColor=n)),r&&(r==="transparent"?h.setAttribute("fillColor","rgba(0,0,0,0)"):h.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&&s.setInfo(e.name,l),W.updateNodeOpt(t)}}class ys extends W{constructor(t){super(t);M(this,"canRotate",!0);M(this,"scaleType",ct.all);M(this,"toolsType",C.Rectangle);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}transformData(){const t=dt(this.tmpPoints);return[[t.x,t.y,0],[t.x+t.w,t.y,0],[t.x+t.w,t.y+t.h,0],[t.x,t.y+t.h,0]]}computDrawPoints(t){const{thickness:e}=this.workOptions,i=[];for(const r of t)i.push(new k(...r));const s=dt(i,e),n=[s.x+s.w/2,s.y+s.h/2];return{rect:s,pos:n,points:i.map(r=>r.XY).flat(1)}}consume(t){const{data:e,isFullWork:i,isSubWorker:s,isMainThread:n}=t,r=this.workId,{op:c}=e,l=c==null?void 0:c.length;if(!l||l<2)return{type:b.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new F(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:b.None};const u=this.transformData();let d;if(s||n){const f=i?this.fullLayer:this.drawLayer||this.fullLayer;d=this.draw({ps:u,workId:r,layer:f,isDrawing:!0})}if(!s){const f=Date.now();return f-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=f,{type:b.DrawWork,dataType:H.Local,op:u.flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:b.None}}const p=ut(d,this.oldRect);return this.oldRect=d,{rect:p,type:b.DrawWork,dataType:H.Local,...this.baseConsumeResult}}consumeAll(){var c;const t=this.workId;if(this.tmpPoints.length<2)return{type:b.RemoveNode,removeIds:[t]};const e=this.transformData(),i=this.fullLayer,s=this.draw({ps:e,workId:t,layer:i,isDrawing:!1});this.oldRect=s;const n=e.flat(1),r=Dt(n);return(c=this.vNodes)==null||c.setInfo(t,{rect:s,op:n,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:s&&W.getCenterPos(s,i)}),{rect:s,type:b.FullWork,dataType:H.Local,ops:r,isSync:!0,...this.baseConsumeResult}}draw(t){const{workId:e,layer:i,isDrawing:s,ps:n,replaceId:r}=t,{strokeColor:c,fillColor:l,thickness:h,zIndex:u,scale:d,rotate:p,translate:f,strokeType:y,eraserlines:m}=this.workOptions,S=i.worldPosition,w=i.worldScaling,{points:v,rect:T,pos:N}=this.computDrawPoints(n),I={close:!0,normalize:!0,points:v,lineWidth:h,fillColor:l!=="transparent"&&l||void 0,strokeColor:c,lineJoin:"round",lineCap:"round",lineDash:y===_.Dotted?[1,h*2]:y===_.LongDotted?[h,h*2]:void 0},x={x:Math.floor(T.x*w[0]+S[0]-W.SafeBorderPadding),y:Math.floor(T.y*w[1]+S[1]-W.SafeBorderPadding),w:Math.floor(T.w*w[0]+2*W.SafeBorderPadding),h:Math.floor(T.h*w[0]+2*W.SafeBorderPadding)},z=new lt.Group({name:e,id:e,zIndex:u,pos:N,anchor:[.5,.5],size:[T.w,T.h],scale:d,rotate:p,translate:f}),A=new lt.Polyline({...I,pos:[0,0]});if(z.appendChild(A),s){const E=new lt.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:c,lineWidth:1,scale:[1/w[0],1/w[1]]});z.appendChild(E)}if(m&&this.drawEraserlines({group:z,eraserlines:m,pos:N,layer:i}),this.replace(i,r||e,z),d||p||f){const E=z.getBoundingClientRect();return{x:Math.floor(E.x-W.SafeBorderPadding),y:Math.floor(E.y-W.SafeBorderPadding),w:Math.floor(E.width+2*W.SafeBorderPadding),h:Math.floor(E.height+2*W.SafeBorderPadding)}}return x}updateTempPoints(t){const e=t.slice(-2),i=new F(e[0],e[1]),s=this.tmpPoints[0],{thickness:n}=this.workOptions;if(s.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(t){var h,u;const{op:e,isFullWork:i,replaceId:s}=t,n=(h=this.workId)==null?void 0:h.toString();if(!n)return;const r=[];for(let d=0;d<e.length;d+=3)r.push([e[d],e[d+1],e[d+2]]);const c=i?this.fullLayer:this.drawLayer||this.fullLayer,l=this.draw({ps:r,workId:n,layer:c,isDrawing:!1,replaceId:s});return this.oldRect=l,(u=this.vNodes)==null||u.setInfo(n,{rect:l,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:l&&W.getCenterPos(l,c)}),l}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var u,d,p;const{node:e,opt:i,vNodes:s}=t,{strokeColor:n,fillColor:r,strokeType:c}=i,l=s.get(e.name);let h=e;return e.tagName==="GROUP"&&(h=e.children[0]),n&&(h.setAttribute("strokeColor",n),(u=l==null?void 0:l.opt)!=null&&u.strokeColor&&(l.opt.strokeColor=n)),r&&(r==="transparent"?h.setAttribute("fillColor","rgba(0,0,0,0)"):h.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&&s.setInfo(e.name,l),W.updateNodeOpt(t)}}class ms extends W{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",ct.all);M(this,"toolsType",C.Star);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){const{data:e,isFullWork:i,isSubWorker:s,isMainThread:n}=t,r=this.workId,{op:c}=e,l=c==null?void 0:c.length;if(!l||l<2)return{type:b.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new F(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:b.None};let u;if(s||n){const p=i?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({workId:r,layer:p,isDrawing:!0})}if(!s){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{type:b.DrawWork,dataType:H.Local,op:this.tmpPoints.map(f=>[...f.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:b.None}}const d=ut(u,this.oldRect);return this.oldRect=u,{rect:d,type:b.DrawWork,dataType:H.Local,...this.baseConsumeResult}}consumeAll(){var r;const t=this.workId;if(this.tmpPoints.length<2)return{type:b.RemoveNode,removeIds:[t]};const e=this.fullLayer,i=this.draw({workId:t,layer:e,isDrawing:!1});this.oldRect=i;const s=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=Dt(s);return(r=this.vNodes)==null||r.setInfo(t,{rect:i,op:s,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:i&&W.getCenterPos(i,e)}),{rect:i,type:b.FullWork,dataType:H.Local,ops:n,isSync:!0,...this.baseConsumeResult}}draw(t){const{workId:e,layer:i,isDrawing:s}=t,{strokeColor:n,fillColor:r,thickness:c,zIndex:l,vertices:h,innerVerticeStep:u,innerRatio:d,scale:p,rotate:f,translate:y,strokeType:m,eraserlines:S}=this.workOptions,w=i.worldScaling,{rect:v,pos:T,points:N}=this.computDrawPoints(c,h,u,d),I={close:!0,points:N,lineWidth:c,fillColor:r!=="transparent"&&r||void 0,strokeColor:n,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:m===_.Dotted?[1,c*2]:m===_.LongDotted?[c,c*2]:void 0},x={name:e,id:e,zIndex:l,pos:T,anchor:[.5,.5],size:[v.w,v.h]};p&&(x.scale=p),f&&(x.rotate=f),y&&(x.translate=y);const z=new lt.Group(x);if(s){const j=new lt.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:n,lineWidth:1,scale:[1/w[0],1/w[1]]});z.append(j)}const A=new lt.Polyline({...I,pos:[0,0]});z.append(A),S&&this.drawEraserlines({group:z,eraserlines:S,pos:T,layer:i}),this.replace(i,e,z);const E=z.getBoundingClientRect();return{x:Math.floor(E.x-W.SafeBorderPadding),y:Math.floor(E.y-W.SafeBorderPadding),w:Math.floor(E.width+W.SafeBorderPadding*2),h:Math.floor(E.height+W.SafeBorderPadding*2)}}computDrawPoints(t,e,i,s){const n=dt(this.tmpPoints),r=[Math.floor(n.x+n.w/2),Math.floor(n.y+n.h/2)],c=xs(n.w,n.h),l=Math.floor(Math.min(n.w,n.h)/2),h=s*l,u=[],d=2*Math.PI/e;for(let f=0;f<e;f++){const y=f*d-.5*Math.PI;let m,S;f%i===1?(m=h*c[0]*Math.cos(y),S=h*c[1]*Math.sin(y)):(m=l*c[0]*Math.cos(y),S=l*c[1]*Math.sin(y),u.push(m,S)),u.push(m,S)}return{rect:dt(this.tmpPoints,t),pos:r,points:u}}updateTempPoints(t){const e=t.slice(-2),i=new F(e[0],e[1]),s=this.tmpPoints[0],{thickness:n}=this.workOptions;if(s.isNear(i,n)||F.Sub(s,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(t){var c,l;const{op:e,isFullWork:i}=t,s=(c=this.workId)==null?void 0:c.toString();if(!s)return;this.tmpPoints.length=0;for(let h=0;h<e.length;h+=3)this.tmpPoints.push(new F(e[h],e[h+1],e[h+2]));const n=i?this.fullLayer:this.drawLayer||this.fullLayer,r=this.draw({workId:s,layer:n,isDrawing:!1});return this.oldRect=r,(l=this.vNodes)==null||l.setInfo(s,{rect:r,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:r&&W.getCenterPos(r,n)}),r}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var m;const{node:e,opt:i,vNodes:s}=t,{strokeColor:n,fillColor:r,toolsType:c,vertices:l,innerVerticeStep:h,innerRatio:u,strokeType:d}=i,p=s.get(e.name),f=p==null?void 0:p.opt;let y=e;return e.tagName==="GROUP"&&(y=e.children[0]),n&&(y.setAttribute("strokeColor",n),f!=null&&f.strokeColor&&(f.strokeColor=n)),r&&(r==="transparent"?y.setAttribute("fillColor","rgba(0,0,0,0)"):y.setAttribute("fillColor",r),f!=null&&f.fillColor&&(f.fillColor=r)),c===C.Star&&(l&&(f.vertices=l),h&&(f.innerVerticeStep=h),u&&(f.innerRatio=u)),d&&(p!=null&&p.opt)&&((m=p.opt)!=null&&m.strokeType)&&(p.opt.strokeType=d),p&&s.setInfo(e.name,{...p,opt:f}),W.updateNodeOpt(t)}}class ws extends W{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",ct.all);M(this,"toolsType",C.Polygon);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){const{data:e,isFullWork:i,isSubWorker:s,isMainThread:n}=t,{op:r}=e,c=this.workId,l=r==null?void 0:r.length;if(!l||l<2)return{type:b.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new F(r[0],r[1])],h=!1):h=this.updateTempPoints(r),!h)return{type:b.None};let u;if(s||n){const p=i?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({workId:c,layer:p,isDrawing:!0})}if(!s){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{type:b.DrawWork,dataType:H.Local,op:this.tmpPoints.map(f=>[...f.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:b.None}}const d=ut(u,this.oldRect);return this.oldRect=u,{rect:d,type:b.DrawWork,dataType:H.Local,...this.baseConsumeResult}}consumeAll(){var r;const t=this.workId;if(this.tmpPoints.length<2)return{type:b.RemoveNode,removeIds:[t]};const e=this.fullLayer,i=this.draw({workId:t,layer:e,isDrawing:!1});this.oldRect=i;const s=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=Dt(s);return(r=this.vNodes)==null||r.setInfo(t,{rect:i,op:s,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:i&&W.getCenterPos(i,e)}),{rect:i,type:b.FullWork,dataType:H.Local,ops:n,isSync:!0,...this.baseConsumeResult}}draw(t){const{workId:e,layer:i,isDrawing:s}=t,{strokeColor:n,fillColor:r,thickness:c,zIndex:l,vertices:h,scale:u,rotate:d,translate:p,strokeType:f,eraserlines:y}=this.workOptions,m=i.worldScaling,{rect:S,pos:w,points:v}=this.computDrawPoints(c,h),T={close:!0,points:v,lineWidth:c,fillColor:r!=="transparent"&&r||void 0,strokeColor:n,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:f===_.Dotted?[1,c*2]:f===_.LongDotted?[c,c*2]:void 0},N={name:e,id:e,zIndex:l,pos:w,anchor:[.5,.5],size:[S.w,S.h]};u&&(N.scale=u),d&&(N.rotate=d),p&&(N.translate=p);const I=new lt.Group(N);if(s){const A=new lt.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:n,lineWidth:1,scale:[1/m[0],1/m[1]]});I.append(A)}const x=new lt.Polyline({...T,pos:[0,0]});I.append(x),y&&this.drawEraserlines({group:I,eraserlines:y,pos:w,layer:i}),this.replace(i,e,I);const z=I.getBoundingClientRect();return{x:Math.floor(z.x-W.SafeBorderPadding),y:Math.floor(z.y-W.SafeBorderPadding),w:Math.floor(z.width+W.SafeBorderPadding*2),h:Math.floor(z.height+W.SafeBorderPadding*2)}}computDrawPoints(t,e){const i=dt(this.tmpPoints),s=[Math.floor(i.x+i.w/2),Math.floor(i.y+i.h/2)],n=xs(i.w,i.h),r=Math.floor(Math.min(i.w,i.h)/2),c=[],l=2*Math.PI/e;for(let u=0;u<e;u++){const d=u*l-.5*Math.PI,p=r*n[0]*Math.cos(d),f=r*n[1]*Math.sin(d);c.push(p,f)}return{rect:dt(this.tmpPoints,t),pos:s,points:c}}updateTempPoints(t){const e=t.slice(-2),i=new F(e[0],e[1]),s=this.tmpPoints[0],{thickness:n}=this.workOptions;if(s.isNear(i,n)||F.Sub(s,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(t){var c,l;const{op:e,isFullWork:i}=t,s=(c=this.workId)==null?void 0:c.toString();if(!s)return;this.tmpPoints.length=0;for(let h=0;h<e.length;h+=3)this.tmpPoints.push(new F(e[h],e[h+1],e[h+2]));const n=i?this.fullLayer:this.drawLayer||this.fullLayer,r=this.draw({workId:s,layer:n,isDrawing:!1});return this.oldRect=r,(l=this.vNodes)==null||l.setInfo(s,{rect:r,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:r&&W.getCenterPos(r,n)}),r}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var f;const{node:e,opt:i,vNodes:s}=t,{strokeColor:n,fillColor:r,toolsType:c,vertices:l,strokeType:h}=i,u=s.get(e.name),d=u==null?void 0:u.opt;let p=e;return e.tagName==="GROUP"&&(p=e.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===C.Polygon&&l&&(d.vertices=l),h&&(u!=null&&u.opt)&&((f=u.opt)!=null&&f.strokeType)&&(u.opt.strokeType=h),u&&s.setInfo(e.name,{...u,opt:d}),W.updateNodeOpt(t)}}class Wt{static bezier(o,t){const e=[];for(let i=0;i<t.length;i+=4){const s=t[i],n=t[i+1],r=t[i+2],c=t[i+3];s&&n&&r&&c?e.push(...Wt.getBezierPoints(o,s,n,r,c)):s&&n&&r?e.push(...Wt.getBezierPoints(o,s,n,r)):s&&n?e.push(...Wt.getBezierPoints(o,s,n)):s&&e.push(s)}return e}static getBezierPoints(o=10,t,e,i,s){let n=null;const r=[];!i&&!s?n=Wt.oneBezier:i&&!s?n=Wt.twoBezier:i&&s&&(n=Wt.threeBezier);for(let c=0;c<o;c++)n&&r.push(n(c/o,t,e,i,s));return s?r.push(s):i&&r.push(i),r}static oneBezier(o,t,e){const i=t.x+(e.x-t.x)*o,s=t.y+(e.y-t.y)*o;return new k(i,s)}static twoBezier(o,t,e,i){const s=(1-o)*(1-o)*t.x+2*o*(1-o)*e.x+o*o*i.x,n=(1-o)*(1-o)*t.y+2*o*(1-o)*e.y+o*o*i.y;return new k(s,n)}static threeBezier(o,t,e,i,s){const n=t.x*(1-o)*(1-o)*(1-o)+3*e.x*o*(1-o)*(1-o)+3*i.x*o*o*(1-o)+s.x*o*o*o,r=t.y*(1-o)*(1-o)*(1-o)+3*e.y*o*(1-o)*(1-o)+3*i.y*o*o*(1-o)+s.y*o*o*o;return new k(n,r)}}class vs extends W{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",ct.all);M(this,"toolsType",C.SpeechBalloon);M(this,"ratio",.8);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){var p;const{data:e,isFullWork:i,isSubWorker:s,isMainThread:n}=t,r=(p=e==null?void 0:e.workId)==null?void 0:p.toString();if(!r)return{type:b.None};const{op:c}=e,l=c==null?void 0:c.length;if(!l||l<2)return{type:b.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new F(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:b.None};let u;if(s||n){const f=i?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({workId:r,layer:f,isDrawing:!0})}if(!s){const f=Date.now();return f-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=f,{type:b.DrawWork,dataType:H.Local,op:this.tmpPoints.map(y=>[...y.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:b.None}}const d=ut(u,this.oldRect);return this.oldRect=u,{rect:d,type:b.DrawWork,dataType:H.Local,...this.baseConsumeResult}}consumeAll(){var r;const t=this.workId;if(this.tmpPoints.length<2)return{type:b.RemoveNode,removeIds:[t]};const e=this.fullLayer,i=this.draw({workId:t,layer:e,isDrawing:!1});this.oldRect=i;const s=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=Dt(s);return(r=this.vNodes)==null||r.setInfo(t,{rect:i,op:s,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:i&&W.getCenterPos(i,e)}),{rect:i,type:b.FullWork,dataType:H.Local,ops:n,isSync:!0,...this.baseConsumeResult}}draw(t){const{workId:e,layer:i}=t,{strokeColor:s,fillColor:n,thickness:r,zIndex:c,placement:l,scale:h,rotate:u,translate:d,strokeType:p,eraserlines:f}=this.workOptions,{rect:y,pos:m,points:S}=this.computDrawPoints(r,l),w={points:S.map(x=>x.XY),lineWidth:r,fillColor:n!=="transparent"&&n||void 0,strokeColor:s,normalize:!0,className:`${m[0]},${m[1]}`,close:!0,lineJoin:"round",lineCap:"round",lineDash:p===_.Dotted?[1,r*2]:p===_.LongDotted?[r,r*2]:void 0},v={name:e,id:e,zIndex:c,pos:m,anchor:[.5,.5],size:[y.w,y.h]};h&&(v.scale=h),u&&(v.rotate=u),d&&(v.translate=d);const T=new lt.Group(v),N=new lt.Polyline({...w,pos:[0,0]});T.append(N),f&&this.drawEraserlines({group:T,eraserlines:f,pos:m,layer:i}),this.replace(i,e,T);const I=T.getBoundingClientRect();return{x:Math.floor(I.x-W.SafeBorderPadding),y:Math.floor(I.y-W.SafeBorderPadding),w:Math.floor(I.width+W.SafeBorderPadding*2),h:Math.floor(I.height+W.SafeBorderPadding*2)}}transformControlPoints(t){const e=dt(this.tmpPoints);switch(t){case"bottom":case"bottomLeft":case"bottomRight":{const i=e.y+e.h*this.ratio;return[new k(e.x,e.y,0),new k(e.x+e.w,e.y,0),new k(e.x+e.w,i,0),new k(e.x,i,0)]}case"top":case"topLeft":case"topRight":{const i=e.y+e.h*(1-this.ratio);return[new k(e.x,i,0),new k(e.x+e.w,i,0),new k(e.x+e.w,e.y+e.h,0),new k(e.x,e.y+e.h,0)]}case"left":case"leftBottom":case"leftTop":{const i=e.x+e.w*(1-this.ratio);return[new k(i,e.y,0),new k(e.x+e.w,e.y,0),new k(e.x+e.w,e.y+e.h,0),new k(i,e.y+e.h,0)]}case"right":case"rightBottom":case"rightTop":{const i=e.x+e.w*this.ratio;return[new k(e.x,e.y,0),new k(i,e.y,0),new k(i,e.y+e.h,0),new k(e.x,e.y+e.h,0)]}}}computDrawPoints(t,e){const i=dt(this.tmpPoints),s=this.transformControlPoints(e),n=Math.floor(i.w*.1),r=Math.floor(i.h*.1),c=[],l=k.Add(s[0],new k(0,r,0)),h=k.Add(s[0],new k(n,0,0)),u=Wt.getBezierPoints(10,l,s[0],h),d=k.Sub(s[1],new k(n,0,0)),p=k.Add(s[1],new k(0,r,0)),f=Wt.getBezierPoints(10,d,s[1],p),y=k.Sub(s[2],new k(0,r,0)),m=k.Sub(s[2],new k(n,0,0)),S=Wt.getBezierPoints(10,y,s[2],m),w=k.Add(s[3],new k(n,0,0)),v=k.Sub(s[3],new k(0,r,0)),T=Wt.getBezierPoints(10,w,s[3],v),N=n*(1-this.ratio)*10,I=r*(1-this.ratio)*10;switch(e){case"bottom":{const A=k.Sub(s[2],new k(n*5-N/2,0,0)),E=k.Sub(s[2],new k(n*5,-I,0)),j=k.Sub(s[2],new k(n*5+N/2,0,0));c.push(E,j,...T,...u,...f,...S,A);break}case"bottomRight":{const A=k.Sub(s[2],new k(n*1.1,0,0)),E=k.Sub(s[2],new k(n*1.1+N/2,-I,0)),j=k.Sub(s[2],new k(n*1.1+N,0,0));c.push(E,j,...T,...u,...f,...S,A);break}case"bottomLeft":{const A=k.Add(s[3],new k(n*1.1+N,0,0)),E=k.Add(s[3],new k(n*1.1+N/2,I,0)),j=k.Add(s[3],new k(n*1.1,0,0));c.push(E,j,...T,...u,...f,...S,A);break}case"top":{const A=k.Sub(s[1],new k(n*5-N/2,0,0)),E=k.Sub(s[1],new k(n*5,I,0)),j=k.Sub(s[1],new k(n*5+N/2,0,0));c.push(E,A,...f,...S,...T,...u,j);break}case"topRight":{const A=k.Sub(s[1],new k(n*1.1,0,0)),E=k.Sub(s[1],new k(n*1.1+N/2,I,0)),j=k.Sub(s[1],new k(n*1.1+N,0,0));c.push(E,A,...f,...S,...T,...u,j);break}case"topLeft":{const A=k.Add(s[0],new k(n*1.1+N,0,0)),E=k.Add(s[0],new k(n*1.1+N/2,-I,0)),j=k.Add(s[0],new k(n*1.1,0,0));c.push(E,A,...f,...S,...T,...u,j);break}case"left":{const A=k.Add(s[0],new k(0,r*5-I/2,0)),E=k.Add(s[0],new k(-N,r*5,0)),j=k.Add(s[0],new k(0,r*5+I/2,0));c.push(E,A,...u,...f,...S,...T,j);break}case"leftTop":{const A=k.Add(s[0],new k(0,r*1.1,0)),E=k.Add(s[0],new k(-N,r*1.1+I/2,0)),j=k.Add(s[0],new k(0,r*1.1+I,0));c.push(E,A,...u,...f,...S,...T,j);break}case"leftBottom":{const A=k.Sub(s[3],new k(0,r*1.1+I,0)),E=k.Sub(s[3],new k(N,r*1.1+I/2,0)),j=k.Sub(s[3],new k(0,r*1.1,0));c.push(E,A,...u,...f,...S,...T,j);break}case"right":{const A=k.Add(s[1],new k(0,r*5-I/2,0)),E=k.Add(s[1],new k(N,r*5,0)),j=k.Add(s[1],new k(0,r*5+I/2,0));c.push(E,j,...S,...T,...u,...f,A);break}case"rightTop":{const A=k.Add(s[1],new k(0,r*1.1,0)),E=k.Add(s[1],new k(N,r*1.1+I/2,0)),j=k.Add(s[1],new k(0,r*1.1+I,0));c.push(E,j,...S,...T,...u,...f,A);break}case"rightBottom":{const A=k.Sub(s[2],new k(0,r*1.1+I,0)),E=k.Sub(s[2],new k(-N,r*1.1+I/2,0)),j=k.Sub(s[2],new k(0,r*1.1,0));c.push(E,j,...S,...T,...u,...f,A);break}}const x=dt(this.tmpPoints,t),z=[Math.floor(x.x+x.w/2),Math.floor(x.y+x.h/2)];return{rect:x,pos:z,points:c}}updateTempPoints(t){const e=t.slice(-2),i=new F(e[0],e[1]),s=this.tmpPoints[0],{thickness:n}=this.workOptions;if(s.isNear(i,n)||F.Sub(s,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(t){var c,l;const{op:e,isFullWork:i}=t,s=(c=this.workId)==null?void 0:c.toString();if(!s)return;this.tmpPoints.length=0;for(let h=0;h<e.length;h+=3)this.tmpPoints.push(new F(e[h],e[h+1],e[h+2]));const n=i?this.fullLayer:this.drawLayer||this.fullLayer,r=this.draw({workId:s,layer:n,isDrawing:!1});return this.oldRect=r,(l=this.vNodes)==null||l.setInfo(s,{rect:r,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:r&&W.getCenterPos(r,n)}),r}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var f;const{node:e,opt:i,vNodes:s}=t,{strokeColor:n,fillColor:r,toolsType:c,placement:l,strokeType:h}=i,u=s.get(e.name),d=u==null?void 0:u.opt;let p=e;return e.tagName==="GROUP"&&(p=e.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===C.SpeechBalloon&&l&&(d.placement=l),h&&(u!=null&&u.opt)&&((f=u.opt)!=null&&f.strokeType)&&(u.opt.strokeType=h),u&&s.setInfo(e.name,{...u,opt:d}),W.updateNodeOpt(t)}}var Cf=ce,kf=qt,xf="[object Boolean]";function zf(a){return a===!0||a===!1||kf(a)&&Cf(a)==xf}var bf=zf;const fe=Ie(bf);class je extends W{constructor(t){super(t);M(this,"canRotate",!0);M(this,"scaleType",ct.all);M(this,"toolsType",C.Image);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");this.workOptions=t.toolsOpt,this.scaleType=je.getScaleType(this.workOptions)}consume(){return{type:b.None}}consumeAll(){return{type:b.None}}draw(t){const{layer:e,workId:i,replaceId:s,imageBitmap:n}=t,{centerX:r,centerY:c,width:l,height:h,rotate:u,zIndex:d,eraserlines:p}=this.workOptions,f=new lt.Group({anchor:[.5,.5],pos:[r,c],name:i,size:[l,h],zIndex:d,rotate:u}),y={anchor:[.5,.5],pos:[0,0],size:[l,h],texture:n};n||(y.bgcolor="rgba(0,0,0,0.3)");const m=new lt.Sprite(y);f.append(m),p&&this.drawEraserlines({group:f,eraserlines:p,pos:[r,c],layer:e}),this.replace(e,s||i,f);const S=f.getBoundingClientRect();if(S)return{x:Math.floor(S.x-W.SafeBorderPadding),y:Math.floor(S.y-W.SafeBorderPadding),w:Math.floor(S.width+W.SafeBorderPadding*2),h:Math.floor(S.height+W.SafeBorderPadding*2)}}consumeService(){}async consumeServiceAsync(t){var h,u,d,p;const{isFullWork:e,replaceId:i,worker:s}=t,{src:n,uuid:r}=this.workOptions,c=((h=this.workId)==null?void 0:h.toString())||r,l=e?this.fullLayer:this.drawLayer||this.fullLayer;if(n){const f=!!l.parent.gl;let y;s&&(y=await s.loadImageBitMap({toolsType:this.toolsType,opt:this.workOptions,workId:c})),y||(y=await fetch(n,{method:"GET",mode:"cors",cache:"default"}).then(S=>S.blob()).then(S=>createImageBitmap(S,{imageOrientation:f?"flipY":"none"}).then(w=>w)).catch(S=>{console.error(`load image error: ${S}`)}));const m=this.draw({workId:c,layer:l,replaceId:i,imageBitmap:y});return this.oldRect=c&&((d=(u=this.vNodes)==null?void 0:u.get(c))==null?void 0:d.rect)||void 0,(p=this.vNodes)==null||p.setInfo(c,{rect:m,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:m&&W.getCenterPos(m,l)}),m}}clearTmpPoints(){this.tmpPoints.length=0}static getScaleType(t){const{uniformScale:e,rotate:i}=t;return e!==!1||i&&Math.abs(i)%90>0?ct.proportional:ct.all}static updateNodeOpt(t){const{node:e,opt:i,vNodes:s,targetNode:n}=t,{translate:r,originPoint:c,scenePoint:l,scale:h,angle:u,isLocked:d,zIndex:p}=i,f=n&&Jt(n)||s.get(e.name);if(!f)return;const y=e.parent;if(y){if(Qt(p)&&(e.setAttribute("zIndex",p),f.opt.zIndex=p),fe(d)&&(f.opt.locked=d),c&&l&&h&&r){const{centerX:m,centerY:S,width:w,height:v,uniformScale:T}=f.opt,N=T!==!1?[h[0],h[0]]:h,I=[m,S],x=[m,S];Ho(x,l,N,r);const z=[x[0]-I[0],x[1]-I[1]];if(f.centerPos=[f.centerPos[0]+z[0],f.centerPos[1]+z[1]],f.opt.width=Math.round(w*N[0]),f.opt.height=Math.round(v*N[1]),f.opt.centerX=x[0],f.opt.centerY=x[1],f.opt.eraserlines)for(const A of Object.values(f.opt.eraserlines)){const{op:E,thickness:j}=A;A.thickness=j*Math.max(h[0],h[1]);for(let O=0;O<E.length;O++)$o(E[O],l,h,r)}}else if(r){if(f.opt.centerX=f.opt.centerX+r[0],f.opt.centerY=f.opt.centerY+r[1],f.centerPos=[f.centerPos[0]+r[0],f.centerPos[1]+r[1]],f.opt.eraserlines)for(const m of Object.values(f.opt.eraserlines)){const{op:S}=m;for(let w=0;w<S.length;w++){const v=S[w].map((T,N)=>N%2?T+r[1]:T+r[0]);m.op[w]=v}}}else if(Qt(u))if(f.opt.rotate=u,f.scaleType=je.getScaleType(f.opt),n){const m=Cs(f.rect,u);f.rect=m}else{const m=W.getRectFromLayer(y,e.name);f.rect=m||f.rect}return f&&s.setInfo(e.name,f),f==null?void 0:f.rect}}}class Is extends W{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",ct.both);M(this,"toolsType",C.Straight);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"straightTipWidth");M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.straightTipWidth=this.workOptions.thickness/2,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){const{data:e,isFullWork:i,isSubWorker:s,isMainThread:n}=t,r=this.workId,{op:c}=e,l=c==null?void 0:c.length;if(!l||l<2)return{type:b.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new F(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:b.None};let u;if(s||n){const p=i?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({workId:r,layer:p})}if(!s){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{type:b.DrawWork,dataType:H.Local,op:this.tmpPoints.map(f=>[...f.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:b.None}}const d=ut(u,this.oldRect);return this.oldRect=u,{rect:d,type:b.DrawWork,dataType:H.Local,...this.baseConsumeResult}}consumeAll(){var r;const t=this.workId;if(this.tmpPoints.length<2)return{type:b.RemoveNode,removeIds:[t]};const e=this.fullLayer,i=this.draw({workId:t,layer:e});this.oldRect=i;const s=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=Dt(s);return(r=this.vNodes)==null||r.setInfo(t,{rect:i,op:s,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:i&&W.getCenterPos(i,e)}),{rect:i,type:b.FullWork,dataType:H.Local,ops:n,isSync:!0,...this.baseConsumeResult}}draw(t){const{workId:e,layer:i}=t,{strokeColor:s,thickness:n,zIndex:r,scale:c,rotate:l,translate:h,strokeType:u,eraserlines:d}=this.workOptions,p=i.worldPosition,f=i.worldScaling,{d:y,rect:m,isDot:S}=this.computDrawPoints(n,u),w=[m.x+m.w/2,m.y+m.h/2],v=new lt.Group({pos:w,anchor:[.5,.5],size:[m.w,m.h],name:e,id:e,normalize:!0,zIndex:r}),T={pos:[0,0],normalize:!0,d:y,fillColor:s,strokeColor:s,lineDash:u===_.Dotted&&!S?[1,n*2]:u===_.LongDotted&&!S?[n,n*2]:void 0,lineCap:u===_.Normal||S?void 0:"round",lineWidth:u===_.Normal||S?0:n};c&&(T.scale=c),l&&(T.rotate=l),h&&(T.translate=h);const N=new lt.Path(T);if(v.append(N),d&&this.drawEraserlines({group:v,eraserlines:d,pos:w,layer:i}),this.replace(i,e,v),l||c||h){const x=N.getBoundingClientRect();return{x:Math.floor(x.x-W.SafeBorderPadding),y:Math.floor(x.y-W.SafeBorderPadding),w:Math.floor(x.width+W.SafeBorderPadding*2),h:Math.floor(x.height+W.SafeBorderPadding*2)}}return{x:Math.floor(m.x*f[0]+p[0]-W.SafeBorderPadding),y:Math.floor(m.y*f[1]+p[1]-W.SafeBorderPadding),w:Math.floor(m.w*f[0]+2*W.SafeBorderPadding),h:Math.floor(m.h*f[1]+2*W.SafeBorderPadding)}}computDrawPoints(t,e){return this.tmpPoints[1].distance(this.tmpPoints[0])>this.straightTipWidth?this.computFullPoints(t,e):this.computDotPoints(t)}computFullPoints(t,e){const i=k.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),s=k.Per(i).mul(t/2),n=F.Sub(this.tmpPoints[0],s),r=F.Add(this.tmpPoints[0],s),c=F.Sub(this.tmpPoints[1],s),l=F.Add(this.tmpPoints[1],s),h=F.GetSemicircleStroke(this.tmpPoints[1],c,-1,8),u=F.GetSemicircleStroke(this.tmpPoints[0],r,-1,8),d=[n,c,...h,l,r,...u];let p;return e!==_.Normal?p=_t(this.tmpPoints,!1):p=_t(d,!0),{d:p,rect:dt(d),isDot:!1,pos:this.tmpPoints[0].XY}}computDotPoints(t){const e=F.GetDotStroke(this.tmpPoints[0],t/2,8);return{d:_t(e,!0),rect:dt(e),isDot:!0,pos:this.tmpPoints[0].XY}}updateTempPoints(t){const e=t.slice(-2),i=new F(e[0],e[1]),s=this.tmpPoints[0],{thickness:n}=this.workOptions;if(s.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(t){var c,l;const{op:e,isFullWork:i}=t,s=(c=this.workId)==null?void 0:c.toString();if(!s)return;this.tmpPoints.length=0;for(let h=0;h<e.length;h+=3)this.tmpPoints.push(new F(e[h],e[h+1],e[h+2]));const n=i?this.fullLayer:this.drawLayer||this.fullLayer,r=this.draw({workId:s,layer:n});return this.oldRect=r,(l=this.vNodes)==null||l.setInfo(s,{rect:r,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:r&&W.getCenterPos(r,n)}),r}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var l,h;const{node:e,opt:i,vNodes:s}=t,{strokeColor:n,strokeType:r}=i,c=s.get(e.name);return n&&(e.tagName==="GROUP"?e.children.forEach(u=>{u.setAttribute("strokeColor",n),u.getAttribute("fillColor")&&u.setAttribute("fillColor",n)}):(e.setAttribute("strokeColor",n),e.setAttribute("fillColor",n)),(l=c==null?void 0:c.opt)!=null&&l.strokeColor&&(c.opt.strokeColor=n)),r&&(c!=null&&c.opt)&&((h=c.opt)!=null&&h.strokeType)&&(c.opt.strokeType=r),c&&s.setInfo(e.name,c),W.updateNodeOpt(t)}}const Kt=class Kt extends W{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",ct.proportional);M(this,"toolsType",C.Text);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");this.workOptions=t.toolsOpt}consume(){return{type:b.None}}consumeAll(){return{type:b.None}}consumeService(){}async draw(t){const{workId:e,layer:i,isDrawLabel:s}=t,{boxSize:n,boxPoint:r,zIndex:c,eraserlines:l}=this.workOptions,h=i.worldPosition,u=i.worldScaling;if(!r||!n)return;const d={name:e,id:e,pos:[r[0],r[1]],anchor:[0,0],size:n,zIndex:c},p=new lt.Group(d),f={x:r[0],y:r[1],w:n[0],h:n[1]},y={x:Math.floor(f.x*u[0]+h[0]),y:Math.floor(f.y*u[1]+h[1]),w:Math.floor(f.w*u[0])+2,h:Math.floor(f.h*u[1])+2};if(this.replace(i,e,p),s&&i&&this.workOptions.text){const m=await Kt.createLabels(this.workOptions,i,y),{labels:S,maxWidth:w}=m;p.append(...S),y.w=Math.ceil(Math.max(w*i.worldScaling[0],y.w))}return l&&this.drawEraserlines({group:p,eraserlines:l,pos:[r[0],r[1]],layer:i}),y}async consumeServiceAsync(t){var l,h,u,d;const e=(l=this.workId)==null?void 0:l.toString();if(!e)return;const{isFullWork:i,replaceId:s,isDrawLabel:n}=t;this.oldRect=s&&((u=(h=this.vNodes)==null?void 0:h.get(s))==null?void 0:u.rect)||void 0;const r=i?this.fullLayer:this.drawLayer||this.fullLayer,c=await this.draw({workId:e,layer:r,isDrawLabel:typeof n>"u"&&this.workOptions.workState===D.Done||n});return(d=this.vNodes)==null||d.setInfo(e,{rect:c,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:c&&W.getCenterPos(c,r)}),c}updataOptService(){}async updataOptServiceAsync(t,e){var f,y;if(!this.workId)return;const i=this.workId.toString(),{fontColor:s,fontBgColor:n,bold:r,italic:c,lineThrough:l,underline:h,zIndex:u}=t,d=(f=this.vNodes)==null?void 0:f.get(i);if(!d)return;s&&(d.opt.fontColor=s),n&&(d.opt.fontBgColor=n),r&&(d.opt.bold=r),c&&(d.opt.italic=c),fe(l)&&(d.opt.lineThrough=l),fe(h)&&(d.opt.underline=h),Qt(u)&&(d.opt.zIndex=u),this.oldRect=d.rect;const p=await this.draw({workId:i,layer:this.fullLayer,isDrawLabel:typeof e>"u"&&this.workOptions.workState===D.Done||e});return(y=this.vNodes)==null||y.setInfo(i,{rect:p,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:p&&W.getCenterPos(p,this.fullLayer)}),p}clearTmpPoints(){this.tmpPoints.length=0}static getSafetySnippetRatio(t){const e=(t==null?void 0:t.parent).displayRatio||1,i=Math.ceil(t.worldScaling[0]*10)/10;let s=i;return i>=.2&&i<1?s=i*e:i<=2&&i>=1?s=i*e*1.6:i>2&&i<=3?s=i*e*1.4:i>3&&i<=4?s=i*e*.8:i>4&&(s=i*e*.6),Math.floor(s*1e3)/1e3}static getSafetySnippetFontLength(t){return Math.floor(Kt.textImageSnippetSize*3/4/t)||1}static async createLabels(t,e,i){var j;const s=[],{x:n,y:r}=i,{width:c,height:l}=(j=e.parent)==null?void 0:j.parent,h=xe(t.text),u=h.length,{fontSize:d,lineHeight:p,bold:f,textAlign:y,italic:m,fontFamily:S,verticalAlign:w,fontColor:v,fontBgColor:T,underline:N,lineThrough:I}=t,x=Kt.getSafetySnippetRatio(e)||1,z=Math.floor(d*x),A=Kt.getSafetySnippetFontLength(z);let E=0;for(let O=0;O<u;O++){const P=h[O],Y=p||z*1.5;if(P){const ot=Rf(P),tt=[0,0],Q=[0,d*1.2];w==="middle"&&(tt[1]=O*d*1.2+5);const J=[0,-d*.15];tt[0]=5;const G=Math.sin(Math.PI/180*20);let Z=0;const X=[];let rt=0;for(;rt<ot;){y==="left"&&(J[0]=Z),rt===0&&m==="italic"&&(J[0]=J[0]-G/2*d);const it=P.slice(rt,rt+A),at={anchor:[0,0],pos:J,text:it,fontFamily:S,fontSize:z,lineHeight:Y,strokeColor:v,fontWeight:f,fillColor:v,textAlign:y,fontStyle:m,scale:[1/x,1/x]},U=new lt.Label(at),nt=await U.textImageReady;let ht=!0;if(nt){const vt=nt.rect&&nt.rect[2],Ht=nt.rect&&nt.rect[3];if(vt&&Ht){const yt=vt/x,gt=Ht/x;Z=yt+Z,m==="italic"&&(f==="bold"?Z=Z-G*d*1.2:Z=Z-G*d),((J[0]+tt[0]+yt)*e.worldScaling[0]+n<=0||(J[0]+tt[0])*e.worldScaling[0]+n>=c||(J[1]+tt[1]+gt)*e.worldScaling[1]+r<=0||(J[1]+tt[1])*e.worldScaling[1]+r>=l)&&(U.disconnect(),ht=!1),ht&&X.push(U)}}rt+=A}Q[0]=Z,m==="italic"&&(Q[0]=Q[0]+G*d),E=Math.max(E,Q[0]);let wt=!0;if(((tt[0]+Q[0])*e.worldScaling[0]+n<=0||tt[0]*e.worldScaling[0]+n>=c||(tt[1]+Q[1])*e.worldScaling[0]+r<=0||tt[1]*e.worldScaling[1]+r>=l)&&(wt=!1),wt){if(N){const U=Math.floor(d/10),nt={normalize:!1,pos:[0,d*1.1+U/2],lineWidth:U,points:[0,0,Math.ceil(Q[0]),0],strokeColor:v,className:"underline"},ht=new lt.Polyline(nt);X.push(ht)}if(I){const U={normalize:!1,pos:[0,d*1.2/2],lineWidth:Math.floor(d/10),points:[0,0,Math.ceil(Q[0]),0],strokeColor:v,className:"lineThrough"},nt=new lt.Polyline(U);X.push(nt)}const it={pos:tt,anchor:[0,0],size:Q,bgcolor:T},at=new lt.Group(it);at.append(...X),s.push(at)}}}return{labels:s,maxWidth:E}}static updateNodeOpt(t){const{node:e,opt:i,vNodes:s,targetNode:n}=t,{fontBgColor:r,fontColor:c,translate:l,originPoint:h,scenePoint:u,scale:d,bold:p,italic:f,lineThrough:y,underline:m,fontSize:S,textInfos:w,zIndex:v}=i,T=n&&Jt(n)||s.get(e.name);if(!T||!e.parent)return;const I=T.opt;if(Qt(v)&&(e.setAttribute("zIndex",v),T.opt.zIndex=v),c&&I.fontColor&&(I.fontColor=c,e.children.forEach(x=>{x.tagName==="GROUP"&&x.children.forEach(z=>{z.tagName==="LABEL"?(z.setAttribute("fillColor",c),z.setAttribute("strokeColor",c)):z.tagName==="POLYLINE"&&z.setAttribute("strokeColor",c)})})),r&&I.fontBgColor&&(I.fontBgColor=r,e.children.forEach(x=>{x.tagName==="GROUP"&&x.setAttribute("bgcolor",r)})),p&&(I.bold=p),f&&(I.italic=f),fe(y)&&(I.lineThrough=y),fe(m)&&(I.underline=m),S&&(I.fontSize=S),h&&u&&d&&n&&I.boxPoint){const x=w==null?void 0:w.get(e.name);if(x){const{fontSize:j,boxSize:O}=x;I.boxSize=O||I.boxSize,I.fontSize=j||I.fontSize}const z=[I.boxPoint[0],I.boxPoint[1]];Ho(I.boxPoint,u,d,l);const A=[T.op[0],T.op[1]],E=[A[0]-z[0],A[1]-z[1]];if(T.centerPos=[T.centerPos[0]+E[0],T.centerPos[1]+E[1]],T.opt.eraserlines)for(const j of Object.values(T.opt.eraserlines)){const{op:O,thickness:P}=j;j.thickness=P*Math.max(d[0],d[1]);for(let Y=0;Y<O.length;Y++)$o(O[Y],u,d,l)}}else if(l&&I.boxPoint&&(I.boxPoint=[I.boxPoint[0]+l[0],I.boxPoint[1]+l[1]],T.centerPos=[T.centerPos[0]+l[0],T.centerPos[1]+l[1]],T.opt.eraserlines))for(const x of Object.values(T.opt.eraserlines)){const{op:z}=x;for(let A=0;A<z.length;A++){const E=z[A].map((j,O)=>O%2?j+l[1]:j+l[0]);x.op[A]=E}}return T&&s.setInfo(e.name,T),T==null?void 0:T.rect}static getRectFromLayer(t,e){const i=t.getElementsByName(e)[0];if(i){const s=i.getBoundingClientRect();let n={x:Math.floor(s.x),y:Math.floor(s.y),w:Math.floor(s.width+2),h:Math.floor(s.height+2)};return i.children.forEach(r=>{if(r.tagName==="GROUP"){const c=i.getBoundingClientRect();n=ut(n,{x:Math.floor(c.x),y:Math.floor(c.y),w:Math.floor(c.width+2),h:Math.floor(c.height+2)})}}),n}}};M(Kt,"textImageSnippetSize",1024*4),M(Kt,"SafeBorderPadding",30);let Je=Kt;const Me=class Me extends W{constructor(t,e){super(t);M(this,"canRotate",!1);M(this,"scaleType",ct.none);M(this,"toolsType",C.PencilEraser);M(this,"serviceWork");M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"worldPosition");M(this,"worldScaling");M(this,"eraserRect");M(this,"eraserPolyline");this.serviceWork=e,this.workOptions=t.toolsOpt,this.worldPosition=this.fullLayer.worldPosition,this.worldScaling=this.fullLayer.worldScaling}consumeService(){}createEraserRect(t){const e=t[0]*this.worldScaling[0]+this.worldPosition[0],i=t[1]*this.worldScaling[1]+this.worldPosition[1],{width:s,height:n}=Me.eraserSizes[this.workOptions.thickness];this.eraserRect={x:e-s*.5,y:i-n*.5,w:s,h:n},this.eraserPolyline=[this.eraserRect.x,this.eraserRect.y,this.eraserRect.x+this.eraserRect.w,this.eraserRect.y+this.eraserRect.h]}computRectCenterPoints(){const t=this.tmpPoints.slice(-2);if(this.tmpPoints.length===4){const e=new k(this.tmpPoints[0],this.tmpPoints[1]),i=new k(this.tmpPoints[2],this.tmpPoints[3]),s=k.Sub(i,e).uni(),n=k.Dist(e,i),{width:r,height:c}=Me.eraserSizes[this.workOptions.thickness],l=Math.min(r,c),h=Math.round(n/l);if(h>1){const u=[];for(let d=0;d<h;d++){const p=k.Mul(s,d*l);u.push(this.tmpPoints[0]+p.x,this.tmpPoints[1]+p.y)}return u.concat(t)}}return t}isNear(t,e){const i=new k(t[0],t[1]),s=new k(e[0],e[1]),{width:n,height:r}=Me.eraserSizes[this.workOptions.thickness];return k.Dist(i,s)<Math.hypot(n,r)*.5}cutPolyline(t,e){let i=[e],s=0;for(;s<t.length;){const c=t[s];if(c.length<2)break;i=n(i,c),s++}return i;function n(c,l){const h=c;for(let u=0;u<c.length;u++){const d=c[u],p=d.findIndex((f,y)=>y<d.length-1?r([f,d[y+1]],[l[0],l[1]]):!1);if(p!==-1&&p>-1){const f=[],y=d.slice(0,p+1);if(k.Equals(d[p],l[0])||y.push(l[0].clone().setz(d[p].z)),y.length>1&&f.push(y),p+l.length-1<d.length-1){const m=p+l.length-1,S=d.slice(m),w=l[l.length-1];k.Equals(d[m],w)||S.unshift(w.clone().setz(d[m].z)),S.length>1&&f.push(S)}return h.splice(u,1,...f),h}}return h}function r(c,l){const h=k.Sub(c[1],c[0]),u=k.Sub(l[1],l[0]),d=k.Sub(l[0],c[0]);return Math.abs(k.Cpr(h,u))<.1&&Math.abs(k.Cpr(h,d))<.1}}isSamePoint(t,e){return t[0]===e[0]&&t[1]===e[1]}translateIntersect(t){const e=[];for(let i=0;i<t.length;i++){const s=t[i].filter((c,l,h)=>!(l>0&&this.isSamePoint(c,h[l-1]))),n=[];let r=0;for(;r<s.length;){const c=s[r],l=new k(c[0],c[1]);n.push(l),r++}e.push(n)}return e}isLineEraser(t,e){return!(t===C.Pencil&&!e)}remove(t){const{curNodeMap:e,removeIds:i,newWorkDatas:s}=t;let n;for(const[r,c]of e.entries())if(c.rect&&this.eraserRect&&this.eraserPolyline&&Ae(this.eraserRect,c.rect)){const{op:l,toolsType:h}=c,u=this.isLineEraser(h,!1),d=[],p=[];for(let y=0;y<l.length;y+=3){const m=new k(l[y]*this.worldScaling[0]+this.worldPosition[0],l[y+1]*this.worldScaling[1]+this.worldPosition[1],l[y+2]);p.push(m),d.push(new F(m.x,m.y))}const f=d.length&&dt(d)||c.rect;if(Ae(f,this.eraserRect)){if(p.length>1){const y=Do.polyline(p.map(m=>m.XY),this.eraserPolyline);if(y.length&&(i.add(c.name),!u)){const m=this.translateIntersect(y),S=this.cutPolyline(m,p);for(let w=0;w<S.length;w++){const v=`${r}_s_${w}`,T=[];S[w].forEach(N=>{T.push((N.x-this.worldPosition[0])/this.worldScaling[0],(N.y-this.worldPosition[1])/this.worldScaling[1],N.z)}),c.opt&&c.toolsType&&this.vNodes&&(this.vNodes.setInfo(v,{rect:f,op:T,opt:c.opt,canRotate:c.canRotate,scaleType:c.scaleType,toolsType:c.toolsType}),s.set(v,{workId:v,op:T,opt:c.opt,toolsType:c.toolsType}))}}}else i.add(c.name);n=ut(n,f)}}return i.forEach(r=>{var c;return(c=this.vNodes)==null?void 0:c.delete(r)}),n&&(n.x-=W.SafeBorderPadding,n.y-=W.SafeBorderPadding,n.w+=W.SafeBorderPadding*2,n.h+=W.SafeBorderPadding*2),n}consume(t){const{op:e}=t.data;if(!e||e.length===0)return{type:b.None,...this.baseConsumeResult};const i=this.tmpPoints.length;if(i>1&&this.isNear([e[0],e[1]],[this.tmpPoints[i-2],this.tmpPoints[i-1]]))return{type:b.None,...this.baseConsumeResult};i<3?this.tmpPoints.push(e[0],e[1]):this.tmpPoints.splice(2,2,e[0],e[1]);const s=this.computRectCenterPoints();let n;const r=new Set,c=new Map;if(!this.vNodes)return{type:b.None,...this.baseConsumeResult};this.vNodes.setTarget();const l=this.getCanEraserNodeMap(this.vNodes.getCanEraserNodes(this.vNodes.getLastTarget()));for(let h=0;h<s.length-1;h+=2){this.createEraserRect(s.slice(h,h+2));const u=this.remove({curNodeMap:l,removeIds:r,newWorkDatas:c});n=ut(n,u)}if(this.vNodes.deleteLastTarget(),n&&r.size){for(const h of c.keys())r.has(h)&&c.delete(h);return{type:b.RemoveNode,rect:n,removeIds:[...r],newWorkDatas:c}}return{type:b.None,...this.baseConsumeResult}}consumeAll(t){return this.consume(t)}clearTmpPoints(){this.tmpPoints.length=0}getCanEraserNodeMap(t){var e;if(this.serviceWork){const i=Jt(t),s=this.serviceWork.selectorWorkShapes,n=this.serviceWork.workShapes;for(const r of s.values())if((e=r.selectIds)!=null&&e.length)for(const c of r.selectIds)i.delete(c);for(const r of n.keys())i.delete(r);return i}return t}};M(Me,"eraserSizes",Object.freeze([Object.freeze({width:18,height:26}),Object.freeze({width:26,height:34}),Object.freeze({width:34,height:50})]));let Xe=Me;const De=class De extends W{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",ct.none);M(this,"toolsType",C.BitMapEraser);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"worldPosition");M(this,"worldScaling");M(this,"eraserRect");M(this,"eraserPolyline");M(this,"syncUnitTime",Lt.syncOpt.interval);M(this,"syncIndex",0);M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.worldPosition=this.fullLayer.worldPosition,this.worldScaling=this.fullLayer.worldScaling,this.syncTimestamp=0}consumeService(t){const{op:e,isFullWork:i}=t;this.tmpPoints.length=0;for(let c=0;c<e.length;c+=3){const l=new F(e[c],e[c+1],e[c+2]);if(this.tmpPoints.length>0){const h=this.tmpPoints[this.tmpPoints.length-1],u=k.Sub(l,h).uni();l.setv(u)}this.tmpPoints.push(l)}if(this.tmpPoints.length<2)return;const s=this.tmpPoints[0].z*2,n=i?this.fullLayer:this.drawLayer||this.fullLayer;return this.draw({consumePoints:this.tmpPoints,layer:n,thickness:s})}updateTempPoints(t,e){let i=this.tmpPoints.length-1;const s=Date.now();for(let n=0;n<t.length;n+=2){const r=this.tmpPoints.length,c=new F(t[n],t[n+1]);if(r===0){this.tmpPoints.push(c);continue}const l=r-1,h=this.tmpPoints[l],u=k.Sub(c,h).uni();c.isNear(h,e/2)||(k.Equals(u,h.v,.02)&&(this.tmpPoints.pop(),i--),c.setv(u),c.setT(s),this.tmpPoints.push(c))}return Math.max(i,0)}getChangeNodes(t){if(!this.vNodes)return;const e=this.worldPosition;let i=dt(this.tmpPoints,t);i=ko(i,e),i=Lf(i,this.worldScaling,e);const{nodeRange:s}=this.vNodes.getRectIntersectRange(i);if(!s.size)return;const n=[];let r=0;for(let l=1;l<this.tmpPoints.length;l++){const h=this.tmpPoints[l-1],u=this.tmpPoints[l];if(l===1&&r===0&&(n[r]=[h.XY]),n[r].push(u.XY),l<this.tmpPoints.length-1){const d=u.getAngleByPoints(h,this.tmpPoints[l+1]);(d<90||d>270)&&(r++,n[r]=[u.XY])}}this.tmpPoints.length===1&&n.length===0&&n.push([this.tmpPoints[0].XY,this.tmpPoints[0].XY]);const c=new Map;for(const[l,h]of s.entries()){let u=ko(h.rect,[-e[0],-e[1]]);u={x:u.x/this.worldScaling[0],y:u.y/this.worldScaling[1],w:u.w/this.worldScaling[0],h:u.h/this.worldScaling[1]};const d=[u.x,u.y,u.x+u.w,u.y+u.h],p=[],f=[];for(const m of n)Do.polyline(m,d,p);if(p.length&&h.opt)for(const m of p){const S=[];for(let w=0;w<m.length;w++)w!==0&&pe(m[w],m[w-1])||S.push(...m[w]);f.push(S)}h.opt.eraserlines||(h.opt.eraserlines=[]),h.opt.eraserlines&&(h.opt.eraserlines.push({op:f,thickness:t}),c.set(l,h))}return c}async reRenderEffectNodes(t){let e;const{willUpdateNodes:i,worker:s}=t;for(const[n,r]of i.entries()){const{toolsType:c}=r,l=s.createWorkShapeNode({workId:n,toolsType:c,toolsOpt:r.opt});l==null||l.setWorkId(n);let h;if(c===C.Image)h=await l.consumeServiceAsync({isFullWork:!0,replaceId:n,worker:s});else if(c===C.Text)h=await l.consumeServiceAsync({isFullWork:!0,replaceId:n});else try{h=l==null?void 0:l.consumeService({op:r.op,isFullWork:!0,replaceId:n})}catch{continue}h&&(e=ut(e,h))}return e}consume(t){const{op:e}=t.data;if(!e||e.length===0)return{type:b.None,...this.baseConsumeResult};const{thickness:i}=this.workOptions,{width:s,height:n}=De.eraserSizes[i],r=Math.max(s,n)/this.worldScaling[0],c=this.tmpPoints.length,l=this.tmpPoints[this.tmpPoints.length-1],h=this.updateTempPoints(e,r),u=this.tmpPoints[this.tmpPoints.length-1];if(c===this.tmpPoints.length&&u.equalsXY(l.x,l.y))return{type:b.None,...this.baseConsumeResult};this.syncIndex=Math.min(this.syncIndex,h,Math.max(0,this.tmpPoints.length-2));const d=this.syncIndex;this.syncTimestamp===0&&(this.syncTimestamp=Date.now());let p=!1;const f=this.tmpPoints.slice(h),y=this.draw({consumePoints:f,layer:this.fullLayer,thickness:r});f[0].t-this.syncTimestamp>this.syncUnitTime&&(p=!0,this.syncTimestamp=f[0].t,this.syncIndex=this.tmpPoints.length);const m=[];return this.tmpPoints.slice(d).forEach(S=>{m.push(S.x,S.y,r/2)}),{...this.baseConsumeResult,type:b.DrawWork,dataType:H.Local,rect:y,op:p?m:void 0,index:p?d*3:void 0,updateNodeOpt:{useAnimation:!0}}}draw(t){const{consumePoints:e,layer:i,thickness:s}=t,n=this.workId;let r=i.getElementsByName(this.workId)[0],c=dt(e,s);const h=[{op:[e.map(u=>[u.x,u.y]).flat(1)],thickness:s}];return r||(r=new lt.Group({normalize:!0,name:n,pos:[0,0],anchor:[.5,.5],bgcolor:"rgba(0,0,0,0.3)",zIndex:9999}),i.appendChild(r)),this.drawEraserlines({group:r,eraserlines:h,pos:[0,0],layer:i,isClear:!0}),c={x:Math.floor(c.x*this.worldScaling[0]+this.worldPosition[0]-W.SafeBorderPadding),y:Math.floor(c.y*this.worldScaling[1]+this.worldPosition[1]-W.SafeBorderPadding),w:Math.floor(c.w*this.worldScaling[0]+2*W.SafeBorderPadding),h:Math.floor(c.h*this.worldScaling[1]+2*W.SafeBorderPadding)},c}consumeAll(){const t=this.fullLayer.getElementsByName(this.workId);let e;if(t.length&&(e=W.getRectFromLayer(this.fullLayer,this.workId)),t.forEach(u=>{u.remove(),u.disconnect()}),!this.tmpPoints.length)return{type:b.None,...this.baseConsumeResult};const{thickness:i}=this.workOptions,{width:s,height:n}=De.eraserSizes[i],r=Math.max(s,n)/this.worldScaling[0],c=this.getChangeNodes(r);if(!(c!=null&&c.size))return{type:b.FullWork,...this.baseConsumeResult,rect:e};const l=[];this.tmpPoints.map(u=>{l.push(u.x,u.y,r/2)});const h=Dt(l);return{...this.baseConsumeResult,type:b.FullWork,dataType:H.Local,rect:e,ops:h,willUpdateNodes:c}}clearTmpPoints(){this.tmpPoints.length=0}};M(De,"eraserSizes",Object.freeze([Object.freeze({width:18,height:26}),Object.freeze({width:26,height:34}),Object.freeze({width:34,height:50})]));let Ke=De;function Ns(a){switch(a){case C.Arrow:return gs;case C.Pencil:return us;case C.Straight:return Is;case C.Ellipse:return Ms;case C.Polygon:case C.Triangle:return ws;case C.Star:case C.Rhombus:return ms;case C.Rectangle:return ys;case C.SpeechBalloon:return vs;case C.Text:return Je;case C.LaserPen:return ds;case C.Eraser:return Ge;case C.PencilEraser:return Xe;case C.BitMapEraser:return Ke;case C.Selector:return qe;case C.Image:return je}}function Ts(a,o){const{toolsType:t,...e}=a;switch(t){case C.Arrow:return new gs(e);case C.Pencil:return new us(e);case C.Straight:return new Is(e);case C.Ellipse:return new Ms(e);case C.Polygon:case C.Triangle:return new ws(e);case C.Star:case C.Rhombus:return new ms(e);case C.Rectangle:return new ys(e);case C.SpeechBalloon:return new vs(e);case C.Text:return new Je(e);case C.LaserPen:return new ds(e);case C.Eraser:return new Ge(e,o);case C.BitMapEraser:return new Ke(e);case C.PencilEraser:return new Xe(e,o);case C.Selector:return e.vNodes?new qe({...e,vNodes:e.vNodes,drawLayer:e.fullLayer}):void 0;case C.Image:return new je(e);default:return}}function Ss(a){const o=[],t=["PATH","SPRITE","POLYLINE","RECT","ELLIPSE","LABEL"];for(const e of a){if(e.tagName==="GROUP"&&e.children.length)return Ss(e.children);e.tagName&&t.includes(e.tagName)&&o.push(e)}return o}function ut(a,o){if(a&&o){const t=Math.min(a.x,o.x),e=Math.min(a.y,o.y),i=Math.max(a.x+a.w,o.x+o.w),s=Math.max(a.y+a.h,o.y+o.h),n=i-t,r=s-e;return{x:t,y:e,w:n,h:r}}return o||a}function Fo(a,o){if(a&&o){const t=Math.min(a.originX,o.originX),e=Math.min(a.originY,o.originY),i=Math.max(a.originX+a.width,o.originX+o.width),s=Math.max(a.originY+a.height,o.originY+o.height),n=i-t,r=s-e;return{originX:t,originY:e,width:n,height:r}}return o||a}function dt(a,o=0){const t={x:0,y:0,w:0,h:0};let e=1/0,i=1/0,s=-1/0,n=-1/0;return a.forEach(r=>{const[c,l]=r.XY;e=Math.min(e,c-o),i=Math.min(i,l-o),s=Math.max(s,c+o),n=Math.max(n,l+o)}),t.x=e,t.y=i,t.w=s-e,t.h=n-i,t}function Ae(a,o){return!(a.x+a.w<o.x||a.x>o.x+o.w||a.y+a.h<o.y||a.y>o.y+o.h)}function ko(a,o){return{x:a.x+o[0],y:a.y+o[1],w:a.w,h:a.h}}function Pf(a,o){const t=new k(a.x,a.y),e=new k(a.x+a.w,a.y),i=new k(a.x+a.w,a.y+a.h),s=new k(a.x,a.y+a.h),n=new k(a.x+a.w/2,a.y+a.h/2),r=Math.PI*o/180,c=k.RotWith(t,n,r),l=k.RotWith(e,n,r),h=k.RotWith(i,n,r),u=k.RotWith(s,n,r);return[c,l,h,u]}function Cs(a,o){const t=Pf(a,o);return dt(t)}function Lf(a,o,t){const e=new k(a.x,a.y),i=new k(a.x+a.w,a.y),s=new k(a.x+a.w,a.y+a.h),n=new k(a.x,a.y+a.h),r=new k(t[0],t[1]),c=new k(o[0],o[1]),l=k.ScaleWOrigin(e,c,r),h=k.ScaleWOrigin(i,c,r),u=k.ScaleWOrigin(s,c,r),d=k.ScaleWOrigin(n,c,r);return dt([l,h,u,d])}function Df(a,o,t){const e=new k(o[0],o[1]);for(let i=0;i<a.length;i+=3){const s=new k(a[i],a[i+1]),n=Math.PI*t/180,r=k.RotWith(s,e,n);a[i]=r.x,a[i+1]=r.y}}function jf(a,o,t){const e=new k(o[0],o[1]);for(let i=0;i<a.length;i+=2){const s=new k(a[i],a[i+1]),n=Math.PI*t/180,r=k.RotWith(s,e,n);a[i]=r.x,a[i+1]=r.y}}function Ho(a,o,t,e=[0,0]){const i=new k(o[0],o[1]);for(let s=0;s<a.length;s+=3){const n=new k(a[s],a[s+1]),r=new k(t[0],t[1]),c=k.ScaleWOrigin(n,r,i);a[s]=c.x+e[0],a[s+1]=c.y+e[1]}}function $o(a,o,t,e=[0,0]){const i=new k(o[0],o[1]);for(let s=0;s<a.length;s+=2){const n=new k(a[s],a[s+1]),r=new k(t[0],t[1]),c=k.ScaleWOrigin(n,r,i);a[s]=c.x+e[0],a[s+1]=c.y+e[1]}}function ks(a,o){return a[0]>=o.x&&a[0]<=o.x+o.w&&a[1]>=o.y&&a[1]<=o.y+o.h}function xs(a,o){const t=a<=o?1:a/o,e=o<=a?1:o/a;return[t,e]}function Af(a){for(const o of a)if(isNaN(o)||o===1/0||o===-1/0)return!1;return!0}const Ef=a=>{if(a.tagName==="GROUP"){const o=Object.getOwnPropertySymbols(a).find(t=>t.toString()==="Symbol(sealed)");if(o&&a[o])return!0}return!1};function he(a){return`${_e(a.x)},${_e(a.y)} `}function ue(a,o){return`${_e((a.x+o.x)/2)},${_e((a.y+o.y)/2)} `}function _e(a){return+a.toFixed(4)}const Bt=(a,o)=>new Promise(function(t){window.requestIdleCallback?requestIdleCallback(()=>{t(1)},{timeout:o}):setTimeout(()=>{t(2)},o)}).then(function(){a()},()=>{a()}),te=a=>{const o=(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)/o)},Of=(a,o)=>a.x+a.w<o.x||a.x>o.x+o.w||a.y+a.h<o.y||a.y>o.y+o.h?Le.outside:a.x>=o.x&&a.y>=o.y&&a.x+a.w<=o.x+o.w&&a.y+a.h<=o.y+o.h?Le.inside:Le.intersect;function Rf(a){let o=0;for(let t=0;t<a.length;t++){const e=a.charCodeAt(t);e>=1&&e<=126||65376<=e&&e<=65439?o++:o+=2}return o}class Yf{constructor(o,t){M(this,"plugin");M(this,"uid");M(this,"control");this.control=o,this.plugin=t,this.uid=t.displayer.uid}getNamespaceData(){var o;return et.toJS((o=this.plugin)==null?void 0:o.attributes[this.namespace])||{}}getAuthSpaceData(){var o;return et.toJS((o=this.plugin)==null?void 0:o.attributes[this.authSpace])||{}}getUidFromKey(o){return o.split(Vt).length===2&&o.split(Vt)[0]||this.uid}isLocalId(o){return o.split(Vt).length===1}getLocalId(o){return o.split(Vt)[1]}isSelector(o){return this.getLocalId(o)===$}}const zt=class zt extends Yf{constructor(t,e,i){super(t,e);M(this,"authSpace");M(this,"namespace");M(this,"serviceStorage",{});M(this,"storage",{});M(this,"authStorage",{});M(this,"stateDisposer");M(this,"authDisposer");M(this,"asyncClockState",!1);zt.syncInterval=(i||zt.syncInterval)*.5,this.namespace=zt.namespace,this.authSpace=zt.authSpace,this.serviceStorage=this.getNamespaceData(),this.storage=L.cloneDeep(this.serviceStorage),this.authStorage=this.getAuthSpaceData()}getViewIdBySecenPath(t){const e=this.getNamespaceData();for(const[i,s]of Object.entries(e))if(s){for(const n of Object.keys(s))if(n===t)return i}}getScenePathData(t){const e=this.getNamespaceData();for(const i of Object.values(e))if(i){for(const s of Object.keys(i))if(s===t)return L.cloneDeep(i[s])}}getStorageData(t,e){const i=this.getNamespaceData();return i&&i[t]&&L.cloneDeep(i[t][e])||void 0}hasSelector(t,e){const i=this.storage&&this.storage[t]&&this.storage[t][e];return!!(i&&Object.keys(i).find(s=>this.isOwn(s)&&this.getLocalId(s)===$))}addStorageStateListener(t){this.stateDisposer=et.autorun(async()=>{var c;const e=this.getNamespaceData(),{diffView:i,diffScenePath:s,diffData:n}=this.diffFunByView(this.serviceStorage,e);this.serviceStorage=e;const r={};if(Object.keys(i).length>0){r.diffView=i;for(const[l,h]of Object.entries(i)){if(h&&h.newValue===void 0&&this.storage[l]){delete this.storage[l];continue}if(h&&h.newValue){this.storage[l]=L.cloneDeep(h.newValue);continue}}}if(Object.keys(s).length>0){r.diffScenePath=s;for(const[l,h]of Object.entries(s))if(h){const{viewId:u,newValue:d}=h;let p=this.storage[u];if(p&&p[l]&&d===void 0){delete p[l];continue}if(d&&u){p===void 0&&(this.storage[u]={},p=this.storage[u]),p[l]=L.cloneDeep(d);continue}}}if(Object.keys(n).length>0){r.diffData=n;for(const[l,h]of Object.entries(n))if(h){const{viewId:u,scenePath:d,newValue:p}=h;if(u&&d){let f=this.storage[u],y=(c=this.storage[u])==null?void 0:c[d];if(f||(this.storage[u]={},f=this.storage[u],f[d]={},y=f[d]),y){if(y[l]&&p===void 0){delete y[l];continue}if(p&&u){y[l]=L.cloneDeep(p);continue}}}}}Object.keys(r).length>0&&t(r)})}removeStorageStateListener(){this.stateDisposer&&this.stateDisposer()}diffFunByView(t,e){const i=Ct(t),s=Ct(e),n={},r={},c={};for(const l of s)if(!i.includes(l)||t[l]===void 0){n[l]={newValue:e[l],oldValue:void 0};continue}for(const l of i){if(L.isEqual(t[l],e[l]))continue;if(!s.includes(l)||e[l]===void 0){n[l]={newValue:void 0,oldValue:t[l]};continue}const h=this.diffFunByScenePath(t[l],e[l],l);Object.assign(r,h.diffScenePath),Object.assign(c,h.diffData)}return{diffData:c,diffScenePath:r,diffView:n}}diffFunByScenePath(t,e,i){const s=Ct(t),n=Ct(e),r={},c={};for(const l of n)if(!s.includes(l)||t[l]===void 0){r[l]={newValue:e[l],oldValue:void 0,viewId:i};continue}for(const l of s){if(L.isEqual(t[l],e[l]))continue;if(!n.includes(l)||e[l]===void 0){r[l]={newValue:void 0,oldValue:t[l],viewId:i};continue}const h=this.diffFunByKeys(t[l],e[l],l,i);Object.assign(c,h)}return{diffScenePath:r,diffData:c}}diffFunByKeys(t,e,i,s){const n=Ct(t),r=Ct(e),c={};for(const l of r)(!n.includes(l)||t[l]===void 0)&&(c[l]={oldValue:void 0,newValue:e[l],viewId:s,scenePath:i});for(const l of n)if(!L.isEqual(t[l],e[l])){if(!r.includes(l)||e[l]===void 0){c[l]={newValue:void 0,oldValue:t[l],viewId:s,scenePath:i};continue}r.includes(l)&&(c[l]={oldValue:t[l],newValue:e[l],viewId:s,scenePath:i})}return c}transformKey(t){return this.uid+Vt+t}isOwn(t){return t.split(Vt)[0]===this.uid}dispatch(t){const{type:e,workId:i,ops:s,index:n,opt:r,toolsType:c,removeIds:l,updateNodeOpt:h,op:u,selectIds:d,isSync:p,scenePath:f,viewId:y}=t;if(y)switch(e){case b.Clear:const m={};f&&this.storage[y]&&this.storage[y][f]?(delete this.storage[y][f],this.setState(m,{isSync:p,viewId:y,scenePath:f})):this.storage[y]&&(delete this.storage[y],this.setState(m,{isSync:p,viewId:y,scenePath:""})),Bt(()=>{var N;(N=this.control.miniMapManager)==null||N.updateMiniMapCamera(y)},zt.syncInterval);break;case b.CreateWork:if(f&&i&&c&&r){const N=this.isLocalId(i.toString())?this.transformKey(i):i;this.control.renderControl.isUsePageAuth(y)&&this.control.renderControl.addRenderPageElementId({viewId:y,scenePath:f,elementId:N.toString()}),this.updateValue(N.toString(),{type:b.CreateWork,workId:i,toolsType:c,opt:r},{isSync:p,viewId:y,scenePath:f})}break;case b.DrawWork:if(f&&i&&typeof n=="number"&&(u!=null&&u.length)){const N=this.isLocalId(i.toString())?this.transformKey(i):i,I=this.storage[y]&&this.storage[y][f]&&this.storage[y][f][N]||void 0;if(I!=null&&I.ops||(I==null?void 0:I.type)===b.FullWork)return;const x=n?((I==null?void 0:I.op)||[]).slice(0,n).concat(u):u||(I==null?void 0:I.op),z=c||(I==null?void 0:I.toolsType),A=r||(I==null?void 0:I.opt),E=h||(I==null?void 0:I.updateNodeOpt);i&&z&&A&&x&&(this.control.renderControl.isUsePageAuth(y)&&this.control.renderControl.addRenderPageElementId({viewId:y,scenePath:f,elementId:N.toString()}),this.updateValue(N.toString(),{...I,type:b.DrawWork,workId:i,updateNodeOpt:E,toolsType:z,opt:A,op:x,index:n},{isSync:p,viewId:y,scenePath:f}))}break;case b.FullWork:if(f&&i){const N=this.isLocalId(i.toString())?this.transformKey(i):i,I=this.storage[y]&&this.storage[y][f]&&this.storage[y][f][N]||void 0,x=h||(I==null?void 0:I.updateNodeOpt),z=c||(I==null?void 0:I.toolsType),A=r||(I==null?void 0:I.opt),E=s||(I==null?void 0:I.ops);z&&A&&(this.control.renderControl.isUsePageAuth(y)&&this.control.renderControl.addRenderPageElementId({viewId:y,scenePath:f,elementId:N.toString()}),this.updateValue(N.toString(),{type:b.FullWork,updateNodeOpt:x,workId:N,toolsType:z,opt:A,ops:E},{isSync:p,viewId:y,scenePath:f}),Bt(()=>{var j;(j=this.control.miniMapManager)==null||j.updateMiniMapCamera(y)},zt.syncInterval))}break;case b.RemoveNode:if(f&&(l!=null&&l.length)){const N=l.map(I=>this.isLocalId(I+"")?this.transformKey(I):I);this.storage[y]&&this.storage[y][f]&&(Object.keys(this.storage[y][f]).map(I=>{N!=null&&N.includes(I)&&(this.control.renderControl.isUsePageAuth(y)&&this.control.renderControl.delRenderPageElementId({viewId:y,scenePath:f,elementId:I}),this.updateValue(I,void 0,{isSync:p,viewId:y,scenePath:f}))}),Bt(()=>{var I;(I=this.control.miniMapManager)==null||I.updateMiniMapCamera(y)},zt.syncInterval))}break;case b.UpdateNode:if(f&&i&&(h||s||r)){const N=this.isLocalId(i.toString())?this.transformKey(i):i,I=this.storage[y]&&this.storage[y][f]&&this.storage[y][f][N]||void 0;I&&(I.updateNodeOpt=h,(s||u)&&(I.ops=s,I.op=u),r&&(I.opt=r),I.type=b.FullWork,this.updateValue(N.toString(),I,{isSync:p,viewId:y,scenePath:f}),Bt(()=>{var x;(x=this.control.miniMapManager)==null||x.updateMiniMapCamera(y)},zt.syncInterval))}break;case b.Select:if(!f)return;let S;d!=null&&d.length&&(S=d.map(N=>this.isLocalId(N+"")?this.transformKey(N):N));const w=this.transformKey($),v=this.storage[y]&&this.storage[y][f]&&this.storage[y][f][w]||void 0,T=r||(v==null?void 0:v.opt);S&&this.checkOtherSelector(w,S,{isSync:p,viewId:y,scenePath:f}),this.updateValue(w,S&&{type:b.Select,toolsType:C.Selector,opt:T,selectIds:S},{isSync:p,viewId:y,scenePath:f});break}}checkOtherSelector(t,e,i){const{viewId:s,scenePath:n}=i;for(const r of Object.keys(this.storage[s][n]))if(r!==t&&this.getLocalId(r)===$){const c=this.storage[s][n][r];if(c&&c.selectIds){const l=c.selectIds.filter(h=>!e.includes(h));l.length>0&&(c.selectIds=l),this.updateValue(r,l.length&&c||void 0,i)}}}setState(t,e){const{viewId:i,scenePath:s}=e,n=Ct(t);for(let r=0;r<n.length;r++){const c=n[r],l=t[c];typeof l<"u"?(this.storage[i]||(this.storage[i]={}),this.storage[i][s]||(this.storage[i][s]={}),this.storage[i][s][c]=l):delete this.storage[i][s][c]}this.runSyncService(e)}updateValue(t,e,i){const{viewId:s,scenePath:n}=i;e===void 0?delete this.storage[s][n][t]:(this.storage[s]||(this.storage[s]={}),this.storage[s][n]||(this.storage[s][n]={}),this.storage[s][n][t]=e),this.runSyncService(i)}runSyncService(t){this.asyncClockState||(this.asyncClockState=!0,setTimeout(()=>{t.isSync?(this.asyncClockState=!1,this.syncSerivice(t.isAfterUpdate)):Bt(()=>{this.asyncClockState=!1,this.syncSerivice(t.isAfterUpdate)},zt.syncInterval)},t!=null&&t.isSync?0:zt.syncInterval))}syncSerivice(t=!1){const e=Ct(this.serviceStorage),i=Ct(this.storage),s=new Map;for(const n of e){if(!i.includes(n)){s.set(n,void 0);continue}L.isEqual(this.serviceStorage[n],this.storage[n])||this.syncViewData(n,t)}for(const n of i)e.includes(n)||s.set(n,this.storage[n]);if(s.size>5)this.syncStorageView(this.storage,t);else for(const[n,r]of s.entries())this.syncUpdataView(n,r,t)}syncViewData(t,e=!1){const i=Ct(this.serviceStorage[t]),s=Ct(this.storage[t]),n=new Map;for(const r of i){if(!s.includes(r)){n.set(r,void 0);continue}L.isEqual(this.serviceStorage[t][r],this.storage[t][r])||this.syncScenePathData(t,r,e)}for(const r of s)i.includes(r)||n.set(r,this.storage[t][r]);if(n.size>5)this.syncStorageScenePath(t,this.storage[t],e);else for(const[r,c]of n.entries())this.syncUpdataScenePath(t,r,c,e)}syncScenePathData(t,e,i=!1){const s=Ct(this.serviceStorage[t][e]),n=Ct(this.storage[t][e]),r=new Map;for(const c of s){if(!n.includes(c)){r.set(c,void 0);continue}L.isEqual(this.serviceStorage[t][e][c],this.storage[t][e][c])||r.set(c,this.storage[t][e][c])}for(const c of n)s.includes(c)||r.set(c,this.storage[t][e][c]);if(r.size>5)this.syncStorageKey(t,e,this.storage[t][e],i);else for(const[c,l]of r.entries())this.syncUpdataKey(t,e,c,l,i)}syncUpdataView(t,e,i=!1){var n;Object.keys(this.serviceStorage).length?(i||(e===void 0?delete this.serviceStorage[t]:this.serviceStorage[t]=L.cloneDeep(e)),(n=this.plugin)==null||n.updateAttributes([this.namespace,t],e)):this.syncStorageView(this.storage,i)}syncStorageView(t,e=!1){var i;e||t&&(this.serviceStorage=L.cloneDeep(t)),(i=this.plugin)==null||i.updateAttributes([this.namespace],t)}syncUpdataScenePath(t,e,i,s=!1){var r;Object.keys(this.serviceStorage[t]).length?(s||(i===void 0?delete this.serviceStorage[t][e]:this.serviceStorage[t][e]=i),(r=this.plugin)==null||r.updateAttributes([this.namespace,t,e],i)):this.syncStorageScenePath(t,this.storage[t],s)}syncStorageScenePath(t,e,i=!1){var s;i||e&&(this.serviceStorage[t]=e),(s=this.plugin)==null||s.updateAttributes([this.namespace,t],e)}syncUpdataKey(t,e,i,s,n=!1){var c;Object.keys(this.serviceStorage[t][e]).length?(n||(s===void 0?delete this.serviceStorage[t][e][i]:this.serviceStorage[t][e][i]=s),(c=this.plugin)==null||c.updateAttributes([this.namespace,t,e,i],s)):this.syncStorageKey(t,e,this.storage[t][e],n)}syncStorageKey(t,e,i,s=!1){var n;s||(this.serviceStorage[t][e]=i),(n=this.plugin)==null||n.updateAttributes([this.namespace,t,e],i)}keyTransformWorkId(t){const e=t.split(Vt);return e.length===2?e[1]:t}destroy(){this.removeStorageStateListener(),this.serviceStorage={},this.storage={},this.removeAuthStateListener(),this.authStorage={}}dispatchPageAuth(t,e=!0){var l,h,u,d,p,f,y,m,S,w,v,T,N,I,x,z,A,E,j,O,P,Y,ot,tt,Q,J,G,Z,X,rt,wt,it,at,U,nt,ht,vt,Ht;const{operation:i,viewId:s,scenePath:n,pageId:r,pageData:c}=t;switch(i){case xt.addPage:{if(!s||!n||!r)return;const yt=[this.authSpace];Object.keys(this.authStorage).length&&yt.push("pageAuth");const gt=this.authStorage.pageAuth||{};this.authStorage.pageAuth=gt,Object.keys(gt).length&&yt.push(s),gt[s]=gt[s]||{},Object.keys(gt[s]).length&&yt.push(n),gt[s][n]=gt[s][n]||{render:(c==null?void 0:c.render)||"localSelf",pages:{}},Object.keys(gt[s][n].pages).length&&yt.push("pages",r);const oe={};if(c!=null&&c.elementIds)for(const Tt of c.elementIds.keys())oe[Tt]=!0;gt[s][n].pages[r]=oe,e&&(yt.length===1?(l=this.plugin)==null||l.updateAttributes(yt,L.cloneDeep(this.authStorage)):yt.length===2?(h=this.plugin)==null||h.updateAttributes(yt,L.cloneDeep(gt)):yt.length===3?(u=this.plugin)==null||u.updateAttributes(yt,L.cloneDeep(gt[s])):yt.length===4?(d=this.plugin)==null||d.updateAttributes(yt,L.cloneDeep(gt[s][n])):(p=this.plugin)==null||p.updateAttributes(yt,L.cloneDeep(oe)));return}case xt.renderPage:{if(!s||!n||!(c!=null&&c.render))return;this.authStorage.pageAuth&&this.authStorage.pageAuth[s]&&this.authStorage.pageAuth[s][n]&&c.render!==this.authStorage.pageAuth[s][n].render&&(this.authStorage.pageAuth[s][n].render=c.render,e&&((f=this.plugin)==null||f.updateAttributes([this.authSpace,"pageAuth",s,n,"render"],c.render)));return}case xt.deletePage:{if(!s||!n||!r)return;(v=(w=(S=(m=(y=this.authStorage)==null?void 0:y.pageAuth)==null?void 0:m[s])==null?void 0:S[n])==null?void 0:w.pages)!=null&&v[r]&&(delete this.authStorage.pageAuth[s][n].pages[r],e&&((T=this.plugin)==null||T.updateAttributes([this.authSpace,"pageAuth",s,n,"pages",r],void 0)));return}case xt.clearPage:{if(!s||!n||!r)return;(A=(z=(x=(I=(N=this.authStorage)==null?void 0:N.pageAuth)==null?void 0:I[s])==null?void 0:x[n])==null?void 0:z.pages)!=null&&A[r]&&(delete this.authStorage.pageAuth[s][n].pages[r],e&&((E=this.plugin)==null||E.updateAttributes([this.authSpace,"pageAuth",s,n,"pages",r],{})));return}case xt.addElement:{if(!s||!n||!r||!(c!=null&&c.elementId))return;(ot=(Y=(P=(O=(j=this.authStorage)==null?void 0:j.pageAuth)==null?void 0:O[s])==null?void 0:P[n])==null?void 0:Y.pages)!=null&&ot[r]&&(this.authStorage.pageAuth[s][n].pages[r][c.elementId]=!0,e&&((tt=this.plugin)==null||tt.updateAttributes([this.authSpace,"pageAuth",s,n,"pages",r,c.elementId],!0)));return}case xt.deleteElement:{if(!s||!n||!r||!(c!=null&&c.elementId))return;(rt=(X=(Z=(G=(J=(Q=this.authStorage)==null?void 0:Q.pageAuth)==null?void 0:J[s])==null?void 0:G[n])==null?void 0:Z.pages)==null?void 0:X[r])!=null&&rt[c.elementId]&&(delete this.authStorage.pageAuth[s][n].pages[r][c.elementId],e&&((wt=this.plugin)==null||wt.updateAttributes([this.authSpace,"pageAuth",s,n,"pages",r,c.elementId],void 0)));return}case xt.clearViewScenePath:{if(!s||!n)return;(U=(at=(it=this.authStorage)==null?void 0:it.pageAuth)==null?void 0:at[s])!=null&&U[n]&&(delete this.authStorage.pageAuth[s][n],e&&((nt=this.plugin)==null||nt.updateAttributes([this.authSpace,"pageAuth",s,n],void 0)));return}case xt.clearView:{if(!s)return;(vt=(ht=this.authStorage)==null?void 0:ht.pageAuth)!=null&&vt[s]&&(delete this.authStorage.pageAuth[s],e&&((Ht=this.plugin)==null||Ht.updateAttributes([this.authSpace,"pageAuth",s],void 0)));return}}}dispatchRenderAuth(t,e=!0){var l,h,u,d,p,f,y,m,S,w,v,T,N,I,x,z,A,E,j,O;const{operation:i,viewId:s,uid:n,renderData:r,isClear:c}=t;if(s)switch(i){case Ut.setAuth:{if(!r||r.render===void 0&&r.hide===void 0&&r.clear===void 0){this.authStorage.renderAuth&&this.authStorage.renderAuth[s]&&(delete this.authStorage.renderAuth[s],e&&((l=this.plugin)==null||l.updateAttributes([this.authSpace,"renderAuth",s],void 0)));return}const P=[this.authSpace];Object.keys(this.authStorage).length&&P.push("renderAuth");const Y=this.authStorage.renderAuth||{};Object.keys(Y).length&&P.push(s),Y[s]={},this.authStorage.renderAuth=Y;const{render:ot,hide:tt,clear:Q}=r;if(ot===!0)Y[s].render=!0;else if(L.isSet(ot)){Y[s].render={};for(const J of ot.keys())Y[s].render[J]=!0}if(tt===!0)Y[s].hide=!0;else if(L.isSet(tt)){Y[s].hide={};for(const J of tt.keys())Y[s].hide[J]=!0}if(Q===!0)Y[s].clear=!0;else if(L.isSet(Q)){Y[s].clear={};for(const J of Q.keys())Y[s].clear[J]=!0}e&&(P.length===1?(h=this.plugin)==null||h.updateAttributes(P,L.cloneDeep(this.authStorage)):P.length===2?(u=this.plugin)==null||u.updateAttributes(P,L.cloneDeep(Y)):(d=this.plugin)==null||d.updateAttributes(P,L.cloneDeep(Y[s])));return}case Ut.setShow:{if(!n)return;const P=[this.authSpace];Object.keys(this.authStorage).length&&P.push("renderAuth");const Y=this.authStorage.renderAuth||{};Object.keys(Y).length&&P.push(s),Y[s]=Y[s]||{},this.authStorage.renderAuth=Y,Object.keys(Y[s]).length&&P.push("render"),Y[s].render=Y[s].render||{},Y[s].render!==!0&&(Object.keys(Y[s].render).length&&P.push(n),Y[s].render[n]=!0),Y[s].hide!==!0&&((p=Y[s].hide)!=null&&p[n])&&(delete Y[s].hide[n],e&&((f=this.plugin)==null||f.updateAttributes([this.authSpace,"renderAuth",s,"hide",n],void 0))),e&&(P.length===1?(y=this.plugin)==null||y.updateAttributes(P,L.cloneDeep(this.authStorage)):P.length===2?(m=this.plugin)==null||m.updateAttributes(P,L.cloneDeep(Y)):P.length===3?(S=this.plugin)==null||S.updateAttributes(P,L.cloneDeep(Y[s])):(w=this.plugin)==null||w.updateAttributes(P,!0));return}case Ut.setHide:{if(!n)return;const P=[this.authSpace];Object.keys(this.authStorage).length&&P.push("renderAuth");const Y=this.authStorage.renderAuth||{};Object.keys(Y).length&&P.push(s),Y[s]=Y[s]||{},this.authStorage.renderAuth=Y,Object.keys(Y[s]).length&&P.push("hide"),Y[s].hide=Y[s].hide||{},Y[s].hide!==!0&&(Object.keys(Y[s].hide).length&&P.push(n),Y[s].hide[n]=!0),Y[s].render!==!0&&((v=Y[s].render)!=null&&v[n])&&(delete Y[s].render[n],e&&((T=this.plugin)==null||T.updateAttributes([this.authSpace,"renderAuth",s,"render",n],void 0))),e&&(P.length===1?(N=this.plugin)==null||N.updateAttributes(P,L.cloneDeep(this.authStorage)):P.length===2?(I=this.plugin)==null||I.updateAttributes(P,L.cloneDeep(Y)):P.length===3?(x=this.plugin)==null||x.updateAttributes(P,L.cloneDeep(Y[s])):(z=this.plugin)==null||z.updateAttributes(P,!0));return}case Ut.setClear:{if(!n)return;const P=[this.authSpace];Object.keys(this.authStorage).length&&P.push("renderAuth");const Y=this.authStorage.renderAuth||{};Object.keys(Y).length&&P.push(s),Y[s]=Y[s]||{},this.authStorage.renderAuth=Y,Object.keys(Y[s]).length&&P.push("clear"),Y[s].clear=Y[s].clear||{},Y[s].clear!==!0&&(Object.keys(Y[s].clear).length&&P.push(n),c?Y[s].clear[n]=!0:delete Y[s].clear[n]),e&&(P.length===1?(A=this.plugin)==null||A.updateAttributes(P,L.cloneDeep(this.authStorage)):P.length===2?(E=this.plugin)==null||E.updateAttributes(P,L.cloneDeep(Y)):P.length===3?(j=this.plugin)==null||j.updateAttributes(P,L.cloneDeep(Y[s])):(O=this.plugin)==null||O.updateAttributes(P,c?!0:void 0));return}}}addAuthStateListener(t){this.authDisposer=et.autorun(async()=>{const e=this.getAuthSpaceData(),{renderAuth:i,pageAuth:s}=e;let n,r;L.isEqual(i,this.authStorage.renderAuth)||(n=this.diffAuthFun(this.authStorage.renderAuth||{},i||{}),this.authStorage.renderAuth=i),L.isEqual(s,this.authStorage.pageAuth)||(r=this.diffAuthPageFun(this.authStorage.pageAuth||{},s||{}),this.authStorage.pageAuth=s),(n||r)&&t(n,r)})}removeAuthStateListener(){this.authDisposer&&this.authDisposer()}diffAuthFun(t,e){const i=Ct(t),s=Ct(e),n={};for(const r of s)if(!i.includes(r)||t[r]===void 0){n[r]={newValue:e[r],oldValue:void 0};continue}for(const r of i)if(!L.isEqual(t[r],e[r])){if(!s.includes(r)||e[r]===void 0){n[r]={newValue:void 0,oldValue:t[r]};continue}n[r]={newValue:e[r],oldValue:t[r]}}return n}diffAuthPageFun(t,e){const i=Ct(t),s=Ct(e),n={};for(const r of s)if(!i.includes(r)||t[r]===void 0){n[r]={newValue:e[r],oldValue:void 0};continue}for(const r of i)if(!L.isEqual(t[r],e[r])){if(!s.includes(r)||e[r]===void 0){n[r]={newValue:void 0,oldValue:t[r]};continue}n[r]={newValue:e[r],oldValue:t[r]}}return n}};M(zt,"namespace","PluginState"),M(zt,"authSpace","PluginAuth"),M(zt,"syncInterval",500);let xo=zt;class Wf{constructor(){M(this,"roomMembers",[]);M(this,"onChangeHooks",new Set)}setRoomMembers(o){this.executChangeUidHook(this.roomMembers,o),this.roomMembers=o}executChangeUidHook(o,t){const e={online:t.map(i=>{var s;return((s=i.payload)==null?void 0:s.uid)||i.session}),offline:o.map(i=>{var s;return((s=i.payload)==null?void 0:s.uid)||i.session})};this.onChangeHooks.forEach(i=>i(e))}getAllRoomMembers(){return this.roomMembers}getRoomMember(o){return this.roomMembers.find(t=>{var e;return((e=t.payload)==null?void 0:e.uid)===o})}isOnLine(o){return!this.getRoomMember(o)}onUidChangeHook(o){this.onChangeHooks.add(o)}destroy(){this.onChangeHooks.clear()}}var Gt=(a=>(a[a.Text=1]="Text",a[a.Shape=2]="Shape",a))(Gt||{});const Uf="cursorhover",Bf=20,It="mainView",bt=class bt{createProxy(o){const t=new Proxy(o,{get(e,i,s){const n=bt.interceptors.hasOwnProperty(i)?bt.interceptors:e;return Reflect.get(n,i,s)}});return bt.proxyToRaw.set(t,o),t}};M(bt,"proxyToRaw",new WeakMap),M(bt,"interceptors",{entries(...o){return bt.proxyToRaw.get(this).entries(...o)},forEach(...o){return bt.proxyToRaw.get(this).forEach(...o)},size(){return bt.proxyToRaw.get(this).size},get(o){return bt.proxyToRaw.get(this).get(o)},set(o,t){return bt.proxyToRaw.get(this).set(o,t)},delete(o,t){return bt.proxyToRaw.get(this).delete(o)},clear(){return bt.proxyToRaw.get(this).clear()}});let se=bt;class Vf{constructor(o){M(this,"internalMsgEmitter");M(this,"control");M(this,"editors");M(this,"activeId");M(this,"proxyMap");M(this,"taskqueue",new Map);const{control:t,internalMsgEmitter:e}=o;this.control=t,this.internalMsgEmitter=e;const i=new Map;this.proxyMap=new se;const s=this,n=se.interceptors.set;se.interceptors.set=function(c,l){return s.interceptors.set(c,l),n.call(this,c,l)};const r=se.interceptors.delete;se.interceptors.delete=function(c,l){return s.interceptors.delete(c,l),r.call(this,c)},this.editors=this.proxyMap.createProxy(i)}get collector(){return this.control.collector}filterEditor(o){const t=new Map;return this.editors.forEach((e,i)=>{e.viewId===o&&t.set(i,e)}),t}get interceptors(){return{set:(o,t)=>{var p,f,y,m,S,w,v,T;if(!this.collector)return!0;const{viewId:e,scenePath:i,canSync:s,canWorker:n,type:r,opt:c,dataType:l}=t;if(!n&&!s)return!0;const u=((p=this.collector)==null?void 0:p.isLocalId(o))?(f=this.collector)==null?void 0:f.transformKey(o):o,d=((y=this.collector)==null?void 0:y.storage[e])&&this.collector.storage[e][i]&&this.collector.storage[e][i][u]||void 0;d?d.toolsType===C.Text&&(n&&(this.control.worker.queryTaskBatchData({workId:o,msgType:b.UpdateNode}).forEach(N=>{var I;(I=this.control.worker)==null||I.taskBatchData.delete(N)}),(v=this.control.worker)==null||v.taskBatchData.add({workId:o,msgType:b.UpdateNode,dataType:l||H.Local,toolsType:C.Text,opt:c,viewId:e,scenePath:i,willRefresh:!0}),(T=this.control.worker)==null||T.runAnimation()),s&&Bt(()=>{var N;(N=this.collector)==null||N.dispatch({type:b.UpdateNode,workId:o,toolsType:C.Text,opt:c,viewId:e,scenePath:i})},this.control.worker.maxLastSyncTime)):r===Gt.Text&&(s&&((m=this.collector)==null||m.dispatch({type:c.text&&b.FullWork||b.CreateWork,workId:o,toolsType:C.Text,opt:c,isSync:!0,viewId:e,scenePath:i})),n&&((S=this.control.worker)==null||S.taskBatchData.add({workId:o,msgType:c.text&&b.FullWork||b.CreateWork,dataType:l||H.Local,toolsType:C.Text,opt:c,viewId:e,scenePath:i,willRefresh:!0}),(w=this.control.worker)==null||w.runAnimation()))},delete:o=>{var r,c;if(!this.collector)return!0;const t=this.editors.get(o);if(!t)return!0;const{viewId:e,scenePath:i,canSync:s,canWorker:n}=t;if(!n&&!s)return!0;n&&((r=this.control.worker)==null||r.taskBatchData.add({workId:o,toolsType:C.Text,msgType:b.RemoveNode,dataType:H.Local,viewId:e,scenePath:i,willRefresh:!0}),(c=this.control.worker)==null||c.runAnimation()),s&&Bt(()=>{var l;(l=this.collector)==null||l.dispatch({type:b.RemoveNode,removeIds:[o],toolsType:C.Text,viewId:e,scenePath:i})},this.control.worker.maxLastSyncTime)},clear(){return!0}}}computeTextActive(o,t){var s,n,r,c;const e=(s=this.control.viewContainerManager)==null?void 0:s.transformToScenePoint(o,t),i=(n=this.control.viewContainerManager)==null?void 0:n.getCurScenePath(t);t&&i&&((r=this.control.worker)==null||r.taskBatchData.add({msgType:b.GetTextActive,dataType:H.Local,op:e,viewId:t,scenePath:i}),(c=this.control.worker)==null||c.runAnimation())}checkEmptyTextBlur(){var t;let o=this.activeId;for(const[e,i]of this.editors.entries())if(i.opt.uid&&i.opt.uid===((t=this.collector)==null?void 0:t.uid)){o=e;break}if(o){const e=this.editors.get(o);(e==null?void 0:e.opt.text)&&(e==null?void 0:e.opt.text.replace(/\s*,/g,""))?this.unActive(o):this.delete(o,!0,!0)}}onCameraChange(o,t){var e,i;for(const[s,n]of this.editors.entries())if(n.viewId===t){const{boxPoint:r,boxSize:c}=n.opt,l=r&&((e=this.control.viewContainerManager)==null?void 0:e.transformToOriginPoint(r,n.viewId)),h=(i=this.control.viewContainerManager)==null?void 0:i.getCurScenePath(t);if(h&&t){const u={x:l&&l[0]||0,y:l&&l[1]||0,w:c&&c[0]||0,h:c&&c[1]||0,opt:n.opt,scale:o.scale,type:Gt.Text,viewId:t,scenePath:h,canWorker:!1,canSync:!1};this.editors.set(s,u),this.control.viewContainerManager.setActiveTextEditor(t,this.activeId)}}}onServiceDerive(o){var f,y;const{workId:t,opt:e,msgType:i,viewId:s,scenePath:n,dataType:r}=o;if(!t||!s||!n)return;const c=t.toString();if(i===b.RemoveNode){this.delete(c,!0,!0);return}const{boxPoint:l,boxSize:h}=e,u=l&&((f=this.control.viewContainerManager)==null?void 0:f.transformToOriginPoint(l,s)),d=this.control.viewContainerManager.getView(s),p={x:u&&u[0]||0,y:u&&u[1]||0,w:h&&h[0]||0,h:h&&h[1]||0,opt:e,type:Gt.Text,canWorker:!0,canSync:!1,dataType:r,scale:((y=d==null?void 0:d.cameraOpt)==null?void 0:y.scale)||1,viewId:s,scenePath:n};this.editors.set(c,p),r===H.Service&&e.workState===D.Done&&this.activeId===c&&(this.activeId=void 0),this.control.viewContainerManager.setActiveTextEditor(s,this.activeId)}updateForViewEdited(o,t){var i;this.editors.set(o,t);const e=(i=this.taskqueue.get(o))==null?void 0:i.resolve;e&&e(t)}active(o){var e;const t=this.editors.get(o);t&&t.viewId&&(t.opt.workState=D.Start,t.opt.uid=(e=this.collector)==null?void 0:e.uid,this.activeId=o,t.canWorker=!0,t.canSync=!0,this.editors.set(o,t),this.control.viewContainerManager.setActiveTextEditor(t.viewId,this.activeId))}unActive(o){const t=this.editors.get(o);t&&t.viewId&&(t.opt.workState=D.Done,t.opt.uid=void 0,t.canWorker=!0,t.canSync=!0,this.editors.set(o,t),this.activeId=void 0,this.control.viewContainerManager.setActiveTextEditor(t.viewId,this.activeId))}createTextForMasterController(o,t){var n;const{workId:e,isActive:i,...s}=o;t&&this.internalMsgEmitter.emit("addUndoTicker",t,s.viewId),s.opt.uid=(n=this.collector)==null?void 0:n.uid,i&&(this.activeId=e),s.dataType=H.Local,s.canWorker=!0,s.canSync=!0,this.editors.set(e,s),this.control.viewContainerManager.setActiveTextEditor(s.viewId,this.activeId)}updateTextForMasterController(o,t){var n;const{workId:e,...i}=o;t&&this.internalMsgEmitter.emit("addUndoTicker",t,i.viewId);const s=this.editors.get(e)||{};i.opt&&(i.opt.uid=(n=this.collector)==null?void 0:n.uid),i.dataType=H.Local,this.editors.set(e,{...s,...i}),this.control.viewContainerManager.setActiveTextEditor(i.viewId,this.activeId)}async updateTextControllerWithEffectAsync(o,t){var h;const{workId:e,...i}=o;t&&this.internalMsgEmitter.emit("addUndoTicker",t,i.viewId);const s=this.editors.get(e)||{};i.opt&&(i.opt.uid=(h=this.collector)==null?void 0:h.uid),i.dataType=H.Local;const n={...s,...i};if(this.editors.set(e,n),this.control.viewContainerManager.setActiveTextEditor(i.viewId,this.activeId),this.taskqueue.has(e)){const u=this.taskqueue.get(e);return u&&(u.clocker&&clearTimeout(u.clocker),this.taskqueue.delete(e)),await this.updateTextControllerWithEffectAsync(o)}const r=setTimeout(()=>{var d;const u=(d=this.taskqueue.get(e))==null?void 0:d.resolve;u&&u(n)},50),c=await new Promise(u=>{this.taskqueue.set(e,{resolve:u,clocker:r})}),l=this.taskqueue.get(e);return l&&(l.clocker&&clearTimeout(l.clocker),this.taskqueue.delete(e)),c}updateTextForWorker(o,t){const{workId:e,isActive:i,...s}=o,r={...this.editors.get(e)||{},...s};if(i){r.canWorker=!1,r.canSync=!1,this.editors.set(e,r),this.active(e);return}this.editors.set(e,r),this.control.viewContainerManager.setActiveTextEditor(s.viewId,this.activeId),t&&this.internalMsgEmitter.emit("addUndoTicker",t,s.viewId)}get(o){return this.editors.get(o)}delete(o,t,e){const i=this.editors.get(o);if(i){const s=i.viewId;i.canSync=t,i.canWorker=e,this.editors.delete(o),this.activeId===o&&(this.activeId=void 0),this.control.viewContainerManager.setActiveTextEditor(s,this.activeId)}}deleteBatch(o,t,e){const i=new Set;for(const s of o){const n=this.editors.get(s);if(n){const r=n.viewId;n.canSync=t,n.canWorker=e,this.editors.delete(s),this.activeId===s&&(this.activeId=void 0),i.add(r)}}for(const s of i)this.control.viewContainerManager.setActiveTextEditor(s,this.activeId)}clear(o,t){this.editors.forEach((e,i)=>{e.viewId===o&&(t&&(e.canSync=!1),e.canWorker=!1,this.editors.delete(i))}),this.activeId=void 0,this.control.viewContainerManager.setActiveTextEditor(o,this.activeId)}destory(){this.editors.clear(),this.activeId=void 0}}class Ff{constructor(o){M(this,"expirationTime",Lt.cursor.expirationTime);M(this,"internalMsgEmitter");M(this,"control");M(this,"eventName","applianc-cursor");M(this,"displayer");M(this,"roomMember");M(this,"animationId");M(this,"maxLastSyncTime",Lt.syncOpt.interval);M(this,"willSendEventWorkers",[]);M(this,"willConsumeEventWorkers",new Map);M(this,"sendEventTimerId");M(this,"animationDrawWorkers",new Map);M(this,"animationEventWorkers",new Map);M(this,"cursorInfoMap",new Map);M(this,"doneRenderCursorInfoMap",new Map);M(this,"eventCollector");var i,s;const{control:t,internalMsgEmitter:e}=o;this.internalMsgEmitter=e,this.control=t,this.roomMember=t.roomMember,this.maxLastSyncTime=((s=(i=this.control.pluginOptions)==null?void 0:i.syncOpt)==null?void 0:s.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(o){var r;const{event:t,payload:e}=o;if(t!==this.eventName)return;const{uid:i,op:s,type:n}=e;if(((r=this.control.collector)==null?void 0:r.uid)!==i&&n===Pe.Cursor&&(s!=null&&s.length)){const c=this.willConsumeEventWorkers.get(i)||[];for(const l of s){const{viewId:h}=l;L.isNumber(l.consumPoint[0])&&L.isNumber(l.consumPoint[1])&&(l.consumPoint=this.control.viewContainerManager.transformToOriginPoint(l.consumPoint,h)),this.control.renderControl.isFilterCursor(h)&&c.unshift({...l,timestamp:Date.now()})}this.willConsumeEventWorkers.set(i,c),this.runAnimation()}}onFocusViewChange(){this.checkDrawWorks(),this.runAnimation()}updateRoomMembers(o){const{offline:t}=o;for(const e of this.cursorInfoMap.keys())e&&t.includes(e)&&this.cursorInfoMap.delete(e)}getKey(o,t){return`${o}${Vt}${t}`}getUidAndviewId(o){const[t,e]=o.split(Vt);return{uid:t,viewId:e}}runAnimation(){this.animationId||(this.animationId=requestAnimationFrame(this.animationCursor.bind(this)))}checkDrawWorks(){var t;const o=this.control.viewContainerManager.focuedViewId;for(const[e,i]of this.animationDrawWorkers.entries()){const{viewId:s,uid:n}=this.getUidAndviewId(e);n!==((t=this.control.collector)==null?void 0:t.uid)&&s!==o&&i.workState===D.Done&&(i.consumPoint=[void 0,void 0])}}animationCursor(){this.animationId=void 0;const o=Date.now();for(const[e,i]of this.animationDrawWorkers.entries()){const{uid:s,viewId:n}=this.getUidAndviewId(e),r=this.roomMember.getRoomMember(s);if(!r){this.animationDrawWorkers.delete(e);continue}const{consumPoint:c,timestamp:l,workState:h}=i,u=this.cursorInfoMap.get(n)||new Map;c&&L.isNumber(c[0])&&L.isNumber(c[1])&&l+this.expirationTime>o?u.set(r.memberId,{x:c[0],y:c[1],roomMember:r,timestamp:l,type:1,workState:h}):u.delete(r.memberId),u.size?this.cursorInfoMap.set(n,u):this.cursorInfoMap.delete(n),this.animationDrawWorkers.delete(e)}const t=new Set;for(const[e,i]of this.cursorInfoMap.entries())if(i)for(const[s,n]of i.entries())n.type===1&&n.workState!==D.Done&&t.add(s);else this.cursorInfoMap.delete(e);for(const[e,i]of this.willConsumeEventWorkers.entries()){const s=this.roomMember.getRoomMember(e);if(L.isNumber(s==null?void 0:s.memberId)&&!t.has(s.memberId)){const n=i.pop();n?this.animationEventWorkers.set(e,n):this.willConsumeEventWorkers.delete(e)}}for(const[e,i]of this.animationEventWorkers.entries()){const s=this.roomMember.getRoomMember(e);if(!s){this.animationEventWorkers.delete(e);continue}const{viewId:n,consumPoint:r,timestamp:c}=i,l=this.cursorInfoMap.get(n)||new Map;r&&L.isNumber(r[0])&&L.isNumber(r[1])&&c+this.expirationTime>o?l.set(s.memberId,{x:r[0],y:r[1],roomMember:s,timestamp:c,type:0}):l.delete(s.memberId),l.size?this.cursorInfoMap.set(n,l):this.cursorInfoMap.delete(n),this.animationEventWorkers.delete(e)}for(const e of this.doneRenderCursorInfoMap.keys())this.cursorInfoMap.has(e)||(this.doneRenderCursorInfoMap.delete(e),this.internalMsgEmitter.emit([q.Cursor,e],[]));for(const[e,i]of this.cursorInfoMap.entries())if(i!=null&&i.size){const s=[];for(const[r,c]of i.entries()){const{timestamp:l,...h}=c;l+this.expirationTime>o?s.push(h):(i.delete(r),i.size===0&&(this.cursorInfoMap.delete(e),this.doneRenderCursorInfoMap.delete(e),this.internalMsgEmitter.emit([q.Cursor,e],[])))}const n=this.doneRenderCursorInfoMap.get(e);L.isEqual(n,s)||(this.doneRenderCursorInfoMap.set(e,s),this.internalMsgEmitter.emit([q.Cursor,e],s))}else this.cursorInfoMap.delete(e),this.doneRenderCursorInfoMap.delete(e),this.internalMsgEmitter.emit([q.Cursor,e],[]);(this.willConsumeEventWorkers.size||this.cursorInfoMap.size)&&this.runAnimation()}sendEvent(o,t){if(this.displayer&&et.isRoom(this.displayer)){const e=L.isNumber(o[0])&&L.isNumber(o[1])&&this.control.viewContainerManager.transformToScenePoint(o,t)||[void 0,void 0];this.willSendEventWorkers.push({consumPoint:e,viewId:t}),this.sendEventTimerId||(this.sendEventTimerId=setTimeout(()=>{this.dispatchMagixEvent()},this.maxLastSyncTime))}}dispatchMagixEvent(){var o;this.displayer.dispatchMagixEvent(this.eventName,{type:Pe.Cursor,op:L.cloneDeep(this.willSendEventWorkers),uid:(o=this.control.collector)==null?void 0:o.uid}),this.willSendEventWorkers.length=0,this.sendEventTimerId&&(clearTimeout(this.sendEventTimerId),this.sendEventTimerId=void 0)}collectServiceCursor(o){var n;const{op:t,uid:e,workState:i,viewId:s}=o;if(e&&t&&i&&s){const r=this.roomMember.getRoomMember(e);if(!r||e===((n=this.control.collector)==null?void 0:n.uid))return;const c=this.getKey(e,s);let l=[void 0,void 0];if(L.isNumber(t[0])&&L.isNumber(t[1])){const[u,d]=this.control.viewContainerManager.transformToOriginPoint(t,s);l=[u,d]}if(i===D.Start){for(const u of this.cursorInfoMap.values())if(u!=null&&u.size)for(const d of u.keys())d===r.memberId&&u.delete(d)}const h={consumPoint:l,workState:i,viewId:s,timestamp:Date.now()};if(i===D.Start||i===D.Done){const u=this.willConsumeEventWorkers.get(e);i===D.Start&&u&&this.willConsumeEventWorkers.delete(e),u&&i===D.Done&&(h.timestamp=h.timestamp-this.expirationTime)}this.animationDrawWorkers.set(c,h),this.runAnimation()}}unabled(){var o;this.displayer&&et.isRoom(this.displayer)&&(this.willSendEventWorkers.length=0,this.displayer.dispatchMagixEvent(this.eventName,{type:Pe.Cursor,op:[{viewId:this.control.viewContainerManager.focuedViewId,consumPoint:[void 0,void 0]}],uid:(o=this.control.collector)==null?void 0:o.uid}),this.sendEventTimerId&&(clearTimeout(this.sendEventTimerId),this.sendEventTimerId=void 0))}clearViewCursor(o){var t,e,i;for(const[s]of this.animationDrawWorkers.entries()){const{uid:n}=this.getUidAndviewId(s);n===((t=this.control.collector)==null?void 0:t.uid)&&o===o&&this.animationDrawWorkers.delete(s)}for(const[s]of this.willConsumeEventWorkers.entries())s===((e=this.control.collector)==null?void 0:e.uid)&&this.willConsumeEventWorkers.delete(s);for(const[s]of this.animationEventWorkers.entries())s===((i=this.control.collector)==null?void 0:i.uid)&&this.animationEventWorkers.delete(s);for(const[s]of this.cursorInfoMap.entries())s===s&&(this.cursorInfoMap.delete(s),this.doneRenderCursorInfoMap.delete(s),this.internalMsgEmitter.emit([q.Cursor,s],[]))}stopAnimation(){this.animationDrawWorkers.clear(),this.willConsumeEventWorkers.clear(),this.cursorInfoMap.clear()}destroy(){var o;(o=this.displayer)==null||o.removeMagixEventListener(this.eventName),this.stopAnimation()}}class Ot{constructor(){M(this,"useEmtMsg");M(this,"emtType");M(this,"control");M(this,"mainEngine")}static dispatch(o,t,e){var i;(i=Nt.InternalMsgEmitter)==null||i.emit([o,t],e)}get serviceColloctor(){return this.control.collector}registerForMainEngine(o,t){return this.emtType=o,this.control=t,this.mainEngine=t.worker,this.mainEngine.internalMsgEmitter.on([this.emtType,this.emitEventType],this.collect.bind(this)),this}destroy(){this.emtType&&this.mainEngine&&this.mainEngine.internalMsgEmitter.off([this.emtType,this.emitEventType],this.collect.bind(this))}collectForLocalWorker(o,t){var e,i,s;for(const[n,r]of o)(e=this.mainEngine)==null||e.queryTaskBatchData(r).forEach(c=>{var l;(l=this.mainEngine)==null||l.taskBatchData.delete(c)}),(i=this.mainEngine)==null||i.taskBatchData.add(n);if(t){this.mainEngine.consume();return}(s=this.mainEngine)==null||s.runAnimation()}collectForServiceWorker(o){Bt(()=>{o.forEach(t=>{var e;(e=this.serviceColloctor)==null||e.dispatch(t)})},this.mainEngine.maxLastSyncTime)}pause(){var o;if(this.lastEmtData){this.useEmtMsg=!0;const t={...this.lastEmtData,workState:D.Done};this.collect(t,!0),(o=Nt.InternalMsgEmitter)==null||o.emit(R.ActiveMethod,!1)}}recover(){var o;this.useEmtMsg&&Nt.InternalMsgEmitter.hasListeners(R.ActiveMethod)&&((o=Nt.InternalMsgEmitter)==null||o.emit(R.ActiveMethod,!0))}}class Hf extends Ot{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.CopyNode)}collect(t){var c;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:e,viewId:i}=t,s=this.control.viewContainerManager.getView(i);if(!(s!=null&&s.displayer))return;const n=s.focusScenePath,r=Date.now();this.mainEngine.internalMsgEmitter.emit("addUndoTicker",r,i);for(const l of e){const h=l.toString(),d=this.serviceColloctor.isLocalId(h)?this.serviceColloctor.transformKey(l):h,p=(c=this.serviceColloctor.getStorageData(i,n))==null?void 0:c[d];if(p){if(l===$){const f=p&&this.copySelector({viewId:i,store:p});f&&this.pasteSelector({...f,viewId:i,scenePath:n,undoTickerId:r});break}if(p.toolsType===C.Text&&p.opt&&p.opt.workState&&p.opt.workState!==D.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(t){const{viewId:e,store:i}=t,s=this.control.viewContainerManager.getView(e);if(!this.serviceColloctor||!s)return;const n=s==null?void 0:s.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(t){var m,S;const{bgCenter:e,textCenter:i,store:s,key:n,viewId:r,scenePath:c,undoTickerId:l}=t,h=this.control.viewContainerManager.getView(r);if(!this.serviceColloctor||!h)return;const u=Math.floor(Math.random()*30+1),d=((m=h.cameraOpt)==null?void 0:m.scale)||1,p=e&&i&&[e[0]-i[0]+u,e[1]-i[1]+u]||[u/d,u/d],y=(this.serviceColloctor.isLocalId(n)?n:this.serviceColloctor.getLocalId(n.toString()))+"-"+l;if(s.toolsType===C.Text&&s.opt){const w=s.opt;if(w&&w.boxPoint&&w.text){w.workState=D.Done;const v=w.boxPoint;w.boxPoint=[v[0]+p[0],v[1]+p[1]],w.workState=D.Done;const T=this.control.viewContainerManager.transformToOriginPoint(w.boxPoint,r);this.control.textEditorManager.createTextForMasterController({workId:y,x:T[0],y:T[1],opt:w,scale:((S=h.cameraOpt)==null?void 0:S.scale)||1,type:Gt.Text,isActive:!1,viewId:r,scenePath:c}),this.collectForServiceWorker([{...s,opt:w,type:b.FullWork,workId:y,viewId:r,scenePath:c}])}}}copySelector(t){var y,m,S,w,v,T,N,I,x;const{viewId:e,store:i}=t,s=this.control.viewContainerManager.getView(e),n=i.selectIds;if(!this.serviceColloctor||!(n!=null&&n.length)||!s)return;const r=new Map,c={offset:{x:0,y:0},cameraOpt:{centerX:((y=s.cameraOpt)==null?void 0:y.centerX)||0,centerY:((m=s.cameraOpt)==null?void 0:m.centerY)||0,scale:((S=s.cameraOpt)==null?void 0:S.scale)||1}},l=this.control.hasOffscreenCanvas()&&((w=s.displayer.canvasBgRef.current)==null?void 0:w.getBoundingClientRect())||((v=s.displayer.canvasContainerRef.current)==null?void 0:v.getBoundingClientRect()),h=(N=(T=s.displayer)==null?void 0:T.floatBarRef.current)==null?void 0:N.getBoundingClientRect(),u=l&&[l.x+l.width/2,l.y+l.height/2],d=h&&[h.x+h.width/2,h.y+h.height/2],p=u&&s.viewData&&s.viewData.convertToPointInWorld({x:u[0],y:u[1]}),f=d&&s.viewData&&s.viewData.convertToPointInWorld({x:d[0],y:d[1]});p&&f&&(c.offset={x:p.x-f.x,y:p.y-f.y});for(const z of n){const A=(x=(I=this.serviceColloctor)==null?void 0:I.getStorageData(s.id,s.focusScenePath))==null?void 0:x[z];A&&r.set(z,A)}return{copyStores:r,copyCoordInfo:c}}pasteSelector(t){var m;const{copyStores:e,copyCoordInfo:i,viewId:s,scenePath:n,undoTickerId:r}=t,c=this.control.viewContainerManager.getView(s);if(!e.size||!this.serviceColloctor||!c)return;const{offset:l,cameraOpt:h}=i,{scale:u}=h,d=Math.floor(Math.random()*30+1),p=l&&[l.x+d,l.y+d]||[d/u,d/u],f=[],y=[];for(const[S,w]of e.entries()){const T=(this.serviceColloctor.isLocalId(S)?S:this.serviceColloctor.getLocalId(S.toString()))+"-"+r,N={useAnimation:!1};if(w.toolsType===C.Text&&w.opt){const I=w.opt;if(I&&I.boxPoint&&I.text){I.workState=D.Done;const x=I.boxPoint;I.boxPoint=[x[0]+p[0],x[1]+p[1]],I.workState=D.Done;const z=this.control.viewContainerManager.transformToOriginPoint(I.boxPoint,s);this.control.textEditorManager.createTextForMasterController({workId:T,x:z[0],y:z[1],opt:I,scale:((m=c.cameraOpt)==null?void 0:m.scale)||1,type:Gt.Text,isActive:!1,viewId:s,scenePath:n})}y.push({...w,opt:I,type:b.FullWork,workId:T,viewId:s,scenePath:n});continue}if(w.toolsType===C.Image&&(w.opt.uuid=T,w.opt.centerX=w.opt.centerX+p[0],w.opt.centerY=w.opt.centerY+p[1]),w.ops){const I=xe(w.ops).map((z,A)=>{const E=A%3;return E===0?z+p[0]:E===1?z+p[1]:z}),x=Dt(I);w.ops=x}y.push({...w,updateNodeOpt:N,type:b.FullWork,workId:T,viewId:s,scenePath:n}),f.push([{...w,updateNodeOpt:N,workId:T,msgType:b.FullWork,dataType:H.Local,emitEventType:R.CopyNode,willSyncService:!1,willRefresh:!0,viewId:s},{workId:T,msgType:b.FullWork,emitEventType:R.CopyNode}])}f.length&&this.collectForLocalWorker(f),y.length&&this.collectForServiceWorker(y)}}function Oe(a,o,t){return"#"+((a<<16)+(o<<8)+t).toString(16).padStart(6,"0")}function Mt(a,o=1){return"rgba("+parseInt("0x"+a.slice(1,3))+","+parseInt("0x"+a.slice(3,5))+","+parseInt("0x"+a.slice(5,7))+","+o+")"}function We(a,o,t,e=1){return`rgba(${a},${o},${t},${e})`}function uo(a){const o=a.split(","),t=parseInt(o[0].split("(")[1]),e=parseInt(o[1]),i=parseInt(o[2]),s=Number(o[3].split(")")[0]);return[Oe(t,e,i),s]}function Ue(a){const o=a.split(","),t=parseInt(o[0].split("(")[1]),e=parseInt(o[1]),i=parseInt(o[2]),s=Number(o[3].split(")")[0]);return[t,e,i,s]}function Be(a){return a==="transparent"}class $f extends Ot{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.SetColorNode);M(this,"undoTickerId")}setTextColor(t,e,i,s){const{fontColor:n,fontBgColor:r}=i;e.opt&&(n&&(e.opt.fontColor=n),r&&(e.opt.fontBgColor=r),this.control.textEditorManager.updateTextForMasterController({workId:t,opt:e.opt,viewId:s,canSync:!0,canWorker:!0}))}collect(t){if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:e,strokeColor:i,fillColor:s,fontColor:n,fontBgColor:r,viewId:c,workState:l,thickness:h,strokeType:u}=t,d=this.control.viewContainerManager.getView(c);if(!(d!=null&&d.displayer))return;const p=d.focusScenePath,f=[...e],y=this.serviceColloctor.storage,m=[],S={};for((l===D.Start||!this.undoTickerId&&l===D.Done)&&(this.undoTickerId=Date.now(),this.mainEngine.internalMsgEmitter.emit("addUndoTicker",this.undoTickerId,c));f.length;){const w=f.pop();if(!w)continue;const v=w.toString(),T=this.serviceColloctor.isLocalId(v),N=T?this.serviceColloctor.transformKey(w):v;let I=v;!T&&this.serviceColloctor.isOwn(I)&&(I=this.serviceColloctor.getLocalId(I));const x=y[c][p][N]||void 0;if(x){const z=x.updateNodeOpt||{};if(n||r){if(n){z.fontColor=n;const[E,j,O,P]=Ue(n);S.textColor=[E,j,O],S.textOpacity=P}if(r)if(z.fontBgColor=Be(r)?"transparent":r,Be(r))S.textBgColor=void 0,S.textBgOpacity=void 0;else{const[E,j,O,P]=Ue(r);S.textBgColor=[E,j,O],S.textBgOpacity=P}if(x.toolsType===C.Text&&x.opt&&l!==D.Start){this.setTextColor(I,Jt(x),z,c),l===D.Done&&(this.undoTickerId=void 0);continue}}if(i){z.strokeColor=i;const[E,j,O,P]=Ue(i);S.strokeColor=[E,j,O],S.strokeOpacity=P}if(s)if(z.fillColor=Be(s)?"transparent":s,Be(s))S.fillColor=void 0,S.fillOpacity=void 0;else{const[E,j,O,P]=Ue(s);S.fillColor=[E,j,O],S.fillOpacity=P}h&&(z.thickness=h,S.strokeWidth=h),u&&(z.strokeType=u,S.strokeType=u);const A={workId:I,msgType:b.UpdateNode,dataType:H.Local,updateNodeOpt:z,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,textUpdateForWoker:!0,viewId:c};m.push([A,{workId:I,msgType:b.UpdateNode,emitEventType:this.emitEventType}])}}m.length&&(l===D.Done&&(this.undoTickerId=void 0),this.collectForLocalWorker(m)),Object.keys(S).length&&setTimeout(()=>{var w;(w=this.control.room)==null||w.setMemberState(S)},0)}}class Qf extends Ot{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.ZIndexNode);M(this,"zIndexMap",new Map)}clearZIndex(t){this.zIndexMap.delete(t)}getMinZIndex(t){var e;return((e=this.zIndexMap.get(t))==null?void 0:e.min)||0}getMaxZIndex(t){var e;return((e=this.zIndexMap.get(t))==null?void 0:e.max)||0}setMaxZIndex(t,e){const i=this.getMinZIndex(e);this.zIndexMap.set(e,{min:i,max:t})}setMinZIndex(t,e){const i=this.getMaxZIndex(e);this.zIndexMap.set(e,{min:t,max:i})}addMaxLayer(t){const e=this.getMaxZIndex(t)+1;this.setMaxZIndex(e,t)}addMinLayer(t){const e=this.getMinZIndex(t)-1;this.setMinZIndex(e,t)}correct(t){const e=t.sort((i,s)=>i[1]-s[1]);for(let i=1;i<e.length;i++){const s=e[i][1],n=e[i-1][1];s<=n&&(e[i][1]=n+1)}return e}collect(t){if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:e,layer:i,viewId:s}=t,n=this.control.viewContainerManager.getView(s);if(!(n!=null&&n.displayer))return;const r=n.focusScenePath,c=[...e],l=this.serviceColloctor.storage,h=[],u=[];for(;c.length;){const p=c.pop();if(!p)continue;const f=p.toString(),y=this.serviceColloctor.isLocalId(f),m=y?this.serviceColloctor.transformKey(p):f;let S=f;!y&&this.serviceColloctor.isOwn(S)&&(S=this.serviceColloctor.getLocalId(S));const w=Jt(l[s][r][m]);let v;if(w&&S===$){if(w.selectIds){u.push(...w.selectIds),u.sort((x,z)=>{var j,O,P,Y;const A=((O=(j=l[d(x,this.serviceColloctor)])==null?void 0:j.opt)==null?void 0:O.zIndex)||0,E=((Y=(P=l[d(x,this.serviceColloctor)])==null?void 0:P.opt)==null?void 0:Y.zIndex)||0;return A>E?1:x<z?-1:0});const T=w.updateNodeOpt||{};T.zIndexLayer=i;const N={workId:p,msgType:b.UpdateNode,dataType:H.Local,updateNodeOpt:T,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:s},I=new Map;i===ae.Top?(this.addMaxLayer(s),v=this.getMaxZIndex(s)):(this.addMinLayer(s),v=this.getMinZIndex(s)),u.forEach(x=>{var j,O,P;const z=(j=this.serviceColloctor)==null?void 0:j.isLocalId(x);let A=z&&((O=this.serviceColloctor)==null?void 0:O.transformKey(x))||x;const E=l[s][r][A];!z&&((P=this.serviceColloctor)!=null&&P.isOwn(A))&&(A=this.serviceColloctor.getLocalId(A)),T.zIndex=v,E!=null&&E.opt&&(E.opt.zIndex=v),E!=null&&E.opt&&I.set(A,{updateNodeOpt:E.updateNodeOpt,opt:E.opt})}),N.selectStore=I,N.willSerializeData=!0,h.push([N,{workId:p,msgType:b.UpdateNode,emitEventType:this.emitEventType}])}continue}}h.length&&this.collectForLocalWorker(h);function d(p,f){return f.isLocalId(p)&&f.transformKey(p)||p}}}class Gf extends Ot{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.TranslateNode);M(this,"cachePosition")}collect(t,e){var f;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:i,position:s,workState:n,viewId:r}=t;this.lastEmtData=t;const c=this.control.viewContainerManager.getView(r);if(!(c!=null&&c.displayer))return;const l=c.focusScenePath,h=[...i],u=(f=this.serviceColloctor)==null?void 0:f.storage,d=[],p=n===D.Start&&Date.now()||void 0;for(p&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",p,r);h.length;){const y=h.pop();if(!y)continue;const m=y.toString(),S=this.serviceColloctor.isLocalId(m),w=S&&this.serviceColloctor.transformKey(y)||m;let v=m;!S&&this.serviceColloctor.isOwn(v)&&(v=this.serviceColloctor.getLocalId(v));const T=u[r][l][w];if(T&&v===$){if(T.selectIds){const N=this.control.viewContainerManager.transformToScenePoint([s.x,s.y],r);if(n===D.Start&&(this.cachePosition=N),this.cachePosition){const I=T.updateNodeOpt||{};I.translate=[N[0]-this.cachePosition[0],N[1]-this.cachePosition[1]],I.workState=n;const x={workId:y,msgType:b.UpdateNode,dataType:H.Local,updateNodeOpt:I,emitEventType:this.emitEventType,willSyncService:!0,textUpdateForWoker:!0,viewId:r};n===D.Done&&(x.textUpdateForWoker=!0,x.willSerializeData=!0,this.cachePosition=void 0),d.push([x,{workId:y,msgType:b.UpdateNode,emitEventType:this.emitEventType}])}}continue}}n===D.Start?this.mainEngine.unWritable():n===D.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),d.length&&this.collectForLocalWorker(d,e)}}class Zf extends Ot{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.DeleteNode)}collect(t){if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:e,viewId:i}=t,s=this.control.viewContainerManager.getView(i);if(!(s!=null&&s.displayer))return;const n=s.focusScenePath,r=this.serviceColloctor.storage,c=[...e],l=[],h=[],u=Date.now();for(;c.length;){const d=c.pop();if(!d)continue;const p=d.toString(),f=this.serviceColloctor.isLocalId(p),y=f?this.serviceColloctor.transformKey(d):p,m=r[i][n][y];if(m){let S=p;if(!f&&this.serviceColloctor.isOwn(S)&&(S=this.serviceColloctor.getLocalId(S)),m.toolsType===C.Text){this.control.textEditorManager.delete(S,!0,!0);continue}h.push(S)}}h.length&&(l.push([{msgType:b.RemoveNode,emitEventType:R.DeleteNode,removeIds:h,dataType:H.Local,willSyncService:!0,willRefresh:!0,viewId:i},void 0]),this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,i),this.collectForLocalWorker(l))}}class qf extends Ot{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.ScaleNode);M(this,"targetText",new Map);M(this,"cacheTextInfo",new Map)}async setTextStyle(t,e,i){const s=await this.control.textEditorManager.updateTextControllerWithEffectAsync({workId:t,opt:e,viewId:i,canSync:!1,canWorker:!1});return{key:t,textInfo:s}}async collect(t,e){var w,v,T,N,I;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:i,workState:s,viewId:n,originPoint:r,scenePoint:c,dir:l,scale:h,translate:u}=t;this.lastEmtData=t;const d=this.control.viewContainerManager.getView(n);if(!(d!=null&&d.displayer))return;const p=d.focusScenePath,f=[...i],y=(w=this.serviceColloctor)==null?void 0:w.storage,m=[],S=s===D.Start&&Date.now()||void 0;for(S&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",S,n);f.length;){const x=f.pop();if(!x)continue;const z=x.toString(),A=this.serviceColloctor.isLocalId(z),E=A&&this.serviceColloctor.transformKey(x)||z;let j=z;!A&&this.serviceColloctor.isOwn(j)&&(j=this.serviceColloctor.getLocalId(j));const O=y[n][p][E];if(O&&j===$&&O.selectIds){const P=O.updateNodeOpt||{};if(P.dir=l,P.originPoint=r,P.scenePoint=c,P.workState=s,P.scale=h,P.translate=u,s===D.Start){this.cacheTextInfo.clear();for(const ot of O.selectIds){const tt=(v=this.serviceColloctor)==null?void 0:v.isLocalId(ot),Q=tt&&((T=this.serviceColloctor)==null?void 0:T.transformKey(ot))||ot;let J=Q;!tt&&((N=this.serviceColloctor)!=null&&N.isOwn(Q))&&(J=this.serviceColloctor.getLocalId(Q));const G=this.control.textEditorManager.get(J);G&&s===D.Start&&this.targetText.set(J,Jt(G))}}if(this.targetText.size&&s!==D.Start&&h){const ot=[];for(const[Q,J]of this.targetText.entries()){const{opt:G}=J,Z=Math.floor(G.fontSize*h[0]),X=this.cacheTextInfo.get(Q),rt=!X&&G.fontSize!==Z||X&&X.fontSize!==Z||!1,wt=(I=this.control.textEditorManager.get(Q))==null?void 0:I.opt;if(rt&&wt&&G.boxSize&&G.boxPoint){const it=this.setTextStyle(Q,{...wt,fontSize:Z},n);ot.push(it)}}const tt=await Promise.all(ot);for(const Q of tt)if(Q){const{key:J,textInfo:G}=Q;this.cacheTextInfo.set(J,{fontSize:G.opt.fontSize,boxSize:G.opt.boxSize,boxPoint:G.opt.boxPoint})}P.textInfos=this.cacheTextInfo}const Y={workId:x,msgType:b.UpdateNode,dataType:H.Local,updateNodeOpt:P,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:n};s===D.Done&&(Y.willSerializeData=!0,this.targetText.clear()),m.push([Y,{workId:x,msgType:b.UpdateNode,emitEventType:this.emitEventType}]);continue}}s===D.Start?this.mainEngine.unWritable():s===D.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),m.length&&this.collectForLocalWorker(m,e)}}class Jf extends Ot{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.RotateNode);M(this,"cacheOriginRotate",0)}collect(t,e){var f,y,m,S,w;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:i,angle:s,workState:n,viewId:r}=t;this.lastEmtData=t;const c=this.control.viewContainerManager.getView(r);if(!(c!=null&&c.displayer))return;const l=c.focusScenePath,h=[...i],u=(f=this.serviceColloctor)==null?void 0:f.storage,d=[],p=n===D.Start&&Date.now()||void 0;for(p&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",p,r);h.length;){const v=h.pop();if(!v)continue;const T=v.toString(),N=this.serviceColloctor.isLocalId(T),I=N&&this.serviceColloctor.transformKey(v)||T;let x=T;!N&&this.serviceColloctor.isOwn(x)&&(x=this.serviceColloctor.getLocalId(x));const z=u[r][l][I];if(z&&x===$){if(((y=z.selectIds)==null?void 0:y.length)===1){const A=z.selectIds[0];if(n===D.Start){const P=((m=this.serviceColloctor)==null?void 0:m.isLocalId(A))&&((S=this.serviceColloctor)==null?void 0:S.transformKey(A))||A,Y=u[r][l][P];this.cacheOriginRotate=((w=Y==null?void 0:Y.opt)==null?void 0:w.rotate)||0}const E=z.updateNodeOpt||{};E.angle=(s+this.cacheOriginRotate)%360,E.workState=n;const j={workId:v,msgType:b.UpdateNode,dataType:H.Local,updateNodeOpt:E,emitEventType:this.emitEventType,willRefreshSelector:!1,willSyncService:!0,viewId:r};n===D.Done&&(j.willRefreshSelector=!0,j.willSerializeData=!0,this.cacheOriginRotate=0),d.push([j,{workId:v,msgType:b.UpdateNode,emitEventType:this.emitEventType}])}continue}}n===D.Start?this.mainEngine.unWritable():n===D.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),d.length&&this.collectForLocalWorker(d,e)}}function Xf(a){switch(a){case C.Text:return Gt.Text;case C.SpeechBalloon:case C.Star:case C.Ellipse:case C.Rectangle:case C.Triangle:case C.Rhombus:case C.Polygon:return Gt.Shape}}class Kf extends Ot{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.SetFontStyle);M(this,"timerId")}async setTextStyle(t,e,i,s){const{bold:n,underline:r,lineThrough:c,italic:l,fontSize:h}=i;if(e.toolsType&&Xf(e.toolsType)===Gt.Text){e.opt&&(n&&(e.opt.bold=n),L.isBoolean(r)&&(e.opt.underline=r),L.isBoolean(c)&&(e.opt.lineThrough=c),l&&(e.opt.italic=l),h&&(e.opt.fontSize=h));const d=await this.control.textEditorManager.updateTextControllerWithEffectAsync({workId:t,opt:e.opt,viewId:s,canSync:!1,canWorker:!1});return{key:t,textInfo:d}}}async collect(t){var w,v,T,N;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:e,bold:i,italic:s,lineThrough:n,underline:r,viewId:c,fontSize:l}=t,h=this.control.viewContainerManager.getView(c);if(!(h!=null&&h.displayer))return;const u=h.focusScenePath,d=[...e],p=this.serviceColloctor.storage,f={},y=Date.now();this.mainEngine.internalMsgEmitter.emit("addUndoTicker",y,c);const m=[];for(;d.length;){const I=d.pop();if(!I)continue;const x=I.toString(),z=this.serviceColloctor.isLocalId(x),A=z?this.serviceColloctor.transformKey(I):x;let E=x;!z&&this.serviceColloctor.isOwn(E)&&(E=this.serviceColloctor.getLocalId(E));const j=p[c][u][A]||void 0;if(j){const O=j.updateNodeOpt||{};if(i&&(O.bold=i,f.bold=i==="bold"),s&&(O.italic=s,f.italic=s==="italic"),L.isBoolean(n)&&(O.lineThrough=n,f.lineThrough=n),L.isBoolean(r)&&(O.underline=r,f.underline=r),l&&(O.fontSize=l,f.textSize=l),j.toolsType===C.Text&&j.opt){const P=this.setTextStyle(E,L.cloneDeep(j),O,c);m.push(P);continue}if(j&&E===$&&((w=j.selectIds)!=null&&w.length))for(const P of j.selectIds){const Y=(v=this.serviceColloctor)==null?void 0:v.isLocalId(P);let ot=Y&&((T=this.serviceColloctor)==null?void 0:T.transformKey(P))||P;const tt=p[c][u][ot]||void 0;if(!Y&&((N=this.serviceColloctor)!=null&&N.isOwn(ot))&&(ot=this.serviceColloctor.getLocalId(ot)),tt&&tt.toolsType===C.Text&&j.opt){const Q=this.setTextStyle(ot,L.cloneDeep(tt),O,c);m.push(Q);continue}}}}const S=await Promise.all(m);for(const I of S)if(I){const{key:x,textInfo:z}=I;z&&(z.canSync=!0,z.canWorker=!0,this.control.textEditorManager.updateForViewEdited(x,z))}Object.keys(f).length&&(this.timerId&&(clearTimeout(this.timerId),this.timerId=void 0),this.timerId=setTimeout(()=>{var I;this.timerId=void 0,(I=this.control.room)==null||I.setMemberState(f)},0))}}class _f extends Ot{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.SetPoint);M(this,"undoTickerId")}collect(t){var w;if(!this.serviceColloctor||!this.mainEngine)return;const{workId:e,pointMap:i,workState:s,viewId:n}=t,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,h=[],u=s===D.Start&&Date.now()||void 0;u&&(this.undoTickerId=u,this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,n));const d=e;if(!d)return;const p=d.toString(),f=this.serviceColloctor.isLocalId(p),y=f&&this.serviceColloctor.transformKey(d)||p;let m=p;!f&&this.serviceColloctor.isOwn(m)&&(m=this.serviceColloctor.getLocalId(m));const S=l[n][c][y];if(S&&m===$&&S.selectIds){const v=S.updateNodeOpt||{};v.pointMap=i,v.workState=s;const T={workId:d,msgType:b.UpdateNode,dataType:H.Local,updateNodeOpt:v,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:n};s===D.Done&&(T.undoTickerId=this.undoTickerId),h.push([T,{workId:d,msgType:b.UpdateNode,emitEventType:this.emitEventType}])}s===D.Start?this.mainEngine.unWritable():s===D.Done&&this.mainEngine.abled(),h.length&&this.collectForLocalWorker(h)}}class tg extends Ot{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.SetLock)}collect(t){if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:e,isLocked:i,viewId:s}=t,n=this.control.viewContainerManager.getView(s);if(!(n!=null&&n.displayer))return;const r=n.focusScenePath,c=[...e],l=this.serviceColloctor.storage,h=[],u=Date.now();for(;c.length;){const d=c.pop();if(!d)continue;const p=d.toString(),f=this.serviceColloctor.isLocalId(p),y=f?this.serviceColloctor.transformKey(d):p;let m=p;!f&&this.serviceColloctor.isOwn(m)&&(m=this.serviceColloctor.getLocalId(m));const S=l[s][r][y]||void 0;if(S){const w=S.updateNodeOpt||{};w.isLocked=i;const v={workId:m,msgType:b.UpdateNode,dataType:H.Local,updateNodeOpt:w,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,viewId:s};h.push([v,{workId:m,msgType:b.UpdateNode,emitEventType:this.emitEventType}])}}this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,s),h.length&&this.collectForLocalWorker(h)}}class eg extends Ot{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.SetShapeOpt)}collect(t){if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:e,viewId:i,...s}=t,n=this.control.viewContainerManager.getView(i);if(!(n!=null&&n.displayer))return;const r=n.focusScenePath,c=[...e],l=this.serviceColloctor.storage,h=[],u=Date.now();for(;c.length;){const d=c.pop();if(!d)continue;const p=d.toString(),f=this.serviceColloctor.isLocalId(p),y=f?this.serviceColloctor.transformKey(d):p;let m=p;!f&&this.serviceColloctor.isOwn(m)&&(m=this.serviceColloctor.getLocalId(m));const S=l[i][r][y]||void 0;if(S){const w={...S.updateNodeOpt,...s,willRefresh:!0};if(S&&m===$){const v={workId:m,msgType:b.UpdateNode,dataType:H.Local,updateNodeOpt:w,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,viewId:i};h.push([v,{workId:m,msgType:b.UpdateNode,emitEventType:this.emitEventType}])}}}h.length&&(this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,i),this.collectForLocalWorker(h))}}class K{constructor(o){M(this,"builders",new Map);this.builders=new Map(o.map(t=>[t,this.build(t)]))}build(o){switch(o){case R.TranslateNode:return new Gf;case R.ZIndexNode:return new Qf;case R.CopyNode:return new Hf;case R.SetColorNode:return new $f;case R.DeleteNode:return new Zf;case R.ScaleNode:return new qf;case R.RotateNode:return new Jf;case R.SetFontStyle:return new Kf;case R.SetPoint:return new _f;case R.SetLock:return new tg;case R.SetShapeOpt:return new eg}}getBuilder(o){return this.builders.get(o)}registerForMainEngine(o,t){return this.builders.forEach(e=>{e&&e.registerForMainEngine(o,t)}),this}destroy(){this.builders.forEach(o=>{o&&o.destroy()}),this.builders.clear()}pause(){return this.builders.forEach(o=>{o&&o.pause()}),this}recover(){return this.builders.forEach(o=>{o&&o.recover()}),this}static emitMethod(o,t,e){Ot.dispatch(o,t,e)}static activeListener(o){Nt.InternalMsgEmitter.on(R.ActiveMethod,o)}static unmountActiveListener(o){Nt.InternalMsgEmitter.off(R.ActiveMethod,o)}}class og{constructor(o){M(this,"master");M(this,"mainThreadWorkerMap",new Map);this.master=o}updateCamera(){for(const[o,t]of this.mainThreadWorkerMap.entries()){const e=this.master.control.viewContainerManager.getView(o);if(e){const{cameraOpt:i}=e;t.updateCamera({cameraOpt:i,viewId:e.viewId,msgType:b.UpdateCamera,dataType:H.Local})}}}notifyDrawCount(o){const t=this.master.getWorkDrawCount(),e=this.mainThreadWorkerMap.get(o);e&&e.clearDrawLayer(t)}clearDrawCount(o){const t=this.mainThreadWorkerMap.get(o);t&&t.clearDrawLayer(1/0)}createMainThreadWorker(o,t){return new ig(o,t,this)}consume(o){var t;for(const e of o.values()){const{msgType:i,viewId:s,layerOpt:n,offscreenCanvasOpt:r,cameraOpt:c}=e;if(i===b.Console){console.log(this);continue}if(i===b.Init){const h=(t=this.master.control.viewContainerManager.getView(s))==null?void 0:t.displayer,u=h==null?void 0:h.subLocalCanvasContainerRef.current;if(h&&u&&n&&r){const d=this.createMainThreadWorker(s,{displayer:h,container:u,layerOpt:n,master:this.master,canvasOpt:r,post:this.post.bind(this)});this.mainThreadWorkerMap.set(s,d),d&&c&&d.setCameraOpt(c)}continue}if(i===b.TasksQueue)continue;const l=this.mainThreadWorkerMap.get(s);l&&(l.on(e),i===b.Destroy&&(l.destroy(),this.mainThreadWorkerMap.delete(s)))}}post(o){const{sp:t}=o;t&&this.master.collectorSyncData(t)}destroy(){for(const o of this.mainThreadWorkerMap.values())o.destroy();this.mainThreadWorkerMap.clear()}active(){}}class ig{constructor(o,t,e){M(this,"viewId");M(this,"opt");M(this,"manager");M(this,"subLocalLayer");M(this,"subLocalWork");M(this,"scene");M(this,"cameraOpt");this.viewId=o,this.opt=t,this.manager=e,this.scene=this.createScene({...t.canvasOpt,container:t.container});const i=Lt.bufferSize.full,s=Lt.bufferSize.sub;this.subLocalLayer=this.createLayer("subLocalLayer",this.scene,{...t.layerOpt,bufferSize:this.viewId===It?i:s});const n={thread:this};this.subLocalWork=new sg(n)}createScene(o){return new lt.Scene({displayRatio:this.opt.displayer.dpr,depth:!1,desynchronized:!0,...o,contextType:"2d",autoRender:!0,id:this.viewId})}createLayer(o,t,e){const{width:i,height:s}=e,n=`canvas-${o}`,r=t.layer(n,{...e,offscreen:!1}),c=new lt.Group({anchor:[.5,.5],pos:[i*.5,s*.5],size:[i,s],name:"viewport",id:o});return r.append(c),c}updateScene(o){this.scene.attr({...o});const{width:t,height:e}=o;this.scene.width=t,this.scene.height=e,this.updateLayer({width:t,height:e})}updateLayer(o){const{width:t,height:e}=o;this.subLocalLayer.parent.setAttribute("width",t),this.subLocalLayer.parent.setAttribute("height",e),this.subLocalLayer.setAttribute("size",[t,e]),this.subLocalLayer.setAttribute("pos",[t*.5,e*.5])}on(o){const{msgType:t,toolsType:e,opt:i,dataType:s,workId:n,workState:r}=o,c=n==null?void 0:n.toString();switch(t){case b.Destroy:this.destroy();break;case b.Clear:this.clearAll();break;case b.UpdateCamera:this.updateCamera(o);break;case b.UpdateTools:if(e&&this.subLocalWork.canUseSubWorkerLayer(e)&&i){const l={toolsType:e,toolsOpt:i};this.subLocalWork.setToolsOpt(l)}break;case b.CreateWork:c&&i&&e&&this.subLocalWork.canUseSubWorkerLayer(e)&&(this.subLocalWork.getToolsOpt()||this.subLocalWork.setToolsOpt({toolsType:e,toolsOpt:i}),this.subLocalWork.setWorkOptions(c,i));break;case b.DrawWork:e&&this.subLocalWork.canUseSubWorkerLayer(e)&&(r===D.Done&&s===H.Local?this.subLocalWork.consumeDrawAll(o):this.subLocalWork.consumeDraw(o));break;case b.RemoveNode:this.subLocalWork.removeNode(o);return}}setCameraOpt(o){this.cameraOpt=o;const{scale:t,centerX:e,centerY:i,width:s,height:n}=o;(s!==this.scene.width||n!==this.scene.height)&&this.updateScene({width:s,height:n}),this.subLocalLayer&&(this.subLocalLayer.setAttribute("scale",[t,t]),this.subLocalLayer.setAttribute("translate",[-e,-i]))}updateCamera(o){const{cameraOpt:t}=o;t&&!L.isEqual(this.cameraOpt,t)&&(this.subLocalWork.workShapes.size&&this.clearAll(),this.setCameraOpt(t))}clearAll(){this.subLocalLayer.children.length&&(this.subLocalLayer.parent.children.forEach(o=>{o.name!=="viewport"&&o.remove()}),this.subLocalLayer.removeAllChildren()),this.subLocalWork.clearAll()}destroy(){this.subLocalLayer.remove(),this.scene.remove(),this.subLocalWork.destroy()}clearDrawLayer(o){if(o===1/0){this.clearAll();return}const t=this.subLocalLayer.children.filter(e=>e.id&&L.isNumber(parseInt(e.id))&&parseInt(e.id)<o);for(const e of t)e.disconnect(),this.subLocalLayer.removeChild(e)}}class sg{constructor(o){M(this,"thread");M(this,"workShapes",new Map);M(this,"tmpOpt");M(this,"syncUnitTime",Lt.syncOpt.interval);M(this,"drawCount",0);this.thread=o.thread}getToolsOpt(){return this.tmpOpt}consumeDrawAll(o){const{workId:t}=o,e=t==null?void 0:t.toString();e&&this.workShapes.get(e)&&(this.drawCount=0,this.thread.subLocalLayer.removeAllChildren(),this.clearWorkShapeNodeCache(e))}consumeDraw(o){const{workId:t,toolsType:e}=o;t&&e&&this.canUseSubWorkerLayer(e)&&(this.getWorkShape(t.toString())||this.createLocalWork(o));const i=t==null?void 0:t.toString(),s=i&&this.workShapes.get(i);if(!s)return;s.consume({data:o,drawCount:this.drawCount,isFullWork:!1,isSubWorker:!0}),this.drawCount++;const n=this.thread.manager.master;n.setSubWorkerDrawCount(this.drawCount);const r=Math.max(n.getMaxDrawCount(),this.drawCount);n.setMaxDrawCount(r)}removeNode(o){const{workId:t}=o,e=t==null?void 0:t.toString();e&&this.workShapes.has(e)&&(this.thread.subLocalLayer.getElementsByName(e).forEach(s=>{s.remove()}),this.clearWorkShapeNodeCache(e))}createLocalWork(o){const{workId:t,toolsType:e,opt:i}=o,s=t==null?void 0:t.toString();e&&this.canUseSubWorkerLayer(e)&&s&&i&&(this.getToolsOpt()||this.setToolsOpt({toolsType:e,toolsOpt:i}),this.setWorkOptions(s,i))}setWorkOptions(o,t){let e=this.workShapes.get(o);if(!e&&this.tmpOpt){const{toolsType:i}=this.tmpOpt;this.tmpOpt.toolsOpt=t,e=this.createWorkShapeNode({workId:o,toolsType:i,toolsOpt:t}),e&&this.workShapes.set(o,e),this.setToolsOpt(this.tmpOpt)}t!=null&&t.syncUnitTime||(t.syncUnitTime=this.syncUnitTime),e&&e.setWorkOptions(t)}destroy(){this.clearAll()}clearAll(){this.thread.subLocalLayer.removeAllChildren(),this.workShapes.clear()}canUseSubWorkerLayer(o){return o===C.Pencil}setToolsOpt(o){var t;this.tmpOpt=o,(t=o.toolsOpt)!=null&&t.syncUnitTime&&(this.syncUnitTime=o.toolsOpt.syncUnitTime)}createWorkShapeNode(o){return Ts({...o,fullLayer:this.thread.subLocalLayer,drawLayer:this.thread.subLocalLayer})}clearWorkShapeNodeCache(o){this.workShapes.delete(o)}getWorkShape(o){return this.workShapes.get(o)}}const ng=async(a,o)=>{const{src:t,isgl:e,isCache:i}=a;if(typeof Image=="function"){const s=new Image;return typeof t=="string"&&(s.crossOrigin="anonymous"),new Promise(n=>{s.onload=function(){createImageBitmap(s,{imageOrientation:e?"flipY":"none"}).then(r=>{n(r)})},s.onerror=function(){n(void 0)},s.src=t})}else return fetch(t,{method:"GET",mode:"cors",cache:"default"}).then(s=>s.blob()).then(s=>createImageBitmap(s,{imageOrientation:e?"flipY":"none"}).then(n=>n))};class rg{constructor(){M(this,"maxLastSyncTime",Lt.syncOpt.interval)}setCurrentToolsData(o){this.currentToolsData=o}getCurrentToolsData(){return this.currentToolsData}setCurrentLocalWorkData(o){this.currentLocalWorkData=o}getWorkId(){return this.currentLocalWorkData.workId}getWorkState(){return this.currentLocalWorkData.workState}}class ag extends rg{constructor(t){var s,n;super();M(this,"isActive",!1);M(this,"currentToolsData");M(this,"currentLocalWorkData");M(this,"control");M(this,"internalMsgEmitter");M(this,"taskBatchData",new Set);M(this,"fullWorker");M(this,"subWorker");M(this,"fullWorkerUrl");M(this,"subWorkerUrl");M(this,"methodBuilder");M(this,"zIndexNodeMethod");M(this,"subWorkerDrawCount",0);M(this,"wokerDrawCount",0);M(this,"maxDrawCount",0);M(this,"reRenders",new Map);M(this,"localWorkViewId");M(this,"localPointsBatchData",new Map);M(this,"tasksqueue",new Map);M(this,"useTasksqueue",!1);M(this,"useTasksClockId");M(this,"mainTasksqueueCount");M(this,"workerTasksqueueCount");M(this,"snapshotMap",new Map);M(this,"boundingRectMap",new Map);M(this,"clearAllResolveMap",new Map);M(this,"delayWorkStateToDoneResolve");M(this,"animationId");M(this,"tmpImageConfigMap",new Map);M(this,"mainThread");M(this,"willSelectorWorkId");M(this,"isLockSentEventCursor",!1);M(this,"subMainThreadWorker");const{control:e,internalMsgEmitter:i}=t;this.control=e,this.maxLastSyncTime=((n=(s=this.control.pluginOptions)==null?void 0:s.syncOpt)==null?void 0:n.interval)||this.maxLastSyncTime,this.fullWorkerUrl=this.control.pluginOptions.cdn.fullWorkerUrl,this.subWorkerUrl=this.control.pluginOptions.cdn.subWorkerUrl,this.internalMsgEmitter=i,this.currentLocalWorkData={workState:D.Pending}}destroy(){var t,e,i;(t=this.methodBuilder)==null||t.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(),(e=this.fullWorker)==null||e.terminate(),(i=this.subWorker)==null||i.terminate()}get viewContainerManager(){return this.control.viewContainerManager}get collector(){return this.control.collector}get isRunSubWork(){var e;const t=(e=this.currentToolsData)==null?void 0:e.toolsType;return t===C.Pencil||t===C.LaserPen||t===C.Arrow||t===C.Straight||t===C.Ellipse||t===C.Rectangle||t===C.Star||t===C.Polygon||t===C.SpeechBalloon}get isCanDrawWork(){var e;const t=(e=this.currentToolsData)==null?void 0:e.toolsType;return t===C.Pencil||t===C.LaserPen||t===C.Arrow||t===C.Straight||t===C.Ellipse||t===C.Rectangle||t===C.Star||t===C.Polygon||t===C.SpeechBalloon||t===C.Triangle||t===C.Rhombus||t===C.BitMapEraser}get isUseZIndex(){var e;const t=(e=this.currentToolsData)==null?void 0:e.toolsType;return t===C.Pencil||t===C.Arrow||t===C.Straight||t===C.Ellipse||t===C.Rectangle||t===C.Star||t===C.Polygon||t===C.SpeechBalloon||t===C.Text||t===C.Image}get isCanRecordUndoRedo(){var e;const t=(e=this.currentToolsData)==null?void 0:e.toolsType;return t===C.Pencil||t===C.Eraser||t===C.BitMapEraser||t===C.Arrow||t===C.Straight||t===C.Ellipse||t===C.Rectangle||t===C.Star||t===C.Polygon||t===C.SpeechBalloon||t===C.Text||t===C.Image}get isCanSentCursor(){var e;const t=(e=this.currentToolsData)==null?void 0:e.toolsType;return t===C.Pencil||t===C.Text||t===C.LaserPen||t===C.Arrow||t===C.Straight||t===C.Ellipse||t===C.Rectangle||t===C.Star||t===C.Polygon||t===C.SpeechBalloon||t===C.Triangle||t===C.Rhombus||t===C.Eraser||t===C.PencilEraser||t===C.BitMapEraser}get isCanStartEventConsum(){var e;const t=(e=this.currentToolsData)==null?void 0:e.toolsType;return t===C.Selector||t===C.Eraser||t===C.PencilEraser||t===C.BitMapEraser}async init(){this.destroy(),await this.on(),this.internalMsgEmitterListener(),this.isActive=!0}async useMainThread(){console.info("no OffscreenCanvas");const{MainThreadManagerImpl:t}=await Promise.resolve().then(()=>require("./index-CVBczavT.js"));this.mainThread=new t(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 og(this),this.fullWorker.onmessage=t=>{var e,i;if(t.data){const{render:s,sp:n,drawCount:r,workerTasksqueueCount:c,viewId:l}=t.data;this.isBusy&&c&&this.setWorkerTasksqueueCount(c),n!=null&&n.length&&this.collectorSyncData(n);const h=(s==null?void 0:s.length)&&s||[];if(r&&l){if(this.setWorkDrawCount(r),this.wokerDrawCount<1/0){const u=Math.max(this.maxDrawCount,this.wokerDrawCount);this.setMaxDrawCount(u),this.control.priority==="ui"?(e=this.subMainThreadWorker)==null||e.notifyDrawCount(l):this.clearReRenders(this.wokerDrawCount)}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 u of this.reRenders.values())h.push(...u)}h.length&&this.viewContainerManager.render(h)}},this.subWorker.onmessage=t=>{if(t.data){const{render:e,sp:i,drawCount:s}=t.data;i!=null&&i.length&&this.collectorSyncData(i);const n=(e==null?void 0:e.length)&&e||[];if(this.control.priority==="cpu"&&L.isNumber(s)){if(this.setSubWorkerDrawCount(s),this.wokerDrawCount<1/0){const r=Math.max(this.maxDrawCount,this.subWorkerDrawCount);this.setMaxDrawCount(r)}if(e!=null&&e.length)if(this.subWorkerDrawCount>this.wokerDrawCount){const r=[];for(const c of e)c.imageBitmap&&(c.isUnClose=!0,r.push(c));this.reRenders.set(this.subWorkerDrawCount,r)}else this.reRenders.size&&this.clearReRenders(this.subWorkerDrawCount)}n.length&&this.viewContainerManager.render(n)}}}clearReRenders(t=1/0){for(const e of this.reRenders.keys())if(L.isNumber(Number(e))&&Number(e)<=t){const i=this.reRenders.get(Number(e));i==null||i.forEach(s=>{var n;(n=s.imageBitmap)==null||n.close()}),this.reRenders.delete(e)}}get isBusy(){return this.getTasksqueueState()===D.Doing}getLockSentEventCursor(){return this.isLockSentEventCursor}setLockSentEventCursor(t){this.isLockSentEventCursor=t}getTasksqueueState(){return this.useTasksqueue&&D.Doing||D.Done}setMaxDrawCount(t){this.maxDrawCount=t}getWorkDrawCount(){return this.wokerDrawCount}getSubWorkerDrawCount(){return this.subWorkerDrawCount}getMaxDrawCount(){return this.maxDrawCount}setWorkDrawCount(t){this.wokerDrawCount=t}setSubWorkerDrawCount(t){this.subWorkerDrawCount=t}setWorkerTasksqueueCount(t){const e=Math.max(this.workerTasksqueueCount||0,t);this.workerTasksqueueCount=e}collectorSyncData(t){var i,s,n;let e=!1;for(const r of t){const{type:c,selectIds:l,opt:h,selectRect:u,strokeColor:d,fillColor:p,willSyncService:f,isSync:y,imageBitmap:m,canvasHeight:S,canvasWidth:w,rect:v,op:T,canTextEdit:N,points:I,selectorColor:x,canRotate:z,scaleType:A,textOpt:E,toolsType:j,workId:O,viewId:P,dataType:Y,canLock:ot,isLocked:tt,shapeOpt:Q,toolsTypes:J,thickness:G,strokeType:Z,useStroke:X,isgl:rt,imageSrc:wt,isSubWorker:it}=r;if(!P)return;const at=r.scenePath||this.viewContainerManager.getCurScenePath(P);switch(c){case b.Select:{const U=l!=null&&l.length?{...u,selectIds:l,canvasHeight:S,canvasWidth:w,points:I}:void 0;U&&(h!=null&&h.strokeColor)&&(U.selectorColor=h.strokeColor),U&&x&&(U.selectorColor=x),U&&d&&(U.strokeColor=d),U&&(h!=null&&h.fillColor)&&(U.fillColor=h.fillColor),U&&p&&(U.fillColor=p),U&&L.isBoolean(z)&&(U.canRotate=z),U&&A&&(U.scaleType=A),U&&N&&(U.canTextEdit=N),U&&E&&(U.textOpt=E),U&&L.isBoolean(ot)&&(U.canLock=ot),U&&L.isBoolean(tt)&&(U.isLocked=tt),U&&Q&&(U.shapeOpt=Q),U&&J&&(U.toolsTypes=J),U&&G&&(U.thickness=G),U&&Z&&(U.strokeType=Z),U&&L.isBoolean(X)&&(U.useStroke=X),P&&this.viewContainerManager.showFloatBar(P,!!U,U),f&&((i=this.collector)==null||i.dispatch({type:c,selectIds:l,opt:h,isSync:y,viewId:P,scenePath:at}));break}case b.Snapshot:if(m&&at){const U=this.snapshotMap.get(at);U&&U(m)}break;case b.BoundingBox:if(v&&at){const U=this.boundingRectMap.get(at);U&&U(v)}break;case b.Cursor:T&&this.control.cursor.collectServiceCursor({...r});break;case b.Clear:if(P){this.viewContainerManager.showFloatBar(P,!1);const U=(s=this.clearAllResolveMap.get(P))==null?void 0:s.resolve;U&&U(P)}break;case b.TextUpdate:if(j===C.Text&&O&&P){const U=this.viewContainerManager.transformToOriginPoint((h==null?void 0:h.boxPoint)||[0,0],P),nt=(h==null?void 0:h.boxSize)||[0,0],ht=(n=this.viewContainerManager.getView(P))==null?void 0:n.cameraOpt;h?this.control.textEditorManager.updateTextForWorker({x:U[0],y:U[1],w:nt[0],h:nt[1],scale:(ht==null?void 0:ht.scale)||1,workId:O,opt:h,dataType:Y,viewId:P,canSync:f||!1,canWorker:!1}):this.control.textEditorManager.delete(O,f||!1,!1)}break;case b.GetTextActive:j===C.Text&&O&&P&&this.control.textEditorManager.updateTextForWorker({workId:O,isActive:!0,viewId:P,dataType:H.Local,canWorker:!1,canSync:!0},Date.now());break;case b.GetImageBitMap:wt&&O&&P&&ng({src:wt,isgl:rt}).then(U=>{var ht;const nt=new Set;if(nt.add({msgType:b.GetImageBitMap,dataType:H.Local,workId:O,viewId:P,imageSrc:wt,isSubWorker:it,imageBitmap:U}),!this.control.hasOffscreenCanvas())(ht=this.mainThread)==null||ht.consume(nt);else{const vt=it?this.subWorker:this.fullWorker;U?vt.postMessage(nt,[U]):vt.postMessage(nt)}});break;default:e=!0;break}}e&&Bt(()=>{this.collectorAsyncData(t)},this.maxLastSyncTime)}collectorAsyncData(t){var e,i,s,n;for(const r of t){const{type:c,op:l,workId:h,index:u,removeIds:d,ops:p,opt:f,updateNodeOpt:y,toolsType:m,isSync:S,viewId:w,isLockSentEventCursor:v,nextTasks:T}=r;if(!w){console.error("collectorAsyncData",r);return}const N=r.scenePath||this.viewContainerManager.getCurScenePath(w);switch(c){case b.None:{v&&Bt(()=>{this.setLockSentEventCursor(!1)},this.maxLastSyncTime);break}case b.DrawWork:{(e=this.collector)==null||e.dispatch({type:c,op:l,opt:f,toolsType:m,workId:h,index:u,isSync:S,viewId:w,scenePath:N,updateNodeOpt:y});break}case b.FullWork:{(i=this.collector)==null||i.dispatch({type:c,ops:p,workId:h,updateNodeOpt:y,opt:f,toolsType:m,isSync:S,viewId:w,scenePath:N}),this.willSelectorWorkId&&h&&h.toString()===this.willSelectorWorkId&&this.control.runEffectWork(()=>{this.setShapeSelectorByWorkId(this.willSelectorWorkId,w),this.willSelectorWorkId=void 0});break}case b.UpdateNode:{(s=this.collector)==null||s.dispatch({type:c,updateNodeOpt:y,workId:h,opt:f,ops:p,op:l,isSync:S,viewId:w,scenePath:N});break}case b.RemoveNode:{d&&this.control.textEditorManager.deleteBatch(d,!1,!1),(n=this.collector)==null||n.dispatch({type:c,removeIds:d,isSync:S,viewId:w,scenePath:N}),this.willSelectorWorkId&&(d!=null&&d.includes(this.willSelectorWorkId))&&(this.willSelectorWorkId=void 0);break}}T&&Bt(()=>{this.collectorAsyncData(T)},this.maxLastSyncTime)}}async onLocalEventEnd(t,e){var l;const i=this.viewContainerManager.getView(e);if(!i)return;const{focusScenePath:s,cameraOpt:n}=i,r=this.viewContainerManager.transformToScenePoint(t,e),c=[];for(const h of this.localPointsBatchData.keys())if(((l=this.currentToolsData)==null?void 0:l.toolsType)===C.Text){const u=this.getLocalPointInfo(h),d=u==null?void 0:u.state;if(d&&d===D.Start){const p=this.currentLocalWorkData.toolsOpt;p.workState=D.Doing,p.boxPoint=r,p.boxSize=[p.fontSize,p.fontSize],this.control.textEditorManager.checkEmptyTextBlur(),this.control.textEditorManager.createTextForMasterController({workId:Date.now().toString(),x:t[0],y:t[1],scale:(n==null?void 0:n.scale)||1,opt:p,type:Gt.Text,isActive:!0,viewId:e,scenePath:s},Date.now())}this.deleteLocalPoint(h);continue}else this.pushLocalPoint(h,r,D.Done,e),c.push(h);if(c.length){try{if(await new Promise(u=>{setTimeout(async()=>{c.forEach(d=>{this.setLocalPointIsFullWork(d)}),this.delayWorkStateToDoneResolve=u,this.consume()},0)})&&c[0]){const u=c[0];c.forEach(d=>{this.deleteLocalPoint(d)}),this.willSelectorWorkId=u.toString()}}catch(h){console.log("error",h)}this.delayWorkStateToDoneResolve=void 0,c.length=0}}onLocalEventDoing(t,e){var s;if(((s=this.currentToolsData)==null?void 0:s.toolsType)===C.Text)return;this.currentLocalWorkData.workState===D.Start&&this.setCurrentLocalWorkData({...this.currentLocalWorkData,workState:D.Doing});let i=!1;for(const[n,{state:r}]of this.localPointsBatchData.entries())if(this.isAbled()&&r!==D.Pending){const c=this.viewContainerManager.transformToScenePoint(t,e);this.pushLocalPoint(n,c,r===D.Start?D.Doing:r,e),i=!0}if(i){this.runAnimation();return}this.useTasksqueue||this.hoverCursor(t,e)}onLocalEventStart(t,e){var r,c,l,h,u,d;this.viewContainerManager.focuedViewId!==e&&this.viewContainerManager.setFocuedViewId(e),this.isCanDrawWork&&this.control.room&&!this.control.room.disableDeviceInputs&&(this.control.room.disableDeviceInputs=!0);const i=((r=this.currentToolsData)==null?void 0:r.toolsType)===C.Selector?$:Date.now(),s=this.setZIndex(e);this.setCurrentLocalWorkData({workState:D.Start,toolsOpt:s,viewId:e});const n=this.viewContainerManager.transformToScenePoint(t,e);if(this.pushLocalPoint(i,n,D.Start,e,s),((c=this.currentToolsData)==null?void 0:c.toolsType)!==C.Text){if(this.control.textEditorManager.checkEmptyTextBlur(),this.isCanRecordUndoRedo&&this.internalMsgEmitter.emit("addUndoTicker",i,e),i&&s&&((l=this.currentToolsData)!=null&&l.toolsType)&&this.isCanStartEventConsum&&this.prepareOnceWork({workId:i,toolsOpt:s,viewId:e},(h=this.currentToolsData)==null?void 0:h.toolsType),this.maxDrawCount=0,this.wokerDrawCount=0,this.subWorkerDrawCount=0,this.clearReRenders(1/0),(u=this.subMainThreadWorker)==null||u.clearDrawCount(e),this.isCanDrawWork){const p=this.viewContainerManager.getCurScenePath(e);p&&((d=this.collector)!=null&&d.hasSelector(e,p))&&this.blurSelector(e,p)}this.consume()}}setLocalPointIsFullWork(t){const e=this.getLocalPointInfo(t);e&&(e.isFullWork=!0,this.localPointsBatchData.set(t,e))}pushLocalPoint(t,e,i,s,n){let r=this.getLocalPointInfo(t);i===D.Start?r={state:D.Start,points:e,opt:n||this.currentLocalWorkData.toolsOpt,isFullWork:!1,viewId:s}:r&&(r.state=i,r.points.push(e[0],e[1])),r&&this.localPointsBatchData.set(t,r)}deleteLocalPoint(t){this.localPointsBatchData.delete(t)}getLocalPointInfo(t){return this.localPointsBatchData.get(t)}getLocalPointsInfo(){return this.localPointsBatchData}correctStorage(t,e,i){var c;const s=new Map,n=[];Object.keys(t).forEach(l=>{var u,d;const h=(d=(u=t[l])==null?void 0:u.opt)==null?void 0:d.zIndex;L.isNumber(h)&&n.push([l,h])});const r=n.length&&((c=this.zIndexNodeMethod)==null?void 0:c.correct(n))||[];this.zIndexNodeMethod&&r.length&&(this.zIndexNodeMethod.setMinZIndex(r[0][1]||0,e),this.zIndexNodeMethod.setMaxZIndex(r[r.length-1][1]||0,e));for(const[l,h]of r){if(!t[l])continue;const u=t[l];u.opt&&L.isNumber(u.opt.zIndex)&&u.opt.zIndex!==h&&(u.opt.zIndex=h,s.set(l,u))}return s.size&&s.forEach((l,h)=>{var u;(u=this.collector)==null||u.updateValue(h,l,{viewId:e,scenePath:i,isSync:!0}),t[h]=l}),t}async originalEventLintener(t,e,i){var r,c;if(!this.isAbled())return;const s=(r=this.collector)==null?void 0:r.uid,n=this.viewContainerManager.getCurScenePath(i);if(!(s&&!this.control.renderControl.isWriteable())){switch((c=this.currentToolsData)==null?void 0:c.toolsType){case C.Eraser:case C.PencilEraser:case C.BitMapEraser:{if(s&&!this.control.renderControl.isClearAble({uid:s,viewId:i,scenePath:n}))return;break}default:{if(s&&!this.control.renderControl.isRenderAble({uid:s,viewId:i,scenePath:n}))return;break}}switch(t){case D.Start:this.setLocalWorkViewId(i),i&&this.onLocalEventStart(e,i);break;case D.Doing:i&&i===this.getLocalWorkViewId()&&this.onLocalEventDoing(e,i);break;case D.Done:i&&i===this.getLocalWorkViewId()&&await this.onLocalEventEnd(e,i);break}}}getLocalWorkViewId(){return this.localWorkViewId}setLocalWorkViewId(t){this.localWorkViewId=t}setCurrentToolsData(t){var s,n,r;const e=t.toolsType,i=((s=this.currentToolsData)==null?void 0:s.toolsType)!==t.toolsType;if(super.setCurrentToolsData(t),i){const c=(n=this.viewContainerManager)==null?void 0:n.getAllViews();for(const l of c)if(l){const{id:h,focusScenePath:u}=l;i&&h&&u&&((r=this.collector)!=null&&r.hasSelector(h,u)&&this.blurSelector(h,u),this.control.textEditorManager.checkEmptyTextBlur())}this.taskBatchData.add({msgType:b.UpdateTools,dataType:H.Local,toolsType:e,opt:{...t.toolsOpt,syncUnitTime:this.maxLastSyncTime},isRunSubWork:this.isRunSubWork,viewId:Fe}),this.runAnimation()}}prepareOnceWork(t,e){const{workId:i,toolsOpt:s,viewId:n}=t;this.queryTaskBatchData({msgType:b.CreateWork,dataType:H.Local,viewId:n,toolsType:e}).forEach(r=>{this.taskBatchData.delete(r)}),this.taskBatchData.add({msgType:b.CreateWork,workId:i,toolsType:e,opt:{...s,syncUnitTime:this.maxLastSyncTime},dataType:H.Local,isRunSubWork:this.isRunSubWork,viewId:n}),this.runAnimation()}createViewWorker(t,e){const{offscreenCanvasOpt:i,layerOpt:s,dpr:n,cameraOpt:r}=e;this.taskBatchData.add({msgType:b.Init,dataType:H.Local,viewId:t,offscreenCanvasOpt:i,layerOpt:s,dpr:n,cameraOpt:r,isRunSubWork:!0,isSafari:navigator.userAgent.indexOf("Safari")!==-1&&navigator.userAgent.indexOf("Chrome")===-1}),this.isBusy&&this.destroyTaskQueue(),this.consume()}destroyViewWorker(t,e=!1){var i;this.getLocalWorkViewId()===t&&this.setLocalWorkViewId(void 0),this.zIndexNodeMethod&&this.zIndexNodeMethod.clearZIndex(t),this.taskBatchData.add({msgType:b.Destroy,dataType:H.Local,viewId:t,isRunSubWork:!0}),this.consume(),e||(i=this.collector)==null||i.dispatch({type:b.Clear,viewId:t}),this.control.renderControl.destoryByViewId(t,e)}onServiceDerive(t,e){var p,f,y,m,S;const{newValue:i,oldValue:s,viewId:n,scenePath:r}=e,c=L.cloneDeep(i)||{},l=t;let h=c.type;if(!i&&s){if(l&&((p=this.collector)==null?void 0:p.getLocalId(l))===$){this.collector.isOwn(l)?this.blurSelector(n,r):this.blurSelector(n,r,l);return}if(h=b.RemoveNode,s.toolsType===C.LaserPen)return}const u=(f=this.viewContainerManager.getView(n))==null?void 0:f.focusScenePath;if(u&&u!==r)return;if(h&&l){if(!this.control.renderControl.isFilterAble({viewId:n,elementId:t,scenePath:r},h))return;const w=c;if(w.workId=(y=this.collector)!=null&&y.isOwn(l)?(m=this.collector)==null?void 0:m.getLocalId(l):l,w.msgType=h,w.toolsType===C.LaserPen&&(w.isRunSubWork=!0),w.dataType=H.Service,w.viewId=n,w.scenePath=r,w.selectIds&&(w.selectIds=w.selectIds.map(v=>{var T,N;return(T=this.collector)!=null&&T.isOwn(v)?(N=this.collector)==null?void 0:N.getLocalId(v):v})),w&&w.toolsType===C.Text||(s==null?void 0:s.toolsType)===C.Text){this.control.textEditorManager.onServiceDerive(w);return}this.taskBatchData.add(w)}this.runAnimation();const d=e.newValue&&((S=e.newValue.opt)==null?void 0:S.zIndex);if(this.zIndexNodeMethod&&L.isNumber(d)){const w=this.zIndexNodeMethod.getMinZIndex(n);this.zIndexNodeMethod.getMaxZIndex(n)<d&&this.zIndexNodeMethod.setMaxZIndex(d,n),w>d&&this.zIndexNodeMethod.setMinZIndex(d,n)}}pullServiceData(t,e,i={isAsync:!1,useAnimation:!1}){var c,l,h,u;let s=(c=this.collector)==null?void 0:c.getStorageData(t,e);const{isAsync:n,useAnimation:r}=i;if(s){this.control.renderControl.isWriteable()&&(s=this.correctStorage(s,t,e));const d=Object.keys(s);for(const p of d){const f=(l=s[p])==null?void 0:l.type;if(f&&p){if(!this.control.renderControl.isFilterAble({viewId:t,elementId:p,scenePath:e},f))continue;const y=s[p];if(y.workId=(h=this.collector)!=null&&h.isOwn(p)?(u=this.collector)==null?void 0:u.getLocalId(p):p,y.msgType=f,y.dataType=H.Service,y.viewId=t,y.scenePath=e,y.useAnimation=!!r,y.selectIds&&(y.selectIds=y.selectIds.map(m=>{var S,w;return(S=this.collector)!=null&&S.isOwn(m)?(w=this.collector)==null?void 0:w.getLocalId(m):m})),y.toolsType===C.Text){this.control.textEditorManager.onServiceDerive(y);continue}this.taskBatchData.add(y)}this.internalMsgEmitter.emit("excludeIds",d,t)}n?this.consume():this.runAnimation()}}runAnimation(){!this.animationId&&!this.isBusy&&(this.animationId=requestAnimationFrame(this.consume.bind(this)))}consume(){var e;this.animationId=void 0;const{viewId:t}=this.currentLocalWorkData;if(this.tasksqueue.size){const i=this.consumeQueue(),s=!!i.size;if(this.taskBatchData.size)for(const n of this.taskBatchData.values())n.dataType===H.Service&&(i.add(n),this.taskBatchData.delete(n));i.size?(this.post(i),s&&this.tasksqueue.clear()):this.tasksqueue.size&&(this.animationId=requestAnimationFrame(this.consume.bind(this)));return}if(this.isAbled()&&this.localPointsBatchData.size&&t)for(const[i,{state:s,isFullWork:n,points:r,opt:c}]of this.localPointsBatchData.entries()){if(s===D.Done&&!n||s===D.Start&&!this.isCanStartEventConsum)continue;const l=r.map(h=>h);l.length&&(this.delayWorkStateToDoneResolve&&s===D.Done&&(this.delayWorkStateToDoneResolve(!0),this.setLockSentEventCursor(!0)),this.taskBatchData.add({op:l,workState:s,workId:i,dataType:H.Local,msgType:b.DrawWork,isRunSubWork:this.isRunSubWork,toolsType:(e=this.currentToolsData)==null?void 0:e.toolsType,viewId:t,scenePath:t&&this.viewContainerManager.getCurScenePath(t),opt:c,isLockSentEventCursor:this.getLockSentEventCursor(),syncUnitTime:this.maxLastSyncTime}),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:D.Unwritable,workId:void 0})}abled(){this.setCurrentLocalWorkData({workState:D.Pending,workId:void 0})}isAbled(){return this.currentLocalWorkData.workState!==D.Unwritable}post(t){var i;if(!this.control.hasOffscreenCanvas()){if(!this.mainThread){let s=[];s=L.cloneDeep([...t]),setTimeout(()=>{for(const n of s)this.taskBatchData.add(n)},0);return}this.mainThread.consume(t);return}this.fullWorker.postMessage(t);const e=new Set;for(const s of t.values()){const n=s.msgType;(n===b.Init||n===b.Clear||n===b.Destroy||n===b.UpdateCamera||s.isRunSubWork)&&e.add(s)}e.size&&(this.subWorker.postMessage(e),this.control.priority==="ui"&&((i=this.subMainThreadWorker)==null||i.consume(e)))}updateNode(t,e,i,s){this.taskBatchData.add({msgType:b.UpdateNode,workId:t,updateNodeOpt:e,viewId:i,scenePath:s,dataType:H.Local}),this.runAnimation()}destroyTaskQueue(){this.useTasksqueue=!1,this.useTasksClockId&&(clearTimeout(this.useTasksClockId),this.useTasksClockId=void 0),this.mainTasksqueueCount=void 0,this.workerTasksqueueCount=void 0}updateCamera(t,e){var i;this.useTasksqueue||((i=this.methodBuilder)==null||i.pause(),this.blurCursor(t),this.checkDrawingWork(t),this.useTasksqueue=!0,this.mainTasksqueueCount=1,this.workerTasksqueueCount=1),this.useTasksqueue&&(this.tasksqueue.set(t,{msgType:b.UpdateCamera,dataType:H.Local,cameraOpt:{...e,width:e.width,height:e.height},scenePath:this.viewContainerManager.getCurScenePath(t),isRunSubWork:!0,viewId:t}),this.consume(),this.useTasksClockId&&clearTimeout(this.useTasksClockId),this.updateCameraDone())}updateCameraDone(){this.useTasksClockId=setTimeout(()=>{var t,e;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"&&((t=this.subMainThreadWorker)==null||t.updateCamera()),(e=this.methodBuilder)==null||e.recover(),this.runAnimation()):this.updateCameraDone()},this.maxLastSyncTime)}consumeQueue(){const t=new Set;let e=!this.isBusy;if(this.isBusy&&this.mainTasksqueueCount&&this.workerTasksqueueCount&&this.mainTasksqueueCount<=this.workerTasksqueueCount&&(e=!0),e){this.mainTasksqueueCount&&this.workerTasksqueueCount&&this.mainTasksqueueCount++,t.add({msgType:b.TasksQueue,dataType:H.Local,isRunSubWork:!0,mainTasksqueueCount:this.mainTasksqueueCount,tasksqueue:this.tasksqueue,viewId:""});for(const[i,s]of this.tasksqueue.entries())s.cameraOpt&&this.control.textEditorManager.onCameraChange(s.cameraOpt,i)}return t}async clearViewScenePath(t,e,i){var n,r;const s=this.viewContainerManager.getCurScenePath(t);if(i){const c=(n=this.collector)==null?void 0:n.uid;if(c&&!this.control.renderControl.isClearAble({uid:c,viewId:t,scenePath:s}))return}this.control.textEditorManager.clear(t,e),this.queryTaskBatchData({msgType:b.Clear,dataType:H.Local,viewId:t}).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add({dataType:H.Local,msgType:b.Clear,viewId:t}),this.runAnimation(),e||(this.control.renderControl.isUsePageAuth(t)&&s?this.control.renderControl.clearRenderPage(t,s):(r=this.collector)==null||r.dispatch({type:b.Clear,viewId:t,scenePath:s})),this.zIndexNodeMethod&&this.zIndexNodeMethod.clearZIndex(t),this.localPointsBatchData.clear(),await new Promise(c=>{const l=this.clearAllResolveMap.get(t)||{resolve:void 0,timer:void 0};l.timer&&clearTimeout(l.timer),l.resolve=c,l.timer=setTimeout(()=>{const h=this.clearAllResolveMap.get(t);h!=null&&h.resolve&&h.resolve(t)},this.maxLastSyncTime),this.clearAllResolveMap.set(t,l)}).then(c=>{this.clearAllResolveMap.delete(c)})}internalMsgEmitterListener(){var t;this.methodBuilder=new K([R.CopyNode,R.SetColorNode,R.DeleteNode,R.RotateNode,R.ScaleNode,R.TranslateNode,R.ZIndexNode,R.RotateNode,R.SetFontStyle,R.SetPoint,R.SetLock,R.SetShapeOpt]).registerForMainEngine(q.MainEngine,this.control),this.zIndexNodeMethod=(t=this.methodBuilder)==null?void 0:t.getBuilder(R.ZIndexNode)}setZIndex(t){const e=this.currentToolsData&&L.cloneDeep(this.currentToolsData.toolsOpt);return e&&this.zIndexNodeMethod&&this.isUseZIndex&&(this.zIndexNodeMethod.addMaxLayer(t),e.zIndex=this.zIndexNodeMethod.getMaxZIndex(t)),e}checkDrawingWork(t){var s,n,r;let e=!1;const i=[];for(const[c,{state:l,viewId:h,points:u,opt:d}]of this.localPointsBatchData.entries())if(t===h&&l===D.Start||l===D.Doing){if(l===D.Doing&&this.isCanDrawWork){Number(c)&&Number(c)+60>Date.now()&&(i.push(c.toString()),this.taskBatchData.add({msgType:b.RemoveNode,workId:c,viewId:h,dataType:H.Local,isRunSubWork:!0}));const p=u.map(f=>f);this.taskBatchData.add({op:p,workState:D.Done,workId:c,dataType:H.Local,msgType:b.DrawWork,isRunSubWork:this.isRunSubWork,toolsType:(s=this.currentToolsData)==null?void 0:s.toolsType,viewId:h,opt:d,scenePath:h&&this.viewContainerManager.getCurScenePath(h)}),e=!0}this.deleteLocalPoint(c)}if((e||i.length)&&(this.consume(),i.length)){const c=(n=this.viewContainerManager.getView(t))==null?void 0:n.focusScenePath;(r=this.collector)==null||r.dispatch({type:b.RemoveNode,removeIds:i,viewId:t,scenePath:c})}}removeDrawingWork(t){var i,s;const e=[];for(const[n,{state:r,viewId:c}]of this.localPointsBatchData.entries())(t===c&&r===D.Start||r===D.Doing)&&(this.deleteLocalPoint(n),r===D.Doing&&this.isCanDrawWork&&(e.push(n.toString()),this.taskBatchData.add({msgType:b.RemoveNode,workId:n,viewId:c,dataType:H.Local,isRunSubWork:!0})));if(e.length){this.consume();const n=(i=this.viewContainerManager.getView(t))==null?void 0:i.focusScenePath;(s=this.collector)==null||s.dispatch({type:b.RemoveNode,removeIds:e,viewId:t,scenePath:n})}}hoverCursor(t,e){var i;if(((i=this.currentToolsData)==null?void 0:i.toolsType)===C.Selector){const s=this.viewContainerManager.getView(e);if(s&&s.displayer&&s.displayer.vDom){const c=s.displayer.vDom.state.floatBarData;if(c){const{x:l,y:h,w:u,h:d}=c;if(ks(t,{x:l,y:h,w:u,h:d}))return}}const n=this.viewContainerManager.transformToScenePoint(t,e),r={msgType:b.CursorHover,dataType:H.Local,point:n,toolsType:this.currentToolsData.toolsType,opt:this.currentToolsData.toolsOpt,isRunSubWork:!1,viewId:e};this.queryTaskBatchData({msgType:b.CursorHover,dataType:H.Local,toolsType:this.currentToolsData.toolsType,viewId:e}).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add(r),this.runAnimation()}}blurCursor(t){var i;if(((i=this.currentToolsData)==null?void 0:i.toolsType)!==C.Selector)return;const e={msgType:b.CursorBlur,dataType:H.Local,isRunSubWork:!1,viewId:t};this.queryTaskBatchData({msgType:b.CursorHover,dataType:H.Local,viewId:t}).forEach(s=>{this.taskBatchData.delete(s)}),this.taskBatchData.add(e),this.consume()}sendCursorEvent(t,e){var r,c;if(!this.currentLocalWorkData||this.currentLocalWorkData.workState===D.Unwritable||!this.currentToolsData||!this.isCanSentCursor)return;const i=(r=this.collector)==null?void 0:r.uid,s=this.viewContainerManager.getCurScenePath(e);switch((c=this.currentToolsData)==null?void 0:c.toolsType){case C.Eraser:case C.PencilEraser:case C.BitMapEraser:{if(i&&!this.control.renderControl.isClearAble({uid:i,viewId:e,filterLocalSelf:!1,scenePath:s}))return;break}default:if(i&&!this.control.renderControl.isWriteable()||i&&!this.control.renderControl.isRenderAble({uid:i,viewId:e,filterLocalSelf:!1,scenePath:s}))return;break}let n=[void 0,void 0];this.currentToolsData&&this.isCanSentCursor&&!this.localPointsBatchData.size&&!this.getLockSentEventCursor()&&(n=t,this.control.cursor.sendEvent(n,e))}getBoundingRect(t){var i,s;if(!((i=this.boundingRectMap)==null?void 0:i.get(t))){const n=(s=this.collector)==null?void 0:s.getScenePathData(t);if(!n)return;if(Object.keys(n).forEach(r=>{var c;((c=this.collector)==null?void 0:c.getLocalId(r))===$&&delete n[r]}),Object.keys(n).length&&this.viewContainerManager.mainView&&this.viewContainerManager.mainView.cameraOpt){const r={msgType:b.BoundingBox,dataType:H.Local,scenePath:t,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(t,c)}).then(c=>(this.boundingRectMap.delete(t),c))}}}getSnapshot(t,e,i,s){var r,c,l,h,u;if(!((r=this.snapshotMap)==null?void 0:r.get(t))){const d=(c=this.collector)==null?void 0:c.getViewIdBySecenPath(t);if(!d)return;const p=(l=this.collector)==null?void 0:l.getStorageData(d,t);if(!p)return;if(Object.keys(p).forEach(f=>{var y;((y=this.collector)==null?void 0:y.getLocalId(f))===$&&delete p[f]}),Object.keys(p).length){const f=this.viewContainerManager.mainView;if(!f)return;const y=e||((h=f.cameraOpt)==null?void 0:h.width),m=i||((u=f.cameraOpt)==null?void 0:u.height),S={msgType:b.Snapshot,dataType:H.Local,scenePath:t,scenes:p,w:y,h:m,cameraOpt:s&&{...s,width:y,height:m}||f.cameraOpt,isRunSubWork:!0,viewId:f.id};return this.taskBatchData.add(S),this.runAnimation(),new Promise(w=>{this.snapshotMap.set(t,w)}).then(w=>(this.snapshotMap.delete(t),w))}}}queryTaskBatchData(t){const e=[];if(t)for(const i of this.taskBatchData.values()){let s=!0;for(const[n,r]of Object.entries(t))if(i[n]!==r){s=!1;break}s&&e.push(i)}return e}insertImage(t,e){const i=this.viewContainerManager.getView(t);if(!i)throw new Error("insertImage viewId is not exist");if(e.src&&!/^(http|https):\/\//.test(e.src))throw new Error("Image src must be http or https");const s=i==null?void 0:i.focusScenePath;if(t&&s){const{src:n,uuid:r}=e;if(r&&!n){this.tmpImageConfigMap.set(r,e);return}const c=Date.now();Nt.InternalMsgEmitter.emit("addUndoTicker",c,t);const l={...e};this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayer(t),l.zIndex=this.zIndexNodeMethod.getMaxZIndex(t)),this.taskBatchData.add({msgType:b.FullWork,dataType:H.Local,toolsType:C.Image,workId:e.uuid,opt:l,viewId:t,willRefresh:!0,willSyncService:!0}),this.runAnimation()}}lockImage(t,e,i){var r,c;const s=this.viewContainerManager.getView(t);if(!s)throw new Error("insertImage viewId is not exist");const n=s==null?void 0:s.focusScenePath;if(t&&n&&this.collector){const l=this.collector.getStorageData(t,n);if(!l)return;for(const[h,u]of Object.entries(l))if(u&&u.toolsType===C.Image&&u.opt.uuid===e){const d=Date.now();Nt.InternalMsgEmitter.emit("addUndoTicker",d,t);const p=(r=this.collector)!=null&&r.isOwn(h)?(c=this.collector)==null?void 0:c.getLocalId(h):h,f={...u.opt,locked:i};this.taskBatchData.add({msgType:b.FullWork,dataType:H.Local,toolsType:C.Image,workId:p,opt:f,viewId:t,willRefresh:!0,willSyncService:!0}),this.runAnimation();return}}}completeImageUpload(t,e,i){const s=this.viewContainerManager.getView(t);if(!s)throw new Error("insertImage viewId is not exist");const n=s==null?void 0:s.focusScenePath;if(t&&n){const r=this.tmpImageConfigMap.get(e);r&&(r.src=i,this.insertImage(t,r),this.tmpImageConfigMap.delete(e));return}}getImagesInformation(t){const e=[];if(this.collector){const i=this.collector.getScenePathData(t);if(!i)return e;for(const s of Object.values(i))if(s&&s.toolsType===C.Image){const n=s.opt;e.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 e}setShapeSelectorByWorkId(t,e){this.taskBatchData.add({workId:$,selectIds:[t],msgType:b.Select,dataType:H.Local,viewId:e,willSyncService:!0}),this.runAnimation()}blurSelector(t,e,i){this.taskBatchData.add({workId:i||$,selectIds:[],msgType:b.Select,dataType:H.Service,viewId:t,scenePath:e}),this.runAnimation()}consoleWorkerInfo(){this.taskBatchData.add({msgType:b.Console,dataType:H.Local,isRunSubWork:!0,viewId:""}),this.consume()}setPriority(t){var s,n;const e=new Set,i=new Set;if(t==="cpu"&&((s=this.subMainThreadWorker)==null||s.destroy(),e.add({msgType:b.PriorityWorker,viewId:Fe,dataType:H.Local,isRunSubWork:!0})),t==="ui"){e.add({msgType:b.PriorityMainThreadWorker,viewId:Fe,dataType:H.Local,isRunSubWork:!0});const r=this.viewContainerManager.mainView;if(r){const l=this.viewContainerManager.getViewInitData(r.id);if(l){const{offscreenCanvasOpt:h,layerOpt:u,dpr:d,cameraOpt:p}=l;i.add({msgType:b.Init,dataType:H.Local,viewId:r.id,offscreenCanvasOpt:h,layerOpt:u,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 h=this.viewContainerManager.getViewInitData(l);if(h){const{offscreenCanvasOpt:u,layerOpt:d,dpr:p,cameraOpt:f}=h;i.add({msgType:b.Init,dataType:H.Local,viewId:l,offscreenCanvasOpt:u,layerOpt:d,dpr:p,cameraOpt:f,isRunSubWork:!0,isSafari:navigator.userAgent.indexOf("Safari")!==-1&&navigator.userAgent.indexOf("Chrome")===-1})}}}e.size&&this.subWorker.postMessage(e),i.size&&((n=this.subMainThreadWorker)==null||n.consume(i))}sendClearUids(t,e){var s,n;const i=new Set;i.add({msgType:b.AuthClear,dataType:H.Local,viewId:t,clearUids:e,localUid:(s=this.collector)==null?void 0:s.uid}),this.control.hasOffscreenCanvas()?this.fullWorker.postMessage(i):(n=this.mainThread)==null||n.consume(i)}}var cg=Ft,lg=function(){return cg.Date.now()},hg=lg,ug=/\s/;function dg(a){for(var o=a.length;o--&&ug.test(a.charAt(o)););return o}var pg=dg,fg=pg,gg=/^\s+/;function Mg(a){return a&&a.slice(0,fg(a)+1).replace(gg,"")}var yg=Mg,mg=ce,wg=qt,vg="[object Symbol]";function Ig(a){return typeof a=="symbol"||wg(a)&&mg(a)==vg}var Ng=Ig,Tg=yg,bi=ee,Sg=Ng,Pi=NaN,Cg=/^[-+]0x[0-9a-f]+$/i,kg=/^0b[01]+$/i,xg=/^0o[0-7]+$/i,zg=parseInt;function bg(a){if(typeof a=="number")return a;if(Sg(a))return Pi;if(bi(a)){var o=typeof a.valueOf=="function"?a.valueOf():a;a=bi(o)?o+"":o}if(typeof a!="string")return a===0?a:+a;a=Tg(a);var t=kg.test(a);return t||xg.test(a)?zg(a.slice(2),t?2:8):Cg.test(a)?Pi:+a}var Pg=bg,Lg=ee,mo=hg,Li=Pg,Dg="Expected a function",jg=Math.max,Ag=Math.min;function Eg(a,o,t){var e,i,s,n,r,c,l=0,h=!1,u=!1,d=!0;if(typeof a!="function")throw new TypeError(Dg);o=Li(o)||0,Lg(t)&&(h=!!t.leading,u="maxWait"in t,s=u?jg(Li(t.maxWait)||0,o):s,d="trailing"in t?!!t.trailing:d);function p(I){var x=e,z=i;return e=i=void 0,l=I,n=a.apply(z,x),n}function f(I){return l=I,r=setTimeout(S,o),h?p(I):n}function y(I){var x=I-c,z=I-l,A=o-x;return u?Ag(A,s-z):A}function m(I){var x=I-c,z=I-l;return c===void 0||x>=o||x<0||u&&z>=s}function S(){var I=mo();if(m(I))return w(I);r=setTimeout(S,y(I))}function w(I){return r=void 0,d&&e?p(I):(e=i=void 0,n)}function v(){r!==void 0&&clearTimeout(r),l=0,e=c=i=r=void 0}function T(){return r===void 0?n:w(mo())}function N(){var I=mo(),x=m(I);if(e=arguments,i=this,c=I,x){if(r===void 0)return f(c);if(u)return clearTimeout(r),r=setTimeout(S,o),p(c)}return r===void 0&&(r=setTimeout(S,o)),n}return N.cancel=v,N.flush=T,N}var Og=Eg,Rg=Og,Yg=ee,Wg="Expected a function";function Ug(a,o,t){var e=!0,i=!0;if(typeof a!="function")throw new TypeError(Wg);return Yg(t)&&(e="leading"in t?!!t.leading:e,i="trailing"in t?!!t.trailing:i),Rg(a,o,{leading:e,maxWait:o,trailing:i})}var Bg=Ug;const Ee=Ie(Bg);class Vg{constructor(o){M(this,"internalMsgEmitter");M(this,"control");M(this,"roomHotkeyCheckers");M(this,"tmpCopyStore",new Map);M(this,"tmpCopyCoordInfo");var i;const{control:t,internalMsgEmitter:e}=o;this.control=t,this.internalMsgEmitter=e,this.roomHotkeyCheckers=((i=this.control.room)==null?void 0:i.viewsParams.hotKeys.nodes)||[]}get isUseSelf(){var o;return((o=this.control.room)==null?void 0:o.disableDeviceInputs)||!1}get isSelector(){var o;return((o=this.control.worker.currentToolsData)==null?void 0:o.toolsType)===C.Selector}get collector(){return this.control.collector}get mainEngine(){return this.control.worker}get keyboardKind(){return/^Mac/i.test(navigator.platform)?"mac":"windows"}getEventKey(o){switch(o.type){case"keydown":return"KeyDown"}return"KeyUp"}onActiveHotkey(o){var i,s,n;const t=this.control.viewContainerManager.focuedViewId,e=(i=this.control.viewContainerManager.focuedView)==null?void 0:i.focusScenePath;if(t&&e)switch(o){case"delete":this.isSelector&&((s=this.collector)!=null&&s.hasSelector(t,e))&&K.emitMethod(q.MainEngine,R.DeleteNode,{workIds:[$],viewId:t});break;case"copy":this.isSelector&&((n=this.collector)!=null&&n.hasSelector(t,e))&&this.copySelectorToTemp(t,e);break;case"paste":this.tmpCopyStore.size&&this.pasteTempToFocusView(t,e);break}(o==="changeToPencil"||o==="redo"||o==="undo")&&this.onSelfActiveHotkey(o)}colloctHotkey(o){if(this.isUseSelf){const t=this.checkHotkey(o);t&&this.onSelfActiveHotkey(t)}}onSelfActiveHotkey(o){switch(o){case"changeToPencil":this.setMemberState({currentApplianceName:st.pencil,useNewPencil:!0});break;case"changeToArrow":this.setMemberState({currentApplianceName:st.arrow});break;case"changeToClick":this.setMemberState({currentApplianceName:st.clicker});break;case"changeToEllipse":this.setMemberState({currentApplianceName:st.ellipse});break;case"changeToEraser":this.setMemberState({currentApplianceName:st.eraser,isLine:!0});break;case"changeToHand":this.setMemberState({currentApplianceName:st.hand});break;case"changeToLaserPointer":this.setMemberState({currentApplianceName:st.laserPointer});break;case"changeToSelector":this.setMemberState({currentApplianceName:st.selector});break;case"changeToRectangle":this.setMemberState({currentApplianceName:st.rectangle});break;case"changeToStraight":this.setMemberState({currentApplianceName:st.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:st.text});break}}checkHotkey(o){for(const t of this.roomHotkeyCheckers){const{kind:e,checker:i}=t;if(i({nativeEvent:o,kind:this.getEventKey(o),key:o.key,altKey:o.altKey,ctrlKey:o.ctrlKey,shiftKey:o.shiftKey},this.keyboardKind))return e}}copySelectorToTemp(o,t){var l,h;const e=this.control.viewContainerManager.getView(o),i=(h=(l=this.mainEngine)==null?void 0:l.methodBuilder)==null?void 0:h.getBuilder(R.CopyNode);if(!e||!this.collector||!i)return;const s=this.collector.transformKey($),n=this.collector.getStorageData(o,t);if(!n)return;const r=n[s],c=r&&i.copySelector({viewId:o,store:r});c&&(this.tmpCopyCoordInfo=c==null?void 0:c.copyCoordInfo,this.tmpCopyStore=c==null?void 0:c.copyStores)}pasteTempToFocusView(o,t){var s,n;const e=this.control.viewContainerManager.getView(o),i=(n=(s=this.mainEngine)==null?void 0:s.methodBuilder)==null?void 0:n.getBuilder(R.CopyNode);if(!(!e||!this.tmpCopyCoordInfo||!this.tmpCopyStore.size||!this.collector||!i)&&e.viewData&&this.tmpCopyCoordInfo){const r=L.cloneDeep(this.tmpCopyCoordInfo.offset),c=this.tmpCopyCoordInfo.cameraOpt,l=e.viewData.camera;r.x=r.x+l.centerX-c.centerX,r.y=r.y+l.centerY-c.centerY;const h=Date.now();this.control.worker.internalMsgEmitter.emit("addUndoTicker",h,o),i.pasteSelector({viewId:o,scenePath:t,copyStores:L.cloneDeep(this.tmpCopyStore),copyCoordInfo:{offset:r,cameraOpt:l},undoTickerId:h})}}setMemberState(o){var t;(t=this.control.room)==null||t.setMemberState(o)}}class Fg{constructor(o){M(this,"control");M(this,"roomMemberManager");M(this,"worker");M(this,"publicMsgEmitter");M(this,"renderUids",new Map);M(this,"pageAuth",new Map);M(this,"isLocalRender",!1);M(this,"isCurWritable",!1);var i;const{control:t,publicMsgEmitter:e}=o;this.control=t,this.publicMsgEmitter=e,this.roomMemberManager=t.roomMember,this.worker=t.worker,this.isCurWritable=((i=this.control.room)==null?void 0:i.isWritable)||!1}onWritableChange(o){this.isCurWritable=o}addPage(o,t=!0){var l,h;const{viewId:e,render:i="localSelf",elementIds:s,pageId:n=(l=this.control.collector)==null?void 0:l.uid}=o,r=this.pageAuth.get(e)||new Map,c=this.control.viewContainerManager.getCurScenePath(e);if(c&&n){const u=r.get(c)||{render:"localSelf",pages:new Map};t&&(u.render=i);const d=s&&this.cloneElementIds(e,c,s,n)||new Set;u.pages.set(n,d),r.set(c,u),this.pageAuth.set(e,r),t&&this.pageAuthEffect(e),this.isLocalRender=!1,(h=this.control.collector)==null||h.dispatchPageAuth({operation:xt.addPage,viewId:e,scenePath:c,pageId:n,pageData:{render:i,elementIds:d}},!0)}}delPage(o,t){var n,r;const e=this.pageAuth.get(t);if(!e)return;const i=[...e.keys()].find(c=>{const l=e.get(c);return!!(l&&l.pages.has(o))});if(!i)return;const s=e.get(i);if(s){const{render:c,pages:l}=s,h=c==="localSelf"?(n=this.control.collector)==null?void 0:n.uid:c,u=l.get(o);u!=null&&u.size&&this.delElementIds(t,i,u),l.delete(o),h===o&&this.pageAuthEffect(t)}(r=this.control.collector)==null||r.dispatchPageAuth({operation:xt.deletePage,viewId:t,scenePath:i,pageId:o},!0)}delViewPage(o,t=!0){var i;this.pageAuth.get(o)&&(this.pageAuth.delete(o),t&&((i=this.control.collector)==null||i.dispatchPageAuth({operation:xt.clearView,viewId:o},t)))}clearRenderPage(o,t,e=!0){var r,c;const i=this.pageAuth.get(o);if(!i)return;const s=i.get(t);let n;if(s){const{render:l,pages:h}=s,u=l==="localSelf"?(r=this.control.collector)==null?void 0:r.uid:l;if(u){if(e){const d=h.get(u);d&&this.delElementIds(o,t,d)}h.set(u,new Set),n=u}}e&&n&&((c=this.control.collector)==null||c.dispatchPageAuth({operation:xt.clearPage,viewId:o,scenePath:t,pageId:n},e))}hasPage(o,t,e){const i=this.pageAuth.get(t);if(!i)return!1;const s=i.get(e);return s?s.pages.has(o):!1}getPageInfo(o,t,e){const i=this.pageAuth.get(t);if(!i)return;const s=i.get(e);if(s)return s.pages.get(o)}addRenderPageElementId(o,t=!0,e=!1){var h,u;const{viewId:i,elementId:s,scenePath:n}=o,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"?(h=this.control.collector)==null?void 0:h.uid:d;if(f&&p.has(f)){const y=p.get(f)||new Set;y.add(s),p.set(f,y),l=f}}e&&this.pageAuthEffect(i),t&&l&&((u=this.control.collector)==null||u.dispatchPageAuth({operation:xt.addElement,viewId:i,scenePath:n,pageId:l,pageData:{elementId:s}},t))}delRenderPageElementId(o,t=!0,e=!1){var h,u;const{viewId:i,elementId:s,scenePath:n}=o,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"?(h=this.control.collector)==null?void 0:h.uid:d;if(f&&p.has(f)){const y=p.get(f);y&&(y.delete(s),p.set(f,y),l=f)}}e&&this.pageAuthEffect(i),t&&l&&((u=this.control.collector)==null||u.dispatchPageAuth({operation:xt.deleteElement,viewId:i,scenePath:n,pageId:l,pageData:{elementId:s}},t))}setPageRender(o,t,e,i=!0){var r;const s=this.pageAuth.get(o);if(!s)throw new Error(`no view info in viewId: ${o}`);const n=s.get(t);n&&(n.render=e),t===this.control.viewContainerManager.getCurScenePath(o)&&this.pageAuthEffect(o),i||(this.isLocalRender=!0),i&&(this.isLocalRender=!1,(r=this.control.collector)==null||r.dispatchPageAuth({operation:xt.renderPage,viewId:o,scenePath:t,pageData:{render:e}},i))}isWriteable(){return this.isCurWritable}isRenderAble(o){var c,l;const{uid:t,viewId:e,filterLocalSelf:i=!0,scenePath:s}=o,n=this.renderUids.get(e);if(n){const{render:h,hide:u}=n;if(h===void 0&&u===void 0)return!0;if(L.isSet(h)){if(h.has(t)||i&&((c=this.control.collector)==null?void 0:c.uid)===t&&h.has("localSelf"))return!0}else if(h===!0&&(!u||L.isSet(u)&&!u.has(t)&&!(i&&u.has("localSelf")&&((l=this.control.collector)==null?void 0:l.uid)===t)))return!0;return!1}const r=this.pageAuth.get(e);if(r&&s){const h=r.get(s);if(h){const{render:u}=h;if(u)return!(u==="localSelf"&&!i)}}return!0}isClearAble(o){var c;const{uid:t,viewId:e,filterLocalSelf:i=!0,scenePath:s}=o,n=this.renderUids.get(e);if(n){const{clear:l}=n;return!!(l===void 0||l===!0||L.isSet(l)&&(l.has(t)||i&&((c=this.control.collector)==null?void 0:c.uid)===t&&l.has("localSelf")))}const r=this.pageAuth.get(e);if(r&&s){const l=r.get(s);if(l){const{render:h}=l;if(h)return!(h==="localSelf"&&!i)}}return!0}isFilterAble(o,t){var c,l,h,u;const{viewId:e,scenePath:i,elementId:s}=o,n=this.renderUids.get(e);if(n&&s){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(s);return f?!!(L.isSet(d)&&(d.has(f)||d.has("localSelf")&&((l=this.control.collector)==null?void 0:l.uid)===f)||d===!0&&(!p||L.isSet(p)&&!p.has(f)&&!(p.has("localSelf")&&((h=this.control.collector)==null?void 0:h.uid)===f))):!1}const r=this.pageAuth.get(e);if(r&&i&&s){const d=r.get(i);if(d){const{render:p,pages:f}=d;if(!p)return!0;const y=(u=this.control.collector)==null?void 0:u.uid,m=p==="localSelf"?y:p,S=m&&f.get(m)||void 0;if(S)switch(t){case b.RemoveNode:return!0;default:return S.has(s)}return!1}}return!0}isFilterCursor(o){if(this.isUsePageAuth(o)){const t=this.control.viewContainerManager.getCurScenePath(o),e=this.pageAuth.get(o);if(t&&e){const i=e.get(t);if(i){const{render:s}=i;return s!=="localSelf"}}}return!0}isUsePageAuth(o){var i;if(!this.pageAuth.has(o))return!1;const e=this.control.viewContainerManager.getCurScenePath(o);return e&&((i=this.pageAuth.get(o))==null?void 0:i.has(e))||!1}publishRender(o){var n;const{viewId:t,option:e,isSync:i=!0}=o,s={};if(e){const{render:r,hide:c,clear:l}=e;r&&(s.render=r===!0&&!0||new Set(r)),c&&(s.hide=c===!0&&!0||new Set(c)),l&&(s.clear=l===!0&&!0||new Set(l)),this.renderUids.set(t,s)}else this.renderUids.delete(t);i&&((n=this.control.collector)==null||n.dispatchRenderAuth({operation:Ut.setAuth,viewId:t,renderData:s},i)),this.renderEffect(t)}publishOneRender(o,t,e,i=!0){var r;const s=this.renderUids.get(o);let n;switch(e){case"show":s?(s.render||(s.render=new Set),L.isSet(s.render)&&s.render.add(t),L.isSet(s.hide)&&s.hide.delete(t)):this.renderUids.set(o,{render:new Set([t])}),n=Ut.setShow;break;case"hide":s?(s.hide||(s.hide=new Set),L.isSet(s.hide)&&s.hide.add(t),L.isSet(s.render)&&s.render.delete(t)):this.renderUids.set(o,{hide:new Set([t])}),n=Ut.setHide;break}s?this.renderUids.set(o,s):this.renderUids.delete(o),i&&n&&((r=this.control.collector)==null||r.dispatchRenderAuth({operation:n,viewId:o,uid:t},i)),this.renderEffect(o)}publishOneClear(o,t,e,i=!0){var n;const s=this.renderUids.get(o);e?s?(s.clear||(s.clear=new Set),L.isSet(s.clear)&&s.clear.add(t)):this.renderUids.set(o,{clear:new Set([t])}):s&&L.isSet(s.clear)&&s.clear.has(t)&&s.clear.delete(t),s?this.renderUids.set(o,s):this.renderUids.delete(o),i&&((n=this.control.collector)==null||n.dispatchRenderAuth({operation:Ut.setClear,viewId:o,uid:t,isClear:e},i)),this.renderEffect(o)}syncRenderUids(o,t,e,i){const s=t===!0?!0:t&&Object.keys(t)?new Set(Object.keys(t)):void 0,n=e===!0?!0:e&&Object.keys(e)?new Set(Object.keys(e)):void 0,r=i===!0?!0:i&&Object.keys(i)?new Set(Object.keys(i)):void 0;s||n||r?this.renderUids.set(o,{render:s,hide:n,clear:r}):this.renderUids.delete(o),this.renderEffect(o),this.publicMsgEmitter.emit("syncRenderUids",o,{render:s,hide:n,clear:r})}syncPageAuth(o,t,e=!1){let i=!1;if(!t)this.pageAuth.delete(o);else{const s=this.pageAuth.get(o)||new Map;for(const[n,r]of Object.entries(t)){const{render:c,pages:l}=r,h=s.get(n),u=this.isLocalRender?h==null?void 0:h.render:c;if(u){u!==(h==null?void 0:h.render)&&(i=!0);const d=new Map;for(const[f,y]of Object.entries(l))d.set(f,new Set(Object.keys(y)));const p={render:u,pages:d};d.size&&s.set(n,p)}}s.size&&(this.pageAuth.set(o,s),this.publicMsgEmitter.emit("syncPageAuth",o,s))}(e||i)&&this.pageAuthEffect(o)}destoryByViewId(o,t=!1){var e;this.renderUids.has(o)&&(this.renderUids.delete(o),t||(e=this.control.collector)==null||e.dispatchRenderAuth({operation:Ut.setAuth,viewId:o})),this.pageAuth.has(o)&&this.control.renderControl.delViewPage(o,!t)}renderEffect(o){var e;const t=(e=this.control.viewContainerManager.getView(o))==null?void 0:e.focusScenePath;t&&this.worker.clearViewScenePath(o,!0).then(()=>{var i;this.worker.pullServiceData(o,t,{isAsync:!0,useAnimation:!1}),this.worker.sendClearUids(o,(i=this.renderUids.get(o))==null?void 0:i.clear)})}pageAuthEffect(o){var e;const t=(e=this.control.viewContainerManager.getView(o))==null?void 0:e.focusScenePath;t&&this.worker.clearViewScenePath(o,!0).then(()=>{this.worker.pullServiceData(o,t,{isAsync:!0,useAnimation:!1}),this.worker.sendClearUids(o,!0)})}cloneElementIds(o,t,e,i){var r,c;const s=(r=this.control.collector)==null?void 0:r.getStorageData(o,t),n=new Set;if(s){for(const l of Object.keys(s))if(e.has(l)){const h=`${l}_${i}`;if(n.add(h),!Object.keys(s).includes(h)){const u=L.cloneDeep(s[l]);(c=this.control.collector)==null||c.updateValue(h,{type:b.FullWork,...u,workId:h},{isSync:!0,viewId:o,scenePath:t})}}}return n}delElementIds(o,t,e){var s,n;const i=(s=this.control.collector)==null?void 0:s.getStorageData(o,t);if(i)for(const r of Object.keys(i))e.has(r)&&Object.keys(i).includes(r)&&((n=this.control.collector)==null||n.updateValue(r,void 0,{isSync:!0,viewId:o,scenePath:t}))}}class Hg{constructor(o){M(this,"internalMsgEmitter");M(this,"control");M(this,"maps",new Map);M(this,"showId");M(this,"color");M(this,"timer");M(this,"updateMiniMapCamera",L.debounce(async o=>{const t=this.maps.get(o);if(t){const e=await this.getMiniMapCamera(o);if(e){const i=e.width/e.scale,s=e.height/e.scale,n=t.miniMapCamera.width/t.miniMapCamera.scale,r=t.miniMapCamera.height/t.miniMapCamera.scale;(i>=n||s>=r)&&(t.miniMapCamera=e);const c=t.miniMapCanvas.current;if(c){const l=c.getContext("2d");if(l){const h=this.control.viewContainerManager.getView(o);if(!(h!=null&&h.focusScenePath))return;const{miniMapCamera:u,contianer:d}=t,{width:p,height:f}=d.getBoundingClientRect(),y=Math.min(p/u.width,f/u.height);l.clearRect(0,0,c.width,c.height),c.width=u.width,c.height=u.height,c.style.width=`${u.width*y}px`,c.style.height=`${u.height*y}px`,await this.control.screenshotToCanvas(l,h.focusScenePath,u.width,u.height,u),this.listener.emitAsync([o,"viewCameraUpate"],1)}}}}},2e3,{maxWait:5e3}));var i;const{control:t,internalMsgEmitter:e}=o;this.control=t,this.internalMsgEmitter=e,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(o){this.color=o}async createMiniMap(o,t,e){const i=this.control.viewContainerManager.getView(o);if(!i)throw new Error("view not found");const s=i.cameraOpt;if(!s)throw new Error("view camera not found");const{width:n,height:r}=t.getBoundingClientRect();if(!n||!r)throw new Error("contianer width or height is 0");const c=g.createRef();this.maps.set(o,{contianer:t,miniMapCanvas:c,miniMapCamera:e,viewCamera:s}),this.showId=o,this.control.viewContainerManager.setActiveMiniMap(this.showId,!0);const l=Math.min(n/e.width,r/e.height),h=await new Promise(u=>{this.listener.once([o,"miniMapCreate"],()=>{const d=c.current;d&&(d.width=e.width,d.height=e.height,d.style.width=`${e.width*l}px`,d.style.height=`${e.height*l}px`),u(!0)}),this.timer=setTimeout(()=>{u(!1)},2e3)});return this.timer&&clearTimeout(this.timer),h}async getMiniMapCamera(o){const t=this.control.viewContainerManager.getView(o);if(!t)return;const{cameraOpt:e,focusScenePath:i}=t;if(!e||!i)return;const s={originX:e.centerX-e.width/e.scale/2,originY:e.centerY-e.height/e.scale/2,width:e.width/e.scale,height:e.height/e.scale};let n=await this.control.getBoundingRect(i)||s;n=Fo(n,s)||s;let r=n.width,c=n.height,l=1;const h=r>e.width&&Math.min(e.width/r,l)||l,u=c>e.height&&Math.min(e.height/c,l)||l;return h<=u?(r=h<1&&e.width||r,c=Math.floor(c*h)+1,l=h):h>u&&(c=u<1&&e.height||c,r=Math.floor(r*u)+1,l=u),{scale:l,centerX:n.originX+n.width/2,centerY:n.originY+n.height/2,width:r,height:c}}getMiniMapCanvas(o){const t=this.maps.get(o);return(t==null?void 0:t.miniMapCanvas.current)||null}updateViewCamera(o,t){const e=this.maps.get(o);e&&(e.viewCamera=t,this.listener.emitAsync([o,"viewCameraUpate"],1))}destroyMiniMap(o){const t=o||this.showId;t&&(this.maps.delete(t),this.control.viewContainerManager.setActiveMiniMap(t,!1))}}const ne=class ne{constructor(o){M(this,"version",ls);M(this,"plugin");M(this,"room");M(this,"play");M(this,"collector");M(this,"hasSwitchToSelectorEffect");M(this,"snapshootStateMap");M(this,"priority","cpu");M(this,"effectResolve");M(this,"hotkeyManager");M(this,"pluginOptions");M(this,"roomMember");M(this,"cursor");M(this,"textEditorManager");M(this,"worker");M(this,"renderControl");M(this,"miniMapManager");M(this,"onSceneChange",async(o,t)=>{var n;const e=this.viewContainerManager.getView(t);e!=null&&e.focusScenePath&&(n=this.collector)!=null&&n.hasSelector(t,e.focusScenePath)&&this.worker.blurSelector(t,e.focusScenePath),this.textEditorManager.checkEmptyTextBlur();const i=e==null?void 0:e.displayer;i&&(i.setActive(!1),await i.stopEventHandler());const s=o;s&&this.viewContainerManager.setViewScenePath(t,s),i==null||i.setActive(!0)});M(this,"onRoomMembersChange",o=>{this.roomMember.setRoomMembers(et.toJS(o))});M(this,"onMemberChange",Ee(o=>{if(!this.room||!this.worker||!o||!this.room.isWritable)return;const t=this.getToolsKey(o),e=this.getToolsOpt(t,o);this.worker.setCurrentToolsData(e),this.effectViewContainer(t),this.effectResolve&&this.effectResolve(!0)},100,{leading:!1}));M(this,"internalSceneChange",(o,t)=>{var i;this.miniMapManager.activeViewId===o&&this.miniMapManager.destroyMiniMap(o),(i=this.worker)==null||i.clearViewScenePath(o,!0).then(()=>{var s;(s=this.worker)==null||s.pullServiceData(o,t,{isAsync:!0,useAnimation:!1})})});M(this,"internalCameraChange",(o,t)=>{var e;(e=this.worker)==null||e.updateCamera(o,t),this.miniMapManager.updateViewCamera(o,t)});const{displayer:t,plugin:e,options:i}=o;this.plugin=e,this.room=et.isRoom(t)?t:void 0,this.play=et.isPlayer(t)?t:void 0,this.pluginOptions=i,this.roomMember=new Wf;const s={control:this,internalMsgEmitter:ne.InternalMsgEmitter,publicMsgEmitter:ne.PublicMsgEmitter};this.cursor=new Ff(s),this.textEditorManager=new Vf(s),this.worker=new ag(s),this.hotkeyManager=new Vg(s),this.renderControl=new Fg(s),this.miniMapManager=new Hg(s)}setPriority(o){var t;this.priority=o,this.hasOffscreenCanvas()&&((t=this.worker)==null||t.setPriority(o))}hasOffscreenCanvas(){return hs==="worker"}bindPlugin(o){var t,e;this.plugin=o,this.collector&&(this.collector.removeStorageStateListener(),this.collector.removeAuthStateListener()),this.collector=new xo(this,o,(e=(t=this.pluginOptions)==null?void 0:t.syncOpt)==null?void 0:e.interval),this.activePlugin()}destroy(){var o,t,e,i,s;this.roomMember.destroy(),(o=this.collector)==null||o.destroy(),(t=this.worker)==null||t.destroy(),(e=this.viewContainerManager)==null||e.destroy(),(i=this.cursor)==null||i.destroy(),(s=this.textEditorManager)==null||s.destory()}cleanCurrentScene(){const o=Date.now(),t=this.worker.getLocalWorkViewId()||this.viewContainerManager.focuedViewId;t&&(ne.InternalMsgEmitter.emit("addUndoTicker",o,t),this.worker.clearViewScenePath(t,!1,!0))}onWritableChange(o){var e,i;o?(i=this.worker)==null||i.abled():(e=this.worker)==null||e.unWritable(),this.renderControl.onWritableChange(o),this.viewContainerManager.getAllViews().forEach(s=>{s!=null&&s.displayer&&s.displayer.bindToolsClass()})}getToolsKey(o){var e;const t=o.currentApplianceName;switch(this.hasSwitchToSelectorEffect=!1,t){case st.text:return o.textCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),C.Text;case st.pencil:return o.useLaserPen?C.LaserPen:C.Pencil;case st.eraser:return C.Eraser;case st.pencilEraser:return((e=this.pluginOptions.pencilEraser)==null?void 0:e.useBitMap)===!1?C.PencilEraser:C.BitMapEraser;case st.selector:return C.Selector;case st.arrow:return o.arrowCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),C.Arrow;case st.straight:return o.straightCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),C.Straight;case st.ellipse:return o.ellipseCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),C.Ellipse;case st.rectangle:return o.rectangleCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),C.Rectangle;case st.shape:if(o.shapeCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),o.shapeType===Yt.Pentagram||o.shapeType===Yt.Star)return C.Star;if(o.shapeType===Yt.Polygon||o.shapeType===Yt.Triangle||o.shapeType===Yt.Rhombus)return C.Polygon;if(o.shapeType===Yt.SpeechBalloon)return C.SpeechBalloon;break}return C.Clicker}getToolsOpt(o,t){if(o===C.Clicker)return{toolsType:o,toolsOpt:{}};const e={strokeColor:We(t.strokeColor[0],t.strokeColor[1],t.strokeColor[2],t.strokeOpacity||1),thickness:t.strokeWidth,isOpacity:(t==null?void 0:t.strokeOpacity)&&t.strokeOpacity<1||(t==null?void 0:t.fillOpacity)&&t.fillOpacity<1||(t==null?void 0:t.textOpacity)&&t.textOpacity<1||(t==null?void 0:t.textBgOpacity)&&t.textBgOpacity<1||!1};switch(o){case C.Text:e.fontFamily=window.getComputedStyle(document.documentElement).getPropertyValue("font-family"),e.fontSize=(t==null?void 0:t.textSizeOverride)||(t==null?void 0:t.textSize)||Number(window.getComputedStyle(document.body).fontSize),e.textAlign=(t==null?void 0:t.textAlign)||"left",e.verticalAlign=(t==null?void 0:t.verticalAlign)||"middle",e.fontColor=(t==null?void 0:t.textColor)&&We(t.textColor[0],t.textColor[1],t.textColor[2],t.textOpacity||1)||e.strokeColor||"rgba(0,0,0,1)",e.fontBgColor=Array.isArray(t==null?void 0:t.textBgColor)&&We(t.textBgColor[0],t.textBgColor[1],t.textBgColor[2],t.textBgOpacity||1)||"transparent",e.bold=(t==null?void 0:t.bold)&&"bold"||void 0,e.italic=(t==null?void 0:t.italic)&&"italic"||void 0,e.underline=(t==null?void 0:t.underline)||void 0,e.lineThrough=(t==null?void 0:t.lineThrough)||void 0,e.text="",e.strokeColor=void 0;break;case C.Pencil:e.strokeType=(t==null?void 0:t.strokeType)||_.Normal;break;case C.PencilEraser:case C.BitMapEraser:case C.Eraser:e.thickness=Math.min(3,Math.max(1,Math.floor(t.pencilEraserSize||1)))-1;break;case C.LaserPen:e.duration=(t==null?void 0:t.duration)||1,t!=null&&t.strokeType&&(t==null?void 0:t.strokeType)===_.Stroke?e.strokeType=_.Normal:e.strokeType=(t==null?void 0:t.strokeType)||_.Normal;break;case C.Arrow:case C.Straight:t!=null&&t.strokeType&&(t==null?void 0:t.strokeType)===_.Stroke?e.strokeType=_.Normal:e.strokeType=(t==null?void 0:t.strokeType)||_.Normal;break;case C.Ellipse:case C.Rectangle:case C.Star:case C.Polygon:case C.SpeechBalloon:t!=null&&t.strokeType&&(t==null?void 0:t.strokeType)===_.Stroke?e.strokeType=_.Normal:e.strokeType=(t==null?void 0:t.strokeType)||_.Normal,o===C.Star&&(t.shapeType===Yt.Pentagram?(e.vertices=10,e.innerVerticeStep=2,e.innerRatio=.4):t!=null&&t.vertices&&(t!=null&&t.innerVerticeStep)&&(t!=null&&t.innerRatio)&&(e.vertices=t.vertices,e.innerVerticeStep=t.innerVerticeStep,e.innerRatio=t.innerRatio)),o===C.Polygon&&(t.shapeType===Yt.Triangle?e.vertices=3:t.shapeType===Yt.Rhombus?e.vertices=4:t.vertices&&(e.vertices=t.vertices)),e.fillColor=(t==null?void 0:t.fillColor)&&We(t.fillColor[0],t.fillColor[1],t.fillColor[2],t==null?void 0:t.fillOpacity)||"transparent",o===C.SpeechBalloon&&(e.placement=t.placement||"bottomLeft");break}return{toolsType:o,toolsOpt:e}}effectViewContainer(o){var t,e,i,s,n;switch(o){case C.Text:case C.Pencil:case C.LaserPen:case C.Arrow:case C.Straight:case C.Rectangle:case C.Ellipse:case C.Star:case C.Polygon:case C.SpeechBalloon:case C.Triangle:case C.Rhombus:case C.Eraser:case C.PencilEraser:case C.BitMapEraser:this.room.disableDeviceInputs=!0,(t=this.worker)==null||t.abled();break;case C.Selector:this.room.disableDeviceInputs=!1,(e=this.cursor)==null||e.unabled(),(i=this.worker)==null||i.abled();break;default:this.room.disableDeviceInputs=!1,(s=this.worker)==null||s.unWritable(),(n=this.cursor)==null||n.unabled();break}setTimeout(()=>{this.viewContainerManager.getAllViews().forEach(c=>{c!=null&&c.displayer&&c.displayer.bindToolsClass()})},0)}async getBoundingRect(o){var e,i,s,n,r;const t=await((e=this.worker)==null?void 0:e.getBoundingRect(o));if(t){const c=((s=(i=this.viewContainerManager.mainView)==null?void 0:i.viewData)==null?void 0:s.convertToPointInWorld({x:t.x,y:t.y}))||{x:t.x,y:t.y},l=((r=(n=this.viewContainerManager.mainView)==null?void 0:n.viewData)==null?void 0:r.camera.scale)||1;return{width:Math.floor(t.w/l)+1,height:Math.floor(t.h/l)+1,originX:c.x,originY:c.y}}}async screenshotToCanvas(o,t,e,i,s,n,r){const c=await this.worker.getSnapshot(t,e,i,s);c&&(o.drawImage(c,n||0,r||0),c.close())}async scenePreview(o,t){var n,r,c,l;const e=(n=this.collector)==null?void 0:n.getViewIdBySecenPath(o);if(!e)return;const i=this.viewContainerManager.getView(e);if(!i||!((r=i.cameraOpt)!=null&&r.width)||!((c=i.cameraOpt)!=null&&c.height))return;const s=await((l=this.worker)==null?void 0:l.getSnapshot(o));if(s&&this.worker){const h=document.createElement("canvas"),u=h.getContext("2d"),{width:d,height:p}=i.cameraOpt;h.width=d,h.height=p,u&&(u.drawImage(s,0,0),t.crossOrigin="anonymous",t.src=h.toDataURL(),t.onload=()=>{h.remove()},t.onerror=()=>{h.remove(),t.remove()}),s.close()}}switchToText(){var o;(o=this.room)==null||o.setMemberState({currentApplianceName:st.text})}switchToSelector(){var o;(o=this.room)==null||o.setMemberState({currentApplianceName:st.selector})}async runEffectWork(o){if(this.hasSwitchToSelectorEffect){const t=await new Promise(e=>{this.switchToSelector(),this.effectResolve=e});this.effectResolve=void 0,t&&o&&o()}}setSnapshootData(){var o;this.room&&(this.snapshootStateMap=new Map,this.snapshootStateMap.set("memberState",(o=this.room)==null?void 0:o.state.memberState))}getSnapshootData(o){var t;return(t=this.snapshootStateMap)==null?void 0:t.get(o)}clearSnapshootData(){var o;(o=this.snapshootStateMap)==null||o.clear(),this.snapshootStateMap=void 0}useBitMapEraser(o){var t;if(((t=this.pluginOptions.pencilEraser)==null?void 0:t.useBitMap)===void 0){this.pluginOptions.pencilEraser={useBitMap:o};return}this.pluginOptions.pencilEraser.useBitMap=o}consoleWorkerInfo(){var o;(o=this.worker)==null||o.consoleWorkerInfo()}filterRenderByUid(o,t,e=!0){var s;this.viewContainerManager.getView(o)&&((s=this.renderControl)==null||s.publishRender({viewId:o,option:t,isSync:e}))}cancelFilterRender(o,t=!0){var e;(e=this.renderControl)==null||e.publishRender({viewId:o,isSync:t})}async createMiniMap(o,t){const e=await this.miniMapManager.getMiniMapCamera(o);if(e&&await this.miniMapManager.createMiniMap(o,t,e)){const s=this.miniMapManager.getMiniMapCanvas(o);if(s){const n=s.getContext("2d");if(n){const r=this.viewContainerManager.getView(o);r!=null&&r.focusScenePath&&this.screenshotToCanvas(n,r.focusScenePath,e.width,e.height,e)}}}}async destroyMiniMap(o){this.miniMapManager.destroyMiniMap(o)}};M(ne,"InternalMsgEmitter",new vo),M(ne,"PublicMsgEmitter",new vo);let Nt=ne;const re=class re{constructor(o){M(this,"emitter",new vo);M(this,"undoStack");M(this,"redoStack");M(this,"worker");M(this,"control");M(this,"room");M(this,"isTicking");M(this,"undoTickerId");M(this,"viewId");M(this,"scenePath");M(this,"tickStartStorerCache");M(this,"excludeIds",new Set);M(this,"onChangeScene",L.debounce(()=>{const o=this.control.viewContainerManager.getCurScenePath(this.viewId);if(o){let t=this.undoStack.filter(i=>i.scenePath===o).length;const e=this.redoStack.filter(i=>i.scenePath===o).length;t===0&&e===0&&this.tickStartStorerCache&&this.scenePath===o&&(t=1),this.emitter.emit("onCanUndoStepsUpdate",t),this.emitter.emit("onCanRedoStepsUpdate",e)}},re.waitTime));const{control:t,internalMsgEmitter:e,viewId:i}=o;this.control=t,this.emitter=e,this.undoStack=[],this.redoStack=[],this.room=t.room,this.worker=t.worker,this.isTicking=!1,this.viewId=i}get collector(){return this.control.collector}addExcludeIds(o){if(this.isTicking)for(const t of o)this.excludeIds.add(t)}undoTickerStart(o,t){if(this.collector&&(this.undoTickerId!==o||this.scenePath!==t)){!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 e=this.collector.transformKey($);this.excludeIds.add(e),this.undoTickerId=o,this.scenePath=t;const i=this.collector.getStorageData(this.viewId,t)||{};this.tickStartStorerCache=new Map(Object.entries(L.cloneDeep(i)))}}undoTickerEndSync(o,t,e){var i,s;if(o===this.undoTickerId&&e===this.scenePath&&t===this.viewId&&this.tickStartStorerCache){const n=((i=this.collector)==null?void 0:i.storage[t])&&((s=this.collector)==null?void 0:s.storage[t][e])||{},r=this.diffFun(this.tickStartStorerCache,new Map(Object.entries(n)));r.size&&(this.undoStack.push({id:o,type:2,data:L.cloneDeep(r),scenePath:e}),this.undoStack.length>re.MaxStackLength&&this.undoStack.shift(),this.emitter.emit("onCanUndoStepsUpdate",this.undoStack.length)),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(o){this.undoTickerId&&this.tickStartStorerCache&&this.scenePath&&this.undoTickerEndSync(this.undoTickerId,this.viewId,this.scenePath);let t=this.undoStack.length-1;for(;t>=0;){if(this.undoStack[t].scenePath===o){const n=this.undoStack[t];n&&(this.redoStack.push(n),n.type===2&&n.data&&this.refreshPlugin(n)),this.undoStack.splice(t,1);break}t--}const e=this.undoStack.filter(s=>s.scenePath===o).length,i=this.redoStack.filter(s=>s.scenePath===o).length;return this.emitter.emit("onCanUndoStepsUpdate",e),this.emitter.emit("onCanRedoStepsUpdate",i),e}redo(o){let t=this.redoStack.length-1;for(;t>=0;){if(this.redoStack[t].scenePath===o){const n=this.redoStack[t];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(t,1);break}t--}const e=this.undoStack.filter(s=>s.scenePath===o).length,i=this.redoStack.filter(s=>s.scenePath===o).length;return this.emitter.emit("onCanUndoStepsUpdate",e),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 o=this.control.viewContainerManager.getCurScenePath(this.viewId);if(o){let t=this.undoStack.filter(i=>i.scenePath===o).length;const e=this.redoStack.filter(i=>i.scenePath===o).length;t===0&&e===0&&this.tickStartStorerCache&&this.scenePath===o&&(t=1),this.emitter.emit("onCanUndoStepsUpdate",t),this.emitter.emit("onCanRedoStepsUpdate",e)}}diffFun(o,t){const e=new Set,i=o.keys(),s=t.keys();for(const n of i){if(this.excludeIds.has(n))continue;const r=o.get(n),c=t.get(n);if(r&&c){if(L.isEqual(c,r))continue;e.add({dataType:3,key:n,data:[r,c]});continue}r&&e.add({dataType:2,key:n,data:r})}for(const n of s){if(this.excludeIds.has(n))continue;const r=t.get(n);r&&!o.has(n)&&e.add({dataType:1,key:n,data:r})}return e}isDrawEffectiveScene(o,t){const{key:e}=o;return!t.includes(e)}isDeleteEffectiveScene(o,t,e){var n;const{key:i}=o;if(!t.includes(i))return!1;const s=t.filter(r=>{var c,l;return((c=this.collector)==null?void 0:c.getLocalId(r))===$&&!((l=this.collector)!=null&&l.isOwn(r))}).map(r=>{var c;return(c=this.collector)==null?void 0:c.storage[this.viewId][e][r]});for(const r of s)if((n=r==null?void 0:r.selectIds)!=null&&n.includes(i))return!1;return!0}isOldEffectiveScene(o,t,e){var n;const{key:i}=o;if(!t.includes(i))return!1;const s=t.filter(r=>{var c,l;return((c=this.collector)==null?void 0:c.getLocalId(r))===$&&!((l=this.collector)!=null&&l.isOwn(r))}).map(r=>{var c;return(c=this.collector)==null?void 0:c.storage[this.viewId][e][r]});for(const r of s)if((n=r==null?void 0:r.selectIds)!=null&&n.includes(i))return!1;return!0}isNewEffectiveScene(o,t){const{key:e}=o;return!!t.includes(e)}refreshPlugin(o,t=!1){var n,r,c,l,h,u,d,p,f,y,m,S,w,v,T,N,I,x,z,A,E;let e;const{scenePath:i}=o,s=o.data;if(!(!s||!this.collector))for(const j of s.values()){const{dataType:O,data:P,key:Y}=j,ot=this.collector.getStorageData(this.viewId,i),tt=ot&&Object.keys(ot)||[];switch(O){case 1:if(e=t?this.isDrawEffectiveScene(j,tt):this.isDeleteEffectiveScene(j,tt,i),e)if(t&&!Array.isArray(P)){if((n=P.updateNodeOpt)!=null&&n.useAnimation&&(P.updateNodeOpt.useAnimation=!1),((r=this.collector)==null?void 0:r.getLocalId(Y))===$&&((c=this.collector)!=null&&c.isOwn(j.key))){const Q=P.selectIds;if(Q){const J=tt.filter(Z=>{var X,rt;return((X=this.collector)==null?void 0:X.getLocalId(Z))===$&&!((rt=this.collector)!=null&&rt.isOwn(Z))}).map(Z=>{var X;return(X=this.collector)==null?void 0:X.storage[this.viewId][i][Z]});let G=!1;for(const Z of J)for(let X=0;X<Q.length;X++)(l=Z==null?void 0:Z.selectIds)!=null&&l.includes(Q[X])&&(delete Q[X],G=!0);G&&(P.selectIds=Q.filter(Z=>!!Z))}}(h=this.collector)==null||h.updateValue(j.key,P,{isAfterUpdate:!0,viewId:this.viewId,scenePath:i,isSync:!0})}else!t&&!Array.isArray(j.data)&&((u=this.collector)==null||u.updateValue(j.key,void 0,{isAfterUpdate:!0,viewId:this.viewId,scenePath:i,isSync:!0}));break;case 2:if(e=t?this.isDeleteEffectiveScene(j,tt,i):this.isDrawEffectiveScene(j,tt),e){if(t&&!Array.isArray(P))(d=this.collector)==null||d.updateValue(Y,void 0,{isAfterUpdate:!0,viewId:this.viewId,scenePath:i,isSync:!0});else if(!t&&!Array.isArray(P)){if((p=P.updateNodeOpt)!=null&&p.useAnimation&&(P.updateNodeOpt.useAnimation=!1),((f=this.collector)==null?void 0:f.getLocalId(j.key))===$&&((y=this.collector)!=null&&y.isOwn(j.key))){const Q=P.selectIds;if(Q){const J=tt.filter(Z=>{var X,rt;return((X=this.collector)==null?void 0:X.getLocalId(Z))===$&&!((rt=this.collector)!=null&&rt.isOwn(Z))}).map(Z=>{var X;return(X=this.collector)==null?void 0:X.storage[this.viewId][i][Z]});let G=!1;for(const Z of J)for(let X=0;X<Q.length;X++)(m=Z==null?void 0:Z.selectIds)!=null&&m.includes(Q[X])&&(delete Q[X],G=!0);G&&(P.selectIds=Q.filter(Z=>!!Z))}}(S=this.collector)==null||S.updateValue(j.key,j.data,{isAfterUpdate:!0,viewId:this.viewId,scenePath:i,isSync:!0})}}break;case 3:if(e=t?this.isNewEffectiveScene(j,tt):this.isOldEffectiveScene(j,tt,i),e){if(t&&Array.isArray(P)&&P.length===2){const Q=P[1];if((w=Q.updateNodeOpt)!=null&&w.useAnimation&&(Q.updateNodeOpt.useAnimation=!1),((v=this.collector)==null?void 0:v.getLocalId(j.key))===$&&((T=this.collector)!=null&&T.isOwn(j.key))){const J=Q.selectIds;if(J){const G=tt.filter(X=>{var rt,wt;return((rt=this.collector)==null?void 0:rt.getLocalId(X))===$&&!((wt=this.collector)!=null&&wt.isOwn(X))}).map(X=>{var rt;return(rt=this.collector)==null?void 0:rt.storage[this.viewId][i][X]});let Z=!1;for(const X of G)for(let rt=0;rt<J.length;rt++)X!=null&&X.selectIds&&((N=X.selectIds)!=null&&N.includes(J[rt]))&&(delete J[rt],Z=!0);Z&&(Q.selectIds=J.filter(X=>!!X))}}(I=this.collector)==null||I.updateValue(Y,Q,{isAfterUpdate:!0,viewId:this.viewId,scenePath:i,isSync:!0})}else if(!t&&Array.isArray(P)&&P.length===2){const Q=P[0];if((x=Q.updateNodeOpt)!=null&&x.useAnimation&&(Q.updateNodeOpt.useAnimation=!1),((z=this.collector)==null?void 0:z.getLocalId(j.key))===$&&((A=this.collector)!=null&&A.isOwn(j.key))){const J=Q.selectIds;if(J){const G=tt.filter(X=>{var rt,wt;return((rt=this.collector)==null?void 0:rt.getLocalId(X))===$&&!((wt=this.collector)!=null&&wt.isOwn(X))}).map(X=>{var rt;return(rt=this.collector)==null?void 0:rt.storage[this.viewId][i][X]});let Z=!1;for(const X of G)for(let rt=0;rt<J.length;rt++)X!=null&&X.selectIds&&X.selectIds.includes(J[rt])&&(delete J[rt],Z=!0);Z&&(Q.selectIds=J.filter(X=>!!X))}}(E=this.collector)==null||E.updateValue(j.key,Q,{isAfterUpdate:!0,viewId:this.viewId,scenePath:i,isSync:!0})}}break}}}};M(re,"sdkCallBack"),M(re,"MaxStackLength",20),M(re,"waitTime",100);let to=re;function $g(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 me(a){return $g(a)&&(a.touches&&a.touches.length===1||a.changedTouches&&a.changedTouches.length===1)}function zs(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 we{constructor(o){M(this,"internalMsgEmitter");M(this,"control");M(this,"mainView");M(this,"appViews",new Map);const{control:t,internalMsgEmitter:e}=o;this.control=t,this.internalMsgEmitter=e,this.internalMsgEmitter.on("addUndoTicker",this.undoTickerStart.bind(this)),this.internalMsgEmitter.on("excludeIds",this.addExcludeIds.bind(this))}undoTickerStart(o,t){const e=this.getView(t);e&&e.displayer&&e.focusScenePath&&e.displayer.commiter.undoTickerStart(o,e.focusScenePath)}addExcludeIds(o,t){const e=this.getView(t);e&&e.displayer&&e.focusScenePath&&e.displayer.commiter.addExcludeIds(o)}undo(){const o=this.focuedView;let t=0;if(o){const e=o.focusScenePath;t=o.displayer.commiter.undo(e)||0}return t}redo(){const o=this.focuedView;let t=0;if(o){const e=o.focusScenePath;t=o.displayer.commiter.redo(e)||0}return t}validator(o,t,e){var n;const i=L.clone(o[t]),s=L.clone(e);t==="focusScenePath"&&e&&!L.isEqual(i,s)&&(this.control.internalSceneChange(o.id,s),(n=this.focuedView)==null||n.displayer.commiter.onChangeScene()),t==="cameraOpt"&&!L.isEqual(i,s)&&this.control.internalCameraChange(o.id,s)}destroyAppView(o,t=!1){const e=this.appViews.get(o);e&&(this.control.textEditorManager.clear(o,t),e.displayer.destroy(),this.appViews.delete(o))}createMianView(o){this.mainView=new Proxy(o,{set:(t,e,i)=>(this.control.worker.isActive&&this.validator(t,e,i),t[e]=i,!0)})}createAppView(o){const t=o.id,e=new Proxy(o,{set:(i,s,n)=>(this.control.worker.isActive&&this.validator(i,s,n),i[s]=n,!0)});this.appViews.set(t,e)}isAppView(o){return o!==It&&this.appViews.has(o)}getView(o){var t;return o===It?this.mainView:(t=this.appViews)==null?void 0:t.get(o)}getCurScenePath(o){const t=this.getView(o);if(t)return t.focusScenePath}getAllViews(){return[this.mainView,...this.appViews.values()]}setViewScenePath(o,t){var e;if(o===It&&this.mainView)this.mainView.focusScenePath=t;else{const i=o&&((e=this.appViews)==null?void 0:e.get(o))||void 0;i&&(i.focusScenePath=t)}}setViewData(o,t){var e;if(o===It&&this.mainView)this.mainView.viewData=t;else{const i=o&&((e=this.appViews)==null?void 0:e.get(o))||void 0;i&&(i.viewData=t)}}setFocuedViewId(o){var t;this.focuedViewId=o,o===It?this.focuedView=this.mainView:this.focuedView=o&&((t=this.appViews)==null?void 0:t.get(o))||void 0,this.control.cursor.onFocusViewChange(),this.focuedView&&this.focuedView.displayer.commiter.onFocusView()}setViewFocusScenePath(o,t){var i;let e;o===It?e=this.mainView:e=(i=this.appViews)==null?void 0:i.get(o),e&&(e.focusScenePath=t)}destroy(){var o;this.internalMsgEmitter.removeAllListeners("addUndoTicker"),this.internalMsgEmitter.removeAllListeners("excludeIds"),(o=this.mainView)==null||o.displayer.destroy(),this.appViews.forEach(t=>{this.destroyAppView(t.id,!0),this.control.worker.destroyViewWorker(t.id)})}setFocuedViewCameraOpt(o){if(this.focuedView){const t=this.focuedView.cameraOpt;L.isEqual(t,o)||(this.focuedView.cameraOpt=o)}}transformToOriginPoint(o,t){const e=this.getView(t);if(e!=null&&e.viewData){const i=e.viewData.convertToPointOnScreen(o[0],o[1]);return[i.x,i.y]}return o}transformToScenePoint(o,t){const e=this.getView(t);if(e!=null&&e.viewData){const i=e.viewData.convertToPointInWorld({x:o[0],y:o[1]});return[i.x,i.y]}return o}render(o){var t,e,i,s,n,r,c,l,h,u,d,p,f,y,m,S,w;for(const v of o){const{rect:T,imageBitmap:N,isClear:I,isUnClose:x,drawCanvas:z,clearCanvas:A,viewId:E}=v,j=(t=this.getView(E))==null?void 0:t.displayer;if(j&&T){const{dpr:O,canvasBgRef:P,canvasFloatRef:Y,canvasServiceFloatRef:ot,canvasTopRef:tt}=j,Q=Math.floor(T.w*O),J=Math.floor(T.h*O),G=T.x*O,Z=T.y*O;if(I){switch(A){case $t.TopFloat:(i=(e=tt.current)==null?void 0:e.getContext("2d"))==null||i.clearRect(G,Z,Q,J);break;case $t.Float:(n=(s=Y.current)==null?void 0:s.getContext("2d"))==null||n.clearRect(G,Z,Q,J);break;case $t.ServiceFloat:(c=(r=ot.current)==null?void 0:r.getContext("2d"))==null||c.clearRect(G,Z,Q,J);break;case $t.Bg:(h=(l=P.current)==null?void 0:l.getContext("2d"))==null||h.clearRect(G,Z,Q,J);break}continue}if(z&&N)switch(z){case $t.TopFloat:(d=(u=tt.current)==null?void 0:u.getContext("2d"))==null||d.drawImage(N,0,0,Q,J,G,Z,Q,J);break;case $t.Float:{(f=(p=Y.current)==null?void 0:p.getContext("2d"))==null||f.drawImage(N,0,0,Q,J,G,Z,Q,J);break}case $t.ServiceFloat:{(m=(y=ot.current)==null?void 0:y.getContext("2d"))==null||m.drawImage(N,0,0,Q,J,G,Z,Q,J);break}case $t.Bg:{(w=(S=P.current)==null?void 0:S.getContext("2d"))==null||w.drawImage(N,0,0,Q,J,G,Z,Q,J);break}}if(x)continue;N==null||N.close()}}}showFloatBar(o,t,e){const i=this.getView(o),s=i==null?void 0:i.displayer.vDom;s&&s.showFloatBar(t,e)}setActiveTextEditor(o,t){const e=this.getView(o),i=e==null?void 0:e.displayer.vDom;i&&i.setActiveTextEditor(t)}setActiveMiniMap(o,t){const e=this.getView(o),i=e==null?void 0:e.displayer.vDom;i&&i.setActiveMiniMap(t&&o||void 0)}}M(we,"defaultCameraOpt",{centerX:0,centerY:0,scale:1}),M(we,"defaultScreenCanvasOpt",{autoRender:!1,contextType:"webgl2"}),M(we,"defaultLayerOpt",{offscreen:!0,handleEvent:!1,depth:!1});class Qg{constructor(o,t,e){M(this,"viewId");M(this,"control");M(this,"internalMsgEmitter");M(this,"commiter");M(this,"cachePoint");M(this,"cacheCursorPoint");M(this,"active",!0);M(this,"mousedown",o=>{if(this.active&&o.button===0&&this.viewId){this.control.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const t=this.getPoint(o);this.cachePoint=t,t&&this.control.worker.originalEventLintener(D.Start,t,this.viewId)}});M(this,"mousemove",o=>{if(this.active&&this.viewId){const t=this.getPoint(o);this.cachePoint=t,t&&this.control.worker.originalEventLintener(D.Doing,t,this.viewId)}});M(this,"mouseup",o=>{if(this.active&&o.button===0&&this.viewId){const t=this.getPoint(o)||this.cachePoint;t&&this.control.worker.originalEventLintener(D.Done,t,this.viewId),this.cachePoint=void 0}});M(this,"touchstart",o=>{var t;if(this.active){if(!me(o)){this.control.worker.unWritable(),this.viewId&&this.control.worker.removeDrawingWork(this.viewId);return}if(this.viewId){if(!this.control.worker.isAbled()){const i=(t=this.control.worker.getCurrentToolsData())==null?void 0:t.toolsType;i&&this.control.effectViewContainer(i)}this.control.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const e=this.getPoint(o);this.cachePoint=e,e&&this.control.worker.originalEventLintener(D.Start,e,this.viewId)}}});M(this,"touchmove",o=>{if(this.active){if(!me(o)){this.control.worker.unWritable(),this.control.worker.removeDrawingWork(this.viewId);return}if(this.viewId){const t=this.getPoint(o);this.cachePoint=t,t&&this.control.worker.originalEventLintener(D.Doing,t,this.viewId)}}});M(this,"touchend",o=>{if(this.active){if(!me(o)||!this.control.worker.isAbled()){this.control.worker.unWritable(),this.control.worker.removeDrawingWork(this.viewId);return}if(this.viewId){const t=this.getPoint(o)||this.cachePoint;t&&this.control.worker.originalEventLintener(D.Done,t,this.viewId),this.cachePoint=void 0}}});M(this,"cursorMouseMove",L.throttle(o=>{const t=this.getPoint(o);this.cacheCursorPoint&&L.isEqual(t,this.cacheCursorPoint)||!this.viewId||(this.cacheCursorPoint=t,t&&this.control.worker.sendCursorEvent(t,this.viewId))},30,{leading:!1}));M(this,"cursorMouseLeave",L.throttle(()=>{this.viewId&&(this.cacheCursorPoint=[void 0,void 0],this.control.worker.sendCursorEvent(this.cacheCursorPoint,this.viewId))},30,{leading:!1}));M(this,"keydown",o=>{this.control.hotkeyManager.colloctHotkey(o)});this.viewId=o,this.control=t,this.internalMsgEmitter=e;const i={control:this.control,internalMsgEmitter:this.internalMsgEmitter,viewId:this.viewId};this.commiter=new to(i)}bindToolsClass(){var t,e;const o=(e=(t=this.control.worker)==null?void 0:t.currentToolsData)==null?void 0:e.toolsType;switch(o){case C.Text:case C.Pencil:case C.LaserPen:case C.Arrow:case C.Straight:case C.Rectangle:case C.Ellipse:case C.Star:case C.Polygon:case C.SpeechBalloon:case C.Eraser:case C.PencilEraser:case C.BitMapEraser:this.eventTragetElement&&(this.eventTragetElement.className=`netless-whiteboard ${o===C.Text?"cursor-text":o===C.Eraser||o===C.PencilEraser||o===C.BitMapEraser?"cursor-eraser":o===C.Pencil||o===C.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(o){this.viewId=o}destroy(){this.eventTragetElement&&this.removeDisplayerEvent(this.eventTragetElement),this.vDom=void 0,this.control.cursor.clearViewCursor(this.viewId),this.internalMsgEmitter.removeAllListeners([q.Cursor,this.viewId])}getPoint(o){const t=zs(o);if(t&&L.isNumber(t.x)&&L.isNumber(t.y))return[t.x-this.containerOffset.x,t.y-this.containerOffset.y]}setActive(o){this.active=o}async stopEventHandler(){this.cachePoint&&(await this.control.worker.originalEventLintener(D.Done,this.cachePoint,this.viewId),this.cachePoint=void 0)}getTranslate(o){const e=(o.style.WebkitTransform||getComputedStyle(o,"").getPropertyValue("-webkit-transform")||o.style.transform||getComputedStyle(o,"").getPropertyValue("transform")).match(/-?[0-9]+\.?[0-9]*/g),i=e&&parseInt(e[0])||0,s=e&&parseInt(e[1])||0;return[i,s]}getContainerOffset(o,t){var s;const e=this.getTranslate(o);let i={x:t.x+o.offsetLeft+e[0],y:t.y+o.offsetTop+e[1]};return(s=o.offsetParent)!=null&&s.nodeName&&o.offsetParent.nodeName!=="BODY"&&(i=this.getContainerOffset(o.offsetParent,i)),i}bindDisplayerEvent(o){o.addEventListener("mousedown",this.mousedown,!1),o.addEventListener("touchstart",this.touchstart,{capture:!0,passive:!1}),window.addEventListener("mouseleave",this.mouseup,!1),window.addEventListener("mousemove",this.mousemove,{capture:!0,passive:!1}),window.addEventListener("mouseup",this.mouseup,!1),window.addEventListener("touchmove",this.touchmove,{capture:!0,passive:!1}),window.addEventListener("touchend",this.touchend,{capture:!0,passive:!1}),o.addEventListener("mousemove",this.cursorMouseMove,!1),o.addEventListener("mouseleave",this.cursorMouseLeave,!1),o.addEventListener("keydown",this.keydown,!0)}removeDisplayerEvent(o){o.removeEventListener("mousedown",this.mousedown),o.removeEventListener("touchstart",this.touchstart),window.removeEventListener("mouseleave",this.mouseup),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend),o.removeEventListener("mousemove",this.cursorMouseMove),o.removeEventListener("mouseleave",this.cursorMouseLeave),o.removeEventListener("keydown",this.keydown)}}class bs{constructor(o,t){M(this,"viewId",It);M(this,"control");M(this,"internalMsgEmitter");M(this,"commiter");M(this,"cachePoint");M(this,"cacheCursorPoint");M(this,"active",!0);M(this,"mousedown",o=>{if(this.active&&o.button===0){this.control.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const t=this.getPoint(o);this.cachePoint=t,t&&this.control.worker.originalEventLintener(D.Start,t,this.viewId)}});M(this,"mousemove",o=>{if(!this.active)return;const t=this.getPoint(o);this.cachePoint=t,t&&this.control.worker.originalEventLintener(D.Doing,t,this.viewId)});M(this,"mouseup",o=>{if(this.active&&o.button===0){const t=this.getPoint(o)||this.cachePoint;t&&this.control.worker.originalEventLintener(D.Done,t,this.viewId),this.cachePoint=void 0}});M(this,"touchstart",o=>{var e;if(!this.active)return;if(!me(o)){this.control.worker.unWritable(),this.viewId&&this.control.worker.removeDrawingWork(this.viewId);return}if(!this.control.worker.isAbled()){const i=(e=this.control.worker.getCurrentToolsData())==null?void 0:e.toolsType;i&&this.control.effectViewContainer(i)}this.control.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const t=this.getPoint(o);this.cachePoint=t,t&&this.control.worker.originalEventLintener(D.Start,t,this.viewId)});M(this,"touchmove",o=>{if(!this.active)return;if(!me(o)){this.control.worker.unWritable(),this.viewId&&this.control.worker.removeDrawingWork(this.viewId);return}const t=this.getPoint(o);this.cachePoint=t,t&&this.control.worker.originalEventLintener(D.Doing,t,this.viewId)});M(this,"touchend",o=>{if(!this.active)return;if(!me(o)||!this.control.worker.isAbled()){this.control.worker.removeDrawingWork(this.viewId);return}const t=this.getPoint(o)||this.cachePoint;t&&this.control.worker.originalEventLintener(D.Done,t,this.viewId),this.cachePoint=void 0});M(this,"cursorMouseMove",L.throttle(o=>{const t=this.getPoint(o);this.cacheCursorPoint&&L.isEqual(t,this.cacheCursorPoint)||(this.cacheCursorPoint=t,t&&this.control.worker.sendCursorEvent(t,this.viewId))},30,{leading:!1}));M(this,"cursorMouseLeave",L.throttle(()=>{this.cacheCursorPoint=[void 0,void 0],this.control.worker.sendCursorEvent(this.cacheCursorPoint,this.viewId)},30,{leading:!1}));M(this,"keydown",o=>{this.control.hotkeyManager.colloctHotkey(o)});this.control=o,this.internalMsgEmitter=t;const e={control:this.control,internalMsgEmitter:this.internalMsgEmitter,viewId:this.viewId};this.commiter=new to(e)}bindToolsClass(){var e,i;const o=(i=(e=this.control.worker)==null?void 0:e.currentToolsData)==null?void 0:i.toolsType,t=this.control.renderControl.isWriteable();switch(o){case C.Text:case C.Pencil:case C.LaserPen:case C.Arrow:case C.Straight:case C.Rectangle:case C.Ellipse:case C.Star:case C.Polygon:case C.SpeechBalloon:case C.Eraser:case C.PencilEraser:case C.BitMapEraser:this.eventTragetElement&&(this.eventTragetElement.className=t?`netless-whiteboard ${o===C.Text?"cursor-text":o===C.Eraser||o===C.PencilEraser||o===C.BitMapEraser?"cursor-eraser":o===C.Pencil||o===C.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}))}destroy(){this.eventTragetElement&&this.removeDisplayerEvent(this.eventTragetElement),this.vDom=void 0,this.control.cursor.destroy(),this.internalMsgEmitter.removeAllListeners([q.Cursor,this.viewId])}getPoint(o){const t=zs(o);if(t&&L.isNumber(t.x)&&L.isNumber(t.y))return[t.x-this.containerOffset.x,t.y-this.containerOffset.y]}setActive(o){this.active=o}async stopEventHandler(){this.cachePoint&&(await this.control.worker.originalEventLintener(D.Done,this.cachePoint,this.viewId),this.cachePoint=void 0)}getTranslate(o){const e=(o.style.WebkitTransform||getComputedStyle(o,"").getPropertyValue("-webkit-transform")||o.style.transform||getComputedStyle(o,"").getPropertyValue("transform")).match(/-?[0-9]+\.?[0-9]*/g),i=e&&parseInt(e[0])||0,s=e&&parseInt(e[1])||0;return[i,s]}getContainerOffset(o,t){var s;const e=this.getTranslate(o);let i={x:t.x+o.offsetLeft+e[0],y:t.y+o.offsetTop+e[1]};return(s=o.offsetParent)!=null&&s.nodeName&&o.offsetParent.nodeName!=="BODY"&&(i=this.getContainerOffset(o.offsetParent,i)),i}bindDisplayerEvent(o){o.addEventListener("mousedown",this.mousedown,!1),window.addEventListener("mouseleave",this.mouseup,!1),window.addEventListener("mousemove",this.mousemove,{capture:!1,passive:!1}),window.addEventListener("mouseup",this.mouseup,!1),o.addEventListener("touchstart",this.touchstart,{capture:!0,passive:!1}),window.addEventListener("touchmove",this.touchmove,{capture:!0,passive:!1}),window.addEventListener("touchend",this.touchend,{capture:!0,passive:!1}),o.addEventListener("mousemove",this.cursorMouseMove,!0),o.addEventListener("mouseleave",this.cursorMouseLeave,!0),o.addEventListener("keydown",this.keydown,!0)}removeDisplayerEvent(o){o.removeEventListener("mousedown",this.mousedown),o.removeEventListener("touchstart",this.touchstart),window.removeEventListener("mouseleave",this.mouseup),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend),o.removeEventListener("mousemove",this.cursorMouseMove),o.removeEventListener("mouseleave",this.cursorMouseLeave),o.removeEventListener("keydown",this.keydown)}}const Gg="index-module__Container__nLsM3",Zg="index-module__CanvasBox__j2Xe-",qg="index-module__FloatCanvas__d1YR7",Jg="index-module__TopFloatCanvas__7IaCw",Xg="index-module__CanvasBoxSub__hcMeK",Kg="index-module__SnapshotBox__--eeE",_g="index-module__FloatBar__cm-EL",tM="index-module__RotateBtn__HSSkf",eM="index-module__ResizeBtn__yjvda",oM="index-module__CursorBox__2UHvI",iM="index-module__TextEditorContainer__Qm8KC",sM="index-module__ResizeTowBox__HOllX",nM="index-module__FloatBarBtn__FJrOG",kt={Container:Gg,CanvasBox:Zg,FloatCanvas:qg,TopFloatCanvas:Jg,CanvasBoxSub:Xg,SnapshotBox:Kg,FloatBar:_g,RotateBtn:tM,ResizeBtn:eM,CursorBox:oM,TextEditorContainer:iM,ResizeTowBox:sM,FloatBarBtn:nM},rM={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,PHN2Zy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gMGg0YTMgMyAwIDAgMSAwIDZoLTQgMG0wIDFWMiIgc3Ryb2tlPSIjNDQ0RTYwIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=","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+PHBhdGggZD0iTTQgOGg4bS0xLTNhMyAzIDAgMCAwLTMtM2gtLjkzOEEyLjY0IDIuNjQgMCAwIDAgNC41IDRhMi41NyAyLjU3IDAgMCAwIDEuMzQ0IDIuOTIybDQuMzEyIDIuMTU2QTIuNTcgMi41NyAwIDAgMSAxMS41IDEyYTIuNjQgMi42NCAwIDAgMS0yLjU2MiAySDdhMyAzIDAgMCAxLTMtM2gwIiBzdHJva2U9IiMzM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zMzIDY4Mi42NjY2Njd2LTIzNC42NjY2NjdoLTY0VjY4Mi42NjY2NjdoNjR6IG0tNTQuNjEzMzMzLTIxMi4wNTMzMzRsODUuMzMzMzMzIDg1LjMzMzMzNCA0NS4yMjY2NjctNDUuMjI2NjY3LTg1LjMzMzMzMy04NS4zMzMzMzMtNDUuMjI2NjY3IDQ1LjIyNjY2NnogbTAtNDUuMjI2NjY2bC04NS4zMzMzMzMgODUuMzMzMzMzIDQ1LjIyNjY2NiA0NS4yMjY2NjcgODUuMzMzMzM0LTg1LjMzMzMzNC00NS4yMjY2NjctNDUuMjI2NjY2eiIgIGZpbGw9IiM0NDRFNjAiPjwvcGF0aD48L3N2Zz4="};function St(a){return rM[a]}const aM=a=>{const{workIds:o,mananger:t}=a;return g.createElement("div",{className:"button normal-button",style:{touchAction:"none"},onClick:e=>{e.cancelable&&e.preventDefault(),e.stopPropagation(),K.emitMethod(q.MainEngine,R.DeleteNode,{workIds:o||[$],viewId:t.viewId})},onTouchEnd:e=>{e.cancelable&&e.preventDefault(),e.stopPropagation(),K.emitMethod(q.MainEngine,R.DeleteNode,{workIds:o||[$],viewId:t.viewId})}},g.createElement("img",{alt:"icon",src:St("delete")}))},cM=a=>{const{workIds:o,viewId:t}=a;return g.createElement("div",{className:"button normal-button",onClick:e=>{e.cancelable&&e.preventDefault(),e.stopPropagation(),K.emitMethod(q.MainEngine,R.CopyNode,{workIds:o||[$],viewId:t})},onTouchEnd:e=>{e.stopPropagation(),K.emitMethod(q.MainEngine,R.CopyNode,{workIds:o||[$],viewId:t})}},g.createElement("img",{alt:"icon",src:St("duplicate")}))},Di=a=>{const{icon:o,onClickHandler:t,onTouchEndHandler:e}=a;return g.createElement("div",{className:"button normal-button",onClick:t,onTouchEnd:e},g.createElement("img",{src:St(o)}))},lM=a=>{const{open:o,setOpen:t,floatBarRef:e}=a,{floatBarData:i,mananger:s}=g.useContext(mt),[n,r]=g.useState([]),c=g.useMemo(()=>{if(e!=null&&e.current&&L.isNumber(i==null?void 0:i.y)&&(s!=null&&s.height)){if(e.current.offsetTop&&e.current.offsetTop+i.y>180){const d={};return d.top="inherit",d.bottom=50,d}else if(!e.current.offsetTop&&(s==null?void 0:s.height)-e.current.offsetTop-i.y<120){const d={};return d.top="inherit",d.bottom=50,d}}},[e==null?void 0:e.current,i,s]),l=g.useMemo(()=>o?g.createElement("div",{className:"image-layer-menu",style:c},g.createElement(Di,{icon:"to-top",onClickHandler:d=>{d.cancelable&&d.preventDefault(),d.stopPropagation(),K.emitMethod(q.MainEngine,R.ZIndexNode,{workIds:[$],layer:ae.Top,viewId:s==null?void 0:s.viewId})},onTouchEndHandler:d=>{d.stopPropagation(),K.emitMethod(q.MainEngine,R.ZIndexNode,{workIds:[$],layer:ae.Top,viewId:s==null?void 0:s.viewId})}}),g.createElement(Di,{icon:"to-bottom",onClickHandler:d=>{d.cancelable&&d.preventDefault(),d.stopPropagation(),K.emitMethod(q.MainEngine,R.ZIndexNode,{workIds:[$],layer:ae.Bottom,viewId:s==null?void 0:s.viewId})},onTouchEndHandler:d=>{d.stopPropagation(),K.emitMethod(q.MainEngine,R.ZIndexNode,{workIds:[$],layer:ae.Bottom,viewId:s==null?void 0:s.viewId})}})):null,[o,c]),h=d=>{d.cancelable&&d.preventDefault(),d.stopPropagation(),d.nativeEvent.stopImmediatePropagation(),t(!o)},u=d=>{d.stopPropagation(),d.nativeEvent.stopImmediatePropagation(),t(!o)};return g.useEffect(()=>{L.isEqual(i==null?void 0:i.selectIds,n)||i!=null&&i.selectIds&&!L.isEqual(i==null?void 0:i.selectIds,n)&&(r(i==null?void 0:i.selectIds),t(!1))},[o,i,n,t]),g.createElement("div",{className:`button normal-button ${o&&"active"}`,onClick:h,onTouchEnd:u},l,g.createElement("img",{alt:"icon",src:St(o?"layer-pressed":"layer")}))},hM=()=>g.createElement("svg",{style:{marginLeft:"2px"},viewBox:"0 0 1025 1024",width:"14",height:"14"},g.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"})),Ps=a=>{const{activeColor:o,onClickHandler:t,onTouchEndHandler:e}=a;return g.createElement("div",{className:`font-color-button ${o==="transparent"?"active":""}`,onClick:t,onTouchEnd:e},g.createElement("div",{className:"circle none"}))},po=a=>{const{color:o,activeColor:t,onClickHandler:e,onTouchEndHandler:i}=a;return g.createElement("div",{className:`font-color-button ${o===t?"active":""}`,onClick:e,onTouchEnd:i},g.createElement("div",{className:"circle",style:{backgroundColor:Mt(o,1)}}))},fo=a=>{const{opacity:o,activeColor:t,setCurOpacity:e}=a,[i,s]=g.useState({x:108,y:0});if(g.useEffect(()=>{s({x:o*100+8,y:0})},[]),!t)return null;const n=L.throttle((l,h)=>{l.cancelable&&l.preventDefault(),l.stopPropagation(),h.x!==(i==null?void 0:i.x)&&s({x:h.x,y:0});const u=Math.min(Math.max(h.x-8,0),100)/100;o!==u&&e(u,t,D.Doing)},100,{leading:!1}),r=l=>{l.cancelable&&l.preventDefault(),l.stopPropagation(),e(o,t,D.Start)},c=L.throttle((l,h)=>{l.cancelable&&l.preventDefault(),l.stopPropagation(),h.x!==(i==null?void 0:i.x)&&s({x:h.x,y:0});const u=Math.min(Math.max(h.x-8,0),100)/100;e(u,t,D.Done)},100,{leading:!1});return g.createElement("div",{className:"font-color-opacity",style:{marginLeft:"10px"},onClick:l=>{const h=l.nativeEvent.offsetX,u=Math.min(Math.max(h-12,0),100)/100;s({x:u*100+8,y:0}),e(u,t,D.Done)}},g.createElement("div",{className:"range-color",style:{background:`linear-gradient(to right, ${Mt(t,0)}, ${Mt(t,1)})`}}),g.createElement("div",{className:"range-opacity"},g.createElement(ve,{bounds:"parent",axis:"x",position:i,onDrag:n,onStart:r,onStop:c},g.createElement("div",{className:"circle",style:{backgroundColor:Mt(t,o)},onClick:l=>{l.cancelable&&l.preventDefault(),l.stopPropagation()}}))))},uM=a=>{const{min:o,max:t,activeNumber:e,setActiveNumber:i,color:s}=a,[n,r]=g.useState({x:108,y:0});if(g.useEffect(()=>{const u=Math.ceil((e-o)/(t-o)*100)+8;r({x:u,y:0})},[]),!e)return null;const c=L.throttle((u,d)=>{u.cancelable&&u.preventDefault(),u.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*(t-o)+o);e!==p&&i(p,D.Doing)},100,{leading:!1}),l=u=>{u.cancelable&&u.preventDefault(),u.stopPropagation(),i(e,D.Start)},h=L.throttle((u,d)=>{u.cancelable&&u.preventDefault(),u.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*(t-o)+o);i(p,D.Done)},100,{leading:!1});return g.createElement("div",{className:"font-color-opacity",style:{marginLeft:"10px"},onClick:u=>{const d=u.nativeEvent.offsetX,p=Math.ceil(Math.max(d-12,0)/100*(t-o)+o),f=Math.ceil((p-o)/(t-o)*100)+8;r({x:f,y:0}),i(p,D.Done)}},g.createElement("div",{className:"range-color",style:{backgroundColor:s}}),g.createElement("div",{className:"range-opacity"},g.createElement(ve,{bounds:"parent",axis:"x",position:n,onDrag:c,onStart:l,onStop:h},g.createElement("div",{className:"circle",style:{backgroundColor:s},onClick:u=>{u.cancelable&&u.preventDefault(),u.stopPropagation()}},g.createElement("div",{className:"range-opacity-data-icon"},e)))))},dM=a=>{const{useStroke:o,color:t,activeStrokeType:e,setStrokeType:i}=a;return g.createElement("div",{className:"stroke-type-box"},!!o&&g.createElement("div",{className:`stroke-type-box-item Stroke ${e===_.Stroke&&"active"}`,style:{backgroundColor:t},onClick:()=>{i(_.Stroke)},onTouchEnd:()=>{i(_.Stroke)}}),g.createElement("div",{className:`stroke-type-box-item Normal ${e===_.Normal&&"active"}`,style:{borderColor:t},onClick:()=>{i(_.Normal)},onTouchEnd:()=>{i(_.Normal)}}),g.createElement("div",{className:`stroke-type-box-item Dotted ${e===_.Dotted&&"active"}`,style:{borderColor:t},onClick:()=>{i(_.Dotted)},onTouchEnd:()=>{i(_.Dotted)}}),g.createElement("div",{className:`stroke-type-box-item LongDotted ${e===_.LongDotted&&"active"}`,style:{borderColor:t},onClick:()=>{i(_.LongDotted)},onTouchEnd:()=>{i(_.LongDotted)}}))},pM=a=>{const{open:o,setOpen:t,floatBarRef:e}=a,{floatBarData:i,floatBarColors:s,mananger:n,setFloatBarData:r}=g.useContext(mt),[c,l]=g.useState(),[h,u]=g.useState(1);g.useEffect(()=>{if(i!=null&&i.strokeColor){const[w,v]=uo(i.strokeColor);l(w),u(v)}},[i]);const d=g.useMemo(()=>{if(e!=null&&e.current&&L.isNumber(i==null?void 0:i.y)&&(n!=null&&n.height)){if(e.current.offsetTop&&e.current.offsetTop+i.y>180){const w={};return w.top="inherit",w.bottom=50,w}else if(!e.current.offsetTop&&(n==null?void 0:n.height)-e.current.offsetTop-i.y<120){const w={};return w.top="inherit",w.bottom=50,w}}},[(e==null?void 0:e.current)&&i,n==null?void 0:n.height]),p=g.useMemo(()=>g.createElement(fo,{key:"strokeColors",opacity:h,activeColor:c,setCurOpacity:(w,v,T)=>{T===D.Start&&(n!=null&&n.control.room)&&(n.control.room.disableDeviceInputs=!0),T===D.Done&&(n!=null&&n.control.room)&&(n.control.room.disableDeviceInputs=!1),u(w);const N=Mt(v,w);i!=null&&i.strokeColor&&r({strokeColor:N}),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:[$],strokeColor:N,workState:T,viewId:n==null?void 0:n.viewId})}}),[h,c,n==null?void 0:n.control.room,n==null?void 0:n.viewId,i]),f=g.useMemo(()=>c&&(i!=null&&i.thickness)?g.createElement(uM,{key:"strokeThickness",min:1,max:10,activeNumber:i.thickness,setActiveNumber:(w,v)=>{v===D.Start&&(n!=null&&n.control.room)&&(n.control.room.disableDeviceInputs=!0),v===D.Done&&(n!=null&&n.control.room)&&(n.control.room.disableDeviceInputs=!1),i!=null&&i.thickness&&r({thickness:w}),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:[$],thickness:w,workState:v,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]),y=g.useMemo(()=>c&&(i!=null&&i.strokeType)?g.createElement(dM,{key:"strokeType",useStroke:i==null?void 0:i.useStroke,activeStrokeType:i.strokeType,setStrokeType:w=>{i.strokeType&&r({strokeType:w}),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:[$],strokeType:w,workState:D.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=g.useMemo(()=>o?g.createElement("div",{className:"font-colors-menu",style:d,onTouchEnd:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()},onClick:w=>{w.cancelable&&w.preventDefault(),w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()}},y,f,g.createElement("div",{className:"font-colors-line"}),s.concat().map((w,v)=>{const T=Oe(...w);return g.createElement(po,{key:v,color:T,activeColor:c,onTouchEndHandler:N=>{N.stopPropagation(),l(T);const I=Mt(T,h);i!=null&&i.strokeColor&&(i.strokeColor=I,r({strokeColor:I})),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:[$],workState:D.Done,strokeColor:I,viewId:n==null?void 0:n.viewId})},onClickHandler:N=>{N.cancelable&&N.preventDefault(),N.stopPropagation(),l(T);const I=Mt(T,h);i!=null&&i.strokeColor&&(i.strokeColor=I,r({strokeColor:I})),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:[$],workState:D.Done,strokeColor:I,viewId:n==null?void 0:n.viewId})}})}),p):null,[o,s,p,c,h,i,n==null?void 0:n.viewId,d]),S=g.useMemo(()=>c?g.createElement("div",{className:"color-bar-ring",style:{backgroundColor:Mt(c,h)}},g.createElement("div",{className:"circle"})):null,[c,h]);return g.createElement("div",{className:`button normal-button font-colors-icon ${o&&"active"}`,onTouchEnd:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation(),t(!o)},onClick:w=>{w.cancelable&&w.preventDefault(),w.stopPropagation(),w.nativeEvent.stopImmediatePropagation(),t(!o)}},S,m)},fM=a=>{const{open:o,setOpen:t,floatBarRef:e}=a,{floatBarData:i,floatBarColors:s,mananger:n,setFloatBarData:r}=g.useContext(mt),[c,l]=g.useState(),[h,u]=g.useState(1);g.useEffect(()=>{if(i!=null&&i.fillColor){const[m,S]=(i==null?void 0:i.fillColor)==="transparent"&&["transparent",1]||uo(i.fillColor);l(m),u(S)}},[i]);const d=g.useMemo(()=>{if(e!=null&&e.current&&L.isNumber(i==null?void 0:i.y)&&(n!=null&&n.height)){if(e.current.offsetTop&&e.current.offsetTop+i.y>200){const m={};return m.top="inherit",m.bottom=50,m}else if(!e.current.offsetTop&&(n==null?void 0:n.height)-e.current.offsetTop-i.y<140){const m={};return m.top="inherit",m.bottom=50,m}}},[e==null?void 0:e.current,i,n==null?void 0:n.height]),p=g.useMemo(()=>c&&c!=="transparent"?g.createElement(fo,{key:"fillColors",opacity:h||0,activeColor:c,setCurOpacity:(m,S,w)=>{w===D.Start&&(n!=null&&n.control.room)&&(n.control.room.disableDeviceInputs=!0),w===D.Done&&(n!=null&&n.control.room)&&(n.control.room.disableDeviceInputs=!1),u(m);const v=Mt(S,m);i!=null&&i.fillColor&&(i.fillColor=v,r({fillColor:v})),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:[$],fillColor:c&&Mt(S,m),workState:w,viewId:n==null?void 0:n.viewId})}}):null,[c,h,n==null?void 0:n.control.room,n==null?void 0:n.viewId,i]),f=g.useMemo(()=>o?g.createElement("div",{className:"font-colors-menu",style:d,onTouchEnd:m=>{m.stopPropagation(),m.nativeEvent.stopImmediatePropagation()},onClick:m=>{m.cancelable&&m.preventDefault(),m.stopPropagation(),m.nativeEvent.stopImmediatePropagation()}},g.createElement(Ps,{activeColor:c,onTouchEndHandler:m=>{m.stopPropagation(),l("transparent");const S="transparent";i!=null&&i.fillColor&&(i.fillColor=S,r({fillColor:S})),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:[$],workState:D.Done,fillColor:S,viewId:n==null?void 0:n.viewId})},onClickHandler:m=>{m.cancelable&&m.preventDefault(),m.stopPropagation(),l("transparent");const S="transparent";i!=null&&i.fillColor&&(i.fillColor=S,r({fillColor:S})),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:[$],workState:D.Done,fillColor:S,viewId:n==null?void 0:n.viewId})}}),s.map((m,S)=>{const w=Oe(...m);return g.createElement(po,{key:S,color:w,activeColor:c,onTouchEndHandler:v=>{v.cancelable&&v.preventDefault(),v.stopPropagation(),l(w);const T=Mt(w,h);i!=null&&i.fillColor&&(i.fillColor=T,r({fillColor:T})),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:[$],workState:D.Done,fillColor:T,viewId:n==null?void 0:n.viewId})},onClickHandler:v=>{v.cancelable&&v.preventDefault(),v.stopPropagation(),l(w);const T=Mt(w,h);i!=null&&i.fillColor&&(i.fillColor=T,r({fillColor:T})),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:[$],workState:D.Done,fillColor:T,viewId:n==null?void 0:n.viewId})}})}),p):null,[o,c,s,p,i,n==null?void 0:n.viewId,h,d]),y=g.useMemo(()=>{const m=c&&c!=="transparent"&&Mt(c,h)||"transparent";return g.createElement("div",{className:"color-bar-fill"},g.createElement("div",{className:"circle",style:{backgroundColor:m}}))},[c,h]);return g.createElement("div",{className:`button normal-button font-colors-icon ${o&&"active"}`,onTouchEnd:m=>{m.stopPropagation(),m.nativeEvent.stopImmediatePropagation(),t(!o)},onClick:m=>{m.cancelable&&m.preventDefault(),m.stopPropagation(),m.nativeEvent.stopImmediatePropagation(),t(!o)}},y,f)},gM=a=>{const{open:o,setOpen:t,textOpt:e,workIds:i,floatBarRef:s}=a,{floatBarColors:n,mananger:r,setFloatBarData:c,floatBarData:l}=g.useContext(mt),[h,u]=g.useState(),[d,p]=g.useState(1);g.useEffect(()=>{if(e!=null&&e.fontColor){const[w,v]=(e==null?void 0:e.fontColor)==="transparent"&&["transparent",0]||uo(e.fontColor);u(w),p(v)}},[e==null?void 0:e.fontColor]);const f=g.useMemo(()=>{if(s!=null&&s.current&&L.isNumber(l==null?void 0:l.y)&&(r!=null&&r.height)){if(s.current.offsetTop&&s.current.offsetTop+l.y>180){const w={};return w.top="inherit",w.bottom=50,w}else if(!s.current.offsetTop&&(r==null?void 0:r.height)-s.current.offsetTop-l.y<120){const w={};return w.top="inherit",w.bottom=50,w}}},[s==null?void 0:s.current,l,r]),y=g.useMemo(()=>h&&h!=="transparent"?g.createElement(fo,{key:"fontColors",opacity:d,activeColor:h,setCurOpacity:(w,v,T)=>{T===D.Start&&(r!=null&&r.control.room)&&(r.control.room.disableDeviceInputs=!0),T===D.Done&&(r!=null&&r.control.room)&&(r.control.room.disableDeviceInputs=!1),p(w);const N=Mt(v,w);l!=null&&l.textOpt&&(l.textOpt.fontColor=N,c({textOpt:l.textOpt})),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:i||[$],fontColor:h&&N,workState:T,viewId:r==null?void 0:r.viewId})}}):null,[h,d,r==null?void 0:r.control.room,r==null?void 0:r.viewId,l==null?void 0:l.textOpt,i]),m=g.useMemo(()=>o?g.createElement("div",{className:"font-colors-menu",style:f,onTouchEnd:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()},onClick:w=>{w.cancelable&&w.preventDefault(),w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()}},n.map((w,v)=>{const T=Oe(...w);return g.createElement(po,{key:v,color:T,activeColor:h,onTouchEndHandler:N=>{N.stopPropagation(),u(T);const I=Mt(T,d);l!=null&&l.textOpt&&(l.textOpt.fontColor=I,c({textOpt:l.textOpt})),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:i||[$],workState:D.Done,fontColor:I,viewId:r==null?void 0:r.viewId})},onClickHandler:N=>{N.cancelable&&N.preventDefault(),N.stopPropagation(),u(T);const I=Mt(T,d);l!=null&&l.textOpt&&(l.textOpt.fontColor=I,c({textOpt:l.textOpt})),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:i||[$],workState:D.Done,fontColor:I,viewId:r==null?void 0:r.viewId})}})}),y):null,[o,n,y,h,d,l==null?void 0:l.textOpt,i,r==null?void 0:r.viewId,f]),S=g.useMemo(()=>{const w=h&&h!=="transparent"&&Mt(h,d)||"transparent";return g.createElement("div",{className:"color-bar"},g.createElement("div",{className:"color-bar-color",style:{backgroundColor:w}}))},[h,d]);return g.createElement("div",{className:`button normal-button font-colors-icon ${o&&"active"}`,onTouchEnd:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation(),t(!o)},onClick:w=>{w.cancelable&&w.preventDefault(),w.stopPropagation(),w.nativeEvent.stopImmediatePropagation(),t(!o)}},g.createElement("img",{alt:"icon",src:St("font-colors")}),S,m)},MM=a=>{const{open:o,setOpen:t,textOpt:e,workIds:i,floatBarRef:s}=a,{floatBarColors:n,mananger:r,setFloatBarData:c,floatBarData:l}=g.useContext(mt),[h,u]=g.useState(),[d,p]=g.useState(1);g.useEffect(()=>{if(e!=null&&e.fontBgColor){const[w,v]=(e==null?void 0:e.fontBgColor)==="transparent"&&["transparent",1]||uo(e.fontBgColor);u(w),p(v)}},[e==null?void 0:e.fontBgColor]);const f=g.useMemo(()=>{if(s!=null&&s.current&&L.isNumber(l==null?void 0:l.y)&&(r!=null&&r.height)){if(s.current.offsetTop&&s.current.offsetTop+l.y>180){const w={};return w.top="inherit",w.bottom=50,w}else if(!s.current.offsetTop&&(r==null?void 0:r.height)-s.current.offsetTop-l.y<120){const w={};return w.top="inherit",w.bottom=50,w}}},[s==null?void 0:s.current,l,r]),y=g.useMemo(()=>h&&h!=="transparent"?g.createElement(fo,{key:"fontBgColor",opacity:d||0,activeColor:h,setCurOpacity:(w,v,T)=>{T===D.Start&&(r!=null&&r.control.room)&&(r.control.room.disableDeviceInputs=!0),T===D.Done&&(r!=null&&r.control.room)&&(r.control.room.disableDeviceInputs=!1),p(w);const N=Mt(v,w);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=N,c({textOpt:l.textOpt})),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:i||[$],fontBgColor:h&&Mt(v,w),workState:T,viewId:r==null?void 0:r.viewId})}}):null,[h,d,r==null?void 0:r.control.room,r==null?void 0:r.viewId,l==null?void 0:l.textOpt,i]),m=g.useMemo(()=>o?g.createElement("div",{className:"font-colors-menu",style:f,onTouchEnd:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()},onClick:w=>{w.cancelable&&w.preventDefault(),w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()}},g.createElement(Ps,{activeColor:h,onTouchEndHandler:w=>{w.stopPropagation();const v="transparent";u(v),l!=null&&l.textOpt&&(l.textOpt.fontBgColor=v,c({textOpt:l.textOpt})),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:i||[$],workState:D.Done,fontBgColor:v,viewId:r==null?void 0:r.viewId})},onClickHandler:w=>{w.cancelable&&w.preventDefault(),w.stopPropagation();const v="transparent";u(v),l!=null&&l.textOpt&&(l.textOpt.fontBgColor=v,c({textOpt:l.textOpt})),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:i||[$],workState:D.Done,fontBgColor:v,viewId:r==null?void 0:r.viewId})}}),n.map((w,v)=>{const T=Oe(...w);return g.createElement(po,{key:v,color:T,activeColor:h,onTouchEndHandler:N=>{N.stopPropagation(),u(T);const I=Mt(T,d);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=I,c({textOpt:l.textOpt})),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:i||[$],workState:D.Done,fontBgColor:Mt(T,d),viewId:r==null?void 0:r.viewId})},onClickHandler:N=>{N.cancelable&&N.preventDefault(),N.stopPropagation(),u(T);const I=Mt(T,d);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=I,c({textOpt:l.textOpt})),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:i||[$],workState:D.Done,fontBgColor:Mt(T,d),viewId:r==null?void 0:r.viewId})}})}),y):null,[o,n,y,d,h,l==null?void 0:l.textOpt,i,r==null?void 0:r.viewId,f]),S=g.useMemo(()=>{const w=h&&h!=="transparent"&&Mt(h,d)||"transparent";return g.createElement("div",{className:"color-bar",style:{marginTop:0}},g.createElement("div",{className:"color-bar-color",style:{backgroundColor:w}}))},[h,d]);return g.createElement("div",{className:`button normal-button font-colors-icon ${o&&"active"}`,onTouchEnd:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation(),t(!o)},onClick:w=>{w.cancelable&&w.preventDefault(),w.stopPropagation(),w.nativeEvent.stopImmediatePropagation(),t(!o)}},g.createElement(hM,null),S,m)},yM=a=>{const{bold:o,setBold:t,workIds:e,viewId:i}=a,s=n=>{const r=o==="bold"?"normal":"bold";n.cancelable&&n.preventDefault(),n==null||n.stopPropagation(),t(r),K.emitMethod(q.MainEngine,R.SetFontStyle,{workIds:e,viewId:i,bold:r})};return g.createElement("div",{className:"font-style-button",onClick:s,onTouchEnd:s},g.createElement("img",{alt:"icon",src:St(o==="bold"?"bold-active":"bold")}))},mM=a=>{const{underline:o,setUnderline:t,workIds:e,viewId:i}=a,s=n=>{const r=!o;n.cancelable&&n.preventDefault(),n==null||n.stopPropagation(),t(r),K.emitMethod(q.MainEngine,R.SetFontStyle,{workIds:e,viewId:i,underline:r})};return g.createElement("div",{className:"font-style-button",onClick:s,onTouchEnd:s},g.createElement("img",{alt:"icon",src:St(o?"underline-active":"underline")}))},wM=a=>{const{lineThrough:o,setLineThrough:t,workIds:e,viewId:i}=a,s=n=>{const r=!o;n.cancelable&&n.preventDefault(),n==null||n.stopPropagation(),t(r),K.emitMethod(q.MainEngine,R.SetFontStyle,{workIds:e,viewId:i,lineThrough:r})};return g.createElement("div",{className:"font-style-button",onClick:s,onTouchEnd:s},g.createElement("img",{alt:"icon",src:St(o?"line-through-active":"line-through")}))},vM=a=>{const{italic:o,setItalic:t,workIds:e,viewId:i}=a,s=n=>{const r=o==="italic"?"normal":"italic";n.cancelable&&n.preventDefault(),n==null||n.stopPropagation(),t(r),K.emitMethod(q.MainEngine,R.SetFontStyle,{workIds:e,viewId:i,italic:r})};return g.createElement("div",{className:"font-style-button",onClick:s,onTouchEnd:s},g.createElement("img",{alt:"icon",src:St(o==="italic"?"italic-active":"italic")}))},IM=a=>{const{open:o,setOpen:t,textOpt:e,workIds:i,style:s,floatBarRef:n}=a,{mananger:r,floatBarData:c}=g.useContext(mt),[l,h]=g.useState("normal"),[u,d]=g.useState("normal"),[p,f]=g.useState(!1),[y,m]=g.useState(!1);g.useEffect(()=>{e!=null&&e.bold&&h(e.bold),L.isBoolean(e==null?void 0:e.underline)&&f(e.underline||!1),L.isBoolean(e==null?void 0:e.lineThrough)&&m(e.lineThrough||!1),e!=null&&e.italic&&d(e.italic)},[e]);const S=g.useMemo(()=>{if(s&&(n!=null&&n.current)&&L.isNumber(c==null?void 0:c.y)&&(r!=null&&r.height)){if(n.current.offsetTop&&n.current.offsetTop+c.y>180){const v={};return v.top="inherit",v.bottom=50,v}else if(!n.current.offsetTop&&(r==null?void 0:r.height)-n.current.offsetTop-c.y<120){const v={};return v.top="inherit",v.bottom=50,v}}},[s,n==null?void 0:n.current,c,r]),w=g.useMemo(()=>o?g.createElement("div",{className:"font-style-menu",style:S,onTouchEnd:v=>{v.stopPropagation(),v.nativeEvent.stopImmediatePropagation()},onClick:v=>{v.cancelable&&v.preventDefault(),v.stopPropagation(),v.nativeEvent.stopImmediatePropagation()}},g.createElement(yM,{workIds:i||[$],bold:l,setBold:h,viewId:r==null?void 0:r.viewId}),g.createElement(mM,{workIds:i||[$],underline:p,setUnderline:f,viewId:r==null?void 0:r.viewId}),g.createElement(wM,{workIds:i||[$],lineThrough:y,setLineThrough:m,viewId:r==null?void 0:r.viewId}),g.createElement(vM,{workIds:i||[$],italic:u,setItalic:d,viewId:r==null?void 0:r.viewId})):null,[o,i,l,r==null?void 0:r.viewId,p,y,u,S]);return g.createElement("div",{className:`button normal-button ${o&&"active"}`,onTouchEnd:v=>{v.stopPropagation(),v.nativeEvent.stopImmediatePropagation(),t(!o)},onClick:v=>{v.cancelable&&v.preventDefault(),v.stopPropagation(),v.nativeEvent.stopImmediatePropagation(),t(!o)}},g.createElement("img",{alt:"icon",src:St(o?"font-style-active":"font-style")}),w)},jt=Object.freeze([12,14,18,24,36,48,64,80,144,288]),de=["top","topLeft","topRight","bottom","bottomLeft","bottomRight","left","leftTop","leftBottom","right","rightTop","rightBottom"],NM=a=>{const{style:o,onClickHandler:t}=a;return g.createElement("div",{className:"font-size-menu",style:o,onTouchEnd:e=>{e.stopPropagation(),e.nativeEvent.stopImmediatePropagation()},onClick:e=>{e.cancelable&&e.preventDefault(),e.stopPropagation(),e.nativeEvent.stopImmediatePropagation()}},jt.map(e=>g.createElement("div",{className:"font-size-btn",key:e,onClick:()=>{t(e)},onTouchEnd:()=>{t(e)}},e)))},TM=a=>{const o=g.useRef(null),{open:t,setOpen:e,textOpt:i,workIds:s,floatBarRef:n}=a,{mananger:r,floatBarData:c}=g.useContext(mt),[l,h]=g.useState(0),[u,d]=g.useState(),p=jt.length-1;g.useEffect(()=>{i!=null&&i.fontSize&&(h(i.fontSize),o.current&&(o.current.value=i.fontSize.toString()))},[i==null?void 0:i.fontSize]);const f=g.useMemo(()=>{if(n!=null&&n.current&&L.isNumber(c==null?void 0:c.y)&&(r!=null&&r.height)){if(n.current.offsetTop&&n.current.offsetTop+c.y>180){const v={};return v.top="inherit",v.bottom=35,v}else if(!n.current.offsetTop&&(r==null?void 0:r.height)-n.current.offsetTop-c.y<120){const v={};return v.top="inherit",v.bottom=35,v}}},[n==null?void 0:n.current,c,r]);function y(v){h(v),v&&v>=jt[0]&&v<=jt[p]&&K.emitMethod(q.MainEngine,R.SetFontStyle,{workIds:s||[$],fontSize:v,viewId:r==null?void 0:r.viewId})}const m=v=>{var T;(T=o.current)==null||T.blur(),e(!1),w(v)},S=g.useMemo(()=>t?g.createElement(NM,{onClickHandler:m,style:f}):null,[t,m,f]),w=v=>{v>jt[p]&&(v=jt[p]),v<jt[0]&&(v=jt[0]),y(v)};return g.useEffect(()=>()=>{r!=null&&r.control.room&&L.isBoolean(u)&&(r.control.room.disableDeviceInputs=u)},[r,u]),g.createElement("div",{className:"button normal-button font-size-barBtn",style:{width:50},onTouchEnd:v=>{v.stopPropagation(),v.nativeEvent.stopImmediatePropagation()},onClick:v=>{v.cancelable&&v.preventDefault(),v.stopPropagation(),v.nativeEvent.stopImmediatePropagation()}},g.createElement("input",{className:"font-size-input",ref:o,onTouchEnd:()=>{o.current&&o.current.focus()},onClick:()=>{e(!t),o.current&&o.current.focus()},onKeyDown:v=>{if(v.key==="Backspace"){const T=window.getSelection(),N=T==null?void 0:T.getRangeAt(0);if(N!=null&&N.collapsed)return v.cancelable&&v.preventDefault(),document.execCommand("delete",!1),!1}return!1},onKeyUp:v=>{var T;if(o.current){const N=o.current.value,I=parseInt(N);isNaN(I)?o.current.value="0":o.current.value=I.toString(),I&&v.key==="Enter"&&(w(I),(T=o.current)==null||T.blur(),e(!1))}},onFocus:()=>{r!=null&&r.control.room&&!r.control.room.disableDeviceInputs&&(d(r.control.room.disableDeviceInputs),r.control.room.disableDeviceInputs=!0)},onBlur:()=>{r!=null&&r.control.room&&L.isBoolean(u)&&(r.control.room.disableDeviceInputs=u)}}),g.createElement("div",{className:"font-size-btns"},g.createElement("div",{className:"font-size-add",onClick:()=>{w(l+jt[0])},onTouchEnd:()=>{w(l+jt[0])}}),g.createElement("div",{className:"font-size-cut",onClick:()=>{w(l-jt[0])},onTouchEnd:()=>{w(l-jt[0])}})),S)},SM=a=>{const{workIds:o,mananger:t,islocked:e}=a;return g.createElement("div",{className:"button normal-button",onClick:i=>{i.cancelable&&i.preventDefault(),i.stopPropagation(),K.emitMethod(q.MainEngine,R.SetLock,{workIds:o||[$],isLocked:!e,viewId:t==null?void 0:t.viewId})},onTouchEnd:i=>{i.stopPropagation(),K.emitMethod(q.MainEngine,R.SetLock,{workIds:o||[$],isLocked:!e,viewId:t==null?void 0:t.viewId})}},g.createElement("img",{alt:"icon",src:St(e?"unlock-new":"lock-new")}))},zo=a=>{const{icon:o,min:t,max:e,step:i,value:s,onInputHandler:n}=a,[r,c]=g.useState(0),l=g.useRef(null),h=u=>{u>e&&(u=e),u<t&&(u=t),c(u),n(u),l.current&&(l.current.value=u.toString())};return g.useEffect(()=>{s&&(c(s),l.current&&(l.current.value=s.toString()))},[s]),g.createElement("div",{className:"button input-button",onTouchEnd:u=>{u.stopPropagation(),u.nativeEvent.stopImmediatePropagation()},onClick:u=>{u.cancelable&&u.preventDefault(),u.stopPropagation(),u.nativeEvent.stopImmediatePropagation()}},g.createElement("img",{src:St(o)}),g.createElement("input",{className:"input-number",type:"text",ref:l,onTouchEnd:()=>{l.current&&l.current.focus()},onClick:()=>{l.current&&l.current.focus()},onKeyDown:u=>{if(u.key==="Backspace"){const d=window.getSelection(),p=d==null?void 0:d.getRangeAt(0);if(p!=null&&p.collapsed)return u.cancelable&&u.preventDefault(),document.execCommand("delete",!1),!1}},onKeyUp:()=>{if(l.current){const u=l.current.value,d=parseInt(u);isNaN(d)?l.current.value="0":l.current.value=d.toString()}},onChange:u=>{const d=u.target.value,p=parseInt(d);p&&p&&p>=t&&p<=e&&h(p)}}),g.createElement("div",{className:"input-number-btns"},g.createElement("div",{className:"input-number-add",onClick:()=>{h(r+i)},onTouchEnd:()=>{h(r+i)}}),g.createElement("div",{className:"input-number-cut",onClick:()=>{h(r-i)},onTouchEnd:()=>{h(r-i)}})))},CM=a=>{const{icon:o,min:t,max:e,step:i,value:s,onInputHandler:n}=a;return g.createElement("div",{className:"button input-button"},g.createElement("img",{src:St(o)}),g.createElement(kM,{min:t,max:e,step:i,value:s,onInputHandler:n}))},kM=a=>{const{value:o,min:t,max:e,onInputHandler:i}=a,[s,n]=g.useState({x:0,y:0});g.useEffect(()=>{n({x:o*100,y:0})},[]);const r=L.throttle((h,u)=>{h.cancelable&&h.preventDefault(),h.stopPropagation();let d=Math.floor(Math.max(u.x,t*100));d=Math.floor(Math.min(d,e*100)),u.x!==(s==null?void 0:s.x)&&n({x:d,y:0});const p=d/100;o!==p&&i(p)},100,{leading:!1}),c=h=>{h.cancelable&&h.preventDefault(),h.stopPropagation()},l=L.throttle((h,u)=>{h.cancelable&&h.preventDefault(),h.stopPropagation();let d=Math.floor(Math.max(u.x,t*100));d=Math.floor(Math.min(d,e*100)),u.x!==(s==null?void 0:s.x)&&n({x:d,y:0});const p=d/100;o!==p&&i(p)},100,{leading:!1});return g.createElement("div",{className:"range-number-container",onClick:h=>{const u=h.nativeEvent.offsetX-6;let d=Math.floor(Math.max(u,t*100));d=Math.floor(Math.min(d,e*100)),n({x:d,y:0});const p=d/100;o!==p&&i(p)}},g.createElement("div",{className:"range-number-color"}),g.createElement("div",{className:"range-number"},g.createElement(ve,{bounds:"parent",axis:"x",position:s,onDrag:r,onStart:c,onStop:l},g.createElement("div",{className:"circle",onClick:c}))))},xM=a=>{const{icon:o,value:t,onChangeHandler:e,style:i}=a,[s,n]=g.useState(0),[r,c]=g.useState(),l=g.useRef(null),h=g.useCallback(p=>{p>=de.length&&(p=0),p<0&&(p=de.length-1),n(p),e(de[p]),c(!1),l.current&&(l.current.value=de[p])},[e]),u=g.useMemo(()=>{if(i&&i.bottom){const p={};return p.top="inherit",p.bottom=50,p}},[i]);g.useEffect(()=>{t&&(n(de.indexOf(t)),l.current&&(l.current.value=t))},[t]);const d=g.useMemo(()=>r?g.createElement(zM,{options:de,onClickHandler:h,style:u}):null,[r,h,u]);return g.createElement("div",{className:"button input-button"},g.createElement("img",{src:St(o)}),g.createElement("input",{readOnly:!0,className:"input-number",type:"text",ref:l,onTouchEnd:p=>{p.cancelable&&p.preventDefault(),p.stopPropagation(),l.current&&l.current.focus()},onClick:p=>{p.cancelable&&p.preventDefault(),p.stopPropagation(),l.current&&(l.current.focus(),c(!r))}}),g.createElement("div",{className:"input-number-btns"},g.createElement("div",{className:"input-number-add",onClick:p=>{p.cancelable&&p.preventDefault(),p.stopPropagation(),h(s+1)},onTouchEnd:p=>{p.cancelable&&p.preventDefault(),p.stopPropagation(),h(s+1)}}),g.createElement("div",{className:"input-number-cut",onClick:p=>{p.cancelable&&p.preventDefault(),p.stopPropagation(),h(s-1)},onTouchEnd:p=>{p.cancelable&&p.preventDefault(),p.stopPropagation(),h(s-1)}})),d)},zM=a=>{const{options:o,style:t,onClickHandler:e}=a;return g.createElement("div",{className:"select-option-menu",style:t,onTouchEnd:i=>{i.cancelable&&i.preventDefault(),i.stopPropagation(),i.nativeEvent.stopImmediatePropagation()},onClick:i=>{i.cancelable&&i.preventDefault(),i.stopPropagation(),i.nativeEvent.stopImmediatePropagation()}},o.map((i,s)=>g.createElement("div",{className:"select-option-btn",key:i,onClick:n=>{n.cancelable&&n.preventDefault(),n.stopPropagation(),e(s)},onTouchEnd:n=>{n.cancelable&&n.preventDefault(),n.stopPropagation(),e(s)}},i)))},bM=a=>{const{mananger:o,innerRatio:t,innerVerticeStep:e,vertices:i}=a,s=c=>{K.emitMethod(q.MainEngine,R.SetShapeOpt,{workIds:[$],toolsType:C.Star,viewId:o.viewId,vertices:c})},n=c=>{K.emitMethod(q.MainEngine,R.SetShapeOpt,{workIds:[$],toolsType:C.Star,viewId:o.viewId,innerVerticeStep:c})},r=c=>{K.emitMethod(q.MainEngine,R.SetShapeOpt,{workIds:[$],toolsType:C.Star,viewId:o.viewId,innerRatio:c})};return g.createElement(g.Fragment,null,g.createElement(zo,{value:i,icon:"polygon-vertex",min:3,max:100,step:1,onInputHandler:s}),g.createElement(zo,{value:e,icon:"star-innerVertex",min:1,max:100,step:1,onInputHandler:n}),g.createElement(CM,{value:t,icon:"star-innerRatio",min:.1,max:1,step:.1,onInputHandler:r}))},PM=a=>{const{mananger:o,vertices:t}=a,e=i=>{K.emitMethod(q.MainEngine,R.SetShapeOpt,{workIds:[$],toolsType:C.Polygon,viewId:o.viewId,vertices:i})};return g.createElement(zo,{value:t,icon:"polygon-vertex",min:3,max:100,step:1,onInputHandler:e})},LM=a=>{const{mananger:o,placement:t}=a,e=i=>{K.emitMethod(q.MainEngine,R.SetShapeOpt,{workIds:[$],toolsType:C.SpeechBalloon,viewId:o.viewId,placement:i})};return g.createElement(xM,{value:t,icon:"speechBallon-placement",onChangeHandler:e})},wo=a=>{const{icon:o,isActive:t,onClickHandler:e,onTouchEndHandler:i}=a;return g.createElement("div",{className:`button tab-button ${t?"active":""}`,onClick:e,onTouchEnd:i},g.createElement("img",{src:St(o)}))},DM=a=>{const{toolsTypes:o,style:t,mananger:e,shapeOpt:i}=a,[s,n]=g.useState();g.useEffect(()=>{o.includes(C.Polygon)?n(C.Polygon):o.includes(C.Star)?n(C.Star):n(C.SpeechBalloon)},[o]);const r=(u,d)=>{d.cancelable&&d.preventDefault(),d==null||d.stopPropagation(),n(u)},c=g.useMemo(()=>s===C.Polygon&&e&&i.vertices?g.createElement(PM,{vertices:i.vertices,mananger:e}):null,[e,s,i]),l=g.useMemo(()=>s===C.Star&&e&&i.vertices&&i.innerVerticeStep&&i.innerRatio?g.createElement(bM,{mananger:e,vertices:i.vertices,innerVerticeStep:i.innerVerticeStep,innerRatio:i.innerRatio}):null,[e,s,i]),h=g.useMemo(()=>s===C.SpeechBalloon&&e&&i.placement?g.createElement(LM,{mananger:e,placement:i.placement}):null,[e,s,i]);return g.createElement("div",{className:"shapeOpt-sub-menu",style:t,onClick:u=>{u.stopPropagation(),u.nativeEvent.stopImmediatePropagation(),u.cancelable&&u.preventDefault()}},g.createElement("div",{className:"shapeOpt-sub-menu-tabs"},o.includes(C.Polygon)&&g.createElement(wo,{isActive:s===C.Polygon,icon:s===C.Polygon?"polygon-active":"polygon",onClickHandler:r.bind(void 0,C.Polygon),onTouchEndHandler:r.bind(void 0,C.Polygon)})||null,o.includes(C.Star)&&g.createElement(wo,{isActive:s===C.Star,icon:s===C.Star?"star-active":"star",onClickHandler:r.bind(void 0,C.Star),onTouchEndHandler:r.bind(void 0,C.Star)})||null,o.includes(C.SpeechBalloon)&&g.createElement(wo,{isActive:s===C.SpeechBalloon,icon:s===C.SpeechBalloon?"speechBallon-active":"speechBallon",onClickHandler:r.bind(void 0,C.SpeechBalloon),onTouchEndHandler:r.bind(void 0,C.SpeechBalloon)})||null),g.createElement("div",{className:"shapeOpt-sub-menu-content"},c,l,h))},jM=a=>{const{open:o,setOpen:t,floatBarRef:e,toolsTypes:i,shapeOpt:s}=a,{floatBarData:n,mananger:r}=g.useContext(mt),[c,l]=g.useState([]),[h,u]=g.useState(),d=g.useMemo(()=>{if(e!=null&&e.current&&L.isNumber(n==null?void 0:n.x)&&L.isNumber(n==null?void 0:n.y)&&(r!=null&&r.height)){if(e.current.offsetTop&&e.current.offsetTop+n.y>200){const m={};return m.top="inherit",m.bottom=50,m}else if(!e.current.offsetTop&&(r==null?void 0:r.height)-e.current.offsetTop-(n==null?void 0:n.y)<140){const m={};return m.top="inherit",m.bottom=50,m}}},[e,n==null?void 0:n.x,n==null?void 0:n.y,r==null?void 0:r.height]),p=g.useMemo(()=>o&&i&&r&&s?(r.control.room&&!r.control.room.disableDeviceInputs&&(u(r.control.room.disableDeviceInputs),r.control.room.disableDeviceInputs=!0),g.createElement(DM,{shapeOpt:s,style:d,toolsTypes:i,mananger:r})):(r!=null&&r.control.room&&L.isBoolean(h)&&(r.control.room.disableDeviceInputs=h),null),[o,d,i,r,s]),f=m=>{m.cancelable&&m.preventDefault(),m.stopPropagation(),m.nativeEvent.stopImmediatePropagation(),t(!o)},y=m=>{m.stopPropagation(),m.nativeEvent.stopImmediatePropagation(),t(!o)};return g.useEffect(()=>{L.isEqual(n==null?void 0:n.selectIds,c)||n!=null&&n.selectIds&&!L.isEqual(n==null?void 0:n.selectIds,c)&&(l(n==null?void 0:n.selectIds),t(!1))},[o,n,c,t]),g.useEffect(()=>()=>{o&&r!=null&&r.control.room&&L.isBoolean(h)&&(r.control.room.disableDeviceInputs=h)},[o,r,h]),g.createElement("div",{className:`button normal-button ${o&&"active"}`,onClick:f,onTouchEnd:y},p,g.createElement("img",{alt:"icon",src:St(o?"shapes-active":"shapes")}))},Ls=g.memo(a=>{const{textOpt:o,workIds:t,noLayer:e,position:i}=a,{floatBarData:s,mananger:n}=g.useContext(mt),[r,c]=g.useState(0),[l,h]=g.useState(),u=g.useRef(null);g.useEffect(()=>{var z,A,E,j;const N={},I=(s==null?void 0:s.w)||((z=o==null?void 0:o.boxSize)==null?void 0:z[0])||0,x=(s==null?void 0:s.h)||((A=o==null?void 0:o.boxSize)==null?void 0:A[1])||0;if(i&&I&&x&&(n!=null&&n.width)&&(n!=null&&n.height)){if(i.y<60?i.y+x<n.height-60?N.bottom=-120:i.y+x<n.height?N.bottom=-58:i.y>0?N.top=62:N.top=-i.y+62:N.top=0,i.x<0)N.left=-i.x+3;else if(i.x+(((E=u.current)==null?void 0:E.offsetWidth)||I)>n.width){const O=n.width-(((j=u.current)==null?void 0:j.offsetWidth)||I)-i.x;N.left=O}h(N);return}h(void 0)},[u,i,s==null?void 0:s.w,s==null?void 0:s.h,n==null?void 0:n.width,n==null?void 0:n.height,o==null?void 0:o.boxSize]);const d=g.useMemo(()=>s!=null&&s.fillColor?g.createElement(fM,{floatBarRef:u,open:r===3,setOpen:N=>{c(N===!0?3:0)}}):null,[s==null?void 0:s.fillColor,r,u]),p=g.useMemo(()=>s!=null&&s.strokeColor?g.createElement(pM,{floatBarRef:u,open:r===2,setOpen:N=>{c(N===!0?2:0)}}):null,[s==null?void 0:s.strokeColor,r,u]),f=g.useMemo(()=>o!=null&&o.fontColor&&(n!=null&&n.viewId)?g.createElement(gM,{floatBarRef:u,open:r===4,setOpen:N=>{c(N===!0?4:0)},textOpt:o,workIds:t}):null,[o,r,t,n,u]),y=g.useMemo(()=>o!=null&&o.fontBgColor&&(n!=null&&n.viewId)?g.createElement(MM,{floatBarRef:u,open:r===5,setOpen:N=>{c(N===!0?5:0)},textOpt:o,workIds:t}):null,[o,r,t,n,u]),m=g.useMemo(()=>o&&(n!=null&&n.viewId)?g.createElement(IM,{floatBarRef:u,open:r===6,setOpen:N=>{c(N===!0?6:0)},textOpt:o,workIds:t,style:l}):null,[o,r,t,n,l,u]),S=g.useMemo(()=>o&&(n!=null&&n.viewId)?g.createElement(TM,{open:r===7,setOpen:N=>{c(N===!0?7:0)},textOpt:o,workIds:t,floatBarRef:u}):null,[o,r,t,n,u]),w=g.useMemo(()=>e?null:g.createElement(lM,{open:r===1,setOpen:N=>{c(N===!0?1:0)},floatBarRef:u}),[e,r,u]),v=g.useMemo(()=>s!=null&&s.canLock&&n?g.createElement(SM,{workIds:t,mananger:n,islocked:s.isLocked}):null,[s,n,t]),T=g.useMemo(()=>n&&(n!=null&&n.viewId)&&l&&(s!=null&&s.shapeOpt)&&(s!=null&&s.toolsTypes)?g.createElement(jM,{open:r===8,setOpen:N=>{c(N===!0?8:0)},floatBarRef:u,workIds:t,toolsTypes:s.toolsTypes,shapeOpt:s.shapeOpt}):null,[s,n,r,l,t,u]);return g.createElement("div",{className:"appliance-plugin-floatbtns",style:l,ref:u,onMouseOver:N=>(N.stopPropagation(),N.cancelable&&N.preventDefault(),n==null||n.control.worker.blurCursor(n.viewId),!1),onMouseMove:N=>(N.stopPropagation(),N.cancelable&&N.preventDefault(),!1)},n&&g.createElement(aM,{workIds:t,mananger:n}),w,v,!!(n!=null&&n.viewId)&&g.createElement(cM,{workIds:t,viewId:n.viewId}),T,S,m,f,y,p,d)}),AM=a=>{const{data:o,isActive:t,manager:e,workId:i}=a,{opt:s,scale:n,translate:r,x:c,y:l}=o,h=`scale(${n||1}) ${r&&"translate("+r[0]+"px,"+r[1]+"px)"||""}`,{fontSize:u,fontFamily:d,underline:p,fontColor:f,lineThrough:y,textAlign:m,strokeColor:S,lineHeight:w,bold:v,italic:T,uid:N,workState:I}=s,x=u,z=w||x*1.2,A={fontSize:`${x}px`,lineHeight:`${z}px`,color:f,borderColor:S,minHeight:`${z}px`,paddingRight:`${T==="italic"?Math.round(x*.3):5}px`};d&&(A.fontFamily=`${d}`),(y||p)&&(A.textDecoration=`${y&&"line-through"||""}${p&&" underline"||""}`),v&&(A.fontWeight=`${v}`),T&&(A.fontStyle=`${T}`),m&&(A.textAlign=`${m}`);function E(){var O;t&&(N&&N===((O=e.control.collector)==null?void 0:O.uid)||!N)&&e.control.textEditorManager.active(i)}const j=g.useMemo(()=>{const O=[];if(s.text){const P=xe(s.text);for(let Y=0;Y<P.length;Y++){const ot=P[Y];ot===""?O.push(g.createElement("div",{style:{backgroundColor:s.fontBgColor},key:Y},g.createElement("br",null))):O.push(g.createElement("div",{style:{backgroundColor:s.fontBgColor},key:Y},ot))}}return O.length?O:null},[s.fontBgColor,s.text]);return g.createElement("div",{className:"editor-box",style:{left:`${c}px`,top:`${l}px`,transform:h,transformOrigin:"left top",pointerEvents:"none",opacity:I===D.Done?0:1}},g.createElement("div",{className:`editor ${t?"":"readOnly"}`,style:A,onClick:E},j))},EM=g.memo(a=>{const{data:o,left:t,top:e,workId:i,updateOptInfo:s}=a,{opt:n,scale:r,translate:c}=o,l=g.useRef(null);g.useEffect(()=>{var A,E;if((A=l.current)!=null&&A.offsetWidth&&((E=l.current)!=null&&E.offsetHeight)){const j=n.boxSize;if((j==null?void 0:j[0])!==l.current.offsetWidth||j[1]!==l.current.offsetHeight||!j){const O=[l.current.offsetWidth,l.current.offsetHeight];s({activeTextId:i,update:{boxSize:O,workState:D.Done}})}}},[n.fontSize,n.italic,n.bold,n.boxSize,i]);const h=`scale(${r||1}) ${c&&"translate("+c[0]+"px,"+c[1]+"px)"||""}`,{fontSize:u,fontFamily:d,underline:p,fontColor:f,lineThrough:y,textAlign:m,strokeColor:S,lineHeight:w,bold:v,italic:T}=n,N=u,I=w||N*1.2,x={fontSize:`${N}px`,lineHeight:`${I}px`,color:f,borderColor:S,minHeight:`${I}px`,pointerEvents:"none",paddingRight:`${T==="italic"?Math.round(N*.3):5}px`};d&&(x.fontFamily=`${d}`),(y||p)&&(x.textDecoration=`${y&&"line-through"||""}${p&&" underline"||""}`),m&&(x.textAlign=`${m}`),v&&(x.fontWeight=`${v}`),T&&(x.fontStyle=`${T}`);const z=g.useMemo(()=>{const A=[];if(n.text){const E=xe(n.text);for(let j=0;j<E.length;j++){const O=E[j];O===""?A.push(g.createElement("div",{key:j},g.createElement("br",null))):A.push(g.createElement("div",{key:j},O))}}return A.length?A:null},[n.text]);return g.createElement("div",{className:"editor-box",style:{left:`${t}`,top:`${e}`,transform:h,transformOrigin:"left top",zIndex:1,pointerEvents:"none",opacity:0}},g.createElement("div",{className:"editor readOnly",ref:l,style:x},z))},(a,o)=>!(a.workId!==o.workId||a.left!==o.left||a.top!==o.top||!L.isEqual(a.data,o.data))),OM=a=>{const{data:o,workId:t,isSelect:e,showFloatBtns:i,handleKeyUp:s,handleFocus:n,updateOptInfo:r,manager:c,runAnimation:l}=a,[h,u]=g.useState(),{opt:d,scale:p,translate:f,x:y,y:m}=o,{fontSize:S,fontFamily:w,underline:v,fontColor:T,lineThrough:N,textAlign:I,strokeColor:x,lineHeight:z,bold:A,italic:E,boxSize:j}=d,O=g.useRef(null),P=g.useMemo(()=>{const it=S,at=z||it*1.2,U={fontSize:`${it}px`,lineHeight:`${at}px`,color:T,borderColor:x,minHeight:`${at}px`,paddingRight:`${E==="italic"?Math.round(it*.3):5}px`,borderWidth:`${Math.max(Math.round(1/(p||1)),1)}px`};return w&&(U.fontFamily=`${w}`),(N||v)&&(U.textDecoration=`${N&&"line-through"||""} ${v&&" underline"||""}`),I&&(U.textAlign=`${I}`),A&&(U.fontWeight=`${A}`),E&&(U.fontStyle=`${E}`),U},[A,T,w,S,E,z,N,p,x,I,v]),Y=g.useMemo(()=>{const it=`scale(${p||1}) ${f&&"translate("+f[0]+"px,"+f[1]+"px)"||""}`;return{left:`${y}px`,top:`${m}px`,zIndex:2,pointerEvents:"none",transform:it,transformOrigin:"left top"}},[p,f,y,m]),ot=g.useMemo(()=>{var it,at;return!e&&p&&i&&L.isNumber(y)&&L.isNumber(m)&&d.boxSize&&L.isNumber((it=d.boxSize)==null?void 0:it[0])&&L.isNumber((at=d.boxSize)==null?void 0:at[1])?g.createElement("div",{className:kt.FloatBarBtn,style:{left:y,top:m,width:d.boxSize[0]*p,height:d.boxSize[1]*p}},g.createElement(Ls,{position:{x:y,y:m},textOpt:d,workIds:[t],noLayer:!0})):null},[e,d,i,t,y,m,p]),tt=g.useMemo(()=>{let it="";if(d.text){const at=xe(d.text);for(let U=0;U<at.length;U++){const nt=at[U];nt===""?it=it+"<div><br/></div>":it=it+`<div style="background-color:${d.fontBgColor}">${nt}</div>`}}else it=`<div style="background-color:${d.fontBgColor}"></div>`;return it},[d.fontBgColor,d.text]),Q=g.useMemo(()=>typeof tt=="string"?g.createElement("div",{id:t,suppressContentEditableWarning:!0,contentEditable:!0,className:"editor",ref:O,style:P,onKeyDown:G,onKeyUp:s,onClick:J,onTouchEnd:J,onFocus:n,onPaste:rt,onInput:wt,dangerouslySetInnerHTML:{__html:tt}}):null,[tt,P,t]);g.useEffect(()=>{Q&&O.current&&(O.current.click(),setTimeout(()=>{var it;if(O.current){const at=window==null?void 0:window.getSelection(),U=O.current.lastChild;if(at&&U){const nt=document.createRange(),ht=((it=U.textContent)==null?void 0:it.length)||0;(U==null?void 0:U.nodeName)==="#text"?nt.setStart(U,ht):nt.setStart(U,ht&&1||0),nt.collapse(!0),at.removeAllRanges(),at.addRange(nt)}}},20))},[Q,O.current]),g.useEffect(()=>{var it,at,U,nt;if(Q&&((it=O.current)!=null&&it.offsetWidth||(at=O.current)!=null&&at.offsetHeight||(U=O.current)!=null&&U.offsetLeft||(nt=O.current)!=null&&nt.offsetTop)){const ht=[O.current.offsetWidth,O.current.offsetHeight];(j&&j[0]!==ht[0]&&j[1]!==ht[1]||!j)&&r({activeTextId:t,update:{boxSize:ht,workState:D.Doing}})}},[j,Q,P,t]);function J(){O.current&&O.current.focus(),l()}function G(it){if(it.key==="Backspace"){const at=window.getSelection(),U=at==null?void 0:at.getRangeAt(0);if(U!=null&&U.collapsed)return it.cancelable&&it.preventDefault(),document.execCommand("delete",!1),!1}return l(),!1}function Z(it,at){const U=window==null?void 0:window.getSelection();if(U!=null&&U.rangeCount&&it&&U&&U.anchorNode){const nt=U.anchorOffset,ht=U.anchorNode.textContent||"",vt=ht.slice(0,nt)||"",Ht=ht.slice(nt)||"",yt=vt.concat(it)||"";X(yt,Ht,at)}}function X(it,at,U){const nt=window==null?void 0:window.getSelection();if(!(nt!=null&&nt.rangeCount)||!nt.anchorNode)return;const ht=it.split(/\n/);let vt=nt.anchorNode.parentNode;vt===U&&(vt=nt.anchorNode);const Ht=[...U.childNodes],yt=[];let gt,oe=nt.anchorOffset;for(;Ht.length;){const Tt=Ht.pop();if(Tt){if(Tt===vt){let Rt=ht[0];ht.length===1&&(oe=ht[0].length,Rt=ht[0].concat(at)),vt.nodeName==="#text"?(vt.textContent=Rt,gt=vt):vt.nodeName==="DIV"&&(vt.innerText=Rt,gt=vt.childNodes[0]);break}yt.push(Tt),U.removeChild(Tt)}}if(ht.length>1)for(let Tt=1;Tt<ht.length;Tt++){let Rt=ht[Tt];const ze=document.createElement("div");d.fontBgColor&&(ze.style.backgroundColor=d.fontBgColor),Tt===ht.length-1&&(oe=Rt.length,Rt=Rt.concat(at)),Rt===""?ze.innerHTML="<br/>":ze.innerText=Rt,U.appendChild(ze),Tt===ht.length-1&&(gt=ze.childNodes[0])}if(yt.length){yt.reverse();for(const Tt of yt)U.appendChild(Tt)}if(gt&>.nodeName==="#text"){nt.deleteFromDocument();const Tt=document.createRange(),Rt=Math.min(oe,(gt==null?void 0:gt.length)||0);Tt.setStart(gt,Rt),Tt.collapse(!0),nt.removeAllRanges(),nt.addRange(Tt)}}function rt(it){if(it.cancelable&&it.preventDefault(),it.stopPropagation(),O.current){const at=(it.clipboardData||window.clipboardData).getData("text"),U=window==null?void 0:window.getSelection();if(!(U!=null&&U.rangeCount))return;at&&U&&U.anchorNode&&Z(at,O.current),l()}}function wt(it){s(it),l()}return g.createElement(g.Fragment,null,ot,g.createElement("div",{className:"editor-box",style:Y,onFocus:()=>{c.control.room&&!c.control.room.disableDeviceInputs&&(u(c.control.room.disableDeviceInputs),c.control.room.disableDeviceInputs=!0)},onBlur:()=>{c!=null&&c.control.room&&L.isBoolean(h)&&(c.control.room.disableDeviceInputs=h)}},Q))};class Ds extends g.Component{constructor(o){super(o)}getInnerText(o){const t=[];for(let e=0;e<o.childNodes.length;e++){const i=o.childNodes[e];if(i.nodeName==="#text"&&e===0){const s=i.textContent.split(/\n/),n=s.pop();t.push(...s),n&&t.push(n)}else if(i.nodeName==="DIV"){const s=i.innerText.split(/\n/);if(s.length===2&&s[0]===""&&s[1]==="")t.push("");else{const n=s.shift();n&&t.push(n);const r=s.pop();t.push(...s),r&&t.push(r)}}}return t}updateOptInfo(o){var n,r;const{activeTextId:t,update:e,syncData:i}=o,s=t&&L.cloneDeep(((n=this.props.manager.control.textEditorManager)==null?void 0:n.get(t))||((r=this.props.editors)==null?void 0:r.get(t)));s&&s.opt&&(s.opt={...s.opt,...e},i&&(s.canSync=Object.keys(i).includes("canSync")&&i.canSync||s.canSync,s.canWorker=Object.keys(i).includes("canWorker")&&i.canWorker||s.canWorker),this.props.manager.control.textEditorManager.updateForViewEdited(t,s))}get editorUI(){var o;if((o=this.props.editors)!=null&&o.size){const t=[];return this.props.editors.forEach((e,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}=e,h=`${c-n}px`,u=`${l-r}px`,d=g.createElement(EM,{left:h,top:u,key:i,data:e,workId:i,isSelect:!0,updateOptInfo:this.updateOptInfo.bind(this),manager:this.props.manager});t.push(d)}}),t}return null}render(){return g.createElement(g.Fragment,null,this.editorUI)}}class RM extends Ds{constructor(t){super(t);M(this,"ref");M(this,"isRunAnimation");this.ref=g.createRef(),this.isRunAnimation=void 0}runAnimation(){this.isRunAnimation||(this.isRunAnimation=requestAnimationFrame(()=>{var t,e;(t=this.ref)!=null&&t.current&&((e=this.ref)==null||e.current.scrollTo({left:0,behavior:"instant"})),this.isRunAnimation=void 0}))}handleKeyUp(t){const e=this.getInnerText(t.nativeEvent.target),i=this.props.activeTextId;if(i){const s=this.props.manager.control.textEditorManager.get(i),n=Dt(e),r=D.Doing,c=[t.nativeEvent.target.offsetWidth,t.nativeEvent.target.offsetHeight];(!s||s&&(s.opt.text!==n||!L.isEqual(s.opt.boxSize,c)||!L.isEqual(s.opt.workState,r)))&&this.updateOptInfo({activeTextId:i,update:{text:n,boxSize:c,workState:r},syncData:{canSync:!0,canWorker:!0}})}}handleFocus(t){const e=this.props.activeTextId;if(e){const i=this.props.manager.control.textEditorManager.get(e),s=D.Doing,n=[t.nativeEvent.target.offsetWidth,t.nativeEvent.target.offsetHeight];(!i||i&&(!L.isEqual(i.opt.boxSize,n)||!L.isEqual(i.opt.workState,s)))&&this.updateOptInfo({activeTextId:e,update:{boxSize:n,workState:s},syncData:{canSync:!0,canWorker:!0}})}}get editorUI(){var t;if((t=this.props.editors)!=null&&t.size){const e=[];return this.props.editors.forEach((i,s)=>{if(!(this.props.selectIds.includes(s)&&this.props.activeTextId!==s)){const c=this.props.activeTextId==s?g.createElement(OM,{key:s,data:i,workId:s,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)}):g.createElement(AM,{manager:this.props.manager,isActive:i.opt.workState===D.Doing||i.opt.workState===D.Start||!1,key:s,data:i,workId:s});e.push(c)}}),e}return null}render(){return g.createElement("div",{className:`${this.props.className}`,ref:this.ref},this.editorUI)}}const YM=()=>{const{floatBarData:a}=g.useContext(mt);return g.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:a==null?void 0:a.selectorColor}},g.createElement("div",{className:"point LT nwse-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),g.createElement("div",{className:"point LC ew-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),g.createElement("div",{className:"point LB nesw-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),g.createElement("div",{className:"point TC ns-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),g.createElement("div",{className:"point RT nesw-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),g.createElement("div",{className:"point RC ew-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),g.createElement("div",{className:"point RB nwse-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),g.createElement("div",{className:"point BC ns-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}))},WM=()=>{const{floatBarData:a,mananger:o}=g.useContext(mt),[t,e]=g.useState(),[i,s]=g.useState();g.useEffect(()=>{const c=[];if(o&&L.isNumber(a==null?void 0:a.x)&&L.isNumber(a==null?void 0:a.y)&&(a!=null&&a.points)){const l=o.viewId;if(o.control.viewContainerManager.getView(l))for(const u of a.points){const d=o.control.viewContainerManager.transformToOriginPoint(u,l);c.push(d)}c[0]&&e({x:c[0][0]-((a==null?void 0:a.x)||0),y:c[0][1]-((a==null?void 0:a.y)||0)}),c[1]&&s({x:c[1][0]-((a==null?void 0:a.x)||0),y:c[1][1]-((a==null?void 0:a.y)||0)})}},[o,a==null?void 0:a.points,a==null?void 0:a.x,a==null?void 0:a.y]);const n=g.useMemo(()=>t?g.createElement("div",{className:"point point-dot",style:{borderColor:a==null?void 0:a.selectorColor,left:t.x,top:t.y}}):null,[a==null?void 0:a.selectorColor,t]),r=g.useMemo(()=>i?g.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 g.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:a==null?void 0:a.selectorColor}},n,r)},UM=()=>{const{floatBarData:a}=g.useContext(mt);return g.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:a==null?void 0:a.selectorColor}},g.createElement("div",{className:"point LT nwse-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),g.createElement("div",{className:"point LB nesw-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),g.createElement("div",{className:"point RT nesw-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),g.createElement("div",{className:"point RB nwse-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}))},BM=()=>{const{floatBarData:a}=g.useContext(mt);return g.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:a==null?void 0:a.selectorColor}},g.createElement("img",{className:"lock",alt:"lock",src:"https://sdk.netless.link/resource/icons/lock.svg"}))},VM=a=>{const{className:o}=a,{floatBarData:t,angle:e,setAngle:i,setOperationType:s,mananger:n}=g.useContext(mt),[r,c]=g.useState(!1),[l,h]=g.useState(new F),[u,d]=g.useState(new F),[p,f]=g.useState(!1);g.useEffect(()=>(K.activeListener(y),()=>{K.unmountActiveListener(y)}),[]);const y=v=>{var T;if(!v){f(!0),c(!1),s(R.None);return}f(!1),(T=n==null?void 0:n.control.room)!=null&&T.disableDeviceInputs&&(n.control.room.disableDeviceInputs=!1)};g.useEffect(()=>{if(t){const v=Math.floor(t.w/2),T=Math.floor(-t.h/2);d(new F(v,T)),h(new F)}},[t]);const m=(v,T)=>{if(v.cancelable&&v.preventDefault(),v.stopPropagation(),n!=null&&n.control.worker.isBusy){f(!0);return}c(!0);const N=Math.round(F.GetAngleByPoints(l,u,new F(T.x,T.y)))||0;i(N),s(R.RotateNode),n!=null&&n.control.room&&(n.control.room.disableDeviceInputs=!0),K.emitMethod(q.MainEngine,R.RotateNode,{workIds:[$],angle:N,workState:D.Start,viewId:n==null?void 0:n.viewId})},S=Ee((v,T)=>{if(v.cancelable&&v.preventDefault(),v.stopPropagation(),n!=null&&n.control.worker.isBusy){f(!0);return}c(!1);const N=Math.round(F.GetAngleByPoints(l,u,new F(T.x,T.y)))||0;i(N),s(R.None),n!=null&&n.control.room&&(n.control.room.disableDeviceInputs=!1),K.emitMethod(q.MainEngine,R.RotateNode,{workIds:[$],angle:N,workState:D.Done,viewId:n==null?void 0:n.viewId})},100,{leading:!1}),w=Ee((v,T)=>{if(v.cancelable&&v.preventDefault(),v.stopPropagation(),n!=null&&n.control.worker.isBusy){f(!0);return}c(!0);const N=Math.round(F.GetAngleByPoints(l,u,new F(T.x,T.y)))||0;i(N),s(R.RotateNode),K.emitMethod(q.MainEngine,R.RotateNode,{workIds:[$],angle:N,workState:D.Doing,viewId:n==null?void 0:n.viewId})},100,{leading:!1});return g.createElement(ve,{disabled:p,handle:".appliance-plugin-rotate-mouse-pointer",onStart:m,onDrag:w,onStop:S},g.createElement("div",{className:`${o}`,style:t?{left:t.x-30,top:t.y+t.h+20,touchAction:"none"}:void 0},!r&&g.createElement("div",{className:"appliance-plugin-rotate-btn",style:{backgroundColor:t==null?void 0:t.selectorColor}},g.createElement("img",{alt:"icon",src:St("rotation-button")})),g.createElement("div",{className:`appliance-plugin-rotate-mouse-pointer ${r?"active":""}`},g.createElement("img",{alt:"icon",src:St("rotation")}),g.createElement("div",{className:"angle-icon"},e,"°"))))},FM=a=>{const{floatBarData:o,setOperationType:t,mananger:e}=g.useContext(mt),{onClickHandle:i}=a,[s,n]=g.useState(D.Pending),[r,c]=g.useState(),[l,h]=g.useState(),[u,d]=g.useState(!1);g.useEffect(()=>(K.activeListener(p),()=>{K.unmountActiveListener(p)}),[]);const p=v=>{var T;if(!v||o!=null&&o.isLocked){d(!0),n(D.Pending),t(R.None);return}d(!1),(T=e==null?void 0:e.control.room)!=null&&T.disableDeviceInputs&&(e.control.room.disableDeviceInputs=!1)};g.useEffect(()=>{if(o!=null&&o.isLocked||e!=null&&e.control.worker.isBusy){d(!0),n(D.Pending);return}d(!1)},[o==null?void 0:o.isLocked]),g.useEffect(()=>{L.isNumber(o==null?void 0:o.x)&&L.isNumber(o==null?void 0:o.y)&&(s===D.Pending||s===D.Done)&&h({x:o==null?void 0:o.x,y:o==null?void 0:o.y})},[s,o==null?void 0:o.x,o==null?void 0:o.y]);const f=v=>{if(v.cancelable&&v.preventDefault(),v.stopPropagation(),e!=null&&e.control.worker.isBusy){d(!0),n(D.Pending);return}L.isNumber(o==null?void 0:o.x)&&L.isNumber(o==null?void 0:o.y)&&(t(R.TranslateNode),n(D.Start),c({x:o==null?void 0:o.x,y:o==null?void 0:o.y}),e!=null&&e.control.room&&(e.control.room.disableDeviceInputs=!0),K.emitMethod(q.MainEngine,R.TranslateNode,{workIds:[$],position:{x:o==null?void 0:o.x,y:o==null?void 0:o.y},workState:D.Start,viewId:e==null?void 0:e.viewId}))},y=L.throttle((v,T)=>{if(v.cancelable&&v.preventDefault(),e!=null&&e.control.worker.isBusy){d(!0),n(D.Pending);return}v.stopPropagation();const N={x:T.x,y:T.y};t(R.None),n(D.Done),e!=null&&e.control.room&&(e.control.room.disableDeviceInputs=!1),K.emitMethod(q.MainEngine,R.TranslateNode,{workIds:[$],position:N,workState:D.Done,viewId:e==null?void 0:e.viewId})},100,{leading:!1}),m=L.throttle((v,T)=>{if(v.cancelable&&v.preventDefault(),v.stopPropagation(),e!=null&&e.control.worker.isBusy){d(!0),n(D.Pending);return}const N={x:T.x,y:T.y};(T.x!==(o==null?void 0:o.x)||T.y!==(o==null?void 0:o.y))&&(n(D.Doing),K.emitMethod(q.MainEngine,R.TranslateNode,{workIds:[$],position:N,workState:D.Doing,viewId:e==null?void 0:e.viewId}))},100,{leading:!1}),S=g.useMemo(()=>!!((o==null?void 0:o.scaleType)===ct.none&&(o!=null&&o.canLock)),[o]),w=L.throttle(v=>(v.stopPropagation(),v.cancelable&&v.preventDefault(),(r==null?void 0:r.x)===(o==null?void 0:o.x)&&(r==null?void 0:r.y)===(o==null?void 0:o.y)&&i(v),!1),100,{leading:!1});return g.createElement(ve,{disabled:u,position:l,onStart:f,onDrag:m,onStop:y},g.createElement("div",{style:o?{position:"absolute",left:0,top:0,width:o.w,height:o.h,zIndex:2,pointerEvents:S?"none":"auto",touchAction:"none"}:void 0,onClick:v=>{v.persist(),w(v)},onTouchEnd:v=>{v.persist(),w(v)}}))},HM=a=>{const{className:o}=a,[t,e]=g.useState({x:0,y:0,h:0,w:0}),[i,s]=g.useState(),[n,r]=g.useState(),[c,l]=g.useState(),{floatBarData:h,mananger:u}=g.useContext(mt),[d,p]=g.useState(),[f,y]=g.useState(!1);g.useEffect(()=>{if(h&&u){const x={x:h.x,y:h.y,w:h.w,h:h.h};e(x)}return K.activeListener(m),()=>{K.unmountActiveListener(m)}},[]);const m=x=>{var z;if(!x){y(!0);return}y(!1),(z=u==null?void 0:u.control.room)!=null&&z.disableDeviceInputs&&(u.control.room.disableDeviceInputs=!1)},S=x=>[[x.x,x.y],[x.x+x.w,x.y],[x.x+x.w,x.y+x.h],[x.x,x.y+x.h]],w=(x,z)=>{switch(z){case"top":case"topLeft":case"left":return x[2];case"topRight":return x[3];case"right":case"bottomRight":case"bottom":return x[0];case"bottomLeft":return x[1]}},v=(x,z,A,E)=>{let j=!1,O=!1;const P={x:t.x,y:t.y,w:t.w,h:t.h},Y=[1,1],ot=[0,0];switch(x){case"top":{const G=z.height+t.h;G<0?(O=!0,P.y=t.y+t.h,P.h=Math.abs(G)):(P.y=t.y-z.height,P.h=t.h+z.height);break}case"topLeft":{const G=z.width+t.w;G<0?(j=!0,P.x=t.x+t.w,P.w=Math.abs(G)):(P.x=t.x-z.width,P.w=t.w+z.width);const Z=z.height+t.h;Z<0?(O=!0,P.y=t.y+t.h,P.h=Math.abs(Z)):(P.y=t.y-z.height,P.h=t.h+z.height);break}case"topRight":{const G=z.width+t.w;G<0?(j=!0,P.x=t.x+G,P.w=Math.abs(G)):P.w=t.w+z.width;const Z=z.height+t.h;Z<0?(O=!0,P.y=t.y+t.h,P.h=Math.abs(Z)):(P.y=t.y-z.height,P.h=t.h+z.height);break}case"bottom":{const G=z.height+t.h;G<0?(O=!0,P.y=t.y+G,P.h=Math.abs(G)):P.h=t.h+z.height;break}case"bottomLeft":{const G=z.width+t.w;G<0?(j=!0,P.x=t.x+t.w,P.w=Math.abs(G)):(P.x=t.x-z.width,P.w=t.w+z.width);const Z=z.height+t.h;Z<0?(O=!0,P.y=t.y+Z,P.h=Math.abs(Z)):P.h=t.h+z.height;break}case"left":{const G=z.width+t.w;G<0?(j=!0,P.x=t.x+t.w,P.w=Math.abs(G)):(P.x=t.x-z.width,P.w=t.w+z.width);break}case"bottomRight":{const G=z.width+t.w;G<0?(j=!0,P.x=t.x+G,P.w=Math.abs(G)):P.w=t.w+z.width;const Z=z.height+t.h;Z<0?(O=!0,P.y=t.y+Z,P.h=Math.abs(Z)):P.h=t.h+z.height;break}case"right":{const G=z.width+t.w;G<0?(j=!0,P.x=t.x+G,P.w=Math.abs(G)):P.w=t.w+z.width;break}}Y[0]=P.w/t.w,Y[1]=P.h/t.h;const Q=S(P).map(G=>A.control.viewContainerManager.transformToScenePoint(G,A.viewId)),J=w(Q,x);return O&&(ot[1]=J[1]-E[1]),j&&(ot[0]=J[0]-E[0]),{scale:Y,translate:ot}},T=(x,z)=>{if(x.cancelable&&x.preventDefault(),x.stopPropagation(),u!=null&&u.control.worker.isBusy){y(!0);return}if(h!=null&&h.w&&(h!=null&&h.h)&&u){const A={x:h.x,y:h.y,w:h.w,h:h.h},E=S(A),j=E.map(Y=>u.control.viewContainerManager.transformToScenePoint(Y,u.viewId)),O=w(E,z),P=w(j,z);e(A),s(O),r(P),l(z),u!=null&&u.control.room&&(u.control.room.disableDeviceInputs=!0),K.emitMethod(q.MainEngine,R.ScaleNode,{workIds:[$],originPoint:O,scenePoint:P,workState:D.Start,viewId:u.viewId})}},N=L.throttle((x,z,A,E)=>{if(x.cancelable&&x.preventDefault(),x.stopPropagation(),!u||!i||!n)return;if(u!=null&&u.control.worker.isBusy){y(!0);return}const{scale:j,translate:O}=v(z,E,u,n);(!L.isEqual(j,d==null?void 0:d.scale)||!L.isEqual(O,d==null?void 0:d.translate))&&(p({scale:j,translate:O}),K.emitMethod(q.MainEngine,R.ScaleNode,{workIds:[$],scale:j,dir:z,translate:O,originPoint:i,scenePoint:n,workState:D.Doing,viewId:u.viewId}))},100,{leading:!1}),I=L.throttle(x=>{if(x.cancelable&&x.preventDefault(),x.stopPropagation(),!(!u||!i||!n)){if(u!=null&&u.control.worker.isBusy){y(!0);return}if(u!=null&&u.control.room&&(u.control.room.disableDeviceInputs=!1),d){const{scale:z,translate:A}=d;K.emitMethod(q.MainEngine,R.ScaleNode,{workIds:[$],scale:z,dir:c,translate:A,originPoint:i,scenePoint:n,workState:D.Done,viewId:u.viewId})}}},100,{leading:!1});return g.createElement(Es.Resizable,{className:`${o}`,boundsByDirection:!0,minWidth:-(((h==null?void 0:h.x)||0)+((h==null?void 0:h.w)||0)),minHeight:-(((h==null?void 0:h.y)||0)+((h==null?void 0:h.h)||0)),size:{width:(h==null?void 0:h.w)||0,height:(h==null?void 0:h.h)||0},style:{position:"absolute",pointerEvents:"auto",left:h==null?void 0:h.x,top:h==null?void 0:h.y},enable:f?!1:{top:(h==null?void 0:h.scaleType)===ct.all&&!0||!1,right:(h==null?void 0:h.scaleType)===ct.all&&!0||!1,bottom:(h==null?void 0:h.scaleType)===ct.all&&!0||!1,left:(h==null?void 0:h.scaleType)===ct.all&&!0||!1,topRight:!0,bottomRight:!0,bottomLeft:!0,topLeft:!0},lockAspectRatio:(h==null?void 0:h.scaleType)===ct.proportional,onResizeStart:T,onResize:N,onResizeStop:I})},ji=a=>{const{id:o,pos:t,pointMap:e,type:i}=a,{setOperationType:s,mananger:n,floatBarData:r}=g.useContext(mt),[c,l]=g.useState({x:0,y:0}),[h,u]=g.useState(D.Pending),[d,p]=g.useState(!1);g.useEffect(()=>(K.activeListener(f),()=>{K.unmountActiveListener(f)}),[]);const f=w=>{var v;if(!w||r!=null&&r.isLocked){p(!0),u(D.Pending),s(R.None);return}p(!1),(v=n==null?void 0:n.control.room)!=null&&v.disableDeviceInputs&&(n.control.room.disableDeviceInputs=!1)};g.useEffect(()=>{L.isNumber(t.x)&&L.isNumber(t.y)&&(h===D.Pending||h===D.Done)&&l({x:t.x,y:t.y})},[t,h]);const y=w=>{if(w.cancelable&&w.preventDefault(),w.stopPropagation(),n!=null&&n.control.worker.isBusy){p(!0),u(D.Pending);return}L.isNumber(t.x)&&L.isNumber(t.y)&&(s(R.SetPoint),u(D.Start),n!=null&&n.control.room&&(n.control.room.disableDeviceInputs=!0),K.emitMethod(q.MainEngine,R.SetPoint,{workId:$,pointMap:e,workState:D.Start,viewId:n==null?void 0:n.viewId}))},m=L.throttle((w,v)=>{if(w.cancelable&&w.preventDefault(),w.stopPropagation(),n!=null&&n.control.worker.isBusy){p(!0),u(D.Pending);return}const T={x:v.x,y:v.y};if((T.x!==(t==null?void 0:t.x)||T.y!==(t==null?void 0:t.y))&&(n!=null&&n.control.viewContainerManager)){const N=n.control.viewContainerManager.transformToScenePoint([T.x,T.y],n.viewId),I=e.get(o);I&&i==="start"?I[0]=N:I&&i==="end"&&(I[1]=N),u(D.Doing),K.emitMethod(q.MainEngine,R.SetPoint,{workId:$,pointMap:e,workState:D.Doing,viewId:n==null?void 0:n.viewId})}},100,{leading:!1}),S=L.throttle((w,v)=>{if(w.cancelable&&w.preventDefault(),n!=null&&n.control.worker.isBusy){p(!0),u(D.Pending);return}w.stopPropagation(),s(R.None),u(D.Done);const T={x:v.x,y:v.y};if(n!=null&&n.control.viewContainerManager){const N=n.control.viewContainerManager.transformToScenePoint([T.x,T.y],n.viewId),I=e.get(o);I&&i==="start"?I[0]=N:I&&i==="end"&&(I[1]=N),n!=null&&n.control.room&&(n.control.room.disableDeviceInputs=!1),K.emitMethod(q.MainEngine,R.SetPoint,{workId:$,pointMap:e,workState:D.Done,viewId:n==null?void 0:n.viewId})}},100,{leading:!1});return g.createElement(ve,{disabled:d,position:c,onStart:y,onDrag:m,onStop:S},g.createElement("div",{className:"appliance-plugin-point-draggable-btn",style:r?{left:0,top:0}:void 0}))},$M=a=>{const{className:o}=a,{floatBarData:t,mananger:e}=g.useContext(mt),[i,s]=g.useState(),[n,r]=g.useState(),[c,l]=g.useState(new Map);g.useEffect(()=>{const d=[];if(e&&(t!=null&&t.points)){const p=e.viewId;if(e.control.viewContainerManager.getView(p))for(const y of t.points){const m=e.control.viewContainerManager.transformToOriginPoint(y,p);d.push(m)}t!=null&&t.selectIds&&t.selectIds.length===1&&(c.set(t.selectIds[0],t.points),l(c))}d[0]&&s({x:d[0][0],y:d[0][1]}),d[1]&&r({x:d[1][0],y:d[1][1]})},[e,t==null?void 0:t.points,t==null?void 0:t.selectIds,c]);const h=g.useMemo(()=>i&&(t!=null&&t.selectIds)?g.createElement(ji,{pos:i,type:"start",id:t.selectIds[0],pointMap:c}):null,[i,t==null?void 0:t.selectIds,c]),u=g.useMemo(()=>n&&(t!=null&&t.selectIds)?g.createElement(ji,{pos:n,type:"end",id:t.selectIds[0],pointMap:c}):null,[n,t==null?void 0:t.selectIds,c]);return g.createElement("div",{className:`${o}`},h,u)},QM=g.forwardRef((a,o)=>{const{floatBarData:t,operationType:e}=g.useContext(mt),i=g.useMemo(()=>(t==null?void 0:t.scaleType)!==ct.all||e===R.RotateNode?null:g.createElement(YM,null),[t,e]),s=g.useMemo(()=>(t==null?void 0:t.scaleType)!==ct.both||e===R.RotateNode?null:g.createElement(WM,null),[t,e]),n=g.useMemo(()=>(t==null?void 0:t.scaleType)!==ct.proportional||e===R.RotateNode?null:g.createElement(UM,null),[t,e]),r=g.useMemo(()=>(t==null?void 0:t.scaleType)===ct.none&&(t!=null&&t.canLock)?g.createElement(BM,null):null,[t]);return g.createElement("div",{ref:o,style:t?{transform:`translate(${t.x}px,${t.y}px)`,width:t.w,height:t.h,pointerEvents:"none"}:void 0},r,i,s,n,a.children)}),GM=g.forwardRef((a,o)=>{var d;const{floatBarData:t,operationType:e,mananger:i}=g.useContext(mt),{editors:s,activeTextId:n}=a,r=g.useMemo(()=>{var p;return t!=null&&t.canRotate&&((p=t==null?void 0:t.selectIds)==null?void 0:p.length)===1&&(e===R.None||e===R.RotateNode)?g.createElement(VM,{className:kt.RotateBtn}):null},[t==null?void 0:t.canRotate,(d=t==null?void 0:t.selectIds)==null?void 0:d.length,e]),c=g.useMemo(()=>((t==null?void 0:t.scaleType)===ct.all||(t==null?void 0:t.scaleType)===ct.proportional)&&(e===R.None||e===R.ScaleNode)&&L.isNumber(t==null?void 0:t.x)&&L.isNumber(t==null?void 0:t.y)?g.createElement(HM,{className:kt.ResizeBtn}):null,[t==null?void 0:t.scaleType,e,t==null?void 0:t.x,t==null?void 0:t.y]),l=g.useMemo(()=>(t==null?void 0:t.scaleType)===ct.both&&(e===R.None||e===R.SetPoint)?g.createElement($M,{className:kt.ResizeTowBox}):null,[t==null?void 0:t.scaleType,e]),h=g.useMemo(()=>{const p=(t==null?void 0:t.selectIds)||[];return s&&i&&p&&L.isNumber(t==null?void 0:t.x)&&L.isNumber(t==null?void 0:t.y)&&L.isNumber(t==null?void 0:t.w)&&L.isNumber(t==null?void 0:t.h)?g.createElement(Ds,{box:{x:t==null?void 0:t.x,y:t==null?void 0:t.y,w:t==null?void 0:t.w,h:t==null?void 0:t.h},manager:i,selectIds:p,activeTextId:n,editors:s}):null},[t==null?void 0:t.selectIds,t==null?void 0:t.x,t==null?void 0:t.y,t==null?void 0:t.w,t==null?void 0:t.h,s,i,n]),u=g.useMemo(()=>e===R.None&&L.isNumber(t==null?void 0:t.x)&&L.isNumber(t==null?void 0:t.y)&&L.isNumber(t==null?void 0:t.w)&&L.isNumber(t==null?void 0:t.h)?g.createElement("div",{className:kt.FloatBarBtn,style:{left:t==null?void 0:t.x,top:t==null?void 0:t.y,width:t.w,height:t.h}},g.createElement(Ls,{position:{x:t.x,y:t.y},textOpt:t==null?void 0:t.textOpt,noLayer:t==null?void 0:t.isLocked})):null,[t==null?void 0:t.x,t==null?void 0:t.y,t==null?void 0:t.w,t==null?void 0:t.h,t==null?void 0:t.textOpt,t==null?void 0:t.isLocked,e]);return g.createElement("div",{className:kt.FloatBar,onMouseOver:()=>{i==null||i.control.worker.blurCursor(i.viewId)}},g.createElement(QM,{ref:o},g.createElement(g.Fragment,null,h)),g.createElement(FM,{onClickHandle:p=>{if(i&&(s!=null&&s.size)){const f=i.getPoint(p.nativeEvent);f&&i.control.textEditorManager.computeTextActive(f,i.viewId)}}}),r,c,l,u)}),ZM=g.memo(GM,(a,o)=>!!L.isEqual(a,o)),qM="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAYAAADFeBvrAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAYISURBVHgB7ZpNSCtXFIBPEuvz+dMGpYUKD/sWFX+Qti6kK7Hqpm6e9q0rIoIUFUShPLV10VZx4+JZqa9v20LBhdq9fyBUCtKNPH8qYl2IOw3G38Rkek4y15y5uTOZJDOWggcOSSYzN/ebc+45554JwIM8iBCPyTEP+86T4vyMfsRN4b+nQTKIJp0vzuGvlpID7os8EQNEIBD4oKio6Bm9DwaDv/v9/n/076JgbtWUYPchwrW8qD7UnOvr6wFNkpubm+/wu7f0c7y6mrnlvQufxB0Iau7V1dX3BDA/P6/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GG4ZU+EWkgNBzN1qamq+pAMTExPgFMzW1tZrhHkFyWE5KxgSszx0527RaDRmOSpRshEOU11dPQPG8CwHARHJlMnTSrwSRFIlfXt7m3V5ngJGuJtqzaQtZkFBVNJezN5ZAdmwjKo2k9tVtrcI3OXk4tPgcg7ChCDZ1URgMOu72Xa5VFHOkymQhWVU60YVmjN6wiC7k6p+S1syCACOwJBYFaexV+yhBekNPsMBO6KAEeE4BMaCU67RsoYhSbXgaT//ht709vZCaWmp6YkEbLFmVJWzas04+iBL7EKpm0J7duqu0B7+CTUpNJuyvb1NCfMj1CqI9wLKUOlOUMeG+gGFkHii4HizUF4z/KFUrPsJ8WbEIyx7nnZ0dDynME6BAuce09iFHo+GrnmGltltb2//E4wVAN82y7vOjKOZXSBhJdHNiT3TYWD8OY2PTUJkdd7MkJMnT5wZVQF2RFX6yBMUdzPMvvfqxz3sXHF+GNT9ANXit/10O1sgHkZvdQAOKvs9B5L7ARELGAAXLSTvM8QExTE+YbHe+HURhZp1aRyF4CJXClbbWwGketgkW9VsY+YaiBCVhfgE+XvxRwgZSM4jUVCDZFQ9pytmXR8hUTB2gnidx4XffVWydN0yQjwmx/jkAZJBrIBI5J7ZvQGZWUgVSuU/EqmOAzicKNMVu816DdRWUV1/7xAP8n+SfwF3Du3NF2sYhwAAAABJRU5ErkJggg==",JM="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",XM="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",KM="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAYAAADFeBvrAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAgrSURBVHgB7ZprTBRXFIDP7gIt8lQppTwE5V0KaAn6o1pqNGkDDTEmTUhsgKRp+gNJw68CFk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c3+BgaZyqAISjOYxSMVvXsBTNlzdiNQDgRao2AtK3pjggpmrqbGpqSsLPIN/dv38/gaBwUjTshMHcvn27JyUlpRmc5xpPMD599LIYnLNyUKKndKjGxsakXbt2deMCLIE8IVvs0YRM1fjdu3d/wrXN5+BcnzEgvor2uN3rjzAYMp5lPEoQlE5fA0fWo8GfhlCbKVFQ1pKNIfzcOHH58mWqaimVUwJI0+6n59D4pIlzmdZPMPiZzXjDjX47Le5g0Uu8x2zgPqWyKpjVe7x3+AUbq9NYjQbgp2dsBud5o8TP7d5kHAWcQchQfoEmLgn8HjOiBIF7o5hI1x6CEbLNP3bdqYAF44JzyWLzcN1i8DcT/o3awbm8Fz3DAy2A62INwPV/E3wWdx5inmBHuwChCBD6R2JwHge80TIQRQLjt7e8DTkGZgfX8cUMZTDAteFDkveaIlzjX9ySQs8X18r2t2VHUURPKoICmDR+eCO9aSdmOIub3/w9RgpgUpiJhvraXpa6jZKHGEqyusw0GLFzX+5RhN/8kYnMSNMMfyH/V/kHST6OYVElTPAAAAAASUVORK5CYII=";class _M extends g.Component{constructor(t){super(t);M(this,"renderAvatar",t=>{var i;const e=`rgb(${t.memberState.strokeColor[0]}, ${t.memberState.strokeColor[1]}, ${t.memberState.strokeColor[2]})`;if(this.detectAvatar(t)){const s=this.getCursorName(t);return g.createElement("img",{className:"cursor-selector-avatar",style:{width:s?19:28,height:s?19:28,position:s?"initial":"absolute",borderColor:s?"white":e,marginRight:s?4:0},src:(i=t.payload)==null?void 0:i.avatar,alt:"avatar"})}else return null});M(this,"getOpacity",t=>{const e=this.getCursorName(t),i=this.detectAvatar(t);return e===void 0&&i===void 0?0:1});M(this,"getCursorName",t=>{if(t.payload)return t.payload.nickName||t.payload.cursorName||t.payload.uid});M(this,"getThemeClass",t=>t.payload&&t.payload.theme?"cursor-inner-mellow":"cursor-inner");M(this,"getCursorBackgroundColor",t=>{const e=this.getCursorName(t);return t.payload&&t.payload.cursorBackgroundColor?t.payload.cursorBackgroundColor:e?`rgb(${t.memberState.strokeColor[0]}, ${t.memberState.strokeColor[1]}, ${t.memberState.strokeColor[2]})`:void 0});M(this,"getCursorTextColor",t=>t.payload&&t.payload.cursorTextColor?t.payload.cursorTextColor:"#FFFFFF");M(this,"getCursorTagBackgroundColor",t=>t.payload&&t.payload.cursorTagBackgroundColor?t.payload.cursorTagBackgroundColor:this.getCursorBackgroundColor(t));M(this,"detectAvatar",t=>!!(t.payload&&t.payload.avatar));M(this,"renderTag",t=>{if(t.payload&&t.payload.cursorTagName)return g.createElement("span",{className:"cursor-tag-name",style:{backgroundColor:this.getCursorTagBackgroundColor(t)}},t.payload.cursorTagName)})}render(){const{roomMember:t}=this.props,e=this.getCursorName(t);switch(t.memberState.currentApplianceName){case st.pencil:return g.createElement("div",{className:"cursor-box"},g.createElement("div",{className:"cursor-mid cursor-pencil-offset",style:{transform:"translate(-50%, -90%)",marginLeft:"10px"}},g.createElement("div",{className:"cursor-name"},g.createElement("div",{style:{opacity:this.getOpacity(t),backgroundColor:this.getCursorBackgroundColor(t),color:this.getCursorTextColor(t)},className:this.getThemeClass(t)},this.renderAvatar(t),e,this.renderTag(t))),g.createElement("div",null,g.createElement("img",{className:"cursor-pencil-image",src:qM,alt:"pencilCursor"}))));case st.eraser:case st.pencilEraser:return g.createElement("div",{className:"cursor-box"},g.createElement("div",{className:"cursor-mid cursor-pencil-offset",style:{transform:"translate(-50%, -90%)",marginLeft:"0px"}},g.createElement("div",{className:"cursor-name"},g.createElement("div",{style:{opacity:this.getOpacity(t),backgroundColor:this.getCursorBackgroundColor(t),color:this.getCursorTextColor(t)},className:this.getThemeClass(t)},this.renderAvatar(t),e,this.renderTag(t))),g.createElement("div",null,g.createElement("img",{className:"cursor-pencil-image",src:KM,alt:"pencilEraser"}))));case st.text:return g.createElement("div",{className:"cursor-box"},g.createElement("div",{className:"cursor-mid cursor-pencil-offset",style:{transform:"translate(-50%, -65%)",marginLeft:"0px"}},g.createElement("div",{className:"cursor-name"},g.createElement("div",{style:{opacity:this.getOpacity(t),backgroundColor:this.getCursorBackgroundColor(t),color:this.getCursorTextColor(t)},className:this.getThemeClass(t)},this.renderAvatar(t),e,this.renderTag(t))),g.createElement("div",null,g.createElement("img",{className:"cursor-arrow-image",src:XM,alt:"textCursor"}))));case st.rectangle:case st.arrow:case st.straight:case st.shape:case st.ellipse:return g.createElement("div",{className:"cursor-box"},g.createElement("div",{className:"cursor-mid cursor-pencil-offset",style:{transform:"translate(-50%, -65%)",marginLeft:"0px"}},g.createElement("div",{className:"cursor-name"},g.createElement("div",{style:{opacity:this.getOpacity(t),backgroundColor:this.getCursorBackgroundColor(t),color:this.getCursorTextColor(t)},className:this.getThemeClass(t)},this.renderAvatar(t),e,this.renderTag(t))),g.createElement("div",null,g.createElement("img",{className:"cursor-arrow-image",src:JM,alt:"shapeCursor"}))));default:return null}}}const ty=a=>{const{className:o,info:t}=a,{roomMember:e,...i}=t||{};return g.createElement("div",{className:`${o}`,style:i?{transform:`translate(${i.x}px, ${i.y}px)`}:{display:"none"}},e&&g.createElement(_M,{roomMember:e}))},ey=a=>{const{className:o,manager:t}=a,[e,i]=g.useState();g.useEffect(()=>(t.internalMsgEmitter.on([q.Cursor,t.viewId],s),()=>{t.internalMsgEmitter.off([q.Cursor,t.viewId],s)}),[t]);function s(r){i(r)}return g.useMemo(()=>{if(e!=null&&e.length){const r=e.map(c=>{var l;return c.roomMember?g.createElement(ty,{key:(l=c.roomMember)==null?void 0:l.memberId,className:o,info:c}):null});return g.createElement(g.Fragment,null,r)}return null},[e])},oy=a=>{const{viewId:o,miniMapCanvas:t,highlightColor:e,miniMapManager:i,contianer:s}=a,[n,r]=g.useState();g.useEffect(()=>(c(),i.listener.addListener([o,"viewCameraUpate"],c),i.listener.emitAsync([o,"miniMapCreate"],!0),()=>{i.listener.removeListener([o,"viewCameraUpate"],c)}),[]);const c=()=>{const u=i.maps.get(o);u&&l(u.miniMapCamera,u.viewCamera)},l=(u,d)=>{const{width:p,height:f}=s.getBoundingClientRect(),y=Math.min(p/u.width,f/u.height),m=d.width/d.scale,S=d.height/d.scale,w=[d.centerX,d.centerY],v=[u.centerX,u.centerY],T=[w[0]-v[0],w[1]-v[1]],N=Math.min(u.scale*y,u.scale*y),I=[T[0]*N,T[1]*N,m,S,N];r(I)},h=u=>{var d;if(i.control.renderControl.isWriteable()){const p=u.nativeEvent.target||u.nativeEvent.srcElement;if(p&&u.nativeEvent&&n){const{width:f,height:y}=p.getBoundingClientRect(),[m,S]=[f/2,y/2],[w,v]=[(u.nativeEvent.offsetX-m)/n[4],(u.nativeEvent.offsetY-S)/n[4]],T=i.maps.get(o);if(T!=null&&T.viewCamera){const[N,I]=[T.miniMapCamera.centerX+w,T.miniMapCamera.centerY+v];(d=i.control.room)==null||d.moveCamera({centerX:N,centerY:I,animationMode:"immediately"})}}}};return g.createElement("div",{style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",pointerEvents:"auto"},onClick:h},g.createElement("canvas",{style:{pointerEvents:"none"},ref:t}),n&&g.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 ${e}`,transform:`translate(calc(-50% + ${n[0]}px), calc(-50% + ${n[1]}px))`,pointerEvents:"none"}}))},iy=a=>{const{miniMapManager:o,active:t,className:e}=a,i=g.useMemo(()=>{const s=o.maps;if(t){const n=s.get(t);if(n){const{miniMapCamera:r,viewCamera:c,...l}=n;if(l.contianer&&r&&c){const h=o.highlightColor;return oo.createPortal(g.createElement(oy,{viewId:t,...l,highlightColor:h,miniMapManager:o}),l.contianer)}}}return null},[t,o]);return g.createElement("div",{className:e},i)},mt=g.createContext({mananger:void 0,floatBarColors:[],floatBarData:void 0,dpr:1,angle:0,operationType:R.None,scale:[1,1],setAngle:()=>{},setOperationType:()=>{},setFloatBarData:()=>{}});class Qo extends g.Component{constructor(t){var e,i;super(t);M(this,"setAngle",t=>{this.setState({angle:t})});M(this,"setOperationType",t=>{this.setState({operationType:t})});this.state={floatBarData:void 0,showFloatBar:!1,dpr:1,angle:0,operationType:R.None,scale:[1,1],editors:this.editors,activeTextId:(e=this.props.mananger.control.textEditorManager)==null?void 0:e.activeId,activeMiniMapViewId:(i=this.props.mananger.control.miniMapManager)==null?void 0:i.activeViewId}}get editors(){return Jt(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(t){this.setState({activeMiniMapViewId:t})}showFloatBar(t,e){const i=t&&e&&{...this.state.floatBarData,...e}||void 0;this.setState({showFloatBar:t,floatBarData:i,angle:0})}setActiveTextEditor(t){this.setState({activeTextId:t,editors:this.editors})}setFloatBarData(t){this.state.floatBarData&&this.setState({floatBarData:{...this.state.floatBarData,...t}})}render(){var e,i,s,n,r,c,l;const t=!!((i=(e=this.props.mananger.control)==null?void 0:e.room)!=null&&i.floatBarOptions);return g.createElement("div",{className:kt.Container},!this.props.mananger.control.hasOffscreenCanvas()&&g.createElement("div",{className:kt.CanvasBox,ref:this.props.refs.canvasContainerRef})||g.createElement("div",{className:kt.CanvasBox,onMouseDown:h=>{h.cancelable&&h.preventDefault(),h.stopPropagation()},onTouchStart:h=>{h.stopPropagation()},onMouseMove:h=>{this.props.mananger.cursorMouseMove(h)}},g.createElement("canvas",{id:"bgCanvas",ref:this.props.refs.canvasBgRef,style:{width:"100%",height:"100%"}}),g.createElement("canvas",{id:"serviceCanvas",className:kt.FloatCanvas,ref:this.props.refs.canvasServiceFloatRef,style:{width:"100%",height:"100%"}}),g.createElement("canvas",{id:"localCanvas",className:kt.FloatCanvas,ref:this.props.refs.canvasFloatRef,style:{width:"100%",height:"100%"}}),g.createElement("div",{id:"subLocalCanvas",className:kt.CanvasBoxSub,ref:this.props.refs.subLocalCanvasContainerRef}),g.createElement("canvas",{id:"topCanvas",className:kt.TopFloatCanvas,ref:this.props.refs.canvasTopRef,style:{width:"100%",height:"100%"}})),!this.props.mananger.control.hasOffscreenCanvas()&&this.props.refs.snapshotContainerRef&&g.createElement("div",{className:kt.SnapshotBox,ref:this.props.refs.snapshotContainerRef})||null,g.createElement(mt.Provider,{value:{mananger:this.props.mananger,floatBarColors:t&&((r=(n=(s=this.props.mananger.control)==null?void 0:s.room)==null?void 0:n.floatBarOptions)==null?void 0:r.colors)||[],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&&g.createElement(ZM,{ref:this.props.refs.floatBarRef,editors:this.state.editors,activeTextId:this.state.activeTextId})||null,((c=this.state.editors)==null?void 0:c.size)&&g.createElement(RM,{className:kt.TextEditorContainer,showFloatBtns:t,manager:this.props.mananger,selectIds:((l=this.state.floatBarData)==null?void 0:l.selectIds)||[],editors:this.state.editors,activeTextId:this.state.activeTextId})||null),g.createElement(ey,{className:kt.CursorBox,manager:this.props.mananger}),g.createElement(iy,{className:kt.MiniMapBox,active:this.state.activeMiniMapViewId,miniMapManager:this.props.mananger.control.miniMapManager}))}}class sy extends bs{constructor(t,e){super(t,e);M(this,"width",1e3);M(this,"height",1e3);M(this,"dpr",1);M(this,"vDom");M(this,"eventTragetElement");M(this,"snapshotContainerRef");M(this,"canvasContainerRef",g.createRef());M(this,"subLocalCanvasContainerRef",g.createRef());M(this,"canvasTopRef",g.createRef());M(this,"canvasServiceFloatRef",g.createRef());M(this,"canvasFloatRef",g.createRef());M(this,"canvasBgRef",g.createRef());M(this,"floatBarRef",g.createRef());M(this,"containerOffset",{x:0,y:0});this.control.hasOffscreenCanvas()||(this.snapshotContainerRef=g.createRef())}setCanvassStyle(){if(this.eventTragetElement){const t=this.eventTragetElement.offsetWidth||this.width,e=this.eventTragetElement.offsetHeight||this.height;t&&e&&this.canvasContainerRef.current&&(t!==this.width||e!==this.height)&&(this.dpr=te(),this.width=t,this.height=e,this.canvasContainerRef.current.style.width=`${t}px`,this.canvasContainerRef.current.style.height=`${e}px`),t&&e&&this.snapshotContainerRef&&this.snapshotContainerRef.current&&(t!==this.width||e!==this.height)&&(this.dpr=te(),this.width=t,this.height=e),t&&e&&this.canvasBgRef.current&&(t!==this.width||e!==this.height)&&(this.dpr=te(this.canvasBgRef.current.getContext("2d")),this.width=t,this.height=e,this.canvasBgRef.current.width=t*this.dpr,this.canvasBgRef.current.height=e*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=t*this.dpr,this.canvasFloatRef.current.height=e*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=t*this.dpr,this.canvasServiceFloatRef.current.height=e*this.dpr),this.canvasTopRef.current&&(this.canvasTopRef.current.width=t*this.dpr,this.canvasTopRef.current.height=e*this.dpr))}}destroy(){if(super.destroy(),this.eventTragetElement){const t=this.eventTragetElement.parentElement;if(t){const e=t.querySelectorAll(".appliance-plugin-main-view-displayer");for(const i of e)i.remove()}}}createMainViewDisplayer(t){const e=document.createElement("div");return e.className="appliance-plugin-main-view-displayer",t.appendChild(e),this.eventTragetElement=t.children[0],this.containerOffset=this.getContainerOffset(this.eventTragetElement,this.containerOffset),this.bindToolsClass(),oo.render(g.createElement(Qo,{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 ny extends Qg{constructor(t,e,i){super(t,e,i);M(this,"dpr",1);M(this,"width",1e3);M(this,"height",1e3);M(this,"vDom");M(this,"eventTragetElement");M(this,"canvasContainerRef",g.createRef());M(this,"subLocalCanvasContainerRef",g.createRef());M(this,"canvasTopRef",g.createRef());M(this,"canvasServiceFloatRef",g.createRef());M(this,"canvasFloatRef",g.createRef());M(this,"canvasBgRef",g.createRef());M(this,"floatBarRef",g.createRef());M(this,"containerOffset",{x:0,y:0})}setCanvassStyle(){if(this.eventTragetElement){if(this.canvasContainerRef.current){const t=this.eventTragetElement.offsetWidth||this.width,e=this.eventTragetElement.offsetHeight||this.height;t&&e&&(t!==this.width||e!==this.height)&&(this.width=t,this.height=e,this.dpr=te(),this.canvasContainerRef.current.style.width=`${t}px`,this.canvasContainerRef.current.style.height=`${e}px`)}if(this.canvasBgRef.current){this.dpr=te(this.canvasBgRef.current.getContext("2d"));const t=this.eventTragetElement.offsetWidth||this.width,e=this.eventTragetElement.offsetHeight||this.height;t&&e&&(t!==this.width||e!==this.height)&&(this.width=t,this.height=e,this.canvasBgRef.current.width=t*this.dpr,this.canvasBgRef.current.height=e*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=t*this.dpr,this.canvasFloatRef.current.height=e*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=t*this.dpr,this.canvasServiceFloatRef.current.height=e*this.dpr),this.canvasTopRef.current&&(this.canvasTopRef.current.width=t*this.dpr,this.canvasTopRef.current.height=e*this.dpr))}}}createAppViewDisplayer(t,e){const i=document.createElement("div");return i.className="appliance-plugin-app-view-displayer",e.appendChild(i),this.eventTragetElement=e.children[0],this.containerOffset=this.getContainerOffset(this.eventTragetElement,this.containerOffset),this.bindToolsClass(),oo.render(g.createElement(Qo,{viewId:t,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 At extends we{constructor(t){super(t);M(this,"focuedViewId");M(this,"focuedView");M(this,"control");M(this,"tmpFocusedViewId");M(this,"checkScaleTimer");M(this,"onMainViewRelease",async t=>{this.control.textEditorManager.clear(It,!0),this.mainViewDestroy(t),await new Promise(i=>{setTimeout(()=>{i(!0)},0)}),this.onMainViewMounted(t);const e=this.control.getSnapshootData("memberState");this.control.room&&this.control.onMemberChange(e),this.control.clearSnapshootData()});M(this,"mainViewDestroy",t=>{var e;if(this.mainView&&this.mainView.displayer){this.mainView.displayer.destroy();const i=t.divElement;if(i){const s=i.getElementsByClassName("appliance-plugin-main-view-displayer");for(const n of s)n.remove()}if(this.mainView.container&&i!==this.mainView.container){const s=this.mainView.container.getElementsByClassName("appliance-plugin-main-view-displayer");for(const n of s)n.remove()}(e=this.control.worker)==null||e.destroyViewWorker(this.mainView.id,!0),this.mainView.displayer.destroy(),this.mainView=void 0}});M(this,"onMainViewMounted",t=>{const e=t.divElement;if(!e||!t.focusScenePath||!(t.focusScenePath||t.scenePath))return;const s=new sy(this.control,Nt.InternalMsgEmitter),n=t.size.width||s.width,r=t.size.height||s.height,l={dpr:s.dpr,originalPoint:[n/2,r/2],offscreenCanvasOpt:{...At.defaultScreenCanvasOpt,width:n,height:r},layerOpt:{...At.defaultLayerOpt,width:n,height:r},cameraOpt:{...At.defaultCameraOpt,width:n,height:r}},{scale:h,...u}=t.camera;l.cameraOpt={...l.cameraOpt,...u,scale:h===1/0?1:h},this.focuedViewId=It,this.createMianView({id:It,container:e,displayer:s,focusScenePath:t.focusScenePath,cameraOpt:l.cameraOpt,viewData:t}),this.focuedView=this.mainView,s.createMainViewDisplayer(e),t.callbacks.on("onSizeUpdated",this.onMainViewSizeUpdated),t.callbacks.on("onCameraUpdated",this.onMainViewCameraUpdated),t.callbacks.on("onActiveHotkey",this.onActiveHotkeyChange.bind(this))});M(this,"onMainViewSizeUpdated",async()=>{await new Promise(t=>{setTimeout(()=>{t(!0)},0)}),this.mainView&&this.mainView.viewData&&this.updateMainViewCamera()});M(this,"onMainViewCameraUpdated",async()=>{await new Promise(t=>{setTimeout(()=>{t(!0)},0)}),this.updateMainViewCamera()});M(this,"updateMainViewCamera",()=>{if(this.mainView&&this.mainView.viewData){const t=this.mainView.viewData.camera,e=this.mainView.cameraOpt;if(e){const i=e.width,s=e.height,{width:n,height:r}=this.mainView.viewData.size;(n!==i||r!==s)&&this.mainView.displayer.updateSize();const c=t.scale===1/0?1:t.scale,l=t.centerX||0,h=t.centerY||0,u={...e,scale:c,centerX:l,centerY:h,width:n,height:r};L.isEqual(e,u)||(this.mainView.cameraOpt=u),this.checkScaleTimer&&t.scale==1/0&&(clearTimeout(this.checkScaleTimer),this.checkScaleTimer=void 0),!this.checkScaleTimer&&t.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:h,animationMode:"immediately"}),this.checkScaleTimer=void 0},500))}}});M(this,"onAppViewMounted",async t=>{var d;const{appId:e,view:i}=t,s=i.divElement;if(!s||!i.focusScenePath)return;const n=this.appViews.get(e);if(n&&n.displayer){let p=s.getElementsByClassName("appliance-plugin-app-view-displayer");for(const f of p)f.remove();if(n.container&&n.container!==s){p=n.container.getElementsByClassName("appliance-plugin-app-view-displayer");for(const f of p)f.remove()}this.destroyAppView(t.appId,!0),(d=this.control.worker)==null||d.destroyViewWorker(e,!0),await new Promise(f=>{setTimeout(()=>{f(!0)},0)})}const r=new ny(e,this.control,Nt.InternalMsgEmitter),c=i.size.width||r.width,l=i.size.height||r.height,u={dpr:r.dpr,originalPoint:[c/2,l/2],offscreenCanvasOpt:{...At.defaultScreenCanvasOpt,width:c,height:l},layerOpt:{...At.defaultLayerOpt,width:c,height:l},cameraOpt:{...At.defaultCameraOpt,...i.camera,width:c,height:l}};if(this.createAppView({id:e,container:s,displayer:r,cameraOpt:u.cameraOpt,focusScenePath:i.focusScenePath,viewData:i}),r.createAppViewDisplayer(e,s),i.callbacks.on("onSizeUpdated",this.onAppViewSizeUpdated.bind(this,e)),i.callbacks.on("onCameraUpdated",this.onAppViewCameraUpdated.bind(this,e)),i.callbacks.on("onActiveHotkey",this.onActiveHotkeyChange.bind(this)),this.tmpFocusedViewId===e){const p=this.control.worker.getLocalWorkViewId();p&&p!==e?this.setFocuedViewId(p):this.setFocuedViewId(e),this.tmpFocusedViewId=void 0}setTimeout(()=>{this.onAppViewCameraUpdated(e)},0)});M(this,"onAppViewSizeUpdated",async t=>{await new Promise(i=>{setTimeout(()=>{i(!0)},0)});const e=this.appViews.get(t);e&&e.viewData&&this.updateAppCamera(t)});M(this,"onAppViewCameraUpdated",async t=>{await new Promise(e=>{setTimeout(()=>{e(!0)},0)}),this.updateAppCamera(t)});M(this,"updateAppCamera",t=>{const e=this.appViews.get(t);if(e&&e.viewData){const i=e.viewData.camera,s=e.cameraOpt;if(s){const{width:n,height:r}=e.viewData.size,c=s.width,l=s.height;(n!==c||r!==l)&&e.displayer.updateSize();const h=i.scale===1/0?1:i.scale,u=i.centerX||0,d=i.centerY||0,p={...s,scale:h,centerX:u,centerY:d,width:n,height:r};L.isEqual(p,s)||(e.cameraOpt=p)}}});this.control=t.control}getViewInitData(t){var i;const e=this.getView(t);if(e){const{width:s,height:n,dpr:r}=e.displayer;(i=this.control.pluginOptions.canvasOpt)!=null&&i.contextType&&(At.defaultScreenCanvasOpt.contextType=this.control.pluginOptions.canvasOpt.contextType);const c={dpr:r,originalPoint:[s/2,n/2],offscreenCanvasOpt:{...At.defaultScreenCanvasOpt,width:s,height:n},layerOpt:{...At.defaultLayerOpt,width:s,height:n},cameraOpt:{...At.defaultCameraOpt,width:s,height:n}};if(e.viewData){const{scale:l,...h}=e.viewData.camera;c.cameraOpt={...c.cameraOpt,...h,scale:l===1/0?1:l}}return c}}async mountView(t){var i,s;const e=this.getView(t);if(e){t===((i=this.mainView)==null?void 0:i.id)&&(this.control.cursor.activeCollector(),await this.control.activeWorker());const n=this.getViewInitData(t);if(n&&((s=this.control.worker)==null||s.createViewWorker(t,n)),e.focusScenePath&&this.control.collector){if(this.control.collector.authStorage){const{renderAuth:r,pageAuth:c}=this.control.collector.authStorage;if(r){const l=r[t];if(l){const{render:h,hide:u,clear:d}=l;this.control.renderControl.syncRenderUids(t,h,u,d);return}}if(c){const l=c[t];if(l){this.control.renderControl.syncPageAuth(t,l,!0);return}}}this.control.worker.pullServiceData(t,e.focusScenePath,{isAsync:!0,useAnimation:!1})}}}listenerWindowManager(t){t.emitter.on("focusedChange",e=>{const i=e||It;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}),t.emitter.on("mainViewScenePathChange",e=>{this.control.onSceneChange(e,It)}),t.emitter.on("onMainViewMounted",this.onMainViewMounted),t.emitter.on("onAppViewMounted",this.onAppViewMounted),t.emitter.on("onMainViewRebind",this.onMainViewRelease),t.emitter.on("onBoxClose",e=>{this.appViews.get(e.appId)&&(this.destroyAppView(e.appId),this.control.worker.destroyViewWorker(e.appId))}),t.emitter.on("onAppScenePathChange",e=>{const{appId:i,view:s}=e;this.control.onSceneChange(s.focusScenePath,i)}),t.emitter.on("appsChange",e=>{for(const i of this.appViews.keys())e.includes(i)||(this.destroyAppView(i),this.control.worker.destroyViewWorker(i,!0))})}onActiveHotkeyChange(t){this.control.hotkeyManager.onActiveHotkey(t)}}class Xt extends Nt{constructor(t){super(t);M(this,"windowManager");M(this,"viewContainerManager");const e={control:this,internalMsgEmitter:Nt.InternalMsgEmitter,publicMsgEmitter:Nt.PublicMsgEmitter};this.viewContainerManager=new At(e)}init(){}destroy(){var t,e,i,s;this.roomMember.destroy(),(t=this.collector)==null||t.destroy(),(e=this.worker)==null||e.destroy(),(i=this.viewContainerManager)==null||i.destroy(),(s=this.cursor)==null||s.destroy()}activePlugin(){this.collector&&(this.collector.addAuthStateListener((t,e)=>{t&&Object.keys(t).forEach(i=>{var n;const s=(n=t[i])==null?void 0:n.newValue;this.renderControl.syncRenderUids(i,s==null?void 0:s.render,s==null?void 0:s.hide,s==null?void 0:s.clear)}),e&&Object.keys(e).forEach(i=>{var n;const s=(n=e[i])==null?void 0:n.newValue;this.renderControl.syncPageAuth(i,s)})}),this.collector.addStorageStateListener(t=>{var r,c;if((r=this.collector)!=null&&r.storage&&Object.keys(this.collector.storage).length===0){(c=this.worker)==null||c.clearViewScenePath(It,!0);return}const{diffView:e,diffScenePath:i,diffData:s}=t,n=new Map;if(e){let l;Object.keys(e).forEach(h=>{var d;const u=e[h];if(u&&!u.newValue)(d=this.worker)==null||d.clearViewScenePath(h,!0),u.oldValue&&(l=u.oldValue);else if(u&&u.newValue){for(const p of Object.keys(u.newValue))this.worker.pullServiceData(h,p,{isAsync:!1,useAnimation:!0});l=u.newValue}if(l)for(const p of Object.values(l)){const f=new Set;for(const y of Object.keys(p))y&&f.add(y);n.set(h,f)}})}if(i){let l;Object.keys(i).forEach(h=>{var d;const u=i[h];if(u&&u.viewId&&!u.newValue?((d=this.worker)==null||d.clearViewScenePath(u.viewId,!0),u.oldValue&&(l=u.oldValue)):u&&u.viewId&&u.newValue&&(this.worker.pullServiceData(u.viewId,h,{isAsync:!1,useAnimation:!0}),l=u.newValue),u!=null&&u.viewId&&l){const p=new Set;for(const f of Object.keys(l))f&&p.add(f),n.set(u.viewId,p)}})}s&&Object.keys(s).forEach(l=>{var u,d;const h=s[l];if(h){const{viewId:p}=h,f=n.get(p)||new Set;f.add(l),n.set(p,f),(u=this.worker)==null||u.onServiceDerive(l,h),(d=this.miniMapManager)==null||d.updateMiniMapCamera(p)}});for(const[l,h]of n.entries())Nt.InternalMsgEmitter.emit("excludeIds",[...h],l)}),this.room&&this.roomMember.onUidChangeHook(t=>{var e,i;if((e=this.collector)!=null&&e.serviceStorage){const s=[];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 h;return(h=this.collector)==null?void 0:h.isSelector(l)}).map(l=>({viewId:n.id,scenePath:n.focusScenePath,key:l}));c.length&&s.push(...c)}}),s.forEach(({key:n,viewId:r,scenePath:c})=>{var h,u;const l=(h=this.collector)==null?void 0:h.getUidFromKey(n);l&&!t.online.includes(l)&&((u=this.collector)==null||u.updateValue(n,void 0,{isAfterUpdate:!0,viewId:r,scenePath:c}))})}(i=this.cursor)==null||i.updateRoomMembers(t)}),this.worker.isActive&&this.viewContainerManager.getAllViews().forEach(t=>{t&&t.focusScenePath&&this.worker.pullServiceData(t.id,t.focusScenePath,{isAsync:!0,useAnimation:!1})}))}async activeWorker(){await this.worker.init()}setWindowManager(t){var e,i,s,n,r;this.windowManager=t,(i=(e=this.windowManager)==null?void 0:e.mainView)!=null&&i.divElement&&this.viewContainerManager.onMainViewMounted(this.windowManager.mainView),(r=(n=(s=this.windowManager.appManager)==null?void 0:s.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 V=class V extends et.InvisiblePlugin{constructor(){super(...arguments);M(this,"onPhaseChanged",t=>{var e;t===et.RoomPhase.Reconnecting&&((e=V.currentManager)==null||e.setSnapshootData())});M(this,"updateRoomWritable",()=>{var t;(t=V.currentManager)==null||t.onWritableChange(this.displayer.isWritable)});M(this,"roomStateChangeListener",async t=>{var e,i;t!=null&&t.roomMembers&&((e=V.currentManager)==null||e.onRoomMembersChange(t.roomMembers)),!(et.isRoom(this.displayer)&&!this.displayer.isWritable)&&t.memberState&&((i=V.currentManager)==null||i.onMemberChange(t.memberState))})}static async getInstance(t,e){!e.options.cdn.fullWorkerUrl&&!e.options.cdn.subWorkerUrl&&V.logger.error("[ApplianceMultiPlugin] you must adaptor options cdn fullWorkerUrl and subWorkerUrl");const i=t.displayer,s=i.callbacks.on,n=i.callbacks.off,r=i.callbacks.once,c=t.cleanCurrentScene,l=t.mainView.setMemberState;e!=null&&e.logger&&(V.logger=e.logger),e.options&&(V.options={...Lt,...e.options});let h=i.getInvisiblePlugin(V.kind);h||(h=await V.createApplianceMultiPlugin(i,V.kind)),i&&h&&V.createCurrentManager(t,V.options,h),h&&V.currentManager&&(V.currentManager.bindPlugin(h),h.init(i));const u={displayer:i,windowManager:t,currentManager:V.currentManager,maxScreenshotWidth:10*1024,maxScreenshotHeight:10*1024,getBoundingRectAsync:async function(f){var S;V.logger.info("[ApplianceMultiPlugin] getBoundingRectAsync");const y=(t.mainView||i).getBoundingRect(f),m=await((S=V.currentManager)==null?void 0:S.getBoundingRect(f));return!y.width||!y.height?m:Fo(y,m)},screenshotToCanvasAsync:async function(f,y,m,S,w,v){var A;V.logger.info("[ApplianceMultiPlugin] screenshotToCanvasAsync");let T=m,N=S,I=w.scale;T>this.maxScreenshotWidth&&(I=this.maxScreenshotWidth/T*I,T=this.maxScreenshotWidth),N>this.maxScreenshotHeight&&(I=Math.min(this.maxScreenshotHeight/N*I,I),N=this.maxScreenshotHeight),w.scale=I;const x=document.createElement("canvas"),z=x.getContext("2d");x.width=T*(v||1),x.height=N*(v||1),z&&((t.mainView||i).screenshotToCanvas(z,y,T,N,w,v),f.drawImage(x,Math.floor((m-T)/2),Math.floor((S-N)/2),T*(v||1),N*(v||1),0,0,T,N),x.remove()),V.currentManager&&await((A=V.currentManager)==null?void 0:A.screenshotToCanvas(f,y,T,N,w,Math.floor((m-T)/2),Math.floor((S-N)/2)))},scenePreviewAsync:async function(f,y,m,S,w){V.logger.info("[ApplianceMultiPlugin] scenePreviewAsync"),(t.mainView||i).scenePreview(f,y,m,S,w);const v=document.createElement("img");v.className="appliance-plugin-fill-scene-snapshot-img",y.append(v),getComputedStyle(y).position||(y.style.position="relative"),V.currentManager&&await V.currentManager.scenePreview(f,v)},fillSceneSnapshotAsync:async function(f,y,m,S,w){V.logger.info("[ApplianceMultiPlugin] fillSceneSnapshotAsync"),y.innerHTML="",(t.mainView||i).fillSceneSnapshot(f,y,m,S,w);const v=m||t.mainView.size.width,T=S||t.mainView.size.height;let N=await this.getBoundingRectAsync(f);N||(N={originX:0,originY:0,width:v,height:T});let I=Math.max(N==null?void 0:N.width,v),x=Math.max(N==null?void 0:N.height,T),z=1;const A=I>v&&Math.min(v/I,z)||z,E=x>T&&Math.min(T/x,z)||z;A<=E?(I=A<1&&v||I,x=Math.floor(x*A)+1,z=A):A>E&&(x=E<1&&T||x,I=Math.floor(I*E)+1,z=E);const j={scale:z,centerX:N.originX+N.width/2,centerY:N.originY+N.height/2},O=document.createElement("canvas"),P=O.getContext("2d");O.width=I,O.height=x,P&&await this.screenshotToCanvasAsync(P,f,I,x,j,devicePixelRatio);const Y=document.createElement("img");Y.className="appliance-plugin-fill-scene-snapshot-img",Y.src=O.toDataURL(),Y.onload=()=>{O.remove()},Y.onerror=()=>{O.remove(),Y.remove()},y.append(Y),getComputedStyle(y).position||(y.style.position="relative")},_callbacksOn:function(f,y){V.logger.info(`[ApplianceMultiPlugin] callbacks ${f}`),(f==="onCanUndoStepsUpdate"||f==="onCanRedoStepsUpdate")&&et.isRoom(i)&&i.isWritable?Xt.InternalMsgEmitter.on(f,y):s.call(i.callbacks,f,y)},_callbacksOnce:function(f,y){V.logger.info(`[ApplianceMultiPlugin] callbacks ${f}`),(f==="onCanUndoStepsUpdate"||f==="onCanRedoStepsUpdate")&&et.isRoom(i)&&i.isWritable?Xt.InternalMsgEmitter.on(f,y):r.call(i.callbacks,f,y)},_callbacksOff:function(f,y){V.logger.info(`[ApplianceMultiPlugin] callbacks ${f}`),(f==="onCanUndoStepsUpdate"||f==="onCanRedoStepsUpdate")&&et.isRoom(i)&&i.isWritable?Xt.InternalMsgEmitter.off(f,y):n.call(i.callbacks,f,y)},canRedoSteps(){if(V.logger.info("[ApplianceMultiPlugin] canRedoSteps"),V.currentManager&&et.isRoom(i)&&!i.disableSerialization){const f=V.currentManager.viewContainerManager.focuedView,y=f==null?void 0:f.focusScenePath;if(f&&y)return f.displayer.commiter.redoStack.filter(m=>m.scenePath===y).length}return 0},canUndoSteps(){if(V.logger.info("[ApplianceMultiPlugin] canUndoSteps"),V.currentManager&&et.isRoom(i)&&!i.disableSerialization){const f=V.currentManager.viewContainerManager.focuedView,y=f==null?void 0:f.focusScenePath;if(f&&y)return f.displayer.commiter.undoStack.filter(m=>m.scenePath===y).length}return 0},undo:function(){return V.logger.info("[ApplianceMultiPlugin] undo"),V.currentManager&&et.isRoom(i)&&!i.disableSerialization?V.currentManager.viewContainerManager.undo():0},redo:function(){return V.logger.info("[ApplianceMultiPlugin] redo"),V.currentManager&&et.isRoom(i)&&!i.disableSerialization?V.currentManager.viewContainerManager.redo():0},cleanCurrentScene:function(){V.logger.info("[ApplianceMultiPlugin] cleanCurrentScene"),V.currentManager&&et.isRoom(i)&&i.isWritable&&(V.currentManager.cleanCurrentScene(),c.call(t))},insertImage:function(f){V.logger.info("[ApplianceMultiPlugin] insertImage"),V.currentManager&&et.isRoom(i)&&i.isWritable&&V.currentManager.worker.insertImage("mainView",f)},lockImage:function(f,y){V.logger.info("[ApplianceMultiPlugin] lockImage"),V.currentManager&&et.isRoom(i)&&i.isWritable&&V.currentManager.worker.lockImage("mainView",f,y)},completeImageUpload:function(f,y){V.logger.info("[ApplianceMultiPlugin] completeImageUpload"),V.currentManager&&et.isRoom(i)&&i.isWritable&&V.currentManager.worker.completeImageUpload("mainView",f,y)},getImagesInformation:function(f){return V.logger.info("[ApplianceMultiPlugin] completeImageUpload"),V.currentManager&&et.isRoom(i)&&i.isWritable?V.currentManager.worker.getImagesInformation(f):[]},callbacks:()=>(V.logger.info("[ApplianceMultiPlugin] callbacks bind"),{...i.callbacks,on:u._callbacksOn.bind(u),once:u._callbacksOnce.bind(u),off:u._callbacksOff.bind(u)}),destroy(){V.currentManager&&(V.logger.info("[ApplianceMultiPlugin] destroy"),V.currentManager.destroy(),V.currentManager=void 0)},setMemberState(f){V.logger.info("[ApplianceMultiPlugin] setMemberState");const y=Object.keys(f);if(et.isRoom(i)&&i.isWritable){y.includes("currentApplianceName")&&(f.currentApplianceName&&f.currentApplianceName===st.laserPen?(f.currentApplianceName=st.pencil,f.useLaserPen=!0):f.currentApplianceName&&f.currentApplianceName===st.pencil&&(f.useLaserPen=!1)),l.call(t.mainView,f);return}throw new Error("[ApplianceMultiPlugin] setMemberState must be called in writable room")},setPerformancePriority(f){V.logger.info("[ApplianceMultiPlugin] setPriority"),V.currentManager&&V.currentManager.setPriority(f)},createMiniMap:async function(f,y){if(V.logger.info("[ApplianceMultiPlugin] createMiniMap"),V.currentManager&&et.isRoom(i)&&i.isWritable)return V.currentManager.createMiniMap(f,y)},destroyMiniMap:async function(f){if(V.logger.info("[ApplianceMultiPlugin] destroyeMiniMap"),V.currentManager&&et.isRoom(i)&&i.isWritable)return V.currentManager.destroyMiniMap(f)},filterRenderByUid(f,y,m){if(V.logger.info("[ApplianceMultiPlugin] filterRenderByUid"),V.currentManager&&et.isRoom(i)&&i.isWritable)return V.currentManager.filterRenderByUid(f,y,m)},cancelFilterRender(f,y){if(V.logger.info("[ApplianceMultiPlugin] filterRenderByUid"),V.currentManager&&et.isRoom(i)&&i.isWritable)return V.currentManager.cancelFilterRender(f,y)},addListener:(f,y)=>{V.logger.info(`[ApplianceMultiPlugin] addListener ${f}`),Xt.PublicMsgEmitter.on(f,y)},removeListener:(f,y)=>{V.logger.info(`[ApplianceMultiPlugin] removeListener ${f}`),Xt.PublicMsgEmitter.off(f,y)}},d=(f,y)=>{if(V.logger.info(`[ApplianceMultiPlugin] injectMethodToObject ${y}`),typeof f[y]=="function"||typeof f[y]>"u"){f[y]=u[y];return}y==="callbacks"&&(f.callbacks.on=u._callbacksOn.bind(u),f.callbacks.off=u._callbacksOff.bind(u),f.callbacks.once=u._callbacksOnce.bind(u))};d(t,"undo"),d(t,"redo"),d(t,"cleanCurrentScene"),d(t,"insertImage"),d(t,"completeImageUpload"),d(t,"lockImage"),d(i,"getImagesInformation"),d(i,"callbacks"),d(i,"screenshotToCanvasAsync"),d(i,"getBoundingRectAsync"),d(i,"scenePreviewAsync"),d(i,"fillSceneSnapshotAsync"),d(t.mainView,"setMemberState"),Object.defineProperty(t,"canUndoSteps",{get(){return u.canUndoSteps()}}),Object.defineProperty(t,"canRedoSteps",{get(){return u.canRedoSteps()}}),Xt.InternalMsgEmitter.on("onCanUndoStepsUpdate",f=>{t.emitter.emit("canUndoStepsChange",f)}),Xt.InternalMsgEmitter.on("onCanRedoStepsUpdate",f=>{t.emitter.emit("canRedoStepsChange",f)});const p={...u,callbacks:u.callbacks()};return t._appliancePlugin=p,t._appliancePlugin}static onCreate(t){t&&V.currentManager&&(V.currentManager.bindPlugin(t),t.init(t.displayer))}static async createApplianceMultiPlugin(t,e){try{await t.createInvisiblePlugin(V,{})}catch{if(!t.isWritable){await t.setWritable(!0);const n=await this.createApplianceMultiPlugin(t,e);return await t.setWritable(!1),n}}let i=t.getInvisiblePlugin(e);return i||(i=await V.createApplianceMultiPlugin(t,e)),i}get isReplay(){return et.isPlayer(this.displayer)}get callbackName(){return this.isReplay?"onPlayerStateChanged":"onRoomStateChanged"}init(t){var i,s;const e=t.state;(i=V.currentManager)==null||i.onRoomMembersChange(e.roomMembers),et.isRoom(t)&&((s=V.currentManager)==null||s.onMemberChange(e.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 t;V.logger.info("[ApplianceMultiPlugin] passive destroy"),(t=V.currentManager)==null||t.destroy(),V.currentManager=void 0}};M(V,"kind","appliance-multi-plugin"),M(V,"currentManager"),M(V,"logger",{info:console.log,warn:console.warn,error:console.error}),M(V,"options",Lt),M(V,"createCurrentManager",(t,e,i)=>{V.currentManager&&V.currentManager.destroy();const s={plugin:i,displayer:t.displayer,options:e},n=new Xt(s);V.logger.info("[ApplianceMultiPlugin] refresh ApplianceMultiManager object"),n.setWindowManager(t),V.currentManager=n});let bo=V;class ry extends bs{constructor(t,e){super(t,e);M(this,"width",1e3);M(this,"height",1e3);M(this,"dpr",1);M(this,"vDom");M(this,"viewId",It);M(this,"eventTragetElement");M(this,"snapshotContainerRef");M(this,"canvasContainerRef",g.createRef());M(this,"subLocalCanvasContainerRef",g.createRef());M(this,"canvasTopRef",g.createRef());M(this,"canvasServiceFloatRef",g.createRef());M(this,"canvasFloatRef",g.createRef());M(this,"canvasBgRef",g.createRef());M(this,"floatBarRef",g.createRef());M(this,"containerOffset",{x:0,y:0});this.control.hasOffscreenCanvas()||(this.snapshotContainerRef=g.createRef())}setCanvassStyle(){if(this.eventTragetElement){const t=this.eventTragetElement.offsetWidth,e=this.eventTragetElement.offsetHeight;t&&e&&this.canvasContainerRef.current&&(t!==this.width||e!==this.height)&&(this.dpr=te()),t&&e&&this.canvasContainerRef.current&&(t!==this.width||e!==this.height)&&(this.dpr=te(),this.width=t,this.height=e),t&&e&&this.canvasBgRef.current&&(t!==this.width||e!==this.height)&&(this.dpr=te(this.canvasBgRef.current.getContext("2d")),this.width=t,this.height=e,this.canvasBgRef.current.width=t*this.dpr,this.canvasBgRef.current.height=e*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=t*this.dpr,this.canvasFloatRef.current.height=e*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=t*this.dpr,this.canvasServiceFloatRef.current.height=e*this.dpr),this.canvasTopRef.current&&(this.canvasTopRef.current.width=t*this.dpr,this.canvasTopRef.current.height=e*this.dpr))}}createMainViewDisplayer(t){return this.vDom||(this.containerOffset=this.getContainerOffset(t,this.containerOffset),this.eventTragetElement=t.parentElement.children[0],t.innerHTML="",oo.render(g.createElement(Qo,{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 Zt extends we{constructor(t){super(t);M(this,"focuedViewId");M(this,"control");M(this,"focuedView");this.control=t.control}bindMainView(){if(!this.control.divMainView)return;const t=new ry(this.control,Nt.InternalMsgEmitter);this.focuedViewId=It;const{width:e,height:i,dpr:s}=t,n={dpr:s,originalPoint:[e/2,i/2],offscreenCanvasOpt:{...Zt.defaultScreenCanvasOpt,width:e,height:i},layerOpt:{...Zt.defaultLayerOpt,width:e,height:i},cameraOpt:{...Zt.defaultCameraOpt,width:e,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:It,displayer:t,focusScenePath:r.focusScenePath||r.scenePath,cameraOpt:n.cameraOpt,viewData:r}),this.focuedView=this.mainView,t.createMainViewDisplayer(this.control.divMainView)}}getViewInitData(t){var i;const e=this.getView(t);if(e){const{width:s,height:n,dpr:r}=e.displayer;(i=this.control.pluginOptions.canvasOpt)!=null&&i.contextType&&(Zt.defaultScreenCanvasOpt.contextType=this.control.pluginOptions.canvasOpt.contextType);const c={dpr:r,originalPoint:[s/2,n/2],offscreenCanvasOpt:{...Zt.defaultScreenCanvasOpt,width:s,height:n},layerOpt:{...Zt.defaultLayerOpt,width:s,height:n},cameraOpt:{...Zt.defaultCameraOpt,width:s,height:n}};if(e.viewData){const{scale:l,...h}=e.viewData.camera;c.cameraOpt={...c.cameraOpt,...h,scale:l===1/0?1:l}}return c}}async mountView(t){var i;const e=this.getView(t);if(e){this.control.worker.isActive||(this.control.cursor.activeCollector(),await this.control.activeWorker());const s=this.getViewInitData(t);s&&((i=this.control.worker)==null||i.createViewWorker(t,s)),e.focusScenePath&&this.control.collector&&this.control.worker.pullServiceData(t,e.focusScenePath,{isAsync:!0,useAnimation:!1})}}}class Et extends Nt{constructor(t){super(t);M(this,"viewContainerManager");M(this,"divMainView");M(this,"onCameraChange",Ee(t=>{var i;const e=this.viewContainerManager.mainView;e&&e.cameraOpt&&(e.cameraOpt.width!==t.width||e.cameraOpt.height!==t.height)&&((i=this.viewContainerManager.mainView)==null||i.displayer.updateSize()),this.viewContainerManager.setFocuedViewCameraOpt(t)},20,{leading:!1}));const e={control:this,internalMsgEmitter:Et.InternalMsgEmitter,publicMsgEmitter:Et.PublicMsgEmitter};this.viewContainerManager=new Zt(e)}init(){Et.InternalMsgEmitter.on(q.BindMainView,t=>{this.divMainView=t,this.plugin&&!this.viewContainerManager.mainView&&this.viewContainerManager.bindMainView()})}activePlugin(){this.plugin&&this.divMainView&&!this.viewContainerManager.mainView&&this.viewContainerManager.bindMainView(),this.collector&&(this.collector.addStorageStateListener(t=>{var r,c;if((r=this.collector)!=null&&r.storage&&Object.keys(this.collector.storage).length===0){(c=this.worker)==null||c.clearViewScenePath(It,!0);return}const{diffView:e,diffScenePath:i,diffData:s}=t,n=new Map;if(e){let l;Object.keys(e).forEach(h=>{var d;const u=e[h];if(u&&!u.newValue)(d=this.worker)==null||d.clearViewScenePath(h,!0),u.oldValue&&(l=u.oldValue);else if(u&&u.newValue){for(const p of Object.keys(u.newValue))this.worker.pullServiceData(h,p,{isAsync:!1,useAnimation:!0});l=u.newValue}if(l)for(const p of Object.values(l)){const f=new Set;for(const y of Object.keys(p))y&&f.add(y);n.set(h,f)}})}if(i){let l;Object.keys(i).forEach(h=>{var d;const u=i[h];if(u&&u.viewId&&!u.newValue?((d=this.worker)==null||d.clearViewScenePath(u.viewId,!0),u.oldValue&&(l=u.oldValue)):u&&u.viewId&&u.newValue&&(this.worker.pullServiceData(u.viewId,h,{isAsync:!1,useAnimation:!0}),l=u.newValue),u!=null&&u.viewId&&l){const p=new Set;for(const f of Object.keys(l))f&&p.add(f),n.set(u.viewId,p)}})}s&&Object.keys(s).forEach(l=>{var u,d;const h=s[l];if(h){const{viewId:p}=h,f=n.get(p)||new Set;f.add(l),n.set(p,f),(u=this.worker)==null||u.onServiceDerive(l,h),(d=this.miniMapManager)==null||d.updateMiniMapCamera(p)}});for(const[l,h]of n.entries())Nt.InternalMsgEmitter.emit("excludeIds",[...h],l)}),this.room&&(this.roomMember.onUidChangeHook(t=>{var e,i,s,n;if((e=this.collector)!=null&&e.serviceStorage){const r=[];this.viewContainerManager.getAllViews().forEach(c=>{var l,h,u;if(c&&c.focusScenePath&&((l=this.collector)!=null&&l.serviceStorage[c.id])&&((h=this.collector)!=null&&h.serviceStorage[c.id][c.focusScenePath])){const d=Object.keys((u=this.collector)==null?void 0:u.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:h})=>{var d,p;const u=(d=this.collector)==null?void 0:d.getUidFromKey(c);u&&!t.online.includes(u)&&((p=this.collector)==null||p.updateValue(c,void 0,{isAfterUpdate:!0,viewId:l,scenePath:h}))})}(s=(i=this.cursor)==null?void 0:i.eventCollector)!=null&&s.serviceStorage&&Object.keys((n=this.cursor)==null?void 0:n.eventCollector.serviceStorage).forEach(c=>{var l,h;t.online.includes(c)||(h=(l=this.cursor)==null?void 0:l.eventCollector)==null||h.clearValue(c)})}),this.worker.isActive&&this.viewContainerManager.getAllViews().forEach(t=>{t&&t.focusScenePath&&this.worker.pullServiceData(t.id,t.focusScenePath,{isAsync:!0,useAnimation:!1})})))}async activeWorker(){await this.worker.init()}}const B=class B extends et.InvisiblePlugin{constructor(){super(...arguments);M(this,"onPhaseChanged",t=>{var e;t===et.RoomPhase.Reconnecting&&((e=B.currentManager)==null||e.setSnapshootData())});M(this,"updateRoomWritable",()=>{var t;(t=B.currentManager)==null||t.onWritableChange(this.displayer.isWritable)});M(this,"roomStateChangeListener",async t=>{var e,i;B.currentManager instanceof Et&&(t.cameraState&&B.currentManager.onCameraChange(t.cameraState),t.sceneState&&B.currentManager.onSceneChange(t.sceneState.scenePath,It)),t!=null&&t.roomMembers&&((e=B.currentManager)==null||e.onRoomMembersChange(t.roomMembers)),!(et.isRoom(this.displayer)&&!this.displayer.isWritable)&&t.memberState&&((i=B.currentManager)==null||i.onMemberChange(t.memberState))})}static async getInstance(t,e){const i=t.callbacks.on,s=t.callbacks.off,n=t.callbacks.once,r=t.cleanCurrentScene.bind(t),c=t.setMemberState.bind(t);e!=null&&e.logger&&(B.logger=e.logger),e.options&&(B.options={...Lt,...e.options});let l=t.getInvisiblePlugin(B.kind);l||(l=await B.createAppliancePlugin(t,B.kind)),t&&l&&B.createCurrentManager(t,B.options,l),l&&B.currentManager&&(B.currentManager.bindPlugin(l),l.init(t)),e!=null&&e.cursorAdapter&&(B.cursorAdapter=e.cursorAdapter),B.effectInstance();const h={displayer:t,currentManager:B.currentManager,maxScreenshotWidth:10*1024,maxScreenshotHeight:10*1024,_injectTargetObject:void 0,getBoundingRectAsync:async function(p){var m;B.logger.info("[ApplianceSinglePlugin] getBoundingRectAsync");const f=t.getBoundingRect(p),y=await((m=B.currentManager)==null?void 0:m.getBoundingRect(p));return!f.width||!f.height?y:Fo(f,y)},screenshotToCanvasAsync:async function(p,f,y,m,S,w){var z;B.logger.info("[ApplianceSinglePlugin] screenshotToCanvasAsync");let v=y,T=m,N=S.scale;v>this.maxScreenshotWidth&&(N=this.maxScreenshotWidth/v*N,v=this.maxScreenshotWidth),T>this.maxScreenshotHeight&&(N=Math.min(this.maxScreenshotHeight/T*N,N),T=this.maxScreenshotHeight),S.scale=N;const I=document.createElement("canvas"),x=I.getContext("2d");I.width=v*(w||1),I.height=T*(w||1),x&&(t.screenshotToCanvas(x,f,v,T,S,w),p.drawImage(I,Math.floor((y-v)/2),Math.floor((m-T)/2),v*(w||1),T*(w||1),0,0,v,T),I.remove()),B.currentManager&&await((z=B.currentManager)==null?void 0:z.screenshotToCanvas(p,f,v,T,S,Math.floor((y-v)/2),Math.floor((m-T)/2)))},scenePreviewAsync:async function(p,f,y,m,S){B.logger.info("[ApplianceSinglePlugin] scenePreviewAsync"),t.scenePreview(p,f,y,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"),B.currentManager&&await B.currentManager.scenePreview(p,w)},fillSceneSnapshotAsync:async function(p,f,y,m,S){var Y,ot;B.logger.info("[ApplianceSinglePlugin] fillSceneSnapshotAsync"),f.innerHTML="",t.fillSceneSnapshot(p,f,y,m,S);const w=y||((Y=t.state.cameraState)==null?void 0:Y.width)||0,v=m||((ot=t.state.cameraState)==null?void 0:ot.height)||0;let T=await this.getBoundingRectAsync(p);T||(T={originX:0,originY:0,width:w,height:v});let N=Math.max(T==null?void 0:T.width,w),I=Math.max(T==null?void 0:T.height,v),x=1;const z=N>w&&Math.min(w/N,x)||x,A=I>v&&Math.min(v/I,x)||x;z<=A?(N=z<1&&w||N,I=Math.floor(I*z)+1,x=z):z>A&&(I=A<1&&v||I,N=Math.floor(N*A)+1,x=A);const E={scale:x,centerX:T.originX+T.width/2,centerY:T.originY+T.height/2},j=document.createElement("canvas"),O=j.getContext("2d");j.width=N,j.height=I,O&&await this.screenshotToCanvasAsync(O,p,N,I,E,devicePixelRatio);const P=document.createElement("img");P.className="appliance-plugin-fill-scene-snapshot-img",P.src=j.toDataURL(),P.onload=()=>{j.remove()},P.onerror=()=>{j.remove(),P.remove()},f.append(P),getComputedStyle(f).position||(f.style.position="relative")},_callbacksOn:function(p,f){B.logger.info(`[ApplianceSinglePlugin] callbacks ${p}`),(p==="onCanUndoStepsUpdate"||p==="onCanRedoStepsUpdate")&&et.isRoom(t)&&t.isWritable?Et.InternalMsgEmitter.on(p,f):i.call(t.callbacks,p,f)},_callbacksOnce:function(p,f){B.logger.info(`[ApplianceSinglePlugin] callbacks ${p}`),(p==="onCanUndoStepsUpdate"||p==="onCanRedoStepsUpdate")&&et.isRoom(t)&&t.isWritable?Et.InternalMsgEmitter.on(p,f):n.call(t.callbacks,p,f)},_callbacksOff:function(p,f){B.logger.info(`[ApplianceSinglePlugin] callbacks ${p}`),(p==="onCanUndoStepsUpdate"||p==="onCanRedoStepsUpdate")&&et.isRoom(t)&&t.isWritable?Et.InternalMsgEmitter.off(p,f):s.call(t.callbacks,p,f)},canRedoSteps(){if(B.logger.info("[ApplianceSinglePlugin] canRedoSteps"),B.currentManager&&et.isRoom(t)&&!t.disableSerialization){const p=B.currentManager.viewContainerManager.focuedView,f=p==null?void 0:p.focusScenePath;if(p&&f)return p.displayer.commiter.redoStack.filter(y=>y.scenePath===f).length}return 0},canUndoSteps(){if(B.logger.info("[ApplianceSinglePlugin] canUndoSteps"),B.currentManager&&et.isRoom(t)&&!t.disableSerialization){const p=B.currentManager.viewContainerManager.focuedView,f=p==null?void 0:p.focusScenePath;if(p&&f)return p.displayer.commiter.undoStack.filter(y=>y.scenePath===f).length}return 0},undo:function(){return B.logger.info("[ApplianceSinglePlugin] undo"),B.currentManager&&et.isRoom(t)&&!t.disableSerialization?B.currentManager.viewContainerManager.undo():0},redo:function(){return B.logger.info("[ApplianceSinglePlugin] redo"),B.currentManager&&et.isRoom(t)&&!t.disableSerialization?B.currentManager.viewContainerManager.redo():0},cleanCurrentScene:function(p){B.logger.info("[ApplianceSinglePlugin] cleanCurrentScene"),B.currentManager&&et.isRoom(t)&&t.isWritable&&(B.currentManager.cleanCurrentScene(),r.call(t,p))},insertImage:function(p){B.logger.info("[ApplianceSinglePlugin] insertImage"),B.currentManager&&et.isRoom(t)&&t.isWritable&&B.currentManager.worker.insertImage("mainView",p)},lockImage:function(p,f){B.logger.info("[ApplianceSinglePlugin] lockImage"),B.currentManager&&et.isRoom(t)&&t.isWritable&&B.currentManager.worker.lockImage("mainView",p,f)},completeImageUpload:function(p,f){B.logger.info("[ApplianceSinglePlugin] completeImageUpload"),B.currentManager&&et.isRoom(t)&&t.isWritable&&B.currentManager.worker.completeImageUpload("mainView",p,f)},getImagesInformation:function(p){return B.logger.info("[ApplianceSinglePlugin] completeImageUpload"),B.currentManager&&et.isRoom(t)&&t.isWritable?B.currentManager.worker.getImagesInformation(p):[]},callbacks:()=>({...t.callbacks,on:h._callbacksOn.bind(h),once:h._callbacksOnce.bind(h),off:h._callbacksOff.bind(h)}),destroy(){B.currentManager&&(B.logger.info("[ApplianceSinglePlugin] destroy"),B.currentManager.destroy(),B.currentManager=void 0,B.cursorAdapter=void 0)},setMemberState(p){B.logger.info("[ApplianceSinglePlugin] setMemberState");const f=Object.keys(p);if(et.isRoom(t)&&t.isWritable){f.includes("currentApplianceName")&&(p.currentApplianceName&&p.currentApplianceName===st.laserPen?(p.currentApplianceName=st.pencil,p.useLaserPen=!0):p.currentApplianceName&&p.currentApplianceName===st.pencil&&(p.useLaserPen=!1)),c(p);return}throw new Error("setMemberState must be called in writable room")},setPerformancePriority(p){B.logger.info("[ApplianceSinglePlugin] setPriority"),B.currentManager&&B.currentManager.setPriority(p)},createMiniMap:async function(p,f){if(B.logger.info("[ApplianceSinglePlugin] createMiniMap"),B.currentManager&&et.isRoom(t)&&t.isWritable)return B.currentManager.createMiniMap(p,f)},destroyMiniMap:async function(p){if(B.logger.info("[ApplianceMultiPlugin] destroyeMiniMap"),B.currentManager&&et.isRoom(t)&&t.isWritable)return B.currentManager.destroyMiniMap(p)},filterRenderByUid(p,f,y){if(B.logger.info("[ApplianceSinglePlugin] filterRenderByUid"),B.currentManager&&et.isRoom(t)&&t.isWritable)return B.currentManager.filterRenderByUid(p,f,y)},cancelFilterRender(p,f){if(B.logger.info("[ApplianceSinglePlugin] filterRenderByUid"),B.currentManager&&et.isRoom(t)&&t.isWritable)return B.currentManager.cancelFilterRender(p,f)},addListener:(p,f)=>{B.logger.info(`[ApplianceSinglePlugin] addListener ${p}`),Et.PublicMsgEmitter.on(p,f)},removeListener:(p,f)=>{B.logger.info(`[ApplianceSinglePlugin] removeListener ${p}`),Et.PublicMsgEmitter.off(p,f)}},u=(p,f)=>{if(B.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))};u(t,"undo"),u(t,"redo"),u(t,"cleanCurrentScene"),u(t,"insertImage"),u(t,"completeImageUpload"),u(t,"lockImage"),u(t,"getImagesInformation"),u(t,"callbacks"),u(t,"screenshotToCanvasAsync"),u(t,"getBoundingRectAsync"),u(t,"scenePreviewAsync"),u(t,"fillSceneSnapshotAsync"),u(t,"setMemberState"),Object.defineProperty(t,"canUndoSteps",{get(){return h.canUndoSteps()}}),Object.defineProperty(t,"canRedoSteps",{get(){return h.canRedoSteps()}});const d={...h,callbacks:h.callbacks()};return t._appliancePlugin=d,t._appliancePlugin}static onCreate(t){t&&B.currentManager&&(B.currentManager.bindPlugin(t),t.init(t.displayer))}static async createAppliancePlugin(t,e){try{await t.createInvisiblePlugin(B,{})}catch{if(!t.isWritable){await t.setWritable(!0);const n=await this.createAppliancePlugin(t,e);return await t.setWritable(!1),n}}let i=t.getInvisiblePlugin(e);return i||(i=await B.createAppliancePlugin(t,e)),i}static effectInstance(){if(B.cursorAdapter){const t=B.cursorAdapter.onAddedCursor;B.cursorAdapter.onAddedCursor=function(e){e.onCursorMemberChanged=i=>{try{i.appliance===st.pencil||i.appliance===st.shape||i.appliance===st.text||i.appliance===st.arrow||i.appliance===st.straight||i.appliance===st.rectangle||i.appliance===st.ellipse||i.appliance===st.eraser?e!=null&&e.divElement&&(e.divElement.style.display="none"):e!=null&&e.divElement&&(e.divElement.style.display="block")}catch{}},t.call(B.cursorAdapter,e)}}}get isReplay(){return et.isPlayer(this.displayer)}get callbackName(){return this.isReplay?"onPlayerStateChanged":"onRoomStateChanged"}init(t){var i,s;const e=t.state;(i=B.currentManager)==null||i.onRoomMembersChange(e.roomMembers),et.isRoom(t)&&e!=null&&e.memberState&&((s=B.currentManager)==null||s.onMemberChange(e.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 t;B.logger.info("[ApplianceSinglePlugin] passive destroy"),(t=B.currentManager)==null||t.destroy(),B.currentManager=void 0,B.cursorAdapter=void 0}};M(B,"kind","appliance-aids-single-plugin"),M(B,"cursorAdapter"),M(B,"currentManager"),M(B,"logger",{info:console.log,warn:console.warn,error:console.error}),M(B,"options",Lt),M(B,"createCurrentManager",(t,e,i)=>{B.currentManager&&B.currentManager.destroy();const s={plugin:i,displayer:t,options:e},n=new Et(s);n.init(),B.logger.info("[ApplianceSinglePlugin] refresh ApplianceSingleManager object"),B.currentManager=n});let Po=B;const ye=class ye extends g.Component{constructor(){super(...arguments);M(this,"mainViewRef",null)}componentDidMount(){ye.emiter||(ye.emiter=Et.InternalMsgEmitter),ye.emiter.emit(q.BindMainView,this.mainViewRef)}render(){return g.createElement(g.Fragment,null,this.props.children,g.createElement("div",{className:"appliance-plugin-main-view-displayer",ref:t=>this.mainViewRef=t}))}};M(ye,"emiter");let Lo=ye;exports.ActiveContainerType=Ei;exports.ApplianceMultiPlugin=bo;exports.ApplianceNames=st;exports.ApplianceSigleWrapper=Lo;exports.ApplianceSinglePlugin=Po;exports.Cursor_Hover_Id=Uf;exports.DefaultAppliancePluginOptions=Lt;exports.ECanvasShowType=$t;exports.EDataType=H;exports.EMatrixrRelationType=Le;exports.EOperationType=xt;exports.EPostMessageType=b;exports.ERenderFilterType=Ut;exports.EScaleType=ct;exports.EStrokeType=_;exports.EToolsKey=C;exports.ElayerType=ae;exports.EmitEventType=R;exports.EventMessageType=Pe;exports.EvevtWorkState=D;exports.EvevtWorkType=Oi;exports.InternalMsgEmitterType=q;exports.Main_View_Id=It;exports.ShapeType=Yt;exports.Storage_Selector_key=$;exports.Storage_Splitter=Vt;exports.Storage_ViewId_ALL=Fe;exports.Task_Time_Interval=Bf;exports.ViewContainerManager=we;exports.checkOp=Af;exports.cloneDeep=Jt;exports.computRect=ut;exports.fullWorker=Os;exports.getRectMatrixrRelation=Of;exports.getShapeInstance=Ts;exports.getShapeTools=Ns;exports.isBoolean=fe;exports.isEqual=pe;exports.isIntersect=Ae;exports.isIntersectForPoint=ks;exports.isNumber=Qt;exports.isSet=Md;exports.subWorker=Rs;exports.throttle=Ee;exports.transformToNormalData=xe;exports.transformToSerializableData=Dt;
|