@netless/appliance-plugin 1.1.22 → 1.1.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ "use strict";var To=Object.defineProperty;var vo=(o,i,e)=>i in o?To(o,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[i]=e;var m=(o,i,e)=>vo(o,typeof i!="symbol"?i+"":i,e);const F=require("white-web-sdk");require("spritejs");const zn=require("lz-string");require("clipper-lib");require("lineclip");const ai=require("xss"),x=require("lodash"),ci=require("eventemitter2"),d=require("react"),Vt=require("react-dom"),Mt=require("react-draggable"),Co=require("re-resizable"),So="/fullWorker.js",jo="/subWorker.js";var ee=(o=>(o.selector="selector",o.clicker="clicker",o.laserPointer="laserPointer",o.pencil="pencil",o.rectangle="rectangle",o.ellipse="ellipse",o.shape="shape",o.eraser="eraser",o.pencilEraser="pencilEraser",o.text="text",o.straight="straight",o.arrow="arrow",o.hand="hand",o.laserPen="laserPen",o))(ee||{}),fe=(o=>(o.Normal="Normal",o.Stroke="Stroke",o.Dotted="Dotted",o.LongDotted="LongDotted",o))(fe||{}),Re=(o=>(o.Triangle="triangle",o.Rhombus="rhombus",o.Pentagram="pentagram",o.SpeechBalloon="speechBalloon",o.Star="star",o.Polygon="polygon",o))(Re||{}),U=(o=>(o.None="None",o.ShowFloatBar="ShowFloatBar",o.ZIndexFloatBar="ZIndexFloatBar",o.DeleteNode="DeleteNode",o.CopyNode="CopyNode",o.ZIndexActive="ZIndexActive",o.ZIndexNode="ZIndexNode",o.RotateNode="RotateNode",o.SetColorNode="SetColorNode",o.TranslateNode="TranslateNode",o.ScaleNode="ScaleNode",o.OriginalEvent="OriginalEvent",o.CreateScene="CreateScene",o.ActiveCursor="ActiveCursor",o.MoveCursor="MoveCursor",o.CommandEditor="CommandEditor",o.SetEditorData="SetEditorData",o.SetFontStyle="SetFontStyle",o.SetPoint="SetPoint",o.SetLock="SetLock",o.SetShapeOpt="SetShapeOpt",o.CameraChange="CameraChange",o.ActiveMethod="ActiveMethod",o.HidFloatBarBtn="HidFloatBarBtn",o))(U||{}),_=(o=>(o.DisplayState="DisplayState",o.MainEngine="MainEngine",o.Cursor="Cursor",o.BindMainView="BindMainView",o))(_||{}),An=(o=>(o[o.MainView=0]="MainView",o[o.Plugin=1]="Plugin",o[o.Both=2]="Both",o))(An||{}),Ti=(o=>(o.longPencil="longPencil",o))(Ti||{}),T=(o=>(o[o.Pencil=1]="Pencil",o[o.Eraser=2]="Eraser",o[o.PencilEraser=3]="PencilEraser",o[o.BitMapEraser=4]="BitMapEraser",o[o.Selector=5]="Selector",o[o.Clicker=6]="Clicker",o[o.Arrow=7]="Arrow",o[o.Hand=8]="Hand",o[o.LaserPen=9]="LaserPen",o[o.Text=10]="Text",o[o.Straight=11]="Straight",o[o.Rectangle=12]="Rectangle",o[o.Ellipse=13]="Ellipse",o[o.Star=14]="Star",o[o.Triangle=15]="Triangle",o[o.Rhombus=16]="Rhombus",o[o.Polygon=17]="Polygon",o[o.SpeechBalloon=18]="SpeechBalloon",o[o.Image=19]="Image",o))(T||{}),K=(o=>(o[o.Local=1]="Local",o[o.Service=2]="Service",o[o.Worker=3]="Worker",o))(K||{}),j=(o=>(o[o.Pending=0]="Pending",o[o.Start=1]="Start",o[o.Doing=2]="Doing",o[o.Done=3]="Done",o[o.Unwritable=4]="Unwritable",o))(j||{}),W=(o=>(o[o.None=0]="None",o[o.Init=1]="Init",o[o.UpdateCamera=2]="UpdateCamera",o[o.UpdateTools=3]="UpdateTools",o[o.CreateWork=4]="CreateWork",o[o.DrawWork=5]="DrawWork",o[o.FullWork=6]="FullWork",o[o.UpdateNode=7]="UpdateNode",o[o.RemoveNode=8]="RemoveNode",o[o.Clear=9]="Clear",o[o.Select=10]="Select",o[o.Destroy=11]="Destroy",o[o.Snapshot=12]="Snapshot",o[o.BoundingBox=13]="BoundingBox",o[o.Cursor=14]="Cursor",o[o.TextUpdate=15]="TextUpdate",o[o.GetTextActive=16]="GetTextActive",o[o.TasksQueue=17]="TasksQueue",o[o.CursorHover=18]="CursorHover",o[o.CursorBlur=19]="CursorBlur",o[o.Console=20]="Console",o[o.GetImageBitMap=23]="GetImageBitMap",o[o.AuthWriter=24]="AuthWriter",o[o.AuthReader=25]="AuthReader",o[o.AuthClear=26]="AuthClear",o[o.AuthPage=27]="AuthPage",o[o.GetVNodeInfo=28]="GetVNodeInfo",o[o.UpdateDpr=29]="UpdateDpr",o[o.SetFontFace=30]="SetFontFace",o))(W||{}),He=(o=>(o[o.None=0]="None",o[o.Bg=1]="Bg",o[o.ServiceFloat=2]="ServiceFloat",o[o.Float=3]="Float",o[o.TopFloat=4]="TopFloat",o))(He||{}),Ct=(o=>(o[o.Cursor=1]="Cursor",o[o.TextCreate=2]="TextCreate",o))(Ct||{}),Dt=(o=>(o[o.Top=1]="Top",o[o.Bottom=2]="Bottom",o))(Dt||{}),Ae=(o=>(o[o.none=1]="none",o[o.all=2]="all",o[o.both=3]="both",o[o.proportional=4]="proportional",o))(Ae||{}),bn=(o=>(o[o.Pending=0]="Pending",o[o.Start=1]="Start",o[o.Doing=2]="Doing",o[o.Done=3]="Done",o[o.Unwritable=4]="Unwritable",o))(bn||{}),St=(o=>(o[o.inside=0]="inside",o[o.outside=1]="outside",o[o.intersect=2]="intersect",o))(St||{}),ze=(o=>(o.renderPage="renderPage",o.addPage="addPage",o.deletePage="deletePage",o.addElement="addElement",o.deleteElement="deleteElement",o.clearPage="clearPage",o.clearViewScenePath="clearViewScenePath",o.clearView="clearView",o))(ze||{}),Ye=(o=>(o.setAuth="setAuth",o.setShow="addShow",o.setHide="setHide",o.setClear="setClear",o))(Ye||{}),jt=(o=>(o.Image="image",o.Iconify="iconify",o))(jt||{});const Do={linear:o=>o,easeInQuad:o=>o*o,easeOutQuad:o=>o*(2-o),easeInOutQuad:o=>o<.5?2*o*o:-1+(4-2*o)*o,easeInCubic:o=>o*o*o,easeOutCubic:o=>--o*o*o+1,easeInOutCubic:o=>o<.5?4*o*o*o:(o-1)*(2*o-2)*(2*o-2)+1,easeInQuart:o=>o*o*o*o,easeOutQuart:o=>1- --o*o*o*o,easeInOutQuart:o=>o<.5?8*o*o*o*o:1-8*--o*o*o*o,easeInQuint:o=>o*o*o*o*o,easeOutQuint:o=>1+--o*o*o*o*o,easeInOutQuint:o=>o<.5?16*o*o*o*o*o:1+16*--o*o*o*o*o,easeInSine:o=>1-Math.cos(o*Math.PI/2),easeOutSine:o=>Math.sin(o*Math.PI/2),easeInOutSine:o=>-(Math.cos(Math.PI*o)-1)/2,easeInExpo:o=>o<=0?0:Math.pow(2,10*o-10),easeOutExpo:o=>o>=1?1:1-Math.pow(2,-10*o),easeInOutExpo:o=>o<=0?0:o>=1?1:o<.5?Math.pow(2,20*o-10)/2:(2-Math.pow(2,-20*o+10))/2};class Y{constructor(i=0,e=0,t=1){this.x=i,this.y=e,this.z=t}get XY(){return[this.x,this.y]}setz(i){return this.z=i,this}setXY(i=this.x,e=this.y){return this.x=i,this.y=e,this}set(i=this.x,e=this.y,t=this.z){return this.x=i,this.y=e,this.z=t,this}setTo({x:i=0,y:e=0,z:t=1}){return this.x=i,this.y=e,this.z=t,this}rot(i){if(i===0)return this;const{x:e,y:t}=this,n=Math.sin(i),r=Math.cos(i);return this.x=e*r-t*n,this.y=e*n+t*r,this}rotWith(i,e){if(e===0)return this;const t=this.x-i.x,n=this.y-i.y,r=Math.sin(e),s=Math.cos(e);return this.x=i.x+(t*s-n*r),this.y=i.y+(t*r+n*s),this}clone(){const{x:i,y:e,z:t}=this;return new Y(i,e,t)}sub(i){return this.x-=i.x,this.y-=i.y,this}subXY(i,e){return this.x-=i,this.y-=e,this}subScalar(i){return this.x-=i,this.y-=i,this}add(i){return this.x+=i.x,this.y+=i.y,this}addXY(i,e){return this.x+=i,this.y+=e,this}addScalar(i){return this.x+=i,this.y+=i,this}clamp(i,e){return this.x=Math.max(this.x,i),this.y=Math.max(this.y,i),e!==void 0&&(this.x=Math.min(this.x,e),this.y=Math.min(this.y,e)),this}div(i){return this.x/=i,this.y/=i,this}divV(i){return this.x/=i.x,this.y/=i.y,this}mul(i){return this.x*=i,this.y*=i,this}mulV(i){return this.x*=i.x,this.y*=i.y,this}abs(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this}nudge(i,e){const t=Y.Tan(i,this);return this.add(t.mul(e))}neg(){return this.x*=-1,this.y*=-1,this}cross(i){return this.x=this.y*i.z-this.z*i.y,this.y=this.z*i.x-this.x*i.z,this}dpr(i){return Y.Dpr(this,i)}cpr(i){return Y.Cpr(this,i)}len2(){return Y.Len2(this)}len(){return Y.Len(this)}pry(i){return Y.Pry(this,i)}per(){const{x:i,y:e}=this;return this.x=e,this.y=-i,this}uni(){return Y.Uni(this)}tan(i){return Y.Tan(this,i)}dist(i){return Y.Dist(this,i)}distanceToLineSegment(i,e){return Y.DistanceToLineSegment(i,e,this)}slope(i){return Y.Slope(this,i)}snapToGrid(i){return this.x=Math.round(this.x/i)*i,this.y=Math.round(this.y/i)*i,this}angle(i){return Y.Angle(this,i)}toAngle(){return Y.ToAngle(this)}lrp(i,e){return this.x=this.x+(i.x-this.x)*e,this.y=this.y+(i.y-this.y)*e,this}equals(i,e){return Y.Equals(this,i,e)}equalsXY(i,e){return Y.EqualsXY(this,i,e)}norm(){const i=this.len();return this.x=i===0?0:this.x/i,this.y=i===0?0:this.y/i,this}toFixed(){return Y.ToFixed(this)}toString(){return Y.ToString(Y.ToFixed(this))}toJson(){return Y.ToJson(this)}toArray(){return Y.ToArray(this)}static Add(i,e){return new Y(i.x+e.x,i.y+e.y)}static AddXY(i,e,t){return new Y(i.x+e,i.y+t)}static Sub(i,e){return new Y(i.x-e.x,i.y-e.y)}static SubXY(i,e,t){return new Y(i.x-e,i.y-t)}static AddScalar(i,e){return new Y(i.x+e,i.y+e)}static SubScalar(i,e){return new Y(i.x-e,i.y-e)}static Div(i,e){return new Y(i.x/e,i.y/e)}static Mul(i,e){return new Y(i.x*e,i.y*e)}static DivV(i,e){return new Y(i.x/e.x,i.y/e.y)}static MulV(i,e){return new Y(i.x*e.x,i.y*e.y)}static Neg(i){return new Y(-i.x,-i.y)}static Per(i){return new Y(i.y,-i.x)}static Dist2(i,e){return Y.Sub(i,e).len2()}static Abs(i){return new Y(Math.abs(i.x),Math.abs(i.y))}static Dist(i,e){return Math.hypot(i.y-e.y,i.x-e.x)}static Dpr(i,e){return i.x*e.x+i.y*e.y}static Cross(i,e){return new Y(i.y*e.z-i.z*e.y,i.z*e.x-i.x*e.z)}static Cpr(i,e){return i.x*e.y-e.x*i.y}static Len2(i){return i.x*i.x+i.y*i.y}static Len(i){return Math.hypot(i.x,i.y)}static Pry(i,e){return Y.Dpr(i,e)/Y.Len(e)}static Uni(i){return Y.Div(i,Y.Len(i))}static Tan(i,e){return Y.Uni(Y.Sub(i,e))}static Min(i,e){return new Y(Math.min(i.x,e.x),Math.min(i.y,e.y))}static Max(i,e){return new Y(Math.max(i.x,e.x),Math.max(i.y,e.y))}static From(i){return new Y().add(i)}static FromArray(i){return new Y(i[0],i[1])}static Rot(i,e=0){const t=Math.sin(e),n=Math.cos(e);return new Y(i.x*n-i.y*t,i.x*t+i.y*n)}static RotWith(i,e,t){const n=i.x-e.x,r=i.y-e.y,s=Math.sin(t),a=Math.cos(t);return new Y(e.x+(n*a-r*s),e.y+(n*s+r*a))}static NearestPointOnLineThroughPoint(i,e,t){return Y.Mul(e,Y.Sub(t,i).pry(e)).add(i)}static NearestPointOnLineSegment(i,e,t,n=!0){const r=Y.Tan(e,i),s=Y.Add(i,Y.Mul(r,Y.Sub(t,i).pry(r)));if(n){if(s.x<Math.min(i.x,e.x))return Y.Cast(i.x<e.x?i:e);if(s.x>Math.max(i.x,e.x))return Y.Cast(i.x>e.x?i:e);if(s.y<Math.min(i.y,e.y))return Y.Cast(i.y<e.y?i:e);if(s.y>Math.max(i.y,e.y))return Y.Cast(i.y>e.y?i:e)}return s}static DistanceToLineThroughPoint(i,e,t){return Y.Dist(t,Y.NearestPointOnLineThroughPoint(i,e,t))}static DistanceToLineSegment(i,e,t,n=!0){return Y.Dist(t,Y.NearestPointOnLineSegment(i,e,t,n))}static Snap(i,e=1){return new Y(Math.round(i.x/e)*e,Math.round(i.y/e)*e)}static Cast(i){return i instanceof Y?i:Y.From(i)}static Slope(i,e){return i.x===e.y?NaN:(i.y-e.y)/(i.x-e.x)}static Angle(i,e){return Math.atan2(e.y-i.y,e.x-i.x)}static Lrp(i,e,t){return Y.Sub(e,i).mul(t).add(i)}static Med(i,e){return new Y((i.x+e.x)/2,(i.y+e.y)/2)}static Equals(i,e,t=1e-4){return Math.abs(i.x-e.x)<t&&Math.abs(i.y-e.y)<t}static EqualsXY(i,e,t){return i.x===e&&i.y===t}static EqualsXYZ(i,e,t=1e-4){return Y.Equals(i,e,t)&&Math.abs((i.z||0)-(e.z||0))<t}static Clockwise(i,e,t){return(t.x-i.x)*(e.y-i.y)-(e.x-i.x)*(t.y-i.y)<0}static Rescale(i,e){const t=Y.Len(i);return new Y(e*i.x/t,e*i.y/t)}static ScaleWithOrigin(i,e,t){return Y.Sub(i,t).mul(e).add(t)}static ScaleWOrigin(i,e,t){return Y.Sub(i,t).mulV(e).add(t)}static ToFixed(i,e=2){return new Y(+i.x.toFixed(e),+i.y.toFixed(e),+i.z.toFixed(e))}static Nudge(i,e,t){return Y.Add(i,Y.Tan(e,i).mul(t))}static ToString(i){return`${i.x}, ${i.y}`}static ToAngle(i){let e=Math.atan2(i.y,i.x);return e<0&&(e+=Math.PI*2),e}static FromAngle(i,e=1){return new Y(Math.cos(i)*e,Math.sin(i)*e)}static ToArray(i){return[i.x,i.y,i.z]}static ToJson(i){const{x:e,y:t,z:n}=i;return{x:e,y:t,z:n}}static Average(i){const e=i.length,t=new Y(0,0);for(let n=0;n<e;n++)t.add(i[n]);return t.div(e)}static Clamp(i,e,t){return t===void 0?new Y(Math.min(Math.max(i.x,e)),Math.min(Math.max(i.y,e))):new Y(Math.min(Math.max(i.x,e),t),Math.min(Math.max(i.y,e),t))}static PointsBetween(i,e,t=6){const n=[];for(let r=0;r<t;r++){const s=Do.easeInQuad(r/(t-1)),a=Y.Lrp(i,e,s);a.z=Math.min(1,.5+Math.abs(.5-xo(s))*.65),n.push(a)}return n}static SnapToGrid(i,e=8){return new Y(Math.round(i.x/e)*e,Math.round(i.y/e)*e)}}const xo=o=>o<.5?2*o*o:-1+(4-2*o)*o;class ye extends Y{constructor(i=0,e=0,t=0,n={x:0,y:0},r=0,s=0){super(i,e,t),this.x=i,this.y=e,this.z=t,this.v=n,this.t=r,this.a=s}get timestamp(){return this.t}get pressure(){return this.z}get angleNum(){return this.a}get XY(){return[this.x,this.y]}setA(i){this.a=i}setT(i){this.t=i}setv(i){return this.v={x:i.x,y:i.y},this}set(i=this.x,e=this.y,t=this.z,n=this.v,r=this.t,s=this.a){return this.x=i,this.y=e,this.z=t,this.v=n,this.t=r,this.a=s,this}clone(){const{x:i,y:e,z:t,v:n,t:r,a:s}=this,a={x:n.x,y:n.y};return new ye(i,e,t,a,r,s)}distance(i){return ye.GetDistance(this,i)}isNear(i,e){return ye.IsNear(this,i,e)}getAngleByPoints(i,e){return ye.GetAngleByPoints(i,this,e)}static Sub(i,e){return new ye(i.x-e.x,i.y-e.y)}static Add(i,e){return new ye(i.x+e.x,i.y+e.y)}static GetDistance(i,e){return ye.Len(i.clone().sub(e))}static GetAngleByPoints(i,e,t){const n=e.x-i.x,r=t.x-e.x,s=e.y-i.y,a=t.y-e.y;let c=0;const l=Math.sqrt(n*n+s*s),h=Math.sqrt(r*r+a*a);if(l&&h){const u=n*r+s*a;c=Math.acos(u/(l*h)),c=c/Math.PI*180;let M=n*a-s*r;M=M>0?1:-1,c=180+M*c}return c}static IsNear(i,e,t){return ye.Len(i.clone().sub(e))<t}static RotWith(i,e,t,n=2){const r=i.x-e.x,s=i.y-e.y,a=Math.sin(t),c=Math.cos(t),l=Math.pow(10,n),h=Math.floor((e.x+(r*c-s*a))*l)/l,u=Math.floor((e.y+(r*a+s*c))*l)/l;return new ye(h,u)}static GetDotStroke(i,e,t=16){const n=new Y(1,1),r=Math.PI+.001,s=ye.Add(i,ye.Sub(i,n).uni().per().mul(-e)),a=[];for(let c=1/t,l=c;l<=1;l+=c)a.push(ye.RotWith(s,i,r*2*l));return a}static GetSemicircleStroke(i,e,t=-1,n=8){const r=t*(Math.PI+.001),s=[];for(let a=1/n,c=a;c<=1;c+=a)s.push(ye.RotWith(e,i,r*c));return s}}var Lt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Qt(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var zo=typeof Lt=="object"&&Lt&&Lt.Object===Object&&Lt,En=zo,Ao=En,bo=typeof self=="object"&&self&&self.Object===Object&&self,Eo=Ao||bo||Function("return this")(),Be=Eo,ko=Be,Lo=ko.Symbol,zt=Lo,Vi=zt,kn=Object.prototype,Po=kn.hasOwnProperty,Oo=kn.toString,Tt=Vi?Vi.toStringTag:void 0;function Ro(o){var i=Po.call(o,Tt),e=o[Tt];try{o[Tt]=void 0;var t=!0}catch{}var n=Oo.call(o);return t&&(i?o[Tt]=e:delete o[Tt]),n}var Yo=Ro,Uo=Object.prototype,Wo=Uo.toString;function Bo(o){return Wo.call(o)}var Fo=Bo,Qi=zt,Vo=Yo,Qo=Fo,Zo="[object Null]",Ho="[object Undefined]",Zi=Qi?Qi.toStringTag:void 0;function $o(o){return o==null?o===void 0?Ho:Zo:Zi&&Zi in Object(o)?Vo(o):Qo(o)}var ft=$o;function Go(o){return o!=null&&typeof o=="object"}var Ke=Go;function Jo(){this.__data__=[],this.size=0}var Xo=Jo;function qo(o,i){return o===i||o!==o&&i!==i}var vi=qo,Ko=vi;function _o(o,i){for(var e=o.length;e--;)if(Ko(o[e][0],i))return e;return-1}var Zt=_o,er=Zt,tr=Array.prototype,ir=tr.splice;function nr(o){var i=this.__data__,e=er(i,o);if(e<0)return!1;var t=i.length-1;return e==t?i.pop():ir.call(i,e,1),--this.size,!0}var or=nr,rr=Zt;function sr(o){var i=this.__data__,e=rr(i,o);return e<0?void 0:i[e][1]}var ar=sr,cr=Zt;function lr(o){return cr(this.__data__,o)>-1}var ur=lr,hr=Zt;function dr(o,i){var e=this.__data__,t=hr(e,o);return t<0?(++this.size,e.push([o,i])):e[t][1]=i,this}var gr=dr,Mr=Xo,fr=or,pr=ar,yr=ur,mr=gr;function pt(o){var i=-1,e=o==null?0:o.length;for(this.clear();++i<e;){var t=o[i];this.set(t[0],t[1])}}pt.prototype.clear=Mr;pt.prototype.delete=fr;pt.prototype.get=pr;pt.prototype.has=yr;pt.prototype.set=mr;var Ht=pt,Ir=Ht;function wr(){this.__data__=new Ir,this.size=0}var Nr=wr;function Tr(o){var i=this.__data__,e=i.delete(o);return this.size=i.size,e}var vr=Tr;function Cr(o){return this.__data__.get(o)}var Sr=Cr;function jr(o){return this.__data__.has(o)}var Dr=jr;function xr(o){var i=typeof o;return o!=null&&(i=="object"||i=="function")}var _e=xr,zr=ft,Ar=_e,br="[object AsyncFunction]",Er="[object Function]",kr="[object GeneratorFunction]",Lr="[object Proxy]";function Pr(o){if(!Ar(o))return!1;var i=zr(o);return i==Er||i==kr||i==br||i==Lr}var Ln=Pr,Or=Be,Rr=Or["__core-js_shared__"],Yr=Rr,ii=Yr,Hi=function(){var o=/[^.]+$/.exec(ii&&ii.keys&&ii.keys.IE_PROTO||"");return o?"Symbol(src)_1."+o:""}();function Ur(o){return!!Hi&&Hi in o}var Wr=Ur,Br=Function.prototype,Fr=Br.toString;function Vr(o){if(o!=null){try{return Fr.call(o)}catch{}try{return o+""}catch{}}return""}var Pn=Vr,Qr=Ln,Zr=Wr,Hr=_e,$r=Pn,Gr=/[\\^$.*+?()[\]{}|]/g,Jr=/^\[object .+?Constructor\]$/,Xr=Function.prototype,qr=Object.prototype,Kr=Xr.toString,_r=qr.hasOwnProperty,es=RegExp("^"+Kr.call(_r).replace(Gr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ts(o){if(!Hr(o)||Zr(o))return!1;var i=Qr(o)?es:Jr;return i.test($r(o))}var is=ts;function ns(o,i){return o==null?void 0:o[i]}var os=ns,rs=is,ss=os;function as(o,i){var e=ss(o,i);return rs(e)?e:void 0}var at=as,cs=at,ls=Be,us=cs(ls,"Map"),Ci=us,hs=at,ds=hs(Object,"create"),$t=ds,$i=$t;function gs(){this.__data__=$i?$i(null):{},this.size=0}var Ms=gs;function fs(o){var i=this.has(o)&&delete this.__data__[o];return this.size-=i?1:0,i}var ps=fs,ys=$t,ms="__lodash_hash_undefined__",Is=Object.prototype,ws=Is.hasOwnProperty;function Ns(o){var i=this.__data__;if(ys){var e=i[o];return e===ms?void 0:e}return ws.call(i,o)?i[o]:void 0}var Ts=Ns,vs=$t,Cs=Object.prototype,Ss=Cs.hasOwnProperty;function js(o){var i=this.__data__;return vs?i[o]!==void 0:Ss.call(i,o)}var Ds=js,xs=$t,zs="__lodash_hash_undefined__";function As(o,i){var e=this.__data__;return this.size+=this.has(o)?0:1,e[o]=xs&&i===void 0?zs:i,this}var bs=As,Es=Ms,ks=ps,Ls=Ts,Ps=Ds,Os=bs;function yt(o){var i=-1,e=o==null?0:o.length;for(this.clear();++i<e;){var t=o[i];this.set(t[0],t[1])}}yt.prototype.clear=Es;yt.prototype.delete=ks;yt.prototype.get=Ls;yt.prototype.has=Ps;yt.prototype.set=Os;var Rs=yt,Gi=Rs,Ys=Ht,Us=Ci;function Ws(){this.size=0,this.__data__={hash:new Gi,map:new(Us||Ys),string:new Gi}}var Bs=Ws;function Fs(o){var i=typeof o;return i=="string"||i=="number"||i=="symbol"||i=="boolean"?o!=="__proto__":o===null}var Vs=Fs,Qs=Vs;function Zs(o,i){var e=o.__data__;return Qs(i)?e[typeof i=="string"?"string":"hash"]:e.map}var Gt=Zs,Hs=Gt;function $s(o){var i=Hs(this,o).delete(o);return this.size-=i?1:0,i}var Gs=$s,Js=Gt;function Xs(o){return Js(this,o).get(o)}var qs=Xs,Ks=Gt;function _s(o){return Ks(this,o).has(o)}var ea=_s,ta=Gt;function ia(o,i){var e=ta(this,o),t=e.size;return e.set(o,i),this.size+=e.size==t?0:1,this}var na=ia,oa=Bs,ra=Gs,sa=qs,aa=ea,ca=na;function mt(o){var i=-1,e=o==null?0:o.length;for(this.clear();++i<e;){var t=o[i];this.set(t[0],t[1])}}mt.prototype.clear=oa;mt.prototype.delete=ra;mt.prototype.get=sa;mt.prototype.has=aa;mt.prototype.set=ca;var On=mt,la=Ht,ua=Ci,ha=On,da=200;function ga(o,i){var e=this.__data__;if(e instanceof la){var t=e.__data__;if(!ua||t.length<da-1)return t.push([o,i]),this.size=++e.size,this;e=this.__data__=new ha(t)}return e.set(o,i),this.size=e.size,this}var Ma=ga,fa=Ht,pa=Nr,ya=vr,ma=Sr,Ia=Dr,wa=Ma;function It(o){var i=this.__data__=new fa(o);this.size=i.size}It.prototype.clear=pa;It.prototype.delete=ya;It.prototype.get=ma;It.prototype.has=Ia;It.prototype.set=wa;var Rn=It;function Na(o,i){for(var e=-1,t=o==null?0:o.length;++e<t&&i(o[e],e,o)!==!1;);return o}var Ta=Na,va=at,Ca=function(){try{var o=va(Object,"defineProperty");return o({},"",{}),o}catch{}}(),Yn=Ca,Ji=Yn;function Sa(o,i,e){i=="__proto__"&&Ji?Ji(o,i,{configurable:!0,enumerable:!0,value:e,writable:!0}):o[i]=e}var Un=Sa,ja=Un,Da=vi,xa=Object.prototype,za=xa.hasOwnProperty;function Aa(o,i,e){var t=o[i];(!(za.call(o,i)&&Da(t,e))||e===void 0&&!(i in o))&&ja(o,i,e)}var Wn=Aa,ba=Wn,Ea=Un;function ka(o,i,e,t){var n=!e;e||(e={});for(var r=-1,s=i.length;++r<s;){var a=i[r],c=t?t(e[a],o[a],a,e,o):void 0;c===void 0&&(c=o[a]),n?Ea(e,a,c):ba(e,a,c)}return e}var Jt=ka;function La(o,i){for(var e=-1,t=Array(o);++e<o;)t[e]=i(e);return t}var Pa=La,Oa=ft,Ra=Ke,Ya="[object Arguments]";function Ua(o){return Ra(o)&&Oa(o)==Ya}var Wa=Ua,Xi=Wa,Ba=Ke,Bn=Object.prototype,Fa=Bn.hasOwnProperty,Va=Bn.propertyIsEnumerable,Qa=Xi(function(){return arguments}())?Xi:function(o){return Ba(o)&&Fa.call(o,"callee")&&!Va.call(o,"callee")},Fn=Qa,Za=Array.isArray,At=Za,Yt={exports:{}};function Ha(){return!1}var $a=Ha;Yt.exports;(function(o,i){var e=Be,t=$a,n=i&&!i.nodeType&&i,r=n&&!0&&o&&!o.nodeType&&o,s=r&&r.exports===n,a=s?e.Buffer:void 0,c=a?a.isBuffer:void 0,l=c||t;o.exports=l})(Yt,Yt.exports);var Si=Yt.exports,Ga=9007199254740991,Ja=/^(?:0|[1-9]\d*)$/;function Xa(o,i){var e=typeof o;return i=i??Ga,!!i&&(e=="number"||e!="symbol"&&Ja.test(o))&&o>-1&&o%1==0&&o<i}var qa=Xa,Ka=9007199254740991;function _a(o){return typeof o=="number"&&o>-1&&o%1==0&&o<=Ka}var Vn=_a,ec=ft,tc=Vn,ic=Ke,nc="[object Arguments]",oc="[object Array]",rc="[object Boolean]",sc="[object Date]",ac="[object Error]",cc="[object Function]",lc="[object Map]",uc="[object Number]",hc="[object Object]",dc="[object RegExp]",gc="[object Set]",Mc="[object String]",fc="[object WeakMap]",pc="[object ArrayBuffer]",yc="[object DataView]",mc="[object Float32Array]",Ic="[object Float64Array]",wc="[object Int8Array]",Nc="[object Int16Array]",Tc="[object Int32Array]",vc="[object Uint8Array]",Cc="[object Uint8ClampedArray]",Sc="[object Uint16Array]",jc="[object Uint32Array]",pe={};pe[mc]=pe[Ic]=pe[wc]=pe[Nc]=pe[Tc]=pe[vc]=pe[Cc]=pe[Sc]=pe[jc]=!0;pe[nc]=pe[oc]=pe[pc]=pe[rc]=pe[yc]=pe[sc]=pe[ac]=pe[cc]=pe[lc]=pe[uc]=pe[hc]=pe[dc]=pe[gc]=pe[Mc]=pe[fc]=!1;function Dc(o){return ic(o)&&tc(o.length)&&!!pe[ec(o)]}var xc=Dc;function zc(o){return function(i){return o(i)}}var Xt=zc,Ut={exports:{}};Ut.exports;(function(o,i){var e=En,t=i&&!i.nodeType&&i,n=t&&!0&&o&&!o.nodeType&&o,r=n&&n.exports===t,s=r&&e.process,a=function(){try{var c=n&&n.require&&n.require("util").types;return c||s&&s.binding&&s.binding("util")}catch{}}();o.exports=a})(Ut,Ut.exports);var ji=Ut.exports,Ac=xc,bc=Xt,qi=ji,Ki=qi&&qi.isTypedArray,Ec=Ki?bc(Ki):Ac,Qn=Ec,kc=Pa,Lc=Fn,Pc=At,Oc=Si,Rc=qa,Yc=Qn,Uc=Object.prototype,Wc=Uc.hasOwnProperty;function Bc(o,i){var e=Pc(o),t=!e&&Lc(o),n=!e&&!t&&Oc(o),r=!e&&!t&&!n&&Yc(o),s=e||t||n||r,a=s?kc(o.length,String):[],c=a.length;for(var l in o)(i||Wc.call(o,l))&&!(s&&(l=="length"||n&&(l=="offset"||l=="parent")||r&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||Rc(l,c)))&&a.push(l);return a}var Zn=Bc,Fc=Object.prototype;function Vc(o){var i=o&&o.constructor,e=typeof i=="function"&&i.prototype||Fc;return o===e}var Di=Vc;function Qc(o,i){return function(e){return o(i(e))}}var Hn=Qc,Zc=Hn,Hc=Zc(Object.keys,Object),$c=Hc,Gc=Di,Jc=$c,Xc=Object.prototype,qc=Xc.hasOwnProperty;function Kc(o){if(!Gc(o))return Jc(o);var i=[];for(var e in Object(o))qc.call(o,e)&&e!="constructor"&&i.push(e);return i}var _c=Kc,el=Ln,tl=Vn;function il(o){return o!=null&&tl(o.length)&&!el(o)}var xi=il,nl=Zn,ol=_c,rl=xi;function sl(o){return rl(o)?nl(o):ol(o)}var zi=sl,al=Jt,cl=zi;function ll(o,i){return o&&al(i,cl(i),o)}var ul=ll;function hl(o){var i=[];if(o!=null)for(var e in Object(o))i.push(e);return i}var dl=hl,gl=_e,Ml=Di,fl=dl,pl=Object.prototype,yl=pl.hasOwnProperty;function ml(o){if(!gl(o))return fl(o);var i=Ml(o),e=[];for(var t in o)t=="constructor"&&(i||!yl.call(o,t))||e.push(t);return e}var Il=ml,wl=Zn,Nl=Il,Tl=xi;function vl(o){return Tl(o)?wl(o,!0):Nl(o)}var Ai=vl,Cl=Jt,Sl=Ai;function jl(o,i){return o&&Cl(i,Sl(i),o)}var Dl=jl,Wt={exports:{}};Wt.exports;(function(o,i){var e=Be,t=i&&!i.nodeType&&i,n=t&&!0&&o&&!o.nodeType&&o,r=n&&n.exports===t,s=r?e.Buffer:void 0,a=s?s.allocUnsafe:void 0;function c(l,h){if(h)return l.slice();var u=l.length,M=a?a(u):new l.constructor(u);return l.copy(M),M}o.exports=c})(Wt,Wt.exports);var xl=Wt.exports;function zl(o,i){var e=-1,t=o.length;for(i||(i=Array(t));++e<t;)i[e]=o[e];return i}var Al=zl;function bl(o,i){for(var e=-1,t=o==null?0:o.length,n=0,r=[];++e<t;){var s=o[e];i(s,e,o)&&(r[n++]=s)}return r}var $n=bl;function El(){return[]}var Gn=El,kl=$n,Ll=Gn,Pl=Object.prototype,Ol=Pl.propertyIsEnumerable,_i=Object.getOwnPropertySymbols,Rl=_i?function(o){return o==null?[]:(o=Object(o),kl(_i(o),function(i){return Ol.call(o,i)}))}:Ll,bi=Rl,Yl=Jt,Ul=bi;function Wl(o,i){return Yl(o,Ul(o),i)}var Bl=Wl;function Fl(o,i){for(var e=-1,t=i.length,n=o.length;++e<t;)o[n+e]=i[e];return o}var Ei=Fl,Vl=Hn,Ql=Vl(Object.getPrototypeOf,Object),Jn=Ql,Zl=Ei,Hl=Jn,$l=bi,Gl=Gn,Jl=Object.getOwnPropertySymbols,Xl=Jl?function(o){for(var i=[];o;)Zl(i,$l(o)),o=Hl(o);return i}:Gl,Xn=Xl,ql=Jt,Kl=Xn;function _l(o,i){return ql(o,Kl(o),i)}var eu=_l,tu=Ei,iu=At;function nu(o,i,e){var t=i(o);return iu(o)?t:tu(t,e(o))}var qn=nu,ou=qn,ru=bi,su=zi;function au(o){return ou(o,su,ru)}var Kn=au,cu=qn,lu=Xn,uu=Ai;function hu(o){return cu(o,uu,lu)}var du=hu,gu=at,Mu=Be,fu=gu(Mu,"DataView"),pu=fu,yu=at,mu=Be,Iu=yu(mu,"Promise"),wu=Iu,Nu=at,Tu=Be,vu=Nu(Tu,"Set"),_n=vu,Cu=at,Su=Be,ju=Cu(Su,"WeakMap"),Du=ju,li=pu,ui=Ci,hi=wu,di=_n,gi=Du,eo=ft,wt=Pn,en="[object Map]",xu="[object Object]",tn="[object Promise]",nn="[object Set]",on="[object WeakMap]",rn="[object DataView]",zu=wt(li),Au=wt(ui),bu=wt(hi),Eu=wt(di),ku=wt(gi),it=eo;(li&&it(new li(new ArrayBuffer(1)))!=rn||ui&&it(new ui)!=en||hi&&it(hi.resolve())!=tn||di&&it(new di)!=nn||gi&&it(new gi)!=on)&&(it=function(o){var i=eo(o),e=i==xu?o.constructor:void 0,t=e?wt(e):"";if(t)switch(t){case zu:return rn;case Au:return en;case bu:return tn;case Eu:return nn;case ku:return on}return i});var qt=it,Lu=Object.prototype,Pu=Lu.hasOwnProperty;function Ou(o){var i=o.length,e=new o.constructor(i);return i&&typeof o[0]=="string"&&Pu.call(o,"index")&&(e.index=o.index,e.input=o.input),e}var Ru=Ou,Yu=Be,Uu=Yu.Uint8Array,to=Uu,sn=to;function Wu(o){var i=new o.constructor(o.byteLength);return new sn(i).set(new sn(o)),i}var ki=Wu,Bu=ki;function Fu(o,i){var e=i?Bu(o.buffer):o.buffer;return new o.constructor(e,o.byteOffset,o.byteLength)}var Vu=Fu,Qu=/\w*$/;function Zu(o){var i=new o.constructor(o.source,Qu.exec(o));return i.lastIndex=o.lastIndex,i}var Hu=Zu,an=zt,cn=an?an.prototype:void 0,ln=cn?cn.valueOf:void 0;function $u(o){return ln?Object(ln.call(o)):{}}var Gu=$u,Ju=ki;function Xu(o,i){var e=i?Ju(o.buffer):o.buffer;return new o.constructor(e,o.byteOffset,o.length)}var qu=Xu,Ku=ki,_u=Vu,eh=Hu,th=Gu,ih=qu,nh="[object Boolean]",oh="[object Date]",rh="[object Map]",sh="[object Number]",ah="[object RegExp]",ch="[object Set]",lh="[object String]",uh="[object Symbol]",hh="[object ArrayBuffer]",dh="[object DataView]",gh="[object Float32Array]",Mh="[object Float64Array]",fh="[object Int8Array]",ph="[object Int16Array]",yh="[object Int32Array]",mh="[object Uint8Array]",Ih="[object Uint8ClampedArray]",wh="[object Uint16Array]",Nh="[object Uint32Array]";function Th(o,i,e){var t=o.constructor;switch(i){case hh:return Ku(o);case nh:case oh:return new t(+o);case dh:return _u(o,e);case gh:case Mh:case fh:case ph:case yh:case mh:case Ih:case wh:case Nh:return ih(o,e);case rh:return new t;case sh:case lh:return new t(o);case ah:return eh(o);case ch:return new t;case uh:return th(o)}}var vh=Th,Ch=_e,un=Object.create,Sh=function(){function o(){}return function(i){if(!Ch(i))return{};if(un)return un(i);o.prototype=i;var e=new o;return o.prototype=void 0,e}}(),jh=Sh,Dh=jh,xh=Jn,zh=Di;function Ah(o){return typeof o.constructor=="function"&&!zh(o)?Dh(xh(o)):{}}var bh=Ah,Eh=qt,kh=Ke,Lh="[object Map]";function Ph(o){return kh(o)&&Eh(o)==Lh}var Oh=Ph,Rh=Oh,Yh=Xt,hn=ji,dn=hn&&hn.isMap,Uh=dn?Yh(dn):Rh,Wh=Uh,Bh=qt,Fh=Ke,Vh="[object Set]";function Qh(o){return Fh(o)&&Bh(o)==Vh}var Zh=Qh,Hh=Zh,$h=Xt,gn=ji,Mn=gn&&gn.isSet,Gh=Mn?$h(Mn):Hh,io=Gh;const Jh=Qt(io);var Xh=Rn,qh=Ta,Kh=Wn,_h=ul,ed=Dl,td=xl,id=Al,nd=Bl,od=eu,rd=Kn,sd=du,ad=qt,cd=Ru,ld=vh,ud=bh,hd=At,dd=Si,gd=Wh,Md=_e,fd=io,pd=zi,yd=Ai,md=1,Id=2,wd=4,no="[object Arguments]",Nd="[object Array]",Td="[object Boolean]",vd="[object Date]",Cd="[object Error]",oo="[object Function]",Sd="[object GeneratorFunction]",jd="[object Map]",Dd="[object Number]",ro="[object Object]",xd="[object RegExp]",zd="[object Set]",Ad="[object String]",bd="[object Symbol]",Ed="[object WeakMap]",kd="[object ArrayBuffer]",Ld="[object DataView]",Pd="[object Float32Array]",Od="[object Float64Array]",Rd="[object Int8Array]",Yd="[object Int16Array]",Ud="[object Int32Array]",Wd="[object Uint8Array]",Bd="[object Uint8ClampedArray]",Fd="[object Uint16Array]",Vd="[object Uint32Array]",Me={};Me[no]=Me[Nd]=Me[kd]=Me[Ld]=Me[Td]=Me[vd]=Me[Pd]=Me[Od]=Me[Rd]=Me[Yd]=Me[Ud]=Me[jd]=Me[Dd]=Me[ro]=Me[xd]=Me[zd]=Me[Ad]=Me[bd]=Me[Wd]=Me[Bd]=Me[Fd]=Me[Vd]=!0;Me[Cd]=Me[oo]=Me[Ed]=!1;function Ot(o,i,e,t,n,r){var s,a=i&md,c=i&Id,l=i&wd;if(e&&(s=n?e(o,t,n,r):e(o)),s!==void 0)return s;if(!Md(o))return o;var h=hd(o);if(h){if(s=cd(o),!a)return id(o,s)}else{var u=ad(o),M=u==oo||u==Sd;if(dd(o))return td(o,a);if(u==ro||u==no||M&&!n){if(s=c||M?{}:ud(o),!a)return c?od(o,ed(s,o)):nd(o,_h(s,o))}else{if(!Me[u])return n?o:{};s=ld(o,u,a)}}r||(r=new Xh);var p=r.get(o);if(p)return p;r.set(o,s),fd(o)?o.forEach(function(y){s.add(Ot(y,i,e,y,o,r))}):gd(o)&&o.forEach(function(y,w){s.set(w,Ot(y,i,e,w,o,r))});var f=l?c?sd:rd:c?yd:pd,g=h?void 0:f(o);return qh(g||o,function(y,w){g&&(w=y,y=o[w]),Kh(s,w,Ot(y,i,e,w,o,r))}),s}var Qd=Ot,Zd=Qd,Hd=1,$d=4;function Gd(o){return Zd(o,Hd|$d)}var Jd=Gd;const bt=Qt(Jd),so="1.1.23",Xd="@netless/appliance-plugin",fn=typeof OffscreenCanvas=="function"?"worker":"mainThread";if(typeof window<"u"){let o=window.__netlessUA||"";o+=` ${Xd}@${so}`,window.__netlessUA=o}const we={useWorker:"auto",useSimple:!1,syncOpt:{interval:300,smoothSync:!0},cursor:{enable:!0,expirationTime:5e3,moveDelayTime:100},bufferSize:{full:2e4,sub:600},bezier:{enable:!0,maxDrawCount:1/0,combineUnitTime:300},pencilEraser:{useBitMap:!0,maxImageWidth:1920,maxImageHeight:1920,maxCombineTime:500},strokeWidth:{min:1,max:10},textEditor:{showFloatBar:!0,canSelectorSwitch:!0,rightBoundBreak:!1,extendFontFaces:[],loadFontFacesTimeout:1e4},longDottedStroke:{lineCap:"round",segment:1,gap:2},dottedStroke:{lineCap:"round",segment:1,gap:2},normalStroke:{lineCap:"round"}};function Kt(o){return JSON.parse(zn.decompress(o))}function xt(o){return zn.compress(JSON.stringify(o))}const De=Object.keys,$e="++",Z="selector",ao="all";var qd="__lodash_hash_undefined__";function Kd(o){return this.__data__.set(o,qd),this}var _d=Kd;function eg(o){return this.__data__.has(o)}var tg=eg,ig=On,ng=_d,og=tg;function Bt(o){var i=-1,e=o==null?0:o.length;for(this.__data__=new ig;++i<e;)this.add(o[i])}Bt.prototype.add=Bt.prototype.push=ng;Bt.prototype.has=og;var Li=Bt;function rg(o,i){for(var e=-1,t=o==null?0:o.length;++e<t;)if(i(o[e],e,o))return!0;return!1}var sg=rg;function ag(o,i){return o.has(i)}var Pi=ag,cg=Li,lg=sg,ug=Pi,hg=1,dg=2;function gg(o,i,e,t,n,r){var s=e&hg,a=o.length,c=i.length;if(a!=c&&!(s&&c>a))return!1;var l=r.get(o),h=r.get(i);if(l&&h)return l==i&&h==o;var u=-1,M=!0,p=e&dg?new cg:void 0;for(r.set(o,i),r.set(i,o);++u<a;){var f=o[u],g=i[u];if(t)var y=s?t(g,f,u,i,o,r):t(f,g,u,o,i,r);if(y!==void 0){if(y)continue;M=!1;break}if(p){if(!lg(i,function(w,I){if(!ug(p,I)&&(f===w||n(f,w,e,t,r)))return p.push(I)})){M=!1;break}}else if(!(f===g||n(f,g,e,t,r))){M=!1;break}}return r.delete(o),r.delete(i),M}var co=gg;function Mg(o){var i=-1,e=Array(o.size);return o.forEach(function(t,n){e[++i]=[n,t]}),e}var fg=Mg;function pg(o){var i=-1,e=Array(o.size);return o.forEach(function(t){e[++i]=t}),e}var Oi=pg,pn=zt,yn=to,yg=vi,mg=co,Ig=fg,wg=Oi,Ng=1,Tg=2,vg="[object Boolean]",Cg="[object Date]",Sg="[object Error]",jg="[object Map]",Dg="[object Number]",xg="[object RegExp]",zg="[object Set]",Ag="[object String]",bg="[object Symbol]",Eg="[object ArrayBuffer]",kg="[object DataView]",mn=pn?pn.prototype:void 0,ni=mn?mn.valueOf:void 0;function Lg(o,i,e,t,n,r,s){switch(e){case kg:if(o.byteLength!=i.byteLength||o.byteOffset!=i.byteOffset)return!1;o=o.buffer,i=i.buffer;case Eg:return!(o.byteLength!=i.byteLength||!r(new yn(o),new yn(i)));case vg:case Cg:case Dg:return yg(+o,+i);case Sg:return o.name==i.name&&o.message==i.message;case xg:case Ag:return o==i+"";case jg:var a=Ig;case zg:var c=t&Ng;if(a||(a=wg),o.size!=i.size&&!c)return!1;var l=s.get(o);if(l)return l==i;t|=Tg,s.set(o,i);var h=mg(a(o),a(i),t,n,r,s);return s.delete(o),h;case bg:if(ni)return ni.call(o)==ni.call(i)}return!1}var Pg=Lg;function Et(o,i,e){return"#"+((o<<16)+(i<<8)+e).toString(16).padStart(6,"0")}function ve(o,i=1){return"rgba("+parseInt("0x"+o.slice(1,3))+","+parseInt("0x"+o.slice(3,5))+","+parseInt("0x"+o.slice(5,7))+","+i+")"}function ut(o,i,e,t=1){return`rgba(${o},${i},${e},${t})`}function _t(o){const i=o.split(","),e=parseInt(i[0].split("(")[1]),t=parseInt(i[1]),n=parseInt(i[2]),r=Number(i[3].split(")")[0]);return[Et(e,t,n),r]}function vt(o){const i=o.split(","),e=parseInt(i[0].split("(")[1]),t=parseInt(i[1]),n=parseInt(i[2]),r=Number(i[3].split(")")[0]);return[e,t,n,r]}function Pt(o){return o==="transparent"}var We=(o=>(o[o.Text=1]="Text",o[o.Shape=2]="Shape",o))(We||{});const Og="cursorhover",Ri=20,ue="mainView",Ee=class Ee{createProxy(i){const e=new Proxy(i,{get(t,n,r){const s=Ee.interceptors.hasOwnProperty(n)?Ee.interceptors:t;return Reflect.get(s,n,r)}});return Ee.proxyToRaw.set(e,i),e}};m(Ee,"proxyToRaw",new WeakMap),m(Ee,"interceptors",{entries(...i){return Ee.proxyToRaw.get(this).entries(...i)},forEach(...i){return Ee.proxyToRaw.get(this).forEach(...i)},size(){return Ee.proxyToRaw.get(this).size},get(i){return Ee.proxyToRaw.get(this).get(i)},set(i,e){return Ee.proxyToRaw.get(this).set(i,e)},delete(i){return Ee.proxyToRaw.get(this).delete(i)},clear(){return Ee.proxyToRaw.get(this).clear()}});let nt=Ee;const Mi=5;class Rg{constructor(i){m(this,"internalMsgEmitter");m(this,"publicMsgEmitter");m(this,"control");m(this,"editors");m(this,"activeId");m(this,"proxyMap");m(this,"taskqueue",new Map);m(this,"checkLocalTextBlur",x.debounce(()=>{if(this.collector)for(const[i,e]of this.editors.entries())e.opt.workState!==j.Done&&this.collector.isLocalId(i)&&this.activeId!==i&&(e.opt.text&&e.opt.text.replace(/\s*,/g,"")?this.unActive(i):this.delete(i,!0,!0))},100));const{control:e,internalMsgEmitter:t,publicMsgEmitter:n}=i;this.control=e,this.internalMsgEmitter=t,this.publicMsgEmitter=n;const r=new Map;this.proxyMap=new nt;const s=this,a=nt.interceptors.set;nt.interceptors.set=function(l,h){return s.interceptors.set(l,h),a.call(this,l,h)};const c=nt.interceptors.delete;nt.interceptors.delete=function(l){return s.interceptors.delete(l),c.call(this,l)},this.editors=this.proxyMap.createProxy(r)}get collector(){return this.control.collector}filterEditor(i){const e=new Map;return this.editors.forEach((t,n)=>{t.viewId===i&&e.set(n,t)}),e}get interceptors(){return{set:(i,e)=>{var f,g,y,w,I,v,S,N;if(!this.collector)return!0;const{viewId:t,scenePath:n,canSync:r,canWorker:s,type:a,opt:c,dataType:l,updateNodeOpt:h}=e;if(!s&&!r)return!0;const M=((f=this.collector)==null?void 0:f.isLocalId(i))?(g=this.collector)==null?void 0:g.transformKey(i):i,p=((y=this.collector)==null?void 0:y.storage[t])&&this.collector.storage[t][n]&&this.collector.storage[t][n][M]||void 0;p?p.toolsType===T.Text&&(s&&(this.control.worker.queryTaskBatchData({workId:i,msgType:W.UpdateNode}).forEach(C=>{var D;(D=this.control.worker)==null||D.taskBatchData.delete(C)}),(S=this.control.worker)==null||S.taskBatchData.add({workId:i,msgType:W.UpdateNode,dataType:l||K.Local,toolsType:T.Text,opt:c,viewId:t,scenePath:n,willRefresh:!0}),(N=this.control.worker)==null||N.runAnimation()),r&&(Ue(()=>{var C;(C=this.collector)==null||C.dispatch({type:W.UpdateNode,workId:i,toolsType:T.Text,opt:c,viewId:t,scenePath:n,updateNodeOpt:h})},this.control.worker.maxLastSyncTime,this.control.hasPolyfillMethod("requestIdleCallback")),c.workState===j.Done&&this.control.runEffectWork(()=>{this.control.worker.setShapeSelectorByWorkId(i,t)}))):a===We.Text&&(r&&((w=this.collector)==null||w.dispatch({type:c.text&&W.FullWork||W.CreateWork,workId:i,toolsType:T.Text,opt:c,isSync:!0,viewId:t,scenePath:n,updateNodeOpt:h})),s&&((I=this.control.worker)==null||I.taskBatchData.add({workId:i,msgType:c.text&&W.FullWork||W.CreateWork,dataType:l||K.Local,toolsType:T.Text,opt:c,viewId:t,scenePath:n,willRefresh:!0}),(v=this.control.worker)==null||v.runAnimation()))},delete:i=>{var a,c;if(!this.collector)return!0;const e=this.editors.get(i);if(!e)return!0;const{viewId:t,scenePath:n,canSync:r,canWorker:s}=e;if(!s&&!r)return!0;s&&((a=this.control.worker)==null||a.taskBatchData.add({workId:i,toolsType:T.Text,msgType:W.RemoveNode,dataType:K.Local,viewId:t,scenePath:n,willRefresh:!0}),(c=this.control.worker)==null||c.runAnimation()),r&&Ue(()=>{var l;(l=this.collector)==null||l.dispatch({type:W.RemoveNode,removeIds:[i],toolsType:T.Text,viewId:t,scenePath:n})},this.control.worker.maxLastSyncTime,this.control.hasPolyfillMethod("requestIdleCallback"))},clear(){return!0}}}computeTextActive(i,e){var r,s,a,c;const t=(r=this.control.viewContainerManager)==null?void 0:r.transformToScenePoint(i,e),n=(s=this.control.viewContainerManager)==null?void 0:s.getCurScenePath(e);e&&n&&((a=this.control.worker)==null||a.taskBatchData.add({msgType:W.GetTextActive,dataType:K.Local,op:t,viewId:e,scenePath:n}),(c=this.control.worker)==null||c.runAnimation())}checkEmptyTextBlur(){var e;let i=this.activeId;for(const[t,n]of this.editors.entries())if(n.opt.uid&&n.opt.uid===((e=this.collector)==null?void 0:e.uid)){i=t;break}if(i){const t=this.editors.get(i);(t==null?void 0:t.opt.text)&&(t==null?void 0:t.opt.text.replace(/\s*,/g,""))?this.unActive(i):this.delete(i,!0,!0)}this.checkLocalTextBlur()}onCameraChange(i,e){var t,n;for(const[r,s]of this.editors.entries())if(s.viewId===e){const{boxPoint:a,boxSize:c}=s.opt,l=a&&((t=this.control.viewContainerManager)==null?void 0:t.transformToOriginPoint(a,s.viewId)),h=(n=this.control.viewContainerManager)==null?void 0:n.getCurScenePath(e);if(h&&e){const u={x:l&&l[0]||0,y:l&&l[1]||0,w:c&&c[0]||0,h:c&&c[1]||0,opt:s.opt,scale:i.scale,type:We.Text,viewId:e,scenePath:h,canWorker:!1,canSync:!1};this.editors.set(r,u),this.control.viewContainerManager.updateTextEditorInfo(e,this.activeId)}}}onServiceDerive(i){var g,y,w;const{workId:e,opt:t,msgType:n,viewId:r,scenePath:s,dataType:a,updateNodeOpt:c}=i;if(!e||!r||!s)return;const l=e.toString();if(n===W.RemoveNode){this.delete(l,!0,!0);return}const{boxPoint:h,boxSize:u}=t,M=h&&((g=this.control.viewContainerManager)==null?void 0:g.transformToOriginPoint(h,r)),p=this.control.viewContainerManager.getView(r),f={x:M&&M[0]||0,y:M&&M[1]||0,w:u&&u[0]||0,h:u&&u[1]||0,opt:t,type:We.Text,canWorker:!0,canSync:!1,dataType:a,scale:((y=p==null?void 0:p.cameraOpt)==null?void 0:y.scale)||1,viewId:r,scenePath:s};if(t&&t.workState===j.Done&&!this.control.cursor.isEnableCursor&&h&&u){let v=c==null?void 0:c.uid;if(!v){const S=this.editors.get(l);v=S&&((w=S.opt)==null?void 0:w.uid)}v&&this.control.cursor.collectServiceCursor({op:h&&[h[0]+u[0],h[1]+u[1]],uid:v,workState:j.Done,viewId:r,type:W.Cursor})}this.editors.set(l,f),a===K.Service&&t.workState===j.Done&&this.activeId===l&&(this.activeId=void 0),this.control.viewContainerManager.updateTextEditorInfo(r,this.activeId)}updateForViewEdited(i,e){var n;this.editors.set(i,e);const t=(n=this.taskqueue.get(i))==null?void 0:n.resolve;t&&t(e)}active(i){var t;const e=this.editors.get(i);e&&e.viewId&&(e.opt.workState=j.Start,e.opt.uid=(t=this.collector)==null?void 0:t.uid,this.activeId=i,e.canWorker=!0,e.canSync=!0,this.editors.set(i,e),this.control.viewContainerManager.updateTextEditorInfo(e.viewId,this.activeId))}unActive(i){var t;const e=this.editors.get(i);if(e&&e.viewId){e.opt.workState=j.Done,e.opt.uid=void 0,e.canWorker=!0,e.canSync=!0,this.editors.set(i,e),this.activeId=void 0;const n=(t=this.control.viewContainerManager.getView(e.viewId))==null?void 0:t.container;if(n){const r=CSS.escape(i),s=n.querySelector(`.editor-box #${r}`);s&&s.blur()}this.control.viewContainerManager.updateTextEditorInfo(e.viewId,this.activeId)}}createTextForMasterController(i,e){var s;const{workId:t,isActive:n,...r}=i;e&&this.internalMsgEmitter.emit("addUndoTicker",e,r.viewId),r.opt.uid=(s=this.collector)==null?void 0:s.uid,n&&(this.activeId=t),r.dataType=K.Local,r.canWorker=!0,r.canSync=!0,this.editors.set(t,r),this.control.viewContainerManager.updateTextEditorInfo(r.viewId,this.activeId)}updateTextForMasterController(i,e){var s;const{workId:t,...n}=i;e&&this.internalMsgEmitter.emit("addUndoTicker",e,n.viewId);const r=this.editors.get(t)||{};n.opt&&(n.opt.uid=(s=this.collector)==null?void 0:s.uid),n.dataType=K.Local,this.editors.set(t,{...r,...n}),this.control.viewContainerManager.updateTextEditorInfo(n.viewId,this.activeId)}async updateTextControllerWithEffectAsync(i,e){var h;const{workId:t,...n}=i;e&&this.internalMsgEmitter.emit("addUndoTicker",e,n.viewId);const r=this.editors.get(t)||{};n.opt&&(n.opt.uid=(h=this.collector)==null?void 0:h.uid),n.dataType=K.Local;const s={...r,...n};if(this.editors.set(t,s),this.control.viewContainerManager.updateTextEditorInfo(n.viewId,this.activeId),this.taskqueue.has(t)){const u=this.taskqueue.get(t);return u&&(u.clocker&&clearTimeout(u.clocker),this.taskqueue.delete(t)),await this.updateTextControllerWithEffectAsync(i)}const a=setTimeout(()=>{var M;const u=(M=this.taskqueue.get(t))==null?void 0:M.resolve;u&&u(s)},50),c=await new Promise(u=>{this.taskqueue.set(t,{resolve:u,clocker:a})}),l=this.taskqueue.get(t);return l&&(l.clocker&&clearTimeout(l.clocker),this.taskqueue.delete(t)),c}updateTextForWorker(i,e){const{workId:t,isActive:n,...r}=i,a={...this.editors.get(t)||{},...r};if(n){a.canWorker=!1,a.canSync=!1,this.editors.set(t,a),this.active(t);return}this.editors.set(t,a),this.control.viewContainerManager.updateTextEditorInfo(r.viewId,this.activeId),e&&this.internalMsgEmitter.emit("addUndoTicker",e,r.viewId)}get(i){return this.editors.get(i)}delete(i,e,t){const n=this.editors.get(i);if(n){const r=n.viewId;n.canSync=e,n.canWorker=t,this.editors.delete(i),this.activeId===i&&(this.activeId=void 0),this.control.viewContainerManager.updateTextEditorInfo(r,this.activeId)}}deleteBatch(i,e,t){const n=new Set;for(const r of i){const s=this.editors.get(r);if(s){const a=s.viewId;s.canSync=e,s.canWorker=t,this.editors.delete(r),this.activeId===r&&(this.activeId=void 0),n.add(a)}}for(const r of n)this.control.viewContainerManager.updateTextEditorInfo(r,this.activeId)}clear(i,e){this.editors.forEach((t,n)=>{t.viewId===i&&(e&&(t.canSync=!1),t.canWorker=!1,this.editors.delete(n))}),this.activeId=void 0,this.control.viewContainerManager.updateTextEditorInfo(i,this.activeId)}destory(){this.editors.clear(),this.activeId=void 0}insertText(i,e,t,n){var f,g;const r=(f=this.control.room)==null?void 0:f.state.memberState;if(!r)return;const s=this.control.viewContainerManager.getView(i);if(!(s!=null&&s.focusScenePath))return;const a=s==null?void 0:s.cameraOpt,c=this.control.getToolsOpt(T.Text,r);if(!c)return;const l=(g=this.control.viewContainerManager)==null?void 0:g.transformToOriginPoint([e,t],i),u=ai(n,{whiteList:{},stripIgnoreTag:!0,stripIgnoreTagBody:["script"]}).split(/\n/),M=c.toolsOpt;M.text=xt(u),M.workState=j.Doing,M.boxPoint=[Math.round(e),Math.round(t)],M.boxSize=[M.fontSize,M.fontSize];const p=this.control.worker.now;return this.control.textEditorManager.checkEmptyTextBlur(),this.control.textEditorManager.createTextForMasterController({workId:p.toString(),x:l&&l[0]||0,y:l&&l[1]||0,scale:(a==null?void 0:a.scale)||1,opt:M,type:We.Text,isActive:!0,viewId:i,scenePath:s.focusScenePath},p),p.toString()}updateText(i,e){const t=this.editors.get(i.toString());if(!t)return;const r=ai(e,{whiteList:{},stripIgnoreTag:!0,stripIgnoreTagBody:["script"]}).split(/\n/);t.opt.text=xt(r),this.control.textEditorManager.updateTextForMasterController({workId:i,opt:t.opt,viewId:t.viewId,canSync:!0,canWorker:!0},this.control.worker.now)}}function Yg(o){return o}var lo=Yg;function Ug(o,i,e){switch(e.length){case 0:return o.call(i);case 1:return o.call(i,e[0]);case 2:return o.call(i,e[0],e[1]);case 3:return o.call(i,e[0],e[1],e[2])}return o.apply(i,e)}var Wg=Ug,Bg=Wg,In=Math.max;function Fg(o,i,e){return i=In(i===void 0?o.length-1:i,0),function(){for(var t=arguments,n=-1,r=In(t.length-i,0),s=Array(r);++n<r;)s[n]=t[i+n];n=-1;for(var a=Array(i+1);++n<i;)a[n]=t[n];return a[i]=e(s),Bg(o,this,a)}}var Vg=Fg;function Qg(o){return function(){return o}}var Zg=Qg,Hg=Zg,wn=Yn,$g=lo,Gg=wn?function(o,i){return wn(o,"toString",{configurable:!0,enumerable:!1,value:Hg(i),writable:!0})}:$g,Jg=Gg,Xg=800,qg=16,Kg=Date.now;function _g(o){var i=0,e=0;return function(){var t=Kg(),n=qg-(t-e);if(e=t,n>0){if(++i>=Xg)return arguments[0]}else i=0;return o.apply(void 0,arguments)}}var eM=_g,tM=Jg,iM=eM,nM=iM(tM),oM=nM,rM=lo,sM=Vg,aM=oM;function cM(o,i){return aM(sM(o,i,rM),o+"")}var lM=cM;function uM(o,i,e,t){for(var n=o.length,r=e+(t?1:-1);t?r--:++r<n;)if(i(o[r],r,o))return r;return-1}var hM=uM;function dM(o){return o!==o}var gM=dM;function MM(o,i,e){for(var t=e-1,n=o.length;++t<n;)if(o[t]===i)return t;return-1}var fM=MM,pM=hM,yM=gM,mM=fM;function IM(o,i,e){return i===i?mM(o,i,e):pM(o,yM,e)}var wM=IM,NM=wM;function TM(o,i){var e=o==null?0:o.length;return!!e&&NM(o,i,0)>-1}var uo=TM;function vM(o,i,e){for(var t=-1,n=o==null?0:o.length;++t<n;)if(e(i,o[t]))return!0;return!1}var ho=vM;function CM(o,i){for(var e=-1,t=o==null?0:o.length,n=Array(t);++e<t;)n[e]=i(o[e],e,o);return n}var SM=CM,jM=Li,DM=uo,xM=ho,zM=SM,AM=Xt,bM=Pi,EM=200;function kM(o,i,e,t){var n=-1,r=DM,s=!0,a=o.length,c=[],l=i.length;if(!a)return c;e&&(i=zM(i,AM(e))),t?(r=xM,s=!1):i.length>=EM&&(r=bM,s=!1,i=new jM(i));e:for(;++n<a;){var h=o[n],u=e==null?h:e(h);if(h=t||h!==0?h:0,s&&u===u){for(var M=l;M--;)if(i[M]===u)continue e;c.push(h)}else r(i,u,t)||c.push(h)}return c}var LM=kM,Nn=zt,PM=Fn,OM=At,Tn=Nn?Nn.isConcatSpreadable:void 0;function RM(o){return OM(o)||PM(o)||!!(Tn&&o&&o[Tn])}var YM=RM,UM=Ei,WM=YM;function go(o,i,e,t,n){var r=-1,s=o.length;for(e||(e=WM),n||(n=[]);++r<s;){var a=o[r];i>0&&e(a)?i>1?go(a,i-1,e,t,n):UM(n,a):t||(n[n.length]=a)}return n}var BM=go;function FM(){}var VM=FM,oi=_n,QM=VM,ZM=Oi,HM=1/0,$M=oi&&1/ZM(new oi([,-0]))[1]==HM?function(o){return new oi(o)}:QM,GM=$M,JM=Li,XM=uo,qM=ho,KM=Pi,_M=GM,ef=Oi,tf=200;function nf(o,i,e){var t=-1,n=XM,r=o.length,s=!0,a=[],c=a;if(e)s=!1,n=qM;else if(r>=tf){var l=i?null:_M(o);if(l)return ef(l);s=!1,n=KM,c=new JM}else c=i?[]:a;e:for(;++t<r;){var h=o[t],u=i?i(h):h;if(h=e||h!==0?h:0,s&&u===u){for(var M=c.length;M--;)if(c[M]===u)continue e;i&&c.push(u),a.push(h)}else n(c,u,e)||(c!==a&&c.push(u),a.push(h))}return a}var of=nf,rf=LM,sf=BM,vn=of;function af(o,i,e){var t=o.length;if(t<2)return t?vn(o[0]):[];for(var n=-1,r=Array(t);++n<t;)for(var s=o[n],a=-1;++a<t;)a!=n&&(r[n]=rf(r[n]||s,o[a],i,e));return vn(sf(r,1),i,e)}var cf=af,lf=xi,uf=Ke;function hf(o){return uf(o)&&lf(o)}var df=hf,gf=$n,Mf=lM,ff=cf,pf=df;Mf(function(o){return ff(gf(o,pf))});function Mo(o,i){if(o&&i){const e=Math.min(o.x,i.x),t=Math.min(o.y,i.y),n=Math.max(o.x+o.w,i.x+i.w),r=Math.max(o.y+o.h,i.y+i.h),s=n-e,a=r-t;return{x:e,y:t,w:s,h:a}}return i||o}function Yi(o,i){if(o&&i){const e=Math.min(o.originX,i.originX),t=Math.min(o.originY,i.originY),n=Math.max(o.originX+o.width,i.originX+i.width),r=Math.max(o.originY+o.height,i.originY+i.height),s=n-e,a=r-t;return{originX:e,originY:t,width:s,height:a}}return i||o}function Ui(o,i=0){const e={x:0,y:0,w:0,h:0};let t=1/0,n=1/0,r=-1/0,s=-1/0;return o.forEach(a=>{const[c,l]=a.XY;t=Math.min(t,c-i),n=Math.min(n,l-i),r=Math.max(r,c+i),s=Math.max(s,l+i)}),e.x=t,e.y=n,e.w=r-t,e.h=s-n,e}function yf(o,i){return!(o.x+o.w<i.x||o.x>i.x+i.w||o.y+o.h<i.y||o.y>i.y+i.h)}function mf(o,i=10){return{x:Math.floor(o.x-i),y:Math.floor(o.y-i),w:Math.ceil(o.w+i*2),h:Math.ceil(o.h+i*2)}}function If(o,i){return{x:o.x+i[0],y:o.y+i[1],w:o.w,h:o.h}}function wf(o,i){const e=new Y(o.x,o.y),t=new Y(o.x+o.w,o.y),n=new Y(o.x+o.w,o.y+o.h),r=new Y(o.x,o.y+o.h),s=new Y(o.x+o.w/2,o.y+o.h/2),a=Math.PI*i/180,c=Y.RotWith(e,s,a),l=Y.RotWith(t,s,a),h=Y.RotWith(n,s,a),u=Y.RotWith(r,s,a);return[c,l,h,u]}function Nf(o,i){const e=wf(o,i);return Ui(e)}function Tf(o,i,e){const t=new Y(o.x,o.y),n=new Y(o.x+o.w,o.y),r=new Y(o.x+o.w,o.y+o.h),s=new Y(o.x,o.y+o.h),a=new Y(e[0],e[1]),c=new Y(i[0],i[1]),l=Y.ScaleWOrigin(t,c,a),h=Y.ScaleWOrigin(n,c,a),u=Y.ScaleWOrigin(r,c,a),M=Y.ScaleWOrigin(s,c,a);return Ui([l,h,u,M])}function vf(o,i,e){const t=new Y(i[0],i[1]);for(let n=0;n<o.length;n+=3){const r=new Y(o[n],o[n+1]),s=Math.PI*e/180,a=Y.RotWith(r,t,s);o[n]=a.x,o[n+1]=a.y}}function Cf(o,i,e){const t=new Y(i[0],i[1]);for(let n=0;n<o.length;n+=2){const r=new Y(o[n],o[n+1]),s=Math.PI*e/180,a=Y.RotWith(r,t,s);o[n]=a.x,o[n+1]=a.y}}function Sf(o,i,e,t=[0,0]){const n=new Y(i[0],i[1]);for(let r=0;r<o.length;r+=3){const s=new Y(o[r],o[r+1]),a=new Y(e[0],e[1]),c=Y.ScaleWOrigin(s,a,n);o[r]=c.x+t[0],o[r+1]=c.y+t[1]}}function jf(o,i,e,t=[0,0]){const n=new Y(i[0],i[1]);for(let r=0;r<o.length;r+=2){const s=new Y(o[r],o[r+1]),a=new Y(e[0],e[1]),c=Y.ScaleWOrigin(s,a,n);o[r]=c.x+t[0],o[r+1]=c.y+t[1]}}function fo(o,i){return o[0]>=i.x&&o[0]<=i.x+i.w&&o[1]>=i.y&&o[1]<=i.y+i.h}function Df(o,i){const e=o<=i?1:o/i,t=i<=o?1:i/o;return[e,t]}function xf(o){for(const i of o)if(isNaN(i)||i===1/0||i===-1/0)return!1;return!0}function zf(o){return o!==Math.floor(o)}function Af(o){const i=o.toString();return i.indexOf(".")!==-1?i.split(".")[1].length:0}function bf(o,i){for(;i!==0;)[o,i]=[i,o%i];return o}function Ef(o){return`${Ft(o.x)},${Ft(o.y)} `}function kf(o,i){return`${Ft((o.x+i.x)/2)},${Ft((o.y+i.y)/2)} `}function Ft(o){return+o.toFixed(4)}const Ue=async(o,i,e=!1)=>{let t,n;return new Promise(function(r){if(e&&requestIdleCallback)requestIdleCallback(()=>{r(1)},{timeout:i});else{if(typeof window.requestIdleCallback=="function"){const s=typeof i=="number"&&!isNaN(i)&&i>0?i:0;n=window.requestIdleCallback(()=>{clearTimeout(t),r(1)},{timeout:s})}t=setTimeout(()=>{n&&window.cancelIdleCallback(n),r(1)},i||0)}}).then(function(){o()}).catch(function(){o()})},gt=o=>Math.max(1,(window.devicePixelRatio||1)/1),Lf=(o,i)=>o.x+o.w<i.x||o.x>i.x+i.w||o.y+o.h<i.y||o.y>i.y+i.h?St.outside:o.x>=i.x&&o.y>=i.y&&o.x+o.w<=i.x+i.w&&o.y+o.h<=i.y+i.h?St.inside:St.intersect;function Pf(o){let i=0;for(let e=0;e<o.length;e++){const t=o.charCodeAt(e);t>=1&&t<=126||65376<=t&&t<=65439?i++:i+=2}return i}class Of{constructor(i,e){m(this,"plugin");m(this,"uid");m(this,"control");this.control=i,this.plugin=e,this.uid=e.displayer.uid}getNamespaceData(){var i;return F.toJS((i=this.plugin)==null?void 0:i.attributes[this.namespace])||{}}getAuthSpaceData(){var i;return F.toJS((i=this.plugin)==null?void 0:i.attributes[this.authSpace])||{}}getUidFromKey(i){return i.split($e).length===2&&i.split($e)[0]||this.uid}isLocalId(i){return i.split($e).length===1}getLocalId(i){return i.split($e)[1]}isSelector(i){return this.getLocalId(i)===Z}}const ke=class ke extends Of{constructor(e,t,n){super(e,t);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);m(this,"limitNums",new Map);m(this,"syncInterval");m(this,"limitComponents",x.debounce((e,t)=>{var s,a,c,l,h,u,M,p;const n=((a=(s=this.storage)==null?void 0:s[e])==null?void 0:a[t])&&Object.keys(this.storage[e][t]).length||0;if(n===0)return;let r=this.limitNums.get(`${e}/${t}`);if(!r){const f=this.getLimitNum(n);this.limitNums.set(`${e}/${t}`,f),r=f}if(r>0&&n>=r){const f=ke.componentsLimits.indexOf(r),g=f>=0&&f<ke.componentsLimits.length-1;if((h=(l=(c=this.control.room)==null?void 0:c.callbacks)==null?void 0:l.listeners)!=null&&h.map.onObjectsLimit&&((M=(u=this.control.room)==null?void 0:u.callbacks)==null||M.dispatch("onObjectsLimit",w=>w(r,g))),!g){this.control.room.logger.error(`exceeds the limit of ${r} components, current: ${n}`),(p=this.control.room)==null||p.disconnect().then(()=>{var w,I,v,S,N;(v=(I=(w=this.control.room)==null?void 0:w.callbacks)==null?void 0:I.listeners)!=null&&v.map.onKickedWithReason&&((N=(S=this.control.room)==null?void 0:S.callbacks)==null||N.dispatch("onKickedWithReason",C=>C("kickByAdmin")))});return}console.warn(`exceeds the limit of ${r} components, current: ${n}`);const y=g?ke.componentsLimits[f+1]:0;this.limitNums.set(`${e}/${t}`,y)}},2e3,{maxWait:5e3}));m(this,"clearLimitComponents",(e,t)=>{if(t)this.limitNums.delete(`${e}/${t}`);else for(const n of this.limitNums.keys())`${e}/`.indexOf(n)===0&&this.limitNums.delete(n)});this.syncInterval=n,this.namespace=ke.namespace,this.authSpace=ke.authSpace,this.serviceStorage=this.getNamespaceData(),this.storage=x.cloneDeep(this.serviceStorage),this.authStorage=this.getAuthSpaceData(),this.getLimitNums()}getLimitNum(e){return e>=ke.componentsLimits[0]?ke.componentsLimits[1]:ke.componentsLimits[0]}getLimitNums(){for(const[e,t]of Object.entries(this.storage))if(e&&t){for(const[n,r]of Object.entries(t))if(n&&r){const s=this.getLimitNum(Object.keys(r).length);this.limitNums.set(`${e}/${n}`,s)}}}getViewIdBySecenPath(e){const t=this.getNamespaceData();for(const[n,r]of Object.entries(t))if(r){for(const s of Object.keys(r))if(s===e)return n}}getScenePathData(e){const t=this.getNamespaceData();for(const n of Object.values(t))if(n){for(const r of Object.keys(n))if(r===e)return x.cloneDeep(n[r])}}getStorageData(e,t){const n=this.getNamespaceData();return n&&n[e]&&x.cloneDeep(n[e][t])||void 0}hasSelector(e,t){const n=this.storage&&this.storage[e]&&this.storage[e][t];return!!(n&&Object.keys(n).find(r=>this.isOwn(r)&&this.getLocalId(r)===Z))}hasIncludeSelector(e,t,n){for(const r of Object.keys(this.storage))if(!(t&&r!==t)){for(const s of Object.keys(this.storage[r]))if(!(n&&s!==n)){for(const a of Object.keys(this.storage[r][s]))if(this.getLocalId(a)===Z){const c=this.storage[r][s][a],l=this.isLocalId(e)?this.transformKey(e):e;if(c&&c.selectIds&&c.selectIds.length&&c.selectIds.includes(l))return!0}}}return!1}addStorageStateListener(e){this.stateDisposer=F.autorun(async()=>{var c,l,h,u,M,p;const t=this.getNamespaceData(),{diffView:n,diffScenePath:r,diffData:s}=this.diffFunByView(this.serviceStorage,t);this.serviceStorage=t;const a={};if(Object.keys(n).length>0)for(const[f,g]of Object.entries(n))g&&!x.isEqual((c=this.storage)==null?void 0:c[f],g.newValue)&&(a.diffView||(a.diffView={}),a.diffView[f]=g,this.storage||(this.storage={}),g.newValue===void 0?delete this.storage[f]:this.storage[f]=x.cloneDeep(g.newValue));if(Object.keys(r).length>0){for(const[f,g]of Object.entries(r))if(g){const{viewId:y,newValue:w}=g;g&&!x.isEqual((h=(l=this.storage)==null?void 0:l[y])==null?void 0:h[f],w)&&(a.diffScenePath||(a.diffScenePath={}),a.diffScenePath[f]=g,this.storage||(this.storage={}),this.storage[y]||(this.storage[y]={}),g.newValue===void 0?delete this.storage[y][f]:this.storage[y][f]=x.cloneDeep(g.newValue))}}if(Object.keys(s).length>0){for(const[f,g]of Object.entries(s))if(g){const{viewId:y,scenePath:w,newValue:I}=g;g&&!x.isEqual((p=(M=(u=this.storage)==null?void 0:u[y])==null?void 0:M[w])==null?void 0:p[f],I)&&(a.diffData||(a.diffData={}),a.diffData[f]=g,this.storage||(this.storage={}),this.storage[y]||(this.storage[y]={}),this.storage[y][w]||(this.storage[y][w]={}),g.newValue===void 0?delete this.storage[y][w][f]:this.storage[y][w][f]=x.cloneDeep(g.newValue))}}Object.keys(a).length>0&&e(a),this.control.worker.publicMsgEmitter.emit("syncStorageChange",this.serviceStorage)})}removeStorageStateListener(){this.stateDisposer&&this.stateDisposer()}diffFunByView(e,t){const n=De(e),r=De(t),s={},a={},c={};for(const l of r)if(!n.includes(l)||e[l]===void 0){s[l]={newValue:t[l],oldValue:void 0};continue}for(const l of n){if(x.isEqual(e[l],t[l]))continue;if(!r.includes(l)||t[l]===void 0){s[l]={newValue:void 0,oldValue:e[l]};continue}const h=this.diffFunByScenePath(e[l],t[l],l);Object.assign(a,h.diffScenePath),Object.assign(c,h.diffData)}return{diffData:c,diffScenePath:a,diffView:s}}diffFunByScenePath(e,t,n){const r=De(e),s=De(t),a={},c={};for(const l of s)if(!r.includes(l)||e[l]===void 0){a[l]={newValue:t[l],oldValue:void 0,viewId:n};continue}for(const l of r){if(x.isEqual(e[l],t[l]))continue;if(!s.includes(l)||t[l]===void 0){a[l]={newValue:void 0,oldValue:e[l],viewId:n};continue}const h=this.diffFunByKeys(e[l],t[l],l,n);Object.assign(c,h)}return{diffScenePath:a,diffData:c}}diffFunByKeys(e,t,n,r){const s=De(e),a=De(t),c={};for(const l of a)(!s.includes(l)||e[l]===void 0)&&(c[l]={oldValue:void 0,newValue:t[l],viewId:r,scenePath:n});for(const l of s)if(!x.isEqual(e[l],t[l])){if(!a.includes(l)||t[l]===void 0){c[l]={newValue:void 0,oldValue:e[l],viewId:r,scenePath:n};continue}a.includes(l)&&(c[l]={oldValue:e[l],newValue:t[l],viewId:r,scenePath:n})}return c}transformKey(e){return this.uid+$e+e}isOwn(e){return e.split($e)[0]===this.uid}dispatch(e){const{type:t,workId:n,ops:r,index:s,opt:a,toolsType:c,removeIds:l,updateNodeOpt:h,op:u,selectIds:M,isSync:p,scenePath:f,viewId:g}=e;if(g)switch(t){case W.Clear:const y={};f&&this.storage[g]&&this.storage[g][f]?(delete this.storage[g][f],this.setState(y,{isSync:p,viewId:g,scenePath:f})):this.storage[g]&&(delete this.storage[g],this.setState(y,{isSync:p,viewId:g,scenePath:""})),Ue(()=>{var N,C;this.control.isUseSimple||((N=this.control.pluginManager)==null||N.dispatchPluginEvent("syncStorage",g,f),(C=this.control.miniMapManager)==null||C.updateMiniMapCamera(g)),this.clearLimitComponents(g,f)},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback"));break;case W.CreateWork:if(f&&n&&c&&a){const N=this.isLocalId(n.toString())?this.transformKey(n):n;this.control.renderControl.isUsePageAuth(g)&&this.control.renderControl.addRenderPageElementId({viewId:g,scenePath:f,elementId:N.toString()}),this.updateValue(N.toString(),{type:W.CreateWork,workId:n,toolsType:c,opt:a},{isSync:p,viewId:g,scenePath:f})}break;case W.DrawWork:if(f&&n&&typeof s=="number"&&(u!=null&&u.length)){const N=this.isLocalId(n.toString())?this.transformKey(n):n,C=this.storage[g]&&this.storage[g][f]&&this.storage[g][f][N]||void 0;if(C!=null&&C.ops||(C==null?void 0:C.type)===W.FullWork)return;const D=s?((C==null?void 0:C.op)||[]).slice(0,s).concat(u):u||(C==null?void 0:C.op),k=c||(C==null?void 0:C.toolsType),P=a||(C==null?void 0:C.opt),L=h||(C==null?void 0:C.updateNodeOpt);n&&k&&P&&D&&(this.control.renderControl.isUsePageAuth(g)&&this.control.renderControl.addRenderPageElementId({viewId:g,scenePath:f,elementId:N.toString()}),this.updateValue(N.toString(),{...C,type:W.DrawWork,workId:n,updateNodeOpt:L,toolsType:k,opt:P,op:D,index:s},{isSync:p,viewId:g,scenePath:f}))}break;case W.FullWork:if(f&&n){const N=this.isLocalId(n.toString())?this.transformKey(n):n,C=this.storage[g]&&this.storage[g][f]&&this.storage[g][f][N]||void 0,D=h||(C==null?void 0:C.updateNodeOpt),k=c||(C==null?void 0:C.toolsType),P=a||(C==null?void 0:C.opt),L=r||(C==null?void 0:C.ops);k&&P&&(this.control.renderControl.isUsePageAuth(g)&&this.control.renderControl.addRenderPageElementId({viewId:g,scenePath:f,elementId:N.toString()}),this.updateValue(N.toString(),{type:W.FullWork,updateNodeOpt:D,workId:N,toolsType:k,opt:P,ops:L},{isSync:p,viewId:g,scenePath:f}),Ue(()=>{var O,E;this.control.isUseSimple||((O=this.control.pluginManager)==null||O.dispatchPluginEvent("syncStorage",g,f),(E=this.control.miniMapManager)==null||E.updateMiniMapCamera(g)),this.limitComponents(g,f)},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback")))}break;case W.RemoveNode:if(f&&(l!=null&&l.length)){const N=l.map(C=>this.isLocalId(C+"")?this.transformKey(C):C);this.storage[g]&&this.storage[g][f]&&(Object.keys(this.storage[g][f]).map(C=>{N!=null&&N.includes(C)&&(this.control.renderControl.isUsePageAuth(g)&&this.control.renderControl.delRenderPageElementId({viewId:g,scenePath:f,elementId:C}),this.updateValue(C,void 0,{isSync:p,viewId:g,scenePath:f}))}),this.control.isUseSimple||Ue(()=>{var C,D;(C=this.control.pluginManager)==null||C.dispatchPluginEvent("syncStorage",g,f),(D=this.control.miniMapManager)==null||D.updateMiniMapCamera(g)},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback")))}break;case W.UpdateNode:if(f&&n&&(h||r||a)){const N=this.isLocalId(n.toString())?this.transformKey(n):n,C=this.storage[g]&&this.storage[g][f]&&this.storage[g][f][N]||void 0;C&&(C.updateNodeOpt=h,(r||u)&&(C.ops=r,C.op=u),a&&(C.opt=a),C.type=W.FullWork,this.updateValue(N.toString(),C,{isSync:p,viewId:g,scenePath:f}),this.control.isUseSimple||Ue(()=>{var D;(D=this.control.miniMapManager)==null||D.updateMiniMapCamera(g)},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback")))}break;case W.Select:if(!f)return;let w;M!=null&&M.length&&(w=M.map(N=>this.isLocalId(N+"")?this.transformKey(N):N));const I=this.transformKey(Z),v=this.storage[g]&&this.storage[g][f]&&this.storage[g][f][I]||void 0,S=a||(v==null?void 0:v.opt);w&&this.checkOtherSelector(I,w,{isSync:p,viewId:g,scenePath:f}),this.updateValue(I,w&&{type:W.Select,toolsType:T.Selector,opt:S,selectIds:w},{isSync:p,viewId:g,scenePath:f});break}}checkOtherSelector(e,t,n){const{viewId:r,scenePath:s}=n;for(const a of Object.keys(this.storage[r][s]))if(a!==e&&this.getLocalId(a)===Z){const c=this.storage[r][s][a];if(c&&c.selectIds){const l=c.selectIds.filter(h=>!t.includes(h));l.length>0&&(c.selectIds=l),this.updateValue(a,l.length&&c||void 0,n)}}}setState(e,t){const{viewId:n,scenePath:r}=t,s=De(e);for(let a=0;a<s.length;a++){const c=s[a],l=e[c];typeof l<"u"?(this.storage[n]||(this.storage[n]={}),this.storage[n][r]||(this.storage[n][r]={}),this.storage[n][r][c]=l):delete this.storage[n][r][c]}this.runSyncService(t)}updateValue(e,t,n){const{viewId:r,scenePath:s,storage:a}=n,c=a||this.storage;t===void 0?delete c[r][s][e]:(c[r]||(c[r]={}),c[r][s]||(c[r][s]={}),c[r][s][e]=t),this.runSyncService(n)}runSyncService(e){if(!this.control.renderControl.isWritable){this.control.room&&this.control.room.logger?this.control.room.logger.error("The current state is not writable and synchronization cannot be synchronized"):console.error("The current state is not writable and synchronization cannot be synchronized");return}this.asyncClockState||(this.asyncClockState=!0,e.isSync?(this.asyncClockState=!1,this.syncSerivice(e)):Ue(()=>{this.asyncClockState=!1,this.syncSerivice(e)},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback")))}syncSerivice(e={storage:this.storage}){const{storage:t}=e,n=t||this.storage,r=De(this.serviceStorage),s=De(n),a=new Map;for(const c of r){if(!s.includes(c)){a.set(c,void 0);continue}x.isEqual(this.serviceStorage[c],n[c])||this.syncViewData(n,c)}for(const c of s)r.includes(c)||a.set(c,n[c]);if(a.size>5)this.syncStorageView(n);else for(const[c,l]of a.entries())this.syncUpdataView(n,c,l)}syncViewData(e,t){const n=De(this.serviceStorage[t]),r=De(e[t]),s=new Map;for(const a of n){if(!r.includes(a)){s.set(a,void 0);continue}x.isEqual(this.serviceStorage[t][a],e[t][a])||this.syncScenePathData(e,t,a)}for(const a of r)n.includes(a)||s.set(a,e[t][a]);if(s.size>5)this.syncStorageScenePath(t,e[t]);else for(const[a,c]of s.entries())this.syncUpdataScenePath(e,t,a,c)}syncScenePathData(e,t,n){const r=De(this.serviceStorage[t][n]),s=De(e[t][n]),a=new Map;for(const c of r){if(!s.includes(c)){a.set(c,void 0);continue}x.isEqual(this.serviceStorage[t][n][c],e[t][n][c])||a.set(c,e[t][n][c])}for(const c of s)r.includes(c)||a.set(c,e[t][n][c]);if(a.size>5)this.syncStorageKey(t,n,e[t][n]);else for(const[c,l]of a.entries())this.syncUpdataKey(e,t,n,c,l)}syncUpdataView(e,t,n){var s;Object.keys(this.serviceStorage).length?(s=this.plugin)==null||s.updateAttributes([this.namespace,t],n):this.syncStorageView(e)}syncStorageView(e){var t;(t=this.plugin)==null||t.updateAttributes([this.namespace],e)}syncUpdataScenePath(e,t,n,r){var a;Object.keys(this.serviceStorage[t]).length?(a=this.plugin)==null||a.updateAttributes([this.namespace,t,n],r):this.syncStorageScenePath(t,e[t])}syncStorageScenePath(e,t){var n;(n=this.plugin)==null||n.updateAttributes([this.namespace,e],t)}syncUpdataKey(e,t,n,r,s){var c;Object.keys(this.serviceStorage[t][n]).length?(c=this.plugin)==null||c.updateAttributes([this.namespace,t,n,r],s):this.syncStorageKey(t,n,e[t][n])}syncStorageKey(e,t,n){var r;(r=this.plugin)==null||r.updateAttributes([this.namespace,e,t],n)}keyTransformWorkId(e){const t=e.split($e);return t.length===2?t[1]:e}destroy(){this.removeStorageStateListener(),this.serviceStorage={},this.storage={},this.removeAuthStateListener(),this.authStorage={}}dispatchPageAuth(e,t=!0){var l,h,u,M,p,f,g,y,w,I,v,S,N,C,D,k,P,L,O,E,R,z,V,te,B,$,ie,re,ne,J,H,le,Fe,Ve,et,Ge,Qe,X;const{operation:n,viewId:r,scenePath:s,pageId:a,pageData:c}=e;switch(n){case ze.addPage:{if(!r||!s||!a)return;const ge=[this.authSpace];Object.keys(this.authStorage).length&&ge.push("pageAuth");const Q=this.authStorage.pageAuth||{};this.authStorage.pageAuth=Q,Object.keys(Q).length&&ge.push(r),Q[r]=Q[r]||{},Object.keys(Q[r]).length&&ge.push(s),Q[r][s]=Q[r][s]||{render:(c==null?void 0:c.render)||"localSelf",pages:{}},Object.keys(Q[r][s].pages).length&&ge.push("pages",a);const G={};if(c!=null&&c.elementIds)for(const q of c.elementIds.keys())G[q]=!0;Q[r][s].pages[a]=G,t&&(ge.length===1?(l=this.plugin)==null||l.updateAttributes(ge,x.cloneDeep(this.authStorage)):ge.length===2?(h=this.plugin)==null||h.updateAttributes(ge,x.cloneDeep(Q)):ge.length===3?(u=this.plugin)==null||u.updateAttributes(ge,x.cloneDeep(Q[r])):ge.length===4?(M=this.plugin)==null||M.updateAttributes(ge,x.cloneDeep(Q[r][s])):(p=this.plugin)==null||p.updateAttributes(ge,x.cloneDeep(G)));return}case ze.renderPage:{if(!r||!s||!(c!=null&&c.render))return;this.authStorage.pageAuth&&this.authStorage.pageAuth[r]&&this.authStorage.pageAuth[r][s]&&c.render!==this.authStorage.pageAuth[r][s].render&&(this.authStorage.pageAuth[r][s].render=c.render,t&&((f=this.plugin)==null||f.updateAttributes([this.authSpace,"pageAuth",r,s,"render"],c.render)));return}case ze.deletePage:{if(!r||!s||!a)return;(v=(I=(w=(y=(g=this.authStorage)==null?void 0:g.pageAuth)==null?void 0:y[r])==null?void 0:w[s])==null?void 0:I.pages)!=null&&v[a]&&(delete this.authStorage.pageAuth[r][s].pages[a],t&&((S=this.plugin)==null||S.updateAttributes([this.authSpace,"pageAuth",r,s,"pages",a],void 0)));return}case ze.clearPage:{if(!r||!s||!a)return;(P=(k=(D=(C=(N=this.authStorage)==null?void 0:N.pageAuth)==null?void 0:C[r])==null?void 0:D[s])==null?void 0:k.pages)!=null&&P[a]&&(delete this.authStorage.pageAuth[r][s].pages[a],t&&((L=this.plugin)==null||L.updateAttributes([this.authSpace,"pageAuth",r,s,"pages",a],{})));return}case ze.addElement:{if(!r||!s||!a||!(c!=null&&c.elementId))return;(V=(z=(R=(E=(O=this.authStorage)==null?void 0:O.pageAuth)==null?void 0:E[r])==null?void 0:R[s])==null?void 0:z.pages)!=null&&V[a]&&(this.authStorage.pageAuth[r][s].pages[a][c.elementId]=!0,t&&((te=this.plugin)==null||te.updateAttributes([this.authSpace,"pageAuth",r,s,"pages",a,c.elementId],!0)));return}case ze.deleteElement:{if(!r||!s||!a||!(c!=null&&c.elementId))return;(J=(ne=(re=(ie=($=(B=this.authStorage)==null?void 0:B.pageAuth)==null?void 0:$[r])==null?void 0:ie[s])==null?void 0:re.pages)==null?void 0:ne[a])!=null&&J[c.elementId]&&(delete this.authStorage.pageAuth[r][s].pages[a][c.elementId],t&&((H=this.plugin)==null||H.updateAttributes([this.authSpace,"pageAuth",r,s,"pages",a,c.elementId],void 0)));return}case ze.clearViewScenePath:{if(!r||!s)return;(Ve=(Fe=(le=this.authStorage)==null?void 0:le.pageAuth)==null?void 0:Fe[r])!=null&&Ve[s]&&(delete this.authStorage.pageAuth[r][s],t&&((et=this.plugin)==null||et.updateAttributes([this.authSpace,"pageAuth",r,s],void 0)));return}case ze.clearView:{if(!r)return;(Qe=(Ge=this.authStorage)==null?void 0:Ge.pageAuth)!=null&&Qe[r]&&(delete this.authStorage.pageAuth[r],t&&((X=this.plugin)==null||X.updateAttributes([this.authSpace,"pageAuth",r],void 0)));return}}}dispatchRenderAuth(e,t=!0){var l,h,u,M,p,f,g,y,w,I,v,S,N,C,D,k,P,L,O,E;const{operation:n,viewId:r,uid:s,renderData:a,isClear:c}=e;if(r)switch(n){case Ye.setAuth:{if(!a||a.render===void 0&&a.hide===void 0&&a.clear===void 0){this.authStorage.renderAuth&&this.authStorage.renderAuth[r]&&(delete this.authStorage.renderAuth[r],t&&((l=this.plugin)==null||l.updateAttributes([this.authSpace,"renderAuth",r],void 0)));return}const R=[this.authSpace];Object.keys(this.authStorage).length&&R.push("renderAuth");const z=this.authStorage.renderAuth||{};Object.keys(z).length&&R.push(r),z[r]={},this.authStorage.renderAuth=z;const{render:V,hide:te,clear:B}=a;if(V===!0)z[r].render=!0;else if(x.isSet(V)){z[r].render={};for(const $ of V.keys())z[r].render[$]=!0}if(te===!0)z[r].hide=!0;else if(x.isSet(te)){z[r].hide={};for(const $ of te.keys())z[r].hide[$]=!0}if(B===!0)z[r].clear=!0;else if(x.isSet(B)){z[r].clear={};for(const $ of B.keys())z[r].clear[$]=!0}t&&(R.length===1?(h=this.plugin)==null||h.updateAttributes(R,x.cloneDeep(this.authStorage)):R.length===2?(u=this.plugin)==null||u.updateAttributes(R,x.cloneDeep(z)):(M=this.plugin)==null||M.updateAttributes(R,x.cloneDeep(z[r])));return}case Ye.setShow:{if(!s)return;const R=[this.authSpace];Object.keys(this.authStorage).length&&R.push("renderAuth");const z=this.authStorage.renderAuth||{};Object.keys(z).length&&R.push(r),z[r]=z[r]||{},this.authStorage.renderAuth=z,Object.keys(z[r]).length&&R.push("render"),z[r].render=z[r].render||{},z[r].render!==!0&&(Object.keys(z[r].render).length&&R.push(s),z[r].render[s]=!0),z[r].hide!==!0&&((p=z[r].hide)!=null&&p[s])&&(delete z[r].hide[s],t&&((f=this.plugin)==null||f.updateAttributes([this.authSpace,"renderAuth",r,"hide",s],void 0))),t&&(R.length===1?(g=this.plugin)==null||g.updateAttributes(R,x.cloneDeep(this.authStorage)):R.length===2?(y=this.plugin)==null||y.updateAttributes(R,x.cloneDeep(z)):R.length===3?(w=this.plugin)==null||w.updateAttributes(R,x.cloneDeep(z[r])):(I=this.plugin)==null||I.updateAttributes(R,!0));return}case Ye.setHide:{if(!s)return;const R=[this.authSpace];Object.keys(this.authStorage).length&&R.push("renderAuth");const z=this.authStorage.renderAuth||{};Object.keys(z).length&&R.push(r),z[r]=z[r]||{},this.authStorage.renderAuth=z,Object.keys(z[r]).length&&R.push("hide"),z[r].hide=z[r].hide||{},z[r].hide!==!0&&(Object.keys(z[r].hide).length&&R.push(s),z[r].hide[s]=!0),z[r].render!==!0&&((v=z[r].render)!=null&&v[s])&&(delete z[r].render[s],t&&((S=this.plugin)==null||S.updateAttributes([this.authSpace,"renderAuth",r,"render",s],void 0))),t&&(R.length===1?(N=this.plugin)==null||N.updateAttributes(R,x.cloneDeep(this.authStorage)):R.length===2?(C=this.plugin)==null||C.updateAttributes(R,x.cloneDeep(z)):R.length===3?(D=this.plugin)==null||D.updateAttributes(R,x.cloneDeep(z[r])):(k=this.plugin)==null||k.updateAttributes(R,!0));return}case Ye.setClear:{if(!s)return;const R=[this.authSpace];Object.keys(this.authStorage).length&&R.push("renderAuth");const z=this.authStorage.renderAuth||{};Object.keys(z).length&&R.push(r),z[r]=z[r]||{},this.authStorage.renderAuth=z,Object.keys(z[r]).length&&R.push("clear"),z[r].clear=z[r].clear||{},z[r].clear!==!0&&(Object.keys(z[r].clear).length&&R.push(s),c?z[r].clear[s]=!0:delete z[r].clear[s]),t&&(R.length===1?(P=this.plugin)==null||P.updateAttributes(R,x.cloneDeep(this.authStorage)):R.length===2?(L=this.plugin)==null||L.updateAttributes(R,x.cloneDeep(z)):R.length===3?(O=this.plugin)==null||O.updateAttributes(R,x.cloneDeep(z[r])):(E=this.plugin)==null||E.updateAttributes(R,c?!0:void 0));return}}}addAuthStateListener(e){this.authDisposer=F.autorun(async()=>{const t=this.getAuthSpaceData(),{renderAuth:n,pageAuth:r}=t;let s,a;x.isEqual(n,this.authStorage.renderAuth)||(s=this.diffAuthFun(this.authStorage.renderAuth||{},n||{}),this.authStorage.renderAuth=n),x.isEqual(r,this.authStorage.pageAuth)||(a=this.diffAuthPageFun(this.authStorage.pageAuth||{},r||{}),this.authStorage.pageAuth=r),(s||a)&&e(s,a)})}removeAuthStateListener(){this.authDisposer&&this.authDisposer()}diffAuthFun(e,t){const n=De(e),r=De(t),s={};for(const a of r)if(!n.includes(a)||e[a]===void 0){s[a]={newValue:t[a],oldValue:void 0};continue}for(const a of n)if(!x.isEqual(e[a],t[a])){if(!r.includes(a)||t[a]===void 0){s[a]={newValue:void 0,oldValue:e[a]};continue}s[a]={newValue:t[a],oldValue:e[a]}}return s}diffAuthPageFun(e,t){const n=De(e),r=De(t),s={};for(const a of r)if(!n.includes(a)||e[a]===void 0){s[a]={newValue:t[a],oldValue:void 0};continue}for(const a of n)if(!x.isEqual(e[a],t[a])){if(!r.includes(a)||t[a]===void 0){s[a]={newValue:void 0,oldValue:e[a]};continue}s[a]={newValue:t[a],oldValue:e[a]}}return s}};m(ke,"namespace","PluginState"),m(ke,"authSpace","PluginAuth"),m(ke,"componentsLimits",[500,1e3]);let fi=ke;class Rf{constructor(){m(this,"roomMembers",[]);m(this,"onChangeHooks",new Set)}setRoomMembers(i){this.executChangeUidHook(this.roomMembers,i),this.roomMembers=i}executChangeUidHook(i,e){const t={online:e.map(n=>{var r;return((r=n.payload)==null?void 0:r.uid)||n.session}),offline:i.map(n=>{var r;return((r=n.payload)==null?void 0:r.uid)||n.session})};this.onChangeHooks.forEach(n=>n(t))}getAllRoomMembers(){return this.roomMembers}getRoomMember(i){return this.roomMembers.find(e=>{var t;return((t=e.payload)==null?void 0:t.uid)===i})}isOnLine(i){return!!this.getRoomMember(i)}onUidChangeHook(i){this.onChangeHooks.add(i)}destroy(){this.onChangeHooks.clear()}}class Yf{constructor(i){m(this,"expirationTime",we.cursor.expirationTime);m(this,"isEnableCursor");m(this,"internalMsgEmitter");m(this,"publicMsgEmitter");m(this,"control");m(this,"eventName","applianc-cursor");m(this,"displayer");m(this,"roomMember");m(this,"animationId");m(this,"maxLastSyncTime");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);const{control:e,internalMsgEmitter:t,publicMsgEmitter:n}=i;this.internalMsgEmitter=t,this.publicMsgEmitter=n,this.expirationTime=x.isNumber(e.pluginOptions.extras.cursor.expirationTime)?e.pluginOptions.extras.cursor.expirationTime:this.expirationTime,this.control=e,this.roomMember=e.roomMember,this.maxLastSyncTime=this.control.pluginOptions.extras.syncOpt.interval,this.isEnableCursor=this.control.pluginOptions.extras.cursor.enable}activeCollector(){this.control.plugin&&this.isEnableCursor&&(this.displayer=this.control.room||this.control.play,this.displayer.addMagixEventListener(this.eventName,this.mainMagixEventListener.bind(this)))}mainMagixEventListener(i){var a;const{event:e,payload:t}=i;if(e!==this.eventName)return;const{uid:n,op:r,type:s}=t;if(((a=this.control.collector)==null?void 0:a.uid)!==n&&s===Ct.Cursor&&(r!=null&&r.length)){const c=this.willConsumeEventWorkers.get(n)||[];for(const l of r){const{viewId:h}=l;x.isNumber(l.consumPoint[0])&&x.isNumber(l.consumPoint[1])&&(l.consumPoint=this.control.viewContainerManager.transformToOriginPoint(l.consumPoint,h)),this.control.renderControl.isFilterCursor(h)&&c.unshift({...l,timestamp:this.control.worker.now})}this.willConsumeEventWorkers.set(n,c),this.runAnimation()}}onFocusViewChange(){this.isEnableCursor&&(this.checkDrawWorks(),this.runAnimation())}updateRoomMembers(i){const{offline:e}=i;for(const t of this.cursorInfoMap.keys())t&&e.includes(t)&&this.cursorInfoMap.delete(t)}getKey(i,e){return`${i}${$e}${e}`}getUidAndviewId(i){const[e,t]=i.split($e);return{uid:e,viewId:t}}runAnimation(){this.animationId||(this.animationId=requestAnimationFrame(this.animationCursor.bind(this)))}checkDrawWorks(){var e;const i=this.control.viewContainerManager.focuedViewId;for(const[t,n]of this.animationDrawWorkers.entries()){const{viewId:r,uid:s}=this.getUidAndviewId(t);s!==((e=this.control.collector)==null?void 0:e.uid)&&r!==i&&n.workState===j.Done&&(n.consumPoint=[void 0,void 0])}}animationCursor(){this.animationId=void 0;const i=this.control.worker.now;for(const[t,n]of this.animationDrawWorkers.entries()){const{uid:r,viewId:s}=this.getUidAndviewId(t),a=this.roomMember.getRoomMember(r);if(!a){this.animationDrawWorkers.delete(t);continue}const{consumPoint:c,timestamp:l,workState:h}=n,u=this.cursorInfoMap.get(s)||new Map;c&&x.isNumber(c[0])&&x.isNumber(c[1])&&l+this.expirationTime>i?u.set(a.memberId,{x:c[0],y:c[1],roomMember:a,timestamp:l,type:1,workState:h}):u.delete(a.memberId),u.size?this.cursorInfoMap.set(s,u):this.cursorInfoMap.delete(s),this.animationDrawWorkers.delete(t)}const e=new Set;for(const[t,n]of this.cursorInfoMap.entries())if(n)for(const[r,s]of n.entries())s.type===1&&s.workState!==j.Done&&e.add(r);else this.cursorInfoMap.delete(t);for(const[t,n]of this.willConsumeEventWorkers.entries()){const r=this.roomMember.getRoomMember(t);if(x.isNumber(r==null?void 0:r.memberId)&&!e.has(r.memberId)){const s=n.pop();s?this.animationEventWorkers.set(t,s):this.willConsumeEventWorkers.delete(t)}}for(const[t,n]of this.animationEventWorkers.entries()){const r=this.roomMember.getRoomMember(t);if(!r){this.animationEventWorkers.delete(t);continue}const{viewId:s,consumPoint:a,timestamp:c}=n,l=this.cursorInfoMap.get(s)||new Map;a&&x.isNumber(a[0])&&x.isNumber(a[1])&&c+this.expirationTime>i?l.set(r.memberId,{x:a[0],y:a[1],roomMember:r,timestamp:c,type:0}):l.delete(r.memberId),l.size?this.cursorInfoMap.set(s,l):this.cursorInfoMap.delete(s),this.animationEventWorkers.delete(t)}for(const t of this.doneRenderCursorInfoMap.keys())this.cursorInfoMap.has(t)||(this.doneRenderCursorInfoMap.delete(t),this.internalMsgEmitter.emit([_.Cursor,t],[]));for(const[t,n]of this.cursorInfoMap.entries())if(n!=null&&n.size){const r=[];for(const[a,c]of n.entries()){const{timestamp:l,...h}=c;l+this.expirationTime>i?r.push(h):(n.delete(a),n.size===0&&(this.cursorInfoMap.delete(t),this.doneRenderCursorInfoMap.delete(t),this.internalMsgEmitter.emit([_.Cursor,t],[])))}const s=this.doneRenderCursorInfoMap.get(t);x.isEqual(s,r)||(this.doneRenderCursorInfoMap.set(t,r),this.internalMsgEmitter.emit([_.Cursor,t],r))}else this.cursorInfoMap.delete(t),this.doneRenderCursorInfoMap.delete(t),this.internalMsgEmitter.emit([_.Cursor,t],[]);(this.willConsumeEventWorkers.size||this.cursorInfoMap.size)&&this.runAnimation()}sendEvent(i,e){if(this.displayer&&F.isRoom(this.displayer)){const t=x.isNumber(i[0])&&x.isNumber(i[1])&&this.control.viewContainerManager.transformToScenePoint(i,e)||[void 0,void 0];this.willSendEventWorkers.push({consumPoint:t,viewId:e}),this.sendEventTimerId||(this.sendEventTimerId=setTimeout(()=>{this.dispatchMagixEvent()},this.maxLastSyncTime))}}dispatchMagixEvent(){var i;this.displayer&&F.isRoom(this.displayer)&&this.displayer.isWritable&&this.displayer.dispatchMagixEvent(this.eventName,{type:Ct.Cursor,op:x.cloneDeep(this.willSendEventWorkers),uid:(i=this.control.collector)==null?void 0:i.uid}),this.willSendEventWorkers.length=0,this.sendEventTimerId&&(clearTimeout(this.sendEventTimerId),this.sendEventTimerId=void 0)}collectServiceCursor(i){var s;if(!this.isEnableCursor&&!this.control.renderControl.isWritable)return;const{op:e,uid:t,workState:n,viewId:r}=i;if(t&&e&&n&&r){const a=this.roomMember.getRoomMember(t);if(!a||t===((s=this.control.collector)==null?void 0:s.uid))return;const c=this.getKey(t,r);let l=[void 0,void 0];if(x.isNumber(e[0])&&x.isNumber(e[1])){const[u,M]=this.control.viewContainerManager.transformToOriginPoint(e,r);l=[u,M]}if(n===j.Start){for(const u of this.cursorInfoMap.values())if(u!=null&&u.size)for(const M of u.keys())M===a.memberId&&u.delete(M)}const h={consumPoint:l,workState:n,viewId:r,timestamp:this.control.worker.now};if(n===j.Start||n===j.Done){const u=this.willConsumeEventWorkers.get(t);n===j.Start&&u&&this.willConsumeEventWorkers.delete(t),u&&n===j.Done&&(h.timestamp=h.timestamp-this.expirationTime)}this.animationDrawWorkers.set(c,h),this.runAnimation()}}unabled(){var i;this.displayer&&F.isRoom(this.displayer)&&(this.willSendEventWorkers.length=0,this.displayer.dispatchMagixEvent(this.eventName,{type:Ct.Cursor,op:[{viewId:this.control.viewContainerManager.focuedViewId,consumPoint:[void 0,void 0]}],uid:(i=this.control.collector)==null?void 0:i.uid}),this.sendEventTimerId&&(clearTimeout(this.sendEventTimerId),this.sendEventTimerId=void 0)),this.isEnableCursor||this.stopAnimation()}clearViewCursor(i){var e,t,n;for(const[r]of this.animationDrawWorkers.entries()){const{uid:s}=this.getUidAndviewId(r);s===((e=this.control.collector)==null?void 0:e.uid)&&i===i&&this.animationDrawWorkers.delete(r)}for(const[r]of this.willConsumeEventWorkers.entries())r===((t=this.control.collector)==null?void 0:t.uid)&&this.willConsumeEventWorkers.delete(r);for(const[r]of this.animationEventWorkers.entries())r===((n=this.control.collector)==null?void 0:n.uid)&&this.animationEventWorkers.delete(r);for(const[r]of this.cursorInfoMap.entries())r===r&&(this.cursorInfoMap.delete(r),this.doneRenderCursorInfoMap.delete(r),this.internalMsgEmitter.emit([_.Cursor,r],[]))}stopAnimation(){this.animationDrawWorkers.clear(),this.willConsumeEventWorkers.clear(),this.cursorInfoMap.clear()}destroy(){var i;(i=this.displayer)==null||i.removeMagixEventListener(this.eventName),this.stopAnimation()}}class Oe{constructor(){m(this,"useEmtMsg");m(this,"emtType");m(this,"control");m(this,"mainEngine");m(this,"collectListener",(i,e)=>{this.collect(i,e)})}static dispatch(i,e,t){var n;(n=Te.InternalMsgEmitter)==null||n.emit([i,e],t)}get serviceColloctor(){return this.control.collector}registerForMainEngine(i,e){return this.emtType=i,this.control=e,this.mainEngine=e.worker,this.mainEngine.internalMsgEmitter.on([this.emtType,this.emitEventType],this.collectListener),this}destroy(){this.emtType&&this.mainEngine&&this.mainEngine.internalMsgEmitter.off([this.emtType,this.emitEventType],this.collectListener)}collectForLocalWorker(i,e){var t,n,r;for(const[s,a]of i)(t=this.mainEngine)==null||t.queryTaskBatchData(a).forEach(c=>{var l;(l=this.mainEngine)==null||l.taskBatchData.delete(c)}),(n=this.mainEngine)==null||n.taskBatchData.add(s);if(e){this.mainEngine.consume();return}(r=this.mainEngine)==null||r.runAnimation()}collectForServiceWorker(i){Ue(()=>{i.forEach(e=>{var t;(t=this.serviceColloctor)==null||t.dispatch(e)})},this.mainEngine.maxLastSyncTime,this.control.hasPolyfillMethod("requestIdleCallback"))}pause(){var i;if(this.lastEmtData){this.useEmtMsg=!0;const e={...this.lastEmtData,workState:j.Done};this.collect(e,!0),(i=Te.InternalMsgEmitter)==null||i.emit(U.ActiveMethod,!1)}}recover(){var i;this.useEmtMsg&&Te.InternalMsgEmitter.hasListeners(U.ActiveMethod)&&((i=Te.InternalMsgEmitter)==null||i.emit(U.ActiveMethod,!0))}}class Uf extends Oe{constructor(){super(...arguments);m(this,"lastEmtData");m(this,"emitEventType",U.CopyNode)}collect(e){var c;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,viewId:n}=e,r=this.control.viewContainerManager.getView(n);if(!(r!=null&&r.displayer))return;const s=r.focusScenePath,a=this.mainEngine.now;this.mainEngine.internalMsgEmitter.emit("addUndoTicker",a,n);for(const l of t){const h=l.toString(),M=this.serviceColloctor.isLocalId(h)?this.serviceColloctor.transformKey(l):h,p=(c=this.serviceColloctor.getStorageData(n,s))==null?void 0:c[M];if(p){if(l===Z){const f=p&&this.copySelector({viewId:n,store:p});f&&this.pasteSelector({...f,viewId:n,scenePath:s,undoTickerId:a});break}if(p.toolsType===T.Text&&p.opt&&p.opt.workState&&p.opt.workState!==j.Done){const f=p&&this.copyText({viewId:n,store:p});f&&this.pasteText({...f,viewId:n,scenePath:s,key:M,store:p,undoTickerId:a});break}}}}copyText(e){const{viewId:t,store:n}=e,r=this.control.viewContainerManager.getView(t);if(!this.serviceColloctor||!r)return;const s=r==null?void 0:r.cameraOpt,a=s&&[s.centerX,s.centerY],c=n.opt,l=c.boxPoint&&c.boxSize&&[c.boxPoint[0]+c.boxSize[0]/2,c.boxPoint[1]+c.boxSize[1]/2];return{bgCenter:a,textCenter:l}}pasteText(e){var y,w;const{bgCenter:t,textCenter:n,store:r,key:s,viewId:a,scenePath:c,undoTickerId:l}=e,h=this.control.viewContainerManager.getView(a);if(!this.serviceColloctor||!h)return;const u=Math.floor(Math.random()*30+1),M=((y=h.cameraOpt)==null?void 0:y.scale)||1,p=t&&n&&[t[0]-n[0]+u,t[1]-n[1]+u]||[u/M,u/M],g=(this.serviceColloctor.isLocalId(s)?s:this.serviceColloctor.getLocalId(s.toString()))+"-"+l;if(r.toolsType===T.Text&&r.opt){const I=r.opt;if(I&&I.boxPoint&&I.text){I.workState=j.Done;const v=I.boxPoint;I.boxPoint=[Math.round(v[0]+p[0]),Math.round(v[1]+p[1])],I.workState=j.Done;const S=this.control.viewContainerManager.transformToOriginPoint(I.boxPoint,a);this.control.textEditorManager.createTextForMasterController({workId:g,x:S[0],y:S[1],opt:I,scale:((w=h.cameraOpt)==null?void 0:w.scale)||1,type:We.Text,isActive:!1,viewId:a,scenePath:c}),this.collectForServiceWorker([{...r,opt:I,type:W.FullWork,workId:g,viewId:a,scenePath:c}])}}}copySelector(e){var g,y,w,I,v,S,N,C,D;const{viewId:t,store:n}=e,r=this.control.viewContainerManager.getView(t),s=n.selectIds;if(!this.serviceColloctor||!(s!=null&&s.length)||!r)return;const a=new Map,c={offset:{x:0,y:0},cameraOpt:{centerX:((g=r.cameraOpt)==null?void 0:g.centerX)||0,centerY:((y=r.cameraOpt)==null?void 0:y.centerY)||0,scale:((w=r.cameraOpt)==null?void 0:w.scale)||1}},l=this.control.hasOffscreenCanvas&&((I=r.displayer.canvasBgRef.current)==null?void 0:I.getBoundingClientRect())||((v=r.displayer.canvasContainerRef.current)==null?void 0:v.getBoundingClientRect()),h=(N=(S=r.displayer)==null?void 0:S.floatBarRef.current)==null?void 0:N.getBoundingClientRect(),u=l&&[l.x+l.width/2,l.y+l.height/2],M=h&&[h.x+h.width/2,h.y+h.height/2],p=u&&r.viewData&&r.viewData.convertToPointInWorld({x:u[0],y:u[1]}),f=M&&r.viewData&&r.viewData.convertToPointInWorld({x:M[0],y:M[1]});p&&f&&(c.offset={x:p.x-f.x,y:p.y-f.y});for(const k of s){const P=(D=(C=this.serviceColloctor)==null?void 0:C.getStorageData(r.id,r.focusScenePath))==null?void 0:D[k];P&&a.set(k,P)}return{copyStores:a,copyCoordInfo:c}}pasteSelector(e){var y,w,I,v;const{copyStores:t,copyCoordInfo:n,viewId:r,scenePath:s,undoTickerId:a}=e,c=this.control.viewContainerManager.getView(r);if(!t.size||!this.serviceColloctor||!c)return;const{offset:l,cameraOpt:h}=n,{scale:u}=h,M=Math.floor(Math.random()*30+1),p=l&&[l.x+M,l.y+M]||[M/u,M/u],f=[],g=[];for(const[S,N]of t.entries()){const D=(this.serviceColloctor.isLocalId(S)?S:this.serviceColloctor.getLocalId(S.toString()))+"-"+a,k={useAnimation:!1};if(N.toolsType===T.Text&&N.opt){const P=N.opt;if(P&&P.boxPoint&&P.text){P.workState=j.Done;const L=P.boxPoint;P.boxPoint=[Math.round(L[0]+p[0]),Math.round(L[1]+p[1])],P.workState=j.Done;const O=this.control.viewContainerManager.transformToOriginPoint(P.boxPoint,r);this.control.textEditorManager.createTextForMasterController({workId:D,x:O[0],y:O[1],opt:P,scale:((y=c.cameraOpt)==null?void 0:y.scale)||1,type:We.Text,isActive:!1,viewId:r,scenePath:s})}g.push({...N,opt:P,type:W.FullWork,workId:D,viewId:r,scenePath:s});continue}if(N.toolsType===T.Image&&(N.opt.uuid=D,N.opt.centerX=N.opt.centerX+p[0],N.opt.centerY=N.opt.centerY+p[1]),N.ops){const P=Kt(N.ops).map((O,E)=>{const R=E%3;return R===0?O+p[0]:R===1?O+p[1]:O}),L=xt(P);N.ops=L}if((w=N==null?void 0:N.opt)!=null&&w.eraserlines&&(I=N==null?void 0:N.opt)!=null&&I.eraserlines.length)for(const P of(v=N==null?void 0:N.opt)==null?void 0:v.eraserlines){const{op:L}=P;for(let O=0;O<L.length;O++){const E=L[O].map((R,z)=>z%2?R+p[1]:R+p[0]);P.op[O]=E}}g.push({...N,updateNodeOpt:k,type:W.FullWork,workId:D,viewId:r,scenePath:s}),f.push([{...N,updateNodeOpt:k,workId:D,msgType:W.FullWork,dataType:K.Local,emitEventType:U.CopyNode,willSyncService:!1,willRefresh:!0,viewId:r},{workId:D,msgType:W.FullWork,emitEventType:U.CopyNode}])}f.length&&this.collectForLocalWorker(f),g.length&&this.collectForServiceWorker(g)}}class Wf extends Oe{constructor(){super(...arguments);m(this,"lastEmtData");m(this,"emitEventType",U.SetColorNode);m(this,"undoTickerId")}setTextColor(e,t,n,r){const{fontColor:s,fontBgColor:a}=n;t.opt&&(s&&(t.opt.fontColor=s),a&&(t.opt.fontBgColor=a),this.control.textEditorManager.updateTextForMasterController({workId:e,opt:t.opt,viewId:r,canSync:!0,canWorker:!0}))}collect(e){var I,v;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,strokeColor:n,fillColor:r,fontColor:s,fontBgColor:a,viewId:c,workState:l,thickness:h,strokeType:u}=e,M=this.control.viewContainerManager.getView(c);if(!(M!=null&&M.displayer))return;const p=M.focusScenePath,f=[...t],g=this.serviceColloctor.storage,y=[],w={};for((l===j.Start||!this.undoTickerId&&l===j.Done)&&(this.undoTickerId=this.mainEngine.now,this.mainEngine.internalMsgEmitter.emit("addUndoTicker",this.undoTickerId,c));f.length;){const S=f.pop();if(!S)continue;const N=S.toString(),C=this.serviceColloctor.isLocalId(N),D=C?this.serviceColloctor.transformKey(S):N;let k=N;!C&&this.serviceColloctor.isOwn(k)&&(k=this.serviceColloctor.getLocalId(k));const P=(v=(I=g==null?void 0:g[c])==null?void 0:I[p])==null?void 0:v[D];if(P){const L=P.updateNodeOpt||{};if(s||a){if(s){L.fontColor=s;const[E,R,z,V]=vt(s);w.textColor=[E,R,z],w.textOpacity=V}if(a)if(L.fontBgColor=Pt(a)?"transparent":a,Pt(a))w.textBgColor=void 0,w.textBgOpacity=void 0;else{const[E,R,z,V]=vt(a);w.textBgColor=[E,R,z],w.textBgOpacity=V}if(P.toolsType===T.Text&&P.opt&&l!==j.Start){this.setTextColor(k,bt(P),L,c),l===j.Done&&(this.undoTickerId=void 0);continue}}if(n){L.strokeColor=n;const[E,R,z,V]=vt(n);w.strokeColor=[E,R,z],w.strokeOpacity=V}if(r)if(L.fillColor=Pt(r)?"transparent":r,Pt(r))w.fillColor=void 0,w.fillOpacity=void 0;else{const[E,R,z,V]=vt(r);w.fillColor=[E,R,z],w.fillOpacity=V}h&&(L.thickness=h,w.strokeWidth=h),u&&(L.strokeType=u,w.strokeType=u);const O={workId:k,msgType:W.UpdateNode,dataType:K.Local,updateNodeOpt:L,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,textUpdateForWoker:!0,viewId:c};y.push([O,{workId:k,msgType:W.UpdateNode,emitEventType:this.emitEventType}])}}y.length&&(l===j.Done&&(this.undoTickerId=void 0),this.collectForLocalWorker(y)),Object.keys(w).length&&setTimeout(()=>{var S;(S=this.control.room)==null||S.setMemberState(w)},0)}}class Bf extends Oe{constructor(){super(...arguments);m(this,"lastEmtData");m(this,"emitEventType",U.ZIndexNode);m(this,"zIndexMap",new Map)}clearZIndex(e){this.zIndexMap.delete(e)}getMinZIndex(e){var t;return((t=this.zIndexMap.get(e))==null?void 0:t.min)||0}getMaxZIndex(e){var t;return((t=this.zIndexMap.get(e))==null?void 0:t.max)||0}setMaxZIndex(e,t){const n=this.getMinZIndex(t);this.zIndexMap.set(t,{min:n,max:e})}setMinZIndex(e,t){const n=this.getMaxZIndex(t);this.zIndexMap.set(t,{min:e,max:n})}addMaxLayer(e){const t=this.getMaxZIndex(e)+1;this.setMaxZIndex(t,e)}addMinLayer(e){const t=this.getMinZIndex(e)-1;this.setMinZIndex(t,e)}correct(e){const t=e.sort((n,r)=>n[1]-r[1]);for(let n=1;n<t.length;n++){const r=t[n][1],s=t[n-1][1];r<=s&&(t[n][1]=s+1)}return t}collect(e){if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,layer:n,viewId:r}=e,s=this.control.viewContainerManager.getView(r);if(!(s!=null&&s.displayer))return;const a=s.focusScenePath,c=[...t],l=this.serviceColloctor.storage,h=[],u=[];for(;c.length;){const p=c.pop();if(!p)continue;const f=p.toString(),g=this.serviceColloctor.isLocalId(f),y=g?this.serviceColloctor.transformKey(p):f;let w=f;!g&&this.serviceColloctor.isOwn(w)&&(w=this.serviceColloctor.getLocalId(w));const I=bt(l[r][a][y]);let v;if(I&&w===Z){if(I.selectIds){u.push(...I.selectIds),u.sort((D,k)=>{var O,E,R,z;const P=((E=(O=l[M(D,this.serviceColloctor)])==null?void 0:O.opt)==null?void 0:E.zIndex)||0,L=((z=(R=l[M(D,this.serviceColloctor)])==null?void 0:R.opt)==null?void 0:z.zIndex)||0;return P>L?1:D<k?-1:0});const S=I.updateNodeOpt||{};S.zIndexLayer=n;const N={workId:p,msgType:W.UpdateNode,dataType:K.Local,updateNodeOpt:S,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:r},C=new Map;n===Dt.Top?(this.addMaxLayer(r),v=this.getMaxZIndex(r)):(this.addMinLayer(r),v=this.getMinZIndex(r)),u.forEach(D=>{var O,E,R,z,V;const k=(O=this.serviceColloctor)==null?void 0:O.isLocalId(D);let P=k&&((E=this.serviceColloctor)==null?void 0:E.transformKey(D))||D;const L=(z=(R=l==null?void 0:l[r])==null?void 0:R[a])==null?void 0:z[P];L&&(!k&&((V=this.serviceColloctor)!=null&&V.isOwn(P))&&(P=this.serviceColloctor.getLocalId(P)),S.zIndex=v,L!=null&&L.opt&&(L.opt.zIndex=v),L!=null&&L.opt&&C.set(P,{updateNodeOpt:L.updateNodeOpt,opt:L.opt}))}),N.selectStore=C,N.willSerializeData=!0,h.push([N,{workId:p,msgType:W.UpdateNode,emitEventType:this.emitEventType}])}continue}}h.length&&this.collectForLocalWorker(h);function M(p,f){return f.isLocalId(p)&&f.transformKey(p)||p}}}class Ff extends Oe{constructor(){super(...arguments);m(this,"lastEmtData");m(this,"emitEventType",U.TranslateNode);m(this,"cachePosition")}collect(e,t){var f,g,y;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:n,position:r,workState:s,viewId:a}=e;this.lastEmtData=e;const c=this.control.viewContainerManager.getView(a);if(!(c!=null&&c.displayer))return;const l=c.focusScenePath,h=[...n],u=(f=this.serviceColloctor)==null?void 0:f.storage,M=[],p=s===j.Start&&this.mainEngine.now||void 0;for(p&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",p,a);h.length;){const w=h.pop();if(!w)continue;const I=w.toString(),v=this.serviceColloctor.isLocalId(I),S=v&&this.serviceColloctor.transformKey(w)||I;let N=I;!v&&this.serviceColloctor.isOwn(N)&&(N=this.serviceColloctor.getLocalId(N));const C=(y=(g=u==null?void 0:u[a])==null?void 0:g[l])==null?void 0:y[S];if(C&&N===Z){if(C.selectIds){const D=this.control.viewContainerManager.transformToScenePoint([r.x,r.y],a);if(s===j.Start&&(this.cachePosition=D),this.cachePosition){const k=C.updateNodeOpt||{};k.translate=[D[0]-this.cachePosition[0],D[1]-this.cachePosition[1]],k.workState=s,this.control.cursor.isEnableCursor?k.useAnimation=!1:(k.uid=this.serviceColloctor.uid,s===j.Start?k.useAnimation=!1:s===j.Done&&(k.useAnimation=!0));const P={workId:w,msgType:W.UpdateNode,dataType:K.Local,updateNodeOpt:k,emitEventType:this.emitEventType,willSyncService:!0,textUpdateForWoker:!0,viewId:a,smoothSync:this.mainEngine.smoothSync};s===j.Done&&(P.textUpdateForWoker=!0,P.willSerializeData=!0,this.cachePosition=void 0),M.push([P,{workId:w,msgType:W.UpdateNode,emitEventType:this.emitEventType,workState:s}])}}continue}}s===j.Start?this.mainEngine.unWritable():s===j.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),M.length&&this.collectForLocalWorker(M,t)}}class Vf extends Oe{constructor(){super(...arguments);m(this,"lastEmtData");m(this,"emitEventType",U.DeleteNode)}collect(e){var M,p;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,viewId:n}=e,r=this.control.viewContainerManager.getView(n);if(!(r!=null&&r.displayer))return;const s=r.focusScenePath,a=this.serviceColloctor.storage,c=[...t],l=[],h=[],u=this.mainEngine.now;for(;c.length;){const f=c.pop();if(!f)continue;const g=f.toString(),y=this.serviceColloctor.isLocalId(g),w=y?this.serviceColloctor.transformKey(f):g,I=(p=(M=a==null?void 0:a[n])==null?void 0:M[s])==null?void 0:p[w];if(I){let v=g;if(!y&&this.serviceColloctor.isOwn(v)&&(v=this.serviceColloctor.getLocalId(v)),I.toolsType===T.Text){this.control.textEditorManager.delete(v,!0,!0);continue}h.push(v)}}h.length&&(l.push([{msgType:W.RemoveNode,emitEventType:U.DeleteNode,removeIds:h,dataType:K.Local,willSyncService:!0,willRefresh:!0,viewId:n},void 0]),this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,n),this.collectForLocalWorker(l))}}class Qf extends Oe{constructor(){super(...arguments);m(this,"lastEmtData");m(this,"emitEventType",U.ScaleNode);m(this,"targetText",new Map);m(this,"cacheTextInfo",new Map)}async setTextStyle(e,t,n){const r=await this.control.textEditorManager.updateTextControllerWithEffectAsync({workId:e,opt:t,viewId:n,canSync:!1,canWorker:!1});return{key:e,textInfo:r}}async collect(e,t){var I,v,S,N,C,D,k;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:n,workState:r,viewId:s,originPoint:a,scenePoint:c,dir:l,scale:h,translate:u}=e;this.lastEmtData=e;const M=this.control.viewContainerManager.getView(s);if(!(M!=null&&M.displayer))return;const p=M.focusScenePath,f=[...n],g=(I=this.serviceColloctor)==null?void 0:I.storage,y=[],w=r===j.Start&&this.mainEngine.now||void 0;for(w&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",w,s);f.length;){const P=f.pop();if(!P)continue;const L=P.toString(),O=this.serviceColloctor.isLocalId(L),E=O&&this.serviceColloctor.transformKey(P)||L;let R=L;!O&&this.serviceColloctor.isOwn(R)&&(R=this.serviceColloctor.getLocalId(R));const z=(S=(v=g==null?void 0:g[s])==null?void 0:v[p])==null?void 0:S[E];if(z&&R===Z&&z.selectIds){const V=z.updateNodeOpt||{};if(V.dir=l,V.originPoint=a,V.scenePoint=c,V.workState=r,V.scale=h,V.translate=u,r===j.Start){this.cacheTextInfo.clear();for(const B of z.selectIds){const $=(N=this.serviceColloctor)==null?void 0:N.isLocalId(B),ie=$&&((C=this.serviceColloctor)==null?void 0:C.transformKey(B))||B;let re=ie;!$&&((D=this.serviceColloctor)!=null&&D.isOwn(ie))&&(re=this.serviceColloctor.getLocalId(ie));const ne=this.control.textEditorManager.get(re);ne&&r===j.Start&&this.targetText.set(re,bt(ne))}}if(this.targetText.size&&r!==j.Start&&h){const B=[];for(const[ie,re]of this.targetText.entries()){const{opt:ne}=re,J=Math.floor(ne.fontSize*h[0]),H=this.cacheTextInfo.get(ie),le=!H&&ne.fontSize!==J||H&&H.fontSize!==J||!1,Fe=(k=this.control.textEditorManager.get(ie))==null?void 0:k.opt;if(le&&Fe&&ne.boxSize&&ne.boxPoint){const Ve=this.setTextStyle(ie,{...Fe,fontSize:J},s);B.push(Ve)}}const $=await Promise.all(B);for(const ie of $)if(ie){const{key:re,textInfo:ne}=ie;this.cacheTextInfo.set(re,{fontSize:ne.opt.fontSize,boxSize:ne.opt.boxSize,boxPoint:ne.opt.boxPoint})}V.textInfos=this.cacheTextInfo}this.control.cursor.isEnableCursor?V.useAnimation=!1:(V.uid=this.serviceColloctor.uid,r===j.Start?V.useAnimation=!1:r===j.Done&&(V.useAnimation=!0));const te={workId:P,msgType:W.UpdateNode,dataType:K.Local,updateNodeOpt:V,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:s,smoothSync:this.mainEngine.smoothSync};r===j.Done&&(te.willSerializeData=!0,this.targetText.clear()),y.push([te,{workId:P,msgType:W.UpdateNode,emitEventType:this.emitEventType,workState:r}]);continue}}r===j.Start?this.mainEngine.unWritable():r===j.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),y.length&&this.collectForLocalWorker(y,t)}}class Zf extends Oe{constructor(){super(...arguments);m(this,"lastEmtData");m(this,"emitEventType",U.RotateNode);m(this,"cacheOriginRotate",0)}collect(e,t){var f,g,y,w,I,v,S;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:n,angle:r,workState:s,viewId:a}=e;this.lastEmtData=e;const c=this.control.viewContainerManager.getView(a);if(!(c!=null&&c.displayer))return;const l=c.focusScenePath,h=[...n],u=(f=this.serviceColloctor)==null?void 0:f.storage,M=[],p=s===j.Start&&this.mainEngine.now||void 0;for(p&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",p,a);h.length;){const N=h.pop();if(!N)continue;const C=N.toString(),D=this.serviceColloctor.isLocalId(C),k=D&&this.serviceColloctor.transformKey(N)||C;let P=C;!D&&this.serviceColloctor.isOwn(P)&&(P=this.serviceColloctor.getLocalId(P));const L=(y=(g=u==null?void 0:u[a])==null?void 0:g[l])==null?void 0:y[k];if(L&&P===Z){if(((w=L.selectIds)==null?void 0:w.length)===1){const O=L.selectIds[0];if(s===j.Start){const V=((I=this.serviceColloctor)==null?void 0:I.isLocalId(O))&&((v=this.serviceColloctor)==null?void 0:v.transformKey(O))||O,te=u[a][l][V];this.cacheOriginRotate=((S=te==null?void 0:te.opt)==null?void 0:S.rotate)||0}const E=L.updateNodeOpt||{};E.angle=(r+this.cacheOriginRotate)%360,E.workState=s,this.control.cursor.isEnableCursor?E.useAnimation=!1:(E.uid=this.serviceColloctor.uid,s===j.Start?E.useAnimation=!1:s===j.Done&&(E.useAnimation=!0));const R={workId:N,msgType:W.UpdateNode,dataType:K.Local,updateNodeOpt:E,emitEventType:this.emitEventType,willRefreshSelector:!1,willSyncService:!0,viewId:a,smoothSync:this.mainEngine.smoothSync};s===j.Done&&(R.willRefreshSelector=!0,R.willSerializeData=!0,this.cacheOriginRotate=0),M.push([R,{workId:N,msgType:W.UpdateNode,emitEventType:this.emitEventType,workState:s}])}continue}}s===j.Start?this.mainEngine.unWritable():s===j.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),M.length&&this.collectForLocalWorker(M,t)}}function Hf(o){switch(o){case T.Text:return We.Text;case T.SpeechBalloon:case T.Star:case T.Ellipse:case T.Rectangle:case T.Triangle:case T.Rhombus:case T.Polygon:return We.Shape}}class $f extends Oe{constructor(){super(...arguments);m(this,"lastEmtData");m(this,"emitEventType",U.SetFontStyle);m(this,"timerId")}async setTextStyle(e,t,n,r){const{bold:s,underline:a,lineThrough:c,italic:l,fontSize:h}=n;if(t.toolsType&&Hf(t.toolsType)===We.Text){t.opt&&(s&&(t.opt.bold=s),x.isBoolean(a)&&(t.opt.underline=a),x.isBoolean(c)&&(t.opt.lineThrough=c),l&&(t.opt.italic=l),h&&(t.opt.fontSize=h));const M=await this.control.textEditorManager.updateTextControllerWithEffectAsync({workId:e,opt:t.opt,viewId:r,canSync:!1,canWorker:!1});return{key:e,textInfo:M}}}async collect(e){var I,v,S,N,C,D;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,bold:n,italic:r,lineThrough:s,underline:a,viewId:c,fontSize:l}=e,h=this.control.viewContainerManager.getView(c);if(!(h!=null&&h.displayer))return;const u=h.focusScenePath,M=[...t],p=this.serviceColloctor.storage,f={},g=this.mainEngine.now;this.mainEngine.internalMsgEmitter.emit("addUndoTicker",g,c);const y=[];for(;M.length;){const k=M.pop();if(!k)continue;const P=k.toString(),L=this.serviceColloctor.isLocalId(P),O=L?this.serviceColloctor.transformKey(k):P;let E=P;!L&&this.serviceColloctor.isOwn(E)&&(E=this.serviceColloctor.getLocalId(E));const R=(v=(I=p==null?void 0:p[c])==null?void 0:I[u])==null?void 0:v[O];if(R){const z=R.updateNodeOpt||{};if(n&&(z.bold=n,f.bold=n==="bold"),r&&(z.italic=r,f.italic=r==="italic"),x.isBoolean(s)&&(z.lineThrough=s,f.lineThrough=s),x.isBoolean(a)&&(z.underline=a,f.underline=a),l&&(z.fontSize=l,f.textSize=l),R.toolsType===T.Text&&R.opt){const V=this.setTextStyle(E,x.cloneDeep(R),z,c);y.push(V);continue}if(R&&E===Z&&((S=R.selectIds)!=null&&S.length))for(const V of R.selectIds){const te=(N=this.serviceColloctor)==null?void 0:N.isLocalId(V);let B=te&&((C=this.serviceColloctor)==null?void 0:C.transformKey(V))||V;const $=p[c][u][B]||void 0;if(!te&&((D=this.serviceColloctor)!=null&&D.isOwn(B))&&(B=this.serviceColloctor.getLocalId(B)),$&&$.toolsType===T.Text&&R.opt){const ie=this.setTextStyle(B,x.cloneDeep($),z,c);y.push(ie);continue}}}}const w=await Promise.all(y);for(const k of w)if(k){const{key:P,textInfo:L}=k;L&&(L.canSync=!0,L.canWorker=!0,this.control.textEditorManager.updateForViewEdited(P,L))}Object.keys(f).length&&(this.timerId&&(clearTimeout(this.timerId),this.timerId=void 0),this.timerId=setTimeout(()=>{var k;this.timerId=void 0,(k=this.control.room)==null||k.setMemberState(f)},0))}}class Gf extends Oe{constructor(){super(...arguments);m(this,"lastEmtData");m(this,"emitEventType",U.SetPoint);m(this,"undoTickerId")}collect(e){var I,v,S;if(!this.serviceColloctor||!this.mainEngine)return;const{workId:t,pointMap:n,workState:r,viewId:s}=e,a=this.control.viewContainerManager.getView(s);if(!(a!=null&&a.displayer))return;const c=a.focusScenePath,l=(I=this.serviceColloctor)==null?void 0:I.storage,h=[],u=r===j.Start&&this.mainEngine.now||void 0;u&&(this.undoTickerId=u,this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,s));const M=t;if(!M)return;const p=M.toString(),f=this.serviceColloctor.isLocalId(p),g=f&&this.serviceColloctor.transformKey(M)||p;let y=p;!f&&this.serviceColloctor.isOwn(y)&&(y=this.serviceColloctor.getLocalId(y));const w=(S=(v=l==null?void 0:l[s])==null?void 0:v[c])==null?void 0:S[g];if(w&&y===Z&&w.selectIds){const N=w.updateNodeOpt||{};N.pointMap=n,N.workState=r;const C={workId:M,msgType:W.UpdateNode,dataType:K.Local,updateNodeOpt:N,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:s};r===j.Done&&(C.undoTickerId=this.undoTickerId),h.push([C,{workId:M,msgType:W.UpdateNode,emitEventType:this.emitEventType}])}r===j.Start?this.mainEngine.unWritable():r===j.Done&&this.mainEngine.abled(),h.length&&this.collectForLocalWorker(h)}}class Jf extends Oe{constructor(){super(...arguments);m(this,"lastEmtData");m(this,"emitEventType",U.SetLock)}collect(e){var M,p;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,isLocked:n,viewId:r}=e,s=this.control.viewContainerManager.getView(r);if(!(s!=null&&s.displayer))return;const a=s.focusScenePath,c=[...t],l=this.serviceColloctor.storage,h=[],u=this.mainEngine.now;for(;c.length;){const f=c.pop();if(!f)continue;const g=f.toString(),y=this.serviceColloctor.isLocalId(g),w=y?this.serviceColloctor.transformKey(f):g;let I=g;!y&&this.serviceColloctor.isOwn(I)&&(I=this.serviceColloctor.getLocalId(I));const v=(p=(M=l==null?void 0:l[r])==null?void 0:M[a])==null?void 0:p[w];if(v){const S=v.updateNodeOpt||{};S.isLocked=n;const N={workId:I,msgType:W.UpdateNode,dataType:K.Local,updateNodeOpt:S,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,viewId:r};h.push([N,{workId:I,msgType:W.UpdateNode,emitEventType:this.emitEventType}])}}this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,r),h.length&&this.collectForLocalWorker(h)}}class Xf extends Oe{constructor(){super(...arguments);m(this,"lastEmtData");m(this,"emitEventType",U.SetShapeOpt)}collect(e){var M,p;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,viewId:n,...r}=e,s=this.control.viewContainerManager.getView(n);if(!(s!=null&&s.displayer))return;const a=s.focusScenePath,c=[...t],l=this.serviceColloctor.storage,h=[],u=this.mainEngine.now;for(;c.length;){const f=c.pop();if(!f)continue;const g=f.toString(),y=this.serviceColloctor.isLocalId(g),w=y?this.serviceColloctor.transformKey(f):g;let I=g;!y&&this.serviceColloctor.isOwn(I)&&(I=this.serviceColloctor.getLocalId(I));const v=(p=(M=l==null?void 0:l[n])==null?void 0:M[a])==null?void 0:p[w];if(v){const S={...v.updateNodeOpt,...r,willRefresh:!0};if(v&&I===Z){const N={workId:I,msgType:W.UpdateNode,dataType:K.Local,updateNodeOpt:S,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,viewId:n};h.push([N,{workId:I,msgType:W.UpdateNode,emitEventType:this.emitEventType}])}}}h.length&&(this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,n),this.collectForLocalWorker(h))}}class oe{constructor(i){m(this,"builders",new Map);this.builders=new Map(i.map(e=>[e,this.build(e)]))}build(i){switch(i){case U.TranslateNode:return new Ff;case U.ZIndexNode:return new Bf;case U.CopyNode:return new Uf;case U.SetColorNode:return new Wf;case U.DeleteNode:return new Vf;case U.ScaleNode:return new Qf;case U.RotateNode:return new Zf;case U.SetFontStyle:return new $f;case U.SetPoint:return new Gf;case U.SetLock:return new Jf;case U.SetShapeOpt:return new Xf}}getBuilder(i){return this.builders.get(i)}registerForMainEngine(i,e){return this.builders.forEach(t=>{t&&t.registerForMainEngine(i,e)}),this}destroy(){this.builders.forEach(i=>{i&&i.destroy()}),this.builders.clear()}pause(){return this.builders.forEach(i=>{i&&i.pause()}),this}recover(){return this.builders.forEach(i=>{i&&i.recover()}),this}static emitMethod(i,e,t){Oe.dispatch(i,e,t)}static activeListener(i){Te.InternalMsgEmitter.on(U.ActiveMethod,i)}static unmountActiveListener(i){Te.InternalMsgEmitter.off(U.ActiveMethod,i)}}const qf=async(o,i)=>{const{src:e,isgl:t,isCache:n}=o;if(typeof Image=="function"){const r=new Image;return typeof e=="string"&&(r.crossOrigin="anonymous"),new Promise(s=>{r.onload=function(){createImageBitmap(r,{imageOrientation:t?"flipY":"none"}).then(a=>{s(a)})},r.onerror=function(){s(void 0)},r.src=e})}else return fetch(e,{method:"GET",mode:"cors",cache:"default"}).then(r=>r.blob()).then(r=>createImageBitmap(r,{imageOrientation:t?"flipY":"none"}).then(s=>s))},ot=class ot{constructor(){m(this,"fontDB");m(this,"FONT_DB_NAME","__APPLIANCE_PLUGIN_FONT_DB");m(this,"FONT_STORE_NAME","fonts");m(this,"FONT_DB_VERSION",1)}static getInstance(){return ot.instance||(ot.instance=new ot),ot.instance}async initFontDB(){return this.fontDB?this.fontDB:new Promise((i,e)=>{const t=indexedDB.open(this.FONT_DB_NAME,this.FONT_DB_VERSION);t.onerror=()=>{e(new Error(`Failed to open font database: ${t.error}`))},t.onsuccess=()=>{this.fontDB=t.result,i(t.result)},t.onupgradeneeded=n=>{const r=n.target.result;r.objectStoreNames.contains(this.FONT_STORE_NAME)||r.createObjectStore(this.FONT_STORE_NAME,{keyPath:"fontFamily"}).createIndex("url","url",{unique:!1})}})}async getFontFromDB(i){try{return this.fontDB||(this.fontDB=await this.initFontDB()),new Promise((e,t)=>{const s=this.fontDB.transaction([this.FONT_STORE_NAME],"readonly").objectStore(this.FONT_STORE_NAME).get(i);s.onsuccess=()=>{s.result&&s.result.buffer?e(s.result.buffer):e(null)},s.onerror=()=>{t(s.error)}})}catch(e){return console.error(`Failed to get font from database for ${i}:`,e),null}}async saveFontToDB(i,e,t){try{return this.fontDB||(this.fontDB=await this.initFontDB()),new Promise((n,r)=>{const a=this.fontDB.transaction([this.FONT_STORE_NAME],"readwrite").objectStore(this.FONT_STORE_NAME),c={fontFamily:i,url:e,buffer:t,timestamp:Date.now()},l=a.put(c);l.onsuccess=()=>{n(!0)},l.onerror=()=>{r(l.error)}})}catch(n){return console.error(`Failed to save font to database for ${i}:`,n),!1}}async clearFontCache(){try{return this.fontDB||(this.fontDB=await this.initFontDB()),new Promise((i,e)=>{const r=this.fontDB.transaction([this.FONT_STORE_NAME],"readwrite").objectStore(this.FONT_STORE_NAME).clear();r.onsuccess=()=>{console.log("Font cache cleared successfully"),i(!0)},r.onerror=()=>{e(r.error)}})}catch(i){return console.error("Failed to clear font cache:",i),!1}}async getFontCacheStatus(){try{return this.fontDB||(this.fontDB=await this.initFontDB()),new Promise((i,e)=>{const r=this.fontDB.transaction([this.FONT_STORE_NAME],"readonly").objectStore(this.FONT_STORE_NAME).getAll();r.onsuccess=()=>{const s=r.result||[],a=s.reduce((c,l)=>c+(l.buffer?l.buffer.byteLength:0),0);i({count:s.length,totalSize:a})},r.onerror=()=>{e(r.error)}})}catch(i){return console.error("Failed to get font cache status:",i),{count:0,totalSize:0}}}};m(ot,"instance");let pi=ot;class Kf{get now(){var i;return((i=this.control.room)==null?void 0:i.calibrationTimestamp)||Date.now()}get newWorkId(){return this.now.toString()}setCurrentToolsData(i){this.currentToolsData=i}getCurrentToolsData(){return this.currentToolsData}setCurrentLocalWorkData(i){this.currentLocalWorkData=i}getWorkId(){return this.currentLocalWorkData.workId}get workState(){return this.currentLocalWorkData.workState}}class _f extends Kf{constructor(e){super();m(this,"maxLastSyncTime",we.syncOpt.interval);m(this,"combineUnitTime",we.bezier.combineUnitTime);m(this,"maxCombineEraserTime",we.pencilEraser.maxCombineTime);m(this,"smoothSync",we.syncOpt.smoothSync);m(this,"isActive",!1);m(this,"currentToolsData");m(this,"currentLocalWorkData");m(this,"control");m(this,"internalMsgEmitter");m(this,"publicMsgEmitter");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,"fullWorkerDrawCount",0);m(this,"maxDrawCount",0);m(this,"_consumeCount",0);m(this,"_postCount",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,"getVNodeInfoResolveMap",new Map);m(this,"setFontFacesResolve",{});m(this,"isLocalWorkActive",!1);m(this,"indexDBUtils",pi.getInstance());const{control:t,internalMsgEmitter:n,publicMsgEmitter:r}=e;this.control=t,this.maxLastSyncTime=this.control.pluginOptions.extras.syncOpt.interval,this.combineUnitTime=this.control.pluginOptions.extras.bezier.combineUnitTime||this.combineUnitTime,this.smoothSync=x.isBoolean(this.control.pluginOptions.extras.syncOpt.smoothSync)?this.control.pluginOptions.extras.syncOpt.smoothSync:this.smoothSync,this.maxCombineEraserTime=this.control.pluginOptions.extras.pencilEraser.maxCombineTime||this.maxCombineEraserTime,this.fullWorkerUrl=this.control.pluginOptions.cdn.fullWorkerUrl||"",this.subWorkerUrl=this.control.pluginOptions.cdn.subWorkerUrl||"",this.internalMsgEmitter=n,this.publicMsgEmitter=r,this.currentLocalWorkData={workState:j.Pending}}get isBezier(){return this.control.pluginOptions.extras.bezier.enable}destroy(){var e,t,n;(e=this.methodBuilder)==null||e.destroy(),this.unWritable(),this.taskBatchData.clear(),this.tasksqueue.clear(),this.tmpImageConfigMap.clear(),this.localPointsBatchData.clear(),this.isActive=!1,this.clearAllResolveMap.clear(),this.snapshotMap.clear(),this.boundingRectMap.clear(),(t=this.fullWorker)==null||t.terminate(),(n=this.subWorker)==null||n.terminate()}get consumeCount(){return this._consumeCount}set consumeCount(e){this._consumeCount=e}get postCount(){return this._postCount}set postCount(e){this._postCount=e}get viewContainerManager(){return this.control.viewContainerManager}get collector(){return this.control.collector}get isRunSubWork(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===T.Pencil||e===T.PencilEraser||e===T.BitMapEraser||e===T.LaserPen||e===T.Arrow||e===T.Straight||e===T.Ellipse||e===T.Rectangle||e===T.Star||e===T.Polygon||e===T.SpeechBalloon||e===T.Selector}get isCanDrawWork(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===T.Pencil||e===T.LaserPen||e===T.Arrow||e===T.Straight||e===T.Ellipse||e===T.Rectangle||e===T.Star||e===T.Polygon||e===T.SpeechBalloon||e===T.Triangle||e===T.Rhombus||e===T.BitMapEraser||e===T.PencilEraser}get isUseZIndex(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===T.Pencil||e===T.Arrow||e===T.Straight||e===T.Ellipse||e===T.Rectangle||e===T.Star||e===T.Polygon||e===T.SpeechBalloon||e===T.Text||e===T.Image}get isCanRecordUndoRedo(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===T.Pencil||e===T.Eraser||e===T.PencilEraser||e===T.BitMapEraser||e===T.Arrow||e===T.Straight||e===T.Ellipse||e===T.Rectangle||e===T.Star||e===T.Polygon||e===T.SpeechBalloon||e===T.Text||e===T.Image}get isCanSentCursor(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===T.Pencil||e===T.Text||e===T.LaserPen||e===T.Arrow||e===T.Straight||e===T.Ellipse||e===T.Rectangle||e===T.Star||e===T.Polygon||e===T.SpeechBalloon||e===T.Triangle||e===T.Rhombus||e===T.Eraser||e===T.PencilEraser||e===T.BitMapEraser||e===T.Selector}get isPostCountType(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===T.Pencil||e===T.Arrow||e===T.Straight||e===T.Ellipse||e===T.Rectangle||e===T.Star||e===T.Polygon||e===T.SpeechBalloon||e===T.Triangle||e===T.Rhombus||e===T.Eraser||e===T.PencilEraser||e===T.BitMapEraser||e===T.Selector}get isCanPostDraw(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===T.Pencil||e===T.PencilEraser||e===T.BitMapEraser}get isCanStartEventConsum(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===T.Selector||e===T.Eraser||e===T.PencilEraser||e===T.BitMapEraser}async init(){this.destroy(),await this.on(),this.internalMsgEmitterListener(),this.isActive=!0}async useMainThread(){console.info("no OffscreenCanvas"),this.control.hasExtendFontFaces&&await document.fonts.ready.then(()=>{this.control.room&&this.control.room.logger.info("set font faces in main thread success")});const{MainThreadManagerImpl:e}=await Promise.resolve().then(()=>require("./index-CWK75u1P.js"));this.mainThread=new e(this)}async on(){if(!this.control.hasOffscreenCanvas){await this.useMainThread();return}if(!this.fullWorkerUrl||!this.subWorkerUrl){console.error("no worker url config");return}if(this.fullWorker=new Worker(this.fullWorkerUrl,{type:"classic"}),this.control.isUseSimple||(this.subWorker=new Worker(this.subWorkerUrl,{type:"classic"})),this.fullWorker.onmessage=e=>{if(e.data){const{render:t,sp:n,fullWorkerDrawCount:r,workerTasksqueueCount:s,viewId:a,consumeCount:c}=e.data;if(c&&(this.consumeCount=c),this.isBusy&&s&&this.setWorkerTasksqueueCount(s),n!=null&&n.length&&this.collectorSyncData(n),this.control.isUseSimple){if(this.control.isUseOffscreenTransfer)return;t&&(t!=null&&t.length)&&this.viewContainerManager.render(t);return}const l=(t==null?void 0:t.length)&&t||[];if(r&&a){if(this.fullWorkerDrawCount=r,this.fullWorkerDrawCount<1/0){const h=Math.max(this.maxDrawCount,this.fullWorkerDrawCount);this.setMaxDrawCount(h),this.clearReRenders(this.fullWorkerDrawCount)}else this.setMaxDrawCount(0),this.clearReRenders(1/0);if(this.reRenders.size)for(const h of this.reRenders.values())l.push(...h)}l.length&&this.viewContainerManager.render(l)}},this.subWorker&&(this.subWorker.onmessage=e=>{if(e.data){const{render:t,sp:n,subWorkerDrawCount:r,consumeCount:s}=e.data;s&&(this.consumeCount=s),n!=null&&n.length&&this.collectorSyncData(n);const a=(t==null?void 0:t.length)&&t||[];if(x.isNumber(r)){if(this.subWorkerDrawCount=r,this.fullWorkerDrawCount<1/0){const c=Math.max(this.maxDrawCount,this.subWorkerDrawCount);this.setMaxDrawCount(c)}if(t!=null&&t.length)if(this.subWorkerDrawCount>this.fullWorkerDrawCount){const c=[];for(const l of t)l.imageBitmap&&(l.isUnClose=!0,c.push(l));this.reRenders.set(this.subWorkerDrawCount,c)}else this.reRenders.size&&this.clearReRenders(this.subWorkerDrawCount)}a.length&&this.viewContainerManager.render(a)}}),this.control.hasExtendFontFaces){const e=this.control.extendFontFaces,t=[],n=[];this.control.room&&this.control.room.logger.info(`load before font faces ${JSON.stringify(e)}`),await new Promise(async r=>{this.setFontFacesResolve.resolve=r,this.setFontFacesResolve.timer=setTimeout(()=>{this.setFontFacesResolve.resolve&&(this.control.room?this.control.room.logger.error("set font faces timeout"):console.warn("set font faces timeout"),this.setFontFacesResolve.resolve(!1))},this.control.loadFontFacesTimeout);try{for(const s of e){let a;a=await this.indexDBUtils.getFontFromDB(s.fontFamily)||void 0,a||(a=await this.loadFontInMainThread(s.src),a&&a.byteLength>0&&(await this.indexDBUtils.saveFontToDB(s.fontFamily,s.src,a)||(this.control.room?this.control.room.logger.warn(`Failed to save font ${s.fontFamily} to IndexedDB, but continuing with font loading`):console.warn(`Failed to save font ${s.fontFamily} to IndexedDB, but continuing with font loading`)))),a&&a.byteLength>0?(n.push({fontFamily:s.fontFamily,buffer:a}),t.push(a)):this.control.room?this.control.room.logger.warn(`Font ${s.fontFamily} could not be loaded from any source`):console.warn(`Font ${s.fontFamily} could not be loaded from any source`)}this.control.room&&this.control.room.logger.info("load end font faces"),n.length?this.fullWorker.postMessage(new Set([{type:W.SetFontFace,fontBuffers:n}]),t):this.setFontFacesResolve.resolve(!0)}catch(s){this.setFontFacesResolve.timer&&(clearTimeout(this.setFontFacesResolve.timer),this.setFontFacesResolve.timer=void 0),this.setFontFacesResolve.resolve&&(this.setFontFacesResolve.resolve(!1),this.control.room?this.control.room.logger.error(`set font faces error: ${s}`):console.error(`set font faces error: ${s}`))}}).then(r=>{this.setFontFacesResolve.resolve=void 0,this.setFontFacesResolve.timer=void 0,this.control.room?r?this.control.room.logger.info("set font faces in web worker success"):this.control.room.logger.error("set font faces in web worker error"):r||console.error("set font faces in web worker error")})}}async clearFontCache(){return await this.indexDBUtils.clearFontCache()}async getFontCacheStatus(){return await this.indexDBUtils.getFontCacheStatus()}async loadFontInMainThread(e){try{const t=await fetch(e);if(!t.ok)throw new Error(`HTTP ${t.status}: ${t.statusText}`);const n=await t.arrayBuffer();if(!n||n.byteLength===0)throw new Error("Empty font data received");const r=new Uint8Array(n);if(!this.validateFontData(r))throw new Error("Invalid font data format: not a valid font file");return n}catch(t){this.control.room?this.control.room.logger.error(`Failed to load font from ${e}: ${t}`):console.error(`Failed to load font from ${e}: ${t}`);return}}validateFontData(e){return e.length<4?!1:e[0]===119&&e[1]===79&&e[2]===70&&e[3]===50||e[0]===119&&e[1]===79&&e[2]===70&&e[3]===70||e[0]===0&&e[1]===1&&e[2]===0&&e[3]===0||e[0]===79&&e[1]===84&&e[2]===84&&e[3]===79||e.length>36&&e[36]===0&&e[37]===1&&e[38]===0&&e[39]===0}clearReRenders(e=1/0){for(const t of this.reRenders.keys())if(x.isNumber(Number(t))&&Number(t)<=e){const n=this.reRenders.get(Number(t));n==null||n.forEach(r=>{var s;(s=r.imageBitmap)==null||s.close()}),this.reRenders.delete(t)}}get isBusy(){return this.getTasksqueueState()===j.Doing}getLockSentEventCursor(){return this.isLockSentEventCursor}setLockSentEventCursor(e){this.isLockSentEventCursor=e}getTasksqueueState(){return this.useTasksqueue&&j.Doing||j.Done}setMaxDrawCount(e){this.maxDrawCount=e}getFullWorkDrawCount(){return this.fullWorkerDrawCount}getMaxDrawCount(){return this.maxDrawCount}setSubWorkerDrawCount(e){this.subWorkerDrawCount=e}setConsumeCount(e){this.consumeCount=e}getConsumeCount(){return this.consumeCount}setWorkerTasksqueueCount(e){const t=Math.max(this.workerTasksqueueCount||0,e);this.workerTasksqueueCount=t}collectorSyncData(e){var n,r,s,a;let t=!1;for(const c of e){const{type:l,selectIds:h,opt:u,selectRect:M,strokeColor:p,fillColor:f,willSyncService:g,isSync:y,imageBitmap:w,canvasHeight:I,canvasWidth:v,rect:S,op:N,canTextEdit:C,points:D,selectorColor:k,canRotate:P,scaleType:L,textOpt:O,toolsType:E,workId:R,viewId:z,dataType:V,canLock:te,isLocked:B,shapeOpt:$,toolsTypes:ie,thickness:re,strokeType:ne,useStroke:J,isgl:H,imageSrc:le,isSubWorker:Fe,updateNodeOpt:Ve,setFontFaceResult:et,failedFonts:Ge}=c;if(l===W.SetFontFace){et&&this.setFontFacesResolve.resolve&&(Ge&&Ge.length>0&&(this.control.room?this.control.room.logger.info("set font face has failed fonts: "+Ge.join(", ")):console.info("set font face has failed fonts: "+Ge.join(", "))),this.setFontFacesResolve.resolve(et));return}if(!z)return;const Qe=c.scenePath||this.viewContainerManager.getCurScenePath(z);switch(l){case W.Select:{const X=h!=null&&h.length?{...M,selectIds:h,canvasHeight:I,canvasWidth:v,points:D}:void 0;X&&(u!=null&&u.strokeColor)&&(X.selectorColor=u.strokeColor),X&&k&&(X.selectorColor=k),X&&p&&(X.strokeColor=p),X&&(u!=null&&u.fillColor)&&(X.fillColor=u.fillColor),X&&f&&(X.fillColor=f),X&&x.isBoolean(P)&&(X.canRotate=P),X&&L&&(X.scaleType=L),X&&C&&(X.canTextEdit=C),X&&O&&(X.textOpt=O),X&&x.isBoolean(te)&&(X.canLock=te),X&&x.isBoolean(B)&&(X.isLocked=B),X&&$&&(X.shapeOpt=$),X&&ie&&(X.toolsTypes=ie),X&&re&&(X.thickness=re),X&&ne&&(X.strokeType=ne),X&&x.isBoolean(J)&&(X.useStroke=J),z&&this.viewContainerManager.showFloatBar(z,!!X,X),g&&((n=this.collector)==null||n.dispatch({type:l,selectIds:h,opt:u,isSync:y,viewId:z,scenePath:Qe}));break}case W.Snapshot:if(w&&Qe){const X=this.snapshotMap.get(Qe);X&&X(w)}break;case W.BoundingBox:if(S&&Qe){const X=this.boundingRectMap.get(Qe);X&&X(S)}break;case W.Cursor:N&&this.control.cursor.collectServiceCursor({...c});break;case W.Clear:if(z){this.viewContainerManager.showFloatBar(z,!1);const X=(r=this.clearAllResolveMap.get(z))==null?void 0:r.resolve;X&&X(z)}break;case W.TextUpdate:if(E===T.Text&&R&&z){const X=this.viewContainerManager.transformToOriginPoint((u==null?void 0:u.boxPoint)||[0,0],z),ge=(u==null?void 0:u.boxSize)||[0,0],Q=(s=this.viewContainerManager.getView(z))==null?void 0:s.cameraOpt;u?this.control.textEditorManager.updateTextForWorker({x:X[0],y:X[1],w:ge[0],h:ge[1],scale:(Q==null?void 0:Q.scale)||1,workId:R,opt:u,dataType:V,viewId:z,canSync:g||!1,canWorker:!1,updateNodeOpt:Ve}):this.control.textEditorManager.delete(R,g||!1,!1)}break;case W.GetTextActive:E===T.Text&&R&&z&&this.control.textEditorManager.updateTextForWorker({workId:R,isActive:!0,viewId:z,dataType:K.Local,canWorker:!1,canSync:!0},this.now);break;case W.GetImageBitMap:le&&z&&R&&qf({src:le,isgl:H}).then(X=>{var Q;const ge=new Set;if(ge.add({msgType:W.GetImageBitMap,dataType:K.Local,workId:R,viewId:z,imageSrc:le,isSubWorker:Fe,imageBitmap:X}),!this.control.hasOffscreenCanvas)(Q=this.mainThread)==null||Q.consume(ge);else{const G=Fe&&this.subWorker?this.subWorker:this.fullWorker;X?G.postMessage(ge,[X]):G.postMessage(ge)}});break;case W.GetVNodeInfo:if(R){const X=R.toString(),ge=(a=this.getVNodeInfoResolveMap.get(X))==null?void 0:a.resolve,Q={...c,uuid:X};ge&&ge(Q)}break;default:t=!0;break}}t&&this.collectorAsyncData(e)}collectorAsyncData(e){var t,n,r,s;for(const a of e){const{type:c,op:l,workId:h,index:u,removeIds:M,ops:p,opt:f,updateNodeOpt:g,toolsType:y,isSync:w,viewId:I,isLockSentEventCursor:v,nextTasks:S}=a;if(!I){console.error("[MasterControlForWorker] collectorAsyncData on viewId in",a);return}const N=a.scenePath||this.viewContainerManager.getCurScenePath(I);switch(c){case W.None:{v&&Ue(()=>{this.setLockSentEventCursor(!1)},this.maxLastSyncTime);break}case W.DrawWork:{(t=this.collector)==null||t.dispatch({type:c,op:l,opt:f,toolsType:y,workId:h,index:u,isSync:w,viewId:I,scenePath:N,updateNodeOpt:g});break}case W.FullWork:{(n=this.collector)==null||n.dispatch({type:c,ops:p,workId:h,updateNodeOpt:g,opt:f,toolsType:y,isSync:w,viewId:I,scenePath:N}),this.willSelectorWorkId&&h&&h.toString()===this.willSelectorWorkId&&this.control.runEffectWork(()=>{this.setShapeSelectorByWorkId(this.willSelectorWorkId,I),this.willSelectorWorkId=void 0});break}case W.UpdateNode:{(r=this.collector)==null||r.dispatch({type:c,updateNodeOpt:g,workId:h,opt:f,ops:p,op:l,isSync:w,viewId:I,scenePath:N});break}case W.RemoveNode:{M&&this.control.textEditorManager.deleteBatch(M,!1,!1),(s=this.collector)==null||s.dispatch({type:c,removeIds:M,isSync:w,viewId:I,scenePath:N}),this.willSelectorWorkId&&(M!=null&&M.includes(this.willSelectorWorkId))&&(this.willSelectorWorkId=void 0);break}}S&&this.collectorAsyncData(S)}}async onLocalEventEnd(e,t){var l;const n=this.viewContainerManager.getView(t);if(!n)return;const{focusScenePath:r,cameraOpt:s}=n,a=this.viewContainerManager.transformToScenePoint(e,t),c=[];for(const h of this.localPointsBatchData.keys())if(((l=this.currentToolsData)==null?void 0:l.toolsType)===T.Text){const u=this.getLocalPointInfo(h),M=u==null?void 0:u.state;if(M&&M===j.Start){const p=this.currentLocalWorkData.toolsOpt;p.workState=j.Doing,p.boxPoint=[Math.round(a[0]),Math.round(a[1])],p.boxSize=[p.fontSize,p.fontSize],this.control.textEditorManager.checkEmptyTextBlur(),this.control.textEditorManager.createTextForMasterController({workId:this.newWorkId,x:e[0],y:e[1],scale:(s==null?void 0:s.scale)||1,opt:p,type:We.Text,isActive:!0,viewId:t,scenePath:r},this.now)}this.deleteLocalPoint(h);continue}else this.pushLocalPoint(h,a,j.Done,t),c.push(h);if(c.length){try{if(await new Promise(u=>{setTimeout(async()=>{c.forEach(M=>{this.setLocalPointIsFullWork(M)}),this.delayWorkStateToDoneResolve=u,this.consume()},0)})&&c[0]){const u=c[0];c.forEach(M=>{this.deleteLocalPoint(M)}),this.willSelectorWorkId=u.toString()}}catch(h){console.error("[MasterControlForWorker] onLocalEventEnd error:",h)}this.delayWorkStateToDoneResolve=void 0,c.length=0}}onLocalEventDoing(e,t){var r;if(((r=this.currentToolsData)==null?void 0:r.toolsType)===T.Text)return;this.currentLocalWorkData.workState===j.Start&&this.setCurrentLocalWorkData({...this.currentLocalWorkData,workState:j.Doing});let n=!1;for(const[s,{state:a}]of this.localPointsBatchData.entries())if(this.isAbled()&&a!==j.Pending){const c=this.viewContainerManager.transformToScenePoint(e,t);this.pushLocalPoint(s,c,a===j.Start?j.Doing:a,t),n=!0}if(n){this.runAnimation();return}}onLocalEventStart(e,t){var c,l;this.viewContainerManager.focuedViewId!==t&&this.viewContainerManager.setFocuedViewId(t),this.isCanDrawWork&&this.control.room&&!this.control.room.disableDeviceInputs&&(this.control.room.disableDeviceInputs=!0);const n=(c=this.currentToolsData)==null?void 0:c.toolsType,r=n===T.Selector?Z:this.newWorkId,s=this.setZIndex(t);this.setCurrentLocalWorkData({workState:j.Start,toolsOpt:s,viewId:t});const a=this.viewContainerManager.transformToScenePoint(e,t);if(this.pushLocalPoint(r,a,j.Start,t,s),n!==T.Text){if(this.control.textEditorManager.checkEmptyTextBlur(),this.isCanRecordUndoRedo&&this.internalMsgEmitter.emit("addUndoTicker",r,t),r&&s&&n&&this.isCanStartEventConsum&&this.prepareOnceWork({workId:r,toolsOpt:s,viewId:t},n),this.consumeCount=0,this.postCount=0,this.maxDrawCount=0,this.fullWorkerDrawCount=0,this.subWorkerDrawCount=0,this.clearReRenders(1/0),this.isCanDrawWork){const h=this.viewContainerManager.getCurScenePath(t);h&&((l=this.collector)!=null&&l.hasSelector(t,h))&&this.blurSelector(t,h)}this.consume()}}setLocalPointIsFullWork(e){const t=this.getLocalPointInfo(e);t&&(t.isFullWork=!0,this.localPointsBatchData.set(e,t))}pushLocalPoint(e,t,n,r,s){let a=this.getLocalPointInfo(e);n===j.Start?a={state:j.Start,points:t,opt:s||this.currentLocalWorkData.toolsOpt,isFullWork:!1,viewId:r}:a&&(a.state=n,a.points.push(t[0],t[1])),a&&this.localPointsBatchData.set(e,a)}deleteLocalPoint(e){this.localPointsBatchData.delete(e)}getLocalPointInfo(e){return this.localPointsBatchData.get(e)}getLocalPointsInfo(){return this.localPointsBatchData}correctStorage(e,t,n){var c;const r=new Map,s=[];Object.keys(e).forEach(l=>{var u,M;const h=(M=(u=e[l])==null?void 0:u.opt)==null?void 0:M.zIndex;x.isNumber(h)&&s.push([l,h])});const a=s.length&&((c=this.zIndexNodeMethod)==null?void 0:c.correct(s))||[];this.zIndexNodeMethod&&a.length&&(this.zIndexNodeMethod.setMinZIndex(a[0][1]||0,t),this.zIndexNodeMethod.setMaxZIndex(a[a.length-1][1]||0,t));for(const[l,h]of a){if(!e[l])continue;const u=e[l];u.opt&&x.isNumber(u.opt.zIndex)&&u.opt.zIndex!==h&&(u.opt.zIndex=h,r.set(l,u))}return r.size&&r.forEach((l,h)=>{var u;(u=this.collector)==null||u.updateValue(h,l,{viewId:t,scenePath:n,isSync:!0}),e[h]=l}),e}async originalEventLintener(e,t,n){var c,l,h;if(!this.isAbled())return;const r=(c=this.collector)==null?void 0:c.uid,s=this.viewContainerManager.getCurScenePath(n);if(r&&!this.control.renderControl.isWritable)return;const a=((l=this.currentToolsData)==null?void 0:l.toolsType)===T.Selector;switch((h=this.currentToolsData)==null?void 0:h.toolsType){case T.Eraser:case T.PencilEraser:case T.BitMapEraser:{if(r&&!this.control.renderControl.isClearAble({uid:r,viewId:n,scenePath:s}))return;break}default:{if(r&&!this.control.renderControl.isRenderAble({uid:r,viewId:n,scenePath:s}))return;break}}switch(this.control.isUseSimple||Ue(()=>{var u;(u=this.control.pluginManager)==null||u.dispatchPluginEvent("localEvent",n,e,t)},Ri,this.control.hasPolyfillMethod("requestIdleCallback")),e){case j.Start:this.isLocalWorkActive=!0,this.setLocalWorkViewId(n),n&&this.onLocalEventStart(t,n),a&&this.viewContainerManager.showFloatBarBtn(n,!1);break;case j.Doing:n&&n===this.getLocalWorkViewId()&&this.onLocalEventDoing(t,n);break;case j.Done:n&&n===this.getLocalWorkViewId()&&(this.setCurrentLocalWorkData({...this.currentLocalWorkData,workState:j.Done}),await this.onLocalEventEnd(t,n),setTimeout(()=>{this.isLocalWorkActive=!1,this.setCurrentLocalWorkData({workState:j.Pending}),a&&this.viewContainerManager.showFloatBarBtn(n,!0),this.setLocalWorkViewId(void 0)},0));break}this.isLocalWorkActive&&this.viewContainerManager.focuedViewId===n&&this.publicMsgEmitter.emit("workState",e,n)}getLocalWorkViewId(){return this.localWorkViewId}setLocalWorkViewId(e){this.localWorkViewId=e}setCurrentToolsData(e){var r,s,a;const t=e.toolsType,n=((r=this.currentToolsData)==null?void 0:r.toolsType)!==e.toolsType;if(super.setCurrentToolsData(e),n){const c=(s=this.viewContainerManager)==null?void 0:s.getAllViews();for(const l of c)if(l){const{id:h,focusScenePath:u}=l;n&&h&&u&&((a=this.collector)!=null&&a.hasSelector(h,u)&&this.blurSelector(h,u),this.control.textEditorManager.checkEmptyTextBlur())}this.taskBatchData.add({msgType:W.UpdateTools,dataType:K.Local,toolsType:t,opt:{...e.toolsOpt,syncUnitTime:this.maxLastSyncTime},combineUnitTime:this.isBezier?this.combineUnitTime:1/0,maxCombineEraserTime:this.maxCombineEraserTime,isRunSubWork:this.isRunSubWork,viewId:ao}),this.runAnimation()}}prepareOnceWork(e,t){const{workId:n,toolsOpt:r,viewId:s}=e,a={msgType:W.CreateWork,dataType:K.Local,viewId:s,toolsType:t};this.queryTaskBatchData(a).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add({...a,workId:n,opt:{...r,syncUnitTime:this.maxLastSyncTime},dataType:K.Local,isRunSubWork:this.isRunSubWork}),this.runAnimation()}createViewWorker(e,t,n){const{offscreenCanvasOpt:r,layerOpt:s,dpr:a,cameraOpt:c}=t,l={msgType:W.Init,dataType:K.Local,viewId:e,offscreenCanvasOpt:r,layerOpt:s,dpr:a,cameraOpt:c,isRunSubWork:!0,isSafari:navigator.userAgent.indexOf("Safari")!==-1&&navigator.userAgent.indexOf("Chrome")===-1,combineUnitTime:this.isBezier?this.combineUnitTime:1/0,maxCombineEraserTime:this.maxCombineEraserTime,syncUnitTime:this.maxLastSyncTime,isUseSimple:this.control.isUseSimple,offscreenCanvas:n.transferControlToOffscreenCanvas};this.taskBatchData.add(l),this.isBusy&&this.destroyTaskQueue(),this.consume()}destroyViewWorker(e,t=!1){var n;this.getLocalWorkViewId()===e&&this.setLocalWorkViewId(void 0),this.zIndexNodeMethod&&this.zIndexNodeMethod.clearZIndex(e),this.taskBatchData.add({msgType:W.Destroy,dataType:K.Local,viewId:e,isRunSubWork:!0}),this.consume(),t||(n=this.collector)==null||n.dispatch({type:W.Clear,viewId:e}),this.control.renderControl.destoryByViewId(e,t)}onServiceDerive(e,t){var p,f,g,y,w,I,v,S;const{newValue:n,oldValue:r,viewId:s,scenePath:a}=t,c=x.cloneDeep(n)||{},l=e;let h=c.type;if(!n&&r){if(l&&((p=this.collector)==null?void 0:p.getLocalId(l))===Z){this.collector.isOwn(l)?this.blurSelector(s,a):this.blurSelector(s,a,l);return}if(h=W.RemoveNode,r.toolsType===T.LaserPen)return}const u=(f=this.viewContainerManager.getView(s))==null?void 0:f.focusScenePath;if(u&&u!==a)return;if((g=this.collector)!=null&&g.isSelector(e)){const N=(y=this.collector)==null?void 0:y.getUidFromKey(e);if(N&&!this.control.roomMember.isOnLine(N))return}if(h&&l){if(!this.control.renderControl.isFilterAble({viewId:s,elementId:e,scenePath:a},h))return;const N=c;if(N.workId=(w=this.collector)!=null&&w.isOwn(l)?(I=this.collector)==null?void 0:I.getLocalId(l):l,N.msgType=h,N.toolsType===T.LaserPen&&(N.isRunSubWork=!0),N.dataType=K.Service,N.viewId=s,N.scenePath=a,N.useAnimation=this.smoothSync&&((v=N.updateNodeOpt)==null?void 0:v.useAnimation)||!1,N.selectIds&&(N.selectIds=N.selectIds.map(C=>{var D,k;return(D=this.collector)!=null&&D.isOwn(C)?(k=this.collector)==null?void 0:k.getLocalId(C):C})),N&&N.toolsType===T.Text||(r==null?void 0:r.toolsType)===T.Text){this.control.textEditorManager.onServiceDerive(N);return}N.isEnableCursor=this.control.cursor.isEnableCursor,this.taskBatchData.add(N)}this.runAnimation();const M=t.newValue&&((S=t.newValue.opt)==null?void 0:S.zIndex);if(this.zIndexNodeMethod&&x.isNumber(M)){const N=this.zIndexNodeMethod.getMinZIndex(s);this.zIndexNodeMethod.getMaxZIndex(s)<M&&this.zIndexNodeMethod.setMaxZIndex(M,s),N>M&&this.zIndexNodeMethod.setMinZIndex(M,s)}}pullServiceData(e,t,n={isAsync:!1,useAnimation:!1}){var c,l,h,u,M,p,f;let r=(c=this.collector)==null?void 0:c.getStorageData(e,t);const{isAsync:s,useAnimation:a}=n;if(r){this.control.renderControl.isWritable&&(r=this.correctStorage(r,e,t));const g=Object.keys(r);for(const y of g){if((l=this.collector)!=null&&l.isSelector(y)){const I=(h=this.collector)==null?void 0:h.getUidFromKey(y);if(I&&!this.control.roomMember.isOnLine(I))continue}const w=(u=r[y])==null?void 0:u.type;if(w&&y){if(!this.control.renderControl.isFilterAble({viewId:e,elementId:y,scenePath:t},w))continue;const I=r[y];if(I.workId=(M=this.collector)!=null&&M.isOwn(y)?(p=this.collector)==null?void 0:p.getLocalId(y):y,I.msgType=w,I.dataType=K.Service,I.viewId=e,I.scenePath=t,I.useAnimation=this.smoothSync&&(I.ops?!!a:(f=I.updateNodeOpt)==null?void 0:f.useAnimation)||!1,I.selectIds&&(I.selectIds=I.selectIds.map(v=>{var S,N;return(S=this.collector)!=null&&S.isOwn(v)?(N=this.collector)==null?void 0:N.getLocalId(v):v})),I.toolsType===T.Text){this.control.textEditorManager.onServiceDerive(I);continue}s&&I.updateNodeOpt&&I.updateNodeOpt.useAnimation&&(I.updateNodeOpt.useAnimation=!1),I.isEnableCursor=this.control.cursor.isEnableCursor,this.taskBatchData.add(I)}this.internalMsgEmitter.emit("excludeIds",g,e)}s?this.consume():this.runAnimation()}}runAnimation(){!this.animationId&&!this.isBusy&&(this.animationId=requestAnimationFrame(this.consume.bind(this)))}consume(){var t;this.animationId=void 0;const{viewId:e}=this.currentLocalWorkData;if(this.tasksqueue.size){const n=this.consumeQueue(),r=!!n.size;if(this.taskBatchData.size)for(const s of this.taskBatchData.values())s.dataType===K.Service&&(n.add(s),this.taskBatchData.delete(s));n.size?(this.post(n),r&&this.tasksqueue.clear()):this.tasksqueue.size&&(this.animationId=requestAnimationFrame(this.consume.bind(this)));return}if(this.isAbled()&&this.localPointsBatchData.size&&e)for(const[n,{state:r,isFullWork:s,points:a,opt:c}]of this.localPointsBatchData.entries()){if(r===j.Done&&!s||r===j.Start&&!this.isCanStartEventConsum)continue;const l=a.map(h=>h);if(l.length){if(this.isPostCountType&&r===j.Doing){if(this.postCount>this.consumeCount)continue;this.postCount++}this.delayWorkStateToDoneResolve&&r===j.Done&&(this.delayWorkStateToDoneResolve(!0),this.setLockSentEventCursor(!0)),this.taskBatchData.add({op:l,workState:r,workId:n,dataType:K.Local,msgType:W.DrawWork,isRunSubWork:this.isRunSubWork,toolsType:(t=this.currentToolsData)==null?void 0:t.toolsType,viewId:e,scenePath:e&&this.viewContainerManager.getCurScenePath(e),opt:c,smoothSync:this.smoothSync,isLockSentEventCursor:this.getLockSentEventCursor(),syncUnitTime:this.maxLastSyncTime,disableEraseImage:this.control.disableEraseImage,disableEraseText:this.control.disableEraseText,postCount:this.isPostCountType&&this.postCount||void 0,fullWorkerDrawCount:this.isCanPostDraw&&this.fullWorkerDrawCount||void 0}),a.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:j.Unwritable}),this.setLockSentEventCursor(!0)}abled(){this.setCurrentLocalWorkData({workState:j.Pending}),this.setLockSentEventCursor(!1)}isAbled(){return this.currentLocalWorkData.workState!==j.Unwritable}post(e){if(!this.control.hasOffscreenCanvas){if(!this.mainThread){let t=[];t=x.cloneDeep([...e]),setTimeout(()=>{for(const n of t)this.taskBatchData.add(n)},0);return}this.mainThread.consume(e);return}if(this.control.isUseSimple){const t=[...e].find(n=>n.msgType===W.Init&&n.offscreenCanvas);t!=null&&t.offscreenCanvas?this.fullWorker.postMessage(e,[t.offscreenCanvas.bgCanvas,t.offscreenCanvas.localCanvas,t.offscreenCanvas.serviceCanvas]):this.fullWorker.postMessage(e);return}else if(this.subWorker){this.fullWorker.postMessage(e);const t=new Set;for(const n of e.values()){const r=n.msgType;(r===W.Init||r===W.Clear||r===W.Destroy||r===W.UpdateCamera||n.isRunSubWork)&&t.add(n)}t.size&&this.subWorker.postMessage(t)}}updateNode(e,t,n,r){this.taskBatchData.add({msgType:W.UpdateNode,workId:e,updateNodeOpt:t,viewId:n,scenePath:r,dataType:K.Local}),this.runAnimation()}destroyTaskQueue(){this.useTasksqueue=!1,this.useTasksClockId&&(clearTimeout(this.useTasksClockId),this.useTasksClockId=void 0),this.mainTasksqueueCount=void 0,this.workerTasksqueueCount=void 0}updateDpr(e,t){this.queryTaskBatchData({msgType:W.UpdateDpr,dataType:K.Local,viewId:e}).forEach(n=>{this.taskBatchData.delete(n)}),this.taskBatchData.add({dataType:K.Local,msgType:W.UpdateDpr,viewId:e,dpr:t,isRunSubWork:!0}),this.runAnimation()}updateCamera(e,t){var n;this.useTasksqueue||((n=this.methodBuilder)==null||n.pause(),this.blurCursor(e),this.checkDrawingWork(e),this.useTasksqueue=!0,this.mainTasksqueueCount=1,this.workerTasksqueueCount=1),this.useTasksqueue&&(this.tasksqueue.set(e,{msgType:W.UpdateCamera,dataType:K.Local,cameraOpt:{...t,width:t.width,height:t.height},scenePath:this.viewContainerManager.getCurScenePath(e),isRunSubWork:!0,viewId:e}),this.consume(),this.useTasksClockId&&clearTimeout(this.useTasksClockId),this.updateCameraDone())}updateCameraDone(){this.useTasksClockId=setTimeout(()=>{var e;this.useTasksClockId=void 0,this.mainTasksqueueCount===this.workerTasksqueueCount?(this.tasksqueue.size&&this.consume(),this.useTasksqueue=!1,this.mainTasksqueueCount=void 0,this.workerTasksqueueCount=void 0,(e=this.methodBuilder)==null||e.recover(),this.runAnimation()):this.updateCameraDone()},this.maxLastSyncTime)}consumeQueue(){const e=new Set;let t=!this.isBusy;if(this.isBusy&&this.mainTasksqueueCount&&this.workerTasksqueueCount&&this.mainTasksqueueCount<=this.workerTasksqueueCount&&(t=!0),t){this.mainTasksqueueCount&&this.workerTasksqueueCount&&this.mainTasksqueueCount++,e.add({msgType:W.TasksQueue,dataType:K.Local,isRunSubWork:!0,mainTasksqueueCount:this.mainTasksqueueCount,tasksqueue:this.tasksqueue,viewId:""});for(const[n,r]of this.tasksqueue.entries())r.cameraOpt&&this.control.textEditorManager.onCameraChange(r.cameraOpt,n)}return e}async clearViewScenePath(e,t,n){var s,a;const r=this.viewContainerManager.getCurScenePath(e);if(n){const c=(s=this.collector)==null?void 0:s.uid;if(c&&!this.control.renderControl.isClearAble({uid:c,viewId:e,scenePath:r}))return}this.control.textEditorManager.clear(e,t),this.queryTaskBatchData({msgType:W.Clear,dataType:K.Local,viewId:e}).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add({dataType:K.Local,msgType:W.Clear,viewId:e}),this.runAnimation(),t||(this.control.renderControl.isUsePageAuth(e)&&r?this.control.renderControl.clearRenderPage(e,r):(a=this.collector)==null||a.dispatch({type:W.Clear,viewId:e,scenePath:r})),this.zIndexNodeMethod&&this.zIndexNodeMethod.clearZIndex(e);for(const[c,l]of this.localPointsBatchData.entries())l.viewId===e&&this.localPointsBatchData.delete(c);await new Promise(c=>{const l=this.clearAllResolveMap.get(e)||{resolve:void 0,timer:void 0};l.timer&&clearTimeout(l.timer),l.resolve=c,l.timer=setTimeout(()=>{const h=this.clearAllResolveMap.get(e);h!=null&&h.resolve&&h.resolve(e)},this.maxLastSyncTime),this.clearAllResolveMap.set(e,l)}).then(c=>{this.clearAllResolveMap.delete(c)})}internalMsgEmitterListener(){var e;this.methodBuilder=new oe([U.CopyNode,U.SetColorNode,U.DeleteNode,U.RotateNode,U.ScaleNode,U.TranslateNode,U.ZIndexNode,U.SetFontStyle,U.SetPoint,U.SetLock,U.SetShapeOpt]).registerForMainEngine(_.MainEngine,this.control),this.zIndexNodeMethod=(e=this.methodBuilder)==null?void 0:e.getBuilder(U.ZIndexNode)}setZIndex(e){const t=this.currentToolsData&&x.cloneDeep(this.currentToolsData.toolsOpt);return t&&this.zIndexNodeMethod&&this.isUseZIndex&&(this.zIndexNodeMethod.addMaxLayer(e),t.zIndex=this.zIndexNodeMethod.getMaxZIndex(e)),t}checkDrawingWork(e){var r,s,a;let t=!1;const n=[];for(const[c,{state:l,viewId:h,points:u,opt:M}]of this.localPointsBatchData.entries())if(e===h&&l===j.Start||l===j.Doing){if(l===j.Doing&&this.isCanDrawWork){Number(c)&&Number(c)+60>this.now&&(n.push(c.toString()),this.taskBatchData.add({msgType:W.RemoveNode,workId:c,viewId:h,dataType:K.Local,isRunSubWork:!0}));const p=u.map(f=>f);this.taskBatchData.add({op:p,workState:j.Done,workId:c,dataType:K.Local,msgType:W.DrawWork,isRunSubWork:this.isRunSubWork,toolsType:(r=this.currentToolsData)==null?void 0:r.toolsType,viewId:h,opt:M,scenePath:h&&this.viewContainerManager.getCurScenePath(h)}),t=!0}this.deleteLocalPoint(c)}if((t||n.length)&&(this.consume(),n.length)){const c=(s=this.viewContainerManager.getView(e))==null?void 0:s.focusScenePath;(a=this.collector)==null||a.dispatch({type:W.RemoveNode,removeIds:n,viewId:e,scenePath:c})}}removeDrawingWork(e){var n,r;const t=[];for(const[s,{state:a,viewId:c}]of this.localPointsBatchData.entries())(e===c&&a===j.Start||a===j.Doing)&&(this.deleteLocalPoint(s),a===j.Doing&&this.isCanDrawWork&&(t.push(s.toString()),this.taskBatchData.add({msgType:W.RemoveNode,workId:s,viewId:c,dataType:K.Local,isRunSubWork:!0})));if(t.length){this.consume();const s=(n=this.viewContainerManager.getView(e))==null?void 0:n.focusScenePath;(r=this.collector)==null||r.dispatch({type:W.RemoveNode,removeIds:t,viewId:e,scenePath:s})}}removeNodes(e,t){var r,s;const n=(r=this.viewContainerManager.getView(e))==null?void 0:r.focusScenePath;if(n&&t.length){for(const a of t)this.taskBatchData.add({msgType:W.RemoveNode,workId:a,viewId:e,dataType:K.Local,isRunSubWork:!1});this.consume(),(s=this.collector)==null||s.dispatch({type:W.RemoveNode,removeIds:t,viewId:e,scenePath:n})}}hoverCursor(e,t){var n;if(((n=this.currentToolsData)==null?void 0:n.toolsType)===T.Selector&&!this.isBusy){const r=this.viewContainerManager.getView(t);if(r&&r.displayer&&r.displayer.vDom){const c=r.displayer.vDom.state.floatBarData;if(c){const{x:l,y:h,w:u,h:M}=c;if(fo(e,{x:l,y:h,w:u,h:M}))return}}const s=this.viewContainerManager.transformToScenePoint(e,t),a={msgType:W.CursorHover,dataType:K.Local,point:s,toolsType:this.currentToolsData.toolsType,opt:this.currentToolsData.toolsOpt,isRunSubWork:!1,viewId:t};this.queryTaskBatchData({msgType:W.CursorHover,dataType:K.Local,toolsType:this.currentToolsData.toolsType,viewId:t}).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add(a),this.runAnimation()}}blurCursor(e){var n;if(((n=this.currentToolsData)==null?void 0:n.toolsType)!==T.Selector)return;const t={msgType:W.CursorBlur,dataType:K.Local,isRunSubWork:!1,viewId:e};this.queryTaskBatchData({msgType:W.CursorHover,dataType:K.Local,viewId:e}).forEach(r=>{this.taskBatchData.delete(r)}),this.taskBatchData.add(t),this.consume()}sendCursorEvent(e,t){var c,l,h;if(!this.currentLocalWorkData||this.currentLocalWorkData.workState===j.Unwritable||this.isBusy)return;const n=(c=this.currentToolsData)==null?void 0:c.toolsType;if(!this.useTasksqueue&&this.workState===j.Pending&&n===T.Selector&&(x.isNumber(e[0])&&x.isNumber(e[1])?this.hoverCursor(e,t):e[0]===void 0&&e[1]===void 0&&this.blurCursor(t)),!this.currentToolsData||!this.isCanSentCursor||!this.control.pluginOptions.extras.cursor.enable)return;const r=(l=this.collector)==null?void 0:l.uid,s=this.viewContainerManager.getCurScenePath(t);switch((h=this.currentToolsData)==null?void 0:h.toolsType){case T.Eraser:case T.PencilEraser:case T.BitMapEraser:{if(r&&!this.control.renderControl.isClearAble({uid:r,viewId:t,filterLocalSelf:!1,scenePath:s}))return;break}default:if(r&&!this.control.renderControl.isWritable||r&&!this.control.renderControl.isRenderAble({uid:r,viewId:t,filterLocalSelf:!1,scenePath:s}))return;break}let a=[void 0,void 0];this.currentToolsData&&this.isCanSentCursor&&!this.localPointsBatchData.size&&!this.getLockSentEventCursor()&&(a=e,this.control.cursor.sendEvent(a,t))}getBoundingRect(e){var n,r;if(!((n=this.boundingRectMap)==null?void 0:n.get(e))){const s=(r=this.collector)==null?void 0:r.getScenePathData(e);if(!s)return;if(Object.keys(s).forEach(a=>{var c;((c=this.collector)==null?void 0:c.getLocalId(a))===Z&&delete s[a]}),Object.keys(s).length&&this.viewContainerManager.mainView&&this.viewContainerManager.mainView.cameraOpt){const a={msgType:W.BoundingBox,dataType:K.Local,scenePath:e,scenes:s,cameraOpt:{...this.viewContainerManager.mainView.cameraOpt},isRunSubWork:!0,viewId:this.viewContainerManager.mainView.id};return this.taskBatchData.add(a),this.runAnimation(),new Promise(c=>{this.boundingRectMap.set(e,c)}).then(c=>(this.boundingRectMap.delete(e),c))}}}getSnapshot(e,t,n,r){var a,c,l,h,u;if(!((a=this.snapshotMap)==null?void 0:a.get(e))){const M=(c=this.collector)==null?void 0:c.getViewIdBySecenPath(e);if(!M)return;const p=(l=this.collector)==null?void 0:l.getStorageData(M,e);if(!p)return;if(Object.keys(p).forEach(f=>{var g;((g=this.collector)==null?void 0:g.getLocalId(f))===Z&&delete p[f]}),Object.keys(p).length){const f=this.viewContainerManager.mainView;if(!f)return;const g=t||((h=f.cameraOpt)==null?void 0:h.width),y=n||((u=f.cameraOpt)==null?void 0:u.height),w={msgType:W.Snapshot,dataType:K.Local,scenePath:e,scenes:p,w:g,h:y,cameraOpt:r&&{...r,width:g,height:y}||f.cameraOpt,isRunSubWork:!0,viewId:M};return this.taskBatchData.add(w),this.runAnimation(),new Promise(I=>{this.snapshotMap.set(e,I)}).then(I=>(this.snapshotMap.delete(e),I))}}}queryTaskBatchData(e){const t=[];if(e)for(const n of this.taskBatchData.values()){let r=!0;for(const[s,a]of Object.entries(e))if(n[s]!==a){r=!1;break}r&&t.push(n)}return t}insertIconify(e,t){var a;const n=this.viewContainerManager.getView(e);if(!n)throw new Error("insertIconify viewId is not exist");if(!t.src)throw new Error("iconify src must be required");if(!/^(http|https):\/\//.test(t.src))throw new Error("iconify src must be http or https");t.strokeColor||(t.strokeColor=(a=this.currentLocalWorkData.toolsOpt)==null?void 0:a.strokeColor);const s=n==null?void 0:n.focusScenePath;if(e&&s){const c=this.now;Te.InternalMsgEmitter.emit("addUndoTicker",c,e);const l={...t,type:jt.Iconify};this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayer(e),l.zIndex=this.zIndexNodeMethod.getMaxZIndex(e)),this.taskBatchData.add({msgType:W.FullWork,dataType:K.Local,toolsType:T.Image,workId:t.uuid,opt:l,viewId:e,willRefresh:!0,willSyncService:!0}),this.runAnimation()}}insertImage(e,t){const n=this.viewContainerManager.getView(e);if(!n)throw new Error("insertImage viewId is not exist");if(t.src&&!/^(http|https):\/\//.test(t.src))throw new Error("Image src must be http or https");const r=n==null?void 0:n.focusScenePath;if(e&&r){const{src:s,uuid:a}=t;if(a&&!s){this.tmpImageConfigMap.set(a,t);return}const c=this.now;Te.InternalMsgEmitter.emit("addUndoTicker",c,e);const l={...t,type:jt.Image};this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayer(e),l.zIndex=this.zIndexNodeMethod.getMaxZIndex(e)),this.taskBatchData.add({msgType:W.FullWork,dataType:K.Local,toolsType:T.Image,workId:t.uuid,opt:l,viewId:e,willRefresh:!0,willSyncService:!0}),this.runAnimation()}}lockImage(e,t,n){var a,c;const r=this.viewContainerManager.getView(e);if(!r)throw new Error("insertImage viewId is not exist");const s=r==null?void 0:r.focusScenePath;if(e&&s&&this.collector){const l=this.collector.getStorageData(e,s);if(!l)return;for(const[h,u]of Object.entries(l))if(u&&u.toolsType===T.Image&&u.opt.uuid===t){const M=this.now;Te.InternalMsgEmitter.emit("addUndoTicker",M,e);const p=(a=this.collector)!=null&&a.isOwn(h)?(c=this.collector)==null?void 0:c.getLocalId(h):h,f={...u.opt,locked:n,type:jt.Image};this.taskBatchData.add({msgType:W.FullWork,dataType:K.Local,toolsType:T.Image,workId:p,opt:f,viewId:e,willRefresh:!0,willSyncService:!0}),this.runAnimation();return}}}completeImageUpload(e,t,n){const r=this.viewContainerManager.getView(e);if(!r)throw new Error("insertImage viewId is not exist");const s=r==null?void 0:r.focusScenePath;if(e&&s){const a=this.tmpImageConfigMap.get(t);a&&(a.src=n,this.insertImage(e,a),this.tmpImageConfigMap.delete(t));return}}getImagesInformation(e){const t=[];if(this.collector){const n=this.collector.getScenePathData(e);if(!n)return t;for(const r of Object.values(n))if(r&&r.toolsType===T.Image){const s=r.opt;t.push({uuid:s.uuid,centerX:s.centerX,centerY:s.centerY,width:s.width,height:s.height,locked:s.locked,uniformScale:s.uniformScale,crossOrigin:s.crossOrigin})}}return t}setShapeSelectorByWorkId(e,t){this.taskBatchData.add({workId:Z,selectIds:[e],msgType:W.Select,dataType:K.Local,viewId:t,willSyncService:!0}),this.runAnimation()}blurSelector(e,t,n){this.taskBatchData.add({workId:n||Z,selectIds:[],msgType:W.Select,dataType:K.Service,viewId:e,scenePath:t}),this.runAnimation()}consoleWorkerInfo(){this.taskBatchData.add({msgType:W.Console,dataType:K.Local,isRunSubWork:!0,viewId:""}),this.consume()}sendClearUids(e,t){var r,s;const n=new Set;n.add({msgType:W.AuthClear,dataType:K.Local,viewId:e,clearUids:t,localUid:(r=this.collector)==null?void 0:r.uid}),this.control.hasOffscreenCanvas?this.fullWorker.postMessage(n):(s=this.mainThread)==null||s.consume(n)}async getVNodeInfo(e,t,n){if(!this.getVNodeInfoResolveMap.has(e))return this.taskBatchData.add({msgType:W.GetVNodeInfo,dataType:K.Local,isRunSubWork:!0,viewId:t,workIds:n,workId:e}),this.consume(),await new Promise(r=>{const s=this.getVNodeInfoResolveMap.get(e)||{resolve:void 0,timer:void 0};s.timer&&clearTimeout(s.timer),s.resolve=r,s.timer=setTimeout(()=>{const a=this.getVNodeInfoResolveMap.get(e);a!=null&&a.resolve&&a.resolve({uuid:e})},this.maxLastSyncTime*5),this.getVNodeInfoResolveMap.set(e,s)}).then(r=>{const{uuid:s}=r;return this.getVNodeInfoResolveMap.delete(s),r})}}class ep{constructor(i){m(this,"internalMsgEmitter");m(this,"control");m(this,"roomHotkeyCheckers");m(this,"tmpCopyStore",new Map);m(this,"tmpCopyCoordInfo");var n;const{control:e,internalMsgEmitter:t}=i;this.control=e,this.internalMsgEmitter=t,this.roomHotkeyCheckers=((n=this.control.room)==null?void 0:n.viewsParams.hotKeys.nodes)||[]}get isUseSelf(){var i,e;return((e=(i=this.control)==null?void 0:i.room)==null?void 0:e.disableDeviceInputs)||!1}get isSelector(){var i;return((i=this.control.worker.currentToolsData)==null?void 0:i.toolsType)===T.Selector}get collector(){return this.control.collector}get mainEngine(){return this.control.worker}get keyboardKind(){return/^Mac/i.test(navigator.platform)?"mac":"windows"}getEventKey(i){switch(i.type){case"keydown":return"KeyDown"}return"KeyUp"}onActiveHotkey(i){var n,r,s;const e=this.control.viewContainerManager.focuedViewId,t=(n=this.control.viewContainerManager.focuedView)==null?void 0:n.focusScenePath;if(e&&t)switch(i){case"delete":this.isSelector&&((r=this.collector)!=null&&r.hasSelector(e,t))&&oe.emitMethod(_.MainEngine,U.DeleteNode,{workIds:[Z],viewId:e});break;case"copy":this.isSelector&&((s=this.collector)!=null&&s.hasSelector(e,t))&&this.copySelectorToTemp(e,t);break;case"paste":this.tmpCopyStore.size&&this.pasteTempToFocusView(e,t);break}(i==="changeToPencil"||i==="redo"||i==="undo")&&this.onSelfActiveHotkey(i)}colloctHotkey(i){if(this.isUseSelf){const e=this.checkHotkey(i);e&&this.onSelfActiveHotkey(e)}}onSelfActiveHotkey(i){switch(i){case"changeToPencil":this.setMemberState({currentApplianceName:ee.pencil,useNewPencil:!0});break;case"changeToArrow":this.setMemberState({currentApplianceName:ee.arrow});break;case"changeToClick":this.setMemberState({currentApplianceName:ee.clicker});break;case"changeToEllipse":this.setMemberState({currentApplianceName:ee.ellipse});break;case"changeToEraser":this.setMemberState({currentApplianceName:ee.eraser});break;case"changeToHand":this.setMemberState({currentApplianceName:ee.hand});break;case"changeToLaserPointer":this.setMemberState({currentApplianceName:ee.laserPointer});break;case"changeToSelector":this.setMemberState({currentApplianceName:ee.selector});break;case"changeToRectangle":this.setMemberState({currentApplianceName:ee.rectangle});break;case"changeToStraight":this.setMemberState({currentApplianceName:ee.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:ee.text});break;case"changeToPencilEraser":this.setMemberState({currentApplianceName:ee.pencilEraser});break;case"delete":case"copy":case"paste":this.onActiveHotkey(i);break}}checkHotkey(i){for(const e of this.roomHotkeyCheckers){const{kind:t,checker:n}=e;if(n({nativeEvent:i,kind:this.getEventKey(i),key:i.key,altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey},this.keyboardKind))return t}}copySelectorToTemp(i,e){var l,h;const t=this.control.viewContainerManager.getView(i),n=(h=(l=this.mainEngine)==null?void 0:l.methodBuilder)==null?void 0:h.getBuilder(U.CopyNode);if(!t||!this.collector||!n)return;const r=this.collector.transformKey(Z),s=this.collector.getStorageData(i,e);if(!s)return;const a=s[r],c=a&&n.copySelector({viewId:i,store:a});c&&(this.tmpCopyCoordInfo=c==null?void 0:c.copyCoordInfo,this.tmpCopyStore=c==null?void 0:c.copyStores)}pasteTempToFocusView(i,e){var r,s;const t=this.control.viewContainerManager.getView(i),n=(s=(r=this.mainEngine)==null?void 0:r.methodBuilder)==null?void 0:s.getBuilder(U.CopyNode);if(!(!t||!this.tmpCopyCoordInfo||!this.tmpCopyStore.size||!this.collector||!n)&&t.viewData&&this.tmpCopyCoordInfo){const a=x.cloneDeep(this.tmpCopyCoordInfo.offset),c=this.tmpCopyCoordInfo.cameraOpt,l=t.viewData.camera;a.x=a.x+l.centerX-c.centerX,a.y=a.y+l.centerY-c.centerY;const h=this.control.worker.now;this.control.worker.internalMsgEmitter.emit("addUndoTicker",h,i),n.pasteSelector({viewId:i,scenePath:e,copyStores:x.cloneDeep(this.tmpCopyStore),copyCoordInfo:{offset:a,cameraOpt:l},undoTickerId:h})}}setMemberState(i){var e;(e=this.control.room)==null||e.setMemberState(i)}}class tp{constructor(i){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 n;const{control:e,publicMsgEmitter:t}=i;this.control=e,this.publicMsgEmitter=t,this.roomMemberManager=e.roomMember,this.worker=e.worker,this.isCurWritable=((n=this.control.room)==null?void 0:n.isWritable)||!1}get isWritable(){return this.isCurWritable}onWritableChange(i){this.isCurWritable=i}addPage(i,e=!0){var l,h;const{viewId:t,render:n="localSelf",elementIds:r,pageId:s=(l=this.control.collector)==null?void 0:l.uid}=i,a=this.pageAuth.get(t)||new Map,c=this.control.viewContainerManager.getCurScenePath(t);if(c&&s){const u=a.get(c)||{render:"localSelf",pages:new Map};e&&(u.render=n);const M=r&&this.cloneElementIds(t,c,r,s)||new Set;u.pages.set(s,M),a.set(c,u),this.pageAuth.set(t,a),e&&this.pageAuthEffect(t),this.isLocalRender=!1,(h=this.control.collector)==null||h.dispatchPageAuth({operation:ze.addPage,viewId:t,scenePath:c,pageId:s,pageData:{render:n,elementIds:M}},!0)}}delPage(i,e){var s,a;const t=this.pageAuth.get(e);if(!t)return;const n=[...t.keys()].find(c=>{const l=t.get(c);return!!(l&&l.pages.has(i))});if(!n)return;const r=t.get(n);if(r){const{render:c,pages:l}=r,h=c==="localSelf"?(s=this.control.collector)==null?void 0:s.uid:c,u=l.get(i);u!=null&&u.size&&this.delElementIds(e,n,u),l.delete(i),h===i&&this.pageAuthEffect(e)}(a=this.control.collector)==null||a.dispatchPageAuth({operation:ze.deletePage,viewId:e,scenePath:n,pageId:i},!0)}delViewPage(i,e=!0){var n;this.pageAuth.get(i)&&(this.pageAuth.delete(i),e&&((n=this.control.collector)==null||n.dispatchPageAuth({operation:ze.clearView,viewId:i},e)))}clearRenderPage(i,e,t=!0){var a,c;const n=this.pageAuth.get(i);if(!n)return;const r=n.get(e);let s;if(r){const{render:l,pages:h}=r,u=l==="localSelf"?(a=this.control.collector)==null?void 0:a.uid:l;if(u){if(t){const M=h.get(u);M&&this.delElementIds(i,e,M)}h.set(u,new Set),s=u}}t&&s&&((c=this.control.collector)==null||c.dispatchPageAuth({operation:ze.clearPage,viewId:i,scenePath:e,pageId:s},t))}hasPage(i,e,t){const n=this.pageAuth.get(e);if(!n)return!1;const r=n.get(t);return r?r.pages.has(i):!1}getPageInfo(i,e,t){const n=this.pageAuth.get(e);if(!n)return;const r=n.get(t);if(r)return r.pages.get(i)}addRenderPageElementId(i,e=!0,t=!1){var h,u;const{viewId:n,elementId:r,scenePath:s}=i,a=this.pageAuth.get(n);if(!a)throw new Error(`no view info in viewId: ${n}`);const c=a.get(s);let l;if(c){const{render:M,pages:p}=c,f=M==="localSelf"?(h=this.control.collector)==null?void 0:h.uid:M;if(f&&p.has(f)){const g=p.get(f)||new Set;g.add(r),p.set(f,g),l=f}}t&&this.pageAuthEffect(n),e&&l&&((u=this.control.collector)==null||u.dispatchPageAuth({operation:ze.addElement,viewId:n,scenePath:s,pageId:l,pageData:{elementId:r}},e))}delRenderPageElementId(i,e=!0,t=!1){var h,u;const{viewId:n,elementId:r,scenePath:s}=i,a=this.pageAuth.get(n);if(!a)throw new Error(`no view info in viewId: ${n}`);const c=a.get(s);let l;if(c){const{render:M,pages:p}=c,f=M==="localSelf"?(h=this.control.collector)==null?void 0:h.uid:M;if(f&&p.has(f)){const g=p.get(f);g&&(g.delete(r),p.set(f,g),l=f)}}t&&this.pageAuthEffect(n),e&&l&&((u=this.control.collector)==null||u.dispatchPageAuth({operation:ze.deleteElement,viewId:n,scenePath:s,pageId:l,pageData:{elementId:r}},e))}setPageRender(i,e,t,n=!0){var a;const r=this.pageAuth.get(i);if(!r)throw new Error(`no view info in viewId: ${i}`);const s=r.get(e);s&&(s.render=t),e===this.control.viewContainerManager.getCurScenePath(i)&&this.pageAuthEffect(i),n||(this.isLocalRender=!0),n&&(this.isLocalRender=!1,(a=this.control.collector)==null||a.dispatchPageAuth({operation:ze.renderPage,viewId:i,scenePath:e,pageData:{render:t}},n))}isRenderAble(i){var c,l;const{uid:e,viewId:t,filterLocalSelf:n=!0,scenePath:r}=i,s=this.renderUids.get(t);if(s){const{render:h,hide:u}=s;if(h===void 0&&u===void 0)return!0;if(x.isSet(h)){if(h.has(e)||n&&((c=this.control.collector)==null?void 0:c.uid)===e&&h.has("localSelf"))return!0}else if(h===!0&&(!u||x.isSet(u)&&!u.has(e)&&!(n&&u.has("localSelf")&&((l=this.control.collector)==null?void 0:l.uid)===e)))return!0;return!1}const a=this.pageAuth.get(t);if(a&&r){const h=a.get(r);if(h){const{render:u}=h;if(u)return!(u==="localSelf"&&!n)}}return!0}isClearAble(i){var c;const{uid:e,viewId:t,filterLocalSelf:n=!0,scenePath:r}=i,s=this.renderUids.get(t);if(s){const{clear:l}=s;return!!(l===void 0||l===!0||x.isSet(l)&&(l.has(e)||n&&((c=this.control.collector)==null?void 0:c.uid)===e&&l.has("localSelf")))}const a=this.pageAuth.get(t);if(a&&r){const l=a.get(r);if(l){const{render:h}=l;if(h)return!(h==="localSelf"&&!n)}}return!0}isFilterAble(i,e){var c,l,h,u;const{viewId:t,scenePath:n,elementId:r}=i,s=this.renderUids.get(t);if(s&&r){const{render:M,hide:p}=s;if(M===void 0&&p===void 0)return!0;const f=(c=this.control.collector)==null?void 0:c.getUidFromKey(r);return f?!!(x.isSet(M)&&(M.has(f)||M.has("localSelf")&&((l=this.control.collector)==null?void 0:l.uid)===f)||M===!0&&(!p||x.isSet(p)&&!p.has(f)&&!(p.has("localSelf")&&((h=this.control.collector)==null?void 0:h.uid)===f))):!1}const a=this.pageAuth.get(t);if(a&&n&&r){const M=a.get(n);if(M){const{render:p,pages:f}=M;if(!p)return!0;const g=(u=this.control.collector)==null?void 0:u.uid,y=p==="localSelf"?g:p,w=y&&f.get(y)||void 0;if(w)switch(e){case W.RemoveNode:return!0;default:return w.has(r)}return!1}}return!0}isFilterCursor(i){if(this.isUsePageAuth(i)){const e=this.control.viewContainerManager.getCurScenePath(i),t=this.pageAuth.get(i);if(e&&t){const n=t.get(e);if(n){const{render:r}=n;return r!=="localSelf"}}}return!0}isUsePageAuth(i){var n;if(!this.pageAuth.has(i))return!1;const t=this.control.viewContainerManager.getCurScenePath(i);return t&&((n=this.pageAuth.get(i))==null?void 0:n.has(t))||!1}publishRender(i){var s;const{viewId:e,option:t,isSync:n=!0}=i,r={};if(t){const{render:a,hide:c,clear:l}=t;a&&(r.render=a===!0&&!0||new Set(a)),c&&(r.hide=c===!0&&!0||new Set(c)),l&&(r.clear=l===!0&&!0||new Set(l)),this.renderUids.set(e,r)}else this.renderUids.delete(e);n&&((s=this.control.collector)==null||s.dispatchRenderAuth({operation:Ye.setAuth,viewId:e,renderData:r},n)),this.renderEffect(e)}publishOneRender(i,e,t,n=!0){var a;const r=this.renderUids.get(i);let s;switch(t){case"show":r?(r.render||(r.render=new Set),x.isSet(r.render)&&r.render.add(e),x.isSet(r.hide)&&r.hide.delete(e)):this.renderUids.set(i,{render:new Set([e])}),s=Ye.setShow;break;case"hide":r?(r.hide||(r.hide=new Set),x.isSet(r.hide)&&r.hide.add(e),x.isSet(r.render)&&r.render.delete(e)):this.renderUids.set(i,{hide:new Set([e])}),s=Ye.setHide;break}r?this.renderUids.set(i,r):this.renderUids.delete(i),n&&s&&((a=this.control.collector)==null||a.dispatchRenderAuth({operation:s,viewId:i,uid:e},n)),this.renderEffect(i)}publishOneClear(i,e,t,n=!0){var s;const r=this.renderUids.get(i);t?r?(r.clear||(r.clear=new Set),x.isSet(r.clear)&&r.clear.add(e)):this.renderUids.set(i,{clear:new Set([e])}):r&&x.isSet(r.clear)&&r.clear.has(e)&&r.clear.delete(e),r?this.renderUids.set(i,r):this.renderUids.delete(i),n&&((s=this.control.collector)==null||s.dispatchRenderAuth({operation:Ye.setClear,viewId:i,uid:e,isClear:t},n)),this.renderEffect(i)}syncRenderUids(i,e,t,n){const r=e===!0?!0:e&&Object.keys(e)?new Set(Object.keys(e)):void 0,s=t===!0?!0:t&&Object.keys(t)?new Set(Object.keys(t)):void 0,a=n===!0?!0:n&&Object.keys(n)?new Set(Object.keys(n)):void 0;r||s||a?this.renderUids.set(i,{render:r,hide:s,clear:a}):this.renderUids.delete(i),this.renderEffect(i),this.publicMsgEmitter.emit("syncRenderUids",i,{render:r,hide:s,clear:a})}syncPageAuth(i,e,t=!1){let n=!1;if(!e)this.pageAuth.delete(i);else{const r=this.pageAuth.get(i)||new Map;for(const[s,a]of Object.entries(e)){const{render:c,pages:l}=a,h=r.get(s),u=this.isLocalRender?h==null?void 0:h.render:c;if(u){u!==(h==null?void 0:h.render)&&(n=!0);const M=new Map;for(const[f,g]of Object.entries(l))M.set(f,new Set(Object.keys(g)));const p={render:u,pages:M};M.size&&r.set(s,p)}}r.size&&(this.pageAuth.set(i,r),this.publicMsgEmitter.emit("syncPageAuth",i,r))}(t||n)&&this.pageAuthEffect(i)}destoryByViewId(i,e=!1){var t;this.renderUids.has(i)&&(this.renderUids.delete(i),e||(t=this.control.collector)==null||t.dispatchRenderAuth({operation:Ye.setAuth,viewId:i})),this.pageAuth.has(i)&&this.control.renderControl.delViewPage(i,!e)}renderEffect(i){var t;const e=(t=this.control.viewContainerManager.getView(i))==null?void 0:t.focusScenePath;e&&this.worker.clearViewScenePath(i,!0).then(()=>{var n;this.worker.pullServiceData(i,e,{isAsync:!0,useAnimation:!1}),this.worker.sendClearUids(i,(n=this.renderUids.get(i))==null?void 0:n.clear)})}pageAuthEffect(i){var t;const e=(t=this.control.viewContainerManager.getView(i))==null?void 0:t.focusScenePath;e&&this.worker.clearViewScenePath(i,!0).then(()=>{this.worker.pullServiceData(i,e,{isAsync:!0,useAnimation:!1}),this.worker.sendClearUids(i,!0)})}cloneElementIds(i,e,t,n){var a,c;const r=(a=this.control.collector)==null?void 0:a.getStorageData(i,e),s=new Set;if(r){for(const l of Object.keys(r))if(t.has(l)){const h=`${l}_${n}`;if(s.add(h),!Object.keys(r).includes(h)){const u=x.cloneDeep(r[l]);(c=this.control.collector)==null||c.updateValue(h,{type:W.FullWork,...u,workId:h},{isSync:!0,viewId:i,scenePath:e})}}}return s}delElementIds(i,e,t){var r,s;const n=(r=this.control.collector)==null?void 0:r.getStorageData(i,e);if(n)for(const a of Object.keys(n))t.has(a)&&Object.keys(n).includes(a)&&((s=this.control.collector)==null||s.updateValue(a,void 0,{isSync:!0,viewId:i,scenePath:e}))}}class ip{constructor(i){m(this,"internalMsgEmitter");m(this,"control");m(this,"maps",new Map);m(this,"showId");m(this,"color");m(this,"timer");m(this,"updateMiniMapCamera",x.debounce(async i=>{const e=this.maps.get(i);if(e){const t=await this.getMiniMapCamera(i);if(t){const n=t.width/t.scale,r=t.height/t.scale,s=e.miniMapCamera.width/e.miniMapCamera.scale,a=e.miniMapCamera.height/e.miniMapCamera.scale;(n>=s||r>=a)&&(e.miniMapCamera=t);const c=e.miniMapCanvas.current;if(c){const l=c.getContext("2d");if(l){const h=this.control.viewContainerManager.getView(i);if(!(h!=null&&h.focusScenePath))return;const{miniMapCamera:u,contianer:M}=e,{width:p,height:f}=M.getBoundingClientRect(),g=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*g}px`,c.style.height=`${u.height*g}px`,await this.control.screenshotToCanvas(l,h.focusScenePath,u.width,u.height,u),this.listener.emitAsync([i,"viewCameraUpate"],1)}}}}},2e3,{maxWait:5e3}));var n;const{control:e,internalMsgEmitter:t}=i;this.control=e,this.internalMsgEmitter=t,this.color=((n=this.control.worker.currentToolsData)==null?void 0:n.toolsOpt.strokeColor)||"#000"}get listener(){return this.internalMsgEmitter}get activeViewId(){return this.showId}get highlightColor(){return this.color}setHighlightColor(i){this.color=i}async createMiniMap(i,e,t){const n=this.control.viewContainerManager.getView(i);if(!n)throw new Error("view not found");const r=n.cameraOpt;if(!r)throw new Error("view camera not found");const{width:s,height:a}=e.getBoundingClientRect();if(!s||!a)throw new Error("contianer width or height is 0");const c=d.createRef();this.maps.set(i,{contianer:e,miniMapCanvas:c,miniMapCamera:t,viewCamera:r}),this.showId=i,this.control.viewContainerManager.setActiveMiniMap(this.showId,!0);const l=Math.min(s/t.width,a/t.height),h=await new Promise(u=>{this.listener.once([i,"miniMapCreate"],()=>{const M=c.current;M&&(M.width=t.width,M.height=t.height,M.style.width=`${t.width*l}px`,M.style.height=`${t.height*l}px`),u(!0)}),this.timer=setTimeout(()=>{u(!1)},2e3)});return this.timer&&clearTimeout(this.timer),h}async getMiniMapCamera(i){const e=this.control.viewContainerManager.getView(i);if(!e)return;const{cameraOpt:t,focusScenePath:n}=e;if(!t||!n)return;const r={originX:t.centerX-t.width/t.scale/2,originY:t.centerY-t.height/t.scale/2,width:t.width/t.scale,height:t.height/t.scale};let s=await this.control.getBoundingRect(n)||r;s=Yi(s,r)||r;let a=s.width,c=s.height,l=1;const h=a>t.width&&Math.min(t.width/a,l)||l,u=c>t.height&&Math.min(t.height/c,l)||l;return h<=u?(a=h<1&&t.width||a,c=Math.floor(c*h)+1,l=h):h>u&&(c=u<1&&t.height||c,a=Math.floor(a*u)+1,l=u),{scale:l,centerX:s.originX+s.width/2,centerY:s.originY+s.height/2,width:a,height:c}}getMiniMapCanvas(i){const e=this.maps.get(i);return(e==null?void 0:e.miniMapCanvas.current)||null}updateViewCamera(i,e){const t=this.maps.get(i);t&&(t.viewCamera=e,this.listener.emitAsync([i,"viewCameraUpate"],1))}destroyMiniMap(i){const e=i||this.showId;e&&(this.maps.delete(e),this.control.viewContainerManager.setActiveMiniMap(e,!1))}}class po{constructor(){m(this,"control");m(this,"_listeners",{})}_inject(i){this.control=i}_onEvent(i,e){this._listeners[i]&&this._listeners[i](...e)}callbacks(i,e){this._listeners[i]=e}removeCallback(i){delete this._listeners[i]}}class np{constructor(i){m(this,"control");m(this,"worker");m(this,"publicMsgEmitter");m(this,"plugins",new Map);const{control:e,publicMsgEmitter:t}=i;this.control=e,this.publicMsgEmitter=t,this.worker=e.worker}use(i){this.plugins.set(i.kind,i),i._inject(this.control),i.onCreate()}destroy(){this.plugins.forEach(i=>{this.plugins.delete(i.kind),i.onDestroy()})}dispatchPluginEvent(i,...e){this.plugins.forEach(t=>{t._onEvent(i,e)})}}const rt=class rt{constructor(i){m(this,"version",so);m(this,"plugin");m(this,"room");m(this,"play");m(this,"collector");m(this,"hasSwitchToSelectorEffect");m(this,"snapshootStateMap");m(this,"_disableDeviceInputs");m(this,"_disableEraseImage");m(this,"_disableEraseText");m(this,"_disableCameraTransform");m(this,"_disableUseWorker",!1);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,"pluginManager");m(this,"_isPolyfill",{requestIdleCallback:!1,cancelIdleCallback:!1});m(this,"onSceneChange",async(i,e)=>{var s;const t=this.viewContainerManager.getView(e);t!=null&&t.focusScenePath&&(s=this.collector)!=null&&s.hasSelector(e,t.focusScenePath)&&this.worker.blurSelector(e,t.focusScenePath),this.textEditorManager.checkEmptyTextBlur();const n=t==null?void 0:t.displayer;n&&(n.setActive(!1),await n.stopEventHandler());const r=i;r&&this.viewContainerManager.setViewScenePath(e,r),n==null||n.setActive(!0)});m(this,"onRoomMembersChange",i=>{this.roomMember.setRoomMembers(F.toJS(i))});m(this,"onMemberChange",x.throttle(i=>{var s,a;if(!this.room||!this.worker||!i||!this.room.isWritable)return;const e=this.getToolsKey(i),t=(s=this.worker.getCurrentToolsData())==null?void 0:s.toolsType,n=this.viewContainerManager.focuedViewId;n&&t===T.Selector&&e!==T.Selector&&this.worker.blurCursor(n);const r=this.getToolsOpt(e,i);this.worker.setCurrentToolsData(r),(a=this.pluginManager)==null||a.dispatchPluginEvent("setToolkey",e),this.effectViewContainer(e),this.effectResolve&&this.effectResolve(!0)},100,{leading:!1}));m(this,"internalSceneChange",(i,e)=>{var t,n,r,s;this.isUseSimple||((t=this.miniMapManager)==null?void 0:t.activeViewId)===i&&((n=this.miniMapManager)==null||n.destroyMiniMap(i)),(r=this.pluginManager)==null||r.dispatchPluginEvent("sceneChange",i,e),(s=this.worker)==null||s.clearViewScenePath(i,!0).then(()=>{var a;(a=this.worker)==null||a.pullServiceData(i,e,{isAsync:!0,useAnimation:!1})})});m(this,"internalCameraChange",(i,e)=>{var t,n;(t=this.worker)==null||t.updateCamera(i,e),this.isUseSimple||(n=this.miniMapManager)==null||n.updateViewCamera(i,e)});var s;const{displayer:e,plugin:t,options:n}=i;this.plugin=t,this.room=F.isRoom(e)?e:void 0,this.play=F.isPlayer(e)?e:void 0,this.room&&(this._disableDeviceInputs=this.room.disableDeviceInputs,this._disableEraseImage=this.room.disableEraseImage,this._disableEraseText=!1),this.pluginOptions=n,((s=n.extras)==null?void 0:s.useWorker)==="mainThread"?this._disableUseWorker=!0:this._disableUseWorker=fn!=="worker",this.roomMember=new Rf;const r={control:this,internalMsgEmitter:rt.InternalMsgEmitter,publicMsgEmitter:rt.PublicMsgEmitter};this.cursor=new Yf(r),this.textEditorManager=new Rg(r),this.worker=new _f(r),this.hotkeyManager=new ep(r),this.renderControl=new tp(r),this.isUseSimple||(this.miniMapManager=new ip(r),this.pluginManager=new np(r))}hasPolyfillMethod(i){return this._isPolyfill[i]}registerPolyfillMethod(i){this._isPolyfill[i]=!0}get hasExtendFontFaces(){return this.extendFontFaces.length>0}get extendFontFaces(){var i;return((i=this.pluginOptions.extras.textEditor)==null?void 0:i.extendFontFaces)??we.textEditor.extendFontFaces}get loadFontFacesTimeout(){var i;return((i=this.pluginOptions.extras.textEditor)==null?void 0:i.loadFontFacesTimeout)??we.textEditor.loadFontFacesTimeout}get disableEraseText(){return this._disableEraseText||!1}set disableEraseText(i){this._disableEraseText=i}get disableEraseImage(){return this._disableEraseImage||!1}set disableEraseImage(i){this._disableEraseImage=i}get disableDeviceInputs(){return this._disableDeviceInputs||!1}set disableDeviceInputs(i){var t;this._disableDeviceInputs=i;const e=(t=this.worker.getCurrentToolsData())==null?void 0:t.toolsType;e&&this.effectViewContainer(e)}get disableCameraTransform(){return this._disableCameraTransform||!1}set disableCameraTransform(i){this._disableCameraTransform=i}get disableUseWorker(){return this._disableUseWorker||!1}set disableUseWorker(i){this._disableUseWorker=i}get hasOffscreenCanvas(){return this._disableUseWorker?!1:fn==="worker"}get canUseTransferControlToOffscreen(){return this._disableUseWorker?!1:!!HTMLCanvasElement.prototype.transferControlToOffscreen}get isUseOffscreenTransfer(){return this.isUseSimple&&this.hasOffscreenCanvas&&this.canUseTransferControlToOffscreen}get isUseSimple(){return this.pluginOptions.extras.useSimple}bindPlugin(i){this.plugin=i,this.collector&&(this.collector.removeStorageStateListener(),this.collector.removeAuthStateListener()),this.collector=new fi(this,i,this.pluginOptions.extras.syncOpt.interval),this.activePlugin()}destroy(){var i,e,t,n,r,s,a;this.roomMember.destroy(),(i=this.collector)==null||i.destroy(),(e=this.worker)==null||e.destroy(),(t=this.viewContainerManager)==null||t.destroy(),(n=this.cursor)==null||n.destroy(),(r=this.textEditorManager)==null||r.destory(),(s=this.pluginManager)==null||s.destroy(),(a=this.miniMapManager)==null||a.destroyMiniMap()}cleanCurrentScene(){const i=this.worker.now,e=this.worker.getLocalWorkViewId()||this.viewContainerManager.focuedViewId;e&&(rt.InternalMsgEmitter.emit("addUndoTicker",i,e),this.worker.clearViewScenePath(e,!1,!0))}async setWritable(i){var e,t;if(!i){(e=this.cursor)==null||e.unabled(),this.textEditorManager.checkEmptyTextBlur();const n=this.viewContainerManager.getAllViews();for(const r of n){r!=null&&r.focusScenePath&&(t=this.collector)!=null&&t.hasSelector(r.id,r.focusScenePath)&&this.worker.blurSelector(r.id,r.focusScenePath);const s=r==null?void 0:r.displayer;s&&(s.setActive(!1),await s.stopEventHandler())}}await new Promise(n=>{setTimeout(()=>{n()},500)})}onWritableChange(i){var n;i?this.worker.abled():this.worker.unWritable(),((n=this.worker.getCurrentToolsData())==null?void 0:n.toolsType)===T.Text&&this.viewContainerManager.focuedViewId&&(i?this.viewContainerManager.activeTextEditor(this.viewContainerManager.focuedViewId):this.viewContainerManager.unActiveTextEditor(this.viewContainerManager.focuedViewId)),this.renderControl.onWritableChange(i),this.viewContainerManager.getAllViews().forEach(r=>{const s=r==null?void 0:r.displayer;s&&(s.bindToolsClass(),i?s.setActive(!0):s.setActive(!1))})}getToolsKey(i){const e=i.currentApplianceName;switch(this.hasSwitchToSelectorEffect=!1,e){case ee.text:return i.textCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),T.Text;case ee.pencil:return i.useLaserPen?T.LaserPen:T.Pencil;case ee.eraser:return T.Eraser;case ee.pencilEraser:return this.pluginOptions.extras.pencilEraser.useBitMap===!1?T.PencilEraser:T.BitMapEraser;case ee.selector:return T.Selector;case ee.arrow:return i.arrowCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),T.Arrow;case ee.straight:return i.straightCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),T.Straight;case ee.ellipse:return i.ellipseCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),T.Ellipse;case ee.rectangle:return i.rectangleCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),T.Rectangle;case ee.shape:if(i.shapeCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),i.shapeType===Re.Pentagram||i.shapeType===Re.Star)return T.Star;if(i.shapeType===Re.Polygon||i.shapeType===Re.Triangle||i.shapeType===Re.Rhombus)return T.Polygon;if(i.shapeType===Re.SpeechBalloon)return T.SpeechBalloon;break}return T.Clicker}getToolsOpt(i,e){if(i===T.Clicker)return{toolsType:i,toolsOpt:{}};const t={strokeColor:ut(e.strokeColor[0],e.strokeColor[1],e.strokeColor[2],e.strokeOpacity||1),thickness:e.strokeWidth,isOpacity:(e==null?void 0:e.strokeOpacity)&&e.strokeOpacity<1||(e==null?void 0:e.fillOpacity)&&e.fillOpacity<1||(e==null?void 0:e.textOpacity)&&e.textOpacity<1||(e==null?void 0:e.textBgOpacity)&&e.textBgOpacity<1||!1};switch(i){case T.Text:t.fontFamily=window.getComputedStyle(document.documentElement).getPropertyValue("font-family"),t.fontSize=(e==null?void 0:e.textSizeOverride)||(e==null?void 0:e.textSize)||Number(window.getComputedStyle(document.body).fontSize),t.textAlign=(e==null?void 0:e.textAlign)||"left",t.verticalAlign=(e==null?void 0:e.verticalAlign)||"middle",t.fontColor=(e==null?void 0:e.textColor)&&ut(e.textColor[0],e.textColor[1],e.textColor[2],e.textOpacity||1)||t.strokeColor||"rgba(0,0,0,1)",t.fontBgColor=Array.isArray(e==null?void 0:e.textBgColor)&&ut(e.textBgColor[0],e.textBgColor[1],e.textBgColor[2],e.textBgOpacity||1)||"transparent",t.bold=(e==null?void 0:e.bold)&&"bold"||void 0,t.italic=(e==null?void 0:e.italic)&&"italic"||void 0,t.underline=(e==null?void 0:e.underline)||void 0,t.lineThrough=(e==null?void 0:e.lineThrough)||void 0,t.text="",t.strokeColor=void 0;break;case T.Pencil:{const n=(e==null?void 0:e.strokeType)||fe.Normal;t.strokeType=n,t.lineCap=this.getLineCap(n),t.lineDash=this.getLineDash(n);break}case T.PencilEraser:case T.BitMapEraser:case T.Eraser:t.thickness=Math.min(4,Math.max(1,Math.floor(e.pencilEraserSize||1)))-1;break;case T.LaserPen:{t.duration=(e==null?void 0:e.duration)||1,e!=null&&e.strokeType&&(e==null?void 0:e.strokeType)===fe.Stroke?t.strokeType=fe.Normal:t.strokeType=(e==null?void 0:e.strokeType)||fe.Normal;const n=t.strokeType;t.lineCap=this.getLineCap(n),t.lineDash=this.getLineDash(n);break}case T.Arrow:case T.Straight:{e!=null&&e.strokeType&&(e==null?void 0:e.strokeType)===fe.Stroke?t.strokeType=fe.Normal:t.strokeType=(e==null?void 0:e.strokeType)||fe.Normal;const n=t.strokeType;t.strokeType=n,t.lineCap=this.getLineCap(n),t.lineDash=this.getLineDash(n);break}case T.Ellipse:case T.Rectangle:case T.Star:case T.Polygon:case T.SpeechBalloon:{e!=null&&e.strokeType&&(e==null?void 0:e.strokeType)===fe.Stroke?t.strokeType=fe.Normal:t.strokeType=(e==null?void 0:e.strokeType)||fe.Normal;const n=t.strokeType;t.lineCap=this.getLineCap(n),t.lineDash=this.getLineDash(n),i===T.Star&&(e.shapeType===Re.Pentagram?(t.vertices=10,t.innerVerticeStep=2,t.innerRatio=.4):e!=null&&e.vertices&&(e!=null&&e.innerVerticeStep)&&(e!=null&&e.innerRatio)&&(t.vertices=e.vertices,t.innerVerticeStep=e.innerVerticeStep,t.innerRatio=e.innerRatio)),i===T.Polygon&&(e.shapeType===Re.Triangle?t.vertices=3:e.shapeType===Re.Rhombus?t.vertices=4:e.vertices&&(t.vertices=e.vertices)),t.fillColor=(e==null?void 0:e.fillColor)&&ut(e.fillColor[0],e.fillColor[1],e.fillColor[2],e==null?void 0:e.fillOpacity)||"transparent",i===T.SpeechBalloon&&(t.placement=e.placement||"bottomLeft");break}}return{toolsType:i,toolsOpt:t}}getLineCap(i){switch(i){case fe.Normal:return this.pluginOptions.extras.normalStroke.lineCap||we.normalStroke.lineCap;case fe.Dotted:return this.pluginOptions.extras.dottedStroke.lineCap||we.dottedStroke.lineCap;case fe.LongDotted:return this.pluginOptions.extras.longDottedStroke.lineCap||we.longDottedStroke.lineCap;default:return}}getLineDash(i){switch(i){case fe.Normal:return;case fe.Dotted:{const{segment:e,gap:t}=this.pluginOptions.extras.dottedStroke||we.dottedStroke;return[e,t]}case fe.LongDotted:{const{segment:e,gap:t}=this.pluginOptions.extras.longDottedStroke||we.longDottedStroke;return[e,t]}default:return}}effectViewContainer(i){var e,t,n,r,s;if(this.disableDeviceInputs===!0)this.room.disableDeviceInputs=!0,(e=this.worker)==null||e.unWritable(),(t=this.cursor)==null||t.unabled();else switch(i!==T.Text&&this.viewContainerManager.focuedViewId&&this.viewContainerManager.unActiveTextEditor(this.viewContainerManager.focuedViewId),i){case T.Text:case T.Pencil:case T.LaserPen:case T.Arrow:case T.Straight:case T.Rectangle:case T.Ellipse:case T.Star:case T.Polygon:case T.SpeechBalloon:case T.Triangle:case T.Rhombus:case T.Eraser:case T.PencilEraser:case T.BitMapEraser:case T.Selector:this.room.disableDeviceInputs=!0,(n=this.worker)==null||n.abled(),i===T.Text&&this.viewContainerManager.focuedViewId&&this.viewContainerManager.activeTextEditor(this.viewContainerManager.focuedViewId);break;default:this.room.disableDeviceInputs=!1,(r=this.worker)==null||r.unWritable(),(s=this.cursor)==null||s.unabled();break}setTimeout(()=>{this.viewContainerManager.getAllViews().forEach(c=>{c!=null&&c.displayer&&c.displayer.bindToolsClass()})},0)}async getBoundingRect(i){var t,n,r,s,a;const e=await((t=this.worker)==null?void 0:t.getBoundingRect(i));if(e){const c=((r=(n=this.viewContainerManager.mainView)==null?void 0:n.viewData)==null?void 0:r.convertToPointInWorld({x:e.x,y:e.y}))||{x:e.x,y:e.y},l=((a=(s=this.viewContainerManager.mainView)==null?void 0:s.viewData)==null?void 0:a.camera.scale)||1;return{width:Math.floor(e.w/l)+1,height:Math.floor(e.h/l)+1,originX:c.x,originY:c.y}}}async screenshotToCanvas(i,e,t,n,r,s,a){const c=await this.worker.getSnapshot(e,t,n,r);c&&(i.drawImage(c,s||0,a||0),c.close())}async scenePreview(i,e){var s,a,c,l;const t=(s=this.collector)==null?void 0:s.getViewIdBySecenPath(i);if(!t)return;const n=this.viewContainerManager.getView(t);if(!n||!((a=n.cameraOpt)!=null&&a.width)||!((c=n.cameraOpt)!=null&&c.height))return;const r=await((l=this.worker)==null?void 0:l.getSnapshot(i));if(r&&this.worker){const h=document.createElement("canvas"),u=h.getContext("2d"),{width:M,height:p}=n.cameraOpt;h.width=M,h.height=p,u&&(u.drawImage(r,0,0),e.crossOrigin="anonymous",e.src=h.toDataURL(),e.onload=()=>{h.remove()},e.onerror=()=>{h.remove(),e.remove()}),r.close()}}switchToText(){var i;(i=this.room)==null||i.setMemberState({currentApplianceName:ee.text})}switchToSelector(){var i;(i=this.room)==null||i.setMemberState({currentApplianceName:ee.selector})}async runEffectWork(i){if(this.hasSwitchToSelectorEffect){const e=await new Promise(t=>{this.switchToSelector(),this.effectResolve=t});this.effectResolve=void 0,e&&i&&i()}}setSnapshootData(){var i;this.room&&(this.snapshootStateMap=new Map,this.snapshootStateMap.set("memberState",(i=this.room)==null?void 0:i.state.memberState))}getSnapshootData(i){var e;return(e=this.snapshootStateMap)==null?void 0:e.get(i)}clearSnapshootData(){var i;(i=this.snapshootStateMap)==null||i.clear(),this.snapshootStateMap=void 0}useBitMapEraser(i){this.pluginOptions.extras.pencilEraser.useBitMap=i}consoleWorkerInfo(){var i;(i=this.worker)==null||i.consoleWorkerInfo()}filterRenderByUid(i,e,t=!0){var r;this.viewContainerManager.getView(i)&&((r=this.renderControl)==null||r.publishRender({viewId:i,option:e,isSync:t}))}cancelFilterRender(i,e=!0){var t;(t=this.renderControl)==null||t.publishRender({viewId:i,isSync:e})}async createMiniMap(i,e){var n,r,s;if(this.isUseSimple)throw new Error("simple mode not support createMiniMap");const t=await((n=this.miniMapManager)==null?void 0:n.getMiniMapCamera(i));if(t&&await((r=this.miniMapManager)==null?void 0:r.createMiniMap(i,e,t))){const c=(s=this.miniMapManager)==null?void 0:s.getMiniMapCanvas(i);if(c){const l=c.getContext("2d");if(l){const h=this.viewContainerManager.getView(i);h!=null&&h.focusScenePath&&this.screenshotToCanvas(l,h.focusScenePath,t.width,t.height,t)}}}}async destroyMiniMap(i){var e;(e=this.miniMapManager)==null||e.destroyMiniMap(i)}insertIconify(i,e){var n;if(this.viewContainerManager.getView(i)&&this.room){const r=this.room.state.memberState,s=ut(r.strokeColor[0],r.strokeColor[1],r.strokeColor[2],r.strokeOpacity||1);(n=this.worker)==null||n.insertIconify(i,{...e,strokeColor:s})}}usePlugin(i){var e;if(this.isUseSimple)throw new Error("simple mode not support usePlugin");return(e=this.pluginManager)==null?void 0:e.use(i)}async stopDraw(i){var t;const e=this.viewContainerManager.getView(i);e&&await((t=e.displayer)==null?void 0:t.stopEventHandler())}};m(rt,"InternalMsgEmitter",new ci),m(rt,"PublicMsgEmitter",new ci);let Te=rt;const st=class st{constructor(i){m(this,"emitter",new ci);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",x.debounce(()=>{const i=this.control.viewContainerManager.getCurScenePath(this.viewId);if(i){let e=this.undoStack.filter(n=>n.scenePath===i).length;const t=this.redoStack.filter(n=>n.scenePath===i).length;e===0&&t===0&&this.tickStartStorerCache&&this.scenePath===i&&(e=1),this.emitter.emit("onCanUndoStepsUpdate",e),this.emitter.emit("onCanRedoStepsUpdate",t)}},st.waitTime));const{control:e,internalMsgEmitter:t,viewId:n}=i;this.control=e,this.emitter=t,this.undoStack=[],this.redoStack=[],this.room=e.room,this.worker=e.worker,this.isTicking=!1,this.viewId=n}get collector(){return this.control.collector}addExcludeIds(i){if(this.isTicking)for(const e of i)this.excludeIds.add(e)}undoTickerStart(i,e){var t,n;if(this.collector&&(this.undoTickerId!==i||this.scenePath!==e)){!this.undoTickerId&&!this.tickStartStorerCache&&!this.scenePath&&this.emitter.emit("onCanUndoStepsUpdate",1),this.undoTickerId&&this.viewId&&this.scenePath&&this.undoTickerEndSync(this.undoTickerId,this.viewId,this.scenePath),this.isTicking=!0;const r=this.collector.transformKey(Z);this.excludeIds.add(r),this.undoTickerId=i,this.scenePath=e;const s=((t=this.collector)==null?void 0:t.storage[this.viewId])&&((n=this.collector)==null?void 0:n.storage[this.viewId][this.scenePath])||{};this.tickStartStorerCache=new Map(Object.entries(x.cloneDeep(s)))}}undoTickerEndSync(i,e,t,n=!0){var r,s;if(i===this.undoTickerId&&t===this.scenePath&&e===this.viewId&&this.tickStartStorerCache){const a=((r=this.collector)==null?void 0:r.storage[e])&&((s=this.collector)==null?void 0:s.storage[e][t])||{},c=this.diffFun(this.tickStartStorerCache,new Map(Object.entries(a)));c.size&&(this.undoStack.push({id:i,type:2,data:x.cloneDeep(c),scenePath:t}),this.undoStack.length>st.MaxStackLength&&this.undoStack.shift(),n&&this.emitter.emit("onCanUndoStepsUpdate",this.undoStack.length+1)),this.redoStack.length&&(this.redoStack.length=0,this.emitter.emit("onCanRedoStepsUpdate",this.redoStack.length)),this.isTicking=!1,this.scenePath=void 0,this.tickStartStorerCache=void 0,this.undoTickerId=void 0,this.excludeIds.clear()}}undo(i){this.undoTickerId&&this.tickStartStorerCache&&this.scenePath&&this.undoTickerEndSync(this.undoTickerId,this.viewId,this.scenePath,!1);let e=this.undoStack.length-1;for(;e>=0;){if(this.undoStack[e].scenePath===i){const s=this.undoStack[e];s&&(this.redoStack.push(s),s.type===2&&s.data&&this.refreshPlugin(s)),this.undoStack.splice(e,1);break}e--}const t=this.undoStack.filter(r=>r.scenePath===i).length,n=this.redoStack.filter(r=>r.scenePath===i).length;return this.emitter.emit("onCanUndoStepsUpdate",t),this.emitter.emit("onCanRedoStepsUpdate",n),t}redo(i){let e=this.redoStack.length-1;for(;e>=0;){if(this.redoStack[e].scenePath===i){const s=this.redoStack[e];s&&(!this.undoTickerId&&s.tickStartStorerCache?(this.undoTickerId=s.id,this.tickStartStorerCache=s.tickStartStorerCache,this.scenePath=s.scenePath):this.undoStack.push(s),s.type===2&&s.data&&this.refreshPlugin(s,!0)),this.redoStack.splice(e,1);break}e--}const t=this.undoStack.filter(r=>r.scenePath===i).length,n=this.redoStack.filter(r=>r.scenePath===i).length;return this.emitter.emit("onCanUndoStepsUpdate",t),this.emitter.emit("onCanRedoStepsUpdate",n),n}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 i=this.control.viewContainerManager.getCurScenePath(this.viewId);if(i){let e=this.undoStack.filter(n=>n.scenePath===i).length;const t=this.redoStack.filter(n=>n.scenePath===i).length;e===0&&t===0&&this.tickStartStorerCache&&this.scenePath===i&&(e=1),this.emitter.emit("onCanUndoStepsUpdate",e),this.emitter.emit("onCanRedoStepsUpdate",t)}}diffFun(i,e){const t=new Set,n=i.keys(),r=e.keys();for(const s of n){if(this.excludeIds.has(s))continue;const a=i.get(s),c=e.get(s);if(a&&c){if(x.isEqual(c,a))continue;t.add({dataType:3,key:s,data:[a,c]});continue}a&&t.add({dataType:2,key:s,data:a})}for(const s of r){if(this.excludeIds.has(s))continue;const a=e.get(s);a&&!i.has(s)&&t.add({dataType:1,key:s,data:a})}return t}isDrawEffectiveScene(i,e){const{key:t}=i;return!e.includes(t)}isDeleteEffectiveScene(i,e,t){var s;const{key:n}=i;if(!e.includes(n))return!1;const r=e.filter(a=>{var c,l;return((c=this.collector)==null?void 0:c.getLocalId(a))===Z&&!((l=this.collector)!=null&&l.isOwn(a))}).map(a=>{var c;return(c=this.collector)==null?void 0:c.storage[this.viewId][t][a]});for(const a of r)if((s=a==null?void 0:a.selectIds)!=null&&s.includes(n))return!1;return!0}isOldEffectiveScene(i,e,t){var s;const{key:n}=i;if(!e.includes(n))return!1;const r=e.filter(a=>{var c,l;return((c=this.collector)==null?void 0:c.getLocalId(a))===Z&&!((l=this.collector)!=null&&l.isOwn(a))}).map(a=>{var c;return(c=this.collector)==null?void 0:c.storage[this.viewId][t][a]});for(const a of r)if((s=a==null?void 0:a.selectIds)!=null&&s.includes(n))return!1;return!0}isNewEffectiveScene(i,e){const{key:t}=i;return!!e.includes(t)}refreshPlugin(i,e=!1){var a,c,l,h,u,M,p,f,g,y,w,I,v,S,N,C,D,k,P,L,O;let t;const{scenePath:n}=i,r=i.data;if(!r||!this.collector)return;const s=x.cloneDeep(this.collector.storage);for(const E of r.values()){const{dataType:R,data:z,key:V}=E,te=this.collector.getStorageData(this.viewId,n),B=te&&Object.keys(te)||[];switch(R){case 1:if(t=e?this.isDrawEffectiveScene(E,B):this.isDeleteEffectiveScene(E,B,n),t)if(e&&!Array.isArray(z)){if((a=z.updateNodeOpt)!=null&&a.useAnimation&&(z.updateNodeOpt.useAnimation=!1),((c=this.collector)==null?void 0:c.getLocalId(V))===Z&&((l=this.collector)!=null&&l.isOwn(E.key))){const $=z.selectIds;if($){const ie=B.filter(ne=>{var J,H;return((J=this.collector)==null?void 0:J.getLocalId(ne))===Z&&!((H=this.collector)!=null&&H.isOwn(ne))}).map(ne=>{var J;return(J=this.collector)==null?void 0:J.storage[this.viewId][n][ne]});let re=!1;for(const ne of ie)for(let J=0;J<$.length;J++)(h=ne==null?void 0:ne.selectIds)!=null&&h.includes($[J])&&(delete $[J],re=!0);re&&(z.selectIds=$.filter(ne=>!!ne))}}(u=this.collector)==null||u.updateValue(E.key,z,{viewId:this.viewId,scenePath:n,isSync:!0,storage:s})}else!e&&!Array.isArray(E.data)&&((M=this.collector)==null||M.updateValue(E.key,void 0,{viewId:this.viewId,scenePath:n,isSync:!0,storage:s}));break;case 2:if(t=e?this.isDeleteEffectiveScene(E,B,n):this.isDrawEffectiveScene(E,B),t){if(e&&!Array.isArray(z))(p=this.collector)==null||p.updateValue(V,void 0,{viewId:this.viewId,scenePath:n,isSync:!0,storage:s});else if(!e&&!Array.isArray(z)){if((f=z.updateNodeOpt)!=null&&f.useAnimation&&(z.updateNodeOpt.useAnimation=!1),((g=this.collector)==null?void 0:g.getLocalId(E.key))===Z&&((y=this.collector)!=null&&y.isOwn(E.key))){const $=z.selectIds;if($){const ie=B.filter(ne=>{var J,H;return((J=this.collector)==null?void 0:J.getLocalId(ne))===Z&&!((H=this.collector)!=null&&H.isOwn(ne))}).map(ne=>{var J;return(J=this.collector)==null?void 0:J.storage[this.viewId][n][ne]});let re=!1;for(const ne of ie)for(let J=0;J<$.length;J++)(w=ne==null?void 0:ne.selectIds)!=null&&w.includes($[J])&&(delete $[J],re=!0);re&&(z.selectIds=$.filter(ne=>!!ne))}}(I=this.collector)==null||I.updateValue(E.key,E.data,{viewId:this.viewId,scenePath:n,isSync:!0,storage:s})}}break;case 3:if(t=e?this.isNewEffectiveScene(E,B):this.isOldEffectiveScene(E,B,n),t){if(e&&Array.isArray(z)&&z.length===2){const $=z[1];if((v=$.updateNodeOpt)!=null&&v.useAnimation&&($.updateNodeOpt.useAnimation=!1),((S=this.collector)==null?void 0:S.getLocalId(E.key))===Z&&((N=this.collector)!=null&&N.isOwn(E.key))){const ie=$.selectIds;if(ie){const re=B.filter(J=>{var H,le;return((H=this.collector)==null?void 0:H.getLocalId(J))===Z&&!((le=this.collector)!=null&&le.isOwn(J))}).map(J=>{var H;return(H=this.collector)==null?void 0:H.storage[this.viewId][n][J]});let ne=!1;for(const J of re)for(let H=0;H<ie.length;H++)J!=null&&J.selectIds&&((C=J.selectIds)!=null&&C.includes(ie[H]))&&(delete ie[H],ne=!0);ne&&($.selectIds=ie.filter(J=>!!J))}}(D=this.collector)==null||D.updateValue(V,$,{viewId:this.viewId,scenePath:n,isSync:!0,storage:s})}else if(!e&&Array.isArray(z)&&z.length===2){const $=z[0];if((k=$.updateNodeOpt)!=null&&k.useAnimation&&($.updateNodeOpt.useAnimation=!1),((P=this.collector)==null?void 0:P.getLocalId(E.key))===Z&&((L=this.collector)!=null&&L.isOwn(E.key))){const ie=$.selectIds;if(ie){const re=B.filter(J=>{var H,le;return((H=this.collector)==null?void 0:H.getLocalId(J))===Z&&!((le=this.collector)!=null&&le.isOwn(J))}).map(J=>{var H;return(H=this.collector)==null?void 0:H.storage[this.viewId][n][J]});let ne=!1;for(const J of re)for(let H=0;H<ie.length;H++)J!=null&&J.selectIds&&J.selectIds.includes(ie[H])&&(delete ie[H],ne=!0);ne&&($.selectIds=ie.filter(J=>!!J))}}(O=this.collector)==null||O.updateValue(E.key,$,{viewId:this.viewId,scenePath:n,isSync:!0,storage:s})}}break}}}};m(st,"sdkCallBack"),m(st,"MaxStackLength",20),m(st,"waitTime",100);let yi=st;function op(o){return o instanceof TouchEvent||o instanceof window.TouchEvent||(o==null?void 0:o.touches)&&(o==null?void 0:o.touches.length)||(o==null?void 0:o.changedTouches)&&(o==null?void 0:o.changedTouches.length)}function Rt(o){return op(o)&&(o.touches&&o.touches.length===1||o.changedTouches&&o.changedTouches.length===1)}function yo(o){return o.touches&&o.touches.length?{x:o.touches[0].pageX,y:o.touches[0].pageY}:o.changedTouches&&o.changedTouches.length?{x:o.changedTouches[0].pageX,y:o.changedTouches[0].pageY}:{x:o.pageX,y:o.pageY}}class dt{constructor(i){m(this,"internalMsgEmitter");m(this,"control");m(this,"mainView");m(this,"appViews",new Map);m(this,"undoTickerStart",(i,e)=>{const t=this.getView(e);t&&t.displayer&&t.focusScenePath&&t.displayer.commiter.undoTickerStart(i,t.focusScenePath)});m(this,"addExcludeIds",(i,e)=>{const t=this.getView(e);t&&t.displayer&&t.focusScenePath&&t.displayer.commiter.addExcludeIds(i)});const{control:e,internalMsgEmitter:t}=i;this.control=e,this.internalMsgEmitter=t,this.internalMsgEmitter.on("addUndoTicker",this.undoTickerStart),this.internalMsgEmitter.on("excludeIds",this.addExcludeIds)}get worker(){return this.control.worker}undo(){const i=this.focuedView;let e=0;if(i){const t=i.focusScenePath;e=i.displayer.commiter.undo(t)||0}return e}redo(){const i=this.focuedView;let e=0;if(i){const t=i.focusScenePath;e=i.displayer.commiter.redo(t)||0}return e}validator(i,e,t){var s;const n=x.clone(i[e]),r=x.clone(t);e==="focusScenePath"&&t&&!x.isEqual(n,r)&&(this.control.internalSceneChange(i.id,r),(s=this.focuedView)==null||s.displayer.commiter.onChangeScene()),e==="cameraOpt"&&!x.isEqual(n,r)&&this.control.internalCameraChange(i.id,r)}destroyAppView(i,e=!1){const t=this.appViews.get(i);t&&(this.control.textEditorManager.clear(i,e),t.displayer.destroy(),this.appViews.delete(i))}createMianView(i){this.mainView=new Proxy(i,{set:(e,t,n)=>(this.worker.isActive&&this.validator(e,t,n),e[t]=n,!0)})}createAppView(i){const e=i.id,t=new Proxy(i,{set:(n,r,s)=>(this.worker.isActive&&this.validator(n,r,s),n[r]=s,!0)});this.appViews.set(e,t)}isAppView(i){return i!==ue&&this.appViews.has(i)}getView(i){var e;return i===ue?this.mainView:(e=this.appViews)==null?void 0:e.get(i)}getCurScenePath(i){const e=this.getView(i);if(e)return e.focusScenePath}getAllViews(){return[this.mainView,...this.appViews.values()]}setViewScenePath(i,e){var t;if(i===ue&&this.mainView)this.mainView.focusScenePath=e;else{const n=i&&((t=this.appViews)==null?void 0:t.get(i))||void 0;n&&(n.focusScenePath=e)}}setViewData(i,e){var t;if(i===ue&&this.mainView)this.mainView.viewData=e;else{const n=i&&((t=this.appViews)==null?void 0:t.get(i))||void 0;n&&(n.viewData=e)}}setFocuedViewId(i){var e;this.focuedViewId=i,i===ue?this.focuedView=this.mainView:this.focuedView=i&&((e=this.appViews)==null?void 0:e.get(i))||void 0,this.worker.currentToolsData&&this.worker.currentToolsData.toolsType===T.Text&&this.activeTextEditor(i),this.control.cursor.onFocusViewChange(),this.focuedView&&this.focuedView.displayer.commiter.onFocusView()}setViewFocusScenePath(i,e){var n;let t;i===ue?t=this.mainView:t=(n=this.appViews)==null?void 0:n.get(i),t&&(t.focusScenePath=e)}destroy(){var i;this.internalMsgEmitter.off("addUndoTicker",this.undoTickerStart),this.internalMsgEmitter.off("excludeIds",this.addExcludeIds),(i=this.mainView)==null||i.displayer.destroy(),this.control.destroyMiniMap(ue),this.appViews.forEach(e=>{this.destroyAppView(e.id,!0),this.worker.destroyViewWorker(e.id),this.control.destroyMiniMap(e.id)})}setFocuedViewCameraOpt(i){if(this.focuedView){const e=this.focuedView.cameraOpt;x.isEqual(e,i)||(this.focuedView.cameraOpt=i)}}transformToOriginPoint(i,e){const t=this.getView(e);if(t!=null&&t.viewData){const n=t.viewData.convertToPointOnScreen(i[0],i[1]);return[n.x,n.y]}return i}transformToScenePoint(i,e){const t=this.getView(e);if(t!=null&&t.viewData){const n=t.viewData.convertToPointInWorld({x:i[0],y:i[1]});return[n.x,n.y]}return i}render(i){var e,t,n,r,s,a,c,l,h,u,M,p,f,g,y,w,I;for(const v of i){const{rect:S,imageBitmap:N,isClear:C,isUnClose:D,drawCanvas:k,clearCanvas:P,viewId:L}=v,O=(e=this.getView(L))==null?void 0:e.displayer;if(O&&S){const{dpr:E,canvasBgRef:R,canvasFloatRef:z,canvasServiceFloatRef:V,canvasTopRef:te}=O,B=Math.floor(S.w*E),$=Math.floor(S.h*E),ie=S.x*E,re=S.y*E;if(C){switch(P){case He.TopFloat:(n=(t=te==null?void 0:te.current)==null?void 0:t.getContext("2d"))==null||n.clearRect(ie,re,B,$);break;case He.Float:(s=(r=z.current)==null?void 0:r.getContext("2d"))==null||s.clearRect(ie,re,B,$);break;case He.ServiceFloat:(c=(a=V.current)==null?void 0:a.getContext("2d"))==null||c.clearRect(ie,re,B,$);break;case He.Bg:(h=(l=R.current)==null?void 0:l.getContext("2d"))==null||h.clearRect(ie,re,B,$);break}continue}if(k&&N)switch(k){case He.TopFloat:(M=(u=te==null?void 0:te.current)==null?void 0:u.getContext("2d"))==null||M.drawImage(N,0,0,B,$,ie,re,B,$);break;case He.Float:{(f=(p=z.current)==null?void 0:p.getContext("2d"))==null||f.drawImage(N,0,0,B,$,ie,re,B,$);break}case He.ServiceFloat:{(y=(g=V.current)==null?void 0:g.getContext("2d"))==null||y.drawImage(N,0,0,B,$,ie,re,B,$);break}case He.Bg:{(I=(w=R.current)==null?void 0:w.getContext("2d"))==null||I.drawImage(N,0,0,B,$,ie,re,B,$);break}}if(D)continue;N==null||N.close()}}}showFloatBar(i,e,t){const n=this.getView(i),r=n==null?void 0:n.displayer.vDom;r&&r.showFloatBar(e,t)}activeTextEditor(i){const e=this.getView(i),t=e==null?void 0:e.displayer.vDom;t&&t.activeTextEditor()}unActiveTextEditor(i){const e=this.getView(i),t=e==null?void 0:e.displayer.vDom;t&&t.unActiveTextEditor()}showFloatBarBtn(i,e){const t=this.getView(i),n=t==null?void 0:t.displayer.vDom;n&&n.showFloatBarBtn(e)}updateTextEditorInfo(i,e){const t=this.getView(i),n=t==null?void 0:t.displayer.vDom;n&&n.updateTextEditorInfo(e)}setActiveMiniMap(i,e){const t=this.getView(i),n=t==null?void 0:t.displayer.vDom;n&&n.setActiveMiniMap(e&&i||void 0)}}m(dt,"defaultCameraOpt",{centerX:0,centerY:0,scale:1}),m(dt,"defaultScreenCanvasOpt",{autoRender:!1,contextType:"webgl2"}),m(dt,"defaultLayerOpt",{offscreen:!0,handleEvent:!1,depth:!1});class mo{constructor(i,e,t){m(this,"control");m(this,"internalMsgEmitter");m(this,"commiter");m(this,"cachePoint");m(this,"cacheCursorPoint");m(this,"active",!0);m(this,"toolsKey");m(this,"cursorMouseMove");m(this,"cursorMouseMoveDebounced");m(this,"cursorMouseMoveThrottled");m(this,"cursorMouseMoveFun");m(this,"_transferControlToOffscreenCanvas");m(this,"cursorMouseLeave",()=>{this.control.pluginOptions.extras.cursor.enable?this.cursorMouseMoveThrottled.cancel():this.cursorMouseMoveDebounced.cancel(),this.cacheCursorPoint=[void 0,void 0],this.worker.sendCursorEvent(this.cacheCursorPoint,this.viewId)});m(this,"mousedown",i=>{var e;if(this.active&&i.button===0&&this.viewId){this.toolsKey=(e=this.worker.getCurrentToolsData())==null?void 0:e.toolsType,!this.worker.isAbled()&&this.toolsKey&&this.control.effectViewContainer(this.toolsKey),this.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const t=this.getPoint(i);this.cachePoint=t,t&&(this.worker.originalEventLintener(j.Start,t,this.viewId),document.addEventListener("mousemove",this.mousemove,!1),document.addEventListener("mouseleave",this.mouseup,!1),document.addEventListener("mouseup",this.mouseup,!1))}});m(this,"mousemove",i=>{if(this.active&&this.viewId){const e=this.getPoint(i);if(this.cachePoint=e,this.checkConsumeCount())return;e&&this.worker.originalEventLintener(j.Doing,e,this.viewId)}});m(this,"mouseup",i=>{if(this.active&&i.button===0&&this.viewId){const e=this.getPoint(i)||this.cachePoint;e?(this.worker.originalEventLintener(j.Done,e,this.viewId).finally(()=>{document.removeEventListener("mouseleave",this.mouseup,!1),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1)}),this.cachePoint=void 0):(document.removeEventListener("mouseleave",this.mouseup,!1),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1))}});m(this,"touchstart",i=>{var e;if(this.active){if(!Rt(i)){this.worker.unWritable(),this.viewId&&this.worker.removeDrawingWork(this.viewId);return}if(this.viewId){this.toolsKey=(e=this.worker.getCurrentToolsData())==null?void 0:e.toolsType,!this.worker.isAbled()&&this.toolsKey&&this.control.effectViewContainer(this.toolsKey),this.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const t=this.getPoint(i);this.cachePoint=t,t&&(this.worker.originalEventLintener(j.Start,t,this.viewId),document.addEventListener("touchmove",this.touchmove,!1),document.addEventListener("touchend",this.touchend,!1))}}});m(this,"touchmove",i=>{if(this.active){if(!Rt(i)){this.worker.unWritable(),this.worker.removeDrawingWork(this.viewId);return}if(this.viewId){const e=this.getPoint(i);if(this.cachePoint=e,this.checkConsumeCount())return;e&&this.worker.originalEventLintener(j.Doing,e,this.viewId)}}});m(this,"touchend",i=>{if(this.active){if(!Rt(i)||!this.worker.isAbled()){this.worker.unWritable(),this.worker.removeDrawingWork(this.viewId);return}if(this.viewId){const e=this.getPoint(i)||this.cachePoint;e?(this.worker.originalEventLintener(j.Done,e,this.viewId).finally(()=>{document.removeEventListener("touchmove",this.touchmove,!1),document.removeEventListener("touchend",this.touchend,!1)}),this.cachePoint=void 0):(document.removeEventListener("touchmove",this.touchmove,!1),document.removeEventListener("touchend",this.touchend,!1))}}});m(this,"keydown",i=>{this.control.hotkeyManager.colloctHotkey(i)});this.control=i,this.internalMsgEmitter=e;const n={control:this.control,internalMsgEmitter:this.internalMsgEmitter,viewId:t};this.commiter=new yi(n),this.cursorMouseMoveFun=r=>{const s=this.getPoint(r);this.cacheCursorPoint&&x.isEqual(s,this.cacheCursorPoint)||(this.cacheCursorPoint=s,s&&this.worker.sendCursorEvent(s,this.viewId))},this.cursorMouseMoveDebounced=x.debounce(this.cursorMouseMoveFun,this.moveDelayTime,{trailing:!0}),this.cursorMouseMoveThrottled=x.throttle(this.cursorMouseMoveFun,this.moveDelayTime,{leading:!0}),this.cursorMouseMove=r=>{this.control.pluginOptions.extras.cursor.enable?this.cursorMouseMoveThrottled(r):this.cursorMouseMoveDebounced(r)}}get moveDelayTime(){var i,e;return((e=(i=this.control.pluginOptions.extras)==null?void 0:i.cursor)==null?void 0:e.moveDelayTime)??we.cursor.moveDelayTime}setTransferControlToOffscreenCanvas(i){this._transferControlToOffscreenCanvas={bgCanvas:i.bgCanvas.transferControlToOffscreen(),serviceCanvas:i.serviceCanvas.transferControlToOffscreen(),localCanvas:i.localCanvas.transferControlToOffscreen()}}get transferControlToOffscreenCanvas(){return this._transferControlToOffscreenCanvas}get worker(){return this.control.worker}bindToolsClass(){var n,r;const i=(r=(n=this.worker)==null?void 0:n.currentToolsData)==null?void 0:r.toolsType,e=this.control.renderControl.isWritable,t=this.worker.isAbled();switch(i){case T.Text:case T.Pencil:case T.LaserPen:case T.Arrow:case T.Straight:case T.Rectangle:case T.Ellipse:case T.Star:case T.Polygon:case T.SpeechBalloon:case T.Eraser:case T.PencilEraser:case T.BitMapEraser:case T.Selector:this.eventTragetElement&&(this.eventTragetElement.className=e&&t?`netless-whiteboard ${i===T.Selector?"cursor-selector":i===T.Text?"cursor-text":i===T.Eraser||i===T.PencilEraser||i===T.BitMapEraser?"cursor-eraser":i===T.Pencil||i===T.LaserPen?"cursor-pencil":"cursor-arrow"}`:"netless-whiteboard");break}}mountView(){this.setCanvassStyle(),this.control.viewContainerManager.mountView(this.viewId)}updateSize(){this.setCanvassStyle(),this.reflashContainerOffset()}reflashContainerOffset(){this.eventTragetElement&&(this.containerOffset=this.getContainerOffset(this.eventTragetElement,{x:0,y:0}))}get parentElement(){var i;return(i=this.eventTragetElement)==null?void 0:i.parentElement}destroy(){this.eventTragetElement&&this.removeDisplayerEvent(this.eventTragetElement),this.vDom=void 0,this.control.cursor.clearViewCursor(this.viewId),this.internalMsgEmitter.removeAllListeners([_.Cursor,this.viewId])}getPoint(i){const e=yo(i);if(e&&x.isNumber(e.x)&&x.isNumber(e.y))return[e.x-this.containerOffset.x,e.y-this.containerOffset.y]}getActive(){return this.active}setActive(i){this.active=i}focusElement(){var i;(i=this.eventTragetElement)==null||i.focus()}async stopEventHandler(){this.cachePoint&&(await this.worker.originalEventLintener(j.Done,this.cachePoint,this.viewId).finally(()=>{document.removeEventListener("mouseleave",this.mouseup,!1),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1),document.removeEventListener("touchmove",this.touchmove,!1),document.removeEventListener("touchend",this.touchend,!1)}),this.cachePoint=void 0)}getTranslate(i){const t=(i.style.WebkitTransform||getComputedStyle(i,"").getPropertyValue("-webkit-transform")||i.style.transform||getComputedStyle(i,"").getPropertyValue("transform")).match(/-?[0-9]+\.?[0-9]*/g),n=t&&parseInt(t[0])||0,r=t&&parseInt(t[1])||0;return[n,r]}getContainerOffset(i,e){var r;const t=this.getTranslate(i);let n={x:e.x+i.offsetLeft-i.scrollLeft+t[0],y:e.y+i.offsetTop-i.scrollTop+t[1]};return(r=i.offsetParent)!=null&&r.nodeName&&i.offsetParent.nodeName!=="BODY"&&(n=this.getContainerOffset(i.offsetParent,n)),n}bindDisplayerEvent(i){i.addEventListener("mousedown",this.mousedown,!1),i.addEventListener("touchstart",this.touchstart,!1),i.addEventListener("mousemove",this.cursorMouseMove,!1),i.addEventListener("mouseleave",this.cursorMouseLeave,!1),i.addEventListener("keydown",this.keydown,!0)}removeDisplayerEvent(i){i.removeEventListener("mousedown",this.mousedown,!1),i.removeEventListener("touchstart",this.touchstart,!1),document.removeEventListener("mouseleave",this.mouseup,!1),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1),document.removeEventListener("touchmove",this.touchmove,!1),document.removeEventListener("touchend",this.touchend,!1),i.removeEventListener("mousemove",this.cursorMouseMove,!1),i.removeEventListener("mouseleave",this.cursorMouseLeave,!1),i.removeEventListener("keydown",this.keydown,!0)}get isBezier(){return this.control.pluginOptions.extras.bezier.enable}get maxDrawCount(){return this.control.pluginOptions.extras.bezier.maxDrawCount||we.bezier.maxDrawCount}checkConsumeCount(){const i=this.worker.getConsumeCount();return this.cachePoint&&this.toolsKey&&this.toolsKey===T.Pencil&&i>this.maxDrawCount?(this.stopEventHandler().finally(()=>{this.worker.publicMsgEmitter.emit("forceStop",Ti.longPencil,this.viewId)}),!0):!1}}class rp extends mo{constructor(e,t,n){super(t,n,e);m(this,"_viewId");this._viewId=e}get viewId(){return this._viewId}setViewId(e){this._viewId=e}}class Io extends mo{constructor(i,e){super(i,e,ue)}get viewId(){return ue}updateSize(){this.setCanvassStyle()}destroy(){super.destroy(),this.control.cursor.destroy()}}const sp="index-module__Container__nLsM3",ap="index-module__CanvasBox__j2Xe-",cp="index-module__FloatCanvas__d1YR7",lp="index-module__TopFloatCanvas__7IaCw",up="index-module__CanvasBoxSub__hcMeK",hp="index-module__SnapshotBox__--eeE",dp="index-module__FloatBar__cm-EL",gp="index-module__RotateBtn__HSSkf",Mp="index-module__ResizeBtn__yjvda",fp="index-module__CursorBox__2UHvI",pp="index-module__TextEditorContainer__Qm8KC",yp="index-module__ResizeTowBox__HOllX",mp="index-module__FloatBarBtn__FJrOG",xe={Container:sp,CanvasBox:ap,FloatCanvas:cp,TopFloatCanvas:lp,CanvasBoxSub:up,SnapshotBox:hp,FloatBar:dp,RotateBtn:gp,ResizeBtn:Mp,CursorBox:fp,TextEditorContainer:pp,ResizeTowBox:yp,FloatBarBtn:mp},Ip={delete:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDZ2NmEyIDIgMCAwIDEtMiAySDZhMiAyIDAgMCAxLTItMlY2aDBtMS0yYTIgMiAwIDAgMSAyLTJoMmEyIDIgMCAwIDEgMiAyaDBNMyA0aDEwIiBzdHJva2U9IiM0NDRFNjAiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2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1bGU9Im5vbnplcm8iLz48L2c+PC9zdmc+","font-colors-active":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0ibTQgMTEgNC05IDQgOU02IDdoNCIgc3Ryb2tlPSIjMzM4MUZGIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=","font-colors":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0ibTQgMTEgNC05IDQgOU02IDdoNCIgc3Ryb2tlPSIjNDQ0RTYwIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=","to-bottom":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDEwdjhtMCAwLTItMm0yIDIgMi0ybS00IDZoMTJtLTYtNGg2bS02LTRoNm0tNi00aDYiIHN0cm9rZT0iIzQ0NEU2MCIgZmlsbD0ibm9uZSIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+PC9zdmc+","to-top":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDIydi04bTAgMC0yIDJtMi0yIDIgMm0tNC02aDEybS02IDRoNm0tNiA0aDZtLTYgNGg2IiBzdHJva2U9IiM0NDRFNjAiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==","bold-active":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTQuNSAySDhhMi41IDIuNSAwIDAgMSAwIDVINS41aDBtLTEgMGg0YTMgMyAwIDAgMSAwIDZoLTQgMG0wIDFWMiIgc3Ryb2tlPSIjMzM4MUZGIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=",bold:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTQuNSAySDhhMi41IDIuNSAwIDAgMSAwIDVINS41aDBtLTEgMGg0YTMgMyAwIDAgMSAwIDZoLTQgMG0wIDFWMiIgc3Ryb2tlPSIjNDQ0RTYwIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=","underline-active":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDJ2NWE0IDQgMCAxIDEtOCAwVjJoME0zIDE0aDEwIiBzdHJva2U9IiMzMzgxRkYiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==",underline:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRw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gc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==","italic-active":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTcgMTQgOSAyTTUgMTRoNE03IDJoNCIgc3Ryb2tlPSIjMzM4MUZGIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=",italic:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTcgMTQgOSAyTTUgMTRoNE03IDJoNCIgc3Ryb2tlPSIjNDQ0RTYwIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=","unlock-new":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48Y2lyY2xlIGZpbGw9IiMzMzgxRkYiIGN4PSIxNiIgY3k9IjE3IiByPSIxIi8+PHJlY3Qgc3Ryb2tlPSIjMzM4MUZGIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHg9IjExIiB5PSIxNCIgd2lkdGg9IjEwIiBoZWlnaHQ9IjgiIHJ4PSIyIi8+PHBhdGggZD0iTTEzIDE0di0xYTMgMyAwIDAgMSA2IDB2MWgwbS0zIDN2MyIgc3Ryb2tlPSIjMzM4MUZGIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0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NjcgMTM4LjY2NjY2NyAwIDAgMC0xMzguNjY2NjY2IDEzOC42NjY2NjZoNjR6TTIxMy4zMzMzMzMgNzE0LjY2NjY2N2M0MS4yMTYgMCA3NC42NjY2NjcgMzMuNDUwNjY3IDc0LjY2NjY2NyA3NC42NjY2NjZoNjRBMTM4LjY2NjY2NyAxMzguNjY2NjY3IDAgMCAwIDIxMy4zMzMzMzMgNjUwLjY2NjY2N3Y2NHogbTc0LjY2NjY2NyA3NC42NjY2NjZBNzQuNjY2NjY3IDc0LjY2NjY2NyAwIDAgMSAyMTMuMzMzMzMzIDg2NHY2NGExMzguNjY2NjY3IDEzOC42NjY2NjcgMCAwIDAgMTM4LjY2NjY2Ny0xMzguNjY2NjY3aC02NHpNMjEzLjMzMzMzMyA4NjRhNzQuNjY2NjY3IDc0LjY2NjY2NyAwIDAgMS03NC42NjY2NjYtNzQuNjY2NjY3aC02NEExMzguNjY2NjY3IDEzOC42NjY2NjcgMCAwIDAgMjEzLjMzMzMzMyA5Mjh2LTY0ek0yNDUuMzMzMzMzIDY4Mi42NjY2Njd2LTIzNC42NjY2NjdoLTY0VjY4Mi42NjY2NjdoNjR6IG0tNTQuNjEzMzMzLTIxMi4wNTMzMzRsODUuMzMzMzMzIDg1LjMzMzMzNCA0NS4yMjY2NjctNDUuMjI2NjY3LTg1LjMzMzMzMy04NS4zMzMzMzMtNDUuMjI2NjY3IDQ1LjIyNjY2NnogbTAtNDUuMjI2NjY2bC04NS4zMzMzMzMgODUuMzMzMzMzIDQ1LjIyNjY2NiA0NS4yMjY2NjcgODUuMzMzMzM0LTg1LjMzMzMzNC00NS4yMjY2NjctNDUuMjI2NjY2eiIgIGZpbGw9IiM0NDRFNjAiPjwvcGF0aD48L3N2Zz4="};function Se(o){return Ip[o]}const wp=o=>{const{workIds:i,mananger:e}=o;return d.createElement("div",{className:"button normal-button",style:{touchAction:"none"},onPointerUp:t=>{t.cancelable&&t.preventDefault(),t.stopPropagation(),t.nativeEvent.stopImmediatePropagation(),oe.emitMethod(_.MainEngine,U.DeleteNode,{workIds:i||[Z],viewId:e.viewId})}},d.createElement("img",{alt:"icon",src:Se("delete")}))},Np=o=>{const{workIds:i,viewId:e}=o;return d.createElement("div",{className:"button normal-button",onPointerUp:t=>{t.stopPropagation(),oe.emitMethod(_.MainEngine,U.CopyNode,{workIds:i||[Z],viewId:e})}},d.createElement("img",{alt:"icon",src:Se("duplicate")}))},Cn=o=>{const{icon:i,onPointerUpHandler:e}=o;return d.createElement("div",{className:"button normal-button",onPointerUp:e},d.createElement("img",{src:Se(i)}))},Tp=o=>{const{open:i,setOpen:e,floatBarRef:t}=o,{floatBarData:n,mananger:r}=d.useContext(me),[s,a]=d.useState([]),c=d.useMemo(()=>{if(t!=null&&t.current&&x.isNumber(n==null?void 0:n.y)&&(r!=null&&r.height)){if(t.current.offsetTop&&t.current.offsetTop+n.y>180){const u={};return u.top="inherit",u.bottom=50,u}else if(!t.current.offsetTop&&(r==null?void 0:r.height)-t.current.offsetTop-n.y<120){const u={};return u.top="inherit",u.bottom=50,u}}},[t==null?void 0:t.current,n,r]),l=d.useMemo(()=>i?d.createElement("div",{className:"image-layer-menu",style:c},d.createElement(Cn,{icon:"to-top",onPointerUpHandler:u=>{u.stopPropagation(),oe.emitMethod(_.MainEngine,U.ZIndexNode,{workIds:[Z],layer:Dt.Top,viewId:r==null?void 0:r.viewId})}}),d.createElement(Cn,{icon:"to-bottom",onPointerUpHandler:u=>{u.stopPropagation(),oe.emitMethod(_.MainEngine,U.ZIndexNode,{workIds:[Z],layer:Dt.Bottom,viewId:r==null?void 0:r.viewId})}})):null,[i,c]),h=u=>{u.stopPropagation(),u.nativeEvent.stopImmediatePropagation(),e(!i)};return d.useEffect(()=>{x.isEqual(n==null?void 0:n.selectIds,s)||n!=null&&n.selectIds&&!x.isEqual(n==null?void 0:n.selectIds,s)&&(a(n==null?void 0:n.selectIds),e(!1))},[i,n,s,e]),d.createElement("div",{className:`button normal-button ${i&&"active"}`,onPointerUp:h},l,d.createElement("img",{alt:"icon",src:Se(i?"layer-pressed":"layer")}))},kt=o=>{o.stopPropagation(),o.nativeEvent.stopImmediatePropagation()},vp=()=>d.createElement("svg",{style:{marginLeft:"2px"},viewBox:"0 0 1025 1024",width:"14",height:"14"},d.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"})),wo=o=>{const{activeColor:i,onPointerUpHandler:e}=o;return d.createElement("div",{className:`font-color-button ${i==="transparent"?"active":""}`,onPointerUp:e},d.createElement("div",{className:"circle none"}))},ei=o=>{const{color:i,activeColor:e,onPointerUpHandler:t}=o;return d.createElement("div",{className:`font-color-button ${i===e?"active":""}`,onPointerUp:t},d.createElement("div",{className:"circle",style:{backgroundColor:ve(i,1)}}))},ti=o=>{const{opacity:i,activeColor:e,setCurOpacity:t}=o,[n,r]=d.useState({x:108,y:0}),s=d.useRef(0);if(d.useEffect(()=>{r({x:i*100+8,y:0})},[]),!e)return null;const a=(u,M)=>{const p=Math.min(Math.max(u-8,0),100)/100;(i!==p||M===j.Done)&&t(p,e,M)},c=(u,M)=>{M.x!==(n==null?void 0:n.x)&&r({x:M.x,y:0}),!s.current&&(s.current=setTimeout(()=>{s.current=0,a(M.x,j.Doing)},100))},l=()=>{t(i,e,j.Start)},h=(u,M)=>{M.x!==(n==null?void 0:n.x)&&r({x:M.x,y:0}),s.current&&(clearTimeout(s.current),s.current=0),a(M.x,j.Done)};return d.createElement("div",{className:"font-color-opacity",style:{marginLeft:"10px"},onPointerUp:u=>{s.current&&(clearTimeout(s.current),s.current=0);const M=u.nativeEvent.offsetX,p=Math.min(Math.max(M-12,0),100)/100;r({x:p*100+8,y:0}),t(p,e,j.Done)}},d.createElement("div",{className:"range-color",style:{background:`linear-gradient(to right, ${ve(e,0)}, ${ve(e,1)})`}}),d.createElement("div",{className:"range-opacity"},d.createElement(Mt,{bounds:"parent",axis:"x",position:n,onDrag:c,onStart:l,onStop:h},d.createElement("div",{className:"circle",style:{backgroundColor:ve(e,i)},onPointerUp:kt}))))},Cp=o=>{const{min:i,max:e,activeNumber:t,setActiveNumber:n,color:r}=o,[s,a]=d.useState({x:108,y:0}),c=d.useRef(0);if(d.useEffect(()=>{const p=Math.ceil((t-i)/(e-i)*100)+8;a({x:p,y:0})},[]),!t)return null;const l=(p,f)=>{const g=Math.ceil(Math.max(p-8,0)/100*(e-i)+i);(t!==g||f===j.Done)&&n(g,f)},h=(p,f)=>{f.x!==(s==null?void 0:s.x)&&a({x:f.x,y:0}),!c.current&&(c.current=setTimeout(()=>{c.current=0,l(f.x,j.Doing)},100))},u=()=>{n(t,j.Start)},M=(p,f)=>{f.x!==(s==null?void 0:s.x)&&a({x:f.x,y:0}),c.current&&(clearTimeout(c.current),c.current=0),l(f.x,j.Done)};return d.createElement("div",{className:"font-color-opacity",style:{marginLeft:"10px"},onPointerUp:p=>{c.current&&(clearTimeout(c.current),c.current=0);const f=p.nativeEvent.offsetX,g=Math.ceil(Math.max(f-12,0)/100*(e-i)+i),y=Math.ceil((g-i)/(e-i)*100)+8;a({x:y,y:0}),n(g,j.Done)}},d.createElement("div",{className:"range-color",style:{backgroundColor:r}}),d.createElement("div",{className:"range-opacity"},d.createElement(Mt,{bounds:"parent",axis:"x",position:s,onDrag:h,onStart:u,onStop:M},d.createElement("div",{className:"circle",style:{backgroundColor:r},onPointerUp:kt},d.createElement("div",{className:"range-opacity-data-icon"},t)))))},Sp=o=>{const{useStroke:i,color:e,activeStrokeType:t,setStrokeType:n}=o;return d.createElement("div",{className:"stroke-type-box"},!!i&&d.createElement("div",{className:`stroke-type-box-item Stroke ${t===fe.Stroke&&"active"}`,style:{backgroundColor:e},onPointerUp:()=>{n(fe.Stroke)}}),d.createElement("div",{className:`stroke-type-box-item Normal ${t===fe.Normal&&"active"}`,style:{borderColor:e},onPointerUp:()=>{n(fe.Normal)}}),d.createElement("div",{className:`stroke-type-box-item Dotted ${t===fe.Dotted&&"active"}`,style:{borderColor:e},onPointerUp:()=>{n(fe.Dotted)}}),d.createElement("div",{className:`stroke-type-box-item LongDotted ${t===fe.LongDotted&&"active"}`,style:{borderColor:e},onPointerUp:()=>{n(fe.LongDotted)}}))},jp=o=>{const{open:i,setOpen:e,floatBarRef:t}=o,{floatBarData:n,floatBarColors:r,mananger:s,setFloatBarData:a}=d.useContext(me),[c,l]=d.useState(),[h,u]=d.useState(1);d.useEffect(()=>{if(n!=null&&n.strokeColor){const[I,v]=_t(n.strokeColor);l(I),u(v)}},[n]);const M=d.useMemo(()=>{if(t!=null&&t.current&&n&&x.isNumber(n==null?void 0:n.y)&&(s!=null&&s.height)){if(t.current.offsetTop&&t.current.offsetTop+n.y>180){const I={};return I.top="inherit",I.bottom=50,I}else if(!t.current.offsetTop&&(s==null?void 0:s.height)-t.current.offsetTop-n.y<120){const I={};return I.top="inherit",I.bottom=50,I}}},[n,t,s==null?void 0:s.height]),p=d.useMemo(()=>d.createElement(ti,{key:"strokeColors",opacity:h,activeColor:c,setCurOpacity:(I,v,S)=>{u(I);const N=ve(v,I);n!=null&&n.strokeColor&&a({strokeColor:N}),oe.emitMethod(_.MainEngine,U.SetColorNode,{workIds:[Z],strokeColor:N,workState:S,viewId:s==null?void 0:s.viewId})}}),[h,c,n==null?void 0:n.strokeColor,s==null?void 0:s.viewId,a]),f=d.useMemo(()=>c&&n&&n.thickness?d.createElement(Cp,{key:"strokeThickness",min:Math.min(n.thickness,(s==null?void 0:s.control.pluginOptions.extras.strokeWidth.min)||we.strokeWidth.min),max:Math.max(n.thickness,(s==null?void 0:s.control.pluginOptions.extras.strokeWidth.max)||we.strokeWidth.max),activeNumber:n.thickness,setActiveNumber:(I,v)=>{n!=null&&n.thickness&&a({thickness:I}),oe.emitMethod(_.MainEngine,U.SetColorNode,{workIds:[Z],thickness:I,workState:v,viewId:s==null?void 0:s.viewId})},color:c}):null,[c,n,s==null?void 0:s.control.pluginOptions.extras.strokeWidth.max,s==null?void 0:s.control.pluginOptions.extras.strokeWidth.min,s==null?void 0:s.viewId,a]),g=d.useMemo(()=>c&&n&&(n!=null&&n.strokeType)?d.createElement(Sp,{key:"strokeType",useStroke:n==null?void 0:n.useStroke,activeStrokeType:n.strokeType,setStrokeType:I=>{n.strokeType&&a({strokeType:I}),oe.emitMethod(_.MainEngine,U.SetColorNode,{workIds:[Z],strokeType:I,workState:j.Done,viewId:s==null?void 0:s.viewId})},color:c}):null,[c,n,s==null?void 0:s.viewId,a]),y=d.useMemo(()=>i?d.createElement("div",{className:"font-colors-menu",style:M,onPointerUp:I=>{I.stopPropagation(),I.nativeEvent.stopImmediatePropagation()}},g,f,d.createElement("div",{className:"font-colors-line"}),r.concat().map((I,v)=>{const S=Et(...I);return d.createElement(ei,{key:v,color:S,activeColor:c,onPointerUpHandler:N=>{N.stopPropagation(),l(S);const C=ve(S,h);n!=null&&n.strokeColor&&(n.strokeColor=C,a({strokeColor:C})),oe.emitMethod(_.MainEngine,U.SetColorNode,{workIds:[Z],workState:j.Done,strokeColor:C,viewId:s==null?void 0:s.viewId})}})}),p):null,[i,M,g,f,r,p,c,h,n,s==null?void 0:s.viewId,a]),w=d.useMemo(()=>c?d.createElement("div",{className:"color-bar-ring",style:{backgroundColor:ve(c,h)}},d.createElement("div",{className:"circle"})):null,[c,h]);return d.createElement("div",{className:`button normal-button font-colors-icon ${i&&"active"}`,onPointerUp:I=>{I.stopPropagation(),I.nativeEvent.stopImmediatePropagation(),e(!i)}},w,y)},Dp=o=>{const{open:i,setOpen:e,floatBarRef:t}=o,{floatBarData:n,floatBarColors:r,mananger:s,setFloatBarData:a}=d.useContext(me),[c,l]=d.useState(),[h,u]=d.useState(1);d.useEffect(()=>{if(n!=null&&n.fillColor){const[y,w]=(n==null?void 0:n.fillColor)==="transparent"&&["transparent",1]||_t(n.fillColor);l(y),u(w)}},[n]);const M=d.useMemo(()=>{if(t!=null&&t.current&&x.isNumber(n==null?void 0:n.y)&&(s!=null&&s.height)){if(t.current.offsetTop&&t.current.offsetTop+n.y>200){const y={};return y.top="inherit",y.bottom=50,y}else if(!t.current.offsetTop&&(s==null?void 0:s.height)-t.current.offsetTop-n.y<140){const y={};return y.top="inherit",y.bottom=50,y}}},[t,n,s==null?void 0:s.height]),p=d.useMemo(()=>c&&c!=="transparent"?d.createElement(ti,{key:"fillColors",opacity:h||0,activeColor:c,setCurOpacity:(y,w,I)=>{u(y);const v=ve(w,y);n!=null&&n.fillColor&&(n.fillColor=v,a({fillColor:v})),oe.emitMethod(_.MainEngine,U.SetColorNode,{workIds:[Z],fillColor:c&&ve(w,y),workState:I,viewId:s==null?void 0:s.viewId})}}):null,[c,h,n,s==null?void 0:s.viewId,a]),f=d.useMemo(()=>i?d.createElement("div",{className:"font-colors-menu",style:M,onPointerUp:y=>{y.stopPropagation(),y.nativeEvent.stopImmediatePropagation()}},d.createElement(wo,{activeColor:c,onPointerUpHandler:y=>{y.stopPropagation(),l("transparent");const w="transparent";n!=null&&n.fillColor&&(n.fillColor=w,a({fillColor:w})),oe.emitMethod(_.MainEngine,U.SetColorNode,{workIds:[Z],workState:j.Done,fillColor:w,viewId:s==null?void 0:s.viewId})}}),r.map((y,w)=>{const I=Et(...y);return d.createElement(ei,{key:w,color:I,activeColor:c,onPointerUpHandler:v=>{v.cancelable&&v.preventDefault(),v.stopPropagation(),l(I);const S=ve(I,h);n!=null&&n.fillColor&&(n.fillColor=S,a({fillColor:S})),oe.emitMethod(_.MainEngine,U.SetColorNode,{workIds:[Z],workState:j.Done,fillColor:S,viewId:s==null?void 0:s.viewId})}})}),p):null,[i,M,c,r,p,n,s==null?void 0:s.viewId,a,h]),g=d.useMemo(()=>{const y=c&&c!=="transparent"&&ve(c,h)||"transparent";return d.createElement("div",{className:"color-bar-fill"},d.createElement("div",{className:"circle",style:{backgroundColor:y}}))},[c,h]);return d.createElement("div",{className:`button normal-button font-colors-icon ${i&&"active"}`,onPointerUp:y=>{y.stopPropagation(),y.nativeEvent.stopImmediatePropagation(),e(!i)}},g,f)},xp=o=>{const{open:i,setOpen:e,textOpt:t,workIds:n,floatBarRef:r}=o,{floatBarColors:s,mananger:a,setFloatBarData:c,floatBarData:l}=d.useContext(me),[h,u]=d.useState(),[M,p]=d.useState(1);d.useEffect(()=>{if(t!=null&&t.fontColor){const[I,v]=(t==null?void 0:t.fontColor)==="transparent"&&["transparent",0]||_t(t.fontColor);u(I),p(v)}},[t==null?void 0:t.fontColor]);const f=d.useMemo(()=>{if(r!=null&&r.current&&l&&x.isNumber(l==null?void 0:l.y)&&(a!=null&&a.height)){if(r.current.offsetTop&&r.current.offsetTop+l.y>180){const I={};return I.top="inherit",I.bottom=50,I}else if(!r.current.offsetTop&&(a==null?void 0:a.height)-r.current.offsetTop-l.y<120){const I={};return I.top="inherit",I.bottom=50,I}}},[r,l,a==null?void 0:a.height]),g=d.useMemo(()=>h&&h!=="transparent"?d.createElement(ti,{key:"fontColors",opacity:M,activeColor:h,setCurOpacity:(I,v,S)=>{p(I);const N=ve(v,I);l!=null&&l.textOpt&&(l.textOpt.fontColor=N,c({textOpt:l.textOpt})),oe.emitMethod(_.MainEngine,U.SetColorNode,{workIds:n||[Z],fontColor:h&&N,workState:S,viewId:a==null?void 0:a.viewId})}}):null,[c,h,M,a==null?void 0:a.control.room,a==null?void 0:a.viewId,l==null?void 0:l.textOpt,n]),y=d.useMemo(()=>i?d.createElement("div",{className:"font-colors-menu",style:f,onPointerUp:I=>{I.stopPropagation(),I.nativeEvent.stopImmediatePropagation()}},s.map((I,v)=>{const S=Et(...I);return d.createElement(ei,{key:v,color:S,activeColor:h,onPointerUpHandler:N=>{N.stopPropagation(),u(S);const C=ve(S,M);l!=null&&l.textOpt&&(l.textOpt.fontColor=C,c({textOpt:l.textOpt})),oe.emitMethod(_.MainEngine,U.SetColorNode,{workIds:n||[Z],workState:j.Done,fontColor:C,viewId:a==null?void 0:a.viewId})}})}),g):null,[c,i,s,g,h,M,l==null?void 0:l.textOpt,n,a==null?void 0:a.viewId,f]),w=d.useMemo(()=>{const I=h&&h!=="transparent"&&ve(h,M)||"transparent";return d.createElement("div",{className:"color-bar"},d.createElement("div",{className:"color-bar-color",style:{backgroundColor:I}}))},[h,M]);return d.createElement("div",{className:`button normal-button font-colors-icon ${i&&"active"}`,onPointerUp:I=>{I.stopPropagation(),I.nativeEvent.stopImmediatePropagation(),e(!i)}},d.createElement("img",{alt:"icon",src:Se("font-colors")}),w,y)},zp=o=>{const{open:i,setOpen:e,textOpt:t,workIds:n,floatBarRef:r}=o,{floatBarColors:s,mananger:a,setFloatBarData:c,floatBarData:l}=d.useContext(me),[h,u]=d.useState(),[M,p]=d.useState(1);d.useEffect(()=>{if(t!=null&&t.fontBgColor){const[I,v]=(t==null?void 0:t.fontBgColor)==="transparent"&&["transparent",1]||_t(t.fontBgColor);u(I),p(v)}},[t==null?void 0:t.fontBgColor]);const f=d.useMemo(()=>{if(r!=null&&r.current&&l&&x.isNumber(l==null?void 0:l.y)&&(a!=null&&a.height)){if(r.current.offsetTop&&r.current.offsetTop+l.y>180){const I={};return I.top="inherit",I.bottom=50,I}else if(!r.current.offsetTop&&(a==null?void 0:a.height)-r.current.offsetTop-l.y<120){const I={};return I.top="inherit",I.bottom=50,I}}},[r,l,a==null?void 0:a.height]),g=d.useMemo(()=>h&&h!=="transparent"?d.createElement(ti,{key:"fontBgColor",opacity:M||0,activeColor:h,setCurOpacity:(I,v,S)=>{p(I);const N=ve(v,I);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=N,c({textOpt:l.textOpt})),oe.emitMethod(_.MainEngine,U.SetColorNode,{workIds:n||[Z],fontBgColor:h&&ve(v,I),workState:S,viewId:a==null?void 0:a.viewId})}}):null,[h,M,l==null?void 0:l.textOpt,n,a==null?void 0:a.viewId,c]),y=d.useMemo(()=>i?d.createElement("div",{className:"font-colors-menu",style:f,onPointerUp:I=>{I.stopPropagation(),I.nativeEvent.stopImmediatePropagation()}},d.createElement(wo,{activeColor:h,onPointerUpHandler:I=>{I.stopPropagation();const v="transparent";u(v),l!=null&&l.textOpt&&(l.textOpt.fontBgColor=v,c({textOpt:l.textOpt})),oe.emitMethod(_.MainEngine,U.SetColorNode,{workIds:n||[Z],workState:j.Done,fontBgColor:v,viewId:a==null?void 0:a.viewId})}}),s.map((I,v)=>{const S=Et(...I);return d.createElement(ei,{key:v,color:S,activeColor:h,onPointerUpHandler:N=>{N.stopPropagation(),u(S);const C=ve(S,M);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=C,c({textOpt:l.textOpt})),oe.emitMethod(_.MainEngine,U.SetColorNode,{workIds:n||[Z],workState:j.Done,fontBgColor:ve(S,M),viewId:a==null?void 0:a.viewId})}})}),g):null,[c,i,s,g,M,h,l==null?void 0:l.textOpt,n,a==null?void 0:a.viewId,f]),w=d.useMemo(()=>{const I=h&&h!=="transparent"&&ve(h,M)||"transparent";return d.createElement("div",{className:"color-bar",style:{marginTop:0}},d.createElement("div",{className:"color-bar-color",style:{backgroundColor:I}}))},[h,M]);return d.createElement("div",{className:`button normal-button font-colors-icon ${i&&"active"}`,onPointerUp:I=>{I.stopPropagation(),I.nativeEvent.stopImmediatePropagation(),e(!i)}},d.createElement(vp,null),w,y)},Ap=o=>{const{bold:i,setBold:e,workIds:t,viewId:n}=o,r=s=>{const a=i==="bold"?"normal":"bold";s==null||s.stopPropagation(),e(a),oe.emitMethod(_.MainEngine,U.SetFontStyle,{workIds:t,viewId:n,bold:a})};return d.createElement("div",{className:"font-style-button",onPointerUp:r},d.createElement("img",{alt:"icon",src:Se(i==="bold"?"bold-active":"bold")}))},bp=o=>{const{underline:i,setUnderline:e,workIds:t,viewId:n}=o,r=s=>{const a=!i;s==null||s.stopPropagation(),e(a),oe.emitMethod(_.MainEngine,U.SetFontStyle,{workIds:t,viewId:n,underline:a})};return d.createElement("div",{className:"font-style-button",onPointerUp:r},d.createElement("img",{alt:"icon",src:Se(i?"underline-active":"underline")}))},Ep=o=>{const{lineThrough:i,setLineThrough:e,workIds:t,viewId:n}=o,r=s=>{const a=!i;s==null||s.stopPropagation(),e(a),oe.emitMethod(_.MainEngine,U.SetFontStyle,{workIds:t,viewId:n,lineThrough:a})};return d.createElement("div",{className:"font-style-button",onPointerUp:r},d.createElement("img",{alt:"icon",src:Se(i?"line-through-active":"line-through")}))},kp=o=>{const{italic:i,setItalic:e,workIds:t,viewId:n}=o,r=s=>{const a=i==="italic"?"normal":"italic";s==null||s.stopPropagation(),e(a),oe.emitMethod(_.MainEngine,U.SetFontStyle,{workIds:t,viewId:n,italic:a})};return d.createElement("div",{className:"font-style-button",onPointerUp:r},d.createElement("img",{alt:"icon",src:Se(i==="italic"?"italic-active":"italic")}))},Lp=o=>{const{open:i,setOpen:e,textOpt:t,workIds:n,style:r,floatBarRef:s}=o,{mananger:a,floatBarData:c}=d.useContext(me),[l,h]=d.useState("normal"),[u,M]=d.useState("normal"),[p,f]=d.useState(!1),[g,y]=d.useState(!1);d.useEffect(()=>{t!=null&&t.bold&&h(t.bold),x.isBoolean(t==null?void 0:t.underline)&&f(t.underline||!1),x.isBoolean(t==null?void 0:t.lineThrough)&&y(t.lineThrough||!1),t!=null&&t.italic&&M(t.italic)},[t]);const w=d.useMemo(()=>{if(r&&(s!=null&&s.current)&&x.isNumber(c==null?void 0:c.y)&&(a!=null&&a.height)){if(s.current.offsetTop&&s.current.offsetTop+c.y>180){const v={};return v.top="inherit",v.bottom=50,v}else if(!s.current.offsetTop&&(a==null?void 0:a.height)-s.current.offsetTop-c.y<120){const v={};return v.top="inherit",v.bottom=50,v}}},[r,s==null?void 0:s.current,c,a]),I=d.useMemo(()=>i?d.createElement("div",{className:"font-style-menu",style:w,onPointerUp:v=>{v.stopPropagation(),v.nativeEvent.stopImmediatePropagation()}},d.createElement(Ap,{workIds:n||[Z],bold:l,setBold:h,viewId:a==null?void 0:a.viewId}),d.createElement(bp,{workIds:n||[Z],underline:p,setUnderline:f,viewId:a==null?void 0:a.viewId}),d.createElement(Ep,{workIds:n||[Z],lineThrough:g,setLineThrough:y,viewId:a==null?void 0:a.viewId}),d.createElement(kp,{workIds:n||[Z],italic:u,setItalic:M,viewId:a==null?void 0:a.viewId})):null,[i,n,l,a==null?void 0:a.viewId,p,g,u,w]);return d.createElement("div",{className:`button normal-button ${i&&"active"}`,onPointerUp:v=>{v.stopPropagation(),v.nativeEvent.stopImmediatePropagation(),e(!i)}},d.createElement("img",{alt:"icon",src:Se(i?"font-style-active":"font-style")}),I)},Ze=Object.freeze([12,14,18,24,36,48,64,80,144,288]),lt=["top","topLeft","topRight","bottom","bottomLeft","bottomRight","left","leftTop","leftBottom","right","rightTop","rightBottom"],Pp=new Map([["selector","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAYAAADE6YVjAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAKeSURBVHgB3VTLi1JhFD86zlQ4ysxSXAy1GWYZzMxmYAhHagRB/QN8FLqPFq4FIQhXkS6kTQ4t2ilIKEWgSS0SmVpIm0BdaBJSaOP78XU+PXey6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wyMC4yNDU0NTk5IDE4LjMyMzEyNDgsMjAuNDQ5NjA4NCAxOC4wODk4NzU2LDIwLjQ5MTk0NDMgTDE4LDIwLjUgTDEzLDIwLjUgQzEyLjcyMzg1NzYsMjAuNSAxMi41LDIwLjI3NjE0MjQgMTIuNSwyMCBDMTIuNSwxOS43NTQ1NDAxIDEyLjY3Njg3NTIsMTkuNTUwMzkxNiAxMi45MTAxMjQ0LDE5LjUwODA1NTcgTDEzLDE5LjUgTDE4LDE5LjUgWiBNMjAsMTIuNSBDMjAuMjQ1NDU5OSwxMi41IDIwLjQ0OTYwODQsMTIuNjc2ODc1MiAyMC40OTE5NDQzLDEyLjkxMDEyNDQgTDIwLjUsMTMgTDIwLjUsMTggQzIwLjUsMTguMjc2MTQyNCAyMC4yNzYxNDI0LDE4LjUgMjAsMTguNSBDMTkuNzU0NTQwMSwxOC41IDE5LjU1MDM5MTYsMTguMzIzMTI0OCAxOS41MDgwNTU3LDE4LjA4OTg3NTYgTDE5LjUsMTggTDE5LjUsMTMgQzE5LjUsMTIuNzIzODU3NiAxOS43MjM4NTc2LDEyLjUgMjAsMTIuNSBaIiBpZD0i5b2i54q257uT5ZCIIiBmaWxsPSIjMjEyMzI0IiBmaWxsLXJ1bGU9Im5vbnplcm8iPjwvcGF0aD4KICAgICAgICAgICAgPC9nPgogICAgICAgIDwvZz4KICAgIDwvZz4KPC9zdmc+"]]),Op=o=>{const{style:i,onClickHandler:e}=o;return d.createElement("div",{className:"font-size-menu",style:i,onPointerUp:t=>{t.stopPropagation(),t.nativeEvent.stopImmediatePropagation()}},Ze.map(t=>d.createElement("div",{className:"font-size-btn",key:t,onPointerUp:()=>{e(t)}},t)))},Rp=o=>{const i=d.useRef(null),{open:e,setOpen:t,textOpt:n,workIds:r,floatBarRef:s}=o,{mananger:a,floatBarData:c}=d.useContext(me),[l,h]=d.useState(0),u=Ze.length-1;d.useEffect(()=>{n!=null&&n.fontSize&&(h(n.fontSize),i.current&&(i.current.value=n.fontSize.toString()))},[n==null?void 0:n.fontSize]);const M=d.useMemo(()=>{if(s!=null&&s.current&&x.isNumber(c==null?void 0:c.y)&&(a!=null&&a.height)){if(s.current.offsetTop&&s.current.offsetTop+c.y>180){const w={};return w.top="inherit",w.bottom=35,w}else if(!s.current.offsetTop&&(a==null?void 0:a.height)-s.current.offsetTop-c.y<120){const w={};return w.top="inherit",w.bottom=35,w}}},[s==null?void 0:s.current,c,a]);function p(w){h(w),w&&w>=Ze[0]&&w<=Ze[u]&&oe.emitMethod(_.MainEngine,U.SetFontStyle,{workIds:r||[Z],fontSize:w,viewId:a==null?void 0:a.viewId})}const f=w=>{var I;(I=i.current)==null||I.blur(),t(!1),y(w)},g=d.useMemo(()=>e?d.createElement(Op,{onClickHandler:f,style:M}):null,[e,f,M]),y=w=>{w>Ze[u]&&(w=Ze[u]),w<Ze[0]&&(w=Ze[0]),p(w)};return d.createElement("div",{className:"button normal-button font-size-barBtn",style:{width:50},onPointerUp:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()}},d.createElement("input",{className:"font-size-input",ref:i,onTouchEnd:()=>{i.current&&i.current.focus()},onClick:()=>{t(!e),i.current&&i.current.focus()},onKeyDown:w=>{if(w.key==="Backspace"){const I=window.getSelection(),v=I==null?void 0:I.getRangeAt(0);if(v!=null&&v.collapsed)return w.cancelable&&w.preventDefault(),document.execCommand("delete",!1),!1}return!1},onKeyUp:w=>{var I;if(i.current){const v=i.current.value,S=parseInt(v);isNaN(S)?i.current.value="0":i.current.value=S.toString(),S&&w.key==="Enter"&&(y(S),(I=i.current)==null||I.blur(),t(!1))}}}),d.createElement("div",{className:"font-size-btns"},d.createElement("div",{className:"font-size-add",onPointerUp:()=>{y(l+Ze[0])}}),d.createElement("div",{className:"font-size-cut",onPointerUp:()=>{y(l-Ze[0])}})),g)},Yp=o=>{const{workIds:i,mananger:e,islocked:t}=o;return d.createElement("div",{className:"button normal-button",onPointerUp:n=>{n.stopPropagation(),oe.emitMethod(_.MainEngine,U.SetLock,{workIds:i||[Z],isLocked:!t,viewId:e==null?void 0:e.viewId})}},d.createElement("img",{alt:"icon",src:Se(t?"unlock-new":"lock-new")}))},mi=o=>{const{icon:i,min:e,max:t,step:n,value:r,onInputHandler:s}=o,[a,c]=d.useState(0),l=d.useRef(null),h=u=>{u>t&&(u=t),u<e&&(u=e),c(u),s(u),l.current&&(l.current.value=u.toString())};return d.useEffect(()=>{r&&(c(r),l.current&&(l.current.value=r.toString()))},[r]),d.createElement("div",{className:"button input-button"},d.createElement("img",{src:Se(i)}),d.createElement("input",{className:"input-number",type:"text",ref:l,onPointerUp:()=>{l.current&&l.current.focus()},onKeyDown:u=>{if(u.key==="Backspace"){const M=window.getSelection(),p=M==null?void 0:M.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,M=parseInt(u);isNaN(M)?l.current.value="0":l.current.value=M.toString()}},onChange:u=>{const M=u.target.value,p=parseInt(M);p&&p&&p>=e&&p<=t&&h(p)}}),d.createElement("div",{className:"input-number-btns"},d.createElement("div",{className:"input-number-add",onPointerUp:()=>{h(a+n)}}),d.createElement("div",{className:"input-number-cut",onPointerUp:()=>{h(a-n)}})))},Up=o=>{const{icon:i,min:e,max:t,step:n,value:r,onInputHandler:s}=o;return d.createElement("div",{className:"button input-button"},d.createElement("img",{src:Se(i)}),d.createElement(Wp,{min:e,max:t,step:n,value:r,onInputHandler:s}))},Wp=o=>{const{value:i,min:e,max:t,onInputHandler:n}=o,[r,s]=d.useState({x:0,y:0});d.useEffect(()=>{s({x:i*100,y:0})},[]);const a=(h,u)=>{let M=Math.floor(Math.max(u.x,e*100));M=Math.floor(Math.min(M,t*100)),u.x!==(r==null?void 0:r.x)&&s({x:M,y:0});const p=M/100;i!==p&&n(p)},c=()=>{},l=(h,u)=>{let M=Math.floor(Math.max(u.x,e*100));M=Math.floor(Math.min(M,t*100)),u.x!==(r==null?void 0:r.x)&&s({x:M,y:0});const p=M/100;i!==p&&n(p)};return d.createElement("div",{className:"range-number-container",onPointerUp:h=>{const u=h.nativeEvent.offsetX-6;let M=Math.floor(Math.max(u,e*100));M=Math.floor(Math.min(M,t*100)),s({x:M,y:0});const p=M/100;i!==p&&n(p)}},d.createElement("div",{className:"range-number-color"}),d.createElement("div",{className:"range-number"},d.createElement(Mt,{bounds:"parent",axis:"x",position:r,onDrag:a,onStart:c,onStop:l},d.createElement("div",{className:"circle",onPointerUp:kt}))))},Bp=o=>{const{icon:i,value:e,onChangeHandler:t,style:n}=o,[r,s]=d.useState(0),[a,c]=d.useState(),l=d.useRef(null),h=d.useCallback(p=>{p>=lt.length&&(p=0),p<0&&(p=lt.length-1),s(p),t(lt[p]),c(!1),l.current&&(l.current.value=lt[p])},[t]),u=d.useMemo(()=>{if(n&&n.bottom){const p={};return p.top="inherit",p.bottom=50,p}},[n]);d.useEffect(()=>{e&&(s(lt.indexOf(e)),l.current&&(l.current.value=e))},[e]);const M=d.useMemo(()=>a?d.createElement(Fp,{options:lt,onClickHandler:h,style:u}):null,[a,h,u]);return d.createElement("div",{className:"button input-button"},d.createElement("img",{src:Se(i)}),d.createElement("input",{readOnly:!0,className:"input-number",type:"text",ref:l,onPointerUp:()=>{l.current&&(l.current.focus(),c(!a))}}),d.createElement("div",{className:"input-number-btns"},d.createElement("div",{className:"input-number-add",onPointerUp:()=>{h(r+1)}}),d.createElement("div",{className:"input-number-cut",onPointerUp:()=>{h(r-1)}})),M)},Fp=o=>{const{options:i,style:e,onClickHandler:t}=o;return d.createElement("div",{className:"select-option-menu",style:e},i.map((n,r)=>d.createElement("div",{className:"select-option-btn",key:n,onPointerUp:()=>{t(r)}},n)))},Vp=o=>{const{innerRatio:i,innerVerticeStep:e,vertices:t,mananger:n,setShapeOpt:r}=o,s=l=>{r({vertices:l}),oe.emitMethod(_.MainEngine,U.SetShapeOpt,{workIds:[Z],toolsType:T.Star,viewId:n.viewId,vertices:l})},a=l=>{r({innerVerticeStep:l}),oe.emitMethod(_.MainEngine,U.SetShapeOpt,{workIds:[Z],toolsType:T.Star,viewId:n.viewId,innerVerticeStep:l})},c=l=>{r({innerRatio:l}),oe.emitMethod(_.MainEngine,U.SetShapeOpt,{workIds:[Z],toolsType:T.Star,viewId:n.viewId,innerRatio:l})};return d.createElement(d.Fragment,null,d.createElement(mi,{value:t,icon:"polygon-vertex",min:3,max:100,step:1,onInputHandler:s}),d.createElement(mi,{value:e,icon:"star-innerVertex",min:1,max:100,step:1,onInputHandler:a}),d.createElement(Up,{value:i,icon:"star-innerRatio",min:.1,max:1,step:.1,onInputHandler:c}))},Qp=o=>{const{mananger:i,vertices:e,setShapeOpt:t}=o,n=r=>{t({vertices:r}),oe.emitMethod(_.MainEngine,U.SetShapeOpt,{workIds:[Z],toolsType:T.Polygon,viewId:i.viewId,vertices:r})};return d.createElement(mi,{value:e,icon:"polygon-vertex",min:3,max:100,step:1,onInputHandler:n})},Zp=o=>{const{mananger:i,placement:e,setShapeOpt:t}=o,n=r=>{t({placement:r}),oe.emitMethod(_.MainEngine,U.SetShapeOpt,{workIds:[Z],toolsType:T.SpeechBalloon,viewId:i.viewId,placement:r})};return d.createElement(Bp,{value:e,icon:"speechBallon-placement",onChangeHandler:n})},ri=o=>{const{icon:i,isActive:e,onPointerUpHandler:t}=o;return d.createElement("div",{className:`button tab-button ${e?"active":""}`,onPointerUp:t},d.createElement("img",{src:Se(i)}))},Hp=o=>{const{toolsTypes:i,style:e,mananger:t,shapeOpt:n,setShapeOpt:r}=o,[s,a]=d.useState();d.useEffect(()=>{i.includes(T.Polygon)?a(T.Polygon):i.includes(T.Star)?a(T.Star):a(T.SpeechBalloon)},[i]);const c=M=>{a(M)},l=d.useMemo(()=>s===T.Polygon&&t&&n.vertices?d.createElement(Qp,{vertices:n.vertices,mananger:t,setShapeOpt:r}):null,[t,s,n,r]),h=d.useMemo(()=>s===T.Star&&t&&n.vertices&&n.innerVerticeStep&&n.innerRatio?d.createElement(Vp,{mananger:t,vertices:n.vertices,innerVerticeStep:n.innerVerticeStep,innerRatio:n.innerRatio,setShapeOpt:r}):null,[t,s,n,r]),u=d.useMemo(()=>s===T.SpeechBalloon&&t&&n.placement?d.createElement(Zp,{mananger:t,placement:n.placement,setShapeOpt:r}):null,[s,t,n.placement,r]);return d.createElement("div",{className:"shapeOpt-sub-menu",style:e,onPointerUp:kt},d.createElement("div",{className:"shapeOpt-sub-menu-tabs"},i.includes(T.Polygon)&&d.createElement(ri,{isActive:s===T.Polygon,icon:s===T.Polygon?"polygon-active":"polygon",onPointerUpHandler:c.bind(void 0,T.Polygon)})||null,i.includes(T.Star)&&d.createElement(ri,{isActive:s===T.Star,icon:s===T.Star?"star-active":"star",onPointerUpHandler:c.bind(void 0,T.Star)})||null,i.includes(T.SpeechBalloon)&&d.createElement(ri,{isActive:s===T.SpeechBalloon,icon:s===T.SpeechBalloon?"speechBallon-active":"speechBallon",onPointerUpHandler:c.bind(void 0,T.SpeechBalloon)})||null),d.createElement("div",{className:"shapeOpt-sub-menu-content"},l,h,u))},$p=o=>{const{open:i,setOpen:e,floatBarRef:t,toolsTypes:n,shapeOpt:r}=o,{floatBarData:s,mananger:a,setFloatBarData:c}=d.useContext(me),l=d.useRef(null),h=d.useMemo(()=>{if(t!=null&&t.current&&x.isNumber(s==null?void 0:s.x)&&x.isNumber(s==null?void 0:s.y)&&(a!=null&&a.height)){if(t.current.offsetTop&&t.current.offsetTop+s.y>200){const f={};return f.top="inherit",f.bottom=50,f}else if(!t.current.offsetTop&&(a==null?void 0:a.height)-t.current.offsetTop-(s==null?void 0:s.y)<140){const f={};return f.top="inherit",f.bottom=50,f}}},[t,s==null?void 0:s.x,s==null?void 0:s.y,a==null?void 0:a.height]),u=d.useCallback(f=>{c({shapeOpt:{...r,...f}})},[c,r]),M=d.useMemo(()=>i&&n&&a&&r?d.createElement(Hp,{shapeOpt:r,style:h,toolsTypes:n,mananger:a,setShapeOpt:u}):null,[i,h,n,a,r,u]),p=()=>{e(!i)};return d.createElement("div",{ref:l,className:`button normal-button ${i&&"active"}`,onPointerUp:p},M,d.createElement("img",{alt:"icon",src:Se(i?"shapes-active":"shapes")}))},No=d.memo(o=>{const{textOpt:i,workIds:e,noLayer:t,position:n,noDelete:r,noCopy:s}=o,{floatBarData:a,mananger:c}=d.useContext(me),[l,h]=d.useState(0),[u,M]=d.useState(),p=d.useRef(null);d.useEffect(()=>{var L,O,E,R;const D={},k=(a==null?void 0:a.w)||((L=i==null?void 0:i.boxSize)==null?void 0:L[0])||0,P=(a==null?void 0:a.h)||((O=i==null?void 0:i.boxSize)==null?void 0:O[1])||0;if(n&&k&&P&&(c!=null&&c.width)&&(c!=null&&c.height)){if(n.y<60?n.y+P<c.height-60?D.bottom=-120:n.y+P<c.height?D.bottom=-58:n.y>0?D.top=62:D.top=-n.y+62:D.top=0,n.x<0)D.left=-n.x+3;else if(n.x+(((E=p.current)==null?void 0:E.offsetWidth)||k)>c.width){const z=c.width-(((R=p.current)==null?void 0:R.offsetWidth)||k)-n.x;D.left=z}M(D);return}M(void 0)},[p,n,a==null?void 0:a.w,a==null?void 0:a.h,c==null?void 0:c.width,c==null?void 0:c.height,i==null?void 0:i.boxSize]);const f=d.useMemo(()=>a!=null&&a.fillColor?d.createElement(Dp,{floatBarRef:p,open:l===3,setOpen:D=>{h(D===!0?3:0)}}):null,[a==null?void 0:a.fillColor,l,p]),g=d.useMemo(()=>a!=null&&a.strokeColor?d.createElement(jp,{floatBarRef:p,open:l===2,setOpen:D=>{h(D===!0?2:0)}}):null,[a==null?void 0:a.strokeColor,l,p]),y=d.useMemo(()=>i!=null&&i.fontColor&&(c!=null&&c.viewId)?d.createElement(xp,{floatBarRef:p,open:l===4,setOpen:D=>{h(D===!0?4:0)},textOpt:i,workIds:e}):null,[i,l,e,c,p]),w=d.useMemo(()=>i!=null&&i.fontBgColor&&(c!=null&&c.viewId)?d.createElement(zp,{floatBarRef:p,open:l===5,setOpen:D=>{h(D===!0?5:0)},textOpt:i,workIds:e}):null,[i,l,e,c,p]),I=d.useMemo(()=>i&&(c!=null&&c.viewId)?d.createElement(Lp,{floatBarRef:p,open:l===6,setOpen:D=>{h(D===!0?6:0)},textOpt:i,workIds:e,style:u}):null,[i,l,e,c,u,p]),v=d.useMemo(()=>i&&(c!=null&&c.viewId)?d.createElement(Rp,{open:l===7,setOpen:D=>{h(D===!0?7:0)},textOpt:i,workIds:e,floatBarRef:p}):null,[i,l,e,c,p]),S=d.useMemo(()=>t?null:d.createElement(Tp,{open:l===1,setOpen:D=>{h(D===!0?1:0)},floatBarRef:p}),[t,l,p]),N=d.useMemo(()=>a!=null&&a.canLock&&c?d.createElement(Yp,{workIds:e,mananger:c,islocked:a.isLocked}):null,[a,c,e]),C=d.useMemo(()=>c&&(c!=null&&c.viewId)&&u&&(a!=null&&a.shapeOpt)&&(a!=null&&a.toolsTypes)?d.createElement($p,{open:l===8,setOpen:D=>{h(D===!0?8:0)},floatBarRef:p,workIds:e,toolsTypes:a.toolsTypes,shapeOpt:a.shapeOpt}):null,[a,c,l,u,e,p]);return d.createElement("div",{className:"appliance-plugin-floatbtns",style:u,ref:p},c&&!r&&d.createElement(wp,{workIds:e,mananger:c}),S,N,!!(c!=null&&c.viewId)&&!s&&d.createElement(Np,{workIds:e,viewId:c.viewId}),C,I,v,y,w,g,f)}),Gp=o=>{const{data:i,workId:e,updateOptInfo:t,handlePointerDown:n,handlePointerUp:r}=o,{opt:s,scale:a,translate:c,x:l,y:h}=i,u=d.useRef(null),{floatBarData:M}=d.useContext(me),p=d.useMemo(()=>{const{fontSize:y,fontFamily:w,underline:I,fontColor:v,lineThrough:S,textAlign:N,strokeColor:C,lineHeight:D,bold:k,italic:P}=s,L=D||y*1.2,O={fontSize:`${y}px`,lineHeight:`${L}px`,color:"transparent",caretColor:v,borderColor:C,minHeight:`${L}px`,pointerEvents:"none",paddingRight:`${P==="italic"?Math.round(y*.3):5}px`};return w&&(O.fontFamily=`${w}`),(S||I)&&(O.textDecoration=`${S&&"line-through"||""}${I&&" underline"||""}`),N&&(O.textAlign=`${N}`),k&&(O.fontWeight=`${k}`),P&&(O.fontStyle=`${P}`),O},[s]),f=d.useMemo(()=>{const y=[];if(s.text){const w=Kt(s.text);for(let I=0;I<w.length;I++){const v=w[I];v===""?y.push(d.createElement("div",{key:I})):y.push(d.createElement("div",{key:I},v))}}return y.length?y:d.createElement("div",null)},[s.text]),g=d.useMemo(()=>{if(!M)return{};const y=`scale(${a||1}) ${c&&"translate("+c[0]+"px,"+c[1]+"px)"||""}`;return{left:`${l-M.x}px`,top:`${h-M.y}px`,zIndex:1,transform:y,transformOrigin:"left top",opacity:0,pointerEvents:"auto"}},[a,c,l,h,M]);return d.useEffect(()=>{var y,w;if((y=u.current)!=null&&y.offsetWidth&&((w=u.current)!=null&&w.offsetHeight)){const I=s.boxSize;if((I==null?void 0:I[0])!==u.current.offsetWidth||I[1]!==u.current.offsetHeight||!I){const v=[u.current.offsetWidth,u.current.offsetHeight];t({activeTextId:e,update:{boxSize:v,workState:j.Done}})}}},[s.fontSize,s.italic,s.bold,s.boxSize,e,t]),d.createElement("div",{className:"editor-box readonly",style:g,onPointerDown:()=>{n(e)},onPointerUp:()=>{r()}},d.createElement("div",{className:"editor",ref:u,style:p},f))},Jp=o=>{const{mananger:i}=d.useContext(me),e=d.useMemo(()=>{var n;const t=r=>{var h,u;if(!i)return;const{activeTextId:s,update:a,syncData:c}=r,l=s&&x.cloneDeep(((h=i.control.textEditorManager)==null?void 0:h.get(s))||((u=o.editors)==null?void 0:u.get(s)));l&&l.opt&&(l.opt={...l.opt,...a},c&&(l.canSync=Object.keys(c).includes("canSync")&&c.canSync||l.canSync,l.canWorker=Object.keys(c).includes("canWorker")&&c.canWorker||l.canWorker),i.control.textEditorManager.updateForViewEdited(s,l))};if((n=o.editors)!=null&&n.size){const r=[];return o.editors.forEach((s,a)=>{if(o.selectIds&&o.selectIds.includes(a)){const c=d.createElement(Gp,{key:a,workId:a,data:s,updateOptInfo:t,handlePointerDown:o.handleTextEditorPointerDown,handlePointerUp:o.handleTextEditorPointerUp});r.push(c)}}),r}return null},[o.editors,o.selectIds,i,o.handleTextEditorPointerDown,o.handleTextEditorPointerUp]);return d.createElement(d.Fragment,null,e)},Xp=o=>{const{position:i,textOpt:e,workIds:t,noLayer:n,noCopy:r,noDelete:s,style:a}=o,c=d.useRef(null);return d.createElement("div",{className:xe.FloatBarBtn,ref:c,style:a},d.createElement(No,{position:i,textOpt:e,workIds:t,noLayer:n,noCopy:r,noDelete:s}))},qp=o=>{const{data:i,workId:e,showFloatBtns:t,handleKeyUp:n,handleFocus:r,runAnimation:s,updateSize:a,rightBoundBreak:c}=o,{activeTextEditor:l,activeTextId:h,mananger:u}=d.useContext(me),{opt:M,scale:p,translate:f,x:g,y}=i,{fontSize:w,fontFamily:I,underline:v,fontColor:S,lineThrough:N,textAlign:C,lineHeight:D,bold:k,italic:P}=M,L=d.useRef(null),O=d.useMemo(()=>{const Q=w,G=D||Q*1.2,q={fontSize:`${Q}px`,lineHeight:`${G}px`,caretColor:S,color:"transparent",minHeight:`${G}px`,paddingRight:`${P==="italic"?Math.round(Q*.3):5}px`,borderWidth:0};return I&&(q.fontFamily=`${I}`),(N||v)&&(q.textDecoration=`${N&&"line-through"||""} ${v&&" underline"||""}`),C&&(q.textAlign=`${C}`),k&&(q.fontWeight=`${k}`),P&&(q.fontStyle=`${P}`),q},[k,S,I,w,P,D,N,p,C,v]),E=d.useRef(!1),R=d.useRef(6),z=d.useRef({fontSize:O.fontSize,lineHeight:O.lineHeight,fontStyle:O.fontStyle,fontWeight:O.fontWeight,fontFamily:O.fontFamily}),V=d.useMemo(()=>h===e?"hover":M.workState===j.Doing||M.workState===j.Start?"editing":l?"active":"none",[h,e,M.workState,l]);function te(Q){if(L.current){const G=window==null?void 0:window.getSelection(),q=L.current,se=(ce,he)=>{var ae;const de=document.createRange();if(he.childNodes.length>0){const Ne=he.lastChild;if(Ne){const je=Ne.lastChild;je&&je.nodeType===Node.TEXT_NODE?de.setStart(je,((ae=je.textContent)==null?void 0:ae.length)||0):de.setStart(Ne,0)}else de.setStart(he,0)}else de.setStart(he,0);de.collapse(!0),ce.removeAllRanges(),ce.addRange(de)};if(G&&q)if(Q&&Rt(Q.nativeEvent)){const{x:ce,y:he}=yo(Q.nativeEvent);if(document.caretPositionFromPoint){const de=document.caretPositionFromPoint(ce,he);if(de){const ae=document.createRange();ae.setStart(de.offsetNode,de.offset),ae.collapse(!0),G.removeAllRanges(),G.addRange(ae)}else se(G,q)}else if(document.caretRangeFromPoint){const de=document.caretRangeFromPoint(ce,he);de?(G.removeAllRanges(),G.addRange(de)):se(G,q)}else se(G,q)}else se(G,q);L.current.focus()}}const B=d.useMemo(()=>{const Q=`scale(${p||1}) ${f&&"translate("+f[0]+"px,"+f[1]+"px)"||""}`;return{left:`${g-Mi*(p||1)}px`,top:`${y-Mi*(p||1)}px`,zIndex:2,transform:Q,transformOrigin:"left top",borderColor:V==="editing"||V==="hover"?S:"transparent"}},[p,f,g,y,S,V]),$=d.useMemo(()=>{let Q="";const G=`<div style="background-color:${M.fontBgColor};"></div>`;if(M.text){const q=Kt(M.text);for(let se=0;se<q.length;se++){const ce=q[se];if(ce==="")Q=Q+G;else{const he=ce.replace(/[<>&]/g,de=>({"<":"&lt;",">":"&gt;","&":"&amp;"})[de]);Q=Q+`<div style="background-color:${M.fontBgColor}">${he}</div>`}}}else Q=G;return Q},[M.fontBgColor,M.text]),ie=d.useMemo(()=>{var Q,G;if(V==="hover"){if(p&&t&&x.isNumber(g)&&x.isNumber(y)&&M.boxSize&&x.isNumber((Q=M.boxSize)==null?void 0:Q[0])&&x.isNumber((G=M.boxSize)==null?void 0:G[1])){const q={x:g,y},se={left:g,top:y,width:M.boxSize[0]*p,height:M.boxSize[1]*p};return d.createElement(Xp,{position:q,style:se,textOpt:M,workIds:[e],noLayer:!0,noCopy:!0,noDelete:!0})}return null}return null},[M,t,e,g,y,p,V]);d.useEffect(()=>{h===e&&L.current&&(document.activeElement!==L.current&&te(),r(L.current))},[h,r,e]),d.useEffect(()=>{if(L.current){const Q=parseInt(getComputedStyle(L.current).paddingRight,10)+parseInt(getComputedStyle(L.current).borderWidth,10);R.current=Number(Q)}},[]),d.useEffect(()=>{if(L.current){const Q={fontSize:O.fontSize,lineHeight:O.lineHeight,fontStyle:O.fontStyle,fontWeight:O.fontWeight,fontFamily:O.fontFamily};if(!x.isEqual(z.current,Q)){z.current=Q;const G=[L.current.offsetWidth,L.current.offsetHeight];a(e,G)}}},[O,e,a]);const re=d.useCallback(Q=>{var he,de;const G=u==null?void 0:u.parentElement;if(!G||!L.current||!c)return!1;const q=L.current.lastChild;if(!q||q instanceof Text)return!1;const se=q==null?void 0:q.getBoundingClientRect(),ce=G==null?void 0:G.getBoundingClientRect();if(!se||!ce)return!1;if(se.right+Q>ce.right){const ae=q.lastChild;if(!(ae instanceof Text))return!1;const Ne=ae.length||0;let je=0,Ie=0,be=Ne;for(;Ie<be;){const Ce=Math.floor((Ie+be)/2),Xe=document.createRange();Xe.setStart(ae,0),Xe.setEnd(ae,Ce);const ct=Xe.getBoundingClientRect(),Bi=ce.right-ct.right;if(Bi<Q){if(Ce>0){const tt=document.createRange();tt.setStart(ae,0),tt.setEnd(ae,Ce-1);const Nt=tt.getBoundingClientRect();if(ce.right-Nt.right>=Q){je=Ce-1;break}}be=Ce}else{const tt=Ce+1;if(tt<Ne){const Nt=document.createRange();Nt.setStart(ae,0),Nt.setEnd(ae,tt);const Fi=Nt.getBoundingClientRect();if(ce.right-Fi.right<=Q&&Bi>Q){je=Ce;break}}Ie=tt}}if(!je){const Ce=document.createRange();Ce.setStart(ae,0),Ce.setEnd(ae,Ie);const Xe=Ce.getBoundingClientRect();ce.right-Xe.right>Q?je=Ie:Ie>0&&(je=Ie-1)}if(je>0){const Ce=((he=ae.textContent)==null?void 0:he.slice(0,je))||"",Xe=((de=ae.textContent)==null?void 0:de.slice(je))||"";ae.textContent=Ce;const ct=document.createElement("div");return M.fontBgColor&&(ct.style.backgroundColor=M.fontBgColor),Xe&&(ct.textContent=Xe),L.current.appendChild(ct),re(Q),!0}}return!1},[u==null?void 0:u.parentElement,M.fontBgColor,c]);function ne(Q){if(Q.key==="Backspace"){const G=window.getSelection(),q=G==null?void 0:G.getRangeAt(0);if(q!=null&&q.collapsed)return Q.cancelable&&Q.preventDefault(),document.execCommand("delete",!1),!1}return!1}function J(Q,G){const q=window==null?void 0:window.getSelection();if(q!=null&&q.rangeCount&&Q&&q&&q.anchorNode){const se=q.anchorOffset,ce=q.anchorNode.textContent||"",he=ce.slice(0,se)||"",de=ce.slice(se)||"",ae=he.concat(Q)||"";H(ae,de,G)}}function H(Q,G,q){const se=window==null?void 0:window.getSelection();if(!(se!=null&&se.rangeCount)||!se.anchorNode)return;const ce=Q.split(/\n/);let he=se.anchorNode.parentNode;he===q&&(he=se.anchorNode);const de=[...q.childNodes],ae=[];let Ne,je=se.anchorOffset;for(;de.length;){const Ie=de.pop();if(Ie){if(Ie===he){let be=ce[0];ce.length===1&&(je=ce[0].length,be=ce[0].concat(G)),he.nodeName==="#text"?(he.textContent=be,Ne=he):he.nodeName==="DIV"&&(he.innerText=be,Ne=he.childNodes[0]);break}ae.push(Ie),q.removeChild(Ie)}}if(ce.length>1)for(let Ie=1;Ie<ce.length;Ie++){let be=ce[Ie];const Ce=document.createElement("div");M.fontBgColor&&(Ce.style.backgroundColor=M.fontBgColor),Ie===ce.length-1&&(je=be.length,be=be.concat(G)),Ce.innerText=be,q.appendChild(Ce),Ie===ce.length-1&&(Ne=Ce.childNodes[0])}if(ae.length){ae.reverse();for(const Ie of ae)q.appendChild(Ie)}if(Ne&&Ne.nodeName==="#text"){se.deleteFromDocument();const Ie=document.createRange(),be=Math.min(je,(Ne==null?void 0:Ne.length)||0);Ie.setStart(Ne,be),Ie.collapse(!0),se.removeAllRanges(),se.addRange(Ie)}}function le(Q){if(Q.cancelable&&Q.preventDefault(),Q.stopPropagation(),Q.nativeEvent.stopImmediatePropagation(),L.current){const G=(Q.clipboardData||window.clipboardData).getData("text"),q=window==null?void 0:window.getSelection();if(!(q!=null&&q.rangeCount))return;if(G&&q&&q.anchorNode){const se=ai(G,{whiteList:{},stripIgnoreTag:!0,stripIgnoreTagBody:["script"]});J(se,L.current),re((p||1)*R.current),n(L.current)}s()}return!1}function Fe(Q){var q;const G=Q.querySelector("div");if(G){const se=document.createTreeWalker(Q,NodeFilter.SHOW_TEXT,null);let ce;const he=[];for(;(ce=se.nextNode())!==null;)ce.parentNode===Q&&he.push(ce);if(he.length>0){for(const ae of he)G.appendChild(ae);const de=window.getSelection();if(de){const ae=document.createRange(),Ne=G.lastChild;Ne&&Ne.nodeType===Node.TEXT_NODE&&(ae.setStart(Ne,((q=Ne.textContent)==null?void 0:q.length)||0),ae.collapse(!0),de.removeAllRanges(),de.addRange(ae))}}}}const Ve=d.useCallback(()=>{const Q=L.current;s(()=>{if(Q){if(Fe(Q),!E.current&&re((p||1)*R.current)){const G=window.getSelection();if(!(G!=null&&G.rangeCount))return!1;const q=document.createRange(),se=L.current.lastChild;q.selectNodeContents(se),q.collapse(!1),G.removeAllRanges(),G.addRange(q)}n(Q)}})},[s,n,re,p]);function et(){E.current=!0,s()}function Ge(){E.current=!1,Ve()}function Qe(){Ve(),s()}const X=d.useCallback(()=>{if(V==="active"&&L.current&&L.current.parentElement){const Q=L.current.parentElement;Q.style.borderColor=S}},[V,S]),ge=d.useCallback(()=>{if(V==="active"&&L.current&&L.current.parentElement){const Q=L.current.parentElement;Q.style.borderColor="transparent"}},[V]);return d.createElement(d.Fragment,null,ie,d.createElement("div",{className:`editor-box ${V}`,style:B,onPointerUp:()=>{var Q;if(V==="editing"){s(()=>{var G;(G=document.activeElement)==null||G.blur(),u==null||u.control.textEditorManager.checkEmptyTextBlur()});return}if(V==="active"&&u){if((Q=u.control.collector)!=null&&Q.hasIncludeSelector(e)){s(()=>{var G;(G=document.activeElement)==null||G.blur(),u==null||u.control.textEditorManager.checkEmptyTextBlur()});return}if(u&&h!==e){u.control.textEditorManager.checkEmptyTextBlur(),u.control.textEditorManager.active(e);return}}},onMouseOver:X,onMouseLeave:ge},d.createElement("div",{id:e,suppressContentEditableWarning:!0,contentEditable:!0,className:"editor",ref:L,style:O,onKeyDown:ne,onPaste:le,onTouchEnd:te,onInput:Ve,onCompositionStart:et,onCompositionUpdate:Qe,onCompositionEnd:Ge,dangerouslySetInnerHTML:{__html:$}})))},Kp=o=>{const i=d.useRef(null),{mananger:e}=d.useContext(me),t=d.useRef(),n=d.useCallback(s=>{var u,M;const{activeTextId:a,update:c,syncData:l}=s;if(!e)return;const h=a&&x.cloneDeep(((u=e.control.textEditorManager)==null?void 0:u.get(a))||((M=o.editors)==null?void 0:M.get(a)));h&&h.opt&&(h.opt={...h.opt,...c},l&&(h.canSync=Object.keys(l).includes("canSync")&&l.canSync||h.canSync,h.canWorker=Object.keys(l).includes("canWorker")&&l.canWorker||h.canWorker),e.control.textEditorManager.updateForViewEdited(a,h))},[e,o.editors]),r=d.useMemo(()=>{var u;const s=M=>{const p=[];for(let f=0;f<M.childNodes.length;f++){const g=M.childNodes[f];if(g.nodeName==="#text"&&f===0){const y=g.textContent.split(/\n/),w=y.pop();p.push(...y),w&&p.push(w)}else if(g.nodeName==="DIV"){const y=g.innerText.split(/\n/);if(y.length===2&&y[0]===""&&y[1]==="")p.push("");else{const w=y.shift();(w||w==="")&&p.push(w);const I=y.pop();p.push(...y),I&&p.push(I)}}}return p},a=M=>{if(!e)return;const p=M.id,f=e.control.textEditorManager.get(p),g=j.Doing,y=[M.offsetWidth,M.offsetHeight];(!f||f&&(!x.isEqual(f.opt.boxSize,y)||!x.isEqual(f.opt.workState,g)))&&n({activeTextId:p,update:{boxSize:y,workState:g},syncData:{canSync:!0,canWorker:!0}})},c=M=>{var v,S;if(!e)return;const p=s(M),f=M.id,g=e.control.textEditorManager.get(f),y=xt(p),w=j.Doing,I=[M.offsetWidth,M.offsetHeight];if(!g||g&&(g.opt.text!==y||!x.isEqual(g.opt.boxSize,I)||!x.isEqual(g.opt.workState,w))){const N=f&&x.cloneDeep(((v=e.control.textEditorManager)==null?void 0:v.get(f))||((S=o.editors)==null?void 0:S.get(f)));N&&N.opt&&(N.opt={...N.opt,text:y,boxSize:I,workState:w},N.canSync=!0,N.canWorker=!0,e.control.textEditorManager.updateForViewEdited(f,N)),e.control.textEditorManager.publicMsgEmitter.emit("textChange",f,M,p,N)}},l=(M,p)=>{if(!e)return;const f=M,g=e.control.textEditorManager.get(f);if(g&&!x.isEqual(g.opt.boxSize,p)){const y=x.cloneDeep(g);y.opt={...y.opt,boxSize:p},y.canSync=!1,y.canWorker=!1,e.control.textEditorManager.updateForViewEdited(f,y)}},h=M=>{t.current&&cancelAnimationFrame(t.current),t.current=requestAnimationFrame(()=>{i!=null&&i.current&&(i==null||i.current.scrollTo({left:0,behavior:"instant"}),M&&M(),t.current=void 0)})};if((u=o.editors)!=null&&u.size){const M=[];return o.editors.forEach((p,f)=>{M.push(d.createElement(qp,{key:f,workId:f,data:p,showFloatBtns:o.showFloatBtns||!1,handleFocus:a,handleKeyUp:c,updateSize:l,runAnimation:h,rightBoundBreak:o.rightBoundBreak||!1}))}),M}return null},[o.editors,o.showFloatBtns,o.rightBoundBreak,e,n]);return d.createElement("div",{className:`${o.className}`,ref:i},r)},_p=()=>{const{floatBarData:o}=d.useContext(me);return d.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:o==null?void 0:o.selectorColor}},d.createElement("div",{className:"point LT nwse-resize",style:{backgroundColor:o==null?void 0:o.selectorColor}}),d.createElement("div",{className:"point LC ew-resize",style:{backgroundColor:o==null?void 0:o.selectorColor}}),d.createElement("div",{className:"point LB nesw-resize",style:{backgroundColor:o==null?void 0:o.selectorColor}}),d.createElement("div",{className:"point TC ns-resize",style:{backgroundColor:o==null?void 0:o.selectorColor}}),d.createElement("div",{className:"point RT nesw-resize",style:{backgroundColor:o==null?void 0:o.selectorColor}}),d.createElement("div",{className:"point RC ew-resize",style:{backgroundColor:o==null?void 0:o.selectorColor}}),d.createElement("div",{className:"point RB nwse-resize",style:{backgroundColor:o==null?void 0:o.selectorColor}}),d.createElement("div",{className:"point BC ns-resize",style:{backgroundColor:o==null?void 0:o.selectorColor}}))},ey=()=>{const{floatBarData:o,mananger:i}=d.useContext(me),[e,t]=d.useState(),[n,r]=d.useState();d.useEffect(()=>{const c=[];if(i&&x.isNumber(o==null?void 0:o.x)&&x.isNumber(o==null?void 0:o.y)&&(o!=null&&o.points)){const l=i.viewId;if(i.control.viewContainerManager.getView(l))for(const u of o.points){const M=i.control.viewContainerManager.transformToOriginPoint(u,l);c.push(M)}c[0]&&t({x:c[0][0]-((o==null?void 0:o.x)||0),y:c[0][1]-((o==null?void 0:o.y)||0)}),c[1]&&r({x:c[1][0]-((o==null?void 0:o.x)||0),y:c[1][1]-((o==null?void 0:o.y)||0)})}},[i,o==null?void 0:o.points,o==null?void 0:o.x,o==null?void 0:o.y]);const s=d.useMemo(()=>e?d.createElement("div",{className:"point point-dot",style:{borderColor:o==null?void 0:o.selectorColor,left:e.x,top:e.y}}):null,[o==null?void 0:o.selectorColor,e]),a=d.useMemo(()=>n?d.createElement("div",{className:"point point-dot",style:{borderColor:o==null?void 0:o.selectorColor,left:n.x,top:n.y}}):null,[n,o==null?void 0:o.selectorColor]);return d.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:o==null?void 0:o.selectorColor}},s,a)},ty=()=>{const{floatBarData:o}=d.useContext(me);return d.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:o==null?void 0:o.selectorColor}},d.createElement("div",{className:"point LT nwse-resize",style:{backgroundColor:o==null?void 0:o.selectorColor}}),d.createElement("div",{className:"point LB nesw-resize",style:{backgroundColor:o==null?void 0:o.selectorColor}}),d.createElement("div",{className:"point RT nesw-resize",style:{backgroundColor:o==null?void 0:o.selectorColor}}),d.createElement("div",{className:"point RB nwse-resize",style:{backgroundColor:o==null?void 0:o.selectorColor}}))},iy=()=>{const{floatBarData:o}=d.useContext(me);return d.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:o==null?void 0:o.selectorColor}},d.createElement("img",{className:"lock",alt:"lock",src:"https://sdk.netless.link/resource/icons/lock.svg"}))},ny=o=>{const{className:i}=o,{floatBarData:e,angle:t,setAngle:n,setOperationType:r,mananger:s}=d.useContext(me),[a,c]=d.useState(j.Pending),[l,h]=d.useState(),[u,M]=d.useState(!1),[p,f]=d.useState(new ye),[g,y]=d.useState(new ye),[w,I]=d.useState(!1),v=d.useRef(0),S=d.useRef(null),N=L=>{if(!L){I(!0),M(!1),r(U.None),c(j.Pending);return}I(!1)},C=(L,O)=>{v.current&&(clearTimeout(v.current),v.current=0),c(j.Done),M(!1);const E=Math.round(ye.GetAngleByPoints(p,g,new ye(O.x,O.y)))||0;n(E),r(U.None),oe.emitMethod(_.MainEngine,U.RotateNode,{workIds:[Z],angle:E,workState:j.Done,viewId:s==null?void 0:s.viewId}),s==null||s.focusElement()};d.useEffect(()=>(oe.activeListener(N),()=>{oe.unmountActiveListener(N)}),[]),d.useEffect(()=>{if(e&&(a===j.Pending||a===j.Done)){const L={x:(e==null?void 0:e.x)-20,y:(e==null?void 0:e.y)+(e==null?void 0:e.h)},O={x:(e==null?void 0:e.x)+(e==null?void 0:e.w)/2,y:(e==null?void 0:e.y)+(e==null?void 0:e.h)/2};y(new ye(O.x,O.y)),f(new ye(L.x,L.y)),h({x:L.x,y:L.y})}},[e,a]);const D=(L,O)=>{if(s!=null&&s.control.worker.isBusy){I(!0),c(j.Pending);return}v.current&&(clearTimeout(v.current),v.current=0),c(j.Start),M(!0);const E=Math.round(ye.GetAngleByPoints(p,g,new ye(O.x,O.y)))||0;n(E),r(U.RotateNode),oe.emitMethod(_.MainEngine,U.RotateNode,{workIds:[Z],angle:0,workState:j.Start,viewId:s==null?void 0:s.viewId})},k=(L,O)=>{if(s!=null&&s.control.worker.isBusy){I(!0),C(L,O);return}C(L,O)},P=(L,O)=>{if(s!=null&&s.control.worker.isBusy){I(!0),C(L,O);return}v.current||(h({x:O.x,y:O.y}),M(!0),v.current=setTimeout(()=>{v.current=0;const E=Math.round(ye.GetAngleByPoints(p,g,new ye(O.x,O.y)))||0;n(E),r(U.RotateNode),c(j.Doing),oe.emitMethod(_.MainEngine,U.RotateNode,{workIds:[Z],angle:E,workState:j.Doing,viewId:s==null?void 0:s.viewId})},60))};return d.createElement(Mt,{disabled:w,position:l,onStart:D,onDrag:P,onStop:k},d.createElement("div",{className:`${i}`,style:e?{left:0,top:0,touchAction:"none"}:void 0},!u&&d.createElement("div",{className:"appliance-plugin-rotate-btn",style:{backgroundColor:e==null?void 0:e.selectorColor}},d.createElement("img",{alt:"icon",src:Se("rotation-button")})),d.createElement("div",{ref:S,className:`appliance-plugin-rotate-mouse-pointer ${u?"active":""}`},d.createElement("img",{alt:"icon",src:Se("rotation")}),d.createElement("div",{className:"angle-icon"},t,"°"))))},oy=o=>{const{editors:i,canSelectorSwitch:e}=o,{floatBarData:t,setOperationType:n,mananger:r,isNoPointerEvents:s}=d.useContext(me),[a,c]=d.useState(),[l,h]=d.useState(!1),u=d.useRef(0),M=d.useRef(),p=d.useRef(j.Pending),f=d.useMemo(()=>!!((t==null?void 0:t.scaleType)===Ae.none&&(t!=null&&t.canLock)),[t]),g=d.useMemo(()=>t&&t.w&&t.h?{position:"absolute",left:0,top:0,width:t.w,height:t.h,zIndex:2,pointerEvents:f||s?"none":"auto",touchAction:"none"}:{display:"none",pointerEvents:"none"},[t,f,s]),y=C=>{if(!C||t!=null&&t.isLocked){h(!0),p.current=j.Pending,n(U.None);return}h(!1)},w=(C,D)=>{u.current&&(clearTimeout(u.current),u.current=0);const k={x:D.x,y:D.y};n(U.None),p.current=j.Done,c(k),oe.emitMethod(_.MainEngine,U.TranslateNode,{workIds:[Z],position:k,workState:j.Done,viewId:r==null?void 0:r.viewId})};d.useEffect(()=>(oe.activeListener(y),()=>{oe.unmountActiveListener(y)}),[]),d.useEffect(()=>{if(t&&(t!=null&&t.isLocked)||r!=null&&r.control.worker.isBusy){h(!0);return}h(!1)},[t,r==null?void 0:r.control.worker.isBusy]),d.useEffect(()=>{(p.current===j.Pending||p.current===j.Done)&&x.isNumber(t==null?void 0:t.x)&&x.isNumber(t==null?void 0:t.y)&&c({x:t==null?void 0:t.x,y:t==null?void 0:t.y})},[t==null?void 0:t.x,t==null?void 0:t.y]);const I=()=>{if(r!=null&&r.control.worker.isBusy){h(!0);return}u.current&&(clearTimeout(u.current),u.current=0),x.isNumber(t==null?void 0:t.x)&&x.isNumber(t==null?void 0:t.y)&&(n(U.TranslateNode),p.current=j.Start,oe.emitMethod(_.MainEngine,U.TranslateNode,{workIds:[Z],position:{x:t==null?void 0:t.x,y:t==null?void 0:t.y},workState:j.Start,viewId:r==null?void 0:r.viewId}))},v=(C,D)=>{var L;r!=null&&r.control.worker.isBusy&&h(!0);const k=p.current,P=M.current;if(w(C,D),M.current&&(M.current=void 0),k===j.Start&&(i!=null&&i.size)&&P){const O=(L=r==null?void 0:r.control.viewContainerManager.getView(r.viewId))==null?void 0:L.focusScenePath;O&&(r==null||r.control.worker.blurSelector(r.viewId,O))}r==null||r.focusElement()},S=(C,D)=>{if(r!=null&&r.control.worker.isBusy){h(!0),w(C,D);return}if(u.current)return;const k={x:D.x,y:D.y};c(k),u.current=setTimeout(()=>{u.current=0,(k.x!==(a==null?void 0:a.x)||k.y!==(a==null?void 0:a.y))&&(M.current&&(M.current=void 0),p.current=j.Doing,oe.emitMethod(_.MainEngine,U.TranslateNode,{workIds:[Z],position:k,workState:j.Doing,viewId:r==null?void 0:r.viewId}))},60)},N=d.useMemo(()=>{if(i){const C=k=>{e&&(M.current=k)},D=()=>{r&&e&&p.current===j.Start&&M.current&&r.control.textEditorManager.active(M.current)};return d.createElement(Jp,{editors:i,selectIds:(t==null?void 0:t.selectIds)||[],handleTextEditorPointerDown:C,handleTextEditorPointerUp:D})}return null},[i,t==null?void 0:t.selectIds,r,e]);return d.createElement(Mt,{disabled:l,position:a,onStart:I,onDrag:S,onStop:v},d.createElement("div",{style:g},N))},ry=o=>{const{className:i}=o,[e,t]=d.useState({x:0,y:0,h:0,w:0}),[n,r]=d.useState(),[s,a]=d.useState(),[c,l]=d.useState(),{floatBarData:h,mananger:u,isNoPointerEvents:M,setOperationType:p}=d.useContext(me),[f,g]=d.useState(),[y,w]=d.useState(!1),I=d.useRef(0);d.useEffect(()=>{if(h&&u){const O={x:h.x,y:h.y,w:h.w,h:h.h};t(O)}return oe.activeListener(S),()=>{oe.unmountActiveListener(S)}},[]),d.useEffect(()=>{if(u!=null&&u.control.worker.isBusy){w(!0);return}w(!1)},[u==null?void 0:u.control.worker.isBusy]);const v=()=>{if(I.current&&(clearTimeout(I.current),I.current=0),f){const{scale:O,translate:E}=f;p(U.None),oe.emitMethod(_.MainEngine,U.ScaleNode,{workIds:[Z],scale:O,dir:c,translate:E,originPoint:n,scenePoint:s,workState:j.Done,viewId:u==null?void 0:u.viewId})}u==null||u.focusElement()},S=O=>{if(!O){w(!0);return}w(!1)},N=O=>[[O.x,O.y],[O.x+O.w,O.y],[O.x+O.w,O.y+O.h],[O.x,O.y+O.h]],C=(O,E)=>{switch(E){case"top":case"topLeft":case"left":return O[2];case"topRight":return O[3];case"right":case"bottomRight":case"bottom":return O[0];case"bottomLeft":return O[1]}},D=(O,E,R,z)=>{let V=!1,te=!1;const B={x:e.x,y:e.y,w:e.w,h:e.h},$=[1,1],ie=[0,0];switch(O){case"top":{const H=E.height+e.h;H<0?(te=!0,B.y=e.y+e.h,B.h=Math.abs(H)):(B.y=e.y-E.height,B.h=e.h+E.height);break}case"topLeft":{const H=E.width+e.w;H<0?(V=!0,B.x=e.x+e.w,B.w=Math.abs(H)):(B.x=e.x-E.width,B.w=e.w+E.width);const le=E.height+e.h;le<0?(te=!0,B.y=e.y+e.h,B.h=Math.abs(le)):(B.y=e.y-E.height,B.h=e.h+E.height);break}case"topRight":{const H=E.width+e.w;H<0?(V=!0,B.x=e.x+H,B.w=Math.abs(H)):B.w=e.w+E.width;const le=E.height+e.h;le<0?(te=!0,B.y=e.y+e.h,B.h=Math.abs(le)):(B.y=e.y-E.height,B.h=e.h+E.height);break}case"bottom":{const H=E.height+e.h;H<0?(te=!0,B.y=e.y+H,B.h=Math.abs(H)):B.h=e.h+E.height;break}case"bottomLeft":{const H=E.width+e.w;H<0?(V=!0,B.x=e.x+e.w,B.w=Math.abs(H)):(B.x=e.x-E.width,B.w=e.w+E.width);const le=E.height+e.h;le<0?(te=!0,B.y=e.y+le,B.h=Math.abs(le)):B.h=e.h+E.height;break}case"left":{const H=E.width+e.w;H<0?(V=!0,B.x=e.x+e.w,B.w=Math.abs(H)):(B.x=e.x-E.width,B.w=e.w+E.width);break}case"bottomRight":{const H=E.width+e.w;H<0?(V=!0,B.x=e.x+H,B.w=Math.abs(H)):B.w=e.w+E.width;const le=E.height+e.h;le<0?(te=!0,B.y=e.y+le,B.h=Math.abs(le)):B.h=e.h+E.height;break}case"right":{const H=E.width+e.w;H<0?(V=!0,B.x=e.x+H,B.w=Math.abs(H)):B.w=e.w+E.width;break}}$[0]=B.w/e.w,$[1]=B.h/e.h;const ne=N(B).map(H=>R.control.viewContainerManager.transformToScenePoint(H,R.viewId)),J=C(ne,O);return te&&(ie[1]=J[1]-z[1]),V&&(ie[0]=J[0]-z[0]),{scale:$,translate:ie}},k=(O,E)=>{if(I.current&&(clearTimeout(I.current),I.current=0),u!=null&&u.control.worker.isBusy){w(!0);return}if(h!=null&&h.w&&(h!=null&&h.h)&&u){const R={x:h.x,y:h.y,w:h.w,h:h.h},z=N(R),V=z.map($=>u.control.viewContainerManager.transformToScenePoint($,u.viewId)),te=C(z,E),B=C(V,E);t(R),r(te),a(B),l(E),p(U.ScaleNode),oe.emitMethod(_.MainEngine,U.ScaleNode,{workIds:[Z],originPoint:te,scenePoint:B,workState:j.Start,viewId:u.viewId})}},P=(O,E,R,z)=>{if(!(!u||!n||!s)){if(u!=null&&u.control.worker.isBusy){w(!0),v();return}I.current||(I.current=setTimeout(()=>{I.current=0;const{scale:V,translate:te}=D(E,z,u,s);(!x.isEqual(V,f==null?void 0:f.scale)||!x.isEqual(te,f==null?void 0:f.translate))&&(g({scale:V,translate:te}),p(U.ScaleNode),oe.emitMethod(_.MainEngine,U.ScaleNode,{workIds:[Z],scale:V,dir:E,translate:te,originPoint:n,scenePoint:s,workState:j.Doing,viewId:u.viewId}))},60))}},L=()=>{u!=null&&u.control.worker.isBusy&&w(!0),v()};return d.createElement(Co.Resizable,{className:`${i}`,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",left:h==null?void 0:h.x,top:h==null?void 0:h.y,pointerEvents:M?"none":"auto"},enable:y?!1:{top:(h==null?void 0:h.scaleType)===Ae.all&&!0||!1,right:(h==null?void 0:h.scaleType)===Ae.all&&!0||!1,bottom:(h==null?void 0:h.scaleType)===Ae.all&&!0||!1,left:(h==null?void 0:h.scaleType)===Ae.all&&!0||!1,topRight:!0,bottomRight:!0,bottomLeft:!0,topLeft:!0},lockAspectRatio:(h==null?void 0:h.scaleType)===Ae.proportional,onResizeStart:k,onResize:P,onResizeStop:L})},Sn=o=>{const{id:i,pos:e,pointMap:t,type:n}=o,{setOperationType:r,mananger:s,floatBarData:a}=d.useContext(me),[c,l]=d.useState({x:0,y:0}),[h,u]=d.useState(j.Pending),[M,p]=d.useState(!1),f=d.useRef(0),g=d.useMemo(()=>a?{left:0,top:0}:{},[a]),y=N=>{if(!N||a!=null&&a.isLocked){p(!0),u(j.Pending),r(U.None);return}p(!1)};d.useEffect(()=>(oe.activeListener(y),()=>{oe.unmountActiveListener(y)}),[]),d.useEffect(()=>{x.isNumber(e.x)&&x.isNumber(e.y)&&(h===j.Pending||h===j.Done)&&l({x:e.x,y:e.y})},[e,h]),d.useEffect(()=>{if(a&&(a!=null&&a.isLocked)||s!=null&&s.control.worker.isBusy){p(!0);return}p(!1)},[a,s==null?void 0:s.control.worker.isBusy]);const w=(N,C)=>{f.current&&(clearTimeout(f.current),f.current=0),r(U.None),u(j.Done);const D={x:C.x,y:C.y};if(l(D),s!=null&&s.control.viewContainerManager){const k=s.control.viewContainerManager.transformToScenePoint([D.x,D.y],s.viewId),P=t.get(i);P&&n==="start"?P[0]=k:P&&n==="end"&&(P[1]=k),oe.emitMethod(_.MainEngine,U.SetPoint,{workId:Z,pointMap:t,workState:j.Done,viewId:s==null?void 0:s.viewId})}s==null||s.focusElement()},I=()=>{if(f.current&&(clearTimeout(f.current),f.current=0),s!=null&&s.control.worker.isBusy){p(!0);return}x.isNumber(e.x)&&x.isNumber(e.y)&&(r(U.SetPoint),u(j.Start),oe.emitMethod(_.MainEngine,U.SetPoint,{workId:Z,pointMap:t,workState:j.Start,viewId:s==null?void 0:s.viewId}))},v=(N,C)=>{if(s!=null&&s.control.worker.isBusy){p(!0),w(N,C);return}if(f.current)return;const D={x:C.x,y:C.y};l(D),f.current=setTimeout(()=>{if(f.current=0,(D.x!==(C==null?void 0:C.x)||D.y!==(C==null?void 0:C.y))&&(s!=null&&s.control.viewContainerManager)){const k=s.control.viewContainerManager.transformToScenePoint([D.x,D.y],s.viewId),P=t.get(i);P&&n==="start"?P[0]=k:P&&n==="end"&&(P[1]=k),u(j.Doing),oe.emitMethod(_.MainEngine,U.SetPoint,{workId:Z,pointMap:t,workState:j.Doing,viewId:s==null?void 0:s.viewId})}},60)},S=(N,C)=>{s!=null&&s.control.worker.isBusy&&p(!0),w(N,C)};return d.createElement(Mt,{disabled:M,position:c,onStart:I,onDrag:v,onStop:S},d.createElement("div",{className:"appliance-plugin-point-draggable-btn",style:g}))},sy=o=>{const{className:i}=o,{floatBarData:e,mananger:t}=d.useContext(me),[n,r]=d.useState(),[s,a]=d.useState(),[c,l]=d.useState(new Map);d.useEffect(()=>{const M=[];if(t&&(e!=null&&e.points)){const p=t.viewId;if(t.control.viewContainerManager.getView(p))for(const g of e.points){const y=t.control.viewContainerManager.transformToOriginPoint(g,p);M.push(y)}e!=null&&e.selectIds&&e.selectIds.length===1&&(c.set(e.selectIds[0],e.points),l(c))}M[0]&&r({x:M[0][0],y:M[0][1]}),M[1]&&a({x:M[1][0],y:M[1][1]})},[t,e==null?void 0:e.points,e==null?void 0:e.selectIds,c]);const h=d.useMemo(()=>n&&(e!=null&&e.selectIds)?d.createElement(Sn,{pos:n,type:"start",id:e.selectIds[0],pointMap:c}):null,[n,e==null?void 0:e.selectIds,c]),u=d.useMemo(()=>s&&(e!=null&&e.selectIds)?d.createElement(Sn,{pos:s,type:"end",id:e.selectIds[0],pointMap:c}):null,[s,e==null?void 0:e.selectIds,c]);return d.createElement("div",{className:`${i}`},h,u)},ay=d.forwardRef((o,i)=>{const{floatBarData:e,operationType:t}=d.useContext(me),n=d.useMemo(()=>(e==null?void 0:e.scaleType)!==Ae.all||t===U.RotateNode?null:d.createElement(_p,null),[e,t]),r=d.useMemo(()=>(e==null?void 0:e.scaleType)!==Ae.both||t===U.RotateNode?null:d.createElement(ey,null),[e,t]),s=d.useMemo(()=>(e==null?void 0:e.scaleType)!==Ae.proportional||t===U.RotateNode?null:d.createElement(ty,null),[e,t]),a=d.useMemo(()=>(e==null?void 0:e.scaleType)===Ae.none&&(e!=null&&e.canLock)?d.createElement(iy,null):null,[e]);return d.createElement("div",{ref:i,style:e?{transform:`translate(${e.x}px,${e.y}px)`,width:e.w,height:e.h,pointerEvents:"none"}:void 0},a,n,r,s,o.children)}),cy=d.forwardRef((o,i)=>{const{floatBarData:e,operationType:t,mananger:n}=d.useContext(me),{editors:r,isHide:s,canSelectorSwitch:a}=o,c=d.useMemo(()=>{var M;return e!=null&&e.canRotate&&((M=e==null?void 0:e.selectIds)==null?void 0:M.length)===1&&(t===U.None||t===U.RotateNode)?d.createElement(ny,{className:xe.RotateBtn}):null},[e,t]),l=d.useMemo(()=>((e==null?void 0:e.scaleType)===Ae.all||(e==null?void 0:e.scaleType)===Ae.proportional)&&(t===U.None||t===U.ScaleNode)&&x.isNumber(e==null?void 0:e.x)&&x.isNumber(e==null?void 0:e.y)?d.createElement(ry,{className:xe.ResizeBtn}):null,[e==null?void 0:e.scaleType,t,e==null?void 0:e.x,e==null?void 0:e.y]),h=d.useMemo(()=>(e==null?void 0:e.scaleType)===Ae.both&&(t===U.None||t===U.SetPoint)?d.createElement(sy,{className:xe.ResizeTowBox}):null,[e==null?void 0:e.scaleType,t]),u=d.useMemo(()=>s&&t===U.None&&x.isNumber(e==null?void 0:e.x)&&x.isNumber(e==null?void 0:e.y)&&x.isNumber(e==null?void 0:e.w)&&x.isNumber(e==null?void 0:e.h)?d.createElement("div",{className:xe.FloatBarBtn,style:{left:e==null?void 0:e.x,top:e==null?void 0:e.y,width:e.w,height:e.h}},d.createElement(No,{position:{x:e.x,y:e.y},textOpt:e==null?void 0:e.textOpt,noLayer:e==null?void 0:e.isLocked})):null,[e==null?void 0:e.x,e==null?void 0:e.y,e==null?void 0:e.w,e==null?void 0:e.h,e==null?void 0:e.textOpt,e==null?void 0:e.isLocked,t,s]);return d.createElement("div",{className:xe.FloatBar,onPointerOver:M=>(kt(M),n==null||n.control.worker.blurCursor(n.viewId),!1)},d.createElement(ay,{ref:i}),d.createElement(oy,{editors:r,canSelectorSwitch:a}),c,l,h,u)}),ly=d.memo(cy,(o,i)=>!!x.isEqual(o,i));class uy extends d.Component{constructor(e){super(e);m(this,"renderAvatar",e=>{var n;const t=`rgb(${e.memberState.strokeColor[0]}, ${e.memberState.strokeColor[1]}, ${e.memberState.strokeColor[2]})`;if(this.detectAvatar(e)){const r=this.getCursorName(e);return d.createElement("img",{className:"cursor-selector-avatar",style:{width:r?19:28,height:r?19:28,position:r?"initial":"absolute",borderColor:r?"white":t,marginRight:r?4:0},src:(n=e.payload)==null?void 0:n.avatar,alt:"avatar"})}else return null});m(this,"getOpacity",e=>{const t=this.getCursorName(e),n=this.detectAvatar(e);return t===void 0&&n===void 0?0:1});m(this,"getCursorName",e=>{if(e.payload)return e.payload.nickName||e.payload.cursorName||e.payload.uid});m(this,"getThemeClass",e=>e.payload&&e.payload.theme?"cursor-inner-mellow":"cursor-inner");m(this,"getCursorBackgroundColor",e=>{const t=this.getCursorName(e);return e.payload&&e.payload.cursorBackgroundColor?e.payload.cursorBackgroundColor:t?`rgb(${e.memberState.strokeColor[0]}, ${e.memberState.strokeColor[1]}, ${e.memberState.strokeColor[2]})`:void 0});m(this,"getCursorTextColor",e=>e.payload&&e.payload.cursorTextColor?e.payload.cursorTextColor:"#FFFFFF");m(this,"getCursorTagBackgroundColor",e=>e.payload&&e.payload.cursorTagBackgroundColor?e.payload.cursorTagBackgroundColor:this.getCursorBackgroundColor(e));m(this,"detectAvatar",e=>!!(e.payload&&e.payload.avatar));m(this,"renderTag",e=>{if(e.payload&&e.payload.cursorTagName)return d.createElement("span",{className:"cursor-tag-name",style:{backgroundColor:this.getCursorTagBackgroundColor(e)}},e.payload.cursorTagName)});m(this,"renderCursor",e=>{const t=Pp.get(e);return t&&this.props.isEnableCursor?d.createElement("img",{className:`cursor-${e}-image`,src:t,alt:`${e}Cursor`}):null})}render(){const{roomMember:e}=this.props,t=this.getCursorName(e);switch(e.memberState.currentApplianceName){case ee.pencil:return d.createElement("div",{className:"cursor-box"},d.createElement("div",{className:"cursor-mid cursor-pencil-offset",style:{transform:"translate(-50%, -100%)",marginLeft:"5px",marginTop:"4px"}},d.createElement("div",{className:"cursor-name"},d.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),d.createElement("span",{className:"cursor-name-text"},t),this.renderTag(e))),d.createElement("div",null,this.renderCursor("pencil"))));case ee.selector:return d.createElement("div",{className:"cursor-box"},d.createElement("div",{className:"cursor-mid cursor-selector-offset",style:{transform:"translate(-50%, -100%)",marginLeft:"3px",marginTop:"17px"}},d.createElement("div",{className:"cursor-name"},d.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),d.createElement("span",{className:"cursor-name-text"},t),this.renderTag(e))),d.createElement("div",null,this.renderCursor("selector"))));case ee.eraser:case ee.pencilEraser:return d.createElement("div",{className:"cursor-box"},d.createElement("div",{className:"cursor-mid cursor-eraser-offset",style:{transform:"translate(-50%, -100%)",marginLeft:"2px",marginTop:"8px"}},d.createElement("div",{className:"cursor-name"},d.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),d.createElement("span",{className:"cursor-name-text"},t),this.renderTag(e))),d.createElement("div",null,this.renderCursor("eraser"))));case ee.text:return d.createElement("div",{className:"cursor-box"},d.createElement("div",{className:"cursor-mid cursor-text-offset",style:{transform:"translate(-50%, -100%)",marginLeft:"0px"}},d.createElement("div",{className:"cursor-name"},d.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),d.createElement("span",{className:"cursor-name-text"},t),this.renderTag(e))),d.createElement("div",null,this.renderCursor("text"))));case ee.rectangle:case ee.arrow:case ee.straight:case ee.shape:case ee.ellipse:return d.createElement("div",{className:"cursor-box"},d.createElement("div",{className:"cursor-mid cursor-shape-offset",style:{transform:"translate(-50%, -100%)",marginLeft:"-3px",marginTop:"19px"}},d.createElement("div",{className:"cursor-name"},d.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),d.createElement("span",{className:"cursor-name-text"},t),this.renderTag(e))),d.createElement("div",null,this.renderCursor("shape"))));default:return null}}}const hy=o=>{var s;const{className:i,info:e,isEnableCursor:t}=o,{roomMember:n,...r}=e||{};return d.createElement("div",{"data-cursor-uid":(s=n==null?void 0:n.payload)==null?void 0:s.uid,className:`${i}`,style:r?{transform:`translate(${r.x}px, ${r.y}px)`}:{display:"none"}},n&&d.createElement(uy,{roomMember:n,isEnableCursor:t}))},dy=o=>{const{className:i,manager:e}=o,[t,n]=d.useState();d.useEffect(()=>(e.internalMsgEmitter.on([_.Cursor,e.viewId],r),()=>{e.internalMsgEmitter.off([_.Cursor,e.viewId],r)}),[e]);function r(a){n(a)}return d.useMemo(()=>{if(t!=null&&t.length){const a=t.map(c=>{var l;return c.roomMember?d.createElement(hy,{key:(l=c.roomMember)==null?void 0:l.memberId,className:i,info:c,isEnableCursor:e.control.cursor.isEnableCursor}):null});return d.createElement(d.Fragment,null,a)}return null},[t])},gy=o=>{const{viewId:i,miniMapCanvas:e,highlightColor:t,miniMapManager:n,contianer:r}=o,[s,a]=d.useState();d.useEffect(()=>(c(),n.listener.addListener([i,"viewCameraUpate"],c),n.listener.emitAsync([i,"miniMapCreate"],!0),()=>{n.listener.removeListener([i,"viewCameraUpate"],c)}),[]);const c=()=>{const u=n.maps.get(i);u&&l(u.miniMapCamera,u.viewCamera)},l=(u,M)=>{const{width:p,height:f}=r.getBoundingClientRect(),g=Math.min(p/u.width,f/u.height),y=M.width/M.scale,w=M.height/M.scale,I=[M.centerX,M.centerY],v=[u.centerX,u.centerY],S=[I[0]-v[0],I[1]-v[1]],N=Math.min(u.scale*g,u.scale*g),C=[S[0]*N,S[1]*N,y,w,N];a(C)},h=u=>{var M;if(n.control.renderControl.isWritable){const p=u.nativeEvent.target||u.nativeEvent.srcElement;if(p&&u.nativeEvent&&s){const{width:f,height:g}=p.getBoundingClientRect(),[y,w]=[f/2,g/2],[I,v]=[(u.nativeEvent.offsetX-y)/s[4],(u.nativeEvent.offsetY-w)/s[4]],S=n.maps.get(i);if(S!=null&&S.viewCamera){const[N,C]=[S.miniMapCamera.centerX+I,S.miniMapCamera.centerY+v];(M=n.control.room)==null||M.moveCamera({centerX:N,centerY:C,animationMode:"immediately"})}}}};return d.createElement("div",{style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",pointerEvents:"auto"},onClick:h},d.createElement("canvas",{style:{pointerEvents:"none"},ref:e}),s&&d.createElement("div",{className:"minimap-highlightBox",style:{position:"absolute",top:"50%",left:"50%",width:s[2]*s[4],height:s[3]*s[4],boxSizing:"content-box",border:`2px solid ${t}`,transform:`translate(calc(-50% + ${s[0]}px), calc(-50% + ${s[1]}px))`,pointerEvents:"none"}}))},My=o=>{const{miniMapManager:i,active:e,className:t}=o,n=d.useMemo(()=>{const r=i.maps;if(e){const s=r.get(e);if(s){const{miniMapCamera:a,viewCamera:c,...l}=s;if(l.contianer&&a&&c){const h=i.highlightColor;return Vt.createPortal(d.createElement(gy,{viewId:e,...l,highlightColor:h,miniMapManager:i}),l.contianer)}}}return null},[e,i]);return d.createElement("div",{className:t},n)},me=d.createContext({viewId:"",mananger:void 0,floatBarColors:[],floatBarData:void 0,dpr:1,angle:0,operationType:U.None,scale:[1,1],isNoPointerEvents:!1,activeTextEditor:!1,activeTextId:void 0,setAngle:()=>{},setOperationType:()=>{},setFloatBarData:()=>{}});class Wi extends d.Component{constructor(e){var n,r;super(e);m(this,"showTextFloatBar");m(this,"canSelectorSwitch");m(this,"rightBoundBreak");m(this,"setAngle",e=>{this.setState({angle:e})});m(this,"setOperationType",e=>{this.setState({operationType:e})});this.state={floatBarData:void 0,showFloatBar:!1,showFloatBarBtn:!0,dpr:1,angle:0,operationType:U.None,scale:[1,1],editors:this.editors,activeTextId:(n=this.props.mananger.control.textEditorManager)==null?void 0:n.activeId,activeMiniMapViewId:(r=this.props.mananger.control.miniMapManager)==null?void 0:r.activeViewId};const t=this.props.mananger.control.pluginOptions.extras.textEditor;this.showTextFloatBar=x.isBoolean(t.showFloatBar)?t.showFloatBar:we.textEditor.showFloatBar,this.canSelectorSwitch=x.isBoolean(t==null?void 0:t.canSelectorSwitch)?t.canSelectorSwitch:we.textEditor.canSelectorSwitch,this.rightBoundBreak=x.isBoolean(t==null?void 0:t.rightBoundBreak)?t.rightBoundBreak:we.textEditor.rightBoundBreak}get editors(){return bt(this.props.mananger.control.textEditorManager.filterEditor(this.props.mananger.viewId))}componentDidMount(){this.props.mananger.vDom=this,this.props.mananger.mountView(),this.setState({dpr:this.props.mananger.dpr})}componentWillUnmount(){}setActiveMiniMap(e){this.setState({activeMiniMapViewId:e})}showFloatBarBtn(e){this.setState({showFloatBarBtn:e})}showFloatBar(e,t){const n=e&&t&&{...this.state.floatBarData,...t}||void 0;this.setState({showFloatBar:e,floatBarData:n,angle:0})}activeTextEditor(){this.setState({activeTextEditor:!0})}unActiveTextEditor(){this.setState({activeTextEditor:!1})}updateTextEditorInfo(e){this.setState({activeTextId:e,editors:this.editors})}setFloatBarData(e){this.state.floatBarData&&this.setState({floatBarData:{...this.state.floatBarData,...e}})}render(){var t,n,r,s,a,c;const e=!!((n=(t=this.props.mananger.control)==null?void 0:t.room)!=null&&n.floatBarOptions);return d.createElement("div",{className:xe.Container},!this.props.mananger.control.hasOffscreenCanvas&&d.createElement("div",{className:xe.CanvasBox,ref:this.props.refs.canvasContainerRef})||d.createElement("div",{className:xe.CanvasBox},d.createElement("canvas",{id:"bgCanvas",ref:this.props.refs.canvasBgRef,style:{width:"100%",height:"100%"}}),d.createElement("canvas",{id:"serviceCanvas",className:xe.FloatCanvas,ref:this.props.refs.canvasServiceFloatRef,style:{width:"100%",height:"100%"}}),d.createElement("canvas",{id:"localCanvas",className:xe.FloatCanvas,ref:this.props.refs.canvasFloatRef,style:{width:"100%",height:"100%"}}),!this.props.mananger.control.isUseSimple&&d.createElement("div",{id:"subLocalCanvas",className:xe.CanvasBoxSub,ref:this.props.refs.subLocalCanvasContainerRef}),!this.props.mananger.control.isUseSimple&&d.createElement("canvas",{id:"topCanvas",className:xe.TopFloatCanvas,ref:this.props.refs.canvasTopRef,style:{width:"100%",height:"100%"}})),!this.props.mananger.control.hasOffscreenCanvas&&this.props.refs.snapshotContainerRef&&d.createElement("div",{className:xe.SnapshotBox,ref:this.props.refs.snapshotContainerRef})||null,d.createElement(me.Provider,{value:{viewId:this.props.viewId,mananger:this.props.mananger,floatBarColors:e&&((a=(s=(r=this.props.mananger.control)==null?void 0:r.room)==null?void 0:s.floatBarOptions)==null?void 0:a.colors)||[],isNoPointerEvents:!this.state.showFloatBarBtn,floatBarData:this.state.floatBarData,dpr:this.state.dpr,angle:this.state.angle,operationType:this.state.operationType,scale:this.state.scale,activeTextEditor:this.state.activeTextEditor,activeTextId:this.state.activeTextId,setAngle:this.setAngle.bind(this),setOperationType:this.setOperationType.bind(this),setFloatBarData:this.setFloatBarData.bind(this)}},this.state.showFloatBar&&d.createElement(ly,{ref:this.props.refs.floatBarRef,editors:this.state.editors,isHide:e&&this.state.showFloatBarBtn,canSelectorSwitch:this.canSelectorSwitch})||null,((c=this.state.editors)==null?void 0:c.size)&&d.createElement(Kp,{className:xe.TextEditorContainer,showFloatBtns:this.showTextFloatBar&&e&&this.state.showFloatBarBtn||!1,editors:this.state.editors,rightBoundBreak:this.rightBoundBreak})||null),d.createElement(dy,{className:xe.CursorBox,manager:this.props.mananger}),!this.props.mananger.control.isUseSimple&&d.createElement(My,{className:xe.MiniMapBox,active:this.state.activeMiniMapViewId,miniMapManager:this.props.mananger.control.miniMapManager}))}}class fy extends Io{constructor(e,t){super(e,t);m(this,"width",1e3);m(this,"height",1e3);m(this,"dpr",gt());m(this,"vDom");m(this,"eventTragetElement");m(this,"snapshotContainerRef");m(this,"canvasContainerRef",d.createRef());m(this,"subLocalCanvasContainerRef");m(this,"canvasTopRef");m(this,"canvasServiceFloatRef",d.createRef());m(this,"canvasFloatRef",d.createRef());m(this,"canvasBgRef",d.createRef());m(this,"floatBarRef",d.createRef());m(this,"containerOffset",{x:0,y:0});this.control.hasOffscreenCanvas||(this.snapshotContainerRef=d.createRef()),this.control.isUseSimple||(this.canvasTopRef=d.createRef(),this.subLocalCanvasContainerRef=d.createRef())}setCanvassStyle(){var e;if(this.eventTragetElement){const t=this.eventTragetElement.offsetWidth||this.width,n=this.eventTragetElement.offsetHeight||this.height,r=gt();r!==this.dpr&&(this.dpr=r,this.control.worker.updateDpr(this.viewId,this.dpr)),t&&n&&this.canvasContainerRef.current&&(t!==this.width||n!==this.height)&&(this.width=t,this.height=n,this.canvasContainerRef.current.style.width=`${t}px`,this.canvasContainerRef.current.style.height=`${n}px`),t&&n&&this.snapshotContainerRef&&this.snapshotContainerRef.current&&(t!==this.width||n!==this.height)&&(this.width=t,this.height=n),t&&n&&this.canvasBgRef.current&&(t!==this.width||n!==this.height)&&(this.width=t,this.height=n,this.control.isUseOffscreenTransfer||(this.canvasBgRef.current.width=t*this.dpr,this.canvasBgRef.current.height=n*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=t*this.dpr,this.canvasFloatRef.current.height=n*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=t*this.dpr,this.canvasServiceFloatRef.current.height=n*this.dpr),(e=this.canvasTopRef)!=null&&e.current&&(this.canvasTopRef.current.width=t*this.dpr,this.canvasTopRef.current.height=n*this.dpr)))}}destroy(){if(super.destroy(),this.eventTragetElement){const e=this.eventTragetElement.parentElement;if(e){const t=e.querySelectorAll(".appliance-plugin-main-view-displayer");for(const n of t)n.remove()}}}createMainViewDisplayer(e){const t=document.createElement("div");return t.className="appliance-plugin-main-view-displayer",e.appendChild(t),this.eventTragetElement=e.children[0],this.containerOffset=this.getContainerOffset(this.eventTragetElement,this.containerOffset),this.bindToolsClass(),Vt.render(d.createElement(Wi,{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 py extends rp{constructor(e,t,n){super(e,t,n);m(this,"dpr",gt());m(this,"width",1e3);m(this,"height",1e3);m(this,"vDom");m(this,"eventTragetElement");m(this,"canvasContainerRef",d.createRef());m(this,"subLocalCanvasContainerRef");m(this,"canvasTopRef");m(this,"canvasServiceFloatRef",d.createRef());m(this,"canvasFloatRef",d.createRef());m(this,"canvasBgRef",d.createRef());m(this,"floatBarRef",d.createRef());m(this,"containerOffset",{x:0,y:0});this.control.isUseSimple||(this.canvasTopRef=d.createRef(),this.subLocalCanvasContainerRef=d.createRef())}setCanvassStyle(){var e;if(this.eventTragetElement){const t=gt();if(t!==this.dpr&&(this.dpr=t,this.control.worker.updateDpr(this.viewId,this.dpr)),this.canvasContainerRef.current){const n=this.eventTragetElement.offsetWidth||this.width,r=this.eventTragetElement.offsetHeight||this.height;n&&r&&(n!==this.width||r!==this.height)&&(this.width=n,this.height=r,this.canvasContainerRef.current.style.width=`${n}px`,this.canvasContainerRef.current.style.height=`${r}px`)}if(this.canvasBgRef.current){const n=this.eventTragetElement.offsetWidth||this.width,r=this.eventTragetElement.offsetHeight||this.height;n&&r&&(n!==this.width||r!==this.height)&&(this.width=n,this.height=r,this.control.isUseOffscreenTransfer||(this.canvasBgRef.current.width=n*this.dpr,this.canvasBgRef.current.height=r*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=n*this.dpr,this.canvasFloatRef.current.height=r*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=n*this.dpr,this.canvasServiceFloatRef.current.height=r*this.dpr),(e=this.canvasTopRef)!=null&&e.current&&(this.canvasTopRef.current.width=n*this.dpr,this.canvasTopRef.current.height=r*this.dpr)))}}}createAppViewDisplayer(e,t){const n=document.createElement("div");return n.className="appliance-plugin-app-view-displayer",t.appendChild(n),this.eventTragetElement=t.children[0],this.containerOffset=this.getContainerOffset(this.eventTragetElement,this.containerOffset),this.bindToolsClass(),Vt.render(d.createElement(Wi,{viewId:e,mananger:this,refs:{canvasServiceFloatRef:this.canvasServiceFloatRef,canvasFloatRef:this.canvasFloatRef,canvasBgRef:this.canvasBgRef,floatBarRef:this.floatBarRef,canvasTopRef:this.canvasTopRef,canvasContainerRef:this.canvasContainerRef,subLocalCanvasContainerRef:this.subLocalCanvasContainerRef}}),n),this.control.room&&this.bindDisplayerEvent(this.eventTragetElement),this}}class Le extends dt{constructor(e){super(e);m(this,"focuedViewId");m(this,"focuedView");m(this,"control");m(this,"tmpFocusedViewId");m(this,"checkScaleTimer");m(this,"onMainViewRelease",async e=>{this.control.textEditorManager.clear(ue,!0),this.mainViewDestroy(e),await new Promise(n=>{setTimeout(()=>{n(!0)},0)}),this.onMainViewMounted(e);const t=this.control.getSnapshootData("memberState");this.control.room&&this.control.onMemberChange(t),this.control.clearSnapshootData()});m(this,"mainViewDestroy",e=>{var t;if(this.mainView&&this.mainView.displayer){this.mainView.displayer.destroy();const n=e.divElement;if(n){const r=n.getElementsByClassName("appliance-plugin-main-view-displayer");for(const s of r)s.remove()}if(this.mainView.container&&n!==this.mainView.container){const r=this.mainView.container.getElementsByClassName("appliance-plugin-main-view-displayer");for(const s of r)s.remove()}(t=this.control.worker)==null||t.destroyViewWorker(this.mainView.id,!0),this.mainView.displayer.destroy(),this.mainView=void 0}});m(this,"onMainViewMounted",e=>{const t=e.divElement;if(!t||!e.focusScenePath||!(e.focusScenePath||e.scenePath))return;const r=new fy(this.control,Te.InternalMsgEmitter),s=e.size.width||r.width,a=e.size.height||r.height,l={dpr:r.dpr,originalPoint:[s/2,a/2],offscreenCanvasOpt:{...Le.defaultScreenCanvasOpt,width:s,height:a},layerOpt:{...Le.defaultLayerOpt,width:s,height:a},cameraOpt:{...Le.defaultCameraOpt,width:s,height:a}},{scale:h,...u}=e.camera;l.cameraOpt={...l.cameraOpt,...u,scale:h===1/0?1:h},this.createMianView({id:ue,container:t,displayer:r,focusScenePath:e.focusScenePath,cameraOpt:l.cameraOpt,viewData:e}),this.setFocuedViewId(ue),r.createMainViewDisplayer(t),e.callbacks.on("onSizeUpdated",this.onMainViewSizeUpdated),e.callbacks.on("onCameraUpdated",this.onMainViewCameraUpdated),e.callbacks.on("onActiveHotkey",this.onActiveHotkeyChange.bind(this))});m(this,"onMainViewSizeUpdated",async()=>{await new Promise(e=>{setTimeout(()=>{e(!0)},0)}),this.mainView&&this.mainView.viewData&&this.updateMainViewCamera()});m(this,"onMainViewCameraUpdated",async()=>{await new Promise(e=>{setTimeout(()=>{e(!0)},0)}),this.updateMainViewCamera()});m(this,"updateMainViewCamera",()=>{if(this.mainView&&this.mainView.viewData){const e=this.mainView.viewData.camera;if(!x.isNumber(e.scale)||e.scale===1/0)return;const t=this.mainView.cameraOpt;if(t){const n=t.width,r=t.height,{width:s,height:a}=this.mainView.viewData.size;(s!==n||a!==r)&&this.mainView.displayer.updateSize();const c=e.scale===1/0?1:e.scale,l=e.centerX||0,h=e.centerY||0,u={...t,scale:c,centerX:l,centerY:h,width:s,height:a};x.isEqual(t,u)||(this.mainView.cameraOpt=u),this.checkScaleTimer&&e.scale==1/0&&(clearTimeout(this.checkScaleTimer),this.checkScaleTimer=void 0),!this.checkScaleTimer&&e.scale===1/0&&this.mainView.viewData&&this.mainView.viewData.camera.scale===1/0&&(this.checkScaleTimer=setTimeout(()=>{var M,p;(p=(M=this.mainView)==null?void 0:M.viewData)==null||p.moveCamera({scale:c,centerX:l,centerY:h,animationMode:"immediately"}),this.checkScaleTimer=void 0},500))}}});m(this,"onAppViewMounted",async e=>{var M;const{appId:t,view:n}=e,r=n.divElement;if(!r||!n.focusScenePath)return;const s=this.appViews.get(t);if(s&&s.displayer){let p=r.getElementsByClassName("appliance-plugin-app-view-displayer");for(const f of p)f.remove();if(s.container&&s.container!==r){p=s.container.getElementsByClassName("appliance-plugin-app-view-displayer");for(const f of p)f.remove()}this.destroyAppView(e.appId,!0),(M=this.control.worker)==null||M.destroyViewWorker(t,!0),await new Promise(f=>{setTimeout(()=>{f(!0)},0)})}const a=new py(t,this.control,Te.InternalMsgEmitter),c=n.size.width||a.width,l=n.size.height||a.height,u={dpr:a.dpr,originalPoint:[c/2,l/2],offscreenCanvasOpt:{...Le.defaultScreenCanvasOpt,width:c,height:l},layerOpt:{...Le.defaultLayerOpt,width:c,height:l},cameraOpt:{...Le.defaultCameraOpt,...n.camera,width:c,height:l}};if(this.createAppView({id:t,container:r,displayer:a,cameraOpt:u.cameraOpt,focusScenePath:n.focusScenePath,viewData:n}),a.createAppViewDisplayer(t,r),n.callbacks.on("onSizeUpdated",this.onAppViewSizeUpdated.bind(this,t)),n.callbacks.on("onCameraUpdated",this.onAppViewCameraUpdated.bind(this,t)),n.callbacks.on("onActiveHotkey",this.onActiveHotkeyChange.bind(this)),this.tmpFocusedViewId===t){const p=this.control.worker.getLocalWorkViewId();p&&p!==t?this.setFocuedViewId(p):this.setFocuedViewId(t),this.tmpFocusedViewId=void 0}setTimeout(()=>{this.onAppViewCameraUpdated(t)},0)});m(this,"onAppViewSizeUpdated",async e=>{await new Promise(n=>{setTimeout(()=>{n(!0)},0)});const t=this.appViews.get(e);t&&t.viewData&&this.updateAppCamera(e)});m(this,"onAppViewCameraUpdated",async e=>{await new Promise(t=>{setTimeout(()=>{t(!0)},0)}),this.updateAppCamera(e)});m(this,"updateAppCamera",e=>{const t=this.appViews.get(e);if(t&&t.viewData){const n=t.viewData.camera,r=t.cameraOpt;if(r){const{width:s,height:a}=t.viewData.size,c=r.width,l=r.height;(s!==c||a!==l)&&t.displayer.updateSize();const h=n.scale===1/0?1:n.scale,u=n.centerX||0,M=n.centerY||0,p={...r,scale:h,centerX:u,centerY:M,width:s,height:a};x.isEqual(p,r)||(t.cameraOpt=p)}}});this.control=e.control}getViewInitData(e){var n;const t=this.getView(e);if(t){const{width:r,height:s,dpr:a}=t.displayer;(n=this.control.pluginOptions.extras.canvasOpt)!=null&&n.contextType&&(Le.defaultScreenCanvasOpt.contextType=this.control.pluginOptions.extras.canvasOpt.contextType);const c={dpr:a,originalPoint:[r/2,s/2],offscreenCanvasOpt:{...Le.defaultScreenCanvasOpt,width:r,height:s},layerOpt:{...Le.defaultLayerOpt,width:r,height:s},cameraOpt:{...Le.defaultCameraOpt,width:r,height:s}};if(t.viewData){const{scale:l,...h}=t.viewData.camera;c.cameraOpt={...c.cameraOpt,...h,scale:l===1/0?1:l}}return c}}async mountView(e){var n,r;const t=this.getView(e);if(t){e===((n=this.mainView)==null?void 0:n.id)&&(this.control.cursor.activeCollector(),await this.control.activeWorker()),this.control.isUseOffscreenTransfer&&t.displayer.canvasBgRef.current&&t.displayer.canvasServiceFloatRef.current&&t.displayer.canvasFloatRef.current&&t.displayer.setTransferControlToOffscreenCanvas({bgCanvas:t.displayer.canvasBgRef.current,serviceCanvas:t.displayer.canvasServiceFloatRef.current,localCanvas:t.displayer.canvasFloatRef.current});const s=this.getViewInitData(e);if(s&&((r=this.control.worker)==null||r.createViewWorker(e,s,t.displayer)),t.focusScenePath&&this.control.collector){if(this.control.collector.authStorage){const{renderAuth:a,pageAuth:c}=this.control.collector.authStorage;if(a){const l=a[e];if(l){const{render:h,hide:u,clear:M}=l;this.control.renderControl.syncRenderUids(e,h,u,M);return}}if(c){const l=c[e];if(l){this.control.renderControl.syncPageAuth(e,l,!0);return}}}this.control.worker.pullServiceData(e,t.focusScenePath,{isAsync:!0,useAnimation:!1})}}}listenerWindowManager(e){e.emitter.on("focusedChange",t=>{const n=t||ue;if(this.focuedViewId!==n)if(this.getView(n)){const s=this.control.worker.getLocalWorkViewId();s&&s!==n?this.setFocuedViewId(s):this.setFocuedViewId(n)}else this.tmpFocusedViewId=n}),e.emitter.on("mainViewScenePathChange",t=>{this.control.onSceneChange(t,ue)}),e.emitter.on("onMainViewMounted",this.onMainViewMounted),e.emitter.on("onAppViewMounted",this.onAppViewMounted),e.emitter.on("onMainViewRebind",this.onMainViewRelease),e.emitter.on("onBoxClose",t=>{this.appViews.get(t.appId)&&(this.destroyAppView(t.appId),this.control.worker.destroyViewWorker(t.appId))}),e.emitter.on("onAppScenePathChange",t=>{const{appId:n,view:r}=t;this.control.onSceneChange(r.focusScenePath,n)}),e.emitter.on("appsChange",t=>{for(const n of this.appViews.keys())t.includes(n)||(this.destroyAppView(n),this.control.worker.destroyViewWorker(n,!0))})}onActiveHotkeyChange(e){this.control.hotkeyManager.onActiveHotkey(e)}}class qe extends Te{constructor(e){super(e);m(this,"windowManager");m(this,"viewContainerManager");const t={control:this,internalMsgEmitter:Te.InternalMsgEmitter,publicMsgEmitter:Te.PublicMsgEmitter};this.viewContainerManager=new Le(t)}init(){}activePlugin(){this.collector&&(this.collector.addAuthStateListener((e,t)=>{e&&Object.keys(e).forEach(n=>{var s;const r=(s=e[n])==null?void 0:s.newValue;this.renderControl.syncRenderUids(n,r==null?void 0:r.render,r==null?void 0:r.hide,r==null?void 0:r.clear)}),t&&Object.keys(t).forEach(n=>{var s;const r=(s=t[n])==null?void 0:s.newValue;this.renderControl.syncPageAuth(n,r)})}),this.collector.addStorageStateListener(e=>{var a,c;if((a=this.collector)!=null&&a.storage&&Object.keys(this.collector.storage).length===0){(c=this.worker)==null||c.clearViewScenePath(ue,!0);return}const{diffView:t,diffScenePath:n,diffData:r}=e,s=new Map;if(t){let l;Object.keys(t).forEach(h=>{var M;const u=t[h];if(u&&!u.newValue)(M=this.worker)==null||M.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:!1});l=u.newValue}if(l)for(const p of Object.values(l)){const f=new Set;for(const g of Object.keys(p))g&&f.add(g);s.set(h,f)}})}if(n){let l;Object.keys(n).forEach(h=>{var M;const u=n[h];if(u&&u.viewId&&!u.newValue?((M=this.worker)==null||M.clearViewScenePath(u.viewId,!0),u.oldValue&&(l=u.oldValue)):u&&u.viewId&&u.newValue&&(this.worker.pullServiceData(u.viewId,h,{isAsync:!1,useAnimation:!1}),l=u.newValue),u!=null&&u.viewId&&l){const p=new Set;for(const f of Object.keys(l))f&&p.add(f),s.set(u.viewId,p)}})}r&&Object.keys(r).forEach(l=>{var u,M;const h=r[l];if(h){const{viewId:p}=h,f=s.get(p)||new Set;f.add(l),s.set(p,f),(u=this.worker)==null||u.onServiceDerive(l,h),(M=this.miniMapManager)==null||M.updateMiniMapCamera(p)}});for(const[l,h]of s.entries())Te.InternalMsgEmitter.emit("excludeIds",[...h],l)}),this.worker.isActive&&this.viewContainerManager.getAllViews().forEach(e=>{e&&e.focusScenePath&&this.worker.pullServiceData(e.id,e.focusScenePath,{isAsync:!0,useAnimation:!1})}),this.room&&this.roomMember.onUidChangeHook(e=>{var t,n;(t=this.collector)!=null&&t.serviceStorage&&this.viewContainerManager.getAllViews().forEach(r=>{var s,a,c,l;if(r&&r.focusScenePath&&((s=this.collector)!=null&&s.serviceStorage[r.id])&&this.collector.serviceStorage[r.id][r.focusScenePath]){const h=Object.keys(this.collector.serviceStorage[r.id][r.focusScenePath]);for(const u of h){const M=(a=this.collector)==null?void 0:a.getUidFromKey(u);if(M&&!e.online.includes(M))if((c=this.collector)!=null&&c.isSelector(u))this.renderControl.isWritable&&((l=this.collector)==null||l.updateValue(u,void 0,{viewId:r.id,scenePath:r.focusScenePath,isSync:!0})),this.worker.blurSelector(r.id,r.focusScenePath,u);else{const p=this.textEditorManager.editors.get(u);p&&p.opt&&(p.opt.workState===j.Doing||p.opt.workState===j.Start)&&(p.opt.text&&p.opt.text.replace(/\s*,/g,"")?this.textEditorManager.unActive(u):this.textEditorManager.delete(u))}}}}),(n=this.cursor)==null||n.updateRoomMembers(e)}))}async activeWorker(){await this.worker.init()}setWindowManager(e){var t,n,r,s,a;this.windowManager=e,(n=(t=this.windowManager)==null?void 0:t.mainView)!=null&&n.divElement&&this.viewContainerManager.onMainViewMounted(this.windowManager.mainView),(a=(s=(r=this.windowManager.appManager)==null?void 0:r.viewManager)==null?void 0:s.views)!=null&&a.size&&this.windowManager.appManager.viewManager.views.forEach((c,l)=>{this.viewContainerManager.onAppViewMounted({appId:l,view:c})}),this.viewContainerManager.listenerWindowManager(this.windowManager)}}const b=class b extends F.InvisiblePlugin{constructor(){super(...arguments);m(this,"onPhaseChanged",e=>{var t;e===F.RoomPhase.Reconnecting&&((t=b.currentManager)==null||t.setSnapshootData())});m(this,"updateRoomWritable",()=>{var e;(e=b.currentManager)==null||e.onWritableChange(this.displayer.isWritable)});m(this,"roomStateChangeListener",async e=>{var t,n;e!=null&&e.roomMembers&&((t=b.currentManager)==null||t.onRoomMembersChange(e.roomMembers)),!(F.isRoom(this.displayer)&&!this.displayer.isWritable)&&e.memberState&&((n=b.currentManager)==null||n.onMemberChange(e.memberState))})}static async getInstance(e,t){var f;t.options&&(((f=t.options.extras)==null?void 0:f.useWorker)==="mainThread"&&(t.options.cdn.fullWorkerUrl="",t.options.cdn.subWorkerUrl=""),(t.options.extras&&t.options.extras.useWorker!=="mainThread"||!t.options.extras)&&!t.options.cdn.fullWorkerUrl&&!t.options.cdn.subWorkerUrl&&b.logger.error("[ApplianceMultiPlugin] you must adaptor options cdn fullWorkerUrl and subWorkerUrl"));const n=e.displayer,r=n.callbacks.on,s=n.callbacks.off,a=n.callbacks.once,c=e.cleanCurrentScene,l=e.mainView.setMemberState;let h;F.isRoom(n)&&(h=n.setWritable),t!=null&&t.logger&&(b.logger=t.logger);let u=n.getInvisiblePlugin(b.kind);u||(u=await b.createApplianceMultiPlugin(n,b.kind)),n&&u&&b.createCurrentManager(e,{cdn:t.options.cdn,extras:{...we,...t.options.extras}},u),u&&b.currentManager&&(b.currentManager.bindPlugin(u),u.init(n));const M={displayer:n,windowManager:e,currentManager:b.currentManager,maxScreenshotWidth:10*1024,maxScreenshotHeight:10*1024,getBoundingRectAsync:async function(g){var I;b.logger.info("[ApplianceMultiPlugin] getBoundingRectAsync");const y=(e.mainView||n).getBoundingRect(g),w=await((I=b.currentManager)==null?void 0:I.getBoundingRect(g));return!y.width||!y.height?w:Yi(y,w)},screenshotToCanvasAsync:async function(g,y,w,I,v,S){var L;b.logger.info("[ApplianceMultiPlugin] screenshotToCanvasAsync");let N=w,C=I,D=v.scale;N>this.maxScreenshotWidth&&(D=this.maxScreenshotWidth/N*D,N=this.maxScreenshotWidth),C>this.maxScreenshotHeight&&(D=Math.min(this.maxScreenshotHeight/C*D,D),C=this.maxScreenshotHeight),v.scale=D;const k=document.createElement("canvas"),P=k.getContext("2d");k.width=N*(S||1),k.height=C*(S||1),P&&((e.mainView||n).screenshotToCanvas(P,y,N,C,v,S),g.drawImage(k,Math.floor((w-N)/2),Math.floor((I-C)/2),N*(S||1),C*(S||1),0,0,N,C),k.remove()),b.currentManager&&await((L=b.currentManager)==null?void 0:L.screenshotToCanvas(g,y,N,C,v,Math.floor((w-N)/2),Math.floor((I-C)/2)))},scenePreviewAsync:async function(g,y,w,I,v){b.logger.info("[ApplianceMultiPlugin] scenePreviewAsync"),(e.mainView||n).scenePreview(g,y,w,I,v);const S=document.createElement("img");S.className="appliance-plugin-fill-scene-snapshot-img",y.append(S),getComputedStyle(y).position||(y.style.position="relative"),b.currentManager&&await b.currentManager.scenePreview(g,S)},fillSceneSnapshotAsync:async function(g,y,w,I,v){b.logger.info("[ApplianceMultiPlugin] fillSceneSnapshotAsync"),y.innerHTML="",(e.mainView||n).fillSceneSnapshot(g,y,w,I,v);const S=w||e.mainView.size.width,N=I||e.mainView.size.height;let C=await this.getBoundingRectAsync(g);C||(C={originX:0,originY:0,width:S,height:N});let D=Math.max(C==null?void 0:C.width,S),k=Math.max(C==null?void 0:C.height,N),P=1;const L=D>S&&Math.min(S/D,P)||P,O=k>N&&Math.min(N/k,P)||P;L<=O?(D=L<1&&S||D,k=Math.floor(k*L)+1,P=L):L>O&&(k=O<1&&N||k,D=Math.floor(D*O)+1,P=O);const E={scale:P,centerX:C.originX+C.width/2,centerY:C.originY+C.height/2},R=document.createElement("canvas"),z=R.getContext("2d");R.width=D,R.height=k,z&&await this.screenshotToCanvasAsync(z,g,D,k,E,devicePixelRatio);const V=document.createElement("img");V.className="appliance-plugin-fill-scene-snapshot-img",V.src=R.toDataURL(),V.onload=()=>{R.remove()},V.onerror=()=>{R.remove(),V.remove()},y.append(V),getComputedStyle(y).position||(y.style.position="relative")},_callbacksOn:function(g,y){b.logger.info(`[ApplianceMultiPlugin] callbacks ${g}`),(g==="onCanUndoStepsUpdate"||g==="onCanRedoStepsUpdate")&&F.isRoom(n)&&n.isWritable?qe.InternalMsgEmitter.on(g,y):r.call(n.callbacks,g,y)},_callbacksOnce:function(g,y){b.logger.info(`[ApplianceMultiPlugin] callbacks ${g}`),(g==="onCanUndoStepsUpdate"||g==="onCanRedoStepsUpdate")&&F.isRoom(n)&&n.isWritable?qe.InternalMsgEmitter.on(g,y):a.call(n.callbacks,g,y)},_callbacksOff:function(g,y){b.logger.info(`[ApplianceMultiPlugin] callbacks ${g}`),(g==="onCanUndoStepsUpdate"||g==="onCanRedoStepsUpdate")&&F.isRoom(n)&&n.isWritable?qe.InternalMsgEmitter.off(g,y):s.call(n.callbacks,g,y)},canRedoSteps(){if(b.logger.info("[ApplianceMultiPlugin] canRedoSteps"),b.currentManager&&F.isRoom(n)&&!n.disableSerialization){const g=b.currentManager.viewContainerManager.focuedView,y=g==null?void 0:g.focusScenePath;if(g&&y)return g.displayer.commiter.redoStack.filter(w=>w.scenePath===y).length}return 0},canUndoSteps(){if(b.logger.info("[ApplianceMultiPlugin] canUndoSteps"),b.currentManager&&F.isRoom(n)&&!n.disableSerialization){const g=b.currentManager.viewContainerManager.focuedView,y=g==null?void 0:g.focusScenePath;if(g&&y)return g.displayer.commiter.undoStack.filter(w=>w.scenePath===y).length}return 0},undo:function(){return b.logger.info("[ApplianceMultiPlugin] undo"),b.currentManager&&F.isRoom(n)&&!n.disableSerialization?b.currentManager.viewContainerManager.undo():0},redo:function(){return b.logger.info("[ApplianceMultiPlugin] redo"),b.currentManager&&F.isRoom(n)&&!n.disableSerialization?b.currentManager.viewContainerManager.redo():0},cleanCurrentScene:function(){b.logger.info("[ApplianceMultiPlugin] cleanCurrentScene"),b.currentManager&&F.isRoom(n)&&n.isWritable&&(b.currentManager.cleanCurrentScene(),c.call(e))},insertImage:function(g){if(b.logger.info("[ApplianceMultiPlugin] insertImage"),b.currentManager&&F.isRoom(n)&&n.isWritable){const y=b.currentManager.viewContainerManager.focuedViewId||ue;b.currentManager.worker.insertImage(y,g)}},lockImage:function(g,y){if(b.logger.info("[ApplianceMultiPlugin] lockImage"),b.currentManager&&F.isRoom(n)&&n.isWritable){const w=b.currentManager.viewContainerManager.focuedViewId||ue;b.currentManager.worker.lockImage(w,g,y)}},completeImageUpload:function(g,y){if(b.logger.info("[ApplianceMultiPlugin] completeImageUpload"),b.currentManager&&F.isRoom(n)&&n.isWritable){const w=b.currentManager.viewContainerManager.focuedViewId||ue;b.currentManager.worker.completeImageUpload(w,g,y)}},getImagesInformation:function(g){return b.logger.info("[ApplianceMultiPlugin] completeImageUpload"),b.currentManager&&F.isRoom(n)&&n.isWritable?b.currentManager.worker.getImagesInformation(g):[]},insertText:function(g,y,w){if(b.logger.info("[ApplianceMultiPlugin] insertText"),b.currentManager&&F.isRoom(n)&&n.isWritable){const I=b.currentManager.viewContainerManager.focuedViewId||ue;return b.currentManager.textEditorManager.insertText(I,g,y,w)}},updateText:function(g,y){b.logger.info("[ApplianceMultiPlugin] updateText"),b.currentManager&&F.isRoom(n)&&n.isWritable&&b.currentManager.textEditorManager.updateText(g,y)},callbacks:()=>(b.logger.info("[ApplianceMultiPlugin] callbacks bind"),{...n.callbacks,on:M._callbacksOn.bind(M),once:M._callbacksOnce.bind(M),off:M._callbacksOff.bind(M)}),destroy(){b.currentManager&&(b.logger.info("[ApplianceMultiPlugin] destroy"),b.currentManager.destroy(),b.currentManager=void 0)},setMemberState(g){var w;b.logger.info(`[ApplianceMultiPlugin] setMemberState ${JSON.stringify(g)}`);const y=Object.keys(g);if(F.isRoom(n)&&n.isWritable){if(y.includes("currentApplianceName"))if(g.currentApplianceName&&g.currentApplianceName===ee.laserPen){if((w=b.currentManager)!=null&&w.isUseSimple)throw new Error("[ApplianceMultiPlugin] laserPen must be not support in simple mode");g.currentApplianceName=ee.pencil,g.useLaserPen=!0}else g.currentApplianceName&&g.currentApplianceName===ee.pencil&&(g.useLaserPen=!1);l.call(e.mainView,g);return}throw new Error("[ApplianceMultiPlugin] setMemberState must be called in writable room")},createMiniMap:async function(g,y){if(b.logger.info("[ApplianceMultiPlugin] createMiniMap"),b.currentManager&&F.isRoom(n)&&n.isWritable)return b.currentManager.createMiniMap(g,y)},destroyMiniMap:async function(g){if(b.logger.info("[ApplianceMultiPlugin] destroyeMiniMap"),b.currentManager&&F.isRoom(n)&&n.isWritable)return b.currentManager.destroyMiniMap(g)},filterRenderByUid(g,y,w){if(b.logger.info("[ApplianceMultiPlugin] filterRenderByUid"),b.currentManager&&F.isRoom(n)&&n.isWritable)return b.currentManager.filterRenderByUid(g,y,w)},cancelFilterRender(g,y){if(b.logger.info("[ApplianceMultiPlugin] filterRenderByUid"),b.currentManager&&F.isRoom(n)&&n.isWritable)return b.currentManager.cancelFilterRender(g,y)},addListener:(g,y)=>{b.logger.info(`[ApplianceMultiPlugin] addListener ${g}`),qe.PublicMsgEmitter.on(g,y)},removeListener:(g,y)=>{b.logger.info(`[ApplianceMultiPlugin] removeListener ${g}`),qe.PublicMsgEmitter.off(g,y)},usePlugin:g=>{var y;b.logger.info("[ApplianceMultiPlugin] usePlugin",g.kind),(y=b.currentManager)==null||y.usePlugin(g)},getDisableDeviceInputs(){if(b.currentManager&&F.isRoom(n))return b.currentManager.disableDeviceInputs},setDisableDeviceInputs(g){b.logger.info(`[ApplianceMultiPlugin] setDisableDeviceInputs ${g}`),b.currentManager&&F.isRoom(n)&&(b.currentManager.disableDeviceInputs=g)},getDisableCameraTransform(){if(b.currentManager&&F.isRoom(n))return b.currentManager.disableCameraTransform},setDisableCameraTransform(g){b.logger.info(`[ApplianceMultiPlugin] setDisableCameraTransform ${g}`),b.currentManager&&F.isRoom(n)&&(b.currentManager.disableCameraTransform=g)},getDisableEraseImage(){if(b.currentManager&&F.isRoom(n))return b.currentManager.disableEraseImage},setDisableEraseImage(g){b.logger.info(`[ApplianceMultiPlugin] setDisableEraseImage ${g}`),b.currentManager&&F.isRoom(n)&&(b.currentManager.disableEraseImage=g)},setWritable:async function(g){var y;b.logger.info(`[ApplianceMultiPlugin] setWritable ${g}`),F.isRoom(n)&&h&&(await((y=b.currentManager)==null?void 0:y.setWritable(g)),await h.call(n,g))},requestIdleCallback:(g,y)=>{const w=(y==null?void 0:y.timeout)||0,I=performance.now();let v;const S=new MessageChannel;let N;const C=D=>{try{g({didTimeout:D,timeRemaining:()=>{const P=performance.now()-I;return Math.max(0,w-P)}})}catch(k){b.logger.error("[ApplianceMultiPlugin] requestIdleCallback error:",k)}finally{S.port1.close(),S.port2.close(),v!==void 0&&cancelAnimationFrame(v),N!==void 0&&clearTimeout(N)}};return S.port1.onmessage=()=>{v=requestAnimationFrame(()=>{w>0&&performance.now()-I>=w?C(!0):C(!1)})},S.port2.postMessage(null),w>0&&(N=setTimeout(()=>{C(!0)},w)),N||v||0},cancelIdleCallback:g=>{try{clearTimeout(g),cancelAnimationFrame(g)}catch(y){b.logger.error("[ApplianceMultiPlugin] cancelIdleCallback error:",y)}},injectMethodToObject:(g,y)=>{if(b.logger.info(`[ApplianceMultiPlugin] injectMethodToObject ${y}`),typeof g[y]=="function"||typeof g[y]>"u"){(y==="requestIdleCallback"||y==="cancelIdleCallback")&&b.currentManager&&b.currentManager.registerPolyfillMethod(y),g[y]=M[y];return}y==="callbacks"&&(g.callbacks.on=M._callbacksOn.bind(M),g.callbacks.off=M._callbacksOff.bind(M),g.callbacks.once=M._callbacksOnce.bind(M))},blurText:()=>{b.logger.info("[ApplianceMultiPlugin] blurText"),b.currentManager&&F.isRoom(n)&&n.isWritable&&b.currentManager.textEditorManager.checkEmptyTextBlur()},hasElements:(g,y)=>{var w;if(b.logger.info(`[ApplianceMultiPlugin] hasElements ${g}`),b.currentManager&&F.isRoom(n)&&n.isWritable){let I=g;if(!I){const v=b.currentManager.viewContainerManager.focuedView;I=v==null?void 0:v.focusScenePath}if(I){const v=(w=b.currentManager.collector)==null?void 0:w.getScenePathData(I);if(v){const S=Object.values(v);return S.length>0?y?S.some(N=>y(N.toolsType)):!0:!1}return!1}return!1}},getElements:(g,y)=>{var w;if(b.logger.info(`[ApplianceMultiPlugin] getElements ${g}`),b.currentManager&&F.isRoom(n)&&n.isWritable){let I=g;if(!I){const v=b.currentManager.viewContainerManager.focuedView;I=v==null?void 0:v.focusScenePath}if(I){const v=(w=b.currentManager.collector)==null?void 0:w.getScenePathData(I),S=v&&Object.values(v)||[];return v&&S.length>0&&y?S.filter(N=>y(N.toolsType)):S}return[]}},stopDraw:g=>{if(b.logger.info(`[ApplianceMultiPlugin] stopDraw ${g}`),b.currentManager&&F.isRoom(n))return b.currentManager.stopDraw(g)}};M.injectMethodToObject(e,"undo"),M.injectMethodToObject(e,"redo"),M.injectMethodToObject(e,"cleanCurrentScene"),M.injectMethodToObject(e,"insertImage"),M.injectMethodToObject(e,"completeImageUpload"),M.injectMethodToObject(e,"lockImage"),M.injectMethodToObject(e,"insertText"),M.injectMethodToObject(e,"updateText"),M.injectMethodToObject(n,"getImagesInformation"),M.injectMethodToObject(n,"callbacks"),M.injectMethodToObject(n,"screenshotToCanvasAsync"),M.injectMethodToObject(n,"getBoundingRectAsync"),M.injectMethodToObject(n,"scenePreviewAsync"),M.injectMethodToObject(n,"fillSceneSnapshotAsync"),M.injectMethodToObject(e.mainView,"setMemberState"),F.isRoom(n)&&M.injectMethodToObject(n,"setWritable"),Object.defineProperty(e,"canUndoSteps",{get(){return M.canUndoSteps()}}),Object.defineProperty(e,"canRedoSteps",{get(){return M.canRedoSteps()}}),qe.InternalMsgEmitter.on("onCanUndoStepsUpdate",g=>{e.emitter.emit("canUndoStepsChange",g)}),qe.InternalMsgEmitter.on("onCanRedoStepsUpdate",g=>{e.emitter.emit("canRedoStepsChange",g)});const p={...M,callbacks:M.callbacks()};return Object.defineProperty(p,"disableDeviceInputs",{set(g){M.setDisableDeviceInputs(g)},get(){return M.getDisableDeviceInputs()}}),Object.defineProperty(p,"disableCameraTransform",{set(g){M.setDisableCameraTransform(g)},get(){return M.getDisableCameraTransform()}}),Object.defineProperty(p,"disableEraseImage",{set(g){M.setDisableEraseImage(g)},get(){return M.getDisableEraseImage()}}),e._appliancePlugin=p,e._appliancePlugin}static onCreate(e){e&&b.currentManager&&(b.currentManager.bindPlugin(e),e.init(e.displayer))}static async createApplianceMultiPlugin(e,t){try{await e.createInvisiblePlugin(b,{})}catch(r){if(!e.isWritable){await e.setWritable(!0);const s=await this.createApplianceMultiPlugin(e,t);return await e.setWritable(!1),s}throw r}let n=e.getInvisiblePlugin(t);return n||(n=await b.createApplianceMultiPlugin(e,t)),n}get isReplay(){return F.isPlayer(this.displayer)}get callbackName(){return this.isReplay?"onPlayerStateChanged":"onRoomStateChanged"}init(e){var n,r;const t=e.state;(n=b.currentManager)==null||n.onRoomMembersChange(t.roomMembers),F.isRoom(e)&&((r=b.currentManager)==null||r.onMemberChange(t.memberState)),this.displayer.callbacks.on(this.callbackName,this.roomStateChangeListener),this.displayer.callbacks.on("onEnableWriteNowChanged",this.updateRoomWritable),this.displayer.callbacks.on("onPhaseChanged",this.onPhaseChanged)}destroy(){var e;b.logger.info("[ApplianceMultiPlugin] passive destroy"),(e=b.currentManager)==null||e.destroy(),b.currentManager=void 0}};m(b,"kind","appliance-multi-plugin"),m(b,"currentManager"),m(b,"logger",{info:console.log,warn:console.warn,error:console.error}),m(b,"createCurrentManager",(e,t,n)=>{b.currentManager&&b.currentManager.destroy();const r={plugin:n,displayer:e.displayer,options:t},s=new qe(r);if(b.logger.info("[ApplianceMultiPlugin] refresh ApplianceMultiManager object"),s.setWindowManager(e),b.currentManager=s,e.room){const a=s.hasOffscreenCanvas;e.room.logger.info(`[ApplianceMultiPlugin] use ${a?"worker":"mainThread"}`)}});let Ii=b;var yy=Be,my=function(){return yy.Date.now()},Iy=my,wy=/\s/;function Ny(o){for(var i=o.length;i--&&wy.test(o.charAt(i)););return i}var Ty=Ny,vy=Ty,Cy=/^\s+/;function Sy(o){return o&&o.slice(0,vy(o)+1).replace(Cy,"")}var jy=Sy,Dy=ft,xy=Ke,zy="[object Symbol]";function Ay(o){return typeof o=="symbol"||xy(o)&&Dy(o)==zy}var by=Ay,Ey=jy,jn=_e,ky=by,Dn=NaN,Ly=/^[-+]0x[0-9a-f]+$/i,Py=/^0b[01]+$/i,Oy=/^0o[0-7]+$/i,Ry=parseInt;function Yy(o){if(typeof o=="number")return o;if(ky(o))return Dn;if(jn(o)){var i=typeof o.valueOf=="function"?o.valueOf():o;o=jn(i)?i+"":i}if(typeof o!="string")return o===0?o:+o;o=Ey(o);var e=Py.test(o);return e||Oy.test(o)?Ry(o.slice(2),e?2:8):Ly.test(o)?Dn:+o}var Uy=Yy,Wy=_e,si=Iy,xn=Uy,By="Expected a function",Fy=Math.max,Vy=Math.min;function Qy(o,i,e){var t,n,r,s,a,c,l=0,h=!1,u=!1,M=!0;if(typeof o!="function")throw new TypeError(By);i=xn(i)||0,Wy(e)&&(h=!!e.leading,u="maxWait"in e,r=u?Fy(xn(e.maxWait)||0,i):r,M="trailing"in e?!!e.trailing:M);function p(C){var D=t,k=n;return t=n=void 0,l=C,s=o.apply(k,D),s}function f(C){return l=C,a=setTimeout(w,i),h?p(C):s}function g(C){var D=C-c,k=C-l,P=i-D;return u?Vy(P,r-k):P}function y(C){var D=C-c,k=C-l;return c===void 0||D>=i||D<0||u&&k>=r}function w(){var C=si();if(y(C))return I(C);a=setTimeout(w,g(C))}function I(C){return a=void 0,M&&t?p(C):(t=n=void 0,s)}function v(){a!==void 0&&clearTimeout(a),l=0,t=c=n=a=void 0}function S(){return a===void 0?s:I(si())}function N(){var C=si(),D=y(C);if(t=arguments,n=this,c=C,D){if(a===void 0)return f(c);if(u)return clearTimeout(a),a=setTimeout(w,i),p(c)}return a===void 0&&(a=setTimeout(w,i)),s}return N.cancel=v,N.flush=S,N}var Zy=Qy,Hy=Zy,$y=_e,Gy="Expected a function";function Jy(o,i,e){var t=!0,n=!0;if(typeof o!="function")throw new TypeError(Gy);return $y(e)&&(t="leading"in e?!!e.leading:t,n="trailing"in e?!!e.trailing:n),Hy(o,i,{leading:t,maxWait:i,trailing:n})}var Xy=Jy;const qy=Qt(Xy);class Ky extends Io{constructor(e,t){super(e,t);m(this,"width",1e3);m(this,"height",1e3);m(this,"dpr",gt());m(this,"vDom");m(this,"eventTragetElement");m(this,"snapshotContainerRef");m(this,"canvasContainerRef",d.createRef());m(this,"subLocalCanvasContainerRef");m(this,"canvasTopRef");m(this,"canvasServiceFloatRef",d.createRef());m(this,"canvasFloatRef",d.createRef());m(this,"canvasBgRef",d.createRef());m(this,"floatBarRef",d.createRef());m(this,"containerOffset",{x:0,y:0});this.control.hasOffscreenCanvas||(this.snapshotContainerRef=d.createRef()),this.control.isUseSimple||(this.canvasTopRef=d.createRef(),this.subLocalCanvasContainerRef=d.createRef())}setCanvassStyle(){var e;if(this.eventTragetElement){const t=this.eventTragetElement.offsetWidth,n=this.eventTragetElement.offsetHeight,r=gt();r!==this.dpr&&(this.dpr=r,this.control.worker.updateDpr(this.viewId,this.dpr)),t&&n&&this.canvasContainerRef.current&&(t!==this.width||n!==this.height)&&(this.width=t,this.height=n),t&&n&&this.canvasBgRef.current&&(t!==this.width||n!==this.height)&&(this.width=t,this.height=n,this.control.isUseOffscreenTransfer||(this.canvasBgRef.current.width=t*this.dpr,this.canvasBgRef.current.height=n*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=t*this.dpr,this.canvasFloatRef.current.height=n*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=t*this.dpr,this.canvasServiceFloatRef.current.height=n*this.dpr),(e=this.canvasTopRef)!=null&&e.current&&(this.canvasTopRef.current.width=t*this.dpr,this.canvasTopRef.current.height=n*this.dpr)))}}createMainViewDisplayer(e){return this.vDom||(this.containerOffset=this.getContainerOffset(e,this.containerOffset),this.eventTragetElement=e.parentElement.children[0],e.innerHTML="",Vt.render(d.createElement(Wi,{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 Je extends dt{constructor(e){super(e);m(this,"focuedViewId");m(this,"control");m(this,"focuedView");this.control=e.control}bindMainView(){if(!this.control.divMainView)return;const e=new Ky(this.control,Te.InternalMsgEmitter),{width:t,height:n,dpr:r}=e,s={dpr:r,originalPoint:[t/2,n/2],offscreenCanvasOpt:{...Je.defaultScreenCanvasOpt,width:t,height:n},layerOpt:{...Je.defaultLayerOpt,width:t,height:n},cameraOpt:{...Je.defaultCameraOpt,width:t,height:n}},a=this.control.room&&this.control.room.mainView||this.control.play&&this.control.play.mainView;if(a){const{scale:c,...l}=a.camera;s.cameraOpt={...s.cameraOpt,...l,scale:c===1/0?1:c},this.createMianView({id:ue,displayer:e,focusScenePath:a.focusScenePath||a.scenePath,cameraOpt:s.cameraOpt,viewData:a}),this.setFocuedViewId(ue),e.createMainViewDisplayer(this.control.divMainView)}}getViewInitData(e){var n;const t=this.getView(e);if(t){const{width:r,height:s,dpr:a}=t.displayer;(n=this.control.pluginOptions.extras.canvasOpt)!=null&&n.contextType&&(Je.defaultScreenCanvasOpt.contextType=this.control.pluginOptions.extras.canvasOpt.contextType);const c={dpr:a,originalPoint:[r/2,s/2],offscreenCanvasOpt:{...Je.defaultScreenCanvasOpt,width:r,height:s},layerOpt:{...Je.defaultLayerOpt,width:r,height:s},cameraOpt:{...Je.defaultCameraOpt,width:r,height:s}};if(t.viewData){const{scale:l,...h}=t.viewData.camera;c.cameraOpt={...c.cameraOpt,...h,scale:l===1/0?1:l}}return c}}async mountView(e){var n;const t=this.getView(e);if(t){this.control.worker.isActive||(this.control.cursor.activeCollector(),this.control.isUseOffscreenTransfer&&t.displayer.canvasBgRef.current&&t.displayer.canvasServiceFloatRef.current&&t.displayer.canvasFloatRef.current&&t.displayer.setTransferControlToOffscreenCanvas({bgCanvas:t.displayer.canvasBgRef.current,serviceCanvas:t.displayer.canvasServiceFloatRef.current,localCanvas:t.displayer.canvasFloatRef.current}),await this.control.activeWorker());const r=this.getViewInitData(e);r&&((n=this.control.worker)==null||n.createViewWorker(e,r,t.displayer)),t.focusScenePath&&this.control.collector&&this.control.worker.pullServiceData(e,t.focusScenePath,{isAsync:!0,useAnimation:!1})}}}class Pe extends Te{constructor(e){super(e);m(this,"viewContainerManager");m(this,"divMainView");m(this,"onCameraChange",qy(e=>{var n;const t=this.viewContainerManager.mainView;t&&t.cameraOpt&&(t.cameraOpt.width!==e.width||t.cameraOpt.height!==e.height)&&((n=this.viewContainerManager.mainView)==null||n.displayer.updateSize()),this.viewContainerManager.setFocuedViewCameraOpt(e)},Ri,{leading:!1}));const t={control:this,internalMsgEmitter:Pe.InternalMsgEmitter,publicMsgEmitter:Pe.PublicMsgEmitter};this.viewContainerManager=new Je(t)}init(){Pe.InternalMsgEmitter.on(_.BindMainView,e=>{this.divMainView=e,this.plugin&&!this.viewContainerManager.mainView&&this.viewContainerManager.bindMainView()})}activePlugin(){this.plugin&&this.divMainView&&!this.viewContainerManager.mainView&&this.viewContainerManager.bindMainView(),this.collector&&(this.collector.addStorageStateListener(e=>{var a,c;if((a=this.collector)!=null&&a.storage&&Object.keys(this.collector.storage).length===0){(c=this.worker)==null||c.clearViewScenePath(ue,!0);return}const{diffView:t,diffScenePath:n,diffData:r}=e,s=new Map;if(t){let l;Object.keys(t).forEach(h=>{var M;const u=t[h];if(u&&!u.newValue)(M=this.worker)==null||M.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 g of Object.keys(p))g&&f.add(g);s.set(h,f)}})}if(n){let l;Object.keys(n).forEach(h=>{var M;const u=n[h];if(u&&u.viewId&&!u.newValue?((M=this.worker)==null||M.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),s.set(u.viewId,p)}})}r&&Object.keys(r).forEach(l=>{var u,M;const h=r[l];if(h){const{viewId:p}=h,f=s.get(p)||new Set;f.add(l),s.set(p,f),(u=this.worker)==null||u.onServiceDerive(l,h),(M=this.miniMapManager)==null||M.updateMiniMapCamera(p)}});for(const[l,h]of s.entries())Te.InternalMsgEmitter.emit("excludeIds",[...h],l)}),this.room&&(this.roomMember.onUidChangeHook(e=>{var t;(t=this.collector)!=null&&t.serviceStorage&&this.viewContainerManager.getAllViews().forEach(n=>{var r,s,a,c,l,h;if(n&&n.focusScenePath&&((r=this.collector)!=null&&r.serviceStorage[n.id])&&((s=this.collector)!=null&&s.serviceStorage[n.id][n.focusScenePath])){const u=Object.keys((a=this.collector)==null?void 0:a.serviceStorage[n.id][n.focusScenePath]);for(const M of u){const p=(c=this.collector)==null?void 0:c.getUidFromKey(M);if(p&&!e.online.includes(p))if((l=this.collector)!=null&&l.isSelector(M))this.renderControl.isWritable&&((h=this.collector)==null||h.updateValue(M,void 0,{viewId:n.id,scenePath:n.focusScenePath,isSync:!0})),this.worker.blurSelector(n.id,n.focusScenePath,M);else{const f=this.textEditorManager.editors.get(M);f&&f.opt&&(f.opt.workState===j.Doing||f.opt.workState===j.Start)&&(f.opt.text&&f.opt.text.replace(/\s*,/g,"")?this.textEditorManager.unActive(M):this.textEditorManager.delete(M))}}}})}),this.worker.isActive&&this.viewContainerManager.getAllViews().forEach(e=>{e&&e.focusScenePath&&this.worker.pullServiceData(e.id,e.focusScenePath,{isAsync:!0,useAnimation:!1})})))}async activeWorker(){await this.worker.init()}}const A=class A extends F.InvisiblePlugin{constructor(){super(...arguments);m(this,"onPhaseChanged",e=>{var t;e===F.RoomPhase.Reconnecting&&((t=A.currentManager)==null||t.setSnapshootData())});m(this,"updateRoomWritable",()=>{var e;(e=A.currentManager)==null||e.onWritableChange(this.displayer.isWritable)});m(this,"roomStateChangeListener",async e=>{var t,n;A.currentManager instanceof Pe&&(e.cameraState&&A.currentManager.onCameraChange(e.cameraState),e.sceneState&&A.currentManager.onSceneChange(e.sceneState.scenePath,ue)),e!=null&&e.roomMembers&&((t=A.currentManager)==null||t.onRoomMembersChange(e.roomMembers)),!(F.isRoom(this.displayer)&&!this.displayer.isWritable)&&e.memberState&&((n=A.currentManager)==null||n.onMemberChange(e.memberState))})}static async getInstance(e,t){var p;t.options&&(((p=t.options.extras)==null?void 0:p.useWorker)==="mainThread"&&(t.options.cdn.fullWorkerUrl="",t.options.cdn.subWorkerUrl=""),(t.options.extras&&t.options.extras.useWorker!=="mainThread"||!t.options.extras)&&!t.options.cdn.fullWorkerUrl&&!t.options.cdn.subWorkerUrl&&A.logger.error("[ApplianceSinglePlugin] you must adaptor options cdn fullWorkerUrl and subWorkerUrl"));const n=e.callbacks.on,r=e.callbacks.off,s=e.callbacks.once,a=e.cleanCurrentScene.bind(e),c=e.setMemberState.bind(e);let l;F.isRoom(e)&&(l=e.setWritable),t!=null&&t.logger&&(A.logger=t.logger);let h=e.getInvisiblePlugin(A.kind);h||(h=await A.createAppliancePlugin(e,A.kind)),e&&h&&A.createCurrentManager(e,{cdn:t.options.cdn,extras:{...we,...t.options.extras}},h),h&&A.currentManager&&(A.currentManager.bindPlugin(h),h.init(e)),t!=null&&t.cursorAdapter&&(A.cursorAdapter=t.cursorAdapter),A.effectInstance();const u={displayer:e,currentManager:A.currentManager,maxScreenshotWidth:10*1024,maxScreenshotHeight:10*1024,_injectTargetObject:void 0,getBoundingRectAsync:async function(f){var w;A.logger.info("[ApplianceSinglePlugin] getBoundingRectAsync");const g=e.getBoundingRect(f),y=await((w=A.currentManager)==null?void 0:w.getBoundingRect(f));return!g.width||!g.height?y:Yi(g,y)},screenshotToCanvasAsync:async function(f,g,y,w,I,v){var P;A.logger.info("[ApplianceSinglePlugin] screenshotToCanvasAsync");let S=y,N=w,C=I.scale;S>this.maxScreenshotWidth&&(C=this.maxScreenshotWidth/S*C,S=this.maxScreenshotWidth),N>this.maxScreenshotHeight&&(C=Math.min(this.maxScreenshotHeight/N*C,C),N=this.maxScreenshotHeight),I.scale=C;const D=document.createElement("canvas"),k=D.getContext("2d");D.width=S*(v||1),D.height=N*(v||1),k&&(e.screenshotToCanvas(k,g,S,N,I,v),f.drawImage(D,Math.floor((y-S)/2),Math.floor((w-N)/2),S*(v||1),N*(v||1),0,0,S,N),D.remove()),A.currentManager&&await((P=A.currentManager)==null?void 0:P.screenshotToCanvas(f,g,S,N,I,Math.floor((y-S)/2),Math.floor((w-N)/2)))},scenePreviewAsync:async function(f,g,y,w,I){A.logger.info("[ApplianceSinglePlugin] scenePreviewAsync"),e.scenePreview(f,g,y,w,I);const v=document.createElement("img");v.className="appliance-plugin-fill-scene-snapshot-img",g.append(v),getComputedStyle(g).position||(g.style.position="relative"),A.currentManager&&await A.currentManager.scenePreview(f,v)},fillSceneSnapshotAsync:async function(f,g,y,w,I){var V,te;A.logger.info("[ApplianceSinglePlugin] fillSceneSnapshotAsync"),g.innerHTML="",e.fillSceneSnapshot(f,g,y,w,I);const v=y||((V=e.state.cameraState)==null?void 0:V.width)||0,S=w||((te=e.state.cameraState)==null?void 0:te.height)||0;let N=await this.getBoundingRectAsync(f);N||(N={originX:0,originY:0,width:v,height:S});let C=Math.max(N==null?void 0:N.width,v),D=Math.max(N==null?void 0:N.height,S),k=1;const P=C>v&&Math.min(v/C,k)||k,L=D>S&&Math.min(S/D,k)||k;P<=L?(C=P<1&&v||C,D=Math.floor(D*P)+1,k=P):P>L&&(D=L<1&&S||D,C=Math.floor(C*L)+1,k=L);const O={scale:k,centerX:N.originX+N.width/2,centerY:N.originY+N.height/2},E=document.createElement("canvas"),R=E.getContext("2d");E.width=C,E.height=D,R&&await this.screenshotToCanvasAsync(R,f,C,D,O,devicePixelRatio);const z=document.createElement("img");z.className="appliance-plugin-fill-scene-snapshot-img",z.src=E.toDataURL(),z.onload=()=>{E.remove()},z.onerror=()=>{E.remove(),z.remove()},g.append(z),getComputedStyle(g).position||(g.style.position="relative")},_callbacksOn:function(f,g){A.logger.info(`[ApplianceSinglePlugin] callbacks ${f}`),(f==="onCanUndoStepsUpdate"||f==="onCanRedoStepsUpdate")&&F.isRoom(e)&&e.isWritable?Pe.InternalMsgEmitter.on(f,g):n.call(e.callbacks,f,g)},_callbacksOnce:function(f,g){A.logger.info(`[ApplianceSinglePlugin] callbacks ${f}`),(f==="onCanUndoStepsUpdate"||f==="onCanRedoStepsUpdate")&&F.isRoom(e)&&e.isWritable?Pe.InternalMsgEmitter.on(f,g):s.call(e.callbacks,f,g)},_callbacksOff:function(f,g){A.logger.info(`[ApplianceSinglePlugin] callbacks ${f}`),(f==="onCanUndoStepsUpdate"||f==="onCanRedoStepsUpdate")&&F.isRoom(e)&&e.isWritable?Pe.InternalMsgEmitter.off(f,g):r.call(e.callbacks,f,g)},canRedoSteps(){if(A.logger.info("[ApplianceSinglePlugin] canRedoSteps"),A.currentManager&&F.isRoom(e)&&!e.disableSerialization){const f=A.currentManager.viewContainerManager.focuedView,g=f==null?void 0:f.focusScenePath;if(f&&g)return f.displayer.commiter.redoStack.filter(y=>y.scenePath===g).length}return 0},canUndoSteps(){if(A.logger.info("[ApplianceSinglePlugin] canUndoSteps"),A.currentManager&&F.isRoom(e)&&!e.disableSerialization){const f=A.currentManager.viewContainerManager.focuedView,g=f==null?void 0:f.focusScenePath;if(f&&g)return f.displayer.commiter.undoStack.filter(y=>y.scenePath===g).length}return 0},undo:function(){return A.logger.info("[ApplianceSinglePlugin] undo"),A.currentManager&&F.isRoom(e)&&!e.disableSerialization?A.currentManager.viewContainerManager.undo():0},redo:function(){return A.logger.info("[ApplianceSinglePlugin] redo"),A.currentManager&&F.isRoom(e)&&!e.disableSerialization?A.currentManager.viewContainerManager.redo():0},cleanCurrentScene:function(f){A.logger.info("[ApplianceSinglePlugin] cleanCurrentScene"),A.currentManager&&F.isRoom(e)&&e.isWritable&&(A.currentManager.cleanCurrentScene(),a.call(e,f))},insertImage:function(f){A.logger.info("[ApplianceSinglePlugin] insertImage"),A.currentManager&&F.isRoom(e)&&e.isWritable&&A.currentManager.worker.insertImage(ue,f)},lockImage:function(f,g){A.logger.info("[ApplianceSinglePlugin] lockImage"),A.currentManager&&F.isRoom(e)&&e.isWritable&&A.currentManager.worker.lockImage(ue,f,g)},completeImageUpload:function(f,g){A.logger.info("[ApplianceSinglePlugin] completeImageUpload"),A.currentManager&&F.isRoom(e)&&e.isWritable&&A.currentManager.worker.completeImageUpload(ue,f,g)},getImagesInformation:function(f){return A.logger.info("[ApplianceSinglePlugin] completeImageUpload"),A.currentManager&&F.isRoom(e)&&e.isWritable?A.currentManager.worker.getImagesInformation(f):[]},insertText:function(f,g,y){if(A.logger.info("[ApplianceSinglePlugin] insertText"),A.currentManager&&F.isRoom(e)&&e.isWritable)return A.currentManager.textEditorManager.insertText(ue,f,g,y)},updateText:function(f,g){A.logger.info("[ApplianceMultiPlugin] updateText"),A.currentManager&&F.isRoom(e)&&e.isWritable&&A.currentManager.textEditorManager.updateText(f,g)},callbacks:()=>({...e.callbacks,on:u._callbacksOn.bind(u),once:u._callbacksOnce.bind(u),off:u._callbacksOff.bind(u)}),destroy(){A.currentManager&&(A.logger.info("[ApplianceSinglePlugin] destroy"),A.currentManager.destroy(),A.currentManager=void 0,A.cursorAdapter=void 0)},setMemberState(f){var y;A.logger.info(`[ApplianceSinglePlugin] setMemberState ${JSON.stringify(f)}`);const g=Object.keys(f);if(F.isRoom(e)&&e.isWritable){if(g.includes("currentApplianceName"))if(f.currentApplianceName&&f.currentApplianceName===ee.laserPen){if((y=A.currentManager)!=null&&y.isUseSimple)throw new Error("[ApplianceMultiPlugin] laserPen must be not support in simple mode");f.currentApplianceName=ee.pencil,f.useLaserPen=!0}else f.currentApplianceName&&f.currentApplianceName===ee.pencil&&(f.useLaserPen=!1);c(f);return}throw new Error("setMemberState must be called in writable room")},createMiniMap:async function(f,g){if(A.logger.info("[ApplianceSinglePlugin] createMiniMap"),A.currentManager&&F.isRoom(e)&&e.isWritable)return A.currentManager.createMiniMap(f,g)},destroyMiniMap:async function(f){if(A.logger.info("[ApplianceMultiPlugin] destroyeMiniMap"),A.currentManager&&F.isRoom(e)&&e.isWritable)return A.currentManager.destroyMiniMap(f)},filterRenderByUid(f,g,y){if(A.logger.info("[ApplianceSinglePlugin] filterRenderByUid"),A.currentManager&&F.isRoom(e)&&e.isWritable)return A.currentManager.filterRenderByUid(f,g,y)},cancelFilterRender(f,g){if(A.logger.info("[ApplianceSinglePlugin] filterRenderByUid"),A.currentManager&&F.isRoom(e)&&e.isWritable)return A.currentManager.cancelFilterRender(f,g)},addListener:(f,g)=>{A.logger.info(`[ApplianceSinglePlugin] addListener ${f}`),Pe.PublicMsgEmitter.on(f,g)},removeListener:(f,g)=>{A.logger.info(`[ApplianceSinglePlugin] removeListener ${f}`),Pe.PublicMsgEmitter.off(f,g)},usePlugin:f=>{var g;A.logger.info("[ApplianceSinglePlugin] usePlugin",f.kind),(g=A.currentManager)==null||g.usePlugin(f)},getDisableDeviceInputs(){if(A.currentManager&&F.isRoom(e))return A.currentManager.disableDeviceInputs},setDisableDeviceInputs(f){A.logger.info(`[ApplianceSinglePlugin] setDisableDeviceInputs ${f}`),A.currentManager&&F.isRoom(e)&&(A.currentManager.disableDeviceInputs=f)},getDisableCameraTransform(){if(A.currentManager&&F.isRoom(e))return A.currentManager.disableCameraTransform},setDisableCameraTransform(f){A.logger.info(`[ApplianceSinglePlugin] setDisableCameraTransform ${f}`),A.currentManager&&F.isRoom(e)&&(A.currentManager.disableCameraTransform=f)},getDisableEraseImage(){if(A.currentManager&&F.isRoom(e))return A.currentManager.disableEraseImage},setDisableEraseImage(f){A.logger.info(`[ApplianceSinglePlugin] setDisableEraseImage ${f}`),A.currentManager&&F.isRoom(e)&&(A.currentManager.disableEraseImage=f)},setWritable:async function(f){var g;A.logger.info(`[ApplianceSinglePlugin] setWritable ${f}`),F.isRoom(e)&&l&&(await((g=A.currentManager)==null?void 0:g.setWritable(f)),await l.call(e,f))},requestIdleCallback:(f,g)=>{const y=(g==null?void 0:g.timeout)||0,w=performance.now();let I;const v=new MessageChannel;let S;const N=C=>{try{f({didTimeout:C,timeRemaining:()=>{const k=performance.now()-w;return Math.max(0,y-k)}})}catch(D){A.logger.error("[ApplianceSinglePlugin] requestIdleCallback error:",D)}finally{v.port1.close(),v.port2.close(),I!==void 0&&cancelAnimationFrame(I),S!==void 0&&clearTimeout(S)}};return v.port1.onmessage=()=>{I=requestAnimationFrame(()=>{y>0&&performance.now()-w>=y?N(!0):N(!1)})},v.port2.postMessage(null),y>0&&(S=setTimeout(()=>{N(!0)},y)),S||I||0},cancelIdleCallback:f=>{try{clearTimeout(f),cancelAnimationFrame(f)}catch(g){A.logger.error("[ApplianceSinglePlugin] cancelIdleCallback error:",g)}},injectMethodToObject:(f,g)=>{if(A.logger.info(`[ApplianceSinglePlugin] injectMethodToObject ${g}`),typeof f[g]=="function"||typeof f[g]>"u"){f[g]=u[g];return}g==="callbacks"&&(f.callbacks.on=u._callbacksOn.bind(u),f.callbacks.off=u._callbacksOff.bind(u),f.callbacks.once=u._callbacksOnce.bind(u))},blurText:()=>{A.logger.info("[ApplianceSinglePlugin] blurText"),A.currentManager&&F.isRoom(e)&&e.isWritable&&A.currentManager.textEditorManager.checkEmptyTextBlur()},hasElements:(f,g)=>{var y;if(A.logger.info(`[ApplianceSinglePlugin] hasElements ${f}`),A.currentManager&&F.isRoom(e)&&e.isWritable){let w=f;if(!w){const I=A.currentManager.viewContainerManager.focuedView;w=I==null?void 0:I.focusScenePath}if(w){const I=(y=A.currentManager.collector)==null?void 0:y.getScenePathData(w);if(I){const v=Object.values(I);return v.length>0?g?v.some(S=>g(S.toolsType)):!0:!1}return!1}return!1}},getElements:(f,g)=>{var y;if(A.logger.info(`[ApplianceSinglePlugin] getElements ${f}`),A.currentManager&&F.isRoom(e)&&e.isWritable){let w=f;if(!w){const I=A.currentManager.viewContainerManager.focuedView;w=I==null?void 0:I.focusScenePath}if(w){const I=(y=A.currentManager.collector)==null?void 0:y.getScenePathData(w),v=I&&Object.values(I)||[];return I&&v.length>0&&g?v.filter(S=>g(S.toolsType)):v}return[]}},stopDraw:f=>{if(A.logger.info(`[ApplianceSinglePlugin] stopDraw ${f}`),A.currentManager&&F.isRoom(e))return A.currentManager.stopDraw(f)}};u.injectMethodToObject(e,"undo"),u.injectMethodToObject(e,"redo"),u.injectMethodToObject(e,"cleanCurrentScene"),u.injectMethodToObject(e,"insertImage"),u.injectMethodToObject(e,"completeImageUpload"),u.injectMethodToObject(e,"lockImage"),u.injectMethodToObject(e,"getImagesInformation"),u.injectMethodToObject(e,"insertText"),u.injectMethodToObject(e,"updateText"),u.injectMethodToObject(e,"callbacks"),u.injectMethodToObject(e,"screenshotToCanvasAsync"),u.injectMethodToObject(e,"getBoundingRectAsync"),u.injectMethodToObject(e,"scenePreviewAsync"),u.injectMethodToObject(e,"fillSceneSnapshotAsync"),u.injectMethodToObject(e,"setMemberState"),F.isRoom(e)&&u.injectMethodToObject(e,"setWritable"),Object.defineProperty(e,"canUndoSteps",{get(){return u.canUndoSteps()}}),Object.defineProperty(e,"canRedoSteps",{get(){return u.canRedoSteps()}});const M={...u,callbacks:u.callbacks()};return Object.defineProperty(M,"disableDeviceInputs",{set(f){u.setDisableDeviceInputs(f)},get(){return u.getDisableDeviceInputs()}}),Object.defineProperty(M,"disableEraseImage",{set(f){u.setDisableEraseImage(f)},get(){return u.getDisableEraseImage()}}),Object.defineProperty(M,"disableCameraTransform",{set(f){u.setDisableCameraTransform(f)},get(){return u.getDisableCameraTransform()}}),e._appliancePlugin=M,e._appliancePlugin}static onCreate(e){e&&A.currentManager&&(A.currentManager.bindPlugin(e),e.init(e.displayer))}static async createAppliancePlugin(e,t){try{await e.createInvisiblePlugin(A,{})}catch(r){if(!e.isWritable){await e.setWritable(!0);const s=await this.createAppliancePlugin(e,t);return await e.setWritable(!1),s}throw r}let n=e.getInvisiblePlugin(t);return n||(n=await A.createAppliancePlugin(e,t)),n}static effectInstance(){if(A.cursorAdapter){const e=A.cursorAdapter.onAddedCursor;A.cursorAdapter.onAddedCursor=function(t){t.onCursorMemberChanged=n=>{try{n.appliance===ee.pencil||n.appliance===ee.shape||n.appliance===ee.text||n.appliance===ee.arrow||n.appliance===ee.straight||n.appliance===ee.rectangle||n.appliance===ee.ellipse||n.appliance===ee.eraser||n.appliance===ee.selector?t!=null&&t.divElement&&(t.divElement.style.display="none"):t!=null&&t.divElement&&(t.divElement.style.display="block")}catch(r){throw r}},e.call(A.cursorAdapter,t)}}}get isReplay(){return F.isPlayer(this.displayer)}get callbackName(){return this.isReplay?"onPlayerStateChanged":"onRoomStateChanged"}init(e){var n,r;const t=e.state;(n=A.currentManager)==null||n.onRoomMembersChange(t.roomMembers),F.isRoom(e)&&t!=null&&t.memberState&&((r=A.currentManager)==null||r.onMemberChange(t.memberState)),this.displayer.callbacks.on(this.callbackName,this.roomStateChangeListener),this.displayer.callbacks.on("onEnableWriteNowChanged",this.updateRoomWritable),this.displayer.callbacks.on("onPhaseChanged",this.onPhaseChanged)}destroy(){var e;A.logger.info("[ApplianceSinglePlugin] passive destroy"),(e=A.currentManager)==null||e.destroy(),A.currentManager=void 0,A.cursorAdapter=void 0}};m(A,"kind","appliance-single-plugin"),m(A,"cursorAdapter"),m(A,"currentManager"),m(A,"logger",{info:console.log,warn:console.warn,error:console.error}),m(A,"createCurrentManager",(e,t,n)=>{A.currentManager&&A.currentManager.destroy();const r={plugin:n,displayer:e,options:t},s=new Pe(r);if(s.init(),A.logger.info("[ApplianceSinglePlugin] refresh ApplianceSingleManager object"),A.currentManager=s,F.isRoom(e)){const a=s.hasOffscreenCanvas,c=s.isUseOffscreenTransfer,l=s.pluginOptions,h=s.isUseSimple;e.logger.info(`[ApplianceSinglePlugin] use ${a?"worker":"mainThread"}, isUseSimple: ${h} ${c?"offscreenTransfer":""}, options: ${JSON.stringify(l)}`)}});let wi=A;const ht=class ht extends d.Component{constructor(){super(...arguments);m(this,"mainViewRef",null)}componentDidMount(){ht.emiter||(ht.emiter=Pe.InternalMsgEmitter),ht.emiter.emit(_.BindMainView,this.mainViewRef)}render(){return d.createElement(d.Fragment,null,this.props.children,d.createElement("div",{className:"appliance-plugin-main-view-displayer",ref:e=>this.mainViewRef=e}))}};m(ht,"emiter");let Ni=ht;class _y extends po{constructor(e){super();m(this,"kind","autoDraw");m(this,"localStorage",[]);m(this,"excludeStorage",[]);m(this,"timer");m(this,"hostServer");m(this,"iconsContainer");m(this,"icons",[]);m(this,"iconRect");m(this,"isActive",!1);m(this,"viewId",ue);m(this,"scenePath");m(this,"delay",2e3);const{container:t,hostServer:n,delay:r}=e;this.hostServer=n,this.iconsContainer=t,this.delay=r||2e3}get collector(){return this.control.collector}onDestroy(){this.unMount()}onCreate(){}onSetToolkey(e){e===T.Pencil?this.isActive=!0:(this.isActive&&(this.localStorage.length=0,this.timer&&clearTimeout(this.timer),this.timer=void 0,this.iconRect&&(this.iconRect=void 0),this.icons.length=0),this.isActive=!1)}syncStorage(e,t){if(!this.isActive||e!==this.viewId)return;if(!t){this.localStorage.length=0;return}const n=this.getOwnStorage(this.viewId,t);this.localStorage=n.map(r=>{var s;return((s=this.collector)==null?void 0:s.getLocalId(r))||r})}getOwnStorage(e,t){var s,a;if(!e||!t)return[];const n=(a=(s=this.collector)==null?void 0:s.storage[e])==null?void 0:a[t];return n?Object.keys(n).filter(c=>{var l,h;return((l=this.collector)==null?void 0:l.isOwn(c))&&((h=n[c])==null?void 0:h.toolsType)===T.Pencil&&!this.excludeStorage.includes(c)}):[]}async batchLocalDraw(){var a;if(this.localStorage.length===0||!this.scenePath||!((a=this.collector)==null?void 0:a.getStorageData(this.viewId,this.scenePath)))return;const t=this.localStorage.toString(),n=await this.control.worker.getVNodeInfo(this.localStorage.toString(),this.viewId,this.localStorage);if(!n)return;const{vInfo:r,uuid:s}=n;if(s===t&&r){const c={rect:{centerX:0,centerY:0,width:0,height:0},ink:[]};let l;const h=[];for(const{rect:u,op:M}of r){l=Mo(l,u);const p=[],f=[];for(let g=0;g<M.length;g+=3){p.push(M[g]),f.push(M[g+1]);const y=h.length&&h[h.length-1]||0;g===0?h.length===0?h.push(0):h.push(y+100):h.push(y+15)}c.ink.push([p,f,h])}return l&&(c.rect.centerX=Math.floor(l.x+l.w/2),c.rect.centerY=Math.floor(l.y+l.h/2),c.rect.width=Math.floor(l.w),c.rect.height=Math.floor(l.h)),c}}async computAutoDraw(e){const{rect:t,ink:n}=e;this.iconRect=t;const r=await fetch(this.hostServer,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({width:t.width,height:t.height,ink:n})}).then(s=>s.json()).then(s=>s.data);this.icons=r||[]}buildHTML(){var n;this.iconsContainer.innerHTML="";const e=document.createElement("div");e.style.display="flex",e.style.overflow="auto",e.style.padding="10px 0";const t=((n=this.control.worker.currentToolsData)==null?void 0:n.toolsOpt.strokeColor)||"#7f7f7f";this.icons.forEach(r=>{const s=document.createElement("img");s.src=`https://api.iconify.design/${r}.svg?color=${t}`,s.onclick=()=>{this.onClickIcon(r)},s.onload=()=>{e.appendChild(s)}}),this.iconsContainer.appendChild(e)}onClickIcon(e){var t,n;if(this.iconRect){const r=this.control.viewContainerManager.transformToScenePoint([this.iconRect.centerX,this.iconRect.centerY],this.viewId),s=((n=(t=this.control.viewContainerManager.getView(this.viewId))==null?void 0:t.cameraOpt)==null?void 0:n.scale)||1;this.icons.length=0,this.iconsContainer.innerHTML="";const a=Date.now().toString();this.control.worker.removeNodes(this.viewId,this.localStorage),this.localStorage.length=0,this.control.insertIconify(this.viewId,{uuid:a,centerX:r[0],centerY:r[1],width:Math.floor(this.iconRect.width/s),height:Math.floor(this.iconRect.height/s),src:`https://api.iconify.design/${e}.svg`,uniformScale:!1,locked:!1}),this.iconRect=void 0}}sceneChange(e,t){e===this.viewId&&(this.scenePath=t,this.excludeStorage=this.getOwnStorage(e,t)),this.localStorage.length=0}localEvent(e,t){var n;if(e===this.viewId&&((n=this.control.worker.currentToolsData)==null?void 0:n.toolsType)===T.Pencil)switch(t){case j.Start:this.timer&&(clearTimeout(this.timer),this.timer=void 0);break;case j.Done:this.timer&&clearTimeout(this.timer),this.timer=setTimeout(async()=>{this.timer=void 0;const r=await this.batchLocalDraw();r&&(await this.computAutoDraw(r),this.buildHTML())},this.delay);break}}mount(){var t,n;this.scenePath=(t=this.control.viewContainerManager.getView(this.viewId))==null?void 0:t.focusScenePath,this.excludeStorage=this.getOwnStorage(this.viewId,this.scenePath);const e=(n=this.control.worker.currentToolsData)==null?void 0:n.toolsType;e&&this.onSetToolkey(e),this.callbacks("setToolkey",this.onSetToolkey.bind(this)),this.callbacks("syncStorage",this.syncStorage.bind(this)),this.callbacks("sceneChange",this.sceneChange.bind(this)),this.callbacks("localEvent",this.localEvent.bind(this))}unMount(){this.timer&&clearTimeout(this.timer),this.timer=void 0,this.iconRect&&(this.iconRect=void 0),this.icons.length=0,this.excludeStorage.length=0,this.localStorage.length=0,this.iconsContainer.innerHTML="",this.removeCallback("setToolkey"),this.removeCallback("syncStorage"),this.removeCallback("sceneChange"),this.removeCallback("localEvent")}}exports.ActiveContainerType=An;exports.ApplianceMultiPlugin=Ii;exports.ApplianceNames=ee;exports.ApplianceSigleWrapper=Ni;exports.ApplianceSinglePlugin=wi;exports.AutoDrawPlugin=_y;exports.Cursor_Hover_Id=Og;exports.DefaultAppliancePluginExtrasOptions=we;exports.ECanvasShowType=He;exports.EDataType=K;exports.EForceStopReason=Ti;exports.EImageType=jt;exports.EMatrixrRelationType=St;exports.EOperationType=ze;exports.EPostMessageType=W;exports.ERenderFilterType=Ye;exports.EScaleType=Ae;exports.EStrokeType=fe;exports.EToolsKey=T;exports.ElayerType=Dt;exports.EmitEventType=U;exports.EventMessageType=Ct;exports.EvevtWorkState=j;exports.EvevtWorkType=bn;exports.InternalMsgEmitterType=_;exports.Main_View_Id=ue;exports.Plugin=po;exports.Point2d=ye;exports.ShapeType=Re;exports.Storage_Selector_key=Z;exports.Storage_Splitter=$e;exports.Storage_ViewId_ALL=ao;exports.Task_Time_Interval=Ri;exports.TextBoxPadding=Mi;exports.Vec2d=Y;exports.ViewContainerManager=dt;exports._Stack=Rn;exports._baseGetTag=ft;exports._equalArrays=co;exports._equalByTag=Pg;exports._getAllKeys=Kn;exports._getTag=qt;exports.average=kf;exports.checkOp=xf;exports.cloneDeep=bt;exports.colorRGBA2Array=vt;exports.computRect=Mo;exports.decimalPlaces=Af;exports.fullWorker=So;exports.gcd=bf;exports.getDefaultExportFromCjs=Qt;exports.getRectFromPoints=Ui;exports.getRectMatrixrRelation=Lf;exports.getRectRotated=Nf;exports.getRectScaleWPoint=Tf;exports.getRectTranslated=If;exports.getSafetyRect=mf;exports.getWHRatio=Df;exports.isArray_1=At;exports.isBufferExports=Si;exports.isDecimal=zf;exports.isIntersect=yf;exports.isIntersectForPoint=fo;exports.isObjectLike_1=Ke;exports.isSet=Jh;exports.isTypedArray_1=Qn;exports.precise=Ef;exports.requestAsyncCallBack=Ue;exports.rgbToRgba=ut;exports.rotateLitePoints=Cf;exports.rotatePoints=vf;exports.scaleLitePoints=jf;exports.scalePoints=Sf;exports.strlen=Pf;exports.subWorker=jo;exports.transformToNormalData=Kt;exports.transformToSerializableData=xt;