@netless/appliance-plugin 1.1.36-beta.1 → 1.1.36-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/READMA.zh-CN.md +11 -48
  2. package/README.md +11 -49
  3. package/dist/appliance-plugin.js +1 -1
  4. package/dist/appliance-plugin.mjs +1 -1
  5. package/dist/assets/{fullWorker-B_mvkoeW.js → fullWorker-D9xRgd20.js} +7 -7
  6. package/dist/assets/{subWorker-CRdsidWT.js → subWorker-DDz22vt8.js} +7 -7
  7. package/dist/{bridge-enxPG6qf.js → bridge-BKHuhuVK.js} +1 -1
  8. package/dist/bridge-g7eU9k12.mjs +67 -0
  9. package/dist/bridge.js +1 -1
  10. package/dist/bridge.mjs +1 -1
  11. package/dist/component/textEditor/manager.d.ts +0 -1
  12. package/dist/fullWorker.js +2 -2
  13. package/dist/index-B7w-GcID.js +1 -0
  14. package/dist/{index-D4z0hSjm.js → index-BLzjGoXh.js} +1 -1
  15. package/dist/{index-CcS9cKSp.js → index-BjEjHeEF.js} +1 -1
  16. package/dist/{index-BrJL-fin.mjs → index-C019qtsS.mjs} +14 -21
  17. package/dist/{index-DbI0V6BY.mjs → index-CfKLCV2y.mjs} +4858 -4987
  18. package/dist/{index-K9QVPOhV.mjs → index-L2uoKaSf.mjs} +14 -21
  19. package/dist/index-L470yte_.js +1 -0
  20. package/dist/{index-2On9v0Ff.mjs → index-LBCXcuGb.mjs} +4841 -4970
  21. package/dist/{index-CIjmeY9J.js → index-PebKJQE3.js} +1 -1
  22. package/dist/{index-Bm90lQii.js → index-Yc4OIUoM.js} +1 -1
  23. package/dist/{index-BZql6xgR.mjs → index-bMvJ4igq.mjs} +1 -1
  24. package/dist/{index-D8SnD90W.mjs → index-hePUiGEB.mjs} +1 -1
  25. package/dist/plugin/selectorApi.d.ts +7 -1
  26. package/dist/plugin/types.d.ts +8 -3
  27. package/dist/subWorker.js +2 -2
  28. package/dist/undo/index.d.ts +0 -1
  29. package/package.json +2 -4
  30. package/cdn/cdn.js +0 -1
  31. package/cdn/fullWorker-uAwmRi.js +0 -486
  32. package/cdn/subWorker-BVNpAC.js +0 -486
  33. package/dist/bridge-DYkH1J6p.mjs +0 -67
  34. package/dist/index-BSD0B_eV.js +0 -1
  35. package/dist/index-W9Jz9E04.js +0 -1
@@ -0,0 +1 @@
1
+ "use strict";var Ir=Object.defineProperty;var wr=(r,n,e)=>n in r?Ir(r,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[n]=e;var I=(r,n,e)=>wr(r,typeof n!="symbol"?n+"":n,e);const G=require("white-web-sdk");require("spritejs");const So=require("lz-string");require("clipper-lib");require("lineclip");const Un=require("xss"),j=require("lodash"),Yn=require("eventemitter2"),f=require("react"),fn=require("react-dom"),Lt=require("react-draggable"),Tr=require("re-resizable"),Sr="/fullWorker.js",vr="/subWorker.js";var ie=(r=>(r.selector="selector",r.clicker="clicker",r.laserPointer="laserPointer",r.pencil="pencil",r.rectangle="rectangle",r.ellipse="ellipse",r.shape="shape",r.eraser="eraser",r.pencilEraser="pencilEraser",r.text="text",r.straight="straight",r.arrow="arrow",r.hand="hand",r.laserPen="laserPen",r))(ie||{}),ce=(r=>(r.Normal="Normal",r.Stroke="Stroke",r.Dotted="Dotted",r.LongDotted="LongDotted",r))(ce||{}),Ye=(r=>(r.Triangle="triangle",r.Rhombus="rhombus",r.Pentagram="pentagram",r.SpeechBalloon="speechBalloon",r.Star="star",r.Polygon="polygon",r))(Ye||{}),U=(r=>(r.None="None",r.ShowFloatBar="ShowFloatBar",r.ZIndexFloatBar="ZIndexFloatBar",r.DeleteNode="DeleteNode",r.CopyNode="CopyNode",r.ZIndexNode="ZIndexNode",r.ZIndexBackgroundSVG="ZIndexBackgroundSVG",r.RotateNode="RotateNode",r.SetColorNode="SetColorNode",r.TranslateNode="TranslateNode",r.ScaleNode="ScaleNode",r.OriginalEvent="OriginalEvent",r.CreateScene="CreateScene",r.ActiveCursor="ActiveCursor",r.MoveCursor="MoveCursor",r.CommandEditor="CommandEditor",r.SetEditorData="SetEditorData",r.SetFontStyle="SetFontStyle",r.SetPoint="SetPoint",r.SetLock="SetLock",r.SetShapeOpt="SetShapeOpt",r.CameraChange="CameraChange",r.ActiveMethod="ActiveMethod",r.HidFloatBarBtn="HidFloatBarBtn",r.SelectMethod="SelectMethod",r))(U||{}),ne=(r=>(r.MainEngine="MainEngine",r.Cursor="Cursor",r.BindMainView="BindMainView",r))(ne||{}),vo=(r=>(r[r.MainView=0]="MainView",r[r.Plugin=1]="Plugin",r[r.Both=2]="Both",r))(vo||{}),ni=(r=>(r.longPencil="longPencil",r))(ni||{}),S=(r=>(r[r.Pencil=1]="Pencil",r[r.Eraser=2]="Eraser",r[r.PencilEraser=3]="PencilEraser",r[r.BitMapEraser=4]="BitMapEraser",r[r.Selector=5]="Selector",r[r.Clicker=6]="Clicker",r[r.Arrow=7]="Arrow",r[r.Hand=8]="Hand",r[r.LaserPen=9]="LaserPen",r[r.Text=10]="Text",r[r.Straight=11]="Straight",r[r.Rectangle=12]="Rectangle",r[r.Ellipse=13]="Ellipse",r[r.Star=14]="Star",r[r.Triangle=15]="Triangle",r[r.Rhombus=16]="Rhombus",r[r.Polygon=17]="Polygon",r[r.SpeechBalloon=18]="SpeechBalloon",r[r.Image=19]="Image",r[r.BackgroundSVG=20]="BackgroundSVG",r))(S||{}),_=(r=>(r[r.Local=1]="Local",r[r.Service=2]="Service",r[r.Worker=3]="Worker",r))(_||{}),D=(r=>(r[r.Pending=0]="Pending",r[r.Start=1]="Start",r[r.Doing=2]="Doing",r[r.Done=3]="Done",r[r.Unwritable=4]="Unwritable",r))(D||{}),$=(r=>(r[r.None=0]="None",r[r.Init=1]="Init",r[r.UpdateCamera=2]="UpdateCamera",r[r.UpdateTools=3]="UpdateTools",r[r.CreateWork=4]="CreateWork",r[r.DrawWork=5]="DrawWork",r[r.FullWork=6]="FullWork",r[r.UpdateNode=7]="UpdateNode",r[r.RemoveNode=8]="RemoveNode",r[r.Clear=9]="Clear",r[r.Select=10]="Select",r[r.Destroy=11]="Destroy",r[r.Snapshot=12]="Snapshot",r[r.BoundingBox=13]="BoundingBox",r[r.Cursor=14]="Cursor",r[r.TextUpdate=15]="TextUpdate",r[r.GetTextActive=16]="GetTextActive",r[r.TasksQueue=17]="TasksQueue",r[r.CursorHover=18]="CursorHover",r[r.CursorBlur=19]="CursorBlur",r[r.Console=20]="Console",r[r.GetImageBitMap=23]="GetImageBitMap",r[r.AuthWriter=24]="AuthWriter",r[r.AuthReader=25]="AuthReader",r[r.AuthClear=26]="AuthClear",r[r.AuthPage=27]="AuthPage",r[r.GetVNodeInfo=28]="GetVNodeInfo",r[r.UpdateDpr=29]="UpdateDpr",r[r.SetFontFace=30]="SetFontFace",r[r.ReportError=31]="ReportError",r[r.ReportLog=32]="ReportLog",r[r.BackgroundSVGUpdate=33]="BackgroundSVGUpdate",r[r.BackgroundSVGDelete=34]="BackgroundSVGDelete",r[r.SelectorTransform=35]="SelectorTransform",r))($||{}),Xe=(r=>(r[r.None=0]="None",r[r.Bg=1]="Bg",r[r.ServiceFloat=2]="ServiceFloat",r[r.Float=3]="Float",r[r.TopFloat=4]="TopFloat",r))(Xe||{}),Ht=(r=>(r[r.Cursor=1]="Cursor",r[r.TextCreate=2]="TextCreate",r))(Ht||{}),st=(r=>(r[r.Top=1]="Top",r[r.Bottom=2]="Bottom",r))(st||{}),Oe=(r=>(r[r.none=1]="none",r[r.all=2]="all",r[r.both=3]="both",r[r.proportional=4]="proportional",r))(Oe||{}),qt=(r=>(r[r.inside=0]="inside",r[r.outside=1]="outside",r[r.intersect=2]="intersect",r))(qt||{}),be=(r=>(r.renderPage="renderPage",r.addPage="addPage",r.deletePage="deletePage",r.addElement="addElement",r.deleteElement="deleteElement",r.clearPage="clearPage",r.clearViewScenePath="clearViewScenePath",r.clearView="clearView",r.syncUndoStack="syncUndoStack",r.syncRedoStack="syncRedoStack",r))(be||{}),Ze=(r=>(r.setAuth="setAuth",r.setShow="addShow",r.setHide="setHide",r.setClear="setClear",r))(Ze||{}),Jt=(r=>(r.Image="image",r.Iconify="iconify",r))(Jt||{}),Kt=(r=>(r.url="url",r.markmap="markmap",r))(Kt||{});const Nr="cursorhover",ii=20,re="mainView",Cr={linear:r=>r,easeInQuad:r=>r*r,easeOutQuad:r=>r*(2-r),easeInOutQuad:r=>r<.5?2*r*r:-1+(4-2*r)*r,easeInCubic:r=>r*r*r,easeOutCubic:r=>--r*r*r+1,easeInOutCubic:r=>r<.5?4*r*r*r:(r-1)*(2*r-2)*(2*r-2)+1,easeInQuart:r=>r*r*r*r,easeOutQuart:r=>1- --r*r*r*r,easeInOutQuart:r=>r<.5?8*r*r*r*r:1-8*--r*r*r*r,easeInQuint:r=>r*r*r*r*r,easeOutQuint:r=>1+--r*r*r*r*r,easeInOutQuint:r=>r<.5?16*r*r*r*r*r:1+16*--r*r*r*r*r,easeInSine:r=>1-Math.cos(r*Math.PI/2),easeOutSine:r=>Math.sin(r*Math.PI/2),easeInOutSine:r=>-(Math.cos(Math.PI*r)-1)/2,easeInExpo:r=>r<=0?0:Math.pow(2,10*r-10),easeOutExpo:r=>r>=1?1:1-Math.pow(2,-10*r),easeInOutExpo:r=>r<=0?0:r>=1?1:r<.5?Math.pow(2,20*r-10)/2:(2-Math.pow(2,-20*r+10))/2};class V{constructor(n=0,e=0,t=1){this.x=n,this.y=e,this.z=t}get XY(){return[this.x,this.y]}setz(n){return this.z=n,this}setXY(n=this.x,e=this.y){return this.x=n,this.y=e,this}set(n=this.x,e=this.y,t=this.z){return this.x=n,this.y=e,this.z=t,this}setTo({x:n=0,y:e=0,z:t=1}){return this.x=n,this.y=e,this.z=t,this}rot(n){if(n===0)return this;const{x:e,y:t}=this,i=Math.sin(n),o=Math.cos(n);return this.x=e*o-t*i,this.y=e*i+t*o,this}rotWith(n,e){if(e===0)return this;const t=this.x-n.x,i=this.y-n.y,o=Math.sin(e),s=Math.cos(e);return this.x=n.x+(t*s-i*o),this.y=n.y+(t*o+i*s),this}clone(){const{x:n,y:e,z:t}=this;return new V(n,e,t)}sub(n){return this.x-=n.x,this.y-=n.y,this}subXY(n,e){return this.x-=n,this.y-=e,this}subScalar(n){return this.x-=n,this.y-=n,this}add(n){return this.x+=n.x,this.y+=n.y,this}addXY(n,e){return this.x+=n,this.y+=e,this}addScalar(n){return this.x+=n,this.y+=n,this}clamp(n,e){return this.x=Math.max(this.x,n),this.y=Math.max(this.y,n),e!==void 0&&(this.x=Math.min(this.x,e),this.y=Math.min(this.y,e)),this}div(n){return this.x/=n,this.y/=n,this}divV(n){return this.x/=n.x,this.y/=n.y,this}mul(n){return this.x*=n,this.y*=n,this}mulV(n){return this.x*=n.x,this.y*=n.y,this}abs(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this}nudge(n,e){const t=V.Tan(n,this);return this.add(t.mul(e))}neg(){return this.x*=-1,this.y*=-1,this}cross(n){return this.x=this.y*n.z-this.z*n.y,this.y=this.z*n.x-this.x*n.z,this}dpr(n){return V.Dpr(this,n)}cpr(n){return V.Cpr(this,n)}len2(){return V.Len2(this)}len(){return V.Len(this)}pry(n){return V.Pry(this,n)}per(){const{x:n,y:e}=this;return this.x=e,this.y=-n,this}uni(){return V.Uni(this)}tan(n){return V.Tan(this,n)}dist(n){return V.Dist(this,n)}distanceToLineSegment(n,e){return V.DistanceToLineSegment(n,e,this)}slope(n){return V.Slope(this,n)}snapToGrid(n){return this.x=Math.round(this.x/n)*n,this.y=Math.round(this.y/n)*n,this}angle(n){return V.Angle(this,n)}toAngle(){return V.ToAngle(this)}lrp(n,e){return this.x=this.x+(n.x-this.x)*e,this.y=this.y+(n.y-this.y)*e,this}equals(n,e){return V.Equals(this,n,e)}equalsXY(n,e){return V.EqualsXY(this,n,e)}norm(){const n=this.len();return this.x=n===0?0:this.x/n,this.y=n===0?0:this.y/n,this}toFixed(){return V.ToFixed(this)}toString(){return V.ToString(V.ToFixed(this))}toJson(){return V.ToJson(this)}toArray(){return V.ToArray(this)}static Add(n,e){return new V(n.x+e.x,n.y+e.y)}static AddXY(n,e,t){return new V(n.x+e,n.y+t)}static Sub(n,e){return new V(n.x-e.x,n.y-e.y)}static SubXY(n,e,t){return new V(n.x-e,n.y-t)}static AddScalar(n,e){return new V(n.x+e,n.y+e)}static SubScalar(n,e){return new V(n.x-e,n.y-e)}static Div(n,e){return new V(n.x/e,n.y/e)}static Mul(n,e){return new V(n.x*e,n.y*e)}static DivV(n,e){return new V(n.x/e.x,n.y/e.y)}static MulV(n,e){return new V(n.x*e.x,n.y*e.y)}static Neg(n){return new V(-n.x,-n.y)}static Per(n){return new V(n.y,-n.x)}static Dist2(n,e){return V.Sub(n,e).len2()}static Abs(n){return new V(Math.abs(n.x),Math.abs(n.y))}static Dist(n,e){return Math.hypot(n.y-e.y,n.x-e.x)}static Dpr(n,e){return n.x*e.x+n.y*e.y}static Cross(n,e){return new V(n.y*e.z-n.z*e.y,n.z*e.x-n.x*e.z)}static Cpr(n,e){return n.x*e.y-e.x*n.y}static Len2(n){return n.x*n.x+n.y*n.y}static Len(n){return Math.hypot(n.x,n.y)}static Pry(n,e){return V.Dpr(n,e)/V.Len(e)}static Uni(n){return V.Div(n,V.Len(n))}static Tan(n,e){return V.Uni(V.Sub(n,e))}static Min(n,e){return new V(Math.min(n.x,e.x),Math.min(n.y,e.y))}static Max(n,e){return new V(Math.max(n.x,e.x),Math.max(n.y,e.y))}static From(n){return new V().add(n)}static FromArray(n){return new V(n[0],n[1])}static Rot(n,e=0){const t=Math.sin(e),i=Math.cos(e);return new V(n.x*i-n.y*t,n.x*t+n.y*i)}static RotWith(n,e,t){const i=n.x-e.x,o=n.y-e.y,s=Math.sin(t),a=Math.cos(t);return new V(e.x+(i*a-o*s),e.y+(i*s+o*a))}static NearestPointOnLineThroughPoint(n,e,t){return V.Mul(e,V.Sub(t,n).pry(e)).add(n)}static NearestPointOnLineSegment(n,e,t,i=!0){const o=V.Tan(e,n),s=V.Add(n,V.Mul(o,V.Sub(t,n).pry(o)));if(i){if(s.x<Math.min(n.x,e.x))return V.Cast(n.x<e.x?n:e);if(s.x>Math.max(n.x,e.x))return V.Cast(n.x>e.x?n:e);if(s.y<Math.min(n.y,e.y))return V.Cast(n.y<e.y?n:e);if(s.y>Math.max(n.y,e.y))return V.Cast(n.y>e.y?n:e)}return s}static DistanceToLineThroughPoint(n,e,t){return V.Dist(t,V.NearestPointOnLineThroughPoint(n,e,t))}static DistanceToLineSegment(n,e,t,i=!0){return V.Dist(t,V.NearestPointOnLineSegment(n,e,t,i))}static Snap(n,e=1){return new V(Math.round(n.x/e)*e,Math.round(n.y/e)*e)}static Cast(n){return n instanceof V?n:V.From(n)}static Slope(n,e){return n.x===e.y?NaN:(n.y-e.y)/(n.x-e.x)}static Angle(n,e){return Math.atan2(e.y-n.y,e.x-n.x)}static Lrp(n,e,t){return V.Sub(e,n).mul(t).add(n)}static Med(n,e){return new V((n.x+e.x)/2,(n.y+e.y)/2)}static Equals(n,e,t=1e-4){return Math.abs(n.x-e.x)<t&&Math.abs(n.y-e.y)<t}static EqualsXY(n,e,t){return n.x===e&&n.y===t}static EqualsXYZ(n,e,t=1e-4){return V.Equals(n,e,t)&&Math.abs((n.z||0)-(e.z||0))<t}static Clockwise(n,e,t){return(t.x-n.x)*(e.y-n.y)-(e.x-n.x)*(t.y-n.y)<0}static Rescale(n,e){const t=V.Len(n);return new V(e*n.x/t,e*n.y/t)}static ScaleWithOrigin(n,e,t){return V.Sub(n,t).mul(e).add(t)}static ScaleWOrigin(n,e,t){return V.Sub(n,t).mulV(e).add(t)}static ToFixed(n,e=2){return new V(+n.x.toFixed(e),+n.y.toFixed(e),+n.z.toFixed(e))}static Nudge(n,e,t){return V.Add(n,V.Tan(e,n).mul(t))}static ToString(n){return`${n.x}, ${n.y}`}static ToAngle(n){let e=Math.atan2(n.y,n.x);return e<0&&(e+=Math.PI*2),e}static FromAngle(n,e=1){return new V(Math.cos(n)*e,Math.sin(n)*e)}static ToArray(n){return[n.x,n.y,n.z]}static ToJson(n){const{x:e,y:t,z:i}=n;return{x:e,y:t,z:i}}static Average(n){const e=n.length,t=new V(0,0);for(let i=0;i<e;i++)t.add(n[i]);return t.div(e)}static Clamp(n,e,t){return t===void 0?new V(Math.min(Math.max(n.x,e)),Math.min(Math.max(n.y,e))):new V(Math.min(Math.max(n.x,e),t),Math.min(Math.max(n.y,e),t))}static PointsBetween(n,e,t=6){const i=[];for(let o=0;o<t;o++){const s=Cr.easeInQuad(o/(t-1)),a=V.Lrp(n,e,s);a.z=Math.min(1,.5+Math.abs(.5-kr(s))*.65),i.push(a)}return i}static SnapToGrid(n,e=8){return new V(Math.round(n.x/e)*e,Math.round(n.y/e)*e)}}const kr=r=>r<.5?2*r*r:-1+(4-2*r)*r;class pe extends V{constructor(n=0,e=0,t=0,i={x:0,y:0},o=0,s=0){super(n,e,t),this.x=n,this.y=e,this.z=t,this.v=i,this.t=o,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(n){this.a=n}setT(n){this.t=n}setv(n){return this.v={x:n.x,y:n.y},this}set(n=this.x,e=this.y,t=this.z,i=this.v,o=this.t,s=this.a){return this.x=n,this.y=e,this.z=t,this.v=i,this.t=o,this.a=s,this}clone(){const{x:n,y:e,z:t,v:i,t:o,a:s}=this,a={x:i.x,y:i.y};return new pe(n,e,t,a,o,s)}distance(n){return pe.GetDistance(this,n)}isNear(n,e){return pe.IsNear(this,n,e)}getAngleByPoints(n,e){return pe.GetAngleByPoints(n,this,e)}static Sub(n,e){return new pe(n.x-e.x,n.y-e.y)}static Add(n,e){return new pe(n.x+e.x,n.y+e.y)}static GetDistance(n,e){return pe.Len(n.clone().sub(e))}static GetAngleByPoints(n,e,t){const i=e.x-n.x,o=t.x-e.x,s=e.y-n.y,a=t.y-e.y;let c=0;const l=Math.sqrt(i*i+s*s),u=Math.sqrt(o*o+a*a);if(l&&u){const h=i*o+s*a;c=Math.acos(h/(l*u)),c=c/Math.PI*180;let g=i*a-s*o;g=g>0?1:-1,c=180+g*c}return c}static IsNear(n,e,t){return pe.Len(n.clone().sub(e))<t}static RotWith(n,e,t,i=2){const o=n.x-e.x,s=n.y-e.y,a=Math.sin(t),c=Math.cos(t),l=Math.pow(10,i),u=Math.floor((e.x+(o*c-s*a))*l)/l,h=Math.floor((e.y+(o*a+s*c))*l)/l;return new pe(u,h)}static GetDotStroke(n,e,t=16){const i=new V(1,1),o=Math.PI+.001,s=pe.Add(n,pe.Sub(n,i).uni().per().mul(-e)),a=[];for(let c=1/t,l=c;l<=1;l+=c)a.push(pe.RotWith(s,n,o*2*l));return a}static GetSemicircleStroke(n,e,t=-1,i=8){const o=t*(Math.PI+.001),s=[];for(let a=1/i,c=a;c<=1;c+=a)s.push(pe.RotWith(e,n,o*c));return s}}var sn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function pn(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var xr=typeof sn=="object"&&sn&&sn.Object===Object&&sn,No=xr,br=No,Dr=typeof self=="object"&&self&&self.Object===Object&&self,jr=br||Dr||Function("return this")(),Je=jr,Er=Je,Ar=Er.Symbol,Xt=Ar,ki=Xt,Co=Object.prototype,zr=Co.hasOwnProperty,Lr=Co.toString,Ft=ki?ki.toStringTag:void 0;function Pr(r){var n=zr.call(r,Ft),e=r[Ft];try{r[Ft]=void 0;var t=!0}catch{}var i=Lr.call(r);return t&&(n?r[Ft]=e:delete r[Ft]),i}var Rr=Pr,Or=Object.prototype,Ur=Or.toString;function Yr(r){return Ur.call(r)}var Br=Yr,xi=Xt,$r=Rr,Wr=Br,Vr="[object Null]",Fr="[object Undefined]",bi=xi?xi.toStringTag:void 0;function Gr(r){return r==null?r===void 0?Fr:Vr:bi&&bi in Object(r)?$r(r):Wr(r)}var Pt=Gr;function Qr(r){return r!=null&&typeof r=="object"}var ct=Qr;function Zr(){this.__data__=[],this.size=0}var Hr=Zr;function qr(r,n){return r===n||r!==r&&n!==n}var oi=qr,Jr=oi;function Kr(r,n){for(var e=r.length;e--;)if(Jr(r[e][0],n))return e;return-1}var Mn=Kr,Xr=Mn,_r=Array.prototype,es=_r.splice;function ts(r){var n=this.__data__,e=Xr(n,r);if(e<0)return!1;var t=n.length-1;return e==t?n.pop():es.call(n,e,1),--this.size,!0}var ns=ts,is=Mn;function os(r){var n=this.__data__,e=is(n,r);return e<0?void 0:n[e][1]}var rs=os,ss=Mn;function as(r){return ss(this.__data__,r)>-1}var cs=as,ls=Mn;function us(r,n){var e=this.__data__,t=ls(e,r);return t<0?(++this.size,e.push([r,n])):e[t][1]=n,this}var hs=us,ds=Hr,gs=ns,fs=rs,ps=cs,Ms=hs;function Rt(r){var n=-1,e=r==null?0:r.length;for(this.clear();++n<e;){var t=r[n];this.set(t[0],t[1])}}Rt.prototype.clear=ds;Rt.prototype.delete=gs;Rt.prototype.get=fs;Rt.prototype.has=ps;Rt.prototype.set=Ms;var yn=Rt,ys=yn;function ms(){this.__data__=new ys,this.size=0}var Is=ms;function ws(r){var n=this.__data__,e=n.delete(r);return this.size=n.size,e}var Ts=ws;function Ss(r){return this.__data__.get(r)}var vs=Ss;function Ns(r){return this.__data__.has(r)}var Cs=Ns;function ks(r){var n=typeof r;return r!=null&&(n=="object"||n=="function")}var lt=ks,xs=Pt,bs=lt,Ds="[object AsyncFunction]",js="[object Function]",Es="[object GeneratorFunction]",As="[object Proxy]";function zs(r){if(!bs(r))return!1;var n=xs(r);return n==js||n==Es||n==Ds||n==As}var ko=zs,Ls=Je,Ps=Ls["__core-js_shared__"],Rs=Ps,Dn=Rs,Di=function(){var r=/[^.]+$/.exec(Dn&&Dn.keys&&Dn.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function Os(r){return!!Di&&Di in r}var Us=Os,Ys=Function.prototype,Bs=Ys.toString;function $s(r){if(r!=null){try{return Bs.call(r)}catch{}try{return r+""}catch{}}return""}var xo=$s,Ws=ko,Vs=Us,Fs=lt,Gs=xo,Qs=/[\\^$.*+?()[\]{}|]/g,Zs=/^\[object .+?Constructor\]$/,Hs=Function.prototype,qs=Object.prototype,Js=Hs.toString,Ks=qs.hasOwnProperty,Xs=RegExp("^"+Js.call(Ks).replace(Qs,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function _s(r){if(!Fs(r)||Vs(r))return!1;var n=Ws(r)?Xs:Zs;return n.test(Gs(r))}var ea=_s;function ta(r,n){return r==null?void 0:r[n]}var na=ta,ia=ea,oa=na;function ra(r,n){var e=oa(r,n);return ia(e)?e:void 0}var Ct=ra,sa=Ct,aa=Je,ca=sa(aa,"Map"),ri=ca,la=Ct,ua=la(Object,"create"),mn=ua,ji=mn;function ha(){this.__data__=ji?ji(null):{},this.size=0}var da=ha;function ga(r){var n=this.has(r)&&delete this.__data__[r];return this.size-=n?1:0,n}var fa=ga,pa=mn,Ma="__lodash_hash_undefined__",ya=Object.prototype,ma=ya.hasOwnProperty;function Ia(r){var n=this.__data__;if(pa){var e=n[r];return e===Ma?void 0:e}return ma.call(n,r)?n[r]:void 0}var wa=Ia,Ta=mn,Sa=Object.prototype,va=Sa.hasOwnProperty;function Na(r){var n=this.__data__;return Ta?n[r]!==void 0:va.call(n,r)}var Ca=Na,ka=mn,xa="__lodash_hash_undefined__";function ba(r,n){var e=this.__data__;return this.size+=this.has(r)?0:1,e[r]=ka&&n===void 0?xa:n,this}var Da=ba,ja=da,Ea=fa,Aa=wa,za=Ca,La=Da;function Ot(r){var n=-1,e=r==null?0:r.length;for(this.clear();++n<e;){var t=r[n];this.set(t[0],t[1])}}Ot.prototype.clear=ja;Ot.prototype.delete=Ea;Ot.prototype.get=Aa;Ot.prototype.has=za;Ot.prototype.set=La;var Pa=Ot,Ei=Pa,Ra=yn,Oa=ri;function Ua(){this.size=0,this.__data__={hash:new Ei,map:new(Oa||Ra),string:new Ei}}var Ya=Ua;function Ba(r){var n=typeof r;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?r!=="__proto__":r===null}var $a=Ba,Wa=$a;function Va(r,n){var e=r.__data__;return Wa(n)?e[typeof n=="string"?"string":"hash"]:e.map}var In=Va,Fa=In;function Ga(r){var n=Fa(this,r).delete(r);return this.size-=n?1:0,n}var Qa=Ga,Za=In;function Ha(r){return Za(this,r).get(r)}var qa=Ha,Ja=In;function Ka(r){return Ja(this,r).has(r)}var Xa=Ka,_a=In;function ec(r,n){var e=_a(this,r),t=e.size;return e.set(r,n),this.size+=e.size==t?0:1,this}var tc=ec,nc=Ya,ic=Qa,oc=qa,rc=Xa,sc=tc;function Ut(r){var n=-1,e=r==null?0:r.length;for(this.clear();++n<e;){var t=r[n];this.set(t[0],t[1])}}Ut.prototype.clear=nc;Ut.prototype.delete=ic;Ut.prototype.get=oc;Ut.prototype.has=rc;Ut.prototype.set=sc;var bo=Ut,ac=yn,cc=ri,lc=bo,uc=200;function hc(r,n){var e=this.__data__;if(e instanceof ac){var t=e.__data__;if(!cc||t.length<uc-1)return t.push([r,n]),this.size=++e.size,this;e=this.__data__=new lc(t)}return e.set(r,n),this.size=e.size,this}var dc=hc,gc=yn,fc=Is,pc=Ts,Mc=vs,yc=Cs,mc=dc;function Yt(r){var n=this.__data__=new gc(r);this.size=n.size}Yt.prototype.clear=fc;Yt.prototype.delete=pc;Yt.prototype.get=Mc;Yt.prototype.has=yc;Yt.prototype.set=mc;var Do=Yt;function Ic(r,n){for(var e=-1,t=r==null?0:r.length;++e<t&&n(r[e],e,r)!==!1;);return r}var wc=Ic,Tc=Ct,Sc=function(){try{var r=Tc(Object,"defineProperty");return r({},"",{}),r}catch{}}(),jo=Sc,Ai=jo;function vc(r,n,e){n=="__proto__"&&Ai?Ai(r,n,{configurable:!0,enumerable:!0,value:e,writable:!0}):r[n]=e}var Eo=vc,Nc=Eo,Cc=oi,kc=Object.prototype,xc=kc.hasOwnProperty;function bc(r,n,e){var t=r[n];(!(xc.call(r,n)&&Cc(t,e))||e===void 0&&!(n in r))&&Nc(r,n,e)}var Ao=bc,Dc=Ao,jc=Eo;function Ec(r,n,e,t){var i=!e;e||(e={});for(var o=-1,s=n.length;++o<s;){var a=n[o],c=t?t(e[a],r[a],a,e,r):void 0;c===void 0&&(c=r[a]),i?jc(e,a,c):Dc(e,a,c)}return e}var wn=Ec;function Ac(r,n){for(var e=-1,t=Array(r);++e<r;)t[e]=n(e);return t}var zc=Ac,Lc=Pt,Pc=ct,Rc="[object Arguments]";function Oc(r){return Pc(r)&&Lc(r)==Rc}var Uc=Oc,zi=Uc,Yc=ct,zo=Object.prototype,Bc=zo.hasOwnProperty,$c=zo.propertyIsEnumerable,Wc=zi(function(){return arguments}())?zi:function(r){return Yc(r)&&Bc.call(r,"callee")&&!$c.call(r,"callee")},Lo=Wc,Vc=Array.isArray,_t=Vc,ln={exports:{}};function Fc(){return!1}var Gc=Fc;ln.exports;(function(r,n){var e=Je,t=Gc,i=n&&!n.nodeType&&n,o=i&&!0&&r&&!r.nodeType&&r,s=o&&o.exports===i,a=s?e.Buffer:void 0,c=a?a.isBuffer:void 0,l=c||t;r.exports=l})(ln,ln.exports);var si=ln.exports,Qc=9007199254740991,Zc=/^(?:0|[1-9]\d*)$/;function Hc(r,n){var e=typeof r;return n=n??Qc,!!n&&(e=="number"||e!="symbol"&&Zc.test(r))&&r>-1&&r%1==0&&r<n}var qc=Hc,Jc=9007199254740991;function Kc(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=Jc}var Po=Kc,Xc=Pt,_c=Po,el=ct,tl="[object Arguments]",nl="[object Array]",il="[object Boolean]",ol="[object Date]",rl="[object Error]",sl="[object Function]",al="[object Map]",cl="[object Number]",ll="[object Object]",ul="[object RegExp]",hl="[object Set]",dl="[object String]",gl="[object WeakMap]",fl="[object ArrayBuffer]",pl="[object DataView]",Ml="[object Float32Array]",yl="[object Float64Array]",ml="[object Int8Array]",Il="[object Int16Array]",wl="[object Int32Array]",Tl="[object Uint8Array]",Sl="[object Uint8ClampedArray]",vl="[object Uint16Array]",Nl="[object Uint32Array]",ve={};ve[Ml]=ve[yl]=ve[ml]=ve[Il]=ve[wl]=ve[Tl]=ve[Sl]=ve[vl]=ve[Nl]=!0;ve[tl]=ve[nl]=ve[fl]=ve[il]=ve[pl]=ve[ol]=ve[rl]=ve[sl]=ve[al]=ve[cl]=ve[ll]=ve[ul]=ve[hl]=ve[dl]=ve[gl]=!1;function Cl(r){return el(r)&&_c(r.length)&&!!ve[Xc(r)]}var kl=Cl;function xl(r){return function(n){return r(n)}}var Tn=xl,un={exports:{}};un.exports;(function(r,n){var e=No,t=n&&!n.nodeType&&n,i=t&&!0&&r&&!r.nodeType&&r,o=i&&i.exports===t,s=o&&e.process,a=function(){try{var c=i&&i.require&&i.require("util").types;return c||s&&s.binding&&s.binding("util")}catch{}}();r.exports=a})(un,un.exports);var ai=un.exports,bl=kl,Dl=Tn,Li=ai,Pi=Li&&Li.isTypedArray,jl=Pi?Dl(Pi):bl,Ro=jl,El=zc,Al=Lo,zl=_t,Ll=si,Pl=qc,Rl=Ro,Ol=Object.prototype,Ul=Ol.hasOwnProperty;function Yl(r,n){var e=zl(r),t=!e&&Al(r),i=!e&&!t&&Ll(r),o=!e&&!t&&!i&&Rl(r),s=e||t||i||o,a=s?El(r.length,String):[],c=a.length;for(var l in r)(n||Ul.call(r,l))&&!(s&&(l=="length"||i&&(l=="offset"||l=="parent")||o&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||Pl(l,c)))&&a.push(l);return a}var Oo=Yl,Bl=Object.prototype;function $l(r){var n=r&&r.constructor,e=typeof n=="function"&&n.prototype||Bl;return r===e}var ci=$l;function Wl(r,n){return function(e){return r(n(e))}}var Uo=Wl,Vl=Uo,Fl=Vl(Object.keys,Object),Gl=Fl,Ql=ci,Zl=Gl,Hl=Object.prototype,ql=Hl.hasOwnProperty;function Jl(r){if(!Ql(r))return Zl(r);var n=[];for(var e in Object(r))ql.call(r,e)&&e!="constructor"&&n.push(e);return n}var Kl=Jl,Xl=ko,_l=Po;function eu(r){return r!=null&&_l(r.length)&&!Xl(r)}var li=eu,tu=Oo,nu=Kl,iu=li;function ou(r){return iu(r)?tu(r):nu(r)}var ui=ou,ru=wn,su=ui;function au(r,n){return r&&ru(n,su(n),r)}var cu=au;function lu(r){var n=[];if(r!=null)for(var e in Object(r))n.push(e);return n}var uu=lu,hu=lt,du=ci,gu=uu,fu=Object.prototype,pu=fu.hasOwnProperty;function Mu(r){if(!hu(r))return gu(r);var n=du(r),e=[];for(var t in r)t=="constructor"&&(n||!pu.call(r,t))||e.push(t);return e}var yu=Mu,mu=Oo,Iu=yu,wu=li;function Tu(r){return wu(r)?mu(r,!0):Iu(r)}var hi=Tu,Su=wn,vu=hi;function Nu(r,n){return r&&Su(n,vu(n),r)}var Cu=Nu,hn={exports:{}};hn.exports;(function(r,n){var e=Je,t=n&&!n.nodeType&&n,i=t&&!0&&r&&!r.nodeType&&r,o=i&&i.exports===t,s=o?e.Buffer:void 0,a=s?s.allocUnsafe:void 0;function c(l,u){if(u)return l.slice();var h=l.length,g=a?a(h):new l.constructor(h);return l.copy(g),g}r.exports=c})(hn,hn.exports);var ku=hn.exports;function xu(r,n){var e=-1,t=r.length;for(n||(n=Array(t));++e<t;)n[e]=r[e];return n}var bu=xu;function Du(r,n){for(var e=-1,t=r==null?0:r.length,i=0,o=[];++e<t;){var s=r[e];n(s,e,r)&&(o[i++]=s)}return o}var Yo=Du;function ju(){return[]}var Bo=ju,Eu=Yo,Au=Bo,zu=Object.prototype,Lu=zu.propertyIsEnumerable,Ri=Object.getOwnPropertySymbols,Pu=Ri?function(r){return r==null?[]:(r=Object(r),Eu(Ri(r),function(n){return Lu.call(r,n)}))}:Au,di=Pu,Ru=wn,Ou=di;function Uu(r,n){return Ru(r,Ou(r),n)}var Yu=Uu;function Bu(r,n){for(var e=-1,t=n.length,i=r.length;++e<t;)r[i+e]=n[e];return r}var gi=Bu,$u=Uo,Wu=$u(Object.getPrototypeOf,Object),$o=Wu,Vu=gi,Fu=$o,Gu=di,Qu=Bo,Zu=Object.getOwnPropertySymbols,Hu=Zu?function(r){for(var n=[];r;)Vu(n,Gu(r)),r=Fu(r);return n}:Qu,Wo=Hu,qu=wn,Ju=Wo;function Ku(r,n){return qu(r,Ju(r),n)}var Xu=Ku,_u=gi,eh=_t;function th(r,n,e){var t=n(r);return eh(r)?t:_u(t,e(r))}var Vo=th,nh=Vo,ih=di,oh=ui;function rh(r){return nh(r,oh,ih)}var Fo=rh,sh=Vo,ah=Wo,ch=hi;function lh(r){return sh(r,ch,ah)}var uh=lh,hh=Ct,dh=Je,gh=hh(dh,"DataView"),fh=gh,ph=Ct,Mh=Je,yh=ph(Mh,"Promise"),mh=yh,Ih=Ct,wh=Je,Th=Ih(wh,"Set"),Go=Th,Sh=Ct,vh=Je,Nh=Sh(vh,"WeakMap"),Ch=Nh,Bn=fh,$n=ri,Wn=mh,Vn=Go,Fn=Ch,Qo=Pt,Bt=xo,Oi="[object Map]",kh="[object Object]",Ui="[object Promise]",Yi="[object Set]",Bi="[object WeakMap]",$i="[object DataView]",xh=Bt(Bn),bh=Bt($n),Dh=Bt(Wn),jh=Bt(Vn),Eh=Bt(Fn),It=Qo;(Bn&&It(new Bn(new ArrayBuffer(1)))!=$i||$n&&It(new $n)!=Oi||Wn&&It(Wn.resolve())!=Ui||Vn&&It(new Vn)!=Yi||Fn&&It(new Fn)!=Bi)&&(It=function(r){var n=Qo(r),e=n==kh?r.constructor:void 0,t=e?Bt(e):"";if(t)switch(t){case xh:return $i;case bh:return Oi;case Dh:return Ui;case jh:return Yi;case Eh:return Bi}return n});var Sn=It,Ah=Object.prototype,zh=Ah.hasOwnProperty;function Lh(r){var n=r.length,e=new r.constructor(n);return n&&typeof r[0]=="string"&&zh.call(r,"index")&&(e.index=r.index,e.input=r.input),e}var Ph=Lh,Rh=Je,Oh=Rh.Uint8Array,Zo=Oh,Wi=Zo;function Uh(r){var n=new r.constructor(r.byteLength);return new Wi(n).set(new Wi(r)),n}var fi=Uh,Yh=fi;function Bh(r,n){var e=n?Yh(r.buffer):r.buffer;return new r.constructor(e,r.byteOffset,r.byteLength)}var $h=Bh,Wh=/\w*$/;function Vh(r){var n=new r.constructor(r.source,Wh.exec(r));return n.lastIndex=r.lastIndex,n}var Fh=Vh,Vi=Xt,Fi=Vi?Vi.prototype:void 0,Gi=Fi?Fi.valueOf:void 0;function Gh(r){return Gi?Object(Gi.call(r)):{}}var Qh=Gh,Zh=fi;function Hh(r,n){var e=n?Zh(r.buffer):r.buffer;return new r.constructor(e,r.byteOffset,r.length)}var qh=Hh,Jh=fi,Kh=$h,Xh=Fh,_h=Qh,ed=qh,td="[object Boolean]",nd="[object Date]",id="[object Map]",od="[object Number]",rd="[object RegExp]",sd="[object Set]",ad="[object String]",cd="[object Symbol]",ld="[object ArrayBuffer]",ud="[object DataView]",hd="[object Float32Array]",dd="[object Float64Array]",gd="[object Int8Array]",fd="[object Int16Array]",pd="[object Int32Array]",Md="[object Uint8Array]",yd="[object Uint8ClampedArray]",md="[object Uint16Array]",Id="[object Uint32Array]";function wd(r,n,e){var t=r.constructor;switch(n){case ld:return Jh(r);case td:case nd:return new t(+r);case ud:return Kh(r,e);case hd:case dd:case gd:case fd:case pd:case Md:case yd:case md:case Id:return ed(r,e);case id:return new t;case od:case ad:return new t(r);case rd:return Xh(r);case sd:return new t;case cd:return _h(r)}}var Td=wd,Sd=lt,Qi=Object.create,vd=function(){function r(){}return function(n){if(!Sd(n))return{};if(Qi)return Qi(n);r.prototype=n;var e=new r;return r.prototype=void 0,e}}(),Nd=vd,Cd=Nd,kd=$o,xd=ci;function bd(r){return typeof r.constructor=="function"&&!xd(r)?Cd(kd(r)):{}}var Dd=bd,jd=Sn,Ed=ct,Ad="[object Map]";function zd(r){return Ed(r)&&jd(r)==Ad}var Ld=zd,Pd=Ld,Rd=Tn,Zi=ai,Hi=Zi&&Zi.isMap,Od=Hi?Rd(Hi):Pd,Ud=Od,Yd=Sn,Bd=ct,$d="[object Set]";function Wd(r){return Bd(r)&&Yd(r)==$d}var Vd=Wd,Fd=Vd,Gd=Tn,qi=ai,Ji=qi&&qi.isSet,Qd=Ji?Gd(Ji):Fd,Ho=Qd;const Zd=pn(Ho);var Hd=Do,qd=wc,Jd=Ao,Kd=cu,Xd=Cu,_d=ku,eg=bu,tg=Yu,ng=Xu,ig=Fo,og=uh,rg=Sn,sg=Ph,ag=Td,cg=Dd,lg=_t,ug=si,hg=Ud,dg=lt,gg=Ho,fg=ui,pg=hi,Mg=1,yg=2,mg=4,qo="[object Arguments]",Ig="[object Array]",wg="[object Boolean]",Tg="[object Date]",Sg="[object Error]",Jo="[object Function]",vg="[object GeneratorFunction]",Ng="[object Map]",Cg="[object Number]",Ko="[object Object]",kg="[object RegExp]",xg="[object Set]",bg="[object String]",Dg="[object Symbol]",jg="[object WeakMap]",Eg="[object ArrayBuffer]",Ag="[object DataView]",zg="[object Float32Array]",Lg="[object Float64Array]",Pg="[object Int8Array]",Rg="[object Int16Array]",Og="[object Int32Array]",Ug="[object Uint8Array]",Yg="[object Uint8ClampedArray]",Bg="[object Uint16Array]",$g="[object Uint32Array]",Se={};Se[qo]=Se[Ig]=Se[Eg]=Se[Ag]=Se[wg]=Se[Tg]=Se[zg]=Se[Lg]=Se[Pg]=Se[Rg]=Se[Og]=Se[Ng]=Se[Cg]=Se[Ko]=Se[kg]=Se[xg]=Se[bg]=Se[Dg]=Se[Ug]=Se[Yg]=Se[Bg]=Se[$g]=!0;Se[Sg]=Se[Jo]=Se[jg]=!1;function cn(r,n,e,t,i,o){var s,a=n&Mg,c=n&yg,l=n&mg;if(e&&(s=i?e(r,t,i,o):e(r)),s!==void 0)return s;if(!dg(r))return r;var u=lg(r);if(u){if(s=sg(r),!a)return eg(r,s)}else{var h=rg(r),g=h==Jo||h==vg;if(ug(r))return _d(r,a);if(h==Ko||h==qo||g&&!i){if(s=c||g?{}:cg(r),!a)return c?ng(r,Xd(s,r)):tg(r,Kd(s,r))}else{if(!Se[h])return i?r:{};s=ag(r,h,a)}}o||(o=new Hd);var y=o.get(r);if(y)return y;o.set(r,s),gg(r)?r.forEach(function(w){s.add(cn(w,n,e,w,r,o))}):hg(r)&&r.forEach(function(w,m){s.set(m,cn(w,n,e,m,r,o))});var d=l?c?og:ig:c?pg:fg,M=u?void 0:d(r);return qd(M||r,function(w,m){M&&(m=w,w=r[m]),Jd(s,m,cn(w,n,e,m,r,o))}),s}var Wg=cn,Vg=Wg,Fg=1,Gg=4;function Qg(r){return Vg(r,Fg|Gg)}var Zg=Qg;const en=pn(Zg),Xo="1.1.36-beta.2",Hg="@netless/appliance-plugin",Ki=typeof OffscreenCanvas=="function"?"worker":"mainThread";if(typeof window<"u"){let r=window.__netlessUA||"";r+=` ${Hg}@${Xo}`,window.__netlessUA=r}const Ie={useWorker:"auto",useSimple:!0,useBackgroundThread:!1,syncOpt:{interval:300,smoothSync:!0},cursor:{enable:!0,expirationTime:5e3,moveDelayTime:40},bufferSize:{full:2e4,sub:600},bezier:{enable:!1,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:!0,extendFontFaces:[],loadFontFacesTimeout:2e4},longDottedStroke:{lineCap:"round",segment:1,gap:2},dottedStroke:{lineCap:"round",segment:1,gap:2},normalStroke:{lineCap:"round"},undoRedo:{enableGlobal:!1,maxStackLength:20,timingFix:!0,ackTimeout:5e3,gracePeriodTimeout:3e3,doingFallbackTimeout:3e4},markmap:{enable:!0,timeout:1e4,options:{autoFit:!0,duration:0,zoom:!1,pan:!1,maxInitialScale:10}},overwriteSelectorStyles:{}};function vn(r){return JSON.parse(So.decompress(r))}function vt(r){return So.compress(JSON.stringify(r))}const je=Object.keys,We="++",Q="selector",_o="all";var qg="__lodash_hash_undefined__";function Jg(r){return this.__data__.set(r,qg),this}var Kg=Jg;function Xg(r){return this.__data__.has(r)}var _g=Xg,ef=bo,tf=Kg,nf=_g;function dn(r){var n=-1,e=r==null?0:r.length;for(this.__data__=new ef;++n<e;)this.add(r[n])}dn.prototype.add=dn.prototype.push=tf;dn.prototype.has=nf;var pi=dn;function of(r,n){for(var e=-1,t=r==null?0:r.length;++e<t;)if(n(r[e],e,r))return!0;return!1}var rf=of;function sf(r,n){return r.has(n)}var Mi=sf,af=pi,cf=rf,lf=Mi,uf=1,hf=2;function df(r,n,e,t,i,o){var s=e&uf,a=r.length,c=n.length;if(a!=c&&!(s&&c>a))return!1;var l=o.get(r),u=o.get(n);if(l&&u)return l==n&&u==r;var h=-1,g=!0,y=e&hf?new af:void 0;for(o.set(r,n),o.set(n,r);++h<a;){var d=r[h],M=n[h];if(t)var w=s?t(M,d,h,n,r,o):t(d,M,h,r,n,o);if(w!==void 0){if(w)continue;g=!1;break}if(y){if(!cf(n,function(m,p){if(!lf(y,p)&&(d===m||i(d,m,e,t,o)))return y.push(p)})){g=!1;break}}else if(!(d===M||i(d,M,e,t,o))){g=!1;break}}return o.delete(r),o.delete(n),g}var er=df;function gf(r){var n=-1,e=Array(r.size);return r.forEach(function(t,i){e[++n]=[i,t]}),e}var ff=gf;function pf(r){var n=-1,e=Array(r.size);return r.forEach(function(t){e[++n]=t}),e}var yi=pf,Xi=Xt,_i=Zo,Mf=oi,yf=er,mf=ff,If=yi,wf=1,Tf=2,Sf="[object Boolean]",vf="[object Date]",Nf="[object Error]",Cf="[object Map]",kf="[object Number]",xf="[object RegExp]",bf="[object Set]",Df="[object String]",jf="[object Symbol]",Ef="[object ArrayBuffer]",Af="[object DataView]",eo=Xi?Xi.prototype:void 0,jn=eo?eo.valueOf:void 0;function zf(r,n,e,t,i,o,s){switch(e){case Af:if(r.byteLength!=n.byteLength||r.byteOffset!=n.byteOffset)return!1;r=r.buffer,n=n.buffer;case Ef:return!(r.byteLength!=n.byteLength||!o(new _i(r),new _i(n)));case Sf:case vf:case kf:return Mf(+r,+n);case Nf:return r.name==n.name&&r.message==n.message;case xf:case Df:return r==n+"";case Cf:var a=mf;case bf:var c=t&wf;if(a||(a=If),r.size!=n.size&&!c)return!1;var l=s.get(r);if(l)return l==n;t|=Tf,s.set(r,n);var u=yf(a(r),a(n),t,i,o,s);return s.delete(r),u;case jf:if(jn)return jn.call(r)==jn.call(n)}return!1}var Lf=zf;function tn(r,n,e){return"#"+((r<<16)+(n<<8)+e).toString(16).padStart(6,"0")}function Ee(r,n=1){return"rgba("+parseInt("0x"+r.slice(1,3))+","+parseInt("0x"+r.slice(3,5))+","+parseInt("0x"+r.slice(5,7))+","+n+")"}function Dt(r,n,e,t=1){return`rgba(${r},${n},${e},${t})`}function Nn(r){const n=r.split(","),e=parseInt(n[0].split("(")[1]),t=parseInt(n[1]),i=parseInt(n[2]),o=Number(n[3].split(")")[0]);return[tn(e,t,i),o]}function Zt(r){const n=r.split(","),e=parseInt(n[0].split("(")[1]),t=parseInt(n[1]),i=parseInt(n[2]),o=Number(n[3].split(")")[0]);return[e,t,i,o]}function an(r){return r==="transparent"}var qe=(r=>(r[r.Text=1]="Text",r[r.Shape=2]="Shape",r))(qe||{});const Ue=class Ue{createProxy(n){const e=new Proxy(n,{get(t,i,o){const s=Ue.interceptors.hasOwnProperty(i)?Ue.interceptors:t;return Reflect.get(s,i,o)}});return Ue.proxyToRaw.set(e,n),e}};I(Ue,"proxyToRaw",new WeakMap),I(Ue,"interceptors",{entries(...n){return Ue.proxyToRaw.get(this).entries(...n)},forEach(...n){return Ue.proxyToRaw.get(this).forEach(...n)},size(){return Ue.proxyToRaw.get(this).size},get(n){return Ue.proxyToRaw.get(this).get(n)},set(n,e){return Ue.proxyToRaw.get(this).set(n,e)},delete(n){return Ue.proxyToRaw.get(this).delete(n)},clear(){return Ue.proxyToRaw.get(this).clear()}});let wt=Ue;const Gn=5;class Pf{constructor(n){I(this,"internalMsgEmitter");I(this,"publicMsgEmitter");I(this,"control");I(this,"editors");I(this,"activeId");I(this,"proxyMap");I(this,"taskqueue",new Map);I(this,"undoTickerId");I(this,"checkLocalTextBlur",j.debounce(()=>{if(this.collector)for(const[n,e]of this.editors.entries())e.opt.workState!==D.Done&&this.collector.isLocalId(n)&&this.activeId!==n&&(e.opt.text&&e.opt.text.replace(/\s*,/g,"")?this.unActive(n):this.delete(n,!0,!0))},100));const{control:e,internalMsgEmitter:t,publicMsgEmitter:i}=n;this.control=e,this.internalMsgEmitter=t,this.publicMsgEmitter=i;const o=new Map;this.proxyMap=new wt;const s=this,a=wt.interceptors.set;wt.interceptors.set=function(l,u){return s.interceptors.set(l,u),a.call(this,l,u)};const c=wt.interceptors.delete;wt.interceptors.delete=function(l){return s.interceptors.delete(l),c.call(this,l)},this.editors=this.proxyMap.createProxy(o)}get collector(){return this.control.collector}set UndoTickerId(n){this.undoTickerId=n}get UndoTickerId(){return this.undoTickerId}getDoneUndoTicker(n,e,t){const i=t??e,o=this.control.viewContainerManager.getUndoTickerId(n);if(i===D.Done)return this.undoTickerId&&o===this.undoTickerId?this.undoTickerId:o}ackDoneRender(n,e,t,i,o){n&&(this.internalMsgEmitter.emit("ackRenderUndoTicker",n,e,t,{requestId:i,emitEventType:o}),this.undoTickerId=void 0)}filterEditor(n){const e=new Map;return this.editors.forEach((t,i)=>{t.viewId===n&&e.set(i,t)}),e}get interceptors(){return{set:(n,e)=>{var p,T,v,C,N,k,P,A,x;if(!this.collector)return!0;const{viewId:t,scenePath:i,canSync:o,canWorker:s,type:a,opt:c,dataType:l,updateNodeOpt:u,requestId:h,emitEventType:g,skipStorageDispatch:y}=e,d=this.getDoneUndoTicker(t,c==null?void 0:c.workState,u==null?void 0:u.workState);if(!s&&!o)return!0;const w=((p=this.collector)==null?void 0:p.isLocalId(n))?(T=this.collector)==null?void 0:T.transformKey(n):n,m=((v=this.collector)==null?void 0:v.storage[t])&&this.collector.storage[t][i]&&this.collector.storage[t][i][w]||void 0;m?m.toolsType===S.Text&&(s&&(this.control.worker.queryTaskBatchData({workId:n,msgType:$.UpdateNode}).forEach(E=>{var b;(b=this.control.worker)==null||b.taskBatchData.delete(E)}),(P=this.control.worker)==null||P.taskBatchData.add({workId:n,msgType:$.UpdateNode,dataType:l||_.Local,toolsType:S.Text,opt:c,viewId:t,scenePath:i,willRefresh:!0}),(A=this.control.worker)==null||A.runAnimation()),o&&!y&&((x=this.collector)==null||x.dispatch({type:$.UpdateNode,workId:n,toolsType:S.Text,opt:c,viewId:t,scenePath:i,updateNodeOpt:u,requestId:h,emitEventType:g,needUndoTicker:d}),this.ackDoneRender(d,t,i,h,g),c.workState===D.Done&&this.control.runEffectWork(()=>{this.control.worker.setShapeSelectorByWorkId(n,t)}))):a===qe.Text&&(o&&!y&&((C=this.collector)==null||C.dispatch({type:c.text&&$.FullWork||$.CreateWork,workId:n,toolsType:S.Text,opt:c,isSync:!0,viewId:t,scenePath:i,updateNodeOpt:u,requestId:h,emitEventType:g,needUndoTicker:d}),this.ackDoneRender(d,t,i,h,g)),s&&((N=this.control.worker)==null||N.taskBatchData.add({workId:n,msgType:c.text&&$.FullWork||$.CreateWork,dataType:l||_.Local,toolsType:S.Text,opt:c,viewId:t,scenePath:i,willRefresh:!0}),(k=this.control.worker)==null||k.runAnimation()))},delete:n=>{var c,l,u;if(!this.collector)return!0;const e=this.editors.get(n);if(!e)return!0;const{viewId:t,scenePath:i,canSync:o,canWorker:s}=e,a=this.getDoneUndoTicker(t,D.Done);if(!s&&!o)return!0;s&&((c=this.control.worker)==null||c.taskBatchData.add({workId:n,toolsType:S.Text,msgType:$.RemoveNode,dataType:_.Local,viewId:t,scenePath:i,willRefresh:!0}),(l=this.control.worker)==null||l.runAnimation()),o&&((u=this.collector)==null||u.dispatch({type:$.RemoveNode,removeIds:[n],toolsType:S.Text,viewId:t,scenePath:i,needUndoTicker:a}),this.ackDoneRender(a,t,i))},clear(){return!0}}}computeTextActive(n,e){var o,s,a,c;const t=(o=this.control.viewContainerManager)==null?void 0:o.transformToScenePoint(n,e),i=(s=this.control.viewContainerManager)==null?void 0:s.getCurScenePath(e);e&&i&&((a=this.control.worker)==null||a.taskBatchData.add({msgType:$.GetTextActive,dataType:_.Local,op:t,viewId:e,scenePath:i}),(c=this.control.worker)==null||c.runAnimation())}checkEmptyTextBlur(){var e;let n=this.activeId;for(const[t,i]of this.editors.entries())if(i.opt.uid&&i.opt.uid===((e=this.collector)==null?void 0:e.uid)){n=t;break}if(n){const t=this.editors.get(n);(t==null?void 0:t.opt.text)&&(t==null?void 0:t.opt.text.replace(/\s*,/g,""))?this.unActive(n):this.delete(n,!0,!0)}this.checkLocalTextBlur()}onCameraChange(n,e){var t,i;for(const[o,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)),u=(i=this.control.viewContainerManager)==null?void 0:i.getCurScenePath(e);if(u&&e){const h={x:l&&l[0]||0,y:l&&l[1]||0,w:c&&c[0]||0,h:c&&c[1]||0,opt:s.opt,scale:n.scale,type:qe.Text,viewId:e,scenePath:u,canWorker:!1,canSync:!1};this.editors.set(o,h),this.control.viewContainerManager.updateTextEditorInfo(e,this.activeId)}}}onServiceDerive(n){var M,w,m;const{workId:e,opt:t,msgType:i,viewId:o,scenePath:s,dataType:a,updateNodeOpt:c}=n;if(!e||!o||!s)return;const l=e.toString();if(i===$.RemoveNode){this.delete(l,!0,!0);return}const{boxPoint:u,boxSize:h}=t,g=u&&((M=this.control.viewContainerManager)==null?void 0:M.transformToOriginPoint(u,o)),y=this.control.viewContainerManager.getView(o),d={x:g&&g[0]||0,y:g&&g[1]||0,w:h&&h[0]||0,h:h&&h[1]||0,opt:t,type:qe.Text,canWorker:!0,canSync:!1,dataType:a,scale:((w=y==null?void 0:y.cameraOpt)==null?void 0:w.scale)||1,viewId:o,scenePath:s};if(t&&t.workState===D.Done&&!this.control.cursor.isEnableCursor&&u&&h){let T=c==null?void 0:c.uid;if(!T){const v=this.editors.get(l);T=v&&((m=v.opt)==null?void 0:m.uid)}T&&this.control.cursor.collectServiceCursor({op:u&&[u[0]+h[0],u[1]+h[1]],uid:T,workState:D.Done,viewId:o,type:$.Cursor})}this.editors.set(l,d),a===_.Service&&t.workState===D.Done&&this.activeId===l&&(this.activeId=void 0),this.control.viewContainerManager.updateTextEditorInfo(o,this.activeId)}updateForViewEdited(n,e){var i;this.editors.set(n,e);const t=(i=this.taskqueue.get(n))==null?void 0:i.resolve;t&&t(e)}active(n,e){var i;const t=this.editors.get(n);t&&t.viewId&&(t.opt.workState=D.Start,t.opt.uid=(i=this.collector)==null?void 0:i.uid,this.activeId=n,t.canWorker=!0,t.canSync=!0,e&&t.viewId&&this.addUndoTicker(e,t.viewId),t.undoTickerId=e||t.undoTickerId||this.undoTickerId,this.editors.set(n,t),this.control.viewContainerManager.updateTextEditorInfo(t.viewId,this.activeId))}unActive(n){var t;const e=this.editors.get(n);if(e&&e.viewId){const i=e.undoTickerId||this.control.viewContainerManager.getUndoTickerId(e.viewId)||this.undoTickerId;i&&this.internalMsgEmitter.emit("finalizeRequested",i,e.viewId,[n],e.scenePath),e.opt.workState=D.Done,e.opt.uid=void 0,e.canWorker=!0,e.canSync=!0,this.editors.set(n,e),this.activeId=void 0;const o=(t=this.control.viewContainerManager.getView(e.viewId))==null?void 0:t.container;if(o){const s=CSS.escape(n),a=o.querySelector(`.editor-box #${s}`);a&&a.blur()}this.control.viewContainerManager.updateTextEditorInfo(e.viewId,this.activeId)}}addUndoTicker(n,e){this.internalMsgEmitter.emit("addUndoTicker",n,e,{render:!0,storage:!0}),this.undoTickerId=n}createTextForMasterController(n,e){var s;const{workId:t,isActive:i,...o}=n;e&&this.addUndoTicker(e,o.viewId),o.opt.uid=(s=this.collector)==null?void 0:s.uid,o.undoTickerId=e||o.undoTickerId||this.undoTickerId,i&&(this.activeId=t),o.dataType=_.Local,o.canWorker=!0,o.canSync=!0,this.editors.set(t,o),this.control.viewContainerManager.updateTextEditorInfo(o.viewId,this.activeId)}updateTextForMasterController(n,e){var s;const{workId:t,...i}=n;e&&this.addUndoTicker(e,i.viewId);const o=this.editors.get(t)||{};i.opt&&(i.opt.uid=(s=this.collector)==null?void 0:s.uid),i.undoTickerId=e||o.undoTickerId||this.undoTickerId,i.dataType=_.Local,this.editors.set(t,{...o,...i}),this.control.viewContainerManager.updateTextEditorInfo(i.viewId,this.activeId)}async updateTextControllerWithEffectAsync(n,e){var u;const{workId:t,...i}=n;e&&this.addUndoTicker(e,i.viewId);const o=this.editors.get(t)||{};i.opt&&(i.opt.uid=(u=this.collector)==null?void 0:u.uid),i.undoTickerId=e||o.undoTickerId||this.undoTickerId,i.dataType=_.Local;const s={...o,...i};if(this.editors.set(t,s),this.control.viewContainerManager.updateTextEditorInfo(i.viewId,this.activeId),this.taskqueue.has(t)){const h=this.taskqueue.get(t);return h&&(h.clocker&&clearTimeout(h.clocker),this.taskqueue.delete(t)),await this.updateTextControllerWithEffectAsync(n)}const a=setTimeout(()=>{var g;const h=(g=this.taskqueue.get(t))==null?void 0:g.resolve;h&&h(s)},50),c=await new Promise(h=>{this.taskqueue.set(t,{resolve:h,clocker:a})}),l=this.taskqueue.get(t);return l&&(l.clocker&&clearTimeout(l.clocker),this.taskqueue.delete(t)),c}updateTextForWorker(n,e){const{workId:t,isActive:i,...o}=n,s=this.editors.get(t)||{},a={...s,...o};if(e&&this.addUndoTicker(e,o.viewId),a.undoTickerId=e||s.undoTickerId||this.undoTickerId,i){a.canWorker=!1,a.canSync=!1,this.editors.set(t,a),this.active(t);return}this.editors.set(t,a),this.control.viewContainerManager.updateTextEditorInfo(o.viewId,this.activeId)}get(n){return this.editors.get(n)}delete(n,e,t){const i=this.editors.get(n);if(i){const o=i.viewId;i.canSync=e,i.canWorker=t,this.editors.delete(n),this.activeId===n&&(this.activeId=void 0),this.control.viewContainerManager.updateTextEditorInfo(o,this.activeId)}}deleteBatch(n,e,t){const i=new Set;for(const o of n){const s=this.editors.get(o);if(s){const a=s.viewId;s.canSync=e,s.canWorker=t,this.editors.delete(o),this.activeId===o&&(this.activeId=void 0),i.add(a)}}for(const o of i)this.control.viewContainerManager.updateTextEditorInfo(o,this.activeId)}clear(n,e){this.editors.forEach((t,i)=>{t.viewId===n&&(e&&(t.canSync=!1),t.canWorker=!1,this.editors.delete(i))}),this.activeId=void 0,this.control.viewContainerManager.updateTextEditorInfo(n,this.activeId)}destory(){this.editors.clear(),this.activeId=void 0}insertText(n,e,t,i){var d,M;const o=(d=this.control.room)==null?void 0:d.state.memberState;if(!o)return;const s=this.control.viewContainerManager.getView(n);if(!(s!=null&&s.focusScenePath))return;const a=s==null?void 0:s.cameraOpt,c=this.control.getToolsOpt(S.Text,o);if(!c)return;const l=(M=this.control.viewContainerManager)==null?void 0:M.transformToOriginPoint([e,t],n),h=Un(i,{whiteList:{},stripIgnoreTag:!0,stripIgnoreTagBody:["script"]}).split(/\n/),g=c.toolsOpt;g.text=vt(h),g.workState=D.Doing,g.boxPoint=[Math.round(e),Math.round(t)],g.boxSize=[g.fontSize,g.fontSize];const y=this.control.worker.now;return this.control.textEditorManager.checkEmptyTextBlur(),this.control.textEditorManager.createTextForMasterController({workId:y.toString(),x:l&&l[0]||0,y:l&&l[1]||0,scale:(a==null?void 0:a.scale)||1,opt:g,type:qe.Text,isActive:!0,viewId:n,scenePath:s.focusScenePath},y),y.toString()}updateText(n,e){const t=this.editors.get(n.toString());if(!t)return;const o=Un(e,{whiteList:{},stripIgnoreTag:!0,stripIgnoreTagBody:["script"]}).split(/\n/);t.opt.text=vt(o),this.control.textEditorManager.updateTextForMasterController({workId:n,opt:t.opt,viewId:t.viewId,canSync:!0,canWorker:!0},this.control.worker.now)}}function Rf(r){return r}var tr=Rf;function Of(r,n,e){switch(e.length){case 0:return r.call(n);case 1:return r.call(n,e[0]);case 2:return r.call(n,e[0],e[1]);case 3:return r.call(n,e[0],e[1],e[2])}return r.apply(n,e)}var Uf=Of,Yf=Uf,to=Math.max;function Bf(r,n,e){return n=to(n===void 0?r.length-1:n,0),function(){for(var t=arguments,i=-1,o=to(t.length-n,0),s=Array(o);++i<o;)s[i]=t[n+i];i=-1;for(var a=Array(n+1);++i<n;)a[i]=t[i];return a[n]=e(s),Yf(r,this,a)}}var $f=Bf;function Wf(r){return function(){return r}}var Vf=Wf,Ff=Vf,no=jo,Gf=tr,Qf=no?function(r,n){return no(r,"toString",{configurable:!0,enumerable:!1,value:Ff(n),writable:!0})}:Gf,Zf=Qf,Hf=800,qf=16,Jf=Date.now;function Kf(r){var n=0,e=0;return function(){var t=Jf(),i=qf-(t-e);if(e=t,i>0){if(++n>=Hf)return arguments[0]}else n=0;return r.apply(void 0,arguments)}}var Xf=Kf,_f=Zf,ep=Xf,tp=ep(_f),np=tp,ip=tr,op=$f,rp=np;function sp(r,n){return rp(op(r,n,ip),r+"")}var ap=sp;function cp(r,n,e,t){for(var i=r.length,o=e+(t?1:-1);t?o--:++o<i;)if(n(r[o],o,r))return o;return-1}var lp=cp;function up(r){return r!==r}var hp=up;function dp(r,n,e){for(var t=e-1,i=r.length;++t<i;)if(r[t]===n)return t;return-1}var gp=dp,fp=lp,pp=hp,Mp=gp;function yp(r,n,e){return n===n?Mp(r,n,e):fp(r,pp,e)}var mp=yp,Ip=mp;function wp(r,n){var e=r==null?0:r.length;return!!e&&Ip(r,n,0)>-1}var nr=wp;function Tp(r,n,e){for(var t=-1,i=r==null?0:r.length;++t<i;)if(e(n,r[t]))return!0;return!1}var ir=Tp;function Sp(r,n){for(var e=-1,t=r==null?0:r.length,i=Array(t);++e<t;)i[e]=n(r[e],e,r);return i}var vp=Sp,Np=pi,Cp=nr,kp=ir,xp=vp,bp=Tn,Dp=Mi,jp=200;function Ep(r,n,e,t){var i=-1,o=Cp,s=!0,a=r.length,c=[],l=n.length;if(!a)return c;e&&(n=xp(n,bp(e))),t?(o=kp,s=!1):n.length>=jp&&(o=Dp,s=!1,n=new Np(n));e:for(;++i<a;){var u=r[i],h=e==null?u:e(u);if(u=t||u!==0?u:0,s&&h===h){for(var g=l;g--;)if(n[g]===h)continue e;c.push(u)}else o(n,h,t)||c.push(u)}return c}var Ap=Ep,io=Xt,zp=Lo,Lp=_t,oo=io?io.isConcatSpreadable:void 0;function Pp(r){return Lp(r)||zp(r)||!!(oo&&r&&r[oo])}var Rp=Pp,Op=gi,Up=Rp;function or(r,n,e,t,i){var o=-1,s=r.length;for(e||(e=Up),i||(i=[]);++o<s;){var a=r[o];n>0&&e(a)?n>1?or(a,n-1,e,t,i):Op(i,a):t||(i[i.length]=a)}return i}var Yp=or;function Bp(){}var $p=Bp,En=Go,Wp=$p,Vp=yi,Fp=1/0,Gp=En&&1/Vp(new En([,-0]))[1]==Fp?function(r){return new En(r)}:Wp,Qp=Gp,Zp=pi,Hp=nr,qp=ir,Jp=Mi,Kp=Qp,Xp=yi,_p=200;function eM(r,n,e){var t=-1,i=Hp,o=r.length,s=!0,a=[],c=a;if(e)s=!1,i=qp;else if(o>=_p){var l=n?null:Kp(r);if(l)return Xp(l);s=!1,i=Jp,c=new Zp}else c=n?[]:a;e:for(;++t<o;){var u=r[t],h=n?n(u):u;if(u=e||u!==0?u:0,s&&h===h){for(var g=c.length;g--;)if(c[g]===h)continue e;n&&c.push(h),a.push(u)}else i(c,h,e)||(c!==a&&c.push(h),a.push(u))}return a}var tM=eM,nM=Ap,iM=Yp,ro=tM;function oM(r,n,e){var t=r.length;if(t<2)return t?ro(r[0]):[];for(var i=-1,o=Array(t);++i<t;)for(var s=r[i],a=-1;++a<t;)a!=i&&(o[i]=nM(o[i]||s,r[a],n,e));return ro(iM(o,1),n,e)}var rM=oM,sM=li,aM=ct;function cM(r){return aM(r)&&sM(r)}var lM=cM,uM=Yo,hM=ap,dM=rM,gM=lM;hM(function(r){return dM(uM(r,gM))});function fM(r,n){if(r&&n){const e=Math.min(r.x,n.x),t=Math.min(r.y,n.y),i=Math.max(r.x+r.w,n.x+n.w),o=Math.max(r.y+r.h,n.y+n.h),s=i-e,a=o-t;return{x:e,y:t,w:s,h:a}}return n||r}function mi(r,n){if(r&&n){const e=Math.min(r.originX,n.originX),t=Math.min(r.originY,n.originY),i=Math.max(r.originX+r.width,n.originX+n.width),o=Math.max(r.originY+r.height,n.originY+n.height),s=i-e,a=o-t;return{originX:e,originY:t,width:s,height:a}}return n||r}function Ii(r,n=0){const e={x:0,y:0,w:0,h:0};let t=1/0,i=1/0,o=-1/0,s=-1/0;return r.forEach(a=>{const[c,l]=a.XY;t=Math.min(t,c-n),i=Math.min(i,l-n),o=Math.max(o,c+n),s=Math.max(s,l+n)}),e.x=t,e.y=i,e.w=o-t,e.h=s-i,e}function pM(r,n){return!(r.x+r.w<n.x||r.x>n.x+n.w||r.y+r.h<n.y||r.y>n.y+n.h)}function MM(r,n=10){return{x:Math.floor(r.x-n),y:Math.floor(r.y-n),w:Math.ceil(r.w+n*2),h:Math.ceil(r.h+n*2)}}function yM(r,n){return{x:r.x+n[0],y:r.y+n[1],w:r.w,h:r.h}}function mM(r,n){const e=new V(r.x,r.y),t=new V(r.x+r.w,r.y),i=new V(r.x+r.w,r.y+r.h),o=new V(r.x,r.y+r.h),s=new V(r.x+r.w/2,r.y+r.h/2),a=Math.PI*n/180,c=V.RotWith(e,s,a),l=V.RotWith(t,s,a),u=V.RotWith(i,s,a),h=V.RotWith(o,s,a);return[c,l,u,h]}function IM(r,n){const e=mM(r,n);return Ii(e)}function wM(r,n,e){const t=new V(r.x,r.y),i=new V(r.x+r.w,r.y),o=new V(r.x+r.w,r.y+r.h),s=new V(r.x,r.y+r.h),a=new V(e[0],e[1]),c=new V(n[0],n[1]),l=V.ScaleWOrigin(t,c,a),u=V.ScaleWOrigin(i,c,a),h=V.ScaleWOrigin(o,c,a),g=V.ScaleWOrigin(s,c,a);return Ii([l,u,h,g])}function TM(r,n,e){const t=new V(n[0],n[1]);for(let i=0;i<r.length;i+=3){const o=new V(r[i],r[i+1]),s=Math.PI*e/180,a=V.RotWith(o,t,s);r[i]=a.x,r[i+1]=a.y}}function SM(r,n,e){const t=new V(n[0],n[1]);for(let i=0;i<r.length;i+=2){const o=new V(r[i],r[i+1]),s=Math.PI*e/180,a=V.RotWith(o,t,s);r[i]=a.x,r[i+1]=a.y}}function vM(r,n,e,t=[0,0]){const i=new V(n[0],n[1]);for(let o=0;o<r.length;o+=3){const s=new V(r[o],r[o+1]),a=new V(e[0],e[1]),c=V.ScaleWOrigin(s,a,i);r[o]=c.x+t[0],r[o+1]=c.y+t[1]}}function NM(r,n,e,t=[0,0]){const i=new V(n[0],n[1]);for(let o=0;o<r.length;o+=2){const s=new V(r[o],r[o+1]),a=new V(e[0],e[1]),c=V.ScaleWOrigin(s,a,i);r[o]=c.x+t[0],r[o+1]=c.y+t[1]}}function rr(r,n){return r[0]>=n.x&&r[0]<=n.x+n.w&&r[1]>=n.y&&r[1]<=n.y+n.h}function CM(r,n){const e=r<=n?1:r/n,t=n<=r?1:n/r;return[e,t]}function kM(r){for(const n of r)if(isNaN(n)||n===1/0||n===-1/0)return!1;return!0}function xM(r){return r!==Math.floor(r)}function bM(r){const n=r.toString();return n.indexOf(".")!==-1?n.split(".")[1].length:0}function DM(r,n){for(;n!==0;)[r,n]=[n,r%n];return r}function jM(r){return`${gn(r.x)},${gn(r.y)} `}function EM(r,n){return`${gn((r.x+n.x)/2)},${gn((r.y+n.y)/2)} `}function gn(r){return+r.toFixed(4)}const He=async(r,n,e=!1)=>{let t,i;return new Promise(function(o){if(e&&requestIdleCallback)requestIdleCallback(()=>{o(1)},{timeout:n});else{if(typeof window.requestIdleCallback=="function"){const s=typeof n=="number"&&!isNaN(n)&&n>0?n:0;i=window.requestIdleCallback(()=>{clearTimeout(t),o(1)},{timeout:s})}t=setTimeout(()=>{i&&window.cancelIdleCallback(i),o(1)},n||0)}}).then(function(){r()}).catch(function(){r()})},zt=r=>Math.max(1,(window.devicePixelRatio||1)/1),AM=(r,n)=>r.x+r.w<n.x||r.x>n.x+n.w||r.y+r.h<n.y||r.y>n.y+n.h?qt.outside:r.x>=n.x&&r.y>=n.y&&r.x+r.w<=n.x+n.w&&r.y+r.h<=n.y+n.h?qt.inside:qt.intersect;function zM(r){let n=0;for(let e=0;e<r.length;e++){const t=r.charCodeAt(e);t>=1&&t<=126||65376<=t&&t<=65439?n++:n+=2}return n}function LM(r){if(!r||typeof r!="string")return!1;const n=r.trim();if(!n)return!1;const e=[/^\s*#{1,6}\s+.+/m,/^\s*[-*+]\s+.+/m,/^\s*\d+\.\s+.+/m,/\[([^\]]+)\]\(([^)]+)\)/,/\[([^\]]+)\]\[([^\]]+)\]/,/```[\s\S]*?```/,/`[^`]+`/,/^\s*\|.+\|/m,/!\[([^\]]*)\]\(([^)]+)\)/,/\*\*[^*]+\*\*/,/__[^_]+__/,/\*[^*]+\*/,/_[^_]+_/,/~~[^~]+~~/,/==[^=]+==/,/^\s*[-*+]\s+\[[ xX]\]\s+.+/m,/^\s*>\s+.+/m,/^\s*[-*]{3,}\s*$/m];let t=0;for(const s of e)s.test(n)&&t++;const o=[/^\s*#{1,6}\s+/m,/^\s*[-*+]\s+/m,/^\s*\d+\.\s+/m,/```[\s\S]*?```/,/^\s*\|.+\|/m].some(s=>s.test(n));return t>=2||o}class PM{constructor(n,e){I(this,"plugin");I(this,"uid");I(this,"control");this.control=n,this.plugin=e,this.uid=e.displayer.uid}getNamespaceData(){var n;return G.toJS((n=this.plugin)==null?void 0:n.attributes[this.namespace])||{}}getAuthSpaceData(){var n;return G.toJS((n=this.plugin)==null?void 0:n.attributes[this.authSpace])||{}}getGlobalUndoRedoStackData(){var n;return G.toJS((n=this.plugin)==null?void 0:n.attributes[this.globalUndoRedoStackSpace])||{}}getUidFromKey(n){return n.split(We).length===2&&n.split(We)[0]||this.uid}isLocalId(n){return n.split(We).length===1}getLocalId(n){return n.split(We)[1]}isSelector(n){return this.getLocalId(n)===Q}}const Re=class Re extends PM{constructor(e,t,i){super(e,t);I(this,"namespace");I(this,"authSpace");I(this,"globalUndoRedoStackSpace");I(this,"serviceStorage",{});I(this,"storage",{});I(this,"authStorage",{});I(this,"globalUndoRedoStackStorage",{});I(this,"stateDisposer");I(this,"authDisposer");I(this,"asyncClockState",!1);I(this,"limitNums",new Map);I(this,"syncInterval");I(this,"limitComponents",j.debounce((e,t)=>{var s,a,c,l,u,h,g,y;const i=((a=(s=this.storage)==null?void 0:s[e])==null?void 0:a[t])&&Object.keys(this.storage[e][t]).length||0;if(i===0)return;let o=this.limitNums.get(`${e}/${t}`);if(!o){const d=this.getLimitNum(i);this.limitNums.set(`${e}/${t}`,d),o=d}if(o>0&&i>=o){const d=Re.componentsLimits.indexOf(o),M=d>=0&&d<Re.componentsLimits.length-1;if((u=(l=(c=this.control.room)==null?void 0:c.callbacks)==null?void 0:l.listeners)!=null&&u.map.onObjectsLimit&&((g=(h=this.control.room)==null?void 0:h.callbacks)==null||g.dispatch("onObjectsLimit",m=>m(o,M))),!M){this.Logger.error(`[Appliance]: exceeds the limit of ${o} components, current: ${i}`),(y=this.control.room)==null||y.disconnect().then(()=>{var m,p,T,v,C;(T=(p=(m=this.control.room)==null?void 0:m.callbacks)==null?void 0:p.listeners)!=null&&T.map.onKickedWithReason&&(this.Logger.info("[Appliance]: onKickedWithReason callback is called"),(C=(v=this.control.room)==null?void 0:v.callbacks)==null||C.dispatch("onKickedWithReason",N=>N("kickByAdmin")))});return}console.warn(`exceeds the limit of ${o} components, current: ${i}`);const w=M?Re.componentsLimits[d+1]:0;this.limitNums.set(`${e}/${t}`,w)}},2e3,{maxWait:5e3}));I(this,"clearLimitComponents",(e,t)=>{if(t)this.limitNums.delete(`${e}/${t}`);else for(const i of this.limitNums.keys())`${e}/`.indexOf(i)===0&&this.limitNums.delete(i)});this.syncInterval=i,this.namespace=Re.namespace,this.authSpace=Re.authSpace,this.globalUndoRedoStackSpace=Re.globalUndoRedoStackSpace,this.serviceStorage=this.getNamespaceData(),this.storage=j.cloneDeep(this.serviceStorage),this.authStorage=this.getAuthSpaceData(),this.globalUndoRedoStackStorage={},this.getLimitNums()}get Logger(){return this.control.logger}hasId(e,t,i){const o=this.getLocalId(i)?this.transformKey(i):i;return!!(this.storage[e]&&this.storage[e][t]&&this.storage[e][t][o])}getLimitNum(e){return e>=Re.componentsLimits[0]?Re.componentsLimits[1]:Re.componentsLimits[0]}getLimitNums(){for(const[e,t]of Object.entries(this.storage))if(e&&t){for(const[i,o]of Object.entries(t))if(i&&o){const s=this.getLimitNum(Object.keys(o).length);this.limitNums.set(`${e}/${i}`,s)}}}getViewIdBySecenPath(e){const t=this.getNamespaceData();for(const[i,o]of Object.entries(t))if(o){for(const s of Object.keys(o))if(s===e)return i}}getScenePathData(e){const t=this.getNamespaceData();for(const i of Object.values(t))if(i){for(const o of Object.keys(i))if(o===e)return j.cloneDeep(i[o])}}hasTargetDataByViewId(e,t){const i=this.getNamespaceData();if(i&&i[e]){for(const o of Object.values(i[e]))for(const s of Object.keys(o))if(s===t)return!0}}getTargetDataByViewId(e,t){const i=this.getNamespaceData();let o,s;if(i&&i[e])for(const[a,c]of Object.entries(i[e]))for(const l of Object.keys(c))l===t&&(o=j.cloneDeep(c[l]),s=a);return{data:o,scenePath:s}}getStorageData(e,t){const i=this.getNamespaceData();return i&&i[e]&&j.cloneDeep(i[e][t])||void 0}hasSelector(e,t){const i=this.storage&&this.storage[e]&&this.storage[e][t];return!!(i&&Object.keys(i).find(o=>this.isOwn(o)&&this.getLocalId(o)===Q))}hasIncludeSelector(e,t,i){for(const o of Object.keys(this.storage))if(!(t&&o!==t)){for(const s of Object.keys(this.storage[o]))if(!(i&&s!==i)){for(const a of Object.keys(this.storage[o][s]))if(this.getLocalId(a)===Q){const c=this.storage[o][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=G.autorun(async()=>{var c,l,u,h,g,y;const t=this.getNamespaceData(),{diffView:i,diffScenePath:o,diffData:s}=this.diffFunByView(this.serviceStorage,t);this.serviceStorage=t;const a={};if(Object.keys(i).length>0)for(const[d,M]of Object.entries(i))M&&!j.isEqual((c=this.storage)==null?void 0:c[d],M.newValue)&&(a.diffView||(a.diffView={}),a.diffView[d]=M,this.storage||(this.storage={}),M.newValue===void 0?delete this.storage[d]:this.storage[d]=j.cloneDeep(M.newValue));if(Object.keys(o).length>0){for(const[d,M]of Object.entries(o))if(M){const{viewId:w,newValue:m}=M;M&&!j.isEqual((u=(l=this.storage)==null?void 0:l[w])==null?void 0:u[d],m)&&(a.diffScenePath||(a.diffScenePath={}),a.diffScenePath[d]=M,this.storage||(this.storage={}),this.storage[w]||(this.storage[w]={}),M.newValue===void 0?delete this.storage[w][d]:this.storage[w][d]=j.cloneDeep(M.newValue))}}if(Object.keys(s).length>0){for(const[d,M]of Object.entries(s))if(M){const{viewId:w,scenePath:m,newValue:p}=M;M&&!j.isEqual((y=(g=(h=this.storage)==null?void 0:h[w])==null?void 0:g[m])==null?void 0:y[d],p)&&(a.diffData||(a.diffData={}),a.diffData[d]=M,this.storage||(this.storage={}),this.storage[w]||(this.storage[w]={}),this.storage[w][m]||(this.storage[w][m]={}),M.newValue===void 0?delete this.storage[w][m][d]:this.storage[w][m][d]=j.cloneDeep(M.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 i=je(e),o=je(t),s={},a={},c={};for(const l of o)if(!i.includes(l)||e[l]===void 0){s[l]={newValue:t[l],oldValue:void 0};continue}for(const l of i){if(j.isEqual(e[l],t[l]))continue;if(!o.includes(l)||t[l]===void 0){s[l]={newValue:void 0,oldValue:e[l]};continue}const u=this.diffFunByScenePath(e[l],t[l],l);Object.assign(a,u.diffScenePath),Object.assign(c,u.diffData)}return{diffData:c,diffScenePath:a,diffView:s}}diffFunByScenePath(e,t,i){const o=je(e),s=je(t),a={},c={};for(const l of s)if(!o.includes(l)||e[l]===void 0){a[l]={newValue:t[l],oldValue:void 0,viewId:i};continue}for(const l of o){if(j.isEqual(e[l],t[l]))continue;if(!s.includes(l)||t[l]===void 0){a[l]={newValue:void 0,oldValue:e[l],viewId:i};continue}const u=this.diffFunByKeys(e[l],t[l],l,i);Object.assign(c,u)}return{diffScenePath:a,diffData:c}}diffFunByKeys(e,t,i,o){const s=je(e),a=je(t),c={};for(const l of a)(!s.includes(l)||e[l]===void 0)&&(c[l]={oldValue:void 0,newValue:t[l],viewId:o,scenePath:i});for(const l of s)if(!j.isEqual(e[l],t[l])){if(!a.includes(l)||t[l]===void 0){c[l]={newValue:void 0,oldValue:e[l],viewId:o,scenePath:i};continue}a.includes(l)&&(c[l]={oldValue:e[l],newValue:t[l],viewId:o,scenePath:i})}return c}transformKey(e){return this.uid+We+e}isOwn(e){return e.split(We)[0]===this.uid}dispatch(e){var p,T;const{type:t,workId:i,ops:o,index:s,opt:a,toolsType:c,removeIds:l,updateNodeOpt:u,op:h,selectIds:g,isSync:y,scenePath:d,viewId:M}=e;if(!M)return;const w=Number(e.needUndoTicker??e.collectUndoTicker??void 0),m=v=>{w?this.control.internalMsgEmitter.emit("ackStorageUndoTicker",w,M,d,v,{requestId:e.requestId,emitEventType:e.emitEventType}):e.emitEventType===U.TranslateNode||(e.emitEventType,U.CopyNode)};switch(t){case $.Clear:const v={};d&&this.storage[M]&&this.storage[M][d]?(delete this.storage[M][d],this.setState(v,{isSync:y,viewId:M,scenePath:d})):this.storage[M]&&(delete this.storage[M],this.setState(v,{isSync:y,viewId:M,scenePath:""})),He(()=>{var A,x;(A=this.control.pluginManager)==null||A.dispatchPluginEvent("syncStorage",M,d),this.control.isUseSimple||(x=this.control.miniMapManager)==null||x.updateMiniMapCamera(M),this.clearLimitComponents(M,d)},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback"));break;case $.CreateWork:if(d&&i&&c&&a){const A=this.isLocalId(i.toString())?this.transformKey(i):i;this.control.renderControl.isUsePageAuth(M)&&this.control.renderControl.addRenderPageElementId({viewId:M,scenePath:d,elementId:A.toString()}),this.updateValue(A.toString(),{type:$.CreateWork,workId:i,toolsType:c,opt:a},{isSync:y,viewId:M,scenePath:d,onApplied:()=>m(A.toString())})}break;case $.DrawWork:if(d&&i&&typeof s=="number"&&(h!=null&&h.length)){const A=this.isLocalId(i.toString())?this.transformKey(i):i,x=this.storage[M]&&this.storage[M][d]&&this.storage[M][d][A]||void 0;if(x!=null&&x.ops||(x==null?void 0:x.type)===$.FullWork)return;const E=s?((x==null?void 0:x.op)||[]).slice(0,s).concat(h):h||(x==null?void 0:x.op),b=c||(x==null?void 0:x.toolsType),O=a||(x==null?void 0:x.opt),Y=u||(x==null?void 0:x.updateNodeOpt);i&&b&&O&&E&&(this.control.renderControl.isUsePageAuth(M)&&this.control.renderControl.addRenderPageElementId({viewId:M,scenePath:d,elementId:A.toString()}),this.updateValue(A.toString(),{...x,type:$.DrawWork,workId:i,updateNodeOpt:Y,toolsType:b,opt:O,op:E,index:s},{isSync:y,viewId:M,scenePath:d,onApplied:()=>m(A.toString())}))}break;case $.FullWork:if(d&&i){const A=this.isLocalId(i.toString())?this.transformKey(i):i,x=this.storage[M]&&this.storage[M][d]&&this.storage[M][d][A]||void 0,E=u||(x==null?void 0:x.updateNodeOpt),b=c||(x==null?void 0:x.toolsType),O=a||(x==null?void 0:x.opt),Y=o||(x==null?void 0:x.ops);b&&O&&(this.control.renderControl.isUsePageAuth(M)&&this.control.renderControl.addRenderPageElementId({viewId:M,scenePath:d,elementId:A.toString()}),this.updateValue(A.toString(),{type:$.FullWork,updateNodeOpt:E,workId:A,toolsType:b,opt:O,ops:Y},{isSync:y,viewId:M,scenePath:d,onApplied:()=>{m(A.toString())}}),He(()=>{var R,W;(R=this.control.pluginManager)==null||R.dispatchPluginEvent("syncStorage",M,d),this.control.isUseSimple||(W=this.control.miniMapManager)==null||W.updateMiniMapCamera(M),this.limitComponents(M,d)},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback")))}break;case $.RemoveNode:if(d&&(l!=null&&l.length)){const A=l.map(b=>this.isLocalId(b+"")?this.transformKey(b):b);let x=0;const E=(p=this.storage[M])==null?void 0:p[d];E&&(Object.keys(E).map(b=>{A!=null&&A.includes(b)&&(x++,this.control.renderControl.isUsePageAuth(M)&&this.control.renderControl.delRenderPageElementId({viewId:M,scenePath:d,elementId:b}),this.updateValue(b,void 0,{isSync:y,viewId:M,scenePath:d,onApplied:()=>m(b)}))}),(T=this.control.pluginManager)==null||T.dispatchPluginEvent("syncStorage",M,d),this.control.isUseSimple||He(()=>{var b;(b=this.control.miniMapManager)==null||b.updateMiniMapCamera(M)},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback"))),w&&x===0&&m()}break;case $.UpdateNode:if(d&&i&&(u||o||a)){const A=this.isLocalId(i.toString())?this.transformKey(i):i,x=this.storage[M]&&this.storage[M][d]&&this.storage[M][d][A]||void 0;x&&(x.updateNodeOpt=u,(o||h)&&(x.ops=o,x.op=h),a&&(x.opt=a),x.type=$.FullWork,this.updateValue(A.toString(),x,{isSync:y,viewId:M,scenePath:d,onApplied:()=>m(A.toString())}),this.control.isUseSimple||He(()=>{var E;(E=this.control.miniMapManager)==null||E.updateMiniMapCamera(M)},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback")))}break;case $.Select:if(!d)return;let C;g!=null&&g.length&&(C=g.map(A=>this.isLocalId(A+"")?this.transformKey(A):A));const N=this.transformKey(Q),k=this.storage[M]&&this.storage[M][d]&&this.storage[M][d][N]||void 0,P=a||(k==null?void 0:k.opt);C&&this.checkOtherSelector(N,C,{isSync:y,viewId:M,scenePath:d}),this.updateValue(N,C&&{type:$.Select,toolsType:S.Selector,opt:P,selectIds:C},{isSync:y,viewId:M,scenePath:d,onApplied:()=>m(N)});break}}checkOtherSelector(e,t,i){const{viewId:o,scenePath:s}=i;for(const a of Object.keys(this.storage[o][s]))if(a!==e&&this.getLocalId(a)===Q){const c=this.storage[o][s][a];if(c&&c.selectIds){const l=c.selectIds.filter(u=>!t.includes(u));l.length>0&&(c.selectIds=l),this.updateValue(a,l.length&&c||void 0,i)}}}setState(e,t){const{viewId:i,scenePath:o}=t,s=je(e);for(let a=0;a<s.length;a++){const c=s[a],l=e[c];typeof l<"u"?(this.storage[i]||(this.storage[i]={}),this.storage[i][o]||(this.storage[i][o]={}),this.storage[i][o][c]=l):delete this.storage[i][o][c]}this.runSyncService(t)}updateValue(e,t,i){var l;const{viewId:o,scenePath:s,storage:a}=i,c=a||this.storage;t===void 0?delete c[o][s][e]:(c[o]||(c[o]={}),c[o][s]||(c[o][s]={}),c[o][s][e]=t),i.onApplied,(l=i.onApplied)==null||l.call(i),this.runSyncService(i)}runSyncService(e){if(!this.control.renderControl.isWritable){this.Logger.error("[Appliance]: 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)):He(()=>{this.asyncClockState=!1,this.syncSerivice(e)},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback")))}syncSerivice(e={storage:this.storage}){const{storage:t}=e,i=t||this.storage,o=je(this.serviceStorage),s=je(i),a=new Map;for(const c of o){if(!s.includes(c)){a.set(c,void 0);continue}j.isEqual(this.serviceStorage[c],i[c])||this.syncViewData(i,c)}for(const c of s)o.includes(c)||a.set(c,i[c]);if(a.size>=s.length||a.size>5&&s.length<20)this.syncStorageView(i);else for(const[c,l]of a.entries())this.syncUpdataView(i,c,l)}syncViewData(e,t){const i=je(this.serviceStorage[t]),o=je(e[t]),s=new Map;for(const a of i){if(!o.includes(a)){s.set(a,void 0);continue}j.isEqual(this.serviceStorage[t][a],e[t][a])||this.syncScenePathData(e,t,a)}for(const a of o)i.includes(a)||s.set(a,e[t][a]);if(s.size>=o.length||s.size>5&&o.length<20)this.syncStorageScenePath(t,e[t]);else for(const[a,c]of s.entries())this.syncUpdataScenePath(e,t,a,c)}syncScenePathData(e,t,i){const o=je(this.serviceStorage[t][i]),s=je(e[t][i]),a=new Map;for(const c of o){if(!s.includes(c)){a.set(c,void 0);continue}j.isEqual(this.serviceStorage[t][i][c],e[t][i][c])||a.set(c,e[t][i][c])}for(const c of s)o.includes(c)||a.set(c,e[t][i][c]);if(a.size>=s.length||a.size>5&&s.length<50)this.syncStorageKey(t,i,e[t][i]);else for(const[c,l]of a.entries())this.syncUpdataKey(e,t,i,c,l)}syncUpdataView(e,t,i){var s;Object.keys(this.serviceStorage).length?(s=this.plugin)==null||s.updateAttributes([this.namespace,t],i):this.syncStorageView(e)}syncStorageView(e){var t;(t=this.plugin)==null||t.updateAttributes([this.namespace],e)}syncUpdataScenePath(e,t,i,o){var a;Object.keys(this.serviceStorage[t]).length?(a=this.plugin)==null||a.updateAttributes([this.namespace,t,i],o):this.syncStorageScenePath(t,e[t])}syncStorageScenePath(e,t){var i;(i=this.plugin)==null||i.updateAttributes([this.namespace,e],t)}syncUpdataKey(e,t,i,o,s){var c;Object.keys(this.serviceStorage[t][i]).length?(c=this.plugin)==null||c.updateAttributes([this.namespace,t,i,o],s):this.syncStorageKey(t,i,e[t][i])}syncStorageKey(e,t,i){var o;(o=this.plugin)==null||o.updateAttributes([this.namespace,e,t],i)}keyTransformWorkId(e){const t=e.split(We);return t.length===2?t[1]:e}destroy(){this.removeStorageStateListener(),this.serviceStorage={},this.storage={},this.removeAuthStateListener(),this.authStorage={},this.globalUndoRedoStackStorage={}}transformToSerializableUndoStackItemData(e){const{data:t,scenePath:i}=e,o={};for(const s of t)o[s.key]={dataType:s.dataType,data:s.data};return{data:o,scenePath:i}}dispatchUndoTicker(e){const{viewId:t,undoTickerId:i,data:o,syncType:s,operation:a}=e,c=a===be.syncUndoStack?"undoStack":"redoStack",l=s==="delete"?void 0:this.transformToSerializableUndoStackItemData(o);if(this.plugin){if(s==="delete"){const u=this.globalUndoRedoStackStorage[t]&&this.globalUndoRedoStackStorage[t][c];if(!u)return;delete u[i],this.plugin.updateAttributes([this.globalUndoRedoStackSpace,t,c,i],void 0);return}if(this.plugin.getAttributesValue([this.globalUndoRedoStackSpace]))if(this.plugin.getAttributesValue([this.globalUndoRedoStackSpace,t]))if(this.plugin.getAttributesValue([this.globalUndoRedoStackSpace,t,c]))this.globalUndoRedoStackStorage[t][c][i]=l,this.plugin.updateAttributes([this.globalUndoRedoStackSpace,t,c,i],l);else{const u={[i]:l};this.globalUndoRedoStackStorage[t][c]=u,this.plugin.updateAttributes([this.globalUndoRedoStackSpace,t,c],u)}else{const u={[c]:{[i]:l}};this.globalUndoRedoStackStorage[t]=u,this.plugin.updateAttributes([this.globalUndoRedoStackSpace,t],u)}else{const u={[t]:{[c]:{[i]:l}}};this.globalUndoRedoStackStorage=u,this.plugin.updateAttributes(this.globalUndoRedoStackSpace,u)}}}addGlobalUndoRedoStackListener(e){this.authDisposer=G.autorun(async()=>{const t=this.getGlobalUndoRedoStackData();if(j.isEqual(this.globalUndoRedoStackStorage,t))return;const i=this.diffGlobalUndoRedoStackFun(this.globalUndoRedoStackStorage,t);this.globalUndoRedoStackStorage=t,e(i)})}diffGlobalUndoRedoStackFun(e,t){const i=je(e),o=je(t),s={};for(const a of o)if(!i.includes(a)||e[a]===void 0){s[a]={newValue:t[a],oldValue:void 0};continue}for(const a of i)if(!j.isEqual(e[a],t[a])){if(!o.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}dispatchPageAuth(e,t=!0){var l,u,h,g,y,d,M,w,m,p,T,v,C,N,k,P,A,x,E,b,O,Y,R,W,B,H,Z,F,X,ye,se,fe,ae,nt,ut,ht,dt,gt;const{operation:i,viewId:o,scenePath:s,pageId:a,pageData:c}=e;switch(i){case be.addPage:{if(!o||!s||!a)return;const xe=[this.authSpace];Object.keys(this.authStorage).length&&xe.push("pageAuth");const Pe=this.authStorage.pageAuth||{};this.authStorage.pageAuth=Pe,Object.keys(Pe).length&&xe.push(o),Pe[o]=Pe[o]||{},Object.keys(Pe[o]).length&&xe.push(s),Pe[o][s]=Pe[o][s]||{render:(c==null?void 0:c.render)||"localSelf",pages:{}},Object.keys(Pe[o][s].pages).length&&xe.push("pages",a);const it={};if(c!=null&&c.elementIds)for(const $t of c.elementIds.keys())it[$t]=!0;Pe[o][s].pages[a]=it,t&&(xe.length===1?(l=this.plugin)==null||l.updateAttributes(xe,j.cloneDeep(this.authStorage)):xe.length===2?(u=this.plugin)==null||u.updateAttributes(xe,j.cloneDeep(Pe)):xe.length===3?(h=this.plugin)==null||h.updateAttributes(xe,j.cloneDeep(Pe[o])):xe.length===4?(g=this.plugin)==null||g.updateAttributes(xe,j.cloneDeep(Pe[o][s])):(y=this.plugin)==null||y.updateAttributes(xe,j.cloneDeep(it)));return}case be.renderPage:{if(!o||!s||!(c!=null&&c.render))return;this.authStorage.pageAuth&&this.authStorage.pageAuth[o]&&this.authStorage.pageAuth[o][s]&&c.render!==this.authStorage.pageAuth[o][s].render&&(this.authStorage.pageAuth[o][s].render=c.render,t&&((d=this.plugin)==null||d.updateAttributes([this.authSpace,"pageAuth",o,s,"render"],c.render)));return}case be.deletePage:{if(!o||!s||!a)return;(T=(p=(m=(w=(M=this.authStorage)==null?void 0:M.pageAuth)==null?void 0:w[o])==null?void 0:m[s])==null?void 0:p.pages)!=null&&T[a]&&(delete this.authStorage.pageAuth[o][s].pages[a],t&&((v=this.plugin)==null||v.updateAttributes([this.authSpace,"pageAuth",o,s,"pages",a],void 0)));return}case be.clearPage:{if(!o||!s||!a)return;(A=(P=(k=(N=(C=this.authStorage)==null?void 0:C.pageAuth)==null?void 0:N[o])==null?void 0:k[s])==null?void 0:P.pages)!=null&&A[a]&&(delete this.authStorage.pageAuth[o][s].pages[a],t&&((x=this.plugin)==null||x.updateAttributes([this.authSpace,"pageAuth",o,s,"pages",a],{})));return}case be.addElement:{if(!o||!s||!a||!(c!=null&&c.elementId))return;(R=(Y=(O=(b=(E=this.authStorage)==null?void 0:E.pageAuth)==null?void 0:b[o])==null?void 0:O[s])==null?void 0:Y.pages)!=null&&R[a]&&(this.authStorage.pageAuth[o][s].pages[a][c.elementId]=!0,t&&((W=this.plugin)==null||W.updateAttributes([this.authSpace,"pageAuth",o,s,"pages",a,c.elementId],!0)));return}case be.deleteElement:{if(!o||!s||!a||!(c!=null&&c.elementId))return;(ye=(X=(F=(Z=(H=(B=this.authStorage)==null?void 0:B.pageAuth)==null?void 0:H[o])==null?void 0:Z[s])==null?void 0:F.pages)==null?void 0:X[a])!=null&&ye[c.elementId]&&(delete this.authStorage.pageAuth[o][s].pages[a][c.elementId],t&&((se=this.plugin)==null||se.updateAttributes([this.authSpace,"pageAuth",o,s,"pages",a,c.elementId],void 0)));return}case be.clearViewScenePath:{if(!o||!s)return;(nt=(ae=(fe=this.authStorage)==null?void 0:fe.pageAuth)==null?void 0:ae[o])!=null&&nt[s]&&(delete this.authStorage.pageAuth[o][s],t&&((ut=this.plugin)==null||ut.updateAttributes([this.authSpace,"pageAuth",o,s],void 0)));return}case be.clearView:{if(!o)return;(dt=(ht=this.authStorage)==null?void 0:ht.pageAuth)!=null&&dt[o]&&(delete this.authStorage.pageAuth[o],t&&((gt=this.plugin)==null||gt.updateAttributes([this.authSpace,"pageAuth",o],void 0)));return}}}dispatchRenderAuth(e,t=!0){var l,u,h,g,y,d,M,w,m,p,T,v,C,N,k,P,A,x,E,b;const{operation:i,viewId:o,uid:s,renderData:a,isClear:c}=e;if(o)switch(i){case Ze.setAuth:{if(!a||a.render===void 0&&a.hide===void 0&&a.clear===void 0){this.authStorage.renderAuth&&this.authStorage.renderAuth[o]&&(delete this.authStorage.renderAuth[o],t&&((l=this.plugin)==null||l.updateAttributes([this.authSpace,"renderAuth",o],void 0)));return}const O=[this.authSpace];Object.keys(this.authStorage).length&&O.push("renderAuth");const Y=this.authStorage.renderAuth||{};Object.keys(Y).length&&O.push(o),Y[o]={},this.authStorage.renderAuth=Y;const{render:R,hide:W,clear:B}=a;if(R===!0)Y[o].render=!0;else if(j.isSet(R)){Y[o].render={};for(const H of R.keys())Y[o].render[H]=!0}if(W===!0)Y[o].hide=!0;else if(j.isSet(W)){Y[o].hide={};for(const H of W.keys())Y[o].hide[H]=!0}if(B===!0)Y[o].clear=!0;else if(j.isSet(B)){Y[o].clear={};for(const H of B.keys())Y[o].clear[H]=!0}t&&(O.length===1?(u=this.plugin)==null||u.updateAttributes(O,j.cloneDeep(this.authStorage)):O.length===2?(h=this.plugin)==null||h.updateAttributes(O,j.cloneDeep(Y)):(g=this.plugin)==null||g.updateAttributes(O,j.cloneDeep(Y[o])));return}case Ze.setShow:{if(!s)return;const O=[this.authSpace];Object.keys(this.authStorage).length&&O.push("renderAuth");const Y=this.authStorage.renderAuth||{};Object.keys(Y).length&&O.push(o),Y[o]=Y[o]||{},this.authStorage.renderAuth=Y,Object.keys(Y[o]).length&&O.push("render"),Y[o].render=Y[o].render||{},Y[o].render!==!0&&(Object.keys(Y[o].render).length&&O.push(s),Y[o].render[s]=!0),Y[o].hide!==!0&&((y=Y[o].hide)!=null&&y[s])&&(delete Y[o].hide[s],t&&((d=this.plugin)==null||d.updateAttributes([this.authSpace,"renderAuth",o,"hide",s],void 0))),t&&(O.length===1?(M=this.plugin)==null||M.updateAttributes(O,j.cloneDeep(this.authStorage)):O.length===2?(w=this.plugin)==null||w.updateAttributes(O,j.cloneDeep(Y)):O.length===3?(m=this.plugin)==null||m.updateAttributes(O,j.cloneDeep(Y[o])):(p=this.plugin)==null||p.updateAttributes(O,!0));return}case Ze.setHide:{if(!s)return;const O=[this.authSpace];Object.keys(this.authStorage).length&&O.push("renderAuth");const Y=this.authStorage.renderAuth||{};Object.keys(Y).length&&O.push(o),Y[o]=Y[o]||{},this.authStorage.renderAuth=Y,Object.keys(Y[o]).length&&O.push("hide"),Y[o].hide=Y[o].hide||{},Y[o].hide!==!0&&(Object.keys(Y[o].hide).length&&O.push(s),Y[o].hide[s]=!0),Y[o].render!==!0&&((T=Y[o].render)!=null&&T[s])&&(delete Y[o].render[s],t&&((v=this.plugin)==null||v.updateAttributes([this.authSpace,"renderAuth",o,"render",s],void 0))),t&&(O.length===1?(C=this.plugin)==null||C.updateAttributes(O,j.cloneDeep(this.authStorage)):O.length===2?(N=this.plugin)==null||N.updateAttributes(O,j.cloneDeep(Y)):O.length===3?(k=this.plugin)==null||k.updateAttributes(O,j.cloneDeep(Y[o])):(P=this.plugin)==null||P.updateAttributes(O,!0));return}case Ze.setClear:{if(!s)return;const O=[this.authSpace];Object.keys(this.authStorage).length&&O.push("renderAuth");const Y=this.authStorage.renderAuth||{};Object.keys(Y).length&&O.push(o),Y[o]=Y[o]||{},this.authStorage.renderAuth=Y,Object.keys(Y[o]).length&&O.push("clear"),Y[o].clear=Y[o].clear||{},Y[o].clear!==!0&&(Object.keys(Y[o].clear).length&&O.push(s),c?Y[o].clear[s]=!0:delete Y[o].clear[s]),t&&(O.length===1?(A=this.plugin)==null||A.updateAttributes(O,j.cloneDeep(this.authStorage)):O.length===2?(x=this.plugin)==null||x.updateAttributes(O,j.cloneDeep(Y)):O.length===3?(E=this.plugin)==null||E.updateAttributes(O,j.cloneDeep(Y[o])):(b=this.plugin)==null||b.updateAttributes(O,c?!0:void 0));return}}}addAuthStateListener(e){this.authDisposer=G.autorun(async()=>{const t=this.getAuthSpaceData(),{renderAuth:i,pageAuth:o}=t;let s,a;j.isEqual(i,this.authStorage.renderAuth)||(s=this.diffAuthFun(this.authStorage.renderAuth||{},i||{}),this.authStorage.renderAuth=i),j.isEqual(o,this.authStorage.pageAuth)||(a=this.diffAuthPageFun(this.authStorage.pageAuth||{},o||{}),this.authStorage.pageAuth=o),(s||a)&&e(s,a)})}removeAuthStateListener(){this.authDisposer&&this.authDisposer()}diffAuthFun(e,t){const i=je(e),o=je(t),s={};for(const a of o)if(!i.includes(a)||e[a]===void 0){s[a]={newValue:t[a],oldValue:void 0};continue}for(const a of i)if(!j.isEqual(e[a],t[a])){if(!o.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 i=je(e),o=je(t),s={};for(const a of o)if(!i.includes(a)||e[a]===void 0){s[a]={newValue:t[a],oldValue:void 0};continue}for(const a of i)if(!j.isEqual(e[a],t[a])){if(!o.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}};I(Re,"namespace","PluginState"),I(Re,"authSpace","PluginAuth"),I(Re,"globalUndoRedoStackSpace","GlobalUndoRedoStack"),I(Re,"componentsLimits",[500,1e3]);let _e=Re;var $e=(r=>(r[r.Draw=1]="Draw",r[r.Delete=2]="Delete",r[r.Update=3]="Update",r))($e||{});class RM{constructor(){I(this,"roomMembers",[]);I(this,"onChangeHooks",new Set)}setRoomMembers(n){this.executChangeUidHook(this.roomMembers,n),this.roomMembers=n}executChangeUidHook(n,e){const t={online:e.map(i=>{var o;return((o=i.payload)==null?void 0:o.uid)||i.session}),offline:n.map(i=>{var o;return((o=i.payload)==null?void 0:o.uid)||i.session})};this.onChangeHooks.forEach(i=>i(t))}getAllRoomMembers(){return this.roomMembers}getRoomMember(n){return this.roomMembers.find(e=>{var t;return((t=e.payload)==null?void 0:t.uid)===n})}isOnLine(n){return!!this.getRoomMember(n)}onUidChangeHook(n){this.onChangeHooks.add(n)}destroy(){this.onChangeHooks.clear()}}class OM{constructor(n){I(this,"expirationTime",Ie.cursor.expirationTime);I(this,"isEnableCursor");I(this,"internalMsgEmitter");I(this,"publicMsgEmitter");I(this,"control");I(this,"eventName","applianc-cursor");I(this,"displayer");I(this,"roomMember");I(this,"animationId");I(this,"maxLastSyncTime");I(this,"willSendEventWorkers",[]);I(this,"willConsumeEventWorkers",new Map);I(this,"sendEventTimerId");I(this,"animationDrawWorkers",new Map);I(this,"animationEventWorkers",new Map);I(this,"cursorInfoMap",new Map);I(this,"doneRenderCursorInfoMap",new Map);const{control:e,internalMsgEmitter:t,publicMsgEmitter:i}=n;this.internalMsgEmitter=t,this.publicMsgEmitter=i,this.expirationTime=j.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(n){var a;const{event:e,payload:t}=n;if(e!==this.eventName)return;const{uid:i,op:o,type:s}=t;if(((a=this.control.collector)==null?void 0:a.uid)!==i&&s===Ht.Cursor&&(o!=null&&o.length)){const c=this.willConsumeEventWorkers.get(i)||[];for(const l of o){const{viewId:u}=l;j.isNumber(l.consumPoint[0])&&j.isNumber(l.consumPoint[1])&&(l.consumPoint=this.control.viewContainerManager.transformToOriginPoint(l.consumPoint,u)),this.control.renderControl.isFilterCursor(u)&&c.unshift({...l,timestamp:this.control.worker.now})}this.willConsumeEventWorkers.set(i,c),this.runAnimation()}}onFocusViewChange(){this.isEnableCursor&&(this.checkDrawWorks(),this.runAnimation())}updateRoomMembers(n){const{offline:e}=n;for(const t of this.cursorInfoMap.keys())t&&e.includes(t)&&this.cursorInfoMap.delete(t)}getKey(n,e){return`${n}${We}${e}`}getUidAndviewId(n){const[e,t]=n.split(We);return{uid:e,viewId:t}}runAnimation(){this.animationId||(this.animationId=requestAnimationFrame(this.animationCursor.bind(this)))}checkDrawWorks(){var e;const n=this.control.viewContainerManager.focuedViewId;for(const[t,i]of this.animationDrawWorkers.entries()){const{viewId:o,uid:s}=this.getUidAndviewId(t);s!==((e=this.control.collector)==null?void 0:e.uid)&&o!==n&&i.workState===D.Done&&(i.consumPoint=[void 0,void 0])}}animationCursor(){this.animationId=void 0;const n=this.control.worker.now;for(const[t,i]of this.animationDrawWorkers.entries()){const{uid:o,viewId:s}=this.getUidAndviewId(t),a=this.roomMember.getRoomMember(o);if(!a){this.animationDrawWorkers.delete(t);continue}const{consumPoint:c,timestamp:l,workState:u}=i,h=this.cursorInfoMap.get(s)||new Map;c&&j.isNumber(c[0])&&j.isNumber(c[1])&&l+this.expirationTime>n?h.set(a.memberId,{x:c[0],y:c[1],roomMember:a,timestamp:l,type:1,workState:u}):h.delete(a.memberId),h.size?this.cursorInfoMap.set(s,h):this.cursorInfoMap.delete(s),this.animationDrawWorkers.delete(t)}const e=new Set;for(const[t,i]of this.cursorInfoMap.entries())if(i)for(const[o,s]of i.entries())s.type===1&&s.workState!==D.Done&&e.add(o);else this.cursorInfoMap.delete(t);for(const[t,i]of this.willConsumeEventWorkers.entries()){const o=this.roomMember.getRoomMember(t);if(j.isNumber(o==null?void 0:o.memberId)&&!e.has(o.memberId)){const s=i.pop();s?this.animationEventWorkers.set(t,s):this.willConsumeEventWorkers.delete(t)}}for(const[t,i]of this.animationEventWorkers.entries()){const o=this.roomMember.getRoomMember(t);if(!o){this.animationEventWorkers.delete(t);continue}const{viewId:s,consumPoint:a,timestamp:c}=i,l=this.cursorInfoMap.get(s)||new Map;a&&j.isNumber(a[0])&&j.isNumber(a[1])&&c+this.expirationTime>n?l.set(o.memberId,{x:a[0],y:a[1],roomMember:o,timestamp:c,type:0}):l.delete(o.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([ne.Cursor,t],[]));for(const[t,i]of this.cursorInfoMap.entries())if(i!=null&&i.size){const o=[];for(const[a,c]of i.entries()){const{timestamp:l,...u}=c;l+this.expirationTime>n?o.push(u):(i.delete(a),i.size===0&&(this.cursorInfoMap.delete(t),this.doneRenderCursorInfoMap.delete(t),this.internalMsgEmitter.emit([ne.Cursor,t],[])))}const s=this.doneRenderCursorInfoMap.get(t);j.isEqual(s,o)||(this.doneRenderCursorInfoMap.set(t,o),this.internalMsgEmitter.emit([ne.Cursor,t],o))}else this.cursorInfoMap.delete(t),this.doneRenderCursorInfoMap.delete(t),this.internalMsgEmitter.emit([ne.Cursor,t],[]);(this.willConsumeEventWorkers.size||this.cursorInfoMap.size)&&this.runAnimation()}sendEvent(n,e){if(this.displayer&&G.isRoom(this.displayer)){const t=j.isNumber(n[0])&&j.isNumber(n[1])&&this.control.viewContainerManager.transformToScenePoint(n,e)||[void 0,void 0];this.willSendEventWorkers.push({consumPoint:t,viewId:e}),this.sendEventTimerId||(this.sendEventTimerId=setTimeout(()=>{this.dispatchMagixEvent()},this.maxLastSyncTime))}}dispatchMagixEvent(){var n;this.displayer&&G.isRoom(this.displayer)&&this.displayer.isWritable&&this.displayer.dispatchMagixEvent(this.eventName,{type:Ht.Cursor,op:j.cloneDeep(this.willSendEventWorkers),uid:(n=this.control.collector)==null?void 0:n.uid}),this.willSendEventWorkers.length=0,this.sendEventTimerId&&(clearTimeout(this.sendEventTimerId),this.sendEventTimerId=void 0)}collectServiceCursor(n){var s;if(!this.isEnableCursor&&!this.control.renderControl.isWritable)return;const{op:e,uid:t,workState:i,viewId:o}=n;if(t&&e&&i&&o){const a=this.roomMember.getRoomMember(t);if(!a||t===((s=this.control.collector)==null?void 0:s.uid))return;const c=this.getKey(t,o);let l=[void 0,void 0];if(j.isNumber(e[0])&&j.isNumber(e[1])){const[h,g]=this.control.viewContainerManager.transformToOriginPoint(e,o);l=[h,g]}if(i===D.Start){for(const h of this.cursorInfoMap.values())if(h!=null&&h.size)for(const g of h.keys())g===a.memberId&&h.delete(g)}const u={consumPoint:l,workState:i,viewId:o,timestamp:this.control.worker.now};if(i===D.Start||i===D.Done){const h=this.willConsumeEventWorkers.get(t);i===D.Start&&h&&this.willConsumeEventWorkers.delete(t),h&&i===D.Done&&(u.timestamp=u.timestamp-this.expirationTime)}this.animationDrawWorkers.set(c,u),this.runAnimation()}}unabled(){var n;this.displayer&&G.isRoom(this.displayer)&&(this.willSendEventWorkers.length=0,this.displayer.dispatchMagixEvent(this.eventName,{type:Ht.Cursor,op:[{viewId:this.control.viewContainerManager.focuedViewId,consumPoint:[void 0,void 0]}],uid:(n=this.control.collector)==null?void 0:n.uid}),this.sendEventTimerId&&(clearTimeout(this.sendEventTimerId),this.sendEventTimerId=void 0)),this.isEnableCursor||this.stopAnimation()}clearViewCursor(n){var e,t,i;for(const[o]of this.animationDrawWorkers.entries()){const{uid:s}=this.getUidAndviewId(o);s===((e=this.control.collector)==null?void 0:e.uid)&&n===n&&this.animationDrawWorkers.delete(o)}for(const[o]of this.willConsumeEventWorkers.entries())o===((t=this.control.collector)==null?void 0:t.uid)&&this.willConsumeEventWorkers.delete(o);for(const[o]of this.animationEventWorkers.entries())o===((i=this.control.collector)==null?void 0:i.uid)&&this.animationEventWorkers.delete(o);for(const[o]of this.cursorInfoMap.entries())o===o&&(this.cursorInfoMap.delete(o),this.doneRenderCursorInfoMap.delete(o),this.internalMsgEmitter.emit([ne.Cursor,o],[]))}stopAnimation(){this.animationDrawWorkers.clear(),this.willConsumeEventWorkers.clear(),this.cursorInfoMap.clear()}destroy(){var n;(n=this.displayer)==null||n.removeMagixEventListener(this.eventName),this.stopAnimation()}}class Qe{constructor(){I(this,"useEmtMsg");I(this,"emtType");I(this,"control");I(this,"mainEngine");I(this,"collectListener",(n,e)=>{this.collect(n,e)})}static dispatch(n,e,t){var i;(i=Me.InternalMsgEmitter)==null||i.emit([n,e],t)}get serviceColloctor(){return this.control.collector}registerForMainEngine(n,e){return this.emtType=n,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(n,e){var t,i,o;for(const[s,a]of n)(t=this.mainEngine)==null||t.queryTaskBatchData(a).forEach(c=>{var l;(l=this.mainEngine)==null||l.taskBatchData.delete(c)}),(i=this.mainEngine)==null||i.taskBatchData.add(s);if(e){this.mainEngine.consume();return}(o=this.mainEngine)==null||o.runAnimation()}collectForServiceWorker(n){He(()=>{n.forEach(e=>{var t;(t=this.serviceColloctor)==null||t.dispatch(e)})},this.mainEngine.maxLastSyncTime,this.control.hasPolyfillMethod("requestIdleCallback"))}pause(){var n;if(this.lastEmtData){this.useEmtMsg=!0;const e={...this.lastEmtData,workState:D.Done};this.collect(e,!0),(n=Me.InternalMsgEmitter)==null||n.emit(U.ActiveMethod,!1)}}recover(){var n;this.useEmtMsg&&Me.InternalMsgEmitter.hasListeners(U.ActiveMethod)&&((n=Me.InternalMsgEmitter)==null||n.emit(U.ActiveMethod,!0))}}function sr(r,n,e){return`${e.isLocalId(r)?r:e.getLocalId(r)}-${n}`}function UM(r,n,e){const t=new Map,i=[];for(const o of r){const s=sr(o,n,e);t.set(o,s),i.push(s)}return{copyNodeKeyBySourceKey:t,expectedWorkIds:i}}class YM extends Qe{constructor(){super(...arguments);I(this,"lastEmtData");I(this,"emitEventType",U.CopyNode)}collect(e){var l;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,viewId:i,requestId:o}=e,s=this.control.viewContainerManager.getView(i);if(!(s!=null&&s.displayer))return;const a=s.focusScenePath,c=this.mainEngine.now;this.mainEngine.internalMsgEmitter.emit("addUndoTicker",c,i,{render:!0,storage:!0,copyAck:!0});for(const u of t){const h=u.toString(),y=this.serviceColloctor.isLocalId(h)?this.serviceColloctor.transformKey(u):h,d=(l=this.serviceColloctor.getStorageData(i,a))==null?void 0:l[y];if(d){if(u===Q){const M=d&&this.copySelector({viewId:i,store:d});M&&this.pasteSelector({...M,viewId:i,scenePath:a,undoTickerId:c,requestId:o});break}if(d.toolsType===S.Text&&d.opt&&d.opt.workState&&d.opt.workState!==D.Done){const M=d&&this.copyText({viewId:i,store:d});M&&this.pasteText({...M,viewId:i,scenePath:a,key:y,store:d,undoTickerId:c,requestId:o});break}}}}copyText(e){const{viewId:t,store:i}=e,o=this.control.viewContainerManager.getView(t);if(!this.serviceColloctor||!o)return;const s=o==null?void 0:o.cameraOpt,a=s&&[s.centerX,s.centerY],c=i.opt,l=c.boxPoint&&c.boxSize&&[c.boxPoint[0]+c.boxSize[0]/2,c.boxPoint[1]+c.boxSize[1]/2];return{bgCenter:a,textCenter:l}}pasteText(e){var w,m;const{bgCenter:t,textCenter:i,store:o,key:s,viewId:a,scenePath:c,undoTickerId:l,requestId:u}=e,h=this.control.viewContainerManager.getView(a);if(!this.serviceColloctor||!h)return;const g=Math.floor(Math.random()*30+1),y=((w=h.cameraOpt)==null?void 0:w.scale)||1,d=t&&i&&[t[0]-i[0]+g,t[1]-i[1]+g]||[g/y,g/y],M=sr(s,l,this.serviceColloctor);if(o.toolsType===S.Text&&o.opt){const p=o.opt;if(p&&p.boxPoint&&p.text){p.workState=D.Done;const T=p.boxPoint;p.boxPoint=[Math.round(T[0]+d[0]),Math.round(T[1]+d[1])],p.workState=D.Done;const v=this.control.viewContainerManager.transformToOriginPoint(p.boxPoint,a);this.control.textEditorManager.createTextForMasterController({workId:M,x:v[0],y:v[1],opt:p,scale:((m=h.cameraOpt)==null?void 0:m.scale)||1,type:qe.Text,isActive:!1,viewId:a,scenePath:c,requestId:u,emitEventType:U.CopyNode}),this.collectForServiceWorker([{...o,opt:p,type:$.FullWork,workId:M,viewId:a,scenePath:c,needUndoTicker:l,requestId:u,emitEventType:U.CopyNode}]),l&&this.mainEngine.internalMsgEmitter.emit("finalizeRequested",l,a,[M],c)}}}copySelector(e){var M,w,m,p,T,v,C,N,k;const{viewId:t,store:i}=e,o=this.control.viewContainerManager.getView(t),s=i.selectIds;if(!this.serviceColloctor||!(s!=null&&s.length)||!o)return;const a=new Map,c={offset:{x:0,y:0},cameraOpt:{centerX:((M=o.cameraOpt)==null?void 0:M.centerX)||0,centerY:((w=o.cameraOpt)==null?void 0:w.centerY)||0,scale:((m=o.cameraOpt)==null?void 0:m.scale)||1}},l=this.control.hasOffscreenCanvas&&((p=o.displayer.canvasBgRef.current)==null?void 0:p.getBoundingClientRect())||((T=o.displayer.canvasContainerRef.current)==null?void 0:T.getBoundingClientRect()),u=(C=(v=o.displayer)==null?void 0:v.floatBarRef.current)==null?void 0:C.getBoundingClientRect(),h=l&&[l.x+l.width/2,l.y+l.height/2],g=u&&[u.x+u.width/2,u.y+u.height/2],y=h&&o.viewData&&o.viewData.convertToPointInWorld({x:h[0],y:h[1]}),d=g&&o.viewData&&o.viewData.convertToPointInWorld({x:g[0],y:g[1]});y&&d&&(c.offset={x:y.x-d.x,y:y.y-d.y});for(const P of s){const A=this.serviceColloctor.isLocalId(P)?this.serviceColloctor.transformKey(P):P,x=(k=(N=this.serviceColloctor)==null?void 0:N.getStorageData(o.id,o.focusScenePath))==null?void 0:k[A];x&&a.set(P,x)}return{copyStores:a,copyCoordInfo:c}}pasteSelector(e){var T,v,C,N;const{copyStores:t,copyCoordInfo:i,viewId:o,scenePath:s,undoTickerId:a,requestId:c}=e,l=this.control.viewContainerManager.getView(o);if(!t.size||!this.serviceColloctor||!l)return;const{offset:u,cameraOpt:h}=i,{scale:g}=h,y=Math.floor(Math.random()*30+1),d=u&&[u.x+y,u.y+y]||[y/g,y/g],M=[],w=[],{copyNodeKeyBySourceKey:m,expectedWorkIds:p}=UM(t.keys(),a,this.serviceColloctor);a&&p.length&&this.mainEngine.internalMsgEmitter.emit("finalizeRequested",a,o,p,s);for(const[k,P]of t.entries()){const A=m.get(k);if(!A)continue;const x={useAnimation:!1};if(P.toolsType===S.Text&&P.opt){const E=P.opt;if(E&&E.boxPoint&&E.text){E.workState=D.Done;const b=E.boxPoint;E.boxPoint=[Math.round(b[0]+d[0]),Math.round(b[1]+d[1])],E.workState=D.Done;const O=this.control.viewContainerManager.transformToOriginPoint(E.boxPoint,o);this.control.textEditorManager.createTextForMasterController({workId:A,x:O[0],y:O[1],opt:E,scale:((T=l.cameraOpt)==null?void 0:T.scale)||1,type:qe.Text,isActive:!1,viewId:o,scenePath:s,requestId:c,emitEventType:U.CopyNode})}w.push({...P,opt:E,type:$.FullWork,workId:A,viewId:o,scenePath:s,requestId:c,needUndoTicker:a,emitEventType:U.CopyNode});continue}if((P.toolsType===S.Image||P.toolsType===S.BackgroundSVG)&&(P.opt.uuid=A,P.opt.centerX=P.opt.centerX+d[0],P.opt.centerY=P.opt.centerY+d[1]),P.ops){const E=vn(P.ops).map((O,Y)=>{const R=Y%3;return R===0?O+d[0]:R===1?O+d[1]:O}),b=vt(E);P.ops=b}if((v=P==null?void 0:P.opt)!=null&&v.eraserlines&&(C=P==null?void 0:P.opt)!=null&&C.eraserlines.length)for(const E of(N=P==null?void 0:P.opt)==null?void 0:N.eraserlines){const{op:b}=E;for(let O=0;O<b.length;O++){const Y=b[O].map((R,W)=>W%2?R+d[1]:R+d[0]);E.op[O]=Y}}w.push({...P,updateNodeOpt:x,type:$.FullWork,workId:A,viewId:o,scenePath:s,requestId:c,needUndoTicker:a,emitEventType:U.CopyNode}),M.push([{...P,updateNodeOpt:x,workId:A,msgType:$.FullWork,dataType:_.Local,emitEventType:U.CopyNode,willSyncService:!1,willRefresh:!0,viewId:o,requestId:c,needUndoTicker:this.control.viewContainerManager.getUndoTickerId(o),isRunBackgroundThread:this.control.isUseBackgroundThread},{workId:A,msgType:$.FullWork,emitEventType:U.CopyNode}])}M.length&&this.collectForLocalWorker(M),w.length&&this.collectForServiceWorker(w)}}class BM extends Qe{constructor(){super(...arguments);I(this,"lastEmtData");I(this,"emitEventType",U.SetColorNode);I(this,"undoTickerId")}ensureUndoTicker(e,t,i,o){if(!(i===D.Start||i===D.Done&&!this.undoTickerId))return this.undoTickerId;const a=this.mainEngine.now;return this.undoTickerId=a,this.mainEngine.internalMsgEmitter.emit("addUndoTicker",a,e,{render:!0,storage:!0}),a}setTextColor(e,t,i,o,s,a){const{fontColor:c,fontBgColor:l}=i;t.opt&&(c&&(t.opt.fontColor=c),l&&(t.opt.fontBgColor=l),this.control.textEditorManager.updateTextForMasterController({workId:e,opt:t.opt,viewId:o,canSync:!0,canWorker:!0,requestId:s,needUndoTicker:a}))}collect(e){var C,N;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,strokeColor:i,fillColor:o,fontColor:s,fontBgColor:a,viewId:c,workState:l,thickness:u,strokeType:h,requestId:g}=e,y=this.control.viewContainerManager.getView(c);if(!(y!=null&&y.displayer))return;const d=y.focusScenePath,M=[...t],w=this.serviceColloctor.storage,m=[],p={},T=this.ensureUndoTicker(c,d,l,t);this.undoTickerId&&(this.control.textEditorManager.UndoTickerId=this.undoTickerId);const v=new Set;for(;M.length;){const k=M.pop();if(!k)continue;const P=k.toString(),A=this.serviceColloctor.isLocalId(P),x=A?this.serviceColloctor.transformKey(k):P;let E=P;!A&&this.serviceColloctor.isOwn(E)&&(E=this.serviceColloctor.getLocalId(E));const b=(N=(C=w==null?void 0:w[c])==null?void 0:C[d])==null?void 0:N[x];if(b){const O=b.updateNodeOpt||{};if(s||a){if(s){O.fontColor=s;const[R,W,B,H]=Zt(s);p.textColor=[R,W,B],p.textOpacity=H}if(a)if(O.fontBgColor=an(a)?"transparent":a,an(a))p.textBgColor=void 0,p.textBgOpacity=void 0;else{const[R,W,B,H]=Zt(a);p.textBgColor=[R,W,B],p.textBgOpacity=H}if(b.toolsType===S.Text&&b.opt&&l!==D.Start){E&&l===D.Done&&v.add(E.toString()),this.setTextColor(E,en(b),O,c,g,l===D.Done&&T||void 0);continue}}if(i){O.strokeColor=i;const[R,W,B,H]=Zt(i);p.strokeColor=[R,W,B],p.strokeOpacity=H}if(o)if(O.fillColor=an(o)?"transparent":o,an(o))p.fillColor=void 0,p.fillOpacity=void 0;else{const[R,W,B,H]=Zt(o);p.fillColor=[R,W,B],p.fillOpacity=H}u&&(O.thickness=u,p.strokeWidth=u),h&&(p.strokeType=h,O.strokeType=h,O.lineCap=this.control.getLineCap(h),O.lineDash=this.control.getLineDash(h));const Y={workId:E,msgType:$.UpdateNode,dataType:_.Local,updateNodeOpt:O,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,textUpdateForWoker:!0,viewId:c,requestId:g,needUndoTicker:l===D.Done&&T||void 0};E&&l===D.Done&&v.add(E.toString()),m.push([Y,{workId:E,msgType:$.UpdateNode,emitEventType:this.emitEventType}])}}if(l===D.Done&&T){const k=[...v];k.length&&this.mainEngine.internalMsgEmitter.emit("finalizeRequested",T,c,k,d)}m.length?(l===D.Done&&(this.undoTickerId=void 0,this.control.textEditorManager.UndoTickerId=void 0),this.collectForLocalWorker(m)):l===D.Done&&(this.undoTickerId=void 0,this.control.textEditorManager.UndoTickerId=void 0),Object.keys(p).length&&setTimeout(()=>{var k;(k=this.control.room)==null||k.setMemberState(p)},0)}}class $M extends Qe{constructor(){super(...arguments);I(this,"lastEmtData");I(this,"emitEventType",U.ZIndexNode);I(this,"zIndexMap",new Map);I(this,"zIndexMapForBackgroundSVG",new Map)}clearZIndex(e){this.zIndexMap.delete(e),this.zIndexMapForBackgroundSVG.delete(e)}getMinZIndex(e){var t;return((t=this.zIndexMap.get(e))==null?void 0:t.min)||0}getMinZIndexForBackgroundSVG(e){var t;return((t=this.zIndexMapForBackgroundSVG.get(e))==null?void 0:t.min)||0}getMaxZIndex(e){var t;return((t=this.zIndexMap.get(e))==null?void 0:t.max)||0}getMaxZIndexForBackgroundSVG(e){var t;return((t=this.zIndexMapForBackgroundSVG.get(e))==null?void 0:t.max)||0}setMaxZIndex(e,t){const i=this.getMinZIndex(t);this.zIndexMap.set(t,{min:i,max:e})}setMaxZIndexForBackgroundSVG(e,t){const i=this.getMinZIndexForBackgroundSVG(t);this.zIndexMapForBackgroundSVG.set(t,{min:i,max:e})}setMinZIndex(e,t){const i=this.getMaxZIndex(t);this.zIndexMap.set(t,{min:e,max:i})}setMinZIndexForBackgroundSVG(e,t){const i=this.getMaxZIndexForBackgroundSVG(t);this.zIndexMapForBackgroundSVG.set(t,{min:e,max:i})}addMaxLayer(e){const t=this.getMaxZIndex(e)+1;this.setMaxZIndex(t,e)}addMaxLayerForBackgroundSVG(e){const t=this.getMaxZIndexForBackgroundSVG(e)+1;this.setMaxZIndexForBackgroundSVG(t,e)}addMinLayer(e){const t=this.getMinZIndex(e)-1;this.setMinZIndex(t,e)}addMinLayerForBackgroundSVG(e){const t=this.getMinZIndexForBackgroundSVG(e)-1;this.setMinZIndexForBackgroundSVG(t,e)}correct(e){const t=e.sort((i,o)=>i[1]-o[1]);for(let i=1;i<t.length;i++){const o=t[i][1],s=t[i-1][1];o<=s&&(t[i][1]=s+1)}return t}collect(e){var w,m;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,layer:i,viewId:o,requestId:s}=e,a=this.control.viewContainerManager.getView(o);if(!(a!=null&&a.displayer))return;const c=a.focusScenePath,l=[...t],u=this.serviceColloctor.storage,h=[],g=[],y=[],d=this.mainEngine.now;for(this.mainEngine.internalMsgEmitter.emit("addUndoTicker",d,o,{render:!0,storage:!0});l.length;){const p=l.pop();if(!p)continue;const T=p.toString(),v=this.serviceColloctor.isLocalId(T),C=v?this.serviceColloctor.transformKey(p):T;let N=T;!v&&this.serviceColloctor.isOwn(N)&&(N=this.serviceColloctor.getLocalId(N));const k=en(u[o][c][C]);let P,A;if(k&&N===Q){if(k.selectIds){for(const b of k.selectIds){const O=M(b,this.serviceColloctor),Y=(m=(w=u==null?void 0:u[o])==null?void 0:w[c])==null?void 0:m[O];Y&&Y.toolsType===S.BackgroundSVG?(y.push(b),y.sort((R,W)=>{var Z,F,X,ye;const B=((F=(Z=u[M(R,this.serviceColloctor)])==null?void 0:Z.opt)==null?void 0:F.zIndex)||0,H=((ye=(X=u[M(R,this.serviceColloctor)])==null?void 0:X.opt)==null?void 0:ye.zIndex)||0;return B>H?1:R<W?-1:0})):(g.push(b),g.sort((R,W)=>{var Z,F,X,ye;const B=((F=(Z=u[M(R,this.serviceColloctor)])==null?void 0:Z.opt)==null?void 0:F.zIndex)||0,H=((ye=(X=u[M(R,this.serviceColloctor)])==null?void 0:X.opt)==null?void 0:ye.zIndex)||0;return B>H?1:R<W?-1:0}))}const x=k.updateNodeOpt||{};x.zIndexLayer=i;const E={workId:p,msgType:$.UpdateNode,dataType:_.Local,updateNodeOpt:x,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:o,requestId:s,needUndoTicker:this.control.viewContainerManager.getUndoTickerId(o)};g.length&&(i===st.Top?(this.addMaxLayer(o),P=this.getMaxZIndex(o)):(this.addMinLayer(o),P=this.getMinZIndex(o)),g.forEach(b=>{var W,B,H,Z,F;const O=(W=this.serviceColloctor)==null?void 0:W.isLocalId(b);let Y=O&&((B=this.serviceColloctor)==null?void 0:B.transformKey(b))||b;const R=(Z=(H=u==null?void 0:u[o])==null?void 0:H[c])==null?void 0:Z[Y];R&&(!O&&((F=this.serviceColloctor)!=null&&F.isOwn(Y))&&(Y=this.serviceColloctor.getLocalId(Y)),x.zIndex=P,R!=null&&R.opt&&(R.opt.zIndex=P))})),y.length&&(i===st.Top?(this.addMaxLayerForBackgroundSVG(o),A=this.getMaxZIndexForBackgroundSVG(o)):(this.addMinLayerForBackgroundSVG(o),A=this.getMinZIndexForBackgroundSVG(o)),y.forEach(b=>{var W,B,H,Z,F;const O=(W=this.serviceColloctor)==null?void 0:W.isLocalId(b);let Y=O&&((B=this.serviceColloctor)==null?void 0:B.transformKey(b))||b;const R=(Z=(H=u==null?void 0:u[o])==null?void 0:H[c])==null?void 0:Z[Y];R&&(!O&&((F=this.serviceColloctor)!=null&&F.isOwn(Y))&&(Y=this.serviceColloctor.getLocalId(Y)),x.zIndexForBackgroundSVG=A,R!=null&&R.opt&&(R.opt.zIndex=A))})),E.willSerializeData=!0,h.push([E,{workId:p,msgType:$.UpdateNode,emitEventType:this.emitEventType}])}continue}}h.length&&(this.mainEngine.internalMsgEmitter.emit("finalizeRequested",d,o,h.map(([p])=>{var T;return(T=p.workId)==null?void 0:T.toString()}).filter(Boolean),c),this.collectForLocalWorker(h));function M(p,T){return T.isLocalId(p)&&T.transformKey(p)||p}}}class WM extends Qe{constructor(){super(...arguments);I(this,"lastEmtData");I(this,"emitEventType",U.TranslateNode);I(this,"cachePosition")}collect(e,t){var M,w,m;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:i,position:o,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,u=[...i],h=(M=this.serviceColloctor)==null?void 0:M.storage,g=[],y=new Set,d=s===D.Start&&this.mainEngine.now||void 0;for(d&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",d,a,{render:!0,storage:!0,isWritable:!0});u.length;){const p=u.pop();if(!p)continue;const T=p.toString(),v=this.serviceColloctor.isLocalId(T),C=v&&this.serviceColloctor.transformKey(p)||T;let N=T;!v&&this.serviceColloctor.isOwn(N)&&(N=this.serviceColloctor.getLocalId(N));const k=(m=(w=h==null?void 0:h[a])==null?void 0:w[l])==null?void 0:m[C];if(k&&N===Q){if(k.selectIds){s===D.Done&&k.selectIds.forEach(A=>{y.add(A.toString())});const P=this.control.viewContainerManager.transformToScenePoint([o.x,o.y],a);if(s===D.Start&&(this.cachePosition=P),this.cachePosition){const A=k.updateNodeOpt||{};A.translate=[P[0]-this.cachePosition[0],P[1]-this.cachePosition[1]],A.workState=s,this.control.cursor.isEnableCursor?A.useAnimation=!1:(A.uid=this.serviceColloctor.uid,s===D.Start?A.useAnimation=!1:s===D.Done&&(A.useAnimation=!0));const x={workId:p,msgType:$.UpdateNode,dataType:_.Local,updateNodeOpt:A,emitEventType:this.emitEventType,willSyncService:!0,textUpdateForWoker:!0,viewId:a,smoothSync:this.mainEngine.smoothSync};s===D.Done&&(x.textUpdateForWoker=!0,x.willSerializeData=!0,this.cachePosition=void 0,x.needUndoTicker=this.control.viewContainerManager.getUndoTickerId(a)),g.push([x,{workId:p,msgType:$.UpdateNode,emitEventType:this.emitEventType,workState:s}])}}continue}}if(s===D.Start?this.mainEngine.unWritable():s===D.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),g.length){if(s===D.Done){const p=this.control.viewContainerManager.getUndoTickerId(a);if(p){const T=[...y];this.mainEngine.internalMsgEmitter.emit("finalizeRequested",p,a,T,l)}}this.collectForLocalWorker(g,t)}}}class VM extends Qe{constructor(){super(...arguments);I(this,"lastEmtData");I(this,"emitEventType",U.DeleteNode)}collect(e){var y,d;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,viewId:i,requestId:o}=e,s=this.control.viewContainerManager.getView(i);if(!(s!=null&&s.displayer))return;const a=s.focusScenePath,c=this.serviceColloctor.storage,l=[...t],u=[],h=[],g=this.mainEngine.now;for(this.control.textEditorManager.UndoTickerId=g;l.length;){const M=l.pop();if(!M)continue;const w=M.toString(),m=this.serviceColloctor.isLocalId(w),p=m?this.serviceColloctor.transformKey(M):w,T=(d=(y=c==null?void 0:c[i])==null?void 0:y[a])==null?void 0:d[p];if(T){let v=w;if(!m&&this.serviceColloctor.isOwn(v)&&(v=this.serviceColloctor.getLocalId(v)),T.toolsType===S.Text){this.control.textEditorManager.delete(v,!0,!0);continue}h.push(v)}}h.length&&(this.mainEngine.internalMsgEmitter.emit("addUndoTicker",g,i,{render:!0,storage:!0}),this.mainEngine.internalMsgEmitter.emit("finalizeRequested",g,i,h.slice(),a),u.push([{msgType:$.RemoveNode,emitEventType:U.DeleteNode,removeIds:h,dataType:_.Local,willSyncService:!0,willRefresh:!0,viewId:i,requestId:o,isRunBackgroundThread:this.control.isUseBackgroundThread,needUndoTicker:this.control.viewContainerManager.getUndoTickerId(i)},void 0]),this.collectForLocalWorker(u))}}class FM extends Qe{constructor(){super(...arguments);I(this,"lastEmtData");I(this,"emitEventType",U.ScaleNode);I(this,"targetText",new Map);I(this,"cacheTextInfo",new Map)}async setTextStyle(e,t,i){const o=await this.control.textEditorManager.updateTextControllerWithEffectAsync({workId:e,opt:t,viewId:i,canSync:!1,canWorker:!1});return{key:e,textInfo:o}}async collect(e,t){var p,T,v,C,N,k,P;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:i,workState:o,viewId:s,originPoint:a,scenePoint:c,dir:l,scale:u,translate:h}=e;this.lastEmtData=e;const g=this.control.viewContainerManager.getView(s);if(!(g!=null&&g.displayer))return;const y=g.focusScenePath,d=[...i],M=(p=this.serviceColloctor)==null?void 0:p.storage,w=[],m=o===D.Start&&this.mainEngine.now||void 0;for(m&&(this.mainEngine.internalMsgEmitter.emit("addUndoTicker",m,s,{render:!0,storage:!0,isWritable:!0}),this.control.textEditorManager.UndoTickerId=m);d.length;){const A=d.pop();if(!A)continue;const x=A.toString(),E=this.serviceColloctor.isLocalId(x),b=E&&this.serviceColloctor.transformKey(A)||x;let O=x;!E&&this.serviceColloctor.isOwn(O)&&(O=this.serviceColloctor.getLocalId(O));const Y=(v=(T=M==null?void 0:M[s])==null?void 0:T[y])==null?void 0:v[b];if(Y&&O===Q&&Y.selectIds){const R=Y.updateNodeOpt||{};if(R.dir=l,R.originPoint=a,R.scenePoint=c,R.workState=o,R.scale=u,R.translate=h,o===D.Start){this.cacheTextInfo.clear();for(const B of Y.selectIds){const H=(C=this.serviceColloctor)==null?void 0:C.isLocalId(B),Z=H&&((N=this.serviceColloctor)==null?void 0:N.transformKey(B))||B;let F=Z;!H&&((k=this.serviceColloctor)!=null&&k.isOwn(Z))&&(F=this.serviceColloctor.getLocalId(Z));const X=this.control.textEditorManager.get(F);X&&o===D.Start&&this.targetText.set(F,en(X))}}if(this.targetText.size&&o!==D.Start&&u){const B=[];for(const[Z,F]of this.targetText.entries()){const{opt:X}=F,ye=Math.floor(X.fontSize*u[0]),se=this.cacheTextInfo.get(Z),fe=!se&&X.fontSize!==ye||se&&se.fontSize!==ye||!1,ae=(P=this.control.textEditorManager.get(Z))==null?void 0:P.opt;if(fe&&ae&&X.boxSize&&X.boxPoint){const nt=this.setTextStyle(Z,{...ae,fontSize:ye},s);B.push(nt)}}const H=await Promise.all(B);for(const Z of H)if(Z){const{key:F,textInfo:X}=Z;this.cacheTextInfo.set(F,{fontSize:X.opt.fontSize,boxSize:X.opt.boxSize,boxPoint:X.opt.boxPoint})}R.textInfos=this.cacheTextInfo}this.control.cursor.isEnableCursor?R.useAnimation=!1:(R.uid=this.serviceColloctor.uid,o===D.Start?R.useAnimation=!1:o===D.Done&&(R.useAnimation=!0));const W={workId:A,msgType:$.UpdateNode,dataType:_.Local,updateNodeOpt:R,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:s,smoothSync:this.mainEngine.smoothSync};o===D.Done&&(W.willSerializeData=!0,this.targetText.clear(),W.needUndoTicker=this.control.viewContainerManager.getUndoTickerId(s)),w.push([W,{workId:A,msgType:$.UpdateNode,emitEventType:this.emitEventType,workState:o}]);continue}}if(o===D.Start?this.mainEngine.unWritable():o===D.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),w.length){if(o===D.Done){const A=this.control.viewContainerManager.getUndoTickerId(s);A&&this.mainEngine.internalMsgEmitter.emit("finalizeRequested",A,s,w.map(([x])=>{var E;return(E=x.workId)==null?void 0:E.toString()}).filter(Boolean),y)}this.collectForLocalWorker(w,t)}}}class GM extends Qe{constructor(){super(...arguments);I(this,"lastEmtData");I(this,"emitEventType",U.RotateNode);I(this,"cacheOriginRotate",0)}collect(e,t){var M,w,m,p,T,v,C;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:i,angle:o,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,u=[...i],h=(M=this.serviceColloctor)==null?void 0:M.storage,g=[],y=new Set,d=s===D.Start&&this.mainEngine.now||void 0;for(d&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",d,a,{render:!0,storage:!0,isWritable:!0});u.length;){const N=u.pop();if(!N)continue;const k=N.toString(),P=this.serviceColloctor.isLocalId(k),A=P&&this.serviceColloctor.transformKey(N)||k;let x=k;!P&&this.serviceColloctor.isOwn(x)&&(x=this.serviceColloctor.getLocalId(x));const E=(m=(w=h==null?void 0:h[a])==null?void 0:w[l])==null?void 0:m[A];if(E&&x===Q){if(((p=E.selectIds)==null?void 0:p.length)===1){const b=E.selectIds[0];if(s===D.Done&&y.add(b.toString()),s===D.Start){const W=((T=this.serviceColloctor)==null?void 0:T.isLocalId(b))&&((v=this.serviceColloctor)==null?void 0:v.transformKey(b))||b,B=h[a][l][W];this.cacheOriginRotate=((C=B==null?void 0:B.opt)==null?void 0:C.rotate)||0}const O=E.updateNodeOpt||{};O.angle=(o+this.cacheOriginRotate)%360,O.workState=s,this.control.cursor.isEnableCursor?O.useAnimation=!1:(O.uid=this.serviceColloctor.uid,s===D.Start?O.useAnimation=!1:s===D.Done&&(O.useAnimation=!0));const Y={workId:N,msgType:$.UpdateNode,dataType:_.Local,updateNodeOpt:O,emitEventType:this.emitEventType,willRefreshSelector:!1,willSyncService:!0,viewId:a,smoothSync:this.mainEngine.smoothSync};s===D.Done&&(Y.willRefreshSelector=!0,Y.willSerializeData=!0,this.cacheOriginRotate=0,Y.needUndoTicker=this.control.viewContainerManager.getUndoTickerId(a)),g.push([Y,{workId:N,msgType:$.UpdateNode,emitEventType:this.emitEventType,workState:s}])}continue}}if(s===D.Start?this.mainEngine.unWritable():s===D.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),g.length){if(s===D.Done){const N=this.control.viewContainerManager.getUndoTickerId(a);if(N){const k=[...y];this.mainEngine.internalMsgEmitter.emit("finalizeRequested",N,a,k,l)}}this.collectForLocalWorker(g,t)}}}function QM(r){switch(r){case S.Text:return qe.Text;case S.SpeechBalloon:case S.Star:case S.Ellipse:case S.Rectangle:case S.Triangle:case S.Rhombus:case S.Polygon:return qe.Shape}}function ZM(r){const n=r.lastChild;if(!n){const i=document.createElement("div"),o=document.createTextNode("");return i.appendChild(o),r.appendChild(i),o}if(n.nodeType===Node.TEXT_NODE)return n;const e=n;if(!e.lastChild){const i=document.createTextNode("");return e.appendChild(i),i}if(e.lastChild.nodeType===Node.TEXT_NODE)return e.lastChild;const t=document.createTextNode("");return e.appendChild(t),t}function HM(r,n){var i;const e=document.createRange(),t=ZM(n);t.nodeType===Node.TEXT_NODE?e.setStart(t,((i=t.textContent)==null?void 0:i.length)||0):e.setStart(t,0),e.collapse(!0),r.removeAllRanges(),r.addRange(e)}function so(r,n){return!!(r!=null&&r.anchorNode)&&n.contains(r.anchorNode)}function ao(r){let n=null,e=!1;for(const i of Array.from(r.childNodes)){if(i instanceof HTMLDivElement){n=i;continue}i.nodeType===Node.TEXT_NODE&&(n||(n=document.createElement("div"),r.insertBefore(n,i),e=!0),n.appendChild(i),e=!0)}const t=Array.from(r.childNodes).reverse().find(i=>i instanceof HTMLDivElement);return{changed:e,lastLine:t||null}}function qM(r){const n=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,null),e=[];let t;for(;(t=n.nextNode())!==null;)e.push(t);return{textContent:e.map(i=>i.textContent||"").join(""),textNodes:e}}function ar(r){const n=[];for(let e=0;e<r.childNodes.length;e++){const t=r.childNodes[e];if(t.nodeName==="#text"&&e===0){const i=t.textContent.split(/\n/),o=i.pop();n.push(...i),o&&n.push(o)}else if(t.nodeName==="DIV"){const o=(t.innerText??t.textContent??"").split(/\n/);if(o.length===2&&o[0]===""&&o[1]==="")n.push("");else{const s=o.shift();(s||s==="")&&n.push(s);const a=o.pop();n.push(...o),a&&n.push(a)}}}return n}function cr(r){return vt(ar(r))}function Gt(r,n){var i,o;if(!r.length)return;let e=Math.max(0,n);for(const s of r){const a=((i=s.textContent)==null?void 0:i.length)||0;if(e<=a)return{node:s,offset:e};e-=a}const t=r[r.length-1];return{node:t,offset:((o=t.textContent)==null?void 0:o.length)||0}}function JM(r){const{hasPoint:n,previousByPoint:e,hasSelectionInEditor:t,rangeCount:i,isCollapsed:o}=r;return!n&&e&&t&&i>0&&o}class KM extends Qe{constructor(){super(...arguments);I(this,"lastEmtData");I(this,"emitEventType",U.SetFontStyle);I(this,"timerId")}async setTextStyle(e,t,i,o,s,a){const{bold:c,underline:l,lineThrough:u,italic:h,fontSize:g}=i;if(t.toolsType&&QM(t.toolsType)===qe.Text){t.opt&&(c&&(t.opt.bold=c),j.isBoolean(l)&&(t.opt.underline=l),j.isBoolean(u)&&(t.opt.lineThrough=u),h&&(t.opt.italic=h),g&&(t.opt.fontSize=g));const d=await this.control.textEditorManager.updateTextControllerWithEffectAsync({workId:e,opt:t.opt,viewId:o,canSync:!1,canWorker:!1,requestId:s,needUndoTicker:a});return{key:e,textInfo:d}}}async collect(e){var v,C,N,k,P,A;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,bold:i,italic:o,lineThrough:s,underline:a,viewId:c,fontSize:l,requestId:u}=e,h=this.control.viewContainerManager.getView(c);if(!(h!=null&&h.displayer))return;const g=h.focusScenePath,y=[...t],d=this.serviceColloctor.storage,M={},w=this.mainEngine.now;this.mainEngine.internalMsgEmitter.emit("addUndoTicker",w,c,{render:!0,storage:!0}),this.control.textEditorManager.UndoTickerId=w;const m=[],p=[];for(;y.length;){const x=y.pop();if(!x)continue;const E=x.toString(),b=this.serviceColloctor.isLocalId(E),O=b?this.serviceColloctor.transformKey(x):E;let Y=E;!b&&this.serviceColloctor.isOwn(Y)&&(Y=this.serviceColloctor.getLocalId(Y));const R=(C=(v=d==null?void 0:d[c])==null?void 0:v[g])==null?void 0:C[O];if(R){const W=R.updateNodeOpt||{};if(i&&(W.bold=i,M.bold=i==="bold"),o&&(W.italic=o,M.italic=o==="italic"),j.isBoolean(s)&&(W.lineThrough=s,M.lineThrough=s),j.isBoolean(a)&&(W.underline=a,M.underline=a),l&&(W.fontSize=l,M.textSize=l),R.toolsType===S.Text&&R.opt){const B=this.setTextStyle(Y,j.cloneDeep(R),W,c,u,w);m.push(Y),p.push(B);continue}if(R&&Y===Q&&((N=R.selectIds)!=null&&N.length))for(const B of R.selectIds){const H=(k=this.serviceColloctor)==null?void 0:k.isLocalId(B);let Z=H&&((P=this.serviceColloctor)==null?void 0:P.transformKey(B))||B;const F=d[c][g][Z]||void 0;if(!H&&((A=this.serviceColloctor)!=null&&A.isOwn(Z))&&(Z=this.serviceColloctor.getLocalId(Z)),F&&F.toolsType===S.Text&&R.opt){const X=this.setTextStyle(Z,j.cloneDeep(F),W,c,u,w);m.push(Z),p.push(X);continue}}}}const T=await Promise.all(p);for(const x of T)if(x){const{key:E,textInfo:b}=x;b&&(b.canSync=!0,b.canWorker=!0,this.control.textEditorManager.updateForViewEdited(E,b))}Object.keys(M).length&&(this.timerId&&(clearTimeout(this.timerId),this.timerId=void 0),this.timerId=setTimeout(()=>{var x;this.timerId=void 0,(x=this.control.room)==null||x.setMemberState(M)},0)),m.length&&this.mainEngine.internalMsgEmitter.emit("finalizeRequested",w,c,m,g)}}class XM extends Qe{constructor(){super(...arguments);I(this,"lastEmtData");I(this,"emitEventType",U.SetPoint);I(this,"undoTickerId")}collect(e){var p,T,v;if(!this.serviceColloctor||!this.mainEngine)return;const{workId:t,pointMap:i,workState:o,viewId:s}=e,a=this.control.viewContainerManager.getView(s);if(!(a!=null&&a.displayer))return;const c=a.focusScenePath,l=(p=this.serviceColloctor)==null?void 0:p.storage,u=[],h=o===D.Start&&this.mainEngine.now||void 0;h&&(this.undoTickerId=h,this.mainEngine.internalMsgEmitter.emit("addUndoTicker",h,s,{render:!0,storage:!0,isWritable:!0}));const g=t;if(!g)return;const y=g.toString(),d=this.serviceColloctor.isLocalId(y),M=d&&this.serviceColloctor.transformKey(g)||y;let w=y;!d&&this.serviceColloctor.isOwn(w)&&(w=this.serviceColloctor.getLocalId(w));const m=(v=(T=l==null?void 0:l[s])==null?void 0:T[c])==null?void 0:v[M];if(m&&w===Q&&m.selectIds){const C=m.updateNodeOpt||{};C.pointMap=i,C.workState=o;const N={workId:g,msgType:$.UpdateNode,dataType:_.Local,updateNodeOpt:C,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:s,needUndoTicker:o===D.Done&&this.control.viewContainerManager.getUndoTickerId(s)||void 0};u.push([N,{workId:g,msgType:$.UpdateNode,emitEventType:this.emitEventType}])}o===D.Start?this.mainEngine.unWritable():o===D.Done&&this.mainEngine.abled(),u.length&&(o===D.Done&&this.undoTickerId&&this.mainEngine.internalMsgEmitter.emit("finalizeRequested",this.undoTickerId,s,u.map(([C])=>{var N;return(N=C.workId)==null?void 0:N.toString()}).filter(Boolean),c),this.collectForLocalWorker(u))}}class _M extends Qe{constructor(){super(...arguments);I(this,"lastEmtData");I(this,"emitEventType",U.SetLock)}collect(e){var y,d;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,isLocked:i,viewId:o,requestId:s}=e,a=this.control.viewContainerManager.getView(o);if(!(a!=null&&a.displayer))return;const c=a.focusScenePath,l=[...t],u=this.serviceColloctor.storage,h=[],g=this.mainEngine.now;for(this.mainEngine.internalMsgEmitter.emit("addUndoTicker",g,o,{render:!0,storage:!0});l.length;){const M=l.pop();if(!M)continue;const w=M.toString(),m=this.serviceColloctor.isLocalId(w),p=m?this.serviceColloctor.transformKey(M):w;let T=w;!m&&this.serviceColloctor.isOwn(T)&&(T=this.serviceColloctor.getLocalId(T));const v=(d=(y=u==null?void 0:u[o])==null?void 0:y[c])==null?void 0:d[p];if(v){const C=v.updateNodeOpt||{};C.isLocked=i;const N={workId:T,msgType:$.UpdateNode,dataType:_.Local,updateNodeOpt:C,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,viewId:o,requestId:s,needUndoTicker:this.control.viewContainerManager.getUndoTickerId(o)};h.push([N,{workId:T,msgType:$.UpdateNode,emitEventType:this.emitEventType}])}}h.length&&(this.mainEngine.internalMsgEmitter.emit("finalizeRequested",g,o,h.map(([M])=>{var w;return(w=M.workId)==null?void 0:w.toString()}).filter(Boolean),c),this.collectForLocalWorker(h))}}class ey extends Qe{constructor(){super(...arguments);I(this,"lastEmtData");I(this,"emitEventType",U.SetShapeOpt)}collect(e){var y,d;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,viewId:i,requestId:o,...s}=e;console.log(`[Appliance]: [selector] setShapeOpt collect requestId=${o||"-"} viewId=${i} workIds=[${t.join(",")}] payload=${JSON.stringify(s)}`);const a=this.control.viewContainerManager.getView(i);if(!(a!=null&&a.displayer)){console.log(`[Appliance]: [selector] setShapeOpt ignored requestId=${o||"-"} viewId=${i} reason=no-view-displayer`);return}const c=a.focusScenePath,l=[...t],u=this.serviceColloctor.storage,h=[],g=this.mainEngine.now;for(this.mainEngine.internalMsgEmitter.emit("addUndoTicker",g,i,{render:!0,storage:!0});l.length;){const M=l.pop();if(!M)continue;const w=M.toString(),m=this.serviceColloctor.isLocalId(w),p=m?this.serviceColloctor.transformKey(M):w;let T=w;!m&&this.serviceColloctor.isOwn(T)&&(T=this.serviceColloctor.getLocalId(T));const v=(d=(y=u==null?void 0:u[i])==null?void 0:y[c])==null?void 0:d[p];if(console.log(`[Appliance]: [selector] setShapeOpt inspect requestId=${o||"-"} viewId=${i} scenePath=${c||"-"} inputId=${w} storageKey=${p} localWorkId=${T||"-"} found=${!!v}`),v){const C={...v.updateNodeOpt,...s,willRefresh:!0};if(v&&T===Q){console.log(`[Appliance]: [selector] setShapeOpt enqueue requestId=${o||"-"} viewId=${i} workId=${T} updateNodeOpt=${JSON.stringify(C)}`);const N={workId:T,msgType:$.UpdateNode,dataType:_.Local,updateNodeOpt:C,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,viewId:i,requestId:o,needUndoTicker:this.control.viewContainerManager.getUndoTickerId(i)};h.push([N,{workId:T,msgType:$.UpdateNode,emitEventType:this.emitEventType}])}}}h.length?(this.mainEngine.internalMsgEmitter.emit("finalizeRequested",g,i,h.map(([M])=>{var w;return(w=M.workId)==null?void 0:w.toString()}).filter(Boolean),c),this.collectForLocalWorker(h)):console.log(`[Appliance]: [selector] setShapeOpt no-local-msg requestId=${o||"-"} viewId=${i} scenePath=${c||"-"} workIds=[${t.join(",")}]`)}}class te{constructor(n){I(this,"builders",new Map);this.builders=new Map(n.map(e=>[e,this.build(e)]))}build(n){switch(n){case U.TranslateNode:return new WM;case U.ZIndexNode:return new $M;case U.CopyNode:return new YM;case U.SetColorNode:return new BM;case U.DeleteNode:return new VM;case U.ScaleNode:return new FM;case U.RotateNode:return new GM;case U.SetFontStyle:return new KM;case U.SetPoint:return new XM;case U.SetLock:return new _M;case U.SetShapeOpt:return new ey}}getBuilder(n){return this.builders.get(n)}registerForMainEngine(n,e){return this.builders.forEach(t=>{t&&t.registerForMainEngine(n,e)}),this}destroy(){this.builders.forEach(n=>{n&&n.destroy()}),this.builders.clear()}pause(){return this.builders.forEach(n=>{n&&n.pause()}),this}recover(){return this.builders.forEach(n=>{n&&n.recover()}),this}static emitMethod(n,e,t){Qe.dispatch(n,e,t)}static activeListener(n){Me.InternalMsgEmitter.on(U.ActiveMethod,n)}static unmountActiveListener(n){Me.InternalMsgEmitter.off(U.ActiveMethod,n)}}const ty=async(r,n)=>{const{src:e,isgl:t}=r;if(typeof Image=="function"){const i=new Image;return typeof e=="string"&&(i.crossOrigin="anonymous"),new Promise(o=>{i.onload=function(){createImageBitmap(i,{imageOrientation:t?"flipY":"none"}).then(s=>{o(s)})},i.onerror=function(){o(void 0)},i.src=e})}else return fetch(e,{method:"GET",mode:"cors",cache:"default"}).then(i=>i.blob()).then(i=>createImageBitmap(i,{imageOrientation:t?"flipY":"none"}).then(o=>o))},St=class St{constructor(){I(this,"fontDB");I(this,"FONT_DB_NAME","__APPLIANCE_PLUGIN_FONT_DB");I(this,"FONT_STORE_NAME","fonts");I(this,"FONT_DB_VERSION",1)}static getInstance(){return St.instance||(St.instance=new St),St.instance}async initFontDB(){return this.fontDB?this.fontDB:new Promise((n,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,n(t.result)},t.onupgradeneeded=i=>{const o=i.target.result;o.objectStoreNames.contains(this.FONT_STORE_NAME)||o.createObjectStore(this.FONT_STORE_NAME,{keyPath:"fontFamily"}).createIndex("url","url",{unique:!1})}})}async getFontFromDB(n){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(n);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 ${n}:`,e),null}}async saveFontToDB(n,e,t){try{return this.fontDB||(this.fontDB=await this.initFontDB()),new Promise((i,o)=>{const a=this.fontDB.transaction([this.FONT_STORE_NAME],"readwrite").objectStore(this.FONT_STORE_NAME),c={fontFamily:n,url:e,buffer:t,timestamp:Date.now()},l=a.put(c);l.onsuccess=()=>{i(!0)},l.onerror=()=>{o(l.error)}})}catch(i){return console.error(`Failed to save font to database for ${n}:`,i),!1}}async clearFontCache(){try{return this.fontDB||(this.fontDB=await this.initFontDB()),new Promise((n,e)=>{const o=this.fontDB.transaction([this.FONT_STORE_NAME],"readwrite").objectStore(this.FONT_STORE_NAME).clear();o.onsuccess=()=>{console.log("Font cache cleared successfully"),n(!0)},o.onerror=()=>{e(o.error)}})}catch(n){return console.error("Failed to clear font cache:",n),!1}}async getFontCacheStatus(){try{return this.fontDB||(this.fontDB=await this.initFontDB()),new Promise((n,e)=>{const o=this.fontDB.transaction([this.FONT_STORE_NAME],"readonly").objectStore(this.FONT_STORE_NAME).getAll();o.onsuccess=()=>{const s=o.result||[],a=s.reduce((c,l)=>c+(l.buffer?l.buffer.byteLength:0),0);n({count:s.length,totalSize:a})},o.onerror=()=>{e(o.error)}})}catch(n){return console.error("Failed to get font cache status:",n),{count:0,totalSize:0}}}};I(St,"instance");let Qn=St;function ny(r){return r===ce.Stroke?ce.Normal:r}function kt(r){const{pencilOptions:n}=r,e=ny(n.strokeType);return{strokeColor:n.strokeColor,thickness:n.thickness,isOpacity:n.isOpacity,zIndex:n.zIndex,scale:n.scale,rotate:n.rotate,translate:n.translate,eraserlines:n.eraserlines,strokeType:e,lineCap:e===ce.Normal?void 0:n.lineCap,lineDash:e===ce.Normal?void 0:n.lineDash}}function lr(r){return[r.start[0],r.start[1],0,r.end[0],r.end[1],0]}function Cn(r){const{minX:n,minY:e,maxX:t,maxY:i}=r.bbox;return[n,e,0,t,i,0]}function iy(r){const{minX:n,minY:e,maxX:t,maxY:i}=r.bbox;return[n,e,0,t,e,0,t,i,0,n,i,0]}const oy=(r,n)=>({toolsType:S.Straight,opt:kt(n),op:lr(r)}),ry=(r,n)=>({toolsType:S.Arrow,opt:kt(n),op:lr(r)}),sy=(r,n)=>({toolsType:S.Rectangle,opt:{...kt(n),fillColor:"transparent"},op:iy(r)}),ay=(r,n)=>({toolsType:S.Ellipse,opt:{...kt(n),fillColor:"transparent"},op:Cn(r)}),cy=(r,n)=>({toolsType:S.Polygon,opt:{...kt(n),fillColor:"transparent",vertices:3,shapeType:Ye.Triangle},op:Cn(r)}),ly=(r,n)=>({toolsType:S.Polygon,opt:{...kt(n),fillColor:"transparent",vertices:4,shapeType:Ye.Rhombus},op:Cn(r)}),uy=(r,n)=>({toolsType:S.Star,opt:{...kt(n),fillColor:"transparent",vertices:10,innerVerticeStep:2,innerRatio:.4,shapeType:Ye.Pentagram},op:Cn(r)}),Mt={straight:oy,arrow:ry,rectangle:sy,ellipse:ay,triangle:cy,rhombus:ly,star:uy};function hy(r){return vt(r.op)}function at(r){if(!r.length)return r;const[n,e]=r[0],[t,i]=r[r.length-1];return n===t&&e===i?r:[...r,r[0]]}function dy(r,n){const e=at(r).slice(0,-1),t=(n%e.length+e.length)%e.length;return at(e.slice(t).concat(e.slice(0,t)))}function wi(r){return[...r].reverse()}function xt(r,n,e,t,i){const o=[];for(let s=0;s<i;s++){const a=dy(e,s),c=wi(a);o.push({id:`${n}-cw-${s}`,semanticKind:r,points:a,threshold:t},{id:`${n}-ccw-${s}`,semanticKind:r,points:c,threshold:t})}return o}function gy(r,n,e,t){const i=[];return e.forEach((o,s)=>{i.push({id:`${n}-forward-${s}`,semanticKind:r,points:o,threshold:t},{id:`${n}-reverse-${s}`,semanticKind:r,points:wi(o),threshold:t})}),i}const co=[[0,.5],[.25,.5],[.5,.5],[.75,.5],[1,.5]],fy=[[.05,.5],[.3,.5],[.55,.5],[.78,.5],[1,.5],[.8,.32],[1,.5],[.8,.68]],py=[[.05,.5],[.3,.5],[.55,.5],[.78,.5],[1,.5],[.8,.68],[1,.5],[.8,.32]],My=at([[.15,.2],[.85,.2],[.85,.8],[.15,.8]]),yy=at([[.5,.12],[.88,.82],[.12,.82]]),my=at([[.5,.08],[.92,.5],[.5,.92],[.08,.5]]),Iy=at([[.5,.04],[.62,.34],[.95,.36],[.68,.56],[.78,.9],[.5,.7],[.22,.9],[.32,.56],[.05,.36],[.38,.34]]),wy=at([[.5,.04],[.74,.88],[.08,.34],[.92,.34],[.26,.88]]),Ty=Array.from({length:24},(r,n)=>{const e=Math.PI*2*n/24;return[.5+Math.cos(e)*.42,.5+Math.sin(e)*.3]}),yt=[{id:"straight-base",semanticKind:"straight",points:co,threshold:.72},{id:"straight-reverse",semanticKind:"straight",points:wi(co),threshold:.72},...gy("arrow","arrow",[fy,py],.71),...xt("rectangle","rectangle",My,.68,4),...xt("ellipse","ellipse",at(Ty),.64,12),...xt("triangle","triangle",yy,.68,3),...xt("rhombus","rhombus",my,.66,4),...xt("star","star",Iy,.7,5),...xt("star","pentagram",wy,.68,5)];function Qt(r,n,e,t){const{metrics:i}=n;return i.closureRatio>.24||i.cornerCount<e||i.cornerCount>t?null:r}const Sy=[{kind:"straight",templates:yt.filter(r=>r.semanticKind==="straight"),postProcessor(r,n){const{metrics:e}=n;return e.bboxDiagonal<8||e.closureRatio<.75||e.straightness<.94&&r.score<.8?null:r},mapper:Mt.straight,enabledInV1:!0},{kind:"arrow",templates:yt.filter(r=>r.semanticKind==="arrow"),postProcessor(r,n){const{metrics:e}=n;return e.closureRatio<.12||e.cornerCount<4||e.cornerCount>7||e.straightness>.93?null:r.score>=Math.max(r.threshold,.71)?r:null},mapper:Mt.arrow,enabledInV1:!0},{kind:"rectangle",templates:yt.filter(r=>r.semanticKind==="rectangle"),postProcessor(r,n){const e=Qt(r,n,4,6);return!e||n.metrics.bboxCornerCloseness>.15||n.metrics.bboxCornerCloseness>=n.metrics.diamondCloseness?null:e},mapper:Mt.rectangle,enabledInV1:!0},{kind:"ellipse",templates:yt.filter(r=>r.semanticKind==="ellipse"),postProcessor(r,n){const e=Qt(r,n,6,12);return!e||n.metrics.radialVariance>.5?null:e},mapper:Mt.ellipse,enabledInV1:!0},{kind:"triangle",templates:yt.filter(r=>r.semanticKind==="triangle"),postProcessor(r,n){return Qt(r,n,3,4)},mapper:Mt.triangle,enabledInV1:!0},{kind:"rhombus",templates:yt.filter(r=>r.semanticKind==="rhombus"),postProcessor(r,n){const e=Qt(r,n,4,5);return!e||n.metrics.diamondCloseness>=n.metrics.bboxCornerCloseness?null:e},mapper:Mt.rhombus,enabledInV1:!0},{kind:"star",templates:yt.filter(r=>r.semanticKind==="star"),postProcessor(r,n){const e=r.templateId.startsWith("pentagram"),t=Qt(r,n,e?5:8,12);if(!t)return null;if(e){if(n.metrics.bboxCornerCloseness<.22||n.metrics.angleVariance<35)return null}else if(n.metrics.radialVariance<.34)return null;return t},mapper:Mt.star,enabledInV1:!0}];function Ti(){return Sy}const vy=64,Zn=250;function tt(r,n){const e=r[0]-n[0],t=r[1]-n[1];return Math.hypot(e,t)}function Ny(r){const n=[];for(const e of r){const t=n[n.length-1];(!t||tt(t,e)>.5)&&n.push(e)}return n}function ur(r){let n=0;for(let e=1;e<r.length;e++)n+=tt(r[e-1],r[e]);return n}function hr(r){let n=Number.POSITIVE_INFINITY,e=Number.POSITIVE_INFINITY,t=Number.NEGATIVE_INFINITY,i=Number.NEGATIVE_INFINITY;for(const[o,s]of r)n=Math.min(n,o),e=Math.min(e,s),t=Math.max(t,o),i=Math.max(i,s);return{minX:n,minY:e,maxX:t,maxY:i}}function Cy(r,n=vy){if(r.length<=1)return r;const e=ur(r)/Math.max(n-1,1),t=[r[0]];let i=0,o=r[0],s=1;const a=[...r];for(;s<a.length;){const c=a[s],l=tt(o,c);if(l===0){s++;continue}if(i+l>=e){const u=(e-i)/l,h=[o[0]+u*(c[0]-o[0]),o[1]+u*(c[1]-o[1])];t.push(h),a.splice(s,0,h),i=0,o=h,s++}else i+=l,o=c,s++}for(;t.length<n;)t.push(a[a.length-1]);return t}function kn(r){const n=r.reduce((e,t)=>[e[0]+t[0],e[1]+t[1]],[0,0]);return[n[0]/r.length,n[1]/r.length]}function ky(r,n){const e=kn(r),t=Math.cos(n),i=Math.sin(n);return r.map(([o,s])=>{const a=o-e[0],c=s-e[1];return[a*t-c*i+e[0],a*i+c*t+e[1]]})}function xy(r){const n=kn(r);return Math.atan2(n[1]-r[0][1],n[0]-r[0][0])}function by(r,n=Zn){const e=hr(r),t=Math.max(e.maxX-e.minX,1),i=Math.max(e.maxY-e.minY,1);return r.map(([o,s])=>[(o-e.minX)/t*n,(s-e.minY)/i*n])}function Dy(r){const n=kn(r);return r.map(([e,t])=>[e-n[0],t-n[1]])}function dr(r){const n=Cy(r),e=ky(n,-xy(n)),t=by(e);return Dy(t)}function jy(r,n){let e=0;const t=Math.min(r.length,n.length);for(let i=0;i<t;i++)e+=tt(r[i],n[i]);return e/Math.max(t,1)}function Ey(r,n,e){const[t,i]=r,[o,s]=n,[a,c]=e,l=Math.abs((c-s)*t-(a-o)*i+a*s-c*o),u=Math.hypot(c-s,a-o)||1;return l/u}function Hn(r,n){if(r.length<=2)return r;let e=0,t=0;for(let s=1;s<r.length-1;s++){const a=Ey(r[s],r[0],r[r.length-1]);a>e&&(e=a,t=s)}if(e<=n)return[r[0],r[r.length-1]];const i=Hn(r.slice(0,t+1),n),o=Hn(r.slice(t),n);return i.slice(0,-1).concat(o)}function Ay(r){if(r.length<3)return[];const n=[];for(let e=0;e<r.length;e++){const t=r[(e-1+r.length)%r.length],i=r[e],o=r[(e+1)%r.length],s=[t[0]-i[0],t[1]-i[1]],a=[o[0]-i[0],o[1]-i[1]],c=s[0]*a[0]+s[1]*a[1],l=Math.hypot(s[0],s[1])*Math.hypot(a[0],a[1])||1,u=Math.acos(Math.max(-1,Math.min(1,c/l)));n.push(u*180/Math.PI)}return n}function zy(r){const n=hr(r),e=Math.max(n.maxX-n.minX,1),t=Math.max(n.maxY-n.minY,1),i=Math.hypot(e,t)||1,o=ur(r),s=tt(r[0],r[r.length-1]),a=tt(r[0],r[r.length-1]),c=a/i,l=i*.045,h=c<.24&&r.length>2?r.slice(0,tt(r[0],r[r.length-1])<.5?-1:r.length):r,g=Hn(h,l),y=Ay(g),d=y.length>0?Math.max(...y.map(k=>Math.abs(k-90))):90,M=g.map(([k,P])=>[(k-n.minX)/e,(P-n.minY)/t]),w=[[0,0],[1,0],[1,1],[0,1]],m=[[.5,0],[1,.5],[.5,1],[0,.5]],p=(k,P)=>k.reduce((A,x)=>{const E=Math.min(...P.map(b=>tt(x,b)));return A+E},0)/Math.max(k.length,1),T=kn(r),v=r.map(k=>tt(k,T)),C=v.reduce((k,P)=>k+P,0)/Math.max(v.length,1),N=C>0?v.reduce((k,P)=>k+Math.abs(P-C)/C,0)/Math.max(v.length,1):0;return{bbox:n,metrics:{pathLength:o,chordLength:s,straightness:s/Math.max(o,1),closureDistance:a,closureRatio:c,bboxWidth:e,bboxHeight:t,bboxDiagonal:i,aspectRatio:e/t,cornerCount:Math.max(0,g.length),angleVariance:d,radialVariance:N,bboxCornerCloseness:p(M,w),diamondCloseness:p(M,m)}}}function Ly(r){return r.map(n=>({template:n,normalized:dr(n.points)}))}const Py=Ly(Ti().flatMap(r=>r.templates));function Ry(r){const n=Ny(r.rawPoints);if(n.length<2)return null;const{bbox:e,metrics:t}=zy(n);return{rawPoints:r.rawPoints,points:n,pencilOptions:r.pencilOptions,viewId:r.viewId,scenePath:r.scenePath,start:n[0],end:n[n.length-1],bbox:e,metrics:t}}function Oy(r){const n=dr(r.points),e=new Map;for(const{template:t,normalized:i}of Py){const o=jy(n,i),s=Math.max(0,1-o/(.5*Math.sqrt(2*Zn*Zn))),a={kind:t.semanticKind,templateId:t.id,threshold:t.threshold||.7,distance:o,score:s},c=e.get(t.semanticKind);(!c||a.score>c.score)&&e.set(t.semanticKind,a)}return[...e.values()].sort((t,i)=>i.score-t.score)}function Uy(r){const n=Ti(),e=Oy(r);if(r.metrics.bboxDiagonal>=8&&r.metrics.straightness>.975&&r.metrics.closureRatio>.75){const i=e.find(o=>o.kind==="straight")||{templateId:"straight-heuristic",score:.99,threshold:.72};return{kind:"straight",score:i.score,threshold:i.threshold,recognized:!0,bbox:r.bbox,start:r.start,end:r.end,points:r.points,templateId:i.templateId,metrics:r.metrics,candidates:e}}for(const i of e){const o=n.find(a=>a.kind===i.kind);if(!o||i.score<i.threshold)continue;const s=o.postProcessor?o.postProcessor(i,r):i;if(s)return{kind:o.kind,score:s.score,threshold:s.threshold,recognized:!0,bbox:r.bbox,start:r.start,end:r.end,points:r.points,templateId:s.templateId,metrics:r.metrics,candidates:e}}const t=e[0];return{kind:"none",score:(t==null?void 0:t.score)||0,threshold:(t==null?void 0:t.threshold)||1,recognized:!1,bbox:r.bbox,start:r.start,end:r.end,points:r.points,templateId:t==null?void 0:t.templateId,metrics:r.metrics,candidates:e}}function Yy(r){return Ry(r)}function By(r){return Uy(r)}function lo(r,n){if(!r.recognized||r.kind==="none")return null;const e=Ti().find(t=>t.kind===r.kind);return(e==null?void 0:e.mapper(r,n))||null}const $y=new Set([S.Eraser,S.PencilEraser,S.BitMapEraser]),Wy=new Set([S.Pencil,S.Arrow,S.Straight,S.Ellipse,S.Rectangle,S.Star,S.Polygon,S.SpeechBalloon]),An=r=>typeof r=="number"&&$y.has(r),Vy=r=>r===$.FullWork||r===$.UpdateNode||r===$.RemoveNode||r===$.DrawWork;class Fy{get now(){var n;return((n=this.control.room)==null?void 0:n.calibrationTimestamp)||Date.now()}get newWorkId(){return this.now.toString()}setCurrentToolsData(n){this.currentToolsData=n}getCurrentToolsData(){return this.currentToolsData}setCurrentLocalWorkData(n){this.currentLocalWorkData=n}getWorkId(){return this.currentLocalWorkData.workId}get workState(){return this.currentLocalWorkData.workState}}class Gy extends Fy{constructor(e){super();I(this,"maxLastSyncTime",Ie.syncOpt.interval);I(this,"combineUnitTime",Ie.bezier.combineUnitTime);I(this,"maxCombineEraserTime",Ie.pencilEraser.maxCombineTime);I(this,"smoothSync",Ie.syncOpt.smoothSync);I(this,"isActive",!1);I(this,"currentToolsData");I(this,"currentLocalWorkData");I(this,"control");I(this,"internalMsgEmitter");I(this,"publicMsgEmitter");I(this,"taskBatchData",new Set);I(this,"fullWorker");I(this,"subWorker");I(this,"fullWorkerUrl");I(this,"subWorkerUrl");I(this,"methodBuilder");I(this,"zIndexNodeMethod");I(this,"subWorkerDrawCount",0);I(this,"fullWorkerDrawCount",0);I(this,"maxDrawCount",0);I(this,"_consumeCount",0);I(this,"_postCount",0);I(this,"reRenders",new Map);I(this,"localWorkViewId");I(this,"localPointsBatchData",new Map);I(this,"tasksqueue",new Map);I(this,"useTasksqueue",!1);I(this,"useTasksClockId");I(this,"mainTasksqueueCount");I(this,"workerTasksqueueCount");I(this,"snapshotMap",new Map);I(this,"boundingRectMap",new Map);I(this,"clearAllResolveMap",new Map);I(this,"delayWorkStateToDoneResolve");I(this,"animationId");I(this,"tmpImageConfigMap",new Map);I(this,"mainThread");I(this,"backgroundThreadManager");I(this,"willSelectorWorkId");I(this,"isLockSentEventCursor",!1);I(this,"getVNodeInfoResolveMap",new Map);I(this,"setFontFacesResolve",{});I(this,"isLocalWorkActive",!1);I(this,"indexDBUtils",Qn.getInstance());I(this,"markmapIdResolveMap",new Map);const{control:t,internalMsgEmitter:i,publicMsgEmitter:o}=e;this.control=t,this.maxLastSyncTime=this.control.pluginOptions.extras.syncOpt.interval,this.combineUnitTime=this.control.pluginOptions.extras.bezier.combineUnitTime||this.combineUnitTime,this.smoothSync=j.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=i,this.publicMsgEmitter=o,this.currentLocalWorkData={workState:D.Pending}}get isBezier(){return this.control.pluginOptions.extras.bezier.enable}get Logger(){return this.control.logger}destroy(){var e,t,i,o,s;(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.mainThread)==null||t.destroy(),this.mainThread=void 0,(i=this.backgroundThreadManager)==null||i.destroy(),this.backgroundThreadManager=void 0,(o=this.fullWorker)==null||o.terminate(),this.fullWorker=void 0,(s=this.subWorker)==null||s.terminate(),this.subWorker=void 0}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===S.Pencil||e===S.PencilEraser||e===S.BitMapEraser||e===S.LaserPen||e===S.Arrow||e===S.Straight||e===S.Ellipse||e===S.Rectangle||e===S.Star||e===S.Polygon||e===S.SpeechBalloon||e===S.Selector}get isCanDrawWork(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===S.Pencil||e===S.LaserPen||e===S.Arrow||e===S.Straight||e===S.Ellipse||e===S.Rectangle||e===S.Star||e===S.Polygon||e===S.SpeechBalloon||e===S.Triangle||e===S.Rhombus||e===S.BitMapEraser||e===S.PencilEraser}get isUseZIndex(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===S.Pencil||e===S.Arrow||e===S.Straight||e===S.Ellipse||e===S.Rectangle||e===S.Star||e===S.Polygon||e===S.SpeechBalloon||e===S.Text||e===S.Image}get isCanRecordUndoRedo(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===S.Pencil||e===S.Eraser||e===S.PencilEraser||e===S.BitMapEraser||e===S.Arrow||e===S.Straight||e===S.Ellipse||e===S.Rectangle||e===S.Star||e===S.Polygon||e===S.SpeechBalloon||e===S.Text||e===S.Image}get isCanSentCursor(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===S.Pencil||e===S.Text||e===S.LaserPen||e===S.Arrow||e===S.Straight||e===S.Ellipse||e===S.Rectangle||e===S.Star||e===S.Polygon||e===S.SpeechBalloon||e===S.Triangle||e===S.Rhombus||e===S.Eraser||e===S.PencilEraser||e===S.BitMapEraser||e===S.Selector}get isPostCountType(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===S.Pencil||e===S.Arrow||e===S.Straight||e===S.Ellipse||e===S.Rectangle||e===S.Star||e===S.Polygon||e===S.SpeechBalloon||e===S.Triangle||e===S.Rhombus||e===S.Eraser||e===S.PencilEraser||e===S.BitMapEraser||e===S.Selector}get isCanPostDraw(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===S.Pencil||e===S.PencilEraser||e===S.BitMapEraser}get isCanStartEventConsum(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===S.Selector||e===S.Eraser||e===S.PencilEraser||e===S.BitMapEraser}async init(){this.destroy();try{this.Logger.info(`[Appliance]: [plugin-options] ${JSON.stringify(this.control.pluginOptions.extras)}`)}catch(e){this.Logger.warn(`[Appliance]: [plugin-options] stringify failed: ${(e==null?void 0:e.message)||e}`)}await this.on(),this.internalMsgEmitterListener(),this.isActive=!0}async useBackgroundThread(){this.Logger.info("[Appliance]: use background thread");const{BackgroundThreadManagerImpl:e}=await Promise.resolve().then(()=>require("./index-PebKJQE3.js"));this.backgroundThreadManager=new e(this)}async useMainThread(){this.Logger.info("[Appliance]: no OffscreenCanvas"),this.control.hasExtendFontFaces&&await document.fonts.ready.then(()=>{this.Logger.info("[Appliance]: set font faces in main thread success")});const{MainThreadManagerImpl:e}=await Promise.resolve().then(()=>require("./index-BLzjGoXh.js"));this.mainThread=new e(this)}async on(){if(this.control.isUseBackgroundThread&&await this.useBackgroundThread(),!this.control.hasOffscreenCanvas){await this.useMainThread();return}if(!this.fullWorkerUrl||!this.subWorkerUrl){this.Logger.error("[Appliance]: 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:i,fullWorkerDrawCount:o,workerTasksqueueCount:s,viewId:a,consumeCount:c}=e.data;if(c&&(this.consumeCount=c),this.isBusy&&s&&this.setWorkerTasksqueueCount(s),i!=null&&i.length&&this.collectorSyncData(i),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(o&&a){if(this.fullWorkerDrawCount=o,this.fullWorkerDrawCount<1/0){const u=Math.max(this.maxDrawCount,this.fullWorkerDrawCount);this.setMaxDrawCount(u),this.clearReRenders(this.fullWorkerDrawCount)}else this.setMaxDrawCount(0),this.clearReRenders(1/0);if(this.reRenders.size)for(const u of this.reRenders.values())l.push(...u)}l.length&&this.viewContainerManager.render(l)}},this.subWorker&&(this.subWorker.onmessage=e=>{if(e.data){const{render:t,sp:i,subWorkerDrawCount:o,consumeCount:s}=e.data;s&&(this.consumeCount=s),i!=null&&i.length&&this.collectorSyncData(i);const a=(t==null?void 0:t.length)&&t||[];if(j.isNumber(o)){if(this.subWorkerDrawCount=o,this.fullWorkerDrawCount<1/0){const c=Math.max(this.maxDrawCount,this.subWorkerDrawCount);this.setMaxDrawCount(c)}if(t!=null&&t.length)if(this.subWorkerDrawCount>this.fullWorkerDrawCount){const c=[];for(const l of t)l.imageBitmap&&(l.isUnClose=!0,c.push(l));this.reRenders.set(this.subWorkerDrawCount,c)}else this.reRenders.size&&this.clearReRenders(this.subWorkerDrawCount)}a.length&&this.viewContainerManager.render(a)}}),this.control.hasExtendFontFaces){const e=this.control.extendFontFaces,t=[],i=[];this.control.room&&this.Logger.info(`[Appliance]: load before font faces ${JSON.stringify(e)}`),await new Promise(async o=>{this.setFontFacesResolve.resolve=o,this.setFontFacesResolve.timer=setTimeout(()=>{this.setFontFacesResolve.resolve&&(this.Logger.warn("[Appliance]: 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.Logger.warn(`[Appliance]: Failed to save font ${s.fontFamily} to IndexedDB, but continuing with font loading`))),a&&a.byteLength>0?(i.push({fontFamily:s.fontFamily,buffer:a}),t.push(a)):this.Logger.warn(`[Appliance]: Font ${s.fontFamily} could not be loaded from any source`)}this.Logger.info("[Appliance]: load end font faces"),i.length?this.fullWorker.postMessage(new Set([{type:$.SetFontFace,fontBuffers:i}]),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.Logger.error(`[Appliance]: set font faces error: ${s}`))}}).then(o=>{this.setFontFacesResolve.resolve=void 0,this.setFontFacesResolve.timer=void 0,o?this.Logger.info("[Appliance]: set font faces in web worker success"):this.Logger.error("[Appliance]: 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 i=await t.arrayBuffer();if(!i||i.byteLength===0)throw new Error("Empty font data received");const o=new Uint8Array(i);if(!this.validateFontData(o))throw new Error("Invalid font data format: not a valid font file");return i}catch(t){this.Logger.error(`[Appliance]: Failed to load font from ${e}: ${t instanceof Error?t.message:String(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}buildPropertyAppliedData(e,t,i){switch(e){case U.SetColorNode:return{strokeColor:t==null?void 0:t.strokeColor,fillColor:t==null?void 0:t.fillColor,fontColor:t==null?void 0:t.fontColor,fontBgColor:t==null?void 0:t.fontBgColor,thickness:t==null?void 0:t.thickness,strokeType:t==null?void 0:t.strokeType};case U.SetFontStyle:return{fontSize:t==null?void 0:t.fontSize,bold:t==null?void 0:t.bold,italic:t==null?void 0:t.italic,underline:t==null?void 0:t.underline,lineThrough:t==null?void 0:t.lineThrough};case U.SetLock:return{isLocked:i==null?void 0:i.isLocked};case U.SetShapeOpt:return{vertices:t==null?void 0:t.vertices,innerVerticeStep:t==null?void 0:t.innerVerticeStep,innerRatio:t==null?void 0:t.innerRatio,placement:t==null?void 0:t.placement};case U.ZIndexNode:return{zIndexLayer:i==null?void 0:i.zIndexLayer};default:return{}}}clearReRenders(e=1/0){for(const t of this.reRenders.keys())if(j.isNumber(Number(t))&&Number(t)<=e){const i=this.reRenders.get(Number(t));i==null||i.forEach(o=>{var s;(s=o.imageBitmap)==null||s.close()}),this.reRenders.delete(t)}}get isBusy(){return this.getTasksqueueState()===D.Doing}getLockSentEventCursor(){return this.isLockSentEventCursor}setLockSentEventCursor(e){this.isLockSentEventCursor=e}getTasksqueueState(){return this.useTasksqueue&&D.Doing||D.Done}setMaxDrawCount(e){this.maxDrawCount=e}getFullWorkDrawCount(){return this.fullWorkerDrawCount}getMaxDrawCount(){return this.maxDrawCount}setSubWorkerDrawCount(e){this.subWorkerDrawCount=e}setConsumeCount(e){this.consumeCount=e}getConsumeCount(){return this.consumeCount}setWorkerTasksqueueCount(e){const t=Math.max(this.workerTasksqueueCount||0,e);this.workerTasksqueueCount=t}collectorSyncData(e){var i,o,s,a,c,l,u,h,g,y,d,M,w,m,p;let t=!1;for(const T of e){const{type:v,selectIds:C,opt:N,selectRect:k,strokeColor:P,fillColor:A,willSyncService:x,isSync:E,imageBitmap:b,canvasHeight:O,canvasWidth:Y,rect:R,op:W,canTextEdit:B,points:H,selectorColor:Z,canRotate:F,scaleType:X,textOpt:ye,toolsType:se,workId:fe,viewId:ae,dataType:nt,canLock:ut,isLocked:ht,shapeOpt:dt,toolsTypes:gt,thickness:xe,strokeType:Pe,useStroke:it,isgl:$t,imageSrc:Wt,isSubWorker:on,updateNodeOpt:q,emitEventType:ee,requestId:oe,setFontFaceResult:ue,failedFonts:we,reportString:me,index:De,imageElement:Te,workState:Ae,isSelecting:ze,needUndoTicker:he}=T;if(v===$.SetFontFace){ue&&this.setFontFacesResolve.resolve&&(we&&we.length>0&&this.Logger.info("[Appliance]: set font face has failed fonts: "+we.join(", ")),this.setFontFacesResolve.resolve(ue));return}if(!ae)return;const ge=T.scenePath||this.viewContainerManager.getCurScenePath(ae);switch(v){case $.SelectorTransform:{if(ee&&Ae)try{(i=this.control.selectorApi)==null||i.onSelectorTransform({viewId:ae,emitEventType:ee,workState:Ae})}catch(K){(s=(o=this.Logger)==null?void 0:o.error)==null||s.call(o,`[Appliance]: [selector] onSelectorTransform failed: ${K==null?void 0:K.message}`)}break}case $.Select:{const K=C!=null&&C.length?{...k,selectIds:C,canvasHeight:O,canvasWidth:Y,points:H}:void 0;if(K&&(N!=null&&N.strokeColor)&&(K.selectorColor=N.strokeColor),K&&Z&&(K.selectorColor=Z),K&&P&&(K.strokeColor=P),K&&(N!=null&&N.fillColor)&&(K.fillColor=N.fillColor),K&&A&&(K.fillColor=A),K&&j.isBoolean(F)&&(K.canRotate=F),K&&X&&(K.scaleType=X),K&&B&&(K.canTextEdit=B),K&&ye&&(K.textOpt=ye),K&&j.isBoolean(ut)&&(K.canLock=ut),K&&j.isBoolean(ht)&&(K.isLocked=ht),K&&dt&&(K.shapeOpt=dt),K&&gt&&(K.toolsTypes=gt),K&&xe&&(K.thickness=xe),K&&Pe&&(K.strokeType=Pe),K&&j.isBoolean(it)&&(K.useStroke=it),ae&&this.viewContainerManager.showFloatBar(ae,!!K,K),x&&((a=this.collector)==null||a.dispatch({type:v,selectIds:C,opt:N,isSync:E,viewId:ae,scenePath:ge,needUndoTicker:he,requestId:oe,emitEventType:ee})),ze)break;try{(c=this.control.selectorApi)==null||c.onSelectorSync({viewId:ae,scenePath:ge,selectIds:C,selectRect:k,selectorInfo:K})}catch(de){(u=(l=this.Logger)==null?void 0:l.error)==null||u.call(l,`[Appliance]: [selector] onSelectorSync failed: ${de==null?void 0:de.message}`)}break}case $.Snapshot:if((b||Te)&&ge){const K=this.snapshotMap.get(ge);if(K){const{resolve:de,value:Ce}=K;if(Ce&&de){const Be=De||0;Ce[Be]=b||Te,Ce.every(rn=>rn!==void 0)&&de(Ce)}}}break;case $.BoundingBox:if(R&&ge){const K=this.boundingRectMap.get(ge);K&&K(R)}break;case $.Cursor:W&&this.control.cursor.collectServiceCursor({...T});break;case $.Clear:if(ae){this.viewContainerManager.showFloatBar(ae,!1);const K=(h=this.clearAllResolveMap.get(ae))==null?void 0:h.resolve;K&&K(ae);try{(g=this.control.selectorApi)==null||g.onSelectorCleared({viewId:ae,scenePath:ge})}catch(de){(d=(y=this.Logger)==null?void 0:y.error)==null||d.call(y,`[Appliance]: [selector] onSelectorCleared failed: ${de==null?void 0:de.message}`)}}break;case $.BackgroundSVGDelete:this.backgroundThreadManager&&ae&&this.backgroundThreadManager.consumeTargetOne(ae,{...T,msgType:$.BackgroundSVGDelete,viewId:ae,dataType:_.Local});break;case $.BackgroundSVGUpdate:this.backgroundThreadManager&&ae&&this.backgroundThreadManager.consumeTargetOne(ae,{...T,msgType:$.BackgroundSVGUpdate,viewId:ae,dataType:_.Local});break;case $.TextUpdate:if(se===S.Text&&fe&&ae){ee&&[U.SetColorNode,U.SetFontStyle,U.SetLock,U.SetShapeOpt,U.ZIndexNode].includes(ee)&&((M=this.control.selectorApi)==null||M.onPropertyApplied({type:ee,viewId:ae,scenePath:ge,requestId:oe,data:this.buildPropertyAppliedData(ee,N,q)}));const K=this.viewContainerManager.transformToOriginPoint((N==null?void 0:N.boxPoint)||[0,0],ae),de=(N==null?void 0:N.boxSize)||[0,0],Ce=(w=this.viewContainerManager.getView(ae))==null?void 0:w.cameraOpt;N?this.control.textEditorManager.updateTextForWorker({x:K[0],y:K[1],w:de[0],h:de[1],scale:(Ce==null?void 0:Ce.scale)||1,workId:fe,opt:N,dataType:nt,viewId:ae,canSync:x||!1,canWorker:!1,updateNodeOpt:q,skipStorageDispatch:!0}):this.control.textEditorManager.delete(fe,x||!1,!1),he&&((m=this.collector)==null||m.dispatch({type:$.UpdateNode,workId:fe,toolsType:S.Text,opt:N,updateNodeOpt:q,isSync:x||!1,viewId:ae,scenePath:ge,needUndoTicker:he,requestId:oe,emitEventType:ee}))}break;case $.GetTextActive:se===S.Text&&fe&&ae&&this.control.textEditorManager.updateTextForWorker({workId:fe,isActive:!0,viewId:ae,dataType:_.Local,canWorker:!1,canSync:!0},this.now);break;case $.GetImageBitMap:Wt&&ae&&fe&&ty({src:Wt,isgl:$t}).then(K=>{var Ce;const de=new Set;if(de.add({msgType:$.GetImageBitMap,dataType:_.Local,workId:fe,viewId:ae,imageSrc:Wt,isSubWorker:on,imageBitmap:K}),!this.control.hasOffscreenCanvas)(Ce=this.mainThread)==null||Ce.consume(de);else{const Be=on&&this.subWorker?this.subWorker:this.fullWorker;K?Be.postMessage(de,[K]):Be.postMessage(de)}});break;case $.GetVNodeInfo:if(fe){const K=fe.toString(),de=(p=this.getVNodeInfoResolveMap.get(K))==null?void 0:p.resolve,Ce={...T,uuid:K};de&&de(Ce)}break;case $.ReportError:case $.ReportLog:me&&(v===$.ReportError?this.Logger.error(`[Appliance]: [MasterControlForWorker] reportError ${me}`):this.Logger.info(`[Appliance]: [MasterControlForWorker] reportLog ${me}`));break;default:t=!0;break}}t&&this.collectorAsyncData(e)}collectorAsyncData(e){var t,i,o,s,a,c;for(const l of e){const{type:u,op:h,workId:g,index:y,removeIds:d,ops:M,opt:w,updateNodeOpt:m,emitEventType:p,requestId:T,toolsType:v,isSync:C,viewId:N,isLockSentEventCursor:k,nextTasks:P,needUndoTicker:A,collectUndoTicker:x,undoScopeIds:E,undoScopePhase:b}=l;if(!N){console.error("[MasterControlForWorker] collectorAsyncData on viewId in",l);return}const O=l.scenePath||this.viewContainerManager.getCurScenePath(N),Y=Number(x??A??void 0);switch(Y&&(E!=null&&E.length)&&(b==="collect"||b==="finalize")&&this.internalMsgEmitter.emit("collectExpectedWorkIds",Y,N,E,O),A&&Number(A)&&Vy(u)&&(E!=null&&E.length)&&this.internalMsgEmitter.emit("reopenStorageAck",Number(A),N,E,O),u){case $.None:{k&&He(()=>{this.setLockSentEventCursor(!1)},this.maxLastSyncTime,this.control.hasPolyfillMethod("requestIdleCallback")),A&&Number(A)&&He(()=>{this.internalMsgEmitter.emit("ackRenderUndoTicker",Number(A),N,O,{requestId:T,emitEventType:p})},0,this.control.hasPolyfillMethod("requestIdleCallback"));break}case $.DrawWork:{(t=this.collector)==null||t.dispatch({type:u,op:h,opt:w,toolsType:v,workId:g,index:y,isSync:C,viewId:N,scenePath:O,updateNodeOpt:m,needUndoTicker:A,collectUndoTicker:x,requestId:T,emitEventType:p});break}case $.FullWork:{if((i=this.collector)==null||i.dispatch({type:u,ops:M,workId:g,updateNodeOpt:m,opt:w,toolsType:v,isSync:C,viewId:N,scenePath:O,needUndoTicker:A,collectUndoTicker:x,requestId:T,emitEventType:p}),v===S.BackgroundSVG&&g&&this.markmapIdResolveMap.has(g.toString())){const R=this.markmapIdResolveMap.get(g.toString());R!=null&&R.timer&&(clearTimeout(R.timer),R.timer=void 0),R!=null&&R.resolve&&R.resolve(g.toString()),this.markmapIdResolveMap.delete(g.toString())}this.willSelectorWorkId&&g&&g.toString()===this.willSelectorWorkId&&this.control.runEffectWork(()=>{this.setShapeSelectorByWorkId(this.willSelectorWorkId,N),this.willSelectorWorkId=void 0});break}case $.UpdateNode:{p&&[U.SetColorNode,U.SetFontStyle,U.SetLock,U.SetShapeOpt,U.ZIndexNode].includes(p)&&((o=this.control.selectorApi)==null||o.onPropertyApplied({type:p,viewId:N,scenePath:O,requestId:T,data:this.buildPropertyAppliedData(p,w,m)})),(s=this.collector)==null||s.dispatch({type:u,updateNodeOpt:m,workId:g,opt:w,ops:M,op:h,isSync:C,viewId:N,scenePath:O,needUndoTicker:A,collectUndoTicker:x,requestId:T,emitEventType:p});break}case $.RemoveNode:{p===U.DeleteNode&&((a=this.control.selectorApi)==null||a.onRemoveNodeApplied({viewId:N,requestId:T,removeIds:d})),d&&this.control.textEditorManager.deleteBatch(d,!1,!1),(c=this.collector)==null||c.dispatch({type:u,removeIds:d,isSync:C,viewId:N,scenePath:O,needUndoTicker:A,collectUndoTicker:x,requestId:T,emitEventType:p}),this.willSelectorWorkId&&(d!=null&&d.includes(this.willSelectorWorkId))&&(this.willSelectorWorkId=void 0);break}}P&&this.collectorAsyncData(P)}}async onLocalEventEnd(e,t){var u,h,g,y;const i=this.viewContainerManager.getView(t);if(!i)return;const{focusScenePath:o,cameraOpt:s}=i,a=this.viewContainerManager.transformToScenePoint(e,t),c=[],l=[];(u=this.currentToolsData)==null||u.toolsType,S.Pencil;for(const d of this.localPointsBatchData.keys())if(((h=this.currentToolsData)==null?void 0:h.toolsType)===S.Text){const M=this.getLocalPointInfo(d),w=M==null?void 0:M.state;if(w&&w===D.Start){const m=this.currentLocalWorkData.toolsOpt;m.workState=D.Doing,m.boxPoint=[Math.round(a[0]),Math.round(a[1])],m.boxSize=[m.fontSize,m.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:m,type:qe.Text,isActive:!0,viewId:t,scenePath:o},this.now)}this.deleteLocalPoint(d);continue}else{this.pushLocalPoint(d,a,D.Done,t);const M=this.getLocalPointInfo(d);if(M){const w=this.createAutoShapeTask({workId:d,viewId:t,scenePath:o,points:[...M.rawPoints],opt:M.opt});w&&l.push(w)}c.push(d)}if(c.length){if(An((g=this.currentToolsData)==null?void 0:g.toolsType)){const d=this.currentLocalWorkData.undoTickerId;d&&o&&this.internalMsgEmitter.emit("finalizeRequested",d,t,[],o)}(y=this.currentToolsData)==null||y.toolsType,S.Pencil;try{if(await new Promise(M=>{setTimeout(async()=>{const w=new Set(l.map(m=>{var p;return(p=m.workId)==null?void 0:p.toString()}).filter(Boolean));c.forEach(m=>{if(w.has(m.toString())){this.deleteLocalPoint(m);return}this.setLocalPointIsFullWork(m)}),l.forEach(m=>{m.needUndoTicker&&o&&m.workId!==void 0&&m.workId!==null&&this.internalMsgEmitter.emit("finalizeRequested",Number(m.needUndoTicker),t,[m.workId.toString()],o),this.taskBatchData.add(m)}),this.delayWorkStateToDoneResolve=M,l.length&&w.size===c.length&&this.delayWorkStateToDoneResolve(!0),this.consume()},0)})&&c[0]){const M=c[0];c.forEach(w=>{this.deleteLocalPoint(w)}),this.willSelectorWorkId=M.toString()}}catch(d){this.Logger.error(`[Appliance]: [MasterControlForWorker] onLocalEventEnd error: ${d instanceof Error?d.message:String(d)}`)}this.delayWorkStateToDoneResolve=void 0,c.length=0}}onLocalEventDoing(e,t){var o;if(((o=this.currentToolsData)==null?void 0:o.toolsType)===S.Text)return;this.currentLocalWorkData.workState===D.Start&&this.setCurrentLocalWorkData({...this.currentLocalWorkData,workState:D.Doing});let i=!1;for(const[s,{state:a}]of this.localPointsBatchData.entries())if(this.isAbled()&&a!==D.Pending){const c=this.viewContainerManager.transformToScenePoint(e,t);this.pushLocalPoint(s,c,a===D.Start?D.Doing:a,t),i=!0}if(i){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 i=(c=this.currentToolsData)==null?void 0:c.toolsType,o=i===S.Selector?Q:this.newWorkId,s=this.setZIndex(t);S.Pencil,this.setCurrentLocalWorkData({workState:D.Start,toolsOpt:s,viewId:t});const a=this.viewContainerManager.transformToScenePoint(e,t);if(this.pushLocalPoint(o,a,D.Start,t,s),i!==S.Text){if(this.control.textEditorManager.checkEmptyTextBlur(),this.isCanRecordUndoRedo){const u=this.now,h=An(i)?{render:!0,storage:!0,scopeMode:"dynamic"}:{render:!0,storage:!0};S.Pencil,this.internalMsgEmitter.emit("addUndoTicker",u,t,h),this.setCurrentLocalWorkData({...this.currentLocalWorkData,undoTickerId:u})}if(o&&s&&i&&this.isCanStartEventConsum&&this.prepareOnceWork({workId:o,toolsOpt:s,viewId:t},i),this.consumeCount=0,this.postCount=0,this.maxDrawCount=0,this.fullWorkerDrawCount=0,this.subWorkerDrawCount=0,this.clearReRenders(1/0),this.isCanDrawWork){const u=this.viewContainerManager.getCurScenePath(t);u&&((l=this.collector)!=null&&l.hasSelector(t,u))&&(S.Pencil,this.blurSelector(t,u))}this.consume()}}setLocalPointIsFullWork(e){const t=this.getLocalPointInfo(e);t&&(t.isFullWork=!0,this.localPointsBatchData.set(e,t))}pushLocalPoint(e,t,i,o,s){let a=this.getLocalPointInfo(e);i===D.Start?a={state:D.Start,points:[...t],rawPoints:[...t],opt:s||this.currentLocalWorkData.toolsOpt,isFullWork:!1,viewId:o,undoTickerId:this.currentLocalWorkData.undoTickerId}:a&&(a.state=i,a.points.push(t[0],t[1]),a.rawPoints.push(t[0],t[1]),this.currentLocalWorkData.undoTickerId!==void 0&&(a.undoTickerId=this.currentLocalWorkData.undoTickerId)),a&&this.localPointsBatchData.set(e,a)}deleteLocalPoint(e){this.localPointsBatchData.delete(e)}getLocalPointInfo(e){return this.localPointsBatchData.get(e)}getLocalPointsInfo(){return this.localPointsBatchData}shouldUseAutoShape(e){var t;return((t=this.currentToolsData)==null?void 0:t.toolsType)===S.Pencil&&!!(e!=null&&e.autoShape)}toAutoShapePoints(e){const t=[];for(let i=0;i<e.length-1;i+=2)t.push([e[i],e[i+1]]);return t}logAutoShapeResult(e){}emitAutoShapeResult(e){const{viewId:t,workId:i,scenePath:o,result:s,recognized:a,mappedToolsType:c}=e,l=s.candidates[0],u={workId:i.toString(),viewId:t,scenePath:o,recognized:a,fallbackToPencil:!a,kind:s.kind,score:s.score,threshold:s.threshold,templateId:s.templateId,mappedToolsType:c,topCandidate:l?{kind:l.kind,score:l.score,threshold:l.threshold,templateId:l.templateId}:void 0,metrics:{cornerCount:s.metrics.cornerCount,straightness:s.metrics.straightness,closureRatio:s.metrics.closureRatio,radialVariance:s.metrics.radialVariance,bboxCornerCloseness:s.metrics.bboxCornerCloseness,diamondCloseness:s.metrics.diamondCloseness}};this.publicMsgEmitter.emit("autoShape",u)}createAutoShapeTask(e){const{workId:t,viewId:i,scenePath:o,points:s,opt:a}=e;if(!this.shouldUseAutoShape(a))return;const c=Yy({rawPoints:this.toAutoShapePoints(s),pencilOptions:j.cloneDeep(a),viewId:i,scenePath:o});if(!c)return;const l=By(c),u=lo(l,c)||this.mapAutoShapeFallback(l,c);if(this.logAutoShapeResult({viewId:i,workId:t,result:l,recognized:!!u}),this.emitAutoShapeResult({viewId:i,workId:t,scenePath:o,result:l,recognized:!!u,mappedToolsType:u==null?void 0:u.toolsType}),!!u)return{msgType:$.FullWork,dataType:_.Local,workId:t,viewId:i,scenePath:o,toolsType:u.toolsType,opt:u.opt,ops:hy(u),willRefresh:!0,willSyncService:!0,isRunSubWork:!0,clearPreviewLocalWork:!0,isLockSentEventCursor:!0,autoShapeResult:l,needUndoTicker:this.viewContainerManager.getUndoTickerId(i)}}mapAutoShapeFallback(e,t){const{metrics:i}=e;if(e.recognized||i.closureRatio>.1)return null;let o;return i.cornerCount>=4&&i.cornerCount<=6&&i.bboxCornerCloseness<=.15&&i.diamondCloseness>i.bboxCornerCloseness+.15?o="rectangle":i.cornerCount===3&&i.radialVariance<.28?o="triangle":i.cornerCount>=8&&i.cornerCount<=12&&i.radialVariance>.28?o="star":i.cornerCount>=5&&i.radialVariance<.22&&i.bboxCornerCloseness>.2&&(o="ellipse"),o?lo({...e,kind:o,recognized:!0},t):null}correctStorage(e,t,i){var h,g;const o=new Map,s=[],a=new Map,c=[];Object.keys(e).forEach(y=>{var w,m,p;const d=(m=(w=e[y])==null?void 0:w.opt)==null?void 0:m.zIndex,M=(p=e[y])==null?void 0:p.toolsType;j.isNumber(d)&&(M&&M===S.BackgroundSVG?c.push([y,d]):s.push([y,d]))});const l=s.length&&((h=this.zIndexNodeMethod)==null?void 0:h.correct(s))||[],u=c.length&&((g=this.zIndexNodeMethod)==null?void 0:g.correct(c))||[];this.zIndexNodeMethod&&l.length&&(this.zIndexNodeMethod.setMinZIndex(l[0][1]||0,t),this.zIndexNodeMethod.setMaxZIndex(l[l.length-1][1]||0,t)),this.zIndexNodeMethod&&u.length&&(this.zIndexNodeMethod.setMinZIndexForBackgroundSVG(u[0][1]||0,t),this.zIndexNodeMethod.setMaxZIndexForBackgroundSVG(u[u.length-1][1]||0,t));for(const[y,d]of l){if(!e[y])continue;const M=e[y];M.opt&&j.isNumber(M.opt.zIndex)&&M.opt.zIndex!==d&&(M.opt.zIndex=d,o.set(y,M))}o.size&&o.forEach((y,d)=>{var M;(M=this.collector)==null||M.updateValue(d,y,{viewId:t,scenePath:i,isSync:!0}),e[d]=y});for(const[y,d]of u){if(!e[y])continue;const M=e[y];M.opt&&j.isNumber(M.opt.zIndex)&&M.opt.zIndex!==d&&(M.opt.zIndex=d,a.set(y,M))}return a.size&&a.forEach((y,d)=>{var M;(M=this.collector)==null||M.updateValue(d,y,{viewId:t,scenePath:i,isSync:!0}),e[d]=y}),e}async originalEventLintener(e,t,i){var c,l,u;if(!this.isAbled())return;const o=(c=this.collector)==null?void 0:c.uid,s=this.viewContainerManager.getCurScenePath(i);if(o&&!this.control.renderControl.isWritable)return;const a=((l=this.currentToolsData)==null?void 0:l.toolsType)===S.Selector;switch((u=this.currentToolsData)==null?void 0:u.toolsType){case S.Eraser:case S.PencilEraser:case S.BitMapEraser:{if(o&&!this.control.renderControl.isClearAble({uid:o,viewId:i,scenePath:s}))return;break}default:{if(o&&!this.control.renderControl.isRenderAble({uid:o,viewId:i,scenePath:s}))return;break}}switch(e){case D.Start:this.isLocalWorkActive=!0,this.setLocalWorkViewId(i),i&&this.onLocalEventStart(t,i),a&&this.viewContainerManager.showFloatBarBtn(i,!1);break;case D.Doing:i&&i===this.getLocalWorkViewId()&&this.onLocalEventDoing(t,i);break;case D.Done:i&&i===this.getLocalWorkViewId()&&(this.setCurrentLocalWorkData({...this.currentLocalWorkData,workState:D.Done}),await this.onLocalEventEnd(t,i),setTimeout(()=>{this.isLocalWorkActive=!1,this.setCurrentLocalWorkData({workState:D.Pending}),a&&this.viewContainerManager.showFloatBarBtn(i,!0),this.setLocalWorkViewId(void 0)},0));break}this.isLocalWorkActive&&this.viewContainerManager.focuedViewId===i&&this.publicMsgEmitter.emit("workState",e,i),He(()=>{var h;(h=this.control.pluginManager)==null||h.dispatchPluginEvent("localEvent",i,e,t)},ii,this.control.hasPolyfillMethod("requestIdleCallback"))}getLocalWorkViewId(){return this.localWorkViewId}setLocalWorkViewId(e){this.localWorkViewId=e}setCurrentToolsData(e){var o,s,a;const t=e.toolsType,i=((o=this.currentToolsData)==null?void 0:o.toolsType)!==e.toolsType;if(super.setCurrentToolsData(e),i){const c=(s=this.viewContainerManager)==null?void 0:s.getAllViews();for(const l of c)if(l){const{id:u,focusScenePath:h}=l;i&&u&&h&&((a=this.collector)!=null&&a.hasSelector(u,h)&&this.blurSelector(u,h),this.control.textEditorManager.checkEmptyTextBlur())}this.taskBatchData.add({msgType:$.UpdateTools,dataType:_.Local,toolsType:t,opt:{...e.toolsOpt,syncUnitTime:this.maxLastSyncTime},combineUnitTime:this.isBezier?this.combineUnitTime:1/0,maxCombineEraserTime:this.maxCombineEraserTime,isRunSubWork:this.isRunSubWork,viewId:_o,isRunBackgroundThread:this.control.isUseBackgroundThread}),this.runAnimation()}}prepareOnceWork(e,t){const{workId:i,toolsOpt:o,viewId:s}=e,a={msgType:$.CreateWork,dataType:_.Local,viewId:s,toolsType:t};this.queryTaskBatchData(a).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add({...a,workId:i,opt:{...o,syncUnitTime:this.maxLastSyncTime},dataType:_.Local,isRunSubWork:this.isRunSubWork}),this.runAnimation()}createViewWorker(e,t,i){const{offscreenCanvasOpt:o,layerOpt:s,dpr:a,cameraOpt:c}=t,l={msgType:$.Init,dataType:_.Local,viewId:e,offscreenCanvasOpt:o,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:i.transferControlToOffscreenCanvas};this.isBusy&&this.destroyTaskQueue(),this.post(new Set([l])),this.taskBatchData.size&&this.consume()}destroyViewWorker(e,t=!1){var i;this.getLocalWorkViewId()===e&&this.setLocalWorkViewId(void 0),this.zIndexNodeMethod&&this.zIndexNodeMethod.clearZIndex(e),this.taskBatchData.add({msgType:$.Destroy,dataType:_.Local,viewId:e,isRunSubWork:!0}),this.consume(),t||(i=this.collector)==null||i.dispatch({type:$.Clear,viewId:e}),this.control.renderControl.destoryByViewId(e,t)}onServiceDerive(e,t){var d,M,w,m,p,T,v,C,N;const{newValue:i,oldValue:o,viewId:s,scenePath:a}=t,c=j.cloneDeep(i)||{},l=e;let u=c.type;if(!i&&o){if(l&&((d=this.collector)==null?void 0:d.getLocalId(l))===Q){this.collector.isOwn(l)?this.blurSelector(s,a):this.blurSelector(s,a,l);return}if(u=$.RemoveNode,o.toolsType===S.LaserPen)return}const h=(M=this.viewContainerManager.getView(s))==null?void 0:M.focusScenePath;if(h&&h!==a)return;if((w=this.collector)!=null&&w.isSelector(e)){const k=(m=this.collector)==null?void 0:m.getUidFromKey(e);if(k&&!this.control.roomMember.isOnLine(k))return}if(u&&l){if(!this.control.renderControl.isFilterAble({viewId:s,elementId:e,scenePath:a},u))return;const k=c;if(k.workId=(p=this.collector)!=null&&p.isOwn(l)?(T=this.collector)==null?void 0:T.getLocalId(l):l,k.msgType=u,k.toolsType===S.LaserPen&&(k.isRunSubWork=!0),k.toolsType===S.BackgroundSVG){if(!this.control.isUseBackgroundThread)return;k.isRunBackgroundThread=!0}if(k.dataType=_.Service,k.viewId=s,k.scenePath=a,k.useAnimation=this.smoothSync&&((v=k.updateNodeOpt)==null?void 0:v.useAnimation)||!1,k.selectIds&&(k.selectIds=k.selectIds.map(P=>{var A,x;return(A=this.collector)!=null&&A.isOwn(P)?(x=this.collector)==null?void 0:x.getLocalId(P):P})),k&&k.toolsType===S.Text||(o==null?void 0:o.toolsType)===S.Text){this.control.textEditorManager.onServiceDerive(k);return}k.isEnableCursor=this.control.cursor.isEnableCursor,this.taskBatchData.add(k)}this.runAnimation();const g=t.newValue&&((C=t.newValue)==null?void 0:C.toolsType),y=t.newValue&&((N=t.newValue.opt)==null?void 0:N.zIndex);if(g&&g===S.BackgroundSVG){if(this.zIndexNodeMethod&&j.isNumber(y)){const k=this.zIndexNodeMethod.getMinZIndexForBackgroundSVG(s);this.zIndexNodeMethod.getMaxZIndexForBackgroundSVG(s)<y&&this.zIndexNodeMethod.setMaxZIndexForBackgroundSVG(y,s),k>y&&this.zIndexNodeMethod.setMinZIndexForBackgroundSVG(y,s)}}else if(this.zIndexNodeMethod&&j.isNumber(y)){const k=this.zIndexNodeMethod.getMinZIndex(s);this.zIndexNodeMethod.getMaxZIndex(s)<y&&this.zIndexNodeMethod.setMaxZIndex(y,s),k>y&&this.zIndexNodeMethod.setMinZIndex(y,s)}}pullServiceData(e,t,i={isAsync:!1,useAnimation:!1}){var c,l,u,h,g,y,d;let o=(c=this.collector)==null?void 0:c.getStorageData(e,t);const{isAsync:s,useAnimation:a}=i;if(o){this.control.renderControl.isWritable&&(o=this.correctStorage(o,e,t));const M=Object.keys(o);for(const w of M){if((l=this.collector)!=null&&l.isSelector(w)){const p=(u=this.collector)==null?void 0:u.getUidFromKey(w);if(p&&!this.control.roomMember.isOnLine(p))continue}const m=(h=o[w])==null?void 0:h.type;if(m&&w){if(!this.control.renderControl.isFilterAble({viewId:e,elementId:w,scenePath:t},m))continue;const p=o[w];if(p.workId=(g=this.collector)!=null&&g.isOwn(w)?(y=this.collector)==null?void 0:y.getLocalId(w):w,p.msgType=m,p.dataType=_.Service,p.viewId=e,p.scenePath=t,p.useAnimation=this.smoothSync&&(p.ops?!!a:(d=p.updateNodeOpt)==null?void 0:d.useAnimation)||!1,p.selectIds&&(p.selectIds=p.selectIds.map(T=>{var v,C;return(v=this.collector)!=null&&v.isOwn(T)?(C=this.collector)==null?void 0:C.getLocalId(T):T})),p.toolsType===S.Text){this.control.textEditorManager.onServiceDerive(p);continue}if(p.toolsType===S.BackgroundSVG){if(!this.control.isUseBackgroundThread)continue;p.isRunBackgroundThread=!0}s&&p.updateNodeOpt&&p.updateNodeOpt.useAnimation&&(p.updateNodeOpt.useAnimation=!1),p.isEnableCursor=this.control.cursor.isEnableCursor,this.taskBatchData.add(p)}this.internalMsgEmitter.emit("excludeIds",M,e)}s?this.consume():this.runAnimation()}}runAnimation(){!this.animationId&&!this.isBusy&&(this.animationId=requestAnimationFrame(this.consume.bind(this)))}consume(){var t,i,o;this.animationId=void 0;const{viewId:e}=this.currentLocalWorkData;if(this.tasksqueue.size){const s=this.consumeQueue(),a=!!s.size;if(this.taskBatchData.size)for(const c of this.taskBatchData.values())c.dataType===_.Service&&(s.add(c),this.taskBatchData.delete(c));s.size?(this.post(s),a&&this.tasksqueue.clear()):this.tasksqueue.size&&(this.animationId=requestAnimationFrame(this.consume.bind(this)));return}if(this.isAbled()&&this.localPointsBatchData.size&&e)for(const[s,{state:a,isFullWork:c,points:l,opt:u,undoTickerId:h}]of this.localPointsBatchData.entries()){if(a===D.Done&&!c||a===D.Start&&!this.isCanStartEventConsum)continue;const g=l.map(y=>y);if(g.length){if(this.isPostCountType&&a===D.Doing){if(this.postCount>this.consumeCount)continue;this.postCount++}this.delayWorkStateToDoneResolve&&a===D.Done&&(this.delayWorkStateToDoneResolve(!0),this.setLockSentEventCursor(!0));const y=e&&this.viewContainerManager.getCurScenePath(e);a===D.Done&&h&&y&&Wy.has((t=this.currentToolsData)==null?void 0:t.toolsType)&&this.internalMsgEmitter.emit("finalizeRequested",h,e,[s.toString()],y),this.taskBatchData.add({op:g,workState:a,workId:s,dataType:_.Local,msgType:$.DrawWork,isRunSubWork:this.isRunSubWork,toolsType:(i=this.currentToolsData)==null?void 0:i.toolsType,viewId:e,scenePath:y,opt:u,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,needUndoTicker:a===D.Done&&h||void 0,collectUndoTicker:a!==D.Done&&An((o=this.currentToolsData)==null?void 0:o.toolsType)&&h||void 0}),l.length=0}}if(this.taskBatchData.size){const s=new Set(this.taskBatchData);this.post(s),this.taskBatchData.clear()}this.taskBatchData.size&&(this.animationId=requestAnimationFrame(this.consume.bind(this)))}unWritable(){this.setCurrentLocalWorkData({workState:D.Unwritable}),this.setLockSentEventCursor(!0)}abled(){this.setCurrentLocalWorkData({workState:D.Pending}),this.setLockSentEventCursor(!1)}isAbled(){return this.currentLocalWorkData.workState!==D.Unwritable}postMainThread(e){if(!this.control.hasOffscreenCanvas&&this.mainThread){this.mainThread.consume(e);return}}postWebWorker(e){if(this.control.isUseSimple){const t=[...e].find(i=>i.msgType===$.Init&&i.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 i of e.values()){const o=i.msgType;(o===$.Init||o===$.Clear||o===$.Destroy||o===$.UpdateCamera||o===$.Console||i.isRunSubWork)&&t.add(i)}t.size&&this.subWorker.postMessage(t)}}post(e){if(this.control.isUseBackgroundThread){if(!this.backgroundThreadManager){let i=[];i=j.cloneDeep([...e]),setTimeout(()=>{for(const o of i)this.taskBatchData.add(o)},0);return}const t=new Set;for(const i of e.values()){const o=i.msgType;(o===$.Init||o===$.Clear||o===$.Destroy||o===$.Console||i.isRunBackgroundThread)&&t.add(i)}t.size&&this.backgroundThreadManager.consume(t)}if(!this.control.hasOffscreenCanvas){if(!this.mainThread){let t=[];t=j.cloneDeep([...e]),setTimeout(()=>{for(const i of t)this.taskBatchData.add(i)},0);return}this.postMainThread(e);return}this.postWebWorker(e)}updateNode(e,t,i,o){this.taskBatchData.add({msgType:$.UpdateNode,workId:e,updateNodeOpt:t,viewId:i,scenePath:o,dataType:_.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:$.UpdateDpr,dataType:_.Local,viewId:e}).forEach(i=>{this.taskBatchData.delete(i)}),this.taskBatchData.add({dataType:_.Local,msgType:$.UpdateDpr,viewId:e,dpr:t,isRunSubWork:!0}),this.runAnimation()}updateCamera(e,t){var i,o,s,a;if(this.useTasksqueue||((i=this.methodBuilder)==null||i.pause(),this.blurCursor(e),this.checkDrawingWork(e),this.useTasksqueue=!0,this.mainTasksqueueCount=1,this.workerTasksqueueCount=1),this.useTasksqueue){this.tasksqueue.set(e,{msgType:$.UpdateCamera,dataType:_.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();try{(o=this.control.selectorApi)==null||o.onCameraChange(e)}catch(c){(a=(s=this.Logger)==null?void 0:s.error)==null||a.call(s,`[Appliance]: [selector] onCameraChange failed: ${c==null?void 0:c.message}`)}}}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:$.TasksQueue,dataType:_.Local,isRunSubWork:!0,isRunBackgroundThread:this.control.isUseBackgroundThread,mainTasksqueueCount:this.mainTasksqueueCount,tasksqueue:this.tasksqueue,viewId:""});for(const[i,o]of this.tasksqueue.entries())o.cameraOpt&&this.control.textEditorManager.onCameraChange(o.cameraOpt,i)}return e}async clearViewScenePath(e,t,i){var s,a;const o=this.viewContainerManager.getCurScenePath(e);if(i){const c=(s=this.collector)==null?void 0:s.uid;if(c&&!this.control.renderControl.isClearAble({uid:c,viewId:e,scenePath:o}))return}this.control.textEditorManager.clear(e,t),this.queryTaskBatchData({msgType:$.Clear,dataType:_.Local,viewId:e}).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add({dataType:_.Local,msgType:$.Clear,viewId:e}),this.runAnimation(),t||(this.control.renderControl.isUsePageAuth(e)&&o?this.control.renderControl.clearRenderPage(e,o):(a=this.collector)==null||a.dispatch({type:$.Clear,viewId:e,scenePath:o})),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 u=this.clearAllResolveMap.get(e);u!=null&&u.resolve&&u.resolve(e)},this.maxLastSyncTime),this.clearAllResolveMap.set(e,l)}).then(c=>{this.clearAllResolveMap.delete(c)})}internalMsgEmitterListener(){var e;this.methodBuilder=new te([U.CopyNode,U.SetColorNode,U.DeleteNode,U.RotateNode,U.ScaleNode,U.TranslateNode,U.ZIndexNode,U.SetFontStyle,U.SetPoint,U.SetLock,U.SetShapeOpt]).registerForMainEngine(ne.MainEngine,this.control),this.zIndexNodeMethod=(e=this.methodBuilder)==null?void 0:e.getBuilder(U.ZIndexNode)}setZIndex(e){const t=this.currentToolsData&&j.cloneDeep(this.currentToolsData.toolsOpt);return t&&this.zIndexNodeMethod&&this.isUseZIndex&&(this.zIndexNodeMethod.addMaxLayer(e),t.zIndex=this.zIndexNodeMethod.getMaxZIndex(e)),t}checkDrawingWork(e){var o,s,a,c,l;let t=!1;const i=[];for(const[u,{state:h,viewId:g,points:y,opt:d}]of this.localPointsBatchData.entries())if(e===g&&h===D.Start||h===D.Doing){if(h===D.Doing&&this.isCanDrawWork){Number(u)&&Number(u)+60>this.now&&(i.push(u.toString()),this.taskBatchData.add({msgType:$.RemoveNode,workId:u,viewId:g,dataType:_.Local,isRunSubWork:!0}));const M=y.map(w=>w);this.taskBatchData.add({op:M,workState:D.Done,workId:u,dataType:_.Local,msgType:$.DrawWork,isRunSubWork:this.isRunSubWork,toolsType:(o=this.currentToolsData)==null?void 0:o.toolsType,viewId:g,opt:d,scenePath:g&&this.viewContainerManager.getCurScenePath(g)}),t=!0}this.deleteLocalPoint(u)}if((t||i.length)&&((s=this.currentToolsData)==null||s.toolsType,S.Pencil,this.consume(),i.length)){const u=(a=this.viewContainerManager.getView(e))==null?void 0:a.focusScenePath;(c=this.currentToolsData)==null||c.toolsType,S.Pencil,(l=this.collector)==null||l.dispatch({type:$.RemoveNode,removeIds:i,viewId:e,scenePath:u})}}removeDrawingWork(e){var i,o,s,a;const t=[];for(const[c,{state:l,viewId:u}]of this.localPointsBatchData.entries())(e===u&&l===D.Start||l===D.Doing)&&(this.deleteLocalPoint(c),l===D.Doing&&this.isCanDrawWork&&(t.push(c.toString()),this.taskBatchData.add({msgType:$.RemoveNode,workId:c,viewId:u,dataType:_.Local,isRunSubWork:!0})));if(t.length){(i=this.currentToolsData)==null||i.toolsType,S.Pencil,this.consume();const c=(o=this.viewContainerManager.getView(e))==null?void 0:o.focusScenePath;(s=this.currentToolsData)==null||s.toolsType,S.Pencil,(a=this.collector)==null||a.dispatch({type:$.RemoveNode,removeIds:t,viewId:e,scenePath:c})}}removeNodes(e,t){var o,s;const i=(o=this.viewContainerManager.getView(e))==null?void 0:o.focusScenePath;if(i&&t.length){for(const a of t)this.taskBatchData.add({msgType:$.RemoveNode,workId:a,viewId:e,dataType:_.Local,isRunSubWork:!1});this.consume(),(s=this.collector)==null||s.dispatch({type:$.RemoveNode,removeIds:t,viewId:e,scenePath:i})}}hoverCursor(e,t){var i;if(((i=this.currentToolsData)==null?void 0:i.toolsType)===S.Selector&&!this.isBusy){const o=this.viewContainerManager.getView(t);if(o&&o.displayer&&o.displayer.vDom){const c=o.displayer.vDom.state.floatBarData;if(c){const{x:l,y:u,w:h,h:g}=c;if(rr(e,{x:l,y:u,w:h,h:g}))return}}const s=this.viewContainerManager.transformToScenePoint(e,t),a={msgType:$.CursorHover,dataType:_.Local,point:s,toolsType:this.currentToolsData.toolsType,opt:this.currentToolsData.toolsOpt,isRunSubWork:!1,viewId:t};this.queryTaskBatchData({msgType:$.CursorHover,dataType:_.Local,toolsType:this.currentToolsData.toolsType,viewId:t}).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add(a),this.runAnimation()}}blurCursor(e){var i;if(((i=this.currentToolsData)==null?void 0:i.toolsType)!==S.Selector)return;const t={msgType:$.CursorBlur,dataType:_.Local,isRunSubWork:!1,viewId:e};this.queryTaskBatchData({msgType:$.CursorHover,dataType:_.Local,viewId:e}).forEach(o=>{this.taskBatchData.delete(o)}),this.taskBatchData.add(t),this.consume()}sendCursorEvent(e,t){var c,l,u;if(!this.currentLocalWorkData||this.currentLocalWorkData.workState===D.Unwritable||this.isBusy)return;const i=(c=this.currentToolsData)==null?void 0:c.toolsType;if(!this.useTasksqueue&&this.workState===D.Pending&&i===S.Selector&&(j.isNumber(e[0])&&j.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 o=(l=this.collector)==null?void 0:l.uid,s=this.viewContainerManager.getCurScenePath(t);switch((u=this.currentToolsData)==null?void 0:u.toolsType){case S.Eraser:case S.PencilEraser:case S.BitMapEraser:{if(o&&!this.control.renderControl.isClearAble({uid:o,viewId:t,filterLocalSelf:!1,scenePath:s}))return;break}default:if(o&&!this.control.renderControl.isWritable||o&&!this.control.renderControl.isRenderAble({uid:o,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 i,o;if(!((i=this.boundingRectMap)==null?void 0:i.get(e))){const s=(o=this.collector)==null?void 0:o.getScenePathData(e);if(!s)return;if(Object.keys(s).forEach(a=>{var c;((c=this.collector)==null?void 0:c.getLocalId(a))===Q&&delete s[a]}),Object.keys(s).length&&this.viewContainerManager.mainView&&this.viewContainerManager.mainView.cameraOpt){const a={msgType:$.BoundingBox,dataType:_.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,i,o){var a,c,l,u,h;if(!((a=this.snapshotMap)==null?void 0:a.get(e))){const g=(c=this.collector)==null?void 0:c.getViewIdBySecenPath(e);if(!g)return;const y=(l=this.collector)==null?void 0:l.getStorageData(g,e);if(!y)return;if(Object.keys(y).forEach(d=>{var M;((M=this.collector)==null?void 0:M.getLocalId(d))===Q&&delete y[d]}),Object.keys(y).length){const d=this.viewContainerManager.mainView;if(!d)return;const M=t||((u=d.cameraOpt)==null?void 0:u.width),w=i||((h=d.cameraOpt)==null?void 0:h.height),m={msgType:$.Snapshot,dataType:_.Local,scenePath:e,scenes:y,w:M,h:w,cameraOpt:o&&{...o,width:M,height:w}||d.cameraOpt,isRunSubWork:!0,isRunBackgroundThread:this.control.isUseBackgroundThread,viewId:g};return this.taskBatchData.add(m),this.runAnimation(),new Promise(p=>{this.snapshotMap.set(e,{resolve:p,value:this.control.isUseBackgroundThread?[void 0,void 0]:[void 0]})}).then(p=>(this.snapshotMap.delete(e),p.reverse()))}}}queryTaskBatchData(e){const t=[];if(e)for(const i of this.taskBatchData.values()){let o=!0;for(const[s,a]of Object.entries(e))if(i[s]!==a){o=!1;break}o&&t.push(i)}return t}insertIconify(e,t){var a;const i=this.viewContainerManager.getView(e);if(!i)throw new Error("insertIconify viewId is not exist");if(!t.src)throw new Error("iconify src must be required");if(!/^(http|https):\/\//.test(t.src))throw new Error("iconify src must be http or https");t.strokeColor||(t.strokeColor=(a=this.currentLocalWorkData.toolsOpt)==null?void 0:a.strokeColor);const s=i==null?void 0:i.focusScenePath;if(e&&s){const c=this.now;Me.InternalMsgEmitter.emit("addUndoTicker",c,e,{render:!0,storage:!0}),Me.InternalMsgEmitter.emit("finalizeRequested",c,e,[t.uuid],s);const l={...t,type:Jt.Iconify};this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayer(e),l.zIndex=this.zIndexNodeMethod.getMaxZIndex(e)),this.taskBatchData.add({msgType:$.FullWork,dataType:_.Local,toolsType:S.Image,workId:t.uuid,opt:l,viewId:e,willRefresh:!0,willSyncService:!0,needUndoTicker:c}),this.runAnimation()}}insertBackgroundSVG(e,t){if(!this.control.isUseBackgroundThread)throw new Error("useBackgroundThread of pluginOptions should be true");const i=this.viewContainerManager.getView(e);if(!i)throw new Error("insertBackgroundSVG viewId is not exist");if(!t.src)throw new Error("src must be required");if(t.src&&!/^(http|https):\/\//.test(t.src))throw new Error("iconify src must be http or https");const o=i==null?void 0:i.focusScenePath;if(e&&o){const s=this.now;Me.InternalMsgEmitter.emit("addUndoTicker",s,e,{render:!0,storage:!0}),Me.InternalMsgEmitter.emit("finalizeRequested",s,e,[t.uuid],o);const a={...t,type:Kt.url};this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayerForBackgroundSVG(e),a.zIndex=this.zIndexNodeMethod.getMaxZIndexForBackgroundSVG(e)),this.taskBatchData.add({msgType:$.FullWork,dataType:_.Local,toolsType:S.BackgroundSVG,workId:t.uuid,opt:a,viewId:e,willRefresh:!0,willSyncService:!0,needUndoTicker:s,isRunBackgroundThread:!0}),this.runAnimation()}}async insertBackgroundMarkMap(e,t){var s;if(!this.control.isUseBackgroundThread)throw new Error("useBackgroundThread of pluginOptions should be true");const i=this.viewContainerManager.getView(e);if(!i)throw new Error("instertBackgroundMarkMap viewId is not exist");if(!t.data)throw new Error("data must be required");if(t.data&&!LM(t.data))throw new Error("data must be markdown string");const o=i==null?void 0:i.focusScenePath;if(e&&o){const a=t.uuid.toString();if((s=this.collector)!=null&&s.hasId(e,o,a))throw new Error("instertBackgroundMarkMap svgInfo.uuid is already exist");if(this.markmapIdResolveMap.has(a))throw new Error("instertBackgroundMarkMap svgInfo.uuid is already resolving");const c=this.now;Me.InternalMsgEmitter.emit("addUndoTicker",c,e,{render:!0,storage:!0}),Me.InternalMsgEmitter.emit("finalizeRequested",c,e,[a],o);const l={...t,type:Kt.markmap};return this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayerForBackgroundSVG(e),l.zIndex=this.zIndexNodeMethod.getMaxZIndexForBackgroundSVG(e)),this.taskBatchData.add({msgType:$.FullWork,dataType:_.Local,toolsType:S.BackgroundSVG,workId:a,opt:l,viewId:e,willRefresh:!0,willSyncService:!0,needUndoTicker:c,isRunBackgroundThread:!0}),this.runAnimation(),new Promise((u,h)=>{this.markmapIdResolveMap.set(a,{resolve:u,timer:setTimeout(()=>{const g=this.markmapIdResolveMap.get(a);g!=null&&g.timer&&(g.timer=void 0),h(a)},this.control.pluginOptions.extras.markmap.timeout)})}).then(u=>{if(u)return this.markmapIdResolveMap.delete(u),u}).catch(u=>{throw this.markmapIdResolveMap.delete(u),Me.InternalMsgEmitter.emit("ackRenderUndoTicker",c,e,o),Me.InternalMsgEmitter.emit("ackStorageUndoTicker",c,e,o),new Error(`instertBackgroundMarkMap svgInfo.uuid ${u} insert timeout`)})}}async updateBackgroundMarkMap(e,t,i){var l;const o=this.viewContainerManager.getView(e);if(!o)throw new Error("updateBackgroundMarkMap viewId is not exist");const s=o==null?void 0:o.focusScenePath;if(!s)throw new Error("updateBackgroundMarkMap scenePath is not exist");if((l=this.collector)!=null&&l.hasId(e,s,t))throw new Error("instertBackgroundMarkMap svgInfo.uuid is already exist");if(this.markmapIdResolveMap.has(t))throw new Error("instertBackgroundMarkMap svgInfo.uuid is already resolving");const a=this.now;Me.InternalMsgEmitter.emit("addUndoTicker",a,e,{render:!0,storage:!0}),Me.InternalMsgEmitter.emit("finalizeRequested",a,e,[t],s);const c={...i,type:Kt.markmap};this.taskBatchData.add({msgType:$.UpdateNode,dataType:_.Local,toolsType:S.BackgroundSVG,workId:t,opt:c,viewId:e,willRefresh:!0,willSyncService:!0,needUndoTicker:a,isRunBackgroundThread:!0}),this.runAnimation()}insertImage(e,t){const i=this.viewContainerManager.getView(e);if(!i)throw new Error("insertImage viewId is not exist");if(t.src&&!/^(http|https):\/\//.test(t.src))throw new Error("Image src must be http or https");const o=i==null?void 0:i.focusScenePath;if(e&&o){const{src:s,uuid:a}=t;if(a&&!s){this.tmpImageConfigMap.set(a,t);return}const c=this.now;Me.InternalMsgEmitter.emit("addUndoTicker",c,e,{render:!0,storage:!0});const l={...t,type:Jt.Image};this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayer(e),l.zIndex=this.zIndexNodeMethod.getMaxZIndex(e)),this.taskBatchData.add({msgType:$.FullWork,dataType:_.Local,toolsType:S.Image,workId:t.uuid,opt:l,viewId:e,willRefresh:!0,willSyncService:!0,needUndoTicker:c}),this.runAnimation(),Me.InternalMsgEmitter.emit("finalizeRequested",c,e,[t.uuid],o)}}lockImage(e,t,i){var a,c;const o=this.viewContainerManager.getView(e);if(!o)throw new Error("insertImage viewId is not exist");const s=o==null?void 0:o.focusScenePath;if(e&&s&&this.collector){const l=this.collector.getStorageData(e,s);if(!l)return;for(const[u,h]of Object.entries(l))if(h&&h.toolsType===S.Image&&h.opt.uuid===t){const g=this.now,y=(a=this.collector)!=null&&a.isOwn(u)?(c=this.collector)==null?void 0:c.getLocalId(u):u;Me.InternalMsgEmitter.emit("addUndoTicker",g,e,{render:!0,storage:!0});const d={...h.opt,locked:i,type:Jt.Image};this.taskBatchData.add({msgType:$.FullWork,dataType:_.Local,toolsType:S.Image,workId:y,opt:d,viewId:e,willRefresh:!0,willSyncService:!0,needUndoTicker:g}),this.runAnimation(),Me.InternalMsgEmitter.emit("finalizeRequested",g,e,[y],s);return}}}completeImageUpload(e,t,i){const o=this.viewContainerManager.getView(e);if(!o)throw new Error("insertImage viewId is not exist");const s=o==null?void 0:o.focusScenePath;if(e&&s){const a=this.tmpImageConfigMap.get(t);a&&(a.src=i,this.insertImage(e,a),this.tmpImageConfigMap.delete(t));return}}getImagesInformation(e){const t=[];if(this.collector){const i=this.collector.getScenePathData(e);if(!i)return t;for(const o of Object.values(i))if(o&&o.toolsType===S.Image){const s=o.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:Q,selectIds:[e],msgType:$.Select,dataType:_.Local,viewId:t,willSyncService:!0}),this.runAnimation()}blurSelector(e,t,i){this.taskBatchData.add({workId:i||Q,selectIds:[],msgType:$.Select,dataType:_.Service,viewId:e,scenePath:t}),this.runAnimation()}consoleWorkerInfo(){this.taskBatchData.add({msgType:$.Console,dataType:_.Local,isRunSubWork:!0,viewId:""}),this.consume()}sendClearUids(e,t){var o,s;const i=new Set;i.add({msgType:$.AuthClear,dataType:_.Local,viewId:e,clearUids:t,localUid:(o=this.collector)==null?void 0:o.uid}),this.control.hasOffscreenCanvas?this.fullWorker.postMessage(i):(s=this.mainThread)==null||s.consume(i)}async getVNodeInfo(e,t,i){if(!this.getVNodeInfoResolveMap.has(e))return this.taskBatchData.add({msgType:$.GetVNodeInfo,dataType:_.Local,isRunSubWork:!0,viewId:t,workIds:i,workId:e}),this.consume(),await new Promise(o=>{const s=this.getVNodeInfoResolveMap.get(e)||{resolve:void 0,timer:void 0};s.timer&&clearTimeout(s.timer),s.resolve=o,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(o=>{const{uuid:s}=o;return this.getVNodeInfoResolveMap.delete(s),o})}}class Qy{constructor(n){I(this,"internalMsgEmitter");I(this,"control");I(this,"roomHotkeyCheckers");I(this,"tmpCopyStore",new Map);I(this,"tmpCopyCoordInfo");var i;const{control:e,internalMsgEmitter:t}=n;this.control=e,this.internalMsgEmitter=t,this.roomHotkeyCheckers=((i=this.control.room)==null?void 0:i.viewsParams.hotKeys.nodes)||[]}get isUseSelf(){var n,e;return((e=(n=this.control)==null?void 0:n.room)==null?void 0:e.disableDeviceInputs)||!1}get isSelector(){var n;return((n=this.control.worker.currentToolsData)==null?void 0:n.toolsType)===S.Selector}get collector(){return this.control.collector}get mainEngine(){return this.control.worker}get keyboardKind(){return/^Mac/i.test(navigator.platform)?"mac":"windows"}getEventKey(n){switch(n.type){case"keydown":return"KeyDown"}return"KeyUp"}onActiveHotkey(n){var i,o,s;const e=this.control.viewContainerManager.focuedViewId,t=(i=this.control.viewContainerManager.focuedView)==null?void 0:i.focusScenePath;if(e&&t)switch(n){case"delete":this.isSelector&&((o=this.collector)!=null&&o.hasSelector(e,t))&&te.emitMethod(ne.MainEngine,U.DeleteNode,{workIds:[Q],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}(n==="changeToPencil"||n==="redo"||n==="undo")&&this.onSelfActiveHotkey(n)}colloctHotkey(n){if(this.isUseSelf){const e=this.checkHotkey(n);e&&this.onSelfActiveHotkey(e)}}onSelfActiveHotkey(n){switch(n){case"changeToPencil":this.setMemberState({currentApplianceName:ie.pencil,useNewPencil:!0});break;case"changeToArrow":this.setMemberState({currentApplianceName:ie.arrow});break;case"changeToClick":this.setMemberState({currentApplianceName:ie.clicker});break;case"changeToEllipse":this.setMemberState({currentApplianceName:ie.ellipse});break;case"changeToEraser":this.setMemberState({currentApplianceName:ie.eraser});break;case"changeToHand":this.setMemberState({currentApplianceName:ie.hand});break;case"changeToLaserPointer":this.setMemberState({currentApplianceName:ie.laserPointer});break;case"changeToSelector":this.setMemberState({currentApplianceName:ie.selector});break;case"changeToRectangle":this.setMemberState({currentApplianceName:ie.rectangle});break;case"changeToStraight":this.setMemberState({currentApplianceName:ie.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:ie.text});break;case"changeToPencilEraser":this.setMemberState({currentApplianceName:ie.pencilEraser});break;case"delete":case"copy":case"paste":this.onActiveHotkey(n);break}}checkHotkey(n){for(const e of this.roomHotkeyCheckers){const{kind:t,checker:i}=e;if(i({nativeEvent:n,kind:this.getEventKey(n),key:n.key,altKey:n.altKey,ctrlKey:n.ctrlKey,shiftKey:n.shiftKey},this.keyboardKind))return t}}copySelectorToTemp(n,e){var l,u;const t=this.control.viewContainerManager.getView(n),i=(u=(l=this.mainEngine)==null?void 0:l.methodBuilder)==null?void 0:u.getBuilder(U.CopyNode);if(!t||!this.collector||!i)return;const o=this.collector.transformKey(Q),s=this.collector.getStorageData(n,e);if(!s)return;const a=s[o],c=a&&i.copySelector({viewId:n,store:a});c&&(this.tmpCopyCoordInfo=c==null?void 0:c.copyCoordInfo,this.tmpCopyStore=c==null?void 0:c.copyStores)}pasteTempToFocusView(n,e){var o,s;const t=this.control.viewContainerManager.getView(n),i=(s=(o=this.mainEngine)==null?void 0:o.methodBuilder)==null?void 0:s.getBuilder(U.CopyNode);if(!(!t||!this.tmpCopyCoordInfo||!this.tmpCopyStore.size||!this.collector||!i)&&t.viewData&&this.tmpCopyCoordInfo){const a=j.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 u=this.control.worker.now;this.control.worker.internalMsgEmitter.emit("addUndoTicker",u,n,{render:!0,storage:!0,copyAck:!0}),i.pasteSelector({viewId:n,scenePath:e,copyStores:j.cloneDeep(this.tmpCopyStore),copyCoordInfo:{offset:a,cameraOpt:l},undoTickerId:u})}}setMemberState(n){var e;(e=this.control.room)==null||e.setMemberState(n)}}class Zy{constructor(n){I(this,"control");I(this,"roomMemberManager");I(this,"worker");I(this,"publicMsgEmitter");I(this,"renderUids",new Map);I(this,"pageAuth",new Map);I(this,"isLocalRender",!1);I(this,"isCurWritable",!1);var i;const{control:e,publicMsgEmitter:t}=n;this.control=e,this.publicMsgEmitter=t,this.roomMemberManager=e.roomMember,this.worker=e.worker,this.isCurWritable=((i=this.control.room)==null?void 0:i.isWritable)||!1}get isWritable(){return this.isCurWritable}onWritableChange(n){this.isCurWritable=n}addPage(n,e=!0){var l,u;const{viewId:t,render:i="localSelf",elementIds:o,pageId:s=(l=this.control.collector)==null?void 0:l.uid}=n,a=this.pageAuth.get(t)||new Map,c=this.control.viewContainerManager.getCurScenePath(t);if(c&&s){const h=a.get(c)||{render:"localSelf",pages:new Map};e&&(h.render=i);const g=o&&this.cloneElementIds(t,c,o,s)||new Set;h.pages.set(s,g),a.set(c,h),this.pageAuth.set(t,a),e&&this.pageAuthEffect(t),this.isLocalRender=!1,(u=this.control.collector)==null||u.dispatchPageAuth({operation:be.addPage,viewId:t,scenePath:c,pageId:s,pageData:{render:i,elementIds:g}},!0)}}delPage(n,e){var s,a;const t=this.pageAuth.get(e);if(!t)return;const i=[...t.keys()].find(c=>{const l=t.get(c);return!!(l&&l.pages.has(n))});if(!i)return;const o=t.get(i);if(o){const{render:c,pages:l}=o,u=c==="localSelf"?(s=this.control.collector)==null?void 0:s.uid:c,h=l.get(n);h!=null&&h.size&&this.delElementIds(e,i,h),l.delete(n),u===n&&this.pageAuthEffect(e)}(a=this.control.collector)==null||a.dispatchPageAuth({operation:be.deletePage,viewId:e,scenePath:i,pageId:n},!0)}delViewPage(n,e=!0){var i;this.pageAuth.get(n)&&(this.pageAuth.delete(n),e&&((i=this.control.collector)==null||i.dispatchPageAuth({operation:be.clearView,viewId:n},e)))}clearRenderPage(n,e,t=!0){var a,c;const i=this.pageAuth.get(n);if(!i)return;const o=i.get(e);let s;if(o){const{render:l,pages:u}=o,h=l==="localSelf"?(a=this.control.collector)==null?void 0:a.uid:l;if(h){if(t){const g=u.get(h);g&&this.delElementIds(n,e,g)}u.set(h,new Set),s=h}}t&&s&&((c=this.control.collector)==null||c.dispatchPageAuth({operation:be.clearPage,viewId:n,scenePath:e,pageId:s},t))}hasPage(n,e,t){const i=this.pageAuth.get(e);if(!i)return!1;const o=i.get(t);return o?o.pages.has(n):!1}getPageInfo(n,e,t){const i=this.pageAuth.get(e);if(!i)return;const o=i.get(t);if(o)return o.pages.get(n)}addRenderPageElementId(n,e=!0,t=!1){var u,h;const{viewId:i,elementId:o,scenePath:s}=n,a=this.pageAuth.get(i);if(!a)throw new Error(`no view info in viewId: ${i}`);const c=a.get(s);let l;if(c){const{render:g,pages:y}=c,d=g==="localSelf"?(u=this.control.collector)==null?void 0:u.uid:g;if(d&&y.has(d)){const M=y.get(d)||new Set;M.add(o),y.set(d,M),l=d}}t&&this.pageAuthEffect(i),e&&l&&((h=this.control.collector)==null||h.dispatchPageAuth({operation:be.addElement,viewId:i,scenePath:s,pageId:l,pageData:{elementId:o}},e))}delRenderPageElementId(n,e=!0,t=!1){var u,h;const{viewId:i,elementId:o,scenePath:s}=n,a=this.pageAuth.get(i);if(!a)throw new Error(`no view info in viewId: ${i}`);const c=a.get(s);let l;if(c){const{render:g,pages:y}=c,d=g==="localSelf"?(u=this.control.collector)==null?void 0:u.uid:g;if(d&&y.has(d)){const M=y.get(d);M&&(M.delete(o),y.set(d,M),l=d)}}t&&this.pageAuthEffect(i),e&&l&&((h=this.control.collector)==null||h.dispatchPageAuth({operation:be.deleteElement,viewId:i,scenePath:s,pageId:l,pageData:{elementId:o}},e))}setPageRender(n,e,t,i=!0){var a;const o=this.pageAuth.get(n);if(!o)throw new Error(`no view info in viewId: ${n}`);const s=o.get(e);s&&(s.render=t),e===this.control.viewContainerManager.getCurScenePath(n)&&this.pageAuthEffect(n),i||(this.isLocalRender=!0),i&&(this.isLocalRender=!1,(a=this.control.collector)==null||a.dispatchPageAuth({operation:be.renderPage,viewId:n,scenePath:e,pageData:{render:t}},i))}isRenderAble(n){var c,l;const{uid:e,viewId:t,filterLocalSelf:i=!0,scenePath:o}=n,s=this.renderUids.get(t);if(s){const{render:u,hide:h}=s;if(u===void 0&&h===void 0)return!0;if(j.isSet(u)){if(u.has(e)||i&&((c=this.control.collector)==null?void 0:c.uid)===e&&u.has("localSelf"))return!0}else if(u===!0&&(!h||j.isSet(h)&&!h.has(e)&&!(i&&h.has("localSelf")&&((l=this.control.collector)==null?void 0:l.uid)===e)))return!0;return!1}const a=this.pageAuth.get(t);if(a&&o){const u=a.get(o);if(u){const{render:h}=u;if(h)return!(h==="localSelf"&&!i)}}return!0}isClearAble(n){var c;const{uid:e,viewId:t,filterLocalSelf:i=!0,scenePath:o}=n,s=this.renderUids.get(t);if(s){const{clear:l}=s;return!!(l===void 0||l===!0||j.isSet(l)&&(l.has(e)||i&&((c=this.control.collector)==null?void 0:c.uid)===e&&l.has("localSelf")))}const a=this.pageAuth.get(t);if(a&&o){const l=a.get(o);if(l){const{render:u}=l;if(u)return!(u==="localSelf"&&!i)}}return!0}isFilterAble(n,e){var c,l,u,h;const{viewId:t,scenePath:i,elementId:o}=n,s=this.renderUids.get(t);if(s&&o){const{render:g,hide:y}=s;if(g===void 0&&y===void 0)return!0;const d=(c=this.control.collector)==null?void 0:c.getUidFromKey(o);return d?!!(j.isSet(g)&&(g.has(d)||g.has("localSelf")&&((l=this.control.collector)==null?void 0:l.uid)===d)||g===!0&&(!y||j.isSet(y)&&!y.has(d)&&!(y.has("localSelf")&&((u=this.control.collector)==null?void 0:u.uid)===d))):!1}const a=this.pageAuth.get(t);if(a&&i&&o){const g=a.get(i);if(g){const{render:y,pages:d}=g;if(!y)return!0;const M=(h=this.control.collector)==null?void 0:h.uid,w=y==="localSelf"?M:y,m=w&&d.get(w)||void 0;if(m)switch(e){case $.RemoveNode:return!0;default:return m.has(o)}return!1}}return!0}isFilterCursor(n){if(this.isUsePageAuth(n)){const e=this.control.viewContainerManager.getCurScenePath(n),t=this.pageAuth.get(n);if(e&&t){const i=t.get(e);if(i){const{render:o}=i;return o!=="localSelf"}}}return!0}isUsePageAuth(n){var i;if(!this.pageAuth.has(n))return!1;const t=this.control.viewContainerManager.getCurScenePath(n);return t&&((i=this.pageAuth.get(n))==null?void 0:i.has(t))||!1}publishRender(n){var s;const{viewId:e,option:t,isSync:i=!0}=n,o={};if(t){const{render:a,hide:c,clear:l}=t;a&&(o.render=a===!0&&!0||new Set(a)),c&&(o.hide=c===!0&&!0||new Set(c)),l&&(o.clear=l===!0&&!0||new Set(l)),this.renderUids.set(e,o)}else this.renderUids.delete(e);i&&((s=this.control.collector)==null||s.dispatchRenderAuth({operation:Ze.setAuth,viewId:e,renderData:o},i)),this.renderEffect(e)}publishOneRender(n,e,t,i=!0){var a;const o=this.renderUids.get(n);let s;switch(t){case"show":o?(o.render||(o.render=new Set),j.isSet(o.render)&&o.render.add(e),j.isSet(o.hide)&&o.hide.delete(e)):this.renderUids.set(n,{render:new Set([e])}),s=Ze.setShow;break;case"hide":o?(o.hide||(o.hide=new Set),j.isSet(o.hide)&&o.hide.add(e),j.isSet(o.render)&&o.render.delete(e)):this.renderUids.set(n,{hide:new Set([e])}),s=Ze.setHide;break}o?this.renderUids.set(n,o):this.renderUids.delete(n),i&&s&&((a=this.control.collector)==null||a.dispatchRenderAuth({operation:s,viewId:n,uid:e},i)),this.renderEffect(n)}publishOneClear(n,e,t,i=!0){var s;const o=this.renderUids.get(n);t?o?(o.clear||(o.clear=new Set),j.isSet(o.clear)&&o.clear.add(e)):this.renderUids.set(n,{clear:new Set([e])}):o&&j.isSet(o.clear)&&o.clear.has(e)&&o.clear.delete(e),o?this.renderUids.set(n,o):this.renderUids.delete(n),i&&((s=this.control.collector)==null||s.dispatchRenderAuth({operation:Ze.setClear,viewId:n,uid:e,isClear:t},i)),this.renderEffect(n)}syncRenderUids(n,e,t,i){const o=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=i===!0?!0:i&&Object.keys(i)?new Set(Object.keys(i)):void 0;o||s||a?this.renderUids.set(n,{render:o,hide:s,clear:a}):this.renderUids.delete(n),this.renderEffect(n),this.publicMsgEmitter.emit("syncRenderUids",n,{render:o,hide:s,clear:a})}syncPageAuth(n,e,t=!1){let i=!1;if(!e)this.pageAuth.delete(n);else{const o=this.pageAuth.get(n)||new Map;for(const[s,a]of Object.entries(e)){const{render:c,pages:l}=a,u=o.get(s),h=this.isLocalRender?u==null?void 0:u.render:c;if(h){h!==(u==null?void 0:u.render)&&(i=!0);const g=new Map;for(const[d,M]of Object.entries(l))g.set(d,new Set(Object.keys(M)));const y={render:h,pages:g};g.size&&o.set(s,y)}}o.size&&(this.pageAuth.set(n,o),this.publicMsgEmitter.emit("syncPageAuth",n,o))}(t||i)&&this.pageAuthEffect(n)}destoryByViewId(n,e=!1){var t;this.renderUids.has(n)&&(this.renderUids.delete(n),e||(t=this.control.collector)==null||t.dispatchRenderAuth({operation:Ze.setAuth,viewId:n})),this.pageAuth.has(n)&&this.control.renderControl.delViewPage(n,!e)}renderEffect(n){var t;const e=(t=this.control.viewContainerManager.getView(n))==null?void 0:t.focusScenePath;e&&this.worker.clearViewScenePath(n,!0).then(()=>{var i;this.worker.pullServiceData(n,e,{isAsync:!0,useAnimation:!1}),this.worker.sendClearUids(n,(i=this.renderUids.get(n))==null?void 0:i.clear)})}pageAuthEffect(n){var t;const e=(t=this.control.viewContainerManager.getView(n))==null?void 0:t.focusScenePath;e&&this.worker.clearViewScenePath(n,!0).then(()=>{this.worker.pullServiceData(n,e,{isAsync:!0,useAnimation:!1}),this.worker.sendClearUids(n,!0)})}cloneElementIds(n,e,t,i){var a,c;const o=(a=this.control.collector)==null?void 0:a.getStorageData(n,e),s=new Set;if(o){for(const l of Object.keys(o))if(t.has(l)){const u=`${l}_${i}`;if(s.add(u),!Object.keys(o).includes(u)){const h=j.cloneDeep(o[l]);(c=this.control.collector)==null||c.updateValue(u,{type:$.FullWork,...h,workId:u},{isSync:!0,viewId:n,scenePath:e})}}}return s}delElementIds(n,e,t){var o,s;const i=(o=this.control.collector)==null?void 0:o.getStorageData(n,e);if(i)for(const a of Object.keys(i))t.has(a)&&Object.keys(i).includes(a)&&((s=this.control.collector)==null||s.updateValue(a,void 0,{isSync:!0,viewId:n,scenePath:e}))}}class Hy{constructor(n){I(this,"internalMsgEmitter");I(this,"control");I(this,"maps",new Map);I(this,"showId");I(this,"color");I(this,"timer");I(this,"updateMiniMapCamera",j.debounce(async n=>{const e=this.maps.get(n);if(e){const t=await this.getMiniMapCamera(n);if(t){const i=t.width/t.scale,o=t.height/t.scale,s=e.miniMapCamera.width/e.miniMapCamera.scale,a=e.miniMapCamera.height/e.miniMapCamera.scale;(i>=s||o>=a)&&(e.miniMapCamera=t);const c=e.miniMapCanvas.current;if(c){const l=c.getContext("2d");if(l){const u=this.control.viewContainerManager.getView(n);if(!(u!=null&&u.focusScenePath))return;const{miniMapCamera:h,contianer:g}=e,{width:y,height:d}=g.getBoundingClientRect(),M=Math.min(y/h.width,d/h.height);l.clearRect(0,0,c.width,c.height),c.width=h.width,c.height=h.height,c.style.width=`${h.width*M}px`,c.style.height=`${h.height*M}px`,await this.control.screenshotToCanvas(l,u.focusScenePath,h.width,h.height,h),this.listener.emitAsync([n,"viewCameraUpate"],1)}}}}},2e3,{maxWait:5e3}));var i;const{control:e,internalMsgEmitter:t}=n;this.control=e,this.internalMsgEmitter=t,this.color=((i=this.control.worker.currentToolsData)==null?void 0:i.toolsOpt.strokeColor)||"#000"}get listener(){return this.internalMsgEmitter}get activeViewId(){return this.showId}get highlightColor(){return this.color}setHighlightColor(n){this.color=n}async createMiniMap(n,e,t){const i=this.control.viewContainerManager.getView(n);if(!i)throw new Error("view not found");const o=i.cameraOpt;if(!o)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=f.createRef();this.maps.set(n,{contianer:e,miniMapCanvas:c,miniMapCamera:t,viewCamera:o}),this.showId=n,this.control.viewContainerManager.setActiveMiniMap(this.showId,!0);const l=Math.min(s/t.width,a/t.height),u=await new Promise(h=>{this.listener.once([n,"miniMapCreate"],()=>{const g=c.current;g&&(g.width=t.width,g.height=t.height,g.style.width=`${t.width*l}px`,g.style.height=`${t.height*l}px`),h(!0)}),this.timer=setTimeout(()=>{h(!1)},2e3)});return this.timer&&clearTimeout(this.timer),u}async getMiniMapCamera(n){const e=this.control.viewContainerManager.getView(n);if(!e)return;const{cameraOpt:t,focusScenePath:i}=e;if(!t||!i)return;const o={originX:t.centerX-t.width/t.scale/2,originY:t.centerY-t.height/t.scale/2,width:t.width/t.scale,height:t.height/t.scale};let s=await this.control.getBoundingRect(i)||o;s=mi(s,o)||o;let a=s.width,c=s.height,l=1;const u=a>t.width&&Math.min(t.width/a,l)||l,h=c>t.height&&Math.min(t.height/c,l)||l;return u<=h?(a=u<1&&t.width||a,c=Math.floor(c*u)+1,l=u):u>h&&(c=h<1&&t.height||c,a=Math.floor(a*h)+1,l=h),{scale:l,centerX:s.originX+s.width/2,centerY:s.originY+s.height/2,width:a,height:c}}getMiniMapCanvas(n){const e=this.maps.get(n);return(e==null?void 0:e.miniMapCanvas.current)||null}updateViewCamera(n,e){const t=this.maps.get(n);t&&(t.viewCamera=e,this.listener.emitAsync([n,"viewCameraUpate"],1))}destroyMiniMap(n){const e=n||this.showId;e&&(this.maps.delete(e),this.control.viewContainerManager.setActiveMiniMap(e,!1))}}class qy{constructor(){I(this,"control");I(this,"_listeners",{})}_inject(n){this.control=n}_onEvent(n,e){this._listeners[n]&&this._listeners[n](...e)}callbacks(n,e){this._listeners[n]=e}removeCallback(n){delete this._listeners[n]}}class Jy{constructor(n){I(this,"control");I(this,"worker");I(this,"publicMsgEmitter");I(this,"plugins",new Map);const{control:e,publicMsgEmitter:t}=n;this.control=e,this.publicMsgEmitter=t,this.worker=e.worker}use(n){this.plugins.set(n.kind,n),n._inject(this.control),n.onCreate()}destroy(){this.plugins.forEach(n=>{this.plugins.delete(n.kind),n.onDestroy()})}dispatchPluginEvent(n,...e){this.plugins.forEach(t=>{t._onEvent(n,e)})}}const zn=200;function Ky(r){return r instanceof TouchEvent||r instanceof window.TouchEvent||(r==null?void 0:r.touches)&&(r==null?void 0:r.touches.length)||(r==null?void 0:r.changedTouches)&&(r==null?void 0:r.changedTouches.length)}function Xy(r){return Ky(r)&&(r.touches&&r.touches.length===1||r.changedTouches&&r.changedTouches.length===1)}function gr(r){return r.touches&&r.touches.length?{x:r.touches[0].pageX,y:r.touches[0].pageY}:r.changedTouches&&r.changedTouches.length?{x:r.changedTouches[0].pageX,y:r.changedTouches[0].pageY}:{x:r.pageX,y:r.pageY}}class Si{constructor(n){I(this,"_logger");I(this,"pendingArgsByChannel",new Map);I(this,"flushTimerByChannel",new Map);this._logger=n}emit(n,e){if(this._logger){this._logger[n](...e);return}(n==="info"?console.info:n==="warn"?console.warn:console.error)(...e)}flush(n,e){this.flushTimerByChannel.set(e,null);const t=this.pendingArgsByChannel.get(e)||null;this.pendingArgsByChannel.set(e,null),t&&this.emit(n,t)}debounce(n,e,t,i){this.pendingArgsByChannel.set(e,t);const o=this.flushTimerByChannel.get(e);o!=null&&clearTimeout(o),this.flushTimerByChannel.set(e,setTimeout(()=>this.flush(n,e),i))}error(...n){this.emit("error",n)}info(...n){this.emit("info",n)}warn(...n){this.emit("warn",n)}errorDebounced(n,...e){this.debounce("error",n,e,zn)}infoDebounced(n,...e){this.debounce("info",n,e,zn)}warnDebounced(n,...e){this.debounce("warn",n,e,zn)}destroy(){for(const n of this.flushTimerByChannel.keys()){const e=this.flushTimerByChannel.get(n);e!=null&&clearTimeout(e),this.flushTimerByChannel.set(n,null),this.pendingArgsByChannel.set(n,null)}}}const _y=new Set([S.Image,S.BackgroundSVG]),uo={"shape.vertices":new Set([S.Polygon,S.Star]),"shape.innerVerticeStep":new Set([S.Star]),"shape.innerRatio":new Set([S.Star]),"shape.placement":new Set([S.SpeechBalloon])},em=new Set(["fontColor","fontBgColor","fontSize","bold","italic","underline","lineThrough"]),tm=new Set(["strokeColor","thickness","strokeType"]),nm=new Set(["fillColor"]),im=new Set(["zIndexLayer"]),om=new Set([S.Pencil,S.LaserPen,S.Arrow,S.Straight]),ho=new Set([S.Rectangle,S.Ellipse,S.Triangle,S.Rhombus,S.Polygon,S.Star,S.SpeechBalloon]),rm=new Set([S.Pencil]),sm=new Set([S.LaserPen,S.Arrow,S.Straight,S.Rectangle,S.Ellipse,S.Star,S.Polygon,S.SpeechBalloon]);function fr(r){return r===ce.Normal||r===ce.Stroke||r===ce.Dotted||r===ce.LongDotted}function jt(r,n){return r?im.has(n)?!0:n==="isLocked"?_y.has(r):em.has(n)?r===S.Text:n in uo?uo[n].has(r):nm.has(n)?ho.has(r):tm.has(n)?om.has(r)||ho.has(r):!1:!1}function go(r){return["strokeColor","fillColor","thickness","strokeType","fontColor","fontBgColor","fontSize","bold","italic","underline","lineThrough","isLocked","zIndexLayer","shape.vertices","shape.innerVerticeStep","shape.innerRatio","shape.placement"].filter(e=>jt(r,e))}function mt(r){var e,t,i,o;const n=[];return r.strokeColor!==void 0&&n.push("strokeColor"),r.fillColor!==void 0&&n.push("fillColor"),r.thickness!==void 0&&n.push("thickness"),r.strokeType!==void 0&&n.push("strokeType"),r.fontColor!==void 0&&n.push("fontColor"),r.fontBgColor!==void 0&&n.push("fontBgColor"),r.fontSize!==void 0&&n.push("fontSize"),r.bold!==void 0&&n.push("bold"),r.italic!==void 0&&n.push("italic"),r.underline!==void 0&&n.push("underline"),r.lineThrough!==void 0&&n.push("lineThrough"),r.isLocked!==void 0&&n.push("isLocked"),r.zIndexLayer!==void 0&&n.push("zIndexLayer"),((e=r.shape)==null?void 0:e.vertices)!==void 0&&n.push("shape.vertices"),((t=r.shape)==null?void 0:t.innerVerticeStep)!==void 0&&n.push("shape.innerVerticeStep"),((i=r.shape)==null?void 0:i.innerRatio)!==void 0&&n.push("shape.innerRatio"),((o=r.shape)==null?void 0:o.placement)!==void 0&&n.push("shape.placement"),n}function fo(r,n){return!r||n===void 0||!jt(r,"strokeType")?!1:rm.has(r)?fr(n):sm.has(r)?n===ce.Normal||n===ce.Dotted||n===ce.LongDotted:!1}const J="[Appliance]: [selector]",po=600,am=["bold","normal"],cm=["italic","normal"],lm=["top","left","right","bottom","topLeft","topRight","bottomLeft","bottomRight","leftTop","leftBottom","rightTop","rightBottom"];class um{constructor(n){I(this,"control");I(this,"logger");I(this,"lastSelectedIdsByView",new Map);I(this,"lastViewRectByView",new Map);I(this,"updateResolveMap",new Map);I(this,"clearResolveMap",new Map);I(this,"copyResolveMap",new Map);I(this,"deleteResolveMap",new Map);I(this,"lastRemoteSelectorByView",new Map);I(this,"cameraEmitThrottleByView",new Map);I(this,"pendingCameraChangeByView",new Map);I(this,"pendingPropertyGeometryByKey",new Map);I(this,"publicStorageHandler");I(this,"onUndoAckApplied",n=>{var a,c;const{viewId:e,scenePath:t,requestId:i,emitEventType:o}=n;if(!i)return;const s=this.copyResolveMap.get(i);!s||s.viewId!==e||o===U.CopyNode&&(this.copyResolveMap.delete(i),s.timer&&clearTimeout(s.timer),(c=(a=this.logger)==null?void 0:a.info)==null||c.call(a,`${J} copySelectedElements done requestId=${i} viewId=${e} scenePath=${t} sourceCount=${s.sourceSelectedIds.length}`),s.resolve({ok:!0,requestId:i,sourceSelectedIds:s.sourceSelectedIds,createdIds:[]}))});this.control=n,this.logger=n.logger,this.bindPublicStorageListener(),this.control.internalMsgEmitter.on("undoAckApplied",this.onUndoAckApplied)}stringifyLogValue(n){try{const e=JSON.stringify(n);return e?e.length>po?`${e.slice(0,po)}...`:e:String(n)}catch{return"[unserializable]"}}formatFieldsFromChanges(n){return mt(n).join("/")||"-"}formatMethods(n){return[...n].join("/")||"-"}hasShapeChanges(n){var e,t,i,o;return((e=n.shape)==null?void 0:e.vertices)!==void 0||((t=n.shape)==null?void 0:t.innerVerticeStep)!==void 0||((i=n.shape)==null?void 0:i.innerRatio)!==void 0||((o=n.shape)==null?void 0:o.placement)!==void 0}resolveShapeDispatchToolsTypes(n,e,t,i){if(!this.hasShapeChanges(i))return[];const o=mt(i).filter(a=>a.startsWith("shape.")),s=[];return t.forEach(a=>{const c=this.lookupToolsType(n,e,a);c&&(!i.toolsType||c===i.toolsType)&&o.some(l=>jt(c,l))&&!s.includes(c)&&s.push(c)}),s}getStorageShapeSnapshot(n,e,t){var s,a,c,l;const i=(l=(c=(a=(s=this.control.collector)==null?void 0:s.storage)==null?void 0:a[n])==null?void 0:c[e||""])==null?void 0:l[t],o=i==null?void 0:i.opt;if(o)return{vertices:o.vertices,innerVerticeStep:o.innerVerticeStep,innerRatio:o.innerRatio,placement:o.placement}}cancelUndoTicker(n,e,t){var o,s,a;if(!n)return;const i=t||((o=this.control.viewContainerManager)==null?void 0:o.getCurScenePath(e));i&&((a=(s=this.control.worker)==null?void 0:s.internalMsgEmitter)==null||a.emit("cancelUndoTicker",n,e,i))}resolveCancelableUndoTickerId(n,e){var t,i;return n??((i=(t=this.control.viewContainerManager)==null?void 0:t.getUndoTickerId)==null?void 0:i.call(t,e))}captureUndoTickerDuringDispatch(n){var i,o;let e;const t=(s,a)=>{a===n&&e===void 0&&(e=s)};return(o=(i=this.control.internalMsgEmitter)==null?void 0:i.on)==null||o.call(i,"addUndoTicker",t),{getUndoTickerId:()=>e,dispose:()=>{var s,a;(a=(s=this.control.internalMsgEmitter)==null?void 0:s.off)==null||a.call(s,"addUndoTicker",t)}}}destroy(){for(const[,n]of this.updateResolveMap)n.timer&&clearTimeout(n.timer),n.resolve({requestId:"",ok:!1,viewId:n.viewId,reason:"busy",selectedIds:n.selectedIds,skippedIds:n.skippedIds.length?n.skippedIds:void 0,warnings:n.warnings.length?n.warnings:void 0,geometryChanged:n.geometryChanged});this.updateResolveMap.clear();for(const[,n]of this.clearResolveMap)n.timer&&clearTimeout(n.timer),n.resolve({ok:!1,requestId:"",reason:"busy"});this.clearResolveMap.clear();for(const[,n]of this.copyResolveMap)n.timer&&clearTimeout(n.timer),n.resolve({ok:!1,requestId:"",reason:"busy"});this.copyResolveMap.clear();for(const[,n]of this.deleteResolveMap)n.timer&&clearTimeout(n.timer),n.resolve({ok:!1,requestId:"",reason:"busy"});this.deleteResolveMap.clear();for(const[,n]of this.pendingPropertyGeometryByKey)n.timer&&clearTimeout(n.timer);this.pendingPropertyGeometryByKey.clear(),this.control.internalMsgEmitter.off("undoAckApplied",this.onUndoAckApplied),this.unbindPublicStorageListener()}resolveViewId(n){const e=this.control.viewContainerManager;return n||(e==null?void 0:e.focuedViewId)||re}getSelectedElements(n){var u,h,g;const e=this.resolveViewId(n);if(!e)return;const t=this.control.viewContainerManager,i=t==null?void 0:t.getView(e);if(!i)return;const o=(g=(h=(u=i.displayer)==null?void 0:u.vDom)==null?void 0:h.state)==null?void 0:g.floatBarData,s=(o==null?void 0:o.selectIds)??[],a=o&&j.isNumber(o.x)&&j.isNumber(o.y)&&j.isNumber(o.w)&&j.isNumber(o.h)?{x:o.x,y:o.y,w:o.w,h:o.h}:void 0,c=i.focusScenePath,l=[];for(const y of s){const d=this.buildSelectedElementInfo(e,c,y,o);d&&l.push(d)}return{viewId:e,scenePath:c,viewRect:a,selectedIds:s,selectedElements:l}}isElementPropertySupported(n,e){return jt(n,e)}async blurSelector(n){var c,l,u,h,g,y,d,M,w;const e=this.genRequestId("clear"),t=this.resolveViewId(n);if(!t)return(l=(c=this.logger)==null?void 0:c.warn)==null||l.call(c,`${J} blurSelector rejected: no-view requestId=${e}`),{ok:!1,requestId:e,reason:"no-selection"};const i=this.getSelectedElements(t),o=(i==null?void 0:i.selectedIds)??[];if(!o.length)return(h=(u=this.logger)==null?void 0:u.warn)==null||h.call(u,`${J} blurSelector rejected: no-selection requestId=${e} viewId=${t}`),{ok:!1,requestId:e,reason:"no-selection"};const s=this.detectSelectorTransforming(t);if(s)return(y=(g=this.logger)==null?void 0:g.warn)==null||y.call(g,`${J} blurSelector rejected: ${s} requestId=${e} viewId=${t}`),{ok:!1,requestId:e,reason:s};(M=(d=this.logger)==null?void 0:d.info)==null||M.call(d,`${J} blurSelector request requestId=${e} viewId=${t} selectedCount=${o.length}`);const a=(i==null?void 0:i.scenePath)||((w=this.control.viewContainerManager)==null?void 0:w.getCurScenePath(t));return new Promise(m=>{var T,v,C;const p=setTimeout(()=>{var N,k;this.clearResolveMap.has(e)&&(this.clearResolveMap.delete(e),(k=(N=this.logger)==null?void 0:N.warn)==null||k.call(N,`${J} blurSelector timeout requestId=${e} viewId=${t}`),m({ok:!1,requestId:e,reason:"busy"}))},5e3);this.clearResolveMap.set(e,{timer:p,resolve:m,viewId:t});try{(T=this.control.worker)==null||T.blurSelector(t,a||"",Q)}catch(N){this.clearResolveMap.delete(e),clearTimeout(p),(C=(v=this.logger)==null?void 0:v.error)==null||C.call(v,`${J} blurSelector failed requestId=${e} viewId=${t} err=${N==null?void 0:N.message}`),m({ok:!1,requestId:e,reason:"busy"})}})}async updateSelectedElements(n,e){var m,p,T,v,C,N,k,P,A,x,E,b,O,Y;const t=this.genRequestId("update"),i=this.resolveViewId(n),o=e||{};if(!i)return(p=(m=this.logger)==null?void 0:m.warn)==null||p.call(m,`${J} updateSelectedElements rejected: no-view requestId=${t}`),{requestId:t,viewId:"",ok:!1,reason:"no-selection"};const s=this.getSelectedElements(i),a=(s==null?void 0:s.selectedIds)??[];if(!a.length)return(v=(T=this.logger)==null?void 0:T.warn)==null||v.call(T,`${J} updateSelectedElements rejected: no-selection requestId=${t} viewId=${i}`),{requestId:t,viewId:i,ok:!1,reason:"no-selection",selectedIds:a};const c=this.detectSelectorTransforming(i);if(c)return(N=(C=this.logger)==null?void 0:C.warn)==null||N.call(C,`${J} updateSelectedElements rejected: ${c} requestId=${t} viewId=${i}`),{requestId:t,viewId:i,ok:!1,reason:c,selectedIds:a};if(!Object.keys(o).some(R=>o[R]!==void 0))return(P=(k=this.logger)==null?void 0:k.warn)==null||P.call(k,`${J} updateSelectedElements rejected: unsupported-change requestId=${t} viewId=${i}`),{requestId:t,viewId:i,ok:!1,reason:"unsupported-change",selectedIds:a};const u=[],h=[],g=[];let y={...o};console.log(`${J} updateSelectedElements validate-start requestId=${t} viewId=${i} scenePath=${(s==null?void 0:s.scenePath)||"-"} selectedIds=[${a.join(",")}] requestedFields=[${this.formatFieldsFromChanges(o)}] changes=${this.stringifyLogValue(o)}`);for(const R of a){const W=this.lookupToolsType(i,s==null?void 0:s.scenePath,R);if(!W){h.push(R),console.log(`${J} updateSelectedElements validate-id requestId=${t} id=${R} toolsType=- result=skip-no-toolsType`);continue}const B=this.validateStrokeTypeForChanges(R,y,W,u);B.strokeType!==y.strokeType&&(y=B),console.log(`${J} updateSelectedElements validate-id requestId=${t} id=${R} toolsType=${W} supportedFields=[${go(W).join("/")}] requestedFields=[${this.formatFieldsFromChanges(y)}]`)}if(y.strokeType!==void 0){const R=a.map(B=>this.lookupToolsType(i,s==null?void 0:s.scenePath,B)).filter(B=>!!B&&jt(B,"strokeType"));R.length>0?y.strokeType===ce.Stroke&&(R.every(H=>H===S.Pencil)||(delete y.strokeType,u.push({id:a.join(","),field:"strokeType",code:"unsupported-by-toolsType",message:"strokeType=Stroke requires all strokeType-capable selected elements to be Pencil"}))):delete y.strokeType}const d=this.collectPendingMethods(y);if(console.log(`${J} updateSelectedElements validate-result requestId=${t} fields=[${this.formatFieldsFromChanges(y)}] pendingMethods=[${this.formatMethods(d)}] warnings=${u.length} skipped=[${h.join(",")}]`),!d.size)return this.flushUpdateSelectedElementsWarnings(i,t,u),(x=(A=this.logger)==null?void 0:A.warn)==null||x.call(A,`${J} updateSelectedElements no-valid-fields requestId=${t} viewId=${i} warnings=${u.length}`),{requestId:t,viewId:i,ok:!1,reason:"unsupported-change",selectedIds:a,skippedIds:h.length?h:void 0,warnings:u.length?u:void 0};const M=mt(y);for(const R of a){const W=this.lookupToolsType(i,s==null?void 0:s.scenePath,R),B=this.hasShapeChanges(y)&&!!y.toolsType&&W!==y.toolsType;this.hasApplicableChangesForToolsType(y,W)?(g.push(R),console.log(`${J} updateSelectedElements apply-target requestId=${t} id=${R} toolsType=${W||"-"} result=apply`)):h.includes(R)||(h.push(R),console.log(`${J} updateSelectedElements apply-target requestId=${t} id=${R} toolsType=${W||"-"} result=${B?"skip-shape-toolsType-mismatch":"skip-unsupported"} requestedFields=[${M.join("/")}] requestedToolsType=${y.toolsType||"-"}`),W&&M.length&&u.push({id:R,field:M.join(","),code:"unsupported-by-toolsType",toolsType:W,message:B?`selected element id=${R} toolsType=${W} skipped by requested toolsType=${y.toolsType}`:`selected element id=${R} toolsType=${W} does not support requested fields=[${M.join(",")}]`}))}const w=this.resolveShapeDispatchToolsTypes(i,s==null?void 0:s.scenePath,g,y);return g.length?((Y=(O=this.logger)==null?void 0:O.info)==null||Y.call(O,`${J} updateSelectedElements request requestId=${t} viewId=${i} scenePath=${(s==null?void 0:s.scenePath)||"-"} selectedCount=${a.length} fields=[${this.formatFieldsFromChanges(o)}]`),this.flushUpdateSelectedElementsWarnings(i,t,u),new Promise(R=>{var H,Z;const W=setTimeout(()=>{var X,ye;const F=this.updateResolveMap.get(t);F&&(this.updateResolveMap.delete(t),(ye=(X=this.logger)==null?void 0:X.warn)==null||ye.call(X,`${J} updateSelectedElements timeout requestId=${t} viewId=${i}`),R({requestId:t,viewId:i,ok:!1,reason:"worker-failed",selectedIds:F.selectedIds,skippedIds:F.skippedIds.length?F.skippedIds:void 0,warnings:F.warnings.length?F.warnings:void 0,geometryChanged:F.geometryChanged}))},8e3);this.updateResolveMap.set(t,{timer:W,resolve:R,viewId:i,selectedIds:a,appliedIds:g,skippedIds:h,warnings:u,geometryChanged:!1});const B=this.captureUndoTickerDuringDispatch(i);try{console.log(`${J} updateSelectedElements dispatch requestId=${t} viewId=${i} workIds=[${Q}] toolsType=${S.Selector} shapeToolsTypes=[${w.join(",")||"-"}] fields=[${this.formatFieldsFromChanges(y)}] changes=${this.stringifyLogValue(y)}`),this.dispatchUpdate(i,[Q],y,S.Selector,t,w)}catch(F){this.updateResolveMap.delete(t),clearTimeout(W),this.cancelUndoTicker(this.resolveCancelableUndoTickerId(B.getUndoTickerId(),i),i,s==null?void 0:s.scenePath),(Z=(H=this.logger)==null?void 0:H.error)==null||Z.call(H,`${J} updateSelectedElements dispatch failed requestId=${t} viewId=${i} err=${F==null?void 0:F.message}`),R({requestId:t,viewId:i,ok:!1,reason:"worker-failed",selectedIds:a,skippedIds:h.length?h:void 0,warnings:u.length?u:void 0})}finally{B.dispose()}})):(this.flushUpdateSelectedElementsWarnings(i,t,u),(b=(E=this.logger)==null?void 0:E.warn)==null||b.call(E,`${J} updateSelectedElements rejected: no-applicable-selection requestId=${t} viewId=${i}`),{requestId:t,viewId:i,ok:!1,reason:"unsupported-change",selectedIds:a,skippedIds:h.length?h:void 0,warnings:u.length?u:void 0})}async copySelectedElements(n){var a,c,l,u,h,g,y,d;const e=this.genRequestId("copy"),t=this.resolveViewId(n);if(!t)return(c=(a=this.logger)==null?void 0:a.warn)==null||c.call(a,`${J} copySelectedElements rejected: no-view requestId=${e}`),{ok:!1,requestId:e,reason:"no-selection"};const i=this.getSelectedElements(t),o=(i==null?void 0:i.selectedIds)??[];if(!o.length)return(u=(l=this.logger)==null?void 0:l.warn)==null||u.call(l,`${J} copySelectedElements rejected: no-selection requestId=${e} viewId=${t}`),{ok:!1,requestId:e,reason:"no-selection"};const s=this.detectSelectorTransforming(t);return s?((g=(h=this.logger)==null?void 0:h.warn)==null||g.call(h,`${J} copySelectedElements rejected: ${s} requestId=${e} viewId=${t}`),{ok:!1,requestId:e,reason:s}):((d=(y=this.logger)==null?void 0:y.info)==null||d.call(y,`${J} copySelectedElements request requestId=${e} viewId=${t} scenePath=${(i==null?void 0:i.scenePath)||"-"} selectedCount=${o.length}`),new Promise(M=>{var p,T;const w=setTimeout(()=>{var v,C;this.copyResolveMap.has(e)&&(this.copyResolveMap.delete(e),(C=(v=this.logger)==null?void 0:v.warn)==null||C.call(v,`${J} copySelectedElements timeout requestId=${e} viewId=${t}`),M({ok:!1,requestId:e,reason:"busy"}))},5e3);this.copyResolveMap.set(e,{timer:w,resolve:M,viewId:t,sourceSelectedIds:o});const m=this.captureUndoTickerDuringDispatch(t);try{te.emitMethod(ne.MainEngine,U.CopyNode,{workIds:[Q],viewId:t,requestId:e})}catch(v){this.copyResolveMap.delete(e),clearTimeout(w),this.cancelUndoTicker(this.resolveCancelableUndoTickerId(m.getUndoTickerId(),t),t,i==null?void 0:i.scenePath),(T=(p=this.logger)==null?void 0:p.error)==null||T.call(p,`${J} copySelectedElements failed requestId=${e} viewId=${t} err=${v==null?void 0:v.message}`),M({ok:!1,requestId:e,reason:"busy"})}finally{m.dispose()}}))}async deleteSelectedElements(n){var a,c,l,u,h,g,y,d;const e=this.genRequestId("delete"),t=this.resolveViewId(n);if(!t)return(c=(a=this.logger)==null?void 0:a.warn)==null||c.call(a,`${J} deleteSelectedElements rejected: no-view requestId=${e}`),{ok:!1,requestId:e,reason:"no-selection"};const i=this.getSelectedElements(t),o=(i==null?void 0:i.selectedIds)??[];if(!o.length)return(u=(l=this.logger)==null?void 0:l.warn)==null||u.call(l,`${J} deleteSelectedElements rejected: no-selection requestId=${e} viewId=${t}`),{ok:!1,requestId:e,reason:"no-selection"};const s=this.detectSelectorTransforming(t);return s?((g=(h=this.logger)==null?void 0:h.warn)==null||g.call(h,`${J} deleteSelectedElements rejected: ${s} requestId=${e} viewId=${t}`),{ok:!1,requestId:e,reason:s}):((d=(y=this.logger)==null?void 0:y.info)==null||d.call(y,`${J} deleteSelectedElements request requestId=${e} viewId=${t} scenePath=${(i==null?void 0:i.scenePath)||"-"} selectedCount=${o.length}`),new Promise(M=>{var p,T;const w=setTimeout(()=>{var v,C;this.deleteResolveMap.has(e)&&(this.deleteResolveMap.delete(e),(C=(v=this.logger)==null?void 0:v.warn)==null||C.call(v,`${J} deleteSelectedElements timeout requestId=${e} viewId=${t}`),M({ok:!1,requestId:e,reason:"busy"}))},5e3);this.deleteResolveMap.set(e,{timer:w,resolve:M,viewId:t,removedIds:o.slice()});const m=this.captureUndoTickerDuringDispatch(t);try{te.emitMethod(ne.MainEngine,U.DeleteNode,{workIds:[Q],viewId:t,requestId:e})}catch(v){this.deleteResolveMap.delete(e),clearTimeout(w),this.cancelUndoTicker(this.resolveCancelableUndoTickerId(m.getUndoTickerId(),t),t,i==null?void 0:i.scenePath),(T=(p=this.logger)==null?void 0:p.error)==null||T.call(p,`${J} deleteSelectedElements failed requestId=${e} viewId=${t} err=${v==null?void 0:v.message}`),M({ok:!1,requestId:e,reason:"busy"})}finally{m.dispose()}}))}async updateElement(n,e,t,i,o=!0){var w,m,p,T,v,C,N,k,P,A,x,E,b;const s=this.control.collector,a=this.control.worker;if(!s||!a||!n||!e||!t||!i)return(m=(w=this.logger)==null?void 0:w.warn)==null||m.call(w,`${J} updateElement ignored: invalid-args viewId=${t||"-"} scenePath=${e||"-"} elementId=${n||"-"}`),!1;const c=(p=s.isLocalId)!=null&&p.call(s,n)&&typeof s.transformKey=="function"?s.transformKey(n):n;if(console.log(`${J} updateElement request viewId=${t} scenePath=${e} elementId=${n} storageKey=${c} useUndoRedoStack=${o} fields=[${mt(i).join("/")||"-"}] info=${this.stringifyLogValue(i)}`),(T=s.isSelector)!=null&&T.call(s,c))return(C=(v=this.logger)==null?void 0:v.warn)==null||C.call(v,`${J} updateElement ignored: selector-not-allowed viewId=${t} scenePath=${e}`),!1;let l=(P=(k=(N=s.storage)==null?void 0:N[t])==null?void 0:k[e])==null?void 0:P[c];if(!l)return(x=(A=this.logger)==null?void 0:A.warn)==null||x.call(A,`${J} updateElement ignored: not-found viewId=${t} scenePath=${e} elementId=${n}`),!1;const u=l.toolsType;if(!u||i.toolsType!==u)return(b=(E=this.logger)==null?void 0:E.warn)==null||b.call(E,`${J} updateElement ignored: toolsType-mismatch viewId=${t} scenePath=${e} elementId=${n} declared=${i.toolsType} actual=${u}`),!1;const h=this.normalizeUpdateElementInfo(i,u);console.log(`${J} updateElement normalized viewId=${t} scenePath=${e} elementId=${n} toolsType=${u} fields=[${mt(h).join("/")||"-"}] info=${this.stringifyLogValue(h)}`);const g=this.getStorageShapeSnapshot(t,e,c),y=this.buildUpdatedElementValue(l,h),d=y.opt||{};console.log(`${J} updateElement build-value viewId=${t} scenePath=${e} elementId=${n} storageKey=${c} beforeShape=${this.stringifyLogValue(g)} afterShape=${this.stringifyLogValue({vertices:d.vertices,innerVerticeStep:d.innerVerticeStep,innerRatio:d.innerRatio,placement:d.placement})}`);const M=a.now;return o&&(console.log(`${J} updateElement undo-start viewId=${t} scenePath=${e} elementId=${n} storageKey=${c} undoTickerId=${M}`),a.internalMsgEmitter.emit("addUndoTicker",M,t,{render:!0,storage:!0}),a.internalMsgEmitter.emit("finalizeRequested",M,t,[c],e)),await new Promise(O=>{He(()=>{var R,W;const Y=s.plugin;console.log(`${J} updateElement updateAttributes viewId=${t} scenePath=${e} elementId=${n} path=[${[_e.namespace,t,e,c].join("/")}]`),Y==null||Y.updateAttributes([_e.namespace,t,e,c],y),o&&(a.internalMsgEmitter.emit("ackRenderUndoTicker",M,t,e),a.internalMsgEmitter.emit("ackStorageUndoTicker",M,t,e,c)),O(!0),(W=(R=this.logger)==null?void 0:R.info)==null||W.call(R,`${J} updateElement notify viewId=${t} scenePath=${e} elementId=${n} toolsType=${u} fields=[${mt(h).join("/")||"-"}]`)},0,this.control.hasPolyfillMethod("requestIdleCallback")).catch(Y=>{var R,W;this.cancelUndoTicker(M,t,e),(W=(R=this.logger)==null?void 0:R.warn)==null||W.call(R,`${J} updateElement err: ${Y.message??"has unknown error"} viewId=${t} scenePath=${e} elementId=${n}`),O(!1)})})}onSelectorTransform(n){var a,c;const{viewId:e,emitEventType:t,workState:i}=n;this.control.publicMsgEmitter.emit("selectorTransformChange",n);const o=`${J} selectorTransformChange viewId=${e} emitEventType=${t} workState=${i}`,s=this.getDebounceLogger();s!=null&&s.infoDebounced?s.infoDebounced(`selector-transform-change:${e}`,o):(c=(a=this.logger)==null?void 0:a.info)==null||c.call(a,o)}onSelectorSync(n){var M,w,m,p;const{viewId:e,scenePath:t,selectIds:i,selectRect:o,selectorInfo:s}=n,a=i&&i.slice().sort()||[],c=this.lastSelectedIdsByView.get(e)||[],l=!this.isArrayEqual(a,c),u=o&&j.isNumber(o.x)&&j.isNumber(o.y)&&j.isNumber(o.w)&&j.isNumber(o.h)?{x:o.x,y:o.y,w:o.w,h:o.h}:void 0,g=!!this.pendingCameraChangeByView.get(e)&&!l&&!!(i!=null&&i.length);if(l){const T=this.getSelectedElements(e),v={viewId:e,scenePath:t,selectorId:Q,reason:i!=null&&i.length?"select":"clear",viewRect:u,selectedIds:(T==null?void 0:T.selectedIds)??i??[],selectorInfo:s};this.lastSelectedIdsByView.set(e,a),this.control.publicMsgEmitter.emit("selectedElementsChange",v);const C=`${J} selectedElementsChange reason=${v.reason} viewId=${e} count=${v.selectedIds.length}`,N=this.getDebounceLogger();N!=null&&N.infoDebounced?N.infoDebounced(`selected-elements-change:${e}`,C):(w=(M=this.logger)==null?void 0:M.info)==null||w.call(M,C)}const y=this.lastViewRectByView.get(e),d=!this.isRectEqual(y,u);if(d||l){let T="selector-action",v=i!=null&&i.length?"select":"clear";g&&d?(T="camera-change",v="cameraTransform"):d&&!l&&(i!=null&&i.length)&&(v="selectorTransform"),this.lastViewRectByView.set(e,u);const C={viewId:e,scenePath:t,selectorId:Q,source:T,action:v,viewRect:u};this.control.publicMsgEmitter.emit("selectorGeometryChange",C),this.logGeometry(e,v,(i==null?void 0:i.length)||0),T==="camera-change"&&this.clearPendingCameraChange(e)}if(!(i!=null&&i.length)&&l)for(const[T,v]of this.clearResolveMap.entries())v.viewId===e&&(this.clearResolveMap.delete(T),v.timer&&clearTimeout(v.timer),(p=(m=this.logger)==null?void 0:m.info)==null||p.call(m,`${J} blurSelector done requestId=${T} viewId=${e}`),v.resolve({ok:!0,requestId:T}))}onSelectorCleared(n){var a,c,l,u;const{viewId:e,scenePath:t,requestId:i}=n;if((this.lastSelectedIdsByView.get(e)||[]).length){const h={viewId:e,scenePath:t,selectorId:Q,reason:"clear",viewRect:void 0,selectedIds:[]};this.lastSelectedIdsByView.set(e,[]),this.control.publicMsgEmitter.emit("selectedElementsChange",h);const g=`${J} selectedElementsChange reason=clear viewId=${e} requestId=${i||"-"}`,y=this.logger;y!=null&&y.infoDebounced?y.infoDebounced(`selected-elements-change:${e}`,g):(c=(a=this.logger)==null?void 0:a.info)==null||c.call(a,g)}if(this.lastViewRectByView.get(e)){const h={viewId:e,scenePath:t,selectorId:Q,source:"selector-action",action:"clear",viewRect:void 0,requestId:i};this.lastViewRectByView.set(e,void 0),this.control.publicMsgEmitter.emit("selectorGeometryChange",h),this.logGeometry(e,"clear",0)}if(i&&this.clearResolveMap.has(i)){const h=this.clearResolveMap.get(i);this.clearResolveMap.delete(i),h.timer&&clearTimeout(h.timer),(u=(l=this.logger)==null?void 0:l.info)==null||u.call(l,`${J} blurSelector done requestId=${i} viewId=${e}`),h.resolve({ok:!0,requestId:i})}}onCameraChange(n){const e=this.getSelectedElements(n);if(!(e!=null&&e.selectedIds.length)){this.clearPendingCameraChange(n);return}this.setPendingCameraChange(n,{ts:Date.now(),viewRect:e.viewRect,selectedIds:e.selectedIds.slice()});let t=this.cameraEmitThrottleByView.get(n);t||(t=j.throttle(i=>this.emitCameraGeometry(i),60,{leading:!0,trailing:!0}),this.cameraEmitThrottleByView.set(n,t)),t(n)}emitCameraGeometry(n){const e=this.getSelectedElements(n);if(!e||!e.selectedIds.length||!e.viewRect){this.clearPendingCameraChange(n);return}const t=this.lastViewRectByView.get(n);if(this.isRectEqual(t,e.viewRect))return;this.lastViewRectByView.set(n,e.viewRect);const i={viewId:n,scenePath:e.scenePath,selectorId:Q,source:"camera-change",action:"cameraTransform",viewRect:e.viewRect};this.control.publicMsgEmitter.emit("selectorGeometryChange",i),this.logGeometry(n,"cameraTransform",e.selectedIds.length),this.clearPendingCameraChange(n)}bindPublicStorageListener(){this.publicStorageHandler||(this.publicStorageHandler=n=>this.onSyncStorageChange(n),this.control.publicMsgEmitter.on("syncStorageChange",this.publicStorageHandler))}unbindPublicStorageListener(){this.publicStorageHandler&&(this.control.publicMsgEmitter.off("syncStorageChange",this.publicStorageHandler),this.publicStorageHandler=void 0)}tryResolveUpdateElements(n,e,t,i){var s,a;if(!e)return;const o=this.updateResolveMap.get(e);!o||o.viewId!==n||(o.geometryChanged=o.geometryChanged||i,this.updateResolveMap.delete(e),o.timer&&clearTimeout(o.timer),(a=(s=this.logger)==null?void 0:s.info)==null||a.call(s,`${J} updateSelectedElements done requestId=${e} viewId=${n} type=${t} geometryChanged=${o.geometryChanged} applied=${o.appliedIds.length}`),o.resolve({requestId:e,viewId:n,ok:!0,selectedIds:o.selectedIds,appliedIds:o.appliedIds,skippedIds:o.skippedIds.length?o.skippedIds:void 0,warnings:o.warnings.length?o.warnings:void 0,geometryChanged:o.geometryChanged}))}onRemoveNodeApplied(n){var o,s;const{viewId:e,requestId:t,removeIds:i}=n;if(t){const a=this.deleteResolveMap.get(t);if(a&&a.viewId===e){const c=i!=null&&i.length?i:a.removedIds;this.deleteResolveMap.delete(t),a.timer&&clearTimeout(a.timer),(s=(o=this.logger)==null?void 0:o.info)==null||s.call(o,`${J} deleteSelectedElements done requestId=${t} viewId=${e} removedCount=${c.length}`),a.resolve({ok:!0,requestId:t,removedIds:c});return}}}onSyncStorageChange(n){var i,o,s;if(!n||typeof n!="object")return;const e=this.control.collector;if(!e)return;const t=e.uid;for(const[a,c]of Object.entries(n)){if(!c)continue;let l=this.lastRemoteSelectorByView.get(a);l||(l=new Map,this.lastRemoteSelectorByView.set(a,l));const u=new Set;for(const[h,g]of Object.entries(c))if(g)for(const[y,d]of Object.entries(g)){if(((i=e.isLocalId)!=null&&i.call(e,y)?y:((o=e.getLocalId)==null?void 0:o.call(e,y))??y)!==Q)continue;const w=((s=e.getUidFromKey)==null?void 0:s.call(e,y))??(y.split(We)[0]||"");!w||w===t||(u.add(w),this.handleRemoteSelectorState(a,h,w,y,d,l))}for(const h of[...l.keys()]){if(u.has(h))continue;const g=l.get(h);if(!g||!g.selectedIds.length){l.delete(h);continue}this.handleRemoteSelectorState(a,"",h,`${h}${We}${Q}`,void 0,l)}}}handleRemoteSelectorState(n,e,t,i,o,s){var d;const a=s.get(t)||{selectedIds:[]};let c="update",l=[],u;if(o){const M=o,w=(M.selectIds||[]).slice().sort(),m=a.selectedIds,p=!this.isArrayEqual(w,m);!m.length&&w.length?c="select":p&&!w.length?c="clear":c=p?"select":"update",l=M.selectIds||[];const T=M.selectRect||M.rect||((d=M.updateNodeOpt)==null?void 0:d.rect);T&&j.isNumber(T.x)&&j.isNumber(T.y)&&j.isNumber(T.w)&&j.isNumber(T.h)&&(u={x:T.x,y:T.y,w:T.w,h:T.h})}else{if(!a.selectedIds.length)return;c="clear",l=[],u=void 0}const h=!this.isRectEqual(a.viewRect,u);if(!!this.isArrayEqual(a.selectedIds,l)&&!h)return;s.set(t,{selectedIds:l,viewRect:u});const y={viewId:n,scenePath:e,uid:t,selectorId:i,source:"sync",action:c,viewRect:u,selectedIds:l,selectedElements:this.buildRemoteSelectedElements(n,e,t,l)};this.control.publicMsgEmitter.emit("remoteSelectorChange",y),this.logRemoteSelector(n,t,c,l.length)}logRemoteSelector(n,e,t,i){var a,c;const o=`${J} remoteSelectorChange uid=${e} action=${t} viewId=${n} count=${i}`,s=this.getDebounceLogger();if(s!=null&&s.infoDebounced){s.infoDebounced(`remote-selector:${n}@${e}`,o);return}(c=(a=this.logger)==null?void 0:a.info)==null||c.call(a,o)}genRequestId(n){return`${n}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}setPendingCameraChange(n,e){this.clearPendingCameraChange(n);const t=setTimeout(()=>{const i=this.pendingCameraChangeByView.get(n);(i==null?void 0:i.ts)===e.ts&&this.pendingCameraChangeByView.delete(n)},400);this.pendingCameraChangeByView.set(n,{...e,timer:t})}clearPendingCameraChange(n){const e=this.pendingCameraChangeByView.get(n);e!=null&&e.timer&&clearTimeout(e.timer),this.pendingCameraChangeByView.delete(n)}getDebounceLogger(){return this.logger}detectSelectorTransforming(n){var l,u,h,g,y;const e=this.control.worker;if(!e)return null;const t=(l=e.getLocalWorkViewId)==null?void 0:l.call(e),i=e.isLocalWorkActive===!0&&t===n,o=(u=e.currentLocalWorkData)==null?void 0:u.workState,s=(y=(g=(h=this.control.viewContainerManager.getView(n))==null?void 0:h.displayer)==null?void 0:g.vDom)==null?void 0:y.state,a=s==null?void 0:s.operationType,c=a===U.TranslateNode||a===U.ScaleNode||a===U.RotateNode||a===U.SetPoint;return i&&c&&o&&o!==D.Pending&&o!==D.Done||i&&c?"selector-transforming":e.isBusy===!0?"busy":null}isArrayEqual(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;return!0}isRectEqual(n,e){return!n&&!e?!0:!n||!e?!1:n.x===e.x&&n.y===e.y&&n.w===e.w&&n.h===e.h}onPropertyApplied(n){const{type:e,viewId:t,requestId:i,data:o}=n;console.log(`${J} property-applied requestId=${i||"-"} viewId=${t} type=${e} data=${this.stringifyLogValue(o)}`);const s=e===U.SetFontStyle&&o.fontSize!==void 0||e===U.SetColorNode&&o.thickness!==void 0;this.tryResolveUpdateElements(t,i,e,s),s&&this.schedulePropertyGeometryEmit(t,e,i)}schedulePropertyGeometryEmit(n,e,t){const i=t?`property-geometry:${n}:${e}:${t}`:`property-geometry:${n}:${e}`,o=this.pendingPropertyGeometryByKey.get(i);o!=null&&o.timer&&clearTimeout(o.timer);const s=setTimeout(()=>{this.pendingPropertyGeometryByKey.delete(i);const a=this.getSelectedElements(n);if(!a||!a.selectedIds.length)return;const c=e===U.SetFontStyle?"setFontStyle":"setStyle",l={viewId:n,scenePath:a.scenePath,selectorId:Q,source:"property-change",action:c,viewRect:a.viewRect,requestId:t};this.lastViewRectByView.set(n,a.viewRect),this.control.publicMsgEmitter.emit("selectorGeometryChange",l),this.logGeometry(n,c,a.selectedIds.length)},0);this.pendingPropertyGeometryByKey.set(i,{timer:s,viewId:n,type:e,requestId:t})}lookupToolsType(n,e,t){var a,c,l,u;const i=this.control.collector;if(!i)return;const o=(a=i.isLocalId)!=null&&a.call(i,t)&&typeof i.transformKey=="function"?i.transformKey(t):t,s=(u=(l=(c=i.storage)==null?void 0:c[n])==null?void 0:l[e||""])==null?void 0:u[o];return s==null?void 0:s.toolsType}validateStrokeTypeForChanges(n,e,t,i){return e.strokeType===void 0?e:fr(e.strokeType)?(fo(t,e.strokeType)||i.push({id:n,field:"strokeType",code:"unsupported-by-toolsType",toolsType:t,message:`strokeType not supported by toolsType=${t} for id=${n}, skipped`}),e):(i.push({id:n,field:"strokeType",code:"unsupported-value",toolsType:t,message:`strokeType=${e.strokeType} is not a valid EStrokeType for id=${n}, skipped`}),e)}flushUpdateSelectedElementsWarnings(n,e,t){var s,a,c,l;if(!t.length)return;const i=new Map,o=new Map;for(const u of t)if(u.code==="unsupported-by-toolsType"){const h=i.get(u.field)||{ids:[],toolsTypes:[]};h.ids.push(u.id),h.toolsTypes.push(u.toolsType),i.set(u.field,h)}else if(u.code==="unsupported-value"){const h=o.get(u.field)||[];h.push(u.id),o.set(u.field,h)}for(const[u,h]of i.entries()){const g=[...new Set(h.toolsTypes.filter(Boolean))].join(","),y=[...new Set(h.ids)].join(",");(a=(s=this.logger)==null?void 0:s.warn)==null||a.call(s,`${J} updateSelectedElements warn unsupported-by-toolsType requestId=${e} viewId=${n} field=${u} toolsTypes=[${g}] ids=[${y}]`)}for(const[u,h]of o.entries())(l=(c=this.logger)==null?void 0:c.warn)==null||l.call(c,`${J} updateSelectedElements warn unsupported-value requestId=${e} viewId=${n} field=${u} ids=[${[...new Set(h)].join(",")}]`)}collectPendingMethods(n){var t,i,o,s;const e=new Set;return(n.strokeColor!==void 0||n.fillColor!==void 0||n.fontColor!==void 0||n.fontBgColor!==void 0||n.thickness!==void 0||n.strokeType!==void 0)&&e.add(U.SetColorNode),(n.fontSize!==void 0||n.bold!==void 0||n.italic!==void 0||n.underline!==void 0||n.lineThrough!==void 0)&&e.add(U.SetFontStyle),n.isLocked!==void 0&&e.add(U.SetLock),n.zIndexLayer!==void 0&&e.add(U.ZIndexNode),(((t=n.shape)==null?void 0:t.vertices)!==void 0||((i=n.shape)==null?void 0:i.innerVerticeStep)!==void 0||((o=n.shape)==null?void 0:o.innerRatio)!==void 0||((s=n.shape)==null?void 0:s.placement)!==void 0)&&e.add(U.SetShapeOpt),e}hasApplicableChangesForToolsType(n,e){return e?mt(n).some(t=>t.startsWith("shape.")&&n.toolsType&&e!==n.toolsType?!1:jt(e,t)):!1}buildUpdatedElementValue(n,e){var s,a,c,l;const t=e,i={...n,opt:n.opt?{...n.opt}:void 0},o=i.opt||{};return t.strokeColor!==void 0&&(o.strokeColor=t.strokeColor),t.fillColor!==void 0&&(o.fillColor=t.fillColor),t.thickness!==void 0&&(o.thickness=t.thickness),t.strokeType!==void 0&&(o.strokeType=t.strokeType),t.fontColor!==void 0&&(o.fontColor=t.fontColor),t.fontBgColor!==void 0&&(o.fontBgColor=t.fontBgColor),t.fontSize!==void 0&&(o.fontSize=t.fontSize),t.bold!==void 0&&(o.bold=t.bold),t.italic!==void 0&&(o.italic=t.italic),t.underline!==void 0&&(o.underline=t.underline),t.lineThrough!==void 0&&(o.lineThrough=t.lineThrough),t.isLocked!==void 0&&(o.locked=t.isLocked),((s=t.shape)==null?void 0:s.vertices)!==void 0&&(o.vertices=t.shape.vertices),((a=t.shape)==null?void 0:a.innerVerticeStep)!==void 0&&(o.innerVerticeStep=t.shape.innerVerticeStep),((c=t.shape)==null?void 0:c.innerRatio)!==void 0&&(o.innerRatio=t.shape.innerRatio),((l=t.shape)==null?void 0:l.placement)!==void 0&&(o.placement=t.shape.placement),i.opt=o,t.zIndexLayer!==void 0&&(i.updateNodeOpt={...i.updateNodeOpt||{},zIndexLayer:t.zIndexLayer}),i}normalizeUpdateElementInfo(n,e){var g,y;const t={...n},i=[],o=d=>{var M,w;d in t&&(delete t[d],i.push(d),(w=(M=this.logger)==null?void 0:M.warn)==null||w.call(M,`${J} updateElement warn unsupported-by-toolsType toolsType=${e} field=${d}`))},s=d=>{var M,w;t.shape&&d in t.shape&&(delete t.shape[d],i.push(`shape.${d}`),(w=(M=this.logger)==null?void 0:M.warn)==null||w.call(M,`${J} updateElement warn unsupported-by-toolsType toolsType=${e} field=shape.${d}`)),t.shape&&!Object.keys(t.shape).length&&delete t.shape},a=d=>{var M,w;d in t&&(i.push(d),(w=(M=this.logger)==null?void 0:M.warn)==null||w.call(M,`${J} updateElement warn invalid-format toolsType=${e} field=${d} value=${JSON.stringify(t[d])}`),delete t[d])},c=d=>{var M,w;!t.shape||!(d in t.shape)||(i.push(`shape.${d}`),(w=(M=this.logger)==null?void 0:M.warn)==null||w.call(M,`${J} updateElement warn invalid-format toolsType=${e} field=shape.${d} value=${JSON.stringify(t.shape[d])}`),delete t.shape[d],Object.keys(t.shape).length||delete t.shape)};"strokeColor"in t&&typeof t.strokeColor!="string"&&a("strokeColor"),"fillColor"in t&&typeof t.fillColor!="string"&&a("fillColor"),"fontColor"in t&&typeof t.fontColor!="string"&&a("fontColor"),"fontBgColor"in t&&typeof t.fontBgColor!="string"&&a("fontBgColor"),"thickness"in t&&!Number.isFinite(t.thickness)&&a("thickness"),"fontSize"in t&&!Number.isFinite(t.fontSize)&&a("fontSize"),"strokeType"in t&&!Object.values(ce).includes(t.strokeType)&&a("strokeType"),"strokeType"in t&&t.strokeType!==void 0&&!fo(e,t.strokeType)&&o("strokeType"),"bold"in t&&!am.includes(t.bold)&&a("bold"),"italic"in t&&!cm.includes(t.italic)&&a("italic"),"underline"in t&&typeof t.underline!="boolean"&&a("underline"),"lineThrough"in t&&typeof t.lineThrough!="boolean"&&a("lineThrough"),"isLocked"in t&&typeof t.isLocked!="boolean"&&a("isLocked"),"zIndexLayer"in t&&![st.Top,st.Bottom].includes(t.zIndexLayer)&&a("zIndexLayer"),t.shape&&("vertices"in t.shape&&!Number.isFinite(t.shape.vertices)&&c("vertices"),"innerVerticeStep"in t.shape&&!Number.isFinite(t.shape.innerVerticeStep)&&c("innerVerticeStep"),"innerRatio"in t.shape&&!Number.isFinite(t.shape.innerRatio)&&c("innerRatio"),"placement"in t.shape&&!lm.includes(t.shape.placement)&&c("placement"));const l=new Set(go(e));return["strokeColor","fillColor","thickness","strokeType","fontColor","fontBgColor","fontSize","bold","italic","underline","lineThrough","isLocked","zIndexLayer"].forEach(d=>{l.has(d)||o(d)}),["vertices","innerVerticeStep","innerRatio","placement"].forEach(d=>{l.has(`shape.${d}`)||s(d)}),i.length&&((y=(g=this.logger)==null?void 0:g.info)==null||y.call(g,`${J} updateElement filtered toolsType=${e} dropped=[${i.join(",")}]`)),t}dispatchUpdate(n,e,t,i,o,s=[]){const a=ne.MainEngine;console.log(`${J} updateSelectedElements dispatch-start requestId=${o||"-"} viewId=${n} workIds=[${e.join(",")}] toolsType=${i||"-"} shapeToolsTypes=[${s.join(",")||"-"}] fields=[${this.formatFieldsFromChanges(t)}]`);const c={};t.strokeColor!==void 0&&(c.strokeColor=t.strokeColor),t.fillColor!==void 0&&(c.fillColor=t.fillColor),t.fontColor!==void 0&&(c.fontColor=t.fontColor),t.fontBgColor!==void 0&&(c.fontBgColor=t.fontBgColor),t.thickness!==void 0&&(c.thickness=t.thickness),t.strokeType!==void 0&&(c.strokeType=t.strokeType),Object.keys(c).length&&(console.log(`${J} updateSelectedElements emit-method requestId=${o||"-"} method=${U.SetColorNode} workIds=[${e.join(",")}] payload=${this.stringifyLogValue(c)}`),te.emitMethod(a,U.SetColorNode,{workIds:e,viewId:n,requestId:o,workState:D.Done,...c}));const l={};if(t.fontSize!==void 0&&(l.fontSize=t.fontSize),t.bold!==void 0&&(l.bold=t.bold),t.italic!==void 0&&(l.italic=t.italic),t.underline!==void 0&&(l.underline=t.underline),t.lineThrough!==void 0&&(l.lineThrough=t.lineThrough),Object.keys(l).length&&(console.log(`${J} updateSelectedElements emit-method requestId=${o||"-"} method=${U.SetFontStyle} workIds=[${e.join(",")}] payload=${this.stringifyLogValue(l)}`),te.emitMethod(a,U.SetFontStyle,{workIds:e,viewId:n,requestId:o,workState:D.Done,...l})),t.isLocked!==void 0&&(console.log(`${J} updateSelectedElements emit-method requestId=${o||"-"} method=${U.SetLock} workIds=[${e.join(",")}] payload=${this.stringifyLogValue({isLocked:t.isLocked})}`),te.emitMethod(a,U.SetLock,{workIds:e,viewId:n,requestId:o,workState:D.Done,isLocked:t.isLocked})),t.zIndexLayer!==void 0&&(console.log(`${J} updateSelectedElements emit-method requestId=${o||"-"} method=${U.ZIndexNode} workIds=[${e.join(",")}] payload=${this.stringifyLogValue({zIndexLayer:t.zIndexLayer})}`),te.emitMethod(a,U.ZIndexNode,{workIds:e,viewId:n,requestId:o,workState:D.Done,layer:t.zIndexLayer})),t.shape){const u={};if(t.shape.vertices!==void 0&&(u.vertices=t.shape.vertices),t.shape.innerVerticeStep!==void 0&&(u.innerVerticeStep=t.shape.innerVerticeStep),t.shape.innerRatio!==void 0&&(u.innerRatio=t.shape.innerRatio),t.shape.placement!==void 0&&(u.placement=t.shape.placement),Object.keys(u).length){if(!s.length){console.log(`${J} updateSelectedElements emit-method-skip requestId=${o||"-"} method=${U.SetShapeOpt} reason=no-shape-toolsType payload=${this.stringifyLogValue(u)}`);return}s.forEach(h=>{console.log(`${J} updateSelectedElements emit-method requestId=${o||"-"} method=${U.SetShapeOpt} workIds=[${e.join(",")}] toolsType=${h} payload=${this.stringifyLogValue(u)}`),te.emitMethod(a,U.SetShapeOpt,{workIds:e,viewId:n,toolsType:h,requestId:o,workState:D.Done,...u})})}}}buildSelectedElementInfo(n,e,t,i){var M,w,m;const o=this.control.collector,s=o&&o.isLocalId(t)?o.transformKey(t):t,a=(m=(w=(M=o==null?void 0:o.storage)==null?void 0:M[n])==null?void 0:w[e||""])==null?void 0:m[s];if(!a)return;const c=a.toolsType,l=a.opt,u=a.updateNodeOpt||{},h={};(l==null?void 0:l.strokeColor)!==void 0&&(h.strokeColor=l.strokeColor),(l==null?void 0:l.fillColor)!==void 0&&(h.fillColor=l.fillColor),(l==null?void 0:l.thickness)!==void 0&&(h.thickness=l.thickness),(l==null?void 0:l.strokeType)!==void 0&&(h.strokeType=l.strokeType),(l==null?void 0:l.fontColor)!==void 0&&(h.fontColor=l.fontColor),(l==null?void 0:l.fontBgColor)!==void 0&&(h.fontBgColor=l.fontBgColor),(l==null?void 0:l.zIndex)!==void 0&&(h.zIndex=l.zIndex);const g={id:t,toolsType:c,style:h};if(i&&(j.isBoolean(i.canRotate)&&(g.canRotate=i.canRotate),j.isBoolean(i.canLock)&&(g.canLock=i.canLock),i.scaleType&&(g.scaleType=i.scaleType),j.isBoolean(i.isLocked)&&(g.isLocked=i.isLocked)),c===S.Text&&l){const p=l,T={text:p.text,fontSize:p.fontSize,fontFamily:p.fontFamily,bold:p.bold,italic:p.italic,underline:p.underline,lineThrough:p.lineThrough,textAlign:p.textAlign,verticalAlign:p.verticalAlign,boxPoint:p.boxPoint,boxSize:p.boxSize};g.text=T}if(c===S.Polygon){const p=l;g.shape={vertices:p.vertices}}else if(c===S.Star){const p=l;g.shape={vertices:p.vertices,innerVerticeStep:p.innerVerticeStep,innerRatio:p.innerRatio}}else if(c===S.SpeechBalloon){const p=l;g.shape={placement:p.placement}}const y=u.rect;y&&(g.rect={x:y.x,y:y.y,w:y.w,h:y.h});const d=u.centerPos;return d&&(g.centerPos=d),g}buildRemoteSelectedElements(n,e,t,i){if(!i.length)return[];const o=[];for(const s of i){const a=this.buildSelectedElementInfo(n,e,`${t}${We}${s}`,void 0);a&&(a.id=s,o.push(a))}return o}logGeometry(n,e,t){var a,c;const i=`${J} selectorGeometryChange action=${e} viewId=${n} count=${t}`,o=this.getDebounceLogger();if((e==="select"||e==="selectorTransform"||e==="cameraTransform")&&o!=null&&o.infoDebounced){o.infoDebounced(`selector-geometry:${n}:${e}`,i);return}(c=(a=this.logger)==null?void 0:a.info)==null||c.call(a,i)}}const Nt="__undo_scope_clear_all__";function hm(r){const{viewId:n,scenePath:e,expectedAcks:t,fallbackTimer:i}=r;return{viewId:n,scenePath:e,expectedRender:t.render,expectedStorage:t.storage,gotRender:!t.render,gotStorage:!t.storage,scopeMode:t.scopeMode||"static",finalizeRequested:!1,collectedScopeKeys:new Set,scopeKeys:new Set,ackedStorageKeys:new Set,meta:{copyAck:t.copyAck,isWritable:t.isWritable},fallbackTimer:i}}function dm(r,n){n&&(r.meta={...r.meta,...n})}function gm(r){return(!r.expectedRender||r.gotRender)&&(!r.expectedStorage||r.gotStorage)}function fm(r){return!r.ackTimer&&(r.gotRender||r.gotStorage)}function pm(r,n){return r.size>0?r.has(Nt)?n===Nt:!!n&&r.has(n):!n||r.has(n)}function Ln(r,n){const e=n.toString();return r.isLocalId(e)?r.transformKey(e):e}function Pn(r,n,e,t){var s,a;const i=new Set;if(!r)return i;const o=r.getStorageData(n,e);for(const c of t){if(c==null)continue;if(c===Nt){i.add(Nt);continue}const l=Ln(r,c),u=o==null?void 0:o[l];if(r.getLocalId(l)===Q){(s=u==null?void 0:u.selectIds)==null||s.forEach(h=>{i.add(Ln(r,h))});continue}i.add(l),(a=u==null?void 0:u.selectIds)==null||a.forEach(h=>{i.add(Ln(r,h))})}return i}function Mo(r,n,e){return e!=null&&e.has(Nt)?!n.has(r):e!=null&&e.size?e.has(r):!n.has(r)}const Ve=class Ve{constructor(n){I(this,"version",Xo);I(this,"plugin");I(this,"logger");I(this,"room");I(this,"play");I(this,"collector");I(this,"hasSwitchToSelectorEffect");I(this,"snapshootStateMap");I(this,"_disableDeviceInputs");I(this,"_disableEraseImage");I(this,"_disableEraseText");I(this,"_disableCameraTransform");I(this,"_disableUseWorker",!1);I(this,"effectResolve");I(this,"hotkeyManager");I(this,"pluginOptions");I(this,"roomMember");I(this,"cursor");I(this,"textEditorManager");I(this,"worker");I(this,"renderControl");I(this,"miniMapManager");I(this,"pluginManager");I(this,"selectorApi");I(this,"_isPolyfill",{requestIdleCallback:!1,cancelIdleCallback:!1});I(this,"onSceneChange",async(n,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 i=t==null?void 0:t.displayer;i&&(i.setActive(!1),await i.stopEventHandler());const o=n;o&&this.viewContainerManager.setViewScenePath(e,o),i==null||i.setActive(!0)});I(this,"onRoomMembersChange",n=>{this.roomMember.setRoomMembers(G.toJS(n))});I(this,"onMemberChange",j.throttle(n=>{var s,a;if(!this.room||!this.worker||!n||!this.room.isWritable)return;const e=this.getToolsKey(n),t=(s=this.worker.getCurrentToolsData())==null?void 0:s.toolsType,i=this.viewContainerManager.focuedViewId;i&&t===S.Selector&&e!==S.Selector&&this.worker.blurCursor(i);const o=this.getToolsOpt(e,n);this.worker.setCurrentToolsData(o),(a=this.pluginManager)==null||a.dispatchPluginEvent("setToolkey",e),this.effectViewContainer(e),this.effectResolve&&this.effectResolve(!0)},100,{leading:!1}));I(this,"internalSceneChange",(n,e)=>{var t,i,o,s;this.isUseSimple||((t=this.miniMapManager)==null?void 0:t.activeViewId)===n&&((i=this.miniMapManager)==null||i.destroyMiniMap(n)),(o=this.pluginManager)==null||o.dispatchPluginEvent("sceneChange",n,e),(s=this.worker)==null||s.clearViewScenePath(n,!0).then(()=>{var a;(a=this.worker)==null||a.pullServiceData(n,e,{isAsync:!0,useAnimation:!1})})});I(this,"internalCameraChange",(n,e)=>{var t,i;(t=this.worker)==null||t.updateCamera(n,e),this.isUseSimple||(i=this.miniMapManager)==null||i.updateViewCamera(n,e)});var a,c;const{displayer:e,plugin:t,options:i}=n;this.plugin=t,this.room=G.isRoom(e)?e:void 0,this.play=G.isPlayer(e)?e:void 0;let o;this.room&&(o=(a=this.room)==null?void 0:a.logger,this._disableDeviceInputs=this.room.disableDeviceInputs,this._disableEraseImage=this.room.disableEraseImage,this._disableEraseText=!1),this.pluginOptions=i,((c=i.extras)==null?void 0:c.useWorker)==="mainThread"?this._disableUseWorker=!0:this._disableUseWorker=Ki!=="worker",this.roomMember=new RM;const s={control:this,internalMsgEmitter:Ve.InternalMsgEmitter,publicMsgEmitter:Ve.PublicMsgEmitter};this.cursor=new OM(s),this.textEditorManager=new Pf(s),this.worker=new Gy(s),this.hotkeyManager=new Qy(s),this.renderControl=new Zy(s),this.pluginManager=new Jy(s),this.isUseSimple||(this.miniMapManager=new Hy(s)),this.logger=new Si(o)}get publicMsgEmitter(){return Ve.PublicMsgEmitter}get internalMsgEmitter(){return Ve.InternalMsgEmitter}hasPolyfillMethod(n){return this._isPolyfill[n]}registerPolyfillMethod(n){this._isPolyfill[n]=!0}get hasExtendFontFaces(){return this.extendFontFaces.length>0}get extendFontFaces(){var n;return((n=this.pluginOptions.extras.textEditor)==null?void 0:n.extendFontFaces)??Ie.textEditor.extendFontFaces}get loadFontFacesTimeout(){var n;return((n=this.pluginOptions.extras.textEditor)==null?void 0:n.loadFontFacesTimeout)??Ie.textEditor.loadFontFacesTimeout}get disableEraseText(){return this._disableEraseText||!1}set disableEraseText(n){this._disableEraseText=n}get disableEraseImage(){return this._disableEraseImage||!1}set disableEraseImage(n){this._disableEraseImage=n,this.room.disableEraseImage=n}get disableDeviceInputs(){return this._disableDeviceInputs||!1}set disableDeviceInputs(n){var t;this._disableDeviceInputs=n;const e=(t=this.worker.getCurrentToolsData())==null?void 0:t.toolsType;e&&this.effectViewContainer(e)}get disableCameraTransform(){return this._disableCameraTransform||!1}set disableCameraTransform(n){this._disableCameraTransform=n,this.room.disableCameraTransform=n}get disableUseWorker(){return this._disableUseWorker||!1}set disableUseWorker(n){this._disableUseWorker=n}get hasOffscreenCanvas(){return this._disableUseWorker?!1:Ki==="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}get isUseBackgroundThread(){return this.pluginOptions.extras.useBackgroundThread}bindPlugin(n){this.plugin=n,this.collector&&(this.collector.removeStorageStateListener(),this.collector.removeAuthStateListener()),this.collector=new _e(this,n,this.pluginOptions.extras.syncOpt.interval),this.activePlugin(),this.selectorApi&&this.selectorApi.destroy(),this.selectorApi=new um(this)}destroy(){var n,e,t,i,o,s,a,c;this.roomMember.destroy(),(n=this.collector)==null||n.destroy(),(e=this.worker)==null||e.destroy(),(t=this.viewContainerManager)==null||t.destroy(),(i=this.cursor)==null||i.destroy(),(o=this.textEditorManager)==null||o.destory(),(s=this.pluginManager)==null||s.destroy(),(a=this.miniMapManager)==null||a.destroyMiniMap(),(c=this.selectorApi)==null||c.destroy(),this.selectorApi=void 0}cleanCurrentScene(){var t,i;const n=this.worker.now,e=this.worker.getLocalWorkViewId()||this.viewContainerManager.focuedViewId;if(e){const o=this.viewContainerManager.getCurScenePath(e),s=(o&&((i=(t=this.collector)==null?void 0:t.storage[e])!=null&&i[o])?Object.keys(this.collector.storage[e][o]):[])||[];Ve.InternalMsgEmitter.emit("addUndoTicker",n,e,{render:!0,storage:!0}),s.length&&Ve.InternalMsgEmitter.emit("finalizeRequested",n,e,[Nt],o),this.worker.clearViewScenePath(e,!1,!0).then(()=>{Ve.InternalMsgEmitter.emit("ackRenderUndoTicker",n,e,o),Ve.InternalMsgEmitter.emit("ackStorageUndoTicker",n,e,o,Nt)})}}async setWritable(n){var e,t;if(!n){(e=this.cursor)==null||e.unabled(),this.textEditorManager.checkEmptyTextBlur();const i=this.viewContainerManager.getAllViews();for(const o of i){o!=null&&o.focusScenePath&&(t=this.collector)!=null&&t.hasSelector(o.id,o.focusScenePath)&&this.worker.blurSelector(o.id,o.focusScenePath);const s=o==null?void 0:o.displayer;s&&(s.setActive(!1),await s.stopEventHandler())}}await new Promise(i=>{setTimeout(()=>{i()},500)})}onWritableChange(n){var i;n?this.worker.abled():this.worker.unWritable(),((i=this.worker.getCurrentToolsData())==null?void 0:i.toolsType)===S.Text&&this.viewContainerManager.focuedViewId&&(n?this.viewContainerManager.activeTextEditor(this.viewContainerManager.focuedViewId):this.viewContainerManager.unActiveTextEditor(this.viewContainerManager.focuedViewId)),this.renderControl.onWritableChange(n),this.viewContainerManager.getAllViews().forEach(o=>{const s=o==null?void 0:o.displayer;s&&(s.bindToolsClass(),n?s.setActive(!0):s.setActive(!1))})}getToolsKey(n){const e=n.currentApplianceName;switch(this.hasSwitchToSelectorEffect=!1,e){case ie.text:return n.textCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),S.Text;case ie.pencil:return n.useLaserPen?S.LaserPen:S.Pencil;case ie.eraser:return S.Eraser;case ie.pencilEraser:return this.pluginOptions.extras.pencilEraser.useBitMap===!1?S.PencilEraser:S.BitMapEraser;case ie.selector:return S.Selector;case ie.arrow:return n.arrowCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),S.Arrow;case ie.straight:return n.straightCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),S.Straight;case ie.ellipse:return n.ellipseCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),S.Ellipse;case ie.rectangle:return n.rectangleCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),S.Rectangle;case ie.shape:if(n.shapeCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),n.shapeType===Ye.Pentagram||n.shapeType===Ye.Star)return S.Star;if(n.shapeType===Ye.Polygon||n.shapeType===Ye.Triangle||n.shapeType===Ye.Rhombus)return S.Polygon;if(n.shapeType===Ye.SpeechBalloon)return S.SpeechBalloon;break}return S.Clicker}getToolsOpt(n,e){if(n===S.Clicker)return{toolsType:n,toolsOpt:{}};const t={strokeColor:Dt(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(n){case S.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)&&Dt(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)&&Dt(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 S.Pencil:{const i=(e==null?void 0:e.strokeType)||ce.Normal;t.strokeType=i,t.autoShape=!!(e!=null&&e.autoShape),t.previewLocalOnly=!!(e!=null&&e.autoShape),t.lineCap=this.getLineCap(i),t.lineDash=this.getLineDash(i);break}case S.PencilEraser:case S.BitMapEraser:case S.Eraser:t.thickness=Math.min(4,Math.max(1,Math.floor(e.pencilEraserSize||1)))-1;break;case S.LaserPen:{t.duration=(e==null?void 0:e.duration)||1,e!=null&&e.strokeType&&(e==null?void 0:e.strokeType)===ce.Stroke?t.strokeType=ce.Normal:t.strokeType=(e==null?void 0:e.strokeType)||ce.Normal;const i=t.strokeType;t.lineCap=this.getLineCap(i),t.lineDash=this.getLineDash(i);break}case S.Arrow:case S.Straight:{e!=null&&e.strokeType&&(e==null?void 0:e.strokeType)===ce.Stroke?t.strokeType=ce.Normal:t.strokeType=(e==null?void 0:e.strokeType)||ce.Normal;const i=t.strokeType;t.strokeType=i,t.lineCap=this.getLineCap(i),t.lineDash=this.getLineDash(i);break}case S.Ellipse:case S.Rectangle:case S.Star:case S.Polygon:case S.SpeechBalloon:{e!=null&&e.strokeType&&(e==null?void 0:e.strokeType)===ce.Stroke?t.strokeType=ce.Normal:t.strokeType=(e==null?void 0:e.strokeType)||ce.Normal;const i=t.strokeType;t.lineCap=this.getLineCap(i),t.lineDash=this.getLineDash(i),n===S.Star&&(e.shapeType===Ye.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)),n===S.Polygon&&(e.shapeType===Ye.Triangle?t.vertices=3:e.shapeType===Ye.Rhombus?t.vertices=4:e.vertices&&(t.vertices=e.vertices)),t.fillColor=(e==null?void 0:e.fillColor)&&Dt(e.fillColor[0],e.fillColor[1],e.fillColor[2],e==null?void 0:e.fillOpacity)||"transparent",n===S.SpeechBalloon&&(t.placement=e.placement||"bottomLeft");break}}return{toolsType:n,toolsOpt:t}}getLineCap(n){switch(n){case ce.Normal:return this.pluginOptions.extras.normalStroke.lineCap||Ie.normalStroke.lineCap;case ce.Dotted:return this.pluginOptions.extras.dottedStroke.lineCap||Ie.dottedStroke.lineCap;case ce.LongDotted:return this.pluginOptions.extras.longDottedStroke.lineCap||Ie.longDottedStroke.lineCap;default:return}}getLineDash(n){switch(n){case ce.Normal:return;case ce.Dotted:{const{segment:e,gap:t}=this.pluginOptions.extras.dottedStroke||Ie.dottedStroke;return[e,t]}case ce.LongDotted:{const{segment:e,gap:t}=this.pluginOptions.extras.longDottedStroke||Ie.longDottedStroke;return[e,t]}default:return}}effectViewContainer(n){var e,t,i,o,s;if(this.disableDeviceInputs===!0)this.room.disableDeviceInputs=!0,(e=this.worker)==null||e.unWritable(),(t=this.cursor)==null||t.unabled();else switch(n!==S.Text&&this.viewContainerManager.focuedViewId&&this.viewContainerManager.unActiveTextEditor(this.viewContainerManager.focuedViewId),n){case S.Text:case S.Pencil:case S.LaserPen:case S.Arrow:case S.Straight:case S.Rectangle:case S.Ellipse:case S.Star:case S.Polygon:case S.SpeechBalloon:case S.Triangle:case S.Rhombus:case S.Eraser:case S.PencilEraser:case S.BitMapEraser:case S.Selector:this.room.disableDeviceInputs=!0,(i=this.worker)==null||i.abled(),n===S.Text&&this.viewContainerManager.focuedViewId&&this.viewContainerManager.activeTextEditor(this.viewContainerManager.focuedViewId);break;default:this.room.disableDeviceInputs=!1,(o=this.worker)==null||o.unWritable(),(s=this.cursor)==null||s.unabled();break}setTimeout(()=>{this.viewContainerManager.getAllViews().forEach(c=>{c!=null&&c.displayer&&c.displayer.bindToolsClass()})},0)}async getBoundingRect(n){var t,i,o,s,a;const e=await((t=this.worker)==null?void 0:t.getBoundingRect(n));if(e){const c=((o=(i=this.viewContainerManager.mainView)==null?void 0:i.viewData)==null?void 0:o.convertToPointInWorld({x:e.x,y:e.y}))||{x:e.x,y:e.y},l=((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(n,e,t,i,o,s,a){const c=await this.worker.getSnapshot(e,t,i,o);c&&c.forEach(l=>{if(l)try{console.log("[screenshotToCanvas] Drawing ImageBitmap:",l.width,l.height),n.drawImage(l,s||0,a||0)}catch(u){console.error("[screenshotToCanvas] Failed to draw ImageBitmap:",u)}l instanceof ImageBitmap?l.close():l instanceof HTMLImageElement&&l.remove()})}async scenePreview(n,e){var s,a,c,l;const t=(s=this.collector)==null?void 0:s.getViewIdBySecenPath(n);if(!t)return;const i=this.viewContainerManager.getView(t);if(!i||!((a=i.cameraOpt)!=null&&a.width)||!((c=i.cameraOpt)!=null&&c.height))return;const o=await((l=this.worker)==null?void 0:l.getSnapshot(n));if(o&&this.worker){const u=document.createElement("canvas"),h=u.getContext("2d"),{width:g,height:y}=i.cameraOpt;u.width=g,u.height=y,h&&(o.forEach(d=>{d&&(h.drawImage(d,0,0),d instanceof ImageBitmap?d.close():d instanceof HTMLImageElement&&d.remove())}),e.crossOrigin="anonymous",e.src=u.toDataURL(),e.onload=()=>{u.remove()},e.onerror=()=>{u.remove(),e.remove()})}}switchToText(){var n;(n=this.room)==null||n.setMemberState({currentApplianceName:ie.text})}switchToSelector(){var n;(n=this.room)==null||n.setMemberState({currentApplianceName:ie.selector})}async runEffectWork(n){if(this.hasSwitchToSelectorEffect){const e=await new Promise(t=>{this.switchToSelector(),this.effectResolve=t});this.effectResolve=void 0,e&&n&&n()}}setSnapshootData(){var n;this.room&&(this.snapshootStateMap=new Map,this.snapshootStateMap.set("memberState",(n=this.room)==null?void 0:n.state.memberState))}getSnapshootData(n){var e;return(e=this.snapshootStateMap)==null?void 0:e.get(n)}clearSnapshootData(){var n;(n=this.snapshootStateMap)==null||n.clear(),this.snapshootStateMap=void 0}useBitMapEraser(n){this.pluginOptions.extras.pencilEraser.useBitMap=n}consoleWorkerInfo(){var n;(n=this.worker)==null||n.consoleWorkerInfo()}filterRenderByUid(n,e,t=!0){var o;this.viewContainerManager.getView(n)&&((o=this.renderControl)==null||o.publishRender({viewId:n,option:e,isSync:t}))}cancelFilterRender(n,e=!0){var t;(t=this.renderControl)==null||t.publishRender({viewId:n,isSync:e})}async createMiniMap(n,e){var i,o,s;if(this.isUseSimple)throw new Error("simple mode not support createMiniMap");const t=await((i=this.miniMapManager)==null?void 0:i.getMiniMapCamera(n));if(t&&await((o=this.miniMapManager)==null?void 0:o.createMiniMap(n,e,t))){const c=(s=this.miniMapManager)==null?void 0:s.getMiniMapCanvas(n);if(c){const l=c.getContext("2d");if(l){const u=this.viewContainerManager.getView(n);u!=null&&u.focusScenePath&&this.screenshotToCanvas(l,u.focusScenePath,t.width,t.height,t)}}}}async destroyMiniMap(n){var e;(e=this.miniMapManager)==null||e.destroyMiniMap(n)}insertIconify(n,e){var i;if(this.viewContainerManager.getView(n)&&this.room){const o=this.room.state.memberState,s=Dt(o.strokeColor[0],o.strokeColor[1],o.strokeColor[2],o.strokeOpacity||1);(i=this.worker)==null||i.insertIconify(n,{...e,strokeColor:s})}}insertBackgroundSVG(n,e){var t;if(!this.isUseBackgroundThread)throw new Error("useBackgroundThread of pluginOptions should be true");(t=this.worker)==null||t.insertBackgroundSVG(n,e)}async insertBackgroundMarkMap(n,e){var t;if(!this.isUseBackgroundThread)throw new Error("useBackgroundThread of pluginOptions should be true");return await((t=this.worker)==null?void 0:t.insertBackgroundMarkMap(n,e))}updateBackgroundMarkMap(n,e,t){var o;const i=this.viewContainerManager.getView(n);if(i&&this.collector&&this.collector.hasTargetDataByViewId(n,e)){const{data:s,scenePath:a}=this.collector.getTargetDataByViewId(n,e);if(!a)throw new Error("updateBackgroundMarkMap scenePath is not exist");const c=i.focusScenePath;if(c&&c!==a)throw new Error("updateBackgroundMarkMap scenePath is not the focus scene path");if(s&&a)(o=this.worker)==null||o.updateBackgroundMarkMap(n,e,t);else throw new Error("updateBackgroundMarkMap data or scenePath is not exist")}}usePlugin(n){var e;return(e=this.pluginManager)==null?void 0:e.use(n)}async stopDraw(n){var t;const e=this.viewContainerManager.getView(n);e&&await((t=e.displayer)==null?void 0:t.stopEventHandler())}async setViewLocalScenePathChange(n,e){this.viewContainerManager.getView(n)&&await this.onSceneChange(e,n)}};I(Ve,"InternalMsgEmitter",new Yn),I(Ve,"PublicMsgEmitter",new Yn);let Me=Ve;var qn=(r=>(r.Undo="undo",r.Redo="redo",r))(qn||{});const le=class le{createProxy(n,e,t){const i=new Proxy(n,{get(o,s,a){if(typeof s=="string"&&/^\d+$/.test(s))return Reflect.get(o,s,a);const c=le.interceptors.hasOwnProperty(s)?le.interceptors:o,l=Reflect.get(c,s,a);return typeof l=="function"&&c===le.interceptors?l.bind(i):l},set(o,s,a,c){const l=le.proxyCallbacks.get(c),u=(l==null?void 0:l.arrayType)||"undo";if(s==="length"){const h=o.length,g=[];if(a<h)for(let d=a;d<h;d++)g.push(o[d]);const y=Reflect.set(o,s,a,c);if(l!=null&&l.callback)for(let d=0;d<g.length;d++)l.callback({operation:"delete",index:a+d,oldValue:g[d],arrayType:u});return y}return typeof s=="string"&&/^\d+$/.test(s),Reflect.set(o,s,a,c)},deleteProperty(o,s){const a=le.proxyCallbacks.get(i),c=(a==null?void 0:a.arrayType)||"undo";if(typeof s=="string"&&/^\d+$/.test(s)){const l=parseInt(s,10),u=o[l],h=Reflect.deleteProperty(o,s);return a!=null&&a.callback&&u!==void 0&&a.callback({operation:"delete",index:l,oldValue:u,arrayType:c}),h}return Reflect.deleteProperty(o,s)}});return le.proxyToRaw.set(i,n),le.proxyCallbacks.set(i,{callback:e,arrayType:t}),i}};I(le,"proxyToRaw",new WeakMap),I(le,"proxyCallbacks",new WeakMap),I(le,"interceptors",{entries(...n){return le.proxyToRaw.get(this).entries(...n)},forEach(...n){return le.proxyToRaw.get(this).forEach(...n)},map(...n){return le.proxyToRaw.get(this).map(...n)},filter(...n){return le.proxyToRaw.get(this).filter(...n)},find(...n){return le.proxyToRaw.get(this).find(...n)},findIndex(...n){return le.proxyToRaw.get(this).findIndex(...n)},includes(...n){return le.proxyToRaw.get(this).includes(...n)},indexOf(...n){return le.proxyToRaw.get(this).indexOf(...n)},slice(...n){return le.proxyToRaw.get(this).slice(...n)},concat(...n){return le.proxyToRaw.get(this).concat(...n)},push(...n){const e=le.proxyToRaw.get(this),t=this,i=le.proxyCallbacks.get(t),o=(i==null?void 0:i.arrayType)||"undo",s=e.length,a=e.push(...n);if(i!=null&&i.callback)for(let c=s;c<e.length;c++)i.callback({operation:"add",index:c,newValue:e[c],arrayType:o});return a},customPush(...n){return le.proxyToRaw.get(this).push(...n)},pop(){const n=le.proxyToRaw.get(this),e=this,t=le.proxyCallbacks.get(e),i=(t==null?void 0:t.arrayType)||"undo",o=n.length,s=n[o-1],a=n.pop();return t!=null&&t.callback&&o>0&&t.callback({operation:"delete",index:o-1,oldValue:s,arrayType:i}),a},shift(){const n=le.proxyToRaw.get(this),e=this,t=le.proxyCallbacks.get(e),i=(t==null?void 0:t.arrayType)||"undo",o=n[0],s=n.shift();return t!=null&&t.callback&&n.length>0&&t.callback({operation:"delete",index:0,oldValue:o,arrayType:i}),s},unshift(...n){const e=le.proxyToRaw.get(this),t=this,i=le.proxyCallbacks.get(t),o=(i==null?void 0:i.arrayType)||"undo",s=e.unshift(...n);if(i!=null&&i.callback)for(let a=0;a<n.length;a++)i.callback({operation:"add",index:a,newValue:e[a],arrayType:o});return s},splice(n,e,...t){const i=le.proxyToRaw.get(this),o=this,s=le.proxyCallbacks.get(o),a=(s==null?void 0:s.arrayType)||"undo",c=e??i.length-n,l=i.slice(n,n+c),u=i.splice(n,c,...t);if(s!=null&&s.callback){for(let h=0;h<l.length;h++)s.callback({operation:"delete",index:n+h,oldValue:l[h],arrayType:a});for(let h=0;h<t.length;h++)s.callback({operation:"add",index:n+h,newValue:i[n+h],arrayType:a})}return u},customSplice(n,e,...t){const i=le.proxyToRaw.get(this),o=e??i.length-n;return i.splice(n,o,...t)},get length(){return le.proxyToRaw.get(this).length},set length(n){const e=le.proxyToRaw.get(this),t=this,i=le.proxyCallbacks.get(t),o=(i==null?void 0:i.arrayType)||"undo",s=e.length,a=[];if(n<s)for(let c=n;c<s;c++)a.push(e[c]);if(e.length=n,i!=null&&i.callback)for(let c=0;c<a.length;c++)i.callback({operation:"delete",index:n+c,oldValue:a[c],arrayType:o})}});let Jn=le;const et=class et{constructor(n){I(this,"emitter",new Yn);I(this,"undoStack");I(this,"redoStack");I(this,"worker");I(this,"control");I(this,"room");I(this,"viewId");I(this,"enableGlobal");I(this,"isTicking");I(this,"_undoTickerId");I(this,"scenePath");I(this,"tickStartStorerCache");I(this,"excludeIds",new Set);I(this,"pendingState",new Map);I(this,"tickStartCaches",new Map);I(this,"tickStartExcludeIds",new Map);I(this,"timingFix");I(this,"ackTimeout");I(this,"gracePeriodTimeout");I(this,"doingFallbackTimeout");I(this,"isGlobalStackTransaction",!1);I(this,"pendingGlobalServiceData");I(this,"pendingArrayChanges",[]);I(this,"onChangeScene",j.debounce(()=>{const n=this.control.viewContainerManager.getCurScenePath(this.viewId);if(n){const e=this.undoStack.filter(i=>i.scenePath===n).length,t=this.redoStack.filter(i=>i.scenePath===n).length;this.emitUndoStepsUpdate(e),this.emitRedoStepsUpdate(t)}},et.waitTime));const{control:e,internalMsgEmitter:t,viewId:i,enableGlobal:o}=n;this.control=e,this.emitter=t;const s=this.control.pluginOptions.extras.undoRedo;et.MaxStackLength=s.maxStackLength||Ie.undoRedo.maxStackLength,this.timingFix=s.timingFix??Ie.undoRedo.timingFix,this.ackTimeout=s.ackTimeout||Ie.undoRedo.ackTimeout,this.gracePeriodTimeout=s.gracePeriodTimeout||Ie.undoRedo.gracePeriodTimeout,this.doingFallbackTimeout=s.doingFallbackTimeout||Ie.undoRedo.doingFallbackTimeout;const a=new Jn,c=[],l=[];this.undoStack=a.createProxy(c,u=>{this.control.renderControl.isWritable&&this.handleArrayChange(u,be.syncUndoStack)},qn.Undo),this.redoStack=a.createProxy(l,u=>{this.control.renderControl.isWritable&&this.handleArrayChange(u,be.syncRedoStack)},qn.Redo),this.room=e.room,this.worker=e.worker,this.isTicking=!1,this.viewId=i,this.enableGlobal=o}reportStackLength(n,e=this.undoStack.length,t=this.redoStack.length){var i,o,s;(s=(o=(i=this.room)==null?void 0:i.logger)==null?void 0:o.info)==null||s.call(o,`[Appliance]: [undo-stack] ${n} viewId=${this.viewId} undoLength=${e} redoLength=${t}`)}emitUndoStepsUpdate(n){this.emitter.emitAsync("onCanUndoStepsUpdate",n,this.viewId)}emitRedoStepsUpdate(n){this.emitter.emitAsync("onCanRedoStepsUpdate",n,this.viewId)}beginGlobalStackTransaction(){this.enableGlobal&&(this.isGlobalStackTransaction=!0)}flushPendingArrayChanges(){if(!this.enableGlobal||!this.pendingArrayChanges.length)return;const n=this.pendingArrayChanges.splice(0);for(const e of n)this.handleArrayChange(e.params,e.operation)}endGlobalStackTransaction(){if(!this.enableGlobal)return;const n=this.pendingGlobalServiceData;this.isGlobalStackTransaction=!1,this.pendingGlobalServiceData=void 0,this.flushPendingArrayChanges(),n&&this.pullServiceData(n)}ackRender(n,e,t){if(!this.timingFix){this.undoTickerEnd(n,e);return}const i=this.pendingState.get(n);!i||i.scenePath!==e||(i.gotRender=!0,this.mergeMeta(i,t),i.finalizeRequested&&(this.armAckTimeout(n,i),this.tryEnd(n)))}ackStorage(n,e,t,i){if(!this.timingFix)return;const o=this.pendingState.get(n);!o||o.scenePath!==e||(t&&(o.scopeMode==="dynamic"||o.finalizeRequested)&&o.ackedStorageKeys.add(t),pm(o.scopeKeys,t)&&o.finalizeRequested&&(o.scopeKeys.size?o.gotStorage=[...o.scopeKeys].every(a=>o.ackedStorageKeys.has(a)):o.gotStorage=!0),this.mergeMeta(o,i),!o.finalizeRequested)||(this.armAckTimeout(n,o),this.tryEnd(n))}collectExpectedWorkIds(n,e,t){const i=this.pendingState.get(n);if(!i||i.scenePath!==e||!t.length)return;Pn(this.collector,this.viewId,e,t).forEach(s=>i.collectedScopeKeys.add(s)),i.scopeMode==="dynamic"&&i.finalizeRequested&&(i.scopeKeys.clear(),i.collectedScopeKeys.forEach(s=>i.scopeKeys.add(s)),i.expectedStorage&&i.scopeKeys.size?i.gotStorage=[...i.scopeKeys].every(s=>i.ackedStorageKeys.has(s)):i.expectedStorage&&!i.scopeKeys.size&&(i.gotStorage=!1),i.ackTimer&&clearTimeout(i.ackTimer),i.ackTimer=void 0,this.armAckTimeout(n,i),this.tryEnd(n))}reopenStorageAck(n,e,t){const i=this.pendingState.get(n);if(!i||i.scenePath!==e||!t.length)return;const o=Pn(this.collector,this.viewId,e,t);o.size&&(o.forEach(s=>i.ackedStorageKeys.delete(s)),i.finalizeRequested&&(i.expectedStorage&&i.scopeKeys.size?i.gotStorage=[...i.scopeKeys].every(s=>i.ackedStorageKeys.has(s)):i.expectedStorage&&!i.scopeKeys.size&&(i.gotStorage=i.scopeMode==="static"),i.ackTimer&&clearTimeout(i.ackTimer),i.ackTimer=void 0,this.armAckTimeout(n,i)))}finalizeRequested(n,e,t){const i=this.pendingState.get(n);if(!i||i.scenePath!==e)return;const o=Pn(this.collector,this.viewId,e,t);i.scopeMode==="dynamic"?(o.forEach(s=>i.collectedScopeKeys.add(s)),i.scopeKeys.clear(),i.collectedScopeKeys.forEach(s=>i.scopeKeys.add(s))):o.forEach(s=>i.scopeKeys.add(s)),i.finalizeRequested=!0,i.expectedStorage&&i.scopeKeys.size?i.gotStorage=[...i.scopeKeys].every(s=>i.ackedStorageKeys.has(s)):i.expectedStorage&&!i.scopeKeys.size&&i.scopeMode==="static"?i.gotStorage=!0:i.expectedStorage&&!i.scopeKeys.size&&i.scopeMode==="dynamic"&&(i.gotStorage=!1),this.armAckTimeout(n,i),this.tryEnd(n)}mergeMeta(n,e){dm(n,e)}armAckTimeout(n,e){e.finalizeRequested&&fm(e)&&(e.ackTimer=setTimeout(()=>{this.forceFlushPending(n)},this.ackTimeout))}tryEnd(n){const e=this.pendingState.get(n);if(!e||!gm(e))return;const t=e.meta;this.undoTickerEndSync(n,e.viewId,e.scenePath,!0),t.copyAck&&t.emitEventType&&t.requestId&&this.emitter.emit("undoAckApplied",{viewId:e.viewId,scenePath:e.scenePath,requestId:t.requestId,emitEventType:t.emitEventType}),t.isWritable&&this.worker.abled()}forceFlushPending(n){const e=this.pendingState.get(n);e&&(e.gotRender=e.expectedRender,e.gotStorage=e.expectedStorage,this.tryEnd(n))}hasAnyAck(n){return n.gotRender||n.gotStorage||n.ackedStorageKeys.size>0||!!n.ackTimer}clearPendingState(n){const e=this.pendingState.get(n);e&&(e.ackTimer&&clearTimeout(e.ackTimer),e.graceTimer&&clearTimeout(e.graceTimer),e.fallbackTimer&&clearTimeout(e.fallbackTimer),this.pendingState.delete(n)),this.tickStartCaches.delete(n),this.tickStartExcludeIds.delete(n)}cancelUndoTicker(n,e,t){const i=this.pendingState.has(n),o=this.undoTickerId===n&&this.viewId===e&&this.scenePath===t;!i&&!o||(o&&(this.isTicking=!1,this.scenePath=void 0,this.tickStartStorerCache=void 0,this._undoTickerId=void 0,this.excludeIds.clear()),this.clearPendingState(n))}getStartCache(n){return this.tickStartCaches.get(n)||this.tickStartStorerCache}getExcludeIds(n){return this.tickStartExcludeIds.get(n)||this.excludeIds}resetLegacyTicker(){this.isTicking=!1,this.scenePath=void 0,this.tickStartStorerCache=void 0,this._undoTickerId=void 0,this.excludeIds.clear()}handleArrayChange(n,e){if(!this.collector||!this.enableGlobal){this.collector;return}if(this.isGlobalStackTransaction){this.pendingArrayChanges.push({operation:e,params:{...n}});return}const{operation:t,oldValue:i,newValue:o}=n;let s,a;t==="delete"&&i?(s=i,a=i.id):t==="add"&&o&&(s=o,a=o.id),s&&a&&this.collector.dispatchUndoTicker({operation:e,syncType:t,viewId:this.viewId,undoTickerId:a,data:s})}get collector(){return this.control.collector}get undoTickerId(){return this._undoTickerId}get tmpTickStartStorerCache(){return this.tickStartStorerCache}get uid(){var n;return((n=this.control.collector)==null?void 0:n.uid)||""}addExcludeIds(n){const e=this.undoTickerId!==void 0?this.pendingState.get(this.undoTickerId):void 0;if(!(this.timingFix&&(e!=null&&e.scopeKeys.size))){if(this.timingFix&&this.undoTickerId!==void 0){const t=this.tickStartExcludeIds.get(this.undoTickerId);if(t)for(const i of n)t.add(i);return}if(this.isTicking)for(const t of n)this.excludeIds.add(t)}}undoTickerStart(n,e,t){var i,o,s;if(!this.timingFix){this.legacyUndoTickerStart(n,e);return}if(!t)throw new Error("[appliance-plugin] addUndoTicker expectedAcks is required");if(this.collector&&(this.undoTickerId!==n||this.scenePath!==e)){if(this.undoTickerId&&this.viewId&&this.scenePath){const g=this.undoTickerId,y=this.pendingState.get(g);y&&!this.hasAnyAck(y)?this.clearPendingState(g):y&&!y.graceTimer?y.graceTimer=setTimeout(()=>{this.forceFlushPending(g)},this.gracePeriodTimeout):y||this.undoTickerEndSync(g,this.viewId,this.scenePath)}this.isTicking=!0;const a=this.collector.transformKey(Q);this.excludeIds.add(a),this._undoTickerId=n,this.scenePath=e;const c=((i=this.collector)==null?void 0:i.storage[this.viewId])&&((o=this.collector)==null?void 0:o.storage[this.viewId][this.scenePath])||{},l=new Map(Object.entries(j.cloneDeep(c))),u=new Set([a]);this.tickStartStorerCache=l,this.tickStartCaches.set(n,l),this.tickStartExcludeIds.set(n,u);const h=setTimeout(()=>{this.forceFlushPending(n)},this.doingFallbackTimeout);this.pendingState.set(n,hm({viewId:this.viewId,scenePath:e,expectedAcks:t,fallbackTimer:h})),(s=t.workIds)!=null&&s.length&&this.finalizeRequested(n,e,t.workIds.map(String))}}legacyUndoTickerStart(n,e){var t,i;if(this.collector&&(this.undoTickerId!==n||this.scenePath!==e)){this.undoTickerId&&this.viewId&&this.scenePath&&this.undoTickerEndSync(this.undoTickerId,this.viewId,this.scenePath),this.isTicking=!0;const o=this.collector.transformKey(Q);this.excludeIds.add(o),this._undoTickerId=n,this.scenePath=e;const s=((t=this.collector)==null?void 0:t.storage[this.viewId])&&((i=this.collector)==null?void 0:i.storage[this.viewId][this.scenePath])||{};this.tickStartStorerCache=new Map(Object.entries(j.cloneDeep(s)))}}undoTickerEnd(n,e,t){if(this.timingFix){this.forceFlushPending(n);return}this.undoTickerId&&n===this.undoTickerId&&e===this.scenePath?this.undoTickerEndSync(n,this.viewId,e,!0,t):this.resetLegacyTicker()}undoTickerEndSync(n,e,t,i=!0,o){var c,l;if(o&&o.length)for(const u of o)this.excludeIds.delete(u);const s=n===this.undoTickerId&&e===this.viewId&&t===this.scenePath,a=this.pendingState.has(n)&&e===this.viewId&&!!this.getStartCache(n);if((s||a)&&this.getStartCache(n)){const u=((c=this.collector)==null?void 0:c.storage[e])&&((l=this.collector)==null?void 0:l.storage[e][t])||{},h=this.pendingState.get(n),g=this.diffFun(this.getStartCache(n),new Map(Object.entries(u)),!0,this.getExcludeIds(n),h==null?void 0:h.scopeKeys);g.size&&(this.undoStack.push({id:`${n}-${this.uid}`,data:j.cloneDeep(g),scenePath:t}),this.undoStack.length>et.MaxStackLength&&this.undoStack.shift(),i&&this.emitUndoStepsUpdate(this.undoStack.length),this.redoStack.length&&(this.redoStack.length=0,i&&this.emitRedoStepsUpdate(this.redoStack.length))),s&&(this.isTicking=!1,this.scenePath=void 0,this.tickStartStorerCache=void 0,this._undoTickerId=void 0,this.excludeIds.clear()),this.clearPendingState(n),this.reportStackLength("undo-ticker-end")}}transformToUndoStackItem(n){const e=[];for(const[t,i]of Object.entries(n)){if(!(i!=null&&i.data))continue;const o=new Set;for(const[s,a]of Object.entries(i.data))o.add({key:s,dataType:a.dataType,data:a.data});e.push({id:t,scenePath:i.scenePath,data:o})}return e}pullServiceData(n){if(this.enableGlobal&&this.isGlobalStackTransaction){this.pendingGlobalServiceData=n;return}if(n){const{undoStack:e,redoStack:t}=n;if(e){const i=this.transformToUndoStackItem(e);for(let o=this.undoStack.length-1;o>=0;o--){const s=this.undoStack[o];i.findIndex(c=>c.id===s.id)===-1&&this.undoStack.customSplice(o,1)}for(const o of i){const s=this.undoStack.findIndex(a=>a.id===o.id);s!==-1?this.undoStack[s]=o:this.undoStack.customPush(o)}this.undoStack.sort((o,s)=>{const a=parseInt(o.id.split("-")[0]),c=parseInt(s.id.split("-")[0]);return a-c}),this.emitUndoStepsUpdate(this.undoStack.length)}if(t){const i=this.transformToUndoStackItem(t);for(let o=this.redoStack.length-1;o>=0;o--){const s=this.redoStack[o];i.findIndex(c=>c.id===s.id)===-1&&this.redoStack.customSplice(o,1)}for(const o of i){const s=this.redoStack.findIndex(a=>a.id===o.id);s!==-1?this.redoStack[s]=o:this.redoStack.customPush(o)}this.redoStack.sort((o,s)=>{const a=parseInt(o.id.split("-")[0]);return parseInt(s.id.split("-")[0])-a}),this.emitRedoStepsUpdate(this.redoStack.length)}}else this.clear()}undo(n){var t,i;let e;this.beginGlobalStackTransaction();try{if(this.undoTickerId&&this.tickStartStorerCache&&this.scenePath){const a=this.undoTickerId;this.timingFix&&this.forceFlushPending(a)}if(this.undoTickerId&&this.tickStartStorerCache&&this.scenePath){const a=this.undoTickerId,c=this.scenePath,l=this.getStartCache(a),u=this.pendingState.get(a);if(!l)return this.resetLegacyTicker(),this.undo(n);const h=((t=this.collector)==null?void 0:t.storage[this.viewId])&&((i=this.collector)==null?void 0:i.storage[this.viewId][c])||{},g=this.diffFun(l,new Map(Object.entries(h)),!1,this.getExcludeIds(a),u==null?void 0:u.scopeKeys),y=this.diffFun(l,new Map(Object.entries(h)),!0,this.getExcludeIds(a),u==null?void 0:u.scopeKeys);g.size===y.size?(this.undoStack.push({id:`${a}-${this.uid}`,data:j.cloneDeep(g),scenePath:c}),this.undoStack.length>et.MaxStackLength&&this.undoStack.shift()):g.size&&!y.size&&(e={id:`${a}-${this.uid}`,data:j.cloneDeep(g),scenePath:c}),this.isTicking=!1,this.scenePath=void 0,this.tickStartStorerCache=void 0,this._undoTickerId=void 0,this.excludeIds.clear(),this.clearPendingState(a)}if(e)this.refreshPlugin(e);else{let a=this.undoStack.length-1;for(;a>=0;){const c=this.undoStack[a];if(c.scenePath===n){const l=c.id;c&&(this.redoStack.push(c),c.data&&this.refreshPlugin(c));const u=this.undoStack.findIndex(h=>h.id===l);u!==-1&&this.undoStack.splice(u,1);break}a--}}const o=this.undoStack.filter(a=>a.scenePath===n).length,s=this.redoStack.filter(a=>a.scenePath===n).length;return this.emitUndoStepsUpdate(o),this.emitRedoStepsUpdate(s),this.reportStackLength("undo-final",o,s),o}finally{this.endGlobalStackTransaction()}}redo(n){this.beginGlobalStackTransaction();try{let e=this.redoStack.length-1;for(;e>=0;){const o=this.redoStack[e];if(o.scenePath===n){const s=o.id;o&&(this.undoStack.push(o),o.data&&this.refreshPlugin(o,!0));const a=this.redoStack.findIndex(c=>c.id===s);a!==-1&&this.redoStack.splice(a,1);break}e--}const t=this.undoStack.filter(o=>o.scenePath===n).length,i=this.redoStack.filter(o=>o.scenePath===n).length;return this.emitUndoStepsUpdate(t),this.emitRedoStepsUpdate(i),this.reportStackLength("redo-final",t,i),i}finally{this.endGlobalStackTransaction()}}clear(){this.clearUndo(),this.clearRedo()}clearUndo(){this.undoStack.length=0,this.emitUndoStepsUpdate(this.undoStack.length)}clearRedo(){this.redoStack.length=0,this.emitRedoStepsUpdate(this.redoStack.length)}canUndo(){return!!this.undoStack.length}canRedo(){return!!this.redoStack.length}onFocusView(){const n=this.control.viewContainerManager.getCurScenePath(this.viewId);if(n){const e=this.undoStack.filter(i=>i.scenePath===n).length,t=this.redoStack.filter(i=>i.scenePath===n).length;this.emitUndoStepsUpdate(e),this.emitRedoStepsUpdate(t)}}especialDiff(n,e,t,i){if(e===$e.Update)switch(t==null?void 0:t.toolsType){case S.Text:{if(i!=null&&i.opt&&(t!=null&&t.opt)){const s=j.omit(i.opt,["uid","workState"]),a=j.omit(t.opt,["uid","workState"]);if(n&&j.isEqual(s,a))return!0;i.opt.workState!==D.Done&&(i.opt.workState=D.Done),t.opt.workState!==D.Done&&(t.opt.workState=D.Done)}break}}else if(e===$e.Draw||e===$e.Delete)switch(t==null?void 0:t.toolsType){case S.Text:{if(t!=null&&t.opt){const s=t.opt.text;if(n&&!s)return!0;t.opt.workState!==D.Done&&(t.opt.workState=D.Done)}break}}return!1}normalizeUndoSnapshotValue(n,e){var o,s,a;if(!e)return e;const t=j.cloneDeep(e);if(((s=(o=this.collector)==null?void 0:o.getLocalId)==null?void 0:s.call(o,n))===Q||t.toolsType===S.Selector)return;if(t.toolsType===S.Text)return((a=t.opt)==null?void 0:a.workState)!==D.Done&&(t.opt.workState=D.Done),t;const i=new Set([S.Pencil,S.Arrow,S.Straight,S.Rectangle,S.Ellipse,S.Polygon,S.Star,S.SpeechBalloon]);return t.type===$.DrawWork&&i.has(t.toolsType)&&!t.ops&&Array.isArray(t.op)&&t.op.length&&(t.type=$.FullWork,t.ops=vt(t.op)),t}diffFun(n,e,t=!0,i=this.excludeIds,o){const s=new Set,a=n.keys(),c=e.keys();for(const l of a){if(!Mo(l,i,o))continue;const u=this.normalizeUndoSnapshotValue(l,n.get(l)),h=this.normalizeUndoSnapshotValue(l,e.get(l));if(!(!u&&!h)){if(u&&h){if(j.isEqual(h,u)||this.especialDiff(t,$e.Update,h,u))continue;s.add({dataType:$e.Update,key:l,data:[u,h]});continue}this.especialDiff(t,$e.Delete,u)||u&&s.add({dataType:$e.Delete,key:l,data:u})}}for(const l of c){if(!Mo(l,i,o))continue;const u=this.normalizeUndoSnapshotValue(l,e.get(l));if(u&&!n.has(l)){if(this.especialDiff(t,$e.Draw,u))continue;s.add({dataType:$e.Draw,key:l,data:u})}}return s}isDrawEffectiveScene(n,e){const{key:t}=n;return!e.includes(t)}isDeleteEffectiveScene(n,e){const{key:t}=n;return!!e.includes(t)}isOldEffectiveScene(n,e){const{key:t}=n;return!!e.includes(t)}isNewEffectiveScene(n,e){const{key:t}=n;return!!e.includes(t)}refreshPlugin(n,e=!1){var l,u,h,g,y,d,M,w,m,p,T,v,C,N,k,P,A;let t;const{scenePath:i}=n,o=n.data;if(!o||!this.collector)return;const a={...this.collector.getStorageData(this.viewId,i)||{}};let c=!1;for(const x of o.values()){const{dataType:E,data:b,key:O}=x,Y=this.collector.getStorageData(this.viewId,i),R=Y&&Object.keys(Y)||[];switch(E){case $e.Draw:if(t=e?this.isDrawEffectiveScene(x,R):this.isDeleteEffectiveScene(x,R),t)if(e&&!Array.isArray(b)){if((l=b.updateNodeOpt)!=null&&l.useAnimation&&(b.updateNodeOpt.useAnimation=!1),((u=this.collector)==null?void 0:u.getLocalId(O))===Q&&((h=this.collector)!=null&&h.isOwn(x.key))){const W=b.selectIds;if(W){const B=R.filter(Z=>{var F,X;return((F=this.collector)==null?void 0:F.getLocalId(Z))===Q&&!((X=this.collector)!=null&&X.isOwn(Z))}).map(Z=>{var F;return(F=this.collector)==null?void 0:F.storage[this.viewId][i][Z]});let H=!1;for(const Z of B)for(let F=0;F<W.length;F++)(g=Z==null?void 0:Z.selectIds)!=null&&g.includes(W[F])&&(delete W[F],H=!0);H&&(b.selectIds=W.filter(Z=>!!Z))}}a[x.key]=b,c=!0}else!e&&!Array.isArray(x.data)&&(delete a[x.key],c=!0);break;case $e.Delete:if(t=e?this.isDeleteEffectiveScene(x,R):this.isDrawEffectiveScene(x,R),t){if(e&&!Array.isArray(b))delete a[O],c=!0;else if(!e&&!Array.isArray(b)){if((y=b.updateNodeOpt)!=null&&y.useAnimation&&(b.updateNodeOpt.useAnimation=!1),((d=this.collector)==null?void 0:d.getLocalId(x.key))===Q&&((M=this.collector)!=null&&M.isOwn(x.key))){const W=b.selectIds;if(W){const B=R.filter(Z=>{var F,X;return((F=this.collector)==null?void 0:F.getLocalId(Z))===Q&&!((X=this.collector)!=null&&X.isOwn(Z))}).map(Z=>{var F;return(F=this.collector)==null?void 0:F.storage[this.viewId][i][Z]});let H=!1;for(const Z of B)for(let F=0;F<W.length;F++)(w=Z==null?void 0:Z.selectIds)!=null&&w.includes(W[F])&&(delete W[F],H=!0);H&&(b.selectIds=W.filter(Z=>!!Z))}}a[x.key]=b,c=!0}}break;case $e.Update:if(t=e?this.isNewEffectiveScene(x,R):this.isOldEffectiveScene(x,R),t){if(e&&Array.isArray(b)&&b.length===2){const W=b[1];if((m=W.updateNodeOpt)!=null&&m.useAnimation&&(W.updateNodeOpt.useAnimation=!1),((p=this.collector)==null?void 0:p.getLocalId(x.key))===Q&&((T=this.collector)!=null&&T.isOwn(x.key))){const B=W.selectIds;if(B){const H=R.filter(F=>{var X,ye;return((X=this.collector)==null?void 0:X.getLocalId(F))===Q&&!((ye=this.collector)!=null&&ye.isOwn(F))}).map(F=>{var X;return(X=this.collector)==null?void 0:X.storage[this.viewId][i][F]});let Z=!1;for(const F of H)for(let X=0;X<B.length;X++)F!=null&&F.selectIds&&((v=F.selectIds)!=null&&v.includes(B[X]))&&(delete B[X],Z=!0);Z&&(W.selectIds=B.filter(F=>!!F))}}a[O]=W,c=!0}else if(!e&&Array.isArray(b)&&b.length===2){const W=b[0];if((C=W.updateNodeOpt)!=null&&C.useAnimation&&(W.updateNodeOpt.useAnimation=!1),((N=this.collector)==null?void 0:N.getLocalId(x.key))===Q&&((k=this.collector)!=null&&k.isOwn(x.key))){const B=W.selectIds;if(B){const H=R.filter(F=>{var X,ye;return((X=this.collector)==null?void 0:X.getLocalId(F))===Q&&!((ye=this.collector)!=null&&ye.isOwn(F))}).map(F=>{var X;return(X=this.collector)==null?void 0:X.storage[this.viewId][i][F]});let Z=!1;for(const F of H)for(let X=0;X<B.length;X++)F!=null&&F.selectIds&&F.selectIds.includes(B[X])&&(delete B[X],Z=!0);Z&&(W.selectIds=B.filter(F=>!!F))}}a[x.key]=W,c=!0}}break}}if(c){const x=this.collector.plugin,E=(P=x==null?void 0:x.getAttributesValue)==null?void 0:P.call(x,[_e.namespace]),b=(A=x==null?void 0:x.getAttributesValue)==null?void 0:A.call(x,[_e.namespace,this.viewId]);E?b?x==null||x.updateAttributes([_e.namespace,this.viewId,i],a):x==null||x.updateAttributes([_e.namespace,this.viewId],{[i]:a}):x==null||x.updateAttributes([_e.namespace],{[this.viewId]:{[i]:a}})}}};I(et,"sdkCallBack"),I(et,"MaxStackLength",Ie.undoRedo.maxStackLength),I(et,"waitTime",100);let Kn=et;class At{constructor(n){I(this,"internalMsgEmitter");I(this,"control");I(this,"mainView");I(this,"appViews",new Map);I(this,"undoTickerStart",(n,e,t)=>{const i=this.getView(e);i&&i.displayer&&i.focusScenePath&&i.displayer.commiter.undoTickerStart(n,i.focusScenePath,t)});I(this,"addExcludeIds",(n,e)=>{const t=this.getView(e);t&&t.displayer&&t.focusScenePath&&t.displayer.commiter.addExcludeIds(n)});I(this,"onAckRenderUndoTicker",(n,e,t,i)=>{const o=this.getView(e);if(!(o!=null&&o.displayer)||!o.focusScenePath)return;const s=t||o.focusScenePath;o.displayer.commiter.ackRender(n,s,i)});I(this,"onAckStorageUndoTicker",(n,e,t,i,o)=>{const s=this.getView(e);if(!(s!=null&&s.displayer)||!s.focusScenePath)return;const a=t||s.focusScenePath;s.displayer.commiter.ackStorage(n,a,i,o)});I(this,"onCollectExpectedWorkIds",(n,e,t,i)=>{const o=this.getView(e);if(!(o!=null&&o.displayer)||!o.focusScenePath)return;const s=i||o.focusScenePath;o.displayer.commiter.collectExpectedWorkIds(n,s,t)});I(this,"onFinalizeRequested",(n,e,t,i)=>{const o=this.getView(e);if(!(o!=null&&o.displayer)||!o.focusScenePath)return;const s=i||o.focusScenePath;o.displayer.commiter.finalizeRequested(n,s,t)});I(this,"onReopenStorageAck",(n,e,t,i)=>{const o=this.getView(e);if(!(o!=null&&o.displayer)||!o.focusScenePath)return;const s=i||o.focusScenePath;o.displayer.commiter.reopenStorageAck(n,s,t)});I(this,"onCancelUndoTicker",(n,e,t)=>{const i=this.getView(e);if(!(i!=null&&i.displayer)||!i.focusScenePath)return;const o=t||i.focusScenePath;i.displayer.commiter.cancelUndoTicker(n,e,o)});const{control:e,internalMsgEmitter:t}=n;this.control=e,this.internalMsgEmitter=t,this.internalMsgEmitter.on("addUndoTicker",this.undoTickerStart),this.internalMsgEmitter.on("excludeIds",this.addExcludeIds),this.internalMsgEmitter.on("ackRenderUndoTicker",this.onAckRenderUndoTicker),this.internalMsgEmitter.on("ackStorageUndoTicker",this.onAckStorageUndoTicker),this.internalMsgEmitter.on("collectExpectedWorkIds",this.onCollectExpectedWorkIds),this.internalMsgEmitter.on("reopenStorageAck",this.onReopenStorageAck),this.internalMsgEmitter.on("finalizeRequested",this.onFinalizeRequested),this.internalMsgEmitter.on("cancelUndoTicker",this.onCancelUndoTicker)}get worker(){return this.control.worker}getUndoTickerId(n){const e=this.getView(n);if(e&&e.displayer&&e.focusScenePath)return e.displayer.commiter.undoTickerId}undo(){const n=this.focuedView;let e=0;if(n){const t=n.focusScenePath;e=n.displayer.commiter.undo(t)||0}return e}redo(){const n=this.focuedView;let e=0;if(n){const t=n.focusScenePath;e=n.displayer.commiter.redo(t)||0}return e}validator(n,e,t){var s;const i=j.clone(n[e]),o=j.clone(t);e==="focusScenePath"&&t&&!j.isEqual(i,o)&&(this.control.internalSceneChange(n.id,o),(s=this.focuedView)==null||s.displayer.commiter.onChangeScene()),e==="cameraOpt"&&!j.isEqual(i,o)&&this.control.internalCameraChange(n.id,o)}destroyAppView(n,e=!1){const t=this.appViews.get(n);t&&(this.control.textEditorManager.clear(n,e),t.displayer.destroy(),this.appViews.delete(n))}createMianView(n){this.mainView=new Proxy(n,{set:(e,t,i)=>(this.worker.isActive&&this.validator(e,t,i),e[t]=i,!0)})}createAppView(n){const e=n.id,t=new Proxy(n,{set:(i,o,s)=>(this.worker.isActive&&this.validator(i,o,s),i[o]=s,!0)});this.appViews.set(e,t)}isAppView(n){return n!==re&&this.appViews.has(n)}getView(n){var e;return n===re?this.mainView:(e=this.appViews)==null?void 0:e.get(n)}resolveView(n){const e=n||this.focuedViewId||re,t=this.getView(e);return!n&&!t&&e!==re?{viewId:re,view:this.getView(re)}:{viewId:e,view:t}}getViewElement(n){var e;return((e=n.viewData)==null?void 0:e.divElement)||n.container||n.displayer.eventTragetElement}getFloatbarContainer(n){const{view:e}=this.resolveView(n);return(e==null?void 0:e.displayer.customFloatbarContainerRef.current)||void 0}getViewOffsetToContainer(n,e){if(!n)return;const{viewId:t,view:i}=this.resolveView(e);if(!i)return;const o=this.getViewElement(i);if(!o)return;const s=o.getBoundingClientRect(),a=n.getBoundingClientRect();return{x:s.left-a.left,y:s.top-a.top,viewId:t}}getCurScenePath(n){const e=this.getView(n);if(e)return e.focusScenePath}getAllViews(){return[this.mainView,...this.appViews.values()]}setViewScenePath(n,e){var t;if(n===re&&this.mainView)this.mainView.focusScenePath=e;else{const i=n&&((t=this.appViews)==null?void 0:t.get(n))||void 0;i&&(i.focusScenePath=e)}}setViewData(n,e){var t;if(n===re&&this.mainView)this.mainView.viewData=e;else{const i=n&&((t=this.appViews)==null?void 0:t.get(n))||void 0;i&&(i.viewData=e)}}setFocuedViewId(n){var e;this.focuedViewId=n,n===re?this.focuedView=this.mainView:this.focuedView=n&&((e=this.appViews)==null?void 0:e.get(n))||void 0,this.worker.currentToolsData&&this.worker.currentToolsData.toolsType===S.Text&&this.activeTextEditor(n),this.control.cursor.onFocusViewChange(),this.focuedView&&this.focuedView.displayer.commiter.onFocusView()}setViewFocusScenePath(n,e){var i;let t;n===re?t=this.mainView:t=(i=this.appViews)==null?void 0:i.get(n),t&&(t.focusScenePath=e)}destroy(){var n;this.internalMsgEmitter.off("addUndoTicker",this.undoTickerStart),this.internalMsgEmitter.off("excludeIds",this.addExcludeIds),this.internalMsgEmitter.off("ackRenderUndoTicker",this.onAckRenderUndoTicker),this.internalMsgEmitter.off("ackStorageUndoTicker",this.onAckStorageUndoTicker),this.internalMsgEmitter.off("collectExpectedWorkIds",this.onCollectExpectedWorkIds),this.internalMsgEmitter.off("reopenStorageAck",this.onReopenStorageAck),this.internalMsgEmitter.off("finalizeRequested",this.onFinalizeRequested),this.internalMsgEmitter.off("cancelUndoTicker",this.onCancelUndoTicker),(n=this.mainView)==null||n.displayer.destroy(),this.control.destroyMiniMap(re),this.appViews.forEach(e=>{this.destroyAppView(e.id,!0),this.worker.destroyViewWorker(e.id),this.control.destroyMiniMap(e.id)})}setFocuedViewCameraOpt(n){if(this.focuedView){const e=this.focuedView.cameraOpt;j.isEqual(e,n)||(this.focuedView.cameraOpt=n)}}transformToOriginPoint(n,e){const t=this.getView(e);if(t!=null&&t.viewData){const i=t.viewData.convertToPointOnScreen(n[0],n[1]);return[i.x,i.y]}return n}transformToScenePoint(n,e){const t=this.getView(e);if(t!=null&&t.viewData){const i=t.viewData.convertToPointInWorld({x:n[0],y:n[1]});return[i.x,i.y]}return n}render(n){var e,t,i,o,s,a,c,l,u,h,g,y,d,M,w,m,p;for(const T of n){const{rect:v,imageBitmap:C,isClear:N,isUnClose:k,drawCanvas:P,clearCanvas:A,viewId:x}=T,E=(e=this.getView(x))==null?void 0:e.displayer;if(E&&v){const{dpr:b,canvasBgRef:O,canvasFloatRef:Y,canvasServiceFloatRef:R,canvasTopRef:W}=E,B=Math.floor(v.w*b),H=Math.floor(v.h*b),Z=v.x*b,F=v.y*b;if(N){switch(A){case Xe.TopFloat:(i=(t=W==null?void 0:W.current)==null?void 0:t.getContext("2d"))==null||i.clearRect(Z,F,B,H);break;case Xe.Float:(s=(o=Y.current)==null?void 0:o.getContext("2d"))==null||s.clearRect(Z,F,B,H);break;case Xe.ServiceFloat:(c=(a=R.current)==null?void 0:a.getContext("2d"))==null||c.clearRect(Z,F,B,H);break;case Xe.Bg:(u=(l=O.current)==null?void 0:l.getContext("2d"))==null||u.clearRect(Z,F,B,H);break}continue}if(P&&C)switch(P){case Xe.TopFloat:(g=(h=W==null?void 0:W.current)==null?void 0:h.getContext("2d"))==null||g.drawImage(C,0,0,B,H,Z,F,B,H);break;case Xe.Float:{(d=(y=Y.current)==null?void 0:y.getContext("2d"))==null||d.drawImage(C,0,0,B,H,Z,F,B,H);break}case Xe.ServiceFloat:{(w=(M=R.current)==null?void 0:M.getContext("2d"))==null||w.drawImage(C,0,0,B,H,Z,F,B,H);break}case Xe.Bg:{(p=(m=O.current)==null?void 0:m.getContext("2d"))==null||p.drawImage(C,0,0,B,H,Z,F,B,H);break}}if(k)continue;C==null||C.close()}}}showFloatBar(n,e,t){const i=this.getView(n),o=i==null?void 0:i.displayer.vDom;o&&o.showFloatBar(e,t)}activeTextEditor(n){const e=this.getView(n),t=e==null?void 0:e.displayer.vDom;t&&t.activeTextEditor()}unActiveTextEditor(n){const e=this.getView(n),t=e==null?void 0:e.displayer.vDom;t&&t.unActiveTextEditor()}showFloatBarBtn(n,e){const t=this.getView(n),i=t==null?void 0:t.displayer.vDom;i&&i.showFloatBarBtn(e)}updateTextEditorInfo(n,e){const t=this.getView(n),i=t==null?void 0:t.displayer.vDom;i&&i.updateTextEditorInfo(e)}setActiveMiniMap(n,e){const t=this.getView(n),i=t==null?void 0:t.displayer.vDom;i&&i.setActiveMiniMap(e&&n||void 0)}}I(At,"defaultCameraOpt",{centerX:0,centerY:0,scale:1}),I(At,"defaultScreenCanvasOpt",{autoRender:!1,contextType:"2d"}),I(At,"defaultLayerOpt",{offscreen:!0,handleEvent:!1,depth:!1});class pr{constructor(n,e,t){I(this,"control");I(this,"internalMsgEmitter");I(this,"commiter");I(this,"cachePoint");I(this,"cacheCursorPoint");I(this,"active",!0);I(this,"toolsKey");I(this,"activePointers",new Set);I(this,"currentDrawingPointerId");I(this,"cursorMouseMove");I(this,"cursorMouseMoveDebounced");I(this,"cursorMouseMoveThrottled");I(this,"cursorMouseMoveFun");I(this,"_transferControlToOffscreenCanvas");I(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)});I(this,"keydown",n=>{n.stopPropagation(),n.stopImmediatePropagation(),this.control.hotkeyManager.colloctHotkey(n)});I(this,"pointerdown",n=>{var e;if(this.active){if(n.pointerType==="touch"&&(this.activePointers.add(n.pointerId),this.activePointers.size>1)){this.worker.unWritable(),this.viewId&&this.worker.removeDrawingWork(this.viewId),document.removeEventListener("pointermove",this.pointermove,!1),document.removeEventListener("pointerup",this.pointerup,!1),document.removeEventListener("pointercancel",this.pointerup,!1),this.currentDrawingPointerId=void 0,this.cachePoint=void 0,this.activePointers.clear();return}if(n.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(n);this.cachePoint=t,t&&(this.currentDrawingPointerId=n.pointerId,this.worker.originalEventLintener(D.Start,t,this.viewId),document.addEventListener("pointermove",this.pointermove,!1),document.addEventListener("pointerup",this.pointerup,!1),document.addEventListener("pointercancel",this.pointerup,!1))}}});I(this,"pointermove",n=>{if(this.active){if(n.pointerType==="touch"){if(this.activePointers.size>1){this.worker.unWritable(),this.worker.removeDrawingWork(this.viewId);return}if(this.currentDrawingPointerId!==void 0&&n.pointerId!==this.currentDrawingPointerId)return;if(!this.worker.isAbled()){this.worker.unWritable(),this.worker.removeDrawingWork(this.viewId);return}}if(this.viewId){const e=this.getPoint(n);if(this.cachePoint=e,this.checkConsumeCount())return;e&&this.worker.originalEventLintener(D.Doing,e,this.viewId)}}});I(this,"pointerup",n=>{if(this.active&&(n.pointerType==="touch"&&this.activePointers.delete(n.pointerId),!(this.currentDrawingPointerId!==void 0&&n.pointerId!==this.currentDrawingPointerId))){if(this.currentDrawingPointerId===void 0){document.removeEventListener("pointermove",this.pointermove,!1),document.removeEventListener("pointerup",this.pointerup,!1),document.removeEventListener("pointercancel",this.pointerup,!1);return}if(n.pointerType==="touch"&&(this.activePointers.size>0||!this.worker.isAbled())){this.worker.unWritable(),this.worker.removeDrawingWork(this.viewId),document.removeEventListener("pointermove",this.pointermove,!1),document.removeEventListener("pointerup",this.pointerup,!1),document.removeEventListener("pointercancel",this.pointerup,!1),this.cachePoint=void 0,this.currentDrawingPointerId=void 0;return}if(n.button===0&&this.viewId){const e=this.getPoint(n)||this.cachePoint;e?(this.worker.originalEventLintener(D.Done,e,this.viewId).finally(()=>{document.removeEventListener("pointermove",this.pointermove,!1),document.removeEventListener("pointerup",this.pointerup,!1),document.removeEventListener("pointercancel",this.pointerup,!1)}),this.cachePoint=void 0,this.currentDrawingPointerId=void 0):(document.removeEventListener("pointermove",this.pointermove,!1),document.removeEventListener("pointerup",this.pointerup,!1),document.removeEventListener("pointercancel",this.pointerup,!1),this.currentDrawingPointerId=void 0)}n.pointerType==="touch"&&this.activePointers.size===0&&this.activePointers.clear()}});this.control=n,this.internalMsgEmitter=e;const i={control:this.control,internalMsgEmitter:this.internalMsgEmitter,viewId:t,enableGlobal:!!this.control.pluginOptions.extras.undoRedo.enableGlobal};this.commiter=new Kn(i),this.cursorMouseMoveFun=o=>{const s=this.getPoint(o);this.cacheCursorPoint&&j.isEqual(s,this.cacheCursorPoint)||(this.cacheCursorPoint=s,s&&this.worker.sendCursorEvent(s,this.viewId))},this.cursorMouseMoveDebounced=j.debounce(this.cursorMouseMoveFun,this.moveDelayTime,{trailing:!0}),this.cursorMouseMoveThrottled=j.throttle(this.cursorMouseMoveFun,this.moveDelayTime,{leading:!0}),this.cursorMouseMove=o=>{this.control.pluginOptions.extras.cursor.enable?this.cursorMouseMoveThrottled(o):this.cursorMouseMoveDebounced(o)},this.setActive(n.renderControl.isWritable)}get moveDelayTime(){var n,e;return((e=(n=this.control.pluginOptions.extras)==null?void 0:n.cursor)==null?void 0:e.moveDelayTime)??Ie.cursor.moveDelayTime}setTransferControlToOffscreenCanvas(n){this._transferControlToOffscreenCanvas={bgCanvas:n.bgCanvas.transferControlToOffscreen(),serviceCanvas:n.serviceCanvas.transferControlToOffscreen(),localCanvas:n.localCanvas.transferControlToOffscreen()}}get transferControlToOffscreenCanvas(){return this._transferControlToOffscreenCanvas}get worker(){return this.control.worker}bindToolsClass(){var i,o;const n=(o=(i=this.worker)==null?void 0:i.currentToolsData)==null?void 0:o.toolsType,e=this.control.renderControl.isWritable,t=this.worker.isAbled();switch(n){case S.Text:case S.Pencil:case S.LaserPen:case S.Arrow:case S.Straight:case S.Rectangle:case S.Ellipse:case S.Star:case S.Polygon:case S.SpeechBalloon:case S.Eraser:case S.PencilEraser:case S.BitMapEraser:case S.Selector:this.eventTragetElement&&(this.eventTragetElement.className=e&&t?`netless-whiteboard ${n===S.Selector?"cursor-selector":n===S.Text?"cursor-text":n===S.Eraser||n===S.PencilEraser||n===S.BitMapEraser?"cursor-eraser":n===S.Pencil||n===S.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 n;return(n=this.eventTragetElement)==null?void 0:n.parentElement}destroy(){this.eventTragetElement&&this.removeDisplayerEvent(this.eventTragetElement),this.vDom=void 0,this.control.cursor.clearViewCursor(this.viewId),this.internalMsgEmitter.removeAllListeners([ne.Cursor,this.viewId])}getPoint(n){const e=gr(n);if(e&&j.isNumber(e.x)&&j.isNumber(e.y))return[e.x-this.containerOffset.x,e.y-this.containerOffset.y]}getActive(){return this.active}setActive(n){this.active=n,this.control.isUseBackgroundThread&&this.backgroundContainerRef&&this.backgroundContainerRef.current&&this.backgroundContainerRef.current.classList.toggle("appliance-plugin-background-isWritable",n)}focusElement(){var n;(n=this.eventTragetElement)==null||n.focus()}async stopEventHandler(){this.cachePoint&&(await this.worker.originalEventLintener(D.Done,this.cachePoint,this.viewId).finally(()=>{document.removeEventListener("pointermove",this.pointermove,!1),document.removeEventListener("pointerup",this.pointerup,!1),document.removeEventListener("pointercancel",this.pointerup,!1)}),this.cachePoint=void 0,this.activePointers.clear(),this.currentDrawingPointerId=void 0)}getTranslate(n){const t=(n.style.WebkitTransform||getComputedStyle(n,"").getPropertyValue("-webkit-transform")||n.style.transform||getComputedStyle(n,"").getPropertyValue("transform")).match(/-?[0-9]+\.?[0-9]*/g),i=t&&parseInt(t[0])||0,o=t&&parseInt(t[1])||0;return[i,o]}getContainerOffset(n,e){var o;const t=this.getTranslate(n);let i={x:e.x+n.offsetLeft-n.scrollLeft+t[0],y:e.y+n.offsetTop-n.scrollTop+t[1]};return(o=n.offsetParent)!=null&&o.nodeName&&n.offsetParent.nodeName!=="BODY"&&(i=this.getContainerOffset(n.offsetParent,i)),i}bindDisplayerEvent(n){n.addEventListener("pointerdown",this.pointerdown,!1),n.addEventListener("mousemove",this.cursorMouseMove,!1),n.addEventListener("mouseleave",this.cursorMouseLeave,!1),n.addEventListener("keydown",this.keydown,!0)}removeDisplayerEvent(n){n.removeEventListener("pointerdown",this.pointerdown,!1),document.removeEventListener("pointermove",this.pointermove,!1),document.removeEventListener("pointerup",this.pointerup,!1),document.removeEventListener("pointerleave",this.pointerup,!1),n.removeEventListener("mousemove",this.cursorMouseMove,!1),n.removeEventListener("mouseleave",this.cursorMouseLeave,!1),n.removeEventListener("keydown",this.keydown,!0)}get isBezier(){return this.control.pluginOptions.extras.bezier.enable}get maxDrawCount(){return this.control.pluginOptions.extras.bezier.maxDrawCount||Ie.bezier.maxDrawCount}checkConsumeCount(){const n=this.worker.getConsumeCount();return this.cachePoint&&this.toolsKey&&this.toolsKey===S.Pencil&&n>this.maxDrawCount?(this.stopEventHandler().finally(()=>{this.worker.publicMsgEmitter.emit("forceStop",ni.longPencil,this.viewId)}),!0):!1}}class Mm extends pr{constructor(e,t,i){super(t,i,e);I(this,"_viewId");this._viewId=e}get viewId(){return this._viewId}setViewId(e){this._viewId=e}}class Mr extends pr{constructor(n,e){super(n,e,re)}get viewId(){return re}updateSize(){this.setCanvassStyle()}destroy(){super.destroy(),this.control.cursor.destroy()}}const ym="index-module__Container__nLsM3",mm="index-module__BackgroundBox__zfthZ",Im="index-module__BackgroundSvgBox__Fv1ay",wm="index-module__BackgroundSnapshotContent__NFLAl",Tm="index-module__BackgroundSnapshotBox__NEM-C",Sm="index-module__CanvasBox__j2Xe-",vm="index-module__FloatCanvas__d1YR7",Nm="index-module__TopFloatCanvas__7IaCw",Cm="index-module__CanvasBoxSub__hcMeK",km="index-module__SnapshotBox__--eeE",xm="index-module__FloatBar__cm-EL",bm="index-module__RotateBtn__HSSkf",Dm="index-module__ResizeBtn__yjvda",jm="index-module__CursorBox__2UHvI",Em="index-module__TextEditorContainer__Qm8KC",Am="index-module__ResizeTowBox__HOllX",zm="index-module__FloatBarBtn__FJrOG",ke={Container:ym,BackgroundBox:mm,BackgroundSvgBox:Im,BackgroundSnapshotContent:wm,BackgroundSnapshotBox:Tm,CanvasBox:Sm,FloatCanvas:vm,TopFloatCanvas:Nm,CanvasBoxSub:Cm,SnapshotBox:km,FloatBar:xm,RotateBtn:bm,ResizeBtn:Dm,CursorBox:jm,TextEditorContainer:Em,ResizeTowBox:Am,FloatBarBtn:zm},Lm={delete:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+P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Q1LTEuNTg0IDIuMzk0IDcuMTgyLTcuMjIyLTIuNDA4IDEuNzkxLTEuNzlBOC44NDYgOC44NDYgMCAwIDEgMy4xMjUgMTJjMC0yLjI3MS44NjYtNC41NDMgMi42LTYuMjc2eiIgc3Ryb2tlPSIjRkZGIiBzdHJva2Utd2lkdGg9Ii41IiBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9Im5vbnplcm8iLz48L2c+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+PHBhdGggZD0iTTEyIDJ2NWE0IDQgMCAxIDEtOCAw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zNC00NS4yMjY2NjctNDUuMjI2NjY2eiIgIGZpbGw9IiM0NDRFNjAiPjwvcGF0aD48L3N2Zz4="};function Le(r){return Lm[r]}const Pm=r=>{const{workIds:n,mananger:e}=r;return f.createElement("div",{className:"button normal-button",style:{touchAction:"none"},onPointerUp:t=>{t.cancelable&&t.preventDefault(),t.stopPropagation(),t.nativeEvent.stopImmediatePropagation(),te.emitMethod(ne.MainEngine,U.DeleteNode,{workIds:n||[Q],viewId:e.viewId})}},f.createElement("img",{alt:"icon",src:Le("delete")}))},Rm=r=>{const{workIds:n,viewId:e}=r;return f.createElement("div",{className:"button normal-button",onPointerUp:t=>{t.stopPropagation(),te.emitMethod(ne.MainEngine,U.CopyNode,{workIds:n||[Q],viewId:e})}},f.createElement("img",{alt:"icon",src:Le("duplicate")}))},yo=r=>{const{icon:n,onPointerUpHandler:e}=r;return f.createElement("div",{className:"button normal-button",onPointerUp:e},f.createElement("img",{src:Le(n)}))},Om=r=>{const{open:n,setOpen:e,floatBarRef:t}=r,{floatBarData:i,mananger:o}=f.useContext(Ne),[s,a]=f.useState([]),c=f.useMemo(()=>{if(t!=null&&t.current&&j.isNumber(i==null?void 0:i.y)&&(o!=null&&o.height)){if(t.current.offsetTop&&t.current.offsetTop+i.y>180){const h={};return h.top="inherit",h.bottom=50,h}else if(!t.current.offsetTop&&(o==null?void 0:o.height)-t.current.offsetTop-i.y<120){const h={};return h.top="inherit",h.bottom=50,h}}},[t==null?void 0:t.current,i,o]),l=f.useMemo(()=>n?f.createElement("div",{className:"image-layer-menu",style:c},f.createElement(yo,{icon:"to-top",onPointerUpHandler:h=>{h.stopPropagation(),te.emitMethod(ne.MainEngine,U.ZIndexNode,{workIds:[Q],layer:st.Top,viewId:o==null?void 0:o.viewId})}}),f.createElement(yo,{icon:"to-bottom",onPointerUpHandler:h=>{h.stopPropagation(),te.emitMethod(ne.MainEngine,U.ZIndexNode,{workIds:[Q],layer:st.Bottom,viewId:o==null?void 0:o.viewId})}})):null,[n,c]),u=h=>{h.stopPropagation(),h.nativeEvent.stopImmediatePropagation(),e(!n)};return f.useEffect(()=>{j.isEqual(i==null?void 0:i.selectIds,s)||i!=null&&i.selectIds&&!j.isEqual(i==null?void 0:i.selectIds,s)&&(a(i==null?void 0:i.selectIds),e(!1))},[n,i,s,e]),f.createElement("div",{className:`button normal-button ${n&&"active"}`,onPointerUp:u},l,f.createElement("img",{alt:"icon",src:Le(n?"layer-pressed":"layer")}))},nn=r=>{r.stopPropagation(),r.nativeEvent.stopImmediatePropagation()},Um=()=>f.createElement("svg",{style:{marginLeft:"2px"},viewBox:"0 0 1025 1024",width:"14",height:"14"},f.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"})),yr=r=>{const{activeColor:n,onPointerUpHandler:e}=r;return f.createElement("div",{className:`font-color-button ${n==="transparent"?"active":""}`,onPointerUp:e},f.createElement("div",{className:"circle none"}))},xn=r=>{const{color:n,activeColor:e,onPointerUpHandler:t}=r;return f.createElement("div",{className:`font-color-button ${n===e?"active":""}`,onPointerUp:t},f.createElement("div",{className:"circle",style:{backgroundColor:Ee(n,1)}}))},bn=r=>{const{opacity:n,activeColor:e,setCurOpacity:t}=r,[i,o]=f.useState({x:108,y:0}),s=f.useRef(0);if(f.useEffect(()=>{o({x:n*100+8,y:0})},[]),!e)return null;const a=(h,g)=>{const y=Math.min(Math.max(h-8,0),100)/100;(n!==y||g===D.Done)&&t(y,e,g)},c=(h,g)=>{g.x!==(i==null?void 0:i.x)&&o({x:g.x,y:0}),!s.current&&(s.current=setTimeout(()=>{s.current=0,a(g.x,D.Doing)},100))},l=()=>{t(n,e,D.Start)},u=(h,g)=>{g.x!==(i==null?void 0:i.x)&&o({x:g.x,y:0}),s.current&&(clearTimeout(s.current),s.current=0),a(g.x,D.Done)};return f.createElement("div",{className:"font-color-opacity",style:{marginLeft:"10px"},onPointerUp:h=>{s.current&&(clearTimeout(s.current),s.current=0);const g=h.nativeEvent.offsetX,y=Math.min(Math.max(g-12,0),100)/100;o({x:y*100+8,y:0}),t(y,e,D.Done)}},f.createElement("div",{className:"range-color",style:{background:`linear-gradient(to right, ${Ee(e,0)}, ${Ee(e,1)})`}}),f.createElement("div",{className:"range-opacity"},f.createElement(Lt,{bounds:"parent",axis:"x",position:i,onDrag:c,onStart:l,onStop:u},f.createElement("div",{className:"circle",style:{backgroundColor:Ee(e,n)},onPointerUp:nn}))))},Ym=r=>{const{min:n,max:e,activeNumber:t,setActiveNumber:i,color:o}=r,[s,a]=f.useState({x:108,y:0}),c=f.useRef(0);if(f.useEffect(()=>{const y=Math.ceil((t-n)/(e-n)*100)+8;a({x:y,y:0})},[]),!t)return null;const l=(y,d)=>{const M=Math.ceil(Math.max(y-8,0)/100*(e-n)+n);(t!==M||d===D.Done)&&i(M,d)},u=(y,d)=>{d.x!==(s==null?void 0:s.x)&&a({x:d.x,y:0}),!c.current&&(c.current=setTimeout(()=>{c.current=0,l(d.x,D.Doing)},100))},h=()=>{i(t,D.Start)},g=(y,d)=>{d.x!==(s==null?void 0:s.x)&&a({x:d.x,y:0}),c.current&&(clearTimeout(c.current),c.current=0),l(d.x,D.Done)};return f.createElement("div",{className:"font-color-opacity",style:{marginLeft:"10px"},onPointerUp:y=>{c.current&&(clearTimeout(c.current),c.current=0);const d=y.nativeEvent.offsetX,M=Math.ceil(Math.max(d-12,0)/100*(e-n)+n),w=Math.ceil((M-n)/(e-n)*100)+8;a({x:w,y:0}),i(M,D.Done)}},f.createElement("div",{className:"range-color",style:{backgroundColor:o}}),f.createElement("div",{className:"range-opacity"},f.createElement(Lt,{bounds:"parent",axis:"x",position:s,onDrag:u,onStart:h,onStop:g},f.createElement("div",{className:"circle",style:{backgroundColor:o},onPointerUp:nn},f.createElement("div",{className:"range-opacity-data-icon"},t)))))},Bm=r=>{const{useStroke:n,color:e,activeStrokeType:t,setStrokeType:i}=r;return f.createElement("div",{className:"stroke-type-box"},!!n&&f.createElement("div",{className:`stroke-type-box-item Stroke ${t===ce.Stroke&&"active"}`,style:{backgroundColor:e},onPointerUp:()=>{i(ce.Stroke)}}),f.createElement("div",{className:`stroke-type-box-item Normal ${t===ce.Normal&&"active"}`,style:{borderColor:e},onPointerUp:()=>{i(ce.Normal)}}),f.createElement("div",{className:`stroke-type-box-item Dotted ${t===ce.Dotted&&"active"}`,style:{borderColor:e},onPointerUp:()=>{i(ce.Dotted)}}),f.createElement("div",{className:`stroke-type-box-item LongDotted ${t===ce.LongDotted&&"active"}`,style:{borderColor:e},onPointerUp:()=>{i(ce.LongDotted)}}))},$m=r=>{const{open:n,setOpen:e,floatBarRef:t}=r,{floatBarData:i,floatBarColors:o,mananger:s,setFloatBarData:a}=f.useContext(Ne),[c,l]=f.useState(),[u,h]=f.useState(1);f.useEffect(()=>{if(i!=null&&i.strokeColor){const[p,T]=Nn(i.strokeColor);l(p),h(T)}},[i]);const g=f.useMemo(()=>{if(t!=null&&t.current&&i&&j.isNumber(i==null?void 0:i.y)&&(s!=null&&s.height)){if(t.current.offsetTop&&t.current.offsetTop+i.y>180){const p={};return p.top="inherit",p.bottom=50,p}else if(!t.current.offsetTop&&(s==null?void 0:s.height)-t.current.offsetTop-i.y<120){const p={};return p.top="inherit",p.bottom=50,p}}},[i,t,s==null?void 0:s.height]),y=f.useMemo(()=>f.createElement(bn,{key:"strokeColors",opacity:u,activeColor:c,setCurOpacity:(p,T,v)=>{h(p);const C=Ee(T,p);i!=null&&i.strokeColor&&a({strokeColor:C}),te.emitMethod(ne.MainEngine,U.SetColorNode,{workIds:[Q],strokeColor:C,workState:v,viewId:s==null?void 0:s.viewId})}}),[u,c,i==null?void 0:i.strokeColor,s==null?void 0:s.viewId,a]),d=f.useMemo(()=>c&&i&&i.thickness?f.createElement(Ym,{key:"strokeThickness",min:Math.min(i.thickness,(s==null?void 0:s.control.pluginOptions.extras.strokeWidth.min)||Ie.strokeWidth.min),max:Math.max(i.thickness,(s==null?void 0:s.control.pluginOptions.extras.strokeWidth.max)||Ie.strokeWidth.max),activeNumber:i.thickness,setActiveNumber:(p,T)=>{i!=null&&i.thickness&&a({thickness:p}),te.emitMethod(ne.MainEngine,U.SetColorNode,{workIds:[Q],thickness:p,workState:T,viewId:s==null?void 0:s.viewId})},color:c}):null,[c,i,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]),M=f.useMemo(()=>c&&i&&(i!=null&&i.strokeType)?f.createElement(Bm,{key:"strokeType",useStroke:i==null?void 0:i.useStroke,activeStrokeType:i.strokeType,setStrokeType:p=>{i.strokeType&&a({strokeType:p}),te.emitMethod(ne.MainEngine,U.SetColorNode,{workIds:[Q],strokeType:p,workState:D.Done,viewId:s==null?void 0:s.viewId})},color:c}):null,[c,i,s==null?void 0:s.viewId,a]),w=f.useMemo(()=>n?f.createElement("div",{className:"font-colors-menu",style:g,onPointerUp:p=>{p.stopPropagation(),p.nativeEvent.stopImmediatePropagation()}},M,d,f.createElement("div",{className:"font-colors-line"}),o.concat().map((p,T)=>{const v=tn(...p);return f.createElement(xn,{key:T,color:v,activeColor:c,onPointerUpHandler:C=>{C.stopPropagation(),l(v);const N=Ee(v,u);i!=null&&i.strokeColor&&(i.strokeColor=N,a({strokeColor:N})),te.emitMethod(ne.MainEngine,U.SetColorNode,{workIds:[Q],workState:D.Done,strokeColor:N,viewId:s==null?void 0:s.viewId})}})}),y):null,[n,g,M,d,o,y,c,u,i,s==null?void 0:s.viewId,a]),m=f.useMemo(()=>c?f.createElement("div",{className:"color-bar-ring",style:{backgroundColor:Ee(c,u)}},f.createElement("div",{className:"circle"})):null,[c,u]);return f.createElement("div",{className:`button normal-button font-colors-icon ${n&&"active"}`,onPointerUp:p=>{p.stopPropagation(),p.nativeEvent.stopImmediatePropagation(),e(!n)}},m,w)},Wm=r=>{const{open:n,setOpen:e,floatBarRef:t}=r,{floatBarData:i,floatBarColors:o,mananger:s,setFloatBarData:a}=f.useContext(Ne),[c,l]=f.useState(),[u,h]=f.useState(1);f.useEffect(()=>{if(i!=null&&i.fillColor){const[w,m]=(i==null?void 0:i.fillColor)==="transparent"&&["transparent",1]||Nn(i.fillColor);l(w),h(m)}},[i]);const g=f.useMemo(()=>{if(t!=null&&t.current&&j.isNumber(i==null?void 0:i.y)&&(s!=null&&s.height)){if(t.current.offsetTop&&t.current.offsetTop+i.y>200){const w={};return w.top="inherit",w.bottom=50,w}else if(!t.current.offsetTop&&(s==null?void 0:s.height)-t.current.offsetTop-i.y<140){const w={};return w.top="inherit",w.bottom=50,w}}},[t,i,s==null?void 0:s.height]),y=f.useMemo(()=>c&&c!=="transparent"?f.createElement(bn,{key:"fillColors",opacity:u||0,activeColor:c,setCurOpacity:(w,m,p)=>{h(w);const T=Ee(m,w);i!=null&&i.fillColor&&(i.fillColor=T,a({fillColor:T})),te.emitMethod(ne.MainEngine,U.SetColorNode,{workIds:[Q],fillColor:c&&Ee(m,w),workState:p,viewId:s==null?void 0:s.viewId})}}):null,[c,u,i,s==null?void 0:s.viewId,a]),d=f.useMemo(()=>n?f.createElement("div",{className:"font-colors-menu",style:g,onPointerUp:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()}},f.createElement(yr,{activeColor:c,onPointerUpHandler:w=>{w.stopPropagation(),l("transparent");const m="transparent";i!=null&&i.fillColor&&(i.fillColor=m,a({fillColor:m})),te.emitMethod(ne.MainEngine,U.SetColorNode,{workIds:[Q],workState:D.Done,fillColor:m,viewId:s==null?void 0:s.viewId})}}),o.map((w,m)=>{const p=tn(...w);return f.createElement(xn,{key:m,color:p,activeColor:c,onPointerUpHandler:T=>{T.cancelable&&T.preventDefault(),T.stopPropagation(),l(p);const v=Ee(p,u);i!=null&&i.fillColor&&(i.fillColor=v,a({fillColor:v})),te.emitMethod(ne.MainEngine,U.SetColorNode,{workIds:[Q],workState:D.Done,fillColor:v,viewId:s==null?void 0:s.viewId})}})}),y):null,[n,g,c,o,y,i,s==null?void 0:s.viewId,a,u]),M=f.useMemo(()=>{const w=c&&c!=="transparent"&&Ee(c,u)||"transparent";return f.createElement("div",{className:"color-bar-fill"},f.createElement("div",{className:"circle",style:{backgroundColor:w}}))},[c,u]);return f.createElement("div",{className:`button normal-button font-colors-icon ${n&&"active"}`,onPointerUp:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation(),e(!n)}},M,d)},Vm=r=>{const{open:n,setOpen:e,textOpt:t,workIds:i,floatBarRef:o}=r,{floatBarColors:s,mananger:a,setFloatBarData:c,floatBarData:l}=f.useContext(Ne),[u,h]=f.useState(),[g,y]=f.useState(1);f.useEffect(()=>{if(t!=null&&t.fontColor){const[p,T]=(t==null?void 0:t.fontColor)==="transparent"&&["transparent",0]||Nn(t.fontColor);h(p),y(T)}},[t==null?void 0:t.fontColor]);const d=f.useMemo(()=>{if(o!=null&&o.current&&l&&j.isNumber(l==null?void 0:l.y)&&(a!=null&&a.height)){if(o.current.offsetTop&&o.current.offsetTop+l.y>180){const p={};return p.top="inherit",p.bottom=50,p}else if(!o.current.offsetTop&&(a==null?void 0:a.height)-o.current.offsetTop-l.y<120){const p={};return p.top="inherit",p.bottom=50,p}}},[o,l,a==null?void 0:a.height]),M=f.useMemo(()=>u&&u!=="transparent"?f.createElement(bn,{key:"fontColors",opacity:g,activeColor:u,setCurOpacity:(p,T,v)=>{y(p);const C=Ee(T,p);l!=null&&l.textOpt&&(l.textOpt.fontColor=C,c({textOpt:l.textOpt})),te.emitMethod(ne.MainEngine,U.SetColorNode,{workIds:i||[Q],fontColor:u&&C,workState:v,viewId:a==null?void 0:a.viewId})}}):null,[c,u,g,a==null?void 0:a.control.room,a==null?void 0:a.viewId,l==null?void 0:l.textOpt,i]),w=f.useMemo(()=>n?f.createElement("div",{className:"font-colors-menu",style:d,onPointerUp:p=>{p.stopPropagation(),p.nativeEvent.stopImmediatePropagation()}},s.map((p,T)=>{const v=tn(...p);return f.createElement(xn,{key:T,color:v,activeColor:u,onPointerUpHandler:C=>{C.stopPropagation(),h(v);const N=Ee(v,g);l!=null&&l.textOpt&&(l.textOpt.fontColor=N,c({textOpt:l.textOpt})),te.emitMethod(ne.MainEngine,U.SetColorNode,{workIds:i||[Q],workState:D.Done,fontColor:N,viewId:a==null?void 0:a.viewId})}})}),M):null,[c,n,s,M,u,g,l==null?void 0:l.textOpt,i,a==null?void 0:a.viewId,d]),m=f.useMemo(()=>{const p=u&&u!=="transparent"&&Ee(u,g)||"transparent";return f.createElement("div",{className:"color-bar"},f.createElement("div",{className:"color-bar-color",style:{backgroundColor:p}}))},[u,g]);return f.createElement("div",{className:`button normal-button font-colors-icon ${n&&"active"}`,onPointerUp:p=>{p.stopPropagation(),p.nativeEvent.stopImmediatePropagation(),e(!n)}},f.createElement("img",{alt:"icon",src:Le("font-colors")}),m,w)},Fm=r=>{const{open:n,setOpen:e,textOpt:t,workIds:i,floatBarRef:o}=r,{floatBarColors:s,mananger:a,setFloatBarData:c,floatBarData:l}=f.useContext(Ne),[u,h]=f.useState(),[g,y]=f.useState(1);f.useEffect(()=>{if(t!=null&&t.fontBgColor){const[p,T]=(t==null?void 0:t.fontBgColor)==="transparent"&&["transparent",1]||Nn(t.fontBgColor);h(p),y(T)}},[t==null?void 0:t.fontBgColor]);const d=f.useMemo(()=>{if(o!=null&&o.current&&l&&j.isNumber(l==null?void 0:l.y)&&(a!=null&&a.height)){if(o.current.offsetTop&&o.current.offsetTop+l.y>180){const p={};return p.top="inherit",p.bottom=50,p}else if(!o.current.offsetTop&&(a==null?void 0:a.height)-o.current.offsetTop-l.y<120){const p={};return p.top="inherit",p.bottom=50,p}}},[o,l,a==null?void 0:a.height]),M=f.useMemo(()=>u&&u!=="transparent"?f.createElement(bn,{key:"fontBgColor",opacity:g||0,activeColor:u,setCurOpacity:(p,T,v)=>{y(p);const C=Ee(T,p);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=C,c({textOpt:l.textOpt})),te.emitMethod(ne.MainEngine,U.SetColorNode,{workIds:i||[Q],fontBgColor:u&&Ee(T,p),workState:v,viewId:a==null?void 0:a.viewId})}}):null,[u,g,l==null?void 0:l.textOpt,i,a==null?void 0:a.viewId,c]),w=f.useMemo(()=>n?f.createElement("div",{className:"font-colors-menu",style:d,onPointerUp:p=>{p.stopPropagation(),p.nativeEvent.stopImmediatePropagation()}},f.createElement(yr,{activeColor:u,onPointerUpHandler:p=>{p.stopPropagation();const T="transparent";h(T),l!=null&&l.textOpt&&(l.textOpt.fontBgColor=T,c({textOpt:l.textOpt})),te.emitMethod(ne.MainEngine,U.SetColorNode,{workIds:i||[Q],workState:D.Done,fontBgColor:T,viewId:a==null?void 0:a.viewId})}}),s.map((p,T)=>{const v=tn(...p);return f.createElement(xn,{key:T,color:v,activeColor:u,onPointerUpHandler:C=>{C.stopPropagation(),h(v);const N=Ee(v,g);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=N,c({textOpt:l.textOpt})),te.emitMethod(ne.MainEngine,U.SetColorNode,{workIds:i||[Q],workState:D.Done,fontBgColor:Ee(v,g),viewId:a==null?void 0:a.viewId})}})}),M):null,[c,n,s,M,g,u,l==null?void 0:l.textOpt,i,a==null?void 0:a.viewId,d]),m=f.useMemo(()=>{const p=u&&u!=="transparent"&&Ee(u,g)||"transparent";return f.createElement("div",{className:"color-bar",style:{marginTop:0}},f.createElement("div",{className:"color-bar-color",style:{backgroundColor:p}}))},[u,g]);return f.createElement("div",{className:`button normal-button font-colors-icon ${n&&"active"}`,onPointerUp:p=>{p.stopPropagation(),p.nativeEvent.stopImmediatePropagation(),e(!n)}},f.createElement(Um,null),m,w)},Gm=r=>{const{bold:n,setBold:e,workIds:t,viewId:i}=r,o=s=>{const a=n==="bold"?"normal":"bold";s==null||s.stopPropagation(),e(a),te.emitMethod(ne.MainEngine,U.SetFontStyle,{workIds:t,viewId:i,bold:a})};return f.createElement("div",{className:"font-style-button",onPointerUp:o},f.createElement("img",{alt:"icon",src:Le(n==="bold"?"bold-active":"bold")}))},Qm=r=>{const{underline:n,setUnderline:e,workIds:t,viewId:i}=r,o=s=>{const a=!n;s==null||s.stopPropagation(),e(a),te.emitMethod(ne.MainEngine,U.SetFontStyle,{workIds:t,viewId:i,underline:a})};return f.createElement("div",{className:"font-style-button",onPointerUp:o},f.createElement("img",{alt:"icon",src:Le(n?"underline-active":"underline")}))},Zm=r=>{const{lineThrough:n,setLineThrough:e,workIds:t,viewId:i}=r,o=s=>{const a=!n;s==null||s.stopPropagation(),e(a),te.emitMethod(ne.MainEngine,U.SetFontStyle,{workIds:t,viewId:i,lineThrough:a})};return f.createElement("div",{className:"font-style-button",onPointerUp:o},f.createElement("img",{alt:"icon",src:Le(n?"line-through-active":"line-through")}))},Hm=r=>{const{italic:n,setItalic:e,workIds:t,viewId:i}=r,o=s=>{const a=n==="italic"?"normal":"italic";s==null||s.stopPropagation(),e(a),te.emitMethod(ne.MainEngine,U.SetFontStyle,{workIds:t,viewId:i,italic:a})};return f.createElement("div",{className:"font-style-button",onPointerUp:o},f.createElement("img",{alt:"icon",src:Le(n==="italic"?"italic-active":"italic")}))},qm=r=>{const{open:n,setOpen:e,textOpt:t,workIds:i,style:o,floatBarRef:s}=r,{mananger:a,floatBarData:c}=f.useContext(Ne),[l,u]=f.useState("normal"),[h,g]=f.useState("normal"),[y,d]=f.useState(!1),[M,w]=f.useState(!1);f.useEffect(()=>{t!=null&&t.bold&&u(t.bold),j.isBoolean(t==null?void 0:t.underline)&&d(t.underline||!1),j.isBoolean(t==null?void 0:t.lineThrough)&&w(t.lineThrough||!1),t!=null&&t.italic&&g(t.italic)},[t]);const m=f.useMemo(()=>{if(o&&(s!=null&&s.current)&&j.isNumber(c==null?void 0:c.y)&&(a!=null&&a.height)){if(s.current.offsetTop&&s.current.offsetTop+c.y>180){const T={};return T.top="inherit",T.bottom=50,T}else if(!s.current.offsetTop&&(a==null?void 0:a.height)-s.current.offsetTop-c.y<120){const T={};return T.top="inherit",T.bottom=50,T}}},[o,s==null?void 0:s.current,c,a]),p=f.useMemo(()=>n?f.createElement("div",{className:"font-style-menu",style:m,onPointerUp:T=>{T.stopPropagation(),T.nativeEvent.stopImmediatePropagation()}},f.createElement(Gm,{workIds:i||[Q],bold:l,setBold:u,viewId:a==null?void 0:a.viewId}),f.createElement(Qm,{workIds:i||[Q],underline:y,setUnderline:d,viewId:a==null?void 0:a.viewId}),f.createElement(Zm,{workIds:i||[Q],lineThrough:M,setLineThrough:w,viewId:a==null?void 0:a.viewId}),f.createElement(Hm,{workIds:i||[Q],italic:h,setItalic:g,viewId:a==null?void 0:a.viewId})):null,[n,i,l,a==null?void 0:a.viewId,y,M,h,m]);return f.createElement("div",{className:`button normal-button ${n&&"active"}`,onPointerUp:T=>{T.stopPropagation(),T.nativeEvent.stopImmediatePropagation(),e(!n)}},f.createElement("img",{alt:"icon",src:Le(n?"font-style-active":"font-style")}),p)},Ke=Object.freeze([12,14,18,24,36,48,64,80,144,288]),bt=["top","topLeft","topRight","bottom","bottomLeft","bottomRight","left","leftTop","leftBottom","right","rightTop","rightBottom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ation(),t.nativeEvent.stopImmediatePropagation()}},Ke.map(t=>f.createElement("div",{className:"font-size-btn",key:t,onPointerUp:()=>{e(t)}},t)))},Xm=r=>{const n=f.useRef(null),{open:e,setOpen:t,textOpt:i,workIds:o,floatBarRef:s}=r,{mananger:a,floatBarData:c}=f.useContext(Ne),[l,u]=f.useState(0),h=Ke.length-1;f.useEffect(()=>{i!=null&&i.fontSize&&(u(i.fontSize),n.current&&(n.current.value=i.fontSize.toString()))},[i==null?void 0:i.fontSize]);const g=f.useMemo(()=>{if(s!=null&&s.current&&j.isNumber(c==null?void 0:c.y)&&(a!=null&&a.height)){if(s.current.offsetTop&&s.current.offsetTop+c.y>180){const m={};return m.top="inherit",m.bottom=35,m}else if(!s.current.offsetTop&&(a==null?void 0:a.height)-s.current.offsetTop-c.y<120){const m={};return m.top="inherit",m.bottom=35,m}}},[s==null?void 0:s.current,c,a]);function y(m){u(m),m&&m>=Ke[0]&&m<=Ke[h]&&te.emitMethod(ne.MainEngine,U.SetFontStyle,{workIds:o||[Q],fontSize:m,viewId:a==null?void 0:a.viewId})}const d=m=>{var p;(p=n.current)==null||p.blur(),t(!1),w(m)},M=f.useMemo(()=>e?f.createElement(Km,{onClickHandler:d,style:g}):null,[e,d,g]),w=m=>{m>Ke[h]&&(m=Ke[h]),m<Ke[0]&&(m=Ke[0]),y(m)};return f.createElement("div",{className:"button normal-button font-size-barBtn",style:{width:50},onPointerUp:m=>{m.stopPropagation(),m.nativeEvent.stopImmediatePropagation()}},f.createElement("input",{className:"font-size-input",ref:n,onTouchEnd:()=>{n.current&&n.current.focus()},onClick:()=>{t(!e),n.current&&n.current.focus()},onKeyDown:m=>{if(m.stopPropagation(),m.nativeEvent.stopImmediatePropagation(),m.key==="Backspace"){const p=window.getSelection(),T=p==null?void 0:p.getRangeAt(0);if(T!=null&&T.collapsed)return m.cancelable&&m.preventDefault(),document.execCommand("delete",!1),!1}return!1},onKeyUp:m=>{var p;if(m.stopPropagation(),m.nativeEvent.stopImmediatePropagation(),n.current){const T=n.current.value,v=parseInt(T);isNaN(v)?n.current.value="0":n.current.value=v.toString(),v&&m.key==="Enter"&&(w(v),(p=n.current)==null||p.blur(),t(!1))}}}),f.createElement("div",{className:"font-size-btns"},f.createElement("div",{className:"font-size-add",onPointerUp:()=>{w(l+Ke[0])}}),f.createElement("div",{className:"font-size-cut",onPointerUp:()=>{w(l-Ke[0])}})),M)},_m=r=>{const{workIds:n,mananger:e,islocked:t}=r;return f.createElement("div",{className:"button normal-button",onPointerUp:i=>{i.stopPropagation(),te.emitMethod(ne.MainEngine,U.SetLock,{workIds:n||[Q],isLocked:!t,viewId:e==null?void 0:e.viewId})}},f.createElement("img",{alt:"icon",src:Le(t?"unlock-new":"lock-new")}))},Xn=r=>{const{icon:n,min:e,max:t,step:i,value:o,onInputHandler:s}=r,[a,c]=f.useState(0),l=f.useRef(null),u=h=>{h>t&&(h=t),h<e&&(h=e),c(h),s(h),l.current&&(l.current.value=h.toString())};return f.useEffect(()=>{o&&(c(o),l.current&&(l.current.value=o.toString()))},[o]),f.createElement("div",{className:"button input-button"},f.createElement("img",{src:Le(n)}),f.createElement("input",{className:"input-number",type:"text",ref:l,onPointerUp:()=>{l.current&&l.current.focus()},onKeyDown:h=>{if(h.stopPropagation(),h.nativeEvent.stopImmediatePropagation(),h.key==="Backspace"){const g=window.getSelection(),y=g==null?void 0:g.getRangeAt(0);if(y!=null&&y.collapsed)return h.cancelable&&h.preventDefault(),document.execCommand("delete",!1),!1}},onKeyUp:h=>{if(h.stopPropagation(),h.nativeEvent.stopImmediatePropagation(),l.current){const g=l.current.value,y=parseInt(g);isNaN(y)?l.current.value="0":l.current.value=y.toString()}},onChange:h=>{const g=h.target.value,y=parseInt(g);y&&y&&y>=e&&y<=t&&u(y)}}),f.createElement("div",{className:"input-number-btns"},f.createElement("div",{className:"input-number-add",onPointerUp:()=>{u(a+i)}}),f.createElement("div",{className:"input-number-cut",onPointerUp:()=>{u(a-i)}})))},eI=r=>{const{icon:n,min:e,max:t,step:i,value:o,onInputHandler:s}=r;return f.createElement("div",{className:"button input-button"},f.createElement("img",{src:Le(n)}),f.createElement(tI,{min:e,max:t,step:i,value:o,onInputHandler:s}))},tI=r=>{const{value:n,min:e,max:t,onInputHandler:i}=r,[o,s]=f.useState({x:0,y:0});f.useEffect(()=>{s({x:n*100,y:0})},[]);const a=(u,h)=>{let g=Math.floor(Math.max(h.x,e*100));g=Math.floor(Math.min(g,t*100)),h.x!==(o==null?void 0:o.x)&&s({x:g,y:0});const y=g/100;n!==y&&i(y)},c=()=>{},l=(u,h)=>{let g=Math.floor(Math.max(h.x,e*100));g=Math.floor(Math.min(g,t*100)),h.x!==(o==null?void 0:o.x)&&s({x:g,y:0});const y=g/100;n!==y&&i(y)};return f.createElement("div",{className:"range-number-container",onPointerUp:u=>{const h=u.nativeEvent.offsetX-6;let g=Math.floor(Math.max(h,e*100));g=Math.floor(Math.min(g,t*100)),s({x:g,y:0});const y=g/100;n!==y&&i(y)}},f.createElement("div",{className:"range-number-color"}),f.createElement("div",{className:"range-number"},f.createElement(Lt,{bounds:"parent",axis:"x",position:o,onDrag:a,onStart:c,onStop:l},f.createElement("div",{className:"circle",onPointerUp:nn}))))},nI=r=>{const{icon:n,value:e,onChangeHandler:t,style:i}=r,[o,s]=f.useState(0),[a,c]=f.useState(),l=f.useRef(null),u=f.useCallback(y=>{y>=bt.length&&(y=0),y<0&&(y=bt.length-1),s(y),t(bt[y]),c(!1),l.current&&(l.current.value=bt[y])},[t]),h=f.useMemo(()=>{if(i&&i.bottom){const y={};return y.top="inherit",y.bottom=50,y}},[i]);f.useEffect(()=>{e&&(s(bt.indexOf(e)),l.current&&(l.current.value=e))},[e]);const g=f.useMemo(()=>a?f.createElement(iI,{options:bt,onClickHandler:u,style:h}):null,[a,u,h]);return f.createElement("div",{className:"button input-button"},f.createElement("img",{src:Le(n)}),f.createElement("input",{readOnly:!0,className:"input-number",type:"text",ref:l,onPointerUp:()=>{l.current&&(l.current.focus(),c(!a))}}),f.createElement("div",{className:"input-number-btns"},f.createElement("div",{className:"input-number-add",onPointerUp:()=>{u(o+1)}}),f.createElement("div",{className:"input-number-cut",onPointerUp:()=>{u(o-1)}})),g)},iI=r=>{const{options:n,style:e,onClickHandler:t}=r;return f.createElement("div",{className:"select-option-menu",style:e},n.map((i,o)=>f.createElement("div",{className:"select-option-btn",key:i,onPointerUp:()=>{t(o)}},i)))},oI=r=>{const{innerRatio:n,innerVerticeStep:e,vertices:t,mananger:i,setShapeOpt:o}=r,s=l=>{o({vertices:l}),te.emitMethod(ne.MainEngine,U.SetShapeOpt,{workIds:[Q],toolsType:S.Star,viewId:i.viewId,vertices:l})},a=l=>{o({innerVerticeStep:l}),te.emitMethod(ne.MainEngine,U.SetShapeOpt,{workIds:[Q],toolsType:S.Star,viewId:i.viewId,innerVerticeStep:l})},c=l=>{o({innerRatio:l}),te.emitMethod(ne.MainEngine,U.SetShapeOpt,{workIds:[Q],toolsType:S.Star,viewId:i.viewId,innerRatio:l})};return f.createElement(f.Fragment,null,f.createElement(Xn,{value:t,icon:"polygon-vertex",min:3,max:100,step:1,onInputHandler:s}),f.createElement(Xn,{value:e,icon:"star-innerVertex",min:1,max:100,step:1,onInputHandler:a}),f.createElement(eI,{value:n,icon:"star-innerRatio",min:.1,max:1,step:.1,onInputHandler:c}))},rI=r=>{const{mananger:n,vertices:e,setShapeOpt:t}=r,i=o=>{t({vertices:o}),te.emitMethod(ne.MainEngine,U.SetShapeOpt,{workIds:[Q],toolsType:S.Polygon,viewId:n.viewId,vertices:o})};return f.createElement(Xn,{value:e,icon:"polygon-vertex",min:3,max:100,step:1,onInputHandler:i})},sI=r=>{const{mananger:n,placement:e,setShapeOpt:t}=r,i=o=>{t({placement:o}),te.emitMethod(ne.MainEngine,U.SetShapeOpt,{workIds:[Q],toolsType:S.SpeechBalloon,viewId:n.viewId,placement:o})};return f.createElement(nI,{value:e,icon:"speechBallon-placement",onChangeHandler:i})},Rn=r=>{const{icon:n,isActive:e,onPointerUpHandler:t}=r;return f.createElement("div",{className:`button tab-button ${e?"active":""}`,onPointerUp:t},f.createElement("img",{src:Le(n)}))},aI=r=>{const{toolsTypes:n,style:e,mananger:t,shapeOpt:i,setShapeOpt:o}=r,[s,a]=f.useState();f.useEffect(()=>{n.includes(S.Polygon)?a(S.Polygon):n.includes(S.Star)?a(S.Star):a(S.SpeechBalloon)},[n]);const c=g=>{a(g)},l=f.useMemo(()=>s===S.Polygon&&t&&i.vertices?f.createElement(rI,{vertices:i.vertices,mananger:t,setShapeOpt:o}):null,[t,s,i,o]),u=f.useMemo(()=>s===S.Star&&t&&i.vertices&&i.innerVerticeStep&&i.innerRatio?f.createElement(oI,{mananger:t,vertices:i.vertices,innerVerticeStep:i.innerVerticeStep,innerRatio:i.innerRatio,setShapeOpt:o}):null,[t,s,i,o]),h=f.useMemo(()=>s===S.SpeechBalloon&&t&&i.placement?f.createElement(sI,{mananger:t,placement:i.placement,setShapeOpt:o}):null,[s,t,i.placement,o]);return f.createElement("div",{className:"shapeOpt-sub-menu",style:e,onPointerUp:nn},f.createElement("div",{className:"shapeOpt-sub-menu-tabs"},n.includes(S.Polygon)&&f.createElement(Rn,{isActive:s===S.Polygon,icon:s===S.Polygon?"polygon-active":"polygon",onPointerUpHandler:c.bind(void 0,S.Polygon)})||null,n.includes(S.Star)&&f.createElement(Rn,{isActive:s===S.Star,icon:s===S.Star?"star-active":"star",onPointerUpHandler:c.bind(void 0,S.Star)})||null,n.includes(S.SpeechBalloon)&&f.createElement(Rn,{isActive:s===S.SpeechBalloon,icon:s===S.SpeechBalloon?"speechBallon-active":"speechBallon",onPointerUpHandler:c.bind(void 0,S.SpeechBalloon)})||null),f.createElement("div",{className:"shapeOpt-sub-menu-content"},l,u,h))},cI=r=>{const{open:n,setOpen:e,floatBarRef:t,toolsTypes:i,shapeOpt:o}=r,{floatBarData:s,mananger:a,setFloatBarData:c}=f.useContext(Ne),l=f.useRef(null),u=f.useMemo(()=>{if(t!=null&&t.current&&j.isNumber(s==null?void 0:s.x)&&j.isNumber(s==null?void 0:s.y)&&(a!=null&&a.height)){if(t.current.offsetTop&&t.current.offsetTop+s.y>200){const d={};return d.top="inherit",d.bottom=50,d}else if(!t.current.offsetTop&&(a==null?void 0:a.height)-t.current.offsetTop-(s==null?void 0:s.y)<140){const d={};return d.top="inherit",d.bottom=50,d}}},[t,s==null?void 0:s.x,s==null?void 0:s.y,a==null?void 0:a.height]),h=f.useCallback(d=>{c({shapeOpt:{...o,...d}})},[c,o]),g=f.useMemo(()=>n&&i&&a&&o?f.createElement(aI,{shapeOpt:o,style:u,toolsTypes:i,mananger:a,setShapeOpt:h}):null,[n,u,i,a,o,h]),y=()=>{e(!n)};return f.createElement("div",{ref:l,className:`button normal-button ${n&&"active"}`,onPointerUp:y},g,f.createElement("img",{alt:"icon",src:Le(n?"shapes-active":"shapes")}))},mr=f.memo(r=>{const{textOpt:n,workIds:e,noLayer:t,position:i,noDelete:o,noCopy:s}=r,{floatBarData:a,mananger:c}=f.useContext(Ne),[l,u]=f.useState(0),[h,g]=f.useState(),y=f.useRef(null);f.useEffect(()=>{var x,E,b,O;const k={},P=(a==null?void 0:a.w)||((x=n==null?void 0:n.boxSize)==null?void 0:x[0])||0,A=(a==null?void 0:a.h)||((E=n==null?void 0:n.boxSize)==null?void 0:E[1])||0;if(i&&P&&A&&(c!=null&&c.width)&&(c!=null&&c.height)){if(i.y<60?i.y+A<c.height-60?k.bottom=-120:i.y+A<c.height?k.bottom=-58:i.y>0?k.top=62:k.top=-i.y+62:k.top=0,i.x<0)k.left=-i.x+3;else if(i.x+(((b=y.current)==null?void 0:b.offsetWidth)||P)>c.width){const Y=c.width-(((O=y.current)==null?void 0:O.offsetWidth)||P)-i.x;k.left=Y}g(k);return}g(void 0)},[y,i,a==null?void 0:a.w,a==null?void 0:a.h,c==null?void 0:c.width,c==null?void 0:c.height,n==null?void 0:n.boxSize]);const d=f.useMemo(()=>a!=null&&a.fillColor?f.createElement(Wm,{floatBarRef:y,open:l===3,setOpen:k=>{u(k===!0?3:0)}}):null,[a==null?void 0:a.fillColor,l,y]),M=f.useMemo(()=>a!=null&&a.strokeColor?f.createElement($m,{floatBarRef:y,open:l===2,setOpen:k=>{u(k===!0?2:0)}}):null,[a==null?void 0:a.strokeColor,l,y]),w=f.useMemo(()=>n!=null&&n.fontColor&&(c!=null&&c.viewId)?f.createElement(Vm,{floatBarRef:y,open:l===4,setOpen:k=>{u(k===!0?4:0)},textOpt:n,workIds:e}):null,[n,l,e,c,y]),m=f.useMemo(()=>n!=null&&n.fontBgColor&&(c!=null&&c.viewId)?f.createElement(Fm,{floatBarRef:y,open:l===5,setOpen:k=>{u(k===!0?5:0)},textOpt:n,workIds:e}):null,[n,l,e,c,y]),p=f.useMemo(()=>n&&(c!=null&&c.viewId)?f.createElement(qm,{floatBarRef:y,open:l===6,setOpen:k=>{u(k===!0?6:0)},textOpt:n,workIds:e,style:h}):null,[n,l,e,c,h,y]),T=f.useMemo(()=>n&&(c!=null&&c.viewId)?f.createElement(Xm,{open:l===7,setOpen:k=>{u(k===!0?7:0)},textOpt:n,workIds:e,floatBarRef:y}):null,[n,l,e,c,y]),v=f.useMemo(()=>t?null:f.createElement(Om,{open:l===1,setOpen:k=>{u(k===!0?1:0)},floatBarRef:y}),[t,l,y]),C=f.useMemo(()=>a!=null&&a.canLock&&c?f.createElement(_m,{workIds:e,mananger:c,islocked:a.isLocked}):null,[a,c,e]),N=f.useMemo(()=>c&&(c!=null&&c.viewId)&&h&&(a!=null&&a.shapeOpt)&&(a!=null&&a.toolsTypes)?f.createElement(cI,{open:l===8,setOpen:k=>{u(k===!0?8:0)},floatBarRef:y,workIds:e,toolsTypes:a.toolsTypes,shapeOpt:a.shapeOpt}):null,[a,c,l,h,e,y]);return f.createElement("div",{className:"appliance-plugin-floatbtns",style:h,ref:y},c&&!o&&f.createElement(Pm,{workIds:e,mananger:c}),v,C,!!(c!=null&&c.viewId)&&!s&&f.createElement(Rm,{workIds:e,viewId:c.viewId}),N,p,T,w,m,M,d)}),lI=r=>{const{data:n,workId:e,updateOptInfo:t}=r,{opt:i,scale:o,translate:s,x:a,y:c}=n,l=f.useRef(null),{floatBarData:u}=f.useContext(Ne),h=f.useMemo(()=>{const{fontSize:d,fontFamily:M,underline:w,fontColor:m,lineThrough:p,textAlign:T,strokeColor:v,lineHeight:C,bold:N,italic:k}=i,P=C||d*1.2,A={fontSize:`${d}px`,lineHeight:`${P}px`,color:"transparent",caretColor:m,borderColor:v,minHeight:`${P}px`,pointerEvents:"none",paddingRight:`${k==="italic"?Math.round(d*.3):5}px`};return M&&(A.fontFamily=`${M}`),(p||w)&&(A.textDecoration=`${p&&"line-through"||""}${w&&" underline"||""}`),T&&(A.textAlign=`${T}`),N&&(A.fontWeight=`${N}`),k&&(A.fontStyle=`${k}`),A},[i]),g=f.useMemo(()=>{const d=[];if(i.text){const M=vn(i.text);for(let w=0;w<M.length;w++){const m=M[w];m===""?d.push(f.createElement("div",{key:w})):d.push(f.createElement("div",{key:w},m))}}return d.length?d:f.createElement("div",null)},[i.text]),y=f.useMemo(()=>{if(!u)return{};const d=`scale(${o||1}) ${s&&"translate("+s[0]+"px,"+s[1]+"px)"||""}`;return{left:`${a-u.x}px`,top:`${c-u.y}px`,zIndex:1,transform:d,transformOrigin:"left top",opacity:0,pointerEvents:"auto"}},[o,s,a,c,u]);return f.useEffect(()=>{if(!l.current)return;const d=l.current.offsetWidth,M=l.current.offsetHeight;if(!d||!M)return;const w=i.boxSize;if((w==null?void 0:w[0])!==d||w[1]!==M||!w){t({activeTextId:e,update:{boxSize:[d,M],workState:D.Done}});return}},[i.fontSize,i.italic,i.bold,i.boxSize,e,t]),f.createElement("div",{className:"editor-box readonly","data-text-work-id":e,style:y},f.createElement("div",{className:"editor",ref:l,style:h},g))},uI=r=>{const{mananger:n}=f.useContext(Ne),e=f.useMemo(()=>{var i;const t=o=>{var u,h;if(!n)return;const{activeTextId:s,update:a,syncData:c}=o,l=s&&j.cloneDeep(((u=n.control.textEditorManager)==null?void 0:u.get(s))||((h=r.editors)==null?void 0:h.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),n.control.textEditorManager.updateForViewEdited(s,l))};if((i=r.editors)!=null&&i.size){const o=[];return r.editors.forEach((s,a)=>{if(r.selectIds&&r.selectIds.includes(a)){const c=f.createElement(lI,{key:a,workId:a,data:s,updateOptInfo:t});o.push(c)}}),o}return null},[r.editors,r.selectIds,n]);return f.createElement(f.Fragment,null,e)},hI=r=>{const{position:n,textOpt:e,workIds:t,noLayer:i,noCopy:o,noDelete:s,style:a}=r,c=f.useRef(null);return f.createElement("div",{className:ke.FloatBarBtn,ref:c,style:a},f.createElement(mr,{position:n,textOpt:e,workIds:t,noLayer:i,noCopy:o,noDelete:s}))},dI=r=>{const{data:n,workId:e,showFloatBtns:t,handleKeyUp:i,handleFocus:o,runAnimation:s,updateSize:a,rightBoundBreak:c}=r,{activeTextEditor:l,activeTextId:u,mananger:h}=f.useContext(Ne),{opt:g,scale:y,translate:d,x:M,y:w}=n,{fontSize:m,fontFamily:p,underline:T,fontColor:v,lineThrough:C,textAlign:N,lineHeight:k,bold:P,italic:A}=g,x=f.useRef(null),E=f.useMemo(()=>{const q=m,ee=k||q*1.2,oe={fontSize:`${q}px`,lineHeight:`${ee}px`,caretColor:v,color:"transparent",minHeight:`${ee}px`,paddingRight:`${A==="italic"?Math.round(q*.3):5}px`,borderWidth:0};return p&&(oe.fontFamily=`${p}`),(C||T)&&(oe.textDecoration=`${C&&"line-through"||""} ${T&&" underline"||""}`),N&&(oe.textAlign=`${N}`),P&&(oe.fontWeight=`${P}`),A&&(oe.fontStyle=`${A}`),oe},[P,v,p,m,A,k,C,y,N,T]),b=f.useRef(!1),O=f.useRef(6),Y=f.useRef(),R=f.useRef(),W=f.useRef(!1),B=f.useRef(!1),H=f.useRef({fontSize:E.fontSize,lineHeight:E.lineHeight,fontStyle:E.fontStyle,fontWeight:E.fontWeight,fontFamily:E.fontFamily}),Z=f.useMemo(()=>typeof window>"u"?!1:navigator.maxTouchPoints>0||"ontouchstart"in window,[]),F=f.useMemo(()=>u===e?"hover":g.workState===D.Doing||g.workState===D.Start?"editing":l?"active":"none",[u,e,g.workState,l]);function X(q){if(!x.current)return;const oe=q&&Xy(q.nativeEvent)?gr(q.nativeEvent):void 0,ue=()=>{Y.current&&(cancelAnimationFrame(Y.current),Y.current=void 0),R.current&&(window.clearTimeout(R.current),R.current=void 0)},we=me=>{const De=x.current,Te=window==null?void 0:window.getSelection();if(!(!De||!Te||!W.current)){if(document.activeElement!==De)try{De.focus({preventScroll:!0})}catch{De.focus()}if(me){const{x:Ae,y:ze}=me;if(document.caretPositionFromPoint){const he=document.caretPositionFromPoint(Ae,ze);if(he){const ge=document.createRange();ge.setStart(he.offsetNode,he.offset),ge.collapse(!0),Te.removeAllRanges(),Te.addRange(ge),B.current=!0;return}}else if(document.caretRangeFromPoint){const he=document.caretRangeFromPoint(Ae,ze);if(he){Te.removeAllRanges(),Te.addRange(he),B.current=!0;return}}}JM({hasPoint:!!me,previousByPoint:B.current,hasSelectionInEditor:so(Te,De),rangeCount:Te.rangeCount,isCollapsed:Te.isCollapsed})||(HM(Te,De),B.current=!1)}};ue(),we(oe),Z&&(Y.current=requestAnimationFrame(()=>{we(),R.current=window.setTimeout(()=>{we(),R.current=void 0},32),Y.current=void 0}))}const ye=f.useMemo(()=>{const q=`scale(${y||1}) ${d&&"translate("+d[0]+"px,"+d[1]+"px)"||""}`;return{left:`${M-Gn*(y||1)}px`,top:`${w-Gn*(y||1)}px`,zIndex:2,transform:q,transformOrigin:"left top",borderColor:F==="editing"||F==="hover"?v:"transparent"}},[y,d,M,w,v,F]),se=f.useMemo(()=>{let q="";const ee="<div></div>";if(g.text){const oe=vn(g.text);for(let ue=0;ue<oe.length;ue++){const we=oe[ue];if(we==="")q=q+ee;else{const me=we.replace(/[<>&]/g,De=>({"<":"&lt;",">":"&gt;","&":"&amp;"})[De]);q=q+`<div>${me}</div>`}}}else q=ee;return q},[g.fontBgColor,g.text]),fe=f.useMemo(()=>{var q,ee;if(F==="hover"){if(y&&t&&j.isNumber(M)&&j.isNumber(w)&&g.boxSize&&j.isNumber((q=g.boxSize)==null?void 0:q[0])&&j.isNumber((ee=g.boxSize)==null?void 0:ee[1])){const oe={x:M,y:w},ue={left:M,top:w,width:g.boxSize[0]*y,height:g.boxSize[1]*y};return f.createElement(hI,{position:oe,style:ue,textOpt:g,workIds:[e],noLayer:!0,noCopy:!0,noDelete:!0})}return null}return null},[g,t,e,M,w,y,F]);f.useEffect(()=>{W.current=u===e,u!==e&&(Y.current&&(cancelAnimationFrame(Y.current),Y.current=void 0),R.current&&(window.clearTimeout(R.current),R.current=void 0),B.current=!1)},[u,e]),f.useEffect(()=>{if(u===e&&x.current){const q=window==null?void 0:window.getSelection(),ee=so(q,x.current);(document.activeElement!==x.current||!ee)&&X(),o(x.current)}},[u,o,e,Z]),f.useEffect(()=>{const q=x.current;if(!q)return;const ee=cr(q),oe=g.text||"";ee!==oe&&(u===e&&b.current||(q.innerHTML=se))},[u,se,g.boxSize,g.text,g.workState,e]),f.useEffect(()=>()=>{Y.current&&cancelAnimationFrame(Y.current),R.current&&window.clearTimeout(R.current)},[]),f.useEffect(()=>{if(x.current){const q=parseInt(getComputedStyle(x.current).paddingRight,10)+parseInt(getComputedStyle(x.current).borderWidth,10);O.current=Number(q)}},[]),f.useEffect(()=>{if(x.current){const q={fontSize:E.fontSize,lineHeight:E.lineHeight,fontStyle:E.fontStyle,fontWeight:E.fontWeight,fontFamily:E.fontFamily};if(!j.isEqual(H.current,q)){H.current=q;const ee=[x.current.offsetWidth,x.current.offsetHeight];a(e,ee)}}},[E,e,a,F,l,u]);const ae=f.useCallback(q=>{const ee=h==null?void 0:h.parentElement,oe=x.current;if(!ee||!oe||!c)return!1;const{lastLine:ue}=ao(oe);if(!ue||ue instanceof Text)return!1;const we=ue==null?void 0:ue.getBoundingClientRect(),me=ee==null?void 0:ee.getBoundingClientRect();if(!we||!me)return!1;if(we.right+q>me.right){const{textContent:De,textNodes:Te}=qM(ue);if(!Te.length)return!1;const Ae=De.length,ze=Gt(Te,0);if(!ze)return!1;let he=0,ge=0,K=Ae;for(;ge<K;){const de=Math.floor((ge+K)/2),Ce=Gt(Te,de);if(!Ce)break;const Be=document.createRange();Be.setStart(ze.node,ze.offset),Be.setEnd(Ce.node,Ce.offset);const rn=Be.getBoundingClientRect(),Ni=me.right-rn.right;if(Ni<q){if(de>0){const ft=Gt(Te,de-1);if(!ft)break;const pt=document.createRange();pt.setStart(ze.node,ze.offset),pt.setEnd(ft.node,ft.offset);const Vt=pt.getBoundingClientRect();if(me.right-Vt.right>=q){he=de-1;break}}K=de}else{const ft=de+1;if(ft<Ae){const pt=Gt(Te,ft);if(!pt)break;const Vt=document.createRange();Vt.setStart(ze.node,ze.offset),Vt.setEnd(pt.node,pt.offset);const Ci=Vt.getBoundingClientRect();if(me.right-Ci.right<=q&&Ni>q){he=de;break}}ge=ft}}if(!he){const de=Gt(Te,ge);if(!de)return!1;const Ce=document.createRange();Ce.setStart(ze.node,ze.offset),Ce.setEnd(de.node,de.offset);const Be=Ce.getBoundingClientRect();me.right-Be.right>q?he=ge:ge>0&&(he=ge-1)}if(he>0){const de=De.slice(0,he),Ce=De.slice(he);ue.textContent=de;const Be=document.createElement("div");return Ce&&(Be.textContent=Ce),x.current.appendChild(Be),ae(q),!0}}return!1},[h==null?void 0:h.parentElement,g.fontBgColor,c,e]);function nt(q){if(q.stopPropagation(),q.nativeEvent.stopImmediatePropagation(),q.key==="Backspace"){const ee=window.getSelection(),oe=ee==null?void 0:ee.getRangeAt(0);if(oe!=null&&oe.collapsed)return q.cancelable&&q.preventDefault(),document.execCommand("delete",!1),!1}return!1}function ut(q,ee){const oe=window==null?void 0:window.getSelection();if(oe!=null&&oe.rangeCount&&q&&oe&&oe.anchorNode){const ue=oe.anchorOffset,we=oe.anchorNode.textContent||"",me=we.slice(0,ue)||"",De=we.slice(ue)||"",Te=me.concat(q)||"";ht(Te,De,ee)}}function ht(q,ee,oe){const ue=window==null?void 0:window.getSelection();if(!(ue!=null&&ue.rangeCount)||!ue.anchorNode)return;const we=q.split(/\n/);let me=ue.anchorNode.parentNode;me===oe&&(me=ue.anchorNode);const De=[...oe.childNodes],Te=[];let Ae,ze=ue.anchorOffset;for(;De.length;){const he=De.pop();if(he){if(he===me){let ge=we[0];we.length===1&&(ze=we[0].length,ge=we[0].concat(ee)),me.nodeName==="#text"?(me.textContent=ge,Ae=me):me.nodeName==="DIV"&&(me.innerText=ge,Ae=me.childNodes[0]);break}Te.push(he),oe.removeChild(he)}}if(we.length>1)for(let he=1;he<we.length;he++){let ge=we[he];const K=document.createElement("div");he===we.length-1&&(ze=ge.length,ge=ge.concat(ee)),K.innerText=ge,oe.appendChild(K),he===we.length-1&&(Ae=K.childNodes[0])}if(Te.length){Te.reverse();for(const he of Te)oe.appendChild(he)}if(Ae&&Ae.nodeName==="#text"){ue.deleteFromDocument();const he=document.createRange(),ge=Math.min(ze,(Ae==null?void 0:Ae.length)||0);he.setStart(Ae,ge),he.collapse(!0),ue.removeAllRanges(),ue.addRange(he)}}function dt(q){if(q.cancelable&&q.preventDefault(),q.stopPropagation(),q.nativeEvent.stopImmediatePropagation(),x.current){const ee=(q.clipboardData||window.clipboardData).getData("text"),oe=window==null?void 0:window.getSelection();if(!(oe!=null&&oe.rangeCount))return;if(ee&&oe&&oe.anchorNode){const ue=Un(ee,{whiteList:{},stripIgnoreTag:!0,stripIgnoreTagBody:["script"]});ut(ue,x.current),ae((y||1)*O.current),i(x.current)}s()}return!1}function gt(q){ao(q)}const xe=f.useCallback(()=>{const q=x.current;s(()=>{if(q){if(gt(q),!b.current&&ae((y||1)*O.current)){const ee=window.getSelection();if(!(ee!=null&&ee.rangeCount))return!1;const oe=document.createRange(),ue=x.current.lastChild;oe.selectNodeContents(ue),oe.collapse(!1),ee.removeAllRanges(),ee.addRange(oe)}i(q)}})},[s,i,ae,y]);function Pe(){b.current=!0,s()}function it(){b.current=!1,xe()}function $t(){xe(),s()}const Wt=f.useCallback(()=>{if(F==="active"&&x.current&&x.current.parentElement){const q=x.current.parentElement;q.style.borderColor=v}},[F,v]),on=f.useCallback(()=>{if(F==="active"&&x.current&&x.current.parentElement){const q=x.current.parentElement;q.style.borderColor="transparent"}},[F]);return f.createElement(f.Fragment,null,fe,f.createElement("div",{className:`editor-box ${F}`,style:ye,onPointerUp:()=>{var q;if(F==="editing"){s(()=>{var ee;(ee=document.activeElement)==null||ee.blur(),h==null||h.control.textEditorManager.checkEmptyTextBlur()});return}if(F==="active"&&h){if((q=h.control.collector)!=null&&q.hasIncludeSelector(e)){s(()=>{var ee;(ee=document.activeElement)==null||ee.blur(),h==null||h.control.textEditorManager.checkEmptyTextBlur()});return}if(h&&u!==e){h.control.textEditorManager.checkEmptyTextBlur(),h.control.textEditorManager.active(e,h.worker.now);return}}},onMouseOver:Wt,onMouseLeave:on},f.createElement("div",{id:e,suppressContentEditableWarning:!0,contentEditable:!0,className:"editor",ref:x,style:E,onKeyDown:nt,onPaste:dt,onTouchEnd:X,onInput:xe,onCompositionStart:Pe,onCompositionUpdate:$t,onCompositionEnd:it,dangerouslySetInnerHTML:{__html:se}})))},gI=r=>{const n=f.useRef(null),{mananger:e}=f.useContext(Ne),t=f.useRef(),i=f.useCallback(s=>{var h,g;const{activeTextId:a,update:c,syncData:l}=s;if(!e)return;const u=a&&j.cloneDeep(((h=e.control.textEditorManager)==null?void 0:h.get(a))||((g=r.editors)==null?void 0:g.get(a)));u&&u.opt&&(u.opt={...u.opt,...c},l&&(u.canSync=Object.keys(l).includes("canSync")&&l.canSync||u.canSync,u.canWorker=Object.keys(l).includes("canWorker")&&l.canWorker||u.canWorker),e.control.textEditorManager.updateForViewEdited(a,u))},[e,r.editors]),o=f.useMemo(()=>{var u;const s=h=>{if(!e)return;const g=h.id,y=e.control.textEditorManager.get(g),d=D.Doing,M=[h.offsetWidth,h.offsetHeight];(!y||y&&(!j.isEqual(y.opt.boxSize,M)||!j.isEqual(y.opt.workState,d)))&&i({activeTextId:g,update:{boxSize:M,workState:d},syncData:{canSync:!0,canWorker:!0}})},a=h=>{var p,T;if(!e)return;const g=ar(h),y=h.id,d=e.control.textEditorManager.get(y),M=cr(h),w=D.Doing,m=[h.offsetWidth,h.offsetHeight];if(!d||d&&(d.opt.text!==M||!j.isEqual(d.opt.boxSize,m)||!j.isEqual(d.opt.workState,w))){const v=y&&j.cloneDeep(((p=e.control.textEditorManager)==null?void 0:p.get(y))||((T=r.editors)==null?void 0:T.get(y)));v&&v.opt&&(v.opt={...v.opt,text:M,boxSize:m,workState:w},v.canSync=!0,v.canWorker=!0,e.control.textEditorManager.updateForViewEdited(y,v)),e.control.textEditorManager.publicMsgEmitter.emit("textChange",y,h,g,v)}},c=(h,g)=>{if(!e)return;const y=h,d=e.control.textEditorManager.get(y);if(d&&!(!g[0]||!g[1])&&!j.isEqual(d.opt.boxSize,g)){const M=j.cloneDeep(d);M.opt={...M.opt,boxSize:g},M.canSync=!1,M.canWorker=!1,e.control.textEditorManager.updateForViewEdited(y,M)}},l=h=>{t.current&&cancelAnimationFrame(t.current),t.current=requestAnimationFrame(()=>{n!=null&&n.current&&(n==null||n.current.scrollTo({left:0,behavior:"instant"}),h&&h(),t.current=void 0)})};if((u=r.editors)!=null&&u.size){const h=[];return r.editors.forEach((g,y)=>{h.push(f.createElement(dI,{key:y,workId:y,data:g,showFloatBtns:r.showFloatBtns||!1,handleFocus:s,handleKeyUp:a,updateSize:c,runAnimation:l,rightBoundBreak:r.rightBoundBreak||!1}))}),h}return null},[r.editors,r.showFloatBtns,r.rightBoundBreak,e,i]);return f.createElement("div",{className:`${r.className}`,ref:n},o)},Fe=(r,n,e)=>({...r,...e==null?void 0:e[n]}),fI=()=>{const{floatBarData:r,overwriteSelectorStyles:n}=f.useContext(Ne),e={borderColor:r==null?void 0:r.selectorColor,...n.highlightBox},t={backgroundColor:r==null?void 0:r.selectorColor,...n.highlightBoxPoint};return f.createElement("div",{className:"appliance-plugin-highlight-box",style:e},f.createElement("div",{className:"point LT nwse-resize",style:Fe(t,"LT",n.highlightBoxPoints)}),f.createElement("div",{className:"point LC ew-resize",style:Fe(t,"LC",n.highlightBoxPoints)}),f.createElement("div",{className:"point LB nesw-resize",style:Fe(t,"LB",n.highlightBoxPoints)}),f.createElement("div",{className:"point TC ns-resize",style:Fe(t,"TC",n.highlightBoxPoints)}),f.createElement("div",{className:"point RT nesw-resize",style:Fe(t,"RT",n.highlightBoxPoints)}),f.createElement("div",{className:"point RC ew-resize",style:Fe(t,"RC",n.highlightBoxPoints)}),f.createElement("div",{className:"point RB nwse-resize",style:Fe(t,"RB",n.highlightBoxPoints)}),f.createElement("div",{className:"point BC ns-resize",style:Fe(t,"BC",n.highlightBoxPoints)}))},pI=()=>{const{floatBarData:r,mananger:n,overwriteSelectorStyles:e}=f.useContext(Ne),[t,i]=f.useState(),[o,s]=f.useState();f.useEffect(()=>{const l=[];if(n&&j.isNumber(r==null?void 0:r.x)&&j.isNumber(r==null?void 0:r.y)&&(r!=null&&r.points)){const u=n.viewId;if(n.control.viewContainerManager.getView(u))for(const g of r.points){const y=n.control.viewContainerManager.transformToOriginPoint(g,u);l.push(y)}l[0]&&i({x:l[0][0]-((r==null?void 0:r.x)||0),y:l[0][1]-((r==null?void 0:r.y)||0)}),l[1]&&s({x:l[1][0]-((r==null?void 0:r.x)||0),y:l[1][1]-((r==null?void 0:r.y)||0)})}},[n,r==null?void 0:r.points,r==null?void 0:r.x,r==null?void 0:r.y]);const a=f.useMemo(()=>t?f.createElement("div",{className:"point point-dot",style:{borderColor:r==null?void 0:r.selectorColor,...e.highlightBoxPoint,...e.highlightBoxPointDot,left:t.x,top:t.y}}):null,[r==null?void 0:r.selectorColor,t]),c=f.useMemo(()=>o?f.createElement("div",{className:"point point-dot",style:{borderColor:r==null?void 0:r.selectorColor,...e.highlightBoxPoint,...e.highlightBoxPointDot,left:o.x,top:o.y}}):null,[o,r==null?void 0:r.selectorColor]);return f.createElement("div",{className:"appliance-plugin-highlight-box",style:{borderColor:r==null?void 0:r.selectorColor,...e.highlightBox}},a,c)},MI=()=>{const{floatBarData:r,overwriteSelectorStyles:n}=f.useContext(Ne),e={borderColor:r==null?void 0:r.selectorColor,...n.highlightBox},t={backgroundColor:r==null?void 0:r.selectorColor,...n.highlightBoxPoint};return f.createElement("div",{className:"appliance-plugin-highlight-box",style:e},f.createElement("div",{className:"point LT nwse-resize",style:Fe(t,"LT",n.highlightBoxPoints)}),f.createElement("div",{className:"point LB nesw-resize",style:Fe(t,"LB",n.highlightBoxPoints)}),f.createElement("div",{className:"point RT nesw-resize",style:Fe(t,"RT",n.highlightBoxPoints)}),f.createElement("div",{className:"point RB nwse-resize",style:Fe(t,"RB",n.highlightBoxPoints)}))},yI=()=>{const{floatBarData:r,overwriteSelectorStyles:n}=f.useContext(Ne);return f.createElement("div",{className:"appliance-plugin-highlight-box",style:{borderColor:r==null?void 0:r.selectorColor,...n.highlightBox}},f.createElement("img",{className:"lock",alt:"lock",src:"https://sdk.netless.link/resource/icons/lock.svg",style:n.highlightBoxLock}))},mI=r=>{const{className:n}=r,{floatBarData:e,angle:t,setAngle:i,setOperationType:o,mananger:s}=f.useContext(Ne),[a,c]=f.useState(D.Pending),[l,u]=f.useState(),[h,g]=f.useState(!1),[y,d]=f.useState(new pe),[M,w]=f.useState(new pe),[m,p]=f.useState(!1),T=f.useRef(0),v=f.useRef(null),C=(E,b)=>{i(E),o(b===D.Done?U.None:U.RotateNode),c(b),b===D.Done?(g(!1),s==null||s.focusElement()):g(!0),te.emitMethod(ne.MainEngine,U.RotateNode,{workIds:[Q],angle:b===D.Start?0:E,workState:b,viewId:s==null?void 0:s.viewId})},N=E=>{if(!E){p(!0),g(!1),o(U.None),c(D.Pending);return}p(!1)},k=(E,b)=>{T.current&&(clearTimeout(T.current),T.current=0),c(D.Done),g(!1);const O=Math.round(pe.GetAngleByPoints(y,M,new pe(b.x,b.y)))||0;C(O,D.Done)};f.useEffect(()=>(te.activeListener(N),()=>{te.unmountActiveListener(N)}),[]),f.useEffect(()=>{if(window.__selectorE2E__)return window.__selectorRotateE2E__={start:(E=y.x,b=y.y)=>{if(s!=null&&s.control.worker.isBusy){p(!0),c(D.Pending);return}const O=Math.round(pe.GetAngleByPoints(y,M,new pe(E,b)))||0;C(O,D.Start)},doing:(E,b)=>{if(s!=null&&s.control.worker.isBusy){p(!0);return}const O=Math.round(pe.GetAngleByPoints(y,M,new pe(E,b)))||0;u({x:E,y:b}),C(O,D.Doing)},done:(E,b)=>{const O=Math.round(pe.GetAngleByPoints(y,M,new pe(E,b)))||0;u({x:E,y:b}),C(O,D.Done)}},()=>{window.__selectorRotateE2E__&&delete window.__selectorRotateE2E__}},[M,s,y]),f.useEffect(()=>{if(e&&(a===D.Pending||a===D.Done)){const E={x:(e==null?void 0:e.x)-20,y:(e==null?void 0:e.y)+(e==null?void 0:e.h)},b={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};w(new pe(b.x,b.y)),d(new pe(E.x,E.y)),u({x:E.x,y:E.y})}},[e,a]);const P=(E,b)=>{if(s!=null&&s.control.worker.isBusy){p(!0),c(D.Pending);return}T.current&&(clearTimeout(T.current),T.current=0),c(D.Start),g(!0);const O=Math.round(pe.GetAngleByPoints(y,M,new pe(b.x,b.y)))||0;C(O,D.Start)},A=(E,b)=>{if(s!=null&&s.control.worker.isBusy){p(!0),k(E,b);return}k(E,b)},x=(E,b)=>{if(s!=null&&s.control.worker.isBusy){p(!0),k(E,b);return}T.current||(u({x:b.x,y:b.y}),g(!0),T.current=setTimeout(()=>{T.current=0;const O=Math.round(pe.GetAngleByPoints(y,M,new pe(b.x,b.y)))||0;C(O,D.Doing)},60))};return f.createElement(Lt,{disabled:m,position:l,onStart:P,onDrag:x,onStop:A},f.createElement("div",{className:`${n}`,style:e?{left:0,top:0,touchAction:"none"}:void 0},!h&&f.createElement("div",{className:"appliance-plugin-rotate-btn",style:{backgroundColor:e==null?void 0:e.selectorColor}},f.createElement("img",{alt:"icon",src:Le("rotation-button")})),f.createElement("div",{ref:v,className:`appliance-plugin-rotate-mouse-pointer ${h?"active":""}`},f.createElement("img",{alt:"icon",src:Le("rotation")}),f.createElement("div",{className:"angle-icon"},t,"°"))))};function II(r){const n=r==null?void 0:r.viewId;if(!n)return;const e=r.control.viewContainerManager.getView(n),t=e==null?void 0:e.focusScenePath,i=r.control.viewContainerManager.getUndoTickerId(n);!i||!t||(r.control.internalMsgEmitter.emit("cancelUndoTicker",i,n,t),r.control.worker.abled())}function wI(r,n){const e=r.control.worker.now;return r.control.textEditorManager.active(n,e),e}const TI="data-text-work-id";function SI(r){var n,e;if(r instanceof HTMLElement)return((e=(n=r.closest(`[${TI}]`))==null?void 0:n.dataset)==null?void 0:e.textWorkId)||void 0}const vI=f.memo(r=>{const{editors:n,canSelectorSwitch:e}=r,{floatBarData:t,setOperationType:i,mananger:o,isNoPointerEvents:s}=f.useContext(Ne),[a,c]=f.useState(),[l,u]=f.useState(!1),h=f.useRef(0),g=f.useRef(),y=f.useRef(D.Pending),d=f.useMemo(()=>!!((t==null?void 0:t.scaleType)===Oe.none&&(t!=null&&t.canLock)),[t]),M=f.useMemo(()=>t&&t.w&&t.h?{position:"absolute",left:0,top:0,width:t.w,height:t.h,zIndex:2,pointerEvents:d||s?"none":"auto",touchAction:"none"}:{display:"none",pointerEvents:"none"},[t,d,s]),w=C=>{if(!C||t!=null&&t.isLocked){u(!0),y.current=D.Pending,i(U.None);return}u(!1)},m=(C,N)=>{h.current&&(clearTimeout(h.current),h.current=0);const k={x:N.x,y:N.y};i(U.None),y.current=D.Done,c(k),te.emitMethod(ne.MainEngine,U.TranslateNode,{workIds:[Q],position:k,workState:D.Done,viewId:o==null?void 0:o.viewId})};f.useEffect(()=>(te.activeListener(w),()=>{te.unmountActiveListener(w)}),[]),f.useEffect(()=>{if(t&&(t!=null&&t.isLocked)||o!=null&&o.control.worker.isBusy){u(!0);return}u(!1)},[t,o==null?void 0:o.control.worker.isBusy]),f.useEffect(()=>{(y.current===D.Pending||y.current===D.Done)&&j.isNumber(t==null?void 0:t.x)&&j.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 p=C=>{const N=C&&"target"in C?C.target:null,k=e?SI(N):void 0;if(o!=null&&o.control.worker.isBusy){u(!0);return}h.current&&(clearTimeout(h.current),h.current=0),g.current=k,j.isNumber(t==null?void 0:t.x)&&j.isNumber(t==null?void 0:t.y)&&(i(U.TranslateNode),y.current=D.Start,te.emitMethod(ne.MainEngine,U.TranslateNode,{workIds:[Q],position:{x:t==null?void 0:t.x,y:t==null?void 0:t.y},workState:D.Start,viewId:o==null?void 0:o.viewId}))},T=(C,N)=>{var x,E;o!=null&&o.control.worker.isBusy&&u(!0);const k=y.current,P=g.current;if(!!P&&k===D.Start&&o&&e){II(o),wI(o,P),g.current=void 0,y.current=D.Pending,i(U.None);const b=(x=o.control.viewContainerManager.getView(o.viewId))==null?void 0:x.focusScenePath;b&&o.control.worker.blurSelector(o.viewId,b);return}if(m(C,N),g.current&&(g.current=void 0),k===D.Start&&(n!=null&&n.size)&&P){const b=(E=o==null?void 0:o.control.viewContainerManager.getView(o.viewId))==null?void 0:E.focusScenePath;b&&(o==null||o.control.worker.blurSelector(o.viewId,b))}o==null||o.focusElement()},v=(C,N)=>{if(o!=null&&o.control.worker.isBusy){u(!0),m(C,N);return}if(h.current)return;const k={x:N.x,y:N.y};c(k),h.current=setTimeout(()=>{h.current=0,(k.x!==(a==null?void 0:a.x)||k.y!==(a==null?void 0:a.y))&&(g.current&&(g.current=void 0),y.current=D.Doing,te.emitMethod(ne.MainEngine,U.TranslateNode,{workIds:[Q],position:k,workState:D.Doing,viewId:o==null?void 0:o.viewId}))},60)};return f.createElement(Lt,{disabled:l,position:a,onStart:p,onDrag:v,onStop:T},f.createElement("div",{style:M},f.createElement(NI,{editors:n,selectIds:(t==null?void 0:t.selectIds)||[]})))},(r,n)=>!!j.isEqual(r,n)),NI=f.memo(r=>{const{editors:n,selectIds:e}=r;return n?f.createElement(uI,{editors:n,selectIds:e||[]}):null},(r,n)=>!(!j.isEqual(r.editors,n.editors)||!j.isEqual(r.selectIds,n.selectIds))),CI=r=>{const{className:n}=r,[e,t]=f.useState({x:0,y:0,h:0,w:0}),[i,o]=f.useState(),[s,a]=f.useState(),[c,l]=f.useState(),{floatBarData:u,mananger:h,isNoPointerEvents:g,setOperationType:y}=f.useContext(Ne),[d,M]=f.useState(),[w,m]=f.useState(!1),p=f.useRef(0);f.useEffect(()=>{if(u&&h){const E={x:u.x,y:u.y,w:u.w,h:u.h};t(E)}return te.activeListener(v),()=>{te.unmountActiveListener(v)}},[]),f.useEffect(()=>{if(h!=null&&h.control.worker.isBusy){m(!0);return}m(!1)},[h==null?void 0:h.control.worker.isBusy]);const T=()=>{if(p.current&&(clearTimeout(p.current),p.current=0),d){const{scale:E,translate:b}=d;y(U.None),te.emitMethod(ne.MainEngine,U.ScaleNode,{workIds:[Q],scale:E,dir:c,translate:b,originPoint:i,scenePoint:s,workState:D.Done,viewId:h==null?void 0:h.viewId})}h==null||h.focusElement()},v=E=>{if(!E){m(!0);return}m(!1)},C=E=>[[E.x,E.y],[E.x+E.w,E.y],[E.x+E.w,E.y+E.h],[E.x,E.y+E.h]],N=(E,b)=>{switch(b){case"top":case"topLeft":case"left":return E[2];case"topRight":return E[3];case"right":case"bottomRight":case"bottom":return E[0];case"bottomLeft":return E[1]}},k=(E,b,O,Y)=>{let R=!1,W=!1;const B={x:e.x,y:e.y,w:e.w,h:e.h},H=[1,1],Z=[0,0];switch(E){case"top":{const se=b.height+e.h;se<0?(W=!0,B.y=e.y+e.h,B.h=Math.abs(se)):(B.y=e.y-b.height,B.h=e.h+b.height);break}case"topLeft":{const se=b.width+e.w;se<0?(R=!0,B.x=e.x+e.w,B.w=Math.abs(se)):(B.x=e.x-b.width,B.w=e.w+b.width);const fe=b.height+e.h;fe<0?(W=!0,B.y=e.y+e.h,B.h=Math.abs(fe)):(B.y=e.y-b.height,B.h=e.h+b.height);break}case"topRight":{const se=b.width+e.w;se<0?(R=!0,B.x=e.x+se,B.w=Math.abs(se)):B.w=e.w+b.width;const fe=b.height+e.h;fe<0?(W=!0,B.y=e.y+e.h,B.h=Math.abs(fe)):(B.y=e.y-b.height,B.h=e.h+b.height);break}case"bottom":{const se=b.height+e.h;se<0?(W=!0,B.y=e.y+se,B.h=Math.abs(se)):B.h=e.h+b.height;break}case"bottomLeft":{const se=b.width+e.w;se<0?(R=!0,B.x=e.x+e.w,B.w=Math.abs(se)):(B.x=e.x-b.width,B.w=e.w+b.width);const fe=b.height+e.h;fe<0?(W=!0,B.y=e.y+fe,B.h=Math.abs(fe)):B.h=e.h+b.height;break}case"left":{const se=b.width+e.w;se<0?(R=!0,B.x=e.x+e.w,B.w=Math.abs(se)):(B.x=e.x-b.width,B.w=e.w+b.width);break}case"bottomRight":{const se=b.width+e.w;se<0?(R=!0,B.x=e.x+se,B.w=Math.abs(se)):B.w=e.w+b.width;const fe=b.height+e.h;fe<0?(W=!0,B.y=e.y+fe,B.h=Math.abs(fe)):B.h=e.h+b.height;break}case"right":{const se=b.width+e.w;se<0?(R=!0,B.x=e.x+se,B.w=Math.abs(se)):B.w=e.w+b.width;break}}H[0]=B.w/e.w,H[1]=B.h/e.h;const X=C(B).map(se=>O.control.viewContainerManager.transformToScenePoint(se,O.viewId)),ye=N(X,E);return W&&(Z[1]=ye[1]-Y[1]),R&&(Z[0]=ye[0]-Y[0]),{scale:H,translate:Z}},P=(E,b)=>{if(p.current&&(clearTimeout(p.current),p.current=0),h!=null&&h.control.worker.isBusy){m(!0);return}if(u!=null&&u.w&&(u!=null&&u.h)&&h){const O={x:u.x,y:u.y,w:u.w,h:u.h},Y=C(O),R=Y.map(H=>h.control.viewContainerManager.transformToScenePoint(H,h.viewId)),W=N(Y,b),B=N(R,b);t(O),o(W),a(B),l(b),y(U.ScaleNode),te.emitMethod(ne.MainEngine,U.ScaleNode,{workIds:[Q],originPoint:W,scenePoint:B,workState:D.Start,viewId:h.viewId})}},A=(E,b,O,Y)=>{if(!(!h||!i||!s)){if(h!=null&&h.control.worker.isBusy){m(!0),T();return}p.current||(p.current=setTimeout(()=>{p.current=0;const{scale:R,translate:W}=k(b,Y,h,s);(!j.isEqual(R,d==null?void 0:d.scale)||!j.isEqual(W,d==null?void 0:d.translate))&&(M({scale:R,translate:W}),y(U.ScaleNode),te.emitMethod(ne.MainEngine,U.ScaleNode,{workIds:[Q],scale:R,dir:b,translate:W,originPoint:i,scenePoint:s,workState:D.Doing,viewId:h.viewId}))},60))}},x=()=>{h!=null&&h.control.worker.isBusy&&m(!0),T()};return f.createElement(Tr.Resizable,{className:`${n}`,boundsByDirection:!0,minWidth:-(((u==null?void 0:u.x)||0)+((u==null?void 0:u.w)||0)),minHeight:-(((u==null?void 0:u.y)||0)+((u==null?void 0:u.h)||0)),size:{width:(u==null?void 0:u.w)||0,height:(u==null?void 0:u.h)||0},style:{position:"absolute",left:u==null?void 0:u.x,top:u==null?void 0:u.y,pointerEvents:g?"none":"auto"},enable:w?!1:{top:(u==null?void 0:u.scaleType)===Oe.all&&!0||!1,right:(u==null?void 0:u.scaleType)===Oe.all&&!0||!1,bottom:(u==null?void 0:u.scaleType)===Oe.all&&!0||!1,left:(u==null?void 0:u.scaleType)===Oe.all&&!0||!1,topRight:!0,bottomRight:!0,bottomLeft:!0,topLeft:!0},lockAspectRatio:(u==null?void 0:u.scaleType)===Oe.proportional,onResizeStart:P,onResize:A,onResizeStop:x})},mo=r=>{const{id:n,pos:e,pointMap:t,type:i}=r,{setOperationType:o,mananger:s,floatBarData:a}=f.useContext(Ne),[c,l]=f.useState({x:0,y:0}),[u,h]=f.useState(D.Pending),[g,y]=f.useState(!1),d=f.useRef(0),M=f.useMemo(()=>a?{left:0,top:0}:{},[a]),w=C=>{if(!C||a!=null&&a.isLocked){y(!0),h(D.Pending),o(U.None);return}y(!1)};f.useEffect(()=>(te.activeListener(w),()=>{te.unmountActiveListener(w)}),[]),f.useEffect(()=>{j.isNumber(e.x)&&j.isNumber(e.y)&&(u===D.Pending||u===D.Done)&&l({x:e.x,y:e.y})},[e,u]),f.useEffect(()=>{if(a&&(a!=null&&a.isLocked)||s!=null&&s.control.worker.isBusy){y(!0);return}y(!1)},[a,s==null?void 0:s.control.worker.isBusy]);const m=(C,N)=>{d.current&&(clearTimeout(d.current),d.current=0),o(U.None),h(D.Done);const k={x:N.x,y:N.y};if(l(k),s!=null&&s.control.viewContainerManager){const P=s.control.viewContainerManager.transformToScenePoint([k.x,k.y],s.viewId),A=t.get(n);A&&i==="start"?A[0]=P:A&&i==="end"&&(A[1]=P),te.emitMethod(ne.MainEngine,U.SetPoint,{workId:Q,pointMap:t,workState:D.Done,viewId:s==null?void 0:s.viewId})}s==null||s.focusElement()},p=()=>{if(d.current&&(clearTimeout(d.current),d.current=0),s!=null&&s.control.worker.isBusy){y(!0);return}j.isNumber(e.x)&&j.isNumber(e.y)&&(o(U.SetPoint),h(D.Start),te.emitMethod(ne.MainEngine,U.SetPoint,{workId:Q,pointMap:t,workState:D.Start,viewId:s==null?void 0:s.viewId}))},T=(C,N)=>{if(s!=null&&s.control.worker.isBusy){y(!0),m(C,N);return}if(d.current)return;const k={x:N.x,y:N.y};l(k),d.current=setTimeout(()=>{if(d.current=0,s!=null&&s.control.viewContainerManager){const P=s.control.viewContainerManager.transformToScenePoint([k.x,k.y],s.viewId),A=t.get(n);A&&i==="start"?A[0]=P:A&&i==="end"&&(A[1]=P),h(D.Doing),te.emitMethod(ne.MainEngine,U.SetPoint,{workId:Q,pointMap:t,workState:D.Doing,viewId:s==null?void 0:s.viewId})}},60)},v=(C,N)=>{s!=null&&s.control.worker.isBusy&&y(!0),m(C,N)};return f.createElement(Lt,{disabled:g,position:c,onStart:p,onDrag:T,onStop:v},f.createElement("div",{className:"appliance-plugin-point-draggable-btn",style:M}))},kI=r=>{const{className:n}=r,{floatBarData:e,mananger:t}=f.useContext(Ne),[i,o]=f.useState(),[s,a]=f.useState(),[c,l]=f.useState(new Map);f.useEffect(()=>{const g=[];if(t&&(e!=null&&e.points)){const y=t.viewId;if(t.control.viewContainerManager.getView(y))for(const M of e.points){const w=t.control.viewContainerManager.transformToOriginPoint(M,y);g.push(w)}e!=null&&e.selectIds&&e.selectIds.length===1&&(c.set(e.selectIds[0],e.points),l(c))}g[0]&&o({x:g[0][0],y:g[0][1]}),g[1]&&a({x:g[1][0],y:g[1][1]})},[t,e==null?void 0:e.points,e==null?void 0:e.selectIds,c]);const u=f.useMemo(()=>i&&(e!=null&&e.selectIds)?f.createElement(mo,{pos:i,type:"start",id:e.selectIds[0],pointMap:c}):null,[i,e==null?void 0:e.selectIds,c]),h=f.useMemo(()=>s&&(e!=null&&e.selectIds)?f.createElement(mo,{pos:s,type:"end",id:e.selectIds[0],pointMap:c}):null,[s,e==null?void 0:e.selectIds,c]);return f.createElement("div",{className:`${n}`},u,h)},xI=f.forwardRef((r,n)=>{const{floatBarData:e,operationType:t}=f.useContext(Ne),i=f.useMemo(()=>(e==null?void 0:e.scaleType)!==Oe.all||t===U.RotateNode?null:f.createElement(fI,null),[e,t]),o=f.useMemo(()=>(e==null?void 0:e.scaleType)!==Oe.both||t===U.RotateNode?null:f.createElement(pI,null),[e,t]),s=f.useMemo(()=>(e==null?void 0:e.scaleType)!==Oe.proportional||t===U.RotateNode?null:f.createElement(MI,null),[e,t]),a=f.useMemo(()=>(e==null?void 0:e.scaleType)===Oe.none&&(e!=null&&e.canLock)?f.createElement(yI,null):null,[e]);return f.createElement("div",{ref:n,style:e?{transform:`translate(${e.x}px,${e.y}px)`,width:e.w,height:e.h,pointerEvents:"none"}:void 0},a,i,o,s,r.children)}),bI=f.memo(r=>{const{isHide:n,operationType:e,floatBarData:t}=r;return n&&e===U.None&&j.isNumber(t==null?void 0:t.x)&&j.isNumber(t==null?void 0:t.y)&&j.isNumber(t==null?void 0:t.w)&&j.isNumber(t==null?void 0:t.h)?f.createElement("div",{className:ke.FloatBarBtn,style:{left:t==null?void 0:t.x,top:t==null?void 0:t.y,width:t.w,height:t.h}},f.createElement(mr,{position:{x:t.x,y:t.y},textOpt:t==null?void 0:t.textOpt,noLayer:t==null?void 0:t.isLocked})):null},(r,n)=>!!j.isEqual(r,n)),DI=f.forwardRef((r,n)=>{const{floatBarData:e,operationType:t,mananger:i}=f.useContext(Ne),{editors:o,isHide:s,canSelectorSwitch:a}=r,c=f.useRef(null);f.useEffect(()=>{const g=c.current;if(!g)return;const y=d=>{d.stopPropagation(),d.stopImmediatePropagation(),i==null||i.control.worker.blurCursor(i.viewId)};return g.addEventListener("pointerdown",y,!1),()=>{g.removeEventListener("pointerdown",y,!1)}},[i]);const l=f.useMemo(()=>{var g;return e!=null&&e.canRotate&&((g=e==null?void 0:e.selectIds)==null?void 0:g.length)===1&&(t===U.None||t===U.RotateNode)?f.createElement(mI,{className:ke.RotateBtn}):null},[e,t]),u=f.useMemo(()=>((e==null?void 0:e.scaleType)===Oe.all||(e==null?void 0:e.scaleType)===Oe.proportional)&&(t===U.None||t===U.ScaleNode)&&j.isNumber(e==null?void 0:e.x)&&j.isNumber(e==null?void 0:e.y)?f.createElement(CI,{className:ke.ResizeBtn}):null,[e==null?void 0:e.scaleType,t,e==null?void 0:e.x,e==null?void 0:e.y]),h=f.useMemo(()=>(e==null?void 0:e.scaleType)===Oe.both&&(t===U.None||t===U.SetPoint)?f.createElement(kI,{className:ke.ResizeTowBox}):null,[e==null?void 0:e.scaleType,t]);return f.createElement("div",{ref:c,className:ke.FloatBar,onPointerOver:g=>(nn(g),i==null||i.control.worker.blurCursor(i.viewId),!1)},f.createElement(xI,{ref:n}),f.createElement(vI,{editors:o,canSelectorSwitch:a}),l,u,h,f.createElement(bI,{isHide:s,operationType:t,floatBarData:e}))}),jI=f.memo(DI,(r,n)=>!!j.isEqual(r,n));class EI extends f.Component{constructor(e){super(e);I(this,"renderAvatar",e=>{var i;const t=`rgb(${e.memberState.strokeColor[0]}, ${e.memberState.strokeColor[1]}, ${e.memberState.strokeColor[2]})`;if(this.detectAvatar(e)){const o=this.getCursorName(e);return f.createElement("img",{className:"cursor-selector-avatar",style:{width:o?19:28,height:o?19:28,position:o?"initial":"absolute",borderColor:o?"white":t,marginRight:o?4:0},src:(i=e.payload)==null?void 0:i.avatar,alt:"avatar"})}else return null});I(this,"getOpacity",e=>{const t=this.getCursorName(e),i=this.detectAvatar(e);return t===void 0&&i===void 0?0:1});I(this,"getCursorName",e=>{if(e.payload)return e.payload.nickName||e.payload.cursorName||e.payload.uid});I(this,"getThemeClass",e=>e.payload&&e.payload.theme?"cursor-inner-mellow":"cursor-inner");I(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});I(this,"getCursorTextColor",e=>e.payload&&e.payload.cursorTextColor?e.payload.cursorTextColor:"#FFFFFF");I(this,"getCursorTagBackgroundColor",e=>e.payload&&e.payload.cursorTagBackgroundColor?e.payload.cursorTagBackgroundColor:this.getCursorBackgroundColor(e));I(this,"detectAvatar",e=>!!(e.payload&&e.payload.avatar));I(this,"renderTag",e=>{if(e.payload&&e.payload.cursorTagName)return f.createElement("span",{className:"cursor-tag-name",style:{backgroundColor:this.getCursorTagBackgroundColor(e)}},e.payload.cursorTagName)});I(this,"renderCursor",e=>{const t=Jm.get(e);return t&&this.props.isEnableCursor?f.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 ie.pencil:return f.createElement("div",{className:"cursor-box"},f.createElement("div",{className:"cursor-mid cursor-pencil-offset",style:{transform:"translate(-50%, -100%)",marginLeft:"5px",marginTop:"4px"}},f.createElement("div",{className:"cursor-name"},f.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),f.createElement("span",{className:"cursor-name-text"},t),this.renderTag(e))),f.createElement("div",null,this.renderCursor("pencil"))));case ie.selector:return f.createElement("div",{className:"cursor-box"},f.createElement("div",{className:"cursor-mid cursor-selector-offset",style:{transform:"translate(-50%, -100%)",marginLeft:"3px",marginTop:"17px"}},f.createElement("div",{className:"cursor-name"},f.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),f.createElement("span",{className:"cursor-name-text"},t),this.renderTag(e))),f.createElement("div",null,this.renderCursor("selector"))));case ie.eraser:case ie.pencilEraser:return f.createElement("div",{className:"cursor-box"},f.createElement("div",{className:"cursor-mid cursor-eraser-offset",style:{transform:"translate(-50%, -100%)",marginLeft:"2px",marginTop:"8px"}},f.createElement("div",{className:"cursor-name"},f.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),f.createElement("span",{className:"cursor-name-text"},t),this.renderTag(e))),f.createElement("div",null,this.renderCursor("eraser"))));case ie.text:return f.createElement("div",{className:"cursor-box"},f.createElement("div",{className:"cursor-mid cursor-text-offset",style:{transform:"translate(-50%, -100%)",marginLeft:"0px"}},f.createElement("div",{className:"cursor-name"},f.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),f.createElement("span",{className:"cursor-name-text"},t),this.renderTag(e))),f.createElement("div",null,this.renderCursor("text"))));case ie.rectangle:case ie.arrow:case ie.straight:case ie.shape:case ie.ellipse:return f.createElement("div",{className:"cursor-box"},f.createElement("div",{className:"cursor-mid cursor-shape-offset",style:{transform:"translate(-50%, -100%)",marginLeft:"-3px",marginTop:"19px"}},f.createElement("div",{className:"cursor-name"},f.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),f.createElement("span",{className:"cursor-name-text"},t),this.renderTag(e))),f.createElement("div",null,this.renderCursor("shape"))));default:return null}}}const AI=r=>{var s;const{className:n,info:e,isEnableCursor:t}=r,{roomMember:i,...o}=e||{};return f.createElement("div",{"data-cursor-uid":(s=i==null?void 0:i.payload)==null?void 0:s.uid,className:`${n}`,style:o?{transform:`translate(${o.x}px, ${o.y}px)`}:{display:"none"}},i&&f.createElement(EI,{roomMember:i,isEnableCursor:t}))},zI=r=>{const{className:n,manager:e}=r,[t,i]=f.useState();f.useEffect(()=>(e.internalMsgEmitter.on([ne.Cursor,e.viewId],o),()=>{e.internalMsgEmitter.off([ne.Cursor,e.viewId],o)}),[e]);function o(a){i(a)}return f.useMemo(()=>{if(t!=null&&t.length){const a=t.map(c=>{var l;return c.roomMember?f.createElement(AI,{key:(l=c.roomMember)==null?void 0:l.memberId,className:n,info:c,isEnableCursor:e.control.cursor.isEnableCursor}):null});return f.createElement(f.Fragment,null,a)}return null},[t])},LI=r=>{const{viewId:n,miniMapCanvas:e,highlightColor:t,miniMapManager:i,contianer:o}=r,[s,a]=f.useState();f.useEffect(()=>(c(),i.listener.addListener([n,"viewCameraUpate"],c),i.listener.emitAsync([n,"miniMapCreate"],!0),()=>{i.listener.removeListener([n,"viewCameraUpate"],c)}),[]);const c=()=>{const h=i.maps.get(n);h&&l(h.miniMapCamera,h.viewCamera)},l=(h,g)=>{const{width:y,height:d}=o.getBoundingClientRect(),M=Math.min(y/h.width,d/h.height),w=g.width/g.scale,m=g.height/g.scale,p=[g.centerX,g.centerY],T=[h.centerX,h.centerY],v=[p[0]-T[0],p[1]-T[1]],C=Math.min(h.scale*M,h.scale*M),N=[v[0]*C,v[1]*C,w,m,C];a(N)},u=h=>{var g;if(i.control.renderControl.isWritable){const y=h.nativeEvent.target||h.nativeEvent.srcElement;if(y&&h.nativeEvent&&s){const{width:d,height:M}=y.getBoundingClientRect(),[w,m]=[d/2,M/2],[p,T]=[(h.nativeEvent.offsetX-w)/s[4],(h.nativeEvent.offsetY-m)/s[4]],v=i.maps.get(n);if(v!=null&&v.viewCamera){const[C,N]=[v.miniMapCamera.centerX+p,v.miniMapCamera.centerY+T];(g=i.control.room)==null||g.moveCamera({centerX:C,centerY:N,animationMode:"immediately"})}}}};return f.createElement("div",{style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",pointerEvents:"auto"},onClick:u},f.createElement("canvas",{style:{pointerEvents:"none"},ref:e}),s&&f.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"}}))},PI=r=>{const{miniMapManager:n,active:e,className:t}=r,i=f.useMemo(()=>{const o=n.maps;if(e){const s=o.get(e);if(s){const{miniMapCamera:a,viewCamera:c,...l}=s;if(l.contianer&&a&&c){const u=n.highlightColor;return fn.createPortal(f.createElement(LI,{viewId:e,...l,highlightColor:u,miniMapManager:n}),l.contianer)}}}return null},[e,n]);return f.createElement("div",{className:t},i)},Ne=f.createContext({viewId:"",mananger:void 0,floatBarColors:[],overwriteSelectorStyles:{},floatBarData:void 0,dpr:1,angle:0,operationType:U.None,scale:[1,1],isNoPointerEvents:!1,activeTextEditor:!1,activeTextId:void 0,setAngle:()=>{},setOperationType:()=>{},setFloatBarData:()=>{}});class vi extends f.Component{constructor(e){var i,o;super(e);I(this,"showTextFloatBar");I(this,"canSelectorSwitch");I(this,"rightBoundBreak");I(this,"setAngle",e=>{this.setState({angle:e})});I(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:(i=this.props.mananger.control.textEditorManager)==null?void 0:i.activeId,activeMiniMapViewId:(o=this.props.mananger.control.miniMapManager)==null?void 0:o.activeViewId};const t=this.props.mananger.control.pluginOptions.extras.textEditor;this.showTextFloatBar=j.isBoolean(t.showFloatBar)?t.showFloatBar:Ie.textEditor.showFloatBar,this.canSelectorSwitch=j.isBoolean(t==null?void 0:t.canSelectorSwitch)?t.canSelectorSwitch:Ie.textEditor.canSelectorSwitch,this.rightBoundBreak=j.isBoolean(t==null?void 0:t.rightBoundBreak)?t.rightBoundBreak:Ie.textEditor.rightBoundBreak}get editors(){return en(this.props.mananger.control.textEditorManager.filterEditor(this.props.mananger.viewId))}componentDidMount(){this.props.mananger.vDom=this,this.props.mananger.mountView(),this.setState({dpr:this.props.mananger.dpr})}componentWillUnmount(){}setActiveMiniMap(e){this.setState({activeMiniMapViewId:e})}showFloatBarBtn(e){this.setState({showFloatBarBtn:e})}showFloatBar(e,t){const i=e&&t&&{...this.state.floatBarData,...t}||void 0;this.setState({showFloatBar:e,floatBarData:i,angle:0})}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,i,o,s,a,c;const e=!!((i=(t=this.props.mananger.control)==null?void 0:t.room)!=null&&i.floatBarOptions);return f.createElement("div",{className:ke.Container},!this.props.mananger.control.hasOffscreenCanvas&&f.createElement("div",{className:ke.CanvasBox,ref:this.props.refs.canvasContainerRef})||f.createElement("div",{className:ke.CanvasBox},f.createElement("canvas",{id:"bgCanvas",ref:this.props.refs.canvasBgRef,style:{width:"100%",height:"100%"}}),f.createElement("canvas",{id:"serviceCanvas",className:ke.FloatCanvas,ref:this.props.refs.canvasServiceFloatRef,style:{width:"100%",height:"100%"}}),f.createElement("canvas",{id:"localCanvas",className:ke.FloatCanvas,ref:this.props.refs.canvasFloatRef,style:{width:"100%",height:"100%"}}),!this.props.mananger.control.isUseSimple&&f.createElement("div",{id:"subLocalCanvas",className:ke.CanvasBoxSub,ref:this.props.refs.subLocalCanvasContainerRef}),!this.props.mananger.control.isUseSimple&&f.createElement("canvas",{id:"topCanvas",className:ke.TopFloatCanvas,ref:this.props.refs.canvasTopRef,style:{width:"100%",height:"100%"}})),!this.props.mananger.control.hasOffscreenCanvas&&this.props.refs.snapshotContainerRef&&f.createElement("div",{className:ke.SnapshotBox,ref:this.props.refs.snapshotContainerRef})||null,this.props.mananger.control.isUseBackgroundThread&&!!this.props.refs.backgroundContainerRef&&f.createElement("div",{className:ke.BackgroundBox},f.createElement("div",{className:ke.BackgroundSvgBox,ref:this.props.refs.backgroundContainerRef}),!!this.props.refs.backgroundSnapshotContainerRef&&f.createElement("div",{className:ke.BackgroundSnapshotBox},f.createElement("div",{className:ke.BackgroundSnapshotContent,ref:this.props.refs.backgroundSnapshotContainerRef})))||null,f.createElement(Ne.Provider,{value:{viewId:this.props.viewId,mananger:this.props.mananger,floatBarColors:e&&((a=(s=(o=this.props.mananger.control)==null?void 0:o.room)==null?void 0:s.floatBarOptions)==null?void 0:a.colors)||[],overwriteSelectorStyles:this.props.mananger.control.pluginOptions.extras.overwriteSelectorStyles||{},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&&f.createElement(jI,{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)&&f.createElement(gI,{className:ke.TextEditorContainer,showFloatBtns:this.showTextFloatBar&&e&&this.state.showFloatBarBtn||!1,editors:this.state.editors,rightBoundBreak:this.rightBoundBreak})||null),f.createElement("div",{className:"appliance-plugin-custom-floatbar-container","data-view-id":this.props.viewId,ref:this.props.refs.customFloatbarContainerRef}),f.createElement(zI,{className:ke.CursorBox,manager:this.props.mananger}),!this.props.mananger.control.isUseSimple&&f.createElement(PI,{className:ke.MiniMapBox,active:this.state.activeMiniMapViewId,miniMapManager:this.props.mananger.control.miniMapManager}))}}class RI extends Mr{constructor(e,t){super(e,t);I(this,"width",1e3);I(this,"height",1e3);I(this,"dpr",zt());I(this,"vDom");I(this,"eventTragetElement");I(this,"snapshotContainerRef");I(this,"backgroundSnapshotContainerRef");I(this,"canvasContainerRef",f.createRef());I(this,"subLocalCanvasContainerRef");I(this,"canvasTopRef");I(this,"canvasServiceFloatRef",f.createRef());I(this,"canvasFloatRef",f.createRef());I(this,"canvasBgRef",f.createRef());I(this,"backgroundContainerRef");I(this,"floatBarRef",f.createRef());I(this,"customFloatbarContainerRef",f.createRef());I(this,"containerOffset",{x:0,y:0});this.control.hasOffscreenCanvas||(this.snapshotContainerRef=f.createRef()),this.control.isUseSimple||(this.canvasTopRef=f.createRef(),this.subLocalCanvasContainerRef=f.createRef()),this.control.isUseBackgroundThread&&(this.backgroundContainerRef=f.createRef(),this.backgroundSnapshotContainerRef=f.createRef())}setCanvassStyle(){var e,t;if(this.eventTragetElement){const i=this.eventTragetElement.offsetWidth||this.width,o=this.eventTragetElement.offsetHeight||this.height,s=zt();s!==this.dpr&&(this.dpr=s,this.control.worker.updateDpr(this.viewId,this.dpr)),i&&o&&this.canvasContainerRef.current&&(i!==this.width||o!==this.height)&&(this.width=i,this.height=o,this.canvasContainerRef.current.style.width=`${i}px`,this.canvasContainerRef.current.style.height=`${o}px`),i&&o&&this.snapshotContainerRef&&this.snapshotContainerRef.current&&(i!==this.width||o!==this.height)&&(this.width=i,this.height=o),i&&o&&this.canvasBgRef.current&&(i!==this.width||o!==this.height)&&(this.width=i,this.height=o,this.control.isUseOffscreenTransfer||(this.canvasBgRef.current.width=i*this.dpr,this.canvasBgRef.current.height=o*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=i*this.dpr,this.canvasFloatRef.current.height=o*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=i*this.dpr,this.canvasServiceFloatRef.current.height=o*this.dpr),(e=this.canvasTopRef)!=null&&e.current&&(this.canvasTopRef.current.width=i*this.dpr,this.canvasTopRef.current.height=o*this.dpr))),i&&o&&this.backgroundContainerRef&&((t=this.backgroundContainerRef)!=null&&t.current)&&(i!==this.width||o!==this.height)&&(this.backgroundContainerRef.current.style.width=`${i}px`,this.backgroundContainerRef.current.style.height=`${o}px`,this.backgroundContainerRef.current.classList.toggle("appliance-plugin-background-isWritable",this.control.renderControl.isWritable))}}destroy(){if(super.destroy(),this.eventTragetElement){const e=this.eventTragetElement.parentElement;if(e){const t=e.querySelectorAll(".appliance-plugin-main-view-displayer");for(const i of t)i.remove()}}}createMainViewDisplayer(e){const t=document.createElement("div");return t.className="appliance-plugin-main-view-displayer",e.appendChild(t),this.eventTragetElement=e.children[0],this.containerOffset=this.getContainerOffset(this.eventTragetElement,this.containerOffset),this.bindToolsClass(),fn.render(f.createElement(vi,{viewId:this.viewId,mananger:this,refs:{canvasServiceFloatRef:this.canvasServiceFloatRef,canvasFloatRef:this.canvasFloatRef,canvasBgRef:this.canvasBgRef,floatBarRef:this.floatBarRef,customFloatbarContainerRef:this.customFloatbarContainerRef,canvasTopRef:this.canvasTopRef,canvasContainerRef:this.canvasContainerRef,snapshotContainerRef:this.snapshotContainerRef,subLocalCanvasContainerRef:this.subLocalCanvasContainerRef,backgroundContainerRef:this.backgroundContainerRef,backgroundSnapshotContainerRef:this.backgroundSnapshotContainerRef}}),t),this.control.room&&this.bindDisplayerEvent(this.eventTragetElement),this}}class OI extends Mm{constructor(e,t,i){super(e,t,i);I(this,"dpr",zt());I(this,"width",1e3);I(this,"height",1e3);I(this,"vDom");I(this,"eventTragetElement");I(this,"canvasContainerRef",f.createRef());I(this,"subLocalCanvasContainerRef");I(this,"canvasTopRef");I(this,"canvasServiceFloatRef",f.createRef());I(this,"canvasFloatRef",f.createRef());I(this,"canvasBgRef",f.createRef());I(this,"backgroundContainerRef");I(this,"floatBarRef",f.createRef());I(this,"customFloatbarContainerRef",f.createRef());I(this,"containerOffset",{x:0,y:0});this.control.isUseSimple||(this.canvasTopRef=f.createRef(),this.subLocalCanvasContainerRef=f.createRef()),this.control.isUseBackgroundThread&&(this.backgroundContainerRef=f.createRef())}setCanvassStyle(){var e,t;if(this.eventTragetElement){const i=zt();if(i!==this.dpr&&(this.dpr=i,this.control.worker.updateDpr(this.viewId,this.dpr)),this.canvasContainerRef.current){const o=this.eventTragetElement.offsetWidth||this.width,s=this.eventTragetElement.offsetHeight||this.height;o&&s&&(o!==this.width||s!==this.height)&&(this.width=o,this.height=s,this.canvasContainerRef.current.style.width=`${o}px`,this.canvasContainerRef.current.style.height=`${s}px`)}if(this.canvasBgRef.current){const o=this.eventTragetElement.offsetWidth||this.width,s=this.eventTragetElement.offsetHeight||this.height;o&&s&&(o!==this.width||s!==this.height)&&(this.width=o,this.height=s,this.control.isUseOffscreenTransfer||(this.canvasBgRef.current.width=o*this.dpr,this.canvasBgRef.current.height=s*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=o*this.dpr,this.canvasFloatRef.current.height=s*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=o*this.dpr,this.canvasServiceFloatRef.current.height=s*this.dpr),(e=this.canvasTopRef)!=null&&e.current&&(this.canvasTopRef.current.width=o*this.dpr,this.canvasTopRef.current.height=s*this.dpr)))}if(this.backgroundContainerRef&&((t=this.backgroundContainerRef)!=null&&t.current)){const o=this.eventTragetElement.offsetWidth||this.width,s=this.eventTragetElement.offsetHeight||this.height;o&&s&&(o!==this.width||s!==this.height)&&(this.backgroundContainerRef.current.style.width=`${o}px`,this.backgroundContainerRef.current.style.height=`${s}px`,this.backgroundContainerRef.current.classList.toggle("appliance-plugin-background-isWritable",this.control.renderControl.isWritable))}}}createAppViewDisplayer(e,t){const i=document.createElement("div");return i.className="appliance-plugin-app-view-displayer",t.appendChild(i),this.eventTragetElement=t.children[0],this.containerOffset=this.getContainerOffset(this.eventTragetElement,this.containerOffset),this.bindToolsClass(),fn.render(f.createElement(vi,{viewId:e,mananger:this,refs:{canvasServiceFloatRef:this.canvasServiceFloatRef,canvasFloatRef:this.canvasFloatRef,canvasBgRef:this.canvasBgRef,floatBarRef:this.floatBarRef,customFloatbarContainerRef:this.customFloatbarContainerRef,canvasTopRef:this.canvasTopRef,canvasContainerRef:this.canvasContainerRef,subLocalCanvasContainerRef:this.subLocalCanvasContainerRef,backgroundContainerRef:this.backgroundContainerRef}}),i),this.control.room&&this.bindDisplayerEvent(this.eventTragetElement),this}}class rt extends At{constructor(e){super(e);I(this,"focuedViewId");I(this,"focuedView");I(this,"control");I(this,"tmpFocusedViewId");I(this,"checkScaleTimer");I(this,"mainViewHotkeyListener",e=>{this.onActiveHotkeyChange(e)});I(this,"appViewListeners",new Map);I(this,"onMainViewRelease",async e=>{this.control.textEditorManager.clear(re,!0),this.mainViewDestroy(e),await new Promise(i=>{setTimeout(()=>{i(!0)},0)}),this.onMainViewMounted(e);const t=this.control.getSnapshootData("memberState");this.control.room&&this.control.onMemberChange(t),this.control.clearSnapshootData()});I(this,"mainViewDestroy",e=>{var t;if(this.mainView&&this.mainView.displayer){this.removeMainViewListeners(this.mainView.viewData),this.mainView.displayer.destroy();const i=e.divElement;if(i){const o=i.getElementsByClassName("appliance-plugin-main-view-displayer");for(const s of o)s.remove()}if(this.mainView.container&&i!==this.mainView.container){const o=this.mainView.container.getElementsByClassName("appliance-plugin-main-view-displayer");for(const s of o)s.remove()}(t=this.control.worker)==null||t.destroyViewWorker(this.mainView.id,!0),this.mainView=void 0}});I(this,"onMainViewMounted",e=>{const t=e.divElement;if(!t||!e.focusScenePath||!(e.focusScenePath||e.scenePath))return;const o=new RI(this.control,Me.InternalMsgEmitter),s=e.size.width||o.width,a=e.size.height||o.height;o.dpr;const c={cameraOpt:{...rt.defaultCameraOpt,width:s,height:a}},{scale:l,...u}=e.camera;c.cameraOpt={...c.cameraOpt,...u,scale:l===1/0?1:l},this.createMianView({id:re,container:t,displayer:o,focusScenePath:e.focusScenePath,cameraOpt:c.cameraOpt,viewData:e}),this.setFocuedViewId(re),o.createMainViewDisplayer(t),e.callbacks.on("onSizeUpdated",this.onMainViewSizeUpdated),e.callbacks.on("onCameraUpdated",this.onMainViewCameraUpdated),e.callbacks.on("onActiveHotkey",this.mainViewHotkeyListener)});I(this,"onMainViewSizeUpdated",async()=>{await new Promise(e=>{setTimeout(()=>{e(!0)},0)}),this.mainView&&this.mainView.viewData&&this.updateMainViewCamera()});I(this,"onMainViewCameraUpdated",async()=>{await new Promise(e=>{setTimeout(()=>{e(!0)},0)}),this.updateMainViewCamera()});I(this,"updateMainViewCamera",()=>{if(this.mainView&&this.mainView.viewData){const e=this.mainView.viewData.camera;if(!j.isNumber(e.scale)||e.scale===1/0)return;const t=this.mainView.cameraOpt;if(t){const i=t.width,o=t.height,{width:s,height:a}=this.mainView.viewData.size;(s!==i||a!==o)&&this.mainView.displayer.updateSize();const c=e.scale===1/0?1:e.scale,l=e.centerX||0,u=e.centerY||0,h={...t,scale:c,centerX:l,centerY:u,width:s,height:a};j.isEqual(t,h)||(this.mainView.cameraOpt=h),this.checkScaleTimer&&e.scale==1/0&&(clearTimeout(this.checkScaleTimer),this.checkScaleTimer=void 0),!this.checkScaleTimer&&e.scale===1/0&&this.mainView.viewData&&this.mainView.viewData.camera.scale===1/0&&(this.checkScaleTimer=setTimeout(()=>{var g,y;(y=(g=this.mainView)==null?void 0:g.viewData)==null||y.moveCamera({scale:c,centerX:l,centerY:u,animationMode:"immediately"}),this.checkScaleTimer=void 0},500))}}});I(this,"onAppViewMounted",async e=>{var g;const{appId:t,view:i}=e,o=i.divElement;if(!o||!i.focusScenePath)return;const s=this.appViews.get(t);if(s&&s.displayer){let y=o.getElementsByClassName("appliance-plugin-app-view-displayer");for(const d of y)d.remove();if(s.container&&s.container!==o){y=s.container.getElementsByClassName("appliance-plugin-app-view-displayer");for(const d of y)d.remove()}this.destroyAppView(e.appId,!0),(g=this.control.worker)==null||g.destroyViewWorker(t,!0),await new Promise(d=>{setTimeout(()=>{d(!0)},0)})}const a=new OI(t,this.control,Me.InternalMsgEmitter),c=i.size.width||a.width,l=i.size.height||a.height;a.dpr;const u={cameraOpt:{...rt.defaultCameraOpt,...i.camera,width:c,height:l}};this.createAppView({id:t,container:o,displayer:a,cameraOpt:u.cameraOpt,focusScenePath:i.focusScenePath,viewData:i}),a.createAppViewDisplayer(t,o);const h=this.getAppViewListeners(t);if(i.callbacks.on("onSizeUpdated",h.onSizeUpdated),i.callbacks.on("onCameraUpdated",h.onCameraUpdated),i.callbacks.on("onActiveHotkey",h.onActiveHotkey),this.tmpFocusedViewId===t){const y=this.control.worker.getLocalWorkViewId();y&&y!==t?this.setFocuedViewId(y):this.setFocuedViewId(t),this.tmpFocusedViewId=void 0}setTimeout(()=>{this.onAppViewCameraUpdated(t)},0)});I(this,"onAppViewSizeUpdated",async e=>{await new Promise(i=>{setTimeout(()=>{i(!0)},0)});const t=this.appViews.get(e);t&&t.viewData&&this.updateAppCamera(e)});I(this,"onAppViewCameraUpdated",async e=>{await new Promise(t=>{setTimeout(()=>{t(!0)},0)}),this.updateAppCamera(e)});I(this,"updateAppCamera",e=>{const t=this.appViews.get(e);if(t&&t.viewData){const i=t.viewData.camera,o=t.cameraOpt;if(o){const{width:s,height:a}=t.viewData.size,c=o.width,l=o.height;(s!==c||a!==l)&&t.displayer.updateSize();const u=i.scale===1/0?1:i.scale,h=i.centerX||0,g=i.centerY||0,y={...o,scale:u,centerX:h,centerY:g,width:s,height:a};j.isEqual(y,o)||(t.cameraOpt=y)}}});this.control=e.control}getAppViewListeners(e){let t=this.appViewListeners.get(e);return t||(t={onSizeUpdated:()=>{this.onAppViewSizeUpdated(e)},onCameraUpdated:()=>{this.onAppViewCameraUpdated(e)},onActiveHotkey:i=>{this.onActiveHotkeyChange(i)}},this.appViewListeners.set(e,t)),t}removeMainViewListeners(e){e&&(e.callbacks.off("onSizeUpdated",this.onMainViewSizeUpdated),e.callbacks.off("onCameraUpdated",this.onMainViewCameraUpdated),e.callbacks.off("onActiveHotkey",this.mainViewHotkeyListener))}removeAppViewListeners(e,t){const i=this.appViewListeners.get(e);t&&i&&(t.callbacks.off("onSizeUpdated",i.onSizeUpdated),t.callbacks.off("onCameraUpdated",i.onCameraUpdated),t.callbacks.off("onActiveHotkey",i.onActiveHotkey)),this.appViewListeners.delete(e)}destroyAppView(e,t=!1){const i=this.appViews.get(e);this.removeAppViewListeners(e,i==null?void 0:i.viewData),super.destroyAppView(e,t)}destroy(){var e;this.removeMainViewListeners((e=this.mainView)==null?void 0:e.viewData);for(const[t,i]of this.appViews.entries())this.removeAppViewListeners(t,i.viewData);super.destroy(),this.appViewListeners.clear()}getViewInitData(e){var i;const t=this.getView(e);if(t){const{width:o,height:s,dpr:a}=t.displayer;(i=this.control.pluginOptions.extras.canvasOpt)!=null&&i.contextType&&(rt.defaultScreenCanvasOpt.contextType=this.control.pluginOptions.extras.canvasOpt.contextType);const c={dpr:a,originalPoint:[o/2,s/2],offscreenCanvasOpt:{...rt.defaultScreenCanvasOpt,width:o,height:s},layerOpt:{...rt.defaultLayerOpt,width:o,height:s},cameraOpt:{...rt.defaultCameraOpt,width:o,height:s}};if(t.viewData){const{scale:l,...u}=t.viewData.camera;c.cameraOpt={...c.cameraOpt,...u,scale:l===1/0?1:l}}return c}}async mountView(e){var i,o,s;const t=this.getView(e);if(t){e===((i=this.mainView)==null?void 0:i.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 a=this.getViewInitData(e);if(a&&((o=this.control.worker)==null||o.createViewWorker(e,a,t.displayer)),t.focusScenePath&&this.control.collector){if(this.control.collector.authStorage){const{renderAuth:c,pageAuth:l}=this.control.collector.authStorage;if(c){const u=c[e];if(u){const{render:h,hide:g,clear:y}=u;this.control.renderControl.syncRenderUids(e,h,g,y);return}}if(l){const u=l[e];if(u){this.control.renderControl.syncPageAuth(e,u,!0);return}}}this.control.worker.pullServiceData(e,t.focusScenePath,{isAsync:!0,useAnimation:!1}),this.control.pluginOptions.extras.undoRedo.enableGlobal&&t.displayer.commiter&&((s=this.control.collector)!=null&&s.globalUndoRedoStackStorage[t.id])&&t.displayer.commiter.pullServiceData(this.control.collector.globalUndoRedoStackStorage[t.id])}}}listenerWindowManager(e){e.emitter.on("focusedChange",t=>{const i=t||re;if(this.focuedViewId!==i)if(this.getView(i)){const s=this.control.worker.getLocalWorkViewId();s&&s!==i?this.setFocuedViewId(s):this.setFocuedViewId(i)}else this.tmpFocusedViewId=i}),e.emitter.on("mainViewScenePathChange",t=>{this.control.onSceneChange(t,re)}),e.emitter.on("onMainViewMounted",this.onMainViewMounted),e.emitter.on("onAppViewMounted",this.onAppViewMounted),e.emitter.on("onMainViewRebind",this.onMainViewRelease),e.emitter.on("onBoxClose",t=>{this.appViews.get(t.appId)&&(this.destroyAppView(t.appId),this.control.worker.destroyViewWorker(t.appId))}),e.emitter.on("onAppScenePathChange",t=>{const{appId:i,view:o}=t;this.control.onSceneChange(o.focusScenePath,i)}),e.emitter.on("appsChange",t=>{for(const i of this.appViews.keys())t.includes(i)||(this.destroyAppView(i),this.control.worker.destroyViewWorker(i,!0))})}onActiveHotkeyChange(e){this.control.hotkeyManager.onActiveHotkey(e)}}class ot extends Me{constructor(e){super(e);I(this,"windowManager");I(this,"viewContainerManager");const t={control:this,internalMsgEmitter:Me.InternalMsgEmitter,publicMsgEmitter:Me.PublicMsgEmitter};this.viewContainerManager=new rt(t)}init(){}activePlugin(){this.collector&&(this.collector.addAuthStateListener((e,t)=>{e&&Object.keys(e).forEach(i=>{var s;const o=(s=e[i])==null?void 0:s.newValue;this.renderControl.syncRenderUids(i,o==null?void 0:o.render,o==null?void 0:o.hide,o==null?void 0:o.clear)}),t&&Object.keys(t).forEach(i=>{var s;const o=(s=t[i])==null?void 0:s.newValue;this.renderControl.syncPageAuth(i,o)})}),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(re,!0);return}const{diffView:t,diffScenePath:i,diffData:o}=e,s=new Map;if(t){let l;Object.keys(t).forEach(u=>{var g;const h=t[u];if(h&&!h.newValue)(g=this.worker)==null||g.clearViewScenePath(u,!0),h.oldValue&&(l=h.oldValue);else if(h&&h.newValue){for(const y of Object.keys(h.newValue))this.worker.pullServiceData(u,y,{isAsync:!1,useAnimation:!1});l=h.newValue}if(l)for(const y of Object.values(l)){const d=new Set;for(const M of Object.keys(y))M&&d.add(M);s.set(u,d)}})}if(i){let l;Object.keys(i).forEach(u=>{var g;const h=i[u];if(h&&h.viewId&&!h.newValue?((g=this.worker)==null||g.clearViewScenePath(h.viewId,!0),h.oldValue&&(l=h.oldValue)):h&&h.viewId&&h.newValue&&(this.worker.pullServiceData(h.viewId,u,{isAsync:!1,useAnimation:!1}),l=h.newValue),h!=null&&h.viewId&&l){const y=new Set;for(const d of Object.keys(l))d&&y.add(d),s.set(h.viewId,y)}})}o&&Object.keys(o).forEach(l=>{var h,g;const u=o[l];if(u){const{viewId:y}=u,d=s.get(y)||new Set;d.add(l),s.set(y,d),(h=this.worker)==null||h.onServiceDerive(l,u),(g=this.miniMapManager)==null||g.updateMiniMapCamera(y)}});for(const[l,u]of s.entries())Me.InternalMsgEmitter.emit("excludeIds",[...u],l)}),this.pluginOptions.extras.undoRedo.enableGlobal&&this.collector.addGlobalUndoRedoStackListener(e=>{Object.keys(e).forEach(t=>{var s;const i=e[t],o=(s=this.viewContainerManager.getView(t))==null?void 0:s.displayer.commiter;o&&o.pullServiceData(i==null?void 0:i.newValue)})}),this.worker.isActive&&this.viewContainerManager.getAllViews().forEach(e=>{e&&e.focusScenePath&&this.worker.pullServiceData(e.id,e.focusScenePath,{isAsync:!0,useAnimation:!1})}),this.room&&this.roomMember.onUidChangeHook(e=>{var t,i;(t=this.collector)!=null&&t.serviceStorage&&this.viewContainerManager.getAllViews().forEach(o=>{var s,a,c,l;if(o&&o.focusScenePath&&((s=this.collector)!=null&&s.serviceStorage[o.id])&&this.collector.serviceStorage[o.id][o.focusScenePath]){const u=Object.keys(this.collector.serviceStorage[o.id][o.focusScenePath]);for(const h of u){const g=(a=this.collector)==null?void 0:a.getUidFromKey(h);if(g&&!e.online.includes(g))if((c=this.collector)!=null&&c.isSelector(h))this.renderControl.isWritable&&((l=this.collector)==null||l.updateValue(h,void 0,{viewId:o.id,scenePath:o.focusScenePath,isSync:!0})),this.worker.blurSelector(o.id,o.focusScenePath,h);else{const y=this.textEditorManager.editors.get(h);y&&y.opt&&(y.opt.workState===D.Doing||y.opt.workState===D.Start)&&(y.opt.text&&y.opt.text.replace(/\s*,/g,"")?this.textEditorManager.unActive(h):this.textEditorManager.delete(h))}}}}),(i=this.cursor)==null||i.updateRoomMembers(e)}))}async activeWorker(){await this.worker.init()}setWindowManager(e){var t,i,o,s,a;this.windowManager=e,(i=(t=this.windowManager)==null?void 0:t.mainView)!=null&&i.divElement&&this.viewContainerManager.onMainViewMounted(this.windowManager.mainView),(a=(s=(o=this.windowManager.appManager)==null?void 0:o.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 z=class z extends G.InvisiblePlugin{constructor(){super(...arguments);I(this,"onPhaseChanged",e=>{var t;e===G.RoomPhase.Reconnecting&&((t=z.currentManager)==null||t.setSnapshootData())});I(this,"updateRoomWritable",()=>{var e;(e=z.currentManager)==null||e.onWritableChange(this.displayer.isWritable)});I(this,"roomStateChangeListener",async e=>{var t,i;e!=null&&e.roomMembers&&((t=z.currentManager)==null||t.onRoomMembersChange(e.roomMembers)),!(G.isRoom(this.displayer)&&!this.displayer.isWritable)&&e.memberState&&((i=z.currentManager)==null||i.onMemberChange(e.memberState))})}static async getInstance(e,t){var w;t.options&&(((w=t.options.extras)==null?void 0:w.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&&z.logger.error("[Appliance]: [ApplianceMultiPlugin] you must adaptor options cdn fullWorkerUrl and subWorkerUrl"));const i=e.displayer,o=i.callbacks.on,s=i.callbacks.off,a=i.callbacks.once,c=e.cleanCurrentScene,l=e.mainView.setMemberState;let u;G.isRoom(i)&&(u=i.setWritable),t!=null&&t.logger&&(z.logger=new Si(t.logger));let h=i.getInvisiblePlugin(z.kind);h||(h=await z.createApplianceMultiPlugin(i,z.kind)),i&&h&&z.createCurrentManager(e,{cdn:t.options.cdn,extras:{...Ie,...t.options.extras}},h);const g={displayer:i,windowManager:e,currentManager:z.currentManager,maxScreenshotWidth:10*1024,maxScreenshotHeight:10*1024,getBoundingRectAsync:async function(m){var v;z.logger.info("[ApplianceMultiPlugin] getBoundingRectAsync");const p=(e.mainView||i).getBoundingRect(m),T=await((v=z.currentManager)==null?void 0:v.getBoundingRect(m));return!p.width||!p.height?T:mi(p,T)},screenshotToCanvasAsync:async function(m,p,T,v,C,N){var b;z.logger.info("[ApplianceMultiPlugin] screenshotToCanvasAsync");let k=T,P=v,A=C.scale;k>this.maxScreenshotWidth&&(A=this.maxScreenshotWidth/k*A,k=this.maxScreenshotWidth),P>this.maxScreenshotHeight&&(A=Math.min(this.maxScreenshotHeight/P*A,A),P=this.maxScreenshotHeight),C.scale=A;const x=document.createElement("canvas"),E=x.getContext("2d");x.width=k*(N||1),x.height=P*(N||1),E&&((e.mainView||i).screenshotToCanvas(E,p,k,P,C,N),m.drawImage(x,Math.floor((T-k)/2),Math.floor((v-P)/2),k*(N||1),P*(N||1),0,0,k,P),x.remove()),z.currentManager&&await((b=z.currentManager)==null?void 0:b.screenshotToCanvas(m,p,k,P,C,Math.floor((T-k)/2),Math.floor((v-P)/2)))},scenePreviewAsync:async function(m,p,T,v,C){z.logger.info("[ApplianceMultiPlugin] scenePreviewAsync"),(e.mainView||i).scenePreview(m,p,T,v,C);const N=document.createElement("img");N.className="appliance-plugin-fill-scene-snapshot-img",p.append(N),getComputedStyle(p).position||(p.style.position="relative"),z.currentManager&&await z.currentManager.scenePreview(m,N)},fillSceneSnapshotAsync:async function(m,p,T,v,C){z.logger.info("[ApplianceMultiPlugin] fillSceneSnapshotAsync"),p.innerHTML="",(e.mainView||i).fillSceneSnapshot(m,p,T,v,C);const N=T||e.mainView.size.width,k=v||e.mainView.size.height;let P=await this.getBoundingRectAsync(m);P||(P={originX:0,originY:0,width:N,height:k});let A=Math.max(P==null?void 0:P.width,N),x=Math.max(P==null?void 0:P.height,k),E=1;const b=A>N&&Math.min(N/A,E)||E,O=x>k&&Math.min(k/x,E)||E;b<=O?(A=b<1&&N||A,x=Math.floor(x*b)+1,E=b):b>O&&(x=O<1&&k||x,A=Math.floor(A*O)+1,E=O);const Y={scale:E,centerX:P.originX+P.width/2,centerY:P.originY+P.height/2},R=document.createElement("canvas"),W=R.getContext("2d");R.width=A,R.height=x,W&&await this.screenshotToCanvasAsync(W,m,A,x,Y,devicePixelRatio);const B=document.createElement("img");B.className="appliance-plugin-fill-scene-snapshot-img",B.src=R.toDataURL(),B.onload=()=>{R.remove()},B.onerror=()=>{R.remove(),B.remove()},p.append(B),getComputedStyle(p).position||(p.style.position="relative")},_callbacksOn:function(m,p){z.logger.info(`[ApplianceMultiPlugin] callbacks ${m}`),(m==="onCanUndoStepsUpdate"||m==="onCanRedoStepsUpdate")&&G.isRoom(i)&&i.isWritable?ot.InternalMsgEmitter.on(m,p):o.call(i.callbacks,m,p)},_callbacksOnce:function(m,p){z.logger.info(`[ApplianceMultiPlugin] callbacks ${m}`),(m==="onCanUndoStepsUpdate"||m==="onCanRedoStepsUpdate")&&G.isRoom(i)&&i.isWritable?ot.InternalMsgEmitter.on(m,p):a.call(i.callbacks,m,p)},_callbacksOff:function(m,p){z.logger.info(`[ApplianceMultiPlugin] callbacks ${m}`),(m==="onCanUndoStepsUpdate"||m==="onCanRedoStepsUpdate")&&G.isRoom(i)&&i.isWritable?ot.InternalMsgEmitter.off(m,p):s.call(i.callbacks,m,p)},canRedoSteps(){if(z.logger.info("[ApplianceMultiPlugin] canRedoSteps"),z.currentManager&&G.isRoom(i)&&!i.disableSerialization){const m=z.currentManager.viewContainerManager.focuedView,p=m==null?void 0:m.focusScenePath;if(m&&p)return m.displayer.commiter.redoStack.filter(T=>T.scenePath===p).length}return 0},canUndoSteps(){if(z.logger.info("[ApplianceMultiPlugin] canUndoSteps"),z.currentManager&&G.isRoom(i)&&!i.disableSerialization){const m=z.currentManager.viewContainerManager.focuedView,p=m==null?void 0:m.focusScenePath;if(m&&p)return m.displayer.commiter.undoStack.filter(C=>C.scenePath===p).length}return 0},undo:function(){return z.logger.info("[ApplianceMultiPlugin] undo"),z.currentManager&&G.isRoom(i)&&!i.disableSerialization&&i.isWritable?z.currentManager.viewContainerManager.undo():0},redo:function(){return z.logger.info("[ApplianceMultiPlugin] redo"),z.currentManager&&G.isRoom(i)&&!i.disableSerialization&&i.isWritable?z.currentManager.viewContainerManager.redo():0},cleanCurrentScene:function(){z.logger.info("[ApplianceMultiPlugin] cleanCurrentScene"),z.currentManager&&G.isRoom(i)&&i.isWritable&&(z.currentManager.logger.info("[Appliance]: cleanCurrentScene"),z.currentManager.cleanCurrentScene(),c.call(e))},insertImage:function(m){if(z.logger.info("[ApplianceMultiPlugin] insertImage"),z.currentManager&&G.isRoom(i)&&i.isWritable){const p=z.currentManager.viewContainerManager.focuedViewId||re;z.currentManager.worker.insertImage(p,m)}},lockImage:function(m,p){if(z.logger.info("[ApplianceMultiPlugin] lockImage"),z.currentManager&&G.isRoom(i)&&i.isWritable){const T=z.currentManager.viewContainerManager.focuedViewId||re;z.currentManager.worker.lockImage(T,m,p)}},completeImageUpload:function(m,p){if(z.logger.info("[ApplianceMultiPlugin] completeImageUpload"),z.currentManager&&G.isRoom(i)&&i.isWritable){const T=z.currentManager.viewContainerManager.focuedViewId||re;z.currentManager.worker.completeImageUpload(T,m,p)}},getImagesInformation:function(m){return z.logger.info("[ApplianceMultiPlugin] completeImageUpload"),z.currentManager&&G.isRoom(i)&&i.isWritable?z.currentManager.worker.getImagesInformation(m):[]},insertText:function(m,p,T){if(z.logger.info("[ApplianceMultiPlugin] insertText"),z.currentManager&&G.isRoom(i)&&i.isWritable){const v=z.currentManager.viewContainerManager.focuedViewId||re;return z.currentManager.textEditorManager.insertText(v,m,p,T)}},updateText:function(m,p){z.logger.info("[ApplianceMultiPlugin] updateText"),z.currentManager&&G.isRoom(i)&&i.isWritable&&z.currentManager.textEditorManager.updateText(m,p)},callbacks:()=>(z.logger.info("[ApplianceMultiPlugin] callbacks bind"),{...i.callbacks,on:g._callbacksOn.bind(g),once:g._callbacksOnce.bind(g),off:g._callbacksOff.bind(g)}),destroy(){z.currentManager&&(z.currentManager.logger.info("[Appliance]: [ApplianceMultiPlugin] destroy"),z.currentManager.destroy(),z.currentManager=void 0)},setMemberState(m){if(z.currentManager){z.currentManager.logger.info(`[Appliance]: setMemberState ${JSON.stringify(m)}`);const p=Object.keys(m);if(G.isRoom(i)&&i.isWritable){if(p.includes("currentApplianceName"))if(m.currentApplianceName&&m.currentApplianceName===ie.laserPen){if(z.currentManager.isUseSimple)throw z.currentManager.logger.error("[Appliance]: [ApplianceMultiPlugin] laserPen must be not support in simple mode"),new Error("[Appliance]: [ApplianceMultiPlugin] laserPen must be not support in simple mode");m.currentApplianceName=ie.pencil,m.useLaserPen=!0}else m.currentApplianceName&&m.currentApplianceName===ie.pencil&&(m.useLaserPen=!1);l.call(e.mainView,m);return}}throw z.logger.error("[Appliance]: [ApplianceMultiPlugin] setMemberState must be called in writable room"),new Error("[Appliance]: [ApplianceMultiPlugin] setMemberState must be called in writable room")},createMiniMap:async function(m,p){if(z.logger.info("[ApplianceMultiPlugin] createMiniMap"),z.currentManager&&G.isRoom(i)&&i.isWritable)return z.currentManager.logger.info("[Appliance]: [ApplianceMultiPlugin] createMiniMap"),z.currentManager.createMiniMap(m,p)},destroyMiniMap:async function(m){if(z.logger.info("[ApplianceMultiPlugin] destroyeMiniMap"),z.currentManager&&G.isRoom(i)&&i.isWritable)return z.currentManager.logger.info("[Appliance]: [ApplianceMultiPlugin] destroyeMiniMap"),z.currentManager.destroyMiniMap(m)},filterRenderByUid(m,p,T){if(z.logger.info("[ApplianceMultiPlugin] filterRenderByUid"),z.currentManager&&G.isRoom(i)&&i.isWritable)return z.currentManager.filterRenderByUid(m,p,T)},cancelFilterRender(m,p){if(z.logger.info("[ApplianceMultiPlugin] filterRenderByUid"),z.currentManager&&G.isRoom(i)&&i.isWritable)return z.currentManager.cancelFilterRender(m,p)},addListener:(m,p)=>{z.logger.info(`[ApplianceMultiPlugin] addListener ${m}`),ot.PublicMsgEmitter.on(m,p)},removeListener:(m,p)=>{z.logger.info(`[ApplianceMultiPlugin] removeListener ${m}`),ot.PublicMsgEmitter.off(m,p)},usePlugin:m=>{var p;z.logger.info("[ApplianceMultiPlugin] usePlugin",m.kind),(p=z.currentManager)==null||p.usePlugin(m)},getDisableDeviceInputs(){if(z.currentManager&&G.isRoom(i))return z.currentManager.disableDeviceInputs},setDisableDeviceInputs(m){z.logger.info(`[ApplianceMultiPlugin] setDisableDeviceInputs ${m}`),z.currentManager&&G.isRoom(i)&&(z.currentManager.disableDeviceInputs=m)},getDisableCameraTransform(){if(z.currentManager&&G.isRoom(i))return z.currentManager.disableCameraTransform},setDisableCameraTransform(m){z.logger.info(`[ApplianceMultiPlugin] setDisableCameraTransform ${m}`),z.currentManager&&G.isRoom(i)&&(z.currentManager.disableCameraTransform=m)},getDisableEraseImage(){if(z.currentManager&&G.isRoom(i))return z.currentManager.disableEraseImage},setDisableEraseImage(m){z.logger.info(`[ApplianceMultiPlugin] setDisableEraseImage ${m}`),z.currentManager&&G.isRoom(i)&&(z.currentManager.disableEraseImage=m)},setWritable:async function(m){var p;z.logger.info(`[ApplianceMultiPlugin] setWritable ${m}`),G.isRoom(i)&&u&&(await((p=z.currentManager)==null?void 0:p.setWritable(m)),await u.call(i,m))},requestIdleCallback:(m,p)=>{const T=(p==null?void 0:p.timeout)||0,v=performance.now();let C;const N=new MessageChannel;let k;const P=A=>{try{m({didTimeout:A,timeRemaining:()=>{const E=performance.now()-v;return Math.max(0,T-E)}})}catch(x){z.logger.error("[ApplianceMultiPlugin] requestIdleCallback error:",x)}finally{N.port1.close(),N.port2.close(),C!==void 0&&cancelAnimationFrame(C),k!==void 0&&clearTimeout(k)}};return N.port1.onmessage=()=>{C=requestAnimationFrame(()=>{T>0&&performance.now()-v>=T?P(!0):P(!1)})},N.port2.postMessage(null),T>0&&(k=setTimeout(()=>{P(!0)},T)),k||C||0},cancelIdleCallback:m=>{try{clearTimeout(m),cancelAnimationFrame(m)}catch(p){z.logger.error("[ApplianceMultiPlugin] cancelIdleCallback error:",p)}},injectMethodToObject:(m,p)=>{if(z.logger.info(`[ApplianceMultiPlugin] injectMethodToObject ${p}`),typeof m[p]=="function"||typeof m[p]>"u"){(p==="requestIdleCallback"||p==="cancelIdleCallback")&&z.currentManager&&z.currentManager.registerPolyfillMethod(p),m[p]=g[p];return}p==="callbacks"&&(m.callbacks.on=g._callbacksOn.bind(g),m.callbacks.off=g._callbacksOff.bind(g),m.callbacks.once=g._callbacksOnce.bind(g))},blurText:()=>{z.logger.info("[ApplianceMultiPlugin] blurText"),z.currentManager&&G.isRoom(i)&&i.isWritable&&z.currentManager.textEditorManager.checkEmptyTextBlur()},hasElements:(m,p)=>{var T;if(z.logger.info(`[ApplianceMultiPlugin] hasElements ${m}`),z.currentManager&&G.isRoom(i)&&i.isWritable){let v=m;if(!v){const C=z.currentManager.viewContainerManager.focuedView;v=C==null?void 0:C.focusScenePath}if(v){const C=(T=z.currentManager.collector)==null?void 0:T.getScenePathData(v);if(C){const N=Object.values(C);return N.length>0?p?N.some(k=>p(k.toolsType)):!0:!1}return!1}return!1}},getElements:(m,p)=>{var T;if(z.logger.info(`[ApplianceMultiPlugin] getElements ${m}`),z.currentManager&&G.isRoom(i)&&i.isWritable){let v=m;if(!v){const C=z.currentManager.viewContainerManager.focuedView;v=C==null?void 0:C.focusScenePath}if(v){const C=(T=z.currentManager.collector)==null?void 0:T.getScenePathData(v),N=C&&Object.values(C)||[];return C&&N.length>0&&p?N.filter(k=>p(k.toolsType)):N}return[]}},stopDraw:m=>{if(z.logger.info(`[ApplianceMultiPlugin] stopDraw ${m}`),z.currentManager&&G.isRoom(i))return z.currentManager.stopDraw(m)},setViewLocalScenePathChange:async(m,p)=>{z.logger.info(`[ApplianceMultiPlugin] setViewLocalScenePathChange ${m} ${p}`),z.currentManager&&await z.currentManager.setViewLocalScenePathChange(p,m)},insertMarkmap:async(m,p)=>{if(z.logger.info(`[ApplianceMultiPlugin] insertMarkmap: ${m}, info: ${JSON.stringify(p)}`),z.currentManager&&z.currentManager.isUseBackgroundThread)return z.currentManager.worker.insertBackgroundMarkMap(m,p)},updateMarkmap:async(m,p,T)=>{if(z.logger.info(`[ApplianceMultiPlugin] updateMarkmap: ${m}, markmapId: ${p}, info: ${JSON.stringify(T)}`),z.currentManager&&z.currentManager.isUseBackgroundThread)return z.currentManager.worker.updateBackgroundMarkMap(m,p,T)},insertBackgroundImage:async(m,p)=>{if(z.logger.info(`[ApplianceMultiPlugin] insertBackgroundImage: ${m}, info: ${JSON.stringify(p)}`),z.currentManager&&z.currentManager.isUseBackgroundThread)return z.currentManager.worker.insertBackgroundSVG(m,p)},getSelectedElements:m=>{var p,T;return(T=(p=z.currentManager)==null?void 0:p.selectorApi)==null?void 0:T.getSelectedElements(m)},isElementPropertySupported:(m,p)=>{var T,v;return((v=(T=z.currentManager)==null?void 0:T.selectorApi)==null?void 0:v.isElementPropertySupported(m,p))||!1},blurSelector:m=>{var p;if(z.currentManager&&G.isRoom(i)&&i.isWritable){const T=(p=z.currentManager)==null?void 0:p.selectorApi;return T?T.blurSelector(m):Promise.resolve({ok:!1,requestId:`clear-${Date.now().toString(36)}`,viewId:m||re,reason:"no-selection"})}return Promise.resolve({ok:!1,requestId:`clear-${Date.now().toString(36)}`,viewId:m||re,reason:"no-selection"})},updateSelectedElements:(m,p)=>{var T;if(z.currentManager&&G.isRoom(i)&&i.isWritable){const v=(T=z.currentManager)==null?void 0:T.selectorApi;return v?v.updateSelectedElements(m,p):Promise.resolve({requestId:`update-${Date.now().toString(36)}`,viewId:m,ok:!1,reason:"no-selection"})}return Promise.resolve({requestId:`update-${Date.now().toString(36)}`,viewId:m,ok:!1,reason:"no-writable permission"})},updateElement:(m,p,T,v,C=!0)=>{var N;if(z.currentManager&&G.isRoom(i)&&i.isWritable){const k=(N=z.currentManager)==null?void 0:N.selectorApi;return k?k.updateElement(m,p,T,v,C):Promise.resolve(!1)}return Promise.resolve(!1)},copySelectedElements:m=>{var p;if(z.currentManager&&G.isRoom(i)&&i.isWritable){const T=(p=z.currentManager)==null?void 0:p.selectorApi;return T?T.copySelectedElements(m):Promise.resolve({ok:!1,requestId:`copy-${Date.now().toString(36)}`,viewId:m||re,reason:"no-selection"})}return Promise.resolve({ok:!1,requestId:`copy-${Date.now().toString(36)}`,viewId:m||re,reason:"no-selection"})},deleteSelectedElements:m=>{var p;if(z.currentManager&&G.isRoom(i)&&i.isWritable){const T=(p=z.currentManager)==null?void 0:p.selectorApi;return T?T.deleteSelectedElements(m):Promise.resolve({ok:!1,requestId:`delete-${Date.now().toString(36)}`,viewId:m||re,reason:"no-selection"})}return Promise.resolve({ok:!1,requestId:`delete-${Date.now().toString(36)}`,viewId:m||re,reason:"no-selection"})},getFloatbarContainer:m=>{var p;return(p=z.currentManager)==null?void 0:p.viewContainerManager.getFloatbarContainer(m)},getViewOffsetToContainer:(m,p)=>{var T;return(T=z.currentManager)==null?void 0:T.viewContainerManager.getViewOffsetToContainer(m,p)}};g.injectMethodToObject(e,"undo"),g.injectMethodToObject(e,"redo"),g.injectMethodToObject(e,"cleanCurrentScene"),g.injectMethodToObject(e,"blurSelector"),g.injectMethodToObject(e,"updateElement"),g.injectMethodToObject(e,"insertImage"),g.injectMethodToObject(e,"completeImageUpload"),g.injectMethodToObject(e,"lockImage"),g.injectMethodToObject(e,"insertText"),g.injectMethodToObject(e,"updateText"),g.injectMethodToObject(i,"getImagesInformation"),g.injectMethodToObject(i,"callbacks"),g.injectMethodToObject(i,"screenshotToCanvasAsync"),g.injectMethodToObject(i,"getBoundingRectAsync"),g.injectMethodToObject(i,"scenePreviewAsync"),g.injectMethodToObject(i,"fillSceneSnapshotAsync"),g.injectMethodToObject(i,"blurSelector"),g.injectMethodToObject(i,"updateElement"),g.injectMethodToObject(e.mainView,"setMemberState"),G.isRoom(i)&&g.injectMethodToObject(i,"setWritable"),Object.defineProperty(e,"canUndoSteps",{get(){return g.canUndoSteps()}}),Object.defineProperty(e,"canRedoSteps",{get(){return g.canRedoSteps()}});const y=(m,p,T=3)=>{const v=e.focused||re;T>0&&v!==m?setTimeout(()=>{y(m,p,T-1)},100):e.emitter.emit("canUndoStepsChange",p)};ot.InternalMsgEmitter.on("onCanUndoStepsUpdate",(m,p)=>{y(p,m)});const d=(m,p,T=3)=>{const v=e.focused||re;T>0&&v!==m?setTimeout(()=>{d(m,p,T-1)},100):e.emitter.emit("canRedoStepsChange",p)};ot.InternalMsgEmitter.on("onCanRedoStepsUpdate",(m,p)=>{d(p,m)});const M={...g,callbacks:g.callbacks()};return Object.defineProperty(M,"disableDeviceInputs",{set(m){g.setDisableDeviceInputs(m)},get(){return g.getDisableDeviceInputs()}}),Object.defineProperty(M,"disableCameraTransform",{set(m){g.setDisableCameraTransform(m)},get(){return g.getDisableCameraTransform()}}),Object.defineProperty(M,"disableEraseImage",{set(m){g.setDisableEraseImage(m)},get(){return g.getDisableEraseImage()}}),h&&z.currentManager&&(z.currentManager.bindPlugin(h),h.init(i)),e._appliancePlugin=M,e._appliancePlugin}static onCreate(e){e&&z.currentManager&&(z.currentManager.bindPlugin(e),e.init(e.displayer))}static async createApplianceMultiPlugin(e,t){try{await e.createInvisiblePlugin(z,{})}catch(o){if(!e.isWritable){await e.setWritable(!0);const s=await this.createApplianceMultiPlugin(e,t);return await e.setWritable(!1),s}throw o}let i=e.getInvisiblePlugin(t);return i||(i=await z.createApplianceMultiPlugin(e,t)),i}get isReplay(){return G.isPlayer(this.displayer)}get callbackName(){return this.isReplay?"onPlayerStateChanged":"onRoomStateChanged"}init(e){var i,o;const t=e.state;(i=z.currentManager)==null||i.onRoomMembersChange(t.roomMembers),G.isRoom(e)&&((o=z.currentManager)==null||o.onMemberChange(t.memberState)),this.displayer.callbacks.on(this.callbackName,this.roomStateChangeListener),this.displayer.callbacks.on("onEnableWriteNowChanged",this.updateRoomWritable),this.displayer.callbacks.on("onPhaseChanged",this.onPhaseChanged)}destroy(){var e;z.logger.info("[ApplianceMultiPlugin] passive destroy"),(e=z.currentManager)==null||e.destroy(),z.currentManager=void 0}};I(z,"kind","appliance-multi-plugin"),I(z,"currentManager"),I(z,"logger",{info:console.log,warn:console.warn,error:console.error}),I(z,"createCurrentManager",(e,t,i)=>{z.currentManager&&z.currentManager.destroy();const o={plugin:i,displayer:e.displayer,options:t},s=new ot(o);if(s.setWindowManager(e),z.currentManager=s,e.room){const a=s.hasOffscreenCanvas;e.room.logger.info(`[Appliance]: [ApplianceMultiPlugin] use ${a?"worker":"mainThread"}`)}});let _n=z;var UI=Je,YI=function(){return UI.Date.now()},BI=YI,$I=/\s/;function WI(r){for(var n=r.length;n--&&$I.test(r.charAt(n)););return n}var VI=WI,FI=VI,GI=/^\s+/;function QI(r){return r&&r.slice(0,FI(r)+1).replace(GI,"")}var ZI=QI,HI=Pt,qI=ct,JI="[object Symbol]";function KI(r){return typeof r=="symbol"||qI(r)&&HI(r)==JI}var XI=KI,_I=ZI,Io=lt,ew=XI,wo=NaN,tw=/^[-+]0x[0-9a-f]+$/i,nw=/^0b[01]+$/i,iw=/^0o[0-7]+$/i,ow=parseInt;function rw(r){if(typeof r=="number")return r;if(ew(r))return wo;if(Io(r)){var n=typeof r.valueOf=="function"?r.valueOf():r;r=Io(n)?n+"":n}if(typeof r!="string")return r===0?r:+r;r=_I(r);var e=nw.test(r);return e||iw.test(r)?ow(r.slice(2),e?2:8):tw.test(r)?wo:+r}var sw=rw,aw=lt,On=BI,To=sw,cw="Expected a function",lw=Math.max,uw=Math.min;function hw(r,n,e){var t,i,o,s,a,c,l=0,u=!1,h=!1,g=!0;if(typeof r!="function")throw new TypeError(cw);n=To(n)||0,aw(e)&&(u=!!e.leading,h="maxWait"in e,o=h?lw(To(e.maxWait)||0,n):o,g="trailing"in e?!!e.trailing:g);function y(N){var k=t,P=i;return t=i=void 0,l=N,s=r.apply(P,k),s}function d(N){return l=N,a=setTimeout(m,n),u?y(N):s}function M(N){var k=N-c,P=N-l,A=n-k;return h?uw(A,o-P):A}function w(N){var k=N-c,P=N-l;return c===void 0||k>=n||k<0||h&&P>=o}function m(){var N=On();if(w(N))return p(N);a=setTimeout(m,M(N))}function p(N){return a=void 0,g&&t?y(N):(t=i=void 0,s)}function T(){a!==void 0&&clearTimeout(a),l=0,t=c=i=a=void 0}function v(){return a===void 0?s:p(On())}function C(){var N=On(),k=w(N);if(t=arguments,i=this,c=N,k){if(a===void 0)return d(c);if(h)return clearTimeout(a),a=setTimeout(m,n),y(c)}return a===void 0&&(a=setTimeout(m,n)),s}return C.cancel=T,C.flush=v,C}var dw=hw,gw=dw,fw=lt,pw="Expected a function";function Mw(r,n,e){var t=!0,i=!0;if(typeof r!="function")throw new TypeError(pw);return fw(e)&&(t="leading"in e?!!e.leading:t,i="trailing"in e?!!e.trailing:i),gw(r,n,{leading:t,maxWait:n,trailing:i})}var yw=Mw;const mw=pn(yw);class Iw extends Mr{constructor(e,t){super(e,t);I(this,"width",1e3);I(this,"height",1e3);I(this,"dpr",zt());I(this,"vDom");I(this,"eventTragetElement");I(this,"snapshotContainerRef");I(this,"backgroundContainerRef");I(this,"backgroundSnapshotContainerRef");I(this,"canvasContainerRef",f.createRef());I(this,"subLocalCanvasContainerRef");I(this,"canvasTopRef");I(this,"canvasServiceFloatRef",f.createRef());I(this,"canvasFloatRef",f.createRef());I(this,"canvasBgRef",f.createRef());I(this,"floatBarRef",f.createRef());I(this,"customFloatbarContainerRef",f.createRef());I(this,"containerOffset",{x:0,y:0});this.control.hasOffscreenCanvas||(this.snapshotContainerRef=f.createRef()),this.control.isUseSimple||(this.canvasTopRef=f.createRef(),this.subLocalCanvasContainerRef=f.createRef()),this.control.isUseBackgroundThread&&(this.backgroundContainerRef=f.createRef(),this.backgroundSnapshotContainerRef=f.createRef())}setCanvassStyle(){var e;if(this.eventTragetElement){const t=this.eventTragetElement.offsetWidth,i=this.eventTragetElement.offsetHeight,o=zt();o!==this.dpr&&(this.dpr=o,this.control.worker.updateDpr(this.viewId,this.dpr)),t&&i&&this.canvasContainerRef.current&&(t!==this.width||i!==this.height)&&(this.width=t,this.height=i),t&&i&&this.backgroundContainerRef&&this.backgroundContainerRef.current&&(t!==this.width||i!==this.height)&&(this.width=t,this.height=i,this.backgroundContainerRef.current.style.width=`${t}px`,this.backgroundContainerRef.current.style.height=`${i}px`,this.backgroundContainerRef.current.classList.toggle("appliance-plugin-background-isWritable",this.control.renderControl.isWritable)),t&&i&&this.canvasBgRef.current&&(t!==this.width||i!==this.height)&&(this.width=t,this.height=i,this.control.isUseOffscreenTransfer||(this.canvasBgRef.current.width=t*this.dpr,this.canvasBgRef.current.height=i*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=t*this.dpr,this.canvasFloatRef.current.height=i*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=t*this.dpr,this.canvasServiceFloatRef.current.height=i*this.dpr),(e=this.canvasTopRef)!=null&&e.current&&(this.canvasTopRef.current.width=t*this.dpr,this.canvasTopRef.current.height=i*this.dpr)))}}createMainViewDisplayer(e){return this.vDom||(this.containerOffset=this.getContainerOffset(e,this.containerOffset),this.eventTragetElement=e.parentElement.children[0],e.innerHTML="",fn.render(f.createElement(vi,{viewId:this.viewId,mananger:this,refs:{canvasServiceFloatRef:this.canvasServiceFloatRef,canvasFloatRef:this.canvasFloatRef,canvasBgRef:this.canvasBgRef,floatBarRef:this.floatBarRef,customFloatbarContainerRef:this.customFloatbarContainerRef,canvasTopRef:this.canvasTopRef,canvasContainerRef:this.canvasContainerRef,snapshotContainerRef:this.snapshotContainerRef,subLocalCanvasContainerRef:this.subLocalCanvasContainerRef,backgroundContainerRef:this.backgroundContainerRef,backgroundSnapshotContainerRef:this.backgroundSnapshotContainerRef}}),e),this.control.room&&this.bindDisplayerEvent(this.eventTragetElement)),this}}class Tt extends At{constructor(e){super(e);I(this,"focuedViewId");I(this,"control");I(this,"focuedView");this.control=e.control}bindMainView(){if(!this.control.divMainView)return;const e=new Iw(this.control,Me.InternalMsgEmitter),{width:t,height:i,dpr:o}=e,s={cameraOpt:{...Tt.defaultCameraOpt,width:t,height:i}},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:re,displayer:e,focusScenePath:a.focusScenePath||a.scenePath,cameraOpt:s.cameraOpt,viewData:a}),this.setFocuedViewId(re),e.createMainViewDisplayer(this.control.divMainView)}}getViewInitData(e){var i;const t=this.getView(e);if(t){const{width:o,height:s,dpr:a}=t.displayer;(i=this.control.pluginOptions.extras.canvasOpt)!=null&&i.contextType&&(Tt.defaultScreenCanvasOpt.contextType=this.control.pluginOptions.extras.canvasOpt.contextType);const c={dpr:a,originalPoint:[o/2,s/2],offscreenCanvasOpt:{...Tt.defaultScreenCanvasOpt,width:o,height:s},layerOpt:{...Tt.defaultLayerOpt,width:o,height:s},cameraOpt:{...Tt.defaultCameraOpt,width:o,height:s}};if(t.viewData){const{scale:l,...u}=t.viewData.camera;c.cameraOpt={...c.cameraOpt,...u,scale:l===1/0?1:l}}return c}}async mountView(e){var i;const t=this.getView(e);if(t){this.control.worker.isActive||(this.control.cursor.activeCollector(),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 o=this.getViewInitData(e);o&&((i=this.control.worker)==null||i.createViewWorker(e,o,t.displayer)),t.focusScenePath&&this.control.collector&&this.control.worker.pullServiceData(e,t.focusScenePath,{isAsync:!0,useAnimation:!1})}}}class Ge extends Me{constructor(e){super(e);I(this,"viewContainerManager");I(this,"divMainView");I(this,"onCameraChange",mw(e=>{var i;const t=this.viewContainerManager.mainView;t&&t.cameraOpt&&(t.cameraOpt.width!==e.width||t.cameraOpt.height!==e.height)&&((i=this.viewContainerManager.mainView)==null||i.displayer.updateSize()),this.viewContainerManager.setFocuedViewCameraOpt(e)},ii,{leading:!1}));const t={control:this,internalMsgEmitter:Ge.InternalMsgEmitter,publicMsgEmitter:Ge.PublicMsgEmitter};this.viewContainerManager=new Tt(t)}init(){Ge.InternalMsgEmitter.on(ne.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(re,!0);return}const{diffView:t,diffScenePath:i,diffData:o}=e,s=new Map;if(t){let l;Object.keys(t).forEach(u=>{var g;const h=t[u];if(h&&!h.newValue)(g=this.worker)==null||g.clearViewScenePath(u,!0),h.oldValue&&(l=h.oldValue);else if(h&&h.newValue){for(const y of Object.keys(h.newValue))this.worker.pullServiceData(u,y,{isAsync:!1,useAnimation:!0});l=h.newValue}if(l)for(const y of Object.values(l)){const d=new Set;for(const M of Object.keys(y))M&&d.add(M);s.set(u,d)}})}if(i){let l;Object.keys(i).forEach(u=>{var g;const h=i[u];if(h&&h.viewId&&!h.newValue?((g=this.worker)==null||g.clearViewScenePath(h.viewId,!0),h.oldValue&&(l=h.oldValue)):h&&h.viewId&&h.newValue&&(this.worker.pullServiceData(h.viewId,u,{isAsync:!1,useAnimation:!0}),l=h.newValue),h!=null&&h.viewId&&l){const y=new Set;for(const d of Object.keys(l))d&&y.add(d),s.set(h.viewId,y)}})}o&&Object.keys(o).forEach(l=>{var h,g;const u=o[l];if(u){const{viewId:y}=u,d=s.get(y)||new Set;d.add(l),s.set(y,d),(h=this.worker)==null||h.onServiceDerive(l,u),(g=this.miniMapManager)==null||g.updateMiniMapCamera(y)}});for(const[l,u]of s.entries())Me.InternalMsgEmitter.emit("excludeIds",[...u],l)}),this.room&&(this.roomMember.onUidChangeHook(e=>{var t;(t=this.collector)!=null&&t.serviceStorage&&this.viewContainerManager.getAllViews().forEach(i=>{var o,s,a,c,l,u;if(i&&i.focusScenePath&&((o=this.collector)!=null&&o.serviceStorage[i.id])&&((s=this.collector)!=null&&s.serviceStorage[i.id][i.focusScenePath])){const h=Object.keys((a=this.collector)==null?void 0:a.serviceStorage[i.id][i.focusScenePath]);for(const g of h){const y=(c=this.collector)==null?void 0:c.getUidFromKey(g);if(y&&!e.online.includes(y))if((l=this.collector)!=null&&l.isSelector(g))this.renderControl.isWritable&&((u=this.collector)==null||u.updateValue(g,void 0,{viewId:i.id,scenePath:i.focusScenePath,isSync:!0})),this.worker.blurSelector(i.id,i.focusScenePath,g);else{const d=this.textEditorManager.editors.get(g);d&&d.opt&&(d.opt.workState===D.Doing||d.opt.workState===D.Start)&&(d.opt.text&&d.opt.text.replace(/\s*,/g,"")?this.textEditorManager.unActive(g):this.textEditorManager.delete(g))}}}})}),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 L=class L extends G.InvisiblePlugin{constructor(){super(...arguments);I(this,"onPhaseChanged",e=>{var t;e===G.RoomPhase.Reconnecting&&((t=L.currentManager)==null||t.setSnapshootData())});I(this,"updateRoomWritable",()=>{var e;(e=L.currentManager)==null||e.onWritableChange(this.displayer.isWritable)});I(this,"roomStateChangeListener",async e=>{var t,i;L.currentManager instanceof Ge&&(e.cameraState&&L.currentManager.onCameraChange(e.cameraState),e.sceneState&&L.currentManager.onSceneChange(e.sceneState.scenePath,re)),e!=null&&e.roomMembers&&((t=L.currentManager)==null||t.onRoomMembersChange(e.roomMembers)),!(G.isRoom(this.displayer)&&!this.displayer.isWritable)&&e.memberState&&((i=L.currentManager)==null||i.onMemberChange(e.memberState))})}static async getInstance(e,t){var y;t.options&&(((y=t.options.extras)==null?void 0:y.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&&L.logger.error("[ApplianceSinglePlugin] you must adaptor options cdn fullWorkerUrl and subWorkerUrl"));const i=e.callbacks.on,o=e.callbacks.off,s=e.callbacks.once,a=e.cleanCurrentScene.bind(e),c=e.setMemberState.bind(e);let l;G.isRoom(e)&&(l=e.setWritable),t!=null&&t.logger&&(L.logger=new Si(t.logger));let u=e.getInvisiblePlugin(L.kind);u||(u=await L.createAppliancePlugin(e,L.kind)),e&&u&&L.createCurrentManager(e,{cdn:t.options.cdn,extras:{...Ie,...t.options.extras}},u),u&&L.currentManager&&(L.currentManager.bindPlugin(u),u.init(e)),t!=null&&t.cursorAdapter&&(L.cursorAdapter=t.cursorAdapter),L.effectInstance();const h={displayer:e,currentManager:L.currentManager,maxScreenshotWidth:10*1024,maxScreenshotHeight:10*1024,_injectTargetObject:void 0,getBoundingRectAsync:async function(d){var m;L.logger.info("[ApplianceSinglePlugin] getBoundingRectAsync");const M=e.getBoundingRect(d),w=await((m=L.currentManager)==null?void 0:m.getBoundingRect(d));return!M.width||!M.height?w:mi(M,w)},screenshotToCanvasAsync:async function(d,M,w,m,p,T){var A;L.logger.info("[ApplianceSinglePlugin] screenshotToCanvasAsync");let v=w,C=m,N=p.scale;v>this.maxScreenshotWidth&&(N=this.maxScreenshotWidth/v*N,v=this.maxScreenshotWidth),C>this.maxScreenshotHeight&&(N=Math.min(this.maxScreenshotHeight/C*N,N),C=this.maxScreenshotHeight),p.scale=N;const k=document.createElement("canvas"),P=k.getContext("2d");k.width=v*(T||1),k.height=C*(T||1),P&&(e.screenshotToCanvas(P,M,v,C,p,T),d.drawImage(k,Math.floor((w-v)/2),Math.floor((m-C)/2),v*(T||1),C*(T||1),0,0,v,C),k.remove()),L.currentManager&&await((A=L.currentManager)==null?void 0:A.screenshotToCanvas(d,M,v,C,p,Math.floor((w-v)/2),Math.floor((m-C)/2)))},scenePreviewAsync:async function(d,M,w,m,p){L.logger.info("[ApplianceSinglePlugin] scenePreviewAsync"),e.scenePreview(d,M,w,m,p);const T=document.createElement("img");T.className="appliance-plugin-fill-scene-snapshot-img",M.append(T),getComputedStyle(M).position||(M.style.position="relative"),L.currentManager&&await L.currentManager.scenePreview(d,T)},fillSceneSnapshotAsync:async function(d,M,w,m,p){var R,W;L.logger.info("[ApplianceSinglePlugin] fillSceneSnapshotAsync"),M.innerHTML="",e.fillSceneSnapshot(d,M,w,m,p);const T=w||((R=e.state.cameraState)==null?void 0:R.width)||0,v=m||((W=e.state.cameraState)==null?void 0:W.height)||0;let C=await this.getBoundingRectAsync(d);C||(C={originX:0,originY:0,width:T,height:v});let N=Math.max(C==null?void 0:C.width,T),k=Math.max(C==null?void 0:C.height,v),P=1;const A=N>T&&Math.min(T/N,P)||P,x=k>v&&Math.min(v/k,P)||P;A<=x?(N=A<1&&T||N,k=Math.floor(k*A)+1,P=A):A>x&&(k=x<1&&v||k,N=Math.floor(N*x)+1,P=x);const E={scale:P,centerX:C.originX+C.width/2,centerY:C.originY+C.height/2},b=document.createElement("canvas"),O=b.getContext("2d");b.width=N,b.height=k,O&&await this.screenshotToCanvasAsync(O,d,N,k,E,devicePixelRatio);const Y=document.createElement("img");Y.className="appliance-plugin-fill-scene-snapshot-img",Y.src=b.toDataURL(),Y.onload=()=>{b.remove()},Y.onerror=()=>{b.remove(),Y.remove()},M.append(Y),getComputedStyle(M).position||(M.style.position="relative")},_callbacksOn:function(d,M){L.logger.info(`[ApplianceSinglePlugin] callbacks ${d}`),(d==="onCanUndoStepsUpdate"||d==="onCanRedoStepsUpdate")&&G.isRoom(e)&&e.isWritable?Ge.InternalMsgEmitter.on(d,M):i.call(e.callbacks,d,M)},_callbacksOnce:function(d,M){L.logger.info(`[ApplianceSinglePlugin] callbacks ${d}`),(d==="onCanUndoStepsUpdate"||d==="onCanRedoStepsUpdate")&&G.isRoom(e)&&e.isWritable?Ge.InternalMsgEmitter.on(d,M):s.call(e.callbacks,d,M)},_callbacksOff:function(d,M){L.logger.info(`[ApplianceSinglePlugin] callbacks ${d}`),(d==="onCanUndoStepsUpdate"||d==="onCanRedoStepsUpdate")&&G.isRoom(e)&&e.isWritable?Ge.InternalMsgEmitter.off(d,M):o.call(e.callbacks,d,M)},canRedoSteps(){if(L.logger.info("[ApplianceSinglePlugin] canRedoSteps"),L.currentManager&&G.isRoom(e)&&!e.disableSerialization){const d=L.currentManager.viewContainerManager.focuedView,M=d==null?void 0:d.focusScenePath;if(d&&M)return d.displayer.commiter.redoStack.filter(w=>w.scenePath===M).length}return 0},canUndoSteps(){if(L.logger.info("[ApplianceSinglePlugin] canUndoSteps"),L.currentManager&&G.isRoom(e)&&!e.disableSerialization){const d=L.currentManager.viewContainerManager.focuedView,M=d==null?void 0:d.focusScenePath;if(d&&M)return d.displayer.commiter.undoStack.filter(w=>w.scenePath===M).length}return 0},undo:function(){return L.logger.info("[ApplianceSinglePlugin] undo"),L.currentManager&&G.isRoom(e)&&!e.disableSerialization?L.currentManager.viewContainerManager.undo():0},redo:function(){return L.logger.info("[ApplianceSinglePlugin] redo"),L.currentManager&&G.isRoom(e)&&!e.disableSerialization?L.currentManager.viewContainerManager.redo():0},cleanCurrentScene:function(d){L.logger.info("[ApplianceSinglePlugin] cleanCurrentScene"),L.currentManager&&G.isRoom(e)&&e.isWritable&&(L.currentManager.cleanCurrentScene(),a.call(e,d))},insertImage:function(d){L.logger.info("[ApplianceSinglePlugin] insertImage"),L.currentManager&&G.isRoom(e)&&e.isWritable&&L.currentManager.worker.insertImage(re,d)},lockImage:function(d,M){L.logger.info("[ApplianceSinglePlugin] lockImage"),L.currentManager&&G.isRoom(e)&&e.isWritable&&L.currentManager.worker.lockImage(re,d,M)},completeImageUpload:function(d,M){L.logger.info("[ApplianceSinglePlugin] completeImageUpload"),L.currentManager&&G.isRoom(e)&&e.isWritable&&L.currentManager.worker.completeImageUpload(re,d,M)},getImagesInformation:function(d){return L.logger.info("[ApplianceSinglePlugin] completeImageUpload"),L.currentManager&&G.isRoom(e)&&e.isWritable?L.currentManager.worker.getImagesInformation(d):[]},insertText:function(d,M,w){if(L.logger.info("[ApplianceSinglePlugin] insertText"),L.currentManager&&G.isRoom(e)&&e.isWritable)return L.currentManager.textEditorManager.insertText(re,d,M,w)},updateText:function(d,M){L.logger.info("[ApplianceMultiPlugin] updateText"),L.currentManager&&G.isRoom(e)&&e.isWritable&&L.currentManager.textEditorManager.updateText(d,M)},callbacks:()=>({...e.callbacks,on:h._callbacksOn.bind(h),once:h._callbacksOnce.bind(h),off:h._callbacksOff.bind(h)}),destroy(){L.currentManager&&(L.logger.info("[ApplianceSinglePlugin] destroy"),L.currentManager.destroy(),L.currentManager=void 0,L.cursorAdapter=void 0)},setMemberState(d){var w;L.logger.info(`[ApplianceSinglePlugin] setMemberState ${JSON.stringify(d)}`);const M=Object.keys(d);if(G.isRoom(e)&&e.isWritable){if(M.includes("currentApplianceName"))if(d.currentApplianceName&&d.currentApplianceName===ie.laserPen){if((w=L.currentManager)!=null&&w.isUseSimple)throw new Error("[ApplianceMultiPlugin] laserPen must be not support in simple mode");d.currentApplianceName=ie.pencil,d.useLaserPen=!0}else d.currentApplianceName&&d.currentApplianceName===ie.pencil&&(d.useLaserPen=!1);c(d);return}throw new Error("setMemberState must be called in writable room")},createMiniMap:async function(d,M){if(L.logger.info("[ApplianceSinglePlugin] createMiniMap"),L.currentManager&&G.isRoom(e)&&e.isWritable)return L.currentManager.createMiniMap(d,M)},destroyMiniMap:async function(d){if(L.logger.info("[ApplianceMultiPlugin] destroyeMiniMap"),L.currentManager&&G.isRoom(e)&&e.isWritable)return L.currentManager.destroyMiniMap(d)},filterRenderByUid(d,M,w){if(L.logger.info("[ApplianceSinglePlugin] filterRenderByUid"),L.currentManager&&G.isRoom(e)&&e.isWritable)return L.currentManager.filterRenderByUid(d,M,w)},cancelFilterRender(d,M){if(L.logger.info("[ApplianceSinglePlugin] filterRenderByUid"),L.currentManager&&G.isRoom(e)&&e.isWritable)return L.currentManager.cancelFilterRender(d,M)},addListener:(d,M)=>{L.logger.info(`[ApplianceSinglePlugin] addListener ${d}`),Ge.PublicMsgEmitter.on(d,M)},removeListener:(d,M)=>{L.logger.info(`[ApplianceSinglePlugin] removeListener ${d}`),Ge.PublicMsgEmitter.off(d,M)},usePlugin:d=>{var M;L.logger.info("[ApplianceSinglePlugin] usePlugin",d.kind),(M=L.currentManager)==null||M.usePlugin(d)},getDisableDeviceInputs(){if(L.currentManager&&G.isRoom(e))return L.currentManager.disableDeviceInputs},setDisableDeviceInputs(d){L.logger.info(`[ApplianceSinglePlugin] setDisableDeviceInputs ${d}`),L.currentManager&&G.isRoom(e)&&(L.currentManager.disableDeviceInputs=d)},getDisableCameraTransform(){if(L.currentManager&&G.isRoom(e))return L.currentManager.disableCameraTransform},setDisableCameraTransform(d){L.logger.info(`[ApplianceSinglePlugin] setDisableCameraTransform ${d}`),L.currentManager&&G.isRoom(e)&&(L.currentManager.disableCameraTransform=d)},getDisableEraseImage(){if(L.currentManager&&G.isRoom(e))return L.currentManager.disableEraseImage},setDisableEraseImage(d){L.logger.info(`[ApplianceSinglePlugin] setDisableEraseImage ${d}`),L.currentManager&&G.isRoom(e)&&(L.currentManager.disableEraseImage=d)},setWritable:async function(d){var M;L.logger.info(`[ApplianceSinglePlugin] setWritable ${d}`),G.isRoom(e)&&l&&(await((M=L.currentManager)==null?void 0:M.setWritable(d)),await l.call(e,d))},requestIdleCallback:(d,M)=>{const w=(M==null?void 0:M.timeout)||0,m=performance.now();let p;const T=new MessageChannel;let v;const C=N=>{try{d({didTimeout:N,timeRemaining:()=>{const P=performance.now()-m;return Math.max(0,w-P)}})}catch(k){L.logger.error("[ApplianceSinglePlugin] requestIdleCallback error:",k)}finally{T.port1.close(),T.port2.close(),p!==void 0&&cancelAnimationFrame(p),v!==void 0&&clearTimeout(v)}};return T.port1.onmessage=()=>{p=requestAnimationFrame(()=>{w>0&&performance.now()-m>=w?C(!0):C(!1)})},T.port2.postMessage(null),w>0&&(v=setTimeout(()=>{C(!0)},w)),v||p||0},cancelIdleCallback:d=>{try{clearTimeout(d),cancelAnimationFrame(d)}catch(M){L.logger.error("[ApplianceSinglePlugin] cancelIdleCallback error:",M)}},injectMethodToObject:(d,M)=>{if(L.logger.info(`[ApplianceSinglePlugin] injectMethodToObject ${M}`),typeof d[M]=="function"||typeof d[M]>"u"){d[M]=h[M];return}M==="callbacks"&&(d.callbacks.on=h._callbacksOn.bind(h),d.callbacks.off=h._callbacksOff.bind(h),d.callbacks.once=h._callbacksOnce.bind(h))},blurText:()=>{L.logger.info("[ApplianceSinglePlugin] blurText"),L.currentManager&&G.isRoom(e)&&e.isWritable&&L.currentManager.textEditorManager.checkEmptyTextBlur()},hasElements:(d,M)=>{var w;if(L.logger.info(`[ApplianceSinglePlugin] hasElements ${d}`),L.currentManager&&G.isRoom(e)&&e.isWritable){let m=d;if(!m){const p=L.currentManager.viewContainerManager.focuedView;m=p==null?void 0:p.focusScenePath}if(m){const p=(w=L.currentManager.collector)==null?void 0:w.getScenePathData(m);if(p){const T=Object.values(p);return T.length>0?M?T.some(v=>M(v.toolsType)):!0:!1}return!1}return!1}},getElements:(d,M)=>{var w;if(L.logger.info(`[ApplianceSinglePlugin] getElements ${d}`),L.currentManager&&G.isRoom(e)&&e.isWritable){let m=d;if(!m){const p=L.currentManager.viewContainerManager.focuedView;m=p==null?void 0:p.focusScenePath}if(m){const p=(w=L.currentManager.collector)==null?void 0:w.getScenePathData(m),T=p&&Object.values(p)||[];return p&&T.length>0&&M?T.filter(v=>M(v.toolsType)):T}return[]}},stopDraw:d=>{if(L.logger.info(`[ApplianceSinglePlugin] stopDraw ${d}`),L.currentManager&&G.isRoom(e))return L.currentManager.stopDraw(d)},setViewLocalScenePathChange:async(d,M)=>{L.logger.info(`[ApplianceSinglePlugin] setViewLocalScenePathChange ${d} ${M}`),L.currentManager&&await L.currentManager.setViewLocalScenePathChange(d,M)},insertMarkmap:async(d,M)=>{if(L.logger.info(`[ApplianceSinglePlugin] insertMarkmap: ${d}, info: ${JSON.stringify(M)}`),L.currentManager&&L.currentManager.isUseBackgroundThread)return L.currentManager.worker.insertBackgroundMarkMap(d,M)},updateMarkmap:async(d,M,w)=>{if(L.logger.info(`[ApplianceSinglePlugin] updateMarkmap: ${d}, markmapId: ${M}, info: ${JSON.stringify(w)}`),L.currentManager&&L.currentManager.isUseBackgroundThread)return L.currentManager.worker.updateBackgroundMarkMap(d,M,w)},insertBackgroundImage:async(d,M)=>{if(L.logger.info(`[ApplianceSinglePlugin] insertBackgroundImage: ${d}, info: ${JSON.stringify(M)}`),L.currentManager&&L.currentManager.isUseBackgroundThread)return L.currentManager.worker.insertBackgroundSVG(d,M)},getSelectedElements:d=>{var M,w;return(w=(M=L.currentManager)==null?void 0:M.selectorApi)==null?void 0:w.getSelectedElements(d)},isElementPropertySupported:(d,M)=>{var w,m;return((m=(w=L.currentManager)==null?void 0:w.selectorApi)==null?void 0:m.isElementPropertySupported(d,M))||!1},blurSelector:d=>{var M;if(L.currentManager&&G.isRoom(e)&&e.isWritable){const w=(M=L.currentManager)==null?void 0:M.selectorApi;return w?w.blurSelector(d):Promise.resolve({ok:!1,requestId:`clear-${Date.now().toString(36)}`,viewId:d||re,reason:"no-selection"})}return Promise.resolve({ok:!1,requestId:`clear-${Date.now().toString(36)}`,viewId:d||re,reason:"no-selection"})},updateSelectedElements:d=>{var M;if(L.currentManager&&G.isRoom(e)&&e.isWritable){const w=(M=L.currentManager)==null?void 0:M.selectorApi;return w?w.updateSelectedElements(re,d):Promise.resolve({requestId:`update-${Date.now().toString(36)}`,viewId:re,ok:!1,reason:"no-selection"})}return Promise.resolve({requestId:`update-${Date.now().toString(36)}`,viewId:re,ok:!1,reason:"no-writable permission"})},updateElement:(d,M,w,m,p=!0)=>{var T;if(L.currentManager&&G.isRoom(e)&&e.isWritable){const v=(T=L.currentManager)==null?void 0:T.selectorApi;return v?v.updateElement(d,M,w,m,p):Promise.resolve(!1)}return Promise.resolve(!1)},copySelectedElements:d=>{var M;if(L.currentManager&&G.isRoom(e)&&e.isWritable){const w=(M=L.currentManager)==null?void 0:M.selectorApi;return w?w.copySelectedElements(d):Promise.resolve({ok:!1,requestId:`copy-${Date.now().toString(36)}`,viewId:d||re,reason:"no-selection"})}return Promise.resolve({ok:!1,requestId:`copy-${Date.now().toString(36)}`,viewId:d||re,reason:"no-selection"})},deleteSelectedElements:d=>{var M;if(L.currentManager&&G.isRoom(e)&&e.isWritable){const w=(M=L.currentManager)==null?void 0:M.selectorApi;return w?w.deleteSelectedElements(d):Promise.resolve({ok:!1,requestId:`delete-${Date.now().toString(36)}`,viewId:d||re,reason:"no-selection"})}return Promise.resolve({ok:!1,requestId:`delete-${Date.now().toString(36)}`,viewId:d||re,reason:"no-selection"})},getFloatbarContainer:d=>{var M;return(M=L.currentManager)==null?void 0:M.viewContainerManager.getFloatbarContainer(d)},getViewOffsetToContainer:(d,M)=>{var w;return(w=L.currentManager)==null?void 0:w.viewContainerManager.getViewOffsetToContainer(d,M)}};h.injectMethodToObject(e,"undo"),h.injectMethodToObject(e,"redo"),h.injectMethodToObject(e,"cleanCurrentScene"),h.injectMethodToObject(e,"blurSelector"),h.injectMethodToObject(e,"updateElement"),h.injectMethodToObject(e,"insertImage"),h.injectMethodToObject(e,"completeImageUpload"),h.injectMethodToObject(e,"lockImage"),h.injectMethodToObject(e,"getImagesInformation"),h.injectMethodToObject(e,"insertText"),h.injectMethodToObject(e,"updateText"),h.injectMethodToObject(e,"callbacks"),h.injectMethodToObject(e,"screenshotToCanvasAsync"),h.injectMethodToObject(e,"getBoundingRectAsync"),h.injectMethodToObject(e,"scenePreviewAsync"),h.injectMethodToObject(e,"fillSceneSnapshotAsync"),h.injectMethodToObject(e,"setMemberState"),G.isRoom(e)&&h.injectMethodToObject(e,"setWritable"),Object.defineProperty(e,"canUndoSteps",{get(){return h.canUndoSteps()}}),Object.defineProperty(e,"canRedoSteps",{get(){return h.canRedoSteps()}});const g={...h,callbacks:h.callbacks()};return Object.defineProperty(g,"disableDeviceInputs",{set(d){h.setDisableDeviceInputs(d)},get(){return h.getDisableDeviceInputs()}}),Object.defineProperty(g,"disableEraseImage",{set(d){h.setDisableEraseImage(d)},get(){return h.getDisableEraseImage()}}),Object.defineProperty(g,"disableCameraTransform",{set(d){h.setDisableCameraTransform(d)},get(){return h.getDisableCameraTransform()}}),e._appliancePlugin=g,e._appliancePlugin}static onCreate(e){e&&L.currentManager&&(L.currentManager.bindPlugin(e),e.init(e.displayer))}static async createAppliancePlugin(e,t){try{await e.createInvisiblePlugin(L,{})}catch(o){if(!e.isWritable){await e.setWritable(!0);const s=await this.createAppliancePlugin(e,t);return await e.setWritable(!1),s}throw o}let i=e.getInvisiblePlugin(t);return i||(i=await L.createAppliancePlugin(e,t)),i}static effectInstance(){if(L.cursorAdapter){const e=L.cursorAdapter.onAddedCursor;L.cursorAdapter.onAddedCursor=function(t){t.onCursorMemberChanged=i=>{try{i.appliance===ie.pencil||i.appliance===ie.shape||i.appliance===ie.text||i.appliance===ie.arrow||i.appliance===ie.straight||i.appliance===ie.rectangle||i.appliance===ie.ellipse||i.appliance===ie.eraser||i.appliance===ie.selector?t!=null&&t.divElement&&(t.divElement.style.display="none"):t!=null&&t.divElement&&(t.divElement.style.display="block")}catch(o){throw o}},e.call(L.cursorAdapter,t)}}}get isReplay(){return G.isPlayer(this.displayer)}get callbackName(){return this.isReplay?"onPlayerStateChanged":"onRoomStateChanged"}init(e){var i,o;const t=e.state;(i=L.currentManager)==null||i.onRoomMembersChange(t.roomMembers),G.isRoom(e)&&t!=null&&t.memberState&&((o=L.currentManager)==null||o.onMemberChange(t.memberState)),this.displayer.callbacks.on(this.callbackName,this.roomStateChangeListener),this.displayer.callbacks.on("onEnableWriteNowChanged",this.updateRoomWritable),this.displayer.callbacks.on("onPhaseChanged",this.onPhaseChanged)}destroy(){var e;L.logger.info("[ApplianceSinglePlugin] passive destroy"),(e=L.currentManager)==null||e.destroy(),L.currentManager=void 0,L.cursorAdapter=void 0}};I(L,"kind","appliance-single-plugin"),I(L,"cursorAdapter"),I(L,"currentManager"),I(L,"logger",{info:console.log,warn:console.warn,error:console.error}),I(L,"createCurrentManager",(e,t,i)=>{L.currentManager&&L.currentManager.destroy();const o={plugin:i,displayer:e,options:t},s=new Ge(o);if(s.init(),L.logger.info("[ApplianceSinglePlugin] refresh ApplianceSingleManager object"),L.currentManager=s,G.isRoom(e)){const a=s.hasOffscreenCanvas,c=s.isUseOffscreenTransfer,l=s.pluginOptions,u=s.isUseSimple;e.logger.info(`[Appliance]: [ApplianceSinglePlugin] use ${a?"worker":"mainThread"}, isUseSimple: ${u} ${c?"offscreenTransfer":""}, options: ${JSON.stringify(l)}`)}});let ei=L;const Et=class Et extends f.Component{constructor(){super(...arguments);I(this,"mainViewRef",null)}componentDidMount(){Et.emiter||(Et.emiter=Ge.InternalMsgEmitter),Et.emiter.emit(ne.BindMainView,this.mainViewRef)}render(){return f.createElement(f.Fragment,null,this.props.children,f.createElement("div",{className:"appliance-plugin-main-view-displayer",ref:e=>this.mainViewRef=e}))}};I(Et,"emiter");let ti=Et;exports.ActiveContainerType=vo;exports.ApplianceMultiPlugin=_n;exports.ApplianceNames=ie;exports.ApplianceSigleWrapper=ti;exports.ApplianceSinglePlugin=ei;exports.Cursor_Hover_Id=Nr;exports.DefaultAppliancePluginExtrasOptions=Ie;exports.ECanvasShowType=Xe;exports.EDataType=_;exports.EForceStopReason=ni;exports.EImageType=Jt;exports.EMatrixrRelationType=qt;exports.EOperationType=be;exports.EPostMessageType=$;exports.ERenderFilterType=Ze;exports.ESVGType=Kt;exports.EScaleType=Oe;exports.EStrokeType=ce;exports.EToolsKey=S;exports.ElayerType=st;exports.EmitEventType=U;exports.EventMessageType=Ht;exports.EventWorkState=D;exports.InternalMsgEmitterType=ne;exports.Main_View_Id=re;exports.Plugin=qy;exports.Point2d=pe;exports.ShapeType=Ye;exports.Storage_Selector_key=Q;exports.Storage_Splitter=We;exports.Storage_ViewId_ALL=_o;exports.Task_Time_Interval=ii;exports.TextBoxPadding=Gn;exports.Vec2d=V;exports.ViewContainerManager=At;exports._Stack=Do;exports._baseGetTag=Pt;exports._equalArrays=er;exports._equalByTag=Lf;exports._getAllKeys=Fo;exports._getTag=Sn;exports.average=EM;exports.checkOp=kM;exports.cloneDeep=en;exports.colorRGBA2Array=Zt;exports.computRect=fM;exports.decimalPlaces=bM;exports.fullWorker=Sr;exports.gcd=DM;exports.getDefaultExportFromCjs=pn;exports.getRectFromPoints=Ii;exports.getRectMatrixrRelation=AM;exports.getRectRotated=IM;exports.getRectScaleWPoint=wM;exports.getRectTranslated=yM;exports.getSafetyRect=MM;exports.getWHRatio=CM;exports.isArray_1=_t;exports.isBufferExports=si;exports.isDecimal=xM;exports.isIntersect=pM;exports.isIntersectForPoint=rr;exports.isObjectLike_1=ct;exports.isSet=Zd;exports.isTypedArray_1=Ro;exports.precise=jM;exports.requestAsyncCallBack=He;exports.rgbToRgba=Dt;exports.rotateLitePoints=SM;exports.rotatePoints=TM;exports.scaleLitePoints=NM;exports.scalePoints=vM;exports.strlen=zM;exports.subWorker=vr;exports.transformToNormalData=vn;exports.transformToSerializableData=vt;