@netless/appliance-plugin 1.1.18 → 1.1.19-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 (73) hide show
  1. package/README.md +318 -260
  2. package/cdn/cdn.js +1 -1
  3. package/cdn/fullWorker-XyhFxc.js +439 -0
  4. package/cdn/subWorker-BpFYAC.js +439 -0
  5. package/dist/appliance-plugin.js +1 -1
  6. package/dist/appliance-plugin.mjs +7 -7
  7. package/dist/cdn.d.ts +2 -2
  8. package/dist/collector/collector.d.ts +2 -2
  9. package/dist/collector/index.d.ts +4 -4
  10. package/dist/collector/types.d.ts +2 -2
  11. package/dist/component/miniMap/index.d.ts +1 -1
  12. package/dist/component/miniMap/manager.d.ts +2 -2
  13. package/dist/component/miniMap/view.d.ts +1 -1
  14. package/dist/component/textEditor/index.d.ts +2 -2
  15. package/dist/component/textEditor/manager.d.ts +2 -1
  16. package/dist/component/textEditor/types.d.ts +4 -3
  17. package/dist/component/textEditor/view.d.ts +1 -1
  18. package/dist/core/index.d.ts +3 -3
  19. package/dist/core/mainEngine.d.ts +20 -5
  20. package/dist/core/mainThread/base.d.ts +4 -4
  21. package/dist/core/mainThread/index.d.ts +2 -2
  22. package/dist/core/mainThread/snapshotThread.d.ts +3 -3
  23. package/dist/core/mainThread/subLocalThread.d.ts +13 -6
  24. package/dist/core/mainThread/subServiceThread.d.ts +1 -1
  25. package/dist/core/mainThread/workerMainThread.d.ts +2 -2
  26. package/dist/core/msgEvent/copyNode/forMain.d.ts +2 -2
  27. package/dist/core/msgEvent/forMainThread.d.ts +4 -4
  28. package/dist/core/msgEvent/forWorker.d.ts +4 -4
  29. package/dist/core/msgEvent/index.d.ts +4 -4
  30. package/dist/core/tools/arrow.d.ts +4 -0
  31. package/dist/core/tools/base.d.ts +4 -3
  32. package/dist/core/tools/ellipse.d.ts +4 -0
  33. package/dist/core/tools/index.d.ts +14 -14
  34. package/dist/core/tools/laserPen.d.ts +1 -1
  35. package/dist/core/tools/pencilEraser.d.ts +4 -34
  36. package/dist/core/tools/pencilEraserBitMap.d.ts +7 -30
  37. package/dist/core/tools/polygon.d.ts +4 -0
  38. package/dist/core/tools/rectangle.d.ts +4 -0
  39. package/dist/core/tools/selector.d.ts +1 -1
  40. package/dist/core/tools/speechBalloon.d.ts +4 -0
  41. package/dist/core/tools/star.d.ts +4 -0
  42. package/dist/core/tools/straight.d.ts +4 -0
  43. package/dist/core/types.d.ts +20 -9
  44. package/dist/core/utils/clipper.d.ts +1 -1
  45. package/dist/core/utils/getSvgPathFromPoints.d.ts +1 -1
  46. package/dist/core/utils/index.d.ts +4 -4
  47. package/dist/core/utils/primitives/Box2d.d.ts +4 -4
  48. package/dist/core/utils/proxy.d.ts +3 -4
  49. package/dist/core/worker/base.d.ts +5 -2
  50. package/dist/core/worker/fullWorkerLocal.d.ts +6 -11
  51. package/dist/cursors/index.d.ts +6 -4
  52. package/dist/displayer/cursor/index.d.ts +1 -0
  53. package/dist/fullWorker.js +142 -203
  54. package/dist/{index-BRQCDzgF.mjs → index-BJkvFhzU.mjs} +9239 -5525
  55. package/dist/index-BXV0vpe1.js +1 -0
  56. package/dist/index-D2qjaZgV.js +1 -0
  57. package/dist/index-DM5jr5_3.mjs +2776 -0
  58. package/dist/plugin/applianceMultiPlugin.d.ts +2 -3
  59. package/dist/plugin/applianceSinglePlugin.d.ts +3 -4
  60. package/dist/plugin/baseApplianceManager.d.ts +4 -4
  61. package/dist/plugin/baseViewContainerManager.d.ts +7 -3
  62. package/dist/plugin/const.d.ts +2 -34
  63. package/dist/plugin/multi/containerManager.d.ts +1 -1
  64. package/dist/plugin/types.d.ts +61 -25
  65. package/dist/style.css +1 -1
  66. package/dist/subWorker.js +142 -203
  67. package/dist/undo/index.d.ts +1 -1
  68. package/package.json +8 -2
  69. package/cdn/fullWorker-D_Qymn.js +0 -500
  70. package/cdn/subWorker-am2Vr9.js +0 -500
  71. package/dist/index-BmM-scQu.mjs +0 -2502
  72. package/dist/index-C9F49Gge.js +0 -1
  73. package/dist/index-DUGXE2hv.js +0 -1
@@ -1 +0,0 @@
1
- "use strict";var xn=Object.defineProperty;var Dn=(r,i,e)=>i in r?xn(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e;var M=(r,i,e)=>Dn(r,typeof i!="symbol"?i+"":i,e);const $=require("white-web-sdk"),he=require("spritejs"),Io=require("lz-string"),ot=require("clipper-lib"),es=require("lineclip"),Ui=require("eventemitter2"),O=require("lodash"),Bi=require("xss"),y=require("react"),Ti=require("react-dom"),Yt=require("react-draggable"),Ln=require("re-resizable"),bn="/fullWorker.js",jn="/subWorker.js";var re=(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))(re||{}),oe=(r=>(r.Normal="Normal",r.Stroke="Stroke",r.Dotted="Dotted",r.LongDotted="LongDotted",r))(oe||{}),Ke=(r=>(r.Triangle="triangle",r.Rhombus="rhombus",r.Pentagram="pentagram",r.SpeechBalloon="speechBalloon",r.Star="star",r.Polygon="polygon",r))(Ke||{}),V=(r=>(r.None="None",r.ShowFloatBar="ShowFloatBar",r.ZIndexFloatBar="ZIndexFloatBar",r.DeleteNode="DeleteNode",r.CopyNode="CopyNode",r.ZIndexActive="ZIndexActive",r.ZIndexNode="ZIndexNode",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))(V||{}),ne=(r=>(r.DisplayState="DisplayState",r.MainEngine="MainEngine",r.Cursor="Cursor",r.BindMainView="BindMainView",r))(ne||{}),To=(r=>(r[r.MainView=0]="MainView",r[r.Plugin=1]="Plugin",r[r.Both=2]="Both",r))(To||{}),vi=(r=>(r.longPencil="longPencil",r))(vi||{}),T=(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))(T||{}),B=(r=>(r[r.Local=1]="Local",r[r.Service=2]="Service",r[r.Worker=3]="Worker",r))(B||{}),j=(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))(j||{}),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.PriorityWorker=21]="PriorityWorker",r[r.PriorityMainThreadWorker=22]="PriorityMainThreadWorker",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))(D||{}),me=(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))(me||{}),Jt=(r=>(r[r.Cursor=1]="Cursor",r[r.TextCreate=2]="TextCreate",r))(Jt||{}),qt=(r=>(r[r.Top=1]="Top",r[r.Bottom=2]="Bottom",r))(qt||{}),ce=(r=>(r[r.none=1]="none",r[r.all=2]="all",r[r.both=3]="both",r[r.proportional=4]="proportional",r))(ce||{}),vo=(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))(vo||{}),Nt=(r=>(r[r.inside=0]="inside",r[r.outside=1]="outside",r[r.intersect=2]="intersect",r))(Nt||{}),Ye=(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))(Ye||{}),et=(r=>(r.setAuth="setAuth",r.setShow="addShow",r.setHide="setHide",r.setClear="setClear",r))(et||{}),St=(r=>(r.Image="image",r.Iconify="iconify",r))(St||{});const An={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 k{constructor(i=0,e=0,t=1){this.x=i,this.y=e,this.z=t}get XY(){return[this.x,this.y]}setz(i){return this.z=i,this}setXY(i=this.x,e=this.y){return this.x=i,this.y=e,this}set(i=this.x,e=this.y,t=this.z){return this.x=i,this.y=e,this.z=t,this}setTo({x:i=0,y:e=0,z:t=1}){return this.x=i,this.y=e,this.z=t,this}rot(i){if(i===0)return this;const{x:e,y:t}=this,s=Math.sin(i),o=Math.cos(i);return this.x=e*o-t*s,this.y=e*s+t*o,this}rotWith(i,e){if(e===0)return this;const t=this.x-i.x,s=this.y-i.y,o=Math.sin(e),n=Math.cos(e);return this.x=i.x+(t*n-s*o),this.y=i.y+(t*o+s*n),this}clone(){const{x:i,y:e,z:t}=this;return new k(i,e,t)}sub(i){return this.x-=i.x,this.y-=i.y,this}subXY(i,e){return this.x-=i,this.y-=e,this}subScalar(i){return this.x-=i,this.y-=i,this}add(i){return this.x+=i.x,this.y+=i.y,this}addXY(i,e){return this.x+=i,this.y+=e,this}addScalar(i){return this.x+=i,this.y+=i,this}clamp(i,e){return this.x=Math.max(this.x,i),this.y=Math.max(this.y,i),e!==void 0&&(this.x=Math.min(this.x,e),this.y=Math.min(this.y,e)),this}div(i){return this.x/=i,this.y/=i,this}divV(i){return this.x/=i.x,this.y/=i.y,this}mul(i){return this.x*=i,this.y*=i,this}mulV(i){return this.x*=i.x,this.y*=i.y,this}abs(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this}nudge(i,e){const t=k.Tan(i,this);return this.add(t.mul(e))}neg(){return this.x*=-1,this.y*=-1,this}cross(i){return this.x=this.y*i.z-this.z*i.y,this.y=this.z*i.x-this.x*i.z,this}dpr(i){return k.Dpr(this,i)}cpr(i){return k.Cpr(this,i)}len2(){return k.Len2(this)}len(){return k.Len(this)}pry(i){return k.Pry(this,i)}per(){const{x:i,y:e}=this;return this.x=e,this.y=-i,this}uni(){return k.Uni(this)}tan(i){return k.Tan(this,i)}dist(i){return k.Dist(this,i)}distanceToLineSegment(i,e){return k.DistanceToLineSegment(i,e,this)}slope(i){return k.Slope(this,i)}snapToGrid(i){return this.x=Math.round(this.x/i)*i,this.y=Math.round(this.y/i)*i,this}angle(i){return k.Angle(this,i)}toAngle(){return k.ToAngle(this)}lrp(i,e){return this.x=this.x+(i.x-this.x)*e,this.y=this.y+(i.y-this.y)*e,this}equals(i,e){return k.Equals(this,i,e)}equalsXY(i,e){return k.EqualsXY(this,i,e)}norm(){const i=this.len();return this.x=i===0?0:this.x/i,this.y=i===0?0:this.y/i,this}toFixed(){return k.ToFixed(this)}toString(){return k.ToString(k.ToFixed(this))}toJson(){return k.ToJson(this)}toArray(){return k.ToArray(this)}static Add(i,e){return new k(i.x+e.x,i.y+e.y)}static AddXY(i,e,t){return new k(i.x+e,i.y+t)}static Sub(i,e){return new k(i.x-e.x,i.y-e.y)}static SubXY(i,e,t){return new k(i.x-e,i.y-t)}static AddScalar(i,e){return new k(i.x+e,i.y+e)}static SubScalar(i,e){return new k(i.x-e,i.y-e)}static Div(i,e){return new k(i.x/e,i.y/e)}static Mul(i,e){return new k(i.x*e,i.y*e)}static DivV(i,e){return new k(i.x/e.x,i.y/e.y)}static MulV(i,e){return new k(i.x*e.x,i.y*e.y)}static Neg(i){return new k(-i.x,-i.y)}static Per(i){return new k(i.y,-i.x)}static Dist2(i,e){return k.Sub(i,e).len2()}static Abs(i){return new k(Math.abs(i.x),Math.abs(i.y))}static Dist(i,e){return Math.hypot(i.y-e.y,i.x-e.x)}static Dpr(i,e){return i.x*e.x+i.y*e.y}static Cross(i,e){return new k(i.y*e.z-i.z*e.y,i.z*e.x-i.x*e.z)}static Cpr(i,e){return i.x*e.y-e.x*i.y}static Len2(i){return i.x*i.x+i.y*i.y}static Len(i){return Math.hypot(i.x,i.y)}static Pry(i,e){return k.Dpr(i,e)/k.Len(e)}static Uni(i){return k.Div(i,k.Len(i))}static Tan(i,e){return k.Uni(k.Sub(i,e))}static Min(i,e){return new k(Math.min(i.x,e.x),Math.min(i.y,e.y))}static Max(i,e){return new k(Math.max(i.x,e.x),Math.max(i.y,e.y))}static From(i){return new k().add(i)}static FromArray(i){return new k(i[0],i[1])}static Rot(i,e=0){const t=Math.sin(e),s=Math.cos(e);return new k(i.x*s-i.y*t,i.x*t+i.y*s)}static RotWith(i,e,t){const s=i.x-e.x,o=i.y-e.y,n=Math.sin(t),a=Math.cos(t);return new k(e.x+(s*a-o*n),e.y+(s*n+o*a))}static NearestPointOnLineThroughPoint(i,e,t){return k.Mul(e,k.Sub(t,i).pry(e)).add(i)}static NearestPointOnLineSegment(i,e,t,s=!0){const o=k.Tan(e,i),n=k.Add(i,k.Mul(o,k.Sub(t,i).pry(o)));if(s){if(n.x<Math.min(i.x,e.x))return k.Cast(i.x<e.x?i:e);if(n.x>Math.max(i.x,e.x))return k.Cast(i.x>e.x?i:e);if(n.y<Math.min(i.y,e.y))return k.Cast(i.y<e.y?i:e);if(n.y>Math.max(i.y,e.y))return k.Cast(i.y>e.y?i:e)}return n}static DistanceToLineThroughPoint(i,e,t){return k.Dist(t,k.NearestPointOnLineThroughPoint(i,e,t))}static DistanceToLineSegment(i,e,t,s=!0){return k.Dist(t,k.NearestPointOnLineSegment(i,e,t,s))}static Snap(i,e=1){return new k(Math.round(i.x/e)*e,Math.round(i.y/e)*e)}static Cast(i){return i instanceof k?i:k.From(i)}static Slope(i,e){return i.x===e.y?NaN:(i.y-e.y)/(i.x-e.x)}static Angle(i,e){return Math.atan2(e.y-i.y,e.x-i.x)}static Lrp(i,e,t){return k.Sub(e,i).mul(t).add(i)}static Med(i,e){return new k((i.x+e.x)/2,(i.y+e.y)/2)}static Equals(i,e,t=1e-4){return Math.abs(i.x-e.x)<t&&Math.abs(i.y-e.y)<t}static EqualsXY(i,e,t){return i.x===e&&i.y===t}static EqualsXYZ(i,e,t=1e-4){return k.Equals(i,e,t)&&Math.abs((i.z||0)-(e.z||0))<t}static Clockwise(i,e,t){return(t.x-i.x)*(e.y-i.y)-(e.x-i.x)*(t.y-i.y)<0}static Rescale(i,e){const t=k.Len(i);return new k(e*i.x/t,e*i.y/t)}static ScaleWithOrigin(i,e,t){return k.Sub(i,t).mul(e).add(t)}static ScaleWOrigin(i,e,t){return k.Sub(i,t).mulV(e).add(t)}static ToFixed(i,e=2){return new k(+i.x.toFixed(e),+i.y.toFixed(e),+i.z.toFixed(e))}static Nudge(i,e,t){return k.Add(i,k.Tan(e,i).mul(t))}static ToString(i){return`${i.x}, ${i.y}`}static ToAngle(i){let e=Math.atan2(i.y,i.x);return e<0&&(e+=Math.PI*2),e}static FromAngle(i,e=1){return new k(Math.cos(i)*e,Math.sin(i)*e)}static ToArray(i){return[i.x,i.y,i.z]}static ToJson(i){const{x:e,y:t,z:s}=i;return{x:e,y:t,z:s}}static Average(i){const e=i.length,t=new k(0,0);for(let s=0;s<e;s++)t.add(i[s]);return t.div(e)}static Clamp(i,e,t){return t===void 0?new k(Math.min(Math.max(i.x,e)),Math.min(Math.max(i.y,e))):new k(Math.min(Math.max(i.x,e),t),Math.min(Math.max(i.y,e),t))}static PointsBetween(i,e,t=6){const s=[];for(let o=0;o<t;o++){const n=An.easeInQuad(o/(t-1)),a=k.Lrp(i,e,n);a.z=Math.min(1,.5+Math.abs(.5-Pn(n))*.65),s.push(a)}return s}static SnapToGrid(i,e=8){return new k(Math.round(i.x/e)*e,Math.round(i.y/e)*e)}}const Pn=r=>r<.5?2*r*r:-1+(4-2*r)*r;class Q extends k{constructor(i=0,e=0,t=0,s={x:0,y:0},o=0,n=0){super(i,e,t),this.x=i,this.y=e,this.z=t,this.v=s,this.t=o,this.a=n}get timestamp(){return this.t}get pressure(){return this.z}get angleNum(){return this.a}get XY(){return[this.x,this.y]}setA(i){this.a=i}setT(i){this.t=i}setv(i){return this.v={x:i.x,y:i.y},this}set(i=this.x,e=this.y,t=this.z,s=this.v,o=this.t,n=this.a){return this.x=i,this.y=e,this.z=t,this.v=s,this.t=o,this.a=n,this}clone(){const{x:i,y:e,z:t,v:s,t:o,a:n}=this,a={x:s.x,y:s.y};return new Q(i,e,t,a,o,n)}distance(i){return Q.GetDistance(this,i)}isNear(i,e){return Q.IsNear(this,i,e)}getAngleByPoints(i,e){return Q.GetAngleByPoints(i,this,e)}static Sub(i,e){return new Q(i.x-e.x,i.y-e.y)}static Add(i,e){return new Q(i.x+e.x,i.y+e.y)}static GetDistance(i,e){return Q.Len(i.clone().sub(e))}static GetAngleByPoints(i,e,t){const s=e.x-i.x,o=t.x-e.x,n=e.y-i.y,a=t.y-e.y;let c=0;const l=Math.sqrt(s*s+n*n),u=Math.sqrt(o*o+a*a);if(l&&u){const h=s*o+n*a;c=Math.acos(h/(l*u)),c=c/Math.PI*180;let d=s*a-n*o;d=d>0?1:-1,c=180+d*c}return c}static IsNear(i,e,t){return Q.Len(i.clone().sub(e))<t}static RotWith(i,e,t,s=2){const o=i.x-e.x,n=i.y-e.y,a=Math.sin(t),c=Math.cos(t),l=Math.pow(10,s),u=Math.floor((e.x+(o*c-n*a))*l)/l,h=Math.floor((e.y+(o*a+n*c))*l)/l;return new Q(u,h)}static GetDotStroke(i,e,t=16){const s=new k(1,1),o=Math.PI+.001,n=Q.Add(i,Q.Sub(i,s).uni().per().mul(-e)),a=[];for(let c=1/t,l=c;l<=1;l+=c)a.push(Q.RotWith(n,i,o*2*l));return a}static GetSemicircleStroke(i,e,t=-1,s=8){const o=t*(Math.PI+.001),n=[];for(let a=1/s,c=a;c<=1;c+=a)n.push(Q.RotWith(e,i,o*c));return n}}var oi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ut(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var zn=typeof oi=="object"&&oi&&oi.Object===Object&&oi,No=zn,En=No,On=typeof self=="object"&&self&&self.Object===Object&&self,Rn=En||On||Function("return this")(),it=Rn,Wn=it,Yn=Wn.Symbol,ei=Yn,Cs=ei,So=Object.prototype,Un=So.hasOwnProperty,Bn=So.toString,Gt=Cs?Cs.toStringTag:void 0;function Fn(r){var i=Un.call(r,Gt),e=r[Gt];try{r[Gt]=void 0;var t=!0}catch{}var s=Bn.call(r);return t&&(i?r[Gt]=e:delete r[Gt]),s}var Vn=Fn,Qn=Object.prototype,Zn=Qn.toString;function Hn(r){return Zn.call(r)}var Gn=Hn,ks=ei,$n=Vn,Xn=Gn,Jn="[object Null]",qn="[object Undefined]",xs=ks?ks.toStringTag:void 0;function Kn(r){return r==null?r===void 0?qn:Jn:xs&&xs in Object(r)?$n(r):Xn(r)}var kt=Kn;function _n(r){return r!=null&&typeof r=="object"}var at=_n,er=kt,tr=at,ir="[object Number]";function sr(r){return typeof r=="number"||tr(r)&&er(r)==ir}var or=sr;const ze=Ut(or);function nr(){this.__data__=[],this.size=0}var rr=nr;function ar(r,i){return r===i||r!==r&&i!==i}var ts=ar,cr=ts;function lr(r,i){for(var e=r.length;e--;)if(cr(r[e][0],i))return e;return-1}var Ni=lr,hr=Ni,ur=Array.prototype,dr=ur.splice;function pr(r){var i=this.__data__,e=hr(i,r);if(e<0)return!1;var t=i.length-1;return e==t?i.pop():dr.call(i,e,1),--this.size,!0}var gr=pr,fr=Ni;function Mr(r){var i=this.__data__,e=fr(i,r);return e<0?void 0:i[e][1]}var yr=Mr,mr=Ni;function wr(r){return mr(this.__data__,r)>-1}var Ir=wr,Tr=Ni;function vr(r,i){var e=this.__data__,t=Tr(e,r);return t<0?(++this.size,e.push([r,i])):e[t][1]=i,this}var Nr=vr,Sr=rr,Cr=gr,kr=yr,xr=Ir,Dr=Nr;function Bt(r){var i=-1,e=r==null?0:r.length;for(this.clear();++i<e;){var t=r[i];this.set(t[0],t[1])}}Bt.prototype.clear=Sr;Bt.prototype.delete=Cr;Bt.prototype.get=kr;Bt.prototype.has=xr;Bt.prototype.set=Dr;var Si=Bt,Lr=Si;function br(){this.__data__=new Lr,this.size=0}var jr=br;function Ar(r){var i=this.__data__,e=i.delete(r);return this.size=i.size,e}var Pr=Ar;function zr(r){return this.__data__.get(r)}var Er=zr;function Or(r){return this.__data__.has(r)}var Rr=Or;function Wr(r){var i=typeof r;return r!=null&&(i=="object"||i=="function")}var Mt=Wr,Yr=kt,Ur=Mt,Br="[object AsyncFunction]",Fr="[object Function]",Vr="[object GeneratorFunction]",Qr="[object Proxy]";function Zr(r){if(!Ur(r))return!1;var i=Yr(r);return i==Fr||i==Vr||i==Br||i==Qr}var Co=Zr,Hr=it,Gr=Hr["__core-js_shared__"],$r=Gr,zi=$r,Ds=function(){var r=/[^.]+$/.exec(zi&&zi.keys&&zi.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function Xr(r){return!!Ds&&Ds in r}var Jr=Xr,qr=Function.prototype,Kr=qr.toString;function _r(r){if(r!=null){try{return Kr.call(r)}catch{}try{return r+""}catch{}}return""}var ko=_r,ea=Co,ta=Jr,ia=Mt,sa=ko,oa=/[\\^$.*+?()[\]{}|]/g,na=/^\[object .+?Constructor\]$/,ra=Function.prototype,aa=Object.prototype,ca=ra.toString,la=aa.hasOwnProperty,ha=RegExp("^"+ca.call(la).replace(oa,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ua(r){if(!ia(r)||ta(r))return!1;var i=ea(r)?ha:na;return i.test(sa(r))}var da=ua;function pa(r,i){return r==null?void 0:r[i]}var ga=pa,fa=da,Ma=ga;function ya(r,i){var e=Ma(r,i);return fa(e)?e:void 0}var xt=ya,ma=xt,wa=it,Ia=ma(wa,"Map"),is=Ia,Ta=xt,va=Ta(Object,"create"),Ci=va,Ls=Ci;function Na(){this.__data__=Ls?Ls(null):{},this.size=0}var Sa=Na;function Ca(r){var i=this.has(r)&&delete this.__data__[r];return this.size-=i?1:0,i}var ka=Ca,xa=Ci,Da="__lodash_hash_undefined__",La=Object.prototype,ba=La.hasOwnProperty;function ja(r){var i=this.__data__;if(xa){var e=i[r];return e===Da?void 0:e}return ba.call(i,r)?i[r]:void 0}var Aa=ja,Pa=Ci,za=Object.prototype,Ea=za.hasOwnProperty;function Oa(r){var i=this.__data__;return Pa?i[r]!==void 0:Ea.call(i,r)}var Ra=Oa,Wa=Ci,Ya="__lodash_hash_undefined__";function Ua(r,i){var e=this.__data__;return this.size+=this.has(r)?0:1,e[r]=Wa&&i===void 0?Ya:i,this}var Ba=Ua,Fa=Sa,Va=ka,Qa=Aa,Za=Ra,Ha=Ba;function Ft(r){var i=-1,e=r==null?0:r.length;for(this.clear();++i<e;){var t=r[i];this.set(t[0],t[1])}}Ft.prototype.clear=Fa;Ft.prototype.delete=Va;Ft.prototype.get=Qa;Ft.prototype.has=Za;Ft.prototype.set=Ha;var Ga=Ft,bs=Ga,$a=Si,Xa=is;function Ja(){this.size=0,this.__data__={hash:new bs,map:new(Xa||$a),string:new bs}}var qa=Ja;function Ka(r){var i=typeof r;return i=="string"||i=="number"||i=="symbol"||i=="boolean"?r!=="__proto__":r===null}var _a=Ka,ec=_a;function tc(r,i){var e=r.__data__;return ec(i)?e[typeof i=="string"?"string":"hash"]:e.map}var ki=tc,ic=ki;function sc(r){var i=ic(this,r).delete(r);return this.size-=i?1:0,i}var oc=sc,nc=ki;function rc(r){return nc(this,r).get(r)}var ac=rc,cc=ki;function lc(r){return cc(this,r).has(r)}var hc=lc,uc=ki;function dc(r,i){var e=uc(this,r),t=e.size;return e.set(r,i),this.size+=e.size==t?0:1,this}var pc=dc,gc=qa,fc=oc,Mc=ac,yc=hc,mc=pc;function Vt(r){var i=-1,e=r==null?0:r.length;for(this.clear();++i<e;){var t=r[i];this.set(t[0],t[1])}}Vt.prototype.clear=gc;Vt.prototype.delete=fc;Vt.prototype.get=Mc;Vt.prototype.has=yc;Vt.prototype.set=mc;var xo=Vt,wc=Si,Ic=is,Tc=xo,vc=200;function Nc(r,i){var e=this.__data__;if(e instanceof wc){var t=e.__data__;if(!Ic||t.length<vc-1)return t.push([r,i]),this.size=++e.size,this;e=this.__data__=new Tc(t)}return e.set(r,i),this.size=e.size,this}var Sc=Nc,Cc=Si,kc=jr,xc=Pr,Dc=Er,Lc=Rr,bc=Sc;function Qt(r){var i=this.__data__=new Cc(r);this.size=i.size}Qt.prototype.clear=kc;Qt.prototype.delete=xc;Qt.prototype.get=Dc;Qt.prototype.has=Lc;Qt.prototype.set=bc;var Do=Qt;function jc(r,i){for(var e=-1,t=r==null?0:r.length;++e<t&&i(r[e],e,r)!==!1;);return r}var Ac=jc,Pc=xt,zc=function(){try{var r=Pc(Object,"defineProperty");return r({},"",{}),r}catch{}}(),Lo=zc,js=Lo;function Ec(r,i,e){i=="__proto__"&&js?js(r,i,{configurable:!0,enumerable:!0,value:e,writable:!0}):r[i]=e}var bo=Ec,Oc=bo,Rc=ts,Wc=Object.prototype,Yc=Wc.hasOwnProperty;function Uc(r,i,e){var t=r[i];(!(Yc.call(r,i)&&Rc(t,e))||e===void 0&&!(i in r))&&Oc(r,i,e)}var jo=Uc,Bc=jo,Fc=bo;function Vc(r,i,e,t){var s=!e;e||(e={});for(var o=-1,n=i.length;++o<n;){var a=i[o],c=t?t(e[a],r[a],a,e,r):void 0;c===void 0&&(c=r[a]),s?Fc(e,a,c):Bc(e,a,c)}return e}var xi=Vc;function Qc(r,i){for(var e=-1,t=Array(r);++e<r;)t[e]=i(e);return t}var Zc=Qc,Hc=kt,Gc=at,$c="[object Arguments]";function Xc(r){return Gc(r)&&Hc(r)==$c}var Jc=Xc,As=Jc,qc=at,Ao=Object.prototype,Kc=Ao.hasOwnProperty,_c=Ao.propertyIsEnumerable,el=As(function(){return arguments}())?As:function(r){return qc(r)&&Kc.call(r,"callee")&&!_c.call(r,"callee")},Po=el,tl=Array.isArray,ti=tl,li={exports:{}};function il(){return!1}var sl=il;li.exports;(function(r,i){var e=it,t=sl,s=i&&!i.nodeType&&i,o=s&&!0&&r&&!r.nodeType&&r,n=o&&o.exports===s,a=n?e.Buffer:void 0,c=a?a.isBuffer:void 0,l=c||t;r.exports=l})(li,li.exports);var ss=li.exports,ol=9007199254740991,nl=/^(?:0|[1-9]\d*)$/;function rl(r,i){var e=typeof r;return i=i??ol,!!i&&(e=="number"||e!="symbol"&&nl.test(r))&&r>-1&&r%1==0&&r<i}var al=rl,cl=9007199254740991;function ll(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=cl}var zo=ll,hl=kt,ul=zo,dl=at,pl="[object Arguments]",gl="[object Array]",fl="[object Boolean]",Ml="[object Date]",yl="[object Error]",ml="[object Function]",wl="[object Map]",Il="[object Number]",Tl="[object Object]",vl="[object RegExp]",Nl="[object Set]",Sl="[object String]",Cl="[object WeakMap]",kl="[object ArrayBuffer]",xl="[object DataView]",Dl="[object Float32Array]",Ll="[object Float64Array]",bl="[object Int8Array]",jl="[object Int16Array]",Al="[object Int32Array]",Pl="[object Uint8Array]",zl="[object Uint8ClampedArray]",El="[object Uint16Array]",Ol="[object Uint32Array]",Ne={};Ne[Dl]=Ne[Ll]=Ne[bl]=Ne[jl]=Ne[Al]=Ne[Pl]=Ne[zl]=Ne[El]=Ne[Ol]=!0;Ne[pl]=Ne[gl]=Ne[kl]=Ne[fl]=Ne[xl]=Ne[Ml]=Ne[yl]=Ne[ml]=Ne[wl]=Ne[Il]=Ne[Tl]=Ne[vl]=Ne[Nl]=Ne[Sl]=Ne[Cl]=!1;function Rl(r){return dl(r)&&ul(r.length)&&!!Ne[hl(r)]}var Wl=Rl;function Yl(r){return function(i){return r(i)}}var Di=Yl,hi={exports:{}};hi.exports;(function(r,i){var e=No,t=i&&!i.nodeType&&i,s=t&&!0&&r&&!r.nodeType&&r,o=s&&s.exports===t,n=o&&e.process,a=function(){try{var c=s&&s.require&&s.require("util").types;return c||n&&n.binding&&n.binding("util")}catch{}}();r.exports=a})(hi,hi.exports);var os=hi.exports,Ul=Wl,Bl=Di,Ps=os,zs=Ps&&Ps.isTypedArray,Fl=zs?Bl(zs):Ul,Eo=Fl,Vl=Zc,Ql=Po,Zl=ti,Hl=ss,Gl=al,$l=Eo,Xl=Object.prototype,Jl=Xl.hasOwnProperty;function ql(r,i){var e=Zl(r),t=!e&&Ql(r),s=!e&&!t&&Hl(r),o=!e&&!t&&!s&&$l(r),n=e||t||s||o,a=n?Vl(r.length,String):[],c=a.length;for(var l in r)(i||Jl.call(r,l))&&!(n&&(l=="length"||s&&(l=="offset"||l=="parent")||o&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||Gl(l,c)))&&a.push(l);return a}var Oo=ql,Kl=Object.prototype;function _l(r){var i=r&&r.constructor,e=typeof i=="function"&&i.prototype||Kl;return r===e}var ns=_l;function eh(r,i){return function(e){return r(i(e))}}var Ro=eh,th=Ro,ih=th(Object.keys,Object),sh=ih,oh=ns,nh=sh,rh=Object.prototype,ah=rh.hasOwnProperty;function ch(r){if(!oh(r))return nh(r);var i=[];for(var e in Object(r))ah.call(r,e)&&e!="constructor"&&i.push(e);return i}var lh=ch,hh=Co,uh=zo;function dh(r){return r!=null&&uh(r.length)&&!hh(r)}var rs=dh,ph=Oo,gh=lh,fh=rs;function Mh(r){return fh(r)?ph(r):gh(r)}var as=Mh,yh=xi,mh=as;function wh(r,i){return r&&yh(i,mh(i),r)}var Ih=wh;function Th(r){var i=[];if(r!=null)for(var e in Object(r))i.push(e);return i}var vh=Th,Nh=Mt,Sh=ns,Ch=vh,kh=Object.prototype,xh=kh.hasOwnProperty;function Dh(r){if(!Nh(r))return Ch(r);var i=Sh(r),e=[];for(var t in r)t=="constructor"&&(i||!xh.call(r,t))||e.push(t);return e}var Lh=Dh,bh=Oo,jh=Lh,Ah=rs;function Ph(r){return Ah(r)?bh(r,!0):jh(r)}var cs=Ph,zh=xi,Eh=cs;function Oh(r,i){return r&&zh(i,Eh(i),r)}var Rh=Oh,ui={exports:{}};ui.exports;(function(r,i){var e=it,t=i&&!i.nodeType&&i,s=t&&!0&&r&&!r.nodeType&&r,o=s&&s.exports===t,n=o?e.Buffer:void 0,a=n?n.allocUnsafe:void 0;function c(l,u){if(u)return l.slice();var h=l.length,d=a?a(h):new l.constructor(h);return l.copy(d),d}r.exports=c})(ui,ui.exports);var Wh=ui.exports;function Yh(r,i){var e=-1,t=r.length;for(i||(i=Array(t));++e<t;)i[e]=r[e];return i}var Uh=Yh;function Bh(r,i){for(var e=-1,t=r==null?0:r.length,s=0,o=[];++e<t;){var n=r[e];i(n,e,r)&&(o[s++]=n)}return o}var Wo=Bh;function Fh(){return[]}var Yo=Fh,Vh=Wo,Qh=Yo,Zh=Object.prototype,Hh=Zh.propertyIsEnumerable,Es=Object.getOwnPropertySymbols,Gh=Es?function(r){return r==null?[]:(r=Object(r),Vh(Es(r),function(i){return Hh.call(r,i)}))}:Qh,ls=Gh,$h=xi,Xh=ls;function Jh(r,i){return $h(r,Xh(r),i)}var qh=Jh;function Kh(r,i){for(var e=-1,t=i.length,s=r.length;++e<t;)r[s+e]=i[e];return r}var hs=Kh,_h=Ro,eu=_h(Object.getPrototypeOf,Object),Uo=eu,tu=hs,iu=Uo,su=ls,ou=Yo,nu=Object.getOwnPropertySymbols,ru=nu?function(r){for(var i=[];r;)tu(i,su(r)),r=iu(r);return i}:ou,Bo=ru,au=xi,cu=Bo;function lu(r,i){return au(r,cu(r),i)}var hu=lu,uu=hs,du=ti;function pu(r,i,e){var t=i(r);return du(r)?t:uu(t,e(r))}var Fo=pu,gu=Fo,fu=ls,Mu=as;function yu(r){return gu(r,Mu,fu)}var Vo=yu,mu=Fo,wu=Bo,Iu=cs;function Tu(r){return mu(r,Iu,wu)}var vu=Tu,Nu=xt,Su=it,Cu=Nu(Su,"DataView"),ku=Cu,xu=xt,Du=it,Lu=xu(Du,"Promise"),bu=Lu,ju=xt,Au=it,Pu=ju(Au,"Set"),Qo=Pu,zu=xt,Eu=it,Ou=zu(Eu,"WeakMap"),Ru=Ou,Fi=ku,Vi=is,Qi=bu,Zi=Qo,Hi=Ru,Zo=kt,Zt=ko,Os="[object Map]",Wu="[object Object]",Rs="[object Promise]",Ws="[object Set]",Ys="[object WeakMap]",Us="[object DataView]",Yu=Zt(Fi),Uu=Zt(Vi),Bu=Zt(Qi),Fu=Zt(Zi),Vu=Zt(Hi),mt=Zo;(Fi&&mt(new Fi(new ArrayBuffer(1)))!=Us||Vi&&mt(new Vi)!=Os||Qi&&mt(Qi.resolve())!=Rs||Zi&&mt(new Zi)!=Ws||Hi&&mt(new Hi)!=Ys)&&(mt=function(r){var i=Zo(r),e=i==Wu?r.constructor:void 0,t=e?Zt(e):"";if(t)switch(t){case Yu:return Us;case Uu:return Os;case Bu:return Rs;case Fu:return Ws;case Vu:return Ys}return i});var Li=mt,Qu=Object.prototype,Zu=Qu.hasOwnProperty;function Hu(r){var i=r.length,e=new r.constructor(i);return i&&typeof r[0]=="string"&&Zu.call(r,"index")&&(e.index=r.index,e.input=r.input),e}var Gu=Hu,$u=it,Xu=$u.Uint8Array,Ho=Xu,Bs=Ho;function Ju(r){var i=new r.constructor(r.byteLength);return new Bs(i).set(new Bs(r)),i}var us=Ju,qu=us;function Ku(r,i){var e=i?qu(r.buffer):r.buffer;return new r.constructor(e,r.byteOffset,r.byteLength)}var _u=Ku,ed=/\w*$/;function td(r){var i=new r.constructor(r.source,ed.exec(r));return i.lastIndex=r.lastIndex,i}var id=td,Fs=ei,Vs=Fs?Fs.prototype:void 0,Qs=Vs?Vs.valueOf:void 0;function sd(r){return Qs?Object(Qs.call(r)):{}}var od=sd,nd=us;function rd(r,i){var e=i?nd(r.buffer):r.buffer;return new r.constructor(e,r.byteOffset,r.length)}var ad=rd,cd=us,ld=_u,hd=id,ud=od,dd=ad,pd="[object Boolean]",gd="[object Date]",fd="[object Map]",Md="[object Number]",yd="[object RegExp]",md="[object Set]",wd="[object String]",Id="[object Symbol]",Td="[object ArrayBuffer]",vd="[object DataView]",Nd="[object Float32Array]",Sd="[object Float64Array]",Cd="[object Int8Array]",kd="[object Int16Array]",xd="[object Int32Array]",Dd="[object Uint8Array]",Ld="[object Uint8ClampedArray]",bd="[object Uint16Array]",jd="[object Uint32Array]";function Ad(r,i,e){var t=r.constructor;switch(i){case Td:return cd(r);case pd:case gd:return new t(+r);case vd:return ld(r,e);case Nd:case Sd:case Cd:case kd:case xd:case Dd:case Ld:case bd:case jd:return dd(r,e);case fd:return new t;case Md:case wd:return new t(r);case yd:return hd(r);case md:return new t;case Id:return ud(r)}}var Pd=Ad,zd=Mt,Zs=Object.create,Ed=function(){function r(){}return function(i){if(!zd(i))return{};if(Zs)return Zs(i);r.prototype=i;var e=new r;return r.prototype=void 0,e}}(),Od=Ed,Rd=Od,Wd=Uo,Yd=ns;function Ud(r){return typeof r.constructor=="function"&&!Yd(r)?Rd(Wd(r)):{}}var Bd=Ud,Fd=Li,Vd=at,Qd="[object Map]";function Zd(r){return Vd(r)&&Fd(r)==Qd}var Hd=Zd,Gd=Hd,$d=Di,Hs=os,Gs=Hs&&Hs.isMap,Xd=Gs?$d(Gs):Gd,Jd=Xd,qd=Li,Kd=at,_d="[object Set]";function ep(r){return Kd(r)&&qd(r)==_d}var tp=ep,ip=tp,sp=Di,$s=os,Xs=$s&&$s.isSet,op=Xs?sp(Xs):ip,Go=op;const np=Ut(Go);var rp=Do,ap=Ac,cp=jo,lp=Ih,hp=Rh,up=Wh,dp=Uh,pp=qh,gp=hu,fp=Vo,Mp=vu,yp=Li,mp=Gu,wp=Pd,Ip=Bd,Tp=ti,vp=ss,Np=Jd,Sp=Mt,Cp=Go,kp=as,xp=cs,Dp=1,Lp=2,bp=4,$o="[object Arguments]",jp="[object Array]",Ap="[object Boolean]",Pp="[object Date]",zp="[object Error]",Xo="[object Function]",Ep="[object GeneratorFunction]",Op="[object Map]",Rp="[object Number]",Jo="[object Object]",Wp="[object RegExp]",Yp="[object Set]",Up="[object String]",Bp="[object Symbol]",Fp="[object WeakMap]",Vp="[object ArrayBuffer]",Qp="[object DataView]",Zp="[object Float32Array]",Hp="[object Float64Array]",Gp="[object Int8Array]",$p="[object Int16Array]",Xp="[object Int32Array]",Jp="[object Uint8Array]",qp="[object Uint8ClampedArray]",Kp="[object Uint16Array]",_p="[object Uint32Array]",ve={};ve[$o]=ve[jp]=ve[Vp]=ve[Qp]=ve[Ap]=ve[Pp]=ve[Zp]=ve[Hp]=ve[Gp]=ve[$p]=ve[Xp]=ve[Op]=ve[Rp]=ve[Jo]=ve[Wp]=ve[Yp]=ve[Up]=ve[Bp]=ve[Jp]=ve[qp]=ve[Kp]=ve[_p]=!0;ve[zp]=ve[Xo]=ve[Fp]=!1;function ai(r,i,e,t,s,o){var n,a=i&Dp,c=i&Lp,l=i&bp;if(e&&(n=s?e(r,t,s,o):e(r)),n!==void 0)return n;if(!Sp(r))return r;var u=Tp(r);if(u){if(n=mp(r),!a)return dp(r,n)}else{var h=yp(r),d=h==Xo||h==Ep;if(vp(r))return up(r,a);if(h==Jo||h==$o||d&&!s){if(n=c||d?{}:Ip(r),!a)return c?gp(r,hp(n,r)):pp(r,lp(n,r))}else{if(!ve[h])return s?r:{};n=wp(r,h,a)}}o||(o=new rp);var g=o.get(r);if(g)return g;o.set(r,n),Cp(r)?r.forEach(function(m){n.add(ai(m,i,e,m,r,o))}):Np(r)&&r.forEach(function(m,w){n.set(w,ai(m,i,e,w,r,o))});var p=l?c?Mp:fp:c?xp:kp,f=u?void 0:p(r);return ap(f||r,function(m,w){f&&(w=m,m=r[w]),cp(n,w,ai(m,i,e,w,r,o))}),n}var eg=ai,tg=eg,ig=1,sg=4;function og(r){return tg(r,ig|sg)}var ng=og;const Pe=Ut(ng),qo="1.1.18",rg="@netless/appliance-plugin",Js=typeof OffscreenCanvas=="function"?"worker":"mainThread";if(typeof window<"u"){let r=window.__netlessUA||"";r+=` ${rg}@${qo}`,window.__netlessUA=r}const Ie={syncOpt:{interval:300},cdn:{subWorkerUrl:"https://cdn.jsdelivr.net/npm/@netless/appliance-plugin@latest/dist/subWorker.js",fullWorkerUrl:"https://cdn.jsdelivr.net/npm/@netless/appliance-plugin@latest/dist/fullWorker.js"},cursor:{expirationTime:5e3},bufferSize:{full:2e4,sub:600},bezier:{maxDrawCount:1/0,combineUnitTime:300},pencilEraser:{useBitMap:!0,maxImageWidth:1920,maxImageHeight:1920},strokeWidth:{min:1,max:10},textEditor:{showFloatBar:!0,canSelectorSwitch:!0,rightBoundBreak:!1}};function rt(r,i=!0){const e=r.length;if(e<2)return"";let t=r[0],s=r[1];if(e===2)return`M${bt(t)}L${bt(s)}`;let o="";for(let n=2,a=e-1;n<a;n++)t=r[n],s=r[n+1],o+=jt(t,s);return i?`M${jt(r[0],r[1])}Q${bt(r[1])}${jt(r[1],r[2])}T${o}${jt(r[e-1],r[0])}${jt(r[0],r[1])}Z`:`M${bt(r[0])}Q${bt(r[1])}${jt(r[1],r[2])}${r.length>3?"T":""}${o}L${bt(r[e-1])}`}const $e=class $e{constructor(i){M(this,"maxImageWidth",Ie.pencilEraser.maxImageWidth);M(this,"maxImageHeight",Ie.pencilEraser.maxImageHeight);M(this,"syncUnitTime",Ie.syncOpt.interval);M(this,"vNodes");M(this,"drawLayer");M(this,"fullLayer");M(this,"workId");M(this,"isDelete",!1);const{vNodes:e,fullLayer:t,drawLayer:s,workId:o,toolsOpt:n}=i;this.vNodes=e,this.fullLayer=t,this.drawLayer=s,this.workId=o,this.syncUnitTime=n.syncUnitTime||this.syncUnitTime}get baseConsumeResult(){return{workId:this.workId,toolsType:this.toolsType,opt:this.workOptions}}filterSamePoints(i,e=.01){return i.reduce((t,s)=>{const o=t[t.length-1];return(s&&!o||s&&o&&!s.isNear(o,e))&&t.push(s),t},[])}setWorkId(i){this.workId=i}getWorkId(){return this.workId}getWorkOptions(){return this.workOptions}setWorkOptions(i){var s,o,n;this.workOptions=i,this.syncUnitTime=i.syncUnitTime||this.syncUnitTime;const e=(s=this.workId)==null?void 0:s.toString(),t=e&&((o=this.vNodes)==null?void 0:o.get(e))||void 0;e&&t&&(t.opt=i,(n=this.vNodes)==null||n.setInfo(e,t))}updataOptService(i){var s,o;let e;const t=(s=this.workId)==null?void 0:s.toString();if(t&&i){const n=this.fullLayer.getElementsByName(t)||this.drawLayer&&this.drawLayer.getElementsByName(t)||[];if(n.length!==1)return;const a=n[0],{pos:c,zIndex:l,scale:u,angle:h,translate:d}=i,g={};ze(l)&&(g.zIndex=l),c&&(g.pos=[c[0],c[1]]),u&&(g.scale=u),h&&(g.rotate=h),d&&(g.translate=d),a.attr(g);const p=a==null?void 0:a.getBoundingClientRect();return p&&(e=ue(e,{x:Math.floor(p.x-$e.SafeBorderPadding),y:Math.floor(p.y-$e.SafeBorderPadding),w:Math.floor(p.width+$e.SafeBorderPadding*2),h:Math.floor(p.height+$e.SafeBorderPadding*2)})),(o=this.vNodes)==null||o.setInfo(t,{rect:e,centerPos:c}),e}}drawEraserlines(i,e){const{group:t,eraserlines:s,pos:o,layer:n}=i,a=n.parent;if(e)try{const l=(n.renderer.glRenderer||n.renderer.canvasRenderer).options.displayRatio,u=t.getBoundingClientRect(),h=u.width*l*n.worldScaling[0],d=u.height*l*n.worldScaling[1];let g=1;(h>this.maxImageWidth||d>this.maxImageHeight)&&(g=Math.min(this.maxImageWidth/h,this.maxImageHeight/d));let p=n.getAttribute("scale");p=[p[0]*g,p[1]*g];const f=n.parent.parent,m=n.getAttribute("translate"),w=this.createVmRenderNode(`${this.workId}_bitMapLayer`,f,{offscreen:a.offscreen,width:a.width,height:a.height,contextType:"2d",autoRender:!1,bufferSize:500},p,m),I=t.cloneNode(!0);this.addEraserlines(I,s,o,!1),w.appendChild(I);const N=w.parent;N.render();const C=w.renderer.canvasRenderer,S=C.context;if(!S)return;const v=C.options.displayRatio,x=I.getBoundingClientRect(),L={x:x.x,y:x.y,w:x.width,h:x.height},b={x:0,y:0,w:f.width,h:f.height};if(Is(L,b)===Nt.outside){Ve(I,N),f.removeChild(N),this.isDelete=!0;return}const A=Pe(L);A.x=Math.floor(Math.max(L.x,0)),A.y=Math.floor(Math.max(L.y,0)),A.w=Math.min(L.x+L.w,f.width)-A.x,A.h=Math.min(L.y+L.h,f.height)-A.y;const E=this.getGroupRect(A,v),R=E.x,z=E.y,Z=E.w,ee=E.h;let F=S.getImageData(R,z,Z,ee);if(this.isTransparentRectByCanvas(F)){Ve(I,N),f.removeChild(N),this.isDelete=!0,F=null;return}Ve(t,a);const te=this.createSpriteNode({imageData:F,safariRect:A,originRect:L,worldScaling:w.worldScaling});te&&t.append(te),Ve(I,N),f.removeChild(N),a.deleteTexture(F),F=null}catch(c){console.error("[BaseShapeTool] drawEraserlines error:",c);return}}createVmRenderNode(i,e,t,s,o){const{width:n,height:a}=t,c=`bitMap-${i}`,l=e.layer(c,t),u=new he.Group({anchor:[.5,.5],pos:[n*.5,a*.5],size:[n,a],name:"viewport",id:i});return u.setAttribute("scale",s),u.setAttribute("translate",o),l.append(u),u}getGroupRect(i,e){const t=Math.floor(i.x*e),s=Math.floor(i.y*e),o=Math.floor(i.w*e),n=Math.floor(i.h*e);return{x:t,y:s,w:o,h:n}}addEraserlines(i,e,t,s=!0){for(const o of e){const{thickness:n,op:a}=o;for(const c of a){const l=c.map((p,f)=>f%2?p-t[1]:p-t[0]),u=this.computEraserPoints(l,n),h=rt(u,!0),d={pos:[0,0],d:h,fillColor:"rgba(0,0,0,1)"},g=new he.Path(d);g.addEventListener("beforerender",({detail:p})=>{const f=p.context;s?f.blendFuncSeparate(f.ZERO,f.ZERO,f.ZERO,f.ZERO):f.globalCompositeOperation="destination-out"}),g.addEventListener("afterrender",({detail:p})=>{const f=p.context;s?f.blendFuncSeparate(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA,f.ONE,f.ONE_MINUS_SRC_ALPHA):f.globalCompositeOperation="source-over"}),i.append(g)}}}isTransparentRectByCanvas(i){let e=!0;for(let t=0;t<i.data.length;t+=4)if(i.data[t+3]!==0){e=!1;break}return e}createSpriteNode(i){const{imageData:e,worldScaling:t,safariRect:s,originRect:o}=i;let n;if(typeof OffscreenCanvas=="function"){n=new OffscreenCanvas(e.width,e.height);const u=n.getContext("2d");u&&u.putImageData(e,0,0)}else if(typeof document<"u"){n=document.createElement("canvas"),n.width=e.width,n.height=e.height;const u=n.getContext("2d");u&&u.putImageData(e,0,0)}if(!n)return console.warn("Failed to create imageEraserBitmap Sprite"),null;const a=[Math.floor(o.w/t[0]),Math.floor(o.h/t[1])],c=[Math.floor((s.x-o.x)/t[0]),Math.floor((s.y-o.y)/t[1]),Math.floor(s.w/t[0]),Math.floor(s.h/t[1])],l={name:"eraserTexture",anchor:[.5,.5],pos:[0,0],size:a,texture:n,textureRect:c};return new he.Sprite(l)}computEraserPoints(i,e){const t=Math.ceil(e/2);return i.length===2?this.computDot(i,t):this.computLine(i,t)}computDot(i,e){const t=new Q(i[0],i[1]);return Q.GetDotStroke(t,e,8)}computLine(i,e){const t=[],s=[];let o,n;for(let a=0;a<i.length;a+=2){const c=new Q(i[a],i[a+1]);let l;if(a==i.length-2){const u=new Q(i[a-2],i[a-1]);l=k.Sub(c,u).uni(),o=c}else{a===0&&(n=c);const u=new Q(i[a+2],i[a+3]);l=k.Sub(u,c).uni()}if(l){const u=k.Per(l).mul(e);t.push(Q.Sub(c,u)),s.push(Q.Add(c,u))}}if(o&&n){const a=Q.GetSemicircleStroke(o,t[t.length-1],-1,8),c=Q.GetSemicircleStroke(n,s[0],-1,8);return t.concat(a,s.reverse(),c)}return[]}replace(i,e,t){var o;if(!e){t&&i.append(t);return}const s=i.getElementsByName(e);if(s.length)for(const n of s)t?gy(t,n,i):(n.remove(),Ge(n,i.parent));else t&&i.append(t);this.fullLayer!==this.drawLayer&&(this.fullLayer===i?(o=this.drawLayer)==null||o.getElementsByName(e).forEach(a=>{var c;a.remove(),Ge(a,(c=this.drawLayer)==null?void 0:c.parent)}):this.fullLayer.getElementsByName(e).forEach(a=>{a.remove(),Ge(a,this.fullLayer.parent)}))}removeDrawCountNodes(i,e){const t=[];i.getElementsByName(this.workId).forEach(s=>{s.id&&e&&Number(s.id)<e&&t.push(s)});for(const s of t)s.remove(),Ge(s,i.parent)}static updateNodeOpt(i){var I;const{node:e,opt:t,vNodes:s,willSerializeData:o,targetNode:n}=i,{zIndex:a,translate:c,angle:l,originPoint:u,scenePoint:h,scale:d,pointMap:g,thickness:p}=t;let f;const m=n&&Pe(n)||s.get(e.name);if(!m)return;ze(a)&&(e.setAttribute("zIndex",a),m.opt.zIndex=a);const w=e.parent;if(w){if(u&&d&&n){const N=[m.op[0],m.op[1]];ms(m.op,h,d,c);const C=[m.op[0],m.op[1]],S=[C[0]-N[0],C[1]-N[1]];if(m.centerPos=[m.centerPos[0]+S[0],m.centerPos[1]+S[1]],m.opt.translate=void 0,m.opt.scale=void 0,m.opt.eraserlines)for(const v of Object.values(m.opt.eraserlines)){const{op:x,thickness:L}=v;v.thickness=L*Math.max(d[0],d[1]);for(let b=0;b<x.length;b++)ws(x[b],h,d,c)}}else if(c)if(e.setAttribute("translate",c),m.opt.translate=c,n){const N=[c[0]*w.worldScaling[0],c[1]*w.worldScaling[1]];f=_t(m.rect,N),m.rect=f}else{const N=$e.getRectFromLayer(w,e.name);m.rect=N||m.rect}else if(ze(l))if(e.setAttribute("rotate",l),m.opt.rotate=l,n)f=mn(m.rect,l),m.rect=f;else{const N=$e.getRectFromLayer(w,e.name);m.rect=N||m.rect}if(g){const N=g.get(e.name);if(N)for(let C=0,S=0;C<m.op.length;C+=3,S++)m.op[C]=N[S][0],m.op[C+1]=N[S][1]}if(p&&((I=m==null?void 0:m.opt)!=null&&I.thickness)&&(m.opt.thickness=p),o&&!(u&&d&&n)){if(c){const N=m.op.map((C,S)=>{const v=S%3;return v===0?C+c[0]:v===1?C+c[1]:C});if(m.op=N,m.centerPos=[m.centerPos[0]+c[0],m.centerPos[1]+c[1]],m!=null&&m.opt&&(m.opt.translate=void 0),m.opt.eraserlines)for(const C of Object.values(m.opt.eraserlines)){const{op:S}=C;for(let v=0;v<S.length;v++){const x=S[v].map((L,b)=>b%2?L+c[1]:L+c[0]);C.op[v]=x}}}else if(ze(l)){const N=m.op;if(ay(N,m.centerPos,l),m.op=N,m!=null&&m.opt&&(m.opt.rotate=void 0),m.opt.eraserlines)for(const C of Object.values(m.opt.eraserlines)){const{op:S}=C;for(let v=0;v<S.length;v++)cy(S[v],m.centerPos,l)}}}m&&s.setInfo(e.name,m)}}static getCenterPos(i,e){const{worldPosition:t,worldScaling:s}=e;return[(i.x+i.w/2-t[0])/s[0],(i.y+i.h/2-t[1])/s[1]]}static getRectFromLayer(i,e){const t=i.getElementsByName(e)[0];if(t){const s=t.getBoundingClientRect();return{x:Math.floor(s.x-$e.SafeBorderPadding),y:Math.floor(s.y-$e.SafeBorderPadding),w:Math.floor(s.width+$e.SafeBorderPadding*2),h:Math.floor(s.height+$e.SafeBorderPadding*2)}}}static isWillRefresh(i){const{toolsType:e,opt:t,node:s,updateOpt:o,willSerializeData:n}=i;return!!(n&&(o.angle||o.translate)||o.thickness&&t.thickness&&t.thickness!==o.thickness||o.strokeType&&t.strokeType&&t.strokeType!==o.strokeType||o.originPoint&&o.scenePoint&&o.scale||o.pointMap&&o.pointMap.has(s.name)||e===T.Text&&(o.fontSize||o.translate||o.textInfos&&o.textInfos.get(s.name))||e===T.Image&&(o.angle||o.translate||o.scale||o.strokeColor&&o.type===St.Iconify)||e===o.toolsType&&o.willRefresh||t.eraserlines&&t.eraserlines.length&&(o.strokeColor||o.fillColor))}};M($e,"SafeBorderPadding",10);let U=$e;const ds=Object.freeze([Object.freeze({width:18,height:26}),Object.freeze({width:26,height:34}),Object.freeze({width:34,height:50}),Object.freeze({width:48,height:74})]);function Dt(r){return JSON.parse(Io.decompress(r))}function Be(r){return Io.compress(JSON.stringify(r))}const Re=Object.keys;function Ko(r,i,e=.01){return Math.abs(r[0]-i[0])<e&&Math.abs(r[1]-i[1])<e}function ag(r,i=.01){if(r.length===0)return[];const e=[[r[0][0],r[0][1]]];for(let t=1;t<r.length;t++)Ko([r[t][0],r[t][1]],e[e.length-1],i)||e.push([r[t][0],r[t][1]]);return e}function cg(r,i=.01){if(r.length<=2)return r;const e=r[0],t=r[r.length-1];return Ko(e,t,i)?r.slice(0,-1):r}function lg(r){const i=r.reduce((t,s)=>t+s[0],0)/r.length,e=r.reduce((t,s)=>t+s[1],0)/r.length;return[i,e]}function qs(r,i){return Math.atan2(i[1]-r[1],i[0]-r[0])}function hg(r,i=.01){if(r.length<=2)return r;const e=[];for(const s of r)e.some(n=>Math.abs(n[0]-s[0])<i&&Math.abs(n[1]-s[1])<i)||e.push([s[0],s[1]]);const t=lg(e);return e.sort((s,o)=>{const n=qs(t,s),a=qs(t,o);return n-a})}function ug(r,i){const e=i[0].x<i[i.length-1].x;return r.map(s=>{const n=s.map(a=>{let c=-1,l=1/0,u=0;for(let h=0;h<i.length;h++){const d=i[h],g=Math.sqrt(Math.pow(d.x-a[0],2)+Math.pow(d.y-a[1],2));g<l&&(l=g,c=h,u=d.z)}return{point:a,index:c,bestZ:u}}).sort((a,c)=>a.index-c.index).map(a=>[...a.point,a.bestZ]);return e&&n[0][0]>n[n.length-1][0]||!e&&n[0][0]<n[n.length-1][0]?n.reverse():n}).sort((s,o)=>{const n=s[0][0],a=o[0][0];return e?n-a:a-n})}function dg(r,i,e=.01){const s=r.map(h=>[h.x,h.y]),o=(h,d)=>h.map(([g,p])=>({X:Math.round(g*d),Y:Math.round(p*d)})),n=new ot.ClipperOffset;n.AddPath(o(s,1e3),ot.JoinType.jtRound,ot.EndType.etOpenButt);const a=[];n.Execute(a,1);const c=new ot.Clipper;c.AddPaths(a,ot.PolyType.ptSubject,!0),i.forEach(h=>{c.AddPath(o(h,1e3),ot.PolyType.ptClip,!0)});const l=new ot.Paths;c.Execute(ot.ClipType.ctDifference,l,ot.PolyFillType.pftNonZero,ot.PolyFillType.pftNonZero);const u=l.map(h=>cg(hg(ag(h.map(d=>[d.X/1e3,d.Y/1e3]),e),e),e)).filter(h=>h.length>=2);return ug(u,r)}class _o extends U{constructor(e){super(e);M(this,"canRotate",!0);M(this,"scaleType",ce.all);M(this,"toolsType",T.Pencil);M(this,"syncTimestamp");M(this,"syncIndex",0);M(this,"tmpPoints",[]);M(this,"MAX_REPEAR",10);M(this,"uniThickness");M(this,"workOptions");M(this,"centerPos",[0,0]);this.workOptions=e.toolsOpt,this.uniThickness=this.MAX_REPEAR/this.workOptions.thickness/10,this.syncTimestamp=0}combineConsume(){var a;const e=(a=this.workId)==null?void 0:a.toString();if(this.tmpPoints.length<2)return{type:D.None};const t=this.transformDataAll(!0),s={name:e};let o;const n=this.drawLayer||this.fullLayer;return t.length&&(o=this.draw({attrs:s,tasks:t,replaceId:e,layer:n})),{rect:o,type:D.DrawWork,dataType:B.Local}}setWorkOptions(e){super.setWorkOptions(e),this.syncTimestamp=Date.now()}consume(e){const{data:t,isFullWork:s,isSubWorker:o,isMainThread:n,drawCount:a,removeDrawCount:c}=e,{workId:l,syncUnitTime:u}=t;u&&(this.syncUnitTime=u);const{tasks:h,effects:d,consumeIndex:g}=this.transformData(t,!1);this.syncIndex=Math.min(this.syncIndex,g,Math.max(0,this.tmpPoints.length-2));const p={name:l,id:ze(a)&&a.toString()||void 0};let f,m=!1;const w=this.syncIndex;if(this.syncTimestamp===0&&(this.syncTimestamp=Date.now()),h.length&&(h[0].taskId-this.syncTimestamp>this.syncUnitTime&&(m=!0,this.syncTimestamp=h[0].taskId,this.syncIndex=this.tmpPoints.length),o||n)){const N=s?this.fullLayer:this.drawLayer||this.fullLayer;f=this.draw({attrs:p,tasks:h,effects:d,layer:N,removeDrawCount:c})}if(o)return g>10&&this.tmpPoints.splice(0,g-10),{rect:f,type:D.DrawWork,dataType:B.Local};const I=[];return this.tmpPoints.slice(w).forEach(N=>{I.push(N.x,N.y,this.computRadius(N.z,this.workOptions.thickness))}),{...this.baseConsumeResult,type:D.DrawWork,dataType:B.Local,rect:f,op:m?I:void 0,index:m?w*3:void 0,updateNodeOpt:{useAnimation:!0}}}consumeAll(e){var u;const t=this.workId;if(e.data){const{op:h,workState:d}=e.data;h!=null&&h.length&&d===j.Done&&this.workOptions.strokeType===oe.Stroke&&this.updateTempPointsWithPressureWhenDone(h)}const s=this.transformDataAll(!0),o={name:t};let n;const a=this.fullLayer;if(s.length&&(n=this.draw({attrs:o,tasks:s,replaceId:t,layer:a})),this.tmpPoints.length<2)return this.replace(a,t),{type:D.RemoveNode,removeIds:[t],rect:n};const c=[];this.tmpPoints.map(h=>{c.push(h.x,h.y,h.z)}),this.syncTimestamp=0,delete this.workOptions.syncUnitTime;const l=Be(c);return(u=this.vNodes)==null||u.setInfo(t,{rect:n,op:c,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:n&&U.getCenterPos(n,a)}),{...this.baseConsumeResult,rect:n,type:D.FullWork,dataType:B.Local,ops:l,updateNodeOpt:{pos:this.centerPos,useAnimation:!0}}}clearTmpPoints(){this.tmpPoints.length=0,this.syncTimestamp=0,this.syncIndex=0}consumeService(e){var h,d;const{op:t,isFullWork:s,replaceId:o,workState:n=j.Done}=e;this.tmpPoints.length=0;for(let g=0;g<t.length;g+=3){const p=new Q(t[g],t[g+1],t[g+2]);if(this.tmpPoints.length>0){const f=this.tmpPoints[this.tmpPoints.length-1],m=k.Sub(p,f).uni();p.setv(m)}this.tmpPoints.push(p)}if(this.tmpPoints.length<2)return;const a=this.transformDataAll(!0),c=(h=this.workId)==null?void 0:h.toString(),l={name:c};let u;if(c&&a.length){const g=s?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({attrs:l,tasks:a,replaceId:o,layer:g,isDrawEraserlines:n===j.Done}),(d=this.vNodes)==null||d.setInfo(c,{rect:u,op:t,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:u&&U.getCenterPos(u,g)})}return u}computPencilPoints(e){const t=[],{op:s,eraserPolylines:o,eraserThickness:n}=e;this.tmpPoints.length=0;for(let c=0;c<s.length;c+=3){const l=new Q(s[c],s[c+1],s[c+2]);if(this.tmpPoints.length>0){const u=this.tmpPoints[this.tmpPoints.length-1],h=k.Sub(l,u).uni();l.setv(h)}this.tmpPoints.push(l)}if(this.tmpPoints.length<2)return;const a=this.transformDataAll(!0);if(a.length)for(let c=0;c<a.length;c++){const{pos:l,points:u}=a[c],h=u.map(p=>p.point.addXY(l[0],l[1])),d=[];for(const p of o){const f=[];for(let w=0;w<p.length;w+=2){const I=new Q(p[w],p[w+1]);if(f.length>0){const N=f[f.length-1].point,C=k.Sub(I,N).uni();I.setv(C)}f.push({point:I,radius:n})}const{ps:m}=this.computStroke(f,!1);d.push(m.map(w=>w.XY))}dg(h,d,.01).forEach(p=>{t.push(p.map(f=>[f[0],f[1],f[2]]).flat(1))})}return t}transformDataAll(e=!0){const t=this.filterSamePoints(this.tmpPoints,this.workOptions.thickness);return this.getTaskPoints(t,e&&this.workOptions.thickness||void 0)}draw(e){const{attrs:t,tasks:s,replaceId:o,effects:n,layer:a,removeDrawCount:c,isDrawEraserlines:l=!0}=e,{strokeColor:u,strokeType:h,thickness:d,zIndex:g,scale:p,rotate:f,translate:m,eraserlines:w}=this.workOptions;n!=null&&n.size&&(n.forEach(x=>{var L;(L=a.getElementById(x+""))==null||L.remove()}),n.clear()),c&&this.removeDrawCountNodes(a,c);let I;const N=[],C=a.worldPosition,S=a.worldScaling;for(let x=0;x<s.length;x++){const{pos:L,points:b}=s[x],{ps:P,rect:A}=this.computDrawPoints(b);let E;const R=b.length===1;h===oe.Stroke||R?E=rt(P,!0):E=rt(P,!1);const z={pos:L,d:E,fillColor:h===oe.Stroke||R?u:void 0,lineDash:h===oe.Dotted&&!R?[1,d*2]:h===oe.LongDotted&&!R?[d,d*2]:void 0,strokeColor:u,lineCap:h===oe.Stroke||R?void 0:"round",lineWidth:h===oe.Stroke||R?0:d};I=ue(I,{x:Math.floor((A.x+L[0])*S[0]+C[0]-U.SafeBorderPadding),y:Math.floor((A.y+L[1])*S[1]+C[1]-U.SafeBorderPadding),w:Math.floor(A.w*S[0]+2*U.SafeBorderPadding),h:Math.floor(A.h*S[1]+2*U.SafeBorderPadding)}),N.push(z)}p&&(t.scale=p),f&&(t.rotate=f),m&&(t.translate=m);const v=new he.Group;if(I){this.centerPos=U.getCenterPos(I,a);const x=h===oe.Stroke&&!w;v.attr({...t,normalize:!0,anchor:[.5,.5],bgcolor:x?u:void 0,pos:this.centerPos,size:[(I.w-2*U.SafeBorderPadding)/S[0],(I.h-2*U.SafeBorderPadding)/S[1]],zIndex:g});const L=N.map(b=>(b.pos=[b.pos[0]-this.centerPos[0],b.pos[1]-this.centerPos[1]],new he.Path(b)));v.append(...L),x&&v.seal(),w&&(this.scaleType=ce.proportional,this.drawEraserlines({group:v,eraserlines:w,pos:this.centerPos,layer:a},l)),this.replace(a,o,v)}if(p||f||m){const x=v==null?void 0:v.getBoundingClientRect();x&&(I={x:Math.floor(x.x-U.SafeBorderPadding),y:Math.floor(x.y-U.SafeBorderPadding),w:Math.floor(x.width+U.SafeBorderPadding*2),h:Math.floor(x.height+U.SafeBorderPadding*2)})}return this.isDelete&&v.setAttribute("opacity",0),I}computDrawPoints(e){return this.workOptions.strokeType===oe.Stroke||e.length===1?this.computStroke(e):this.computNomal(e)}computNomal(e){let t=this.workOptions.thickness;const s=e.map(o=>(t=Math.max(t,o.radius),o.point));return{ps:s,rect:Me(s,t)}}computStroke(e,t=!0){return e.length===1?this.computDotStroke(e[0]):this.computLineStroke(e,t)}computLineStroke(e,t=!0){const s=[],o=[];for(let c=0;c<e.length;c++){const{point:l,radius:u}=e[c];let h=l.v;c===0&&e.length>1&&(h=e[c+1].point.v);const d=k.Per(h).mul(u);s.push(Q.Sub(l,d)),o.push(Q.Add(l,d))}const n=e[e.length-1];if(t){const c=Q.GetSemicircleStroke(n.point,s[s.length-1],-1,8),l=Q.GetSemicircleStroke(e[0].point,o[0],-1,8),u=s.concat(c,o.reverse(),l);return{ps:u,rect:Me(u)}}const a=s.concat(o.reverse());return{ps:a,rect:Me(a)}}computDotStroke(e){const{point:t,radius:s}=e,o={x:t.x-s,y:t.y-s,w:s*2,h:s*2};return{ps:Q.GetDotStroke(t,s,8),rect:o}}transformData(e,t){const{op:s,workState:o}=e;let n=this.tmpPoints.length-1,a=[];if(s!=null&&s.length&&o){const{strokeType:c,thickness:l}=this.workOptions,u=new Set;n=c===oe.Stroke?this.updateTempPointsWithPressure(s,l,u):this.updateTempPoints(s,l,u);const h=t?this.tmpPoints:this.tmpPoints.slice(n);return a=this.getTaskPoints(h,l),{tasks:a,effects:u,consumeIndex:n}}return{tasks:a,consumeIndex:n}}computRadius(e,t){return e*.03*t+t*.5}getMinZ(e,t){return((t||Math.max(1,Math.floor(e*.3)))-e*.5)*100/e/3}getTaskPoints(e,t){var h;const s=[];if(e.length===0)return[];let o=0,n=e[0].x,a=e[0].y,c=[n,a],l=[],u=e[0].t;for(;o<e.length;){const d=e[o],g=d.x-n,p=d.y-a,f=d.z,m=t?this.computRadius(f,t):f;if(l.push({point:new Q(g,p,f,e[o].v),radius:m}),o>0&&o<e.length-1){const w=e[o].getAngleByPoints(e[o-1],e[o+1]);if(w<60||w>300){const I=(h=l.pop())==null?void 0:h.point.clone();I&&s.push({taskId:u,pos:c,points:[...l,{point:I,radius:m}]}),n=e[o].x,a=e[o].y,c=[n,a];const N=d.x-n,C=d.y-a;l=[{point:new Q(N,C,f),radius:m}],u=Date.now()}}o++}return s.push({taskId:u,pos:c,points:l}),s}updateTempPointsWithPressure(e,t,s){const o=Date.now(),n=this.tmpPoints.length;let a=n;for(let l=0;l<e.length;l+=2){a=Math.min(a,n);const u=this.tmpPoints.length,h=new Q(e[l],e[l+1]);if(u===0){this.tmpPoints.push(h);continue}const d=u-1,g=this.tmpPoints[d],p=k.Sub(h,g).uni();if(h.isNear(g,t)){if(g.z<this.MAX_REPEAR){if(g.setz(Math.min(g.z+1,this.MAX_REPEAR)),a=Math.min(a,d),u>1){let w=u-1;for(;w>0;){const I=this.tmpPoints[w].distance(this.tmpPoints[w-1]),N=Math.max(this.tmpPoints[w].z-this.uniThickness*I,0);if(this.tmpPoints[w-1].z>=N)break;this.tmpPoints[w-1].setz(N),a=Math.min(a,w-1),w--}}}else a=1/0;continue}h.setv(p);const f=h.distance(g),m=Math.max(g.z-this.uniThickness*f,0);u>1&&k.Equals(p,g.v,.02)&&(m>0||g.z<=0)&&(s&&g.t&&s.add(g.t),this.tmpPoints.pop(),a=Math.min(d,a)),h.setz(m),this.tmpPoints.push(h)}if(a===1/0)return this.tmpPoints.length;let c=n;if(a===n){c=Math.max(c-1,0);const l=this.tmpPoints[c].t;l&&(s==null||s.add(l))}else{let l=n-1;for(c=a;l>=0;){const u=this.tmpPoints[l].t;if(u&&(s==null||s.add(u),l<=a)){c=l,l=-1;break}l--}}return this.tmpPoints[c].setT(o),c}updateTempPoints(e,t,s){var l;const o=Date.now(),n=this.tmpPoints.length;let a=n;for(let u=0;u<e.length;u+=2){const h=this.tmpPoints.length,d=new Q(e[u],e[u+1]);if(h===0){this.tmpPoints.push(d);continue}const g=h-1,p=this.tmpPoints[g],f=k.Sub(d,p).uni();if(d.isNear(p,t/2)){a=Math.min(g,a);continue}k.Equals(f,p.v,.02)&&(s&&p.t&&s.add(p.t),this.tmpPoints.pop(),a=Math.min(g,a)),d.setv(f),this.tmpPoints.push(d)}let c=n;if(a===n){c=Math.max(c-1,0);const u=this.tmpPoints[c].t;u&&(s==null||s.add(u))}else{let u=Math.min(n-1,a);for(c=a;u>=0;){const h=(l=this.tmpPoints[u])==null?void 0:l.t;if(h&&(s==null||s.add(h),u<=a)){c=u,u=-1;break}u--}}return this.tmpPoints[c].setT(o),c}updateTempPointsWithPressureWhenDone(e){const{thickness:t}=this.workOptions,s=e.length,o=this.getMinZ(t);for(let n=0;n<s;n+=2){const a=this.tmpPoints.length,c=new Q(e[n],e[n+1]);if(a===0){this.tmpPoints.push(c);continue}const l=a-1,u=this.tmpPoints[l],h=k.Sub(c,u).uni(),d=c.distance(u);if(a>1&&u.z===o)break;if(c.isNear(u,t/2)){if(s<3&&u.z<this.MAX_REPEAR&&(u.setz(Math.min(u.z+1,this.MAX_REPEAR)),a>1)){let p=a-1;for(;p>0;){const f=this.tmpPoints[p].distance(this.tmpPoints[p-1]),m=Math.max(this.tmpPoints[p].z-this.uniThickness*f,-t/4);if(this.tmpPoints[p-1].z>=m)break;this.tmpPoints[p-1].setz(m),p--}}continue}c.setv(h);const g=Math.max(u.z-this.uniThickness*d,o);a>1&&k.Equals(h,u.v,.02)&&u.z<=0&&this.tmpPoints.pop(),c.setz(g),this.tmpPoints.push(c)}}static updateNodeOpt(e){var l,u;const{node:t,opt:s,vNodes:o}=e,{strokeColor:n,strokeType:a}=s,c=o.get(t.name);return n&&(t.tagName==="GROUP"?py(t)?t.setAttribute("bgcolor",n):t.children.forEach(h=>{h.setAttribute("strokeColor",n),h.getAttribute("fillColor")&&h.setAttribute("fillColor",n)}):(t.setAttribute("strokeColor",n),t.setAttribute("fillColor",n)),(l=c==null?void 0:c.opt)!=null&&l.strokeColor&&(c.opt.strokeColor=n)),a&&(c!=null&&c.opt)&&((u=c.opt)!=null&&u.strokeType)&&(c.opt.strokeType=a),c&&o.setInfo(t.name,c),U.updateNodeOpt(e)}}class en extends U{constructor(e){super(e);M(this,"toolsType",T.LaserPen);M(this,"canRotate",!1);M(this,"scaleType",ce.none);M(this,"syncTimestamp");M(this,"syncIndex",0);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"consumeIndex",0);this.workOptions=e.toolsOpt,this.syncTimestamp=0}combineConsume(){}setWorkOptions(e){super.setWorkOptions(e),this.syncTimestamp=Date.now()}consume(e){const{data:t,isSubWorker:s}=e,{workId:o,op:n,syncUnitTime:a}=t;if((n==null?void 0:n.length)===0)return{type:D.None};if(a&&(this.syncUnitTime=a),this.updateTempPoints(n||[]),this.consumeIndex>this.tmpPoints.length-4)return{type:D.None};const{strokeColor:c,thickness:l,strokeType:u}=this.workOptions,h=Me(this.tmpPoints,l);let d=!1;const g=this.syncIndex,p=this.tmpPoints.slice(this.consumeIndex);this.consumeIndex=this.tmpPoints.length-1,this.syncTimestamp===0&&(this.syncTimestamp=Date.now());const f={name:o==null?void 0:o.toString(),opacity:1,lineDash:u===oe.Dotted?[1,l*2]:u===oe.LongDotted?[l,l*2]:void 0,strokeColor:c,lineCap:"round",lineWidth:l,anchor:[.5,.5]},m=this.getTaskPoints(p);if(m.length){const I=Date.now();I-this.syncTimestamp>this.syncUnitTime&&(d=!0,this.syncTimestamp=I,this.syncIndex=this.tmpPoints.length),s&&this.draw({attrs:f,tasks:m,isDot:!1,layer:this.drawLayer||this.fullLayer})}const w=[];return this.tmpPoints.slice(g).forEach(I=>{w.push(I.x,I.y)}),{rect:{x:h.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:h.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:h.w*this.fullLayer.worldScaling[0],h:h.h*this.fullLayer.worldScaling[1]},type:D.DrawWork,dataType:B.Local,op:d?w:void 0,index:d?g*2:void 0,...this.baseConsumeResult}}consumeAll(){var n;const e=(n=this.workId)==null?void 0:n.toString();let t;if(this.tmpPoints.length-1>this.consumeIndex){let a=this.tmpPoints.slice(this.consumeIndex);const c=a.length===1,{strokeColor:l,thickness:u,strokeType:h}=this.workOptions;if(c){const p=this.computDotStroke({point:a[0],radius:u/2});a=p.ps,t=p.rect}else t=Me(this.tmpPoints,u);const d={name:e==null?void 0:e.toString(),fillColor:c?l:void 0,opacity:1,lineDash:h===oe.Dotted&&!c?[1,u*2]:h===oe.LongDotted&&!c?[u,u*2]:void 0,strokeColor:l,lineCap:c?void 0:"round",lineWidth:c?0:u,anchor:[.5,.5]},g=this.getTaskPoints(a);g.length&&this.draw({attrs:d,tasks:g,isDot:c,layer:this.drawLayer||this.fullLayer})}const s=[];this.tmpPoints.forEach(a=>{s.push(a.x,a.y)});const o=Be(s);return{rect:t&&{x:t.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:t.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:t.w*this.fullLayer.worldScaling[0],h:t.h*this.fullLayer.worldScaling[1]},type:D.FullWork,dataType:B.Local,ops:o,index:this.syncIndex*2,...this.baseConsumeResult}}clearTmpPoints(){this.tmpPoints.length=0,this.syncTimestamp=0,this.syncIndex=0}consumeService(e){var f;const{op:t,replaceId:s,isFullWork:o}=e,{strokeColor:n,thickness:a,strokeType:c}=this.workOptions;if(!t.length){const m=Me(this.tmpPoints,a);return{x:m.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:m.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:m.w*this.fullLayer.worldScaling[0],h:m.h*this.fullLayer.worldScaling[1]}}const l=Math.max(0,this.tmpPoints.length-1);this.updateTempPoints(t||[]);let u,h=this.tmpPoints.slice(l);const d=h.length===1;if(d){const m=this.computDotStroke({point:h[0],radius:a/2});h=m.ps,u=m.rect}else u=Me(this.tmpPoints,a);const g={name:(f=this.workId)==null?void 0:f.toString(),fillColor:d?n:void 0,opacity:1,lineDash:c===oe.Dotted&&!d?[1,a*2]:c===oe.LongDotted&&!d?[a,a*2]:void 0,strokeColor:n,lineCap:d?void 0:"round",lineWidth:d?0:a,anchor:[.5,.5]},p=this.getTaskPoints(h);if(p.length){const m=o?this.fullLayer:this.drawLayer||this.fullLayer;this.draw({attrs:g,tasks:p,isDot:d,replaceId:s,layer:m})}return{x:u.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:u.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:u.w*this.fullLayer.worldScaling[0],h:u.h*this.fullLayer.worldScaling[1]}}computDotStroke(e){const{point:t,radius:s}=e,o={x:t.x-s,y:t.y-s,w:s*2,h:s*2};return{ps:Q.GetDotStroke(t,s,8),rect:o}}updateTempPoints(e){const t=this.tmpPoints.length;for(let s=0;s<e.length;s+=2){if(t){const o=this.tmpPoints.slice(-1)[0];o&&o.x===e[s]&&o.y===e[s+1]&&this.tmpPoints.pop()}this.tmpPoints.push(new Q(e[s],e[s+1]))}}async draw(e){const{attrs:t,tasks:s,isDot:o,layer:n}=e,{duration:a}=this.workOptions;for(const c of s){const l=new he.Path,{pos:u,points:h}=c;let d;o?d=rt(h,!0):d=rt(h,!1),l.attr({...t,pos:u,d});const{vertex:g,fragment:p}=this.workOptions;if(g&&p){const f=n.renderer.createProgram({vertex:g,fragment:p}),{width:m,height:w}=n.getResolution();l.setUniforms({u_time:0,u_resolution:[m,w]}),l.setProgram(f)}n.appendChild(l),l.transition(a).attr({scale:o?[.1,.1]:[1,1],lineWidth:o?0:1}).then(()=>{l.remove()})}}getTaskPoints(e){var l;const t=[];if(e.length===0)return[];let s=0,o=e[0].x,n=e[0].y,a=[o,n],c=[];for(;s<e.length;){const u=e[s],h=u.x-o,d=u.y-n;if(c.push(new Q(h,d)),s>0&&s<e.length-1){const g=e[s].getAngleByPoints(e[s-1],e[s+1]);if(g<60||g>300){const p=(l=c.pop())==null?void 0:l.clone();p&&t.push({pos:a,points:[...c,p]}),o=e[s].x,n=e[s].y,a=[o,n];const f=u.x-o,m=u.y-n;c=[new Q(f,m)]}}s++}return t.push({pos:a,points:c}),t}removeLocal(){}removeService(e){let t;const s=[];return this.fullLayer.getElementsByName(e).forEach(o=>{if(o.name===e){const n=o.getBoundingClientRect();t=ue(t,{x:n.x,y:n.y,w:n.width,h:n.height}),s.push(o)}}),s.length&&s.forEach(o=>o.remove()),t}}const zt=class zt extends U{constructor(e,t){super(e);M(this,"canRotate",!1);M(this,"scaleType",ce.none);M(this,"toolsType",T.Eraser);M(this,"serviceWork");M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"worldPosition");M(this,"worldScaling");M(this,"eraserRect");M(this,"eraserPolyline");this.serviceWork=t,this.workOptions=e.toolsOpt,this.worldPosition=this.fullLayer.worldPosition,this.worldScaling=this.fullLayer.worldScaling}combineConsume(){}consumeService(){}setWorkOptions(e){super.setWorkOptions(e)}createEraserRect(e){const t=e[0]*this.worldScaling[0]+this.worldPosition[0],s=e[1]*this.worldScaling[1]+this.worldPosition[1],{width:o,height:n}=zt.eraserSizes[this.workOptions.thickness];this.eraserRect={x:t-o*.5,y:s-n*.5,w:o,h:n},this.eraserPolyline=[this.eraserRect.x,this.eraserRect.y,this.eraserRect.x+this.eraserRect.w,this.eraserRect.y+this.eraserRect.h]}computRectCenterPoints(){const e=this.tmpPoints.slice(-2);if(this.tmpPoints.length===4){const t=new k(this.tmpPoints[0],this.tmpPoints[1]),s=new k(this.tmpPoints[2],this.tmpPoints[3]),o=k.Sub(s,t).uni(),n=k.Dist(t,s),{width:a,height:c}=zt.eraserSizes[this.workOptions.thickness],l=Math.min(a,c),u=Math.round(n/l);if(u>1){const h=[];for(let d=0;d<u;d++){const g=k.Mul(o,d*l);h.push(this.tmpPoints[0]+g.x,this.tmpPoints[1]+g.y)}return h.concat(e)}}return e}isNear(e,t){const s=new k(e[0],e[1]),o=new k(t[0],t[1]),{width:n,height:a}=zt.eraserSizes[this.workOptions.thickness];return k.Dist(s,o)<Math.hypot(n,a)*.5}remove(e){const{curNodeMap:t,removeIds:s}=e;let o;for(const n of t.values())if(n.rect&&this.eraserRect&&this.eraserPolyline&&$i(this.eraserRect,n.rect)){const{op:a}=n,c=[],l=[];for(let h=0;h<a.length;h+=3){const d=new k(a[h]*this.worldScaling[0]+this.worldPosition[0],a[h+1]*this.worldScaling[1]+this.worldPosition[1],a[h+2]);l.push(d),c.push(new Q(d.x,d.y))}const u=c.length&&Me(c)||n.rect;$i(u,this.eraserRect)&&(l.length>1?es.polyline(l.map(d=>d.XY),this.eraserPolyline).length&&s.add(n.name):s.add(n.name),o=ue(o,n.rect||u))}return s.forEach(n=>{var c;const a=this.fullLayer.getElementsByName(n);a[0]&&(a[0].remove(),Ge(a[0],this.fullLayer.parent),(c=this.vNodes)==null||c.delete(n))}),o&&(o.x-=U.SafeBorderPadding,o.y-=U.SafeBorderPadding,o.w+=U.SafeBorderPadding*2,o.h+=U.SafeBorderPadding*2),o}consume(e){const{op:t,disableEraseImage:s,disableEraseText:o}=e.data;if(!t||t.length===0)return{type:D.None,...this.baseConsumeResult};const n=this.tmpPoints.length;if(n>1&&this.isNear([t[0],t[1]],[this.tmpPoints[n-2],this.tmpPoints[n-1]]))return{type:D.None,...this.baseConsumeResult};n<3?this.tmpPoints.push(t[0],t[1]):this.tmpPoints.splice(2,2,t[0],t[1]);const a=this.computRectCenterPoints();let c;const l=new Set;if(!this.vNodes)return{type:D.None,...this.baseConsumeResult};const u=this.getCanEraserNodeMap(this.vNodes.getCanEraserNodes(this.vNodes.curNodeMap,{disableEraseImage:s,disableEraseText:o}));for(let h=0;h<a.length-1;h+=2){this.createEraserRect(a.slice(h,h+2));const d=this.remove({curNodeMap:u,removeIds:l});c=ue(c,d)}return c&&l.size?{type:D.RemoveNode,rect:c,removeIds:[...l]}:{type:D.None,...this.baseConsumeResult}}consumeAll(e){return this.consume(e)}clearTmpPoints(){this.tmpPoints.length=0}getCanEraserNodeMap(e){var t;if(this.serviceWork){const s=new Map(e),o=this.serviceWork.selectorWorkShapes,n=this.serviceWork.workShapes;for(const a of o.values())if((t=a.selectIds)!=null&&t.length)for(const c of a.selectIds)s.delete(c);for(const a of n.keys())s.delete(a);return s}return e}};M(zt,"eraserSizes",ds);let di=zt;const He="++",G="selector",ci="all";var pg="__lodash_hash_undefined__";function gg(r){return this.__data__.set(r,pg),this}var fg=gg;function Mg(r){return this.__data__.has(r)}var yg=Mg,mg=xo,wg=fg,Ig=yg;function pi(r){var i=-1,e=r==null?0:r.length;for(this.__data__=new mg;++i<e;)this.add(r[i])}pi.prototype.add=pi.prototype.push=wg;pi.prototype.has=Ig;var ps=pi;function Tg(r,i){for(var e=-1,t=r==null?0:r.length;++e<t;)if(i(r[e],e,r))return!0;return!1}var vg=Tg;function Ng(r,i){return r.has(i)}var gs=Ng,Sg=ps,Cg=vg,kg=gs,xg=1,Dg=2;function Lg(r,i,e,t,s,o){var n=e&xg,a=r.length,c=i.length;if(a!=c&&!(n&&c>a))return!1;var l=o.get(r),u=o.get(i);if(l&&u)return l==i&&u==r;var h=-1,d=!0,g=e&Dg?new Sg:void 0;for(o.set(r,i),o.set(i,r);++h<a;){var p=r[h],f=i[h];if(t)var m=n?t(f,p,h,i,r,o):t(p,f,h,r,i,o);if(m!==void 0){if(m)continue;d=!1;break}if(g){if(!Cg(i,function(w,I){if(!kg(g,I)&&(p===w||s(p,w,e,t,o)))return g.push(I)})){d=!1;break}}else if(!(p===f||s(p,f,e,t,o))){d=!1;break}}return o.delete(r),o.delete(i),d}var tn=Lg;function bg(r){var i=-1,e=Array(r.size);return r.forEach(function(t,s){e[++i]=[s,t]}),e}var jg=bg;function Ag(r){var i=-1,e=Array(r.size);return r.forEach(function(t){e[++i]=t}),e}var fs=Ag,Ks=ei,_s=Ho,Pg=ts,zg=tn,Eg=jg,Og=fs,Rg=1,Wg=2,Yg="[object Boolean]",Ug="[object Date]",Bg="[object Error]",Fg="[object Map]",Vg="[object Number]",Qg="[object RegExp]",Zg="[object Set]",Hg="[object String]",Gg="[object Symbol]",$g="[object ArrayBuffer]",Xg="[object DataView]",eo=Ks?Ks.prototype:void 0,Ei=eo?eo.valueOf:void 0;function Jg(r,i,e,t,s,o,n){switch(e){case Xg:if(r.byteLength!=i.byteLength||r.byteOffset!=i.byteOffset)return!1;r=r.buffer,i=i.buffer;case $g:return!(r.byteLength!=i.byteLength||!o(new _s(r),new _s(i)));case Yg:case Ug:case Vg:return Pg(+r,+i);case Bg:return r.name==i.name&&r.message==i.message;case Qg:case Hg:return r==i+"";case Fg:var a=Eg;case Zg:var c=t&Rg;if(a||(a=Og),r.size!=i.size&&!c)return!1;var l=n.get(r);if(l)return l==i;t|=Wg,n.set(r,i);var u=zg(a(r),a(i),t,s,o,n);return n.delete(r),u;case Gg:if(Ei)return Ei.call(r)==Ei.call(i)}return!1}var qg=Jg,to=Vo,Kg=1,_g=Object.prototype,ef=_g.hasOwnProperty;function tf(r,i,e,t,s,o){var n=e&Kg,a=to(r),c=a.length,l=to(i),u=l.length;if(c!=u&&!n)return!1;for(var h=c;h--;){var d=a[h];if(!(n?d in i:ef.call(i,d)))return!1}var g=o.get(r),p=o.get(i);if(g&&p)return g==i&&p==r;var f=!0;o.set(r,i),o.set(i,r);for(var m=n;++h<c;){d=a[h];var w=r[d],I=i[d];if(t)var N=n?t(I,w,d,i,r,o):t(w,I,d,r,i,o);if(!(N===void 0?w===I||s(w,I,e,t,o):N)){f=!1;break}m||(m=d=="constructor")}if(f&&!m){var C=r.constructor,S=i.constructor;C!=S&&"constructor"in r&&"constructor"in i&&!(typeof C=="function"&&C instanceof C&&typeof S=="function"&&S instanceof S)&&(f=!1)}return o.delete(r),o.delete(i),f}var sf=tf,Oi=Do,of=tn,nf=qg,rf=sf,io=Li,so=ti,oo=ss,af=Eo,cf=1,no="[object Arguments]",ro="[object Array]",ni="[object Object]",lf=Object.prototype,ao=lf.hasOwnProperty;function hf(r,i,e,t,s,o){var n=so(r),a=so(i),c=n?ro:io(r),l=a?ro:io(i);c=c==no?ni:c,l=l==no?ni:l;var u=c==ni,h=l==ni,d=c==l;if(d&&oo(r)){if(!oo(i))return!1;n=!0,u=!1}if(d&&!u)return o||(o=new Oi),n||af(r)?of(r,i,e,t,s,o):nf(r,i,c,e,t,s,o);if(!(e&cf)){var g=u&&ao.call(r,"__wrapped__"),p=h&&ao.call(i,"__wrapped__");if(g||p){var f=g?r.value():r,m=p?i.value():i;return o||(o=new Oi),s(f,m,e,t,o)}}return d?(o||(o=new Oi),rf(r,i,e,t,s,o)):!1}var uf=hf,df=uf,co=at;function sn(r,i,e,t,s){return r===i?!0:r==null||i==null||!co(r)&&!co(i)?r!==r&&i!==i:df(r,i,e,t,sn,s)}var pf=sn,gf=pf;function ff(r,i){return gf(r,i)}var Mf=ff;const lt=Ut(Mf);function ii(r,i,e){return"#"+((r<<16)+(i<<8)+e).toString(16).padStart(6,"0")}function je(r,i=1){return"rgba("+parseInt("0x"+r.slice(1,3))+","+parseInt("0x"+r.slice(3,5))+","+parseInt("0x"+r.slice(5,7))+","+i+")"}function gt(r,i,e,t=1){return`rgba(${r},${i},${e},${t})`}function bi(r){const i=r.split(","),e=parseInt(i[0].split("(")[1]),t=parseInt(i[1]),s=parseInt(i[2]),o=Number(i[3].split(")")[0]);return[ii(e,t,s),o]}function Xt(r){const i=r.split(","),e=parseInt(i[0].split("(")[1]),t=parseInt(i[1]),s=parseInt(i[2]),o=Number(i[3].split(")")[0]);return[e,t,s,o]}function ri(r){return r==="transparent"}const Ii=class Ii extends U{constructor(e){super(e);M(this,"toolsType",T.Selector);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"vNodes");M(this,"selectIds");M(this,"selectorColor");M(this,"strokeColor");M(this,"fillColor");M(this,"oldSelectRect");M(this,"canRotate",!1);M(this,"canTextEdit",!1);M(this,"canLock",!1);M(this,"scaleType",ce.all);M(this,"toolsTypes");M(this,"shapeOpt");M(this,"textOpt");M(this,"isLocked");M(this,"thickness");M(this,"strokeType");M(this,"useStroke");this.workOptions=e.toolsOpt,this.vNodes=e.vNodes}computSelector(e=!0){const t=Me(this.tmpPoints);if(t.w===0||t.h===0)return{selectIds:[],intersectRect:void 0,subNodeMap:new Map};const{rectRange:s,nodeRange:o}=this.vNodes.getRectIntersectRange(t,e);return{selectIds:[...o.keys()],intersectRect:s,subNodeMap:o}}updateTempPoints(e){const t=this.tmpPoints.length,s=e.length;if(s>1){const o=new Q(e[s-2]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],e[s-1]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[1]);t===2?this.tmpPoints.splice(1,1,o):this.tmpPoints.push(o)}}drawSelector(e){const{drawRect:t,subNodeMap:s,selectorId:o,layer:n,isService:a}=e,c=new he.Group({pos:[t.x,t.y],anchor:[0,0],size:[t.w,t.h],id:o,name:o,zIndex:9999}),l=[];if(a){const u=new he.Rect({normalize:!0,pos:[t.w/2,t.h/2],lineWidth:1,strokeColor:this.selectorColor||this.workOptions.strokeColor,width:t.w,height:t.h,name:Ii.selectorBorderId});l.push(u)}s.forEach((u,h)=>{const d=[u.rect.x+u.rect.w/2-t.x,u.rect.y+u.rect.h/2-t.y],g=new he.Rect({normalize:!0,pos:d,lineWidth:1,strokeColor:s.size>1?this.selectorColor||this.workOptions.strokeColor:void 0,width:u.rect.w,height:u.rect.h,id:`selector-${h}`,name:`selector-${h}`});l.push(g)}),l&&c.append(...l),(n==null?void 0:n.parent).appendChild(c)}draw(e,t,s,o=!1){var c,l;const{intersectRect:n,subNodeMap:a}=s;(l=(c=t.parent)==null?void 0:c.getElementById(e))==null||l.remove(),n&&this.drawSelector({drawRect:n,subNodeMap:a,selectorId:e,layer:t,isService:o})}getSelecteorInfo(e){this.scaleType=ce.all,this.canRotate=!1,this.textOpt=void 0,this.strokeColor=void 0,this.fillColor=void 0,this.canTextEdit=!1,this.canLock=!1,this.isLocked=!1,this.toolsTypes=void 0,this.shapeOpt=void 0,this.thickness=void 0,this.strokeType=void 0,this.useStroke=!1;const t=new Set;let s,o=!0;for(const n of e.values()){const{opt:a,canRotate:c,scaleType:l,toolsType:u}=n;this.selectorColor=this.workOptions.strokeColor,a.strokeColor&&(this.strokeColor=a.strokeColor),a.fillColor&&(this.fillColor=a.fillColor),a.textOpt&&(this.textOpt=a.textOpt),a.thickness&&(this.thickness=a.thickness),u!==T.Pencil&&(o=!1),a.strokeType&&(this.strokeType=a.strokeType),u===T.SpeechBalloon&&(t.add(u),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.placement=a.placement),u===T.Polygon&&(t.add(u),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=a.vertices),u===T.Star&&(t.add(u),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=a.vertices,this.shapeOpt.innerRatio=a.innerRatio,this.shapeOpt.innerVerticeStep=a.innerVerticeStep),u===T.Text&&(this.textOpt=a),e.size===1&&(this.textOpt&&(this.canTextEdit=!0),this.canRotate=c,this.scaleType=l),u===T.Image&&(s=n),(l===ce.proportional&&this.scaleType!==ce.none||l===ce.none)&&(this.scaleType=l)}o&&(this.useStroke=!0),t.size&&(this.toolsTypes=[...t]),s&&(e.size===1?(this.canLock=!0,s.opt.locked&&(this.isLocked=!0,this.scaleType=ce.none,this.canRotate=!1,this.textOpt=void 0,this.fillColor=void 0,this.selectorColor="rgb(177,177,177)",this.strokeColor=void 0,this.canTextEdit=!1,this.thickness=void 0,this.strokeType=void 0,this.useStroke=void 0)):e.size>1&&!s.opt.locked&&(this.canLock=!1,this.canRotate=!1))}getChildrenPoints(){var e,t;if(this.scaleType===ce.both&&((e=this.selectIds)==null?void 0:e.length)===1){const s=this.selectIds[0],o=(t=this.vNodes.get(s))==null?void 0:t.op;if(o){const n=[];for(let a=0;a<o.length;a+=3)n.push([o[a],o[a+1]]);return n}}}consume(e){if(e.isSubWorker)return this.subWorkerConsume(e);const{op:t,workState:s}=e.data;let o=this.oldSelectRect;if(s===j.Start&&(o=this.unSelectedAllIds()),!(t!=null&&t.length)||!this.vNodes.curNodeMap.size)return{type:D.None};this.updateTempPoints(t);const n=this.computSelector();if(this.selectIds&&lt(this.selectIds,n.selectIds))return{type:D.None};this.selectIds=n.selectIds;const a=n.intersectRect;this.getSelecteorInfo(n.subNodeMap),this.draw(G,this.fullLayer,n),this.oldSelectRect=a;const c=this.getChildrenPoints();return{type:D.Select,dataType:B.Local,rect:ue(a,o),selectIds:n.selectIds,selectRect:a,selectorColor:this.selectorColor,strokeColor:this.strokeColor,fillColor:this.fillColor,textOpt:this.textOpt,canTextEdit:this.canTextEdit,canRotate:this.canRotate,canLock:this.canLock,scaleType:this.scaleType,willSyncService:!0,points:c,isLocked:this.isLocked,toolsTypes:this.toolsTypes,shapeOpt:this.shapeOpt,thickness:this.thickness,useStroke:this.useStroke,strokeType:this.strokeType,...this.baseConsumeResult}}consumeAll(){var t,s;let e=this.oldSelectRect;if(!((t=this.selectIds)!=null&&t.length)&&this.tmpPoints[0]&&this.selectSingleTool(this.tmpPoints[0].XY,G,!1),(s=this.selectIds)!=null&&s.length&&(e=this.selectedByIds(this.selectIds)),e){const o=this.getChildrenPoints();return{type:D.Select,dataType:B.Local,rect:this.oldSelectRect,selectIds:this.selectIds,selectorColor:this.selectorColor,selectRect:this.oldSelectRect,strokeColor:this.strokeColor,fillColor:this.fillColor,textOpt:this.textOpt,canTextEdit:this.canTextEdit,canRotate:this.canRotate,canLock:this.canLock,scaleType:this.scaleType,willSyncService:!0,points:o,isLocked:this.isLocked,toolsTypes:this.toolsTypes,shapeOpt:this.shapeOpt,thickness:this.thickness,useStroke:this.useStroke,strokeType:this.strokeType,...this.baseConsumeResult}}return{type:D.None}}consumeService(){}updateTempPointsForSubWorker(e){const t=e.slice(-2),s=new Q(t[0],t[1]);if(this.tmpPoints[0].isNear(s,1))return!1;if(this.tmpPoints.length===2){if(s.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=s}else this.tmpPoints.push(s);return!0}computDrawPoints(e){const{thickness:t}=this.workOptions,s=[];for(const a of e)s.push(new k(...a));const o=Me(s,t),n=[o.x+o.w/2,o.y+o.h/2];return{rect:o,pos:n,points:s.map(a=>a.XY).flat(1)}}drawForSubWorker(e){const{workId:t,layer:s,ps:o}=e,{strokeColor:n,scale:a,rotate:c,translate:l}=this.workOptions,u=s.worldPosition,h=s.worldScaling,{points:d,rect:g,pos:p}=this.computDrawPoints(o),f=1/s.worldScaling[0],m=n&&Xt(n)||[0,0,0,0],w={close:!0,normalize:!0,points:d,lineWidth:f,fillColor:gt(m[0],m[1],m[2],.1),strokeColor:gt(m[0],m[1],m[2],1),lineJoin:"round",lineCap:"round"};let I={x:Math.floor(g.x*h[0]+u[0]-U.SafeBorderPadding),y:Math.floor(g.y*h[1]+u[1]-U.SafeBorderPadding),w:Math.floor(g.w*h[0]+2*U.SafeBorderPadding),h:Math.floor(g.h*h[0]+2*U.SafeBorderPadding)};const N=new he.Group({name:t,id:t,pos:p,anchor:[.5,.5],size:[g.w,g.h],scale:a,rotate:c,translate:l}),C=new he.Polyline({...w,pos:[0,0]});if(N.appendChild(C),this.replace(s,t,N),a||c||l){const S=N.getBoundingClientRect();I={x:Math.floor(S.x-U.SafeBorderPadding),y:Math.floor(S.y-U.SafeBorderPadding),w:Math.floor(S.width+2*U.SafeBorderPadding),h:Math.floor(S.height+2*U.SafeBorderPadding)}}return I}transformData(){const e=Me(this.tmpPoints);return[[e.x,e.y,0],[e.x+e.w,e.y,0],[e.x+e.w,e.y+e.h,0],[e.x,e.y+e.h,0]]}subWorkerConsume(e){const{data:t,isFullWork:s}=e,{op:o,syncUnitTime:n}=t;n&&(this.syncUnitTime=n);const a=o==null?void 0:o.length;if(!a||a<2)return{type:D.None};let c;if(this.tmpPoints.length===0?(this.tmpPoints=[new Q(o[0],o[1])],c=!1):c=this.updateTempPointsForSubWorker(o),!c)return{type:D.None};const l=this.transformData(),u=s?this.fullLayer:this.drawLayer||this.fullLayer,h=this.drawForSubWorker({ps:l,workId:this.workId,layer:u}),d=ue(h,this.oldSelectRect);return this.oldSelectRect=h,{rect:d,type:D.DrawWork,dataType:B.Local,...this.baseConsumeResult}}subWorkerConsumeAll(e){const{isFullWork:t}=e,s=t?this.fullLayer:this.drawLayer||this.fullLayer;return this.replace(s,this.workId),{rect:this.oldSelectRect,type:D.FullWork,dataType:B.Local,...this.baseConsumeResult}}clearTmpPoints(){this.tmpPoints.length=0}clearSelectData(){this.selectIds=void 0,this.oldSelectRect=void 0}selectSingleTool(e,t=G,s=!1){if(e.length===2){const o=e[0],n=e[1];let a;const{nodeRange:c}=this.vNodes.getRectIntersectRange({x:o,y:n,w:0,h:0},!1),l=[...c.values()].sort((u,h)=>(h.opt.zIndex||0)-(u.opt.zIndex||0));for(const u of l){const h=this.fullLayer.getElementsByName(u.name);if(dn(h).find(g=>g.isPointCollision(o,n))){a=u;break}}if(a){const u=a.name;if(!lt(this.oldSelectRect,a.rect)){const h=new Map([[u,a]]);this.getSelecteorInfo(h),this.draw(t,this.fullLayer,{intersectRect:a.rect,subNodeMap:h,selectIds:this.selectIds||[]},s)}this.selectIds=[u],this.oldSelectRect=a.rect}}}unSelectedAllIds(){let e;for(const[t,s]of this.vNodes.curNodeMap.entries())s.isSelected&&(e=ue(e,s.rect),this.vNodes.unSelected(t));return e}unSelectedByIds(e){let t;for(const s of e){const o=this.vNodes.get(s);o&&o.isSelected&&(t=ue(t,o.rect),this.vNodes.unSelected(s))}return t}selectedByIds(e){let t;for(const s of e){const o=this.vNodes.get(s);o&&(t=ue(t,o.rect),this.vNodes.selected(s))}return t}getSelectorRect(e,t){var a;let s;const o=(a=e.parent)==null?void 0:a.getElementById(t),n=o==null?void 0:o.getBoundingClientRect();return n&&(s=ue(s,{x:Math.floor(n.x),y:Math.floor(n.y),w:Math.floor(n.width+1),h:Math.floor(n.height+1)})),s}isCanFillColor(e){return e===T.Ellipse||e===T.Triangle||e===T.Rectangle||e===T.Polygon||e===T.Star||e===T.SpeechBalloon}async updateSelector(e){const{updateSelectorOpt:t,selectIds:s,vNodes:o,willSerializeData:n,worker:a,offset:c}=e,l=this.fullLayer;if(!l)return;let u;const h=new Map,{originPoint:d,workState:g,angle:p,translate:f,dir:m,scale:w}=t;c&&(f?t.translate=[f[0]+c[0],f[1]+c[1]]:t.translate=c);let I;if(d||f||ze(p)){if(g===j.Start&&s)return o.setTargetAssignKeys(s),{type:D.Select,dataType:B.Local,selectRect:this.oldSelectRect,rect:this.oldSelectRect};if(I=o.getLastTarget(),!I)return}if(s)for(const S of s){const v=o.get(S);if(v){const{toolsType:x,opt:L}=v,b=(l==null?void 0:l.getElementsByName(S))[0];if(b){const P={...t};let A;const E=U.isWillRefresh({toolsType:x,opt:L,updateOpt:P,vNodes:o,node:b,willSerializeData:n});if(x){A=I==null?void 0:I.get(S);const R=un(x);if(R==null||R.updateNodeOpt({node:b,opt:P,vNodes:o,willSerializeData:n,targetNode:A}),v&&a&&E){const z=a.createWorkShapeNode({workId:S,toolsType:x,toolsOpt:v.opt});z==null||z.setWorkId(S);let Z;if(x===T.Image)Z=await z.consumeServiceAsync({isFullWork:!0,replaceId:S,worker:a});else if(x===T.Text)Z=await z.consumeServiceAsync({isFullWork:!0,replaceId:S});else try{Z=z==null?void 0:z.consumeService({op:v.op,isFullWork:!0,replaceId:S,workState:g})}catch{continue}Z&&(v.rect=Z)}v&&(h.set(S,v),u=ue(u,v.rect))}}}}I&&g===j.Done&&(o.deleteLastTarget(),I=void 0);const N=u;if(d&&f&&w&&m&&N&&!c){const S=[[N.x,N.y],[N.x+N.w,N.y],[N.x+N.w,N.y+N.h],[N.x,N.y+N.h]];let v;switch(m){case"top":case"topLeft":case"left":f[0]>0&&f[1]>0?v=S[0]:f[0]>0?v=S[3]:f[1]>0?v=S[1]:v=S[2];break;case"topRight":f[0]<0&&f[1]>0?v=S[1]:f[0]<0?v=S[2]:f[1]>0?v=S[0]:v=S[3];break;case"right":case"bottomRight":case"bottom":f[0]<0&&f[1]<0?v=S[2]:f[0]<0?v=S[1]:f[1]<0?v=S[3]:v=S[0];break;case"bottomLeft":f[0]>0&&f[1]<0?v=S[3]:f[0]>0?v=S[0]:f[1]<0?v=S[2]:v=S[1];break}const x=v&&[d[0]-v[0],d[1]-v[1]]||[0,0];if(!lt(x,[0,0]))return await this.updateSelector({...e,updateSelectorOpt:{workState:g},offset:x})}this.getSelecteorInfo(h),this.draw(G,l,{selectIds:s||[],subNodeMap:h,intersectRect:N});const C=ue(this.oldSelectRect,N);return this.oldSelectRect=N,{type:D.Select,dataType:B.Local,selectRect:N,renderRect:u,rect:ue(C,N),selectIds:s}}blurSelector(){const e=this.unSelectedAllIds();return{type:D.Select,dataType:B.Local,rect:e,selectIds:[],willSyncService:!0}}getRightServiceId(e){return e.replace(He,"-")}selectServiceNode(e,t,s){const{selectIds:o}=t,n=this.getRightServiceId(e),a=this.getSelectorRect(this.fullLayer,n);let c;const l=new Map;return o==null||o.forEach(u=>{const h=this.vNodes.get(u);h&&(c=ue(c,h.rect),l.set(u,h))}),this.getSelecteorInfo(l),this.draw(n,this.fullLayer,{intersectRect:c,selectIds:o||[],subNodeMap:l},s),ue(c,a)}reRenderSelector(){var s;let e;const t=new Map;return(s=this.selectIds)==null||s.forEach(o=>{const n=this.vNodes.get(o);n&&(e=ue(e,n.rect),t.set(o,n))},this),this.getSelecteorInfo(t),this.draw(G,this.fullLayer,{intersectRect:e,subNodeMap:t,selectIds:this.selectIds||[]}),this.oldSelectRect=e,e}updateSelectIds(e){var n;let t;const s=(n=this.selectIds)==null?void 0:n.filter(a=>!e.includes(a));if(s!=null&&s.length&&(t=this.unSelectedByIds(s)),e.length){const a=this.selectedByIds(e);t=ue(t,a)}this.selectIds=e;const o=this.reRenderSelector();return{bgRect:t,selectRect:o}}cursorHover(e){var n,a;const t=this.oldSelectRect;this.selectIds=[];const s=(n=this.workId)==null?void 0:n.toString(),o=[e[0]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],e[1]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[1]];if(this.selectSingleTool(o,s,!0),this.oldSelectRect&&!lt(t,this.oldSelectRect))return{type:D.CursorHover,dataType:B.Local,rect:ue(t,this.oldSelectRect),selectorColor:this.selectorColor,willSyncService:!1};if((a=this.selectIds)!=null&&a.length||(this.oldSelectRect=void 0),t&&!this.oldSelectRect)return this.cursorBlur(),{type:D.CursorHover,dataType:B.Local,rect:t,selectorColor:this.selectorColor,willSyncService:!1}}cursorBlur(){var t,s;this.selectIds=[];const e=(t=this.workId)==null?void 0:t.toString();((s=this.fullLayer)==null?void 0:s.parent).children.forEach(o=>{o.name===e&&o.remove()})}};M(Ii,"selectorBorderId","selector-border");let gi=Ii;class on extends U{constructor(e){super(e);M(this,"canRotate",!1);M(this,"scaleType",ce.both);M(this,"toolsType",T.Arrow);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"arrowTipWidth");M(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.arrowTipWidth=this.workOptions.thickness*4,this.syncTimestamp=0,this.syncUnitTime=50}consume(e){const{data:t,isFullWork:s,isSubWorker:o,isMainThread:n}=e,a=this.workId,{op:c,syncUnitTime:l}=t;l&&(this.syncUnitTime=l);const u=c==null?void 0:c.length;if(!u||u<2)return{type:D.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new Q(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:D.None};let d;if(o||n){const p=s?this.fullLayer:this.drawLayer||this.fullLayer;d=this.draw({workId:a,layer:p})}if(!o){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{...this.baseConsumeResult,type:D.DrawWork,dataType:B.Local,op:this.tmpPoints.map(f=>[...f.XY,0]).flat(1),isSync:!0,index:0}):{type:D.None}}const g=ue(d,this.oldRect);return this.oldRect=d,{rect:g,...this.baseConsumeResult,type:D.DrawWork,dataType:B.Local}}consumeAll(){var a;const e=this.workId;if(this.tmpPoints.length<2)return{type:D.RemoveNode,removeIds:[e]};const t=this.fullLayer,s=this.draw({workId:e,layer:t});this.oldRect=s;const o=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=Be(o);return(a=this.vNodes)==null||a.setInfo(e,{rect:s,op:o,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:U.getCenterPos(s,t)}),{rect:s,...this.baseConsumeResult,type:D.FullWork,dataType:B.Local,ops:n,isSync:!0}}draw(e){const{workId:t,layer:s,isDrawEraserlines:o}=e,{strokeColor:n,thickness:a,zIndex:c,scale:l,rotate:u,translate:h,strokeType:d,eraserlines:g}=this.workOptions,p=s.worldPosition,f=s.worldScaling,{points:m,pos:w,rect:I,isTriangle:N,trianglePoints:C,trianglePos:S}=this.computDrawPoints(a),v=[I.x+I.w/2,I.y+I.h/2],x={pos:v,name:t,id:t,zIndex:c,anchor:[.5,.5],size:[I.w,I.h]};l&&(x.scale=l),u&&(x.rotate=u),h&&(x.translate=h);const L=new he.Group(x),b={points:C,pos:[S[0]-v[0],S[1]-v[1]],fillColor:n,strokeColor:n,lineWidth:0,normalize:!1},P=new he.Polyline(b);if(L.append(P),!N&&m&&w){const E={points:m,pos:[w[0]-v[0],w[1]-v[1]],fillColor:n,strokeColor:n,lineDash:d===oe.Dotted&&!N?[1,a*2]:d===oe.LongDotted&&!N?[a,a*2]:void 0,lineCap:d===oe.Normal?void 0:"round",lineWidth:a,normalize:!1},R=new he.Polyline(E);L.append(R)}g&&(this.scaleType=ce.proportional,this.drawEraserlines({group:L,eraserlines:g,pos:v,layer:s},o)),this.replace(s,t,L);let A={x:Math.floor(I.x*f[0]+p[0]-U.SafeBorderPadding),y:Math.floor(I.y*f[1]+p[1]-U.SafeBorderPadding),w:Math.floor(I.w*f[0]+2*U.SafeBorderPadding),h:Math.floor(I.h*f[1]+2*U.SafeBorderPadding)};if(l||u||h){const E=L.getBoundingClientRect();A={x:Math.floor(E.x-U.SafeBorderPadding),y:Math.floor(E.y-U.SafeBorderPadding),w:Math.floor(E.width+U.SafeBorderPadding*2),h:Math.floor(E.height+U.SafeBorderPadding*2)}}return this.isDelete&&L.setAttribute("opacity",0),A}computDrawPoints(e){return this.tmpPoints[1].distance(this.tmpPoints[0])>this.arrowTipWidth?this.computFullArrowPoints(e):this.computTrianglePoints()}computFullArrowPoints(e){const t=k.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),s=k.Per(t).mul(e/2),o=Q.Sub(this.tmpPoints[0],s),n=Q.Add(this.tmpPoints[0],s),a=k.Mul(t,this.arrowTipWidth),c=k.Sub(this.tmpPoints[1],a),l=Q.Sub(c,s),u=Q.Add(c,s),h=k.Per(t).mul(e*1.5),d=Q.Sub(c,h),g=Q.Add(c,h),p=[this.tmpPoints[0],c],f=[d,this.tmpPoints[1],g],m=[o,n,...f,l,u];return{trianglePoints:f.map(w=>Q.Sub(w,this.tmpPoints[1]).XY).flat(1),trianglePos:this.tmpPoints[1].XY,points:p.map(w=>Q.Sub(w,this.tmpPoints[0]).XY).flat(1),rect:Me(m),isTriangle:!1,pos:this.tmpPoints[0].XY}}computTrianglePoints(){const e=k.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),t=this.tmpPoints[1].distance(this.tmpPoints[0]),s=k.Per(e).mul(Math.floor(t*3/8)),o=Q.Sub(this.tmpPoints[0],s),n=Q.Add(this.tmpPoints[0],s),a=[o,this.tmpPoints[1],n];return{trianglePoints:a.map(c=>Q.Sub(c,this.tmpPoints[1]).XY).flat(1),trianglePos:this.tmpPoints[1].XY,rect:Me(a),isTriangle:!0}}updateTempPoints(e){const t=e.slice(-2),s=new Q(t[0],t[1]),o=this.tmpPoints[0],{thickness:n}=this.workOptions;if(o.isNear(s,n))return!1;if(this.tmpPoints.length===2){if(s.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=s}else this.tmpPoints.push(s);return!0}consumeService(e){var l,u;const{op:t,isFullWork:s,workState:o=j.Done}=e,n=(l=this.workId)==null?void 0:l.toString();if(!n)return;this.tmpPoints.length=0;for(let h=0;h<t.length;h+=3)this.tmpPoints.push(new Q(t[h],t[h+1],t[h+2]));const a=s?this.fullLayer:this.drawLayer||this.fullLayer,c=this.draw({workId:n,layer:a,isDrawEraserlines:o===j.Done});return this.oldRect=c,(u=this.vNodes)==null||u.setInfo(n,{rect:c,op:t,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:U.getCenterPos(c,a)}),c}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var l,u;const{node:t,opt:s,vNodes:o}=e,{strokeColor:n,strokeType:a}=s,c=o.get(t.name);return n&&(t.tagName==="GROUP"?t.children.forEach(h=>{h.setAttribute("strokeColor",n),h.getAttribute("fillColor")&&h.setAttribute("fillColor",n)}):(t.setAttribute("strokeColor",n),t.setAttribute("fillColor",n)),(l=c==null?void 0:c.opt)!=null&&l.strokeColor&&(c.opt.strokeColor=n)),a&&(c!=null&&c.opt)&&((u=c.opt)!=null&&u.strokeType)&&(c.opt.strokeType=a),c&&o.setInfo(t.name,c),U.updateNodeOpt(e)}}class nn extends U{constructor(e){super(e);M(this,"canRotate",!1);M(this,"scaleType",ce.all);M(this,"toolsType",T.Ellipse);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(e){const{data:t,isFullWork:s,isSubWorker:o,isMainThread:n}=e,a=this.workId,{op:c,syncUnitTime:l}=t;l&&(this.syncUnitTime=l);const u=c==null?void 0:c.length;if(!u||u<2)return{type:D.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new Q(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:D.None};if(!o){const g=Date.now();return g-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=g,{type:D.DrawWork,dataType:B.Local,...this.baseConsumeResult,op:this.tmpPoints.map(p=>[...p.XY,0]).flat(1),isSync:!0,index:0}):{type:D.None}}let d;if(o||n){const g=s?this.fullLayer:this.drawLayer||this.fullLayer;d=this.draw({workId:a,layer:g,isDrawing:!0});const p=g.parent.parent,f={x:0,y:0,w:Math.floor(p.width),h:Math.floor(p.height)};if(Is(d,f)!==Nt.outside){const w=ue(d,this.oldRect);return this.oldRect=d,{rect:w,type:D.DrawWork,dataType:B.Local,...this.baseConsumeResult}}return{type:D.None}}return{type:D.None}}consumeAll(){var a;const e=this.workId;if(this.tmpPoints.length<2)return{type:D.RemoveNode,removeIds:[e]};const t=this.fullLayer,s=this.draw({workId:e,layer:t,isDrawing:!1});this.oldRect=s;const o=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=Be(o);return(a=this.vNodes)==null||a.setInfo(e,{rect:s,op:o,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:s&&U.getCenterPos(s,t)}),{rect:s,type:D.FullWork,dataType:B.Local,...this.baseConsumeResult,ops:n,isSync:!0}}draw(e){const{workId:t,layer:s,isDrawing:o,isDrawEraserlines:n}=e,{strokeColor:a,fillColor:c,thickness:l,zIndex:u,scale:h,rotate:d,translate:g,strokeType:p,eraserlines:f}=this.workOptions,m=s.worldScaling,{radius:w,rect:I,pos:N}=this.computDrawPoints(l),C={closeType:"normal",radius:w,lineWidth:l,fillColor:c!=="transparent"&&c||void 0,strokeColor:a,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:p===oe.Dotted?[1,l*2]:p===oe.LongDotted?[l,l*2]:void 0},S={name:t,id:t,zIndex:u,pos:N,anchor:[.5,.5],size:[I.w,I.h]};h&&(S.scale=h),d&&(S.rotate=d),g&&(S.translate=g);const v=new he.Group(S);if(o){const b=new he.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:a,lineWidth:1,scale:[1/m[0],1/m[1]]});v.append(b)}const x=new he.Ellipse({...C,pos:[0,0]});v.append(x),f&&(this.scaleType=ce.proportional,this.drawEraserlines({group:v,eraserlines:f,pos:N,layer:s},n)),this.replace(s,t,v);const L=v.getBoundingClientRect();return this.isDelete&&v.setAttribute("opacity",0),{x:Math.floor(L.x-U.SafeBorderPadding),y:Math.floor(L.y-U.SafeBorderPadding),w:Math.floor(L.width+U.SafeBorderPadding*2),h:Math.floor(L.height+U.SafeBorderPadding*2)}}computDrawPoints(e){const t=Me(this.tmpPoints),s=Me(this.tmpPoints,e),o=[Math.floor(t.x+t.w/2),Math.floor(t.y+t.h/2)];return{rect:s,pos:o,radius:[Math.floor(t.w/2),Math.floor(t.h/2)]}}updateTempPoints(e){const t=e.slice(-2),s=new Q(t[0],t[1]),o=this.tmpPoints[0],{thickness:n}=this.workOptions;if(o.isNear(s,n))return!1;if(this.tmpPoints.length===2){if(s.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=s}else this.tmpPoints.push(s);return!0}consumeService(e){var l,u;const{op:t,isFullWork:s,workState:o=j.Done}=e,n=(l=this.workId)==null?void 0:l.toString();if(!n)return;this.tmpPoints.length=0;for(let h=0;h<t.length;h+=3)this.tmpPoints.push(new Q(t[h],t[h+1],t[h+2]));const a=s?this.fullLayer:this.drawLayer||this.fullLayer,c=this.draw({workId:n,layer:a,isDrawing:!1,isDrawEraserlines:o===j.Done});return this.oldRect=c,(u=this.vNodes)==null||u.setInfo(n,{rect:c,op:t,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:U.getCenterPos(c,a)}),c}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var h,d,g;const{node:t,opt:s,vNodes:o}=e,{strokeColor:n,fillColor:a,strokeType:c}=s,l=o.get(t.name);let u=t;return t.tagName==="GROUP"&&(u=t.children[0]),n&&(u.setAttribute("strokeColor",n),(h=l==null?void 0:l.opt)!=null&&h.strokeColor&&(l.opt.strokeColor=n)),a&&(a==="transparent"?u.setAttribute("fillColor","rgba(0,0,0,0)"):u.setAttribute("fillColor",a),(d=l==null?void 0:l.opt)!=null&&d.fillColor&&(l.opt.fillColor=a)),c&&(l!=null&&l.opt)&&((g=l.opt)!=null&&g.strokeType)&&(l.opt.strokeType=c),l&&o.setInfo(t.name,l),U.updateNodeOpt(e)}}class rn extends U{constructor(e){super(e);M(this,"canRotate",!0);M(this,"scaleType",ce.all);M(this,"toolsType",T.Rectangle);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}transformData(){const e=Me(this.tmpPoints);return[[e.x,e.y,0],[e.x+e.w,e.y,0],[e.x+e.w,e.y+e.h,0],[e.x,e.y+e.h,0]]}computDrawPoints(e){const{thickness:t}=this.workOptions,s=[];for(const a of e)s.push(new k(...a));const o=Me(s,t),n=[o.x+o.w/2,o.y+o.h/2];return{rect:o,pos:n,points:s.map(a=>a.XY).flat(1)}}consume(e){const{data:t,isFullWork:s,isSubWorker:o,isMainThread:n}=e,a=this.workId,{op:c}=t,l=c==null?void 0:c.length;if(!l||l<2)return{type:D.None};let u;if(this.tmpPoints.length===0?(this.tmpPoints=[new Q(c[0],c[1])],u=!1):u=this.updateTempPoints(c),!u)return{type:D.None};const h=this.transformData();let d;if(o||n){const p=s?this.fullLayer:this.drawLayer||this.fullLayer;d=this.draw({ps:h,workId:a,layer:p,isDrawing:!0})}if(!o){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{type:D.DrawWork,dataType:B.Local,op:h.flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:D.None}}const g=ue(d,this.oldRect);return this.oldRect=d,{rect:g,type:D.DrawWork,dataType:B.Local,...this.baseConsumeResult}}consumeAll(){var c;const e=this.workId;if(this.tmpPoints.length<2)return{type:D.RemoveNode,removeIds:[e]};const t=this.transformData(),s=this.fullLayer,o=this.draw({ps:t,workId:e,layer:s,isDrawing:!1});this.oldRect=o;const n=t.flat(1),a=Be(n);return(c=this.vNodes)==null||c.setInfo(e,{rect:o,op:n,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:o&&U.getCenterPos(o,s)}),{rect:o,type:D.FullWork,dataType:B.Local,ops:a,isSync:!0,...this.baseConsumeResult}}draw(e){const{workId:t,layer:s,isDrawing:o,ps:n,replaceId:a,isDrawEraserlines:c=!0}=e,{strokeColor:l,fillColor:u,thickness:h,zIndex:d,scale:g,rotate:p,translate:f,strokeType:m,eraserlines:w}=this.workOptions,I=s.worldPosition,N=s.worldScaling,{points:C,rect:S,pos:v}=this.computDrawPoints(n),x={close:!0,normalize:!0,points:C,lineWidth:h,fillColor:u!=="transparent"&&u||void 0,strokeColor:l,lineJoin:"round",lineCap:"round",lineDash:m===oe.Dotted?[1,h*2]:m===oe.LongDotted?[h,h*2]:void 0};let L={x:Math.floor(S.x*N[0]+I[0]-U.SafeBorderPadding),y:Math.floor(S.y*N[1]+I[1]-U.SafeBorderPadding),w:Math.floor(S.w*N[0]+2*U.SafeBorderPadding),h:Math.floor(S.h*N[0]+2*U.SafeBorderPadding)};const b=new he.Group({name:t,id:t,zIndex:d,pos:v,anchor:[.5,.5],size:[S.w,S.h],scale:g,rotate:p,translate:f}),P=new he.Polyline({...x,pos:[0,0]});if(b.appendChild(P),o){const A=new he.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:l,lineWidth:1,scale:[1/N[0],1/N[1]]});b.appendChild(A)}if(w&&(this.scaleType=ce.proportional,this.drawEraserlines({group:b,eraserlines:w,pos:v,layer:s},c)),this.replace(s,a||t,b),g||p||f){const A=b.getBoundingClientRect();L={x:Math.floor(A.x-U.SafeBorderPadding),y:Math.floor(A.y-U.SafeBorderPadding),w:Math.floor(A.width+2*U.SafeBorderPadding),h:Math.floor(A.height+2*U.SafeBorderPadding)}}return this.isDelete&&b.setAttribute("opacity",0),L}updateTempPoints(e){const t=e.slice(-2),s=new Q(t[0],t[1]),o=this.tmpPoints[0],{thickness:n}=this.workOptions;if(o.isNear(s,n))return!1;if(this.tmpPoints.length===2){if(s.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=s}else this.tmpPoints.push(s);return!0}consumeService(e){var h,d;const{op:t,isFullWork:s,replaceId:o,workState:n=j.Done}=e,a=(h=this.workId)==null?void 0:h.toString();if(!a)return;const c=[];for(let g=0;g<t.length;g+=3)c.push([t[g],t[g+1],t[g+2]]);const l=s?this.fullLayer:this.drawLayer||this.fullLayer,u=this.draw({ps:c,workId:a,layer:l,isDrawing:!1,replaceId:o,isDrawEraserlines:n===j.Done});return this.oldRect=u,(d=this.vNodes)==null||d.setInfo(a,{rect:u,op:t,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:u&&U.getCenterPos(u,l)}),u}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var h,d,g;const{node:t,opt:s,vNodes:o}=e,{strokeColor:n,fillColor:a,strokeType:c}=s,l=o.get(t.name);let u=t;return t.tagName==="GROUP"&&(u=t.children[0]),n&&(u.setAttribute("strokeColor",n),(h=l==null?void 0:l.opt)!=null&&h.strokeColor&&(l.opt.strokeColor=n)),a&&(a==="transparent"?u.setAttribute("fillColor","rgba(0,0,0,0)"):u.setAttribute("fillColor",a),(d=l==null?void 0:l.opt)!=null&&d.fillColor&&(l.opt.fillColor=a)),c&&(l!=null&&l.opt)&&((g=l.opt)!=null&&g.strokeType)&&(l.opt.strokeType=c),l&&o.setInfo(t.name,l),U.updateNodeOpt(e)}}class an extends U{constructor(e){super(e);M(this,"canRotate",!1);M(this,"scaleType",ce.all);M(this,"toolsType",T.Star);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(e){const{data:t,isFullWork:s,isSubWorker:o,isMainThread:n}=e,a=this.workId,{op:c,syncUnitTime:l}=t,u=c==null?void 0:c.length;if(!u||u<2)return{type:D.None};l&&(this.syncUnitTime=l);let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new Q(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:D.None};let d;if(o||n){const p=s?this.fullLayer:this.drawLayer||this.fullLayer;d=this.draw({workId:a,layer:p,isDrawing:!0})}if(!o){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{type:D.DrawWork,dataType:B.Local,op:this.tmpPoints.map(f=>[...f.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:D.None}}const g=ue(d,this.oldRect);return this.oldRect=d,{rect:g,type:D.DrawWork,dataType:B.Local,...this.baseConsumeResult}}consumeAll(){var a;const e=this.workId;if(this.tmpPoints.length<2)return{type:D.RemoveNode,removeIds:[e]};const t=this.fullLayer,s=this.draw({workId:e,layer:t,isDrawing:!1});this.oldRect=s;const o=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=Be(o);return(a=this.vNodes)==null||a.setInfo(e,{rect:s,op:o,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:s&&U.getCenterPos(s,t)}),{rect:s,type:D.FullWork,dataType:B.Local,ops:n,isSync:!0,...this.baseConsumeResult}}draw(e){const{workId:t,layer:s,isDrawing:o,isDrawEraserlines:n=!0}=e,{strokeColor:a,fillColor:c,thickness:l,zIndex:u,vertices:h,innerVerticeStep:d,innerRatio:g,scale:p,rotate:f,translate:m,strokeType:w,eraserlines:I}=this.workOptions,N=s.worldScaling,{rect:C,pos:S,points:v}=this.computDrawPoints(l,h,d,g),x={close:!0,points:v,lineWidth:l,fillColor:c!=="transparent"&&c||void 0,strokeColor:a,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:w===oe.Dotted?[1,l*2]:w===oe.LongDotted?[l,l*2]:void 0},L={name:t,id:t,zIndex:u,pos:S,anchor:[.5,.5],size:[C.w,C.h]};p&&(L.scale=p),f&&(L.rotate=f),m&&(L.translate=m);const b=new he.Group(L);if(o){const E=new he.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:a,lineWidth:1,scale:[1/N[0],1/N[1]]});b.append(E)}const P=new he.Polyline({...x,pos:[0,0]});b.append(P),I&&(this.scaleType=ce.proportional,this.drawEraserlines({group:b,eraserlines:I,pos:S,layer:s},n)),this.replace(s,t,b);const A=b.getBoundingClientRect();return this.isDelete&&b.setAttribute("opacity",0),{x:Math.floor(A.x-U.SafeBorderPadding),y:Math.floor(A.y-U.SafeBorderPadding),w:Math.floor(A.width+U.SafeBorderPadding*2),h:Math.floor(A.height+U.SafeBorderPadding*2)}}computDrawPoints(e,t,s,o){const n=Me(this.tmpPoints),a=[Math.floor(n.x+n.w/2),Math.floor(n.y+n.h/2)],c=Tn(n.w,n.h),l=Math.floor(Math.min(n.w,n.h)/2),u=o*l,h=[],d=2*Math.PI/t;for(let p=0;p<t;p++){const f=p*d-.5*Math.PI;let m,w;p%s===1?(m=u*c[0]*Math.cos(f),w=u*c[1]*Math.sin(f)):(m=l*c[0]*Math.cos(f),w=l*c[1]*Math.sin(f),h.push(m,w)),h.push(m,w)}return{rect:Me(this.tmpPoints,e),pos:a,points:h}}updateTempPoints(e){const t=e.slice(-2),s=new Q(t[0],t[1]),o=this.tmpPoints[0],{thickness:n}=this.workOptions;if(o.isNear(s,n)||Q.Sub(o,s).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(s.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=s}else this.tmpPoints.push(s);return!0}consumeService(e){var l,u;const{op:t,isFullWork:s,workState:o=j.Done}=e,n=(l=this.workId)==null?void 0:l.toString();if(!n)return;this.tmpPoints.length=0;for(let h=0;h<t.length;h+=3)this.tmpPoints.push(new Q(t[h],t[h+1],t[h+2]));const a=s?this.fullLayer:this.drawLayer||this.fullLayer,c=this.draw({workId:n,layer:a,isDrawing:!1,isDrawEraserlines:o===j.Done});return this.oldRect=c,(u=this.vNodes)==null||u.setInfo(n,{rect:c,op:t,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:c&&U.getCenterPos(c,a)}),c}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var m;const{node:t,opt:s,vNodes:o}=e,{strokeColor:n,fillColor:a,toolsType:c,vertices:l,innerVerticeStep:u,innerRatio:h,strokeType:d}=s,g=o.get(t.name),p=g==null?void 0:g.opt;let f=t;return t.tagName==="GROUP"&&(f=t.children[0]),n&&(f.setAttribute("strokeColor",n),p!=null&&p.strokeColor&&(p.strokeColor=n)),a&&(a==="transparent"?f.setAttribute("fillColor","rgba(0,0,0,0)"):f.setAttribute("fillColor",a),p!=null&&p.fillColor&&(p.fillColor=a)),c===T.Star&&(l&&(p.vertices=l),u&&(p.innerVerticeStep=u),h&&(p.innerRatio=h)),d&&(g!=null&&g.opt)&&((m=g.opt)!=null&&m.strokeType)&&(g.opt.strokeType=d),g&&o.setInfo(t.name,{...g,opt:p}),U.updateNodeOpt(e)}}class cn extends U{constructor(e){super(e);M(this,"canRotate",!1);M(this,"scaleType",ce.all);M(this,"toolsType",T.Polygon);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(e){const{data:t,isFullWork:s,isSubWorker:o,isMainThread:n}=e,{op:a,syncUnitTime:c}=t;c&&(this.syncUnitTime=c);const l=this.workId,u=a==null?void 0:a.length;if(!u||u<2)return{type:D.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new Q(a[0],a[1])],h=!1):h=this.updateTempPoints(a),!h)return{type:D.None};let d;if(o||n){const p=s?this.fullLayer:this.drawLayer||this.fullLayer;d=this.draw({workId:l,layer:p,isDrawing:!0})}if(!o){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{type:D.DrawWork,dataType:B.Local,op:this.tmpPoints.map(f=>[...f.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:D.None}}const g=ue(d,this.oldRect);return this.oldRect=d,{rect:g,type:D.DrawWork,dataType:B.Local,...this.baseConsumeResult}}consumeAll(){var a;const e=this.workId;if(this.tmpPoints.length<2)return{type:D.RemoveNode,removeIds:[e]};const t=this.fullLayer,s=this.draw({workId:e,layer:t,isDrawing:!1});this.oldRect=s;const o=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=Be(o);return(a=this.vNodes)==null||a.setInfo(e,{rect:s,op:o,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:s&&U.getCenterPos(s,t)}),{rect:s,type:D.FullWork,dataType:B.Local,ops:n,isSync:!0,...this.baseConsumeResult}}draw(e){const{workId:t,layer:s,isDrawing:o,isDrawEraserlines:n=!0}=e,{strokeColor:a,fillColor:c,thickness:l,zIndex:u,vertices:h,scale:d,rotate:g,translate:p,strokeType:f,eraserlines:m}=this.workOptions,w=s.worldScaling,{rect:I,pos:N,points:C}=this.computDrawPoints(l,h),S={close:!0,points:C,lineWidth:l,fillColor:c!=="transparent"&&c||void 0,strokeColor:a,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:f===oe.Dotted?[1,l*2]:f===oe.LongDotted?[l,l*2]:void 0},v={name:t,id:t,zIndex:u,pos:N,anchor:[.5,.5],size:[I.w,I.h]};d&&(v.scale=d),g&&(v.rotate=g),p&&(v.translate=p);const x=new he.Group(v);if(o){const P=new he.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:a,lineWidth:1,scale:[1/w[0],1/w[1]]});x.append(P)}const L=new he.Polyline({...S,pos:[0,0]});x.append(L),m&&(this.scaleType=ce.proportional,this.drawEraserlines({group:x,eraserlines:m,pos:N,layer:s},n)),this.replace(s,t,x);const b=x.getBoundingClientRect();return this.isDelete&&x.setAttribute("opacity",0),{x:Math.floor(b.x-U.SafeBorderPadding),y:Math.floor(b.y-U.SafeBorderPadding),w:Math.floor(b.width+U.SafeBorderPadding*2),h:Math.floor(b.height+U.SafeBorderPadding*2)}}computDrawPoints(e,t){const s=Me(this.tmpPoints),o=[Math.floor(s.x+s.w/2),Math.floor(s.y+s.h/2)],n=Tn(s.w,s.h),a=Math.floor(Math.min(s.w,s.h)/2),c=[],l=2*Math.PI/t;for(let h=0;h<t;h++){const d=h*l-.5*Math.PI,g=a*n[0]*Math.cos(d),p=a*n[1]*Math.sin(d);c.push(g,p)}return{rect:Me(this.tmpPoints,e),pos:o,points:c}}updateTempPoints(e){const t=e.slice(-2),s=new Q(t[0],t[1]),o=this.tmpPoints[0],{thickness:n}=this.workOptions;if(o.isNear(s,n)||Q.Sub(o,s).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(s.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=s}else this.tmpPoints.push(s);return!0}consumeService(e){var l,u;const{op:t,isFullWork:s,workState:o=j.Done}=e,n=(l=this.workId)==null?void 0:l.toString();if(!n)return;this.tmpPoints.length=0;for(let h=0;h<t.length;h+=3)this.tmpPoints.push(new Q(t[h],t[h+1],t[h+2]));const a=s?this.fullLayer:this.drawLayer||this.fullLayer,c=this.draw({workId:n,layer:a,isDrawing:!1,isDrawEraserlines:o===j.Done});return this.oldRect=c,(u=this.vNodes)==null||u.setInfo(n,{rect:c,op:t,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:c&&U.getCenterPos(c,a)}),c}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var p;const{node:t,opt:s,vNodes:o}=e,{strokeColor:n,fillColor:a,toolsType:c,vertices:l,strokeType:u}=s,h=o.get(t.name),d=h==null?void 0:h.opt;let g=t;return t.tagName==="GROUP"&&(g=t.children[0]),n&&(g.setAttribute("strokeColor",n),d!=null&&d.strokeColor&&(d.strokeColor=n)),a&&(a==="transparent"?g.setAttribute("fillColor","rgba(0,0,0,0)"):g.setAttribute("fillColor",a),d!=null&&d.fillColor&&(d.fillColor=a)),c===T.Polygon&&l&&(d.vertices=l),u&&(h!=null&&h.opt)&&((p=h.opt)!=null&&p.strokeType)&&(h.opt.strokeType=u),h&&o.setInfo(t.name,{...h,opt:d}),U.updateNodeOpt(e)}}class _e{static bezier(i,e){const t=[];for(let s=0;s<e.length;s+=4){const o=e[s],n=e[s+1],a=e[s+2],c=e[s+3];o&&n&&a&&c?t.push(..._e.getBezierPoints(i,o,n,a,c)):o&&n&&a?t.push(..._e.getBezierPoints(i,o,n,a)):o&&n?t.push(..._e.getBezierPoints(i,o,n)):o&&t.push(o)}return t}static getBezierPoints(i=10,e,t,s,o){let n=null;const a=[];!s&&!o?n=_e.oneBezier:s&&!o?n=_e.twoBezier:s&&o&&(n=_e.threeBezier);for(let c=0;c<i;c++)n&&a.push(n(c/i,e,t,s,o));return o?a.push(o):s&&a.push(s),a}static oneBezier(i,e,t){const s=e.x+(t.x-e.x)*i,o=e.y+(t.y-e.y)*i;return new k(s,o)}static twoBezier(i,e,t,s){const o=(1-i)*(1-i)*e.x+2*i*(1-i)*t.x+i*i*s.x,n=(1-i)*(1-i)*e.y+2*i*(1-i)*t.y+i*i*s.y;return new k(o,n)}static threeBezier(i,e,t,s,o){const n=e.x*(1-i)*(1-i)*(1-i)+3*t.x*i*(1-i)*(1-i)+3*s.x*i*i*(1-i)+o.x*i*i*i,a=e.y*(1-i)*(1-i)*(1-i)+3*t.y*i*(1-i)*(1-i)+3*s.y*i*i*(1-i)+o.y*i*i*i;return new k(n,a)}}class ln extends U{constructor(e){super(e);M(this,"canRotate",!1);M(this,"scaleType",ce.all);M(this,"toolsType",T.SpeechBalloon);M(this,"ratio",.8);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(e){var g;const{data:t,isFullWork:s,isSubWorker:o,isMainThread:n}=e,a=(g=t==null?void 0:t.workId)==null?void 0:g.toString();if(!a)return{type:D.None};const{op:c}=t,l=c==null?void 0:c.length;if(!l||l<2)return{type:D.None};let u;if(this.tmpPoints.length===0?(this.tmpPoints=[new Q(c[0],c[1])],u=!1):u=this.updateTempPoints(c),!u)return{type:D.None};let h;if(o||n){const p=s?this.fullLayer:this.drawLayer||this.fullLayer;h=this.draw({workId:a,layer:p,isDrawing:!0})}if(!o){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{type:D.DrawWork,dataType:B.Local,op:this.tmpPoints.map(f=>[...f.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:D.None}}const d=ue(h,this.oldRect);return this.oldRect=h,{rect:d,type:D.DrawWork,dataType:B.Local,...this.baseConsumeResult}}consumeAll(){var a;const e=this.workId;if(this.tmpPoints.length<2)return{type:D.RemoveNode,removeIds:[e]};const t=this.fullLayer,s=this.draw({workId:e,layer:t,isDrawing:!1});this.oldRect=s;const o=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=Be(o);return(a=this.vNodes)==null||a.setInfo(e,{rect:s,op:o,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:s&&U.getCenterPos(s,t)}),{rect:s,type:D.FullWork,dataType:B.Local,ops:n,isSync:!0,...this.baseConsumeResult}}draw(e){const{workId:t,layer:s,isDrawEraserlines:o=!0}=e,{strokeColor:n,fillColor:a,thickness:c,zIndex:l,placement:u,scale:h,rotate:d,translate:g,strokeType:p,eraserlines:f}=this.workOptions,{rect:m,pos:w,points:I}=this.computDrawPoints(c,u),N={points:I.map(L=>L.XY),lineWidth:c,fillColor:a!=="transparent"&&a||void 0,strokeColor:n,normalize:!0,className:`${w[0]},${w[1]}`,close:!0,lineJoin:"round",lineCap:"round",lineDash:p===oe.Dotted?[1,c*2]:p===oe.LongDotted?[c,c*2]:void 0},C={name:t,id:t,zIndex:l,pos:w,anchor:[.5,.5],size:[m.w,m.h]};h&&(C.scale=h),d&&(C.rotate=d),g&&(C.translate=g);const S=new he.Group(C),v=new he.Polyline({...N,pos:[0,0]});S.append(v),f&&(this.scaleType=ce.proportional,this.drawEraserlines({group:S,eraserlines:f,pos:w,layer:s},o)),this.replace(s,t,S);const x=S.getBoundingClientRect();return this.isDelete&&S.setAttribute("opacity",0),{x:Math.floor(x.x-U.SafeBorderPadding),y:Math.floor(x.y-U.SafeBorderPadding),w:Math.floor(x.width+U.SafeBorderPadding*2),h:Math.floor(x.height+U.SafeBorderPadding*2)}}transformControlPoints(e){const t=Me(this.tmpPoints);switch(e){case"bottom":case"bottomLeft":case"bottomRight":{const s=t.y+t.h*this.ratio;return[new k(t.x,t.y,0),new k(t.x+t.w,t.y,0),new k(t.x+t.w,s,0),new k(t.x,s,0)]}case"top":case"topLeft":case"topRight":{const s=t.y+t.h*(1-this.ratio);return[new k(t.x,s,0),new k(t.x+t.w,s,0),new k(t.x+t.w,t.y+t.h,0),new k(t.x,t.y+t.h,0)]}case"left":case"leftBottom":case"leftTop":{const s=t.x+t.w*(1-this.ratio);return[new k(s,t.y,0),new k(t.x+t.w,t.y,0),new k(t.x+t.w,t.y+t.h,0),new k(s,t.y+t.h,0)]}case"right":case"rightBottom":case"rightTop":{const s=t.x+t.w*this.ratio;return[new k(t.x,t.y,0),new k(s,t.y,0),new k(s,t.y+t.h,0),new k(t.x,t.y+t.h,0)]}}}computDrawPoints(e,t){const s=Me(this.tmpPoints),o=this.transformControlPoints(t),n=Math.floor(s.w*.1),a=Math.floor(s.h*.1),c=[],l=k.Add(o[0],new k(0,a,0)),u=k.Add(o[0],new k(n,0,0)),h=_e.getBezierPoints(10,l,o[0],u),d=k.Sub(o[1],new k(n,0,0)),g=k.Add(o[1],new k(0,a,0)),p=_e.getBezierPoints(10,d,o[1],g),f=k.Sub(o[2],new k(0,a,0)),m=k.Sub(o[2],new k(n,0,0)),w=_e.getBezierPoints(10,f,o[2],m),I=k.Add(o[3],new k(n,0,0)),N=k.Sub(o[3],new k(0,a,0)),C=_e.getBezierPoints(10,I,o[3],N),S=n*(1-this.ratio)*10,v=a*(1-this.ratio)*10;switch(t){case"bottom":{const b=k.Sub(o[2],new k(n*5-S/2,0,0)),P=k.Sub(o[2],new k(n*5,-v,0)),A=k.Sub(o[2],new k(n*5+S/2,0,0));c.push(P,A,...C,...h,...p,...w,b);break}case"bottomRight":{const b=k.Sub(o[2],new k(n*1.1,0,0)),P=k.Sub(o[2],new k(n*1.1+S/2,-v,0)),A=k.Sub(o[2],new k(n*1.1+S,0,0));c.push(P,A,...C,...h,...p,...w,b);break}case"bottomLeft":{const b=k.Add(o[3],new k(n*1.1+S,0,0)),P=k.Add(o[3],new k(n*1.1+S/2,v,0)),A=k.Add(o[3],new k(n*1.1,0,0));c.push(P,A,...C,...h,...p,...w,b);break}case"top":{const b=k.Sub(o[1],new k(n*5-S/2,0,0)),P=k.Sub(o[1],new k(n*5,v,0)),A=k.Sub(o[1],new k(n*5+S/2,0,0));c.push(P,b,...p,...w,...C,...h,A);break}case"topRight":{const b=k.Sub(o[1],new k(n*1.1,0,0)),P=k.Sub(o[1],new k(n*1.1+S/2,v,0)),A=k.Sub(o[1],new k(n*1.1+S,0,0));c.push(P,b,...p,...w,...C,...h,A);break}case"topLeft":{const b=k.Add(o[0],new k(n*1.1+S,0,0)),P=k.Add(o[0],new k(n*1.1+S/2,-v,0)),A=k.Add(o[0],new k(n*1.1,0,0));c.push(P,b,...p,...w,...C,...h,A);break}case"left":{const b=k.Add(o[0],new k(0,a*5-v/2,0)),P=k.Add(o[0],new k(-S,a*5,0)),A=k.Add(o[0],new k(0,a*5+v/2,0));c.push(P,b,...h,...p,...w,...C,A);break}case"leftTop":{const b=k.Add(o[0],new k(0,a*1.1,0)),P=k.Add(o[0],new k(-S,a*1.1+v/2,0)),A=k.Add(o[0],new k(0,a*1.1+v,0));c.push(P,b,...h,...p,...w,...C,A);break}case"leftBottom":{const b=k.Sub(o[3],new k(0,a*1.1+v,0)),P=k.Sub(o[3],new k(S,a*1.1+v/2,0)),A=k.Sub(o[3],new k(0,a*1.1,0));c.push(P,b,...h,...p,...w,...C,A);break}case"right":{const b=k.Add(o[1],new k(0,a*5-v/2,0)),P=k.Add(o[1],new k(S,a*5,0)),A=k.Add(o[1],new k(0,a*5+v/2,0));c.push(P,A,...w,...C,...h,...p,b);break}case"rightTop":{const b=k.Add(o[1],new k(0,a*1.1,0)),P=k.Add(o[1],new k(S,a*1.1+v/2,0)),A=k.Add(o[1],new k(0,a*1.1+v,0));c.push(P,A,...w,...C,...h,...p,b);break}case"rightBottom":{const b=k.Sub(o[2],new k(0,a*1.1+v,0)),P=k.Sub(o[2],new k(-S,a*1.1+v/2,0)),A=k.Sub(o[2],new k(0,a*1.1,0));c.push(P,A,...w,...C,...h,...p,b);break}}const x=Me(this.tmpPoints,e),L=[Math.floor(x.x+x.w/2),Math.floor(x.y+x.h/2)];return{rect:x,pos:L,points:c}}updateTempPoints(e){const t=e.slice(-2),s=new Q(t[0],t[1]),o=this.tmpPoints[0],{thickness:n}=this.workOptions;if(o.isNear(s,n)||Q.Sub(o,s).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(s.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=s}else this.tmpPoints.push(s);return!0}consumeService(e){var l,u;const{op:t,isFullWork:s,workState:o=j.Done}=e,n=(l=this.workId)==null?void 0:l.toString();if(!n)return;this.tmpPoints.length=0;for(let h=0;h<t.length;h+=3)this.tmpPoints.push(new Q(t[h],t[h+1],t[h+2]));const a=s?this.fullLayer:this.drawLayer||this.fullLayer,c=this.draw({workId:n,layer:a,isDrawing:!1,isDrawEraserlines:o===j.Done});return this.oldRect=c,(u=this.vNodes)==null||u.setInfo(n,{rect:c,op:t,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:c&&U.getCenterPos(c,a)}),c}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var p;const{node:t,opt:s,vNodes:o}=e,{strokeColor:n,fillColor:a,toolsType:c,placement:l,strokeType:u}=s,h=o.get(t.name),d=h==null?void 0:h.opt;let g=t;return t.tagName==="GROUP"&&(g=t.children[0]),n&&(g.setAttribute("strokeColor",n),d!=null&&d.strokeColor&&(d.strokeColor=n)),a&&(a==="transparent"?g.setAttribute("fillColor","rgba(0,0,0,0)"):g.setAttribute("fillColor",a),d!=null&&d.fillColor&&(d.fillColor=a)),c===T.SpeechBalloon&&l&&(d.placement=l),u&&(h!=null&&h.opt)&&((p=h.opt)!=null&&p.strokeType)&&(h.opt.strokeType=u),h&&o.setInfo(t.name,{...h,opt:d}),U.updateNodeOpt(e)}}var yf=kt,mf=at,wf="[object Boolean]";function If(r){return r===!0||r===!1||mf(r)&&yf(r)==wf}var Tf=If;const Pt=Ut(Tf);class hn extends U{constructor(e){super(e);M(this,"canRotate",!1);M(this,"scaleType",ce.both);M(this,"toolsType",T.Straight);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"straightTipWidth");M(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.straightTipWidth=this.workOptions.thickness/2,this.syncTimestamp=0,this.syncUnitTime=50}consume(e){const{data:t,isFullWork:s,isSubWorker:o,isMainThread:n}=e,a=this.workId,{op:c,syncUnitTime:l}=t,u=c==null?void 0:c.length;if(!u||u<2)return{type:D.None};l&&(this.syncUnitTime=l);let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new Q(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:D.None};let d;if(o||n){const p=s?this.fullLayer:this.drawLayer||this.fullLayer;d=this.draw({workId:a,layer:p})}if(!o){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{type:D.DrawWork,dataType:B.Local,op:this.tmpPoints.map(f=>[...f.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:D.None}}const g=ue(d,this.oldRect);return this.oldRect=d,{rect:g,type:D.DrawWork,dataType:B.Local,...this.baseConsumeResult}}consumeAll(){var a;const e=this.workId;if(this.tmpPoints.length<2)return{type:D.RemoveNode,removeIds:[e]};const t=this.fullLayer,s=this.draw({workId:e,layer:t});this.oldRect=s;const o=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=Be(o);return(a=this.vNodes)==null||a.setInfo(e,{rect:s,op:o,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:s&&U.getCenterPos(s,t)}),{rect:s,type:D.FullWork,dataType:B.Local,ops:n,isSync:!0,...this.baseConsumeResult}}draw(e){const{workId:t,layer:s,isDrawEraserlines:o=!0}=e,{strokeColor:n,thickness:a,zIndex:c,scale:l,rotate:u,translate:h,strokeType:d,eraserlines:g}=this.workOptions,p=s.worldPosition,f=s.worldScaling,{d:m,rect:w,isDot:I}=this.computDrawPoints(a,d),N=[w.x+w.w/2,w.y+w.h/2],C=new he.Group({pos:N,anchor:[.5,.5],size:[w.w,w.h],name:t,id:t,normalize:!0,zIndex:c}),S={pos:[0,0],normalize:!0,d:m,fillColor:n,strokeColor:n,lineDash:d===oe.Dotted&&!I?[1,a*2]:d===oe.LongDotted&&!I?[a,a*2]:void 0,lineCap:d===oe.Normal||I?void 0:"round",lineWidth:d===oe.Normal||I?0:a};l&&(S.scale=l),u&&(S.rotate=u),h&&(S.translate=h);const v=new he.Path(S);C.append(v),g&&(this.scaleType=ce.proportional,this.drawEraserlines({group:C,eraserlines:g,pos:N,layer:s},o)),this.replace(s,t,C);let x={x:Math.floor(w.x*f[0]+p[0]-U.SafeBorderPadding),y:Math.floor(w.y*f[1]+p[1]-U.SafeBorderPadding),w:Math.floor(w.w*f[0]+2*U.SafeBorderPadding),h:Math.floor(w.h*f[1]+2*U.SafeBorderPadding)};if(u||l||h){const L=v.getBoundingClientRect();x={x:Math.floor(L.x-U.SafeBorderPadding),y:Math.floor(L.y-U.SafeBorderPadding),w:Math.floor(L.width+U.SafeBorderPadding*2),h:Math.floor(L.height+U.SafeBorderPadding*2)}}return this.isDelete&&C.setAttribute("opacity",0),x}computDrawPoints(e,t){return this.tmpPoints[1].distance(this.tmpPoints[0])>this.straightTipWidth?this.computFullPoints(e,t):this.computDotPoints(e)}computFullPoints(e,t){const s=k.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),o=k.Per(s).mul(e/2),n=Q.Sub(this.tmpPoints[0],o),a=Q.Add(this.tmpPoints[0],o),c=Q.Sub(this.tmpPoints[1],o),l=Q.Add(this.tmpPoints[1],o),u=Q.GetSemicircleStroke(this.tmpPoints[1],c,-1,8),h=Q.GetSemicircleStroke(this.tmpPoints[0],a,-1,8),d=[n,c,...u,l,a,...h];let g;return t!==oe.Normal?g=rt(this.tmpPoints,!1):g=rt(d,!0),{d:g,rect:Me(d),isDot:!1,pos:this.tmpPoints[0].XY}}computDotPoints(e){const t=Q.GetDotStroke(this.tmpPoints[0],e/2,8);return{d:rt(t,!0),rect:Me(t),isDot:!0,pos:this.tmpPoints[0].XY}}updateTempPoints(e){const t=e.slice(-2),s=new Q(t[0],t[1]),o=this.tmpPoints[0],{thickness:n}=this.workOptions;if(o.isNear(s,n))return!1;if(this.tmpPoints.length===2){if(s.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=s}else this.tmpPoints.push(s);return!0}consumeService(e){var l,u;const{op:t,isFullWork:s,workState:o=j.Done}=e,n=(l=this.workId)==null?void 0:l.toString();if(!n)return;this.tmpPoints.length=0;for(let h=0;h<t.length;h+=3)this.tmpPoints.push(new Q(t[h],t[h+1],t[h+2]));const a=s?this.fullLayer:this.drawLayer||this.fullLayer,c=this.draw({workId:n,layer:a,isDrawEraserlines:o===j.Done});return this.oldRect=c,(u=this.vNodes)==null||u.setInfo(n,{rect:c,op:t,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:c&&U.getCenterPos(c,a)}),c}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var l,u;const{node:t,opt:s,vNodes:o}=e,{strokeColor:n,strokeType:a}=s,c=o.get(t.name);return n&&(t.tagName==="GROUP"?t.children.forEach(h=>{h.setAttribute("strokeColor",n),h.getAttribute("fillColor")&&h.setAttribute("fillColor",n)}):(t.setAttribute("strokeColor",n),t.setAttribute("fillColor",n)),(l=c==null?void 0:c.opt)!=null&&l.strokeColor&&(c.opt.strokeColor=n)),a&&(c!=null&&c.opt)&&((u=c.opt)!=null&&u.strokeType)&&(c.opt.strokeType=a),c&&o.setInfo(t.name,c),U.updateNodeOpt(e)}}const ft=class ft extends U{constructor(e){super(e);M(this,"canRotate",!1);M(this,"scaleType",ce.proportional);M(this,"toolsType",T.Text);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");this.workOptions=e.toolsOpt}consume(){return{type:D.None}}consumeAll(){return{type:D.None}}consumeService(){}async draw(e){const{workId:t,layer:s,isDrawLabel:o}=e,{boxSize:n,boxPoint:a,zIndex:c}=this.workOptions,l=s.worldPosition,u=s.worldScaling;if(!a||!n)return;const h={name:t,id:t,pos:[a[0],a[1]],anchor:[0,0],size:n,zIndex:c},d=new he.Group(h),g={x:a[0],y:a[1],w:n[0],h:n[1]},p={x:Math.floor(g.x*u[0]+l[0]),y:Math.floor(g.y*u[1]+l[1]),w:Math.floor(g.w*u[0])+2,h:Math.floor(g.h*u[1])+2};if(this.replace(s,t,d),o&&s&&this.workOptions.text){const f=await ft.createLabels(this.workOptions,s,p),{labels:m,maxWidth:w}=f;d.append(...m),p.w=Math.ceil(Math.max(w*s.worldScaling[0],p.w))}return p}async consumeServiceAsync(e){var l,u,h,d;const t=(l=this.workId)==null?void 0:l.toString();if(!t)return;const{isFullWork:s,replaceId:o,isDrawLabel:n}=e;this.oldRect=o&&((h=(u=this.vNodes)==null?void 0:u.get(o))==null?void 0:h.rect)||void 0;const a=s?this.fullLayer:this.drawLayer||this.fullLayer,c=await this.draw({workId:t,layer:a,isDrawLabel:typeof n>"u"&&this.workOptions.workState===j.Done||n});return(d=this.vNodes)==null||d.setInfo(t,{rect:c,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:c&&U.getCenterPos(c,a)}),c}updataOptService(){}async updataOptServiceAsync(e,t){var p,f;if(!this.workId)return;const s=this.workId.toString(),{fontColor:o,fontBgColor:n,bold:a,italic:c,lineThrough:l,underline:u,zIndex:h}=e,d=(p=this.vNodes)==null?void 0:p.get(s);if(!d)return;o&&(d.opt.fontColor=o),n&&(d.opt.fontBgColor=n),a&&(d.opt.bold=a),c&&(d.opt.italic=c),Pt(l)&&(d.opt.lineThrough=l),Pt(u)&&(d.opt.underline=u),ze(h)&&(d.opt.zIndex=h),this.oldRect=d.rect;const g=await this.draw({workId:s,layer:this.fullLayer,isDrawLabel:typeof t>"u"&&this.workOptions.workState===j.Done||t});return(f=this.vNodes)==null||f.setInfo(s,{rect:g,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:g&&U.getCenterPos(g,this.fullLayer)}),g}clearTmpPoints(){this.tmpPoints.length=0}static getSafetySnippetRatio(e){const t=(e==null?void 0:e.parent).displayRatio||1,s=Math.ceil(e.worldScaling[0]*10)/10;let o=s;return s>=.2&&s<1?o=s*t:s<=2&&s>=1?o=s*t*1.6:s>2&&s<=3?o=s*t*1.4:s>3&&s<=4?o=s*t*.8:s>4&&(o=s*t*.6),Math.floor(o*1e3)/1e3}static getSafetySnippetFontLength(e){return Math.floor(ft.textImageSnippetSize*3/4/e)||1}static async createLabels(e,t,s){var A;const o=[],{x:n,y:a}=s,{width:c,height:l}=(A=t.parent)==null?void 0:A.parent,u=Dt(e.text),h=u.length,{fontSize:d,lineHeight:g,bold:p,textAlign:f,italic:m,fontFamily:w,verticalAlign:I,fontColor:N,fontBgColor:C,underline:S,lineThrough:v}=e,x=ft.getSafetySnippetRatio(t)||1,L=Math.floor(d*x),b=ft.getSafetySnippetFontLength(L);let P=0;for(let E=0;E<h;E++){const R=u[E],z=g||L*1.5;if(R){const Z=My(R),ee=[0,0],F=[0,d*1.2];I==="middle"&&(ee[1]=E*d*1.2+5);const X=[0,-d*.15];ee[0]=5;const te=Math.sin(Math.PI/180*20);let le=0;const se=[];let _=0;for(;_<Z;){f==="left"&&(X[0]=le),_===0&&m==="italic"&&(X[0]=X[0]-te/2*d);const de=R.slice(_,_+b),Fe={anchor:[0,0],pos:X,text:de,fontFamily:w,fontSize:L,lineHeight:z,strokeColor:N,fontWeight:p,fillColor:N,textAlign:f,fontStyle:m,scale:[1/x,1/x]},ke=new he.Label(Fe),q=await ke.textImageReady;let Le=!0;if(q){const Ue=q.rect&&q.rect[2],st=q.rect&&q.rect[3];if(Ue&&st){const H=Ue/x,K=st/x;le=H+le,m==="italic"&&(p==="bold"?le=le-te*d*1.2:le=le-te*d),((X[0]+ee[0]+H)*t.worldScaling[0]+n<=0||(X[0]+ee[0])*t.worldScaling[0]+n>=c||(X[1]+ee[1]+K)*t.worldScaling[1]+a<=0||(X[1]+ee[1])*t.worldScaling[1]+a>=l)&&(ke.disconnect(),Le=!1),Le&&se.push(ke)}}_+=b}F[0]=le,m==="italic"&&(F[0]=F[0]+te*d),P=Math.max(P,F[0]);let J=!0;if(((ee[0]+F[0])*t.worldScaling[0]+n<=0||ee[0]*t.worldScaling[0]+n>=c||(ee[1]+F[1])*t.worldScaling[0]+a<=0||ee[1]*t.worldScaling[1]+a>=l)&&(J=!1),J){if(S){const ke=Math.floor(d/10),q={normalize:!1,pos:[0,d*1.1+ke/2],lineWidth:ke,points:[0,0,Math.ceil(F[0]),0],strokeColor:N,className:"underline"},Le=new he.Polyline(q);se.push(Le)}if(v){const ke={normalize:!1,pos:[0,d*1.2/2],lineWidth:Math.floor(d/10),points:[0,0,Math.ceil(F[0]),0],strokeColor:N,className:"lineThrough"},q=new he.Polyline(ke);se.push(q)}const de={pos:ee,anchor:[0,0],size:F,bgcolor:C},Fe=new he.Group(de);Fe.append(...se),o.push(Fe)}}}return{labels:o,maxWidth:P}}static updateNodeOpt(e){const{node:t,opt:s,vNodes:o,targetNode:n}=e,{fontBgColor:a,fontColor:c,translate:l,originPoint:u,scenePoint:h,scale:d,bold:g,italic:p,lineThrough:f,underline:m,fontSize:w,textInfos:I,zIndex:N}=s,C=n&&Pe(n)||o.get(t.name);if(!C||!t.parent)return;const v=C.opt;if(ze(N)&&(t.setAttribute("zIndex",N),C.opt.zIndex=N),c&&v.fontColor&&(v.fontColor=c,t.children.forEach(x=>{x.tagName==="GROUP"&&x.children.forEach(L=>{L.tagName==="LABEL"?(L.setAttribute("fillColor",c),L.setAttribute("strokeColor",c)):L.tagName==="POLYLINE"&&L.setAttribute("strokeColor",c)})})),a&&v.fontBgColor&&(v.fontBgColor=a,t.children.forEach(x=>{x.tagName==="GROUP"&&x.setAttribute("bgcolor",a)})),g&&(v.bold=g),p&&(v.italic=p),Pt(f)&&(v.lineThrough=f),Pt(m)&&(v.underline=m),w&&(v.fontSize=w),u&&h&&d&&n&&v.boxPoint){const x=I==null?void 0:I.get(t.name);if(x){const{fontSize:A,boxSize:E}=x;v.boxSize=E||v.boxSize,v.fontSize=A||v.fontSize}const L=[v.boxPoint[0],v.boxPoint[1]];ms(v.boxPoint,h,d,l);const b=[C.op[0],C.op[1]],P=[b[0]-L[0],b[1]-L[1]];if(C.centerPos=[C.centerPos[0]+P[0],C.centerPos[1]+P[1]],C.opt.eraserlines)for(const A of Object.values(C.opt.eraserlines)){const{op:E,thickness:R}=A;A.thickness=R*Math.max(d[0],d[1]);for(let z=0;z<E.length;z++)ws(E[z],h,d,l)}}else if(l&&v.boxPoint&&(v.boxPoint=[v.boxPoint[0]+l[0],v.boxPoint[1]+l[1]],C.centerPos=[C.centerPos[0]+l[0],C.centerPos[1]+l[1]],C.opt.eraserlines))for(const x of Object.values(C.opt.eraserlines)){const{op:L}=x;for(let b=0;b<L.length;b++){const P=L[b].map((A,E)=>E%2?A+l[1]:A+l[0]);x.op[b]=P}}return C&&o.setInfo(t.name,C),C==null?void 0:C.rect}static getRectFromLayer(e,t){const s=e.getElementsByName(t)[0];if(s){const o=s.getBoundingClientRect();let n={x:Math.floor(o.x),y:Math.floor(o.y),w:Math.floor(o.width+2),h:Math.floor(o.height+2)};return s.children.forEach(a=>{if(a.tagName==="GROUP"){const c=s.getBoundingClientRect();n=ue(n,{x:Math.floor(c.x),y:Math.floor(c.y),w:Math.floor(c.width+2),h:Math.floor(c.height+2)})}}),n}}};M(ft,"textImageSnippetSize",1024*4),M(ft,"SafeBorderPadding",30);let fi=ft;const Et=class Et extends U{constructor(e){super(e);M(this,"canRotate",!1);M(this,"scaleType",ce.none);M(this,"toolsType",T.PencilEraser);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"worldPosition");M(this,"worldScaling");M(this,"eraserRect");M(this,"eraserPolyline");M(this,"syncUnitTime",Ie.syncOpt.interval);M(this,"syncIndex",0);M(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.worldPosition=this.fullLayer.worldPosition,this.worldScaling=this.fullLayer.worldScaling,this.syncTimestamp=0}combineConsume(){if(this.tmpPoints.length<2)return{type:D.None};const{thickness:e}=this.workOptions,{width:t,height:s}=Et.eraserSizes[e],o=Math.max(t,s)/this.worldScaling[0],n=this.drawLayer||this.fullLayer,a=this.workId,c={name:a};return{rect:this.draw({attrs:c,consumePoints:this.tmpPoints,replaceId:a,layer:n,thickness:o}),type:D.DrawWork,dataType:B.Local}}consumeService(e){const{op:t,isFullWork:s,replaceId:o}=e;this.tmpPoints.length=0;for(let h=0;h<t.length;h+=3){const d=new Q(t[h],t[h+1],t[h+2]);if(this.tmpPoints.length>0){const g=this.tmpPoints[this.tmpPoints.length-1],p=k.Sub(d,g).uni();d.setv(p)}this.tmpPoints.push(d)}if(this.tmpPoints.length<2)return;const n=this.tmpPoints[0].z*2,a=s?this.fullLayer:this.drawLayer||this.fullLayer,l={name:this.workId};return this.draw({attrs:l,consumePoints:this.tmpPoints,layer:a,thickness:n,replaceId:o})}updateTempPoints(e,t){let s=this.tmpPoints.length-1;const o=Date.now();for(let n=0;n<e.length;n+=2){const a=this.tmpPoints.length,c=new Q(e[n],e[n+1]);if(a===0){this.tmpPoints.push(c);continue}const l=a-1,u=this.tmpPoints[l],h=k.Sub(c,u).uni();c.isNear(u,t/2)||(k.Equals(h,u.v,.02)&&(this.tmpPoints.pop(),s--),c.setv(h),c.setT(o),this.tmpPoints.push(c))}return Math.max(s,0)}getChangeNodes(e,t){const s=new Map,o=new Set;let n;if(!this.vNodes)return{willDeleteNodes:o,willNewNodes:s,rect:n};const a=this.worldPosition;let c=Me(this.tmpPoints,e);c=_t(c,a),c=wn(c,this.worldScaling,a);const{nodeRange:l}=this.vNodes.getRectIntersectRange(c);if(!l.size)return{willDeleteNodes:o,willNewNodes:s,rect:n};const u=this.computEraserPointLines(this.tmpPoints,90);for(const[h,d]of l.entries()){if(d.toolsType!==T.Pencil)continue;let g=_t(d.rect,[-a[0],-a[1]]);g={x:g.x/this.worldScaling[0],y:g.y/this.worldScaling[1],w:g.w/this.worldScaling[0],h:g.h/this.worldScaling[1]};const p=[g.x,g.y,g.x+g.w,g.y+g.h],f=[],m=[];for(const w of u)es.polyline(w,p,f);if(f.length&&d.opt)for(const w of f){const I=[];for(let N=0;N<w.length;N++)N!==0&&lt(w[N],w[N-1])||I.push(...w[N]);m.push(I)}if(m.length&&t){const w=t.createWorkShapeNode({workId:h,toolsType:T.Pencil,toolsOpt:d.opt});w.setWorkId(h);const I=w==null?void 0:w.computPencilPoints({op:d.op,eraserPolylines:m,eraserThickness:e});if(n=ue(n,d.rect),o.add(h),t.removeNode(h),I.length)for(let N=0;N<I.length;N++){const C=`${h}_${Date.now()}_${N}`,S=C,x=t.setFullWork({workId:S,opt:d.opt,toolsType:T.Pencil}).consumeService({op:I[N],isFullWork:!0,replaceId:S});t.clearWorkShapeNodeCache(S),n=ue(n,x),s.set(C,{...d,rect:x??d.rect,name:C,op:I[N]})}}}return{willNewNodes:s,willDeleteNodes:o,rect:n}}consume(e){const{data:t,isFullWork:s,isSubWorker:o,isMainThread:n,removeDrawCount:a,drawCount:c}=e,{op:l,syncUnitTime:u}=t;if(!l||l.length===0)return{type:D.None,...this.baseConsumeResult};u&&(this.syncUnitTime=u);const{thickness:h}=this.workOptions,{width:d,height:g}=Et.eraserSizes[h],p=Math.max(d,g)/this.worldScaling[0],f=this.tmpPoints.length,m=this.tmpPoints[this.tmpPoints.length-1],w=this.updateTempPoints(l,p),I=this.tmpPoints[this.tmpPoints.length-1];if(f===this.tmpPoints.length&&I.equalsXY(m.x,m.y))return{type:D.None,...this.baseConsumeResult};this.syncIndex=Math.min(this.syncIndex,w,Math.max(0,this.tmpPoints.length-2));const N={name:this.workId,id:ze(c)&&c.toString()||void 0},C=this.syncIndex;this.syncTimestamp===0&&(this.syncTimestamp=Date.now());let S=!1,v;const x=this.tmpPoints.slice(w);if(o||n){const b=s?this.fullLayer:this.drawLayer||this.fullLayer;v=this.draw({attrs:N,consumePoints:x,layer:b,removeDrawCount:a,thickness:p})}if(o)return w>10&&this.tmpPoints.splice(0,w-10),{rect:v,type:D.DrawWork,dataType:B.Local};x[0].t-this.syncTimestamp>this.syncUnitTime&&(S=!0,this.syncTimestamp=x[0].t,this.syncIndex=this.tmpPoints.length);const L=[];return this.tmpPoints.slice(C).forEach(b=>{L.push(b.x,b.y,p/2)}),{...this.baseConsumeResult,type:D.DrawWork,dataType:B.Local,rect:v,op:S?L:void 0,index:S?C*3:void 0,updateNodeOpt:{useAnimation:!0}}}draw(e){const{attrs:t,consumePoints:s,layer:o,thickness:n,replaceId:a,removeDrawCount:c}=e;c&&this.removeDrawCountNodes(o,c);let l=Me(s,n);l={x:Math.floor(l.x*this.worldScaling[0]+this.worldPosition[0]-U.SafeBorderPadding),y:Math.floor(l.y*this.worldScaling[1]+this.worldPosition[1]-U.SafeBorderPadding),w:Math.floor(l.w*this.worldScaling[0]+2*U.SafeBorderPadding),h:Math.floor(l.h*this.worldScaling[1]+2*U.SafeBorderPadding)};const u=new he.Group({...t,normalize:!0,pos:[0,0],anchor:[.5,.5],zIndex:9999,bgcolor:this.workOptions.eraserColor}),h=this.computEraserPointLines(s,90),d=[];for(const g of h)d.push({op:g,thickness:n});for(const g of d){const{thickness:p,op:f}=g,m=f.reduce((S,v,x,L)=>x>0&&L[x-1][0]===v[0]&&L[x-1][1]===v[1]?S:S.concat(v[0],v[1]),[]),w=this.computEraserPoints(m,p),I=rt(w,!0),N={pos:[0,0],d:I,fillColor:this.workOptions.eraserColor},C=new he.Path(N);u.append(C),u.seal()}return this.replace(o,a,u),l}computEraserPointLines(e,t=60){const s=[];let o=0;const n=360-t;for(let a=1;a<e.length;a++){const c=e[a-1],l=e[a];if(a===1&&o===0&&(s[o]=[c.XY]),s[o].push(l.XY),a<e.length-1){const u=l.getAngleByPoints(c,e[a+1]);(u<t||u>n)&&(o++,s[o]=[l.XY])}}return e.length===1&&s.length===0&&s.push([e[0].XY,e[0].XY]),s}consumeAll(e){const{workerEngine:t}=e;if(this.replace(this.fullLayer,this.workId),!this.tmpPoints.length)return{type:D.None,...this.baseConsumeResult};const{thickness:s}=this.workOptions,{width:o,height:n}=Et.eraserSizes[s],a=Math.max(o,n)/this.worldScaling[0],{willDeleteNodes:c,willNewNodes:l,rect:u}=this.getChangeNodes(a,t);if(c.size===0&&l.size===0)return{type:D.FullWork,...this.baseConsumeResult,rect:u};const h=[];this.tmpPoints.map(g=>{h.push(g.x,g.y,a/2)});const d=Be(h);return{...this.baseConsumeResult,type:D.FullWork,dataType:B.Local,rect:u,ops:d,willNewNodes:l,willDeleteNodes:c}}clearTmpPoints(){this.tmpPoints.length=0}};M(Et,"eraserSizes",ds);let Mi=Et;const Ot=class Ot extends U{constructor(e){super(e);M(this,"canRotate",!1);M(this,"scaleType",ce.none);M(this,"toolsType",T.BitMapEraser);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"worldPosition");M(this,"worldScaling");M(this,"eraserRect");M(this,"eraserPolyline");M(this,"syncUnitTime",Ie.syncOpt.interval);M(this,"syncIndex",0);M(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.worldPosition=this.fullLayer.worldPosition,this.worldScaling=this.fullLayer.worldScaling,this.syncTimestamp=0}combineConsume(){if(this.tmpPoints.length<2)return{type:D.None};const{thickness:e}=this.workOptions,{width:t,height:s}=Ot.eraserSizes[e],o=Math.max(t,s)/this.worldScaling[0],n=this.drawLayer||this.fullLayer,a=this.workId,c={name:a};return{rect:this.draw({attrs:c,consumePoints:this.tmpPoints,replaceId:a,layer:n,thickness:o}),type:D.DrawWork,dataType:B.Local}}consumeService(e){const{op:t,isFullWork:s,replaceId:o}=e;this.tmpPoints.length=0;for(let h=0;h<t.length;h+=3){const d=new Q(t[h],t[h+1],t[h+2]);if(this.tmpPoints.length>0){const g=this.tmpPoints[this.tmpPoints.length-1],p=k.Sub(d,g).uni();d.setv(p)}this.tmpPoints.push(d)}if(this.tmpPoints.length<2)return;const n=this.tmpPoints[0].z*2,a=s?this.fullLayer:this.drawLayer||this.fullLayer,l={name:this.workId};return this.draw({attrs:l,consumePoints:this.tmpPoints,layer:a,thickness:n,replaceId:o})}updateTempPoints(e,t){let s=this.tmpPoints.length-1;const o=Date.now();for(let n=0;n<e.length;n+=2){const a=this.tmpPoints.length,c=new Q(e[n],e[n+1]);if(a===0){this.tmpPoints.push(c);continue}const l=a-1,u=this.tmpPoints[l],h=k.Sub(c,u).uni();c.isNear(u,t/2)||(k.Equals(h,u.v,.02)&&(this.tmpPoints.pop(),s--),c.setv(h),c.setT(o),this.tmpPoints.push(c))}return Math.max(s,0)}getChangeNodes(e,t){const s=new Map,o=new Set;let n;if(!this.vNodes)return{willDeleteNodes:o,willUpdateNodes:s,rect:n};const a=this.worldPosition;let c=Me(this.tmpPoints,e);c=_t(c,a),c=wn(c,this.worldScaling,a);const{nodeRange:l}=this.vNodes.getRectIntersectRange(c);if(!l.size)return{willDeleteNodes:o,willUpdateNodes:s,rect:n};const u=this.computEraserPointLines(this.tmpPoints);for(const[h,d]of l.entries()){if(d.toolsType===T.Text||d.toolsType===T.Image)continue;let g=_t(d.rect,[-a[0],-a[1]]);g={x:g.x/this.worldScaling[0],y:g.y/this.worldScaling[1],w:g.w/this.worldScaling[0],h:g.h/this.worldScaling[1]};const p=[g.x,g.y,g.x+g.w,g.y+g.h],f=[],m=[];for(const I of u)es.polyline(I,p,f);if(f.length&&d.opt)for(const I of f){const N=[];for(let C=0;C<I.length&&!(isNaN(I[C][0])||isNaN(I[C][1]));C++)C!==0&&lt(I[C],I[C-1])||N.push(...I[C]);N.length!==0&&m.push(N)}if(d.opt.eraserlines||(d.opt.eraserlines=[]),d.opt.eraserlines){if(d.opt.eraserlines.push({op:m,thickness:e}),t){const{toolsType:I}=d,N=t.createWorkShapeNode({workId:h,toolsType:I,toolsOpt:d.opt});N==null||N.setWorkId(h);const C=N==null?void 0:N.consumeService({op:d.op,isFullWork:!0,replaceId:h});if(n=ue(n,C),N!=null&&N.isDelete){t.removeNode(h),o.add(h);continue}}s.set(h,d)}}return{willUpdateNodes:s,willDeleteNodes:o,rect:n}}consume(e){const{data:t,isFullWork:s,isSubWorker:o,isMainThread:n,removeDrawCount:a,drawCount:c}=e,{op:l,syncUnitTime:u}=t;if(!l||l.length===0)return{type:D.None,...this.baseConsumeResult};u&&(this.syncUnitTime=u);const{thickness:h}=this.workOptions,{width:d,height:g}=Ot.eraserSizes[h],p=Math.max(d,g)/this.worldScaling[0],f=this.tmpPoints.length,m=this.tmpPoints[this.tmpPoints.length-1],w=this.updateTempPoints(l,p),I=this.tmpPoints[this.tmpPoints.length-1];if(f===this.tmpPoints.length&&I.equalsXY(m.x,m.y))return{type:D.None,...this.baseConsumeResult};this.syncIndex=Math.min(this.syncIndex,w,Math.max(0,this.tmpPoints.length-2));const N={name:this.workId,id:ze(c)&&c.toString()||void 0},C=this.syncIndex;this.syncTimestamp===0&&(this.syncTimestamp=Date.now());let S=!1,v;const x=this.tmpPoints.slice(w);if(o||n){const b=s?this.fullLayer:this.drawLayer||this.fullLayer;v=this.draw({attrs:N,consumePoints:x,layer:b,removeDrawCount:a,thickness:p})}if(o)return w>10&&this.tmpPoints.splice(0,w-10),{rect:v,type:D.DrawWork,dataType:B.Local};x[0].t-this.syncTimestamp>this.syncUnitTime&&(S=!0,this.syncTimestamp=x[0].t,this.syncIndex=this.tmpPoints.length);const L=[];return this.tmpPoints.slice(C).forEach(b=>{L.push(b.x,b.y,p/2)}),{...this.baseConsumeResult,type:D.DrawWork,dataType:B.Local,rect:v,op:S?L:void 0,index:S?C*3:void 0,updateNodeOpt:{useAnimation:!0}}}draw(e){const{attrs:t,consumePoints:s,layer:o,thickness:n,replaceId:a,removeDrawCount:c}=e;c&&this.removeDrawCountNodes(o,c);let l=Me(s,n);l={x:Math.floor(l.x*this.worldScaling[0]+this.worldPosition[0]-U.SafeBorderPadding),y:Math.floor(l.y*this.worldScaling[1]+this.worldPosition[1]-U.SafeBorderPadding),w:Math.floor(l.w*this.worldScaling[0]+2*U.SafeBorderPadding),h:Math.floor(l.h*this.worldScaling[1]+2*U.SafeBorderPadding)};const u=new he.Group({...t,normalize:!0,pos:[0,0],anchor:[.5,.5],zIndex:9999,bgcolor:this.workOptions.eraserColor}),h=this.computEraserPointLines(s),d=[];for(const g of h)d.push({op:g,thickness:n});for(const g of d){const{thickness:p,op:f}=g,m=f.reduce((S,v,x,L)=>x>0&&L[x-1][0]===v[0]&&L[x-1][1]===v[1]?S:S.concat(v[0],v[1]),[]),w=this.computEraserPoints(m,p),I=rt(w,!0),N={pos:[0,0],d:I,fillColor:this.workOptions.eraserColor},C=new he.Path(N);u.append(C),u.seal()}return this.replace(o,a,u),l}computEraserPointLines(e,t=60){const s=[];let o=0;const n=360-t;for(let a=1;a<e.length;a++){const c=e[a-1],l=e[a];if(a===1&&o===0&&(s[o]=[c.XY]),s[o].push(l.XY),a<e.length-1){const u=l.getAngleByPoints(c,e[a+1]);(u<t||u>n)&&(o++,s[o]=[l.XY])}}return e.length===1&&s.length===0&&s.push([e[0].XY,e[0].XY]),s}consumeAll(e){const{workerEngine:t}=e;if(this.replace(this.fullLayer,this.workId),!this.tmpPoints.length)return{type:D.None,...this.baseConsumeResult};const{thickness:s}=this.workOptions,{width:o,height:n}=Ot.eraserSizes[s],a=Math.max(o,n)/this.worldScaling[0],{willDeleteNodes:c,willUpdateNodes:l,rect:u}=this.getChangeNodes(a,t);if(c.size===0&&l.size===0)return{type:D.FullWork,...this.baseConsumeResult,rect:u};const h=[];this.tmpPoints.map(g=>{h.push(g.x,g.y,a/2)});const d=Be(h);return{...this.baseConsumeResult,type:D.FullWork,dataType:B.Local,rect:u,ops:d,willUpdateNodes:l,willDeleteNodes:c}}clearTmpPoints(){this.tmpPoints.length=0}};M(Ot,"eraserSizes",ds);let yi=Ot;function un(r){switch(r){case T.Arrow:return on;case T.Pencil:return _o;case T.Straight:return hn;case T.Ellipse:return nn;case T.Polygon:case T.Triangle:return cn;case T.Star:case T.Rhombus:return an;case T.Rectangle:return rn;case T.SpeechBalloon:return ln;case T.Text:return fi;case T.LaserPen:return en;case T.Eraser:return di;case T.PencilEraser:return Mi;case T.BitMapEraser:return yi;case T.Selector:return gi;case T.Image:return Kt}}function ji(r,i){const{toolsType:e,...t}=r;switch(e){case T.Arrow:return new on(t);case T.Pencil:return new _o(t);case T.Straight:return new hn(t);case T.Ellipse:return new nn(t);case T.Polygon:case T.Triangle:return new cn(t);case T.Star:case T.Rhombus:return new an(t);case T.Rectangle:return new rn(t);case T.SpeechBalloon:return new ln(t);case T.Text:return new fi(t);case T.LaserPen:return new en(t);case T.Eraser:return new di(t,i);case T.BitMapEraser:return new yi(t);case T.PencilEraser:return new Mi(t);case T.Selector:return t.vNodes?new gi({...t,vNodes:t.vNodes,drawLayer:t.fullLayer}):void 0;case T.Image:return new Kt(t);default:return}}function dn(r){const i=[],e=["PATH","SPRITE","POLYLINE","RECT","ELLIPSE","LABEL"];for(const t of r){if(t.tagName==="GROUP"&&t.children.length){const s=dn(t.children);i.push(...s)}t.tagName&&e.includes(t.tagName)&&i.push(t)}return i}const vf="cursorhover",Ms=20,ge="mainView";class pn{constructor(i,e){M(this,"viewId");M(this,"scene");M(this,"fullLayer");M(this,"curNodeMap",new Map);M(this,"targetNodeMap",[]);M(this,"highLevelIds");M(this,"canClearUids");M(this,"localUid");this.viewId=i,this.scene=e}init(i){this.fullLayer=i}get(i){return this.curNodeMap.get(i)}setLocalUid(i){this.localUid=i}getLocalUid(){return this.localUid}setCanClearUids(i){this.canClearUids=i}getCanClearUids(){return this.canClearUids}getCanEraserNodes(i,e){const t=new Map;for(const[s,o]of i.entries())o.toolsType===T.Image&&(o.opt.locked||e&&e.disableEraseImage)||o.toolsType===T.Text&&(o.opt.workState===j.Doing||o.opt.workState===j.Start||e&&e.disableEraseText)||this.isCanClearWorkId(s)&&t.set(s,o);return t}getNodesByType(i){const e=new Map;return this.curNodeMap.forEach((t,s)=>{t.toolsType===i&&e.set(s,t)}),e}gethasEraserNodes(){const i=new Map;return this.curNodeMap.forEach((e,t)=>{var s;(s=e.opt.eraserlines)!=null&&s.length&&i.set(t,e)}),i}hasRenderNodes(){return!0}has(i){return this.curNodeMap.has(i)}setInfo(i,e){const t=this.curNodeMap.get(i)||{name:i,rect:e.rect};e.rect&&(t.rect=Pe(e.rect)),e.op&&ly(e.op)&&(t.op=Pe(e.op)),e.canRotate&&(t.canRotate=e.canRotate),e.scaleType&&(t.scaleType=e.scaleType),e.opt&&(t.opt=Pe(e.opt)),e.toolsType&&(t.toolsType=e.toolsType),e.centerPos&&(t.centerPos=Pe(e.centerPos)),Pt(e.isSelected)&&(t.isSelected=e.isSelected),t.rect?this.curNodeMap.set(i,t):this.curNodeMap.delete(i)}selected(i){this.setInfo(i,{isSelected:!0})}unSelected(i){this.setInfo(i,{isSelected:!1})}delete(i){this.curNodeMap.delete(i)}clear(){this.curNodeMap.clear(),this.targetNodeMap.length=0}getRectIntersectRange(i,e=!0,t=!0){let s;const o=new Map;for(const[n,a]of this.curNodeMap.entries())if($i(i,a.rect)){if(e&&a.toolsType===T.Image&&a.opt.locked||t&&a.toolsType===T.Text&&(a.opt.workState===j.Doing||a.opt.workState===j.Start))continue;s=ue(s,a.rect),o.set(n,a)}return{rectRange:s,nodeRange:o}}getNodeRectFormShape(i,e){const t=un(e.toolsType);return this.fullLayer&&(t==null?void 0:t.getRectFromLayer(this.fullLayer,i))}updateNodeRect(i){const e=this.curNodeMap.get(i);if(e){const t=this.getNodeRectFormShape(i,e);if(!t){this.curNodeMap.delete(i);return}e.rect=t,this.curNodeMap.set(i,e)}}updateHighLevelNodesRect(i){this.highLevelIds=i;for(const e of this.highLevelIds.keys())this.updateNodeRect(e)}updateLowLevelNodesRect(){var i;for(const e of this.curNodeMap.keys())(i=this.highLevelIds)!=null&&i.has(e)||this.updateNodeRect(e)}clearHighLevelIds(){this.highLevelIds=void 0}setTargetAssignKeys(i){const e=new Map;for(const t of i){const s=this.curNodeMap.get(t);s&&e.set(t,Pe(s))}return this.targetNodeMap.push(Pe(e)),this.targetNodeMap.length-1}setTarget(){return this.targetNodeMap.push(Pe(this.curNodeMap)),this.targetNodeMap.length-1}getLastTarget(){return this.targetNodeMap[this.targetNodeMap.length-1]}deleteLastTarget(){this.targetNodeMap.length&&(this.targetNodeMap.length=this.targetNodeMap.length-1)}getTarget(i){return this.targetNodeMap[i]}deleteTarget(i){this.targetNodeMap.length=i}clearTarget(){this.targetNodeMap.length=0}isLocalWorkId(i){return i.split(He).length===1}isCanClearWorkId(i){if(this.canClearUids===void 0||this.canClearUids===!0)return!0;if(np(this.canClearUids)){const e=i.split(He);if(e.length===1)return this.canClearUids.has("localSelf")||this.localUid&&this.canClearUids.has(this.localUid);if(e.length===2)return this.canClearUids.has(e[0])}return!1}}class Nf{constructor(i,e,t){M(this,"viewId");M(this,"scene");M(this,"fullLayer");M(this,"vNodes");M(this,"dpr");M(this,"contextType");M(this,"opt");M(this,"cameraOpt");M(this,"isSafari",!1);M(this,"combinePostMsg",new Set);M(this,"workerTaskId");M(this,"protectedTask");M(this,"hasPriorityDraw",!0);M(this,"delayPostDoneResolve");M(this,"cacheImages",new Map);M(this,"imageResolveMap",new Map);M(this,"taskUpdateCameraId");M(this,"debounceUpdateCameraId");var s,o;if(this.viewId=i,this.opt=e,this.dpr=e.dpr,this.contextType=this.getSupportContextType(t,(s=e==null?void 0:e.offscreenCanvasOpt)==null?void 0:s.contextType),!this.contextType)throw new Error("Sorry, your browser doesn't support canvas context type 2d or webgl");try{this.createRenderLayer(e)}catch{if(this.contextType!=="2d")this.contextType="2d",(o=this.scene)==null||o.disconnect(),this.createRenderLayer(e);else throw new Error(`Sorry, your browser doesn't support canvas context type ${this.contextType}`)}this.vNodes=new pn(i,this.scene)}createRenderLayer(i){this.scene=this.createScene(i.offscreenCanvasOpt);const e=Ie.bufferSize.full,t=Ie.bufferSize.sub;this.fullLayer=this.createLayer("fullLayer",this.scene,{...i.layerOpt,bufferSize:this.viewId===ge?e:t*2})}async updateDpr(i){this.dpr=i,this.scene.displayRatio=i}getCachedImages(i){var e;return(e=this.cacheImages.get(i))==null?void 0:e.imageBitmap}getCachedImagesByWorkId(i){for(const[e,t]of this.cacheImages.entries())if(e===i&&t.imageBitmap)return t.imageBitmap}deleteCachedImagesByWorkId(i,e){for(const[t,s]of this.cacheImages.entries())e&&t===e||s.workId===i&&(s.imageBitmap.close(),this.cacheImages.delete(t))}clearCacheImages(){this.cacheImages.forEach(i=>i.imageBitmap.close()),this.cacheImages.clear()}clearImageResolveMap(){this.imageResolveMap.forEach(({timer:i})=>{i&&clearTimeout(i)}),this.imageResolveMap.clear()}setHasPriorityDraw(i){this.hasPriorityDraw=i}getPriorityDraw(){return this.hasPriorityDraw}setIsSafari(i){this.isSafari=i}async on(i){const{msgType:e,toolsType:t,opt:s,imageSrc:o,imageBitmap:n,workId:a,dpr:c}=i;switch(e){case D.UpdateDpr:ze(c)&&await this.updateDpr(c);break;case D.UpdateCamera:await this.updateCamera(i);break;case D.Destroy:this.destroy();break;case D.Clear:await this.clearAll();break;case D.UpdateTools:if(t&&s){const l={toolsType:t,toolsOpt:s,combineUnitTime:i.combineUnitTime};this.localWork.setToolsOpt(l)}break;case D.GetImageBitMap:if(o&&n&&a){const l=a.toString();this.cacheImages.set(o,{imageBitmap:n,workId:l});const u=this.imageResolveMap.get(o);if(u){const{resolve:h,timer:d}=u;d&&clearTimeout(d),h&&h(o)}this.deleteCachedImagesByWorkId(l,o)}break}}getIconSize(i,e,t){const s=i*t,o=e*t;return s<=50||o<=50?[50,50]:s<=100||o<=100?[100,100]:s<=200||o<=200?[200,200]:s<=400||o<=400?[400,400]:s<=800||o<=800?[800,800]:[1600,1600]}async loadImageBitMap(i){const{toolsType:e,opt:t,workId:s,isSubWorker:o}=i;if(e===T.Image&&t&&s){const n=s.toString(),{src:a,type:c,width:l,height:u,strokeColor:h}=t;if(!a||!c||!l||!u)return;let d=a;if(c===St.Iconify){const[m,w]=this.getIconSize(l,u,this.dpr);d=`${a}?width=${m}&height=${w}&color=${h}`}if(this.cacheImages.has(d)){const m=this.getCachedImages(d);if(m)return m}if(this.imageResolveMap.has(d)){const m=this.getCachedImagesByWorkId(n);if(m)return m}const f=await new Promise(m=>{const w=this.imageResolveMap.get(d)||{resolve:void 0,timer:void 0};w.timer&&clearTimeout(w.timer),w.resolve=m,w.timer=setTimeout(()=>{const I=this.imageResolveMap.get(d);I!=null&&I.resolve&&I.resolve(d)},5e3),this.imageResolveMap.set(d,w),this._post({sp:[{imageSrc:d,workId:n,viewId:this.viewId,isgl:!!this.fullLayer.parent.gl,isSubWorker:o,type:D.GetImageBitMap}]})});return this.imageResolveMap.delete(f),this.getCachedImages(d)}}createLocalWork(i){const{workId:e,opt:t,toolsType:s}=i;e&&t&&(!this.localWork.getToolsOpt()&&s&&this.setToolsOpt({toolsType:s,toolsOpt:t}),this.setWorkOpt({workId:e,toolsOpt:t}))}updateScene(i){this.scene.attr({...i});const{width:e,height:t}=i;this.scene.container.width=e,this.scene.container.height=t,this.scene.width=e,this.scene.height=t,this.updateLayer({width:e,height:t})}updateLayer(i){const{width:e,height:t}=i;this.fullLayer&&(this.fullLayer.parent.setAttribute("width",e),this.fullLayer.parent.setAttribute("height",t),this.fullLayer.setAttribute("size",[e,t]),this.fullLayer.setAttribute("pos",[e*.5,t*.5]))}getSupportContextType(i,e){const t=new OffscreenCanvas(100,100);let s=["2d"];i===Gi.Full&&this.viewId===ge&&(s=["webgl2","webgl","2d"],e&&s.unshift(e));for(const o of s)try{if(t.getContext(o))return o}catch{continue}}createScene(i){const{width:e,height:t}=i,s=new OffscreenCanvas(e,t);i.contextType&&delete i.contextType;const o=new he.Scene({container:s,displayRatio:this.dpr,depth:!1,desynchronized:!0,failIfMajorPerformanceCaveat:!0,...i,contextType:this.contextType,id:this.viewId});return o.setAttribute("id",this.viewId),o}createLayer(i,e,t){const{width:s,height:o}=t,n=`offscreen-${i}`,a=e.layer(n,t),c=new he.Group({anchor:[.5,.5],pos:[s*.5,o*.5],size:[s,o],name:"viewport",id:i});return a.append(c),c}async clearAll(){var i;this.fullLayer&&(this.fullLayer.parent.children.forEach(e=>{e.name!=="viewport"&&e.remove()}),Ve(this.fullLayer,this.fullLayer.parent)),this.taskUpdateCameraId&&(clearTimeout(this.taskUpdateCameraId),this.taskUpdateCameraId=void 0),this.debounceUpdateCameraId&&(clearTimeout(this.debounceUpdateCameraId),this.debounceUpdateCameraId=void 0),this.clearCacheImages(),this.clearImageResolveMap(),this.localWork.destroy(),(i=this.serviceWork)==null||i.destroy()}setToolsOpt(i){this.localWork.setToolsOpt(i)}setWorkOpt(i){const{workId:e,toolsOpt:t}=i;e&&t&&this.localWork.setWorkOptions(e.toString(),t)}destroy(){var i;this.vNodes.clear(),this.fullLayer.remove(),Ge(this.fullLayer,this.fullLayer.parent),this.clearCacheImages(),this.clearImageResolveMap(),this.scene.remove(),this.localWork.destroy(),(i=this.serviceWork)==null||i.destroy()}async post(i){this.combinePostMsg.add(i),await this.runBatchPostData()}async runBatchPostData(){this.workerTaskId||(this.workerTaskId=setTimeout(()=>{this.workerTaskId=void 0,this.combinePost()},16)),this.type===Gi.Full&&!this.delayPostDoneResolve&&await new Promise(e=>{this.delayPostDoneResolve=e})&&(this.delayPostDoneResolve=void 0)}combinePostData(){var a,c;this.workerTaskId=void 0;const i=[],e=[];let t,s,o;const n=new Set;for(const l of this.combinePostMsg.values()){if((a=l.render)!=null&&a.length)for(const u of l.render){let h=!1;if(u.workId&&n.add(u.workId),u.isClearAll&&(u.rect=this.getSceneRect(),u.isClear=!0,delete u.isClearAll),u.drawCanvas){const d=this.getLayer(u.drawCanvas);if(!d||!(d.parent instanceof he.Layer))continue;if(d.parent.render(),u.isDrawAll){const g=this.getSceneRect();u.rect=g,delete u.isDrawAll}}for(const d of i)if(u.viewId===d.viewId){u.isClear&&d.clearCanvas&&d.isClear&&d.clearCanvas===u.clearCanvas&&(d.rect=ue(d.rect,u.rect),h=!0),d.drawCanvas&&d.drawCanvas===u.drawCanvas&&(d.rect=ue(d.rect,u.rect),h=!0);continue}h||(u.isClear&&!u.drawCanvas?i.unshift(u):i.push(u))}if((c=l.sp)!=null&&c.length)for(const u of l.sp){let h=!1;for(const d of e)if(lt(u,d)){h=!0;break}h||e.push(u)}ze(l.fullWorkerDrawCount)&&(t=l.fullWorkerDrawCount),ze(l.subWorkerDrawCount)&&(s=l.subWorkerDrawCount),ze(l.consumeCount)&&(o=l.consumeCount)}return this.combinePostMsg.clear(),{render:i,sp:e,fullWorkerDrawCount:t,subWorkerDrawCount:s,consumeCount:o,workIds:n,viewId:this.viewId}}getSceneRect(){const{width:i,height:e}=this.scene;return{x:0,y:0,w:Math.floor(i),h:Math.floor(e)}}}class Sf{constructor(i){M(this,"viewId");M(this,"vNodes");M(this,"thread");M(this,"fullLayer");M(this,"drawLayer");M(this,"_post");M(this,"tmpOpt");M(this,"workShapes",new Map);M(this,"drawCount",0);M(this,"consumeCount",0);M(this,"syncUnitTime",Ie.syncOpt.interval);M(this,"combineUnitTime",Ie.bezier.combineUnitTime);this.thread=i.thread,this.viewId=i.viewId,this.vNodes=i.vNodes,this.fullLayer=i.fullLayer,this.drawLayer=i.drawLayer,this._post=this.thread.post.bind(i.thread)}setCombineUnitTime(i){this.combineUnitTime=i}setSyncUnitTime(i){this.syncUnitTime=i}destroy(){this.workShapes.clear()}getWorkShapes(){return this.workShapes}getWorkShape(i){return this.workShapes.get(i)}createWorkShape(i,e){if(i&&this.tmpOpt){const t={toolsType:this.tmpOpt.toolsType,toolsOpt:e||this.tmpOpt.toolsOpt},s=this.createWorkShapeNode({...t,workId:i});s&&this.workShapes.set(i,s)}}setWorkOptions(i,e){const t=this.getWorkShape(i);t||this.createWorkShape(i,e),t==null||t.setWorkOptions(e)}createWorkShapeNode(i){var e;return ji({...i,vNodes:this.vNodes,fullLayer:this.fullLayer,drawLayer:this.drawLayer},(e=this.thread)==null?void 0:e.serviceWork)}setToolsOpt(i){var e,t,s;((e=this.tmpOpt)==null?void 0:e.toolsType)!==i.toolsType&&(t=this.tmpOpt)!=null&&t.toolsType&&this.clearAllWorkShapesCache(),this.tmpOpt=i,(s=i.toolsOpt)!=null&&s.syncUnitTime&&(this.syncUnitTime=i.toolsOpt.syncUnitTime),i.combineUnitTime&&(this.combineUnitTime=i.combineUnitTime)}getToolsOpt(){return this.tmpOpt}clearWorkShapeNodeCache(i){var e;(e=this.getWorkShape(i))==null||e.clearTmpPoints(),this.workShapes.delete(i)}clearAllWorkShapesCache(){this.workShapes.forEach(i=>i.clearTmpPoints()),this.workShapes.clear()}setFullWork(i){const{workId:e,opt:t,toolsType:s}=i;if(e&&t&&s){const o=e.toString();let n;return e&&this.workShapes.has(o)?(n=this.workShapes.get(o),n==null||n.setWorkOptions(t)):n=this.createWorkShapeNode({toolsOpt:t,toolsType:s,workId:o}),n?(this.workShapes.set(o,n),n):void 0}}}function Cf(r){return r}var gn=Cf;function kf(r,i,e){switch(e.length){case 0:return r.call(i);case 1:return r.call(i,e[0]);case 2:return r.call(i,e[0],e[1]);case 3:return r.call(i,e[0],e[1],e[2])}return r.apply(i,e)}var xf=kf,Df=xf,lo=Math.max;function Lf(r,i,e){return i=lo(i===void 0?r.length-1:i,0),function(){for(var t=arguments,s=-1,o=lo(t.length-i,0),n=Array(o);++s<o;)n[s]=t[i+s];s=-1;for(var a=Array(i+1);++s<i;)a[s]=t[s];return a[i]=e(n),Df(r,this,a)}}var bf=Lf;function jf(r){return function(){return r}}var Af=jf,Pf=Af,ho=Lo,zf=gn,Ef=ho?function(r,i){return ho(r,"toString",{configurable:!0,enumerable:!1,value:Pf(i),writable:!0})}:zf,Of=Ef,Rf=800,Wf=16,Yf=Date.now;function Uf(r){var i=0,e=0;return function(){var t=Yf(),s=Wf-(t-e);if(e=t,s>0){if(++i>=Rf)return arguments[0]}else i=0;return r.apply(void 0,arguments)}}var Bf=Uf,Ff=Of,Vf=Bf,Qf=Vf(Ff),Zf=Qf,Hf=gn,Gf=bf,$f=Zf;function Xf(r,i){return $f(Gf(r,i,Hf),r+"")}var Jf=Xf;function qf(r,i,e,t){for(var s=r.length,o=e+(t?1:-1);t?o--:++o<s;)if(i(r[o],o,r))return o;return-1}var Kf=qf;function _f(r){return r!==r}var eM=_f;function tM(r,i,e){for(var t=e-1,s=r.length;++t<s;)if(r[t]===i)return t;return-1}var iM=tM,sM=Kf,oM=eM,nM=iM;function rM(r,i,e){return i===i?nM(r,i,e):sM(r,oM,e)}var aM=rM,cM=aM;function lM(r,i){var e=r==null?0:r.length;return!!e&&cM(r,i,0)>-1}var fn=lM;function hM(r,i,e){for(var t=-1,s=r==null?0:r.length;++t<s;)if(e(i,r[t]))return!0;return!1}var Mn=hM;function uM(r,i){for(var e=-1,t=r==null?0:r.length,s=Array(t);++e<t;)s[e]=i(r[e],e,r);return s}var dM=uM,pM=ps,gM=fn,fM=Mn,MM=dM,yM=Di,mM=gs,wM=200;function IM(r,i,e,t){var s=-1,o=gM,n=!0,a=r.length,c=[],l=i.length;if(!a)return c;e&&(i=MM(i,yM(e))),t?(o=fM,n=!1):i.length>=wM&&(o=mM,n=!1,i=new pM(i));e:for(;++s<a;){var u=r[s],h=e==null?u:e(u);if(u=t||u!==0?u:0,n&&h===h){for(var d=l;d--;)if(i[d]===h)continue e;c.push(u)}else o(i,h,t)||c.push(u)}return c}var TM=IM,uo=ei,vM=Po,NM=ti,po=uo?uo.isConcatSpreadable:void 0;function SM(r){return NM(r)||vM(r)||!!(po&&r&&r[po])}var CM=SM,kM=hs,xM=CM;function yn(r,i,e,t,s){var o=-1,n=r.length;for(e||(e=xM),s||(s=[]);++o<n;){var a=r[o];i>0&&e(a)?i>1?yn(a,i-1,e,t,s):kM(s,a):t||(s[s.length]=a)}return s}var DM=yn;function LM(){}var bM=LM,Ri=Qo,jM=bM,AM=fs,PM=1/0,zM=Ri&&1/AM(new Ri([,-0]))[1]==PM?function(r){return new Ri(r)}:jM,EM=zM,OM=ps,RM=fn,WM=Mn,YM=gs,UM=EM,BM=fs,FM=200;function VM(r,i,e){var t=-1,s=RM,o=r.length,n=!0,a=[],c=a;if(e)n=!1,s=WM;else if(o>=FM){var l=i?null:UM(r);if(l)return BM(l);n=!1,s=YM,c=new OM}else c=i?[]:a;e:for(;++t<o;){var u=r[t],h=i?i(u):u;if(u=e||u!==0?u:0,n&&h===h){for(var d=c.length;d--;)if(c[d]===h)continue e;i&&c.push(h),a.push(u)}else s(c,h,e)||(c!==a&&c.push(h),a.push(u))}return a}var QM=VM,ZM=TM,HM=DM,go=QM;function GM(r,i,e){var t=r.length;if(t<2)return t?go(r[0]):[];for(var s=-1,o=Array(t);++s<t;)for(var n=r[s],a=-1;++a<t;)a!=s&&(o[s]=ZM(o[s]||n,r[a],i,e));return go(HM(o,1),i,e)}var $M=GM,XM=rs,JM=at;function qM(r){return JM(r)&&XM(r)}var KM=qM,_M=Wo,ey=Jf,ty=$M,iy=KM;ey(function(r){return ty(_M(r,iy))});class sy extends Sf{constructor(e){super(e);M(this,"drawWorkActiveId")}async runFullWork(e){var o;const t=this.setFullWork(e),s=e.ops&&Dt(e.ops);if(t){let n,a;const c=(o=t.getWorkId())==null?void 0:o.toString();return t.toolsType===T.Image?n=await t.consumeServiceAsync({isFullWork:!0,worker:this.thread}):t.toolsType===T.Text?n=await t.consumeServiceAsync({isFullWork:!0,replaceId:c,isDrawLabel:!0}):(n=t.consumeService({op:s,isFullWork:!0,replaceId:c}),a=(e==null?void 0:e.updateNodeOpt)&&t.updataOptService(e.updateNodeOpt)),e.workId&&this.workShapes.delete(e.workId.toString()),ue(n,a)}}runSelectWork(e){var s;const t=this.setFullWork(e);t&&((s=e.selectIds)!=null&&s.length)&&e.workId&&t.selectServiceNode(e.workId.toString(),{selectIds:e.selectIds},!1)}workShapesDone(){for(const e of this.workShapes.keys())this.clearWorkShapeNodeCache(e);Ve(this.fullLayer,this.fullLayer.parent)}canUseSubWorker(e){const t=this.thread.getPriorityDraw();return t||!t&&e!==T.Pencil}async consumeDraw(e){const{workId:t,fullWorkerDrawCount:s,postCount:o}=e,n=t==null?void 0:t.toString(),a=n&&this.workShapes.get(n);if(!a)return;this.drawWorkActiveId&&this.drawWorkActiveId!==n&&(await this.consumeDrawAll({workId:this.drawWorkActiveId,viewId:this.viewId,msgType:D.DrawWork,dataType:B.Local}),this.drawWorkActiveId=void 0),!this.drawWorkActiveId&&n!==G&&(this.drawWorkActiveId=n);const c=a.toolsType;ze(o)&&(this.consumeCount=o);const l=a.consume({data:e,drawCount:this.drawCount,isFullWork:!0,isSubWorker:!0,removeDrawCount:s});switch(c){case T.Selector:l&&(this.drawCount++,await this.drawSelector(l));break;case T.Ellipse:case T.Arrow:case T.Straight:case T.Rectangle:case T.Star:case T.Polygon:case T.SpeechBalloon:{l&&(this.drawCount++,await this.drawShape(l));break}case T.Pencil:case T.PencilEraser:case T.BitMapEraser:{l&&(this.drawCount++,await this.drawPencil(l,t==null?void 0:t.toString()));break}}}async consumeDrawAll(e){const{workId:t}=e;if(t){const s=t.toString();this.drawWorkActiveId===s&&(this.drawWorkActiveId=void 0);const o=this.workShapes.get(s);if(!o)return;switch(o.toolsType){case T.Selector:this.drawCount=0,Ve(this.fullLayer,this.fullLayer.parent),this.clearWorkShapeNodeCache(s),this._post({render:[{isClearAll:!0,clearCanvas:me.Float,viewId:this.viewId}]});break;case T.Arrow:case T.Straight:case T.Ellipse:case T.Pencil:case T.Rectangle:case T.Star:case T.Polygon:case T.SpeechBalloon:case T.BitMapEraser:case T.PencilEraser:this.drawCount=0,Ve(this.fullLayer,this.fullLayer.parent),this.clearWorkShapeNodeCache(s);break}}}async removeWork(e){const{workId:t}=e,s=t==null?void 0:t.toString();if(s){const o=this.removeNode(s);if(o){const n=[];n.push({rect:wt(o),clearCanvas:me.Float,isClear:!0,viewId:this.viewId},{rect:wt(o),drawCanvas:me.Float,viewId:this.viewId}),await this._post({render:n})}}}removeNode(e){const t=this.workShapes.has(e);let s;return t&&(this.fullLayer.getElementsByName(e).forEach(o=>{const n=o.getBoundingClientRect();s=ue(s,{x:n.x-U.SafeBorderPadding,y:n.y-U.SafeBorderPadding,w:n.width+U.SafeBorderPadding*2,h:n.height+U.SafeBorderPadding*2}),o.remove(),Ge(o,this.fullLayer.parent)}),s&&this.clearWorkShapeNodeCache(e)),s}async drawPencil(e,t){await this._post({subWorkerDrawCount:this.drawCount,consumeCount:this.consumeCount,render:[{rect:e==null?void 0:e.rect,workId:t,drawCanvas:me.Float,viewId:this.viewId}],sp:(e==null?void 0:e.op)&&[e]})}async drawShape(e){await this._post({subWorkerDrawCount:this.drawCount,consumeCount:this.consumeCount,render:[{rect:(e==null?void 0:e.rect)&&wt(e.rect),isClear:!0,clearCanvas:me.Float,viewId:this.viewId},{rect:(e==null?void 0:e.rect)&&wt(e.rect),drawCanvas:me.Float,viewId:this.viewId}]})}async drawSelector(e){await this._post({subWorkerDrawCount:this.drawCount,consumeCount:this.consumeCount,render:[{rect:(e==null?void 0:e.rect)&&wt(e.rect),isClear:!0,clearCanvas:me.Float,viewId:this.viewId},{rect:(e==null?void 0:e.rect)&&wt(e.rect),drawCanvas:me.Float,viewId:this.viewId}]})}}class oy{constructor(i){M(this,"viewId");M(this,"vNodes");M(this,"topLayer");M(this,"thread");M(this,"post");M(this,"serviceWorkShapes",new Map);M(this,"localWorkShapes",new Map);M(this,"tmpOpt");M(this,"syncUnitTime",Ie.syncOpt.interval);M(this,"animationId");this.viewId=i.viewId,this.vNodes=i.vNodes,this.topLayer=i.topLayer,this.thread=i.thread,this.post=i.thread.post.bind(i.thread)}canUseTopLayer(i){return i===T.LaserPen}getWorkShape(i){return this.localWorkShapes.get(i)}createWorkShape(i,e){if(i&&this.tmpOpt){const t={toolsType:this.tmpOpt.toolsType,toolsOpt:e||this.tmpOpt.toolsOpt},s=this.createWorkShapeNode({...t,workId:i});return s&&this.localWorkShapes.set(i,{node:s,toolsType:s.toolsType,workState:j.Start}),s}}setWorkOptions(i,e){var s;const t=(s=this.localWorkShapes.get(i))==null?void 0:s.node;t||this.createWorkShape(i,e),t==null||t.setWorkOptions(e)}createWorkShapeNode(i){const{toolsType:e}=i;if(e===T.LaserPen)return ji({...i,vNodes:this.vNodes,fullLayer:this.topLayer,drawLayer:this.topLayer})}clearAllWorkShapesCache(){this.localWorkShapes.forEach(i=>{var e;return(e=i.node)==null?void 0:e.clearTmpPoints()}),this.localWorkShapes.clear()}setToolsOpt(i){var e;this.tmpOpt=i,(e=i.toolsOpt)!=null&&e.syncUnitTime&&(this.syncUnitTime=i.toolsOpt.syncUnitTime)}getToolsOpt(){return this.tmpOpt}consumeDraw(i){const{workId:e,dataType:t}=i;if(t===B.Service)this.activeServiceWorkShape(i);else{const s=e==null?void 0:e.toString(),o=s&&this.localWorkShapes.get(s);if(!o)return;const n=o.node.consume({data:i,isFullWork:!1,isSubWorker:!0});n.rect&&(o.totalRect=ue(n.rect,o.totalRect),o.result=n,o.workState=j.Doing,s&&this.localWorkShapes.set(s,o))}this.runAnimation()}consumeDrawAll(i){const{workId:e,dataType:t}=i;if(t===B.Service)this.activeServiceWorkShape(i);else{const s=e==null?void 0:e.toString(),o=s&&this.localWorkShapes.get(s);if(!o)return;const n=o.node.consumeAll({data:i});o.totalRect=ue(n.rect,o.totalRect),o.result=n,o.workState=j.Done,s&&this.localWorkShapes.set(s,o)}this.runAnimation()}destroy(){this.serviceWorkShapes.clear(),this.localWorkShapes.clear()}setNodeKey(i,e,t,s){return e.toolsType=t,e.node=this.createWorkShapeNode({workId:i,toolsType:t,toolsOpt:s}),e}activeServiceWorkShape(i){var d,g;const{workId:e,opt:t,toolsType:s,type:o,updateNodeOpt:n,ops:a,op:c}=i;if(!e)return;const l=e.toString(),u=(d=this.vNodes.get(l))==null?void 0:d.rect;if(!((g=this.serviceWorkShapes)!=null&&g.has(l))){let p={toolsType:s,animationWorkData:c||[],animationIndex:0,type:o,updateNodeOpt:n,ops:a,oldRect:u};s&&t&&(p=this.setNodeKey(l,p,s,t)),this.serviceWorkShapes.set(l,p)}const h=this.serviceWorkShapes.get(l);o&&(h.type=o),a&&(h.animationWorkData=Dt(a),h.ops=a),n&&(h.updateNodeOpt=n),c&&(h.animationWorkData=c),h.node&&h.node.getWorkId()!==l&&h.node.setWorkId(l),u&&(h.oldRect=u),s&&t&&(h.toolsType!==s&&s&&t&&this.setNodeKey(l,h,s,t),h.node&&h.node.setWorkOptions(t))}computNextAnimationIndex(i,e){const t=Math.floor((i.animationWorkData||[]).slice(i.animationIndex).length*32/e/this.syncUnitTime)*e;return Math.min((i.animationIndex||0)+(t||e),(i.animationWorkData||[]).length)}async animationDraw(){var n,a,c,l;this.animationId=void 0;let i=!1;const e=new Map,t=[],s=[],o=[];for(const[u,h]of this.serviceWorkShapes.entries())switch(h.toolsType){case T.LaserPen:{const g=this.computNextAnimationIndex(h,8),p=Math.max(0,h.animationIndex||0),f=(h.animationWorkData||[]).slice(p,g);if((h.animationIndex||0)<g){const m=(n=h.node)==null?void 0:n.consumeService({op:f,isFullWork:!1});h.totalRect=ue(h.totalRect,m),h.animationIndex=g,f.length&&e.set(u,{workState:p===0?j.Start:g===((a=h.animationWorkData)==null?void 0:a.length)?j.Done:j.Doing,op:f.slice(-2)})}if(s.push({isClear:!0,rect:h.totalRect,clearCanvas:me.TopFloat,viewId:this.viewId}),t.push({rect:h.totalRect,drawCanvas:me.TopFloat,viewId:this.viewId}),h.isDel){(c=h.node)==null||c.clearTmpPoints(),this.serviceWorkShapes.delete(u);break}h.ops&&h.animationIndex===((l=h.animationWorkData)==null?void 0:l.length)&&!h.isDel&&(this.topLayer.getElementsByName(u.toString())[0]||(h.isDel=!0,this.serviceWorkShapes.set(u,h))),i=!0;break}}for(const[u,h]of this.localWorkShapes.entries()){const{result:d,toolsType:g,totalRect:p,isDel:f,workState:m}=h;switch(g){case T.LaserPen:{if(p&&(s.push({isClear:!0,rect:p,clearCanvas:me.TopFloat,viewId:this.viewId}),t.push({rect:p,drawCanvas:me.TopFloat,viewId:this.viewId})),f){h.node.clearTmpPoints(),this.localWorkShapes.delete(u),o.push({removeIds:[u.toString()],viewId:this.viewId,type:D.RemoveNode});break}d&&((d.op||d.ops)&&o.push(d),h.result=void 0),!this.topLayer.getElementsByName(u.toString())[0]&&m===j.Done&&(h.isDel=!0,this.localWorkShapes.set(u,h)),i=!0;break}}}i&&this.runAnimation(),e.size&&e.forEach((u,h)=>{o.push({type:D.Cursor,uid:h.split(He)[0],op:u.op,workState:u.workState,viewId:this.viewId})}),(t.length||s.length||o.length)&&this.post({render:[...s,...t],sp:o})}runAnimation(){this.animationId||(this.animationId=setTimeout(()=>{this.animationId=void 0,this.animationDraw()},16))}}var Gi=(r=>(r.Full="full",r.Sub="sub",r))(Gi||{});class ny extends Nf{constructor(e,t,s){super(e,t,"sub");M(this,"type","sub");M(this,"_post");M(this,"topLayer");M(this,"snapshotFullLayer");M(this,"serviceWork");M(this,"localWork");M(this,"topLayerWork");this._post=s;const o=Ie.bufferSize.sub;this.topLayer=this.createLayer("topLayer",this.scene,{...t.layerOpt,bufferSize:o,contextType:"2d"});const n={thread:this,viewId:this.viewId,vNodes:this.vNodes,fullLayer:this.fullLayer,topLayer:this.topLayer};this.localWork=new sy(n),this.topLayerWork=new oy(n),this.vNodes.init(this.fullLayer)}async combinePost(){var n,a;const{render:e,...t}=this.combinePostData();let s;if(e!=null&&e.length){const c=[];for(const l of e)if(l.rect){if(l.rect=fy(Pe(l.rect),this.scene,this.dpr),!l.rect)continue;if(l.drawCanvas&&l.rect&&l.rect.w>0&&l.rect.h>0){const u=await this.getRectImageBitmap(l);l.imageBitmap=u,s||(s=[]),s.push(u)}c.push(l)}t.render=c}const o=(n=t.sp)==null?void 0:n.filter(c=>c.type!==D.None||c.isLockSentEventCursor);o!=null&&o.length?t.sp=o.map(c=>({...c,viewId:this.viewId})):delete t.sp,t.consumeCount===void 0&&delete t.consumeCount,t.subWorkerDrawCount===void 0&&delete t.subWorkerDrawCount,(o!=null&&o.length||t.consumeCount||t.subWorkerDrawCount||(a=t==null?void 0:t.render)!=null&&a.length)&&this._post(t,s),this.delayPostDoneResolve&&this.delayPostDoneResolve(!0)}getLayer(e,t){if(t&&this.snapshotFullLayer)return this.snapshotFullLayer;switch(e){case me.TopFloat:return this.topLayer;default:return this.fullLayer}}async on(e){const{msgType:t,toolsType:s,opt:o,dataType:n,workState:a,isLockSentEventCursor:c}=e;switch(t){case D.UpdateTools:if(s&&this.topLayerWork.canUseTopLayer(s)&&o){const l={toolsType:s,toolsOpt:o};this.topLayerWork.setToolsOpt(l);return}break;case D.CreateWork:this.createLocalWork(e);return;case D.DrawWork:a===j.Done&&n===B.Local?(await this.consumeDrawAll(n,e),s===T.LaserPen&&c&&this.post({sp:[{type:D.None,isLockSentEventCursor:c}]})):this.consumeDraw(n,e);return;case D.RemoveNode:await this.removeNode(e);return;case D.FullWork:s&&this.topLayerWork.canUseTopLayer(s)&&await this.consumeDrawAll(n,e);return;case D.Snapshot:this.snapshotFullLayer=this.createLayer("snapshotFullLayer",this.scene,{...this.opt.layerOpt,bufferSize:this.viewId===ge?6e3:3e3,contextType:"2d"}),this.snapshotFullLayer&&(await this.getSnapshot(e),this.snapshotFullLayer=void 0);return;case D.BoundingBox:this.snapshotFullLayer=this.createLayer("snapshotFullLayer",this.scene,{...this.opt.layerOpt,bufferSize:this.viewId===ge?6e3:3e3,contextType:"2d"}),this.snapshotFullLayer&&(await this.getBoundingRect(e),this.snapshotFullLayer=void 0);return}await super.on(e)}createLocalWork(e){const{workId:t,toolsType:s,opt:o}=e;if(s&&this.topLayerWork.canUseTopLayer(s)&&t&&o){this.topLayerWork.getToolsOpt()||this.topLayerWork.setToolsOpt({toolsType:s,toolsOpt:o}),this.topLayerWork.setWorkOptions(t.toString(),o);return}s&&this.localWork.canUseSubWorker(s)&&super.createLocalWork(e)}async removeNode(e){const{dataType:t}=e;t===B.Local&&await this.localWork.removeWork(e)}getOffscreen(e,t){return this.getLayer(e,t).parent.canvas}async consumeDraw(e,t){const{workId:s,toolsType:o}=t;if(s){if(o&&this.topLayerWork.canUseTopLayer(o)){e===B.Local&&(this.topLayerWork.getWorkShape(s.toString())||this.createLocalWork(t)),this.topLayerWork.consumeDraw(t);return}o&&this.localWork.canUseSubWorker(o)&&(this.localWork.getWorkShape(s.toString())||this.createLocalWork(t),await this.localWork.consumeDraw(t));return}}async consumeDrawAll(e,t){const{workId:s,toolsType:o,dataType:n}=t;if(s){const a=s.toString();if(o&&this.topLayerWork.canUseTopLayer(o)){n===B.Local&&(this.topLayerWork.getWorkShape(a)||this.createLocalWork(t)),this.topLayerWork.consumeDrawAll(t);return}o&&this.localWork.canUseSubWorker(o)&&(this.localWork.getWorkShape(a)||super.createLocalWork(t),this.localWork.consumeDrawAll(t));return}}async clearAll(){this.vNodes.clear(),super.clearAll(),this.topLayer&&(this.topLayer.parent.children.forEach(e=>{e.name!=="viewport"&&e.remove()}),Ve(this.topLayer,this.topLayer.parent)),await this.post({render:[{isClearAll:!0,clearCanvas:me.TopFloat,viewId:this.viewId}],sp:[{type:D.Clear}]})}getRectImageBitmap(e,t=!1,s){const{rect:o,drawCanvas:n}=e,a=Math.floor(o.x*this.dpr),c=Math.floor(o.y*this.dpr),l=Math.floor(o.w*this.dpr||1),u=Math.floor(o.h*this.dpr||1);return createImageBitmap(this.getOffscreen(n,t),a,c,l,u,s)}updateLayer(e){const{width:t,height:s}=e;super.updateLayer(e),this.topLayer&&(this.topLayer.parent.setAttribute("width",t),this.topLayer.parent.setAttribute("height",s),this.topLayer.setAttribute("size",[t,s]),this.topLayer.setAttribute("pos",[t*.5,s*.5])),this.snapshotFullLayer&&(this.snapshotFullLayer.parent.setAttribute("width",t),this.snapshotFullLayer.parent.setAttribute("height",s),this.snapshotFullLayer.setAttribute("size",[t,s]),this.snapshotFullLayer.setAttribute("pos",[t*.5,s*.5]))}async updateDpr(e){super.updateDpr(e);const t=!!this.topLayerWork.localWorkShapes.size,s=!!this.localWork.getWorkShapes().size,o=[];s&&o.push({isClearAll:!0,clearCanvas:me.Float,viewId:this.viewId}),t&&o.push({isClearAll:!0,clearCanvas:me.TopFloat,viewId:this.viewId}),o.length&&await this.post({render:o})}async updateCamera(e){const t=[],{cameraOpt:s}=e;if(s&&!lt(this.cameraOpt,s)){const o=!!this.topLayerWork.localWorkShapes.size,n=!!this.localWork.getWorkShapes().size;if(n&&this.localWork.workShapesDone(),this.setCameraOpt(s),n&&t.push({isClearAll:!0,clearCanvas:me.Float,viewId:this.viewId}),o){t.push({isClearAll:!0,clearCanvas:me.TopFloat,viewId:this.viewId});for(const[a,c]of this.topLayerWork.localWorkShapes.entries())if(c.totalRect){let l;this.topLayer.getElementsByName(a.toString()).forEach(u=>{const h=u.getBoundingClientRect(),d=wt({x:h.x,y:h.y,w:h.width,h:h.height});l=ue(l,d)}),c.totalRect=l,this.topLayerWork.localWorkShapes.set(a,c)}}t.length&&await this.post({render:t})}}setCameraOpt(e,t){this.cameraOpt=e;const{scale:s,centerX:o,centerY:n,width:a,height:c}=e;(a!==this.scene.width||c!==this.scene.height)&&this.updateScene({width:a,height:c}),t?(t.setAttribute("scale",[s,s]),t.setAttribute("translate",[-o,-n])):(this.fullLayer.setAttribute("scale",[s,s]),this.fullLayer.setAttribute("translate",[-o,-n]),this.topLayer.setAttribute("scale",[s,s]),this.topLayer.setAttribute("translate",[-o,-n]))}async getSnapshot(e){const{scenePath:t,scenes:s,cameraOpt:o,w:n,h:a}=e;if(t&&s&&o&&this.snapshotFullLayer){const c=Pe(this.cameraOpt);this.setCameraOpt(o,this.snapshotFullLayer),this.localWork.fullLayer=this.snapshotFullLayer,this.localWork.drawLayer=void 0;let l;for(const[h,d]of Object.entries(s))if(d!=null&&d.type)switch(d==null?void 0:d.type){case D.UpdateNode:case D.FullWork:{const{opt:g}=d,p={...d,opt:g,workId:h,msgType:D.FullWork,dataType:B.Service,viewId:this.viewId},f=await this.localWork.runFullWork(p);l=ue(l,f);break}}let u;n&&a&&(u={resizeWidth:n,resizeHeight:a}),await this.getSnapshotRender({scenePath:t,curCameraOpt:c,options:u}),this.localWork.fullLayer=this.fullLayer,this.localWork.drawLayer=void 0}}async getSnapshotRender(e){var a;const{scenePath:t,curCameraOpt:s,options:o}=e;((a=this.snapshotFullLayer)==null?void 0:a.parent).render();const n=await this.getRectImageBitmap({rect:this.getSceneRect(),drawCanvas:me.None},!0,o);n&&(this._post({sp:[{type:D.Snapshot,scenePath:t,imageBitmap:n,viewId:this.viewId}]},[n]),n.close(),this.snapshotFullLayer&&Ve(this.snapshotFullLayer,this.snapshotFullLayer.parent),this.setCameraOpt(s,this.fullLayer))}async getBoundingRect(e){const{scenePath:t,scenes:s,cameraOpt:o}=e;if(t&&s&&o&&this.snapshotFullLayer){const n=Pe(this.cameraOpt);this.setCameraOpt(o,this.snapshotFullLayer),this.localWork.fullLayer=this.snapshotFullLayer,this.localWork.drawLayer=void 0;let a;for(const[c,l]of Object.entries(s))if(l!=null&&l.type)switch(l==null?void 0:l.type){case D.UpdateNode:case D.FullWork:{const u=await this.localWork.runFullWork({...l,workId:c,msgType:D.FullWork,dataType:B.Service,viewId:this.viewId});a=ue(a,u);break}}a&&await this.post({sp:[{type:D.BoundingBox,scenePath:t,rect:a}]}),this.localWork.fullLayer=this.fullLayer,this.localWork.drawLayer=void 0,Ve(this.snapshotFullLayer,this.snapshotFullLayer.parent),this.setCameraOpt(n,this.fullLayer)}}}class Kt extends U{constructor(e){super(e);M(this,"canRotate",!0);M(this,"scaleType",ce.all);M(this,"toolsType",T.Image);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");this.workOptions=e.toolsOpt,this.scaleType=Kt.getScaleType(this.workOptions)}consume(){return{type:D.None}}consumeAll(){return{type:D.None}}draw(e){const{layer:t,workId:s,replaceId:o,imageBitmap:n}=e,{centerX:a,centerY:c,width:l,height:u,rotate:h,zIndex:d,eraserlines:g}=this.workOptions,p=new he.Group({anchor:[.5,.5],pos:[a,c],name:s,size:[l,u],zIndex:d,rotate:h}),f={anchor:[.5,.5],pos:[0,0],size:[l,u],texture:n};n||(f.bgcolor="rgba(0,0,0,0.3)");const m=new he.Sprite(f);p.append(m),g&&this.drawEraserlines({group:p,eraserlines:g,pos:[a,c],layer:t}),this.replace(t,o||s,p);const w=p.getBoundingClientRect();if(w)return{x:Math.floor(w.x-U.SafeBorderPadding),y:Math.floor(w.y-U.SafeBorderPadding),w:Math.floor(w.width+U.SafeBorderPadding*2),h:Math.floor(w.height+U.SafeBorderPadding*2)}}consumeService(){}async consumeServiceAsync(e){var u,h,d,g;const{isFullWork:t,replaceId:s,worker:o}=e,{src:n,uuid:a}=this.workOptions,c=((u=this.workId)==null?void 0:u.toString())||a,l=t?this.fullLayer:this.drawLayer||this.fullLayer;if(n){const p=await o.loadImageBitMap({toolsType:this.toolsType,opt:this.workOptions,workId:c,isSubWorker:o instanceof ny});if(p){const f=this.draw({workId:c,layer:l,replaceId:s,imageBitmap:p});return this.oldRect=c&&((d=(h=this.vNodes)==null?void 0:h.get(c))==null?void 0:d.rect)||void 0,(g=this.vNodes)==null||g.setInfo(c,{rect:f,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:f&&U.getCenterPos(f,l)}),f}}}clearTmpPoints(){this.tmpPoints.length=0}static getScaleType(e){const{uniformScale:t,rotate:s}=e;return t!==!1||s&&Math.abs(s)%90>0?ce.proportional:ce.all}static updateNodeOpt(e){const{node:t,opt:s,vNodes:o,targetNode:n}=e,{translate:a,originPoint:c,scenePoint:l,scale:u,angle:h,isLocked:d,zIndex:g,strokeColor:p}=s,f=n&&Pe(n)||o.get(t.name);if(!f)return;const m=t.parent;if(m){if(p&&(f.opt.strokeColor=p),ze(g)&&(t.setAttribute("zIndex",g),f.opt.zIndex=g),Pt(d)&&(f.opt.locked=d),c&&l&&u&&a){const{centerX:w,centerY:I,width:N,height:C,uniformScale:S}=f.opt,v=S!==!1?[u[0],u[0]]:u,x=[w,I],L=[w,I];ms(L,l,v,a);const b=[L[0]-x[0],L[1]-x[1]];if(f.centerPos=[f.centerPos[0]+b[0],f.centerPos[1]+b[1]],f.opt.width=Math.round(N*v[0]),f.opt.height=Math.round(C*v[1]),f.opt.centerX=L[0],f.opt.centerY=L[1],f.opt.eraserlines)for(const P of Object.values(f.opt.eraserlines)){const{op:A,thickness:E}=P;P.thickness=E*Math.max(u[0],u[1]);for(let R=0;R<A.length;R++)ws(A[R],l,u,a)}}else if(a){if(f.opt.centerX=f.opt.centerX+a[0],f.opt.centerY=f.opt.centerY+a[1],f.centerPos=[f.centerPos[0]+a[0],f.centerPos[1]+a[1]],f.opt.eraserlines)for(const w of Object.values(f.opt.eraserlines)){const{op:I}=w;for(let N=0;N<I.length;N++){const C=I[N].map((S,v)=>v%2?S+a[1]:S+a[0]);w.op[N]=C}}}else if(ze(h))if(f.opt.rotate=h,f.scaleType=Kt.getScaleType(f.opt),n){const w=mn(f.rect,h);f.rect=w}else{const w=U.getRectFromLayer(m,t.name);f.rect=w||f.rect}return f&&o.setInfo(t.name,f),f==null?void 0:f.rect}}}function ue(r,i){if(r&&i){const e=Math.min(r.x,i.x),t=Math.min(r.y,i.y),s=Math.max(r.x+r.w,i.x+i.w),o=Math.max(r.y+r.h,i.y+i.h),n=s-e,a=o-t;return{x:e,y:t,w:n,h:a}}return i||r}function ys(r,i){if(r&&i){const e=Math.min(r.originX,i.originX),t=Math.min(r.originY,i.originY),s=Math.max(r.originX+r.width,i.originX+i.width),o=Math.max(r.originY+r.height,i.originY+i.height),n=s-e,a=o-t;return{originX:e,originY:t,width:n,height:a}}return i||r}function Me(r,i=0){const e={x:0,y:0,w:0,h:0};let t=1/0,s=1/0,o=-1/0,n=-1/0;return r.forEach(a=>{const[c,l]=a.XY;t=Math.min(t,c-i),s=Math.min(s,l-i),o=Math.max(o,c+i),n=Math.max(n,l+i)}),e.x=t,e.y=s,e.w=o-t,e.h=n-s,e}function $i(r,i){return!(r.x+r.w<i.x||r.x>i.x+i.w||r.y+r.h<i.y||r.y>i.y+i.h)}function wt(r,i=10){return{x:Math.floor(r.x-i),y:Math.floor(r.y-i),w:Math.ceil(r.w+i*2),h:Math.ceil(r.h+i*2)}}function _t(r,i){return{x:r.x+i[0],y:r.y+i[1],w:r.w,h:r.h}}function ry(r,i){const e=new k(r.x,r.y),t=new k(r.x+r.w,r.y),s=new k(r.x+r.w,r.y+r.h),o=new k(r.x,r.y+r.h),n=new k(r.x+r.w/2,r.y+r.h/2),a=Math.PI*i/180,c=k.RotWith(e,n,a),l=k.RotWith(t,n,a),u=k.RotWith(s,n,a),h=k.RotWith(o,n,a);return[c,l,u,h]}function mn(r,i){const e=ry(r,i);return Me(e)}function wn(r,i,e){const t=new k(r.x,r.y),s=new k(r.x+r.w,r.y),o=new k(r.x+r.w,r.y+r.h),n=new k(r.x,r.y+r.h),a=new k(e[0],e[1]),c=new k(i[0],i[1]),l=k.ScaleWOrigin(t,c,a),u=k.ScaleWOrigin(s,c,a),h=k.ScaleWOrigin(o,c,a),d=k.ScaleWOrigin(n,c,a);return Me([l,u,h,d])}function ay(r,i,e){const t=new k(i[0],i[1]);for(let s=0;s<r.length;s+=3){const o=new k(r[s],r[s+1]),n=Math.PI*e/180,a=k.RotWith(o,t,n);r[s]=a.x,r[s+1]=a.y}}function cy(r,i,e){const t=new k(i[0],i[1]);for(let s=0;s<r.length;s+=2){const o=new k(r[s],r[s+1]),n=Math.PI*e/180,a=k.RotWith(o,t,n);r[s]=a.x,r[s+1]=a.y}}function ms(r,i,e,t=[0,0]){const s=new k(i[0],i[1]);for(let o=0;o<r.length;o+=3){const n=new k(r[o],r[o+1]),a=new k(e[0],e[1]),c=k.ScaleWOrigin(n,a,s);r[o]=c.x+t[0],r[o+1]=c.y+t[1]}}function ws(r,i,e,t=[0,0]){const s=new k(i[0],i[1]);for(let o=0;o<r.length;o+=2){const n=new k(r[o],r[o+1]),a=new k(e[0],e[1]),c=k.ScaleWOrigin(n,a,s);r[o]=c.x+t[0],r[o+1]=c.y+t[1]}}function In(r,i){return r[0]>=i.x&&r[0]<=i.x+i.w&&r[1]>=i.y&&r[1]<=i.y+i.h}function Tn(r,i){const e=r<=i?1:r/i,t=i<=r?1:i/r;return[e,t]}function ly(r){for(const i of r)if(isNaN(i)||i===1/0||i===-1/0)return!1;return!0}function hy(r){return r!==Math.floor(r)}function uy(r){const i=r.toString();return i.indexOf(".")!==-1?i.split(".")[1].length:0}function dy(r,i){for(;i!==0;)[r,i]=[i,r%i];return r}const py=r=>{if(r.tagName==="GROUP"){const i=Object.getOwnPropertySymbols(r).find(e=>e.toString()==="Symbol(sealed)");if(i&&r[i])return!0}return!1},Ge=(r,i)=>{if(r.mesh&&r.mesh.texture&&r.name==="eraserTexture"){const e=r.mesh.texture.image;i.deleteTexture(e)}else if(r.tagName==="GROUP"&&r&&r.children)for(const e of r.children)Ge(e,i)},Ve=(r,i)=>{Ge(r,i),r.removeAllChildren()},gy=(r,i,e)=>{const t=e.parent;if(i){const s=i.children;if(s){for(const o of s)if(Ge(o,t),o.tagName==="GROUP")for(const n of o.children)Ge(n,t)}}i.parent.replaceChild(r,i)},fy=(r,i,e)=>{if(r.w+r.x<=0||r.h+r.y<=0||r.w<=0||r.h<=0)return;const t=i.width,s=i.height,o={x:Math.floor(Math.max(0,r.x)),y:Math.floor(Math.max(0,r.y)),w:Math.floor(Math.min(t,r.w)),h:Math.floor(Math.min(s,r.h))};if(o.x+o.w>t&&(o.w=Math.floor(t-o.x)),o.y+o.h>s&&(o.h=Math.floor(s-o.y)),hy(e)){const n=uy(e),a=Math.pow(10,n),c=dy(a,e*a),l=o.x%c,u=o.x-l;u>=0?(o.x=u,o.w=o.w+l):(o.x=0,o.w=o.w+l-u);const h=o.y%c,d=o.y-h;d>=0?(o.y=d,o.h=o.h+h):(o.y=0,o.h=o.h+h-d)}return o};function bt(r){return`${mi(r.x)},${mi(r.y)} `}function jt(r,i){return`${mi((r.x+i.x)/2)},${mi((r.y+i.y)/2)} `}function mi(r){return+r.toFixed(4)}const ht=async(r,i)=>{let e,t;return new Promise(function(s){if(typeof window.requestIdleCallback=="function"){const o=typeof i=="number"&&!isNaN(i)&&i>0?i:0;t=window.requestIdleCallback(()=>{clearTimeout(e),s(1)},{timeout:o})}e=setTimeout(()=>{t&&window.cancelIdleCallback(t),s(1)},i||0)}).then(function(){r()}).catch(function(){r()})},ut=r=>{const i=(r==null?void 0:r.webkitBackingStorePixelRatio)||(r==null?void 0:r.mozBackingStorePixelRatio)||(r==null?void 0:r.msBackingStorePixelRatio)||(r==null?void 0:r.oBackingStorePixelRatio)||(r==null?void 0:r.backingStorePixelRatio)||1;return Math.max(1,(window.devicePixelRatio||1)/i)},Is=(r,i)=>r.x+r.w<i.x||r.x>i.x+i.w||r.y+r.h<i.y||r.y>i.y+i.h?Nt.outside:r.x>=i.x&&r.y>=i.y&&r.x+r.w<=i.x+i.w&&r.y+r.h<=i.y+i.h?Nt.inside:Nt.intersect;function My(r){let i=0;for(let e=0;e<r.length;e++){const t=r.charCodeAt(e);t>=1&&t<=126||65376<=t&&t<=65439?i++:i+=2}return i}class yy{constructor(i,e){M(this,"plugin");M(this,"uid");M(this,"control");this.control=i,this.plugin=e,this.uid=e.displayer.uid}getNamespaceData(){var i;return $.toJS((i=this.plugin)==null?void 0:i.attributes[this.namespace])||{}}getAuthSpaceData(){var i;return $.toJS((i=this.plugin)==null?void 0:i.attributes[this.authSpace])||{}}getUidFromKey(i){return i.split(He).length===2&&i.split(He)[0]||this.uid}isLocalId(i){return i.split(He).length===1}getLocalId(i){return i.split(He)[1]}isSelector(i){return this.getLocalId(i)===G}}const De=class De extends yy{constructor(e,t,s){super(e,t);M(this,"authSpace");M(this,"namespace");M(this,"serviceStorage",{});M(this,"storage",{});M(this,"authStorage",{});M(this,"stateDisposer");M(this,"authDisposer");M(this,"asyncClockState",!1);M(this,"limitNums",new Map);M(this,"limitComponents",O.debounce((e,t)=>{var n,a,c,l,u,h,d,g;const s=((a=(n=this.storage)==null?void 0:n[e])==null?void 0:a[t])&&Object.keys(this.storage[e][t]).length||0;if(s===0)return;let o=this.limitNums.get(`${e}/${t}`);if(!o){const p=this.getLimitNum(s);this.limitNums.set(`${e}/${t}`,p),o=p}if(o>0&&s>=o){const p=De.componentsLimits.indexOf(o),f=p>=0&&p<De.componentsLimits.length-1;if((u=(l=(c=this.control.room)==null?void 0:c.callbacks)==null?void 0:l.listeners)!=null&&u.map.onObjectsLimit&&((d=(h=this.control.room)==null?void 0:h.callbacks)==null||d.dispatch("onObjectsLimit",w=>w(o,f))),!f){this.control.room.logger.error(`exceeds the limit of ${o} components, current: ${s}`),(g=this.control.room)==null||g.disconnect().then(()=>{var w,I,N,C,S;(N=(I=(w=this.control.room)==null?void 0:w.callbacks)==null?void 0:I.listeners)!=null&&N.map.onKickedWithReason&&((S=(C=this.control.room)==null?void 0:C.callbacks)==null||S.dispatch("onKickedWithReason",v=>v("kickByAdmin")))});return}console.warn(`exceeds the limit of ${o} components, current: ${s}`);const m=f?De.componentsLimits[p+1]:0;this.limitNums.set(`${e}/${t}`,m)}},2e3,{maxWait:5e3}));M(this,"clearLimitComponents",(e,t)=>{if(t)this.limitNums.delete(`${e}/${t}`);else for(const s of this.limitNums.keys())`${e}/`.indexOf(s)===0&&this.limitNums.delete(s)});De.syncInterval=(s||De.syncInterval)*.5,this.namespace=De.namespace,this.authSpace=De.authSpace,this.serviceStorage=this.getNamespaceData(),this.storage=O.cloneDeep(this.serviceStorage),this.authStorage=this.getAuthSpaceData(),this.getLimitNums()}getLimitNum(e){return e>=De.componentsLimits[0]?De.componentsLimits[1]:De.componentsLimits[0]}getLimitNums(){for(const[e,t]of Object.entries(this.storage))if(e&&t){for(const[s,o]of Object.entries(t))if(s&&o){const n=this.getLimitNum(Object.keys(o).length);this.limitNums.set(`${e}/${s}`,n)}}}getViewIdBySecenPath(e){const t=this.getNamespaceData();for(const[s,o]of Object.entries(t))if(o){for(const n of Object.keys(o))if(n===e)return s}}getScenePathData(e){const t=this.getNamespaceData();for(const s of Object.values(t))if(s){for(const o of Object.keys(s))if(o===e)return O.cloneDeep(s[o])}}getStorageData(e,t){const s=this.getNamespaceData();return s&&s[e]&&O.cloneDeep(s[e][t])||void 0}hasSelector(e,t){const s=this.storage&&this.storage[e]&&this.storage[e][t];return!!(s&&Object.keys(s).find(o=>this.isOwn(o)&&this.getLocalId(o)===G))}hasIncludeSelector(e,t,s){for(const o of Object.keys(this.storage))if(!(t&&o!==t)){for(const n of Object.keys(this.storage[o]))if(!(s&&n!==s)){for(const a of Object.keys(this.storage[o][n]))if(this.getLocalId(a)===G){const c=this.storage[o][n][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=$.autorun(async()=>{var c,l,u,h,d,g;const t=this.getNamespaceData(),{diffView:s,diffScenePath:o,diffData:n}=this.diffFunByView(this.serviceStorage,t);this.serviceStorage=t;const a={};if(Object.keys(s).length>0)for(const[p,f]of Object.entries(s))f&&!O.isEqual((c=this.storage)==null?void 0:c[p],f.newValue)&&(a.diffView||(a.diffView={}),a.diffView[p]=f,this.storage||(this.storage={}),f.newValue===void 0?delete this.storage[p]:this.storage[p]=O.cloneDeep(f.newValue));if(Object.keys(o).length>0){for(const[p,f]of Object.entries(o))if(f){const{viewId:m,newValue:w}=f;f&&!O.isEqual((u=(l=this.storage)==null?void 0:l[m])==null?void 0:u[p],w)&&(a.diffScenePath||(a.diffScenePath={}),a.diffScenePath[p]=f,this.storage||(this.storage={}),this.storage[m]||(this.storage[m]={}),f.newValue===void 0?delete this.storage[m][p]:this.storage[m][p]=O.cloneDeep(f.newValue))}}if(Object.keys(n).length>0){for(const[p,f]of Object.entries(n))if(f){const{viewId:m,scenePath:w,newValue:I}=f;f&&!O.isEqual((g=(d=(h=this.storage)==null?void 0:h[m])==null?void 0:d[w])==null?void 0:g[p],I)&&(a.diffData||(a.diffData={}),a.diffData[p]=f,this.storage||(this.storage={}),this.storage[m]||(this.storage[m]={}),this.storage[m][w]||(this.storage[m][w]={}),f.newValue===void 0?delete this.storage[m][w][p]:this.storage[m][w][p]=O.cloneDeep(f.newValue))}}Object.keys(a).length>0&&e(a)})}removeStorageStateListener(){this.stateDisposer&&this.stateDisposer()}diffFunByView(e,t){const s=Re(e),o=Re(t),n={},a={},c={};for(const l of o)if(!s.includes(l)||e[l]===void 0){n[l]={newValue:t[l],oldValue:void 0};continue}for(const l of s){if(O.isEqual(e[l],t[l]))continue;if(!o.includes(l)||t[l]===void 0){n[l]={newValue:void 0,oldValue:e[l]};continue}const u=this.diffFunByScenePath(e[l],t[l],l);Object.assign(a,u.diffScenePath),Object.assign(c,u.diffData)}return{diffData:c,diffScenePath:a,diffView:n}}diffFunByScenePath(e,t,s){const o=Re(e),n=Re(t),a={},c={};for(const l of n)if(!o.includes(l)||e[l]===void 0){a[l]={newValue:t[l],oldValue:void 0,viewId:s};continue}for(const l of o){if(O.isEqual(e[l],t[l]))continue;if(!n.includes(l)||t[l]===void 0){a[l]={newValue:void 0,oldValue:e[l],viewId:s};continue}const u=this.diffFunByKeys(e[l],t[l],l,s);Object.assign(c,u)}return{diffScenePath:a,diffData:c}}diffFunByKeys(e,t,s,o){const n=Re(e),a=Re(t),c={};for(const l of a)(!n.includes(l)||e[l]===void 0)&&(c[l]={oldValue:void 0,newValue:t[l],viewId:o,scenePath:s});for(const l of n)if(!O.isEqual(e[l],t[l])){if(!a.includes(l)||t[l]===void 0){c[l]={newValue:void 0,oldValue:e[l],viewId:o,scenePath:s};continue}a.includes(l)&&(c[l]={oldValue:e[l],newValue:t[l],viewId:o,scenePath:s})}return c}transformKey(e){return this.uid+He+e}isOwn(e){return e.split(He)[0]===this.uid}dispatch(e){const{type:t,workId:s,ops:o,index:n,opt:a,toolsType:c,removeIds:l,updateNodeOpt:u,op:h,selectIds:d,isSync:g,scenePath:p,viewId:f}=e;if(f)switch(t){case D.Clear:const m={};p&&this.storage[f]&&this.storage[f][p]?(delete this.storage[f][p],this.setState(m,{isSync:g,viewId:f,scenePath:p})):this.storage[f]&&(delete this.storage[f],this.setState(m,{isSync:g,viewId:f,scenePath:""})),ht(()=>{var S;this.control.pluginManager.dispatchPluginEvent("syncStorage",f,p),(S=this.control.miniMapManager)==null||S.updateMiniMapCamera(f),this.clearLimitComponents(f,p)},De.syncInterval);break;case D.CreateWork:if(p&&s&&c&&a){const S=this.isLocalId(s.toString())?this.transformKey(s):s;this.control.renderControl.isUsePageAuth(f)&&this.control.renderControl.addRenderPageElementId({viewId:f,scenePath:p,elementId:S.toString()}),this.updateValue(S.toString(),{type:D.CreateWork,workId:s,toolsType:c,opt:a},{isSync:g,viewId:f,scenePath:p})}break;case D.DrawWork:if(p&&s&&typeof n=="number"&&(h!=null&&h.length)){const S=this.isLocalId(s.toString())?this.transformKey(s):s,v=this.storage[f]&&this.storage[f][p]&&this.storage[f][p][S]||void 0;if(v!=null&&v.ops||(v==null?void 0:v.type)===D.FullWork)return;const x=n?((v==null?void 0:v.op)||[]).slice(0,n).concat(h):h||(v==null?void 0:v.op),L=c||(v==null?void 0:v.toolsType),b=a||(v==null?void 0:v.opt),P=u||(v==null?void 0:v.updateNodeOpt);s&&L&&b&&x&&(this.control.renderControl.isUsePageAuth(f)&&this.control.renderControl.addRenderPageElementId({viewId:f,scenePath:p,elementId:S.toString()}),this.updateValue(S.toString(),{...v,type:D.DrawWork,workId:s,updateNodeOpt:P,toolsType:L,opt:b,op:x,index:n},{isSync:g,viewId:f,scenePath:p}))}break;case D.FullWork:if(p&&s){const S=this.isLocalId(s.toString())?this.transformKey(s):s,v=this.storage[f]&&this.storage[f][p]&&this.storage[f][p][S]||void 0,x=u||(v==null?void 0:v.updateNodeOpt),L=c||(v==null?void 0:v.toolsType),b=a||(v==null?void 0:v.opt),P=o||(v==null?void 0:v.ops);L&&b&&(this.control.renderControl.isUsePageAuth(f)&&this.control.renderControl.addRenderPageElementId({viewId:f,scenePath:p,elementId:S.toString()}),this.updateValue(S.toString(),{type:D.FullWork,updateNodeOpt:x,workId:S,toolsType:L,opt:b,ops:P},{isSync:g,viewId:f,scenePath:p}),ht(()=>{var A;this.control.pluginManager.dispatchPluginEvent("syncStorage",f,p),(A=this.control.miniMapManager)==null||A.updateMiniMapCamera(f),this.limitComponents(f,p)},De.syncInterval))}break;case D.RemoveNode:if(p&&(l!=null&&l.length)){const S=l.map(v=>this.isLocalId(v+"")?this.transformKey(v):v);this.storage[f]&&this.storage[f][p]&&(Object.keys(this.storage[f][p]).map(v=>{S!=null&&S.includes(v)&&(this.control.renderControl.isUsePageAuth(f)&&this.control.renderControl.delRenderPageElementId({viewId:f,scenePath:p,elementId:v}),this.updateValue(v,void 0,{isSync:g,viewId:f,scenePath:p}))}),ht(()=>{var v;this.control.pluginManager.dispatchPluginEvent("syncStorage",f,p),(v=this.control.miniMapManager)==null||v.updateMiniMapCamera(f)},De.syncInterval))}break;case D.UpdateNode:if(p&&s&&(u||o||a)){const S=this.isLocalId(s.toString())?this.transformKey(s):s,v=this.storage[f]&&this.storage[f][p]&&this.storage[f][p][S]||void 0;v&&(v.updateNodeOpt=u,(o||h)&&(v.ops=o,v.op=h),a&&(v.opt=a),v.type=D.FullWork,this.updateValue(S.toString(),v,{isSync:g,viewId:f,scenePath:p}),ht(()=>{var x;(x=this.control.miniMapManager)==null||x.updateMiniMapCamera(f)},De.syncInterval))}break;case D.Select:if(!p)return;let w;d!=null&&d.length&&(w=d.map(S=>this.isLocalId(S+"")?this.transformKey(S):S));const I=this.transformKey(G),N=this.storage[f]&&this.storage[f][p]&&this.storage[f][p][I]||void 0,C=a||(N==null?void 0:N.opt);w&&this.checkOtherSelector(I,w,{isSync:g,viewId:f,scenePath:p}),this.updateValue(I,w&&{type:D.Select,toolsType:T.Selector,opt:C,selectIds:w},{isSync:g,viewId:f,scenePath:p});break}}checkOtherSelector(e,t,s){const{viewId:o,scenePath:n}=s;for(const a of Object.keys(this.storage[o][n]))if(a!==e&&this.getLocalId(a)===G){const c=this.storage[o][n][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,s)}}}setState(e,t){const{viewId:s,scenePath:o}=t,n=Re(e);for(let a=0;a<n.length;a++){const c=n[a],l=e[c];typeof l<"u"?(this.storage[s]||(this.storage[s]={}),this.storage[s][o]||(this.storage[s][o]={}),this.storage[s][o][c]=l):delete this.storage[s][o][c]}this.runSyncService(t)}updateValue(e,t,s){const{viewId:o,scenePath:n,storage:a}=s,c=a||this.storage;t===void 0?delete c[o][n][e]:(c[o]||(c[o]={}),c[o][n]||(c[o][n]={}),c[o][n][e]=t),this.runSyncService(s)}runSyncService(e){if(!this.control.renderControl.isWritable){console.warn("The current state is not writable and synchronization cannot be synchronized");return}this.asyncClockState||(this.asyncClockState=!0,setTimeout(()=>{this.asyncClockState=!1,this.syncSerivice(e)},e.isSync?0:De.syncInterval))}syncSerivice(e={storage:this.storage}){const{storage:t}=e,s=t||this.storage,o=Re(this.serviceStorage),n=Re(s),a=new Map;for(const c of o){if(!n.includes(c)){a.set(c,void 0);continue}O.isEqual(this.serviceStorage[c],s[c])||this.syncViewData(s,c)}for(const c of n)o.includes(c)||a.set(c,s[c]);if(a.size>5)this.syncStorageView(s);else for(const[c,l]of a.entries())this.syncUpdataView(s,c,l)}syncViewData(e,t){const s=Re(this.serviceStorage[t]),o=Re(e[t]),n=new Map;for(const a of s){if(!o.includes(a)){n.set(a,void 0);continue}O.isEqual(this.serviceStorage[t][a],e[t][a])||this.syncScenePathData(e,t,a)}for(const a of o)s.includes(a)||n.set(a,e[t][a]);if(n.size>5)this.syncStorageScenePath(t,e[t]);else for(const[a,c]of n.entries())this.syncUpdataScenePath(e,t,a,c)}syncScenePathData(e,t,s){const o=Re(this.serviceStorage[t][s]),n=Re(e[t][s]),a=new Map;for(const c of o){if(!n.includes(c)){a.set(c,void 0);continue}O.isEqual(this.serviceStorage[t][s][c],e[t][s][c])||a.set(c,e[t][s][c])}for(const c of n)o.includes(c)||a.set(c,e[t][s][c]);if(a.size>5)this.syncStorageKey(t,s,e[t][s]);else for(const[c,l]of a.entries())this.syncUpdataKey(e,t,s,c,l)}syncUpdataView(e,t,s){var n;Object.keys(this.serviceStorage).length?(n=this.plugin)==null||n.updateAttributes([this.namespace,t],s):this.syncStorageView(e)}syncStorageView(e){var t;(t=this.plugin)==null||t.updateAttributes([this.namespace],e)}syncUpdataScenePath(e,t,s,o){var a;Object.keys(this.serviceStorage[t]).length?(a=this.plugin)==null||a.updateAttributes([this.namespace,t,s],o):this.syncStorageScenePath(t,e[t])}syncStorageScenePath(e,t){var s;(s=this.plugin)==null||s.updateAttributes([this.namespace,e],t)}syncUpdataKey(e,t,s,o,n){var c;Object.keys(this.serviceStorage[t][s]).length?(c=this.plugin)==null||c.updateAttributes([this.namespace,t,s,o],n):this.syncStorageKey(t,s,e[t][s])}syncStorageKey(e,t,s){var o;(o=this.plugin)==null||o.updateAttributes([this.namespace,e,t],s)}keyTransformWorkId(e){const t=e.split(He);return t.length===2?t[1]:e}destroy(){this.removeStorageStateListener(),this.serviceStorage={},this.storage={},this.removeAuthStateListener(),this.authStorage={}}dispatchPageAuth(e,t=!0){var l,u,h,d,g,p,f,m,w,I,N,C,S,v,x,L,b,P,A,E,R,z,Z,ee,F,X,te,le,se,_,J,de,Fe,ke,q,Le,Ue,st;const{operation:s,viewId:o,scenePath:n,pageId:a,pageData:c}=e;switch(s){case Ye.addPage:{if(!o||!n||!a)return;const H=[this.authSpace];Object.keys(this.authStorage).length&&H.push("pageAuth");const K=this.authStorage.pageAuth||{};this.authStorage.pageAuth=K,Object.keys(K).length&&H.push(o),K[o]=K[o]||{},Object.keys(K[o]).length&&H.push(n),K[o][n]=K[o][n]||{render:(c==null?void 0:c.render)||"localSelf",pages:{}},Object.keys(K[o][n].pages).length&&H.push("pages",a);const ie={};if(c!=null&&c.elementIds)for(const pe of c.elementIds.keys())ie[pe]=!0;K[o][n].pages[a]=ie,t&&(H.length===1?(l=this.plugin)==null||l.updateAttributes(H,O.cloneDeep(this.authStorage)):H.length===2?(u=this.plugin)==null||u.updateAttributes(H,O.cloneDeep(K)):H.length===3?(h=this.plugin)==null||h.updateAttributes(H,O.cloneDeep(K[o])):H.length===4?(d=this.plugin)==null||d.updateAttributes(H,O.cloneDeep(K[o][n])):(g=this.plugin)==null||g.updateAttributes(H,O.cloneDeep(ie)));return}case Ye.renderPage:{if(!o||!n||!(c!=null&&c.render))return;this.authStorage.pageAuth&&this.authStorage.pageAuth[o]&&this.authStorage.pageAuth[o][n]&&c.render!==this.authStorage.pageAuth[o][n].render&&(this.authStorage.pageAuth[o][n].render=c.render,t&&((p=this.plugin)==null||p.updateAttributes([this.authSpace,"pageAuth",o,n,"render"],c.render)));return}case Ye.deletePage:{if(!o||!n||!a)return;(N=(I=(w=(m=(f=this.authStorage)==null?void 0:f.pageAuth)==null?void 0:m[o])==null?void 0:w[n])==null?void 0:I.pages)!=null&&N[a]&&(delete this.authStorage.pageAuth[o][n].pages[a],t&&((C=this.plugin)==null||C.updateAttributes([this.authSpace,"pageAuth",o,n,"pages",a],void 0)));return}case Ye.clearPage:{if(!o||!n||!a)return;(b=(L=(x=(v=(S=this.authStorage)==null?void 0:S.pageAuth)==null?void 0:v[o])==null?void 0:x[n])==null?void 0:L.pages)!=null&&b[a]&&(delete this.authStorage.pageAuth[o][n].pages[a],t&&((P=this.plugin)==null||P.updateAttributes([this.authSpace,"pageAuth",o,n,"pages",a],{})));return}case Ye.addElement:{if(!o||!n||!a||!(c!=null&&c.elementId))return;(Z=(z=(R=(E=(A=this.authStorage)==null?void 0:A.pageAuth)==null?void 0:E[o])==null?void 0:R[n])==null?void 0:z.pages)!=null&&Z[a]&&(this.authStorage.pageAuth[o][n].pages[a][c.elementId]=!0,t&&((ee=this.plugin)==null||ee.updateAttributes([this.authSpace,"pageAuth",o,n,"pages",a,c.elementId],!0)));return}case Ye.deleteElement:{if(!o||!n||!a||!(c!=null&&c.elementId))return;(_=(se=(le=(te=(X=(F=this.authStorage)==null?void 0:F.pageAuth)==null?void 0:X[o])==null?void 0:te[n])==null?void 0:le.pages)==null?void 0:se[a])!=null&&_[c.elementId]&&(delete this.authStorage.pageAuth[o][n].pages[a][c.elementId],t&&((J=this.plugin)==null||J.updateAttributes([this.authSpace,"pageAuth",o,n,"pages",a,c.elementId],void 0)));return}case Ye.clearViewScenePath:{if(!o||!n)return;(ke=(Fe=(de=this.authStorage)==null?void 0:de.pageAuth)==null?void 0:Fe[o])!=null&&ke[n]&&(delete this.authStorage.pageAuth[o][n],t&&((q=this.plugin)==null||q.updateAttributes([this.authSpace,"pageAuth",o,n],void 0)));return}case Ye.clearView:{if(!o)return;(Ue=(Le=this.authStorage)==null?void 0:Le.pageAuth)!=null&&Ue[o]&&(delete this.authStorage.pageAuth[o],t&&((st=this.plugin)==null||st.updateAttributes([this.authSpace,"pageAuth",o],void 0)));return}}}dispatchRenderAuth(e,t=!0){var l,u,h,d,g,p,f,m,w,I,N,C,S,v,x,L,b,P,A,E;const{operation:s,viewId:o,uid:n,renderData:a,isClear:c}=e;if(o)switch(s){case et.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 R=[this.authSpace];Object.keys(this.authStorage).length&&R.push("renderAuth");const z=this.authStorage.renderAuth||{};Object.keys(z).length&&R.push(o),z[o]={},this.authStorage.renderAuth=z;const{render:Z,hide:ee,clear:F}=a;if(Z===!0)z[o].render=!0;else if(O.isSet(Z)){z[o].render={};for(const X of Z.keys())z[o].render[X]=!0}if(ee===!0)z[o].hide=!0;else if(O.isSet(ee)){z[o].hide={};for(const X of ee.keys())z[o].hide[X]=!0}if(F===!0)z[o].clear=!0;else if(O.isSet(F)){z[o].clear={};for(const X of F.keys())z[o].clear[X]=!0}t&&(R.length===1?(u=this.plugin)==null||u.updateAttributes(R,O.cloneDeep(this.authStorage)):R.length===2?(h=this.plugin)==null||h.updateAttributes(R,O.cloneDeep(z)):(d=this.plugin)==null||d.updateAttributes(R,O.cloneDeep(z[o])));return}case et.setShow:{if(!n)return;const R=[this.authSpace];Object.keys(this.authStorage).length&&R.push("renderAuth");const z=this.authStorage.renderAuth||{};Object.keys(z).length&&R.push(o),z[o]=z[o]||{},this.authStorage.renderAuth=z,Object.keys(z[o]).length&&R.push("render"),z[o].render=z[o].render||{},z[o].render!==!0&&(Object.keys(z[o].render).length&&R.push(n),z[o].render[n]=!0),z[o].hide!==!0&&((g=z[o].hide)!=null&&g[n])&&(delete z[o].hide[n],t&&((p=this.plugin)==null||p.updateAttributes([this.authSpace,"renderAuth",o,"hide",n],void 0))),t&&(R.length===1?(f=this.plugin)==null||f.updateAttributes(R,O.cloneDeep(this.authStorage)):R.length===2?(m=this.plugin)==null||m.updateAttributes(R,O.cloneDeep(z)):R.length===3?(w=this.plugin)==null||w.updateAttributes(R,O.cloneDeep(z[o])):(I=this.plugin)==null||I.updateAttributes(R,!0));return}case et.setHide:{if(!n)return;const R=[this.authSpace];Object.keys(this.authStorage).length&&R.push("renderAuth");const z=this.authStorage.renderAuth||{};Object.keys(z).length&&R.push(o),z[o]=z[o]||{},this.authStorage.renderAuth=z,Object.keys(z[o]).length&&R.push("hide"),z[o].hide=z[o].hide||{},z[o].hide!==!0&&(Object.keys(z[o].hide).length&&R.push(n),z[o].hide[n]=!0),z[o].render!==!0&&((N=z[o].render)!=null&&N[n])&&(delete z[o].render[n],t&&((C=this.plugin)==null||C.updateAttributes([this.authSpace,"renderAuth",o,"render",n],void 0))),t&&(R.length===1?(S=this.plugin)==null||S.updateAttributes(R,O.cloneDeep(this.authStorage)):R.length===2?(v=this.plugin)==null||v.updateAttributes(R,O.cloneDeep(z)):R.length===3?(x=this.plugin)==null||x.updateAttributes(R,O.cloneDeep(z[o])):(L=this.plugin)==null||L.updateAttributes(R,!0));return}case et.setClear:{if(!n)return;const R=[this.authSpace];Object.keys(this.authStorage).length&&R.push("renderAuth");const z=this.authStorage.renderAuth||{};Object.keys(z).length&&R.push(o),z[o]=z[o]||{},this.authStorage.renderAuth=z,Object.keys(z[o]).length&&R.push("clear"),z[o].clear=z[o].clear||{},z[o].clear!==!0&&(Object.keys(z[o].clear).length&&R.push(n),c?z[o].clear[n]=!0:delete z[o].clear[n]),t&&(R.length===1?(b=this.plugin)==null||b.updateAttributes(R,O.cloneDeep(this.authStorage)):R.length===2?(P=this.plugin)==null||P.updateAttributes(R,O.cloneDeep(z)):R.length===3?(A=this.plugin)==null||A.updateAttributes(R,O.cloneDeep(z[o])):(E=this.plugin)==null||E.updateAttributes(R,c?!0:void 0));return}}}addAuthStateListener(e){this.authDisposer=$.autorun(async()=>{const t=this.getAuthSpaceData(),{renderAuth:s,pageAuth:o}=t;let n,a;O.isEqual(s,this.authStorage.renderAuth)||(n=this.diffAuthFun(this.authStorage.renderAuth||{},s||{}),this.authStorage.renderAuth=s),O.isEqual(o,this.authStorage.pageAuth)||(a=this.diffAuthPageFun(this.authStorage.pageAuth||{},o||{}),this.authStorage.pageAuth=o),(n||a)&&e(n,a)})}removeAuthStateListener(){this.authDisposer&&this.authDisposer()}diffAuthFun(e,t){const s=Re(e),o=Re(t),n={};for(const a of o)if(!s.includes(a)||e[a]===void 0){n[a]={newValue:t[a],oldValue:void 0};continue}for(const a of s)if(!O.isEqual(e[a],t[a])){if(!o.includes(a)||t[a]===void 0){n[a]={newValue:void 0,oldValue:e[a]};continue}n[a]={newValue:t[a],oldValue:e[a]}}return n}diffAuthPageFun(e,t){const s=Re(e),o=Re(t),n={};for(const a of o)if(!s.includes(a)||e[a]===void 0){n[a]={newValue:t[a],oldValue:void 0};continue}for(const a of s)if(!O.isEqual(e[a],t[a])){if(!o.includes(a)||t[a]===void 0){n[a]={newValue:void 0,oldValue:e[a]};continue}n[a]={newValue:t[a],oldValue:e[a]}}return n}};M(De,"namespace","PluginState"),M(De,"authSpace","PluginAuth"),M(De,"syncInterval",500),M(De,"componentsLimits",[500,1e3]);let Xi=De;class my{constructor(){M(this,"roomMembers",[]);M(this,"onChangeHooks",new Set)}setRoomMembers(i){this.executChangeUidHook(this.roomMembers,i),this.roomMembers=i}executChangeUidHook(i,e){const t={online:e.map(s=>{var o;return((o=s.payload)==null?void 0:o.uid)||s.session}),offline:i.map(s=>{var o;return((o=s.payload)==null?void 0:o.uid)||s.session})};this.onChangeHooks.forEach(s=>s(t))}getAllRoomMembers(){return this.roomMembers}getRoomMember(i){return this.roomMembers.find(e=>{var t;return((t=e.payload)==null?void 0:t.uid)===i})}isOnLine(i){return!!this.getRoomMember(i)}onUidChangeHook(i){this.onChangeHooks.add(i)}destroy(){this.onChangeHooks.clear()}}var tt=(r=>(r[r.Text=1]="Text",r[r.Shape=2]="Shape",r))(tt||{});const Ze=class Ze{createProxy(i){const e=new Proxy(i,{get(t,s,o){const n=Ze.interceptors.hasOwnProperty(s)?Ze.interceptors:t;return Reflect.get(n,s,o)}});return Ze.proxyToRaw.set(e,i),e}};M(Ze,"proxyToRaw",new WeakMap),M(Ze,"interceptors",{entries(...i){return Ze.proxyToRaw.get(this).entries(...i)},forEach(...i){return Ze.proxyToRaw.get(this).forEach(...i)},size(){return Ze.proxyToRaw.get(this).size},get(i){return Ze.proxyToRaw.get(this).get(i)},set(i,e){return Ze.proxyToRaw.get(this).set(i,e)},delete(i,e){return Ze.proxyToRaw.get(this).delete(i)},clear(){return Ze.proxyToRaw.get(this).clear()}});let It=Ze;class wy{constructor(i){M(this,"internalMsgEmitter");M(this,"publicMsgEmitter");M(this,"control");M(this,"editors");M(this,"activeId");M(this,"proxyMap");M(this,"taskqueue",new Map);const{control:e,internalMsgEmitter:t,publicMsgEmitter:s}=i;this.control=e,this.internalMsgEmitter=t,this.publicMsgEmitter=s;const o=new Map;this.proxyMap=new It;const n=this,a=It.interceptors.set;It.interceptors.set=function(l,u){return n.interceptors.set(l,u),a.call(this,l,u)};const c=It.interceptors.delete;It.interceptors.delete=function(l,u){return n.interceptors.delete(l,u),c.call(this,l)},this.editors=this.proxyMap.createProxy(o)}get collector(){return this.control.collector}filterEditor(i){const e=new Map;return this.editors.forEach((t,s)=>{t.viewId===i&&e.set(s,t)}),e}get interceptors(){return{set:(i,e)=>{var g,p,f,m,w,I,N,C;if(!this.collector)return!0;const{viewId:t,scenePath:s,canSync:o,canWorker:n,type:a,opt:c,dataType:l}=e;if(!n&&!o)return!0;const h=((g=this.collector)==null?void 0:g.isLocalId(i))?(p=this.collector)==null?void 0:p.transformKey(i):i,d=((f=this.collector)==null?void 0:f.storage[t])&&this.collector.storage[t][s]&&this.collector.storage[t][s][h]||void 0;d?d.toolsType===T.Text&&(n&&(this.control.worker.queryTaskBatchData({workId:i,msgType:D.UpdateNode}).forEach(S=>{var v;(v=this.control.worker)==null||v.taskBatchData.delete(S)}),(N=this.control.worker)==null||N.taskBatchData.add({workId:i,msgType:D.UpdateNode,dataType:l||B.Local,toolsType:T.Text,opt:c,viewId:t,scenePath:s,willRefresh:!0}),(C=this.control.worker)==null||C.runAnimation()),o&&(ht(()=>{var S;(S=this.collector)==null||S.dispatch({type:D.UpdateNode,workId:i,toolsType:T.Text,opt:c,viewId:t,scenePath:s})},this.control.worker.maxLastSyncTime),c.workState===j.Done&&this.control.runEffectWork(()=>{this.control.worker.setShapeSelectorByWorkId(i,t)}))):a===tt.Text&&(o&&((m=this.collector)==null||m.dispatch({type:c.text&&D.FullWork||D.CreateWork,workId:i,toolsType:T.Text,opt:c,isSync:!0,viewId:t,scenePath:s})),n&&((w=this.control.worker)==null||w.taskBatchData.add({workId:i,msgType:c.text&&D.FullWork||D.CreateWork,dataType:l||B.Local,toolsType:T.Text,opt:c,viewId:t,scenePath:s,willRefresh:!0}),(I=this.control.worker)==null||I.runAnimation()))},delete:i=>{var a,c;if(!this.collector)return!0;const e=this.editors.get(i);if(!e)return!0;const{viewId:t,scenePath:s,canSync:o,canWorker:n}=e;if(!n&&!o)return!0;n&&((a=this.control.worker)==null||a.taskBatchData.add({workId:i,toolsType:T.Text,msgType:D.RemoveNode,dataType:B.Local,viewId:t,scenePath:s,willRefresh:!0}),(c=this.control.worker)==null||c.runAnimation()),o&&ht(()=>{var l;(l=this.collector)==null||l.dispatch({type:D.RemoveNode,removeIds:[i],toolsType:T.Text,viewId:t,scenePath:s})},this.control.worker.maxLastSyncTime)},clear(){return!0}}}computeTextActive(i,e){var o,n,a,c;const t=(o=this.control.viewContainerManager)==null?void 0:o.transformToScenePoint(i,e),s=(n=this.control.viewContainerManager)==null?void 0:n.getCurScenePath(e);e&&s&&((a=this.control.worker)==null||a.taskBatchData.add({msgType:D.GetTextActive,dataType:B.Local,op:t,viewId:e,scenePath:s}),(c=this.control.worker)==null||c.runAnimation())}checkEmptyTextBlur(){var e;let i=this.activeId;for(const[t,s]of this.editors.entries())if(s.opt.uid&&s.opt.uid===((e=this.collector)==null?void 0:e.uid)){i=t;break}if(i){const t=this.editors.get(i);(t==null?void 0:t.opt.text)&&(t==null?void 0:t.opt.text.replace(/\s*,/g,""))?this.unActive(i):this.delete(i,!0,!0)}}onCameraChange(i,e){var t,s;for(const[o,n]of this.editors.entries())if(n.viewId===e){const{boxPoint:a,boxSize:c}=n.opt,l=a&&((t=this.control.viewContainerManager)==null?void 0:t.transformToOriginPoint(a,n.viewId)),u=(s=this.control.viewContainerManager)==null?void 0:s.getCurScenePath(e);if(u&&e){const h={x:l&&l[0]||0,y:l&&l[1]||0,w:c&&c[0]||0,h:c&&c[1]||0,opt:n.opt,scale:i.scale,type:tt.Text,viewId:e,scenePath:u,canWorker:!1,canSync:!1};this.editors.set(o,h),this.control.viewContainerManager.updateTextEditorInfo(e,this.activeId)}}}onServiceDerive(i){var p,f;const{workId:e,opt:t,msgType:s,viewId:o,scenePath:n,dataType:a}=i;if(!e||!o||!n)return;const c=e.toString();if(s===D.RemoveNode){this.delete(c,!0,!0);return}const{boxPoint:l,boxSize:u}=t,h=l&&((p=this.control.viewContainerManager)==null?void 0:p.transformToOriginPoint(l,o)),d=this.control.viewContainerManager.getView(o),g={x:h&&h[0]||0,y:h&&h[1]||0,w:u&&u[0]||0,h:u&&u[1]||0,opt:t,type:tt.Text,canWorker:!0,canSync:!1,dataType:a,scale:((f=d==null?void 0:d.cameraOpt)==null?void 0:f.scale)||1,viewId:o,scenePath:n};this.editors.set(c,g),a===B.Service&&t.workState===j.Done&&this.activeId===c&&(this.activeId=void 0),this.control.viewContainerManager.updateTextEditorInfo(o,this.activeId)}updateForViewEdited(i,e){var s;this.editors.set(i,e);const t=(s=this.taskqueue.get(i))==null?void 0:s.resolve;t&&t(e)}active(i){var t;const e=this.editors.get(i);e&&e.viewId&&(e.opt.workState=j.Start,e.opt.uid=(t=this.collector)==null?void 0:t.uid,this.activeId=i,e.canWorker=!0,e.canSync=!0,this.editors.set(i,e),this.control.viewContainerManager.updateTextEditorInfo(e.viewId,this.activeId))}unActive(i){const e=this.editors.get(i);e&&e.viewId&&(e.opt.workState=j.Done,e.opt.uid=void 0,e.canWorker=!0,e.canSync=!0,this.editors.set(i,e),this.activeId=void 0,this.control.viewContainerManager.updateTextEditorInfo(e.viewId,this.activeId))}createTextForMasterController(i,e){var n;const{workId:t,isActive:s,...o}=i;e&&this.internalMsgEmitter.emit("addUndoTicker",e,o.viewId),o.opt.uid=(n=this.collector)==null?void 0:n.uid,s&&(this.activeId=t),o.dataType=B.Local,o.canWorker=!0,o.canSync=!0,this.editors.set(t,o),this.control.viewContainerManager.updateTextEditorInfo(o.viewId,this.activeId)}updateTextForMasterController(i,e){var n;const{workId:t,...s}=i;e&&this.internalMsgEmitter.emit("addUndoTicker",e,s.viewId);const o=this.editors.get(t)||{};s.opt&&(s.opt.uid=(n=this.collector)==null?void 0:n.uid),s.dataType=B.Local,this.editors.set(t,{...o,...s}),this.control.viewContainerManager.updateTextEditorInfo(s.viewId,this.activeId)}async updateTextControllerWithEffectAsync(i,e){var u;const{workId:t,...s}=i;e&&this.internalMsgEmitter.emit("addUndoTicker",e,s.viewId);const o=this.editors.get(t)||{};s.opt&&(s.opt.uid=(u=this.collector)==null?void 0:u.uid),s.dataType=B.Local;const n={...o,...s};if(this.editors.set(t,n),this.control.viewContainerManager.updateTextEditorInfo(s.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(i)}const a=setTimeout(()=>{var d;const h=(d=this.taskqueue.get(t))==null?void 0:d.resolve;h&&h(n)},50),c=await new Promise(h=>{this.taskqueue.set(t,{resolve:h,clocker:a})}),l=this.taskqueue.get(t);return l&&(l.clocker&&clearTimeout(l.clocker),this.taskqueue.delete(t)),c}updateTextForWorker(i,e){const{workId:t,isActive:s,...o}=i,a={...this.editors.get(t)||{},...o};if(s){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),e&&this.internalMsgEmitter.emit("addUndoTicker",e,o.viewId)}get(i){return this.editors.get(i)}delete(i,e,t){const s=this.editors.get(i);if(s){const o=s.viewId;s.canSync=e,s.canWorker=t,this.editors.delete(i),this.activeId===i&&(this.activeId=void 0),this.control.viewContainerManager.updateTextEditorInfo(o,this.activeId)}}deleteBatch(i,e,t){const s=new Set;for(const o of i){const n=this.editors.get(o);if(n){const a=n.viewId;n.canSync=e,n.canWorker=t,this.editors.delete(o),this.activeId===o&&(this.activeId=void 0),s.add(a)}}for(const o of s)this.control.viewContainerManager.updateTextEditorInfo(o,this.activeId)}clear(i,e){this.editors.forEach((t,s)=>{t.viewId===i&&(e&&(t.canSync=!1),t.canWorker=!1,this.editors.delete(s))}),this.activeId=void 0,this.control.viewContainerManager.updateTextEditorInfo(i,this.activeId)}destory(){this.editors.clear(),this.activeId=void 0}insertText(i,e,t,s){var p,f;const o=(p=this.control.room)==null?void 0:p.state.memberState;if(!o)return;const n=this.control.viewContainerManager.getView(i);if(!(n!=null&&n.focusScenePath))return;const a=n==null?void 0:n.cameraOpt,c=this.control.getToolsOpt(T.Text,o);if(!c)return;const l=(f=this.control.viewContainerManager)==null?void 0:f.transformToOriginPoint([e,t],i),h=Bi(s,{whiteList:{},stripIgnoreTag:!0,stripIgnoreTagBody:["script"]}).split(/\n/),d=c.toolsOpt;d.text=Be(h),d.workState=j.Doing,d.boxPoint=[e,t],d.boxSize=[d.fontSize,d.fontSize];const g=Date.now();return this.control.textEditorManager.checkEmptyTextBlur(),this.control.textEditorManager.createTextForMasterController({workId:g.toString(),x:l&&l[0]||0,y:l&&l[1]||0,scale:(a==null?void 0:a.scale)||1,opt:d,type:tt.Text,isActive:!0,viewId:i,scenePath:n.focusScenePath},g),g.toString()}updateText(i,e){const t=this.editors.get(i.toString());if(!t)return;const o=Bi(e,{whiteList:{},stripIgnoreTag:!0,stripIgnoreTagBody:["script"]}).split(/\n/);t.opt.text=Be(o),this.control.textEditorManager.updateTextForMasterController({workId:i,opt:t.opt,viewId:t.viewId,canSync:!0,canWorker:!0},Date.now())}}class Iy{constructor(i){M(this,"expirationTime",Ie.cursor.expirationTime);M(this,"internalMsgEmitter");M(this,"control");M(this,"eventName","applianc-cursor");M(this,"displayer");M(this,"roomMember");M(this,"animationId");M(this,"maxLastSyncTime",Ie.syncOpt.interval);M(this,"willSendEventWorkers",[]);M(this,"willConsumeEventWorkers",new Map);M(this,"sendEventTimerId");M(this,"animationDrawWorkers",new Map);M(this,"animationEventWorkers",new Map);M(this,"cursorInfoMap",new Map);M(this,"doneRenderCursorInfoMap",new Map);var s,o;const{control:e,internalMsgEmitter:t}=i;this.internalMsgEmitter=t,this.control=e,this.roomMember=e.roomMember,this.maxLastSyncTime=((o=(s=this.control.pluginOptions)==null?void 0:s.syncOpt)==null?void 0:o.interval)||this.maxLastSyncTime}activeCollector(){this.control.plugin&&(this.displayer=this.control.room||this.control.play,this.displayer.addMagixEventListener(this.eventName,this.mainMagixEventListener.bind(this)))}mainMagixEventListener(i){var a;const{event:e,payload:t}=i;if(e!==this.eventName)return;const{uid:s,op:o,type:n}=t;if(((a=this.control.collector)==null?void 0:a.uid)!==s&&n===Jt.Cursor&&(o!=null&&o.length)){const c=this.willConsumeEventWorkers.get(s)||[];for(const l of o){const{viewId:u}=l;O.isNumber(l.consumPoint[0])&&O.isNumber(l.consumPoint[1])&&(l.consumPoint=this.control.viewContainerManager.transformToOriginPoint(l.consumPoint,u)),this.control.renderControl.isFilterCursor(u)&&c.unshift({...l,timestamp:Date.now()})}this.willConsumeEventWorkers.set(s,c),this.runAnimation()}}onFocusViewChange(){this.checkDrawWorks(),this.runAnimation()}updateRoomMembers(i){const{offline:e}=i;for(const t of this.cursorInfoMap.keys())t&&e.includes(t)&&this.cursorInfoMap.delete(t)}getKey(i,e){return`${i}${He}${e}`}getUidAndviewId(i){const[e,t]=i.split(He);return{uid:e,viewId:t}}runAnimation(){this.animationId||(this.animationId=requestAnimationFrame(this.animationCursor.bind(this)))}checkDrawWorks(){var e;const i=this.control.viewContainerManager.focuedViewId;for(const[t,s]of this.animationDrawWorkers.entries()){const{viewId:o,uid:n}=this.getUidAndviewId(t);n!==((e=this.control.collector)==null?void 0:e.uid)&&o!==i&&s.workState===j.Done&&(s.consumPoint=[void 0,void 0])}}animationCursor(){this.animationId=void 0;const i=Date.now();for(const[t,s]of this.animationDrawWorkers.entries()){const{uid:o,viewId:n}=this.getUidAndviewId(t),a=this.roomMember.getRoomMember(o);if(!a){this.animationDrawWorkers.delete(t);continue}const{consumPoint:c,timestamp:l,workState:u}=s,h=this.cursorInfoMap.get(n)||new Map;c&&O.isNumber(c[0])&&O.isNumber(c[1])&&l+this.expirationTime>i?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(n,h):this.cursorInfoMap.delete(n),this.animationDrawWorkers.delete(t)}const e=new Set;for(const[t,s]of this.cursorInfoMap.entries())if(s)for(const[o,n]of s.entries())n.type===1&&n.workState!==j.Done&&e.add(o);else this.cursorInfoMap.delete(t);for(const[t,s]of this.willConsumeEventWorkers.entries()){const o=this.roomMember.getRoomMember(t);if(O.isNumber(o==null?void 0:o.memberId)&&!e.has(o.memberId)){const n=s.pop();n?this.animationEventWorkers.set(t,n):this.willConsumeEventWorkers.delete(t)}}for(const[t,s]of this.animationEventWorkers.entries()){const o=this.roomMember.getRoomMember(t);if(!o){this.animationEventWorkers.delete(t);continue}const{viewId:n,consumPoint:a,timestamp:c}=s,l=this.cursorInfoMap.get(n)||new Map;a&&O.isNumber(a[0])&&O.isNumber(a[1])&&c+this.expirationTime>i?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(n,l):this.cursorInfoMap.delete(n),this.animationEventWorkers.delete(t)}for(const t of this.doneRenderCursorInfoMap.keys())this.cursorInfoMap.has(t)||(this.doneRenderCursorInfoMap.delete(t),this.internalMsgEmitter.emit([ne.Cursor,t],[]));for(const[t,s]of this.cursorInfoMap.entries())if(s!=null&&s.size){const o=[];for(const[a,c]of s.entries()){const{timestamp:l,...u}=c;l+this.expirationTime>i?o.push(u):(s.delete(a),s.size===0&&(this.cursorInfoMap.delete(t),this.doneRenderCursorInfoMap.delete(t),this.internalMsgEmitter.emit([ne.Cursor,t],[])))}const n=this.doneRenderCursorInfoMap.get(t);O.isEqual(n,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(i,e){if(this.displayer&&$.isRoom(this.displayer)){const t=O.isNumber(i[0])&&O.isNumber(i[1])&&this.control.viewContainerManager.transformToScenePoint(i,e)||[void 0,void 0];this.willSendEventWorkers.push({consumPoint:t,viewId:e}),this.sendEventTimerId||(this.sendEventTimerId=setTimeout(()=>{this.dispatchMagixEvent()},this.maxLastSyncTime))}}dispatchMagixEvent(){var i;this.displayer&&$.isRoom(this.displayer)&&this.displayer.isWritable&&this.displayer.dispatchMagixEvent(this.eventName,{type:Jt.Cursor,op:O.cloneDeep(this.willSendEventWorkers),uid:(i=this.control.collector)==null?void 0:i.uid}),this.willSendEventWorkers.length=0,this.sendEventTimerId&&(clearTimeout(this.sendEventTimerId),this.sendEventTimerId=void 0)}collectServiceCursor(i){var n;const{op:e,uid:t,workState:s,viewId:o}=i;if(t&&e&&s&&o){const a=this.roomMember.getRoomMember(t);if(!a||t===((n=this.control.collector)==null?void 0:n.uid))return;const c=this.getKey(t,o);let l=[void 0,void 0];if(O.isNumber(e[0])&&O.isNumber(e[1])){const[h,d]=this.control.viewContainerManager.transformToOriginPoint(e,o);l=[h,d]}if(s===j.Start){for(const h of this.cursorInfoMap.values())if(h!=null&&h.size)for(const d of h.keys())d===a.memberId&&h.delete(d)}const u={consumPoint:l,workState:s,viewId:o,timestamp:Date.now()};if(s===j.Start||s===j.Done){const h=this.willConsumeEventWorkers.get(t);s===j.Start&&h&&this.willConsumeEventWorkers.delete(t),h&&s===j.Done&&(u.timestamp=u.timestamp-this.expirationTime)}this.animationDrawWorkers.set(c,u),this.runAnimation()}}unabled(){var i;this.displayer&&$.isRoom(this.displayer)&&(this.willSendEventWorkers.length=0,this.displayer.dispatchMagixEvent(this.eventName,{type:Jt.Cursor,op:[{viewId:this.control.viewContainerManager.focuedViewId,consumPoint:[void 0,void 0]}],uid:(i=this.control.collector)==null?void 0:i.uid}),this.sendEventTimerId&&(clearTimeout(this.sendEventTimerId),this.sendEventTimerId=void 0))}clearViewCursor(i){var e,t,s;for(const[o]of this.animationDrawWorkers.entries()){const{uid:n}=this.getUidAndviewId(o);n===((e=this.control.collector)==null?void 0:e.uid)&&i===i&&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===((s=this.control.collector)==null?void 0:s.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 i;(i=this.displayer)==null||i.removeMagixEventListener(this.eventName),this.stopAnimation()}}class qe{constructor(){M(this,"useEmtMsg");M(this,"emtType");M(this,"control");M(this,"mainEngine");M(this,"collectListener",(i,e)=>{this.collect(i,e)})}static dispatch(i,e,t){var s;(s=be.InternalMsgEmitter)==null||s.emit([i,e],t)}get serviceColloctor(){return this.control.collector}registerForMainEngine(i,e){return this.emtType=i,this.control=e,this.mainEngine=e.worker,this.mainEngine.internalMsgEmitter.on([this.emtType,this.emitEventType],this.collectListener),this}destroy(){this.emtType&&this.mainEngine&&this.mainEngine.internalMsgEmitter.off([this.emtType,this.emitEventType],this.collectListener)}collectForLocalWorker(i,e){var t,s,o;for(const[n,a]of i)(t=this.mainEngine)==null||t.queryTaskBatchData(a).forEach(c=>{var l;(l=this.mainEngine)==null||l.taskBatchData.delete(c)}),(s=this.mainEngine)==null||s.taskBatchData.add(n);if(e){this.mainEngine.consume();return}(o=this.mainEngine)==null||o.runAnimation()}collectForServiceWorker(i){ht(()=>{i.forEach(e=>{var t;(t=this.serviceColloctor)==null||t.dispatch(e)})},this.mainEngine.maxLastSyncTime)}pause(){var i;if(this.lastEmtData){this.useEmtMsg=!0;const e={...this.lastEmtData,workState:j.Done};this.collect(e,!0),(i=be.InternalMsgEmitter)==null||i.emit(V.ActiveMethod,!1)}}recover(){var i;this.useEmtMsg&&be.InternalMsgEmitter.hasListeners(V.ActiveMethod)&&((i=be.InternalMsgEmitter)==null||i.emit(V.ActiveMethod,!0))}}class Ty extends qe{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",V.CopyNode)}collect(e){var c;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,viewId:s}=e,o=this.control.viewContainerManager.getView(s);if(!(o!=null&&o.displayer))return;const n=o.focusScenePath,a=Date.now();this.mainEngine.internalMsgEmitter.emit("addUndoTicker",a,s);for(const l of t){const u=l.toString(),d=this.serviceColloctor.isLocalId(u)?this.serviceColloctor.transformKey(l):u,g=(c=this.serviceColloctor.getStorageData(s,n))==null?void 0:c[d];if(g){if(l===G){const p=g&&this.copySelector({viewId:s,store:g});p&&this.pasteSelector({...p,viewId:s,scenePath:n,undoTickerId:a});break}if(g.toolsType===T.Text&&g.opt&&g.opt.workState&&g.opt.workState!==j.Done){const p=g&&this.copyText({viewId:s,store:g});p&&this.pasteText({...p,viewId:s,scenePath:n,key:d,store:g,undoTickerId:a});break}}}}copyText(e){const{viewId:t,store:s}=e,o=this.control.viewContainerManager.getView(t);if(!this.serviceColloctor||!o)return;const n=o==null?void 0:o.cameraOpt,a=n&&[n.centerX,n.centerY],c=s.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 m,w;const{bgCenter:t,textCenter:s,store:o,key:n,viewId:a,scenePath:c,undoTickerId:l}=e,u=this.control.viewContainerManager.getView(a);if(!this.serviceColloctor||!u)return;const h=Math.floor(Math.random()*30+1),d=((m=u.cameraOpt)==null?void 0:m.scale)||1,g=t&&s&&[t[0]-s[0]+h,t[1]-s[1]+h]||[h/d,h/d],f=(this.serviceColloctor.isLocalId(n)?n:this.serviceColloctor.getLocalId(n.toString()))+"-"+l;if(o.toolsType===T.Text&&o.opt){const I=o.opt;if(I&&I.boxPoint&&I.text){I.workState=j.Done;const N=I.boxPoint;I.boxPoint=[N[0]+g[0],N[1]+g[1]],I.workState=j.Done;const C=this.control.viewContainerManager.transformToOriginPoint(I.boxPoint,a);this.control.textEditorManager.createTextForMasterController({workId:f,x:C[0],y:C[1],opt:I,scale:((w=u.cameraOpt)==null?void 0:w.scale)||1,type:tt.Text,isActive:!1,viewId:a,scenePath:c}),this.collectForServiceWorker([{...o,opt:I,type:D.FullWork,workId:f,viewId:a,scenePath:c}])}}}copySelector(e){var f,m,w,I,N,C,S,v,x;const{viewId:t,store:s}=e,o=this.control.viewContainerManager.getView(t),n=s.selectIds;if(!this.serviceColloctor||!(n!=null&&n.length)||!o)return;const a=new Map,c={offset:{x:0,y:0},cameraOpt:{centerX:((f=o.cameraOpt)==null?void 0:f.centerX)||0,centerY:((m=o.cameraOpt)==null?void 0:m.centerY)||0,scale:((w=o.cameraOpt)==null?void 0:w.scale)||1}},l=this.control.hasOffscreenCanvas()&&((I=o.displayer.canvasBgRef.current)==null?void 0:I.getBoundingClientRect())||((N=o.displayer.canvasContainerRef.current)==null?void 0:N.getBoundingClientRect()),u=(S=(C=o.displayer)==null?void 0:C.floatBarRef.current)==null?void 0:S.getBoundingClientRect(),h=l&&[l.x+l.width/2,l.y+l.height/2],d=u&&[u.x+u.width/2,u.y+u.height/2],g=h&&o.viewData&&o.viewData.convertToPointInWorld({x:h[0],y:h[1]}),p=d&&o.viewData&&o.viewData.convertToPointInWorld({x:d[0],y:d[1]});g&&p&&(c.offset={x:g.x-p.x,y:g.y-p.y});for(const L of n){const b=(x=(v=this.serviceColloctor)==null?void 0:v.getStorageData(o.id,o.focusScenePath))==null?void 0:x[L];b&&a.set(L,b)}return{copyStores:a,copyCoordInfo:c}}pasteSelector(e){var m,w;const{copyStores:t,copyCoordInfo:s,viewId:o,scenePath:n,undoTickerId:a}=e,c=this.control.viewContainerManager.getView(o);if(!t.size||!this.serviceColloctor||!c)return;const{offset:l,cameraOpt:u}=s,{scale:h}=u,d=Math.floor(Math.random()*30+1),g=l&&[l.x+d,l.y+d]||[d/h,d/h],p=[],f=[];for(const[I,N]of t.entries()){const S=(this.serviceColloctor.isLocalId(I)?I:this.serviceColloctor.getLocalId(I.toString()))+"-"+a,v={useAnimation:!1};if(N.toolsType===T.Text&&N.opt){const L=N.opt;if(L&&L.boxPoint&&L.text){L.workState=j.Done;const b=L.boxPoint;L.boxPoint=[b[0]+g[0],b[1]+g[1]],L.workState=j.Done;const P=this.control.viewContainerManager.transformToOriginPoint(L.boxPoint,o);this.control.textEditorManager.createTextForMasterController({workId:S,x:P[0],y:P[1],opt:L,scale:((m=c.cameraOpt)==null?void 0:m.scale)||1,type:tt.Text,isActive:!1,viewId:o,scenePath:n})}f.push({...N,opt:L,type:D.FullWork,workId:S,viewId:o,scenePath:n});continue}if(N.toolsType===T.Image&&(N.opt.uuid=S,N.opt.centerX=N.opt.centerX+g[0],N.opt.centerY=N.opt.centerY+g[1]),N.ops){const L=Dt(N.ops).map((P,A)=>{const E=A%3;return E===0?P+g[0]:E===1?P+g[1]:P}),b=Be(L);N.ops=b}const x=((w=N==null?void 0:N.opt)==null?void 0:w.eraserlines)??[];if(x.length)for(const L of Object.values(x)){const{op:b}=L;for(let P=0;P<b.length;P++){const A=b[P].map((E,R)=>R%2?E+g[1]:E+g[0]);L.op[P]=A}}f.push({...N,updateNodeOpt:v,type:D.FullWork,workId:S,viewId:o,scenePath:n}),p.push([{...N,updateNodeOpt:v,workId:S,msgType:D.FullWork,dataType:B.Local,emitEventType:V.CopyNode,willSyncService:!1,willRefresh:!0,viewId:o},{workId:S,msgType:D.FullWork,emitEventType:V.CopyNode}])}p.length&&this.collectForLocalWorker(p),f.length&&this.collectForServiceWorker(f)}}class vy extends qe{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",V.SetColorNode);M(this,"undoTickerId")}setTextColor(e,t,s,o){const{fontColor:n,fontBgColor:a}=s;t.opt&&(n&&(t.opt.fontColor=n),a&&(t.opt.fontBgColor=a),this.control.textEditorManager.updateTextForMasterController({workId:e,opt:t.opt,viewId:o,canSync:!0,canWorker:!0}))}collect(e){var I,N;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,strokeColor:s,fillColor:o,fontColor:n,fontBgColor:a,viewId:c,workState:l,thickness:u,strokeType:h}=e,d=this.control.viewContainerManager.getView(c);if(!(d!=null&&d.displayer))return;const g=d.focusScenePath,p=[...t],f=this.serviceColloctor.storage,m=[],w={};for((l===j.Start||!this.undoTickerId&&l===j.Done)&&(this.undoTickerId=Date.now(),this.mainEngine.internalMsgEmitter.emit("addUndoTicker",this.undoTickerId,c));p.length;){const C=p.pop();if(!C)continue;const S=C.toString(),v=this.serviceColloctor.isLocalId(S),x=v?this.serviceColloctor.transformKey(C):S;let L=S;!v&&this.serviceColloctor.isOwn(L)&&(L=this.serviceColloctor.getLocalId(L));const b=(N=(I=f==null?void 0:f[c])==null?void 0:I[g])==null?void 0:N[x];if(b){const P=b.updateNodeOpt||{};if(n||a){if(n){P.fontColor=n;const[E,R,z,Z]=Xt(n);w.textColor=[E,R,z],w.textOpacity=Z}if(a)if(P.fontBgColor=ri(a)?"transparent":a,ri(a))w.textBgColor=void 0,w.textBgOpacity=void 0;else{const[E,R,z,Z]=Xt(a);w.textBgColor=[E,R,z],w.textBgOpacity=Z}if(b.toolsType===T.Text&&b.opt&&l!==j.Start){this.setTextColor(L,Pe(b),P,c),l===j.Done&&(this.undoTickerId=void 0);continue}}if(s){P.strokeColor=s;const[E,R,z,Z]=Xt(s);w.strokeColor=[E,R,z],w.strokeOpacity=Z}if(o)if(P.fillColor=ri(o)?"transparent":o,ri(o))w.fillColor=void 0,w.fillOpacity=void 0;else{const[E,R,z,Z]=Xt(o);w.fillColor=[E,R,z],w.fillOpacity=Z}u&&(P.thickness=u,w.strokeWidth=u),h&&(P.strokeType=h,w.strokeType=h);const A={workId:L,msgType:D.UpdateNode,dataType:B.Local,updateNodeOpt:P,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,textUpdateForWoker:!0,viewId:c};m.push([A,{workId:L,msgType:D.UpdateNode,emitEventType:this.emitEventType}])}}m.length&&(l===j.Done&&(this.undoTickerId=void 0),this.collectForLocalWorker(m)),Object.keys(w).length&&setTimeout(()=>{var C;(C=this.control.room)==null||C.setMemberState(w)},0)}}class Ny extends qe{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",V.ZIndexNode);M(this,"zIndexMap",new Map)}clearZIndex(e){this.zIndexMap.delete(e)}getMinZIndex(e){var t;return((t=this.zIndexMap.get(e))==null?void 0:t.min)||0}getMaxZIndex(e){var t;return((t=this.zIndexMap.get(e))==null?void 0:t.max)||0}setMaxZIndex(e,t){const s=this.getMinZIndex(t);this.zIndexMap.set(t,{min:s,max:e})}setMinZIndex(e,t){const s=this.getMaxZIndex(t);this.zIndexMap.set(t,{min:e,max:s})}addMaxLayer(e){const t=this.getMaxZIndex(e)+1;this.setMaxZIndex(t,e)}addMinLayer(e){const t=this.getMinZIndex(e)-1;this.setMinZIndex(t,e)}correct(e){const t=e.sort((s,o)=>s[1]-o[1]);for(let s=1;s<t.length;s++){const o=t[s][1],n=t[s-1][1];o<=n&&(t[s][1]=n+1)}return t}collect(e){if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,layer:s,viewId:o}=e,n=this.control.viewContainerManager.getView(o);if(!(n!=null&&n.displayer))return;const a=n.focusScenePath,c=[...t],l=this.serviceColloctor.storage,u=[],h=[];for(;c.length;){const g=c.pop();if(!g)continue;const p=g.toString(),f=this.serviceColloctor.isLocalId(p),m=f?this.serviceColloctor.transformKey(g):p;let w=p;!f&&this.serviceColloctor.isOwn(w)&&(w=this.serviceColloctor.getLocalId(w));const I=Pe(l[o][a][m]);let N;if(I&&w===G){if(I.selectIds){h.push(...I.selectIds),h.sort((x,L)=>{var A,E,R,z;const b=((E=(A=l[d(x,this.serviceColloctor)])==null?void 0:A.opt)==null?void 0:E.zIndex)||0,P=((z=(R=l[d(x,this.serviceColloctor)])==null?void 0:R.opt)==null?void 0:z.zIndex)||0;return b>P?1:x<L?-1:0});const C=I.updateNodeOpt||{};C.zIndexLayer=s;const S={workId:g,msgType:D.UpdateNode,dataType:B.Local,updateNodeOpt:C,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:o},v=new Map;s===qt.Top?(this.addMaxLayer(o),N=this.getMaxZIndex(o)):(this.addMinLayer(o),N=this.getMinZIndex(o)),h.forEach(x=>{var A,E,R,z,Z;const L=(A=this.serviceColloctor)==null?void 0:A.isLocalId(x);let b=L&&((E=this.serviceColloctor)==null?void 0:E.transformKey(x))||x;const P=(z=(R=l==null?void 0:l[o])==null?void 0:R[a])==null?void 0:z[b];P&&(!L&&((Z=this.serviceColloctor)!=null&&Z.isOwn(b))&&(b=this.serviceColloctor.getLocalId(b)),C.zIndex=N,P!=null&&P.opt&&(P.opt.zIndex=N),P!=null&&P.opt&&v.set(b,{updateNodeOpt:P.updateNodeOpt,opt:P.opt}))}),S.selectStore=v,S.willSerializeData=!0,u.push([S,{workId:g,msgType:D.UpdateNode,emitEventType:this.emitEventType}])}continue}}u.length&&this.collectForLocalWorker(u);function d(g,p){return p.isLocalId(g)&&p.transformKey(g)||g}}}class Sy extends qe{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",V.TranslateNode);M(this,"cachePosition")}collect(e,t){var p,f,m;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:s,position:o,workState:n,viewId:a}=e;this.lastEmtData=e;const c=this.control.viewContainerManager.getView(a);if(!(c!=null&&c.displayer))return;const l=c.focusScenePath,u=[...s],h=(p=this.serviceColloctor)==null?void 0:p.storage,d=[],g=n===j.Start&&Date.now()||void 0;for(g&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",g,a);u.length;){const w=u.pop();if(!w)continue;const I=w.toString(),N=this.serviceColloctor.isLocalId(I),C=N&&this.serviceColloctor.transformKey(w)||I;let S=I;!N&&this.serviceColloctor.isOwn(S)&&(S=this.serviceColloctor.getLocalId(S));const v=(m=(f=h==null?void 0:h[a])==null?void 0:f[l])==null?void 0:m[C];if(v&&S===G){if(v.selectIds){const x=this.control.viewContainerManager.transformToScenePoint([o.x,o.y],a);if(n===j.Start&&(this.cachePosition=x),this.cachePosition){const L=v.updateNodeOpt||{};L.translate=[x[0]-this.cachePosition[0],x[1]-this.cachePosition[1]],L.workState=n;const b={workId:w,msgType:D.UpdateNode,dataType:B.Local,updateNodeOpt:L,emitEventType:this.emitEventType,willSyncService:!0,textUpdateForWoker:!0,viewId:a};n===j.Done&&(b.textUpdateForWoker=!0,b.willSerializeData=!0,this.cachePosition=void 0),d.push([b,{workId:w,msgType:D.UpdateNode,emitEventType:this.emitEventType,workState:n}])}}continue}}n===j.Start?this.mainEngine.unWritable():n===j.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),d.length&&this.collectForLocalWorker(d,t)}}class Cy extends qe{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",V.DeleteNode)}collect(e){var d,g;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,viewId:s}=e,o=this.control.viewContainerManager.getView(s);if(!(o!=null&&o.displayer))return;const n=o.focusScenePath,a=this.serviceColloctor.storage,c=[...t],l=[],u=[],h=Date.now();for(;c.length;){const p=c.pop();if(!p)continue;const f=p.toString(),m=this.serviceColloctor.isLocalId(f),w=m?this.serviceColloctor.transformKey(p):f,I=(g=(d=a==null?void 0:a[s])==null?void 0:d[n])==null?void 0:g[w];if(I){let N=f;if(!m&&this.serviceColloctor.isOwn(N)&&(N=this.serviceColloctor.getLocalId(N)),I.toolsType===T.Text){this.control.textEditorManager.delete(N,!0,!0);continue}u.push(N)}}u.length&&(l.push([{msgType:D.RemoveNode,emitEventType:V.DeleteNode,removeIds:u,dataType:B.Local,willSyncService:!0,willRefresh:!0,viewId:s},void 0]),this.mainEngine.internalMsgEmitter.emit("addUndoTicker",h,s),this.collectForLocalWorker(l))}}class ky extends qe{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",V.ScaleNode);M(this,"targetText",new Map);M(this,"cacheTextInfo",new Map)}async setTextStyle(e,t,s){const o=await this.control.textEditorManager.updateTextControllerWithEffectAsync({workId:e,opt:t,viewId:s,canSync:!1,canWorker:!1});return{key:e,textInfo:o}}async collect(e,t){var I,N,C,S,v,x,L;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:s,workState:o,viewId:n,originPoint:a,scenePoint:c,dir:l,scale:u,translate:h}=e;this.lastEmtData=e;const d=this.control.viewContainerManager.getView(n);if(!(d!=null&&d.displayer))return;const g=d.focusScenePath,p=[...s],f=(I=this.serviceColloctor)==null?void 0:I.storage,m=[],w=o===j.Start&&Date.now()||void 0;for(w&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",w,n);p.length;){const b=p.pop();if(!b)continue;const P=b.toString(),A=this.serviceColloctor.isLocalId(P),E=A&&this.serviceColloctor.transformKey(b)||P;let R=P;!A&&this.serviceColloctor.isOwn(R)&&(R=this.serviceColloctor.getLocalId(R));const z=(C=(N=f==null?void 0:f[n])==null?void 0:N[g])==null?void 0:C[E];if(z&&R===G&&z.selectIds){const Z=z.updateNodeOpt||{};if(Z.dir=l,Z.originPoint=a,Z.scenePoint=c,Z.workState=o,Z.scale=u,Z.translate=h,o===j.Start){this.cacheTextInfo.clear();for(const F of z.selectIds){const X=(S=this.serviceColloctor)==null?void 0:S.isLocalId(F),te=X&&((v=this.serviceColloctor)==null?void 0:v.transformKey(F))||F;let le=te;!X&&((x=this.serviceColloctor)!=null&&x.isOwn(te))&&(le=this.serviceColloctor.getLocalId(te));const se=this.control.textEditorManager.get(le);se&&o===j.Start&&this.targetText.set(le,Pe(se))}}if(this.targetText.size&&o!==j.Start&&u){const F=[];for(const[te,le]of this.targetText.entries()){const{opt:se}=le,_=Math.floor(se.fontSize*u[0]),J=this.cacheTextInfo.get(te),de=!J&&se.fontSize!==_||J&&J.fontSize!==_||!1,Fe=(L=this.control.textEditorManager.get(te))==null?void 0:L.opt;if(de&&Fe&&se.boxSize&&se.boxPoint){const ke=this.setTextStyle(te,{...Fe,fontSize:_},n);F.push(ke)}}const X=await Promise.all(F);for(const te of X)if(te){const{key:le,textInfo:se}=te;this.cacheTextInfo.set(le,{fontSize:se.opt.fontSize,boxSize:se.opt.boxSize,boxPoint:se.opt.boxPoint})}Z.textInfos=this.cacheTextInfo}const ee={workId:b,msgType:D.UpdateNode,dataType:B.Local,updateNodeOpt:Z,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:n};o===j.Done&&(ee.willSerializeData=!0,this.targetText.clear()),m.push([ee,{workId:b,msgType:D.UpdateNode,emitEventType:this.emitEventType,workState:o}]);continue}}o===j.Start?this.mainEngine.unWritable():o===j.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),m.length&&this.collectForLocalWorker(m,t)}}class xy extends qe{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",V.RotateNode);M(this,"cacheOriginRotate",0)}collect(e,t){var p,f,m,w,I,N,C;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:s,angle:o,workState:n,viewId:a}=e;this.lastEmtData=e;const c=this.control.viewContainerManager.getView(a);if(!(c!=null&&c.displayer))return;const l=c.focusScenePath,u=[...s],h=(p=this.serviceColloctor)==null?void 0:p.storage,d=[],g=n===j.Start&&Date.now()||void 0;for(g&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",g,a);u.length;){const S=u.pop();if(!S)continue;const v=S.toString(),x=this.serviceColloctor.isLocalId(v),L=x&&this.serviceColloctor.transformKey(S)||v;let b=v;!x&&this.serviceColloctor.isOwn(b)&&(b=this.serviceColloctor.getLocalId(b));const P=(m=(f=h==null?void 0:h[a])==null?void 0:f[l])==null?void 0:m[L];if(P&&b===G){if(((w=P.selectIds)==null?void 0:w.length)===1){const A=P.selectIds[0];if(n===j.Start){const Z=((I=this.serviceColloctor)==null?void 0:I.isLocalId(A))&&((N=this.serviceColloctor)==null?void 0:N.transformKey(A))||A,ee=h[a][l][Z];this.cacheOriginRotate=((C=ee==null?void 0:ee.opt)==null?void 0:C.rotate)||0}const E=P.updateNodeOpt||{};E.angle=(o+this.cacheOriginRotate)%360,E.workState=n;const R={workId:S,msgType:D.UpdateNode,dataType:B.Local,updateNodeOpt:E,emitEventType:this.emitEventType,willRefreshSelector:!1,willSyncService:!0,viewId:a};n===j.Done&&(R.willRefreshSelector=!0,R.willSerializeData=!0,this.cacheOriginRotate=0),d.push([R,{workId:S,msgType:D.UpdateNode,emitEventType:this.emitEventType,workState:n}])}continue}}n===j.Start?this.mainEngine.unWritable():n===j.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),d.length&&this.collectForLocalWorker(d,t)}}function Dy(r){switch(r){case T.Text:return tt.Text;case T.SpeechBalloon:case T.Star:case T.Ellipse:case T.Rectangle:case T.Triangle:case T.Rhombus:case T.Polygon:return tt.Shape}}class Ly extends qe{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",V.SetFontStyle);M(this,"timerId")}async setTextStyle(e,t,s,o){const{bold:n,underline:a,lineThrough:c,italic:l,fontSize:u}=s;if(t.toolsType&&Dy(t.toolsType)===tt.Text){t.opt&&(n&&(t.opt.bold=n),O.isBoolean(a)&&(t.opt.underline=a),O.isBoolean(c)&&(t.opt.lineThrough=c),l&&(t.opt.italic=l),u&&(t.opt.fontSize=u));const d=await this.control.textEditorManager.updateTextControllerWithEffectAsync({workId:e,opt:t.opt,viewId:o,canSync:!1,canWorker:!1});return{key:e,textInfo:d}}}async collect(e){var I,N,C,S,v,x;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,bold:s,italic:o,lineThrough:n,underline:a,viewId:c,fontSize:l}=e,u=this.control.viewContainerManager.getView(c);if(!(u!=null&&u.displayer))return;const h=u.focusScenePath,d=[...t],g=this.serviceColloctor.storage,p={},f=Date.now();this.mainEngine.internalMsgEmitter.emit("addUndoTicker",f,c);const m=[];for(;d.length;){const L=d.pop();if(!L)continue;const b=L.toString(),P=this.serviceColloctor.isLocalId(b),A=P?this.serviceColloctor.transformKey(L):b;let E=b;!P&&this.serviceColloctor.isOwn(E)&&(E=this.serviceColloctor.getLocalId(E));const R=(N=(I=g==null?void 0:g[c])==null?void 0:I[h])==null?void 0:N[A];if(R){const z=R.updateNodeOpt||{};if(s&&(z.bold=s,p.bold=s==="bold"),o&&(z.italic=o,p.italic=o==="italic"),O.isBoolean(n)&&(z.lineThrough=n,p.lineThrough=n),O.isBoolean(a)&&(z.underline=a,p.underline=a),l&&(z.fontSize=l,p.textSize=l),R.toolsType===T.Text&&R.opt){const Z=this.setTextStyle(E,O.cloneDeep(R),z,c);m.push(Z);continue}if(R&&E===G&&((C=R.selectIds)!=null&&C.length))for(const Z of R.selectIds){const ee=(S=this.serviceColloctor)==null?void 0:S.isLocalId(Z);let F=ee&&((v=this.serviceColloctor)==null?void 0:v.transformKey(Z))||Z;const X=g[c][h][F]||void 0;if(!ee&&((x=this.serviceColloctor)!=null&&x.isOwn(F))&&(F=this.serviceColloctor.getLocalId(F)),X&&X.toolsType===T.Text&&R.opt){const te=this.setTextStyle(F,O.cloneDeep(X),z,c);m.push(te);continue}}}}const w=await Promise.all(m);for(const L of w)if(L){const{key:b,textInfo:P}=L;P&&(P.canSync=!0,P.canWorker=!0,this.control.textEditorManager.updateForViewEdited(b,P))}Object.keys(p).length&&(this.timerId&&(clearTimeout(this.timerId),this.timerId=void 0),this.timerId=setTimeout(()=>{var L;this.timerId=void 0,(L=this.control.room)==null||L.setMemberState(p)},0))}}class by extends qe{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",V.SetPoint);M(this,"undoTickerId")}collect(e){var I,N,C;if(!this.serviceColloctor||!this.mainEngine)return;const{workId:t,pointMap:s,workState:o,viewId:n}=e,a=this.control.viewContainerManager.getView(n);if(!(a!=null&&a.displayer))return;const c=a.focusScenePath,l=(I=this.serviceColloctor)==null?void 0:I.storage,u=[],h=o===j.Start&&Date.now()||void 0;h&&(this.undoTickerId=h,this.mainEngine.internalMsgEmitter.emit("addUndoTicker",h,n));const d=t;if(!d)return;const g=d.toString(),p=this.serviceColloctor.isLocalId(g),f=p&&this.serviceColloctor.transformKey(d)||g;let m=g;!p&&this.serviceColloctor.isOwn(m)&&(m=this.serviceColloctor.getLocalId(m));const w=(C=(N=l==null?void 0:l[n])==null?void 0:N[c])==null?void 0:C[f];if(w&&m===G&&w.selectIds){const S=w.updateNodeOpt||{};S.pointMap=s,S.workState=o;const v={workId:d,msgType:D.UpdateNode,dataType:B.Local,updateNodeOpt:S,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:n};o===j.Done&&(v.undoTickerId=this.undoTickerId),u.push([v,{workId:d,msgType:D.UpdateNode,emitEventType:this.emitEventType}])}o===j.Start?this.mainEngine.unWritable():o===j.Done&&this.mainEngine.abled(),u.length&&this.collectForLocalWorker(u)}}class jy extends qe{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",V.SetLock)}collect(e){var d,g;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,isLocked:s,viewId:o}=e,n=this.control.viewContainerManager.getView(o);if(!(n!=null&&n.displayer))return;const a=n.focusScenePath,c=[...t],l=this.serviceColloctor.storage,u=[],h=Date.now();for(;c.length;){const p=c.pop();if(!p)continue;const f=p.toString(),m=this.serviceColloctor.isLocalId(f),w=m?this.serviceColloctor.transformKey(p):f;let I=f;!m&&this.serviceColloctor.isOwn(I)&&(I=this.serviceColloctor.getLocalId(I));const N=(g=(d=l==null?void 0:l[o])==null?void 0:d[a])==null?void 0:g[w];if(N){const C=N.updateNodeOpt||{};C.isLocked=s;const S={workId:I,msgType:D.UpdateNode,dataType:B.Local,updateNodeOpt:C,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,viewId:o};u.push([S,{workId:I,msgType:D.UpdateNode,emitEventType:this.emitEventType}])}}this.mainEngine.internalMsgEmitter.emit("addUndoTicker",h,o),u.length&&this.collectForLocalWorker(u)}}class Ay extends qe{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",V.SetShapeOpt)}collect(e){var d,g;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,viewId:s,...o}=e,n=this.control.viewContainerManager.getView(s);if(!(n!=null&&n.displayer))return;const a=n.focusScenePath,c=[...t],l=this.serviceColloctor.storage,u=[],h=Date.now();for(;c.length;){const p=c.pop();if(!p)continue;const f=p.toString(),m=this.serviceColloctor.isLocalId(f),w=m?this.serviceColloctor.transformKey(p):f;let I=f;!m&&this.serviceColloctor.isOwn(I)&&(I=this.serviceColloctor.getLocalId(I));const N=(g=(d=l==null?void 0:l[s])==null?void 0:d[a])==null?void 0:g[w];if(N){const C={...N.updateNodeOpt,...o,willRefresh:!0};if(N&&I===G){const S={workId:I,msgType:D.UpdateNode,dataType:B.Local,updateNodeOpt:C,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,viewId:s};u.push([S,{workId:I,msgType:D.UpdateNode,emitEventType:this.emitEventType}])}}}u.length&&(this.mainEngine.internalMsgEmitter.emit("addUndoTicker",h,s),this.collectForLocalWorker(u))}}class ae{constructor(i){M(this,"builders",new Map);this.builders=new Map(i.map(e=>[e,this.build(e)]))}build(i){switch(i){case V.TranslateNode:return new Sy;case V.ZIndexNode:return new Ny;case V.CopyNode:return new Ty;case V.SetColorNode:return new vy;case V.DeleteNode:return new Cy;case V.ScaleNode:return new ky;case V.RotateNode:return new xy;case V.SetFontStyle:return new Ly;case V.SetPoint:return new by;case V.SetLock:return new jy;case V.SetShapeOpt:return new Ay}}getBuilder(i){return this.builders.get(i)}registerForMainEngine(i,e){return this.builders.forEach(t=>{t&&t.registerForMainEngine(i,e)}),this}destroy(){this.builders.forEach(i=>{i&&i.destroy()}),this.builders.clear()}pause(){return this.builders.forEach(i=>{i&&i.pause()}),this}recover(){return this.builders.forEach(i=>{i&&i.recover()}),this}static emitMethod(i,e,t){qe.dispatch(i,e,t)}static activeListener(i){be.InternalMsgEmitter.on(V.ActiveMethod,i)}static unmountActiveListener(i){be.InternalMsgEmitter.off(V.ActiveMethod,i)}}class Py{constructor(i){M(this,"master");M(this,"mainThreadWorkerMap",new Map);this.master=i}updateCamera(){for(const[i,e]of this.mainThreadWorkerMap.entries()){const t=this.master.control.viewContainerManager.getView(i);if(t){const{cameraOpt:s}=t;e.updateCamera({cameraOpt:s,viewId:t.viewId,msgType:D.UpdateCamera,dataType:B.Local})}}}notifyDrawCount(i){const e=this.master.getFullWorkDrawCount(),t=this.mainThreadWorkerMap.get(i);t&&t.clearDrawLayer(e)}clearDrawCount(i){const e=this.mainThreadWorkerMap.get(i);e&&e.clearDrawLayer(1/0)}createMainThreadWorker(i,e){return new zy(i,e,this)}consume(i){var e;for(const t of i.values()){const{msgType:s,viewId:o,layerOpt:n,offscreenCanvasOpt:a,cameraOpt:c}=t;if(s===D.Console){console.log(this);continue}if(s===D.Init){const u=(e=this.master.control.viewContainerManager.getView(o))==null?void 0:e.displayer,h=u==null?void 0:u.subLocalCanvasContainerRef.current;if(u&&h&&n&&a){const d=this.createMainThreadWorker(o,{displayer:u,container:h,layerOpt:n,master:this.master,canvasOpt:a,post:this.post.bind(this)});this.mainThreadWorkerMap.set(o,d),d&&c&&d.setCameraOpt(c)}continue}if(s===D.TasksQueue)continue;const l=this.mainThreadWorkerMap.get(o);l&&(l.on(t),s===D.Destroy&&(l.destroy(),this.mainThreadWorkerMap.delete(o)))}}post(i){const{sp:e}=i;e&&this.master.collectorSyncData(e)}destroy(){for(const i of this.mainThreadWorkerMap.values())i.destroy();this.mainThreadWorkerMap.clear()}active(){}}class zy{constructor(i,e,t){M(this,"viewId");M(this,"opt");M(this,"manager");M(this,"subLocalLayer");M(this,"subLocalWork");M(this,"scene");M(this,"cameraOpt");this.viewId=i,this.opt=e,this.manager=t,this.scene=this.createScene({...e.canvasOpt,container:e.container});const s=Ie.bufferSize.full,o=Ie.bufferSize.sub;this.subLocalLayer=this.createLayer("subLocalLayer",this.scene,{...e.layerOpt,bufferSize:this.viewId===ge?s:o,contextType:"2d"});const n={thread:this};this.subLocalWork=new Ey(n)}createScene(i){return new he.Scene({displayRatio:this.opt.displayer.dpr,depth:!1,desynchronized:!0,...i,contextType:"2d",autoRender:!0,id:this.viewId})}createLayer(i,e,t){const{width:s,height:o}=t,n=`canvas-${i}`,a=e.layer(n,{...t,offscreen:!1}),c=new he.Group({anchor:[.5,.5],pos:[s*.5,o*.5],size:[s,o],name:"viewport",id:i});return a.append(c),c}updateScene(i){this.scene.attr({...i});const{width:e,height:t}=i;this.scene.width=e,this.scene.height=t,this.updateLayer({width:e,height:t})}updateLayer(i){const{width:e,height:t}=i;this.subLocalLayer.parent.setAttribute("width",e),this.subLocalLayer.parent.setAttribute("height",t),this.subLocalLayer.setAttribute("size",[e,t]),this.subLocalLayer.setAttribute("pos",[e*.5,t*.5])}updateDpr(i){this.scene.displayRatio=i}on(i){const{msgType:e,toolsType:t,opt:s,dataType:o,workId:n,workState:a}=i,c=n==null?void 0:n.toString();switch(e){case D.Destroy:this.destroy();break;case D.Clear:this.clearAll();break;case D.UpdateDpr:O.isNumber(i.dpr)&&this.updateDpr(i.dpr);break;case D.UpdateCamera:this.updateCamera(i);break;case D.UpdateTools:if(t&&this.subLocalWork.canUseSubWorkerLayer(t)&&s){const l={toolsType:t,toolsOpt:s};this.subLocalWork.setToolsOpt(l)}break;case D.CreateWork:c&&s&&t&&this.subLocalWork.canUseSubWorkerLayer(t)&&(this.subLocalWork.getToolsOpt()||this.subLocalWork.setToolsOpt({toolsType:t,toolsOpt:s}),this.subLocalWork.setWorkOptions(c,s));break;case D.DrawWork:t&&this.subLocalWork.canUseSubWorkerLayer(t)&&(a===j.Done&&o===B.Local?this.subLocalWork.consumeDrawAll(i):this.subLocalWork.consumeDraw(i));break;case D.RemoveNode:this.subLocalWork.removeNode(i);return}}setCameraOpt(i){this.cameraOpt=i;const{scale:e,centerX:t,centerY:s,width:o,height:n}=i;(o!==this.scene.width||n!==this.scene.height)&&this.updateScene({width:o,height:n}),this.subLocalLayer&&(this.subLocalLayer.setAttribute("scale",[e,e]),this.subLocalLayer.setAttribute("translate",[-t,-s]))}updateCamera(i){const{cameraOpt:e}=i;e&&!O.isEqual(this.cameraOpt,e)&&(this.subLocalWork.workShapes.size&&this.clearAll(),this.setCameraOpt(e))}clearAll(){this.subLocalLayer.children.length&&(this.subLocalLayer.parent.children.forEach(i=>{i.name!=="viewport"&&i.remove()}),Ve(this.subLocalLayer,this.subLocalLayer.parent)),this.subLocalWork.clearAll()}destroy(){this.subLocalLayer.remove(),Ge(this.subLocalLayer,this.subLocalLayer.parent),this.scene.remove(),this.subLocalWork.destroy()}clearDrawLayer(i){if(i===1/0){this.clearAll();return}const e=this.subLocalLayer.children.filter(t=>t.id&&O.isNumber(parseInt(t.id))&&parseInt(t.id)<i);for(const t of e)t.remove(),Ge(t,this.subLocalLayer.parent)}}class Ey{constructor(i){M(this,"thread");M(this,"workShapes",new Map);M(this,"tmpOpt");M(this,"syncUnitTime",Ie.syncOpt.interval);M(this,"subWorkerDrawCount",0);this.thread=i.thread}getToolsOpt(){return this.tmpOpt}consumeDrawAll(i){const{workId:e}=i,t=e==null?void 0:e.toString();t&&this.workShapes.get(t)&&(this.subWorkerDrawCount=0,Ve(this.thread.subLocalLayer,this.thread.subLocalLayer.parent),this.clearWorkShapeNodeCache(t))}consumeDraw(i){const{workId:e,toolsType:t,postCount:s}=i;e&&t&&this.canUseSubWorkerLayer(t)&&(this.getWorkShape(e.toString())||this.createLocalWork(i));const o=e==null?void 0:e.toString(),n=o&&this.workShapes.get(o);if(!n)return;n.consume({data:i,drawCount:this.subWorkerDrawCount,isFullWork:!1,isSubWorker:!0}),this.subWorkerDrawCount++;const a=this.thread.manager.master;a.setSubWorkerDrawCount(this.subWorkerDrawCount);const c=Math.max(a.getMaxDrawCount(),this.subWorkerDrawCount);a.setMaxDrawCount(c),O.isNumber(s)&&a.setConsumeCount(s)}removeNode(i){const{workId:e}=i,t=e==null?void 0:e.toString();t&&this.workShapes.has(t)&&(this.thread.subLocalLayer.getElementsByName(t).forEach(o=>{o.remove()}),this.clearWorkShapeNodeCache(t))}createLocalWork(i){const{workId:e,toolsType:t,opt:s}=i,o=e==null?void 0:e.toString();t&&this.canUseSubWorkerLayer(t)&&o&&s&&(this.getToolsOpt()||this.setToolsOpt({toolsType:t,toolsOpt:s}),this.setWorkOptions(o,s))}setWorkOptions(i,e){let t=this.workShapes.get(i);if(!t&&this.tmpOpt){const{toolsType:s}=this.tmpOpt;this.tmpOpt.toolsOpt=e,t=this.createWorkShapeNode({workId:i,toolsType:s,toolsOpt:e}),t&&this.workShapes.set(i,t),this.setToolsOpt(this.tmpOpt)}e!=null&&e.syncUnitTime||(e.syncUnitTime=this.syncUnitTime),t&&t.setWorkOptions(e)}destroy(){this.clearAll()}clearAll(){Ve(this.thread.subLocalLayer,this.thread.subLocalLayer.parent),this.workShapes.clear()}canUseSubWorkerLayer(i){return i===T.Pencil}setToolsOpt(i){var e;this.tmpOpt=i,(e=i.toolsOpt)!=null&&e.syncUnitTime&&(this.syncUnitTime=i.toolsOpt.syncUnitTime)}createWorkShapeNode(i){return ji({...i,fullLayer:this.thread.subLocalLayer,drawLayer:this.thread.subLocalLayer})}clearWorkShapeNodeCache(i){this.workShapes.delete(i)}getWorkShape(i){return this.workShapes.get(i)}}const Oy=async(r,i)=>{const{src:e,isgl:t,isCache:s}=r;if(typeof Image=="function"){const o=new Image;return typeof e=="string"&&(o.crossOrigin="anonymous"),new Promise(n=>{o.onload=function(){createImageBitmap(o,{imageOrientation:t?"flipY":"none"}).then(a=>{n(a)})},o.onerror=function(){n(void 0)},o.src=e})}else return fetch(e,{method:"GET",mode:"cors",cache:"default"}).then(o=>o.blob()).then(o=>createImageBitmap(o,{imageOrientation:t?"flipY":"none"}).then(n=>n))};class Ry{constructor(){M(this,"maxLastSyncTime",Ie.syncOpt.interval);M(this,"combineUnitTime",Ie.bezier.combineUnitTime)}setCurrentToolsData(i){this.currentToolsData=i}getCurrentToolsData(){return this.currentToolsData}setCurrentLocalWorkData(i){this.currentLocalWorkData=i}getWorkId(){return this.currentLocalWorkData.workId}get workState(){return this.currentLocalWorkData.workState}}class Wy extends Ry{constructor(e){var n,a,c,l;super();M(this,"isActive",!1);M(this,"currentToolsData");M(this,"currentLocalWorkData");M(this,"control");M(this,"internalMsgEmitter");M(this,"publicMsgEmitter");M(this,"taskBatchData",new Set);M(this,"fullWorker");M(this,"subWorker");M(this,"fullWorkerUrl");M(this,"subWorkerUrl");M(this,"methodBuilder");M(this,"zIndexNodeMethod");M(this,"subWorkerDrawCount",0);M(this,"fullWorkerDrawCount",0);M(this,"maxDrawCount",0);M(this,"_consumeCount",0);M(this,"_postCount",0);M(this,"reRenders",new Map);M(this,"localWorkViewId");M(this,"localPointsBatchData",new Map);M(this,"tasksqueue",new Map);M(this,"useTasksqueue",!1);M(this,"useTasksClockId");M(this,"mainTasksqueueCount");M(this,"workerTasksqueueCount");M(this,"snapshotMap",new Map);M(this,"boundingRectMap",new Map);M(this,"clearAllResolveMap",new Map);M(this,"delayWorkStateToDoneResolve");M(this,"animationId");M(this,"tmpImageConfigMap",new Map);M(this,"mainThread");M(this,"willSelectorWorkId");M(this,"isLockSentEventCursor",!1);M(this,"subMainThreadWorker");M(this,"getVNodeInfoResolveMap",new Map);M(this,"isLocalWorkActive",!1);const{control:t,internalMsgEmitter:s,publicMsgEmitter:o}=e;this.control=t,this.maxLastSyncTime=((a=(n=this.control.pluginOptions)==null?void 0:n.syncOpt)==null?void 0:a.interval)||this.maxLastSyncTime,this.combineUnitTime=((l=(c=this.control.pluginOptions)==null?void 0:c.bezier)==null?void 0:l.combineUnitTime)||this.combineUnitTime,this.fullWorkerUrl=this.control.pluginOptions.cdn.fullWorkerUrl||"",this.subWorkerUrl=this.control.pluginOptions.cdn.subWorkerUrl||"",this.internalMsgEmitter=s,this.publicMsgEmitter=o,this.currentLocalWorkData={workState:j.Pending}}destroy(){var e,t,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.fullWorker)==null||t.terminate(),(s=this.subWorker)==null||s.terminate()}get consumeCount(){return this._consumeCount}set consumeCount(e){this._consumeCount=e}get postCount(){return this._postCount}set postCount(e){this._postCount=e}get viewContainerManager(){return this.control.viewContainerManager}get collector(){return this.control.collector}get isRunSubWork(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===T.Pencil||e===T.PencilEraser||e===T.BitMapEraser||e===T.LaserPen||e===T.Arrow||e===T.Straight||e===T.Ellipse||e===T.Rectangle||e===T.Star||e===T.Polygon||e===T.SpeechBalloon||e===T.Selector}get isCanDrawWork(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===T.Pencil||e===T.LaserPen||e===T.Arrow||e===T.Straight||e===T.Ellipse||e===T.Rectangle||e===T.Star||e===T.Polygon||e===T.SpeechBalloon||e===T.Triangle||e===T.Rhombus||e===T.BitMapEraser||e===T.PencilEraser}get isUseZIndex(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===T.Pencil||e===T.Arrow||e===T.Straight||e===T.Ellipse||e===T.Rectangle||e===T.Star||e===T.Polygon||e===T.SpeechBalloon||e===T.Text||e===T.Image}get isCanRecordUndoRedo(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===T.Pencil||e===T.Eraser||e===T.PencilEraser||e===T.BitMapEraser||e===T.Arrow||e===T.Straight||e===T.Ellipse||e===T.Rectangle||e===T.Star||e===T.Polygon||e===T.SpeechBalloon||e===T.Text||e===T.Image}get isCanSentCursor(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===T.Pencil||e===T.Text||e===T.LaserPen||e===T.Arrow||e===T.Straight||e===T.Ellipse||e===T.Rectangle||e===T.Star||e===T.Polygon||e===T.SpeechBalloon||e===T.Triangle||e===T.Rhombus||e===T.Eraser||e===T.PencilEraser||e===T.BitMapEraser||e===T.Selector}get isPostCountType(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===T.Pencil||e===T.Arrow||e===T.Straight||e===T.Ellipse||e===T.Rectangle||e===T.Star||e===T.Polygon||e===T.SpeechBalloon||e===T.Triangle||e===T.Rhombus||e===T.Eraser||e===T.PencilEraser||e===T.BitMapEraser||e===T.Selector}get isCanPostDraw(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===T.Pencil||e===T.PencilEraser||e===T.BitMapEraser}get isCanStartEventConsum(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===T.Selector||e===T.Eraser||e===T.PencilEraser||e===T.BitMapEraser}async init(){this.destroy(),await this.on(),this.internalMsgEmitterListener(),this.isActive=!0}async useMainThread(){console.info("no OffscreenCanvas");const{MainThreadManagerImpl:e}=await Promise.resolve().then(()=>require("./index-DUGXE2hv.js"));this.mainThread=new e(this)}async on(){if(!this.control.hasOffscreenCanvas()){await this.useMainThread();return}if(!this.fullWorkerUrl||!this.subWorkerUrl){console.error("no worker url config");return}this.fullWorker=new Worker(this.fullWorkerUrl,{type:"classic"}),this.subWorker=new Worker(this.subWorkerUrl,{type:"classic"}),this.subMainThreadWorker=new Py(this),this.fullWorker.onmessage=e=>{var t,s;if(e.data){const{render:o,sp:n,fullWorkerDrawCount:a,workerTasksqueueCount:c,viewId:l,consumeCount:u}=e.data;u&&(this.consumeCount=u),this.isBusy&&c&&this.setWorkerTasksqueueCount(c),n!=null&&n.length&&this.collectorSyncData(n);const h=(o==null?void 0:o.length)&&o||[];if(a&&l){if(this.fullWorkerDrawCount=a,this.fullWorkerDrawCount<1/0){const d=Math.max(this.maxDrawCount,this.fullWorkerDrawCount);this.setMaxDrawCount(d),this.control.priority==="ui"?(t=this.subMainThreadWorker)==null||t.notifyDrawCount(l):this.clearReRenders(this.fullWorkerDrawCount)}else this.setMaxDrawCount(0),this.control.priority==="ui"?(s=this.subMainThreadWorker)==null||s.clearDrawCount(l):this.clearReRenders(1/0);if(this.reRenders.size)for(const d of this.reRenders.values())h.push(...d)}h.length&&this.viewContainerManager.render(h)}},this.subWorker.onmessage=e=>{if(e.data){const{render:t,sp:s,subWorkerDrawCount:o,consumeCount:n}=e.data;n&&(this.consumeCount=n),s!=null&&s.length&&this.collectorSyncData(s);const a=(t==null?void 0:t.length)&&t||[];if(this.control.priority==="cpu"&&O.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)}}}clearReRenders(e=1/0){for(const t of this.reRenders.keys())if(O.isNumber(Number(t))&&Number(t)<=e){const s=this.reRenders.get(Number(t));s==null||s.forEach(o=>{var n;(n=o.imageBitmap)==null||n.close()}),this.reRenders.delete(t)}}get isBusy(){return this.getTasksqueueState()===j.Doing}getLockSentEventCursor(){return this.isLockSentEventCursor}setLockSentEventCursor(e){this.isLockSentEventCursor=e}getTasksqueueState(){return this.useTasksqueue&&j.Doing||j.Done}setMaxDrawCount(e){this.maxDrawCount=e}getFullWorkDrawCount(){return this.fullWorkerDrawCount}getMaxDrawCount(){return this.maxDrawCount}setSubWorkerDrawCount(e){this.subWorkerDrawCount=e}setConsumeCount(e){this.consumeCount=e}getConsumeCount(){return this.consumeCount}setWorkerTasksqueueCount(e){const t=Math.max(this.workerTasksqueueCount||0,e);this.workerTasksqueueCount=t}collectorSyncData(e){var s,o,n,a;let t=!1;for(const c of e){const{type:l,selectIds:u,opt:h,selectRect:d,strokeColor:g,fillColor:p,willSyncService:f,isSync:m,imageBitmap:w,canvasHeight:I,canvasWidth:N,rect:C,op:S,canTextEdit:v,points:x,selectorColor:L,canRotate:b,scaleType:P,textOpt:A,toolsType:E,workId:R,viewId:z,dataType:Z,canLock:ee,isLocked:F,shapeOpt:X,toolsTypes:te,thickness:le,strokeType:se,useStroke:_,isgl:J,imageSrc:de,isSubWorker:Fe}=c;if(!z)return;const ke=c.scenePath||this.viewContainerManager.getCurScenePath(z);switch(l){case D.Select:{const q=u!=null&&u.length?{...d,selectIds:u,canvasHeight:I,canvasWidth:N,points:x}:void 0;q&&(h!=null&&h.strokeColor)&&(q.selectorColor=h.strokeColor),q&&L&&(q.selectorColor=L),q&&g&&(q.strokeColor=g),q&&(h!=null&&h.fillColor)&&(q.fillColor=h.fillColor),q&&p&&(q.fillColor=p),q&&O.isBoolean(b)&&(q.canRotate=b),q&&P&&(q.scaleType=P),q&&v&&(q.canTextEdit=v),q&&A&&(q.textOpt=A),q&&O.isBoolean(ee)&&(q.canLock=ee),q&&O.isBoolean(F)&&(q.isLocked=F),q&&X&&(q.shapeOpt=X),q&&te&&(q.toolsTypes=te),q&&le&&(q.thickness=le),q&&se&&(q.strokeType=se),q&&O.isBoolean(_)&&(q.useStroke=_),z&&this.viewContainerManager.showFloatBar(z,!!q,q),f&&((s=this.collector)==null||s.dispatch({type:l,selectIds:u,opt:h,isSync:m,viewId:z,scenePath:ke}));break}case D.Snapshot:if(w&&ke){const q=this.snapshotMap.get(ke);q&&q(w)}break;case D.BoundingBox:if(C&&ke){const q=this.boundingRectMap.get(ke);q&&q(C)}break;case D.Cursor:S&&this.control.cursor.collectServiceCursor({...c});break;case D.Clear:if(z){this.viewContainerManager.showFloatBar(z,!1);const q=(o=this.clearAllResolveMap.get(z))==null?void 0:o.resolve;q&&q(z)}break;case D.TextUpdate:if(E===T.Text&&R&&z){const q=this.viewContainerManager.transformToOriginPoint((h==null?void 0:h.boxPoint)||[0,0],z),Le=(h==null?void 0:h.boxSize)||[0,0],Ue=(n=this.viewContainerManager.getView(z))==null?void 0:n.cameraOpt;h?this.control.textEditorManager.updateTextForWorker({x:q[0],y:q[1],w:Le[0],h:Le[1],scale:(Ue==null?void 0:Ue.scale)||1,workId:R,opt:h,dataType:Z,viewId:z,canSync:f||!1,canWorker:!1}):this.control.textEditorManager.delete(R,f||!1,!1)}break;case D.GetTextActive:E===T.Text&&R&&z&&this.control.textEditorManager.updateTextForWorker({workId:R,isActive:!0,viewId:z,dataType:B.Local,canWorker:!1,canSync:!0},Date.now());break;case D.GetImageBitMap:de&&z&&R&&Oy({src:de,isgl:J}).then(q=>{var Ue;const Le=new Set;if(Le.add({msgType:D.GetImageBitMap,dataType:B.Local,workId:R,viewId:z,imageSrc:de,isSubWorker:Fe,imageBitmap:q}),!this.control.hasOffscreenCanvas())(Ue=this.mainThread)==null||Ue.consume(Le);else{const st=Fe?this.subWorker:this.fullWorker;q?st.postMessage(Le,[q]):st.postMessage(Le)}});break;case D.GetVNodeInfo:if(R){const q=R.toString(),Le=(a=this.getVNodeInfoResolveMap.get(q))==null?void 0:a.resolve,Ue={...c,uuid:q};Le&&Le(Ue)}break;default:t=!0;break}}t&&this.collectorAsyncData(e)}collectorAsyncData(e){var t,s,o,n;for(const a of e){const{type:c,op:l,workId:u,index:h,removeIds:d,ops:g,opt:p,updateNodeOpt:f,toolsType:m,isSync:w,viewId:I,isLockSentEventCursor:N,nextTasks:C}=a;if(!I){console.error("[MasterControlForWorker] collectorAsyncData on viewId in",a);return}const S=a.scenePath||this.viewContainerManager.getCurScenePath(I);switch(c){case D.None:{N&&ht(()=>{this.setLockSentEventCursor(!1)},this.maxLastSyncTime);break}case D.DrawWork:{(t=this.collector)==null||t.dispatch({type:c,op:l,opt:p,toolsType:m,workId:u,index:h,isSync:w,viewId:I,scenePath:S,updateNodeOpt:f});break}case D.FullWork:{(s=this.collector)==null||s.dispatch({type:c,ops:g,workId:u,updateNodeOpt:f,opt:p,toolsType:m,isSync:w,viewId:I,scenePath:S}),this.willSelectorWorkId&&u&&u.toString()===this.willSelectorWorkId&&this.control.runEffectWork(()=>{this.setShapeSelectorByWorkId(this.willSelectorWorkId,I),this.willSelectorWorkId=void 0});break}case D.UpdateNode:{(o=this.collector)==null||o.dispatch({type:c,updateNodeOpt:f,workId:u,opt:p,ops:g,op:l,isSync:w,viewId:I,scenePath:S});break}case D.RemoveNode:{d&&this.control.textEditorManager.deleteBatch(d,!1,!1),(n=this.collector)==null||n.dispatch({type:c,removeIds:d,isSync:w,viewId:I,scenePath:S}),this.willSelectorWorkId&&(d!=null&&d.includes(this.willSelectorWorkId))&&(this.willSelectorWorkId=void 0);break}}C&&this.collectorAsyncData(C)}}async onLocalEventEnd(e,t){var l;const s=this.viewContainerManager.getView(t);if(!s)return;const{focusScenePath:o,cameraOpt:n}=s,a=this.viewContainerManager.transformToScenePoint(e,t),c=[];for(const u of this.localPointsBatchData.keys())if(((l=this.currentToolsData)==null?void 0:l.toolsType)===T.Text){const h=this.getLocalPointInfo(u),d=h==null?void 0:h.state;if(d&&d===j.Start){const g=this.currentLocalWorkData.toolsOpt;g.workState=j.Doing,g.boxPoint=a,g.boxSize=[g.fontSize,g.fontSize],this.control.textEditorManager.checkEmptyTextBlur(),this.control.textEditorManager.createTextForMasterController({workId:Date.now().toString(),x:e[0],y:e[1],scale:(n==null?void 0:n.scale)||1,opt:g,type:tt.Text,isActive:!0,viewId:t,scenePath:o},Date.now())}this.deleteLocalPoint(u);continue}else this.pushLocalPoint(u,a,j.Done,t),c.push(u);if(c.length){try{if(await new Promise(h=>{setTimeout(async()=>{c.forEach(d=>{this.setLocalPointIsFullWork(d)}),this.delayWorkStateToDoneResolve=h,this.consume()},0)})&&c[0]){const h=c[0];c.forEach(d=>{this.deleteLocalPoint(d)}),this.willSelectorWorkId=h.toString()}}catch(u){console.error("[MasterControlForWorker] onLocalEventEnd error:",u)}this.delayWorkStateToDoneResolve=void 0,c.length=0}}onLocalEventDoing(e,t){var o;if(((o=this.currentToolsData)==null?void 0:o.toolsType)===T.Text)return;this.currentLocalWorkData.workState===j.Start&&this.setCurrentLocalWorkData({...this.currentLocalWorkData,workState:j.Doing});let s=!1;for(const[n,{state:a}]of this.localPointsBatchData.entries())if(this.isAbled()&&a!==j.Pending){const c=this.viewContainerManager.transformToScenePoint(e,t);this.pushLocalPoint(n,c,a===j.Start?j.Doing:a,t),s=!0}if(s){this.runAnimation();return}}onLocalEventStart(e,t){var c,l,u;this.viewContainerManager.focuedViewId!==t&&this.viewContainerManager.setFocuedViewId(t),this.isCanDrawWork&&this.control.room&&!this.control.room.disableDeviceInputs&&(this.control.room.disableDeviceInputs=!0);const s=(c=this.currentToolsData)==null?void 0:c.toolsType,o=s===T.Selector?G:Date.now(),n=this.setZIndex(t);this.setCurrentLocalWorkData({workState:j.Start,toolsOpt:n,viewId:t});const a=this.viewContainerManager.transformToScenePoint(e,t);if(this.pushLocalPoint(o,a,j.Start,t,n),s!==T.Text){if(this.control.textEditorManager.checkEmptyTextBlur(),this.isCanRecordUndoRedo&&this.internalMsgEmitter.emit("addUndoTicker",o,t),o&&n&&s&&this.isCanStartEventConsum&&this.prepareOnceWork({workId:o,toolsOpt:n,viewId:t},s),this.consumeCount=0,this.postCount=0,this.maxDrawCount=0,this.fullWorkerDrawCount=0,this.subWorkerDrawCount=0,this.clearReRenders(1/0),(l=this.subMainThreadWorker)==null||l.clearDrawCount(t),this.isCanDrawWork){const h=this.viewContainerManager.getCurScenePath(t);h&&((u=this.collector)!=null&&u.hasSelector(t,h))&&this.blurSelector(t,h)}this.consume()}}setLocalPointIsFullWork(e){const t=this.getLocalPointInfo(e);t&&(t.isFullWork=!0,this.localPointsBatchData.set(e,t))}pushLocalPoint(e,t,s,o,n){let a=this.getLocalPointInfo(e);s===j.Start?a={state:j.Start,points:t,opt:n||this.currentLocalWorkData.toolsOpt,isFullWork:!1,viewId:o}:a&&(a.state=s,a.points.push(t[0],t[1])),a&&this.localPointsBatchData.set(e,a)}deleteLocalPoint(e){this.localPointsBatchData.delete(e)}getLocalPointInfo(e){return this.localPointsBatchData.get(e)}getLocalPointsInfo(){return this.localPointsBatchData}correctStorage(e,t,s){var c;const o=new Map,n=[];Object.keys(e).forEach(l=>{var h,d;const u=(d=(h=e[l])==null?void 0:h.opt)==null?void 0:d.zIndex;O.isNumber(u)&&n.push([l,u])});const a=n.length&&((c=this.zIndexNodeMethod)==null?void 0:c.correct(n))||[];this.zIndexNodeMethod&&a.length&&(this.zIndexNodeMethod.setMinZIndex(a[0][1]||0,t),this.zIndexNodeMethod.setMaxZIndex(a[a.length-1][1]||0,t));for(const[l,u]of a){if(!e[l])continue;const h=e[l];h.opt&&O.isNumber(h.opt.zIndex)&&h.opt.zIndex!==u&&(h.opt.zIndex=u,o.set(l,h))}return o.size&&o.forEach((l,u)=>{var h;(h=this.collector)==null||h.updateValue(u,l,{viewId:t,scenePath:s,isSync:!0}),e[u]=l}),e}async originalEventLintener(e,t,s){var c,l,u;if(!this.isAbled())return;const o=(c=this.collector)==null?void 0:c.uid,n=this.viewContainerManager.getCurScenePath(s);if(o&&!this.control.renderControl.isWritable)return;const a=((l=this.currentToolsData)==null?void 0:l.toolsType)===T.Selector;switch((u=this.currentToolsData)==null?void 0:u.toolsType){case T.Eraser:case T.PencilEraser:case T.BitMapEraser:{if(o&&!this.control.renderControl.isClearAble({uid:o,viewId:s,scenePath:n}))return;break}default:{if(o&&!this.control.renderControl.isRenderAble({uid:o,viewId:s,scenePath:n}))return;break}}switch(ht(()=>{this.control.pluginManager.dispatchPluginEvent("localEvent",s,e,t)},Ms),e){case j.Start:this.isLocalWorkActive=!0,this.setLocalWorkViewId(s),s&&this.onLocalEventStart(t,s),a&&this.viewContainerManager.showFloatBarBtn(s,!1);break;case j.Doing:s&&s===this.getLocalWorkViewId()&&this.onLocalEventDoing(t,s);break;case j.Done:s&&s===this.getLocalWorkViewId()&&(this.setCurrentLocalWorkData({...this.currentLocalWorkData,workState:j.Done}),await this.onLocalEventEnd(t,s),setTimeout(()=>{this.isLocalWorkActive=!1,this.setCurrentLocalWorkData({workState:j.Pending}),a&&this.viewContainerManager.showFloatBarBtn(s,!0),this.setLocalWorkViewId(void 0)},0));break}this.isLocalWorkActive&&this.viewContainerManager.focuedViewId===s&&this.publicMsgEmitter.emit("workState",e,s)}getLocalWorkViewId(){return this.localWorkViewId}setLocalWorkViewId(e){this.localWorkViewId=e}setCurrentToolsData(e){var o,n,a;const t=e.toolsType,s=((o=this.currentToolsData)==null?void 0:o.toolsType)!==e.toolsType;if(super.setCurrentToolsData(e),s){const c=(n=this.viewContainerManager)==null?void 0:n.getAllViews();for(const l of c)if(l){const{id:u,focusScenePath:h}=l;s&&u&&h&&((a=this.collector)!=null&&a.hasSelector(u,h)&&this.blurSelector(u,h),this.control.textEditorManager.checkEmptyTextBlur())}this.taskBatchData.add({msgType:D.UpdateTools,dataType:B.Local,toolsType:t,opt:{...e.toolsOpt,syncUnitTime:this.maxLastSyncTime},combineUnitTime:this.combineUnitTime,isRunSubWork:this.isRunSubWork,viewId:ci}),this.runAnimation()}}prepareOnceWork(e,t){const{workId:s,toolsOpt:o,viewId:n}=e,a={msgType:D.CreateWork,dataType:B.Local,viewId:n,toolsType:t};this.queryTaskBatchData(a).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add({...a,workId:s,opt:{...o,syncUnitTime:this.maxLastSyncTime},dataType:B.Local,isRunSubWork:this.isRunSubWork}),this.runAnimation()}createViewWorker(e,t){const{offscreenCanvasOpt:s,layerOpt:o,dpr:n,cameraOpt:a}=t;this.taskBatchData.add({msgType:D.Init,dataType:B.Local,viewId:e,offscreenCanvasOpt:s,layerOpt:o,dpr:n,cameraOpt:a,isRunSubWork:!0,isSafari:navigator.userAgent.indexOf("Safari")!==-1&&navigator.userAgent.indexOf("Chrome")===-1,combineUnitTime:this.combineUnitTime,syncUnitTime:this.maxLastSyncTime}),this.isBusy&&this.destroyTaskQueue(),this.consume()}destroyViewWorker(e,t=!1){var s;this.getLocalWorkViewId()===e&&this.setLocalWorkViewId(void 0),this.zIndexNodeMethod&&this.zIndexNodeMethod.clearZIndex(e),this.taskBatchData.add({msgType:D.Destroy,dataType:B.Local,viewId:e,isRunSubWork:!0}),this.consume(),t||(s=this.collector)==null||s.dispatch({type:D.Clear,viewId:e}),this.control.renderControl.destoryByViewId(e,t)}onServiceDerive(e,t){var g,p,f,m,w,I,N;const{newValue:s,oldValue:o,viewId:n,scenePath:a}=t,c=O.cloneDeep(s)||{},l=e;let u=c.type;if(!s&&o){if(l&&((g=this.collector)==null?void 0:g.getLocalId(l))===G){this.collector.isOwn(l)?this.blurSelector(n,a):this.blurSelector(n,a,l);return}if(u=D.RemoveNode,o.toolsType===T.LaserPen)return}const h=(p=this.viewContainerManager.getView(n))==null?void 0:p.focusScenePath;if(h&&h!==a)return;if((f=this.collector)!=null&&f.isSelector(e)){const C=(m=this.collector)==null?void 0:m.getUidFromKey(e);if(C&&!this.control.roomMember.isOnLine(C))return}if(u&&l){if(!this.control.renderControl.isFilterAble({viewId:n,elementId:e,scenePath:a},u))return;const C=c;if(C.workId=(w=this.collector)!=null&&w.isOwn(l)?(I=this.collector)==null?void 0:I.getLocalId(l):l,C.msgType=u,C.toolsType===T.LaserPen&&(C.isRunSubWork=!0),C.dataType=B.Service,C.viewId=n,C.scenePath=a,C.selectIds&&(C.selectIds=C.selectIds.map(S=>{var v,x;return(v=this.collector)!=null&&v.isOwn(S)?(x=this.collector)==null?void 0:x.getLocalId(S):S})),C&&C.toolsType===T.Text||(o==null?void 0:o.toolsType)===T.Text){this.control.textEditorManager.onServiceDerive(C);return}this.taskBatchData.add(C)}this.runAnimation();const d=t.newValue&&((N=t.newValue.opt)==null?void 0:N.zIndex);if(this.zIndexNodeMethod&&O.isNumber(d)){const C=this.zIndexNodeMethod.getMinZIndex(n);this.zIndexNodeMethod.getMaxZIndex(n)<d&&this.zIndexNodeMethod.setMaxZIndex(d,n),C>d&&this.zIndexNodeMethod.setMinZIndex(d,n)}}pullServiceData(e,t,s={isAsync:!1,useAnimation:!1}){var c,l,u,h,d,g,p;let o=(c=this.collector)==null?void 0:c.getStorageData(e,t);const{isAsync:n,useAnimation:a}=s;if(o){this.control.renderControl.isWritable&&(o=this.correctStorage(o,e,t));const f=Object.keys(o);for(const m of f){if((l=this.collector)!=null&&l.isSelector(m)){const I=(u=this.collector)==null?void 0:u.getUidFromKey(m);if(I&&!this.control.roomMember.isOnLine(I))continue}const w=(h=o[m])==null?void 0:h.type;if(w&&m){if(!this.control.renderControl.isFilterAble({viewId:e,elementId:m,scenePath:t},w))continue;const I=o[m];if(I.workId=(d=this.collector)!=null&&d.isOwn(m)?(g=this.collector)==null?void 0:g.getLocalId(m):m,I.msgType=w,I.dataType=B.Service,I.viewId=e,I.scenePath=t,I.useAnimation=I.ops?!!a:((p=I.updateNodeOpt)==null?void 0:p.useAnimation)||!1,I.selectIds&&(I.selectIds=I.selectIds.map(N=>{var C,S;return(C=this.collector)!=null&&C.isOwn(N)?(S=this.collector)==null?void 0:S.getLocalId(N):N})),I.toolsType===T.Text){this.control.textEditorManager.onServiceDerive(I);continue}this.taskBatchData.add(I)}this.internalMsgEmitter.emit("excludeIds",f,e)}n?this.consume():this.runAnimation()}}runAnimation(){!this.animationId&&!this.isBusy&&(this.animationId=requestAnimationFrame(this.consume.bind(this)))}consume(){var t;this.animationId=void 0;const{viewId:e}=this.currentLocalWorkData;if(this.tasksqueue.size){const s=this.consumeQueue(),o=!!s.size;if(this.taskBatchData.size)for(const n of this.taskBatchData.values())n.dataType===B.Service&&(s.add(n),this.taskBatchData.delete(n));s.size?(this.post(s),o&&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:o,isFullWork:n,points:a,opt:c}]of this.localPointsBatchData.entries()){if(o===j.Done&&!n||o===j.Start&&!this.isCanStartEventConsum)continue;const l=a.map(u=>u);if(l.length){if(this.isPostCountType&&o===j.Doing){if(this.postCount>this.consumeCount)continue;this.postCount++}this.delayWorkStateToDoneResolve&&o===j.Done&&(this.delayWorkStateToDoneResolve(!0),this.setLockSentEventCursor(!0)),this.taskBatchData.add({op:l,workState:o,workId:s,dataType:B.Local,msgType:D.DrawWork,isRunSubWork:this.isRunSubWork,toolsType:(t=this.currentToolsData)==null?void 0:t.toolsType,viewId:e,scenePath:e&&this.viewContainerManager.getCurScenePath(e),opt:c,isLockSentEventCursor:this.getLockSentEventCursor(),syncUnitTime:this.maxLastSyncTime,disableEraseImage:this.control.disableEraseImage,disableEraseText:this.control.disableEraseText,postCount:this.isPostCountType&&this.postCount||void 0,fullWorkerDrawCount:this.isCanPostDraw&&this.fullWorkerDrawCount||void 0}),a.length=0}}this.taskBatchData.size&&(this.post(this.taskBatchData),this.taskBatchData.clear()),this.taskBatchData.size&&(this.animationId=requestAnimationFrame(this.consume.bind(this)))}unWritable(){this.setCurrentLocalWorkData({workState:j.Unwritable}),this.setLockSentEventCursor(!0)}abled(){this.setCurrentLocalWorkData({workState:j.Pending}),this.setLockSentEventCursor(!1)}isAbled(){return this.currentLocalWorkData.workState!==j.Unwritable}post(e){var s;if(!this.control.hasOffscreenCanvas()){if(!this.mainThread){let o=[];o=O.cloneDeep([...e]),setTimeout(()=>{for(const n of o)this.taskBatchData.add(n)},0);return}this.mainThread.consume(e);return}this.fullWorker.postMessage(e);const t=new Set;for(const o of e.values()){const n=o.msgType;(n===D.Init||n===D.Clear||n===D.Destroy||n===D.UpdateCamera||o.isRunSubWork)&&t.add(o)}t.size&&(this.subWorker.postMessage(t),this.control.priority==="ui"&&((s=this.subMainThreadWorker)==null||s.consume(t)))}updateNode(e,t,s,o){this.taskBatchData.add({msgType:D.UpdateNode,workId:e,updateNodeOpt:t,viewId:s,scenePath:o,dataType:B.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:D.UpdateDpr,dataType:B.Local,viewId:e}).forEach(s=>{this.taskBatchData.delete(s)}),this.taskBatchData.add({dataType:B.Local,msgType:D.UpdateDpr,viewId:e,dpr:t,isRunSubWork:!0}),this.runAnimation()}updateCamera(e,t){var s;this.useTasksqueue||((s=this.methodBuilder)==null||s.pause(),this.blurCursor(e),this.checkDrawingWork(e),this.useTasksqueue=!0,this.mainTasksqueueCount=1,this.workerTasksqueueCount=1),this.useTasksqueue&&(this.tasksqueue.set(e,{msgType:D.UpdateCamera,dataType:B.Local,cameraOpt:{...t,width:t.width,height:t.height},scenePath:this.viewContainerManager.getCurScenePath(e),isRunSubWork:!0,viewId:e}),this.consume(),this.useTasksClockId&&clearTimeout(this.useTasksClockId),this.updateCameraDone())}updateCameraDone(){this.useTasksClockId=setTimeout(()=>{var e,t;this.useTasksClockId=void 0,this.mainTasksqueueCount===this.workerTasksqueueCount?(this.tasksqueue.size&&this.consume(),this.useTasksqueue=!1,this.mainTasksqueueCount=void 0,this.workerTasksqueueCount=void 0,this.control.priority==="ui"&&((e=this.subMainThreadWorker)==null||e.updateCamera()),(t=this.methodBuilder)==null||t.recover(),this.runAnimation()):this.updateCameraDone()},this.maxLastSyncTime)}consumeQueue(){const e=new Set;let t=!this.isBusy;if(this.isBusy&&this.mainTasksqueueCount&&this.workerTasksqueueCount&&this.mainTasksqueueCount<=this.workerTasksqueueCount&&(t=!0),t){this.mainTasksqueueCount&&this.workerTasksqueueCount&&this.mainTasksqueueCount++,e.add({msgType:D.TasksQueue,dataType:B.Local,isRunSubWork:!0,mainTasksqueueCount:this.mainTasksqueueCount,tasksqueue:this.tasksqueue,viewId:""});for(const[s,o]of this.tasksqueue.entries())o.cameraOpt&&this.control.textEditorManager.onCameraChange(o.cameraOpt,s)}return e}async clearViewScenePath(e,t,s){var n,a;const o=this.viewContainerManager.getCurScenePath(e);if(s){const c=(n=this.collector)==null?void 0:n.uid;if(c&&!this.control.renderControl.isClearAble({uid:c,viewId:e,scenePath:o}))return}this.control.textEditorManager.clear(e,t),this.queryTaskBatchData({msgType:D.Clear,dataType:B.Local,viewId:e}).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add({dataType:B.Local,msgType:D.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:D.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 ae([V.CopyNode,V.SetColorNode,V.DeleteNode,V.RotateNode,V.ScaleNode,V.TranslateNode,V.ZIndexNode,V.SetFontStyle,V.SetPoint,V.SetLock,V.SetShapeOpt]).registerForMainEngine(ne.MainEngine,this.control),this.zIndexNodeMethod=(e=this.methodBuilder)==null?void 0:e.getBuilder(V.ZIndexNode)}setZIndex(e){const t=this.currentToolsData&&O.cloneDeep(this.currentToolsData.toolsOpt);return t&&this.zIndexNodeMethod&&this.isUseZIndex&&(this.zIndexNodeMethod.addMaxLayer(e),t.zIndex=this.zIndexNodeMethod.getMaxZIndex(e)),t}checkDrawingWork(e){var o,n,a;let t=!1;const s=[];for(const[c,{state:l,viewId:u,points:h,opt:d}]of this.localPointsBatchData.entries())if(e===u&&l===j.Start||l===j.Doing){if(l===j.Doing&&this.isCanDrawWork){Number(c)&&Number(c)+60>Date.now()&&(s.push(c.toString()),this.taskBatchData.add({msgType:D.RemoveNode,workId:c,viewId:u,dataType:B.Local,isRunSubWork:!0}));const g=h.map(p=>p);this.taskBatchData.add({op:g,workState:j.Done,workId:c,dataType:B.Local,msgType:D.DrawWork,isRunSubWork:this.isRunSubWork,toolsType:(o=this.currentToolsData)==null?void 0:o.toolsType,viewId:u,opt:d,scenePath:u&&this.viewContainerManager.getCurScenePath(u)}),t=!0}this.deleteLocalPoint(c)}if((t||s.length)&&(this.consume(),s.length)){const c=(n=this.viewContainerManager.getView(e))==null?void 0:n.focusScenePath;(a=this.collector)==null||a.dispatch({type:D.RemoveNode,removeIds:s,viewId:e,scenePath:c})}}removeDrawingWork(e){var s,o;const t=[];for(const[n,{state:a,viewId:c}]of this.localPointsBatchData.entries())(e===c&&a===j.Start||a===j.Doing)&&(this.deleteLocalPoint(n),a===j.Doing&&this.isCanDrawWork&&(t.push(n.toString()),this.taskBatchData.add({msgType:D.RemoveNode,workId:n,viewId:c,dataType:B.Local,isRunSubWork:!0})));if(t.length){this.consume();const n=(s=this.viewContainerManager.getView(e))==null?void 0:s.focusScenePath;(o=this.collector)==null||o.dispatch({type:D.RemoveNode,removeIds:t,viewId:e,scenePath:n})}}removeNodes(e,t){var o,n;const s=(o=this.viewContainerManager.getView(e))==null?void 0:o.focusScenePath;if(s&&t.length){for(const a of t)this.taskBatchData.add({msgType:D.RemoveNode,workId:a,viewId:e,dataType:B.Local,isRunSubWork:!1});this.consume(),(n=this.collector)==null||n.dispatch({type:D.RemoveNode,removeIds:t,viewId:e,scenePath:s})}}hoverCursor(e,t){var s;if(((s=this.currentToolsData)==null?void 0:s.toolsType)===T.Selector&&!this.isBusy){const o=this.viewContainerManager.getView(t);if(o&&o.displayer&&o.displayer.vDom){const c=o.displayer.vDom.state.floatBarData;if(c){const{x:l,y:u,w:h,h:d}=c;if(In(e,{x:l,y:u,w:h,h:d}))return}}const n=this.viewContainerManager.transformToScenePoint(e,t),a={msgType:D.CursorHover,dataType:B.Local,point:n,toolsType:this.currentToolsData.toolsType,opt:this.currentToolsData.toolsOpt,isRunSubWork:!1,viewId:t};this.queryTaskBatchData({msgType:D.CursorHover,dataType:B.Local,toolsType:this.currentToolsData.toolsType,viewId:t}).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add(a),this.runAnimation()}}blurCursor(e){var s;if(((s=this.currentToolsData)==null?void 0:s.toolsType)!==T.Selector)return;const t={msgType:D.CursorBlur,dataType:B.Local,isRunSubWork:!1,viewId:e};this.queryTaskBatchData({msgType:D.CursorHover,dataType:B.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===j.Unwritable||this.isBusy)return;const s=(c=this.currentToolsData)==null?void 0:c.toolsType;if(!this.useTasksqueue&&this.workState===j.Pending&&s===T.Selector&&O.isNumber(e[0])&&O.isNumber(e[1])&&this.hoverCursor(e,t),!this.currentToolsData||!this.isCanSentCursor)return;const o=(l=this.collector)==null?void 0:l.uid,n=this.viewContainerManager.getCurScenePath(t);switch((u=this.currentToolsData)==null?void 0:u.toolsType){case T.Eraser:case T.PencilEraser:case T.BitMapEraser:{if(o&&!this.control.renderControl.isClearAble({uid:o,viewId:t,filterLocalSelf:!1,scenePath:n}))return;break}default:if(o&&!this.control.renderControl.isWritable||o&&!this.control.renderControl.isRenderAble({uid:o,viewId:t,filterLocalSelf:!1,scenePath:n}))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 s,o;if(!((s=this.boundingRectMap)==null?void 0:s.get(e))){const n=(o=this.collector)==null?void 0:o.getScenePathData(e);if(!n)return;if(Object.keys(n).forEach(a=>{var c;((c=this.collector)==null?void 0:c.getLocalId(a))===G&&delete n[a]}),Object.keys(n).length&&this.viewContainerManager.mainView&&this.viewContainerManager.mainView.cameraOpt){const a={msgType:D.BoundingBox,dataType:B.Local,scenePath:e,scenes:n,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,s,o){var a,c,l,u,h;if(!((a=this.snapshotMap)==null?void 0:a.get(e))){const d=(c=this.collector)==null?void 0:c.getViewIdBySecenPath(e);if(!d)return;const g=(l=this.collector)==null?void 0:l.getStorageData(d,e);if(!g)return;if(Object.keys(g).forEach(p=>{var f;((f=this.collector)==null?void 0:f.getLocalId(p))===G&&delete g[p]}),Object.keys(g).length){const p=this.viewContainerManager.mainView;if(!p)return;const f=t||((u=p.cameraOpt)==null?void 0:u.width),m=s||((h=p.cameraOpt)==null?void 0:h.height),w={msgType:D.Snapshot,dataType:B.Local,scenePath:e,scenes:g,w:f,h:m,cameraOpt:o&&{...o,width:f,height:m}||p.cameraOpt,isRunSubWork:!0,viewId:p.id};return this.taskBatchData.add(w),this.runAnimation(),new Promise(I=>{this.snapshotMap.set(e,I)}).then(I=>(this.snapshotMap.delete(e),I))}}}queryTaskBatchData(e){const t=[];if(e)for(const s of this.taskBatchData.values()){let o=!0;for(const[n,a]of Object.entries(e))if(s[n]!==a){o=!1;break}o&&t.push(s)}return t}insertIconify(e,t){var a;const s=this.viewContainerManager.getView(e);if(!s)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 n=s==null?void 0:s.focusScenePath;if(e&&n){const c=Date.now();be.InternalMsgEmitter.emit("addUndoTicker",c,e);const l={...t,type:St.Iconify};this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayer(e),l.zIndex=this.zIndexNodeMethod.getMaxZIndex(e)),this.taskBatchData.add({msgType:D.FullWork,dataType:B.Local,toolsType:T.Image,workId:t.uuid,opt:l,viewId:e,willRefresh:!0,willSyncService:!0}),this.runAnimation()}}insertImage(e,t){const s=this.viewContainerManager.getView(e);if(!s)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=s==null?void 0:s.focusScenePath;if(e&&o){const{src:n,uuid:a}=t;if(a&&!n){this.tmpImageConfigMap.set(a,t);return}const c=Date.now();be.InternalMsgEmitter.emit("addUndoTicker",c,e);const l={...t,type:St.Image};this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayer(e),l.zIndex=this.zIndexNodeMethod.getMaxZIndex(e)),this.taskBatchData.add({msgType:D.FullWork,dataType:B.Local,toolsType:T.Image,workId:t.uuid,opt:l,viewId:e,willRefresh:!0,willSyncService:!0}),this.runAnimation()}}lockImage(e,t,s){var a,c;const o=this.viewContainerManager.getView(e);if(!o)throw new Error("insertImage viewId is not exist");const n=o==null?void 0:o.focusScenePath;if(e&&n&&this.collector){const l=this.collector.getStorageData(e,n);if(!l)return;for(const[u,h]of Object.entries(l))if(h&&h.toolsType===T.Image&&h.opt.uuid===t){const d=Date.now();be.InternalMsgEmitter.emit("addUndoTicker",d,e);const g=(a=this.collector)!=null&&a.isOwn(u)?(c=this.collector)==null?void 0:c.getLocalId(u):u,p={...h.opt,locked:s,type:St.Image};this.taskBatchData.add({msgType:D.FullWork,dataType:B.Local,toolsType:T.Image,workId:g,opt:p,viewId:e,willRefresh:!0,willSyncService:!0}),this.runAnimation();return}}}completeImageUpload(e,t,s){const o=this.viewContainerManager.getView(e);if(!o)throw new Error("insertImage viewId is not exist");const n=o==null?void 0:o.focusScenePath;if(e&&n){const a=this.tmpImageConfigMap.get(t);a&&(a.src=s,this.insertImage(e,a),this.tmpImageConfigMap.delete(t));return}}getImagesInformation(e){const t=[];if(this.collector){const s=this.collector.getScenePathData(e);if(!s)return t;for(const o of Object.values(s))if(o&&o.toolsType===T.Image){const n=o.opt;t.push({uuid:n.uuid,centerX:n.centerX,centerY:n.centerY,width:n.width,height:n.height,locked:n.locked,uniformScale:n.uniformScale,crossOrigin:n.crossOrigin})}}return t}setShapeSelectorByWorkId(e,t){this.taskBatchData.add({workId:G,selectIds:[e],msgType:D.Select,dataType:B.Local,viewId:t,willSyncService:!0}),this.runAnimation()}blurSelector(e,t,s){this.taskBatchData.add({workId:s||G,selectIds:[],msgType:D.Select,dataType:B.Service,viewId:e,scenePath:t}),this.runAnimation()}consoleWorkerInfo(){this.taskBatchData.add({msgType:D.Console,dataType:B.Local,isRunSubWork:!0,viewId:""}),this.consume()}setPriority(e){var o,n;const t=new Set,s=new Set;if(e==="cpu"&&((o=this.subMainThreadWorker)==null||o.destroy(),t.add({msgType:D.PriorityWorker,viewId:ci,dataType:B.Local,isRunSubWork:!0})),e==="ui"){t.add({msgType:D.PriorityMainThreadWorker,viewId:ci,dataType:B.Local,isRunSubWork:!0});const a=this.viewContainerManager.mainView;if(a){const l=this.viewContainerManager.getViewInitData(a.id);if(l){const{offscreenCanvasOpt:u,layerOpt:h,dpr:d,cameraOpt:g}=l;s.add({msgType:D.Init,dataType:B.Local,viewId:a.id,offscreenCanvasOpt:u,layerOpt:h,dpr:d,cameraOpt:g,isRunSubWork:!0,isSafari:navigator.userAgent.indexOf("Safari")!==-1&&navigator.userAgent.indexOf("Chrome")===-1})}}const c=this.viewContainerManager.appViews;for(const l of c.keys()){const u=this.viewContainerManager.getViewInitData(l);if(u){const{offscreenCanvasOpt:h,layerOpt:d,dpr:g,cameraOpt:p}=u;s.add({msgType:D.Init,dataType:B.Local,viewId:l,offscreenCanvasOpt:h,layerOpt:d,dpr:g,cameraOpt:p,isRunSubWork:!0,isSafari:navigator.userAgent.indexOf("Safari")!==-1&&navigator.userAgent.indexOf("Chrome")===-1})}}}t.size&&this.subWorker.postMessage(t),s.size&&((n=this.subMainThreadWorker)==null||n.consume(s))}sendClearUids(e,t){var o,n;const s=new Set;s.add({msgType:D.AuthClear,dataType:B.Local,viewId:e,clearUids:t,localUid:(o=this.collector)==null?void 0:o.uid}),this.control.hasOffscreenCanvas()?this.fullWorker.postMessage(s):(n=this.mainThread)==null||n.consume(s)}async getVNodeInfo(e,t,s){if(!this.getVNodeInfoResolveMap.has(e))return this.taskBatchData.add({msgType:D.GetVNodeInfo,dataType:B.Local,isRunSubWork:!0,viewId:t,workIds:s,workId:e}),this.consume(),await new Promise(o=>{const n=this.getVNodeInfoResolveMap.get(e)||{resolve:void 0,timer:void 0};n.timer&&clearTimeout(n.timer),n.resolve=o,n.timer=setTimeout(()=>{const a=this.getVNodeInfoResolveMap.get(e);a!=null&&a.resolve&&a.resolve({uuid:e})},this.maxLastSyncTime*5),this.getVNodeInfoResolveMap.set(e,n)}).then(o=>{const{uuid:n}=o;return this.getVNodeInfoResolveMap.delete(n),o})}}var Yy=it,Uy=function(){return Yy.Date.now()},By=Uy,Fy=/\s/;function Vy(r){for(var i=r.length;i--&&Fy.test(r.charAt(i)););return i}var Qy=Vy,Zy=Qy,Hy=/^\s+/;function Gy(r){return r&&r.slice(0,Zy(r)+1).replace(Hy,"")}var $y=Gy,Xy=kt,Jy=at,qy="[object Symbol]";function Ky(r){return typeof r=="symbol"||Jy(r)&&Xy(r)==qy}var _y=Ky,em=$y,fo=Mt,tm=_y,Mo=NaN,im=/^[-+]0x[0-9a-f]+$/i,sm=/^0b[01]+$/i,om=/^0o[0-7]+$/i,nm=parseInt;function rm(r){if(typeof r=="number")return r;if(tm(r))return Mo;if(fo(r)){var i=typeof r.valueOf=="function"?r.valueOf():r;r=fo(i)?i+"":i}if(typeof r!="string")return r===0?r:+r;r=em(r);var e=sm.test(r);return e||om.test(r)?nm(r.slice(2),e?2:8):im.test(r)?Mo:+r}var am=rm,cm=Mt,Wi=By,yo=am,lm="Expected a function",hm=Math.max,um=Math.min;function dm(r,i,e){var t,s,o,n,a,c,l=0,u=!1,h=!1,d=!0;if(typeof r!="function")throw new TypeError(lm);i=yo(i)||0,cm(e)&&(u=!!e.leading,h="maxWait"in e,o=h?hm(yo(e.maxWait)||0,i):o,d="trailing"in e?!!e.trailing:d);function g(v){var x=t,L=s;return t=s=void 0,l=v,n=r.apply(L,x),n}function p(v){return l=v,a=setTimeout(w,i),u?g(v):n}function f(v){var x=v-c,L=v-l,b=i-x;return h?um(b,o-L):b}function m(v){var x=v-c,L=v-l;return c===void 0||x>=i||x<0||h&&L>=o}function w(){var v=Wi();if(m(v))return I(v);a=setTimeout(w,f(v))}function I(v){return a=void 0,d&&t?g(v):(t=s=void 0,n)}function N(){a!==void 0&&clearTimeout(a),l=0,t=c=s=a=void 0}function C(){return a===void 0?n:I(Wi())}function S(){var v=Wi(),x=m(v);if(t=arguments,s=this,c=v,x){if(a===void 0)return p(c);if(h)return clearTimeout(a),a=setTimeout(w,i),g(c)}return a===void 0&&(a=setTimeout(w,i)),n}return S.cancel=N,S.flush=C,S}var pm=dm,gm=pm,fm=Mt,Mm="Expected a function";function ym(r,i,e){var t=!0,s=!0;if(typeof r!="function")throw new TypeError(Mm);return fm(e)&&(t="leading"in e?!!e.leading:t,s="trailing"in e?!!e.trailing:s),gm(r,i,{leading:t,maxWait:i,trailing:s})}var mm=ym;const vn=Ut(mm);class wm{constructor(i){M(this,"internalMsgEmitter");M(this,"control");M(this,"roomHotkeyCheckers");M(this,"tmpCopyStore",new Map);M(this,"tmpCopyCoordInfo");var s;const{control:e,internalMsgEmitter:t}=i;this.control=e,this.internalMsgEmitter=t,this.roomHotkeyCheckers=((s=this.control.room)==null?void 0:s.viewsParams.hotKeys.nodes)||[]}get isUseSelf(){var i;return((i=this.control)==null?void 0:i.disableDeviceInputs)||!1}get isSelector(){var i;return((i=this.control.worker.currentToolsData)==null?void 0:i.toolsType)===T.Selector}get collector(){return this.control.collector}get mainEngine(){return this.control.worker}get keyboardKind(){return/^Mac/i.test(navigator.platform)?"mac":"windows"}getEventKey(i){switch(i.type){case"keydown":return"KeyDown"}return"KeyUp"}onActiveHotkey(i){var s,o,n;const e=this.control.viewContainerManager.focuedViewId,t=(s=this.control.viewContainerManager.focuedView)==null?void 0:s.focusScenePath;if(e&&t)switch(i){case"delete":this.isSelector&&((o=this.collector)!=null&&o.hasSelector(e,t))&&ae.emitMethod(ne.MainEngine,V.DeleteNode,{workIds:[G],viewId:e});break;case"copy":this.isSelector&&((n=this.collector)!=null&&n.hasSelector(e,t))&&this.copySelectorToTemp(e,t);break;case"paste":this.tmpCopyStore.size&&this.pasteTempToFocusView(e,t);break}(i==="changeToPencil"||i==="redo"||i==="undo")&&this.onSelfActiveHotkey(i)}colloctHotkey(i){if(this.isUseSelf){const e=this.checkHotkey(i);e&&this.onSelfActiveHotkey(e)}}onSelfActiveHotkey(i){switch(i){case"changeToPencil":this.setMemberState({currentApplianceName:re.pencil,useNewPencil:!0});break;case"changeToArrow":this.setMemberState({currentApplianceName:re.arrow});break;case"changeToClick":this.setMemberState({currentApplianceName:re.clicker});break;case"changeToEllipse":this.setMemberState({currentApplianceName:re.ellipse});break;case"changeToEraser":this.setMemberState({currentApplianceName:re.eraser,isLine:!0});break;case"changeToHand":this.setMemberState({currentApplianceName:re.hand});break;case"changeToLaserPointer":this.setMemberState({currentApplianceName:re.laserPointer});break;case"changeToSelector":this.setMemberState({currentApplianceName:re.selector});break;case"changeToRectangle":this.setMemberState({currentApplianceName:re.rectangle});break;case"changeToStraight":this.setMemberState({currentApplianceName:re.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:re.text});break}}checkHotkey(i){for(const e of this.roomHotkeyCheckers){const{kind:t,checker:s}=e;if(s({nativeEvent:i,kind:this.getEventKey(i),key:i.key,altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey},this.keyboardKind))return t}}copySelectorToTemp(i,e){var l,u;const t=this.control.viewContainerManager.getView(i),s=(u=(l=this.mainEngine)==null?void 0:l.methodBuilder)==null?void 0:u.getBuilder(V.CopyNode);if(!t||!this.collector||!s)return;const o=this.collector.transformKey(G),n=this.collector.getStorageData(i,e);if(!n)return;const a=n[o],c=a&&s.copySelector({viewId:i,store:a});c&&(this.tmpCopyCoordInfo=c==null?void 0:c.copyCoordInfo,this.tmpCopyStore=c==null?void 0:c.copyStores)}pasteTempToFocusView(i,e){var o,n;const t=this.control.viewContainerManager.getView(i),s=(n=(o=this.mainEngine)==null?void 0:o.methodBuilder)==null?void 0:n.getBuilder(V.CopyNode);if(!(!t||!this.tmpCopyCoordInfo||!this.tmpCopyStore.size||!this.collector||!s)&&t.viewData&&this.tmpCopyCoordInfo){const a=O.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=Date.now();this.control.worker.internalMsgEmitter.emit("addUndoTicker",u,i),s.pasteSelector({viewId:i,scenePath:e,copyStores:O.cloneDeep(this.tmpCopyStore),copyCoordInfo:{offset:a,cameraOpt:l},undoTickerId:u})}}setMemberState(i){var e;(e=this.control.room)==null||e.setMemberState(i)}}class Im{constructor(i){M(this,"control");M(this,"roomMemberManager");M(this,"worker");M(this,"publicMsgEmitter");M(this,"renderUids",new Map);M(this,"pageAuth",new Map);M(this,"isLocalRender",!1);M(this,"isCurWritable",!1);var s;const{control:e,publicMsgEmitter:t}=i;this.control=e,this.publicMsgEmitter=t,this.roomMemberManager=e.roomMember,this.worker=e.worker,this.isCurWritable=((s=this.control.room)==null?void 0:s.isWritable)||!1}get isWritable(){return this.isCurWritable}onWritableChange(i){this.isCurWritable=i}addPage(i,e=!0){var l,u;const{viewId:t,render:s="localSelf",elementIds:o,pageId:n=(l=this.control.collector)==null?void 0:l.uid}=i,a=this.pageAuth.get(t)||new Map,c=this.control.viewContainerManager.getCurScenePath(t);if(c&&n){const h=a.get(c)||{render:"localSelf",pages:new Map};e&&(h.render=s);const d=o&&this.cloneElementIds(t,c,o,n)||new Set;h.pages.set(n,d),a.set(c,h),this.pageAuth.set(t,a),e&&this.pageAuthEffect(t),this.isLocalRender=!1,(u=this.control.collector)==null||u.dispatchPageAuth({operation:Ye.addPage,viewId:t,scenePath:c,pageId:n,pageData:{render:s,elementIds:d}},!0)}}delPage(i,e){var n,a;const t=this.pageAuth.get(e);if(!t)return;const s=[...t.keys()].find(c=>{const l=t.get(c);return!!(l&&l.pages.has(i))});if(!s)return;const o=t.get(s);if(o){const{render:c,pages:l}=o,u=c==="localSelf"?(n=this.control.collector)==null?void 0:n.uid:c,h=l.get(i);h!=null&&h.size&&this.delElementIds(e,s,h),l.delete(i),u===i&&this.pageAuthEffect(e)}(a=this.control.collector)==null||a.dispatchPageAuth({operation:Ye.deletePage,viewId:e,scenePath:s,pageId:i},!0)}delViewPage(i,e=!0){var s;this.pageAuth.get(i)&&(this.pageAuth.delete(i),e&&((s=this.control.collector)==null||s.dispatchPageAuth({operation:Ye.clearView,viewId:i},e)))}clearRenderPage(i,e,t=!0){var a,c;const s=this.pageAuth.get(i);if(!s)return;const o=s.get(e);let n;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 d=u.get(h);d&&this.delElementIds(i,e,d)}u.set(h,new Set),n=h}}t&&n&&((c=this.control.collector)==null||c.dispatchPageAuth({operation:Ye.clearPage,viewId:i,scenePath:e,pageId:n},t))}hasPage(i,e,t){const s=this.pageAuth.get(e);if(!s)return!1;const o=s.get(t);return o?o.pages.has(i):!1}getPageInfo(i,e,t){const s=this.pageAuth.get(e);if(!s)return;const o=s.get(t);if(o)return o.pages.get(i)}addRenderPageElementId(i,e=!0,t=!1){var u,h;const{viewId:s,elementId:o,scenePath:n}=i,a=this.pageAuth.get(s);if(!a)throw new Error(`no view info in viewId: ${s}`);const c=a.get(n);let l;if(c){const{render:d,pages:g}=c,p=d==="localSelf"?(u=this.control.collector)==null?void 0:u.uid:d;if(p&&g.has(p)){const f=g.get(p)||new Set;f.add(o),g.set(p,f),l=p}}t&&this.pageAuthEffect(s),e&&l&&((h=this.control.collector)==null||h.dispatchPageAuth({operation:Ye.addElement,viewId:s,scenePath:n,pageId:l,pageData:{elementId:o}},e))}delRenderPageElementId(i,e=!0,t=!1){var u,h;const{viewId:s,elementId:o,scenePath:n}=i,a=this.pageAuth.get(s);if(!a)throw new Error(`no view info in viewId: ${s}`);const c=a.get(n);let l;if(c){const{render:d,pages:g}=c,p=d==="localSelf"?(u=this.control.collector)==null?void 0:u.uid:d;if(p&&g.has(p)){const f=g.get(p);f&&(f.delete(o),g.set(p,f),l=p)}}t&&this.pageAuthEffect(s),e&&l&&((h=this.control.collector)==null||h.dispatchPageAuth({operation:Ye.deleteElement,viewId:s,scenePath:n,pageId:l,pageData:{elementId:o}},e))}setPageRender(i,e,t,s=!0){var a;const o=this.pageAuth.get(i);if(!o)throw new Error(`no view info in viewId: ${i}`);const n=o.get(e);n&&(n.render=t),e===this.control.viewContainerManager.getCurScenePath(i)&&this.pageAuthEffect(i),s||(this.isLocalRender=!0),s&&(this.isLocalRender=!1,(a=this.control.collector)==null||a.dispatchPageAuth({operation:Ye.renderPage,viewId:i,scenePath:e,pageData:{render:t}},s))}isRenderAble(i){var c,l;const{uid:e,viewId:t,filterLocalSelf:s=!0,scenePath:o}=i,n=this.renderUids.get(t);if(n){const{render:u,hide:h}=n;if(u===void 0&&h===void 0)return!0;if(O.isSet(u)){if(u.has(e)||s&&((c=this.control.collector)==null?void 0:c.uid)===e&&u.has("localSelf"))return!0}else if(u===!0&&(!h||O.isSet(h)&&!h.has(e)&&!(s&&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"&&!s)}}return!0}isClearAble(i){var c;const{uid:e,viewId:t,filterLocalSelf:s=!0,scenePath:o}=i,n=this.renderUids.get(t);if(n){const{clear:l}=n;return!!(l===void 0||l===!0||O.isSet(l)&&(l.has(e)||s&&((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"&&!s)}}return!0}isFilterAble(i,e){var c,l,u,h;const{viewId:t,scenePath:s,elementId:o}=i,n=this.renderUids.get(t);if(n&&o){const{render:d,hide:g}=n;if(d===void 0&&g===void 0)return!0;const p=(c=this.control.collector)==null?void 0:c.getUidFromKey(o);return p?!!(O.isSet(d)&&(d.has(p)||d.has("localSelf")&&((l=this.control.collector)==null?void 0:l.uid)===p)||d===!0&&(!g||O.isSet(g)&&!g.has(p)&&!(g.has("localSelf")&&((u=this.control.collector)==null?void 0:u.uid)===p))):!1}const a=this.pageAuth.get(t);if(a&&s&&o){const d=a.get(s);if(d){const{render:g,pages:p}=d;if(!g)return!0;const f=(h=this.control.collector)==null?void 0:h.uid,m=g==="localSelf"?f:g,w=m&&p.get(m)||void 0;if(w)switch(e){case D.RemoveNode:return!0;default:return w.has(o)}return!1}}return!0}isFilterCursor(i){if(this.isUsePageAuth(i)){const e=this.control.viewContainerManager.getCurScenePath(i),t=this.pageAuth.get(i);if(e&&t){const s=t.get(e);if(s){const{render:o}=s;return o!=="localSelf"}}}return!0}isUsePageAuth(i){var s;if(!this.pageAuth.has(i))return!1;const t=this.control.viewContainerManager.getCurScenePath(i);return t&&((s=this.pageAuth.get(i))==null?void 0:s.has(t))||!1}publishRender(i){var n;const{viewId:e,option:t,isSync:s=!0}=i,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);s&&((n=this.control.collector)==null||n.dispatchRenderAuth({operation:et.setAuth,viewId:e,renderData:o},s)),this.renderEffect(e)}publishOneRender(i,e,t,s=!0){var a;const o=this.renderUids.get(i);let n;switch(t){case"show":o?(o.render||(o.render=new Set),O.isSet(o.render)&&o.render.add(e),O.isSet(o.hide)&&o.hide.delete(e)):this.renderUids.set(i,{render:new Set([e])}),n=et.setShow;break;case"hide":o?(o.hide||(o.hide=new Set),O.isSet(o.hide)&&o.hide.add(e),O.isSet(o.render)&&o.render.delete(e)):this.renderUids.set(i,{hide:new Set([e])}),n=et.setHide;break}o?this.renderUids.set(i,o):this.renderUids.delete(i),s&&n&&((a=this.control.collector)==null||a.dispatchRenderAuth({operation:n,viewId:i,uid:e},s)),this.renderEffect(i)}publishOneClear(i,e,t,s=!0){var n;const o=this.renderUids.get(i);t?o?(o.clear||(o.clear=new Set),O.isSet(o.clear)&&o.clear.add(e)):this.renderUids.set(i,{clear:new Set([e])}):o&&O.isSet(o.clear)&&o.clear.has(e)&&o.clear.delete(e),o?this.renderUids.set(i,o):this.renderUids.delete(i),s&&((n=this.control.collector)==null||n.dispatchRenderAuth({operation:et.setClear,viewId:i,uid:e,isClear:t},s)),this.renderEffect(i)}syncRenderUids(i,e,t,s){const o=e===!0?!0:e&&Object.keys(e)?new Set(Object.keys(e)):void 0,n=t===!0?!0:t&&Object.keys(t)?new Set(Object.keys(t)):void 0,a=s===!0?!0:s&&Object.keys(s)?new Set(Object.keys(s)):void 0;o||n||a?this.renderUids.set(i,{render:o,hide:n,clear:a}):this.renderUids.delete(i),this.renderEffect(i),this.publicMsgEmitter.emit("syncRenderUids",i,{render:o,hide:n,clear:a})}syncPageAuth(i,e,t=!1){let s=!1;if(!e)this.pageAuth.delete(i);else{const o=this.pageAuth.get(i)||new Map;for(const[n,a]of Object.entries(e)){const{render:c,pages:l}=a,u=o.get(n),h=this.isLocalRender?u==null?void 0:u.render:c;if(h){h!==(u==null?void 0:u.render)&&(s=!0);const d=new Map;for(const[p,f]of Object.entries(l))d.set(p,new Set(Object.keys(f)));const g={render:h,pages:d};d.size&&o.set(n,g)}}o.size&&(this.pageAuth.set(i,o),this.publicMsgEmitter.emit("syncPageAuth",i,o))}(t||s)&&this.pageAuthEffect(i)}destoryByViewId(i,e=!1){var t;this.renderUids.has(i)&&(this.renderUids.delete(i),e||(t=this.control.collector)==null||t.dispatchRenderAuth({operation:et.setAuth,viewId:i})),this.pageAuth.has(i)&&this.control.renderControl.delViewPage(i,!e)}renderEffect(i){var t;const e=(t=this.control.viewContainerManager.getView(i))==null?void 0:t.focusScenePath;e&&this.worker.clearViewScenePath(i,!0).then(()=>{var s;this.worker.pullServiceData(i,e,{isAsync:!0,useAnimation:!1}),this.worker.sendClearUids(i,(s=this.renderUids.get(i))==null?void 0:s.clear)})}pageAuthEffect(i){var t;const e=(t=this.control.viewContainerManager.getView(i))==null?void 0:t.focusScenePath;e&&this.worker.clearViewScenePath(i,!0).then(()=>{this.worker.pullServiceData(i,e,{isAsync:!0,useAnimation:!1}),this.worker.sendClearUids(i,!0)})}cloneElementIds(i,e,t,s){var a,c;const o=(a=this.control.collector)==null?void 0:a.getStorageData(i,e),n=new Set;if(o){for(const l of Object.keys(o))if(t.has(l)){const u=`${l}_${s}`;if(n.add(u),!Object.keys(o).includes(u)){const h=O.cloneDeep(o[l]);(c=this.control.collector)==null||c.updateValue(u,{type:D.FullWork,...h,workId:u},{isSync:!0,viewId:i,scenePath:e})}}}return n}delElementIds(i,e,t){var o,n;const s=(o=this.control.collector)==null?void 0:o.getStorageData(i,e);if(s)for(const a of Object.keys(s))t.has(a)&&Object.keys(s).includes(a)&&((n=this.control.collector)==null||n.updateValue(a,void 0,{isSync:!0,viewId:i,scenePath:e}))}}class Tm{constructor(i){M(this,"internalMsgEmitter");M(this,"control");M(this,"maps",new Map);M(this,"showId");M(this,"color");M(this,"timer");M(this,"updateMiniMapCamera",O.debounce(async i=>{const e=this.maps.get(i);if(e){const t=await this.getMiniMapCamera(i);if(t){const s=t.width/t.scale,o=t.height/t.scale,n=e.miniMapCamera.width/e.miniMapCamera.scale,a=e.miniMapCamera.height/e.miniMapCamera.scale;(s>=n||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(i);if(!(u!=null&&u.focusScenePath))return;const{miniMapCamera:h,contianer:d}=e,{width:g,height:p}=d.getBoundingClientRect(),f=Math.min(g/h.width,p/h.height);l.clearRect(0,0,c.width,c.height),c.width=h.width,c.height=h.height,c.style.width=`${h.width*f}px`,c.style.height=`${h.height*f}px`,await this.control.screenshotToCanvas(l,u.focusScenePath,h.width,h.height,h),this.listener.emitAsync([i,"viewCameraUpate"],1)}}}}},2e3,{maxWait:5e3}));var s;const{control:e,internalMsgEmitter:t}=i;this.control=e,this.internalMsgEmitter=t,this.color=((s=this.control.worker.currentToolsData)==null?void 0:s.toolsOpt.strokeColor)||"#000"}get listener(){return this.internalMsgEmitter}get activeViewId(){return this.showId}get highlightColor(){return this.color}setHighlightColor(i){this.color=i}async createMiniMap(i,e,t){const s=this.control.viewContainerManager.getView(i);if(!s)throw new Error("view not found");const o=s.cameraOpt;if(!o)throw new Error("view camera not found");const{width:n,height:a}=e.getBoundingClientRect();if(!n||!a)throw new Error("contianer width or height is 0");const c=y.createRef();this.maps.set(i,{contianer:e,miniMapCanvas:c,miniMapCamera:t,viewCamera:o}),this.showId=i,this.control.viewContainerManager.setActiveMiniMap(this.showId,!0);const l=Math.min(n/t.width,a/t.height),u=await new Promise(h=>{this.listener.once([i,"miniMapCreate"],()=>{const d=c.current;d&&(d.width=t.width,d.height=t.height,d.style.width=`${t.width*l}px`,d.style.height=`${t.height*l}px`),h(!0)}),this.timer=setTimeout(()=>{h(!1)},2e3)});return this.timer&&clearTimeout(this.timer),u}async getMiniMapCamera(i){const e=this.control.viewContainerManager.getView(i);if(!e)return;const{cameraOpt:t,focusScenePath:s}=e;if(!t||!s)return;const o={originX:t.centerX-t.width/t.scale/2,originY:t.centerY-t.height/t.scale/2,width:t.width/t.scale,height:t.height/t.scale};let n=await this.control.getBoundingRect(s)||o;n=ys(n,o)||o;let a=n.width,c=n.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:n.originX+n.width/2,centerY:n.originY+n.height/2,width:a,height:c}}getMiniMapCanvas(i){const e=this.maps.get(i);return(e==null?void 0:e.miniMapCanvas.current)||null}updateViewCamera(i,e){const t=this.maps.get(i);t&&(t.viewCamera=e,this.listener.emitAsync([i,"viewCameraUpate"],1))}destroyMiniMap(i){const e=i||this.showId;e&&(this.maps.delete(e),this.control.viewContainerManager.setActiveMiniMap(e,!1))}}class Nn{constructor(){M(this,"control");M(this,"_listeners",{})}_inject(i){this.control=i}_onEvent(i,e){this._listeners[i]&&this._listeners[i](...e)}callbacks(i,e){this._listeners[i]=e}removeCallback(i){delete this._listeners[i]}}class vm{constructor(i){M(this,"control");M(this,"worker");M(this,"publicMsgEmitter");M(this,"plugins",new Map);const{control:e,publicMsgEmitter:t}=i;this.control=e,this.publicMsgEmitter=t,this.worker=e.worker}use(i){this.plugins.set(i.kind,i),i._inject(this.control),i.onCreate()}destroy(){this.plugins.forEach(i=>{this.plugins.delete(i.kind),i.onDestroy()})}dispatchPluginEvent(i,...e){this.plugins.forEach(t=>{t._onEvent(i,e)})}}const Tt=class Tt{constructor(i){M(this,"version",qo);M(this,"plugin");M(this,"room");M(this,"play");M(this,"collector");M(this,"hasSwitchToSelectorEffect");M(this,"snapshootStateMap");M(this,"_disableDeviceInputs");M(this,"_disableEraseImage");M(this,"_disableEraseText");M(this,"_disableCameraTransform");M(this,"_disableUseWorker",!1);M(this,"priority","cpu");M(this,"effectResolve");M(this,"hotkeyManager");M(this,"pluginOptions");M(this,"roomMember");M(this,"cursor");M(this,"textEditorManager");M(this,"worker");M(this,"renderControl");M(this,"miniMapManager");M(this,"pluginManager");M(this,"onSceneChange",async(i,e)=>{var n;const t=this.viewContainerManager.getView(e);t!=null&&t.focusScenePath&&(n=this.collector)!=null&&n.hasSelector(e,t.focusScenePath)&&this.worker.blurSelector(e,t.focusScenePath),this.textEditorManager.checkEmptyTextBlur();const s=t==null?void 0:t.displayer;s&&(s.setActive(!1),await s.stopEventHandler());const o=i;o&&this.viewContainerManager.setViewScenePath(e,o),s==null||s.setActive(!0)});M(this,"onRoomMembersChange",i=>{this.roomMember.setRoomMembers($.toJS(i))});M(this,"onMemberChange",vn(i=>{var n;if(!this.room||!this.worker||!i||!this.room.isWritable)return;const e=this.getToolsKey(i),t=(n=this.worker.getCurrentToolsData())==null?void 0:n.toolsType,s=this.viewContainerManager.focuedViewId;s&&t===T.Selector&&e!==T.Selector&&this.worker.blurCursor(s);const o=this.getToolsOpt(e,i);this.worker.setCurrentToolsData(o),this.pluginManager.dispatchPluginEvent("setToolkey",e),this.effectViewContainer(e),this.effectResolve&&this.effectResolve(!0)},100,{leading:!1}));M(this,"internalSceneChange",(i,e)=>{var s;this.miniMapManager.activeViewId===i&&this.miniMapManager.destroyMiniMap(i),this.pluginManager.dispatchPluginEvent("sceneChange",i,e),(s=this.worker)==null||s.clearViewScenePath(i,!0).then(()=>{var o;(o=this.worker)==null||o.pullServiceData(i,e,{isAsync:!0,useAnimation:!1})})});M(this,"internalCameraChange",(i,e)=>{var t;(t=this.worker)==null||t.updateCamera(i,e),this.miniMapManager.updateViewCamera(i,e)});const{displayer:e,plugin:t,options:s}=i;this.plugin=t,this.room=$.isRoom(e)?e:void 0,this.play=$.isPlayer(e)?e:void 0,this.room&&(this._disableDeviceInputs=this.room.disableDeviceInputs,this._disableEraseImage=this.room.disableEraseImage,this._disableEraseText=!1),this.pluginOptions=s,s.cdn.useWorker==="mainThread"?this._disableUseWorker=!0:this._disableUseWorker=Js!=="worker",this.roomMember=new my;const o={control:this,internalMsgEmitter:Tt.InternalMsgEmitter,publicMsgEmitter:Tt.PublicMsgEmitter};this.cursor=new Iy(o),this.textEditorManager=new wy(o),this.worker=new Wy(o),this.hotkeyManager=new wm(o),this.renderControl=new Im(o),this.miniMapManager=new Tm(o),this.pluginManager=new vm(o)}get disableEraseText(){return this._disableEraseText||!1}set disableEraseText(i){this._disableEraseText=i}get disableEraseImage(){return this._disableEraseImage||!1}set disableEraseImage(i){this._disableEraseImage=i}get disableDeviceInputs(){return this._disableDeviceInputs||!1}set disableDeviceInputs(i){var t;this._disableDeviceInputs=i;const e=(t=this.worker.getCurrentToolsData())==null?void 0:t.toolsType;e&&this.effectViewContainer(e)}get disableCameraTransform(){return this._disableCameraTransform||!1}set disableCameraTransform(i){this._disableCameraTransform=i}get disableUseWorker(){return this._disableUseWorker||!1}set disableUseWorker(i){this._disableUseWorker=i}setPriority(i){var e;this.priority=i,this.hasOffscreenCanvas()&&((e=this.worker)==null||e.setPriority(i))}hasOffscreenCanvas(){return this._disableUseWorker?!1:Js==="worker"}bindPlugin(i){var e,t;this.plugin=i,this.collector&&(this.collector.removeStorageStateListener(),this.collector.removeAuthStateListener()),this.collector=new Xi(this,i,(t=(e=this.pluginOptions)==null?void 0:e.syncOpt)==null?void 0:t.interval),this.activePlugin()}destroy(){var i,e,t,s,o,n;this.roomMember.destroy(),(i=this.collector)==null||i.destroy(),(e=this.worker)==null||e.destroy(),(t=this.viewContainerManager)==null||t.destroy(),(s=this.cursor)==null||s.destroy(),(o=this.textEditorManager)==null||o.destory(),(n=this.pluginManager)==null||n.destroy()}cleanCurrentScene(){const i=Date.now(),e=this.worker.getLocalWorkViewId()||this.viewContainerManager.focuedViewId;e&&(Tt.InternalMsgEmitter.emit("addUndoTicker",i,e),this.worker.clearViewScenePath(e,!1,!0))}async setWritable(i){var e,t;if(!i){(e=this.cursor)==null||e.unabled(),this.textEditorManager.checkEmptyTextBlur();const s=this.viewContainerManager.getAllViews();for(const o of s){o!=null&&o.focusScenePath&&(t=this.collector)!=null&&t.hasSelector(o.id,o.focusScenePath)&&this.worker.blurSelector(o.id,o.focusScenePath);const n=o==null?void 0:o.displayer;n&&n.getActive()&&(n.setActive(!1),await n.stopEventHandler())}}await new Promise(s=>{setTimeout(()=>{s()},500)})}onWritableChange(i){var s;i?this.worker.abled():this.worker.unWritable(),((s=this.worker.getCurrentToolsData())==null?void 0:s.toolsType)===T.Text&&this.viewContainerManager.focuedViewId&&(i?this.viewContainerManager.activeTextEditor(this.viewContainerManager.focuedViewId):this.viewContainerManager.unActiveTextEditor(this.viewContainerManager.focuedViewId)),this.renderControl.onWritableChange(i),this.viewContainerManager.getAllViews().forEach(o=>{const n=o==null?void 0:o.displayer;n&&(n.bindToolsClass(),i?n.setActive(!0):n.setActive(!1))})}getToolsKey(i){var t;const e=i.currentApplianceName;switch(this.hasSwitchToSelectorEffect=!1,e){case re.text:return i.textCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),T.Text;case re.pencil:return i.useLaserPen?T.LaserPen:T.Pencil;case re.eraser:return T.Eraser;case re.pencilEraser:return((t=this.pluginOptions.pencilEraser)==null?void 0:t.useBitMap)===!1?T.PencilEraser:T.BitMapEraser;case re.selector:return T.Selector;case re.arrow:return i.arrowCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),T.Arrow;case re.straight:return i.straightCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),T.Straight;case re.ellipse:return i.ellipseCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),T.Ellipse;case re.rectangle:return i.rectangleCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),T.Rectangle;case re.shape:if(i.shapeCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),i.shapeType===Ke.Pentagram||i.shapeType===Ke.Star)return T.Star;if(i.shapeType===Ke.Polygon||i.shapeType===Ke.Triangle||i.shapeType===Ke.Rhombus)return T.Polygon;if(i.shapeType===Ke.SpeechBalloon)return T.SpeechBalloon;break}return T.Clicker}getToolsOpt(i,e){if(i===T.Clicker)return{toolsType:i,toolsOpt:{}};const t={strokeColor:gt(e.strokeColor[0],e.strokeColor[1],e.strokeColor[2],e.strokeOpacity||1),thickness:e.strokeWidth,isOpacity:(e==null?void 0:e.strokeOpacity)&&e.strokeOpacity<1||(e==null?void 0:e.fillOpacity)&&e.fillOpacity<1||(e==null?void 0:e.textOpacity)&&e.textOpacity<1||(e==null?void 0:e.textBgOpacity)&&e.textBgOpacity<1||!1};switch(i){case T.Text:t.fontFamily=window.getComputedStyle(document.documentElement).getPropertyValue("font-family"),t.fontSize=(e==null?void 0:e.textSizeOverride)||(e==null?void 0:e.textSize)||Number(window.getComputedStyle(document.body).fontSize),t.textAlign=(e==null?void 0:e.textAlign)||"left",t.verticalAlign=(e==null?void 0:e.verticalAlign)||"middle",t.fontColor=(e==null?void 0:e.textColor)&&gt(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)&&gt(e.textBgColor[0],e.textBgColor[1],e.textBgColor[2],e.textBgOpacity||1)||"transparent",t.bold=(e==null?void 0:e.bold)&&"bold"||void 0,t.italic=(e==null?void 0:e.italic)&&"italic"||void 0,t.underline=(e==null?void 0:e.underline)||void 0,t.lineThrough=(e==null?void 0:e.lineThrough)||void 0,t.text="",t.strokeColor=void 0;break;case T.Pencil:t.strokeType=(e==null?void 0:e.strokeType)||oe.Normal;break;case T.PencilEraser:case T.BitMapEraser:case T.Eraser:t.thickness=Math.min(4,Math.max(1,Math.floor(e.pencilEraserSize||1)))-1,(i===T.BitMapEraser||i===T.PencilEraser)&&(t.eraserColor=e.eraserColor&&gt(e.eraserColor[0],e.eraserColor[1],e.eraserColor[2],e.eraserOpacity||.3)||"rgba(136,136,136,0.3)");break;case T.LaserPen:t.duration=(e==null?void 0:e.duration)||1,e!=null&&e.strokeType&&(e==null?void 0:e.strokeType)===oe.Stroke?t.strokeType=oe.Normal:t.strokeType=(e==null?void 0:e.strokeType)||oe.Normal;break;case T.Arrow:case T.Straight:e!=null&&e.strokeType&&(e==null?void 0:e.strokeType)===oe.Stroke?t.strokeType=oe.Normal:t.strokeType=(e==null?void 0:e.strokeType)||oe.Normal;break;case T.Ellipse:case T.Rectangle:case T.Star:case T.Polygon:case T.SpeechBalloon:e!=null&&e.strokeType&&(e==null?void 0:e.strokeType)===oe.Stroke?t.strokeType=oe.Normal:t.strokeType=(e==null?void 0:e.strokeType)||oe.Normal,i===T.Star&&(e.shapeType===Ke.Pentagram?(t.vertices=10,t.innerVerticeStep=2,t.innerRatio=.4):e!=null&&e.vertices&&(e!=null&&e.innerVerticeStep)&&(e!=null&&e.innerRatio)&&(t.vertices=e.vertices,t.innerVerticeStep=e.innerVerticeStep,t.innerRatio=e.innerRatio)),i===T.Polygon&&(e.shapeType===Ke.Triangle?t.vertices=3:e.shapeType===Ke.Rhombus?t.vertices=4:e.vertices&&(t.vertices=e.vertices)),t.fillColor=(e==null?void 0:e.fillColor)&&gt(e.fillColor[0],e.fillColor[1],e.fillColor[2],e==null?void 0:e.fillOpacity)||"transparent",i===T.SpeechBalloon&&(t.placement=e.placement||"bottomLeft");break}return{toolsType:i,toolsOpt:t}}effectViewContainer(i){var e,t,s,o,n;if(this.disableDeviceInputs===!0)this.room.disableDeviceInputs=!0,(e=this.worker)==null||e.unWritable(),(t=this.cursor)==null||t.unabled();else switch(i!==T.Text&&this.viewContainerManager.focuedViewId&&this.viewContainerManager.unActiveTextEditor(this.viewContainerManager.focuedViewId),i){case T.Text:case T.Pencil:case T.LaserPen:case T.Arrow:case T.Straight:case T.Rectangle:case T.Ellipse:case T.Star:case T.Polygon:case T.SpeechBalloon:case T.Triangle:case T.Rhombus:case T.Eraser:case T.PencilEraser:case T.BitMapEraser:case T.Selector:this.room.disableDeviceInputs=!0,(s=this.worker)==null||s.abled(),i===T.Text&&this.viewContainerManager.focuedViewId&&this.viewContainerManager.activeTextEditor(this.viewContainerManager.focuedViewId);break;default:this.room.disableDeviceInputs=!1,(o=this.worker)==null||o.unWritable(),(n=this.cursor)==null||n.unabled();break}setTimeout(()=>{this.viewContainerManager.getAllViews().forEach(c=>{c!=null&&c.displayer&&c.displayer.bindToolsClass()})},0)}async getBoundingRect(i){var t,s,o,n,a;const e=await((t=this.worker)==null?void 0:t.getBoundingRect(i));if(e){const c=((o=(s=this.viewContainerManager.mainView)==null?void 0:s.viewData)==null?void 0:o.convertToPointInWorld({x:e.x,y:e.y}))||{x:e.x,y:e.y},l=((a=(n=this.viewContainerManager.mainView)==null?void 0:n.viewData)==null?void 0:a.camera.scale)||1;return{width:Math.floor(e.w/l)+1,height:Math.floor(e.h/l)+1,originX:c.x,originY:c.y}}}async screenshotToCanvas(i,e,t,s,o,n,a){const c=await this.worker.getSnapshot(e,t,s,o);c&&(i.drawImage(c,n||0,a||0),c.close())}async scenePreview(i,e){var n,a,c,l;const t=(n=this.collector)==null?void 0:n.getViewIdBySecenPath(i);if(!t)return;const s=this.viewContainerManager.getView(t);if(!s||!((a=s.cameraOpt)!=null&&a.width)||!((c=s.cameraOpt)!=null&&c.height))return;const o=await((l=this.worker)==null?void 0:l.getSnapshot(i));if(o&&this.worker){const u=document.createElement("canvas"),h=u.getContext("2d"),{width:d,height:g}=s.cameraOpt;u.width=d,u.height=g,h&&(h.drawImage(o,0,0),e.crossOrigin="anonymous",e.src=u.toDataURL(),e.onload=()=>{u.remove()},e.onerror=()=>{u.remove(),e.remove()}),o.close()}}switchToText(){var i;(i=this.room)==null||i.setMemberState({currentApplianceName:re.text})}switchToSelector(){var i;(i=this.room)==null||i.setMemberState({currentApplianceName:re.selector})}async runEffectWork(i){if(this.hasSwitchToSelectorEffect){const e=await new Promise(t=>{this.switchToSelector(),this.effectResolve=t});this.effectResolve=void 0,e&&i&&i()}}setSnapshootData(){var i;this.room&&(this.snapshootStateMap=new Map,this.snapshootStateMap.set("memberState",(i=this.room)==null?void 0:i.state.memberState))}getSnapshootData(i){var e;return(e=this.snapshootStateMap)==null?void 0:e.get(i)}clearSnapshootData(){var i;(i=this.snapshootStateMap)==null||i.clear(),this.snapshootStateMap=void 0}useBitMapEraser(i){var e;if(((e=this.pluginOptions.pencilEraser)==null?void 0:e.useBitMap)===void 0){this.pluginOptions.pencilEraser={useBitMap:i,maxImageWidth:Ie.pencilEraser.maxImageWidth,maxImageHeight:Ie.pencilEraser.maxImageHeight};return}this.pluginOptions.pencilEraser.useBitMap=i}consoleWorkerInfo(){var i;(i=this.worker)==null||i.consoleWorkerInfo()}filterRenderByUid(i,e,t=!0){var o;this.viewContainerManager.getView(i)&&((o=this.renderControl)==null||o.publishRender({viewId:i,option:e,isSync:t}))}cancelFilterRender(i,e=!0){var t;(t=this.renderControl)==null||t.publishRender({viewId:i,isSync:e})}async createMiniMap(i,e){const t=await this.miniMapManager.getMiniMapCamera(i);if(t&&await this.miniMapManager.createMiniMap(i,e,t)){const o=this.miniMapManager.getMiniMapCanvas(i);if(o){const n=o.getContext("2d");if(n){const a=this.viewContainerManager.getView(i);a!=null&&a.focusScenePath&&this.screenshotToCanvas(n,a.focusScenePath,t.width,t.height,t)}}}}async destroyMiniMap(i){this.miniMapManager.destroyMiniMap(i)}insertIconify(i,e){var s;if(this.viewContainerManager.getView(i)&&this.room){const o=this.room.state.memberState,n=gt(o.strokeColor[0],o.strokeColor[1],o.strokeColor[2],o.strokeOpacity||1);(s=this.worker)==null||s.insertIconify(i,{...e,strokeColor:n})}}usePlugin(i){return this.pluginManager.use(i)}};M(Tt,"InternalMsgEmitter",new Ui),M(Tt,"PublicMsgEmitter",new Ui);let be=Tt;const vt=class vt{constructor(i){M(this,"emitter",new Ui);M(this,"undoStack");M(this,"redoStack");M(this,"worker");M(this,"control");M(this,"room");M(this,"isTicking");M(this,"undoTickerId");M(this,"viewId");M(this,"scenePath");M(this,"tickStartStorerCache");M(this,"excludeIds",new Set);M(this,"onChangeScene",O.debounce(()=>{const i=this.control.viewContainerManager.getCurScenePath(this.viewId);if(i){let e=this.undoStack.filter(s=>s.scenePath===i).length;const t=this.redoStack.filter(s=>s.scenePath===i).length;e===0&&t===0&&this.tickStartStorerCache&&this.scenePath===i&&(e=1),this.emitter.emit("onCanUndoStepsUpdate",e),this.emitter.emit("onCanRedoStepsUpdate",t)}},vt.waitTime));const{control:e,internalMsgEmitter:t,viewId:s}=i;this.control=e,this.emitter=t,this.undoStack=[],this.redoStack=[],this.room=e.room,this.worker=e.worker,this.isTicking=!1,this.viewId=s}get collector(){return this.control.collector}addExcludeIds(i){if(this.isTicking)for(const e of i)this.excludeIds.add(e)}undoTickerStart(i,e){var t,s;if(this.collector&&(this.undoTickerId!==i||this.scenePath!==e)){!this.undoTickerId&&!this.tickStartStorerCache&&!this.scenePath&&this.emitter.emit("onCanUndoStepsUpdate",1),this.undoTickerId&&this.viewId&&this.scenePath&&this.undoTickerEndSync(this.undoTickerId,this.viewId,this.scenePath),this.isTicking=!0;const o=this.collector.transformKey(G);this.excludeIds.add(o),this.undoTickerId=i,this.scenePath=e;const n=((t=this.collector)==null?void 0:t.storage[this.viewId])&&((s=this.collector)==null?void 0:s.storage[this.viewId][this.scenePath])||{};this.tickStartStorerCache=new Map(Object.entries(O.cloneDeep(n)))}}undoTickerEndSync(i,e,t,s=!0){var o,n;if(i===this.undoTickerId&&t===this.scenePath&&e===this.viewId&&this.tickStartStorerCache){const a=((o=this.collector)==null?void 0:o.storage[e])&&((n=this.collector)==null?void 0:n.storage[e][t])||{},c=this.diffFun(this.tickStartStorerCache,new Map(Object.entries(a)));c.size&&(this.undoStack.push({id:i,type:2,data:O.cloneDeep(c),scenePath:t}),this.undoStack.length>vt.MaxStackLength&&this.undoStack.shift(),s&&this.emitter.emit("onCanUndoStepsUpdate",this.undoStack.length+1)),this.redoStack.length&&(this.redoStack.length=0,this.emitter.emit("onCanRedoStepsUpdate",this.redoStack.length)),this.isTicking=!1,this.scenePath=void 0,this.tickStartStorerCache=void 0,this.undoTickerId=void 0,this.excludeIds.clear()}}undo(i){this.undoTickerId&&this.tickStartStorerCache&&this.scenePath&&this.undoTickerEndSync(this.undoTickerId,this.viewId,this.scenePath,!1);let e=this.undoStack.length-1;for(;e>=0;){if(this.undoStack[e].scenePath===i){const n=this.undoStack[e];n&&(this.redoStack.push(n),n.type===2&&n.data&&this.refreshPlugin(n)),this.undoStack.splice(e,1);break}e--}const t=this.undoStack.filter(o=>o.scenePath===i).length,s=this.redoStack.filter(o=>o.scenePath===i).length;return this.emitter.emit("onCanUndoStepsUpdate",t),this.emitter.emit("onCanRedoStepsUpdate",s),t}redo(i){let e=this.redoStack.length-1;for(;e>=0;){if(this.redoStack[e].scenePath===i){const n=this.redoStack[e];n&&(!this.undoTickerId&&n.tickStartStorerCache?(this.undoTickerId=n.id,this.tickStartStorerCache=n.tickStartStorerCache,this.scenePath=n.scenePath):this.undoStack.push(n),n.type===2&&n.data&&this.refreshPlugin(n,!0)),this.redoStack.splice(e,1);break}e--}const t=this.undoStack.filter(o=>o.scenePath===i).length,s=this.redoStack.filter(o=>o.scenePath===i).length;return this.emitter.emit("onCanUndoStepsUpdate",t),this.emitter.emit("onCanRedoStepsUpdate",s),s}clear(){this.clearUndo(),this.clearRedo()}clearUndo(){this.undoStack.length=0,this.emitter.emit("onCanUndoStepsUpdate",this.undoStack.length)}clearRedo(){this.redoStack.length=0,this.emitter.emit("onCanRedoStepsUpdate",this.redoStack.length)}canUndo(){return!!this.undoStack.length}canRedo(){return!!this.redoStack.length}onFocusView(){const i=this.control.viewContainerManager.getCurScenePath(this.viewId);if(i){let e=this.undoStack.filter(s=>s.scenePath===i).length;const t=this.redoStack.filter(s=>s.scenePath===i).length;e===0&&t===0&&this.tickStartStorerCache&&this.scenePath===i&&(e=1),this.emitter.emit("onCanUndoStepsUpdate",e),this.emitter.emit("onCanRedoStepsUpdate",t)}}diffFun(i,e){const t=new Set,s=i.keys(),o=e.keys();for(const n of s){if(this.excludeIds.has(n))continue;const a=i.get(n),c=e.get(n);if(a&&c){if(O.isEqual(c,a))continue;t.add({dataType:3,key:n,data:[a,c]});continue}a&&t.add({dataType:2,key:n,data:a})}for(const n of o){if(this.excludeIds.has(n))continue;const a=e.get(n);a&&!i.has(n)&&t.add({dataType:1,key:n,data:a})}return t}isDrawEffectiveScene(i,e){const{key:t}=i;return!e.includes(t)}isDeleteEffectiveScene(i,e,t){var n;const{key:s}=i;if(!e.includes(s))return!1;const o=e.filter(a=>{var c,l;return((c=this.collector)==null?void 0:c.getLocalId(a))===G&&!((l=this.collector)!=null&&l.isOwn(a))}).map(a=>{var c;return(c=this.collector)==null?void 0:c.storage[this.viewId][t][a]});for(const a of o)if((n=a==null?void 0:a.selectIds)!=null&&n.includes(s))return!1;return!0}isOldEffectiveScene(i,e,t){var n;const{key:s}=i;if(!e.includes(s))return!1;const o=e.filter(a=>{var c,l;return((c=this.collector)==null?void 0:c.getLocalId(a))===G&&!((l=this.collector)!=null&&l.isOwn(a))}).map(a=>{var c;return(c=this.collector)==null?void 0:c.storage[this.viewId][t][a]});for(const a of o)if((n=a==null?void 0:a.selectIds)!=null&&n.includes(s))return!1;return!0}isNewEffectiveScene(i,e){const{key:t}=i;return!!e.includes(t)}refreshPlugin(i,e=!1){var a,c,l,u,h,d,g,p,f,m,w,I,N,C,S,v,x,L,b,P,A;let t;const{scenePath:s}=i,o=i.data;if(!o||!this.collector)return;const n=O.cloneDeep(this.collector.storage);for(const E of o.values()){const{dataType:R,data:z,key:Z}=E,ee=this.collector.getStorageData(this.viewId,s),F=ee&&Object.keys(ee)||[];switch(R){case 1:if(t=e?this.isDrawEffectiveScene(E,F):this.isDeleteEffectiveScene(E,F,s),t)if(e&&!Array.isArray(z)){if((a=z.updateNodeOpt)!=null&&a.useAnimation&&(z.updateNodeOpt.useAnimation=!1),((c=this.collector)==null?void 0:c.getLocalId(Z))===G&&((l=this.collector)!=null&&l.isOwn(E.key))){const X=z.selectIds;if(X){const te=F.filter(se=>{var _,J;return((_=this.collector)==null?void 0:_.getLocalId(se))===G&&!((J=this.collector)!=null&&J.isOwn(se))}).map(se=>{var _;return(_=this.collector)==null?void 0:_.storage[this.viewId][s][se]});let le=!1;for(const se of te)for(let _=0;_<X.length;_++)(u=se==null?void 0:se.selectIds)!=null&&u.includes(X[_])&&(delete X[_],le=!0);le&&(z.selectIds=X.filter(se=>!!se))}}(h=this.collector)==null||h.updateValue(E.key,z,{viewId:this.viewId,scenePath:s,isSync:!0,storage:n})}else!e&&!Array.isArray(E.data)&&((d=this.collector)==null||d.updateValue(E.key,void 0,{viewId:this.viewId,scenePath:s,isSync:!0,storage:n}));break;case 2:if(t=e?this.isDeleteEffectiveScene(E,F,s):this.isDrawEffectiveScene(E,F),t){if(e&&!Array.isArray(z))(g=this.collector)==null||g.updateValue(Z,void 0,{viewId:this.viewId,scenePath:s,isSync:!0,storage:n});else if(!e&&!Array.isArray(z)){if((p=z.updateNodeOpt)!=null&&p.useAnimation&&(z.updateNodeOpt.useAnimation=!1),((f=this.collector)==null?void 0:f.getLocalId(E.key))===G&&((m=this.collector)!=null&&m.isOwn(E.key))){const X=z.selectIds;if(X){const te=F.filter(se=>{var _,J;return((_=this.collector)==null?void 0:_.getLocalId(se))===G&&!((J=this.collector)!=null&&J.isOwn(se))}).map(se=>{var _;return(_=this.collector)==null?void 0:_.storage[this.viewId][s][se]});let le=!1;for(const se of te)for(let _=0;_<X.length;_++)(w=se==null?void 0:se.selectIds)!=null&&w.includes(X[_])&&(delete X[_],le=!0);le&&(z.selectIds=X.filter(se=>!!se))}}(I=this.collector)==null||I.updateValue(E.key,E.data,{viewId:this.viewId,scenePath:s,isSync:!0,storage:n})}}break;case 3:if(t=e?this.isNewEffectiveScene(E,F):this.isOldEffectiveScene(E,F,s),t){if(e&&Array.isArray(z)&&z.length===2){const X=z[1];if((N=X.updateNodeOpt)!=null&&N.useAnimation&&(X.updateNodeOpt.useAnimation=!1),((C=this.collector)==null?void 0:C.getLocalId(E.key))===G&&((S=this.collector)!=null&&S.isOwn(E.key))){const te=X.selectIds;if(te){const le=F.filter(_=>{var J,de;return((J=this.collector)==null?void 0:J.getLocalId(_))===G&&!((de=this.collector)!=null&&de.isOwn(_))}).map(_=>{var J;return(J=this.collector)==null?void 0:J.storage[this.viewId][s][_]});let se=!1;for(const _ of le)for(let J=0;J<te.length;J++)_!=null&&_.selectIds&&((v=_.selectIds)!=null&&v.includes(te[J]))&&(delete te[J],se=!0);se&&(X.selectIds=te.filter(_=>!!_))}}(x=this.collector)==null||x.updateValue(Z,X,{viewId:this.viewId,scenePath:s,isSync:!0,storage:n})}else if(!e&&Array.isArray(z)&&z.length===2){const X=z[0];if((L=X.updateNodeOpt)!=null&&L.useAnimation&&(X.updateNodeOpt.useAnimation=!1),((b=this.collector)==null?void 0:b.getLocalId(E.key))===G&&((P=this.collector)!=null&&P.isOwn(E.key))){const te=X.selectIds;if(te){const le=F.filter(_=>{var J,de;return((J=this.collector)==null?void 0:J.getLocalId(_))===G&&!((de=this.collector)!=null&&de.isOwn(_))}).map(_=>{var J;return(J=this.collector)==null?void 0:J.storage[this.viewId][s][_]});let se=!1;for(const _ of le)for(let J=0;J<te.length;J++)_!=null&&_.selectIds&&_.selectIds.includes(te[J])&&(delete te[J],se=!0);se&&(X.selectIds=te.filter(_=>!!_))}}(A=this.collector)==null||A.updateValue(E.key,X,{viewId:this.viewId,scenePath:s,isSync:!0,storage:n})}}break}}}};M(vt,"sdkCallBack"),M(vt,"MaxStackLength",20),M(vt,"waitTime",100);let wi=vt;function Nm(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 Ct(r){return Nm(r)&&(r.touches&&r.touches.length===1||r.changedTouches&&r.changedTouches.length===1)}function Ts(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 Wt{constructor(i){M(this,"internalMsgEmitter");M(this,"control");M(this,"mainView");M(this,"appViews",new Map);M(this,"undoTickerStart",(i,e)=>{const t=this.getView(e);t&&t.displayer&&t.focusScenePath&&t.displayer.commiter.undoTickerStart(i,t.focusScenePath)});M(this,"addExcludeIds",(i,e)=>{const t=this.getView(e);t&&t.displayer&&t.focusScenePath&&t.displayer.commiter.addExcludeIds(i)});const{control:e,internalMsgEmitter:t}=i;this.control=e,this.internalMsgEmitter=t,this.internalMsgEmitter.on("addUndoTicker",this.undoTickerStart),this.internalMsgEmitter.on("excludeIds",this.addExcludeIds)}get worker(){return this.control.worker}undo(){const i=this.focuedView;let e=0;if(i){const t=i.focusScenePath;e=i.displayer.commiter.undo(t)||0}return e}redo(){const i=this.focuedView;let e=0;if(i){const t=i.focusScenePath;e=i.displayer.commiter.redo(t)||0}return e}validator(i,e,t){var n;const s=O.clone(i[e]),o=O.clone(t);e==="focusScenePath"&&t&&!O.isEqual(s,o)&&(this.control.internalSceneChange(i.id,o),(n=this.focuedView)==null||n.displayer.commiter.onChangeScene()),e==="cameraOpt"&&!O.isEqual(s,o)&&this.control.internalCameraChange(i.id,o)}destroyAppView(i,e=!1){const t=this.appViews.get(i);t&&(this.control.textEditorManager.clear(i,e),t.displayer.destroy(),this.appViews.delete(i))}createMianView(i){this.mainView=new Proxy(i,{set:(e,t,s)=>(this.worker.isActive&&this.validator(e,t,s),e[t]=s,!0)})}createAppView(i){const e=i.id,t=new Proxy(i,{set:(s,o,n)=>(this.worker.isActive&&this.validator(s,o,n),s[o]=n,!0)});this.appViews.set(e,t)}isAppView(i){return i!==ge&&this.appViews.has(i)}getView(i){var e;return i===ge?this.mainView:(e=this.appViews)==null?void 0:e.get(i)}getCurScenePath(i){const e=this.getView(i);if(e)return e.focusScenePath}getAllViews(){return[this.mainView,...this.appViews.values()]}setViewScenePath(i,e){var t;if(i===ge&&this.mainView)this.mainView.focusScenePath=e;else{const s=i&&((t=this.appViews)==null?void 0:t.get(i))||void 0;s&&(s.focusScenePath=e)}}setViewData(i,e){var t;if(i===ge&&this.mainView)this.mainView.viewData=e;else{const s=i&&((t=this.appViews)==null?void 0:t.get(i))||void 0;s&&(s.viewData=e)}}setFocuedViewId(i){var e;this.focuedViewId=i,i===ge?this.focuedView=this.mainView:this.focuedView=i&&((e=this.appViews)==null?void 0:e.get(i))||void 0,this.worker.currentToolsData&&this.worker.currentToolsData.toolsType===T.Text&&this.activeTextEditor(i),this.control.cursor.onFocusViewChange(),this.focuedView&&this.focuedView.displayer.commiter.onFocusView()}setViewFocusScenePath(i,e){var s;let t;i===ge?t=this.mainView:t=(s=this.appViews)==null?void 0:s.get(i),t&&(t.focusScenePath=e)}destroy(){var i;this.internalMsgEmitter.off("addUndoTicker",this.undoTickerStart),this.internalMsgEmitter.off("excludeIds",this.addExcludeIds),(i=this.mainView)==null||i.displayer.destroy(),this.control.destroyMiniMap(ge),this.appViews.forEach(e=>{this.destroyAppView(e.id,!0),this.worker.destroyViewWorker(e.id),this.control.destroyMiniMap(e.id)})}setFocuedViewCameraOpt(i){if(this.focuedView){const e=this.focuedView.cameraOpt;O.isEqual(e,i)||(this.focuedView.cameraOpt=i)}}transformToOriginPoint(i,e){const t=this.getView(e);if(t!=null&&t.viewData){const s=t.viewData.convertToPointOnScreen(i[0],i[1]);return[s.x,s.y]}return i}transformToScenePoint(i,e){const t=this.getView(e);if(t!=null&&t.viewData){const s=t.viewData.convertToPointInWorld({x:i[0],y:i[1]});return[s.x,s.y]}return i}render(i){var e,t,s,o,n,a,c,l,u,h,d,g,p,f,m,w,I;for(const N of i){const{rect:C,imageBitmap:S,isClear:v,isUnClose:x,drawCanvas:L,clearCanvas:b,viewId:P}=N,A=(e=this.getView(P))==null?void 0:e.displayer;if(A&&C){const{dpr:E,canvasBgRef:R,canvasFloatRef:z,canvasServiceFloatRef:Z,canvasTopRef:ee}=A,F=Math.floor(C.w*E),X=Math.floor(C.h*E),te=C.x*E,le=C.y*E;if(v){switch(b){case me.TopFloat:(s=(t=ee.current)==null?void 0:t.getContext("2d"))==null||s.clearRect(te,le,F,X);break;case me.Float:(n=(o=z.current)==null?void 0:o.getContext("2d"))==null||n.clearRect(te,le,F,X);break;case me.ServiceFloat:(c=(a=Z.current)==null?void 0:a.getContext("2d"))==null||c.clearRect(te,le,F,X);break;case me.Bg:(u=(l=R.current)==null?void 0:l.getContext("2d"))==null||u.clearRect(te,le,F,X);break}continue}if(L&&S)switch(L){case me.TopFloat:(d=(h=ee.current)==null?void 0:h.getContext("2d"))==null||d.drawImage(S,0,0,F,X,te,le,F,X);break;case me.Float:{(p=(g=z.current)==null?void 0:g.getContext("2d"))==null||p.drawImage(S,0,0,F,X,te,le,F,X);break}case me.ServiceFloat:{(m=(f=Z.current)==null?void 0:f.getContext("2d"))==null||m.drawImage(S,0,0,F,X,te,le,F,X);break}case me.Bg:{(I=(w=R.current)==null?void 0:w.getContext("2d"))==null||I.drawImage(S,0,0,F,X,te,le,F,X);break}}if(x)continue;S==null||S.close()}}}showFloatBar(i,e,t){const s=this.getView(i),o=s==null?void 0:s.displayer.vDom;o&&o.showFloatBar(e,t)}activeTextEditor(i){const e=this.getView(i),t=e==null?void 0:e.displayer.vDom;t&&t.activeTextEditor()}unActiveTextEditor(i){const e=this.getView(i),t=e==null?void 0:e.displayer.vDom;t&&t.unActiveTextEditor()}showFloatBarBtn(i,e){const t=this.getView(i),s=t==null?void 0:t.displayer.vDom;s&&s.showFloatBarBtn(e)}updateTextEditorInfo(i,e){const t=this.getView(i),s=t==null?void 0:t.displayer.vDom;s&&s.updateTextEditorInfo(e)}setActiveMiniMap(i,e){const t=this.getView(i),s=t==null?void 0:t.displayer.vDom;s&&s.setActiveMiniMap(e&&i||void 0)}}M(Wt,"defaultCameraOpt",{centerX:0,centerY:0,scale:1}),M(Wt,"defaultScreenCanvasOpt",{autoRender:!1,contextType:"webgl2"}),M(Wt,"defaultLayerOpt",{offscreen:!0,handleEvent:!1,depth:!1});class Sm{constructor(i,e,t){M(this,"viewId");M(this,"control");M(this,"internalMsgEmitter");M(this,"commiter");M(this,"cachePoint");M(this,"cacheCursorPoint");M(this,"active",!0);M(this,"toolsKey");M(this,"mousedown",i=>{var e;if(this.active&&i.button===0&&this.viewId){this.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset(),this.toolsKey=(e=this.worker.getCurrentToolsData())==null?void 0:e.toolsType;const t=this.getPoint(i);this.cachePoint=t,t&&this.worker.originalEventLintener(j.Start,t,this.viewId),document.addEventListener("mousemove",this.mousemove,!1),document.addEventListener("mouseleave",this.mouseup,!1),document.addEventListener("mouseup",this.mouseup,!1)}});M(this,"mousemove",i=>{if(this.active&&this.viewId){const e=this.getPoint(i);if(this.cachePoint=e,this.checkConsumeCount())return;e&&this.worker.originalEventLintener(j.Doing,e,this.viewId)}});M(this,"mouseup",i=>{if(this.active&&i.button===0&&this.viewId){const e=this.getPoint(i)||this.cachePoint;e?(this.worker.originalEventLintener(j.Done,e,this.viewId).finally(()=>{document.removeEventListener("mouseleave",this.mouseup,!1),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1)}),this.cachePoint=void 0):(document.removeEventListener("mouseleave",this.mouseup,!1),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1))}});M(this,"touchstart",i=>{var e;if(this.active){if(!Ct(i)){this.worker.unWritable(),this.viewId&&this.worker.removeDrawingWork(this.viewId);return}if(this.viewId){this.toolsKey=(e=this.worker.getCurrentToolsData())==null?void 0:e.toolsType,!this.worker.isAbled()&&this.toolsKey&&this.control.effectViewContainer(this.toolsKey),this.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const t=this.getPoint(i);this.cachePoint=t,t&&(this.worker.originalEventLintener(j.Start,t,this.viewId),document.addEventListener("touchmove",this.touchmove,!1),document.addEventListener("touchend",this.touchend,!1))}}});M(this,"touchmove",i=>{if(this.active){if(!Ct(i)){this.worker.unWritable(),this.worker.removeDrawingWork(this.viewId);return}if(this.viewId){const e=this.getPoint(i);if(this.cachePoint=e,this.checkConsumeCount())return;e&&this.worker.originalEventLintener(j.Doing,e,this.viewId)}}});M(this,"touchend",i=>{if(this.active){if(!Ct(i)||!this.worker.isAbled()){this.worker.unWritable(),this.worker.removeDrawingWork(this.viewId);return}if(this.viewId){const e=this.getPoint(i)||this.cachePoint;e?(this.worker.originalEventLintener(j.Done,e,this.viewId).finally(()=>{document.removeEventListener("touchmove",this.touchmove,!1),document.removeEventListener("touchend",this.touchend,!1)}),this.cachePoint=void 0):(document.removeEventListener("touchmove",this.touchmove,!1),document.removeEventListener("touchend",this.touchend,!1))}}});M(this,"cursorMouseMove",O.throttle(i=>{const e=this.getPoint(i);this.cacheCursorPoint&&O.isEqual(e,this.cacheCursorPoint)||!this.viewId||(this.cacheCursorPoint=e,e&&this.worker.sendCursorEvent(e,this.viewId))},30,{leading:!1}));M(this,"cursorMouseLeave",O.throttle(()=>{this.viewId&&(this.cacheCursorPoint=[void 0,void 0],this.worker.sendCursorEvent(this.cacheCursorPoint,this.viewId))},30,{leading:!1}));M(this,"keydown",i=>{this.control.hotkeyManager.colloctHotkey(i)});this.viewId=i,this.control=e,this.internalMsgEmitter=t;const s={control:this.control,internalMsgEmitter:this.internalMsgEmitter,viewId:this.viewId};this.commiter=new wi(s)}get worker(){return this.control.worker}bindToolsClass(){var e,t;const i=(t=(e=this.worker)==null?void 0:e.currentToolsData)==null?void 0:t.toolsType;switch(i){case T.Text:case T.Pencil:case T.LaserPen:case T.Arrow:case T.Straight:case T.Rectangle:case T.Ellipse:case T.Star:case T.Polygon:case T.SpeechBalloon:case T.Eraser:case T.PencilEraser:case T.BitMapEraser:case T.Selector:this.eventTragetElement&&(this.eventTragetElement.className=`netless-whiteboard ${i===T.Selector?"cursor-selector":i===T.Text?"cursor-text":i===T.Eraser||i===T.PencilEraser||i===T.BitMapEraser?"cursor-eraser":i===T.Pencil||i===T.LaserPen?"cursor-pencil":"cursor-arrow"}`);break}}mountView(){this.setCanvassStyle(),this.control.viewContainerManager.mountView(this.viewId)}reflashContainerOffset(){this.eventTragetElement&&(this.containerOffset=this.getContainerOffset(this.eventTragetElement,{x:0,y:0}))}updateSize(){this.setCanvassStyle(),this.reflashContainerOffset()}setViewId(i){this.viewId=i}get parentElement(){var i;return(i=this.eventTragetElement)==null?void 0:i.parentElement}destroy(){this.eventTragetElement&&this.removeDisplayerEvent(this.eventTragetElement),this.vDom=void 0,this.control.cursor.clearViewCursor(this.viewId),this.internalMsgEmitter.removeAllListeners([ne.Cursor,this.viewId])}getPoint(i){const e=Ts(i);if(e&&O.isNumber(e.x)&&O.isNumber(e.y))return[e.x-this.containerOffset.x,e.y-this.containerOffset.y]}getActive(){this.active=!0}setActive(i){this.active=i}async stopEventHandler(){this.cachePoint&&(await this.worker.originalEventLintener(j.Done,this.cachePoint,this.viewId).finally(()=>{document.removeEventListener("mouseleave",this.mouseup,!1),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1)}),this.cachePoint=void 0)}getTranslate(i){const t=(i.style.WebkitTransform||getComputedStyle(i,"").getPropertyValue("-webkit-transform")||i.style.transform||getComputedStyle(i,"").getPropertyValue("transform")).match(/-?[0-9]+\.?[0-9]*/g),s=t&&parseInt(t[0])||0,o=t&&parseInt(t[1])||0;return[s,o]}getContainerOffset(i,e){var o;const t=this.getTranslate(i);let s={x:e.x+i.offsetLeft-i.scrollLeft+t[0],y:e.y+i.offsetTop-i.scrollTop+t[1]};return(o=i.offsetParent)!=null&&o.nodeName&&i.offsetParent.nodeName!=="BODY"&&(s=this.getContainerOffset(i.offsetParent,s)),s}checkConsumeCount(){return this.cachePoint&&this.control.pluginOptions.bezier&&this.worker.getConsumeCount()>this.control.pluginOptions.bezier.maxDrawCount?(this.stopEventHandler().finally(()=>{this.worker.publicMsgEmitter.emit("forceStop",vi.longPencil,this.viewId)}),!0):!1}bindDisplayerEvent(i){i.addEventListener("mousedown",this.mousedown,!1),i.addEventListener("touchstart",this.touchstart,!1),i.addEventListener("mousemove",this.cursorMouseMove,!1),i.addEventListener("mouseleave",this.cursorMouseLeave,!1),i.addEventListener("keydown",this.keydown,!0)}removeDisplayerEvent(i){i.removeEventListener("mousedown",this.mousedown,!1),i.removeEventListener("touchstart",this.touchstart,!1),document.removeEventListener("mouseleave",this.mouseup,!1),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1),document.removeEventListener("touchmove",this.touchmove,!1),document.removeEventListener("touchend",this.touchend,!1),i.removeEventListener("mousemove",this.cursorMouseMove,!1),i.removeEventListener("mouseleave",this.cursorMouseLeave,!1),i.removeEventListener("keydown",this.keydown,!0)}}class Sn{constructor(i,e){M(this,"viewId",ge);M(this,"control");M(this,"internalMsgEmitter");M(this,"commiter");M(this,"cachePoint");M(this,"cacheCursorPoint");M(this,"active",!0);M(this,"toolsKey");M(this,"mousedown",i=>{var e;if(this.active&&i.button===0){this.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const t=this.getPoint(i);this.cachePoint=t,this.toolsKey=(e=this.worker.getCurrentToolsData())==null?void 0:e.toolsType,t&&(this.worker.originalEventLintener(j.Start,t,this.viewId),document.addEventListener("mousemove",this.mousemove,!1),document.addEventListener("mouseleave",this.mouseup,!1),document.addEventListener("mouseup",this.mouseup,!1))}});M(this,"mousemove",i=>{if(!this.active)return;const e=this.getPoint(i);this.cachePoint=e,!this.checkConsumeCount()&&e&&this.worker.originalEventLintener(j.Doing,e,this.viewId)});M(this,"mouseup",i=>{if(this.active&&i.button===0){const e=this.getPoint(i)||this.cachePoint;e?(this.worker.originalEventLintener(j.Done,e,this.viewId).finally(()=>{document.removeEventListener("mouseleave",this.mouseup,!1),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1)}),this.cachePoint=void 0):(document.removeEventListener("mouseleave",this.mouseup,!1),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1))}});M(this,"touchstart",i=>{var t;if(!this.active)return;if(!Ct(i)){this.worker.unWritable(),this.viewId&&this.worker.removeDrawingWork(this.viewId);return}this.toolsKey=(t=this.worker.getCurrentToolsData())==null?void 0:t.toolsType,!this.worker.isAbled()&&this.toolsKey&&this.control.effectViewContainer(this.toolsKey),this.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const e=this.getPoint(i);this.cachePoint=e,e&&(this.worker.originalEventLintener(j.Start,e,this.viewId),document.addEventListener("touchmove",this.touchmove,!1),document.addEventListener("touchend",this.touchend,!1))});M(this,"touchmove",i=>{if(!this.active)return;if(!Ct(i)){this.worker.unWritable(),this.viewId&&this.worker.removeDrawingWork(this.viewId);return}const e=this.getPoint(i);this.cachePoint=e,!this.checkConsumeCount()&&e&&this.worker.originalEventLintener(j.Doing,e,this.viewId)});M(this,"touchend",i=>{if(!this.active)return;if(!Ct(i)||!this.worker.isAbled()){this.worker.unWritable(),this.worker.removeDrawingWork(this.viewId);return}const e=this.getPoint(i)||this.cachePoint;e?(this.worker.originalEventLintener(j.Done,e,this.viewId).finally(()=>{document.removeEventListener("touchmove",this.touchmove,!1),document.removeEventListener("touchend",this.touchend,!1)}),this.cachePoint=void 0):(document.removeEventListener("touchmove",this.touchmove,!1),document.removeEventListener("touchend",this.touchend,!1))});M(this,"cursorMouseMove",O.throttle(i=>{const e=this.getPoint(i);this.cacheCursorPoint&&O.isEqual(e,this.cacheCursorPoint)||(this.cacheCursorPoint=e,e&&this.worker.sendCursorEvent(e,this.viewId))},30,{leading:!1}));M(this,"cursorMouseLeave",O.throttle(()=>{this.cacheCursorPoint=[void 0,void 0],this.worker.sendCursorEvent(this.cacheCursorPoint,this.viewId)},30,{leading:!1}));M(this,"keydown",i=>{this.control.hotkeyManager.colloctHotkey(i)});this.control=i,this.internalMsgEmitter=e;const t={control:this.control,internalMsgEmitter:this.internalMsgEmitter,viewId:this.viewId};this.commiter=new wi(t)}get worker(){return this.control.worker}bindToolsClass(){var s,o;const i=(o=(s=this.worker)==null?void 0:s.currentToolsData)==null?void 0:o.toolsType,e=this.control.renderControl.isWritable,t=this.worker.isAbled();switch(i){case T.Text:case T.Pencil:case T.LaserPen:case T.Arrow:case T.Straight:case T.Rectangle:case T.Ellipse:case T.Star:case T.Polygon:case T.SpeechBalloon:case T.Eraser:case T.PencilEraser:case T.BitMapEraser:case T.Selector:this.eventTragetElement&&(this.eventTragetElement.className=e&&t?`netless-whiteboard ${i===T.Selector?"cursor-selector":i===T.Text?"cursor-text":i===T.Eraser||i===T.PencilEraser||i===T.BitMapEraser?"cursor-eraser":i===T.Pencil||i===T.LaserPen?"cursor-pencil":"cursor-arrow"}`:"netless-whiteboard");break}}mountView(){this.setCanvassStyle(),this.control.viewContainerManager.mountView(this.viewId)}updateSize(){this.setCanvassStyle()}reflashContainerOffset(){this.eventTragetElement&&(this.containerOffset=this.getContainerOffset(this.eventTragetElement,{x:0,y:0}))}get parentElement(){var i;return(i=this.eventTragetElement)==null?void 0:i.parentElement}destroy(){this.eventTragetElement&&this.removeDisplayerEvent(this.eventTragetElement),this.vDom=void 0,this.control.cursor.destroy(),this.internalMsgEmitter.removeAllListeners([ne.Cursor,this.viewId])}getPoint(i){const e=Ts(i);if(e&&O.isNumber(e.x)&&O.isNumber(e.y))return[e.x-this.containerOffset.x,e.y-this.containerOffset.y]}getActive(){return this.active}setActive(i){this.active=i}async stopEventHandler(){this.cachePoint&&(await this.worker.originalEventLintener(j.Done,this.cachePoint,this.viewId).finally(()=>{document.removeEventListener("mouseleave",this.mouseup,!1),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1)}),this.cachePoint=void 0)}getTranslate(i){const t=(i.style.WebkitTransform||getComputedStyle(i,"").getPropertyValue("-webkit-transform")||i.style.transform||getComputedStyle(i,"").getPropertyValue("transform")).match(/-?[0-9]+\.?[0-9]*/g),s=t&&parseInt(t[0])||0,o=t&&parseInt(t[1])||0;return[s,o]}getContainerOffset(i,e){var o;const t=this.getTranslate(i);let s={x:e.x+i.offsetLeft-i.scrollLeft+t[0],y:e.y+i.offsetTop-i.scrollTop+t[1]};return(o=i.offsetParent)!=null&&o.nodeName&&i.offsetParent.nodeName!=="BODY"&&(s=this.getContainerOffset(i.offsetParent,s)),s}checkConsumeCount(){const i=this.worker.getConsumeCount();return this.cachePoint&&this.toolsKey&&this.toolsKey===T.Pencil&&this.control.pluginOptions.bezier&&i>this.control.pluginOptions.bezier.maxDrawCount?(this.stopEventHandler().finally(()=>{this.worker.publicMsgEmitter.emit("forceStop",vi.longPencil,this.viewId)}),!0):!1}bindDisplayerEvent(i){i.addEventListener("mousedown",this.mousedown,!1),i.addEventListener("touchstart",this.touchstart,!1),i.addEventListener("mousemove",this.cursorMouseMove,!1),i.addEventListener("mouseleave",this.cursorMouseLeave,!1),i.addEventListener("keydown",this.keydown,!0)}removeDisplayerEvent(i){i.removeEventListener("mousedown",this.mousedown,!1),document.removeEventListener("mouseleave",this.mouseup,!1),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1),i.removeEventListener("touchstart",this.touchstart,!1),document.removeEventListener("touchmove",this.touchmove,!1),document.removeEventListener("touchend",this.touchend,!1),i.removeEventListener("mousemove",this.cursorMouseMove,!1),i.removeEventListener("mouseleave",this.cursorMouseLeave,!1),i.removeEventListener("keydown",this.keydown,!0)}}const Cm="index-module__Container__nLsM3",km="index-module__CanvasBox__j2Xe-",xm="index-module__FloatCanvas__d1YR7",Dm="index-module__TopFloatCanvas__7IaCw",Lm="index-module__CanvasBoxSub__hcMeK",bm="index-module__SnapshotBox__--eeE",jm="index-module__FloatBar__cm-EL",Am="index-module__RotateBtn__HSSkf",Pm="index-module__ResizeBtn__yjvda",zm="index-module__CursorBox__2UHvI",Em="index-module__TextEditorContainer__Qm8KC",Om="index-module__ResizeTowBox__HOllX",Rm="index-module__FloatBarBtn__FJrOG",We={Container:Cm,CanvasBox:km,FloatCanvas:xm,TopFloatCanvas:Dm,CanvasBoxSub:Lm,SnapshotBox:bm,FloatBar:jm,RotateBtn:Am,ResizeBtn:Pm,CursorBox:zm,TextEditorContainer:Em,ResizeTowBox:Om,FloatBarBtn:Rm},Wm={delete:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDZ2NmEyIDIgMCAwIDEtMiAySDZhMiAyIDAgMCAxLTItMlY2aDBtM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OC44NDYgMCAwIDEgMy4xMjUgMTJjMC0yLjI3MS44NjYtNC41NDMgMi42LTYuMjc2eiIgc3Ryb2tlPSIjRkZGIiBzdHJva2Utd2lkdGg9Ii41IiBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9Im5vbnplcm8iLz48L2c+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+PHBhdGggZD0iTTEyIDJ2NWE0IDQgMCAxIDEtOCAwVjJoME0zIDE0aDEwIiBzdHJva2U9IiMzMzgxRkYiIGZpbGw9Im5vbmUiIHN0cm9rZS1sa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Zz4="};function Ee(r){return Wm[r]}const Ym=r=>{const{workIds:i,mananger:e}=r;return y.createElement("div",{className:"button normal-button",style:{touchAction:"none"},onPointerUp:t=>{t.cancelable&&t.preventDefault(),t.stopPropagation(),t.nativeEvent.stopImmediatePropagation(),ae.emitMethod(ne.MainEngine,V.DeleteNode,{workIds:i||[G],viewId:e.viewId})}},y.createElement("img",{alt:"icon",src:Ee("delete")}))},Um=r=>{const{workIds:i,viewId:e}=r;return y.createElement("div",{className:"button normal-button",onPointerUp:t=>{t.stopPropagation(),ae.emitMethod(ne.MainEngine,V.CopyNode,{workIds:i||[G],viewId:e})}},y.createElement("img",{alt:"icon",src:Ee("duplicate")}))},mo=r=>{const{icon:i,onPointerUpHandler:e}=r;return y.createElement("div",{className:"button normal-button",onPointerUp:e},y.createElement("img",{src:Ee(i)}))},Bm=r=>{const{open:i,setOpen:e,floatBarRef:t}=r,{floatBarData:s,mananger:o}=y.useContext(Se),[n,a]=y.useState([]),c=y.useMemo(()=>{if(t!=null&&t.current&&O.isNumber(s==null?void 0:s.y)&&(o!=null&&o.height)){if(t.current.offsetTop&&t.current.offsetTop+s.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-s.y<120){const h={};return h.top="inherit",h.bottom=50,h}}},[t==null?void 0:t.current,s,o]),l=y.useMemo(()=>i?y.createElement("div",{className:"image-layer-menu",style:c},y.createElement(mo,{icon:"to-top",onPointerUpHandler:h=>{h.stopPropagation(),ae.emitMethod(ne.MainEngine,V.ZIndexNode,{workIds:[G],layer:qt.Top,viewId:o==null?void 0:o.viewId})}}),y.createElement(mo,{icon:"to-bottom",onPointerUpHandler:h=>{h.stopPropagation(),ae.emitMethod(ne.MainEngine,V.ZIndexNode,{workIds:[G],layer:qt.Bottom,viewId:o==null?void 0:o.viewId})}})):null,[i,c]),u=h=>{h.stopPropagation(),h.nativeEvent.stopImmediatePropagation(),e(!i)};return y.useEffect(()=>{O.isEqual(s==null?void 0:s.selectIds,n)||s!=null&&s.selectIds&&!O.isEqual(s==null?void 0:s.selectIds,n)&&(a(s==null?void 0:s.selectIds),e(!1))},[i,s,n,e]),y.createElement("div",{className:`button normal-button ${i&&"active"}`,onPointerUp:u},l,y.createElement("img",{alt:"icon",src:Ee(i?"layer-pressed":"layer")}))},si=r=>{r.stopPropagation(),r.nativeEvent.stopImmediatePropagation()},Fm=()=>y.createElement("svg",{style:{marginLeft:"2px"},viewBox:"0 0 1025 1024",width:"14",height:"14"},y.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"})),Cn=r=>{const{activeColor:i,onPointerUpHandler:e}=r;return y.createElement("div",{className:`font-color-button ${i==="transparent"?"active":""}`,onPointerUp:e},y.createElement("div",{className:"circle none"}))},Ai=r=>{const{color:i,activeColor:e,onPointerUpHandler:t}=r;return y.createElement("div",{className:`font-color-button ${i===e?"active":""}`,onPointerUp:t},y.createElement("div",{className:"circle",style:{backgroundColor:je(i,1)}}))},Pi=r=>{const{opacity:i,activeColor:e,setCurOpacity:t}=r,[s,o]=y.useState({x:108,y:0}),n=y.useRef(0);if(y.useEffect(()=>{o({x:i*100+8,y:0})},[]),!e)return null;const a=(h,d)=>{const g=Math.min(Math.max(h-8,0),100)/100;(i!==g||d===j.Done)&&t(g,e,d)},c=(h,d)=>{d.x!==(s==null?void 0:s.x)&&o({x:d.x,y:0}),!n.current&&(n.current=setTimeout(()=>{n.current=0,a(d.x,j.Doing)},100))},l=()=>{t(i,e,j.Start)},u=(h,d)=>{d.x!==(s==null?void 0:s.x)&&o({x:d.x,y:0}),n.current&&(clearTimeout(n.current),n.current=0),a(d.x,j.Done)};return y.createElement("div",{className:"font-color-opacity",style:{marginLeft:"10px"},onPointerUp:h=>{n.current&&(clearTimeout(n.current),n.current=0);const d=h.nativeEvent.offsetX,g=Math.min(Math.max(d-12,0),100)/100;o({x:g*100+8,y:0}),t(g,e,j.Done)}},y.createElement("div",{className:"range-color",style:{background:`linear-gradient(to right, ${je(e,0)}, ${je(e,1)})`}}),y.createElement("div",{className:"range-opacity"},y.createElement(Yt,{bounds:"parent",axis:"x",position:s,onDrag:c,onStart:l,onStop:u},y.createElement("div",{className:"circle",style:{backgroundColor:je(e,i)},onPointerUp:si}))))},Vm=r=>{const{min:i,max:e,activeNumber:t,setActiveNumber:s,color:o}=r,[n,a]=y.useState({x:108,y:0}),c=y.useRef(0);if(y.useEffect(()=>{const g=Math.ceil((t-i)/(e-i)*100)+8;a({x:g,y:0})},[]),!t)return null;const l=(g,p)=>{const f=Math.ceil(Math.max(g-8,0)/100*(e-i)+i);(t!==f||p===j.Done)&&s(f,p)},u=(g,p)=>{p.x!==(n==null?void 0:n.x)&&a({x:p.x,y:0}),!c.current&&(c.current=setTimeout(()=>{c.current=0,l(p.x,j.Doing)},100))},h=()=>{s(t,j.Start)},d=(g,p)=>{p.x!==(n==null?void 0:n.x)&&a({x:p.x,y:0}),c.current&&(clearTimeout(c.current),c.current=0),l(p.x,j.Done)};return y.createElement("div",{className:"font-color-opacity",style:{marginLeft:"10px"},onPointerUp:g=>{c.current&&(clearTimeout(c.current),c.current=0);const p=g.nativeEvent.offsetX,f=Math.ceil(Math.max(p-12,0)/100*(e-i)+i),m=Math.ceil((f-i)/(e-i)*100)+8;a({x:m,y:0}),s(f,j.Done)}},y.createElement("div",{className:"range-color",style:{backgroundColor:o}}),y.createElement("div",{className:"range-opacity"},y.createElement(Yt,{bounds:"parent",axis:"x",position:n,onDrag:u,onStart:h,onStop:d},y.createElement("div",{className:"circle",style:{backgroundColor:o},onPointerUp:si},y.createElement("div",{className:"range-opacity-data-icon"},t)))))},Qm=r=>{const{useStroke:i,color:e,activeStrokeType:t,setStrokeType:s}=r;return y.createElement("div",{className:"stroke-type-box"},!!i&&y.createElement("div",{className:`stroke-type-box-item Stroke ${t===oe.Stroke&&"active"}`,style:{backgroundColor:e},onPointerUp:()=>{s(oe.Stroke)}}),y.createElement("div",{className:`stroke-type-box-item Normal ${t===oe.Normal&&"active"}`,style:{borderColor:e},onPointerUp:()=>{s(oe.Normal)}}),y.createElement("div",{className:`stroke-type-box-item Dotted ${t===oe.Dotted&&"active"}`,style:{borderColor:e},onPointerUp:()=>{s(oe.Dotted)}}),y.createElement("div",{className:`stroke-type-box-item LongDotted ${t===oe.LongDotted&&"active"}`,style:{borderColor:e},onPointerUp:()=>{s(oe.LongDotted)}}))},Zm=r=>{var I,N;const{open:i,setOpen:e,floatBarRef:t}=r,{floatBarData:s,floatBarColors:o,mananger:n,setFloatBarData:a}=y.useContext(Se),[c,l]=y.useState(),[u,h]=y.useState(1);y.useEffect(()=>{if(s!=null&&s.strokeColor){const[C,S]=bi(s.strokeColor);l(C),h(S)}},[s]);const d=y.useMemo(()=>{if(t!=null&&t.current&&s&&O.isNumber(s==null?void 0:s.y)&&(n!=null&&n.height)){if(t.current.offsetTop&&t.current.offsetTop+s.y>180){const C={};return C.top="inherit",C.bottom=50,C}else if(!t.current.offsetTop&&(n==null?void 0:n.height)-t.current.offsetTop-s.y<120){const C={};return C.top="inherit",C.bottom=50,C}}},[s,t,n==null?void 0:n.height]),g=y.useMemo(()=>y.createElement(Pi,{key:"strokeColors",opacity:u,activeColor:c,setCurOpacity:(C,S,v)=>{h(C);const x=je(S,C);s!=null&&s.strokeColor&&a({strokeColor:x}),ae.emitMethod(ne.MainEngine,V.SetColorNode,{workIds:[G],strokeColor:x,workState:v,viewId:n==null?void 0:n.viewId})}}),[u,c,s==null?void 0:s.strokeColor,n==null?void 0:n.viewId,a]),p=y.useMemo(()=>{var C,S;return c&&s&&s.thickness?y.createElement(Vm,{key:"strokeThickness",min:Math.min(s.thickness,((C=n==null?void 0:n.control.pluginOptions.strokeWidth)==null?void 0:C.min)||1),max:Math.max(s.thickness,((S=n==null?void 0:n.control.pluginOptions.strokeWidth)==null?void 0:S.max)||10),activeNumber:s.thickness,setActiveNumber:(v,x)=>{s!=null&&s.thickness&&a({thickness:v}),ae.emitMethod(ne.MainEngine,V.SetColorNode,{workIds:[G],thickness:v,workState:x,viewId:n==null?void 0:n.viewId})},color:c}):null},[c,s,(I=n==null?void 0:n.control.pluginOptions.strokeWidth)==null?void 0:I.max,(N=n==null?void 0:n.control.pluginOptions.strokeWidth)==null?void 0:N.min,n==null?void 0:n.viewId,a]),f=y.useMemo(()=>c&&s&&(s!=null&&s.strokeType)?y.createElement(Qm,{key:"strokeType",useStroke:s==null?void 0:s.useStroke,activeStrokeType:s.strokeType,setStrokeType:C=>{s.strokeType&&a({strokeType:C}),ae.emitMethod(ne.MainEngine,V.SetColorNode,{workIds:[G],strokeType:C,workState:j.Done,viewId:n==null?void 0:n.viewId})},color:c}):null,[c,s,n==null?void 0:n.viewId,a]),m=y.useMemo(()=>i?y.createElement("div",{className:"font-colors-menu",style:d,onPointerUp:C=>{C.stopPropagation(),C.nativeEvent.stopImmediatePropagation()}},f,p,y.createElement("div",{className:"font-colors-line"}),o.concat().map((C,S)=>{const v=ii(...C);return y.createElement(Ai,{key:S,color:v,activeColor:c,onPointerUpHandler:x=>{x.stopPropagation(),l(v);const L=je(v,u);s!=null&&s.strokeColor&&(s.strokeColor=L,a({strokeColor:L})),ae.emitMethod(ne.MainEngine,V.SetColorNode,{workIds:[G],workState:j.Done,strokeColor:L,viewId:n==null?void 0:n.viewId})}})}),g):null,[i,d,f,p,o,g,c,u,s,n==null?void 0:n.viewId,a]),w=y.useMemo(()=>c?y.createElement("div",{className:"color-bar-ring",style:{backgroundColor:je(c,u)}},y.createElement("div",{className:"circle"})):null,[c,u]);return y.createElement("div",{className:`button normal-button font-colors-icon ${i&&"active"}`,onPointerUp:C=>{C.stopPropagation(),C.nativeEvent.stopImmediatePropagation(),e(!i)}},w,m)},Hm=r=>{const{open:i,setOpen:e,floatBarRef:t}=r,{floatBarData:s,floatBarColors:o,mananger:n,setFloatBarData:a}=y.useContext(Se),[c,l]=y.useState(),[u,h]=y.useState(1);y.useEffect(()=>{if(s!=null&&s.fillColor){const[m,w]=(s==null?void 0:s.fillColor)==="transparent"&&["transparent",1]||bi(s.fillColor);l(m),h(w)}},[s]);const d=y.useMemo(()=>{if(t!=null&&t.current&&O.isNumber(s==null?void 0:s.y)&&(n!=null&&n.height)){if(t.current.offsetTop&&t.current.offsetTop+s.y>200){const m={};return m.top="inherit",m.bottom=50,m}else if(!t.current.offsetTop&&(n==null?void 0:n.height)-t.current.offsetTop-s.y<140){const m={};return m.top="inherit",m.bottom=50,m}}},[t,s,n==null?void 0:n.height]),g=y.useMemo(()=>c&&c!=="transparent"?y.createElement(Pi,{key:"fillColors",opacity:u||0,activeColor:c,setCurOpacity:(m,w,I)=>{h(m);const N=je(w,m);s!=null&&s.fillColor&&(s.fillColor=N,a({fillColor:N})),ae.emitMethod(ne.MainEngine,V.SetColorNode,{workIds:[G],fillColor:c&&je(w,m),workState:I,viewId:n==null?void 0:n.viewId})}}):null,[c,u,s,n==null?void 0:n.viewId,a]),p=y.useMemo(()=>i?y.createElement("div",{className:"font-colors-menu",style:d,onPointerUp:m=>{m.stopPropagation(),m.nativeEvent.stopImmediatePropagation()}},y.createElement(Cn,{activeColor:c,onPointerUpHandler:m=>{m.stopPropagation(),l("transparent");const w="transparent";s!=null&&s.fillColor&&(s.fillColor=w,a({fillColor:w})),ae.emitMethod(ne.MainEngine,V.SetColorNode,{workIds:[G],workState:j.Done,fillColor:w,viewId:n==null?void 0:n.viewId})}}),o.map((m,w)=>{const I=ii(...m);return y.createElement(Ai,{key:w,color:I,activeColor:c,onPointerUpHandler:N=>{N.cancelable&&N.preventDefault(),N.stopPropagation(),l(I);const C=je(I,u);s!=null&&s.fillColor&&(s.fillColor=C,a({fillColor:C})),ae.emitMethod(ne.MainEngine,V.SetColorNode,{workIds:[G],workState:j.Done,fillColor:C,viewId:n==null?void 0:n.viewId})}})}),g):null,[i,d,c,o,g,s,n==null?void 0:n.viewId,a,u]),f=y.useMemo(()=>{const m=c&&c!=="transparent"&&je(c,u)||"transparent";return y.createElement("div",{className:"color-bar-fill"},y.createElement("div",{className:"circle",style:{backgroundColor:m}}))},[c,u]);return y.createElement("div",{className:`button normal-button font-colors-icon ${i&&"active"}`,onPointerUp:m=>{m.stopPropagation(),m.nativeEvent.stopImmediatePropagation(),e(!i)}},f,p)},Gm=r=>{const{open:i,setOpen:e,textOpt:t,workIds:s,floatBarRef:o}=r,{floatBarColors:n,mananger:a,setFloatBarData:c,floatBarData:l}=y.useContext(Se),[u,h]=y.useState(),[d,g]=y.useState(1);y.useEffect(()=>{if(t!=null&&t.fontColor){const[I,N]=(t==null?void 0:t.fontColor)==="transparent"&&["transparent",0]||bi(t.fontColor);h(I),g(N)}},[t==null?void 0:t.fontColor]);const p=y.useMemo(()=>{if(o!=null&&o.current&&l&&O.isNumber(l==null?void 0:l.y)&&(a!=null&&a.height)){if(o.current.offsetTop&&o.current.offsetTop+l.y>180){const I={};return I.top="inherit",I.bottom=50,I}else if(!o.current.offsetTop&&(a==null?void 0:a.height)-o.current.offsetTop-l.y<120){const I={};return I.top="inherit",I.bottom=50,I}}},[o,l,a==null?void 0:a.height]),f=y.useMemo(()=>u&&u!=="transparent"?y.createElement(Pi,{key:"fontColors",opacity:d,activeColor:u,setCurOpacity:(I,N,C)=>{g(I);const S=je(N,I);l!=null&&l.textOpt&&(l.textOpt.fontColor=S,c({textOpt:l.textOpt})),ae.emitMethod(ne.MainEngine,V.SetColorNode,{workIds:s||[G],fontColor:u&&S,workState:C,viewId:a==null?void 0:a.viewId})}}):null,[u,d,a==null?void 0:a.control.room,a==null?void 0:a.viewId,l==null?void 0:l.textOpt,s]),m=y.useMemo(()=>i?y.createElement("div",{className:"font-colors-menu",style:p,onPointerUp:I=>{I.stopPropagation(),I.nativeEvent.stopImmediatePropagation()}},n.map((I,N)=>{const C=ii(...I);return y.createElement(Ai,{key:N,color:C,activeColor:u,onPointerUpHandler:S=>{S.stopPropagation(),h(C);const v=je(C,d);l!=null&&l.textOpt&&(l.textOpt.fontColor=v,c({textOpt:l.textOpt})),ae.emitMethod(ne.MainEngine,V.SetColorNode,{workIds:s||[G],workState:j.Done,fontColor:v,viewId:a==null?void 0:a.viewId})}})}),f):null,[i,n,f,u,d,l==null?void 0:l.textOpt,s,a==null?void 0:a.viewId,p]),w=y.useMemo(()=>{const I=u&&u!=="transparent"&&je(u,d)||"transparent";return y.createElement("div",{className:"color-bar"},y.createElement("div",{className:"color-bar-color",style:{backgroundColor:I}}))},[u,d]);return y.createElement("div",{className:`button normal-button font-colors-icon ${i&&"active"}`,onPointerUp:I=>{I.stopPropagation(),I.nativeEvent.stopImmediatePropagation(),e(!i)}},y.createElement("img",{alt:"icon",src:Ee("font-colors")}),w,m)},$m=r=>{const{open:i,setOpen:e,textOpt:t,workIds:s,floatBarRef:o}=r,{floatBarColors:n,mananger:a,setFloatBarData:c,floatBarData:l}=y.useContext(Se),[u,h]=y.useState(),[d,g]=y.useState(1);y.useEffect(()=>{if(t!=null&&t.fontBgColor){const[I,N]=(t==null?void 0:t.fontBgColor)==="transparent"&&["transparent",1]||bi(t.fontBgColor);h(I),g(N)}},[t==null?void 0:t.fontBgColor]);const p=y.useMemo(()=>{if(o!=null&&o.current&&l&&O.isNumber(l==null?void 0:l.y)&&(a!=null&&a.height)){if(o.current.offsetTop&&o.current.offsetTop+l.y>180){const I={};return I.top="inherit",I.bottom=50,I}else if(!o.current.offsetTop&&(a==null?void 0:a.height)-o.current.offsetTop-l.y<120){const I={};return I.top="inherit",I.bottom=50,I}}},[o,l,a==null?void 0:a.height]),f=y.useMemo(()=>u&&u!=="transparent"?y.createElement(Pi,{key:"fontBgColor",opacity:d||0,activeColor:u,setCurOpacity:(I,N,C)=>{g(I);const S=je(N,I);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=S,c({textOpt:l.textOpt})),ae.emitMethod(ne.MainEngine,V.SetColorNode,{workIds:s||[G],fontBgColor:u&&je(N,I),workState:C,viewId:a==null?void 0:a.viewId})}}):null,[u,d,l==null?void 0:l.textOpt,s,a==null?void 0:a.viewId,c]),m=y.useMemo(()=>i?y.createElement("div",{className:"font-colors-menu",style:p,onPointerUp:I=>{I.stopPropagation(),I.nativeEvent.stopImmediatePropagation()}},y.createElement(Cn,{activeColor:u,onPointerUpHandler:I=>{I.stopPropagation();const N="transparent";h(N),l!=null&&l.textOpt&&(l.textOpt.fontBgColor=N,c({textOpt:l.textOpt})),ae.emitMethod(ne.MainEngine,V.SetColorNode,{workIds:s||[G],workState:j.Done,fontBgColor:N,viewId:a==null?void 0:a.viewId})}}),n.map((I,N)=>{const C=ii(...I);return y.createElement(Ai,{key:N,color:C,activeColor:u,onPointerUpHandler:S=>{S.stopPropagation(),h(C);const v=je(C,d);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=v,c({textOpt:l.textOpt})),ae.emitMethod(ne.MainEngine,V.SetColorNode,{workIds:s||[G],workState:j.Done,fontBgColor:je(C,d),viewId:a==null?void 0:a.viewId})}})}),f):null,[i,n,f,d,u,l==null?void 0:l.textOpt,s,a==null?void 0:a.viewId,p]),w=y.useMemo(()=>{const I=u&&u!=="transparent"&&je(u,d)||"transparent";return y.createElement("div",{className:"color-bar",style:{marginTop:0}},y.createElement("div",{className:"color-bar-color",style:{backgroundColor:I}}))},[u,d]);return y.createElement("div",{className:`button normal-button font-colors-icon ${i&&"active"}`,onPointerUp:I=>{I.stopPropagation(),I.nativeEvent.stopImmediatePropagation(),e(!i)}},y.createElement(Fm,null),w,m)},Xm=r=>{const{bold:i,setBold:e,workIds:t,viewId:s}=r,o=n=>{const a=i==="bold"?"normal":"bold";n==null||n.stopPropagation(),e(a),ae.emitMethod(ne.MainEngine,V.SetFontStyle,{workIds:t,viewId:s,bold:a})};return y.createElement("div",{className:"font-style-button",onPointerUp:o},y.createElement("img",{alt:"icon",src:Ee(i==="bold"?"bold-active":"bold")}))},Jm=r=>{const{underline:i,setUnderline:e,workIds:t,viewId:s}=r,o=n=>{const a=!i;n==null||n.stopPropagation(),e(a),ae.emitMethod(ne.MainEngine,V.SetFontStyle,{workIds:t,viewId:s,underline:a})};return y.createElement("div",{className:"font-style-button",onPointerUp:o},y.createElement("img",{alt:"icon",src:Ee(i?"underline-active":"underline")}))},qm=r=>{const{lineThrough:i,setLineThrough:e,workIds:t,viewId:s}=r,o=n=>{const a=!i;n==null||n.stopPropagation(),e(a),ae.emitMethod(ne.MainEngine,V.SetFontStyle,{workIds:t,viewId:s,lineThrough:a})};return y.createElement("div",{className:"font-style-button",onPointerUp:o},y.createElement("img",{alt:"icon",src:Ee(i?"line-through-active":"line-through")}))},Km=r=>{const{italic:i,setItalic:e,workIds:t,viewId:s}=r,o=n=>{const a=i==="italic"?"normal":"italic";n==null||n.stopPropagation(),e(a),ae.emitMethod(ne.MainEngine,V.SetFontStyle,{workIds:t,viewId:s,italic:a})};return y.createElement("div",{className:"font-style-button",onPointerUp:o},y.createElement("img",{alt:"icon",src:Ee(i==="italic"?"italic-active":"italic")}))},_m=r=>{const{open:i,setOpen:e,textOpt:t,workIds:s,style:o,floatBarRef:n}=r,{mananger:a,floatBarData:c}=y.useContext(Se),[l,u]=y.useState("normal"),[h,d]=y.useState("normal"),[g,p]=y.useState(!1),[f,m]=y.useState(!1);y.useEffect(()=>{t!=null&&t.bold&&u(t.bold),O.isBoolean(t==null?void 0:t.underline)&&p(t.underline||!1),O.isBoolean(t==null?void 0:t.lineThrough)&&m(t.lineThrough||!1),t!=null&&t.italic&&d(t.italic)},[t]);const w=y.useMemo(()=>{if(o&&(n!=null&&n.current)&&O.isNumber(c==null?void 0:c.y)&&(a!=null&&a.height)){if(n.current.offsetTop&&n.current.offsetTop+c.y>180){const N={};return N.top="inherit",N.bottom=50,N}else if(!n.current.offsetTop&&(a==null?void 0:a.height)-n.current.offsetTop-c.y<120){const N={};return N.top="inherit",N.bottom=50,N}}},[o,n==null?void 0:n.current,c,a]),I=y.useMemo(()=>i?y.createElement("div",{className:"font-style-menu",style:w,onPointerUp:N=>{N.stopPropagation(),N.nativeEvent.stopImmediatePropagation()}},y.createElement(Xm,{workIds:s||[G],bold:l,setBold:u,viewId:a==null?void 0:a.viewId}),y.createElement(Jm,{workIds:s||[G],underline:g,setUnderline:p,viewId:a==null?void 0:a.viewId}),y.createElement(qm,{workIds:s||[G],lineThrough:f,setLineThrough:m,viewId:a==null?void 0:a.viewId}),y.createElement(Km,{workIds:s||[G],italic:h,setItalic:d,viewId:a==null?void 0:a.viewId})):null,[i,s,l,a==null?void 0:a.viewId,g,f,h,w]);return y.createElement("div",{className:`button normal-button ${i&&"active"}`,onPointerUp:N=>{N.stopPropagation(),N.nativeEvent.stopImmediatePropagation(),e(!i)}},y.createElement("img",{alt:"icon",src:Ee(i?"font-style-active":"font-style")}),I)},nt=Object.freeze([12,14,18,24,36,48,64,80,144,288]),At=["top","topLeft","topRight","bottom","bottomLeft","bottomRight","left","leftTop","leftBottom","right","rightTop","rightBottom"],$t=new Map([["selector","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAYAAADE6YVjAAAACXBIWXMAAAsT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0NTQwMSAyMS42NzY4NzUyLDE5LjU1MDM5MTYgMjEuOTEwMTI0NCwxOS41MDgwNTU3IEwyMiwxOS41IEwyNywxOS41IFogTTE4LDE5LjUgQzE4LjI3NjE0MjQsMTkuNSAxOC41LDE5LjcyMzg1NzYgMTguNSwyMCBDMTguNSwyMC4yNDU0NTk5IDE4LjMyMzEyNDgsMjAuNDQ5NjA4NCAxOC4wODk4NzU2LDIwLjQ5MTk0NDMgTDE4LDIwLjUgTDEzLDIwLjUgQzEyLjcyMzg1NzYsMjAuNSAxMi41LDIwLjI3NjE0MjQgMTIuNSwyMCBDMTIuNSwxOS43NTQ1NDAxIDEyLjY3Njg3NTIsMTkuNTUwMzkxNiAxMi45MTAxMjQ0LDE5LjUwODA1NTcgTDEzLDE5LjUgTDE4LDE5LjUgWiBNMjAsMTIuNSBDMjAuMjQ1NDU5OSwxMi41IDIwLjQ0OTYwODQsMTIuNjc2ODc1MiAyMC40OTE5NDQzLDEyLjkxMDEyNDQgTDIwLjUsMTMgTDIwLjUsMTggQzIwLjUsMTguMjc2MTQyNCAyMC4yNzYxNDI0LDE4LjUgMjAsMTguNSBDMTkuNzU0NTQwMSwxOC41IDE5LjU1MDM5MTYsMTguMzIzMTI0OCAxOS41MDgwNTU3LDE4LjA4OTg3NTYgTDE5LjUsMTggTDE5LjUsMTMgQzE5LjUsMTIuNzIzODU3NiAxOS43MjM4NTc2LDEyLjUgMjAsMTIuNSBaIiBpZD0i5b2i54q257uT5ZCIIiBmaWxsPSIjMjEyMzI0IiBmaWxsLXJ1bGU9Im5vbnplcm8iPjwvcGF0aD4KICAgICAgICAgICAgPC9nPgogICAgICAgIDwvZz4KICAgIDwvZz4KPC9zdmc+"]]),ew=r=>{const{style:i,onClickHandler:e}=r;return y.createElement("div",{className:"font-size-menu",style:i,onPointerUp:t=>{t.stopPropagation(),t.nativeEvent.stopImmediatePropagation()}},nt.map(t=>y.createElement("div",{className:"font-size-btn",key:t,onPointerUp:()=>{e(t)}},t)))},tw=r=>{const i=y.useRef(null),{open:e,setOpen:t,textOpt:s,workIds:o,floatBarRef:n}=r,{mananger:a,floatBarData:c}=y.useContext(Se),[l,u]=y.useState(0),h=nt.length-1;y.useEffect(()=>{s!=null&&s.fontSize&&(u(s.fontSize),i.current&&(i.current.value=s.fontSize.toString()))},[s==null?void 0:s.fontSize]);const d=y.useMemo(()=>{if(n!=null&&n.current&&O.isNumber(c==null?void 0:c.y)&&(a!=null&&a.height)){if(n.current.offsetTop&&n.current.offsetTop+c.y>180){const w={};return w.top="inherit",w.bottom=35,w}else if(!n.current.offsetTop&&(a==null?void 0:a.height)-n.current.offsetTop-c.y<120){const w={};return w.top="inherit",w.bottom=35,w}}},[n==null?void 0:n.current,c,a]);function g(w){u(w),w&&w>=nt[0]&&w<=nt[h]&&ae.emitMethod(ne.MainEngine,V.SetFontStyle,{workIds:o||[G],fontSize:w,viewId:a==null?void 0:a.viewId})}const p=w=>{var I;(I=i.current)==null||I.blur(),t(!1),m(w)},f=y.useMemo(()=>e?y.createElement(ew,{onClickHandler:p,style:d}):null,[e,p,d]),m=w=>{w>nt[h]&&(w=nt[h]),w<nt[0]&&(w=nt[0]),g(w)};return y.createElement("div",{className:"button normal-button font-size-barBtn",style:{width:50},onPointerUp:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()}},y.createElement("input",{className:"font-size-input",ref:i,onTouchEnd:()=>{i.current&&i.current.focus()},onClick:()=>{t(!e),i.current&&i.current.focus()},onKeyDown:w=>{if(w.key==="Backspace"){const I=window.getSelection(),N=I==null?void 0:I.getRangeAt(0);if(N!=null&&N.collapsed)return w.cancelable&&w.preventDefault(),document.execCommand("delete",!1),!1}return!1},onKeyUp:w=>{var I;if(i.current){const N=i.current.value,C=parseInt(N);isNaN(C)?i.current.value="0":i.current.value=C.toString(),C&&w.key==="Enter"&&(m(C),(I=i.current)==null||I.blur(),t(!1))}}}),y.createElement("div",{className:"font-size-btns"},y.createElement("div",{className:"font-size-add",onPointerUp:()=>{m(l+nt[0])}}),y.createElement("div",{className:"font-size-cut",onPointerUp:()=>{m(l-nt[0])}})),f)},iw=r=>{const{workIds:i,mananger:e,islocked:t}=r;return y.createElement("div",{className:"button normal-button",onPointerUp:s=>{s.stopPropagation(),ae.emitMethod(ne.MainEngine,V.SetLock,{workIds:i||[G],isLocked:!t,viewId:e==null?void 0:e.viewId})}},y.createElement("img",{alt:"icon",src:Ee(t?"unlock-new":"lock-new")}))},Ji=r=>{const{icon:i,min:e,max:t,step:s,value:o,onInputHandler:n}=r,[a,c]=y.useState(0),l=y.useRef(null),u=h=>{h>t&&(h=t),h<e&&(h=e),c(h),n(h),l.current&&(l.current.value=h.toString())};return y.useEffect(()=>{o&&(c(o),l.current&&(l.current.value=o.toString()))},[o]),y.createElement("div",{className:"button input-button"},y.createElement("img",{src:Ee(i)}),y.createElement("input",{className:"input-number",type:"text",ref:l,onPointerUp:()=>{l.current&&l.current.focus()},onKeyDown:h=>{if(h.key==="Backspace"){const d=window.getSelection(),g=d==null?void 0:d.getRangeAt(0);if(g!=null&&g.collapsed)return h.cancelable&&h.preventDefault(),document.execCommand("delete",!1),!1}},onKeyUp:()=>{if(l.current){const h=l.current.value,d=parseInt(h);isNaN(d)?l.current.value="0":l.current.value=d.toString()}},onChange:h=>{const d=h.target.value,g=parseInt(d);g&&g&&g>=e&&g<=t&&u(g)}}),y.createElement("div",{className:"input-number-btns"},y.createElement("div",{className:"input-number-add",onPointerUp:()=>{u(a+s)}}),y.createElement("div",{className:"input-number-cut",onPointerUp:()=>{u(a-s)}})))},sw=r=>{const{icon:i,min:e,max:t,step:s,value:o,onInputHandler:n}=r;return y.createElement("div",{className:"button input-button"},y.createElement("img",{src:Ee(i)}),y.createElement(ow,{min:e,max:t,step:s,value:o,onInputHandler:n}))},ow=r=>{const{value:i,min:e,max:t,onInputHandler:s}=r,[o,n]=y.useState({x:0,y:0});y.useEffect(()=>{n({x:i*100,y:0})},[]);const a=(u,h)=>{let d=Math.floor(Math.max(h.x,e*100));d=Math.floor(Math.min(d,t*100)),h.x!==(o==null?void 0:o.x)&&n({x:d,y:0});const g=d/100;i!==g&&s(g)},c=()=>{},l=(u,h)=>{let d=Math.floor(Math.max(h.x,e*100));d=Math.floor(Math.min(d,t*100)),h.x!==(o==null?void 0:o.x)&&n({x:d,y:0});const g=d/100;i!==g&&s(g)};return y.createElement("div",{className:"range-number-container",onPointerUp:u=>{const h=u.nativeEvent.offsetX-6;let d=Math.floor(Math.max(h,e*100));d=Math.floor(Math.min(d,t*100)),n({x:d,y:0});const g=d/100;i!==g&&s(g)}},y.createElement("div",{className:"range-number-color"}),y.createElement("div",{className:"range-number"},y.createElement(Yt,{bounds:"parent",axis:"x",position:o,onDrag:a,onStart:c,onStop:l},y.createElement("div",{className:"circle",onPointerUp:si}))))},nw=r=>{const{icon:i,value:e,onChangeHandler:t,style:s}=r,[o,n]=y.useState(0),[a,c]=y.useState(),l=y.useRef(null),u=y.useCallback(g=>{g>=At.length&&(g=0),g<0&&(g=At.length-1),n(g),t(At[g]),c(!1),l.current&&(l.current.value=At[g])},[t]),h=y.useMemo(()=>{if(s&&s.bottom){const g={};return g.top="inherit",g.bottom=50,g}},[s]);y.useEffect(()=>{e&&(n(At.indexOf(e)),l.current&&(l.current.value=e))},[e]);const d=y.useMemo(()=>a?y.createElement(rw,{options:At,onClickHandler:u,style:h}):null,[a,u,h]);return y.createElement("div",{className:"button input-button"},y.createElement("img",{src:Ee(i)}),y.createElement("input",{readOnly:!0,className:"input-number",type:"text",ref:l,onPointerUp:()=>{l.current&&(l.current.focus(),c(!a))}}),y.createElement("div",{className:"input-number-btns"},y.createElement("div",{className:"input-number-add",onPointerUp:()=>{u(o+1)}}),y.createElement("div",{className:"input-number-cut",onPointerUp:()=>{u(o-1)}})),d)},rw=r=>{const{options:i,style:e,onClickHandler:t}=r;return y.createElement("div",{className:"select-option-menu",style:e},i.map((s,o)=>y.createElement("div",{className:"select-option-btn",key:s,onPointerUp:()=>{t(o)}},s)))},aw=r=>{const{innerRatio:i,innerVerticeStep:e,vertices:t,mananger:s,setShapeOpt:o}=r,n=l=>{o({vertices:l}),ae.emitMethod(ne.MainEngine,V.SetShapeOpt,{workIds:[G],toolsType:T.Star,viewId:s.viewId,vertices:l})},a=l=>{o({innerVerticeStep:l}),ae.emitMethod(ne.MainEngine,V.SetShapeOpt,{workIds:[G],toolsType:T.Star,viewId:s.viewId,innerVerticeStep:l})},c=l=>{o({innerRatio:l}),ae.emitMethod(ne.MainEngine,V.SetShapeOpt,{workIds:[G],toolsType:T.Star,viewId:s.viewId,innerRatio:l})};return y.createElement(y.Fragment,null,y.createElement(Ji,{value:t,icon:"polygon-vertex",min:3,max:100,step:1,onInputHandler:n}),y.createElement(Ji,{value:e,icon:"star-innerVertex",min:1,max:100,step:1,onInputHandler:a}),y.createElement(sw,{value:i,icon:"star-innerRatio",min:.1,max:1,step:.1,onInputHandler:c}))},cw=r=>{const{mananger:i,vertices:e,setShapeOpt:t}=r,s=o=>{t({vertices:o}),ae.emitMethod(ne.MainEngine,V.SetShapeOpt,{workIds:[G],toolsType:T.Polygon,viewId:i.viewId,vertices:o})};return y.createElement(Ji,{value:e,icon:"polygon-vertex",min:3,max:100,step:1,onInputHandler:s})},lw=r=>{const{mananger:i,placement:e,setShapeOpt:t}=r,s=o=>{t({placement:o}),ae.emitMethod(ne.MainEngine,V.SetShapeOpt,{workIds:[G],toolsType:T.SpeechBalloon,viewId:i.viewId,placement:o})};return y.createElement(nw,{value:e,icon:"speechBallon-placement",onChangeHandler:s})},Yi=r=>{const{icon:i,isActive:e,onPointerUpHandler:t}=r;return y.createElement("div",{className:`button tab-button ${e?"active":""}`,onPointerUp:t},y.createElement("img",{src:Ee(i)}))},hw=r=>{const{toolsTypes:i,style:e,mananger:t,shapeOpt:s,setShapeOpt:o}=r,[n,a]=y.useState();y.useEffect(()=>{i.includes(T.Polygon)?a(T.Polygon):i.includes(T.Star)?a(T.Star):a(T.SpeechBalloon)},[i]);const c=d=>{a(d)},l=y.useMemo(()=>n===T.Polygon&&t&&s.vertices?y.createElement(cw,{vertices:s.vertices,mananger:t,setShapeOpt:o}):null,[t,n,s,o]),u=y.useMemo(()=>n===T.Star&&t&&s.vertices&&s.innerVerticeStep&&s.innerRatio?y.createElement(aw,{mananger:t,vertices:s.vertices,innerVerticeStep:s.innerVerticeStep,innerRatio:s.innerRatio,setShapeOpt:o}):null,[t,n,s,o]),h=y.useMemo(()=>n===T.SpeechBalloon&&t&&s.placement?y.createElement(lw,{mananger:t,placement:s.placement,setShapeOpt:o}):null,[n,t,s.placement,o]);return y.createElement("div",{className:"shapeOpt-sub-menu",style:e,onPointerUp:si},y.createElement("div",{className:"shapeOpt-sub-menu-tabs"},i.includes(T.Polygon)&&y.createElement(Yi,{isActive:n===T.Polygon,icon:n===T.Polygon?"polygon-active":"polygon",onPointerUpHandler:c.bind(void 0,T.Polygon)})||null,i.includes(T.Star)&&y.createElement(Yi,{isActive:n===T.Star,icon:n===T.Star?"star-active":"star",onPointerUpHandler:c.bind(void 0,T.Star)})||null,i.includes(T.SpeechBalloon)&&y.createElement(Yi,{isActive:n===T.SpeechBalloon,icon:n===T.SpeechBalloon?"speechBallon-active":"speechBallon",onPointerUpHandler:c.bind(void 0,T.SpeechBalloon)})||null),y.createElement("div",{className:"shapeOpt-sub-menu-content"},l,u,h))},uw=r=>{const{open:i,setOpen:e,floatBarRef:t,toolsTypes:s,shapeOpt:o}=r,{floatBarData:n,mananger:a,setFloatBarData:c}=y.useContext(Se),l=y.useRef(null),u=y.useMemo(()=>{if(t!=null&&t.current&&O.isNumber(n==null?void 0:n.x)&&O.isNumber(n==null?void 0:n.y)&&(a!=null&&a.height)){if(t.current.offsetTop&&t.current.offsetTop+n.y>200){const p={};return p.top="inherit",p.bottom=50,p}else if(!t.current.offsetTop&&(a==null?void 0:a.height)-t.current.offsetTop-(n==null?void 0:n.y)<140){const p={};return p.top="inherit",p.bottom=50,p}}},[t,n==null?void 0:n.x,n==null?void 0:n.y,a==null?void 0:a.height]),h=y.useCallback(p=>{c({shapeOpt:{...o,...p}})},[c,o]),d=y.useMemo(()=>i&&s&&a&&o?y.createElement(hw,{shapeOpt:o,style:u,toolsTypes:s,mananger:a,setShapeOpt:h}):null,[i,u,s,a,o,h]),g=()=>{e(!i)};return y.createElement("div",{ref:l,className:`button normal-button ${i&&"active"}`,onPointerUp:g},d,y.createElement("img",{alt:"icon",src:Ee(i?"shapes-active":"shapes")}))},kn=y.memo(r=>{const{textOpt:i,workIds:e,noLayer:t,position:s,noDelete:o,noCopy:n}=r,{floatBarData:a,mananger:c}=y.useContext(Se),[l,u]=y.useState(0),[h,d]=y.useState(),g=y.useRef(null);y.useEffect(()=>{var P,A,E,R;const x={},L=(a==null?void 0:a.w)||((P=i==null?void 0:i.boxSize)==null?void 0:P[0])||0,b=(a==null?void 0:a.h)||((A=i==null?void 0:i.boxSize)==null?void 0:A[1])||0;if(s&&L&&b&&(c!=null&&c.width)&&(c!=null&&c.height)){if(s.y<60?s.y+b<c.height-60?x.bottom=-120:s.y+b<c.height?x.bottom=-58:s.y>0?x.top=62:x.top=-s.y+62:x.top=0,s.x<0)x.left=-s.x+3;else if(s.x+(((E=g.current)==null?void 0:E.offsetWidth)||L)>c.width){const z=c.width-(((R=g.current)==null?void 0:R.offsetWidth)||L)-s.x;x.left=z}d(x);return}d(void 0)},[g,s,a==null?void 0:a.w,a==null?void 0:a.h,c==null?void 0:c.width,c==null?void 0:c.height,i==null?void 0:i.boxSize]);const p=y.useMemo(()=>a!=null&&a.fillColor?y.createElement(Hm,{floatBarRef:g,open:l===3,setOpen:x=>{u(x===!0?3:0)}}):null,[a==null?void 0:a.fillColor,l,g]),f=y.useMemo(()=>a!=null&&a.strokeColor?y.createElement(Zm,{floatBarRef:g,open:l===2,setOpen:x=>{u(x===!0?2:0)}}):null,[a==null?void 0:a.strokeColor,l,g]),m=y.useMemo(()=>i!=null&&i.fontColor&&(c!=null&&c.viewId)?y.createElement(Gm,{floatBarRef:g,open:l===4,setOpen:x=>{u(x===!0?4:0)},textOpt:i,workIds:e}):null,[i,l,e,c,g]),w=y.useMemo(()=>i!=null&&i.fontBgColor&&(c!=null&&c.viewId)?y.createElement($m,{floatBarRef:g,open:l===5,setOpen:x=>{u(x===!0?5:0)},textOpt:i,workIds:e}):null,[i,l,e,c,g]),I=y.useMemo(()=>i&&(c!=null&&c.viewId)?y.createElement(_m,{floatBarRef:g,open:l===6,setOpen:x=>{u(x===!0?6:0)},textOpt:i,workIds:e,style:h}):null,[i,l,e,c,h,g]),N=y.useMemo(()=>i&&(c!=null&&c.viewId)?y.createElement(tw,{open:l===7,setOpen:x=>{u(x===!0?7:0)},textOpt:i,workIds:e,floatBarRef:g}):null,[i,l,e,c,g]),C=y.useMemo(()=>t?null:y.createElement(Bm,{open:l===1,setOpen:x=>{u(x===!0?1:0)},floatBarRef:g}),[t,l,g]),S=y.useMemo(()=>a!=null&&a.canLock&&c?y.createElement(iw,{workIds:e,mananger:c,islocked:a.isLocked}):null,[a,c,e]),v=y.useMemo(()=>c&&(c!=null&&c.viewId)&&h&&(a!=null&&a.shapeOpt)&&(a!=null&&a.toolsTypes)?y.createElement(uw,{open:l===8,setOpen:x=>{u(x===!0?8:0)},floatBarRef:g,workIds:e,toolsTypes:a.toolsTypes,shapeOpt:a.shapeOpt}):null,[a,c,l,h,e,g]);return y.createElement("div",{className:"appliance-plugin-floatbtns",style:h,ref:g},c&&!o&&y.createElement(Ym,{workIds:e,mananger:c}),C,S,!!(c!=null&&c.viewId)&&!n&&y.createElement(Um,{workIds:e,viewId:c.viewId}),v,I,N,m,w,f,p)}),dw=r=>{const{data:i,workId:e,updateOptInfo:t,handlePointerDown:s,handlePointerUp:o}=r,{opt:n,scale:a,translate:c,x:l,y:u}=i,h=y.useRef(null),{floatBarData:d}=y.useContext(Se),g=y.useMemo(()=>{const{fontSize:m,fontFamily:w,underline:I,fontColor:N,lineThrough:C,textAlign:S,strokeColor:v,lineHeight:x,bold:L,italic:b}=n,P=x||m*1.2,A={fontSize:`${m}px`,lineHeight:`${P}px`,color:N,borderColor:v,minHeight:`${P}px`,pointerEvents:"none",paddingRight:`${b==="italic"?Math.round(m*.3):5}px`};return w&&(A.fontFamily=`${w}`),(C||I)&&(A.textDecoration=`${C&&"line-through"||""}${I&&" underline"||""}`),S&&(A.textAlign=`${S}`),L&&(A.fontWeight=`${L}`),b&&(A.fontStyle=`${b}`),A},[n]),p=y.useMemo(()=>{const m=[];if(n.text){const w=Dt(n.text);for(let I=0;I<w.length;I++){const N=w[I];N===""?m.push(y.createElement("div",{key:I})):m.push(y.createElement("div",{key:I},N))}}return m.length?m:y.createElement("div",null)},[n.text]),f=y.useMemo(()=>{if(!d)return{};const m=`scale(${a||1}) ${c&&"translate("+c[0]+"px,"+c[1]+"px)"||""}`;return{left:`${l-d.x}px`,top:`${u-d.y}px`,zIndex:1,transform:m,transformOrigin:"left top",opacity:0,pointerEvents:"auto"}},[a,c,l,u,d]);return y.useEffect(()=>{var m,w;if((m=h.current)!=null&&m.offsetWidth&&((w=h.current)!=null&&w.offsetHeight)){const I=n.boxSize;if((I==null?void 0:I[0])!==h.current.offsetWidth||I[1]!==h.current.offsetHeight||!I){const N=[h.current.offsetWidth,h.current.offsetHeight];t({activeTextId:e,update:{boxSize:N,workState:j.Done}})}}},[n.fontSize,n.italic,n.bold,n.boxSize,e,t]),y.createElement("div",{className:"editor-box readonly",style:f,onPointerDown:()=>{s(e)},onPointerUp:()=>{o()}},y.createElement("div",{className:"editor",ref:h,style:g},p))},pw=r=>{const{mananger:i}=y.useContext(Se),e=y.useMemo(()=>{var s;const t=o=>{var u,h;if(!i)return;const{activeTextId:n,update:a,syncData:c}=o,l=n&&O.cloneDeep(((u=i.control.textEditorManager)==null?void 0:u.get(n))||((h=r.editors)==null?void 0:h.get(n)));l&&l.opt&&(l.opt={...l.opt,...a},c&&(l.canSync=Object.keys(c).includes("canSync")&&c.canSync||l.canSync,l.canWorker=Object.keys(c).includes("canWorker")&&c.canWorker||l.canWorker),i.control.textEditorManager.updateForViewEdited(n,l))};if((s=r.editors)!=null&&s.size){const o=[];return r.editors.forEach((n,a)=>{if(r.selectIds&&r.selectIds.includes(a)){const c=y.createElement(dw,{key:a,workId:a,data:n,updateOptInfo:t,handlePointerDown:r.handleTextEditorPointerDown,handlePointerUp:r.handleTextEditorPointerUp});o.push(c)}}),o}return null},[r.editors,r.selectIds,i,r.handleTextEditorPointerDown,r.handleTextEditorPointerUp]);return y.createElement(y.Fragment,null,e)},gw=r=>{const{position:i,textOpt:e,workIds:t,noLayer:s,noCopy:o,noDelete:n,style:a}=r,c=y.useRef(null);return y.createElement("div",{className:We.FloatBarBtn,ref:c,style:a},y.createElement(kn,{position:i,textOpt:e,workIds:t,noLayer:s,noCopy:o,noDelete:n}))},fw=r=>{const{data:i,workId:e,showFloatBtns:t,handleKeyUp:s,handleFocus:o,runAnimation:n,updateSize:a,rightBoundBreak:c}=r,{activeTextEditor:l,activeTextId:u,mananger:h}=y.useContext(Se),{opt:d,scale:g,translate:p,x:f,y:m}=i,{fontSize:w,fontFamily:I,underline:N,fontColor:C,lineThrough:S,textAlign:v,lineHeight:x,bold:L,italic:b}=d,P=y.useRef(null),A=y.useMemo(()=>{const H=w,K=x||H*1.2,ie={fontSize:`${H}px`,lineHeight:`${K}px`,color:C,minHeight:`${K}px`,paddingRight:`${b==="italic"?Math.round(H*.3):5}px`,borderWidth:`${Math.max(Math.round(1/(g||1)),1)}px`};return I&&(ie.fontFamily=`${I}`),(S||N)&&(ie.textDecoration=`${S&&"line-through"||""} ${N&&" underline"||""}`),v&&(ie.textAlign=`${v}`),L&&(ie.fontWeight=`${L}`),b&&(ie.fontStyle=`${b}`),ie},[L,C,I,w,b,x,S,g,v,N]),E=y.useRef(!1),R=y.useRef(6),z=y.useRef({fontSize:A.fontSize,lineHeight:A.lineHeight,fontStyle:A.fontStyle,fontWeight:A.fontWeight,fontFamily:A.fontFamily}),Z=y.useMemo(()=>u===e?"hover":d.workState===j.Doing||d.workState===j.Start?"editing":l?"active":"none",[u,e,d.workState,l]);function ee(H){if(P.current){const K=window==null?void 0:window.getSelection(),ie=P.current,pe=(ye,we)=>{var fe;const Te=document.createRange();if(we.childNodes.length>0){const xe=we.lastChild;if(xe){const Oe=xe.lastChild;Oe&&Oe.nodeType===Node.TEXT_NODE?Te.setStart(Oe,((fe=Oe.textContent)==null?void 0:fe.length)||0):Te.setStart(xe,0)}else Te.setStart(we,0)}else Te.setStart(we,0);Te.collapse(!0),ye.removeAllRanges(),ye.addRange(Te)};if(K&&ie)if(H&&Ct(H.nativeEvent)){const{x:ye,y:we}=Ts(H.nativeEvent);if(document.caretPositionFromPoint){const Te=document.caretPositionFromPoint(ye,we);if(Te){const fe=document.createRange();fe.setStart(Te.offsetNode,Te.offset),fe.collapse(!0),K.removeAllRanges(),K.addRange(fe)}else pe(K,ie)}else if(document.caretRangeFromPoint){const Te=document.caretRangeFromPoint(ye,we);Te?(K.removeAllRanges(),K.addRange(Te)):pe(K,ie)}else pe(K,ie)}else pe(K,ie);P.current.focus()}}const F=y.useMemo(()=>{const H=`scale(${g||1}) ${p&&"translate("+p[0]+"px,"+p[1]+"px)"||""}`;return{left:`${f}px`,top:`${m}px`,zIndex:2,transform:H,transformOrigin:"left top",borderColor:Z==="editing"||Z==="hover"?C:"transparent"}},[g,p,f,m,C,Z]),X=y.useMemo(()=>{let H="";const K=`<div style="background-color:${d.fontBgColor};"></div>`;if(d.text){const ie=Dt(d.text);for(let pe=0;pe<ie.length;pe++){const ye=ie[pe];if(ye==="")H=H+K;else{const we=ye.replace(/[<>&]/g,Te=>({"<":"&lt;",">":"&gt;","&":"&amp;"})[Te]);H=H+`<div style="background-color:${d.fontBgColor}">${we}</div>`}}}else H=K;return H},[d.fontBgColor,d.text]),te=y.useMemo(()=>{var H,K;if(Z==="hover"){if(g&&t&&O.isNumber(f)&&O.isNumber(m)&&d.boxSize&&O.isNumber((H=d.boxSize)==null?void 0:H[0])&&O.isNumber((K=d.boxSize)==null?void 0:K[1])){const ie={x:f,y:m},pe={left:f,top:m,width:d.boxSize[0]*g,height:d.boxSize[1]*g};return y.createElement(gw,{position:ie,style:pe,textOpt:d,workIds:[e],noLayer:!0,noCopy:!0,noDelete:!0})}return null}return null},[d,t,e,f,m,g,Z]);y.useEffect(()=>{u===e&&P.current&&(document.activeElement!==P.current&&ee(),o(P.current))},[u,o,e]),y.useEffect(()=>{if(P.current){const H=parseInt(getComputedStyle(P.current).paddingRight,10)+parseInt(getComputedStyle(P.current).borderWidth,10);R.current=Number(H)}},[]),y.useEffect(()=>{if(P.current){const H={fontSize:A.fontSize,lineHeight:A.lineHeight,fontStyle:A.fontStyle,fontWeight:A.fontWeight,fontFamily:A.fontFamily};if(!O.isEqual(z.current,H)){z.current=H;const K=[P.current.offsetWidth,P.current.offsetHeight];a(e,K)}}},[A,e,a]);const le=y.useCallback(H=>{var we,Te;const K=h==null?void 0:h.parentElement;if(!K||!P.current||!c)return!1;const ie=P.current.lastChild;if(!ie)return!1;const pe=ie.getBoundingClientRect(),ye=K.getBoundingClientRect();if(pe.right+H>ye.right){const fe=ie.lastChild;if(!(fe instanceof Text))return!1;const xe=fe.length||0;let Oe=0,Ce=0,Qe=xe;for(;Ce<Qe;){const Ae=Math.floor((Ce+Qe)/2),dt=document.createRange();dt.setStart(fe,0),dt.setEnd(fe,Ae);const Lt=dt.getBoundingClientRect(),Ns=ye.right-Lt.right;if(Ns<H){if(Ae>0){const yt=document.createRange();yt.setStart(fe,0),yt.setEnd(fe,Ae-1);const Ht=yt.getBoundingClientRect();if(ye.right-Ht.right>=H){Oe=Ae-1;break}}Qe=Ae}else{const yt=Ae+1;if(yt<xe){const Ht=document.createRange();Ht.setStart(fe,0),Ht.setEnd(fe,yt);const Ss=Ht.getBoundingClientRect();if(ye.right-Ss.right<=H&&Ns>H){Oe=Ae;break}}Ce=yt}}if(!Oe){const Ae=document.createRange();Ae.setStart(fe,0),Ae.setEnd(fe,Ce);const dt=Ae.getBoundingClientRect();ye.right-dt.right>H?Oe=Ce:Ce>0&&(Oe=Ce-1)}if(Oe>0){const Ae=((we=fe.textContent)==null?void 0:we.slice(0,Oe))||"",dt=((Te=fe.textContent)==null?void 0:Te.slice(Oe))||"";fe.textContent=Ae;const Lt=document.createElement("div");return d.fontBgColor&&(Lt.style.backgroundColor=d.fontBgColor),dt&&(Lt.textContent=dt),P.current.appendChild(Lt),le(H),!0}}return!1},[h==null?void 0:h.parentElement,d.fontBgColor,c]);function se(H){if(H.key==="Backspace"){const K=window.getSelection(),ie=K==null?void 0:K.getRangeAt(0);if(ie!=null&&ie.collapsed)return H.cancelable&&H.preventDefault(),document.execCommand("delete",!1),!1}return!1}function _(H,K){const ie=window==null?void 0:window.getSelection();if(ie!=null&&ie.rangeCount&&H&&ie&&ie.anchorNode){const pe=ie.anchorOffset,ye=ie.anchorNode.textContent||"",we=ye.slice(0,pe)||"",Te=ye.slice(pe)||"",fe=we.concat(H)||"";J(fe,Te,K)}}function J(H,K,ie){const pe=window==null?void 0:window.getSelection();if(!(pe!=null&&pe.rangeCount)||!pe.anchorNode)return;const ye=H.split(/\n/);let we=pe.anchorNode.parentNode;we===ie&&(we=pe.anchorNode);const Te=[...ie.childNodes],fe=[];let xe,Oe=pe.anchorOffset;for(;Te.length;){const Ce=Te.pop();if(Ce){if(Ce===we){let Qe=ye[0];ye.length===1&&(Oe=ye[0].length,Qe=ye[0].concat(K)),we.nodeName==="#text"?(we.textContent=Qe,xe=we):we.nodeName==="DIV"&&(we.innerText=Qe,xe=we.childNodes[0]);break}fe.push(Ce),ie.removeChild(Ce)}}if(ye.length>1)for(let Ce=1;Ce<ye.length;Ce++){let Qe=ye[Ce];const Ae=document.createElement("div");d.fontBgColor&&(Ae.style.backgroundColor=d.fontBgColor),Ce===ye.length-1&&(Oe=Qe.length,Qe=Qe.concat(K)),Ae.innerText=Qe,ie.appendChild(Ae),Ce===ye.length-1&&(xe=Ae.childNodes[0])}if(fe.length){fe.reverse();for(const Ce of fe)ie.appendChild(Ce)}if(xe&&xe.nodeName==="#text"){pe.deleteFromDocument();const Ce=document.createRange(),Qe=Math.min(Oe,(xe==null?void 0:xe.length)||0);Ce.setStart(xe,Qe),Ce.collapse(!0),pe.removeAllRanges(),pe.addRange(Ce)}}function de(H){if(H.cancelable&&H.preventDefault(),H.stopPropagation(),H.stopImmediatePropagation(),P.current){const K=(H.clipboardData||window.clipboardData).getData("text"),ie=window==null?void 0:window.getSelection();if(!(ie!=null&&ie.rangeCount))return;if(K&&ie&&ie.anchorNode){const pe=Bi(K,{whiteList:{},stripIgnoreTag:!0,stripIgnoreTagBody:["script"]});_(pe,P.current),s(P.current)}n()}}function Fe(H){var ie;const K=H.querySelector("div");if(K){const pe=document.createTreeWalker(H,NodeFilter.SHOW_TEXT,null);let ye;const we=[];for(;(ye=pe.nextNode())!==null;)ye.parentNode===H&&we.push(ye);if(we.length>0){for(const fe of we)K.appendChild(fe);const Te=window.getSelection();if(Te){const fe=document.createRange(),xe=K.lastChild;xe&&xe.nodeType===Node.TEXT_NODE&&(fe.setStart(xe,((ie=xe.textContent)==null?void 0:ie.length)||0),fe.collapse(!0),Te.removeAllRanges(),Te.addRange(fe))}}}}const ke=y.useCallback(()=>{const H=P.current;n(()=>{if(!E.current&&H){if(Fe(H),le((g||1)*R.current)){const K=window.getSelection();if(!(K!=null&&K.rangeCount))return!1;const ie=document.createRange(),pe=P.current.lastChild;ie.selectNodeContents(pe),ie.collapse(!1),K.removeAllRanges(),K.addRange(ie)}s(H)}})},[n,s,le,g]);function q(){E.current=!0,n()}function Le(){E.current=!1,ke()}const Ue=y.useCallback(()=>{if(Z==="active"&&P.current&&P.current.parentElement){const H=P.current.parentElement;H.style.borderColor=C}},[Z,C]),st=y.useCallback(()=>{if(Z==="active"&&P.current&&P.current.parentElement){const H=P.current.parentElement;H.style.borderColor="transparent"}},[Z]);return y.createElement(y.Fragment,null,te,y.createElement("div",{className:`editor-box ${Z}`,style:F,onPointerUp:()=>{var H;if(Z==="editing"){n(()=>{var K;(K=document.activeElement)==null||K.blur(),h==null||h.control.textEditorManager.checkEmptyTextBlur()});return}if(Z==="active"&&h){if((H=h.control.collector)!=null&&H.hasIncludeSelector(e)){n(()=>{var K;(K=document.activeElement)==null||K.blur(),h==null||h.control.textEditorManager.checkEmptyTextBlur()});return}if(h&&u!==e){h.control.textEditorManager.checkEmptyTextBlur(),h.control.textEditorManager.active(e);return}}},onMouseOver:Ue,onMouseLeave:st},y.createElement("div",{id:e,suppressContentEditableWarning:!0,contentEditable:!0,className:"editor",ref:P,style:A,onKeyDown:se,onPaste:de,onTouchEnd:ee,onInput:ke,onCompositionStart:q,onCompositionEnd:Le,dangerouslySetInnerHTML:{__html:X}})))},Mw=r=>{const i=y.useRef(null),{mananger:e}=y.useContext(Se),t=y.useRef(),s=y.useCallback(n=>{var h,d;const{activeTextId:a,update:c,syncData:l}=n;if(!e)return;const u=a&&O.cloneDeep(((h=e.control.textEditorManager)==null?void 0:h.get(a))||((d=r.editors)==null?void 0:d.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=y.useMemo(()=>{var h;const n=d=>{const g=[];for(let p=0;p<d.childNodes.length;p++){const f=d.childNodes[p];if(f.nodeName==="#text"&&p===0){const m=f.textContent.split(/\n/),w=m.pop();g.push(...m),w&&g.push(w)}else if(f.nodeName==="DIV"){const m=f.innerText.split(/\n/);if(m.length===2&&m[0]===""&&m[1]==="")g.push("");else{const w=m.shift();(w||w==="")&&g.push(w);const I=m.pop();g.push(...m),I&&g.push(I)}}}return g},a=d=>{if(!e)return;const g=d.id,p=e.control.textEditorManager.get(g),f=j.Doing,m=[d.offsetWidth,d.offsetHeight];(!p||p&&(!O.isEqual(p.opt.boxSize,m)||!O.isEqual(p.opt.workState,f)))&&s({activeTextId:g,update:{boxSize:m,workState:f},syncData:{canSync:!0,canWorker:!0}})},c=d=>{var N,C;if(!e)return;const g=n(d),p=d.id,f=e.control.textEditorManager.get(p),m=Be(g),w=j.Doing,I=[d.offsetWidth,d.offsetHeight];if(!f||f&&(f.opt.text!==m||!O.isEqual(f.opt.boxSize,I)||!O.isEqual(f.opt.workState,w))){const S=p&&O.cloneDeep(((N=e.control.textEditorManager)==null?void 0:N.get(p))||((C=r.editors)==null?void 0:C.get(p)));S&&S.opt&&(S.opt={...S.opt,text:m,boxSize:I,workState:w},S.canSync=!0,S.canWorker=!0,e.control.textEditorManager.updateForViewEdited(p,S)),e.control.textEditorManager.publicMsgEmitter.emit("textChange",p,d,g,S)}},l=(d,g)=>{if(!e)return;const p=d,f=e.control.textEditorManager.get(p);if(f&&!O.isEqual(f.opt.boxSize,g)){const m=O.cloneDeep(f);m.opt={...m.opt,boxSize:g},m.canSync=!1,m.canWorker=!1,e.control.textEditorManager.updateForViewEdited(p,m)}},u=d=>{t.current&&cancelAnimationFrame(t.current),t.current=requestAnimationFrame(()=>{i!=null&&i.current&&(i==null||i.current.scrollTo({left:0,behavior:"instant"}),d&&d(),t.current=void 0)})};if((h=r.editors)!=null&&h.size){const d=[];return r.editors.forEach((g,p)=>{d.push(y.createElement(fw,{key:p,workId:p,data:g,showFloatBtns:r.showFloatBtns||!1,handleFocus:a,handleKeyUp:c,updateSize:l,runAnimation:u,rightBoundBreak:r.rightBoundBreak||!1}))}),d}return null},[r.editors,r.showFloatBtns,r.rightBoundBreak,e,s]);return y.createElement("div",{className:`${r.className}`,ref:i},o)},yw=()=>{const{floatBarData:r}=y.useContext(Se);return y.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:r==null?void 0:r.selectorColor}},y.createElement("div",{className:"point LT nwse-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),y.createElement("div",{className:"point LC ew-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),y.createElement("div",{className:"point LB nesw-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),y.createElement("div",{className:"point TC ns-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),y.createElement("div",{className:"point RT nesw-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),y.createElement("div",{className:"point RC ew-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),y.createElement("div",{className:"point RB nwse-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),y.createElement("div",{className:"point BC ns-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}))},mw=()=>{const{floatBarData:r,mananger:i}=y.useContext(Se),[e,t]=y.useState(),[s,o]=y.useState();y.useEffect(()=>{const c=[];if(i&&O.isNumber(r==null?void 0:r.x)&&O.isNumber(r==null?void 0:r.y)&&(r!=null&&r.points)){const l=i.viewId;if(i.control.viewContainerManager.getView(l))for(const h of r.points){const d=i.control.viewContainerManager.transformToOriginPoint(h,l);c.push(d)}c[0]&&t({x:c[0][0]-((r==null?void 0:r.x)||0),y:c[0][1]-((r==null?void 0:r.y)||0)}),c[1]&&o({x:c[1][0]-((r==null?void 0:r.x)||0),y:c[1][1]-((r==null?void 0:r.y)||0)})}},[i,r==null?void 0:r.points,r==null?void 0:r.x,r==null?void 0:r.y]);const n=y.useMemo(()=>e?y.createElement("div",{className:"point point-dot",style:{borderColor:r==null?void 0:r.selectorColor,left:e.x,top:e.y}}):null,[r==null?void 0:r.selectorColor,e]),a=y.useMemo(()=>s?y.createElement("div",{className:"point point-dot",style:{borderColor:r==null?void 0:r.selectorColor,left:s.x,top:s.y}}):null,[s,r==null?void 0:r.selectorColor]);return y.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:r==null?void 0:r.selectorColor}},n,a)},ww=()=>{const{floatBarData:r}=y.useContext(Se);return y.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:r==null?void 0:r.selectorColor}},y.createElement("div",{className:"point LT nwse-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),y.createElement("div",{className:"point LB nesw-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),y.createElement("div",{className:"point RT nesw-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),y.createElement("div",{className:"point RB nwse-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}))},Iw=()=>{const{floatBarData:r}=y.useContext(Se);return y.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:r==null?void 0:r.selectorColor}},y.createElement("img",{className:"lock",alt:"lock",src:"https://sdk.netless.link/resource/icons/lock.svg"}))},Tw=r=>{const{className:i}=r,{floatBarData:e,angle:t,setAngle:s,setOperationType:o,mananger:n}=y.useContext(Se),[a,c]=y.useState(j.Pending),[l,u]=y.useState(),[h,d]=y.useState(!1),[g,p]=y.useState(new Q),[f,m]=y.useState(new Q),[w,I]=y.useState(!1),N=y.useRef(0),C=y.useRef(null),S=P=>{if(!P){I(!0),d(!1),o(V.None),c(j.Pending);return}I(!1)},v=(P,A)=>{N.current&&(clearTimeout(N.current),N.current=0),c(j.Done),d(!1);const E=Math.round(Q.GetAngleByPoints(g,f,new Q(A.x,A.y)))||0;s(E),o(V.None),ae.emitMethod(ne.MainEngine,V.RotateNode,{workIds:[G],angle:E,workState:j.Done,viewId:n==null?void 0:n.viewId})};y.useEffect(()=>(ae.activeListener(S),()=>{ae.unmountActiveListener(S)}),[]),y.useEffect(()=>{if(e&&(a===j.Pending||a===j.Done)){const P={x:(e==null?void 0:e.x)-20,y:(e==null?void 0:e.y)+(e==null?void 0:e.h)},A={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};m(new Q(A.x,A.y)),p(new Q(P.x,P.y)),u({x:P.x,y:P.y})}},[e,a]);const x=(P,A)=>{if(n!=null&&n.control.worker.isBusy){I(!0),c(j.Pending);return}N.current&&(clearTimeout(N.current),N.current=0),c(j.Start),d(!0);const E=Math.round(Q.GetAngleByPoints(g,f,new Q(A.x,A.y)))||0;s(E),o(V.RotateNode),ae.emitMethod(ne.MainEngine,V.RotateNode,{workIds:[G],angle:0,workState:j.Start,viewId:n==null?void 0:n.viewId})},L=(P,A)=>{if(n!=null&&n.control.worker.isBusy){I(!0),v(P,A);return}v(P,A)},b=(P,A)=>{if(n!=null&&n.control.worker.isBusy){I(!0),v(P,A);return}N.current||(u({x:A.x,y:A.y}),d(!0),N.current=setTimeout(()=>{N.current=0;const E=Math.round(Q.GetAngleByPoints(g,f,new Q(A.x,A.y)))||0;s(E),o(V.RotateNode),c(j.Doing),ae.emitMethod(ne.MainEngine,V.RotateNode,{workIds:[G],angle:E,workState:j.Doing,viewId:n==null?void 0:n.viewId})},60))};return y.createElement(Yt,{disabled:w,position:l,onStart:x,onDrag:b,onStop:L},y.createElement("div",{className:`${i}`,style:e?{left:0,top:0,touchAction:"none"}:void 0},!h&&y.createElement("div",{className:"appliance-plugin-rotate-btn",style:{backgroundColor:e==null?void 0:e.selectorColor}},y.createElement("img",{alt:"icon",src:Ee("rotation-button")})),y.createElement("div",{ref:C,className:`appliance-plugin-rotate-mouse-pointer ${h?"active":""}`},y.createElement("img",{alt:"icon",src:Ee("rotation")}),y.createElement("div",{className:"angle-icon"},t,"°"))))},vw=r=>{const{editors:i,canSelectorSwitch:e}=r,{floatBarData:t,setOperationType:s,mananger:o,isNoPointerEvents:n}=y.useContext(Se),[a,c]=y.useState(),[l,u]=y.useState(!1),h=y.useRef(0),d=y.useRef(),g=y.useRef(j.Pending),p=y.useMemo(()=>!!((t==null?void 0:t.scaleType)===ce.none&&(t!=null&&t.canLock)),[t]),f=y.useMemo(()=>t&&t.w&&t.h?{position:"absolute",left:0,top:0,width:t.w,height:t.h,zIndex:2,pointerEvents:p||n?"none":"auto",touchAction:"none"}:{display:"none",pointerEvents:"none"},[t,p,n]),m=v=>{if(!v||t!=null&&t.isLocked){u(!0),g.current=j.Pending,s(V.None);return}u(!1)},w=(v,x)=>{h.current&&(clearTimeout(h.current),h.current=0);const L={x:x.x,y:x.y};s(V.None),g.current=j.Done,c(L),ae.emitMethod(ne.MainEngine,V.TranslateNode,{workIds:[G],position:L,workState:j.Done,viewId:o==null?void 0:o.viewId})};y.useEffect(()=>(ae.activeListener(m),()=>{ae.unmountActiveListener(m)}),[]),y.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]),y.useEffect(()=>{(g.current===j.Pending||g.current===j.Done)&&O.isNumber(t==null?void 0:t.x)&&O.isNumber(t==null?void 0:t.y)&&c({x:t==null?void 0:t.x,y:t==null?void 0:t.y})},[t==null?void 0:t.x,t==null?void 0:t.y]);const I=()=>{if(o!=null&&o.control.worker.isBusy){u(!0);return}h.current&&(clearTimeout(h.current),h.current=0),O.isNumber(t==null?void 0:t.x)&&O.isNumber(t==null?void 0:t.y)&&(s(V.TranslateNode),g.current=j.Start,ae.emitMethod(ne.MainEngine,V.TranslateNode,{workIds:[G],position:{x:t==null?void 0:t.x,y:t==null?void 0:t.y},workState:j.Start,viewId:o==null?void 0:o.viewId}))},N=(v,x)=>{var P;o!=null&&o.control.worker.isBusy&&u(!0);const L=g.current,b=d.current;if(w(v,x),d.current&&(d.current=void 0),L===j.Start&&(i!=null&&i.size)&&b){const A=(P=o==null?void 0:o.control.viewContainerManager.getView(o.viewId))==null?void 0:P.focusScenePath;A&&(o==null||o.control.worker.blurSelector(o.viewId,A))}},C=(v,x)=>{if(o!=null&&o.control.worker.isBusy){u(!0),w(v,x);return}if(h.current)return;const L={x:x.x,y:x.y};c(L),h.current=setTimeout(()=>{h.current=0,(L.x!==(a==null?void 0:a.x)||L.y!==(a==null?void 0:a.y))&&(d.current&&(d.current=void 0),g.current=j.Doing,ae.emitMethod(ne.MainEngine,V.TranslateNode,{workIds:[G],position:L,workState:j.Doing,viewId:o==null?void 0:o.viewId}))},60)},S=y.useMemo(()=>{if(i){const v=L=>{e&&(d.current=L)},x=()=>{o&&e&&g.current===j.Start&&d.current&&o.control.textEditorManager.active(d.current)};return y.createElement(pw,{editors:i,selectIds:(t==null?void 0:t.selectIds)||[],handleTextEditorPointerDown:v,handleTextEditorPointerUp:x})}return null},[i,t==null?void 0:t.selectIds,o,e]);return y.createElement(Yt,{disabled:l,position:a,onStart:I,onDrag:C,onStop:N},y.createElement("div",{style:f},S))},Nw=r=>{const{className:i}=r,[e,t]=y.useState({x:0,y:0,h:0,w:0}),[s,o]=y.useState(),[n,a]=y.useState(),[c,l]=y.useState(),{floatBarData:u,mananger:h,isNoPointerEvents:d,setOperationType:g}=y.useContext(Se),[p,f]=y.useState(),[m,w]=y.useState(!1),I=y.useRef(0);y.useEffect(()=>{if(u&&h){const A={x:u.x,y:u.y,w:u.w,h:u.h};t(A)}return ae.activeListener(C),()=>{ae.unmountActiveListener(C)}},[]),y.useEffect(()=>{if(h!=null&&h.control.worker.isBusy){w(!0);return}w(!1)},[h==null?void 0:h.control.worker.isBusy]);const N=()=>{if(I.current&&(clearTimeout(I.current),I.current=0),p){const{scale:A,translate:E}=p;g(V.None),ae.emitMethod(ne.MainEngine,V.ScaleNode,{workIds:[G],scale:A,dir:c,translate:E,originPoint:s,scenePoint:n,workState:j.Done,viewId:h==null?void 0:h.viewId})}},C=A=>{if(!A){w(!0);return}w(!1)},S=A=>[[A.x,A.y],[A.x+A.w,A.y],[A.x+A.w,A.y+A.h],[A.x,A.y+A.h]],v=(A,E)=>{switch(E){case"top":case"topLeft":case"left":return A[2];case"topRight":return A[3];case"right":case"bottomRight":case"bottom":return A[0];case"bottomLeft":return A[1]}},x=(A,E,R,z)=>{let Z=!1,ee=!1;const F={x:e.x,y:e.y,w:e.w,h:e.h},X=[1,1],te=[0,0];switch(A){case"top":{const J=E.height+e.h;J<0?(ee=!0,F.y=e.y+e.h,F.h=Math.abs(J)):(F.y=e.y-E.height,F.h=e.h+E.height);break}case"topLeft":{const J=E.width+e.w;J<0?(Z=!0,F.x=e.x+e.w,F.w=Math.abs(J)):(F.x=e.x-E.width,F.w=e.w+E.width);const de=E.height+e.h;de<0?(ee=!0,F.y=e.y+e.h,F.h=Math.abs(de)):(F.y=e.y-E.height,F.h=e.h+E.height);break}case"topRight":{const J=E.width+e.w;J<0?(Z=!0,F.x=e.x+J,F.w=Math.abs(J)):F.w=e.w+E.width;const de=E.height+e.h;de<0?(ee=!0,F.y=e.y+e.h,F.h=Math.abs(de)):(F.y=e.y-E.height,F.h=e.h+E.height);break}case"bottom":{const J=E.height+e.h;J<0?(ee=!0,F.y=e.y+J,F.h=Math.abs(J)):F.h=e.h+E.height;break}case"bottomLeft":{const J=E.width+e.w;J<0?(Z=!0,F.x=e.x+e.w,F.w=Math.abs(J)):(F.x=e.x-E.width,F.w=e.w+E.width);const de=E.height+e.h;de<0?(ee=!0,F.y=e.y+de,F.h=Math.abs(de)):F.h=e.h+E.height;break}case"left":{const J=E.width+e.w;J<0?(Z=!0,F.x=e.x+e.w,F.w=Math.abs(J)):(F.x=e.x-E.width,F.w=e.w+E.width);break}case"bottomRight":{const J=E.width+e.w;J<0?(Z=!0,F.x=e.x+J,F.w=Math.abs(J)):F.w=e.w+E.width;const de=E.height+e.h;de<0?(ee=!0,F.y=e.y+de,F.h=Math.abs(de)):F.h=e.h+E.height;break}case"right":{const J=E.width+e.w;J<0?(Z=!0,F.x=e.x+J,F.w=Math.abs(J)):F.w=e.w+E.width;break}}X[0]=F.w/e.w,X[1]=F.h/e.h;const se=S(F).map(J=>R.control.viewContainerManager.transformToScenePoint(J,R.viewId)),_=v(se,A);return ee&&(te[1]=_[1]-z[1]),Z&&(te[0]=_[0]-z[0]),{scale:X,translate:te}},L=(A,E)=>{if(I.current&&(clearTimeout(I.current),I.current=0),h!=null&&h.control.worker.isBusy){w(!0);return}if(u!=null&&u.w&&(u!=null&&u.h)&&h){const R={x:u.x,y:u.y,w:u.w,h:u.h},z=S(R),Z=z.map(X=>h.control.viewContainerManager.transformToScenePoint(X,h.viewId)),ee=v(z,E),F=v(Z,E);t(R),o(ee),a(F),l(E),g(V.ScaleNode),ae.emitMethod(ne.MainEngine,V.ScaleNode,{workIds:[G],originPoint:ee,scenePoint:F,workState:j.Start,viewId:h.viewId})}},b=(A,E,R,z)=>{if(!(!h||!s||!n)){if(h!=null&&h.control.worker.isBusy){w(!0),N();return}I.current||(I.current=setTimeout(()=>{I.current=0;const{scale:Z,translate:ee}=x(E,z,h,n);(!O.isEqual(Z,p==null?void 0:p.scale)||!O.isEqual(ee,p==null?void 0:p.translate))&&(f({scale:Z,translate:ee}),g(V.ScaleNode),ae.emitMethod(ne.MainEngine,V.ScaleNode,{workIds:[G],scale:Z,dir:E,translate:ee,originPoint:s,scenePoint:n,workState:j.Doing,viewId:h.viewId}))},60))}},P=()=>{h!=null&&h.control.worker.isBusy&&w(!0),N()};return y.createElement(Ln.Resizable,{className:`${i}`,boundsByDirection:!0,minWidth:-(((u==null?void 0:u.x)||0)+((u==null?void 0:u.w)||0)),minHeight:-(((u==null?void 0:u.y)||0)+((u==null?void 0:u.h)||0)),size:{width:(u==null?void 0:u.w)||0,height:(u==null?void 0:u.h)||0},style:{position:"absolute",left:u==null?void 0:u.x,top:u==null?void 0:u.y,pointerEvents:d?"none":"auto"},enable:m?!1:{top:(u==null?void 0:u.scaleType)===ce.all&&!0||!1,right:(u==null?void 0:u.scaleType)===ce.all&&!0||!1,bottom:(u==null?void 0:u.scaleType)===ce.all&&!0||!1,left:(u==null?void 0:u.scaleType)===ce.all&&!0||!1,topRight:!0,bottomRight:!0,bottomLeft:!0,topLeft:!0},lockAspectRatio:(u==null?void 0:u.scaleType)===ce.proportional,onResizeStart:L,onResize:b,onResizeStop:P})},wo=r=>{const{id:i,pos:e,pointMap:t,type:s}=r,{setOperationType:o,mananger:n,floatBarData:a}=y.useContext(Se),[c,l]=y.useState({x:0,y:0}),[u,h]=y.useState(j.Pending),[d,g]=y.useState(!1),p=y.useRef(0),f=y.useMemo(()=>a?{left:0,top:0}:{},[a]),m=S=>{if(!S||a!=null&&a.isLocked){g(!0),h(j.Pending),o(V.None);return}g(!1)};y.useEffect(()=>(ae.activeListener(m),()=>{ae.unmountActiveListener(m)}),[]),y.useEffect(()=>{O.isNumber(e.x)&&O.isNumber(e.y)&&(u===j.Pending||u===j.Done)&&l({x:e.x,y:e.y})},[e,u]),y.useEffect(()=>{if(a&&(a!=null&&a.isLocked)||n!=null&&n.control.worker.isBusy){g(!0);return}g(!1)},[a,n==null?void 0:n.control.worker.isBusy]);const w=(S,v)=>{p.current&&(clearTimeout(p.current),p.current=0),o(V.None),h(j.Done);const x={x:v.x,y:v.y};if(l(x),n!=null&&n.control.viewContainerManager){const L=n.control.viewContainerManager.transformToScenePoint([x.x,x.y],n.viewId),b=t.get(i);b&&s==="start"?b[0]=L:b&&s==="end"&&(b[1]=L),ae.emitMethod(ne.MainEngine,V.SetPoint,{workId:G,pointMap:t,workState:j.Done,viewId:n==null?void 0:n.viewId})}},I=()=>{if(p.current&&(clearTimeout(p.current),p.current=0),n!=null&&n.control.worker.isBusy){g(!0);return}O.isNumber(e.x)&&O.isNumber(e.y)&&(o(V.SetPoint),h(j.Start),ae.emitMethod(ne.MainEngine,V.SetPoint,{workId:G,pointMap:t,workState:j.Start,viewId:n==null?void 0:n.viewId}))},N=(S,v)=>{if(n!=null&&n.control.worker.isBusy){g(!0),w(S,v);return}if(p.current)return;const x={x:v.x,y:v.y};l(x),p.current=setTimeout(()=>{if(p.current=0,(x.x!==(v==null?void 0:v.x)||x.y!==(v==null?void 0:v.y))&&(n!=null&&n.control.viewContainerManager)){const L=n.control.viewContainerManager.transformToScenePoint([x.x,x.y],n.viewId),b=t.get(i);b&&s==="start"?b[0]=L:b&&s==="end"&&(b[1]=L),h(j.Doing),ae.emitMethod(ne.MainEngine,V.SetPoint,{workId:G,pointMap:t,workState:j.Doing,viewId:n==null?void 0:n.viewId})}},60)},C=(S,v)=>{n!=null&&n.control.worker.isBusy&&g(!0),w(S,v)};return y.createElement(Yt,{disabled:d,position:c,onStart:I,onDrag:N,onStop:C},y.createElement("div",{className:"appliance-plugin-point-draggable-btn",style:f}))},Sw=r=>{const{className:i}=r,{floatBarData:e,mananger:t}=y.useContext(Se),[s,o]=y.useState(),[n,a]=y.useState(),[c,l]=y.useState(new Map);y.useEffect(()=>{const d=[];if(t&&(e!=null&&e.points)){const g=t.viewId;if(t.control.viewContainerManager.getView(g))for(const f of e.points){const m=t.control.viewContainerManager.transformToOriginPoint(f,g);d.push(m)}e!=null&&e.selectIds&&e.selectIds.length===1&&(c.set(e.selectIds[0],e.points),l(c))}d[0]&&o({x:d[0][0],y:d[0][1]}),d[1]&&a({x:d[1][0],y:d[1][1]})},[t,e==null?void 0:e.points,e==null?void 0:e.selectIds,c]);const u=y.useMemo(()=>s&&(e!=null&&e.selectIds)?y.createElement(wo,{pos:s,type:"start",id:e.selectIds[0],pointMap:c}):null,[s,e==null?void 0:e.selectIds,c]),h=y.useMemo(()=>n&&(e!=null&&e.selectIds)?y.createElement(wo,{pos:n,type:"end",id:e.selectIds[0],pointMap:c}):null,[n,e==null?void 0:e.selectIds,c]);return y.createElement("div",{className:`${i}`},u,h)},Cw=y.forwardRef((r,i)=>{const{floatBarData:e,operationType:t}=y.useContext(Se),s=y.useMemo(()=>(e==null?void 0:e.scaleType)!==ce.all||t===V.RotateNode?null:y.createElement(yw,null),[e,t]),o=y.useMemo(()=>(e==null?void 0:e.scaleType)!==ce.both||t===V.RotateNode?null:y.createElement(mw,null),[e,t]),n=y.useMemo(()=>(e==null?void 0:e.scaleType)!==ce.proportional||t===V.RotateNode?null:y.createElement(ww,null),[e,t]),a=y.useMemo(()=>(e==null?void 0:e.scaleType)===ce.none&&(e!=null&&e.canLock)?y.createElement(Iw,null):null,[e]);return y.createElement("div",{ref:i,style:e?{transform:`translate(${e.x}px,${e.y}px)`,width:e.w,height:e.h,pointerEvents:"none"}:void 0},a,s,o,n,r.children)}),kw=y.forwardRef((r,i)=>{const{floatBarData:e,operationType:t,mananger:s}=y.useContext(Se),{editors:o,isHide:n,canSelectorSwitch:a}=r,c=y.useMemo(()=>{var d;return e!=null&&e.canRotate&&((d=e==null?void 0:e.selectIds)==null?void 0:d.length)===1&&(t===V.None||t===V.RotateNode)?y.createElement(Tw,{className:We.RotateBtn}):null},[e,t]),l=y.useMemo(()=>((e==null?void 0:e.scaleType)===ce.all||(e==null?void 0:e.scaleType)===ce.proportional)&&(t===V.None||t===V.ScaleNode)&&O.isNumber(e==null?void 0:e.x)&&O.isNumber(e==null?void 0:e.y)?y.createElement(Nw,{className:We.ResizeBtn}):null,[e==null?void 0:e.scaleType,t,e==null?void 0:e.x,e==null?void 0:e.y]),u=y.useMemo(()=>(e==null?void 0:e.scaleType)===ce.both&&(t===V.None||t===V.SetPoint)?y.createElement(Sw,{className:We.ResizeTowBox}):null,[e==null?void 0:e.scaleType,t]),h=y.useMemo(()=>n&&t===V.None&&O.isNumber(e==null?void 0:e.x)&&O.isNumber(e==null?void 0:e.y)&&O.isNumber(e==null?void 0:e.w)&&O.isNumber(e==null?void 0:e.h)?y.createElement("div",{className:We.FloatBarBtn,style:{left:e==null?void 0:e.x,top:e==null?void 0:e.y,width:e.w,height:e.h}},y.createElement(kn,{position:{x:e.x,y:e.y},textOpt:e==null?void 0:e.textOpt,noLayer:e==null?void 0:e.isLocked})):null,[e==null?void 0:e.x,e==null?void 0:e.y,e==null?void 0:e.w,e==null?void 0:e.h,e==null?void 0:e.textOpt,e==null?void 0:e.isLocked,t,n]);return y.createElement("div",{className:We.FloatBar,onPointerOver:d=>(si(d),s==null||s.control.worker.blurCursor(s.viewId),!1)},y.createElement(Cw,{ref:i}),y.createElement(vw,{editors:o,canSelectorSwitch:a}),c,l,u,h)}),xw=y.memo(kw,(r,i)=>!!O.isEqual(r,i));class Dw extends y.Component{constructor(e){super(e);M(this,"renderAvatar",e=>{var s;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 y.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:(s=e.payload)==null?void 0:s.avatar,alt:"avatar"})}else return null});M(this,"getOpacity",e=>{const t=this.getCursorName(e),s=this.detectAvatar(e);return t===void 0&&s===void 0?0:1});M(this,"getCursorName",e=>{if(e.payload)return e.payload.nickName||e.payload.cursorName||e.payload.uid});M(this,"getThemeClass",e=>e.payload&&e.payload.theme?"cursor-inner-mellow":"cursor-inner");M(this,"getCursorBackgroundColor",e=>{const t=this.getCursorName(e);return e.payload&&e.payload.cursorBackgroundColor?e.payload.cursorBackgroundColor:t?`rgb(${e.memberState.strokeColor[0]}, ${e.memberState.strokeColor[1]}, ${e.memberState.strokeColor[2]})`:void 0});M(this,"getCursorTextColor",e=>e.payload&&e.payload.cursorTextColor?e.payload.cursorTextColor:"#FFFFFF");M(this,"getCursorTagBackgroundColor",e=>e.payload&&e.payload.cursorTagBackgroundColor?e.payload.cursorTagBackgroundColor:this.getCursorBackgroundColor(e));M(this,"detectAvatar",e=>!!(e.payload&&e.payload.avatar));M(this,"renderTag",e=>{if(e.payload&&e.payload.cursorTagName)return y.createElement("span",{className:"cursor-tag-name",style:{backgroundColor:this.getCursorTagBackgroundColor(e)}},e.payload.cursorTagName)})}render(){const{roomMember:e}=this.props,t=this.getCursorName(e);switch(e.memberState.currentApplianceName){case re.pencil:return y.createElement("div",{className:"cursor-box"},y.createElement("div",{className:"cursor-mid cursor-pencil-offset",style:{transform:"translate(-50%, -100%)",marginLeft:"5px",marginTop:"4px"}},y.createElement("div",{className:"cursor-name"},y.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),y.createElement("span",{className:"cursor-name-text"},t),this.renderTag(e))),y.createElement("div",null,y.createElement("img",{className:"cursor-pencil-image",src:$t.get("pencil"),alt:"pencilCursor"}))));case re.selector:return y.createElement("div",{className:"cursor-box"},y.createElement("div",{className:"cursor-mid cursor-selector-offset",style:{transform:"translate(-50%, -100%)",marginLeft:"3px",marginTop:"17px"}},y.createElement("div",{className:"cursor-name"},y.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),y.createElement("span",{className:"cursor-name-text"},t),this.renderTag(e))),y.createElement("div",null,y.createElement("img",{className:"cursor-selector-image",src:$t.get("selector"),alt:"selectorCursor"}))));case re.eraser:case re.pencilEraser:return y.createElement("div",{className:"cursor-box"},y.createElement("div",{className:"cursor-mid cursor-eraser-offset",style:{transform:"translate(-50%, -100%)",marginLeft:"2px",marginTop:"8px"}},y.createElement("div",{className:"cursor-name"},y.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),y.createElement("span",{className:"cursor-name-text"},t),this.renderTag(e))),y.createElement("div",null,y.createElement("img",{className:"cursor-eraser-image",src:$t.get("eraser"),alt:"eraserCursor"}))));case re.text:return y.createElement("div",{className:"cursor-box"},y.createElement("div",{className:"cursor-mid cursor-text-offset",style:{transform:"translate(-50%, -100%)",marginLeft:"0px"}},y.createElement("div",{className:"cursor-name"},y.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),y.createElement("span",{className:"cursor-name-text"},t),this.renderTag(e))),y.createElement("div",null,y.createElement("img",{className:"cursor-text-image",src:$t.get("text"),alt:"textCursor"}))));case re.rectangle:case re.arrow:case re.straight:case re.shape:case re.ellipse:return y.createElement("div",{className:"cursor-box"},y.createElement("div",{className:"cursor-mid cursor-shape-offset",style:{transform:"translate(-50%, -100%)",marginLeft:"-3px",marginTop:"19px"}},y.createElement("div",{className:"cursor-name"},y.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),y.createElement("span",{className:"cursor-name-text"},t),this.renderTag(e))),y.createElement("div",null,y.createElement("img",{className:"cursor-shape-image",src:$t.get("shape"),alt:"shapeCursor"}))));default:return null}}}const Lw=r=>{var o;const{className:i,info:e}=r,{roomMember:t,...s}=e||{};return y.createElement("div",{"data-cursor-uid":(o=t==null?void 0:t.payload)==null?void 0:o.uid,className:`${i}`,style:s?{transform:`translate(${s.x}px, ${s.y}px)`}:{display:"none"}},t&&y.createElement(Dw,{roomMember:t}))},bw=r=>{const{className:i,manager:e}=r,[t,s]=y.useState();y.useEffect(()=>(e.internalMsgEmitter.on([ne.Cursor,e.viewId],o),()=>{e.internalMsgEmitter.off([ne.Cursor,e.viewId],o)}),[e]);function o(a){s(a)}return y.useMemo(()=>{if(t!=null&&t.length){const a=t.map(c=>{var l;return c.roomMember?y.createElement(Lw,{key:(l=c.roomMember)==null?void 0:l.memberId,className:i,info:c}):null});return y.createElement(y.Fragment,null,a)}return null},[t])},jw=r=>{const{viewId:i,miniMapCanvas:e,highlightColor:t,miniMapManager:s,contianer:o}=r,[n,a]=y.useState();y.useEffect(()=>(c(),s.listener.addListener([i,"viewCameraUpate"],c),s.listener.emitAsync([i,"miniMapCreate"],!0),()=>{s.listener.removeListener([i,"viewCameraUpate"],c)}),[]);const c=()=>{const h=s.maps.get(i);h&&l(h.miniMapCamera,h.viewCamera)},l=(h,d)=>{const{width:g,height:p}=o.getBoundingClientRect(),f=Math.min(g/h.width,p/h.height),m=d.width/d.scale,w=d.height/d.scale,I=[d.centerX,d.centerY],N=[h.centerX,h.centerY],C=[I[0]-N[0],I[1]-N[1]],S=Math.min(h.scale*f,h.scale*f),v=[C[0]*S,C[1]*S,m,w,S];a(v)},u=h=>{var d;if(s.control.renderControl.isWritable){const g=h.nativeEvent.target||h.nativeEvent.srcElement;if(g&&h.nativeEvent&&n){const{width:p,height:f}=g.getBoundingClientRect(),[m,w]=[p/2,f/2],[I,N]=[(h.nativeEvent.offsetX-m)/n[4],(h.nativeEvent.offsetY-w)/n[4]],C=s.maps.get(i);if(C!=null&&C.viewCamera){const[S,v]=[C.miniMapCamera.centerX+I,C.miniMapCamera.centerY+N];(d=s.control.room)==null||d.moveCamera({centerX:S,centerY:v,animationMode:"immediately"})}}}};return y.createElement("div",{style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",pointerEvents:"auto"},onClick:u},y.createElement("canvas",{style:{pointerEvents:"none"},ref:e}),n&&y.createElement("div",{className:"minimap-highlightBox",style:{position:"absolute",top:"50%",left:"50%",width:n[2]*n[4],height:n[3]*n[4],boxSizing:"content-box",border:`2px solid ${t}`,transform:`translate(calc(-50% + ${n[0]}px), calc(-50% + ${n[1]}px))`,pointerEvents:"none"}}))},Aw=r=>{const{miniMapManager:i,active:e,className:t}=r,s=y.useMemo(()=>{const o=i.maps;if(e){const n=o.get(e);if(n){const{miniMapCamera:a,viewCamera:c,...l}=n;if(l.contianer&&a&&c){const u=i.highlightColor;return Ti.createPortal(y.createElement(jw,{viewId:e,...l,highlightColor:u,miniMapManager:i}),l.contianer)}}}return null},[e,i]);return y.createElement("div",{className:t},s)},Se=y.createContext({viewId:"",mananger:void 0,floatBarColors:[],floatBarData:void 0,dpr:1,angle:0,operationType:V.None,scale:[1,1],isNoPointerEvents:!1,activeTextEditor:!1,activeTextId:void 0,setAngle:()=>{},setOperationType:()=>{},setFloatBarData:()=>{}});class vs extends y.Component{constructor(e){var s,o,n;super(e);M(this,"showTextFloatBar");M(this,"canSelectorSwitch");M(this,"rightBoundBreak");M(this,"setAngle",e=>{this.setState({angle:e})});M(this,"setOperationType",e=>{this.setState({operationType:e})});this.state={floatBarData:void 0,showFloatBar:!1,showFloatBarBtn:!0,dpr:1,angle:0,operationType:V.None,scale:[1,1],editors:this.editors,activeTextId:(s=this.props.mananger.control.textEditorManager)==null?void 0:s.activeId,activeMiniMapViewId:(o=this.props.mananger.control.miniMapManager)==null?void 0:o.activeViewId};const t=(n=this.props.mananger.control.pluginOptions)==null?void 0:n.textEditor;this.showTextFloatBar=O.isBoolean(t==null?void 0:t.showFloatBar)?t.showFloatBar:Ie.textEditor.showFloatBar,this.canSelectorSwitch=O.isBoolean(t==null?void 0:t.canSelectorSwitch)?t.canSelectorSwitch:Ie.textEditor.canSelectorSwitch,this.rightBoundBreak=O.isBoolean(t==null?void 0:t.rightBoundBreak)?t.rightBoundBreak:Ie.textEditor.rightBoundBreak}get editors(){return Pe(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 s=e&&t&&{...this.state.floatBarData,...t}||void 0;this.setState({showFloatBar:e,floatBarData:s,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,s,o,n,a,c;const e=!!((s=(t=this.props.mananger.control)==null?void 0:t.room)!=null&&s.floatBarOptions);return y.createElement("div",{className:We.Container},!this.props.mananger.control.hasOffscreenCanvas()&&y.createElement("div",{className:We.CanvasBox,ref:this.props.refs.canvasContainerRef})||y.createElement("div",{className:We.CanvasBox},y.createElement("canvas",{id:"bgCanvas",ref:this.props.refs.canvasBgRef,style:{width:"100%",height:"100%"}}),y.createElement("canvas",{id:"serviceCanvas",className:We.FloatCanvas,ref:this.props.refs.canvasServiceFloatRef,style:{width:"100%",height:"100%"}}),y.createElement("canvas",{id:"localCanvas",className:We.FloatCanvas,ref:this.props.refs.canvasFloatRef,style:{width:"100%",height:"100%"}}),y.createElement("div",{id:"subLocalCanvas",className:We.CanvasBoxSub,ref:this.props.refs.subLocalCanvasContainerRef}),y.createElement("canvas",{id:"topCanvas",className:We.TopFloatCanvas,ref:this.props.refs.canvasTopRef,style:{width:"100%",height:"100%"}})),!this.props.mananger.control.hasOffscreenCanvas()&&this.props.refs.snapshotContainerRef&&y.createElement("div",{className:We.SnapshotBox,ref:this.props.refs.snapshotContainerRef})||null,y.createElement(Se.Provider,{value:{viewId:this.props.viewId,mananger:this.props.mananger,floatBarColors:e&&((a=(n=(o=this.props.mananger.control)==null?void 0:o.room)==null?void 0:n.floatBarOptions)==null?void 0:a.colors)||[],isNoPointerEvents:!this.state.showFloatBarBtn,floatBarData:this.state.floatBarData,dpr:this.state.dpr,angle:this.state.angle,operationType:this.state.operationType,scale:this.state.scale,activeTextEditor:this.state.activeTextEditor,activeTextId:this.state.activeTextId,setAngle:this.setAngle.bind(this),setOperationType:this.setOperationType.bind(this),setFloatBarData:this.setFloatBarData.bind(this)}},this.state.showFloatBar&&y.createElement(xw,{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)&&y.createElement(Mw,{className:We.TextEditorContainer,showFloatBtns:this.showTextFloatBar&&e&&this.state.showFloatBarBtn||!1,editors:this.state.editors,rightBoundBreak:this.rightBoundBreak})||null),y.createElement(bw,{className:We.CursorBox,manager:this.props.mananger}),y.createElement(Aw,{className:We.MiniMapBox,active:this.state.activeMiniMapViewId,miniMapManager:this.props.mananger.control.miniMapManager}))}}class Pw extends Sn{constructor(e,t){super(e,t);M(this,"width",1e3);M(this,"height",1e3);M(this,"dpr",ut());M(this,"vDom");M(this,"eventTragetElement");M(this,"snapshotContainerRef");M(this,"canvasContainerRef",y.createRef());M(this,"subLocalCanvasContainerRef",y.createRef());M(this,"canvasTopRef",y.createRef());M(this,"canvasServiceFloatRef",y.createRef());M(this,"canvasFloatRef",y.createRef());M(this,"canvasBgRef",y.createRef());M(this,"floatBarRef",y.createRef());M(this,"containerOffset",{x:0,y:0});this.control.hasOffscreenCanvas()||(this.snapshotContainerRef=y.createRef())}setCanvassStyle(){if(this.eventTragetElement){const e=this.eventTragetElement.offsetWidth||this.width,t=this.eventTragetElement.offsetHeight||this.height;let s=ut();this.canvasBgRef.current&&(s=ut(this.canvasBgRef.current.getContext("2d"))),s!==this.dpr&&(this.dpr=s,this.control.worker.updateDpr(this.viewId,this.dpr)),e&&t&&this.canvasContainerRef.current&&(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.canvasContainerRef.current.style.width=`${e}px`,this.canvasContainerRef.current.style.height=`${t}px`),e&&t&&this.snapshotContainerRef&&this.snapshotContainerRef.current&&(e!==this.width||t!==this.height)&&(this.width=e,this.height=t),e&&t&&this.canvasBgRef.current&&(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.canvasBgRef.current.width=e*this.dpr,this.canvasBgRef.current.height=t*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=e*this.dpr,this.canvasFloatRef.current.height=t*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=e*this.dpr,this.canvasServiceFloatRef.current.height=t*this.dpr),this.canvasTopRef.current&&(this.canvasTopRef.current.width=e*this.dpr,this.canvasTopRef.current.height=t*this.dpr))}}destroy(){if(super.destroy(),this.eventTragetElement){const e=this.eventTragetElement.parentElement;if(e){const t=e.querySelectorAll(".appliance-plugin-main-view-displayer");for(const s of t)s.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(),Ti.render(y.createElement(vs,{viewId:this.viewId,mananger:this,refs:{canvasServiceFloatRef:this.canvasServiceFloatRef,canvasFloatRef:this.canvasFloatRef,canvasBgRef:this.canvasBgRef,floatBarRef:this.floatBarRef,canvasTopRef:this.canvasTopRef,canvasContainerRef:this.canvasContainerRef,snapshotContainerRef:this.snapshotContainerRef,subLocalCanvasContainerRef:this.subLocalCanvasContainerRef}}),t),this.control.room&&this.bindDisplayerEvent(this.eventTragetElement),this}}class zw extends Sm{constructor(e,t,s){super(e,t,s);M(this,"dpr",ut());M(this,"width",1e3);M(this,"height",1e3);M(this,"vDom");M(this,"eventTragetElement");M(this,"canvasContainerRef",y.createRef());M(this,"subLocalCanvasContainerRef",y.createRef());M(this,"canvasTopRef",y.createRef());M(this,"canvasServiceFloatRef",y.createRef());M(this,"canvasFloatRef",y.createRef());M(this,"canvasBgRef",y.createRef());M(this,"floatBarRef",y.createRef());M(this,"containerOffset",{x:0,y:0})}setCanvassStyle(){if(this.eventTragetElement){let e=ut();if(this.canvasBgRef.current&&(e=ut(this.canvasBgRef.current.getContext("2d"))),e!==this.dpr&&(this.dpr=e,this.control.worker.updateDpr(this.viewId,this.dpr)),this.canvasContainerRef.current){const t=this.eventTragetElement.offsetWidth||this.width,s=this.eventTragetElement.offsetHeight||this.height;t&&s&&(t!==this.width||s!==this.height)&&(this.width=t,this.height=s,this.canvasContainerRef.current.style.width=`${t}px`,this.canvasContainerRef.current.style.height=`${s}px`)}if(this.canvasBgRef.current){const t=this.eventTragetElement.offsetWidth||this.width,s=this.eventTragetElement.offsetHeight||this.height;t&&s&&(t!==this.width||s!==this.height)&&(this.width=t,this.height=s,this.canvasBgRef.current.width=t*this.dpr,this.canvasBgRef.current.height=s*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=t*this.dpr,this.canvasFloatRef.current.height=s*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=t*this.dpr,this.canvasServiceFloatRef.current.height=s*this.dpr),this.canvasTopRef.current&&(this.canvasTopRef.current.width=t*this.dpr,this.canvasTopRef.current.height=s*this.dpr))}}}createAppViewDisplayer(e,t){const s=document.createElement("div");return s.className="appliance-plugin-app-view-displayer",t.appendChild(s),this.eventTragetElement=t.children[0],this.containerOffset=this.getContainerOffset(this.eventTragetElement,this.containerOffset),this.bindToolsClass(),Ti.render(y.createElement(vs,{viewId:e,mananger:this,refs:{canvasServiceFloatRef:this.canvasServiceFloatRef,canvasFloatRef:this.canvasFloatRef,canvasBgRef:this.canvasBgRef,floatBarRef:this.floatBarRef,canvasTopRef:this.canvasTopRef,canvasContainerRef:this.canvasContainerRef,subLocalCanvasContainerRef:this.subLocalCanvasContainerRef}}),s),this.control.room&&this.bindDisplayerEvent(this.eventTragetElement),this}}class Xe extends Wt{constructor(e){super(e);M(this,"focuedViewId");M(this,"focuedView");M(this,"control");M(this,"tmpFocusedViewId");M(this,"checkScaleTimer");M(this,"onMainViewRelease",async e=>{this.control.textEditorManager.clear(ge,!0),this.mainViewDestroy(e),await new Promise(s=>{setTimeout(()=>{s(!0)},0)}),this.onMainViewMounted(e);const t=this.control.getSnapshootData("memberState");this.control.room&&this.control.onMemberChange(t),this.control.clearSnapshootData()});M(this,"mainViewDestroy",e=>{var t;if(this.mainView&&this.mainView.displayer){this.mainView.displayer.destroy();const s=e.divElement;if(s){const o=s.getElementsByClassName("appliance-plugin-main-view-displayer");for(const n of o)n.remove()}if(this.mainView.container&&s!==this.mainView.container){const o=this.mainView.container.getElementsByClassName("appliance-plugin-main-view-displayer");for(const n of o)n.remove()}(t=this.control.worker)==null||t.destroyViewWorker(this.mainView.id,!0),this.mainView.displayer.destroy(),this.mainView=void 0}});M(this,"onMainViewMounted",e=>{const t=e.divElement;if(!t||!e.focusScenePath||!(e.focusScenePath||e.scenePath))return;const o=new Pw(this.control,be.InternalMsgEmitter),n=e.size.width||o.width,a=e.size.height||o.height,l={dpr:o.dpr,originalPoint:[n/2,a/2],offscreenCanvasOpt:{...Xe.defaultScreenCanvasOpt,width:n,height:a},layerOpt:{...Xe.defaultLayerOpt,width:n,height:a},cameraOpt:{...Xe.defaultCameraOpt,width:n,height:a}},{scale:u,...h}=e.camera;l.cameraOpt={...l.cameraOpt,...h,scale:u===1/0?1:u},this.createMianView({id:ge,container:t,displayer:o,focusScenePath:e.focusScenePath,cameraOpt:l.cameraOpt,viewData:e}),this.setFocuedViewId(ge),o.createMainViewDisplayer(t),e.callbacks.on("onSizeUpdated",this.onMainViewSizeUpdated),e.callbacks.on("onCameraUpdated",this.onMainViewCameraUpdated),e.callbacks.on("onActiveHotkey",this.onActiveHotkeyChange.bind(this))});M(this,"onMainViewSizeUpdated",async()=>{await new Promise(e=>{setTimeout(()=>{e(!0)},0)}),this.mainView&&this.mainView.viewData&&this.updateMainViewCamera()});M(this,"onMainViewCameraUpdated",async()=>{await new Promise(e=>{setTimeout(()=>{e(!0)},0)}),this.updateMainViewCamera()});M(this,"updateMainViewCamera",()=>{if(this.mainView&&this.mainView.viewData){const e=this.mainView.viewData.camera,t=this.mainView.cameraOpt;if(t){const s=t.width,o=t.height,{width:n,height:a}=this.mainView.viewData.size;(n!==s||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:n,height:a};O.isEqual(t,h)||(this.mainView.cameraOpt=h),this.checkScaleTimer&&e.scale==1/0&&(clearTimeout(this.checkScaleTimer),this.checkScaleTimer=void 0),!this.checkScaleTimer&&e.scale===1/0&&this.mainView.viewData&&this.mainView.viewData.camera.scale===1/0&&(this.checkScaleTimer=setTimeout(()=>{var d,g;(g=(d=this.mainView)==null?void 0:d.viewData)==null||g.moveCamera({scale:c,centerX:l,centerY:u,animationMode:"immediately"}),this.checkScaleTimer=void 0},500))}}});M(this,"onAppViewMounted",async e=>{var d;const{appId:t,view:s}=e,o=s.divElement;if(!o||!s.focusScenePath)return;const n=this.appViews.get(t);if(n&&n.displayer){let g=o.getElementsByClassName("appliance-plugin-app-view-displayer");for(const p of g)p.remove();if(n.container&&n.container!==o){g=n.container.getElementsByClassName("appliance-plugin-app-view-displayer");for(const p of g)p.remove()}this.destroyAppView(e.appId,!0),(d=this.control.worker)==null||d.destroyViewWorker(t,!0),await new Promise(p=>{setTimeout(()=>{p(!0)},0)})}const a=new zw(t,this.control,be.InternalMsgEmitter),c=s.size.width||a.width,l=s.size.height||a.height,h={dpr:a.dpr,originalPoint:[c/2,l/2],offscreenCanvasOpt:{...Xe.defaultScreenCanvasOpt,width:c,height:l},layerOpt:{...Xe.defaultLayerOpt,width:c,height:l},cameraOpt:{...Xe.defaultCameraOpt,...s.camera,width:c,height:l}};if(this.createAppView({id:t,container:o,displayer:a,cameraOpt:h.cameraOpt,focusScenePath:s.focusScenePath,viewData:s}),a.createAppViewDisplayer(t,o),s.callbacks.on("onSizeUpdated",this.onAppViewSizeUpdated.bind(this,t)),s.callbacks.on("onCameraUpdated",this.onAppViewCameraUpdated.bind(this,t)),s.callbacks.on("onActiveHotkey",this.onActiveHotkeyChange.bind(this)),this.tmpFocusedViewId===t){const g=this.control.worker.getLocalWorkViewId();g&&g!==t?this.setFocuedViewId(g):this.setFocuedViewId(t),this.tmpFocusedViewId=void 0}setTimeout(()=>{this.onAppViewCameraUpdated(t)},0)});M(this,"onAppViewSizeUpdated",async e=>{await new Promise(s=>{setTimeout(()=>{s(!0)},0)});const t=this.appViews.get(e);t&&t.viewData&&this.updateAppCamera(e)});M(this,"onAppViewCameraUpdated",async e=>{await new Promise(t=>{setTimeout(()=>{t(!0)},0)}),this.updateAppCamera(e)});M(this,"updateAppCamera",e=>{const t=this.appViews.get(e);if(t&&t.viewData){const s=t.viewData.camera,o=t.cameraOpt;if(o){const{width:n,height:a}=t.viewData.size,c=o.width,l=o.height;(n!==c||a!==l)&&t.displayer.updateSize();const u=s.scale===1/0?1:s.scale,h=s.centerX||0,d=s.centerY||0,g={...o,scale:u,centerX:h,centerY:d,width:n,height:a};O.isEqual(g,o)||(t.cameraOpt=g)}}});this.control=e.control}getViewInitData(e){var s;const t=this.getView(e);if(t){const{width:o,height:n,dpr:a}=t.displayer;(s=this.control.pluginOptions.canvasOpt)!=null&&s.contextType&&(Xe.defaultScreenCanvasOpt.contextType=this.control.pluginOptions.canvasOpt.contextType);const c={dpr:a,originalPoint:[o/2,n/2],offscreenCanvasOpt:{...Xe.defaultScreenCanvasOpt,width:o,height:n},layerOpt:{...Xe.defaultLayerOpt,width:o,height:n},cameraOpt:{...Xe.defaultCameraOpt,width:o,height:n}};if(t.viewData){const{scale:l,...u}=t.viewData.camera;c.cameraOpt={...c.cameraOpt,...u,scale:l===1/0?1:l}}return c}}async mountView(e){var s,o;const t=this.getView(e);if(t){e===((s=this.mainView)==null?void 0:s.id)&&(this.control.cursor.activeCollector(),await this.control.activeWorker());const n=this.getViewInitData(e);if(n&&((o=this.control.worker)==null||o.createViewWorker(e,n)),t.focusScenePath&&this.control.collector){if(this.control.collector.authStorage){const{renderAuth:a,pageAuth:c}=this.control.collector.authStorage;if(a){const l=a[e];if(l){const{render:u,hide:h,clear:d}=l;this.control.renderControl.syncRenderUids(e,u,h,d);return}}if(c){const l=c[e];if(l){this.control.renderControl.syncPageAuth(e,l,!0);return}}}this.control.worker.pullServiceData(e,t.focusScenePath,{isAsync:!0,useAnimation:!1})}}}listenerWindowManager(e){e.emitter.on("focusedChange",t=>{const s=t||ge;if(this.focuedViewId!==s)if(this.getView(s)){const n=this.control.worker.getLocalWorkViewId();n&&n!==s?this.setFocuedViewId(n):this.setFocuedViewId(s)}else this.tmpFocusedViewId=s}),e.emitter.on("mainViewScenePathChange",t=>{this.control.onSceneChange(t,ge)}),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:s,view:o}=t;this.control.onSceneChange(o.focusScenePath,s)}),e.emitter.on("appsChange",t=>{for(const s of this.appViews.keys())t.includes(s)||(this.destroyAppView(s),this.control.worker.destroyViewWorker(s,!0))})}onActiveHotkeyChange(e){this.control.hotkeyManager.onActiveHotkey(e)}}class pt extends be{constructor(e){super(e);M(this,"windowManager");M(this,"viewContainerManager");const t={control:this,internalMsgEmitter:be.InternalMsgEmitter,publicMsgEmitter:be.PublicMsgEmitter};this.viewContainerManager=new Xe(t)}init(){}activePlugin(){this.collector&&(this.collector.addAuthStateListener((e,t)=>{e&&Object.keys(e).forEach(s=>{var n;const o=(n=e[s])==null?void 0:n.newValue;this.renderControl.syncRenderUids(s,o==null?void 0:o.render,o==null?void 0:o.hide,o==null?void 0:o.clear)}),t&&Object.keys(t).forEach(s=>{var n;const o=(n=t[s])==null?void 0:n.newValue;this.renderControl.syncPageAuth(s,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(ge,!0);return}const{diffView:t,diffScenePath:s,diffData:o}=e,n=new Map;if(t){let l;Object.keys(t).forEach(u=>{var d;const h=t[u];if(h&&!h.newValue)(d=this.worker)==null||d.clearViewScenePath(u,!0),h.oldValue&&(l=h.oldValue);else if(h&&h.newValue){for(const g of Object.keys(h.newValue))this.worker.pullServiceData(u,g,{isAsync:!1,useAnimation:!1});l=h.newValue}if(l)for(const g of Object.values(l)){const p=new Set;for(const f of Object.keys(g))f&&p.add(f);n.set(u,p)}})}if(s){let l;Object.keys(s).forEach(u=>{var d;const h=s[u];if(h&&h.viewId&&!h.newValue?((d=this.worker)==null||d.clearViewScenePath(h.viewId,!0),h.oldValue&&(l=h.oldValue)):h&&h.viewId&&h.newValue&&(this.worker.pullServiceData(h.viewId,u,{isAsync:!1,useAnimation:!1}),l=h.newValue),h!=null&&h.viewId&&l){const g=new Set;for(const p of Object.keys(l))p&&g.add(p),n.set(h.viewId,g)}})}o&&Object.keys(o).forEach(l=>{var h,d;const u=o[l];if(u){const{viewId:g}=u,p=n.get(g)||new Set;p.add(l),n.set(g,p),(h=this.worker)==null||h.onServiceDerive(l,u),(d=this.miniMapManager)==null||d.updateMiniMapCamera(g)}});for(const[l,u]of n.entries())be.InternalMsgEmitter.emit("excludeIds",[...u],l)}),this.worker.isActive&&this.viewContainerManager.getAllViews().forEach(e=>{e&&e.focusScenePath&&this.worker.pullServiceData(e.id,e.focusScenePath,{isAsync:!0,useAnimation:!1})}),this.room&&this.roomMember.onUidChangeHook(e=>{var t,s;(t=this.collector)!=null&&t.serviceStorage&&this.viewContainerManager.getAllViews().forEach(o=>{var n,a,c,l;if(o&&o.focusScenePath&&((n=this.collector)!=null&&n.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 d=(a=this.collector)==null?void 0:a.getUidFromKey(h);if(d&&!e.online.includes(d))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 g=this.textEditorManager.editors.get(h);g&&g.opt&&(g.opt.workState===j.Doing||g.opt.workState===j.Start)&&(g.opt.text&&g.opt.text.replace(/\s*,/g,"")?this.textEditorManager.unActive(h):this.textEditorManager.delete(h))}}}}),(s=this.cursor)==null||s.updateRoomMembers(e)}))}async activeWorker(){await this.worker.init()}setWindowManager(e){var t,s,o,n,a;this.windowManager=e,(s=(t=this.windowManager)==null?void 0:t.mainView)!=null&&s.divElement&&this.viewContainerManager.onMainViewMounted(this.windowManager.mainView),(a=(n=(o=this.windowManager.appManager)==null?void 0:o.viewManager)==null?void 0:n.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 Y=class Y extends $.InvisiblePlugin{constructor(){super(...arguments);M(this,"onPhaseChanged",e=>{var t;e===$.RoomPhase.Reconnecting&&((t=Y.currentManager)==null||t.setSnapshootData())});M(this,"updateRoomWritable",()=>{var e;(e=Y.currentManager)==null||e.onWritableChange(this.displayer.isWritable)});M(this,"roomStateChangeListener",async e=>{var t,s;e!=null&&e.roomMembers&&((t=Y.currentManager)==null||t.onRoomMembersChange(e.roomMembers)),!($.isRoom(this.displayer)&&!this.displayer.isWritable)&&e.memberState&&((s=Y.currentManager)==null||s.onMemberChange(e.memberState))})}static async getInstance(e,t){t.options&&(t.options.cdn.useWorker!=="mainThread"&&!t.options.cdn.fullWorkerUrl&&!t.options.cdn.subWorkerUrl&&Y.logger.error("[ApplianceMultiPlugin] you must adaptor options cdn fullWorkerUrl and subWorkerUrl"),Y.options={...Ie,...t.options});const s=e.displayer,o=s.callbacks.on,n=s.callbacks.off,a=s.callbacks.once,c=e.cleanCurrentScene,l=e.mainView.setMemberState;let u;$.isRoom(s)&&(u=s.setWritable),t!=null&&t.logger&&(Y.logger=t.logger);let h=s.getInvisiblePlugin(Y.kind);h||(h=await Y.createApplianceMultiPlugin(s,Y.kind)),s&&h&&Y.createCurrentManager(e,Y.options,h),h&&Y.currentManager&&(Y.currentManager.bindPlugin(h),h.init(s));const d={displayer:s,windowManager:e,currentManager:Y.currentManager,maxScreenshotWidth:10*1024,maxScreenshotHeight:10*1024,getBoundingRectAsync:async function(p){var w;Y.logger.info("[ApplianceMultiPlugin] getBoundingRectAsync");const f=(e.mainView||s).getBoundingRect(p),m=await((w=Y.currentManager)==null?void 0:w.getBoundingRect(p));return!f.width||!f.height?m:ys(f,m)},screenshotToCanvasAsync:async function(p,f,m,w,I,N){var b;Y.logger.info("[ApplianceMultiPlugin] screenshotToCanvasAsync");let C=m,S=w,v=I.scale;C>this.maxScreenshotWidth&&(v=this.maxScreenshotWidth/C*v,C=this.maxScreenshotWidth),S>this.maxScreenshotHeight&&(v=Math.min(this.maxScreenshotHeight/S*v,v),S=this.maxScreenshotHeight),I.scale=v;const x=document.createElement("canvas"),L=x.getContext("2d");x.width=C*(N||1),x.height=S*(N||1),L&&((e.mainView||s).screenshotToCanvas(L,f,C,S,I,N),p.drawImage(x,Math.floor((m-C)/2),Math.floor((w-S)/2),C*(N||1),S*(N||1),0,0,C,S),x.remove()),Y.currentManager&&await((b=Y.currentManager)==null?void 0:b.screenshotToCanvas(p,f,C,S,I,Math.floor((m-C)/2),Math.floor((w-S)/2)))},scenePreviewAsync:async function(p,f,m,w,I){Y.logger.info("[ApplianceMultiPlugin] scenePreviewAsync"),(e.mainView||s).scenePreview(p,f,m,w,I);const N=document.createElement("img");N.className="appliance-plugin-fill-scene-snapshot-img",f.append(N),getComputedStyle(f).position||(f.style.position="relative"),Y.currentManager&&await Y.currentManager.scenePreview(p,N)},fillSceneSnapshotAsync:async function(p,f,m,w,I){Y.logger.info("[ApplianceMultiPlugin] fillSceneSnapshotAsync"),f.innerHTML="",(e.mainView||s).fillSceneSnapshot(p,f,m,w,I);const N=m||e.mainView.size.width,C=w||e.mainView.size.height;let S=await this.getBoundingRectAsync(p);S||(S={originX:0,originY:0,width:N,height:C});let v=Math.max(S==null?void 0:S.width,N),x=Math.max(S==null?void 0:S.height,C),L=1;const b=v>N&&Math.min(N/v,L)||L,P=x>C&&Math.min(C/x,L)||L;b<=P?(v=b<1&&N||v,x=Math.floor(x*b)+1,L=b):b>P&&(x=P<1&&C||x,v=Math.floor(v*P)+1,L=P);const A={scale:L,centerX:S.originX+S.width/2,centerY:S.originY+S.height/2},E=document.createElement("canvas"),R=E.getContext("2d");E.width=v,E.height=x,R&&await this.screenshotToCanvasAsync(R,p,v,x,A,devicePixelRatio);const z=document.createElement("img");z.className="appliance-plugin-fill-scene-snapshot-img",z.src=E.toDataURL(),z.onload=()=>{E.remove()},z.onerror=()=>{E.remove(),z.remove()},f.append(z),getComputedStyle(f).position||(f.style.position="relative")},_callbacksOn:function(p,f){Y.logger.info(`[ApplianceMultiPlugin] callbacks ${p}`),(p==="onCanUndoStepsUpdate"||p==="onCanRedoStepsUpdate")&&$.isRoom(s)&&s.isWritable?pt.InternalMsgEmitter.on(p,f):o.call(s.callbacks,p,f)},_callbacksOnce:function(p,f){Y.logger.info(`[ApplianceMultiPlugin] callbacks ${p}`),(p==="onCanUndoStepsUpdate"||p==="onCanRedoStepsUpdate")&&$.isRoom(s)&&s.isWritable?pt.InternalMsgEmitter.on(p,f):a.call(s.callbacks,p,f)},_callbacksOff:function(p,f){Y.logger.info(`[ApplianceMultiPlugin] callbacks ${p}`),(p==="onCanUndoStepsUpdate"||p==="onCanRedoStepsUpdate")&&$.isRoom(s)&&s.isWritable?pt.InternalMsgEmitter.off(p,f):n.call(s.callbacks,p,f)},canRedoSteps(){if(Y.logger.info("[ApplianceMultiPlugin] canRedoSteps"),Y.currentManager&&$.isRoom(s)&&!s.disableSerialization){const p=Y.currentManager.viewContainerManager.focuedView,f=p==null?void 0:p.focusScenePath;if(p&&f)return p.displayer.commiter.redoStack.filter(m=>m.scenePath===f).length}return 0},canUndoSteps(){if(Y.logger.info("[ApplianceMultiPlugin] canUndoSteps"),Y.currentManager&&$.isRoom(s)&&!s.disableSerialization){const p=Y.currentManager.viewContainerManager.focuedView,f=p==null?void 0:p.focusScenePath;if(p&&f)return p.displayer.commiter.undoStack.filter(m=>m.scenePath===f).length}return 0},undo:function(){return Y.logger.info("[ApplianceMultiPlugin] undo"),Y.currentManager&&$.isRoom(s)&&!s.disableSerialization?Y.currentManager.viewContainerManager.undo():0},redo:function(){return Y.logger.info("[ApplianceMultiPlugin] redo"),Y.currentManager&&$.isRoom(s)&&!s.disableSerialization?Y.currentManager.viewContainerManager.redo():0},cleanCurrentScene:function(){Y.logger.info("[ApplianceMultiPlugin] cleanCurrentScene"),Y.currentManager&&$.isRoom(s)&&s.isWritable&&(Y.currentManager.cleanCurrentScene(),c.call(e))},insertImage:function(p){if(Y.logger.info("[ApplianceMultiPlugin] insertImage"),Y.currentManager&&$.isRoom(s)&&s.isWritable){const f=Y.currentManager.viewContainerManager.focuedViewId||ge;Y.currentManager.worker.insertImage(f,p)}},lockImage:function(p,f){if(Y.logger.info("[ApplianceMultiPlugin] lockImage"),Y.currentManager&&$.isRoom(s)&&s.isWritable){const m=Y.currentManager.viewContainerManager.focuedViewId||ge;Y.currentManager.worker.lockImage(m,p,f)}},completeImageUpload:function(p,f){if(Y.logger.info("[ApplianceMultiPlugin] completeImageUpload"),Y.currentManager&&$.isRoom(s)&&s.isWritable){const m=Y.currentManager.viewContainerManager.focuedViewId||ge;Y.currentManager.worker.completeImageUpload(m,p,f)}},getImagesInformation:function(p){return Y.logger.info("[ApplianceMultiPlugin] completeImageUpload"),Y.currentManager&&$.isRoom(s)&&s.isWritable?Y.currentManager.worker.getImagesInformation(p):[]},insertText:function(p,f,m){if(Y.logger.info("[ApplianceMultiPlugin] insertText"),Y.currentManager&&$.isRoom(s)&&s.isWritable){const w=Y.currentManager.viewContainerManager.focuedViewId||ge;return Y.currentManager.textEditorManager.insertText(w,p,f,m)}},updateText:function(p,f){Y.logger.info("[ApplianceMultiPlugin] updateText"),Y.currentManager&&$.isRoom(s)&&s.isWritable&&Y.currentManager.textEditorManager.updateText(p,f)},callbacks:()=>(Y.logger.info("[ApplianceMultiPlugin] callbacks bind"),{...s.callbacks,on:d._callbacksOn.bind(d),once:d._callbacksOnce.bind(d),off:d._callbacksOff.bind(d)}),destroy(){Y.currentManager&&(Y.logger.info("[ApplianceMultiPlugin] destroy"),Y.currentManager.destroy(),Y.currentManager=void 0)},setMemberState(p){Y.logger.info(`[ApplianceMultiPlugin] setMemberState ${JSON.stringify(p)}`);const f=Object.keys(p);if($.isRoom(s)&&s.isWritable){f.includes("currentApplianceName")&&(p.currentApplianceName&&p.currentApplianceName===re.laserPen?(p.currentApplianceName=re.pencil,p.useLaserPen=!0):p.currentApplianceName&&p.currentApplianceName===re.pencil&&(p.useLaserPen=!1)),l.call(e.mainView,p);return}throw new Error("[ApplianceMultiPlugin] setMemberState must be called in writable room")},setPerformancePriority(p){Y.logger.info("[ApplianceMultiPlugin] setPriority"),Y.currentManager&&Y.currentManager.setPriority(p)},createMiniMap:async function(p,f){if(Y.logger.info("[ApplianceMultiPlugin] createMiniMap"),Y.currentManager&&$.isRoom(s)&&s.isWritable)return Y.currentManager.createMiniMap(p,f)},destroyMiniMap:async function(p){if(Y.logger.info("[ApplianceMultiPlugin] destroyeMiniMap"),Y.currentManager&&$.isRoom(s)&&s.isWritable)return Y.currentManager.destroyMiniMap(p)},filterRenderByUid(p,f,m){if(Y.logger.info("[ApplianceMultiPlugin] filterRenderByUid"),Y.currentManager&&$.isRoom(s)&&s.isWritable)return Y.currentManager.filterRenderByUid(p,f,m)},cancelFilterRender(p,f){if(Y.logger.info("[ApplianceMultiPlugin] filterRenderByUid"),Y.currentManager&&$.isRoom(s)&&s.isWritable)return Y.currentManager.cancelFilterRender(p,f)},addListener:(p,f)=>{Y.logger.info(`[ApplianceMultiPlugin] addListener ${p}`),pt.PublicMsgEmitter.on(p,f)},removeListener:(p,f)=>{Y.logger.info(`[ApplianceMultiPlugin] removeListener ${p}`),pt.PublicMsgEmitter.off(p,f)},usePlugin:p=>{var f;Y.logger.info("[ApplianceMultiPlugin] usePlugin",p.kind),(f=Y.currentManager)==null||f.usePlugin(p)},getDisableDeviceInputs(){if(Y.currentManager&&$.isRoom(s))return Y.currentManager.disableDeviceInputs},setDisableDeviceInputs(p){Y.logger.info(`[ApplianceMultiPlugin] setDisableDeviceInputs ${p}`),Y.currentManager&&$.isRoom(s)&&(Y.currentManager.disableDeviceInputs=p)},getDisableCameraTransform(){if(Y.currentManager&&$.isRoom(s))return Y.currentManager.disableCameraTransform},setDisableCameraTransform(p){Y.logger.info(`[ApplianceMultiPlugin] setDisableCameraTransform ${p}`),Y.currentManager&&$.isRoom(s)&&(Y.currentManager.disableCameraTransform=p)},getDisableEraseImage(){if(Y.currentManager&&$.isRoom(s))return Y.currentManager.disableEraseImage},setDisableEraseImage(p){Y.logger.info(`[ApplianceMultiPlugin] setDisableEraseImage ${p}`),Y.currentManager&&$.isRoom(s)&&(Y.currentManager.disableEraseImage=p)},setWritable:async function(p){var f;Y.logger.info(`[ApplianceMultiPlugin] setWritable ${p}`),$.isRoom(s)&&u&&(await((f=Y.currentManager)==null?void 0:f.setWritable(p)),await u.call(s,p))},requestIdleCallback:(p,f)=>{const m=(f==null?void 0:f.timeout)||0,w=performance.now();let I;const N=new MessageChannel;let C;const S=v=>{try{p({didTimeout:v,timeRemaining:()=>{const L=performance.now()-w;return Math.max(0,m-L)}})}catch(x){Y.logger.error("[ApplianceMultiPlugin] requestIdleCallback error:",x)}finally{N.port1.close(),N.port2.close(),I!==void 0&&cancelAnimationFrame(I),C!==void 0&&clearTimeout(C)}};return N.port1.onmessage=()=>{I=requestAnimationFrame(()=>{m>0&&performance.now()-w>=m?S(!0):S(!1)})},N.port2.postMessage(null),m>0&&(C=setTimeout(()=>{S(!0)},m)),C||I||0},cancelIdleCallback:p=>{try{clearTimeout(p),cancelAnimationFrame(p)}catch(f){Y.logger.error("[ApplianceMultiPlugin] cancelIdleCallback error:",f)}},injectMethodToObject:(p,f)=>{if(Y.logger.info(`[ApplianceMultiPlugin] injectMethodToObject ${f}`),typeof p[f]=="function"||typeof p[f]>"u"){p[f]=d[f];return}f==="callbacks"&&(p.callbacks.on=d._callbacksOn.bind(d),p.callbacks.off=d._callbacksOff.bind(d),p.callbacks.once=d._callbacksOnce.bind(d))}};d.injectMethodToObject(e,"undo"),d.injectMethodToObject(e,"redo"),d.injectMethodToObject(e,"cleanCurrentScene"),d.injectMethodToObject(e,"insertImage"),d.injectMethodToObject(e,"completeImageUpload"),d.injectMethodToObject(e,"lockImage"),d.injectMethodToObject(e,"insertText"),d.injectMethodToObject(e,"updateText"),d.injectMethodToObject(s,"getImagesInformation"),d.injectMethodToObject(s,"callbacks"),d.injectMethodToObject(s,"screenshotToCanvasAsync"),d.injectMethodToObject(s,"getBoundingRectAsync"),d.injectMethodToObject(s,"scenePreviewAsync"),d.injectMethodToObject(s,"fillSceneSnapshotAsync"),d.injectMethodToObject(e.mainView,"setMemberState"),$.isRoom(s)&&d.injectMethodToObject(s,"setWritable"),Object.defineProperty(e,"canUndoSteps",{get(){return d.canUndoSteps()}}),Object.defineProperty(e,"canRedoSteps",{get(){return d.canRedoSteps()}}),pt.InternalMsgEmitter.on("onCanUndoStepsUpdate",p=>{e.emitter.emit("canUndoStepsChange",p)}),pt.InternalMsgEmitter.on("onCanRedoStepsUpdate",p=>{e.emitter.emit("canRedoStepsChange",p)});const g={...d,callbacks:d.callbacks()};return Object.defineProperty(g,"disableDeviceInputs",{set(p){d.setDisableDeviceInputs(p)},get(){return d.getDisableDeviceInputs()}}),Object.defineProperty(g,"disableCameraTransform",{set(p){d.setDisableCameraTransform(p)},get(){return d.getDisableCameraTransform()}}),Object.defineProperty(g,"disableEraseImage",{set(p){d.setDisableEraseImage(p)},get(){return d.getDisableEraseImage()}}),e._appliancePlugin=g,e._appliancePlugin}static onCreate(e){e&&Y.currentManager&&(Y.currentManager.bindPlugin(e),e.init(e.displayer))}static async createApplianceMultiPlugin(e,t){try{await e.createInvisiblePlugin(Y,{})}catch{if(!e.isWritable){await e.setWritable(!0);const n=await this.createApplianceMultiPlugin(e,t);return await e.setWritable(!1),n}}let s=e.getInvisiblePlugin(t);return s||(s=await Y.createApplianceMultiPlugin(e,t)),s}get isReplay(){return $.isPlayer(this.displayer)}get callbackName(){return this.isReplay?"onPlayerStateChanged":"onRoomStateChanged"}init(e){var s,o;const t=e.state;(s=Y.currentManager)==null||s.onRoomMembersChange(t.roomMembers),$.isRoom(e)&&((o=Y.currentManager)==null||o.onMemberChange(t.memberState)),this.displayer.callbacks.on(this.callbackName,this.roomStateChangeListener),this.displayer.callbacks.on("onEnableWriteNowChanged",this.updateRoomWritable),this.displayer.callbacks.on("onPhaseChanged",this.onPhaseChanged)}destroy(){var e;Y.logger.info("[ApplianceMultiPlugin] passive destroy"),(e=Y.currentManager)==null||e.destroy(),Y.currentManager=void 0}};M(Y,"kind","appliance-multi-plugin"),M(Y,"currentManager"),M(Y,"logger",{info:console.log,warn:console.warn,error:console.error}),M(Y,"options",Ie),M(Y,"createCurrentManager",(e,t,s)=>{Y.currentManager&&Y.currentManager.destroy();const o={plugin:s,displayer:e.displayer,options:t},n=new pt(o);if(Y.logger.info("[ApplianceMultiPlugin] refresh ApplianceMultiManager object"),n.setWindowManager(e),Y.currentManager=n,e.room){const a=n.hasOffscreenCanvas();e.room.logger.info(`[ApplianceMultiPlugin] use ${a?"worker":"mainThread"}`)}});let qi=Y;class Ew extends Sn{constructor(e,t){super(e,t);M(this,"width",1e3);M(this,"height",1e3);M(this,"dpr",ut());M(this,"vDom");M(this,"viewId",ge);M(this,"eventTragetElement");M(this,"snapshotContainerRef");M(this,"canvasContainerRef",y.createRef());M(this,"subLocalCanvasContainerRef",y.createRef());M(this,"canvasTopRef",y.createRef());M(this,"canvasServiceFloatRef",y.createRef());M(this,"canvasFloatRef",y.createRef());M(this,"canvasBgRef",y.createRef());M(this,"floatBarRef",y.createRef());M(this,"containerOffset",{x:0,y:0});this.control.hasOffscreenCanvas()||(this.snapshotContainerRef=y.createRef())}setCanvassStyle(){if(this.eventTragetElement){const e=this.eventTragetElement.offsetWidth,t=this.eventTragetElement.offsetHeight;let s=ut();this.canvasBgRef.current&&(s=ut(this.canvasBgRef.current.getContext("2d"))),s!==this.dpr&&(this.dpr=s,this.control.worker.updateDpr(this.viewId,this.dpr)),e&&t&&this.canvasContainerRef.current&&(e!==this.width||t!==this.height)&&(this.width=e,this.height=t),e&&t&&this.canvasBgRef.current&&(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.canvasBgRef.current.width=e*this.dpr,this.canvasBgRef.current.height=t*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=e*this.dpr,this.canvasFloatRef.current.height=t*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=e*this.dpr,this.canvasServiceFloatRef.current.height=t*this.dpr),this.canvasTopRef.current&&(this.canvasTopRef.current.width=e*this.dpr,this.canvasTopRef.current.height=t*this.dpr))}}createMainViewDisplayer(e){return this.vDom||(this.containerOffset=this.getContainerOffset(e,this.containerOffset),this.eventTragetElement=e.parentElement.children[0],e.innerHTML="",Ti.render(y.createElement(vs,{viewId:this.viewId,mananger:this,refs:{canvasServiceFloatRef:this.canvasServiceFloatRef,canvasFloatRef:this.canvasFloatRef,canvasBgRef:this.canvasBgRef,floatBarRef:this.floatBarRef,canvasTopRef:this.canvasTopRef,canvasContainerRef:this.canvasContainerRef,snapshotContainerRef:this.snapshotContainerRef,subLocalCanvasContainerRef:this.subLocalCanvasContainerRef}}),e),this.control.room&&this.bindDisplayerEvent(this.eventTragetElement)),this}}class ct extends Wt{constructor(e){super(e);M(this,"focuedViewId");M(this,"control");M(this,"focuedView");this.control=e.control}bindMainView(){if(!this.control.divMainView)return;const e=new Ew(this.control,be.InternalMsgEmitter),{width:t,height:s,dpr:o}=e,n={dpr:o,originalPoint:[t/2,s/2],offscreenCanvasOpt:{...ct.defaultScreenCanvasOpt,width:t,height:s},layerOpt:{...ct.defaultLayerOpt,width:t,height:s},cameraOpt:{...ct.defaultCameraOpt,width:t,height:s}},a=this.control.room&&this.control.room.mainView||this.control.play&&this.control.play.mainView;if(a){const{scale:c,...l}=a.camera;n.cameraOpt={...n.cameraOpt,...l,scale:c===1/0?1:c},this.createMianView({id:ge,displayer:e,focusScenePath:a.focusScenePath||a.scenePath,cameraOpt:n.cameraOpt,viewData:a}),this.setFocuedViewId(ge),e.createMainViewDisplayer(this.control.divMainView)}}getViewInitData(e){var s;const t=this.getView(e);if(t){const{width:o,height:n,dpr:a}=t.displayer;(s=this.control.pluginOptions.canvasOpt)!=null&&s.contextType&&(ct.defaultScreenCanvasOpt.contextType=this.control.pluginOptions.canvasOpt.contextType);const c={dpr:a,originalPoint:[o/2,n/2],offscreenCanvasOpt:{...ct.defaultScreenCanvasOpt,width:o,height:n},layerOpt:{...ct.defaultLayerOpt,width:o,height:n},cameraOpt:{...ct.defaultCameraOpt,width:o,height:n}};if(t.viewData){const{scale:l,...u}=t.viewData.camera;c.cameraOpt={...c.cameraOpt,...u,scale:l===1/0?1:l}}return c}}async mountView(e){var s;const t=this.getView(e);if(t){this.control.worker.isActive||(this.control.cursor.activeCollector(),await this.control.activeWorker());const o=this.getViewInitData(e);o&&((s=this.control.worker)==null||s.createViewWorker(e,o)),t.focusScenePath&&this.control.collector&&this.control.worker.pullServiceData(e,t.focusScenePath,{isAsync:!0,useAnimation:!1})}}}class Je extends be{constructor(e){super(e);M(this,"viewContainerManager");M(this,"divMainView");M(this,"onCameraChange",vn(e=>{var s;const t=this.viewContainerManager.mainView;t&&t.cameraOpt&&(t.cameraOpt.width!==e.width||t.cameraOpt.height!==e.height)&&((s=this.viewContainerManager.mainView)==null||s.displayer.updateSize()),this.viewContainerManager.setFocuedViewCameraOpt(e)},Ms,{leading:!1}));const t={control:this,internalMsgEmitter:Je.InternalMsgEmitter,publicMsgEmitter:Je.PublicMsgEmitter};this.viewContainerManager=new ct(t)}init(){Je.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(ge,!0);return}const{diffView:t,diffScenePath:s,diffData:o}=e,n=new Map;if(t){let l;Object.keys(t).forEach(u=>{var d;const h=t[u];if(h&&!h.newValue)(d=this.worker)==null||d.clearViewScenePath(u,!0),h.oldValue&&(l=h.oldValue);else if(h&&h.newValue){for(const g of Object.keys(h.newValue))this.worker.pullServiceData(u,g,{isAsync:!1,useAnimation:!0});l=h.newValue}if(l)for(const g of Object.values(l)){const p=new Set;for(const f of Object.keys(g))f&&p.add(f);n.set(u,p)}})}if(s){let l;Object.keys(s).forEach(u=>{var d;const h=s[u];if(h&&h.viewId&&!h.newValue?((d=this.worker)==null||d.clearViewScenePath(h.viewId,!0),h.oldValue&&(l=h.oldValue)):h&&h.viewId&&h.newValue&&(this.worker.pullServiceData(h.viewId,u,{isAsync:!1,useAnimation:!0}),l=h.newValue),h!=null&&h.viewId&&l){const g=new Set;for(const p of Object.keys(l))p&&g.add(p),n.set(h.viewId,g)}})}o&&Object.keys(o).forEach(l=>{var h,d;const u=o[l];if(u){const{viewId:g}=u,p=n.get(g)||new Set;p.add(l),n.set(g,p),(h=this.worker)==null||h.onServiceDerive(l,u),(d=this.miniMapManager)==null||d.updateMiniMapCamera(g)}});for(const[l,u]of n.entries())be.InternalMsgEmitter.emit("excludeIds",[...u],l)}),this.room&&(this.roomMember.onUidChangeHook(e=>{var t;(t=this.collector)!=null&&t.serviceStorage&&this.viewContainerManager.getAllViews().forEach(s=>{var o,n,a,c,l,u;if(s&&s.focusScenePath&&((o=this.collector)!=null&&o.serviceStorage[s.id])&&((n=this.collector)!=null&&n.serviceStorage[s.id][s.focusScenePath])){const h=Object.keys((a=this.collector)==null?void 0:a.serviceStorage[s.id][s.focusScenePath]);for(const d of h){const g=(c=this.collector)==null?void 0:c.getUidFromKey(d);if(g&&!e.online.includes(g))if((l=this.collector)!=null&&l.isSelector(d))this.renderControl.isWritable&&((u=this.collector)==null||u.updateValue(d,void 0,{viewId:s.id,scenePath:s.focusScenePath,isSync:!0})),this.worker.blurSelector(s.id,s.focusScenePath,d);else{const p=this.textEditorManager.editors.get(d);p&&p.opt&&(p.opt.workState===j.Doing||p.opt.workState===j.Start)&&(p.opt.text&&p.opt.text.replace(/\s*,/g,"")?this.textEditorManager.unActive(d):this.textEditorManager.delete(d))}}}})}),this.worker.isActive&&this.viewContainerManager.getAllViews().forEach(e=>{e&&e.focusScenePath&&this.worker.pullServiceData(e.id,e.focusScenePath,{isAsync:!0,useAnimation:!1})})))}async activeWorker(){await this.worker.init()}}const W=class W extends $.InvisiblePlugin{constructor(){super(...arguments);M(this,"onPhaseChanged",e=>{var t;e===$.RoomPhase.Reconnecting&&((t=W.currentManager)==null||t.setSnapshootData())});M(this,"updateRoomWritable",()=>{var e;(e=W.currentManager)==null||e.onWritableChange(this.displayer.isWritable)});M(this,"roomStateChangeListener",async e=>{var t,s;W.currentManager instanceof Je&&(e.cameraState&&W.currentManager.onCameraChange(e.cameraState),e.sceneState&&W.currentManager.onSceneChange(e.sceneState.scenePath,ge)),e!=null&&e.roomMembers&&((t=W.currentManager)==null||t.onRoomMembersChange(e.roomMembers)),!($.isRoom(this.displayer)&&!this.displayer.isWritable)&&e.memberState&&((s=W.currentManager)==null||s.onMemberChange(e.memberState))})}static async getInstance(e,t){t.options&&(t.options.cdn.useWorker!=="mainThread"&&!t.options.cdn.fullWorkerUrl&&!t.options.cdn.subWorkerUrl&&W.logger.error("[ApplianceSinglePlugin] you must adaptor options cdn fullWorkerUrl and subWorkerUrl"),W.options={...Ie,...t.options});const s=e.callbacks.on,o=e.callbacks.off,n=e.callbacks.once,a=e.cleanCurrentScene.bind(e),c=e.setMemberState.bind(e);let l;$.isRoom(e)&&(l=e.setWritable),t!=null&&t.logger&&(W.logger=t.logger);let u=e.getInvisiblePlugin(W.kind);u||(u=await W.createAppliancePlugin(e,W.kind)),e&&u&&W.createCurrentManager(e,W.options,u),u&&W.currentManager&&(W.currentManager.bindPlugin(u),u.init(e)),t!=null&&t.cursorAdapter&&(W.cursorAdapter=t.cursorAdapter),W.effectInstance();const h={displayer:e,currentManager:W.currentManager,maxScreenshotWidth:10*1024,maxScreenshotHeight:10*1024,_injectTargetObject:void 0,getBoundingRectAsync:async function(g){var m;W.logger.info("[ApplianceSinglePlugin] getBoundingRectAsync");const p=e.getBoundingRect(g),f=await((m=W.currentManager)==null?void 0:m.getBoundingRect(g));return!p.width||!p.height?f:ys(p,f)},screenshotToCanvasAsync:async function(g,p,f,m,w,I){var L;W.logger.info("[ApplianceSinglePlugin] screenshotToCanvasAsync");let N=f,C=m,S=w.scale;N>this.maxScreenshotWidth&&(S=this.maxScreenshotWidth/N*S,N=this.maxScreenshotWidth),C>this.maxScreenshotHeight&&(S=Math.min(this.maxScreenshotHeight/C*S,S),C=this.maxScreenshotHeight),w.scale=S;const v=document.createElement("canvas"),x=v.getContext("2d");v.width=N*(I||1),v.height=C*(I||1),x&&(e.screenshotToCanvas(x,p,N,C,w,I),g.drawImage(v,Math.floor((f-N)/2),Math.floor((m-C)/2),N*(I||1),C*(I||1),0,0,N,C),v.remove()),W.currentManager&&await((L=W.currentManager)==null?void 0:L.screenshotToCanvas(g,p,N,C,w,Math.floor((f-N)/2),Math.floor((m-C)/2)))},scenePreviewAsync:async function(g,p,f,m,w){W.logger.info("[ApplianceSinglePlugin] scenePreviewAsync"),e.scenePreview(g,p,f,m,w);const I=document.createElement("img");I.className="appliance-plugin-fill-scene-snapshot-img",p.append(I),getComputedStyle(p).position||(p.style.position="relative"),W.currentManager&&await W.currentManager.scenePreview(g,I)},fillSceneSnapshotAsync:async function(g,p,f,m,w){var z,Z;W.logger.info("[ApplianceSinglePlugin] fillSceneSnapshotAsync"),p.innerHTML="",e.fillSceneSnapshot(g,p,f,m,w);const I=f||((z=e.state.cameraState)==null?void 0:z.width)||0,N=m||((Z=e.state.cameraState)==null?void 0:Z.height)||0;let C=await this.getBoundingRectAsync(g);C||(C={originX:0,originY:0,width:I,height:N});let S=Math.max(C==null?void 0:C.width,I),v=Math.max(C==null?void 0:C.height,N),x=1;const L=S>I&&Math.min(I/S,x)||x,b=v>N&&Math.min(N/v,x)||x;L<=b?(S=L<1&&I||S,v=Math.floor(v*L)+1,x=L):L>b&&(v=b<1&&N||v,S=Math.floor(S*b)+1,x=b);const P={scale:x,centerX:C.originX+C.width/2,centerY:C.originY+C.height/2},A=document.createElement("canvas"),E=A.getContext("2d");A.width=S,A.height=v,E&&await this.screenshotToCanvasAsync(E,g,S,v,P,devicePixelRatio);const R=document.createElement("img");R.className="appliance-plugin-fill-scene-snapshot-img",R.src=A.toDataURL(),R.onload=()=>{A.remove()},R.onerror=()=>{A.remove(),R.remove()},p.append(R),getComputedStyle(p).position||(p.style.position="relative")},_callbacksOn:function(g,p){W.logger.info(`[ApplianceSinglePlugin] callbacks ${g}`),(g==="onCanUndoStepsUpdate"||g==="onCanRedoStepsUpdate")&&$.isRoom(e)&&e.isWritable?Je.InternalMsgEmitter.on(g,p):s.call(e.callbacks,g,p)},_callbacksOnce:function(g,p){W.logger.info(`[ApplianceSinglePlugin] callbacks ${g}`),(g==="onCanUndoStepsUpdate"||g==="onCanRedoStepsUpdate")&&$.isRoom(e)&&e.isWritable?Je.InternalMsgEmitter.on(g,p):n.call(e.callbacks,g,p)},_callbacksOff:function(g,p){W.logger.info(`[ApplianceSinglePlugin] callbacks ${g}`),(g==="onCanUndoStepsUpdate"||g==="onCanRedoStepsUpdate")&&$.isRoom(e)&&e.isWritable?Je.InternalMsgEmitter.off(g,p):o.call(e.callbacks,g,p)},canRedoSteps(){if(W.logger.info("[ApplianceSinglePlugin] canRedoSteps"),W.currentManager&&$.isRoom(e)&&!e.disableSerialization){const g=W.currentManager.viewContainerManager.focuedView,p=g==null?void 0:g.focusScenePath;if(g&&p)return g.displayer.commiter.redoStack.filter(f=>f.scenePath===p).length}return 0},canUndoSteps(){if(W.logger.info("[ApplianceSinglePlugin] canUndoSteps"),W.currentManager&&$.isRoom(e)&&!e.disableSerialization){const g=W.currentManager.viewContainerManager.focuedView,p=g==null?void 0:g.focusScenePath;if(g&&p)return g.displayer.commiter.undoStack.filter(f=>f.scenePath===p).length}return 0},undo:function(){return W.logger.info("[ApplianceSinglePlugin] undo"),W.currentManager&&$.isRoom(e)&&!e.disableSerialization?W.currentManager.viewContainerManager.undo():0},redo:function(){return W.logger.info("[ApplianceSinglePlugin] redo"),W.currentManager&&$.isRoom(e)&&!e.disableSerialization?W.currentManager.viewContainerManager.redo():0},cleanCurrentScene:function(g){W.logger.info("[ApplianceSinglePlugin] cleanCurrentScene"),W.currentManager&&$.isRoom(e)&&e.isWritable&&(W.currentManager.cleanCurrentScene(),a.call(e,g))},insertImage:function(g){W.logger.info("[ApplianceSinglePlugin] insertImage"),W.currentManager&&$.isRoom(e)&&e.isWritable&&W.currentManager.worker.insertImage(ge,g)},lockImage:function(g,p){W.logger.info("[ApplianceSinglePlugin] lockImage"),W.currentManager&&$.isRoom(e)&&e.isWritable&&W.currentManager.worker.lockImage(ge,g,p)},completeImageUpload:function(g,p){W.logger.info("[ApplianceSinglePlugin] completeImageUpload"),W.currentManager&&$.isRoom(e)&&e.isWritable&&W.currentManager.worker.completeImageUpload(ge,g,p)},getImagesInformation:function(g){return W.logger.info("[ApplianceSinglePlugin] completeImageUpload"),W.currentManager&&$.isRoom(e)&&e.isWritable?W.currentManager.worker.getImagesInformation(g):[]},insertText:function(g,p,f){if(W.logger.info("[ApplianceSinglePlugin] insertText"),W.currentManager&&$.isRoom(e)&&e.isWritable)return W.currentManager.textEditorManager.insertText(ge,g,p,f)},updateText:function(g,p){W.logger.info("[ApplianceMultiPlugin] updateText"),W.currentManager&&$.isRoom(e)&&e.isWritable&&W.currentManager.textEditorManager.updateText(g,p)},callbacks:()=>({...e.callbacks,on:h._callbacksOn.bind(h),once:h._callbacksOnce.bind(h),off:h._callbacksOff.bind(h)}),destroy(){W.currentManager&&(W.logger.info("[ApplianceSinglePlugin] destroy"),W.currentManager.destroy(),W.currentManager=void 0,W.cursorAdapter=void 0)},setMemberState(g){W.logger.info(`[ApplianceSinglePlugin] setMemberState ${JSON.stringify(g)}`);const p=Object.keys(g);if($.isRoom(e)&&e.isWritable){p.includes("currentApplianceName")&&(g.currentApplianceName&&g.currentApplianceName===re.laserPen?(g.currentApplianceName=re.pencil,g.useLaserPen=!0):g.currentApplianceName&&g.currentApplianceName===re.pencil&&(g.useLaserPen=!1)),c(g);return}throw new Error("setMemberState must be called in writable room")},setPerformancePriority(g){W.logger.info("[ApplianceSinglePlugin] setPriority"),W.currentManager&&W.currentManager.setPriority(g)},createMiniMap:async function(g,p){if(W.logger.info("[ApplianceSinglePlugin] createMiniMap"),W.currentManager&&$.isRoom(e)&&e.isWritable)return W.currentManager.createMiniMap(g,p)},destroyMiniMap:async function(g){if(W.logger.info("[ApplianceMultiPlugin] destroyeMiniMap"),W.currentManager&&$.isRoom(e)&&e.isWritable)return W.currentManager.destroyMiniMap(g)},filterRenderByUid(g,p,f){if(W.logger.info("[ApplianceSinglePlugin] filterRenderByUid"),W.currentManager&&$.isRoom(e)&&e.isWritable)return W.currentManager.filterRenderByUid(g,p,f)},cancelFilterRender(g,p){if(W.logger.info("[ApplianceSinglePlugin] filterRenderByUid"),W.currentManager&&$.isRoom(e)&&e.isWritable)return W.currentManager.cancelFilterRender(g,p)},addListener:(g,p)=>{W.logger.info(`[ApplianceSinglePlugin] addListener ${g}`),Je.PublicMsgEmitter.on(g,p)},removeListener:(g,p)=>{W.logger.info(`[ApplianceSinglePlugin] removeListener ${g}`),Je.PublicMsgEmitter.off(g,p)},usePlugin:g=>{var p;W.logger.info("[ApplianceSinglePlugin] usePlugin",g.kind),(p=W.currentManager)==null||p.usePlugin(g)},getDisableDeviceInputs(){if(W.currentManager&&$.isRoom(e))return W.currentManager.disableDeviceInputs},setDisableDeviceInputs(g){W.logger.info(`[ApplianceSinglePlugin] setDisableDeviceInputs ${g}`),W.currentManager&&$.isRoom(e)&&(W.currentManager.disableDeviceInputs=g)},getDisableCameraTransform(){if(W.currentManager&&$.isRoom(e))return W.currentManager.disableCameraTransform},setDisableCameraTransform(g){W.logger.info(`[ApplianceSinglePlugin] setDisableCameraTransform ${g}`),W.currentManager&&$.isRoom(e)&&(W.currentManager.disableCameraTransform=g)},getDisableEraseImage(){if(W.currentManager&&$.isRoom(e))return W.currentManager.disableEraseImage},setDisableEraseImage(g){W.logger.info(`[ApplianceSinglePlugin] setDisableEraseImage ${g}`),W.currentManager&&$.isRoom(e)&&(W.currentManager.disableEraseImage=g)},setWritable:async function(g){var p;W.logger.info(`[ApplianceSinglePlugin] setWritable ${g}`),$.isRoom(e)&&l&&(await((p=W.currentManager)==null?void 0:p.setWritable(g)),await l.call(e,g))},requestIdleCallback:(g,p)=>{const f=(p==null?void 0:p.timeout)||0,m=performance.now();let w;const I=new MessageChannel;let N;const C=S=>{try{g({didTimeout:S,timeRemaining:()=>{const x=performance.now()-m;return Math.max(0,f-x)}})}catch(v){W.logger.error("[ApplianceSinglePlugin] requestIdleCallback error:",v)}finally{I.port1.close(),I.port2.close(),w!==void 0&&cancelAnimationFrame(w),N!==void 0&&clearTimeout(N)}};return I.port1.onmessage=()=>{w=requestAnimationFrame(()=>{f>0&&performance.now()-m>=f?C(!0):C(!1)})},I.port2.postMessage(null),f>0&&(N=setTimeout(()=>{C(!0)},f)),N||w||0},cancelIdleCallback:g=>{try{clearTimeout(g),cancelAnimationFrame(g)}catch(p){W.logger.error("[ApplianceSinglePlugin] cancelIdleCallback error:",p)}},injectMethodToObject:(g,p)=>{if(W.logger.info(`[ApplianceSinglePlugin] injectMethodToObject ${p}`),typeof g[p]=="function"||typeof g[p]>"u"){g[p]=h[p];return}p==="callbacks"&&(g.callbacks.on=h._callbacksOn.bind(h),g.callbacks.off=h._callbacksOff.bind(h),g.callbacks.once=h._callbacksOnce.bind(h))}};h.injectMethodToObject(e,"undo"),h.injectMethodToObject(e,"redo"),h.injectMethodToObject(e,"cleanCurrentScene"),h.injectMethodToObject(e,"insertImage"),h.injectMethodToObject(e,"completeImageUpload"),h.injectMethodToObject(e,"lockImage"),h.injectMethodToObject(e,"getImagesInformation"),h.injectMethodToObject(e,"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"),$.isRoom(e)&&h.injectMethodToObject(e,"setWritable"),Object.defineProperty(e,"canUndoSteps",{get(){return h.canUndoSteps()}}),Object.defineProperty(e,"canRedoSteps",{get(){return h.canRedoSteps()}});const d={...h,callbacks:h.callbacks()};return Object.defineProperty(d,"disableDeviceInputs",{set(g){h.setDisableDeviceInputs(g)},get(){return h.getDisableDeviceInputs()}}),Object.defineProperty(d,"disableEraseImage",{set(g){h.setDisableEraseImage(g)},get(){return h.getDisableEraseImage()}}),Object.defineProperty(d,"disableCameraTransform",{set(g){h.setDisableCameraTransform(g)},get(){return h.getDisableCameraTransform()}}),e._appliancePlugin=d,e._appliancePlugin}static onCreate(e){e&&W.currentManager&&(W.currentManager.bindPlugin(e),e.init(e.displayer))}static async createAppliancePlugin(e,t){try{await e.createInvisiblePlugin(W,{})}catch{if(!e.isWritable){await e.setWritable(!0);const n=await this.createAppliancePlugin(e,t);return await e.setWritable(!1),n}}let s=e.getInvisiblePlugin(t);return s||(s=await W.createAppliancePlugin(e,t)),s}static effectInstance(){if(W.cursorAdapter){const e=W.cursorAdapter.onAddedCursor;W.cursorAdapter.onAddedCursor=function(t){t.onCursorMemberChanged=s=>{try{s.appliance===re.pencil||s.appliance===re.shape||s.appliance===re.text||s.appliance===re.arrow||s.appliance===re.straight||s.appliance===re.rectangle||s.appliance===re.ellipse||s.appliance===re.eraser||s.appliance===re.selector?t!=null&&t.divElement&&(t.divElement.style.display="none"):t!=null&&t.divElement&&(t.divElement.style.display="block")}catch{}},e.call(W.cursorAdapter,t)}}}get isReplay(){return $.isPlayer(this.displayer)}get callbackName(){return this.isReplay?"onPlayerStateChanged":"onRoomStateChanged"}init(e){var s,o;const t=e.state;(s=W.currentManager)==null||s.onRoomMembersChange(t.roomMembers),$.isRoom(e)&&t!=null&&t.memberState&&((o=W.currentManager)==null||o.onMemberChange(t.memberState)),this.displayer.callbacks.on(this.callbackName,this.roomStateChangeListener),this.displayer.callbacks.on("onEnableWriteNowChanged",this.updateRoomWritable),this.displayer.callbacks.on("onPhaseChanged",this.onPhaseChanged)}destroy(){var e;W.logger.info("[ApplianceSinglePlugin] passive destroy"),(e=W.currentManager)==null||e.destroy(),W.currentManager=void 0,W.cursorAdapter=void 0}};M(W,"kind","appliance-aids-single-plugin"),M(W,"cursorAdapter"),M(W,"currentManager"),M(W,"logger",{info:console.log,warn:console.warn,error:console.error}),M(W,"options",Ie),M(W,"createCurrentManager",(e,t,s)=>{W.currentManager&&W.currentManager.destroy();const o={plugin:s,displayer:e,options:t},n=new Je(o);if(n.init(),W.logger.info("[ApplianceSinglePlugin] refresh ApplianceSingleManager object"),W.currentManager=n,$.isRoom(e)){const a=n.hasOffscreenCanvas();e.logger.info(`[ApplianceSinglePlugin] use ${a?"worker":"mainThread"}`)}});let Ki=W;const Rt=class Rt extends y.Component{constructor(){super(...arguments);M(this,"mainViewRef",null)}componentDidMount(){Rt.emiter||(Rt.emiter=Je.InternalMsgEmitter),Rt.emiter.emit(ne.BindMainView,this.mainViewRef)}render(){return y.createElement(y.Fragment,null,this.props.children,y.createElement("div",{className:"appliance-plugin-main-view-displayer",ref:e=>this.mainViewRef=e}))}};M(Rt,"emiter");let _i=Rt;class Ow extends Nn{constructor(e){super();M(this,"kind","autoDraw");M(this,"localStorage",[]);M(this,"excludeStorage",[]);M(this,"timer");M(this,"hostServer");M(this,"iconsContainer");M(this,"icons",[]);M(this,"iconRect");M(this,"isActive",!1);M(this,"viewId",ge);M(this,"scenePath");M(this,"delay",2e3);const{container:t,hostServer:s,delay:o}=e;this.hostServer=s,this.iconsContainer=t,this.delay=o||2e3}get collector(){return this.control.collector}onDestroy(){this.unMount()}onCreate(){}onSetToolkey(e){e===T.Pencil?this.isActive=!0:(this.isActive&&(this.localStorage.length=0,this.timer&&clearTimeout(this.timer),this.timer=void 0,this.iconRect&&(this.iconRect=void 0),this.icons.length=0),this.isActive=!1)}syncStorage(e,t){if(!this.isActive||e!==this.viewId)return;if(!t){this.localStorage.length=0;return}const s=this.getOwnStorage(this.viewId,t);this.localStorage=s.map(o=>{var n;return((n=this.collector)==null?void 0:n.getLocalId(o))||o})}getOwnStorage(e,t){var n,a;if(!e||!t)return[];const s=(a=(n=this.collector)==null?void 0:n.storage[e])==null?void 0:a[t];return s?Object.keys(s).filter(c=>{var l,u;return((l=this.collector)==null?void 0:l.isOwn(c))&&((u=s[c])==null?void 0:u.toolsType)===T.Pencil&&!this.excludeStorage.includes(c)}):[]}async batchLocalDraw(){var a;if(this.localStorage.length===0||!this.scenePath||!((a=this.collector)==null?void 0:a.getStorageData(this.viewId,this.scenePath)))return;const t=this.localStorage.toString(),s=await this.control.worker.getVNodeInfo(this.localStorage.toString(),this.viewId,this.localStorage);if(!s)return;const{vInfo:o,uuid:n}=s;if(n===t&&o){const c={rect:{centerX:0,centerY:0,width:0,height:0},ink:[]};let l;const u=[];for(const{rect:h,op:d}of o){l=ue(l,h);const g=[],p=[];for(let f=0;f<d.length;f+=3){g.push(d[f]),p.push(d[f+1]);const m=u.length&&u[u.length-1]||0;f===0?u.length===0?u.push(0):u.push(m+100):u.push(m+15)}c.ink.push([g,p,u])}return l&&(c.rect.centerX=Math.floor(l.x+l.w/2),c.rect.centerY=Math.floor(l.y+l.h/2),c.rect.width=Math.floor(l.w),c.rect.height=Math.floor(l.h)),c}}async computAutoDraw(e){const{rect:t,ink:s}=e;this.iconRect=t;const o=await fetch(this.hostServer,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({width:t.width,height:t.height,ink:s})}).then(n=>n.json()).then(n=>n.data);this.icons=o||[]}buildHTML(){var s;this.iconsContainer.innerHTML="";const e=document.createElement("div");e.style.display="flex",e.style.overflow="auto",e.style.padding="10px 0";const t=((s=this.control.worker.currentToolsData)==null?void 0:s.toolsOpt.strokeColor)||"#7f7f7f";this.icons.forEach(o=>{const n=document.createElement("img");n.src=`https://api.iconify.design/${o}.svg?color=${t}`,n.onclick=()=>{this.onClickIcon(o)},n.onload=()=>{e.appendChild(n)}}),this.iconsContainer.appendChild(e)}onClickIcon(e){var t,s;if(this.iconRect){const o=this.control.viewContainerManager.transformToScenePoint([this.iconRect.centerX,this.iconRect.centerY],this.viewId),n=((s=(t=this.control.viewContainerManager.getView(this.viewId))==null?void 0:t.cameraOpt)==null?void 0:s.scale)||1;this.icons.length=0,this.iconsContainer.innerHTML="";const a=Date.now().toString();this.control.worker.removeNodes(this.viewId,this.localStorage),this.localStorage.length=0,this.control.insertIconify(this.viewId,{uuid:a,centerX:o[0],centerY:o[1],width:Math.floor(this.iconRect.width/n),height:Math.floor(this.iconRect.height/n),src:`https://api.iconify.design/${e}.svg`,uniformScale:!1,locked:!1}),this.iconRect=void 0}}sceneChange(e,t){e===this.viewId&&(this.scenePath=t,this.excludeStorage=this.getOwnStorage(e,t)),this.localStorage.length=0}localEvent(e,t){var s;if(e===this.viewId&&((s=this.control.worker.currentToolsData)==null?void 0:s.toolsType)===T.Pencil)switch(t){case j.Start:this.timer&&(clearTimeout(this.timer),this.timer=void 0);break;case j.Done:this.timer&&clearTimeout(this.timer),this.timer=setTimeout(async()=>{this.timer=void 0;const o=await this.batchLocalDraw();o&&(await this.computAutoDraw(o),this.buildHTML())},this.delay);break}}mount(){var t,s;this.scenePath=(t=this.control.viewContainerManager.getView(this.viewId))==null?void 0:t.focusScenePath,this.excludeStorage=this.getOwnStorage(this.viewId,this.scenePath);const e=(s=this.control.worker.currentToolsData)==null?void 0:s.toolsType;e&&this.onSetToolkey(e),this.callbacks("setToolkey",this.onSetToolkey.bind(this)),this.callbacks("syncStorage",this.syncStorage.bind(this)),this.callbacks("sceneChange",this.sceneChange.bind(this)),this.callbacks("localEvent",this.localEvent.bind(this))}unMount(){this.timer&&clearTimeout(this.timer),this.timer=void 0,this.iconRect&&(this.iconRect=void 0),this.icons.length=0,this.excludeStorage.length=0,this.localStorage.length=0,this.iconsContainer.innerHTML="",this.removeCallback("setToolkey"),this.removeCallback("syncStorage"),this.removeCallback("sceneChange"),this.removeCallback("localEvent")}}exports.ActiveContainerType=To;exports.ApplianceMultiPlugin=qi;exports.ApplianceNames=re;exports.ApplianceSigleWrapper=_i;exports.ApplianceSinglePlugin=Ki;exports.AutoDrawPlugin=Ow;exports.Cursor_Hover_Id=vf;exports.DefaultAppliancePluginOptions=Ie;exports.ECanvasShowType=me;exports.EDataType=B;exports.EForceStopReason=vi;exports.EImageType=St;exports.EMatrixrRelationType=Nt;exports.EOperationType=Ye;exports.EPostMessageType=D;exports.ERenderFilterType=et;exports.EScaleType=ce;exports.EStrokeType=oe;exports.EToolsKey=T;exports.ElayerType=qt;exports.EmitEventType=V;exports.EventMessageType=Jt;exports.EvevtWorkState=j;exports.EvevtWorkType=vo;exports.InternalMsgEmitterType=ne;exports.Main_View_Id=ge;exports.Plugin=Nn;exports.ShapeType=Ke;exports.Storage_Selector_key=G;exports.Storage_Splitter=He;exports.Storage_ViewId_ALL=ci;exports.Task_Time_Interval=Ms;exports.VNodeManager=pn;exports.ViewContainerManager=Wt;exports.computRect=ue;exports.fullWorker=bn;exports.getRectMatrixrRelation=Is;exports.getShapeInstance=ji;exports.isEqual=lt;exports.isIntersectForPoint=In;exports.isNumber=ze;exports.removeAllChildren=Ve;exports.removeTexture=Ge;exports.subWorker=jn;exports.transformToNormalData=Dt;exports.transformToSerializableData=Be;