@netless/appliance-plugin 1.1.40 → 1.1.41

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 (40) hide show
  1. package/README.md +31 -0
  2. package/dist/appliance-plugin.js +1 -1
  3. package/dist/appliance-plugin.mjs +1 -1
  4. package/dist/{bridge-b23MKtwT.mjs → bridge-BNKS_R2l.mjs} +1 -1
  5. package/dist/{bridge-DLEmhE7Y.js → bridge-BxkfdTkq.js} +1 -1
  6. package/dist/bridge.js +1 -1
  7. package/dist/bridge.mjs +1 -1
  8. package/dist/component/backgroundImageLoadCoordinator.d.ts +61 -0
  9. package/dist/component/svg/base.d.ts +2 -0
  10. package/dist/component/svg/svgElemt.d.ts +3 -1
  11. package/dist/component/svg/types.d.ts +2 -0
  12. package/dist/core/currentSceneGuard.d.ts +6 -0
  13. package/dist/core/initReadyBarrier.d.ts +8 -0
  14. package/dist/core/mainEngine.d.ts +4 -2
  15. package/dist/core/mainThread/base.d.ts +3 -3
  16. package/dist/core/mainThread/snapshotThread.d.ts +3 -3
  17. package/dist/core/mainThread/subLocalThread.d.ts +1 -1
  18. package/dist/core/mainThread/subServiceThread.d.ts +1 -1
  19. package/dist/fullWorker.js +18 -18
  20. package/dist/{index-WifS74pI.mjs → index-Bellzj9L.mjs} +234 -210
  21. package/dist/{index-CDDMgpaL.js → index-BoGQFZPO.js} +1 -1
  22. package/dist/index-BpI4eSla.js +1 -0
  23. package/dist/{index-BSR23bx5.mjs → index-BwKNcV3h.mjs} +1 -1
  24. package/dist/{index-CDbcv4B7.js → index-C4uTXXaR.js} +1 -1
  25. package/dist/{index-rhSRO8Tb.mjs → index-COQOIflN.mjs} +11433 -11139
  26. package/dist/index-DjDB-MYx.js +570 -0
  27. package/dist/{index-C3XOupI-.mjs → index-Doaj3rDL.mjs} +1 -1
  28. package/dist/index-DrGUJkFH.js +570 -0
  29. package/dist/index-SwxjyKCD.js +1 -0
  30. package/dist/{index-GpA_9BZu.mjs → index-WMF2MmW5.mjs} +11464 -11165
  31. package/dist/{index-pyv2KvXa.mjs → index-z4Oul31S.mjs} +221 -201
  32. package/dist/plugin/backgroundImageQuery.d.ts +4 -0
  33. package/dist/plugin/baseApplianceManager.d.ts +4 -0
  34. package/dist/plugin/types.d.ts +26 -1
  35. package/dist/subWorker.js +17 -17
  36. package/package.json +8 -4
  37. package/dist/index-DKaa5HSe.js +0 -1
  38. package/dist/index-DoIyQYzA.js +0 -570
  39. package/dist/index-DwW4gzgA.js +0 -1
  40. package/dist/index-RKd-OVPO.js +0 -570
@@ -0,0 +1,570 @@
1
+ "use strict";var K0=Object.defineProperty;var q0=(i,t,e)=>t in i?K0(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var R=(i,t,e)=>q0(i,typeof t!="symbol"?t+"":t,e);const ip=require("./bridge-BxkfdTkq.js"),Tt=require("clipper-lib"),sp=require("lz-string"),wu=require("lineclip"),Sl=require("xss"),ve=require("lodash"),X0=require("rbush"),Il=require("eventemitter2"),G=require("react"),Sa=require("react-dom"),Bi=require("react-draggable"),J0=require("re-resizable");var Ne=(i=>(i.selector="selector",i.clicker="clicker",i.laserPointer="laserPointer",i.pencil="pencil",i.rectangle="rectangle",i.ellipse="ellipse",i.shape="shape",i.eraser="eraser",i.pencilEraser="pencilEraser",i.text="text",i.straight="straight",i.arrow="arrow",i.hand="hand",i.laserPen="laserPen",i))(Ne||{}),mr=(i=>(i[i.OffscreenTransfer=1]="OffscreenTransfer",i[i.ImageBitmap=2]="ImageBitmap",i))(mr||{}),Qn=(i=>(i[i.WebGL=1]="WebGL",i))(Qn||{}),Tu=(i=>(i[i.SingleChannelTexture=1]="SingleChannelTexture",i))(Tu||{}),Su=(i=>(i[i.TextureSubImage2D=1]="TextureSubImage2D",i))(Su||{}),Iu=(i=>(i[i.DirtyRect=1]="DirtyRect",i))(Iu||{}),ze=(i=>(i.Normal="Normal",i.Stroke="Stroke",i.Dotted="Dotted",i.LongDotted="LongDotted",i))(ze||{}),Gt=(i=>(i.Triangle="triangle",i.Rhombus="rhombus",i.Pentagram="pentagram",i.SpeechBalloon="speechBalloon",i.Star="star",i.Polygon="polygon",i))(Gt||{});const rr={star:"star",polygon:"polygon",speechBalloon:"speechBalloon",bitMapEraser:"bitMapEraser"};var Se=(i=>(i.None="None",i.ShowFloatBar="ShowFloatBar",i.ZIndexFloatBar="ZIndexFloatBar",i.DeleteNode="DeleteNode",i.CopyNode="CopyNode",i.ZIndexNode="ZIndexNode",i.ZIndexBackgroundSVG="ZIndexBackgroundSVG",i.RotateNode="RotateNode",i.SetColorNode="SetColorNode",i.TranslateNode="TranslateNode",i.ScaleNode="ScaleNode",i.OriginalEvent="OriginalEvent",i.CreateScene="CreateScene",i.ActiveCursor="ActiveCursor",i.MoveCursor="MoveCursor",i.CommandEditor="CommandEditor",i.SetEditorData="SetEditorData",i.SetFontStyle="SetFontStyle",i.SetPoint="SetPoint",i.SetLock="SetLock",i.SetShapeOpt="SetShapeOpt",i.CameraChange="CameraChange",i.ActiveMethod="ActiveMethod",i.HidFloatBarBtn="HidFloatBarBtn",i.SelectMethod="SelectMethod",i))(Se||{}),Fe=(i=>(i.MainEngine="MainEngine",i.Cursor="Cursor",i.BindMainView="BindMainView",i))(Fe||{}),op=(i=>(i[i.MainView=0]="MainView",i[i.Plugin=1]="Plugin",i[i.Both=2]="Both",i))(op||{}),Cu=(i=>(i.longPencil="longPencil",i))(Cu||{}),K=(i=>(i[i.Pencil=1]="Pencil",i[i.Eraser=2]="Eraser",i[i.PencilEraser=3]="PencilEraser",i[i.BitMapEraser=4]="BitMapEraser",i[i.Selector=5]="Selector",i[i.Clicker=6]="Clicker",i[i.Arrow=7]="Arrow",i[i.Hand=8]="Hand",i[i.LaserPen=9]="LaserPen",i[i.Text=10]="Text",i[i.Straight=11]="Straight",i[i.Rectangle=12]="Rectangle",i[i.Ellipse=13]="Ellipse",i[i.Star=14]="Star",i[i.Triangle=15]="Triangle",i[i.Rhombus=16]="Rhombus",i[i.Polygon=17]="Polygon",i[i.SpeechBalloon=18]="SpeechBalloon",i[i.Image=19]="Image",i[i.BackgroundSVG=20]="BackgroundSVG",i))(K||{}),Ee=(i=>(i[i.Local=1]="Local",i[i.Service=2]="Service",i[i.Worker=3]="Worker",i))(Ee||{}),ge=(i=>(i[i.Pending=0]="Pending",i[i.Start=1]="Start",i[i.Doing=2]="Doing",i[i.Done=3]="Done",i[i.Unwritable=4]="Unwritable",i))(ge||{}),he=(i=>(i[i.None=0]="None",i[i.Init=1]="Init",i[i.UpdateCamera=2]="UpdateCamera",i[i.UpdateTools=3]="UpdateTools",i[i.CreateWork=4]="CreateWork",i[i.DrawWork=5]="DrawWork",i[i.FullWork=6]="FullWork",i[i.UpdateNode=7]="UpdateNode",i[i.RemoveNode=8]="RemoveNode",i[i.Clear=9]="Clear",i[i.Select=10]="Select",i[i.Destroy=11]="Destroy",i[i.Snapshot=12]="Snapshot",i[i.BoundingBox=13]="BoundingBox",i[i.Cursor=14]="Cursor",i[i.TextUpdate=15]="TextUpdate",i[i.GetTextActive=16]="GetTextActive",i[i.TasksQueue=17]="TasksQueue",i[i.CursorHover=18]="CursorHover",i[i.CursorBlur=19]="CursorBlur",i[i.Console=20]="Console",i[i.GetImageBitMap=23]="GetImageBitMap",i[i.AuthWriter=24]="AuthWriter",i[i.AuthReader=25]="AuthReader",i[i.AuthClear=26]="AuthClear",i[i.AuthPage=27]="AuthPage",i[i.GetVNodeInfo=28]="GetVNodeInfo",i[i.UpdateDpr=29]="UpdateDpr",i[i.SetFontFace=30]="SetFontFace",i[i.ReportError=31]="ReportError",i[i.ReportLog=32]="ReportLog",i[i.BackgroundSVGUpdate=33]="BackgroundSVGUpdate",i[i.BackgroundSVGDelete=34]="BackgroundSVGDelete",i[i.SelectorTransform=35]="SelectorTransform",i[i.CheckFontFace=36]="CheckFontFace",i[i.RefreshTextRender=37]="RefreshTextRender",i[i.ProbeRenderCapabilities=38]="ProbeRenderCapabilities",i))(he||{}),_e=(i=>(i[i.None=0]="None",i[i.Bg=1]="Bg",i[i.ServiceFloat=2]="ServiceFloat",i[i.Float=3]="Float",i[i.TopFloat=4]="TopFloat",i))(_e||{}),Ts=(i=>(i[i.Cursor=1]="Cursor",i[i.TextCreate=2]="TextCreate",i))(Ts||{}),Mn=(i=>(i[i.Top=1]="Top",i[i.Bottom=2]="Bottom",i))(Mn||{}),Ve=(i=>(i[i.none=1]="none",i[i.all=2]="all",i[i.both=3]="both",i[i.proportional=4]="proportional",i))(Ve||{}),Kr=(i=>(i[i.inside=0]="inside",i[i.outside=1]="outside",i[i.intersect=2]="intersect",i))(Kr||{}),yt=(i=>(i.renderPage="renderPage",i.addPage="addPage",i.deletePage="deletePage",i.addElement="addElement",i.deleteElement="deleteElement",i.clearPage="clearPage",i.clearViewScenePath="clearViewScenePath",i.clearView="clearView",i.syncUndoStack="syncUndoStack",i.syncRedoStack="syncRedoStack",i))(yt||{}),gr=(i=>(i.setAuth="setAuth",i.setShow="addShow",i.setHide="setHide",i.setClear="setClear",i))(gr||{}),qr=(i=>(i.Image="image",i.Iconify="iconify",i))(qr||{}),Li=(i=>(i.url="url",i.markmap="markmap",i))(Li||{});const ap="cursorhover",Ia=20,Ue="mainView",_0=ip.getWhiteWebSdkBridgeRuntime(),{toJS:Wo,autorun:mc,isRoom:Le,isPlayer:bu,InvisiblePlugin:cp,RoomPhase:lp}=_0,ev={linear:i=>i,easeInQuad:i=>i*i,easeOutQuad:i=>i*(2-i),easeInOutQuad:i=>i<.5?2*i*i:-1+(4-2*i)*i,easeInCubic:i=>i*i*i,easeOutCubic:i=>--i*i*i+1,easeInOutCubic:i=>i<.5?4*i*i*i:(i-1)*(2*i-2)*(2*i-2)+1,easeInQuart:i=>i*i*i*i,easeOutQuart:i=>1- --i*i*i*i,easeInOutQuart:i=>i<.5?8*i*i*i*i:1-8*--i*i*i*i,easeInQuint:i=>i*i*i*i*i,easeOutQuint:i=>1+--i*i*i*i*i,easeInOutQuint:i=>i<.5?16*i*i*i*i*i:1+16*--i*i*i*i*i,easeInSine:i=>1-Math.cos(i*Math.PI/2),easeOutSine:i=>Math.sin(i*Math.PI/2),easeInOutSine:i=>-(Math.cos(Math.PI*i)-1)/2,easeInExpo:i=>i<=0?0:Math.pow(2,10*i-10),easeOutExpo:i=>i>=1?1:1-Math.pow(2,-10*i),easeInOutExpo:i=>i<=0?0:i>=1?1:i<.5?Math.pow(2,20*i-10)/2:(2-Math.pow(2,-20*i+10))/2};class fe{constructor(t=0,e=0,r=1){this.x=t,this.y=e,this.z=r}get XY(){return[this.x,this.y]}setz(t){return this.z=t,this}setXY(t=this.x,e=this.y){return this.x=t,this.y=e,this}set(t=this.x,e=this.y,r=this.z){return this.x=t,this.y=e,this.z=r,this}setTo({x:t=0,y:e=0,z:r=1}){return this.x=t,this.y=e,this.z=r,this}rot(t){if(t===0)return this;const{x:e,y:r}=this,n=Math.sin(t),s=Math.cos(t);return this.x=e*s-r*n,this.y=e*n+r*s,this}rotWith(t,e){if(e===0)return this;const r=this.x-t.x,n=this.y-t.y,s=Math.sin(e),o=Math.cos(e);return this.x=t.x+(r*o-n*s),this.y=t.y+(r*s+n*o),this}clone(){const{x:t,y:e,z:r}=this;return new fe(t,e,r)}sub(t){return this.x-=t.x,this.y-=t.y,this}subXY(t,e){return this.x-=t,this.y-=e,this}subScalar(t){return this.x-=t,this.y-=t,this}add(t){return this.x+=t.x,this.y+=t.y,this}addXY(t,e){return this.x+=t,this.y+=e,this}addScalar(t){return this.x+=t,this.y+=t,this}clamp(t,e){return this.x=Math.max(this.x,t),this.y=Math.max(this.y,t),e!==void 0&&(this.x=Math.min(this.x,e),this.y=Math.min(this.y,e)),this}div(t){return this.x/=t,this.y/=t,this}divV(t){return this.x/=t.x,this.y/=t.y,this}mul(t){return this.x*=t,this.y*=t,this}mulV(t){return this.x*=t.x,this.y*=t.y,this}abs(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this}nudge(t,e){const r=fe.Tan(t,this);return this.add(r.mul(e))}neg(){return this.x*=-1,this.y*=-1,this}cross(t){return this.x=this.y*t.z-this.z*t.y,this.y=this.z*t.x-this.x*t.z,this}dpr(t){return fe.Dpr(this,t)}cpr(t){return fe.Cpr(this,t)}len2(){return fe.Len2(this)}len(){return fe.Len(this)}pry(t){return fe.Pry(this,t)}per(){const{x:t,y:e}=this;return this.x=e,this.y=-t,this}uni(){return fe.Uni(this)}tan(t){return fe.Tan(this,t)}dist(t){return fe.Dist(this,t)}distanceToLineSegment(t,e){return fe.DistanceToLineSegment(t,e,this)}slope(t){return fe.Slope(this,t)}snapToGrid(t){return this.x=Math.round(this.x/t)*t,this.y=Math.round(this.y/t)*t,this}angle(t){return fe.Angle(this,t)}toAngle(){return fe.ToAngle(this)}lrp(t,e){return this.x=this.x+(t.x-this.x)*e,this.y=this.y+(t.y-this.y)*e,this}equals(t,e){return fe.Equals(this,t,e)}equalsXY(t,e){return fe.EqualsXY(this,t,e)}norm(){const t=this.len();return this.x=t===0?0:this.x/t,this.y=t===0?0:this.y/t,this}toFixed(){return fe.ToFixed(this)}toString(){return fe.ToString(fe.ToFixed(this))}toJson(){return fe.ToJson(this)}toArray(){return fe.ToArray(this)}static Add(t,e){return new fe(t.x+e.x,t.y+e.y)}static AddXY(t,e,r){return new fe(t.x+e,t.y+r)}static Sub(t,e){return new fe(t.x-e.x,t.y-e.y)}static SubXY(t,e,r){return new fe(t.x-e,t.y-r)}static AddScalar(t,e){return new fe(t.x+e,t.y+e)}static SubScalar(t,e){return new fe(t.x-e,t.y-e)}static Div(t,e){return new fe(t.x/e,t.y/e)}static Mul(t,e){return new fe(t.x*e,t.y*e)}static DivV(t,e){return new fe(t.x/e.x,t.y/e.y)}static MulV(t,e){return new fe(t.x*e.x,t.y*e.y)}static Neg(t){return new fe(-t.x,-t.y)}static Per(t){return new fe(t.y,-t.x)}static Dist2(t,e){return fe.Sub(t,e).len2()}static Abs(t){return new fe(Math.abs(t.x),Math.abs(t.y))}static Dist(t,e){return Math.hypot(t.y-e.y,t.x-e.x)}static Dpr(t,e){return t.x*e.x+t.y*e.y}static Cross(t,e){return new fe(t.y*e.z-t.z*e.y,t.z*e.x-t.x*e.z)}static Cpr(t,e){return t.x*e.y-e.x*t.y}static Len2(t){return t.x*t.x+t.y*t.y}static Len(t){return Math.hypot(t.x,t.y)}static Pry(t,e){return fe.Dpr(t,e)/fe.Len(e)}static Uni(t){return fe.Div(t,fe.Len(t))}static Tan(t,e){return fe.Uni(fe.Sub(t,e))}static Min(t,e){return new fe(Math.min(t.x,e.x),Math.min(t.y,e.y))}static Max(t,e){return new fe(Math.max(t.x,e.x),Math.max(t.y,e.y))}static From(t){return new fe().add(t)}static FromArray(t){return new fe(t[0],t[1])}static Rot(t,e=0){const r=Math.sin(e),n=Math.cos(e);return new fe(t.x*n-t.y*r,t.x*r+t.y*n)}static RotWith(t,e,r){const n=t.x-e.x,s=t.y-e.y,o=Math.sin(r),a=Math.cos(r);return new fe(e.x+(n*a-s*o),e.y+(n*o+s*a))}static NearestPointOnLineThroughPoint(t,e,r){return fe.Mul(e,fe.Sub(r,t).pry(e)).add(t)}static NearestPointOnLineSegment(t,e,r,n=!0){const s=fe.Tan(e,t),o=fe.Add(t,fe.Mul(s,fe.Sub(r,t).pry(s)));if(n){if(o.x<Math.min(t.x,e.x))return fe.Cast(t.x<e.x?t:e);if(o.x>Math.max(t.x,e.x))return fe.Cast(t.x>e.x?t:e);if(o.y<Math.min(t.y,e.y))return fe.Cast(t.y<e.y?t:e);if(o.y>Math.max(t.y,e.y))return fe.Cast(t.y>e.y?t:e)}return o}static DistanceToLineThroughPoint(t,e,r){return fe.Dist(r,fe.NearestPointOnLineThroughPoint(t,e,r))}static DistanceToLineSegment(t,e,r,n=!0){return fe.Dist(r,fe.NearestPointOnLineSegment(t,e,r,n))}static Snap(t,e=1){return new fe(Math.round(t.x/e)*e,Math.round(t.y/e)*e)}static Cast(t){return t instanceof fe?t:fe.From(t)}static Slope(t,e){return t.x===e.y?NaN:(t.y-e.y)/(t.x-e.x)}static Angle(t,e){return Math.atan2(e.y-t.y,e.x-t.x)}static Lrp(t,e,r){return fe.Sub(e,t).mul(r).add(t)}static Med(t,e){return new fe((t.x+e.x)/2,(t.y+e.y)/2)}static Equals(t,e,r=1e-4){return Math.abs(t.x-e.x)<r&&Math.abs(t.y-e.y)<r}static EqualsXY(t,e,r){return t.x===e&&t.y===r}static EqualsXYZ(t,e,r=1e-4){return fe.Equals(t,e,r)&&Math.abs((t.z||0)-(e.z||0))<r}static Clockwise(t,e,r){return(r.x-t.x)*(e.y-t.y)-(e.x-t.x)*(r.y-t.y)<0}static Rescale(t,e){const r=fe.Len(t);return new fe(e*t.x/r,e*t.y/r)}static ScaleWithOrigin(t,e,r){return fe.Sub(t,r).mul(e).add(r)}static ScaleWOrigin(t,e,r){return fe.Sub(t,r).mulV(e).add(r)}static ToFixed(t,e=2){return new fe(+t.x.toFixed(e),+t.y.toFixed(e),+t.z.toFixed(e))}static Nudge(t,e,r){return fe.Add(t,fe.Tan(e,t).mul(r))}static ToString(t){return`${t.x}, ${t.y}`}static ToAngle(t){let e=Math.atan2(t.y,t.x);return e<0&&(e+=Math.PI*2),e}static FromAngle(t,e=1){return new fe(Math.cos(t)*e,Math.sin(t)*e)}static ToArray(t){return[t.x,t.y,t.z]}static ToJson(t){const{x:e,y:r,z:n}=t;return{x:e,y:r,z:n}}static Average(t){const e=t.length,r=new fe(0,0);for(let n=0;n<e;n++)r.add(t[n]);return r.div(e)}static Clamp(t,e,r){return r===void 0?new fe(Math.min(Math.max(t.x,e)),Math.min(Math.max(t.y,e))):new fe(Math.min(Math.max(t.x,e),r),Math.min(Math.max(t.y,e),r))}static PointsBetween(t,e,r=6){const n=[];for(let s=0;s<r;s++){const o=ev.easeInQuad(s/(r-1)),a=fe.Lrp(t,e,o);a.z=Math.min(1,.5+Math.abs(.5-tv(o))*.65),n.push(a)}return n}static SnapToGrid(t,e=8){return new fe(Math.round(t.x/e)*e,Math.round(t.y/e)*e)}}const tv=i=>i<.5?2*i*i:-1+(4-2*i)*i;class Ae extends fe{constructor(t=0,e=0,r=0,n={x:0,y:0},s=0,o=0){super(t,e,r),this.x=t,this.y=e,this.z=r,this.v=n,this.t=s,this.a=o}get timestamp(){return this.t}get pressure(){return this.z}get angleNum(){return this.a}get XY(){return[this.x,this.y]}setA(t){this.a=t}setT(t){this.t=t}setv(t){return this.v={x:t.x,y:t.y},this}set(t=this.x,e=this.y,r=this.z,n=this.v,s=this.t,o=this.a){return this.x=t,this.y=e,this.z=r,this.v=n,this.t=s,this.a=o,this}clone(){const{x:t,y:e,z:r,v:n,t:s,a:o}=this,a={x:n.x,y:n.y};return new Ae(t,e,r,a,s,o)}distance(t){return Ae.GetDistance(this,t)}isNear(t,e){return Ae.IsNear(this,t,e)}getAngleByPoints(t,e){return Ae.GetAngleByPoints(t,this,e)}static Sub(t,e){return new Ae(t.x-e.x,t.y-e.y)}static Add(t,e){return new Ae(t.x+e.x,t.y+e.y)}static GetDistance(t,e){return Ae.Len(t.clone().sub(e))}static GetAngleByPoints(t,e,r){const n=e.x-t.x,s=r.x-e.x,o=e.y-t.y,a=r.y-e.y;let c=0;const l=Math.sqrt(n*n+o*o),u=Math.sqrt(s*s+a*a);if(l&&u){const h=n*s+o*a;c=Math.acos(h/(l*u)),c=c/Math.PI*180;let d=n*a-o*s;d=d>0?1:-1,c=180+d*c}return c}static IsNear(t,e,r){return Ae.Len(t.clone().sub(e))<r}static RotWith(t,e,r,n=2){const s=t.x-e.x,o=t.y-e.y,a=Math.sin(r),c=Math.cos(r),l=Math.pow(10,n),u=Math.floor((e.x+(s*c-o*a))*l)/l,h=Math.floor((e.y+(s*a+o*c))*l)/l;return new Ae(u,h)}static GetDotStroke(t,e,r=16){const n=new fe(1,1),s=Math.PI+.001,o=Ae.Add(t,Ae.Sub(t,n).uni().per().mul(-e)),a=[];for(let c=1/r,l=c;l<=1;l+=c)a.push(Ae.RotWith(o,t,s*2*l));return a}static GetSemicircleStroke(t,e,r=-1,n=8){const s=r*(Math.PI+.001),o=[];for(let a=1/n,c=a;c<=1;c+=a)o.push(Ae.RotWith(e,t,s*c));return o}}var fi=1e-6,Es=typeof Float32Array<"u"?Float32Array:Array;function qe(i){Es=i}function rv(){var i=new Es(6);return Es!=Float32Array&&(i[1]=0,i[2]=0,i[4]=0,i[5]=0),i[0]=1,i[3]=1,i}function nv(i){var t=new Es(6);return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t}function iv(i,t){return i[0]=t[0],i[1]=t[1],i[2]=t[2],i[3]=t[3],i[4]=t[4],i[5]=t[5],i}function sv(i){return i[0]=1,i[1]=0,i[2]=0,i[3]=1,i[4]=0,i[5]=0,i}function Zn(i,t,e,r,n,s){var o=new Es(6);return o[0]=i,o[1]=t,o[2]=e,o[3]=r,o[4]=n,o[5]=s,o}function ov(i,t,e,r,n,s,o){return i[0]=t,i[1]=e,i[2]=r,i[3]=n,i[4]=s,i[5]=o,i}function Jo(i,t){var e=t[0],r=t[1],n=t[2],s=t[3],o=t[4],a=t[5],c=e*s-r*n;return c?(c=1/c,i[0]=s*c,i[1]=-r*c,i[2]=-n*c,i[3]=e*c,i[4]=(n*a-s*o)*c,i[5]=(r*o-e*a)*c,i):null}function av(i){return i[0]*i[3]-i[1]*i[2]}function Er(i,t,e){var r=t[0],n=t[1],s=t[2],o=t[3],a=t[4],c=t[5],l=e[0],u=e[1],h=e[2],d=e[3],g=e[4],p=e[5];return i[0]=r*l+s*u,i[1]=n*l+o*u,i[2]=r*h+s*d,i[3]=n*h+o*d,i[4]=r*g+s*p+a,i[5]=n*g+o*p+c,i}function up(i,t,e){var r=t[0],n=t[1],s=t[2],o=t[3],a=t[4],c=t[5],l=Math.sin(e),u=Math.cos(e);return i[0]=r*u+s*l,i[1]=n*u+o*l,i[2]=r*-l+s*u,i[3]=n*-l+o*u,i[4]=a,i[5]=c,i}function cv(i,t,e){var r=t[0],n=t[1],s=t[2],o=t[3],a=t[4],c=t[5],l=e[0],u=e[1];return i[0]=r*l,i[1]=n*l,i[2]=s*u,i[3]=o*u,i[4]=a,i[5]=c,i}function Cl(i,t,e){var r=t[0],n=t[1],s=t[2],o=t[3],a=t[4],c=t[5],l=e[0],u=e[1];return i[0]=r,i[1]=n,i[2]=s,i[3]=o,i[4]=r*l+s*u+a,i[5]=n*l+o*u+c,i}function lv(i,t){var e=Math.sin(t),r=Math.cos(t);return i[0]=r,i[1]=e,i[2]=-e,i[3]=r,i[4]=0,i[5]=0,i}function uv(i,t){return i[0]=t[0],i[1]=0,i[2]=0,i[3]=t[1],i[4]=0,i[5]=0,i}function hv(i,t){return i[0]=1,i[1]=0,i[2]=0,i[3]=1,i[4]=t[0],i[5]=t[1],i}function dv(i){return"mat2d("+i[0]+", "+i[1]+", "+i[2]+", "+i[3]+", "+i[4]+", "+i[5]+")"}function fv(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]+i[3]*i[3]+i[4]*i[4]+i[5]*i[5]+1)}function gv(i,t,e){return i[0]=t[0]+e[0],i[1]=t[1]+e[1],i[2]=t[2]+e[2],i[3]=t[3]+e[3],i[4]=t[4]+e[4],i[5]=t[5]+e[5],i}function hp(i,t,e){return i[0]=t[0]-e[0],i[1]=t[1]-e[1],i[2]=t[2]-e[2],i[3]=t[3]-e[3],i[4]=t[4]-e[4],i[5]=t[5]-e[5],i}function pv(i,t,e){return i[0]=t[0]*e,i[1]=t[1]*e,i[2]=t[2]*e,i[3]=t[3]*e,i[4]=t[4]*e,i[5]=t[5]*e,i}function mv(i,t,e,r){return i[0]=t[0]+e[0]*r,i[1]=t[1]+e[1]*r,i[2]=t[2]+e[2]*r,i[3]=t[3]+e[3]*r,i[4]=t[4]+e[4]*r,i[5]=t[5]+e[5]*r,i}function yv(i,t){return i[0]===t[0]&&i[1]===t[1]&&i[2]===t[2]&&i[3]===t[3]&&i[4]===t[4]&&i[5]===t[5]}function vv(i,t){var e=i[0],r=i[1],n=i[2],s=i[3],o=i[4],a=i[5],c=t[0],l=t[1],u=t[2],h=t[3],d=t[4],g=t[5];return Math.abs(e-c)<=fi*Math.max(1,Math.abs(e),Math.abs(c))&&Math.abs(r-l)<=fi*Math.max(1,Math.abs(r),Math.abs(l))&&Math.abs(n-u)<=fi*Math.max(1,Math.abs(n),Math.abs(u))&&Math.abs(s-h)<=fi*Math.max(1,Math.abs(s),Math.abs(h))&&Math.abs(o-d)<=fi*Math.max(1,Math.abs(o),Math.abs(d))&&Math.abs(a-g)<=fi*Math.max(1,Math.abs(a),Math.abs(g))}var Mv=Er,wv=hp;const dp=Object.freeze(Object.defineProperty({__proto__:null,add:gv,clone:nv,copy:iv,create:rv,determinant:av,equals:vv,exactEquals:yv,frob:fv,fromRotation:lv,fromScaling:uv,fromTranslation:hv,fromValues:Zn,identity:sv,invert:Jo,mul:Mv,multiply:Er,multiplyScalar:pv,multiplyScalarAndAdd:mv,rotate:up,scale:cv,set:ov,str:dv,sub:wv,subtract:hp,translate:Cl},Symbol.toStringTag,{value:"Module"}));var vt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function en(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var fp={exports:{}};(function(i,t){(function(r,n){i.exports=n()})(vt,function(){return function(e){var r={};function n(s){if(r[s])return r[s].exports;var o=r[s]={i:s,l:!1,exports:{}};return e[s].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=r,n.d=function(s,o,a){n.o(s,o)||Object.defineProperty(s,o,{enumerable:!0,get:a})},n.r=function(s){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(s,"__esModule",{value:!0})},n.t=function(s,o){if(o&1&&(s=n(s)),o&8||o&4&&typeof s=="object"&&s&&s.__esModule)return s;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:s}),o&2&&typeof s!="string")for(var c in s)n.d(a,c,(function(l){return s[l]}).bind(null,c));return a},n.n=function(s){var o=s&&s.__esModule?function(){return s.default}:function(){return s};return n.d(o,"a",o),o},n.o=function(s,o){return Object.prototype.hasOwnProperty.call(s,o)},n.p="/js/",n(n.s=0)}([function(e,r,n){n.r(r);var s=n(12);n.d(r,"Renderer",function(){return s.default});var o=n(56);n.d(r,"Figure2D",function(){return o.default});var a=n(73);n.d(r,"Mesh2D",function(){return a.default});var c=n(45);n.d(r,"MeshCloud",function(){return c.default});var l=n(39);n.d(r,"parseFont",function(){return l.default});var u=n(47);n.d(r,"parseColor",function(){return u.default});var h=n(37);n.d(r,"ENV",function(){return h.default}),n(1).glMatrix.setMatrixArrayType(Array)},function(e,r,n){n.r(r);var s=n(2);n.d(r,"glMatrix",function(){return s});var o=n(3);n.d(r,"mat2",function(){return o});var a=n(4);n.d(r,"mat2d",function(){return a});var c=n(5);n.d(r,"mat3",function(){return c});var l=n(6);n.d(r,"mat4",function(){return l});var u=n(7);n.d(r,"quat",function(){return u});var h=n(10);n.d(r,"quat2",function(){return h});var d=n(11);n.d(r,"vec2",function(){return d});var g=n(8);n.d(r,"vec3",function(){return g});var p=n(9);n.d(r,"vec4",function(){return p})},function(e,r,n){n.r(r),n.d(r,"EPSILON",function(){return s}),n.d(r,"ARRAY_TYPE",function(){return o}),n.d(r,"RANDOM",function(){return a}),n.d(r,"setMatrixArrayType",function(){return c}),n.d(r,"toRadian",function(){return u}),n.d(r,"equals",function(){return h});var s=1e-6,o=typeof Float32Array<"u"?Float32Array:Array,a=Math.random;function c(d){o=d}var l=Math.PI/180;function u(d){return d*l}function h(d,g){return Math.abs(d-g)<=s*Math.max(1,Math.abs(d),Math.abs(g))}Math.hypot||(Math.hypot=function(){for(var d=0,g=arguments.length;g--;)d+=arguments[g]*arguments[g];return Math.sqrt(d)})},function(e,r,n){n.r(r),n.d(r,"create",function(){return o}),n.d(r,"clone",function(){return a}),n.d(r,"copy",function(){return c}),n.d(r,"identity",function(){return l}),n.d(r,"fromValues",function(){return u}),n.d(r,"set",function(){return h}),n.d(r,"transpose",function(){return d}),n.d(r,"invert",function(){return g}),n.d(r,"adjoint",function(){return p}),n.d(r,"determinant",function(){return v}),n.d(r,"multiply",function(){return I}),n.d(r,"rotate",function(){return D}),n.d(r,"scale",function(){return x}),n.d(r,"fromRotation",function(){return j}),n.d(r,"fromScaling",function(){return w}),n.d(r,"str",function(){return y}),n.d(r,"frob",function(){return f}),n.d(r,"LDU",function(){return M}),n.d(r,"add",function(){return T}),n.d(r,"subtract",function(){return b}),n.d(r,"exactEquals",function(){return C}),n.d(r,"equals",function(){return P}),n.d(r,"multiplyScalar",function(){return E}),n.d(r,"multiplyScalarAndAdd",function(){return O}),n.d(r,"mul",function(){return V}),n.d(r,"sub",function(){return N});var s=n(2);function o(){var A=new s.ARRAY_TYPE(4);return s.ARRAY_TYPE!=Float32Array&&(A[1]=0,A[2]=0),A[0]=1,A[3]=1,A}function a(A){var k=new s.ARRAY_TYPE(4);return k[0]=A[0],k[1]=A[1],k[2]=A[2],k[3]=A[3],k}function c(A,k){return A[0]=k[0],A[1]=k[1],A[2]=k[2],A[3]=k[3],A}function l(A){return A[0]=1,A[1]=0,A[2]=0,A[3]=1,A}function u(A,k,U,Z){var Q=new s.ARRAY_TYPE(4);return Q[0]=A,Q[1]=k,Q[2]=U,Q[3]=Z,Q}function h(A,k,U,Z,Q){return A[0]=k,A[1]=U,A[2]=Z,A[3]=Q,A}function d(A,k){if(A===k){var U=k[1];A[1]=k[2],A[2]=U}else A[0]=k[0],A[1]=k[2],A[2]=k[1],A[3]=k[3];return A}function g(A,k){var U=k[0],Z=k[1],Q=k[2],ce=k[3],L=U*ce-Q*Z;return L?(L=1/L,A[0]=ce*L,A[1]=-Z*L,A[2]=-Q*L,A[3]=U*L,A):null}function p(A,k){var U=k[0];return A[0]=k[3],A[1]=-k[1],A[2]=-k[2],A[3]=U,A}function v(A){return A[0]*A[3]-A[2]*A[1]}function I(A,k,U){var Z=k[0],Q=k[1],ce=k[2],L=k[3],W=U[0],H=U[1],$=U[2],ee=U[3];return A[0]=Z*W+ce*H,A[1]=Q*W+L*H,A[2]=Z*$+ce*ee,A[3]=Q*$+L*ee,A}function D(A,k,U){var Z=k[0],Q=k[1],ce=k[2],L=k[3],W=Math.sin(U),H=Math.cos(U);return A[0]=Z*H+ce*W,A[1]=Q*H+L*W,A[2]=Z*-W+ce*H,A[3]=Q*-W+L*H,A}function x(A,k,U){var Z=k[0],Q=k[1],ce=k[2],L=k[3],W=U[0],H=U[1];return A[0]=Z*W,A[1]=Q*W,A[2]=ce*H,A[3]=L*H,A}function j(A,k){var U=Math.sin(k),Z=Math.cos(k);return A[0]=Z,A[1]=U,A[2]=-U,A[3]=Z,A}function w(A,k){return A[0]=k[0],A[1]=0,A[2]=0,A[3]=k[1],A}function y(A){return"mat2("+A[0]+", "+A[1]+", "+A[2]+", "+A[3]+")"}function f(A){return Math.hypot(A[0],A[1],A[2],A[3])}function M(A,k,U,Z){return A[2]=Z[2]/Z[0],U[0]=Z[0],U[1]=Z[1],U[3]=Z[3]-A[2]*U[1],[A,k,U]}function T(A,k,U){return A[0]=k[0]+U[0],A[1]=k[1]+U[1],A[2]=k[2]+U[2],A[3]=k[3]+U[3],A}function b(A,k,U){return A[0]=k[0]-U[0],A[1]=k[1]-U[1],A[2]=k[2]-U[2],A[3]=k[3]-U[3],A}function C(A,k){return A[0]===k[0]&&A[1]===k[1]&&A[2]===k[2]&&A[3]===k[3]}function P(A,k){var U=A[0],Z=A[1],Q=A[2],ce=A[3],L=k[0],W=k[1],H=k[2],$=k[3];return Math.abs(U-L)<=s.EPSILON*Math.max(1,Math.abs(U),Math.abs(L))&&Math.abs(Z-W)<=s.EPSILON*Math.max(1,Math.abs(Z),Math.abs(W))&&Math.abs(Q-H)<=s.EPSILON*Math.max(1,Math.abs(Q),Math.abs(H))&&Math.abs(ce-$)<=s.EPSILON*Math.max(1,Math.abs(ce),Math.abs($))}function E(A,k,U){return A[0]=k[0]*U,A[1]=k[1]*U,A[2]=k[2]*U,A[3]=k[3]*U,A}function O(A,k,U,Z){return A[0]=k[0]+U[0]*Z,A[1]=k[1]+U[1]*Z,A[2]=k[2]+U[2]*Z,A[3]=k[3]+U[3]*Z,A}var V=I,N=b},function(e,r,n){n.r(r),n.d(r,"create",function(){return o}),n.d(r,"clone",function(){return a}),n.d(r,"copy",function(){return c}),n.d(r,"identity",function(){return l}),n.d(r,"fromValues",function(){return u}),n.d(r,"set",function(){return h}),n.d(r,"invert",function(){return d}),n.d(r,"determinant",function(){return g}),n.d(r,"multiply",function(){return p}),n.d(r,"rotate",function(){return v}),n.d(r,"scale",function(){return I}),n.d(r,"translate",function(){return D}),n.d(r,"fromRotation",function(){return x}),n.d(r,"fromScaling",function(){return j}),n.d(r,"fromTranslation",function(){return w}),n.d(r,"str",function(){return y}),n.d(r,"frob",function(){return f}),n.d(r,"add",function(){return M}),n.d(r,"subtract",function(){return T}),n.d(r,"multiplyScalar",function(){return b}),n.d(r,"multiplyScalarAndAdd",function(){return C}),n.d(r,"exactEquals",function(){return P}),n.d(r,"equals",function(){return E}),n.d(r,"mul",function(){return O}),n.d(r,"sub",function(){return V});var s=n(2);function o(){var N=new s.ARRAY_TYPE(6);return s.ARRAY_TYPE!=Float32Array&&(N[1]=0,N[2]=0,N[4]=0,N[5]=0),N[0]=1,N[3]=1,N}function a(N){var A=new s.ARRAY_TYPE(6);return A[0]=N[0],A[1]=N[1],A[2]=N[2],A[3]=N[3],A[4]=N[4],A[5]=N[5],A}function c(N,A){return N[0]=A[0],N[1]=A[1],N[2]=A[2],N[3]=A[3],N[4]=A[4],N[5]=A[5],N}function l(N){return N[0]=1,N[1]=0,N[2]=0,N[3]=1,N[4]=0,N[5]=0,N}function u(N,A,k,U,Z,Q){var ce=new s.ARRAY_TYPE(6);return ce[0]=N,ce[1]=A,ce[2]=k,ce[3]=U,ce[4]=Z,ce[5]=Q,ce}function h(N,A,k,U,Z,Q,ce){return N[0]=A,N[1]=k,N[2]=U,N[3]=Z,N[4]=Q,N[5]=ce,N}function d(N,A){var k=A[0],U=A[1],Z=A[2],Q=A[3],ce=A[4],L=A[5],W=k*Q-U*Z;return W?(W=1/W,N[0]=Q*W,N[1]=-U*W,N[2]=-Z*W,N[3]=k*W,N[4]=(Z*L-Q*ce)*W,N[5]=(U*ce-k*L)*W,N):null}function g(N){return N[0]*N[3]-N[1]*N[2]}function p(N,A,k){var U=A[0],Z=A[1],Q=A[2],ce=A[3],L=A[4],W=A[5],H=k[0],$=k[1],ee=k[2],ie=k[3],le=k[4],pe=k[5];return N[0]=U*H+Q*$,N[1]=Z*H+ce*$,N[2]=U*ee+Q*ie,N[3]=Z*ee+ce*ie,N[4]=U*le+Q*pe+L,N[5]=Z*le+ce*pe+W,N}function v(N,A,k){var U=A[0],Z=A[1],Q=A[2],ce=A[3],L=A[4],W=A[5],H=Math.sin(k),$=Math.cos(k);return N[0]=U*$+Q*H,N[1]=Z*$+ce*H,N[2]=U*-H+Q*$,N[3]=Z*-H+ce*$,N[4]=L,N[5]=W,N}function I(N,A,k){var U=A[0],Z=A[1],Q=A[2],ce=A[3],L=A[4],W=A[5],H=k[0],$=k[1];return N[0]=U*H,N[1]=Z*H,N[2]=Q*$,N[3]=ce*$,N[4]=L,N[5]=W,N}function D(N,A,k){var U=A[0],Z=A[1],Q=A[2],ce=A[3],L=A[4],W=A[5],H=k[0],$=k[1];return N[0]=U,N[1]=Z,N[2]=Q,N[3]=ce,N[4]=U*H+Q*$+L,N[5]=Z*H+ce*$+W,N}function x(N,A){var k=Math.sin(A),U=Math.cos(A);return N[0]=U,N[1]=k,N[2]=-k,N[3]=U,N[4]=0,N[5]=0,N}function j(N,A){return N[0]=A[0],N[1]=0,N[2]=0,N[3]=A[1],N[4]=0,N[5]=0,N}function w(N,A){return N[0]=1,N[1]=0,N[2]=0,N[3]=1,N[4]=A[0],N[5]=A[1],N}function y(N){return"mat2d("+N[0]+", "+N[1]+", "+N[2]+", "+N[3]+", "+N[4]+", "+N[5]+")"}function f(N){return Math.hypot(N[0],N[1],N[2],N[3],N[4],N[5],1)}function M(N,A,k){return N[0]=A[0]+k[0],N[1]=A[1]+k[1],N[2]=A[2]+k[2],N[3]=A[3]+k[3],N[4]=A[4]+k[4],N[5]=A[5]+k[5],N}function T(N,A,k){return N[0]=A[0]-k[0],N[1]=A[1]-k[1],N[2]=A[2]-k[2],N[3]=A[3]-k[3],N[4]=A[4]-k[4],N[5]=A[5]-k[5],N}function b(N,A,k){return N[0]=A[0]*k,N[1]=A[1]*k,N[2]=A[2]*k,N[3]=A[3]*k,N[4]=A[4]*k,N[5]=A[5]*k,N}function C(N,A,k,U){return N[0]=A[0]+k[0]*U,N[1]=A[1]+k[1]*U,N[2]=A[2]+k[2]*U,N[3]=A[3]+k[3]*U,N[4]=A[4]+k[4]*U,N[5]=A[5]+k[5]*U,N}function P(N,A){return N[0]===A[0]&&N[1]===A[1]&&N[2]===A[2]&&N[3]===A[3]&&N[4]===A[4]&&N[5]===A[5]}function E(N,A){var k=N[0],U=N[1],Z=N[2],Q=N[3],ce=N[4],L=N[5],W=A[0],H=A[1],$=A[2],ee=A[3],ie=A[4],le=A[5];return Math.abs(k-W)<=s.EPSILON*Math.max(1,Math.abs(k),Math.abs(W))&&Math.abs(U-H)<=s.EPSILON*Math.max(1,Math.abs(U),Math.abs(H))&&Math.abs(Z-$)<=s.EPSILON*Math.max(1,Math.abs(Z),Math.abs($))&&Math.abs(Q-ee)<=s.EPSILON*Math.max(1,Math.abs(Q),Math.abs(ee))&&Math.abs(ce-ie)<=s.EPSILON*Math.max(1,Math.abs(ce),Math.abs(ie))&&Math.abs(L-le)<=s.EPSILON*Math.max(1,Math.abs(L),Math.abs(le))}var O=p,V=T},function(e,r,n){n.r(r),n.d(r,"create",function(){return o}),n.d(r,"fromMat4",function(){return a}),n.d(r,"clone",function(){return c}),n.d(r,"copy",function(){return l}),n.d(r,"fromValues",function(){return u}),n.d(r,"set",function(){return h}),n.d(r,"identity",function(){return d}),n.d(r,"transpose",function(){return g}),n.d(r,"invert",function(){return p}),n.d(r,"adjoint",function(){return v}),n.d(r,"determinant",function(){return I}),n.d(r,"multiply",function(){return D}),n.d(r,"translate",function(){return x}),n.d(r,"rotate",function(){return j}),n.d(r,"scale",function(){return w}),n.d(r,"fromTranslation",function(){return y}),n.d(r,"fromRotation",function(){return f}),n.d(r,"fromScaling",function(){return M}),n.d(r,"fromMat2d",function(){return T}),n.d(r,"fromQuat",function(){return b}),n.d(r,"normalFromMat4",function(){return C}),n.d(r,"projection",function(){return P}),n.d(r,"str",function(){return E}),n.d(r,"frob",function(){return O}),n.d(r,"add",function(){return V}),n.d(r,"subtract",function(){return N}),n.d(r,"multiplyScalar",function(){return A}),n.d(r,"multiplyScalarAndAdd",function(){return k}),n.d(r,"exactEquals",function(){return U}),n.d(r,"equals",function(){return Z}),n.d(r,"mul",function(){return Q}),n.d(r,"sub",function(){return ce});var s=n(2);function o(){var L=new s.ARRAY_TYPE(9);return s.ARRAY_TYPE!=Float32Array&&(L[1]=0,L[2]=0,L[3]=0,L[5]=0,L[6]=0,L[7]=0),L[0]=1,L[4]=1,L[8]=1,L}function a(L,W){return L[0]=W[0],L[1]=W[1],L[2]=W[2],L[3]=W[4],L[4]=W[5],L[5]=W[6],L[6]=W[8],L[7]=W[9],L[8]=W[10],L}function c(L){var W=new s.ARRAY_TYPE(9);return W[0]=L[0],W[1]=L[1],W[2]=L[2],W[3]=L[3],W[4]=L[4],W[5]=L[5],W[6]=L[6],W[7]=L[7],W[8]=L[8],W}function l(L,W){return L[0]=W[0],L[1]=W[1],L[2]=W[2],L[3]=W[3],L[4]=W[4],L[5]=W[5],L[6]=W[6],L[7]=W[7],L[8]=W[8],L}function u(L,W,H,$,ee,ie,le,pe,Te){var z=new s.ARRAY_TYPE(9);return z[0]=L,z[1]=W,z[2]=H,z[3]=$,z[4]=ee,z[5]=ie,z[6]=le,z[7]=pe,z[8]=Te,z}function h(L,W,H,$,ee,ie,le,pe,Te,z){return L[0]=W,L[1]=H,L[2]=$,L[3]=ee,L[4]=ie,L[5]=le,L[6]=pe,L[7]=Te,L[8]=z,L}function d(L){return L[0]=1,L[1]=0,L[2]=0,L[3]=0,L[4]=1,L[5]=0,L[6]=0,L[7]=0,L[8]=1,L}function g(L,W){if(L===W){var H=W[1],$=W[2],ee=W[5];L[1]=W[3],L[2]=W[6],L[3]=H,L[5]=W[7],L[6]=$,L[7]=ee}else L[0]=W[0],L[1]=W[3],L[2]=W[6],L[3]=W[1],L[4]=W[4],L[5]=W[7],L[6]=W[2],L[7]=W[5],L[8]=W[8];return L}function p(L,W){var H=W[0],$=W[1],ee=W[2],ie=W[3],le=W[4],pe=W[5],Te=W[6],z=W[7],B=W[8],X=B*le-pe*z,ae=-B*ie+pe*Te,q=z*ie-le*Te,te=H*X+$*ae+ee*q;return te?(te=1/te,L[0]=X*te,L[1]=(-B*$+ee*z)*te,L[2]=(pe*$-ee*le)*te,L[3]=ae*te,L[4]=(B*H-ee*Te)*te,L[5]=(-pe*H+ee*ie)*te,L[6]=q*te,L[7]=(-z*H+$*Te)*te,L[8]=(le*H-$*ie)*te,L):null}function v(L,W){var H=W[0],$=W[1],ee=W[2],ie=W[3],le=W[4],pe=W[5],Te=W[6],z=W[7],B=W[8];return L[0]=le*B-pe*z,L[1]=ee*z-$*B,L[2]=$*pe-ee*le,L[3]=pe*Te-ie*B,L[4]=H*B-ee*Te,L[5]=ee*ie-H*pe,L[6]=ie*z-le*Te,L[7]=$*Te-H*z,L[8]=H*le-$*ie,L}function I(L){var W=L[0],H=L[1],$=L[2],ee=L[3],ie=L[4],le=L[5],pe=L[6],Te=L[7],z=L[8];return W*(z*ie-le*Te)+H*(-z*ee+le*pe)+$*(Te*ee-ie*pe)}function D(L,W,H){var $=W[0],ee=W[1],ie=W[2],le=W[3],pe=W[4],Te=W[5],z=W[6],B=W[7],X=W[8],ae=H[0],q=H[1],te=H[2],m=H[3],S=H[4],F=H[5],Y=H[6],_=H[7],re=H[8];return L[0]=ae*$+q*le+te*z,L[1]=ae*ee+q*pe+te*B,L[2]=ae*ie+q*Te+te*X,L[3]=m*$+S*le+F*z,L[4]=m*ee+S*pe+F*B,L[5]=m*ie+S*Te+F*X,L[6]=Y*$+_*le+re*z,L[7]=Y*ee+_*pe+re*B,L[8]=Y*ie+_*Te+re*X,L}function x(L,W,H){var $=W[0],ee=W[1],ie=W[2],le=W[3],pe=W[4],Te=W[5],z=W[6],B=W[7],X=W[8],ae=H[0],q=H[1];return L[0]=$,L[1]=ee,L[2]=ie,L[3]=le,L[4]=pe,L[5]=Te,L[6]=ae*$+q*le+z,L[7]=ae*ee+q*pe+B,L[8]=ae*ie+q*Te+X,L}function j(L,W,H){var $=W[0],ee=W[1],ie=W[2],le=W[3],pe=W[4],Te=W[5],z=W[6],B=W[7],X=W[8],ae=Math.sin(H),q=Math.cos(H);return L[0]=q*$+ae*le,L[1]=q*ee+ae*pe,L[2]=q*ie+ae*Te,L[3]=q*le-ae*$,L[4]=q*pe-ae*ee,L[5]=q*Te-ae*ie,L[6]=z,L[7]=B,L[8]=X,L}function w(L,W,H){var $=H[0],ee=H[1];return L[0]=$*W[0],L[1]=$*W[1],L[2]=$*W[2],L[3]=ee*W[3],L[4]=ee*W[4],L[5]=ee*W[5],L[6]=W[6],L[7]=W[7],L[8]=W[8],L}function y(L,W){return L[0]=1,L[1]=0,L[2]=0,L[3]=0,L[4]=1,L[5]=0,L[6]=W[0],L[7]=W[1],L[8]=1,L}function f(L,W){var H=Math.sin(W),$=Math.cos(W);return L[0]=$,L[1]=H,L[2]=0,L[3]=-H,L[4]=$,L[5]=0,L[6]=0,L[7]=0,L[8]=1,L}function M(L,W){return L[0]=W[0],L[1]=0,L[2]=0,L[3]=0,L[4]=W[1],L[5]=0,L[6]=0,L[7]=0,L[8]=1,L}function T(L,W){return L[0]=W[0],L[1]=W[1],L[2]=0,L[3]=W[2],L[4]=W[3],L[5]=0,L[6]=W[4],L[7]=W[5],L[8]=1,L}function b(L,W){var H=W[0],$=W[1],ee=W[2],ie=W[3],le=H+H,pe=$+$,Te=ee+ee,z=H*le,B=$*le,X=$*pe,ae=ee*le,q=ee*pe,te=ee*Te,m=ie*le,S=ie*pe,F=ie*Te;return L[0]=1-X-te,L[3]=B-F,L[6]=ae+S,L[1]=B+F,L[4]=1-z-te,L[7]=q-m,L[2]=ae-S,L[5]=q+m,L[8]=1-z-X,L}function C(L,W){var H=W[0],$=W[1],ee=W[2],ie=W[3],le=W[4],pe=W[5],Te=W[6],z=W[7],B=W[8],X=W[9],ae=W[10],q=W[11],te=W[12],m=W[13],S=W[14],F=W[15],Y=H*pe-$*le,_=H*Te-ee*le,re=H*z-ie*le,ne=$*Te-ee*pe,J=$*z-ie*pe,se=ee*z-ie*Te,ue=B*m-X*te,oe=B*S-ae*te,de=B*F-q*te,me=X*S-ae*m,ye=X*F-q*m,be=ae*F-q*S,Ce=Y*be-_*ye+re*me+ne*de-J*oe+se*ue;return Ce?(Ce=1/Ce,L[0]=(pe*be-Te*ye+z*me)*Ce,L[1]=(Te*de-le*be-z*oe)*Ce,L[2]=(le*ye-pe*de+z*ue)*Ce,L[3]=(ee*ye-$*be-ie*me)*Ce,L[4]=(H*be-ee*de+ie*oe)*Ce,L[5]=($*de-H*ye-ie*ue)*Ce,L[6]=(m*se-S*J+F*ne)*Ce,L[7]=(S*re-te*se-F*_)*Ce,L[8]=(te*J-m*re+F*Y)*Ce,L):null}function P(L,W,H){return L[0]=2/W,L[1]=0,L[2]=0,L[3]=0,L[4]=-2/H,L[5]=0,L[6]=-1,L[7]=1,L[8]=1,L}function E(L){return"mat3("+L[0]+", "+L[1]+", "+L[2]+", "+L[3]+", "+L[4]+", "+L[5]+", "+L[6]+", "+L[7]+", "+L[8]+")"}function O(L){return Math.hypot(L[0],L[1],L[2],L[3],L[4],L[5],L[6],L[7],L[8])}function V(L,W,H){return L[0]=W[0]+H[0],L[1]=W[1]+H[1],L[2]=W[2]+H[2],L[3]=W[3]+H[3],L[4]=W[4]+H[4],L[5]=W[5]+H[5],L[6]=W[6]+H[6],L[7]=W[7]+H[7],L[8]=W[8]+H[8],L}function N(L,W,H){return L[0]=W[0]-H[0],L[1]=W[1]-H[1],L[2]=W[2]-H[2],L[3]=W[3]-H[3],L[4]=W[4]-H[4],L[5]=W[5]-H[5],L[6]=W[6]-H[6],L[7]=W[7]-H[7],L[8]=W[8]-H[8],L}function A(L,W,H){return L[0]=W[0]*H,L[1]=W[1]*H,L[2]=W[2]*H,L[3]=W[3]*H,L[4]=W[4]*H,L[5]=W[5]*H,L[6]=W[6]*H,L[7]=W[7]*H,L[8]=W[8]*H,L}function k(L,W,H,$){return L[0]=W[0]+H[0]*$,L[1]=W[1]+H[1]*$,L[2]=W[2]+H[2]*$,L[3]=W[3]+H[3]*$,L[4]=W[4]+H[4]*$,L[5]=W[5]+H[5]*$,L[6]=W[6]+H[6]*$,L[7]=W[7]+H[7]*$,L[8]=W[8]+H[8]*$,L}function U(L,W){return L[0]===W[0]&&L[1]===W[1]&&L[2]===W[2]&&L[3]===W[3]&&L[4]===W[4]&&L[5]===W[5]&&L[6]===W[6]&&L[7]===W[7]&&L[8]===W[8]}function Z(L,W){var H=L[0],$=L[1],ee=L[2],ie=L[3],le=L[4],pe=L[5],Te=L[6],z=L[7],B=L[8],X=W[0],ae=W[1],q=W[2],te=W[3],m=W[4],S=W[5],F=W[6],Y=W[7],_=W[8];return Math.abs(H-X)<=s.EPSILON*Math.max(1,Math.abs(H),Math.abs(X))&&Math.abs($-ae)<=s.EPSILON*Math.max(1,Math.abs($),Math.abs(ae))&&Math.abs(ee-q)<=s.EPSILON*Math.max(1,Math.abs(ee),Math.abs(q))&&Math.abs(ie-te)<=s.EPSILON*Math.max(1,Math.abs(ie),Math.abs(te))&&Math.abs(le-m)<=s.EPSILON*Math.max(1,Math.abs(le),Math.abs(m))&&Math.abs(pe-S)<=s.EPSILON*Math.max(1,Math.abs(pe),Math.abs(S))&&Math.abs(Te-F)<=s.EPSILON*Math.max(1,Math.abs(Te),Math.abs(F))&&Math.abs(z-Y)<=s.EPSILON*Math.max(1,Math.abs(z),Math.abs(Y))&&Math.abs(B-_)<=s.EPSILON*Math.max(1,Math.abs(B),Math.abs(_))}var Q=D,ce=N},function(e,r,n){n.r(r),n.d(r,"create",function(){return o}),n.d(r,"clone",function(){return a}),n.d(r,"copy",function(){return c}),n.d(r,"fromValues",function(){return l}),n.d(r,"set",function(){return u}),n.d(r,"identity",function(){return h}),n.d(r,"transpose",function(){return d}),n.d(r,"invert",function(){return g}),n.d(r,"adjoint",function(){return p}),n.d(r,"determinant",function(){return v}),n.d(r,"multiply",function(){return I}),n.d(r,"translate",function(){return D}),n.d(r,"scale",function(){return x}),n.d(r,"rotate",function(){return j}),n.d(r,"rotateX",function(){return w}),n.d(r,"rotateY",function(){return y}),n.d(r,"rotateZ",function(){return f}),n.d(r,"fromTranslation",function(){return M}),n.d(r,"fromScaling",function(){return T}),n.d(r,"fromRotation",function(){return b}),n.d(r,"fromXRotation",function(){return C}),n.d(r,"fromYRotation",function(){return P}),n.d(r,"fromZRotation",function(){return E}),n.d(r,"fromRotationTranslation",function(){return O}),n.d(r,"fromQuat2",function(){return V}),n.d(r,"getTranslation",function(){return N}),n.d(r,"getScaling",function(){return A}),n.d(r,"getRotation",function(){return k}),n.d(r,"fromRotationTranslationScale",function(){return U}),n.d(r,"fromRotationTranslationScaleOrigin",function(){return Z}),n.d(r,"fromQuat",function(){return Q}),n.d(r,"frustum",function(){return ce}),n.d(r,"perspective",function(){return L}),n.d(r,"perspectiveFromFieldOfView",function(){return W}),n.d(r,"ortho",function(){return H}),n.d(r,"lookAt",function(){return $}),n.d(r,"targetTo",function(){return ee}),n.d(r,"str",function(){return ie}),n.d(r,"frob",function(){return le}),n.d(r,"add",function(){return pe}),n.d(r,"subtract",function(){return Te}),n.d(r,"multiplyScalar",function(){return z}),n.d(r,"multiplyScalarAndAdd",function(){return B}),n.d(r,"exactEquals",function(){return X}),n.d(r,"equals",function(){return ae}),n.d(r,"mul",function(){return q}),n.d(r,"sub",function(){return te});var s=n(2);function o(){var m=new s.ARRAY_TYPE(16);return s.ARRAY_TYPE!=Float32Array&&(m[1]=0,m[2]=0,m[3]=0,m[4]=0,m[6]=0,m[7]=0,m[8]=0,m[9]=0,m[11]=0,m[12]=0,m[13]=0,m[14]=0),m[0]=1,m[5]=1,m[10]=1,m[15]=1,m}function a(m){var S=new s.ARRAY_TYPE(16);return S[0]=m[0],S[1]=m[1],S[2]=m[2],S[3]=m[3],S[4]=m[4],S[5]=m[5],S[6]=m[6],S[7]=m[7],S[8]=m[8],S[9]=m[9],S[10]=m[10],S[11]=m[11],S[12]=m[12],S[13]=m[13],S[14]=m[14],S[15]=m[15],S}function c(m,S){return m[0]=S[0],m[1]=S[1],m[2]=S[2],m[3]=S[3],m[4]=S[4],m[5]=S[5],m[6]=S[6],m[7]=S[7],m[8]=S[8],m[9]=S[9],m[10]=S[10],m[11]=S[11],m[12]=S[12],m[13]=S[13],m[14]=S[14],m[15]=S[15],m}function l(m,S,F,Y,_,re,ne,J,se,ue,oe,de,me,ye,be,Ce){var Ie=new s.ARRAY_TYPE(16);return Ie[0]=m,Ie[1]=S,Ie[2]=F,Ie[3]=Y,Ie[4]=_,Ie[5]=re,Ie[6]=ne,Ie[7]=J,Ie[8]=se,Ie[9]=ue,Ie[10]=oe,Ie[11]=de,Ie[12]=me,Ie[13]=ye,Ie[14]=be,Ie[15]=Ce,Ie}function u(m,S,F,Y,_,re,ne,J,se,ue,oe,de,me,ye,be,Ce,Ie){return m[0]=S,m[1]=F,m[2]=Y,m[3]=_,m[4]=re,m[5]=ne,m[6]=J,m[7]=se,m[8]=ue,m[9]=oe,m[10]=de,m[11]=me,m[12]=ye,m[13]=be,m[14]=Ce,m[15]=Ie,m}function h(m){return m[0]=1,m[1]=0,m[2]=0,m[3]=0,m[4]=0,m[5]=1,m[6]=0,m[7]=0,m[8]=0,m[9]=0,m[10]=1,m[11]=0,m[12]=0,m[13]=0,m[14]=0,m[15]=1,m}function d(m,S){if(m===S){var F=S[1],Y=S[2],_=S[3],re=S[6],ne=S[7],J=S[11];m[1]=S[4],m[2]=S[8],m[3]=S[12],m[4]=F,m[6]=S[9],m[7]=S[13],m[8]=Y,m[9]=re,m[11]=S[14],m[12]=_,m[13]=ne,m[14]=J}else m[0]=S[0],m[1]=S[4],m[2]=S[8],m[3]=S[12],m[4]=S[1],m[5]=S[5],m[6]=S[9],m[7]=S[13],m[8]=S[2],m[9]=S[6],m[10]=S[10],m[11]=S[14],m[12]=S[3],m[13]=S[7],m[14]=S[11],m[15]=S[15];return m}function g(m,S){var F=S[0],Y=S[1],_=S[2],re=S[3],ne=S[4],J=S[5],se=S[6],ue=S[7],oe=S[8],de=S[9],me=S[10],ye=S[11],be=S[12],Ce=S[13],Ie=S[14],Pe=S[15],Re=F*J-Y*ne,ke=F*se-_*ne,Oe=F*ue-re*ne,je=Y*se-_*J,Be=Y*ue-re*J,Je=_*ue-re*se,tt=oe*Ce-de*be,rt=oe*Ie-me*be,nt=oe*Pe-ye*be,st=de*Ie-me*Ce,ut=de*Pe-ye*Ce,lt=me*Pe-ye*Ie,Ze=Re*lt-ke*ut+Oe*st+je*nt-Be*rt+Je*tt;return Ze?(Ze=1/Ze,m[0]=(J*lt-se*ut+ue*st)*Ze,m[1]=(_*ut-Y*lt-re*st)*Ze,m[2]=(Ce*Je-Ie*Be+Pe*je)*Ze,m[3]=(me*Be-de*Je-ye*je)*Ze,m[4]=(se*nt-ne*lt-ue*rt)*Ze,m[5]=(F*lt-_*nt+re*rt)*Ze,m[6]=(Ie*Oe-be*Je-Pe*ke)*Ze,m[7]=(oe*Je-me*Oe+ye*ke)*Ze,m[8]=(ne*ut-J*nt+ue*tt)*Ze,m[9]=(Y*nt-F*ut-re*tt)*Ze,m[10]=(be*Be-Ce*Oe+Pe*Re)*Ze,m[11]=(de*Oe-oe*Be-ye*Re)*Ze,m[12]=(J*rt-ne*st-se*tt)*Ze,m[13]=(F*st-Y*rt+_*tt)*Ze,m[14]=(Ce*ke-be*je-Ie*Re)*Ze,m[15]=(oe*je-de*ke+me*Re)*Ze,m):null}function p(m,S){var F=S[0],Y=S[1],_=S[2],re=S[3],ne=S[4],J=S[5],se=S[6],ue=S[7],oe=S[8],de=S[9],me=S[10],ye=S[11],be=S[12],Ce=S[13],Ie=S[14],Pe=S[15];return m[0]=J*(me*Pe-ye*Ie)-de*(se*Pe-ue*Ie)+Ce*(se*ye-ue*me),m[1]=-(Y*(me*Pe-ye*Ie)-de*(_*Pe-re*Ie)+Ce*(_*ye-re*me)),m[2]=Y*(se*Pe-ue*Ie)-J*(_*Pe-re*Ie)+Ce*(_*ue-re*se),m[3]=-(Y*(se*ye-ue*me)-J*(_*ye-re*me)+de*(_*ue-re*se)),m[4]=-(ne*(me*Pe-ye*Ie)-oe*(se*Pe-ue*Ie)+be*(se*ye-ue*me)),m[5]=F*(me*Pe-ye*Ie)-oe*(_*Pe-re*Ie)+be*(_*ye-re*me),m[6]=-(F*(se*Pe-ue*Ie)-ne*(_*Pe-re*Ie)+be*(_*ue-re*se)),m[7]=F*(se*ye-ue*me)-ne*(_*ye-re*me)+oe*(_*ue-re*se),m[8]=ne*(de*Pe-ye*Ce)-oe*(J*Pe-ue*Ce)+be*(J*ye-ue*de),m[9]=-(F*(de*Pe-ye*Ce)-oe*(Y*Pe-re*Ce)+be*(Y*ye-re*de)),m[10]=F*(J*Pe-ue*Ce)-ne*(Y*Pe-re*Ce)+be*(Y*ue-re*J),m[11]=-(F*(J*ye-ue*de)-ne*(Y*ye-re*de)+oe*(Y*ue-re*J)),m[12]=-(ne*(de*Ie-me*Ce)-oe*(J*Ie-se*Ce)+be*(J*me-se*de)),m[13]=F*(de*Ie-me*Ce)-oe*(Y*Ie-_*Ce)+be*(Y*me-_*de),m[14]=-(F*(J*Ie-se*Ce)-ne*(Y*Ie-_*Ce)+be*(Y*se-_*J)),m[15]=F*(J*me-se*de)-ne*(Y*me-_*de)+oe*(Y*se-_*J),m}function v(m){var S=m[0],F=m[1],Y=m[2],_=m[3],re=m[4],ne=m[5],J=m[6],se=m[7],ue=m[8],oe=m[9],de=m[10],me=m[11],ye=m[12],be=m[13],Ce=m[14],Ie=m[15],Pe=S*ne-F*re,Re=S*J-Y*re,ke=S*se-_*re,Oe=F*J-Y*ne,je=F*se-_*ne,Be=Y*se-_*J,Je=ue*be-oe*ye,tt=ue*Ce-de*ye,rt=ue*Ie-me*ye,nt=oe*Ce-de*be,st=oe*Ie-me*be,ut=de*Ie-me*Ce;return Pe*ut-Re*st+ke*nt+Oe*rt-je*tt+Be*Je}function I(m,S,F){var Y=S[0],_=S[1],re=S[2],ne=S[3],J=S[4],se=S[5],ue=S[6],oe=S[7],de=S[8],me=S[9],ye=S[10],be=S[11],Ce=S[12],Ie=S[13],Pe=S[14],Re=S[15],ke=F[0],Oe=F[1],je=F[2],Be=F[3];return m[0]=ke*Y+Oe*J+je*de+Be*Ce,m[1]=ke*_+Oe*se+je*me+Be*Ie,m[2]=ke*re+Oe*ue+je*ye+Be*Pe,m[3]=ke*ne+Oe*oe+je*be+Be*Re,ke=F[4],Oe=F[5],je=F[6],Be=F[7],m[4]=ke*Y+Oe*J+je*de+Be*Ce,m[5]=ke*_+Oe*se+je*me+Be*Ie,m[6]=ke*re+Oe*ue+je*ye+Be*Pe,m[7]=ke*ne+Oe*oe+je*be+Be*Re,ke=F[8],Oe=F[9],je=F[10],Be=F[11],m[8]=ke*Y+Oe*J+je*de+Be*Ce,m[9]=ke*_+Oe*se+je*me+Be*Ie,m[10]=ke*re+Oe*ue+je*ye+Be*Pe,m[11]=ke*ne+Oe*oe+je*be+Be*Re,ke=F[12],Oe=F[13],je=F[14],Be=F[15],m[12]=ke*Y+Oe*J+je*de+Be*Ce,m[13]=ke*_+Oe*se+je*me+Be*Ie,m[14]=ke*re+Oe*ue+je*ye+Be*Pe,m[15]=ke*ne+Oe*oe+je*be+Be*Re,m}function D(m,S,F){var Y=F[0],_=F[1],re=F[2],ne,J,se,ue,oe,de,me,ye,be,Ce,Ie,Pe;return S===m?(m[12]=S[0]*Y+S[4]*_+S[8]*re+S[12],m[13]=S[1]*Y+S[5]*_+S[9]*re+S[13],m[14]=S[2]*Y+S[6]*_+S[10]*re+S[14],m[15]=S[3]*Y+S[7]*_+S[11]*re+S[15]):(ne=S[0],J=S[1],se=S[2],ue=S[3],oe=S[4],de=S[5],me=S[6],ye=S[7],be=S[8],Ce=S[9],Ie=S[10],Pe=S[11],m[0]=ne,m[1]=J,m[2]=se,m[3]=ue,m[4]=oe,m[5]=de,m[6]=me,m[7]=ye,m[8]=be,m[9]=Ce,m[10]=Ie,m[11]=Pe,m[12]=ne*Y+oe*_+be*re+S[12],m[13]=J*Y+de*_+Ce*re+S[13],m[14]=se*Y+me*_+Ie*re+S[14],m[15]=ue*Y+ye*_+Pe*re+S[15]),m}function x(m,S,F){var Y=F[0],_=F[1],re=F[2];return m[0]=S[0]*Y,m[1]=S[1]*Y,m[2]=S[2]*Y,m[3]=S[3]*Y,m[4]=S[4]*_,m[5]=S[5]*_,m[6]=S[6]*_,m[7]=S[7]*_,m[8]=S[8]*re,m[9]=S[9]*re,m[10]=S[10]*re,m[11]=S[11]*re,m[12]=S[12],m[13]=S[13],m[14]=S[14],m[15]=S[15],m}function j(m,S,F,Y){var _=Y[0],re=Y[1],ne=Y[2],J=Math.hypot(_,re,ne),se,ue,oe,de,me,ye,be,Ce,Ie,Pe,Re,ke,Oe,je,Be,Je,tt,rt,nt,st,ut,lt,Ze,Ut;return J<s.EPSILON?null:(J=1/J,_*=J,re*=J,ne*=J,se=Math.sin(F),ue=Math.cos(F),oe=1-ue,de=S[0],me=S[1],ye=S[2],be=S[3],Ce=S[4],Ie=S[5],Pe=S[6],Re=S[7],ke=S[8],Oe=S[9],je=S[10],Be=S[11],Je=_*_*oe+ue,tt=re*_*oe+ne*se,rt=ne*_*oe-re*se,nt=_*re*oe-ne*se,st=re*re*oe+ue,ut=ne*re*oe+_*se,lt=_*ne*oe+re*se,Ze=re*ne*oe-_*se,Ut=ne*ne*oe+ue,m[0]=de*Je+Ce*tt+ke*rt,m[1]=me*Je+Ie*tt+Oe*rt,m[2]=ye*Je+Pe*tt+je*rt,m[3]=be*Je+Re*tt+Be*rt,m[4]=de*nt+Ce*st+ke*ut,m[5]=me*nt+Ie*st+Oe*ut,m[6]=ye*nt+Pe*st+je*ut,m[7]=be*nt+Re*st+Be*ut,m[8]=de*lt+Ce*Ze+ke*Ut,m[9]=me*lt+Ie*Ze+Oe*Ut,m[10]=ye*lt+Pe*Ze+je*Ut,m[11]=be*lt+Re*Ze+Be*Ut,S!==m&&(m[12]=S[12],m[13]=S[13],m[14]=S[14],m[15]=S[15]),m)}function w(m,S,F){var Y=Math.sin(F),_=Math.cos(F),re=S[4],ne=S[5],J=S[6],se=S[7],ue=S[8],oe=S[9],de=S[10],me=S[11];return S!==m&&(m[0]=S[0],m[1]=S[1],m[2]=S[2],m[3]=S[3],m[12]=S[12],m[13]=S[13],m[14]=S[14],m[15]=S[15]),m[4]=re*_+ue*Y,m[5]=ne*_+oe*Y,m[6]=J*_+de*Y,m[7]=se*_+me*Y,m[8]=ue*_-re*Y,m[9]=oe*_-ne*Y,m[10]=de*_-J*Y,m[11]=me*_-se*Y,m}function y(m,S,F){var Y=Math.sin(F),_=Math.cos(F),re=S[0],ne=S[1],J=S[2],se=S[3],ue=S[8],oe=S[9],de=S[10],me=S[11];return S!==m&&(m[4]=S[4],m[5]=S[5],m[6]=S[6],m[7]=S[7],m[12]=S[12],m[13]=S[13],m[14]=S[14],m[15]=S[15]),m[0]=re*_-ue*Y,m[1]=ne*_-oe*Y,m[2]=J*_-de*Y,m[3]=se*_-me*Y,m[8]=re*Y+ue*_,m[9]=ne*Y+oe*_,m[10]=J*Y+de*_,m[11]=se*Y+me*_,m}function f(m,S,F){var Y=Math.sin(F),_=Math.cos(F),re=S[0],ne=S[1],J=S[2],se=S[3],ue=S[4],oe=S[5],de=S[6],me=S[7];return S!==m&&(m[8]=S[8],m[9]=S[9],m[10]=S[10],m[11]=S[11],m[12]=S[12],m[13]=S[13],m[14]=S[14],m[15]=S[15]),m[0]=re*_+ue*Y,m[1]=ne*_+oe*Y,m[2]=J*_+de*Y,m[3]=se*_+me*Y,m[4]=ue*_-re*Y,m[5]=oe*_-ne*Y,m[6]=de*_-J*Y,m[7]=me*_-se*Y,m}function M(m,S){return m[0]=1,m[1]=0,m[2]=0,m[3]=0,m[4]=0,m[5]=1,m[6]=0,m[7]=0,m[8]=0,m[9]=0,m[10]=1,m[11]=0,m[12]=S[0],m[13]=S[1],m[14]=S[2],m[15]=1,m}function T(m,S){return m[0]=S[0],m[1]=0,m[2]=0,m[3]=0,m[4]=0,m[5]=S[1],m[6]=0,m[7]=0,m[8]=0,m[9]=0,m[10]=S[2],m[11]=0,m[12]=0,m[13]=0,m[14]=0,m[15]=1,m}function b(m,S,F){var Y=F[0],_=F[1],re=F[2],ne=Math.hypot(Y,_,re),J,se,ue;return ne<s.EPSILON?null:(ne=1/ne,Y*=ne,_*=ne,re*=ne,J=Math.sin(S),se=Math.cos(S),ue=1-se,m[0]=Y*Y*ue+se,m[1]=_*Y*ue+re*J,m[2]=re*Y*ue-_*J,m[3]=0,m[4]=Y*_*ue-re*J,m[5]=_*_*ue+se,m[6]=re*_*ue+Y*J,m[7]=0,m[8]=Y*re*ue+_*J,m[9]=_*re*ue-Y*J,m[10]=re*re*ue+se,m[11]=0,m[12]=0,m[13]=0,m[14]=0,m[15]=1,m)}function C(m,S){var F=Math.sin(S),Y=Math.cos(S);return m[0]=1,m[1]=0,m[2]=0,m[3]=0,m[4]=0,m[5]=Y,m[6]=F,m[7]=0,m[8]=0,m[9]=-F,m[10]=Y,m[11]=0,m[12]=0,m[13]=0,m[14]=0,m[15]=1,m}function P(m,S){var F=Math.sin(S),Y=Math.cos(S);return m[0]=Y,m[1]=0,m[2]=-F,m[3]=0,m[4]=0,m[5]=1,m[6]=0,m[7]=0,m[8]=F,m[9]=0,m[10]=Y,m[11]=0,m[12]=0,m[13]=0,m[14]=0,m[15]=1,m}function E(m,S){var F=Math.sin(S),Y=Math.cos(S);return m[0]=Y,m[1]=F,m[2]=0,m[3]=0,m[4]=-F,m[5]=Y,m[6]=0,m[7]=0,m[8]=0,m[9]=0,m[10]=1,m[11]=0,m[12]=0,m[13]=0,m[14]=0,m[15]=1,m}function O(m,S,F){var Y=S[0],_=S[1],re=S[2],ne=S[3],J=Y+Y,se=_+_,ue=re+re,oe=Y*J,de=Y*se,me=Y*ue,ye=_*se,be=_*ue,Ce=re*ue,Ie=ne*J,Pe=ne*se,Re=ne*ue;return m[0]=1-(ye+Ce),m[1]=de+Re,m[2]=me-Pe,m[3]=0,m[4]=de-Re,m[5]=1-(oe+Ce),m[6]=be+Ie,m[7]=0,m[8]=me+Pe,m[9]=be-Ie,m[10]=1-(oe+ye),m[11]=0,m[12]=F[0],m[13]=F[1],m[14]=F[2],m[15]=1,m}function V(m,S){var F=new s.ARRAY_TYPE(3),Y=-S[0],_=-S[1],re=-S[2],ne=S[3],J=S[4],se=S[5],ue=S[6],oe=S[7],de=Y*Y+_*_+re*re+ne*ne;return de>0?(F[0]=(J*ne+oe*Y+se*re-ue*_)*2/de,F[1]=(se*ne+oe*_+ue*Y-J*re)*2/de,F[2]=(ue*ne+oe*re+J*_-se*Y)*2/de):(F[0]=(J*ne+oe*Y+se*re-ue*_)*2,F[1]=(se*ne+oe*_+ue*Y-J*re)*2,F[2]=(ue*ne+oe*re+J*_-se*Y)*2),O(m,S,F),m}function N(m,S){return m[0]=S[12],m[1]=S[13],m[2]=S[14],m}function A(m,S){var F=S[0],Y=S[1],_=S[2],re=S[4],ne=S[5],J=S[6],se=S[8],ue=S[9],oe=S[10];return m[0]=Math.hypot(F,Y,_),m[1]=Math.hypot(re,ne,J),m[2]=Math.hypot(se,ue,oe),m}function k(m,S){var F=new s.ARRAY_TYPE(3);A(F,S);var Y=1/F[0],_=1/F[1],re=1/F[2],ne=S[0]*Y,J=S[1]*_,se=S[2]*re,ue=S[4]*Y,oe=S[5]*_,de=S[6]*re,me=S[8]*Y,ye=S[9]*_,be=S[10]*re,Ce=ne+oe+be,Ie=0;return Ce>0?(Ie=Math.sqrt(Ce+1)*2,m[3]=.25*Ie,m[0]=(de-ye)/Ie,m[1]=(me-se)/Ie,m[2]=(J-ue)/Ie):ne>oe&&ne>be?(Ie=Math.sqrt(1+ne-oe-be)*2,m[3]=(de-ye)/Ie,m[0]=.25*Ie,m[1]=(J+ue)/Ie,m[2]=(me+se)/Ie):oe>be?(Ie=Math.sqrt(1+oe-ne-be)*2,m[3]=(me-se)/Ie,m[0]=(J+ue)/Ie,m[1]=.25*Ie,m[2]=(de+ye)/Ie):(Ie=Math.sqrt(1+be-ne-oe)*2,m[3]=(J-ue)/Ie,m[0]=(me+se)/Ie,m[1]=(de+ye)/Ie,m[2]=.25*Ie),m}function U(m,S,F,Y){var _=S[0],re=S[1],ne=S[2],J=S[3],se=_+_,ue=re+re,oe=ne+ne,de=_*se,me=_*ue,ye=_*oe,be=re*ue,Ce=re*oe,Ie=ne*oe,Pe=J*se,Re=J*ue,ke=J*oe,Oe=Y[0],je=Y[1],Be=Y[2];return m[0]=(1-(be+Ie))*Oe,m[1]=(me+ke)*Oe,m[2]=(ye-Re)*Oe,m[3]=0,m[4]=(me-ke)*je,m[5]=(1-(de+Ie))*je,m[6]=(Ce+Pe)*je,m[7]=0,m[8]=(ye+Re)*Be,m[9]=(Ce-Pe)*Be,m[10]=(1-(de+be))*Be,m[11]=0,m[12]=F[0],m[13]=F[1],m[14]=F[2],m[15]=1,m}function Z(m,S,F,Y,_){var re=S[0],ne=S[1],J=S[2],se=S[3],ue=re+re,oe=ne+ne,de=J+J,me=re*ue,ye=re*oe,be=re*de,Ce=ne*oe,Ie=ne*de,Pe=J*de,Re=se*ue,ke=se*oe,Oe=se*de,je=Y[0],Be=Y[1],Je=Y[2],tt=_[0],rt=_[1],nt=_[2],st=(1-(Ce+Pe))*je,ut=(ye+Oe)*je,lt=(be-ke)*je,Ze=(ye-Oe)*Be,Ut=(1-(me+Pe))*Be,Dr=(Ie+Re)*Be,Pr=(be+ke)*Je,di=(Ie-Re)*Je,eo=(1-(me+Ce))*Je;return m[0]=st,m[1]=ut,m[2]=lt,m[3]=0,m[4]=Ze,m[5]=Ut,m[6]=Dr,m[7]=0,m[8]=Pr,m[9]=di,m[10]=eo,m[11]=0,m[12]=F[0]+tt-(st*tt+Ze*rt+Pr*nt),m[13]=F[1]+rt-(ut*tt+Ut*rt+di*nt),m[14]=F[2]+nt-(lt*tt+Dr*rt+eo*nt),m[15]=1,m}function Q(m,S){var F=S[0],Y=S[1],_=S[2],re=S[3],ne=F+F,J=Y+Y,se=_+_,ue=F*ne,oe=Y*ne,de=Y*J,me=_*ne,ye=_*J,be=_*se,Ce=re*ne,Ie=re*J,Pe=re*se;return m[0]=1-de-be,m[1]=oe+Pe,m[2]=me-Ie,m[3]=0,m[4]=oe-Pe,m[5]=1-ue-be,m[6]=ye+Ce,m[7]=0,m[8]=me+Ie,m[9]=ye-Ce,m[10]=1-ue-de,m[11]=0,m[12]=0,m[13]=0,m[14]=0,m[15]=1,m}function ce(m,S,F,Y,_,re,ne){var J=1/(F-S),se=1/(_-Y),ue=1/(re-ne);return m[0]=re*2*J,m[1]=0,m[2]=0,m[3]=0,m[4]=0,m[5]=re*2*se,m[6]=0,m[7]=0,m[8]=(F+S)*J,m[9]=(_+Y)*se,m[10]=(ne+re)*ue,m[11]=-1,m[12]=0,m[13]=0,m[14]=ne*re*2*ue,m[15]=0,m}function L(m,S,F,Y,_){var re=1/Math.tan(S/2),ne;return m[0]=re/F,m[1]=0,m[2]=0,m[3]=0,m[4]=0,m[5]=re,m[6]=0,m[7]=0,m[8]=0,m[9]=0,m[11]=-1,m[12]=0,m[13]=0,m[15]=0,_!=null&&_!==1/0?(ne=1/(Y-_),m[10]=(_+Y)*ne,m[14]=2*_*Y*ne):(m[10]=-1,m[14]=-2*Y),m}function W(m,S,F,Y){var _=Math.tan(S.upDegrees*Math.PI/180),re=Math.tan(S.downDegrees*Math.PI/180),ne=Math.tan(S.leftDegrees*Math.PI/180),J=Math.tan(S.rightDegrees*Math.PI/180),se=2/(ne+J),ue=2/(_+re);return m[0]=se,m[1]=0,m[2]=0,m[3]=0,m[4]=0,m[5]=ue,m[6]=0,m[7]=0,m[8]=-((ne-J)*se*.5),m[9]=(_-re)*ue*.5,m[10]=Y/(F-Y),m[11]=-1,m[12]=0,m[13]=0,m[14]=Y*F/(F-Y),m[15]=0,m}function H(m,S,F,Y,_,re,ne){var J=1/(S-F),se=1/(Y-_),ue=1/(re-ne);return m[0]=-2*J,m[1]=0,m[2]=0,m[3]=0,m[4]=0,m[5]=-2*se,m[6]=0,m[7]=0,m[8]=0,m[9]=0,m[10]=2*ue,m[11]=0,m[12]=(S+F)*J,m[13]=(_+Y)*se,m[14]=(ne+re)*ue,m[15]=1,m}function $(m,S,F,Y){var _,re,ne,J,se,ue,oe,de,me,ye,be=S[0],Ce=S[1],Ie=S[2],Pe=Y[0],Re=Y[1],ke=Y[2],Oe=F[0],je=F[1],Be=F[2];return Math.abs(be-Oe)<s.EPSILON&&Math.abs(Ce-je)<s.EPSILON&&Math.abs(Ie-Be)<s.EPSILON?h(m):(oe=be-Oe,de=Ce-je,me=Ie-Be,ye=1/Math.hypot(oe,de,me),oe*=ye,de*=ye,me*=ye,_=Re*me-ke*de,re=ke*oe-Pe*me,ne=Pe*de-Re*oe,ye=Math.hypot(_,re,ne),ye?(ye=1/ye,_*=ye,re*=ye,ne*=ye):(_=0,re=0,ne=0),J=de*ne-me*re,se=me*_-oe*ne,ue=oe*re-de*_,ye=Math.hypot(J,se,ue),ye?(ye=1/ye,J*=ye,se*=ye,ue*=ye):(J=0,se=0,ue=0),m[0]=_,m[1]=J,m[2]=oe,m[3]=0,m[4]=re,m[5]=se,m[6]=de,m[7]=0,m[8]=ne,m[9]=ue,m[10]=me,m[11]=0,m[12]=-(_*be+re*Ce+ne*Ie),m[13]=-(J*be+se*Ce+ue*Ie),m[14]=-(oe*be+de*Ce+me*Ie),m[15]=1,m)}function ee(m,S,F,Y){var _=S[0],re=S[1],ne=S[2],J=Y[0],se=Y[1],ue=Y[2],oe=_-F[0],de=re-F[1],me=ne-F[2],ye=oe*oe+de*de+me*me;ye>0&&(ye=1/Math.sqrt(ye),oe*=ye,de*=ye,me*=ye);var be=se*me-ue*de,Ce=ue*oe-J*me,Ie=J*de-se*oe;return ye=be*be+Ce*Ce+Ie*Ie,ye>0&&(ye=1/Math.sqrt(ye),be*=ye,Ce*=ye,Ie*=ye),m[0]=be,m[1]=Ce,m[2]=Ie,m[3]=0,m[4]=de*Ie-me*Ce,m[5]=me*be-oe*Ie,m[6]=oe*Ce-de*be,m[7]=0,m[8]=oe,m[9]=de,m[10]=me,m[11]=0,m[12]=_,m[13]=re,m[14]=ne,m[15]=1,m}function ie(m){return"mat4("+m[0]+", "+m[1]+", "+m[2]+", "+m[3]+", "+m[4]+", "+m[5]+", "+m[6]+", "+m[7]+", "+m[8]+", "+m[9]+", "+m[10]+", "+m[11]+", "+m[12]+", "+m[13]+", "+m[14]+", "+m[15]+")"}function le(m){return Math.hypot(m[0],m[1],m[2],m[3],m[4],m[5],m[6],m[7],m[8],m[9],m[10],m[11],m[12],m[13],m[14],m[15])}function pe(m,S,F){return m[0]=S[0]+F[0],m[1]=S[1]+F[1],m[2]=S[2]+F[2],m[3]=S[3]+F[3],m[4]=S[4]+F[4],m[5]=S[5]+F[5],m[6]=S[6]+F[6],m[7]=S[7]+F[7],m[8]=S[8]+F[8],m[9]=S[9]+F[9],m[10]=S[10]+F[10],m[11]=S[11]+F[11],m[12]=S[12]+F[12],m[13]=S[13]+F[13],m[14]=S[14]+F[14],m[15]=S[15]+F[15],m}function Te(m,S,F){return m[0]=S[0]-F[0],m[1]=S[1]-F[1],m[2]=S[2]-F[2],m[3]=S[3]-F[3],m[4]=S[4]-F[4],m[5]=S[5]-F[5],m[6]=S[6]-F[6],m[7]=S[7]-F[7],m[8]=S[8]-F[8],m[9]=S[9]-F[9],m[10]=S[10]-F[10],m[11]=S[11]-F[11],m[12]=S[12]-F[12],m[13]=S[13]-F[13],m[14]=S[14]-F[14],m[15]=S[15]-F[15],m}function z(m,S,F){return m[0]=S[0]*F,m[1]=S[1]*F,m[2]=S[2]*F,m[3]=S[3]*F,m[4]=S[4]*F,m[5]=S[5]*F,m[6]=S[6]*F,m[7]=S[7]*F,m[8]=S[8]*F,m[9]=S[9]*F,m[10]=S[10]*F,m[11]=S[11]*F,m[12]=S[12]*F,m[13]=S[13]*F,m[14]=S[14]*F,m[15]=S[15]*F,m}function B(m,S,F,Y){return m[0]=S[0]+F[0]*Y,m[1]=S[1]+F[1]*Y,m[2]=S[2]+F[2]*Y,m[3]=S[3]+F[3]*Y,m[4]=S[4]+F[4]*Y,m[5]=S[5]+F[5]*Y,m[6]=S[6]+F[6]*Y,m[7]=S[7]+F[7]*Y,m[8]=S[8]+F[8]*Y,m[9]=S[9]+F[9]*Y,m[10]=S[10]+F[10]*Y,m[11]=S[11]+F[11]*Y,m[12]=S[12]+F[12]*Y,m[13]=S[13]+F[13]*Y,m[14]=S[14]+F[14]*Y,m[15]=S[15]+F[15]*Y,m}function X(m,S){return m[0]===S[0]&&m[1]===S[1]&&m[2]===S[2]&&m[3]===S[3]&&m[4]===S[4]&&m[5]===S[5]&&m[6]===S[6]&&m[7]===S[7]&&m[8]===S[8]&&m[9]===S[9]&&m[10]===S[10]&&m[11]===S[11]&&m[12]===S[12]&&m[13]===S[13]&&m[14]===S[14]&&m[15]===S[15]}function ae(m,S){var F=m[0],Y=m[1],_=m[2],re=m[3],ne=m[4],J=m[5],se=m[6],ue=m[7],oe=m[8],de=m[9],me=m[10],ye=m[11],be=m[12],Ce=m[13],Ie=m[14],Pe=m[15],Re=S[0],ke=S[1],Oe=S[2],je=S[3],Be=S[4],Je=S[5],tt=S[6],rt=S[7],nt=S[8],st=S[9],ut=S[10],lt=S[11],Ze=S[12],Ut=S[13],Dr=S[14],Pr=S[15];return Math.abs(F-Re)<=s.EPSILON*Math.max(1,Math.abs(F),Math.abs(Re))&&Math.abs(Y-ke)<=s.EPSILON*Math.max(1,Math.abs(Y),Math.abs(ke))&&Math.abs(_-Oe)<=s.EPSILON*Math.max(1,Math.abs(_),Math.abs(Oe))&&Math.abs(re-je)<=s.EPSILON*Math.max(1,Math.abs(re),Math.abs(je))&&Math.abs(ne-Be)<=s.EPSILON*Math.max(1,Math.abs(ne),Math.abs(Be))&&Math.abs(J-Je)<=s.EPSILON*Math.max(1,Math.abs(J),Math.abs(Je))&&Math.abs(se-tt)<=s.EPSILON*Math.max(1,Math.abs(se),Math.abs(tt))&&Math.abs(ue-rt)<=s.EPSILON*Math.max(1,Math.abs(ue),Math.abs(rt))&&Math.abs(oe-nt)<=s.EPSILON*Math.max(1,Math.abs(oe),Math.abs(nt))&&Math.abs(de-st)<=s.EPSILON*Math.max(1,Math.abs(de),Math.abs(st))&&Math.abs(me-ut)<=s.EPSILON*Math.max(1,Math.abs(me),Math.abs(ut))&&Math.abs(ye-lt)<=s.EPSILON*Math.max(1,Math.abs(ye),Math.abs(lt))&&Math.abs(be-Ze)<=s.EPSILON*Math.max(1,Math.abs(be),Math.abs(Ze))&&Math.abs(Ce-Ut)<=s.EPSILON*Math.max(1,Math.abs(Ce),Math.abs(Ut))&&Math.abs(Ie-Dr)<=s.EPSILON*Math.max(1,Math.abs(Ie),Math.abs(Dr))&&Math.abs(Pe-Pr)<=s.EPSILON*Math.max(1,Math.abs(Pe),Math.abs(Pr))}var q=I,te=Te},function(e,r,n){n.r(r),n.d(r,"create",function(){return l}),n.d(r,"identity",function(){return u}),n.d(r,"setAxisAngle",function(){return h}),n.d(r,"getAxisAngle",function(){return d}),n.d(r,"getAngle",function(){return g}),n.d(r,"multiply",function(){return p}),n.d(r,"rotateX",function(){return v}),n.d(r,"rotateY",function(){return I}),n.d(r,"rotateZ",function(){return D}),n.d(r,"calculateW",function(){return x}),n.d(r,"exp",function(){return j}),n.d(r,"ln",function(){return w}),n.d(r,"pow",function(){return y}),n.d(r,"slerp",function(){return f}),n.d(r,"random",function(){return M}),n.d(r,"invert",function(){return T}),n.d(r,"conjugate",function(){return b}),n.d(r,"fromMat3",function(){return C}),n.d(r,"fromEuler",function(){return P}),n.d(r,"str",function(){return E}),n.d(r,"clone",function(){return O}),n.d(r,"fromValues",function(){return V}),n.d(r,"copy",function(){return N}),n.d(r,"set",function(){return A}),n.d(r,"add",function(){return k}),n.d(r,"mul",function(){return U}),n.d(r,"scale",function(){return Z}),n.d(r,"dot",function(){return Q}),n.d(r,"lerp",function(){return ce}),n.d(r,"length",function(){return L}),n.d(r,"len",function(){return W}),n.d(r,"squaredLength",function(){return H}),n.d(r,"sqrLen",function(){return $}),n.d(r,"normalize",function(){return ee}),n.d(r,"exactEquals",function(){return ie}),n.d(r,"equals",function(){return le}),n.d(r,"rotationTo",function(){return pe}),n.d(r,"sqlerp",function(){return Te}),n.d(r,"setAxes",function(){return z});var s=n(2),o=n(5),a=n(8),c=n(9);function l(){var B=new s.ARRAY_TYPE(4);return s.ARRAY_TYPE!=Float32Array&&(B[0]=0,B[1]=0,B[2]=0),B[3]=1,B}function u(B){return B[0]=0,B[1]=0,B[2]=0,B[3]=1,B}function h(B,X,ae){ae=ae*.5;var q=Math.sin(ae);return B[0]=q*X[0],B[1]=q*X[1],B[2]=q*X[2],B[3]=Math.cos(ae),B}function d(B,X){var ae=Math.acos(X[3])*2,q=Math.sin(ae/2);return q>s.EPSILON?(B[0]=X[0]/q,B[1]=X[1]/q,B[2]=X[2]/q):(B[0]=1,B[1]=0,B[2]=0),ae}function g(B,X){var ae=Q(B,X);return Math.acos(2*ae*ae-1)}function p(B,X,ae){var q=X[0],te=X[1],m=X[2],S=X[3],F=ae[0],Y=ae[1],_=ae[2],re=ae[3];return B[0]=q*re+S*F+te*_-m*Y,B[1]=te*re+S*Y+m*F-q*_,B[2]=m*re+S*_+q*Y-te*F,B[3]=S*re-q*F-te*Y-m*_,B}function v(B,X,ae){ae*=.5;var q=X[0],te=X[1],m=X[2],S=X[3],F=Math.sin(ae),Y=Math.cos(ae);return B[0]=q*Y+S*F,B[1]=te*Y+m*F,B[2]=m*Y-te*F,B[3]=S*Y-q*F,B}function I(B,X,ae){ae*=.5;var q=X[0],te=X[1],m=X[2],S=X[3],F=Math.sin(ae),Y=Math.cos(ae);return B[0]=q*Y-m*F,B[1]=te*Y+S*F,B[2]=m*Y+q*F,B[3]=S*Y-te*F,B}function D(B,X,ae){ae*=.5;var q=X[0],te=X[1],m=X[2],S=X[3],F=Math.sin(ae),Y=Math.cos(ae);return B[0]=q*Y+te*F,B[1]=te*Y-q*F,B[2]=m*Y+S*F,B[3]=S*Y-m*F,B}function x(B,X){var ae=X[0],q=X[1],te=X[2];return B[0]=ae,B[1]=q,B[2]=te,B[3]=Math.sqrt(Math.abs(1-ae*ae-q*q-te*te)),B}function j(B,X){var ae=X[0],q=X[1],te=X[2],m=X[3],S=Math.sqrt(ae*ae+q*q+te*te),F=Math.exp(m),Y=S>0?F*Math.sin(S)/S:0;return B[0]=ae*Y,B[1]=q*Y,B[2]=te*Y,B[3]=F*Math.cos(S),B}function w(B,X){var ae=X[0],q=X[1],te=X[2],m=X[3],S=Math.sqrt(ae*ae+q*q+te*te),F=S>0?Math.atan2(S,m)/S:0;return B[0]=ae*F,B[1]=q*F,B[2]=te*F,B[3]=.5*Math.log(ae*ae+q*q+te*te+m*m),B}function y(B,X,ae){return w(B,X),Z(B,B,ae),j(B,B),B}function f(B,X,ae,q){var te=X[0],m=X[1],S=X[2],F=X[3],Y=ae[0],_=ae[1],re=ae[2],ne=ae[3],J,se,ue,oe,de;return se=te*Y+m*_+S*re+F*ne,se<0&&(se=-se,Y=-Y,_=-_,re=-re,ne=-ne),1-se>s.EPSILON?(J=Math.acos(se),ue=Math.sin(J),oe=Math.sin((1-q)*J)/ue,de=Math.sin(q*J)/ue):(oe=1-q,de=q),B[0]=oe*te+de*Y,B[1]=oe*m+de*_,B[2]=oe*S+de*re,B[3]=oe*F+de*ne,B}function M(B){var X=s.RANDOM(),ae=s.RANDOM(),q=s.RANDOM(),te=Math.sqrt(1-X),m=Math.sqrt(X);return B[0]=te*Math.sin(2*Math.PI*ae),B[1]=te*Math.cos(2*Math.PI*ae),B[2]=m*Math.sin(2*Math.PI*q),B[3]=m*Math.cos(2*Math.PI*q),B}function T(B,X){var ae=X[0],q=X[1],te=X[2],m=X[3],S=ae*ae+q*q+te*te+m*m,F=S?1/S:0;return B[0]=-ae*F,B[1]=-q*F,B[2]=-te*F,B[3]=m*F,B}function b(B,X){return B[0]=-X[0],B[1]=-X[1],B[2]=-X[2],B[3]=X[3],B}function C(B,X){var ae=X[0]+X[4]+X[8],q;if(ae>0)q=Math.sqrt(ae+1),B[3]=.5*q,q=.5/q,B[0]=(X[5]-X[7])*q,B[1]=(X[6]-X[2])*q,B[2]=(X[1]-X[3])*q;else{var te=0;X[4]>X[0]&&(te=1),X[8]>X[te*3+te]&&(te=2);var m=(te+1)%3,S=(te+2)%3;q=Math.sqrt(X[te*3+te]-X[m*3+m]-X[S*3+S]+1),B[te]=.5*q,q=.5/q,B[3]=(X[m*3+S]-X[S*3+m])*q,B[m]=(X[m*3+te]+X[te*3+m])*q,B[S]=(X[S*3+te]+X[te*3+S])*q}return B}function P(B,X,ae,q){var te=.5*Math.PI/180;X*=te,ae*=te,q*=te;var m=Math.sin(X),S=Math.cos(X),F=Math.sin(ae),Y=Math.cos(ae),_=Math.sin(q),re=Math.cos(q);return B[0]=m*Y*re-S*F*_,B[1]=S*F*re+m*Y*_,B[2]=S*Y*_-m*F*re,B[3]=S*Y*re+m*F*_,B}function E(B){return"quat("+B[0]+", "+B[1]+", "+B[2]+", "+B[3]+")"}var O=c.clone,V=c.fromValues,N=c.copy,A=c.set,k=c.add,U=p,Z=c.scale,Q=c.dot,ce=c.lerp,L=c.length,W=L,H=c.squaredLength,$=H,ee=c.normalize,ie=c.exactEquals,le=c.equals,pe=function(){var B=a.create(),X=a.fromValues(1,0,0),ae=a.fromValues(0,1,0);return function(q,te,m){var S=a.dot(te,m);return S<-.999999?(a.cross(B,X,te),a.len(B)<1e-6&&a.cross(B,ae,te),a.normalize(B,B),h(q,B,Math.PI),q):S>.999999?(q[0]=0,q[1]=0,q[2]=0,q[3]=1,q):(a.cross(B,te,m),q[0]=B[0],q[1]=B[1],q[2]=B[2],q[3]=1+S,ee(q,q))}}(),Te=function(){var B=l(),X=l();return function(ae,q,te,m,S,F){return f(B,q,S,F),f(X,te,m,F),f(ae,B,X,2*F*(1-F)),ae}}(),z=function(){var B=o.create();return function(X,ae,q,te){return B[0]=q[0],B[3]=q[1],B[6]=q[2],B[1]=te[0],B[4]=te[1],B[7]=te[2],B[2]=-ae[0],B[5]=-ae[1],B[8]=-ae[2],ee(X,C(X,B))}}()},function(e,r,n){n.r(r),n.d(r,"create",function(){return o}),n.d(r,"clone",function(){return a}),n.d(r,"length",function(){return c}),n.d(r,"fromValues",function(){return l}),n.d(r,"copy",function(){return u}),n.d(r,"set",function(){return h}),n.d(r,"add",function(){return d}),n.d(r,"subtract",function(){return g}),n.d(r,"multiply",function(){return p}),n.d(r,"divide",function(){return v}),n.d(r,"ceil",function(){return I}),n.d(r,"floor",function(){return D}),n.d(r,"min",function(){return x}),n.d(r,"max",function(){return j}),n.d(r,"round",function(){return w}),n.d(r,"scale",function(){return y}),n.d(r,"scaleAndAdd",function(){return f}),n.d(r,"distance",function(){return M}),n.d(r,"squaredDistance",function(){return T}),n.d(r,"squaredLength",function(){return b}),n.d(r,"negate",function(){return C}),n.d(r,"inverse",function(){return P}),n.d(r,"normalize",function(){return E}),n.d(r,"dot",function(){return O}),n.d(r,"cross",function(){return V}),n.d(r,"lerp",function(){return N}),n.d(r,"hermite",function(){return A}),n.d(r,"bezier",function(){return k}),n.d(r,"random",function(){return U}),n.d(r,"transformMat4",function(){return Z}),n.d(r,"transformMat3",function(){return Q}),n.d(r,"transformQuat",function(){return ce}),n.d(r,"rotateX",function(){return L}),n.d(r,"rotateY",function(){return W}),n.d(r,"rotateZ",function(){return H}),n.d(r,"angle",function(){return $}),n.d(r,"zero",function(){return ee}),n.d(r,"str",function(){return ie}),n.d(r,"exactEquals",function(){return le}),n.d(r,"equals",function(){return pe}),n.d(r,"sub",function(){return Te}),n.d(r,"mul",function(){return z}),n.d(r,"div",function(){return B}),n.d(r,"dist",function(){return X}),n.d(r,"sqrDist",function(){return ae}),n.d(r,"len",function(){return q}),n.d(r,"sqrLen",function(){return te}),n.d(r,"forEach",function(){return m});var s=n(2);function o(){var S=new s.ARRAY_TYPE(3);return s.ARRAY_TYPE!=Float32Array&&(S[0]=0,S[1]=0,S[2]=0),S}function a(S){var F=new s.ARRAY_TYPE(3);return F[0]=S[0],F[1]=S[1],F[2]=S[2],F}function c(S){var F=S[0],Y=S[1],_=S[2];return Math.hypot(F,Y,_)}function l(S,F,Y){var _=new s.ARRAY_TYPE(3);return _[0]=S,_[1]=F,_[2]=Y,_}function u(S,F){return S[0]=F[0],S[1]=F[1],S[2]=F[2],S}function h(S,F,Y,_){return S[0]=F,S[1]=Y,S[2]=_,S}function d(S,F,Y){return S[0]=F[0]+Y[0],S[1]=F[1]+Y[1],S[2]=F[2]+Y[2],S}function g(S,F,Y){return S[0]=F[0]-Y[0],S[1]=F[1]-Y[1],S[2]=F[2]-Y[2],S}function p(S,F,Y){return S[0]=F[0]*Y[0],S[1]=F[1]*Y[1],S[2]=F[2]*Y[2],S}function v(S,F,Y){return S[0]=F[0]/Y[0],S[1]=F[1]/Y[1],S[2]=F[2]/Y[2],S}function I(S,F){return S[0]=Math.ceil(F[0]),S[1]=Math.ceil(F[1]),S[2]=Math.ceil(F[2]),S}function D(S,F){return S[0]=Math.floor(F[0]),S[1]=Math.floor(F[1]),S[2]=Math.floor(F[2]),S}function x(S,F,Y){return S[0]=Math.min(F[0],Y[0]),S[1]=Math.min(F[1],Y[1]),S[2]=Math.min(F[2],Y[2]),S}function j(S,F,Y){return S[0]=Math.max(F[0],Y[0]),S[1]=Math.max(F[1],Y[1]),S[2]=Math.max(F[2],Y[2]),S}function w(S,F){return S[0]=Math.round(F[0]),S[1]=Math.round(F[1]),S[2]=Math.round(F[2]),S}function y(S,F,Y){return S[0]=F[0]*Y,S[1]=F[1]*Y,S[2]=F[2]*Y,S}function f(S,F,Y,_){return S[0]=F[0]+Y[0]*_,S[1]=F[1]+Y[1]*_,S[2]=F[2]+Y[2]*_,S}function M(S,F){var Y=F[0]-S[0],_=F[1]-S[1],re=F[2]-S[2];return Math.hypot(Y,_,re)}function T(S,F){var Y=F[0]-S[0],_=F[1]-S[1],re=F[2]-S[2];return Y*Y+_*_+re*re}function b(S){var F=S[0],Y=S[1],_=S[2];return F*F+Y*Y+_*_}function C(S,F){return S[0]=-F[0],S[1]=-F[1],S[2]=-F[2],S}function P(S,F){return S[0]=1/F[0],S[1]=1/F[1],S[2]=1/F[2],S}function E(S,F){var Y=F[0],_=F[1],re=F[2],ne=Y*Y+_*_+re*re;return ne>0&&(ne=1/Math.sqrt(ne)),S[0]=F[0]*ne,S[1]=F[1]*ne,S[2]=F[2]*ne,S}function O(S,F){return S[0]*F[0]+S[1]*F[1]+S[2]*F[2]}function V(S,F,Y){var _=F[0],re=F[1],ne=F[2],J=Y[0],se=Y[1],ue=Y[2];return S[0]=re*ue-ne*se,S[1]=ne*J-_*ue,S[2]=_*se-re*J,S}function N(S,F,Y,_){var re=F[0],ne=F[1],J=F[2];return S[0]=re+_*(Y[0]-re),S[1]=ne+_*(Y[1]-ne),S[2]=J+_*(Y[2]-J),S}function A(S,F,Y,_,re,ne){var J=ne*ne,se=J*(2*ne-3)+1,ue=J*(ne-2)+ne,oe=J*(ne-1),de=J*(3-2*ne);return S[0]=F[0]*se+Y[0]*ue+_[0]*oe+re[0]*de,S[1]=F[1]*se+Y[1]*ue+_[1]*oe+re[1]*de,S[2]=F[2]*se+Y[2]*ue+_[2]*oe+re[2]*de,S}function k(S,F,Y,_,re,ne){var J=1-ne,se=J*J,ue=ne*ne,oe=se*J,de=3*ne*se,me=3*ue*J,ye=ue*ne;return S[0]=F[0]*oe+Y[0]*de+_[0]*me+re[0]*ye,S[1]=F[1]*oe+Y[1]*de+_[1]*me+re[1]*ye,S[2]=F[2]*oe+Y[2]*de+_[2]*me+re[2]*ye,S}function U(S,F){F=F||1;var Y=s.RANDOM()*2*Math.PI,_=s.RANDOM()*2-1,re=Math.sqrt(1-_*_)*F;return S[0]=Math.cos(Y)*re,S[1]=Math.sin(Y)*re,S[2]=_*F,S}function Z(S,F,Y){var _=F[0],re=F[1],ne=F[2],J=Y[3]*_+Y[7]*re+Y[11]*ne+Y[15];return J=J||1,S[0]=(Y[0]*_+Y[4]*re+Y[8]*ne+Y[12])/J,S[1]=(Y[1]*_+Y[5]*re+Y[9]*ne+Y[13])/J,S[2]=(Y[2]*_+Y[6]*re+Y[10]*ne+Y[14])/J,S}function Q(S,F,Y){var _=F[0],re=F[1],ne=F[2];return S[0]=_*Y[0]+re*Y[3]+ne*Y[6],S[1]=_*Y[1]+re*Y[4]+ne*Y[7],S[2]=_*Y[2]+re*Y[5]+ne*Y[8],S}function ce(S,F,Y){var _=Y[0],re=Y[1],ne=Y[2],J=Y[3],se=F[0],ue=F[1],oe=F[2],de=re*oe-ne*ue,me=ne*se-_*oe,ye=_*ue-re*se,be=re*ye-ne*me,Ce=ne*de-_*ye,Ie=_*me-re*de,Pe=J*2;return de*=Pe,me*=Pe,ye*=Pe,be*=2,Ce*=2,Ie*=2,S[0]=se+de+be,S[1]=ue+me+Ce,S[2]=oe+ye+Ie,S}function L(S,F,Y,_){var re=[],ne=[];return re[0]=F[0]-Y[0],re[1]=F[1]-Y[1],re[2]=F[2]-Y[2],ne[0]=re[0],ne[1]=re[1]*Math.cos(_)-re[2]*Math.sin(_),ne[2]=re[1]*Math.sin(_)+re[2]*Math.cos(_),S[0]=ne[0]+Y[0],S[1]=ne[1]+Y[1],S[2]=ne[2]+Y[2],S}function W(S,F,Y,_){var re=[],ne=[];return re[0]=F[0]-Y[0],re[1]=F[1]-Y[1],re[2]=F[2]-Y[2],ne[0]=re[2]*Math.sin(_)+re[0]*Math.cos(_),ne[1]=re[1],ne[2]=re[2]*Math.cos(_)-re[0]*Math.sin(_),S[0]=ne[0]+Y[0],S[1]=ne[1]+Y[1],S[2]=ne[2]+Y[2],S}function H(S,F,Y,_){var re=[],ne=[];return re[0]=F[0]-Y[0],re[1]=F[1]-Y[1],re[2]=F[2]-Y[2],ne[0]=re[0]*Math.cos(_)-re[1]*Math.sin(_),ne[1]=re[0]*Math.sin(_)+re[1]*Math.cos(_),ne[2]=re[2],S[0]=ne[0]+Y[0],S[1]=ne[1]+Y[1],S[2]=ne[2]+Y[2],S}function $(S,F){var Y=S[0],_=S[1],re=S[2],ne=F[0],J=F[1],se=F[2],ue=Math.sqrt(Y*Y+_*_+re*re),oe=Math.sqrt(ne*ne+J*J+se*se),de=ue*oe,me=de&&O(S,F)/de;return Math.acos(Math.min(Math.max(me,-1),1))}function ee(S){return S[0]=0,S[1]=0,S[2]=0,S}function ie(S){return"vec3("+S[0]+", "+S[1]+", "+S[2]+")"}function le(S,F){return S[0]===F[0]&&S[1]===F[1]&&S[2]===F[2]}function pe(S,F){var Y=S[0],_=S[1],re=S[2],ne=F[0],J=F[1],se=F[2];return Math.abs(Y-ne)<=s.EPSILON*Math.max(1,Math.abs(Y),Math.abs(ne))&&Math.abs(_-J)<=s.EPSILON*Math.max(1,Math.abs(_),Math.abs(J))&&Math.abs(re-se)<=s.EPSILON*Math.max(1,Math.abs(re),Math.abs(se))}var Te=g,z=p,B=v,X=M,ae=T,q=c,te=b,m=function(){var S=o();return function(F,Y,_,re,ne,J){var se,ue;for(Y||(Y=3),_||(_=0),re?ue=Math.min(re*Y+_,F.length):ue=F.length,se=_;se<ue;se+=Y)S[0]=F[se],S[1]=F[se+1],S[2]=F[se+2],ne(S,S,J),F[se]=S[0],F[se+1]=S[1],F[se+2]=S[2];return F}}()},function(e,r,n){n.r(r),n.d(r,"create",function(){return o}),n.d(r,"clone",function(){return a}),n.d(r,"fromValues",function(){return c}),n.d(r,"copy",function(){return l}),n.d(r,"set",function(){return u}),n.d(r,"add",function(){return h}),n.d(r,"subtract",function(){return d}),n.d(r,"multiply",function(){return g}),n.d(r,"divide",function(){return p}),n.d(r,"ceil",function(){return v}),n.d(r,"floor",function(){return I}),n.d(r,"min",function(){return D}),n.d(r,"max",function(){return x}),n.d(r,"round",function(){return j}),n.d(r,"scale",function(){return w}),n.d(r,"scaleAndAdd",function(){return y}),n.d(r,"distance",function(){return f}),n.d(r,"squaredDistance",function(){return M}),n.d(r,"length",function(){return T}),n.d(r,"squaredLength",function(){return b}),n.d(r,"negate",function(){return C}),n.d(r,"inverse",function(){return P}),n.d(r,"normalize",function(){return E}),n.d(r,"dot",function(){return O}),n.d(r,"cross",function(){return V}),n.d(r,"lerp",function(){return N}),n.d(r,"random",function(){return A}),n.d(r,"transformMat4",function(){return k}),n.d(r,"transformQuat",function(){return U}),n.d(r,"zero",function(){return Z}),n.d(r,"str",function(){return Q}),n.d(r,"exactEquals",function(){return ce}),n.d(r,"equals",function(){return L}),n.d(r,"sub",function(){return W}),n.d(r,"mul",function(){return H}),n.d(r,"div",function(){return $}),n.d(r,"dist",function(){return ee}),n.d(r,"sqrDist",function(){return ie}),n.d(r,"len",function(){return le}),n.d(r,"sqrLen",function(){return pe}),n.d(r,"forEach",function(){return Te});var s=n(2);function o(){var z=new s.ARRAY_TYPE(4);return s.ARRAY_TYPE!=Float32Array&&(z[0]=0,z[1]=0,z[2]=0,z[3]=0),z}function a(z){var B=new s.ARRAY_TYPE(4);return B[0]=z[0],B[1]=z[1],B[2]=z[2],B[3]=z[3],B}function c(z,B,X,ae){var q=new s.ARRAY_TYPE(4);return q[0]=z,q[1]=B,q[2]=X,q[3]=ae,q}function l(z,B){return z[0]=B[0],z[1]=B[1],z[2]=B[2],z[3]=B[3],z}function u(z,B,X,ae,q){return z[0]=B,z[1]=X,z[2]=ae,z[3]=q,z}function h(z,B,X){return z[0]=B[0]+X[0],z[1]=B[1]+X[1],z[2]=B[2]+X[2],z[3]=B[3]+X[3],z}function d(z,B,X){return z[0]=B[0]-X[0],z[1]=B[1]-X[1],z[2]=B[2]-X[2],z[3]=B[3]-X[3],z}function g(z,B,X){return z[0]=B[0]*X[0],z[1]=B[1]*X[1],z[2]=B[2]*X[2],z[3]=B[3]*X[3],z}function p(z,B,X){return z[0]=B[0]/X[0],z[1]=B[1]/X[1],z[2]=B[2]/X[2],z[3]=B[3]/X[3],z}function v(z,B){return z[0]=Math.ceil(B[0]),z[1]=Math.ceil(B[1]),z[2]=Math.ceil(B[2]),z[3]=Math.ceil(B[3]),z}function I(z,B){return z[0]=Math.floor(B[0]),z[1]=Math.floor(B[1]),z[2]=Math.floor(B[2]),z[3]=Math.floor(B[3]),z}function D(z,B,X){return z[0]=Math.min(B[0],X[0]),z[1]=Math.min(B[1],X[1]),z[2]=Math.min(B[2],X[2]),z[3]=Math.min(B[3],X[3]),z}function x(z,B,X){return z[0]=Math.max(B[0],X[0]),z[1]=Math.max(B[1],X[1]),z[2]=Math.max(B[2],X[2]),z[3]=Math.max(B[3],X[3]),z}function j(z,B){return z[0]=Math.round(B[0]),z[1]=Math.round(B[1]),z[2]=Math.round(B[2]),z[3]=Math.round(B[3]),z}function w(z,B,X){return z[0]=B[0]*X,z[1]=B[1]*X,z[2]=B[2]*X,z[3]=B[3]*X,z}function y(z,B,X,ae){return z[0]=B[0]+X[0]*ae,z[1]=B[1]+X[1]*ae,z[2]=B[2]+X[2]*ae,z[3]=B[3]+X[3]*ae,z}function f(z,B){var X=B[0]-z[0],ae=B[1]-z[1],q=B[2]-z[2],te=B[3]-z[3];return Math.hypot(X,ae,q,te)}function M(z,B){var X=B[0]-z[0],ae=B[1]-z[1],q=B[2]-z[2],te=B[3]-z[3];return X*X+ae*ae+q*q+te*te}function T(z){var B=z[0],X=z[1],ae=z[2],q=z[3];return Math.hypot(B,X,ae,q)}function b(z){var B=z[0],X=z[1],ae=z[2],q=z[3];return B*B+X*X+ae*ae+q*q}function C(z,B){return z[0]=-B[0],z[1]=-B[1],z[2]=-B[2],z[3]=-B[3],z}function P(z,B){return z[0]=1/B[0],z[1]=1/B[1],z[2]=1/B[2],z[3]=1/B[3],z}function E(z,B){var X=B[0],ae=B[1],q=B[2],te=B[3],m=X*X+ae*ae+q*q+te*te;return m>0&&(m=1/Math.sqrt(m)),z[0]=X*m,z[1]=ae*m,z[2]=q*m,z[3]=te*m,z}function O(z,B){return z[0]*B[0]+z[1]*B[1]+z[2]*B[2]+z[3]*B[3]}function V(z,B,X,ae){var q=X[0]*ae[1]-X[1]*ae[0],te=X[0]*ae[2]-X[2]*ae[0],m=X[0]*ae[3]-X[3]*ae[0],S=X[1]*ae[2]-X[2]*ae[1],F=X[1]*ae[3]-X[3]*ae[1],Y=X[2]*ae[3]-X[3]*ae[2],_=B[0],re=B[1],ne=B[2],J=B[3];return z[0]=re*Y-ne*F+J*S,z[1]=-(_*Y)+ne*m-J*te,z[2]=_*F-re*m+J*q,z[3]=-(_*S)+re*te-ne*q,z}function N(z,B,X,ae){var q=B[0],te=B[1],m=B[2],S=B[3];return z[0]=q+ae*(X[0]-q),z[1]=te+ae*(X[1]-te),z[2]=m+ae*(X[2]-m),z[3]=S+ae*(X[3]-S),z}function A(z,B){B=B||1;var X,ae,q,te,m,S;do X=s.RANDOM()*2-1,ae=s.RANDOM()*2-1,m=X*X+ae*ae;while(m>=1);do q=s.RANDOM()*2-1,te=s.RANDOM()*2-1,S=q*q+te*te;while(S>=1);var F=Math.sqrt((1-m)/S);return z[0]=B*X,z[1]=B*ae,z[2]=B*q*F,z[3]=B*te*F,z}function k(z,B,X){var ae=B[0],q=B[1],te=B[2],m=B[3];return z[0]=X[0]*ae+X[4]*q+X[8]*te+X[12]*m,z[1]=X[1]*ae+X[5]*q+X[9]*te+X[13]*m,z[2]=X[2]*ae+X[6]*q+X[10]*te+X[14]*m,z[3]=X[3]*ae+X[7]*q+X[11]*te+X[15]*m,z}function U(z,B,X){var ae=B[0],q=B[1],te=B[2],m=X[0],S=X[1],F=X[2],Y=X[3],_=Y*ae+S*te-F*q,re=Y*q+F*ae-m*te,ne=Y*te+m*q-S*ae,J=-m*ae-S*q-F*te;return z[0]=_*Y+J*-m+re*-F-ne*-S,z[1]=re*Y+J*-S+ne*-m-_*-F,z[2]=ne*Y+J*-F+_*-S-re*-m,z[3]=B[3],z}function Z(z){return z[0]=0,z[1]=0,z[2]=0,z[3]=0,z}function Q(z){return"vec4("+z[0]+", "+z[1]+", "+z[2]+", "+z[3]+")"}function ce(z,B){return z[0]===B[0]&&z[1]===B[1]&&z[2]===B[2]&&z[3]===B[3]}function L(z,B){var X=z[0],ae=z[1],q=z[2],te=z[3],m=B[0],S=B[1],F=B[2],Y=B[3];return Math.abs(X-m)<=s.EPSILON*Math.max(1,Math.abs(X),Math.abs(m))&&Math.abs(ae-S)<=s.EPSILON*Math.max(1,Math.abs(ae),Math.abs(S))&&Math.abs(q-F)<=s.EPSILON*Math.max(1,Math.abs(q),Math.abs(F))&&Math.abs(te-Y)<=s.EPSILON*Math.max(1,Math.abs(te),Math.abs(Y))}var W=d,H=g,$=p,ee=f,ie=M,le=T,pe=b,Te=function(){var z=o();return function(B,X,ae,q,te,m){var S,F;for(X||(X=4),ae||(ae=0),q?F=Math.min(q*X+ae,B.length):F=B.length,S=ae;S<F;S+=X)z[0]=B[S],z[1]=B[S+1],z[2]=B[S+2],z[3]=B[S+3],te(z,z,m),B[S]=z[0],B[S+1]=z[1],B[S+2]=z[2],B[S+3]=z[3];return B}}()},function(e,r,n){n.r(r),n.d(r,"create",function(){return c}),n.d(r,"clone",function(){return l}),n.d(r,"fromValues",function(){return u}),n.d(r,"fromRotationTranslationValues",function(){return h}),n.d(r,"fromRotationTranslation",function(){return d}),n.d(r,"fromTranslation",function(){return g}),n.d(r,"fromRotation",function(){return p}),n.d(r,"fromMat4",function(){return v}),n.d(r,"copy",function(){return I}),n.d(r,"identity",function(){return D}),n.d(r,"set",function(){return x}),n.d(r,"getReal",function(){return j}),n.d(r,"getDual",function(){return w}),n.d(r,"setReal",function(){return y}),n.d(r,"setDual",function(){return f}),n.d(r,"getTranslation",function(){return M}),n.d(r,"translate",function(){return T}),n.d(r,"rotateX",function(){return b}),n.d(r,"rotateY",function(){return C}),n.d(r,"rotateZ",function(){return P}),n.d(r,"rotateByQuatAppend",function(){return E}),n.d(r,"rotateByQuatPrepend",function(){return O}),n.d(r,"rotateAroundAxis",function(){return V}),n.d(r,"add",function(){return N}),n.d(r,"multiply",function(){return A}),n.d(r,"mul",function(){return k}),n.d(r,"scale",function(){return U}),n.d(r,"dot",function(){return Z}),n.d(r,"lerp",function(){return Q}),n.d(r,"invert",function(){return ce}),n.d(r,"conjugate",function(){return L}),n.d(r,"length",function(){return W}),n.d(r,"len",function(){return H}),n.d(r,"squaredLength",function(){return $}),n.d(r,"sqrLen",function(){return ee}),n.d(r,"normalize",function(){return ie}),n.d(r,"str",function(){return le}),n.d(r,"exactEquals",function(){return pe}),n.d(r,"equals",function(){return Te});var s=n(2),o=n(7),a=n(6);function c(){var z=new s.ARRAY_TYPE(8);return s.ARRAY_TYPE!=Float32Array&&(z[0]=0,z[1]=0,z[2]=0,z[4]=0,z[5]=0,z[6]=0,z[7]=0),z[3]=1,z}function l(z){var B=new s.ARRAY_TYPE(8);return B[0]=z[0],B[1]=z[1],B[2]=z[2],B[3]=z[3],B[4]=z[4],B[5]=z[5],B[6]=z[6],B[7]=z[7],B}function u(z,B,X,ae,q,te,m,S){var F=new s.ARRAY_TYPE(8);return F[0]=z,F[1]=B,F[2]=X,F[3]=ae,F[4]=q,F[5]=te,F[6]=m,F[7]=S,F}function h(z,B,X,ae,q,te,m){var S=new s.ARRAY_TYPE(8);S[0]=z,S[1]=B,S[2]=X,S[3]=ae;var F=q*.5,Y=te*.5,_=m*.5;return S[4]=F*ae+Y*X-_*B,S[5]=Y*ae+_*z-F*X,S[6]=_*ae+F*B-Y*z,S[7]=-F*z-Y*B-_*X,S}function d(z,B,X){var ae=X[0]*.5,q=X[1]*.5,te=X[2]*.5,m=B[0],S=B[1],F=B[2],Y=B[3];return z[0]=m,z[1]=S,z[2]=F,z[3]=Y,z[4]=ae*Y+q*F-te*S,z[5]=q*Y+te*m-ae*F,z[6]=te*Y+ae*S-q*m,z[7]=-ae*m-q*S-te*F,z}function g(z,B){return z[0]=0,z[1]=0,z[2]=0,z[3]=1,z[4]=B[0]*.5,z[5]=B[1]*.5,z[6]=B[2]*.5,z[7]=0,z}function p(z,B){return z[0]=B[0],z[1]=B[1],z[2]=B[2],z[3]=B[3],z[4]=0,z[5]=0,z[6]=0,z[7]=0,z}function v(z,B){var X=o.create();a.getRotation(X,B);var ae=new s.ARRAY_TYPE(3);return a.getTranslation(ae,B),d(z,X,ae),z}function I(z,B){return z[0]=B[0],z[1]=B[1],z[2]=B[2],z[3]=B[3],z[4]=B[4],z[5]=B[5],z[6]=B[6],z[7]=B[7],z}function D(z){return z[0]=0,z[1]=0,z[2]=0,z[3]=1,z[4]=0,z[5]=0,z[6]=0,z[7]=0,z}function x(z,B,X,ae,q,te,m,S,F){return z[0]=B,z[1]=X,z[2]=ae,z[3]=q,z[4]=te,z[5]=m,z[6]=S,z[7]=F,z}var j=o.copy;function w(z,B){return z[0]=B[4],z[1]=B[5],z[2]=B[6],z[3]=B[7],z}var y=o.copy;function f(z,B){return z[4]=B[0],z[5]=B[1],z[6]=B[2],z[7]=B[3],z}function M(z,B){var X=B[4],ae=B[5],q=B[6],te=B[7],m=-B[0],S=-B[1],F=-B[2],Y=B[3];return z[0]=(X*Y+te*m+ae*F-q*S)*2,z[1]=(ae*Y+te*S+q*m-X*F)*2,z[2]=(q*Y+te*F+X*S-ae*m)*2,z}function T(z,B,X){var ae=B[0],q=B[1],te=B[2],m=B[3],S=X[0]*.5,F=X[1]*.5,Y=X[2]*.5,_=B[4],re=B[5],ne=B[6],J=B[7];return z[0]=ae,z[1]=q,z[2]=te,z[3]=m,z[4]=m*S+q*Y-te*F+_,z[5]=m*F+te*S-ae*Y+re,z[6]=m*Y+ae*F-q*S+ne,z[7]=-ae*S-q*F-te*Y+J,z}function b(z,B,X){var ae=-B[0],q=-B[1],te=-B[2],m=B[3],S=B[4],F=B[5],Y=B[6],_=B[7],re=S*m+_*ae+F*te-Y*q,ne=F*m+_*q+Y*ae-S*te,J=Y*m+_*te+S*q-F*ae,se=_*m-S*ae-F*q-Y*te;return o.rotateX(z,B,X),ae=z[0],q=z[1],te=z[2],m=z[3],z[4]=re*m+se*ae+ne*te-J*q,z[5]=ne*m+se*q+J*ae-re*te,z[6]=J*m+se*te+re*q-ne*ae,z[7]=se*m-re*ae-ne*q-J*te,z}function C(z,B,X){var ae=-B[0],q=-B[1],te=-B[2],m=B[3],S=B[4],F=B[5],Y=B[6],_=B[7],re=S*m+_*ae+F*te-Y*q,ne=F*m+_*q+Y*ae-S*te,J=Y*m+_*te+S*q-F*ae,se=_*m-S*ae-F*q-Y*te;return o.rotateY(z,B,X),ae=z[0],q=z[1],te=z[2],m=z[3],z[4]=re*m+se*ae+ne*te-J*q,z[5]=ne*m+se*q+J*ae-re*te,z[6]=J*m+se*te+re*q-ne*ae,z[7]=se*m-re*ae-ne*q-J*te,z}function P(z,B,X){var ae=-B[0],q=-B[1],te=-B[2],m=B[3],S=B[4],F=B[5],Y=B[6],_=B[7],re=S*m+_*ae+F*te-Y*q,ne=F*m+_*q+Y*ae-S*te,J=Y*m+_*te+S*q-F*ae,se=_*m-S*ae-F*q-Y*te;return o.rotateZ(z,B,X),ae=z[0],q=z[1],te=z[2],m=z[3],z[4]=re*m+se*ae+ne*te-J*q,z[5]=ne*m+se*q+J*ae-re*te,z[6]=J*m+se*te+re*q-ne*ae,z[7]=se*m-re*ae-ne*q-J*te,z}function E(z,B,X){var ae=X[0],q=X[1],te=X[2],m=X[3],S=B[0],F=B[1],Y=B[2],_=B[3];return z[0]=S*m+_*ae+F*te-Y*q,z[1]=F*m+_*q+Y*ae-S*te,z[2]=Y*m+_*te+S*q-F*ae,z[3]=_*m-S*ae-F*q-Y*te,S=B[4],F=B[5],Y=B[6],_=B[7],z[4]=S*m+_*ae+F*te-Y*q,z[5]=F*m+_*q+Y*ae-S*te,z[6]=Y*m+_*te+S*q-F*ae,z[7]=_*m-S*ae-F*q-Y*te,z}function O(z,B,X){var ae=B[0],q=B[1],te=B[2],m=B[3],S=X[0],F=X[1],Y=X[2],_=X[3];return z[0]=ae*_+m*S+q*Y-te*F,z[1]=q*_+m*F+te*S-ae*Y,z[2]=te*_+m*Y+ae*F-q*S,z[3]=m*_-ae*S-q*F-te*Y,S=X[4],F=X[5],Y=X[6],_=X[7],z[4]=ae*_+m*S+q*Y-te*F,z[5]=q*_+m*F+te*S-ae*Y,z[6]=te*_+m*Y+ae*F-q*S,z[7]=m*_-ae*S-q*F-te*Y,z}function V(z,B,X,ae){if(Math.abs(ae)<s.EPSILON)return I(z,B);var q=Math.hypot(X[0],X[1],X[2]);ae=ae*.5;var te=Math.sin(ae),m=te*X[0]/q,S=te*X[1]/q,F=te*X[2]/q,Y=Math.cos(ae),_=B[0],re=B[1],ne=B[2],J=B[3];z[0]=_*Y+J*m+re*F-ne*S,z[1]=re*Y+J*S+ne*m-_*F,z[2]=ne*Y+J*F+_*S-re*m,z[3]=J*Y-_*m-re*S-ne*F;var se=B[4],ue=B[5],oe=B[6],de=B[7];return z[4]=se*Y+de*m+ue*F-oe*S,z[5]=ue*Y+de*S+oe*m-se*F,z[6]=oe*Y+de*F+se*S-ue*m,z[7]=de*Y-se*m-ue*S-oe*F,z}function N(z,B,X){return z[0]=B[0]+X[0],z[1]=B[1]+X[1],z[2]=B[2]+X[2],z[3]=B[3]+X[3],z[4]=B[4]+X[4],z[5]=B[5]+X[5],z[6]=B[6]+X[6],z[7]=B[7]+X[7],z}function A(z,B,X){var ae=B[0],q=B[1],te=B[2],m=B[3],S=X[4],F=X[5],Y=X[6],_=X[7],re=B[4],ne=B[5],J=B[6],se=B[7],ue=X[0],oe=X[1],de=X[2],me=X[3];return z[0]=ae*me+m*ue+q*de-te*oe,z[1]=q*me+m*oe+te*ue-ae*de,z[2]=te*me+m*de+ae*oe-q*ue,z[3]=m*me-ae*ue-q*oe-te*de,z[4]=ae*_+m*S+q*Y-te*F+re*me+se*ue+ne*de-J*oe,z[5]=q*_+m*F+te*S-ae*Y+ne*me+se*oe+J*ue-re*de,z[6]=te*_+m*Y+ae*F-q*S+J*me+se*de+re*oe-ne*ue,z[7]=m*_-ae*S-q*F-te*Y+se*me-re*ue-ne*oe-J*de,z}var k=A;function U(z,B,X){return z[0]=B[0]*X,z[1]=B[1]*X,z[2]=B[2]*X,z[3]=B[3]*X,z[4]=B[4]*X,z[5]=B[5]*X,z[6]=B[6]*X,z[7]=B[7]*X,z}var Z=o.dot;function Q(z,B,X,ae){var q=1-ae;return Z(B,X)<0&&(ae=-ae),z[0]=B[0]*q+X[0]*ae,z[1]=B[1]*q+X[1]*ae,z[2]=B[2]*q+X[2]*ae,z[3]=B[3]*q+X[3]*ae,z[4]=B[4]*q+X[4]*ae,z[5]=B[5]*q+X[5]*ae,z[6]=B[6]*q+X[6]*ae,z[7]=B[7]*q+X[7]*ae,z}function ce(z,B){var X=$(B);return z[0]=-B[0]/X,z[1]=-B[1]/X,z[2]=-B[2]/X,z[3]=B[3]/X,z[4]=-B[4]/X,z[5]=-B[5]/X,z[6]=-B[6]/X,z[7]=B[7]/X,z}function L(z,B){return z[0]=-B[0],z[1]=-B[1],z[2]=-B[2],z[3]=B[3],z[4]=-B[4],z[5]=-B[5],z[6]=-B[6],z[7]=B[7],z}var W=o.length,H=W,$=o.squaredLength,ee=$;function ie(z,B){var X=$(B);if(X>0){X=Math.sqrt(X);var ae=B[0]/X,q=B[1]/X,te=B[2]/X,m=B[3]/X,S=B[4],F=B[5],Y=B[6],_=B[7],re=ae*S+q*F+te*Y+m*_;z[0]=ae,z[1]=q,z[2]=te,z[3]=m,z[4]=(S-ae*re)/X,z[5]=(F-q*re)/X,z[6]=(Y-te*re)/X,z[7]=(_-m*re)/X}return z}function le(z){return"quat2("+z[0]+", "+z[1]+", "+z[2]+", "+z[3]+", "+z[4]+", "+z[5]+", "+z[6]+", "+z[7]+")"}function pe(z,B){return z[0]===B[0]&&z[1]===B[1]&&z[2]===B[2]&&z[3]===B[3]&&z[4]===B[4]&&z[5]===B[5]&&z[6]===B[6]&&z[7]===B[7]}function Te(z,B){var X=z[0],ae=z[1],q=z[2],te=z[3],m=z[4],S=z[5],F=z[6],Y=z[7],_=B[0],re=B[1],ne=B[2],J=B[3],se=B[4],ue=B[5],oe=B[6],de=B[7];return Math.abs(X-_)<=s.EPSILON*Math.max(1,Math.abs(X),Math.abs(_))&&Math.abs(ae-re)<=s.EPSILON*Math.max(1,Math.abs(ae),Math.abs(re))&&Math.abs(q-ne)<=s.EPSILON*Math.max(1,Math.abs(q),Math.abs(ne))&&Math.abs(te-J)<=s.EPSILON*Math.max(1,Math.abs(te),Math.abs(J))&&Math.abs(m-se)<=s.EPSILON*Math.max(1,Math.abs(m),Math.abs(se))&&Math.abs(S-ue)<=s.EPSILON*Math.max(1,Math.abs(S),Math.abs(ue))&&Math.abs(F-oe)<=s.EPSILON*Math.max(1,Math.abs(F),Math.abs(oe))&&Math.abs(Y-de)<=s.EPSILON*Math.max(1,Math.abs(Y),Math.abs(de))}},function(e,r,n){n.r(r),n.d(r,"create",function(){return o}),n.d(r,"clone",function(){return a}),n.d(r,"fromValues",function(){return c}),n.d(r,"copy",function(){return l}),n.d(r,"set",function(){return u}),n.d(r,"add",function(){return h}),n.d(r,"subtract",function(){return d}),n.d(r,"multiply",function(){return g}),n.d(r,"divide",function(){return p}),n.d(r,"ceil",function(){return v}),n.d(r,"floor",function(){return I}),n.d(r,"min",function(){return D}),n.d(r,"max",function(){return x}),n.d(r,"round",function(){return j}),n.d(r,"scale",function(){return w}),n.d(r,"scaleAndAdd",function(){return y}),n.d(r,"distance",function(){return f}),n.d(r,"squaredDistance",function(){return M}),n.d(r,"length",function(){return T}),n.d(r,"squaredLength",function(){return b}),n.d(r,"negate",function(){return C}),n.d(r,"inverse",function(){return P}),n.d(r,"normalize",function(){return E}),n.d(r,"dot",function(){return O}),n.d(r,"cross",function(){return V}),n.d(r,"lerp",function(){return N}),n.d(r,"random",function(){return A}),n.d(r,"transformMat2",function(){return k}),n.d(r,"transformMat2d",function(){return U}),n.d(r,"transformMat3",function(){return Z}),n.d(r,"transformMat4",function(){return Q}),n.d(r,"rotate",function(){return ce}),n.d(r,"angle",function(){return L}),n.d(r,"zero",function(){return W}),n.d(r,"str",function(){return H}),n.d(r,"exactEquals",function(){return $}),n.d(r,"equals",function(){return ee}),n.d(r,"len",function(){return ie}),n.d(r,"sub",function(){return le}),n.d(r,"mul",function(){return pe}),n.d(r,"div",function(){return Te}),n.d(r,"dist",function(){return z}),n.d(r,"sqrDist",function(){return B}),n.d(r,"sqrLen",function(){return X}),n.d(r,"forEach",function(){return ae});var s=n(2);function o(){var q=new s.ARRAY_TYPE(2);return s.ARRAY_TYPE!=Float32Array&&(q[0]=0,q[1]=0),q}function a(q){var te=new s.ARRAY_TYPE(2);return te[0]=q[0],te[1]=q[1],te}function c(q,te){var m=new s.ARRAY_TYPE(2);return m[0]=q,m[1]=te,m}function l(q,te){return q[0]=te[0],q[1]=te[1],q}function u(q,te,m){return q[0]=te,q[1]=m,q}function h(q,te,m){return q[0]=te[0]+m[0],q[1]=te[1]+m[1],q}function d(q,te,m){return q[0]=te[0]-m[0],q[1]=te[1]-m[1],q}function g(q,te,m){return q[0]=te[0]*m[0],q[1]=te[1]*m[1],q}function p(q,te,m){return q[0]=te[0]/m[0],q[1]=te[1]/m[1],q}function v(q,te){return q[0]=Math.ceil(te[0]),q[1]=Math.ceil(te[1]),q}function I(q,te){return q[0]=Math.floor(te[0]),q[1]=Math.floor(te[1]),q}function D(q,te,m){return q[0]=Math.min(te[0],m[0]),q[1]=Math.min(te[1],m[1]),q}function x(q,te,m){return q[0]=Math.max(te[0],m[0]),q[1]=Math.max(te[1],m[1]),q}function j(q,te){return q[0]=Math.round(te[0]),q[1]=Math.round(te[1]),q}function w(q,te,m){return q[0]=te[0]*m,q[1]=te[1]*m,q}function y(q,te,m,S){return q[0]=te[0]+m[0]*S,q[1]=te[1]+m[1]*S,q}function f(q,te){var m=te[0]-q[0],S=te[1]-q[1];return Math.hypot(m,S)}function M(q,te){var m=te[0]-q[0],S=te[1]-q[1];return m*m+S*S}function T(q){var te=q[0],m=q[1];return Math.hypot(te,m)}function b(q){var te=q[0],m=q[1];return te*te+m*m}function C(q,te){return q[0]=-te[0],q[1]=-te[1],q}function P(q,te){return q[0]=1/te[0],q[1]=1/te[1],q}function E(q,te){var m=te[0],S=te[1],F=m*m+S*S;return F>0&&(F=1/Math.sqrt(F)),q[0]=te[0]*F,q[1]=te[1]*F,q}function O(q,te){return q[0]*te[0]+q[1]*te[1]}function V(q,te,m){var S=te[0]*m[1]-te[1]*m[0];return q[0]=q[1]=0,q[2]=S,q}function N(q,te,m,S){var F=te[0],Y=te[1];return q[0]=F+S*(m[0]-F),q[1]=Y+S*(m[1]-Y),q}function A(q,te){te=te||1;var m=s.RANDOM()*2*Math.PI;return q[0]=Math.cos(m)*te,q[1]=Math.sin(m)*te,q}function k(q,te,m){var S=te[0],F=te[1];return q[0]=m[0]*S+m[2]*F,q[1]=m[1]*S+m[3]*F,q}function U(q,te,m){var S=te[0],F=te[1];return q[0]=m[0]*S+m[2]*F+m[4],q[1]=m[1]*S+m[3]*F+m[5],q}function Z(q,te,m){var S=te[0],F=te[1];return q[0]=m[0]*S+m[3]*F+m[6],q[1]=m[1]*S+m[4]*F+m[7],q}function Q(q,te,m){var S=te[0],F=te[1];return q[0]=m[0]*S+m[4]*F+m[12],q[1]=m[1]*S+m[5]*F+m[13],q}function ce(q,te,m,S){var F=te[0]-m[0],Y=te[1]-m[1],_=Math.sin(S),re=Math.cos(S);return q[0]=F*re-Y*_+m[0],q[1]=F*_+Y*re+m[1],q}function L(q,te){var m=q[0],S=q[1],F=te[0],Y=te[1],_=Math.sqrt(m*m+S*S)*Math.sqrt(F*F+Y*Y),re=_&&(m*F+S*Y)/_;return Math.acos(Math.min(Math.max(re,-1),1))}function W(q){return q[0]=0,q[1]=0,q}function H(q){return"vec2("+q[0]+", "+q[1]+")"}function $(q,te){return q[0]===te[0]&&q[1]===te[1]}function ee(q,te){var m=q[0],S=q[1],F=te[0],Y=te[1];return Math.abs(m-F)<=s.EPSILON*Math.max(1,Math.abs(m),Math.abs(F))&&Math.abs(S-Y)<=s.EPSILON*Math.max(1,Math.abs(S),Math.abs(Y))}var ie=T,le=d,pe=g,Te=p,z=f,B=M,X=b,ae=function(){var q=o();return function(te,m,S,F,Y,_){var re,ne;for(m||(m=2),S||(S=0),F?ne=Math.min(F*m+S,te.length):ne=te.length,re=S;re<ne;re+=m)q[0]=te[re],q[1]=te[re+1],Y(q,q,_),te[re]=q[0],te[re+1]=q[1];return te}}()},function(e,r,n){n.r(r),n.d(r,"default",function(){return L});var s=n(13),o=n.n(s),a=n(19),c=n.n(a),l=n(23),u=n.n(l),h=n(24),d=n.n(h),g=n(25),p=n(1),v=n(36),I=n(43),D=n(41),x=n(56),j=n(73),w=n(45),y=n(78),f=n(37),M=n(82);n(1).glMatrix.setMatrixArrayType(Array);function T(W,H){var $;if(typeof Symbol>"u"||W[Symbol.iterator]==null){if(Array.isArray(W)||($=b(W))||H){$&&(W=$);var ee=0,ie=function(){};return{s:ie,n:function(){return ee>=W.length?{done:!0}:{done:!1,value:W[ee++]}},e:function(B){throw B},f:ie}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
2
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var le=!0,pe=!1,Te;return{s:function(){$=W[Symbol.iterator]()},n:function(){var B=$.next();return le=B.done,B},e:function(B){pe=!0,Te=B},f:function(){try{!le&&$.return!=null&&$.return()}finally{if(pe)throw Te}}}}function b(W,H){if(W){if(typeof W=="string")return C(W,H);var $=Object.prototype.toString.call(W).slice(8,-1);if($==="Object"&&W.constructor&&($=W.constructor.name),$==="Map"||$==="Set")return Array.from(W);if($==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test($))return C(W,H)}}function C(W,H){(H==null||H>W.length)&&(H=W.length);for(var $=0,ee=new Array(H);$<H;$++)ee[$]=W[$];return ee}var P={autoUpdate:!1,preserveDrawingBuffer:!1,bufferSize:1500},E=`attribute vec3 a_vertexPosition;
3
+ attribute vec3 a_vertexTextureCoord;
4
+ varying vec3 vTextureCoord;
5
+ uniform mat3 viewMatrix;
6
+ uniform mat3 projectionMatrix;
7
+
8
+ void main() {
9
+ gl_PointSize = 1.0;
10
+ vec3 pos = projectionMatrix * viewMatrix * vec3(a_vertexPosition.xy, 1.0);
11
+ gl_Position = vec4(pos.xy, 1.0, 1.0);
12
+ vTextureCoord = a_vertexTextureCoord;
13
+ }
14
+ `,O=`precision mediump float;
15
+ varying vec3 vTextureCoord;
16
+ uniform sampler2D u_texSampler;
17
+ void main() {
18
+ gl_FragColor = texture2D(u_texSampler, vTextureCoord.xy);
19
+ }
20
+ `,V=Symbol("glRenderer"),N=Symbol("canvasRenderer"),A=Symbol("options"),k=Symbol("globalTransform"),U=Symbol("applyGlobalTransform"),Z=Symbol("canvas");function Q(W){var H=W.gl,$=W.fbo;$&&H.bindFramebuffer(H.FRAMEBUFFER,$),W._draw(),$&&H.bindFramebuffer(H.FRAMEBUFFER,null)}function ce(W,H,$,ee){var ie=W.createTexture(H.canvas),le=[[[0,0],[$,0],[$,ee],[0,ee],[0,0]]];le.closed=!0;var pe=new j.default({contours:le});pe.setTexture(ie),W.setMeshData([pe.meshData]),Q(W),ie.delete(),H.clearRect(0,0,$,ee),delete H._filter}var L=function(){function W(H){var $=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};u()(this,W);var ee=$.contextType;if(ee||(typeof WebGL2RenderingContext=="function"?ee="webgl2":typeof WebGLRenderingContext=="function"?ee="webgl":ee="2d"),!H.getContext){var ie=H;H={getContext:function(){return ie},width:$.width,height:$.height},ie.canvas=H,ee="2d"}if(this[Z]=H,ee!=="webgl"&&ee!=="webgl2"&&ee!=="2d")throw new Error("Unknown context type ".concat(ee));if($.contextType=ee,this[A]=Object.assign({},P,$),ee==="webgl"||ee==="webgl2"){ee==="webgl2"&&(this[A].webgl2=!0);var le=new g.default(H,this[A]);ee==="webgl2"&&!le.isWebGL2&&($.contextType="webgl"),Object(M.createShaders)(le),Object(M.applyShader)(le),Object(M.createCloudShaders)(le);var pe=le.gl;pe.clearColor(0,0,0,0),pe.blendFuncSeparate(pe.SRC_ALPHA,pe.ONE_MINUS_SRC_ALPHA,pe.ONE,pe.ONE_MINUS_SRC_ALPHA),this[V]=le}else this[N]=new v.default(H,this[A]);this[k]=[1,0,0,0,1,0,0,0,1],this.updateResolution()}return d()(W,[{key:U,value:function(){var $=this[V]||this[N];if(this[V]){var ee=this.canvas,ie=ee.width,le=ee.height;$.uniforms.viewMatrix=this.viewMatrix,$.uniforms.projectionMatrix=this.projectionMatrix,$.uniforms.u_resolution=[ie,le]}}},{key:"updateResolution",value:function(){var $=this.canvas,ee=$.width,ie=$.height,le=[1,0,0,0,1,0,-ee/2,-ie/2,1],pe=[2/ee,0,0,0,-2/ie,0,0,0,1],Te=p.mat3.multiply(Array.of(0,0,0,0,0,0,0,0,0),pe,le);this.projectionMatrix=Te,this[V]&&this[V].gl.viewport(0,0,ee,ie)}},{key:"createTexture",value:function($,ee){var ie=this[V]||this[N];return ie.createTexture($,ee)}},{key:"loadTexture",value:function($){var ee=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ie=ee.useImageBitmap,le=ie===void 0?!1:ie,pe=this[V]||this[N];return pe.loadTexture($,{useImageBitmap:le})}},{key:"createText",value:function($){var ee=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ie=ee.font,le=ie===void 0?"16px arial":ie,pe=ee.fillColor,Te=pe===void 0?null:pe,z=ee.strokeColor,B=z===void 0?null:z,X=ee.strokeWidth,ae=X===void 0?1:X;if(this[V]){var q=f.default.createText($,{font:le,fillColor:Te,strokeColor:B,strokeWidth:ae});return{image:this.createTexture(q.image),rect:q.rect}}return{_img:{font:le,fillColor:Te,strokeColor:B,strokeWidth:ae,text:$}}}},{key:"createProgram",value:function(){var $=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ee=$.vertex,ie=$.fragment,le=$.options;if(this[V]){var pe=this[V].compileSync(ie,ee);return pe._attribOpts=le,pe}throw new Error("Context 2D cannot create webgl program.")}},{key:"createPassProgram",value:function(){var $=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ee=$.vertex,ie=ee===void 0?E:ee,le=$.fragment,pe=le===void 0?O:le,Te=$.options;return this.createProgram({vertex:ie,fragment:pe,options:Te})}},{key:"useProgram",value:function($){var ee=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this[V]){var ie=Object.assign({},$._attribOpts,ee);return this[V].useProgram($,ie)}throw new Error("Context 2D cannot use webgl program.")}},{key:"deleteTexture",value:function($){var ee=this[V]||this[N];return ee.deleteTexture($)}},{key:"clear",value:function(){if(this[V]){var $=this[V].gl;$.clear($.COLOR_BUFFER_BIT)}else{var ee;(ee=this[N]).clear.apply(ee,arguments)}}},{key:"drawMeshCloud",value:function($){var ee=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ie=ee.clear,le=ie===void 0?!1:ie,pe=ee.program,Te=pe===void 0?null:pe,z=this[V]||this[N],B=Te||$.program;if(this[V]){var X=z.gl;if(le&&X.clear(X.COLOR_BUFFER_BIT),B)z.program!==B&&this.useProgram(B,{a_color:{type:"UNSIGNED_BYTE",normalize:!0},a_fillCloudColor:{type:"UNSIGNED_BYTE",normalize:!0},a_strokeCloudColor:{type:"UNSIGNED_BYTE",normalize:!0},a_frameIndex:{type:"UNSIGNED_BYTE",normalize:!1}});else{var ae=$.mesh.meshData,q=!!ae.uniforms.u_texSampler,te=!!ae.uniforms.u_filterFlag,m=!!ae.uniforms.u_radialGradientVector,S=$.hasCloudColor,F=$.hasCloudFilter,Y=!!ae.uniforms.u_clipSampler;Object(M.applyCloudShader)(z,{hasTexture:q,hasFilter:te,hasGradient:m,hasCloudColor:S,hasCloudFilter:F,hasClipPath:Y})}this[U](),z.setMeshData([$.meshData]),$.beforeRender&&$.beforeRender(X,$),Q(z),$.afterRender&&$.afterRender(X,$)}else z.setTransform(this.globalTransformMatrix),z.drawMeshCloud($,{clear:le,hook:!1})}},{key:"drawMeshes",value:function($){var ee=this,ie=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},le=ie.clear,pe=le===void 0?!1:le,Te=ie.program,z=Te===void 0?null:Te,B=this[V]||this[N];this[V]?function(){var X=B.fbo,ae=Object(I.default)(ee,$,z==null),q=B.gl;pe&&q.clear(q.COLOR_BUFFER_BIT);var te=!Object(y.isUnitTransform)(ee.globalTransformMatrix);ee._drawCalls=0;var m=T(ae),S;try{var F=function(){var _=S.value;ee._drawCalls++;var re=z||_.program;if(_ instanceof w.default)ee.drawMeshCloud(_,{clear:pe,program:re});else{var ne=ee.canvas,J=ne.width,se=ne.height;if(_.beforeRender&&_.beforeRender(q,_),_.pass.length&&((!ee.fbo||ee.fbo.width!==J||ee.fbo.height!==se)&&(ee.fbo={width:J,height:se,target:B.createFBO(),buffer:B.createFBO(),swap:function(){var je=[this.buffer,this.target];this.target=je[0],this.buffer=je[1]}}),B.bindFBO(ee.fbo.target)),!re&&_.filterCanvas){Object(M.applyShader)(B,{hasTexture:!0});var ue=ee.filterContext;if(!ue){var oe=f.default.createCanvas(J,se);ue=oe.getContext("2d"),ee.filterContext=ue}var de=$[_.packIndex],me=de.filter,ye=$[_.packIndex+1],be=$[_.packIndex-1];(!be||!be.filterCanvas||be.filter!==me)&&(!ye||!ye.filterCanvas||ye.filter!==me)?(te?(ue.save(),Object(D.drawMesh2D)(de,ue,!1),ue.restore(),Object(D.applyFilter)(ue,me)):Object(D.drawMesh2D)(de,ue,!0),ee[U](),ce(B,ue,J,se)):(te&&ue.save(),Object(D.drawMesh2D)(de,ue,!1),te&&ue.restore(),(!ye||!ye.filterCanvas||de.filter!==ye.filter)&&(Object(D.applyFilter)(ue,me),ee[U](),ce(B,ue,J,se)))}else{if(re)B.program!==re&&ee.useProgram(re,{a_color:{type:"UNSIGNED_BYTE",normalize:!0}});else{var Ce=!!_.uniforms.u_texSampler,Ie=!!_.uniforms.u_filterFlag,Pe=!!_.uniforms.u_radialGradientVector,Re=!!_.uniforms.u_clipSampler;Object(M.applyShader)(B,{hasTexture:Ce,hasFilter:Ie,hasGradient:Pe,hasClipPath:Re})}_.filterCanvas&&console.warn("User program ignored some filter effects."),ee[U](),B.setMeshData([_]),Q(B)}if(_.pass.length){var ke=_.pass.length;_.pass.forEach(function(Oe,je){Oe.blend=_.enableBlend,Oe.setTexture(B.fbo.texture),je===ke-1?B.bindFBO(X):(ee.fbo.swap(),B.bindFBO(ee.fbo.target)),Oe.program?B.useProgram(Oe.program):(ee.defaultPassProgram=ee.defaultPassProgram||ee.createPassProgram(),B.useProgram(ee.defaultPassProgram)),B.setMeshData([Oe.meshData]),q.clear(q.COLOR_BUFFER_BIT),Q(B)})}_.afterRender&&_.afterRender(q,_)}};for(m.s();!(S=m.n()).done;)F()}catch(Y){m.e(Y)}finally{m.f()}}():(B.setTransform(this.globalTransformMatrix),B.drawMeshes($,{clear:pe}))}},{key:"drawImage",value:function($){for(var ee=arguments.length,ie=new Array(ee>1?ee-1:0),le=1;le<ee;le++)ie[le-1]=arguments[le];var pe=ie.length;if(pe<2)throw new TypeError("Failed to execute 'drawImage' on 'Renderer': 3 arguments required, but only ".concat(ie.length+1," present."));if(pe!==2&&pe!==4&&pe!==8)throw new TypeError("Failed to execute 'drawImage' on 'Renderer': Valid arities are: [3, 5, 9], but ".concat(ie.length+1," arguments provided."));var Te=null,z=null;pe===2?Te=[ie[0],ie[1],$.width,$.height]:pe===4?Te=ie:pe===8&&(z=ie.slice(0,4),Te=ie.slice(4));var B=this.createTexture($),X=this.canvas,ae=X.width,q=X.height,te=new x.default;te.rect(Te[0],Te[1],ae,q);var m=new j.default(te,{width:ae,height:q});m.setTexture(B,{rect:Te,srcRect:z}),this.drawMeshes([m]),this.deleteTexture(B)}},{key:"setGlobalTransform",value:function(){return this[k]=[arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],0,arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3],0,arguments.length<=4?void 0:arguments[4],arguments.length<=5?void 0:arguments[5],1],this}},{key:"globalTransform",value:function(){for(var $=this[k],ee=arguments.length,ie=new Array(ee),le=0;le<ee;le++)ie[le]=arguments[le];return this[k]=p.mat3.multiply(Array.of(0,0,0,0,0,0,0,0,0),$,ie),this}},{key:"globalTranslate",value:function($,ee){var ie=p.mat3.create();return ie=p.mat3.translate(Array.of(0,0,0,0,0,0,0,0,0),ie,[$,ee]),this.globalTransform.apply(this,c()(ie))}},{key:"globalRotate",value:function($){var ee=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[0,0],ie=o()(ee,2),le=ie[0],pe=ie[1],Te=p.mat3.create();return Te=p.mat3.translate(Array.of(0,0,0,0,0,0,0,0,0),Te,[le,pe]),Te=p.mat3.rotate(Array.of(0,0,0,0,0,0,0,0,0),Te,$),Te=p.mat3.translate(Array.of(0,0,0,0,0,0,0,0,0),Te,[-le,-pe]),this.globalTransform.apply(this,c()(Te))}},{key:"globalScale",value:function($){var ee=arguments.length>1&&arguments[1]!==void 0?arguments[1]:$,ie=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[0,0],le=o()(ie,2),pe=le[0],Te=le[1],z=p.mat3.create();return z=p.mat3.translate(Array.of(0,0,0,0,0,0,0,0,0),z,[pe,Te]),z=p.mat3.scale(Array.of(0,0,0,0,0,0,0,0,0),z,[$,ee]),z=p.mat3.translate(Array.of(0,0,0,0,0,0,0,0,0),z,[-pe,-Te]),this.globalTransform.apply(this,c()(z))}},{key:"globalSkew",value:function($){var ee=arguments.length>1&&arguments[1]!==void 0?arguments[1]:$,ie=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[0,0],le=o()(ie,2),pe=le[0],Te=le[1],z=p.mat3.create();return z=p.mat3.translate(Array.of(0,0,0,0,0,0,0,0,0),z,[pe,Te]),z=p.mat3.multiply(Array.of(0,0,0,0,0,0,0,0,0),z,p.mat3.fromValues(1,Math.tan(ee),Math.tan($),1,0,0)),z=p.mat3.translate(Array.of(0,0,0,0,0,0,0,0,0),z,[-pe,-Te]),this.globalTransform.apply(this,c()(z))}},{key:"transformPoint",value:function($,ee,ie){var le=this.globalTransformMatrix;ie&&(le=p.mat3.multiply(Array.of(0,0,0,0,0,0,0,0,0),le,ie));var pe=$*le[0]+ee*le[2]+le[4],Te=$*le[1]+ee*le[3]+le[5];return[pe,Te]}},{key:"canvas",get:function(){return this[Z]}},{key:"canvasRenderer",get:function(){return this[N]}},{key:"glRenderer",get:function(){return this[V]}},{key:"isWebGL2",get:function(){return this[V]&&this[V].isWebGL2}},{key:"options",get:function(){return this[A]}},{key:"globalTransformMatrix",get:function(){var $=this[k];return[$[0],$[1],$[3],$[4],$[6],$[7]]}},{key:"viewMatrix",get:function(){return this[k]}}]),W}()},function(e,r,n){var s=n(14),o=n(15),a=n(16),c=n(18);function l(u,h){return s(u)||o(u,h)||a(u,h)||c()}e.exports=l},function(e,r){function n(s){if(Array.isArray(s))return s}e.exports=n},function(e,r){function n(s,o){if(!(typeof Symbol>"u"||!(Symbol.iterator in Object(s)))){var a=[],c=!0,l=!1,u=void 0;try{for(var h=s[Symbol.iterator](),d;!(c=(d=h.next()).done)&&(a.push(d.value),!(o&&a.length===o));c=!0);}catch(g){l=!0,u=g}finally{try{!c&&h.return!=null&&h.return()}finally{if(l)throw u}}return a}}e.exports=n},function(e,r,n){var s=n(17);function o(a,c){if(a){if(typeof a=="string")return s(a,c);var l=Object.prototype.toString.call(a).slice(8,-1);if(l==="Object"&&a.constructor&&(l=a.constructor.name),l==="Map"||l==="Set")return Array.from(a);if(l==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(l))return s(a,c)}}e.exports=o},function(e,r){function n(s,o){(o==null||o>s.length)&&(o=s.length);for(var a=0,c=new Array(o);a<o;a++)c[a]=s[a];return c}e.exports=n},function(e,r){function n(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
21
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}e.exports=n},function(e,r,n){var s=n(20),o=n(21),a=n(16),c=n(22);function l(u){return s(u)||o(u)||a(u)||c()}e.exports=l},function(e,r,n){var s=n(17);function o(a){if(Array.isArray(a))return s(a)}e.exports=o},function(e,r){function n(s){if(typeof Symbol<"u"&&Symbol.iterator in Object(s))return Array.from(s)}e.exports=n},function(e,r){function n(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
22
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}e.exports=n},function(e,r){function n(s,o){if(!(s instanceof o))throw new TypeError("Cannot call a class as a function")}e.exports=n},function(e,r){function n(o,a){for(var c=0;c<a.length;c++){var l=a[c];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(o,l.key,l)}}function s(o,a,c){return a&&n(o.prototype,a),c&&n(o,c),o}e.exports=s},function(e,r,n){n.r(r);var s=n(26);n(1).glMatrix.setMatrixArrayType(Array),r.default=s.default},function(e,r,n){n.r(r),n.d(r,"default",function(){return E});var s=n(27),o=n.n(s),a=n(29),c=n.n(a),l=n(13),u=n.n(l),h=n(19),d=n.n(h),g=n(23),p=n.n(g),v=n(24),I=n.n(v),D=n(30),x=n.n(D),j=n(31),w=n(33),y=n(34),f=n(35);n(1).glMatrix.setMatrixArrayType(Array);var M={};function T(O){for(var V=arguments.length>1&&arguments[1]!==void 0?arguments[1]:3,N=[],A=O.length,k=0;k<A;k++)k%V<2&&N.push(.5*(O[k]+1));return N}function b(O,V){var N=V._buffers;Object.values(N).forEach(function(A){O.deleteBuffer(A)}),V._buffers={}}function C(O,V,N){return O.activeTexture(O.TEXTURE0+N),Array.isArray(V._img)?O.bindTexture(O.TEXTURE_CUBE_MAP,V):O.bindTexture(O.TEXTURE_2D,V),V}var P={int:"1i",ivec2:"2i",ivec3:"3i",ivec4:"4i",float:"1f",vec2:"2f",vec3:"3f",vec4:"4f",mat2:"Matrix2fv",mat3:"Matrix3fv",mat4:"Matrix4fv",sampler1D:"sampler1D",sampler2D:"sampler2D",sampler3D:"sampler3D",samplerCube:"samplerCube",sampler1DShadow:"sampler1DShadow",sampler2DShadow:"sampler2DShadow",sampler2DRect:"sampler2DRect",sampler2DRectShadow:"sampler2DRectShadow"},E=function(){I()(O,null,[{key:"addLibs",value:function(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.assign(M,N)}},{key:"FLOAT",value:function(N,A){return Object(j.pointsToBuffer)(N,Float32Array,A)}},{key:"UNSIGNED_BYTE",value:function(N,A){return Object(j.pointsToBuffer)(N,Uint8Array,A)}},{key:"UNSIGNED_SHORT",value:function(N,A){return Object(j.pointsToBuffer)(N,Uint16Array,A)}},{key:"BYTE",value:function(N,A){return Object(j.pointsToBuffer)(N,Int8Array,A)}},{key:"SHORT",value:function(N,A){return Object(j.pointsToBuffer)(N,Int16Array,A)}}]);function O(V){var N=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};p()(this,O),this.options=Object.assign({},O.defaultOptions,N),this.canvas=V;var A;this.options.webgl2&&(A=V.getContext("webgl2",this.options)),A==null&&(A=Object(j.setupWebGL)(V,this.options),this.aia_ext=A.getExtension("ANGLE_instanced_arrays")),this.gl=A,A.viewport(0,0,V.width,V.height),A.clearColor(0,0,0,0),A.blendFuncSeparate(A.SRC_ALPHA,A.ONE_MINUS_SRC_ALPHA,A.ONE,A.ONE_MINUS_SRC_ALPHA),this.programs=[],this._events={}}return I()(O,[{key:"_declareUniform",value:function(N,A){var k=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"1f",U=this.gl,Z=U.getUniformLocation(N,A),Q,ce=this;if(/^sampler/.test(k)){var L=N._samplerMap,W=N._bindTextures;Object.defineProperty(N.uniforms,A,{get:function(){return Q},set:function(le){Q=le;var pe=L[A]!=null?L[A]:W.length;W[pe]=le,C(U,le,pe),L[A]||(L[A]=pe,U.uniform1i(Z,pe)),ce.options.autoUpdate&&ce.update()},configurable:!1,enumerable:!0})}else{var H=k.indexOf("Matrix")===0,$=!H&&/v$/.test(k),ee=U["uniform".concat(k)].bind(U);Object.defineProperty(N.uniforms,A,{get:function(){return Q},set:function(le){Q=le,typeof le=="number"&&(le=[le]),H?ee(Z,!1,le):$?ee(Z,le):ee.apply(void 0,[Z].concat(d()(le))),ce.options.autoUpdate&&ce.update()},configurable:!1,enumerable:!0})}}},{key:"_draw",value:function(){var N=this,A=this.program;A.meshData.forEach(function(k,U){var Z=k.positions,Q=k.cells,ce=k.instanceCount,L=k.cellsCount,W=k.attributes,H=k.uniforms,$=k.textureCoord,ee=k.enableBlend,ie=N.gl,le=k.mode!=null?k.mode:ie.TRIANGLES;typeof le=="string"&&(le=ie[le]),ee?ie.enable(ie.BLEND):ie.disable(ie.BLEND),ie.bindBuffer(ie.ARRAY_BUFFER,A._buffers.verticesBuffer),ie.bufferData(ie.ARRAY_BUFFER,Z,ie.STATIC_DRAW),Q&&(ie.bindBuffer(ie.ELEMENT_ARRAY_BUFFER,A._buffers.cellsBuffer),ie.bufferData(ie.ELEMENT_ARRAY_BUFFER,Q,ie.STATIC_DRAW));var pe=[];W&&Object.values(W).forEach(function(X){var ae=X.name,q=X.data,te=X.divisor;if(ie.bindBuffer(ie.ARRAY_BUFFER,A._buffers[ae]),ie.bufferData(ie.ARRAY_BUFFER,q,ie.STATIC_DRAW),te!=null){var m=ie.getAttribLocation(A,ae);m>=0&&(ie.enableVertexAttribArray(m),pe.push(m),ie.vertexAttribDivisor?ie.vertexAttribDivisor(m,te):N.aia_ext&&N.aia_ext.vertexAttribDivisorANGLE(m,te))}}),H&&Object.entries(H).forEach(function(X){var ae=u()(X,2),q=ae[0],te=ae[1];N.uniforms[q]=te});var Te;if(!Q){var z=A._dimension;Te=Z.length/z}if(A._enableTextures&&A._buffers.texCoordBuffer){var B=$||T(Z,A._dimension);ie.bindBuffer(ie.ARRAY_BUFFER,A._buffers.texCoordBuffer),ie.bufferData(ie.ARRAY_BUFFER,O.FLOAT(B),ie.STATIC_DRAW)}ce!=null?(Q?ie.drawElementsInstanced?ie.drawElementsInstanced(le,L,ie.UNSIGNED_SHORT,0,ce):N.aia_ext&&N.aia_ext.drawElementsInstancedANGLE(le,L,ie.UNSIGNED_SHORT,0,ce):ie.drawArraysInstanced?ie.drawArraysInstanced(le,0,Te,ce):N.aia_ext.drawArraysInstancedANGLE(le,0,Te,ce),pe.forEach(function(X){ie.vertexAttribDivisor?ie.vertexAttribDivisor(X,null):N.aia_ext&&N.aia_ext.vertexAttribDivisorANGLE(X,null)})):Q?ie.drawElements(le,L,ie.UNSIGNED_SHORT,0):ie.drawArrays(le,0,Te)})}},{key:"deleteProgram",value:function(N){var A=this.gl;this.program===N&&(this.startRender=!1,this._renderFrameID&&(cancelAnimationFrame(this._renderFrameID),delete this._renderFrameID),A.useProgram(null));var k=this.programs.indexOf(N);k>=0&&this.programs.splice(k,1),b(A,N),A.deleteProgram(N)}},{key:"setMeshData",value:function(N){var A=this;Array.isArray(N)||(N=[N]);var k=this.program;k.meshData=N.map(function(U){var Z=U.mode,Q=U.positions,ce=U.instanceCount,L=U.cells,W=U.cellsCount,H=U.attributes,$=U.uniforms,ee=U.textureCoord,ie=U.enableBlend,le={positions:O.FLOAT(Q),uniforms:$,enableBlend:!!ie,textureCoord:O.FLOAT(ee)};if(L&&(le.cells=O.USHORT(L),le.cellsCount=W||le.cells.length),Z!=null&&(le.mode=Z),ce!=null){if(!A.isWebGL2&&!A.aia_ext)throw new Error("Cannot use instanceCount in this rendering context, use webgl2 context instead.");le.instanceCount=ce}if(H){var pe={};Object.entries(H).forEach(function(Te){var z=u()(Te,2),B=z[0],X=z[1];if(!k._attribute[B])k._attribute[B]="ignored";else if(k._attribute[B]!=="ignored"){var ae=k._attribute[B],q=ae.name,te=ae.type,m=X.data||X;if(Array.isArray(m)&&(m=O[te](m)),pe[B]={name:q,data:m},X.divisor!=null){if(!A.isWebGL2&&!A.aia_ext)throw new Error("Cannot use divisor in this rendering context, use webgl2 context instead.");pe[B].divisor=X.divisor}}}),le.attributes=pe}return le}),this.options.autoUpdate&&this.update()}},{key:"createProgram",value:function(N,A){var k=this,U=/^\s*uniform\s+sampler/mg.test(N);N==null&&(N=y.default),A==null&&(A=U?f.default:w.default);var Z=this.gl,Q=Object(j.createProgram)(Z,A,N);Q.shaderText={vertexShader:A,fragmentShader:N},Q._buffers={},Q._attribute={},Q.uniforms={},Q._samplerMap={},Q._bindTextures=[];var ce=new RegExp("(?:attribute|in) vec(\\d) ".concat(this.options.vertexPosition),"im"),L=A.match(ce);L&&(Q._dimension=Number(L[1]));var W=new RegExp("(?:attribute|in) vec(\\d) ".concat(this.options.vertexTextureCoord),"im");L=A.match(W),L&&(Q._texCoordSize=Number(L[1]));var H=/^\s*(?:attribute|in) (\w+?)(\d*) (\w+)/gim;if(L=A.match(H),L)for(var $=0;$<L.length;$++){var ee=/^\s*(?:attribute|in) (\w+?)(\d*) (\w+)/im,ie=L[$].match(ee);if(ie&&ie[3]!==this.options.vertexPosition&&ie[3]!==this.options.vertexTextureCoord){var le=u()(ie,4),pe=le[1],Te=le[2],z=le[3];pe==="mat"&&(Te=Math.pow(Te,2)),Q._buffers[z]=Z.createBuffer(),Q._attribute[z]={name:z,type:pe,size:Number(Te)||1}}}var B=/^\s*uniform\s+(\w+)\s+(\w+)(\[\d+\])?/mg;L=A.match(B)||[],L=L.concat(N.match(B)||[]),L.forEach(function(ae){var q=ae.match(/^\s*uniform\s+(\w+)\s+(\w+)(\[\d+\])?/),te=q.slice(1),m=u()(te,3),S=m[0],F=m[1],Y=m[2];S=P[S],Y=!!Y,S.indexOf("Matrix")!==0&&Y&&(S+="v"),k._declareUniform(Q,F,S)}),Q._buffers.verticesBuffer=Z.createBuffer(),Q._buffers.cellsBuffer=Z.createBuffer();var X=Z.getAttribLocation(Q,this.options.vertexTextureCoord);return Q._enableTextures=X>=0,Q._enableTextures&&(Q._buffers.texCoordBuffer=Z.createBuffer()),this.programs.push(Q),Q}},{key:"useProgram",value:function(N){var A=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.startRender=!1,this._renderFrameID&&(cancelAnimationFrame(this._renderFrameID),delete this._renderFrameID);var k=this.gl;k.useProgram(N);var U=N._dimension;k.bindBuffer(k.ARRAY_BUFFER,N._buffers.verticesBuffer);var Z=k.getAttribLocation(N,this.options.vertexPosition);if(k.vertexAttribPointer(Z,U,k.FLOAT,!1,0,0),k.enableVertexAttribArray(Z),N._enableTextures){k.bindBuffer(k.ARRAY_BUFFER,N._buffers.texCoordBuffer);var Q=k.getAttribLocation(N,this.options.vertexTextureCoord);k.vertexAttribPointer(Q,N._texCoordSize||2,k.FLOAT,!1,0,0),k.enableVertexAttribArray(Q)}if(Object.entries(N._attribute).forEach(function(W){var H=u()(W,2),$=H[0],ee=H[1];if(ee!=="ignored"){var ie=ee.size,le=A[$]||{},pe=!!le.normalize,Te=le.type||"FLOAT",z=le.key||$;Te==="UBYTE"&&(Te="UNSIGNED_BYTE"),Te==="USHORT"&&(Te="UNSIGNED_SHORT"),ee.type=Te,z&&z!==$&&(N._attribute[z]=ee),k.bindBuffer(k.ARRAY_BUFFER,N._buffers[$]);var B=k.getAttribLocation(N,$);B>=0&&(k.vertexAttribPointer(B,ie,k[Te],pe,0,0),k.enableVertexAttribArray(B))}}),!N.meshData){var ce=[[-1,-1,0,1].slice(0,U),[1,-1,0,1].slice(0,U),[1,1,0,1].slice(0,U),[-1,1,0,1].slice(0,U)],L=[[0,1,3],[3,1,2]];this.setMeshData({positions:ce,cells:L})}return N}},{key:"compileSync",value:function(N,A){N=N||y.default;var k={};function U(L){L=L.replace(/^\s*/mg,"");var W=[],H=L.match(/^#pragma\s+include\s+.*/mg);if(H){for(var $=0;$<H.length;$++){var ee=H[$],ie=ee.match(/(?:<|")(.*)(?:>|")/);if(ie){var le=ie[0].indexOf("<")===0?"lib":"link",pe=ie[1];if(pe==="graph"&&(pe="graphics"),k[pe])W.push("/* included ".concat(pe," */"));else if(k[pe]=!0,le==="lib"){var Te=U(M[pe]);W.push(Te)}else if(le==="link")throw new Error("Cannot load external links synchronously. Use compile instead of compileSync.")}}W.forEach(function(z){L=L.replace(/^#pragma\s+include\s+.*/m,z)})}return L}var Z=U(N),Q=A?U(A):null,ce=this.createProgram(Z,Q);return ce}},{key:"compile",value:function(){var V=c()(o.a.mark(function A(k,U){var Z,Q,ce,L,W,H;return o.a.wrap(function(ee){for(;;)switch(ee.prev=ee.next){case 0:return ce=function(){return ce=c()(o.a.mark(function le(pe){var Te,z,B,X,ae,q,te,m,S;return o.a.wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:if(pe=pe.replace(/^\s*/mg,""),Te=[],z=pe.match(/^#pragma\s+include\s+.*/mg),!z){Y.next=36;break}B=0;case 5:if(!(B<z.length)){Y.next=35;break}if(X=z[B],ae=X.match(/(?:<|")(.*)(?:>|")/),!ae){Y.next=32;break}if(q=ae[0].indexOf("<")===0?"lib":"link",te=ae[1],te==="graph"&&(te="graphics"),Z[te]){Y.next=31;break}if(Z[te]=!0,q!=="lib"){Y.next=21;break}return Y.next=17,Q(M[te]);case 17:m=Y.sent,Te.push(m),Y.next=29;break;case 21:if(q!=="link"){Y.next=29;break}return Y.next=24,O.fetchShader(te);case 24:return S=Y.sent,Y.next=27,Q(S);case 27:S=Y.sent,Te.push(S);case 29:Y.next=32;break;case 31:Te.push("/* included ".concat(te," */"));case 32:B++,Y.next=5;break;case 35:Te.forEach(function(_){pe=pe.replace(/^#pragma\s+include\s+.*/m,_)});case 36:return Y.abrupt("return",pe);case 37:case"end":return Y.stop()}},le)})),ce.apply(this,arguments)},Q=function(le){return ce.apply(this,arguments)},k=k||y.default,Z={},ee.next=6,Q(k);case 6:if(L=ee.sent,!U){ee.next=13;break}return ee.next=10,Q(U);case 10:ee.t0=ee.sent,ee.next=14;break;case 13:ee.t0=null;case 14:return W=ee.t0,H=this.createProgram(L,W),ee.abrupt("return",H);case 17:case"end":return ee.stop()}},A,this)}));function N(A,k){return V.apply(this,arguments)}return N}()},{key:"load",value:function(){var V=c()(o.a.mark(function A(k){var U,Z=arguments;return o.a.wrap(function(ce){for(;;)switch(ce.prev=ce.next){case 0:return U=Z.length>1&&Z[1]!==void 0?Z[1]:null,ce.next=3,O.fetchShader(k);case 3:if(k=ce.sent,!U){ce.next=8;break}return ce.next=7,O.fetchShader(U);case 7:U=ce.sent;case 8:return ce.abrupt("return",this.compile(k,U));case 9:case"end":return ce.stop()}},A,this)}));function N(A){return V.apply(this,arguments)}return N}()},{key:"createTexture",value:function(){var N=this,A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,k=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},U=k.wrapS,Z=U===void 0?this.gl.CLAMP_TO_EDGE:U,Q=k.wrapT,ce=Q===void 0?this.gl.CLAMP_TO_EDGE:Q,L=k.minFilter,W=L===void 0?this.gl.LINEAR:L,H=k.magFilter,$=H===void 0?this.gl.LINEAR:H,ee=this.gl,ie=Array.isArray(A)?ee.TEXTURE_CUBE_MAP:ee.TEXTURE_2D;this._max_texture_image_units=this._max_texture_image_units||ee.getParameter(ee.MAX_COMBINED_TEXTURE_IMAGE_UNITS),ee.activeTexture(ee.TEXTURE0+this._max_texture_image_units-1);var le=ee.createTexture();ee.bindTexture(ie,le),ee.pixelStorei(ee.UNPACK_FLIP_Y_WEBGL,!0);var pe=this.canvas,Te=pe.width,z=pe.height;if(A)if(ie===ee.TEXTURE_CUBE_MAP)for(var B=0;B<6;B++)ee.texImage2D(ee.TEXTURE_CUBE_MAP_POSITIVE_X+B,0,ee.RGBA,ee.RGBA,ee.UNSIGNED_BYTE,A[B]);else ee.texImage2D(ie,0,ee.RGBA,ee.RGBA,ee.UNSIGNED_BYTE,A);else if(ie===ee.TEXTURE_CUBE_MAP)for(var X=0;X<6;X++)this.gl.texImage2D(this.gl.TEXTURE_CUBE_MAP_POSITIVE_X+X,0,ee.RGBA,Te,z,0,ee.RGBA,ee.UNSIGNED_BYTE,null);else ee.texImage2D(ie,0,ee.RGBA,Te,z,0,ee.RGBA,ee.UNSIGNED_BYTE,null);return ee.texParameteri(ie,ee.TEXTURE_MIN_FILTER,W),ee.texParameteri(ie,ee.TEXTURE_MAG_FILTER,$),ee.texParameteri(ie,ee.TEXTURE_WRAP_S,Z),ee.texParameteri(ie,ee.TEXTURE_WRAP_T,ce),ie===ee.TEXTURE_CUBE_MAP&&(A.width=A[0].width,A.height=A[0].height),ee.bindTexture(ie,null),le._img=A||{width:Te,height:z},le.delete=function(){N.deleteTexture(le)},le}},{key:"deleteTexture",value:function(N){var A=N._img;this.gl.deleteTexture(N),typeof A.close=="function"&&A.close()}},{key:"loadTexture",value:function(){var V=c()(o.a.mark(function A(k){var U,Z,Q,ce,L=arguments;return o.a.wrap(function(H){for(;;)switch(H.prev=H.next){case 0:return U=L.length>1&&L[1]!==void 0?L[1]:{},Z=U.useImageBitmap,Q=Z===void 0?!0:Z,H.next=3,O.loadImage(k,{useImageBitmap:Q});case 3:return ce=H.sent,H.abrupt("return",this.createTexture(ce));case 5:case"end":return H.stop()}},A,this)}));function N(A){return V.apply(this,arguments)}return N}()},{key:"createFBO",value:function(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},A=N.color,k=A===void 0?1:A,U=N.blend,Z=U===void 0?!1:U,Q=N.depth,ce=Q===void 0?this.options.depth!==!1:Q,L=N.stencil,W=L===void 0?!!this.options.stencil:L,H=this.gl,$=H.createFramebuffer();H.bindFramebuffer(H.FRAMEBUFFER,$);for(var ee=[],ie=0;ie<k;ie++){var le=this.createTexture();H.framebufferTexture2D(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0+ie,H.TEXTURE_2D,le,0),ee.push(le)}$.textures=ee,$.texture=ee[0],$.blend=Z;var pe=this.canvas,Te=pe.width,z=pe.height;return ce&&!W&&($.depthBuffer=H.createRenderbuffer(),H.bindRenderbuffer(H.RENDERBUFFER,$.depthBuffer),H.renderbufferStorage(H.RENDERBUFFER,H.DEPTH_COMPONENT16,Te,z),H.framebufferRenderbuffer(H.FRAMEBUFFER,H.DEPTH_ATTACHMENT,H.RENDERBUFFER,$.depthBuffer)),W&&!ce&&($.stencilBuffer=H.createRenderbuffer(),H.bindRenderbuffer(H.RENDERBUFFER,$.stencilBuffer),H.renderbufferStorage(H.RENDERBUFFER,H.STENCIL_INDEX8,Te,z),H.framebufferRenderbuffer(H.FRAMEBUFFER,H.STENCIL_ATTACHMENT,H.RENDERBUFFER,$.stencilBuffer)),ce&&W&&($.depthStencilBuffer=H.createRenderbuffer(),H.bindRenderbuffer(H.RENDERBUFFER,$.depthStencilBuffer),H.renderbufferStorage(H.RENDERBUFFER,H.DEPTH_STENCIL,Te,z),H.framebufferRenderbuffer(H.FRAMEBUFFER,H.DEPTH_STENCIL_ATTACHMENT,H.RENDERBUFFER,$.depthStencilBuffer)),H.bindFramebuffer(H.FRAMEBUFFER,null),$}},{key:"bindFBO",value:function(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null;this.fbo=N}},{key:"render",value:function(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};N.clearBuffer,this.startRender=!0;var A=this.gl,k=this.program;k||(k=this.createProgram(),this.useProgram(k)),this.fbo&&A.bindFramebuffer(A.FRAMEBUFFER,this.fbo);var U=this.options.depth;U&&A.enable(A.DEPTH_TEST),this.gl.clear(this.gl.COLOR_BUFFER_BIT|(U?this.gl.DEPTH_BUFFER_BIT:0)|(this.options.stencil?this.gl.STENCIL_BUFFER_BIT:0));var Z=this._renderFrameID;this._draw(),this.fbo&&A.bindFramebuffer(A.FRAMEBUFFER,null),this._renderFrameID===Z&&(this._renderFrameID=null)}},{key:"update",value:function(){this.startRender&&this._renderFrameID==null&&(this._renderFrameID=requestAnimationFrame(this.render.bind(this)))}},{key:"program",get:function(){var N=this.gl;return N.getParameter(N.CURRENT_PROGRAM)}},{key:"isWebGL2",get:function(){return typeof WebGL2RenderingContext<"u"&&this.gl instanceof WebGL2RenderingContext}},{key:"enableTextures",get:function(){return this.program&&this.program._enableTextures}},{key:"uniforms",get:function(){var N=this.program;if(!N||!N.uniforms)throw Error("No avaliable program.");return N.uniforms}}]),O}();x()(E,"defaultOptions",{preserveDrawingBuffer:!0,autoUpdate:!0,vertexPosition:"a_vertexPosition",vertexTextureCoord:"a_vertexTextureCoord",webgl2:!1}),x()(E,"UBYTE",E.UNSIGNED_BYTE),x()(E,"USHORT",E.UNSIGNED_SHORT),x()(E,"fetchShader",j.fetchShader),x()(E,"loadImage",j.loadImage)},function(e,r,n){e.exports=n(28)},function(e,r,n){var s=function(o){var a=Object.prototype,c=a.hasOwnProperty,l,u=typeof Symbol=="function"?Symbol:{},h=u.iterator||"@@iterator",d=u.asyncIterator||"@@asyncIterator",g=u.toStringTag||"@@toStringTag";function p(L,W,H){return Object.defineProperty(L,W,{value:H,enumerable:!0,configurable:!0,writable:!0}),L[W]}try{p({},"")}catch{p=function(W,H,$){return W[H]=$}}function v(L,W,H,$){var ee=W&&W.prototype instanceof f?W:f,ie=Object.create(ee.prototype),le=new Z($||[]);return ie._invoke=N(L,H,le),ie}o.wrap=v;function I(L,W,H){try{return{type:"normal",arg:L.call(W,H)}}catch($){return{type:"throw",arg:$}}}var D="suspendedStart",x="suspendedYield",j="executing",w="completed",y={};function f(){}function M(){}function T(){}var b={};b[h]=function(){return this};var C=Object.getPrototypeOf,P=C&&C(C(Q([])));P&&P!==a&&c.call(P,h)&&(b=P);var E=T.prototype=f.prototype=Object.create(b);M.prototype=E.constructor=T,T.constructor=M,M.displayName=p(T,g,"GeneratorFunction");function O(L){["next","throw","return"].forEach(function(W){p(L,W,function(H){return this._invoke(W,H)})})}o.isGeneratorFunction=function(L){var W=typeof L=="function"&&L.constructor;return W?W===M||(W.displayName||W.name)==="GeneratorFunction":!1},o.mark=function(L){return Object.setPrototypeOf?Object.setPrototypeOf(L,T):(L.__proto__=T,p(L,g,"GeneratorFunction")),L.prototype=Object.create(E),L},o.awrap=function(L){return{__await:L}};function V(L,W){function H(ie,le,pe,Te){var z=I(L[ie],L,le);if(z.type==="throw")Te(z.arg);else{var B=z.arg,X=B.value;return X&&typeof X=="object"&&c.call(X,"__await")?W.resolve(X.__await).then(function(ae){H("next",ae,pe,Te)},function(ae){H("throw",ae,pe,Te)}):W.resolve(X).then(function(ae){B.value=ae,pe(B)},function(ae){return H("throw",ae,pe,Te)})}}var $;function ee(ie,le){function pe(){return new W(function(Te,z){H(ie,le,Te,z)})}return $=$?$.then(pe,pe):pe()}this._invoke=ee}O(V.prototype),V.prototype[d]=function(){return this},o.AsyncIterator=V,o.async=function(L,W,H,$,ee){ee===void 0&&(ee=Promise);var ie=new V(v(L,W,H,$),ee);return o.isGeneratorFunction(W)?ie:ie.next().then(function(le){return le.done?le.value:ie.next()})};function N(L,W,H){var $=D;return function(ie,le){if($===j)throw new Error("Generator is already running");if($===w){if(ie==="throw")throw le;return ce()}for(H.method=ie,H.arg=le;;){var pe=H.delegate;if(pe){var Te=A(pe,H);if(Te){if(Te===y)continue;return Te}}if(H.method==="next")H.sent=H._sent=H.arg;else if(H.method==="throw"){if($===D)throw $=w,H.arg;H.dispatchException(H.arg)}else H.method==="return"&&H.abrupt("return",H.arg);$=j;var z=I(L,W,H);if(z.type==="normal"){if($=H.done?w:x,z.arg===y)continue;return{value:z.arg,done:H.done}}else z.type==="throw"&&($=w,H.method="throw",H.arg=z.arg)}}}function A(L,W){var H=L.iterator[W.method];if(H===l){if(W.delegate=null,W.method==="throw"){if(L.iterator.return&&(W.method="return",W.arg=l,A(L,W),W.method==="throw"))return y;W.method="throw",W.arg=new TypeError("The iterator does not provide a 'throw' method")}return y}var $=I(H,L.iterator,W.arg);if($.type==="throw")return W.method="throw",W.arg=$.arg,W.delegate=null,y;var ee=$.arg;if(!ee)return W.method="throw",W.arg=new TypeError("iterator result is not an object"),W.delegate=null,y;if(ee.done)W[L.resultName]=ee.value,W.next=L.nextLoc,W.method!=="return"&&(W.method="next",W.arg=l);else return ee;return W.delegate=null,y}O(E),p(E,g,"Generator"),E[h]=function(){return this},E.toString=function(){return"[object Generator]"};function k(L){var W={tryLoc:L[0]};1 in L&&(W.catchLoc=L[1]),2 in L&&(W.finallyLoc=L[2],W.afterLoc=L[3]),this.tryEntries.push(W)}function U(L){var W=L.completion||{};W.type="normal",delete W.arg,L.completion=W}function Z(L){this.tryEntries=[{tryLoc:"root"}],L.forEach(k,this),this.reset(!0)}o.keys=function(L){var W=[];for(var H in L)W.push(H);return W.reverse(),function $(){for(;W.length;){var ee=W.pop();if(ee in L)return $.value=ee,$.done=!1,$}return $.done=!0,$}};function Q(L){if(L){var W=L[h];if(W)return W.call(L);if(typeof L.next=="function")return L;if(!isNaN(L.length)){var H=-1,$=function ee(){for(;++H<L.length;)if(c.call(L,H))return ee.value=L[H],ee.done=!1,ee;return ee.value=l,ee.done=!0,ee};return $.next=$}}return{next:ce}}o.values=Q;function ce(){return{value:l,done:!0}}return Z.prototype={constructor:Z,reset:function(L){if(this.prev=0,this.next=0,this.sent=this._sent=l,this.done=!1,this.delegate=null,this.method="next",this.arg=l,this.tryEntries.forEach(U),!L)for(var W in this)W.charAt(0)==="t"&&c.call(this,W)&&!isNaN(+W.slice(1))&&(this[W]=l)},stop:function(){this.done=!0;var L=this.tryEntries[0],W=L.completion;if(W.type==="throw")throw W.arg;return this.rval},dispatchException:function(L){if(this.done)throw L;var W=this;function H(Te,z){return ie.type="throw",ie.arg=L,W.next=Te,z&&(W.method="next",W.arg=l),!!z}for(var $=this.tryEntries.length-1;$>=0;--$){var ee=this.tryEntries[$],ie=ee.completion;if(ee.tryLoc==="root")return H("end");if(ee.tryLoc<=this.prev){var le=c.call(ee,"catchLoc"),pe=c.call(ee,"finallyLoc");if(le&&pe){if(this.prev<ee.catchLoc)return H(ee.catchLoc,!0);if(this.prev<ee.finallyLoc)return H(ee.finallyLoc)}else if(le){if(this.prev<ee.catchLoc)return H(ee.catchLoc,!0)}else if(pe){if(this.prev<ee.finallyLoc)return H(ee.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(L,W){for(var H=this.tryEntries.length-1;H>=0;--H){var $=this.tryEntries[H];if($.tryLoc<=this.prev&&c.call($,"finallyLoc")&&this.prev<$.finallyLoc){var ee=$;break}}ee&&(L==="break"||L==="continue")&&ee.tryLoc<=W&&W<=ee.finallyLoc&&(ee=null);var ie=ee?ee.completion:{};return ie.type=L,ie.arg=W,ee?(this.method="next",this.next=ee.finallyLoc,y):this.complete(ie)},complete:function(L,W){if(L.type==="throw")throw L.arg;return L.type==="break"||L.type==="continue"?this.next=L.arg:L.type==="return"?(this.rval=this.arg=L.arg,this.method="return",this.next="end"):L.type==="normal"&&W&&(this.next=W),y},finish:function(L){for(var W=this.tryEntries.length-1;W>=0;--W){var H=this.tryEntries[W];if(H.finallyLoc===L)return this.complete(H.completion,H.afterLoc),U(H),y}},catch:function(L){for(var W=this.tryEntries.length-1;W>=0;--W){var H=this.tryEntries[W];if(H.tryLoc===L){var $=H.completion;if($.type==="throw"){var ee=$.arg;U(H)}return ee}}throw new Error("illegal catch attempt")},delegateYield:function(L,W,H){return this.delegate={iterator:Q(L),resultName:W,nextLoc:H},this.method==="next"&&(this.arg=l),y}},o}(e.exports);try{regeneratorRuntime=s}catch{Function("r","regeneratorRuntime = r")(s)}},function(e,r){function n(o,a,c,l,u,h,d){try{var g=o[h](d),p=g.value}catch(v){c(v);return}g.done?a(p):Promise.resolve(p).then(l,u)}function s(o){return function(){var a=this,c=arguments;return new Promise(function(l,u){var h=o.apply(a,c);function d(p){n(h,l,u,d,g,"next",p)}function g(p){n(h,l,u,d,g,"throw",p)}d(void 0)})}}e.exports=s},function(e,r){function n(s,o,a){return o in s?Object.defineProperty(s,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):s[o]=a,s}e.exports=n},function(e,r,n){n.r(r),n.d(r,"setupWebGL",function(){return d}),n.d(r,"createProgram",function(){return g}),n.d(r,"pointsToBuffer",function(){return p}),n.d(r,"loadImage",function(){return I}),n.d(r,"fetchShader",function(){return x});var s=n(27),o=n.n(s),a=n(29),c=n.n(a),l=n(32),u=n.n(l);n(1).glMatrix.setMatrixArrayType(Array);function h(w,y){for(var f=["webgl","experimental-webgl","webkit-3d","moz-webgl"],M=null,T=0;T<f.length;++T){try{M=w.getContext(f[T],y)}catch{}if(M)break}return M}function d(w,y){var f=h(w,y);if(!f)throw new Error("Sorry, your browser doesn't support WebGL.");return f}function g(w,y,f){var M=w.createShader(w.VERTEX_SHADER);if(w.shaderSource(M,y),w.compileShader(M),!w.getShaderParameter(M,w.COMPILE_STATUS)){var T="Vertex shader failed to compile. The error log is:".concat(w.getShaderInfoLog(M));throw new Error(T)}var b=w.createShader(w.FRAGMENT_SHADER);if(w.shaderSource(b,f),w.compileShader(b),!w.getShaderParameter(b,w.COMPILE_STATUS)){var C="Fragment shader failed to compile. The error log is:".concat(w.getShaderInfoLog(b));throw new Error(C)}var P=w.createProgram();if(w.attachShader(P,M),w.attachShader(P,b),w.linkProgram(P),!w.getProgramParameter(P,w.LINK_STATUS)){var E="Shader program failed to link. The error log is:".concat(w.getProgramInfoLog(P));throw new Error(E)}return w.deleteShader(M),w.deleteShader(b),P}function p(w){var y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Float32Array,f=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null;if(f&&!(f instanceof y))throw new TypeError("Wrong buffer type.");if(w==null||w instanceof y)return w;if(w[0]==null||w[0].length==null)return f?(f.set(w,0),f):new y(w);var M=w[0].length,T=w.length;f||(f=new y(M*T));for(var b=0,C=0;C<T;C++)for(var P=0;P<M;P++)f[b++]=w[C][P];return f}var v={};function I(w){var y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},f=y.useImageBitmap,M=f===void 0?!0:f,T=y.alias,b=T===void 0?null:T;if(!v[w]){if(typeof Image=="function"){var C=new Image;typeof w=="string"&&!((typeof location>"u"?"undefined":u()(location))==="object"&&/^file:/.test(location.href))&&!/^data:/.test(w)&&(C.crossOrigin="anonymous"),v[w]=new Promise(function(P){C.onload=function(){M&&typeof createImageBitmap=="function"?createImageBitmap(C,{imageOrientation:"flipY"}).then(function(E){v[w]=E,b&&(v[b]=E),P(E)}):(v[w]=C,b&&(v[b]=C),P(C))},C.src=w}),b&&(v[b]=v[w])}else if(typeof fetch=="function")return fetch(w,{method:"GET",mode:"cors",cache:"default"}).then(function(P){return P.blob()}).then(function(P){return createImageBitmap(P,{imageOrientation:"flipY"}).then(function(E){return v[w]=E,b&&(v[b]=E),E})})}return v[w]}var D={};function x(w){return j.apply(this,arguments)}function j(){return j=c()(o.a.mark(function w(y){var f,M;return o.a.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(!D[y]){b.next=2;break}return b.abrupt("return",D[y]);case 2:return b.next=4,fetch(y);case 4:if(f=b.sent,!(f.status>=200&&f.status<300)){b.next=11;break}return b.next=8,f.text();case 8:return M=b.sent,D[y]=M,b.abrupt("return",M);case 11:throw new Error("Shader loaded error.");case 12:case"end":return b.stop()}},w)})),j.apply(this,arguments)}},function(e,r){function n(s){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?e.exports=n=function(a){return typeof a}:e.exports=n=function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},n(s)}e.exports=n},function(e,r,n){n.r(r),r.default=`attribute vec3 a_vertexPosition;
23
+
24
+ void main() {
25
+ gl_PointSize = 1.0;
26
+ gl_Position = vec4(a_vertexPosition, 1);
27
+ }`},function(e,r,n){n.r(r),r.default=`#ifdef GL_ES
28
+ precision mediump float;
29
+ #endif
30
+
31
+ void main() {
32
+ gl_FragColor = vec4(0.0, 0.0, 0.0, 0.1);
33
+ }`},function(e,r,n){n.r(r),r.default=`attribute vec4 a_vertexPosition;
34
+ attribute vec2 a_vertexTextureCoord;
35
+ varying vec2 vTextureCoord;
36
+
37
+ void main() {
38
+ gl_PointSize = 1.0;
39
+ gl_Position = a_vertexPosition;
40
+ vTextureCoord = a_vertexTextureCoord;
41
+ }`},function(e,r,n){n.r(r),n.d(r,"default",function(){return w});var s=n(19),o=n.n(s),a=n(13),c=n.n(a),l=n(27),u=n.n(l),h=n(29),d=n.n(h),g=n(23),p=n.n(g),v=n(24),I=n.n(v),D=n(37),x=n(41);n(1).glMatrix.setMatrixArrayType(Array);var j=Symbol("transform"),w=function(){function y(f,M){p()(this,y),this.context=f.getContext("2d"),this.options=M,this[j]=[1,0,0,1,0,0]}return I()(y,[{key:"createTexture",value:function(M){var T={_img:M};return T}},{key:"loadTexture",value:function(){var f=d()(u.a.mark(function T(b){var C;return u.a.wrap(function(E){for(;;)switch(E.prev=E.next){case 0:return E.next=2,D.default.loadImage(b,{useImageBitmap:!1});case 2:return C=E.sent,E.abrupt("return",this.createTexture(C));case 4:case"end":return E.stop()}},T,this)}));function M(T){return f.apply(this,arguments)}return M}()},{key:"deleteTexture",value:function(M){return M}},{key:"clear",value:function(M,T,b,C){var P=this.context;M=M||0,T=T||0,b=b||P.canvas.width-M,C=C||P.canvas.height-T,P.clearRect(M,T,b,C)}},{key:"drawMeshCloud",value:function(M){for(var T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},b=T.clear,C=b===void 0?!1:b,P=[],E=0;E<M.amount;E++){var O=M.getTransform(E),V=M.getTextureFrame(E);V&&(V=V._img);var N=M.getFilter(E),A=M.getCloudRGBA(E),k=A.fill,U=A.stroke;P.push({mesh:M.mesh,_cloudOptions:[k,U,V,O,N]})}M.beforeRender&&M.beforeRender(this.context,M),this.drawMeshes(P,{clear:C,hook:!1}),M.afterRender&&M.afterRender(this.context,M)}},{key:"drawMeshes",value:function(M){var T=this,b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},C=b.clear,P=C===void 0?!1:C,E=b.hook,O=E===void 0?!0:E,V=this.context;P&&V.clearRect(0,0,V.canvas.width,V.canvas.height);var N=null,A=V.canvas,k=A.width,U=A.height,Z=M.length;M.forEach(function(Q,ce){var L,W,H,$,ee;if(O&&Q.beforeRender&&Q.beforeRender(V,Q),Q._cloudOptions){var ie=c()(Q._cloudOptions,5);L=ie[0],W=ie[1],H=ie[2],$=ie[3],ee=ie[4],Q=Q.mesh}var le=Q.filter;if(ee&&(le=le?"".concat(le," ").concat(ee):ee),le&&!T.filterBuffer&&T.filterBuffer!==!1){var pe=D.default.createCanvas(k,U);pe?T.filterBuffer=pe.getContext("2d"):T.filterBuffer=!1}if(N&&N!==le&&(Object(x.applyFilter)(T.filterBuffer,N),V.drawImage(T.filterBuffer.canvas,0,0,k,U),T.filterBuffer.clearRect(0,0,k,U),N=null),le&&T.filterBuffer){var Te;T.filterBuffer.save(),(Te=T.filterBuffer).transform.apply(Te,o()(T[j])),Object(x.drawMesh2D)(Q,T.filterBuffer,!1,L,W,H,$),T.filterBuffer.restore(),ce===Z-1?(Object(x.applyFilter)(T.filterBuffer,le),V.drawImage(T.filterBuffer.canvas,0,0,k,U),T.filterBuffer.clearRect(0,0,k,U)):N=le}else V.save(),V.transform.apply(V,o()(T[j])),Object(x.drawMesh2D)(Q,V,!1,L,W,H,$),V.restore();O&&Q.afterRender&&Q.afterRender(V,Q)})}},{key:"setTransform",value:function(M){this[j]=M}}]),y}()},function(e,r,n){n.r(r),(function(s){var o=n(32),a=n.n(o),c=n(19),l=n.n(c),u=n(25),h=n(39),d=n(40);n(1).glMatrix.setMatrixArrayType(Array);var g={};function p(w,y){var f=w.style,M=w.variant,T=w.weight,b=w.stretch,C=w.size,P=w.pxLineHeight,E=w.family;return b==="normal"?"".concat(f," ").concat(M," ").concat(T," ").concat(C*y,"px/").concat(P*y,"px ").concat(E):"".concat(f," ").concat(M," ").concat(T," ").concat(b," ").concat(C*y,"px/").concat(P*y,"px ").concat(E)}function v(w,y){var f=y.font,M=y.fillColor,T=y.strokeColor,b=y.strokeWidth,C=y.ratio,P=C===void 0?1:C,E=y.textCanvas,O=y.cachable,V=O===void 0?!1:O,N;if(V){N=[w,f,String(M),String(T),String(b)].join("###");var A=g[N];if(A)return A}E||(E=x(1,1));var k=E.getContext("2d");k.save(),k.font=f;var U=k.measureText(w),Z=U.width;k.restore();var Q=Object(h.default)(f),ce=Math.max(Q.pxLineHeight,Q.pxHeight*1.13);/italic|oblique/.test(f)&&(Z+=ce*Math.tan(15*Math.PI/180)),!M&&!T&&(M="#000");var L=k.canvas,W=Math.ceil(Z),H=Math.ceil(ce);L.width=Math.round(W*P),L.height=Math.round(H*P),k.save(),k.font=p(Q,P),k.textAlign="center",k.textBaseline="middle";var $=L.height*.5+Q.pxHeight*.05*P,ee=L.width*.5;if(M){if(Array.isArray(M))M=Object(d.default)(M);else if(M.vector){var ie,le=M,pe=le.vector,Te=le.colors;pe.length===6?ie=k.createRadialGradient.apply(k,l()(pe)):ie=k.createLinearGradient.apply(k,l()(pe)),Te.forEach(function(te){var m=te.offset,S=te.color;ie.addColorStop(m,S)}),M=ie}k.fillStyle=M,k.fillText(w,ee,$)}if(T){if(k.lineWidth=b*P,Array.isArray(T))T=Object(d.default)(T);else if(T.vector){var z,B=T,X=B.vector,ae=B.colors;X.length===6?z=k.createRadialGradient.apply(k,l()(X)):z=k.createLinearGradient.apply(k,l()(X)),ae.forEach(function(te){var m=te.offset,S=te.color;z.addColorStop(m,S)}),T=z}k.strokeStyle=T,k.strokeText(w,ee,$)}k.restore();var q={image:E,rect:[0,0,W,H]};return V&&(g[N]=q),q}var I=!1;if((typeof navigator>"u"?"undefined":a()(navigator))==="object"&&typeof navigator.userAgent=="string"){var D=navigator.userAgent.toLowerCase().match(/chrome\/(\d+)/);D&&(I=Number(D[1])<70)}function x(w,y){var f=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},M=f.offscreen||!I&&f.offscreen!==!1,T;return typeof s<"u"&&typeof s.createCanvas=="function"?T=s.createCanvas(w,y,f):M&&typeof OffscreenCanvas=="function"?T=new OffscreenCanvas(w,y):(T=document.createElement("canvas"),T.width=w,T.height=y),T}var j={createCanvas:x,createText:v,loadImage:u.default.loadImage};r.default=j}).call(this,n(38))},function(e,r){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch{typeof window=="object"&&(n=window)}e.exports=n},function(e,r,n){n.r(r),n.d(r,"default",function(){return D}),n(1).glMatrix.setMatrixArrayType(Array);function s(x,j){if(typeof x=="string"){var w=x.trim().match(/^([\d.]+)(px|pt|pc|in|cm|mm|em|ex|rem|q|vw|vh|vmax|vmin|%)$/);w?x={size:parseFloat(w[1]),unit:w[2]}:x={size:parseInt(x,10),unit:"px"}}var y=x,f=y.size,M=y.unit;if(M==="pt")f/=.75;else if(M==="pc")f*=16;else if(M==="in")f*=96;else if(M==="cm")f*=96/2.54;else if(M==="mm")f*=96/25.4;else if(M==="em"||M==="rem"||M==="ex"){if(!j&&typeof getComputedStyle=="function"&&typeof document<"u"){var T=getComputedStyle(document.documentElement).fontSize;j=s(T,16)}f*=j,M==="ex"&&(f/=2)}else if(M==="q")f*=96/25.4/4;else if(M==="vw"||M==="vh"){if(typeof document<"u"){var b=M==="vw"?document.documentElement.clientWidth:document.documentElement.clientHeight;f*=b/100}}else if((M==="vmax"||M==="vmin")&&typeof document<"u"){var C=document.documentElement.clientWidth,P=document.documentElement.clientHeight;M==="vmax"?f*=Math.max(C,P)/100:f*=Math.min(C,P)/100}return f}var o="bold|bolder|lighter|[1-9]00",a="italic|oblique",c="small-caps",l="ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded",u="px|pt|pc|in|cm|mm|em|ex|rem|q|vw|vh|vmax|vmin|%",h=`'([^']+)'|"([^"]+)"|([\\w-]|[一-龥])+`,d=new RegExp("(".concat(o,") +"),"i"),g=new RegExp("(".concat(a,") +"),"i"),p=new RegExp("(".concat(c,") +"),"i"),v=new RegExp("(".concat(l,") +"),"i"),I=new RegExp("([\\d\\.]+)("+u+")(?:\\/([\\d\\.]+)("+u+"))? *((?:"+h+")( *, *(?:"+h+"))*)");function D(x,j){var w=I.exec(x);if(w){var y=parseFloat(w[3]),f={weight:"normal",style:"normal",stretch:"normal",variant:"normal",size:parseFloat(w[1]),unit:w[2],lineHeight:Number.isFinite(y)?y:void 0,lineHeightUnit:w[4],family:w[5].replace(/ *, */g,",")},M=x.substring(0,w.index),T=d.exec(M),b=g.exec(M),C=p.exec(M),P=v.exec(M);return T&&(f.weight=T[1]),b&&(f.style=b[1]),C&&(f.variant=C[1]),P&&(f.stretch=P[1]),f.pxHeight=s({size:f.size,unit:f.unit},j),f.pxLineHeight=s({size:f.lineHeight||f.size,unit:f.lineHeightUnit||f.unit},j),f}}},function(e,r,n){n.r(r),n.d(r,"default",function(){return s}),n(1).glMatrix.setMatrixArrayType(Array);function s(o){return"rgba(".concat(o.map(function(a,c){return c<3?Math.round(a*255):a}).join(),")")}},function(e,r,n){n.r(r),n.d(r,"applyFilter",function(){return h}),n.d(r,"drawMesh2D",function(){return g});var s=n(19),o=n.n(s),a=n(1),c=n(40),l=n(39),u=n(42);n(1).glMatrix.setMatrixArrayType(Array);function h(p,v){var I=p.canvas;p.save(),p.filter=v,p.drawImage(I,0,0,I.width,I.height),p.restore()}function d(p,v){var I=/rgba\((\d+),(\d+),(\d+),(\d+)\)/;p=p.match(I).slice(1,5).map(Number),v=v.match(I).slice(1,5).map(Number);for(var D=[],x=v[3],j=0;j<4;j++)D[j]=Object(u.mix)(p[j],v[j],x);return"rgba(".concat(D.join(),")")}function g(p,v){var I=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,D=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null,x=arguments.length>4&&arguments[4]!==void 0?arguments[4]:null,j=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null,w=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null;v.save();var y=!1,f=!1;if(v.globalAlpha=p.getOpacity(),p._updateMatrix){var M=p.transformScale/p.contours.scale;M>1.5&&p.accurate(p.transformScale)}if(p.lineWidth){var T=p.gradient&&p.gradient.stroke;if(T){var b=T,C=b.vector,P=b.colors;if(C.length===6)T=v.createRadialGradient.apply(v,o()(C));else if(C.length===4)T=v.createLinearGradient.apply(v,o()(C));else if(C.length===3)T=v.createCircularGradient.apply(v,o()(C));else throw new TypeError("Invalid vector dimension.");P.forEach(function(Q){var ce=Q.offset,L=Q.color,W=Object(c.default)(L);x&&(W=d(W,x)),T.addColorStop(ce,W)}),v.strokeStyle=T,y=!0}else p.strokeStyle&&(x?v.strokeStyle=d(p.strokeStyle,x):v.strokeStyle=p.strokeStyle,y=!0)}y&&(v.lineWidth=p.lineWidth,v.lineJoin=p.lineJoin,v.lineCap=p.lineCap,v.miterLimit=p.miterLimit,p.lineDash&&(v.setLineDash(p.lineDash),p.lineDashOffset&&(v.lineDashOffset=p.lineDashOffset)));var E=p.gradient&&p.gradient.fill;if(E){var O=E,V=O.vector,N=O.colors;if(V.length===6)E=v.createRadialGradient.apply(v,o()(V));else if(V.length===4)E=v.createLinearGradient.apply(v,o()(V));else if(V.length===3)E=v.createCircularGradient.apply(v,o()(V));else throw new TypeError("Invalid vector dimension.");N.forEach(function(Q){var ce=Q.offset,L=Q.color,W=Object(c.default)(L);x&&(W=d(W,x)),E.addColorStop(ce,W)}),v.fillStyle=E,f=!0}else p.fillStyle&&(D?v.fillStyle=d(p.fillStyle,D):v.fillStyle=p.fillStyle,f=!0);if(w&&v.transform.apply(v,o()(w)),v.transform.apply(v,o()(p.transformMatrix)),p.clipPath){var A=p.clipPath,k=new Path2D(A);v.clip(k)}var U=p.contours.length;if(p.contours.forEach(function(Q,ce){var L=Q.length,W=L>1&&a.vec2.equals(Q[0],Q[L-1]),H=ce===U-1&&p.texture;if(Q&&L>0){if(f||y||H){v.beginPath(),v.moveTo.apply(v,o()(Q[0]));for(var $=1;$<L;$++)$===L-1&&W?v.closePath():v.lineTo.apply(v,o()(Q[$]))}if(f&&v.fill(p.fillRule),H){v.save(),v.clip();var ee=p.texture,ie=ee.image,le=ee.options;if(j&&(ie=j),le.repeat&&console.warn("Context 2D not supported image repeat yet."),ie.font){le.scale&&console.warn("Context 2D not supported text scale yet."),le.srcRect&&console.warn("Context 2D not supported text srcRect yet.");var pe=ie,Te=pe.font,z=pe.fillColor,B=pe.strokeColor,X=pe.strokeWidth,ae=pe.text;!z&&!B&&(z="#000"),Array.isArray(z)&&(z=Object(c.default)(z)),Array.isArray(B)&&(B=Object(c.default)(B)),v.font=Te;var q=v.measureText(ae),te=q.width,m=Object(l.default)(Te),S=Math.max(m.pxLineHeight,m.pxHeight*1.13);v.textAlign="center",v.textBaseline="middle";var F=le.rect,Y=F[0]+S*.5+m.pxHeight*.06,_=F[1]+te*.5;F[2]!=null&&v.scale(F[2]/te,F[3]/S),z&&(v.fillStyle=z,v.fillText(ae,_,Y)),B&&(v.lineWidth=X,v.strokeStyle=B,v.strokeText(ae,_,Y))}else{var re=le.rect,ne=le.srcRect;le.scale&&(re=[0,0,v.canvas.width,v.canvas.height]),le.rotated&&re&&(re=[-re[1],re[0],re[3],re[2]]),ne&&(re=re||[0,0,ne[2],ne[3]]),le.rotated&&(v.translate(0,re?re[2]:ie.width),v.rotate(-.5*Math.PI)),ne?v.drawImage.apply(v,[ie].concat(o()(ne),o()(re))):re?v.drawImage.apply(v,[ie].concat(o()(re))):v.drawImage(ie,0,0)}v.restore()}y&&v.stroke()}}),v.restore(),I){var Z=p.filter;Z&&h(v,Z)}}},function(e,r,n){n.r(r),n.d(r,"clamp",function(){return a}),n.d(r,"mix",function(){return c}),n.d(r,"transformPoint",function(){return l});var s=n(13),o=n.n(s);n(1).glMatrix.setMatrixArrayType(Array);function a(u,h,d){if(h>d){var g=[d,h];h=g[0],d=g[1]}return u<h?h:u>d?d:u}function c(u,h,d){return u*(1-d)+h*d}function l(u,h){var d=o()(u,2),g=d[0],p=d[1];return[g*h[0]+p*h[2]+h[4],g*h[1]+p*h[3]+h[5]]}},function(e,r,n){n.r(r),n.d(r,"default",function(){return g});var s=n(27),o=n.n(s),a=n(44),c=n(45);n(1).glMatrix.setMatrixArrayType(Array);var l=o.a.mark(g);function u(p,v,I){var D=p.uniforms||{},x=v.uniforms||{};if(D.u_texSampler&&x.u_texSampler&&D.u_texSampler!==x.u_texSampler)return!1;var j=Object.keys(D),w=Object.keys(x),y=j.indexOf("u_texSampler"),f=w.indexOf("u_texSampler");if(y>=0&&j.splice(y,1),f>=0&&w.splice(f,1),j.length!==w.length)return!1;var M=j.every(function(b){var C=D[b],P=x[b];if(C===P)return!0;if(C.length&&P.length&&C.length===P.length){for(var E=0;E<C.length;E++)if(C[E]!==P[E])return!1;return!0}return!1});if(M){if(D.u_texSampler&&!x.u_texSampler)v.setTexture(D.u_texSampler,{hidden:!0});else if(!D.u_texSampler&&x.u_texSampler)for(var T=0;T<I.length;T++)I[T].setTexture(x.u_texSampler,{hidden:!0})}return M}var h={};function d(p,v){if(p.length){var I=Object(a.default)(p,h);return I.enableBlend=v,p[0].filterCanvas&&(I.filterCanvas=!0),I.packIndex=p[0].packIndex,I.packLength=p.length,I.beforeRender=p[0].beforeRender,I.pass=p[0].pass,I.afterRender=p[p.length-1].afterRender,p.length=0,I}}function g(p,v){var I,D,x,j,w,y,f,M,T,b,C,P,E=arguments;return o.a.wrap(function(V){for(;;)switch(V.prev=V.next){case 0:I=E.length>2&&E[2]!==void 0?E[2]:!1,D=[],x=p.options.bufferSize,j=0,w=!1,y=0;case 6:if(!(y<v.length)){V.next=50;break}if(f=v[y],!(f instanceof c.default)){V.next=18;break}if(!D.length){V.next=12;break}return V.next=12,d(D,w);case 12:return j=0,w=!1,V.next=16,f;case 16:V.next=47;break;case 18:if(M=f.meshData,M.clipPath&&!M.uniforms.u_clipSampler&&(T=p.createTexture(M.clipPath),M.uniforms.u_clipSampler=T),b=0,!((!I||!f.canIgnore())&&M&&M.positions.length)){V.next=43;break}if(f.packIndex=y,C=f.filterCanvas,b=M.positions.length,!(C||j+b>x)){V.next=33;break}if(!D.length){V.next=29;break}return V.next=29,d(D,w);case 29:j=0,w=!1,V.next=40;break;case 33:if(!j){V.next=40;break}if(P=D[D.length-1],!(P&&(P.filterCanvas||P.afterRender||f.beforeRender||P.pass.length||f.pass.length||P.program!==f.program||!u(P,f,D)))){V.next=40;break}return V.next=38,d(D,w);case 38:j=0,w=!1;case 40:D.push(f),w=w||f.enableBlend,j+=b;case 43:if(y!==v.length-1){V.next=47;break}if(!D.length){V.next=47;break}return V.next=47,d(D,w);case 47:y++,V.next=6;break;case 50:case"end":return V.stop()}},l)}},function(e,r,n){n.r(r),n.d(r,"default",function(){return h});var s=n(19),o=n.n(s),a=n(13),c=n.n(a);n(1).glMatrix.setMatrixArrayType(Array);var l={UNSIGNED_BYTE:Uint8Array,UNSIGNED_SHORT:Uint16Array,BYTE:Int8Array,SHORT:Int16Array,FLOAT:Float32Array};function u(d,g){for(var p=0,v=0,I=0,D=0,x=0,j=0,w=0,y=d[0].program,f=0;f<d.length;f++){var M=d[f].meshData;if(M){w+=M.positions.length;var T=M.positions[0].length;p+=M.positions.length*T,v+=M.cells.length*3,j+=M.attributes.a_color.length*4;var b=M.textureCoord;b&&(I+=b.length*b[0].length);var C=M.attributes.a_sourceRect;C&&(D+=C.length*4);var P=M.attributes.a_clipUV;P&&(x+=P.length*2)}}if((!g.positions||g.positions.length<p)&&(g.positions=new Float32Array(p)),(!g.cells||g.cells.length<v)&&(g.cells=new Uint16Array(v)),I&&(!g.textureCoord||g.textureCoord.length<I)&&(g.textureCoord=new Float32Array(I)),(!g.a_color||g.a_color.length<j)&&(g.a_color=new Uint8Array(j)),D&&(!g.a_sourceRect||g.a_sourceRect.length<D)&&(g.a_sourceRect=new Float32Array(D)),x&&(!g.a_clipUV||g.a_clipUV.length<x)&&(g.a_clipUV=new Float32Array(x)),y)for(var E=Object.entries(y._attribute),O=y._attribOpts||{},V=0;V<E.length;V++){var N=c()(E[V],2),A=N[0],k=N[1];if(A!=="a_color"&&A!=="a_sourceRect"&&k!=="ignored"){var U=O[A]?O[A].type:"FLOAT",Z=l[U],Q=k.size*w;(!g[A]||g[A].length<Q)&&(g[A]=new Z(Q))}}return g}function h(d,g){var p=[],v=[],I=[],D=[],x=[],j=[],w=0,y=0,f=d[0]?d[0].uniforms||{}:{},M=d[0]?d[0].program:null;g&&(u(d,g),v=g.cells,p=g.positions,I=g.textureCoord,D=g.a_color,x=g.a_sourceRect,j=g.a_clipUV);for(var T=!1,b=!1,C={},P=0;P<d.length;P++){var E=d[P];if(E){if(E.meshData&&(E=E.meshData),g)for(var O=E.positions,V=0;V<O.length;V++)for(var N=O[V],A=3*(w+V),k=0;k<N.length;k++)p[A+k]=N[k];else{var U;(U=p).push.apply(U,o()(E.positions))}for(var Z=E.cells,Q=0;Q<Z.length;Q++){var ce=Z[Q];if(g){var L=3*(y+Q);v[L]=ce[0]+w,v[L+1]=ce[1]+w,v[L+2]=ce[2]+w}else v.push([ce[0]+w,ce[1]+w,ce[2]+w])}if(g)for(var W=E.attributes.a_color,H=0;H<W.length;H++){var $=W[H],ee=4*(w+H);D[ee]=$[0],D[ee+1]=$[1],D[ee+2]=$[2],D[ee+3]=$[3]}else{var ie;(ie=D).push.apply(ie,o()(E.attributes.a_color))}if(E.attributes.a_sourceRect)if(T=!0,g)for(var le=E.attributes.a_sourceRect,pe=0;pe<le.length;pe++){var Te=le[pe],z=4*(w+pe);x[z]=Te[0],x[z+1]=Te[1],x[z+2]=Te[2],x[z+3]=Te[3]}else{var B;(B=x).push.apply(B,o()(E.attributes.a_sourceRect))}if(E.attributes.a_clipUV)if(b=!0,g)for(var X=E.attributes.a_clipUV,ae=0;ae<X.length;ae++){var q=X[ae],te=2*(w+ae);j[te]=q[0],j[te+1]=q[1]}else{var m;(m=j).push.apply(m,o()(E.attributes.a_clipUV))}if(E.textureCoord)if(g)for(var S=E.textureCoord,F=0;F<S.length;F++)for(var Y=S[F],_=3*(w+F),re=0;re<Y.length;re++)I[_+re]=Y[re];else{var ne;(ne=I).push.apply(ne,o()(E.textureCoord))}if(M)for(var J=Object.entries(M._attribute),se=0;se<J.length;se++){var ue=c()(J[se],2),oe=ue[0],de=ue[1];if(oe!=="a_color"&&oe!=="a_sourceRect"&&de!=="ignored")if(C[oe]=[],g){C[oe]=g[oe];for(var me=E.attributes[oe],ye=me[0].length,be=0;be<me.length;be++)for(var Ce=me[be],Ie=ye*(w+be),Pe=0;Pe<Ce.length;Pe++)C[oe][Ie+Pe]=Ce[Pe]}else{var Re;(Re=C[oe]).push.apply(Re,o()(E.attributes[oe]))}}w+=E.positions.length,y+=E.cells.length}}C.a_color=D,T&&x&&x.length>0&&(C.a_sourceRect=x);var ke={positions:p,cells:v,attributes:C,uniforms:f,cellsCount:y*3,program:M};return I&&I.length&&(ke.textureCoord=I),b&&j.length>0&&(C.a_clipUV=j),ke}},function(e,r,n){n.r(r),n.d(r,"default",function(){return N});var s=n(30),o=n.n(s),a=n(19),c=n.n(a),l=n(13),u=n.n(l),h=n(23),d=n.n(h),g=n(24),p=n.n(g),v=n(1),I=n(46),D=n(42),x=n(47);n(1).glMatrix.setMatrixArrayType(Array);function j(A,k){var U=Object.keys(A);if(Object.getOwnPropertySymbols){var Z=Object.getOwnPropertySymbols(A);k&&(Z=Z.filter(function(Q){return Object.getOwnPropertyDescriptor(A,Q).enumerable})),U.push.apply(U,Z)}return U}function w(A){for(var k=1;k<arguments.length;k++){var U=arguments[k]!=null?arguments[k]:{};k%2?j(Object(U),!0).forEach(function(Z){o()(A,Z,U[Z])}):Object.getOwnPropertyDescriptors?Object.defineProperties(A,Object.getOwnPropertyDescriptors(U)):j(Object(U)).forEach(function(Z){Object.defineProperty(A,Z,Object.getOwnPropertyDescriptor(U,Z))})}return A}var y=Symbol("mesh"),f=Symbol("count"),M=Symbol("blend"),T=Symbol("filter"),b=Symbol("textures"),C=Symbol("textureOptions"),P=Symbol("cloudColor"),E=Symbol("cloudFilter"),O=Symbol("buffer");function V(A){var k=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,U=new Float32Array(3*A),Z=new Float32Array(3*A),Q=new Float32Array(4*A),ce=new Float32Array(4*A),L=new Float32Array(4*A),W=new Float32Array(4*A),H=new Float32Array(4*A),$=new Uint8Array(A),ee=new Uint8Array(4*A),ie=new Uint8Array(4*A);return k&&(U.set(k.transform0,0),Z.set(k.transform1,0),Q.set(k.color0,0),ce.set(k.color1,0),L.set(k.color2,0),W.set(k.color3,0),H.set(k.color4,0),$.set(k.frameIndex,0),ee.set(k.fillColor,0),ie.set(k.strokeColor,0)),{bufferSize:A,transform0:U,transform1:Z,color0:Q,color1:ce,color2:L,color3:W,color4:H,frameIndex:$,fillColor:ee,strokeColor:ie}}var N=function(){function A(k){var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,Z=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},Q=Z.buffer,ce=Q===void 0?1e3:Q;d()(this,A),ce=Math.max(ce,U),this[f]=U,this[y]=k,this[O]=V(ce),this[b]=[],this[T]=[],this[P]=!1,this[E]=!1,this[M]=!1,this.initBuffer()}return p()(A,[{key:"initBuffer",value:function(){for(var U=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,Z=this[f],Q=U;Q<Z;Q++)this[O].transform0.set([1,0,0],Q*3),this[O].transform1.set([0,1,0],Q*3),this[O].frameIndex.set([-1],Q),this[O].fillColor.set([0,0,0,0],Q*4),this[O].strokeColor.set([0,0,0,0],Q*4),this.setColorTransform(Q,null)}},{key:"_getFilter",value:function(U){return this[T][U]=this[T][U]||[],this[T][U]}},{key:"getFilter",value:function(U){return this._getFilter(U).join(" ")}},{key:"canIgnore",value:function(){return this[y].canIgnore()}},{key:"delete",value:function(U){if(U>=this[f]||U<0)throw new Error("Out of range.");var Z=this[O],Q=Z.transform0,ce=Z.transform1,L=Z.color0,W=Z.color1,H=Z.color2,$=Z.color3,ee=Z.color4,ie=Z.frameIndex,le=Z.fillColor,pe=Z.strokeColor;Q.set(Q.subarray(3*(U+1)),3*U),ce.set(ce.subarray(3*(U+1)),3*U),L.set(L.subarray(4*(U+1)),4*U),W.set(W.subarray(4*(U+1)),4*U),H.set(H.subarray(4*(U+1)),4*U),$.set($.subarray(4*(U+1)),4*U),ee.set(ee.subarray(4*(U+1)),4*U),ie.set(ie.subarray(U+1),U),le.set(le.subarray(4*(U+1)),4*U),pe.set(pe.subarray(4*(U+1)),4*U);for(var Te in this[T])Te===U?delete this[T][Te]:Te>U&&(this[T][Te-1]=this[T][Te],delete this[T][Te]);this[f]--}},{key:"setColorTransform",value:function(U,Z){if(U>=this[f]||U<0)throw new Error("Out of range.");U*=4;var Q=this[O],ce=Q.color0,L=Q.color1,W=Q.color2,H=Q.color3,$=Q.color4;return Z!=null?(ce.set([Z[0],Z[5],Z[10],Z[15]],U),L.set([Z[1],Z[6],Z[11],Z[16]],U),W.set([Z[2],Z[7],Z[12],Z[17]],U),H.set([Z[3],Z[8],Z[13],Z[18]],U),$.set([Z[4],Z[9],Z[14],Z[19]],U),this[M]=this[M]||Z[18]<1,this[E]=!0):(ce.set([1,0,0,0],U),L.set([0,1,0,0],U),W.set([0,0,1,0],U),H.set([0,0,0,1],U),$.set([0,0,0,0],U)),this}},{key:"getColorTransform",value:function(U){if(U>=this[f]||U<0)throw new Error("Out of range.");U*=4;var Z=this[O],Q=Z.color0,ce=Z.color1,L=Z.color2,W=Z.color3,H=Z.color4;return[Q[U],ce[U],L[U],W[U],H[U],Q[U+1],ce[U+1],L[U+1],W[U+1],H[U+1],Q[U+2],ce[U+2],L[U+2],W[U+2],H[U+2],Q[U+3],ce[U+3],L[U+3],W[U+3],H[U+3]]}},{key:"transformColor",value:function(U,Z){var Q=this.getColorTransform(U);return Q=Object(I.multiply)(Q,Z),this.setColorTransform(U,Q),this}},{key:"setFillColor",value:function(U,Z){if(U>=this[f]||U<0)throw new Error("Out of range.");typeof Z=="string"&&(Z=Object(x.default)(Z)),Z[3]>0&&(this[P]=!0),this[O].fillColor.set(Z.map(function(Q){return Math.round(255*Q)}),4*U)}},{key:"setStrokeColor",value:function(U,Z){if(U>=this[f]||U<0)throw new Error("Out of range.");typeof Z=="string"&&(Z=Object(x.default)(Z)),Z[3]>0&&(this[P]=!0),this[O].strokeColor.set(Z.map(function(Q){return Math.round(255*Q)}),4*U)}},{key:"getCloudRGBA",value:function(U){if(U>=this[f]||U<0)throw new Error("Out of range.");U*=4;var Z=this[O],Q=Z.fillColor,ce=Z.strokeColor,L=[Q[U],Q[U+1],Q[U+2],Q[U+3]],W=[ce[U],ce[U+1],ce[U+2],ce[U+3]];return L[3]/=255,W[3]/=255,{fill:"rgba(".concat(L.join(),")"),stroke:"rgba(".concat(W.join(),")")}}},{key:"grayscale",value:function(U,Z){this.transformColor(U,Object(I.grayscale)(Z)),this._getFilter(U).push("grayscale(".concat(100*Z,"%)"))}},{key:"brightness",value:function(U,Z){this.transformColor(U,Object(I.brightness)(Z)),this._getFilter(U).push("brightness(".concat(100*Z,"%)"))}},{key:"saturate",value:function(U,Z){this.transformColor(U,Object(I.saturate)(Z)),this._getFilter(U).push("saturate(".concat(100*Z,"%)"))}},{key:"contrast",value:function(U,Z){this.transformColor(U,Object(I.contrast)(Z)),this._getFilter(U).push("contrast(".concat(100*Z,"%)"))}},{key:"invert",value:function(U,Z){this.transformColor(U,Object(I.invert)(Z)),this._getFilter(U).push("invert(".concat(100*Z,"%)"))}},{key:"sepia",value:function(U,Z){this.transformColor(U,Object(I.sepia)(Z)),this._getFilter(U).push("sepia(".concat(100*Z,"%)"))}},{key:"opacity",value:function(U,Z){this.transformColor(U,Object(I.opacity)(Z)),this._getFilter(U).push("opacity(".concat(100*Z,"%)"))}},{key:"hueRotate",value:function(U,Z){this.transformColor(U,Object(I.hueRotate)(Z)),this._getFilter(U).push("hue-rotate(".concat(Z,"deg)"))}},{key:"setTransform",value:function(U,Z){if(U>=this[f]||U<0)throw new Error("Out of range.");U*=3,Z==null&&(Z=[1,0,0,1,0,0]);var Q=this[O],ce=Q.transform0,L=Q.transform1;return ce.set([Z[0],Z[2],Z[4]],U),L.set([Z[1],Z[3],Z[5]],U),this}},{key:"getTransform",value:function(U){if(U>=this[f]||U<0)throw new Error("Out of range.");U*=3;var Z=this[O],Q=Z.transform0,ce=Z.transform1,L=[Q[U],ce[U],Q[U+1],ce[U+1],Q[U+2],ce[U+2]];return L}},{key:"getTextureFrame",value:function(U){return this[b][this[O].frameIndex[U]]}},{key:"setTextureFrames",value:function(){var U=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],Z=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(U.length>12)throw new Error("Max frames exceed. Allow 12 frames.");if(U.length){var Q=this[y];Q.setTexture(U[0],Z)}this[b]=U,this[C]=Z}},{key:"setFrameIndex",value:function(U,Z){if(U>=this[f]||U<0)throw new Error("Out of range.");var Q=this[b].length;if(Q<=0)throw new Error("No frames");this[O].frameIndex[U]=Z%Q}},{key:"setProgram",value:function(U){this[y].setProgram(U)}},{key:"transform",value:function(U,Z){var Q=this.getTransform(U);return Z=v.mat2d.multiply(Array.of(0,0,0,0,0,0),Q,Z),this.setTransform(U,Z),this}},{key:"translate",value:function(U,Z){var Q=u()(Z,2),ce=Q[0],L=Q[1],W=v.mat2d.create();return W=v.mat2d.translate(Array.of(0,0,0,0,0,0),W,[ce,L]),this.transform(U,W)}},{key:"rotate",value:function(U,Z){var Q=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[0,0],ce=u()(Q,2),L=ce[0],W=ce[1],H=v.mat2d.create();return H=v.mat2d.translate(Array.of(0,0,0,0,0,0),H,[L,W]),H=v.mat2d.rotate(Array.of(0,0,0,0,0,0),H,Z),H=v.mat2d.translate(Array.of(0,0,0,0,0,0),H,[-L,-W]),this.transform(U,H)}},{key:"scale",value:function(U,Z){var Q=u()(Z,2),ce=Q[0],L=Q[1],W=L===void 0?ce:L,H=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[0,0],$=u()(H,2),ee=$[0],ie=$[1],le=v.mat2d.create();return le=v.mat2d.translate(Array.of(0,0,0,0,0,0),le,[ee,ie]),le=v.mat2d.scale(Array.of(0,0,0,0,0,0),le,[ce,W]),le=v.mat2d.translate(Array.of(0,0,0,0,0,0),le,[-ee,-ie]),this.transform(U,le)}},{key:"skew",value:function(U,Z){var Q=u()(Z,2),ce=Q[0],L=Q[1],W=L===void 0?ce:L,H=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[0,0],$=u()(H,2),ee=$[0],ie=$[1],le=v.mat2d.create();return le=v.mat2d.translate(Array.of(0,0,0,0,0,0),le,[ee,ie]),le=v.mat2d.multiply(Array.of(0,0,0,0,0,0),le,v.mat2d.fromValues(1,Math.tan(W),Math.tan(ce),1,0,0)),le=v.mat2d.translate(Array.of(0,0,0,0,0,0),le,[-ee,-ie]),this.transform(U,le)}},{key:"isPointCollision",value:function(U,Z){var Q,ce=u()(Z,2),L=ce[0],W=ce[1],H=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"both",$=this.getTransform(U),ee=Object(D.transformPoint)([L,W],v.mat2d.invert(Array.of(0,0,0,0,0,0),$));return(Q=this[y]).isPointCollision.apply(Q,c()(ee).concat([H]))}},{key:"isPointInFill",value:function(U,Z){var Q=u()(Z,2),ce=Q[0],L=Q[1];return this.isPointCollision(U,[ce,L],"fill")}},{key:"isPointInStroke",value:function(U,Z){var Q=u()(Z,2),ce=Q[0],L=Q[1];return this.isPointCollision(U,[ce,L],"stroke")}},{key:"bufferSize",get:function(){return this[O].bufferSize}},{key:"mesh",get:function(){return this[y]},set:function(U){this[y]=U,this[b]&&this.setTextureFrames(this[b],this[C])}},{key:"hasCloudColor",get:function(){return this[P]}},{key:"hasCloudFilter",get:function(){return this[E]}},{key:"enableBlend",get:function(){return this[y].enableBlend||this[M]}},{key:"amount",get:function(){return this[f]},set:function(U){var Z=this[f];U!==Z&&(U>this[O].bufferSize&&(this[O]=V(Math.max(U,this[O].bufferSize+1e3),this[O])),this[f]=U,U>Z&&this.initBuffer(Z))}},{key:"meshData",get:function(){var U=this[y].meshData,Z=U.attributes,Q=U.cells,ce=U.positions,L=U.textureCoord,W=U.uniforms,H=this[b],$={attributes:w({},Z),cells:Q,positions:ce,textureCoord:L,uniforms:w({},W),instanceCount:this[f],enableBlend:this.enableBlend};H.length&&H.forEach(function(m,S){$.uniforms["u_texFrame".concat(S)]=m});var ee=this[O],ie=ee.transform0,le=ee.transform1,pe=ee.color0,Te=ee.color1,z=ee.color2,B=ee.color3,X=ee.color4,ae=ee.fillColor,q=ee.strokeColor,te=ee.frameIndex;return this[y].uniforms.u_texSampler&&($.attributes.a_frameIndex={data:te,divisor:1}),$.attributes.a_transform0={data:ie,divisor:1},$.attributes.a_transform1={data:le,divisor:1},$.attributes.a_colorCloud0={data:pe,divisor:1},$.attributes.a_colorCloud1={data:Te,divisor:1},$.attributes.a_colorCloud2={data:z,divisor:1},$.attributes.a_colorCloud3={data:B,divisor:1},$.attributes.a_colorCloud4={data:X,divisor:1},this.hasCloudColor&&($.attributes.a_fillCloudColor={data:ae,divisor:1},$.attributes.a_strokeCloudColor={data:q,divisor:1}),$}},{key:"program",get:function(){return this[y].program}}]),A}()},function(e,r,n){n.r(r),n.d(r,"multiply",function(){return o}),n.d(r,"grayscale",function(){return a}),n.d(r,"brightness",function(){return c}),n.d(r,"saturate",function(){return l}),n.d(r,"contrast",function(){return u}),n.d(r,"invert",function(){return h}),n.d(r,"sepia",function(){return d}),n.d(r,"opacity",function(){return g}),n.d(r,"hueRotate",function(){return p});var s=n(42);n(1).glMatrix.setMatrixArrayType(Array);function o(v,I){var D=[],x=v[0],j=v[1],w=v[2],y=v[3],f=v[4],M=v[5],T=v[6],b=v[7],C=v[8],P=v[9],E=v[10],O=v[11],V=v[12],N=v[13],A=v[14],k=v[15],U=v[16],Z=v[17],Q=v[18],ce=v[19],L=I[0],W=I[1],H=I[2],$=I[3],ee=I[4];return D[0]=L*x+W*M+H*E+$*k,D[1]=L*j+W*T+H*O+$*U,D[2]=L*w+W*b+H*V+$*Z,D[3]=L*y+W*C+H*N+$*Q,D[4]=L*f+W*P+H*A+$*ce+ee,L=I[5],W=I[6],H=I[7],$=I[8],ee=I[9],D[5]=L*x+W*M+H*E+$*k,D[6]=L*j+W*T+H*O+$*U,D[7]=L*w+W*b+H*V+$*Z,D[8]=L*y+W*C+H*N+$*Q,D[9]=L*f+W*P+H*A+$*ce+ee,L=I[10],W=I[11],H=I[12],$=I[13],ee=I[14],D[10]=L*x+W*M+H*E+$*k,D[11]=L*j+W*T+H*O+$*U,D[12]=L*w+W*b+H*V+$*Z,D[13]=L*y+W*C+H*N+$*Q,D[14]=L*f+W*P+H*A+$*ce+ee,L=I[15],W=I[16],H=I[17],$=I[18],ee=I[19],D[15]=L*x+W*M+H*E+$*k,D[16]=L*j+W*T+H*O+$*U,D[17]=L*w+W*b+H*V+$*Z,D[18]=L*y+W*C+H*N+$*Q,D[19]=L*f+W*P+H*A+$*ce+ee,D}function a(v){v=Object(s.clamp)(0,1,v);var I=.2126*v,D=.7152*v,x=.0722*v;return[I+1-v,D,x,0,0,I,D+1-v,x,0,0,I,D,x+1-v,0,0,0,0,0,1,0]}function c(v){return[v,0,0,0,0,0,v,0,0,0,0,0,v,0,0,0,0,0,1,0]}function l(v){var I=.2126*(1-v),D=.7152*(1-v),x=.0722*(1-v);return[I+v,D,x,0,0,I,D+v,x,0,0,I,D,x+v,0,0,0,0,0,1,0]}function u(v){var I=.5*(1-v);return[v,0,0,0,I,0,v,0,0,I,0,0,v,0,I,0,0,0,1,0]}function h(v){var I=1-2*v;return[I,0,0,0,v,0,I,0,0,v,0,0,I,0,v,0,0,0,1,0]}function d(v){return[1-.607*v,.769*v,.189*v,0,0,.349*v,1-.314*v,.168*v,0,0,.272*v,.534*v,1-.869*v,0,0,0,0,0,1,0]}function g(v){return[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,v,0]}function p(v){var I=v/180*Math.PI,D=Math.cos(I),x=Math.sin(I),j=.2126,w=.7152,y=.0722;return[j+D*(1-j)+x*-j,w+D*-w+x*-w,y+D*-y+x*(1-y),0,0,j+D*-j+x*.143,w+D*(1-w)+x*.14,y+D*-y+x*-.283,0,0,j+D*-j+x*-.7874,w+D*-w+x*w,y+D*(1-y)+x*y,0,0,0,0,0,1,0]}},function(e,r,n){n.r(r),n.d(r,"default",function(){return a});var s=n(48),o=n.n(s);n(1).glMatrix.setMatrixArrayType(Array);function a(c){var l=o()(c);if(!l||!l.length)throw new TypeError("Invalid color value.");return[l[0]/255,l[1]/255,l[2]/255,l[3]]}},function(e,r,n){var s=n(49),o=n(53),a=n(55);e.exports=function(l){var u,h=s(l);return h.space?(u=Array(3),u[0]=a(h.values[0],0,255),u[1]=a(h.values[1],0,255),u[2]=a(h.values[2],0,255),h.space[0]==="h"&&(u=o.rgb(u)),u.push(a(h.alpha,0,1)),u):[]}},function(e,r,n){(function(s){var o=n(50),a=n(51),c=n(52);e.exports=u;var l={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};function u(h){var d,g=[],p=1,v;if(typeof h=="string")if(o[h])g=o[h].slice(),v="rgb";else if(h==="transparent")p=0,v="rgb",g=[0,0,0];else if(/^#[A-Fa-f0-9]+$/.test(h)){var I=h.slice(1),D=I.length,x=D<=4;p=1,x?(g=[parseInt(I[0]+I[0],16),parseInt(I[1]+I[1],16),parseInt(I[2]+I[2],16)],D===4&&(p=parseInt(I[3]+I[3],16)/255)):(g=[parseInt(I[0]+I[1],16),parseInt(I[2]+I[3],16),parseInt(I[4]+I[5],16)],D===8&&(p=parseInt(I[6]+I[7],16)/255)),g[0]||(g[0]=0),g[1]||(g[1]=0),g[2]||(g[2]=0),v="rgb"}else if(d=/^((?:rgb|hs[lvb]|hwb|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms)a?)\s*\(([^\)]*)\)/.exec(h)){var j=d[1],w=j==="rgb",I=j.replace(/a$/,"");v=I;var D=I==="cmyk"?4:I==="gray"?1:3;g=d[2].trim().split(/\s*,\s*/).map(function(T,b){if(/%$/.test(T))return b===D?parseFloat(T)/100:I==="rgb"?parseFloat(T)*255/100:parseFloat(T);if(I[b]==="h"){if(/deg$/.test(T))return parseFloat(T);if(l[T]!==void 0)return l[T]}return parseFloat(T)}),j===I&&g.push(1),p=w||g[D]===void 0?1:g[D],g=g.slice(0,D)}else h.length>10&&/[0-9](?:\s|\/)/.test(h)&&(g=h.match(/([0-9]+)/g).map(function(f){return parseFloat(f)}),v=h.match(/([a-z])/ig).join("").toLowerCase());else if(!isNaN(h))v="rgb",g=[h>>>16,(h&65280)>>>8,h&255];else if(a(h)){var y=c(h.r,h.red,h.R,null);y!==null?(v="rgb",g=[y,c(h.g,h.green,h.G),c(h.b,h.blue,h.B)]):(v="hsl",g=[c(h.h,h.hue,h.H),c(h.s,h.saturation,h.S),c(h.l,h.lightness,h.L,h.b,h.brightness)]),p=c(h.a,h.alpha,h.opacity,1),h.opacity!=null&&(p/=100)}else(Array.isArray(h)||s.ArrayBuffer&&ArrayBuffer.isView&&ArrayBuffer.isView(h))&&(g=[h[0],h[1],h[2]],v="rgb",p=h.length===4?h[3]:1);return{space:v,values:g,alpha:p}}}).call(this,n(38))},function(e,r,n){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},function(e,r,n){var s=Object.prototype.toString;e.exports=function(o){var a;return s.call(o)==="[object Object]"&&(a=Object.getPrototypeOf(o),a===null||a===Object.getPrototypeOf({}))}},function(e,r){e.exports=function(){for(var n=0;n<arguments.length;n++)if(arguments[n]!==void 0)return arguments[n]}},function(e,r,n){var s=n(54);e.exports={name:"hsl",min:[0,0,0],max:[360,100,100],channel:["hue","saturation","lightness"],alias:["HSL"],rgb:function(o){var a=o[0]/360,c=o[1]/100,l=o[2]/100,u,h,d,g,p;if(c===0)return p=l*255,[p,p,p];l<.5?h=l*(1+c):h=l+c-l*c,u=2*l-h,g=[0,0,0];for(var v=0;v<3;v++)d=a+1/3*-(v-1),d<0?d++:d>1&&d--,6*d<1?p=u+(h-u)*6*d:2*d<1?p=h:3*d<2?p=u+(h-u)*(2/3-d)*6:p=u,g[v]=p*255;return g}},s.hsl=function(o){var a=o[0]/255,c=o[1]/255,l=o[2]/255,u=Math.min(a,c,l),h=Math.max(a,c,l),d=h-u,g,p,v;return h===u?g=0:a===h?g=(c-l)/d:c===h?g=2+(l-a)/d:l===h&&(g=4+(a-c)/d),g=Math.min(g*60,360),g<0&&(g+=360),v=(u+h)/2,h===u?p=0:v<=.5?p=d/(h+u):p=d/(2-h-u),[g,p*100,v*100]}},function(e,r,n){e.exports={name:"rgb",min:[0,0,0],max:[255,255,255],channel:["red","green","blue"],alias:["RGB"]}},function(e,r){e.exports=n;function n(s,o,a){return o<a?s<o?o:s>a?a:s:s<a?a:s>o?o:s}},function(e,r,n){n.r(r),n.d(r,"default",function(){return O});var s=n(19),o=n.n(s),a=n(57),c=n.n(a),l=n(23),u=n.n(l),h=n(24),d=n.n(h),g=n(58),p=n.n(g),v=n(59),I=n.n(v),D=n(60),x=n.n(D),j=n(61),w=n(63),y=n.n(w),f=n(70),M=n(72);n(1).glMatrix.setMatrixArrayType(Array);var T=Symbol("contours"),b=Symbol("path"),C=Symbol("simplify"),P=Symbol("scale"),E=2*Math.PI,O=function(){function V(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};u()(this,V),typeof N=="string"&&(N={path:N}),N.path?this[b]=p()(N.path):this[b]=[],this[T]=null,this[C]=N.simplify!=null?N.simplify:0,this[P]=N.scale!=null?N.scale:2}return d()(V,[{key:"normalize",value:function(){var A,k=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,Z=Object(j.default)(x()(this[b])).map(function(Q){for(var ce=c()(Q),L=ce[0],W=ce.slice(1),H=[L],$=0;$<W.length;$+=2){var ee=W[$]-k,ie=W[$+1]-U;H.push(ee,ie)}return H});return this.beginPath(),(A=this[b]).push.apply(A,o()(Z)),this}},{key:"getPointAtLength",value:function(A){return this.contours?Object(f.getPointAtLength)(this[T],A):null}},{key:"getTotalLength",value:function(){return this.contours?Object(f.getTotalLength)(this[T]):0}},{key:"addPath",value:function(A){var k;this[T]=null,typeof A=="string"&&(A=p()(A)),(k=this[b]).push.apply(k,o()(A))}},{key:"beginPath",value:function(){this[b]=[],this[T]=null}},{key:"clear",value:function(){this.beginPath()}},{key:"ellipse",value:function(A,k,U,Z,Q,ce,L){var W=arguments.length>7&&arguments[7]!==void 0?arguments[7]:0;if(ce+=Q,L+=Q,!(U<=0||Z<=0||L===ce)){L<ce&&(L=ce+E+(L-ce)%E),L-ce>E&&(L=ce+E);var H=L-ce;H>=E&&(L-=.001);var $=this[b].length>0&&H<E?"L":"M",ee=Object(M.getPoint)(A,k,U,Z,ce),ie=Object(M.getPoint)(A,k,U,Z,L),le=+!W,pe=H>Math.PI?1:0;W&&(pe=1-pe),$+=ee.join(" "),$+="A".concat(U," ").concat(Z," 0 ").concat(pe," ").concat(le," ").concat(ie.join(" ")),H>=E&&($+="Z"),this.addPath($)}}},{key:"arc",value:function(A,k,U,Z,Q){var ce=arguments.length>5&&arguments[5]!==void 0?arguments[5]:0;return this.ellipse(A,k,U,U,0,Z,Q,ce)}},{key:"arcTo",value:function(A,k,U,Z,Q,ce,L){this[T]=null,this[b].push(["A",A,k,U,Z,Q,ce,L])}},{key:"moveTo",value:function(A,k){this[T]=null,this[b].push(["M",A,k])}},{key:"lineTo",value:function(A,k){this[T]=null,this[b].push(["L",A,k])}},{key:"bezierCurveTo",value:function(A,k,U,Z,Q,ce){this[T]=null,this[b].push(["C",A,k,U,Z,Q,ce])}},{key:"quadraticCurveTo",value:function(A,k,U,Z){this[T]=null,this[b].push(["Q",A,k,U,Z])}},{key:"rect",value:function(A,k,U,Z){var Q="M".concat(A," ").concat(k,"L").concat(A+U," ").concat(k,"L").concat(A+U," ").concat(k+Z,"L").concat(A," ").concat(k+Z,"Z");this.addPath(Q)}},{key:"closePath",value:function(){this[T]=null;var A=[],k=this[b].length;k>0&&(A=this[b][k-1]),A[0]!=="Z"&&A[0]!=="z"&&this[b].push(["Z"])}},{key:"contours",get:function(){var A=null;if(!this[T]&&this[b]){var k=Object(j.default)(x()(this[b]));this[T]=y()(k,this[P],this[C]),this[T].path=k,this[T].simplify=this[C],this[T].scale=this[P]}return this[T]&&(A=this[T].map(function(U){return o()(U)}),A.path=this[T].path,A.simplify=this[T].simplify,A.scale=this[T].scale),A}},{key:"path",get:function(){return this[b]}},{key:"simplify",get:function(){return this[C]}},{key:"boundingBox",get:function(){var A=this.contours;if(A&&A.length){var k=A.reduce(function(U,Z){return[].concat(o()(U),o()(Z))});return I()(k)}return[[0,0],[0,0]]}},{key:"boundingCenter",get:function(){var A=this.boundingBox;return A?[.5*(A[0][0]+A[1][0]),.5*(A[0][1]+A[1][1])]:[0,0]}}]),V}()},function(e,r,n){var s=n(14),o=n(21),a=n(16),c=n(18);function l(u){return s(u)||o(u)||a(u)||c()}e.exports=l},function(e,r){e.exports=o;var n={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},s=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function o(l){var u=[];return l.replace(s,function(h,d,g){var p=d.toLowerCase();for(g=c(g),p=="m"&&g.length>2&&(u.push([d].concat(g.splice(0,2))),p="l",d=d=="m"?"l":"L");;){if(g.length==n[p])return g.unshift(d),u.push(g);if(g.length<n[p])throw new Error("malformed path data");u.push([d].concat(g.splice(0,n[p])))}}),u}var a=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function c(l){var u=l.match(a);return u?u.map(Number):[]}},function(e,r,n){e.exports=s;function s(o){var a=o.length;if(a===0)return[[],[]];for(var c=o[0].length,l=o[0].slice(),u=o[0].slice(),h=1;h<a;++h)for(var d=o[h],g=0;g<c;++g){var p=d[g];l[g]=Math.min(l[g],p),u[g]=Math.max(u[g],p)}return[l,u]}},function(e,r){e.exports=n;function n(s){var o=0,a=0,c=0,l=0;return s.map(function(u){u=u.slice();var h=u[0],d=h.toUpperCase();if(h!=d)switch(u[0]=d,h){case"a":u[6]+=c,u[7]+=l;break;case"v":u[1]+=l;break;case"h":u[1]+=c;break;default:for(var g=1;g<u.length;)u[g++]+=c,u[g++]+=l}switch(d){case"Z":c=o,l=a;break;case"H":c=u[1];break;case"V":l=u[1];break;case"M":c=o=u[1],l=a=u[2];break;default:c=u[u.length-2],l=u[u.length-1]}return u})}},function(e,r,n){n.r(r),n.d(r,"default",function(){return c});var s=n(13),o=n.n(s),a=n(62);n(1).glMatrix.setMatrixArrayType(Array);function c(h){for(var d,g=[],p=0,v=0,I=0,D=0,x=null,j=null,w=0,y=0,f=0,M=h.length;f<M;f++){var T=h[f],b=T[0];switch(b){case"M":I=T[1],D=T[2];break;case"A":var C=Object(a.default)(w,y,T[6],T[7],T[4],T[5],T[1],T[2],T[3]);if(!C.length)continue;C=C.map(function(N){var A=o()(N,8);A[0],A[1];var k=A[2],U=A[3],Z=A[4],Q=A[5],ce=A[6],L=A[7];return{x1:k,y1:U,x2:Z,y2:Q,x:ce,y:L}});for(var P=0,E;P<C.length;P++)E=C[P],T=["C",E.x1,E.y1,E.x2,E.y2,E.x,E.y],P<C.length-1&&g.push(T);break;case"S":var O=w,V=y;(d=="C"||d=="S")&&(O+=O-p,V+=V-v),T=["C",O,V,T[1],T[2],T[3],T[4]];break;case"T":d=="Q"||d=="T"?(x=w*2-x,j=y*2-j):(x=w,j=y),T=u(w,y,x,j,T[1],T[2]);break;case"Q":x=T[1],j=T[2],T=u(w,y,T[1],T[2],T[3],T[4]);break;case"L":T=l(w,y,T[1],T[2]);break;case"H":T=l(w,y,T[1],y);break;case"V":T=l(w,y,w,T[1]);break;case"Z":T=l(w,y,I,D);break}d=b,w=T[T.length-2],y=T[T.length-1],T.length>4?(p=T[T.length-4],v=T[T.length-3]):(p=w,v=y),g.push(T)}return g}function l(h,d,g,p){return["C",h,d,g,p,g,p]}function u(h,d,g,p,v,I){return["C",h/3+2/3*g,d/3+2/3*p,v/3+2/3*g,I/3+2/3*p,v,I]}},function(e,r,n){n.r(r),n.d(r,"default",function(){return l}),n(1).glMatrix.setMatrixArrayType(Array);var s=Math.PI*2;function o(u,h,d,g){var p=u*g-h*d<0?-1:1,v=u*d+h*g;return v>1&&(v=1),v<-1&&(v=-1),p*Math.acos(v)}function a(u,h,d,g,p,v,I,D,x,j){var w=j*(u-d)/2+x*(h-g)/2,y=-x*(u-d)/2+j*(h-g)/2,f=I*I,M=D*D,T=w*w,b=y*y,C=f*M-f*b-M*T;C<0&&(C=0),C/=f*b+M*T,C=Math.sqrt(C)*(p===v?-1:1);var P=C*I/D*y,E=C*-D/I*w,O=j*P-x*E+(u+d)/2,V=x*P+j*E+(h+g)/2,N=(w-P)/I,A=(y-E)/D,k=(-w-P)/I,U=(-y-E)/D,Z=o(1,0,N,A),Q=o(N,A,k,U);return v===0&&Q>0&&(Q-=s),v===1&&Q<0&&(Q+=s),[O,V,Z,Q]}function c(u,h){var d=1.3333333333333333*Math.tan(h/4),g=Math.cos(u),p=Math.sin(u),v=Math.cos(u+h),I=Math.sin(u+h);return[g,p,g-p*d,p+g*d,v+I*d,I-v*d,v,I]}function l(u,h,d,g,p,v,I,D,x){var j=Math.sin(x*s/360),w=Math.cos(x*s/360),y=w*(u-d)/2+j*(h-g)/2,f=-j*(u-d)/2+w*(h-g)/2;if(y===0&&f===0)return[];if(I===0||D===0)return[];I=Math.abs(I),D=Math.abs(D);var M=y*y/(I*I)+f*f/(D*D);M>1&&(I*=Math.sqrt(M),D*=Math.sqrt(M));var T=a(u,h,d,g,p,v,I,D,j,w),b=[],C=T[2],P=T[3],E=Math.max(Math.ceil(Math.abs(P)/(s/4)),1);P/=E;for(var O=0;O<E;O++)b.push(c(C,P)),C+=P;return b.map(function(V){for(var N=0;N<V.length;N+=2){var A=V[N+0],k=V[N+1];A*=I,k*=D;var U=w*A-j*k,Z=j*A+w*k;V[N+0]=U+T[0],V[N+1]=Z+T[1]}return V})}},function(e,r,n){n(1).glMatrix.setMatrixArrayType(Array);var s=n(64),o=n(66),a=o.copy,c=n(67);function l(p,v,I){return p[0]=v,p[1]=I,p}var u=[0,0],h=[0,0],d=[0,0];function g(p,v,I,D){s(I,l(u,D[1],D[2]),l(h,D[3],D[4]),l(d,D[5],D[6]),v,p)}e.exports=function(v,I,D){var x=[],j=[],w=[0,0];return v.forEach(function(y,f,M){if(y[0]==="M")a(w,y.slice(1)),j.length>0&&(x.push(j),j=[]);else if(y[0]==="C")g(j,I,w,y),l(w,y[5],y[6]);else throw new Error("illegal type in SVG: "+y[0])}),j.length>0&&x.push(j),x.map(function(y){return c(y,D||0)})}},function(e,r,n){e.exports=n(65)()},function(e,r){function n(o){return[o[0],o[1]]}function s(o,a){return[o,a]}e.exports=function(a){a=a||{};var c=typeof a.recursion=="number"?a.recursion:8,l=typeof a.epsilon=="number"?a.epsilon:11920929e-14,u=typeof a.pathEpsilon=="number"?a.pathEpsilon:1,h=typeof a.angleEpsilon=="number"?a.angleEpsilon:.01,d=a.angleTolerance||0,g=a.cuspLimit||0;return function(D,x,j,w,y,f){f||(f=[]),y=typeof y=="number"?y:1;var M=u/y;return M*=M,p(D,x,j,w,f,M),f};function p(I,D,x,j,w,y){w.push(n(I));var f=I[0],M=I[1],T=D[0],b=D[1],C=x[0],P=x[1],E=j[0],O=j[1];v(f,M,T,b,C,P,E,O,w,y,0),w.push(n(j))}function v(I,D,x,j,w,y,f,M,T,b,C){if(!(C>c)){var P=Math.PI,E=(I+x)/2,O=(D+j)/2,V=(x+w)/2,N=(j+y)/2,A=(w+f)/2,k=(y+M)/2,U=(E+V)/2,Z=(O+N)/2,Q=(V+A)/2,ce=(N+k)/2,L=(U+Q)/2,W=(Z+ce)/2;if(C>0){var H=f-I,$=M-D,ee=Math.abs((x-f)*$-(j-M)*H),ie=Math.abs((w-f)*$-(y-M)*H),le,pe;if(ee>l&&ie>l){if((ee+ie)*(ee+ie)<=b*(H*H+$*$)){if(d<h){T.push(s(L,W));return}var Te=Math.atan2(y-j,w-x);if(le=Math.abs(Te-Math.atan2(j-D,x-I)),pe=Math.abs(Math.atan2(M-y,f-w)-Te),le>=P&&(le=2*P-le),pe>=P&&(pe=2*P-pe),le+pe<d){T.push(s(L,W));return}if(g!==0){if(le>g){T.push(s(x,j));return}if(pe>g){T.push(s(w,y));return}}}}else if(ee>l){if(ee*ee<=b*(H*H+$*$)){if(d<h){T.push(s(L,W));return}if(le=Math.abs(Math.atan2(y-j,w-x)-Math.atan2(j-D,x-I)),le>=P&&(le=2*P-le),le<d){T.push(s(x,j)),T.push(s(w,y));return}if(g!==0&&le>g){T.push(s(x,j));return}}}else if(ie>l){if(ie*ie<=b*(H*H+$*$)){if(d<h){T.push(s(L,W));return}if(le=Math.abs(Math.atan2(M-y,f-w)-Math.atan2(y-j,w-x)),le>=P&&(le=2*P-le),le<d){T.push(s(x,j)),T.push(s(w,y));return}if(g!==0&&le>g){T.push(s(w,y));return}}}else if(H=L-(I+f)/2,$=W-(D+M)/2,H*H+$*$<=b){T.push(s(L,W));return}}v(I,D,E,O,U,Z,L,W,T,b,C+1),v(L,W,Q,ce,A,k,f,M,T,b,C+1)}}}},function(e,r,n){n.r(r),n.d(r,"create",function(){return a}),n.d(r,"clone",function(){return o}),n.d(r,"copy",function(){return c}),n.d(r,"scaleAndAdd",function(){return l}),n.d(r,"dot",function(){return u}),n.d(r,"rotate",function(){return h}),n.d(r,"cross",function(){return d}),n.d(r,"sub",function(){return g}),n.d(r,"add",function(){return p}),n.d(r,"computeMiter",function(){return x}),n.d(r,"normal",function(){return j}),n.d(r,"direction",function(){return w});var s=n(1);n(1).glMatrix.setMatrixArrayType(Array);function o(y){return[y[0],y[1]]}function a(){return[0,0]}var c=s.vec2.copy,l=s.vec2.scaleAndAdd,u=s.vec2.dot,h=s.vec2.rotate,d=s.vec2.cross,g=s.vec2.sub,p=s.vec2.add,v=s.vec2.normalize,I=s.vec2.set,D=a();function x(y,f,M,T,b){p(y,M,T),v(y,y),I(f,-y[1],y[0]),I(D,-M[1],M[0]);var C=b/u(f,D);return Math.abs(C)}function j(y,f){return I(y,-f[1],f[0]),y}function w(y,f,M){return g(y,f,M),v(y,y),y}},function(e,r,n){var s=n(68),o=n(69);e.exports=function(c,l){return c=s(c,l),c=o(c,l),c},e.exports.radialDistance=s,e.exports.douglasPeucker=o},function(e,r){function n(s,o){var a=s[0]-o[0],c=s[1]-o[1];return a*a+c*c}e.exports=function(o,a){if(o.length<=1)return o;a=typeof a=="number"?a:1;for(var c=a*a,l=o[0],u=[l],h,d=1,g=o.length;d<g;d++)h=o[d],n(h,l)>c&&(u.push(h),l=h);return l!==h&&u.push(h),u}},function(e,r){function n(o,a,c){var l=a[0],u=a[1],h=c[0]-l,d=c[1]-u;if(h!==0||d!==0){var g=((o[0]-l)*h+(o[1]-u)*d)/(h*h+d*d);g>1?(l=c[0],u=c[1]):g>0&&(l+=h*g,u+=d*g)}return h=o[0]-l,d=o[1]-u,h*h+d*d}function s(o,a,c,l,u){for(var h=l,d,g=a+1;g<c;g++){var p=n(o[g],o[a],o[c]);p>h&&(d=g,h=p)}h>l&&(d-a>1&&s(o,a,d,l,u),u.push(o[d]),c-d>1&&s(o,d,c,l,u))}e.exports=function(a,c){if(a.length<=1)return a;c=typeof c=="number"?c:1;var l=c*c,u=a.length-1,h=[a[0]];return s(a,0,u,l,h),h.push(a[u]),h}},function(e,r,n){n.r(r),n.d(r,"getTotalLength",function(){return c}),n.d(r,"getPointAtLength",function(){return u}),n.d(r,"getDashContours",function(){return h});var s=n(19),o=n.n(s),a=n(71);n(1).glMatrix.setMatrixArrayType(Array);function c(d){if(d.totalLength!=null)return d.totalLength;var g=0;return d.forEach(function(p){for(var v=p[0],I=1;I<p.length;I++){var D=p[I];g+=Object(a.distance)(v,D),v=D}}),d.totalLength=g,g}function l(d,g){var p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(g=Number(g),!Number.isFinite(g))throw new TypeError("Failed to execute 'getPointAtLength' on figure: The provided float value is non-finite.");if(g<=0)throw new TypeError("Length must > 0");var v=c(d);if(g>=v){var I=d[d.length-1],D=I[I.length-2],x=I[I.length-1],j=Math.atan2(x[1]-D[1],x[0]-D[0]);return{current:d.map(function(A){return o()(A)}),point:{x:x[0],y:x[1],angle:j}}}for(var w=[],y=0;y<d.length;y++){w[y]=[];for(var f=d[y],M=f[0],T=1;T<f.length;T++){var b=f[T],C=Object(a.distance)(M,b);if(g<C){var P=g/C,E=Math.atan2(b[1]-M[1],b[0]-M[0]),O={x:M[0]*(1-P)+b[0]*P,y:M[1]*(1-P)+b[1]*P,angle:E};if(w[y].push(M),g>0&&w[y].push([O.x,O.y]),!p)return{current:w,point:O};for(var V=[],N=y;y<d.length;y++){for(V[y-N]=[],y===N&&V[0].push([O.x,O.y]);T<f.length;T++)V[y-N].push(f[T]);T=0}return{current:w,point:O,rest:V}}g-=C,w[y].push(M),M=b}}}function u(d,g){if(g=Number(g),!Number.isFinite(g))throw new TypeError("Failed to execute 'getPointAtLength' on figure: The provided float value is non-finite.");if(d.length<=0)return{x:0,y:0,angle:0};if(g<=0){var p=d[0][0],v=d[0][1],I=Math.atan2(v[1]-p[1],v[0]-p[0]);return{x:p[0],y:p[1],angle:I}}return l(d,g,!1).point}function h(d,g,p){var v=0,I=g[0],D=d,x=[],j=g.length;if(p>0){do p-=g[v%j],v++;while(p>0);p<0&&(I=-p,v--)}else if(p<0){v=-1;do p+=g[v%j+j-1],v--;while(p<0);p>=0&&(v++,I=g[v%j+j-1]-p)}do{var w=l(D,I);D=w.rest,++v%2&&x.push.apply(x,o()(w.current));var y=v%j;y<0&&(y+=j),I=g[y]}while(D);return x}},function(e,r,n){n.r(r),n.d(r,"normalize",function(){return a}),n.d(r,"distance",function(){return c});var s=n(13),o=n.n(s);n(1).glMatrix.setMatrixArrayType(Array);function a(l,u,h,d){var g=o()(l,3),p=g[0],v=g[1],I=g[2];return p=p*2/u-1,v=1-v*2/h,Number.isFinite(d)?(I=I*2/d-1,[p,v,I]):[p,v]}function c(l,u){var h=o()(l,3),d=h[0],g=h[1],p=h[2],v=p===void 0?0:p,I=o()(u,3),D=I[0],x=I[1],j=I[2],w=j===void 0?0:j;return Math.hypot(D-d,x-g,w-v)}},function(e,r,n){n.r(r),n.d(r,"getPoint",function(){return o}),n(1).glMatrix.setMatrixArrayType(Array);var s=Math.PI*2;function o(a,c,l,u,h){h%=s,h<0&&(h+=s);var d=Math.tan(h);if(Math.abs(d)<1e5){var g=c-d*a,p=1/Math.pow(l,2)+Math.pow(d,2)/Math.pow(u,2),v=-1;(h<=Math.PI/2||h>3*Math.PI/2)&&(v=1);var I=v*Math.sqrt(1/p)+a,D=d*I+g;return[I,D]}return h<Math.PI?[a,c+u]:[a,c-u]}},function(e,r,n){n.r(r),n.d(r,"default",function(){return _});var s=n(74),o=n.n(s),a=n(19),c=n.n(a),l=n(23),u=n.n(l),h=n(24),d=n.n(h),g=n(13),p=n.n(g),v=n(1),I=n(59),D=n.n(I),x=n(76),j=n(44),w=n(40),y=n(46),f=n(78),M=n(70),T=n(79),b=n.n(T),C=n(63),P=n.n(C),E=n(47),O=n(56),V=n(37);n(1).glMatrix.setMatrixArrayType(Array);var N=Symbol("mesh"),A=Symbol("contours"),k=Symbol("stroke"),U=Symbol("fill"),Z=Symbol("strokeColor"),Q=Symbol("fillColor"),ce=Symbol("transform"),L=Symbol("invertTransform"),W=Symbol("uniforms"),H=Symbol("texOptions"),$=Symbol("blend"),ee=Symbol("applyTexture"),ie=Symbol("applyTransform"),le=Symbol("applyGradientTransform"),pe=Symbol("applyProgram"),Te=Symbol("gradient"),z=Symbol("filter"),B=Symbol("opacity"),X=Symbol("program"),ae=Symbol("attributes"),q=Symbol("pass"),te=Symbol("clipContext"),m=Symbol("applyClipPath");function S(re,ne){for(var J=re[1][0]-re[0][0],se=re[1][1]-re[0][1],ue=[],oe=0;oe<ne.length;oe++){var de=ne[oe],me=[(de[0]-re[0][0])/J,1-(de[1]-re[0][1])/se];ue.push(me)}return ue}function F(re,ne,J){var se=p()(re,2),ue=se[0],oe=se[1],de=p()(ne,4),me=de[0],ye=de[1],be=de[2],Ce=de[3],Ie=J.scale;return Ie||(ue/=be,oe=1-oe/Ce,ue-=me,oe+=ye),[ue,oe,0]}function Y(re,ne,J){var se=P()(re,ne,J);return se.path=re,se.simplify=J,se.scale=ne,se}var _=function(){function re(ne){u()(this,re),this[k]=null,this[U]=null,this[ce]=[1,0,0,1,0,0],this[B]=1,this[W]={},this[z]=[],this[$]=null,this[H]={},this.contours=ne.contours,this[X]=null,this[ae]={},this[q]=[]}return d()(re,[{key:"setProgram",value:function(J){this[X]=J,this[N]&&this[pe](J)}},{key:"setAttribute",value:function(J,se){se==null?delete this[ae][J]:this[ae][J]=se}},{key:"getOpacity",value:function(){return this[B]}},{key:"setOpacity",value:function(J){if(J<0||J>1)throw new TypeError("Invalid opacity value.");this[N]&&this[N].positions.forEach(function(se){se[2]=1/se[2]>0?J:-J}),this[B]=J}},{key:"setClipPath",value:function(J){this.clipPath=J,this[W].u_clipSampler&&this[W].u_clipSampler.delete(),this.setUniforms({u_clipSampler:null}),this[N]&&delete this[N].attributes.a_clipUV,J&&this[N]&&this[m]()}},{key:m,value:function(){if(this.clipPath){this[te]||(this[te]=V.default.createCanvas(1,1));var J=p()(this.boundingBox,2),se=p()(J[0],2),ue=se[0],oe=se[1],de=p()(J[1],2),me=de[0],ye=de[1];me&&ye&&(this[te].width=me-ue,this[te].height=ye-oe);var be=this[te].getContext("2d"),Ce=new Path2D(this.clipPath);be.clearRect(0,0,this[te].width,this[te].height),be.save(),be.translate(-ue,-oe),be.fillStyle="white",be.fill(Ce),be.restore(),this[N].clipPath=this[te];var Ie=S(this.boundingBox,this[N].position0);this[N].attributes.a_clipUV=Ie}}},{key:"getPointAtLength",value:function(J){return Object(M.getPointAtLength)(this[A],J)}},{key:"getTotalLength",value:function(){return Object(M.getTotalLength)(this[A])}},{key:pe,value:function(J){for(var se=this[ae],ue=this[N].position0,oe=Object.entries(J._attribute),de=0;de<oe.length;de++){var me=p()(oe[de],2),ye=me[0],be=me[1];if(ye!=="a_color"&&ye!=="a_sourceRect"&&be!=="ignored"){var Ce=se[ye];if(ye==="uv"&&!Ce){var Ie=this[N].boundingBox||D()(ue);this[N].attributes[ye]=S(Ie,ue)}else{this[N].attributes[ye]=[];for(var Pe=0;Pe<ue.length;Pe++){var Re=ue[Pe];this[N].attributes[ye].push(Ce?Ce(Re,de,ue):Array(be.size).fill(0))}}}}}},{key:ie,value:function(J,se){for(var ue=J.positions,oe=J.position0,de=0;de<ue.length;de++){var me=p()(oe[de],2),ye=me[0],be=me[1],Ce=ue[de];Ce[0]=ye*se[0]+be*se[2]+se[4],Ce[1]=ye*se[1]+be*se[3]+se[5]}this._updateMatrix=!1}},{key:le,value:function(){var J=this[ce],se=c()(this._radialGradientVector);if(se){var ue=p()(se,5),oe=ue[0],de=ue[1],me=ue[3],ye=ue[4];se[0]=oe*J[0]+de*J[2]+J[4],se[1]=oe*J[1]+de*J[3]+J[5],se[3]=me*J[0]+ye*J[2]+J[4],se[4]=me*J[1]+ye*J[3]+J[5],this[W].u_radialGradientVector=se}}},{key:ee,value:function(J,se){function ue(Re,ke){return Re==null&&ke==null?!0:Re==null||ke==null?!1:Re[0]===ke[0]&&Re[1]===ke[1]&&Re[2]===ke[2]&&Re[3]===ke[3]}var oe=this[W].u_texSampler;if(oe){var de=oe._img,me=de.width,ye=de.height,be=se.srcRect,Ce=se.rect||[0,0];if(se.rotated&&(Ce=[-Ce[1],Ce[0],Ce[3],Ce[2]]),Ce[2]==null&&(Ce[2]=be?be[2]:me),Ce[3]==null&&(Ce[3]=be?be[3]:ye),se.hidden)J.textureCoord=J.positions.map(function(){return[-1,-1,-1]});else if(!J.textureCoord||!ue(this[H].rect,se.rect)||this[H].hidden!==se.hidden||this[H].rotated!==se.rotated){var Ie=null;se.rotated&&(Ie=v.mat2d.rotate(Array.of(0,0,0,0,0,0),v.mat2d.fromValues(1,0,0,1,0,0),.5*Math.PI),Ie=v.mat2d.translate(Array.of(0,0,0,0,0,0),Ie,[0,-Ce[2]])),J.textureCoord=J.position0.map(function(Re){var ke=p()(Re,3),Oe=ke[0],je=ke[1],Be=ke[2];if(1/Be>0){if(se.rotated){var Je=Oe*Ie[0]+je*Ie[2]+Ie[4],tt=Oe*Ie[1]+je*Ie[3]+Ie[5];Oe=Je,je=tt}var rt=F([Oe,je],[Ce[0]/Ce[2],Ce[1]/Ce[3],Ce[2],Ce[3]],se);return se.repeat&&(rt[2]=1),rt}return[-1,-1,-1]})}if(be){var Pe=[be[0]/me,be[1]/ye,be[2]/me,be[3]/ye];J.attributes.a_sourceRect=J.positions.map(function(){return[].concat(Pe)})}else J.attributes.a_sourceRect=J.positions.map(function(){return[0,0,0,0]})}}},{key:"accurate",value:function(J){if(this.contours){var se=this.contours.path;if(se){var ue=this.contours.simplify,oe=Y(this.contours.path,2*J,ue);this[N]=null,this[A]=oe}}}},{key:"canIgnore",value:function(){var J=this[k]==null||this[k].lineWidth===0||this[Z][3]===0,se=this[U]==null||this[Q][3]===0,ue=this[W].u_radialGradientVector==null,oe=this[W].u_texSampler==null;return this[B]===0||this[X]==null&&J&&se&&ue&&oe&&!this.beforeRender&&!this.afterRender}},{key:"setStroke",value:function(){var J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},se=J.thickness,ue=se===void 0?1:se,oe=J.cap,de=oe===void 0?"butt":oe,me=J.join,ye=me===void 0?"miter":me,be=J.miterLimit,Ce=be===void 0?10:be,Ie=J.color,Pe=Ie===void 0?[0,0,0,0]:Ie,Re=J.lineDash,ke=Re===void 0?null:Re,Oe=J.lineDashOffset,je=Oe===void 0?0:Oe,Be=J.roundSegments,Je=Be===void 0?20:Be;return this[N]=null,this[k]=new x.default({lineWidth:ue,lineCap:de,lineJoin:ye,miterLimit:Ce,roundSegments:Je}),typeof Pe=="string"&&(Pe=Object(E.default)(Pe)),this[Z]=Pe,this[k].lineDash=ke,this[k].lineDashOffset=je,this}},{key:"setFill",value:function(){var J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},se=J.rule,ue=se===void 0?this.fillRule:se,oe=J.color,de=oe===void 0?[0,0,0,0]:oe;return this[N]=null,this[U]={rule:ue},typeof de=="string"&&(de=Object(E.default)(de)),this[Q]=de,this}},{key:"setTexture",value:function(J){var se=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(J&&J.image){var ue=J,oe=ue.image,de=ue.rect;if(J=oe,se.rect)for(var me=0;me<se.rect.length;me++)de[me]=se.rect[me];se.rect=de}return this[U]||this.setFill(),this.setUniforms({u_texSampler:J}),this[N]&&this[ee](this[N],se),this[H]=se,this}},{key:"setCircularGradient",value:function(){var J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},se=J.vector,ue=J.colors,oe=J.type,de=oe===void 0?"fill":oe;if(se.length!==3)throw new TypeError("Invalid linearGradient.");this.setGradient({vector:se,colors:ue,type:de})}},{key:"setLinearGradient",value:function(){var J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},se=J.vector,ue=J.colors,oe=J.type,de=oe===void 0?"fill":oe;if(se.length!==4)throw new TypeError("Invalid linearGradient.");this.setGradient({vector:se,colors:ue,type:de})}},{key:"setRadialGradient",value:function(){var J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},se=J.vector,ue=J.colors,oe=J.type,de=oe===void 0?"fill":oe;if(se.length!==6)throw new TypeError("Invalid radialGradient.");this.setGradient({vector:se,colors:ue,type:de})}},{key:"setGradient",value:function(){var J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},se=J.vector,ue=J.colors,oe=J.type,de=oe===void 0?"fill":oe;ue=ue.map(function(be){var Ce=be.offset,Ie=be.color;return typeof Ie=="string"&&(Ie=Object(E.default)(Ie)),{offset:Ce,color:Ie}}),this[Te]=this[Te]||{},this[Te][de]={vector:se,colors:ue},ue.sort(function(be,Ce){return be.offset-Ce.offset});var me=[];ue.forEach(function(be){var Ce=be.offset,Ie=be.color;me.push.apply(me,[Ce].concat(c()(Ie)))});var ye;if(se.length===4?ye=[se[0],se[1],0,se[2],se[3],0]:ye=c()(se),me.length<40&&me.push(-1),me.length>40)throw new Error("Too many colors, should be less than 8 colors");return this._radialGradientVector=ye,this[W].u_colorSteps=me,de==="fill"?this[W].u_gradientType=1:this[W].u_gradientType=0,this[le](),this}},{key:"setUniforms",value:function(){var J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return Object.assign(this[W],J),this}},{key:"setTransform",value:function(){for(var J=this[ce],se=arguments.length,ue=new Array(se),oe=0;oe<se;oe++)ue[oe]=arguments[oe];return v.mat2d.equals(ue,J)||(this[ce]=ue,delete this[L],this._updateMatrix=!0),this}},{key:"transform",value:function(){for(var J=this[ce],se=arguments.length,ue=new Array(se),oe=0;oe<se;oe++)ue[oe]=arguments[oe];return this[ce]=v.mat2d.multiply(Array.of(0,0,0,0,0,0),J,ue),delete this[L],this._updateMatrix=!0,this}},{key:"translate",value:function(J,se){var ue=v.mat2d.create();return ue=v.mat2d.translate(Array.of(0,0,0,0,0,0),ue,[J,se]),this.transform.apply(this,c()(ue))}},{key:"rotate",value:function(J){var se=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[0,0],ue=p()(se,2),oe=ue[0],de=ue[1],me=v.mat2d.create();return me=v.mat2d.translate(Array.of(0,0,0,0,0,0),me,[oe,de]),me=v.mat2d.rotate(Array.of(0,0,0,0,0,0),me,J),me=v.mat2d.translate(Array.of(0,0,0,0,0,0),me,[-oe,-de]),this.transform.apply(this,c()(me))}},{key:"scale",value:function(J){var se=arguments.length>1&&arguments[1]!==void 0?arguments[1]:J,ue=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[0,0],oe=p()(ue,2),de=oe[0],me=oe[1],ye=v.mat2d.create();return ye=v.mat2d.translate(Array.of(0,0,0,0,0,0),ye,[de,me]),ye=v.mat2d.scale(Array.of(0,0,0,0,0,0),ye,[J,se]),ye=v.mat2d.translate(Array.of(0,0,0,0,0,0),ye,[-de,-me]),this.transform.apply(this,c()(ye))}},{key:"skew",value:function(J){var se=arguments.length>1&&arguments[1]!==void 0?arguments[1]:J,ue=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[0,0],oe=p()(ue,2),de=oe[0],me=oe[1],ye=v.mat2d.create();return ye=v.mat2d.translate(Array.of(0,0,0,0,0,0),ye,[de,me]),ye=v.mat2d.multiply(Array.of(0,0,0,0,0,0),ye,v.mat2d.fromValues(1,Math.tan(se),Math.tan(J),1,0,0)),ye=v.mat2d.translate(Array.of(0,0,0,0,0,0),ye,[-de,-me]),this.transform.apply(this,c()(ye))}},{key:"clearFilter",value:function(){return this.setColorTransform(null),this[z].length=0,this}},{key:"setColorTransform",value:function(){for(var J=arguments.length,se=new Array(J),ue=0;ue<J;ue++)se[ue]=arguments[ue];return se[0]===null?this.setUniforms({u_filterFlag:0,u_colorMatrix:0}):this.setUniforms({u_filterFlag:1,u_colorMatrix:se}),this}},{key:"transformColor",value:function(){for(var J=this.uniforms.u_colorMatrix,se=arguments.length,ue=new Array(se),oe=0;oe<se;oe++)ue[oe]=arguments[oe];return J?J=Object(y.multiply)(J,ue):J=ue,this.setColorTransform.apply(this,c()(J)),this}},{key:"blur",value:function(J){return this[z].push("blur(".concat(J,"px)")),this}},{key:"brightness",value:function(){var J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;return this[z].push("brightness(".concat(100*J,"%)")),this.transformColor.apply(this,c()(Object(y.brightness)(J)))}},{key:"contrast",value:function(){var J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;return this[z].push("contrast(".concat(100*J,"%)")),this.transformColor.apply(this,c()(Object(y.contrast)(J)))}},{key:"dropShadow",value:function(J,se){var ue=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,oe=arguments.length>3&&arguments[3]!==void 0?arguments[3]:[0,0,0,1];return Array.isArray(oe)&&(oe=Object(w.default)(oe)),this[z].push("drop-shadow(".concat(J,"px ").concat(se,"px ").concat(ue,"px ").concat(oe,")")),this}},{key:"grayscale",value:function(){var J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;return this[z].push("grayscale(".concat(100*J,"%)")),this.transformColor.apply(this,c()(Object(y.grayscale)(J)))}},{key:"hueRotate",value:function(){var J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return this[z].push("hue-rotate(".concat(J,"deg)")),this.transformColor.apply(this,c()(Object(y.hueRotate)(J)))}},{key:"invert",value:function(){var J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;return this[z].push("invert(".concat(100*J,"%)")),this.transformColor.apply(this,c()(Object(y.invert)(J)))}},{key:"opacity",value:function(){var J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;return this[z].push("opacity(".concat(100*J,"%)")),this.transformColor.apply(this,c()(Object(y.opacity)(J)))}},{key:"saturate",value:function(){var J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;return this[z].push("saturate(".concat(100*J,"%)")),this.transformColor.apply(this,c()(Object(y.saturate)(J)))}},{key:"sepia",value:function(){var J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;return this[z].push("sepia(".concat(100*J,"%)")),this.transformColor.apply(this,c()(Object(y.sepia)(J)))}},{key:"url",value:function(J){return this[z].push("url(".concat(J,")")),this}},{key:"isPointCollision",value:function(J,se){var ue=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"both",oe=this.meshData,de=oe.positions,me=oe.cells,ye=this.invertMatrix,be=ye[0]*J+ye[2]*se+ye[4],Ce=ye[1]*J+ye[3]*se+ye[5],Ie=this.boundingBox;if(be<Ie[0][0]||be>Ie[1][0]||Ce<Ie[0][1]||Ce>Ie[1][1])return!1;function Pe(di,eo,Y0){var Gh=p()(di,2),G0=Gh[0],H0=Gh[1],Hh=p()(eo,2),Qh=Hh[0],Zh=Hh[1],Kh=p()(Y0,2),Q0=Kh[0],Z0=Kh[1],qh=Q0-Qh,Xh=Z0-Zh,Jh=((G0-Qh)*qh+(H0-Zh)*Xh)/(Math.pow(qh,2)+Math.pow(Xh,2));return Jh>=0&&Jh<=1}for(var Re=0;Re<me.length;Re++){var ke=me[Re];if(ue==="fill"&&ke[0]>=oe.fillPointCount)break;if(!(ue==="stroke"&&ke[0]<oe.fillPointCount)){var Oe=ke.map(function(di){return de[di]}),je=p()(Oe,3),Be=p()(je[0],2),Je=Be[0],tt=Be[1],rt=p()(je[1],2),nt=rt[0],st=rt[1],ut=p()(je[2],2),lt=ut[0],Ze=ut[1],Ut=Math.sign((J-Je)*(st-tt)-(nt-Je)*(se-tt));if(Ut===0&&Pe([J,se],[Je,tt],[nt,st]))return!0;var Dr=Math.sign((J-nt)*(Ze-st)-(lt-nt)*(se-st));if(Dr===0&&Pe([J,se],[nt,st],[lt,Ze]))return!0;var Pr=Math.sign((J-lt)*(tt-Ze)-(Je-lt)*(se-Ze));if(Pr===0&&Pe([J,se],[lt,Ze],[Je,tt])||Ut===1&&Dr===1&&Pr===1||Ut===-1&&Dr===-1&&Pr===-1)return!0}}return!1}},{key:"isPointInFill",value:function(J,se){return this.isPointCollision(J,se,"fill")}},{key:"isPointInStroke",value:function(J,se){return this.isPointCollision(J,se,"stroke")}},{key:"addPass",value:function(J){var se=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ue=se.width,oe=se.height,de=o()(se,["width","height"]),me=new O.default;me.rect(0,0,ue,oe);var ye=new re(me);ye.setUniforms(de),ye.setProgram(J),this[q].push(ye)}},{key:"contours",get:function(){return this[A]},set:function(J){this[N]=null,this[A]=J;var se=J.scale,ue=this.transformScale/se;ue>1.5&&this.accurate(this.transformScale)}},{key:"program",get:function(){return this[X]}},{key:"blend",get:function(){return this[$]==null?"auto":this[$]},set:function(J){this[$]=J,this[N]&&(this[N].enableBlend=this.enableBlend)}},{key:"boundingBox",get:function(){if(this[N]&&this[N].boundingBox)return this[N].boundingBox;var J=this.meshData;if(J){var se=J.position0;if(se.length)J.boundingBox=D()(se);else return[[0,0],[0,0]];return J.boundingBox}return[[0,0],[0,0]]}},{key:"boundingCenter",get:function(){var J=this.boundingBox;return J?[.5*(J[0][0]+J[1][0]),.5*(J[0][1]+J[1][1])]:[0,0]}},{key:"fillRule",get:function(){return this[U]?this[U].rule:"nonzero"}},{key:"lineWidth",get:function(){return this[k]?this[k].lineWidth:0}},{key:"lineCap",get:function(){return this[k]?this[k].lineCap:""}},{key:"lineJoin",get:function(){return this[k]?this[k].lineJoin:""}},{key:"miterLimit",get:function(){return this[k]?this[k].miterLimit:0}},{key:"strokeStyle",get:function(){return this[Z]&&this[Z][3]!==0?Object(w.default)(this[Z]):""}},{key:"lineDash",get:function(){return this[k]?this[k].lineDash:null}},{key:"lineDashOffset",get:function(){return this[k]?this[k].lineDashOffset:0}},{key:"fillStyle",get:function(){return this[Q]&&this[Q][3]!==0?Object(w.default)(this[Q]):""}},{key:"gradient",get:function(){return this[Te]}},{key:"texture",get:function(){return this[W].u_texSampler?{image:this[W].u_texSampler._img,options:this[H]}:null}},{key:"enableBlend",get:function(){return this[$]===!0||this[$]===!1?this[$]:this[B]<1||this[Z]!=null&&this[Z][3]<1||this[Q]!=null&&this[Q][3]<1||this[W].u_colorMatrix!=null&&this[W].u_colorMatrix[18]<1||this[W].u_radialGradientVector!=null||this.beforeRender||this.afterRender}},{key:"filterCanvas",get:function(){return/blur|drop-shadow|url/.test(this.filter)}},{key:"filter",get:function(){return this[z].join(" ")}},{key:"transformMatrix",get:function(){return this[ce]}},{key:"invertMatrix",get:function(){if(!this[L]){var J=v.mat2d.invert(Array.of(0,0,0,0,0,0),this[ce]);this[L]=J}return this[L]}},{key:"transformScale",get:function(){var J=this[ce];return Math.max(Math.hypot(J[0],J[1]),Math.hypot(J[2],J[3]))}},{key:"uniforms",get:function(){return this[W]}},{key:"pass",get:function(){return this[q]}},{key:"meshData",get:function(){var J=this;if(this._updateMatrix){var se=this.transformScale/this.contours.scale;se>1.5&&this.accurate(this.transformScale)}if(!this[N]){!this[U]&&!this[k]&&this.setFill();var ue=this[A],oe={};if(ue&&ue.length){if(this[U])try{var de=b()(ue,this[U]);de.positions=de.positions.map(function(Re){return Re.push(J[B]),Re}),de.attributes={a_color:Array.from({length:de.positions.length}).map(function(){return J[Q].map(function(Re){return Math.round(255*Re)})})},oe.fill=de}catch{}if(this[k]){var me=this[k].lineDash,ye=ue;if(me){var be=this[k].lineDashOffset;ye=Object(M.getDashContours)(ue,me,be)}var Ce=ye.map(function(Re,ke){var Oe=Re.length>1&&v.vec2.equals(Re[0],Re[Re.length-1]),je=J[k].build(Re,Oe);return b()([je])});Ce.forEach(function(Re){Re.positions=Re.positions.map(function(ke){return ke.push(-J[B]),ke}),Re.attributes={a_color:Array.from({length:Re.positions.length}).map(function(){return J[Z].map(function(ke){return Math.round(255*ke)})})}}),oe.stroke=Object(j.default)(Ce)}}var Ie=Object(j.default)([oe.fill,oe.stroke]);Ie.fillPointCount=oe.fill?oe.fill.positions.length:0,Ie.enableBlend=this.enableBlend,Ie.position0=Ie.positions.map(function(Re){var ke=p()(Re,3),Oe=ke[0],je=ke[1],Be=ke[2];return[Oe,je,Be]}),Ie.uniforms=this[W],this[N]=Ie,this[W].u_texSampler&&this[ee](Ie,this[H]);var Pe=this[ce];Object(f.isUnitTransform)(Pe)||(this[ie](Ie,Pe),this[W].u_radialGradientVector&&this[le]()),this.clipPath&&this[m](),this[X]&&this[pe](this[X])}return this._updateMatrix&&(this[N].matrix=this[ce],this[ie](this[N],this[ce]),this[W].u_radialGradientVector&&this[le]()),this[N]}}]),re}()},function(e,r,n){var s=n(75);function o(a,c){if(a==null)return{};var l=s(a,c),u,h;if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);for(h=0;h<d.length;h++)u=d[h],!(c.indexOf(u)>=0)&&Object.prototype.propertyIsEnumerable.call(a,u)&&(l[u]=a[u])}return l}e.exports=o},function(e,r){function n(s,o){if(s==null)return{};var a={},c=Object.keys(s),l,u;for(u=0;u<c.length;u++)l=c[u],!(o.indexOf(l)>=0)&&(a[l]=s[l]);return a}e.exports=n},function(e,r,n){n.r(r);var s=n(77);n(1).glMatrix.setMatrixArrayType(Array),r.default=s.Stroke},function(e,r,n){n.r(r),n.d(r,"Stroke",function(){return x});var s=n(19),o=n.n(s),a=n(23),c=n.n(a),l=n(24),u=n.n(l),h=n(66);n(1).glMatrix.setMatrixArrayType(Array);var d=Object(h.create)(),g=Object(h.create)(),p=Object(h.create)(),v=Object(h.create)(),I=Object(h.create)(),D=1e20,x=function(){function f(){var M=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},T=M.lineWidth,b=T===void 0?1:T,C=M.lineJoin,P=C===void 0?"miter":C,E=M.miterLimit,O=E===void 0?10:E,V=M.lineCap,N=V===void 0?"butt":V,A=M.roundSegments,k=A===void 0?20:A;c()(this,f),this.lineWidth=b,this.lineJoin=P,this.miterLimit=O,this.lineCap=N,this.roundSegments=k,this._normal=null}return u()(f,[{key:"build",value:function(T){var b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,C=T.length;if(T=o()(T),C<2)return T;b&&((T[0][0]!==T[C-1][0]||T[0][1]!==T[C-1][1])&&T.push(o()(T[0])),T.push(o()(T[1]))),C=T.length,this._normal=null;var P={left:[],right:[]},E=this.lineWidth/2,O=this.lineCap;if(!b&&O==="square"){Object(h.direction)(g,T[0],T[1]),Object(h.scaleAndAdd)(T[0],T[0],g,E);var V=T.length-1;Object(h.direction)(g,T[V],T[V-1]),Object(h.scaleAndAdd)(T[V],T[V],g,E)}for(var N=1;N<C;N++){var A=T[N-1],k=T[N],U=T[N+1];this._seg(P,A,k,U,E,b)}!b&&O==="round"&&y(P,this.roundSegments);var Z=[].concat(o()(P.left),o()(P.right.reverse()));return Z}},{key:"_seg",value:function(T,b,C,P,E,O){var V=this.lineJoin==="bevel",N=this.lineJoin==="round";if(Object(h.direction)(g,C,b),this._normal||(this._normal=Object(h.create)(),Object(h.normal)(this._normal,g)),T.left.length||w(T,b,this._normal,E),!P)Object(h.normal)(this._normal,g),O?w(T,b,this._normal,E):w(T,C,this._normal,E);else{Object(h.direction)(p,P,C);var A=Object(h.computeMiter)(v,I,g,p,E);A=Math.min(A,D);var k=Object(h.dot)(v,this._normal)<0?-1:1,U=V||N;if(!U&&this.lineJoin==="miter"){var Z=A/E;Z>this.miterLimit&&(U=!0)}if(U){Object(h.scaleAndAdd)(d,C,this._normal,-E*k),j(T,d,k);var Q=1/0;b&&(Q=Math.min(Q,Math.hypot(C[0]-b[0],C[1]-b[1]))),P&&(Q=Math.min(Q,Math.hypot(P[0]-C[0],P[1]-C[1])));var ce=Math.max(E,Math.min(A,Q));if(Object(h.scaleAndAdd)(d,C,I,ce*k),j(T,d,-k),P)if(Object(h.normal)(d,p),Object(h.copy)(this._normal,d),Object(h.scaleAndAdd)(d,C,d,-E*k),N){for(var L=Object(h.clone)(d),W=k>0?T.left[T.left.length-1]:T.right[T.right.length-1],H=Object(h.clone)(C),$=Object(h.sub)(Object(h.create)(),W,H),ee=Object(h.sub)(Object(h.create)(),L,H),ie=Math.PI/this.roundSegments,le=0;le<this.roundSegments&&(Object(h.rotate)($,$,[0,0],k*ie),Math.sign(Object(h.cross)(d,$,ee)[2])===k);le++)Object(h.add)(d,$,H),j(T,d,k);j(T,L,k)}else j(T,d,k)}else w(T,C,I,A),Object(h.copy)(this._normal,I)}}}]),f}();function j(f,M,T){T>0?f.left.push(Object(h.clone)(M)):f.right.push(Object(h.clone)(M))}function w(f,M,T,b){var C=arguments.length>4&&arguments[4]!==void 0?arguments[4]:-1;Object(h.scaleAndAdd)(d,M,T,-b),j(f,d,-C),Object(h.scaleAndAdd)(d,M,T,b),j(f,d,C)}function y(f,M){var T=f.left,b=f.right,C=Object(h.create)(),P=Object(h.create)(),E=T[0],O=b[0],V=[.5*(E[0]+O[0]),.5*(E[1]+O[1])];Object(h.sub)(P,E,V);for(var N=1;N<=M;N++){var A=-1*Math.PI*N/M;Object(h.rotate)(C,P,[0,0],A),Object(h.add)(d,V,C),T.unshift(Object(h.clone)(d))}E=b[b.length-1],O=T[T.length-1],V=[.5*(E[0]+O[0]),.5*(E[1]+O[1])],Object(h.sub)(P,E,V);for(var k=1;k<=M;k++){var U=-1*Math.PI*k/M;Object(h.rotate)(C,P,[0,0],U),Object(h.add)(d,V,C),b.push(Object(h.clone)(d))}}},function(e,r,n){n.r(r),n.d(r,"isUnitTransform",function(){return s}),n(1).glMatrix.setMatrixArrayType(Array);function s(o){return o[0]===1&&o[1]===0&&o[2]===0&&o[3]===1&&o[4]===0&&o[5]===0}},function(e,r,n){n(1).glMatrix.setMatrixArrayType(Array);var s=n(80),o=n(81);e.exports=function(a,c){if(c=c||{},a=a.filter(function(x){return x.length>2}),a.length===0)return{positions:[],cells:[]};typeof c.vertexSize!="number"&&(c.vertexSize=a[0][0].length),a=a.map(function(x){return x.reduce(function(j,w){return j.concat(w)})});for(var l=c.rule==="evenodd"?s.WINDING_ODD:s.WINDING_NONZERO,u=s.tesselate(o({contours:a,windingRule:l,elementType:s.POLYGONS,polySize:3,vertexSize:2},c)),h=[],d=0;d<u.vertices.length;d+=c.vertexSize){var g=u.vertices.slice(d,d+c.vertexSize);h.push(g)}var p=[];for(d=0;d<u.elements.length;d+=3){var v=u.elements[d],I=u.elements[d+1],D=u.elements[d+2];p.push([v,I,D])}return{positions:h,cells:p}}},function(e,r,n){n(1).glMatrix.setMatrixArrayType(Array);var s={},o={};e.exports=s,s.WINDING_ODD=0,s.WINDING_NONZERO=1,s.WINDING_POSITIVE=2,s.WINDING_NEGATIVE=3,s.WINDING_ABS_GEQ_TWO=4,s.POLYGONS=0,s.CONNECTED_POLYGONS=1,s.BOUNDARY_CONTOURS=2,s.tesselate=function(w){for(var y=w.debug||!1,f=new j,M=0;M<w.contours.length;M++)f.addContour(w.vertexSize||2,w.contours[M]);return f.tesselate(w.windingRule||s.WINDING_ODD,w.elementType||s.POLYGONS,w.polySize||3,w.vertexSize||2,w.normal||[0,0,1]),{vertices:f.vertices,vertexIndices:f.vertexIndices,vertexCount:f.vertexCount,elements:f.elements,elementCount:f.elementCount,mesh:y?f.mesh:void 0}};var a=function(y){if(!y)throw"Assertion Failed!"};function c(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}function l(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}function u(w){this.next=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Org=null,this.Lface=null,this.activeRegion=null,this.winding=0,this.side=w}u.prototype={get Rface(){return this.Sym.Lface},set Rface(w){this.Sym.Lface=w},get Dst(){return this.Sym.Org},set Dst(w){this.Sym.Org=w},get Oprev(){return this.Sym.Lnext},set Oprev(w){this.Sym.Lnext=w},get Lprev(){return this.Onext.Sym},set Lprev(w){this.Onext.Sym=w},get Dprev(){return this.Lnext.Sym},set Dprev(w){this.Lnext.Sym=w},get Rprev(){return this.Sym.Onext},set Rprev(w){this.Sym.Onext=w},get Dnext(){return this.Sym.Onext.Sym},set Dnext(w){this.Sym.Onext.Sym=w},get Rnext(){return this.Sym.Lnext.Sym},set Rnext(w){this.Sym.Lnext.Sym=w}};function h(){var w=new c,y=new l,f=new u(0),M=new u(1);w.next=w.prev=w,w.anEdge=null,y.next=y.prev=y,y.anEdge=null,y.trail=null,y.marked=!1,y.inside=!1,f.next=f,f.Sym=M,f.Onext=null,f.Lnext=null,f.Org=null,f.Lface=null,f.winding=0,f.activeRegion=null,M.next=M,M.Sym=f,M.Onext=null,M.Lnext=null,M.Org=null,M.Lface=null,M.winding=0,M.activeRegion=null,this.vHead=w,this.fHead=y,this.eHead=f,this.eHeadSym=M}h.prototype={makeEdge_:function(y){var f=new u(0),M=new u(1);y.Sym.side<y.side&&(y=y.Sym);var T=y.Sym.next;return M.next=T,T.Sym.next=f,f.next=y,y.Sym.next=M,f.Sym=M,f.Onext=f,f.Lnext=M,f.Org=null,f.Lface=null,f.winding=0,f.activeRegion=null,M.Sym=f,M.Onext=M,M.Lnext=f,M.Org=null,M.Lface=null,M.winding=0,M.activeRegion=null,f},splice_:function(y,f){var M=y.Onext,T=f.Onext;M.Sym.Lnext=f,T.Sym.Lnext=y,y.Onext=T,f.Onext=M},makeVertex_:function(y,f,M){var T=y;a(T!==null);var b=M.prev;T.prev=b,b.next=T,T.next=M,M.prev=T,T.anEdge=f;var C=f;do C.Org=T,C=C.Onext;while(C!==f)},makeFace_:function(y,f,M){var T=y;a(T!==null);var b=M.prev;T.prev=b,b.next=T,T.next=M,M.prev=T,T.anEdge=f,T.trail=null,T.marked=!1,T.inside=M.inside;var C=f;do C.Lface=T,C=C.Lnext;while(C!==f)},killEdge_:function(y){y.Sym.side<y.side&&(y=y.Sym);var f=y.next,M=y.Sym.next;f.Sym.next=M,M.Sym.next=f},killVertex_:function(y,f){var M=y.anEdge,T=M;do T.Org=f,T=T.Onext;while(T!==M);var b=y.prev,C=y.next;C.prev=b,b.next=C},killFace_:function(y,f){var M=y.anEdge,T=M;do T.Lface=f,T=T.Lnext;while(T!==M);var b=y.prev,C=y.next;C.prev=b,b.next=C},makeEdge:function(){var y=new c,f=new c,M=new l,T=this.makeEdge_(this.eHead);return this.makeVertex_(y,T,this.vHead),this.makeVertex_(f,T.Sym,this.vHead),this.makeFace_(M,T,this.fHead),T},splice:function(y,f){var M=!1,T=!1;if(y!==f){if(f.Org!==y.Org&&(T=!0,this.killVertex_(f.Org,y.Org)),f.Lface!==y.Lface&&(M=!0,this.killFace_(f.Lface,y.Lface)),this.splice_(f,y),!T){var b=new c;this.makeVertex_(b,f,y.Org),y.Org.anEdge=y}if(!M){var C=new l;this.makeFace_(C,f,y.Lface),y.Lface.anEdge=y}}},delete:function(y){var f=y.Sym,M=!1;if(y.Lface!==y.Rface&&(M=!0,this.killFace_(y.Lface,y.Rface)),y.Onext===y)this.killVertex_(y.Org,null);else if(y.Rface.anEdge=y.Oprev,y.Org.anEdge=y.Onext,this.splice_(y,y.Oprev),!M){var T=new l;this.makeFace_(T,y,y.Lface)}f.Onext===f?(this.killVertex_(f.Org,null),this.killFace_(f.Lface,null)):(y.Lface.anEdge=f.Oprev,f.Org.anEdge=f.Onext,this.splice_(f,f.Oprev)),this.killEdge_(y)},addEdgeVertex:function(y){var f=this.makeEdge_(y),M=f.Sym;this.splice_(f,y.Lnext),f.Org=y.Dst;var T=new c;return this.makeVertex_(T,M,f.Org),f.Lface=M.Lface=y.Lface,f},splitEdge:function(y,f){var M=this.addEdgeVertex(y),T=M.Sym;return this.splice_(y.Sym,y.Sym.Oprev),this.splice_(y.Sym,T),y.Dst=T.Org,T.Dst.anEdge=T.Sym,T.Rface=y.Rface,T.winding=y.winding,T.Sym.winding=y.Sym.winding,T},connect:function(y,f){var M=!1,T=this.makeEdge_(y),b=T.Sym;if(f.Lface!==y.Lface&&(M=!0,this.killFace_(f.Lface,y.Lface)),this.splice_(T,y.Lnext),this.splice_(b,f),T.Org=y.Dst,b.Org=f.Org,T.Lface=b.Lface=y.Lface,y.Lface.anEdge=b,!M){var C=new l;this.makeFace_(C,T,y.Lface)}return T},zapFace:function(y){var f=y.anEdge,M,T,b,C,P;T=f.Lnext;do M=T,T=M.Lnext,M.Lface=null,M.Rface===null&&(M.Onext===M?this.killVertex_(M.Org,null):(M.Org.anEdge=M.Onext,this.splice_(M,M.Oprev)),b=M.Sym,b.Onext===b?this.killVertex_(b.Org,null):(b.Org.anEdge=b.Onext,this.splice_(b,b.Oprev)),this.killEdge_(M));while(M!=f);C=y.prev,P=y.next,P.prev=C,C.next=P},countFaceVerts_:function(y){var f=y.anEdge,M=0;do M++,f=f.Lnext;while(f!==y.anEdge);return M},mergeConvexFaces:function(y){var f,M,T,b,C,P,E;for(f=this.fHead.next;f!==this.fHead;f=f.next)if(f.inside)for(M=f.anEdge,C=M.Org;T=M.Lnext,b=M.Sym,b&&b.Lface&&b.Lface.inside&&(P=this.countFaceVerts_(f),E=this.countFaceVerts_(b.Lface),P+E-2<=y&&o.vertCCW(M.Lprev.Org,M.Org,b.Lnext.Lnext.Org)&&o.vertCCW(b.Lprev.Org,b.Org,M.Lnext.Lnext.Org)&&(T=b.Lnext,this.delete(b),M=null,b=null)),!(M&&M.Lnext.Org===C);)M=T;return!0},check:function(){var y=this.fHead,f=this.vHead,M=this.eHead,T,b,C,P,E,O;for(b=y,b=y;(T=b.next)!==y;b=T){a(T.prev===b),E=T.anEdge;do a(E.Sym!==E),a(E.Sym.Sym===E),a(E.Lnext.Onext.Sym===E),a(E.Onext.Sym.Lnext===E),a(E.Lface===T),E=E.Lnext;while(E!==T.anEdge)}for(a(T.prev===b&&T.anEdge===null),P=f,P=f;(C=P.next)!==f;P=C){a(C.prev===P),E=C.anEdge;do a(E.Sym!==E),a(E.Sym.Sym===E),a(E.Lnext.Onext.Sym===E),a(E.Onext.Sym.Lnext===E),a(E.Org===C),E=E.Onext;while(E!==C.anEdge)}for(a(C.prev===P&&C.anEdge===null),O=M,O=M;(E=O.next)!==M;O=E)a(E.Sym.next===O.Sym),a(E.Sym!==E),a(E.Sym.Sym===E),a(E.Org!==null),a(E.Dst!==null),a(E.Lnext.Onext.Sym===E),a(E.Onext.Sym.Lnext===E);a(E.Sym.next===O.Sym&&E.Sym===this.eHeadSym&&E.Sym.Sym===E&&E.Org===null&&E.Dst===null&&E.Lface===null&&E.Rface===null)}},o.vertEq=function(w,y){return w.s===y.s&&w.t===y.t},o.vertLeq=function(w,y){return w.s<y.s||w.s===y.s&&w.t<=y.t},o.transLeq=function(w,y){return w.t<y.t||w.t===y.t&&w.s<=y.s},o.edgeGoesLeft=function(w){return o.vertLeq(w.Dst,w.Org)},o.edgeGoesRight=function(w){return o.vertLeq(w.Org,w.Dst)},o.vertL1dist=function(w,y){return Math.abs(w.s-y.s)+Math.abs(w.t-y.t)},o.edgeEval=function(w,y,f){a(o.vertLeq(w,y)&&o.vertLeq(y,f));var M=y.s-w.s,T=f.s-y.s;return M+T>0?M<T?y.t-w.t+(w.t-f.t)*(M/(M+T)):y.t-f.t+(f.t-w.t)*(T/(M+T)):0},o.edgeSign=function(w,y,f){a(o.vertLeq(w,y)&&o.vertLeq(y,f));var M=y.s-w.s,T=f.s-y.s;return M+T>0?(y.t-f.t)*M+(y.t-w.t)*T:0},o.transEval=function(w,y,f){a(o.transLeq(w,y)&&o.transLeq(y,f));var M=y.t-w.t,T=f.t-y.t;return M+T>0?M<T?y.s-w.s+(w.s-f.s)*(M/(M+T)):y.s-f.s+(f.s-w.s)*(T/(M+T)):0},o.transSign=function(w,y,f){a(o.transLeq(w,y)&&o.transLeq(y,f));var M=y.t-w.t,T=f.t-y.t;return M+T>0?(y.s-f.s)*M+(y.s-w.s)*T:0},o.vertCCW=function(w,y,f){return w.s*(y.t-f.t)+y.s*(f.t-w.t)+f.s*(w.t-y.t)>=0},o.interpolate=function(w,y,f,M){return w=w<0?0:w,f=f<0?0:f,w<=f?f===0?(y+M)/2:y+(M-y)*(w/(w+f)):M+(y-M)*(f/(w+f))},o.intersect=function(w,y,f,M,T){var b,C,P;o.vertLeq(w,y)||(P=w,w=y,y=P),o.vertLeq(f,M)||(P=f,f=M,M=P),o.vertLeq(w,f)||(P=w,w=f,f=P,P=y,y=M,M=P),o.vertLeq(f,y)?o.vertLeq(y,M)?(b=o.edgeEval(w,f,y),C=o.edgeEval(f,y,M),b+C<0&&(b=-b,C=-C),T.s=o.interpolate(b,f.s,C,y.s)):(b=o.edgeSign(w,f,y),C=-o.edgeSign(w,M,y),b+C<0&&(b=-b,C=-C),T.s=o.interpolate(b,f.s,C,M.s)):T.s=(f.s+y.s)/2,o.transLeq(w,y)||(P=w,w=y,y=P),o.transLeq(f,M)||(P=f,f=M,M=P),o.transLeq(w,f)||(P=w,w=f,f=P,P=y,y=M,M=P),o.transLeq(f,y)?o.transLeq(y,M)?(b=o.transEval(w,f,y),C=o.transEval(f,y,M),b+C<0&&(b=-b,C=-C),T.t=o.interpolate(b,f.t,C,y.t)):(b=o.transSign(w,f,y),C=-o.transSign(w,M,y),b+C<0&&(b=-b,C=-C),T.t=o.interpolate(b,f.t,C,M.t)):T.t=(f.t+y.t)/2};function d(){this.key=null,this.next=null,this.prev=null}function g(w,y){this.head=new d,this.head.next=this.head,this.head.prev=this.head,this.frame=w,this.leq=y}g.prototype={min:function(){return this.head.next},max:function(){return this.head.prev},insert:function(y){return this.insertBefore(this.head,y)},search:function(y){var f=this.head;do f=f.next;while(f.key!==null&&!this.leq(this.frame,y,f.key));return f},insertBefore:function(y,f){do y=y.prev;while(y.key!==null&&!this.leq(this.frame,y.key,f));var M=new d;return M.key=f,M.next=y.next,y.next.prev=M,M.prev=y,y.next=M,M},delete:function(y){y.next.prev=y.prev,y.prev.next=y.next}};function p(){this.handle=null}function v(){this.key=null,this.node=null}function I(w,y){this.size=0,this.max=w,this.nodes=[],this.nodes.length=w+1;var f;for(f=0;f<this.nodes.length;f++)this.nodes[f]=new p;for(this.handles=[],this.handles.length=w+1,f=0;f<this.handles.length;f++)this.handles[f]=new v;this.initialized=!1,this.freeList=0,this.leq=y,this.nodes[1].handle=1,this.handles[1].key=null}I.prototype={floatDown_:function(y){var f=this.nodes,M=this.handles,T,b,C;for(T=f[y].handle;;){if(C=y<<1,C<this.size&&this.leq(M[f[C+1].handle].key,M[f[C].handle].key)&&++C,a(C<=this.max),b=f[C].handle,C>this.size||this.leq(M[T].key,M[b].key)){f[y].handle=T,M[T].node=y;break}f[y].handle=b,M[b].node=y,y=C}},floatUp_:function(y){var f=this.nodes,M=this.handles,T,b,C;for(T=f[y].handle;;){if(C=y>>1,b=f[C].handle,C===0||this.leq(M[b].key,M[T].key)){f[y].handle=T,M[T].node=y;break}f[y].handle=b,M[b].node=y,y=C}},init:function(){for(var y=this.size;y>=1;--y)this.floatDown_(y);this.initialized=!0},min:function(){return this.handles[this.nodes[1].handle].key},insert:function(y){var f,M;if(f=++this.size,f*2>this.max){this.max*=2;var T,b;for(b=this.nodes.length,this.nodes.length=this.max+1,T=b;T<this.nodes.length;T++)this.nodes[T]=new p;for(b=this.handles.length,this.handles.length=this.max+1,T=b;T<this.handles.length;T++)this.handles[T]=new v}return this.freeList===0?M=f:(M=this.freeList,this.freeList=this.handles[M].node),this.nodes[f].handle=M,this.handles[M].node=f,this.handles[M].key=y,this.initialized&&this.floatUp_(f),M},extractMin:function(){var y=this.nodes,f=this.handles,M=y[1].handle,T=f[M].key;return this.size>0&&(y[1].handle=y[this.size].handle,f[y[1].handle].node=1,f[M].key=null,f[M].node=this.freeList,this.freeList=M,--this.size,this.size>0&&this.floatDown_(1)),T},delete:function(y){var f=this.nodes,M=this.handles,T;a(y>=1&&y<=this.max&&M[y].key!==null),T=M[y].node,f[T].handle=f[this.size].handle,M[f[T].handle].node=T,--this.size,T<=this.size&&(T<=1||this.leq(M[f[T>>1].handle].key,M[f[T].handle].key)?this.floatDown_(T):this.floatUp_(T)),M[y].key=null,M[y].node=this.freeList,this.freeList=y}};function D(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}var x={};x.regionBelow=function(w){return w.nodeUp.prev.key},x.regionAbove=function(w){return w.nodeUp.next.key},x.debugEvent=function(w){},x.addWinding=function(w,y){w.winding+=y.winding,w.Sym.winding+=y.Sym.winding},x.edgeLeq=function(w,y,f){var M=w.event,C,P,T=y.eUp,b=f.eUp;if(T.Dst===M)return b.Dst===M?o.vertLeq(T.Org,b.Org)?o.edgeSign(b.Dst,T.Org,b.Org)<=0:o.edgeSign(T.Dst,b.Org,T.Org)>=0:o.edgeSign(b.Dst,M,b.Org)<=0;if(b.Dst===M)return o.edgeSign(T.Dst,M,T.Org)>=0;var C=o.edgeEval(T.Dst,M,T.Org),P=o.edgeEval(b.Dst,M,b.Org);return C>=P},x.deleteRegion=function(w,y){y.fixUpperEdge&&a(y.eUp.winding===0),y.eUp.activeRegion=null,w.dict.delete(y.nodeUp)},x.fixUpperEdge=function(w,y,f){a(y.fixUpperEdge),w.mesh.delete(y.eUp),y.fixUpperEdge=!1,y.eUp=f,f.activeRegion=y},x.topLeftRegion=function(w,y){var f=y.eUp.Org,M;do y=x.regionAbove(y);while(y.eUp.Org===f);if(y.fixUpperEdge){if(M=w.mesh.connect(x.regionBelow(y).eUp.Sym,y.eUp.Lnext),M===null)return null;x.fixUpperEdge(w,y,M),y=x.regionAbove(y)}return y},x.topRightRegion=function(w){var y=w.eUp.Dst;do w=x.regionAbove(w);while(w.eUp.Dst===y);return w},x.addRegionBelow=function(w,y,f){var M=new D;return M.eUp=f,M.nodeUp=w.dict.insertBefore(y.nodeUp,M),M.fixUpperEdge=!1,M.sentinel=!1,M.dirty=!1,f.activeRegion=M,M},x.isWindingInside=function(w,y){switch(w.windingRule){case s.WINDING_ODD:return(y&1)!==0;case s.WINDING_NONZERO:return y!==0;case s.WINDING_POSITIVE:return y>0;case s.WINDING_NEGATIVE:return y<0;case s.WINDING_ABS_GEQ_TWO:return y>=2||y<=-2}return a(!1),!1},x.computeWinding=function(w,y){y.windingNumber=x.regionAbove(y).windingNumber+y.eUp.winding,y.inside=x.isWindingInside(w,y.windingNumber)},x.finishRegion=function(w,y){var f=y.eUp,M=f.Lface;M.inside=y.inside,M.anEdge=f,x.deleteRegion(w,y)},x.finishLeftRegions=function(w,y,f){for(var M,C,T=null,b=y,C=y.eUp;b!==f;){if(b.fixUpperEdge=!1,T=x.regionBelow(b),M=T.eUp,M.Org!=C.Org){if(!T.fixUpperEdge){x.finishRegion(w,b);break}M=w.mesh.connect(C.Lprev,M.Sym),x.fixUpperEdge(w,T,M)}C.Onext!==M&&(w.mesh.splice(M.Oprev,M),w.mesh.splice(C,M)),x.finishRegion(w,b),C=T.eUp,b=T}return C},x.addRightEdges=function(w,y,f,M,T,b){var C,P,E,O,V=!0;E=f;do a(o.vertLeq(E.Org,E.Dst)),x.addRegionBelow(w,y,E.Sym),E=E.Onext;while(E!==M);for(T===null&&(T=x.regionBelow(y).eUp.Rprev),P=y,O=T;C=x.regionBelow(P),E=C.eUp.Sym,E.Org===O.Org;)E.Onext!==O&&(w.mesh.splice(E.Oprev,E),w.mesh.splice(O.Oprev,E)),C.windingNumber=P.windingNumber-E.winding,C.inside=x.isWindingInside(w,C.windingNumber),P.dirty=!0,!V&&x.checkForRightSplice(w,P)&&(x.addWinding(E,O),x.deleteRegion(w,P),w.mesh.delete(O)),V=!1,P=C,O=E;P.dirty=!0,a(P.windingNumber-E.winding===C.windingNumber),b&&x.walkDirtyRegions(w,P)},x.spliceMergeVertices=function(w,y,f){w.mesh.splice(y,f)},x.vertexWeights=function(w,y,f){var M=o.vertL1dist(y,w),T=o.vertL1dist(f,w),b=.5*T/(M+T),C=.5*M/(M+T);w.coords[0]+=b*y.coords[0]+C*f.coords[0],w.coords[1]+=b*y.coords[1]+C*f.coords[1],w.coords[2]+=b*y.coords[2]+C*f.coords[2]},x.getIntersectData=function(w,y,f,M,T,b){y.coords[0]=y.coords[1]=y.coords[2]=0,y.idx=-1,x.vertexWeights(y,f,M),x.vertexWeights(y,T,b)},x.checkForRightSplice=function(w,y){var f=x.regionBelow(y),M=y.eUp,T=f.eUp;if(o.vertLeq(M.Org,T.Org)){if(o.edgeSign(T.Dst,M.Org,T.Org)>0)return!1;o.vertEq(M.Org,T.Org)?M.Org!==T.Org&&(w.pq.delete(M.Org.pqHandle),x.spliceMergeVertices(w,T.Oprev,M)):(w.mesh.splitEdge(T.Sym),w.mesh.splice(M,T.Oprev),y.dirty=f.dirty=!0)}else{if(o.edgeSign(M.Dst,T.Org,M.Org)<0)return!1;x.regionAbove(y).dirty=y.dirty=!0,w.mesh.splitEdge(M.Sym),w.mesh.splice(T.Oprev,M)}return!0},x.checkForLeftSplice=function(w,y){var f=x.regionBelow(y),M=y.eUp,T=f.eUp,b;if(a(!o.vertEq(M.Dst,T.Dst)),o.vertLeq(M.Dst,T.Dst)){if(o.edgeSign(M.Dst,T.Dst,M.Org)<0)return!1;x.regionAbove(y).dirty=y.dirty=!0,b=w.mesh.splitEdge(M),w.mesh.splice(T.Sym,b),b.Lface.inside=y.inside}else{if(o.edgeSign(T.Dst,M.Dst,T.Org)>0)return!1;y.dirty=f.dirty=!0,b=w.mesh.splitEdge(T),w.mesh.splice(M.Lnext,T.Sym),b.Rface.inside=y.inside}return!0},x.checkForIntersect=function(w,y){var f=x.regionBelow(y),M=y.eUp,T=f.eUp,b=M.Org,C=T.Org,P=M.Dst,E=T.Dst,O,V,N=new c,A,k;if(a(!o.vertEq(E,P)),a(o.edgeSign(P,w.event,b)<=0),a(o.edgeSign(E,w.event,C)>=0),a(b!==w.event&&C!==w.event),a(!y.fixUpperEdge&&!f.fixUpperEdge),b===C||(O=Math.min(b.t,P.t),V=Math.max(C.t,E.t),O>V))return!1;if(o.vertLeq(b,C)){if(o.edgeSign(E,b,C)>0)return!1}else if(o.edgeSign(P,C,b)<0)return!1;return x.debugEvent(w),o.intersect(P,b,E,C,N),a(Math.min(b.t,P.t)<=N.t),a(N.t<=Math.max(C.t,E.t)),a(Math.min(E.s,P.s)<=N.s),a(N.s<=Math.max(C.s,b.s)),o.vertLeq(N,w.event)&&(N.s=w.event.s,N.t=w.event.t),A=o.vertLeq(b,C)?b:C,o.vertLeq(A,N)&&(N.s=A.s,N.t=A.t),o.vertEq(N,b)||o.vertEq(N,C)?(x.checkForRightSplice(w,y),!1):!o.vertEq(P,w.event)&&o.edgeSign(P,w.event,N)>=0||!o.vertEq(E,w.event)&&o.edgeSign(E,w.event,N)<=0?E===w.event?(w.mesh.splitEdge(M.Sym),w.mesh.splice(T.Sym,M),y=x.topLeftRegion(w,y),M=x.regionBelow(y).eUp,x.finishLeftRegions(w,x.regionBelow(y),f),x.addRightEdges(w,y,M.Oprev,M,M,!0),!0):P===w.event?(w.mesh.splitEdge(T.Sym),w.mesh.splice(M.Lnext,T.Oprev),f=y,y=x.topRightRegion(y),k=x.regionBelow(y).eUp.Rprev,f.eUp=T.Oprev,T=x.finishLeftRegions(w,f,null),x.addRightEdges(w,y,T.Onext,M.Rprev,k,!0),!0):(o.edgeSign(P,w.event,N)>=0&&(x.regionAbove(y).dirty=y.dirty=!0,w.mesh.splitEdge(M.Sym),M.Org.s=w.event.s,M.Org.t=w.event.t),o.edgeSign(E,w.event,N)<=0&&(y.dirty=f.dirty=!0,w.mesh.splitEdge(T.Sym),T.Org.s=w.event.s,T.Org.t=w.event.t),!1):(w.mesh.splitEdge(M.Sym),w.mesh.splitEdge(T.Sym),w.mesh.splice(T.Oprev,M),M.Org.s=N.s,M.Org.t=N.t,M.Org.pqHandle=w.pq.insert(M.Org),x.getIntersectData(w,M.Org,b,P,C,E),x.regionAbove(y).dirty=y.dirty=f.dirty=!0,!1)},x.walkDirtyRegions=function(w,y){for(var f=x.regionBelow(y),M,T;;){for(;f.dirty;)y=f,f=x.regionBelow(f);if(!y.dirty&&(f=y,y=x.regionAbove(y),y===null||!y.dirty))return;if(y.dirty=!1,M=y.eUp,T=f.eUp,M.Dst!==T.Dst&&x.checkForLeftSplice(w,y)&&(f.fixUpperEdge?(x.deleteRegion(w,f),w.mesh.delete(T),f=x.regionBelow(y),T=f.eUp):y.fixUpperEdge&&(x.deleteRegion(w,y),w.mesh.delete(M),y=x.regionAbove(f),M=y.eUp)),M.Org!==T.Org)if(M.Dst!==T.Dst&&!y.fixUpperEdge&&!f.fixUpperEdge&&(M.Dst===w.event||T.Dst===w.event)){if(x.checkForIntersect(w,y))return}else x.checkForRightSplice(w,y);M.Org===T.Org&&M.Dst===T.Dst&&(x.addWinding(T,M),x.deleteRegion(w,y),w.mesh.delete(M),y=x.regionAbove(f))}},x.connectRightVertex=function(w,y,f){var M,T=f.Onext,b=x.regionBelow(y),C=y.eUp,P=b.eUp,E=!1;if(C.Dst!==P.Dst&&x.checkForIntersect(w,y),o.vertEq(C.Org,w.event)&&(w.mesh.splice(T.Oprev,C),y=x.topLeftRegion(w,y),T=x.regionBelow(y).eUp,x.finishLeftRegions(w,x.regionBelow(y),b),E=!0),o.vertEq(P.Org,w.event)&&(w.mesh.splice(f,P.Oprev),f=x.finishLeftRegions(w,b,null),E=!0),E){x.addRightEdges(w,y,f.Onext,T,T,!0);return}o.vertLeq(P.Org,C.Org)?M=P.Oprev:M=C,M=w.mesh.connect(f.Lprev,M),x.addRightEdges(w,y,M,M.Onext,M.Onext,!1),M.Sym.activeRegion.fixUpperEdge=!0,x.walkDirtyRegions(w,y)},x.connectLeftDegenerate=function(w,y,f){var M,T,b,C,P;if(M=y.eUp,o.vertEq(M.Org,f)){a(!1),x.spliceMergeVertices(w,M,f.anEdge);return}if(!o.vertEq(M.Dst,f)){w.mesh.splitEdge(M.Sym),y.fixUpperEdge&&(w.mesh.delete(M.Onext),y.fixUpperEdge=!1),w.mesh.splice(f.anEdge,M),x.sweepEvent(w,f);return}a(!1),y=x.topRightRegion(y),P=x.regionBelow(y),b=P.eUp.Sym,T=C=b.Onext,P.fixUpperEdge&&(a(T!==b),x.deleteRegion(w,P),w.mesh.delete(b),b=T.Oprev),w.mesh.splice(f.anEdge,b),o.edgeGoesLeft(T)||(T=null),x.addRightEdges(w,y,b.Onext,C,T,!0)},x.connectLeftVertex=function(w,y){var f,M,T,b,C,P,E=new D;if(E.eUp=y.anEdge.Sym,f=w.dict.search(E).key,M=x.regionBelow(f),!!M){if(b=f.eUp,C=M.eUp,o.edgeSign(b.Dst,y,b.Org)===0){x.connectLeftDegenerate(w,f,y);return}if(T=o.vertLeq(C.Dst,b.Dst)?f:M,f.inside||T.fixUpperEdge){if(T===f)P=w.mesh.connect(y.anEdge.Sym,b.Lnext);else{var O=w.mesh.connect(C.Dnext,y.anEdge);P=O.Sym}T.fixUpperEdge?x.fixUpperEdge(w,T,P):x.computeWinding(w,x.addRegionBelow(w,f,P)),x.sweepEvent(w,y)}else x.addRightEdges(w,f,y.anEdge,y.anEdge,null,!0)}},x.sweepEvent=function(w,y){w.event=y,x.debugEvent(w);for(var f=y.anEdge;f.activeRegion===null;)if(f=f.Onext,f===y.anEdge){x.connectLeftVertex(w,y);return}var M=x.topLeftRegion(w,f.activeRegion);a(M!==null);var T=x.regionBelow(M),b=T.eUp,C=x.finishLeftRegions(w,T,null);C.Onext===b?x.connectRightVertex(w,M,C):x.addRightEdges(w,M,C.Onext,b,b,!0)},x.addSentinel=function(w,y,f,M){var T=new D,b=w.mesh.makeEdge();b.Org.s=f,b.Org.t=M,b.Dst.s=y,b.Dst.t=M,w.event=b.Dst,T.eUp=b,T.windingNumber=0,T.inside=!1,T.fixUpperEdge=!1,T.sentinel=!0,T.dirty=!1,T.nodeUp=w.dict.insert(T)},x.initEdgeDict=function(w){w.dict=new g(w,x.edgeLeq);var y=w.bmax[0]-w.bmin[0],f=w.bmax[1]-w.bmin[1],M=w.bmin[0]-y,T=w.bmax[0]+y,b=w.bmin[1]-f,C=w.bmax[1]+f;x.addSentinel(w,M,T,b),x.addSentinel(w,M,T,C)},x.doneEdgeDict=function(w){for(var y,f=0;(y=w.dict.min().key)!==null;)y.sentinel||(a(y.fixUpperEdge),a(++f===1)),a(y.windingNumber===0),x.deleteRegion(w,y)},x.removeDegenerateEdges=function(w){var y,f,M,T=w.mesh.eHead;for(y=T.next;y!==T;y=f)f=y.next,M=y.Lnext,o.vertEq(y.Org,y.Dst)&&y.Lnext.Lnext!==y&&(x.spliceMergeVertices(w,M,y),w.mesh.delete(y),y=M,M=y.Lnext),M.Lnext===y&&(M!==y&&((M===f||M===f.Sym)&&(f=f.next),w.mesh.delete(M)),(y===f||y===f.Sym)&&(f=f.next),w.mesh.delete(y))},x.initPriorityQ=function(w){var y,f,M,T=0;for(M=w.mesh.vHead,f=M.next;f!==M;f=f.next)T++;for(T+=8,y=w.pq=new I(T,o.vertLeq),M=w.mesh.vHead,f=M.next;f!==M;f=f.next)f.pqHandle=y.insert(f);return f!==M?!1:(y.init(),!0)},x.donePriorityQ=function(w){w.pq=null},x.removeDegenerateFaces=function(w,y){var f,M,T;for(f=y.fHead.next;f!==y.fHead;f=M)M=f.next,T=f.anEdge,a(T.Lnext!==T),T.Lnext.Lnext===T&&(x.addWinding(T.Onext,T),w.mesh.delete(T));return!0},x.computeInterior=function(w){var y,f;if(x.removeDegenerateEdges(w),!x.initPriorityQ(w))return!1;for(x.initEdgeDict(w);(y=w.pq.extractMin())!==null;){for(;f=w.pq.min(),!(f===null||!o.vertEq(f,y));)f=w.pq.extractMin(),x.spliceMergeVertices(w,y.anEdge,f.anEdge);x.sweepEvent(w,y)}return w.event=w.dict.min().key.eUp.Org,x.debugEvent(w),x.doneEdgeDict(w),x.donePriorityQ(w),x.removeDegenerateFaces(w,w.mesh)?(w.mesh.check(),!0):!1};function j(){this.mesh=null,this.normal=[0,0,0],this.sUnit=[0,0,0],this.tUnit=[0,0,0],this.bmin=[0,0],this.bmax=[0,0],this.windingRule=s.WINDING_ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}j.prototype={dot_:function(y,f){return y[0]*f[0]+y[1]*f[1]+y[2]*f[2]},normalize_:function(y){var f=y[0]*y[0]+y[1]*y[1]+y[2]*y[2];a(f>0),f=Math.sqrt(f),y[0]/=f,y[1]/=f,y[2]/=f},longAxis_:function(y){var f=0;return Math.abs(y[1])>Math.abs(y[0])&&(f=1),Math.abs(y[2])>Math.abs(y[f])&&(f=2),f},computeNormal_:function(y){var f,M,T,b,C,P,E=[0,0,0],O=[0,0,0],V=[0,0,0],N=[0,0,0],A=[0,0,0],k=[null,null,null],U=[null,null,null],Z=this.mesh.vHead,Q;for(f=Z.next,Q=0;Q<3;++Q)b=f.coords[Q],O[Q]=b,U[Q]=f,E[Q]=b,k[Q]=f;for(f=Z.next;f!==Z;f=f.next)for(Q=0;Q<3;++Q)b=f.coords[Q],b<O[Q]&&(O[Q]=b,U[Q]=f),b>E[Q]&&(E[Q]=b,k[Q]=f);if(Q=0,E[1]-O[1]>E[0]-O[0]&&(Q=1),E[2]-O[2]>E[Q]-O[Q]&&(Q=2),O[Q]>=E[Q]){y[0]=0,y[1]=0,y[2]=1;return}for(P=0,M=U[Q],T=k[Q],V[0]=M.coords[0]-T.coords[0],V[1]=M.coords[1]-T.coords[1],V[2]=M.coords[2]-T.coords[2],f=Z.next;f!==Z;f=f.next)N[0]=f.coords[0]-T.coords[0],N[1]=f.coords[1]-T.coords[1],N[2]=f.coords[2]-T.coords[2],A[0]=V[1]*N[2]-V[2]*N[1],A[1]=V[2]*N[0]-V[0]*N[2],A[2]=V[0]*N[1]-V[1]*N[0],C=A[0]*A[0]+A[1]*A[1]+A[2]*A[2],C>P&&(P=C,y[0]=A[0],y[1]=A[1],y[2]=A[2]);P<=0&&(y[0]=y[1]=y[2]=0,y[this.longAxis_(V)]=1)},checkOrientation_:function(){var y,f,M=this.mesh.fHead,T,b=this.mesh.vHead,C;for(y=0,f=M.next;f!==M;f=f.next)if(C=f.anEdge,!(C.winding<=0))do y+=(C.Org.s-C.Dst.s)*(C.Org.t+C.Dst.t),C=C.Lnext;while(C!==f.anEdge);if(y<0){for(T=b.next;T!==b;T=T.next)T.t=-T.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},projectPolygon_:function(){var y,f=this.mesh.vHead,M=[0,0,0],T,b,C,P,E=!1;for(M[0]=this.normal[0],M[1]=this.normal[1],M[2]=this.normal[2],M[0]===0&&M[1]===0&&M[2]===0&&(this.computeNormal_(M),E=!0),T=this.sUnit,b=this.tUnit,C=this.longAxis_(M),T[C]=0,T[(C+1)%3]=1,T[(C+2)%3]=0,b[C]=0,b[(C+1)%3]=0,b[(C+2)%3]=M[C]>0?1:-1,y=f.next;y!==f;y=y.next)y.s=this.dot_(y.coords,T),y.t=this.dot_(y.coords,b);for(E&&this.checkOrientation_(),P=!0,y=f.next;y!==f;y=y.next)P?(this.bmin[0]=this.bmax[0]=y.s,this.bmin[1]=this.bmax[1]=y.t,P=!1):(y.s<this.bmin[0]&&(this.bmin[0]=y.s),y.s>this.bmax[0]&&(this.bmax[0]=y.s),y.t<this.bmin[1]&&(this.bmin[1]=y.t),y.t>this.bmax[1]&&(this.bmax[1]=y.t))},addWinding_:function(y,f){y.winding+=f.winding,y.Sym.winding+=f.Sym.winding},tessellateMonoRegion_:function(y,f){var M,T;for(M=f.anEdge,a(M.Lnext!==M&&M.Lnext.Lnext!==M);o.vertLeq(M.Dst,M.Org);M=M.Lprev);for(;o.vertLeq(M.Org,M.Dst);M=M.Lnext);for(T=M.Lprev;M.Lnext!==T;)if(o.vertLeq(M.Dst,T.Org)){for(;T.Lnext!==M&&(o.edgeGoesLeft(T.Lnext)||o.edgeSign(T.Org,T.Dst,T.Lnext.Dst)<=0);){var b=y.connect(T.Lnext,T);T=b.Sym}T=T.Lprev}else{for(;T.Lnext!==M&&(o.edgeGoesRight(M.Lprev)||o.edgeSign(M.Dst,M.Org,M.Lprev.Org)>=0);){var b=y.connect(M,M.Lprev);M=b.Sym}M=M.Lnext}for(a(T.Lnext!==M);T.Lnext.Lnext!==M;){var b=y.connect(T.Lnext,T);T=b.Sym}return!0},tessellateInterior_:function(y){var f,M;for(f=y.fHead.next;f!==y.fHead;f=M)if(M=f.next,f.inside&&!this.tessellateMonoRegion_(y,f))return!1;return!0},discardExterior_:function(y){var f,M;for(f=y.fHead.next;f!==y.fHead;f=M)M=f.next,f.inside||y.zapFace(f)},setWindingNumber_:function(y,f,M){var T,b;for(T=y.eHead.next;T!==y.eHead;T=b)b=T.next,T.Rface.inside!==T.Lface.inside?T.winding=T.Lface.inside?f:-f:M?y.delete(T):T.winding=0},getNeighbourFace_:function(y){return!y.Rface||!y.Rface.inside?-1:y.Rface.n},outputPolymesh_:function(y,f,M,T){var b,C,P,E=0,O=0,V,N;for(M>3&&y.mergeConvexFaces(M),b=y.vHead.next;b!==y.vHead;b=b.next)b.n=-1;for(C=y.fHead.next;C!==y.fHead;C=C.next)if(C.n=-1,!!C.inside){P=C.anEdge,V=0;do b=P.Org,b.n===-1&&(b.n=O,O++),V++,P=P.Lnext;while(P!==C.anEdge);a(V<=M),C.n=E,++E}for(this.elementCount=E,f===s.CONNECTED_POLYGONS&&(E*=2),this.elements=[],this.elements.length=E*M,this.vertexCount=O,this.vertices=[],this.vertices.length=O*T,this.vertexIndices=[],this.vertexIndices.length=O,b=y.vHead.next;b!==y.vHead;b=b.next)if(b.n!==-1){var A=b.n*T;this.vertices[A+0]=b.coords[0],this.vertices[A+1]=b.coords[1],T>2&&(this.vertices[A+2]=b.coords[2]),this.vertexIndices[b.n]=b.idx}var k=0;for(C=y.fHead.next;C!==y.fHead;C=C.next)if(C.inside){P=C.anEdge,V=0;do b=P.Org,this.elements[k++]=b.n,V++,P=P.Lnext;while(P!==C.anEdge);for(N=V;N<M;++N)this.elements[k++]=-1;if(f===s.CONNECTED_POLYGONS){P=C.anEdge;do this.elements[k++]=this.getNeighbourFace_(P),P=P.Lnext;while(P!==C.anEdge);for(N=V;N<M;++N)this.elements[k++]=-1}}},outputContours_:function(y,f){var M,T,b,C=0,P=0;for(this.vertexCount=0,this.elementCount=0,M=y.fHead.next;M!==y.fHead;M=M.next)if(M.inside){b=T=M.anEdge;do this.vertexCount++,T=T.Lnext;while(T!==b);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*f,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var E=0,O=0,V=0;for(C=0,M=y.fHead.next;M!==y.fHead;M=M.next)if(M.inside){P=0,b=T=M.anEdge;do this.vertices[E++]=T.Org.coords[0],this.vertices[E++]=T.Org.coords[1],f>2&&(this.vertices[E++]=T.Org.coords[2]),this.vertexIndices[O++]=T.Org.idx,P++,T=T.Lnext;while(T!==b);this.elements[V++]=C,this.elements[V++]=P,C+=P}},addContour:function(y,f){var M,T;for(this.mesh===null&&(this.mesh=new h),y<2&&(y=2),y>3&&(y=3),M=null,T=0;T<f.length;T+=y)M===null?(M=this.mesh.makeEdge(),this.mesh.splice(M,M.Sym)):(this.mesh.splitEdge(M),M=M.Lnext),M.Org.coords[0]=f[T+0],M.Org.coords[1]=f[T+1],y>2?M.Org.coords[2]=f[T+2]:M.Org.coords[2]=0,M.Org.idx=this.vertexIndexCounter++,M.winding=1,M.Sym.winding=-1},tesselate:function(y,f,M,T,b){if(this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,b&&(this.normal[0]=b[0],this.normal[1]=b[1],this.normal[2]=b[2]),this.windingRule=y,T<2&&(T=2),T>3&&(T=3),!this.mesh)return!1;this.projectPolygon_(),x.computeInterior(this);var C=this.mesh;return f===s.BOUNDARY_CONTOURS?this.setWindingNumber_(C,1,!0):this.tessellateInterior_(C),C.check(),f===s.BOUNDARY_CONTOURS?this.outputContours_(C,T):this.outputPolymesh_(C,f,M,T),!0}}},function(e,r){e.exports=s;var n=Object.prototype.hasOwnProperty;function s(){for(var o={},a=0;a<arguments.length;a++){var c=arguments[a];for(var l in c)n.call(c,l)&&(o[l]=c[l])}return o}},function(e,r,n){n.r(r),n.d(r,"createShaders",function(){return d}),n.d(r,"applyShader",function(){return g}),n.d(r,"createCloudShaders",function(){return v}),n.d(r,"applyCloudShader",function(){return I});var s=n(19),o=n.n(s),a=n(83),c=n(84),l=n(85),u=n(86);n(1).glMatrix.setMatrixArrayType(Array);var h=Symbol("shaders");function d(D){D[h]=[];for(var x=0;x<16;x++){var j=[],w=!!(x&1),y=!!(x&2),f=!!(x&4),M=!!(x&8);w&&j.push("#define TEXTURE 1"),y&&j.push("#define FILTER 1"),f&&j.push("#define GRADIENT 1"),M&&j.push("#define CLIPPATH 1");var T="".concat(j.join(`
42
+ `),`
43
+ `),b=[];w&&b.push("uniform sampler2D u_texSampler;"),M&&b.push("uniform sampler2D u_clipSampler;"),D[h][x]=[T+b.join(`
44
+ `)+c.default,T+a.default]}}function g(D){var x=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},j=x.hasTexture,w=j===void 0?!1:j,y=x.hasFilter,f=y===void 0?!1:y,M=x.hasGradient,T=M===void 0?!1:M,b=x.hasClipPath,C=b===void 0?!1:b,P=w|f<<1|T<<2|C<<3,E=D[h][P];Array.isArray(E)&&(E=D.createProgram.apply(D,o()(E)),D[h][P]=E),D.program!==E&&D.useProgram(E,{a_color:{type:"UNSIGNED_BYTE",normalize:!0}})}var p=[];function v(D){for(var x=0;x<64;x++){var j=[],w=!!(x&1),y=!!(x&2),f=!!(x&4),M=!!(x&8),T=!!(x&16),b=!!(x&32);w&&j.push("#define TEXTURE 1"),y&&j.push("#define FILTER 1"),f&&j.push("#define GRADIENT 1"),M&&j.push("#define CLOUDCOLOR 1"),T&&j.push("#define CLOUDFILTER 1"),b&&j.push("#define CLIPPATH 1");var C="".concat(j.join(`
45
+ `),`
46
+ `),P=[];if(w){P.push("uniform sampler2D u_texSampler;");for(var E=0;E<12;E++)P.push("uniform sampler2D u_texFrame".concat(E,";"))}b&&P.push("uniform sampler2D u_clipSampler;"),p[x]=[C+P.join(`
47
+ `)+u.default,C+l.default]}}function I(D){var x=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},j=x.hasTexture,w=j===void 0?!1:j,y=x.hasFilter,f=y===void 0?!1:y,M=x.hasGradient,T=M===void 0?!1:M,b=x.hasCloudColor,C=b===void 0?!1:b,P=x.hasCloudFilter,E=P===void 0?!1:P,O=x.hasClipPath,V=O===void 0?!1:O,N=w|f<<1|T<<2|C<<3|E<<4|V<<5,A=p[N];Array.isArray(A)&&(A=D.createProgram.apply(D,o()(A)),p[N]=A),D.program!==A&&D.useProgram(A,{a_color:{type:"UNSIGNED_BYTE",normalize:!0},a_fillCloudColor:{type:"UNSIGNED_BYTE",normalize:!0},a_strokeCloudColor:{type:"UNSIGNED_BYTE",normalize:!0},a_frameIndex:{type:"UNSIGNED_BYTE",normalize:!1}})}},function(e,r,n){n.r(r),r.default=`attribute vec3 a_vertexPosition;
48
+ attribute vec4 a_color;
49
+ varying vec4 vColor;
50
+ varying float flagBackground;
51
+ uniform vec2 u_resolution;
52
+ uniform mat3 viewMatrix;
53
+ uniform mat3 projectionMatrix;
54
+
55
+ #ifdef TEXTURE
56
+ attribute vec3 a_vertexTextureCoord;
57
+ varying vec3 vTextureCoord;
58
+ attribute vec4 a_sourceRect;
59
+ varying vec4 vSourceRect;
60
+ #endif
61
+
62
+ #ifdef CLIPPATH
63
+ attribute vec2 a_clipUV;
64
+ varying vec2 vClipUV;
65
+ #endif
66
+
67
+ #ifdef GRADIENT
68
+ uniform float u_radialGradientVector[6];
69
+ varying vec3 vGradientVector1;
70
+ varying vec3 vGradientVector2;
71
+ #endif
72
+
73
+ void main() {
74
+ gl_PointSize = 1.0;
75
+
76
+ vec3 pos = projectionMatrix * viewMatrix * vec3(a_vertexPosition.xy, 1.0);
77
+ gl_Position = vec4(pos.xy, 1.0, 1.0);
78
+
79
+ #ifdef GRADIENT
80
+ vec3 vg1 = viewMatrix * vec3(u_radialGradientVector[0], u_radialGradientVector[1], 1.0);
81
+ vec3 vg2 = viewMatrix * vec3(u_radialGradientVector[3], u_radialGradientVector[4], 1.0);
82
+ float h = u_resolution.y;
83
+ vg1.y = h - vg1.y;
84
+ vg2.y = h - vg2.y;
85
+ vGradientVector1 = vec3(vg1.xy, u_radialGradientVector[2]);
86
+ vGradientVector2 = vec3(vg2.xy, u_radialGradientVector[5]);
87
+ #endif
88
+
89
+ flagBackground = a_vertexPosition.z;
90
+ vColor = a_color;
91
+
92
+ #ifdef TEXTURE
93
+ vTextureCoord = a_vertexTextureCoord;
94
+ vSourceRect = a_sourceRect;
95
+ #endif
96
+
97
+ #ifdef CLIPPATH
98
+ vClipUV = a_clipUV;
99
+ #endif
100
+ }`},function(e,r,n){n.r(r),r.default=`precision mediump float;
101
+
102
+ varying vec4 vColor;
103
+ varying float flagBackground;
104
+
105
+ #ifdef TEXTURE
106
+ varying vec3 vTextureCoord;
107
+ varying vec4 vSourceRect;
108
+ #endif
109
+
110
+ #ifdef CLIPPATH
111
+ varying vec2 vClipUV;
112
+ #endif
113
+
114
+ #ifdef FILTER
115
+ uniform int u_filterFlag;
116
+ uniform float u_colorMatrix[20];
117
+ #endif
118
+
119
+ #ifdef GRADIENT
120
+ varying vec3 vGradientVector1;
121
+ varying vec3 vGradientVector2;
122
+ uniform float u_colorSteps[40];
123
+ uniform int u_gradientType;
124
+ // uniform float u_radialGradientVector[6];
125
+
126
+ void gradient(inout vec4 color, vec3 gv1, vec3 gv2, float colorSteps[40]) {
127
+ float t;
128
+ // center circle radius
129
+ float cr = gv1.z;
130
+ // focal circle radius
131
+ float fr = gv2.z;
132
+
133
+ if(cr > 0.0 || fr > 0.0) {
134
+ // radial gradient
135
+ vec2 center = gv1.xy;
136
+ vec2 focal = gv2.xy;
137
+ float x = focal.x - gl_FragCoord.x;
138
+ float y = focal.y - gl_FragCoord.y;
139
+ float dx = focal.x - center.x;
140
+ float dy = focal.y - center.y;
141
+ float dr = cr - fr;
142
+ float a = dx * dx + dy * dy - dr * dr;
143
+ float b = -2.0 * (y * dy + x * dx + fr * dr);
144
+ float c = x * x + y * y - fr * fr;
145
+ t = 1.0 - 0.5 * (1.0 / a) * (-b + sqrt(b * b - 4.0 * a * c));
146
+ } else {
147
+ // linear gradient
148
+ vec2 v1 = gl_FragCoord.xy - gv1.xy;
149
+ vec2 v2 = gv2.xy - gv1.xy;
150
+ t = (v1.x * v2.x + v1.y * v2.y) / (v2.x * v2.x + v2.y * v2.y);
151
+ }
152
+
153
+ vec4 colors[8];
154
+ colors[0] = vec4(colorSteps[1], colorSteps[2], colorSteps[3], colorSteps[4]);
155
+ colors[1] = vec4(colorSteps[6], colorSteps[7], colorSteps[8], colorSteps[9]);
156
+ colors[2] = vec4(colorSteps[11], colorSteps[12], colorSteps[13], colorSteps[14]);
157
+ colors[3] = vec4(colorSteps[16], colorSteps[17], colorSteps[18], colorSteps[19]);
158
+ colors[4] = vec4(colorSteps[21], colorSteps[22], colorSteps[23], colorSteps[24]);
159
+ colors[5] = vec4(colorSteps[26], colorSteps[27], colorSteps[28], colorSteps[29]);
160
+ colors[6] = vec4(colorSteps[31], colorSteps[32], colorSteps[33], colorSteps[34]);
161
+ colors[7] = vec4(colorSteps[36], colorSteps[37], colorSteps[38], colorSteps[39]);
162
+
163
+ float steps[8];
164
+ steps[0] = colorSteps[0];
165
+ steps[1] = colorSteps[5];
166
+ steps[2] = colorSteps[10];
167
+ steps[3] = colorSteps[15];
168
+ steps[4] = colorSteps[20];
169
+ steps[5] = colorSteps[25];
170
+ steps[6] = colorSteps[30];
171
+ steps[7] = colorSteps[35];
172
+
173
+ color = colors[0];
174
+ for (int i = 1; i < 8; i++) {
175
+ if (steps[i] < 0.0 || steps[i] > 1.0) {
176
+ break;
177
+ }
178
+ if(steps[i] == steps[i - 1]) {
179
+ color = colors[i];
180
+ } else {
181
+ color = mix(color, colors[i], clamp((t - steps[i - 1]) / (steps[i] - steps[i - 1]), 0.0, 1.0));
182
+ }
183
+ if (steps[i] >= t) {
184
+ break;
185
+ }
186
+ }
187
+ }
188
+ #endif
189
+
190
+ #ifdef FILTER
191
+ void transformColor(inout vec4 color, in float colorMatrix[20]) {
192
+ float r = color.r, g = color.g, b = color.b, a = color.a;
193
+ color[0] = colorMatrix[0] * r + colorMatrix[1] * g + colorMatrix[2] * b + colorMatrix[3] * a + colorMatrix[4];
194
+ color[1] = colorMatrix[5] * r + colorMatrix[6] * g + colorMatrix[7] * b + colorMatrix[8] * a + colorMatrix[9];
195
+ color[2] = colorMatrix[10] * r + colorMatrix[11] * g + colorMatrix[12] * b + colorMatrix[13] * a + colorMatrix[14];
196
+ color[3] = colorMatrix[15] * r + colorMatrix[16] * g + colorMatrix[17] * b + colorMatrix[18] * a + colorMatrix[19];
197
+ }
198
+ #endif
199
+
200
+ void main() {
201
+ vec4 color = vColor;
202
+ float opacity = abs(flagBackground);
203
+
204
+ #ifdef GRADIENT
205
+ if(u_gradientType > 0 && flagBackground > 0.0 || u_gradientType == 0 && flagBackground <= 0.0) {
206
+ gradient(color, vGradientVector1, vGradientVector2, u_colorSteps);
207
+ }
208
+ #endif
209
+
210
+ if(opacity < 1.0) {
211
+ color.a *= opacity;
212
+ }
213
+
214
+ #ifdef TEXTURE
215
+ if(flagBackground > 0.0) {
216
+ vec3 texCoord = vTextureCoord;
217
+
218
+ if(texCoord.z == 1.0) {
219
+ texCoord = fract(texCoord);
220
+ }
221
+
222
+ if(texCoord.x <= 1.0 && texCoord.x >= 0.0
223
+ && texCoord.y <= 1.0 && texCoord.y >= 0.0) {
224
+ if(vSourceRect.z > 0.0) {
225
+ texCoord.x = vSourceRect.x + texCoord.x * vSourceRect.z;
226
+ texCoord.y = 1.0 - (vSourceRect.y + (1.0 - texCoord.y) * vSourceRect.w);
227
+ }
228
+ vec4 texColor = texture2D(u_texSampler, texCoord.xy);
229
+ float alpha = texColor.a;
230
+ if(opacity < 1.0) {
231
+ texColor.a *= opacity;
232
+ alpha *= mix(0.465, 1.0, opacity);
233
+ }
234
+ // color = mix(color, texColor, texColor.a);
235
+ color.rgb = mix(color.rgb, texColor.rgb, alpha);
236
+ // color.rgb = mix(texColor.rgb, color.rgb, color.a);
237
+ color.rgb = mix(texColor.rgb, color.rgb, clamp(color.a / max(0.0001, texColor.a), 0.0, 1.0));
238
+ color.a = texColor.a + (1.0 - texColor.a) * color.a;
239
+ }
240
+ }
241
+ #endif
242
+
243
+ #ifdef FILTER
244
+ if(u_filterFlag > 0) {
245
+ transformColor(color, u_colorMatrix);
246
+ }
247
+ #endif
248
+
249
+ #ifdef CLIPPATH
250
+ float clip = texture2D(u_clipSampler, vClipUV).r;
251
+ color *= clip;
252
+ #endif
253
+
254
+ gl_FragColor = color;
255
+ }`},function(e,r,n){n.r(r),r.default=`attribute vec3 a_vertexPosition;
256
+ attribute vec4 a_color;
257
+ varying vec4 vColor;
258
+ varying float flagBackground;
259
+ attribute vec3 a_transform0;
260
+ attribute vec3 a_transform1;
261
+ uniform vec2 u_resolution;
262
+ uniform mat3 viewMatrix;
263
+ uniform mat3 projectionMatrix;
264
+
265
+ #ifdef TEXTURE
266
+ attribute vec3 a_vertexTextureCoord;
267
+ varying vec3 vTextureCoord;
268
+ attribute float a_frameIndex;
269
+ varying float frameIndex;
270
+ attribute vec4 a_sourceRect;
271
+ varying vec4 vSourceRect;
272
+ #endif
273
+
274
+ #ifdef CLIPPATH
275
+ attribute vec2 a_clipUV;
276
+ varying vec2 vClipUV;
277
+ #endif
278
+
279
+ #ifdef CLOUDFILTER
280
+ attribute vec4 a_colorCloud0;
281
+ attribute vec4 a_colorCloud1;
282
+ attribute vec4 a_colorCloud2;
283
+ attribute vec4 a_colorCloud3;
284
+ attribute vec4 a_colorCloud4;
285
+ varying vec4 colorCloud0;
286
+ varying vec4 colorCloud1;
287
+ varying vec4 colorCloud2;
288
+ varying vec4 colorCloud3;
289
+ varying vec4 colorCloud4;
290
+ #endif
291
+
292
+ #ifdef CLOUDCOLOR
293
+ attribute vec4 a_fillCloudColor;
294
+ attribute vec4 a_strokeCloudColor;
295
+ #endif
296
+
297
+ #ifdef GRADIENT
298
+ uniform float u_radialGradientVector[6];
299
+ varying vec3 vGradientVector1;
300
+ varying vec3 vGradientVector2;
301
+ #endif
302
+
303
+ void main() {
304
+ gl_PointSize = 1.0;
305
+
306
+ mat3 modelMatrix = mat3(
307
+ a_transform0.x, a_transform1.x, 0,
308
+ a_transform0.y, a_transform1.y, 0,
309
+ a_transform0.z, a_transform1.z, 1
310
+ );
311
+
312
+ vec3 pos = projectionMatrix * viewMatrix * modelMatrix * vec3(a_vertexPosition.xy, 1.0);
313
+ gl_Position = vec4(pos.xy, 1.0, 1.0);
314
+
315
+ #ifdef GRADIENT
316
+ vec3 vg1 = viewMatrix * vec3(u_radialGradientVector[0], u_radialGradientVector[1], 1.0);
317
+ vec3 vg2 = viewMatrix * vec3(u_radialGradientVector[3], u_radialGradientVector[4], 1.0);
318
+ float h = u_resolution.y;
319
+ vg1.y = h - vg1.y;
320
+ vg2.y = h - vg2.y;
321
+ vGradientVector1 = vec3(vg1.xy, u_radialGradientVector[2]);
322
+ vGradientVector2 = vec3(vg2.xy, u_radialGradientVector[5]);
323
+ #endif
324
+
325
+ flagBackground = a_vertexPosition.z;
326
+
327
+ #ifdef CLOUDCOLOR
328
+ if(flagBackground > 0.0) {
329
+ vColor = mix(a_color, a_fillCloudColor, a_fillCloudColor.a);
330
+ } else {
331
+ vColor = mix(a_color, a_strokeCloudColor, a_strokeCloudColor.a);
332
+ }
333
+ #else
334
+ vColor = a_color;
335
+ #endif
336
+
337
+ #ifdef TEXTURE
338
+ vTextureCoord = a_vertexTextureCoord;
339
+ frameIndex = a_frameIndex;
340
+ vSourceRect = a_sourceRect;
341
+ #endif
342
+
343
+ #ifdef CLIPPATH
344
+ vClipUV = a_clipUV;
345
+ #endif
346
+
347
+ #ifdef CLOUDFILTER
348
+ colorCloud0 = a_colorCloud0;
349
+ colorCloud1 = a_colorCloud1;
350
+ colorCloud2 = a_colorCloud2;
351
+ colorCloud3 = a_colorCloud3;
352
+ colorCloud4 = a_colorCloud4;
353
+ #endif
354
+ }`},function(e,r,n){n.r(r),r.default=`precision mediump float;
355
+
356
+ varying vec4 vColor;
357
+ varying float flagBackground;
358
+
359
+ #ifdef TEXTURE
360
+ varying float frameIndex;
361
+ varying vec3 vTextureCoord;
362
+ varying vec4 vSourceRect;
363
+ #endif
364
+
365
+ #ifdef CLIPPATH
366
+ varying vec2 vClipUV;
367
+ #endif
368
+
369
+ #ifdef FILTER
370
+ uniform int u_filterFlag;
371
+ uniform float u_colorMatrix[20];
372
+ #endif
373
+
374
+ #ifdef CLOUDFILTER
375
+ varying vec4 colorCloud0;
376
+ varying vec4 colorCloud1;
377
+ varying vec4 colorCloud2;
378
+ varying vec4 colorCloud3;
379
+ varying vec4 colorCloud4;
380
+ #endif
381
+
382
+ #ifdef GRADIENT
383
+ varying vec3 vGradientVector1;
384
+ varying vec3 vGradientVector2;
385
+ uniform float u_colorSteps[40];
386
+ uniform int u_gradientType;
387
+
388
+ void gradient(inout vec4 color, vec3 gv1, vec3 gv2, float colorSteps[40]) {
389
+ float t;
390
+ // center circle radius
391
+ float cr = gv1.z;
392
+ // focal circle radius
393
+ float fr = gv2.z;
394
+
395
+ if(cr > 0.0 || fr > 0.0) {
396
+ // radial gradient
397
+ vec2 center = gv1.xy;
398
+ vec2 focal = gv2.xy;
399
+ float x = focal.x - gl_FragCoord.x;
400
+ float y = focal.y - gl_FragCoord.y;
401
+ float dx = focal.x - center.x;
402
+ float dy = focal.y - center.y;
403
+ float dr = cr - fr;
404
+ float a = dx * dx + dy * dy - dr * dr;
405
+ float b = -2.0 * (y * dy + x * dx + fr * dr);
406
+ float c = x * x + y * y - fr * fr;
407
+ t = 1.0 - 0.5 * (1.0 / a) * (-b + sqrt(b * b - 4.0 * a * c));
408
+ } else {
409
+ // linear gradient
410
+ vec2 v1 = gl_FragCoord.xy - gv1.xy;
411
+ vec2 v2 = gv2.xy - gv1.xy;
412
+ t = (v1.x * v2.x + v1.y * v2.y) / (v2.x * v2.x + v2.y * v2.y);
413
+ }
414
+
415
+ vec4 colors[8];
416
+ colors[0] = vec4(colorSteps[1], colorSteps[2], colorSteps[3], colorSteps[4]);
417
+ colors[1] = vec4(colorSteps[6], colorSteps[7], colorSteps[8], colorSteps[9]);
418
+ colors[2] = vec4(colorSteps[11], colorSteps[12], colorSteps[13], colorSteps[14]);
419
+ colors[3] = vec4(colorSteps[16], colorSteps[17], colorSteps[18], colorSteps[19]);
420
+ colors[4] = vec4(colorSteps[21], colorSteps[22], colorSteps[23], colorSteps[24]);
421
+ colors[5] = vec4(colorSteps[26], colorSteps[27], colorSteps[28], colorSteps[29]);
422
+ colors[6] = vec4(colorSteps[31], colorSteps[32], colorSteps[33], colorSteps[34]);
423
+ colors[7] = vec4(colorSteps[36], colorSteps[37], colorSteps[38], colorSteps[39]);
424
+
425
+ float steps[8];
426
+ steps[0] = colorSteps[0];
427
+ steps[1] = colorSteps[5];
428
+ steps[2] = colorSteps[10];
429
+ steps[3] = colorSteps[15];
430
+ steps[4] = colorSteps[20];
431
+ steps[5] = colorSteps[25];
432
+ steps[6] = colorSteps[30];
433
+ steps[7] = colorSteps[35];
434
+
435
+ color = colors[0];
436
+ for (int i = 1; i < 8; i++) {
437
+ if (steps[i] < 0.0 || steps[i] > 1.0) {
438
+ break;
439
+ }
440
+ if(steps[i] == steps[i - 1]) {
441
+ color = colors[i];
442
+ } else {
443
+ color = mix(color, colors[i], clamp((t - steps[i - 1]) / (steps[i] - steps[i - 1]), 0.0, 1.0));
444
+ }
445
+ if (steps[i] >= t) {
446
+ break;
447
+ }
448
+ }
449
+ }
450
+ #endif
451
+
452
+ void transformColor(inout vec4 color, in float colorMatrix[20]) {
453
+ float r = color.r, g = color.g, b = color.b, a = color.a;
454
+ color[0] = colorMatrix[0] * r + colorMatrix[1] * g + colorMatrix[2] * b + colorMatrix[3] * a + colorMatrix[4];
455
+ color[1] = colorMatrix[5] * r + colorMatrix[6] * g + colorMatrix[7] * b + colorMatrix[8] * a + colorMatrix[9];
456
+ color[2] = colorMatrix[10] * r + colorMatrix[11] * g + colorMatrix[12] * b + colorMatrix[13] * a + colorMatrix[14];
457
+ color[3] = colorMatrix[15] * r + colorMatrix[16] * g + colorMatrix[17] * b + colorMatrix[18] * a + colorMatrix[19];
458
+ }
459
+
460
+ #ifdef CLOUDFILTER
461
+ void buildCloudColor(inout float colorCloudMatrix[20]) {
462
+ colorCloudMatrix[0] = colorCloud0[0];
463
+ colorCloudMatrix[1] = colorCloud1[0];
464
+ colorCloudMatrix[2] = colorCloud2[0];
465
+ colorCloudMatrix[3] = colorCloud3[0];
466
+ colorCloudMatrix[4] = colorCloud4[0];
467
+
468
+ colorCloudMatrix[5] = colorCloud0[1];
469
+ colorCloudMatrix[6] = colorCloud1[1];
470
+ colorCloudMatrix[7] = colorCloud2[1];
471
+ colorCloudMatrix[8] = colorCloud3[1];
472
+ colorCloudMatrix[9] = colorCloud4[1];
473
+
474
+ colorCloudMatrix[10] = colorCloud0[2];
475
+ colorCloudMatrix[11] = colorCloud1[2];
476
+ colorCloudMatrix[12] = colorCloud2[2];
477
+ colorCloudMatrix[13] = colorCloud3[2];
478
+ colorCloudMatrix[14] = colorCloud4[2];
479
+
480
+ colorCloudMatrix[15] = colorCloud0[3];
481
+ colorCloudMatrix[16] = colorCloud1[3];
482
+ colorCloudMatrix[17] = colorCloud2[3];
483
+ colorCloudMatrix[18] = colorCloud3[3];
484
+ colorCloudMatrix[19] = colorCloud4[3];
485
+ }
486
+ #endif
487
+
488
+ void main() {
489
+ vec4 color = vColor;
490
+ float opacity = abs(flagBackground);
491
+
492
+ #ifdef GRADIENT
493
+ if(u_gradientType > 0 && flagBackground > 0.0 || u_gradientType == 0 && flagBackground <= 0.0) {
494
+ gradient(color, vGradientVector1, vGradientVector2, u_colorSteps);
495
+ }
496
+ #endif
497
+
498
+ if(opacity < 1.0) {
499
+ color.a *= opacity;
500
+ }
501
+
502
+ #ifdef TEXTURE
503
+ if(flagBackground > 0.0) {
504
+ vec3 texCoord = vTextureCoord;
505
+
506
+ if(texCoord.z == 1.0) {
507
+ texCoord = fract(texCoord);
508
+ }
509
+
510
+ if(texCoord.x <= 1.0 && texCoord.x >= 0.0
511
+ && texCoord.y <= 1.0 && texCoord.y >= 0.0) {
512
+ if(vSourceRect.z > 0.0) {
513
+ texCoord.x = vSourceRect.x + texCoord.x * vSourceRect.z;
514
+ texCoord.y = 1.0 - (vSourceRect.y + (1.0 - texCoord.y) * vSourceRect.w);
515
+ }
516
+ if(frameIndex < 0.0) {
517
+ vec4 texColor = texture2D(u_texSampler, texCoord.xy);
518
+ color = mix(color, texColor, texColor.a);
519
+ } else {
520
+ int index = int(floor(clamp(0.0, 11.0, frameIndex)));
521
+ vec4 texColor;
522
+ if(index == 0) texColor = texture2D(u_texFrame0, texCoord.xy);
523
+ else if(index == 1) texColor = texture2D(u_texFrame1, texCoord.xy);
524
+ else if(index == 2) texColor = texture2D(u_texFrame2, texCoord.xy);
525
+ else if(index == 3) texColor = texture2D(u_texFrame3, texCoord.xy);
526
+ else if(index == 4) texColor = texture2D(u_texFrame4, texCoord.xy);
527
+ else if(index == 5) texColor = texture2D(u_texFrame5, texCoord.xy);
528
+ else if(index == 6) texColor = texture2D(u_texFrame6, texCoord.xy);
529
+ else if(index == 7) texColor = texture2D(u_texFrame7, texCoord.xy);
530
+ else if(index == 8) texColor = texture2D(u_texFrame8, texCoord.xy);
531
+ else if(index == 9) texColor = texture2D(u_texFrame9, texCoord.xy);
532
+ else if(index == 10) texColor = texture2D(u_texFrame10, texCoord.xy);
533
+ else texColor = texture2D(u_texFrame11, texCoord.xy);
534
+ float alpha = texColor.a;
535
+ if(opacity < 1.0) {
536
+ texColor.a *= opacity;
537
+ alpha *= mix(0.465, 1.0, opacity);
538
+ }
539
+ // color = mix(color, texColor, texColor.a);
540
+ color.rgb = mix(color.rgb, texColor.rgb, alpha);
541
+ // color.rgb = mix(texColor.rgb, color.rgb, color.a);
542
+ color.rgb = mix(texColor.rgb, color.rgb, clamp(color.a / max(0.0001, texColor.a), 0.0, 1.0));
543
+ color.a = texColor.a + (1.0 - texColor.a) * color.a;
544
+ }
545
+ }
546
+ }
547
+ #endif
548
+
549
+ #ifdef FILTER
550
+ if(u_filterFlag > 0) {
551
+ transformColor(color, u_colorMatrix);
552
+ }
553
+ #endif
554
+
555
+ #ifdef CLOUDFILTER
556
+ float colorCloudMatrix[20];
557
+ buildCloudColor(colorCloudMatrix);
558
+ transformColor(color, colorCloudMatrix);
559
+ #endif
560
+
561
+ #ifdef CLIPPATH
562
+ float clip = texture2D(u_clipSampler, vClipUV).r;
563
+ color *= clip;
564
+ #endif
565
+
566
+ gl_FragColor = color;
567
+ }`}])})})(fp);var ht=fp.exports;qe(Array);function xu(i,t){const e=i.trim().match(/^([\d.]+)(px|pt|pc|in|cm|mm|em|ex|rem|q|vw|vh|vmax|vmin)$/);e?i={size:parseFloat(e[1]),unit:e[2]}:i={size:parseFloat(i),unit:"px"};let{size:r,unit:n}=i;if(n==="pt")r/=.75;else if(n==="pc")r*=16;else if(n==="in")r*=96;else if(n==="cm")r*=96/2.54;else if(n==="mm")r*=96/25.4;else if(n==="em"||n==="rem"||n==="ex"){if(!t&&typeof getComputedStyle=="function"&&typeof document<"u"){const s=getComputedStyle(document.documentElement).fontSize;s?t=xu(s,16):t=16}r*=t,n==="ex"&&(r/=2)}else if(n==="q")r*=96/25.4/4;else if(n==="vw"||n==="vh"){if(typeof document<"u"){const s=n==="vw"?window.innerWidth||document.documentElement.clientWidth:window.innerHeight||document.documentElement.clientHeight;r*=s/100}}else if((n==="vmax"||n==="vmin")&&typeof document<"u"){const s=window.innerWidth||document.documentElement.clientWidth,o=window.innerHeight||document.documentElement.clientHeight;n==="vmax"?r*=Math.max(s,o)/100:r*=Math.min(s,o)/100}return r}function Qe(i){if(i==null)return i;if(typeof i=="string"&&(i=xu(i)),!Number.isFinite(i))throw new TypeError("Invalid value");return i}function mt(i,t=!1){return i===""?null:(typeof i=="string"&&(i=i.split(/[\s,]+/g)),Array.isArray(i)&&(t&&(i=i.map(Qe)),i.length===1)?i[0]:i)}function bl(i,t){if(Array.isArray(i)&&Array.isArray(t)){if(i.length!==t.length)return!1;for(let e=0;e<i.length;e++)if(i[e]!==t[e])return!1;return!0}return i==null&&t==null||i===t}qe(Array);const yc=Symbol.for("spritejs_setAttributeDefault"),vc=Symbol.for("spritejs_declareAlias"),Ct=Symbol.for("spritejs_setAttribute"),ft=Symbol.for("spritejs_getAttribute"),_h=Symbol.for("spritejs_attributes"),ed=Symbol.for("spritejs_changedAttrs"),$o=Symbol("subject"),Ur=Symbol("attr"),Mc=Symbol("default"),to=Symbol("alias");function Tv(i,[t,e]){let r=Zn(1,0,0,1,0,0);return[...i].forEach(([n,s])=>{if((t||e)&&(r=Cl(Array.of(0,0,0,0,0,0),r,[t,e])),n==="matrix")r=Er(r,r,s);else if(n==="offsetTranslate")r[4]+=s[0],r[5]+=s[1];else if(n==="offsetRotate")r=up(Array.of(0,0,0,0,0,0),r,s);else if(n==="skew"){const[o,a]=s;r=Er(r,r,Zn(1,Math.tan(a),Math.tan(o),1,0,0))}else dp[n](r,r,s);(t||e)&&(r=Cl(Array.of(0,0,0,0,0,0),r,[-t,-e]))}),r}const dn=Symbol("transformMatrix"),Ss=Symbol("transforms"),qi=Symbol("changedAttrs"),gp=Symbol("lastChangedAttr"),Vo=Symbol("offsetFigure");function ro(i,t,e){const r=i[Ur][t];if(i[Ct](t,e,!1)||i[gp]!==t){const s=i[Ss];s.has(t)&&s.delete(t),e&&(t==="rotate"&&(e=Math.PI*e/180),t==="scale"&&(e=e.map(o=>Math.abs(o)>1e-5?o:1/o>0?1e-5:-1e-5)),s.set(t,e)),i[dn]=null,i[$o].onPropertyChange(t,e,r,i)}}function wc(i){const t=i[Vo],e=i.offsetDistance*t.getTotalLength(),r=t.getPointAtLength(e);if(r){const n=i[Ss];let s=i.offsetRotate;s==="auto"?s=r.angle:s==="reverse"?s=Math.PI+r.angle:s=Math.PI*s/180,n.set("offsetRotate",s),n.set("offsetTranslate",[r.x,r.y]),i[dn]=null}}let Eu=class{static setDefault(t,...e){return t[yc](...e)}static declareAlias(t,...e){return t[vc](...e)}static setAttribute(t,...e){return t[Ct](...e)}static getAttribute(t,...e){return t[ft](...e)}static getAttributes(t){return t[_h]}static getChangedAttributes(t){return t[ed]}constructor(t){this[$o]=t,this[Ur]={},this[dn]=Zn(1,0,0,1,0,0),this[Ss]=new Map,this[Mc]={},this[to]=[],Object.defineProperty(t,"transformMatrix",{get:()=>(this[dn]||(this[dn]=Tv(this[Ss],this.transformOrigin)),[...this[dn]])}),this[yc]({id:"",name:"",className:"",x:0,y:0,transformOrigin:[0,0],transform:"",translate:[0,0],rotate:0,scale:[1,1],skew:[0,0],opacity:1,zIndex:0,offsetPath:void 0,offsetDistance:0,offsetRotate:"auto",pointerEvents:"visible",filter:"none",display:""}),this[vc]("class","pos"),this[qi]=new Set,this[Vo]=new ht.Figure2D({scale:5,simplify:0})}get[ed](){const t={};return[...this[qi]].forEach(e=>{t[e]=this[Ur][e]}),t}get[_h](){const t=Object.assign({},this[Ur]);for(let e=0;e<this[to].length;e++){const r=this[to][e];t[r]=this[r]}return t}[yc](t){Object.assign(this[Mc],t),Object.assign(this[Ur],t)}[vc](...t){this[to].push(...t)}[Ct](t,e,r=!0){const n=this[Ur][t],s=this[$o];return e==null&&(e=this[Mc][t]),bl(n,e)?!1:(this[Ur][t]=e,this[qi].has(t)&&this[qi].delete(t),this[qi].add(t),this[gp]=t,r&&s.onPropertyChange(t,e,n,this),!0)}[ft](t){return this[Ur][t]}set id(t){this[Ct]("id",t)}get id(){return this[ft]("id")}set name(t){this[Ct]("name",t)}get name(){return this[ft]("name")}set className(t){this[Ct]("className",t)}get className(){return this[ft]("className")}set class(t){this.className=t}get class(){return this.className}get x(){return this[ft]("x")}set x(t){this[Ct]("x",Qe(t))}get y(){return this[ft]("y")}set y(t){this[Ct]("y",Qe(t))}get pos(){return[this.x,this.y]}set pos(t){t=mt(t),Array.isArray(t)||(t=[t,t]),this.x=t[0],this.y=t[1]}get transform(){return this[ft]("transform")}set transform(t){let e=null;if(Array.isArray(t)&&(e=t,t=`matrix(${t.map(Qe).join()})`),typeof t=="string")t=t.replace(/\s*,\s*/g,",");else if(t!=null)throw new TypeError("Invalid transform value.");const r=this[Ur].transform;if(this[Ct]("transform",t,!1)){const n=this[Ss];if(n.has("matrix")&&n.delete("matrix"),e)n.set("matrix",e);else if(t){const s=t.match(/(matrix|translate|rotate|scale|skew)\([^()]+\)/g);if(s){let o=Zn(1,0,0,1,0,0);for(let a=0;a<s.length;a++){const l=s[a].match(/^(matrix|translate|rotate|scale|skew)\(([^()]+)\)/);if(l){let[,u,h]=l;u==="rotate"?h=Math.PI*parseFloat(h)/180:h=h.trim().split(/[\s,]+/).map(d=>Qe(d)),u==="matrix"?o=Er(o,o,h):u==="skew"?o=Er(o,o,Zn(1,Math.tan(h[1]),Math.tan(h[0]),1,0,0)):dp[u](o,o,h),n.set("matrix",o)}}}else throw new TypeError("Invalid transform value.")}this[dn]=null,this[$o].onPropertyChange("transform",t,r,this)}}get transformOrigin(){return this[ft]("transformOrigin")}set transformOrigin(t){t=mt(t,!0),t!=null&&!Array.isArray(t)&&(t=[t,t]),this[Ct]("transformOrigin",t)&&(this[dn]=null)}get rotate(){return this[ft]("rotate")}set rotate(t){ro(this,"rotate",t)}get translate(){return this[ft]("translate")}set translate(t){t=mt(t,!0),t!=null&&!Array.isArray(t)&&(t=[t,t]),ro(this,"translate",t)}get scale(){return this[ft]("scale")}set scale(t){t=mt(t,!0),t!=null&&!Array.isArray(t)&&(t=[t,t]),ro(this,"scale",t)}get skew(){return this[ft]("skew")}set skew(t){t=mt(t,!0),t!=null&&!Array.isArray(t)&&(t=[t,t]),ro(this,"skew",t)}get opacity(){return this[ft]("opacity")}set opacity(t){t!=null&&(t=Number(t)),this[Ct]("opacity",t)}get zIndex(){return this[ft]("zIndex")}set zIndex(t){t!=null&&(t=Number(t)),this[Ct]("zIndex",t)}get offsetPath(){return this[ft]("offsetPath")}set offsetPath(t){this[Ct]("offsetPath",t)&&(this[Vo].beginPath(),t!=null&&this[Vo].addPath(t),wc(this))}get offsetDistance(){return this[ft]("offsetDistance")}set offsetDistance(t){this[Ct]("offsetDistance",Qe(t))&&wc(this)}get offsetRotate(){return this[ft]("offsetRotate")}set offsetRotate(t){this[Ct]("offsetRotate",t),wc(this)}get pointerEvents(){return this[ft]("pointerEvents")}set pointerEvents(t){if(t!=null&&t!=="none"&&t!=="visible"&&t!=="visibleFill"&&t!=="visibleStroke"&&t!=="all")throw new TypeError("Invalid pointerEvents type.");this[Ct]("pointerEvents",t)}get filter(){return this[ft]("filter")}set filter(t){this[Ct]("filter",t)}get display(){return this[ft]("display")}set display(t){this[Ct]("display",t)}set offset(t){}};var Gr={},Ca={},js={},pp=function(i,t){return{value:t,done:!!i}},Ui={},Sv={}.toString,Bs=function(i){return Sv.call(i).slice(8,-1)},Iv=Bs,Au=Object("z").propertyIsEnumerable(0)?Object:function(i){return Iv(i)=="String"?i.split(""):Object(i)},Nu=function(i){if(i==null)throw TypeError("Can't call method on "+i);return i},Cv=Au,bv=Nu,ei=function(i){return Cv(bv(i))},xv=!0,mp={exports:{}},Ev=mp.exports=typeof window<"u"&&window.Math==Math?window:typeof self<"u"&&self.Math==Math?self:Function("return this")();typeof __g=="number"&&(__g=Ev);var Kt=mp.exports,yp={exports:{}},Av=yp.exports={version:"2.6.12"};typeof __e=="number"&&(__e=Av);var At=yp.exports,Us=function(i){if(typeof i!="function")throw TypeError(i+" is not a function!");return i},Nv=Us,Cn=function(i,t,e){if(Nv(i),t===void 0)return i;switch(e){case 1:return function(r){return i.call(t,r)};case 2:return function(r,n){return i.call(t,r,n)};case 3:return function(r,n,s){return i.call(t,r,n,s)}}return function(){return i.apply(t,arguments)}},lr={},Ar=function(i){return typeof i=="object"?i!==null:typeof i=="function"},Dv=Ar,tn=function(i){if(!Dv(i))throw TypeError(i+" is not an object!");return i},ti=function(i){try{return!!i()}catch{return!0}},ur=!ti(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7}),td=Ar,xl=Kt.document,Pv=td(xl)&&td(xl.createElement),Du=function(i){return Pv?xl.createElement(i):{}},vp=!ur&&!ti(function(){return Object.defineProperty(Du("div"),"a",{get:function(){return 7}}).a!=7}),no=Ar,Pu=function(i,t){if(!no(i))return i;var e,r;if(t&&typeof(e=i.toString)=="function"&&!no(r=e.call(i))||typeof(e=i.valueOf)=="function"&&!no(r=e.call(i))||!t&&typeof(e=i.toString)=="function"&&!no(r=e.call(i)))return r;throw TypeError("Can't convert object to primitive value")},rd=tn,kv=vp,Lv=Pu,Rv=Object.defineProperty;lr.f=ur?Object.defineProperty:function(t,e,r){if(rd(t),e=Lv(e,!0),rd(r),kv)try{return Rv(t,e,r)}catch{}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(t[e]=r.value),t};var Fs=function(i,t){return{enumerable:!(i&1),configurable:!(i&2),writable:!(i&4),value:t}},Ov=lr,zv=Fs,bn=ur?function(i,t,e){return Ov.f(i,t,zv(1,e))}:function(i,t,e){return i[t]=e,i},jv={}.hasOwnProperty,ri=function(i,t){return jv.call(i,t)},io=Kt,Tc=At,nd=Cn,Bv=bn,Uv=ri,so="prototype",jt=function(i,t,e){var r=i&jt.F,n=i&jt.G,s=i&jt.S,o=i&jt.P,a=i&jt.B,c=i&jt.W,l=n?Tc:Tc[t]||(Tc[t]={}),u=l[so],h=n?io:s?io[t]:(io[t]||{})[so],d,g,p;n&&(e=t);for(d in e)g=!r&&h&&h[d]!==void 0,!(g&&Uv(l,d))&&(p=g?h[d]:e[d],l[d]=n&&typeof h[d]!="function"?e[d]:a&&g?nd(p,io):c&&h[d]==p?function(v){var I=function(D,x,j){if(this instanceof v){switch(arguments.length){case 0:return new v;case 1:return new v(D);case 2:return new v(D,x)}return new v(D,x,j)}return v.apply(this,arguments)};return I[so]=v[so],I}(p):o&&typeof p=="function"?nd(Function.call,p):p,o&&((l.virtual||(l.virtual={}))[d]=p,i&jt.R&&u&&!u[d]&&Bv(u,d,p)))};jt.F=1;jt.G=2;jt.S=4;jt.P=8;jt.B=16;jt.W=32;jt.U=64;jt.R=128;var qt=jt,Mp=bn,Fv=Math.ceil,Wv=Math.floor,ku=function(i){return isNaN(i=+i)?0:(i>0?Wv:Fv)(i)},$v=ku,Vv=Math.min,ba=function(i){return i>0?Vv($v(i),9007199254740991):0},Yv=ku,Gv=Math.max,Hv=Math.min,Qv=function(i,t){return i=Yv(i),i<0?Gv(i+t,0):Hv(i,t)},Zv=ei,Kv=ba,qv=Qv,Xv=function(i){return function(t,e,r){var n=Zv(t),s=Kv(n.length),o=qv(r,s),a;if(i&&e!=e){for(;s>o;)if(a=n[o++],a!=a)return!0}else for(;s>o;o++)if((i||o in n)&&n[o]===e)return i||o||0;return!i&&-1}},wp={exports:{}},Jv=At,id=Kt,sd="__core-js_shared__",od=id[sd]||(id[sd]={});(wp.exports=function(i,t){return od[i]||(od[i]=t!==void 0?t:{})})("versions",[]).push({version:Jv.version,mode:"pure",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"});var Lu=wp.exports,_v=0,eM=Math.random(),xa=function(i){return"Symbol(".concat(i===void 0?"":i,")_",(++_v+eM).toString(36))},ad=Lu("keys"),tM=xa,Ru=function(i){return ad[i]||(ad[i]=tM(i))},cd=ri,rM=ei,nM=Xv(!1),iM=Ru("IE_PROTO"),Tp=function(i,t){var e=rM(i),r=0,n=[],s;for(s in e)s!=iM&&cd(e,s)&&n.push(s);for(;t.length>r;)cd(e,s=t[r++])&&(~nM(n,s)||n.push(s));return n},Ou="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","),sM=Tp,oM=Ou,Fi=Object.keys||function(t){return sM(t,oM)},aM=lr,cM=tn,lM=Fi,uM=ur?Object.defineProperties:function(t,e){cM(t);for(var r=lM(e),n=r.length,s=0,o;n>s;)aM.f(t,o=r[s++],e[o]);return t},ld=Kt.document,Sp=ld&&ld.documentElement,hM=tn,dM=uM,ud=Ou,fM=Ru("IE_PROTO"),Sc=function(){},El="prototype",Yo=function(){var i=Du("iframe"),t=ud.length,e="<",r=">",n;for(i.style.display="none",Sp.appendChild(i),i.src="javascript:",n=i.contentWindow.document,n.open(),n.write(e+"script"+r+"document.F=Object"+e+"/script"+r),n.close(),Yo=n.F;t--;)delete Yo[El][ud[t]];return Yo()},zu=Object.create||function(t,e){var r;return t!==null?(Sc[El]=hM(t),r=new Sc,Sc[El]=null,r[fM]=t):r=Yo(),e===void 0?r:dM(r,e)},Ip={exports:{}},Al=Lu("wks"),gM=xa,Nl=Kt.Symbol,hd=typeof Nl=="function",pM=Ip.exports=function(i){return Al[i]||(Al[i]=hd&&Nl[i]||(hd?Nl:gM)("Symbol."+i))};pM.store=Al;var Wt=Ip.exports,mM=lr.f,yM=ri,dd=Wt("toStringTag"),Ws=function(i,t,e){i&&!yM(i=e?i:i.prototype,dd)&&mM(i,dd,{configurable:!0,value:t})},vM=zu,MM=Fs,wM=Ws,Cp={};bn(Cp,Wt("iterator"),function(){return this});var TM=function(i,t,e){i.prototype=vM(Cp,{next:MM(1,e)}),wM(i,t+" Iterator")},SM=Nu,Wi=function(i){return Object(SM(i))},IM=ri,CM=Wi,fd=Ru("IE_PROTO"),bM=Object.prototype,xM=Object.getPrototypeOf||function(i){return i=CM(i),IM(i,fd)?i[fd]:typeof i.constructor=="function"&&i instanceof i.constructor?i.constructor.prototype:i instanceof Object?bM:null},Ic=qt,EM=Mp,AM=bn,gd=Ui,NM=TM,DM=Ws,PM=xM,Cc=Wt("iterator"),bc=!([].keys&&"next"in[].keys()),kM="@@iterator",pd="keys",oo="values",LM=function(){return this},ju=function(i,t,e,r,n,s,o){NM(e,t,r);var a=function(j){if(!bc&&j in h)return h[j];switch(j){case pd:return function(){return new e(this,j)};case oo:return function(){return new e(this,j)}}return function(){return new e(this,j)}},c=t+" Iterator",l=n==oo,u=!1,h=i.prototype,d=h[Cc]||h[kM]||n&&h[n],g=d||a(n),p=n?l?a("entries"):g:void 0,v=t=="Array"&&h.entries||d,I,D,x;if(v&&(x=PM(v.call(new i)),x!==Object.prototype&&x.next&&DM(x,c,!0)),l&&d&&d.name!==oo&&(u=!0,g=function(){return d.call(this)}),o&&(bc||u||!h[Cc])&&AM(h,Cc,g),gd[t]=g,gd[c]=LM,n)if(I={values:l?g:a(oo),keys:s?g:a(pd),entries:p},o)for(D in I)D in h||EM(h,D,I[D]);else Ic(Ic.P+Ic.F*(bc||u),t,I);return I},ao=pp,md=Ui,RM=ei;ju(Array,"Array",function(i,t){this._t=RM(i),this._i=0,this._k=t},function(){var i=this._t,t=this._k,e=this._i++;return!i||e>=i.length?(this._t=void 0,ao(1)):t=="keys"?ao(0,e):t=="values"?ao(0,i[e]):ao(0,[e,i[e]])},"values");md.Arguments=md.Array;var OM=Kt,zM=bn,yd=Ui,vd=Wt("toStringTag"),Md="CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,TextTrackList,TouchList".split(",");for(var xc=0;xc<Md.length;xc++){var Ec=Md[xc],wd=OM[Ec],Ac=wd&&wd.prototype;Ac&&!Ac[vd]&&zM(Ac,vd,Ec),yd[Ec]=yd.Array}var jM=ku,BM=Nu,UM=function(i){return function(t,e){var r=String(BM(t)),n=jM(e),s=r.length,o,a;return n<0||n>=s?i?"":void 0:(o=r.charCodeAt(n),o<55296||o>56319||n+1===s||(a=r.charCodeAt(n+1))<56320||a>57343?i?r.charAt(n):o:i?r.slice(n,n+2):(o-55296<<10)+(a-56320)+65536)}},FM=UM(!0);ju(String,"String",function(i){this._t=String(i),this._i=0},function(){var i=this._t,t=this._i,e;return t>=i.length?{value:void 0,done:!0}:(e=FM(i,t),this._i+=e.length,{value:e,done:!1})});var Dl=Bs,WM=Wt("toStringTag"),$M=Dl(function(){return arguments}())=="Arguments",VM=function(i,t){try{return i[t]}catch{}},Ea=function(i){var t,e,r;return i===void 0?"Undefined":i===null?"Null":typeof(e=VM(t=Object(i),WM))=="string"?e:$M?Dl(t):(r=Dl(t))=="Object"&&typeof t.callee=="function"?"Arguments":r},YM=Ea,GM=Wt("iterator"),HM=Ui,QM=At.isIterable=function(i){var t=Object(i);return t[GM]!==void 0||"@@iterator"in t||HM.hasOwnProperty(YM(t))},ZM=QM,KM={default:ZM,__esModule:!0},qM=Ea,XM=Wt("iterator"),JM=Ui,Bu=At.getIteratorMethod=function(i){if(i!=null)return i[XM]||i["@@iterator"]||JM[qM(i)]},_M=tn,e1=Bu,t1=At.getIterator=function(i){var t=e1(i);if(typeof t!="function")throw TypeError(i+" is not iterable!");return _M(t.call(i))},r1=t1,n1={default:r1,__esModule:!0};js.__esModule=!0;var i1=KM,s1=bp(i1),o1=n1,a1=bp(o1);function bp(i){return i&&i.__esModule?i:{default:i}}js.default=function(){function i(t,e){var r=[],n=!0,s=!1,o=void 0;try{for(var a=(0,a1.default)(t),c;!(n=(c=a.next()).done)&&(r.push(c.value),!(e&&r.length===e));n=!0);}catch(l){s=!0,o=l}finally{try{!n&&a.return&&a.return()}finally{if(s)throw o}}return r}return function(t,e){if(Array.isArray(t))return t;if((0,s1.default)(Object(t)))return i(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();var Aa={},Td=tn,xp=function(i,t,e,r){try{return r?t(Td(e)[0],e[1]):t(e)}catch(s){var n=i.return;throw n!==void 0&&Td(n.call(i)),s}},c1=Ui,l1=Wt("iterator"),u1=Array.prototype,Ep=function(i){return i!==void 0&&(c1.Array===i||u1[l1]===i)},h1=lr,d1=Fs,f1=function(i,t,e){t in i?h1.f(i,t,d1(0,e)):i[t]=e},Nc,Sd;function Ap(){if(Sd)return Nc;Sd=1;var i=Wt("iterator"),t=!1;try{var e=[7][i]();e.return=function(){t=!0},Array.from(e,function(){throw 2})}catch{}return Nc=function(r,n){if(!n&&!t)return!1;var s=!1;try{var o=[7],a=o[i]();a.next=function(){return{done:s=!0}},o[i]=function(){return a},r(o)}catch{}return s},Nc}var g1=Cn,Dc=qt,p1=Wi,m1=xp,y1=Ep,v1=ba,Id=f1,M1=Bu;Dc(Dc.S+Dc.F*!Ap()(function(i){Array.from(i)}),"Array",{from:function(t){var e=p1(t),r=typeof this=="function"?this:Array,n=arguments.length,s=n>1?arguments[1]:void 0,o=s!==void 0,a=0,c=M1(e),l,u,h,d;if(o&&(s=g1(s,n>2?arguments[2]:void 0,2)),c!=null&&!(r==Array&&y1(c)))for(d=c.call(e),u=new r;!(h=d.next()).done;a++)Id(u,a,o?m1(d,s,[h.value,a],!0):h.value);else for(l=v1(e.length),u=new r(l);l>a;a++)Id(u,a,o?s(e[a],a):e[a]);return u.length=a,u}});var w1=At.Array.from,T1={default:w1,__esModule:!0};Aa.__esModule=!0;var S1=T1,I1=C1(S1);function C1(i){return i&&i.__esModule?i:{default:i}}Aa.default=function(i){if(Array.isArray(i)){for(var t=0,e=Array(i.length);t<i.length;t++)e[t]=i[t];return e}else return(0,I1.default)(i)};var b1=bn,Uu=function(i,t,e){for(var r in t)e&&i[r]?i[r]=t[r]:b1(i,r,t[r]);return i},Fu=function(i,t,e,r){if(!(i instanceof t)||r!==void 0&&r in i)throw TypeError(e+": incorrect invocation!");return i},Np={exports:{}},x1=Cn,E1=xp,A1=Ep,N1=tn,D1=ba,P1=Bu,Pl={},kl={},Dp=Np.exports=function(i,t,e,r,n){var s=n?function(){return i}:P1(i),o=x1(e,r,t?2:1),a=0,c,l,u,h;if(typeof s!="function")throw TypeError(i+" is not iterable!");if(A1(s)){for(c=D1(i.length);c>a;a++)if(h=t?o(N1(l=i[a])[0],l[1]):o(i[a]),h===Pl||h===kl)return h}else for(u=s.call(i);!(l=u.next()).done;)if(h=E1(u,o,l.value,t),h===Pl||h===kl)return h};Dp.BREAK=Pl;Dp.RETURN=kl;var $s=Np.exports,k1=Kt,Cd=At,L1=lr,R1=ur,bd=Wt("species"),Pp=function(i){var t=typeof Cd[i]=="function"?Cd[i]:k1[i];R1&&t&&!t[bd]&&L1.f(t,bd,{configurable:!0,get:function(){return this}})},kp={exports:{}},Jn=xa("meta"),O1=Ar,Wu=ri,z1=lr.f,j1=0,Na=Object.isExtensible||function(){return!0},B1=!ti(function(){return Na(Object.preventExtensions({}))}),$u=function(i){z1(i,Jn,{value:{i:"O"+ ++j1,w:{}}})},U1=function(i,t){if(!O1(i))return typeof i=="symbol"?i:(typeof i=="string"?"S":"P")+i;if(!Wu(i,Jn)){if(!Na(i))return"F";if(!t)return"E";$u(i)}return i[Jn].i},F1=function(i,t){if(!Wu(i,Jn)){if(!Na(i))return!0;if(!t)return!1;$u(i)}return i[Jn].w},W1=function(i){return B1&&$1.NEED&&Na(i)&&!Wu(i,Jn)&&$u(i),i},$1=kp.exports={KEY:Jn,NEED:!1,fastKey:U1,getWeak:F1,onFreeze:W1},Vu=kp.exports,V1=Ar,Lp=function(i,t){if(!V1(i)||i._t!==t)throw TypeError("Incompatible receiver, "+t+" required!");return i},Y1=lr.f,G1=zu,H1=Uu,Q1=Cn,Z1=Fu,K1=$s,q1=ju,co=pp,X1=Pp,Rp=ur,Op=Vu.fastKey,gi=Lp,Xi=Rp?"_s":"size",lo=function(i,t){var e=Op(t),r;if(e!=="F")return i._i[e];for(r=i._f;r;r=r.n)if(r.k==t)return r},J1={getConstructor:function(i,t,e,r){var n=i(function(s,o){Z1(s,n,t,"_i"),s._t=t,s._i=G1(null),s._f=void 0,s._l=void 0,s[Xi]=0,o!=null&&K1(o,e,s[r],s)});return H1(n.prototype,{clear:function(){for(var o=gi(this,t),a=o._i,c=o._f;c;c=c.n)c.r=!0,c.p&&(c.p=c.p.n=void 0),delete a[c.i];o._f=o._l=void 0,o[Xi]=0},delete:function(s){var o=gi(this,t),a=lo(o,s);if(a){var c=a.n,l=a.p;delete o._i[a.i],a.r=!0,l&&(l.n=c),c&&(c.p=l),o._f==a&&(o._f=c),o._l==a&&(o._l=l),o[Xi]--}return!!a},forEach:function(o){gi(this,t);for(var a=Q1(o,arguments.length>1?arguments[1]:void 0,3),c;c=c?c.n:this._f;)for(a(c.v,c.k,this);c&&c.r;)c=c.p},has:function(o){return!!lo(gi(this,t),o)}}),Rp&&Y1(n.prototype,"size",{get:function(){return gi(this,t)[Xi]}}),n},def:function(i,t,e){var r=lo(i,t),n,s;return r?r.v=e:(i._l=r={i:s=Op(t,!0),k:t,v:e,p:n=i._l,n:void 0,r:!1},i._f||(i._f=r),n&&(n.n=r),i[Xi]++,s!=="F"&&(i._i[s]=r)),i},getEntry:lo,setStrong:function(i,t,e){q1(i,t,function(r,n){this._t=gi(r,t),this._k=n,this._l=void 0},function(){for(var r=this,n=r._k,s=r._l;s&&s.r;)s=s.p;return!r._t||!(r._l=s=s?s.n:r._t._f)?(r._t=void 0,co(1)):n=="keys"?co(0,s.k):n=="values"?co(0,s.v):co(0,[s.k,s.v])},e?"entries":"values",!e,!0),X1(t)}},_1=Bs,zp=Array.isArray||function(t){return _1(t)=="Array"},ew=Ar,xd=zp,tw=Wt("species"),rw=function(i){var t;return xd(i)&&(t=i.constructor,typeof t=="function"&&(t===Array||xd(t.prototype))&&(t=void 0),ew(t)&&(t=t[tw],t===null&&(t=void 0))),t===void 0?Array:t},nw=rw,iw=function(i,t){return new(nw(i))(t)},sw=Cn,ow=Au,aw=Wi,cw=ba,lw=iw,uw=function(i,t){var e=i==1,r=i==2,n=i==3,s=i==4,o=i==6,a=i==5||o,c=t||lw;return function(l,u,h){for(var d=aw(l),g=ow(d),p=sw(u,h,3),v=cw(g.length),I=0,D=e?c(l,v):r?c(l,0):void 0,x,j;v>I;I++)if((a||I in g)&&(x=g[I],j=p(x,I,d),i)){if(e)D[I]=j;else if(j)switch(i){case 3:return!0;case 5:return x;case 6:return I;case 2:D.push(x)}else if(s)return!1}return o?-1:n||s?s:D}},hw=Kt,uo=qt,dw=Vu,fw=ti,gw=bn,pw=Uu,mw=$s,Ed=Fu,yw=Ar,vw=Ws,Mw=lr.f,ww=uw(0),Tw=ur,Sw=function(i,t,e,r,n,s){var o=hw[i],a=o,c=n?"set":"add",l=a&&a.prototype,u={};return!Tw||typeof a!="function"||!(s||l.forEach&&!fw(function(){new a().entries().next()}))?(a=r.getConstructor(t,i,n,c),pw(a.prototype,e),dw.NEED=!0):(a=t(function(h,d){Ed(h,a,i,"_c"),h._c=new o,d!=null&&mw(d,n,h[c],h)}),ww("add,clear,delete,forEach,get,has,set,keys,values,entries,toJSON".split(","),function(h){var d=h=="add"||h=="set";h in l&&!(s&&h=="clear")&&gw(a.prototype,h,function(g,p){if(Ed(this,a,h),!d&&s&&!yw(g))return h=="get"?void 0:!1;var v=this._c[h](g===0?0:g,p);return d?this:v})}),s||Mw(a.prototype,"size",{get:function(){return this._c.size}})),vw(a,i),u[i]=a,uo(uo.G+uo.W+uo.F,u),s||r.setStrong(a,i,n),a},Pc=J1,Ad=Lp,kc="Map";Sw(kc,function(i){return function(){return i(this,arguments.length>0?arguments[0]:void 0)}},{get:function(t){var e=Pc.getEntry(Ad(this,kc),t);return e&&e.v},set:function(t,e){return Pc.def(Ad(this,kc),t===0?0:t,e)}},Pc,!0);var Lc,Nd;function Iw(){if(Nd)return Lc;Nd=1;var i=$s;return Lc=function(t,e){var r=[];return i(t,!1,r.push,r,e),r},Lc}var Rc,Dd;function Cw(){if(Dd)return Rc;Dd=1;var i=Ea,t=Iw();return Rc=function(e){return function(){if(i(this)!=e)throw TypeError(e+"#toJSON isn't generic");return t(this)}},Rc}var Oc=qt;Oc(Oc.P+Oc.R,"Map",{toJSON:Cw()("Map")});var Pd=qt,bw=function(i){Pd(Pd.S,i,{of:function(){for(var e=arguments.length,r=new Array(e);e--;)r[e]=arguments[e];return new this(r)}})};bw("Map");var kd=qt,Ld=Us,xw=Cn,Rd=$s,Ew=function(i){kd(kd.S,i,{from:function(e){var r=arguments[1],n,s,o,a;return Ld(this),n=r!==void 0,n&&Ld(r),e==null?new this:(s=[],n?(o=0,a=xw(r,arguments[2],2),Rd(e,!1,function(c){s.push(a(c,o++))})):Rd(e,!1,s.push,s),new this(s))}})};Ew("Map");var Aw=At.Map,jp={default:Aw,__esModule:!0},Da={};Da.f=Object.getOwnPropertySymbols;var $i={};$i.f={}.propertyIsEnumerable;var zc,Od;function Nw(){if(Od)return zc;Od=1;var i=ur,t=Fi,e=Da,r=$i,n=Wi,s=Au,o=Object.assign;return zc=!o||ti(function(){var a={},c={},l=Symbol(),u="abcdefghijklmnopqrst";return a[l]=7,u.split("").forEach(function(h){c[h]=h}),o({},a)[l]!=7||Object.keys(o({},c)).join("")!=u})?function(c,l){for(var u=n(c),h=arguments.length,d=1,g=e.f,p=r.f;h>d;)for(var v=s(arguments[d++]),I=g?t(v).concat(g(v)):t(v),D=I.length,x=0,j;D>x;)j=I[x++],(!i||p.call(v,j))&&(u[j]=v[j]);return u}:o,zc}var jc=qt;jc(jc.S+jc.F,"Object",{assign:Nw()});var Dw=At.Object.assign,Yu={default:Dw,__esModule:!0},Pa={};Pa.__esModule=!0;Pa.default=function(i,t){if(!(i instanceof t))throw new TypeError("Cannot call a class as a function")};var ka={},Bc=qt;Bc(Bc.S+Bc.F*!ur,"Object",{defineProperty:lr.f});var Pw=At.Object,kw=function(t,e,r){return Pw.defineProperty(t,e,r)},Lw={default:kw,__esModule:!0};ka.__esModule=!0;var Rw=Lw,Ow=zw(Rw);function zw(i){return i&&i.__esModule?i:{default:i}}ka.default=function(){function i(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),(0,Ow.default)(t,n.key,n)}}return function(t,e,r){return e&&i(t.prototype,e),r&&i(t,r),t}}();var Gu={};Gu.f=Wt;var zd=At,jw=Gu,Bw=lr.f,Hu=function(i){var t=zd.Symbol||(zd.Symbol={});i.charAt(0)!="_"&&!(i in t)&&Bw(t,i,{value:jw.f(i)})},Uw=Fi,Fw=Da,Ww=$i,$w=function(i){var t=Uw(i),e=Fw.f;if(e)for(var r=e(i),n=Ww.f,s=0,o;r.length>s;)n.call(i,o=r[s++])&&t.push(o);return t},Bp={},Qu={},Vw=Tp,Yw=Ou.concat("length","prototype");Qu.f=Object.getOwnPropertyNames||function(t){return Vw(t,Yw)};var Gw=ei,Up=Qu.f,Hw={}.toString,Fp=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],Qw=function(i){try{return Up(i)}catch{return Fp.slice()}};Bp.f=function(t){return Fp&&Hw.call(t)=="[object Window]"?Qw(t):Up(Gw(t))};var Wp={},Zw=$i,Kw=Fs,qw=ei,Xw=Pu,Jw=ri,_w=vp,jd=Object.getOwnPropertyDescriptor;Wp.f=ur?jd:function(t,e){if(t=qw(t),e=Xw(e,!0),_w)try{return jd(t,e)}catch{}if(Jw(t,e))return Kw(!Zw.f.call(t,e),t[e])};var La=Kt,bt=ri,$p=ur,Bt=qt,eT=Mp,tT=Vu.KEY,Zu=ti,Ku=Lu,qu=Ws,rT=xa,Vs=Wt,nT=Gu,iT=Hu,sT=$w,oT=zp,Ll=tn,aT=Ar,cT=Wi,Ra=ei,Xu=Pu,Rl=Fs,As=zu,Vp=Bp,Yp=Wp,Oa=Da,Gp=lr,lT=Fi,Hp=Yp.f,Fn=Gp.f,Qp=Vp.f,Qt=La.Symbol,_o=La.JSON,ho=_o&&_o.stringify,yn="prototype",Ht=Vs("_hidden"),Bd=Vs("toPrimitive"),uT={}.propertyIsEnumerable,Ji=Ku("symbol-registry"),_r=Ku("symbols"),Ys=Ku("op-symbols"),yr=Object[yn],Vi=typeof Qt=="function"&&!!Oa.f,Uc=La.QObject,Ol=!Uc||!Uc[yn]||!Uc[yn].findChild,zl=$p&&Zu(function(){return As(Fn({},"a",{get:function(){return Fn(this,"a",{value:7}).a}})).a!=7})?function(i,t,e){var r=Hp(yr,t);r&&delete yr[t],Fn(i,t,e),r&&i!==yr&&Fn(yr,t,r)}:Fn,Ud=function(i){var t=_r[i]=As(Qt[yn]);return t._k=i,t},jl=Vi&&typeof Qt.iterator=="symbol"?function(i){return typeof i=="symbol"}:function(i){return i instanceof Qt},za=function(t,e,r){return t===yr&&za(Ys,e,r),Ll(t),e=Xu(e,!0),Ll(r),bt(_r,e)?(r.enumerable?(bt(t,Ht)&&t[Ht][e]&&(t[Ht][e]=!1),r=As(r,{enumerable:Rl(0,!1)})):(bt(t,Ht)||Fn(t,Ht,Rl(1,{})),t[Ht][e]=!0),zl(t,e,r)):Fn(t,e,r)},Zp=function(t,e){Ll(t);for(var r=sT(e=Ra(e)),n=0,s=r.length,o;s>n;)za(t,o=r[n++],e[o]);return t},hT=function(t,e){return e===void 0?As(t):Zp(As(t),e)},dT=function(t){var e=uT.call(this,t=Xu(t,!0));return this===yr&&bt(_r,t)&&!bt(Ys,t)?!1:e||!bt(this,t)||!bt(_r,t)||bt(this,Ht)&&this[Ht][t]?e:!0},Kp=function(t,e){if(t=Ra(t),e=Xu(e,!0),!(t===yr&&bt(_r,e)&&!bt(Ys,e))){var r=Hp(t,e);return r&&bt(_r,e)&&!(bt(t,Ht)&&t[Ht][e])&&(r.enumerable=!0),r}},qp=function(t){for(var e=Qp(Ra(t)),r=[],n=0,s;e.length>n;)!bt(_r,s=e[n++])&&s!=Ht&&s!=tT&&r.push(s);return r},Xp=function(t){for(var e=t===yr,r=Qp(e?Ys:Ra(t)),n=[],s=0,o;r.length>s;)bt(_r,o=r[s++])&&(!e||bt(yr,o))&&n.push(_r[o]);return n};Vi||(Qt=function(){if(this instanceof Qt)throw TypeError("Symbol is not a constructor!");var t=rT(arguments.length>0?arguments[0]:void 0),e=function(r){this===yr&&e.call(Ys,r),bt(this,Ht)&&bt(this[Ht],t)&&(this[Ht][t]=!1),zl(this,t,Rl(1,r))};return $p&&Ol&&zl(yr,t,{configurable:!0,set:e}),Ud(t)},eT(Qt[yn],"toString",function(){return this._k}),Yp.f=Kp,Gp.f=za,Qu.f=Vp.f=qp,$i.f=dT,Oa.f=Xp,nT.f=function(i){return Ud(Vs(i))});Bt(Bt.G+Bt.W+Bt.F*!Vi,{Symbol:Qt});for(var Fd="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),Wd=0;Fd.length>Wd;)Vs(Fd[Wd++]);for(var $d=lT(Vs.store),Vd=0;$d.length>Vd;)iT($d[Vd++]);Bt(Bt.S+Bt.F*!Vi,"Symbol",{for:function(i){return bt(Ji,i+="")?Ji[i]:Ji[i]=Qt(i)},keyFor:function(t){if(!jl(t))throw TypeError(t+" is not a symbol!");for(var e in Ji)if(Ji[e]===t)return e},useSetter:function(){Ol=!0},useSimple:function(){Ol=!1}});Bt(Bt.S+Bt.F*!Vi,"Object",{create:hT,defineProperty:za,defineProperties:Zp,getOwnPropertyDescriptor:Kp,getOwnPropertyNames:qp,getOwnPropertySymbols:Xp});var fT=Zu(function(){Oa.f(1)});Bt(Bt.S+Bt.F*fT,"Object",{getOwnPropertySymbols:function(t){return Oa.f(cT(t))}});_o&&Bt(Bt.S+Bt.F*(!Vi||Zu(function(){var i=Qt();return ho([i])!="[null]"||ho({a:i})!="{}"||ho(Object(i))!="{}"})),"JSON",{stringify:function(t){for(var e=[t],r=1,n,s;arguments.length>r;)e.push(arguments[r++]);if(s=n=e[1],!(!aT(n)&&t===void 0||jl(t)))return oT(n)||(n=function(o,a){if(typeof s=="function"&&(a=s.call(this,o,a)),!jl(a))return a}),e[1]=n,ho.apply(_o,e)}});Qt[yn][Bd]||bn(Qt[yn],Bd,Qt[yn].valueOf);qu(Qt,"Symbol");qu(Math,"Math",!0);qu(La.JSON,"JSON",!0);Hu("asyncIterator");Hu("observable");var gT=At.Symbol,Jp={default:gT,__esModule:!0},ja={};Object.defineProperty(ja,"__esModule",{value:!0});ja.createNowTime=pT;ja.formatDelay=mT;function pT(){var i=null;return Date.now?i=Date.now:i=function(){return new Date().getTime()},i}function mT(i){return typeof i=="number"?i={delay:i}:"entropy"in i&&(i={delay:i.entropy,isEntropy:!0}),i}Object.defineProperty(Ca,"__esModule",{value:!0});var yT=js,Yd=ii(yT),vT=Aa,Fc=ii(vT),MT=jp,wT=ii(MT),TT=Yu,ST=ii(TT),IT=Pa,CT=ii(IT),bT=ka,xT=ii(bT),ET=Jp,ni=ii(ET),_p=ja;function ii(i){return i&&i.__esModule?i:{default:i}}var AT=(0,_p.createNowTime)(),NT={originTime:0,playbackRate:1},kr=(0,ni.default)("timeMark"),Wc=(0,ni.default)("playbackRate"),Lr=(0,ni.default)("timers"),DT=(0,ni.default)("originTime"),_i=(0,ni.default)("setTimer"),Rr=(0,ni.default)("parent"),PT=function(){function i(t,e){(0,CT.default)(this,i),t instanceof i&&(e=t,t={}),t=(0,ST.default)({},NT,t),e&&(this[Rr]=e);var r=t.nowtime||AT;if(e)Object.defineProperty(this,"globalTime",{get:function(){return e.currentTime}});else{var n=r();Object.defineProperty(this,"globalTime",{get:function(){return r()-n}})}this[kr]=[{globalTime:this.globalTime,localTime:-t.originTime,entropy:-t.originTime,playbackRate:t.playbackRate,globalEntropy:0}],this[Rr]&&(this[kr][0].globalEntropy=this[Rr].entropy),this[DT]=t.originTime,this[Wc]=t.playbackRate,this[Lr]=new wT.default}return(0,xT.default)(i,[{key:"markTime",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=e.time,n=r===void 0?this.currentTime:r,s=e.entropy,o=s===void 0?this.entropy:s,a=e.playbackRate,c=a===void 0?this.playbackRate:a,l={globalTime:this.globalTime,localTime:n,entropy:o,playbackRate:c,globalEntropy:this.globalEntropy};this[kr].push(l)}},{key:"fork",value:function(e){return new i(e,this)}},{key:"seekGlobalTime",value:function(e){var r=this.seekTimeMark(e),n=this[kr][r],s=n.entropy,o=n.playbackRate,a=n.globalTime;return a+(e-s)/Math.abs(o)}},{key:"seekLocalTime",value:function(e){var r=this.seekTimeMark(e),n=this[kr][r],s=n.localTime,o=n.entropy,a=n.playbackRate;return a>0?s+(e-o):s-(e-o)}},{key:"seekTimeMark",value:function(e){var r=this[kr],n=0,s=r.length-1;if(e<=r[n].entropy)return n;if(e>=r[s].entropy)return s;for(var o=Math.floor((n+s)/2);o>n&&o<s;){if(e===r[o].entropy)return o;e<r[o].entropy?s=o:e>r[o].entropy&&(n=o),o=Math.floor((n+s)/2)}return n}},{key:"updateTimers",value:function(){var e=this,r=[].concat((0,Fc.default)(this[Lr]));r.forEach(function(n){var s=(0,Yd.default)(n,2),o=s[0],a=s[1];e[_i](a.handler,a.time,o)})}},{key:"clearTimeout",value:function(t){function e(r){return t.apply(this,arguments)}return e.toString=function(){return t.toString()},e}(function(t){var e=this[Lr].get(t);e&&e.timerID!=null&&(this[Rr]?this[Rr].clearTimeout(e.timerID):clearTimeout(e.timerID)),this[Lr].delete(t)})},{key:"clearInterval",value:function(e){return this.clearTimeout(e)}},{key:"clear",value:function(){var e=this,r=this[Lr];[].concat((0,Fc.default)(r.keys())).forEach(function(n){e.clearTimeout(n)})}},{key:"setTimeout",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{delay:0};return this[_i](e,r)}},{key:"setInterval",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{delay:0},n=this,s=this[_i](function o(){n[_i](o,r,s),e()},r);return s}},{key:_i,value:function(e,r){var n=this,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:(0,ni.default)("timerID");r=(0,_p.formatDelay)(r);var o=this[Lr].get(s),a=void 0,c=null,l=void 0,u=void 0;o?(this.clearTimeout(s),r.isEntropy?a=(r.delay-(this.entropy-o.startEntropy))/Math.abs(this.playbackRate):a=(r.delay-(this.currentTime-o.startTime))/this.playbackRate,l=o.startTime,u=o.startEntropy):(a=r.delay/(r.isEntropy?Math.abs(this.playbackRate):this.playbackRate),l=this.currentTime,u=this.entropy);var h=this[Rr],d=h?h.setTimeout.bind(h):setTimeout,g=r.heading;return!h&&g===!1&&a<0&&(a=1/0),(isFinite(a)||h)&&(a=Math.ceil(a),d!==setTimeout&&(a={delay:a,heading:g}),c=d(function(){n[Lr].delete(s),e()},a)),this[Lr].set(s,{timerID:c,handler:e,time:r,startTime:l,startEntropy:u}),s}},{key:"parent",get:function(){return this[Rr]}},{key:"lastTimeMark",get:function(){return this[kr][this[kr].length-1]}},{key:"currentTime",get:function(){var e=this.lastTimeMark,r=e.localTime,n=e.globalTime;return r+(this.globalTime-n)*this.playbackRate},set:function(e){var r=this,n=this.currentTime,s=e,o=this[Lr];this.markTime({time:e}),[].concat((0,Fc.default)(o)).forEach(function(a){var c=(0,Yd.default)(a,2),l=c[0],u=c[1];if(o.has(l)){var h=u.time,d=h.isEntropy,g=h.delay,p=h.heading,v=u.handler,I=u.startTime;if(d)g===0&&(v(),r.clearTimeout(l));else{var D=I+g;(g===0||p!==!1&&(s-n)*g<=0||n<=D&&D<=s||n>=D&&D>=s)&&(v(),r.clearTimeout(l))}}}),this.updateTimers()}},{key:"entropy",get:function(){var e=this.lastTimeMark,r=e.entropy,n=e.globalEntropy;return r+Math.abs((this.globalEntropy-n)*this.playbackRate)},set:function(e){if(this.entropy>e){var r=this.seekTimeMark(e);this[kr].length=r+1}this.markTime({entropy:e}),this.updateTimers()}},{key:"globalEntropy",get:function(){return this[Rr]?this[Rr].entropy:this.globalTime}},{key:"playbackRate",get:function(){return this[Wc]},set:function(e){e!==this.playbackRate&&(this.markTime({playbackRate:e}),this[Wc]=e,this.updateTimers())}},{key:"paused",get:function(){if(this.playbackRate===0)return!0;for(var e=this.parent;e;){if(e.playbackRate===0)return!0;e=e.parent}return!1}}]),i}();Ca.default=PT;var Ba={};Object.defineProperty(Ba,"__esModule",{value:!0});Ba.default={default:function(t,e,r,n,s){return typeof t=="number"&&typeof e=="number"?t+(r-n)/(s-n)*(e-t):r-n>s-r?e:t}};var wn={},kT=4,LT=.001,RT=1e-7,OT=10,ms=11,fo=1/(ms-1),zT=typeof Float32Array=="function";function em(i,t){return 1-3*t+3*i}function tm(i,t){return 3*t-6*i}function rm(i){return 3*i}function ea(i,t,e){return((em(t,e)*i+tm(t,e))*i+rm(t))*i}function nm(i,t,e){return 3*em(t,e)*i*i+2*tm(t,e)*i+rm(t)}function jT(i,t,e,r,n){var s,o,a=0;do o=t+(e-t)/2,s=ea(o,r,n)-i,s>0?e=o:t=o;while(Math.abs(s)>RT&&++a<OT);return o}function BT(i,t,e,r){for(var n=0;n<kT;++n){var s=nm(t,e,r);if(s===0)return t;var o=ea(t,e,r)-i;t-=o/s}return t}function UT(i){return i}var FT=function(t,e,r,n){if(!(0<=t&&t<=1&&0<=r&&r<=1))throw new Error("bezier x values must be in [0, 1] range");if(t===e&&r===n)return UT;for(var s=zT?new Float32Array(ms):new Array(ms),o=0;o<ms;++o)s[o]=ea(o*fo,t,r);function a(c){for(var l=0,u=1,h=ms-1;u!==h&&s[u]<=c;++u)l+=fo;--u;var d=(c-s[u])/(s[u+1]-s[u]),g=l+d*fo,p=nm(g,t,r);return p>=LT?BT(c,g,t,r):p===0?g:jT(c,l,l+fo,t,r)}return function(l){return l===0?0:l===1?1:ea(a(l),e,n)}};Object.defineProperty(wn,"__esModule",{value:!0});wn.parseEasing=wn.Easings=void 0;var WT=js,$T=Ju(WT),VT=Aa,im=Ju(VT),YT=jp,GT=Ju(YT);function Ju(i){return i&&i.__esModule?i:{default:i}}var HT=FT,Gd=new GT.default;function Ci(){for(var i=arguments.length,t=Array(i),e=0;e<i;e++)t[e]=arguments[e];var r=Gd.get(t);return r||(r=HT.apply(void 0,t),Gd.set(t,r),r)}function ta(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"end";return function(e,r){for(var n=1;n<r.length;n++){var s=r[n].offset;if(e<=s){var o=r[n-1].offset,a=s,c=(e-o)/(a-o),l=1/i,u=c/l;return t==="end"?u=Math.floor(u):u=Math.ceil(u),l*u*(a-o)+o}}return 0}}function QT(i){var t=/^cubic-bezier\((.*)\)/,e=i.match(t);if(e){var r=e[1].trim();return r=r.split(",").map(function(l){return parseFloat(l.trim())}),Ci.apply(void 0,(0,im.default)(r))}if(t=/^steps\((.*)\)/,e=i.match(t),e){var n=e[1].trim();n=n.split(",").map(function(l){return l.trim()});var s=n,o=(0,$T.default)(s,2),a=o[0],c=o[1];return ta(parseInt(a,10),c)}return i}var Bl={linear:function(t){return t},ease:Ci(.25,.1,.25,1),"ease-in":Ci(.42,0,1,1),"ease-out":Ci(0,0,.58,1),"ease-in-out":Ci(.42,0,.58,1),"step-start":ta(1,"start"),"step-end":ta(1,"end")};function ZT(i){return typeof i=="string"?Bl[i]?i=Bl[i]:i=QT(i):i.type==="cubic-bezier"?i=Ci.apply(void 0,(0,im.default)(i.value)):i.type==="steps"&&(i=ta(i.step,i.pos)),i}wn.Easings=Bl;wn.parseEasing=ZT;var _u={},Hd=tn,KT=Us,qT=Wt("species"),sm=function(i,t){var e=Hd(i).constructor,r;return e===void 0||(r=Hd(e)[qT])==null?t:KT(r)},XT=function(i,t,e){var r=e===void 0;switch(t.length){case 0:return r?i():i.call(e);case 1:return r?i(t[0]):i.call(e,t[0]);case 2:return r?i(t[0],t[1]):i.call(e,t[0],t[1]);case 3:return r?i(t[0],t[1],t[2]):i.call(e,t[0],t[1],t[2]);case 4:return r?i(t[0],t[1],t[2],t[3]):i.call(e,t[0],t[1],t[2],t[3])}return i.apply(e,t)},go=Cn,JT=XT,Qd=Sp,Zd=Du,Hr=Kt,Kd=Hr.process,Ul=Hr.setImmediate,qd=Hr.clearImmediate,Xd=Hr.MessageChannel,$c=Hr.Dispatch,Vc=0,Is={},Jd="onreadystatechange",Dn,Yc,Gc,ys=function(){var i=+this;if(Is.hasOwnProperty(i)){var t=Is[i];delete Is[i],t()}},_d=function(i){ys.call(i.data)};(!Ul||!qd)&&(Ul=function(t){for(var e=[],r=1;arguments.length>r;)e.push(arguments[r++]);return Is[++Vc]=function(){JT(typeof t=="function"?t:Function(t),e)},Dn(Vc),Vc},qd=function(t){delete Is[t]},Bs(Kd)=="process"?Dn=function(i){Kd.nextTick(go(ys,i,1))}:$c&&$c.now?Dn=function(i){$c.now(go(ys,i,1))}:Xd?(Yc=new Xd,Gc=Yc.port2,Yc.port1.onmessage=_d,Dn=go(Gc.postMessage,Gc,1)):Hr.addEventListener&&typeof postMessage=="function"&&!Hr.importScripts?(Dn=function(i){Hr.postMessage(i+"","*")},Hr.addEventListener("message",_d,!1)):Jd in Zd("script")?Dn=function(i){Qd.appendChild(Zd("script"))[Jd]=function(){Qd.removeChild(this),ys.call(i)}}:Dn=function(i){setTimeout(go(ys,i,1),0)});var om={set:Ul},Kn=Kt,_T=om.set,ef=Kn.MutationObserver||Kn.WebKitMutationObserver,Fl=Kn.process,Hc=Kn.Promise,tf=Bs(Fl)=="process",eS=function(){var i,t,e,r=function(){var a,c;for(tf&&(a=Fl.domain)&&a.exit();i;){c=i.fn,i=i.next;try{c()}catch(l){throw i?e():t=void 0,l}}t=void 0,a&&a.enter()};if(tf)e=function(){Fl.nextTick(r)};else if(ef&&!(Kn.navigator&&Kn.navigator.standalone)){var n=!0,s=document.createTextNode("");new ef(r).observe(s,{characterData:!0}),e=function(){s.data=n=!n}}else if(Hc&&Hc.resolve){var o=Hc.resolve(void 0);e=function(){o.then(r)}}else e=function(){_T.call(Kn,r)};return function(a){var c={fn:a,next:void 0};t&&(t.next=c),i||(i=c,e()),t=c}},Ua={},rf=Us;function tS(i){var t,e;this.promise=new i(function(r,n){if(t!==void 0||e!==void 0)throw TypeError("Bad Promise constructor");t=r,e=n}),this.resolve=rf(t),this.reject=rf(e)}Ua.f=function(i){return new tS(i)};var am=function(i){try{return{e:!1,v:i()}}catch(t){return{e:!0,v:t}}},rS=Kt,nf=rS.navigator,nS=nf&&nf.userAgent||"",iS=tn,sS=Ar,oS=Ua,cm=function(i,t){if(iS(i),sS(t)&&t.constructor===i)return t;var e=oS.f(i),r=e.resolve;return r(t),e.promise},aS=xv,vn=Kt,bi=Cn,cS=Ea,nr=qt,lS=Ar,uS=Us,hS=Fu,sf=$s,dS=sm,lm=om.set,um=eS(),hm=Ua,Wl=am,fS=nS,gS=cm,xn="Promise",dm=vn.TypeError,zi=vn.process,of=zi&&zi.versions,pS=of&&of.v8||"",br=vn[xn],Ns=cS(zi)=="process",Go=function(){},po,fm,af,eh,Ds=fm=hm.f,Fa=!!function(){try{var i=br.resolve(1),t=(i.constructor={})[Wt("species")]=function(e){e(Go,Go)};return(Ns||typeof PromiseRejectionEvent=="function")&&i.then(Go)instanceof t&&pS.indexOf("6.6")!==0&&fS.indexOf("Chrome/66")===-1}catch{}}(),gm=function(i){var t;return lS(i)&&typeof(t=i.then)=="function"?t:!1},th=function(i,t){if(!i._n){i._n=!0;var e=i._c;um(function(){for(var r=i._v,n=i._s==1,s=0,o=function(a){var c=n?a.ok:a.fail,l=a.resolve,u=a.reject,h=a.domain,d,g,p;try{c?(n||(i._h==2&&yS(i),i._h=1),c===!0?d=r:(h&&h.enter(),d=c(r),h&&(h.exit(),p=!0)),d===a.promise?u(dm("Promise-chain cycle")):(g=gm(d))?g.call(d,l,u):l(d)):u(r)}catch(v){h&&!p&&h.exit(),u(v)}};e.length>s;)o(e[s++]);i._c=[],i._n=!1,t&&!i._h&&mS(i)})}},mS=function(i){lm.call(vn,function(){var t=i._v,e=cf(i),r,n,s;if(e&&(r=Wl(function(){Ns?zi.emit("unhandledRejection",t,i):(n=vn.onunhandledrejection)?n({promise:i,reason:t}):(s=vn.console)&&s.error&&s.error("Unhandled promise rejection",t)}),i._h=Ns||cf(i)?2:1),i._a=void 0,e&&r.e)throw r.v})},cf=function(i){return i._h!==1&&(i._a||i._c).length===0},yS=function(i){lm.call(vn,function(){var t;Ns?zi.emit("rejectionHandled",i):(t=vn.onrejectionhandled)&&t({promise:i,reason:i._v})})},Ri=function(i){var t=this;t._d||(t._d=!0,t=t._w||t,t._v=i,t._s=2,t._a||(t._a=t._c.slice()),th(t,!0))},$l=function(i){var t=this,e;if(!t._d){t._d=!0,t=t._w||t;try{if(t===i)throw dm("Promise can't be resolved itself");(e=gm(i))?um(function(){var r={_w:t,_d:!1};try{e.call(i,bi($l,r,1),bi(Ri,r,1))}catch(n){Ri.call(r,n)}}):(t._v=i,t._s=1,th(t,!1))}catch(r){Ri.call({_w:t,_d:!1},r)}}};Fa||(br=function(t){hS(this,br,xn,"_h"),uS(t),po.call(this);try{t(bi($l,this,1),bi(Ri,this,1))}catch(e){Ri.call(this,e)}},po=function(t){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},po.prototype=Uu(br.prototype,{then:function(t,e){var r=Ds(dS(this,br));return r.ok=typeof t=="function"?t:!0,r.fail=typeof e=="function"&&e,r.domain=Ns?zi.domain:void 0,this._c.push(r),this._a&&this._a.push(r),this._s&&th(this,!1),r.promise},catch:function(i){return this.then(void 0,i)}}),af=function(){var i=new po;this.promise=i,this.resolve=bi($l,i,1),this.reject=bi(Ri,i,1)},hm.f=Ds=function(i){return i===br||i===eh?new af(i):fm(i)});nr(nr.G+nr.W+nr.F*!Fa,{Promise:br});Ws(br,xn);Pp(xn);eh=At[xn];nr(nr.S+nr.F*!Fa,xn,{reject:function(t){var e=Ds(this),r=e.reject;return r(t),e.promise}});nr(nr.S+nr.F*aS,xn,{resolve:function(t){return gS(this===eh?br:this,t)}});nr(nr.S+nr.F*!(Fa&&Ap()(function(i){br.all(i).catch(Go)})),xn,{all:function(t){var e=this,r=Ds(e),n=r.resolve,s=r.reject,o=Wl(function(){var a=[],c=0,l=1;sf(t,!1,function(u){var h=c++,d=!1;a.push(void 0),l++,e.resolve(u).then(function(g){d||(d=!0,a[h]=g,--l||n(a))},s)}),--l||n(a)});return o.e&&s(o.v),r.promise},race:function(t){var e=this,r=Ds(e),n=r.reject,s=Wl(function(){sf(t,!1,function(o){e.resolve(o).then(r.resolve,n)})});return s.e&&n(s.v),r.promise}});var Qc=qt,vS=At,MS=Kt,wS=sm,lf=cm;Qc(Qc.P+Qc.R,"Promise",{finally:function(i){var t=wS(this,vS.Promise||MS.Promise),e=typeof i=="function";return this.then(e?function(r){return lf(t,i()).then(function(){return r})}:i,e?function(r){return lf(t,i()).then(function(){throw r})}:i)}});var uf=qt,TS=Ua,SS=am;uf(uf.S,"Promise",{try:function(i){var t=TS.f(this),e=SS(i);return(e.e?t.reject:t.resolve)(e.v),t.promise}});var IS=At.Promise,pm={default:IS,__esModule:!0},Zc=qt,CS=At,bS=ti,xS=function(i,t){var e=(CS.Object||{})[i]||Object[i],r={};r[i]=t(e),Zc(Zc.S+Zc.F*bS(function(){e(1)}),"Object",r)},ES=Wi,AS=Fi;xS("keys",function(){return function(t){return AS(ES(t))}});var NS=At.Object.keys,DS={default:NS,__esModule:!0},si={},PS=ur,kS=Fi,LS=ei,RS=$i.f,OS=function(i){return function(t){for(var e=LS(t),r=kS(e),n=r.length,s=0,o=[],a;n>s;)a=r[s++],(!PS||RS.call(e,a))&&o.push(i?[a,e[a]]:e[a]);return o}},hf=qt,zS=OS(!0);hf(hf.S,"Object",{entries:function(t){return zS(t)}});var jS=At.Object.entries,BS={default:jS,__esModule:!0};Object.defineProperty(si,"__esModule",{value:!0});var US=js,FS=Gs(US),WS=BS,$S=Gs(WS),VS=Yu,mm=Gs(VS),YS=pm,GS=Gs(YS);si.defer=KS;si.periodicity=qS;si.calculateFramesOffset=XS;si.getProgress=JS;si.getCurrentFrame=eI;var HS=wn,QS=Ba,ZS=Gs(QS);function Gs(i){return i&&i.__esModule?i:{default:i}}function KS(){var i={};return i.promise=new GS.default(function(t,e){i.resolve=t,i.reject=e}),i}function qS(i,t){var e=Math.floor(i/t),r=i-e*t;return r===0&&e>0&&(r=t,e--),[e,r]}function XS(i){i=i.slice(0);var t=i[0],e=i[i.length-1];e.offset=e.offset||1,t.offset=t.offset||0;for(var r=0,n=-1,s=0;s<i.length;s++){var o=i[s];if(o.offset!=null){var a=s-n;if(a>1)for(var c=(o.offset-r)/a,l=0;l<a-1;l++)i[n+l+1].offset=r+c*(l+1);r=o.offset,n=s}if(o.easing!=null&&(o.easing=(0,HS.parseEasing)(o.easing)),s>0){var u=i[s].easing!=null;i[s]=(0,mm.default)({},i[s-1],i[s]),u||delete i[s].easing}}return i}function JS(i,t,e){var r=i.currentTime,n=t.direction,s=t.duration,o=!1;if(n==="reverse")e=1-e,o=!0;else if(n==="alternate"||n==="alternate-reverse"){var a=Math.floor(r/s);e===1&&a--,a%2^n==="alternate-reverse"&&(e=1-e,o=!0)}return{p:e,inverted:o}}function _S(i,t,e,r){var n={};return(0,$S.default)(t).forEach(function(s){var o=(0,FS.default)(s,2),a=o[0],c=o[1];if(a!=="offset"&&a!=="easing"){var l=e[a]||e.default,u=l(i[a],c,r,i.offset,t.offset);u!=null&&(n[a]=u)}}),n}function eI(i,t,e,r){var n=i.easing,s=i.effect;s||(e=(0,mm.default)({},ZS.default,e));var o={};r=n(r,t);for(var a=1;a<t.length;a++){var c=t[a],l=c.offset;if(l>=r||a===t.length-1){var u=t[a-1],h=u.offset,d=u.easing,g=r;if(d){var p=l-h;g=d((r-h)/p)*p+h}s?o=s(u,c,g,h,l):o=_S(u,c,e,g);break}}return o}Object.defineProperty(_u,"__esModule",{value:!0});var tI=pm,Kc=oi(tI),rI=DS,nI=oi(rI),iI=Yu,es=oi(iI),sI=Pa,oI=oi(sI),aI=ka,cI=oi(aI),lI=Jp,rn=oi(lI),uI=Ca,hI=oi(uI),nn=si,dI=wn;function oi(i){return i&&i.__esModule?i:{default:i}}var Ot=(0,rn.default)("timing"),Or=(0,rn.default)("keyframes"),ts=(0,rn.default)("initState"),Nt=(0,rn.default)("readyDefer"),Xt=(0,rn.default)("finishedDefer"),mo=(0,rn.default)("effects"),yo=(0,rn.default)("activeReadyTimer"),qc=(0,rn.default)("activeFinishTimer"),zr=(0,rn.default)("removeDefer"),fI={delay:0,endDelay:0,fill:"auto",iterations:1,playbackRate:1,direction:"normal",easing:"linear",effect:null},gI=function(){function i(t,e,r){var n=this;if((0,oI.default)(this,i),Array.isArray(t)){var s=[t[0],t,e];t=s[0],e=s[1],r=s[2]}typeof r=="number"&&(r={duration:r}),this[Ot]=(0,es.default)({},fI,r),this[Ot].easing=(0,dI.parseEasing)(this[Ot].easing),this[Or]=(0,nn.calculateFramesOffset)(e);var o=this[Or][this[Or].length-1];this[ts]={},(0,nI.default)(o).forEach(function(a){Object.prototype.hasOwnProperty.call(t,a)&&a!=="easing"&&a!=="offset"&&(n[ts][a]=t[a])}),this[Or]=this[Or].map(function(a){return(0,es.default)({},n[ts],a)}),this[Or][0].offset!==0&&this[Or].unshift((0,es.default)({},this[ts],{offset:0})),o.offset<1&&this[Or].push((0,es.default)({},o,{offset:1})),this[mo]={},this.timeline=null}return(0,cI.default)(i,[{key:"pause",value:function(){this.timeline.playbackRate=0}},{key:yo,value:function(){var e=this;this[Nt]&&!this[Nt].timerID&&(this.timeline.currentTime<0?this[Nt].timerID=this.timeline.setTimeout(function(){e[Nt].resolve(),delete e[Nt]},{delay:-this.timeline.currentTime,heading:!1}):this[Nt].timerID=this.timeline.setTimeout(function(){e[Nt].resolve(),delete e[Nt]},{delay:0,isEntropy:!0}))}},{key:qc,value:function(){var e=this,r=this[Ot],n=r.duration,s=r.iterations,o=r.endDelay,a=Math.ceil(n*s+o-this.timeline.currentTime)+1;this[Xt]&&!this[Xt].timerID&&(this[Xt].timerID=this.timeline.setTimeout(function(){e[Xt].resolve(),e[zr](Nt),e[zr](Xt)},{delay:a,heading:!1}),this[Xt].reverseTimerID=this.timeline.setTimeout(function(){e[Xt].resolve(),e[zr](Nt),e[zr](Xt),e.timeline=null},{delay:-this[Ot].delay-1,heading:!1}))}},{key:"play",value:function(){if(this.playState==="finished"&&this.cancel(),this.playState==="idle"){if(this.playbackRate<=0)return;var e=this[Ot],r=e.delay,n=e.playbackRate,s=e.timeline;this.timeline=new hI.default({originTime:r,playbackRate:n},s),this[yo](),this[qc]()}else this.playState==="paused"&&(this.timeline.playbackRate=this.playbackRate,this[yo]())}},{key:zr,value:function(e){var r=this[e],n=this.timeline;r&&n&&(n.clearTimeout(r.timerID),r.reverseTimerID&&n.clearTimeout(r.reverseTimerID)),delete this[e]}},{key:"cancel",value:function(){this[zr](Nt),this[zr](Xt),this.timeline=null}},{key:"finish",value:function(){this.timeline&&(this.timeline.currentTime=1/0/this.playbackRate),this[zr](Nt),this[zr](Xt)}},{key:"applyEffects",value:function(e){return(0,es.default)(this[mo],e)}},{key:"playbackRate",get:function(){return this[Ot].playbackRate},set:function(e){this.timeline&&(this.timeline.playbackRate=e),this[Ot].playbackRate=e}},{key:"playState",get:function(){var e=this.timeline,r=this[Ot],n=r.iterations,s=r.duration,o=r.endDelay,a="running";if(e==null)a="idle";else if(e.paused)a="paused";else if(e.currentTime<0)a="pending";else{var c=e.currentTime-n*s;c>0&&c<o?a="pending":c>=o&&(a="finished")}return a}},{key:"progress",get:function(){if(!this.timeline)return 0;var e=this[Ot],r=e.duration,n=e.iterations,s=this.timeline,o=this.playState,a=void 0;if(o==="idle")a=0;else if(o==="paused"&&s.currentTime<0)a=0;else if(o==="pending")if(s.currentTime<0)a=0;else{var c=s.seekLocalTime(n*r);a=(0,nn.periodicity)(c,r)[1]/r}else(o==="running"||o==="paused")&&(a=(0,nn.periodicity)(s.currentTime,r)[1]/r);return o==="finished"&&(a=(0,nn.periodicity)(n,1)[1]),a}},{key:"frame",get:function(){var e=this.playState,r=this[ts],n=this[Ot].fill;if(e==="idle")return r;var s=this.timeline.currentTime,o=this[Or].slice(0),a=(0,nn.getProgress)(this.timeline,this[Ot],this.progress),c=a.p,l=a.inverted,u=r;return s<0&&e==="pending"?(n==="backwards"||n==="both")&&(u=l?o[o.length-1]:o[0]):(e!=="pending"&&e!=="finished"||n==="forwards"||n==="both")&&(u=(0,nn.getCurrentFrame)(this[Ot],o,this[mo],c)),u}},{key:"timing",get:function(){return this[Ot]}},{key:"effects",get:function(){return this[mo]}},{key:"baseTimeline",set:function(e){this[Ot].timeline=e},get:function(){return this[Ot].timeline}},{key:"ready",get:function(){return this[Nt]?this[Nt].promise:this.timeline&&this.timeline.currentTime>=0&&this.playState!=="paused"?Kc.default.resolve():(this[Nt]=(0,nn.defer)(),this.timeline&&this[yo](),this[Nt]?this[Nt].promise:Kc.default.resolve())}},{key:"finished",get:function(){return this.playState==="finished"?Kc.default.resolve():(this[Xt]||(this[Xt]=(0,nn.defer)(),this.timeline&&this[qc]()),this[Xt].promise)}}]),i}();_u.default=gI;Object.defineProperty(Gr,"__esModule",{value:!0});var ym=Gr.Timeline=Mr=Gr.Effects=Gr.Easings=vm=Gr.Animator=void 0,pI=Ca,mI=rh(pI),yI=Ba,vI=rh(yI),MI=wn,wI=_u,TI=rh(wI);function rh(i){return i&&i.__esModule?i:{default:i}}var vm=Gr.Animator=TI.default;Gr.Easings=MI.Easings;var Mr=Gr.Effects=vI.default;ym=Gr.Timeline=mI.default;var SI={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};const df=en(SI);var ff={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};function II(i){var t,e=[],r=1,n;if(typeof i=="string")if(i=i.toLowerCase(),df[i])e=df[i].slice(),n="rgb";else if(i==="transparent")r=0,n="rgb",e=[0,0,0];else if(/^#[A-Fa-f0-9]+$/.test(i)){var s=i.slice(1),o=s.length,a=o<=4;r=1,a?(e=[parseInt(s[0]+s[0],16),parseInt(s[1]+s[1],16),parseInt(s[2]+s[2],16)],o===4&&(r=parseInt(s[3]+s[3],16)/255)):(e=[parseInt(s[0]+s[1],16),parseInt(s[2]+s[3],16),parseInt(s[4]+s[5],16)],o===8&&(r=parseInt(s[6]+s[7],16)/255)),e[0]||(e[0]=0),e[1]||(e[1]=0),e[2]||(e[2]=0),n="rgb"}else if(t=/^((?:rgb|hs[lvb]|hwb|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms)a?)\s*\(([^\)]*)\)/.exec(i)){var c=t[1],l=c==="rgb",s=c.replace(/a$/,"");n=s;var o=s==="cmyk"?4:s==="gray"?1:3;e=t[2].trim().split(/\s*[,\/]\s*|\s+/).map(function(d,g){if(/%$/.test(d))return g===o?parseFloat(d)/100:s==="rgb"?parseFloat(d)*255/100:parseFloat(d);if(s[g]==="h"){if(/deg$/.test(d))return parseFloat(d);if(ff[d]!==void 0)return ff[d]}return parseFloat(d)}),c===s&&e.push(1),r=l||e[o]===void 0?1:e[o],e=e.slice(0,o)}else i.length>10&&/[0-9](?:\s|\/)/.test(i)&&(e=i.match(/([0-9]+)/g).map(function(u){return parseFloat(u)}),n=i.match(/([a-z])/ig).join("").toLowerCase());else isNaN(i)?Array.isArray(i)||i.length?(e=[i[0],i[1],i[2]],n="rgb",r=i.length===4?i[3]:1):i instanceof Object&&(i.r!=null||i.red!=null||i.R!=null?(n="rgb",e=[i.r||i.red||i.R||0,i.g||i.green||i.G||0,i.b||i.blue||i.B||0]):(n="hsl",e=[i.h||i.hue||i.H||0,i.s||i.saturation||i.S||0,i.l||i.lightness||i.L||i.b||i.brightness]),r=i.a||i.alpha||i.opacity||1,i.opacity!=null&&(r/=100)):(n="rgb",e=[i>>>16,(i&65280)>>>8,i&255]);return{space:n,values:e,alpha:r}}const Vl={min:[0,0,0],max:[255,255,255]};var Xc={name:"hsl",min:[0,0,0],max:[360,100,100],channel:["hue","saturation","lightness"],alias:["HSL"],rgb:function(i){var t=i[0]/360,e=i[1]/100,r=i[2]/100,n,s,o,a,c,l=0;if(e===0)return c=r*255,[c,c,c];for(s=r<.5?r*(1+e):r+e-r*e,n=2*r-s,a=[0,0,0];l<3;)o=t+1/3*-(l-1),o<0?o++:o>1&&o--,c=6*o<1?n+(s-n)*6*o:2*o<1?s:3*o<2?n+(s-n)*(2/3-o)*6:n,a[l++]=c*255;return a}};Vl.hsl=function(i){var t=i[0]/255,e=i[1]/255,r=i[2]/255,n=Math.min(t,e,r),s=Math.max(t,e,r),o=s-n,a,c,l;return s===n?a=0:t===s?a=(e-r)/o:e===s?a=2+(r-t)/o:r===s&&(a=4+(t-e)/o),a=Math.min(a*60,360),a<0&&(a+=360),l=(n+s)/2,s===n?c=0:l<=.5?c=o/(s+n):c=o/(2-s-n),[a,c*100,l*100]};function Yl(i){Array.isArray(i)&&i.raw&&(i=String.raw(...arguments));var t,e=II(i);if(!e.space)return[];const r=e.space[0]==="h"?Xc.min:Vl.min,n=e.space[0]==="h"?Xc.max:Vl.max;return t=Array(3),t[0]=Math.min(Math.max(e.values[0],r[0]),n[0]),t[1]=Math.min(Math.max(e.values[1],r[1]),n[1]),t[2]=Math.min(Math.max(e.values[2],r[2]),n[2]),e.space[0]==="h"&&(t=Xc.rgb(t)),t.push(Math.min(Math.max(e.alpha,0),1)),t}qe(Array);function CI(){if(typeof performance<"u"&&performance.now)return performance.now();if(typeof process<"u"&&process.hrtime){const[i,t]=process.hrtime();return i*1e3+t*1e-6}return Date.now?Date.now():new Date().getTime()}let Qr,qn;typeof global<"u"&&typeof global.requestAnimationFrame=="function"?(Qr=global.requestAnimationFrame,qn=global.cancelAnimationFrame):(Qr=function(i){return setTimeout(()=>{i(CI())},16)},qn=function(i){return clearTimeout(i)});qe(Array);function gf(i){if(typeof i=="string"){if(i=i.trim(),/^[0-9.]+%$/.test(i))return parseFloat(i)/100;if(/^([\d.]+)(px|pt|pc|in|cm|mm|em|ex|rem|q|vw|vh|vmax|vmin)$/.test(i))return xu(i)}return i}function Wa(i,t,e,r,n){return typeof i=="string"&&(i=Yl(i)),typeof t=="string"&&(t=Yl(t)),Mr.default(i,t,e,r,n)}function bI(i,t,e,r,n){return Mr.default(i,t,e,r,n)}Mr.default=function(i,t,e,r,n){return Array.isArray(i)&&Array.isArray(t)?i.map((s,o)=>s+(e-r)/(n-r)*(t[o]-s)):typeof i=="number"&&typeof t=="number"?i+(e-r)/(n-r)*(t-i):e-r>n-e?t:i};Mr.fillColor=Wa;Mr.strokeColor=Wa;Mr.bgcolor=Wa;Mr.borderColor=Wa;Mr.text=bI;class xI extends vm{constructor(t,e,r){const n=t.attr();Object.entries(n).forEach(([s,o])=>{n[s]=Mr[s]?o:gf(o)}),e=e.map(({...s})=>{const o={};return Object.entries(s).forEach(([a,c])=>{o[a]=Mr[a]?c:gf(c)}),o}),super(n,e,r),this.target=t,this.setter=function(s,o){o.attr(s)}}get playState(){return this.target.parent?super.playState:"idle"}get finished(){return super.finished.then(()=>{const t=this;return new Promise(e=>{function r(){t.setter(t.frame,t.target);const n=t.playState;n==="finished"||n==="idle"?(qn(t.requestId),e()):Qr(r)}r()})})}finish(){super.finish(),qn(this.requestId),this.setter(this.frame,this.target)}play(){if(!this.target.parent||this.playState==="running")return;super.play(),this.setter(this.frame,this.target);const t=this;this.ready.then(()=>{t.setter(t.frame,t.target),t.requestId=Qr(function e(){const r=t.target;if(typeof document<"u"&&document.documentElement&&document.documentElement.contains&&r.layer&&r.layer.canvas&&!document.documentElement.contains(r.layer.canvas)){t.cancel();return}const n=t.playState;t.setter(t.frame,t.target),n!=="idle"&&(n==="running"?t.requestId=Qr(e):(n==="paused"||n==="pending"&&t.timeline.currentTime<0)&&t.ready.then(()=>{t.setter(t.frame,t.target),t.requestId=Qr(e)}))})})}cancel(t=!1){qn(this.requestId),t?(this.setter(this.frame,this.target),super.cancel()):(super.cancel(),this.setter(this.frame,this.target))}}qe(Array);const Ho=new Map;function pf(i,t={},e=[]){i=i.toLowerCase();const r=Ho.get(i);if(!r)throw new TypeError(`Invalid node: ${i}`);const n=new r(t);return e.forEach(s=>{n.appendChild(s)}),n}const $t={registerNode(i,t,e=100){if(t=t.toLowerCase(),Ho.has(t))throw new TypeError(`Cannot registerNode, ${t} has been taken.`);Ho.set(t,i),Object.defineProperties(i.prototype,{nodeType:{value:e},tagName:{value:t.toUpperCase()},nodeName:{value:t},ownerDocument:{value:$t},namespaceURI:{value:`http://spritejs.com/${t}`}})},createElement:pf,createElementNS(i,t){return pf(t)},isSpriteNode(i){return Ho.has(i.toLowerCase())}};qe(Array);const vo=Symbol("type"),Jc=Symbol("bubbles"),_c=Symbol("originalEvent"),mf=Symbol("detail");class Xn{constructor(t,{bubbles:e=null}={}){if(typeof t=="string"?(this[vo]=t,this[Jc]=!!e):(this[vo]=t.type,this[_c]=t,this[Jc]=e!=null?!!e:!!t.bubbles,t.detail&&(this[mf]=t.detail)),!this[vo])throw new TypeError("Invalid event type.");this.cancelBubble=!1}setOriginalEvent(t){this[_c]=t}get originalEvent(){return this[_c]}get type(){return this[vo]}get bubbles(){return this[Jc]}get detail(){return this[mf]}stopPropagation(){this.cancelBubble=!0}}qe(Array);function EI(i){if(i=i.trim(),!i||i==="none")return null;const t=/^(?:(url|blur|brightness|contrast|drop-shadow|grayscale|hue-rotate|invert|opacity|saturate|sepia)\(([^()]*(?:\(.*\))*[^()]*)\))+$/i,e=i.match(/(?:(url|blur|brightness|contrast|drop-shadow|grayscale|hue-rotate|invert|opacity|saturate|sepia)\(([^()]*(?:\(.*\))*[^()]*)\))+?/ig),r=[];return e&&e.forEach(n=>{const s=n.match(t);if(!s)throw new TypeError("Invalid fitler string.");let[,o,a]=s;o=o.toLowerCase(),a=a.trim().match(/([^( )]+|([^( )]+\(.*\)))(?=\s|$)/g).map((c,l)=>{let u;return o==="url"||o==="drop-shadow"&&l===3?u=c:u=Qe(c),/%$/.test(c)&&(u/=100),u}),r.push({type:o,args:a})}),r}function AI(i,t){i.clearFilter(),t&&t.forEach(({type:e,args:r})=>{let n=e;n==="drop-shadow"?n="dropShadow":n==="hue-rotate"&&(n="hueRotate"),i[n](...r)})}qe(Array);function NI(i,t){if(!t)return;const e=i.getListeners("beforerender"),r=i.getListeners("afterrender");e.length&&!t.beforeRender?t.beforeRender=n=>{i.dispatchEvent({type:"beforerender",detail:{context:n}})}:e.length||(t.beforeRender=null),r.length&&!t.afterRender?t.afterRender=n=>{i.dispatchEvent({type:"afterrender",detail:{context:n}})}:r.length||(t.afterRender=null)}qe(Array);const DI=Symbol.for("spritejs_changedAttrs"),PI=Symbol.for("spritejs_attributes"),Mo=Symbol("resolution"),pi=Symbol("animations"),Pn=Symbol("eventListeners"),kn=Symbol("captureEventListeners"),yf=Symbol("filters"),vf=Symbol("display"),wo=Symbol("program"),rs=Symbol("shaderAttrs"),mi=Symbol("uniforms"),To=Symbol("mask");var Tl;let $a=(Tl=class{constructor(t={}){this.attributes=new this.constructor.Attr(this),this[Mo]={width:300,height:150},Object.assign(this.attributes,t),this[pi]=new Set,this[Pn]={},this[kn]={}}get ancestors(){let t=this.parent;const e=[];for(;t;)e.push(t),t=t.parent;return e}get animations(){return this[pi]}get filters(){return this[yf]||this.parent&&this.parent.filters}get isVisible(){return!1}get layer(){return this.parent?this.parent.layer:null}get localMatrix(){const t=this.transformMatrix,{x:e,y:r}=this.attributes;return t[4]+=e,t[5]+=r,t}get opacity(){let t=this.attributes.opacity;return this.parent&&this.parent.opacity!=null&&(t*=this.parent.opacity),t}get mask(){return this[To]?{...this[To],owner:this}:this.parent&&this.parent.mask}get parentNode(){return this.parent}get nextSibling(){return this.getNodeNearBy(1)}get previousSibling(){return this.getNodeNearBy(-1)}get program(){return this[wo]}get renderer(){return this.parent?this.parent.renderer:null}get renderMatrix(){if(this.__cacheRenderMatrix)return this.__cacheRenderMatrix;let t=this.localMatrix;const e=this.parent;if(e){const r=e.__cacheRenderMatrix||e.renderMatrix;r&&(t=Er(Array.of(0,0,0,0,0,0),r,t))}return t}get worldScaling(){const t=this.renderMatrix;return[Math.hypot(t[0],t[1]),Math.hypot(t[2],t[3])]}get worldRotation(){const t=this.renderMatrix;return Math.atan2(t[1],t[3])}get worldPosition(){const t=this.renderMatrix;return[t[4],t[5]]}get uniforms(){return this[mi]}get className(){return this.attributes.className}set className(t){this.attributes.className=t}get id(){return this.attributes.id}set id(t){this.attributes.id=t}get name(){return this.attributes.name}set name(t){this.attributes.name=t}get zIndex(){return this.attributes.zIndex}set zIndex(t){this.attributes.zIndex=t}get mesh(){return null}get shaderAttrs(){return this[rs]||{}}activateAnimations(){const t=this.layer;if(t){const e=this[pi];e.forEach(n=>{n.baseTimeline=t.timeline,n.play(),n.finished.then(()=>{e.delete(n)})});const r=this.children;r&&r.forEach(n=>{n.activateAnimations&&n.activateAnimations()})}}addEventListener(t,e,r={}){t==="mousewheel"&&(t="wheel"),typeof r=="boolean"&&(r={capture:r});const{capture:n,once:s}=r,o=n?kn:Pn;return this[o][t]=this[o][t]||[],this[o][t].push({listener:e,once:s}),this}animate(t,e){const r=new xI(this,t,e);return this.effects&&r.applyEffects(this.effects),this.layer&&(r.baseTimeline=this.layer.timeline,r.play(),r.finished.then(()=>{this[pi].delete(r)})),this[pi].add(r),r}attr(...t){if(t.length===0)return this.attributes[PI];if(t.length>1){let[e,r]=t;return typeof r=="function"&&(r=r(this.attr(e))),this.setAttribute(e,r),this}return typeof t[0]=="string"?this.getAttribute(t[0]):(Object.assign(this.attributes,t[0]),this)}cloneNode(){const t=new this.constructor,e=this.attributes[DI];return t.attr(e),t}connect(t,e){Object.defineProperty(this,"parent",{value:t,writable:!1,configurable:!0}),Object.defineProperty(this,"zOrder",{value:e,writable:!1,configurable:!0}),t.timeline&&this.activateAnimations(),this.setResolution(t.getResolution()),this.forceUpdate(),this.dispatchEvent({type:"append",detail:{parent:t,zOrder:e}})}contains(t){for(;t&&this!==t;)t=t.parent;return!!t}deactivateAnimations(){this[pi].forEach(e=>e.cancel());const t=this.children;t&&t.forEach(e=>{e.deactivateAnimations&&e.deactivateAnimations()})}disconnect(){const{parent:t,zOrder:e}=this;delete this.parent,delete this.zOrder,this.deactivateAnimations(),this.dispatchEvent({type:"remove",detail:{parent:t,zOrder:e}}),t&&t.forceUpdate()}dispatchEvent(t){t instanceof Xn||(t=new Xn(t)),t.target=this;let e=t.type;e==="mousewheel"&&(e="wheel");const r=[this];let n=this.parent;for(;t.bubbles&&n;)r.push(n),n=n.parent;for(let s=r.length-1;s>=0;s--){const o=r[s],a=o[kn]&&o[kn][e];if(a&&a.length&&(t.currentTarget=o,a.forEach(({listener:c,once:l})=>{c.call(this,t),l&&r.removeEventListener(c)}),delete t.currentTarget),!t.bubbles&&t.cancelBubble)break}if(!t.cancelBubble)for(let s=0;s<r.length;s++){const o=r[s],a=o[Pn]&&o[Pn][e];if(a&&a.length&&(t.currentTarget=o,a.forEach(({listener:c,once:l})=>{c.call(this,t),l&&r.removeEventListener(c)}),delete t.currentTarget),!t.bubbles||t.cancelBubble)break}}dispatchPointerEvent(t){const{layerX:e,layerY:r}=t;return this.isPointCollision(e,r)?(this.dispatchEvent(t),!0):!1}draw(t=[]){const e=this.mesh;if(e){if(AI(e,this.filters),this._applyMask(e),t.push(e),this[wo]){e.setProgram(this[wo]);const r=this[rs];r&&Object.entries(r).forEach(([s,o])=>{e.setAttribute(s,o)});const n=this[mi];if(this[mi]){const s={};Object.entries(n).forEach(([o,a])=>{typeof a=="function"&&(a=a(this,o)),s[o]=a}),e.setUniforms(s)}}NI(this,e)}return t}forceUpdate(){this.parent&&this.parent.forceUpdate()}getAttribute(t){return this.attributes[t]}getListeners(t,{capture:e=!1}={}){return[...this[e?kn:Pn][t]||[]]}getNodeNearBy(t=1){if(!this.parent)return null;if(t===0)return this;const e=this.parent.children,r=e.indexOf(this);return e[r+t]}getWorldPosition(t,e){const r=this.renderMatrix,n=t*r[0]+e*r[2]+r[4],s=t*r[1]+e*r[3]+r[5];return[n,s]}getOffsetPosition(t,e){const r=Jo(Array.of(0,0,0,0,0,0),this.renderMatrix),n=t*r[0]+e*r[2]+r[4],s=t*r[1]+e*r[3]+r[5];return[n,s]}getResolution(){return{...this[Mo]}}isPointCollision(t,e){if(!this.mesh)return!1;const r=this.attributes.pointerEvents;if(r==="none"||r!=="all"&&!this.isVisible)return!1;let n="both";return r==="visibleFill"&&(n="fill"),r==="visibleStroke"&&(n="stroke"),this.mesh.isPointCollision(t,e,n)}onPropertyChange(t,e,r){t!=="id"&&t!=="name"&&t!=="className"&&t!=="pointerEvents"&&t!=="passEvents"&&this.forceUpdate(),t==="filter"&&(this[yf]=EI(e)),t==="zIndex"&&this.parent&&this.parent.reorder()}setAttribute(t,e){t==="attrs"&&this.attr(e),this.attributes[t]=e}setMouseCapture(){this.layer&&(this.layer.__mouseCapturedTarget=this)}setMask(t,e={}){return t?(this[To]={handle:t,rect:e.rect||t.rect},this.forceUpdate(),this):this.clearMask()}clearMask(){return this[To]=null,this.forceUpdate(),this}_applyMask(t){const e=this.mask,r=this.renderer;if(!e||!r||!r.glRenderer||this.attributes.clipPath){if(t.__spriteMaskApplied){t.setUniforms({u_clipSampler:null});const u=t.meshData;u.attributes&&delete u.attributes.a_clipUV,t.blend=t.__spriteMaskBlend,delete t.__spriteMaskBlend,t.__spriteMaskApplied=!1}return}const n=e.handle.getTexture(r),s=e.rect;if(!n||!s||s[2]<=0||s[3]<=0)return;const o=Jo(Array.of(0,0,0,0,0,0),e.owner.renderMatrix);if(!o)return;const a=Er(Array.of(0,0,0,0,0,0),o,this.renderMatrix);t.setUniforms({u_clipSampler:n});const c=t.meshData,l=c.position0||c.positions;c.attributes=c.attributes||{},c.attributes.a_clipUV=l.map(([u,h])=>{const d=u*a[0]+h*a[2]+a[4],g=u*a[1]+h*a[3]+a[5];return[(d-s[0])/s[2],1-(g-s[1])/s[3]]}),t.__spriteMaskApplied||(t.__spriteMaskBlend=t.blend),t.blend=!0,t.__spriteMaskApplied=!0}setProgram(t){this[wo]=t,this.forceUpdate()}setShaderAttribute(t,e){this[rs]=this[rs]||{},this[rs][t]=e,this.forceUpdate()}setUniforms(t){this[mi]=this[mi]||{},Object.assign(this[mi],t),this.forceUpdate()}setResolution({width:t,height:e}){const{width:r,height:n}=this[Mo];(r!==t||n!==e)&&(this[Mo]={width:t,height:e},this.forceUpdate(),this.dispatchEvent({type:"resolutionchange",detail:{width:t,height:e}}))}show(){this.attributes.display==="none"&&(this.attributes.display=this[vf]||"")}hide(){this.attributes.display!=="none"&&(this[vf]=this.attributes.display,this.attributes.display="none")}releaseMouseCapture(){this.layer&&this.layer.__mouseCapturedTarget===this&&(this.layer.__mouseCapturedTarget=null)}remove(){return this.parent&&this.parent.removeChild?(this.parent.removeChild(this),!0):!1}removeAllListeners(t,e={}){typeof e=="boolean"&&(e={capture:e});const n=e.capture?kn:Pn;return this[n][t]&&(this[n][t]=[]),this}removeAttribute(t){this.setAttribute(t,null)}removeEventListener(t,e,r={}){typeof r=="boolean"&&(r={capture:r});const s=r.capture?kn:Pn;if(this[s][t]){const o=this[s][t];if(o)for(let a=0;a<o.length;a++){const{listener:c}=o[a];if(c===e){this[s][t].splice(a,1);break}}}return this}transition(t,e="linear"){const r=this,n=Symbol("animation");e=e||"linear";let s=0;return typeof t=="object"&&(s=t.delay||0,t=t.duration),{[n]:null,cancel(o=!1){const a=this[n];a&&a.cancel(o)},end(){const o=this[n];o&&(o.playState==="running"||o.playState==="pending")&&o.finish()},reverse(){const o=this[n];if(o)if(o.playState==="running"||o.playState==="pending")o.playbackRate=-o.playbackRate;else{const a=o.timing.direction;o.timing.direction=a==="reverse"?"normal":"reverse",o.play()}return o.finished},attr(o,a){return this.end(),typeof o=="string"&&(o={[o]:a}),Object.entries(o).forEach(([c,l])=>{typeof l=="function"&&(o[c]=l(r.attr(c)))}),this[n]=r.animate([o],{duration:t*1e3,delay:s*1e3,fill:"forwards",easing:e}),this[n].finished}}}updateContours(){}},R(Tl,"Attr",Eu),Tl);$t.registerNode($a,"node");qe(Array);class kI{constructor({vector:t,colors:e}){if(!Array.isArray(t)||t.length!==4&&t.length!==6&&t.length!==3)throw new TypeError("Invalid gradient");this.vector=t,this.colors=e.map(({offset:r,color:n})=>({offset:r,color:Tn(n)}))}toString(){return JSON.stringify({vector:this.vector,colors:this.colors})}}function Tn(i){if(i==null||(i||(i="transparent"),i instanceof kI))return i;const t=Yl(i);if(!t||!t.length)throw new TypeError("Invalid color value.");return`rgba(${t.join()})`}function Mm(i,t,e){const r=i.boundingBox[0];if(e.vector){let{vector:n,colors:s}=e;n.length===4?(n=[n[0]+r[0],n[1]+r[1],n[2]+r[0],n[3]+r[1]],i.setLinearGradient({vector:n,colors:s,type:t})):n.length===3?(n=[n[0]+r[0],n[1]+r[1],n[2]],i.setCircularGradient({vector:n,colors:s,type:t})):(n=[n[0]+r[0],n[1]+r[1],n[2],n[3]+r[0],n[4]+r[1],n[5]],i.setRadialGradient({vector:n,colors:s,type:t}))}else i.gradient&&i.gradient[t]&&(delete i.gradient[t],delete i.uniforms.u_radialGradientVector)}function ra(i,{color:t,rule:e="nonzero"}){return Mm(i,"fill",t),t.vector||i.setFill({color:t,rule:e}),i}function na(i,{color:t,lineWidth:e,lineCap:r,lineJoin:n,lineDash:s,lineDashOffset:o,miterLimit:a,roundSegments:c}){Mm(i,"stroke",t),t.vector&&(t=[0,0,0,1]),i.setStroke({color:t,thickness:e,cap:r,join:n,miterLimit:a,lineDash:s,lineDashOffset:o,roundSegments:c})}qe(Array);const Mt=Symbol.for("spritejs_setAttribute"),wt=Symbol.for("spritejs_getAttribute"),LI=Symbol.for("spritejs_setAttributeDefault"),RI=Symbol.for("spritejs_declareAlias");let Va=class extends Eu{constructor(t){super(t),this[LI]({anchorX:0,anchorY:0,width:void 0,height:void 0,borderWidth:0,borderColor:"rgba(0,0,0,1)",borderDash:void 0,borderDashOffset:0,borderTopLeftRadius:[0,0],borderTopRightRadius:[0,0],borderBottomRightRadius:[0,0],borderBottomLeftRadius:[0,0],bgcolor:"rgba(0,0,0,0)",paddingTop:0,paddingRight:0,paddingBottom:0,paddingLeft:0,boxSizing:"content-box",clipPath:void 0}),this[RI]("anchor","size","border","borderRadius","padding")}get anchorX(){return this[wt]("anchorX")}set anchorX(t){this[Mt]("anchorX",Qe(t))}get anchorY(){return this[wt]("anchorY")}set anchorY(t){this[Mt]("anchorY",Qe(t))}get anchor(){return[this.anchorX,this.anchorY]}set anchor(t){t=mt(t),Array.isArray(t)||(t=[t,t]),this.anchorX=t[0],this.anchorY=t[1]}get width(){return this[wt]("width")}set width(t){this[Mt]("width",Qe(t))}get height(){return this[wt]("height")}set height(t){this[Mt]("height",Qe(t))}get size(){return[this.width,this.height]}set size(t){t=mt(t),Array.isArray(t)||(t=[t,t]),this.width=t[0],this.height=t[1]}get borderWidth(){return this[wt]("borderWidth")}set borderWidth(t){this[Mt]("borderWidth",Qe(t))}get borderColor(){return this[wt]("borderColor")}set borderColor(t){this[Mt]("borderColor",Tn(t))}get border(){return[this.borderWidth,this.borderColor]}set border(t){t=mt(t),Array.isArray(t)||(t=[t]),this.borderWidth=t[0],t[1]!=null&&(this.borderColor=t[1])}get borderDash(){return this[wt]("borderDash")}set borderDash(t){t=mt(t,!0),t!=null&&!Array.isArray(t)&&(t=[t]),this[Mt]("borderDash",t?t.map(Qe):null)}get borderDashOffset(){return this[wt]("borderDashOffset")}set borderDashOffset(t){this[Mt]("borderDashOffset",Qe(t))}get borderTopLeftRadius(){return this[wt]("borderTopLeftRadius")}set borderTopLeftRadius(t){t=mt(t,!0),Array.isArray(t)||(t=[t,t]),this[Mt]("borderTopLeftRadius",t.map(Qe))}get borderTopRightRadius(){return this[wt]("borderTopRightRadius")}set borderTopRightRadius(t){t=mt(t,!0),Array.isArray(t)||(t=[t,t]),this[Mt]("borderTopRightRadius",t.map(Qe))}get borderBottomRightRadius(){return this[wt]("borderBottomRightRadius")}set borderBottomRightRadius(t){t=mt(t,!0),Array.isArray(t)||(t=[t,t]),this[Mt]("borderBottomRightRadius",t.map(Qe))}get borderBottomLeftRadius(){return this[wt]("borderBottomLeftRadius")}set borderBottomLeftRadius(t){t=mt(t,!0),Array.isArray(t)||(t=[t,t]),this[Mt]("borderBottomLeftRadius",t.map(Qe))}get borderRadius(){return[...this.borderTopLeftRadius,...this.borderTopRightRadius,...this.borderBottomRightRadius,...this.borderBottomLeftRadius]}set borderRadius(t){if(t=mt(t),!Array.isArray(t))t=Array(8).fill(t);else if(t.length===2)t=[t[0],t[1],t[0],t[1],t[0],t[1],t[0],t[1]];else if(t.length===4)t=[t[0],t[1],t[2],t[3],t[0],t[1],t[2],t[3]];else if(t.length===6)t=[t[0],t[1],t[2],t[3],t[4],t[5],t[2],t[3]];else if(t.length!==8)throw new TypeError("Invalid borderRadius value.");this.borderTopLeftRadius=[t[0],t[1]],this.borderTopRightRadius=[t[2],t[3]],this.borderBottomRightRadius=[t[4],t[5]],this.borderBottomLeftRadius=[t[6],t[7]]}get bgcolor(){return this[wt]("bgcolor")}set bgcolor(t){this[Mt]("bgcolor",Tn(t))}get paddingTop(){return this[wt]("paddingTop")}set paddingTop(t){this[Mt]("paddingTop",Qe(t))}get paddingRight(){return this[wt]("paddingRight")}set paddingRight(t){this[Mt]("paddingRight",Qe(t))}get paddingBottom(){return this[wt]("paddingBottom")}set paddingBottom(t){this[Mt]("paddingBottom",Qe(t))}get paddingLeft(){return this[wt]("paddingLeft")}set paddingLeft(t){this[Mt]("paddingLeft",Qe(t))}get padding(){return[this.paddingTop,this.paddingRight,this.paddingBottom,this.paddingLeft]}set padding(t){t=mt(t),Array.isArray(t)?t.length===2?t=[t[0],t[1],t[0],t[1]]:t.length===3&&(t=[t[0],t[1],t[2],t[1]]):t=[t,t,t,t],this.paddingTop=t[0],this.paddingRight=t[1],this.paddingBottom=t[2],this.paddingLeft=t[3]}get clipPath(){return this[wt]("clipPath")}set clipPath(t){this[Mt]("clipPath",t)}get boxSizing(){return this[wt]("boxSizing")}set boxSizing(t){if(t!=null&&t!=="border-box"&&t!=="content-box")throw new TypeError("Invalid boxSizing type.");this[Mt]("boxSizing",t)}};qe(Array);function So(i,t,e,r,n,s="leftTop"){const o=.5522848,a=r/2*o,c=n/2*o,l=t+r,u=e+n,h=t+r/2,d=e+n/2;s==="leftTop"?(i.moveTo(t,d),i.bezierCurveTo(t,d-c,h-a,e,h,e)):s==="rightTop"?i.bezierCurveTo(h+a,e,l,d-c,l,d):s==="rightBottom"?i.bezierCurveTo(l,d+c,h+a,u,h,u):s==="leftBottom"&&i.bezierCurveTo(h-a,u,t,d+c,t,d)}function OI(i,[t,e,r,n],s){if(!s||Array.isArray(s)&&s.every(o=>o===0))i.beginPath(),i.rect(t,e,r,n);else{typeof s=="number"&&(s=Array(8).fill(s));const[o,a,c,l,u,h,d,g]=s.map((p,v)=>v%2?Math.min(p,n/2):Math.min(p,r/2));i.beginPath(),i.moveTo(t,e+a),So(i,t,e,o*2,a*2,"leftTop"),i.lineTo(t+r-c,e),So(i,t+r-c*2,e,c*2,l*2,"rightTop"),i.lineTo(t+r,e+n-h),So(i,t+r-u*2,e+n-h*2,u*2,h*2,"rightBottom"),i.lineTo(t+d,e+n),So(i,t,e+n-g*2,d*2,g*2,"leftBottom"),i.closePath()}return i}qe(Array);function wm(i,t){if(!i)return{x:0,y:0,width:0,height:0,left:0,top:0,right:0,bottom:0};const[[e,r],[n,s]]=i,o=e*t[0]+r*t[2]+t[4],a=e*t[1]+r*t[3]+t[5],c=n*t[0]+r*t[2]+t[4],l=n*t[1]+r*t[3]+t[5],u=n*t[0]+s*t[2]+t[4],h=n*t[1]+s*t[3]+t[5],d=e*t[0]+s*t[2]+t[4],g=e*t[1]+s*t[3]+t[5],p=Math.min(o,c,u,d),v=Math.min(a,l,h,g),I=Math.max(o,c,u,d),D=Math.max(a,l,h,g);return{x:p,y:v,width:I-p,height:D-v,left:p,top:v,right:I,bottom:D}}qe(Array);const jr=Symbol("mesh");class Hs extends $a{constructor(t={}){super(t)}get borderSize(){const{paddingTop:t,paddingRight:e,paddingBottom:r,paddingLeft:n,borderWidth:s}=this.attributes,[o,a]=this.contentSize;return[n+o+e+s,t+a+r+s]}get clientSize(){const{paddingTop:t,paddingRight:e,paddingBottom:r,paddingLeft:n}=this.attributes,[s,o]=this.contentSize;return[n+s+e,t+o+r]}get contentSize(){let{width:t,height:e,boxSizing:r,paddingTop:n,paddingRight:s,paddingBottom:o,paddingLeft:a}=this.attributes;if(t=t||0,e=e||0,r==="border-box"){const c=2*this.attributes.borderWidth;t-=c+s+a,e-=c+n+o,t=Math.max(0,t),e=Math.max(0,e)}return[t,e]}get hasBorder(){return this.attributes.borderWidth>0}get isVisible(){const[t,e]=this.borderSize;return t>0&&e>0}get mesh(){if(this.attributes.display==="none")return null;const t=this.clientBox;if(t){let e=this[jr];if(e)e.box!==t&&(e.contours=t.contours,e.box=t);else{e=new ht.Mesh2D(t),e.box=t;const n=this.attributes.bgcolor;if(ra(e,{color:n}),this.hasBorder){const{borderColor:o,borderWidth:a,borderDash:c,borderDashOffset:l}=this.attributes;na(e,{color:o,lineWidth:a,lineDash:c,lineDashOffset:l})}this[jr]=e;const s=this.attributes.clipPath;s&&this[jr].setClipPath(s)}const r=this.opacity;return e.getOpacity()!==r&&e.setOpacity(r),e.setTransform(...this.renderMatrix),e}return null}get offsetSize(){const{paddingTop:t,paddingRight:e,paddingBottom:r,paddingLeft:n,borderWidth:s}=this.attributes,[o,a]=this.contentSize,c=2*s;return[n+o+e+c,t+a+r+c]}get originalClientRect(){if(this.mesh){const t=this.mesh.boundingBox;return[t[0][0],t[0][1],t[1][0]-t[0][0],t[1][1]-t[0][1]]}return[0,0,0,0]}get originalContentRect(){const[t,e,r,n]=this.originalClientRect,s=this.attributes.padding;return[t+s[0],e+s[1],r-s[0]-s[2],n-s[1]-s[3]]}getBoundingClientRect(){let t=this.renderMatrix;this.layer&&this.layer.layerTransformInvert&&(t=Er(Array.of(0,0,0,0,0,0),this.layer.transformMatrix,t));let e=null;if(this.mesh){e=[...this.mesh.boundingBox];const r=this.attributes.borderWidth;r&&(e[0]=[e[0][0]-r,e[0][1]-r],e[1]=[e[1][0]+r,e[1][1]+r])}return wm(e,t)}onPropertyChange(t,e,r){if(super.onPropertyChange(t,e,r),(t==="anchorX"||t==="anchorY"||t==="boxSizing"||t==="width"||t==="height"||t==="borderWidth"||t==="paddingLeft"||t==="paddingRight"||t==="paddingTop"||t==="paddingBottom"||/^border(TopLeft|TopRight|BottomRight|BottomLeft)Radius$/.test(t))&&this.updateContours(),this[jr]&&t==="clipPath"&&this[jr].setClipPath(e),this[jr]&&t==="bgcolor"&&ra(this[jr],{color:e}),this[jr]&&(t==="borderColor"||t==="borderWidth"||t==="borderDash"||t==="borderDashOffset")){const{borderColor:n,borderWidth:s,borderDash:o,borderDashOffset:a}=this.attributes;na(this[jr],{color:n,lineWidth:s,lineDash:s?o:0,lineDashOffset:a})}}updateContours(){const{anchorX:t,anchorY:e,borderWidth:r,borderRadius:n}=this.attributes,[s,o]=this.borderSize,a=this.offsetSize,c=.5*r,l=-t*a[0]+c,u=-e*a[1]+c;this.clientBox=new ht.Figure2D,OI(this.clientBox,[l,u,s,o],n)}}R(Hs,"Attr",Va);$t.registerNode(Hs,"block");qe(Array);let zI=class extends Va{};var Tm={exports:{}},nh={Text:"text",CDATA:"cdata",isTag:function(i){return i.type==="tag"||i.type==="script"||i.type==="style"}},Sm={exports:{}},Im={};(function(i){Object.defineProperty(i,"__esModule",{value:!0}),i.Doctype=i.CDATA=i.Tag=i.Style=i.Script=i.Comment=i.Directive=i.Text=i.Root=i.isTag=i.ElementType=void 0;var t;(function(r){r.Root="root",r.Text="text",r.Directive="directive",r.Comment="comment",r.Script="script",r.Style="style",r.Tag="tag",r.CDATA="cdata",r.Doctype="doctype"})(t=i.ElementType||(i.ElementType={}));function e(r){return r.type===t.Tag||r.type===t.Script||r.type===t.Style}i.isTag=e,i.Root=t.Root,i.Text=t.Text,i.Directive=t.Directive,i.Comment=t.Comment,i.Script=t.Script,i.Style=t.Style,i.Tag=t.Tag,i.CDATA=t.CDATA,i.Doctype=t.Doctype})(Im);var Cm={},Xr={};const jI="Á",BI="á",UI="Ă",FI="ă",WI="∾",$I="∿",VI="∾̳",YI="Â",GI="â",HI="´",QI="А",ZI="а",KI="Æ",qI="æ",XI="⁡",JI="𝔄",_I="𝔞",e2="À",t2="à",r2="ℵ",n2="ℵ",i2="Α",s2="α",o2="Ā",a2="ā",c2="⨿",l2="&",u2="&",h2="⩕",d2="⩓",f2="∧",g2="⩜",p2="⩘",m2="⩚",y2="∠",v2="⦤",M2="∠",w2="⦨",T2="⦩",S2="⦪",I2="⦫",C2="⦬",b2="⦭",x2="⦮",E2="⦯",A2="∡",N2="∟",D2="⊾",P2="⦝",k2="∢",L2="Å",R2="⍼",O2="Ą",z2="ą",j2="𝔸",B2="𝕒",U2="⩯",F2="≈",W2="⩰",$2="≊",V2="≋",Y2="'",G2="⁡",H2="≈",Q2="≊",Z2="Å",K2="å",q2="𝒜",X2="𝒶",J2="≔",_2="*",eC="≈",tC="≍",rC="Ã",nC="ã",iC="Ä",sC="ä",oC="∳",aC="⨑",cC="≌",lC="϶",uC="‵",hC="∽",dC="⋍",fC="∖",gC="⫧",pC="⊽",mC="⌅",yC="⌆",vC="⌅",MC="⎵",wC="⎶",TC="≌",SC="Б",IC="б",CC="„",bC="∵",xC="∵",EC="∵",AC="⦰",NC="϶",DC="ℬ",PC="ℬ",kC="Β",LC="β",RC="ℶ",OC="≬",zC="𝔅",jC="𝔟",BC="⋂",UC="◯",FC="⋃",WC="⨀",$C="⨁",VC="⨂",YC="⨆",GC="★",HC="▽",QC="△",ZC="⨄",KC="⋁",qC="⋀",XC="⤍",JC="⧫",_C="▪",eb="▴",tb="▾",rb="◂",nb="▸",ib="␣",sb="▒",ob="░",ab="▓",cb="█",lb="=⃥",ub="≡⃥",hb="⫭",db="⌐",fb="𝔹",gb="𝕓",pb="⊥",mb="⊥",yb="⋈",vb="⧉",Mb="┐",wb="╕",Tb="╖",Sb="╗",Ib="┌",Cb="╒",bb="╓",xb="╔",Eb="─",Ab="═",Nb="┬",Db="╤",Pb="╥",kb="╦",Lb="┴",Rb="╧",Ob="╨",zb="╩",jb="⊟",Bb="⊞",Ub="⊠",Fb="┘",Wb="╛",$b="╜",Vb="╝",Yb="└",Gb="╘",Hb="╙",Qb="╚",Zb="│",Kb="║",qb="┼",Xb="╪",Jb="╫",_b="╬",ex="┤",tx="╡",rx="╢",nx="╣",ix="├",sx="╞",ox="╟",ax="╠",cx="‵",lx="˘",ux="˘",hx="¦",dx="𝒷",fx="ℬ",gx="⁏",px="∽",mx="⋍",yx="⧅",vx="\\",Mx="⟈",wx="•",Tx="•",Sx="≎",Ix="⪮",Cx="≏",bx="≎",xx="≏",Ex="Ć",Ax="ć",Nx="⩄",Dx="⩉",Px="⩋",kx="∩",Lx="⋒",Rx="⩇",Ox="⩀",zx="ⅅ",jx="∩︀",Bx="⁁",Ux="ˇ",Fx="ℭ",Wx="⩍",$x="Č",Vx="č",Yx="Ç",Gx="ç",Hx="Ĉ",Qx="ĉ",Zx="∰",Kx="⩌",qx="⩐",Xx="Ċ",Jx="ċ",_x="¸",eE="¸",tE="⦲",rE="¢",nE="·",iE="·",sE="𝔠",oE="ℭ",aE="Ч",cE="ч",lE="✓",uE="✓",hE="Χ",dE="χ",fE="ˆ",gE="≗",pE="↺",mE="↻",yE="⊛",vE="⊚",ME="⊝",wE="⊙",TE="®",SE="Ⓢ",IE="⊖",CE="⊕",bE="⊗",xE="○",EE="⧃",AE="≗",NE="⨐",DE="⫯",PE="⧂",kE="∲",LE="”",RE="’",OE="♣",zE="♣",jE=":",BE="∷",UE="⩴",FE="≔",WE="≔",$E=",",VE="@",YE="∁",GE="∘",HE="∁",QE="ℂ",ZE="≅",KE="⩭",qE="≡",XE="∮",JE="∯",_E="∮",eA="𝕔",tA="ℂ",rA="∐",nA="∐",iA="©",sA="©",oA="℗",aA="∳",cA="↵",lA="✗",uA="⨯",hA="𝒞",dA="𝒸",fA="⫏",gA="⫑",pA="⫐",mA="⫒",yA="⋯",vA="⤸",MA="⤵",wA="⋞",TA="⋟",SA="↶",IA="⤽",CA="⩈",bA="⩆",xA="≍",EA="∪",AA="⋓",NA="⩊",DA="⊍",PA="⩅",kA="∪︀",LA="↷",RA="⤼",OA="⋞",zA="⋟",jA="⋎",BA="⋏",UA="¤",FA="↶",WA="↷",$A="⋎",VA="⋏",YA="∲",GA="∱",HA="⌭",QA="†",ZA="‡",KA="ℸ",qA="↓",XA="↡",JA="⇓",_A="‐",eN="⫤",tN="⊣",rN="⤏",nN="˝",iN="Ď",sN="ď",oN="Д",aN="д",cN="‡",lN="⇊",uN="ⅅ",hN="ⅆ",dN="⤑",fN="⩷",gN="°",pN="∇",mN="Δ",yN="δ",vN="⦱",MN="⥿",wN="𝔇",TN="𝔡",SN="⥥",IN="⇃",CN="⇂",bN="´",xN="˙",EN="˝",AN="`",NN="˜",DN="⋄",PN="⋄",kN="⋄",LN="♦",RN="♦",ON="¨",zN="ⅆ",jN="ϝ",BN="⋲",UN="÷",FN="÷",WN="⋇",$N="⋇",VN="Ђ",YN="ђ",GN="⌞",HN="⌍",QN="$",ZN="𝔻",KN="𝕕",qN="¨",XN="˙",JN="⃜",_N="≐",eD="≑",tD="≐",rD="∸",nD="∔",iD="⊡",sD="⌆",oD="∯",aD="¨",cD="⇓",lD="⇐",uD="⇔",hD="⫤",dD="⟸",fD="⟺",gD="⟹",pD="⇒",mD="⊨",yD="⇑",vD="⇕",MD="∥",wD="⤓",TD="↓",SD="↓",ID="⇓",CD="⇵",bD="̑",xD="⇊",ED="⇃",AD="⇂",ND="⥐",DD="⥞",PD="⥖",kD="↽",LD="⥟",RD="⥗",OD="⇁",zD="↧",jD="⊤",BD="⤐",UD="⌟",FD="⌌",WD="𝒟",$D="𝒹",VD="Ѕ",YD="ѕ",GD="⧶",HD="Đ",QD="đ",ZD="⋱",KD="▿",qD="▾",XD="⇵",JD="⥯",_D="⦦",eP="Џ",tP="џ",rP="⟿",nP="É",iP="é",sP="⩮",oP="Ě",aP="ě",cP="Ê",lP="ê",uP="≖",hP="≕",dP="Э",fP="э",gP="⩷",pP="Ė",mP="ė",yP="≑",vP="ⅇ",MP="≒",wP="𝔈",TP="𝔢",SP="⪚",IP="È",CP="è",bP="⪖",xP="⪘",EP="⪙",AP="∈",NP="⏧",DP="ℓ",PP="⪕",kP="⪗",LP="Ē",RP="ē",OP="∅",zP="∅",jP="◻",BP="∅",UP="▫",FP=" ",WP=" ",$P=" ",VP="Ŋ",YP="ŋ",GP=" ",HP="Ę",QP="ę",ZP="𝔼",KP="𝕖",qP="⋕",XP="⧣",JP="⩱",_P="ε",ek="Ε",tk="ε",rk="ϵ",nk="≖",ik="≕",sk="≂",ok="⪖",ak="⪕",ck="⩵",lk="=",uk="≂",hk="≟",dk="⇌",fk="≡",gk="⩸",pk="⧥",mk="⥱",yk="≓",vk="ℯ",Mk="ℰ",wk="≐",Tk="⩳",Sk="≂",Ik="Η",Ck="η",bk="Ð",xk="ð",Ek="Ë",Ak="ë",Nk="€",Dk="!",Pk="∃",kk="∃",Lk="ℰ",Rk="ⅇ",Ok="ⅇ",zk="≒",jk="Ф",Bk="ф",Uk="♀",Fk="ffi",Wk="ff",$k="ffl",Vk="𝔉",Yk="𝔣",Gk="fi",Hk="◼",Qk="▪",Zk="fj",Kk="♭",qk="fl",Xk="▱",Jk="ƒ",_k="𝔽",eL="𝕗",tL="∀",rL="∀",nL="⋔",iL="⫙",sL="ℱ",oL="⨍",aL="½",cL="⅓",lL="¼",uL="⅕",hL="⅙",dL="⅛",fL="⅔",gL="⅖",pL="¾",mL="⅗",yL="⅜",vL="⅘",ML="⅚",wL="⅝",TL="⅞",SL="⁄",IL="⌢",CL="𝒻",bL="ℱ",xL="ǵ",EL="Γ",AL="γ",NL="Ϝ",DL="ϝ",PL="⪆",kL="Ğ",LL="ğ",RL="Ģ",OL="Ĝ",zL="ĝ",jL="Г",BL="г",UL="Ġ",FL="ġ",WL="≥",$L="≧",VL="⪌",YL="⋛",GL="≥",HL="≧",QL="⩾",ZL="⪩",KL="⩾",qL="⪀",XL="⪂",JL="⪄",_L="⋛︀",eR="⪔",tR="𝔊",rR="𝔤",nR="≫",iR="⋙",sR="⋙",oR="ℷ",aR="Ѓ",cR="ѓ",lR="⪥",uR="≷",hR="⪒",dR="⪤",fR="⪊",gR="⪊",pR="⪈",mR="≩",yR="⪈",vR="≩",MR="⋧",wR="𝔾",TR="𝕘",SR="`",IR="≥",CR="⋛",bR="≧",xR="⪢",ER="≷",AR="⩾",NR="≳",DR="𝒢",PR="ℊ",kR="≳",LR="⪎",RR="⪐",OR="⪧",zR="⩺",jR=">",BR=">",UR="≫",FR="⋗",WR="⦕",$R="⩼",VR="⪆",YR="⥸",GR="⋗",HR="⋛",QR="⪌",ZR="≷",KR="≳",qR="≩︀",XR="≩︀",JR="ˇ",_R=" ",eO="½",tO="ℋ",rO="Ъ",nO="ъ",iO="⥈",sO="↔",oO="⇔",aO="↭",cO="^",lO="ℏ",uO="Ĥ",hO="ĥ",dO="♥",fO="♥",gO="…",pO="⊹",mO="𝔥",yO="ℌ",vO="ℋ",MO="⤥",wO="⤦",TO="⇿",SO="∻",IO="↩",CO="↪",bO="𝕙",xO="ℍ",EO="―",AO="─",NO="𝒽",DO="ℋ",PO="ℏ",kO="Ħ",LO="ħ",RO="≎",OO="≏",zO="⁃",jO="‐",BO="Í",UO="í",FO="⁣",WO="Î",$O="î",VO="И",YO="и",GO="İ",HO="Е",QO="е",ZO="¡",KO="⇔",qO="𝔦",XO="ℑ",JO="Ì",_O="ì",ez="ⅈ",tz="⨌",rz="∭",nz="⧜",iz="℩",sz="IJ",oz="ij",az="Ī",cz="ī",lz="ℑ",uz="ⅈ",hz="ℐ",dz="ℑ",fz="ı",gz="ℑ",pz="⊷",mz="Ƶ",yz="⇒",vz="℅",Mz="∞",wz="⧝",Tz="ı",Sz="⊺",Iz="∫",Cz="∬",bz="ℤ",xz="∫",Ez="⊺",Az="⋂",Nz="⨗",Dz="⨼",Pz="⁣",kz="⁢",Lz="Ё",Rz="ё",Oz="Į",zz="į",jz="𝕀",Bz="𝕚",Uz="Ι",Fz="ι",Wz="⨼",$z="¿",Vz="𝒾",Yz="ℐ",Gz="∈",Hz="⋵",Qz="⋹",Zz="⋴",Kz="⋳",qz="∈",Xz="⁢",Jz="Ĩ",_z="ĩ",ej="І",tj="і",rj="Ï",nj="ï",ij="Ĵ",sj="ĵ",oj="Й",aj="й",cj="𝔍",lj="𝔧",uj="ȷ",hj="𝕁",dj="𝕛",fj="𝒥",gj="𝒿",pj="Ј",mj="ј",yj="Є",vj="є",Mj="Κ",wj="κ",Tj="ϰ",Sj="Ķ",Ij="ķ",Cj="К",bj="к",xj="𝔎",Ej="𝔨",Aj="ĸ",Nj="Х",Dj="х",Pj="Ќ",kj="ќ",Lj="𝕂",Rj="𝕜",Oj="𝒦",zj="𝓀",jj="⇚",Bj="Ĺ",Uj="ĺ",Fj="⦴",Wj="ℒ",$j="Λ",Vj="λ",Yj="⟨",Gj="⟪",Hj="⦑",Qj="⟨",Zj="⪅",Kj="ℒ",qj="«",Xj="⇤",Jj="⤟",_j="←",e3="↞",t3="⇐",r3="⤝",n3="↩",i3="↫",s3="⤹",o3="⥳",a3="↢",c3="⤙",l3="⤛",u3="⪫",h3="⪭",d3="⪭︀",f3="⤌",g3="⤎",p3="❲",m3="{",y3="[",v3="⦋",M3="⦏",w3="⦍",T3="Ľ",S3="ľ",I3="Ļ",C3="ļ",b3="⌈",x3="{",E3="Л",A3="л",N3="⤶",D3="“",P3="„",k3="⥧",L3="⥋",R3="↲",O3="≤",z3="≦",j3="⟨",B3="⇤",U3="←",F3="←",W3="⇐",$3="⇆",V3="↢",Y3="⌈",G3="⟦",H3="⥡",Q3="⥙",Z3="⇃",K3="⌊",q3="↽",X3="↼",J3="⇇",_3="↔",e4="↔",t4="⇔",r4="⇆",n4="⇋",i4="↭",s4="⥎",o4="↤",a4="⊣",c4="⥚",l4="⋋",u4="⧏",h4="⊲",d4="⊴",f4="⥑",g4="⥠",p4="⥘",m4="↿",y4="⥒",v4="↼",M4="⪋",w4="⋚",T4="≤",S4="≦",I4="⩽",C4="⪨",b4="⩽",x4="⩿",E4="⪁",A4="⪃",N4="⋚︀",D4="⪓",P4="⪅",k4="⋖",L4="⋚",R4="⪋",O4="⋚",z4="≦",j4="≶",B4="≶",U4="⪡",F4="≲",W4="⩽",$4="≲",V4="⥼",Y4="⌊",G4="𝔏",H4="𝔩",Q4="≶",Z4="⪑",K4="⥢",q4="↽",X4="↼",J4="⥪",_4="▄",eB="Љ",tB="љ",rB="⇇",nB="≪",iB="⋘",sB="⌞",oB="⇚",aB="⥫",cB="◺",lB="Ŀ",uB="ŀ",hB="⎰",dB="⎰",fB="⪉",gB="⪉",pB="⪇",mB="≨",yB="⪇",vB="≨",MB="⋦",wB="⟬",TB="⇽",SB="⟦",IB="⟵",CB="⟵",bB="⟸",xB="⟷",EB="⟷",AB="⟺",NB="⟼",DB="⟶",PB="⟶",kB="⟹",LB="↫",RB="↬",OB="⦅",zB="𝕃",jB="𝕝",BB="⨭",UB="⨴",FB="∗",WB="_",$B="↙",VB="↘",YB="◊",GB="◊",HB="⧫",QB="(",ZB="⦓",KB="⇆",qB="⌟",XB="⇋",JB="⥭",_B="‎",e5="⊿",t5="‹",r5="𝓁",n5="ℒ",i5="↰",s5="↰",o5="≲",a5="⪍",c5="⪏",l5="[",u5="‘",h5="‚",d5="Ł",f5="ł",g5="⪦",p5="⩹",m5="<",y5="<",v5="≪",M5="⋖",w5="⋋",T5="⋉",S5="⥶",I5="⩻",C5="◃",b5="⊴",x5="◂",E5="⦖",A5="⥊",N5="⥦",D5="≨︀",P5="≨︀",k5="¯",L5="♂",R5="✠",O5="✠",z5="↦",j5="↦",B5="↧",U5="↤",F5="↥",W5="▮",$5="⨩",V5="М",Y5="м",G5="—",H5="∺",Q5="∡",Z5=" ",K5="ℳ",q5="𝔐",X5="𝔪",J5="℧",_5="µ",eU="*",tU="⫰",rU="∣",nU="·",iU="⊟",sU="−",oU="∸",aU="⨪",cU="∓",lU="⫛",uU="…",hU="∓",dU="⊧",fU="𝕄",gU="𝕞",pU="∓",mU="𝓂",yU="ℳ",vU="∾",MU="Μ",wU="μ",TU="⊸",SU="⊸",IU="∇",CU="Ń",bU="ń",xU="∠⃒",EU="≉",AU="⩰̸",NU="≋̸",DU="ʼn",PU="≉",kU="♮",LU="ℕ",RU="♮",OU=" ",zU="≎̸",jU="≏̸",BU="⩃",UU="Ň",FU="ň",WU="Ņ",$U="ņ",VU="≇",YU="⩭̸",GU="⩂",HU="Н",QU="н",ZU="–",KU="⤤",qU="↗",XU="⇗",JU="↗",_U="≠",eF="≐̸",tF="​",rF="​",nF="​",iF="​",sF="≢",oF="⤨",aF="≂̸",cF="≫",lF="≪",uF=`
568
+ `,hF="∄",dF="∄",fF="𝔑",gF="𝔫",pF="≧̸",mF="≱",yF="≱",vF="≧̸",MF="⩾̸",wF="⩾̸",TF="⋙̸",SF="≵",IF="≫⃒",CF="≯",bF="≯",xF="≫̸",EF="↮",AF="⇎",NF="⫲",DF="∋",PF="⋼",kF="⋺",LF="∋",RF="Њ",OF="њ",zF="↚",jF="⇍",BF="‥",UF="≦̸",FF="≰",WF="↚",$F="⇍",VF="↮",YF="⇎",GF="≰",HF="≦̸",QF="⩽̸",ZF="⩽̸",KF="≮",qF="⋘̸",XF="≴",JF="≪⃒",_F="≮",eW="⋪",tW="⋬",rW="≪̸",nW="∤",iW="⁠",sW=" ",oW="𝕟",aW="ℕ",cW="⫬",lW="¬",uW="≢",hW="≭",dW="∦",fW="∉",gW="≠",pW="≂̸",mW="∄",yW="≯",vW="≱",MW="≧̸",wW="≫̸",TW="≹",SW="⩾̸",IW="≵",CW="≎̸",bW="≏̸",xW="∉",EW="⋵̸",AW="⋹̸",NW="∉",DW="⋷",PW="⋶",kW="⧏̸",LW="⋪",RW="⋬",OW="≮",zW="≰",jW="≸",BW="≪̸",UW="⩽̸",FW="≴",WW="⪢̸",$W="⪡̸",VW="∌",YW="∌",GW="⋾",HW="⋽",QW="⊀",ZW="⪯̸",KW="⋠",qW="∌",XW="⧐̸",JW="⋫",_W="⋭",e$="⊏̸",t$="⋢",r$="⊐̸",n$="⋣",i$="⊂⃒",s$="⊈",o$="⊁",a$="⪰̸",c$="⋡",l$="≿̸",u$="⊃⃒",h$="⊉",d$="≁",f$="≄",g$="≇",p$="≉",m$="∤",y$="∦",v$="∦",M$="⫽⃥",w$="∂̸",T$="⨔",S$="⊀",I$="⋠",C$="⊀",b$="⪯̸",x$="⪯̸",E$="⤳̸",A$="↛",N$="⇏",D$="↝̸",P$="↛",k$="⇏",L$="⋫",R$="⋭",O$="⊁",z$="⋡",j$="⪰̸",B$="𝒩",U$="𝓃",F$="∤",W$="∦",$$="≁",V$="≄",Y$="≄",G$="∤",H$="∦",Q$="⋢",Z$="⋣",K$="⊄",q$="⫅̸",X$="⊈",J$="⊂⃒",_$="⊈",eV="⫅̸",tV="⊁",rV="⪰̸",nV="⊅",iV="⫆̸",sV="⊉",oV="⊃⃒",aV="⊉",cV="⫆̸",lV="≹",uV="Ñ",hV="ñ",dV="≸",fV="⋪",gV="⋬",pV="⋫",mV="⋭",yV="Ν",vV="ν",MV="#",wV="№",TV=" ",SV="≍⃒",IV="⊬",CV="⊭",bV="⊮",xV="⊯",EV="≥⃒",AV=">⃒",NV="⤄",DV="⧞",PV="⤂",kV="≤⃒",LV="<⃒",RV="⊴⃒",OV="⤃",zV="⊵⃒",jV="∼⃒",BV="⤣",UV="↖",FV="⇖",WV="↖",$V="⤧",VV="Ó",YV="ó",GV="⊛",HV="Ô",QV="ô",ZV="⊚",KV="О",qV="о",XV="⊝",JV="Ő",_V="ő",eY="⨸",tY="⊙",rY="⦼",nY="Œ",iY="œ",sY="⦿",oY="𝔒",aY="𝔬",cY="˛",lY="Ò",uY="ò",hY="⧁",dY="⦵",fY="Ω",gY="∮",pY="↺",mY="⦾",yY="⦻",vY="‾",MY="⧀",wY="Ō",TY="ō",SY="Ω",IY="ω",CY="Ο",bY="ο",xY="⦶",EY="⊖",AY="𝕆",NY="𝕠",DY="⦷",PY="“",kY="‘",LY="⦹",RY="⊕",OY="↻",zY="⩔",jY="∨",BY="⩝",UY="ℴ",FY="ℴ",WY="ª",$Y="º",VY="⊶",YY="⩖",GY="⩗",HY="⩛",QY="Ⓢ",ZY="𝒪",KY="ℴ",qY="Ø",XY="ø",JY="⊘",_Y="Õ",eG="õ",tG="⨶",rG="⨷",nG="⊗",iG="Ö",sG="ö",oG="⌽",aG="‾",cG="⏞",lG="⎴",uG="⏜",hG="¶",dG="∥",fG="∥",gG="⫳",pG="⫽",mG="∂",yG="∂",vG="П",MG="п",wG="%",TG=".",SG="‰",IG="⊥",CG="‱",bG="𝔓",xG="𝔭",EG="Φ",AG="φ",NG="ϕ",DG="ℳ",PG="☎",kG="Π",LG="π",RG="⋔",OG="ϖ",zG="ℏ",jG="ℎ",BG="ℏ",UG="⨣",FG="⊞",WG="⨢",$G="+",VG="∔",YG="⨥",GG="⩲",HG="±",QG="±",ZG="⨦",KG="⨧",qG="±",XG="ℌ",JG="⨕",_G="𝕡",e8="ℙ",t8="£",r8="⪷",n8="⪻",i8="≺",s8="≼",o8="⪷",a8="≺",c8="≼",l8="≺",u8="⪯",h8="≼",d8="≾",f8="⪯",g8="⪹",p8="⪵",m8="⋨",y8="⪯",v8="⪳",M8="≾",w8="′",T8="″",S8="ℙ",I8="⪹",C8="⪵",b8="⋨",x8="∏",E8="∏",A8="⌮",N8="⌒",D8="⌓",P8="∝",k8="∝",L8="∷",R8="∝",O8="≾",z8="⊰",j8="𝒫",B8="𝓅",U8="Ψ",F8="ψ",W8=" ",$8="𝔔",V8="𝔮",Y8="⨌",G8="𝕢",H8="ℚ",Q8="⁗",Z8="𝒬",K8="𝓆",q8="ℍ",X8="⨖",J8="?",_8="≟",e6='"',t6='"',r6="⇛",n6="∽̱",i6="Ŕ",s6="ŕ",o6="√",a6="⦳",c6="⟩",l6="⟫",u6="⦒",h6="⦥",d6="⟩",f6="»",g6="⥵",p6="⇥",m6="⤠",y6="⤳",v6="→",M6="↠",w6="⇒",T6="⤞",S6="↪",I6="↬",C6="⥅",b6="⥴",x6="⤖",E6="↣",A6="↝",N6="⤚",D6="⤜",P6="∶",k6="ℚ",L6="⤍",R6="⤏",O6="⤐",z6="❳",j6="}",B6="]",U6="⦌",F6="⦎",W6="⦐",$6="Ř",V6="ř",Y6="Ŗ",G6="ŗ",H6="⌉",Q6="}",Z6="Р",K6="р",q6="⤷",X6="⥩",J6="”",_6="”",e9="↳",t9="ℜ",r9="ℛ",n9="ℜ",i9="ℝ",s9="ℜ",o9="▭",a9="®",c9="®",l9="∋",u9="⇋",h9="⥯",d9="⥽",f9="⌋",g9="𝔯",p9="ℜ",m9="⥤",y9="⇁",v9="⇀",M9="⥬",w9="Ρ",T9="ρ",S9="ϱ",I9="⟩",C9="⇥",b9="→",x9="→",E9="⇒",A9="⇄",N9="↣",D9="⌉",P9="⟧",k9="⥝",L9="⥕",R9="⇂",O9="⌋",z9="⇁",j9="⇀",B9="⇄",U9="⇌",F9="⇉",W9="↝",$9="↦",V9="⊢",Y9="⥛",G9="⋌",H9="⧐",Q9="⊳",Z9="⊵",K9="⥏",q9="⥜",X9="⥔",J9="↾",_9="⥓",eH="⇀",tH="˚",rH="≓",nH="⇄",iH="⇌",sH="‏",oH="⎱",aH="⎱",cH="⫮",lH="⟭",uH="⇾",hH="⟧",dH="⦆",fH="𝕣",gH="ℝ",pH="⨮",mH="⨵",yH="⥰",vH=")",MH="⦔",wH="⨒",TH="⇉",SH="⇛",IH="›",CH="𝓇",bH="ℛ",xH="↱",EH="↱",AH="]",NH="’",DH="’",PH="⋌",kH="⋊",LH="▹",RH="⊵",OH="▸",zH="⧎",jH="⧴",BH="⥨",UH="℞",FH="Ś",WH="ś",$H="‚",VH="⪸",YH="Š",GH="š",HH="⪼",QH="≻",ZH="≽",KH="⪰",qH="⪴",XH="Ş",JH="ş",_H="Ŝ",e7="ŝ",t7="⪺",r7="⪶",n7="⋩",i7="⨓",s7="≿",o7="С",a7="с",c7="⊡",l7="⋅",u7="⩦",h7="⤥",d7="↘",f7="⇘",g7="↘",p7="§",m7=";",y7="⤩",v7="∖",M7="∖",w7="✶",T7="𝔖",S7="𝔰",I7="⌢",C7="♯",b7="Щ",x7="щ",E7="Ш",A7="ш",N7="↓",D7="←",P7="∣",k7="∥",L7="→",R7="↑",O7="­",z7="Σ",j7="σ",B7="ς",U7="ς",F7="∼",W7="⩪",$7="≃",V7="≃",Y7="⪞",G7="⪠",H7="⪝",Q7="⪟",Z7="≆",K7="⨤",q7="⥲",X7="←",J7="∘",_7="∖",eQ="⨳",tQ="⧤",rQ="∣",nQ="⌣",iQ="⪪",sQ="⪬",oQ="⪬︀",aQ="Ь",cQ="ь",lQ="⌿",uQ="⧄",hQ="/",dQ="𝕊",fQ="𝕤",gQ="♠",pQ="♠",mQ="∥",yQ="⊓",vQ="⊓︀",MQ="⊔",wQ="⊔︀",TQ="√",SQ="⊏",IQ="⊑",CQ="⊏",bQ="⊑",xQ="⊐",EQ="⊒",AQ="⊐",NQ="⊒",DQ="□",PQ="□",kQ="⊓",LQ="⊏",RQ="⊑",OQ="⊐",zQ="⊒",jQ="⊔",BQ="▪",UQ="□",FQ="▪",WQ="→",$Q="𝒮",VQ="𝓈",YQ="∖",GQ="⌣",HQ="⋆",QQ="⋆",ZQ="☆",KQ="★",qQ="ϵ",XQ="ϕ",JQ="¯",_Q="⊂",eZ="⋐",tZ="⪽",rZ="⫅",nZ="⊆",iZ="⫃",sZ="⫁",oZ="⫋",aZ="⊊",cZ="⪿",lZ="⥹",uZ="⊂",hZ="⋐",dZ="⊆",fZ="⫅",gZ="⊆",pZ="⊊",mZ="⫋",yZ="⫇",vZ="⫕",MZ="⫓",wZ="⪸",TZ="≻",SZ="≽",IZ="≻",CZ="⪰",bZ="≽",xZ="≿",EZ="⪰",AZ="⪺",NZ="⪶",DZ="⋩",PZ="≿",kZ="∋",LZ="∑",RZ="∑",OZ="♪",zZ="¹",jZ="²",BZ="³",UZ="⊃",FZ="⋑",WZ="⪾",$Z="⫘",VZ="⫆",YZ="⊇",GZ="⫄",HZ="⊃",QZ="⊇",ZZ="⟉",KZ="⫗",qZ="⥻",XZ="⫂",JZ="⫌",_Z="⊋",eK="⫀",tK="⊃",rK="⋑",nK="⊇",iK="⫆",sK="⊋",oK="⫌",aK="⫈",cK="⫔",lK="⫖",uK="⤦",hK="↙",dK="⇙",fK="↙",gK="⤪",pK="ß",mK=" ",yK="⌖",vK="Τ",MK="τ",wK="⎴",TK="Ť",SK="ť",IK="Ţ",CK="ţ",bK="Т",xK="т",EK="⃛",AK="⌕",NK="𝔗",DK="𝔱",PK="∴",kK="∴",LK="∴",RK="Θ",OK="θ",zK="ϑ",jK="ϑ",BK="≈",UK="∼",FK="  ",WK=" ",$K=" ",VK="≈",YK="∼",GK="Þ",HK="þ",QK="˜",ZK="∼",KK="≃",qK="≅",XK="≈",JK="⨱",_K="⊠",eq="×",tq="⨰",rq="∭",nq="⤨",iq="⌶",sq="⫱",oq="⊤",aq="𝕋",cq="𝕥",lq="⫚",uq="⤩",hq="‴",dq="™",fq="™",gq="▵",pq="▿",mq="◃",yq="⊴",vq="≜",Mq="▹",wq="⊵",Tq="◬",Sq="≜",Iq="⨺",Cq="⃛",bq="⨹",xq="⧍",Eq="⨻",Aq="⏢",Nq="𝒯",Dq="𝓉",Pq="Ц",kq="ц",Lq="Ћ",Rq="ћ",Oq="Ŧ",zq="ŧ",jq="≬",Bq="↞",Uq="↠",Fq="Ú",Wq="ú",$q="↑",Vq="↟",Yq="⇑",Gq="⥉",Hq="Ў",Qq="ў",Zq="Ŭ",Kq="ŭ",qq="Û",Xq="û",Jq="У",_q="у",eX="⇅",tX="Ű",rX="ű",nX="⥮",iX="⥾",sX="𝔘",oX="𝔲",aX="Ù",cX="ù",lX="⥣",uX="↿",hX="↾",dX="▀",fX="⌜",gX="⌜",pX="⌏",mX="◸",yX="Ū",vX="ū",MX="¨",wX="_",TX="⏟",SX="⎵",IX="⏝",CX="⋃",bX="⊎",xX="Ų",EX="ų",AX="𝕌",NX="𝕦",DX="⤒",PX="↑",kX="↑",LX="⇑",RX="⇅",OX="↕",zX="↕",jX="⇕",BX="⥮",UX="↿",FX="↾",WX="⊎",$X="↖",VX="↗",YX="υ",GX="ϒ",HX="ϒ",QX="Υ",ZX="υ",KX="↥",qX="⊥",XX="⇈",JX="⌝",_X="⌝",eJ="⌎",tJ="Ů",rJ="ů",nJ="◹",iJ="𝒰",sJ="𝓊",oJ="⋰",aJ="Ũ",cJ="ũ",lJ="▵",uJ="▴",hJ="⇈",dJ="Ü",fJ="ü",gJ="⦧",pJ="⦜",mJ="ϵ",yJ="ϰ",vJ="∅",MJ="ϕ",wJ="ϖ",TJ="∝",SJ="↕",IJ="⇕",CJ="ϱ",bJ="ς",xJ="⊊︀",EJ="⫋︀",AJ="⊋︀",NJ="⫌︀",DJ="ϑ",PJ="⊲",kJ="⊳",LJ="⫨",RJ="⫫",OJ="⫩",zJ="В",jJ="в",BJ="⊢",UJ="⊨",FJ="⊩",WJ="⊫",$J="⫦",VJ="⊻",YJ="∨",GJ="⋁",HJ="≚",QJ="⋮",ZJ="|",KJ="‖",qJ="|",XJ="‖",JJ="∣",_J="|",e_="❘",t_="≀",r_=" ",n_="𝔙",i_="𝔳",s_="⊲",o_="⊂⃒",a_="⊃⃒",c_="𝕍",l_="𝕧",u_="∝",h_="⊳",d_="𝒱",f_="𝓋",g_="⫋︀",p_="⊊︀",m_="⫌︀",y_="⊋︀",v_="⊪",M_="⦚",w_="Ŵ",T_="ŵ",S_="⩟",I_="∧",C_="⋀",b_="≙",x_="℘",E_="𝔚",A_="𝔴",N_="𝕎",D_="𝕨",P_="℘",k_="≀",L_="≀",R_="𝒲",O_="𝓌",z_="⋂",j_="◯",B_="⋃",U_="▽",F_="𝔛",W_="𝔵",$_="⟷",V_="⟺",Y_="Ξ",G_="ξ",H_="⟵",Q_="⟸",Z_="⟼",K_="⋻",q_="⨀",X_="𝕏",J_="𝕩",__="⨁",eee="⨂",tee="⟶",ree="⟹",nee="𝒳",iee="𝓍",see="⨆",oee="⨄",aee="△",cee="⋁",lee="⋀",uee="Ý",hee="ý",dee="Я",fee="я",gee="Ŷ",pee="ŷ",mee="Ы",yee="ы",vee="¥",Mee="𝔜",wee="𝔶",Tee="Ї",See="ї",Iee="𝕐",Cee="𝕪",bee="𝒴",xee="𝓎",Eee="Ю",Aee="ю",Nee="ÿ",Dee="Ÿ",Pee="Ź",kee="ź",Lee="Ž",Ree="ž",Oee="З",zee="з",jee="Ż",Bee="ż",Uee="ℨ",Fee="​",Wee="Ζ",$ee="ζ",Vee="𝔷",Yee="ℨ",Gee="Ж",Hee="ж",Qee="⇝",Zee="𝕫",Kee="ℤ",qee="𝒵",Xee="𝓏",Jee="‍",_ee="‌",bm={Aacute:jI,aacute:BI,Abreve:UI,abreve:FI,ac:WI,acd:$I,acE:VI,Acirc:YI,acirc:GI,acute:HI,Acy:QI,acy:ZI,AElig:KI,aelig:qI,af:XI,Afr:JI,afr:_I,Agrave:e2,agrave:t2,alefsym:r2,aleph:n2,Alpha:i2,alpha:s2,Amacr:o2,amacr:a2,amalg:c2,amp:l2,AMP:u2,andand:h2,And:d2,and:f2,andd:g2,andslope:p2,andv:m2,ang:y2,ange:v2,angle:M2,angmsdaa:w2,angmsdab:T2,angmsdac:S2,angmsdad:I2,angmsdae:C2,angmsdaf:b2,angmsdag:x2,angmsdah:E2,angmsd:A2,angrt:N2,angrtvb:D2,angrtvbd:P2,angsph:k2,angst:L2,angzarr:R2,Aogon:O2,aogon:z2,Aopf:j2,aopf:B2,apacir:U2,ap:F2,apE:W2,ape:$2,apid:V2,apos:Y2,ApplyFunction:G2,approx:H2,approxeq:Q2,Aring:Z2,aring:K2,Ascr:q2,ascr:X2,Assign:J2,ast:_2,asymp:eC,asympeq:tC,Atilde:rC,atilde:nC,Auml:iC,auml:sC,awconint:oC,awint:aC,backcong:cC,backepsilon:lC,backprime:uC,backsim:hC,backsimeq:dC,Backslash:fC,Barv:gC,barvee:pC,barwed:mC,Barwed:yC,barwedge:vC,bbrk:MC,bbrktbrk:wC,bcong:TC,Bcy:SC,bcy:IC,bdquo:CC,becaus:bC,because:xC,Because:EC,bemptyv:AC,bepsi:NC,bernou:DC,Bernoullis:PC,Beta:kC,beta:LC,beth:RC,between:OC,Bfr:zC,bfr:jC,bigcap:BC,bigcirc:UC,bigcup:FC,bigodot:WC,bigoplus:$C,bigotimes:VC,bigsqcup:YC,bigstar:GC,bigtriangledown:HC,bigtriangleup:QC,biguplus:ZC,bigvee:KC,bigwedge:qC,bkarow:XC,blacklozenge:JC,blacksquare:_C,blacktriangle:eb,blacktriangledown:tb,blacktriangleleft:rb,blacktriangleright:nb,blank:ib,blk12:sb,blk14:ob,blk34:ab,block:cb,bne:lb,bnequiv:ub,bNot:hb,bnot:db,Bopf:fb,bopf:gb,bot:pb,bottom:mb,bowtie:yb,boxbox:vb,boxdl:Mb,boxdL:wb,boxDl:Tb,boxDL:Sb,boxdr:Ib,boxdR:Cb,boxDr:bb,boxDR:xb,boxh:Eb,boxH:Ab,boxhd:Nb,boxHd:Db,boxhD:Pb,boxHD:kb,boxhu:Lb,boxHu:Rb,boxhU:Ob,boxHU:zb,boxminus:jb,boxplus:Bb,boxtimes:Ub,boxul:Fb,boxuL:Wb,boxUl:$b,boxUL:Vb,boxur:Yb,boxuR:Gb,boxUr:Hb,boxUR:Qb,boxv:Zb,boxV:Kb,boxvh:qb,boxvH:Xb,boxVh:Jb,boxVH:_b,boxvl:ex,boxvL:tx,boxVl:rx,boxVL:nx,boxvr:ix,boxvR:sx,boxVr:ox,boxVR:ax,bprime:cx,breve:lx,Breve:ux,brvbar:hx,bscr:dx,Bscr:fx,bsemi:gx,bsim:px,bsime:mx,bsolb:yx,bsol:vx,bsolhsub:Mx,bull:wx,bullet:Tx,bump:Sx,bumpE:Ix,bumpe:Cx,Bumpeq:bx,bumpeq:xx,Cacute:Ex,cacute:Ax,capand:Nx,capbrcup:Dx,capcap:Px,cap:kx,Cap:Lx,capcup:Rx,capdot:Ox,CapitalDifferentialD:zx,caps:jx,caret:Bx,caron:Ux,Cayleys:Fx,ccaps:Wx,Ccaron:$x,ccaron:Vx,Ccedil:Yx,ccedil:Gx,Ccirc:Hx,ccirc:Qx,Cconint:Zx,ccups:Kx,ccupssm:qx,Cdot:Xx,cdot:Jx,cedil:_x,Cedilla:eE,cemptyv:tE,cent:rE,centerdot:nE,CenterDot:iE,cfr:sE,Cfr:oE,CHcy:aE,chcy:cE,check:lE,checkmark:uE,Chi:hE,chi:dE,circ:fE,circeq:gE,circlearrowleft:pE,circlearrowright:mE,circledast:yE,circledcirc:vE,circleddash:ME,CircleDot:wE,circledR:TE,circledS:SE,CircleMinus:IE,CirclePlus:CE,CircleTimes:bE,cir:xE,cirE:EE,cire:AE,cirfnint:NE,cirmid:DE,cirscir:PE,ClockwiseContourIntegral:kE,CloseCurlyDoubleQuote:LE,CloseCurlyQuote:RE,clubs:OE,clubsuit:zE,colon:jE,Colon:BE,Colone:UE,colone:FE,coloneq:WE,comma:$E,commat:VE,comp:YE,compfn:GE,complement:HE,complexes:QE,cong:ZE,congdot:KE,Congruent:qE,conint:XE,Conint:JE,ContourIntegral:_E,copf:eA,Copf:tA,coprod:rA,Coproduct:nA,copy:iA,COPY:sA,copysr:oA,CounterClockwiseContourIntegral:aA,crarr:cA,cross:lA,Cross:uA,Cscr:hA,cscr:dA,csub:fA,csube:gA,csup:pA,csupe:mA,ctdot:yA,cudarrl:vA,cudarrr:MA,cuepr:wA,cuesc:TA,cularr:SA,cularrp:IA,cupbrcap:CA,cupcap:bA,CupCap:xA,cup:EA,Cup:AA,cupcup:NA,cupdot:DA,cupor:PA,cups:kA,curarr:LA,curarrm:RA,curlyeqprec:OA,curlyeqsucc:zA,curlyvee:jA,curlywedge:BA,curren:UA,curvearrowleft:FA,curvearrowright:WA,cuvee:$A,cuwed:VA,cwconint:YA,cwint:GA,cylcty:HA,dagger:QA,Dagger:ZA,daleth:KA,darr:qA,Darr:XA,dArr:JA,dash:_A,Dashv:eN,dashv:tN,dbkarow:rN,dblac:nN,Dcaron:iN,dcaron:sN,Dcy:oN,dcy:aN,ddagger:cN,ddarr:lN,DD:uN,dd:hN,DDotrahd:dN,ddotseq:fN,deg:gN,Del:pN,Delta:mN,delta:yN,demptyv:vN,dfisht:MN,Dfr:wN,dfr:TN,dHar:SN,dharl:IN,dharr:CN,DiacriticalAcute:bN,DiacriticalDot:xN,DiacriticalDoubleAcute:EN,DiacriticalGrave:AN,DiacriticalTilde:NN,diam:DN,diamond:PN,Diamond:kN,diamondsuit:LN,diams:RN,die:ON,DifferentialD:zN,digamma:jN,disin:BN,div:UN,divide:FN,divideontimes:WN,divonx:$N,DJcy:VN,djcy:YN,dlcorn:GN,dlcrop:HN,dollar:QN,Dopf:ZN,dopf:KN,Dot:qN,dot:XN,DotDot:JN,doteq:_N,doteqdot:eD,DotEqual:tD,dotminus:rD,dotplus:nD,dotsquare:iD,doublebarwedge:sD,DoubleContourIntegral:oD,DoubleDot:aD,DoubleDownArrow:cD,DoubleLeftArrow:lD,DoubleLeftRightArrow:uD,DoubleLeftTee:hD,DoubleLongLeftArrow:dD,DoubleLongLeftRightArrow:fD,DoubleLongRightArrow:gD,DoubleRightArrow:pD,DoubleRightTee:mD,DoubleUpArrow:yD,DoubleUpDownArrow:vD,DoubleVerticalBar:MD,DownArrowBar:wD,downarrow:TD,DownArrow:SD,Downarrow:ID,DownArrowUpArrow:CD,DownBreve:bD,downdownarrows:xD,downharpoonleft:ED,downharpoonright:AD,DownLeftRightVector:ND,DownLeftTeeVector:DD,DownLeftVectorBar:PD,DownLeftVector:kD,DownRightTeeVector:LD,DownRightVectorBar:RD,DownRightVector:OD,DownTeeArrow:zD,DownTee:jD,drbkarow:BD,drcorn:UD,drcrop:FD,Dscr:WD,dscr:$D,DScy:VD,dscy:YD,dsol:GD,Dstrok:HD,dstrok:QD,dtdot:ZD,dtri:KD,dtrif:qD,duarr:XD,duhar:JD,dwangle:_D,DZcy:eP,dzcy:tP,dzigrarr:rP,Eacute:nP,eacute:iP,easter:sP,Ecaron:oP,ecaron:aP,Ecirc:cP,ecirc:lP,ecir:uP,ecolon:hP,Ecy:dP,ecy:fP,eDDot:gP,Edot:pP,edot:mP,eDot:yP,ee:vP,efDot:MP,Efr:wP,efr:TP,eg:SP,Egrave:IP,egrave:CP,egs:bP,egsdot:xP,el:EP,Element:AP,elinters:NP,ell:DP,els:PP,elsdot:kP,Emacr:LP,emacr:RP,empty:OP,emptyset:zP,EmptySmallSquare:jP,emptyv:BP,EmptyVerySmallSquare:UP,emsp13:FP,emsp14:WP,emsp:$P,ENG:VP,eng:YP,ensp:GP,Eogon:HP,eogon:QP,Eopf:ZP,eopf:KP,epar:qP,eparsl:XP,eplus:JP,epsi:_P,Epsilon:ek,epsilon:tk,epsiv:rk,eqcirc:nk,eqcolon:ik,eqsim:sk,eqslantgtr:ok,eqslantless:ak,Equal:ck,equals:lk,EqualTilde:uk,equest:hk,Equilibrium:dk,equiv:fk,equivDD:gk,eqvparsl:pk,erarr:mk,erDot:yk,escr:vk,Escr:Mk,esdot:wk,Esim:Tk,esim:Sk,Eta:Ik,eta:Ck,ETH:bk,eth:xk,Euml:Ek,euml:Ak,euro:Nk,excl:Dk,exist:Pk,Exists:kk,expectation:Lk,exponentiale:Rk,ExponentialE:Ok,fallingdotseq:zk,Fcy:jk,fcy:Bk,female:Uk,ffilig:Fk,fflig:Wk,ffllig:$k,Ffr:Vk,ffr:Yk,filig:Gk,FilledSmallSquare:Hk,FilledVerySmallSquare:Qk,fjlig:Zk,flat:Kk,fllig:qk,fltns:Xk,fnof:Jk,Fopf:_k,fopf:eL,forall:tL,ForAll:rL,fork:nL,forkv:iL,Fouriertrf:sL,fpartint:oL,frac12:aL,frac13:cL,frac14:lL,frac15:uL,frac16:hL,frac18:dL,frac23:fL,frac25:gL,frac34:pL,frac35:mL,frac38:yL,frac45:vL,frac56:ML,frac58:wL,frac78:TL,frasl:SL,frown:IL,fscr:CL,Fscr:bL,gacute:xL,Gamma:EL,gamma:AL,Gammad:NL,gammad:DL,gap:PL,Gbreve:kL,gbreve:LL,Gcedil:RL,Gcirc:OL,gcirc:zL,Gcy:jL,gcy:BL,Gdot:UL,gdot:FL,ge:WL,gE:$L,gEl:VL,gel:YL,geq:GL,geqq:HL,geqslant:QL,gescc:ZL,ges:KL,gesdot:qL,gesdoto:XL,gesdotol:JL,gesl:_L,gesles:eR,Gfr:tR,gfr:rR,gg:nR,Gg:iR,ggg:sR,gimel:oR,GJcy:aR,gjcy:cR,gla:lR,gl:uR,glE:hR,glj:dR,gnap:fR,gnapprox:gR,gne:pR,gnE:mR,gneq:yR,gneqq:vR,gnsim:MR,Gopf:wR,gopf:TR,grave:SR,GreaterEqual:IR,GreaterEqualLess:CR,GreaterFullEqual:bR,GreaterGreater:xR,GreaterLess:ER,GreaterSlantEqual:AR,GreaterTilde:NR,Gscr:DR,gscr:PR,gsim:kR,gsime:LR,gsiml:RR,gtcc:OR,gtcir:zR,gt:jR,GT:BR,Gt:UR,gtdot:FR,gtlPar:WR,gtquest:$R,gtrapprox:VR,gtrarr:YR,gtrdot:GR,gtreqless:HR,gtreqqless:QR,gtrless:ZR,gtrsim:KR,gvertneqq:qR,gvnE:XR,Hacek:JR,hairsp:_R,half:eO,hamilt:tO,HARDcy:rO,hardcy:nO,harrcir:iO,harr:sO,hArr:oO,harrw:aO,Hat:cO,hbar:lO,Hcirc:uO,hcirc:hO,hearts:dO,heartsuit:fO,hellip:gO,hercon:pO,hfr:mO,Hfr:yO,HilbertSpace:vO,hksearow:MO,hkswarow:wO,hoarr:TO,homtht:SO,hookleftarrow:IO,hookrightarrow:CO,hopf:bO,Hopf:xO,horbar:EO,HorizontalLine:AO,hscr:NO,Hscr:DO,hslash:PO,Hstrok:kO,hstrok:LO,HumpDownHump:RO,HumpEqual:OO,hybull:zO,hyphen:jO,Iacute:BO,iacute:UO,ic:FO,Icirc:WO,icirc:$O,Icy:VO,icy:YO,Idot:GO,IEcy:HO,iecy:QO,iexcl:ZO,iff:KO,ifr:qO,Ifr:XO,Igrave:JO,igrave:_O,ii:ez,iiiint:tz,iiint:rz,iinfin:nz,iiota:iz,IJlig:sz,ijlig:oz,Imacr:az,imacr:cz,image:lz,ImaginaryI:uz,imagline:hz,imagpart:dz,imath:fz,Im:gz,imof:pz,imped:mz,Implies:yz,incare:vz,in:"∈",infin:Mz,infintie:wz,inodot:Tz,intcal:Sz,int:Iz,Int:Cz,integers:bz,Integral:xz,intercal:Ez,Intersection:Az,intlarhk:Nz,intprod:Dz,InvisibleComma:Pz,InvisibleTimes:kz,IOcy:Lz,iocy:Rz,Iogon:Oz,iogon:zz,Iopf:jz,iopf:Bz,Iota:Uz,iota:Fz,iprod:Wz,iquest:$z,iscr:Vz,Iscr:Yz,isin:Gz,isindot:Hz,isinE:Qz,isins:Zz,isinsv:Kz,isinv:qz,it:Xz,Itilde:Jz,itilde:_z,Iukcy:ej,iukcy:tj,Iuml:rj,iuml:nj,Jcirc:ij,jcirc:sj,Jcy:oj,jcy:aj,Jfr:cj,jfr:lj,jmath:uj,Jopf:hj,jopf:dj,Jscr:fj,jscr:gj,Jsercy:pj,jsercy:mj,Jukcy:yj,jukcy:vj,Kappa:Mj,kappa:wj,kappav:Tj,Kcedil:Sj,kcedil:Ij,Kcy:Cj,kcy:bj,Kfr:xj,kfr:Ej,kgreen:Aj,KHcy:Nj,khcy:Dj,KJcy:Pj,kjcy:kj,Kopf:Lj,kopf:Rj,Kscr:Oj,kscr:zj,lAarr:jj,Lacute:Bj,lacute:Uj,laemptyv:Fj,lagran:Wj,Lambda:$j,lambda:Vj,lang:Yj,Lang:Gj,langd:Hj,langle:Qj,lap:Zj,Laplacetrf:Kj,laquo:qj,larrb:Xj,larrbfs:Jj,larr:_j,Larr:e3,lArr:t3,larrfs:r3,larrhk:n3,larrlp:i3,larrpl:s3,larrsim:o3,larrtl:a3,latail:c3,lAtail:l3,lat:u3,late:h3,lates:d3,lbarr:f3,lBarr:g3,lbbrk:p3,lbrace:m3,lbrack:y3,lbrke:v3,lbrksld:M3,lbrkslu:w3,Lcaron:T3,lcaron:S3,Lcedil:I3,lcedil:C3,lceil:b3,lcub:x3,Lcy:E3,lcy:A3,ldca:N3,ldquo:D3,ldquor:P3,ldrdhar:k3,ldrushar:L3,ldsh:R3,le:O3,lE:z3,LeftAngleBracket:j3,LeftArrowBar:B3,leftarrow:U3,LeftArrow:F3,Leftarrow:W3,LeftArrowRightArrow:$3,leftarrowtail:V3,LeftCeiling:Y3,LeftDoubleBracket:G3,LeftDownTeeVector:H3,LeftDownVectorBar:Q3,LeftDownVector:Z3,LeftFloor:K3,leftharpoondown:q3,leftharpoonup:X3,leftleftarrows:J3,leftrightarrow:_3,LeftRightArrow:e4,Leftrightarrow:t4,leftrightarrows:r4,leftrightharpoons:n4,leftrightsquigarrow:i4,LeftRightVector:s4,LeftTeeArrow:o4,LeftTee:a4,LeftTeeVector:c4,leftthreetimes:l4,LeftTriangleBar:u4,LeftTriangle:h4,LeftTriangleEqual:d4,LeftUpDownVector:f4,LeftUpTeeVector:g4,LeftUpVectorBar:p4,LeftUpVector:m4,LeftVectorBar:y4,LeftVector:v4,lEg:M4,leg:w4,leq:T4,leqq:S4,leqslant:I4,lescc:C4,les:b4,lesdot:x4,lesdoto:E4,lesdotor:A4,lesg:N4,lesges:D4,lessapprox:P4,lessdot:k4,lesseqgtr:L4,lesseqqgtr:R4,LessEqualGreater:O4,LessFullEqual:z4,LessGreater:j4,lessgtr:B4,LessLess:U4,lesssim:F4,LessSlantEqual:W4,LessTilde:$4,lfisht:V4,lfloor:Y4,Lfr:G4,lfr:H4,lg:Q4,lgE:Z4,lHar:K4,lhard:q4,lharu:X4,lharul:J4,lhblk:_4,LJcy:eB,ljcy:tB,llarr:rB,ll:nB,Ll:iB,llcorner:sB,Lleftarrow:oB,llhard:aB,lltri:cB,Lmidot:lB,lmidot:uB,lmoustache:hB,lmoust:dB,lnap:fB,lnapprox:gB,lne:pB,lnE:mB,lneq:yB,lneqq:vB,lnsim:MB,loang:wB,loarr:TB,lobrk:SB,longleftarrow:IB,LongLeftArrow:CB,Longleftarrow:bB,longleftrightarrow:xB,LongLeftRightArrow:EB,Longleftrightarrow:AB,longmapsto:NB,longrightarrow:DB,LongRightArrow:PB,Longrightarrow:kB,looparrowleft:LB,looparrowright:RB,lopar:OB,Lopf:zB,lopf:jB,loplus:BB,lotimes:UB,lowast:FB,lowbar:WB,LowerLeftArrow:$B,LowerRightArrow:VB,loz:YB,lozenge:GB,lozf:HB,lpar:QB,lparlt:ZB,lrarr:KB,lrcorner:qB,lrhar:XB,lrhard:JB,lrm:_B,lrtri:e5,lsaquo:t5,lscr:r5,Lscr:n5,lsh:i5,Lsh:s5,lsim:o5,lsime:a5,lsimg:c5,lsqb:l5,lsquo:u5,lsquor:h5,Lstrok:d5,lstrok:f5,ltcc:g5,ltcir:p5,lt:m5,LT:y5,Lt:v5,ltdot:M5,lthree:w5,ltimes:T5,ltlarr:S5,ltquest:I5,ltri:C5,ltrie:b5,ltrif:x5,ltrPar:E5,lurdshar:A5,luruhar:N5,lvertneqq:D5,lvnE:P5,macr:k5,male:L5,malt:R5,maltese:O5,Map:"⤅",map:z5,mapsto:j5,mapstodown:B5,mapstoleft:U5,mapstoup:F5,marker:W5,mcomma:$5,Mcy:V5,mcy:Y5,mdash:G5,mDDot:H5,measuredangle:Q5,MediumSpace:Z5,Mellintrf:K5,Mfr:q5,mfr:X5,mho:J5,micro:_5,midast:eU,midcir:tU,mid:rU,middot:nU,minusb:iU,minus:sU,minusd:oU,minusdu:aU,MinusPlus:cU,mlcp:lU,mldr:uU,mnplus:hU,models:dU,Mopf:fU,mopf:gU,mp:pU,mscr:mU,Mscr:yU,mstpos:vU,Mu:MU,mu:wU,multimap:TU,mumap:SU,nabla:IU,Nacute:CU,nacute:bU,nang:xU,nap:EU,napE:AU,napid:NU,napos:DU,napprox:PU,natural:kU,naturals:LU,natur:RU,nbsp:OU,nbump:zU,nbumpe:jU,ncap:BU,Ncaron:UU,ncaron:FU,Ncedil:WU,ncedil:$U,ncong:VU,ncongdot:YU,ncup:GU,Ncy:HU,ncy:QU,ndash:ZU,nearhk:KU,nearr:qU,neArr:XU,nearrow:JU,ne:_U,nedot:eF,NegativeMediumSpace:tF,NegativeThickSpace:rF,NegativeThinSpace:nF,NegativeVeryThinSpace:iF,nequiv:sF,nesear:oF,nesim:aF,NestedGreaterGreater:cF,NestedLessLess:lF,NewLine:uF,nexist:hF,nexists:dF,Nfr:fF,nfr:gF,ngE:pF,nge:mF,ngeq:yF,ngeqq:vF,ngeqslant:MF,nges:wF,nGg:TF,ngsim:SF,nGt:IF,ngt:CF,ngtr:bF,nGtv:xF,nharr:EF,nhArr:AF,nhpar:NF,ni:DF,nis:PF,nisd:kF,niv:LF,NJcy:RF,njcy:OF,nlarr:zF,nlArr:jF,nldr:BF,nlE:UF,nle:FF,nleftarrow:WF,nLeftarrow:$F,nleftrightarrow:VF,nLeftrightarrow:YF,nleq:GF,nleqq:HF,nleqslant:QF,nles:ZF,nless:KF,nLl:qF,nlsim:XF,nLt:JF,nlt:_F,nltri:eW,nltrie:tW,nLtv:rW,nmid:nW,NoBreak:iW,NonBreakingSpace:sW,nopf:oW,Nopf:aW,Not:cW,not:lW,NotCongruent:uW,NotCupCap:hW,NotDoubleVerticalBar:dW,NotElement:fW,NotEqual:gW,NotEqualTilde:pW,NotExists:mW,NotGreater:yW,NotGreaterEqual:vW,NotGreaterFullEqual:MW,NotGreaterGreater:wW,NotGreaterLess:TW,NotGreaterSlantEqual:SW,NotGreaterTilde:IW,NotHumpDownHump:CW,NotHumpEqual:bW,notin:xW,notindot:EW,notinE:AW,notinva:NW,notinvb:DW,notinvc:PW,NotLeftTriangleBar:kW,NotLeftTriangle:LW,NotLeftTriangleEqual:RW,NotLess:OW,NotLessEqual:zW,NotLessGreater:jW,NotLessLess:BW,NotLessSlantEqual:UW,NotLessTilde:FW,NotNestedGreaterGreater:WW,NotNestedLessLess:$W,notni:VW,notniva:YW,notnivb:GW,notnivc:HW,NotPrecedes:QW,NotPrecedesEqual:ZW,NotPrecedesSlantEqual:KW,NotReverseElement:qW,NotRightTriangleBar:XW,NotRightTriangle:JW,NotRightTriangleEqual:_W,NotSquareSubset:e$,NotSquareSubsetEqual:t$,NotSquareSuperset:r$,NotSquareSupersetEqual:n$,NotSubset:i$,NotSubsetEqual:s$,NotSucceeds:o$,NotSucceedsEqual:a$,NotSucceedsSlantEqual:c$,NotSucceedsTilde:l$,NotSuperset:u$,NotSupersetEqual:h$,NotTilde:d$,NotTildeEqual:f$,NotTildeFullEqual:g$,NotTildeTilde:p$,NotVerticalBar:m$,nparallel:y$,npar:v$,nparsl:M$,npart:w$,npolint:T$,npr:S$,nprcue:I$,nprec:C$,npreceq:b$,npre:x$,nrarrc:E$,nrarr:A$,nrArr:N$,nrarrw:D$,nrightarrow:P$,nRightarrow:k$,nrtri:L$,nrtrie:R$,nsc:O$,nsccue:z$,nsce:j$,Nscr:B$,nscr:U$,nshortmid:F$,nshortparallel:W$,nsim:$$,nsime:V$,nsimeq:Y$,nsmid:G$,nspar:H$,nsqsube:Q$,nsqsupe:Z$,nsub:K$,nsubE:q$,nsube:X$,nsubset:J$,nsubseteq:_$,nsubseteqq:eV,nsucc:tV,nsucceq:rV,nsup:nV,nsupE:iV,nsupe:sV,nsupset:oV,nsupseteq:aV,nsupseteqq:cV,ntgl:lV,Ntilde:uV,ntilde:hV,ntlg:dV,ntriangleleft:fV,ntrianglelefteq:gV,ntriangleright:pV,ntrianglerighteq:mV,Nu:yV,nu:vV,num:MV,numero:wV,numsp:TV,nvap:SV,nvdash:IV,nvDash:CV,nVdash:bV,nVDash:xV,nvge:EV,nvgt:AV,nvHarr:NV,nvinfin:DV,nvlArr:PV,nvle:kV,nvlt:LV,nvltrie:RV,nvrArr:OV,nvrtrie:zV,nvsim:jV,nwarhk:BV,nwarr:UV,nwArr:FV,nwarrow:WV,nwnear:$V,Oacute:VV,oacute:YV,oast:GV,Ocirc:HV,ocirc:QV,ocir:ZV,Ocy:KV,ocy:qV,odash:XV,Odblac:JV,odblac:_V,odiv:eY,odot:tY,odsold:rY,OElig:nY,oelig:iY,ofcir:sY,Ofr:oY,ofr:aY,ogon:cY,Ograve:lY,ograve:uY,ogt:hY,ohbar:dY,ohm:fY,oint:gY,olarr:pY,olcir:mY,olcross:yY,oline:vY,olt:MY,Omacr:wY,omacr:TY,Omega:SY,omega:IY,Omicron:CY,omicron:bY,omid:xY,ominus:EY,Oopf:AY,oopf:NY,opar:DY,OpenCurlyDoubleQuote:PY,OpenCurlyQuote:kY,operp:LY,oplus:RY,orarr:OY,Or:zY,or:jY,ord:BY,order:UY,orderof:FY,ordf:WY,ordm:$Y,origof:VY,oror:YY,orslope:GY,orv:HY,oS:QY,Oscr:ZY,oscr:KY,Oslash:qY,oslash:XY,osol:JY,Otilde:_Y,otilde:eG,otimesas:tG,Otimes:rG,otimes:nG,Ouml:iG,ouml:sG,ovbar:oG,OverBar:aG,OverBrace:cG,OverBracket:lG,OverParenthesis:uG,para:hG,parallel:dG,par:fG,parsim:gG,parsl:pG,part:mG,PartialD:yG,Pcy:vG,pcy:MG,percnt:wG,period:TG,permil:SG,perp:IG,pertenk:CG,Pfr:bG,pfr:xG,Phi:EG,phi:AG,phiv:NG,phmmat:DG,phone:PG,Pi:kG,pi:LG,pitchfork:RG,piv:OG,planck:zG,planckh:jG,plankv:BG,plusacir:UG,plusb:FG,pluscir:WG,plus:$G,plusdo:VG,plusdu:YG,pluse:GG,PlusMinus:HG,plusmn:QG,plussim:ZG,plustwo:KG,pm:qG,Poincareplane:XG,pointint:JG,popf:_G,Popf:e8,pound:t8,prap:r8,Pr:n8,pr:i8,prcue:s8,precapprox:o8,prec:a8,preccurlyeq:c8,Precedes:l8,PrecedesEqual:u8,PrecedesSlantEqual:h8,PrecedesTilde:d8,preceq:f8,precnapprox:g8,precneqq:p8,precnsim:m8,pre:y8,prE:v8,precsim:M8,prime:w8,Prime:T8,primes:S8,prnap:I8,prnE:C8,prnsim:b8,prod:x8,Product:E8,profalar:A8,profline:N8,profsurf:D8,prop:P8,Proportional:k8,Proportion:L8,propto:R8,prsim:O8,prurel:z8,Pscr:j8,pscr:B8,Psi:U8,psi:F8,puncsp:W8,Qfr:$8,qfr:V8,qint:Y8,qopf:G8,Qopf:H8,qprime:Q8,Qscr:Z8,qscr:K8,quaternions:q8,quatint:X8,quest:J8,questeq:_8,quot:e6,QUOT:t6,rAarr:r6,race:n6,Racute:i6,racute:s6,radic:o6,raemptyv:a6,rang:c6,Rang:l6,rangd:u6,range:h6,rangle:d6,raquo:f6,rarrap:g6,rarrb:p6,rarrbfs:m6,rarrc:y6,rarr:v6,Rarr:M6,rArr:w6,rarrfs:T6,rarrhk:S6,rarrlp:I6,rarrpl:C6,rarrsim:b6,Rarrtl:x6,rarrtl:E6,rarrw:A6,ratail:N6,rAtail:D6,ratio:P6,rationals:k6,rbarr:L6,rBarr:R6,RBarr:O6,rbbrk:z6,rbrace:j6,rbrack:B6,rbrke:U6,rbrksld:F6,rbrkslu:W6,Rcaron:$6,rcaron:V6,Rcedil:Y6,rcedil:G6,rceil:H6,rcub:Q6,Rcy:Z6,rcy:K6,rdca:q6,rdldhar:X6,rdquo:J6,rdquor:_6,rdsh:e9,real:t9,realine:r9,realpart:n9,reals:i9,Re:s9,rect:o9,reg:a9,REG:c9,ReverseElement:l9,ReverseEquilibrium:u9,ReverseUpEquilibrium:h9,rfisht:d9,rfloor:f9,rfr:g9,Rfr:p9,rHar:m9,rhard:y9,rharu:v9,rharul:M9,Rho:w9,rho:T9,rhov:S9,RightAngleBracket:I9,RightArrowBar:C9,rightarrow:b9,RightArrow:x9,Rightarrow:E9,RightArrowLeftArrow:A9,rightarrowtail:N9,RightCeiling:D9,RightDoubleBracket:P9,RightDownTeeVector:k9,RightDownVectorBar:L9,RightDownVector:R9,RightFloor:O9,rightharpoondown:z9,rightharpoonup:j9,rightleftarrows:B9,rightleftharpoons:U9,rightrightarrows:F9,rightsquigarrow:W9,RightTeeArrow:$9,RightTee:V9,RightTeeVector:Y9,rightthreetimes:G9,RightTriangleBar:H9,RightTriangle:Q9,RightTriangleEqual:Z9,RightUpDownVector:K9,RightUpTeeVector:q9,RightUpVectorBar:X9,RightUpVector:J9,RightVectorBar:_9,RightVector:eH,ring:tH,risingdotseq:rH,rlarr:nH,rlhar:iH,rlm:sH,rmoustache:oH,rmoust:aH,rnmid:cH,roang:lH,roarr:uH,robrk:hH,ropar:dH,ropf:fH,Ropf:gH,roplus:pH,rotimes:mH,RoundImplies:yH,rpar:vH,rpargt:MH,rppolint:wH,rrarr:TH,Rrightarrow:SH,rsaquo:IH,rscr:CH,Rscr:bH,rsh:xH,Rsh:EH,rsqb:AH,rsquo:NH,rsquor:DH,rthree:PH,rtimes:kH,rtri:LH,rtrie:RH,rtrif:OH,rtriltri:zH,RuleDelayed:jH,ruluhar:BH,rx:UH,Sacute:FH,sacute:WH,sbquo:$H,scap:VH,Scaron:YH,scaron:GH,Sc:HH,sc:QH,sccue:ZH,sce:KH,scE:qH,Scedil:XH,scedil:JH,Scirc:_H,scirc:e7,scnap:t7,scnE:r7,scnsim:n7,scpolint:i7,scsim:s7,Scy:o7,scy:a7,sdotb:c7,sdot:l7,sdote:u7,searhk:h7,searr:d7,seArr:f7,searrow:g7,sect:p7,semi:m7,seswar:y7,setminus:v7,setmn:M7,sext:w7,Sfr:T7,sfr:S7,sfrown:I7,sharp:C7,SHCHcy:b7,shchcy:x7,SHcy:E7,shcy:A7,ShortDownArrow:N7,ShortLeftArrow:D7,shortmid:P7,shortparallel:k7,ShortRightArrow:L7,ShortUpArrow:R7,shy:O7,Sigma:z7,sigma:j7,sigmaf:B7,sigmav:U7,sim:F7,simdot:W7,sime:$7,simeq:V7,simg:Y7,simgE:G7,siml:H7,simlE:Q7,simne:Z7,simplus:K7,simrarr:q7,slarr:X7,SmallCircle:J7,smallsetminus:_7,smashp:eQ,smeparsl:tQ,smid:rQ,smile:nQ,smt:iQ,smte:sQ,smtes:oQ,SOFTcy:aQ,softcy:cQ,solbar:lQ,solb:uQ,sol:hQ,Sopf:dQ,sopf:fQ,spades:gQ,spadesuit:pQ,spar:mQ,sqcap:yQ,sqcaps:vQ,sqcup:MQ,sqcups:wQ,Sqrt:TQ,sqsub:SQ,sqsube:IQ,sqsubset:CQ,sqsubseteq:bQ,sqsup:xQ,sqsupe:EQ,sqsupset:AQ,sqsupseteq:NQ,square:DQ,Square:PQ,SquareIntersection:kQ,SquareSubset:LQ,SquareSubsetEqual:RQ,SquareSuperset:OQ,SquareSupersetEqual:zQ,SquareUnion:jQ,squarf:BQ,squ:UQ,squf:FQ,srarr:WQ,Sscr:$Q,sscr:VQ,ssetmn:YQ,ssmile:GQ,sstarf:HQ,Star:QQ,star:ZQ,starf:KQ,straightepsilon:qQ,straightphi:XQ,strns:JQ,sub:_Q,Sub:eZ,subdot:tZ,subE:rZ,sube:nZ,subedot:iZ,submult:sZ,subnE:oZ,subne:aZ,subplus:cZ,subrarr:lZ,subset:uZ,Subset:hZ,subseteq:dZ,subseteqq:fZ,SubsetEqual:gZ,subsetneq:pZ,subsetneqq:mZ,subsim:yZ,subsub:vZ,subsup:MZ,succapprox:wZ,succ:TZ,succcurlyeq:SZ,Succeeds:IZ,SucceedsEqual:CZ,SucceedsSlantEqual:bZ,SucceedsTilde:xZ,succeq:EZ,succnapprox:AZ,succneqq:NZ,succnsim:DZ,succsim:PZ,SuchThat:kZ,sum:LZ,Sum:RZ,sung:OZ,sup1:zZ,sup2:jZ,sup3:BZ,sup:UZ,Sup:FZ,supdot:WZ,supdsub:$Z,supE:VZ,supe:YZ,supedot:GZ,Superset:HZ,SupersetEqual:QZ,suphsol:ZZ,suphsub:KZ,suplarr:qZ,supmult:XZ,supnE:JZ,supne:_Z,supplus:eK,supset:tK,Supset:rK,supseteq:nK,supseteqq:iK,supsetneq:sK,supsetneqq:oK,supsim:aK,supsub:cK,supsup:lK,swarhk:uK,swarr:hK,swArr:dK,swarrow:fK,swnwar:gK,szlig:pK,Tab:mK,target:yK,Tau:vK,tau:MK,tbrk:wK,Tcaron:TK,tcaron:SK,Tcedil:IK,tcedil:CK,Tcy:bK,tcy:xK,tdot:EK,telrec:AK,Tfr:NK,tfr:DK,there4:PK,therefore:kK,Therefore:LK,Theta:RK,theta:OK,thetasym:zK,thetav:jK,thickapprox:BK,thicksim:UK,ThickSpace:FK,ThinSpace:WK,thinsp:$K,thkap:VK,thksim:YK,THORN:GK,thorn:HK,tilde:QK,Tilde:ZK,TildeEqual:KK,TildeFullEqual:qK,TildeTilde:XK,timesbar:JK,timesb:_K,times:eq,timesd:tq,tint:rq,toea:nq,topbot:iq,topcir:sq,top:oq,Topf:aq,topf:cq,topfork:lq,tosa:uq,tprime:hq,trade:dq,TRADE:fq,triangle:gq,triangledown:pq,triangleleft:mq,trianglelefteq:yq,triangleq:vq,triangleright:Mq,trianglerighteq:wq,tridot:Tq,trie:Sq,triminus:Iq,TripleDot:Cq,triplus:bq,trisb:xq,tritime:Eq,trpezium:Aq,Tscr:Nq,tscr:Dq,TScy:Pq,tscy:kq,TSHcy:Lq,tshcy:Rq,Tstrok:Oq,tstrok:zq,twixt:jq,twoheadleftarrow:Bq,twoheadrightarrow:Uq,Uacute:Fq,uacute:Wq,uarr:$q,Uarr:Vq,uArr:Yq,Uarrocir:Gq,Ubrcy:Hq,ubrcy:Qq,Ubreve:Zq,ubreve:Kq,Ucirc:qq,ucirc:Xq,Ucy:Jq,ucy:_q,udarr:eX,Udblac:tX,udblac:rX,udhar:nX,ufisht:iX,Ufr:sX,ufr:oX,Ugrave:aX,ugrave:cX,uHar:lX,uharl:uX,uharr:hX,uhblk:dX,ulcorn:fX,ulcorner:gX,ulcrop:pX,ultri:mX,Umacr:yX,umacr:vX,uml:MX,UnderBar:wX,UnderBrace:TX,UnderBracket:SX,UnderParenthesis:IX,Union:CX,UnionPlus:bX,Uogon:xX,uogon:EX,Uopf:AX,uopf:NX,UpArrowBar:DX,uparrow:PX,UpArrow:kX,Uparrow:LX,UpArrowDownArrow:RX,updownarrow:OX,UpDownArrow:zX,Updownarrow:jX,UpEquilibrium:BX,upharpoonleft:UX,upharpoonright:FX,uplus:WX,UpperLeftArrow:$X,UpperRightArrow:VX,upsi:YX,Upsi:GX,upsih:HX,Upsilon:QX,upsilon:ZX,UpTeeArrow:KX,UpTee:qX,upuparrows:XX,urcorn:JX,urcorner:_X,urcrop:eJ,Uring:tJ,uring:rJ,urtri:nJ,Uscr:iJ,uscr:sJ,utdot:oJ,Utilde:aJ,utilde:cJ,utri:lJ,utrif:uJ,uuarr:hJ,Uuml:dJ,uuml:fJ,uwangle:gJ,vangrt:pJ,varepsilon:mJ,varkappa:yJ,varnothing:vJ,varphi:MJ,varpi:wJ,varpropto:TJ,varr:SJ,vArr:IJ,varrho:CJ,varsigma:bJ,varsubsetneq:xJ,varsubsetneqq:EJ,varsupsetneq:AJ,varsupsetneqq:NJ,vartheta:DJ,vartriangleleft:PJ,vartriangleright:kJ,vBar:LJ,Vbar:RJ,vBarv:OJ,Vcy:zJ,vcy:jJ,vdash:BJ,vDash:UJ,Vdash:FJ,VDash:WJ,Vdashl:$J,veebar:VJ,vee:YJ,Vee:GJ,veeeq:HJ,vellip:QJ,verbar:ZJ,Verbar:KJ,vert:qJ,Vert:XJ,VerticalBar:JJ,VerticalLine:_J,VerticalSeparator:e_,VerticalTilde:t_,VeryThinSpace:r_,Vfr:n_,vfr:i_,vltri:s_,vnsub:o_,vnsup:a_,Vopf:c_,vopf:l_,vprop:u_,vrtri:h_,Vscr:d_,vscr:f_,vsubnE:g_,vsubne:p_,vsupnE:m_,vsupne:y_,Vvdash:v_,vzigzag:M_,Wcirc:w_,wcirc:T_,wedbar:S_,wedge:I_,Wedge:C_,wedgeq:b_,weierp:x_,Wfr:E_,wfr:A_,Wopf:N_,wopf:D_,wp:P_,wr:k_,wreath:L_,Wscr:R_,wscr:O_,xcap:z_,xcirc:j_,xcup:B_,xdtri:U_,Xfr:F_,xfr:W_,xharr:$_,xhArr:V_,Xi:Y_,xi:G_,xlarr:H_,xlArr:Q_,xmap:Z_,xnis:K_,xodot:q_,Xopf:X_,xopf:J_,xoplus:__,xotime:eee,xrarr:tee,xrArr:ree,Xscr:nee,xscr:iee,xsqcup:see,xuplus:oee,xutri:aee,xvee:cee,xwedge:lee,Yacute:uee,yacute:hee,YAcy:dee,yacy:fee,Ycirc:gee,ycirc:pee,Ycy:mee,ycy:yee,yen:vee,Yfr:Mee,yfr:wee,YIcy:Tee,yicy:See,Yopf:Iee,yopf:Cee,Yscr:bee,yscr:xee,YUcy:Eee,yucy:Aee,yuml:Nee,Yuml:Dee,Zacute:Pee,zacute:kee,Zcaron:Lee,zcaron:Ree,Zcy:Oee,zcy:zee,Zdot:jee,zdot:Bee,zeetrf:Uee,ZeroWidthSpace:Fee,Zeta:Wee,zeta:$ee,zfr:Vee,Zfr:Yee,ZHcy:Gee,zhcy:Hee,zigrarr:Qee,zopf:Zee,Zopf:Kee,Zscr:qee,zscr:Xee,zwj:Jee,zwnj:_ee},ete="Á",tte="á",rte="Â",nte="â",ite="´",ste="Æ",ote="æ",ate="À",cte="à",lte="&",ute="&",hte="Å",dte="å",fte="Ã",gte="ã",pte="Ä",mte="ä",yte="¦",vte="Ç",Mte="ç",wte="¸",Tte="¢",Ste="©",Ite="©",Cte="¤",bte="°",xte="÷",Ete="É",Ate="é",Nte="Ê",Dte="ê",Pte="È",kte="è",Lte="Ð",Rte="ð",Ote="Ë",zte="ë",jte="½",Bte="¼",Ute="¾",Fte=">",Wte=">",$te="Í",Vte="í",Yte="Î",Gte="î",Hte="¡",Qte="Ì",Zte="ì",Kte="¿",qte="Ï",Xte="ï",Jte="«",_te="<",ere="<",tre="¯",rre="µ",nre="·",ire=" ",sre="¬",ore="Ñ",are="ñ",cre="Ó",lre="ó",ure="Ô",hre="ô",dre="Ò",fre="ò",gre="ª",pre="º",mre="Ø",yre="ø",vre="Õ",Mre="õ",wre="Ö",Tre="ö",Sre="¶",Ire="±",Cre="£",bre='"',xre='"',Ere="»",Are="®",Nre="®",Dre="§",Pre="­",kre="¹",Lre="²",Rre="³",Ore="ß",zre="Þ",jre="þ",Bre="×",Ure="Ú",Fre="ú",Wre="Û",$re="û",Vre="Ù",Yre="ù",Gre="¨",Hre="Ü",Qre="ü",Zre="Ý",Kre="ý",qre="¥",Xre="ÿ",Jre={Aacute:ete,aacute:tte,Acirc:rte,acirc:nte,acute:ite,AElig:ste,aelig:ote,Agrave:ate,agrave:cte,amp:lte,AMP:ute,Aring:hte,aring:dte,Atilde:fte,atilde:gte,Auml:pte,auml:mte,brvbar:yte,Ccedil:vte,ccedil:Mte,cedil:wte,cent:Tte,copy:Ste,COPY:Ite,curren:Cte,deg:bte,divide:xte,Eacute:Ete,eacute:Ate,Ecirc:Nte,ecirc:Dte,Egrave:Pte,egrave:kte,ETH:Lte,eth:Rte,Euml:Ote,euml:zte,frac12:jte,frac14:Bte,frac34:Ute,gt:Fte,GT:Wte,Iacute:$te,iacute:Vte,Icirc:Yte,icirc:Gte,iexcl:Hte,Igrave:Qte,igrave:Zte,iquest:Kte,Iuml:qte,iuml:Xte,laquo:Jte,lt:_te,LT:ere,macr:tre,micro:rre,middot:nre,nbsp:ire,not:sre,Ntilde:ore,ntilde:are,Oacute:cre,oacute:lre,Ocirc:ure,ocirc:hre,Ograve:dre,ograve:fre,ordf:gre,ordm:pre,Oslash:mre,oslash:yre,Otilde:vre,otilde:Mre,Ouml:wre,ouml:Tre,para:Sre,plusmn:Ire,pound:Cre,quot:bre,QUOT:xre,raquo:Ere,reg:Are,REG:Nre,sect:Dre,shy:Pre,sup1:kre,sup2:Lre,sup3:Rre,szlig:Ore,THORN:zre,thorn:jre,times:Bre,Uacute:Ure,uacute:Fre,Ucirc:Wre,ucirc:$re,Ugrave:Vre,ugrave:Yre,uml:Gre,Uuml:Hre,uuml:Qre,Yacute:Zre,yacute:Kre,yen:qre,yuml:Xre},_re="&",ene="'",tne=">",rne="<",nne='"',xm={amp:_re,apos:ene,gt:tne,lt:rne,quot:nne};var ih={};const ine={0:65533,128:8364,130:8218,131:402,132:8222,133:8230,134:8224,135:8225,136:710,137:8240,138:352,139:8249,140:338,142:381,145:8216,146:8217,147:8220,148:8221,149:8226,150:8211,151:8212,152:732,153:8482,154:353,155:8250,156:339,158:382,159:376};var sne=vt&&vt.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(ih,"__esModule",{value:!0});var Mf=sne(ine),one=String.fromCodePoint||function(i){var t="";return i>65535&&(i-=65536,t+=String.fromCharCode(i>>>10&1023|55296),i=56320|i&1023),t+=String.fromCharCode(i),t};function ane(i){return i>=55296&&i<=57343||i>1114111?"�":(i in Mf.default&&(i=Mf.default[i]),one(i))}ih.default=ane;var Ya=vt&&vt.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(Xr,"__esModule",{value:!0});Xr.decodeHTML=Xr.decodeHTMLStrict=Xr.decodeXML=void 0;var Gl=Ya(bm),cne=Ya(Jre),lne=Ya(xm),wf=Ya(ih),une=/&(?:[a-zA-Z0-9]+|#[xX][\da-fA-F]+|#\d+);/g;Xr.decodeXML=Em(lne.default);Xr.decodeHTMLStrict=Em(Gl.default);function Em(i){var t=Am(i);return function(e){return String(e).replace(une,t)}}var Tf=function(i,t){return i<t?1:-1};Xr.decodeHTML=function(){for(var i=Object.keys(cne.default).sort(Tf),t=Object.keys(Gl.default).sort(Tf),e=0,r=0;e<t.length;e++)i[r]===t[e]?(t[e]+=";?",r++):t[e]+=";";var n=new RegExp("&(?:"+t.join("|")+"|#[xX][\\da-fA-F]+;?|#\\d+;?)","g"),s=Am(Gl.default);function o(a){return a.substr(-1)!==";"&&(a+=";"),s(a)}return function(a){return String(a).replace(n,o)}}();function Am(i){return function(e){if(e.charAt(1)==="#"){var r=e.charAt(2);return r==="X"||r==="x"?wf.default(parseInt(e.substr(3),16)):wf.default(parseInt(e.substr(2),10))}return i[e.slice(1,-1)]||e}}var tr={},Nm=vt&&vt.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(tr,"__esModule",{value:!0});tr.escapeUTF8=tr.escape=tr.encodeNonAsciiHTML=tr.encodeHTML=tr.encodeXML=void 0;var hne=Nm(xm),Dm=km(hne.default),Pm=Lm(Dm);tr.encodeXML=zm(Dm);var dne=Nm(bm),sh=km(dne.default),fne=Lm(sh);tr.encodeHTML=pne(sh,fne);tr.encodeNonAsciiHTML=zm(sh);function km(i){return Object.keys(i).sort().reduce(function(t,e){return t[i[e]]="&"+e+";",t},{})}function Lm(i){for(var t=[],e=[],r=0,n=Object.keys(i);r<n.length;r++){var s=n[r];s.length===1?t.push("\\"+s):e.push(s)}t.sort();for(var o=0;o<t.length-1;o++){for(var a=o;a<t.length-1&&t[a].charCodeAt(1)+1===t[a+1].charCodeAt(1);)a+=1;var c=1+a-o;c<3||t.splice(o,c,t[o]+"-"+t[a])}return e.unshift("["+t.join("")+"]"),new RegExp(e.join("|"),"g")}var Rm=/(?:[\x80-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/g,gne=String.prototype.codePointAt!=null?function(i){return i.codePointAt(0)}:function(i){return(i.charCodeAt(0)-55296)*1024+i.charCodeAt(1)-56320+65536};function Ga(i){return"&#x"+(i.length>1?gne(i):i.charCodeAt(0)).toString(16).toUpperCase()+";"}function pne(i,t){return function(e){return e.replace(t,function(r){return i[r]}).replace(Rm,Ga)}}var Om=new RegExp(Pm.source+"|"+Rm.source,"g");function mne(i){return i.replace(Om,Ga)}tr.escape=mne;function yne(i){return i.replace(Pm,Ga)}tr.escapeUTF8=yne;function zm(i){return function(t){return t.replace(Om,function(e){return i[e]||Ga(e)})}}(function(i){Object.defineProperty(i,"__esModule",{value:!0}),i.decodeXMLStrict=i.decodeHTML5Strict=i.decodeHTML4Strict=i.decodeHTML5=i.decodeHTML4=i.decodeHTMLStrict=i.decodeHTML=i.decodeXML=i.encodeHTML5=i.encodeHTML4=i.escapeUTF8=i.escape=i.encodeNonAsciiHTML=i.encodeHTML=i.encodeXML=i.encode=i.decodeStrict=i.decode=void 0;var t=Xr,e=tr;function r(c,l){return(!l||l<=0?t.decodeXML:t.decodeHTML)(c)}i.decode=r;function n(c,l){return(!l||l<=0?t.decodeXML:t.decodeHTMLStrict)(c)}i.decodeStrict=n;function s(c,l){return(!l||l<=0?e.encodeXML:e.encodeHTML)(c)}i.encode=s;var o=tr;Object.defineProperty(i,"encodeXML",{enumerable:!0,get:function(){return o.encodeXML}}),Object.defineProperty(i,"encodeHTML",{enumerable:!0,get:function(){return o.encodeHTML}}),Object.defineProperty(i,"encodeNonAsciiHTML",{enumerable:!0,get:function(){return o.encodeNonAsciiHTML}}),Object.defineProperty(i,"escape",{enumerable:!0,get:function(){return o.escape}}),Object.defineProperty(i,"escapeUTF8",{enumerable:!0,get:function(){return o.escapeUTF8}}),Object.defineProperty(i,"encodeHTML4",{enumerable:!0,get:function(){return o.encodeHTML}}),Object.defineProperty(i,"encodeHTML5",{enumerable:!0,get:function(){return o.encodeHTML}});var a=Xr;Object.defineProperty(i,"decodeXML",{enumerable:!0,get:function(){return a.decodeXML}}),Object.defineProperty(i,"decodeHTML",{enumerable:!0,get:function(){return a.decodeHTML}}),Object.defineProperty(i,"decodeHTMLStrict",{enumerable:!0,get:function(){return a.decodeHTMLStrict}}),Object.defineProperty(i,"decodeHTML4",{enumerable:!0,get:function(){return a.decodeHTML}}),Object.defineProperty(i,"decodeHTML5",{enumerable:!0,get:function(){return a.decodeHTML}}),Object.defineProperty(i,"decodeHTML4Strict",{enumerable:!0,get:function(){return a.decodeHTMLStrict}}),Object.defineProperty(i,"decodeHTML5Strict",{enumerable:!0,get:function(){return a.decodeHTMLStrict}}),Object.defineProperty(i,"decodeXMLStrict",{enumerable:!0,get:function(){return a.decodeXML}})})(Cm);const vne={altglyph:"altGlyph",altglyphdef:"altGlyphDef",altglyphitem:"altGlyphItem",animatecolor:"animateColor",animatemotion:"animateMotion",animatetransform:"animateTransform",clippath:"clipPath",feblend:"feBlend",fecolormatrix:"feColorMatrix",fecomponenttransfer:"feComponentTransfer",fecomposite:"feComposite",feconvolvematrix:"feConvolveMatrix",fediffuselighting:"feDiffuseLighting",fedisplacementmap:"feDisplacementMap",fedistantlight:"feDistantLight",fedropshadow:"feDropShadow",feflood:"feFlood",fefunca:"feFuncA",fefuncb:"feFuncB",fefuncg:"feFuncG",fefuncr:"feFuncR",fegaussianblur:"feGaussianBlur",feimage:"feImage",femerge:"feMerge",femergenode:"feMergeNode",femorphology:"feMorphology",feoffset:"feOffset",fepointlight:"fePointLight",fespecularlighting:"feSpecularLighting",fespotlight:"feSpotLight",fetile:"feTile",feturbulence:"feTurbulence",foreignobject:"foreignObject",glyphref:"glyphRef",lineargradient:"linearGradient",radialgradient:"radialGradient",textpath:"textPath"},Mne={definitionurl:"definitionURL",attributename:"attributeName",attributetype:"attributeType",basefrequency:"baseFrequency",baseprofile:"baseProfile",calcmode:"calcMode",clippathunits:"clipPathUnits",diffuseconstant:"diffuseConstant",edgemode:"edgeMode",filterunits:"filterUnits",glyphref:"glyphRef",gradienttransform:"gradientTransform",gradientunits:"gradientUnits",kernelmatrix:"kernelMatrix",kernelunitlength:"kernelUnitLength",keypoints:"keyPoints",keysplines:"keySplines",keytimes:"keyTimes",lengthadjust:"lengthAdjust",limitingconeangle:"limitingConeAngle",markerheight:"markerHeight",markerunits:"markerUnits",markerwidth:"markerWidth",maskcontentunits:"maskContentUnits",maskunits:"maskUnits",numoctaves:"numOctaves",pathlength:"pathLength",patterncontentunits:"patternContentUnits",patterntransform:"patternTransform",patternunits:"patternUnits",pointsatx:"pointsAtX",pointsaty:"pointsAtY",pointsatz:"pointsAtZ",preservealpha:"preserveAlpha",preserveaspectratio:"preserveAspectRatio",primitiveunits:"primitiveUnits",refx:"refX",refy:"refY",repeatcount:"repeatCount",repeatdur:"repeatDur",requiredextensions:"requiredExtensions",requiredfeatures:"requiredFeatures",specularconstant:"specularConstant",specularexponent:"specularExponent",spreadmethod:"spreadMethod",startoffset:"startOffset",stddeviation:"stdDeviation",stitchtiles:"stitchTiles",surfacescale:"surfaceScale",systemlanguage:"systemLanguage",tablevalues:"tableValues",targetx:"targetX",targety:"targetY",textlength:"textLength",viewbox:"viewBox",viewtarget:"viewTarget",xchannelselector:"xChannelSelector",ychannelselector:"yChannelSelector",zoomandpan:"zoomAndPan"},wne={elementNames:vne,attributeNames:Mne};var Io=Im,jm=Cm,Ha=wne;Ha.elementNames.__proto__=null;Ha.attributeNames.__proto__=null;var Tne={__proto__:null,style:!0,script:!0,xmp:!0,iframe:!0,noembed:!0,noframes:!0,plaintext:!0,noscript:!0};function Sne(i,t){if(i){var e="",r;for(var n in i)r=i[n],e&&(e+=" "),t.xmlMode==="foreign"&&(n=Ha.attributeNames[n]||n),e+=n,(r!==null&&r!==""||t.xmlMode)&&(e+='="'+(t.decodeEntities?jm.encodeXML(r):r.replace(/\"/g,"&quot;"))+'"');return e}}var Ine={__proto__:null,area:!0,base:!0,basefont:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,isindex:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},Bm=Sm.exports=function(i,t){!Array.isArray(i)&&!i.cheerio&&(i=[i]),t=t||{};for(var e="",r=0;r<i.length;r++){var n=i[r];n.type==="root"?e+=Bm(n.children,t):Io.isTag(n)?e+=bne(n,t):n.type===Io.Directive?e+=xne(n):n.type===Io.Comment?e+=Nne(n):n.type===Io.CDATA?e+=Ane(n):e+=Ene(n,t)}return e},Cne=["mi","mo","mn","ms","mtext","annotation-xml","foreignObject","desc","title"];function bne(i,t){t.xmlMode==="foreign"&&(i.name=Ha.elementNames[i.name]||i.name,i.parent&&Cne.indexOf(i.parent.name)>=0&&(t=Object.assign({},t,{xmlMode:!1}))),!t.xmlMode&&["svg","math"].indexOf(i.name)>=0&&(t=Object.assign({},t,{xmlMode:"foreign"}));var e="<"+i.name,r=Sne(i.attribs,t);return r&&(e+=" "+r),t.xmlMode&&(!i.children||i.children.length===0)?e+="/>":(e+=">",i.children&&(e+=Bm(i.children,t)),(!Ine[i.name]||t.xmlMode)&&(e+="</"+i.name+">")),e}function xne(i){return"<"+i.data+">"}function Ene(i,t){var e=i.data||"";return t.decodeEntities&&!(i.parent&&i.parent.name in Tne)&&(e=jm.encodeXML(e)),e}function Ane(i){return"<![CDATA["+i.children[0].data+"]]>"}function Nne(i){return"<!--"+i.data+"-->"}var Dne=Sm.exports,Hl=nh,Um=Dne,Pne=Hl.isTag,kne={getInnerHTML:Lne,getOuterHTML:Um,getText:Qo};function Lne(i,t){return i.children?i.children.map(function(e){return Um(e,t)}).join(""):""}function Qo(i){return Array.isArray(i)?i.map(Qo).join(""):Pne(i)?i.name==="br"?`
569
+ `:Qo(i.children):i.type===Hl.CDATA?Qo(i.children):i.type===Hl.Text?i.data:""}var ai={},Rne=ai.getChildren=function(i){return i.children},One=ai.getParent=function(i){return i.parent};ai.getSiblings=function(i){var t=One(i);return t?Rne(t):[i]};ai.getAttributeValue=function(i,t){return i.attribs&&i.attribs[t]};ai.hasAttrib=function(i,t){return!!i.attribs&&hasOwnProperty.call(i.attribs,t)};ai.getName=function(i){return i.name};var Yi={};Yi.removeElement=function(i){if(i.prev&&(i.prev.next=i.next),i.next&&(i.next.prev=i.prev),i.parent){var t=i.parent.children;t.splice(t.lastIndexOf(i),1)}};Yi.replaceElement=function(i,t){var e=t.prev=i.prev;e&&(e.next=t);var r=t.next=i.next;r&&(r.prev=t);var n=t.parent=i.parent;if(n){var s=n.children;s[s.lastIndexOf(i)]=t}};Yi.appendChild=function(i,t){if(t.parent=i,i.children.push(t)!==1){var e=i.children[i.children.length-2];e.next=t,t.prev=e,t.next=null}};Yi.append=function(i,t){var e=i.parent,r=i.next;if(t.next=r,t.prev=i,i.next=t,t.parent=e,r){if(r.prev=t,e){var n=e.children;n.splice(n.lastIndexOf(r),0,t)}}else e&&e.children.push(t)};Yi.prepend=function(i,t){var e=i.parent;if(e){var r=e.children;r.splice(r.lastIndexOf(i),0,t)}i.prev&&(i.prev.next=t),t.parent=e,t.prev=i.prev,t.next=i,i.prev=t};var oh=nh.isTag,zne={filter:jne,find:ah,findOneChild:Bne,findOne:Fm,existsOne:Wm,findAll:Une};function jne(i,t,e,r){return Array.isArray(t)||(t=[t]),(typeof r!="number"||!isFinite(r))&&(r=1/0),ah(i,t,e!==!1,r)}function ah(i,t,e,r){for(var n=[],s,o=0,a=t.length;o<a&&!(i(t[o])&&(n.push(t[o]),--r<=0)||(s=t[o].children,e&&s&&s.length>0&&(s=ah(i,s,e,r),n=n.concat(s),r-=s.length,r<=0)));o++);return n}function Bne(i,t){for(var e=0,r=t.length;e<r;e++)if(i(t[e]))return t[e];return null}function Fm(i,t){for(var e=null,r=0,n=t.length;r<n&&!e;r++)if(oh(t[r]))i(t[r])?e=t[r]:t[r].children.length>0&&(e=Fm(i,t[r].children));else continue;return e}function Wm(i,t){for(var e=0,r=t.length;e<r;e++)if(oh(t[e])&&(i(t[e])||t[e].children.length>0&&Wm(i,t[e].children)))return!0;return!1}function Une(i,t){for(var e=[],r=t.slice();r.length;){var n=r.shift();oh(n)&&(n.children&&n.children.length>0&&r.unshift.apply(r,n.children),i(n)&&e.push(n))}return e}var ci={},Fne=nh,Wn=ci.isTag=Fne.isTag;ci.testElement=function(i,t){for(var e in i)if(i.hasOwnProperty(e)){if(e==="tag_name"){if(!Wn(t)||!i.tag_name(t.name))return!1}else if(e==="tag_type"){if(!i.tag_type(t.type))return!1}else if(e==="tag_contains"){if(Wn(t)||!i.tag_contains(t.data))return!1}else if(!t.attribs||!i[e](t.attribs[e]))return!1}return!0};var ia={tag_name:function(i){return typeof i=="function"?function(t){return Wn(t)&&i(t.name)}:i==="*"?Wn:function(t){return Wn(t)&&t.name===i}},tag_type:function(i){return typeof i=="function"?function(t){return i(t.type)}:function(t){return t.type===i}},tag_contains:function(i){return typeof i=="function"?function(t){return!Wn(t)&&i(t.data)}:function(t){return!Wn(t)&&t.data===i}}};function $m(i,t){return typeof t=="function"?function(e){return e.attribs&&t(e.attribs[i])}:function(e){return e.attribs&&e.attribs[i]===t}}function Wne(i,t){return function(e){return i(e)||t(e)}}ci.getElements=function(i,t,e,r){var n=Object.keys(i).map(function(s){var o=i[s];return s in ia?ia[s](o):$m(s,o)});return n.length===0?[]:this.filter(n.reduce(Wne),t,e,r)};ci.getElementById=function(i,t,e){return Array.isArray(t)||(t=[t]),this.findOne($m("id",i),t,e!==!1)};ci.getElementsByTagName=function(i,t,e,r){return this.filter(ia.tag_name(i),t,e,r)};ci.getElementsByTagType=function(i,t,e,r){return this.filter(ia.tag_type(i),t,e,r)};var Qa={};Qa.removeSubsets=function(i){for(var t=i.length,e,r,n;--t>-1;){for(e=r=i[t],i[t]=null,n=!0;r;){if(i.indexOf(r)>-1){n=!1,i.splice(t,1);break}r=r.parent}n&&(i[t]=e)}return i};var Wr={DISCONNECTED:1,PRECEDING:2,FOLLOWING:4,CONTAINS:8,CONTAINED_BY:16},$ne=Qa.compareDocumentPosition=function(i,t){var e=[],r=[],n,s,o,a,c,l;if(i===t)return 0;for(n=i;n;)e.unshift(n),n=n.parent;for(n=t;n;)r.unshift(n),n=n.parent;for(l=0;e[l]===r[l];)l++;return l===0?Wr.DISCONNECTED:(s=e[l-1],o=s.children,a=e[l],c=r[l],o.indexOf(a)>o.indexOf(c)?s===t?Wr.FOLLOWING|Wr.CONTAINED_BY:Wr.FOLLOWING:s===i?Wr.PRECEDING|Wr.CONTAINS:Wr.PRECEDING)};Qa.uniqueSort=function(i){var t=i.length,e,r;for(i=i.slice();--t>-1;)e=i[t],r=i.indexOf(e),r>-1&&r<t&&i.splice(t,1);return i.sort(function(n,s){var o=$ne(n,s);return o&Wr.PRECEDING?-1:o&Wr.FOLLOWING?1:0}),i};(function(i){var t=i.exports;[kne,ai,Yi,zne,ci,Qa].forEach(function(e){Object.keys(e).forEach(function(r){t[r]=e[r].bind(t)})})})(Tm);var Vne=Tm.exports,Qs={trueFunc:function(){return!0},falseFunc:function(){return!1}},Vm={},sa={};Object.defineProperty(sa,"__esModule",{value:!0});sa.default=qne;var Sf=/^[^\\]?(?:\\(?:[\da-f]{1,6}\s?|.)|[\w\-\u00b0-\uFFFF])+/,Yne=/\\([\da-f]{1,6}\s?|(\s)|.)/gi,Gne=/^\s*((?:\\.|[\w\u00b0-\uFFFF-])+)\s*(?:(\S?)=\s*(?:(['"])((?:[^\\]|\\[^])*?)\3|(#?(?:\\.|[\w\u00b0-\uFFFF-])*)|)|)\s*(i)?\]/,Hne={undefined:"exists","":"equals","~":"element","^":"start",$:"end","*":"any","!":"not","|":"hyphen"},If={">":"child","<":"parent","~":"sibling","+":"adjacent"},Cf={"#":["id","equals"],".":["class","element"]},Qne=new Set(["has","not","matches","is","host","host-context"]),Zne=new Set(["contains","icontains"]),bf=new Set(['"',"'"]);function Kne(i,t,e){var r=parseInt(t,16)-65536;return r!==r||e?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,r&1023|56320)}function Co(i){return i.replace(Yne,Kne)}function xf(i){return i===" "||i===`
570
+ `||i===" "||i==="\f"||i==="\r"}function qne(i,t){var e=[];if(i=Ym(e,""+i,t),i!=="")throw new Error("Unmatched selector: "+i);return e}function Ym(i,t,e){var r,n;e===void 0&&(e={});var s=[],o=!1;function a(){var N=t.match(Sf);if(!N)throw new Error("Expected name, found "+t);var A=N[0];return t=t.substr(A.length),Co(A)}function c(N){for(;xf(t.charAt(N));)N++;t=t.substr(N)}function l(N){for(var A=0;t.charAt(--N)==="\\";)A++;return(A&1)===1}for(c(0);t!=="";){var u=t.charAt(0);if(xf(u))o=!0,c(1);else if(u in If)s.push({type:If[u]}),o=!1,c(1);else if(u===","){if(s.length===0)throw new Error("Empty sub-selector");i.push(s),s=[],o=!1,c(1)}else if(o&&(s.length>0&&s.push({type:"descendant"}),o=!1),u==="*")t=t.substr(1),s.push({type:"universal"});else if(u in Cf){var h=Cf[u],d=h[0],g=h[1];t=t.substr(1),s.push({type:"attribute",name:d,action:g,value:a(),ignoreCase:!1})}else if(u==="["){t=t.substr(1);var p=t.match(Gne);if(!p)throw new Error("Malformed attribute selector: "+t);var v=p[0],I=p[1],D=p[2],x=p[4],j=x===void 0?"":x,w=p[5],y=w===void 0?j:w,f=p[6];t=t.substr(v.length);var M=Co(I);((r=e.lowerCaseAttributeNames)!==null&&r!==void 0?r:!e.xmlMode)&&(M=M.toLowerCase()),s.push({type:"attribute",name:M,action:Hne[D],value:Co(y),ignoreCase:!!f})}else if(u===":"){if(t.charAt(1)===":"){t=t.substr(2),s.push({type:"pseudo-element",name:a().toLowerCase()});continue}t=t.substr(1);var T=a().toLowerCase(),b=null;if(t.startsWith("("))if(Qne.has(T)){var C=t.charAt(1),P=bf.has(C);if(t=t.substr(P?2:1),b=[],t=Ym(b,t,e),P)if(t.startsWith(C))t=t.substr(1);else throw new Error("Unmatched quotes in :"+T);if(!t.startsWith(")"))throw new Error("Missing closing parenthesis in :"+T+" ("+t+")");t=t.substr(1)}else{for(var E=1,O=1;O>0&&E<t.length;E++)t.charAt(E)==="("&&!l(E)?O++:t.charAt(E)===")"&&!l(E)&&O--;if(O)throw new Error("Parenthesis not matched");if(b=t.substr(1,E-2),t=t.substr(E),Zne.has(T)){var C=b.charAt(0);C===b.slice(-1)&&bf.has(C)&&(b=b.slice(1,-1)),b=Co(b)}}s.push({type:"pseudo",name:T,data:b})}else if(Sf.test(t)){var V=a();((n=e.lowerCaseTags)!==null&&n!==void 0?n:!e.xmlMode)&&(V=V.toLowerCase()),s.push({type:"tag",name:V})}else return s.length&&s[s.length-1].type==="descendant"&&s.pop(),Ef(i,s),t}return Ef(i,s),t}function Ef(i,t){if(i.length>0&&t.length===0)throw new Error("Empty sub-selector");i.push(t)}var ch={},Xne=vt&&vt.__spreadArrays||function(){for(var i=0,t=0,e=arguments.length;t<e;t++)i+=arguments[t].length;for(var r=Array(i),n=0,t=0;t<e;t++)for(var s=arguments[t],o=0,a=s.length;o<a;o++,n++)r[n]=s[o];return r};Object.defineProperty(ch,"__esModule",{value:!0});var Ql={equals:"",element:"~",start:"^",end:"$",any:"*",not:"!",hyphen:"|"},Jne=new Set(Xne(Object.keys(Ql).map(function(i){return Ql[i]}).filter(Boolean),[":","[","]"," ","\\"]));function Gm(i){return i.map(_ne).join(", ")}ch.default=Gm;function _ne(i){return i.map(eie).join("")}function eie(i){switch(i.type){case"child":return" > ";case"parent":return" < ";case"sibling":return" ~ ";case"adjacent":return" + ";case"descendant":return" ";case"universal":return"*";case"tag":return Ir(i.name);case"pseudo-element":return"::"+Ir(i.name);case"pseudo":return i.data===null?":"+Ir(i.name):typeof i.data=="string"?":"+Ir(i.name)+"("+i.data+")":":"+Ir(i.name)+"("+Gm(i.data)+")";case"attribute":return i.action==="exists"?"["+Ir(i.name)+"]":i.name==="id"&&i.action==="equals"&&!i.ignoreCase?"#"+Ir(i.value):i.name==="class"&&i.action==="element"&&!i.ignoreCase?"."+Ir(i.value):"["+Ir(i.name)+Ql[i.action]+"='"+Ir(i.value)+"'"+(i.ignoreCase?"i":"")+"]"}}function Ir(i){return i.split("").map(function(t){return Jne.has(t)?"\\"+t:t}).join("")}(function(i){var t=vt&&vt.__createBinding||(Object.create?function(o,a,c,l){l===void 0&&(l=c),Object.defineProperty(o,l,{enumerable:!0,get:function(){return a[c]}})}:function(o,a,c,l){l===void 0&&(l=c),o[l]=a[c]}),e=vt&&vt.__exportStar||function(o,a){for(var c in o)c!=="default"&&!Object.prototype.hasOwnProperty.call(a,c)&&t(a,o,c)},r=vt&&vt.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(i,"__esModule",{value:!0}),i.stringify=i.parse=void 0,e(sa,i);var n=sa;Object.defineProperty(i,"parse",{enumerable:!0,get:function(){return r(n).default}});var s=ch;Object.defineProperty(i,"stringify",{enumerable:!0,get:function(){return r(s).default}})})(Vm);const tie=50,rie=30,nie=1,iie=0,sie=-1,oie=-1,aie=-1,cie=-1,lie=-1,Hm={universal:tie,tag:rie,attribute:nie,pseudo:iie,descendant:sie,child:oie,parent:aie,sibling:cie,adjacent:lie};var uie=hie,el=Hm,Af={__proto__:null,exists:10,equals:8,not:7,start:6,end:6,any:5,hyphen:4,element:4};function hie(i){for(var t=i.map(Qm),e=1;e<i.length;e++){var r=t[e];if(!(r<0))for(var n=e-1;n>=0&&r<t[n];n--){var s=i[n+1];i[n+1]=i[n],i[n]=s,t[n+1]=t[n],t[n]=r}}}function Qm(i){var t=el[i.type];if(t===el.attribute)t=Af[i.action],t===Af.equals&&i.name==="id"&&(t=9),i.ignoreCase&&(t>>=1);else if(t===el.pseudo)if(!i.data)t=3;else if(i.name==="has"||i.name==="contains")t=0;else if(i.name==="matches"||i.name==="not"){t=0;for(var e=0;e<i.data.length;e++)if(i.data[e].length===1){var r=Qm(i.data[e][0]);if(r===0){t=0;break}r>t&&(t=r)}i.data.length>1&&t>0&&(t-=1)}else t=1;return t}var bo=Qs.falseFunc,Nf=/[-[\]{}()*+?.,\\^$|#\s]/g,Df={__proto__:null,equals:function(i,t,e){var r=t.name,n=t.value,s=e.adapter;return t.ignoreCase?(n=n.toLowerCase(),function(a){var c=s.getAttributeValue(a,r);return c!=null&&c.toLowerCase()===n&&i(a)}):function(a){return s.getAttributeValue(a,r)===n&&i(a)}},hyphen:function(i,t,e){var r=t.name,n=t.value,s=n.length,o=e.adapter;return t.ignoreCase?(n=n.toLowerCase(),function(c){var l=o.getAttributeValue(c,r);return l!=null&&(l.length===s||l.charAt(s)==="-")&&l.substr(0,s).toLowerCase()===n&&i(c)}):function(c){var l=o.getAttributeValue(c,r);return l!=null&&l.substr(0,s)===n&&(l.length===s||l.charAt(s)==="-")&&i(c)}},element:function(i,t,e){var r=t.name,n=t.value,s=e.adapter;if(/\s/.test(n))return bo;n=n.replace(Nf,"\\$&");var o="(?:^|\\s)"+n+"(?:$|\\s)",a=t.ignoreCase?"i":"",c=new RegExp(o,a);return function(u){var h=s.getAttributeValue(u,r);return h!=null&&c.test(h)&&i(u)}},exists:function(i,t,e){var r=t.name,n=e.adapter;return function(o){return n.hasAttrib(o,r)&&i(o)}},start:function(i,t,e){var r=t.name,n=t.value,s=n.length,o=e.adapter;return s===0?bo:t.ignoreCase?(n=n.toLowerCase(),function(c){var l=o.getAttributeValue(c,r);return l!=null&&l.substr(0,s).toLowerCase()===n&&i(c)}):function(c){var l=o.getAttributeValue(c,r);return l!=null&&l.substr(0,s)===n&&i(c)}},end:function(i,t,e){var r=t.name,n=t.value,s=-n.length,o=e.adapter;return s===0?bo:t.ignoreCase?(n=n.toLowerCase(),function(c){var l=o.getAttributeValue(c,r);return l!=null&&l.substr(s).toLowerCase()===n&&i(c)}):function(c){var l=o.getAttributeValue(c,r);return l!=null&&l.substr(s)===n&&i(c)}},any:function(i,t,e){var r=t.name,n=t.value,s=e.adapter;if(n==="")return bo;if(t.ignoreCase){var o=new RegExp(n.replace(Nf,"\\$&"),"i");return function(c){var l=s.getAttributeValue(c,r);return l!=null&&o.test(l)&&i(c)}}return function(c){var l=s.getAttributeValue(c,r);return l!=null&&l.indexOf(n)>=0&&i(c)}},not:function(i,t,e){var r=t.name,n=t.value,s=e.adapter;return n===""?function(a){return!!s.getAttributeValue(a,r)&&i(a)}:t.ignoreCase?(n=n.toLowerCase(),function(a){var c=s.getAttributeValue(a,r);return c!=null&&c.toLowerCase()!==n&&i(a)}):function(a){return s.getAttributeValue(a,r)!==n&&i(a)}}},Zm={compile:function(i,t,e){if(e&&e.strict&&(t.ignoreCase||t.action==="not"))throw new Error("Unsupported attribute selector");return Df[t.action](i,t,e)},rules:Df},Za={exports:{}},die=gie,fie=/^([+\-]?\d*n)?\s*(?:([+\-]?)\s*(\d+))?$/;function gie(i){if(i=i.trim().toLowerCase(),i==="even")return[2,0];if(i==="odd")return[2,1];var t=i.match(fie);if(!t)throw new SyntaxError("n-th rule couldn't be parsed ('"+i+"')");var e;return t[1]?(e=parseInt(t[1],10),isNaN(e)&&(t[1].charAt(0)==="-"?e=-1:e=1)):e=0,[e,t[3]?parseInt((t[2]||"")+t[3],10):0]}var pie=vie,Km=Qs,mie=Km.trueFunc,yie=Km.falseFunc;function vie(i){var t=i[0],e=i[1]-1;if(e<0&&t<=0)return yie;if(t===-1)return function(n){return n<=e};if(t===0)return function(n){return n===e};if(t===1)return e<0?mie:function(n){return n>=e};var r=e%t;return r<0&&(r+=t),t>1?function(n){return n>=e&&n%t===r}:(t*=-1,function(n){return n<=e&&n%t===r})}var qm=die,Xm=pie;Za.exports=function(t){return Xm(qm(t))};Za.exports.parse=qm;Za.exports.compile=Xm;var Mie=Za.exports,xo=Mie,Jm=Qs,wie=Zm,vs=Jm.trueFunc,hn=Jm.falseFunc,Tie=wie.rules.equals;function Ln(i,t){var e={name:i,value:t};return function(n,s,o){return Tie(n,e,o)}}function Eo(i,t){return function(e){return!!t.getParent(e)&&i(e)}}var Zo={contains:function(i,t,e){var r=e.adapter;return function(s){return i(s)&&r.getText(s).indexOf(t)>=0}},icontains:function(i,t,e){var r=t.toLowerCase(),n=e.adapter;return function(o){return i(o)&&n.getText(o).toLowerCase().indexOf(r)>=0}},"nth-child":function(i,t,e){var r=xo(t),n=e.adapter;return r===hn?r:r===vs?Eo(i,n):function(o){for(var a=n.getSiblings(o),c=0,l=0;c<a.length;c++)if(n.isTag(a[c])){if(a[c]===o)break;l++}return r(l)&&i(o)}},"nth-last-child":function(i,t,e){var r=xo(t),n=e.adapter;return r===hn?r:r===vs?Eo(i,n):function(o){for(var a=n.getSiblings(o),c=0,l=a.length-1;l>=0;l--)if(n.isTag(a[l])){if(a[l]===o)break;c++}return r(c)&&i(o)}},"nth-of-type":function(i,t,e){var r=xo(t),n=e.adapter;return r===hn?r:r===vs?Eo(i,n):function(o){for(var a=n.getSiblings(o),c=0,l=0;l<a.length;l++)if(n.isTag(a[l])){if(a[l]===o)break;n.getName(a[l])===n.getName(o)&&c++}return r(c)&&i(o)}},"nth-last-of-type":function(i,t,e){var r=xo(t),n=e.adapter;return r===hn?r:r===vs?Eo(i,n):function(o){for(var a=n.getSiblings(o),c=0,l=a.length-1;l>=0;l--)if(n.isTag(a[l])){if(a[l]===o)break;n.getName(a[l])===n.getName(o)&&c++}return r(c)&&i(o)}},root:function(i,t,e){var r=e.adapter;return function(n){return!r.getParent(n)&&i(n)}},scope:function(i,t,e,r){var n=e.adapter;if(!r||r.length===0)return Zo.root(i,t,e);function s(o,a){return typeof n.equals=="function"?n.equals(o,a):o===a}return r.length===1?function(o){return s(r[0],o)&&i(o)}:function(o){return r.indexOf(o)>=0&&i(o)}},checkbox:Ln("type","checkbox"),file:Ln("type","file"),password:Ln("type","password"),radio:Ln("type","radio"),reset:Ln("type","reset"),image:Ln("type","image"),submit:Ln("type","submit"),hover:function(i,t,e){var r=e.adapter;return typeof r.isHovered=="function"?function(s){return i(s)&&r.isHovered(s)}:hn},visited:function(i,t,e){var r=e.adapter;return typeof r.isVisited=="function"?function(s){return i(s)&&r.isVisited(s)}:hn},active:function(i,t,e){var r=e.adapter;return typeof r.isActive=="function"?function(s){return i(s)&&r.isActive(s)}:hn}};function Sie(i,t){for(var e=0;i&&e<i.length;e++)if(t.isTag(i[e]))return i[e]}var Cs={empty:function(i,t){return!t.getChildren(i).some(function(e){return t.isTag(e)||e.type==="text"})},"first-child":function(i,t){return Sie(t.getSiblings(i),t)===i},"last-child":function(i,t){for(var e=t.getSiblings(i),r=e.length-1;r>=0;r--){if(e[r]===i)return!0;if(t.isTag(e[r]))break}return!1},"first-of-type":function(i,t){for(var e=t.getSiblings(i),r=0;r<e.length;r++)if(t.isTag(e[r])){if(e[r]===i)return!0;if(t.getName(e[r])===t.getName(i))break}return!1},"last-of-type":function(i,t){for(var e=t.getSiblings(i),r=e.length-1;r>=0;r--)if(t.isTag(e[r])){if(e[r]===i)return!0;if(t.getName(e[r])===t.getName(i))break}return!1},"only-of-type":function(i,t){for(var e=t.getSiblings(i),r=0,n=e.length;r<n;r++)if(t.isTag(e[r])){if(e[r]===i)continue;if(t.getName(e[r])===t.getName(i))return!1}return!0},"only-child":function(i,t){for(var e=t.getSiblings(i),r=0;r<e.length;r++)if(t.isTag(e[r])&&e[r]!==i)return!1;return!0},link:function(i,t){return t.hasAttrib(i,"href")},selected:function(i,t){if(t.hasAttrib(i,"selected"))return!0;if(t.getName(i)!=="option")return!1;var e=t.getParent(i);if(!e||t.getName(e)!=="select"||t.hasAttrib(e,"multiple"))return!1;for(var r=t.getChildren(e),n=!1,s=0;s<r.length;s++)if(t.isTag(r[s]))if(r[s]===i)n=!0;else if(n){if(t.hasAttrib(r[s],"selected"))return!1}else return!1;return n},disabled:function(i,t){return t.hasAttrib(i,"disabled")},enabled:function(i,t){return!t.hasAttrib(i,"disabled")},checked:function(i,t){return t.hasAttrib(i,"checked")||Cs.selected(i,t)},required:function(i,t){return t.hasAttrib(i,"required")},optional:function(i,t){return!t.hasAttrib(i,"required")},parent:function(i,t){return!Cs.empty(i,t)},header:Pf(["h1","h2","h3","h4","h5","h6"]),button:function(i,t){var e=t.getName(i);return e==="button"||e==="input"&&t.getAttributeValue(i,"type")==="button"},input:Pf(["input","textarea","select","button"]),text:function(i,t){var e;return t.getName(i)==="input"&&(!(e=t.getAttributeValue(i,"type"))||e.toLowerCase()==="text")}};function Pf(i){if(typeof Set<"u"){var t=new Set(i);return function(e,r){return t.has(r.getName(e))}}return function(e,r){return i.indexOf(r.getName(e))>=0}}function Iie(i,t,e){if(e===null){if(i.length>2&&t!=="scope")throw new Error("pseudo-selector :"+t+" requires an argument")}else if(i.length===2)throw new Error("pseudo-selector :"+t+" doesn't have any arguments")}var Cie=/^(?:(?:nth|last|first|only)-(?:child|of-type)|root|empty|(?:en|dis)abled|checked|not)$/,_m={compile:function(i,t,e,r){var n=t.name,s=t.data,o=e.adapter;if(e&&e.strict&&!Cie.test(n))throw new Error(":"+n+" isn't part of CSS3");if(typeof Zo[n]=="function")return Zo[n](i,s,e,r);if(typeof Cs[n]=="function"){var a=Cs[n];return Iie(a,n,s),a===hn?a:i===vs?function(l){return a(l,o,s)}:function(l){return a(l,o,s)&&i(l)}}else throw new Error("unmatched pseudo-class :"+n)},filters:Zo,pseudos:Cs},bie=Zm,xie=_m,Eie={__proto__:null,attribute:bie.compile,pseudo:xie.compile,tag:function(i,t,e){var r=t.name,n=e.adapter;return function(o){return n.getName(o)===r&&i(o)}},descendant:function(i,t,e){var r=typeof WeakSet<"u"?new WeakSet:null,n=e.adapter;return function(o){for(var a=!1;!a&&(o=n.getParent(o));)(!r||!r.has(o))&&(a=i(o),!a&&r&&r.add(o));return a}},_flexibleDescendant:function(i,t,e){var r=e.adapter;return function(s){for(var o=i(s);!o&&(s=r.getParent(s));)o=i(s);return o}},parent:function(i,t,e){if(e&&e.strict)throw new Error("Parent selector isn't part of CSS3");var r=e.adapter;return function(o){return r.getChildren(o).some(n)};function n(s){return r.isTag(s)&&i(s)}},child:function(i,t,e){var r=e.adapter;return function(s){var o=r.getParent(s);return!!o&&i(o)}},sibling:function(i,t,e){var r=e.adapter;return function(s){for(var o=r.getSiblings(s),a=0;a<o.length;a++)if(r.isTag(o[a])){if(o[a]===s)break;if(i(o[a]))return!0}return!1}},adjacent:function(i,t,e){var r=e.adapter;return function(s){for(var o=r.getSiblings(s),a,c=0;c<o.length;c++)if(r.isTag(o[c])){if(o[c]===s)break;a=o[c]}return!!a&&i(a)}},universal:function(i){return i}},Aie=Ka,Nie=Vm.parse,ey=Qs,Die=uie,Pie=Hm,kf=Eie,ty=_m,Ps=ey.trueFunc,Sn=ey.falseFunc,lh=ty.filters;function Ka(i,t,e){var r=ny(i,t,e);return ry(r,t)}function ry(i,t){var e=t.adapter;return function(n){return e.isTag(n)&&i(n)}}function ny(i,t,e){var r=Nie(i,t);return Zs(r,t,e)}function Zl(i){return i.type==="pseudo"&&(i.name==="scope"||Array.isArray(i.data)&&i.data.some(function(t){return t.some(Zl)}))}var kie={type:"descendant"},Lie={type:"_flexibleDescendant"},Rie={type:"pseudo",name:"scope"},iy={};function Oie(i,t,e){var r=t.adapter,n=!!e&&!!e.length&&e.every(function(s){return s===iy||!!r.getParent(s)});i.forEach(function(s){if(!(s.length>0&&sy(s[0])&&s[0].type!=="descendant"))if(n&&!(Array.isArray(s)?s.some(Zl):Zl(s)))s.unshift(kie);else return;s.unshift(Rie)})}function Zs(i,t,e){i=i.filter(function(o){return o.length>0}),i.forEach(Die);var r=Array.isArray(e);e=t&&t.context||e,e&&!r&&(e=[e]),Oie(i,t,e);var n=!1,s=i.map(function(o){if(o[0]&&o[1]&&o[0].name==="scope"){var a=o[1].type;r&&a==="descendant"?o[1]=Lie:(a==="adjacent"||a==="sibling")&&(n=!0)}return zie(o,t,e)}).reduce(jie,Sn);return s.shouldTestNextSiblings=n,s}function sy(i){return Pie[i.type]<0}function zie(i,t,e){return i.reduce(function(r,n){if(r===Sn)return r;if(!(n.type in kf))throw new Error("Rule type "+n.type+" is not supported by css-select");return kf[n.type](r,n,t,e)},t&&t.rootFunc||Ps)}function jie(i,t){return t===Sn||i===Ps?i:i===Sn||t===Ps?t:function(r){return i(r)||t(r)}}function oy(i){return i.some(sy)}lh.not=function(i,t,e,r){var n={xmlMode:!!(e&&e.xmlMode),strict:!!(e&&e.strict),adapter:e.adapter};if(n.strict&&(t.length>1||t.some(oy)))throw new Error("complex selectors in :not aren't allowed in strict mode");var s=Zs(t,n,r);return s===Sn?i:s===Ps?Sn:function(a){return!s(a)&&i(a)}};lh.has=function(i,t,e){var r=e.adapter,n={xmlMode:!!(e&&e.xmlMode),strict:!!(e&&e.strict),adapter:r},s=t.some(oy)?[iy]:null,o=Zs(t,n,s);return o===Sn?Sn:o===Ps?function(c){return r.getChildren(c).some(r.isTag)&&i(c)}:(o=ry(o,e),s?function(c){return i(c)&&(s[0]=c,r.existsOne(o,r.getChildren(c)))}:function(c){return i(c)&&r.existsOne(o,r.getChildren(c))})};lh.matches=function(i,t,e,r){var n={xmlMode:!!(e&&e.xmlMode),strict:!!(e&&e.strict),rootFunc:i,adapter:e.adapter};return Zs(t,n,r)};Ka.compileToken=Zs;Ka.compileUnsafe=ny;Ka.Pseudos=ty;var Bie=Tr,uh=Vne,ay=Qs.falseFunc,Ks=Aie;function cy(i){return function(e,r,n){return r=r||{},r.adapter=r.adapter||uh,i(e,r,n)}}var hh=cy(Ks),ly=cy(Ks.compileUnsafe);function uy(i){return function(e,r,n){return n=n||{},n.adapter=n.adapter||uh,typeof e!="function"&&(e=ly(e,n,r)),e.shouldTestNextSiblings&&(r=Fie(n&&n.context||r,n.adapter)),Array.isArray(r)?r=n.adapter.removeSubsets(r):r=n.adapter.getChildren(r),i(e,r,n)}}function Uie(i,t){var e=t.getSiblings(i);if(!Array.isArray(e))return[];for(e=e.slice(0);e.shift()!==i;);return e}function Fie(i,t){Array.isArray(i)||(i=[i]);for(var e=i.slice(0),r=0,n=i.length;r<n;r++){var s=Uie(e[r],t);e.push.apply(e,s)}return e}var dh=uy(function(t,e,r){return t===ay||!e||e.length===0?[]:r.adapter.findAll(t,e)}),Wie=uy(function(t,e,r){return t===ay||!e||e.length===0?null:r.adapter.findOne(t,e)});function $ie(i,t,e){return e=e||{},e.adapter=e.adapter||uh,(typeof t=="function"?t:hh(t,e))(i)}function Tr(i,t,e){return dh(i,t,e)}Tr.compile=hh;Tr.filters=Ks.Pseudos.filters;Tr.pseudos=Ks.Pseudos.pseudos;Tr.selectAll=dh;Tr.selectOne=Wie;Tr.is=$ie;Tr.parse=hh;Tr.iterate=dh;Tr._compileUnsafe=ly;Tr._compileToken=Ks.compileToken;const hy=en(Bie);qe(Array);function Ao(i){return i.nodeType===1||$t.isSpriteNode(i.nodeName)}function yi(i){return Array.from(i.childNodes||[])}function Kl(i){return $t.isSpriteNode(i.nodeName)?i.parent||i.canvas||i.container:i.parentElement}function Vie(i){let t=i.length,e,r,n;for(;--t>-1;){for(e=r=i[t],i[t]=null,n=!0;r;){if(i.indexOf(r)>-1){n=!1,i.splice(t,1);break}r=Kl(r)}n&&(i[t]=e)}return i}const fh={isTag:Ao,existsOne(i,t){return t.some(e=>Ao(e)?i(e)||fh.existsOne(i,yi(e)):!1)},getSiblings(i){const t=Kl(i);return t&&yi(t)},getChildren:yi,getParent:Kl,getAttributeValue(i,t){if(i.nodeType===1&&t==="class"||t==="id")return i[t];if(this.hasAttrib(i,t)){let e=i.attributes[t];return Array.isArray(e)&&(e=`[${e.join()}]`),String(e)}},hasAttrib(i,t){return i.attributes[t]!=null},removeSubsets:Vie,getName(i){return i.tagName?i.tagName.toLowerCase():null},findOne:function i(t,e){let r=null;for(let n=0,s=e.length;n<s&&!r;n++)if(t(e[n]))r=e[n];else{const o=yi(e[n]);o&&o.length>0&&(r=i(t,o))}return r},findAll:function i(t,e){let r=[];for(let n=0,s=e.length;n<s;n++){if(!Ao(e[n]))continue;t(e[n])&&r.push(e[n]);const o=yi(e[n]);o&&(r=r.concat(i(t,o)))}return r},getText:function i(t){return Array.isArray(t)?t.map(i).join(""):Ao(t)?i(yi(t)):t.nodeType===3?t.nodeValue:$t.isSpriteNode(t.nodeName)?t.text:""}};function dy(i){if(typeof i!="string")return i;let t=i.match(/\[(bgcolor|fillColor|strokeColor|color)\s*=\s*['"]?\w+['"]?\]/g);return t&&(t=t.map(e=>{const r=e.slice(1,-1).split("="),n=Tn(r[1].replace(/['"]/g,""));return[e,`[${r[0]}="${n}"]`]}),t.forEach(([e,r])=>{i=i.replace(e,r)})),t=i.match(/\[\w+\s*=\s*['"]\[.+?\]['"]\]/g),t&&(t=t.map(e=>{const r=e.slice(1,-1).split("="),n=r[1].slice(2,-2).split(/,/g).map(s=>s.trim());return[e,`[${r[0]}="[${n}]"]`]}),t.forEach(([e,r])=>{i=i.replace(e,r)})),i}function No(i,t){return hy.selectAll(dy(i),t,{adapter:fh})}function Lf(i,t){return hy.selectOne(dy(i),t,{adapter:fh})}qe(Array);const Rf=Symbol("zOrder"),pt=Symbol("ordered"),Dt=Symbol("children"),tl=Symbol("sealed"),wa=class wa extends Hs{constructor(t={}){super(t),this[Dt]=[],this[pt]=null,this[Rf]=0}get childNodes(){return this[Dt]}get children(){return this[Dt]}get orderedChildren(){return this[pt]||(this[pt]=[...this[Dt]],this[pt].sort((t,e)=>t.zIndex-e.zIndex||t.zOrder-e.zOrder)),this[pt]}append(...t){return t.map(e=>this.appendChild(e))}appendChild(t){return t.remove(),this[Dt].push(t),t.connect(this,this[Rf]++),this[pt]&&(this[pt].length&&t.zIndex<this[pt][this[pt].length-1].zIndex?this.reorder():this[pt].push(t)),t}cloneNode(t=!1){const e=super.cloneNode();return t&&this[Dt].forEach(r=>{const n=r.cloneNode(t);e.appendChild(n)}),e}dispatchPointerEvent(t){const e=this.orderedChildren;for(let r=e.length-1;r>=0;r--)if(e[r].dispatchPointerEvent(t))return!0;return super.dispatchPointerEvent(t)}draw(t=[]){if(this.__cacheRenderMatrix=this.renderMatrix,super.draw(t),!this[tl]&&this.attributes.display!=="none"){const e=this.orderedChildren;for(let r=0;r<e.length;r++)e[r].draw(t)}return this.__cacheRenderMatrix=null,t}getElementById(t){return Lf(`#${t}`,this)}getElementsByClassName(t){return No(`.${t}`,this)}getElementsByName(t){return No(`[name="${t}"]`,this)}getElementsByTagName(t){return No(t,this)}insertBefore(t,e){if(e==null)return this.appendChild(t);t.remove();const r=this[Dt].indexOf(e);if(r<0)throw new Error("Invalid reference node.");const n=e.zOrder;for(let s=r;s<this[Dt].length;s++){const o=this[Dt][s].zOrder,a=this[Dt][s];delete a.zOrder,Object.defineProperty(a,"zOrder",{value:o+1,writable:!1,configurable:!0})}if(this[Dt].splice(r,0,t),t.connect(this,n),this[pt])if(t.zIndex!==e.zIndex)this.reorder();else{const s=this[pt].indexOf(e);this[pt].splice(s,0,t)}return t}querySelector(t){return Lf(t,this)}querySelectorAll(t){return No(t,this)}replaceChild(t,e){t.remove();const r=this[Dt].indexOf(e);if(r<0)throw new Error("Invalid reference node.");if(this[Dt][r]=t,t.connect(this,e.zOrder),this[pt])if(t.zIndex!==e.zIndex)this.reorder();else{const n=this[pt].indexOf(e);this[pt][n]=t}return e.disconnect(this),t}removeAllChildren(){const t=this[Dt];for(let e=t.length-1;e>=0;e--)t[e].remove()}removeChild(t){const e=this[Dt].indexOf(t);if(e>=0){if(this[Dt].splice(e,1),this[pt]){const r=this[pt].indexOf(t);this[pt].splice(r,1)}return t.disconnect(this),t}return null}reorder(){this[pt]=null}seal(){function t(s,o){const a=[];for(let c=0;c<s.length;c++){const l=[...s[c]];for(let u=1;u<l.length;u+=2){const h=l[u],d=l[u+1];l[u]=h*o[0]+d*o[2]+o[4],l[u+1]=h*o[1]+d*o[3]+o[5]}a.push(l)}return a}const e=this.orderedChildren,r=new ht.Figure2D,n=this.localMatrix;for(let s=0;s<e.length;s++){let o=e[s];if(o instanceof wa&&(o=o.seal()),o.clientBox){let a=o.clientBox.contours.path;a=t(a,o.localMatrix),r.addPath(a)}if(o.path){let a=o.path.contours.path;a=t(a,o.localMatrix),r.addPath(a)}}return this[tl]=!0,this.clientBox=r,{clientBox:r,localMatrix:n}}setResolution({width:t,height:e}){super.setResolution({width:t,height:e}),this[Dt].forEach(r=>{r.setResolution({width:t,height:e})})}updateContours(){this[tl]||super.updateContours()}};R(wa,"Attr",zI);let dt=wa;$t.registerNode(dt,"group");qe(Array);const ql={};function oa(i,t){if(ql[i])return ql[i];const e=ht.ENV.loadImage(i,{alias:t,useImageBitmap:!1});return e??i}async function fy(i,t,e){let r=t;if(typeof t=="string"&&(r=oa(t)),r&&typeof r.then=="function"&&(r=await r),t===i.attributes.texture){r&&r.image&&(r.sourceRect&&(i.attributes.sourceRect=r.sourceRect),i.textureImageRotated=!!r.rotated,r=r.image);const{width:n,height:s,textureRect:o}=i.attributes,a=i.textureImage;i.textureImage=r,e&&a!==r&&!o&&(n==null||s==null)&&i.updateContours(),i.forceUpdate()}return r}const pr=Symbol("textureMap");function gy(i,t){if(t[pr]=t[pr]||new Map,t[pr].has(i))return t[pr].get(i);const e=t.createTexture(i);return!/^blob:/.test(i.src)&&typeof i.getContext!="function"&&t[pr].set(i,e),e}function py(i,t){if(t[pr]&&t[pr].has(i)){const e=t[pr].get(i);return t.deleteTexture(e),t[pr].delete(i),!0}return!1}const rl=Symbol("textureContext");function my(i,t){const e=i.textureImage instanceof String?String(i.textureImage):i.textureImage,r=i.textureImageRotated,n=t.texture,s=i.renderer;if(e){const o=i.originalContentRect;let a=i.attributes.textureRect;const c=i.attributes.textureRepeat,l=i.attributes.sourceRect;if(!n||i[rl]&&i[rl]!==s||n.image!==e||n.options.repeat!==c||!bl(n.options.rect,a)||!bl(n.options.srcRect,l)){const u=gy(e,s);a?(a[0]+=o[0],a[1]+=o[1]):a=o;let h=null;n&&!s[pr].has(n.image)&&(!n.options||!n.options.hidden)&&(h=t.uniforms.u_texSampler),t.setTexture(u,{rect:a,repeat:c,srcRect:l,rotated:r}),h&&h.delete&&h.delete(),i[rl]=s}}else if(n){let o=null;!s[pr].has(n.image)&&(!n.options||!n.options.hidden)&&(o=t.uniforms.u_texSampler),t.setTexture(null),o&&o.delete&&o.delete()}}async function Yie(i,t){typeof t=="string"&&(t=await(await fetch(t,{method:"GET",mode:"cors",cache:"default"})).json());const e=await oa(i),r=t.frames;return Object.entries(r).forEach(([n,s])=>{const{x:o,y:a,w:c,h:l}=s.frame;let u=[o,a,c,l];const h=s.rotated;h&&(u=[u[0],u[1],u[3],u[2]]),ql[n]={image:e,sourceRect:u,rotated:h}}),e}qe(Array);const Gie={antialias:!0,autoRender:!0,alpha:!0},Do=Symbol("autoRender"),ns=Symbol("renderer"),Of=Symbol("timeline"),zt=Symbol("prepareRender"),nl=Symbol("tickRender"),sn=Symbol("pass"),Rn=Symbol("fbo"),vi=Symbol("tickers"),on=Symbol("layerTransformInvert");function Hie(i){if(!i||!i.options)return null;let t="2d";return i.glRenderer&&(t=i.isWebGL2?"webgl2":"webgl"),i.options.contextType=t,i.options.webgl2=t==="webgl2",t}let xi=class extends dt{constructor(t={}){if(super(),!t.canvas){const{width:s,height:o}=this.getResolution(),a=ht.ENV.createCanvas(s,o,{offscreen:!!t.offscreen,id:t.id,extra:t.extra});a.style&&(a.style.position="absolute"),a.dataset&&(a.dataset.layerId=t.id),a.contextType&&(t.contextType=a.contextType),t.canvas=a}const e=t.canvas,r=Object.assign({},Gie,t);this[Do]=r.autoRender,delete t.autoRender;const n=r.Renderer||ht.Renderer;this[ns]=new n(e,r),Hie(this[ns]),this.options=t,this.id=t.id,this[sn]=[],this.setResolution(e),this.canvas=e,this[Of]=new ym,this.__mouseCapturedTarget=null,this[on]=null}get autoRender(){return this[Do]}get displayRatio(){return this.parent&&this.parent.options?this.parent.options.displayRatio:1}get height(){const{height:t}=this.getResolution();return t/this.displayRatio}get gl(){return this.renderer.glRenderer?this.renderer.glRenderer.gl:null}get layer(){return this}get offscreen(){return!!this.options.offscreen||this.canvas._offscreen}get pass(){return this[sn]}get prepareRender(){return this[zt]?this[zt]:Promise.resolve()}get renderer(){return this[ns]}get renderOffset(){if(this.parent&&this.parent.options){const{left:t,top:e}=this.parent.options;return[t,e]}return[this.options.left|0,this.options.top|0]}get timeline(){return this[Of]}get width(){const{width:t}=this.getResolution();return t/this.displayRatio}get localMatrix(){const{x:t,y:e}=this.attributes;return[1,0,0,1,t,e]}get layerTransformInvert(){if(this[on])return this[on];const t=this.transformMatrix;return t[0]===1&&t[1]===0&&t[2]===0&&t[3]===1&&t[4]===0&&t[5]===0?null:(this[on]=Jo(Array.of(0,0,0,0,0,0),t),this[on])}forceContextLoss(){const t=this.renderer.glRenderer;if(t){const e=t.getExtension("WEBGL_lose_context");if(e)return e.loseContext(),!0}return!1}addPass({vertex:t,fragment:e,options:r,uniforms:n}={}){if(this.renderer.glRenderer){const{width:s,height:o}=this.getResolution(),a=this.renderer.createPassProgram({vertex:t,fragment:e,options:r}),c=new ht.Figure2D;c.rect(0,0,s/this.displayRatio,o/this.displayRatio);const l=new ht.Mesh2D(c);return l.setUniforms(n),l.setProgram(a),this[sn].push(l),this.forceUpdate(),l}return null}deleteTexture(t){return py(t,this.renderer)}dispatchPointerEvent(t){const e=t.type;if(e==="mousedown"||e==="mouseup"||e==="mousemove"){const a=this.__mouseCapturedTarget;if(a){if(a.layer===this)return a.dispatchEvent(t),!0;this.__mouseCapturedTarget=null}}let r,n;const s=this.layerTransformInvert;if(s){r=t.x,n=t.y;const a=s,c=a[0]*r+a[2]*n+a[4],l=a[1]*r+a[3]*n+a[5];delete t.x,delete t.y,delete t.layerX,delete t.layerY,Object.defineProperties(t,{layerX:{value:c,configurable:!0},layerY:{value:l,configurable:!0},x:{value:c,configurable:!0},y:{value:l,configurable:!0}})}const o=super.dispatchPointerEvent(t);return s&&Object.defineProperties(t,{layerX:{value:r,configurable:!0},layerY:{value:n,configurable:!0},x:{value:r,configurable:!0},y:{value:n,configurable:!0}}),o}forceUpdate(){if(!this[zt])if(this.parent&&this.parent.hasOffscreenCanvas){this.parent.forceUpdate();let t=null;const e=new Promise(r=>{t=r});e._resolve=t,this[zt]=e}else{let t=null,e=null;const r=new Promise(n=>{t=n,this[Do]&&(e=Qr(()=>{delete r._requestID,this.render()}))});r._resolve=t,r._requestID=e,this[zt]=r}}getFBO(){const t=this.renderer.glRenderer,{width:e,height:r}=this.getResolution();return t&&(!this[Rn]||this[Rn].width!==e||this[Rn].height!==r)?(this[Rn]={width:e,height:r,target:t.createFBO(),buffer:t.createFBO(),swap(){[this.target,this.buffer]=[this.buffer,this.target]}},this[Rn]):this[Rn]?this[Rn]:null}updateGlobalTransform(){if(this.layerTransformInvert){const t=this.renderer,e=t.__globalTransformMatrix||t.globalTransformMatrix;t.__globalTransformMatrix=e;const r=Zn(1,0,0,1,0,0);t.setGlobalTransform(...Er(r,e,this.transformMatrix))}}onPropertyChange(t,e,r){if(super.onPropertyChange(t,e,r),t==="zIndex"&&(this.canvas.style.zIndex=e),t==="transform"||t==="translate"||t==="rotate"||t==="scale"||t==="skew"){const n=this[on];if(this[on]=null,this.updateGlobalTransform(),n&&!this.layerTransformInvert){const s=this.renderer,o=s.__globalTransformMatrix||s.globalTransformMatrix;s.setGlobalTransform(...o)}}}_prepareRenderFinished(){this[zt]&&(this[zt]._requestID&&qn(this[zt]._requestID),this[zt]._resolve(),delete this[zt])}render({clear:t=!0}={}){const e=this[sn].length?this.getFBO():null;e&&this.renderer.glRenderer.bindFBO(e.target),t&&this[ns].clear();const r=this.draw();if(r&&r.length&&(this.renderer.drawMeshes(r),this.canvas.draw&&this.canvas.draw()),e){const n=this.renderer.glRenderer,s=this[sn].length,{width:o,height:a}=this.getResolution(),c=[0,0,o/this.displayRatio,a/this.displayRatio];this[sn].forEach((l,u)=>{l.blend=!0,l.setTexture(e.target.texture,{rect:c}),u===s-1?n.bindFBO(null):(e.swap(),n.bindFBO(e.target)),this[ns].clear(),this.renderer.drawMeshes([l])})}this._prepareRenderFinished()}setResolution({width:t,height:e}){const r=this.renderer,n=r.__globalTransformMatrix||r.globalTransformMatrix,s=n[4],o=n[5],a=n[0],{width:c,height:l}=this.getResolution();(c!==t||l!==e)&&(super.setResolution({width:t,height:e}),this.canvas&&(this.canvas.width=t,this.canvas.height=e,r.updateResolution&&r.updateResolution()),this.attributes.size=[t,e],this[sn].length&&this[sn].forEach(g=>{const p=new ht.Figure2D;p.rect(0,0,t/this.displayRatio,e/this.displayRatio),g.contours=p.contours}));const[u,h]=this.renderOffset,d=this.displayRatio;(s!==u||o!==h||a!==d)&&(r.setGlobalTransform(d,0,0,d,u,h),r.__globalTransformMatrix=null,this[on]=null,this.updateGlobalTransform(),this.forceUpdate())}tick(t=null,{duration:e=1/0,...r}={}){const n=this.timeline.fork(r),s=this;this[vi]=this[vi]||[],this[vi].push({handler:t,duration:e});const o=()=>{let a=null,c=null;const l=()=>{const u=this[vi].map(({handler:h,duration:d})=>{const g=Math.min(1,n.currentTime/d);return{value:h?h(n.currentTime,g):null,p:g}});s[nl]||(s[nl]=Promise.resolve().then(()=>{s[Do]&&s.render(),delete s[nl];for(let h=u.length-1;h>=0;h--){const{value:d,p:g}=u[h];(d===!1||g>=1)&&this[vi].splice(h,1)}this[vi].length>0&&o()}))};if(this[zt]&&this[zt]._type!=="ticker"&&(qn(this[zt]._requestID),delete this[zt]),!this[zt]){const u=new Promise(h=>{a=h,c=Qr(l)});u._resolve=a,u._requestID=c,u._type="ticker",this[zt]=u}};o()}toGlobalPos(t,e){if(this.layerTransformInvert){const c=this.transformMatrix;t=c[0]*t+c[2]*e+c[4],e=c[1]*t+c[3]*e+c[5]}const{width:r,height:n}=this.getResolution(),s=this.renderOffset,o=[this.canvas.clientWidth,this.canvas.clientHeight];t=t*o[0]/r+s[0],e=e*o[1]/n+s[1];const a=this.displayRatio;return t*=a,e*=a,[t,e]}toLocalPos(t,e){const{width:r,height:n}=this.getResolution(),s=this.renderOffset,o=[this.canvas.clientWidth,this.canvas.clientHeight];t=t*r/o[0]-s[0],e=e*n/o[1]-s[1];const a=this.displayRatio;t/=a,e/=a;const c=this.layerTransformInvert;return c&&(t=c[0]*t+c[2]*e+c[4],e=c[1]*t+c[3]*e+c[5]),[t,e]}};$t.registerNode(xi,"layer");qe(Array);const zf=Symbol("inited");let Ms=null;typeof Worker=="function"&&(Ms=class extends Worker{constructor(i){if(i.worker===!0&&(i.worker=`./${i.id}.worker.js`),super(i.worker),this.options=i,!i.canvas){const{width:t,height:e}=this.getResolution(),r=ht.ENV.createCanvas(t,e,{offscreen:!1});r.style&&(r.style.position="absolute"),r.dataset&&(r.dataset.layerId=i.id),i.canvas=r}this.canvas=i.canvas}get id(){return this.options.id}setResolution({width:i,height:t}){if(this[zf])this.postMessage({type:"resolution_change",width:i,height:t});else{this.canvas.width=i,this.canvas.height=t;const e=this.options,r=e.canvas.transferControlToOffscreen(),n={...e};delete n.container,n.canvas=r,this.postMessage({type:"create",options:n},[r]),this[zf]=!0}}getResolution(){if(this.canvas){const{width:i,height:t}=this.canvas;return{width:i,height:t}}return{width:300,height:150}}remove(){return this.parent&&this.parent.removeChild?(this.parent.removeChild(this),!0):!1}connect(i,t){Object.defineProperty(this,"parent",{value:i,writable:!1,configurable:!0}),Object.defineProperty(this,"zOrder",{value:t,writable:!1,configurable:!0})}disconnect(){delete this.parent,delete this.zOrder}dispatchPointerEvent(i){this.postMessage({type:"event",event:{cancelBubble:i.cancelBubble,bubbles:i.bubbles,detail:i.detail,identifier:i.identifier,layerX:i.layerX,layerY:i.layerY,originalX:i.originalX,originalY:i.originalY,type:i.type,x:i.x,y:i.y}})}});qe(Array);function Qie(i,{offsetTop:t=0,offsetLeft:e=0,displayRatio:r=1}={}){let n,s;const o=[],{left:a,top:c,width:l,height:u}=i.target.getBoundingClientRect(),h=i.target.width,d=i.target.height,g=i.changedTouches||[i];for(let v=0;v<g.length;v++){const I=g[v],D=I.identifier,{clientX:x,clientY:j}=I;x!=null&&j!=null&&o.push({x:Math.round((x|0)-a),y:Math.round((j|0)-c),identifier:D})}o.length<=0&&o.push({x:n,y:s});const p=[];return o.forEach(v=>{v.x!=null&&v.y!=null&&(n=(v.x*h/l-e)/r,s=(v.y*d/u-t)/r);const I=new Xn(i);Object.defineProperties(I,{layerX:{value:n,configurable:!0},layerY:{value:s,configurable:!0},originalX:{value:v.x},originalY:{value:v.y},x:{value:n,configurable:!0},y:{value:s,configurable:!0},identifier:{value:v.identifier}}),p.push(I)}),p}qe(Array);const Ko=Symbol("enteredTargets");function jf(i){return i.id=i.id||`_layer${Math.random().toString(36).slice(2,12)}`,i.dataset||(i.dataset={}),i.dataset.layerId=i.id,i.connect=(t,e)=>{i.parent=t,Object.defineProperty(i,"zOrder",{value:e,writable:!1,configurable:!0})},i.disconnect=t=>{delete i.zOrder},i.canvas=i,i.getResolution=()=>({width:0,height:0}),i.setResolution=()=>!1,i.options={handleEvent:!1},i}function Bf(i,t){const e=i.children;let r=null;for(let n=0;n<e.length;n++){const s=e[n];if((t===s||r!=null)&&(r=s),r&&r!==t&&!r.offscreen)return r.canvas}return null}function Uf(i,t){const[e,r]=i.renderOffset,{width:n,height:s}=i.getResolution(),o=i.displayRatio;i.renderer.drawImage(t.canvas,-e/o,-r/o,n/o,s/o)}const il={};function Zie(i){const t=["mousedown","mouseup","mousemove","mousewheel","wheel","touchstart","touchend","touchmove","touchcancel","click","dblclick","longpress","tap","contextmenu"],e=i.container;e.addEventListener("mouseleave",r=>{const n=i[Ko];if(n.size){const s=new Xn("mouseleave");s.setOriginalEvent(r),[...n].forEach(o=>{o.dispatchEvent(s)}),i[Ko].clear()}},{passive:!0}),t.forEach(r=>{e.addEventListener(r,n=>{const{left:s,top:o,displayRatio:a}=i.options,c=i.orderedChildren;Qie(n,{offsetLeft:s,offsetTop:o,displayRatio:a}).forEach(u=>{const h=u.identifier;if(u.type==="touchmove"||u.type==="touchend"){const g=il[h];g&&g.dispatchEvent(u),u.type==="touchend"&&delete il[h]}else{for(let g=c.length-1;g>=0;g--){const p=c[g];if(p.options.handleEvent!==!1){if(p.dispatchPointerEvent(u)&&u.target!==p)break;u.cancelBubble=!1}}if(u.target===c[0])for(let g=c.length-1;g>=0;g--){const p=c[g];if(p.options.handleEvent!==!1){u.target=p;break}}}const d=u.target;if(u.type==="touchstart"&&(il[h]=u.target),u.type==="mousemove"){const g=i[Ko];let p;if(d){const D=d.ancestors||[];p=new Set([d,...D])}else p=new Set;const v=Object.entries(n);if(!g.has(d)&&d){const D=new Xn("mouseenter");D.setOriginalEvent(n),v.forEach(([j,w])=>{D[j]=w}),g.add(d),d.dispatchEvent(D);const x=d.ancestors;x&&x.forEach(j=>{j instanceof $a&&!g.has(j)&&(g.add(j),j.dispatchEvent(D))})}const I=new Xn("mouseleave");I.setOriginalEvent(n),v.forEach(([D,x])=>{I[D]=x}),[...g].forEach(D=>{p.has(D)||(g.delete(D),D.dispatchEvent(I))})}})},{passive:r!=="contextmenu"})})}function Po(i,t){if(t&&t.style){let{width:e,height:r,mode:n,container:s}=i;const{clientWidth:o,clientHeight:a}=s;e=e||o,r=r||a,n==="static"?(t.style.width=`${e}px`,t.style.height=`${r}px`):(t.style.top="0",t.style.left="0",t.style.width=`${o}px`,t.style.height=`${a}px`,t.style.transform="",t.style.webkitTransform="")}}const is=Symbol("offscreenLayerCount");class qa extends dt{constructor(t={}){if(super(),!t.container)if(typeof ht.ENV.Container=="function")t.container=new ht.ENV.Container(t.width||300,t.height||150);else throw new Error("No container specified.");if(this.container=t.container,this.container.style&&(this.container.style.overflow||(this.container.style.overflow="hidden"),this.container.style.position||(this.container.style.position="relative")),this.options=t,t.displayRatio=t.displayRatio||1,t.mode=t.mode||"scale",t.left=0,t.top=0,t.autoResize=t.autoResize!==!1,t.autoResize){let e;if(typeof globalThis<"u"?e=globalThis:e=typeof window<"u"?window:global,e.addEventListener){const r=this;e.addEventListener("resize",function n(){typeof document<"u"&&document.contains(r.container)?r.resize():e.removeEventListener("resize",n)})}}this[Ko]=new Set,this.setResolution(t),Zie(this),this[is]=0}get hasOffscreenCanvas(){return this[is]>0}set displayRatio(t){this.options.displayRatio!==t&&(this.options.displayRatio=t,this.resize())}get displayRatio(){return this.options.displayRatio}set height(t){this.options.height!==t&&(this.options.height=t,this.resize())}get height(){return this.options.height}set mode(t){this.options.mode!==t&&(this.options.mode=t,this.resize())}get mode(){return this.options.mode}set width(t){this.options.width!==t&&(this.options.width=t,this.resize())}get width(){return this.options.width}appendChild(t){!(t instanceof xi)&&!(t instanceof Ms)&&jf(t);const e=super.appendChild(t),r=t.canvas;return t.offscreen?this[is]++:this.container.appendChild(r),Po(this.options,r),t.setResolution(this.getResolution()),e}forceUpdate(){this.hasOffscreenCanvas&&!this._requestID&&(this._requestID=Qr(()=>{delete this._requestID,this.render()}))}insertBefore(t,e){!(t instanceof xi)&&!(t instanceof Ms)&&jf(t);const r=super.insertBefore(t,e),n=t.canvas;if(!t.offscreen){const s=Bf(this,t);this.container.insertBefore(n,s)}return Po(this.options,n),t.setResolution(this.getResolution()),r}layer(t="default",e={}){e=Object.assign({},this.options,e),e.id=t;const r=this.orderedChildren;for(let o=0;o<r.length;o++)if(r[o].id===t)return r[o];const n=e.worker;let s;return n?s=new Ms(e):s=new xi(e),this.appendChild(s),s}async preload(...t){const e=[],r=[],n=[];for(let s=0;s<t.length;s++){const o=t[s];let a;if(typeof o=="string")a=oa(o);else if(Array.isArray(o))a=Yie(...o);else{const{id:c,src:l}=o;a=oa(l,c)}a instanceof Promise||(a=Promise.resolve(a)),r.push(a.then(c=>{e.push(c),n[s]=c;const l=new Xn({type:"preload",detail:{current:c,loaded:e,resources:t}});this.dispatchEvent(l)}))}return await Promise.all(r),n}removeChild(t){const e=super.removeChild(t);if(e){t._prepareRenderFinished&&t._prepareRenderFinished();const r=t.canvas;r&&r.remove&&r.remove(),t.offscreen&&this[is]--}return e}render(){const t=this.orderedChildren;let e=null;const r=[];for(let n=0;n<t.length;n++){const s=t[n],o=r.length>0;if(s instanceof xi&&!s.offscreen)if(!s.autoRender)o&&(console.warn("Some offscreen canvas will not be rendered."),r.length=0);else if(e=s,o){s.renderer.clear();for(let a=0;a<r.length;a++){const c=r[a];c.render(),Uf(s,c)}r.length=0,s.render({clear:!1})}else s.prepareRender&&s.render();else s.offscreen?e?(s.prepareRender&&s.render(),Uf(e,s)):r.push(s):s instanceof Ms&&o&&(console.warn("Some offscreen canvas will not be rendered."),r.length=0)}}replaceChild(t,e){const r=super.replaceChild(t,e);e.canvas.remove&&e.canvas.remove(),e.offscreen&&this[is]--;const n=t.canvas;if(!t.offscreen){const s=Bf(this,t);this.container.insertBefore(n,s)}return Po(this.options,n),t.setResolution(this.getResolution()),r}resize(){const t=this.options;this.children.forEach(e=>{Po(t,e.canvas)}),this.setResolution(t),this.dispatchEvent({type:"resize"})}setResolution({width:t,height:e}={}){const r=this.container,{clientWidth:n,clientHeight:s}=r;(t==null||e==null)&&(t=t??n,e=e??s);const{mode:o,displayRatio:a}=this.options;if(t*=a,e*=a,this.options.left=0,this.options.top=0,o==="stickyHeight"||o==="stickyLeft"||o==="stickyRight"){const c=t;t=n*e/s,o==="stickyHeight"&&(this.options.left=.5*(t-c)),o==="stickyRight"&&(this.options.left=t-c)}else if(o==="stickyWidth"||o==="stickyTop"||o==="stickyBottom"){const c=e;e=s*t/n,o==="stickyWidth"&&(this.options.top=.5*(e-c)),o==="stickyBottom"&&(this.options.top=e-c)}super.setResolution({width:t,height:e})}snapshot({offscreen:t=!1,layers:e}={}){const r=t?"snapshotOffScreenCanvas":"snapshotCanvas",{width:n,height:s}=this.getResolution();this[r]=this[r]||ht.ENV.createCanvas(n,s,{offscreen:t});const o=this[r].getContext("2d");e=e||this.orderedChildren,this[r].width=n,this[r].height=s;for(let a=0;a<e.length;a++){const c=e[a];if(!c.options.ignoreSnapshot){c.render&&c.render();const l=c.canvas;l&&l!==c&&o.drawImage(l,0,0,n,s)}}return this[r]}}typeof document<"u"&&(qa.prototype.layer3d=function(i,t={}){const e=t.url||"https://unpkg.com/sprite-extend-3d/dist/sprite-extend-3d.min.js";return new Promise((r,n)=>{const s=document.createElement("script");s.async=!1,s.src=e,s.onload=()=>{try{r(this.layer3d(i,t))}catch(o){n(o)}},document.documentElement.appendChild(s)})});$t.registerNode(qa,"scene");var yy={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(vt,function(){var e=function(){function C(P,E){var O=[],V=!0,N=!1,A=void 0;try{for(var k=P[Symbol.iterator](),U;!(V=(U=k.next()).done)&&(O.push(U.value),!(E&&O.length===E));V=!0);}catch(Z){N=!0,A=Z}finally{try{!V&&k.return&&k.return()}finally{if(N)throw A}}return O}return function(P,E){if(Array.isArray(P))return P;if(Symbol.iterator in Object(P))return C(P,E);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),r=Math.PI*2,n=function(P,E,O,V,N,A,k){var U=P.x,Z=P.y;U*=E,Z*=O;var Q=V*U-N*Z,ce=N*U+V*Z;return{x:Q+A,y:ce+k}},s=function(P,E){var O=1.3333333333333333*Math.tan(E/4),V=Math.cos(P),N=Math.sin(P),A=Math.cos(P+E),k=Math.sin(P+E);return[{x:V-N*O,y:N+V*O},{x:A+k*O,y:k-A*O},{x:A,y:k}]},o=function(P,E,O,V){var N=P*V-E*O<0?-1:1,A=Math.sqrt(P*P+E*E),k=Math.sqrt(P*P+E*E),U=P*O+E*V,Z=U/(A*k);return Z>1&&(Z=1),Z<-1&&(Z=-1),N*Math.acos(Z)},a=function(P,E,O,V,N,A,k,U,Z,Q,ce,L){var W=Math.pow(N,2),H=Math.pow(A,2),$=Math.pow(ce,2),ee=Math.pow(L,2),ie=W*H-W*ee-H*$;ie<0&&(ie=0),ie/=W*ee+H*$,ie=Math.sqrt(ie)*(k===U?-1:1);var le=ie*N/A*L,pe=ie*-A/N*ce,Te=Q*le-Z*pe+(P+O)/2,z=Z*le+Q*pe+(E+V)/2,B=(ce-le)/N,X=(L-pe)/A,ae=(-ce-le)/N,q=(-L-pe)/A,te=o(1,0,B,X),m=o(B,X,ae,q);return U===0&&m>0&&(m-=r),U===1&&m<0&&(m+=r),[Te,z,te,m]},c=function(P){var E=P.px,O=P.py,V=P.cx,N=P.cy,A=P.rx,k=P.ry,U=P.xAxisRotation,Z=U===void 0?0:U,Q=P.largeArcFlag,ce=Q===void 0?0:Q,L=P.sweepFlag,W=L===void 0?0:L,H=[];if(A===0||k===0)return[];var $=Math.sin(Z*r/360),ee=Math.cos(Z*r/360),ie=ee*(E-V)/2+$*(O-N)/2,le=-$*(E-V)/2+ee*(O-N)/2;if(ie===0&&le===0)return[];A=Math.abs(A),k=Math.abs(k);var pe=Math.pow(ie,2)/Math.pow(A,2)+Math.pow(le,2)/Math.pow(k,2);pe>1&&(A*=Math.sqrt(pe),k*=Math.sqrt(pe));var Te=a(E,O,V,N,A,k,ce,W,$,ee,ie,le),z=e(Te,4),B=z[0],X=z[1],ae=z[2],q=z[3],te=Math.max(Math.ceil(Math.abs(q)/(r/4)),1);q/=te;for(var m=0;m<te;m++)H.push(s(ae,q)),ae+=q;return H.map(function(S){var F=n(S[0],A,k,ee,$,B,X),Y=F.x,_=F.y,re=n(S[1],A,k,ee,$,B,X),ne=re.x,J=re.y,se=n(S[2],A,k,ee,$,B,X),ue=se.x,oe=se.y;return{x1:Y,y1:_,x2:ne,y2:J,x:ue,y:oe}})},l={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},u=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function h(C){var P=[];return C.replace(u,function(E,O,V){var N=O.toLowerCase();for(V=g(V),N=="m"&&V.length>2&&(P.push([O].concat(V.splice(0,2))),N="l",O=O=="m"?"l":"L");;){if(V.length==l[N])return V.unshift(O),P.push(V);if(V.length<l[N])throw new Error("malformed path data");P.push([O].concat(V.splice(0,l[N])))}}),P}var d=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function g(C){var P=C.match(d);return P?P.map(Number):[]}function p(C){var P=C[0][0],E=C[0][1],O=P,V=E;return C.forEach(function(N){var A=N[0],k=N[2],U=N[4],Z=N[6],Q=N[1],ce=N[3],L=N[5],W=N[7];P=Math.min(P,A,k,U,Z),E=Math.min(E,Q,ce,L,W),O=Math.max(O,A,k,U,Z),V=Math.max(V,Q,ce,L,W)}),[P,E,O,V]}function v(C,P){return Math.sqrt(Math.pow(C[0]-P[0],2)+Math.pow(C[1]-P[1],2))+Math.sqrt(Math.pow(C[2]-P[2],2)+Math.pow(C[3]-P[3],2))}function I(C,P){var E=C[0],O=C[2],V=C[4],N=C[6],A=C[1],k=C[3],U=C[5],Z=C[7],Q=P[0],ce=P[2],L=P[4],W=P[6],H=P[1],$=P[3],ee=P[5],ie=P[7];return Math.sqrt(Math.pow(Q-E,2)+Math.pow(H-A,2))+Math.sqrt(Math.pow(ce-O,2)+Math.pow($-k,2))+Math.sqrt(Math.pow(L-V,2)+Math.pow(ee-U,2))+Math.sqrt(Math.pow(W-N,2)+Math.pow(ie-Z,2))}function D(C,P){var E=j(C.length),O=[];E.forEach(function(N){var A=0,k=0;N.forEach(function(U){A+=I(C[U],P[k++])}),O.push({index:N,distance:A})}),O.sort(function(N,A){return N.distance-A.distance});var V=[];return O[0].index.forEach(function(N){V.push(C[N])}),V}function x(C,P){var E=w(C.length),O=[];E.forEach(function(N){var A=0;N.forEach(function(k){A+=v(p(C[k]),p(P[k]))}),O.push({index:N,distance:A})}),O.sort(function(N,A){return N.distance-A.distance});var V=[];return O[0].index.forEach(function(N){V.push(C[N])}),V}function j(C){for(var P=[],E=0;E<C;E++){for(var O=[],V=0;V<C;V++){var N=V+E;N>C-1&&(N-=C),O[N]=V}P.push(O)}return P}function w(C){for(var P=[],E=0;E<C;E++)P.push(E);return y(P)}function y(C){var P=[],E=[];function O(V){var N,A;for(N=0;N<V.length;N++)A=V.splice(N,1)[0],E.push(A),V.length==0&&P.push(E.slice()),O(V),V.splice(N,0,A),E.pop();return P}return O(C)}var f={};f.parser=h,f.lerpCurve=function(C,P,E){return f.lerpPoints(C[0],C[1],P[0],P[1],E).concat(f.lerpPoints(C[2],C[3],P[2],P[3],E)).concat(f.lerpPoints(C[4],C[5],P[4],P[5],E)).concat(f.lerpPoints(C[6],C[7],P[6],P[7],E))},f.lerpPoints=function(C,P,E,O,V){return[C+(E-C)*V,P+(O-P)*V]},f.q2b=function(C,P,E,O,V,N){return[C,P,(C+2*E)/3,(P+2*O)/3,(V+2*E)/3,(N+2*O)/3,V,N]},f.path2shapes=function(C){for(var P=f.parser(C),E=0,O=0,V=0,N=P.length,A=[],k=null,U=void 0,Z=void 0,Q=void 0,ce=void 0,L=void 0,W=void 0,H=void 0;V<N;V++){var $=P[V],ee=$[0],ie=P[V-1];switch(ee){case"m":L=A.length,A[L]=[],k=A[L],E=E+$[1],O=O+$[2];break;case"M":L=A.length,A[L]=[],k=A[L],E=$[1],O=$[2];break;case"l":k.push([E,O,E,O,E,O,E+$[1],O+$[2]]),E+=$[1],O+=$[2];break;case"L":k.push([E,O,$[1],$[2],$[1],$[2],$[1],$[2]]),E=$[1],O=$[2];break;case"h":k.push([E,O,E,O,E,O,E+$[1],O]),E+=$[1];break;case"H":k.push([E,O,$[1],O,$[1],O,$[1],O]),E=$[1];break;case"v":k.push([E,O,E,O,E,O,E,O+$[1]]),O+=$[1];break;case"V":k.push([E,O,E,$[1],E,$[1],E,$[1]]),O=$[1];break;case"C":k.push([E,O,$[1],$[2],$[3],$[4],$[5],$[6]]),E=$[5],O=$[6];break;case"S":ie[0]==="C"||ie[0]==="c"?k.push([E,O,E+ie[5]-ie[3],O+ie[6]-ie[4],$[1],$[2],$[3],$[4]]):(ie[0]==="S"||ie[0]==="s")&&k.push([E,O,E+ie[3]-ie[1],O+ie[4]-ie[2],$[1],$[2],$[3],$[4]]),E=$[3],O=$[4];break;case"c":k.push([E,O,E+$[1],O+$[2],E+$[3],O+$[4],E+$[5],O+$[6]]),E=E+$[5],O=O+$[6];break;case"s":ie[0]==="C"||ie[0]==="c"?k.push([E,O,E+ie[5]-ie[3],O+ie[6]-ie[4],E+$[1],O+$[2],E+$[3],O+$[4]]):(ie[0]==="S"||ie[0]==="s")&&k.push([E,O,E+ie[3]-ie[1],O+ie[4]-ie[2],E+$[1],O+$[2],E+$[3],O+$[4]]),E=E+$[3],O=O+$[4];break;case"a":W=c({rx:$[1],ry:$[2],px:E,py:O,xAxisRotation:$[3],largeArcFlag:$[4],sweepFlag:$[5],cx:E+$[6],cy:O+$[7]}),H=W[W.length-1],W.forEach(function(le,pe){pe===0?k.push([E,O,le.x1,le.y1,le.x2,le.y2,le.x,le.y]):k.push([W[pe-1].x,W[pe-1].y,le.x1,le.y1,le.x2,le.y2,le.x,le.y])}),E=H.x,O=H.y;break;case"A":W=c({rx:$[1],ry:$[2],px:E,py:O,xAxisRotation:$[3],largeArcFlag:$[4],sweepFlag:$[5],cx:$[6],cy:$[7]}),H=W[W.length-1],W.forEach(function(le,pe){pe===0?k.push([E,O,le.x1,le.y1,le.x2,le.y2,le.x,le.y]):k.push([W[pe-1].x,W[pe-1].y,le.x1,le.y1,le.x2,le.y2,le.x,le.y])}),E=H.x,O=H.y;break;case"Q":k.push(f.q2b(E,O,$[1],$[2],$[3],$[4])),E=$[3],O=$[4];break;case"q":k.push(f.q2b(E,O,E+$[1],O+$[2],$[3]+E,$[4]+O)),E+=$[3],O+=$[4];break;case"T":ie[0]==="Q"||ie[0]==="q"?(Q=E+ie[3]-ie[1],ce=O+ie[4]-ie[2],k.push(f.q2b(E,O,Q,ce,$[1],$[2]))):(ie[0]==="T"||ie[0]==="t")&&(k.push(f.q2b(E,O,E+E-Q,O+O-ce,$[1],$[2])),Q=E+E-Q,ce=O+O-ce),E=$[1],O=$[2];break;case"t":ie[0]==="Q"||ie[0]==="q"?(Q=E+ie[3]-ie[1],ce=O+ie[4]-ie[2],k.push(f.q2b(E,O,Q,ce,E+$[1],O+$[2]))):(ie[0]==="T"||ie[0]==="t")&&(k.push(f.q2b(E,O,E+E-Q,O+O-ce,E+$[1],O+$[2])),Q=E+E-Q,ce=O+O-ce),E+=$[1],O+=$[2];break;case"Z":U=k[0][0],Z=k[0][1],k.push([E,O,U,Z,U,Z,U,Z]);break;case"z":U=k[0][0],Z=k[0][1],k.push([E,O,U,Z,U,Z,U,Z]);break}}return A},f._upCurves=function(C,P){for(var E=0,O=0,V=C.length;E<P;E++)C.push(C[O].slice(0)),O++,O>V-1&&(O-=V)};function M(C,P,E,O,V,N,A,k,U){return{left:T(C,P,E,O,V,N,A,k,U),right:T(A,k,V,N,E,O,C,P,1-U,!0)}}function T(C,P,E,O,V,N,A,k,U,Z){var Q=(E-C)*U+C,ce=(O-P)*U+P,L=(V-E)*U+E,W=(N-O)*U+O,H=(A-V)*U+V,$=(k-N)*U+N,ee=(L-Q)*U+Q,ie=(W-ce)*U+ce,le=(H-L)*U+L,pe=($-W)*U+W,Te=(le-ee)*U+ee,z=(pe-ie)*U+ie;return Z?[Te,z,ee,ie,Q,ce,C,P]:[C,P,Q,ce,ee,ie,Te,z]}f._splitCurves=function(C,P){for(var E=0,O=0;E<P;E++){var V=C[O],N=M(V[0],V[1],V[2],V[3],V[4],V[5],V[6],V[7],.5);C.splice(O,1),C.splice(O,0,N.left,N.right),O+=2,O>=C.length-1&&(O=0)}};function b(C,P){for(var E=function(N){var A=C[C.length-1],k=[];A.forEach(function(U){k.push(U.slice(0))}),C.push(k)},O=0;O<P;O++)E()}return f.lerp=function(C,P,E){return f._lerp(f.path2shapes(C),f.path2shapes(P),E)},f.MIM_CURVES_COUNT=100,f._preprocessing=function(C,P){var E=C.length,O=P.length,V=JSON.parse(JSON.stringify(C)),N=JSON.parse(JSON.stringify(P));return E>O?b(N,E-O):E<O&&b(V,O-E),V=x(V,N),V.forEach(function(A,k){var U=A.length,Z=N[k].length;U>Z?U<f.MIM_CURVES_COUNT?(f._splitCurves(A,f.MIM_CURVES_COUNT-U),f._splitCurves(N[k],f.MIM_CURVES_COUNT-Z)):f._splitCurves(N[k],U-Z):U<Z&&(Z<f.MIM_CURVES_COUNT?(f._splitCurves(A,f.MIM_CURVES_COUNT-U),f._splitCurves(N[k],f.MIM_CURVES_COUNT-Z)):f._splitCurves(A,Z-U))}),V.forEach(function(A,k){V[k]=D(A,N[k])}),[V,N]},f._lerp=function(C,P,E){var O=[];return C.forEach(function(V,N){var A=[];V.forEach(function(k,U){A.push(f.lerpCurve(k,P[N][U],E))}),O.push(A)}),O},f.animate=function(C){var P=f.path2shapes(C.from),E=f.path2shapes(C.to),O=f._preprocessing(P,E),V=new Date,N=C.end||function(){},A=C.progress||function(){},k=C.begin||function(){},U=C.easing||function(W){return W},Z=null,Q=null,ce=C.time;k(P);var L=function W(){var H=new Date-V;if(H>=ce){Q=E,A(Q,1),N(Q),cancelAnimationFrame(Z);return}var $=U(H/ce);Q=f._lerp(O[0],O[1],$),A(Q,$),Z=requestAnimationFrame(W)};L()},f})})(yy);var Kie=yy.exports;const ko=en(Kie);qe(Array);const qie=Symbol.for("spritejs_setAttributeDefault"),Pt=Symbol.for("spritejs_setAttribute"),kt=Symbol.for("spritejs_getAttribute");let Xa=class extends Eu{constructor(t){super(t),this[qie]({d:"",normalize:!1,fillColor:void 0,fillRule:"nonzero",strokeColor:void 0,lineWidth:1,lineJoin:"miter",lineCap:"butt",roundSegments:20,lineDash:void 0,lineDashOffset:0,miterLimit:10,texture:void 0,textureRect:void 0,textureRepeat:!1,sourceRect:void 0,clipPath:void 0})}get d(){return this[kt]("d")}set d(t){this[Pt]("d",t)}get normalize(){return this[kt]("normalize")}set normalize(t){this[Pt]("normalize",!!t)}get fillColor(){return this[kt]("fillColor")}set fillColor(t){this[Pt]("fillColor",Tn(t))}get fillRule(){return this[kt]("fillRule")}set fillRule(t){if(t!=null&&t!=="nonzero"&&t!=="evenodd")throw new TypeError("Invalid fill rule.");this[Pt]("fillRule",t)}get strokeColor(){return this[kt]("strokeColor")}set strokeColor(t){this[Pt]("strokeColor",Tn(t))}get lineWidth(){return this[kt]("lineWidth")}set lineWidth(t){this[Pt]("lineWidth",Qe(t))}get lineJoin(){return this[kt]("lineJoin")}set lineJoin(t){if(t!=null&&t!=="miter"&&t!=="bevel"&&t!=="round")throw new TypeError("Invalid lineJoin type.");this[Pt]("lineJoin",t)}get lineCap(){return this[kt]("lineCap")}set lineCap(t){if(t!=null&&t!=="butt"&&t!=="square"&&t!=="round")throw new TypeError("Invalid lineCap type.");this[Pt]("lineCap",t)}get lineDash(){return this[kt]("lineDash")}set lineDash(t){t=mt(t,!0),t!=null&&!Array.isArray(t)&&(t=[t]),this[Pt]("lineDash",t?t.map(Qe):null)}get lineDashOffset(){return this[kt]("lineDashOffset")}set lineDashOffset(t){this[Pt]("lineDashOffset",Qe(t))}get miterLimit(){return this[kt]("miterLimit")}set miterLimit(t){this[Pt]("miterLimit",Qe(t))}get roundSegments(){return this[kt]("roundSegments")}set roundSegments(t){this[Pt]("roundSegments",t)}get texture(){return this[kt]("texture")}set texture(t){this[Pt]("texture",t)}get textureRect(){return this[kt]("textureRect")}set textureRect(t){this[Pt]("textureRect",t)}get sourceRect(){return this[kt]("sourceRect")}set sourceRect(t){this[Pt]("sourceRect",t)}get textureRepeat(){return this[kt]("textureRepeat")}set textureRepeat(t){this[Pt]("textureRepeat",!!t)}get clipPath(){return this[kt]("clipPath")}set clipPath(t){this[Pt]("clipPath",t)}};qe(Array);const Br=Symbol("mesh");class Zt extends $a{constructor(t={}){typeof t=="string"&&(t={d:t}),super(t),this.effects={d(e,r,n,s,o){const a=(n-s)/(o-s);if(a<=0)return e;if(a>=1)return r;const c=ko._preprocessing(ko.path2shapes(e),ko.path2shapes(r)),l=ko._lerp(...c,a)[0];return l.reduce((h,d)=>`${h}${d.slice(2).join(" ")} `,`M${l[0][0]} ${l[0][1]}C`).trim()}}}get isVisible(){return!!this.d}get mesh(){if(this.attributes.display==="none")return null;const t=this.path;if(t){let e=this[Br];if(e)e.path!==t&&(e.contours=t.contours,e.path=t);else{e=new ht.Mesh2D(this.path),e.path=t;const n=this.attributes.fillColor,s=this.attributes.fillRule;n&&ra(e,{color:n,rule:s});const o=this.attributes.lineWidth,a=this.attributes.strokeColor;if(a&&o>0){const{lineCap:l,lineJoin:u,miterLimit:h,lineDash:d,lineDashOffset:g,roundSegments:p}=this.attributes;na(e,{color:a,lineWidth:o,lineCap:l,lineJoin:u,miterLimit:h,lineDash:d,lineDashOffset:g,roundSegments:p})}this[Br]=e;const c=this.attributes.clipPath;c&&this[Br].setClipPath(c)}const r=this.opacity;return e.getOpacity()!==r&&e.setOpacity(r),e.setTransform(...this.renderMatrix),e}return null}get originalContentRect(){if(this.path){const t=this.path.boundingBox;return[t[0][0],t[0][1],t[1][0]-t[0][0],t[1][1]-t[0][1]]}return[0,0,0,0]}get originalClientRect(){if(this.mesh){const t=this.mesh.boundingBox;return[t[0][0],t[0][1],t[1][0]-t[0][0],t[1][1]-t[0][1]]}return[0,0,0,0]}get originalClientCenter(){return this.mesh?this.mesh.boundingCenter:[0,0]}set d(t){this.attributes.d=t}get d(){return this.attributes.d}draw(t=[]){super.draw(t);const e=this.mesh;return e&&my(this,e),t}getBoundingClientRect(){let t=null;return this.mesh&&(t=this.mesh.boundingBox),wm(t,this.renderMatrix)}getPathLength(){return this.mesh?this.mesh.getTotalLength():0}getPointAtLength(t){if(this.mesh){const e=this.mesh.getPointAtLength(t);if(e)return[e.x,e.y]}return[0,0]}onPropertyChange(t,e,r){if(super.onPropertyChange(t,e,r),(t==="d"||t==="normalize")&&this.updateContours(),this[Br]&&(t==="fillColor"||t==="fillRule")){const{fillColor:n,fillRule:s}=this.attributes;ra(this[Br],{color:n,rule:s})}if(this[Br]&&(t==="strokeColor"||t==="lineWidth"||t==="lineCap"||t==="lineJoin"||t==="lineDash"||t==="lineDashOffset"||t==="roundSegments")){const{strokeColor:n,lineWidth:s}=this.attributes;if(n&&s>0){const{lineCap:o,lineJoin:a,lineDash:c,lineDashOffset:l,miterLimit:u,roundSegments:h}=this.attributes;na(this[Br],{color:n,lineCap:o,lineJoin:a,lineWidth:s,lineDash:c,lineDashOffset:l,miterLimit:u,roundSegments:h})}}this[Br]&&t==="clipPath"&&this[Br].setClipPath(e),t==="texture"&&fy(this,e)}updateContours(){this.path=new ht.Figure2D,this.path.addPath(this.attributes.d),this.attributes.normalize&&this.path.normalize(...this.path.boundingCenter)}}R(Zt,"Attr",Xa);$t.registerNode(Zt,"path");qe(Array);function Xie(i,t=[0]){function e(s,o=.168,a=.168){let c,l,u,h;if((i[s].x===i[s+1].x||i[s].y===i[s+1].y)&&(o=0,a=0),s<1?(c=i[0].x+(i[1].x-i[0].x)*o,l=i[0].y+(i[1].y-i[0].y)*o):(c=i[s].x+(i[s+1].x-i[s-1].x)*o,l=i[s].y+(i[s+1].y-i[s-1].y)*o),s>i.length-3){const d=i.length-1;u=i[d].x-(i[d].x-i[d-1].x)*a,h=i[d].y-(i[d].y-i[d-1].y)*a}else u=i[s+1].x-(i[s+2].x-i[s].x)*a,h=i[s+1].y-(i[s+2].y-i[s].y)*a;return[{x:c,y:l},{x:u,y:h}]}i=i.map(([s,o])=>({x:s,y:o}));let r="",n=0;return i.forEach((s,o)=>{if(o===0)r+=`M${s.x} ${s.y}`;else{for(;o>t[n];)n++;if(n%2){const[a,c]=e(o-1);r+=`C${[a.x,a.y,c.x,c.y,s.x,s.y].join(" ")}`}else r+=`L${s.x} ${s.y}`}}),r}qe(Array);const Jie=Symbol.for("spritejs_setAttributeDefault"),an=Symbol.for("spritejs_setAttribute"),ss=Symbol.for("spritejs_getAttribute"),_ie=Symbol.for("spritejs_declareAlias");function Lo(i){const{points:t,smooth:e,smoothRange:r,close:n}=i,s=[];for(let a=0;a<t.length;a+=2)s.push([t[a],t[a+1]]);let o="";return e?o=Xie(s,r):s.length&&(o=`M${s.map(a=>a.join(" ")).join("L")}`),o&&n&&(o+="Z"),o}let ese=class extends Xa{constructor(t){super(t),this[Jie]({points:[],smooth:!1,smoothRange:[0],closeType:"none"}),this[_ie]("close")}get d(){return this[ss]("d")}set d(t){}get close(){return this.closeType!=="none"}set close(t){t=t?"normal":"none",this.closeType=t}get closeType(){return this[ss]("closeType")}set closeType(t){if(t!=null&&t!=="none"&&t!=="normal")throw new TypeError("Invalid closeType type.");if(this[an]("closeType",t)){const e=Lo(this);this[an]("d",e)}}get smooth(){return this[ss]("smooth")}set smooth(t){if(this[an]("smooth",t)){const e=Lo(this);this[an]("d",e)}}get smoothRange(){return this[ss]("smoothRange")}set smoothRange(t){if(t&&!Array.isArray(t)&&(t=[t]),this[an]("smoothRange",t)&&this.smooth){const e=Lo(this);this[an]("d",e)}}get points(){return this[ss]("points")}set points(t){if(t=mt(t),Array.isArray(t)&&(t=t.reduce((e,r)=>Array.isArray(r)?[...e,...r.map(n=>Qe(n))]:[...e,Qe(r)],[])),this[an]("points",t)){const e=Lo(this);this[an]("d",e)}}};qe(Array);class wr extends Zt{get isVisible(){const{points:t}=this.attributes;return t.length>0&&super.isVisible}}R(wr,"Attr",ese);$t.registerNode(wr,"polyline");qe(Array);const tse=Symbol.for("spritejs_setAttributeDefault"),Ro=Symbol.for("spritejs_setAttribute"),sl=Symbol.for("spritejs_getAttribute"),rse=Symbol.for("spritejs_declareAlias");function Ff(i){const{width:t,height:e}=i;return`M0 0L${t} 0L${t} ${e}L0 ${e}Z`}let nse=class extends Xa{constructor(t){super(t),this[tse]({width:0,height:0}),this[rse]("size")}get d(){return this[sl]("d")}set d(t){}get width(){return this[sl]("width")}set width(t){if(t=Qe(t),this[Ro]("width",t)){const e=Ff(this);this[Ro]("d",e)}}get height(){return this[sl]("height")}set height(t){if(t=Qe(t),this[Ro]("height",t)){const e=Ff(this);this[Ro]("d",e)}}get size(){return[this.width,this.height]}set size(t){t=mt(t),Array.isArray(t)||(t=[t,t]),this.width=t[0],this.height=t[1]}};qe(Array);class ks extends Zt{get isVisible(){const{width:t,height:e}=this.attributes;return t>0&&e>0&&super.isVisible}}R(ks,"Attr",nse);$t.registerNode(ks,"rect");qe(Array);const ise=Symbol.for("spritejs_setAttributeDefault"),dr=Symbol.for("spritejs_setAttribute"),On=Symbol.for("spritejs_getAttribute"),sse=Symbol.for("spritejs_declareAlias");function os(i){const{radiusX:t,radiusY:e,startAngle:r,endAngle:n,direction:s,closeType:o}=i,a=s==="anitclockwise",c=new ht.Figure2D;return o==="sector"&&c.moveTo(0,0),c.ellipse(0,0,t,e,0,Math.PI*r/180,Math.PI*n/180,a),o!=="none"&&c.closePath(),c.path.reduce((h,d)=>h+d.join(" "),"")}let ose=class extends Xa{constructor(t){super(t),this[ise]({radiusX:0,radiusY:0,startAngle:0,endAngle:360,direction:"clockwise",closeType:"none"}),this[sse]("radius","angle")}get d(){return this[On]("d")}set d(t){}get radiusX(){return this[On]("radiusX")}set radiusX(t){if(t=Qe(t),this[dr]("radiusX",t)){const e=os(this);this[dr]("d",e)}}get radiusY(){return this[On]("radiusY")}set radiusY(t){if(t=Qe(t),this[dr]("radiusY",t)){const e=os(this);this[dr]("d",e)}}get radius(){return[this.radiusX,this.radiusY]}set radius(t){t=mt(t,!0),Array.isArray(t)||(t=[t,t]),this.radiusX=t[0],this.radiusY=t[1]}get angle(){return[this.startAngle,this.endAngle]}set angle(t){t=mt(t),Array.isArray(t)||(t=[t,t]),this.startAngle=t[0],this.endAngle=t[1]}get direction(){return this[On]("direction")}set direction(t){if(t!=null&&t!=="clockwise"&&t!=="anticlockwise")throw new TypeError("Invalid direction type.");this[dr]("direction",t)}get startAngle(){return this[On]("startAngle")}set startAngle(t){if(t=Qe(t),this[dr]("startAngle",t)){const e=os(this);this[dr]("d",e)}}get endAngle(){return this[On]("endAngle")}set endAngle(t){if(t=Qe(t),this[dr]("endAngle",t)){const e=os(this);this[dr]("d",e)}}get closeType(){return this[On]("closeType")}set closeType(t){if(t!=null&&t!=="none"&&t!=="sector"&&t!=="normal")throw new TypeError("Invalid closeType type.");if(this[dr]("closeType",t)){const e=os(this);this[dr]("d",e)}}};qe(Array);class gh extends Zt{get isVisible(){const{radiusX:t,radiusY:e,startAngle:r,endAngle:n}=this.attributes;return t>0&&e>0&&r!==n&&super.isVisible}}R(gh,"Attr",ose);$t.registerNode(gh,"ellipse");qe(Array);const ase=Symbol.for("spritejs_setAttributeDefault"),Oo=Symbol.for("spritejs_setAttribute"),zo=Symbol.for("spritejs_getAttribute");let cse=class extends Va{constructor(t){super(t),this[ase]({texture:void 0,textureRect:void 0,textureRepeat:!1,sourceRect:void 0})}get texture(){return this[zo]("texture")}set texture(t){this[Oo]("texture",t)}get textureRect(){return this[zo]("textureRect")}set textureRect(t){this[Oo]("textureRect",t)}get sourceRect(){return this[zo]("sourceRect")}set sourceRect(t){this[Oo]("sourceRect",t)}get textureRepeat(){return this[zo]("textureRepeat")}set textureRepeat(t){this[Oo]("textureRepeat",!!t)}};qe(Array);const Wf=Symbol("textureTask");class Ja extends Hs{constructor(t={}){typeof t=="string"&&(t={texture:t}),super(t)}get contentSize(){let[t,e]=super.contentSize;const{width:r,height:n}=this.attributes;if(r==null||n==null){const s=this.textureImage,o=this.attributes.textureRect,a=this.attributes.sourceRect;if(o)r==null&&(t=o[0]+o[2]),n==null&&(e=o[1]+o[3]);else if(a){const c=this.layer?this.layer.displayRatio:1;r==null&&(t=a[2]/c),n==null&&(e=a[3]/c)}else if(s){const c=this.layer?this.layer.displayRatio:1;r==null&&(t=s.width/c),n==null&&(e=s.height/c)}}return[t,e]}get textureImageReady(){return this[Wf]||Promise.resolve()}draw(t=[]){super.draw(t);const e=this.mesh;return e&&my(this,e),t}onPropertyChange(t,e,r){if(super.onPropertyChange(t,e,r),t==="texture"&&(this[Wf]=fy(this,e,!0)),t==="textureRect"){const{width:n,height:s}=this.attributes;(n==null||s==null)&&this.updateContours()}}}R(Ja,"Attr",cse);$t.registerNode(Ja,"sprite");qe(Array);const lse=Symbol.for("spritejs_setAttributeDefault"),Jt=Symbol.for("spritejs_setAttribute"),_t=Symbol.for("spritejs_getAttribute"),use=Symbol.for("spritejs_declareAlias");let hse=class extends Va{constructor(t){super(t),this[lse]({text:"",fontSize:16,fontFamily:"Helvetica,Arial,sans-serif",fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",fontStretch:"normal",lineHeight:"",textAlign:"left",strokeColor:void 0,strokeWidth:1,fillColor:void 0,verticalAlign:"middle"}),this[use]("font")}get text(){return this[_t]("text")||" "}set text(t){this[Jt]("text",t)}get fontSize(){return this[_t]("fontSize")}set fontSize(t){this[Jt]("fontSize",Qe(t))}get fontFamily(){return this[_t]("fontFamily")}set fontFamily(t){this[Jt]("fontFamily",t)}get fontStyle(){return this[_t]("fontStyle")}set fontStyle(t){this[Jt]("fontStyle",t)}get fontVariant(){return this[_t]("fontVariant")}set fontVariant(t){this[Jt]("fontVariant",t)}get fontWeight(){return this[_t]("fontWeight")}set fontWeight(t){this[Jt]("fontWeight",t)}get fontStretch(){return this[_t]("fontStretch")}set fontStretch(t){this[Jt]("fontStretch",t)}get lineHeight(){return this[_t]("lineHeight")||this.fontSize}set lineHeight(t){this[Jt]("lineHeight",Qe(t))}get textAlign(){return this[_t]("textAlign")}set textAlign(t){this[Jt]("textAlign",t)}get strokeColor(){return this[_t]("strokeColor")}set strokeColor(t){this[Jt]("strokeColor",Tn(t))}get strokeWidth(){return this[_t]("strokeWidth")}set strokeWidth(t){this[Jt]("strokeWidth",Qe(t))}get verticalAlign(){return this[_t]("verticalAlign")}set verticalAlign(t){this[Jt]("verticalAlign",t)}get fillColor(){return this[_t]("fillColor")}set fillColor(t){this[Jt]("fillColor",Tn(t))}get font(){const{fontStyle:t,fontVariant:e,fontWeight:r,fontStretch:n,fontSize:s,lineHeight:o,fontFamily:a}=this;return`${t} ${e} ${r} ${n} ${s}px/${o}px ${a}`}set font(t){if(t==null)this.fontStyle=null,this.fontVariant=null,this.fontWeight=null,this.fontStretch=null,this.fontSize=null,this.lineHeight=null,this.fontFamily=null;else{const e=ht.parseFont(t);this.fontStyle=e.style,this.fontVariant=e.variant,this.fontWeight=e.weight,this.fontStretch=e.stretch,this.fontSize=Qe(`${e.size}${e.unit}`),e.lineHeight&&(this.lineHeight=e.pxLineHeight),this.fontFamily=e.family}}};qe(Array);const Mi=Symbol("textImage"),jo=Symbol("textImageTask"),ol=Symbol("textureContext"),as=Symbol("updateTextureRect"),al=Symbol("textCanvas");class ph extends Hs{constructor(t={}){typeof t=="string"&&(t={text:t}),super(t)}get contentSize(){let[t,e]=super.contentSize;const{width:r,height:n}=this.attributes;if(r==null||n==null){const s=this[Mi];s&&(r==null&&(t=s.rect[2]),n==null&&(e=s.rect[3]))}return[t,e]}get text(){return this.attributes.text}set text(t){this.attributes.text=t}get textContent(){return this.attributes.text}set textContent(t){this.attributes.text=t}get textImage(){return this[Mi]||{}}get textImageReady(){return this[jo]||Promise.resolve()}draw(t){super.draw(t);const e=this.mesh;if(e){const r=this[Mi];if(r){let n=e.texture;if(!n||this[ol]&&this[ol]!==this.renderer||r.needsUpdate?(r.needsUpdate=!1,py(r.image,this.renderer),n=gy(r.image,this.renderer),this[as]=!0):n=e.uniforms.u_texSampler,this[as]){const[s,o]=r.rect.slice(2),[a,c]=this.contentSize,l=this.attributes.textAlign,u=this.attributes.verticalAlign;let h=0;l==="center"?h=(a-s)/2:(l==="right"||l==="end")&&(h=a-s);const d=this.attributes.fontSize,g=this.attributes.lineHeight;let p=0;u==="top"?p=(d-g)/2:u==="bottom"&&(p=(g-d)/2);const{paddingLeft:v,paddingTop:I}=this.attributes,{borderWidth:D}=this.attributes;h+=v+D,p+=I+D;const{anchorX:x,anchorY:j}=this.attributes;h-=this.offsetSize[0]*x,p-=this.offsetSize[1]*j,e.setTexture(n,{rect:[h,p,s,o]}),this[as]=!1,this[ol]=this.renderer}}}return t}onPropertyChange(t,e,r){t==="text"||t==="fontSize"||t==="fontFamily"||t==="fontStyle"||t==="fontVariant"||t==="fontWeight"||t==="fontStretch"||t==="lineHeight"||t==="strokeColor"||t==="fillColor"||t==="strokeWidth"?this.updateText():((t==="textAlign"||t==="verticalAlign")&&(this[as]=!0),super.onPropertyChange(t,e,r))}updateContours(){super.updateContours(),this[as]=!0}updateText(){this[jo]||(this[jo]=Promise.resolve().then(()=>{this[jo]=null;const{text:t,font:e,fillColor:r,strokeColor:n,strokeWidth:s}=this.attributes,o=this.layer?this.layer.displayRatio:1;return this[al]=this[al]||ht.ENV.createCanvas(1,1),this[Mi]=ht.ENV.createText(t,{font:e,fillColor:r,strokeColor:n,strokeWidth:s,parseFont:ht.parseFont,ratio:o,textCanvas:this[al]}),this[Mi].needsUpdate=!0,this.updateContours(),this.forceUpdate(),this[Mi]}))}}R(ph,"Attr",hse);$t.registerNode(ph,"label");qe(Array);function dse(i,t){if(!i)return t&&[...t];if(!t)return i;const e=Math.min(i[0],t[0]),r=Math.min(i[1],t[1]);return[e,r,Math.max(i[0]+i[2],t[0]+t[2])-e,Math.max(i[1]+i[3],t[1]+t[3])-r]}class fse{constructor(t,{rect:e,revision:r=0,singleChannelTexture:n=!0,textureSubImage2D:s=!0}={}){if(!t||!e||e.length!==4)throw new TypeError("MaskHandle requires a source and [x, y, width, height] rect.");this.source=t,this.rect=[...e],this.revision=r,this.textureSubImage2D=s,this.singleChannelTexture=n,this._textures=new Map,this._dirtyRect=null,this._stagingCanvas=null}update({rect:t,dirtyRect:e}={}){return t&&(this.rect=[...t]),this._dirtyRect=dse(this._dirtyRect,e),this.revision++,this}getTexture(t){if(!t||!t.glRenderer)return null;let e=this._textures.get(t);return e?e.revision!==this.revision&&(this._upload(t.glRenderer.gl,e,this._dirtyRect),e.revision=this.revision):(e={revision:this.revision,...this._createTexture(t)},this._textures.set(t,e)),[...this._textures.values()].every(r=>r.revision===this.revision)&&(this._dirtyRect=null),e.texture}destroy(t){if(t){const e=this._textures.get(t);e&&(t.deleteTexture(e.texture),this._textures.delete(t));return}this._textures.forEach((e,r)=>{r.deleteTexture(e.texture)}),this._textures.clear()}_createTexture(t){const e=t.glRenderer.gl;if(!(this.singleChannelTexture&&t.isWebGL2&&e.R8!=null))return{texture:t.createTexture(this.source),singleChannel:!1};const n=e.createTexture();try{if(e.bindTexture(e.TEXTURE_2D,n),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!0),e.texImage2D(e.TEXTURE_2D,0,e.R8,e.RED,e.UNSIGNED_BYTE,this.source),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.getError()!==e.NO_ERROR)throw new Error("R8 texture upload failed.");return n._img=this.source,n.delete=()=>e.deleteTexture(n),{texture:n,singleChannel:!0}}catch{return e.deleteTexture(n),this.singleChannelTexture=!1,{texture:t.createTexture(this.source),singleChannel:!1}}finally{e.bindTexture(e.TEXTURE_2D,null)}}_upload(t,e,r){const{texture:n,singleChannel:s}=e,o=t.getParameter(t.ACTIVE_TEXTURE),a=t.getParameter(t.TEXTURE_BINDING_2D),c=t.getParameter(t.UNPACK_FLIP_Y_WEBGL);t.bindTexture(t.TEXTURE_2D,n),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!0),this._uploadDirtyRect(t,r,s)||(s?t.texImage2D(t.TEXTURE_2D,0,t.R8,t.RED,t.UNSIGNED_BYTE,this.source):t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,this.source)),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,c),t.bindTexture(t.TEXTURE_2D,a),t.activeTexture(o)}_uploadDirtyRect(t,e,r){if(!this.textureSubImage2D||!e)return!1;const[n,s,o,a]=this.rect,c=Math.max(0,Math.floor((e[0]-n)/o*this.source.width)),l=Math.max(0,Math.floor((e[1]-s)/a*this.source.height)),u=Math.min(this.source.width,Math.ceil((e[0]+e[2]-n)/o*this.source.width)),h=Math.min(this.source.height,Math.ceil((e[1]+e[3]-s)/a*this.source.height)),d=u-c,g=h-l;if(d<=0||g<=0)return!0;let p=this._stagingCanvas;(!p||p.width!==d||p.height!==g)&&(p=ht.ENV.createCanvas(d,g,{offscreen:!0}),this._stagingCanvas=p);const v=p&&p.getContext("2d");if(!v)return!1;v.clearRect(0,0,d,g),v.drawImage(this.source,c,l,d,g,0,0,d,g);try{return t.texSubImage2D(t.TEXTURE_2D,0,c,this.source.height-h,r?t.RED:t.RGBA,t.UNSIGNED_BYTE,p),!0}catch{return this.textureSubImage2D=!1,!1}}}qe(Array);var gse=typeof vt=="object"&&vt&&vt.Object===Object&&vt,vy=gse,pse=vy,mse=typeof self=="object"&&self&&self.Object===Object&&self,yse=pse||mse||Function("return this")(),Sr=yse,vse=Sr,Mse=vse.Symbol,qs=Mse,$f=qs,My=Object.prototype,wse=My.hasOwnProperty,Tse=My.toString,cs=$f?$f.toStringTag:void 0;function Sse(i){var t=wse.call(i,cs),e=i[cs];try{i[cs]=void 0;var r=!0}catch{}var n=Tse.call(i);return r&&(t?i[cs]=e:delete i[cs]),n}var Ise=Sse,Cse=Object.prototype,bse=Cse.toString;function xse(i){return bse.call(i)}var Ese=xse,Vf=qs,Ase=Ise,Nse=Ese,Dse="[object Null]",Pse="[object Undefined]",Yf=Vf?Vf.toStringTag:void 0;function kse(i){return i==null?i===void 0?Pse:Dse:Yf&&Yf in Object(i)?Ase(i):Nse(i)}var li=kse;function Lse(i){return i!=null&&typeof i=="object"}var Nr=Lse,Rse=li,Ose=Nr,zse="[object Number]";function jse(i){return typeof i=="number"||Ose(i)&&Rse(i)==zse}var Bse=jse;const It=en(Bse);function Use(){this.__data__=[],this.size=0}var Fse=Use;function Wse(i,t){return i===t||i!==i&&t!==t}var mh=Wse,$se=mh;function Vse(i,t){for(var e=i.length;e--;)if($se(i[e][0],t))return e;return-1}var _a=Vse,Yse=_a,Gse=Array.prototype,Hse=Gse.splice;function Qse(i){var t=this.__data__,e=Yse(t,i);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():Hse.call(t,e,1),--this.size,!0}var Zse=Qse,Kse=_a;function qse(i){var t=this.__data__,e=Kse(t,i);return e<0?void 0:t[e][1]}var Xse=qse,Jse=_a;function _se(i){return Jse(this.__data__,i)>-1}var eoe=_se,toe=_a;function roe(i,t){var e=this.__data__,r=toe(e,i);return r<0?(++this.size,e.push([i,t])):e[r][1]=t,this}var noe=roe,ioe=Fse,soe=Zse,ooe=Xse,aoe=eoe,coe=noe;function Gi(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}Gi.prototype.clear=ioe;Gi.prototype.delete=soe;Gi.prototype.get=ooe;Gi.prototype.has=aoe;Gi.prototype.set=coe;var ec=Gi,loe=ec;function uoe(){this.__data__=new loe,this.size=0}var hoe=uoe;function doe(i){var t=this.__data__,e=t.delete(i);return this.size=t.size,e}var foe=doe;function goe(i){return this.__data__.get(i)}var poe=goe;function moe(i){return this.__data__.has(i)}var yoe=moe;function voe(i){var t=typeof i;return i!=null&&(t=="object"||t=="function")}var En=voe,Moe=li,woe=En,Toe="[object AsyncFunction]",Soe="[object Function]",Ioe="[object GeneratorFunction]",Coe="[object Proxy]";function boe(i){if(!woe(i))return!1;var t=Moe(i);return t==Soe||t==Ioe||t==Toe||t==Coe}var wy=boe,xoe=Sr,Eoe=xoe["__core-js_shared__"],Aoe=Eoe,cl=Aoe,Gf=function(){var i=/[^.]+$/.exec(cl&&cl.keys&&cl.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function Noe(i){return!!Gf&&Gf in i}var Doe=Noe,Poe=Function.prototype,koe=Poe.toString;function Loe(i){if(i!=null){try{return koe.call(i)}catch{}try{return i+""}catch{}}return""}var Ty=Loe,Roe=wy,Ooe=Doe,zoe=En,joe=Ty,Boe=/[\\^$.*+?()[\]{}|]/g,Uoe=/^\[object .+?Constructor\]$/,Foe=Function.prototype,Woe=Object.prototype,$oe=Foe.toString,Voe=Woe.hasOwnProperty,Yoe=RegExp("^"+$oe.call(Voe).replace(Boe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Goe(i){if(!zoe(i)||Ooe(i))return!1;var t=Roe(i)?Yoe:Uoe;return t.test(joe(i))}var Hoe=Goe;function Qoe(i,t){return i==null?void 0:i[t]}var Zoe=Qoe,Koe=Hoe,qoe=Zoe;function Xoe(i,t){var e=qoe(i,t);return Koe(e)?e:void 0}var ui=Xoe,Joe=ui,_oe=Sr,eae=Joe(_oe,"Map"),yh=eae,tae=ui,rae=tae(Object,"create"),tc=rae,Hf=tc;function nae(){this.__data__=Hf?Hf(null):{},this.size=0}var iae=nae;function sae(i){var t=this.has(i)&&delete this.__data__[i];return this.size-=t?1:0,t}var oae=sae,aae=tc,cae="__lodash_hash_undefined__",lae=Object.prototype,uae=lae.hasOwnProperty;function hae(i){var t=this.__data__;if(aae){var e=t[i];return e===cae?void 0:e}return uae.call(t,i)?t[i]:void 0}var dae=hae,fae=tc,gae=Object.prototype,pae=gae.hasOwnProperty;function mae(i){var t=this.__data__;return fae?t[i]!==void 0:pae.call(t,i)}var yae=mae,vae=tc,Mae="__lodash_hash_undefined__";function wae(i,t){var e=this.__data__;return this.size+=this.has(i)?0:1,e[i]=vae&&t===void 0?Mae:t,this}var Tae=wae,Sae=iae,Iae=oae,Cae=dae,bae=yae,xae=Tae;function Hi(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}Hi.prototype.clear=Sae;Hi.prototype.delete=Iae;Hi.prototype.get=Cae;Hi.prototype.has=bae;Hi.prototype.set=xae;var Eae=Hi,Qf=Eae,Aae=ec,Nae=yh;function Dae(){this.size=0,this.__data__={hash:new Qf,map:new(Nae||Aae),string:new Qf}}var Pae=Dae;function kae(i){var t=typeof i;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?i!=="__proto__":i===null}var Lae=kae,Rae=Lae;function Oae(i,t){var e=i.__data__;return Rae(t)?e[typeof t=="string"?"string":"hash"]:e.map}var rc=Oae,zae=rc;function jae(i){var t=zae(this,i).delete(i);return this.size-=t?1:0,t}var Bae=jae,Uae=rc;function Fae(i){return Uae(this,i).get(i)}var Wae=Fae,$ae=rc;function Vae(i){return $ae(this,i).has(i)}var Yae=Vae,Gae=rc;function Hae(i,t){var e=Gae(this,i),r=e.size;return e.set(i,t),this.size+=e.size==r?0:1,this}var Qae=Hae,Zae=Pae,Kae=Bae,qae=Wae,Xae=Yae,Jae=Qae;function Qi(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}Qi.prototype.clear=Zae;Qi.prototype.delete=Kae;Qi.prototype.get=qae;Qi.prototype.has=Xae;Qi.prototype.set=Jae;var Sy=Qi,_ae=ec,ece=yh,tce=Sy,rce=200;function nce(i,t){var e=this.__data__;if(e instanceof _ae){var r=e.__data__;if(!ece||r.length<rce-1)return r.push([i,t]),this.size=++e.size,this;e=this.__data__=new tce(r)}return e.set(i,t),this.size=e.size,this}var ice=nce,sce=ec,oce=hoe,ace=foe,cce=poe,lce=yoe,uce=ice;function Zi(i){var t=this.__data__=new sce(i);this.size=t.size}Zi.prototype.clear=oce;Zi.prototype.delete=ace;Zi.prototype.get=cce;Zi.prototype.has=lce;Zi.prototype.set=uce;var Iy=Zi;function hce(i,t){for(var e=-1,r=i==null?0:i.length;++e<r&&t(i[e],e,i)!==!1;);return i}var dce=hce,fce=ui,gce=function(){try{var i=fce(Object,"defineProperty");return i({},"",{}),i}catch{}}(),Cy=gce,Zf=Cy;function pce(i,t,e){t=="__proto__"&&Zf?Zf(i,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):i[t]=e}var by=pce,mce=by,yce=mh,vce=Object.prototype,Mce=vce.hasOwnProperty;function wce(i,t,e){var r=i[t];(!(Mce.call(i,t)&&yce(r,e))||e===void 0&&!(t in i))&&mce(i,t,e)}var xy=wce,Tce=xy,Sce=by;function Ice(i,t,e,r){var n=!e;e||(e={});for(var s=-1,o=t.length;++s<o;){var a=t[s],c=r?r(e[a],i[a],a,e,i):void 0;c===void 0&&(c=i[a]),n?Sce(e,a,c):Tce(e,a,c)}return e}var nc=Ice;function Cce(i,t){for(var e=-1,r=Array(i);++e<i;)r[e]=t(e);return r}var bce=Cce,xce=li,Ece=Nr,Ace="[object Arguments]";function Nce(i){return Ece(i)&&xce(i)==Ace}var Dce=Nce,Kf=Dce,Pce=Nr,Ey=Object.prototype,kce=Ey.hasOwnProperty,Lce=Ey.propertyIsEnumerable,Rce=Kf(function(){return arguments}())?Kf:function(i){return Pce(i)&&kce.call(i,"callee")&&!Lce.call(i,"callee")},Ay=Rce,Oce=Array.isArray,Xs=Oce,aa={exports:{}};function zce(){return!1}var jce=zce;aa.exports;(function(i,t){var e=Sr,r=jce,n=t&&!t.nodeType&&t,s=n&&!0&&i&&!i.nodeType&&i,o=s&&s.exports===n,a=o?e.Buffer:void 0,c=a?a.isBuffer:void 0,l=c||r;i.exports=l})(aa,aa.exports);var vh=aa.exports,Bce=9007199254740991,Uce=/^(?:0|[1-9]\d*)$/;function Fce(i,t){var e=typeof i;return t=t??Bce,!!t&&(e=="number"||e!="symbol"&&Uce.test(i))&&i>-1&&i%1==0&&i<t}var Wce=Fce,$ce=9007199254740991;function Vce(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=$ce}var Ny=Vce,Yce=li,Gce=Ny,Hce=Nr,Qce="[object Arguments]",Zce="[object Array]",Kce="[object Boolean]",qce="[object Date]",Xce="[object Error]",Jce="[object Function]",_ce="[object Map]",ele="[object Number]",tle="[object Object]",rle="[object RegExp]",nle="[object Set]",ile="[object String]",sle="[object WeakMap]",ole="[object ArrayBuffer]",ale="[object DataView]",cle="[object Float32Array]",lle="[object Float64Array]",ule="[object Int8Array]",hle="[object Int16Array]",dle="[object Int32Array]",fle="[object Uint8Array]",gle="[object Uint8ClampedArray]",ple="[object Uint16Array]",mle="[object Uint32Array]",at={};at[cle]=at[lle]=at[ule]=at[hle]=at[dle]=at[fle]=at[gle]=at[ple]=at[mle]=!0;at[Qce]=at[Zce]=at[ole]=at[Kce]=at[ale]=at[qce]=at[Xce]=at[Jce]=at[_ce]=at[ele]=at[tle]=at[rle]=at[nle]=at[ile]=at[sle]=!1;function yle(i){return Hce(i)&&Gce(i.length)&&!!at[Yce(i)]}var vle=yle;function Mle(i){return function(t){return i(t)}}var ic=Mle,ca={exports:{}};ca.exports;(function(i,t){var e=vy,r=t&&!t.nodeType&&t,n=r&&!0&&i&&!i.nodeType&&i,s=n&&n.exports===r,o=s&&e.process,a=function(){try{var c=n&&n.require&&n.require("util").types;return c||o&&o.binding&&o.binding("util")}catch{}}();i.exports=a})(ca,ca.exports);var Mh=ca.exports,wle=vle,Tle=ic,qf=Mh,Xf=qf&&qf.isTypedArray,Sle=Xf?Tle(Xf):wle,Dy=Sle,Ile=bce,Cle=Ay,ble=Xs,xle=vh,Ele=Wce,Ale=Dy,Nle=Object.prototype,Dle=Nle.hasOwnProperty;function Ple(i,t){var e=ble(i),r=!e&&Cle(i),n=!e&&!r&&xle(i),s=!e&&!r&&!n&&Ale(i),o=e||r||n||s,a=o?Ile(i.length,String):[],c=a.length;for(var l in i)(t||Dle.call(i,l))&&!(o&&(l=="length"||n&&(l=="offset"||l=="parent")||s&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||Ele(l,c)))&&a.push(l);return a}var Py=Ple,kle=Object.prototype;function Lle(i){var t=i&&i.constructor,e=typeof t=="function"&&t.prototype||kle;return i===e}var wh=Lle;function Rle(i,t){return function(e){return i(t(e))}}var ky=Rle,Ole=ky,zle=Ole(Object.keys,Object),jle=zle,Ble=wh,Ule=jle,Fle=Object.prototype,Wle=Fle.hasOwnProperty;function $le(i){if(!Ble(i))return Ule(i);var t=[];for(var e in Object(i))Wle.call(i,e)&&e!="constructor"&&t.push(e);return t}var Vle=$le,Yle=wy,Gle=Ny;function Hle(i){return i!=null&&Gle(i.length)&&!Yle(i)}var Th=Hle,Qle=Py,Zle=Vle,Kle=Th;function qle(i){return Kle(i)?Qle(i):Zle(i)}var Sh=qle,Xle=nc,Jle=Sh;function _le(i,t){return i&&Xle(t,Jle(t),i)}var eue=_le;function tue(i){var t=[];if(i!=null)for(var e in Object(i))t.push(e);return t}var rue=tue,nue=En,iue=wh,sue=rue,oue=Object.prototype,aue=oue.hasOwnProperty;function cue(i){if(!nue(i))return sue(i);var t=iue(i),e=[];for(var r in i)r=="constructor"&&(t||!aue.call(i,r))||e.push(r);return e}var lue=cue,uue=Py,hue=lue,due=Th;function fue(i){return due(i)?uue(i,!0):hue(i)}var Ih=fue,gue=nc,pue=Ih;function mue(i,t){return i&&gue(t,pue(t),i)}var yue=mue,la={exports:{}};la.exports;(function(i,t){var e=Sr,r=t&&!t.nodeType&&t,n=r&&!0&&i&&!i.nodeType&&i,s=n&&n.exports===r,o=s?e.Buffer:void 0,a=o?o.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}i.exports=c})(la,la.exports);var vue=la.exports;function Mue(i,t){var e=-1,r=i.length;for(t||(t=Array(r));++e<r;)t[e]=i[e];return t}var wue=Mue;function Tue(i,t){for(var e=-1,r=i==null?0:i.length,n=0,s=[];++e<r;){var o=i[e];t(o,e,i)&&(s[n++]=o)}return s}var Ly=Tue;function Sue(){return[]}var Ry=Sue,Iue=Ly,Cue=Ry,bue=Object.prototype,xue=bue.propertyIsEnumerable,Jf=Object.getOwnPropertySymbols,Eue=Jf?function(i){return i==null?[]:(i=Object(i),Iue(Jf(i),function(t){return xue.call(i,t)}))}:Cue,Ch=Eue,Aue=nc,Nue=Ch;function Due(i,t){return Aue(i,Nue(i),t)}var Pue=Due;function kue(i,t){for(var e=-1,r=t.length,n=i.length;++e<r;)i[n+e]=t[e];return i}var bh=kue,Lue=ky,Rue=Lue(Object.getPrototypeOf,Object),Oy=Rue,Oue=bh,zue=Oy,jue=Ch,Bue=Ry,Uue=Object.getOwnPropertySymbols,Fue=Uue?function(i){for(var t=[];i;)Oue(t,jue(i)),i=zue(i);return t}:Bue,zy=Fue,Wue=nc,$ue=zy;function Vue(i,t){return Wue(i,$ue(i),t)}var Yue=Vue,Gue=bh,Hue=Xs;function Que(i,t,e){var r=t(i);return Hue(i)?r:Gue(r,e(i))}var jy=Que,Zue=jy,Kue=Ch,que=Sh;function Xue(i){return Zue(i,que,Kue)}var By=Xue,Jue=jy,_ue=zy,ehe=Ih;function the(i){return Jue(i,ehe,_ue)}var rhe=the,nhe=ui,ihe=Sr,she=nhe(ihe,"DataView"),ohe=she,ahe=ui,che=Sr,lhe=ahe(che,"Promise"),uhe=lhe,hhe=ui,dhe=Sr,fhe=hhe(dhe,"Set"),Uy=fhe,ghe=ui,phe=Sr,mhe=ghe(phe,"WeakMap"),yhe=mhe,Xl=ohe,Jl=yh,_l=uhe,eu=Uy,tu=yhe,Fy=li,Ki=Ty,_f="[object Map]",vhe="[object Object]",eg="[object Promise]",tg="[object Set]",rg="[object WeakMap]",ng="[object DataView]",Mhe=Ki(Xl),whe=Ki(Jl),The=Ki(_l),She=Ki(eu),Ihe=Ki(tu),Un=Fy;(Xl&&Un(new Xl(new ArrayBuffer(1)))!=ng||Jl&&Un(new Jl)!=_f||_l&&Un(_l.resolve())!=eg||eu&&Un(new eu)!=tg||tu&&Un(new tu)!=rg)&&(Un=function(i){var t=Fy(i),e=t==vhe?i.constructor:void 0,r=e?Ki(e):"";if(r)switch(r){case Mhe:return ng;case whe:return _f;case The:return eg;case She:return tg;case Ihe:return rg}return t});var sc=Un,Che=Object.prototype,bhe=Che.hasOwnProperty;function xhe(i){var t=i.length,e=new i.constructor(t);return t&&typeof i[0]=="string"&&bhe.call(i,"index")&&(e.index=i.index,e.input=i.input),e}var Ehe=xhe,Ahe=Sr,Nhe=Ahe.Uint8Array,Wy=Nhe,ig=Wy;function Dhe(i){var t=new i.constructor(i.byteLength);return new ig(t).set(new ig(i)),t}var xh=Dhe,Phe=xh;function khe(i,t){var e=t?Phe(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.byteLength)}var Lhe=khe,Rhe=/\w*$/;function Ohe(i){var t=new i.constructor(i.source,Rhe.exec(i));return t.lastIndex=i.lastIndex,t}var zhe=Ohe,sg=qs,og=sg?sg.prototype:void 0,ag=og?og.valueOf:void 0;function jhe(i){return ag?Object(ag.call(i)):{}}var Bhe=jhe,Uhe=xh;function Fhe(i,t){var e=t?Uhe(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.length)}var Whe=Fhe,$he=xh,Vhe=Lhe,Yhe=zhe,Ghe=Bhe,Hhe=Whe,Qhe="[object Boolean]",Zhe="[object Date]",Khe="[object Map]",qhe="[object Number]",Xhe="[object RegExp]",Jhe="[object Set]",_he="[object String]",ede="[object Symbol]",tde="[object ArrayBuffer]",rde="[object DataView]",nde="[object Float32Array]",ide="[object Float64Array]",sde="[object Int8Array]",ode="[object Int16Array]",ade="[object Int32Array]",cde="[object Uint8Array]",lde="[object Uint8ClampedArray]",ude="[object Uint16Array]",hde="[object Uint32Array]";function dde(i,t,e){var r=i.constructor;switch(t){case tde:return $he(i);case Qhe:case Zhe:return new r(+i);case rde:return Vhe(i,e);case nde:case ide:case sde:case ode:case ade:case cde:case lde:case ude:case hde:return Hhe(i,e);case Khe:return new r;case qhe:case _he:return new r(i);case Xhe:return Yhe(i);case Jhe:return new r;case ede:return Ghe(i)}}var fde=dde,gde=En,cg=Object.create,pde=function(){function i(){}return function(t){if(!gde(t))return{};if(cg)return cg(t);i.prototype=t;var e=new i;return i.prototype=void 0,e}}(),mde=pde,yde=mde,vde=Oy,Mde=wh;function wde(i){return typeof i.constructor=="function"&&!Mde(i)?yde(vde(i)):{}}var Tde=wde,Sde=sc,Ide=Nr,Cde="[object Map]";function bde(i){return Ide(i)&&Sde(i)==Cde}var xde=bde,Ede=xde,Ade=ic,lg=Mh,ug=lg&&lg.isMap,Nde=ug?Ade(ug):Ede,Dde=Nde,Pde=sc,kde=Nr,Lde="[object Set]";function Rde(i){return kde(i)&&Pde(i)==Lde}var Ode=Rde,zde=Ode,jde=ic,hg=Mh,dg=hg&&hg.isSet,Bde=dg?jde(dg):zde,$y=Bde;const Ude=en($y);var Fde=Iy,Wde=dce,$de=xy,Vde=eue,Yde=yue,Gde=vue,Hde=wue,Qde=Pue,Zde=Yue,Kde=By,qde=rhe,Xde=sc,Jde=Ehe,_de=fde,efe=Tde,tfe=Xs,rfe=vh,nfe=Dde,ife=En,sfe=$y,ofe=Sh,afe=Ih,cfe=1,lfe=2,ufe=4,Vy="[object Arguments]",hfe="[object Array]",dfe="[object Boolean]",ffe="[object Date]",gfe="[object Error]",Yy="[object Function]",pfe="[object GeneratorFunction]",mfe="[object Map]",yfe="[object Number]",Gy="[object Object]",vfe="[object RegExp]",Mfe="[object Set]",wfe="[object String]",Tfe="[object Symbol]",Sfe="[object WeakMap]",Ife="[object ArrayBuffer]",Cfe="[object DataView]",bfe="[object Float32Array]",xfe="[object Float64Array]",Efe="[object Int8Array]",Afe="[object Int16Array]",Nfe="[object Int32Array]",Dfe="[object Uint8Array]",Pfe="[object Uint8ClampedArray]",kfe="[object Uint16Array]",Lfe="[object Uint32Array]",it={};it[Vy]=it[hfe]=it[Ife]=it[Cfe]=it[dfe]=it[ffe]=it[bfe]=it[xfe]=it[Efe]=it[Afe]=it[Nfe]=it[mfe]=it[yfe]=it[Gy]=it[vfe]=it[Mfe]=it[wfe]=it[Tfe]=it[Dfe]=it[Pfe]=it[kfe]=it[Lfe]=!0;it[gfe]=it[Yy]=it[Sfe]=!1;function qo(i,t,e,r,n,s){var o,a=t&cfe,c=t&lfe,l=t&ufe;if(e&&(o=n?e(i,r,n,s):e(i)),o!==void 0)return o;if(!ife(i))return i;var u=tfe(i);if(u){if(o=Jde(i),!a)return Hde(i,o)}else{var h=Xde(i),d=h==Yy||h==pfe;if(rfe(i))return Gde(i,a);if(h==Gy||h==Vy||d&&!n){if(o=c||d?{}:efe(i),!a)return c?Zde(i,Yde(o,i)):Qde(i,Vde(o,i))}else{if(!it[h])return n?i:{};o=_de(i,h,a)}}s||(s=new Fde);var g=s.get(i);if(g)return g;s.set(i,o),sfe(i)?i.forEach(function(I){o.add(qo(I,t,e,I,i,s))}):nfe(i)&&i.forEach(function(I,D){o.set(D,qo(I,t,e,D,i,s))});var p=l?c?qde:Kde:c?afe:ofe,v=u?void 0:p(i);return Wde(v||i,function(I,D){v&&(D=I,I=i[D]),$de(o,D,qo(I,t,e,D,i,s))}),o}var Rfe=qo,Ofe=Rfe,zfe=1,jfe=4;function Bfe(i){return Ofe(i,zfe|jfe)}var Ufe=Bfe;const Lt=en(Ufe),Ffe={maxRetries:3,timeoutMs:15e3,retryIntervalMs:1e3};function Eh(i){const t={...Ffe,...i};if(t.maxRetries!==Number.POSITIVE_INFINITY&&t.maxRetries!==-1&&(!Number.isInteger(t.maxRetries)||t.maxRetries<0||t.maxRetries>10))throw new RangeError("backgroundImageLoadOptions.maxRetries must be -1, Infinity, or an integer from 0 to 10");if(!Number.isFinite(t.timeoutMs)||t.timeoutMs<1e3||t.timeoutMs>12e4)throw new RangeError("backgroundImageLoadOptions.timeoutMs must be from 1000 to 120000");if(!Number.isFinite(t.retryIntervalMs)||t.retryIntervalMs<0||t.retryIntervalMs>3e4)throw new RangeError("backgroundImageLoadOptions.retryIntervalMs must be from 0 to 30000");return t}class Wfe{constructor(t,e){R(this,"tasks",new Map);R(this,"failedTasks",new Map);R(this,"options");R(this,"queue",[]);R(this,"activeAttempts",0);R(this,"maxActiveAttempts",4);this.onEvent=e,this.options=Eh(t)}load(t){const e=this.keyOf(t);if(this.cancel(e),this.failedTasks.delete(e),!t.isActive())return Promise.resolve();const r={...t,key:e,attempt:0,generation:0,settled:!1};return this.tasks.set(e,r),this.enqueue(r),Promise.resolve()}cancelByViewScene(t,e){for(const r of this.tasks.values())r.viewId===t&&(!e||r.scenePath===e)&&this.cancel(r.key);for(const[r,n]of this.failedTasks)n.viewId===t&&(!e||n.scenePath===e)&&this.failedTasks.delete(r)}cancelResource(t,e,r){const n=this.keyOf({viewId:t,scenePath:e,resourceId:r});this.cancel(n),this.failedTasks.delete(n)}cancelAll(){for(const t of[...this.tasks.keys()])this.cancel(t);this.failedTasks.clear()}reload(t){var s;if(t.source!=="appliance")return{accepted:!1,reloadedCount:0,reason:"resourceNotFound"};const e=[...this.failedTasks.values()].filter(o=>o.viewId===t.viewId&&o.scenePath===t.scenePath);if(!e.length)return{accepted:!1,reloadedCount:0,reason:[...this.tasks.values()].some(a=>a.viewId===t.viewId&&a.scenePath===t.scenePath)?"alreadyLoading":"resourceNotFound"};const r=e.filter(o=>o.isActive());if(!r.length)return{accepted:!1,reloadedCount:0,reason:"sceneNotFocused"};let n=0;for(const o of r)this.failedTasks.delete(this.keyOf(o)),t.url&&((s=o.onReloadUrl)==null||s.call(o,t.url)),this.load(t.url?{...o,src:t.url}:o),n+=1;return{accepted:!0,reloadedCount:n}}keyOf(t){return`${t.viewId}\0${t.scenePath}\0${t.resourceId}`}async attempt(t){if(!this.canRun(t)){this.cancel(t.key);return}t.attempt+=1;const e=++t.generation;try{if(await this.loadImage(t,e),!this.canRun(t)||t.generation!==e)return;t.settled=!0,this.tasks.delete(t.key),this.emit(t,"success")}catch{if(!this.canRun(t)||t.generation!==e)return;if(this.options.maxRetries===-1||this.options.maxRetries===Number.POSITIVE_INFINITY||t.attempt<=this.options.maxRetries){const r=Math.floor(Math.random()*Math.min(100,this.options.retryIntervalMs));t.timer=setTimeout(()=>{t.timer=void 0,this.enqueue(t)},this.options.retryIntervalMs+r)}else t.settled=!0,this.tasks.delete(t.key),this.failedTasks.set(t.key,{viewId:t.viewId,scenePath:t.scenePath,resourceId:t.resourceId,src:t.src,image:t.image,isActive:t.isActive,onReloadUrl:t.onReloadUrl}),this.emit(t,"failed")}}enqueue(t){!this.canRun(t)||this.queue.includes(t)||(this.queue.push(t),this.drain())}drain(){for(;this.activeAttempts<this.maxActiveAttempts&&this.queue.length;){const t=this.queue.shift();this.canRun(t)&&(this.activeAttempts+=1,this.attempt(t).finally(()=>{this.activeAttempts-=1,this.drain()}))}}loadImage(t,e){return new Promise((r,n)=>{const s=t.image,o=()=>{t.timer&&(clearTimeout(t.timer),t.timer=void 0),s.onload=null,s.onerror=null,t.cancelAttempt=void 0};s.dataset.netlessBackgroundImageManaged="true",s.onload=()=>{o(),r()},s.onerror=()=>{o(),n(new Error("background image load failed"))},t.timer=setTimeout(()=>{o(),s.removeAttribute("src");const a=new Error("background image load timed out");a.name="TimeoutError",n(a)},this.options.timeoutMs),t.cancelAttempt=()=>{o(),n(new Error("background image load cancelled"))},t.generation===e&&(s.src=t.src)})}canRun(t){return!t.settled&&this.tasks.get(t.key)===t&&t.isActive()}cancel(t){var r;const e=this.tasks.get(t);!e||e.settled||(e.settled=!0,e.generation+=1,(r=e.cancelAttempt)==null||r.call(e),e.timer&&(clearTimeout(e.timer),e.timer=void 0),e.image.onload=null,e.image.onerror=null,e.image.removeAttribute("src"),this.tasks.delete(t),this.emit(e,"cancelled"))}emit(t,e){var r;try{(r=this.onEvent)==null||r.call(this,{name:"backgroundImageLoad",state:e,source:"appliance",resourceId:t.resourceId,resourceUrl:t.src,viewId:t.viewId,scenePath:t.scenePath})}catch(n){console.error("[backgroundImage] onBackgroundImageLoadEvent callback failed",n)}}}const $fe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAYAAADFeBvrAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAYISURBVHgB7ZpNSCtXFIBPEuvz+dMGpYUKD/sWFX+Qti6kK7Hqpm6e9q0rIoIUFUShPLV10VZx4+JZqa9v20LBhdq9fyBUCtKNPH8qYl2IOw3G38Rkek4y15y5uTOZJDOWggcOSSYzN/ebc+45554JwIM8iBCPyTEP+86T4vyMfsRN4b+nQTKIJp0vzuGvlpID7os8EQNEIBD4oKio6Bm9DwaDv/v9/n/076JgbtWUYPchwrW8qD7UnOvr6wFNkpubm+/wu7f0c7y6mrnlvQufxB0Iau7V1dX3BDA/P6/V1dVpzc3N2uLiIofK1c8VYHys/wRKBUN3/hGHqaysNOjc3FwMis6hc0FtLTHuvYLxCCZgci8uLn4wg5Gh6Fy8Jk+/NkcCAlAAuUkoW4g0B+d5tLS05O/r67O8eGxsDNra2uDy8nKsoKCAwCIQDxQa0yTxgrvCYXyTk5Ml+Orf2dlJeeHIyAigFSE/P38ELfUNqNdSkjgF5FF89jL1TU1NlQwODl5gZPujp6cHWltbUw7Koc7Pz8mkZpHPFeFrJuZeqLnoMoPoZqe0JjDP/IZgnyLUG/o8NDRkuo5Ua2pjY6MC4oFCFf1cA0oKzRSOp6enRfTaGh0d/QxBt+1CUVgnOTs7+xrHfQzGyOcKkK3QTJMnQffZ6e/v/xwttmsHqqmpKXbdycnJCxy7ABLh3FEgVZ6hZJhnFZoFFMF0d3c/w7v+dyookXBnZ2c/xvHfhriVcvXfdBRItsxjnOhYqjwjoAimq6vrCysoGofk+Ph4Esd/F/UdiFtJAGUd2DygTpp5dmBUUJ2dnc9VUALm8PDwJY7/BPU9VD8k3M4RC6kskxZMKigKIMLN9vf3p3H8DyWgfEhEOwOQD9IXOTz7EObbwsLC4YWFBRgeHrY9ECXYo6MjaGlpKWlsbPxkYGDgRW1tbSEWquVlZWXBzc3Nl1VVVa8hXiXc6ioqBqGaPDk7AACJTRZ3NS9lcUp86cJwoSQ7Pj4Op6enfxUXF3/V0NCQv7q6GsCvwrqGUG/01xAD4+VQTOxaSF43d5bBOisrGBJRCtXX17+/trb268rKSgASFgmz97KFkmo6OztWuVyPweiWGc4WRkhFRQVEIpHg8vJyQAIQVlLBROVxvBYQHsXnO8tk62ZcyN0wecLBwcEvYHSzEPscBqOLCRhLC4n9uqaA8UAWAcAKhtbQ3t7eTHl5+Y9gtAp3twhT056CDMQ7MRzIFTeTYKb1yYYVQFH9VdzsqNmYKpfTJBDX3Ixgdnd3XyHMT2AMALJlBBSPaMpNngrIsTyTCgaj288YDGakictrxizvKFNOjgSSBLS+vv6UYHDb7DgMVgsChjTEgCIKGG4ZU+EWkgNBzN1qamq+pAMTExPgFMzW1tZrhHkFyWE5KxgSszx0527RaDRmOSpRshEOU11dPQPG8CwHARHJlMnTSrwSRFIlfXt7m3V5ngJGuJtqzaQtZkFBVNJezN5ZAdmwjKo2k9tVtrcI3OXk4tPgcg7ChCDZ1URgMOu72Xa5VFHOkymQhWVU60YVmjN6wiC7k6p+S1syCACOwJBYFaexV+yhBekNPsMBO6KAEeE4BMaCU67RsoYhSbXgaT//ht709vZCaWmp6YkEbLFmVJWzas04+iBL7EKpm0J7duqu0B7+CTUpNJuyvb1NCfMj1CqI9wLKUOlOUMeG+gGFkHii4HizUF4z/KFUrPsJ8WbEIyx7nnZ0dDynME6BAuce09iFHo+GrnmGltltb2//E4wVAN82y7vOjKOZXSBhJdHNiT3TYWD8OY2PTUJkdd7MkJMnT5wZVQF2RFX6yBMUdzPMvvfqxz3sXHF+GNT9ANXit/10O1sgHkZvdQAOKvs9B5L7ARELGAAXLSTvM8QExTE+YbHe+HURhZp1aRyF4CJXClbbWwGketgkW9VsY+YaiBCVhfgE+XvxRwgZSM4jUVCDZFQ9pytmXR8hUTB2gnidx4XffVWydN0yQjwmx/jkAZJBrIBI5J7ZvQGZWUgVSuU/EqmOAzicKNMVu816DdRWUV1/7xAP8n+SfwF3Du3NF2sYhwAAAABJRU5ErkJggg==",Vfe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAYAAADFeBvrAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAgrSURBVHgB7ZprTBRXFIDP7gIt8lQppTwE5V0KaAn6o1pqNGkDDTEmTUhsgKRp+gNJw68CFkLbVC2QkDS+gD8KJdWmARvbFBNNWpuIRGPFWBXQRMPDqIki+KLATs+ZnTvcvXtnX8w2beJJToaduTP3fHPOPffcOwC8kP+2WCDwIvahGFxTuN8KmNSZmULPNjLeqF9F8rdPkIEGEn+r+vjx46LQ0NA8/Dsader58+e/h4WFDWntFO7ot6fMFAt3JLWi2lCDpqamCux2+2+KROj82NhYGrXT2lu5Z/DP/deFByElA4Pv3LlTiHY/nJ6eVnbv3q1s2bJFyc7OVrZu3arU1dUp4+PjxPUQoT+g9tp9PkMFgpo9kxljHRoaWp2Xl3duYmIiurKyEvDoclNCQgIcPnxYPc7MzHwcGRnZhaft4Ag7O9fUbRhaITCie4lgcnNzT7qDIaHz27dvh+vXr0NEREQneqoCHKFnAR+8ZCaQGGq2CxcurCGYycnJZHcwTNAzUFFRoUJFRUV1IFQ5OKBsXB9uxSwgl0TQ3d29Yt26dccwoyVXV1d7hGEiQmGi2AzOUHx/hob4K2yuYS9G987s7OwPISEh7xPM6dOnwVfBsIMjR45AZmbmo5s3b76Xnp7+J55egMVxBSAZT0v1ED+76yn66dOnLQSzd+9ev2BIyFP0MjBco1JTU/sxfFeDazp3cYgZHmKqdoaGNISHh9fv378fSJcqlPV6e3sBJ+I/goOD34VFL0k95Y+HxPHCYGxmw5DQ2NuzZw8EBQVtunXr1jvgwUP+hhz/QDXMMCNVE8zx48dNg2FCz6QQjI2N/RA8VBFmANnu3btXihnpG8pM9fX1EAi5du0aeWkVOAMBCF7yN+R0z4yOjq6NiYlpp9CgdBtIwXpPH6vgDKWLt0CygtM6MDCwBuUYZSKaOCksAiVY9wFOBePgDOOytPAGSKzNVCCC2bBhw69YdK7ypgpYimzbtk2dl7CM+hFcveOUHDylbTFO1YdhFbByx44dA1QFUP0VSJj4+Hjo6+sDq9U6iEmHKvFZTedQ50GYbN15SITVlwNlZWUnLRZL8s6dOwMOQ9UCTtKTra2ttdppt9V2kMF5cbmsjxuM43bMNrmUzc6fP6+GQiDGDoOJi4ubwb4qm5ubafyIE6nLxGqTPEsGo1cBOGNX0TyDYafC0CyOaxcVziyh53Z2dkJycvLMvn37PmpoaBgFR4jxYSbWdVIgI89Iq4CjR48CZjlYv369+tssqI6ODsjPz4f+/v668vLycxrEHHfkYdwC8SB6mGEV8Cl64cuuri5oa2tTG+EyGjZu3AiXLl1qefDgwV8lJSUFZkDV1tZCcXExXLx4sbWoqKgPFj0zx8GI9ZwO5W4M6ekZYeqpaqbqmaSqqkpNpcPDw4dwzfM9nrLduHEjEs+X0XV/Sx96LnqE1kLtBQUF3eDwCO8dGQyzV5rl+JyuegfXI29jRotiRlKnpFghHMzKyjqotVXS0tLacKPjF3bdHxjSq1evduAkepAD+ZsDYlC8V5w8ZBVg+PPq2MGMlkInqE4joTf45MmT4YyMjAPcA+ltLSQlJX2BafxnX6HI29QeK44TOTk57mCYZ0QoJ8OBM4yB6dkNkwGlSygsLFQvYtYB3BTMxFL+M+0eFgZqp4mJiU2+QKGX1fGIk/QIrn0aYXGsyDxjmAyMhO2jhaCGoUbX1NSkLSwsPMJqV8Fspu6lIZS6OYhjiOLwdU7fQM1HfRPD7wS1obZ0j0xpb4726Z49ezaJf2/S7s9ATUGNR41BjdJseRnke3WGwhrRTS9pD1mOGoeG15BxOOfoxuCkp0Ih6NeaEaSZGlieJyiCoc1FgsGldokGk8nBvAKOrWIGQ5uPsm0tt0BWDiicAaGuGhkZ+YqMw9StGzU4OKhCnT179hNsswY1FTXdE5QEJhc1S3tGogazXLOBwQSBl3tzIhQPtAL1VQJCTcNx8y1vHIUghSKFZE9PT7H2dlM1b+Wgrr1y5Uq77J75+fnplpaWMg2ch4nlYEI5z7hdensDpI4hrYNErcMMXJ32koG4ztf3pultz83NjWG99Ra2WQ0OL2VjZjwgeufUqVOqV8+cOdPIwdBLSNJeHg8TAh5WqJ6EfSmgt7IMNRJ1JThiOlnrOAMHshprmMKdoGSCpb9s3B3SYLIFGIqICJB7xisYi+RvfiypXw40DWGdlJaWRmMd141hk8V2OWm7ieYTXhBc3+BgaZyqAISjOYxSMVvXsBTNlzdiNQDgRao2AtK3pjggpmrqbGpqSsLPIN/dv38/gaBwUjTshMHcvn27JyUlpRmc5xpPMD599LIYnLNyUKKndKjGxsakXbt2deMCLIE8IVvs0YRM1fjdu3d/wrXN5+BcnzEgvor2uN3rjzAYMp5lPEoQlE5fA0fWo8GfhlCbKVFQ1pKNIfzcOHH58mWqaimVUwJI0+6n59D4pIlzmdZPMPiZzXjDjX47Le5g0Uu8x2zgPqWyKpjVe7x3+AUbq9NYjQbgp2dsBud5o8TP7d5kHAWcQchQfoEmLgn8HjOiBIF7o5hI1x6CEbLNP3bdqYAF44JzyWLzcN1i8DcT/o3awbm8Fz3DAy2A62INwPV/E3wWdx5inmBHuwChCBD6R2JwHge80TIQRQLjt7e8DTkGZgfX8cUMZTDAteFDkveaIlzjX9ySQs8X18r2t2VHUURPKoICmDR+eCO9aSdmOIub3/w9RgpgUpiJhvraXpa6jZKHGEqyusw0GLFzX+5RhN/8kYnMSNMMfyH/V/kHST6OYVElTPAAAAAASUVORK5CYII=",Yfe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADEAAAAxCAYAAABznEEcAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAZoSURBVHgB7VlLSCRXFL3ljNEhEXTGhMQJmOjCz8ZNVLKICz9xIYhCNi7UgINkGEk2En8hW5cBUQNxo05GAoKikuCAmvGzGMdPcCUGjDPxD/4Vv/3JvWW97luvq7ur+hMZ8MKlqrteNfe8e965970GuLVbC5kpJr53+hjHx9yY3TUxJgLMAQG4ITARfp5T4Mri4uL9q6urnxwOxz/oY5eXl1/Pzs7e195X2FX4jZsIhAK7gx5ps9m6nGj9/f3OtbU1pzAE0318fPwVjYHrrN7R3AjU/wpOBwA9Cmf/9ejoqDMtLU31iooKGdA+ATo4OMiXAEWAHhBAGEApXj4rPAik0vPt7e0vCgoKPH4gMzMTSktLIS8vD2JiYgABvcHMTZyennbHxsaOg3udOJmLzwqEYB0ZgRCZENm4u7e39yQuLq65srISZmZmvP5Ybm4u5OfnQ0lJyXWUCAgzNLS+vt6SnJz8WgvYwV5xSlcRgyVg3ha2Dkxzc3MvfZmVlQW+bGxsDBobGyE7O1u94uJPjIqKqklKSvrbbrfPnp+ff7e8vJwMnlSTKWfJjDKhywJo6wLp0YcZ+dyIUr7s4cOHLsrRlQwBTSBFuzc2NiZYhjjVAIyzZBqEwgCQv0OOM/gNzuiP/ijlDxBRjgClpqa6AF1cXDydmpoaLCws3JcAGYHyC4JMzoKaibKysvienp6FtrY2IA/WCFB5ebkqCHSvARo8Ozt7igIxwIJ2gJ+seFMnDoIyEUV+dHT0G3qWVUr5M043DdAB0m2IKZwAYpgZX+qkywR6NFbuR0iDxmAoZRUQKRxSLTMnJ8eIaqqSeVMnIYUOdu+sq6vrp4f+VCoYo8khZaNs01VRlERUu2/BrWAA7sl2Anink1Ao18JGjyY/PDx8hq1GZqgp5c2mp6chMjLy2b179x7hRzvoqeUUwXIzqq4O5nZsNUaEbIbLqPLTou/s7FTvT05OpsA9sXJG1AVsZDwjutqBIN6gUlWjxod8XRBNKXgsrqpqYZfwEqX9h8TExD7wbFm8LmzxHQ0QHSlXKZVSqFC/hkqlaKapTaGgCQTK7PHW1lb/wsLC86KiokkccoV+qV1tcE0pO7AWxmhTxBszDzqRr66ujqanp2cRpQLNBgUsCh8BwQ54bn5+/s+mpqa+4eHhfS1gb52vwuP0trPjhSZCBtLQ0NA3MDDQQIFYAUHBYhuvzjpVbJr1lZWVP3p7e19UVVXNgHumXYrI4uBx6Yqevz02b0FcRQ8CoBQF3dXVpQLZ3d39C7n+ora29vfJyclDYFnWgFyxK3cxhss/+KoT/N6DVkQpKypFGUCp3Ozo6HgSHx//GLW/BwHsg57zl5pzADajwLn52mPL1ZHPloMoRYPMFL6EhAR18e7s7MxVV1fPsAAp4Avteq7dC/c1+wKI4g+EfGzDM+EYHBw8RDrNiA2QL6upqVGvKJ2/gHu2L1nA5wwEB2YDfSYMO1x/px0cgEc2zBY+eo67u6H29vZ/wU2VC8l58JxKNjDOgojNEp08aFVfX++3l6JMEdDx8fEB0FNIBsDXBc8ArwuW1EkeI1RKdLWmCx+1DhkZGRvR0dFfSsHKxYtnW0iqvJAN9xNm6MR/QO5sfapUSkqKmqW5ubmfwVgyZdpw/vPZl2kUEAinBMSUStG+gwra0NDQSynQKyloIxnlewafjDFLJzLRBJqiFMnqyMgIbG5uDuD996Dnv8iAPOMAPmbcm5lVJwA/vZRMKZGZlpaWVtAvUL4GZMqE1fjRJrUd76LHoX+InlhcXPwZnWW2tra6jjrpiBM3UK/weQr6J+gfodMh9HtwncG7YLA3CMSsLmxx5WuDCt8B7vZeicInTjCWlpb6wc15mfey7oc9E8LElpVmMgb9AXoC+qcTExOPKRu4NlTHs6Q10GfhgfYOvRsJQZ76BWMKuDtaolQs+gfoH6Mn436gDg+e+5BKXUQx/C5Je/a+NpbeiQJPKgUdlNXx/BCBKxVdxW5Q0I3XBqFKRhU4KLtjYawi3csuTKdc4FnIXNvKUJkVEGRG20QZAAUpA5DbaYAQLmQzfzxyk/ffdnCD4NWVnGdE7kQBQvQHC5lVEDxgMaM29lkxGCNLKrDnIbFAMkFmBIaDkHstU41coGZ1TZD5UjReCGUAYbNgdNqoXZB/T67yYbFAMiGML3BhYeH8rb0t9h/zgcTBcTNGiQAAAABJRU5ErkJggg==",Gfe="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4%202.5V19L8.5%2014.5L11.5%2021L14.5%2019.5L11.5%2013H18L4%202.5Z'%20fill='%23212324'%20stroke='white'%20stroke-width='1.5'%20stroke-linejoin='round'/%3e%3c/svg%3e",Hfe="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20width='26px'%20height='26px'%20viewBox='7%207%2026%2026'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3c!--%20Generator:%20Sketch%2060.1%20(88133)%20-%20https://sketch.com%20--%3e%3ctitle%3eshape-cursor%3c/title%3e%3cdesc%3eCreated%20with%20Sketch.%3c/desc%3e%3cdefs%3e%3cpath%20d='M20,21.5%20C20.2454599,21.5%2020.4496084,21.6768752%2020.4919443,21.9101244%20L20.5,22%20L20.5,27%20C20.5,27.2761424%2020.2761424,27.5%2020,27.5%20C19.7545401,27.5%2019.5503916,27.3231248%2019.5080557,27.0898756%20L19.5,27%20L19.5,22%20C19.5,21.7238576%2019.7238576,21.5%2020,21.5%20Z%20M27,19.5%20C27.2761424,19.5%2027.5,19.7238576%2027.5,20%20C27.5,20.2454599%2027.3231248,20.4496084%2027.0898756,20.4919443%20L27,20.5%20L22,20.5%20C21.7238576,20.5%2021.5,20.2761424%2021.5,20%20C21.5,19.7545401%2021.6768752,19.5503916%2021.9101244,19.5080557%20L22,19.5%20L27,19.5%20Z%20M18,19.5%20C18.2761424,19.5%2018.5,19.7238576%2018.5,20%20C18.5,20.2454599%2018.3231248,20.4496084%2018.0898756,20.4919443%20L18,20.5%20L13,20.5%20C12.7238576,20.5%2012.5,20.2761424%2012.5,20%20C12.5,19.7545401%2012.6768752,19.5503916%2012.9101244,19.5080557%20L13,19.5%20L18,19.5%20Z%20M20,12.5%20C20.2454599,12.5%2020.4496084,12.6768752%2020.4919443,12.9101244%20L20.5,13%20L20.5,18%20C20.5,18.2761424%2020.2761424,18.5%2020,18.5%20C19.7545401,18.5%2019.5503916,18.3231248%2019.5080557,18.0898756%20L19.5,18%20L19.5,13%20C19.5,12.7238576%2019.7238576,12.5%2020,12.5%20Z'%20id='path-1'%3e%3c/path%3e%3cfilter%20x='-64.6%25'%20y='-59.5%25'%20width='229.3%25'%20height='246.1%25'%20filterUnits='objectBoundingBox'%20id='filter-2'%3e%3cfeMorphology%20radius='1'%20operator='dilate'%20in='SourceAlpha'%20result='shadowSpreadOuter1'%3e%3c/feMorphology%3e%3cfeOffset%20dx='0'%20dy='2'%20in='shadowSpreadOuter1'%20result='shadowOffsetOuter1'%3e%3c/feOffset%3e%3cfeGaussianBlur%20stdDeviation='3'%20in='shadowOffsetOuter1'%20result='shadowBlurOuter1'%3e%3c/feGaussianBlur%3e%3cfeComposite%20in='shadowBlurOuter1'%20in2='SourceAlpha'%20operator='out'%20result='shadowBlurOuter1'%3e%3c/feComposite%3e%3cfeColorMatrix%20values='0%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200.16%200'%20type='matrix'%20in='shadowBlurOuter1'%3e%3c/feColorMatrix%3e%3c/filter%3e%3c/defs%3e%3cg%20id='页面-4'%20stroke='none'%20stroke-width='1'%20fill='none'%20fill-rule='evenodd'%3e%3cg%20id='Whiteboard-Guidelines'%20transform='translate(-344.000000,%20-751.000000)'%3e%3cg%20id='shape-cursor'%20transform='translate(344.000000,%20751.000000)'%3e%3crect%20id='矩形备份-44'%20fill='%23FFFFFF'%20opacity='0.01'%20x='0'%20y='0'%20width='40'%20height='40'%20rx='2'%3e%3c/rect%3e%3cg%20id='形状结合'%20fill-rule='nonzero'%3e%3cuse%20fill='black'%20fill-opacity='1'%20filter='url(%23filter-2)'%20xlink:href='%23path-1'%3e%3c/use%3e%3cpath%20stroke='%23FFFFFF'%20stroke-width='1'%20d='M20,21%20C20.4854103,21%2020.898085,21.3479993%2020.9899479,21.8654877%20L21,22%20L21,27%20C21,27.5522847%2020.5522847,28%2020,28%20C19.5145897,28%2019.101915,27.6520007%2019.0100521,27.1345123%20L19,27%20L19,22%20C19,21.4477153%2019.4477153,21%2020,21%20Z%20M27,19%20C27.5522847,19%2028,19.4477153%2028,20%20C28,20.4854103%2027.6520007,20.898085%2027.1345123,20.9899479%20L27,21%20L22,21%20C21.4477153,21%2021,20.5522847%2021,20%20C21,19.5145897%2021.3479993,19.101915%2021.8654877,19.0100521%20L22,19%20L27,19%20Z%20M18,19%20C18.5522847,19%2019,19.4477153%2019,20%20C19,20.4854103%2018.6520007,20.898085%2018.1345123,20.9899479%20L18,21%20L13,21%20C12.4477153,21%2012,20.5522847%2012,20%20C12,19.5145897%2012.3479993,19.101915%2012.8654877,19.0100521%20L13,19%20L18,19%20Z%20M20,12%20C20.4854103,12%2020.898085,12.3479993%2020.9899479,12.8654877%20L21,13%20L21,18%20C21,18.5522847%2020.5522847,19%2020,19%20C19.5145897,19%2019.101915,18.6520007%2019.0100521,18.1345123%20L19,18%20L19,13%20C19,12.4477153%2019.4477153,12%2020,12%20Z'%20fill='%23212324'%20fill-rule='evenodd'%3e%3c/path%3e%3c/g%3e%3crect%20id='矩形'%20fill='%23FFFFFF'%20x='18.5'%20y='17'%20width='3'%20height='6'%3e%3c/rect%3e%3crect%20id='矩形'%20fill='%23FFFFFF'%20x='17'%20y='18.5'%20width='6'%20height='3'%3e%3c/rect%3e%3cpath%20d='M20,21.5%20C20.2454599,21.5%2020.4496084,21.6768752%2020.4919443,21.9101244%20L20.5,22%20L20.5,27%20C20.5,27.2761424%2020.2761424,27.5%2020,27.5%20C19.7545401,27.5%2019.5503916,27.3231248%2019.5080557,27.0898756%20L19.5,27%20L19.5,22%20C19.5,21.7238576%2019.7238576,21.5%2020,21.5%20Z%20M27,19.5%20C27.2761424,19.5%2027.5,19.7238576%2027.5,20%20C27.5,20.2454599%2027.3231248,20.4496084%2027.0898756,20.4919443%20L27,20.5%20L22,20.5%20C21.7238576,20.5%2021.5,20.2761424%2021.5,20%20C21.5,19.7545401%2021.6768752,19.5503916%2021.9101244,19.5080557%20L22,19.5%20L27,19.5%20Z%20M18,19.5%20C18.2761424,19.5%2018.5,19.7238576%2018.5,20%20C18.5,20.2454599%2018.3231248,20.4496084%2018.0898756,20.4919443%20L18,20.5%20L13,20.5%20C12.7238576,20.5%2012.5,20.2761424%2012.5,20%20C12.5,19.7545401%2012.6768752,19.5503916%2012.9101244,19.5080557%20L13,19.5%20L18,19.5%20Z%20M20,12.5%20C20.2454599,12.5%2020.4496084,12.6768752%2020.4919443,12.9101244%20L20.5,13%20L20.5,18%20C20.5,18.2761424%2020.2761424,18.5%2020,18.5%20C19.7545401,18.5%2019.5503916,18.3231248%2019.5080557,18.0898756%20L19.5,18%20L19.5,13%20C19.5,12.7238576%2019.7238576,12.5%2020,12.5%20Z'%20id='形状结合'%20fill='%23212324'%20fill-rule='nonzero'%3e%3c/path%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e",Qfe="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20width='26px'%20height='26px'%20viewBox='7%207%2026%2026'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3c!--%20Generator:%20Sketch%2060.1%20(88133)%20-%20https://sketch.com%20--%3e%3ctitle%3etext-cursor%3c/title%3e%3cdesc%3eCreated%20with%20Sketch.%3c/desc%3e%3cdefs%3e%3cpath%20d='M16,26.5%20C15.7238576,26.5%2015.5,26.2761424%2015.5,26%20C15.5,25.7545401%2015.6768752,25.5503916%2015.9101244,25.5080557%20L16,25.5%20L19.5,25.5%20L19.5,14.5%20L16,14.5%20C15.7238576,14.5%2015.5,14.2761424%2015.5,14%20C15.5,13.7545401%2015.6768752,13.5503916%2015.9101244,13.5080557%20L16,13.5%20L24,13.5%20C24.2761424,13.5%2024.5,13.7238576%2024.5,14%20C24.5,14.2454599%2024.3231248,14.4496084%2024.0898756,14.4919443%20L24,14.5%20L20.5,14.5%20L20.5,25.5%20L24,25.5%20C24.2761424,25.5%2024.5,25.7238576%2024.5,26%20C24.5,26.2454599%2024.3231248,26.4496084%2024.0898756,26.4919443%20L24,26.5%20L16,26.5%20Z'%20id='path-1'%3e%3c/path%3e%3cfilter%20x='-284.0%25'%20y='-81.5%25'%20width='668.1%25'%20height='293.9%25'%20filterUnits='objectBoundingBox'%20id='filter-2'%3e%3cfeMorphology%20radius='1'%20operator='dilate'%20in='SourceAlpha'%20result='shadowSpreadOuter1'%3e%3c/feMorphology%3e%3cfeOffset%20dx='0'%20dy='2'%20in='shadowSpreadOuter1'%20result='shadowOffsetOuter1'%3e%3c/feOffset%3e%3cfeGaussianBlur%20stdDeviation='3'%20in='shadowOffsetOuter1'%20result='shadowBlurOuter1'%3e%3c/feGaussianBlur%3e%3cfeComposite%20in='shadowBlurOuter1'%20in2='SourceAlpha'%20operator='out'%20result='shadowBlurOuter1'%3e%3c/feComposite%3e%3cfeColorMatrix%20values='0%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200.16%200'%20type='matrix'%20in='shadowBlurOuter1'%3e%3c/feColorMatrix%3e%3c/filter%3e%3c/defs%3e%3cg%20id='页面-4'%20stroke='none'%20stroke-width='1'%20fill='none'%20fill-rule='evenodd'%3e%3cg%20id='Whiteboard-Guidelines'%20transform='translate(-388.000000,%20-672.000000)'%3e%3cg%20id='text-cursor'%20transform='translate(392.000000,%20672.000000)'%3e%3crect%20id='矩形备份-40'%20fill='%23FFFFFF'%20opacity='0.01'%20x='0'%20y='0'%20width='40'%20height='40'%20rx='2'%3e%3c/rect%3e%3cg%20id='形状结合'%20fill-rule='nonzero'%3e%3cuse%20fill='black'%20fill-opacity='1'%20filter='url(%23filter-2)'%20xlink:href='%23path-1'%3e%3c/use%3e%3cpath%20stroke='%23FFFFFF'%20stroke-width='1'%20d='M19,25%20L19,15%20L16,15%20C15.4477153,15%2015,14.5522847%2015,14%20C15,13.5145897%2015.3479993,13.101915%2015.8654877,13.0100521%20L16,13%20L24,13%20C24.5522847,13%2025,13.4477153%2025,14%20C25,14.4854103%2024.6520007,14.898085%2024.1345123,14.9899479%20L24,15%20L21,15%20L21,25%20L24,25%20C24.5522847,25%2025,25.4477153%2025,26%20C25,26.4854103%2024.6520007,26.898085%2024.1345123,26.9899479%20L24,27%20L16,27%20C15.4477153,27%2015,26.5522847%2015,26%20C15,25.5145897%2015.3479993,25.101915%2015.8654877,25.0100521%20L16,25%20L19,25%20Z'%20fill='%23212324'%20fill-rule='evenodd'%3e%3c/path%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e",Cr=Object.freeze([12,14,18,24,36,48,64,80,144,288]),wi=["top","topLeft","topRight","bottom","bottomLeft","bottomRight","left","leftTop","leftBottom","right","rightTop","rightBottom"],ls=new Map([["selector","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAYAAADE6YVjAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAKeSURBVHgB3VTLi1JhFD86zlQ4ysxSXAy1GWYZzMxmYAhHagRB/QN8FLqPFq4FIQhXkS6kTQ4t2ilIKEWgSS0SmVpIm0BdaBJSaOP78XU+PXey6+saburAD+73uL/feX0H4H81GQdj7D7ilrCGFRonk3c6nXvhcJiFQiGWy+Xy/X7/WbPZ1K1KkBOsl0qlO36/n+3t7Q1hs9kYF+WC3W73MTpxc1lBmej7KuJaoVDInZ6eqsWXDw4OwGKxwPHx8Se1Wn1Wr9cjW1tbOTxi9D9bJCJHXEFslsvlR263+246nYZZptPpQK/Xg8lkSvZ6vbNGo5EgQRCLiSPhIqpoNHobo3keCARgkalUKjg5ORlGuL+/n8T6PVAqlefjYmKRdYQSsZ3P5z8aDAYVLGFarRbi8fhbhUKhx2VPEJGP3eEbfTrs4MUwr4EU49FYrVbweDy1SqXyipy95FaI7g8QXS6SyWReHx4e2ubVBc+HtTk6OjqvVqtvvF7vi0gkUiSByyyJ21BGwpswJ2Vmsxlw/0Kj0bxMJBJJl8vFPWkhGogLQoeyMhEJo2jGUzYRjcPh+Op0Oq2pVOoHkXE0SahF/w+E+3KYNEaX2pSyiSiKxeJTFPiGyyriO6FKEUgSESLp4ht4bzQaf4pFYrHYO/ysEXGNyJtjKRqM/zNNhFuf0B7vst3dXdjZ2Yn4fL4vRFwn8jaMGqYPU179LBEGf3bZcNNutwPOtScwKnCLPJ9KLMWEh7mNuIFdVsNXzbBNP+D6Ou1vwAqm8hqMWlmbzWYf4mz6HAwGzbjWwGgqrEklmucJT+UGCfG3wiPjueeNwGvB0zkAid7OMmF8CyOck/I6NJcR4KZYcM6J2vCbUGhvyQIA0gonzCEZkQud9Fcd9W/bL57cJu3lkjuNAAAAAElFTkSuQmCC"],["pencil","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAYAAACpSkzOAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAJ2SURBVHgB7ZXPqxJRFMfvjI4F+cqkTcrjge9B+B+0LJQ27lq4ijZprly6DaF1COKPjYRrVy0CF/aof6Baa6ChOPkLFcdMm1+dM93RafzxZuptgnfgC3ecO+dzz497JOTKNsZMp9OAoihvZFku4xp/I5dsbL/fP221Wl/D4bCKwnWn0znDd+SSDE/N6ZBgMKjJBNuKzC4dHTgQ5PF4bququn7R7XZJPB4/kSTpHcBOiQlmJ6cMpCvAcdz5ZDJhF4tF1u12v4jFYkc8z683+f1+Uq1W38K+x/AogVQ7ETF4SnB+Ho1GTxKJxDFC2u32q1KpJPh8vvVGjHK5XM4xahv+tYgRcranJrNarfay2WwKoVBIRTUajW42m70P390EOYmFrOEGdhfECEMIwur1Og+p5VOp1CP47piCOB3EXBBJAIuLRcZi7zKsSaVSEbxe70N4FEEL0AyE6VuBZEJD2wmyAkHDmoxGIwGW36ljBP2gUEXf5/wXCDZBsVjky+XyUwpCyBL0k0ai7gNp3WUVUigUvgHoWSaTaRoi2YJojk1r52q1eh2JRJ5YgUB3Pc/n83WyXRPV/A1rWrtgSAZsQL6Q3ynTI1F2QdCMqXNQEGsDMqMgrMt6ChwCaXcGYdBFjA3InELkQxBCtkcEI4riHyPFCMnlcnEKMbYzQhRi0TCKa6A76XT6wWAweD8ejz8Oh8PPcEc+9Xq9D8lkMgLv74Hugo5ALmJzlumG4+IG6BZ1dJ06wtPqN14gmza2FYljD1SljrCTsAaYpjnZFP7CmpADEel/ai4qffLiqSUKFSlEP8xfgYwwlmzyr1KYHoUtgBU4Y9D/Y78AxCeE/aWoyrkAAAAASUVORK5CYII="],["eraser","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAYAAACpSkzOAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAANKSURBVHgB1VTdS5NhFD/7iuXa8KNw7SK/IjBYo13soqvEITENtj9AwZiCOCTvQrNWF9rFFPGLrC1iF10Oiy68mBSUF2KB4YabhKKyTfFCc+3Lzb2ds72LsfbxCkZ04Mf7Puc5z/k95+M5AP+R8OAvCW9nZ6cyHo8/SSaTc4RQKKQ+S0JyxFtbW6va39//ZjKZmMbGRkar1TJOp5MhYtwXwBkQkgMROnyXIcmGw+FgYrHY00JkQm4cqYPCaDQ6ZrFY7i4sLPxhMDg4SJ8hTOOWRCJ5jf8npyUiEgE6eGy1Wk12u72gIZHJZDLr4eHhVnl5+YdsslL5pH1+JBIx22y2h9PT01BKpFIpLC4ufhKJRFpcxhEM6fmlSMLh8P35+XlOJCTBYBC2t7dr8fdctv+iRHjI4HK5LAMDA8BVFAoFyOVyH/6KIKsxCtVIgC188+Dg4CV2GJxGpqamYHR09AHklEWQY5d6K/gg67HD3huNRrlKpYLNzU3gIsPDw8Dn84fa29s/4zIK6Rol8xIhSUMikXB2dXXV4AHo6en5KhaLFcvLy0VJent7QaPRzKrV6le4DCEi2UTCnGgE1dXVj3Q6XY1er08drKiosK2urnbjnrFQQxBJU1PTC3y4kyxJGHEMWe2dTUSNIcLZVXl0dAStra3BiYmJOTqgVCqfu91uull3LhlFjbZv6urqiCTIElHaEsC2dq4QqXRlZeUePsrUDFtfX/eZzebbqL+GuIFks1js32OHRtHu7u5H3FMiahFViPNQYuZRO8oQVzY2NibJocFgYAKBgLuzs/M66hsQKuzELx0dHak9rKe3paXlFurrERdZEiGUGARkcAFxmSJAJ/aRkRGGnOKwdPn9/rG9vT0HXaC5uZnxer3+vr4+HdpeRVxClBWLJFuZqhF7gAjL0PGz8fFxvcfjSY0WevVUv5mZmQDWyog1/I52PyBdlxgUqUu+qMSQznVtW1ubBlP3dmlpicnA5/N5+vv770C6bhS9lEu6eHnWFP45NioJS5xxRLdNsrenKH5CusNOWH1BEeTRMTnI6MgZpYYeYhhOmS5eEX0mMhELPktGoBd/zCWSUkTAOs4QZqZ8JsokS8Kp8KWICtlwdv5P5BchBHaEIRURoQAAAABJRU5ErkJggg=="],["text","data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iNDdweCIgaGVpZ2h0PSI0MHB4IiB2aWV3Qm94PSIwIDAgNDcgNDAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICA8IS0tIEdlbmVyYXRvcjogU2tldGNoIDYwLjEgKDg4MTMzKSAtIGh0dHBzOi8vc2tldGNoLmNvbSAtLT4KICAgIDx0aXRsZT50ZXh0LWN1cnNvcjwvdGl0bGU+CiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4KICAgIDxkZWZzPgogICAgICAgIDxwYXRoIGQ9Ik0xNiwyNi41IEMxNS43MjM4NTc2LDI2LjUgMTUuNSwyNi4yNzYxNDI0IDE1LjUsMjYgQzE1LjUsMjUuNzU0NTQwMSAxNS42NzY4NzUyLDI1LjU1MDM5MTYgMTUuOTEwMTI0NCwyNS41MDgwNTU3IEwxNiwyNS41IEwxOS41LDI1LjUgTDE5LjUsMTQuNSBMMTYsMTQuNSBDMTUuNzIzODU3NiwxNC41IDE1LjUsMTQuMjc2MTQyNCAxNS41LDE0IEMxNS41LDEzLjc1NDU0MDEgMTUuNjc2ODc1MiwxMy41NTAzOTE2IDE1LjkxMDEyNDQsMTMuNTA4MDU1NyBMMTYsMTMuNSBMMjQsMTMuNSBDMjQuMjc2MTQyNCwxMy41IDI0LjUsMTMuNzIzODU3NiAyNC41LDE0IEMyNC41LDE0LjI0NTQ1OTkgMjQuMzIzMTI0OCwxNC40NDk2MDg0IDI0LjA4OTg3NTYsMTQuNDkxOTQ0MyBMMjQsMTQuNSBMMjAuNSwxNC41IEwyMC41LDI1LjUgTDI0LDI1LjUgQzI0LjI3NjE0MjQsMjUuNSAyNC41LDI1LjcyMzg1NzYgMjQuNSwyNiBDMjQuNSwyNi4yNDU0NTk5IDI0LjMyMzEyNDgsMjYuNDQ5NjA4NCAyNC4wODk4NzU2LDI2LjQ5MTk0NDMgTDI0LDI2LjUgTDE2LDI2LjUgWiIgaWQ9InBhdGgtMSI+PC9wYXRoPgogICAgICAgIDxmaWx0ZXIgeD0iLTI4NC4wJSIgeT0iLTgxLjUlIiB3aWR0aD0iNjY4LjElIiBoZWlnaHQ9IjI5My45JSIgZmlsdGVyVW5pdHM9Im9iamVjdEJvdW5kaW5nQm94IiBpZD0iZmlsdGVyLTIiPgogICAgICAgICAgICA8ZmVNb3JwaG9sb2d5IHJhZGl1cz0iMSIgb3BlcmF0b3I9ImRpbGF0ZSIgaW49IlNvdXJjZUFscGhhIiByZXN1bHQ9InNoYWRvd1NwcmVhZE91dGVyMSI+PC9mZU1vcnBob2xvZ3k+CiAgICAgICAgICAgIDxmZU9mZnNldCBkeD0iMCIgZHk9IjIiIGluPSJzaGFkb3dTcHJlYWRPdXRlcjEiIHJlc3VsdD0ic2hhZG93T2Zmc2V0T3V0ZXIxIj48L2ZlT2Zmc2V0PgogICAgICAgICAgICA8ZmVHYXVzc2lhbkJsdXIgc3RkRGV2aWF0aW9uPSIzIiBpbj0ic2hhZG93T2Zmc2V0T3V0ZXIxIiByZXN1bHQ9InNoYWRvd0JsdXJPdXRlcjEiPjwvZmVHYXVzc2lhbkJsdXI+CiAgICAgICAgICAgIDxmZUNvbXBvc2l0ZSBpbj0ic2hhZG93Qmx1ck91dGVyMSIgaW4yPSJTb3VyY2VBbHBoYSIgb3BlcmF0b3I9Im91dCIgcmVzdWx0PSJzaGFkb3dCbHVyT3V0ZXIxIj48L2ZlQ29tcG9zaXRlPgogICAgICAgICAgICA8ZmVDb2xvck1hdHJpeCB2YWx1ZXM9IjAgMCAwIDAgMCAgIDAgMCAwIDAgMCAgIDAgMCAwIDAgMCAgMCAwIDAgMC4xNiAwIiB0eXBlPSJtYXRyaXgiIGluPSJzaGFkb3dCbHVyT3V0ZXIxIj48L2ZlQ29sb3JNYXRyaXg+CiAgICAgICAgPC9maWx0ZXI+CiAgICA8L2RlZnM+CiAgICA8ZyBpZD0i6aG16Z2iLTQiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxnIGlkPSJXaGl0ZWJvYXJkLUd1aWRlbGluZXMiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0zODguMDAwMDAwLCAtNjcyLjAwMDAwMCkiPgogICAgICAgICAgICA8ZyBpZD0idGV4dC1jdXJzb3IiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDM5Mi4wMDAwMDAsIDY3Mi4wMDAwMDApIj4KICAgICAgICAgICAgICAgIDxyZWN0IGlkPSLnn6nlvaLlpIfku70tNDAiIGZpbGw9IiNGRkZGRkYiIG9wYWNpdHk9IjAuMDEiIHg9IjAiIHk9IjAiIHdpZHRoPSI0MCIgaGVpZ2h0PSI0MCIgcng9IjIiPjwvcmVjdD4KICAgICAgICAgICAgICAgIDxnIGlkPSLlvaLnirbnu5PlkIgiIGZpbGwtcnVsZT0ibm9uemVybyI+CiAgICAgICAgICAgICAgICAgICAgPHVzZSBmaWxsPSJibGFjayIgZmlsbC1vcGFjaXR5PSIxIiBmaWx0ZXI9InVybCgjZmlsdGVyLTIpIiB4bGluazpocmVmPSIjcGF0aC0xIj48L3VzZT4KICAgICAgICAgICAgICAgICAgICA8cGF0aCBzdHJva2U9IiNGRkZGRkYiIHN0cm9rZS13aWR0aD0iMSIgZD0iTTE5LDI1IEwxOSwxNSBMMTYsMTUgQzE1LjQ0NzcxNTMsMTUgMTUsMTQuNTUyMjg0NyAxNSwxNCBDMTUsMTMuNTE0NTg5NyAxNS4zNDc5OTkzLDEzLjEwMTkxNSAxNS44NjU0ODc3LDEzLjAxMDA1MjEgTDE2LDEzIEwyNCwxMyBDMjQuNTUyMjg0NywxMyAyNSwxMy40NDc3MTUzIDI1LDE0IEMyNSwxNC40ODU0MTAzIDI0LjY1MjAwMDcsMTQuODk4MDg1IDI0LjEzNDUxMjMsMTQuOTg5OTQ3OSBMMjQsMTUgTDIxLDE1IEwyMSwyNSBMMjQsMjUgQzI0LjU1MjI4NDcsMjUgMjUsMjUuNDQ3NzE1MyAyNSwyNiBDMjUsMjYuNDg1NDEwMyAyNC42NTIwMDA3LDI2Ljg5ODA4NSAyNC4xMzQ1MTIzLDI2Ljk4OTk0NzkgTDI0LDI3IEwxNiwyNyBDMTUuNDQ3NzE1MywyNyAxNSwyNi41NTIyODQ3IDE1LDI2IEMxNSwyNS41MTQ1ODk3IDE1LjM0Nzk5OTMsMjUuMTAxOTE1IDE1Ljg2NTQ4NzcsMjUuMDEwMDUyMSBMMTYsMjUgTDE5LDI1IFoiIGZpbGw9IiMyMTIzMjQiIGZpbGwtcnVsZT0iZXZlbm9kZCI+PC9wYXRoPgogICAgICAgICAgICAgICAgPC9nPgogICAgICAgICAgICA8L2c+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4="],["shape","data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iNDBweCIgaGVpZ2h0PSI0MHB4IiB2aWV3Qm94PSIwIDAgNDAgNDAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICA8IS0tIEdlbmVyYXRvcjogU2tldGNoIDYwLjEgKDg4MTMzKSAtIGh0dHBzOi8vc2tldGNoLmNvbSAtLT4KICAgIDx0aXRsZT5zaGFwZS1jdXJzb3I8L3RpdGxlPgogICAgPGRlc2M+Q3JlYXRlZCB3aXRoIFNrZXRjaC48L2Rlc2M+CiAgICA8ZGVmcz4KICAgICAgICA8cGF0aCBkPSJNMjAsMjEuNSBDMjAuMjQ1NDU5OSwyMS41IDIwLjQ0OTYwODQsMjEuNjc2ODc1MiAyMC40OTE5NDQzLDIxLjkxMDEyNDQgTDIwLjUsMjIgTDIwLjUsMjcgQzIwLjUsMjcuMjc2MTQyNCAyMC4yNzYxNDI0LDI3LjUgMjAsMjcuNSBDMTkuNzU0NTQwMSwyNy41IDE5LjU1MDM5MTYsMjcuMzIzMTI0OCAxOS41MDgwNTU3LDI3LjA4OTg3NTYgTDE5LjUsMjcgTDE5LjUsMjIgQzE5LjUsMjEuNzIzODU3NiAxOS43MjM4NTc2LDIxLjUgMjAsMjEuNSBaIE0yNywxOS41IEMyNy4yNzYxNDI0LDE5LjUgMjcuNSwxOS43MjM4NTc2IDI3LjUsMjAgQzI3LjUsMjAuMjQ1NDU5OSAyNy4zMjMxMjQ4LDIwLjQ0OTYwODQgMjcuMDg5ODc1NiwyMC40OTE5NDQzIEwyNywyMC41IEwyMiwyMC41IEMyMS43MjM4NTc2LDIwLjUgMjEuNSwyMC4yNzYxNDI0IDIxLjUsMjAgQzIxLjUsMTkuNzU0NTQwMSAyMS42NzY4NzUyLDE5LjU1MDM5MTYgMjEuOTEwMTI0NCwxOS41MDgwNTU3IEwyMiwxOS41IEwyNywxOS41IFogTTE4LDE5LjUgQzE4LjI3NjE0MjQsMTkuNSAxOC41LDE5LjcyMzg1NzYgMTguNSwyMCBDMTguNSwyMC4yNDU0NTk5IDE4LjMyMzEyNDgsMjAuNDQ5NjA4NCAxOC4wODk4NzU2LDIwLjQ5MTk0NDMgTDE4LDIwLjUgTDEzLDIwLjUgQzEyLjcyMzg1NzYsMjAuNSAxMi41LDIwLjI3NjE0MjQgMTIuNSwyMCBDMTIuNSwxOS43NTQ1NDAxIDEyLjY3Njg3NTIsMTkuNTUwMzkxNiAxMi45MTAxMjQ0LDE5LjUwODA1NTcgTDEzLDE5LjUgTDE4LDE5LjUgWiBNMjAsMTIuNSBDMjAuMjQ1NDU5OSwxMi41IDIwLjQ0OTYwODQsMTIuNjc2ODc1MiAyMC40OTE5NDQzLDEyLjkxMDEyNDQgTDIwLjUsMTMgTDIwLjUsMTggQzIwLjUsMTguMjc2MTQyNCAyMC4yNzYxNDI0LDE4LjUgMjAsMTguNSBDMTkuNzU0NTQwMSwxOC41IDE5LjU1MDM5MTYsMTguMzIzMTI0OCAxOS41MDgwNTU3LDE4LjA4OTg3NTYgTDE5LjUsMTggTDE5LjUsMTMgQzE5LjUsMTIuNzIzODU3NiAxOS43MjM4NTc2LDEyLjUgMjAsMTIuNSBaIiBpZD0icGF0aC0xIj48L3BhdGg+CiAgICAgICAgPGZpbHRlciB4PSItNjQuNiUiIHk9Ii01OS41JSIgd2lkdGg9IjIyOS4zJSIgaGVpZ2h0PSIyNDYuMSUiIGZpbHRlclVuaXRzPSJvYmplY3RCb3VuZGluZ0JveCIgaWQ9ImZpbHRlci0yIj4KICAgICAgICAgICAgPGZlTW9ycGhvbG9neSByYWRpdXM9IjEiIG9wZXJhdG9yPSJkaWxhdGUiIGluPSJTb3VyY2VBbHBoYSIgcmVzdWx0PSJzaGFkb3dTcHJlYWRPdXRlcjEiPjwvZmVNb3JwaG9sb2d5PgogICAgICAgICAgICA8ZmVPZmZzZXQgZHg9IjAiIGR5PSIyIiBpbj0ic2hhZG93U3ByZWFkT3V0ZXIxIiByZXN1bHQ9InNoYWRvd09mZnNldE91dGVyMSI+PC9mZU9mZnNldD4KICAgICAgICAgICAgPGZlR2F1c3NpYW5CbHVyIHN0ZERldmlhdGlvbj0iMyIgaW49InNoYWRvd09mZnNldE91dGVyMSIgcmVzdWx0PSJzaGFkb3dCbHVyT3V0ZXIxIj48L2ZlR2F1c3NpYW5CbHVyPgogICAgICAgICAgICA8ZmVDb21wb3NpdGUgaW49InNoYWRvd0JsdXJPdXRlcjEiIGluMj0iU291cmNlQWxwaGEiIG9wZXJhdG9yPSJvdXQiIHJlc3VsdD0ic2hhZG93Qmx1ck91dGVyMSI+PC9mZUNvbXBvc2l0ZT4KICAgICAgICAgICAgPGZlQ29sb3JNYXRyaXggdmFsdWVzPSIwIDAgMCAwIDAgICAwIDAgMCAwIDAgICAwIDAgMCAwIDAgIDAgMCAwIDAuMTYgMCIgdHlwZT0ibWF0cml4IiBpbj0ic2hhZG93Qmx1ck91dGVyMSI+PC9mZUNvbG9yTWF0cml4PgogICAgICAgIDwvZmlsdGVyPgogICAgPC9kZWZzPgogICAgPGcgaWQ9Iumhtemdoi00IiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj4KICAgICAgICA8ZyBpZD0iV2hpdGVib2FyZC1HdWlkZWxpbmVzIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgtMzQ0LjAwMDAwMCwgLTc1MS4wMDAwMDApIj4KICAgICAgICAgICAgPGcgaWQ9InNoYXBlLWN1cnNvciIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMzQ0LjAwMDAwMCwgNzUxLjAwMDAwMCkiPgogICAgICAgICAgICAgICAgPHJlY3QgaWQ9IuefqeW9ouWkh+S7vS00NCIgZmlsbD0iI0ZGRkZGRiIgb3BhY2l0eT0iMC4wMSIgeD0iMCIgeT0iMCIgd2lkdGg9IjQwIiBoZWlnaHQ9IjQwIiByeD0iMiI+PC9yZWN0PgogICAgICAgICAgICAgICAgPGcgaWQ9IuW9oueKtue7k+WQiCIgZmlsbC1ydWxlPSJub256ZXJvIj4KICAgICAgICAgICAgICAgICAgICA8dXNlIGZpbGw9ImJsYWNrIiBmaWxsLW9wYWNpdHk9IjEiIGZpbHRlcj0idXJsKCNmaWx0ZXItMikiIHhsaW5rOmhyZWY9IiNwYXRoLTEiPjwvdXNlPgogICAgICAgICAgICAgICAgICAgIDxwYXRoIHN0cm9rZT0iI0ZGRkZGRiIgc3Ryb2tlLXdpZHRoPSIxIiBkPSJNMjAsMjEgQzIwLjQ4NTQxMDMsMjEgMjAuODk4MDg1LDIxLjM0Nzk5OTMgMjAuOTg5OTQ3OSwyMS44NjU0ODc3IEwyMSwyMiBMMjEsMjcgQzIxLDI3LjU1MjI4NDcgMjAuNTUyMjg0NywyOCAyMCwyOCBDMTkuNTE0NTg5NywyOCAxOS4xMDE5MTUsMjcuNjUyMDAwNyAxOS4wMTAwNTIxLDI3LjEzNDUxMjMgTDE5LDI3IEwxOSwyMiBDMTksMjEuNDQ3NzE1MyAxOS40NDc3MTUzLDIxIDIwLDIxIFogTTI3LDE5IEMyNy41NTIyODQ3LDE5IDI4LDE5LjQ0NzcxNTMgMjgsMjAgQzI4LDIwLjQ4NTQxMDMgMjcuNjUyMDAwNywyMC44OTgwODUgMjcuMTM0NTEyMywyMC45ODk5NDc5IEwyNywyMSBMMjIsMjEgQzIxLjQ0NzcxNTMsMjEgMjEsMjAuNTUyMjg0NyAyMSwyMCBDMjEsMTkuNTE0NTg5NyAyMS4zNDc5OTkzLDE5LjEwMTkxNSAyMS44NjU0ODc3LDE5LjAxMDA1MjEgTDIyLDE5IEwyNywxOSBaIE0xOCwxOSBDMTguNTUyMjg0NywxOSAxOSwxOS40NDc3MTUzIDE5LDIwIEMxOSwyMC40ODU0MTAzIDE4LjY1MjAwMDcsMjAuODk4MDg1IDE4LjEzNDUxMjMsMjAuOTg5OTQ3OSBMMTgsMjEgTDEzLDIxIEMxMi40NDc3MTUzLDIxIDEyLDIwLjU1MjI4NDcgMTIsMjAgQzEyLDE5LjUxNDU4OTcgMTIuMzQ3OTk5MywxOS4xMDE5MTUgMTIuODY1NDg3NywxOS4wMTAwNTIxIEwxMywxOSBMMTgsMTkgWiBNMjAsMTIgQzIwLjQ4NTQxMDMsMTIgMjAuODk4MDg1LDEyLjM0Nzk5OTMgMjAuOTg5OTQ3OSwxMi44NjU0ODc3IEwyMSwxMyBMMjEsMTggQzIxLDE4LjU1MjI4NDcgMjAuNTUyMjg0NywxOSAyMCwxOSBDMTkuNTE0NTg5NywxOSAxOS4xMDE5MTUsMTguNjUyMDAwNyAxOS4wMTAwNTIxLDE4LjEzNDUxMjMgTDE5LDE4IEwxOSwxMyBDMTksMTIuNDQ3NzE1MyAxOS40NDc3MTUzLDEyIDIwLDEyIFoiIGZpbGw9IiMyMTIzMjQiIGZpbGwtcnVsZT0iZXZlbm9kZCI+PC9wYXRoPgogICAgICAgICAgICAgICAgPC9nPgogICAgICAgICAgICAgICAgPHJlY3QgaWQ9IuefqeW9oiIgZmlsbD0iI0ZGRkZGRiIgeD0iMTguNSIgeT0iMTciIHdpZHRoPSIzIiBoZWlnaHQ9IjYiPjwvcmVjdD4KICAgICAgICAgICAgICAgIDxyZWN0IGlkPSLnn6nlvaIiIGZpbGw9IiNGRkZGRkYiIHg9IjE3IiB5PSIxOC41IiB3aWR0aD0iNiIgaGVpZ2h0PSIzIj48L3JlY3Q+CiAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMjAsMjEuNSBDMjAuMjQ1NDU5OSwyMS41IDIwLjQ0OTYwODQsMjEuNjc2ODc1MiAyMC40OTE5NDQzLDIxLjkxMDEyNDQgTDIwLjUsMjIgTDIwLjUsMjcgQzIwLjUsMjcuMjc2MTQyNCAyMC4yNzYxNDI0LDI3LjUgMjAsMjcuNSBDMTkuNzU0NTQwMSwyNy41IDE5LjU1MDM5MTYsMjcuMzIzMTI0OCAxOS41MDgwNTU3LDI3LjA4OTg3NTYgTDE5LjUsMjcgTDE5LjUsMjIgQzE5LjUsMjEuNzIzODU3NiAxOS43MjM4NTc2LDIxLjUgMjAsMjEuNSBaIE0yNywxOS41IEMyNy4yNzYxNDI0LDE5LjUgMjcuNSwxOS43MjM4NTc2IDI3LjUsMjAgQzI3LjUsMjAuMjQ1NDU5OSAyNy4zMjMxMjQ4LDIwLjQ0OTYwODQgMjcuMDg5ODc1NiwyMC40OTE5NDQzIEwyNywyMC41IEwyMiwyMC41IEMyMS43MjM4NTc2LDIwLjUgMjEuNSwyMC4yNzYxNDI0IDIxLjUsMjAgQzIxLjUsMTkuNzU0NTQwMSAyMS42NzY4NzUyLDE5LjU1MDM5MTYgMjEuOTEwMTI0NCwxOS41MDgwNTU3IEwyMiwxOS41IEwyNywxOS41IFogTTE4LDE5LjUgQzE4LjI3NjE0MjQsMTkuNSAxOC41LDE5LjcyMzg1NzYgMTguNSwyMCBDMTguNSwyMC4yNDU0NTk5IDE4LjMyMzEyNDgsMjAuNDQ5NjA4NCAxOC4wODk4NzU2LDIwLjQ5MTk0NDMgTDE4LDIwLjUgTDEzLDIwLjUgQzEyLjcyMzg1NzYsMjAuNSAxMi41LDIwLjI3NjE0MjQgMTIuNSwyMCBDMTIuNSwxOS43NTQ1NDAxIDEyLjY3Njg3NTIsMTkuNTUwMzkxNiAxMi45MTAxMjQ0LDE5LjUwODA1NTcgTDEzLDE5LjUgTDE4LDE5LjUgWiBNMjAsMTIuNSBDMjAuMjQ1NDU5OSwxMi41IDIwLjQ0OTYwODQsMTIuNjc2ODc1MiAyMC40OTE5NDQzLDEyLjkxMDEyNDQgTDIwLjUsMTMgTDIwLjUsMTggQzIwLjUsMTguMjc2MTQyNCAyMC4yNzYxNDI0LDE4LjUgMjAsMTguNSBDMTkuNzU0NTQwMSwxOC41IDE5LjU1MDM5MTYsMTguMzIzMTI0OCAxOS41MDgwNTU3LDE4LjA4OTg3NTYgTDE5LjUsMTggTDE5LjUsMTMgQzE5LjUsMTIuNzIzODU3NiAxOS43MjM4NTc2LDEyLjUgMjAsMTIuNSBaIiBpZD0i5b2i54q257uT5ZCIIiBmaWxsPSIjMjEyMzI0IiBmaWxsLXJ1bGU9Im5vbnplcm8iPjwvcGF0aD4KICAgICAgICAgICAgPC9nPgogICAgICAgIDwvZz4KICAgIDwvZz4KPC9zdmc+"]]),Ah=new Map([["selector",{key:"selector",standardResolution:ls.get("selector"),highResolution:Yfe}],["shapeSynced",{key:"shape",standardResolution:Hfe}],["textSynced",{key:"text",standardResolution:Qfe}],["pencil",{key:"pencil",standardResolution:ls.get("pencil"),highResolution:$fe}],["eraser",{key:"eraser",standardResolution:ls.get("eraser"),highResolution:Vfe}],["text",{key:"text",standardResolution:ls.get("text")}],["shape",{key:"shape",standardResolution:ls.get("shape")}],["clicker",{key:"clicker",standardResolution:Gfe}]]),Fr={enable:!0,expirationTime:5e3,moveDelayTime:40,preloadTimeout:5e3,appearance:{},syncedLabel:{enableShowName:!0,placement:"top",gap:2,maxWidth:88}};function Nh(i){var e,r,n,s;const t={...i==null?void 0:i.appearance};return delete t[Ne.hand],delete t[Ne.laserPointer],{enable:(i==null?void 0:i.enable)??Fr.enable,expirationTime:(i==null?void 0:i.expirationTime)??Fr.expirationTime,moveDelayTime:(i==null?void 0:i.moveDelayTime)??Fr.moveDelayTime,preloadTimeout:typeof(i==null?void 0:i.preloadTimeout)=="number"&&Number.isFinite(i.preloadTimeout)&&i.preloadTimeout>0?i.preloadTimeout:Fr.preloadTimeout,appearance:t,syncedLabel:{enableShowName:((e=i==null?void 0:i.syncedLabel)==null?void 0:e.enableShowName)??Fr.syncedLabel.enableShowName,placement:((r=i==null?void 0:i.syncedLabel)==null?void 0:r.placement)??Fr.syncedLabel.placement,gap:((n=i==null?void 0:i.syncedLabel)==null?void 0:n.gap)??Fr.syncedLabel.gap,maxWidth:((s=i==null?void 0:i.syncedLabel)==null?void 0:s.maxWidth)??Fr.syncedLabel.maxWidth}}}function Zfe(i,t){var e,r;return((r=(e=i.appearance[t])==null?void 0:e.synced)==null?void 0:r.enableShowName)??i.syncedLabel.enableShowName}function Kfe(i,t){return{...i,...t,cursor:Nh(t==null?void 0:t.cursor)}}const oc="1.1.41",qfe="@netless/appliance-plugin";if(typeof window<"u"){let i=window.__netlessUA||"";i+=` ${qfe}@${oc}`,window.__netlessUA=i}const He={useWorker:"auto",useSimple:!0,workerRenderModeBlacklist:{androidWebView:{89:mr.OffscreenTransfer},harmonyArkWeb:{99:mr.OffscreenTransfer},iosWebView:{12:mr.ImageBitmap,16:mr.OffscreenTransfer}},workerCanvasContextBlacklist:{androidWebView:{89:Qn.WebGL},harmonyArkWeb:{99:Qn.WebGL},iosWebView:{16:Qn.WebGL}},workerMaskTextureFormatBlacklist:{},workerMaskTextureUploadBlacklist:{},workerImageBitmapFeatureBlacklist:{},useBackgroundThread:!1,syncOpt:{interval:300,smoothSync:!0},syncLogger:{batchWindowMs:4e3},cursor:{...Fr},bufferSize:{full:4e3,sub:600},bezier:{enable:!1,maxDrawCount:1/0,combineUnitTime:300},pencilEraser:{useBitMap:!0,removeOnDone:!0,maxImageWidth:1920,maxImageHeight:1920,maxCombineTime:500},strokeWidth:{min:1,max:10},textEditor:{showFloatBar:!0,canSelectorSwitch:!0,rightBoundBreak:!0,extendFontFaces:[],loadFontFacesTimeout:2e4},longDottedStroke:{lineCap:"round",segment:1,gap:2},dottedStroke:{lineCap:"round",segment:1,gap:2},normalStroke:{lineCap:"round"},undoRedo:{enableGlobal:!1,maxStackLength:20,timingFix:!0,ackTimeout:5e3,gracePeriodTimeout:3e3,doingFallbackTimeout:3e4},markmap:{enable:!0,timeout:1e4,options:{autoFit:!0,duration:0,zoom:!1,pan:!1,maxInitialScale:10}},overwriteSelectorStyles:{},backgroundImageLoadOptions:Eh(),onBackgroundImageLoadEvent:()=>{}},An=(i,t,e)=>({images:Ah.get(i),size:{width:26,height:26},offset:{x:0,y:0},local:{size:t,offset:e},synced:{}}),fg={...An("pencil",{width:26,height:26},{x:-2,y:4}),synced:{offset:{x:0,y:9}}},Xfe={...An("selector",{width:25,height:25},{x:-5,y:21}),synced:{offset:{x:0,y:26}}},Jfe={...An("eraser",{width:26,height:26},{x:-8,y:8}),synced:{offset:{x:-5,y:13}}},_fe={...An("eraser",{width:26,height:26},{x:-8,y:8}),synced:{offset:{x:-5,y:13}}},ege=An("eraser",{width:26,height:26},{x:-8,y:8}),tge={...An("text",{width:47,height:40},{x:-20,y:20}),synced:{images:Ah.get("textSynced"),offset:{x:-13,y:16}}},cn={...An("shape",{width:40,height:40},{x:-20,y:20}),synced:{images:Ah.get("shapeSynced"),offset:{x:-9,y:16}}},rge={...An("clicker",{width:24,height:24},{x:-4,y:21}),synced:{offset:{x:0,y:26}}},Xo=Object.freeze({[Ne.selector]:Xfe,[Ne.clicker]:rge,[Ne.pencil]:fg,[Ne.rectangle]:cn,[Ne.ellipse]:cn,[Ne.shape]:cn,[Ne.eraser]:Jfe,[Ne.pencilEraser]:_fe,[Ne.text]:tge,[Ne.straight]:cn,[Ne.arrow]:cn,[Ne.laserPen]:fg,[rr.star]:cn,[rr.polygon]:cn,[rr.speechBalloon]:cn,[rr.bitMapEraser]:ege});function Hy(i){return{...Kfe(He,i),syncLogger:{...He.syncLogger,...i==null?void 0:i.syncLogger},backgroundImageLoadOptions:Eh(i==null?void 0:i.backgroundImageLoadOptions)}}const ru=new WeakMap,nu=new WeakMap,Qy=new WeakMap;function nge(i,t){Qy.set(i,t)}function ige(i){return Qy.get(i)}function sge(i,t,e,r){let n=ru.get(i);n||(n=new Map,ru.set(i,n));let s=n.get(t);s||(s=new Set,n.set(t,s)),s.add(e);let o=nu.get(i);o||(o=new Map,nu.set(i,o));let a=o.get(t);return a||(a=new Set,o.set(t,a)),r&&a.add(r),()=>{s==null||s.delete(e),s!=null&&s.size||n==null||n.delete(t),r&&(a==null||a.delete(r)),a!=null&&a.size||o==null||o.delete(t)}}function Zy(i,t,e){var r;for(const n of((r=ru.get(i))==null?void 0:r.get(t))||[])n(e)}function oge(i,t){var e;for(const r of((e=nu.get(i))==null?void 0:e.get(t))||[])r()}function age(i,t){const[e,r,n,s,o,a]=t,c=Math.max(Math.hypot(e,r),Math.hypot(n,s));for(const l of i){l.thickness*=c;for(const u of l.op)for(let h=0;h<u.length;h+=2){const d=u[h],g=u[h+1];u[h]=e*d+n*g+o,u[h+1]=r*d+s*g+a}}}const Dh=16,cge=1;function mn(i){return Object.prototype.hasOwnProperty.call(i,"eraserFaces")}function lge(i,t){return t!==void 0&&i.has(t)}function iu(i,t){const e={...t};return mn(t)?delete e.eraserlines:i&&mn(i)&&(e.eraserFaces=i.eraserFaces??null,delete e.eraserlines),e}function su(i){const t={...i};return delete t.doingLines,t}function uge(i,t){const e=mn(i)?i.eraserFaces?ua(i.eraserFaces):[]:gg(i.eraserlines||[]);return{eraserFaces:Ky(hge(e,gg(t)))}}function Ky(i,t=Dh){if(!Number.isSafeInteger(t)||t<=0)throw new Error("eraserFaces scale must be a positive safe integer");const e=[];bs(e,i.length);for(const r of i){bs(e,r.rings.length);for(const n of r.rings){bs(e,n.length);let s=0,o=0;n.forEach(([a,c],l)=>{const u=mg(a,t),h=mg(c,t);yg(e,l===0?u:u-s),yg(e,l===0?h:h-o),s=u,o=h})}}return{v:1,s:t,e:1,d:Jy(e)}}function ua(i){if(i.v!==1||i.e!==1||i.s<=0)throw new Error("unsupported eraserFaces payload");const t=new gge(pge(i.d)),e=[],r=t.readUVarint();for(let n=0;n<r;n++){const s=[],o=t.readUVarint();for(let a=0;a<o;a++){const c=[],l=t.readUVarint();let u=0,h=0;for(let d=0;d<l;d++){const g=t.readSVarint(),p=t.readSVarint();u=d===0?g:u+g,h=d===0?p:h+p,c.push([u/i.s,h/i.s])}s.push(c)}e.push({rings:s})}if(!t.done)throw new Error("trailing eraserFaces bytes");return e}function gg(i,t=Dh){const e=[];for(const r of i){const n=new Tt.ClipperOffset;n.ArcTolerance=Math.max(.25,t*.05);for(const s of r.op){const o=[];for(let a=0;a<s.length;a+=2)o.push({X:Math.round(s[a]*t),Y:Math.round(s[a+1]*t)});o.length===1&&o.push({...o[0]}),o.length>=2&&n.AddPath(o,Tt.JoinType.jtRound,Tt.EndType.etOpenRound)}n.Execute(e,r.thickness*t/2)}return Xy(e,t)}function hge(i,t,e=Dh){const r=[...i,...t].flatMap(n=>n.rings.map(s=>s.map(([o,a])=>({X:Math.round(o*e),Y:Math.round(a*e)}))));return Xy(r,e)}function ha(i,t){const e=[cge];return vg(e,i),vg(e,t),Jy(Array.from(fge(Uint8Array.from(e)).slice(0,16)))}function qy(i,t,e){return i.matrix.length===6&&i.matrix.every(Number.isFinite)&&i.fromDigest===ha(t,e)&&/^[A-Za-z0-9_-]{22}$/.test(i.toDigest)}function dge(i,t,e,r,n){return!qy(e,r.op,r.centerPos)||e.toDigest!==ha(n.op,n.centerPos)?!1:(Zy(i,t,e.matrix),!0)}function ll(i,t){if(!i)return null;const e=ua(i);for(const r of e)for(const n of r.rings){const s=n.flat();t(s),r.rings[r.rings.indexOf(n)]=Array.from({length:s.length/2},(o,a)=>[s[a*2],s[a*2+1]])}return Ky(e,i.s)}function Xy(i,t){if(!i.length)return[];const e=new Tt.Clipper;e.AddPaths(i,Tt.PolyType.ptSubject,!0);const r=new Tt.PolyTree;e.Execute(Tt.ClipType.ctUnion,r,Tt.PolyFillType.pftNonZero,Tt.PolyFillType.pftNonZero);const n=[],s=o=>{for(const a of o.Childs()){if(!a.IsHole()){const c=[pg(a.Contour(),t)];for(const l of a.Childs())l.IsHole()&&c.push(pg(l.Contour(),t));n.push({rings:c})}s(a)}};return s(r),n}function pg(i,t){return i.map(({X:e,Y:r})=>[e/t,r/t])}function mg(i,t){if(!Number.isFinite(i))throw new Error("eraserFaces coordinate must be finite");const e=Math.round(i*t);if(!Number.isSafeInteger(e))throw new Error("eraserFaces coordinate is out of range");return Object.is(e,-0)?0:e}function bs(i,t){if(!Number.isSafeInteger(t)||t<0)throw new Error("invalid unsigned varint");do{let e=t%128;t=Math.floor(t/128),t&&(e|=128),i.push(e)}while(t)}function yg(i,t){const e=t>=0?t*2:-t*2-1;bs(i,e)}function vg(i,t){bs(i,t.length);const e=new ArrayBuffer(8),r=new DataView(e);for(const n of t){if(!Number.isFinite(n))throw new Error("geometry digest values must be finite");const s=Object.is(n,-0)?0:n;r.setFloat64(0,s,!0);for(let o=0;o<8;o++)i.push(r.getUint8(o))}}function fge(i){const t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),e=i.length*8,r=Math.ceil((i.length+9)/64)*64,n=new Uint8Array(r);n.set(i),n[i.length]=128;const s=new DataView(n.buffer);s.setUint32(r-8,Math.floor(e/4294967296),!1),s.setUint32(r-4,e>>>0,!1);const o=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64),c=(h,d)=>h>>>d|h<<32-d;for(let h=0;h<r;h+=64){for(let w=0;w<16;w++)a[w]=s.getUint32(h+w*4,!1);for(let w=16;w<64;w++){const y=a[w-15],f=a[w-2],M=c(y,7)^c(y,18)^y>>>3,T=c(f,17)^c(f,19)^f>>>10;a[w]=a[w-16]+M+a[w-7]+T>>>0}let[d,g,p,v,I,D,x,j]=o;for(let w=0;w<64;w++){const y=c(I,6)^c(I,11)^c(I,25),f=I&D^~I&x,M=j+y+f+t[w]+a[w]>>>0,T=c(d,2)^c(d,13)^c(d,22),b=d&g^d&p^g&p,C=T+b>>>0;j=x,x=D,D=I,I=v+M>>>0,v=p,p=g,g=d,d=M+C>>>0}o[0]=o[0]+d>>>0,o[1]=o[1]+g>>>0,o[2]=o[2]+p>>>0,o[3]=o[3]+v>>>0,o[4]=o[4]+I>>>0,o[5]=o[5]+D>>>0,o[6]=o[6]+x>>>0,o[7]=o[7]+j>>>0}const l=new Uint8Array(32),u=new DataView(l.buffer);return o.forEach((h,d)=>u.setUint32(d*4,h,!1)),l}class gge{constructor(t){R(this,"index",0);this.bytes=t}get done(){return this.index===this.bytes.length}readUVarint(){let t=0,e=1;for(let r=0;r<8;r++){const n=this.bytes[this.index++];if(n===void 0)throw new Error("truncated eraserFaces payload");if(t+=(n&127)*e,!(n&128))return t;e*=128}throw new Error("eraserFaces varint is too long")}readSVarint(){const t=this.readUVarint();return t%2===0?t/2:-(t+1)/2}}function Jy(i){let t="";for(let e=0;e<i.length;e+=32768)t+=String.fromCharCode(...i.slice(e,e+32768));return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function pge(i){const t=i.replace(/-/g,"+").replace(/_/g,"/").padEnd(Math.ceil(i.length/4)*4,"="),e=atob(t);return Uint8Array.from(e,r=>r.charCodeAt(0))}function Jr(i,t=!0){const e=i.length;if(e<2)return"";let r=i[0],n=i[1];if(e===2)return`M${Ti(r)}L${Ti(n)}`;let s="";for(let o=2,a=e-1;o<a;o++)r=i[o],n=i[o+1],s+=Si(r,n);return t?`M${Si(i[0],i[1])}Q${Ti(i[1])}${Si(i[1],i[2])}T${s}${Si(i[e-1],i[0])}${Si(i[0],i[1])}Z`:`M${Ti(i[0])}Q${Ti(i[1])}${Si(i[1],i[2])}${i.length>3?"T":""}${s}L${Ti(i[e-1])}`}function mge(i,t){const e=t>0?t:1,r=Math.floor(i.x*e),n=Math.floor(i.y*e),s=Math.ceil((i.x+i.w)*e),o=Math.ceil((i.y+i.h)*e);return{x:r,y:n,w:Math.max(1,s-r),h:Math.max(1,o-n)}}function yge(i,t){const r=1/(t>0?t:1);return{x:i.x-r,y:i.y-r,w:i.w+r*2,h:i.h+r*2}}function vge(i,t,e){const r=Math.abs(e[0])||1,n=Math.abs(e[1])||1;return{size:[t.w/r,t.h/n],textureRect:[(i.x-t.x)/r,(i.y-t.y)/n,i.w/r,i.h/n]}}function Nn(i){return JSON.parse(sp.decompress(i))}function xt(i){return sp.compress(JSON.stringify(i))}const ot=Object.keys,Mg=new WeakMap,Vt=class Vt{constructor(t){R(this,"maxImageWidth",He.pencilEraser.maxImageWidth);R(this,"maxImageHeight",He.pencilEraser.maxImageHeight);R(this,"syncUnitTime",He.syncOpt.interval);R(this,"vNodes");R(this,"drawLayer");R(this,"fullLayer");R(this,"workId");R(this,"confirmEraserDeletion",!1);R(this,"isDelete",!1);const{vNodes:e,fullLayer:r,drawLayer:n,workId:s,toolsOpt:o}=t;this.vNodes=e,this.fullLayer=r,this.drawLayer=n,this.workId=s,this.syncUnitTime=o.syncUnitTime||this.syncUnitTime}static async normalizeStorageData(t){return this.normalizeStorageDataSync(t)}static normalizeStorageDataSync(t){const e=Lt(t),r=JSON.stringify(t);if(e.opt){const n=su(e.opt);e.opt=iu(void 0,n)}return e.updateNodeOpt={...e.updateNodeOpt,useAnimation:!1},{status:JSON.stringify(e)===r?"already-stable":"stable",value:e}}static async normalizeDrawableStorageData(t){return this.normalizeDrawableStorageDataSync(t)}static normalizeDrawableStorageDataSync(t){const e=Vt.normalizeStorageDataSync(t);if(e.status==="unrecoverable")return e;const r=e.value;return r.type===he.DrawWork&&!r.ops&&Array.isArray(r.op)&&r.op.length?(r.type=he.FullWork,r.ops=xt(r.op),{status:"stable",value:r}):e}get baseConsumeResult(){return{workId:this.workId,toolsType:this.toolsType,opt:this.workOptions}}filterSamePoints(t,e=.01){return t.reduce((r,n)=>{const s=r[r.length-1];return(n&&!s||n&&s&&!n.isNear(s,e))&&r.push(n),r},[])}setWorkId(t){this.workId=t}getWorkId(){return this.workId}setEraserDeleteConfirmation(t){this.confirmEraserDeletion=t}getWorkOptions(){return this.workOptions}setWorkOptions(t){var s,o,a;const e=iu(this.workOptions,t);this.workOptions=e,this.syncUnitTime=t.syncUnitTime||this.syncUnitTime;const r=(s=this.workId)==null?void 0:s.toString(),n=r&&((o=this.vNodes)==null?void 0:o.get(r))||void 0;r&&n&&(n.opt=su(e),(a=this.vNodes)==null||a.setInfo(r,n))}getRenderableEraserLines(t){return[...t.eraserlines||[],...t.doingLines||[]]}updataOptService(t){var n,s;let e;const r=(n=this.workId)==null?void 0:n.toString();if(r&&t){const o=this.fullLayer.getElementsByName(r)||this.drawLayer&&this.drawLayer.getElementsByName(r)||[];if(o.length!==1)return;const a=o[0],{pos:c,zIndex:l,scale:u,angle:h,translate:d}=t,g={};It(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=Ge(e,{x:Math.floor(p.x-Vt.SafeBorderPadding),y:Math.floor(p.y-Vt.SafeBorderPadding),w:Math.floor(p.width+Vt.SafeBorderPadding*2),h:Math.floor(p.height+Vt.SafeBorderPadding*2)})),(s=this.vNodes)==null||s.setInfo(r,{rect:e,centerPos:c}),e}}drawEraserlines(t,e){const{group:r,eraserlines:n=[],eraserFaces:s,pos:o,layer:a}=t,c=a.parent;if(e)try{const u=(a.renderer.glRenderer||a.renderer.canvasRenderer).options.displayRatio,h=r.getBoundingClientRect(),d=h.width*u*a.worldScaling[0],g=h.height*u*a.worldScaling[1];let p=1;if((d>this.maxImageWidth||g>this.maxImageHeight)&&(p=Math.min(this.maxImageWidth/d,this.maxImageHeight/g)),c.renderer.glRenderer&&!this.confirmEraserDeletion&&this.drawEraserMask({group:r,eraserlines:n,eraserFaces:s,pos:o,layer:a,targetScale:p}))return;let v=a.getAttribute("scale");v=[v[0]*p,v[1]*p];const I=a.parent.parent,D=a.getAttribute("translate"),x=this.createVmRenderNode(`${this.workId}_bitMapLayer`,I,{offscreen:c.offscreen,width:c.width,height:c.height,contextType:"2d",autoRender:!1,bufferSize:500},v,D),j=r.cloneNode(!0);if(!n.length&&!s)return;s&&this.addEraserFaces(j,s,o,!1),this.addEraserlines(j,n,o,!1),x.appendChild(j);const w=x.parent;w.render();const y=x.renderer.canvasRenderer,f=y.context;if(!f)return;const M=y.options.displayRatio,T=j.getBoundingClientRect(),b={x:T.x,y:T.y,w:T.width,h:T.height},C={x:0,y:0,w:I.width,h:I.height};if(hc(b,C)===Kr.outside){ar(j,w),I.removeChild(w),this.isDelete=!0;return}const E=yge(b,M),O=Lt(E);O.x=Math.floor(Math.max(E.x,0)),O.y=Math.floor(Math.max(E.y,0)),O.w=Math.min(E.x+E.w,I.width)-O.x,O.h=Math.min(E.y+E.h,I.height)-O.y;const V=this.getGroupRect(O,M),N=V.x,A=V.y,k=V.w,U=V.h;let Z=f.getImageData(N,A,k,U);if(this.confirmEraserDeletion&&this.isTransparentRectByCanvas(Z)){ar(j,w),I.removeChild(w),this.isDelete=!0,Z=null;return}if(this.confirmEraserDeletion&&c.renderer.glRenderer&&this.drawEraserMask({group:r,eraserlines:n,eraserFaces:s,pos:o,layer:a,targetScale:p})){ar(j,w),I.removeChild(w),Z=null;return}ar(r,c);const Q=this.createSpriteNode({imageData:Z,safariRect:O,originRect:E,worldScaling:x.worldScaling});Q&&r.append(Q),ar(j,w),I.removeChild(w),c.deleteTexture(Z),Z=null}catch(l){console.error("[BaseShapeTool] drawEraserlines error:",l);return}}drawEraserMask(t){var f,M;const{group:e,eraserlines:r,eraserFaces:n,pos:s,layer:o,targetScale:a}=t;if(!r.length&&!n||e.getAttribute("clipPath"))return!1;const c=Number(e.getAttribute("width")),l=Number(e.getAttribute("height"));if(!(c>0)||!(l>0))return!1;const u=o.parent.renderer;if(!u.glRenderer)return!1;const h=u.options.displayRatio||1,d=Math.max(1,Math.ceil(c*h*o.worldScaling[0]*a)),g=Math.max(1,Math.ceil(l*h*o.worldScaling[1]*a)),p=[-c/2,-l/2,c,l];let v=Mg.get(o);v||(v=new Map,Mg.set(o,v)),this.pruneEraserMaskCaches(o,v,u);let I=v.get(this.workId),D=!I||I.pixelWidth!==d||I.pixelHeight!==g||I.facesKey!==(n==null?void 0:n.d);if(I&&!D&&(D=this.isEraserMaskPrefixChanged(I,r)),D){if(I==null||I.handle.destroy(u),I=this.createEraserMaskCache(d,g,p),!I)return!1;v.set(this.workId,I)}if(!I)return!1;const x=d/c,j=g/l;I.context.setTransform(x,0,0,j,d/2,g/2),D&&n&&(this.appendEraserMaskFaces(I.context,n,s),I.facesKey=n.d);let w=D,y;for(const T of r){const b=I.commands.get(T.workId),C=D?0:(b==null?void 0:b.count)||0;for(let P=C;P<T.op.length;P++)w=!0,y=Ge(y,this.appendEraserMaskStroke(I.context,T.op[P],T.thickness,s));I.commands.set(T.workId,{count:T.op.length,thickness:T.thickness,first:(f=T.op[0])==null?void 0:f.slice(0,2),last:(M=T.op[T.op.length-1])==null?void 0:M.slice(-2)})}return w&&I.handle.update({rect:p,dirtyRect:D||!y?void 0:[y.x,y.y,y.w,y.h]}),e.setMask(I.handle,{rect:p}),!0}pruneEraserMaskCaches(t,e,r){for(const[n,s]of e)n!==this.workId&&t.getElementsByName(n).length===0&&(s.handle.destroy(r),e.delete(n))}createEraserMaskCache(t,e,r){var o,a;let n;typeof OffscreenCanvas=="function"?n=new OffscreenCanvas(t,e):typeof document<"u"&&(n=document.createElement("canvas"),n.width=t,n.height=e);const s=n==null?void 0:n.getContext("2d");if(!(!n||!s))return s.save(),s.setTransform(1,0,0,1,0,0),s.fillStyle="#fff",s.fillRect(0,0,t,e),s.restore(),{canvas:n,context:s,handle:new fse(n,{rect:r,singleChannelTexture:((o=this.fullLayer.parent.renderer.options.bitmapEraserMaskOptions)==null?void 0:o.singleChannelTexture)!==!1,textureSubImage2D:((a=this.fullLayer.parent.renderer.options.bitmapEraserMaskOptions)==null?void 0:a.textureSubImage2D)!==!1}),rect:r,pixelWidth:t,pixelHeight:e,commands:new Map}}appendEraserMaskStroke(t,e,r,n){if(e.length<2)return;t.save(),t.fillStyle="#000",t.strokeStyle="#000",t.lineCap="round",t.lineJoin="round",t.lineWidth=r;const s=e[0]-n[0],o=e[1]-n[1];if(e.length===2)t.beginPath(),t.arc(s,o,r/2,0,Math.PI*2),t.fill();else{t.beginPath(),t.moveTo(s,o);for(let p=2;p<e.length;p+=2)t.lineTo(e[p]-n[0],e[p+1]-n[1]);t.stroke()}t.restore();const a=[],c=[];for(let p=0;p<e.length;p+=2)a.push(e[p]-n[0]),c.push(e[p+1]-n[1]);const l=r/2+1,u=Math.min(...a),h=Math.min(...c),d=Math.max(...a),g=Math.max(...c);return{x:u-l,y:h-l,w:d-u+l*2,h:g-h+l*2}}appendEraserMaskFaces(t,e,r){t.save(),t.fillStyle="#000",t.beginPath();for(const n of ua(e))for(const s of n.rings)s.forEach(([o,a],c)=>{const l=o-r[0],u=a-r[1];c===0?t.moveTo(l,u):t.lineTo(l,u)}),t.closePath();t.fill("evenodd"),t.restore()}isEraserMaskPrefixChanged(t,e){var r,n;if(t.commands.size>e.length)return!0;for(const s of e){const o=t.commands.get(s.workId);if(o&&(s.op.length<o.count||s.thickness!==o.thickness||!this.isSamePoint(o.first,(r=s.op[0])==null?void 0:r.slice(0,2))||!this.isSamePoint(o.last,(n=s.op[o.count-1])==null?void 0:n.slice(-2))))return!0}return!1}isSamePoint(t,e){return!t||!e?t===e:t[0]===e[0]&&t[1]===e[1]}createVmRenderNode(t,e,r,n,s){const{width:o,height:a}=r,c=`bitMap-${t}`,l=e.layer(c,r),u=new dt({anchor:[.5,.5],pos:[o*.5,a*.5],size:[o,a],name:"viewport",id:t});return u.setAttribute("scale",n),u.setAttribute("translate",s),l.append(u),u}getGroupRect(t,e){return mge(t,e)}addEraserlines(t,e,r,n=!0){for(const s of e){const{thickness:o,op:a}=s;for(const c of a){const l=c.map((p,v)=>v%2?p-r[1]:p-r[0]),u=this.computEraserPoints(l,o),h=Jr(u,!0),d={pos:[0,0],d:h,fillColor:"rgba(0,0,0,1)"},g=new Zt(d);g.addEventListener("beforerender",({detail:p})=>{const v=p.context;n?v.blendFuncSeparate(v.ZERO,v.ZERO,v.ZERO,v.ZERO):v.globalCompositeOperation="destination-out"}),g.addEventListener("afterrender",({detail:p})=>{const v=p.context;n?v.blendFuncSeparate(v.SRC_ALPHA,v.ONE_MINUS_SRC_ALPHA,v.ONE,v.ONE_MINUS_SRC_ALPHA):v.globalCompositeOperation="source-over"}),t.append(g)}}}addEraserFaces(t,e,r,n=!0){const s=ua(e).flatMap(a=>a.rings.map(c=>Jr(c.map(([l,u])=>new Ae(l-r[0],u-r[1])),!0))).join(" ");if(!s)return;const o=new Zt({pos:[0,0],d:s,fillColor:"rgba(0,0,0,1)",fillRule:"evenodd"});o.addEventListener("beforerender",({detail:a})=>{const c=a.context;n?c.blendFuncSeparate(c.ZERO,c.ZERO,c.ZERO,c.ZERO):c.globalCompositeOperation="destination-out"}),o.addEventListener("afterrender",({detail:a})=>{const c=a.context;n?c.blendFuncSeparate(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA):c.globalCompositeOperation="source-over"}),t.append(o)}isTransparentRectByCanvas(t){let e=!0;for(let r=0;r<t.data.length;r+=4)if(t.data[r+3]!==0){e=!1;break}return e}createSpriteNode(t){const{imageData:e,worldScaling:r,safariRect:n,originRect:s}=t;let o;if(typeof OffscreenCanvas=="function"){o=new OffscreenCanvas(e.width,e.height);const d=o.getContext("2d");d&&d.putImageData(e,0,0)}else if(typeof document<"u"){o=document.createElement("canvas"),o.width=e.width,o.height=e.height;const d=o.getContext("2d");d&&d.putImageData(e,0,0)}if(!o)return console.warn("Failed to create imageEraserBitmap Sprite"),null;const{size:a,textureRect:c}=vge(n,s,r),l={name:"eraserTexture",anchor:[.5,.5],pos:[0,0],size:a,texture:o,textureRect:c},u=new Ja(l);let h=!0;return u.addEventListener("beforerender",({detail:d})=>{const g=d.context;typeof g.imageSmoothingEnabled=="boolean"&&(h=g.imageSmoothingEnabled,g.imageSmoothingEnabled=!1)}),u.addEventListener("afterrender",({detail:d})=>{const g=d.context;typeof g.imageSmoothingEnabled=="boolean"&&(g.imageSmoothingEnabled=h)}),u}computEraserPoints(t,e){const r=Math.ceil(e/2);return t.length===2?this.computDot(t,r):this.computLine(t,r)}computDot(t,e){const r=new Ae(t[0],t[1]);return Ae.GetDotStroke(r,e,8)}computLine(t,e){const r=[],n=[];let s,o;for(let a=0;a<t.length;a+=2){const c=new Ae(t[a],t[a+1]);let l;if(a==t.length-2){const u=new Ae(t[a-2],t[a-1]);l=fe.Sub(c,u).uni(),s=c}else{a===0&&(o=c);const u=new Ae(t[a+2],t[a+3]);l=fe.Sub(u,c).uni()}if(l){const u=fe.Per(l).mul(e);r.push(Ae.Sub(c,u)),n.push(Ae.Add(c,u))}}if(s&&o){const a=Ae.GetSemicircleStroke(s,r[r.length-1],-1,8),c=Ae.GetSemicircleStroke(o,n[0],-1,8);return r.concat(a,n.reverse(),c)}return[]}replace(t,e,r){var s;if(!e){r&&t.append(r);return}const n=t.getElementsByName(e);if(n.length)for(const o of n)r?s0e(r,o,t):(o.remove(),cr(o,t.parent));else r&&t.append(r);this.fullLayer!==this.drawLayer&&(this.fullLayer===t?(s=this.drawLayer)==null||s.getElementsByName(e).forEach(a=>{var c;a.remove(),cr(a,(c=this.drawLayer)==null?void 0:c.parent)}):this.fullLayer.getElementsByName(e).forEach(a=>{a.remove(),cr(a,this.fullLayer.parent)}))}removeDrawCountNodes(t,e){const r=[];t.getElementsByName(this.workId).forEach(n=>{n.id&&e&&Number(n.id)<e&&r.push(n)});for(const n of r)n.remove(),cr(n,t.parent)}static updateNodeOpt(t){var y;const{node:e,opt:r,vNodes:n,willSerializeData:s,targetNode:o}=t,{zIndex:a,translate:c,angle:l,originPoint:u,scenePoint:h,scale:d,pointMap:g,thickness:p}=r;let v;const I=o&&Lt(o)||n.get(e.name);if(!I)return;const D=r.eraserGeometryDelta,x=mn(I.opt)?ha(I.op,I.centerPos):void 0;if(D&&(!x||!qy(D,I.op,I.centerPos)))return;D&&Zy(n,e.name,D.matrix);let j;It(a)&&(e.setAttribute("zIndex",a),I.opt.zIndex=a);const w=e.parent;if(w){if(u&&d&&o){if(j=[d[0],0,0,d[1],h[0]*(1-d[0])+((c==null?void 0:c[0])||0),h[1]*(1-d[1])+((c==null?void 0:c[1])||0)],uc(I.op,h,d,c),xs(I.centerPos,h,d,c),I.opt.translate=void 0,I.opt.scale=void 0,I.opt.eraserlines)for(let f=0;f<I.opt.eraserlines.length;f++){const{op:M,thickness:T}=I.opt.eraserlines[f];I.opt.eraserlines[f].thickness=Math.round(T*Math.max(d[0],d[1]));for(let b=0;b<M.length;b++)xs(M[b],h,d,c)}mn(I.opt)&&(I.opt.eraserFaces=ll(I.opt.eraserFaces??null,f=>xs(f,h,d,c)),delete I.opt.eraserlines)}else if(c)if(e.setAttribute("translate",c),I.opt.translate=c,o){const f=[c[0]*w.worldScaling[0],c[1]*w.worldScaling[1]];v=zs(I.rect,f),I.rect=v}else{const f=Vt.getRectFromLayer(w,e.name);I.rect=f||I.rect}else if(It(l))if(e.setAttribute("rotate",l),I.opt.rotate=l,o)v=jh(I.rect,l),I.rect=v;else{const f=Vt.getRectFromLayer(w,e.name);I.rect=f||I.rect}if(g){const f=g.get(e.name);if(f)for(let M=0,T=0;M<I.op.length;M+=3,T++)I.op[M]=f[T][0],I.op[M+1]=f[T][1]}if(p&&((y=I==null?void 0:I.opt)!=null&&y.thickness)&&(I.opt.thickness=p),s&&!(u&&d&&o)){if(c){j=[1,0,0,1,c[0],c[1]];const f=I.op.map((M,T)=>{const b=T%3;return b===0?M+c[0]:b===1?M+c[1]:M});if(I.op=f,I.centerPos=[I.centerPos[0]+c[0],I.centerPos[1]+c[1]],I!=null&&I.opt&&(I.opt.translate=void 0),I.opt.eraserlines)for(let M=0;M<I.opt.eraserlines.length;M++){const{op:T}=I.opt.eraserlines[M];for(let b=0;b<T.length;b++){const C=T[b].map((P,E)=>E%2?P+c[1]:P+c[0]);I.opt.eraserlines[M].op[b]=C}}mn(I.opt)&&(I.opt.eraserFaces=ll(I.opt.eraserFaces??null,M=>{for(let T=0;T<M.length;T+=2)M[T]+=c[0],M[T+1]+=c[1]}),delete I.opt.eraserlines)}else if(It(l)){const f=Math.PI*l/180,M=Math.cos(f),T=Math.sin(f),[b,C]=I.centerPos;j=[M,T,-T,M,b-M*b+T*C,C-T*b-M*C];const P=I.op;if(_ye(P,I.centerPos,l),I.op=P,I!=null&&I.opt&&(I.opt.rotate=void 0),I.opt.eraserlines)for(let E=0;E<I.opt.eraserlines.length;E++){const{op:O}=I.opt.eraserlines[E];for(let V=0;V<O.length;V++)Vg(O[V],I.centerPos,l)}mn(I.opt)&&(I.opt.eraserFaces=ll(I.opt.eraserFaces??null,E=>Vg(E,I.centerPos,l)),delete I.opt.eraserlines)}}if(x&&j&&mn(I.opt)){const f=ha(I.op,I.centerPos);if(D&&D.toDigest!==f)return;D||nge(I.opt,{matrix:j,fromDigest:x,toDigest:f})}I&&n.setInfo(e.name,I)}}static getCenterPos(t,e){const{worldPosition:r,worldScaling:n}=e;return[(t.x+t.w/2-r[0])/n[0],(t.y+t.h/2-r[1])/n[1]]}static getRectFromLayer(t,e){const r=t.getElementsByName(e)[0];if(r){const n=r.getBoundingClientRect();return{x:Math.floor(n.x-Vt.SafeBorderPadding),y:Math.floor(n.y-Vt.SafeBorderPadding),w:Math.floor(n.width+Vt.SafeBorderPadding*2),h:Math.floor(n.height+Vt.SafeBorderPadding*2)}}}static isWillRefresh(t){const{toolsType:e,opt:r,node:n,updateOpt:s,willSerializeData:o}=t;return!!(o&&(s.angle||s.translate)||s.thickness&&r.thickness&&r.thickness!==s.thickness||s.strokeType&&r.strokeType&&r.strokeType!==s.strokeType||s.originPoint&&s.scenePoint&&s.scale||s.pointMap&&s.pointMap.has(n.name)||e===K.Text&&(s.fontSize||s.translate||s.textInfos&&s.textInfos.get(n.name))||e===K.BackgroundSVG&&(s.translate||s.scale)||e===K.Image&&(s.angle||s.translate||s.scale||s.strokeColor&&r.type===qr.Iconify)||e===s.toolsType&&s.willRefresh||r.eraserlines&&r.eraserlines.length&&(s.strokeColor||s.fillColor))}};R(Vt,"SafeBorderPadding",10);let xe=Vt;const Ph=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 _y(i,t,e=.01){return Math.abs(i[0]-t[0])<e&&Math.abs(i[1]-t[1])<e}function Mge(i,t=.01){if(i.length===0)return[];const e=[[i[0][0],i[0][1]]];for(let r=1;r<i.length;r++)_y([i[r][0],i[r][1]],e[e.length-1],t)||e.push([i[r][0],i[r][1]]);return e}function wge(i,t=.01){if(i.length<=2)return i;const e=i[0],r=i[i.length-1];return _y(e,r,t)?i.slice(0,-1):i}function Tge(i){const t=i.reduce((r,n)=>r+n[0],0)/i.length,e=i.reduce((r,n)=>r+n[1],0)/i.length;return[t,e]}function wg(i,t){return Math.atan2(t[1]-i[1],t[0]-i[0])}function Sge(i,t=.01){if(i.length<=2)return i;const e=[];for(const n of i)e.some(o=>Math.abs(o[0]-n[0])<t&&Math.abs(o[1]-n[1])<t)||e.push([n[0],n[1]]);const r=Tge(e);return e.sort((n,s)=>{const o=wg(r,n),a=wg(r,s);return o-a})}function Ige(i,t){const e=t[0].x<t[t.length-1].x;return i.map(n=>{const o=n.map(a=>{let c=-1,l=1/0,u=0;for(let h=0;h<t.length;h++){const d=t[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&&o[0][0]>o[o.length-1][0]||!e&&o[0][0]<o[o.length-1][0]?o.reverse():o}).sort((n,s)=>{const o=n[0][0],a=s[0][0];return e?o-a:a-o})}function Cge(i,t,e=.01){const n=i.map(h=>[h.x,h.y]),s=(h,d)=>h.map(([g,p])=>({X:Math.round(g*d),Y:Math.round(p*d)})),o=new Tt.ClipperOffset;o.AddPath(s(n,1e3),Tt.JoinType.jtRound,Tt.EndType.etOpenButt);const a=[];o.Execute(a,1);const c=new Tt.Clipper;c.AddPaths(a,Tt.PolyType.ptSubject,!0),t.forEach(h=>{c.AddPath(s(h,1e3),Tt.PolyType.ptClip,!0)});const l=new Tt.Paths;c.Execute(Tt.ClipType.ctDifference,l,Tt.PolyFillType.pftNonZero,Tt.PolyFillType.pftNonZero);const u=l.map(h=>wge(Sge(Mge(h.map(d=>[d.X/1e3,d.Y/1e3]),e),e),e)).filter(h=>h.length>=2);return Ige(u,i)}class e0 extends xe{constructor(e){super(e);R(this,"canRotate",!0);R(this,"scaleType",Ve.all);R(this,"toolsType",K.Pencil);R(this,"syncTimestamp");R(this,"syncIndex",0);R(this,"tmpPoints",[]);R(this,"MAX_REPEAR",10);R(this,"uniThickness");R(this,"workOptions");R(this,"centerPos",[0,0]);this.workOptions=e.toolsOpt,this.uniThickness=this.MAX_REPEAR/this.workOptions.thickness/10,this.syncTimestamp=0}static normalizeStorageData(e){return this.normalizeDrawableStorageData(e)}setPointVector(e,r){if(!r)return!1;const n=e.x-r.x,s=e.y-r.y;if(n===0&&s===0)return!1;const o=fe.Sub(e,r).uni();return!Number.isFinite(o.x)||!Number.isFinite(o.y)?!1:(e.setv(o),!0)}combineConsume(){var a;const e=(a=this.workId)==null?void 0:a.toString();if(this.tmpPoints.length<2)return{type:he.None};const r=this.transformDataAll(!0),n={name:e};let s;const o=this.drawLayer||this.fullLayer;return r.length&&(s=this.draw({attrs:n,tasks:r,replaceId:e,layer:o})),{rect:s,type:he.DrawWork,dataType:Ee.Local}}setWorkOptions(e){super.setWorkOptions(e),this.syncTimestamp=Date.now()}consume(e){const{data:r,isFullWork:n,isSubWorker:s,isMainThread:o,drawCount:a,removeDrawCount:c,isSimpleWorker:l}=e,{workId:u,syncUnitTime:h}=r;h&&(this.syncUnitTime=h);const{tasks:d,effects:g,consumeIndex:p}=this.transformData(r,!1);this.syncIndex=Math.min(this.syncIndex,p,Math.max(0,this.tmpPoints.length-2));const v={name:u,id:It(a)&&a.toString()||void 0};let I,D=!1;const x=this.syncIndex;if(this.syncTimestamp===0&&(this.syncTimestamp=Date.now()),d.length&&(d[0].taskId-this.syncTimestamp>this.syncUnitTime&&(D=!0,this.syncTimestamp=d[0].taskId,this.syncIndex=this.tmpPoints.length),s||o||l)){const y=n?this.fullLayer:this.drawLayer||this.fullLayer;I=this.draw({attrs:v,tasks:d,effects:g,layer:y,removeDrawCount:c})}if(l){const y=[];this.tmpPoints.slice(x).forEach(M=>{y.push(M.x,M.y,this.computRadius(M.z,this.workOptions.thickness))});const f=!this.workOptions.previewLocalOnly&&D;return{...this.baseConsumeResult,type:he.DrawWork,dataType:Ee.Local,op:f?y:void 0,index:f?x*3:void 0,rect:I,updateNodeOpt:{useAnimation:!0}}}if(s)return p>10&&this.tmpPoints.splice(0,p-10),{rect:I,type:he.DrawWork,dataType:Ee.Local};const j=[];this.tmpPoints.slice(x).forEach(y=>{j.push(y.x,y.y,this.computRadius(y.z,this.workOptions.thickness))});const w=!this.workOptions.previewLocalOnly&&D;return{...this.baseConsumeResult,type:he.DrawWork,dataType:Ee.Local,rect:I,op:w?j:void 0,index:w?x*3:void 0,updateNodeOpt:{useAnimation:!0}}}consumeAll(e){var u;const r=this.workId;if(e.data){const{op:h,workState:d}=e.data;h!=null&&h.length&&d===ge.Done&&this.workOptions.strokeType===ze.Stroke&&this.updateTempPointsWithPressureWhenDone(h)}const n=this.fullLayer;if(this.tmpPoints.length<2)return this.replace(n,r),{type:he.RemoveNode,removeIds:[r]};const s=this.transformDataAll(!0),o={name:r};let a;s.length&&(a=this.draw({attrs:o,tasks:s,replaceId:r,layer:n}));const c=[];this.tmpPoints.map(h=>{c.push(h.x,h.y,h.z)}),this.syncTimestamp=0,delete this.workOptions.syncUnitTime;const l=xt(c);return(u=this.vNodes)==null||u.setInfo(r,{rect:a,op:c,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&xe.getCenterPos(a,n)}),{...this.baseConsumeResult,rect:a,type:he.FullWork,dataType:Ee.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:r,isFullWork:n,replaceId:s,workState:o=ge.Done}=e;this.tmpPoints.length=0;for(let g=0;g<r.length;g+=3){const p=new Ae(r[g],r[g+1],r[g+2]);if(this.tmpPoints.length>0){const v=this.tmpPoints[this.tmpPoints.length-1];if(!this.setPointVector(p,v))continue}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=n?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({attrs:l,tasks:a,replaceId:s,layer:g,isDrawEraserlines:o===ge.Done}),(d=this.vNodes)==null||d.setInfo(c,{rect:u,op:r,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:u&&xe.getCenterPos(u,g)})}return u}computPencilPoints(e){const r=[],{op:n,eraserPolylines:s,eraserThickness:o}=e;this.tmpPoints.length=0;for(let c=0;c<n.length;c+=3){const l=new Ae(n[c],n[c+1],n[c+2]);if(this.tmpPoints.length>0){const u=this.tmpPoints[this.tmpPoints.length-1];if(!this.setPointVector(l,u))continue}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 s){const v=[];for(let D=0;D<p.length;D+=2){const x=new Ae(p[D],p[D+1]);if(v.length>0){const j=v[v.length-1].point;if(!this.setPointVector(x,j))continue}v.push({point:x,radius:o})}const{ps:I}=this.computStroke(v,!1);d.push(I.map(D=>D.XY))}Cge(h,d,.01).forEach(p=>{r.push(p.map(v=>[v[0],v[1],v[2]]).flat(1))})}return r}transformDataAll(e=!0){return this.getTaskPoints(this.tmpPoints,e&&this.workOptions.thickness||void 0)}draw(e){const{attrs:r,tasks:n,replaceId:s,effects:o,layer:a,removeDrawCount:c,isDrawEraserlines:l=!0}=e,{strokeColor:u,strokeType:h,thickness:d,zIndex:g,scale:p,rotate:v,translate:I,eraserlines:D,eraserFaces:x,doingLines:j,lineCap:w,lineDash:y}=this.workOptions;o!=null&&o.size&&(o.forEach(P=>{var E;(E=a.getElementById(P+""))==null||E.remove()}),o.clear()),c&&this.removeDrawCountNodes(a,c);let f;const M=[],T=a.worldPosition,b=a.worldScaling;for(let P=0;P<n.length;P++){const{pos:E,points:O}=n[P],{ps:V,rect:N}=this.computDrawPoints(O);let A;const k=O.length===1;h===ze.Stroke||k?A=Jr(V,!0):A=Jr(V,!1);const U={pos:E,d:A,fillColor:h===ze.Stroke||k?u:void 0,lineDash:k?void 0:h===ze.Dotted?[y&&y[0]||1,(y&&y[1]||2)*d]:h===ze.LongDotted?[(y&&y[0]||1)*d,(y&&y[1]||2)*d]:void 0,strokeColor:u,lineCap:k?void 0:w,lineWidth:h===ze.Stroke||k?0:d};f=Ge(f,{x:Math.floor((N.x+E[0])*b[0]+T[0]-xe.SafeBorderPadding),y:Math.floor((N.y+E[1])*b[1]+T[1]-xe.SafeBorderPadding),w:Math.floor(N.w*b[0]+2*xe.SafeBorderPadding),h:Math.floor(N.h*b[1]+2*xe.SafeBorderPadding)}),M.push(U)}p&&(r.scale=p),v&&(r.rotate=v),I&&(r.translate=I);const C=new dt;if(f){this.centerPos=xe.getCenterPos(f,a);const P=h===ze.Stroke&&!D&&!x&&!j;C.attr({...r,normalize:!0,anchor:[.5,.5],bgcolor:P?u:void 0,pos:this.centerPos,size:[(f.w-2*xe.SafeBorderPadding)/b[0],(f.h-2*xe.SafeBorderPadding)/b[1]],zIndex:g});const E=M.map(O=>(O.pos=[O.pos[0]-this.centerPos[0],O.pos[1]-this.centerPos[1]],new Zt(O)));C.append(...E),P&&C.seal(),(D||x||j)&&(this.scaleType=Ve.proportional,this.drawEraserlines({group:C,eraserlines:this.getRenderableEraserLines(this.workOptions),eraserFaces:x,pos:this.centerPos,layer:a},l)),this.replace(a,s,C)}if(p||v||I){const P=C==null?void 0:C.getBoundingClientRect();P&&(f={x:Math.floor(P.x-xe.SafeBorderPadding),y:Math.floor(P.y-xe.SafeBorderPadding),w:Math.floor(P.width+xe.SafeBorderPadding*2),h:Math.floor(P.height+xe.SafeBorderPadding*2)})}return this.isDelete&&C.setAttribute("opacity",0),f}computDrawPoints(e){return this.workOptions.strokeType===ze.Stroke||e.length===1?this.computStroke(e):this.computNomal(e)}computNomal(e){let r=this.workOptions.thickness;const n=e.map(s=>(r=Math.max(r,s.radius),s.point));return{ps:n,rect:et(n,r)}}computStroke(e,r=!0){return e.length===1?this.computDotStroke(e[0]):this.computLineStroke(e,r)}computLineStroke(e,r=!0){const n=[],s=[];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=fe.Per(h).mul(u);n.push(Ae.Sub(l,d)),s.push(Ae.Add(l,d))}const o=e[e.length-1];if(r){const c=Ae.GetSemicircleStroke(o.point,n[n.length-1],-1,8),l=Ae.GetSemicircleStroke(e[0].point,s[0],-1,8),u=n.concat(c,s.reverse(),l);return{ps:u,rect:et(u)}}const a=n.concat(s.reverse());return{ps:a,rect:et(a)}}computDotStroke(e){const{point:r,radius:n}=e,s={x:r.x-n,y:r.y-n,w:n*2,h:n*2};return{ps:Ae.GetDotStroke(r,n,8),rect:s}}transformData(e,r){const{op:n,workState:s}=e;let o=this.tmpPoints.length-1,a=[];if(n!=null&&n.length&&s){const{strokeType:c,thickness:l}=this.workOptions,u=new Set,h=Math.max(0,this.tmpPoints.length-1);c===ze.Stroke?this.updateTempPointsWithPressure(n,l,u):this.updateTempPoints(n,l,u),o=h;const d=r?this.tmpPoints:this.tmpPoints.slice(o);return a=this.getTaskPoints(d,l),{tasks:a,effects:u,consumeIndex:o}}return{tasks:a,consumeIndex:o}}computRadius(e,r){return e*.03*r+r*.5}getMinZ(e,r){return((r||Math.max(1,Math.floor(e*.3)))-e*.5)*100/e/3}getTaskPoints(e,r){var h;const n=[];if(e.length===0)return[];let s=0,o=e[0].x,a=e[0].y,c=[o,a],l=[],u=e[0].t;for(;s<e.length;){const d=e[s],g=d.x-o,p=d.y-a,v=d.z,I=r?this.computRadius(v,r):v;if(l.push({point:new Ae(g,p,v,e[s].v),radius:I}),s>0&&s<e.length-1){const D=e[s].getAngleByPoints(e[s-1],e[s+1]);if(D<60||D>300){const x=(h=l.pop())==null?void 0:h.point.clone();x&&n.push({taskId:u,pos:c,points:[...l,{point:x,radius:I}]}),o=e[s].x,a=e[s].y,c=[o,a];const j=d.x-o,w=d.y-a;l=[{point:new Ae(j,w,v),radius:I}],u=Date.now()}}s++}return n.push({taskId:u,pos:c,points:l}),n}updateTempPointsWithPressure(e,r,n){const s=Date.now(),o=this.tmpPoints.length;let a=o;for(let l=0;l<e.length;l+=2){a=Math.min(a,o);const u=this.tmpPoints.length,h=new Ae(e[l],e[l+1]);if(u===0){this.tmpPoints.push(h);continue}const d=u-1,g=this.tmpPoints[d];if(h.x===g.x&&h.y===g.y){g.z<this.MAX_REPEAR&&g.setz(Math.min(g.z+1,this.MAX_REPEAR));continue}const p=fe.Sub(h,g).uni();if(h.isNear(g,r)){let D=g.z;if(g.z<this.MAX_REPEAR&&(D=Math.min(g.z+1,this.MAX_REPEAR),u>1)){let w=u-1;for(;w>0;){const y=this.tmpPoints[w].distance(this.tmpPoints[w-1]),f=Math.max(this.tmpPoints[w].z-this.uniThickness*y,0);if(this.tmpPoints[w-1].z>=f)break;this.tmpPoints[w-1].setz(f),a=Math.min(a,w-1),w--}}if(a=Math.min(a,d),g.t){h.setz(D),h.setv(p),this.tmpPoints.push(h);continue}const x=this.tmpPoints[d-1],j=x?fe.Sub(h,x).uni():g.v;g.set(h.x,h.y,D,j);continue}h.setv(p);const v=h.distance(g),I=Math.max(g.z-this.uniThickness*v,0);u>1&&fe.Equals(p,g.v,.01)&&(I>0||g.z<=0)&&(g.t||this.tmpPoints.pop(),a=Math.min(d,a)),h.setz(I),this.tmpPoints.push(h)}if(a===1/0)return this.tmpPoints.length;let c=o;if(a===o){c=Math.max(c-1,0);const l=this.tmpPoints[c].t;l&&(n==null||n.add(l))}else{let l=o-1;for(c=a;l>=0;){const u=this.tmpPoints[l].t;if(u&&(n==null||n.add(u),l<=a)){c=l,l=-1;break}l--}}return this.tmpPoints[this.tmpPoints.length-1].setT(s),c}updateTempPoints(e,r,n){var l;const s=Date.now(),o=this.tmpPoints.length;let a=o;for(let u=0;u<e.length;u+=2){const h=this.tmpPoints.length,d=new Ae(e[u],e[u+1]);if(h===0){this.tmpPoints.push(d);continue}const g=h-1,p=this.tmpPoints[g];if(d.x===p.x&&d.y===p.y)continue;const v=fe.Sub(d,p).uni();if(d.isNear(p,r/2)){if(p.t){d.setz(p.z),d.setv(v),this.tmpPoints.push(d),a=Math.min(g,a);continue}const I=this.tmpPoints[g-1],D=I?fe.Sub(d,I).uni():p.v;p.set(d.x,d.y,p.z,D),a=Math.min(g,a);continue}fe.Equals(v,p.v,.01)&&(p.t||this.tmpPoints.pop(),a=Math.min(g,a)),d.setv(v),this.tmpPoints.push(d)}let c=o;if(a===o){c=Math.max(c-1,0);const u=this.tmpPoints[c].t;u&&(n==null||n.add(u))}else{let u=Math.min(o-1,a);for(c=a;u>=0;){const h=(l=this.tmpPoints[u])==null?void 0:l.t;if(h&&(n==null||n.add(h),u<=a)){c=u,u=-1;break}u--}}return this.tmpPoints[this.tmpPoints.length-1].setT(s),c}updateTempPointsWithPressureWhenDone(e){const{thickness:r}=this.workOptions,n=e.length,s=this.getMinZ(r);for(let o=0;o<n;o+=2){const a=this.tmpPoints.length,c=new Ae(e[o],e[o+1]);if(a===0){this.tmpPoints.push(c);continue}const l=a-1,u=this.tmpPoints[l];if(c.x===u.x&&c.y===u.y){u.z<this.MAX_REPEAR&&u.setz(Math.min(u.z+1,this.MAX_REPEAR));continue}const h=fe.Sub(c,u).uni(),d=c.distance(u);if(a>1&&u.z===s)break;if(c.isNear(u,r/2)){let p=u.z;if(n<3&&u.z<this.MAX_REPEAR&&(p=Math.min(u.z+1,this.MAX_REPEAR),a>1)){let D=a-1;for(;D>0;){const x=this.tmpPoints[D].distance(this.tmpPoints[D-1]),j=Math.max(this.tmpPoints[D].z-this.uniThickness*x,-r/4);if(this.tmpPoints[D-1].z>=j)break;this.tmpPoints[D-1].setz(j),D--}}if(u.t){c.setz(p),c.setv(h),this.tmpPoints.push(c);continue}const v=this.tmpPoints[l-1],I=v?fe.Sub(c,v).uni():u.v;u.set(c.x,c.y,p,I);continue}c.setv(h);const g=Math.max(u.z-this.uniThickness*d,s);a>1&&fe.Equals(h,u.v,.01)&&u.z<=0&&(u.t||this.tmpPoints.pop()),c.setz(g),this.tmpPoints.push(c)}}static updateNodeOpt(e){var h,d;const{node:r,opt:n,vNodes:s}=e,{strokeColor:o,strokeType:a,lineCap:c,lineDash:l}=n,u=s.get(r.name);return o&&(r.tagName==="GROUP"?i0e(r)?r.setAttribute("bgcolor",o):r.children.forEach(g=>{g.setAttribute("strokeColor",o),g.getAttribute("fillColor")&&g.setAttribute("fillColor",o)}):(r.setAttribute("strokeColor",o),r.setAttribute("fillColor",o)),(h=u==null?void 0:u.opt)!=null&&h.strokeColor&&(u.opt.strokeColor=o)),a&&(u!=null&&u.opt)&&((d=u.opt)!=null&&d.strokeType)&&(u.opt.strokeType=a),c&&(u!=null&&u.opt)&&(u.opt.lineCap=c),l&&(u!=null&&u.opt)&&(u.opt.lineDash=l),u&&s.setInfo(r.name,u),xe.updateNodeOpt(e)}}class t0 extends xe{constructor(e){super(e);R(this,"toolsType",K.LaserPen);R(this,"canRotate",!1);R(this,"scaleType",Ve.none);R(this,"syncTimestamp");R(this,"syncIndex",0);R(this,"tmpPoints",[]);R(this,"workOptions");R(this,"consumeIndex",0);this.workOptions=e.toolsOpt,this.syncTimestamp=0}combineConsume(){}setWorkOptions(e){super.setWorkOptions(e),this.syncTimestamp=Date.now()}consume(e){const{data:r,isSubWorker:n}=e,{workId:s,op:o,syncUnitTime:a}=r;if((o==null?void 0:o.length)===0)return{type:he.None};if(a&&(this.syncUnitTime=a),this.updateTempPoints(o||[]),this.consumeIndex>this.tmpPoints.length-4)return{type:he.None};const{strokeColor:c,thickness:l,strokeType:u,lineDash:h,lineCap:d}=this.workOptions,g=et(this.tmpPoints,l);let p=!1;const v=this.syncIndex,I=this.tmpPoints.slice(this.consumeIndex);this.consumeIndex=this.tmpPoints.length-1,this.syncTimestamp===0&&(this.syncTimestamp=Date.now());const D={name:s==null?void 0:s.toString(),opacity:1,lineDash:u===ze.Dotted?[h&&h[0]||1,(h&&h[1]||2)*l]:u===ze.LongDotted?[(h&&h[0]||1)*l,(h&&h[1]||2)*l]:void 0,strokeColor:c,lineCap:d,lineWidth:l,anchor:[.5,.5]},x=this.getTaskPoints(I);if(x.length){const w=Date.now();w-this.syncTimestamp>this.syncUnitTime&&(p=!0,this.syncTimestamp=w,this.syncIndex=this.tmpPoints.length),n&&this.draw({attrs:D,tasks:x,isDot:!1,layer:this.drawLayer||this.fullLayer})}const j=[];return this.tmpPoints.slice(v).forEach(w=>{j.push(w.x,w.y)}),{rect:{x:g.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:g.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:g.w*this.fullLayer.worldScaling[0],h:g.h*this.fullLayer.worldScaling[1]},type:he.DrawWork,dataType:Ee.Local,op:p?j:void 0,index:p?v*2:void 0,...this.baseConsumeResult}}consumeAll(){var o;const e=(o=this.workId)==null?void 0:o.toString();let r;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,r=p.rect}else r=et(this.tmpPoints,u);const d={name:e==null?void 0:e.toString(),fillColor:c?l:void 0,opacity:1,lineDash:h===ze.Dotted&&!c?[1,u*2]:h===ze.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 n=[];this.tmpPoints.forEach(a=>{n.push(a.x,a.y)});const s=xt(n);return{rect:r&&{x:r.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:r.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:r.w*this.fullLayer.worldScaling[0],h:r.h*this.fullLayer.worldScaling[1]},type:he.FullWork,dataType:Ee.Local,ops:s,index:this.syncIndex*2,...this.baseConsumeResult}}clearTmpPoints(){this.tmpPoints.length=0,this.syncTimestamp=0,this.syncIndex=0}consumeService(e){var v;const{op:r,replaceId:n,isFullWork:s}=e,{strokeColor:o,thickness:a,strokeType:c}=this.workOptions;if(!r.length){const I=et(this.tmpPoints,a);return{x:I.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:I.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:I.w*this.fullLayer.worldScaling[0],h:I.h*this.fullLayer.worldScaling[1]}}const l=Math.max(0,this.tmpPoints.length-1);this.updateTempPoints(r||[]);let u,h=this.tmpPoints.slice(l);const d=h.length===1;if(d){const I=this.computDotStroke({point:h[0],radius:a/2});h=I.ps,u=I.rect}else u=et(this.tmpPoints,a);const g={name:(v=this.workId)==null?void 0:v.toString(),fillColor:d?o:void 0,opacity:1,lineDash:c===ze.Dotted&&!d?[1,a*2]:c===ze.LongDotted&&!d?[a,a*2]:void 0,strokeColor:o,lineCap:d?void 0:"round",lineWidth:d?0:a,anchor:[.5,.5]},p=this.getTaskPoints(h);if(p.length){const I=s?this.fullLayer:this.drawLayer||this.fullLayer;this.draw({attrs:g,tasks:p,isDot:d,replaceId:n,layer:I})}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:r,radius:n}=e,s={x:r.x-n,y:r.y-n,w:n*2,h:n*2};return{ps:Ae.GetDotStroke(r,n,8),rect:s}}updateTempPoints(e){const r=this.tmpPoints.length;for(let n=0;n<e.length;n+=2){if(r){const s=this.tmpPoints.slice(-1)[0];s&&s.x===e[n]&&s.y===e[n+1]&&this.tmpPoints.pop()}this.tmpPoints.push(new Ae(e[n],e[n+1]))}}async draw(e){const{attrs:r,tasks:n,isDot:s,layer:o}=e,{duration:a}=this.workOptions;for(const c of n){const l=new Zt,{pos:u,points:h}=c;let d;s?d=Jr(h,!0):d=Jr(h,!1),l.attr({...r,pos:u,d}),o.appendChild(l),l.transition(a).attr({scale:s?[.1,.1]:[1,1],lineWidth:s?0:1}).then(()=>{l.remove()})}}getTaskPoints(e){var l;const r=[];if(e.length===0)return[];let n=0,s=e[0].x,o=e[0].y,a=[s,o],c=[];for(;n<e.length;){const u=e[n],h=u.x-s,d=u.y-o;if(c.push(new Ae(h,d)),n>0&&n<e.length-1){const g=e[n].getAngleByPoints(e[n-1],e[n+1]);if(g<60||g>300){const p=(l=c.pop())==null?void 0:l.clone();p&&r.push({pos:a,points:[...c,p]}),s=e[n].x,o=e[n].y,a=[s,o];const v=u.x-s,I=u.y-o;c=[new Ae(v,I)]}}n++}return r.push({pos:a,points:c}),r}removeLocal(){}removeService(e){let r;const n=[];return this.fullLayer.getElementsByName(e).forEach(s=>{if(s.name===e){const o=s.getBoundingClientRect();r=Ge(r,{x:o.x,y:o.y,w:o.width,h:o.height}),n.push(s)}}),n.length&&n.forEach(s=>s.remove()),r}}const Ni=class Ni extends xe{constructor(e,r){super(e);R(this,"canRotate",!1);R(this,"scaleType",Ve.none);R(this,"toolsType",K.Eraser);R(this,"serviceWork");R(this,"tmpPoints",[]);R(this,"workOptions");R(this,"worldPosition");R(this,"worldScaling");R(this,"eraserRect");R(this,"eraserPolyline");this.serviceWork=r,this.workOptions=e.toolsOpt,this.worldPosition=this.fullLayer.worldPosition,this.worldScaling=this.fullLayer.worldScaling}combineConsume(){}consumeService(){}setWorkOptions(e){super.setWorkOptions(e)}createEraserRect(e){const r=e[0]*this.worldScaling[0]+this.worldPosition[0],n=e[1]*this.worldScaling[1]+this.worldPosition[1],{width:s,height:o}=Ni.eraserSizes[this.workOptions.thickness];this.eraserRect={x:r-s*.5,y:n-o*.5,w:s,h:o},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 r=new fe(this.tmpPoints[0],this.tmpPoints[1]),n=new fe(this.tmpPoints[2],this.tmpPoints[3]),s=fe.Sub(n,r).uni(),o=fe.Dist(r,n),{width:a,height:c}=Ni.eraserSizes[this.workOptions.thickness],l=Math.min(a,c),u=Math.round(o/l);if(u>1){const h=[];for(let d=0;d<u;d++){const g=fe.Mul(s,d*l);h.push(this.tmpPoints[0]+g.x,this.tmpPoints[1]+g.y)}return h.concat(e)}}return e}isNear(e,r){const n=new fe(e[0],e[1]),s=new fe(r[0],r[1]),{width:o,height:a}=Ni.eraserSizes[this.workOptions.thickness];return fe.Dist(n,s)<Math.hypot(o,a)*.5}remove(e){const{curNodeMap:r,removeIds:n}=e;let s;for(const o of r.values())if(o.rect&&this.eraserRect&&this.eraserPolyline&&va(this.eraserRect,o.rect)){const{op:a}=o,c=[],l=[];for(let h=0;h<a.length;h+=3){const d=new fe(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 Ae(d.x,d.y))}const u=c.length&&et(c)||o.rect;va(u,this.eraserRect)&&(l.length>1?wu.polyline(l.map(d=>d.XY),this.eraserPolyline).length&&n.add(o.name):n.add(o.name),s=Ge(s,o.rect||u))}return n.forEach(o=>{var c;const a=this.fullLayer.getElementsByName(o);a[0]&&(a[0].remove(),cr(a[0],this.fullLayer.parent),(c=this.vNodes)==null||c.delete(o))}),s&&(s.x-=xe.SafeBorderPadding,s.y-=xe.SafeBorderPadding,s.w+=xe.SafeBorderPadding*2,s.h+=xe.SafeBorderPadding*2),s}consume(e){const{op:r,disableEraseImage:n,disableEraseText:s}=e.data;if(!r||r.length===0)return{type:he.None,...this.baseConsumeResult};const o=this.tmpPoints.length;if(o>1&&this.isNear([r[0],r[1]],[this.tmpPoints[o-2],this.tmpPoints[o-1]]))return{type:he.None,...this.baseConsumeResult};o<3?this.tmpPoints.push(r[0],r[1]):this.tmpPoints.splice(2,2,r[0],r[1]);const a=this.computRectCenterPoints();let c;const l=new Set;if(!this.vNodes)return{type:he.None,...this.baseConsumeResult};const u=this.getCanEraserNodeMap(this.vNodes.getCanEraserNodes(this.vNodes.curNodeMap,{disableEraseImage:n,disableEraseText:s}));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=Ge(c,d)}return c&&l.size?{type:he.RemoveNode,rect:c,removeIds:[...l]}:{type:he.None,...this.baseConsumeResult}}consumeAll(e){return this.consume(e)}clearTmpPoints(){this.tmpPoints.length=0}getCanEraserNodeMap(e){var r;if(this.serviceWork){const n=new Map(e),s=this.serviceWork.selectorWorkShapes,o=this.serviceWork.workShapes;for(const a of s.values())if((r=a.selectIds)!=null&&r.length)for(const c of a.selectIds)n.delete(c);for(const a of o.keys())n.delete(a);return n}return e}};R(Ni,"eraserSizes",Ph);let da=Ni;const Rt="++",De="selector",ou="all";var bge="__lodash_hash_undefined__";function xge(i){return this.__data__.set(i,bge),this}var Ege=xge;function Age(i){return this.__data__.has(i)}var Nge=Age,Dge=Sy,Pge=Ege,kge=Nge;function fa(i){var t=-1,e=i==null?0:i.length;for(this.__data__=new Dge;++t<e;)this.add(i[t])}fa.prototype.add=fa.prototype.push=Pge;fa.prototype.has=kge;var kh=fa;function Lge(i,t){for(var e=-1,r=i==null?0:i.length;++e<r;)if(t(i[e],e,i))return!0;return!1}var Rge=Lge;function Oge(i,t){return i.has(t)}var Lh=Oge,zge=kh,jge=Rge,Bge=Lh,Uge=1,Fge=2;function Wge(i,t,e,r,n,s){var o=e&Uge,a=i.length,c=t.length;if(a!=c&&!(o&&c>a))return!1;var l=s.get(i),u=s.get(t);if(l&&u)return l==t&&u==i;var h=-1,d=!0,g=e&Fge?new zge:void 0;for(s.set(i,t),s.set(t,i);++h<a;){var p=i[h],v=t[h];if(r)var I=o?r(v,p,h,t,i,s):r(p,v,h,i,t,s);if(I!==void 0){if(I)continue;d=!1;break}if(g){if(!jge(t,function(D,x){if(!Bge(g,x)&&(p===D||n(p,D,e,r,s)))return g.push(x)})){d=!1;break}}else if(!(p===v||n(p,v,e,r,s))){d=!1;break}}return s.delete(i),s.delete(t),d}var r0=Wge;function $ge(i){var t=-1,e=Array(i.size);return i.forEach(function(r,n){e[++t]=[n,r]}),e}var Vge=$ge;function Yge(i){var t=-1,e=Array(i.size);return i.forEach(function(r){e[++t]=r}),e}var Rh=Yge,Tg=qs,Sg=Wy,Gge=mh,Hge=r0,Qge=Vge,Zge=Rh,Kge=1,qge=2,Xge="[object Boolean]",Jge="[object Date]",_ge="[object Error]",epe="[object Map]",tpe="[object Number]",rpe="[object RegExp]",npe="[object Set]",ipe="[object String]",spe="[object Symbol]",ope="[object ArrayBuffer]",ape="[object DataView]",Ig=Tg?Tg.prototype:void 0,ul=Ig?Ig.valueOf:void 0;function cpe(i,t,e,r,n,s,o){switch(e){case ape:if(i.byteLength!=t.byteLength||i.byteOffset!=t.byteOffset)return!1;i=i.buffer,t=t.buffer;case ope:return!(i.byteLength!=t.byteLength||!s(new Sg(i),new Sg(t)));case Xge:case Jge:case tpe:return Gge(+i,+t);case _ge:return i.name==t.name&&i.message==t.message;case rpe:case ipe:return i==t+"";case epe:var a=Qge;case npe:var c=r&Kge;if(a||(a=Zge),i.size!=t.size&&!c)return!1;var l=o.get(i);if(l)return l==t;r|=qge,o.set(i,t);var u=Hge(a(i),a(t),r,n,s,o);return o.delete(i),u;case spe:if(ul)return ul.call(i)==ul.call(t)}return!1}var lpe=cpe,Cg=By,upe=1,hpe=Object.prototype,dpe=hpe.hasOwnProperty;function fpe(i,t,e,r,n,s){var o=e&upe,a=Cg(i),c=a.length,l=Cg(t),u=l.length;if(c!=u&&!o)return!1;for(var h=c;h--;){var d=a[h];if(!(o?d in t:dpe.call(t,d)))return!1}var g=s.get(i),p=s.get(t);if(g&&p)return g==t&&p==i;var v=!0;s.set(i,t),s.set(t,i);for(var I=o;++h<c;){d=a[h];var D=i[d],x=t[d];if(r)var j=o?r(x,D,d,t,i,s):r(D,x,d,i,t,s);if(!(j===void 0?D===x||n(D,x,e,r,s):j)){v=!1;break}I||(I=d=="constructor")}if(v&&!I){var w=i.constructor,y=t.constructor;w!=y&&"constructor"in i&&"constructor"in t&&!(typeof w=="function"&&w instanceof w&&typeof y=="function"&&y instanceof y)&&(v=!1)}return s.delete(i),s.delete(t),v}var gpe=fpe,hl=Iy,ppe=r0,mpe=lpe,ype=gpe,bg=sc,xg=Xs,Eg=vh,vpe=Dy,Mpe=1,Ag="[object Arguments]",Ng="[object Array]",Bo="[object Object]",wpe=Object.prototype,Dg=wpe.hasOwnProperty;function Tpe(i,t,e,r,n,s){var o=xg(i),a=xg(t),c=o?Ng:bg(i),l=a?Ng:bg(t);c=c==Ag?Bo:c,l=l==Ag?Bo:l;var u=c==Bo,h=l==Bo,d=c==l;if(d&&Eg(i)){if(!Eg(t))return!1;o=!0,u=!1}if(d&&!u)return s||(s=new hl),o||vpe(i)?ppe(i,t,e,r,n,s):mpe(i,t,c,e,r,n,s);if(!(e&Mpe)){var g=u&&Dg.call(i,"__wrapped__"),p=h&&Dg.call(t,"__wrapped__");if(g||p){var v=g?i.value():i,I=p?t.value():t;return s||(s=new hl),n(v,I,e,r,s)}}return d?(s||(s=new hl),ype(i,t,e,r,n,s)):!1}var Spe=Tpe,Ipe=Spe,Pg=Nr;function n0(i,t,e,r,n){return i===t?!0:i==null||t==null||!Pg(i)&&!Pg(t)?i!==i&&t!==t:Ipe(i,t,e,r,n0,n)}var Cpe=n0,bpe=Cpe;function xpe(i,t){return bpe(i,t)}var Epe=xpe;const Zr=en(Epe);function Js(i,t,e){return"#"+((i<<16)+(t<<8)+e).toString(16).padStart(6,"0")}function St(i,t=1){return"rgba("+parseInt("0x"+i.slice(1,3))+","+parseInt("0x"+i.slice(3,5))+","+parseInt("0x"+i.slice(5,7))+","+t+")"}function $n(i,t,e,r=1){return`rgba(${i},${t},${e},${r})`}function ac(i){const t=i.split(","),e=parseInt(t[0].split("(")[1]),r=parseInt(t[1]),n=parseInt(t[2]),s=Number(t[3].split(")")[0]);return[Js(e,r,n),s]}function ws(i){const t=i.split(","),e=parseInt(t[0].split("(")[1]),r=parseInt(t[1]),n=parseInt(t[2]),s=Number(t[3].split(")")[0]);return[e,r,n,s]}function Uo(i){return i==="transparent"}const Ta=class Ta extends xe{constructor(e){super(e);R(this,"toolsType",K.Selector);R(this,"tmpPoints",[]);R(this,"subTmpPoints",[]);R(this,"workOptions");R(this,"vNodes");R(this,"selectIds");R(this,"selectorColor");R(this,"strokeColor");R(this,"fillColor");R(this,"oldSelectRect");R(this,"oldSubSelectRect");R(this,"canRotate",!1);R(this,"canTextEdit",!1);R(this,"canLock",!1);R(this,"scaleType",Ve.all);R(this,"toolsTypes");R(this,"shapeOpt");R(this,"textOpt");R(this,"isLocked");R(this,"thickness");R(this,"strokeType");R(this,"useStroke");this.workOptions=e.toolsOpt,this.vNodes=e.vNodes}computSelector(e=!0){const r=et(this.tmpPoints);if(r.w===0||r.h===0)return{selectIds:[],intersectRect:void 0,subNodeMap:new Map};const{rectRange:n,nodeRange:s}=this.vNodes.getRectIntersectRange(r,e);return{selectIds:[...s.keys()],intersectRect:n,subNodeMap:s}}updateTempPoints(e){const r=this.tmpPoints.length,n=e.length;if(n>1){const s=new Ae(e[n-2]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],e[n-1]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[1]);r===2?this.tmpPoints.splice(1,1,s):this.tmpPoints.push(s)}}drawSelector(e){const{drawRect:r,subNodeMap:n,selectorId:s,layer:o,isService:a}=e,c=new dt({pos:[r.x,r.y],anchor:[0,0],size:[r.w,r.h],id:s,name:s,zIndex:9999}),l=[];if(a){const u=new ks({normalize:!0,pos:[r.w/2,r.h/2],lineWidth:1,strokeColor:this.selectorColor||this.workOptions.strokeColor,width:r.w,height:r.h,name:Ta.selectorBorderId});l.push(u)}n.forEach((u,h)=>{const d=[u.rect.x+u.rect.w/2-r.x,u.rect.y+u.rect.h/2-r.y],g=new ks({normalize:!0,pos:d,lineWidth:1,strokeColor:n.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),(o==null?void 0:o.parent).appendChild(c)}draw(e,r,n,s=!1){var c,l;const{intersectRect:o,subNodeMap:a}=n;(l=(c=r.parent)==null?void 0:c.getElementById(e))==null||l.remove(),o&&this.drawSelector({drawRect:o,subNodeMap:a,selectorId:e,layer:r,isService:s})}getSelecteorInfo(e){this.scaleType=Ve.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 r=new Set;let n,s=!0;for(const o of e.values()){const{opt:a,canRotate:c,scaleType:l,toolsType:u}=o;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!==K.Pencil&&(s=!1),a.strokeType&&(this.strokeType=a.strokeType),u===K.SpeechBalloon&&(r.add(u),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.placement=a.placement),u===K.Polygon&&(r.add(u),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=a.vertices),u===K.Star&&(r.add(u),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=a.vertices,this.shapeOpt.innerRatio=a.innerRatio,this.shapeOpt.innerVerticeStep=a.innerVerticeStep),u===K.Text&&(this.textOpt=a),e.size===1&&(this.textOpt&&(this.canTextEdit=!0),this.canRotate=c,this.scaleType=l),(u===K.Image||u===K.BackgroundSVG)&&(n=o),(l===Ve.proportional&&this.scaleType!==Ve.none||l===Ve.none)&&(this.scaleType=l)}s&&(this.useStroke=!0),r.size&&(this.toolsTypes=[...r]),n&&(e.size===1?(this.canLock=!0,n.opt.locked&&(this.isLocked=!0,this.scaleType=Ve.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&&!n.opt.locked&&(this.canLock=!1,this.canRotate=!1))}getChildrenPoints(){var e,r;if(this.scaleType===Ve.both&&((e=this.selectIds)==null?void 0:e.length)===1){const n=this.selectIds[0],s=(r=this.vNodes.get(n))==null?void 0:r.op;if(s){const o=[];for(let a=0;a<s.length;a+=3)o.push([s[a],s[a+1]]);return o}}}consume(e){if(e.isSubWorker)return this.subWorkerConsume(e);let r={type:he.Select,dataType:Ee.Local,...this.baseConsumeResult};if(e.isSimpleWorker){const u=this.subWorkerConsume(e);r.subRect=u.rect}const{op:n,workState:s}=e.data;let o=this.oldSelectRect;if(s===ge.Start&&(o=this.unSelectedAllIds()),!(n!=null&&n.length)||!this.vNodes.curNodeMap.size)return e.isSimpleWorker?r:{type:he.None};this.updateTempPoints(n);const a=this.computSelector();if(this.selectIds&&Zr(this.selectIds,a.selectIds))return e.isSimpleWorker?r:{type:he.None};this.selectIds=a.selectIds;const c=a.intersectRect;this.getSelecteorInfo(a.subNodeMap),this.draw(De,this.fullLayer,a),this.oldSelectRect=c;const l=this.getChildrenPoints();return r={...r,rect:Ge(c,o),selectIds:a.selectIds,selectRect:c,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:l,isLocked:this.isLocked,toolsTypes:this.toolsTypes,shapeOpt:this.shapeOpt,thickness:this.thickness,useStroke:this.useStroke,strokeType:this.strokeType},r}consumeAll(){var r,n;let e=this.oldSelectRect;if(!((r=this.selectIds)!=null&&r.length)&&this.tmpPoints[0]&&this.selectSingleTool(this.tmpPoints[0].XY,De,!1),(n=this.selectIds)!=null&&n.length&&(e=this.selectedByIds(this.selectIds)),e){const s=this.getChildrenPoints();return{type:he.Select,dataType:Ee.Local,rect:this.oldSelectRect,selectIds:this.selectIds,selectorColor:this.selectorColor,selectRect:this.oldSelectRect,strokeColor:this.strokeColor,fillColor:this.fillColor,textOpt:this.textOpt,canTextEdit:this.canTextEdit,canRotate:this.canRotate,canLock:this.canLock,scaleType:this.scaleType,willSyncService:!0,points:s,isLocked:this.isLocked,toolsTypes:this.toolsTypes,shapeOpt:this.shapeOpt,thickness:this.thickness,useStroke:this.useStroke,strokeType:this.strokeType,...this.baseConsumeResult}}return{type:he.Select,dataType:Ee.Local,...this.baseConsumeResult}}consumeService(){}updateTempPointsForSubWorker(e){const r=e.slice(-2),n=new Ae(r[0],r[1]);if(this.subTmpPoints[0].isNear(n,1))return!1;if(this.subTmpPoints.length===2){if(n.isNear(this.subTmpPoints[1],1))return!1;this.subTmpPoints[1]=n}else this.subTmpPoints.push(n);return!0}computDrawPoints(e){const{thickness:r}=this.workOptions,n=[];for(const a of e)n.push(new fe(...a));const s=et(n,r),o=[s.x+s.w/2,s.y+s.h/2];return{rect:s,pos:o,points:n.map(a=>a.XY).flat(1)}}drawForSubWorker(e){const{workId:r,layer:n,ps:s}=e,{strokeColor:o,scale:a,rotate:c,translate:l}=this.workOptions,u=n.worldPosition,h=n.worldScaling,{points:d,rect:g,pos:p}=this.computDrawPoints(s),v=1/n.worldScaling[0],I=o&&ws(o)||[0,0,0,0],D={close:!0,normalize:!0,points:d,lineWidth:v,fillColor:$n(I[0],I[1],I[2],.1),strokeColor:$n(I[0],I[1],I[2],1),lineJoin:"round",lineCap:"round"};let x={x:Math.floor(g.x*h[0]+u[0]-xe.SafeBorderPadding),y:Math.floor(g.y*h[1]+u[1]-xe.SafeBorderPadding),w:Math.floor(g.w*h[0]+2*xe.SafeBorderPadding),h:Math.floor(g.h*h[0]+2*xe.SafeBorderPadding)};const j=new dt({name:r,id:r,pos:p,anchor:[.5,.5],size:[g.w,g.h],scale:a,rotate:c,translate:l}),w=new wr({...D,pos:[0,0]});if(j.appendChild(w),this.replace(n,r,j),a||c||l){const y=j.getBoundingClientRect();x={x:Math.floor(y.x-xe.SafeBorderPadding),y:Math.floor(y.y-xe.SafeBorderPadding),w:Math.floor(y.width+2*xe.SafeBorderPadding),h:Math.floor(y.height+2*xe.SafeBorderPadding)}}return x}transformData(e){const r=et(e);return[[r.x,r.y,0],[r.x+r.w,r.y,0],[r.x+r.w,r.y+r.h,0],[r.x,r.y+r.h,0]]}subWorkerConsume(e){const{data:r,isFullWork:n}=e,{op:s,syncUnitTime:o}=r;o&&(this.syncUnitTime=o);const a=s==null?void 0:s.length;if(!a||a<2)return{type:he.None,rect:void 0};let c;if(this.subTmpPoints.length===0?(this.subTmpPoints=[new Ae(s[0],s[1])],c=!1):c=this.updateTempPointsForSubWorker(s),!c)return{type:he.None,rect:void 0};const l=this.transformData(this.subTmpPoints),u=n?this.fullLayer:this.drawLayer||this.fullLayer,h=this.drawForSubWorker({ps:l,workId:this.workId,layer:u}),d=Ge(h,this.oldSubSelectRect);return this.oldSubSelectRect=h,{rect:d,type:he.DrawWork,dataType:Ee.Local,...this.baseConsumeResult}}subWorkerConsumeAll(e){const{isFullWork:r}=e,n=r?this.fullLayer:this.drawLayer||this.fullLayer;return this.replace(n,this.workId),{rect:this.oldSelectRect,type:he.FullWork,dataType:Ee.Local,...this.baseConsumeResult}}clearSubTmpPoints(){this.subTmpPoints.length=0}clearTmpPoints(){this.tmpPoints.length=0,this.clearSubTmpPoints()}clearSubSelectData(){this.oldSubSelectRect=void 0}clearSelectData(){this.selectIds=void 0,this.oldSelectRect=void 0,this.clearSubSelectData()}selectSingleTool(e,r=De,n=!1){if(e.length===2){const s=e[0],o=e[1];let a;const{nodeRange:c}=this.vNodes.getRectIntersectRange({x:s,y:o,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(y0(h).find(g=>g.isPointCollision(s,o))){a=u;break}}if(a){const u=a.name;if(!Zr(this.oldSelectRect,a.rect)){const h=new Map([[u,a]]);this.getSelecteorInfo(h),this.draw(r,this.fullLayer,{intersectRect:a.rect,subNodeMap:h,selectIds:this.selectIds||[]},n)}this.selectIds=[u],this.oldSelectRect=a.rect}}}unSelectedAllIds(){let e;for(const[r,n]of this.vNodes.curNodeMap.entries())n.isSelected&&(e=Ge(e,n.rect),this.vNodes.unSelected(r));return e}unSelectedByIds(e){let r;for(const n of e){const s=this.vNodes.get(n);s&&s.isSelected&&(r=Ge(r,s.rect),this.vNodes.unSelected(n))}return r}selectedByIds(e){let r;for(const n of e){const s=this.vNodes.get(n);s&&(r=Ge(r,s.rect),this.vNodes.selected(n))}return r}getSelectorRect(e,r){var a;let n;const s=(a=e.parent)==null?void 0:a.getElementById(r),o=s==null?void 0:s.getBoundingClientRect();return o&&(n=Ge(n,{x:Math.floor(o.x),y:Math.floor(o.y),w:Math.floor(o.width+1),h:Math.floor(o.height+1)})),n}isCanFillColor(e){return e===K.Ellipse||e===K.Triangle||e===K.Rectangle||e===K.Polygon||e===K.Star||e===K.SpeechBalloon}async updateSelector(e){const{updateSelectorOpt:r,selectIds:n,vNodes:s,willSerializeData:o,worker:a,offset:c}=e,l=this.fullLayer;if(!l)return;let u;const h=new Map,{originPoint:d,workState:g,angle:p,translate:v,dir:I,scale:D}=r;c&&(v?r.translate=[v[0]+c[0],v[1]+c[1]]:r.translate=c);let x;if(d||v||It(p)){if(g===ge.Start&&n)return s.setTargetAssignKeys(n),{type:he.Select,dataType:Ee.Local,selectRect:this.oldSelectRect,rect:this.oldSelectRect};if(x=s.getLastTarget(),!x)return}if(n)for(const y of n){const f=s.get(y);if(f){const{toolsType:M,opt:T}=f,b=(l==null?void 0:l.getElementsByName(y))[0];if(b){const C={...r};let P;const E=xe.isWillRefresh({toolsType:M,opt:T,updateOpt:C,vNodes:s,node:b,willSerializeData:o});if(M){P=x==null?void 0:x.get(y);const O=lc(M);O==null||O.updateNodeOpt({node:b,opt:C,vNodes:s,willSerializeData:o,targetNode:P});const V=s.get(y)||f;if(V&&a&&E){const N=a.createWorkShapeNode({workId:y,toolsType:M,toolsOpt:V.opt});N==null||N.setWorkId(y);let A;if(M===K.BackgroundSVG)A=N.consumeService({isFullWork:!0,replaceId:y});else if(M===K.Image)A=await N.consumeServiceAsync({isFullWork:!0,replaceId:y,worker:a});else if(M===K.Text)A=await N.consumeServiceAsync({isFullWork:!0,replaceId:y,isDrawLabel:!0});else try{A=N==null?void 0:N.consumeService({op:V.op,isFullWork:!0,replaceId:y,workState:g})}catch(k){console.error("consumeService error",k);continue}A&&(V.rect=A)}V&&(h.set(y,V),u=Ge(u,V.rect))}}}}x&&g===ge.Done&&(s.deleteLastTarget(),x=void 0);const j=u;if(d&&v&&D&&I&&j&&!c){const y=[[j.x,j.y],[j.x+j.w,j.y],[j.x+j.w,j.y+j.h],[j.x,j.y+j.h]];let f;switch(I){case"top":case"topLeft":case"left":v[0]>0&&v[1]>0?f=y[0]:v[0]>0?f=y[3]:v[1]>0?f=y[1]:f=y[2];break;case"topRight":v[0]<0&&v[1]>0?f=y[1]:v[0]<0?f=y[2]:v[1]>0?f=y[0]:f=y[3];break;case"right":case"bottomRight":case"bottom":v[0]<0&&v[1]<0?f=y[2]:v[0]<0?f=y[1]:v[1]<0?f=y[3]:f=y[0];break;case"bottomLeft":v[0]>0&&v[1]<0?f=y[3]:v[0]>0?f=y[0]:v[1]<0?f=y[2]:f=y[1];break}const M=f&&[d[0]-f[0],d[1]-f[1]]||[0,0];if(!Zr(M,[0,0]))return await this.updateSelector({...e,updateSelectorOpt:{workState:g},offset:M})}this.getSelecteorInfo(h),this.draw(De,l,{selectIds:n||[],subNodeMap:h,intersectRect:j});const w=Ge(this.oldSelectRect,j);return this.oldSelectRect=j,{type:he.Select,dataType:Ee.Local,selectRect:j,renderRect:u,rect:Ge(w,j),selectIds:n}}blurSelector(){const e=this.unSelectedAllIds();return{type:he.Select,dataType:Ee.Local,rect:e,selectIds:[],willSyncService:!0}}getRightServiceId(e){return e.replace(Rt,"-")}selectServiceNode(e,r,n){const{selectIds:s}=r,o=this.getRightServiceId(e),a=this.getSelectorRect(this.fullLayer,o);let c;const l=new Map;return s==null||s.forEach(u=>{const h=this.vNodes.get(u);h&&(c=Ge(c,h.rect),l.set(u,h))}),this.getSelecteorInfo(l),this.draw(o,this.fullLayer,{intersectRect:c,selectIds:s||[],subNodeMap:l},n),Ge(c,a)}reRenderSelector(){var n;let e;const r=new Map;return(n=this.selectIds)==null||n.forEach(s=>{const o=this.vNodes.get(s);o&&(e=Ge(e,o.rect),r.set(s,o))},this),this.getSelecteorInfo(r),this.draw(De,this.fullLayer,{intersectRect:e,subNodeMap:r,selectIds:this.selectIds||[]}),this.oldSelectRect=e,e}updateSelectIds(e){var o;let r;const n=(o=this.selectIds)==null?void 0:o.filter(a=>!e.includes(a));if(n!=null&&n.length&&(r=this.unSelectedByIds(n)),e.length){const a=this.selectedByIds(e);r=Ge(r,a)}this.selectIds=e;const s=this.reRenderSelector();return{bgRect:r,selectRect:s}}cursorHover(e){var o,a;const r=this.oldSelectRect;this.selectIds=[];const n=(o=this.workId)==null?void 0:o.toString(),s=[e[0]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],e[1]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[1]];if(this.selectSingleTool(s,n,!0),this.oldSelectRect&&!Zr(r,this.oldSelectRect))return{type:he.CursorHover,dataType:Ee.Local,rect:Ge(r,this.oldSelectRect),selectorColor:this.selectorColor,willSyncService:!1};if((a=this.selectIds)!=null&&a.length||(this.oldSelectRect=void 0),r&&!this.oldSelectRect)return this.cursorBlur(),{type:he.CursorHover,dataType:Ee.Local,rect:r,selectorColor:this.selectorColor,willSyncService:!1}}cursorBlur(){var r,n;this.selectIds=[];const e=(r=this.workId)==null?void 0:r.toString();((n=this.fullLayer)==null?void 0:n.parent).children.forEach(s=>{s.name===e&&s.remove()})}};R(Ta,"selectorBorderId","selector-border");let ga=Ta;class i0 extends xe{constructor(e){super(e);R(this,"canRotate",!1);R(this,"scaleType",Ve.both);R(this,"toolsType",K.Arrow);R(this,"tmpPoints",[]);R(this,"workOptions");R(this,"oldRect");R(this,"arrowTipWidth");R(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.arrowTipWidth=this.workOptions.thickness*4,this.syncTimestamp=0,this.syncUnitTime=50}static normalizeStorageData(e){return this.normalizeDrawableStorageData(e)}consume(e){const{data:r,isFullWork:n,isSubWorker:s,isMainThread:o,smoothSync:a,isSimpleWorker:c}=e,l=this.workId,{op:u,syncUnitTime:h}=r;h&&(this.syncUnitTime=h);const d=u==null?void 0:u.length;if(!d||d<2)return{type:he.None};let g;if(this.tmpPoints.length===0?(this.tmpPoints=[new Ae(u[0],u[1])],g=!1):g=this.updateTempPoints(u),!g)return{type:he.None};let p;if(s||o||c){const I=n?this.fullLayer:this.drawLayer||this.fullLayer;p=this.draw({workId:l,layer:I})}if(c){const I=Ge(p,this.oldRect);this.oldRect=p;const D={rect:I,type:he.DrawWork,dataType:Ee.Local,...this.baseConsumeResult};if(a){const x=Date.now();x-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=x,D.op=this.tmpPoints.map(j=>[...j.XY,0]).flat(1),D.index=0,D.isSync=!0)}return D}if(!s&&a){const I=Date.now();return I-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=I,{...this.baseConsumeResult,type:he.DrawWork,dataType:Ee.Local,op:this.tmpPoints.map(D=>[...D.XY,0]).flat(1),isSync:!0,index:0}):{type:he.None}}const v=Ge(p,this.oldRect);return this.oldRect=p,{rect:v,...this.baseConsumeResult,type:he.DrawWork,dataType:Ee.Local}}consumeAll(){var a;const e=this.workId;if(this.tmpPoints.length<2)return{type:he.RemoveNode,removeIds:[e]};const r=this.fullLayer,n=this.draw({workId:e,layer:r});this.oldRect=n;const s=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),o=xt(s);return(a=this.vNodes)==null||a.setInfo(e,{rect:n,op:s,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:xe.getCenterPos(n,r)}),{rect:n,...this.baseConsumeResult,type:he.FullWork,dataType:Ee.Local,ops:o,isSync:!0,updateNodeOpt:{useAnimation:!0}}}draw(e){const{workId:r,layer:n,isDrawEraserlines:s}=e,{strokeColor:o,thickness:a,zIndex:c,scale:l,rotate:u,translate:h,strokeType:d,eraserlines:g,eraserFaces:p,doingLines:v,lineDash:I,lineCap:D}=this.workOptions,x=n.worldPosition,j=n.worldScaling,{points:w,pos:y,rect:f,isTriangle:M,trianglePoints:T,trianglePos:b}=this.computDrawPoints(a),C=[f.x+f.w/2,f.y+f.h/2],P={pos:C,name:r,id:r,zIndex:c,anchor:[.5,.5],size:[f.w,f.h]};l&&(P.scale=l),u&&(P.rotate=u),h&&(P.translate=h);const E=new dt(P),O={points:T,pos:[b[0]-C[0],b[1]-C[1]],fillColor:o,strokeColor:o,lineWidth:0,normalize:!1},V=new wr(O);if(E.append(V),!M&&w&&y){const A={points:w,pos:[y[0]-C[0],y[1]-C[1]],fillColor:o,strokeColor:o,lineDash:d===ze.Dotted?[I&&I[0]||1,(I&&I[1]||2)*a]:d===ze.LongDotted?[(I&&I[0]||1)*a,(I&&I[1]||2)*a]:void 0,lineCap:d===ze.Normal?void 0:D,lineWidth:a,normalize:!1},k=new wr(A);E.append(k)}(g||p||v)&&(this.scaleType=Ve.proportional,this.drawEraserlines({group:E,eraserlines:this.getRenderableEraserLines(this.workOptions),eraserFaces:p,pos:C,layer:n},s)),this.replace(n,r,E);let N={x:Math.floor(f.x*j[0]+x[0]-xe.SafeBorderPadding),y:Math.floor(f.y*j[1]+x[1]-xe.SafeBorderPadding),w:Math.floor(f.w*j[0]+2*xe.SafeBorderPadding),h:Math.floor(f.h*j[1]+2*xe.SafeBorderPadding)};if(l||u||h){const A=E.getBoundingClientRect();N={x:Math.floor(A.x-xe.SafeBorderPadding),y:Math.floor(A.y-xe.SafeBorderPadding),w:Math.floor(A.width+xe.SafeBorderPadding*2),h:Math.floor(A.height+xe.SafeBorderPadding*2)}}return this.isDelete&&E.setAttribute("opacity",0),N}computDrawPoints(e){return this.tmpPoints[1].distance(this.tmpPoints[0])>this.arrowTipWidth?this.computFullArrowPoints(e):this.computTrianglePoints()}computFullArrowPoints(e){const r=fe.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),n=fe.Per(r).mul(e/2),s=Ae.Sub(this.tmpPoints[0],n),o=Ae.Add(this.tmpPoints[0],n),a=fe.Mul(r,this.arrowTipWidth),c=fe.Sub(this.tmpPoints[1],a),l=Ae.Sub(c,n),u=Ae.Add(c,n),h=fe.Per(r).mul(e*1.5),d=Ae.Sub(c,h),g=Ae.Add(c,h),p=[this.tmpPoints[0],c],v=[d,this.tmpPoints[1],g],I=[s,o,...v,l,u];return{trianglePoints:v.map(D=>Ae.Sub(D,this.tmpPoints[1]).XY).flat(1),trianglePos:this.tmpPoints[1].XY,points:p.map(D=>Ae.Sub(D,this.tmpPoints[0]).XY).flat(1),rect:et(I),isTriangle:!1,pos:this.tmpPoints[0].XY}}computTrianglePoints(){const e=fe.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),r=this.tmpPoints[1].distance(this.tmpPoints[0]),n=fe.Per(e).mul(Math.floor(r*3/8)),s=Ae.Sub(this.tmpPoints[0],n),o=Ae.Add(this.tmpPoints[0],n),a=[s,this.tmpPoints[1],o];return{trianglePoints:a.map(c=>Ae.Sub(c,this.tmpPoints[1]).XY).flat(1),trianglePos:this.tmpPoints[1].XY,rect:et(a),isTriangle:!0}}updateTempPoints(e){const r=e.slice(-2),n=new Ae(r[0],r[1]),s=this.tmpPoints[0],{thickness:o}=this.workOptions;if(s.isNear(n,o))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n}else this.tmpPoints.push(n);return!0}consumeService(e){var l,u;const{op:r,isFullWork:n,workState:s=ge.Done}=e,o=(l=this.workId)==null?void 0:l.toString();if(!o)return;this.tmpPoints.length=0;for(let h=0;h<r.length;h+=3)this.tmpPoints.push(new Ae(r[h],r[h+1],r[h+2]));const a=n?this.fullLayer:this.drawLayer||this.fullLayer,c=this.draw({workId:o,layer:a,isDrawEraserlines:s===ge.Done});return this.oldRect=c,(u=this.vNodes)==null||u.setInfo(o,{rect:c,op:r,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:xe.getCenterPos(c,a)}),c}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var l,u;const{node:r,opt:n,vNodes:s}=e,{strokeColor:o,strokeType:a}=n,c=s.get(r.name);return o&&(r.tagName==="GROUP"?r.children.forEach(h=>{h.setAttribute("strokeColor",o),h.getAttribute("fillColor")&&h.setAttribute("fillColor",o)}):(r.setAttribute("strokeColor",o),r.setAttribute("fillColor",o)),(l=c==null?void 0:c.opt)!=null&&l.strokeColor&&(c.opt.strokeColor=o)),a&&(c!=null&&c.opt)&&((u=c.opt)!=null&&u.strokeType)&&(c.opt.strokeType=a),c&&s.setInfo(r.name,c),xe.updateNodeOpt(e)}}class s0 extends xe{constructor(e){super(e);R(this,"canRotate",!1);R(this,"scaleType",Ve.all);R(this,"toolsType",K.Ellipse);R(this,"tmpPoints",[]);R(this,"workOptions");R(this,"oldRect");R(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}static normalizeStorageData(e){return this.normalizeDrawableStorageData(e)}consume(e){const{data:r,isFullWork:n,isSubWorker:s,isMainThread:o,smoothSync:a,isSimpleWorker:c}=e,l=this.workId,{op:u,syncUnitTime:h}=r;h&&(this.syncUnitTime=h);const d=u==null?void 0:u.length;if(!d||d<2)return{type:he.None};let g;if(this.tmpPoints.length===0?(this.tmpPoints=[new Ae(u[0],u[1])],g=!1):g=this.updateTempPoints(u),!g)return{type:he.None};let p;if(s||o||c){const v=n?this.fullLayer:this.drawLayer||this.fullLayer;p=this.draw({workId:l,layer:v,isDrawing:!0});const I=v.parent.parent,D={x:0,y:0,w:Math.floor(I.width),h:Math.floor(I.height)},x={type:he.DrawWork,dataType:Ee.Local,...this.baseConsumeResult};if(hc(p,D)!==Kr.outside){const w=Ge(p,this.oldRect);if(this.oldRect=p,x.rect=w,!c)return x}if(c){const w=Date.now();return w-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=w,x.op=this.tmpPoints.map(y=>[...y.XY,0]).flat(1),x.index=0,x.isSync=!0),x}return{type:he.None}}if(!s&&!o&&!c&&a){const v=Date.now();return v-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=v,{type:he.DrawWork,dataType:Ee.Local,...this.baseConsumeResult,op:this.tmpPoints.map(I=>[...I.XY,0]).flat(1),isSync:!0,index:0}):{type:he.None}}return{type:he.None}}consumeAll(){var a;const e=this.workId;if(this.tmpPoints.length<2)return{type:he.RemoveNode,removeIds:[e]};const r=this.fullLayer,n=this.draw({workId:e,layer:r,isDrawing:!1});this.oldRect=n;const s=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),o=xt(s);return(a=this.vNodes)==null||a.setInfo(e,{rect:n,op:s,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:n&&xe.getCenterPos(n,r)}),{rect:n,type:he.FullWork,dataType:Ee.Local,...this.baseConsumeResult,ops:o,isSync:!0,updateNodeOpt:{useAnimation:!0}}}draw(e){const{workId:r,layer:n,isDrawing:s,isDrawEraserlines:o}=e,{strokeColor:a,fillColor:c,thickness:l,zIndex:u,scale:h,rotate:d,translate:g,strokeType:p,eraserlines:v,eraserFaces:I,doingLines:D,lineDash:x,lineCap:j}=this.workOptions,w=n.worldScaling,{radius:y,rect:f,pos:M}=this.computDrawPoints(l),T={closeType:"normal",radius:y,lineWidth:l,fillColor:c!=="transparent"&&c||void 0,strokeColor:a,normalize:!0,lineCap:j,lineDash:p===ze.Dotted?[x&&x[0]||1,(x&&x[1]||2)*l]:p===ze.LongDotted?[(x&&x[0]||1)*l,(x&&x[1]||2)*l]:void 0},b={name:r,id:r,zIndex:u,pos:M,anchor:[.5,.5],size:[f.w,f.h]};h&&(b.scale=h),d&&(b.rotate=d),g&&(b.translate=g);const C=new dt(b);if(s){const O=new Zt({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:a,lineWidth:1,scale:[1/w[0],1/w[1]]});C.append(O)}const P=new gh({...T,pos:[0,0]});C.append(P),(v||I||D)&&(this.scaleType=Ve.proportional,this.drawEraserlines({group:C,eraserlines:this.getRenderableEraserLines(this.workOptions),eraserFaces:I,pos:M,layer:n},o)),this.replace(n,r,C);const E=C.getBoundingClientRect();return this.isDelete&&C.setAttribute("opacity",0),{x:Math.floor(E.x-xe.SafeBorderPadding),y:Math.floor(E.y-xe.SafeBorderPadding),w:Math.floor(E.width+xe.SafeBorderPadding*2),h:Math.floor(E.height+xe.SafeBorderPadding*2)}}computDrawPoints(e){const r=et(this.tmpPoints),n=et(this.tmpPoints,e),s=[Math.floor(r.x+r.w/2),Math.floor(r.y+r.h/2)];return{rect:n,pos:s,radius:[Math.floor(r.w/2),Math.floor(r.h/2)]}}updateTempPoints(e){const r=e.slice(-2),n=new Ae(r[0],r[1]),s=this.tmpPoints[0],{thickness:o}=this.workOptions;if(s.isNear(n,o))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n}else this.tmpPoints.push(n);return!0}consumeService(e){var l,u;const{op:r,isFullWork:n,workState:s=ge.Done}=e,o=(l=this.workId)==null?void 0:l.toString();if(!o)return;this.tmpPoints.length=0;for(let h=0;h<r.length;h+=3)this.tmpPoints.push(new Ae(r[h],r[h+1],r[h+2]));const a=n?this.fullLayer:this.drawLayer||this.fullLayer,c=this.draw({workId:o,layer:a,isDrawing:!1,isDrawEraserlines:s===ge.Done});return this.oldRect=c,(u=this.vNodes)==null||u.setInfo(o,{rect:c,op:r,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:xe.getCenterPos(c,a)}),c}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var h,d,g;const{node:r,opt:n,vNodes:s}=e,{strokeColor:o,fillColor:a,strokeType:c}=n,l=s.get(r.name);let u=r;return r.tagName==="GROUP"&&(u=r.children[0]),o&&(u.setAttribute("strokeColor",o),(h=l==null?void 0:l.opt)!=null&&h.strokeColor&&(l.opt.strokeColor=o)),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&&s.setInfo(r.name,l),xe.updateNodeOpt(e)}}class o0 extends xe{constructor(e){super(e);R(this,"canRotate",!0);R(this,"scaleType",Ve.all);R(this,"toolsType",K.Rectangle);R(this,"tmpPoints",[]);R(this,"workOptions");R(this,"oldRect");R(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}static normalizeStorageData(e){return this.normalizeDrawableStorageData(e)}transformData(){const e=et(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:r}=this.workOptions,n=[];for(const a of e)n.push(new fe(...a));const s=et(n,r),o=[s.x+s.w/2,s.y+s.h/2];return{rect:s,pos:o,points:n.map(a=>a.XY).flat(1)}}consume(e){const{data:r,isFullWork:n,isSubWorker:s,isMainThread:o,smoothSync:a,isSimpleWorker:c}=e,l=this.workId,{op:u}=r,h=u==null?void 0:u.length;if(!h||h<2)return{type:he.None};let d;if(this.tmpPoints.length===0?(this.tmpPoints=[new Ae(u[0],u[1])],d=!1):d=this.updateTempPoints(u),!d)return{type:he.None};const g=this.transformData();let p;if(s||o||c){const I=n?this.fullLayer:this.drawLayer||this.fullLayer;p=this.draw({ps:g,workId:l,layer:I,isDrawing:!0})}if(c){const I=Ge(p,this.oldRect);this.oldRect=p;const D={rect:I,type:he.DrawWork,dataType:Ee.Local,...this.baseConsumeResult};if(a){const x=Date.now();x-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=x,D.op=g.flat(1),D.index=0,D.isSync=!0)}return D}if(!s&&a){const I=Date.now();return I-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=I,{type:he.DrawWork,dataType:Ee.Local,op:g.flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:he.None}}const v=Ge(p,this.oldRect);return this.oldRect=p,{rect:v,type:he.DrawWork,dataType:Ee.Local,...this.baseConsumeResult}}consumeAll(){var c;const e=this.workId;if(this.tmpPoints.length<2)return{type:he.RemoveNode,removeIds:[e]};const r=this.transformData(),n=this.fullLayer,s=this.draw({ps:r,workId:e,layer:n,isDrawing:!1});this.oldRect=s;const o=r.flat(1),a=xt(o);return(c=this.vNodes)==null||c.setInfo(e,{rect:s,op:o,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:s&&xe.getCenterPos(s,n)}),{rect:s,type:he.FullWork,dataType:Ee.Local,ops:a,isSync:!0,...this.baseConsumeResult,updateNodeOpt:{useAnimation:!0}}}draw(e){const{workId:r,layer:n,isDrawing:s,ps:o,replaceId:a,isDrawEraserlines:c=!0}=e,{strokeColor:l,fillColor:u,thickness:h,zIndex:d,scale:g,rotate:p,translate:v,strokeType:I,eraserlines:D,eraserFaces:x,doingLines:j,lineCap:w,lineDash:y}=this.workOptions,f=n.worldPosition,M=n.worldScaling,{points:T,rect:b,pos:C}=this.computDrawPoints(o),P={close:!0,normalize:!0,points:T,lineWidth:h,fillColor:u!=="transparent"&&u||void 0,strokeColor:l,lineCap:w,lineDash:I===ze.Dotted?[y&&y[0]||1,(y&&y[1]||2)*h]:I===ze.LongDotted?[(y&&y[0]||1)*h,(y&&y[1]||2)*h]:void 0};let E={x:Math.floor(b.x*M[0]+f[0]-xe.SafeBorderPadding),y:Math.floor(b.y*M[1]+f[1]-xe.SafeBorderPadding),w:Math.floor(b.w*M[0]+2*xe.SafeBorderPadding),h:Math.floor(b.h*M[0]+2*xe.SafeBorderPadding)};const O=new dt({name:r,id:r,zIndex:d,pos:C,anchor:[.5,.5],size:[b.w,b.h],scale:g,rotate:p,translate:v}),V=new wr({...P,pos:[0,0]});if(O.appendChild(V),s){const N=new Zt({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:l,lineWidth:1,scale:[1/M[0],1/M[1]]});O.appendChild(N)}if((D||x||j)&&(this.scaleType=Ve.proportional,this.drawEraserlines({group:O,eraserlines:this.getRenderableEraserLines(this.workOptions),eraserFaces:x,pos:C,layer:n},c)),this.replace(n,a||r,O),g||p||v){const N=O.getBoundingClientRect();E={x:Math.floor(N.x-xe.SafeBorderPadding),y:Math.floor(N.y-xe.SafeBorderPadding),w:Math.floor(N.width+2*xe.SafeBorderPadding),h:Math.floor(N.height+2*xe.SafeBorderPadding)}}return this.isDelete&&O.setAttribute("opacity",0),E}updateTempPoints(e){const r=e.slice(-2),n=new Ae(r[0],r[1]),s=this.tmpPoints[0],{thickness:o}=this.workOptions;if(s.isNear(n,o))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n}else this.tmpPoints.push(n);return!0}consumeService(e){var h,d;const{op:r,isFullWork:n,replaceId:s,workState:o=ge.Done}=e,a=(h=this.workId)==null?void 0:h.toString();if(!a)return;const c=[];for(let g=0;g<r.length;g+=3)c.push([r[g],r[g+1],r[g+2]]);const l=n?this.fullLayer:this.drawLayer||this.fullLayer,u=this.draw({ps:c,workId:a,layer:l,isDrawing:!1,replaceId:s,isDrawEraserlines:o===ge.Done});return this.oldRect=u,(d=this.vNodes)==null||d.setInfo(a,{rect:u,op:r,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:u&&xe.getCenterPos(u,l)}),u}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var h,d,g;const{node:r,opt:n,vNodes:s}=e,{strokeColor:o,fillColor:a,strokeType:c}=n,l=s.get(r.name);let u=r;return r.tagName==="GROUP"&&(u=r.children[0]),o&&(u.setAttribute("strokeColor",o),(h=l==null?void 0:l.opt)!=null&&h.strokeColor&&(l.opt.strokeColor=o)),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&&s.setInfo(r.name,l),xe.updateNodeOpt(e)}}class a0 extends xe{constructor(e){super(e);R(this,"canRotate",!1);R(this,"scaleType",Ve.all);R(this,"toolsType",K.Star);R(this,"tmpPoints",[]);R(this,"workOptions");R(this,"oldRect");R(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}static normalizeStorageData(e){return this.normalizeDrawableStorageData(e)}consume(e){const{data:r,isFullWork:n,isSubWorker:s,isMainThread:o,smoothSync:a,isSimpleWorker:c}=e,l=this.workId,{op:u,syncUnitTime:h}=r,d=u==null?void 0:u.length;if(!d||d<2)return{type:he.None};h&&(this.syncUnitTime=h);let g;if(this.tmpPoints.length===0?(this.tmpPoints=[new Ae(u[0],u[1])],g=!1):g=this.updateTempPoints(u),!g)return{type:he.None};let p;if(s||o||c){const I=n?this.fullLayer:this.drawLayer||this.fullLayer;p=this.draw({workId:l,layer:I,isDrawing:!0})}if(c){const I=Ge(p,this.oldRect);this.oldRect=p;const D={rect:I,type:he.DrawWork,dataType:Ee.Local,...this.baseConsumeResult};if(a){const x=Date.now();x-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=x,D.op=this.tmpPoints.map(j=>[...j.XY,0]).flat(1),D.index=0,D.isSync=!0)}return D}if(!s&&a){const I=Date.now();return I-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=I,{type:he.DrawWork,dataType:Ee.Local,op:this.tmpPoints.map(D=>[...D.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:he.None}}const v=Ge(p,this.oldRect);return this.oldRect=p,{rect:v,type:he.DrawWork,dataType:Ee.Local,...this.baseConsumeResult}}consumeAll(){var a;const e=this.workId;if(this.tmpPoints.length<2)return{type:he.RemoveNode,removeIds:[e]};const r=this.fullLayer,n=this.draw({workId:e,layer:r,isDrawing:!1});this.oldRect=n;const s=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),o=xt(s);return(a=this.vNodes)==null||a.setInfo(e,{rect:n,op:s,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:n&&xe.getCenterPos(n,r)}),{rect:n,type:he.FullWork,dataType:Ee.Local,ops:o,isSync:!0,...this.baseConsumeResult,updateNodeOpt:{useAnimation:!0}}}draw(e){const{workId:r,layer:n,isDrawing:s,isDrawEraserlines:o=!0}=e,{strokeColor:a,fillColor:c,thickness:l,zIndex:u,vertices:h,innerVerticeStep:d,innerRatio:g,scale:p,rotate:v,translate:I,strokeType:D,eraserlines:x,eraserFaces:j,doingLines:w,lineDash:y,lineCap:f}=this.workOptions,M=n.worldScaling,{rect:T,pos:b,points:C}=this.computDrawPoints(l,h,d,g),P={close:!0,points:C,lineWidth:l,fillColor:c!=="transparent"&&c||void 0,strokeColor:a,normalize:!0,lineCap:f,lineDash:D===ze.Dotted?[y&&y[0]||1,(y&&y[1]||2)*l]:D===ze.LongDotted?[(y&&y[0]||1)*l,(y&&y[1]||2)*l]:void 0},E={name:r,id:r,zIndex:u,pos:b,anchor:[.5,.5],size:[T.w,T.h]};p&&(E.scale=p),v&&(E.rotate=v),I&&(E.translate=I);const O=new dt(E);if(s){const A=new Zt({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:a,lineWidth:1,scale:[1/M[0],1/M[1]]});O.append(A)}const V=new wr({...P,pos:[0,0]});O.append(V),(x||j||w)&&(this.scaleType=Ve.proportional,this.drawEraserlines({group:O,eraserlines:this.getRenderableEraserLines(this.workOptions),eraserFaces:j,pos:b,layer:n},o)),this.replace(n,r,O);const N=O.getBoundingClientRect();return this.isDelete&&O.setAttribute("opacity",0),{x:Math.floor(N.x-xe.SafeBorderPadding),y:Math.floor(N.y-xe.SafeBorderPadding),w:Math.floor(N.width+xe.SafeBorderPadding*2),h:Math.floor(N.height+xe.SafeBorderPadding*2)}}computDrawPoints(e,r,n,s){const o=et(this.tmpPoints),a=[Math.floor(o.x+o.w/2),Math.floor(o.y+o.h/2)],c=N0(o.w,o.h),l=Math.floor(Math.min(o.w,o.h)/2),u=s*l,h=[],d=2*Math.PI/r;for(let p=0;p<r;p++){const v=p*d-.5*Math.PI;let I,D;p%n===1?(I=u*c[0]*Math.cos(v),D=u*c[1]*Math.sin(v)):(I=l*c[0]*Math.cos(v),D=l*c[1]*Math.sin(v),h.push(I,D)),h.push(I,D)}return{rect:et(this.tmpPoints,e),pos:a,points:h}}updateTempPoints(e){const r=e.slice(-2),n=new Ae(r[0],r[1]),s=this.tmpPoints[0],{thickness:o}=this.workOptions;if(s.isNear(n,o)||Ae.Sub(s,n).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n}else this.tmpPoints.push(n);return!0}consumeService(e){var l,u;const{op:r,isFullWork:n,workState:s=ge.Done}=e,o=(l=this.workId)==null?void 0:l.toString();if(!o)return;this.tmpPoints.length=0;for(let h=0;h<r.length;h+=3)this.tmpPoints.push(new Ae(r[h],r[h+1],r[h+2]));const a=n?this.fullLayer:this.drawLayer||this.fullLayer,c=this.draw({workId:o,layer:a,isDrawing:!1,isDrawEraserlines:s===ge.Done});return this.oldRect=c,(u=this.vNodes)==null||u.setInfo(o,{rect:c,op:r,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:c&&xe.getCenterPos(c,a)}),c}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var I;const{node:r,opt:n,vNodes:s}=e,{strokeColor:o,fillColor:a,toolsType:c,vertices:l,innerVerticeStep:u,innerRatio:h,strokeType:d}=n,g=s.get(r.name),p=g==null?void 0:g.opt;let v=r;return r.tagName==="GROUP"&&(v=r.children[0]),o&&(v.setAttribute("strokeColor",o),p!=null&&p.strokeColor&&(p.strokeColor=o)),a&&(a==="transparent"?v.setAttribute("fillColor","rgba(0,0,0,0)"):v.setAttribute("fillColor",a),p!=null&&p.fillColor&&(p.fillColor=a)),c===K.Star&&(l&&(p.vertices=l),u&&(p.innerVerticeStep=u),h&&(p.innerRatio=h)),d&&(g!=null&&g.opt)&&((I=g.opt)!=null&&I.strokeType)&&(g.opt.strokeType=d),g&&s.setInfo(r.name,{...g,opt:p}),xe.updateNodeOpt(e)}}class c0 extends xe{constructor(e){super(e);R(this,"canRotate",!1);R(this,"scaleType",Ve.all);R(this,"toolsType",K.Polygon);R(this,"tmpPoints",[]);R(this,"workOptions");R(this,"oldRect");R(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}static normalizeStorageData(e){return this.normalizeDrawableStorageData(e)}consume(e){const{data:r,isFullWork:n,isSubWorker:s,isMainThread:o,smoothSync:a,isSimpleWorker:c}=e,{op:l,syncUnitTime:u}=r;u&&(this.syncUnitTime=u);const h=this.workId,d=l==null?void 0:l.length;if(!d||d<2)return{type:he.None};let g;if(this.tmpPoints.length===0?(this.tmpPoints=[new Ae(l[0],l[1])],g=!1):g=this.updateTempPoints(l),!g)return{type:he.None};let p;if(s||o||c){const I=n?this.fullLayer:this.drawLayer||this.fullLayer;p=this.draw({workId:h,layer:I,isDrawing:!0})}if(c){const I=Ge(p,this.oldRect);this.oldRect=p;const D={type:he.DrawWork,rect:I,dataType:Ee.Local,...this.baseConsumeResult};if(a){const x=Date.now();x-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=x,D.op=this.tmpPoints.map(j=>[...j.XY,0]).flat(1),D.index=0,D.isSync=!0)}return D}if(!s&&a){const I=Date.now();return I-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=I,{type:he.DrawWork,dataType:Ee.Local,op:this.tmpPoints.map(D=>[...D.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:he.None}}const v=Ge(p,this.oldRect);return this.oldRect=p,{rect:v,type:he.DrawWork,dataType:Ee.Local,...this.baseConsumeResult}}consumeAll(){var a;const e=this.workId;if(this.tmpPoints.length<2)return{type:he.RemoveNode,removeIds:[e]};const r=this.fullLayer,n=this.draw({workId:e,layer:r,isDrawing:!1});this.oldRect=n;const s=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),o=xt(s);return(a=this.vNodes)==null||a.setInfo(e,{rect:n,op:s,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:n&&xe.getCenterPos(n,r)}),{rect:n,type:he.FullWork,dataType:Ee.Local,ops:o,isSync:!0,...this.baseConsumeResult,updateNodeOpt:{useAnimation:!0}}}draw(e){const{workId:r,layer:n,isDrawing:s,isDrawEraserlines:o=!0}=e,{strokeColor:a,fillColor:c,thickness:l,zIndex:u,vertices:h,scale:d,rotate:g,translate:p,strokeType:v,eraserlines:I,eraserFaces:D,doingLines:x,lineCap:j,lineDash:w}=this.workOptions,y=n.worldScaling,{rect:f,pos:M,points:T}=this.computDrawPoints(l,h),b={close:!0,points:T,lineWidth:l,fillColor:c!=="transparent"&&c||void 0,strokeColor:a,normalize:!0,lineCap:j,lineDash:v===ze.Dotted?[w&&w[0]||1,(w&&w[1]||2)*l]:v===ze.LongDotted?[(w&&w[0]||1)*l,(w&&w[1]||2)*l]:void 0},C={name:r,id:r,zIndex:u,pos:M,anchor:[.5,.5],size:[f.w,f.h]};d&&(C.scale=d),g&&(C.rotate=g),p&&(C.translate=p);const P=new dt(C);if(s){const V=new Zt({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:a,lineWidth:1,scale:[1/y[0],1/y[1]]});P.append(V)}const E=new wr({...b,pos:[0,0]});P.append(E),(I||D||x)&&(this.scaleType=Ve.proportional,this.drawEraserlines({group:P,eraserlines:this.getRenderableEraserLines(this.workOptions),eraserFaces:D,pos:M,layer:n},o)),this.replace(n,r,P);const O=P.getBoundingClientRect();return this.isDelete&&P.setAttribute("opacity",0),{x:Math.floor(O.x-xe.SafeBorderPadding),y:Math.floor(O.y-xe.SafeBorderPadding),w:Math.floor(O.width+xe.SafeBorderPadding*2),h:Math.floor(O.height+xe.SafeBorderPadding*2)}}computDrawPoints(e,r){const n=et(this.tmpPoints),s=[Math.floor(n.x+n.w/2),Math.floor(n.y+n.h/2)],o=N0(n.w,n.h),a=Math.floor(Math.min(n.w,n.h)/2),c=[],l=2*Math.PI/r;for(let h=0;h<r;h++){const d=h*l-.5*Math.PI,g=a*o[0]*Math.cos(d),p=a*o[1]*Math.sin(d);c.push(g,p)}return{rect:et(this.tmpPoints,e),pos:s,points:c}}updateTempPoints(e){const r=e.slice(-2),n=new Ae(r[0],r[1]),s=this.tmpPoints[0],{thickness:o}=this.workOptions;if(s.isNear(n,o)||Ae.Sub(s,n).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n}else this.tmpPoints.push(n);return!0}consumeService(e){var l,u;const{op:r,isFullWork:n,workState:s=ge.Done}=e,o=(l=this.workId)==null?void 0:l.toString();if(!o)return;this.tmpPoints.length=0;for(let h=0;h<r.length;h+=3)this.tmpPoints.push(new Ae(r[h],r[h+1],r[h+2]));const a=n?this.fullLayer:this.drawLayer||this.fullLayer,c=this.draw({workId:o,layer:a,isDrawing:!1,isDrawEraserlines:s===ge.Done});return this.oldRect=c,(u=this.vNodes)==null||u.setInfo(o,{rect:c,op:r,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:c&&xe.getCenterPos(c,a)}),c}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var p;const{node:r,opt:n,vNodes:s}=e,{strokeColor:o,fillColor:a,toolsType:c,vertices:l,strokeType:u}=n,h=s.get(r.name),d=h==null?void 0:h.opt;let g=r;return r.tagName==="GROUP"&&(g=r.children[0]),o&&(g.setAttribute("strokeColor",o),d!=null&&d.strokeColor&&(d.strokeColor=o)),a&&(a==="transparent"?g.setAttribute("fillColor","rgba(0,0,0,0)"):g.setAttribute("fillColor",a),d!=null&&d.fillColor&&(d.fillColor=a)),c===K.Polygon&&l&&(d.vertices=l),u&&(h!=null&&h.opt)&&((p=h.opt)!=null&&p.strokeType)&&(h.opt.strokeType=u),h&&s.setInfo(r.name,{...h,opt:d}),xe.updateNodeOpt(e)}}class fr{static bezier(t,e){const r=[];for(let n=0;n<e.length;n+=4){const s=e[n],o=e[n+1],a=e[n+2],c=e[n+3];s&&o&&a&&c?r.push(...fr.getBezierPoints(t,s,o,a,c)):s&&o&&a?r.push(...fr.getBezierPoints(t,s,o,a)):s&&o?r.push(...fr.getBezierPoints(t,s,o)):s&&r.push(s)}return r}static getBezierPoints(t=10,e,r,n,s){let o=null;const a=[];!n&&!s?o=fr.oneBezier:n&&!s?o=fr.twoBezier:n&&s&&(o=fr.threeBezier);for(let c=0;c<t;c++)o&&a.push(o(c/t,e,r,n,s));return s?a.push(s):n&&a.push(n),a}static oneBezier(t,e,r){const n=e.x+(r.x-e.x)*t,s=e.y+(r.y-e.y)*t;return new fe(n,s)}static twoBezier(t,e,r,n){const s=(1-t)*(1-t)*e.x+2*t*(1-t)*r.x+t*t*n.x,o=(1-t)*(1-t)*e.y+2*t*(1-t)*r.y+t*t*n.y;return new fe(s,o)}static threeBezier(t,e,r,n,s){const o=e.x*(1-t)*(1-t)*(1-t)+3*r.x*t*(1-t)*(1-t)+3*n.x*t*t*(1-t)+s.x*t*t*t,a=e.y*(1-t)*(1-t)*(1-t)+3*r.y*t*(1-t)*(1-t)+3*n.y*t*t*(1-t)+s.y*t*t*t;return new fe(o,a)}}class l0 extends xe{constructor(e){super(e);R(this,"canRotate",!1);R(this,"scaleType",Ve.all);R(this,"toolsType",K.SpeechBalloon);R(this,"ratio",.8);R(this,"tmpPoints",[]);R(this,"workOptions");R(this,"oldRect");R(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}static normalizeStorageData(e){return this.normalizeDrawableStorageData(e)}consume(e){var v;const{data:r,isFullWork:n,isSubWorker:s,isMainThread:o,smoothSync:a,isSimpleWorker:c}=e,l=(v=r==null?void 0:r.workId)==null?void 0:v.toString();if(!l)return{type:he.None};const{op:u}=r,h=u==null?void 0:u.length;if(!h||h<2)return{type:he.None};let d;if(this.tmpPoints.length===0?(this.tmpPoints=[new Ae(u[0],u[1])],d=!1):d=this.updateTempPoints(u),!d)return{type:he.None};let g;if(s||o||c){const I=n?this.fullLayer:this.drawLayer||this.fullLayer;g=this.draw({workId:l,layer:I,isDrawing:!0})}if(c){const I=Ge(g,this.oldRect);this.oldRect=g;const D={rect:I,type:he.DrawWork,dataType:Ee.Local,...this.baseConsumeResult};if(a){const x=Date.now();x-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=x,D.op=this.tmpPoints.map(j=>[...j.XY,0]).flat(1),D.index=0,D.isSync=!0)}return D}if(!s&&a){const I=Date.now();return I-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=I,{type:he.DrawWork,dataType:Ee.Local,op:this.tmpPoints.map(D=>[...D.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:he.None}}const p=Ge(g,this.oldRect);return this.oldRect=g,{rect:p,type:he.DrawWork,dataType:Ee.Local,...this.baseConsumeResult}}consumeAll(){var a;const e=this.workId;if(this.tmpPoints.length<2)return{type:he.RemoveNode,removeIds:[e]};const r=this.fullLayer,n=this.draw({workId:e,layer:r,isDrawing:!1});this.oldRect=n;const s=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),o=xt(s);return(a=this.vNodes)==null||a.setInfo(e,{rect:n,op:s,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:n&&xe.getCenterPos(n,r)}),{rect:n,type:he.FullWork,dataType:Ee.Local,ops:o,isSync:!0,...this.baseConsumeResult,updateNodeOpt:{useAnimation:!0}}}draw(e){const{workId:r,layer:n,isDrawEraserlines:s=!0}=e,{strokeColor:o,fillColor:a,thickness:c,zIndex:l,placement:u,scale:h,rotate:d,translate:g,strokeType:p,eraserlines:v,eraserFaces:I,doingLines:D,lineDash:x,lineCap:j}=this.workOptions,{rect:w,pos:y,points:f}=this.computDrawPoints(c,u),M={points:f.map(E=>E.XY),lineWidth:c,fillColor:a!=="transparent"&&a||void 0,strokeColor:o,normalize:!0,className:`${y[0]},${y[1]}`,close:!0,lineCap:j,lineDash:p===ze.Dotted?[x&&x[0]||1,(x&&x[1]||2)*c]:p===ze.LongDotted?[(x&&x[0]||1)*c,(x&&x[1]||2)*c]:void 0},T={name:r,id:r,zIndex:l,pos:y,anchor:[.5,.5],size:[w.w,w.h]};h&&(T.scale=h),d&&(T.rotate=d),g&&(T.translate=g);const b=new dt(T),C=new wr({...M,pos:[0,0]});b.append(C),(v||I||D)&&(this.scaleType=Ve.proportional,this.drawEraserlines({group:b,eraserlines:this.getRenderableEraserLines(this.workOptions),eraserFaces:I,pos:y,layer:n},s)),this.replace(n,r,b);const P=b.getBoundingClientRect();return this.isDelete&&b.setAttribute("opacity",0),{x:Math.floor(P.x-xe.SafeBorderPadding),y:Math.floor(P.y-xe.SafeBorderPadding),w:Math.floor(P.width+xe.SafeBorderPadding*2),h:Math.floor(P.height+xe.SafeBorderPadding*2)}}transformControlPoints(e){const r=et(this.tmpPoints);switch(e){case"bottom":case"bottomLeft":case"bottomRight":{const n=r.y+r.h*this.ratio;return[new fe(r.x,r.y,0),new fe(r.x+r.w,r.y,0),new fe(r.x+r.w,n,0),new fe(r.x,n,0)]}case"top":case"topLeft":case"topRight":{const n=r.y+r.h*(1-this.ratio);return[new fe(r.x,n,0),new fe(r.x+r.w,n,0),new fe(r.x+r.w,r.y+r.h,0),new fe(r.x,r.y+r.h,0)]}case"left":case"leftBottom":case"leftTop":{const n=r.x+r.w*(1-this.ratio);return[new fe(n,r.y,0),new fe(r.x+r.w,r.y,0),new fe(r.x+r.w,r.y+r.h,0),new fe(n,r.y+r.h,0)]}case"right":case"rightBottom":case"rightTop":{const n=r.x+r.w*this.ratio;return[new fe(r.x,r.y,0),new fe(n,r.y,0),new fe(n,r.y+r.h,0),new fe(r.x,r.y+r.h,0)]}}}computDrawPoints(e,r){const n=et(this.tmpPoints),s=this.transformControlPoints(r),o=Math.floor(n.w*.1),a=Math.floor(n.h*.1),c=[],l=fe.Add(s[0],new fe(0,a,0)),u=fe.Add(s[0],new fe(o,0,0)),h=fr.getBezierPoints(10,l,s[0],u),d=fe.Sub(s[1],new fe(o,0,0)),g=fe.Add(s[1],new fe(0,a,0)),p=fr.getBezierPoints(10,d,s[1],g),v=fe.Sub(s[2],new fe(0,a,0)),I=fe.Sub(s[2],new fe(o,0,0)),D=fr.getBezierPoints(10,v,s[2],I),x=fe.Add(s[3],new fe(o,0,0)),j=fe.Sub(s[3],new fe(0,a,0)),w=fr.getBezierPoints(10,x,s[3],j),y=o*(1-this.ratio)*10,f=a*(1-this.ratio)*10;switch(r){case"bottom":{const b=fe.Sub(s[2],new fe(o*5-y/2,0,0)),C=fe.Sub(s[2],new fe(o*5,-f,0)),P=fe.Sub(s[2],new fe(o*5+y/2,0,0));c.push(C,P,...w,...h,...p,...D,b);break}case"bottomRight":{const b=fe.Sub(s[2],new fe(o*1.1,0,0)),C=fe.Sub(s[2],new fe(o*1.1+y/2,-f,0)),P=fe.Sub(s[2],new fe(o*1.1+y,0,0));c.push(C,P,...w,...h,...p,...D,b);break}case"bottomLeft":{const b=fe.Add(s[3],new fe(o*1.1+y,0,0)),C=fe.Add(s[3],new fe(o*1.1+y/2,f,0)),P=fe.Add(s[3],new fe(o*1.1,0,0));c.push(C,P,...w,...h,...p,...D,b);break}case"top":{const b=fe.Sub(s[1],new fe(o*5-y/2,0,0)),C=fe.Sub(s[1],new fe(o*5,f,0)),P=fe.Sub(s[1],new fe(o*5+y/2,0,0));c.push(C,b,...p,...D,...w,...h,P);break}case"topRight":{const b=fe.Sub(s[1],new fe(o*1.1,0,0)),C=fe.Sub(s[1],new fe(o*1.1+y/2,f,0)),P=fe.Sub(s[1],new fe(o*1.1+y,0,0));c.push(C,b,...p,...D,...w,...h,P);break}case"topLeft":{const b=fe.Add(s[0],new fe(o*1.1+y,0,0)),C=fe.Add(s[0],new fe(o*1.1+y/2,-f,0)),P=fe.Add(s[0],new fe(o*1.1,0,0));c.push(C,b,...p,...D,...w,...h,P);break}case"left":{const b=fe.Add(s[0],new fe(0,a*5-f/2,0)),C=fe.Add(s[0],new fe(-y,a*5,0)),P=fe.Add(s[0],new fe(0,a*5+f/2,0));c.push(C,b,...h,...p,...D,...w,P);break}case"leftTop":{const b=fe.Add(s[0],new fe(0,a*1.1,0)),C=fe.Add(s[0],new fe(-y,a*1.1+f/2,0)),P=fe.Add(s[0],new fe(0,a*1.1+f,0));c.push(C,b,...h,...p,...D,...w,P);break}case"leftBottom":{const b=fe.Sub(s[3],new fe(0,a*1.1+f,0)),C=fe.Sub(s[3],new fe(y,a*1.1+f/2,0)),P=fe.Sub(s[3],new fe(0,a*1.1,0));c.push(C,b,...h,...p,...D,...w,P);break}case"right":{const b=fe.Add(s[1],new fe(0,a*5-f/2,0)),C=fe.Add(s[1],new fe(y,a*5,0)),P=fe.Add(s[1],new fe(0,a*5+f/2,0));c.push(C,P,...D,...w,...h,...p,b);break}case"rightTop":{const b=fe.Add(s[1],new fe(0,a*1.1,0)),C=fe.Add(s[1],new fe(y,a*1.1+f/2,0)),P=fe.Add(s[1],new fe(0,a*1.1+f,0));c.push(C,P,...D,...w,...h,...p,b);break}case"rightBottom":{const b=fe.Sub(s[2],new fe(0,a*1.1+f,0)),C=fe.Sub(s[2],new fe(-y,a*1.1+f/2,0)),P=fe.Sub(s[2],new fe(0,a*1.1,0));c.push(C,P,...D,...w,...h,...p,b);break}}const M=et(this.tmpPoints,e),T=[Math.floor(M.x+M.w/2),Math.floor(M.y+M.h/2)];return{rect:M,pos:T,points:c}}updateTempPoints(e){const r=e.slice(-2),n=new Ae(r[0],r[1]),s=this.tmpPoints[0],{thickness:o}=this.workOptions;if(s.isNear(n,o)||Ae.Sub(s,n).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n}else this.tmpPoints.push(n);return!0}consumeService(e){var l,u;const{op:r,isFullWork:n,workState:s=ge.Done}=e,o=(l=this.workId)==null?void 0:l.toString();if(!o)return;this.tmpPoints.length=0;for(let h=0;h<r.length;h+=3)this.tmpPoints.push(new Ae(r[h],r[h+1],r[h+2]));const a=n?this.fullLayer:this.drawLayer||this.fullLayer,c=this.draw({workId:o,layer:a,isDrawing:!1,isDrawEraserlines:s===ge.Done});return this.oldRect=c,(u=this.vNodes)==null||u.setInfo(o,{rect:c,op:r,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:c&&xe.getCenterPos(c,a)}),c}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var p;const{node:r,opt:n,vNodes:s}=e,{strokeColor:o,fillColor:a,toolsType:c,placement:l,strokeType:u}=n,h=s.get(r.name),d=h==null?void 0:h.opt;let g=r;return r.tagName==="GROUP"&&(g=r.children[0]),o&&(g.setAttribute("strokeColor",o),d!=null&&d.strokeColor&&(d.strokeColor=o)),a&&(a==="transparent"?g.setAttribute("fillColor","rgba(0,0,0,0)"):g.setAttribute("fillColor",a),d!=null&&d.fillColor&&(d.fillColor=a)),c===K.SpeechBalloon&&l&&(d.placement=l),u&&(h!=null&&h.opt)&&((p=h.opt)!=null&&p.strokeType)&&(h.opt.strokeType=u),h&&s.setInfo(r.name,{...h,opt:d}),xe.updateNodeOpt(e)}}var Ape=li,Npe=Nr,Dpe="[object Boolean]";function Ppe(i){return i===!0||i===!1||Npe(i)&&Ape(i)==Dpe}var kpe=Ppe;const Hn=en(kpe);class u0 extends xe{constructor(e){super(e);R(this,"canRotate",!1);R(this,"scaleType",Ve.both);R(this,"toolsType",K.Straight);R(this,"tmpPoints",[]);R(this,"workOptions");R(this,"oldRect");R(this,"straightTipWidth");R(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.straightTipWidth=this.workOptions.thickness/2,this.syncTimestamp=0,this.syncUnitTime=50}static normalizeStorageData(e){return this.normalizeDrawableStorageData(e)}consume(e){const{data:r,isFullWork:n,isSubWorker:s,isMainThread:o,smoothSync:a,isSimpleWorker:c}=e,l=this.workId,{op:u,syncUnitTime:h}=r,d=u==null?void 0:u.length;if(!d||d<2)return{type:he.None};h&&(this.syncUnitTime=h);let g;if(this.tmpPoints.length===0?(this.tmpPoints=[new Ae(u[0],u[1])],g=!1):g=this.updateTempPoints(u),!g)return{type:he.None};let p;if(s||o||c){const I=n?this.fullLayer:this.drawLayer||this.fullLayer;p=this.draw({workId:l,layer:I})}if(c){const I=Ge(p,this.oldRect);this.oldRect=p;const D={rect:I,type:he.DrawWork,dataType:Ee.Local,...this.baseConsumeResult};if(a){const x=Date.now();x-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=x,D.op=this.tmpPoints.map(j=>[...j.XY,0]).flat(1),D.index=0,D.isSync=!0)}return D}if(!s&&a){const I=Date.now();return I-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=I,{type:he.DrawWork,dataType:Ee.Local,op:this.tmpPoints.map(D=>[...D.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:he.None}}const v=Ge(p,this.oldRect);return this.oldRect=p,{rect:v,type:he.DrawWork,dataType:Ee.Local,...this.baseConsumeResult}}consumeAll(){var a;const e=this.workId;if(this.tmpPoints.length<2)return{type:he.RemoveNode,removeIds:[e]};const r=this.fullLayer,n=this.draw({workId:e,layer:r});this.oldRect=n;const s=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),o=xt(s);return(a=this.vNodes)==null||a.setInfo(e,{rect:n,op:s,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:n&&xe.getCenterPos(n,r)}),{rect:n,type:he.FullWork,dataType:Ee.Local,ops:o,isSync:!0,...this.baseConsumeResult,updateNodeOpt:{useAnimation:!0}}}draw(e){const{workId:r,layer:n,isDrawEraserlines:s=!0}=e,{strokeColor:o,thickness:a,zIndex:c,scale:l,rotate:u,translate:h,strokeType:d,eraserlines:g,eraserFaces:p,doingLines:v,lineCap:I,lineDash:D}=this.workOptions,x=n.worldPosition,j=n.worldScaling,{d:w,rect:y,isDot:f}=this.computDrawPoints(a,d),M=[y.x+y.w/2,y.y+y.h/2],T=new dt({pos:M,anchor:[.5,.5],size:[y.w,y.h],name:r,id:r,normalize:!0,zIndex:c}),b={pos:[0,0],normalize:!0,d:w,fillColor:o,strokeColor:o,lineDash:f?void 0:d===ze.Dotted?[D&&D[0]||1,(D&&D[1]||2)*a]:d===ze.LongDotted?[(D&&D[0]||1)*a,(D&&D[1]||2)*a]:void 0,lineCap:f?void 0:I,lineWidth:d===ze.Normal||f?0:a};l&&(b.scale=l),u&&(b.rotate=u),h&&(b.translate=h);const C=new Zt(b);T.append(C),(g||p||v)&&(this.scaleType=Ve.proportional,this.drawEraserlines({group:T,eraserlines:this.getRenderableEraserLines(this.workOptions),eraserFaces:p,pos:M,layer:n},s)),this.replace(n,r,T);let P={x:Math.floor(y.x*j[0]+x[0]-xe.SafeBorderPadding),y:Math.floor(y.y*j[1]+x[1]-xe.SafeBorderPadding),w:Math.floor(y.w*j[0]+2*xe.SafeBorderPadding),h:Math.floor(y.h*j[1]+2*xe.SafeBorderPadding)};if(u||l||h){const E=C.getBoundingClientRect();P={x:Math.floor(E.x-xe.SafeBorderPadding),y:Math.floor(E.y-xe.SafeBorderPadding),w:Math.floor(E.width+xe.SafeBorderPadding*2),h:Math.floor(E.height+xe.SafeBorderPadding*2)}}return this.isDelete&&T.setAttribute("opacity",0),P}computDrawPoints(e,r){return this.tmpPoints[1].distance(this.tmpPoints[0])>this.straightTipWidth?this.computFullPoints(e,r):this.computDotPoints(e)}computFullPoints(e,r){const n=fe.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),s=fe.Per(n).mul(e/2),o=Ae.Sub(this.tmpPoints[0],s),a=Ae.Add(this.tmpPoints[0],s),c=Ae.Sub(this.tmpPoints[1],s),l=Ae.Add(this.tmpPoints[1],s),u=Ae.GetSemicircleStroke(this.tmpPoints[1],c,-1,8),h=Ae.GetSemicircleStroke(this.tmpPoints[0],a,-1,8),d=[o,c,...u,l,a,...h];let g;return r!==ze.Normal?g=Jr(this.tmpPoints,!1):g=Jr(d,!0),{d:g,rect:et(d),isDot:!1,pos:this.tmpPoints[0].XY}}computDotPoints(e){const r=Ae.GetDotStroke(this.tmpPoints[0],e/2,8);return{d:Jr(r,!0),rect:et(r),isDot:!0,pos:this.tmpPoints[0].XY}}updateTempPoints(e){const r=e.slice(-2),n=new Ae(r[0],r[1]),s=this.tmpPoints[0],{thickness:o}=this.workOptions;if(s.isNear(n,o))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n}else this.tmpPoints.push(n);return!0}consumeService(e){var l,u;const{op:r,isFullWork:n,workState:s=ge.Done}=e,o=(l=this.workId)==null?void 0:l.toString();if(!o)return;this.tmpPoints.length=0;for(let h=0;h<r.length;h+=3)this.tmpPoints.push(new Ae(r[h],r[h+1],r[h+2]));const a=n?this.fullLayer:this.drawLayer||this.fullLayer,c=this.draw({workId:o,layer:a,isDrawEraserlines:s===ge.Done});return this.oldRect=c,(u=this.vNodes)==null||u.setInfo(o,{rect:c,op:r,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:c&&xe.getCenterPos(c,a)}),c}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var l,u;const{node:r,opt:n,vNodes:s}=e,{strokeColor:o,strokeType:a}=n,c=s.get(r.name);return o&&(r.tagName==="GROUP"?r.children.forEach(h=>{h.setAttribute("strokeColor",o),h.getAttribute("fillColor")&&h.setAttribute("fillColor",o)}):(r.setAttribute("strokeColor",o),r.setAttribute("fillColor",o)),(l=c==null?void 0:c.opt)!=null&&l.strokeColor&&(c.opt.strokeColor=o)),a&&(c!=null&&c.opt)&&((u=c.opt)!=null&&u.strokeType)&&(c.opt.strokeType=a),c&&s.setInfo(r.name,c),xe.updateNodeOpt(e)}}var vr=(i=>(i[i.Text=1]="Text",i[i.Shape=2]="Shape",i))(vr||{});const Yt=class Yt{createProxy(t){const e=new Proxy(t,{get(r,n,s){const o=Yt.interceptors.hasOwnProperty(n)?Yt.interceptors:r;return Reflect.get(o,n,s)}});return Yt.proxyToRaw.set(e,t),e}};R(Yt,"proxyToRaw",new WeakMap),R(Yt,"interceptors",{entries(...t){return Yt.proxyToRaw.get(this).entries(...t)},forEach(...t){return Yt.proxyToRaw.get(this).forEach(...t)},size(){return Yt.proxyToRaw.get(this).size},get(t){return Yt.proxyToRaw.get(this).get(t)},set(t,e){return Yt.proxyToRaw.get(this).set(t,e)},delete(t){return Yt.proxyToRaw.get(this).delete(t)},clear(){return Yt.proxyToRaw.get(this).clear()}});let Vn=Yt;const _n="__undo_scope_clear_all__";var $e=(i=>(i.DrawingPencil="drawing:pencil",i.DrawingArrow="drawing:arrow",i.DrawingShape="drawing:shape",i.DrawingEraser="drawing:eraser",i.DrawingPencilEraser="drawing:pencil-eraser",i.DrawingBitMapEraser="drawing:bitmap-eraser",i.MethodTranslateNode="method:translate-node",i.MethodScaleNode="method:scale-node",i.MethodRotateNode="method:rotate-node",i.MethodSetPoint="method:set-point",i.MethodSetColorNode="method:set-color-node",i.AsyncCopyNode="async:copy-node",i.AsyncPasteNode="async:paste-node",i.AsyncDeleteNode="async:delete-node",i.AsyncSetFontStyle="async:set-font-style",i.AsyncSetShapeOpt="async:set-shape-opt",i.AsyncZIndexNode="async:z-index-node",i.AsyncSetLock="async:set-lock",i.AsyncUpdateElement="async:update-element",i.AsyncImage="async:image",i.AsyncIcon="async:icon",i.AsyncMarkmap="async:markmap",i.Text="text",i.Clear="command:clear",i))($e||{});function Lpe(i){const{tickerId:t,viewId:e,scenePath:r,expectedAcks:n,fallbackTimer:s}=i;return{viewId:e,scenePath:r,expectedRender:n.render,expectedStorage:n.storage,gotRender:!n.render,gotStorage:!n.storage,scopeMode:n.scopeMode||"static",source:n.source,transactionId:n.transactionId||`${e}:${t}`,barrierEpoch:n.barrierEpoch||0,startedAt:Date.now(),phase:"doing",ownerPromiseActive:n.ownerPromiseActive??!0,finalizeRequested:!1,collectedScopeKeys:new Set,scopeKeys:new Set,ackedStorageKeys:new Set,meta:{copyAck:n.copyAck,isWritable:n.isWritable},fallbackTimer:s}}function Rpe(i,t){t&&(i.meta={...i.meta,...t})}function Ope(i){return(!i.expectedRender||i.gotRender)&&(!i.expectedStorage||i.gotStorage)}function zpe(i){return!i.ackTimer&&i.finalizeRequested}function jpe(i){return i.expectedStorage?i.finalizeRequested?i.scopeKeys.size?[...i.scopeKeys].every(t=>i.ackedStorageKeys.has(t)):!0:!1:!0}function Bpe(i,t){return i.size>0?i.has(_n)?t===_n:!!t&&i.has(t):!t||i.has(t)}function dl(i,t){const e=t.toString();return i.isLocalId(e)?i.transformKey(e):e}function fl(i,t,e,r){var o,a;const n=new Set;if(!i)return n;const s=i.getStorageData(t,e);for(const c of r){if(c==null)continue;if(c===_n){n.add(_n);continue}const l=dl(i,c),u=s==null?void 0:s[l];if(i.getLocalId(l)===De){(o=u==null?void 0:u.selectIds)==null||o.forEach(h=>{n.add(dl(i,h))});continue}n.add(l),(a=u==null?void 0:u.selectIds)==null||a.forEach(h=>{n.add(dl(i,h))})}return n}function kg(i,t,e){return e!=null&&e.has(_n)?!t.has(i):e!=null&&e.size?e.has(i):!t.has(i)}const Upe={[K.Selector]:Ne.selector,[K.Clicker]:Ne.clicker,[K.Text]:Ne.text,[K.Pencil]:Ne.pencil,[K.LaserPen]:Ne.laserPen,[K.Arrow]:Ne.arrow,[K.Straight]:Ne.straight,[K.Rectangle]:Ne.rectangle,[K.Ellipse]:Ne.ellipse,[K.Star]:rr.star,[K.Polygon]:rr.polygon,[K.SpeechBalloon]:rr.speechBalloon,[K.Eraser]:Ne.eraser,[K.PencilEraser]:Ne.pencilEraser,[K.BitMapEraser]:rr.bitMapEraser};function cc(i){return i===void 0?void 0:Upe[i]}function Fpe(i,t){return i||t}function Wpe(i){return cc(i)}function $pe(i){switch(i){case K.Text:return vr.Text;case K.SpeechBalloon:case K.Star:case K.Ellipse:case K.Rectangle:case K.Triangle:case K.Rhombus:case K.Polygon:return vr.Shape}}function pa(i){if(!i)return!1;try{const t=Nn(i);if(Array.isArray(t))return t.some(e=>String(e??"").trim().length>0);if(typeof t=="string")return t.trim().length>0}catch{}return i.split(",").some(t=>t.trim().length>0)}function h0(i){const t=i.lastChild;if(!t){const n=document.createElement("div"),s=document.createTextNode("");return n.appendChild(s),i.appendChild(n),s}if(t.nodeType===Node.TEXT_NODE)return t;const e=t;if(!e.lastChild){const n=document.createTextNode("");return e.appendChild(n),n}if(e.lastChild.nodeType===Node.TEXT_NODE)return e.lastChild;const r=document.createTextNode("");return e.appendChild(r),r}function Vpe(i,t){var n;const e=document.createRange(),r=h0(t);r.nodeType===Node.TEXT_NODE?e.setStart(r,((n=r.textContent)==null?void 0:n.length)||0):e.setStart(r,0),e.collapse(!0),i.removeAllRanges(),i.addRange(e)}function d0(i){const t=document.createTreeWalker(i,NodeFilter.SHOW_TEXT,null),e=[];let r;for(;(r=t.nextNode())!==null;)e.push(r);return e}function Ype(i,t,e){var a;const r=document.createRange();r.setStart(i,t),r.collapse(!0);const n=r.getBoundingClientRect();if(!n.width&&!n.height){const c=(a=i.parentElement)==null?void 0:a.getBoundingClientRect();if(c){const l=e.y<c.top?c.top-e.y:e.y>c.bottom?e.y-c.bottom:0,u=t===0?c.left:c.right;return Math.abs(e.x-u)+l*4}}const s=n.left+n.width/2,o=n.top+n.height/2;return Math.abs(e.x-s)+Math.abs(e.y-o)*4}function Gpe(i,t){var n;const e=d0(i);if(!e.length){const s=h0(i);return s.nodeType===Node.TEXT_NODE?{node:s,offset:0}:void 0}let r;for(const s of e){const o=((n=s.textContent)==null?void 0:n.length)||0;for(let a=0;a<=o;a++){const c=Ype(s,a,t);(!r||c<r.distance)&&(r={node:s,offset:a,distance:c})}}return r?{node:r.node,offset:r.offset}:void 0}function Hpe(i,t,e){const r=Gpe(t,e);if(!r)return!1;const n=document.createRange();return n.setStart(r.node,r.offset),n.collapse(!0),i.removeAllRanges(),i.addRange(n),!0}function Lg(i,t){return!!(i!=null&&i.anchorNode)&&t.contains(i.anchorNode)}function Rg(i){let t=null,e=!1;for(const n of Array.from(i.childNodes)){if(n instanceof HTMLDivElement){t=n;continue}n.nodeType===Node.TEXT_NODE&&(t||(t=document.createElement("div"),i.insertBefore(t,n),e=!0),t.appendChild(n),e=!0)}const r=Array.from(i.childNodes).reverse().find(n=>n instanceof HTMLDivElement);return{changed:e,lastLine:r||null}}function Qpe(i){const t=d0(i);return{textContent:t.map(e=>e.textContent||"").join(""),textNodes:t}}function f0(i){const t=[];for(let e=0;e<i.childNodes.length;e++){const r=i.childNodes[e];if(r.nodeName==="#text"&&e===0){const n=r.textContent.split(/\n/),s=n.pop();t.push(...n),s&&t.push(s)}else if(r.nodeName==="DIV"){const s=(r.innerText??r.textContent??"").split(/\n/);if(s.length===2&&s[0]===""&&s[1]==="")t.push("");else{const o=s.shift();(o||o==="")&&t.push(o);const a=s.pop();t.push(...s),a&&t.push(a)}}}return t}function g0(i){return xt(f0(i))}function us(i,t){var n,s;if(!i.length)return;let e=Math.max(0,t);for(const o of i){const a=((n=o.textContent)==null?void 0:n.length)||0;if(e<=a)return{node:o,offset:e};e-=a}const r=i[i.length-1];return{node:r,offset:((s=r.textContent)==null?void 0:s.length)||0}}function Zpe(i){const{hasPoint:t,previousByPoint:e,hasSelectionInEditor:r,rangeCount:n,isCollapsed:s}=i;return!t&&e&&r&&n>0&&s}const Ei=5;class Kpe{constructor(t){R(this,"internalMsgEmitter");R(this,"publicMsgEmitter");R(this,"control");R(this,"editors");R(this,"activeId");R(this,"proxyMap");R(this,"taskqueue",new Map);R(this,"undoTickerId");R(this,"checkLocalTextBlur",ve.debounce(()=>{if(this.collector)for(const[t,e]of this.editors.entries())e.opt.workState!==ge.Done&&this.collector.isLocalId(t)&&this.activeId!==t&&(pa(e.opt.text)?this.unActive(t):this.delete(t,!0,!0))},100));const{control:e,internalMsgEmitter:r,publicMsgEmitter:n}=t;this.control=e,this.internalMsgEmitter=r,this.publicMsgEmitter=n;const s=new Map;this.proxyMap=new Vn;const o=this,a=Vn.interceptors.set;Vn.interceptors.set=function(l,u){return o.interceptors.set(l,u),a.call(this,l,u)};const c=Vn.interceptors.delete;Vn.interceptors.delete=function(l){return o.interceptors.delete(l),c.call(this,l)},this.editors=this.proxyMap.createProxy(s)}get collector(){return this.control.collector}set UndoTickerId(t){this.undoTickerId=t}get UndoTickerId(){return this.undoTickerId}getDoneUndoTicker(t,e,r){const n=r??e,s=this.control.viewContainerManager.getUndoTickerId(t);if(n===ge.Done)return this.undoTickerId&&s===this.undoTickerId?this.undoTickerId:s}ackDoneRender(t,e,r,n,s){t&&(this.internalMsgEmitter.emit("ackRenderUndoTicker",t,e,r,{requestId:n,emitEventType:s}),this.undoTickerId=void 0)}filterEditor(t){const e=new Map;return this.editors.forEach((r,n)=>{r.viewId===t&&e.set(n,r)}),e}get interceptors(){return{set:(t,e)=>{var x,j,w,y,f,M,T,b,C;if(!this.collector)return!0;const{viewId:r,scenePath:n,canSync:s,canWorker:o,type:a,opt:c,dataType:l,updateNodeOpt:u,requestId:h,emitEventType:d,skipStorageDispatch:g}=e,p=this.getDoneUndoTicker(r,c==null?void 0:c.workState,u==null?void 0:u.workState);if(!o&&!s)return!0;const I=((x=this.collector)==null?void 0:x.isLocalId(t))?(j=this.collector)==null?void 0:j.transformKey(t):t,D=((w=this.collector)==null?void 0:w.storage[r])&&this.collector.storage[r][n]&&this.collector.storage[r][n][I]||void 0;D?D.toolsType===K.Text&&(o&&(this.control.worker.queryTaskBatchData({workId:t,msgType:he.UpdateNode}).forEach(P=>{var E;(E=this.control.worker)==null||E.taskBatchData.delete(P)}),(T=this.control.worker)==null||T.taskBatchData.add({workId:t,msgType:he.UpdateNode,dataType:l||Ee.Local,toolsType:K.Text,opt:c,viewId:r,scenePath:n,willRefresh:!0}),(b=this.control.worker)==null||b.runAnimation()),s&&!g&&((C=this.collector)==null||C.dispatch({type:he.UpdateNode,workId:t,toolsType:K.Text,opt:c,viewId:r,scenePath:n,updateNodeOpt:u,requestId:h,emitEventType:d,needUndoTicker:p}),this.ackDoneRender(p,r,n,h,d),c.workState===ge.Done&&this.control.runEffectWork(()=>{this.control.worker.setShapeSelectorByWorkId(t,r)}))):a===vr.Text&&(s&&!g&&((y=this.collector)==null||y.dispatch({type:c.text&&he.FullWork||he.CreateWork,workId:t,toolsType:K.Text,opt:c,isSync:!0,viewId:r,scenePath:n,updateNodeOpt:u,requestId:h,emitEventType:d,needUndoTicker:p}),this.ackDoneRender(p,r,n,h,d)),o&&((f=this.control.worker)==null||f.taskBatchData.add({workId:t,msgType:c.text&&he.FullWork||he.CreateWork,dataType:l||Ee.Local,toolsType:K.Text,opt:c,viewId:r,scenePath:n,willRefresh:!0}),(M=this.control.worker)==null||M.runAnimation()))},delete:t=>{var c,l,u;if(!this.collector)return!0;const e=this.editors.get(t);if(!e)return!0;const{viewId:r,scenePath:n,canSync:s,canWorker:o}=e,a=this.getDoneUndoTicker(r,ge.Done);if(!o&&!s)return!0;o&&((c=this.control.worker)==null||c.taskBatchData.add({workId:t,toolsType:K.Text,msgType:he.RemoveNode,dataType:Ee.Local,viewId:r,scenePath:n,willRefresh:!0}),(l=this.control.worker)==null||l.runAnimation()),s&&((u=this.collector)==null||u.dispatch({type:he.RemoveNode,removeIds:[t],toolsType:K.Text,viewId:r,scenePath:n,needUndoTicker:a}),this.ackDoneRender(a,r,n))},clear(){return!0}}}computeTextActive(t,e){var s,o,a,c;const r=(s=this.control.viewContainerManager)==null?void 0:s.transformToScenePoint(t,e),n=(o=this.control.viewContainerManager)==null?void 0:o.getCurScenePath(e);e&&n&&((a=this.control.worker)==null||a.taskBatchData.add({msgType:he.GetTextActive,dataType:Ee.Local,op:r,viewId:e,scenePath:n}),(c=this.control.worker)==null||c.runAnimation())}checkEmptyTextBlur(){var e;let t=this.activeId;for(const[r,n]of this.editors.entries())if(n.opt.uid&&n.opt.uid===((e=this.collector)==null?void 0:e.uid)){t=r;break}if(t){const r=this.editors.get(t);pa(r==null?void 0:r.opt.text)?this.unActive(t):this.delete(t,!0,!0)}this.checkLocalTextBlur()}onCameraChange(t,e){var r,n;for(const[s,o]of this.editors.entries())if(o.viewId===e){const{boxPoint:a,boxSize:c}=o.opt,l=a&&((r=this.control.viewContainerManager)==null?void 0:r.transformToOriginPoint(a,o.viewId)),u=(n=this.control.viewContainerManager)==null?void 0:n.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:o.opt,scale:t.scale,type:vr.Text,viewId:e,scenePath:u,canWorker:!1,canSync:!1};this.editors.set(s,h),this.control.viewContainerManager.updateTextEditorInfo(e,this.activeId)}}}deriveTextEditorInfoFromServiceData(t,e={}){var I,D,x;const{workId:r,opt:n,msgType:s,viewId:o,scenePath:a,dataType:c,updateNodeOpt:l}=t;if(!r||!o||!a)return;const u=r.toString();if(s===he.RemoveNode){this.delete(u,!0,!0);return}const{boxPoint:h,boxSize:d}=n,g=h&&((I=this.control.viewContainerManager)==null?void 0:I.transformToOriginPoint(h,o)),p=this.control.viewContainerManager.getView(o),v={x:g&&g[0]||0,y:g&&g[1]||0,w:d&&d[0]||0,h:d&&d[1]||0,opt:n,type:vr.Text,canWorker:e.canWorker??!0,canSync:e.canSync??!1,dataType:c,scale:((D=p==null?void 0:p.cameraOpt)==null?void 0:D.scale)||1,viewId:o,scenePath:a};if(n&&n.workState===ge.Done&&!this.control.cursor.isEnableCursor&&h&&d){let w=l==null?void 0:l.uid;if(!w){const y=this.editors.get(u);w=y&&((x=y.opt)==null?void 0:x.uid)}w&&this.control.cursor.collectServiceCursor({op:h&&[h[0]+d[0],h[1]+d[1]],uid:w,workState:ge.Done,cursorTool:cc(K.Text),viewId:o,type:he.Cursor})}return this.editors.set(u,v),c===Ee.Service&&n.workState===ge.Done&&this.activeId===u&&(this.activeId=void 0),(e.updateView??!0)&&this.control.viewContainerManager.updateTextEditorInfo(o,this.activeId),v}onServiceDerive(t){this.deriveTextEditorInfoFromServiceData(t)}updateForViewEdited(t,e){var n;this.editors.set(t,e);const r=(n=this.taskqueue.get(t))==null?void 0:n.resolve;r&&r(e)}active(t,e){var n;const r=this.editors.get(t);r&&r.viewId&&(r.opt.workState=ge.Start,r.opt.uid=(n=this.collector)==null?void 0:n.uid,this.activeId=t,r.canWorker=!0,r.canSync=!0,e&&r.viewId&&this.addUndoTicker(e,r.viewId),r.undoTickerId=e||r.undoTickerId||this.undoTickerId,this.editors.set(t,r),this.control.viewContainerManager.updateTextEditorInfo(r.viewId,this.activeId))}unActive(t){var r;const e=this.editors.get(t);if(e&&e.viewId){const n=e.undoTickerId||this.control.viewContainerManager.getUndoTickerId(e.viewId)||this.undoTickerId;n&&this.internalMsgEmitter.emit("finalizeRequested",n,e.viewId,[t],e.scenePath),e.opt.workState=ge.Done,e.opt.uid=void 0,e.canWorker=!0,e.canSync=!0,this.editors.set(t,e),this.activeId=void 0;const s=(r=this.control.viewContainerManager.getView(e.viewId))==null?void 0:r.container;if(s){const o=CSS.escape(t),a=s.querySelector(`.editor-box #${o}`);a&&a.blur()}this.control.viewContainerManager.updateTextEditorInfo(e.viewId,this.activeId)}}addUndoTicker(t,e){this.internalMsgEmitter.emit("addUndoTicker",t,e,{render:!0,storage:!0,source:$e.Text}),this.undoTickerId=t}createTextForMasterController(t,e){var o;const{workId:r,isActive:n,...s}=t;e&&this.addUndoTicker(e,s.viewId),s.opt.uid=(o=this.collector)==null?void 0:o.uid,s.undoTickerId=e||s.undoTickerId||this.undoTickerId,n&&(this.activeId=r),s.dataType=Ee.Local,s.canWorker=!0,s.canSync=!0,this.editors.set(r,s),this.control.viewContainerManager.updateTextEditorInfo(s.viewId,this.activeId)}updateTextForMasterController(t,e){var o;const{workId:r,...n}=t;e&&this.addUndoTicker(e,n.viewId);const s=this.editors.get(r)||{};n.opt&&(n.opt.uid=(o=this.collector)==null?void 0:o.uid),n.undoTickerId=e||s.undoTickerId||this.undoTickerId,n.dataType=Ee.Local,this.editors.set(r,{...s,...n}),this.control.viewContainerManager.updateTextEditorInfo(n.viewId,this.activeId)}async updateTextControllerWithEffectAsync(t,e){var u;const{workId:r,...n}=t;e&&this.addUndoTicker(e,n.viewId);const s=this.editors.get(r)||{};n.opt&&(n.opt.uid=(u=this.collector)==null?void 0:u.uid),n.undoTickerId=e||s.undoTickerId||this.undoTickerId,n.dataType=Ee.Local;const o={...s,...n};if(this.editors.set(r,o),this.control.viewContainerManager.updateTextEditorInfo(n.viewId,this.activeId),this.taskqueue.has(r)){const h=this.taskqueue.get(r);return h&&(h.clocker&&clearTimeout(h.clocker),this.taskqueue.delete(r)),await this.updateTextControllerWithEffectAsync(t)}const a=setTimeout(()=>{var d;const h=(d=this.taskqueue.get(r))==null?void 0:d.resolve;h&&h(o)},50),c=await new Promise(h=>{this.taskqueue.set(r,{resolve:h,clocker:a})}),l=this.taskqueue.get(r);return l&&(l.clocker&&clearTimeout(l.clocker),this.taskqueue.delete(r)),c}updateTextForWorker(t,e){const{workId:r,isActive:n,...s}=t,o=this.editors.get(r)||{},a={...o,...s};if(e&&this.addUndoTicker(e,s.viewId),a.undoTickerId=e||o.undoTickerId||this.undoTickerId,n){a.canWorker=!1,a.canSync=!1,this.editors.set(r,a),this.active(r);return}this.editors.set(r,a),this.control.viewContainerManager.updateTextEditorInfo(s.viewId,this.activeId)}get(t){return this.editors.get(t)}delete(t,e,r){const n=this.editors.get(t);if(n){const s=n.viewId;n.canSync=e,n.canWorker=r,this.editors.delete(t),this.activeId===t&&(this.activeId=void 0),this.control.viewContainerManager.updateTextEditorInfo(s,this.activeId)}}deleteBatch(t,e,r){const n=new Set;for(const s of t){const o=this.editors.get(s);if(o){const a=o.viewId;o.canSync=e,o.canWorker=r,this.editors.delete(s),this.activeId===s&&(this.activeId=void 0),n.add(a)}}for(const s of n)this.control.viewContainerManager.updateTextEditorInfo(s,this.activeId)}clear(t,e){this.editors.forEach((r,n)=>{r.viewId===t&&(e&&(r.canSync=!1),r.canWorker=!1,this.editors.delete(n))}),this.activeId=void 0,this.control.viewContainerManager.updateTextEditorInfo(t,this.activeId)}destory(){this.editors.clear(),this.activeId=void 0}insertText(t,e,r,n){var p,v;const s=(p=this.control.room)==null?void 0:p.state.memberState;if(!s)return;const o=this.control.viewContainerManager.getView(t);if(!(o!=null&&o.focusScenePath))return;const a=o==null?void 0:o.cameraOpt,c=this.control.getToolsOpt(K.Text,s);if(!c)return;const l=(v=this.control.viewContainerManager)==null?void 0:v.transformToOriginPoint([e,r],t),h=Sl(n,{whiteList:{},stripIgnoreTag:!0,stripIgnoreTagBody:["script"]}).split(/\n/),d=c.toolsOpt;d.text=xt(h),d.workState=ge.Doing,d.boxPoint=[Math.round(e),Math.round(r)],d.boxSize=[d.fontSize,d.fontSize];const g=this.control.worker.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:vr.Text,isActive:!0,viewId:t,scenePath:o.focusScenePath},g),g.toString()}updateText(t,e){const r=this.editors.get(t.toString());if(!r)return;const s=Sl(e,{whiteList:{},stripIgnoreTag:!0,stripIgnoreTagBody:["script"]}).split(/\n/);r.opt.text=xt(s),this.control.textEditorManager.updateTextForMasterController({workId:t,opt:r.opt,viewId:r.viewId,canSync:!0,canWorker:!0},this.control.worker.now)}}const pn=class pn extends xe{constructor(e){super(e);R(this,"canRotate",!1);R(this,"scaleType",Ve.proportional);R(this,"toolsType",K.Text);R(this,"tmpPoints",[]);R(this,"workOptions");R(this,"oldRect");this.workOptions=e.toolsOpt}static async normalizeStorageData(e){return this.normalizeStorageDataSync(e)}static normalizeStorageDataSync(e){const r=xe.normalizeStorageDataSync(e);if(r.status==="unrecoverable")return r;const n=r.value,s=n.opt;return s&&s.workState!==ge.Done?(n.type=he.FullWork,n.opt={...s,workState:ge.Done},{status:"stable",value:n}):r}consume(){return{type:he.None}}consumeAll(){return{type:he.None}}consumeService(){}async draw(e){const{workId:r,layer:n,isDrawLabel:s,boxRect:o}=e,{boxSize:a,boxPoint:c,zIndex:l}=this.workOptions,u=n.worldPosition,h=n.worldScaling;if(!c||!a)return;const d={name:r,id:r,pos:[c[0]-Ei,c[1]-Ei],anchor:[0,0],size:a,zIndex:l},g=new dt(d),p={x:c[0]-Ei,y:c[1]-Ei,w:a[0],h:a[1]},v={x:Math.floor(p.x*h[0]+u[0]),y:Math.floor(p.y*h[1]+u[1]),w:Math.floor(p.w*h[0])+2,h:Math.floor(p.h*h[1])+2};this.replace(n,r,g);let I;if(o&&(I=hc(v,o)),(s||o&&I!==Kr.outside)&&n&&this.workOptions.text){const D=await pn.createLabels(this.workOptions,n,v),{labels:x,maxWidth:j}=D;g.append(...x),v.w=Math.ceil(Math.max(j*n.worldScaling[0],v.w))}return v}async consumeServiceAsync(e){var u,h,d,g;const r=(u=this.workId)==null?void 0:u.toString();if(!r)return;const{isFullWork:n,replaceId:s,isDrawLabel:o,boxRect:a}=e;this.oldRect=s&&((d=(h=this.vNodes)==null?void 0:h.get(s))==null?void 0:d.rect)||void 0;const c=n?this.fullLayer:this.drawLayer||this.fullLayer,l=await this.draw({workId:r,layer:c,isDrawLabel:typeof o>"u"&&this.workOptions.workState===ge.Done||o,boxRect:a});return(g=this.vNodes)==null||g.setInfo(r,{rect:l,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:l&&xe.getCenterPos(l,c)}),l}updataOptService(){}async updataOptServiceAsync(e,r,n){var v,I;if(!this.workId)return;const s=this.workId.toString(),{fontColor:o,fontBgColor:a,bold:c,italic:l,lineThrough:u,underline:h,zIndex:d}=e,g=(v=this.vNodes)==null?void 0:v.get(s);if(!g)return;o&&(g.opt.fontColor=o),a&&(g.opt.fontBgColor=a),c&&(g.opt.bold=c),l&&(g.opt.italic=l),Hn(u)&&(g.opt.lineThrough=u),Hn(h)&&(g.opt.underline=h),It(d)&&(g.opt.zIndex=d),this.oldRect=g.rect;const p=await this.draw({workId:s,layer:this.fullLayer,isDrawLabel:typeof r>"u"&&this.workOptions.workState===ge.Done||r,boxRect:n});return(I=this.vNodes)==null||I.setInfo(s,{rect:p,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:p&&xe.getCenterPos(p,this.fullLayer)}),p}clearTmpPoints(){this.tmpPoints.length=0}static getSafetySnippetRatio(e){const r=(e==null?void 0:e.parent).displayRatio||1,n=Math.ceil(e.worldScaling[0]*10)/10;let s=n;return n<=2?s=n*r*2:n>2&&n<=3?s=n*r*1.6:n>3&&n<=4?s=n*r*1.2:n>4&&(s=n*r),Math.floor(s*1e3)/1e3}static getSafetySnippetFontLength(e){return Math.floor(pn.textImageSnippetSize*3/4/e)||1}static async createLabels(e,r,n){var P;const s=[],{x:o,y:a}=n,{width:c,height:l}=(P=r.parent)==null?void 0:P.parent,u=Nn(e.text),h=u.length,{fontSize:d,lineHeight:g,bold:p,textAlign:v,italic:I,fontFamily:D,verticalAlign:x,fontColor:j,fontBgColor:w,underline:y,lineThrough:f}=e,M=pn.getSafetySnippetRatio(r)||1,T=Math.floor(d*M),b=pn.getSafetySnippetFontLength(T);let C=0;for(let E=0;E<h;E++){const O=u[E],V=g||T*1.5;if(O){const N=a0e(O),A=[0,0],k=[0,d*1.2];x==="middle"&&(A[1]=Math.floor(E*d*1.2+6+d*(1.1-1)));const U=[0,Math.floor(-d*.15)];A[0]=6;const Z=Math.sin(Math.PI/180*20);let Q=0;const ce=[];let L=0;for(;L<N;){v==="left"&&(U[0]=Q),L===0&&I==="italic"&&(U[0]=U[0]-Z/2*d);const H=O.slice(L,L+b),$={anchor:[0,0],pos:U,text:H,fontFamily:D,fontSize:T,lineHeight:V,strokeColor:j,fontWeight:p,fillColor:j,textAlign:v,fontStyle:I,scale:[1/M,1/M]},ee=new ph($),ie=await ee.textImageReady;let le=!0;if(ie){const pe=ie.rect&&ie.rect[2],Te=ie.rect&&ie.rect[3];if(pe&&Te){const z=pe/M,B=Te/M;Q=z+Q,I==="italic"&&(p==="bold"?Q=Q-Z*d*1.2:Q=Q-Z*d),((U[0]+A[0]+z)*r.worldScaling[0]+o<=0||(U[0]+A[0])*r.worldScaling[0]+o>=c||(U[1]+A[1]+B)*r.worldScaling[1]+a<=0||(U[1]+A[1])*r.worldScaling[1]+a>=l)&&(ee.disconnect(),le=!1),le&&ce.push(ee)}}L+=b}k[0]=Q,I==="italic"&&(k[0]=k[0]+Z*d),C=Math.max(C,k[0]);let W=!0;if(((A[0]+k[0])*r.worldScaling[0]+o<=0||A[0]*r.worldScaling[0]+o>=c||(A[1]+k[1])*r.worldScaling[0]+a<=0||A[1]*r.worldScaling[1]+a>=l)&&(W=!1),W){if(y){const ee=Math.floor(d/10),ie={normalize:!1,pos:[0,d*1.1+ee/2],lineWidth:ee,points:[0,0,Math.ceil(k[0]),0],strokeColor:j,className:"underline"},le=new wr(ie);ce.push(le)}if(f){const ee={normalize:!1,pos:[0,d*1.2/2],lineWidth:Math.floor(d/10),points:[0,0,Math.ceil(k[0]),0],strokeColor:j,className:"lineThrough"},ie=new wr(ee);ce.push(ie)}const H={pos:A,anchor:[0,0],size:k,bgcolor:w},$=new dt(H);$.append(...ce),s.push($)}}}return{labels:s,maxWidth:C}}static updateNodeOpt(e){const{node:r,opt:n,vNodes:s,targetNode:o}=e,{fontBgColor:a,fontColor:c,translate:l,originPoint:u,scenePoint:h,scale:d,bold:g,italic:p,lineThrough:v,underline:I,fontSize:D,textInfos:x,zIndex:j}=n,w=o&&Lt(o)||s.get(r.name);if(!w||!r.parent)return;const f=w.opt;if(It(j)&&(r.setAttribute("zIndex",j),w.opt.zIndex=j),c&&f.fontColor&&(f.fontColor=c,r.children.forEach(M=>{M.tagName==="GROUP"&&M.children.forEach(T=>{T.tagName==="LABEL"?(T.setAttribute("fillColor",c),T.setAttribute("strokeColor",c)):T.tagName==="POLYLINE"&&T.setAttribute("strokeColor",c)})})),a&&f.fontBgColor&&(f.fontBgColor=a,r.children.forEach(M=>{M.tagName==="GROUP"&&M.setAttribute("bgcolor",a)})),g&&(f.bold=g),p&&(f.italic=p),Hn(v)&&(f.lineThrough=v),Hn(I)&&(f.underline=I),D&&(f.fontSize=D),u&&h&&d&&o&&f.boxPoint){const M=x==null?void 0:x.get(r.name);if(M){const{fontSize:P,boxSize:E}=M;f.boxSize=E||f.boxSize,f.fontSize=P||f.fontSize}const T=[f.boxPoint[0],f.boxPoint[1]];uc(f.boxPoint,h,d,l);const b=[w.op[0],w.op[1]],C=[b[0]-T[0],b[1]-T[1]];if(w.centerPos=[w.centerPos[0]+C[0],w.centerPos[1]+C[1]],w.opt.eraserlines)for(const P of w.opt.eraserlines){const{op:E,thickness:O}=P;P.thickness=Math.round(O*Math.max(d[0],d[1]));for(let V=0;V<E.length;V++)xs(E[V],h,d,l)}}else if(l&&f.boxPoint&&(f.boxPoint=[Math.round(f.boxPoint[0]+l[0]),Math.round(f.boxPoint[1]+l[1])],w.centerPos=[w.centerPos[0]+l[0],w.centerPos[1]+l[1]],w.opt.eraserlines))for(const M of w.opt.eraserlines){const{op:T}=M;for(let b=0;b<T.length;b++){const C=T[b].map((P,E)=>E%2?P+l[1]:P+l[0]);M.op[b]=C}}return w&&s.setInfo(r.name,w),w==null?void 0:w.rect}static getRectFromLayer(e,r){const n=e.getElementsByName(r)[0];if(n){const s=n.getBoundingClientRect();let o={x:Math.floor(s.x),y:Math.floor(s.y),w:Math.floor(s.width+2),h:Math.floor(s.height+2)};return n.children.forEach(a=>{if(a.tagName==="GROUP"){const c=n.getBoundingClientRect();o=Ge(o,{x:Math.floor(c.x),y:Math.floor(c.y),w:Math.floor(c.width+2),h:Math.floor(c.height+2)})}}),o}}};R(pn,"textImageSnippetSize",1024*4),R(pn,"SafeBorderPadding",30);let Ls=pn;const qpe=.01;function p0(i,t,e={}){let r=i.length-1;const n=e.protectedIndex??-1,s=e.timestamp??Date.now();for(let o=0;o<t.length;o+=2){const a=new Ae(t[o],t[o+1]),c=i[i.length-1];if(!c){a.setT(s),i.push(a);continue}if(a.x===c.x&&a.y===c.y){c.setT(s);continue}const l=i.length-1;if(i.length>1&&l>n){const h=i[l-1],d=fe.Sub(c,h).uni(),g=fe.Sub(a,c).uni();Number.isFinite(d.x)&&Number.isFinite(d.y)&&Number.isFinite(g.x)&&Number.isFinite(g.y)&&fe.Equals(d,g,qpe)&&(i.pop(),r--)}const u=i[i.length-1];a.setv(fe.Sub(a,u).uni()),a.setT(s),i.push(a)}return Math.max(r,0)}const Di=class Di extends xe{constructor(e){super(e);R(this,"canRotate",!1);R(this,"scaleType",Ve.none);R(this,"toolsType",K.PencilEraser);R(this,"tmpPoints",[]);R(this,"workOptions");R(this,"worldPosition");R(this,"worldScaling");R(this,"eraserRect");R(this,"eraserPolyline");this.workOptions=e.toolsOpt,this.worldPosition=this.fullLayer.worldPosition,this.worldScaling=this.fullLayer.worldScaling}combineConsume(e){const{workerEngine:r}=e;if(this.tmpPoints.length===0)return{type:he.None};const{thickness:n}=this.workOptions,{width:s,height:o}=Di.eraserSizes[n],a=Math.round(Math.max(s,o)/this.worldScaling[0]),{rect:c,willNewNodes:l,willDeleteNodes:u}=this.getChangeNodes(a,r);return{...this.baseConsumeResult,type:he.DrawWork,rect:c,willNewNodes:l,willDeleteNodes:u}}consumeService(){}updateTempPoints(e,r){return p0(this.tmpPoints,e)}getChangeNodes(e,r){const n=new Map,s=new Set;let o;if(!this.vNodes)return{willDeleteNodes:s,willNewNodes:n,rect:o};const a=this.worldPosition;let c=et(this.tmpPoints,e);c=zs(c,a),c=E0(c,this.worldScaling,a);const{nodeRange:l}=this.vNodes.getRectIntersectRange(c);if(!l.size)return{willDeleteNodes:s,willNewNodes:n,rect:o};const u=this.computEraserPointLines(this.tmpPoints,90);for(const[h,d]of l.entries()){if(d.toolsType!==K.Pencil)continue;let g=zs(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],v=[],I=[];for(const D of u)wu.polyline(D,p,v);if(v.length&&d.opt)for(const D of v){const x=[];for(let j=0;j<D.length;j++)j!==0&&Zr(D[j],D[j-1])||x.push(...D[j]);I.push(x)}if(I.length&&r){const D=r.createWorkShapeNode({workId:h,toolsType:K.Pencil,toolsOpt:d.opt});D.setWorkId(h);const x=D==null?void 0:D.computPencilPoints({op:d.op,eraserPolylines:I,eraserThickness:e});if(o=Ge(o,d.rect),s.add(h),r.removeNode(h),x.length)for(let j=0;j<x.length;j++){const w=`${h}_${Date.now()}_${j}`,y=w,M=r.setFullWork({workId:y,opt:d.opt,toolsType:K.Pencil}).consumeService({op:x[j],isFullWork:!0,replaceId:y});r.clearWorkShapeNodeCache(y),o=Ge(o,M),n.set(w,{...d,toolsType:K.Pencil,rect:M??d.rect,name:w,op:x[j]})}}}return{willNewNodes:n,willDeleteNodes:s,rect:o}}consume(e){const{data:r}=e,{op:n}=r;if(!n||n.length===0)return{type:he.None,...this.baseConsumeResult};const{thickness:s}=this.workOptions,{width:o,height:a}=Di.eraserSizes[s],c=Math.max(o,a)/this.worldScaling[0];return this.updateTempPoints(n,c),{type:he.None,...this.baseConsumeResult}}computEraserPointLines(e,r=60){const n=[];let s=0;const o=360-r;for(let a=1;a<e.length;a++){const c=e[a-1],l=e[a];if(a===1&&s===0&&(n[s]=[c.XY]),n[s].push(l.XY),a<e.length-1){const u=l.getAngleByPoints(c,e[a+1]);(u<r||u>o)&&(s++,n[s]=[l.XY])}}return e.length===1&&n.length===0&&n.push([e[0].XY,e[0].XY]),n}consumeAll(e){const{workerEngine:r}=e;if(this.replace(this.fullLayer,this.workId),!this.tmpPoints.length)return{type:he.None,...this.baseConsumeResult};const{thickness:n}=this.workOptions,{width:s,height:o}=Di.eraserSizes[n],a=Math.max(s,o)/this.worldScaling[0],{willDeleteNodes:c,willNewNodes:l,rect:u}=this.getChangeNodes(a,r);if(c.size===0&&l.size===0)return{type:he.FullWork,...this.baseConsumeResult,rect:u};const h=[];this.tmpPoints.map(g=>{h.push(g.x,g.y,a/2)});const d=xt(h);return{...this.baseConsumeResult,type:he.FullWork,dataType:Ee.Local,rect:u,ops:d,willNewNodes:l,willDeleteNodes:c}}clearTmpPoints(){this.tmpPoints.length=0}};R(Di,"eraserSizes",Ph);let ma=Di;const Xpe=new Set([K.Image,K.BackgroundSVG]),Og={"shape.vertices":new Set([K.Polygon,K.Star]),"shape.innerVerticeStep":new Set([K.Star]),"shape.innerRatio":new Set([K.Star]),"shape.placement":new Set([K.SpeechBalloon])},Jpe=new Set(["fontColor","fontBgColor","fontSize","bold","italic","underline","lineThrough"]),_pe=new Set(["strokeColor","thickness","strokeType"]),eme=new Set(["fillColor"]),tme=new Set(["zIndexLayer"]),rme=new Set([K.Pencil,K.LaserPen,K.Arrow,K.Straight]),zg=new Set([K.Rectangle,K.Ellipse,K.Triangle,K.Rhombus,K.Polygon,K.Star,K.SpeechBalloon]),nme=new Set([K.Pencil,K.Arrow,K.Straight,K.Rectangle,K.Ellipse,K.Star,K.Triangle,K.Rhombus,K.Polygon,K.SpeechBalloon]);function ime(i){return i!==void 0&&nme.has(i)}const sme=new Set([K.Pencil]),ome=new Set([K.LaserPen,K.Arrow,K.Straight,K.Rectangle,K.Ellipse,K.Star,K.Polygon,K.SpeechBalloon]);function m0(i){return i===ze.Normal||i===ze.Stroke||i===ze.Dotted||i===ze.LongDotted}function Ai(i,t){return i?tme.has(t)?!0:t==="isLocked"?Xpe.has(i):Jpe.has(t)?i===K.Text:t in Og?Og[t].has(i):eme.has(t)?zg.has(i):_pe.has(t)?rme.has(i)||zg.has(i):!1:!1}function ame(i){return["strokeColor","fillColor","thickness","strokeType","fontColor","fontBgColor","fontSize","bold","italic","underline","lineThrough","isLocked","zIndexLayer","shape.vertices","shape.innerVerticeStep","shape.innerRatio","shape.placement"].filter(e=>Ai(i,e))}function hs(i){var e,r,n,s;const t=[];return i.strokeColor!==void 0&&t.push("strokeColor"),i.fillColor!==void 0&&t.push("fillColor"),i.thickness!==void 0&&t.push("thickness"),i.strokeType!==void 0&&t.push("strokeType"),i.fontColor!==void 0&&t.push("fontColor"),i.fontBgColor!==void 0&&t.push("fontBgColor"),i.fontSize!==void 0&&t.push("fontSize"),i.bold!==void 0&&t.push("bold"),i.italic!==void 0&&t.push("italic"),i.underline!==void 0&&t.push("underline"),i.lineThrough!==void 0&&t.push("lineThrough"),i.isLocked!==void 0&&t.push("isLocked"),i.zIndexLayer!==void 0&&t.push("zIndexLayer"),((e=i.shape)==null?void 0:e.vertices)!==void 0&&t.push("shape.vertices"),((r=i.shape)==null?void 0:r.innerVerticeStep)!==void 0&&t.push("shape.innerVerticeStep"),((n=i.shape)==null?void 0:n.innerRatio)!==void 0&&t.push("shape.innerRatio"),((s=i.shape)==null?void 0:s.placement)!==void 0&&t.push("shape.placement"),t}function jg(i,t){return!i||t===void 0||!Ai(i,"strokeType")?!1:sme.has(i)?m0(t):ome.has(i)?t===ze.Normal||t===ze.Dotted||t===ze.LongDotted:!1}function cme(i,t,e){const r=i-(e?1:2);if(!(r<1||r<=t))return{start:Math.max(t,0),end:r,committedIndex:r}}const Pi=class Pi extends xe{constructor(e){super(e);R(this,"canRotate",!1);R(this,"scaleType",Ve.none);R(this,"toolsType",K.BitMapEraser);R(this,"tmpPoints",[]);R(this,"workOptions");R(this,"worldPosition");R(this,"worldScaling");R(this,"eraserRect");R(this,"eraserPolyline");R(this,"oldRect");R(this,"committedPointIndex",-1);R(this,"changedNodes",new Map);R(this,"doingLines",new Map);R(this,"doingTransformDisposers",new Map);R(this,"deletedNodes",new Set);R(this,"changedRect");this.workOptions=e.toolsOpt,this.worldPosition=this.fullLayer.worldPosition,this.worldScaling=this.fullLayer.worldScaling}combineConsume(e){const{workerEngine:r}=e,n=this.getDeltaPoints(!0);if(!n)return{type:he.None};const{thickness:s}=this.workOptions,{width:o,height:a}=Pi.eraserSizes[s],c=Math.round(Math.max(o,a)/this.worldScaling[0]),{willDeleteNodes:l,rect:u}=this.getChangeNodes(n.points,c,r);return this.committedPointIndex=n.committedIndex,{...this.baseConsumeResult,type:he.DrawWork,rect:u,willDeleteNodes:l}}consumeService(){}updateTempPoints(e,r){return p0(this.tmpPoints,e,{protectedIndex:this.committedPointIndex})}getChangeNodes(e,r,n){const s=new Map,o=new Set;let a;if(!this.vNodes)return{willDeleteNodes:o,willUpdateNodes:s,rect:a};const c=this.worldPosition;let l=et(e,r);l=zs(l,c),l=E0(l,this.worldScaling,c);const{nodeRange:u}=this.vNodes.getRectIntersectRange(l);if(!u.size)return{willDeleteNodes:o,willUpdateNodes:s,rect:a};const h=this.computEraserPointLines(e,120);for(const[d,g]of u.entries()){if(!ime(g.toolsType))continue;let p=zs(g.rect,[-c[0],-c[1]]);p={x:p.x/this.worldScaling[0],y:p.y/this.worldScaling[1],w:p.w/this.worldScaling[0],h:p.h/this.worldScaling[1]};const v=[p.x,p.y,p.x+p.w,p.y+p.h],I=[],D=[];for(const w of h)wu.polyline(w,v,I);if(I.length&&g.opt)for(const w of I){const y=[];for(let f=0;f<w.length&&!(isNaN(w[f][0])||isNaN(w[f][1]));f++){const M=w[f].map(T=>Math.round(T*100)/100);if(f!==0){const T=w[f-1].map(b=>Math.round(b*100)/100);if(Zr(M,T))continue}y.push(...M)}y.length!==0&&D.push(y)}if(!D.length)continue;let x=this.doingLines.get(d);x||(x=[],this.doingLines.set(d,x),this.vNodes&&this.doingTransformDisposers.set(d,sge(this.vNodes,d,w=>{const y=this.doingLines.get(d);y&&age(y,w)},()=>{this.doingLines.delete(d),this.changedNodes.delete(d)})));const j=x.find(w=>w.workId===this.workId);if(j?j.op.push(...D):x.push({workId:this.workId,op:D,thickness:r}),n){const{toolsType:w}=g,y=n.createWorkShapeNode({workId:d,toolsType:w,toolsOpt:{...g.opt,doingLines:x}});y==null||y.setWorkId(d);const f=y==null?void 0:y.consumeService({op:g.op,isFullWork:!0,replaceId:d});a=Ge(a,f)}s.set(d,g),this.changedNodes.set(d,g)}return this.changedRect=Ge(this.changedRect,a),{willUpdateNodes:s,willDeleteNodes:o,rect:a}}consume(e){const{data:r}=e,{op:n}=r;if(!n||n.length===0)return{type:he.None,...this.baseConsumeResult};const{thickness:s}=this.workOptions,{width:o,height:a}=Pi.eraserSizes[s],c=Math.round(Math.max(o,a)/this.worldScaling[0]);return this.updateTempPoints(n,c),{type:he.None,...this.baseConsumeResult}}computEraserPointLines(e,r=60){const n=[];let s=0;const o=360-r;for(let a=1;a<e.length;a++){const c=e[a-1],l=e[a];if(a===1&&s===0&&(n[s]=[c.XY]),n[s].push(l.XY),a<e.length-1){const u=l.getAngleByPoints(c,e[a+1]);(u<r||u>o)&&(s++,n[s]=[l.XY])}}return e.length===1&&n.length===0&&n.push([e[0].XY,e[0].XY]),n}consumeAll(e){const{workerEngine:r}=e;if(this.replace(this.fullLayer,this.workId),!this.tmpPoints.length)return{type:he.None,...this.baseConsumeResult};const{thickness:n}=this.workOptions,{width:s,height:o}=Pi.eraserSizes[n],a=Math.round(Math.max(s,o)/this.worldScaling[0]),c=this.getDeltaPoints(!0);c&&(this.getChangeNodes(c.points,a,r),this.committedPointIndex=c.committedIndex),this.commitDoingFaces(),this.workOptions.removeOnDone!==!1&&this.confirmChangedNodeDeletions(r);const l=new Set(this.deletedNodes),u=new Map(this.changedNodes),h=this.changedRect;if(l.size===0&&u.size===0)return{type:he.FullWork,...this.baseConsumeResult,rect:h};const d=[];this.tmpPoints.map(p=>{d.push(p.x,p.y,a/2)});const g=xt(d);return{...this.baseConsumeResult,type:he.FullWork,dataType:Ee.Local,rect:h,ops:g,willUpdateNodes:u,willDeleteNodes:l}}clearTmpPoints(){this.tmpPoints.length=0,this.committedPointIndex=-1,this.changedNodes.clear(),this.doingLines.clear();for(const e of this.doingTransformDisposers.values())e();this.doingTransformDisposers.clear(),this.deletedNodes.clear(),this.changedRect=void 0}commitDoingFaces(){var e,r;for(const[n,s]of this.doingLines){const o=((e=this.vNodes)==null?void 0:e.get(n))||this.changedNodes.get(n);if(!(o!=null&&o.opt)||!s.length)continue;const a=uge(o.opt,s),c={...o.opt,...a};delete c.eraserlines,o.opt=c,this.changedNodes.set(n,o),(r=this.vNodes)==null||r.setInfo(n,{opt:c})}}confirmChangedNodeDeletions(e){if(e)for(const[r,n]of[...this.changedNodes]){const s=e.createWorkShapeNode({workId:r,toolsType:n.toolsType,toolsOpt:n.opt});s==null||s.setWorkId(r),s==null||s.setEraserDeleteConfirmation(!0);const o=s==null?void 0:s.consumeService({op:n.op,isFullWork:!0,replaceId:r});this.changedRect=Ge(this.changedRect,o),s!=null&&s.isDelete&&(e.removeNode(r),this.deletedNodes.add(r),this.changedNodes.delete(r))}}getDeltaPoints(e){const r=cme(this.tmpPoints.length,this.committedPointIndex,e);if(r)return{points:this.tmpPoints.slice(r.start,r.end+1),committedIndex:r.committedIndex}}};R(Pi,"eraserSizes",Ph);let ya=Pi;class Rs extends xe{constructor(e){super(e);R(this,"canRotate",!1);R(this,"scaleType",Ve.all);R(this,"toolsType",K.BackgroundSVG);R(this,"tmpPoints",[]);R(this,"workOptions");R(this,"oldRect");this.workOptions=e.toolsOpt,this.scaleType=Rs.getScaleType(this.workOptions)}static normalizeStorageData(e){return xe.normalizeStorageData(e)}consume(){return{type:he.None}}consumeAll(){return{type:he.None}}draw(e){const{layer:r,workId:n,replaceId:s}=e,{centerX:o,centerY:a,width:c,height:l,rotate:u,zIndex:h}=this.workOptions,d=(h||0)-100,g=new dt({anchor:[.5,.5],pos:[o,a],name:n,size:[c,l],zIndex:d,rotate:u}),p=new ks({normalize:!0,pos:[0,0],width:c,height:l});g.appendChild(p),this.replace(r,s||n,g);const v=g.getBoundingClientRect();if(v)return{x:Math.floor(v.x-xe.SafeBorderPadding),y:Math.floor(v.y-xe.SafeBorderPadding),w:Math.floor(v.width+xe.SafeBorderPadding*2),h:Math.floor(v.height+xe.SafeBorderPadding*2)}}consumeService(e){var o;const{replaceId:r}=e,n=this.workId,s=this.draw({workId:n,layer:this.fullLayer,replaceId:r});return(o=this.vNodes)==null||o.setInfo(n,{rect:s,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:s&&xe.getCenterPos(s,this.fullLayer)}),s}clearTmpPoints(){this.tmpPoints.length=0}static getScaleType(e){const{uniformScale:r,rotate:n}=e;return r!==!1||n&&Math.abs(n)%90>0?Ve.proportional:Ve.all}static updateNodeOpt(e){const{node:r,opt:n,vNodes:s,targetNode:o}=e,{translate:a,originPoint:c,scenePoint:l,scale:u,angle:h,isLocked:d,zIndexForBackgroundSVG:g}=n,p=o&&Lt(o)||s.get(r.name);if(!p)return;const v=r.parent;if(v){if(It(g)){const I=(g||0)-100;r.setAttribute("zIndex",I),p.opt.zIndex=g}if(Hn(d)&&(p.opt.locked=d),c&&l&&u&&a){const{centerX:I,centerY:D,width:x,height:j,uniformScale:w}=p.opt,y=w!==!1?[u[0],u[0]]:u,f=[I,D],M=[I,D];uc(M,l,y,a);const T=[M[0]-f[0],M[1]-f[1]];p.centerPos=[p.centerPos[0]+T[0],p.centerPos[1]+T[1]],p.opt.width=Math.round(x*y[0]),p.opt.height=Math.round(j*y[1]),p.opt.centerX=M[0],p.opt.centerY=M[1]}else if(a)p.opt.centerX=p.opt.centerX+a[0],p.opt.centerY=p.opt.centerY+a[1],p.centerPos=[p.centerPos[0]+a[0],p.centerPos[1]+a[1]];else if(It(h))if(p.opt.rotate=h,p.scaleType=Rs.getScaleType(p.opt),o){const I=jh(p.rect,h);p.rect=I}else{const I=xe.getRectFromLayer(v,r.name);p.rect=I||p.rect}return p&&s.setInfo(r.name,p),p==null?void 0:p.rect}}}function lc(i){switch(i){case K.Arrow:return i0;case K.Pencil:return e0;case K.Straight:return u0;case K.Ellipse:return s0;case K.Polygon:case K.Triangle:return c0;case K.Star:case K.Rhombus:return a0;case K.Rectangle:return o0;case K.SpeechBalloon:return l0;case K.Text:return Ls;case K.LaserPen:return t0;case K.Eraser:return da;case K.PencilEraser:return ma;case K.BitMapEraser:return ya;case K.Selector:return ga;case K.Image:return Os;case K.BackgroundSVG:return Rs}}async function lme(i){const t=i.toolsType;if(t===void 0)return{status:"unrecoverable",reason:"missing-tools-type"};const e=lc(t);return e?e.normalizeStorageData(i):{status:"unrecoverable",reason:`unsupported-tool:${t}`}}function ume(i){const t=i.toolsType;if(t===void 0)return{status:"unrecoverable",reason:"missing-tools-type"};const e=lc(t);return e?t===K.Text?Ls.normalizeStorageDataSync(i):[K.Pencil,K.Arrow,K.Straight,K.Ellipse,K.Rectangle,K.Polygon,K.Triangle,K.Star,K.Rhombus,K.SpeechBalloon].includes(t)?xe.normalizeDrawableStorageDataSync(i):e.normalizeStorageDataSync(i):{status:"unrecoverable",reason:`unsupported-tool:${t}`}}function Oh(i,t){const{toolsType:e,...r}=i;switch(e){case K.Arrow:return new i0(r);case K.Pencil:return new e0(r);case K.Straight:return new u0(r);case K.Ellipse:return new s0(r);case K.Polygon:case K.Triangle:return new c0(r);case K.Star:case K.Rhombus:return new a0(r);case K.Rectangle:return new o0(r);case K.SpeechBalloon:return new l0(r);case K.Text:return new Ls(r);case K.LaserPen:return new t0(r);case K.Eraser:return new da(r,t);case K.BitMapEraser:return new ya(r);case K.PencilEraser:return new ma(r);case K.Selector:return r.vNodes?new ga({...r,vNodes:r.vNodes,drawLayer:r.fullLayer}):void 0;case K.Image:return new Os(r);case K.BackgroundSVG:return new Rs({...r,toolsOpt:r.toolsOpt});default:return}}function y0(i){const t=[],e=["PATH","SPRITE","POLYLINE","RECT","ELLIPSE","LABEL","SPRITESVG"];for(const r of i){if(r.tagName==="GROUP"&&r.children.length){const n=y0(r.children);t.push(...n)}r.tagName&&e.includes(r.tagName)&&t.push(r)}return t}class au{constructor(t){R(this,"_map");R(this,"_observers",new Set);this._map=new Map(t)}notifyObservers(t,e,r){for(const n of this._observers)n(t,e,r)}observe(t){this._observers.add(t)}unobserve(t){this._observers.delete(t)}get(t){return this._map.get(t)}set(t,e,r=!0){const n=this._map.has(t)?"update":"add";return this._map.set(t,e),r&&this.notifyObservers(n,t,e),this}has(t){return this._map.has(t)}delete(t,e=!0){const r=this._map.get(t),n=this._map.delete(t);return e&&r&&this.notifyObservers("delete",t,r),n}clear(t=!0){const e=this._map.keys();if(this._map.clear(),t)for(const r of e)this.notifyObservers("clear",r,void 0)}get size(){return this._map.size}keys(){return this._map.keys()}values(){return this._map.values()}entries(){return this._map.entries()}forEach(t,e){this._map.forEach(t,e)}}class v0{constructor(t,e){R(this,"viewId");R(this,"scene");R(this,"fullLayer");R(this,"curNodeMap");R(this,"targetNodeMap",[]);R(this,"highLevelIds");R(this,"canClearUids");R(this,"localUid");R(this,"spatialIndex",new X0);R(this,"spatialEntries",new Map);R(this,"verifySpatialIndex",!1);this.viewId=t,this.scene=e,this.curNodeMap=new au}init(t){this.fullLayer=t}get(t){return this.curNodeMap.get(t)}setLocalUid(t){this.localUid=t}getLocalUid(){return this.localUid}setSpatialIndexVerification(t){this.verifySpatialIndex=t}setCanClearUids(t){this.canClearUids=t}getCanClearUids(){return this.canClearUids}getCanEraserNodes(t,e){const r=new Map;for(const[n,s]of t.entries())s.toolsType!==K.BackgroundSVG&&(s.toolsType===K.Image&&s.opt.type===qr.Image&&(s.opt.locked||e&&e.disableEraseImage)||s.toolsType===K.Text&&(s.opt.workState===ge.Doing||s.opt.workState===ge.Start||e&&e.disableEraseText)||this.isCanClearWorkId(n)&&r.set(n,s));return r}getNodesByType(t){const e=new Map;return this.curNodeMap.forEach((r,n)=>{r.toolsType===t&&e.set(n,r)}),e}gethasEraserNodes(){const t=new Map;return this.curNodeMap.forEach((e,r)=>{var n;((n=e.opt.eraserlines)!=null&&n.length||e.opt.eraserFaces)&&t.set(r,e)}),t}hasRenderNodes(){return!0}has(t){return this.curNodeMap.has(t)}setInfo(t,e){const r=this.curNodeMap.get(t)||{name:t,rect:e.rect};e.rect&&(r.rect=Lt(e.rect)),e.op&&e0e(e.op)&&(r.op=Lt(e.op)),e.canRotate&&(r.canRotate=e.canRotate),e.scaleType&&(r.scaleType=e.scaleType),e.opt&&(r.opt=Lt(e.opt)),e.toolsType&&(r.toolsType=e.toolsType),e.centerPos&&(r.centerPos=Lt(e.centerPos)),Hn(e.isSelected)&&(r.isSelected=e.isSelected),r.rect?(this.curNodeMap.set(t,r),this.updateSpatialEntry(t,r.rect)):this.delete(t)}selected(t){this.setInfo(t,{isSelected:!0})}unSelected(t){this.setInfo(t,{isSelected:!1})}delete(t){this.curNodeMap.delete(t);const e=this.spatialEntries.get(t);e&&(this.spatialIndex.remove(e),this.spatialEntries.delete(t))}clear(){this.curNodeMap.clear(),this.spatialIndex.clear(),this.spatialEntries.clear(),this.targetNodeMap.length=0}getRectIntersectRange(t,e=!0,r=!0){const n=this.spatialIndex.search(this.toSpatialBox(t)).map(c=>c.key);let s=n;if(this.verifySpatialIndex){const c=this.getLinearIntersectKeys(t),l=new Set(n);(c.length!==n.length||c.some(u=>!l.has(u)))&&(console.warn(`[VNodeManager] spatial index mismatch in ${this.viewId}; using linear result`),s=c)}let o;const a=new Map;for(const c of s){const l=this.curNodeMap.get(c);!l||!va(t,l.rect)||e&&l.toolsType===K.Image&&l.opt.locked||r&&l.toolsType===K.Text&&(l.opt.workState===ge.Doing||l.opt.workState===ge.Start)||(o=Ge(o,l.rect),a.set(c,l))}return{rectRange:o,nodeRange:a}}getNodeRectFormShape(t,e){const r=lc(e.toolsType);return this.fullLayer&&(r==null?void 0:r.getRectFromLayer(this.fullLayer,t))}updateNodeRect(t){const e=this.curNodeMap.get(t);if(e){const r=this.getNodeRectFormShape(t,e);if(!r){this.delete(t);return}e.rect=r,this.curNodeMap.set(t,e),this.updateSpatialEntry(t,r)}}updateHighLevelNodesRect(t){this.highLevelIds=t;for(const e of this.highLevelIds.keys())this.updateNodeRect(e)}updateLowLevelNodesRect(){var t;for(const e of this.curNodeMap.keys())(t=this.highLevelIds)!=null&&t.has(e)||this.updateNodeRect(e)}clearHighLevelIds(){this.highLevelIds=void 0}updateSpatialEntry(t,e){const r=this.spatialEntries.get(t);r&&this.spatialIndex.remove(r);const n={key:t,...this.toSpatialBox(e)};this.spatialEntries.set(t,n),this.spatialIndex.insert(n)}toSpatialBox(t){return{minX:t.x,minY:t.y,maxX:t.x+t.w,maxY:t.y+t.h}}getLinearIntersectKeys(t){const e=[];for(const[r,n]of this.curNodeMap.entries())va(t,n.rect)&&e.push(r);return e}setTargetAssignKeys(t){const e=new au;for(const r of t){const n=this.curNodeMap.get(r);n&&e.set(r,Lt(n))}return this.targetNodeMap.push(Lt(e)),this.targetNodeMap.length-1}setTarget(){const t=this.curNodeMap.keys();return this.setTargetAssignKeys(Array.from(t))}getLastTarget(){return this.targetNodeMap[this.targetNodeMap.length-1]}deleteLastTarget(){this.targetNodeMap.length&&(this.targetNodeMap.length=this.targetNodeMap.length-1)}getTarget(t){return this.targetNodeMap[t]}deleteTarget(t){this.targetNodeMap.length=t}clearTarget(){this.targetNodeMap.length=0}isLocalWorkId(t){return t.split(Rt).length===1}isCanClearWorkId(t){if(this.canClearUids===void 0||this.canClearUids===!0)return!0;if(Ude(this.canClearUids)){const e=t.split(Rt);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}}const M0=(i,t,e,r)=>{const n=new URL(i);return n.searchParams.set("width",t.toString()),n.searchParams.set("height",e.toString()),r&&n.searchParams.set("color",r),n.toString()},hme=async(i,t)=>{const{src:e,isgl:r,isCache:n,useImageBitmap:s=!0}=i;if(typeof Image=="function"){const o=new Image;return typeof e=="string"&&(o.crossOrigin="anonymous"),new Promise(a=>{o.onload=async function(){if(!s){a(o);return}if(typeof createImageBitmap!="function"){a(void 0);return}try{const c=r?await createImageBitmap(o,{imageOrientation:"flipY"}):await createImageBitmap(o);a(c)}catch{a(void 0)}},o.onerror=function(){a(void 0)},o.src=e})}else return fetch(e,{method:"GET",mode:"cors",cache:"default"}).then(o=>o.blob()).then(o=>(r?createImageBitmap(o,{imageOrientation:"flipY"}):createImageBitmap(o)).then(c=>c))};class w0{constructor(){R(this,"timer")}get pending(){return this.timer!==void 0}schedule(t,e){this.timer===void 0&&(this.timer=setTimeout(()=>{this.timer=void 0,t()},Math.max(0,e)))}cancel(){this.timer!==void 0&&(clearTimeout(this.timer),this.timer=void 0)}}const dme=30,fme=1e3/dme;function T0(i){return Math.min(Math.max(0,i),fme)}const gl=()=>typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now();class gme{constructor(t=1e3/30){R(this,"timer");R(this,"pending");R(this,"resolvePending");R(this,"activeWorkId");R(this,"generation",0);R(this,"lastReleaseTime",0);this.interval=t}wait(t){if(this.activeWorkId!==t&&(this.finish(),this.activeWorkId=t),this.pending)return this.pending;const e=this.generation,r=Math.max(0,this.lastReleaseTime+this.interval-gl());return r===0?(this.lastReleaseTime=gl(),Promise.resolve(!0)):(this.pending=new Promise(n=>{this.resolvePending=n,this.timer=setTimeout(()=>{if(this.timer=void 0,this.pending=void 0,this.resolvePending=void 0,e!==this.generation||this.activeWorkId!==t){n(!1);return}this.lastReleaseTime=gl(),n(!0)},r)}),this.pending)}finish(t){if(t!==void 0&&this.activeWorkId!==t)return;this.generation++,this.timer!==void 0&&clearTimeout(this.timer),this.timer=void 0,this.pending=void 0;const e=this.resolvePending;this.resolvePending=void 0,this.activeWorkId=void 0,this.lastReleaseTime=0,e==null||e(!1)}cancel(){this.finish()}}class pme{constructor(t,e,r){R(this,"viewId");R(this,"type");R(this,"scene");R(this,"fullLayer");R(this,"vNodes");R(this,"dpr");R(this,"contextType");R(this,"opt");R(this,"cameraOpt");R(this,"isSafari",!1);R(this,"combinePostMsg",new Set);R(this,"workerTaskId");R(this,"protectedTask");R(this,"delayPostDoneResolve");R(this,"cacheImages",new Map);R(this,"imageResolveMap",new Map);R(this,"taskUpdateCameraId");R(this,"taskUpdateCameraResolve");R(this,"debounceUpdateCameraId");var n,s;if(this.viewId=t,this.type=r,this.opt=e,this.dpr=e.dpr,this.contextType=this.getSupportContextType(r,(n=e==null?void 0:e.offscreenCanvasOpt)==null?void 0:n.contextType),!this.contextType)throw new Error("Sorry, your browser doesn't support canvas context type 2d or webgl");try{this.scene=this.createScene(e),this.createRenderLayer(this.scene,e)}catch(o){if(this.contextType!=="2d")this.contextType="2d",(s=this.scene)==null||s.disconnect(),this.scene=this.createScene(e),this.createRenderLayer(this.scene,e);else throw o}this.vNodes=new v0(t,this.scene)}createRenderLayer(t,e){const r=He.bufferSize.full,n=He.bufferSize.sub;this.fullLayer=this.createLayer("fullLayer",t,{...e.layerOpt,bufferSize:this.viewId===Ue?r:n*2})}async updateDpr(t){this.dpr=t,this.scene.displayRatio=t}getCachedImages(t){var e;return(e=this.cacheImages.get(t))==null?void 0:e.imageBitmap}getCachedImagesByWorkId(t){for(const[e,r]of this.cacheImages.entries())if(e===t&&r.imageBitmap)return r.imageBitmap}deleteCachedImagesByWorkId(t,e){for(const[r,n]of this.cacheImages.entries())e&&r===e||n.workId===t&&(n.imageBitmap.close(),this.cacheImages.delete(r))}clearCacheImages(){this.cacheImages.forEach(t=>t.imageBitmap.close()),this.cacheImages.clear()}clearImageResolveMap(){this.imageResolveMap.forEach(({timer:t})=>{t&&clearTimeout(t)}),this.imageResolveMap.clear()}setIsSafari(t){this.isSafari=t}async on(t){const{msgType:e,toolsType:r,opt:n,imageSrc:s,imageBitmap:o,workId:a,dpr:c}=t;switch(e){case he.UpdateDpr:{It(c)&&await this.updateDpr(c);break}case he.UpdateCamera:{await this.updateCamera(t);break}case he.Destroy:{this.destroy();break}case he.Clear:{await this.clearAll();break}case he.UpdateTools:{if(r&&n){const l={toolsType:r,toolsOpt:n,combineUnitTime:t.combineUnitTime,maxCombineEraserTime:t.maxCombineEraserTime};this.localWork.setToolsOpt(l)}break}case he.GetImageBitMap:{if(s&&o&&a){const l=a.toString();this.cacheImages.set(s,{imageBitmap:o,workId:l});const u=this.imageResolveMap.get(s);if(u){const{resolve:h,timer:d}=u;d&&clearTimeout(d),h&&h(s)}this.deleteCachedImagesByWorkId(l,s)}break}}}getIconSize(t,e,r){const n=t*r,s=e*r;return n<=50||s<=50?[50,50]:n<=100||s<=100?[100,100]:n<=200||s<=200?[200,200]:n<=400||s<=400?[400,400]:n<=800||s<=800?[800,800]:[1600,1600]}async loadImageBitMap(t){const{toolsType:e,opt:r,workId:n,isSubWorker:s}=t;if(e===K.Image&&r&&n){const o=n.toString(),{src:a,type:c,width:l,height:u,strokeColor:h}=r;if(!a||!c||!l||!u)return;let d=a;if(c===qr.Iconify){const[I,D]=this.getIconSize(l,u,this.dpr);d=M0(a,I,D,h)}if(this.cacheImages.has(d)){const I=this.getCachedImages(d);if(I)return I}if(this.imageResolveMap.has(d)){const I=this.getCachedImagesByWorkId(o);if(I)return I}const v=await new Promise(I=>{const D=this.imageResolveMap.get(d)||{resolve:void 0,timer:void 0};D.timer&&clearTimeout(D.timer),D.resolve=I,D.timer=setTimeout(()=>{const x=this.imageResolveMap.get(d);x!=null&&x.resolve&&x.resolve(d)},5e3),this.imageResolveMap.set(d,D),this._post({sp:[{imageSrc:d,workId:o,viewId:this.viewId,isgl:!!this.fullLayer.parent.gl,isSubWorker:s,type:he.GetImageBitMap}]})});return this.imageResolveMap.delete(v),this.getCachedImages(d)}}createLocalWork(t){const{workId:e,opt:r,toolsType:n}=t;e&&r&&(!this.localWork.getToolsOpt()&&n&&this.setToolsOpt({toolsType:n,toolsOpt:r}),this.setWorkOpt({workId:e,toolsOpt:r}))}updateScene(t,e,r){t.attr({...e});const{width:n,height:s}=e;t.container.width=n,t.container.height=s,t.width=n,t.height=s,this.updateLayer({width:n,height:s},r)}updateLayer(t,e){const{width:r,height:n}=t,s=e||this.fullLayer;s&&(s.parent.setAttribute("width",r),s.parent.setAttribute("height",n),s.setAttribute("size",[r,n]),s.setAttribute("pos",[r*.5,n*.5]))}getSupportContextType(t,e){const r=new OffscreenCanvas(100,100);let n=["2d"];t===cu.Full&&this.viewId===Ue&&(n=["webgl2","webgl","2d"],e&&n.unshift(e));for(const s of n)try{if(r.getContext(s))return s}catch(o){throw o}}createScene(t){const{offscreenCanvasOpt:e}=t,{width:r,height:n}=e,s=new OffscreenCanvas(r,n);e.contextType&&delete e.contextType;const o=new qa({container:s,displayRatio:this.dpr,depth:!1,desynchronized:!0,failIfMajorPerformanceCaveat:!0,...e,contextType:this.contextType,id:this.viewId});return o.setAttribute("id",this.viewId),o}createLayer(t,e,r,n){const s=`offscreen-${t}`,{width:o,height:a}=r;n&&(r.offscreen=!0,r.canvas=n);const c=e.layer(s,r),l=new dt({anchor:[.5,.5],pos:[o*.5,a*.5],size:[o,a],name:"viewport",id:t});return c.append(l),l}async clearAll(){var t,e;this.fullLayer&&(this.fullLayer.parent.children.forEach(r=>{r.name!=="viewport"&&r.remove()}),ar(this.fullLayer,this.fullLayer.parent)),this.taskUpdateCameraId&&(clearTimeout(this.taskUpdateCameraId),this.taskUpdateCameraId=void 0,(t=this.taskUpdateCameraResolve)==null||t.call(this,!1),this.taskUpdateCameraResolve=void 0),this.debounceUpdateCameraId&&(clearTimeout(this.debounceUpdateCameraId),this.debounceUpdateCameraId=void 0),this.clearCacheImages(),this.clearImageResolveMap(),this.localWork.destroy(),(e=this.serviceWork)==null||e.destroy()}setToolsOpt(t){this.localWork.setToolsOpt(t)}setWorkOpt(t){const{workId:e,toolsOpt:r}=t;e&&r&&this.localWork.setWorkOptions(e.toString(),r)}destroy(){var t;this.vNodes.clear(),this.fullLayer.remove(),cr(this.fullLayer,this.fullLayer.parent),this.clearCacheImages(),this.clearImageResolveMap(),this.scene.remove(),this.localWork.destroy(),(t=this.serviceWork)==null||t.destroy()}async post(t){this.combinePostMsg.add(t),await this.runBatchPostData()}async runBatchPostData(){this.workerTaskId||(this.workerTaskId=setTimeout(()=>{this.workerTaskId=void 0,this.combinePost()},16)),this.type===cu.Full&&!this.delayPostDoneResolve&&await new Promise(e=>{this.delayPostDoneResolve=e})&&(this.delayPostDoneResolve=void 0)}combinePostData(){var c,l;this.workerTaskId=void 0;const t=[],e=[];let r,n,s,o;const a=new Set;for(const u of this.combinePostMsg.values()){if((c=u.render)!=null&&c.length)for(const h of u.render){let d=!1;if(h.workId&&a.add(h.workId),h.isClearAll&&(h.rect=this.getSceneRect(),h.isClear=!0,delete h.isClearAll),h.drawCanvas){const g=this.getLayer(h.drawCanvas);if(!g||!(g.parent instanceof xi))continue;if(g.parent.render(),h.isDrawAll){const p=this.getSceneRect();h.rect=p,delete h.isDrawAll}}for(const g of t)if(h.viewId===g.viewId){h.isClear&&g.clearCanvas&&g.isClear&&g.clearCanvas===h.clearCanvas&&(g.rect=Ge(g.rect,h.rect),d=!0),g.drawCanvas&&g.drawCanvas===h.drawCanvas&&(g.rect=Ge(g.rect,h.rect),d=!0);continue}d||(h.isClear&&!h.drawCanvas?t.unshift(h):t.push(h))}if((l=u.sp)!=null&&l.length)for(const h of u.sp){let d=!1;for(const g of e)if(Zr(h,g)){d=!0;break}d||e.push(h)}It(u.fullWorkerDrawCount)&&(r=u.fullWorkerDrawCount),It(u.subWorkerDrawCount)&&(n=u.subWorkerDrawCount),It(u.consumeCount)&&(s=u.consumeCount,o=u.consumeWorkId)}return this.combinePostMsg.clear(),{render:t,sp:e,fullWorkerDrawCount:r,subWorkerDrawCount:n,consumeCount:s,consumeWorkId:o,workIds:a,viewId:this.viewId}}getSceneRect(){const{width:t,height:e}=this.scene;return{x:0,y:0,w:Math.floor(t),h:Math.floor(e)}}}class S0{constructor(t){R(this,"viewId");R(this,"vNodes");R(this,"thread");R(this,"fullLayer");R(this,"drawLayer");R(this,"_post");R(this,"tmpOpt");R(this,"workShapes",new Map);R(this,"drawCount",0);R(this,"consumeCount",0);R(this,"syncUnitTime",He.syncOpt.interval);R(this,"combineUnitTime",He.bezier.combineUnitTime);R(this,"maxCombineEraserTime",He.pencilEraser.maxCombineTime);R(this,"eraserBatchScheduler",new w0);R(this,"drawAckBackpressure",new gme);this.thread=t.thread,this.viewId=t.viewId,this.vNodes=t.vNodes,this.fullLayer=t.fullLayer,this.drawLayer=t.drawLayer,this._post=this.thread.post.bind(t.thread)}get eraserBatchDelay(){return T0(this.maxCombineEraserTime)}setmaxCombineEraserTime(t){this.maxCombineEraserTime=t}setCombineUnitTime(t){this.combineUnitTime=t}setSyncUnitTime(t){this.syncUnitTime=t}destroy(){this.eraserBatchScheduler.cancel(),this.drawAckBackpressure.cancel(),this.workShapes.clear()}getWorkShapes(){return this.workShapes}getWorkShape(t){return this.workShapes.get(t)}createWorkShape(t,e){if(t&&this.tmpOpt){const r={toolsType:this.tmpOpt.toolsType,toolsOpt:e||this.tmpOpt.toolsOpt},n=this.createWorkShapeNode({...r,workId:t});n&&this.workShapes.set(t,n)}}setWorkOptions(t,e){const r=this.getWorkShape(t);r||this.createWorkShape(t,e),r==null||r.setWorkOptions(e)}createWorkShapeNode(t){var e;return Oh({...t,vNodes:this.vNodes,fullLayer:this.fullLayer,drawLayer:this.drawLayer},(e=this.thread)==null?void 0:e.serviceWork)}setToolsOpt(t){var e,r,n;((e=this.tmpOpt)==null?void 0:e.toolsType)!==t.toolsType&&(r=this.tmpOpt)!=null&&r.toolsType&&this.clearAllWorkShapesCache(),this.tmpOpt=t,(n=t.toolsOpt)!=null&&n.syncUnitTime&&(this.syncUnitTime=t.toolsOpt.syncUnitTime),t.combineUnitTime&&(this.combineUnitTime=t.combineUnitTime),t.maxCombineEraserTime&&(this.maxCombineEraserTime=t.maxCombineEraserTime)}getToolsOpt(){return this.tmpOpt}clearWorkShapeNodeCache(t){var e;(e=this.getWorkShape(t))==null||e.clearTmpPoints(),this.workShapes.delete(t)}clearAllWorkShapesCache(){this.eraserBatchScheduler.cancel(),this.drawAckBackpressure.cancel(),this.workShapes.forEach(t=>t.clearTmpPoints()),this.workShapes.clear()}setFullWork(t){const{workId:e,opt:r,toolsType:n}=t;if(e&&r&&n){const s=e.toString();let o;return e&&this.workShapes.has(s)?(o=this.workShapes.get(s),(o==null?void 0:o.toolsType)!==n?(o==null||o.clearTmpPoints(),this.workShapes.delete(s),o=void 0):o==null||o.setWorkOptions(r)):o=this.createWorkShapeNode({toolsOpt:r,toolsType:n,workId:s}),o||(o=this.createWorkShapeNode({toolsOpt:r,toolsType:n,workId:s})),o?(this.workShapes.set(s,o),o):void 0}}}function mme(i){return i}var I0=mme;function yme(i,t,e){switch(e.length){case 0:return i.call(t);case 1:return i.call(t,e[0]);case 2:return i.call(t,e[0],e[1]);case 3:return i.call(t,e[0],e[1],e[2])}return i.apply(t,e)}var vme=yme,Mme=vme,Bg=Math.max;function wme(i,t,e){return t=Bg(t===void 0?i.length-1:t,0),function(){for(var r=arguments,n=-1,s=Bg(r.length-t,0),o=Array(s);++n<s;)o[n]=r[t+n];n=-1;for(var a=Array(t+1);++n<t;)a[n]=r[n];return a[t]=e(o),Mme(i,this,a)}}var Tme=wme;function Sme(i){return function(){return i}}var Ime=Sme,Cme=Ime,Ug=Cy,bme=I0,xme=Ug?function(i,t){return Ug(i,"toString",{configurable:!0,enumerable:!1,value:Cme(t),writable:!0})}:bme,Eme=xme,Ame=800,Nme=16,Dme=Date.now;function Pme(i){var t=0,e=0;return function(){var r=Dme(),n=Nme-(r-e);if(e=r,n>0){if(++t>=Ame)return arguments[0]}else t=0;return i.apply(void 0,arguments)}}var kme=Pme,Lme=Eme,Rme=kme,Ome=Rme(Lme),zme=Ome,jme=I0,Bme=Tme,Ume=zme;function Fme(i,t){return Ume(Bme(i,t,jme),i+"")}var Wme=Fme;function $me(i,t,e,r){for(var n=i.length,s=e+(r?1:-1);r?s--:++s<n;)if(t(i[s],s,i))return s;return-1}var Vme=$me;function Yme(i){return i!==i}var Gme=Yme;function Hme(i,t,e){for(var r=e-1,n=i.length;++r<n;)if(i[r]===t)return r;return-1}var Qme=Hme,Zme=Vme,Kme=Gme,qme=Qme;function Xme(i,t,e){return t===t?qme(i,t,e):Zme(i,Kme,e)}var Jme=Xme,_me=Jme;function eye(i,t){var e=i==null?0:i.length;return!!e&&_me(i,t,0)>-1}var C0=eye;function tye(i,t,e){for(var r=-1,n=i==null?0:i.length;++r<n;)if(e(t,i[r]))return!0;return!1}var b0=tye;function rye(i,t){for(var e=-1,r=i==null?0:i.length,n=Array(r);++e<r;)n[e]=t(i[e],e,i);return n}var nye=rye,iye=kh,sye=C0,oye=b0,aye=nye,cye=ic,lye=Lh,uye=200;function hye(i,t,e,r){var n=-1,s=sye,o=!0,a=i.length,c=[],l=t.length;if(!a)return c;e&&(t=aye(t,cye(e))),r?(s=oye,o=!1):t.length>=uye&&(s=lye,o=!1,t=new iye(t));e:for(;++n<a;){var u=i[n],h=e==null?u:e(u);if(u=r||u!==0?u:0,o&&h===h){for(var d=l;d--;)if(t[d]===h)continue e;c.push(u)}else s(t,h,r)||c.push(u)}return c}var dye=hye,Fg=qs,fye=Ay,gye=Xs,Wg=Fg?Fg.isConcatSpreadable:void 0;function pye(i){return gye(i)||fye(i)||!!(Wg&&i&&i[Wg])}var mye=pye,yye=bh,vye=mye;function x0(i,t,e,r,n){var s=-1,o=i.length;for(e||(e=vye),n||(n=[]);++s<o;){var a=i[s];t>0&&e(a)?t>1?x0(a,t-1,e,r,n):yye(n,a):r||(n[n.length]=a)}return n}var Mye=x0;function wye(){}var Tye=wye,pl=Uy,Sye=Tye,Iye=Rh,Cye=1/0,bye=pl&&1/Iye(new pl([,-0]))[1]==Cye?function(i){return new pl(i)}:Sye,xye=bye,Eye=kh,Aye=C0,Nye=b0,Dye=Lh,Pye=xye,kye=Rh,Lye=200;function Rye(i,t,e){var r=-1,n=Aye,s=i.length,o=!0,a=[],c=a;if(e)o=!1,n=Nye;else if(s>=Lye){var l=t?null:Pye(i);if(l)return kye(l);o=!1,n=Dye,c=new Eye}else c=t?[]:a;e:for(;++r<s;){var u=i[r],h=t?t(u):u;if(u=e||u!==0?u:0,o&&h===h){for(var d=c.length;d--;)if(c[d]===h)continue e;t&&c.push(h),a.push(u)}else n(c,h,e)||(c!==a&&c.push(h),a.push(u))}return a}var Oye=Rye,zye=dye,jye=Mye,$g=Oye;function Bye(i,t,e){var r=i.length;if(r<2)return r?$g(i[0]):[];for(var n=-1,s=Array(r);++n<r;)for(var o=i[n],a=-1;++a<r;)a!=n&&(s[n]=zye(s[n]||o,i[a],t,e));return $g(jye(s,1),t,e)}var Uye=Bye,Fye=Th,Wye=Nr;function $ye(i){return Wye(i)&&Fye(i)}var Vye=$ye,Yye=Ly,Gye=Wme,Hye=Uye,Qye=Vye;Gye(function(i){return Hye(Yye(i,Qye))});class Zye extends S0{constructor(e){super(e);R(this,"drawWorkActiveId")}runSelectWork(e){var n;const r=this.setFullWork(e);r&&((n=e.selectIds)!=null&&n.length)&&e.workId&&r.selectServiceNode(e.workId.toString(),{selectIds:e.selectIds},!1)}workShapesDone(){for(const e of this.workShapes.keys())this.clearWorkShapeNodeCache(e);ar(this.fullLayer,this.fullLayer.parent)}async consumeDraw(e){const{workId:r,fullWorkerDrawCount:n,postCount:s}=e,o=r==null?void 0:r.toString(),a=o&&this.workShapes.get(o);if(!a){o&&It(s)&&await this.drawAckBackpressure.wait(o)&&await this._post({consumeCount:s,consumeWorkId:o});return}this.drawWorkActiveId&&this.drawWorkActiveId!==o&&(await this.consumeDrawAll({workId:this.drawWorkActiveId,viewId:this.viewId,msgType:he.DrawWork,dataType:Ee.Local}),this.drawWorkActiveId=void 0),!this.drawWorkActiveId&&o!==De&&(this.drawWorkActiveId=o);const c=a.toolsType;It(s)&&(this.consumeCount=s);const l=a.consume({data:e,drawCount:this.drawCount,isFullWork:!0,isSubWorker:!0,removeDrawCount:n});switch(c){case K.Selector:l&&(this.drawCount++,await this.drawSelector(l));break;case K.Ellipse:case K.Arrow:case K.Straight:case K.Rectangle:case K.Star:case K.Polygon:case K.SpeechBalloon:{l&&(this.drawCount++,await this.drawShape(l));break}case K.Pencil:{l&&(this.drawCount++,await this.drawPencil(l,r==null?void 0:r.toString()));break}case K.BitMapEraser:case K.PencilEraser:{l&&(this.drawCount++,await this.drawAckBackpressure.wait(o)&&await this._post({subWorkerDrawCount:this.drawCount,consumeCount:this.consumeCount,consumeWorkId:o}));break}}}async consumeDrawAll(e){const{workId:r}=e;if(r){const n=r.toString();this.drawAckBackpressure.finish(n),this.drawWorkActiveId===n&&(this.drawWorkActiveId=void 0);const s=this.workShapes.get(n);if(!s)return;switch(s.toolsType){case K.Selector:this.drawCount=0,ar(this.fullLayer,this.fullLayer.parent),this.clearWorkShapeNodeCache(n),this._post({render:[{isClearAll:!0,clearCanvas:_e.Float,viewId:this.viewId}]});break;case K.Arrow:case K.Straight:case K.Ellipse:case K.Pencil:case K.Rectangle:case K.Star:case K.Polygon:case K.SpeechBalloon:case K.BitMapEraser:case K.PencilEraser:this.drawCount=0,ar(this.fullLayer,this.fullLayer.parent),this.clearWorkShapeNodeCache(n);break}}}async removeWork(e){const{workId:r}=e,n=r==null?void 0:r.toString();if(n){const s=this.removeNode(n);if(s){const o=[];o.push({rect:fn(s),clearCanvas:_e.Float,isClear:!0,viewId:this.viewId},{rect:fn(s),drawCanvas:_e.Float,viewId:this.viewId}),await this._post({render:o})}}}removeNode(e){const r=this.workShapes.has(e);let n;return r&&(this.fullLayer.getElementsByName(e).forEach(s=>{const o=s.getBoundingClientRect();n=Ge(n,{x:o.x-xe.SafeBorderPadding,y:o.y-xe.SafeBorderPadding,w:o.width+xe.SafeBorderPadding*2,h:o.height+xe.SafeBorderPadding*2}),s.remove(),cr(s,this.fullLayer.parent)}),n&&this.clearWorkShapeNodeCache(e)),n}async drawPencil(e,r){!r||!await this.drawAckBackpressure.wait(r)||await this._post({subWorkerDrawCount:this.drawCount,consumeCount:this.consumeCount,consumeWorkId:r,render:[{rect:e==null?void 0:e.rect,workId:r,drawCanvas:_e.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)&&fn(e.rect),isClear:!0,clearCanvas:_e.Float,viewId:this.viewId},{rect:(e==null?void 0:e.rect)&&fn(e.rect),drawCanvas:_e.Float,viewId:this.viewId}]})}async drawSelector(e){await this._post({subWorkerDrawCount:this.drawCount,consumeCount:this.consumeCount,render:[{rect:(e==null?void 0:e.rect)&&fn(e.rect),isClear:!0,clearCanvas:_e.Float,viewId:this.viewId},{rect:(e==null?void 0:e.rect)&&fn(e.rect),drawCanvas:_e.Float,viewId:this.viewId}]})}}class Kye{constructor(t){R(this,"viewId");R(this,"vNodes");R(this,"topLayer");R(this,"thread");R(this,"post");R(this,"serviceWorkShapes",new Map);R(this,"localWorkShapes",new Map);R(this,"tmpOpt");R(this,"syncUnitTime",He.syncOpt.interval);R(this,"animationId");this.viewId=t.viewId,this.vNodes=t.vNodes,this.topLayer=t.topLayer,this.thread=t.thread,this.post=t.thread.post.bind(t.thread)}canUseTopLayer(t){return t===K.LaserPen}getWorkShape(t){return this.localWorkShapes.get(t)}createWorkShape(t,e){if(t&&this.tmpOpt){const r={toolsType:this.tmpOpt.toolsType,toolsOpt:e||this.tmpOpt.toolsOpt},n=this.createWorkShapeNode({...r,workId:t});return n&&this.localWorkShapes.set(t,{node:n,toolsType:n.toolsType,workState:ge.Start}),n}}setWorkOptions(t,e){var n;const r=(n=this.localWorkShapes.get(t))==null?void 0:n.node;r||this.createWorkShape(t,e),r==null||r.setWorkOptions(e)}createWorkShapeNode(t){const{toolsType:e}=t;if(e===K.LaserPen)return Oh({...t,vNodes:this.vNodes,fullLayer:this.topLayer,drawLayer:this.topLayer})}clearAllWorkShapesCache(){this.localWorkShapes.forEach(t=>{var e;return(e=t.node)==null?void 0:e.clearTmpPoints()}),this.localWorkShapes.clear()}setToolsOpt(t){var e;this.tmpOpt=t,(e=t.toolsOpt)!=null&&e.syncUnitTime&&(this.syncUnitTime=t.toolsOpt.syncUnitTime)}getToolsOpt(){return this.tmpOpt}consumeDraw(t){const{workId:e,dataType:r}=t;if(r===Ee.Service)this.activeServiceWorkShape(t);else{const n=e==null?void 0:e.toString(),s=n&&this.localWorkShapes.get(n);if(!s)return;const o=s.node.consume({data:t,isFullWork:!1,isSubWorker:!0});o.rect&&(s.totalRect=Ge(o.rect,s.totalRect),s.result=o,s.workState=ge.Doing,n&&this.localWorkShapes.set(n,s))}this.runAnimation()}consumeDrawAll(t){const{workId:e,dataType:r}=t;if(r===Ee.Service)this.activeServiceWorkShape(t);else{const n=e==null?void 0:e.toString(),s=n&&this.localWorkShapes.get(n);if(!s)return;const o=s.node.consumeAll({data:t});s.totalRect=Ge(o.rect,s.totalRect),s.result=o,s.workState=ge.Done,n&&this.localWorkShapes.set(n,s)}this.runAnimation()}destroy(){this.serviceWorkShapes.clear(),this.localWorkShapes.clear()}setNodeKey(t,e,r,n){return e.toolsType=r,e.node=this.createWorkShapeNode({workId:t,toolsType:r,toolsOpt:n}),e}activeServiceWorkShape(t){var d,g;const{workId:e,opt:r,toolsType:n,type:s,updateNodeOpt:o,ops:a,op:c}=t;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:n,animationWorkData:c||[],animationIndex:0,type:s,updateNodeOpt:o,ops:a,oldRect:u};n&&r&&(p=this.setNodeKey(l,p,n,r)),this.serviceWorkShapes.set(l,p)}const h=this.serviceWorkShapes.get(l);s&&(h.type=s),a&&(h.animationWorkData=Nn(a),h.ops=a),o&&(h.updateNodeOpt=o),c&&(h.animationWorkData=c),h.node&&h.node.getWorkId()!==l&&h.node.setWorkId(l),u&&(h.oldRect=u),n&&r?(h.toolsType!==n&&n&&r&&this.setNodeKey(l,h,n,r),h.node&&h.node.setWorkOptions(r)):n&&(h.toolsType=n)}computNextAnimationIndex(t,e){const r=Math.floor((t.animationWorkData||[]).slice(t.animationIndex).length*32/e/this.syncUnitTime)*e;return Math.min((t.animationIndex||0)+(r||e),(t.animationWorkData||[]).length)}async animationDraw(){var o,a,c,l;this.animationId=void 0;let t=!1;const e=new Map,r=[],n=[],s=[];for(const[u,h]of this.serviceWorkShapes.entries())switch(h.toolsType){case K.LaserPen:{const g=this.computNextAnimationIndex(h,8),p=Math.max(0,h.animationIndex||0),v=(h.animationWorkData||[]).slice(p,g);if((h.animationIndex||0)<g){const I=(o=h.node)==null?void 0:o.consumeService({op:v,isFullWork:!1});h.totalRect=Ge(h.totalRect,I),h.animationIndex=g,v.length&&e.set(u,{cursorTool:Wpe(h.toolsType),workState:p===0?ge.Start:g===((a=h.animationWorkData)==null?void 0:a.length)?ge.Done:ge.Doing,op:v.slice(-2)})}if(n.push({isClear:!0,rect:h.totalRect,clearCanvas:_e.TopFloat,viewId:this.viewId}),r.push({rect:h.totalRect,drawCanvas:_e.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))),t=!0;break}}for(const[u,h]of this.localWorkShapes.entries()){const{result:d,toolsType:g,totalRect:p,isDel:v,workState:I}=h;switch(g){case K.LaserPen:{if(p&&(n.push({isClear:!0,rect:p,clearCanvas:_e.TopFloat,viewId:this.viewId}),r.push({rect:p,drawCanvas:_e.TopFloat,viewId:this.viewId})),v){h.node.clearTmpPoints(),this.localWorkShapes.delete(u),s.push({removeIds:[u.toString()],viewId:this.viewId,type:he.RemoveNode});break}d&&((d.op||d.ops)&&s.push(d),h.result=void 0),!this.topLayer.getElementsByName(u.toString())[0]&&I===ge.Done&&(h.isDel=!0,this.localWorkShapes.set(u,h)),t=!0;break}}}t&&this.runAnimation(),e.size&&e.forEach((u,h)=>{s.push({type:he.Cursor,uid:h.split(Rt)[0],op:u.op,workState:u.workState,cursorTool:u.cursorTool,viewId:this.viewId})}),(r.length||n.length||s.length)&&this.post({render:[...n,...r],sp:s})}runAnimation(){this.animationId||(this.animationId=setTimeout(()=>{this.animationId=void 0,this.animationDraw()},16))}}class qye extends S0{constructor(e){super(e);R(this,"opt");R(this,"scene");R(this,"cameraOpt");R(this,"vNodes");this.opt=e,this.vNodes=void 0}createSnapshotFullLayer(e,r){this.scene=this.opt.createScene(e),this.fullLayer=this.opt.createLayer("snapshotFullLayer",this.scene,r)}destroySnapshotFullLayer(){var e,r,n;ar(this.fullLayer,this.fullLayer.parent),(e=this.fullLayer)==null||e.disconnect(),(r=this.fullLayer)==null||r.remove(),(n=this.scene)==null||n.remove(),this.scene=void 0}updateScene(e){if(!this.scene)throw new Error("SnapshotWork scene is not initialized");this.scene.attr({...e});const{width:r,height:n}=e;this.scene.width=r,this.scene.height=n,this.updateLayer({width:r,height:n})}updateLayer(e){if(!this.fullLayer)throw new Error("SnapshotWork snapshotFullLayer is not initialized");const{width:r,height:n}=e;this.fullLayer.parent.setAttribute("width",r),this.fullLayer.parent.setAttribute("height",n),this.fullLayer.setAttribute("size",[r,n]),this.fullLayer.setAttribute("pos",[r*.5,n*.5])}setCameraOpt(e){this.cameraOpt=e;const{scale:r,centerX:n,centerY:s,width:o,height:a}=e;if(!this.scene)throw new Error("SnapshotWork scene is not initialized");if(!this.fullLayer)throw new Error("SnapshotWork snapshotFullLayer is not initialized");(o!==this.scene.width||a!==this.scene.height)&&this.updateScene({width:o,height:a}),this.fullLayer.setAttribute("scale",[r,r]),this.fullLayer.setAttribute("translate",[-n,-s])}getOffscreen(){var r;return((r=this.fullLayer)==null?void 0:r.parent).canvas}getRectImageBitmap(e,r){const{rect:n}=e,s=this.thread.dpr,o=Math.floor(n.x*s),a=Math.floor(n.y*s),c=Math.floor(n.w*s),l=Math.floor(n.h*s);return createImageBitmap(this.getOffscreen(),o,a,c,l,r)}async getSnapshot(e){const{scenePath:r,scenes:n,cameraOpt:s,w:o,h:a}=e;if(r&&n&&s&&this.fullLayer){this.setCameraOpt(s);for(const[l,u]of Object.entries(n))if(u!=null&&u.type)switch(u==null?void 0:u.type){case he.UpdateNode:case he.FullWork:{const{opt:h}=u,d={...u,opt:h,workId:l,msgType:he.FullWork,dataType:Ee.Service,viewId:this.viewId};await this.runFullWork(d);break}}let c;o&&a&&(c={resizeWidth:o,resizeHeight:a});try{await this.getSnapshotRender({scenePath:r,options:c})}catch(l){const u=l&&l instanceof Error?l.message:l==null?void 0:l.toString();console.error("[SnapshotWork] getSnapshotRender error",u),this.thread._post({sp:[{type:he.ReportError,reportString:`[SnapshotWork] getSnapshotRender error: ${u}`}]})}}}async runFullWork(e){var s;const r=this.setFullWork(e),n=e.ops&&Nn(e.ops);if(r){let o,a;const c=(s=r.getWorkId())==null?void 0:s.toString();return r.toolsType===K.BackgroundSVG?o=r.consumeService({isFullWork:!0,replaceId:c}):r.toolsType===K.Image?o=await r.consumeServiceAsync({isFullWork:!0,worker:this.thread}):r.toolsType===K.Text?o=await r.consumeServiceAsync({isFullWork:!0,replaceId:c,isDrawLabel:!0}):(o=r.consumeService({op:n,isFullWork:!0,replaceId:c}),a=(e==null?void 0:e.updateNodeOpt)&&r.updataOptService(e.updateNodeOpt)),e.workId&&this.workShapes.delete(e.workId.toString()),Ge(o,a)}}getSceneRect(){if(!this.scene)throw new Error("SnapshotWork scene is not initialized");const{width:e,height:r}=this.scene;return{x:0,y:0,w:Math.floor(e),h:Math.floor(r)}}async getSnapshotRender(e){var o;const{scenePath:r,options:n}=e;((o=this.fullLayer)==null?void 0:o.parent).render();const s=await this.getRectImageBitmap({rect:this.getSceneRect(),drawCanvas:_e.None},n);s&&(this.thread._post({sp:[{type:he.Snapshot,scenePath:r,imageBitmap:s,viewId:this.viewId,index:0}]},[s]),s.close())}async getBoundingRect(e){const{scenePath:r,scenes:n,cameraOpt:s}=e;if(r&&n&&s&&this.fullLayer){this.setCameraOpt(s);let o;for(const[a,c]of Object.entries(n))if(c!=null&&c.type)switch(c==null?void 0:c.type){case he.UpdateNode:case he.FullWork:{const l=await this.runFullWork({...c,workId:a,msgType:he.FullWork,dataType:Ee.Service,viewId:this.viewId});o=Ge(o,l);break}}o&&this.thread._post({sp:[{type:he.BoundingBox,scenePath:r,rect:o,viewId:this.viewId}]})}}}var cu=(i=>(i.Full="full",i.Sub="sub",i))(cu||{});class Xye extends pme{constructor(e,r,n){super(e,r,"sub");R(this,"type","sub");R(this,"_post");R(this,"topLayer");R(this,"serviceWork");R(this,"localWork");R(this,"topLayerWork");R(this,"snapshotWork");this._post=n;const s=He.bufferSize.sub;this.topLayer=r.isUseSimple?void 0:this.createLayer("topLayer",this.scene,{...r.layerOpt,bufferSize:s,contextType:"2d"});const o={thread:this,viewId:this.viewId,vNodes:this.vNodes,fullLayer:this.fullLayer,topLayer:this.topLayer,isUseSimple:r.isUseSimple};this.localWork=new Zye(o),r.isUseSimple||(this.topLayerWork=new Kye(o)),this.snapshotWork=new qye({...o,createScene:this.createScene.bind(this),createLayer:this.createLayer.bind(this)}),this.vNodes.init(this.fullLayer)}async combinePost(){var o,a;const{render:e,...r}=this.combinePostData();let n;if(e!=null&&e.length){const c=[];for(const l of e)if(l.rect){if(l.rect=o0e(Lt(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,n||(n=[]),n.push(u)}c.push(l)}r.render=c}const s=(o=r.sp)==null?void 0:o.filter(c=>c.type!==he.None||c.isLockSentEventCursor||c.needUndoTicker||c.collectUndoTicker);s!=null&&s.length?r.sp=s.map(c=>({...c,viewId:this.viewId})):delete r.sp,r.consumeCount===void 0&&delete r.consumeCount,r.subWorkerDrawCount===void 0&&delete r.subWorkerDrawCount,(s!=null&&s.length||r.consumeCount||r.subWorkerDrawCount||(a=r==null?void 0:r.render)!=null&&a.length)&&this._post(r,n),this.delayPostDoneResolve&&this.delayPostDoneResolve(!0)}async on(e){var l,u;const{msgType:r,toolsType:n,opt:s,dataType:o,workState:a,isLockSentEventCursor:c}=e;switch(r){case he.UpdateTools:{if(n&&((l=this.topLayerWork)!=null&&l.canUseTopLayer(n))&&s){const h={toolsType:n,toolsOpt:s};this.topLayerWork.setToolsOpt(h);return}break}case he.CreateWork:{this.createLocalWork(e);return}case he.DrawWork:{a===ge.Done&&o===Ee.Local?(await this.consumeDrawAll(o,e),n===K.LaserPen&&c&&this.post({sp:[{type:he.None,isLockSentEventCursor:c}]})):this.consumeDraw(o,e);return}case he.RemoveNode:{await this.removeNode(e);return}case he.FullWork:{n&&((u=this.topLayerWork)!=null&&u.canUseTopLayer(n))?await this.consumeDrawAll(o,e):o===Ee.Local&&e.clearPreviewLocalWork&&e.workId&&await this.localWork.consumeDrawAll({...e,msgType:he.DrawWork,workState:ge.Done});return}case he.Snapshot:{this.snapshotWork.createSnapshotFullLayer(this.opt,{...this.opt.layerOpt,bufferSize:this.viewId===Ue?6e3:3e3,contextType:"2d"}),await this.snapshotWork.getSnapshot(e),this.snapshotWork.destroySnapshotFullLayer();return}case he.BoundingBox:{this.snapshotWork.createSnapshotFullLayer(this.opt,{...this.opt.layerOpt,bufferSize:this.viewId===Ue?6e3:3e3,contextType:"2d"}),await this.snapshotWork.getBoundingRect(e),this.snapshotWork.destroySnapshotFullLayer();return}}await super.on(e)}createLocalWork(e){var o;const{workId:r,toolsType:n,opt:s}=e;if(n&&((o=this.topLayerWork)!=null&&o.canUseTopLayer(n))&&r&&s){this.topLayerWork.getToolsOpt()||this.topLayerWork.setToolsOpt({toolsType:n,toolsOpt:s}),this.topLayerWork.setWorkOptions(r.toString(),s);return}n&&super.createLocalWork(e)}async removeNode(e){const{dataType:r}=e;r===Ee.Local&&await this.localWork.removeWork(e)}getLayer(e){switch(e){case _e.TopFloat:return this.topLayer||this.fullLayer;default:return this.fullLayer}}getOffscreen(e){var n;return((n=this.getLayer(e))==null?void 0:n.parent).canvas}async consumeDraw(e,r){var o;const{workId:n,toolsType:s}=r;if(n){if(s&&((o=this.topLayerWork)!=null&&o.canUseTopLayer(s))){e===Ee.Local&&(this.topLayerWork.getWorkShape(n.toString())||this.createLocalWork(r)),this.topLayerWork.consumeDraw(r);return}s&&(this.localWork.getWorkShape(n.toString())||this.createLocalWork(r),await this.localWork.consumeDraw(r));return}}async consumeDrawAll(e,r){var a;const{workId:n,toolsType:s,dataType:o}=r;if(n){const c=n.toString();if(s&&((a=this.topLayerWork)!=null&&a.canUseTopLayer(s))){o===Ee.Local&&(this.topLayerWork.getWorkShape(c)||this.createLocalWork(r)),this.topLayerWork.consumeDrawAll(r);return}s&&(this.localWork.getWorkShape(c)||super.createLocalWork(r),this.localWork.consumeDrawAll(r));return}}async clearAll(){this.vNodes.clear(),super.clearAll(),this.topLayer&&(this.topLayer.parent.children.forEach(e=>{e.name!=="viewport"&&e.remove()}),ar(this.topLayer,this.topLayer.parent)),await this.post({render:[{isClearAll:!0,clearCanvas:_e.TopFloat,viewId:this.viewId}],sp:[{type:he.Clear}]})}async getRectImageBitmap(e,r){var u;const{rect:n,drawCanvas:s}=e;if(((u=this.opt.bitmapEraserMaskOptions)==null?void 0:u.imageBitmapDirtyRect)===!1){const h=this.getOffscreen(s);return n.x=0,n.y=0,n.w=h.width/this.dpr,n.h=h.height/this.dpr,createImageBitmap(h,0,0,h.width,h.height,r)}const o=Math.floor(n.x*this.dpr),a=Math.floor(n.y*this.dpr),c=Math.floor(n.w*this.dpr||1),l=Math.floor(n.h*this.dpr||1);try{return await createImageBitmap(this.getOffscreen(s),o,a,c,l,r)}catch{this.opt.bitmapEraserMaskOptions&&(this.opt.bitmapEraserMaskOptions.imageBitmapDirtyRect=!1);const h=this.getOffscreen(s);return n.x=0,n.y=0,n.w=h.width/this.dpr,n.h=h.height/this.dpr,createImageBitmap(h,0,0,h.width,h.height,r)}}updateLayer(e){const{width:r,height:n}=e;super.updateLayer(e),this.topLayer&&(this.topLayer.parent.setAttribute("width",r),this.topLayer.parent.setAttribute("height",n),this.topLayer.setAttribute("size",[r,n]),this.topLayer.setAttribute("pos",[r*.5,n*.5]))}async updateDpr(e){super.updateDpr(e);const r=this.topLayerWork&&!!this.topLayerWork.localWorkShapes.size||!1,n=!!this.localWork.getWorkShapes().size,s=[];n&&s.push({isClearAll:!0,clearCanvas:_e.Float,viewId:this.viewId}),r&&s.push({isClearAll:!0,clearCanvas:_e.TopFloat,viewId:this.viewId}),s.length&&await this.post({render:s})}async updateCamera(e){var s;const r=[],{cameraOpt:n}=e;if(n&&!Zr(this.cameraOpt,n)){const o=this.topLayerWork&&!!this.topLayerWork.localWorkShapes.size||!1,a=!!this.localWork.getWorkShapes().size;if(a&&this.localWork.workShapesDone(),this.setCameraOpt(n),a&&r.push({isClearAll:!0,clearCanvas:_e.Float,viewId:this.viewId}),o&&this.topLayerWork){r.push({isClearAll:!0,clearCanvas:_e.TopFloat,viewId:this.viewId});for(const[c,l]of this.topLayerWork.localWorkShapes.entries()||[])if(l.totalRect){let u;(s=this.topLayer)==null||s.getElementsByName(c.toString()).forEach(h=>{const d=h.getBoundingClientRect(),g=fn({x:d.x,y:d.y,w:d.width,h:d.height});u=Ge(u,g)}),l.totalRect=u,this.topLayerWork.localWorkShapes.set(c,l)}}r.length&&await this.post({render:r})}}setCameraOpt(e,r){var l,u;this.cameraOpt=e;const{scale:n,centerX:s,centerY:o,width:a,height:c}=e;(a!==this.scene.width||c!==this.scene.height)&&this.updateScene(this.scene,{width:a,height:c}),r?(r.setAttribute("scale",[n,n]),r.setAttribute("translate",[-s,-o])):(this.fullLayer.setAttribute("scale",[n,n]),this.fullLayer.setAttribute("translate",[-s,-o]),(l=this.topLayer)==null||l.setAttribute("scale",[n,n]),(u=this.topLayer)==null||u.setAttribute("translate",[-s,-o]))}}class Os extends xe{constructor(e){super(e);R(this,"canRotate",!0);R(this,"scaleType",Ve.all);R(this,"toolsType",K.Image);R(this,"tmpPoints",[]);R(this,"workOptions");R(this,"oldRect");this.workOptions=e.toolsOpt,this.scaleType=Os.getScaleType(this.workOptions)}static normalizeStorageData(e){return xe.normalizeStorageData(e)}consume(){return{type:he.None}}consumeAll(){return{type:he.None}}draw(e){const{layer:r,workId:n,replaceId:s,imageBitmap:o}=e,{centerX:a,centerY:c,width:l,height:u,rotate:h,zIndex:d,eraserlines:g,eraserFaces:p,doingLines:v}=this.workOptions,I=new dt({anchor:[.5,.5],pos:[a,c],name:n,size:[l,u],zIndex:d,rotate:h}),D={anchor:[.5,.5],pos:[0,0],size:[l,u],texture:o};o||(D.bgcolor="rgba(0,0,0,0.3)");const x=new Ja(D);I.append(x),(g||p||v)&&this.drawEraserlines({group:I,eraserlines:this.getRenderableEraserLines(this.workOptions),eraserFaces:p,pos:[a,c],layer:r}),this.replace(r,s||n,I);const j=I.getBoundingClientRect();if(j)return{x:Math.floor(j.x-xe.SafeBorderPadding),y:Math.floor(j.y-xe.SafeBorderPadding),w:Math.floor(j.width+xe.SafeBorderPadding*2),h:Math.floor(j.height+xe.SafeBorderPadding*2)}}consumeService(){}async consumeServiceAsync(e){var u,h,d,g;const{isFullWork:r,replaceId:n,worker:s}=e,{src:o,uuid:a}=this.workOptions,c=((u=this.workId)==null?void 0:u.toString())||a,l=r?this.fullLayer:this.drawLayer||this.fullLayer;if(o){const p=await s.loadImageBitMap({toolsType:this.toolsType,opt:this.workOptions,workId:c,isSubWorker:s instanceof Xye});if(p){const v=this.draw({workId:c,layer:l,replaceId:n,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:v,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:v&&xe.getCenterPos(v,l)}),v}}}clearTmpPoints(){this.tmpPoints.length=0}static getScaleType(e){const{uniformScale:r,rotate:n}=e;return r!==!1||n&&Math.abs(n)%90>0?Ve.proportional:Ve.all}static updateNodeOpt(e){const{node:r,opt:n,vNodes:s,targetNode:o}=e,{translate:a,originPoint:c,scenePoint:l,scale:u,angle:h,isLocked:d,zIndex:g,strokeColor:p}=n,v=o&&Lt(o)||s.get(r.name);if(!v)return;const I=r.parent;if(I){if(p&&(v.opt.strokeColor=p),It(g)&&(r.setAttribute("zIndex",g),v.opt.zIndex=g),Hn(d)&&(v.opt.locked=d),c&&l&&u&&a){const{centerX:D,centerY:x,width:j,height:w,uniformScale:y}=v.opt,f=y!==!1?[u[0],u[0]]:u,M=[D,x],T=[D,x];uc(T,l,f,a);const b=[T[0]-M[0],T[1]-M[1]];if(v.centerPos=[v.centerPos[0]+b[0],v.centerPos[1]+b[1]],v.opt.width=Math.round(j*f[0]),v.opt.height=Math.round(w*f[1]),v.opt.centerX=T[0],v.opt.centerY=T[1],v.opt.eraserlines)for(const C of v.opt.eraserlines){const{op:P,thickness:E}=C;C.thickness=Math.round(E*Math.max(u[0],u[1]));for(let O=0;O<P.length;O++)xs(P[O],l,u,a)}}else if(a){if(v.opt.centerX=v.opt.centerX+a[0],v.opt.centerY=v.opt.centerY+a[1],v.centerPos=[v.centerPos[0]+a[0],v.centerPos[1]+a[1]],v.opt.eraserlines)for(const D of v.opt.eraserlines){const{op:x}=D;for(let j=0;j<x.length;j++){const w=x[j].map((y,f)=>f%2?y+a[1]:y+a[0]);D.op[j]=w}}}else if(It(h))if(v.opt.rotate=h,v.scaleType=Os.getScaleType(v.opt),o){const D=jh(v.rect,h);v.rect=D}else{const D=xe.getRectFromLayer(I,r.name);v.rect=D||v.rect}return v&&s.setInfo(r.name,v),v==null?void 0:v.rect}}}function Ge(i,t){if(i&&t){const e=Math.min(i.x,t.x),r=Math.min(i.y,t.y),n=Math.max(i.x+i.w,t.x+t.w),s=Math.max(i.y+i.h,t.y+t.h),o=n-e,a=s-r;return{x:e,y:r,w:o,h:a}}return t||i}function zh(i,t){if(i&&t){const e=Math.min(i.originX,t.originX),r=Math.min(i.originY,t.originY),n=Math.max(i.originX+i.width,t.originX+t.width),s=Math.max(i.originY+i.height,t.originY+t.height),o=n-e,a=s-r;return{originX:e,originY:r,width:o,height:a}}return t||i}function et(i,t=0){const e={x:0,y:0,w:0,h:0};let r=1/0,n=1/0,s=-1/0,o=-1/0;return i.forEach(a=>{const[c,l]=a.XY;r=Math.min(r,c-t),n=Math.min(n,l-t),s=Math.max(s,c+t),o=Math.max(o,l+t)}),e.x=r,e.y=n,e.w=s-r,e.h=o-n,e}function va(i,t){return!(i.x+i.w<t.x||i.x>t.x+t.w||i.y+i.h<t.y||i.y>t.y+t.h)}function fn(i,t=10){return{x:Math.floor(i.x-t),y:Math.floor(i.y-t),w:Math.ceil(i.w+t*2),h:Math.ceil(i.h+t*2)}}function zs(i,t){return{x:i.x+t[0],y:i.y+t[1],w:i.w,h:i.h}}function Jye(i,t){const e=new fe(i.x,i.y),r=new fe(i.x+i.w,i.y),n=new fe(i.x+i.w,i.y+i.h),s=new fe(i.x,i.y+i.h),o=new fe(i.x+i.w/2,i.y+i.h/2),a=Math.PI*t/180,c=fe.RotWith(e,o,a),l=fe.RotWith(r,o,a),u=fe.RotWith(n,o,a),h=fe.RotWith(s,o,a);return[c,l,u,h]}function jh(i,t){const e=Jye(i,t);return et(e)}function E0(i,t,e){const r=new fe(i.x,i.y),n=new fe(i.x+i.w,i.y),s=new fe(i.x+i.w,i.y+i.h),o=new fe(i.x,i.y+i.h),a=new fe(e[0],e[1]),c=new fe(t[0],t[1]),l=fe.ScaleWOrigin(r,c,a),u=fe.ScaleWOrigin(n,c,a),h=fe.ScaleWOrigin(s,c,a),d=fe.ScaleWOrigin(o,c,a);return et([l,u,h,d])}function _ye(i,t,e){const r=new fe(t[0],t[1]);for(let n=0;n<i.length;n+=3){const s=new fe(i[n],i[n+1]),o=Math.PI*e/180,a=fe.RotWith(s,r,o);i[n]=a.x,i[n+1]=a.y}}function Vg(i,t,e){const r=new fe(t[0],t[1]);for(let n=0;n<i.length;n+=2){const s=new fe(i[n],i[n+1]),o=Math.PI*e/180,a=fe.RotWith(s,r,o);i[n]=a.x,i[n+1]=a.y}}function uc(i,t,e,r=[0,0]){const n=new fe(t[0],t[1]);for(let s=0;s<i.length;s+=3){const o=new fe(i[s],i[s+1]),a=new fe(e[0],e[1]),c=fe.ScaleWOrigin(o,a,n);i[s]=c.x+r[0],i[s+1]=c.y+r[1]}}function xs(i,t,e,r=[0,0]){const n=new fe(t[0],t[1]);for(let s=0;s<i.length;s+=2){const o=new fe(i[s],i[s+1]),a=new fe(e[0],e[1]),c=fe.ScaleWOrigin(o,a,n);i[s]=c.x+r[0],i[s+1]=c.y+r[1]}}function A0(i,t){return i[0]>=t.x&&i[0]<=t.x+t.w&&i[1]>=t.y&&i[1]<=t.y+t.h}function N0(i,t){const e=i<=t?1:i/t,r=t<=i?1:t/i;return[e,r]}function e0e(i){for(const t of i)if(isNaN(t)||t===1/0||t===-1/0)return!1;return!0}function t0e(i){return i!==Math.floor(i)}function r0e(i){const t=i.toString();return t.indexOf(".")!==-1?t.split(".")[1].length:0}function n0e(i,t){for(;t!==0;)[i,t]=[t,i%t];return i}const i0e=i=>{if(i.tagName==="GROUP"){const t=Object.getOwnPropertySymbols(i).find(e=>e.toString()==="Symbol(sealed)");if(t&&i[t])return!0}return!1},cr=(i,t)=>{if(i.mesh&&i.mesh.texture&&i.name==="eraserTexture"){const e=i.mesh.texture.image;t.deleteTexture(e)}else if(i.tagName==="GROUP"&&i&&i.children)for(const e of i.children)cr(e,t)},ar=(i,t)=>{cr(i,t),i.removeAllChildren()},s0e=(i,t,e)=>{const r=e.parent;if(t){const n=t.children;if(n){for(const s of n)if(cr(s,r),s.tagName==="GROUP")for(const o of s.children)cr(o,r)}}t.parent.replaceChild(i,t)},o0e=(i,t,e)=>{if(i.w+i.x<=0||i.h+i.y<=0||i.w<=0||i.h<=0)return;const r=t.width,n=t.height,s={x:Math.floor(Math.max(0,i.x)),y:Math.floor(Math.max(0,i.y)),w:Math.floor(Math.min(r,i.w)),h:Math.floor(Math.min(n,i.h))};if(s.x+s.w>r&&(s.w=Math.floor(r-s.x)),s.y+s.h>n&&(s.h=Math.floor(n-s.y)),t0e(e)){const o=r0e(e),a=Math.pow(10,o),c=n0e(a,e*a),l=s.x%c,u=s.x-l;u>=0?(s.x=u,s.w=s.w+l):(s.x=0,s.w=s.w+l-u);const h=s.y%c,d=s.y-h;d>=0?(s.y=d,s.h=s.h+h):(s.y=0,s.h=s.h+h-d)}return s};function Ti(i){return`${Ma(i.x)},${Ma(i.y)} `}function Si(i,t){return`${Ma((i.x+t.x)/2)},${Ma((i.y+t.y)/2)} `}function Ma(i){return+i.toFixed(4)}const xr=async(i,t,e=!1)=>{let r,n;return new Promise(function(s){if(e&&requestIdleCallback)requestIdleCallback(()=>{s(1)},{timeout:t});else{if(typeof window.requestIdleCallback=="function"){const o=typeof t=="number"&&!isNaN(t)&&t>0?t:0;n=window.requestIdleCallback(()=>{clearTimeout(r),s(1)},{timeout:o})}r=setTimeout(()=>{n&&window.cancelIdleCallback(n),s(1)},t||0)}}).then(function(){i()}).catch(function(){i()})},ji=i=>Math.max(1,(window.devicePixelRatio||1)/1),hc=(i,t)=>i.x+i.w<t.x||i.x>t.x+t.w||i.y+i.h<t.y||i.y>t.y+t.h?Kr.outside:i.x>=t.x&&i.y>=t.y&&i.x+i.w<=t.x+t.w&&i.y+i.h<=t.y+t.h?Kr.inside:Kr.intersect;function a0e(i){let t=0;for(let e=0;e<i.length;e++){const r=i.charCodeAt(e);r>=1&&r<=126||65376<=r&&r<=65439?t++:t+=2}return t}function c0e(i){if(!i||typeof i!="string")return!1;const t=i.trim();if(!t)return!1;const e=[/^\s*#{1,6}\s+.+/m,/^\s*[-*+]\s+.+/m,/^\s*\d+\.\s+.+/m,/\[([^\]]+)\]\(([^)]+)\)/,/\[([^\]]+)\]\[([^\]]+)\]/,/```[\s\S]*?```/,/`[^`]+`/,/^\s*\|.+\|/m,/!\[([^\]]*)\]\(([^)]+)\)/,/\*\*[^*]+\*\*/,/__[^_]+__/,/\*[^*]+\*/,/_[^_]+_/,/~~[^~]+~~/,/==[^=]+==/,/^\s*[-*+]\s+\[[ xX]\]\s+.+/m,/^\s*>\s+.+/m,/^\s*[-*]{3,}\s*$/m];let r=0;for(const o of e)o.test(t)&&r++;const s=[/^\s*#{1,6}\s+/m,/^\s*[-*+]\s+/m,/^\s*\d+\.\s+/m,/```[\s\S]*?```/,/^\s*\|.+\|/m].some(o=>o.test(t));return r>=2||s}class l0e{constructor(t,e){R(this,"plugin");R(this,"uid");R(this,"control");this.control=t,this.plugin=e,this.uid=e.displayer.uid}getNamespaceData(){var t;return Wo((t=this.plugin)==null?void 0:t.attributes[this.namespace])||{}}getAuthSpaceData(){var t;return Wo((t=this.plugin)==null?void 0:t.attributes[this.authSpace])||{}}getGlobalUndoRedoStackData(){var t;return Wo((t=this.plugin)==null?void 0:t.attributes[this.globalUndoRedoStackSpace])||{}}getUidFromKey(t){return t.split(Rt).length===2&&t.split(Rt)[0]||this.uid}isLocalId(t){return t.split(Rt).length===1}getLocalId(t){return t.split(Rt)[1]}isSelector(t){return this.getLocalId(t)===De}}const Ft=class Ft extends l0e{constructor(e,r,n){super(e,r);R(this,"namespace");R(this,"authSpace");R(this,"globalUndoRedoStackSpace");R(this,"serviceStorage",{});R(this,"storage",{});R(this,"authStorage",{});R(this,"globalUndoRedoStackStorage",{});R(this,"stateDisposer");R(this,"authDisposer");R(this,"asyncClockState",!1);R(this,"limitNums",new Map);R(this,"syncInterval");R(this,"limitComponents",ve.debounce((e,r)=>{var o,a,c,l,u,h,d,g;const n=((a=(o=this.storage)==null?void 0:o[e])==null?void 0:a[r])&&Object.keys(this.storage[e][r]).length||0;if(n===0)return;let s=this.limitNums.get(`${e}/${r}`);if(!s){const p=this.getLimitNum(n);this.limitNums.set(`${e}/${r}`,p),s=p}if(s>0&&n>=s){const p=Ft.componentsLimits.indexOf(s),v=p>=0&&p<Ft.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",D=>D(s,v))),!v){this.Logger.error(`[Appliance]: exceeds the limit of ${s} components, current: ${n}`),(g=this.control.room)==null||g.disconnect().then(()=>{var D,x,j,w,y;(j=(x=(D=this.control.room)==null?void 0:D.callbacks)==null?void 0:x.listeners)!=null&&j.map.onKickedWithReason&&(this.Logger.info("[Appliance]: onKickedWithReason callback is called"),(y=(w=this.control.room)==null?void 0:w.callbacks)==null||y.dispatch("onKickedWithReason",f=>f("kickByAdmin")))});return}console.warn(`exceeds the limit of ${s} components, current: ${n}`);const I=v?Ft.componentsLimits[p+1]:0;this.limitNums.set(`${e}/${r}`,I)}},2e3,{maxWait:5e3}));R(this,"clearLimitComponents",(e,r)=>{if(r)this.limitNums.delete(`${e}/${r}`);else for(const n of this.limitNums.keys())`${e}/`.indexOf(n)===0&&this.limitNums.delete(n)});this.syncInterval=n,this.namespace=Ft.namespace,this.authSpace=Ft.authSpace,this.globalUndoRedoStackSpace=Ft.globalUndoRedoStackSpace,this.serviceStorage=this.getNamespaceData(),this.storage=ve.cloneDeep(this.serviceStorage),this.authStorage=this.getAuthSpaceData(),this.globalUndoRedoStackStorage={},this.getLimitNums()}get Logger(){return this.control.logger}hasId(e,r,n){const s=this.getLocalId(n)?this.transformKey(n):n;return!!(this.storage[e]&&this.storage[e][r]&&this.storage[e][r][s])}getLimitNum(e){return e>=Ft.componentsLimits[0]?Ft.componentsLimits[1]:Ft.componentsLimits[0]}getLimitNums(){for(const[e,r]of Object.entries(this.storage))if(e&&r){for(const[n,s]of Object.entries(r))if(n&&s){const o=this.getLimitNum(Object.keys(s).length);this.limitNums.set(`${e}/${n}`,o)}}}getViewIdBySecenPath(e){const r=this.getNamespaceData();for(const[n,s]of Object.entries(r))if(s){for(const o of Object.keys(s))if(o===e)return n}}getScenePathData(e){const r=this.getNamespaceData();for(const n of Object.values(r))if(n){for(const s of Object.keys(n))if(s===e)return ve.cloneDeep(n[s])}}hasTargetDataByViewId(e,r){const n=this.getNamespaceData();if(n&&n[e]){for(const s of Object.values(n[e]))for(const o of Object.keys(s))if(o===r)return!0}}getTargetDataByViewId(e,r){const n=this.getNamespaceData();let s,o;if(n&&n[e])for(const[a,c]of Object.entries(n[e]))for(const l of Object.keys(c))l===r&&(s=ve.cloneDeep(c[l]),o=a);return{data:s,scenePath:o}}getStorageData(e,r){const n=this.getNamespaceData();return n&&n[e]&&ve.cloneDeep(n[e][r])||void 0}hasSelector(e,r){const n=this.storage&&this.storage[e]&&this.storage[e][r];return!!(n&&Object.keys(n).find(s=>this.isOwn(s)&&this.getLocalId(s)===De))}hasIncludeSelector(e,r,n){for(const s of Object.keys(this.storage))if(!(r&&s!==r)){for(const o of Object.keys(this.storage[s]))if(!(n&&o!==n)){for(const a of Object.keys(this.storage[s][o]))if(this.getLocalId(a)===De){const c=this.storage[s][o][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=mc(async()=>{var c,l,u,h,d,g;const r=this.getNamespaceData(),{diffView:n,diffScenePath:s,diffData:o}=this.diffFunByView(this.serviceStorage,r);this.serviceStorage=r;const a={};if(Object.keys(n).length>0)for(const[p,v]of Object.entries(n))v&&!ve.isEqual((c=this.storage)==null?void 0:c[p],v.newValue)&&(a.diffView||(a.diffView={}),a.diffView[p]=v,this.storage||(this.storage={}),v.newValue===void 0?delete this.storage[p]:this.storage[p]=ve.cloneDeep(v.newValue));if(Object.keys(s).length>0){for(const[p,v]of Object.entries(s))if(v){const{viewId:I,newValue:D}=v;v&&!ve.isEqual((u=(l=this.storage)==null?void 0:l[I])==null?void 0:u[p],D)&&(a.diffScenePath||(a.diffScenePath={}),a.diffScenePath[p]=v,this.storage||(this.storage={}),this.storage[I]||(this.storage[I]={}),v.newValue===void 0?delete this.storage[I][p]:this.storage[I][p]=ve.cloneDeep(v.newValue))}}if(Object.keys(o).length>0){for(const[p,v]of Object.entries(o))if(v){const{viewId:I,scenePath:D,newValue:x}=v;v&&!ve.isEqual((g=(d=(h=this.storage)==null?void 0:h[I])==null?void 0:d[D])==null?void 0:g[p],x)&&(a.diffData||(a.diffData={}),a.diffData[p]=v,this.storage||(this.storage={}),this.storage[I]||(this.storage[I]={}),this.storage[I][D]||(this.storage[I][D]={}),v.newValue===void 0?delete this.storage[I][D][p]:this.storage[I][D][p]=ve.cloneDeep(v.newValue))}}this.logServiceDiff(a),Object.keys(a).length>0&&e(a),this.control.worker.publicMsgEmitter.emit("syncStorageChange",this.serviceStorage)})}logServiceDiff(e){var r,n,s;for(const o of Object.keys(e.diffView||{}))this.control.isServiceSyncReady(o)&&this.control.syncLogger.append("serviceDiff",o,"",[{diffType:"view",viewId:o}]);for(const[o,a]of Object.entries(e.diffScenePath||{}))a&&this.control.isServiceSyncReady(a.viewId)&&this.control.syncLogger.append("serviceDiff",a.viewId,o,[{diffType:"scenePath",viewId:a.viewId,scenePath:o}]);for(const[o,a]of Object.entries(e.diffData||{}))a&&this.control.isServiceSyncReady(a.viewId)&&this.control.syncLogger.append("serviceDiff",a.viewId,a.scenePath,[{diffType:"data",viewId:a.viewId,scenePath:a.scenePath,key:o,type:(r=a.newValue)==null?void 0:r.type,toolsType:((n=a.newValue)==null?void 0:n.toolsType)??((s=a.oldValue)==null?void 0:s.toolsType)}])}removeStorageStateListener(){this.stateDisposer&&this.stateDisposer()}diffFunByView(e,r){const n=ot(e),s=ot(r),o={},a={},c={};for(const l of s)if(!n.includes(l)||e[l]===void 0){o[l]={newValue:r[l],oldValue:void 0};continue}for(const l of n){if(ve.isEqual(e[l],r[l]))continue;if(!s.includes(l)||r[l]===void 0){o[l]={newValue:void 0,oldValue:e[l]};continue}const u=this.diffFunByScenePath(e[l],r[l],l);Object.assign(a,u.diffScenePath),Object.assign(c,u.diffData)}return{diffData:c,diffScenePath:a,diffView:o}}diffFunByScenePath(e,r,n){const s=ot(e),o=ot(r),a={},c={};for(const l of o)if(!s.includes(l)||e[l]===void 0){a[l]={newValue:r[l],oldValue:void 0,viewId:n};continue}for(const l of s){if(ve.isEqual(e[l],r[l]))continue;if(!o.includes(l)||r[l]===void 0){a[l]={newValue:void 0,oldValue:e[l],viewId:n};continue}const u=this.diffFunByKeys(e[l],r[l],l,n);Object.assign(c,u)}return{diffScenePath:a,diffData:c}}diffFunByKeys(e,r,n,s){const o=ot(e),a=ot(r),c={};for(const l of a)(!o.includes(l)||e[l]===void 0)&&(c[l]={oldValue:void 0,newValue:r[l],viewId:s,scenePath:n});for(const l of o)if(!ve.isEqual(e[l],r[l])){if(!a.includes(l)||r[l]===void 0){c[l]={newValue:void 0,oldValue:e[l],viewId:s,scenePath:n};continue}a.includes(l)&&(c[l]={oldValue:e[l],newValue:r[l],viewId:s,scenePath:n})}return c}transformKey(e){return this.uid+Rt+e}isOwn(e){return e.split(Rt)[0]===this.uid}dispatch(e){var x,j;const{type:r,workId:n,ops:s,index:o,opt:a,toolsType:c,removeIds:l,updateNodeOpt:u,op:h,selectIds:d,isSync:g,scenePath:p,viewId:v}=e;if(!v)return;const I=Number(e.needUndoTicker??e.collectUndoTicker??void 0),D=w=>{I?this.control.internalMsgEmitter.emit("ackStorageUndoTicker",I,v,p,w,{requestId:e.requestId,emitEventType:e.emitEventType}):e.emitEventType===Se.TranslateNode||(e.emitEventType,Se.CopyNode)};switch(r){case he.Clear:const w={};p&&this.storage[v]&&this.storage[v][p]?(delete this.storage[v][p],this.setState(w,{isSync:g,viewId:v,scenePath:p})):this.storage[v]&&(delete this.storage[v],this.setState(w,{isSync:g,viewId:v,scenePath:""})),xr(()=>{var b,C;(b=this.control.pluginManager)==null||b.dispatchPluginEvent("syncStorage",v,p),this.control.isUseSimple||(C=this.control.miniMapManager)==null||C.updateMiniMapCamera(v),this.clearLimitComponents(v,p)},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback"));break;case he.CreateWork:if(p&&n&&c&&a){const b=this.isLocalId(n.toString())?this.transformKey(n):n;this.control.renderControl.isUsePageAuth(v)&&this.control.renderControl.addRenderPageElementId({viewId:v,scenePath:p,elementId:b.toString()}),this.updateValue(b.toString(),{type:he.CreateWork,workId:n,toolsType:c,opt:a},{isSync:g,viewId:v,scenePath:p,onApplied:()=>D(b.toString())})}break;case he.DrawWork:if(p&&n&&typeof o=="number"&&(h!=null&&h.length)){const b=this.isLocalId(n.toString())?this.transformKey(n):n,C=this.storage[v]&&this.storage[v][p]&&this.storage[v][p][b]||void 0;if(C!=null&&C.ops||(C==null?void 0:C.type)===he.FullWork)return;const P=o?((C==null?void 0:C.op)||[]).slice(0,o).concat(h):h||(C==null?void 0:C.op),E=c||(C==null?void 0:C.toolsType),O=a||(C==null?void 0:C.opt),V=u||(C==null?void 0:C.updateNodeOpt);n&&E&&O&&P&&(this.control.renderControl.isUsePageAuth(v)&&this.control.renderControl.addRenderPageElementId({viewId:v,scenePath:p,elementId:b.toString()}),this.updateValue(b.toString(),{...C,type:he.DrawWork,workId:n,updateNodeOpt:V,toolsType:E,opt:O,op:P,index:o},{isSync:g,viewId:v,scenePath:p,onApplied:()=>D(b.toString())}))}break;case he.FullWork:if(p&&n){const b=this.isLocalId(n.toString())?this.transformKey(n):n,C=this.storage[v]&&this.storage[v][p]&&this.storage[v][p][b]||void 0,P=u||(C==null?void 0:C.updateNodeOpt),E=c||(C==null?void 0:C.toolsType),O=a||(C==null?void 0:C.opt),V=s||(C==null?void 0:C.ops);E&&O&&(this.control.renderControl.isUsePageAuth(v)&&this.control.renderControl.addRenderPageElementId({viewId:v,scenePath:p,elementId:b.toString()}),this.updateValue(b.toString(),{type:he.FullWork,updateNodeOpt:P,workId:b,toolsType:E,opt:O,ops:V},{isSync:g,viewId:v,scenePath:p,onApplied:()=>{D(b.toString())}}),xr(()=>{var N,A;(N=this.control.pluginManager)==null||N.dispatchPluginEvent("syncStorage",v,p),this.control.isUseSimple||(A=this.control.miniMapManager)==null||A.updateMiniMapCamera(v),this.limitComponents(v,p)},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback")))}break;case he.RemoveNode:if(p&&(l!=null&&l.length)){const b=l.map(E=>this.isLocalId(E+"")?this.transformKey(E):E);let C=0;const P=(x=this.storage[v])==null?void 0:x[p];P&&(Object.keys(P).map(E=>{b!=null&&b.includes(E)&&(C++,this.control.renderControl.isUsePageAuth(v)&&this.control.renderControl.delRenderPageElementId({viewId:v,scenePath:p,elementId:E}),this.updateValue(E,void 0,{isSync:g,viewId:v,scenePath:p,onApplied:()=>D(E)}))}),(j=this.control.pluginManager)==null||j.dispatchPluginEvent("syncStorage",v,p),this.control.isUseSimple||xr(()=>{var E;(E=this.control.miniMapManager)==null||E.updateMiniMapCamera(v)},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback"))),I&&C===0&&D()}break;case he.UpdateNode:if(p&&n&&(u||s||a)){const b=this.isLocalId(n.toString())?this.transformKey(n):n,C=this.storage[v]&&this.storage[v][p]&&this.storage[v][p][b]||void 0;C&&(C.updateNodeOpt=u,(s||h)&&(C.ops=s,C.op=h),a&&(C.opt=su(iu(C.opt,a))),C.type=he.FullWork,this.updateValue(b.toString(),C,{isSync:g,viewId:v,scenePath:p,onApplied:()=>D(b.toString())}),this.control.isUseSimple||xr(()=>{var P;(P=this.control.miniMapManager)==null||P.updateMiniMapCamera(v)},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback")))}break;case he.Select:if(!p)return;let y;d!=null&&d.length&&(y=d.map(b=>this.isLocalId(b+"")?this.transformKey(b):b));const f=this.transformKey(De),M=this.storage[v]&&this.storage[v][p]&&this.storage[v][p][f]||void 0,T=a||(M==null?void 0:M.opt);y&&this.checkOtherSelector(f,y,{isSync:g,viewId:v,scenePath:p}),this.updateValue(f,y&&{type:he.Select,toolsType:K.Selector,opt:T,selectIds:y},{isSync:g,viewId:v,scenePath:p,onApplied:()=>D(f)});break}}checkOtherSelector(e,r,n){const{viewId:s,scenePath:o}=n;for(const a of Object.keys(this.storage[s][o]))if(a!==e&&this.getLocalId(a)===De){const c=this.storage[s][o][a];if(c&&c.selectIds){const l=c.selectIds.filter(u=>!r.includes(u));l.length>0&&(c.selectIds=l),this.updateValue(a,l.length&&c||void 0,n)}}}setState(e,r){const{viewId:n,scenePath:s}=r,o=ot(e);for(let a=0;a<o.length;a++){const c=o[a],l=e[c];typeof l<"u"?(this.storage[n]||(this.storage[n]={}),this.storage[n][s]||(this.storage[n][s]={}),this.storage[n][s][c]=l):delete this.storage[n][s][c]}this.runSyncService(r)}updateValue(e,r,n){var l,u;const{viewId:s,scenePath:o,storage:a}=n,c=a||this.storage;if(r===void 0){const h=(l=c[s])==null?void 0:l[o];h&&delete h[e]}else c[s]||(c[s]={}),c[s][o]||(c[s][o]={}),c[s][o][e]=r;n.onApplied,(u=n.onApplied)==null||u.call(n),this.runSyncService(n)}runSyncService(e){if(!this.control.renderControl.isWritable){this.Logger.error("[Appliance]: The current state is not writable and synchronization cannot be synchronized");return}this.asyncClockState||(this.asyncClockState=!0,e.isSync?(this.asyncClockState=!1,this.syncSerivice(e)):xr(()=>{this.asyncClockState=!1,this.syncSerivice(e)},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback")))}syncSerivice(e={storage:this.storage}){const{storage:r}=e,n=r||this.storage;this.logLocalSyncChanges(this.serviceStorage,n);const s=ot(this.serviceStorage),o=ot(n),a=new Map;for(const c of s){if(!o.includes(c)){a.set(c,void 0);continue}ve.isEqual(this.serviceStorage[c],n[c])||this.syncViewData(n,c)}for(const c of o)s.includes(c)||a.set(c,n[c]);if(a.size>=o.length||a.size>5&&o.length<20)this.syncStorageView(n);else for(const[c,l]of a.entries())this.syncUpdataView(n,c,l)}logLocalSyncChanges(e,r){const n=new Set([...ot(e),...ot(r)]);for(const s of n){const o=e[s]||{},a=r[s]||{},c=new Set([...ot(o),...ot(a)]);for(const l of c){const u=o[l]||{},h=a[l]||{},d=new Set([...ot(u),...ot(h)]),g=[];for(const p of d){const v=u[p],I=h[p];ve.isEqual(v,I)||g.push({key:p,type:I==null?void 0:I.type,toolsType:(I==null?void 0:I.toolsType)??(v==null?void 0:v.toolsType)})}this.control.syncLogger.append("localSync",s,l,g)}}}syncViewData(e,r){const n=ot(this.serviceStorage[r]),s=ot(e[r]),o=new Map;for(const a of n){if(!s.includes(a)){o.set(a,void 0);continue}ve.isEqual(this.serviceStorage[r][a],e[r][a])||this.syncScenePathData(e,r,a)}for(const a of s)n.includes(a)||o.set(a,e[r][a]);if(o.size>=s.length||o.size>5&&s.length<20)this.syncStorageScenePath(r,e[r]);else for(const[a,c]of o.entries())this.syncUpdataScenePath(e,r,a,c)}syncScenePathData(e,r,n){const s=ot(this.serviceStorage[r][n]),o=ot(e[r][n]),a=new Map;for(const c of s){if(!o.includes(c)){a.set(c,void 0);continue}ve.isEqual(this.serviceStorage[r][n][c],e[r][n][c])||a.set(c,e[r][n][c])}for(const c of o)s.includes(c)||a.set(c,e[r][n][c]);if(a.size>=o.length||a.size>5&&o.length<50)this.syncStorageKey(r,n,e[r][n]);else for(const[c,l]of a.entries())this.syncUpdataKey(e,r,n,c,l)}syncUpdataView(e,r,n){var o;Object.keys(this.serviceStorage).length?(o=this.plugin)==null||o.updateAttributes([this.namespace,r],n):this.syncStorageView(e)}syncStorageView(e){var r;(r=this.plugin)==null||r.updateAttributes([this.namespace],e)}syncUpdataScenePath(e,r,n,s){var a;Object.keys(this.serviceStorage[r]).length?(a=this.plugin)==null||a.updateAttributes([this.namespace,r,n],s):this.syncStorageScenePath(r,e[r])}syncStorageScenePath(e,r){var n;(n=this.plugin)==null||n.updateAttributes([this.namespace,e],r)}syncUpdataKey(e,r,n,s,o){var c;Object.keys(this.serviceStorage[r][n]).length?(c=this.plugin)==null||c.updateAttributes([this.namespace,r,n,s],o):this.syncStorageKey(r,n,e[r][n])}syncStorageKey(e,r,n){var s;(s=this.plugin)==null||s.updateAttributes([this.namespace,e,r],n)}keyTransformWorkId(e){const r=e.split(Rt);return r.length===2?r[1]:e}destroy(){this.removeStorageStateListener(),this.serviceStorage={},this.storage={},this.removeAuthStateListener(),this.authStorage={},this.globalUndoRedoStackStorage={}}transformToSerializableUndoStackItemData(e){const{data:r,scenePath:n}=e,s={};for(const o of r)s[o.key]={dataType:o.dataType,data:o.data};return{data:s,scenePath:n}}dispatchUndoTicker(e){const{viewId:r,undoTickerId:n,data:s,syncType:o,operation:a}=e,c=a===yt.syncUndoStack?"undoStack":"redoStack",l=o==="delete"?void 0:this.transformToSerializableUndoStackItemData(s);if(this.plugin){if(o==="delete"){const u=this.globalUndoRedoStackStorage[r]&&this.globalUndoRedoStackStorage[r][c];if(!u)return;delete u[n],this.plugin.updateAttributes([this.globalUndoRedoStackSpace,r,c,n],void 0);return}if(this.plugin.getAttributesValue([this.globalUndoRedoStackSpace]))if(this.plugin.getAttributesValue([this.globalUndoRedoStackSpace,r]))if(this.plugin.getAttributesValue([this.globalUndoRedoStackSpace,r,c]))this.globalUndoRedoStackStorage[r][c][n]=l,this.plugin.updateAttributes([this.globalUndoRedoStackSpace,r,c,n],l);else{const u={[n]:l};this.globalUndoRedoStackStorage[r][c]=u,this.plugin.updateAttributes([this.globalUndoRedoStackSpace,r,c],u)}else{const u={[c]:{[n]:l}};this.globalUndoRedoStackStorage[r]=u,this.plugin.updateAttributes([this.globalUndoRedoStackSpace,r],u)}else{const u={[r]:{[c]:{[n]:l}}};this.globalUndoRedoStackStorage=u,this.plugin.updateAttributes(this.globalUndoRedoStackSpace,u)}}}addGlobalUndoRedoStackListener(e){this.authDisposer=mc(async()=>{const r=this.getGlobalUndoRedoStackData();if(ve.isEqual(this.globalUndoRedoStackStorage,r))return;const n=this.diffGlobalUndoRedoStackFun(this.globalUndoRedoStackStorage,r);this.globalUndoRedoStackStorage=r,e(n)})}diffGlobalUndoRedoStackFun(e,r){const n=ot(e),s=ot(r),o={};for(const a of s)if(!n.includes(a)||e[a]===void 0){o[a]={newValue:r[a],oldValue:void 0};continue}for(const a of n)if(!ve.isEqual(e[a],r[a])){if(!s.includes(a)||r[a]===void 0){o[a]={newValue:void 0,oldValue:e[a]};continue}o[a]={newValue:r[a],oldValue:e[a]}}return o}dispatchPageAuth(e,r=!0){var l,u,h,d,g,p,v,I,D,x,j,w,y,f,M,T,b,C,P,E,O,V,N,A,k,U,Z,Q,ce,L,W,H,$,ee,ie,le,pe,Te;const{operation:n,viewId:s,scenePath:o,pageId:a,pageData:c}=e;switch(n){case yt.addPage:{if(!s||!o||!a)return;const z=[this.authSpace];Object.keys(this.authStorage).length&&z.push("pageAuth");const B=this.authStorage.pageAuth||{};this.authStorage.pageAuth=B,Object.keys(B).length&&z.push(s),B[s]=B[s]||{},Object.keys(B[s]).length&&z.push(o),B[s][o]=B[s][o]||{render:(c==null?void 0:c.render)||"localSelf",pages:{}},Object.keys(B[s][o].pages).length&&z.push("pages",a);const X={};if(c!=null&&c.elementIds)for(const ae of c.elementIds.keys())X[ae]=!0;B[s][o].pages[a]=X,r&&(z.length===1?(l=this.plugin)==null||l.updateAttributes(z,ve.cloneDeep(this.authStorage)):z.length===2?(u=this.plugin)==null||u.updateAttributes(z,ve.cloneDeep(B)):z.length===3?(h=this.plugin)==null||h.updateAttributes(z,ve.cloneDeep(B[s])):z.length===4?(d=this.plugin)==null||d.updateAttributes(z,ve.cloneDeep(B[s][o])):(g=this.plugin)==null||g.updateAttributes(z,ve.cloneDeep(X)));return}case yt.renderPage:{if(!s||!o||!(c!=null&&c.render))return;this.authStorage.pageAuth&&this.authStorage.pageAuth[s]&&this.authStorage.pageAuth[s][o]&&c.render!==this.authStorage.pageAuth[s][o].render&&(this.authStorage.pageAuth[s][o].render=c.render,r&&((p=this.plugin)==null||p.updateAttributes([this.authSpace,"pageAuth",s,o,"render"],c.render)));return}case yt.deletePage:{if(!s||!o||!a)return;(j=(x=(D=(I=(v=this.authStorage)==null?void 0:v.pageAuth)==null?void 0:I[s])==null?void 0:D[o])==null?void 0:x.pages)!=null&&j[a]&&(delete this.authStorage.pageAuth[s][o].pages[a],r&&((w=this.plugin)==null||w.updateAttributes([this.authSpace,"pageAuth",s,o,"pages",a],void 0)));return}case yt.clearPage:{if(!s||!o||!a)return;(b=(T=(M=(f=(y=this.authStorage)==null?void 0:y.pageAuth)==null?void 0:f[s])==null?void 0:M[o])==null?void 0:T.pages)!=null&&b[a]&&(delete this.authStorage.pageAuth[s][o].pages[a],r&&((C=this.plugin)==null||C.updateAttributes([this.authSpace,"pageAuth",s,o,"pages",a],{})));return}case yt.addElement:{if(!s||!o||!a||!(c!=null&&c.elementId))return;(N=(V=(O=(E=(P=this.authStorage)==null?void 0:P.pageAuth)==null?void 0:E[s])==null?void 0:O[o])==null?void 0:V.pages)!=null&&N[a]&&(this.authStorage.pageAuth[s][o].pages[a][c.elementId]=!0,r&&((A=this.plugin)==null||A.updateAttributes([this.authSpace,"pageAuth",s,o,"pages",a,c.elementId],!0)));return}case yt.deleteElement:{if(!s||!o||!a||!(c!=null&&c.elementId))return;(L=(ce=(Q=(Z=(U=(k=this.authStorage)==null?void 0:k.pageAuth)==null?void 0:U[s])==null?void 0:Z[o])==null?void 0:Q.pages)==null?void 0:ce[a])!=null&&L[c.elementId]&&(delete this.authStorage.pageAuth[s][o].pages[a][c.elementId],r&&((W=this.plugin)==null||W.updateAttributes([this.authSpace,"pageAuth",s,o,"pages",a,c.elementId],void 0)));return}case yt.clearViewScenePath:{if(!s||!o)return;(ee=($=(H=this.authStorage)==null?void 0:H.pageAuth)==null?void 0:$[s])!=null&&ee[o]&&(delete this.authStorage.pageAuth[s][o],r&&((ie=this.plugin)==null||ie.updateAttributes([this.authSpace,"pageAuth",s,o],void 0)));return}case yt.clearView:{if(!s)return;(pe=(le=this.authStorage)==null?void 0:le.pageAuth)!=null&&pe[s]&&(delete this.authStorage.pageAuth[s],r&&((Te=this.plugin)==null||Te.updateAttributes([this.authSpace,"pageAuth",s],void 0)));return}}}dispatchRenderAuth(e,r=!0){var l,u,h,d,g,p,v,I,D,x,j,w,y,f,M,T,b,C,P,E;const{operation:n,viewId:s,uid:o,renderData:a,isClear:c}=e;if(s)switch(n){case gr.setAuth:{if(!a||a.render===void 0&&a.hide===void 0&&a.clear===void 0){this.authStorage.renderAuth&&this.authStorage.renderAuth[s]&&(delete this.authStorage.renderAuth[s],r&&((l=this.plugin)==null||l.updateAttributes([this.authSpace,"renderAuth",s],void 0)));return}const O=[this.authSpace];Object.keys(this.authStorage).length&&O.push("renderAuth");const V=this.authStorage.renderAuth||{};Object.keys(V).length&&O.push(s),V[s]={},this.authStorage.renderAuth=V;const{render:N,hide:A,clear:k}=a;if(N===!0)V[s].render=!0;else if(ve.isSet(N)){V[s].render={};for(const U of N.keys())V[s].render[U]=!0}if(A===!0)V[s].hide=!0;else if(ve.isSet(A)){V[s].hide={};for(const U of A.keys())V[s].hide[U]=!0}if(k===!0)V[s].clear=!0;else if(ve.isSet(k)){V[s].clear={};for(const U of k.keys())V[s].clear[U]=!0}r&&(O.length===1?(u=this.plugin)==null||u.updateAttributes(O,ve.cloneDeep(this.authStorage)):O.length===2?(h=this.plugin)==null||h.updateAttributes(O,ve.cloneDeep(V)):(d=this.plugin)==null||d.updateAttributes(O,ve.cloneDeep(V[s])));return}case gr.setShow:{if(!o)return;const O=[this.authSpace];Object.keys(this.authStorage).length&&O.push("renderAuth");const V=this.authStorage.renderAuth||{};Object.keys(V).length&&O.push(s),V[s]=V[s]||{},this.authStorage.renderAuth=V,Object.keys(V[s]).length&&O.push("render"),V[s].render=V[s].render||{},V[s].render!==!0&&(Object.keys(V[s].render).length&&O.push(o),V[s].render[o]=!0),V[s].hide!==!0&&((g=V[s].hide)!=null&&g[o])&&(delete V[s].hide[o],r&&((p=this.plugin)==null||p.updateAttributes([this.authSpace,"renderAuth",s,"hide",o],void 0))),r&&(O.length===1?(v=this.plugin)==null||v.updateAttributes(O,ve.cloneDeep(this.authStorage)):O.length===2?(I=this.plugin)==null||I.updateAttributes(O,ve.cloneDeep(V)):O.length===3?(D=this.plugin)==null||D.updateAttributes(O,ve.cloneDeep(V[s])):(x=this.plugin)==null||x.updateAttributes(O,!0));return}case gr.setHide:{if(!o)return;const O=[this.authSpace];Object.keys(this.authStorage).length&&O.push("renderAuth");const V=this.authStorage.renderAuth||{};Object.keys(V).length&&O.push(s),V[s]=V[s]||{},this.authStorage.renderAuth=V,Object.keys(V[s]).length&&O.push("hide"),V[s].hide=V[s].hide||{},V[s].hide!==!0&&(Object.keys(V[s].hide).length&&O.push(o),V[s].hide[o]=!0),V[s].render!==!0&&((j=V[s].render)!=null&&j[o])&&(delete V[s].render[o],r&&((w=this.plugin)==null||w.updateAttributes([this.authSpace,"renderAuth",s,"render",o],void 0))),r&&(O.length===1?(y=this.plugin)==null||y.updateAttributes(O,ve.cloneDeep(this.authStorage)):O.length===2?(f=this.plugin)==null||f.updateAttributes(O,ve.cloneDeep(V)):O.length===3?(M=this.plugin)==null||M.updateAttributes(O,ve.cloneDeep(V[s])):(T=this.plugin)==null||T.updateAttributes(O,!0));return}case gr.setClear:{if(!o)return;const O=[this.authSpace];Object.keys(this.authStorage).length&&O.push("renderAuth");const V=this.authStorage.renderAuth||{};Object.keys(V).length&&O.push(s),V[s]=V[s]||{},this.authStorage.renderAuth=V,Object.keys(V[s]).length&&O.push("clear"),V[s].clear=V[s].clear||{},V[s].clear!==!0&&(Object.keys(V[s].clear).length&&O.push(o),c?V[s].clear[o]=!0:delete V[s].clear[o]),r&&(O.length===1?(b=this.plugin)==null||b.updateAttributes(O,ve.cloneDeep(this.authStorage)):O.length===2?(C=this.plugin)==null||C.updateAttributes(O,ve.cloneDeep(V)):O.length===3?(P=this.plugin)==null||P.updateAttributes(O,ve.cloneDeep(V[s])):(E=this.plugin)==null||E.updateAttributes(O,c?!0:void 0));return}}}addAuthStateListener(e){this.authDisposer=mc(async()=>{const r=this.getAuthSpaceData(),{renderAuth:n,pageAuth:s}=r;let o,a;ve.isEqual(n,this.authStorage.renderAuth)||(o=this.diffAuthFun(this.authStorage.renderAuth||{},n||{}),this.authStorage.renderAuth=n),ve.isEqual(s,this.authStorage.pageAuth)||(a=this.diffAuthPageFun(this.authStorage.pageAuth||{},s||{}),this.authStorage.pageAuth=s),(o||a)&&e(o,a)})}removeAuthStateListener(){this.authDisposer&&this.authDisposer()}diffAuthFun(e,r){const n=ot(e),s=ot(r),o={};for(const a of s)if(!n.includes(a)||e[a]===void 0){o[a]={newValue:r[a],oldValue:void 0};continue}for(const a of n)if(!ve.isEqual(e[a],r[a])){if(!s.includes(a)||r[a]===void 0){o[a]={newValue:void 0,oldValue:e[a]};continue}o[a]={newValue:r[a],oldValue:e[a]}}return o}diffAuthPageFun(e,r){const n=ot(e),s=ot(r),o={};for(const a of s)if(!n.includes(a)||e[a]===void 0){o[a]={newValue:r[a],oldValue:void 0};continue}for(const a of n)if(!ve.isEqual(e[a],r[a])){if(!s.includes(a)||r[a]===void 0){o[a]={newValue:void 0,oldValue:e[a]};continue}o[a]={newValue:r[a],oldValue:e[a]}}return o}};R(Ft,"namespace","PluginState"),R(Ft,"authSpace","PluginAuth"),R(Ft,"globalUndoRedoStackSpace","GlobalUndoRedoStack"),R(Ft,"componentsLimits",[500,1e3]);let Vr=Ft;var er=(i=>(i[i.Draw=1]="Draw",i[i.Delete=2]="Delete",i[i.Update=3]="Update",i))(er||{});class u0e{constructor(){R(this,"roomMembers",[]);R(this,"onChangeHooks",new Set)}setRoomMembers(t){this.executChangeUidHook(this.roomMembers,t),this.roomMembers=t}executChangeUidHook(t,e){const r={online:e.map(n=>{var s;return((s=n.payload)==null?void 0:s.uid)||n.session}),offline:t.map(n=>{var s;return((s=n.payload)==null?void 0:s.uid)||n.session})};this.onChangeHooks.forEach(n=>n(r))}getAllRoomMembers(){return this.roomMembers}getRoomMember(t){return this.roomMembers.find(e=>{var r;return((r=e.payload)==null?void 0:r.uid)===t})}isOnLine(t){return!!this.getRoomMember(t)}onUidChangeHook(t){this.onChangeHooks.add(t)}destroy(){this.onChangeHooks.clear()}}function Yg(i,t,e){var r,n;for(const[s,o]of i.entries())((n=(r=o.roomMember)==null?void 0:r.payload)==null?void 0:n.uid)===t&&s!==e&&i.delete(s)}class h0e{constructor(t){R(this,"expirationTime",He.cursor.expirationTime);R(this,"isEnableCursor");R(this,"internalMsgEmitter");R(this,"publicMsgEmitter");R(this,"control");R(this,"eventName","applianc-cursor");R(this,"displayer");R(this,"roomMember");R(this,"animationId");R(this,"maxLastSyncTime");R(this,"willSendEventWorkers",[]);R(this,"willConsumeEventWorkers",new Map);R(this,"sendEventTimerId");R(this,"animationDrawWorkers",new Map);R(this,"animationEventWorkers",new Map);R(this,"drawActiveUids",new Set);R(this,"cursorInfoMap",new Map);R(this,"doneRenderCursorInfoMap",new Map);const{control:e,internalMsgEmitter:r,publicMsgEmitter:n}=t;this.internalMsgEmitter=r,this.publicMsgEmitter=n,this.expirationTime=ve.isNumber(e.pluginOptions.extras.cursor.expirationTime)?e.pluginOptions.extras.cursor.expirationTime:this.expirationTime,this.control=e,this.roomMember=e.roomMember,this.maxLastSyncTime=this.control.pluginOptions.extras.syncOpt.interval,this.isEnableCursor=this.control.pluginOptions.extras.cursor.enable}activeCollector(){this.control.plugin&&this.isEnableCursor&&(this.displayer=this.control.room||this.control.play,this.displayer.addMagixEventListener(this.eventName,this.mainMagixEventListener.bind(this)))}mainMagixEventListener(t){var a;const{event:e,payload:r}=t;if(e!==this.eventName)return;const{uid:n,op:s,type:o}=r;if(((a=this.control.collector)==null?void 0:a.uid)!==n&&o===Ts.Cursor&&(s!=null&&s.length)){if(this.drawActiveUids.has(n))return;const c=this.willConsumeEventWorkers.get(n)||[];for(const l of s){const{viewId:u}=l;ve.isNumber(l.consumPoint[0])&&ve.isNumber(l.consumPoint[1])&&(l.consumPoint=this.control.viewContainerManager.transformToOriginPoint(l.consumPoint,u)),this.control.renderControl.isFilterCursor(u)&&c.unshift({...l,timestamp:this.control.worker.now})}this.willConsumeEventWorkers.set(n,c),this.runAnimation()}}onFocusViewChange(){this.isEnableCursor&&(this.checkDrawWorks(),this.runAnimation())}updateRoomMembers(t){var r,n;const e=new Set(t.online);for(const s of this.drawActiveUids)e.has(s)||this.drawActiveUids.delete(s);for(const[s,o]of this.cursorInfoMap.entries())if(o){for(const[a,c]of o.entries()){const l=(n=(r=c.roomMember)==null?void 0:r.payload)==null?void 0:n.uid;l&&!e.has(l)&&o.delete(a)}o.size===0&&this.cursorInfoMap.delete(s)}}getKey(t,e){return`${t}${Rt}${e}`}getUidAndviewId(t){const[e,r]=t.split(Rt);return{uid:e,viewId:r}}removeRenderedCursorByUid(t,e){var r,n;for(const[s,o]of this.cursorInfoMap.entries()){if(!o||s===e)continue;let a=!1;for(const[c,l]of o.entries())((n=(r=l.roomMember)==null?void 0:r.payload)==null?void 0:n.uid)===t&&(o.delete(c),a=!0);a&&(o.size===0&&this.cursorInfoMap.delete(s),this.doneRenderCursorInfoMap.delete(s),this.internalMsgEmitter.emit([Fe.Cursor,s],o.size?Array.from(o.values(),c=>({x:c.x,y:c.y,roomMember:c.roomMember})):[]))}}dropAllEventCursor(t){var e,r;this.willConsumeEventWorkers.delete(t),this.animationEventWorkers.delete(t);for(const[n,s]of this.cursorInfoMap.entries()){if(!s)continue;let o=!1;for(const[a,c]of s.entries())c.type===0&&((r=(e=c.roomMember)==null?void 0:e.payload)==null?void 0:r.uid)===t&&(s.delete(a),o=!0);o&&(s.size===0&&this.cursorInfoMap.delete(n),this.doneRenderCursorInfoMap.delete(n),this.internalMsgEmitter.emit([Fe.Cursor,n],s.size?Array.from(s.values(),a=>({x:a.x,y:a.y,roomMember:a.roomMember})):[]))}}runAnimation(){this.animationId||(this.animationId=requestAnimationFrame(this.animationCursor.bind(this)))}checkDrawWorks(){var e;const t=this.control.viewContainerManager.focuedViewId;for(const[r,n]of this.animationDrawWorkers.entries()){const{viewId:s,uid:o}=this.getUidAndviewId(r);o!==((e=this.control.collector)==null?void 0:e.uid)&&s!==t&&n.workState===ge.Done&&(n.consumPoint=[void 0,void 0])}}animationCursor(){var r,n,s,o;this.animationId=void 0;const t=this.control.worker.now;for(const[a,c]of this.animationDrawWorkers.entries()){const{uid:l,viewId:u}=this.getUidAndviewId(a),h=this.roomMember.getRoomMember(l);if(!h){this.animationDrawWorkers.delete(a),this.drawActiveUids.delete(l);continue}const{consumPoint:d,timestamp:g,workState:p,cursorTool:v}=c,I=this.cursorInfoMap.get(u)||new Map;if(d&&ve.isNumber(d[0])&&ve.isNumber(d[1])&&g+this.expirationTime>t){const D=(r=h.payload)==null?void 0:r.uid;D&&(this.removeRenderedCursorByUid(D,u),Yg(I,D,h.memberId)),I.set(h.memberId,{x:d[0],y:d[1],roomMember:h,timestamp:g,type:1,workState:p,cursorTool:v})}else I.delete(h.memberId),this.drawActiveUids.delete(l);I.size?this.cursorInfoMap.set(u,I):this.cursorInfoMap.delete(u),this.animationDrawWorkers.delete(a)}const e=new Set;for(const[a,c]of this.cursorInfoMap.entries())if(c)for(const[l,u]of c.entries())u.type===1&&u.workState!==ge.Done&&e.add(l);else this.cursorInfoMap.delete(a);for(const[a,c]of this.willConsumeEventWorkers.entries()){const l=this.roomMember.getRoomMember(a);if(ve.isNumber(l==null?void 0:l.memberId)&&!e.has(l.memberId)){const u=c.pop();u?this.animationEventWorkers.set(a,u):this.willConsumeEventWorkers.delete(a)}}for(const[a,c]of this.animationEventWorkers.entries()){const l=this.roomMember.getRoomMember(a);if(!l){this.animationEventWorkers.delete(a);continue}const{viewId:u,consumPoint:h,timestamp:d,cursorTool:g}=c,p=this.cursorInfoMap.get(u)||new Map;if(h&&ve.isNumber(h[0])&&ve.isNumber(h[1])&&d+this.expirationTime>t){const v=(n=l.payload)==null?void 0:n.uid;v&&(this.removeRenderedCursorByUid(v,u),Yg(p,v,l.memberId)),p.set(l.memberId,{x:h[0],y:h[1],roomMember:l,timestamp:d,type:0,cursorTool:g})}else p.delete(l.memberId);p.size?this.cursorInfoMap.set(u,p):this.cursorInfoMap.delete(u),this.animationEventWorkers.delete(a)}for(const a of this.doneRenderCursorInfoMap.keys())this.cursorInfoMap.has(a)||(this.doneRenderCursorInfoMap.delete(a),this.internalMsgEmitter.emit([Fe.Cursor,a],[]));for(const[a,c]of this.cursorInfoMap.entries())if(c!=null&&c.size){const l=[];for(const[h,d]of c.entries()){const{timestamp:g,...p}=d;if(g+this.expirationTime>t)l.push(p);else{const v=(o=(s=p.roomMember)==null?void 0:s.payload)==null?void 0:o.uid;v&&p.type===1&&p.workState!==ge.Done&&this.drawActiveUids.delete(v),c.delete(h),c.size===0&&(this.cursorInfoMap.delete(a),this.doneRenderCursorInfoMap.delete(a),this.internalMsgEmitter.emit([Fe.Cursor,a],[]))}}const u=this.doneRenderCursorInfoMap.get(a);ve.isEqual(u,l)||(this.doneRenderCursorInfoMap.set(a,l),this.internalMsgEmitter.emit([Fe.Cursor,a],l))}else this.cursorInfoMap.delete(a),this.doneRenderCursorInfoMap.delete(a),this.internalMsgEmitter.emit([Fe.Cursor,a],[]);(this.willConsumeEventWorkers.size||this.cursorInfoMap.size)&&this.runAnimation()}sendEvent(t,e){var r;if(this.displayer&&Le(this.displayer)){const n=ve.isNumber(t[0])&&ve.isNumber(t[1])&&this.control.viewContainerManager.transformToScenePoint(t,e)||[void 0,void 0];this.willSendEventWorkers.push({consumPoint:n,viewId:e,cursorTool:cc((r=this.control.worker.getCurrentToolsData())==null?void 0:r.toolsType)}),this.sendEventTimerId||(this.sendEventTimerId=setTimeout(()=>{this.dispatchMagixEvent()},this.maxLastSyncTime))}}dispatchMagixEvent(){var t;this.displayer&&Le(this.displayer)&&this.displayer.isWritable&&this.displayer.dispatchMagixEvent(this.eventName,{type:Ts.Cursor,op:ve.cloneDeep(this.willSendEventWorkers),uid:(t=this.control.collector)==null?void 0:t.uid}),this.willSendEventWorkers.length=0,this.sendEventTimerId&&(clearTimeout(this.sendEventTimerId),this.sendEventTimerId=void 0)}collectServiceCursor(t){var a,c,l,u;if(!this.isEnableCursor)return;const{op:e,uid:r,workState:n,viewId:s,cursorTool:o}=t;if(r&&e&&n&&s){const h=this.roomMember.getRoomMember(r);if(!h||r===((a=this.control.collector)==null?void 0:a.uid))return;this.dropAllEventCursor(r),n===ge.Done?this.drawActiveUids.delete(r):this.drawActiveUids.add(r);const d=this.getKey(r,s);let g=[void 0,void 0];if(ve.isNumber(e[0])&&ve.isNumber(e[1])){const[D,x]=this.control.viewContainerManager.transformToOriginPoint(e,s);g=[D,x]}const p=((c=this.animationDrawWorkers.get(d))==null?void 0:c.cursorTool)||((u=(l=this.cursorInfoMap.get(s))==null?void 0:l.get(h.memberId))==null?void 0:u.cursorTool),v=Fpe(o,p)||Ne.pencil,I={consumPoint:g,workState:n,viewId:s,timestamp:this.control.worker.now,cursorTool:v};if(n===ge.Start||n===ge.Done){const D=this.willConsumeEventWorkers.get(r);n===ge.Start&&D&&this.willConsumeEventWorkers.delete(r)}this.animationDrawWorkers.set(d,I),this.runAnimation()}}unabled(){var t;this.displayer&&Le(this.displayer)&&(this.willSendEventWorkers.length=0,this.displayer.dispatchMagixEvent(this.eventName,{type:Ts.Cursor,op:[{viewId:this.control.viewContainerManager.focuedViewId,consumPoint:[void 0,void 0]}],uid:(t=this.control.collector)==null?void 0:t.uid}),this.sendEventTimerId&&(clearTimeout(this.sendEventTimerId),this.sendEventTimerId=void 0)),this.isEnableCursor||this.stopAnimation()}clearViewCursor(t){for(const[e]of this.animationDrawWorkers.entries()){const{viewId:r}=this.getUidAndviewId(e);r===t&&this.animationDrawWorkers.delete(e)}for(const[e,r]of this.willConsumeEventWorkers.entries()){const n=r.filter(s=>s.viewId!==t);n.length?this.willConsumeEventWorkers.set(e,n):this.willConsumeEventWorkers.delete(e)}for(const[e,r]of this.animationEventWorkers.entries())r.viewId===t&&this.animationEventWorkers.delete(e);this.cursorInfoMap.delete(t),this.doneRenderCursorInfoMap.delete(t),this.internalMsgEmitter.emit([Fe.Cursor,t],[])}stopAnimation(){this.animationId!==void 0&&(cancelAnimationFrame(this.animationId),this.animationId=void 0),this.animationDrawWorkers.clear(),this.willConsumeEventWorkers.clear(),this.animationEventWorkers.clear(),this.drawActiveUids.clear(),this.cursorInfoMap.clear(),this.doneRenderCursorInfoMap.clear(),this.willSendEventWorkers.length=0,this.sendEventTimerId!==void 0&&(clearTimeout(this.sendEventTimerId),this.sendEventTimerId=void 0)}destroy(){var t;(t=this.displayer)==null||t.removeMagixEventListener(this.eventName),this.stopAnimation()}}function lu(i,t,e){const r=e(i);return!!t&&!!r&&t===r}function d0e(i,t){return!i.isService||!i.viewId||i.isAllViews?!0:lu(i.viewId,i.scenePath,t)}function f0e(i,t,e){return d0e(i,e)?!i.viewId||i.isAllViews||t(i.viewId)?"dispatch":"pending":"discard"}class g0e{constructor(){R(this,"state","pending");R(this,"waiters",new Set)}wait(t){return this.state==="ready"?Promise.resolve("ready"):this.state==="cancelled"?Promise.resolve("cancelled"):new Promise(e=>{let r;const n=s=>{r&&clearTimeout(r),e(s)};this.waiters.add(n),t!==void 0&&(r=setTimeout(()=>{this.waiters.delete(n),e("timeout")},t))})}begin(){this.state="pending"}markReady(){if(this.state==="ready")return;this.state="ready";const t=[...this.waiters];this.waiters.clear(),t.forEach(e=>e("ready"))}cancel(){this.state="cancelled";const t=[...this.waiters];this.waiters.clear(),t.forEach(e=>e("cancelled"))}}class hr{constructor(){R(this,"activeScenePath");R(this,"activeUndoTickerId");R(this,"forceEndedContext");R(this,"useEmtMsg");R(this,"emtType");R(this,"control");R(this,"mainEngine");R(this,"collectListener",(t,e)=>{const r=t;if(r.workState===ge.Start)this.forceEndedContext=void 0;else if(r.workState===ge.Done&&this.forceEndedContext&&(!this.forceEndedContext.viewId||this.forceEndedContext.viewId===r.viewId)&&(!this.forceEndedContext.scenePath||!r.scenePath||this.forceEndedContext.scenePath===r.scenePath))return;this.collect(t,e)})}static dispatch(t,e,r){var n;(n=Xe.InternalMsgEmitter)==null||n.emit([t,e],r)}get serviceColloctor(){return this.control.collector}registerForMainEngine(t,e){return this.emtType=t,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(t,e){var r,n,s;for(const[o,a]of t)(r=this.mainEngine)==null||r.queryTaskBatchData(a).forEach(c=>{var l;(l=this.mainEngine)==null||l.taskBatchData.delete(c)}),(n=this.mainEngine)==null||n.taskBatchData.add(o);if(e){this.mainEngine.consume();return}(s=this.mainEngine)==null||s.runAnimation()}collectForServiceWorker(t){xr(()=>{t.forEach(e=>{var r;(r=this.serviceColloctor)==null||r.dispatch(e)})},this.mainEngine.maxLastSyncTime,this.control.hasPolyfillMethod("requestIdleCallback"))}async pause(t,e){var r;if(this.lastEmtData){const n=this.lastEmtData;if(t&&n.viewId!==t||e&&this.activeScenePath!==e)return;this.useEmtMsg=!0;const s=this.activeUndoTickerId,o={...n,scenePath:this.activeScenePath||n.scenePath,workState:ge.Done};return await this.collect(o,!0),this.forceEndedContext={viewId:n.viewId,scenePath:o.scenePath},(r=Xe.InternalMsgEmitter)==null||r.emit(Se.ActiveMethod,!1),s}}recover(){var t;this.useEmtMsg&&Xe.InternalMsgEmitter.hasListeners(Se.ActiveMethod)&&((t=Xe.InternalMsgEmitter)==null||t.emit(Se.ActiveMethod,!0))}}function D0(i,t,e){return`${e.isLocalId(i)?i:e.getLocalId(i)}-${t}`}function p0e(i,t,e){const r=new Map,n=[];for(const s of i){const o=D0(s,t,e);r.set(s,o),n.push(o)}return{copyNodeKeyBySourceKey:r,expectedWorkIds:n}}class m0e extends hr{constructor(){super(...arguments);R(this,"lastEmtData");R(this,"emitEventType",Se.CopyNode)}collect(e){var l;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:r,viewId:n,requestId:s}=e,o=this.control.viewContainerManager.getView(n);if(!(o!=null&&o.displayer))return;const a=o.focusScenePath,c=this.mainEngine.now;this.mainEngine.internalMsgEmitter.emit("addUndoTicker",c,n,{render:!0,storage:!0,copyAck:!0,source:$e.AsyncCopyNode});for(const u of r){const h=u.toString(),g=this.serviceColloctor.isLocalId(h)?this.serviceColloctor.transformKey(u):h,p=(l=this.serviceColloctor.getStorageData(n,a))==null?void 0:l[g];if(p){if(u===De){const v=p&&this.copySelector({viewId:n,store:p});v&&this.pasteSelector({...v,viewId:n,scenePath:a,undoTickerId:c,requestId:s});break}if(p.toolsType===K.Text&&p.opt&&p.opt.workState&&p.opt.workState!==ge.Done){const v=p&&this.copyText({viewId:n,store:p});v&&this.pasteText({...v,viewId:n,scenePath:a,key:g,store:p,undoTickerId:c,requestId:s});break}}}}copyText(e){const{viewId:r,store:n}=e,s=this.control.viewContainerManager.getView(r);if(!this.serviceColloctor||!s)return;const o=s==null?void 0:s.cameraOpt,a=o&&[o.centerX,o.centerY],c=n.opt,l=c.boxPoint&&c.boxSize&&[c.boxPoint[0]+c.boxSize[0]/2,c.boxPoint[1]+c.boxSize[1]/2];return{bgCenter:a,textCenter:l}}pasteText(e){var I,D;const{bgCenter:r,textCenter:n,store:s,key:o,viewId:a,scenePath:c,undoTickerId:l,requestId:u}=e,h=this.control.viewContainerManager.getView(a);if(!this.serviceColloctor||!h)return;const d=Math.floor(Math.random()*30+1),g=((I=h.cameraOpt)==null?void 0:I.scale)||1,p=r&&n&&[r[0]-n[0]+d,r[1]-n[1]+d]||[d/g,d/g],v=D0(o,l,this.serviceColloctor);if(s.toolsType===K.Text&&s.opt){const x=s.opt;if(x&&x.boxPoint&&x.text){x.workState=ge.Done;const j=x.boxPoint;x.boxPoint=[Math.round(j[0]+p[0]),Math.round(j[1]+p[1])],x.workState=ge.Done;const w=this.control.viewContainerManager.transformToOriginPoint(x.boxPoint,a);this.control.textEditorManager.createTextForMasterController({workId:v,x:w[0],y:w[1],opt:x,scale:((D=h.cameraOpt)==null?void 0:D.scale)||1,type:vr.Text,isActive:!1,viewId:a,scenePath:c,requestId:u,emitEventType:Se.CopyNode}),this.collectForServiceWorker([{...s,opt:x,type:he.FullWork,workId:v,viewId:a,scenePath:c,needUndoTicker:l,requestId:u,emitEventType:Se.CopyNode}]),l&&this.mainEngine.internalMsgEmitter.emit("finalizeRequested",l,a,[v],c)}}}copySelector(e){var v,I,D,x,j,w,y,f,M;const{viewId:r,store:n}=e,s=this.control.viewContainerManager.getView(r),o=n.selectIds;if(!this.serviceColloctor||!(o!=null&&o.length)||!s)return;const a=new Map,c={offset:{x:0,y:0},cameraOpt:{centerX:((v=s.cameraOpt)==null?void 0:v.centerX)||0,centerY:((I=s.cameraOpt)==null?void 0:I.centerY)||0,scale:((D=s.cameraOpt)==null?void 0:D.scale)||1}},l=this.control.hasOffscreenCanvas&&((x=s.displayer.canvasBgRef.current)==null?void 0:x.getBoundingClientRect())||((j=s.displayer.canvasContainerRef.current)==null?void 0:j.getBoundingClientRect()),u=(y=(w=s.displayer)==null?void 0:w.floatBarRef.current)==null?void 0:y.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&&s.viewData&&s.viewData.convertToPointInWorld({x:h[0],y:h[1]}),p=d&&s.viewData&&s.viewData.convertToPointInWorld({x:d[0],y:d[1]});g&&p&&(c.offset={x:g.x-p.x,y:g.y-p.y});for(const T of o){const b=this.serviceColloctor.isLocalId(T)?this.serviceColloctor.transformKey(T):T,C=(M=(f=this.serviceColloctor)==null?void 0:f.getStorageData(s.id,s.focusScenePath))==null?void 0:M[b];C&&a.set(T,C)}return{copyStores:a,copyCoordInfo:c}}pasteSelector(e){var j,w,y,f;const{copyStores:r,copyCoordInfo:n,viewId:s,scenePath:o,undoTickerId:a,requestId:c}=e,l=this.control.viewContainerManager.getView(s);if(!r.size||!this.serviceColloctor||!l)return;const{offset:u,cameraOpt:h}=n,{scale:d}=h,g=Math.floor(Math.random()*30+1),p=u&&[u.x+g,u.y+g]||[g/d,g/d],v=[],I=[],{copyNodeKeyBySourceKey:D,expectedWorkIds:x}=p0e(r.keys(),a,this.serviceColloctor);a&&x.length&&this.mainEngine.internalMsgEmitter.emit("finalizeRequested",a,s,x,o);for(const[M,T]of r.entries()){const b=D.get(M);if(!b)continue;const C={useAnimation:!1};if(T.toolsType===K.Text&&T.opt){const P=T.opt;if(P&&P.boxPoint&&P.text){P.workState=ge.Done;const E=P.boxPoint;P.boxPoint=[Math.round(E[0]+p[0]),Math.round(E[1]+p[1])],P.workState=ge.Done;const O=this.control.viewContainerManager.transformToOriginPoint(P.boxPoint,s);this.control.textEditorManager.createTextForMasterController({workId:b,x:O[0],y:O[1],opt:P,scale:((j=l.cameraOpt)==null?void 0:j.scale)||1,type:vr.Text,isActive:!1,viewId:s,scenePath:o,requestId:c,emitEventType:Se.CopyNode})}I.push({...T,opt:P,type:he.FullWork,workId:b,viewId:s,scenePath:o,requestId:c,needUndoTicker:a,emitEventType:Se.CopyNode});continue}if((T.toolsType===K.Image||T.toolsType===K.BackgroundSVG)&&(T.opt.uuid=b,T.opt.centerX=T.opt.centerX+p[0],T.opt.centerY=T.opt.centerY+p[1]),T.ops){const P=Nn(T.ops).map((O,V)=>{const N=V%3;return N===0?O+p[0]:N===1?O+p[1]:O}),E=xt(P);T.ops=E}if((w=T==null?void 0:T.opt)!=null&&w.eraserlines&&(y=T==null?void 0:T.opt)!=null&&y.eraserlines.length)for(const P of(f=T==null?void 0:T.opt)==null?void 0:f.eraserlines){const{op:E}=P;for(let O=0;O<E.length;O++){const V=E[O].map((N,A)=>A%2?N+p[1]:N+p[0]);P.op[O]=V}}I.push({...T,updateNodeOpt:C,type:he.FullWork,workId:b,viewId:s,scenePath:o,requestId:c,needUndoTicker:a,emitEventType:Se.CopyNode}),v.push([{...T,updateNodeOpt:C,workId:b,msgType:he.FullWork,dataType:Ee.Local,emitEventType:Se.CopyNode,willSyncService:!1,willRefresh:!0,viewId:s,requestId:c,needUndoTicker:this.control.viewContainerManager.getUndoTickerId(s),isRunBackgroundThread:this.control.isUseBackgroundThread},{workId:b,msgType:he.FullWork,emitEventType:Se.CopyNode}])}v.length&&this.collectForLocalWorker(v),I.length&&this.collectForServiceWorker(I)}}class y0e extends hr{constructor(){super(...arguments);R(this,"lastEmtData");R(this,"emitEventType",Se.SetColorNode);R(this,"undoTickerId")}ensureUndoTicker(e,r,n,s){if(!(n===ge.Start||n===ge.Done&&!this.undoTickerId))return this.undoTickerId;const a=this.mainEngine.now;return this.undoTickerId=a,this.activeUndoTickerId=a,this.mainEngine.internalMsgEmitter.emit("addUndoTicker",a,e,{render:!0,storage:!0,source:$e.MethodSetColorNode}),a}setTextColor(e,r,n,s,o,a){const{fontColor:c,fontBgColor:l}=n;r.opt&&(c&&(r.opt.fontColor=c),l&&(r.opt.fontBgColor=l),this.control.textEditorManager.updateTextForMasterController({workId:e,opt:r.opt,viewId:s,canSync:!0,canWorker:!0,requestId:o,needUndoTicker:a}))}collect(e,r){var f,M;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:n,strokeColor:s,fillColor:o,fontColor:a,fontBgColor:c,viewId:l,workState:u,thickness:h,strokeType:d,requestId:g}=e,p=this.control.viewContainerManager.getView(l);if(!(p!=null&&p.displayer))return;if(u===ge.Start)this.activeScenePath=e.scenePath||p.focusScenePath;else if(u===ge.Doing&&!this.activeScenePath)return;const v=e.scenePath||this.activeScenePath||p.focusScenePath;u!==ge.Done&&(this.lastEmtData={...e,scenePath:v});const I=[...n],D=this.serviceColloctor.storage,x=[],j={},w=this.ensureUndoTicker(l,v,u,n);this.undoTickerId&&(this.control.textEditorManager.UndoTickerId=this.undoTickerId);const y=new Set;for(;I.length;){const T=I.pop();if(!T)continue;const b=T.toString(),C=this.serviceColloctor.isLocalId(b),P=C?this.serviceColloctor.transformKey(T):b;let E=b;!C&&this.serviceColloctor.isOwn(E)&&(E=this.serviceColloctor.getLocalId(E));const O=(M=(f=D==null?void 0:D[l])==null?void 0:f[v])==null?void 0:M[P];if(O){const V=O.updateNodeOpt||{};if(a||c){if(a){V.fontColor=a;const[A,k,U,Z]=ws(a);j.textColor=[A,k,U],j.textOpacity=Z}if(c)if(V.fontBgColor=Uo(c)?"transparent":c,Uo(c))j.textBgColor=void 0,j.textBgOpacity=void 0;else{const[A,k,U,Z]=ws(c);j.textBgColor=[A,k,U],j.textBgOpacity=Z}if(O.toolsType===K.Text&&O.opt&&u!==ge.Start){E&&u===ge.Done&&y.add(E.toString()),this.setTextColor(E,Lt(O),V,l,g,u===ge.Done&&w||void 0);continue}}if(s){V.strokeColor=s;const[A,k,U,Z]=ws(s);j.strokeColor=[A,k,U],j.strokeOpacity=Z}if(o)if(V.fillColor=Uo(o)?"transparent":o,Uo(o))j.fillColor=void 0,j.fillOpacity=void 0;else{const[A,k,U,Z]=ws(o);j.fillColor=[A,k,U],j.fillOpacity=Z}h&&(V.thickness=h,j.strokeWidth=h),d&&(j.strokeType=d,V.strokeType=d,V.lineCap=this.control.getLineCap(d),V.lineDash=this.control.getLineDash(d));const N={workId:E,msgType:he.UpdateNode,dataType:Ee.Local,updateNodeOpt:V,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,textUpdateForWoker:!0,viewId:l,scenePath:v,requestId:g,needUndoTicker:u===ge.Done&&w||void 0};E&&u===ge.Done&&y.add(E.toString()),x.push([N,{workId:E,msgType:he.UpdateNode,emitEventType:this.emitEventType}])}}if(u===ge.Done&&w){const T=[...y];T.length&&this.mainEngine.internalMsgEmitter.emit("finalizeRequested",w,l,T,v)}x.length?(u===ge.Done&&(this.undoTickerId=void 0,this.control.textEditorManager.UndoTickerId=void 0),this.collectForLocalWorker(x,r)):u===ge.Done&&(this.undoTickerId=void 0,this.control.textEditorManager.UndoTickerId=void 0),Object.keys(j).length&&setTimeout(()=>{var T;(T=this.control.room)==null||T.setMemberState(j)},0),u===ge.Done&&(this.lastEmtData=void 0,this.activeScenePath=void 0,this.activeUndoTickerId=void 0)}}class v0e extends hr{constructor(){super(...arguments);R(this,"lastEmtData");R(this,"emitEventType",Se.ZIndexNode);R(this,"zIndexMap",new Map);R(this,"zIndexMapForBackgroundSVG",new Map)}clearZIndex(e){this.zIndexMap.delete(e),this.zIndexMapForBackgroundSVG.delete(e)}getMinZIndex(e){var r;return((r=this.zIndexMap.get(e))==null?void 0:r.min)||0}getMinZIndexForBackgroundSVG(e){var r;return((r=this.zIndexMapForBackgroundSVG.get(e))==null?void 0:r.min)||0}getMaxZIndex(e){var r;return((r=this.zIndexMap.get(e))==null?void 0:r.max)||0}getMaxZIndexForBackgroundSVG(e){var r;return((r=this.zIndexMapForBackgroundSVG.get(e))==null?void 0:r.max)||0}setMaxZIndex(e,r){const n=this.getMinZIndex(r);this.zIndexMap.set(r,{min:n,max:e})}setMaxZIndexForBackgroundSVG(e,r){const n=this.getMinZIndexForBackgroundSVG(r);this.zIndexMapForBackgroundSVG.set(r,{min:n,max:e})}setMinZIndex(e,r){const n=this.getMaxZIndex(r);this.zIndexMap.set(r,{min:e,max:n})}setMinZIndexForBackgroundSVG(e,r){const n=this.getMaxZIndexForBackgroundSVG(r);this.zIndexMapForBackgroundSVG.set(r,{min:e,max:n})}addMaxLayer(e){const r=this.getMaxZIndex(e)+1;this.setMaxZIndex(r,e)}addMaxLayerForBackgroundSVG(e){const r=this.getMaxZIndexForBackgroundSVG(e)+1;this.setMaxZIndexForBackgroundSVG(r,e)}addMinLayer(e){const r=this.getMinZIndex(e)-1;this.setMinZIndex(r,e)}addMinLayerForBackgroundSVG(e){const r=this.getMinZIndexForBackgroundSVG(e)-1;this.setMinZIndexForBackgroundSVG(r,e)}correct(e){const r=e.sort((n,s)=>n[1]-s[1]);for(let n=1;n<r.length;n++){const s=r[n][1],o=r[n-1][1];s<=o&&(r[n][1]=o+1)}return r}collect(e){var I,D;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:r,layer:n,viewId:s,requestId:o}=e,a=this.control.viewContainerManager.getView(s);if(!(a!=null&&a.displayer))return;const c=a.focusScenePath,l=[...r],u=this.serviceColloctor.storage,h=[],d=[],g=[],p=this.mainEngine.now;for(this.mainEngine.internalMsgEmitter.emit("addUndoTicker",p,s,{render:!0,storage:!0,source:$e.AsyncZIndexNode});l.length;){const x=l.pop();if(!x)continue;const j=x.toString(),w=this.serviceColloctor.isLocalId(j),y=w?this.serviceColloctor.transformKey(x):j;let f=j;!w&&this.serviceColloctor.isOwn(f)&&(f=this.serviceColloctor.getLocalId(f));const M=Lt(u[s][c][y]);let T,b;if(M&&f===De){if(M.selectIds){for(const E of M.selectIds){const O=v(E,this.serviceColloctor),V=(D=(I=u==null?void 0:u[s])==null?void 0:I[c])==null?void 0:D[O];V&&V.toolsType===K.BackgroundSVG?(g.push(E),g.sort((N,A)=>{var Z,Q,ce,L;const k=((Q=(Z=u[v(N,this.serviceColloctor)])==null?void 0:Z.opt)==null?void 0:Q.zIndex)||0,U=((L=(ce=u[v(N,this.serviceColloctor)])==null?void 0:ce.opt)==null?void 0:L.zIndex)||0;return k>U?1:N<A?-1:0})):(d.push(E),d.sort((N,A)=>{var Z,Q,ce,L;const k=((Q=(Z=u[v(N,this.serviceColloctor)])==null?void 0:Z.opt)==null?void 0:Q.zIndex)||0,U=((L=(ce=u[v(N,this.serviceColloctor)])==null?void 0:ce.opt)==null?void 0:L.zIndex)||0;return k>U?1:N<A?-1:0}))}const C=M.updateNodeOpt||{};C.zIndexLayer=n;const P={workId:x,msgType:he.UpdateNode,dataType:Ee.Local,updateNodeOpt:C,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:s,requestId:o,needUndoTicker:this.control.viewContainerManager.getUndoTickerId(s)};d.length&&(n===Mn.Top?(this.addMaxLayer(s),T=this.getMaxZIndex(s)):(this.addMinLayer(s),T=this.getMinZIndex(s)),d.forEach(E=>{var A,k,U,Z,Q;const O=(A=this.serviceColloctor)==null?void 0:A.isLocalId(E);let V=O&&((k=this.serviceColloctor)==null?void 0:k.transformKey(E))||E;const N=(Z=(U=u==null?void 0:u[s])==null?void 0:U[c])==null?void 0:Z[V];N&&(!O&&((Q=this.serviceColloctor)!=null&&Q.isOwn(V))&&(V=this.serviceColloctor.getLocalId(V)),C.zIndex=T,N!=null&&N.opt&&(N.opt.zIndex=T))})),g.length&&(n===Mn.Top?(this.addMaxLayerForBackgroundSVG(s),b=this.getMaxZIndexForBackgroundSVG(s)):(this.addMinLayerForBackgroundSVG(s),b=this.getMinZIndexForBackgroundSVG(s)),g.forEach(E=>{var A,k,U,Z,Q;const O=(A=this.serviceColloctor)==null?void 0:A.isLocalId(E);let V=O&&((k=this.serviceColloctor)==null?void 0:k.transformKey(E))||E;const N=(Z=(U=u==null?void 0:u[s])==null?void 0:U[c])==null?void 0:Z[V];N&&(!O&&((Q=this.serviceColloctor)!=null&&Q.isOwn(V))&&(V=this.serviceColloctor.getLocalId(V)),C.zIndexForBackgroundSVG=b,N!=null&&N.opt&&(N.opt.zIndex=b))})),P.willSerializeData=!0,h.push([P,{workId:x,msgType:he.UpdateNode,emitEventType:this.emitEventType}])}continue}}h.length&&(this.mainEngine.internalMsgEmitter.emit("finalizeRequested",p,s,h.map(([x])=>{var j;return(j=x.workId)==null?void 0:j.toString()}).filter(Boolean),c),this.collectForLocalWorker(h));function v(x,j){return j.isLocalId(x)&&j.transformKey(x)||x}}}class M0e extends hr{constructor(){super(...arguments);R(this,"lastEmtData");R(this,"emitEventType",Se.TranslateNode);R(this,"cachePosition")}collect(e,r){var v,I,D;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:n,position:s,workState:o,viewId:a}=e,c=this.control.viewContainerManager.getView(a);if(!(c!=null&&c.displayer))return;if(o===ge.Start)this.activeScenePath=e.scenePath||c.focusScenePath;else if(!this.activeScenePath)return;const l=e.scenePath||this.activeScenePath;this.lastEmtData={...e,scenePath:l};const u=[...n],h=(v=this.serviceColloctor)==null?void 0:v.storage,d=[],g=new Set,p=o===ge.Start&&this.mainEngine.now||void 0;for(p&&(this.activeUndoTickerId=p,this.mainEngine.internalMsgEmitter.emit("addUndoTicker",p,a,{render:!0,storage:!0,isWritable:!0,source:$e.MethodTranslateNode}));u.length;){const x=u.pop();if(!x)continue;const j=x.toString(),w=this.serviceColloctor.isLocalId(j),y=w&&this.serviceColloctor.transformKey(x)||j;let f=j;!w&&this.serviceColloctor.isOwn(f)&&(f=this.serviceColloctor.getLocalId(f));const M=(D=(I=h==null?void 0:h[a])==null?void 0:I[l])==null?void 0:D[y];if(M&&f===De){if(M.selectIds){o===ge.Done&&M.selectIds.forEach(b=>{g.add(b.toString())});const T=this.control.viewContainerManager.transformToScenePoint([s.x,s.y],a);if(o===ge.Start&&(this.cachePosition=T),this.cachePosition){const b=M.updateNodeOpt||{};b.translate=[T[0]-this.cachePosition[0],T[1]-this.cachePosition[1]],b.workState=o,this.control.cursor.isEnableCursor?b.useAnimation=!1:(b.uid=this.serviceColloctor.uid,o===ge.Start?b.useAnimation=!1:o===ge.Done&&(b.useAnimation=!0));const C={workId:x,msgType:he.UpdateNode,dataType:Ee.Local,updateNodeOpt:b,emitEventType:this.emitEventType,willSyncService:!0,textUpdateForWoker:!0,viewId:a,scenePath:l,smoothSync:this.mainEngine.smoothSync};o===ge.Done&&(C.textUpdateForWoker=!0,C.willSerializeData=!0,this.cachePosition=void 0,C.needUndoTicker=this.activeUndoTickerId),d.push([C,{workId:x,msgType:he.UpdateNode,emitEventType:this.emitEventType,workState:o}])}}continue}}if(o===ge.Start?this.mainEngine.unWritable():o===ge.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),d.length){if(o===ge.Done){const x=this.activeUndoTickerId;if(x){const j=[...g];this.mainEngine.internalMsgEmitter.emit("finalizeRequested",x,a,j,l)}}this.collectForLocalWorker(d,r)}o===ge.Done&&(this.activeScenePath=void 0,this.activeUndoTickerId=void 0)}}class w0e extends hr{constructor(){super(...arguments);R(this,"lastEmtData");R(this,"emitEventType",Se.DeleteNode)}collect(e){var g,p;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:r,viewId:n,requestId:s}=e,o=this.control.viewContainerManager.getView(n);if(!(o!=null&&o.displayer))return;const a=o.focusScenePath,c=this.serviceColloctor.storage,l=[...r],u=[],h=[],d=this.mainEngine.now;for(this.control.textEditorManager.UndoTickerId=d;l.length;){const v=l.pop();if(!v)continue;const I=v.toString(),D=this.serviceColloctor.isLocalId(I),x=D?this.serviceColloctor.transformKey(v):I,j=(p=(g=c==null?void 0:c[n])==null?void 0:g[a])==null?void 0:p[x];if(j){let w=I;if(!D&&this.serviceColloctor.isOwn(w)&&(w=this.serviceColloctor.getLocalId(w)),j.toolsType===K.Text){this.control.textEditorManager.delete(w,!0,!0);continue}h.push(w)}}h.length&&(this.mainEngine.internalMsgEmitter.emit("addUndoTicker",d,n,{render:!0,storage:!0,source:$e.AsyncDeleteNode}),this.mainEngine.internalMsgEmitter.emit("finalizeRequested",d,n,h.slice(),a),u.push([{msgType:he.RemoveNode,emitEventType:Se.DeleteNode,removeIds:h,dataType:Ee.Local,willSyncService:!0,willRefresh:!0,viewId:n,requestId:s,isRunBackgroundThread:this.control.isUseBackgroundThread,needUndoTicker:this.control.viewContainerManager.getUndoTickerId(n)},void 0]),this.collectForLocalWorker(u))}}class T0e extends hr{constructor(){super(...arguments);R(this,"lastEmtData");R(this,"emitEventType",Se.ScaleNode);R(this,"targetText",new Map);R(this,"cacheTextInfo",new Map)}async setTextStyle(e,r,n){const s=await this.control.textEditorManager.updateTextControllerWithEffectAsync({workId:e,opt:r,viewId:n,canSync:!1,canWorker:!1});return{key:e,textInfo:s}}async collect(e,r){var x,j,w,y,f,M,T;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:n,workState:s,viewId:o,originPoint:a,scenePoint:c,dir:l,scale:u,translate:h}=e,d=this.control.viewContainerManager.getView(o);if(!(d!=null&&d.displayer))return;if(s===ge.Start)this.activeScenePath=e.scenePath||d.focusScenePath;else if(!this.activeScenePath)return;const g=e.scenePath||this.activeScenePath;this.lastEmtData={...e,scenePath:g};const p=[...n],v=(x=this.serviceColloctor)==null?void 0:x.storage,I=[],D=s===ge.Start&&this.mainEngine.now||void 0;for(D&&(this.activeUndoTickerId=D,this.mainEngine.internalMsgEmitter.emit("addUndoTicker",D,o,{render:!0,storage:!0,isWritable:!0,source:$e.MethodScaleNode}),this.control.textEditorManager.UndoTickerId=D);p.length;){const b=p.pop();if(!b)continue;const C=b.toString(),P=this.serviceColloctor.isLocalId(C),E=P&&this.serviceColloctor.transformKey(b)||C;let O=C;!P&&this.serviceColloctor.isOwn(O)&&(O=this.serviceColloctor.getLocalId(O));const V=(w=(j=v==null?void 0:v[o])==null?void 0:j[g])==null?void 0:w[E];if(V&&O===De&&V.selectIds){const N=V.updateNodeOpt||{};if(N.dir=l,N.originPoint=a,N.scenePoint=c,N.workState=s,N.scale=u,N.translate=h,s===ge.Start){this.cacheTextInfo.clear();for(const k of V.selectIds){const U=(y=this.serviceColloctor)==null?void 0:y.isLocalId(k),Z=U&&((f=this.serviceColloctor)==null?void 0:f.transformKey(k))||k;let Q=Z;!U&&((M=this.serviceColloctor)!=null&&M.isOwn(Z))&&(Q=this.serviceColloctor.getLocalId(Z));const ce=this.control.textEditorManager.get(Q);ce&&s===ge.Start&&this.targetText.set(Q,Lt(ce))}}if(this.targetText.size&&s!==ge.Start&&u){const k=[];for(const[Z,Q]of this.targetText.entries()){const{opt:ce}=Q,L=Math.floor(ce.fontSize*u[0]),W=this.cacheTextInfo.get(Z),H=!W&&ce.fontSize!==L||W&&W.fontSize!==L||!1,$=(T=this.control.textEditorManager.get(Z))==null?void 0:T.opt;if(H&&$&&ce.boxSize&&ce.boxPoint){const ee=this.setTextStyle(Z,{...$,fontSize:L},o);k.push(ee)}}const U=await Promise.all(k);for(const Z of U)if(Z){const{key:Q,textInfo:ce}=Z;this.cacheTextInfo.set(Q,{fontSize:ce.opt.fontSize,boxSize:ce.opt.boxSize,boxPoint:ce.opt.boxPoint})}N.textInfos=this.cacheTextInfo}this.control.cursor.isEnableCursor?N.useAnimation=!1:(N.uid=this.serviceColloctor.uid,s===ge.Start?N.useAnimation=!1:s===ge.Done&&(N.useAnimation=!0));const A={workId:b,msgType:he.UpdateNode,dataType:Ee.Local,updateNodeOpt:N,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:o,scenePath:g,smoothSync:this.mainEngine.smoothSync};s===ge.Done&&(A.willSerializeData=!0,this.targetText.clear(),A.needUndoTicker=this.activeUndoTickerId),I.push([A,{workId:b,msgType:he.UpdateNode,emitEventType:this.emitEventType,workState:s}]);continue}}if(s===ge.Start?this.mainEngine.unWritable():s===ge.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),I.length){if(s===ge.Done){const b=this.activeUndoTickerId;b&&this.mainEngine.internalMsgEmitter.emit("finalizeRequested",b,o,I.map(([C])=>{var P;return(P=C.workId)==null?void 0:P.toString()}).filter(Boolean),g)}this.collectForLocalWorker(I,r)}s===ge.Done&&(this.activeScenePath=void 0,this.activeUndoTickerId=void 0)}}class S0e extends hr{constructor(){super(...arguments);R(this,"lastEmtData");R(this,"emitEventType",Se.RotateNode);R(this,"cacheOriginRotate",0)}collect(e,r){var v,I,D,x,j,w,y;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:n,angle:s,workState:o,viewId:a}=e,c=this.control.viewContainerManager.getView(a);if(!(c!=null&&c.displayer))return;if(o===ge.Start)this.activeScenePath=e.scenePath||c.focusScenePath;else if(!this.activeScenePath)return;const l=e.scenePath||this.activeScenePath;this.lastEmtData={...e,scenePath:l};const u=[...n],h=(v=this.serviceColloctor)==null?void 0:v.storage,d=[],g=new Set,p=o===ge.Start&&this.mainEngine.now||void 0;for(p&&(this.activeUndoTickerId=p,this.mainEngine.internalMsgEmitter.emit("addUndoTicker",p,a,{render:!0,storage:!0,isWritable:!0,source:$e.MethodRotateNode}));u.length;){const f=u.pop();if(!f)continue;const M=f.toString(),T=this.serviceColloctor.isLocalId(M),b=T&&this.serviceColloctor.transformKey(f)||M;let C=M;!T&&this.serviceColloctor.isOwn(C)&&(C=this.serviceColloctor.getLocalId(C));const P=(D=(I=h==null?void 0:h[a])==null?void 0:I[l])==null?void 0:D[b];if(P&&C===De){if(((x=P.selectIds)==null?void 0:x.length)===1){const E=P.selectIds[0];if(o===ge.Done&&g.add(E.toString()),o===ge.Start){const A=((j=this.serviceColloctor)==null?void 0:j.isLocalId(E))&&((w=this.serviceColloctor)==null?void 0:w.transformKey(E))||E,k=h[a][l][A];this.cacheOriginRotate=((y=k==null?void 0:k.opt)==null?void 0:y.rotate)||0}const O=P.updateNodeOpt||{};O.angle=(s+this.cacheOriginRotate)%360,O.workState=o,this.control.cursor.isEnableCursor?O.useAnimation=!1:(O.uid=this.serviceColloctor.uid,o===ge.Start?O.useAnimation=!1:o===ge.Done&&(O.useAnimation=!0));const V={workId:f,msgType:he.UpdateNode,dataType:Ee.Local,updateNodeOpt:O,emitEventType:this.emitEventType,willRefreshSelector:!1,willSyncService:!0,viewId:a,scenePath:l,smoothSync:this.mainEngine.smoothSync};o===ge.Done&&(V.willRefreshSelector=!0,V.willSerializeData=!0,this.cacheOriginRotate=0,V.needUndoTicker=this.activeUndoTickerId),d.push([V,{workId:f,msgType:he.UpdateNode,emitEventType:this.emitEventType,workState:o}])}continue}}if(o===ge.Start?this.mainEngine.unWritable():o===ge.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),d.length){if(o===ge.Done){const f=this.activeUndoTickerId;if(f){const M=[...g];this.mainEngine.internalMsgEmitter.emit("finalizeRequested",f,a,M,l)}}this.collectForLocalWorker(d,r)}o===ge.Done&&(this.activeScenePath=void 0,this.activeUndoTickerId=void 0)}}class I0e extends hr{constructor(){super(...arguments);R(this,"lastEmtData");R(this,"emitEventType",Se.SetFontStyle);R(this,"timerId")}async setTextStyle(e,r,n,s,o,a){const{bold:c,underline:l,lineThrough:u,italic:h,fontSize:d}=n;if(r.toolsType&&$pe(r.toolsType)===vr.Text){r.opt&&(c&&(r.opt.bold=c),ve.isBoolean(l)&&(r.opt.underline=l),ve.isBoolean(u)&&(r.opt.lineThrough=u),h&&(r.opt.italic=h),d&&(r.opt.fontSize=d));const p=await this.control.textEditorManager.updateTextControllerWithEffectAsync({workId:e,opt:r.opt,viewId:s,canSync:!1,canWorker:!1,requestId:o,needUndoTicker:a});return{key:e,textInfo:p}}}async collect(e){var w,y,f,M,T,b;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:r,bold:n,italic:s,lineThrough:o,underline:a,viewId:c,fontSize:l,requestId:u}=e,h=this.control.viewContainerManager.getView(c);if(!(h!=null&&h.displayer))return;const d=h.focusScenePath,g=[...r],p=this.serviceColloctor.storage,v={},I=this.mainEngine.now;this.mainEngine.internalMsgEmitter.emit("addUndoTicker",I,c,{render:!0,storage:!0,source:$e.AsyncSetFontStyle}),this.control.textEditorManager.UndoTickerId=I;const D=[],x=[];for(;g.length;){const C=g.pop();if(!C)continue;const P=C.toString(),E=this.serviceColloctor.isLocalId(P),O=E?this.serviceColloctor.transformKey(C):P;let V=P;!E&&this.serviceColloctor.isOwn(V)&&(V=this.serviceColloctor.getLocalId(V));const N=(y=(w=p==null?void 0:p[c])==null?void 0:w[d])==null?void 0:y[O];if(N){const A=N.updateNodeOpt||{};if(n&&(A.bold=n,v.bold=n==="bold"),s&&(A.italic=s,v.italic=s==="italic"),ve.isBoolean(o)&&(A.lineThrough=o,v.lineThrough=o),ve.isBoolean(a)&&(A.underline=a,v.underline=a),l&&(A.fontSize=l,v.textSize=l),N.toolsType===K.Text&&N.opt){const k=this.setTextStyle(V,ve.cloneDeep(N),A,c,u,I);D.push(V),x.push(k);continue}if(N&&V===De&&((f=N.selectIds)!=null&&f.length))for(const k of N.selectIds){const U=(M=this.serviceColloctor)==null?void 0:M.isLocalId(k);let Z=U&&((T=this.serviceColloctor)==null?void 0:T.transformKey(k))||k;const Q=p[c][d][Z]||void 0;if(!U&&((b=this.serviceColloctor)!=null&&b.isOwn(Z))&&(Z=this.serviceColloctor.getLocalId(Z)),Q&&Q.toolsType===K.Text&&N.opt){const ce=this.setTextStyle(Z,ve.cloneDeep(Q),A,c,u,I);D.push(Z),x.push(ce);continue}}}}const j=await Promise.all(x);for(const C of j)if(C){const{key:P,textInfo:E}=C;E&&(E.canSync=!0,E.canWorker=!0,this.control.textEditorManager.updateForViewEdited(P,E))}Object.keys(v).length&&(this.timerId&&(clearTimeout(this.timerId),this.timerId=void 0),this.timerId=setTimeout(()=>{var C;this.timerId=void 0,(C=this.control.room)==null||C.setMemberState(v)},0)),D.length&&this.mainEngine.internalMsgEmitter.emit("finalizeRequested",I,c,D,d)}}class C0e extends hr{constructor(){super(...arguments);R(this,"lastEmtData");R(this,"emitEventType",Se.SetPoint)}collect(e,r){var j,w,y;if(!this.serviceColloctor||!this.mainEngine)return;const{workId:n,pointMap:s,workState:o,viewId:a}=e,c=this.control.viewContainerManager.getView(a);if(!(c!=null&&c.displayer))return;if(o===ge.Start)this.activeScenePath=e.scenePath||c.focusScenePath;else if(!this.activeScenePath)return;const l=e.scenePath||this.activeScenePath;this.lastEmtData={...e,scenePath:l};const u=(j=this.serviceColloctor)==null?void 0:j.storage,h=[],d=o===ge.Start&&this.mainEngine.now||void 0;d&&(this.activeUndoTickerId=d,this.mainEngine.internalMsgEmitter.emit("addUndoTicker",d,a,{render:!0,storage:!0,isWritable:!0,source:$e.MethodSetPoint}));const g=n;if(!g)return;const p=g.toString(),v=this.serviceColloctor.isLocalId(p),I=v&&this.serviceColloctor.transformKey(g)||p;let D=p;!v&&this.serviceColloctor.isOwn(D)&&(D=this.serviceColloctor.getLocalId(D));const x=(y=(w=u==null?void 0:u[a])==null?void 0:w[l])==null?void 0:y[I];if(x&&D===De&&x.selectIds){const f=x.updateNodeOpt||{};f.pointMap=s,f.workState=o;const M={workId:g,msgType:he.UpdateNode,dataType:Ee.Local,updateNodeOpt:f,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:a,scenePath:l,needUndoTicker:o===ge.Done&&this.activeUndoTickerId||void 0};h.push([M,{workId:g,msgType:he.UpdateNode,emitEventType:this.emitEventType}])}o===ge.Start?this.mainEngine.unWritable():o===ge.Done&&this.mainEngine.abled(),h.length&&(o===ge.Done&&this.activeUndoTickerId&&this.mainEngine.internalMsgEmitter.emit("finalizeRequested",this.activeUndoTickerId,a,h.map(([f])=>{var M;return(M=f.workId)==null?void 0:M.toString()}).filter(Boolean),l),this.collectForLocalWorker(h,r)),o===ge.Done&&(this.lastEmtData=void 0,this.activeScenePath=void 0,this.activeUndoTickerId=void 0)}}class b0e extends hr{constructor(){super(...arguments);R(this,"lastEmtData");R(this,"emitEventType",Se.SetLock)}collect(e){var g,p;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:r,isLocked:n,viewId:s,requestId:o}=e,a=this.control.viewContainerManager.getView(s);if(!(a!=null&&a.displayer))return;const c=a.focusScenePath,l=[...r],u=this.serviceColloctor.storage,h=[],d=this.mainEngine.now;for(this.mainEngine.internalMsgEmitter.emit("addUndoTicker",d,s,{render:!0,storage:!0,source:$e.AsyncSetLock});l.length;){const v=l.pop();if(!v)continue;const I=v.toString(),D=this.serviceColloctor.isLocalId(I),x=D?this.serviceColloctor.transformKey(v):I;let j=I;!D&&this.serviceColloctor.isOwn(j)&&(j=this.serviceColloctor.getLocalId(j));const w=(p=(g=u==null?void 0:u[s])==null?void 0:g[c])==null?void 0:p[x];if(w){const y=w.updateNodeOpt||{};y.isLocked=n;const f={workId:j,msgType:he.UpdateNode,dataType:Ee.Local,updateNodeOpt:y,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,viewId:s,requestId:o,needUndoTicker:this.control.viewContainerManager.getUndoTickerId(s)};h.push([f,{workId:j,msgType:he.UpdateNode,emitEventType:this.emitEventType}])}}h.length&&(this.mainEngine.internalMsgEmitter.emit("finalizeRequested",d,s,h.map(([v])=>{var I;return(I=v.workId)==null?void 0:I.toString()}).filter(Boolean),c),this.collectForLocalWorker(h))}}class x0e extends hr{constructor(){super(...arguments);R(this,"lastEmtData");R(this,"emitEventType",Se.SetShapeOpt)}collect(e){var g,p;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:r,viewId:n,requestId:s,...o}=e,a=this.control.viewContainerManager.getView(n);if(!(a!=null&&a.displayer))return;const c=a.focusScenePath,l=[...r],u=this.serviceColloctor.storage,h=[],d=this.mainEngine.now;for(this.mainEngine.internalMsgEmitter.emit("addUndoTicker",d,n,{render:!0,storage:!0,source:$e.AsyncSetShapeOpt});l.length;){const v=l.pop();if(!v)continue;const I=v.toString(),D=this.serviceColloctor.isLocalId(I),x=D?this.serviceColloctor.transformKey(v):I;let j=I;!D&&this.serviceColloctor.isOwn(j)&&(j=this.serviceColloctor.getLocalId(j));const w=(p=(g=u==null?void 0:u[n])==null?void 0:g[c])==null?void 0:p[x];if(w){const y={...w.updateNodeOpt,...o,willRefresh:!0};if(w&&j===De){const f={workId:j,msgType:he.UpdateNode,dataType:Ee.Local,updateNodeOpt:y,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,viewId:n,requestId:s,needUndoTicker:this.control.viewContainerManager.getUndoTickerId(n)};h.push([f,{workId:j,msgType:he.UpdateNode,emitEventType:this.emitEventType}])}}}h.length&&(this.mainEngine.internalMsgEmitter.emit("finalizeRequested",d,n,h.map(([v])=>{var I;return(I=v.workId)==null?void 0:I.toString()}).filter(Boolean),c),this.collectForLocalWorker(h))}}class We{constructor(t){R(this,"builders",new Map);this.builders=new Map(t.map(e=>[e,this.build(e)]))}build(t){switch(t){case Se.TranslateNode:return new M0e;case Se.ZIndexNode:return new v0e;case Se.CopyNode:return new m0e;case Se.SetColorNode:return new y0e;case Se.DeleteNode:return new w0e;case Se.ScaleNode:return new T0e;case Se.RotateNode:return new S0e;case Se.SetFontStyle:return new I0e;case Se.SetPoint:return new C0e;case Se.SetLock:return new b0e;case Se.SetShapeOpt:return new x0e}}getBuilder(t){return this.builders.get(t)}registerForMainEngine(t,e){return this.builders.forEach(r=>{r&&r.registerForMainEngine(t,e)}),this}destroy(){this.builders.forEach(t=>{t&&t.destroy()}),this.builders.clear()}async pause(){return await Promise.all([...this.builders.values()].map(t=>t==null?void 0:t.pause())),this}async finishActiveContinuousMethods(t,e){const r=[Se.TranslateNode,Se.ScaleNode,Se.RotateNode,Se.SetPoint,Se.SetColorNode];return(await Promise.all(r.map(s=>{var o;return(o=this.builders.get(s))==null?void 0:o.pause(t,e)}))).filter(s=>s!==void 0)}recover(){return this.builders.forEach(t=>{t&&t.recover()}),this}static emitMethod(t,e,r){hr.dispatch(t,e,r)}static activeListener(t){Xe.InternalMsgEmitter.on(Se.ActiveMethod,t)}static unmountActiveListener(t){Xe.InternalMsgEmitter.off(Se.ActiveMethod,t)}}function E0e(i){return i===ze.Stroke?ze.Normal:i}function hi(i){const{pencilOptions:t}=i,e=E0e(t.strokeType);return{strokeColor:t.strokeColor,thickness:t.thickness,isOpacity:t.isOpacity,zIndex:t.zIndex,scale:t.scale,rotate:t.rotate,translate:t.translate,eraserlines:t.eraserlines,strokeType:e,lineCap:e===ze.Normal?void 0:t.lineCap,lineDash:e===ze.Normal?void 0:t.lineDash}}function P0(i){return[i.start[0],i.start[1],0,i.end[0],i.end[1],0]}function dc(i){const{minX:t,minY:e,maxX:r,maxY:n}=i.bbox;return[t,e,0,r,n,0]}function A0e(i){const{minX:t,minY:e,maxX:r,maxY:n}=i.bbox;return[t,e,0,r,e,0,r,n,0,t,n,0]}const N0e=(i,t)=>({toolsType:K.Straight,opt:hi(t),op:P0(i)}),D0e=(i,t)=>({toolsType:K.Arrow,opt:hi(t),op:P0(i)}),P0e=(i,t)=>({toolsType:K.Rectangle,opt:{...hi(t),fillColor:"transparent"},op:A0e(i)}),k0e=(i,t)=>({toolsType:K.Ellipse,opt:{...hi(t),fillColor:"transparent"},op:dc(i)}),L0e=(i,t)=>({toolsType:K.Polygon,opt:{...hi(t),fillColor:"transparent",vertices:3,shapeType:Gt.Triangle},op:dc(i)}),R0e=(i,t)=>({toolsType:K.Polygon,opt:{...hi(t),fillColor:"transparent",vertices:4,shapeType:Gt.Rhombus},op:dc(i)}),O0e=(i,t)=>({toolsType:K.Star,opt:{...hi(t),fillColor:"transparent",vertices:10,innerVerticeStep:2,innerRatio:.4,shapeType:Gt.Pentagram},op:dc(i)}),zn={straight:N0e,arrow:D0e,rectangle:P0e,ellipse:k0e,triangle:L0e,rhombus:R0e,star:O0e};function z0e(i){return xt(i.op)}function In(i){if(!i.length)return i;const[t,e]=i[0],[r,n]=i[i.length-1];return t===r&&e===n?i:[...i,i[0]]}function j0e(i,t){const e=In(i).slice(0,-1),r=(t%e.length+e.length)%e.length;return In(e.slice(r).concat(e.slice(0,r)))}function Bh(i){return[...i].reverse()}function Ii(i,t,e,r,n){const s=[];for(let o=0;o<n;o++){const a=j0e(e,o),c=Bh(a);s.push({id:`${t}-cw-${o}`,semanticKind:i,points:a,threshold:r},{id:`${t}-ccw-${o}`,semanticKind:i,points:c,threshold:r})}return s}function B0e(i,t,e,r){const n=[];return e.forEach((s,o)=>{n.push({id:`${t}-forward-${o}`,semanticKind:i,points:s,threshold:r},{id:`${t}-reverse-${o}`,semanticKind:i,points:Bh(s),threshold:r})}),n}const Gg=[[0,.5],[.25,.5],[.5,.5],[.75,.5],[1,.5]],U0e=[[.05,.5],[.3,.5],[.55,.5],[.78,.5],[1,.5],[.8,.32],[1,.5],[.8,.68]],F0e=[[.05,.5],[.3,.5],[.55,.5],[.78,.5],[1,.5],[.8,.68],[1,.5],[.8,.32]],W0e=In([[.15,.2],[.85,.2],[.85,.8],[.15,.8]]),$0e=In([[.5,.12],[.88,.82],[.12,.82]]),V0e=In([[.5,.08],[.92,.5],[.5,.92],[.08,.5]]),Y0e=In([[.5,.04],[.62,.34],[.95,.36],[.68,.56],[.78,.9],[.5,.7],[.22,.9],[.32,.56],[.05,.36],[.38,.34]]),G0e=In([[.5,.04],[.74,.88],[.08,.34],[.92,.34],[.26,.88]]),H0e=Array.from({length:24},(i,t)=>{const e=Math.PI*2*t/24;return[.5+Math.cos(e)*.42,.5+Math.sin(e)*.3]}),jn=[{id:"straight-base",semanticKind:"straight",points:Gg,threshold:.72},{id:"straight-reverse",semanticKind:"straight",points:Bh(Gg),threshold:.72},...B0e("arrow","arrow",[U0e,F0e],.71),...Ii("rectangle","rectangle",W0e,.68,4),...Ii("ellipse","ellipse",In(H0e),.64,12),...Ii("triangle","triangle",$0e,.68,3),...Ii("rhombus","rhombus",V0e,.66,4),...Ii("star","star",Y0e,.7,5),...Ii("star","pentagram",G0e,.68,5)];function ds(i,t,e,r){const{metrics:n}=t;return n.closureRatio>.24||n.cornerCount<e||n.cornerCount>r?null:i}const Q0e=[{kind:"straight",templates:jn.filter(i=>i.semanticKind==="straight"),postProcessor(i,t){const{metrics:e}=t;return e.bboxDiagonal<8||e.closureRatio<.75||e.straightness<.94&&i.score<.8?null:i},mapper:zn.straight,enabledInV1:!0},{kind:"arrow",templates:jn.filter(i=>i.semanticKind==="arrow"),postProcessor(i,t){const{metrics:e}=t;return e.closureRatio<.12||e.cornerCount<4||e.cornerCount>7||e.straightness>.93?null:i.score>=Math.max(i.threshold,.71)?i:null},mapper:zn.arrow,enabledInV1:!0},{kind:"rectangle",templates:jn.filter(i=>i.semanticKind==="rectangle"),postProcessor(i,t){const e=ds(i,t,4,6);return!e||t.metrics.bboxCornerCloseness>.15||t.metrics.bboxCornerCloseness>=t.metrics.diamondCloseness?null:e},mapper:zn.rectangle,enabledInV1:!0},{kind:"ellipse",templates:jn.filter(i=>i.semanticKind==="ellipse"),postProcessor(i,t){const e=ds(i,t,6,12);return!e||t.metrics.radialVariance>.5?null:e},mapper:zn.ellipse,enabledInV1:!0},{kind:"triangle",templates:jn.filter(i=>i.semanticKind==="triangle"),postProcessor(i,t){return ds(i,t,3,4)},mapper:zn.triangle,enabledInV1:!0},{kind:"rhombus",templates:jn.filter(i=>i.semanticKind==="rhombus"),postProcessor(i,t){const e=ds(i,t,4,5);return!e||t.metrics.diamondCloseness>=t.metrics.bboxCornerCloseness?null:e},mapper:zn.rhombus,enabledInV1:!0},{kind:"star",templates:jn.filter(i=>i.semanticKind==="star"),postProcessor(i,t){const e=i.templateId.startsWith("pentagram"),r=ds(i,t,e?5:8,12);if(!r)return null;if(e){if(t.metrics.bboxCornerCloseness<.22||t.metrics.angleVariance<35)return null}else if(t.metrics.radialVariance<.34)return null;return r},mapper:zn.star,enabledInV1:!0}];function Uh(){return Q0e}const Z0e=64,uu=250;function Yr(i,t){const e=i[0]-t[0],r=i[1]-t[1];return Math.hypot(e,r)}function K0e(i){const t=[];for(const e of i){const r=t[t.length-1];(!r||Yr(r,e)>.5)&&t.push(e)}return t}function k0(i){let t=0;for(let e=1;e<i.length;e++)t+=Yr(i[e-1],i[e]);return t}function L0(i){let t=Number.POSITIVE_INFINITY,e=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,n=Number.NEGATIVE_INFINITY;for(const[s,o]of i)t=Math.min(t,s),e=Math.min(e,o),r=Math.max(r,s),n=Math.max(n,o);return{minX:t,minY:e,maxX:r,maxY:n}}function q0e(i,t=Z0e){if(i.length<=1)return i;const e=k0(i)/Math.max(t-1,1),r=[i[0]];let n=0,s=i[0],o=1;const a=[...i];for(;o<a.length;){const c=a[o],l=Yr(s,c);if(l===0){o++;continue}if(n+l>=e){const u=(e-n)/l,h=[s[0]+u*(c[0]-s[0]),s[1]+u*(c[1]-s[1])];r.push(h),a.splice(o,0,h),n=0,s=h,o++}else n+=l,s=c,o++}for(;r.length<t;)r.push(a[a.length-1]);return r}function fc(i){const t=i.reduce((e,r)=>[e[0]+r[0],e[1]+r[1]],[0,0]);return[t[0]/i.length,t[1]/i.length]}function X0e(i,t){const e=fc(i),r=Math.cos(t),n=Math.sin(t);return i.map(([s,o])=>{const a=s-e[0],c=o-e[1];return[a*r-c*n+e[0],a*n+c*r+e[1]]})}function J0e(i){const t=fc(i);return Math.atan2(t[1]-i[0][1],t[0]-i[0][0])}function _0e(i,t=uu){const e=L0(i),r=Math.max(e.maxX-e.minX,1),n=Math.max(e.maxY-e.minY,1);return i.map(([s,o])=>[(s-e.minX)/r*t,(o-e.minY)/n*t])}function eve(i){const t=fc(i);return i.map(([e,r])=>[e-t[0],r-t[1]])}function R0(i){const t=q0e(i),e=X0e(t,-J0e(t)),r=_0e(e);return eve(r)}function tve(i,t){let e=0;const r=Math.min(i.length,t.length);for(let n=0;n<r;n++)e+=Yr(i[n],t[n]);return e/Math.max(r,1)}function rve(i,t,e){const[r,n]=i,[s,o]=t,[a,c]=e,l=Math.abs((c-o)*r-(a-s)*n+a*o-c*s),u=Math.hypot(c-o,a-s)||1;return l/u}function hu(i,t){if(i.length<=2)return i;let e=0,r=0;for(let o=1;o<i.length-1;o++){const a=rve(i[o],i[0],i[i.length-1]);a>e&&(e=a,r=o)}if(e<=t)return[i[0],i[i.length-1]];const n=hu(i.slice(0,r+1),t),s=hu(i.slice(r),t);return n.slice(0,-1).concat(s)}function nve(i){if(i.length<3)return[];const t=[];for(let e=0;e<i.length;e++){const r=i[(e-1+i.length)%i.length],n=i[e],s=i[(e+1)%i.length],o=[r[0]-n[0],r[1]-n[1]],a=[s[0]-n[0],s[1]-n[1]],c=o[0]*a[0]+o[1]*a[1],l=Math.hypot(o[0],o[1])*Math.hypot(a[0],a[1])||1,u=Math.acos(Math.max(-1,Math.min(1,c/l)));t.push(u*180/Math.PI)}return t}function ive(i){const t=L0(i),e=Math.max(t.maxX-t.minX,1),r=Math.max(t.maxY-t.minY,1),n=Math.hypot(e,r)||1,s=k0(i),o=Yr(i[0],i[i.length-1]),a=Yr(i[0],i[i.length-1]),c=a/n,l=n*.045,h=c<.24&&i.length>2?i.slice(0,Yr(i[0],i[i.length-1])<.5?-1:i.length):i,d=hu(h,l),g=nve(d),p=g.length>0?Math.max(...g.map(M=>Math.abs(M-90))):90,v=d.map(([M,T])=>[(M-t.minX)/e,(T-t.minY)/r]),I=[[0,0],[1,0],[1,1],[0,1]],D=[[.5,0],[1,.5],[.5,1],[0,.5]],x=(M,T)=>M.reduce((b,C)=>{const P=Math.min(...T.map(E=>Yr(C,E)));return b+P},0)/Math.max(M.length,1),j=fc(i),w=i.map(M=>Yr(M,j)),y=w.reduce((M,T)=>M+T,0)/Math.max(w.length,1),f=y>0?w.reduce((M,T)=>M+Math.abs(T-y)/y,0)/Math.max(w.length,1):0;return{bbox:t,metrics:{pathLength:s,chordLength:o,straightness:o/Math.max(s,1),closureDistance:a,closureRatio:c,bboxWidth:e,bboxHeight:r,bboxDiagonal:n,aspectRatio:e/r,cornerCount:Math.max(0,d.length),angleVariance:p,radialVariance:f,bboxCornerCloseness:x(v,I),diamondCloseness:x(v,D)}}}function sve(i){return i.map(t=>({template:t,normalized:R0(t.points)}))}const ove=sve(Uh().flatMap(i=>i.templates));function ave(i){const t=K0e(i.rawPoints);if(t.length<2)return null;const{bbox:e,metrics:r}=ive(t);return{rawPoints:i.rawPoints,points:t,pencilOptions:i.pencilOptions,viewId:i.viewId,scenePath:i.scenePath,start:t[0],end:t[t.length-1],bbox:e,metrics:r}}function cve(i){const t=R0(i.points),e=new Map;for(const{template:r,normalized:n}of ove){const s=tve(t,n),o=Math.max(0,1-s/(.5*Math.sqrt(2*uu*uu))),a={kind:r.semanticKind,templateId:r.id,threshold:r.threshold||.7,distance:s,score:o},c=e.get(r.semanticKind);(!c||a.score>c.score)&&e.set(r.semanticKind,a)}return[...e.values()].sort((r,n)=>n.score-r.score)}function lve(i){const t=Uh(),e=cve(i);if(i.metrics.bboxDiagonal>=8&&i.metrics.straightness>.975&&i.metrics.closureRatio>.75){const n=e.find(s=>s.kind==="straight")||{templateId:"straight-heuristic",score:.99,threshold:.72};return{kind:"straight",score:n.score,threshold:n.threshold,recognized:!0,bbox:i.bbox,start:i.start,end:i.end,points:i.points,templateId:n.templateId,metrics:i.metrics,candidates:e}}for(const n of e){const s=t.find(a=>a.kind===n.kind);if(!s||n.score<n.threshold)continue;const o=s.postProcessor?s.postProcessor(n,i):n;if(o)return{kind:s.kind,score:o.score,threshold:o.threshold,recognized:!0,bbox:i.bbox,start:i.start,end:i.end,points:i.points,templateId:o.templateId,metrics:i.metrics,candidates:e}}const r=e[0];return{kind:"none",score:(r==null?void 0:r.score)||0,threshold:(r==null?void 0:r.threshold)||1,recognized:!1,bbox:i.bbox,start:i.start,end:i.end,points:i.points,templateId:r==null?void 0:r.templateId,metrics:i.metrics,candidates:e}}function uve(i){return ave(i)}function hve(i){return lve(i)}function Hg(i,t){if(!i.recognized||i.kind==="none")return null;const e=Uh().find(r=>r.kind===i.kind);return(e==null?void 0:e.mapper(i,t))||null}const dve="__netless_appliance_plugin_markmap_runtime__";function fve(){return globalThis}function gve(){return fve()[dve]}function pve(){return new Error('Markmap runtime is not registered. Install "markmap-lib", "markmap-view", and "mermaid", then import "@netless/appliance-plugin/markmap" before using insertMarkmap/updateMarkmap.')}function O0(){const i=gve();if(!i)throw pve();return i}const Gn=class Gn{constructor(){R(this,"fontDB");R(this,"FONT_DB_NAME","__APPLIANCE_PLUGIN_FONT_DB");R(this,"FONT_STORE_NAME","fonts");R(this,"FONT_DB_VERSION",1)}static getInstance(){return Gn.instance||(Gn.instance=new Gn),Gn.instance}async initFontDB(){return this.fontDB?this.fontDB:new Promise((t,e)=>{const r=indexedDB.open(this.FONT_DB_NAME,this.FONT_DB_VERSION);r.onerror=()=>{e(new Error(`Failed to open font database: ${r.error}`))},r.onsuccess=()=>{this.fontDB=r.result,t(r.result)},r.onupgradeneeded=n=>{const s=n.target.result;s.objectStoreNames.contains(this.FONT_STORE_NAME)||s.createObjectStore(this.FONT_STORE_NAME,{keyPath:"fontFamily"}).createIndex("url","url",{unique:!1})}})}async getFontFromDB(t,e){try{return this.fontDB||(this.fontDB=await this.initFontDB()),new Promise((r,n)=>{const a=this.fontDB.transaction([this.FONT_STORE_NAME],"readonly").objectStore(this.FONT_STORE_NAME).get(t);a.onsuccess=()=>{a.result&&a.result.buffer&&(!e||a.result.url===e)?r(a.result.buffer):r(null)},a.onerror=()=>{n(a.error)}})}catch(r){return console.error(`Failed to get font from database for ${t}:`,r),null}}async saveFontToDB(t,e,r){try{return this.fontDB||(this.fontDB=await this.initFontDB()),new Promise((n,s)=>{const a=this.fontDB.transaction([this.FONT_STORE_NAME],"readwrite").objectStore(this.FONT_STORE_NAME),c={fontFamily:t,url:e,buffer:r,timestamp:Date.now()},l=a.put(c);l.onsuccess=()=>{n(!0)},l.onerror=()=>{s(l.error)}})}catch(n){return console.error(`Failed to save font to database for ${t}:`,n),!1}}async clearFontCache(){try{return this.fontDB||(this.fontDB=await this.initFontDB()),new Promise((t,e)=>{const s=this.fontDB.transaction([this.FONT_STORE_NAME],"readwrite").objectStore(this.FONT_STORE_NAME).clear();s.onsuccess=()=>{t(!0)},s.onerror=()=>{e(s.error)}})}catch(t){return console.error("Failed to clear font cache:",t),!1}}async getFontCacheStatus(){try{return this.fontDB||(this.fontDB=await this.initFontDB()),new Promise((t,e)=>{const s=this.fontDB.transaction([this.FONT_STORE_NAME],"readonly").objectStore(this.FONT_STORE_NAME).getAll();s.onsuccess=()=>{const o=s.result||[],a=o.reduce((c,l)=>c+(l.buffer?l.buffer.byteLength:0),0);t({count:o.length,totalSize:a})},s.onerror=()=>{e(s.error)}})}catch(t){return console.error("Failed to get font cache status:",t),{count:0,totalSize:0}}}};R(Gn,"instance");let du=Gn;class mve{constructor(t){R(this,"control");R(this,"getFullWorker");R(this,"getSubWorker");R(this,"indexDBUtils",du.getInstance());R(this,"fontFaceWorkerResolveMap",new Map);R(this,"fontFacesLoadingPromise");R(this,"lastFontFacesAlreadyReady",!1);R(this,"fontFaceLoadStateStarted",!1);R(this,"documentFontsReadyLogged",!1);this.control=t.control,this.getFullWorker=t.getFullWorker,this.getSubWorker=t.getSubWorker}destroy(){for(const t of this.fontFaceWorkerResolveMap.values())t.timer&&clearTimeout(t.timer),t.resolve(!1);this.fontFaceWorkerResolveMap.clear(),this.fontFacesLoadingPromise=void 0,this.lastFontFacesAlreadyReady=!1,this.fontFaceLoadStateStarted=!1,this.documentFontsReadyLogged=!1}get Logger(){return this.control.logger}async waitDocumentFontsReady(t){var e;if(!(typeof document>"u"||!((e=document.fonts)!=null&&e.ready)))try{await document.fonts.ready,this.documentFontsReadyLogged||(this.documentFontsReadyLogged=!0,this.Logger.info(`[Appliance]: document fonts ready for ${t}`))}catch(r){this.Logger.warn(`[Appliance]: document fonts ready failed for ${t}: ${(r==null?void 0:r.message)||r}`)}}async clearFontCache(){return await this.indexDBUtils.clearFontCache()}async getFontCacheStatus(){return await this.indexDBUtils.getFontCacheStatus()}createFontFaceRequestId(t){return`${t}-${Date.now()}-${Math.random().toString(16).slice(2)}`}getFontFaceCssValue(t){return`12px "${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}isDocumentFontFaceReady(t){if(typeof document>"u"||!document.fonts)return!1;let e=!1;for(const r of document.fonts)if(r.family===t&&(e=!0,r.status!=="loaded"))return!1;return e&&(!document.fonts.check||document.fonts.check(this.getFontFaceCssValue(t)))}areDocumentFontFacesReady(){return this.control.extendFontFaces.every(t=>this.isDocumentFontFaceReady(t.fontFamily))}resolveFontFaceWorkerRequest(t,e){const r=this.fontFaceWorkerResolveMap.get(t);r&&(r.timer&&clearTimeout(r.timer),this.fontFaceWorkerResolveMap.delete(t),r.resolve(e))}requestFontFaceWorker(t,e,r){const n=e.requestId;return n?new Promise(s=>{const o=setTimeout(()=>{this.Logger.warn(`[Appliance]: font face worker request timeout: ${n}`),this.resolveFontFaceWorkerRequest(n,!1)},this.control.loadFontFacesTimeout);this.fontFaceWorkerResolveMap.set(n,{timer:o,resolve:s}),t.postMessage(new Set([e]),r||[])}):Promise.resolve(!1)}getWorkers(){return[this.getFullWorker(),this.getSubWorker()].filter(Boolean)}async areWorkerFontFacesReady(){if(!this.control.hasOffscreenCanvas)return!0;const t=this.getWorkers();if(!t.length)return!1;const e=this.control.extendFontFaces.map(({fontFamily:n})=>({fontFamily:n}));return(await Promise.all(t.map(n=>this.requestFontFaceWorker(n,{msgType:he.CheckFontFace,dataType:Ee.Local,viewId:"",fontFaces:e,requestId:this.createFontFaceRequestId("check")})))).every(Boolean)}async waitWorkerReadyForFontFaces(){if(!this.control.hasOffscreenCanvas)return!0;const t=()=>this.control.isUseSimple?!!this.getFullWorker():!!this.getFullWorker()&&!!this.getSubWorker();if(t())return!0;const e=Date.now();return new Promise(r=>{const n=()=>{if(t()){r(!0);return}if(Date.now()-e>=this.control.loadFontFacesTimeout){r(!1);return}setTimeout(n,16)};n()})}async getRuntimeFontFacesReadyState(){if(!this.control.hasExtendFontFaces)return{documentReady:!0,workerReady:!0};const t=this.areDocumentFontFacesReady(),e=await this.areWorkerFontFacesReady();return{documentReady:t,workerReady:e}}async loadFontFaceBuffers(){const t=[];for(const e of this.control.extendFontFaces){let r;const n=await this.indexDBUtils.getFontFromDB(e.fontFamily,e.src);n&&n.byteLength>0&&this.validateFontData(new Uint8Array(n))&&(r=n),r||(r=await this.loadFontInMainThread(e.src),r&&r.byteLength>0&&(await this.indexDBUtils.saveFontToDB(e.fontFamily,e.src,r)||this.Logger.warn(`[Appliance]: Failed to save font ${e.fontFamily} to IndexedDB, but continuing with font loading`))),r&&r.byteLength>0?t.push({fontFamily:e.fontFamily,buffer:r}):this.Logger.warn(`[Appliance]: Font ${e.fontFamily} could not be loaded from any source`)}return t}async setDocumentFontFaces(t){if(typeof document>"u"||!document.fonts)return!1;try{for(const{fontFamily:e,buffer:r}of t){if(this.isDocumentFontFaceReady(e))continue;const n=new FontFace(e,r.slice(0));await n.load(),document.fonts.add(n),await n.loaded}return this.areDocumentFontFacesReady()}catch(e){return this.Logger.error(`[Appliance]: set document font faces error: ${(e==null?void 0:e.message)||e}`),!1}}async setWorkerFontFaces(t){if(!this.control.hasOffscreenCanvas)return!0;const e=this.getWorkers();return e.length?(await Promise.all(e.map(n=>{const s=t.map(({fontFamily:o,buffer:a})=>({fontFamily:o,buffer:a.slice(0)}));return this.requestFontFaceWorker(n,{msgType:he.SetFontFace,dataType:Ee.Local,viewId:"",fontBuffers:s,requestId:this.createFontFaceRequestId("set")},s.map(({buffer:o})=>o))}))).every(Boolean)&&await this.areWorkerFontFacesReady():!1}async doLoadFontFaces(t){if(this.lastFontFacesAlreadyReady=!1,!this.control.hasExtendFontFaces)return this.lastFontFacesAlreadyReady=!0,{status:"success"};if(await this.waitDocumentFontsReady("fontFaceLoad"),!await this.waitWorkerReadyForFontFaces())return{status:"timeout"};const e=await this.getRuntimeFontFacesReadyState();if(e.documentReady&&e.workerReady)return this.lastFontFacesAlreadyReady=!0,{status:"success"};t==null||t(),this.Logger.info(`[Appliance]: load font faces ${JSON.stringify(this.control.extendFontFaces)}`);const r=await this.loadFontFaceBuffers();if(r.length!==this.control.extendFontFaces.length)return{status:"error"};const n=e.documentReady||await this.setDocumentFontFaces(r),s=e.workerReady||await this.setWorkerFontFaces(r);return n&&s?(this.Logger.info("[Appliance]: set font faces success"),{status:"success"}):{status:"error"}}getLastFontFacesAlreadyReady(){return this.lastFontFacesAlreadyReady}async loadFontFaces(){if(!this.fontFacesLoadingPromise){this.fontFaceLoadStateStarted=!1;let t=!1;const e=()=>{t||this.fontFaceLoadStateStarted||(this.fontFaceLoadStateStarted=!0,this.control.emitFontFaceLoadState({status:"start"}))},r=new Promise(n=>{setTimeout(()=>{t=!0,n({status:"timeout"})},this.control.loadFontFacesTimeout)});this.fontFacesLoadingPromise=Promise.race([this.doLoadFontFaces(e),r]).then(n=>(this.fontFaceLoadStateStarted&&this.control.emitFontFaceLoadState(n),n.status!=="success"&&(this.fontFacesLoadingPromise=void 0,this.fontFaceLoadStateStarted=!1),n)).catch(n=>{this.Logger.error(`[Appliance]: load font faces error: ${(n==null?void 0:n.message)||n}`);const s={status:"error"};return this.fontFaceLoadStateStarted&&this.control.emitFontFaceLoadState(s),this.fontFacesLoadingPromise=void 0,this.fontFaceLoadStateStarted=!1,s})}return this.fontFacesLoadingPromise}async loadFontInMainThread(t){try{const e=await fetch(t);if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);const r=await e.arrayBuffer();if(!r||r.byteLength===0)throw new Error("Empty font data received");const n=new Uint8Array(r);if(!this.validateFontData(n))throw new Error("Invalid font data format: not a valid font file");return r}catch(e){this.Logger.error(`[Appliance]: Failed to load font from ${t}: ${e instanceof Error?e.message:String(e)}`);return}}validateFontData(t){return t.length<4?!1:t[0]===119&&t[1]===79&&t[2]===70&&t[3]===50||t[0]===119&&t[1]===79&&t[2]===70&&t[3]===70||t[0]===0&&t[1]===1&&t[2]===0&&t[3]===0||t[0]===79&&t[1]===84&&t[2]===84&&t[3]===79||t.length>36&&t[36]===0&&t[37]===1&&t[38]===0&&t[39]===0}handleWorkerMessage(t){const{type:e,requestId:r,setFontFaceResult:n,fontFaceCheckResult:s,failedFonts:o}=t;return e!==he.SetFontFace&&e!==he.CheckFontFace?!1:(e===he.SetFontFace&&(o!=null&&o.length)&&this.Logger.info("[Appliance]: set font face has failed fonts: "+o.join(", ")),r&&this.resolveFontFaceWorkerRequest(r,e===he.CheckFontFace?!!s:!!n&&!(o!=null&&o.length)),!0)}}const yve=new Set([K.Eraser,K.PencilEraser,K.BitMapEraser]),vve=new Set([K.Pencil,K.Arrow,K.Straight,K.Ellipse,K.Rectangle,K.Star,K.Polygon,K.SpeechBalloon]);function Qg(i){return i===K.Pencil?$e.DrawingPencil:i===K.Arrow||i===K.Straight?$e.DrawingArrow:i===K.Eraser?$e.DrawingEraser:i===K.PencilEraser?$e.DrawingPencilEraser:i===K.BitMapEraser?$e.DrawingBitMapEraser:$e.DrawingShape}function Mve(i){switch(i){case $e.DrawingPencil:case $e.DrawingArrow:case $e.DrawingShape:case $e.DrawingEraser:case $e.DrawingPencilEraser:case $e.DrawingBitMapEraser:return{kind:"stop-event"};case $e.MethodTranslateNode:return{kind:"method-pause",emitEventType:Se.TranslateNode};case $e.MethodScaleNode:return{kind:"method-pause",emitEventType:Se.ScaleNode};case $e.MethodRotateNode:return{kind:"method-pause",emitEventType:Se.RotateNode};case $e.MethodSetPoint:return{kind:"method-pause",emitEventType:Se.SetPoint};case $e.MethodSetColorNode:return{kind:"method-pause",emitEventType:Se.SetColorNode};case $e.AsyncCopyNode:case $e.AsyncPasteNode:case $e.AsyncDeleteNode:case $e.AsyncSetFontStyle:case $e.AsyncSetShapeOpt:case $e.AsyncZIndexNode:case $e.AsyncSetLock:case $e.AsyncUpdateElement:case $e.AsyncImage:case $e.AsyncIcon:case $e.AsyncMarkmap:case $e.Text:case $e.Clear:return{kind:"wait-owner"}}}const fs=i=>typeof i=="number"&&yve.has(i),wve=i=>i===he.FullWork||i===he.UpdateNode||i===he.RemoveNode||i===he.DrawWork;class Tve{get now(){var t;return((t=this.control.room)==null?void 0:t.calibrationTimestamp)||Date.now()}get newWorkId(){return this.now.toString()}setCurrentToolsData(t){this.currentToolsData=t}getCurrentToolsData(){return this.currentToolsData}setCurrentLocalWorkData(t){this.currentLocalWorkData=t}getWorkId(){return this.currentLocalWorkData.workId}get workState(){return this.currentLocalWorkData.workState}}class Sve extends Tve{constructor(e){super();R(this,"maxLastSyncTime",He.syncOpt.interval);R(this,"combineUnitTime",He.bezier.combineUnitTime);R(this,"maxCombineEraserTime",He.pencilEraser.maxCombineTime);R(this,"smoothSync",He.syncOpt.smoothSync);R(this,"isActive",!1);R(this,"currentToolsData");R(this,"currentLocalWorkData");R(this,"control");R(this,"internalMsgEmitter");R(this,"publicMsgEmitter");R(this,"taskBatchData",new Set);R(this,"fullWorker");R(this,"subWorker");R(this,"fullWorkerUrl");R(this,"subWorkerUrl");R(this,"methodBuilder");R(this,"zIndexNodeMethod");R(this,"subWorkerDrawCount",0);R(this,"fullWorkerDrawCount",0);R(this,"maxDrawCount",0);R(this,"_consumeCount",0);R(this,"_postCount",0);R(this,"reRenders",new Map);R(this,"localWorkViewId");R(this,"localPointsBatchData",new Map);R(this,"tasksqueue",new Map);R(this,"cameraUpdateStateByView",new Map);R(this,"cameraUpdateEndWaitersByView",new Map);R(this,"cameraTaskSequenceByView",new Map);R(this,"localWorkFinalizeQueue",Promise.resolve());R(this,"operationBarrierQueueByView",new Map);R(this,"cancelledEraseTxnIds",new Set);R(this,"snapshotMap",new Map);R(this,"boundingRectMap",new Map);R(this,"clearAllResolveMap",new Map);R(this,"localEventQueue",Promise.resolve());R(this,"localEventSequence",0);R(this,"queuedLocalEventCount",0);R(this,"activeLocalEvent");R(this,"localDoneWait");R(this,"delayWorkStateToDoneResolve");R(this,"animationId");R(this,"tmpImageConfigMap",new Map);R(this,"mainThread");R(this,"backgroundThreadManager");R(this,"willSelectorWorkId");R(this,"isLockSentEventCursor",!1);R(this,"getVNodeInfoResolveMap",new Map);R(this,"refreshTextRenderResolveMap",new Map);R(this,"fontFaceManager");R(this,"isLocalWorkActive",!1);R(this,"hasMainViewInitAck",!1);R(this,"mainViewInitReady",new g0e);R(this,"serviceSyncReadyViews",new Set);R(this,"mainViewInitAckCallbacks",new Set);R(this,"initAckedViewIds",new Set);R(this,"pendingTransportMessages",new Map);R(this,"isRenderTransportReady",!1);R(this,"renderProbeResolve");R(this,"renderProbeRequestId");R(this,"renderProbeTimer");R(this,"initGeneration",0);R(this,"viewGenerationById",new Map);R(this,"initCameraOptByView",new Map);R(this,"markmapIdResolveMap",new Map);const{control:r,internalMsgEmitter:n,publicMsgEmitter:s}=e;this.control=r,this.maxLastSyncTime=this.control.pluginOptions.extras.syncOpt.interval,this.combineUnitTime=this.control.pluginOptions.extras.bezier.combineUnitTime||this.combineUnitTime,this.smoothSync=ve.isBoolean(this.control.pluginOptions.extras.syncOpt.smoothSync)?this.control.pluginOptions.extras.syncOpt.smoothSync:this.smoothSync,this.maxCombineEraserTime=this.control.pluginOptions.extras.pencilEraser.maxCombineTime||this.maxCombineEraserTime,this.fullWorkerUrl=this.control.pluginOptions.cdn.fullWorkerUrl||"",this.subWorkerUrl=this.control.pluginOptions.cdn.subWorkerUrl||"",this.internalMsgEmitter=n,this.publicMsgEmitter=s,this.currentLocalWorkData={workState:ge.Pending},this.fontFaceManager=new mve({control:this.control,getFullWorker:()=>this.fullWorker,getSubWorker:()=>this.subWorker})}get isBezier(){return this.control.pluginOptions.extras.bezier.enable}get Logger(){return this.control.logger}afterMainViewInitAck(e){if(this.hasMainViewInitAck){window.setTimeout(()=>{try{e()}catch{}},0);return}this.mainViewInitAckCallbacks.add(e)}get isMainViewInitAck(){return this.hasMainViewInitAck}waitForMainViewInitAck(e=6e4){return this.mainViewInitReady.wait(e)}isViewInitAck(e){return this.initAckedViewIds.has(e)}ackMainViewInit(e,r){var a;if(r!==void 0&&this.viewGenerationById.get(e)!==r||this.initAckedViewIds.has(e))return;this.initAckedViewIds.add(e),this.Logger.info(`[Appliance]: [render-init] stage=acked viewId=${e}`),e===Ue&&!this.hasMainViewInitAck&&(this.hasMainViewInitAck=!0,this.mainViewInitReady.markReady());const n=this.initCameraOptByView.get(e),s=(a=this.viewContainerManager.getView(e))==null?void 0:a.cameraOpt;if(this.initCameraOptByView.delete(e),n&&s&&!this.isSameCameraOpt(n,s)&&this.updateCamera(e,s),this.pullLatestServiceDataAfterInit(e),this.serviceSyncReadyViews.add(e),this.taskBatchData.size&&this.runAnimation(),e!==Ue)return;const o=[...this.mainViewInitAckCallbacks];this.mainViewInitAckCallbacks.clear();for(const c of o)window.setTimeout(()=>{try{c()}catch{}},0)}flushPendingTransportInitMessages(){if(!this.isRenderTransportReady)return;const e=new Set;for(const[r,n]of this.pendingTransportMessages)e.add(n),this.pendingTransportMessages.delete(r);if(e.size){for(const r of e)this.Logger.info(`[Appliance]: [render-init] stage=sent viewId=${r.viewId}`);e.size&&this.dispatchMessages(e)}}getPendingInitMessageKey(e){return`${e.msgType}:${e.viewId}:${e.scenePath||""}`}pullLatestServiceDataAfterInit(e){const r=this.viewContainerManager.getView(e);r!=null&&r.focusScenePath&&this.pullServiceData(r.id,r.focusScenePath,{isAsync:!1,useAnimation:!1})}assertMarkmapRuntimeRegistered(e,r){try{O0()}catch(n){const s=n instanceof Error?n.message:String(n);throw this.Logger.error(`[Appliance]: [markmap] ${e} failed: ${s}; viewId=${r}`),n}}destroy(e=!1){var r,n,s,o,a,c;this.initGeneration++,this.renderProbeTimer&&clearTimeout(this.renderProbeTimer),this.renderProbeTimer=void 0,this.renderProbeRequestId=void 0,(r=this.renderProbeResolve)==null||r.call(this,!1),this.renderProbeResolve=void 0,this.hasMainViewInitAck=!1,e||this.mainViewInitReady.cancel(),this.serviceSyncReadyViews.clear(),this.initAckedViewIds.clear(),this.pendingTransportMessages.clear(),this.isRenderTransportReady=!1,this.initCameraOptByView.clear(),this.mainViewInitAckCallbacks.clear(),(n=this.methodBuilder)==null||n.destroy(),this.unWritable(),this.destroyTaskQueue(),this.taskBatchData.clear(),this.cameraUpdateStateByView.clear(),this.cameraTaskSequenceByView.clear(),this.operationBarrierQueueByView.clear(),this.cameraUpdateEndWaitersByView.forEach(l=>{l.forEach(u=>u())}),this.cameraUpdateEndWaitersByView.clear(),this.tmpImageConfigMap.clear(),this.localPointsBatchData.clear(),this.isActive=!1,this.clearAllResolveMap.clear(),this.snapshotMap.clear(),this.boundingRectMap.clear(),this.refreshTextRenderResolveMap.forEach(({timer:l,resolve:u})=>{l&&clearTimeout(l),u==null||u(!1)}),this.refreshTextRenderResolveMap.clear(),this.fontFaceManager.destroy(),(s=this.mainThread)==null||s.destroy(),this.mainThread=void 0,(o=this.backgroundThreadManager)==null||o.destroy(),this.backgroundThreadManager=void 0,(a=this.fullWorker)==null||a.terminate(),this.fullWorker=void 0,(c=this.subWorker)==null||c.terminate(),this.subWorker=void 0}get consumeCount(){return this._consumeCount}set consumeCount(e){this._consumeCount=e}acceptConsumeAck(e,r){if(!ve.isNumber(e)||r&&!Array.from(this.localPointsBatchData.keys()).some(s=>s.toString()===r))return!1;const n=Math.max(this.consumeCount,e);return n===this.consumeCount?!1:(this.consumeCount=n,this.runAnimation(),!0)}get postCount(){return this._postCount}isServiceSyncReady(e){return this.serviceSyncReadyViews.has(e)}set postCount(e){this._postCount=e}get viewContainerManager(){return this.control.viewContainerManager}get collector(){return this.control.collector}get isRunSubWork(){var r;const e=(r=this.currentToolsData)==null?void 0:r.toolsType;return e===K.Pencil||e===K.PencilEraser||e===K.BitMapEraser||e===K.LaserPen||e===K.Arrow||e===K.Straight||e===K.Ellipse||e===K.Rectangle||e===K.Star||e===K.Polygon||e===K.SpeechBalloon||e===K.Selector}get isCanDrawWork(){var r;const e=(r=this.currentToolsData)==null?void 0:r.toolsType;return e===K.Pencil||e===K.LaserPen||e===K.Arrow||e===K.Straight||e===K.Ellipse||e===K.Rectangle||e===K.Star||e===K.Polygon||e===K.SpeechBalloon||e===K.Triangle||e===K.Rhombus||e===K.BitMapEraser||e===K.PencilEraser}get isUseZIndex(){var r;const e=(r=this.currentToolsData)==null?void 0:r.toolsType;return e===K.Pencil||e===K.Arrow||e===K.Straight||e===K.Ellipse||e===K.Rectangle||e===K.Star||e===K.Polygon||e===K.SpeechBalloon||e===K.Text||e===K.Image}get isCanRecordUndoRedo(){var r;const e=(r=this.currentToolsData)==null?void 0:r.toolsType;return e===K.Pencil||e===K.Eraser||e===K.PencilEraser||e===K.BitMapEraser||e===K.Arrow||e===K.Straight||e===K.Ellipse||e===K.Rectangle||e===K.Star||e===K.Polygon||e===K.SpeechBalloon||e===K.Text||e===K.Image}get isCanSentCursor(){var r;const e=(r=this.currentToolsData)==null?void 0:r.toolsType;return e===K.Pencil||e===K.Text||e===K.LaserPen||e===K.Arrow||e===K.Straight||e===K.Ellipse||e===K.Rectangle||e===K.Star||e===K.Polygon||e===K.SpeechBalloon||e===K.Triangle||e===K.Rhombus||e===K.Eraser||e===K.PencilEraser||e===K.BitMapEraser||e===K.Selector||e===K.Clicker}get isPostCountType(){var r;const e=(r=this.currentToolsData)==null?void 0:r.toolsType;return e===K.Pencil||e===K.Arrow||e===K.Straight||e===K.Ellipse||e===K.Rectangle||e===K.Star||e===K.Polygon||e===K.SpeechBalloon||e===K.Triangle||e===K.Rhombus||e===K.Eraser||e===K.PencilEraser||e===K.BitMapEraser||e===K.Selector}get isCanPostDraw(){var r;const e=(r=this.currentToolsData)==null?void 0:r.toolsType;return e===K.Pencil||e===K.PencilEraser||e===K.BitMapEraser}get isCanStartEventConsum(){var r;const e=(r=this.currentToolsData)==null?void 0:r.toolsType;return e===K.Selector||e===K.Eraser||e===K.PencilEraser||e===K.BitMapEraser}async init(){this.destroy(!0),this.mainViewInitReady.begin(),this.control.emitInitLoadingChange({loading:!0,phase:"worker",status:"start"});try{this.Logger.info(`[Appliance]: [plugin-options] ${JSON.stringify(this.control.pluginOptions.extras)}`)}catch(e){this.Logger.warn(`[Appliance]: [plugin-options] stringify failed: ${(e==null?void 0:e.message)||e}`)}try{if(await this.on()===!1)return;this.internalMsgEmitterListener(),this.isActive=!0,this.control.emitInitLoadingChange({loading:!0,phase:"worker",status:"success"})}catch(e){throw this.mainViewInitReady.cancel(),this.control.emitInitLoadingChange({loading:!1,phase:"worker",status:"error"}),e}}async useBackgroundThread(){this.Logger.info("[Appliance]: use background thread");const{BackgroundThreadManagerImpl:e}=await Promise.resolve().then(()=>require("./index-SwxjyKCD.js"));this.backgroundThreadManager=new e(this)}async useMainThread(){this.Logger.info("[Appliance]: no OffscreenCanvas");const{MainThreadManagerImpl:e}=await Promise.resolve().then(()=>require("./index-C4uTXXaR.js"));this.mainThread=new e(this),this.isRenderTransportReady=!0,this.flushPendingTransportInitMessages()}async on(){var r;const e=++this.initGeneration;if(await this.fontFaceManager.waitDocumentFontsReady("init"),e!==this.initGeneration)return!1;if(this.control.isUseBackgroundThread&&await this.useBackgroundThread(),!this.control.hasOffscreenCanvas){await this.useMainThread(),this.control.logFinalRenderDecision();return}if(!this.fullWorkerUrl||!this.subWorkerUrl)throw new Error("[Appliance]: no worker url config");if(this.fullWorker=new Worker(this.fullWorkerUrl,{type:"classic"}),this.control.isUseSimple||(this.subWorker=new Worker(this.subWorkerUrl,{type:"classic"})),this.fullWorker.onmessage=n=>{var s;if(n.data){const o=n.data;if(o.type===he.ProbeRenderCapabilities){if(o.requestId!==this.renderProbeRequestId)return;const D=o.workerCapabilities,x=(D==null?void 0:D.offscreenCanvas)===!0&&D.contextSupported===!0;this.control.applyWorkerRenderProbe(x),(s=this.renderProbeResolve)==null||s.call(this,x),this.renderProbeResolve=void 0;return}const{render:a,sp:c,fullWorkerDrawCount:l,workerTasksqueueCount:u,cameraTaskId:h,cameraSettledTaskId:d,viewId:g,consumeCount:p,consumeWorkId:v}=n.data;if(this.acceptConsumeAck(p,v),g&&ve.isNumber(h)&&this.ackCameraTask(g,h),g&&ve.isNumber(d)?this.ackCameraSettledTask(g,d):this.isBusy&&u&&this.setWorkerTasksqueueCount(u),c!=null&&c.length&&this.collectorSyncData(c),this.control.isUseSimple){if(this.control.isUseOffscreenTransfer)return;a&&(a!=null&&a.length)&&this.viewContainerManager.render(a);return}const I=(a==null?void 0:a.length)&&a||[];if(l&&g){if(this.fullWorkerDrawCount=l,this.fullWorkerDrawCount<1/0){const D=Math.max(this.maxDrawCount,this.fullWorkerDrawCount);this.setMaxDrawCount(D),this.clearReRenders(this.fullWorkerDrawCount)}else this.setMaxDrawCount(0),this.clearReRenders(1/0);if(this.reRenders.size)for(const D of this.reRenders.values())I.push(...D)}I.length&&this.viewContainerManager.render(I)}},this.control.pluginOptions.extras.useWorker==="auto"){const n=await new Promise(s=>{this.renderProbeResolve=s,this.renderProbeRequestId=`render-probe-${Date.now()}-${Math.random()}`,this.renderProbeTimer=setTimeout(()=>{this.renderProbeResolve===s&&(this.renderProbeResolve=void 0,this.renderProbeTimer=void 0,s(!1))},3e3),this.fullWorker.postMessage(new Set([{msgType:he.ProbeRenderCapabilities,type:he.ProbeRenderCapabilities,requestId:this.renderProbeRequestId,requestedContextType:this.control.renderingCompatibilityDecision.contextType}]))});if(e!==this.initGeneration)return!1;if(!n){this.fullWorker.terminate(),(r=this.subWorker)==null||r.terminate(),this.fullWorker=void 0,this.subWorker=void 0,this.control.renderMode="main-thread",await this.useMainThread(),this.control.logFinalRenderDecision();return}}else this.control.logFinalRenderDecision();this.isRenderTransportReady=!0,this.flushPendingTransportInitMessages(),this.subWorker&&(this.subWorker.onmessage=n=>{if(n.data){const{render:s,sp:o,subWorkerDrawCount:a,consumeCount:c,consumeWorkId:l}=n.data;this.acceptConsumeAck(c,l),o!=null&&o.length&&this.collectorSyncData(o);const u=(s==null?void 0:s.length)&&s||[];if(ve.isNumber(a)){if(this.subWorkerDrawCount=a,this.fullWorkerDrawCount<1/0){const h=Math.max(this.maxDrawCount,this.subWorkerDrawCount);this.setMaxDrawCount(h)}if(s!=null&&s.length)if(this.subWorkerDrawCount>this.fullWorkerDrawCount){const h=[];for(const d of s)d.imageBitmap&&(d.isUnClose=!0,h.push(d));this.reRenders.set(this.subWorkerDrawCount,h)}else this.reRenders.size&&this.clearReRenders(this.subWorkerDrawCount)}u.length&&this.viewContainerManager.render(u)}})}async clearFontCache(){return await this.fontFaceManager.clearFontCache()}async getFontCacheStatus(){return await this.fontFaceManager.getFontCacheStatus()}getLastFontFacesAlreadyReady(){return this.fontFaceManager.getLastFontFacesAlreadyReady()}async loadFontFaces(){return await this.fontFaceManager.loadFontFaces()}createInternalRequestId(e){return`${e}_${this.now}_${Math.random().toString(36).slice(2)}`}waitRefreshTextRender(e){return new Promise(r=>{const n=setTimeout(()=>{this.refreshTextRenderResolveMap.delete(e),r(!1)},5e3);this.refreshTextRenderResolveMap.set(e,{timer:n,resolve:r})})}resolveRefreshTextRender(e,r=!0){var s;if(!e)return;const n=this.refreshTextRenderResolveMap.get(e);n&&(n.timer&&clearTimeout(n.timer),(s=n.resolve)==null||s.call(n,r),this.refreshTextRenderResolveMap.delete(e))}async refreshTextRenderForWorker(e){if(!e.length)return!0;const r=new Set,n=[];for(const o of e){if(!o.viewId||!this.isViewInitAck(o.viewId))continue;const a=this.createInternalRequestId("refresh_text_render");n.push(this.waitRefreshTextRender(a)),r.add({...o,requestId:a,msgType:he.UpdateNode,type:he.UpdateNode,dataType:Ee.Service,toolsType:K.Text,refreshTextRender:!0,useAnimation:!1,willRefresh:!0})}return this.post(r),(await Promise.all(n)).every(Boolean)}buildPropertyAppliedData(e,r,n){switch(e){case Se.SetColorNode:return{strokeColor:r==null?void 0:r.strokeColor,fillColor:r==null?void 0:r.fillColor,fontColor:r==null?void 0:r.fontColor,fontBgColor:r==null?void 0:r.fontBgColor,thickness:r==null?void 0:r.thickness,strokeType:r==null?void 0:r.strokeType};case Se.SetFontStyle:return{fontSize:r==null?void 0:r.fontSize,bold:r==null?void 0:r.bold,italic:r==null?void 0:r.italic,underline:r==null?void 0:r.underline,lineThrough:r==null?void 0:r.lineThrough};case Se.SetLock:return{isLocked:n==null?void 0:n.isLocked};case Se.SetShapeOpt:return{vertices:r==null?void 0:r.vertices,innerVerticeStep:r==null?void 0:r.innerVerticeStep,innerRatio:r==null?void 0:r.innerRatio,placement:r==null?void 0:r.placement};case Se.ZIndexNode:return{zIndexLayer:n==null?void 0:n.zIndexLayer};default:return{}}}clearReRenders(e=1/0){for(const r of this.reRenders.keys())if(ve.isNumber(Number(r))&&Number(r)<=e){const n=this.reRenders.get(Number(r));n==null||n.forEach(s=>{var o;(o=s.imageBitmap)==null||o.close()}),this.reRenders.delete(r)}}get isBusy(){return this.cameraUpdateStateByView.size>0}isViewBusy(e){var r;return((r=this.cameraUpdateStateByView.get(e))==null?void 0:r.isBusy)===!0||this.control.isClearBusy(e)}getLockSentEventCursor(){return this.isLockSentEventCursor}setLockSentEventCursor(e){this.isLockSentEventCursor=e}getTasksqueueState(){return this.isBusy&&ge.Doing||ge.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){ve.isNumber(e)}collectorSyncData(e){var n,s,o,a,c,l,u,h,d,g,p,v,I,D,x;let r=!1;for(const j of e){if(lge(this.cancelledEraseTxnIds,j.eraseTxnId)||this.fontFaceManager.handleWorkerMessage(j))continue;const{type:w,selectIds:y,opt:f,selectRect:M,strokeColor:T,fillColor:b,willSyncService:C,isSync:P,imageBitmap:E,canvasHeight:O,canvasWidth:V,rect:N,op:A,canTextEdit:k,points:U,selectorColor:Z,canRotate:Q,scaleType:ce,textOpt:L,toolsType:W,workId:H,viewId:$,dataType:ee,canLock:ie,isLocked:le,shapeOpt:pe,toolsTypes:Te,thickness:z,strokeType:B,useStroke:X,isgl:ae,imageSrc:q,isSubWorker:te,updateNodeOpt:m,emitEventType:S,requestId:F,reportString:Y,index:_,imageElement:re,workState:ne,isSelecting:J,needUndoTicker:se}=j;if(w===he.Init&&$){this.ackMainViewInit($,j.viewGeneration);continue}if(!$)return;const ue=j.scenePath||this.viewContainerManager.getCurScenePath($);switch(w){case he.RefreshTextRender:this.resolveRefreshTextRender(F,!0);break;case he.SelectorTransform:{if(S&&ne)try{(n=this.control.selectorApi)==null||n.onSelectorTransform({viewId:$,emitEventType:S,workState:ne})}catch(oe){(o=(s=this.Logger)==null?void 0:s.error)==null||o.call(s,`[Appliance]: [selector] onSelectorTransform failed: ${oe==null?void 0:oe.message}`)}break}case he.Select:{const oe=y!=null&&y.length?{...M,selectIds:y,canvasHeight:O,canvasWidth:V,points:U}:void 0;if(oe&&(f!=null&&f.strokeColor)&&(oe.selectorColor=f.strokeColor),oe&&Z&&(oe.selectorColor=Z),oe&&T&&(oe.strokeColor=T),oe&&(f!=null&&f.fillColor)&&(oe.fillColor=f.fillColor),oe&&b&&(oe.fillColor=b),oe&&ve.isBoolean(Q)&&(oe.canRotate=Q),oe&&ce&&(oe.scaleType=ce),oe&&k&&(oe.canTextEdit=k),oe&&L&&(oe.textOpt=L),oe&&ve.isBoolean(ie)&&(oe.canLock=ie),oe&&ve.isBoolean(le)&&(oe.isLocked=le),oe&&pe&&(oe.shapeOpt=pe),oe&&Te&&(oe.toolsTypes=Te),oe&&z&&(oe.thickness=z),oe&&B&&(oe.strokeType=B),oe&&ve.isBoolean(X)&&(oe.useStroke=X),$&&this.viewContainerManager.showFloatBar($,!!oe,oe),C&&((a=this.collector)==null||a.dispatch({type:w,selectIds:y,opt:f,isSync:P,viewId:$,scenePath:ue,needUndoTicker:se,requestId:F,emitEventType:S})),J)break;try{(c=this.control.selectorApi)==null||c.onSelectorSync({viewId:$,scenePath:ue,selectIds:y,selectRect:M,selectorInfo:oe})}catch(de){(u=(l=this.Logger)==null?void 0:l.error)==null||u.call(l,`[Appliance]: [selector] onSelectorSync failed: ${de==null?void 0:de.message}`)}break}case he.Snapshot:if((E||re)&&ue){const oe=this.snapshotMap.get(ue);if(oe){const{resolve:de,value:me}=oe;if(me&&de){const ye=_||0;me[ye]=E||re,me.every(be=>be!==void 0)&&de(me)}}}break;case he.BoundingBox:if(N&&ue){const oe=this.boundingRectMap.get(ue);oe&&oe(N)}break;case he.Cursor:A&&this.control.cursor.collectServiceCursor({...j});break;case he.Clear:if($){this.viewContainerManager.showFloatBar($,!1);const oe=(h=this.clearAllResolveMap.get($))==null?void 0:h.resolve;oe&&oe($);try{(d=this.control.selectorApi)==null||d.onSelectorCleared({viewId:$,scenePath:ue})}catch(de){(p=(g=this.Logger)==null?void 0:g.error)==null||p.call(g,`[Appliance]: [selector] onSelectorCleared failed: ${de==null?void 0:de.message}`)}}break;case he.BackgroundSVGDelete:this.backgroundThreadManager&&$&&this.backgroundThreadManager.consumeTargetOne($,{...j,msgType:he.BackgroundSVGDelete,viewId:$,dataType:Ee.Local});break;case he.BackgroundSVGUpdate:this.backgroundThreadManager&&$&&this.backgroundThreadManager.consumeTargetOne($,{...j,msgType:he.BackgroundSVGUpdate,viewId:$,dataType:Ee.Local});break;case he.TextUpdate:if(W===K.Text&&H&&$){const oe=S===Se.TranslateNode;S&&[Se.SetColorNode,Se.SetFontStyle,Se.SetLock,Se.SetShapeOpt,Se.ZIndexNode].includes(S)&&((v=this.control.selectorApi)==null||v.onPropertyApplied({type:S,viewId:$,scenePath:ue,requestId:F,data:this.buildPropertyAppliedData(S,f,m)}));const de=this.viewContainerManager.transformToOriginPoint((f==null?void 0:f.boxPoint)||[0,0],$),me=(f==null?void 0:f.boxSize)||[0,0],ye=(I=this.viewContainerManager.getView($))==null?void 0:I.cameraOpt;f?this.control.textEditorManager.updateTextForWorker({x:de[0],y:de[1],w:me[0],h:me[1],scale:(ye==null?void 0:ye.scale)||1,workId:H,opt:f,dataType:ee,viewId:$,canSync:C||!1,canWorker:!1,updateNodeOpt:m,skipStorageDispatch:!0}):this.control.textEditorManager.delete(H,C||!1,!1),!!(se||oe&&C)&&((D=this.collector)==null||D.dispatch({type:he.UpdateNode,workId:H,toolsType:K.Text,opt:f,updateNodeOpt:m,isSync:C||!1,viewId:$,scenePath:ue,needUndoTicker:se,requestId:F,emitEventType:S}))}break;case he.GetTextActive:W===K.Text&&H&&$&&this.control.textEditorManager.updateTextForWorker({workId:H,isActive:!0,viewId:$,dataType:Ee.Local,canWorker:!1,canSync:!0},this.now);break;case he.GetImageBitMap:q&&$&&H&&hme({src:q,isgl:ae,useImageBitmap:this.control.hasOffscreenCanvas}).then(oe=>{var be;const de=this.control.hasOffscreenCanvas?oe:void 0,me=this.control.hasOffscreenCanvas?void 0:oe,ye=new Set;if(ye.add({msgType:he.GetImageBitMap,dataType:Ee.Local,workId:H,viewId:$,imageSrc:q,isSubWorker:te,imageBitmap:de,imageElement:me}),!this.control.hasOffscreenCanvas)(be=this.mainThread)==null||be.consume(ye);else{const Ce=te&&this.subWorker?this.subWorker:this.fullWorker;de?Ce.postMessage(ye,[de]):Ce.postMessage(ye)}});break;case he.GetVNodeInfo:if(H){const oe=H.toString(),de=(x=this.getVNodeInfoResolveMap.get(oe))==null?void 0:x.resolve,me={...j,uuid:oe};de&&de(me)}break;case he.ReportError:case he.ReportLog:Y&&(w===he.ReportError?this.Logger.error(`[Appliance]: [MasterControlForWorker] reportError ${Y}`):this.Logger.info(`[Appliance]: [MasterControlForWorker] reportLog ${Y}`));break;default:r=!0;break}}r&&this.collectorAsyncData(e)}collectorAsyncData(e){var r,n,s,o,a,c;for(const l of e){const{type:u,op:h,workId:d,index:g,removeIds:p,ops:v,opt:I,updateNodeOpt:D,emitEventType:x,requestId:j,toolsType:w,isSync:y,viewId:f,isLockSentEventCursor:M,nextTasks:T,needUndoTicker:b,collectUndoTicker:C,undoScopeIds:P,undoScopePhase:E}=l;if(!f){console.error("[MasterControlForWorker] collectorAsyncData on viewId in",l);return}const O=l.scenePath||this.viewContainerManager.getCurScenePath(f),V=Number(C??b??void 0);if(V&&(P!=null&&P.length)&&(E==="collect"||E==="finalize")&&this.internalMsgEmitter.emit("collectExpectedWorkIds",V,f,P,O),E==="finalize"&&b&&Number(b)&&O){const N=Number(b);this.internalMsgEmitter.emit("finalizeRequested",N,f,P||[],O)}switch(b&&Number(b)&&wve(u)&&(P!=null&&P.length)&&this.internalMsgEmitter.emit("reopenStorageAck",Number(b),f,P,O),u){case he.None:{M&&xr(()=>{this.setLockSentEventCursor(!1)},this.maxLastSyncTime,this.control.hasPolyfillMethod("requestIdleCallback")),b&&Number(b)&&xr(()=>{this.internalMsgEmitter.emit("ackRenderUndoTicker",Number(b),f,O,{requestId:j,emitEventType:x})},0,this.control.hasPolyfillMethod("requestIdleCallback"));break}case he.DrawWork:{(r=this.collector)==null||r.dispatch({type:u,op:h,opt:I,toolsType:w,workId:d,index:g,isSync:y,viewId:f,scenePath:O,updateNodeOpt:D,needUndoTicker:b,collectUndoTicker:C,requestId:j,emitEventType:x});break}case he.FullWork:{if((n=this.collector)==null||n.dispatch({type:u,ops:v,workId:d,updateNodeOpt:D,opt:I,toolsType:w,isSync:y,viewId:f,scenePath:O,needUndoTicker:b,collectUndoTicker:C,requestId:j,emitEventType:x}),w===K.BackgroundSVG&&d&&this.markmapIdResolveMap.has(d.toString())){const N=this.markmapIdResolveMap.get(d.toString());N!=null&&N.timer&&(clearTimeout(N.timer),N.timer=void 0),N!=null&&N.resolve&&N.resolve(d.toString()),this.markmapIdResolveMap.delete(d.toString())}this.willSelectorWorkId&&d&&d.toString()===this.willSelectorWorkId&&this.control.runEffectWork(()=>{this.setShapeSelectorByWorkId(this.willSelectorWorkId,f),this.willSelectorWorkId=void 0});break}case he.UpdateNode:{x&&[Se.SetColorNode,Se.SetFontStyle,Se.SetLock,Se.SetShapeOpt,Se.ZIndexNode].includes(x)&&((s=this.control.selectorApi)==null||s.onPropertyApplied({type:x,viewId:f,scenePath:O,requestId:j,data:this.buildPropertyAppliedData(x,I,D)})),(o=this.collector)==null||o.dispatch({type:u,updateNodeOpt:D,workId:d,opt:I,ops:v,op:h,isSync:y,viewId:f,scenePath:O,needUndoTicker:b,collectUndoTicker:C,requestId:j,emitEventType:x});break}case he.RemoveNode:{x===Se.DeleteNode&&((a=this.control.selectorApi)==null||a.onRemoveNodeApplied({viewId:f,requestId:j,removeIds:p})),p&&this.control.textEditorManager.deleteBatch(p,!1,!1),(c=this.collector)==null||c.dispatch({type:u,removeIds:p,isSync:y,viewId:f,scenePath:O,needUndoTicker:b,collectUndoTicker:C,requestId:j,emitEventType:x}),this.willSelectorWorkId&&(p!=null&&p.includes(this.willSelectorWorkId))&&(this.willSelectorWorkId=void 0);break}}T&&this.collectorAsyncData(T)}}async onLocalEventEnd(e,r){var h;const n=this.viewContainerManager.getView(r);if(!n)return;const{focusScenePath:s,cameraOpt:o}=n,a=this.viewContainerManager.transformToScenePoint(e,r),c=[],l=[],u=new Map;(h=this.currentToolsData)==null||h.toolsType,K.Pencil;for(const[d,g]of this.localPointsBatchData)if(g.toolsType===K.Text){const v=g.state;if(v&&v===ge.Start){const I=g.opt;I.workState=ge.Doing,I.boxPoint=[Math.round(a[0]),Math.round(a[1])],I.boxSize=[I.fontSize,I.fontSize],this.control.textEditorManager.checkEmptyTextBlur(),this.control.textEditorManager.createTextForMasterController({workId:this.newWorkId,x:e[0],y:e[1],scale:(o==null?void 0:o.scale)||1,opt:I,type:vr.Text,isActive:!0,viewId:r,scenePath:s},this.now)}this.deleteLocalPoint(d);continue}else{this.pushLocalPoint(d,a,ge.Done,r);const v=this.getLocalPointInfo(d);if(v){const I=this.createAutoShapeTask({workId:d,viewId:r,scenePath:s,points:[...v.rawPoints],opt:v.opt});I&&l.push(I),fs(v.toolsType)&&v.toolsType!==K.BitMapEraser&&v.undoTickerId&&s&&u.set(v.undoTickerId,s)}c.push(d)}if(c.length){u.forEach((d,g)=>{this.internalMsgEmitter.emit("finalizeRequested",g,r,[],d)});try{if(this.localDoneWait={workIds:c.map(String),startedAt:Date.now()},await new Promise(g=>{setTimeout(async()=>{const p=new Set(l.map(I=>{var D;return(D=I.workId)==null?void 0:D.toString()}).filter(Boolean));if(c.forEach(I=>{if(p.has(I.toString())){this.deleteLocalPoint(I);return}this.setLocalPointIsFullWork(I)}),l.forEach(I=>{I.needUndoTicker&&s&&I.workId!==void 0&&I.workId!==null&&this.internalMsgEmitter.emit("finalizeRequested",Number(I.needUndoTicker),r,[I.workId.toString()],s),this.taskBatchData.add(I)}),this.delayWorkStateToDoneResolve=g,!c.some(I=>this.localPointsBatchData.has(I))){this.delayWorkStateToDoneResolve(!1);return}l.length&&p.size===c.length&&this.delayWorkStateToDoneResolve(!0),this.consume()},0)})&&c[0]){const g=c[0];c.forEach(p=>{this.deleteLocalPoint(p)}),this.willSelectorWorkId=g.toString()}}catch(d){this.Logger.error(`[Appliance]: [MasterControlForWorker] onLocalEventEnd error: ${d instanceof Error?d.message:String(d)}`)}this.localDoneWait=void 0,this.delayWorkStateToDoneResolve=void 0,c.length=0}}onLocalEventDoing(e,r){var s;if(((s=this.currentToolsData)==null?void 0:s.toolsType)===K.Text)return;this.currentLocalWorkData.workState===ge.Start&&this.setCurrentLocalWorkData({...this.currentLocalWorkData,workState:ge.Doing});let n=!1;for(const[o,{state:a}]of this.localPointsBatchData.entries())if(this.isAbled()&&a!==ge.Pending){const c=this.viewContainerManager.transformToScenePoint(e,r);this.pushLocalPoint(o,c,a===ge.Start?ge.Doing:a,r),n=!0}if(n){this.runAnimation();return}}onLocalEventStart(e,r){var l,u;this.viewContainerManager.focuedViewId!==r&&this.viewContainerManager.setFocuedViewId(r),this.isCanDrawWork&&this.control.room&&!this.control.room.disableDeviceInputs&&(this.control.room.disableDeviceInputs=!0);const n=(l=this.currentToolsData)==null?void 0:l.toolsType,s=n===K.Selector?De:this.newWorkId,o=this.setZIndex(r);let a;if(n!==void 0&&n!==K.Text&&this.isCanRecordUndoRedo){a=this.now;const h=fs(n)?{render:!0,storage:!0,scopeMode:"dynamic",source:Qg(n)}:{render:!0,storage:!0,source:Qg(n)};this.internalMsgEmitter.emit("addUndoTicker",a,r,h)}this.setCurrentLocalWorkData({workState:ge.Start,toolsOpt:o,viewId:r,undoTickerId:a});const c=this.viewContainerManager.transformToScenePoint(e,r);if(this.pushLocalPoint(s,c,ge.Start,r,o),n!==K.Text){if(this.control.textEditorManager.checkEmptyTextBlur(),s&&o&&n&&this.isCanStartEventConsum&&this.prepareOnceWork({workId:s,toolsOpt:o,viewId:r},n),this.consumeCount=0,this.postCount=0,this.maxDrawCount=0,this.fullWorkerDrawCount=0,this.subWorkerDrawCount=0,this.clearReRenders(1/0),this.isCanDrawWork){const h=this.viewContainerManager.getCurScenePath(r);h&&((u=this.collector)!=null&&u.hasSelector(r,h))&&this.blurSelector(r,h)}this.consume()}}setLocalPointIsFullWork(e){const r=this.getLocalPointInfo(e);r&&(r.isFullWork=!0,this.localPointsBatchData.set(e,r))}pushLocalPoint(e,r,n,s,o){var c;let a=this.getLocalPointInfo(e);n===ge.Start?a={state:ge.Start,points:[...r],rawPoints:[...r],toolsType:(c=this.currentToolsData)==null?void 0:c.toolsType,opt:o||this.currentLocalWorkData.toolsOpt,isFullWork:!1,viewId:s,undoTickerId:this.currentLocalWorkData.undoTickerId,scenePath:this.viewContainerManager.getCurScenePath(s)}:a&&(a.state=n,a.points.push(r[0],r[1]),a.rawPoints.push(r[0],r[1])),a&&this.localPointsBatchData.set(e,a)}deleteLocalPoint(e){this.localPointsBatchData.delete(e)}getLocalPointInfo(e){return this.localPointsBatchData.get(e)}getLocalPointsInfo(){return this.localPointsBatchData}getLocalInputDebugState(){var a;const e=Date.now(),r=[...this.localPointsBatchData.entries()].map(([c,l])=>({workId:c,state:l.state,toolsType:l.toolsType,undoTickerId:l.undoTickerId,isFullWork:l.isFullWork,pointCount:Math.floor(l.points.length/2),rawPointCount:Math.floor(l.rawPoints.length/2),viewId:l.viewId})),n=[],s=this.viewContainerManager.getAllViews().flatMap(c=>{if(!c)return[];const l=c.focusScenePath;return l?c.displayer.commiter.getPendingTickerSnapshots(l):[]});this.control.isToolChangePending&&n.push("tool-change-pending"),this.queuedLocalEventCount>0&&n.push("local-event-queue-pending"),this.localDoneWait&&(n.push("local-done-waiting"),r.length?r.every(c=>c.state===ge.Done&&!c.pointCount)&&n.push("done-work-has-no-points"):n.push("done-waiting-without-local-work")),this.isLocalWorkActive&&this.currentLocalWorkData.workState===ge.Pending&&n.push("active-work-with-pending-state"),s.some(c=>c.phase==="failed")&&n.push("undo-ticker-failed");const o=this.viewContainerManager.getAllViews().filter(c=>c&&this.control.isClearBusy(c.id)).map(c=>c.id);return o.length&&n.push("clear-operation-pending"),{timestamp:e,suspectedBlockers:n,toolChangePending:this.control.isToolChangePending,isAbled:this.isAbled(),isWritable:this.control.renderControl.isWritable,currentTool:(a=this.currentToolsData)==null?void 0:a.toolsType,currentLocalWorkData:{...this.currentLocalWorkData},isLocalWorkActive:this.isLocalWorkActive,localWorkViewId:this.getLocalWorkViewId(),queuedLocalEventCount:this.queuedLocalEventCount,activeLocalEvent:this.activeLocalEvent?{...this.activeLocalEvent,waitingMs:e-this.activeLocalEvent.startedAt}:void 0,localDoneWait:this.localDoneWait?{...this.localDoneWait,waitingMs:e-this.localDoneWait.startedAt}:void 0,hasDoneResolver:!!this.delayWorkStateToDoneResolve,localPoints:r,taskBatchSize:this.taskBatchData.size,tasksqueueSize:this.tasksqueue.size,animationScheduled:this.animationId!==void 0,cameraStates:[...this.cameraUpdateStateByView.entries()].map(([c,l])=>({viewId:c,isBusy:l.isBusy,hasPending:!!l.pendingCamera,hasPrepare:!!l.preparePromise,currentTaskId:l.currentTaskId,lastAckTaskId:l.lastAckTaskId})),operationBarrierViews:[...this.operationBarrierQueueByView.keys()],clearBusyViews:o,pendingTickers:s}}shouldUseAutoShape(e){var r;return((r=this.currentToolsData)==null?void 0:r.toolsType)===K.Pencil&&!!(e!=null&&e.autoShape)}toAutoShapePoints(e){const r=[];for(let n=0;n<e.length-1;n+=2)r.push([e[n],e[n+1]]);return r}logAutoShapeResult(e){}emitAutoShapeResult(e){const{viewId:r,workId:n,scenePath:s,result:o,recognized:a,mappedToolsType:c}=e,l=o.candidates[0],u={workId:n.toString(),viewId:r,scenePath:s,recognized:a,fallbackToPencil:!a,kind:o.kind,score:o.score,threshold:o.threshold,templateId:o.templateId,mappedToolsType:c,topCandidate:l?{kind:l.kind,score:l.score,threshold:l.threshold,templateId:l.templateId}:void 0,metrics:{cornerCount:o.metrics.cornerCount,straightness:o.metrics.straightness,closureRatio:o.metrics.closureRatio,radialVariance:o.metrics.radialVariance,bboxCornerCloseness:o.metrics.bboxCornerCloseness,diamondCloseness:o.metrics.diamondCloseness}};this.publicMsgEmitter.emit("autoShape",u)}createAutoShapeTask(e){const{workId:r,viewId:n,scenePath:s,points:o,opt:a}=e;if(!this.shouldUseAutoShape(a))return;const c=uve({rawPoints:this.toAutoShapePoints(o),pencilOptions:ve.cloneDeep(a),viewId:n,scenePath:s});if(!c)return;const l=hve(c),u=Hg(l,c)||this.mapAutoShapeFallback(l,c);if(this.logAutoShapeResult({viewId:n,workId:r,result:l,recognized:!!u}),this.emitAutoShapeResult({viewId:n,workId:r,scenePath:s,result:l,recognized:!!u,mappedToolsType:u==null?void 0:u.toolsType}),!!u)return{msgType:he.FullWork,dataType:Ee.Local,workId:r,viewId:n,scenePath:s,toolsType:u.toolsType,opt:u.opt,ops:z0e(u),willRefresh:!0,willSyncService:!0,isRunSubWork:!0,clearPreviewLocalWork:!0,isLockSentEventCursor:!0,autoShapeResult:l,needUndoTicker:this.viewContainerManager.getUndoTickerId(n)}}mapAutoShapeFallback(e,r){const{metrics:n}=e;if(e.recognized||n.closureRatio>.1)return null;let s;return n.cornerCount>=4&&n.cornerCount<=6&&n.bboxCornerCloseness<=.15&&n.diamondCloseness>n.bboxCornerCloseness+.15?s="rectangle":n.cornerCount===3&&n.radialVariance<.28?s="triangle":n.cornerCount>=8&&n.cornerCount<=12&&n.radialVariance>.28?s="star":n.cornerCount>=5&&n.radialVariance<.22&&n.bboxCornerCloseness>.2&&(s="ellipse"),s?Hg({...e,kind:s,recognized:!0},r):null}correctStorage(e,r,n){var h,d;const s=new Map,o=[],a=new Map,c=[];Object.keys(e).forEach(g=>{var I,D,x;const p=(D=(I=e[g])==null?void 0:I.opt)==null?void 0:D.zIndex,v=(x=e[g])==null?void 0:x.toolsType;ve.isNumber(p)&&(v&&v===K.BackgroundSVG?c.push([g,p]):o.push([g,p]))});const l=o.length&&((h=this.zIndexNodeMethod)==null?void 0:h.correct(o))||[],u=c.length&&((d=this.zIndexNodeMethod)==null?void 0:d.correct(c))||[];this.zIndexNodeMethod&&l.length&&(this.zIndexNodeMethod.setMinZIndex(l[0][1]||0,r),this.zIndexNodeMethod.setMaxZIndex(l[l.length-1][1]||0,r)),this.zIndexNodeMethod&&u.length&&(this.zIndexNodeMethod.setMinZIndexForBackgroundSVG(u[0][1]||0,r),this.zIndexNodeMethod.setMaxZIndexForBackgroundSVG(u[u.length-1][1]||0,r));for(const[g,p]of l){if(!e[g])continue;const v=e[g];v.opt&&ve.isNumber(v.opt.zIndex)&&v.opt.zIndex!==p&&(v.opt.zIndex=p,s.set(g,v))}s.size&&s.forEach((g,p)=>{var v;(v=this.collector)==null||v.updateValue(p,g,{viewId:r,scenePath:n,isSync:!0}),e[p]=g});for(const[g,p]of u){if(!e[g])continue;const v=e[g];v.opt&&ve.isNumber(v.opt.zIndex)&&v.opt.zIndex!==p&&(v.opt.zIndex=p,a.set(g,v))}return a.size&&a.forEach((g,p)=>{var v;(v=this.collector)==null||v.updateValue(p,g,{viewId:r,scenePath:n,isSync:!0}),e[p]=g}),e}originalEventLintener(e,r,n){const s=++this.localEventSequence;this.queuedLocalEventCount++;const o=this.localEventQueue.then(async()=>{var a;this.activeLocalEvent={sequence:s,state:e,viewId:n,startedAt:Date.now()};try{await this.consumeOriginalEvent(e,r,n,s)}finally{this.queuedLocalEventCount=Math.max(0,this.queuedLocalEventCount-1),((a=this.activeLocalEvent)==null?void 0:a.sequence)===s&&(this.activeLocalEvent=void 0)}});return this.localEventQueue=o.catch(()=>{}),o}async waitForLocalEventQueue(){await this.localEventQueue}async finishActiveContinuousMethods(e,r){var l,u,h;const n=this.viewContainerManager.getUndoTickerId(e),s=await((l=this.methodBuilder)==null?void 0:l.finishActiveContinuousMethods(e,r))||[],o=new Set(s);n!==void 0&&o.add(n);const a=this.viewContainerManager.getUndoTickerId(e);if(a!==void 0&&o.add(a),!o.size)return;const c=(h=(u=this.viewContainerManager.getView(e))==null?void 0:u.displayer)==null?void 0:h.commiter;c&&await Promise.all([...o].map(d=>c.waitForTickerEnd(d,Math.max(this.maxLastSyncTime*4,1e3))))}async flushActiveTransactionBeforeOperation(e,r,n){const o=(this.operationBarrierQueueByView.get(e)||Promise.resolve()).then(()=>this.executeTransactionBarrier(e,r)),a=o.catch(()=>{});this.operationBarrierQueueByView.set(e,a);try{await o}finally{this.operationBarrierQueueByView.get(e)===a&&this.operationBarrierQueueByView.delete(e)}}async executeTransactionBarrier(e,r){var v,I,D;const n=this.viewContainerManager.getView(e),s=this.viewGenerationById.get(e),o=()=>this.viewGenerationById.get(e)===s&&this.viewContainerManager.getView(e)===n,a=(v=n==null?void 0:n.displayer)==null?void 0:v.commiter;if(!(n!=null&&n.displayer)||!a||(await this.waitForLocalEventQueue(),!o()))return;const l=a.getPendingTickerSnapshots(r).filter(x=>x.source!==$e.Text);if(!l.length)return;const u=Math.max((this.control.pluginOptions.extras.undoRedo.ackTimeout||5e3)+1e3,6e3),h=Math.max(this.control.pluginOptions.extras.undoRedo.ackTimeout||5e3,1e3),d=l.map(x=>a.waitForUndoStackEnd(x,u)),g=l.filter(x=>!x.finalizeRequested).map(x=>a.waitForFinalizeRequested(x,h));let p=!1;for(const x of l){if(x.finalizeRequested||x.phase!=="doing")continue;const j=Mve(x.source);if(j.kind==="stop-event"){if(!p&&(p=!0,await n.displayer.stopEventHandler(),!o()))return;continue}if(j.kind==="method-pause"&&(await((D=(I=this.methodBuilder)==null?void 0:I.getBuilder(j.emitEventType))==null?void 0:D.pause(e,r)),!o()))return}await this.waitForLocalEventQueue(),o()&&(await Promise.all(g),o()&&await Promise.all(d))}async consumeOriginalEvent(e,r,n,s){var l,u,h;if(!this.isAbled())return;const o=(l=this.collector)==null?void 0:l.uid,a=this.viewContainerManager.getCurScenePath(n);if(o&&!this.control.renderControl.isWritable)return;const c=((u=this.currentToolsData)==null?void 0:u.toolsType)===K.Selector;switch((h=this.currentToolsData)==null?void 0:h.toolsType){case K.Eraser:case K.PencilEraser:case K.BitMapEraser:{if(o&&!this.control.renderControl.isClearAble({uid:o,viewId:n,scenePath:a}))return;break}default:{if(o&&!this.control.renderControl.isRenderAble({uid:o,viewId:n,scenePath:a}))return;break}}switch(e){case ge.Start:{const d=this.control.isSceneBusy(n);if(this.isViewBusy(n)||d||this.control.isToolChangePending)return;this.isLocalWorkActive=!0,this.setLocalWorkViewId(n),n&&this.onLocalEventStart(r,n),c&&this.viewContainerManager.showFloatBarBtn(n,!1)}break;case ge.Doing:n&&n===this.getLocalWorkViewId()&&this.onLocalEventDoing(r,n);break;case ge.Done:if(n&&n===this.getLocalWorkViewId()){this.setCurrentLocalWorkData({...this.currentLocalWorkData,workState:ge.Done});try{await this.onLocalEventEnd(r,n)}finally{this.isLocalWorkActive=!1,this.setCurrentLocalWorkData({workState:ge.Pending}),c&&this.viewContainerManager.showFloatBarBtn(n,!0),this.setLocalWorkViewId(void 0)}}break}this.isLocalWorkActive&&this.viewContainerManager.focuedViewId===n&&this.publicMsgEmitter.emit("workState",e,n),xr(()=>{var d;(d=this.control.pluginManager)==null||d.dispatchPluginEvent("localEvent",n,e,r)},Ia,this.control.hasPolyfillMethod("requestIdleCallback"))}getLocalWorkViewId(){return this.localWorkViewId}setLocalWorkViewId(e){this.localWorkViewId=e}setCurrentToolsData(e){var o,a,c;const r=e.toolsType,s=((o=this.currentToolsData)==null?void 0:o.toolsType)!==e.toolsType;if(super.setCurrentToolsData(e),s){const l=(a=this.viewContainerManager)==null?void 0:a.getAllViews();for(const u of l)if(u){const{id:h,focusScenePath:d}=u;s&&h&&d&&((c=this.collector)!=null&&c.hasSelector(h,d)&&this.blurSelector(h,d),this.control.textEditorManager.checkEmptyTextBlur())}this.taskBatchData.add({msgType:he.UpdateTools,dataType:Ee.Local,toolsType:r,opt:{...e.toolsOpt,syncUnitTime:this.maxLastSyncTime},combineUnitTime:this.isBezier?this.combineUnitTime:1/0,maxCombineEraserTime:this.maxCombineEraserTime,isRunSubWork:this.isRunSubWork,viewId:ou,isRunBackgroundThread:this.control.isUseBackgroundThread}),this.runAnimation()}}prepareOnceWork(e,r){const{workId:n,toolsOpt:s,viewId:o}=e,a={msgType:he.CreateWork,dataType:Ee.Local,viewId:o,toolsType:r};this.queryTaskBatchData(a).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add({...a,workId:n,opt:{...s,syncUnitTime:this.maxLastSyncTime},dataType:Ee.Local,isRunSubWork:this.isRunSubWork}),this.runAnimation()}createViewWorker(e,r,n){const s=(this.viewGenerationById.get(e)||0)+1;this.viewGenerationById.set(e,s),this.pendingTransportMessages.delete(`destroy:${e}`);const{offscreenCanvasOpt:o,layerOpt:a,dpr:c,cameraOpt:l}=r;l&&this.initCameraOptByView.set(e,{...l});const u={singleChannelTexture:this.control.renderingCompatibilityDecision.effectiveMaskTextureFormatLevel===void 0,textureSubImage2D:this.control.renderingCompatibilityDecision.effectiveMaskTextureUploadLevel===void 0,imageBitmapDirtyRect:this.control.renderingCompatibilityDecision.effectiveImageBitmapFeatureLevel===void 0},h={msgType:he.Init,dataType:Ee.Local,viewId:e,viewGeneration:s,offscreenCanvasOpt:o,layerOpt:{...a,bitmapEraserMaskOptions:u},dpr:c,cameraOpt:l,isRunSubWork:!0,isSafari:navigator.userAgent.indexOf("Safari")!==-1&&navigator.userAgent.indexOf("Chrome")===-1,combineUnitTime:this.isBezier?this.combineUnitTime:1/0,maxCombineEraserTime:this.maxCombineEraserTime,syncUnitTime:this.maxLastSyncTime,isUseSimple:this.control.isUseSimple,offscreenCanvas:n.transferControlToOffscreenCanvas,bitmapEraserMaskOptions:u};if(!this.isRenderTransportReady){this.pendingTransportMessages.set(this.getPendingInitMessageKey(h),h);return}this.Logger.info(`[Appliance]: [render-init] stage=sent viewId=${e}`),this.cameraUpdateDestroy(e),this.post(new Set([h])),this.taskBatchData.size&&this.consume()}destroyViewWorker(e,r=!1){var o;const n=(this.viewGenerationById.get(e)||0)+1;this.viewGenerationById.set(e,n),this.initAckedViewIds.delete(e),this.serviceSyncReadyViews.delete(e),this.cameraUpdateDestroy(e),this.initCameraOptByView.delete(e);for(const[a,c]of this.pendingTransportMessages)c.viewId===e&&this.pendingTransportMessages.delete(a);this.getLocalWorkViewId()===e&&this.setLocalWorkViewId(void 0),this.zIndexNodeMethod&&this.zIndexNodeMethod.clearZIndex(e);const s={msgType:he.Destroy,dataType:Ee.Local,viewId:e,viewGeneration:n,isRunSubWork:!0};this.isRenderTransportReady?this.dispatchMessages(new Set([s])):this.pendingTransportMessages.set(`destroy:${e}`,s),r||(o=this.collector)==null||o.dispatch({type:he.Clear,viewId:e}),this.control.renderControl.destoryByViewId(e,r)}onServiceDerive(e,r){var g,p,v,I,D,x,j,w;const{newValue:n,oldValue:s,viewId:o,scenePath:a}=r;if(!o||!this.isViewInitAck(o)||!this.isServiceSyncReady(o))return;const c=ve.cloneDeep(n)||{},l=e;let u=c.type;if(!n&&s&&(u=he.RemoveNode),!n&&s){if(l&&((g=this.collector)==null?void 0:g.getLocalId(l))===De){this.collector.isOwn(l)?this.blurSelector(o,a):this.blurSelector(o,a,l);return}if(s.toolsType===K.LaserPen)return}if(!lu(o,a,y=>{var f;return(f=this.viewContainerManager.getView(y))==null?void 0:f.focusScenePath}))return;if((p=this.collector)!=null&&p.isSelector(e)){const y=(v=this.collector)==null?void 0:v.getUidFromKey(e);if(y&&!this.control.roomMember.isOnLine(y))return}if(u&&l){if(!this.control.renderControl.isFilterAble({viewId:o,elementId:e,scenePath:a},u))return;const y=c;if(y.workId=(I=this.collector)!=null&&I.isOwn(l)?(D=this.collector)==null?void 0:D.getLocalId(l):l,y.msgType=u,y.toolsType===K.LaserPen&&(y.isRunSubWork=!0),y.toolsType===K.BackgroundSVG){if(!this.control.isUseBackgroundThread)return;y.isRunBackgroundThread=!0}if(y.dataType=Ee.Service,y.viewId=o,y.scenePath=a,y.useAnimation=this.smoothSync&&((x=y.updateNodeOpt)==null?void 0:x.useAnimation)||!1,y.selectIds&&(y.selectIds=y.selectIds.map(f=>{var M,T;return(M=this.collector)!=null&&M.isOwn(f)?(T=this.collector)==null?void 0:T.getLocalId(f):f})),y&&y.toolsType===K.Text||(s==null?void 0:s.toolsType)===K.Text){this.control.textEditorManager.onServiceDerive(y);return}y.isEnableCursor=this.control.cursor.isEnableCursor,this.taskBatchData.add(y)}this.runAnimation();const h=r.newValue&&((j=r.newValue)==null?void 0:j.toolsType),d=r.newValue&&((w=r.newValue.opt)==null?void 0:w.zIndex);if(h&&h===K.BackgroundSVG){if(this.zIndexNodeMethod&&ve.isNumber(d)){const y=this.zIndexNodeMethod.getMinZIndexForBackgroundSVG(o);this.zIndexNodeMethod.getMaxZIndexForBackgroundSVG(o)<d&&this.zIndexNodeMethod.setMaxZIndexForBackgroundSVG(d,o),y>d&&this.zIndexNodeMethod.setMinZIndexForBackgroundSVG(d,o)}}else if(this.zIndexNodeMethod&&ve.isNumber(d)){const y=this.zIndexNodeMethod.getMinZIndex(o);this.zIndexNodeMethod.getMaxZIndex(o)<d&&this.zIndexNodeMethod.setMaxZIndex(d,o),y>d&&this.zIndexNodeMethod.setMinZIndex(d,o)}}pullServiceData(e,r,n={isAsync:!1,useAnimation:!1}){var c,l,u,h,d,g,p;if(!this.isViewInitAck(e)||!lu(e,r,v=>{var I;return(I=this.viewContainerManager.getView(v))==null?void 0:I.focusScenePath}))return;let s=(c=this.collector)==null?void 0:c.getStorageData(e,r);const{isAsync:o,useAnimation:a}=n;if(s){this.control.syncLogger.append("pullServiceData",e,r,Object.entries(s).map(([I,D])=>({key:I,type:D==null?void 0:D.type,toolsType:D==null?void 0:D.toolsType}))),this.control.renderControl.isWritable&&(s=this.correctStorage(s,e,r));const v=Object.keys(s);for(const I of v){if((l=this.collector)!=null&&l.isSelector(I)){const x=(u=this.collector)==null?void 0:u.getUidFromKey(I);if(x&&!this.control.roomMember.isOnLine(x))continue}const D=(h=s[I])==null?void 0:h.type;if(D&&I){if(!this.control.renderControl.isFilterAble({viewId:e,elementId:I,scenePath:r},D))continue;const x=s[I];if(x.workId=(d=this.collector)!=null&&d.isOwn(I)?(g=this.collector)==null?void 0:g.getLocalId(I):I,x.msgType=D,x.dataType=Ee.Service,x.viewId=e,x.scenePath=r,x.useAnimation=this.smoothSync&&(x.ops?!!a:(p=x.updateNodeOpt)==null?void 0:p.useAnimation)||!1,x.selectIds&&(x.selectIds=x.selectIds.map(j=>{var w,y;return(w=this.collector)!=null&&w.isOwn(j)?(y=this.collector)==null?void 0:y.getLocalId(j):j})),x.toolsType===K.Text){this.control.shouldHoldServiceTextRenderForFontFace()?this.control.markInitFontFaceTextRenderSkipped():this.control.textEditorManager.onServiceDerive(x);continue}if(x.toolsType===K.BackgroundSVG){if(!this.control.isUseBackgroundThread)continue;x.isRunBackgroundThread=!0}o&&x.updateNodeOpt&&x.updateNodeOpt.useAnimation&&(x.updateNodeOpt.useAnimation=!1),x.isEnableCursor=this.control.cursor.isEnableCursor,this.taskBatchData.add(x)}this.internalMsgEmitter.emit("excludeIds",v,e)}o?this.consume():this.runAnimation()}}runAnimation(){this.animationId||(this.animationId=requestAnimationFrame(this.consume.bind(this)))}consume(){var e;if(this.animationId=void 0,this.isAbled()&&this.localPointsBatchData.size)for(const[r,{state:n,isFullWork:s,points:o,opt:a,toolsType:c,undoTickerId:l,viewId:u}]of this.localPointsBatchData.entries()){if(!u||n===ge.Done&&!s||n===ge.Start&&!this.isCanStartEventConsum)continue;const h=o.map(d=>d);if(h.length||n===ge.Done){if(this.isPostCountType&&n===ge.Doing){if(this.postCount>this.consumeCount)continue;this.postCount++}this.delayWorkStateToDoneResolve&&n===ge.Done&&(this.delayWorkStateToDoneResolve(!0),this.setLockSentEventCursor(!0));const d=((e=this.getLocalPointInfo(r))==null?void 0:e.scenePath)||u&&this.viewContainerManager.getCurScenePath(u);n===ge.Done&&l&&d&&vve.has(c)&&c!==K.Pencil&&this.internalMsgEmitter.emit("finalizeRequested",l,u,[r.toString()],d),this.taskBatchData.add({op:h,workState:n,workId:r,dataType:Ee.Local,msgType:he.DrawWork,isRunSubWork:this.isRunSubWork,toolsType:c,viewId:u,scenePath:d,opt:a,smoothSync:this.smoothSync,isLockSentEventCursor:this.getLockSentEventCursor(),syncUnitTime:this.maxLastSyncTime,disableEraseImage:this.control.disableEraseImage,disableEraseText:this.control.disableEraseText,postCount:this.isPostCountType&&this.postCount||void 0,fullWorkerDrawCount:this.isCanPostDraw&&this.fullWorkerDrawCount||void 0,needUndoTicker:n===ge.Done&&l||void 0,collectUndoTicker:n!==ge.Done&&fs(c)&&l||void 0}),o.length=0}}if(this.taskBatchData.size){const r=new Set(this.taskBatchData),n=new Set,s=new Set;for(const o of r){const a=f0e({isService:o.dataType===Ee.Service,isAllViews:o.viewId===ou,viewId:o.viewId,scenePath:o.scenePath},c=>this.isViewInitAck(c),c=>{var l;return(l=this.viewContainerManager.getView(c))==null?void 0:l.focusScenePath});a==="dispatch"?n.add(o):a==="pending"&&s.add(o)}this.post(n),this.taskBatchData.clear(),s.forEach(o=>this.taskBatchData.add(o))}}unWritable(){const e=new Set;this.localPointsBatchData.forEach(({viewId:r})=>{e.add(r)}),e.forEach(r=>this.cancelLocalWorks(r,!1)),this.setCurrentLocalWorkData({workState:ge.Unwritable}),this.setLockSentEventCursor(!0)}abled(){this.setCurrentLocalWorkData({workState:ge.Pending}),this.setLockSentEventCursor(!1)}isAbled(){return this.currentLocalWorkData.workState!==ge.Unwritable}postMainThread(e){if(!this.control.hasOffscreenCanvas&&this.mainThread){this.mainThread.consume(e);return}}postWebWorker(e){if(this.control.isUseSimple){const r=[...e].find(n=>n.msgType===he.Init&&n.offscreenCanvas);r!=null&&r.offscreenCanvas?this.fullWorker.postMessage(e,[r.offscreenCanvas.bgCanvas,r.offscreenCanvas.localCanvas,r.offscreenCanvas.serviceCanvas]):this.fullWorker.postMessage(e);return}else if(this.subWorker){this.fullWorker.postMessage(e);const r=new Set;for(const n of e.values()){const s=n.msgType;(s===he.Init||s===he.Clear||s===he.Destroy||s===he.UpdateCamera||s===he.Console||n.isRunSubWork)&&r.add(n)}r.size&&this.subWorker.postMessage(r)}}post(e){!this.isRenderTransportReady||!e.size||this.dispatchMessages(e)}dispatchMessages(e){if(this.control.isUseBackgroundThread){if(!this.backgroundThreadManager){let n=[];n=ve.cloneDeep([...e]),setTimeout(()=>{for(const s of n)this.taskBatchData.add(s)},0);return}const r=new Set;for(const n of e.values()){const s=n.msgType;(s===he.Init||s===he.Clear||s===he.Destroy||s===he.Console||n.isRunBackgroundThread)&&r.add(n)}r.size&&this.backgroundThreadManager.consume(r)}if(!this.control.hasOffscreenCanvas){if(!this.mainThread){let r=[];r=ve.cloneDeep([...e]),setTimeout(()=>{for(const n of r)this.taskBatchData.add(n)},0);return}this.postMainThread(e);return}this.postWebWorker(e)}updateNode(e,r,n,s){this.taskBatchData.add({msgType:he.UpdateNode,workId:e,updateNodeOpt:r,viewId:n,scenePath:s,dataType:Ee.Local}),this.runAnimation()}destroyTaskQueue(){for(const e of this.cameraUpdateStateByView.keys())this.cameraUpdateDestroy(e);this.tasksqueue.clear()}updateDpr(e,r){this.queryTaskBatchData({msgType:he.UpdateDpr,dataType:Ee.Local,viewId:e}).forEach(n=>{this.taskBatchData.delete(n)}),this.taskBatchData.add({dataType:Ee.Local,msgType:he.UpdateDpr,viewId:e,dpr:r,isRunSubWork:!0}),this.runAnimation()}updateCamera(e,r){if(!this.isViewInitAck(e))return;if(this.control.isSceneBusy(e)){this.control.deferSceneCamera(e,r);return}if(this.control.isClearBusy(e)){this.control.deferClearCamera(e,r);return}let n=this.cameraUpdateStateByView.get(e);if(n||(n={isBusy:!0},this.cameraUpdateStateByView.set(e,n)),n.pendingCamera={cameraOpt:r,scenePath:this.viewContainerManager.getCurScenePath(e)},!n.preparePromise){if(n.currentTaskId!==void 0){this.resetCameraTimeout(e,n);return}if(!n.lastAckTaskId){const s=this.enqueueCameraPreparation(e);n.preparePromise=s,s.then(()=>{this.cameraUpdateStateByView.get(e)!==n||(n==null?void 0:n.preparePromise)!==s||this.control.isSceneBusy(e)||(n.preparePromise=void 0,this.consumePendingCameraForView(e,n))}).catch(()=>{this.cameraUpdateStateByView.get(e)===n&&(n.preparePromise=void 0,this.cameraUpdateDestroy(e))});return}this.resetCameraTimeout(e,n),this.consumePendingCameraForView(e,n)}}isSameCameraOpt(e,r){return e.scale===r.scale&&e.centerX===r.centerX&&e.centerY===r.centerY&&e.width===r.width&&e.height===r.height}enqueueCameraPreparation(e){const r=this.localWorkFinalizeQueue.then(async()=>{await this.waitForLocalEventQueue();const n=this.viewContainerManager.getCurScenePath(e);!n||this.control.isSceneBusy(e)||await this.flushActiveTransactionBeforeOperation(e,n,"camera-update")});return this.localWorkFinalizeQueue=r.catch(()=>{}),r}consumePendingCameraForView(e,r){var c,l,u;if(this.cameraUpdateStateByView.get(e)!==r||r.preparePromise||r.currentTaskId!==void 0||this.control.isSceneBusy(e))return;const n=r.pendingCamera;if(!n)return;const s=this.viewContainerManager.getCurScenePath(e);if(n.scenePath&&n.scenePath!==s){r.pendingCamera=void 0;return}r.pendingCamera=void 0;const o=(this.cameraTaskSequenceByView.get(e)||0)+1;this.cameraTaskSequenceByView.set(e,o),r.currentTaskId=o,this.blurCursor(e);const a={msgType:he.UpdateCamera,dataType:Ee.Local,cameraOpt:n.cameraOpt,scenePath:s,isRunSubWork:!0,viewId:e,cameraTaskId:o};this.post(new Set([{msgType:he.TasksQueue,dataType:Ee.Local,isRunSubWork:!0,isRunBackgroundThread:this.control.isUseBackgroundThread,mainTasksqueueCount:o,cameraTaskId:o,tasksqueue:new Map([[e,a]]),viewId:e}])),this.control.textEditorManager.onCameraChange(n.cameraOpt,e);try{(c=this.control.selectorApi)==null||c.onCameraChange(e)}catch(h){(u=(l=this.Logger)==null?void 0:l.error)==null||u.call(l,`[Appliance]: [selector] onCameraChange failed: ${h==null?void 0:h.message}`)}this.resetCameraTimeout(e,r)}resetCameraTimeout(e,r){r.cameraTimeoutId&&clearTimeout(r.cameraTimeoutId),r.cameraTimeoutId=setTimeout(()=>{var n,s;if(this.cameraUpdateStateByView.get(e)===r){if(r.cameraTimeoutId=void 0,r.pendingCamera){r.currentTaskId!==void 0&&((s=(n=this.Logger)==null?void 0:n.warn)==null||s.call(n,`[Appliance]: camera render ACK timeout with pending viewId=${e} taskId=${r.currentTaskId}`),r.currentTaskId=void 0),this.consumePendingCameraForView(e,r);return}r.currentTaskId!==void 0&&this.Logger.error(`[Appliance]: camera render ACK timeout viewId=${e} taskId=${r.currentTaskId}`),this.cameraUpdateDestroy(e)}},this.maxLastSyncTime)}ackCameraTask(e,r){const n=this.cameraUpdateStateByView.get(e);!(n&&n.currentTaskId===r)||!n||(n.currentTaskId=void 0,n.lastAckTaskId=r,n.pendingCamera&&this.consumePendingCameraForView(e,n))}ackCameraSettledTask(e,r){const n=this.cameraUpdateStateByView.get(e);!(n&&n.lastAckTaskId===r&&!n.pendingCamera)||!n||this.cameraUpdateDestroy(e)}cameraUpdateDestroy(e){var s;const r=this.cameraUpdateStateByView.get(e);if(!r)return;r.cameraTimeoutId&&clearTimeout(r.cameraTimeoutId),r.pendingCamera=void 0,r.preparePromise=void 0,r.currentTaskId=void 0,r.lastAckTaskId=void 0,r.cameraTimeoutId=void 0,this.cameraUpdateStateByView.delete(e);const n=this.cameraUpdateEndWaitersByView.get(e);n&&(this.cameraUpdateEndWaitersByView.delete(e),n.forEach(o=>o())),!this.control.isSceneBusy(e)&&!this.control.isClearBusy(e)&&((s=this.methodBuilder)==null||s.recover(),this.runAnimation())}waitForCameraUpdateEnd(e){return this.cameraUpdateStateByView.has(e)?new Promise(r=>{const n=this.cameraUpdateEndWaitersByView.get(e)||new Set;n.add(r),this.cameraUpdateEndWaitersByView.set(e,n)}):Promise.resolve()}recoverAfterSceneChange(e){var r;(r=this.methodBuilder)==null||r.recover(),this.runAnimation()}async clearViewScenePath(e,r,n){var o,a;const s=this.viewContainerManager.getCurScenePath(e);if(n){const c=(o=this.collector)==null?void 0:o.uid;if(!(!c||this.control.renderControl.isClearAble({uid:c,viewId:e,scenePath:s})))return}this.cancelLocalWorks(e,!r),this.control.textEditorManager.clear(e,r),this.queryTaskBatchData({dataType:Ee.Service,viewId:e}).forEach(c=>{this.taskBatchData.delete(c)}),this.queryTaskBatchData({msgType:he.Clear,dataType:Ee.Local,viewId:e}).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add({dataType:Ee.Local,msgType:he.Clear,viewId:e}),this.runAnimation(),r||(this.control.renderControl.isUsePageAuth(e)&&s?this.control.renderControl.clearRenderPage(e,s):(a=this.collector)==null||a.dispatch({type:he.Clear,viewId:e,scenePath:s})),this.zIndexNodeMethod&&this.zIndexNodeMethod.clearZIndex(e),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 We([Se.CopyNode,Se.SetColorNode,Se.DeleteNode,Se.RotateNode,Se.ScaleNode,Se.TranslateNode,Se.ZIndexNode,Se.SetFontStyle,Se.SetPoint,Se.SetLock,Se.SetShapeOpt]).registerForMainEngine(Fe.MainEngine,this.control),this.zIndexNodeMethod=(e=this.methodBuilder)==null?void 0:e.getBuilder(Se.ZIndexNode)}setZIndex(e){const r=this.currentToolsData&&ve.cloneDeep(this.currentToolsData.toolsOpt);return r&&this.zIndexNodeMethod&&this.isUseZIndex&&(this.zIndexNodeMethod.addMaxLayer(e),r.zIndex=this.zIndexNodeMethod.getMaxZIndex(e)),r}async checkDrawingWork(e){const r=new Set;let n=!1;for(const[s,o]of this.localPointsBatchData.entries()){const{state:a,viewId:c,toolsType:l,undoTickerId:u}=o;if(e===c&&(a===ge.Start||a===ge.Doing)){if(l===K.Text)continue;o.state=ge.Done,o.isFullWork=!0,this.localPointsBatchData.set(s,o),u&&(r.add(u),fs(l)&&l!==K.BitMapEraser&&o.scenePath&&this.internalMsgEmitter.emit("finalizeRequested",u,c,[],o.scenePath)),n=!0}}if(n){this.consume();for(const[s,o]of this.localPointsBatchData.entries())o.viewId===e&&o.state===ge.Done&&this.deleteLocalPoint(s)}return[...r]}cancelLocalWorks(e,r=!0){var c,l;const n=this.viewContainerManager.getCurScenePath(e),s=new Set,o=new Set;let a=!1;for(const[u,h]of this.localPointsBatchData.entries())h.viewId===e&&(h.undoTickerId&&o.add(h.undoTickerId),fs(h.toolsType)&&(this.cancelledEraseTxnIds.add(u.toString()),this.cancelledEraseTxnIds.size>256&&this.cancelledEraseTxnIds.delete(this.cancelledEraseTxnIds.values().next().value)),(c=this.localDoneWait)!=null&&c.workIds.includes(u.toString())&&(a=!0),u!==De&&h.state!==ge.Start&&s.add(u.toString()),this.localPointsBatchData.delete(u));if(a&&this.delayWorkStateToDoneResolve&&this.delayWorkStateToDoneResolve(!1),o.forEach(u=>{n&&this.internalMsgEmitter.emit("cancelUndoTicker",u,e,n)}),s.size){const u=[...s];u.forEach(h=>{this.taskBatchData.add({msgType:he.RemoveNode,workId:h,viewId:e,dataType:Ee.Local,isRunSubWork:!0})}),r&&((l=this.collector)==null||l.dispatch({type:he.RemoveNode,removeIds:u,viewId:e,scenePath:n})),this.consume()}this.currentLocalWorkData.viewId===e&&this.setCurrentLocalWorkData({workState:ge.Pending})}removeDrawingWork(e){this.cancelLocalWorks(e)}removeNodes(e,r){var s,o;const n=(s=this.viewContainerManager.getView(e))==null?void 0:s.focusScenePath;if(n&&r.length){for(const a of r)this.taskBatchData.add({msgType:he.RemoveNode,workId:a,viewId:e,dataType:Ee.Local,isRunSubWork:!1});this.consume(),(o=this.collector)==null||o.dispatch({type:he.RemoveNode,removeIds:r,viewId:e,scenePath:n})}}hoverCursor(e,r){var n;if(((n=this.currentToolsData)==null?void 0:n.toolsType)===K.Selector&&!this.isViewBusy(r)){const s=this.viewContainerManager.getView(r);if(s&&s.displayer&&s.displayer.vDom){const c=s.displayer.vDom.state.floatBarData;if(c){const{x:l,y:u,w:h,h:d}=c;if(A0(e,{x:l,y:u,w:h,h:d}))return}}const o=this.viewContainerManager.transformToScenePoint(e,r),a={msgType:he.CursorHover,dataType:Ee.Local,point:o,toolsType:this.currentToolsData.toolsType,opt:this.currentToolsData.toolsOpt,isRunSubWork:!1,viewId:r};this.queryTaskBatchData({msgType:he.CursorHover,dataType:Ee.Local,toolsType:this.currentToolsData.toolsType,viewId:r}).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add(a),this.runAnimation()}}blurCursor(e){var n;if(((n=this.currentToolsData)==null?void 0:n.toolsType)!==K.Selector)return;const r={msgType:he.CursorBlur,dataType:Ee.Local,isRunSubWork:!1,viewId:e};this.queryTaskBatchData({msgType:he.CursorHover,dataType:Ee.Local,viewId:e}).forEach(s=>{this.taskBatchData.delete(s)}),this.taskBatchData.add(r),this.consume()}sendCursorEvent(e,r){var c,l,u;if(!this.currentLocalWorkData||this.currentLocalWorkData.workState===ge.Unwritable||this.isViewBusy(r))return;const n=(c=this.currentToolsData)==null?void 0:c.toolsType;if(this.workState===ge.Pending&&n===K.Selector&&(ve.isNumber(e[0])&&ve.isNumber(e[1])?this.hoverCursor(e,r):e[0]===void 0&&e[1]===void 0&&this.blurCursor(r)),!this.currentToolsData||!this.isCanSentCursor||!this.control.pluginOptions.extras.cursor.enable)return;const s=(l=this.collector)==null?void 0:l.uid,o=this.viewContainerManager.getCurScenePath(r);switch((u=this.currentToolsData)==null?void 0:u.toolsType){case K.Eraser:case K.PencilEraser:case K.BitMapEraser:{if(s&&!this.control.renderControl.isClearAble({uid:s,viewId:r,filterLocalSelf:!1,scenePath:o}))return;break}default:if(s&&!this.control.renderControl.isWritable||s&&!this.control.renderControl.isRenderAble({uid:s,viewId:r,filterLocalSelf:!1,scenePath:o}))return;break}let a=[void 0,void 0];this.currentToolsData&&this.isCanSentCursor&&!this.localPointsBatchData.size&&!this.getLockSentEventCursor()&&(a=e,this.control.cursor.sendEvent(a,r))}getBoundingRect(e){var n,s;if(!((n=this.boundingRectMap)==null?void 0:n.get(e))){const o=(s=this.collector)==null?void 0:s.getScenePathData(e);if(!o)return;if(Object.keys(o).forEach(a=>{var c;((c=this.collector)==null?void 0:c.getLocalId(a))===De&&delete o[a]}),Object.keys(o).length&&this.viewContainerManager.mainView&&this.viewContainerManager.mainView.cameraOpt){const a={msgType:he.BoundingBox,dataType:Ee.Local,scenePath:e,scenes:o,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,r,n,s){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 v;((v=this.collector)==null?void 0:v.getLocalId(p))===De&&delete g[p]}),Object.keys(g).length){const p=this.viewContainerManager.mainView;if(!p)return;const v=r||((u=p.cameraOpt)==null?void 0:u.width),I=n||((h=p.cameraOpt)==null?void 0:h.height),D={msgType:he.Snapshot,dataType:Ee.Local,scenePath:e,scenes:g,w:v,h:I,cameraOpt:s&&{...s,width:v,height:I}||p.cameraOpt,isRunSubWork:!0,isRunBackgroundThread:this.control.isUseBackgroundThread,viewId:d};return this.taskBatchData.add(D),this.runAnimation(),new Promise(x=>{this.snapshotMap.set(e,{resolve:x,value:this.control.isUseBackgroundThread?[void 0,void 0]:[void 0]})}).then(x=>(this.snapshotMap.delete(e),x.reverse()))}}}queryTaskBatchData(e){const r=[];if(e)for(const n of this.taskBatchData.values()){let s=!0;for(const[o,a]of Object.entries(e))if(n[o]!==a){s=!1;break}s&&r.push(n)}return r}insertIconify(e,r){var a;const n=this.viewContainerManager.getView(e);if(!n)throw new Error("insertIconify viewId is not exist");if(!r.src)throw new Error("iconify src must be required");if(!/^(http|https):\/\//.test(r.src))throw new Error("iconify src must be http or https");r.strokeColor||(r.strokeColor=(a=this.currentLocalWorkData.toolsOpt)==null?void 0:a.strokeColor);const o=n==null?void 0:n.focusScenePath;if(e&&o){const c=this.now;Xe.InternalMsgEmitter.emit("addUndoTicker",c,e,{render:!0,storage:!0,source:$e.AsyncIcon}),Xe.InternalMsgEmitter.emit("finalizeRequested",c,e,[r.uuid],o);const l={...r,type:qr.Iconify};this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayer(e),l.zIndex=this.zIndexNodeMethod.getMaxZIndex(e)),this.taskBatchData.add({msgType:he.FullWork,dataType:Ee.Local,toolsType:K.Image,workId:r.uuid,opt:l,viewId:e,willRefresh:!0,willSyncService:!0,needUndoTicker:c}),this.runAnimation()}}insertBackgroundSVG(e,r){if(!this.control.isUseBackgroundThread)throw new Error("useBackgroundThread of pluginOptions should be true");const n=this.viewContainerManager.getView(e);if(!n)throw new Error("insertBackgroundSVG viewId is not exist");if(!r.src)throw new Error("src must be required");if(r.src&&!/^(http|https):\/\//.test(r.src))throw new Error("iconify src must be http or https");const s=n==null?void 0:n.focusScenePath;if(e&&s){const o=this.now;Xe.InternalMsgEmitter.emit("addUndoTicker",o,e,{render:!0,storage:!0,source:$e.AsyncIcon}),Xe.InternalMsgEmitter.emit("finalizeRequested",o,e,[r.uuid],s);const a={...r,type:Li.url};this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayerForBackgroundSVG(e),a.zIndex=this.zIndexNodeMethod.getMaxZIndexForBackgroundSVG(e)),this.taskBatchData.add({msgType:he.FullWork,dataType:Ee.Local,toolsType:K.BackgroundSVG,workId:r.uuid,opt:a,viewId:e,willRefresh:!0,willSyncService:!0,needUndoTicker:o,isRunBackgroundThread:!0,scenePath:s}),this.runAnimation()}}async insertBackgroundMarkMap(e,r){var o;if(this.assertMarkmapRuntimeRegistered("insertBackgroundMarkMap",e),!this.control.isUseBackgroundThread)throw new Error("useBackgroundThread of pluginOptions should be true");const n=this.viewContainerManager.getView(e);if(!n)throw new Error("instertBackgroundMarkMap viewId is not exist");if(!r.data)throw new Error("data must be required");if(r.data&&!c0e(r.data))throw new Error("data must be markdown string");const s=n==null?void 0:n.focusScenePath;if(e&&s){const a=r.uuid.toString();if((o=this.collector)!=null&&o.hasId(e,s,a))throw new Error("instertBackgroundMarkMap svgInfo.uuid is already exist");if(this.markmapIdResolveMap.has(a))throw new Error("instertBackgroundMarkMap svgInfo.uuid is already resolving");const c=this.now;Xe.InternalMsgEmitter.emit("addUndoTicker",c,e,{render:!0,storage:!0,source:$e.AsyncMarkmap}),Xe.InternalMsgEmitter.emit("finalizeRequested",c,e,[a],s);const l={...r,type:Li.markmap};return this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayerForBackgroundSVG(e),l.zIndex=this.zIndexNodeMethod.getMaxZIndexForBackgroundSVG(e)),this.taskBatchData.add({msgType:he.FullWork,dataType:Ee.Local,toolsType:K.BackgroundSVG,workId:a,opt:l,viewId:e,willRefresh:!0,willSyncService:!0,needUndoTicker:c,isRunBackgroundThread:!0}),this.runAnimation(),new Promise((u,h)=>{this.markmapIdResolveMap.set(a,{resolve:u,timer:setTimeout(()=>{const d=this.markmapIdResolveMap.get(a);d!=null&&d.timer&&(d.timer=void 0),h(a)},this.control.pluginOptions.extras.markmap.timeout)})}).then(u=>{if(u)return this.markmapIdResolveMap.delete(u),u}).catch(u=>{throw this.markmapIdResolveMap.delete(u),Xe.InternalMsgEmitter.emit("ackRenderUndoTicker",c,e,s),Xe.InternalMsgEmitter.emit("ackStorageUndoTicker",c,e,s),new Error(`instertBackgroundMarkMap svgInfo.uuid ${u} insert timeout`)})}}async updateBackgroundMarkMap(e,r,n){var l;this.assertMarkmapRuntimeRegistered("updateBackgroundMarkMap",e);const s=this.viewContainerManager.getView(e);if(!s)throw new Error("updateBackgroundMarkMap viewId is not exist");const o=s==null?void 0:s.focusScenePath;if(!o)throw new Error("updateBackgroundMarkMap scenePath is not exist");if((l=this.collector)!=null&&l.hasId(e,o,r))throw new Error("instertBackgroundMarkMap svgInfo.uuid is already exist");if(this.markmapIdResolveMap.has(r))throw new Error("instertBackgroundMarkMap svgInfo.uuid is already resolving");const a=this.now;Xe.InternalMsgEmitter.emit("addUndoTicker",a,e,{render:!0,storage:!0,source:$e.AsyncMarkmap}),Xe.InternalMsgEmitter.emit("finalizeRequested",a,e,[r],o);const c={...n,type:Li.markmap};this.taskBatchData.add({msgType:he.UpdateNode,dataType:Ee.Local,toolsType:K.BackgroundSVG,workId:r,opt:c,viewId:e,willRefresh:!0,willSyncService:!0,needUndoTicker:a,isRunBackgroundThread:!0}),this.runAnimation()}insertImage(e,r){const n=this.viewContainerManager.getView(e);if(!n)throw new Error("insertImage viewId is not exist");if(r.src&&!/^(http|https):\/\//.test(r.src))throw new Error("Image src must be http or https");const s=n==null?void 0:n.focusScenePath;if(e&&s){const{src:o,uuid:a}=r;if(a&&!o){this.tmpImageConfigMap.set(a,r);return}const c=this.now;Xe.InternalMsgEmitter.emit("addUndoTicker",c,e,{render:!0,storage:!0,source:$e.AsyncImage});const l={...r,type:qr.Image};this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayer(e),l.zIndex=this.zIndexNodeMethod.getMaxZIndex(e)),this.taskBatchData.add({msgType:he.FullWork,dataType:Ee.Local,toolsType:K.Image,workId:r.uuid,opt:l,viewId:e,willRefresh:!0,willSyncService:!0,needUndoTicker:c}),this.runAnimation(),Xe.InternalMsgEmitter.emit("finalizeRequested",c,e,[r.uuid],s)}}lockImage(e,r,n){var a,c;const s=this.viewContainerManager.getView(e);if(!s)throw new Error("insertImage viewId is not exist");const o=s==null?void 0:s.focusScenePath;if(e&&o&&this.collector){const l=this.collector.getStorageData(e,o);if(!l)return;for(const[u,h]of Object.entries(l))if(h&&h.toolsType===K.Image&&h.opt.uuid===r){const d=this.now,g=(a=this.collector)!=null&&a.isOwn(u)?(c=this.collector)==null?void 0:c.getLocalId(u):u;Xe.InternalMsgEmitter.emit("addUndoTicker",d,e,{render:!0,storage:!0,source:$e.AsyncImage});const p={...h.opt,locked:n,type:qr.Image};this.taskBatchData.add({msgType:he.FullWork,dataType:Ee.Local,toolsType:K.Image,workId:g,opt:p,viewId:e,willRefresh:!0,willSyncService:!0,needUndoTicker:d}),this.runAnimation(),Xe.InternalMsgEmitter.emit("finalizeRequested",d,e,[g],o);return}}}completeImageUpload(e,r,n){const s=this.viewContainerManager.getView(e);if(!s)throw new Error("insertImage viewId is not exist");const o=s==null?void 0:s.focusScenePath;if(e&&o){const a=this.tmpImageConfigMap.get(r);a&&(a.src=n,this.insertImage(e,a),this.tmpImageConfigMap.delete(r));return}}getImagesInformation(e){const r=[];if(this.collector){const n=this.collector.getScenePathData(e);if(!n)return r;for(const s of Object.values(n))if(s&&s.toolsType===K.Image){const o=s.opt;r.push({uuid:o.uuid,centerX:o.centerX,centerY:o.centerY,width:o.width,height:o.height,locked:o.locked,uniformScale:o.uniformScale,crossOrigin:o.crossOrigin})}}return r}setShapeSelectorByWorkId(e,r){this.taskBatchData.add({workId:De,selectIds:[e],msgType:he.Select,dataType:Ee.Local,viewId:r,willSyncService:!0}),this.runAnimation()}blurSelector(e,r,n){this.taskBatchData.add({workId:n||De,selectIds:[],msgType:he.Select,dataType:Ee.Service,viewId:e,scenePath:r}),this.runAnimation()}consoleWorkerInfo(){this.taskBatchData.add({msgType:he.Console,dataType:Ee.Local,isRunSubWork:!0,viewId:""}),this.consume()}sendClearUids(e,r){var s,o;const n=new Set;n.add({msgType:he.AuthClear,dataType:Ee.Local,viewId:e,clearUids:r,localUid:(s=this.collector)==null?void 0:s.uid}),this.control.hasOffscreenCanvas?this.fullWorker.postMessage(n):(o=this.mainThread)==null||o.consume(n)}async getVNodeInfo(e,r,n){if(!this.getVNodeInfoResolveMap.has(e))return this.taskBatchData.add({msgType:he.GetVNodeInfo,dataType:Ee.Local,isRunSubWork:!0,viewId:r,workIds:n,workId:e}),this.consume(),await new Promise(s=>{const o=this.getVNodeInfoResolveMap.get(e)||{resolve:void 0,timer:void 0};o.timer&&clearTimeout(o.timer),o.resolve=s,o.timer=setTimeout(()=>{const a=this.getVNodeInfoResolveMap.get(e);a!=null&&a.resolve&&a.resolve({uuid:e})},this.maxLastSyncTime*5),this.getVNodeInfoResolveMap.set(e,o)}).then(s=>{const{uuid:o}=s;return this.getVNodeInfoResolveMap.delete(o),s})}}class Ive{constructor(t){R(this,"internalMsgEmitter");R(this,"control");R(this,"roomHotkeyCheckers");R(this,"tmpCopyStore",new Map);R(this,"tmpCopyCoordInfo");var n;const{control:e,internalMsgEmitter:r}=t;this.control=e,this.internalMsgEmitter=r,this.roomHotkeyCheckers=((n=this.control.room)==null?void 0:n.viewsParams.hotKeys.nodes)||[]}get isUseSelf(){var t,e;return((e=(t=this.control)==null?void 0:t.room)==null?void 0:e.disableDeviceInputs)||!1}get isSelector(){var t;return((t=this.control.worker.currentToolsData)==null?void 0:t.toolsType)===K.Selector}get collector(){return this.control.collector}get mainEngine(){return this.control.worker}get keyboardKind(){return/^Mac/i.test(navigator.platform)?"mac":"windows"}getEventKey(t){switch(t.type){case"keydown":return"KeyDown"}return"KeyUp"}onActiveHotkey(t){var n,s,o;const e=this.control.viewContainerManager.focuedViewId,r=(n=this.control.viewContainerManager.focuedView)==null?void 0:n.focusScenePath;if(e&&r)switch(t){case"delete":this.isSelector&&((s=this.collector)!=null&&s.hasSelector(e,r))&&We.emitMethod(Fe.MainEngine,Se.DeleteNode,{workIds:[De],viewId:e});break;case"copy":this.isSelector&&((o=this.collector)!=null&&o.hasSelector(e,r))&&this.copySelectorToTemp(e,r);break;case"paste":this.tmpCopyStore.size&&this.pasteTempToFocusView(e,r);break}(t==="changeToPencil"||t==="redo"||t==="undo")&&this.onSelfActiveHotkey(t)}colloctHotkey(t){if(this.isUseSelf){const e=this.checkHotkey(t);e&&this.onSelfActiveHotkey(e)}}onSelfActiveHotkey(t){switch(t){case"changeToPencil":this.setMemberState({currentApplianceName:Ne.pencil,useNewPencil:!0});break;case"changeToArrow":this.setMemberState({currentApplianceName:Ne.arrow});break;case"changeToClick":this.setMemberState({currentApplianceName:Ne.clicker});break;case"changeToEllipse":this.setMemberState({currentApplianceName:Ne.ellipse});break;case"changeToEraser":this.setMemberState({currentApplianceName:Ne.eraser});break;case"changeToHand":this.setMemberState({currentApplianceName:Ne.hand});break;case"changeToLaserPointer":this.setMemberState({currentApplianceName:Ne.laserPointer});break;case"changeToSelector":this.setMemberState({currentApplianceName:Ne.selector});break;case"changeToRectangle":this.setMemberState({currentApplianceName:Ne.rectangle});break;case"changeToStraight":this.setMemberState({currentApplianceName:Ne.straight});break;case"redo":this.control.room&&!this.control.room.disableSerialization&&this.control.viewContainerManager.redo();break;case"undo":this.control.room&&!this.control.room.disableSerialization&&this.control.viewContainerManager.undo();break;case"changeToText":this.setMemberState({currentApplianceName:Ne.text});break;case"changeToPencilEraser":this.setMemberState({currentApplianceName:Ne.pencilEraser});break;case"delete":case"copy":case"paste":this.onActiveHotkey(t);break}}checkHotkey(t){for(const e of this.roomHotkeyCheckers){const{kind:r,checker:n}=e;if(n({nativeEvent:t,kind:this.getEventKey(t),key:t.key,altKey:t.altKey,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey},this.keyboardKind))return r}}copySelectorToTemp(t,e){var l,u;const r=this.control.viewContainerManager.getView(t),n=(u=(l=this.mainEngine)==null?void 0:l.methodBuilder)==null?void 0:u.getBuilder(Se.CopyNode);if(!r||!this.collector||!n)return;const s=this.collector.transformKey(De),o=this.collector.getStorageData(t,e);if(!o)return;const a=o[s],c=a&&n.copySelector({viewId:t,store:a});c&&(this.tmpCopyCoordInfo=c==null?void 0:c.copyCoordInfo,this.tmpCopyStore=c==null?void 0:c.copyStores)}pasteTempToFocusView(t,e){var s,o;const r=this.control.viewContainerManager.getView(t),n=(o=(s=this.mainEngine)==null?void 0:s.methodBuilder)==null?void 0:o.getBuilder(Se.CopyNode);if(!(!r||!this.tmpCopyCoordInfo||!this.tmpCopyStore.size||!this.collector||!n)&&r.viewData&&this.tmpCopyCoordInfo){const a=ve.cloneDeep(this.tmpCopyCoordInfo.offset),c=this.tmpCopyCoordInfo.cameraOpt,l=r.viewData.camera;a.x=a.x+l.centerX-c.centerX,a.y=a.y+l.centerY-c.centerY;const u=this.control.worker.now;this.control.worker.internalMsgEmitter.emit("addUndoTicker",u,t,{render:!0,storage:!0,copyAck:!0,source:$e.AsyncPasteNode}),n.pasteSelector({viewId:t,scenePath:e,copyStores:ve.cloneDeep(this.tmpCopyStore),copyCoordInfo:{offset:a,cameraOpt:l},undoTickerId:u})}}setMemberState(t){var e;(e=this.control.room)==null||e.setMemberState(t)}}const Zg=50;function Cve(i){if("diffType"in i){if(i.diffType==="view")return`view:${i.viewId}`;if(i.diffType==="scenePath")return`scenePath:${i.viewId}:${i.scenePath}`}return`data:${i.key}:${i.type??""}:${i.toolsType??""}`}class bve{constructor(t,e){R(this,"batches",new Map);this.logger=t,this.batchWindowMs=e}append(t,e,r,n){if(!n.length)return;const s=`${t}:${e}:${r}`;let o=this.batches.get(s);o||(o={items:[],indexByIdentity:new Map,flushTimer:setTimeout(()=>this.flush(s),this.batchWindowMs)},this.batches.set(s,o));const a=Date.now();for(const c of n){const l=Cve(c),u=o.indexByIdentity.get(l);u!==void 0?o.items[u]={timestamp:a,item:c}:(o.indexByIdentity.set(l,o.items.length),o.items.push({timestamp:a,item:c}))}}flush(t){const e=this.batches.get(t);if(!e)return;clearTimeout(e.flushTimer),this.batches.delete(t);const[r,n,...s]=t.split(":"),o=` viewId=${n} scenePath=${s.join(":")}`;for(let a=0;a<e.items.length;a+=Zg){const l=e.items.slice(a,a+Zg).map(({timestamp:u,item:h})=>"diffType"in h&&h.diffType!=="data"?{timestamp:u,...h}:`${h.key},${h.type??""},${h.toolsType??""},${u}`);try{this.logger.info(`[Appliance]: [sync-data] source=${r}${o} changesLength=${l.length} changes=${JSON.stringify(l)}`)}catch{}}}destroy(){this.clearPending()}clearPending(){for(const t of this.batches.values())clearTimeout(t.flushTimer);this.batches.clear()}}const xve={worker:!1,offscreenCanvas:!1,workerUrl:!1,offscreenTransfer:!1,imageBitmap:!1,webgl2:!1,webgl:!1},Eve=new Set(["__proto__","constructor","prototype"]),ml=64;function Fh(i){const e=i.replace(/_/g,".").split(".");if(!(e.length<1||e.length>4||e.some(r=>!/^\d+$/.test(r)||Number(r)>99999)||Number(e[0])<1))return e.map(r=>String(Number(r))).join(".")}function ln(i,t){const e=i.match(t);return e?Fh(e[1]):void 0}function Ave(i,t){const e=i.split(".").map(Number),r=t.split(".").map(Number);for(let n=0;n<r.length;n+=1){const s=(e[n]??0)-r[n];if(s!==0)return s}return 0}function Nve(i=typeof navigator>"u"?"":navigator.userAgent){if(ln(i,/\bArkWeb\/(\d+(?:\.\d+)*)/i)){const a=ln(i,/\bChrome\/(\d+(?:\.\d+)*)/i);return a?{kind:"harmonyArkWeb",version:a}:void 0}if(/\bAndroid\b/i.test(i)&&(/;\s*wv\)/i.test(i)||/\bVersion\/4\.0\b/i.test(i)&&/\bChrome\/\d+/i.test(i))){const c=ln(i,/\bChrome\/(\d+(?:\.\d+)*)/i);return c?{kind:"androidWebView",version:c}:void 0}const e=ln(i,/\b(?:iPhone|iPad|iPod).*?\bOS\s+(\d+(?:[_.]\d+)*)/i);if(e)return{kind:"iosWebView",version:e};const r=ln(i,/\bEdg(?:A)?\/(\d+(?:\.\d+)*)/i);if(r)return{kind:"web",browser:"edge",version:r};const n=ln(i,/\bChrome\/(\d+(?:\.\d+)*)/i);if(n)return{kind:"web",browser:"chrome",version:n};const s=ln(i,/\bFirefox\/(\d+(?:\.\d+)*)/i);if(s)return{kind:"web",browser:"firefox",version:s};const o=ln(i,/\bVersion\/(\d+(?:\.\d+)*).*\bSafari\//i);return o?{kind:"web",browser:"safari",version:o}:void 0}function Wh(i){if(!i||typeof i!="object"||Array.isArray(i))return!1;try{const t=Object.getPrototypeOf(i);return t===Object.prototype||t===null}catch{return!1}}function z0(i,t){if(!Number.isInteger(i))return!1;switch(t){case"renderMode":return i===mr.OffscreenTransfer||i===mr.ImageBitmap;case"canvasContext":return i===Qn.WebGL;case"maskTextureFormat":return i===Tu.SingleChannelTexture;case"maskTextureUpload":return i===Su.TextureSubImage2D;case"imageBitmapFeature":return i===Iu.DirtyRect}}function Dve(i,t,e,r=[]){if(!Wh(t))return;const n=Object.entries(t);n.length>ml&&r.push(`worker blacklist exceeds ${ml} rules`);let s;for(const[o,a]of n.slice(0,ml)){if(Eve.has(o))continue;const c=Fh(o);if(!c||!z0(a,e)){r.push(`invalid ${e} blacklist rule: ${o}`);continue}Ave(i,c)<=0&&(s=s===void 0?a:Math.max(s,a))}return s}function Pve(i,t){var e;return t.kind==="web"?(e=i==null?void 0:i.web)==null?void 0:e[t.browser]:i==null?void 0:i[t.kind]}function gs(i,t,e){const r=[];if(!Wh(i))return{issues:r};if(!t)return r.push(`${e} blacklist runtime version unavailable`),{issues:r};const n=Pve(i,t);return n?{level:Dve(t.version,n,e,r),runtime:t,issues:r}:{runtime:t,issues:r}}function Bn(i,t,e){const r={};for(const n of[i,t])if(Wh(n))for(const[s,o]of Object.entries(n)){const a=Fh(s);!a||!z0(o,e)||(r[a]=Math.max(r[a]??0,o))}return Object.keys(r).length>0?r:void 0}function ps(i,t,e){var s,o,a,c,l,u,h,d;const r={chrome:Bn((s=i==null?void 0:i.web)==null?void 0:s.chrome,(o=t==null?void 0:t.web)==null?void 0:o.chrome,e),edge:Bn((a=i==null?void 0:i.web)==null?void 0:a.edge,(c=t==null?void 0:t.web)==null?void 0:c.edge,e),firefox:Bn((l=i==null?void 0:i.web)==null?void 0:l.firefox,(u=t==null?void 0:t.web)==null?void 0:u.firefox,e),safari:Bn((h=i==null?void 0:i.web)==null?void 0:h.safari,(d=t==null?void 0:t.web)==null?void 0:d.safari,e)},n={androidWebView:Bn(i==null?void 0:i.androidWebView,t==null?void 0:t.androidWebView,e),iosWebView:Bn(i==null?void 0:i.iosWebView,t==null?void 0:t.iosWebView,e),harmonyArkWeb:Bn(i==null?void 0:i.harmonyArkWeb,t==null?void 0:t.harmonyArkWeb,e),web:Object.values(r).some(Boolean)?r:void 0};return Object.fromEntries(Object.entries(n).filter(([,g])=>g!==void 0))}function Kg(i){var t,e;if(typeof OffscreenCanvas!="function")return!1;try{const r=new OffscreenCanvas(1,1).getContext(i);return r?((e=(t=r.getExtension)==null?void 0:t.call(r,"WEBGL_lose_context"))==null||e.loseContext(),!0):!1}catch{return!1}}function kve(){if(typeof OffscreenCanvas!="function")return!1;try{return!!new OffscreenCanvas(1,1).getContext("2d")}catch{return!1}}function Lve(i=!0){const t=typeof OffscreenCanvas=="function",e=typeof CanvasRenderingContext2D=="function"&&typeof CanvasRenderingContext2D.prototype.drawImage=="function";return{worker:typeof Worker=="function",offscreenCanvas:t,workerUrl:i,offscreenTransfer:typeof HTMLCanvasElement=="function"&&typeof HTMLCanvasElement.prototype.transferControlToOffscreen=="function",imageBitmap:t&&kve()&&typeof createImageBitmap=="function"&&typeof ImageBitmap=="function"&&e,webgl2:Kg("webgl2"),webgl:Kg("webgl")}}function Rve(i,t,e,r){return i==="main-thread"||t==="2d"||e===Qn.WebGL?"2d":t==="webgl"?r.webgl?"webgl":"2d":r.webgl2?"webgl2":r.webgl?"webgl":"2d"}function Ove(i){const t=i.userAgent??(typeof navigator>"u"?"":navigator.userAgent);if(i.useWorker==="mainThread")return{renderMode:"main-thread",contextType:"2d",reason:"use-worker-main-thread",capabilities:i.capabilities??xve,issues:[]};const e=i.capabilities??Lve(i.workerUrl),r=x=>({renderMode:"main-thread",contextType:"2d",reason:x,capabilities:e,issues:[]});if(!e.worker||!e.offscreenCanvas||!e.workerUrl)return r("worker-capability-missing");const n=Nve(t),s=[],o=gs(i.workerRenderModeBlacklist,n,"renderMode"),a=gs(i.workerCanvasContextBlacklist,n,"canvasContext"),c=gs(i.workerMaskTextureFormatBlacklist,n,"maskTextureFormat"),l=gs(i.workerMaskTextureUploadBlacklist,n,"maskTextureUpload"),u=gs(i.workerImageBitmapFeatureBlacklist,n,"imageBitmapFeature");s.push(...o.issues,...a.issues,...c.issues,...l.issues,...u.issues);const h=o.level,d=a.level,g=c.level,p=l.level,v=u.level,I=(x,j)=>({renderMode:x,contextType:Rve(x,i.requestedContextType,d||void 0,e),reason:j,capabilities:e,runtime:n,effectiveRenderModeLevel:h,effectiveContextLevel:d,effectiveMaskTextureFormatLevel:g,effectiveMaskTextureUploadLevel:p,effectiveImageBitmapFeatureLevel:v,issues:s});if(h===mr.ImageBitmap)return I("main-thread","render-mode-blacklist");if(!(!i.useSimple||h===mr.OffscreenTransfer)&&e.offscreenTransfer)return I("worker-offscreen-transfer","default-offscreen-transfer");if(e.imageBitmap){const x=h===mr.OffscreenTransfer?"render-mode-blacklist":i.useSimple?"worker-capability-missing":"use-simple-false";return I("worker-image-bitmap",x)}return I("main-thread","image-bitmap-unavailable")}class zve{constructor(t){R(this,"control");R(this,"roomMemberManager");R(this,"worker");R(this,"publicMsgEmitter");R(this,"renderUids",new Map);R(this,"pageAuth",new Map);R(this,"isLocalRender",!1);R(this,"isCurWritable",!1);var n;const{control:e,publicMsgEmitter:r}=t;this.control=e,this.publicMsgEmitter=r,this.roomMemberManager=e.roomMember,this.worker=e.worker,this.isCurWritable=((n=this.control.room)==null?void 0:n.isWritable)||!1}get isWritable(){return this.isCurWritable}onWritableChange(t){this.isCurWritable=t}addPage(t,e=!0){var l,u;const{viewId:r,render:n="localSelf",elementIds:s,pageId:o=(l=this.control.collector)==null?void 0:l.uid}=t,a=this.pageAuth.get(r)||new Map,c=this.control.viewContainerManager.getCurScenePath(r);if(c&&o){const h=a.get(c)||{render:"localSelf",pages:new Map};e&&(h.render=n);const d=s&&this.cloneElementIds(r,c,s,o)||new Set;h.pages.set(o,d),a.set(c,h),this.pageAuth.set(r,a),e&&this.pageAuthEffect(r),this.isLocalRender=!1,(u=this.control.collector)==null||u.dispatchPageAuth({operation:yt.addPage,viewId:r,scenePath:c,pageId:o,pageData:{render:n,elementIds:d}},!0)}}delPage(t,e){var o,a;const r=this.pageAuth.get(e);if(!r)return;const n=[...r.keys()].find(c=>{const l=r.get(c);return!!(l&&l.pages.has(t))});if(!n)return;const s=r.get(n);if(s){const{render:c,pages:l}=s,u=c==="localSelf"?(o=this.control.collector)==null?void 0:o.uid:c,h=l.get(t);h!=null&&h.size&&this.delElementIds(e,n,h),l.delete(t),u===t&&this.pageAuthEffect(e)}(a=this.control.collector)==null||a.dispatchPageAuth({operation:yt.deletePage,viewId:e,scenePath:n,pageId:t},!0)}delViewPage(t,e=!0){var n;this.pageAuth.get(t)&&(this.pageAuth.delete(t),e&&((n=this.control.collector)==null||n.dispatchPageAuth({operation:yt.clearView,viewId:t},e)))}clearRenderPage(t,e,r=!0){var a,c;const n=this.pageAuth.get(t);if(!n)return;const s=n.get(e);let o;if(s){const{render:l,pages:u}=s,h=l==="localSelf"?(a=this.control.collector)==null?void 0:a.uid:l;if(h){if(r){const d=u.get(h);d&&this.delElementIds(t,e,d)}u.set(h,new Set),o=h}}r&&o&&((c=this.control.collector)==null||c.dispatchPageAuth({operation:yt.clearPage,viewId:t,scenePath:e,pageId:o},r))}hasPage(t,e,r){const n=this.pageAuth.get(e);if(!n)return!1;const s=n.get(r);return s?s.pages.has(t):!1}getPageInfo(t,e,r){const n=this.pageAuth.get(e);if(!n)return;const s=n.get(r);if(s)return s.pages.get(t)}addRenderPageElementId(t,e=!0,r=!1){var u,h;const{viewId:n,elementId:s,scenePath:o}=t,a=this.pageAuth.get(n);if(!a)throw new Error(`no view info in viewId: ${n}`);const c=a.get(o);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 v=g.get(p)||new Set;v.add(s),g.set(p,v),l=p}}r&&this.pageAuthEffect(n),e&&l&&((h=this.control.collector)==null||h.dispatchPageAuth({operation:yt.addElement,viewId:n,scenePath:o,pageId:l,pageData:{elementId:s}},e))}delRenderPageElementId(t,e=!0,r=!1){var u,h;const{viewId:n,elementId:s,scenePath:o}=t,a=this.pageAuth.get(n);if(!a)throw new Error(`no view info in viewId: ${n}`);const c=a.get(o);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 v=g.get(p);v&&(v.delete(s),g.set(p,v),l=p)}}r&&this.pageAuthEffect(n),e&&l&&((h=this.control.collector)==null||h.dispatchPageAuth({operation:yt.deleteElement,viewId:n,scenePath:o,pageId:l,pageData:{elementId:s}},e))}setPageRender(t,e,r,n=!0){var a;const s=this.pageAuth.get(t);if(!s)throw new Error(`no view info in viewId: ${t}`);const o=s.get(e);o&&(o.render=r),e===this.control.viewContainerManager.getCurScenePath(t)&&this.pageAuthEffect(t),n||(this.isLocalRender=!0),n&&(this.isLocalRender=!1,(a=this.control.collector)==null||a.dispatchPageAuth({operation:yt.renderPage,viewId:t,scenePath:e,pageData:{render:r}},n))}isRenderAble(t){var c,l;const{uid:e,viewId:r,filterLocalSelf:n=!0,scenePath:s}=t,o=this.renderUids.get(r);if(o){const{render:u,hide:h}=o;if(u===void 0&&h===void 0)return!0;if(ve.isSet(u)){if(u.has(e)||n&&((c=this.control.collector)==null?void 0:c.uid)===e&&u.has("localSelf"))return!0}else if(u===!0&&(!h||ve.isSet(h)&&!h.has(e)&&!(n&&h.has("localSelf")&&((l=this.control.collector)==null?void 0:l.uid)===e)))return!0;return!1}const a=this.pageAuth.get(r);if(a&&s){const u=a.get(s);if(u){const{render:h}=u;if(h)return!(h==="localSelf"&&!n)}}return!0}isClearAble(t){var c;const{uid:e,viewId:r,filterLocalSelf:n=!0,scenePath:s}=t,o=this.renderUids.get(r);if(o){const{clear:l}=o;return!!(l===void 0||l===!0||ve.isSet(l)&&(l.has(e)||n&&((c=this.control.collector)==null?void 0:c.uid)===e&&l.has("localSelf")))}const a=this.pageAuth.get(r);if(a&&s){const l=a.get(s);if(l){const{render:u}=l;if(u)return!(u==="localSelf"&&!n)}}return!0}isFilterAble(t,e){var c,l,u,h;const{viewId:r,scenePath:n,elementId:s}=t,o=this.renderUids.get(r);if(o&&s){const{render:d,hide:g}=o;if(d===void 0&&g===void 0)return!0;const p=(c=this.control.collector)==null?void 0:c.getUidFromKey(s);return p?!!(ve.isSet(d)&&(d.has(p)||d.has("localSelf")&&((l=this.control.collector)==null?void 0:l.uid)===p)||d===!0&&(!g||ve.isSet(g)&&!g.has(p)&&!(g.has("localSelf")&&((u=this.control.collector)==null?void 0:u.uid)===p))):!1}const a=this.pageAuth.get(r);if(a&&n&&s){const d=a.get(n);if(d){const{render:g,pages:p}=d;if(!g)return!0;const v=(h=this.control.collector)==null?void 0:h.uid,I=g==="localSelf"?v:g,D=I&&p.get(I)||void 0;if(D)switch(e){case he.RemoveNode:return!0;default:return D.has(s)}return!1}}return!0}isFilterCursor(t){if(this.isUsePageAuth(t)){const e=this.control.viewContainerManager.getCurScenePath(t),r=this.pageAuth.get(t);if(e&&r){const n=r.get(e);if(n){const{render:s}=n;return s!=="localSelf"}}}return!0}isUsePageAuth(t){var n;if(!this.pageAuth.has(t))return!1;const r=this.control.viewContainerManager.getCurScenePath(t);return r&&((n=this.pageAuth.get(t))==null?void 0:n.has(r))||!1}publishRender(t){var o;const{viewId:e,option:r,isSync:n=!0}=t,s={};if(r){const{render:a,hide:c,clear:l}=r;a&&(s.render=a===!0&&!0||new Set(a)),c&&(s.hide=c===!0&&!0||new Set(c)),l&&(s.clear=l===!0&&!0||new Set(l)),this.renderUids.set(e,s)}else this.renderUids.delete(e);n&&((o=this.control.collector)==null||o.dispatchRenderAuth({operation:gr.setAuth,viewId:e,renderData:s},n)),this.renderEffect(e)}publishOneRender(t,e,r,n=!0){var a;const s=this.renderUids.get(t);let o;switch(r){case"show":s?(s.render||(s.render=new Set),ve.isSet(s.render)&&s.render.add(e),ve.isSet(s.hide)&&s.hide.delete(e)):this.renderUids.set(t,{render:new Set([e])}),o=gr.setShow;break;case"hide":s?(s.hide||(s.hide=new Set),ve.isSet(s.hide)&&s.hide.add(e),ve.isSet(s.render)&&s.render.delete(e)):this.renderUids.set(t,{hide:new Set([e])}),o=gr.setHide;break}s?this.renderUids.set(t,s):this.renderUids.delete(t),n&&o&&((a=this.control.collector)==null||a.dispatchRenderAuth({operation:o,viewId:t,uid:e},n)),this.renderEffect(t)}publishOneClear(t,e,r,n=!0){var o;const s=this.renderUids.get(t);r?s?(s.clear||(s.clear=new Set),ve.isSet(s.clear)&&s.clear.add(e)):this.renderUids.set(t,{clear:new Set([e])}):s&&ve.isSet(s.clear)&&s.clear.has(e)&&s.clear.delete(e),s?this.renderUids.set(t,s):this.renderUids.delete(t),n&&((o=this.control.collector)==null||o.dispatchRenderAuth({operation:gr.setClear,viewId:t,uid:e,isClear:r},n)),this.renderEffect(t)}syncRenderUids(t,e,r,n){const s=e===!0?!0:e&&Object.keys(e)?new Set(Object.keys(e)):void 0,o=r===!0?!0:r&&Object.keys(r)?new Set(Object.keys(r)):void 0,a=n===!0?!0:n&&Object.keys(n)?new Set(Object.keys(n)):void 0;s||o||a?this.renderUids.set(t,{render:s,hide:o,clear:a}):this.renderUids.delete(t),this.renderEffect(t),this.publicMsgEmitter.emit("syncRenderUids",t,{render:s,hide:o,clear:a})}syncPageAuth(t,e,r=!1){let n=!1;if(!e)this.pageAuth.delete(t);else{const s=this.pageAuth.get(t)||new Map;for(const[o,a]of Object.entries(e)){const{render:c,pages:l}=a,u=s.get(o),h=this.isLocalRender?u==null?void 0:u.render:c;if(h){h!==(u==null?void 0:u.render)&&(n=!0);const d=new Map;for(const[p,v]of Object.entries(l))d.set(p,new Set(Object.keys(v)));const g={render:h,pages:d};d.size&&s.set(o,g)}}s.size&&(this.pageAuth.set(t,s),this.publicMsgEmitter.emit("syncPageAuth",t,s))}(r||n)&&this.pageAuthEffect(t)}destoryByViewId(t,e=!1){var r;this.renderUids.has(t)&&(this.renderUids.delete(t),e||(r=this.control.collector)==null||r.dispatchRenderAuth({operation:gr.setAuth,viewId:t})),this.pageAuth.has(t)&&this.control.renderControl.delViewPage(t,!e)}renderEffect(t){var r;const e=(r=this.control.viewContainerManager.getView(t))==null?void 0:r.focusScenePath;e&&this.worker.clearViewScenePath(t,!0).then(()=>{var n;this.worker.pullServiceData(t,e,{isAsync:!0,useAnimation:!1}),this.worker.sendClearUids(t,(n=this.renderUids.get(t))==null?void 0:n.clear)})}pageAuthEffect(t){var r;const e=(r=this.control.viewContainerManager.getView(t))==null?void 0:r.focusScenePath;e&&this.worker.clearViewScenePath(t,!0).then(()=>{this.worker.pullServiceData(t,e,{isAsync:!0,useAnimation:!1}),this.worker.sendClearUids(t,!0)})}cloneElementIds(t,e,r,n){var a,c;const s=(a=this.control.collector)==null?void 0:a.getStorageData(t,e),o=new Set;if(s){for(const l of Object.keys(s))if(r.has(l)){const u=`${l}_${n}`;if(o.add(u),!Object.keys(s).includes(u)){const h=ve.cloneDeep(s[l]);(c=this.control.collector)==null||c.updateValue(u,{type:he.FullWork,...h,workId:u},{isSync:!0,viewId:t,scenePath:e})}}}return o}delElementIds(t,e,r){var s,o;const n=(s=this.control.collector)==null?void 0:s.getStorageData(t,e);if(n)for(const a of Object.keys(n))r.has(a)&&Object.keys(n).includes(a)&&((o=this.control.collector)==null||o.updateValue(a,void 0,{isSync:!0,viewId:t,scenePath:e}))}}class jve{constructor(t){R(this,"internalMsgEmitter");R(this,"control");R(this,"maps",new Map);R(this,"showId");R(this,"color");R(this,"timer");R(this,"updateMiniMapCamera",ve.debounce(async t=>{const e=this.maps.get(t);if(e){const r=await this.getMiniMapCamera(t);if(r){const n=r.width/r.scale,s=r.height/r.scale,o=e.miniMapCamera.width/e.miniMapCamera.scale,a=e.miniMapCamera.height/e.miniMapCamera.scale;(n>=o||s>=a)&&(e.miniMapCamera=r);const c=e.miniMapCanvas.current;if(c){const l=c.getContext("2d");if(l){const u=this.control.viewContainerManager.getView(t);if(!(u!=null&&u.focusScenePath))return;const{miniMapCamera:h,contianer:d}=e,{width:g,height:p}=d.getBoundingClientRect(),v=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*v}px`,c.style.height=`${h.height*v}px`,await this.control.screenshotToCanvas(l,u.focusScenePath,h.width,h.height,h),this.listener.emitAsync([t,"viewCameraUpate"],1)}}}}},2e3,{maxWait:5e3}));var n;const{control:e,internalMsgEmitter:r}=t;this.control=e,this.internalMsgEmitter=r,this.color=((n=this.control.worker.currentToolsData)==null?void 0:n.toolsOpt.strokeColor)||"#000"}get listener(){return this.internalMsgEmitter}get activeViewId(){return this.showId}get highlightColor(){return this.color}setHighlightColor(t){this.color=t}async createMiniMap(t,e,r){const n=this.control.viewContainerManager.getView(t);if(!n)throw new Error("view not found");const s=n.cameraOpt;if(!s)throw new Error("view camera not found");const{width:o,height:a}=e.getBoundingClientRect();if(!o||!a)throw new Error("contianer width or height is 0");const c=G.createRef();this.maps.set(t,{contianer:e,miniMapCanvas:c,miniMapCamera:r,viewCamera:s}),this.showId=t,this.control.viewContainerManager.setActiveMiniMap(this.showId,!0);const l=Math.min(o/r.width,a/r.height),u=await new Promise(h=>{this.listener.once([t,"miniMapCreate"],()=>{const d=c.current;d&&(d.width=r.width,d.height=r.height,d.style.width=`${r.width*l}px`,d.style.height=`${r.height*l}px`),h(!0)}),this.timer=setTimeout(()=>{h(!1)},2e3)});return this.timer&&clearTimeout(this.timer),u}async getMiniMapCamera(t){const e=this.control.viewContainerManager.getView(t);if(!e)return;const{cameraOpt:r,focusScenePath:n}=e;if(!r||!n)return;const s={originX:r.centerX-r.width/r.scale/2,originY:r.centerY-r.height/r.scale/2,width:r.width/r.scale,height:r.height/r.scale};let o=await this.control.getBoundingRect(n)||s;o=zh(o,s)||s;let a=o.width,c=o.height,l=1;const u=a>r.width&&Math.min(r.width/a,l)||l,h=c>r.height&&Math.min(r.height/c,l)||l;return u<=h?(a=u<1&&r.width||a,c=Math.floor(c*u)+1,l=u):u>h&&(c=h<1&&r.height||c,a=Math.floor(a*h)+1,l=h),{scale:l,centerX:o.originX+o.width/2,centerY:o.originY+o.height/2,width:a,height:c}}getMiniMapCanvas(t){const e=this.maps.get(t);return(e==null?void 0:e.miniMapCanvas.current)||null}updateViewCamera(t,e){const r=this.maps.get(t);r&&(r.viewCamera=e,this.listener.emitAsync([t,"viewCameraUpate"],1))}destroyMiniMap(t){const e=t||this.showId;e&&(this.maps.delete(e),this.control.viewContainerManager.setActiveMiniMap(e,!1))}}const yl=200;function Bve(i){return i instanceof TouchEvent||i instanceof window.TouchEvent||(i==null?void 0:i.touches)&&(i==null?void 0:i.touches.length)||(i==null?void 0:i.changedTouches)&&(i==null?void 0:i.changedTouches.length)}function Uve(i){return Bve(i)&&(i.touches&&i.touches.length===1||i.changedTouches&&i.changedTouches.length===1)}function Fve(i){return i.touches&&i.touches.length?{x:i.touches[0].pageX,y:i.touches[0].pageY}:i.changedTouches&&i.changedTouches.length?{x:i.changedTouches[0].pageX,y:i.changedTouches[0].pageY}:{x:i.pageX,y:i.pageY}}function Wve(i){const t=i.touches&&i.touches[0]||i.changedTouches&&i.changedTouches[0]||i;return{x:t.clientX,y:t.clientY}}class $h{constructor(t){R(this,"_logger");R(this,"pendingArgsByChannel",new Map);R(this,"flushTimerByChannel",new Map);this._logger=t}emit(t,e){if(this._logger){this._logger[t](...e);return}(t==="info"?console.info:t==="warn"?console.warn:console.error)(...e)}flush(t,e){this.flushTimerByChannel.set(e,null);const r=this.pendingArgsByChannel.get(e)||null;this.pendingArgsByChannel.set(e,null),r&&this.emit(t,r)}debounce(t,e,r,n){this.pendingArgsByChannel.set(e,r);const s=this.flushTimerByChannel.get(e);s!=null&&clearTimeout(s),this.flushTimerByChannel.set(e,setTimeout(()=>this.flush(t,e),n))}error(...t){this.emit("error",t)}info(...t){this.emit("info",t)}warn(...t){this.emit("warn",t)}errorDebounced(t,...e){this.debounce("error",t,e,yl)}infoDebounced(t,...e){this.debounce("info",t,e,yl)}warnDebounced(t,...e){this.debounce("warn",t,e,yl)}destroy(){for(const t of this.flushTimerByChannel.keys()){const e=this.flushTimerByChannel.get(t);e!=null&&clearTimeout(e),this.flushTimerByChannel.set(t,null),this.pendingArgsByChannel.set(t,null)}}}const Ye="[Appliance]: [selector]",$ve=["bold","normal"],Vve=["italic","normal"],Yve=["top","left","right","bottom","topLeft","topRight","bottomLeft","bottomRight","leftTop","leftBottom","rightTop","rightBottom"];class Gve{constructor(t){R(this,"control");R(this,"logger");R(this,"lastSelectedIdsByView",new Map);R(this,"lastViewRectByView",new Map);R(this,"updateResolveMap",new Map);R(this,"clearResolveMap",new Map);R(this,"copyResolveMap",new Map);R(this,"deleteResolveMap",new Map);R(this,"lastRemoteSelectorByView",new Map);R(this,"cameraEmitThrottleByView",new Map);R(this,"pendingCameraChangeByView",new Map);R(this,"pendingPropertyGeometryByKey",new Map);R(this,"publicStorageHandler");R(this,"onUndoAckApplied",t=>{var a,c;const{viewId:e,scenePath:r,requestId:n,emitEventType:s}=t;if(!n)return;const o=this.copyResolveMap.get(n);!o||o.viewId!==e||s===Se.CopyNode&&(this.copyResolveMap.delete(n),o.timer&&clearTimeout(o.timer),(c=(a=this.logger)==null?void 0:a.info)==null||c.call(a,`${Ye} copySelectedElements done requestId=${n} viewId=${e} scenePath=${r} sourceCount=${o.sourceSelectedIds.length}`),o.resolve({ok:!0,requestId:n,sourceSelectedIds:o.sourceSelectedIds,createdIds:[]}))});this.control=t,this.logger=t.logger,this.bindPublicStorageListener(),this.control.internalMsgEmitter.on("undoAckApplied",this.onUndoAckApplied)}formatFieldsFromChanges(t){return hs(t).join("/")||"-"}hasShapeChanges(t){var e,r,n,s;return((e=t.shape)==null?void 0:e.vertices)!==void 0||((r=t.shape)==null?void 0:r.innerVerticeStep)!==void 0||((n=t.shape)==null?void 0:n.innerRatio)!==void 0||((s=t.shape)==null?void 0:s.placement)!==void 0}resolveShapeDispatchToolsTypes(t,e,r,n){if(!this.hasShapeChanges(n))return[];const s=hs(n).filter(a=>a.startsWith("shape.")),o=[];return r.forEach(a=>{const c=this.lookupToolsType(t,e,a);c&&(!n.toolsType||c===n.toolsType)&&s.some(l=>Ai(c,l))&&!o.includes(c)&&o.push(c)}),o}cancelUndoTicker(t,e,r){var s,o,a;if(!t)return;const n=r||((s=this.control.viewContainerManager)==null?void 0:s.getCurScenePath(e));n&&((a=(o=this.control.worker)==null?void 0:o.internalMsgEmitter)==null||a.emit("cancelUndoTicker",t,e,n))}resolveCancelableUndoTickerId(t,e){var r,n;return t??((n=(r=this.control.viewContainerManager)==null?void 0:r.getUndoTickerId)==null?void 0:n.call(r,e))}captureUndoTickerDuringDispatch(t){var n,s;let e;const r=(o,a)=>{a===t&&e===void 0&&(e=o)};return(s=(n=this.control.internalMsgEmitter)==null?void 0:n.on)==null||s.call(n,"addUndoTicker",r),{getUndoTickerId:()=>e,dispose:()=>{var o,a;(a=(o=this.control.internalMsgEmitter)==null?void 0:o.off)==null||a.call(o,"addUndoTicker",r)}}}destroy(){for(const[,t]of this.updateResolveMap)t.timer&&clearTimeout(t.timer),t.resolve({requestId:"",ok:!1,viewId:t.viewId,reason:"busy",selectedIds:t.selectedIds,skippedIds:t.skippedIds.length?t.skippedIds:void 0,warnings:t.warnings.length?t.warnings:void 0,geometryChanged:t.geometryChanged});this.updateResolveMap.clear();for(const[,t]of this.clearResolveMap)t.timer&&clearTimeout(t.timer),t.resolve({ok:!1,requestId:"",reason:"busy"});this.clearResolveMap.clear();for(const[,t]of this.copyResolveMap)t.timer&&clearTimeout(t.timer),t.resolve({ok:!1,requestId:"",reason:"busy"});this.copyResolveMap.clear();for(const[,t]of this.deleteResolveMap)t.timer&&clearTimeout(t.timer),t.resolve({ok:!1,requestId:"",reason:"busy"});this.deleteResolveMap.clear();for(const[,t]of this.pendingPropertyGeometryByKey)t.timer&&clearTimeout(t.timer);this.pendingPropertyGeometryByKey.clear(),this.control.internalMsgEmitter.off("undoAckApplied",this.onUndoAckApplied),this.unbindPublicStorageListener()}resolveViewId(t){const e=this.control.viewContainerManager;return t||(e==null?void 0:e.focuedViewId)||Ue}getSelectedElements(t){var u,h,d;const e=this.resolveViewId(t);if(!e)return;const r=this.control.viewContainerManager,n=r==null?void 0:r.getView(e);if(!n)return;const s=(d=(h=(u=n.displayer)==null?void 0:u.vDom)==null?void 0:h.state)==null?void 0:d.floatBarData,o=(s==null?void 0:s.selectIds)??[],a=s&&ve.isNumber(s.x)&&ve.isNumber(s.y)&&ve.isNumber(s.w)&&ve.isNumber(s.h)?{x:s.x,y:s.y,w:s.w,h:s.h}:void 0,c=n.focusScenePath,l=[];for(const g of o){const p=this.buildSelectedElementInfo(e,c,g,s);p&&l.push(p)}return{viewId:e,scenePath:c,viewRect:a,selectedIds:o,selectedElements:l}}isElementPropertySupported(t,e){return Ai(t,e)}async blurSelector(t){var c,l,u,h,d,g,p,v,I;const e=this.genRequestId("clear"),r=this.resolveViewId(t);if(!r)return(l=(c=this.logger)==null?void 0:c.warn)==null||l.call(c,`${Ye} blurSelector rejected: no-view requestId=${e}`),{ok:!1,requestId:e,reason:"no-selection"};const n=this.getSelectedElements(r),s=(n==null?void 0:n.selectedIds)??[];if(!s.length)return(h=(u=this.logger)==null?void 0:u.warn)==null||h.call(u,`${Ye} blurSelector rejected: no-selection requestId=${e} viewId=${r}`),{ok:!1,requestId:e,reason:"no-selection"};const o=this.detectSelectorTransforming(r);if(o)return(g=(d=this.logger)==null?void 0:d.warn)==null||g.call(d,`${Ye} blurSelector rejected: ${o} requestId=${e} viewId=${r}`),{ok:!1,requestId:e,reason:o};(v=(p=this.logger)==null?void 0:p.info)==null||v.call(p,`${Ye} blurSelector request requestId=${e} viewId=${r} selectedCount=${s.length}`);const a=(n==null?void 0:n.scenePath)||((I=this.control.viewContainerManager)==null?void 0:I.getCurScenePath(r));return new Promise(D=>{var j,w,y;const x=setTimeout(()=>{var f,M;this.clearResolveMap.has(e)&&(this.clearResolveMap.delete(e),(M=(f=this.logger)==null?void 0:f.warn)==null||M.call(f,`${Ye} blurSelector timeout requestId=${e} viewId=${r}`),D({ok:!1,requestId:e,reason:"busy"}))},5e3);this.clearResolveMap.set(e,{timer:x,resolve:D,viewId:r});try{(j=this.control.worker)==null||j.blurSelector(r,a||"",De)}catch(f){this.clearResolveMap.delete(e),clearTimeout(x),(y=(w=this.logger)==null?void 0:w.error)==null||y.call(w,`${Ye} blurSelector failed requestId=${e} viewId=${r} err=${f==null?void 0:f.message}`),D({ok:!1,requestId:e,reason:"busy"})}})}async updateSelectedElements(t,e){var D,x,j,w,y,f,M,T,b,C,P,E,O,V;const r=this.genRequestId("update"),n=this.resolveViewId(t),s=e||{};if(!n)return(x=(D=this.logger)==null?void 0:D.warn)==null||x.call(D,`${Ye} updateSelectedElements rejected: no-view requestId=${r}`),{requestId:r,viewId:"",ok:!1,reason:"no-selection"};const o=this.getSelectedElements(n),a=(o==null?void 0:o.selectedIds)??[];if(!a.length)return(w=(j=this.logger)==null?void 0:j.warn)==null||w.call(j,`${Ye} updateSelectedElements rejected: no-selection requestId=${r} viewId=${n}`),{requestId:r,viewId:n,ok:!1,reason:"no-selection",selectedIds:a};const c=this.detectSelectorTransforming(n);if(c)return(f=(y=this.logger)==null?void 0:y.warn)==null||f.call(y,`${Ye} updateSelectedElements rejected: ${c} requestId=${r} viewId=${n}`),{requestId:r,viewId:n,ok:!1,reason:c,selectedIds:a};if(!Object.keys(s).some(N=>s[N]!==void 0))return(T=(M=this.logger)==null?void 0:M.warn)==null||T.call(M,`${Ye} updateSelectedElements rejected: unsupported-change requestId=${r} viewId=${n}`),{requestId:r,viewId:n,ok:!1,reason:"unsupported-change",selectedIds:a};const u=[],h=[],d=[];let g={...s};for(const N of a){const A=this.lookupToolsType(n,o==null?void 0:o.scenePath,N);if(!A){h.push(N);continue}const k=this.validateStrokeTypeForChanges(N,g,A,u);k.strokeType!==g.strokeType&&(g=k)}if(g.strokeType!==void 0){const N=a.map(k=>this.lookupToolsType(n,o==null?void 0:o.scenePath,k)).filter(k=>!!k&&Ai(k,"strokeType"));N.length>0?g.strokeType===ze.Stroke&&(N.every(U=>U===K.Pencil)||(delete g.strokeType,u.push({id:a.join(","),field:"strokeType",code:"unsupported-by-toolsType",message:"strokeType=Stroke requires all strokeType-capable selected elements to be Pencil"}))):delete g.strokeType}if(!this.collectPendingMethods(g).size)return this.flushUpdateSelectedElementsWarnings(n,r,u),(C=(b=this.logger)==null?void 0:b.warn)==null||C.call(b,`${Ye} updateSelectedElements no-valid-fields requestId=${r} viewId=${n} warnings=${u.length}`),{requestId:r,viewId:n,ok:!1,reason:"unsupported-change",selectedIds:a,skippedIds:h.length?h:void 0,warnings:u.length?u:void 0};const v=hs(g);for(const N of a){const A=this.lookupToolsType(n,o==null?void 0:o.scenePath,N),k=this.hasShapeChanges(g)&&!!g.toolsType&&A!==g.toolsType;this.hasApplicableChangesForToolsType(g,A)?d.push(N):h.includes(N)||(h.push(N),A&&v.length&&u.push({id:N,field:v.join(","),code:"unsupported-by-toolsType",toolsType:A,message:k?`selected element id=${N} toolsType=${A} skipped by requested toolsType=${g.toolsType}`:`selected element id=${N} toolsType=${A} does not support requested fields=[${v.join(",")}]`}))}const I=this.resolveShapeDispatchToolsTypes(n,o==null?void 0:o.scenePath,d,g);return d.length?((V=(O=this.logger)==null?void 0:O.info)==null||V.call(O,`${Ye} updateSelectedElements request requestId=${r} viewId=${n} scenePath=${(o==null?void 0:o.scenePath)||"-"} selectedCount=${a.length} fields=[${this.formatFieldsFromChanges(s)}]`),this.flushUpdateSelectedElementsWarnings(n,r,u),new Promise(N=>{var U,Z;const A=setTimeout(()=>{var ce,L;const Q=this.updateResolveMap.get(r);Q&&(this.updateResolveMap.delete(r),(L=(ce=this.logger)==null?void 0:ce.warn)==null||L.call(ce,`${Ye} updateSelectedElements timeout requestId=${r} viewId=${n}`),N({requestId:r,viewId:n,ok:!1,reason:"worker-failed",selectedIds:Q.selectedIds,skippedIds:Q.skippedIds.length?Q.skippedIds:void 0,warnings:Q.warnings.length?Q.warnings:void 0,geometryChanged:Q.geometryChanged}))},8e3);this.updateResolveMap.set(r,{timer:A,resolve:N,viewId:n,selectedIds:a,appliedIds:d,skippedIds:h,warnings:u,geometryChanged:!1});const k=this.captureUndoTickerDuringDispatch(n);try{this.dispatchUpdate(n,[De],g,r,I)}catch(Q){this.updateResolveMap.delete(r),clearTimeout(A),this.cancelUndoTicker(this.resolveCancelableUndoTickerId(k.getUndoTickerId(),n),n,o==null?void 0:o.scenePath),(Z=(U=this.logger)==null?void 0:U.error)==null||Z.call(U,`${Ye} updateSelectedElements dispatch failed requestId=${r} viewId=${n} err=${Q==null?void 0:Q.message}`),N({requestId:r,viewId:n,ok:!1,reason:"worker-failed",selectedIds:a,skippedIds:h.length?h:void 0,warnings:u.length?u:void 0})}finally{k.dispose()}})):(this.flushUpdateSelectedElementsWarnings(n,r,u),(E=(P=this.logger)==null?void 0:P.warn)==null||E.call(P,`${Ye} updateSelectedElements rejected: no-applicable-selection requestId=${r} viewId=${n}`),{requestId:r,viewId:n,ok:!1,reason:"unsupported-change",selectedIds:a,skippedIds:h.length?h:void 0,warnings:u.length?u:void 0})}async copySelectedElements(t){var a,c,l,u,h,d,g,p;const e=this.genRequestId("copy"),r=this.resolveViewId(t);if(!r)return(c=(a=this.logger)==null?void 0:a.warn)==null||c.call(a,`${Ye} copySelectedElements rejected: no-view requestId=${e}`),{ok:!1,requestId:e,reason:"no-selection"};const n=this.getSelectedElements(r),s=(n==null?void 0:n.selectedIds)??[];if(!s.length)return(u=(l=this.logger)==null?void 0:l.warn)==null||u.call(l,`${Ye} copySelectedElements rejected: no-selection requestId=${e} viewId=${r}`),{ok:!1,requestId:e,reason:"no-selection"};const o=this.detectSelectorTransforming(r);return o?((d=(h=this.logger)==null?void 0:h.warn)==null||d.call(h,`${Ye} copySelectedElements rejected: ${o} requestId=${e} viewId=${r}`),{ok:!1,requestId:e,reason:o}):((p=(g=this.logger)==null?void 0:g.info)==null||p.call(g,`${Ye} copySelectedElements request requestId=${e} viewId=${r} scenePath=${(n==null?void 0:n.scenePath)||"-"} selectedCount=${s.length}`),new Promise(v=>{var x,j;const I=setTimeout(()=>{var w,y;this.copyResolveMap.has(e)&&(this.copyResolveMap.delete(e),(y=(w=this.logger)==null?void 0:w.warn)==null||y.call(w,`${Ye} copySelectedElements timeout requestId=${e} viewId=${r}`),v({ok:!1,requestId:e,reason:"busy"}))},5e3);this.copyResolveMap.set(e,{timer:I,resolve:v,viewId:r,sourceSelectedIds:s});const D=this.captureUndoTickerDuringDispatch(r);try{We.emitMethod(Fe.MainEngine,Se.CopyNode,{workIds:[De],viewId:r,requestId:e})}catch(w){this.copyResolveMap.delete(e),clearTimeout(I),this.cancelUndoTicker(this.resolveCancelableUndoTickerId(D.getUndoTickerId(),r),r,n==null?void 0:n.scenePath),(j=(x=this.logger)==null?void 0:x.error)==null||j.call(x,`${Ye} copySelectedElements failed requestId=${e} viewId=${r} err=${w==null?void 0:w.message}`),v({ok:!1,requestId:e,reason:"busy"})}finally{D.dispose()}}))}async deleteSelectedElements(t){var a,c,l,u,h,d,g,p;const e=this.genRequestId("delete"),r=this.resolveViewId(t);if(!r)return(c=(a=this.logger)==null?void 0:a.warn)==null||c.call(a,`${Ye} deleteSelectedElements rejected: no-view requestId=${e}`),{ok:!1,requestId:e,reason:"no-selection"};const n=this.getSelectedElements(r),s=(n==null?void 0:n.selectedIds)??[];if(!s.length)return(u=(l=this.logger)==null?void 0:l.warn)==null||u.call(l,`${Ye} deleteSelectedElements rejected: no-selection requestId=${e} viewId=${r}`),{ok:!1,requestId:e,reason:"no-selection"};const o=this.detectSelectorTransforming(r);return o?((d=(h=this.logger)==null?void 0:h.warn)==null||d.call(h,`${Ye} deleteSelectedElements rejected: ${o} requestId=${e} viewId=${r}`),{ok:!1,requestId:e,reason:o}):((p=(g=this.logger)==null?void 0:g.info)==null||p.call(g,`${Ye} deleteSelectedElements request requestId=${e} viewId=${r} scenePath=${(n==null?void 0:n.scenePath)||"-"} selectedCount=${s.length}`),new Promise(v=>{var x,j;const I=setTimeout(()=>{var w,y;this.deleteResolveMap.has(e)&&(this.deleteResolveMap.delete(e),(y=(w=this.logger)==null?void 0:w.warn)==null||y.call(w,`${Ye} deleteSelectedElements timeout requestId=${e} viewId=${r}`),v({ok:!1,requestId:e,reason:"busy"}))},5e3);this.deleteResolveMap.set(e,{timer:I,resolve:v,viewId:r,removedIds:s.slice()});const D=this.captureUndoTickerDuringDispatch(r);try{We.emitMethod(Fe.MainEngine,Se.DeleteNode,{workIds:[De],viewId:r,requestId:e})}catch(w){this.deleteResolveMap.delete(e),clearTimeout(I),this.cancelUndoTicker(this.resolveCancelableUndoTickerId(D.getUndoTickerId(),r),r,n==null?void 0:n.scenePath),(j=(x=this.logger)==null?void 0:x.error)==null||j.call(x,`${Ye} deleteSelectedElements failed requestId=${e} viewId=${r} err=${w==null?void 0:w.message}`),v({ok:!1,requestId:e,reason:"busy"})}finally{D.dispose()}}))}async updateElement(t,e,r,n,s=!0){var p,v,I,D,x,j,w,y,f,M,T,b,C;const o=this.control.collector,a=this.control.worker;if(!o||!a||!t||!e||!r||!n)return(v=(p=this.logger)==null?void 0:p.warn)==null||v.call(p,`${Ye} updateElement ignored: invalid-args viewId=${r||"-"} scenePath=${e||"-"} elementId=${t||"-"}`),!1;const c=(I=o.isLocalId)!=null&&I.call(o,t)&&typeof o.transformKey=="function"?o.transformKey(t):t;if((D=o.isSelector)!=null&&D.call(o,c))return(j=(x=this.logger)==null?void 0:x.warn)==null||j.call(x,`${Ye} updateElement ignored: selector-not-allowed viewId=${r} scenePath=${e}`),!1;let l=(f=(y=(w=o.storage)==null?void 0:w[r])==null?void 0:y[e])==null?void 0:f[c];if(!l)return(T=(M=this.logger)==null?void 0:M.warn)==null||T.call(M,`${Ye} updateElement ignored: not-found viewId=${r} scenePath=${e} elementId=${t}`),!1;const u=l.toolsType;if(!u||n.toolsType!==u)return(C=(b=this.logger)==null?void 0:b.warn)==null||C.call(b,`${Ye} updateElement ignored: toolsType-mismatch viewId=${r} scenePath=${e} elementId=${t} declared=${n.toolsType} actual=${u}`),!1;const h=this.normalizeUpdateElementInfo(n,u),d=this.buildUpdatedElementValue(l,h),g=a.now;return s&&(a.internalMsgEmitter.emit("addUndoTicker",g,r,{render:!0,storage:!0,source:$e.AsyncUpdateElement}),a.internalMsgEmitter.emit("finalizeRequested",g,r,[c],e)),await new Promise(P=>{xr(()=>{var O,V;const E=o.plugin;E==null||E.updateAttributes([Vr.namespace,r,e,c],d),s&&(a.internalMsgEmitter.emit("ackRenderUndoTicker",g,r,e),a.internalMsgEmitter.emit("ackStorageUndoTicker",g,r,e,c)),P(!0),(V=(O=this.logger)==null?void 0:O.info)==null||V.call(O,`${Ye} updateElement notify viewId=${r} scenePath=${e} elementId=${t} toolsType=${u} fields=[${hs(h).join("/")||"-"}]`)},0,this.control.hasPolyfillMethod("requestIdleCallback")).catch(E=>{var O,V;this.cancelUndoTicker(g,r,e),(V=(O=this.logger)==null?void 0:O.warn)==null||V.call(O,`${Ye} updateElement err: ${E.message??"has unknown error"} viewId=${r} scenePath=${e} elementId=${t}`),P(!1)})})}onSelectorTransform(t){var a,c;const{viewId:e,emitEventType:r,workState:n}=t;this.control.publicMsgEmitter.emit("selectorTransformChange",t);const s=`${Ye} selectorTransformChange viewId=${e} emitEventType=${r} workState=${n}`,o=this.getDebounceLogger();o!=null&&o.infoDebounced?o.infoDebounced(`selector-transform-change:${e}`,s):(c=(a=this.logger)==null?void 0:a.info)==null||c.call(a,s)}onSelectorSync(t){var v,I,D,x;const{viewId:e,scenePath:r,selectIds:n,selectRect:s,selectorInfo:o}=t,a=n&&n.slice().sort()||[],c=this.lastSelectedIdsByView.get(e)||[],l=!this.isArrayEqual(a,c),u=s&&ve.isNumber(s.x)&&ve.isNumber(s.y)&&ve.isNumber(s.w)&&ve.isNumber(s.h)?{x:s.x,y:s.y,w:s.w,h:s.h}:void 0,d=!!this.pendingCameraChangeByView.get(e)&&!l&&!!(n!=null&&n.length);if(l){const j=this.getSelectedElements(e),w={viewId:e,scenePath:r,selectorId:De,reason:n!=null&&n.length?"select":"clear",viewRect:u,selectedIds:(j==null?void 0:j.selectedIds)??n??[],selectorInfo:o};this.lastSelectedIdsByView.set(e,a),this.control.publicMsgEmitter.emit("selectedElementsChange",w);const y=`${Ye} selectedElementsChange reason=${w.reason} viewId=${e} count=${w.selectedIds.length}`,f=this.getDebounceLogger();f!=null&&f.infoDebounced?f.infoDebounced(`selected-elements-change:${e}`,y):(I=(v=this.logger)==null?void 0:v.info)==null||I.call(v,y)}const g=this.lastViewRectByView.get(e),p=!this.isRectEqual(g,u);if(p||l){let j="selector-action",w=n!=null&&n.length?"select":"clear";d&&p?(j="camera-change",w="cameraTransform"):p&&!l&&(n!=null&&n.length)&&(w="selectorTransform"),this.lastViewRectByView.set(e,u);const y={viewId:e,scenePath:r,selectorId:De,source:j,action:w,viewRect:u};this.control.publicMsgEmitter.emit("selectorGeometryChange",y),this.logGeometry(e,w,(n==null?void 0:n.length)||0),j==="camera-change"&&this.clearPendingCameraChange(e)}if(!(n!=null&&n.length)&&l)for(const[j,w]of this.clearResolveMap.entries())w.viewId===e&&(this.clearResolveMap.delete(j),w.timer&&clearTimeout(w.timer),(x=(D=this.logger)==null?void 0:D.info)==null||x.call(D,`${Ye} blurSelector done requestId=${j} viewId=${e}`),w.resolve({ok:!0,requestId:j}))}onSelectorCleared(t){var a,c,l,u;const{viewId:e,scenePath:r,requestId:n}=t;if((this.lastSelectedIdsByView.get(e)||[]).length){const h={viewId:e,scenePath:r,selectorId:De,reason:"clear",viewRect:void 0,selectedIds:[]};this.lastSelectedIdsByView.set(e,[]),this.control.publicMsgEmitter.emit("selectedElementsChange",h);const d=`${Ye} selectedElementsChange reason=clear viewId=${e} requestId=${n||"-"}`,g=this.logger;g!=null&&g.infoDebounced?g.infoDebounced(`selected-elements-change:${e}`,d):(c=(a=this.logger)==null?void 0:a.info)==null||c.call(a,d)}if(this.lastViewRectByView.get(e)){const h={viewId:e,scenePath:r,selectorId:De,source:"selector-action",action:"clear",viewRect:void 0,requestId:n};this.lastViewRectByView.set(e,void 0),this.control.publicMsgEmitter.emit("selectorGeometryChange",h),this.logGeometry(e,"clear",0)}if(n&&this.clearResolveMap.has(n)){const h=this.clearResolveMap.get(n);this.clearResolveMap.delete(n),h.timer&&clearTimeout(h.timer),(u=(l=this.logger)==null?void 0:l.info)==null||u.call(l,`${Ye} blurSelector done requestId=${n} viewId=${e}`),h.resolve({ok:!0,requestId:n})}}onCameraChange(t){const e=this.getSelectedElements(t);if(!(e!=null&&e.selectedIds.length)){this.clearPendingCameraChange(t);return}this.setPendingCameraChange(t,{ts:Date.now(),viewRect:e.viewRect,selectedIds:e.selectedIds.slice()});let r=this.cameraEmitThrottleByView.get(t);r||(r=ve.throttle(n=>this.emitCameraGeometry(n),60,{leading:!0,trailing:!0}),this.cameraEmitThrottleByView.set(t,r)),r(t)}emitCameraGeometry(t){const e=this.getSelectedElements(t);if(!e||!e.selectedIds.length||!e.viewRect){this.clearPendingCameraChange(t);return}const r=this.lastViewRectByView.get(t);if(this.isRectEqual(r,e.viewRect))return;this.lastViewRectByView.set(t,e.viewRect);const n={viewId:t,scenePath:e.scenePath,selectorId:De,source:"camera-change",action:"cameraTransform",viewRect:e.viewRect};this.control.publicMsgEmitter.emit("selectorGeometryChange",n),this.logGeometry(t,"cameraTransform",e.selectedIds.length),this.clearPendingCameraChange(t)}bindPublicStorageListener(){this.publicStorageHandler||(this.publicStorageHandler=t=>this.onSyncStorageChange(t),this.control.publicMsgEmitter.on("syncStorageChange",this.publicStorageHandler))}unbindPublicStorageListener(){this.publicStorageHandler&&(this.control.publicMsgEmitter.off("syncStorageChange",this.publicStorageHandler),this.publicStorageHandler=void 0)}tryResolveUpdateElements(t,e,r,n){var o,a;if(!e)return;const s=this.updateResolveMap.get(e);!s||s.viewId!==t||(s.geometryChanged=s.geometryChanged||n,this.updateResolveMap.delete(e),s.timer&&clearTimeout(s.timer),(a=(o=this.logger)==null?void 0:o.info)==null||a.call(o,`${Ye} updateSelectedElements done requestId=${e} viewId=${t} type=${r} geometryChanged=${s.geometryChanged} applied=${s.appliedIds.length}`),s.resolve({requestId:e,viewId:t,ok:!0,selectedIds:s.selectedIds,appliedIds:s.appliedIds,skippedIds:s.skippedIds.length?s.skippedIds:void 0,warnings:s.warnings.length?s.warnings:void 0,geometryChanged:s.geometryChanged}))}onRemoveNodeApplied(t){var s,o;const{viewId:e,requestId:r,removeIds:n}=t;if(r){const a=this.deleteResolveMap.get(r);if(a&&a.viewId===e){const c=n!=null&&n.length?n:a.removedIds;this.deleteResolveMap.delete(r),a.timer&&clearTimeout(a.timer),(o=(s=this.logger)==null?void 0:s.info)==null||o.call(s,`${Ye} deleteSelectedElements done requestId=${r} viewId=${e} removedCount=${c.length}`),a.resolve({ok:!0,requestId:r,removedIds:c});return}}}onSyncStorageChange(t){var n,s,o;if(!t||typeof t!="object")return;const e=this.control.collector;if(!e)return;const r=e.uid;for(const[a,c]of Object.entries(t)){if(!c)continue;let l=this.lastRemoteSelectorByView.get(a);l||(l=new Map,this.lastRemoteSelectorByView.set(a,l));const u=new Set;for(const[h,d]of Object.entries(c))if(d)for(const[g,p]of Object.entries(d)){if(((n=e.isLocalId)!=null&&n.call(e,g)?g:((s=e.getLocalId)==null?void 0:s.call(e,g))??g)!==De)continue;const I=((o=e.getUidFromKey)==null?void 0:o.call(e,g))??(g.split(Rt)[0]||"");!I||I===r||(u.add(I),this.handleRemoteSelectorState(a,h,I,g,p,l))}for(const h of[...l.keys()]){if(u.has(h))continue;const d=l.get(h);if(!d||!d.selectedIds.length){l.delete(h);continue}this.handleRemoteSelectorState(a,"",h,`${h}${Rt}${De}`,void 0,l)}}}handleRemoteSelectorState(t,e,r,n,s,o){var p;const a=o.get(r)||{selectedIds:[]};let c="update",l=[],u;if(s){const v=s,I=(v.selectIds||[]).slice().sort(),D=a.selectedIds,x=!this.isArrayEqual(I,D);!D.length&&I.length?c="select":x&&!I.length?c="clear":c=x?"select":"update",l=v.selectIds||[];const j=v.selectRect||v.rect||((p=v.updateNodeOpt)==null?void 0:p.rect);j&&ve.isNumber(j.x)&&ve.isNumber(j.y)&&ve.isNumber(j.w)&&ve.isNumber(j.h)&&(u={x:j.x,y:j.y,w:j.w,h:j.h})}else{if(!a.selectedIds.length)return;c="clear",l=[],u=void 0}const h=!this.isRectEqual(a.viewRect,u);if(!!this.isArrayEqual(a.selectedIds,l)&&!h)return;o.set(r,{selectedIds:l,viewRect:u});const g={viewId:t,scenePath:e,uid:r,selectorId:n,source:"sync",action:c,viewRect:u,selectedIds:l,selectedElements:this.buildRemoteSelectedElements(t,e,r,l)};this.control.publicMsgEmitter.emit("remoteSelectorChange",g),this.logRemoteSelector(t,r,c,l.length)}logRemoteSelector(t,e,r,n){var a,c;const s=`${Ye} remoteSelectorChange uid=${e} action=${r} viewId=${t} count=${n}`,o=this.getDebounceLogger();if(o!=null&&o.infoDebounced){o.infoDebounced(`remote-selector:${t}@${e}`,s);return}(c=(a=this.logger)==null?void 0:a.info)==null||c.call(a,s)}genRequestId(t){return`${t}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}setPendingCameraChange(t,e){this.clearPendingCameraChange(t);const r=setTimeout(()=>{const n=this.pendingCameraChangeByView.get(t);(n==null?void 0:n.ts)===e.ts&&this.pendingCameraChangeByView.delete(t)},400);this.pendingCameraChangeByView.set(t,{...e,timer:r})}clearPendingCameraChange(t){const e=this.pendingCameraChangeByView.get(t);e!=null&&e.timer&&clearTimeout(e.timer),this.pendingCameraChangeByView.delete(t)}getDebounceLogger(){return this.logger}detectSelectorTransforming(t){var l,u,h,d,g;const e=this.control.worker;if(!e)return null;const r=(l=e.getLocalWorkViewId)==null?void 0:l.call(e),n=e.isLocalWorkActive===!0&&r===t,s=(u=e.currentLocalWorkData)==null?void 0:u.workState,o=(g=(d=(h=this.control.viewContainerManager.getView(t))==null?void 0:h.displayer)==null?void 0:d.vDom)==null?void 0:g.state,a=o==null?void 0:o.operationType,c=a===Se.TranslateNode||a===Se.ScaleNode||a===Se.RotateNode||a===Se.SetPoint;return n&&c&&s&&s!==ge.Pending&&s!==ge.Done||n&&c?"selector-transforming":e.isBusy===!0?"busy":null}isArrayEqual(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}isRectEqual(t,e){return!t&&!e?!0:!t||!e?!1:t.x===e.x&&t.y===e.y&&t.w===e.w&&t.h===e.h}onPropertyApplied(t){const{type:e,viewId:r,requestId:n,data:s}=t,o=e===Se.SetFontStyle&&s.fontSize!==void 0||e===Se.SetColorNode&&s.thickness!==void 0;this.tryResolveUpdateElements(r,n,e,o),o&&this.schedulePropertyGeometryEmit(r,e,n)}schedulePropertyGeometryEmit(t,e,r){const n=r?`property-geometry:${t}:${e}:${r}`:`property-geometry:${t}:${e}`,s=this.pendingPropertyGeometryByKey.get(n);s!=null&&s.timer&&clearTimeout(s.timer);const o=setTimeout(()=>{this.pendingPropertyGeometryByKey.delete(n);const a=this.getSelectedElements(t);if(!a||!a.selectedIds.length)return;const c=e===Se.SetFontStyle?"setFontStyle":"setStyle",l={viewId:t,scenePath:a.scenePath,selectorId:De,source:"property-change",action:c,viewRect:a.viewRect,requestId:r};this.lastViewRectByView.set(t,a.viewRect),this.control.publicMsgEmitter.emit("selectorGeometryChange",l),this.logGeometry(t,c,a.selectedIds.length)},0);this.pendingPropertyGeometryByKey.set(n,{timer:o,viewId:t,type:e,requestId:r})}lookupToolsType(t,e,r){var a,c,l,u;const n=this.control.collector;if(!n)return;const s=(a=n.isLocalId)!=null&&a.call(n,r)&&typeof n.transformKey=="function"?n.transformKey(r):r,o=(u=(l=(c=n.storage)==null?void 0:c[t])==null?void 0:l[e||""])==null?void 0:u[s];return o==null?void 0:o.toolsType}validateStrokeTypeForChanges(t,e,r,n){return e.strokeType===void 0?e:m0(e.strokeType)?(jg(r,e.strokeType)||n.push({id:t,field:"strokeType",code:"unsupported-by-toolsType",toolsType:r,message:`strokeType not supported by toolsType=${r} for id=${t}, skipped`}),e):(n.push({id:t,field:"strokeType",code:"unsupported-value",toolsType:r,message:`strokeType=${e.strokeType} is not a valid EStrokeType for id=${t}, skipped`}),e)}flushUpdateSelectedElementsWarnings(t,e,r){var o,a,c,l;if(!r.length)return;const n=new Map,s=new Map;for(const u of r)if(u.code==="unsupported-by-toolsType"){const h=n.get(u.field)||{ids:[],toolsTypes:[]};h.ids.push(u.id),h.toolsTypes.push(u.toolsType),n.set(u.field,h)}else if(u.code==="unsupported-value"){const h=s.get(u.field)||[];h.push(u.id),s.set(u.field,h)}for(const[u,h]of n.entries()){const d=[...new Set(h.toolsTypes.filter(Boolean))].join(","),g=[...new Set(h.ids)].join(",");(a=(o=this.logger)==null?void 0:o.warn)==null||a.call(o,`${Ye} updateSelectedElements warn unsupported-by-toolsType requestId=${e} viewId=${t} field=${u} toolsTypes=[${d}] ids=[${g}]`)}for(const[u,h]of s.entries())(l=(c=this.logger)==null?void 0:c.warn)==null||l.call(c,`${Ye} updateSelectedElements warn unsupported-value requestId=${e} viewId=${t} field=${u} ids=[${[...new Set(h)].join(",")}]`)}collectPendingMethods(t){var r,n,s,o;const e=new Set;return(t.strokeColor!==void 0||t.fillColor!==void 0||t.fontColor!==void 0||t.fontBgColor!==void 0||t.thickness!==void 0||t.strokeType!==void 0)&&e.add(Se.SetColorNode),(t.fontSize!==void 0||t.bold!==void 0||t.italic!==void 0||t.underline!==void 0||t.lineThrough!==void 0)&&e.add(Se.SetFontStyle),t.isLocked!==void 0&&e.add(Se.SetLock),t.zIndexLayer!==void 0&&e.add(Se.ZIndexNode),(((r=t.shape)==null?void 0:r.vertices)!==void 0||((n=t.shape)==null?void 0:n.innerVerticeStep)!==void 0||((s=t.shape)==null?void 0:s.innerRatio)!==void 0||((o=t.shape)==null?void 0:o.placement)!==void 0)&&e.add(Se.SetShapeOpt),e}hasApplicableChangesForToolsType(t,e){return e?hs(t).some(r=>r.startsWith("shape.")&&t.toolsType&&e!==t.toolsType?!1:Ai(e,r)):!1}buildUpdatedElementValue(t,e){var o,a,c,l;const r=e,n={...t,opt:t.opt?{...t.opt}:void 0},s=n.opt||{};return r.strokeColor!==void 0&&(s.strokeColor=r.strokeColor),r.fillColor!==void 0&&(s.fillColor=r.fillColor),r.thickness!==void 0&&(s.thickness=r.thickness),r.strokeType!==void 0&&(s.strokeType=r.strokeType),r.fontColor!==void 0&&(s.fontColor=r.fontColor),r.fontBgColor!==void 0&&(s.fontBgColor=r.fontBgColor),r.fontSize!==void 0&&(s.fontSize=r.fontSize),r.bold!==void 0&&(s.bold=r.bold),r.italic!==void 0&&(s.italic=r.italic),r.underline!==void 0&&(s.underline=r.underline),r.lineThrough!==void 0&&(s.lineThrough=r.lineThrough),r.isLocked!==void 0&&(s.locked=r.isLocked),((o=r.shape)==null?void 0:o.vertices)!==void 0&&(s.vertices=r.shape.vertices),((a=r.shape)==null?void 0:a.innerVerticeStep)!==void 0&&(s.innerVerticeStep=r.shape.innerVerticeStep),((c=r.shape)==null?void 0:c.innerRatio)!==void 0&&(s.innerRatio=r.shape.innerRatio),((l=r.shape)==null?void 0:l.placement)!==void 0&&(s.placement=r.shape.placement),n.opt=s,r.zIndexLayer!==void 0&&(n.updateNodeOpt={...n.updateNodeOpt||{},zIndexLayer:r.zIndexLayer}),n}normalizeUpdateElementInfo(t,e){var d,g;const r={...t},n=[],s=p=>{var v,I;p in r&&(delete r[p],n.push(p),(I=(v=this.logger)==null?void 0:v.warn)==null||I.call(v,`${Ye} updateElement warn unsupported-by-toolsType toolsType=${e} field=${p}`))},o=p=>{var v,I;r.shape&&p in r.shape&&(delete r.shape[p],n.push(`shape.${p}`),(I=(v=this.logger)==null?void 0:v.warn)==null||I.call(v,`${Ye} updateElement warn unsupported-by-toolsType toolsType=${e} field=shape.${p}`)),r.shape&&!Object.keys(r.shape).length&&delete r.shape},a=p=>{var v,I;p in r&&(n.push(p),(I=(v=this.logger)==null?void 0:v.warn)==null||I.call(v,`${Ye} updateElement warn invalid-format toolsType=${e} field=${p} value=${JSON.stringify(r[p])}`),delete r[p])},c=p=>{var v,I;!r.shape||!(p in r.shape)||(n.push(`shape.${p}`),(I=(v=this.logger)==null?void 0:v.warn)==null||I.call(v,`${Ye} updateElement warn invalid-format toolsType=${e} field=shape.${p} value=${JSON.stringify(r.shape[p])}`),delete r.shape[p],Object.keys(r.shape).length||delete r.shape)};"strokeColor"in r&&typeof r.strokeColor!="string"&&a("strokeColor"),"fillColor"in r&&typeof r.fillColor!="string"&&a("fillColor"),"fontColor"in r&&typeof r.fontColor!="string"&&a("fontColor"),"fontBgColor"in r&&typeof r.fontBgColor!="string"&&a("fontBgColor"),"thickness"in r&&!Number.isFinite(r.thickness)&&a("thickness"),"fontSize"in r&&!Number.isFinite(r.fontSize)&&a("fontSize"),"strokeType"in r&&!Object.values(ze).includes(r.strokeType)&&a("strokeType"),"strokeType"in r&&r.strokeType!==void 0&&!jg(e,r.strokeType)&&s("strokeType"),"bold"in r&&!$ve.includes(r.bold)&&a("bold"),"italic"in r&&!Vve.includes(r.italic)&&a("italic"),"underline"in r&&typeof r.underline!="boolean"&&a("underline"),"lineThrough"in r&&typeof r.lineThrough!="boolean"&&a("lineThrough"),"isLocked"in r&&typeof r.isLocked!="boolean"&&a("isLocked"),"zIndexLayer"in r&&![Mn.Top,Mn.Bottom].includes(r.zIndexLayer)&&a("zIndexLayer"),r.shape&&("vertices"in r.shape&&!Number.isFinite(r.shape.vertices)&&c("vertices"),"innerVerticeStep"in r.shape&&!Number.isFinite(r.shape.innerVerticeStep)&&c("innerVerticeStep"),"innerRatio"in r.shape&&!Number.isFinite(r.shape.innerRatio)&&c("innerRatio"),"placement"in r.shape&&!Yve.includes(r.shape.placement)&&c("placement"));const l=new Set(ame(e));return["strokeColor","fillColor","thickness","strokeType","fontColor","fontBgColor","fontSize","bold","italic","underline","lineThrough","isLocked","zIndexLayer"].forEach(p=>{l.has(p)||s(p)}),["vertices","innerVerticeStep","innerRatio","placement"].forEach(p=>{l.has(`shape.${p}`)||o(p)}),n.length&&((g=(d=this.logger)==null?void 0:d.info)==null||g.call(d,`${Ye} updateElement filtered toolsType=${e} dropped=[${n.join(",")}]`)),r}dispatchUpdate(t,e,r,n,s=[]){const o=Fe.MainEngine,a={};r.strokeColor!==void 0&&(a.strokeColor=r.strokeColor),r.fillColor!==void 0&&(a.fillColor=r.fillColor),r.fontColor!==void 0&&(a.fontColor=r.fontColor),r.fontBgColor!==void 0&&(a.fontBgColor=r.fontBgColor),r.thickness!==void 0&&(a.thickness=r.thickness),r.strokeType!==void 0&&(a.strokeType=r.strokeType),Object.keys(a).length&&We.emitMethod(o,Se.SetColorNode,{workIds:e,viewId:t,requestId:n,workState:ge.Done,...a});const c={};if(r.fontSize!==void 0&&(c.fontSize=r.fontSize),r.bold!==void 0&&(c.bold=r.bold),r.italic!==void 0&&(c.italic=r.italic),r.underline!==void 0&&(c.underline=r.underline),r.lineThrough!==void 0&&(c.lineThrough=r.lineThrough),Object.keys(c).length&&We.emitMethod(o,Se.SetFontStyle,{workIds:e,viewId:t,requestId:n,workState:ge.Done,...c}),r.isLocked!==void 0&&We.emitMethod(o,Se.SetLock,{workIds:e,viewId:t,requestId:n,workState:ge.Done,isLocked:r.isLocked}),r.zIndexLayer!==void 0&&We.emitMethod(o,Se.ZIndexNode,{workIds:e,viewId:t,requestId:n,workState:ge.Done,layer:r.zIndexLayer}),r.shape){const l={};if(r.shape.vertices!==void 0&&(l.vertices=r.shape.vertices),r.shape.innerVerticeStep!==void 0&&(l.innerVerticeStep=r.shape.innerVerticeStep),r.shape.innerRatio!==void 0&&(l.innerRatio=r.shape.innerRatio),r.shape.placement!==void 0&&(l.placement=r.shape.placement),Object.keys(l).length){if(!s.length)return;s.forEach(u=>{We.emitMethod(o,Se.SetShapeOpt,{workIds:e,viewId:t,toolsType:u,requestId:n,workState:ge.Done,...l})})}}}buildSelectedElementInfo(t,e,r,n){var v,I,D;const s=this.control.collector,o=s&&s.isLocalId(r)?s.transformKey(r):r,a=(D=(I=(v=s==null?void 0:s.storage)==null?void 0:v[t])==null?void 0:I[e||""])==null?void 0:D[o];if(!a)return;const c=a.toolsType,l=a.opt,u=a.updateNodeOpt||{},h={};(l==null?void 0:l.strokeColor)!==void 0&&(h.strokeColor=l.strokeColor),(l==null?void 0:l.fillColor)!==void 0&&(h.fillColor=l.fillColor),(l==null?void 0:l.thickness)!==void 0&&(h.thickness=l.thickness),(l==null?void 0:l.strokeType)!==void 0&&(h.strokeType=l.strokeType),(l==null?void 0:l.fontColor)!==void 0&&(h.fontColor=l.fontColor),(l==null?void 0:l.fontBgColor)!==void 0&&(h.fontBgColor=l.fontBgColor),(l==null?void 0:l.zIndex)!==void 0&&(h.zIndex=l.zIndex);const d={id:r,toolsType:c,style:h};if(n&&(ve.isBoolean(n.canRotate)&&(d.canRotate=n.canRotate),ve.isBoolean(n.canLock)&&(d.canLock=n.canLock),n.scaleType&&(d.scaleType=n.scaleType),ve.isBoolean(n.isLocked)&&(d.isLocked=n.isLocked)),c===K.Text&&l){const x=l,j={text:x.text,fontSize:x.fontSize,fontFamily:x.fontFamily,bold:x.bold,italic:x.italic,underline:x.underline,lineThrough:x.lineThrough,textAlign:x.textAlign,verticalAlign:x.verticalAlign,boxPoint:x.boxPoint,boxSize:x.boxSize};d.text=j}if(c===K.Polygon){const x=l;d.shape={vertices:x.vertices}}else if(c===K.Star){const x=l;d.shape={vertices:x.vertices,innerVerticeStep:x.innerVerticeStep,innerRatio:x.innerRatio}}else if(c===K.SpeechBalloon){const x=l;d.shape={placement:x.placement}}const g=u.rect;g&&(d.rect={x:g.x,y:g.y,w:g.w,h:g.h});const p=u.centerPos;return p&&(d.centerPos=p),d}buildRemoteSelectedElements(t,e,r,n){if(!n.length)return[];const s=[];for(const o of n){const a=this.buildSelectedElementInfo(t,e,`${r}${Rt}${o}`,void 0);a&&(a.id=o,s.push(a))}return s}logGeometry(t,e,r){var a,c;const n=`${Ye} selectorGeometryChange action=${e} viewId=${t} count=${r}`,s=this.getDebounceLogger();if((e==="select"||e==="selectorTransform"||e==="cameraTransform")&&s!=null&&s.infoDebounced){s.infoDebounced(`selector-geometry:${t}:${e}`,n);return}(c=(a=this.logger)==null?void 0:a.info)==null||c.call(a,n)}}async function Hve({previousScenePath:i,attemptedScenePath:t,getCurrentScenePath:e,getTargetScenePath:r,yieldToNextTask:n=()=>new Promise(s=>window.setTimeout(s,0))}){const s=e(),o=r();if(s===o)return!1;if(s!==i||o!==t)return!0;await n();const a=e(),c=r();return a===c?!1:a!==i||c!==t}const ir=class ir{constructor(t){R(this,"backgroundImageLoadCoordinator");R(this,"toolChangePending",!1);R(this,"toolChangePendingTimer");R(this,"pendingSceneChecks",new Set);R(this,"pendingSceneChanges",new Map);R(this,"pendingClears",new Map);R(this,"clearQueueByView",new Map);R(this,"viewOperationQueueByView",new Map);R(this,"lifecycleGeneration",0);R(this,"viewLifecycleGeneration",new Map);R(this,"version",oc);R(this,"plugin");R(this,"logger");R(this,"syncLogger");R(this,"room");R(this,"play");R(this,"collector");R(this,"hasSwitchToSelectorEffect");R(this,"snapshootStateMap");R(this,"_disableDeviceInputs");R(this,"_disableEraseImage");R(this,"_disableEraseText");R(this,"_disableCameraTransform");R(this,"initFontFaceTextRenderGate",!1);R(this,"initFontFaceTextRenderSkipped",!1);R(this,"effectResolve");R(this,"hotkeyManager");R(this,"pluginOptions");R(this,"renderMode");R(this,"renderingCompatibilityDecision");R(this,"roomMember");R(this,"cursor");R(this,"textEditorManager");R(this,"worker");R(this,"renderControl");R(this,"miniMapManager");R(this,"pluginManager");R(this,"onInitLoadingChange");R(this,"selectorApi");R(this,"_isPolyfill",{requestIdleCallback:!1,cancelIdleCallback:!1});R(this,"onSceneChange",(t,e)=>{var s,o,a;if(!this.worker.isViewInitAck(e))return Promise.resolve();let r=this.pendingSceneChanges.get(e);r?(r.targetScenePath=t,r.isSceneBusy=!0,(s=r.deferredCamera)!=null&&s.scenePath&&r.deferredCamera.scenePath!==t&&(r.deferredCamera=void 0)):(r={targetScenePath:t,isSceneBusy:!0,running:!1,waiters:new Set},this.pendingSceneChanges.set(e,r)),this.worker.cameraUpdateDestroy(e),(a=(o=this.viewContainerManager.getView(e))==null?void 0:o.displayer)==null||a.setActive(!1);const n=new Promise(c=>{r==null||r.waiters.add(c)});return r.running||(r.running=!0,this.consumePendingSceneChanges(e,r).catch(c=>{var l,u;(u=(l=this.logger)==null?void 0:l.error)==null||u.call(l,`[Appliance]: scene change failed viewId=${e} scenePath=${(r==null?void 0:r.targetScenePath)||""} error=${(c==null?void 0:c.message)||c}`)})),n});R(this,"onRoomMembersChange",t=>{this.roomMember.setRoomMembers(Wo(t))});R(this,"onMemberChange",ve.throttle(t=>{var o,a;if(this.setToolChangePending(!1,"member-change"),!this.room||!this.worker||!t||!this.room.isWritable)return;const e=this.getToolsKey(t),r=(o=this.worker.getCurrentToolsData())==null?void 0:o.toolsType,n=this.viewContainerManager.focuedViewId;n&&r===K.Selector&&e!==K.Selector&&this.worker.blurCursor(n);const s=this.getToolsOpt(e,t);this.worker.setCurrentToolsData(s),(a=this.pluginManager)==null||a.dispatchPluginEvent("setToolkey",e),this.effectViewContainer(e),this.effectResolve&&this.effectResolve(!0)},100,{leading:!1}));R(this,"internalSceneChange",(t,e)=>{var r,n,s,o;this.worker.isViewInitAck(t)&&(this.isUseSimple||((r=this.miniMapManager)==null?void 0:r.activeViewId)===t&&((n=this.miniMapManager)==null||n.destroyMiniMap(t)),(s=this.pluginManager)==null||s.dispatchPluginEvent("sceneChange",t,e),(o=this.worker)==null||o.clearViewScenePath(t,!0).then(()=>{var a;(a=this.worker)==null||a.pullServiceData(t,e,{isAsync:!0,useAnimation:!1})}))});R(this,"internalCameraChange",(t,e)=>{var r,n;(r=this.worker)==null||r.updateCamera(t,e),this.isUseSimple||(n=this.miniMapManager)==null||n.updateViewCamera(t,e)});var v,I;const{displayer:e,plugin:r,options:n,onInitLoadingChange:s}=t;this.plugin=r,this.onInitLoadingChange=s,this.room=Le(e)?e:void 0,this.play=bu(e)?e:void 0;let o;this.room&&(o=(v=this.room)==null?void 0:v.logger,this._disableDeviceInputs=this.room.disableDeviceInputs,this._disableEraseImage=this.room.disableEraseImage,this._disableEraseText=!1);const a=!!(n.cdn.fullWorkerUrl&&n.cdn.subWorkerUrl),c=ps(He.workerRenderModeBlacklist,n.extras.workerRenderModeBlacklist,"renderMode"),l=ps(He.workerCanvasContextBlacklist,n.extras.workerCanvasContextBlacklist,"canvasContext"),u=ps(He.workerMaskTextureFormatBlacklist,n.extras.workerMaskTextureFormatBlacklist,"maskTextureFormat"),h=ps(He.workerMaskTextureUploadBlacklist,n.extras.workerMaskTextureUploadBlacklist,"maskTextureUpload"),d=ps(He.workerImageBitmapFeatureBlacklist,n.extras.workerImageBitmapFeatureBlacklist,"imageBitmapFeature");this.renderingCompatibilityDecision=Ove({useWorker:n.extras.useWorker,useSimple:n.extras.useSimple,requestedContextType:(I=n.extras.canvasOpt)==null?void 0:I.contextType,workerRenderModeBlacklist:c,workerCanvasContextBlacklist:l,workerMaskTextureFormatBlacklist:u,workerMaskTextureUploadBlacklist:h,workerImageBitmapFeatureBlacklist:d,workerUrl:a}),this.pluginOptions={...n,extras:{...n.extras,canvasOpt:n.extras.canvasOpt,workerRenderModeBlacklist:c,workerCanvasContextBlacklist:l,workerMaskTextureFormatBlacklist:u,workerMaskTextureUploadBlacklist:h,workerImageBitmapFeatureBlacklist:d}},this.backgroundImageLoadCoordinator=new Wfe(this.pluginOptions.extras.backgroundImageLoadOptions,this.pluginOptions.extras.onBackgroundImageLoadEvent),this.renderMode=this.renderingCompatibilityDecision.renderMode,this.roomMember=new u0e;const g={control:this,internalMsgEmitter:ir.InternalMsgEmitter,publicMsgEmitter:ir.PublicMsgEmitter};this.cursor=new h0e(g),this.textEditorManager=new Kpe(g),this.worker=new Sve(g),this.hotkeyManager=new Ive(g),this.renderControl=new zve(g),this.pluginManager=new ip.PluginManager(g),this.isUseSimple||(this.miniMapManager=new jve(g)),this.logger=new $h(o);const p=this.pluginOptions.extras.syncLogger.batchWindowMs??He.syncLogger.batchWindowMs;this.syncLogger=new bve(this.logger,p>0?p:He.syncLogger.batchWindowMs)}get publicMsgEmitter(){return ir.PublicMsgEmitter}get internalMsgEmitter(){return ir.InternalMsgEmitter}emitInitLoadingChange(t){var e,r,n;try{(e=this.onInitLoadingChange)==null||e.call(this,t)}catch(s){(n=(r=this.logger)==null?void 0:r.error)==null||n.call(r,`[Appliance]: onInitLoadingChange error: ${(s==null?void 0:s.message)||s}`)}}emitFontFaceLoadState(t){var e,r;try{this.publicMsgEmitter.emit("fontFaceLoadState",t)}catch(n){(r=(e=this.logger)==null?void 0:e.error)==null||r.call(e,`[Appliance]: fontFaceLoadState listener error: ${(n==null?void 0:n.message)||n}`)}}emitFontFaceRenderState(t){var e,r;try{this.publicMsgEmitter.emit("fontFaceRenderState",t)}catch(n){(r=(e=this.logger)==null?void 0:e.error)==null||r.call(e,`[Appliance]: fontFaceRenderState listener error: ${(n==null?void 0:n.message)||n}`)}}hasPolyfillMethod(t){return this._isPolyfill[t]}registerPolyfillMethod(t){this._isPolyfill[t]=!0}get hasExtendFontFaces(){return this.extendFontFaces.length>0}get extendFontFaces(){var t;return((t=this.pluginOptions.extras.textEditor)==null?void 0:t.extendFontFaces)??He.textEditor.extendFontFaces}get loadFontFacesTimeout(){var t;return((t=this.pluginOptions.extras.textEditor)==null?void 0:t.loadFontFacesTimeout)??He.textEditor.loadFontFacesTimeout}loadFontFaces(){return this.worker.loadFontFaces()}beginInitFontFaceTextRenderGate(){this.initFontFaceTextRenderGate=!0,this.initFontFaceTextRenderSkipped=!1}markInitFontFaceTextRenderSkipped(){this.initFontFaceTextRenderGate&&(this.initFontFaceTextRenderSkipped=!0)}shouldHoldServiceTextRenderForFontFace(){return this.initFontFaceTextRenderGate}hasInitFontFaceTextRenderSkipped(){return this.initFontFaceTextRenderSkipped}endInitFontFaceTextRenderGate(){this.initFontFaceTextRenderGate=!1,this.initFontFaceTextRenderSkipped=!1}startInitFontFaceLoadAndRender(){this.hasExtendFontFaces&&(this.beginInitFontFaceTextRenderGate(),setTimeout(()=>{this.loadFontFaces().then(t=>{if(t.status==="success"&&(!this.worker.getLastFontFacesAlreadyReady()||this.hasInitFontFaceTextRenderSkipped()))return this.refreshTextRender()}).catch(t=>{var e,r;(r=(e=this.logger)==null?void 0:e.error)==null||r.call(e,`[Appliance]: init font face load and render failed: ${(t==null?void 0:t.message)||t}`)}).finally(()=>{this.endInitFontFaceTextRenderGate()})},0))}waitNextFrame(){return new Promise(t=>requestAnimationFrame(()=>t()))}getSortedRefreshViews(){const t=this.viewContainerManager.getAllViews().filter(r=>!!r),e=this.viewContainerManager.focuedViewId;return t.sort((r,n)=>r.id===e?-1:n.id===e?1:0)}escapeCssIdentifier(t){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(t):t.replace(/([ #;?%&,.+*~':"!^$[\]()=>|/@])/g,"\\$1")}getTextEditorElement(t,e){var s;const r=`.editor-box #${this.escapeCssIdentifier(e)}`,n=[];t.container&&n.push(t.container),(s=t.viewData)!=null&&s.divElement&&n.push(t.viewData.divElement),t.displayer.eventTragetElement&&n.push(t.displayer.eventTragetElement),n.push(document);for(const o of n){const a=o.querySelector(r);if(a)return a}return document.getElementById(e)}measureViewTextEditorsForRender(t){const e=this.viewContainerManager.getView(t);if(!e)return{changed:!1,tasks:[]};let r=!1;const n=[];return this.textEditorManager.filterEditor(t).forEach((o,a)=>{const c=this.getTextEditorElement(e,a);let l=o.opt;if(c){const h=[c.offsetWidth,c.offsetHeight];h[0]&&h[1]&&!ve.isEqual(o.opt.boxSize,h)&&(l={...o.opt,boxSize:h},this.textEditorManager.updateForViewEdited(a,{...o,opt:l,canSync:!1,canWorker:!1,skipStorageDispatch:!0}),r=!0)}const u=this.textEditorManager.get(a)||o;n.push({viewId:t,scenePath:u.scenePath,workId:a,opt:u.opt})}),{changed:r,tasks:n}}async refreshViewTextRenderInternal(t){const e=this.viewContainerManager.getView(t),r=e==null?void 0:e.focusScenePath;if(!r||!this.collector)return{status:"error"};const n=this.collector.getStorageData(t,r);if(this.textEditorManager.clear(t,!0),n)for(const c of Object.keys(n)){const l=n[c];if(!l||l.toolsType!==K.Text)continue;const u=l.type;if(!u||!this.renderControl.isFilterAble({viewId:t,elementId:c,scenePath:r},u))continue;const h={...l,workId:this.collector.isOwn(c)?this.collector.getLocalId(c):c,msgType:u,dataType:Ee.Service,viewId:t,scenePath:r};this.textEditorManager.deriveTextEditorInfoFromServiceData(h,{canWorker:!1,canSync:!1,updateView:!1})}await this.viewContainerManager.renderTextEditorInfoAsync(t,this.textEditorManager.activeId),await this.waitNextFrame();const{changed:s,tasks:o}=this.measureViewTextEditorsForRender(t);return s&&(await this.viewContainerManager.renderTextEditorInfoAsync(t,this.textEditorManager.activeId),await this.waitNextFrame()),{status:await this.worker.refreshTextRenderForWorker(o)?"success":"error"}}async refreshViewTextRender(t,e=!0){var r,n;e&&this.emitFontFaceRenderState({status:"start"});try{const s=await this.refreshViewTextRenderInternal(t);return e&&this.emitFontFaceRenderState({status:s.status==="success"?"success":"error"}),s}catch(s){return(n=(r=this.logger)==null?void 0:r.error)==null||n.call(r,`[Appliance]: refreshViewTextRender failed: ${(s==null?void 0:s.message)||s}`),e&&this.emitFontFaceRenderState({status:"error"}),{status:"error"}}}async refreshTextRender(){var e,r;this.emitFontFaceRenderState({status:"start"});let t="success";try{for(const n of this.getSortedRefreshViews())(await this.refreshViewTextRenderInternal(n.id)).status==="error"&&(t="error");return this.emitFontFaceRenderState({status:t}),{status:t}}catch(n){return(r=(e=this.logger)==null?void 0:e.error)==null||r.call(e,`[Appliance]: refreshTextRender failed: ${(n==null?void 0:n.message)||n}`),this.emitFontFaceRenderState({status:"error"}),{status:"error"}}}async refreshViewRender(t){var e,r;try{const n=this.viewContainerManager.getView(t),s=n==null?void 0:n.focusScenePath;return s?(await this.worker.clearViewScenePath(t,!0),this.worker.pullServiceData(t,s,{isAsync:!0,useAnimation:!1}),await this.viewContainerManager.updateTextEditorInfoAsync(t,this.textEditorManager.activeId),await this.waitNextFrame(),{status:"success"}):{status:"error"}}catch(n){return(r=(e=this.logger)==null?void 0:e.error)==null||r.call(e,`[Appliance]: refreshViewRender failed: ${(n==null?void 0:n.message)||n}`),{status:"error"}}}async refreshRender(){let t="success";for(const e of this.getSortedRefreshViews())(await this.refreshViewRender(e.id)).status==="error"&&(t="error");return{status:t}}get disableEraseText(){return this._disableEraseText||!1}set disableEraseText(t){this._disableEraseText=t}get disableEraseImage(){return this._disableEraseImage||!1}set disableEraseImage(t){this._disableEraseImage=t,this.room.disableEraseImage=t}get disableDeviceInputs(){return this._disableDeviceInputs||!1}set disableDeviceInputs(t){var r;this._disableDeviceInputs=t;const e=(r=this.worker.getCurrentToolsData())==null?void 0:r.toolsType;e&&this.effectViewContainer(e)}get disableCameraTransform(){return this._disableCameraTransform||!1}set disableCameraTransform(t){this._disableCameraTransform=t,this.room.disableCameraTransform=t}get disableUseWorker(){return this.renderMode==="main-thread"}get hasOffscreenCanvas(){return this.renderMode!=="main-thread"}get isUseOffscreenTransfer(){return this.renderMode==="worker-offscreen-transfer"}isServiceSyncReady(t){return this.worker.isServiceSyncReady(t)}applyWorkerRenderProbe(t){const e=this.renderingCompatibilityDecision;e.workerProbe=t?"passed":"failed",!t&&this.renderMode!=="main-thread"&&(this.renderMode="main-thread",e.renderMode="main-thread",e.contextType="2d",e.reason="worker-capability-missing",e.issues=[...e.issues,"Worker owner-side render capability probe failed"]),this.logFinalRenderDecision()}logFinalRenderDecision(){const t=this.renderingCompatibilityDecision;this.logger.info(`[Appliance]: [render-capabilities] ${JSON.stringify({renderMode:t.renderMode,contextType:t.contextType,reason:t.reason,workerProbe:t.workerProbe,issues:t.issues})}`)}get isUseSimple(){return this.pluginOptions.extras.useSimple}get isUseBackgroundThread(){return this.pluginOptions.extras.useBackgroundThread}bindPlugin(t){this.plugin=t,this.collector&&(this.collector.removeStorageStateListener(),this.collector.removeAuthStateListener()),this.collector=new Vr(this,t,this.pluginOptions.extras.syncOpt.interval),this.activePlugin(),this.selectorApi&&this.selectorApi.destroy(),this.selectorApi=new Gve(this)}destroy(){var t,e,r,n,s,o,a,c;this.backgroundImageLoadCoordinator.cancelAll(),this.lifecycleGeneration++,this.viewLifecycleGeneration.forEach((l,u)=>{this.viewLifecycleGeneration.set(u,this.viewLifecycleGeneration.get(u)+1)}),this.syncLogger.destroy(),this.pendingSceneChecks.clear(),this.pendingSceneChanges.forEach(l=>{l.waiters.forEach(u=>u())}),this.pendingSceneChanges.clear(),this.pendingClears.clear(),this.clearQueueByView.clear(),this.viewOperationQueueByView.clear(),this.roomMember.destroy(),(t=this.collector)==null||t.destroy(),(e=this.worker)==null||e.destroy(),(r=this.viewContainerManager)==null||r.destroy(),(n=this.cursor)==null||n.destroy(),(s=this.textEditorManager)==null||s.destory(),(o=this.pluginManager)==null||o.destroy(),(a=this.miniMapManager)==null||a.destroyMiniMap(),(c=this.selectorApi)==null||c.destroy(),this.selectorApi=void 0}async cleanCurrentScene(t=!0){const e=this.worker.getLocalWorkViewId()||this.viewContainerManager.focuedViewId;if(!e)return;const r=this.lifecycleGeneration,n=this.viewLifecycleGeneration.get(e)||0,s=()=>{const u=this.lifecycleGeneration,h=this.viewLifecycleGeneration.get(e)||0,d=this.viewContainerManager.getView(e);return r===u&&h===n&&!!d};let o=this.pendingClears.get(e);o?o.isClearBusy=!0:(o={isClearBusy:!0},this.pendingClears.set(e,o));const a=this.enqueueViewOperation(e,async()=>{var p,v;const u=this.viewContainerManager.getCurScenePath(e);if(!u||(await this.worker.waitForCameraUpdateEnd(e),!s())||t&&(await this.worker.flushActiveTransactionBeforeOperation(e,u,"clean-scene"),!s()))return;const h=this.worker.now;ir.InternalMsgEmitter.emit("addUndoTicker",h,e,{render:!0,storage:!0,source:$e.Clear}),ir.InternalMsgEmitter.emit("finalizeRequested",h,e,[_n],u);const d=(v=(p=this.viewContainerManager.getView(e))==null?void 0:p.displayer)==null?void 0:v.commiter,g=d==null?void 0:d.getPendingTickerSnapshots(u).find(I=>I.tickerId===h);if(await this.worker.clearViewScenePath(e,!1,!0),!!s()&&(ir.InternalMsgEmitter.emit("ackRenderUndoTicker",h,e,u),ir.InternalMsgEmitter.emit("ackStorageUndoTicker",h,e,u,_n),g&&d)){const I=Math.max((this.pluginOptions.extras.undoRedo.ackTimeout||5e3)+1e3,6e3);if(await d.waitForUndoStackEnd(g,I),!s())return}}),c=a.catch(()=>{});this.clearQueueByView.set(e,c);let l=!1;try{await a,l=!0}catch(u){throw u}finally{if(this.clearQueueByView.get(e)===c){this.clearQueueByView.delete(e);const u=this.pendingClears.get(e);this.pendingClears.delete(e),l&&(u!=null&&u.deferredCamera)?this.worker.updateCamera(e,u.deferredCamera):l&&!this.isSceneBusy(e)&&this.worker.recoverAfterSceneChange(e)}}}isClearBusy(t){var e;return((e=this.pendingClears.get(t))==null?void 0:e.isClearBusy)===!0}deferClearCamera(t,e){const r=this.pendingClears.get(t);r!=null&&r.isClearBusy&&(r.deferredCamera=e)}enqueueViewOperation(t,e){const n=(this.viewOperationQueueByView.get(t)||Promise.resolve()).then(()=>e()),s=n.catch(()=>{});this.viewOperationQueueByView.set(t,s);const o=()=>{this.viewOperationQueueByView.get(t)===s&&this.viewOperationQueueByView.delete(t)};return n.then(o,o),n}async setWritable(t){var e,r;if(!t){(e=this.cursor)==null||e.unabled(),this.textEditorManager.checkEmptyTextBlur();const n=this.viewContainerManager.getAllViews();for(const s of n){s!=null&&s.focusScenePath&&(r=this.collector)!=null&&r.hasSelector(s.id,s.focusScenePath)&&this.worker.blurSelector(s.id,s.focusScenePath);const o=s==null?void 0:s.displayer;o&&(o.setActive(!1),await o.stopEventHandler())}}await new Promise(n=>{setTimeout(()=>{n()},500)})}onWritableChange(t){var n;t?this.worker.abled():this.worker.unWritable(),((n=this.worker.getCurrentToolsData())==null?void 0:n.toolsType)===K.Text&&this.viewContainerManager.focuedViewId&&(t?this.viewContainerManager.activeTextEditor(this.viewContainerManager.focuedViewId):this.viewContainerManager.unActiveTextEditor(this.viewContainerManager.focuedViewId)),this.renderControl.onWritableChange(t),this.viewContainerManager.getAllViews().forEach(s=>{const o=s==null?void 0:s.displayer;o&&(o.bindToolsClass(),t?o.setActive(!0):o.setActive(!1))})}async consumePendingSceneChanges(t,e){var r,n,s;try{for(;this.pendingSceneChanges.get(t)===e;){const o=(r=this.viewContainerManager.getView(t))==null?void 0:r.focusScenePath,a=e.targetScenePath;if(!o||o===a||(await this.applySceneChange(t,o,e),!await Hve({previousScenePath:o,attemptedScenePath:a,getCurrentScenePath:()=>{var l;return(l=this.viewContainerManager.getView(t))==null?void 0:l.focusScenePath},getTargetScenePath:()=>e.targetScenePath})))break}}finally{const o=this.pendingSceneChanges.get(t)===e,a=o?e.deferredCamera:void 0;e.running=!1,e.isSceneBusy=!1,o&&this.pendingSceneChanges.delete(t),o&&((s=(n=this.viewContainerManager.getView(t))==null?void 0:n.displayer)==null||s.setActive(!0)),e.waiters.forEach(c=>c()),e.waiters.clear(),o&&a&&(!a.scenePath||a.scenePath===e.targetScenePath)?this.worker.updateCamera(t,a.cameraOpt):o&&this.worker.recoverAfterSceneChange(t)}}isSceneBusy(t){var e;return((e=this.pendingSceneChanges.get(t))==null?void 0:e.isSceneBusy)===!0}deferSceneCamera(t,e){const r=this.pendingSceneChanges.get(t);r!=null&&r.isSceneBusy&&(r.deferredCamera={cameraOpt:e,scenePath:this.viewContainerManager.getCurScenePath(t)})}destroySceneChange(t){this.viewLifecycleGeneration.set(t,(this.viewLifecycleGeneration.get(t)||0)+1);const e=this.pendingSceneChanges.get(t);this.pendingClears.delete(t),e&&(e.isSceneBusy=!1,e.waiters.forEach(r=>r()),e.waiters.clear(),this.pendingSceneChanges.delete(t))}async applySceneChange(t,e,r){await this.enqueueViewOperation(t,()=>this.applySceneChangeExclusive(t,e,r))}async applySceneChangeExclusive(t,e,r){var u;const n=this.lifecycleGeneration,s=this.viewLifecycleGeneration.get(t)||0,o=()=>n===this.lifecycleGeneration&&(this.viewLifecycleGeneration.get(t)||0)===s&&!!this.viewContainerManager.getView(t),a=this.viewContainerManager.getView(t);this.textEditorManager.checkEmptyTextBlur();const c=a==null?void 0:a.displayer;if(c&&c.setActive(!1),await this.worker.flushActiveTransactionBeforeOperation(t,e,"scene-change"),!o())return;const l=r.targetScenePath;l!==e&&(this.pendingSceneChecks.add(this.getPendingSceneCheckKey(t,e)),await this.reconcileSceneStorageIfPending(t,l),o()&&((u=this.collector)!=null&&u.hasSelector(t,e)&&this.worker.blurSelector(t,e),this.viewContainerManager.setViewScenePath(t,l),this.schedulePendingSceneChecks(t,l)))}getPendingSceneCheckKey(t,e){return JSON.stringify([t,e])}parsePendingSceneCheckKey(t){try{const e=JSON.parse(t);if(Array.isArray(e)&&e.length===2&&typeof e[0]=="string"&&typeof e[1]=="string")return[e[0],e[1]]}catch{}}async reconcileSceneStorageIfPending(t,e){const r=this.getPendingSceneCheckKey(t,e);this.pendingSceneChecks.has(r)&&await this.reconcileSceneStorage(t,e)}async reconcileSceneStorage(t,e){var s;const r=this.getPendingSceneCheckKey(t,e),n=(s=this.collector)==null?void 0:s.getStorageData(t,e);if(!n||!this.collector){this.pendingSceneChecks.delete(r);return}for(const[o,a]of Object.entries(n)){if(!a)continue;if(o===De||this.collector.isOwn(o)&&this.collector.getLocalId(o)===De){this.collector.updateValue(o,void 0,{viewId:t,scenePath:e,isSync:!0});continue}if(!this.collector.isOwn(o))continue;const l=await lme(a);if(l.status==="unrecoverable")continue;const u=l.value;if(l.status==="already-stable")continue;const h=this.collector.getLocalId(o);h&&this.collector.dispatch({...u,workId:h,viewId:t,scenePath:e,isSync:!0})}this.pendingSceneChecks.delete(r)}schedulePendingSceneChecks(t,e){const r=()=>{const s=this.getPendingSceneCheckKey(t,e);for(const o of[...this.pendingSceneChecks]){if(o===s||!this.pendingSceneChecks.has(o))continue;const a=this.parsePendingSceneCheckKey(o);a?this.reconcileSceneStorage(a[0],a[1]):this.pendingSceneChecks.delete(o)}},n=window.requestIdleCallback;n?n(r,{timeout:500}):window.setTimeout(r,0)}requestToolChange(t){var s,o;const e={...(s=this.room)==null?void 0:s.state.memberState,...t},r=this.getToolsKey(e),n=(o=this.worker.getCurrentToolsData())==null?void 0:o.toolsType;if(r===n){this.setToolChangePending(!1,"same-tool",r);return}this.setToolChangePending(!0,"requested",r)}setToolChangePending(t,e="manual",r){this.toolChangePendingTimer!==void 0&&(clearTimeout(this.toolChangePendingTimer),this.toolChangePendingTimer=void 0),this.toolChangePending=t,t&&(this.toolChangePendingTimer=window.setTimeout(()=>{this.toolChangePendingTimer=void 0,this.toolChangePending=!1},500))}get isToolChangePending(){return this.toolChangePending}getToolsKey(t){const e=t.currentApplianceName;switch(this.hasSwitchToSelectorEffect=!1,e){case Ne.text:return t.textCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),K.Text;case Ne.pencil:return t.useLaserPen?K.LaserPen:K.Pencil;case Ne.eraser:return K.Eraser;case Ne.pencilEraser:return this.pluginOptions.extras.pencilEraser.useBitMap===!1?K.PencilEraser:K.BitMapEraser;case Ne.selector:return K.Selector;case Ne.clicker:return K.Clicker;case Ne.hand:return K.Hand;case Ne.laserPointer:return K.Hand;case Ne.arrow:return t.arrowCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),K.Arrow;case Ne.straight:return t.straightCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),K.Straight;case Ne.ellipse:return t.ellipseCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),K.Ellipse;case Ne.rectangle:return t.rectangleCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),K.Rectangle;case Ne.shape:if(t.shapeCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),t.shapeType===Gt.Pentagram||t.shapeType===Gt.Star)return K.Star;if(t.shapeType===Gt.Polygon||t.shapeType===Gt.Triangle||t.shapeType===Gt.Rhombus)return K.Polygon;if(t.shapeType===Gt.SpeechBalloon)return K.SpeechBalloon;break}return K.Hand}getToolsOpt(t,e){if(t===K.Clicker)return{toolsType:t,toolsOpt:{}};const r={strokeColor:$n(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(t){case K.Text:r.fontFamily=window.getComputedStyle(document.documentElement).getPropertyValue("font-family"),r.fontSize=(e==null?void 0:e.textSizeOverride)||(e==null?void 0:e.textSize)||Number(window.getComputedStyle(document.body).fontSize),r.textAlign=(e==null?void 0:e.textAlign)||"left",r.verticalAlign=(e==null?void 0:e.verticalAlign)||"middle",r.fontColor=(e==null?void 0:e.textColor)&&$n(e.textColor[0],e.textColor[1],e.textColor[2],e.textOpacity||1)||r.strokeColor||"rgba(0,0,0,1)",r.fontBgColor=Array.isArray(e==null?void 0:e.textBgColor)&&$n(e.textBgColor[0],e.textBgColor[1],e.textBgColor[2],e.textBgOpacity||1)||"transparent",r.bold=(e==null?void 0:e.bold)&&"bold"||void 0,r.italic=(e==null?void 0:e.italic)&&"italic"||void 0,r.underline=(e==null?void 0:e.underline)||void 0,r.lineThrough=(e==null?void 0:e.lineThrough)||void 0,r.text="",r.strokeColor=void 0;break;case K.Pencil:{const n=(e==null?void 0:e.strokeType)||ze.Normal;r.strokeType=n,r.autoShape=!!(e!=null&&e.autoShape),r.previewLocalOnly=!!(e!=null&&e.autoShape),r.lineCap=this.getLineCap(n),r.lineDash=this.getLineDash(n);break}case K.PencilEraser:case K.BitMapEraser:case K.Eraser:r.thickness=Math.min(4,Math.max(1,Math.floor(e.pencilEraserSize||1)))-1,t===K.BitMapEraser&&(r.removeOnDone=this.pluginOptions.extras.pencilEraser.removeOnDone!==!1);break;case K.LaserPen:{r.duration=(e==null?void 0:e.duration)||1,e!=null&&e.strokeType&&(e==null?void 0:e.strokeType)===ze.Stroke?r.strokeType=ze.Normal:r.strokeType=(e==null?void 0:e.strokeType)||ze.Normal;const n=r.strokeType;r.lineCap=this.getLineCap(n),r.lineDash=this.getLineDash(n);break}case K.Arrow:case K.Straight:{e!=null&&e.strokeType&&(e==null?void 0:e.strokeType)===ze.Stroke?r.strokeType=ze.Normal:r.strokeType=(e==null?void 0:e.strokeType)||ze.Normal;const n=r.strokeType;r.strokeType=n,r.lineCap=this.getLineCap(n),r.lineDash=this.getLineDash(n);break}case K.Ellipse:case K.Rectangle:case K.Star:case K.Polygon:case K.SpeechBalloon:{e!=null&&e.strokeType&&(e==null?void 0:e.strokeType)===ze.Stroke?r.strokeType=ze.Normal:r.strokeType=(e==null?void 0:e.strokeType)||ze.Normal;const n=r.strokeType;r.lineCap=this.getLineCap(n),r.lineDash=this.getLineDash(n),t===K.Star&&(e.shapeType===Gt.Pentagram?(r.vertices=10,r.innerVerticeStep=2,r.innerRatio=.4):e!=null&&e.vertices&&(e!=null&&e.innerVerticeStep)&&(e!=null&&e.innerRatio)&&(r.vertices=e.vertices,r.innerVerticeStep=e.innerVerticeStep,r.innerRatio=e.innerRatio)),t===K.Polygon&&(e.shapeType===Gt.Triangle?r.vertices=3:e.shapeType===Gt.Rhombus?r.vertices=4:e.vertices&&(r.vertices=e.vertices)),r.fillColor=(e==null?void 0:e.fillColor)&&$n(e.fillColor[0],e.fillColor[1],e.fillColor[2],e==null?void 0:e.fillOpacity)||"transparent",t===K.SpeechBalloon&&(r.placement=e.placement||"bottomLeft");break}}return{toolsType:t,toolsOpt:r}}getLineCap(t){switch(t){case ze.Normal:return this.pluginOptions.extras.normalStroke.lineCap||He.normalStroke.lineCap;case ze.Dotted:return this.pluginOptions.extras.dottedStroke.lineCap||He.dottedStroke.lineCap;case ze.LongDotted:return this.pluginOptions.extras.longDottedStroke.lineCap||He.longDottedStroke.lineCap;default:return}}getLineDash(t){switch(t){case ze.Normal:return;case ze.Dotted:{const{segment:e,gap:r}=this.pluginOptions.extras.dottedStroke||He.dottedStroke;return[e,r]}case ze.LongDotted:{const{segment:e,gap:r}=this.pluginOptions.extras.longDottedStroke||He.longDottedStroke;return[e,r]}default:return}}effectViewContainer(t){var e,r,n,s,o;if(this.disableDeviceInputs===!0)this.room.disableDeviceInputs=!0,(e=this.worker)==null||e.unWritable(),(r=this.cursor)==null||r.unabled();else switch(t!==K.Text&&this.viewContainerManager.focuedViewId&&this.viewContainerManager.unActiveTextEditor(this.viewContainerManager.focuedViewId),t){case K.Text:case K.Pencil:case K.LaserPen:case K.Arrow:case K.Straight:case K.Rectangle:case K.Ellipse:case K.Star:case K.Polygon:case K.SpeechBalloon:case K.Triangle:case K.Rhombus:case K.Eraser:case K.PencilEraser:case K.BitMapEraser:case K.Selector:case K.Clicker:this.room.disableDeviceInputs=!0,(n=this.worker)==null||n.abled(),t===K.Text&&this.viewContainerManager.focuedViewId&&this.viewContainerManager.activeTextEditor(this.viewContainerManager.focuedViewId);break;default:this.room.disableDeviceInputs=!1,(s=this.worker)==null||s.unWritable(),(o=this.cursor)==null||o.unabled();break}setTimeout(()=>{this.viewContainerManager.getAllViews().forEach(c=>{c!=null&&c.displayer&&c.displayer.bindToolsClass()})},0)}async getBoundingRect(t){var r,n,s,o,a;const e=await((r=this.worker)==null?void 0:r.getBoundingRect(t));if(e){const c=((s=(n=this.viewContainerManager.mainView)==null?void 0:n.viewData)==null?void 0:s.convertToPointInWorld({x:e.x,y:e.y}))||{x:e.x,y:e.y},l=((a=(o=this.viewContainerManager.mainView)==null?void 0:o.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(t,e,r,n,s,o,a){const c=await this.worker.getSnapshot(e,r,n,s);c&&c.forEach(l=>{if(l)try{t.drawImage(l,o||0,a||0)}catch(u){console.error("[screenshotToCanvas] Failed to draw ImageBitmap:",u)}l instanceof ImageBitmap?l.close():l instanceof HTMLImageElement&&l.remove()})}async scenePreview(t,e){var o,a,c,l;const r=(o=this.collector)==null?void 0:o.getViewIdBySecenPath(t);if(!r)return;const n=this.viewContainerManager.getView(r);if(!n||!((a=n.cameraOpt)!=null&&a.width)||!((c=n.cameraOpt)!=null&&c.height))return;const s=await((l=this.worker)==null?void 0:l.getSnapshot(t));if(s&&this.worker){const u=document.createElement("canvas"),h=u.getContext("2d"),{width:d,height:g}=n.cameraOpt;u.width=d,u.height=g,h&&(s.forEach(p=>{p&&(h.drawImage(p,0,0),p instanceof ImageBitmap?p.close():p instanceof HTMLImageElement&&p.remove())}),e.crossOrigin="anonymous",e.src=u.toDataURL(),e.onload=()=>{u.remove()},e.onerror=()=>{u.remove(),e.remove()})}}switchToText(){var t;(t=this.room)==null||t.setMemberState({currentApplianceName:Ne.text})}switchToSelector(){var t;(t=this.room)==null||t.setMemberState({currentApplianceName:Ne.selector})}async runEffectWork(t){if(this.hasSwitchToSelectorEffect){const e=await new Promise(r=>{this.switchToSelector(),this.effectResolve=r});this.effectResolve=void 0,e&&t&&t()}}setSnapshootData(){var t;this.room&&(this.snapshootStateMap=new Map,this.snapshootStateMap.set("memberState",(t=this.room)==null?void 0:t.state.memberState))}getSnapshootData(t){var e;return(e=this.snapshootStateMap)==null?void 0:e.get(t)}clearSnapshootData(){var t;(t=this.snapshootStateMap)==null||t.clear(),this.snapshootStateMap=void 0}useBitMapEraser(t){this.pluginOptions.extras.pencilEraser.useBitMap=t}consoleWorkerInfo(){var t;(t=this.worker)==null||t.consoleWorkerInfo()}filterRenderByUid(t,e,r=!0){var s;this.viewContainerManager.getView(t)&&((s=this.renderControl)==null||s.publishRender({viewId:t,option:e,isSync:r}))}cancelFilterRender(t,e=!0){var r;(r=this.renderControl)==null||r.publishRender({viewId:t,isSync:e})}async createMiniMap(t,e){var n,s,o;if(this.isUseSimple)throw new Error("simple mode not support createMiniMap");const r=await((n=this.miniMapManager)==null?void 0:n.getMiniMapCamera(t));if(r&&await((s=this.miniMapManager)==null?void 0:s.createMiniMap(t,e,r))){const c=(o=this.miniMapManager)==null?void 0:o.getMiniMapCanvas(t);if(c){const l=c.getContext("2d");if(l){const u=this.viewContainerManager.getView(t);u!=null&&u.focusScenePath&&this.screenshotToCanvas(l,u.focusScenePath,r.width,r.height,r)}}}}async destroyMiniMap(t){var e;(e=this.miniMapManager)==null||e.destroyMiniMap(t)}insertIconify(t,e){var n;if(this.viewContainerManager.getView(t)&&this.room){const s=this.room.state.memberState,o=$n(s.strokeColor[0],s.strokeColor[1],s.strokeColor[2],s.strokeOpacity||1);(n=this.worker)==null||n.insertIconify(t,{...e,strokeColor:o})}}insertBackgroundSVG(t,e){var r;if(!this.isUseBackgroundThread)throw new Error("useBackgroundThread of pluginOptions should be true");(r=this.worker)==null||r.insertBackgroundSVG(t,e)}reloadBackgroundImage(t){if(t.source!=="appliance")return{accepted:!1,reloadedCount:0,reason:"resourceNotFound"};const e=this.viewContainerManager.getView(t.viewId);return e?!e.focusScenePath||t.scenePath!==void 0&&e.focusScenePath!==t.scenePath?{accepted:!1,reloadedCount:0,reason:"sceneNotFocused"}:this.backgroundImageLoadCoordinator.reload({...t,scenePath:t.scenePath??e.focusScenePath}):{accepted:!1,reloadedCount:0,reason:"viewNotFound"}}async insertBackgroundMarkMap(t,e){var r;if(!this.isUseBackgroundThread)throw new Error("useBackgroundThread of pluginOptions should be true");return await((r=this.worker)==null?void 0:r.insertBackgroundMarkMap(t,e))}updateBackgroundMarkMap(t,e,r){var s;const n=this.viewContainerManager.getView(t);if(n&&this.collector&&this.collector.hasTargetDataByViewId(t,e)){const{data:o,scenePath:a}=this.collector.getTargetDataByViewId(t,e);if(!a)throw new Error("updateBackgroundMarkMap scenePath is not exist");const c=n.focusScenePath;if(c&&c!==a)throw new Error("updateBackgroundMarkMap scenePath is not the focus scene path");if(o&&a)(s=this.worker)==null||s.updateBackgroundMarkMap(t,e,r);else throw new Error("updateBackgroundMarkMap data or scenePath is not exist")}}usePlugin(t){var e;return(e=this.pluginManager)==null?void 0:e.use(t)}async stopDraw(t){var r;const e=this.viewContainerManager.getView(t);e&&await((r=e.displayer)==null?void 0:r.stopEventHandler())}async setViewLocalScenePathChange(t,e){this.viewContainerManager.getView(t)&&await this.onSceneChange(e,t)}};R(ir,"InternalMsgEmitter",new Il),R(ir,"PublicMsgEmitter",new Il);let Xe=ir;var fu=(i=>(i.Undo="undo",i.Redo="redo",i))(fu||{});const Ke=class Ke{createProxy(t,e,r){const n=new Proxy(t,{get(s,o,a){if(typeof o=="string"&&/^\d+$/.test(o))return Reflect.get(s,o,a);const c=Ke.interceptors.hasOwnProperty(o)?Ke.interceptors:s,l=Reflect.get(c,o,a);return typeof l=="function"&&c===Ke.interceptors?l.bind(n):l},set(s,o,a,c){const l=Ke.proxyCallbacks.get(c),u=(l==null?void 0:l.arrayType)||"undo";if(o==="length"){const h=s.length,d=[];if(a<h)for(let p=a;p<h;p++)d.push(s[p]);const g=Reflect.set(s,o,a,c);if(l!=null&&l.callback)for(let p=0;p<d.length;p++)l.callback({operation:"delete",index:a+p,oldValue:d[p],arrayType:u});return g}return typeof o=="string"&&/^\d+$/.test(o),Reflect.set(s,o,a,c)},deleteProperty(s,o){const a=Ke.proxyCallbacks.get(n),c=(a==null?void 0:a.arrayType)||"undo";if(typeof o=="string"&&/^\d+$/.test(o)){const l=parseInt(o,10),u=s[l],h=Reflect.deleteProperty(s,o);return a!=null&&a.callback&&u!==void 0&&a.callback({operation:"delete",index:l,oldValue:u,arrayType:c}),h}return Reflect.deleteProperty(s,o)}});return Ke.proxyToRaw.set(n,t),Ke.proxyCallbacks.set(n,{callback:e,arrayType:r}),n}};R(Ke,"proxyToRaw",new WeakMap),R(Ke,"proxyCallbacks",new WeakMap),R(Ke,"interceptors",{entries(...t){return Ke.proxyToRaw.get(this).entries(...t)},forEach(...t){return Ke.proxyToRaw.get(this).forEach(...t)},map(...t){return Ke.proxyToRaw.get(this).map(...t)},filter(...t){return Ke.proxyToRaw.get(this).filter(...t)},find(...t){return Ke.proxyToRaw.get(this).find(...t)},findIndex(...t){return Ke.proxyToRaw.get(this).findIndex(...t)},includes(...t){return Ke.proxyToRaw.get(this).includes(...t)},indexOf(...t){return Ke.proxyToRaw.get(this).indexOf(...t)},slice(...t){return Ke.proxyToRaw.get(this).slice(...t)},concat(...t){return Ke.proxyToRaw.get(this).concat(...t)},push(...t){const e=Ke.proxyToRaw.get(this),r=this,n=Ke.proxyCallbacks.get(r),s=(n==null?void 0:n.arrayType)||"undo",o=e.length,a=e.push(...t);if(n!=null&&n.callback)for(let c=o;c<e.length;c++)n.callback({operation:"add",index:c,newValue:e[c],arrayType:s});return a},customPush(...t){return Ke.proxyToRaw.get(this).push(...t)},pop(){const t=Ke.proxyToRaw.get(this),e=this,r=Ke.proxyCallbacks.get(e),n=(r==null?void 0:r.arrayType)||"undo",s=t.length,o=t[s-1],a=t.pop();return r!=null&&r.callback&&s>0&&r.callback({operation:"delete",index:s-1,oldValue:o,arrayType:n}),a},shift(){const t=Ke.proxyToRaw.get(this),e=this,r=Ke.proxyCallbacks.get(e),n=(r==null?void 0:r.arrayType)||"undo",s=t[0],o=t.shift();return r!=null&&r.callback&&t.length>0&&r.callback({operation:"delete",index:0,oldValue:s,arrayType:n}),o},unshift(...t){const e=Ke.proxyToRaw.get(this),r=this,n=Ke.proxyCallbacks.get(r),s=(n==null?void 0:n.arrayType)||"undo",o=e.unshift(...t);if(n!=null&&n.callback)for(let a=0;a<t.length;a++)n.callback({operation:"add",index:a,newValue:e[a],arrayType:s});return o},splice(t,e,...r){const n=Ke.proxyToRaw.get(this),s=this,o=Ke.proxyCallbacks.get(s),a=(o==null?void 0:o.arrayType)||"undo",c=e??n.length-t,l=n.slice(t,t+c),u=n.splice(t,c,...r);if(o!=null&&o.callback){for(let h=0;h<l.length;h++)o.callback({operation:"delete",index:t+h,oldValue:l[h],arrayType:a});for(let h=0;h<r.length;h++)o.callback({operation:"add",index:t+h,newValue:n[t+h],arrayType:a})}return u},customSplice(t,e,...r){const n=Ke.proxyToRaw.get(this),s=e??n.length-t;return n.splice(t,s,...r)},get length(){return Ke.proxyToRaw.get(this).length},set length(t){const e=Ke.proxyToRaw.get(this),r=this,n=Ke.proxyCallbacks.get(r),s=(n==null?void 0:n.arrayType)||"undo",o=e.length,a=[];if(t<o)for(let c=t;c<o;c++)a.push(e[c]);if(e.length=t,n!=null&&n.callback)for(let c=0;c<a.length;c++)n.callback({operation:"delete",index:t+c,oldValue:a[c],arrayType:s})}});let gu=Ke;const $r=class $r{constructor(t){R(this,"emitter",new Il);R(this,"undoStack");R(this,"redoStack");R(this,"worker");R(this,"control");R(this,"room");R(this,"viewId");R(this,"enableGlobal");R(this,"isTicking");R(this,"_undoTickerId");R(this,"scenePath");R(this,"tickStartStorerCache");R(this,"excludeIds",new Set);R(this,"pendingState",new Map);R(this,"tickerEndWaiters",new Map);R(this,"undoLifecycleListeners",new Set);R(this,"lifecycleCache",new Map);R(this,"stackRevision",0);R(this,"tickStartCaches",new Map);R(this,"tickStartExcludeIds",new Map);R(this,"timingFix");R(this,"ackTimeout");R(this,"gracePeriodTimeout");R(this,"doingFallbackTimeout");R(this,"isGlobalStackTransaction",!1);R(this,"pendingGlobalServiceData");R(this,"pendingArrayChanges",[]);R(this,"onChangeScene",ve.debounce(()=>{const t=this.control.viewContainerManager.getCurScenePath(this.viewId);if(t){const e=this.undoStack.filter(n=>n.scenePath===t).length,r=this.redoStack.filter(n=>n.scenePath===t).length;this.emitUndoStepsUpdate(e),this.emitRedoStepsUpdate(r)}},$r.waitTime));const{control:e,internalMsgEmitter:r,viewId:n,enableGlobal:s}=t;this.control=e,this.emitter=r;const o=this.control.pluginOptions.extras.undoRedo;$r.MaxStackLength=o.maxStackLength||He.undoRedo.maxStackLength,this.timingFix=o.timingFix??He.undoRedo.timingFix,this.ackTimeout=o.ackTimeout||He.undoRedo.ackTimeout,this.gracePeriodTimeout=o.gracePeriodTimeout||He.undoRedo.gracePeriodTimeout,this.doingFallbackTimeout=o.doingFallbackTimeout||He.undoRedo.doingFallbackTimeout;const a=new gu,c=[],l=[];this.undoStack=a.createProxy(c,u=>{this.control.renderControl.isWritable&&this.handleArrayChange(u,yt.syncUndoStack)},fu.Undo),this.redoStack=a.createProxy(l,u=>{this.control.renderControl.isWritable&&this.handleArrayChange(u,yt.syncRedoStack)},fu.Redo),this.room=e.room,this.worker=e.worker,this.isTicking=!1,this.viewId=n,this.enableGlobal=s}reportStackLength(t,e=this.undoStack.length,r=this.redoStack.length){var n,s,o;(o=(s=(n=this.room)==null?void 0:n.logger)==null?void 0:s.info)==null||o.call(s,`[Appliance]: [undo-stack] ${t} viewId=${this.viewId} undoLength=${e} redoLength=${r}`)}lifecycleKey(t){return`${t.viewId}|${t.scenePath}|${t.tickerId}|${t.transactionId}`}getIdentity(t,e){return{viewId:e.viewId,scenePath:e.scenePath,tickerId:t,transactionId:e.transactionId}}emitUndoLifecycle(t){const e=this.lifecycleKey(t);for(this.lifecycleCache.set(e,t);this.lifecycleCache.size>100;){const r=this.lifecycleCache.keys().next().value;if(r===void 0)break;this.lifecycleCache.delete(r)}this.undoLifecycleListeners.forEach(r=>r(t))}onUndoLifecycle(t){return this.undoLifecycleListeners.add(t),()=>this.undoLifecycleListeners.delete(t)}getPendingTickerSnapshots(t){const e=[];return this.pendingState.forEach((r,n)=>{r.scenePath===t&&e.push({...this.getIdentity(n,r),source:r.source,startedAt:r.startedAt,barrierEpoch:r.barrierEpoch,phase:r.phase,ownerPromiseActive:r.ownerPromiseActive,finalizeRequested:r.finalizeRequested,scopeMode:r.scopeMode})}),e}waitForUndoStackEnd(t,e){const r=this.lifecycleCache.get(this.lifecycleKey(t));return(r==null?void 0:r.phase)==="stack-end"?Promise.resolve(r):(r==null?void 0:r.phase)==="failed"?Promise.reject(r):new Promise((n,s)=>{let o,a=!1;const c=()=>{o!==void 0&&clearTimeout(o),h()},l=d=>{if(a)return;a=!0;const g=Math.max(0,d+e-Date.now());o=setTimeout(()=>{c(),s(new Error(`undo stack end timeout: ${this.lifecycleKey(t)}`))},g)},u=d=>{if(this.lifecycleKey(d)===this.lifecycleKey(t)){if(d.phase==="finalize-requested"){l(d.finalizedAt);return}c(),d.phase==="stack-end"?n(d):s(d)}},h=this.onUndoLifecycle(u);(r==null?void 0:r.phase)==="finalize-requested"&&l(r.finalizedAt)})}waitForFinalizeRequested(t,e){const r=this.lifecycleCache.get(this.lifecycleKey(t));return(r==null?void 0:r.phase)==="finalize-requested"||(r==null?void 0:r.phase)==="stack-end"?Promise.resolve():(r==null?void 0:r.phase)==="failed"?Promise.reject(r):new Promise((n,s)=>{let o;const a=()=>{clearTimeout(o),l()},c=u=>{this.lifecycleKey(u)===this.lifecycleKey(t)&&(a(),u.phase==="finalize-requested"||u.phase==="stack-end"?n():s(u))},l=this.onUndoLifecycle(c);o=setTimeout(()=>{a(),s(new Error(`undo finalize timeout: ${this.lifecycleKey(t)}`))},e)})}emitUndoStepsUpdate(t){this.emitter.emitAsync("onCanUndoStepsUpdate",t,this.viewId)}emitRedoStepsUpdate(t){this.emitter.emitAsync("onCanRedoStepsUpdate",t,this.viewId)}beginGlobalStackTransaction(){this.enableGlobal&&(this.isGlobalStackTransaction=!0)}flushPendingArrayChanges(){if(!this.enableGlobal||!this.pendingArrayChanges.length)return;const t=this.pendingArrayChanges.splice(0);for(const e of t)this.handleArrayChange(e.params,e.operation)}endGlobalStackTransaction(){if(!this.enableGlobal)return;const t=this.pendingGlobalServiceData;this.isGlobalStackTransaction=!1,this.pendingGlobalServiceData=void 0,this.flushPendingArrayChanges(),t&&this.pullServiceData(t)}ackRender(t,e,r){if(!this.timingFix){this.undoTickerEnd(t,e);return}const n=this.pendingState.get(t);!n||n.scenePath!==e||(n.gotRender=!0,this.mergeMeta(n,r),n.finalizeRequested&&(this.armAckTimeout(t,n),this.tryEnd(t)))}ackStorage(t,e,r,n){if(!this.timingFix)return;const s=this.pendingState.get(t);!s||s.scenePath!==e||(r&&(s.scopeMode==="dynamic"||s.finalizeRequested)&&s.ackedStorageKeys.add(r),Bpe(s.scopeKeys,r)&&s.finalizeRequested&&(s.scopeKeys.size?s.gotStorage=[...s.scopeKeys].every(a=>s.ackedStorageKeys.has(a)):s.gotStorage=!0),this.mergeMeta(s,n),!s.finalizeRequested)||(this.armAckTimeout(t,s),this.tryEnd(t))}collectExpectedWorkIds(t,e,r){const n=this.pendingState.get(t);if(!n||n.scenePath!==e||!r.length)return;fl(this.collector,this.viewId,e,r).forEach(o=>n.collectedScopeKeys.add(o)),n.scopeMode==="dynamic"&&n.finalizeRequested&&(n.scopeKeys.clear(),n.collectedScopeKeys.forEach(o=>n.scopeKeys.add(o)),n.expectedStorage&&n.scopeKeys.size?n.gotStorage=[...n.scopeKeys].every(o=>n.ackedStorageKeys.has(o)):n.expectedStorage&&!n.scopeKeys.size&&(n.gotStorage=!1),n.ackTimer&&clearTimeout(n.ackTimer),n.ackTimer=void 0,this.armAckTimeout(t,n),this.tryEnd(t))}reopenStorageAck(t,e,r){const n=this.pendingState.get(t);if(!n||n.scenePath!==e||!r.length)return;const s=fl(this.collector,this.viewId,e,r);s.size&&(s.forEach(o=>n.ackedStorageKeys.delete(o)),n.finalizeRequested&&(n.expectedStorage&&n.scopeKeys.size?n.gotStorage=[...n.scopeKeys].every(o=>n.ackedStorageKeys.has(o)):n.expectedStorage&&!n.scopeKeys.size&&(n.gotStorage=n.scopeMode==="static"),n.ackTimer&&clearTimeout(n.ackTimer),n.ackTimer=void 0,this.armAckTimeout(t,n)))}finalizeRequested(t,e,r){const n=this.pendingState.get(t);if(!n||n.scenePath!==e)return;const s=n.finalizeRequested,o=fl(this.collector,this.viewId,e,r);n.scopeMode==="dynamic"?(o.forEach(a=>n.collectedScopeKeys.add(a)),n.scopeKeys.clear(),n.collectedScopeKeys.forEach(a=>n.scopeKeys.add(a))):o.forEach(a=>n.scopeKeys.add(a)),n.finalizeRequested=!0,n.phase="finalizing",n.gotStorage=jpe(n),this.armAckTimeout(t,n),s||this.emitUndoLifecycle({...this.getIdentity(t,n),phase:"finalize-requested",source:n.source,scopeMode:n.scopeMode,finalizedAt:Date.now()}),this.tryEnd(t)}mergeMeta(t,e){Rpe(t,e)}armAckTimeout(t,e){e.finalizeRequested&&zpe(e)&&(e.ackTimer=setTimeout(()=>{this.forceFlushPending(t)},this.ackTimeout))}tryEnd(t){const e=this.pendingState.get(t);if(!e||!Ope(e))return;const r=e.meta,n=this.undoStack.length,s=e.phase==="failed";this.undoTickerEndSync(t,e.viewId,e.scenePath,!0),s||(e.phase="completed",this.stackRevision++,this.emitUndoLifecycle({...this.getIdentity(t,e),phase:"stack-end",source:e.source,outcome:this.undoStack.length>n?"committed":"no-change",undoItemCreated:this.undoStack.length>n,stackRevision:this.stackRevision})),r.copyAck&&r.emitEventType&&r.requestId&&this.emitter.emit("undoAckApplied",{viewId:e.viewId,scenePath:e.scenePath,requestId:r.requestId,emitEventType:r.emitEventType}),r.isWritable&&this.worker.abled()}forceFlushPending(t){const e=this.pendingState.get(t);if(!e)return;e.phase="failed";const r={...this.getIdentity(t,e),phase:"failed",source:e.source,reason:"timeout",missingRender:e.expectedRender&&!e.gotRender,missingStorageIds:[...e.scopeKeys].filter(n=>!e.ackedStorageKeys.has(n))};this.emitUndoLifecycle(r),e.gotRender=e.expectedRender,e.gotStorage=e.expectedStorage,this.tryEnd(t)}hasAnyAck(t){return t.gotRender||t.gotStorage||t.ackedStorageKeys.size>0||!!t.ackTimer}clearPendingState(t){const e=this.pendingState.get(t);e&&(e.ackTimer&&clearTimeout(e.ackTimer),e.graceTimer&&clearTimeout(e.graceTimer),e.fallbackTimer&&clearTimeout(e.fallbackTimer),this.pendingState.delete(t)),this.tickStartCaches.delete(t),this.tickStartExcludeIds.delete(t);const r=this.tickerEndWaiters.get(t);r&&(this.tickerEndWaiters.delete(t),r.forEach(n=>n()))}waitForTickerEnd(t,e){return!this.pendingState.has(t)&&this.undoTickerId!==t?Promise.resolve():new Promise(r=>{let n;const s=()=>{n!==void 0&&clearTimeout(n);const a=this.tickerEndWaiters.get(t);a==null||a.delete(s),(a==null?void 0:a.size)===0&&this.tickerEndWaiters.delete(t),r()},o=this.tickerEndWaiters.get(t)||new Set;o.add(s),this.tickerEndWaiters.set(t,o),e!==void 0&&(n=setTimeout(s,e))})}cancelUndoTicker(t,e,r){const n=this.pendingState.has(t),s=this.undoTickerId===t&&this.viewId===e&&this.scenePath===r;if(!n&&!s)return;const o=this.pendingState.get(t);s&&(this.isTicking=!1,this.scenePath=void 0,this.tickStartStorerCache=void 0,this._undoTickerId=void 0,this.excludeIds.clear()),this.clearPendingState(t),o&&(o.phase="cancelled",this.stackRevision++,this.emitUndoLifecycle({...this.getIdentity(t,o),phase:"stack-end",source:o.source,outcome:"no-change",undoItemCreated:!1,stackRevision:this.stackRevision}))}getStartCache(t){return this.tickStartCaches.get(t)||this.tickStartStorerCache}getExcludeIds(t){return this.tickStartExcludeIds.get(t)||this.excludeIds}resetLegacyTicker(){this.isTicking=!1,this.scenePath=void 0,this.tickStartStorerCache=void 0,this._undoTickerId=void 0,this.excludeIds.clear()}handleArrayChange(t,e){if(!this.collector||!this.enableGlobal)return;if(this.isGlobalStackTransaction){this.pendingArrayChanges.push({operation:e,params:{...t}});return}const{operation:r,oldValue:n,newValue:s}=t;let o,a;r==="delete"&&n?(o=n,a=n.id):r==="add"&&s&&(o=s,a=s.id),o&&a&&this.collector.dispatchUndoTicker({operation:e,syncType:r,viewId:this.viewId,undoTickerId:a,data:o})}get collector(){return this.control.collector}get undoTickerId(){return this._undoTickerId}get tmpTickStartStorerCache(){return this.tickStartStorerCache}get uid(){var t;return((t=this.control.collector)==null?void 0:t.uid)||""}addExcludeIds(t){const e=this.undoTickerId!==void 0?this.pendingState.get(this.undoTickerId):void 0;if(!(this.timingFix&&(e!=null&&e.scopeKeys.size))){if(this.timingFix&&this.undoTickerId!==void 0){const r=this.tickStartExcludeIds.get(this.undoTickerId);if(r)for(const n of t)r.add(n);return}if(this.isTicking)for(const r of t)this.excludeIds.add(r)}}undoTickerStart(t,e,r){var n,s,o;if(!this.timingFix){this.legacyUndoTickerStart(t,e);return}if(!r)throw new Error("[appliance-plugin] addUndoTicker expectedAcks is required");if(!r.source)throw new Error("[appliance-plugin] addUndoTicker source is required");if(this.collector&&(this.undoTickerId!==t||this.scenePath!==e)){if(this.undoTickerId&&this.viewId&&this.scenePath){const d=this.undoTickerId,g=this.pendingState.get(d);g&&!this.hasAnyAck(g)?this.clearPendingState(d):g&&!g.graceTimer?g.graceTimer=setTimeout(()=>{this.forceFlushPending(d)},this.gracePeriodTimeout):g||this.undoTickerEndSync(d,this.viewId,this.scenePath)}this.isTicking=!0;const a=this.collector.transformKey(De);this.excludeIds.add(a),this._undoTickerId=t,this.scenePath=e;const c=((n=this.collector)==null?void 0:n.storage[this.viewId])&&((s=this.collector)==null?void 0:s.storage[this.viewId][this.scenePath])||{},l=new Map(Object.entries(ve.cloneDeep(c))),u=new Set([a]);this.tickStartStorerCache=l,this.tickStartCaches.set(t,l),this.tickStartExcludeIds.set(t,u);const h=setTimeout(()=>{this.forceFlushPending(t)},this.doingFallbackTimeout);this.pendingState.set(t,Lpe({tickerId:t,viewId:this.viewId,scenePath:e,expectedAcks:r,fallbackTimer:h})),(o=r.workIds)!=null&&o.length&&this.finalizeRequested(t,e,r.workIds.map(String))}}legacyUndoTickerStart(t,e){var r,n;if(this.collector&&(this.undoTickerId!==t||this.scenePath!==e)){this.undoTickerId&&this.viewId&&this.scenePath&&this.undoTickerEndSync(this.undoTickerId,this.viewId,this.scenePath),this.isTicking=!0;const s=this.collector.transformKey(De);this.excludeIds.add(s),this._undoTickerId=t,this.scenePath=e;const o=((r=this.collector)==null?void 0:r.storage[this.viewId])&&((n=this.collector)==null?void 0:n.storage[this.viewId][this.scenePath])||{};this.tickStartStorerCache=new Map(Object.entries(ve.cloneDeep(o)))}}undoTickerEnd(t,e,r){if(this.timingFix){this.forceFlushPending(t);return}this.undoTickerId&&t===this.undoTickerId&&e===this.scenePath?this.undoTickerEndSync(t,this.viewId,e,!0,r):this.resetLegacyTicker()}undoTickerEndSync(t,e,r,n=!0,s){var c,l;if(s&&s.length)for(const u of s)this.excludeIds.delete(u);const o=t===this.undoTickerId&&e===this.viewId&&r===this.scenePath,a=this.pendingState.has(t)&&e===this.viewId&&!!this.getStartCache(t);if((o||a)&&this.getStartCache(t)){const u=((c=this.collector)==null?void 0:c.storage[e])&&((l=this.collector)==null?void 0:l.storage[e][r])||{},h=this.pendingState.get(t),d=this.diffFun(this.getStartCache(t),new Map(Object.entries(u)),!0,this.getExcludeIds(t),h==null?void 0:h.scopeKeys);d.size&&(this.undoStack.push({id:`${t}-${this.uid}`,data:ve.cloneDeep(d),scenePath:r}),this.undoStack.length>$r.MaxStackLength&&this.undoStack.shift(),n&&this.emitUndoStepsUpdate(this.undoStack.length),this.redoStack.length&&(this.redoStack.length=0,n&&this.emitRedoStepsUpdate(this.redoStack.length))),o&&(this.isTicking=!1,this.scenePath=void 0,this.tickStartStorerCache=void 0,this._undoTickerId=void 0,this.excludeIds.clear()),this.clearPendingState(t),this.reportStackLength("undo-ticker-end")}}transformToUndoStackItem(t){const e=[];for(const[r,n]of Object.entries(t)){if(!(n!=null&&n.data))continue;const s=new Set;for(const[o,a]of Object.entries(n.data))s.add({key:o,dataType:a.dataType,data:a.data});e.push({id:r,scenePath:n.scenePath,data:s})}return e}pullServiceData(t){if(this.enableGlobal&&this.isGlobalStackTransaction){this.pendingGlobalServiceData=t;return}if(t){const{undoStack:e,redoStack:r}=t;if(e){const n=this.transformToUndoStackItem(e);for(let s=this.undoStack.length-1;s>=0;s--){const o=this.undoStack[s];n.findIndex(c=>c.id===o.id)===-1&&this.undoStack.customSplice(s,1)}for(const s of n){const o=this.undoStack.findIndex(a=>a.id===s.id);o!==-1?this.undoStack[o]=s:this.undoStack.customPush(s)}this.undoStack.sort((s,o)=>{const a=parseInt(s.id.split("-")[0]),c=parseInt(o.id.split("-")[0]);return a-c}),this.emitUndoStepsUpdate(this.undoStack.length)}if(r){const n=this.transformToUndoStackItem(r);for(let s=this.redoStack.length-1;s>=0;s--){const o=this.redoStack[s];n.findIndex(c=>c.id===o.id)===-1&&this.redoStack.customSplice(s,1)}for(const s of n){const o=this.redoStack.findIndex(a=>a.id===s.id);o!==-1?this.redoStack[o]=s:this.redoStack.customPush(s)}this.redoStack.sort((s,o)=>{const a=parseInt(s.id.split("-")[0]);return parseInt(o.id.split("-")[0])-a}),this.emitRedoStepsUpdate(this.redoStack.length)}}else this.clear()}undo(t){var r,n;let e;this.beginGlobalStackTransaction();try{if(this.undoTickerId&&this.tickStartStorerCache&&this.scenePath){const a=this.undoTickerId;this.timingFix&&this.forceFlushPending(a)}if(this.undoTickerId&&this.tickStartStorerCache&&this.scenePath){const a=this.undoTickerId,c=this.scenePath,l=this.getStartCache(a),u=this.pendingState.get(a);if(!l)return this.resetLegacyTicker(),this.undo(t);const h=((r=this.collector)==null?void 0:r.storage[this.viewId])&&((n=this.collector)==null?void 0:n.storage[this.viewId][c])||{},d=this.diffFun(l,new Map(Object.entries(h)),!1,this.getExcludeIds(a),u==null?void 0:u.scopeKeys),g=this.diffFun(l,new Map(Object.entries(h)),!0,this.getExcludeIds(a),u==null?void 0:u.scopeKeys);d.size===g.size?(this.undoStack.push({id:`${a}-${this.uid}`,data:ve.cloneDeep(d),scenePath:c}),this.undoStack.length>$r.MaxStackLength&&this.undoStack.shift()):d.size&&!g.size&&(e={id:`${a}-${this.uid}`,data:ve.cloneDeep(d),scenePath:c}),this.isTicking=!1,this.scenePath=void 0,this.tickStartStorerCache=void 0,this._undoTickerId=void 0,this.excludeIds.clear(),this.clearPendingState(a)}if(e)this.refreshPlugin(e);else{let a=this.undoStack.length-1;for(;a>=0;){const c=this.undoStack[a];if(c.scenePath===t){const l=c.id;c&&(this.redoStack.push(c),c.data&&this.refreshPlugin(c));const u=this.undoStack.findIndex(h=>h.id===l);u!==-1&&this.undoStack.splice(u,1);break}a--}}const s=this.undoStack.filter(a=>a.scenePath===t).length,o=this.redoStack.filter(a=>a.scenePath===t).length;return this.emitUndoStepsUpdate(s),this.emitRedoStepsUpdate(o),this.reportStackLength("undo-final",s,o),s}finally{this.endGlobalStackTransaction()}}redo(t){this.beginGlobalStackTransaction();try{let e=this.redoStack.length-1;for(;e>=0;){const s=this.redoStack[e];if(s.scenePath===t){const o=s.id;s&&(this.undoStack.push(s),s.data&&this.refreshPlugin(s,!0));const a=this.redoStack.findIndex(c=>c.id===o);a!==-1&&this.redoStack.splice(a,1);break}e--}const r=this.undoStack.filter(s=>s.scenePath===t).length,n=this.redoStack.filter(s=>s.scenePath===t).length;return this.emitUndoStepsUpdate(r),this.emitRedoStepsUpdate(n),this.reportStackLength("redo-final",r,n),n}finally{this.endGlobalStackTransaction()}}clear(){this.clearUndo(),this.clearRedo()}clearUndo(){this.undoStack.length=0,this.emitUndoStepsUpdate(this.undoStack.length)}clearRedo(){this.redoStack.length=0,this.emitRedoStepsUpdate(this.redoStack.length)}canUndo(){return!!this.undoStack.length}canRedo(){return!!this.redoStack.length}onFocusView(){const t=this.control.viewContainerManager.getCurScenePath(this.viewId);if(t){const e=this.undoStack.filter(n=>n.scenePath===t).length,r=this.redoStack.filter(n=>n.scenePath===t).length;this.emitUndoStepsUpdate(e),this.emitRedoStepsUpdate(r)}}especialDiff(t,e,r,n){if(e===er.Update)switch(r==null?void 0:r.toolsType){case K.Text:{if(n!=null&&n.opt&&(r!=null&&r.opt)){const o=ve.omit(n.opt,["uid","workState"]),a=ve.omit(r.opt,["uid","workState"]);if(t&&ve.isEqual(o,a))return!0;n.opt.workState!==ge.Done&&(n.opt.workState=ge.Done),r.opt.workState!==ge.Done&&(r.opt.workState=ge.Done)}break}}else if(e===er.Draw||e===er.Delete)switch(r==null?void 0:r.toolsType){case K.Text:{if(r!=null&&r.opt){const o=r.opt.text;if(t&&!o)return!0;r.opt.workState!==ge.Done&&(r.opt.workState=ge.Done)}break}}return!1}normalizeUndoSnapshotValue(t,e){var n,s;if(!e)return e;if(((s=(n=this.collector)==null?void 0:n.getLocalId)==null?void 0:s.call(n,t))===De||e.toolsType===K.Selector)return;const r=ume(e);return r.status==="unrecoverable"?ve.cloneDeep(e):r.value}diffFun(t,e,r=!0,n=this.excludeIds,s){const o=new Set,a=t.keys(),c=e.keys();for(const l of a){if(!kg(l,n,s))continue;const u=this.normalizeUndoSnapshotValue(l,t.get(l)),h=this.normalizeUndoSnapshotValue(l,e.get(l));if(!(!u&&!h)){if(u&&h){if(ve.isEqual(h,u)||this.especialDiff(r,er.Update,h,u))continue;o.add({dataType:er.Update,key:l,data:[u,h]});continue}this.especialDiff(r,er.Delete,u)||u&&o.add({dataType:er.Delete,key:l,data:u})}}for(const l of c){if(!kg(l,n,s))continue;const u=this.normalizeUndoSnapshotValue(l,e.get(l));if(u&&!t.has(l)){if(this.especialDiff(r,er.Draw,u))continue;o.add({dataType:er.Draw,key:l,data:u})}}return o}isDrawEffectiveScene(t,e){const{key:r}=t;return!e.includes(r)}isDeleteEffectiveScene(t,e){const{key:r}=t;return!!e.includes(r)}isOldEffectiveScene(t,e){const{key:r}=t;return!!e.includes(r)}isNewEffectiveScene(t,e){const{key:r}=t;return!!e.includes(r)}refreshPlugin(t,e=!1){var l,u,h,d,g,p,v,I,D,x,j,w,y,f,M,T,b;let r;const{scenePath:n}=t,s=t.data;if(!s||!this.collector)return;const a={...this.collector.getStorageData(this.viewId,n)||{}};let c=!1;for(const C of s.values()){const{dataType:P,data:E,key:O}=C,V=this.collector.getStorageData(this.viewId,n),N=V&&Object.keys(V)||[];switch(P){case er.Draw:if(r=e?this.isDrawEffectiveScene(C,N):this.isDeleteEffectiveScene(C,N),r)if(e&&!Array.isArray(E)){if((l=E.updateNodeOpt)!=null&&l.useAnimation&&(E.updateNodeOpt.useAnimation=!1),((u=this.collector)==null?void 0:u.getLocalId(O))===De&&((h=this.collector)!=null&&h.isOwn(C.key))){const A=E.selectIds;if(A){const k=N.filter(Z=>{var Q,ce;return((Q=this.collector)==null?void 0:Q.getLocalId(Z))===De&&!((ce=this.collector)!=null&&ce.isOwn(Z))}).map(Z=>{var Q;return(Q=this.collector)==null?void 0:Q.storage[this.viewId][n][Z]});let U=!1;for(const Z of k)for(let Q=0;Q<A.length;Q++)(d=Z==null?void 0:Z.selectIds)!=null&&d.includes(A[Q])&&(delete A[Q],U=!0);U&&(E.selectIds=A.filter(Z=>!!Z))}}a[C.key]=E,c=!0}else!e&&!Array.isArray(C.data)&&(delete a[C.key],c=!0);break;case er.Delete:if(r=e?this.isDeleteEffectiveScene(C,N):this.isDrawEffectiveScene(C,N),r){if(e&&!Array.isArray(E))delete a[O],c=!0;else if(!e&&!Array.isArray(E)){if((g=E.updateNodeOpt)!=null&&g.useAnimation&&(E.updateNodeOpt.useAnimation=!1),((p=this.collector)==null?void 0:p.getLocalId(C.key))===De&&((v=this.collector)!=null&&v.isOwn(C.key))){const A=E.selectIds;if(A){const k=N.filter(Z=>{var Q,ce;return((Q=this.collector)==null?void 0:Q.getLocalId(Z))===De&&!((ce=this.collector)!=null&&ce.isOwn(Z))}).map(Z=>{var Q;return(Q=this.collector)==null?void 0:Q.storage[this.viewId][n][Z]});let U=!1;for(const Z of k)for(let Q=0;Q<A.length;Q++)(I=Z==null?void 0:Z.selectIds)!=null&&I.includes(A[Q])&&(delete A[Q],U=!0);U&&(E.selectIds=A.filter(Z=>!!Z))}}a[C.key]=E,c=!0}}break;case er.Update:if(r=e?this.isNewEffectiveScene(C,N):this.isOldEffectiveScene(C,N),r){if(e&&Array.isArray(E)&&E.length===2){const A=E[1];if((D=A.updateNodeOpt)!=null&&D.useAnimation&&(A.updateNodeOpt.useAnimation=!1),((x=this.collector)==null?void 0:x.getLocalId(C.key))===De&&((j=this.collector)!=null&&j.isOwn(C.key))){const k=A.selectIds;if(k){const U=N.filter(Q=>{var ce,L;return((ce=this.collector)==null?void 0:ce.getLocalId(Q))===De&&!((L=this.collector)!=null&&L.isOwn(Q))}).map(Q=>{var ce;return(ce=this.collector)==null?void 0:ce.storage[this.viewId][n][Q]});let Z=!1;for(const Q of U)for(let ce=0;ce<k.length;ce++)Q!=null&&Q.selectIds&&((w=Q.selectIds)!=null&&w.includes(k[ce]))&&(delete k[ce],Z=!0);Z&&(A.selectIds=k.filter(Q=>!!Q))}}a[O]=A,c=!0}else if(!e&&Array.isArray(E)&&E.length===2){const A=E[0];if((y=A.updateNodeOpt)!=null&&y.useAnimation&&(A.updateNodeOpt.useAnimation=!1),((f=this.collector)==null?void 0:f.getLocalId(C.key))===De&&((M=this.collector)!=null&&M.isOwn(C.key))){const k=A.selectIds;if(k){const U=N.filter(Q=>{var ce,L;return((ce=this.collector)==null?void 0:ce.getLocalId(Q))===De&&!((L=this.collector)!=null&&L.isOwn(Q))}).map(Q=>{var ce;return(ce=this.collector)==null?void 0:ce.storage[this.viewId][n][Q]});let Z=!1;for(const Q of U)for(let ce=0;ce<k.length;ce++)Q!=null&&Q.selectIds&&Q.selectIds.includes(k[ce])&&(delete k[ce],Z=!0);Z&&(A.selectIds=k.filter(Q=>!!Q))}}a[C.key]=A,c=!0}}break}}if(c){const C=this.collector.plugin,P=(T=C==null?void 0:C.getAttributesValue)==null?void 0:T.call(C,[Vr.namespace]),E=(b=C==null?void 0:C.getAttributesValue)==null?void 0:b.call(C,[Vr.namespace,this.viewId]);P?E?C==null||C.updateAttributes([Vr.namespace,this.viewId,n],a):C==null||C.updateAttributes([Vr.namespace,this.viewId],{[n]:a}):C==null||C.updateAttributes([Vr.namespace],{[this.viewId]:{[n]:a}})}}};R($r,"sdkCallBack"),R($r,"MaxStackLength",He.undoRedo.maxStackLength),R($r,"waitTime",100);let pu=$r;const Qve=(i,t)=>({...i,...t}),qg=(i,...t)=>t.reduce((e,r)=>({images:Qve(e.images,r==null?void 0:r.images),size:(r==null?void 0:r.size)||e.size,offset:{...e.offset,...r==null?void 0:r.offset}}),i),Fo={[K.Selector]:{applianceKey:Ne.selector,classSuffix:"selector",hostClassName:"cursor-selector"},[K.Clicker]:{applianceKey:Ne.clicker,classSuffix:"clicker",hostClassName:"cursor-clicker"},[K.Text]:{applianceKey:Ne.text,classSuffix:"text",hostClassName:"cursor-text"},[K.Pencil]:{applianceKey:Ne.pencil,classSuffix:"pencil",hostClassName:"cursor-pencil"},[K.LaserPen]:{applianceKey:Ne.laserPen,classSuffix:"laser-pen",hostClassName:"cursor-pencil"},[K.Arrow]:{applianceKey:Ne.arrow,classSuffix:"arrow",hostClassName:"cursor-arrow"},[K.Straight]:{applianceKey:Ne.straight,classSuffix:"straight",hostClassName:"cursor-straight"},[K.Rectangle]:{applianceKey:Ne.rectangle,classSuffix:"rectangle",hostClassName:"cursor-rectangle"},[K.Ellipse]:{applianceKey:Ne.ellipse,classSuffix:"ellipse",hostClassName:"cursor-ellipse"},[K.Star]:{applianceKey:rr.star,classSuffix:"star",hostClassName:"cursor-shape"},[K.Polygon]:{applianceKey:rr.polygon,classSuffix:"polygon",hostClassName:"cursor-shape"},[K.SpeechBalloon]:{applianceKey:rr.speechBalloon,classSuffix:"speech-balloon",hostClassName:"cursor-shape"},[K.Eraser]:{applianceKey:Ne.eraser,classSuffix:"eraser",hostClassName:"cursor-eraser"},[K.PencilEraser]:{applianceKey:Ne.pencilEraser,classSuffix:"pencil-eraser",hostClassName:"cursor-eraser"},[K.BitMapEraser]:{applianceKey:rr.bitMapEraser,classSuffix:"bitmap-eraser",hostClassName:"cursor-eraser"}},Zve={[K.Selector]:Ne.selector,[K.Clicker]:Ne.clicker,[K.Text]:Ne.text,[K.Pencil]:Ne.pencil,[K.Arrow]:Ne.arrow,[K.Straight]:Ne.straight,[K.Rectangle]:Ne.rectangle,[K.Ellipse]:Ne.ellipse,[K.Eraser]:Ne.eraser,[K.PencilEraser]:Ne.pencilEraser};function Kve(i,t){if(!(!i||t===void 0)&&i.currentApplianceName!==Ne.laserPointer)return t===K.LaserPen?i.currentApplianceName===Ne.pencil&&i.useLaserPen?Fo[t]:void 0:t===K.Star||t===K.Polygon||t===K.SpeechBalloon?i.currentApplianceName===Ne.shape?Fo[t]:void 0:t===K.BitMapEraser?i.currentApplianceName===Ne.pencilEraser?Fo[t]:void 0:Zve[t]===i.currentApplianceName?Fo[t]:void 0}class j0{constructor(t){R(this,"options");this.options=Nh(t)}getAppearance(t){return this.options.appearance[t]||Xo[t]}getLocal(t){var s;const e=Xo[t],r=this.getAppearance(t),n=qg(e,e.local,r,r.local);return{...n,size:n.size||e.local.size,fallback:((s=r.local)==null?void 0:s.fallback)||"auto"}}getSynced(t){const e=Xo[t],r=this.getAppearance(t);return qg(e,e.synced,r,r.synced)}getSyncedEnableShowName(t){return Zfe(this.options,t)}getLocalCursorOwnership(t){const e=this.options.appearance[t];return e&&(e.local||e.images||e.offset||e.size)?"custom":"plugin-default"}}function Xg(i){const t=i.trim().toLowerCase();return t.startsWith("data:image/svg+xml")||/\.svg(?:[?#]|$)/i.test(t)}function Vh(i){const t=i.highResolution;if(!(!t||t===i.standardResolution||Xg(i.standardResolution)||Xg(t)))return t}function qve(i){var c,l;const t=Math.round(-i.offset.x),e=Math.round(i.size.height-i.offset.y),r=i.fallback,n=`url("${i.images.standardResolution}") ${t} ${e}, ${r}`,s=Vh(i.images);if(!s)return n;const o=`image-set(url("${i.images.standardResolution}") 1x, url("${s}") 2x) ${t} ${e}, ${r}`,a=`-webkit-image-set(url("${i.images.standardResolution}") 1x, url("${s}") 2x) ${t} ${e}, ${r}`;return typeof CSS<"u"&&((c=CSS.supports)!=null&&c.call(CSS,"cursor",o))?o:typeof CSS<"u"&&((l=CSS.supports)!=null&&l.call(CSS,"cursor",a))?a:n}class Oi{constructor(t){R(this,"internalMsgEmitter");R(this,"control");R(this,"mainView");R(this,"appViews",new Map);R(this,"undoTickerStart",(t,e,r)=>{const n=this.getView(e);n&&n.displayer&&n.focusScenePath&&n.displayer.commiter.undoTickerStart(t,n.focusScenePath,r)});R(this,"addExcludeIds",(t,e)=>{const r=this.getView(e);r&&r.displayer&&r.focusScenePath&&r.displayer.commiter.addExcludeIds(t)});R(this,"onAckRenderUndoTicker",(t,e,r,n)=>{const s=this.getView(e);if(!(s!=null&&s.displayer)||!s.focusScenePath)return;const o=r||s.focusScenePath;s.displayer.commiter.ackRender(t,o,n)});R(this,"onAckStorageUndoTicker",(t,e,r,n,s)=>{const o=this.getView(e);if(!(o!=null&&o.displayer)||!o.focusScenePath)return;const a=r||o.focusScenePath;o.displayer.commiter.ackStorage(t,a,n,s)});R(this,"onCollectExpectedWorkIds",(t,e,r,n)=>{const s=this.getView(e);if(!(s!=null&&s.displayer)||!s.focusScenePath)return;const o=n||s.focusScenePath;s.displayer.commiter.collectExpectedWorkIds(t,o,r)});R(this,"onFinalizeRequested",(t,e,r,n)=>{const s=this.getView(e);if(!(s!=null&&s.displayer)||!s.focusScenePath)return;const o=n||s.focusScenePath;s.displayer.commiter.finalizeRequested(t,o,r)});R(this,"onReopenStorageAck",(t,e,r,n)=>{const s=this.getView(e);if(!(s!=null&&s.displayer)||!s.focusScenePath)return;const o=n||s.focusScenePath;s.displayer.commiter.reopenStorageAck(t,o,r)});R(this,"onCancelUndoTicker",(t,e,r)=>{const n=this.getView(e);if(!(n!=null&&n.displayer)||!n.focusScenePath)return;const s=r||n.focusScenePath;n.displayer.commiter.cancelUndoTicker(t,e,s)});const{control:e,internalMsgEmitter:r}=t;this.control=e,this.internalMsgEmitter=r,this.internalMsgEmitter.on("addUndoTicker",this.undoTickerStart),this.internalMsgEmitter.on("excludeIds",this.addExcludeIds),this.internalMsgEmitter.on("ackRenderUndoTicker",this.onAckRenderUndoTicker),this.internalMsgEmitter.on("ackStorageUndoTicker",this.onAckStorageUndoTicker),this.internalMsgEmitter.on("collectExpectedWorkIds",this.onCollectExpectedWorkIds),this.internalMsgEmitter.on("reopenStorageAck",this.onReopenStorageAck),this.internalMsgEmitter.on("finalizeRequested",this.onFinalizeRequested),this.internalMsgEmitter.on("cancelUndoTicker",this.onCancelUndoTicker)}get worker(){return this.control.worker}getUndoTickerId(t){const e=this.getView(t);if(e&&e.displayer&&e.focusScenePath)return e.displayer.commiter.undoTickerId}undo(){const t=this.focuedView;let e=0;if(t){const r=t.focusScenePath;e=t.displayer.commiter.undo(r)||0}return e}redo(){const t=this.focuedView;let e=0;if(t){const r=t.focusScenePath;e=t.displayer.commiter.redo(r)||0}return e}validator(t,e,r){var o;const n=ve.clone(t[e]),s=ve.clone(r);e==="focusScenePath"&&!ve.isEqual(n,s)&&(this.control.backgroundImageLoadCoordinator.cancelByViewScene(t.id,n),this.control.internalSceneChange(t.id,s),(o=this.focuedView)==null||o.displayer.commiter.onChangeScene()),e==="cameraOpt"&&!ve.isEqual(n,s)&&this.control.internalCameraChange(t.id,s)}destroyAppView(t,e=!1){this.control.backgroundImageLoadCoordinator.cancelByViewScene(t),this.control.destroySceneChange(t),this.control.worker.cameraUpdateDestroy(t);const r=this.appViews.get(t);r&&(this.control.textEditorManager.clear(t,e),r.displayer.destroy(),this.appViews.delete(t))}createMianView(t){this.mainView=new Proxy(t,{set:(e,r,n)=>(this.worker.isActive&&this.validator(e,r,n),e[r]=n,!0)})}createAppView(t){const e=t.id,r=new Proxy(t,{set:(n,s,o)=>(this.worker.isActive&&this.validator(n,s,o),n[s]=o,!0)});this.appViews.set(e,r)}isAppView(t){return t!==Ue&&this.appViews.has(t)}getView(t){var e;return t===Ue?this.mainView:(e=this.appViews)==null?void 0:e.get(t)}resolveView(t){const e=t||this.focuedViewId||Ue,r=this.getView(e);return!t&&!r&&e!==Ue?{viewId:Ue,view:this.getView(Ue)}:{viewId:e,view:r}}getViewElement(t){var e;return((e=t.viewData)==null?void 0:e.divElement)||t.container||t.displayer.eventTragetElement}getFloatbarContainer(t){const{view:e}=this.resolveView(t);return(e==null?void 0:e.displayer.customFloatbarContainerRef.current)||void 0}getViewOffsetToContainer(t,e){if(!t)return;const{viewId:r,view:n}=this.resolveView(e);if(!n)return;const s=this.getViewElement(n);if(!s)return;const o=s.getBoundingClientRect(),a=t.getBoundingClientRect();return{x:o.left-a.left,y:o.top-a.top,viewId:r}}getCurScenePath(t){const e=this.getView(t);if(e)return e.focusScenePath}getAllViews(){return[this.mainView,...this.appViews.values()]}setViewScenePath(t,e){var r;if(t===Ue&&this.mainView)this.mainView.focusScenePath=e;else{const n=t&&((r=this.appViews)==null?void 0:r.get(t))||void 0;n&&(n.focusScenePath=e)}}setViewData(t,e){var r;if(t===Ue&&this.mainView)this.mainView.viewData=e;else{const n=t&&((r=this.appViews)==null?void 0:r.get(t))||void 0;n&&(n.viewData=e)}}setFocuedViewId(t){var e;this.focuedViewId=t,t===Ue?this.focuedView=this.mainView:this.focuedView=t&&((e=this.appViews)==null?void 0:e.get(t))||void 0,this.worker.currentToolsData&&this.worker.currentToolsData.toolsType===K.Text&&this.activeTextEditor(t),this.control.cursor.onFocusViewChange(),this.focuedView&&this.focuedView.displayer.commiter.onFocusView()}setViewFocusScenePath(t,e){var n;let r;t===Ue?r=this.mainView:r=(n=this.appViews)==null?void 0:n.get(t),r&&(r.focusScenePath=e)}destroy(){var t;this.internalMsgEmitter.off("addUndoTicker",this.undoTickerStart),this.internalMsgEmitter.off("excludeIds",this.addExcludeIds),this.internalMsgEmitter.off("ackRenderUndoTicker",this.onAckRenderUndoTicker),this.internalMsgEmitter.off("ackStorageUndoTicker",this.onAckStorageUndoTicker),this.internalMsgEmitter.off("collectExpectedWorkIds",this.onCollectExpectedWorkIds),this.internalMsgEmitter.off("reopenStorageAck",this.onReopenStorageAck),this.internalMsgEmitter.off("finalizeRequested",this.onFinalizeRequested),this.internalMsgEmitter.off("cancelUndoTicker",this.onCancelUndoTicker),(t=this.mainView)==null||t.displayer.destroy(),this.control.destroyMiniMap(Ue),this.appViews.forEach(e=>{this.destroyAppView(e.id,!0),this.worker.destroyViewWorker(e.id),this.control.destroyMiniMap(e.id)})}setFocuedViewCameraOpt(t){if(this.focuedView){const e=this.focuedView.cameraOpt;ve.isEqual(e,t)||(this.focuedView.cameraOpt=t)}}transformToOriginPoint(t,e){const r=this.getView(e);if(r!=null&&r.viewData){const n=r.viewData.convertToPointOnScreen(t[0],t[1]);return[n.x,n.y]}return t}transformToScenePoint(t,e){const r=this.getView(e);if(r!=null&&r.viewData){const n=r.viewData.convertToPointInWorld({x:t[0],y:t[1]});return[n.x,n.y]}return t}render(t){var e,r,n,s,o,a,c,l,u,h,d,g,p,v,I,D,x;for(const j of t){const{rect:w,imageBitmap:y,isClear:f,isUnClose:M,drawCanvas:T,clearCanvas:b,viewId:C}=j,P=(e=this.getView(C))==null?void 0:e.displayer;if(P&&w){const{dpr:E,canvasBgRef:O,canvasFloatRef:V,canvasServiceFloatRef:N,canvasTopRef:A}=P,k=Math.floor(w.w*E),U=Math.floor(w.h*E),Z=w.x*E,Q=w.y*E;if(f){switch(b){case _e.TopFloat:(n=(r=A==null?void 0:A.current)==null?void 0:r.getContext("2d"))==null||n.clearRect(Z,Q,k,U);break;case _e.Float:(o=(s=V.current)==null?void 0:s.getContext("2d"))==null||o.clearRect(Z,Q,k,U);break;case _e.ServiceFloat:(c=(a=N.current)==null?void 0:a.getContext("2d"))==null||c.clearRect(Z,Q,k,U);break;case _e.Bg:(u=(l=O.current)==null?void 0:l.getContext("2d"))==null||u.clearRect(Z,Q,k,U);break}continue}if(T&&y)switch(T){case _e.TopFloat:(d=(h=A==null?void 0:A.current)==null?void 0:h.getContext("2d"))==null||d.drawImage(y,0,0,k,U,Z,Q,k,U);break;case _e.Float:{(p=(g=V.current)==null?void 0:g.getContext("2d"))==null||p.drawImage(y,0,0,k,U,Z,Q,k,U);break}case _e.ServiceFloat:{(I=(v=N.current)==null?void 0:v.getContext("2d"))==null||I.drawImage(y,0,0,k,U,Z,Q,k,U);break}case _e.Bg:{(x=(D=O.current)==null?void 0:D.getContext("2d"))==null||x.drawImage(y,0,0,k,U,Z,Q,k,U);break}}if(M)continue;y==null||y.close()}}}showFloatBar(t,e,r){const n=this.getView(t),s=n==null?void 0:n.displayer.vDom;s&&s.showFloatBar(e,r)}activeTextEditor(t){const e=this.getView(t),r=e==null?void 0:e.displayer.vDom;r&&r.activeTextEditor()}unActiveTextEditor(t){const e=this.getView(t),r=e==null?void 0:e.displayer.vDom;r&&r.unActiveTextEditor()}showFloatBarBtn(t,e){const r=this.getView(t),n=r==null?void 0:r.displayer.vDom;n&&n.showFloatBarBtn(e)}updateTextEditorInfo(t,e,r){const n=this.getView(t),s=n==null?void 0:n.displayer.vDom;if(s){s.updateTextEditorInfo(e,r);return}r==null||r()}renderTextEditorInfo(t,e,r){const n=this.getView(t),s=n==null?void 0:n.displayer.vDom;if(s){s.renderTextEditorInfo(e,r);return}r==null||r()}renderTextEditorInfoAsync(t,e){return new Promise(r=>{this.renderTextEditorInfo(t,e,r)})}updateTextEditorInfoAsync(t,e){return new Promise(r=>{this.updateTextEditorInfo(t,e,r)})}setActiveMiniMap(t,e){const r=this.getView(t),n=r==null?void 0:r.displayer.vDom;n&&n.setActiveMiniMap(e&&t||void 0)}}R(Oi,"defaultCameraOpt",{centerX:0,centerY:0,scale:1}),R(Oi,"defaultScreenCanvasOpt",{autoRender:!1,contextType:"2d"}),R(Oi,"defaultLayerOpt",{offscreen:!0,handleEvent:!1,depth:!1});class B0{constructor(t,e,r){R(this,"control");R(this,"internalMsgEmitter");R(this,"commiter");R(this,"cachePoint");R(this,"cacheCursorPoint");R(this,"active",!0);R(this,"toolsKey");R(this,"activePointers",new Set);R(this,"currentDrawingPointerId");R(this,"pointerDrawingSession",0);R(this,"currentPointerDrawingSession");R(this,"isTouchDrawing",!1);R(this,"cursorMouseMove");R(this,"cursorMouseMoveDebounced");R(this,"cursorMouseMoveThrottled");R(this,"cursorMouseMoveFun");R(this,"cursorEventElement");R(this,"appliedCursorClassNames",[]);R(this,"_transferControlToOffscreenCanvas");R(this,"cursorMouseLeave",()=>{this.control.pluginOptions.extras.cursor.enable?this.cursorMouseMoveThrottled.cancel():this.cursorMouseMoveDebounced.cancel(),this.cacheCursorPoint=[void 0,void 0],this.worker.sendCursorEvent(this.cacheCursorPoint,this.viewId)});R(this,"keydown",t=>{t.stopPropagation(),t.stopImmediatePropagation(),this.control.hotkeyManager.colloctHotkey(t)});R(this,"windowBlur",()=>{this.currentDrawingPointerId!==void 0&&this.cancelPointerDrawing("window-blur")});R(this,"visibilitychange",()=>{document.visibilityState==="hidden"&&this.currentDrawingPointerId!==void 0&&this.cancelPointerDrawing("document-hidden")});R(this,"pointerdown",t=>{var e;if(this.active&&this.consumeClickerEvent(t)){const r=this.getPoint(t);r&&this.worker.sendCursorEvent(r,this.viewId);return}if(!(!this.active||this.worker.isViewBusy(this.viewId)||this.control.isSceneBusy(this.viewId))){if(t.pointerType==="touch"&&(this.activePointers.add(t.pointerId),this.activePointers.size>1)){this.cancelPointerDrawing("multi-pointer-down",!0);return}if(t.button===0&&this.viewId){this.toolsKey=(e=this.worker.getCurrentToolsData())==null?void 0:e.toolsType,!this.worker.isAbled()&&this.toolsKey&&this.control.effectViewContainer(this.toolsKey),this.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const r=this.getPoint(t);this.cachePoint=r,r&&(this.currentDrawingPointerId=t.pointerId,this.currentPointerDrawingSession=++this.pointerDrawingSession,this.worker.originalEventLintener(ge.Start,r,this.viewId),this.addPointerDocumentEvents())}}});R(this,"pointermove",t=>{if(this.active){if(t.pointerType==="touch"){if(this.activePointers.size>1){this.cancelPointerDrawing("multi-pointer-move",!0);return}if(this.currentDrawingPointerId!==void 0&&t.pointerId!==this.currentDrawingPointerId)return;if(!this.worker.isAbled()){this.cancelPointerDrawing("worker-disabled",!0);return}}if(this.viewId){const e=this.getPoint(t);if(this.cachePoint=e,this.checkConsumeCount())return;e&&this.worker.originalEventLintener(ge.Doing,e,this.viewId)}}});R(this,"pointerup",t=>{if(this.active&&(t.pointerType==="touch"&&this.activePointers.delete(t.pointerId),!(this.currentDrawingPointerId!==void 0&&t.pointerId!==this.currentDrawingPointerId))){if(this.currentDrawingPointerId===void 0){this.clearPointerDocumentEvents();return}if(t.pointerType==="touch"&&(this.activePointers.size>0||!this.worker.isAbled())){this.cancelPointerDrawing("touch-pointer-up-invalid",!0);return}if(t.button===0&&this.viewId){const e=this.getPoint(t)||this.cachePoint;if(e){const r=this.currentPointerDrawingSession;this.worker.originalEventLintener(ge.Done,e,this.viewId).finally(()=>{r===this.currentPointerDrawingSession&&(this.clearPointerDocumentEvents(),this.currentPointerDrawingSession=void 0)}),this.cachePoint=void 0,this.currentDrawingPointerId=void 0}else this.cancelPointerDrawing("pointer-up-without-point")}t.pointerType==="touch"&&this.activePointers.size===0&&this.activePointers.clear()}});R(this,"pointercancel",t=>{this.currentDrawingPointerId!==void 0&&t.pointerId!==this.currentDrawingPointerId||this.cancelPointerDrawing("pointer-cancel")});R(this,"touchstart",t=>{var r;if(this.active&&this.consumeClickerEvent(t)){const n=this.getPoint(t);n&&this.worker.sendCursorEvent(n,this.viewId);return}if(!this.active||this.worker.isViewBusy(this.viewId)||this.control.isSceneBusy(this.viewId))return;if(t.touches.length!==1){this.cancelTouchDrawing();return}if(t.preventDefault(),!this.viewId)return;this.toolsKey=(r=this.worker.getCurrentToolsData())==null?void 0:r.toolsType,!this.worker.isAbled()&&this.toolsKey&&this.control.effectViewContainer(this.toolsKey),this.worker.checkDrawingWork(this.viewId);const e=this.getPoint(t);this.cachePoint=e,e&&(this.isTouchDrawing=!0,this.worker.originalEventLintener(ge.Start,e,this.viewId),document.addEventListener("touchmove",this.touchmove,{passive:!1}),document.addEventListener("touchend",this.touchend,!1),document.addEventListener("touchcancel",this.touchcancel,!1))});R(this,"touchmove",t=>{if(!this.active||!this.isTouchDrawing)return;if(t.touches.length!==1||!this.worker.isAbled()){this.cancelTouchDrawing();return}t.preventDefault();const e=this.getPoint(t);this.cachePoint=e,!this.checkConsumeCount()&&e&&this.worker.originalEventLintener(ge.Doing,e,this.viewId)});R(this,"touchend",t=>{if(!this.active||!this.isTouchDrawing)return;if(t.touches.length>0||!this.worker.isAbled()){this.cancelTouchDrawing();return}t.preventDefault();const e=this.getPoint(t)||this.cachePoint;this.clearTouchDocumentEvents(),this.cachePoint=void 0,this.isTouchDrawing=!1,e&&this.worker.originalEventLintener(ge.Done,e,this.viewId)});R(this,"touchcancel",()=>{this.cancelTouchDrawing()});this.control=t,this.internalMsgEmitter=e;const n={control:this.control,internalMsgEmitter:this.internalMsgEmitter,viewId:r,enableGlobal:!!this.control.pluginOptions.extras.undoRedo.enableGlobal};this.commiter=new pu(n),this.cursorMouseMoveFun=s=>{const o=this.getPoint(s);this.cacheCursorPoint&&ve.isEqual(o,this.cacheCursorPoint)||(this.cacheCursorPoint=o,o&&this.worker.sendCursorEvent(o,this.viewId))},this.cursorMouseMoveDebounced=ve.debounce(this.cursorMouseMoveFun,this.moveDelayTime,{trailing:!0}),this.cursorMouseMoveThrottled=ve.throttle(this.cursorMouseMoveFun,this.moveDelayTime,{leading:!0}),this.cursorMouseMove=s=>{this.consumeClickerEvent(s),this.control.pluginOptions.extras.cursor.enable?this.cursorMouseMoveThrottled(s):this.cursorMouseMoveDebounced(s)},this.setActive(t.renderControl.isWritable)}consumeClickerEvent(t){var e;return((e=this.worker.getCurrentToolsData())==null?void 0:e.toolsType)!==K.Clicker?!1:(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),!0)}get moveDelayTime(){var t,e;return((e=(t=this.control.pluginOptions.extras)==null?void 0:t.cursor)==null?void 0:e.moveDelayTime)??He.cursor.moveDelayTime}setTransferControlToOffscreenCanvas(t){this._transferControlToOffscreenCanvas={bgCanvas:t.bgCanvas.transferControlToOffscreen(),serviceCanvas:t.serviceCanvas.transferControlToOffscreen(),localCanvas:t.localCanvas.transferControlToOffscreen()}}get transferControlToOffscreenCanvas(){return this._transferControlToOffscreenCanvas}get worker(){return this.control.worker}bindToolsClass(){var c,l,u;const t=(l=(c=this.worker)==null?void 0:c.currentToolsData)==null?void 0:l.toolsType,e=this.control.renderControl.isWritable,r=this.worker.isAbled(),n=(u=this.control.room)==null?void 0:u.state.memberState,s=Kve(n,t),o=[],a=e&&r;if(a&&s){o.push(s.hostClassName),o.push(`cursor-tool-${s.classSuffix}`);const h=new j0(this.control.pluginOptions.extras.cursor),d=h.getLocalCursorOwnership(s.applianceKey),g=h.getLocal(s.applianceKey);o.push(d==="custom"?"custom-cursor":"plugin-cursor",`${d==="custom"?"custom-cursor":"plugin-cursor"}-${s.classSuffix}`),this.eventTragetElement&&this.eventTragetElement.style.setProperty("cursor",qve(g),"important")}this.eventTragetElement&&(this.eventTragetElement.classList.remove(...this.appliedCursorClassNames),o.length&&this.eventTragetElement.classList.add(...o),this.appliedCursorClassNames=o,(!a||!s)&&this.eventTragetElement.style.removeProperty("cursor"))}mountView(){this.setCanvassStyle(),this.control.viewContainerManager.mountView(this.viewId)}updateSize(){this.setCanvassStyle(),this.reflashContainerOffset()}reflashContainerOffset(){this.eventTragetElement&&(this.containerOffset=this.getContainerOffset(this.eventTragetElement,{x:0,y:0}))}get parentElement(){var t;return(t=this.eventTragetElement)==null?void 0:t.parentElement}destroy(){this.cancelPointerDrawing("destroy"),this.eventTragetElement&&this.removeDisplayerEvent(this.eventTragetElement),this.vDom=void 0,this.control.cursor.clearViewCursor(this.viewId),this.internalMsgEmitter.removeAllListeners([Fe.Cursor,this.viewId])}getPoint(t){if(!this.eventTragetElement)return;const e=Wve(t);if(!ve.isNumber(e.x)||!ve.isNumber(e.y))return;const r=this.eventTragetElement.getBoundingClientRect();return[e.x-r.left,e.y-r.top]}getActive(){return this.active}setActive(t){this.active=t,this.control.isUseBackgroundThread&&this.backgroundContainerRef&&this.backgroundContainerRef.current&&this.backgroundContainerRef.current.classList.toggle("appliance-plugin-background-isWritable",t)}focusElement(){var t;(t=this.eventTragetElement)==null||t.focus()}async stopEventHandler(){this.cachePoint&&(await this.worker.originalEventLintener(ge.Done,this.cachePoint,this.viewId).finally(()=>{this.clearPointerDocumentEvents(),this.clearTouchDocumentEvents()}),this.cachePoint=void 0,this.activePointers.clear(),this.currentDrawingPointerId=void 0,this.currentPointerDrawingSession=void 0,this.isTouchDrawing=!1)}getTranslate(t){const r=(t.style.WebkitTransform||getComputedStyle(t,"").getPropertyValue("-webkit-transform")||t.style.transform||getComputedStyle(t,"").getPropertyValue("transform")).match(/-?[0-9]+\.?[0-9]*/g),n=r&&parseInt(r[0])||0,s=r&&parseInt(r[1])||0;return[n,s]}getContainerOffset(t,e){var s;const r=this.getTranslate(t);let n={x:e.x+t.offsetLeft-t.scrollLeft+r[0],y:e.y+t.offsetTop-t.scrollTop+r[1]};return(s=t.offsetParent)!=null&&s.nodeName&&t.offsetParent.nodeName!=="BODY"&&(n=this.getContainerOffset(t.offsetParent,n)),n}addPointerDocumentEvents(){document.addEventListener("pointermove",this.pointermove,!1),document.addEventListener("pointerup",this.pointerup,!1),document.addEventListener("pointercancel",this.pointercancel,!1),document.addEventListener("visibilitychange",this.visibilitychange,!1),window.addEventListener("blur",this.windowBlur,!1)}clearPointerDocumentEvents(){document.removeEventListener("pointermove",this.pointermove,!1),document.removeEventListener("pointerup",this.pointerup,!1),document.removeEventListener("pointercancel",this.pointercancel,!1),document.removeEventListener("visibilitychange",this.visibilitychange,!1),window.removeEventListener("blur",this.windowBlur,!1)}resetPointerDrawingState(){this.cachePoint=void 0,this.currentDrawingPointerId=void 0,this.currentPointerDrawingSession=void 0,this.activePointers.clear()}cancelPointerDrawing(t,e=!1){this.currentDrawingPointerId!==void 0&&this.viewId&&(e&&this.worker.unWritable(),this.worker.removeDrawingWork(this.viewId)),this.clearPointerDocumentEvents(),this.resetPointerDrawingState()}clearTouchDocumentEvents(){document.removeEventListener("touchmove",this.touchmove,!1),document.removeEventListener("touchend",this.touchend,!1),document.removeEventListener("touchcancel",this.touchcancel,!1)}cancelTouchDrawing(){this.isTouchDrawing&&(this.worker.unWritable(),this.viewId&&this.worker.removeDrawingWork(this.viewId)),this.clearTouchDocumentEvents(),this.cachePoint=void 0,this.isTouchDrawing=!1}bindDisplayerEvent(t){"PointerEvent"in window?t.addEventListener("pointerdown",this.pointerdown,!1):t.addEventListener("touchstart",this.touchstart,{passive:!1}),this.cursorEventElement=t.parentElement||t,this.cursorEventElement.addEventListener("mousemove",this.cursorMouseMove,!0),this.cursorEventElement.addEventListener("mouseleave",this.cursorMouseLeave,!1),t.addEventListener("keydown",this.keydown,!0)}removeDisplayerEvent(t){var e,r;t.removeEventListener("pointerdown",this.pointerdown,!1),t.removeEventListener("touchstart",this.touchstart,!1),this.clearPointerDocumentEvents(),this.clearTouchDocumentEvents(),(e=this.cursorEventElement)==null||e.removeEventListener("mousemove",this.cursorMouseMove,!0),(r=this.cursorEventElement)==null||r.removeEventListener("mouseleave",this.cursorMouseLeave,!1),this.cursorEventElement=void 0,t.removeEventListener("keydown",this.keydown,!0)}get isBezier(){return this.control.pluginOptions.extras.bezier.enable}get maxDrawCount(){return this.control.pluginOptions.extras.bezier.maxDrawCount||He.bezier.maxDrawCount}checkConsumeCount(){const t=this.worker.getConsumeCount();return this.cachePoint&&this.toolsKey&&this.toolsKey===K.Pencil&&t>this.maxDrawCount?(this.stopEventHandler().finally(()=>{this.worker.publicMsgEmitter.emit("forceStop",Cu.longPencil,this.viewId)}),!0):!1}}class Xve extends B0{constructor(e,r,n){super(r,n,e);R(this,"_viewId");this._viewId=e}get viewId(){return this._viewId}setViewId(e){this._viewId=e}}class U0 extends B0{constructor(t,e){super(t,e,Ue)}get viewId(){return Ue}updateSize(){this.setCanvassStyle()}destroy(){super.destroy(),this.control.cursor.destroy()}}const Jve="index-module__Container__nLsM3",_ve="index-module__BackgroundBox__zfthZ",eMe="index-module__BackgroundSvgBox__Fv1ay",tMe="index-module__BackgroundSnapshotContent__NFLAl",rMe="index-module__BackgroundSnapshotBox__NEM-C",nMe="index-module__CanvasBox__j2Xe-",iMe="index-module__FloatCanvas__d1YR7",sMe="index-module__TopFloatCanvas__7IaCw",oMe="index-module__CanvasBoxSub__hcMeK",aMe="index-module__SnapshotBox__--eeE",cMe="index-module__FloatBar__cm-EL",lMe="index-module__RotateBtn__HSSkf",uMe="index-module__ResizeBtn__yjvda",hMe="index-module__CursorBox__2UHvI",dMe="index-module__TextEditorContainer__Qm8KC",fMe="index-module__ResizeTowBox__HOllX",gMe="index-module__FloatBarBtn__FJrOG",gt={Container:Jve,BackgroundBox:_ve,BackgroundSvgBox:eMe,BackgroundSnapshotContent:tMe,BackgroundSnapshotBox:rMe,CanvasBox:nMe,FloatCanvas:iMe,TopFloatCanvas:sMe,CanvasBoxSub:oMe,SnapshotBox:aMe,FloatBar:cMe,RotateBtn:lMe,ResizeBtn:uMe,CursorBox:hMe,TextEditorContainer:dMe,ResizeTowBox:fMe,FloatBarBtn:gMe},pMe={delete:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDZ2NmEyIDIgMCAwIDEtMiAySDZhMiAyIDAgMCAxLTItMlY2aDBtMS0yYTIgMiAwIDAgMSAyLTJoMmEyIDIgMCAwIDEgMiAyaDBNMyA0aDEwIiBzdHJva2U9IiM0NDRFNjAiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==",duplicate:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgc3Ryb2tlPSIjNDQ0RTYwIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiPjxwYXRoIGQ9Ik0xMSAySDZhMSAxIDAgMCAwLTEgMXY4YTEgMSAwIDAgMCAxIDFoNmExIDEgMCAwIDAgMS0xVjRoMGwtMi0yeiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIi8+PHBhdGggZD0iTTExIDJ2MWExIDEgMCAwIDAgMSAxaDFsLTItMnoiLz48cGF0aCBkPSJNOSAxNEg0YTEgMSAwIDAgMS0xLTFWNWgwIiBzdHJva2UtbGluZWNhcD0icm91bmQiLz48L2c+PC9zdmc+","layer-pressed":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0ibTE2IDEwLTYgNCA2IDQgNi00em0tNiA4IDYgNCA2LTQiIHN0cm9rZT0iIzMzODFGRiIgZmlsbD0ibm9uZSIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+PC9zdmc+",layer:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0ibTE2IDEwLTYgNCA2IDQgNi00em0tNiA4IDYgNCA2LTQiIHN0cm9rZT0iIzQ0NEU2MCIgZmlsbD0ibm9uZSIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+PC9zdmc+",rotate:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjUiIGhlaWdodD0iMjQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgc3Ryb2tlPSIjNDQ0RTYwIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCI+PHBhdGggZD0iTTEzIDZhNiA2IDAgMSAxLTMuNzA5IDEuMjgzIi8+PHBhdGggZD0ibTEzIDYgMS40MTQgMi40NUwxMyA2bDIuNDUtMS40MTQiLz48L2c+PC9zdmc+","rotation-button":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0iI0ZGRiIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBvcGFjaXR5PSIuMDEiIGQ9Ik0wIDI0VjBoMjR2MjR6Ii8+PHBhdGggZD0iTTUuNzI0IDUuNzI0QTguODQ3IDguODQ3IDAgMCAxIDEyIDMuMTI1YzIuMjcxIDAgNC41NDMuODY2IDYuMjc2IDIuNmE4Ljg0NiA4Ljg0NiAwIDAgMSAyLjU5OCA2LjE0IDguODQ5IDguODQ5IDAgMCAxLTIuNTU5IDYuMzdsLTEuNS0uOTgzQTcuMTA1IDcuMTA1IDAgMCAwIDE5LjEyNSAxMmE3LjEwMyA3LjEwMyAwIDAgMC0yLjA4Ny01LjAzOEE3LjEwMyA3LjEwMyAwIDAgMCAxMiA0Ljg3NWE3LjEwMyA3LjEwMyAwIDAgMC01LjAzOCAyLjA4NyA3LjEwMSA3LjEwMSAwIDAgMC0yLjA4NiA0LjkyIDcuMTAzIDcuMTAzIDAgMCAwIDEuNzY2IDQuODE1bDEuOTQ1LTEuNTg0IDIuMzk0IDcuMTgyLTcuMjIyLTIuNDA4IDEuNzkxLTEuNzlBOC44NDYgOC44NDYgMCAwIDEgMy4xMjUgMTJjMC0yLjI3MS44NjYtNC41NDMgMi42LTYuMjc2eiIgc3Ryb2tlPSIjRkZGIiBzdHJva2Utd2lkdGg9Ii41IiBmaWxsLXJ1bGU9Im5vbnplcm8iLz48L2c+PC9zdmc+",rotation:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBmaWxsPSIjRkZGIiBvcGFjaXR5PSIuMDEiIGQ9Ik0wIDI0VjBoMjR2MjR6Ii8+PHBhdGggZD0iTTUuNzI0IDUuNzI0QTguODQ3IDguODQ3IDAgMCAxIDEyIDMuMTI1YzIuMjcxIDAgNC41NDMuODY2IDYuMjc2IDIuNmE4Ljg0NiA4Ljg0NiAwIDAgMSAyLjU5OCA2LjE0IDguODQ5IDguODQ5IDAgMCAxLTIuNTU5IDYuMzdsLTEuNS0uOTgzQTcuMTA1IDcuMTA1IDAgMCAwIDE5LjEyNSAxMmE3LjEwMyA3LjEwMyAwIDAgMC0yLjA4Ny01LjAzOEE3LjEwMyA3LjEwMyAwIDAgMCAxMiA0Ljg3NWE3LjEwMyA3LjEwMyAwIDAgMC01LjAzOCAyLjA4NyA3LjEwMSA3LjEwMSAwIDAgMC0yLjA4NiA0LjkyIDcuMTAzIDcuMTAzIDAgMCAwIDEuNzY2IDQuODE1bDEuOTQ1LTEuNTg0IDIuMzk0IDcuMTgyLTcuMjIyLTIuNDA4IDEuNzkxLTEuNzlBOC44NDYgOC44NDYgMCAwIDEgMy4xMjUgMTJjMC0yLjI3MS44NjYtNC41NDMgMi42LTYuMjc2eiIgc3Ryb2tlPSIjRkZGIiBzdHJva2Utd2lkdGg9Ii41IiBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9Im5vbnplcm8iLz48L2c+PC9zdmc+","font-colors-active":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0ibTQgMTEgNC05IDQgOU02IDdoNCIgc3Ryb2tlPSIjMzM4MUZGIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=","font-colors":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0ibTQgMTEgNC05IDQgOU02IDdoNCIgc3Ryb2tlPSIjNDQ0RTYwIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=","to-bottom":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDEwdjhtMCAwLTItMm0yIDIgMi0ybS00IDZoMTJtLTYtNGg2bS02LTRoNm0tNi00aDYiIHN0cm9rZT0iIzQ0NEU2MCIgZmlsbD0ibm9uZSIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+PC9zdmc+","to-top":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDIydi04bTAgMC0yIDJtMi0yIDIgMm0tNC02aDEybS02IDRoNm0tNiA0aDZtLTYgNGg2IiBzdHJva2U9IiM0NDRFNjAiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==","bold-active":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTQuNSAySDhhMi41IDIuNSAwIDAgMSAwIDVINS41aDBtLTEgMGg0YTMgMyAwIDAgMSAwIDZoLTQgMG0wIDFWMiIgc3Ryb2tlPSIjMzM4MUZGIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=",bold:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTQuNSAySDhhMi41IDIuNSAwIDAgMSAwIDVINS41aDBtLTEgMGg0YTMgMyAwIDAgMSAwIDZoLTQgMG0wIDFWMiIgc3Ryb2tlPSIjNDQ0RTYwIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=","underline-active":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDJ2NWE0IDQgMCAxIDEtOCAwVjJoME0zIDE0aDEwIiBzdHJva2U9IiMzMzgxRkYiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==",underline:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDJ2NWE0IDQgMCAxIDEtOCAwVjJoME0zIDE0aDEwIiBzdHJva2U9IiM0NDRFNjAiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==","line-through-active":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTQgOGg4bS0xLTNhMyAzIDAgMCAwLTMtM2gtLjkzOEEyLjY0IDIuNjQgMCAwIDAgNC41IDRhMi41NyAyLjU3IDAgMCAwIDEuMzQ0IDIuOTIybDQuMzEyIDIuMTU2QTIuNTcgMi41NyAwIDAgMSAxMS41IDEyYTIuNjQgMi42NCAwIDAgMS0yLjU2MiAySDdhMyAzIDAgMCAxLTMtM2gwIiBzdHJva2U9IiMzMzgxRkYiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==","line-through":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTQgOGg4bS0xLTNhMyAzIDAgMCAwLTMtM2gtLjkzOEEyLjY0IDIuNjQgMCAwIDAgNC41IDRhMi41NyAyLjU3IDAgMCAwIDEuMzQ0IDIuOTIybDQuMzEyIDIuMTU2QTIuNTcgMi41NyAwIDAgMSAxMS41IDEyYTIuNjQgMi42NCAwIDAgMS0yLjU2MiAySDdhMyAzIDAgMCAxLTMtM2gwIiBzdHJva2U9IiM0NDRFNjAiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==","italic-active":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTcgMTQgOSAyTTUgMTRoNE03IDJoNCIgc3Ryb2tlPSIjMzM4MUZGIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=",italic:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTcgMTQgOSAyTTUgMTRoNE03IDJoNCIgc3Ryb2tlPSIjNDQ0RTYwIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=","unlock-new":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48Y2lyY2xlIGZpbGw9IiMzMzgxRkYiIGN4PSIxNiIgY3k9IjE3IiByPSIxIi8+PHJlY3Qgc3Ryb2tlPSIjMzM4MUZGIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHg9IjExIiB5PSIxNCIgd2lkdGg9IjEwIiBoZWlnaHQ9IjgiIHJ4PSIyIi8+PHBhdGggZD0iTTEzIDE0di0xYTMgMyAwIDAgMSA2IDB2MWgwbS0zIDN2MyIgc3Ryb2tlPSIjMzM4MUZGIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L2c+PC9zdmc+","lock-new":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48Y2lyY2xlIGZpbGw9IiM0NDRFNjAiIGN4PSIxNiIgY3k9IjE3IiByPSIxIi8+PHJlY3Qgc3Ryb2tlPSIjNDQ0RTYwIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHg9IjExIiB5PSIxNCIgd2lkdGg9IjEwIiBoZWlnaHQ9IjgiIHJ4PSIyIi8+PHBhdGggZD0iTTEzIDE0di0zYTMgMyAwIDAgMSA2IDB2MWgwbS0zIDV2MyIgc3Ryb2tlPSIjNDQ0RTYwIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L2c+PC9zdmc+",shapes:"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTY4Mi42NjY2NjcgMTAyNEM2ODIuNjY2NjY3IDEwMjQgNjgyLjY2NjY2NyAxMDI0IDY4Mi42NjY2NjcgMTAyNEwxNzAuNjY2NjY3IDEwMjRjLTE3LjA2NjY2NyAwLTI5Ljg2NjY2Ny04LjUzMzMzMy0zOC40LTIxLjMzMzMzMy04LjUzMzMzMy0xMi44LTguNTMzMzMzLTI5Ljg2NjY2NyAwLTQyLjY2NjY2N2wyNTYtMzg0YzE3LjA2NjY2Ny0yNS42IDU1LjQ2NjY2Ny0yNS42IDcyLjUzMzMzMyAwbDI1MS43MzMzMzMgMzc5LjczMzMzM2M4LjUzMzMzMyA4LjUzMzMzMyAxMi44IDE3LjA2NjY2NyAxMi44IDI5Ljg2NjY2N0M3MjUuMzMzMzMzIDEwMDYuOTMzMzMzIDcwOC4yNjY2NjcgMTAyNCA2ODIuNjY2NjY3IDEwMjR6TTI1MS43MzMzMzMgOTM4LjY2NjY2N2wzNTQuMTMzMzMzIDBMNDI2LjY2NjY2NyA2NzQuMTMzMzMzIDI1MS43MzMzMzMgOTM4LjY2NjY2N3oiIGZpbGw9IiM0NDRFNjAiPjwvcGF0aD48cGF0aCBkPSJNOTgxLjMzMzMzMyA3MjUuMzMzMzMzbC0zNDEuMzMzMzMzIDBjLTI1LjYgMC00Mi42NjY2NjctMTcuMDY2NjY3LTQyLjY2NjY2Ny00Mi42NjY2NjdMNTk3LjMzMzMzMyAzNDEuMzMzMzMzYzAtMjUuNiAxNy4wNjY2NjctNDIuNjY2NjY3IDQyLjY2NjY2Ny00Mi42NjY2NjdsMzQxLjMzMzMzMyAwYzI1LjYgMCA0Mi42NjY2NjcgMTcuMDY2NjY3IDQyLjY2NjY2NyA0Mi42NjY2NjdsMCAzNDEuMzMzMzMzQzEwMjQgNzA4LjI2NjY2NyAxMDA2LjkzMzMzMyA3MjUuMzMzMzMzIDk4MS4zMzMzMzMgNzI1LjMzMzMzM3pNNjgyLjY2NjY2NyA2NDBsMjU2IDBMOTM4LjY2NjY2NyAzODRsLTI1NiAwTDY4Mi42NjY2NjcgNjQweiIgZmlsbD0iIzQ0NEU2MCI+PC9wYXRoPjxwYXRoIGQ9Ik0yNzcuMzMzMzMzIDU1NC42NjY2NjdDMTIzLjczMzMzMyA1NTQuNjY2NjY3IDAgNDMwLjkzMzMzMyAwIDI3Ny4zMzMzMzNTMTIzLjczMzMzMyAwIDI3Ny4zMzMzMzMgMCA1NTQuNjY2NjY3IDEyMy43MzMzMzMgNTU0LjY2NjY2NyAyNzcuMzMzMzMzIDQzMC45MzMzMzMgNTU0LjY2NjY2NyAyNzcuMzMzMzMzIDU1NC42NjY2Njd6TTI3Ny4zMzMzMzMgODUuMzMzMzMzQzE3MC42NjY2NjcgODUuMzMzMzMzIDg1LjMzMzMzMyAxNzAuNjY2NjY3IDg1LjMzMzMzMyAyNzcuMzMzMzMzUzE3MC42NjY2NjcgNDY5LjMzMzMzMyAyNzcuMzMzMzMzIDQ2OS4zMzMzMzMgNDY5LjMzMzMzMyAzODQgNDY5LjMzMzMzMyAyNzcuMzMzMzMzIDM4NCA4NS4zMzMzMzMgMjc3LjMzMzMzMyA4NS4zMzMzMzN6IiBmaWxsPSIjNDQ0RTYwIj48L3BhdGg+PC9zdmc+","shapes-active":"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTY4Mi42NjY2NjcgMTAyNEM2ODIuNjY2NjY3IDEwMjQgNjgyLjY2NjY2NyAxMDI0IDY4Mi42NjY2NjcgMTAyNEwxNzAuNjY2NjY3IDEwMjRjLTE3LjA2NjY2NyAwLTI5Ljg2NjY2Ny04LjUzMzMzMy0zOC40LTIxLjMzMzMzMy04LjUzMzMzMy0xMi44LTguNTMzMzMzLTI5Ljg2NjY2NyAwLTQyLjY2NjY2N2wyNTYtMzg0YzE3LjA2NjY2Ny0yNS42IDU1LjQ2NjY2Ny0yNS42IDcyLjUzMzMzMyAwbDI1MS43MzMzMzMgMzc5LjczMzMzM2M4LjUzMzMzMyA4LjUzMzMzMyAxMi44IDE3LjA2NjY2NyAxMi44IDI5Ljg2NjY2N0M3MjUuMzMzMzMzIDEwMDYuOTMzMzMzIDcwOC4yNjY2NjcgMTAyNCA2ODIuNjY2NjY3IDEwMjR6TTI1MS43MzMzMzMgOTM4LjY2NjY2N2wzNTQuMTMzMzMzIDBMNDI2LjY2NjY2NyA2NzQuMTMzMzMzIDI1MS43MzMzMzMgOTM4LjY2NjY2N3oiIGZpbGw9IiMzMzgxRkYiPjwvcGF0aD48cGF0aCBkPSJNOTgxLjMzMzMzMyA3MjUuMzMzMzMzbC0zNDEuMzMzMzMzIDBjLTI1LjYgMC00Mi42NjY2NjctMTcuMDY2NjY3LTQyLjY2NjY2Ny00Mi42NjY2NjdMNTk3LjMzMzMzMyAzNDEuMzMzMzMzYzAtMjUuNiAxNy4wNjY2NjctNDIuNjY2NjY3IDQyLjY2NjY2Ny00Mi42NjY2NjdsMzQxLjMzMzMzMyAwYzI1LjYgMCA0Mi42NjY2NjcgMTcuMDY2NjY3IDQyLjY2NjY2NyA0Mi42NjY2NjdsMCAzNDEuMzMzMzMzQzEwMjQgNzA4LjI2NjY2NyAxMDA2LjkzMzMzMyA3MjUuMzMzMzMzIDk4MS4zMzMzMzMgNzI1LjMzMzMzM3pNNjgyLjY2NjY2NyA2NDBsMjU2IDBMOTM4LjY2NjY2NyAzODRsLTI1NiAwTDY4Mi42NjY2NjcgNjQweiIgZmlsbD0iIzMzODFGRiI+PC9wYXRoPjxwYXRoIGQ9Ik0yNzcuMzMzMzMzIDU1NC42NjY2NjdDMTIzLjczMzMzMyA1NTQuNjY2NjY3IDAgNDMwLjkzMzMzMyAwIDI3Ny4zMzMzMzNTMTIzLjczMzMzMyAwIDI3Ny4zMzMzMzMgMCA1NTQuNjY2NjY3IDEyMy43MzMzMzMgNTU0LjY2NjY2NyAyNzcuMzMzMzMzIDQzMC45MzMzMzMgNTU0LjY2NjY2NyAyNzcuMzMzMzMzIDU1NC42NjY2Njd6TTI3Ny4zMzMzMzMgODUuMzMzMzMzQzE3MC42NjY2NjcgODUuMzMzMzMzIDg1LjMzMzMzMyAxNzAuNjY2NjY3IDg1LjMzMzMzMyAyNzcuMzMzMzMzUzE3MC42NjY2NjcgNDY5LjMzMzMzMyAyNzcuMzMzMzMzIDQ2OS4zMzMzMzMgNDY5LjMzMzMzMyAzODQgNDY5LjMzMzMzMyAyNzcuMzMzMzMzIDM4NCA4NS4zMzMzMzMgMjc3LjMzMzMzMyA4NS4zMzMzMzN6IiBmaWxsPSIjMzM4MUZGIj48L3BhdGg+PC9zdmc+","font-style-active":"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTM2MC4yMzQ2NjcgMjEzLjMzMzMzM0w1NTQuNjY2NjY3IDc3Ni4yNzczMzNoLTc2LjU0NGwtNTQuNjEzMzM0LTE3Mi4wMzJIMjE0LjE4NjY2N2wtNTUuNDY2NjY3IDE3Mi4wMzJIODUuMzMzMzMzTDI3OS43NjUzMzMgMjEzLjMzMzMzM2g4MC40NjkzMzR6IG00MTAuMDI2NjY2IDE3My44MjRjOTAuMTEyIDAgMTI4LjM0MTMzMyA2MC43NTczMzMgMTI4LjM0MTMzNCAxNTIuMjM0NjY3djIyOC4wMTA2NjdoLTUxLjJsLTUuNDYxMzM0LTQ0LjM3MzMzNGgtMi4wNDhjLTM1LjQ5ODY2NyAyOS4zNTQ2NjctNzcuMTQxMzMzIDUzLjI0OC0xMjIuODggNTMuMjQ4LTYyLjEyMjY2NyAwLTEwOC41NDQtMzguMjI5MzMzLTEwOC41NDQtMTA1LjEzMDY2NiAwLTgwLjU1NDY2NyA3MC4zMTQ2NjctMTIwLjgzMiAyMjguMDEwNjY3LTEzOC41ODEzMzQgMC00Ny43ODY2NjctMTUuNzAxMzMzLTkzLjUyNTMzMy03Ni40NTg2NjctOTMuNTI1MzMzLTQzLjAwOCAwLTgxLjkyIDE5Ljc5NzMzMy0xMTEuMjc0NjY2IDM5LjU5NDY2N2wtMjQuNTc2LTQzLjAwOGMzNC4xMzMzMzMtMjEuODQ1MzMzIDg2LjY5ODY2Ny00OC40NjkzMzMgMTQ2LjA5MDY2Ni00OC40NjkzMzR6IG02Ni4yMTg2NjcgMTg2LjM2OGMtMTI0LjkyOCAxNS4wMTg2NjctMTY3LjI1MzMzMyA0NS43Mzg2NjctMTY3LjI1MzMzMyA5My41MjUzMzQgMCA0Mi4zMjUzMzMgMjguNjcyIDU5LjM5MiA2NS41MzYgNTkuMzkyIDM2LjE4MTMzMyAwIDY1LjUzNi0xNy4wNjY2NjcgMTAxLjcxNzMzMy00OS4xNTJ6TTMyMC4zODQgMjcwLjkzMzMzM2gtMy4xMTQ2NjdjLTE3Ljk2MjY2NyA2Ni4wNDgtMzYuNjkzMzMzIDEyNi43Mi01Ny4wMDI2NjYgMTkwLjQ2NGwtMjguMTYgODYuMDE2aDE3My4zOTczMzNsLTI3LjMwNjY2Ny04Ni4wMTZBNDkxMy40OTMzMzMgNDkxMy40OTMzMzMgMCAwIDEgMzIwLjM4NCAyNzAuOTMzMzMzeiIgZmlsbD0iIzMzODFGRiI+PC9wYXRoPjwvc3ZnPg==","font-style":"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTM2MC4yMzQ2NjcgMjEzLjMzMzMzM0w1NTQuNjY2NjY3IDc3Ni4yNzczMzNoLTc2LjU0NGwtNTQuNjEzMzM0LTE3Mi4wMzJIMjE0LjE4NjY2N2wtNTUuNDY2NjY3IDE3Mi4wMzJIODUuMzMzMzMzTDI3OS43NjUzMzMgMjEzLjMzMzMzM2g4MC40NjkzMzR6IG00MTAuMDI2NjY2IDE3My44MjRjOTAuMTEyIDAgMTI4LjM0MTMzMyA2MC43NTczMzMgMTI4LjM0MTMzNCAxNTIuMjM0NjY3djIyOC4wMTA2NjdoLTUxLjJsLTUuNDYxMzM0LTQ0LjM3MzMzNGgtMi4wNDhjLTM1LjQ5ODY2NyAyOS4zNTQ2NjctNzcuMTQxMzMzIDUzLjI0OC0xMjIuODggNTMuMjQ4LTYyLjEyMjY2NyAwLTEwOC41NDQtMzguMjI5MzMzLTEwOC41NDQtMTA1LjEzMDY2NiAwLTgwLjU1NDY2NyA3MC4zMTQ2NjctMTIwLjgzMiAyMjguMDEwNjY3LTEzOC41ODEzMzQgMC00Ny43ODY2NjctMTUuNzAxMzMzLTkzLjUyNTMzMy03Ni40NTg2NjctOTMuNTI1MzMzLTQzLjAwOCAwLTgxLjkyIDE5Ljc5NzMzMy0xMTEuMjc0NjY2IDM5LjU5NDY2N2wtMjQuNTc2LTQzLjAwOGMzNC4xMzMzMzMtMjEuODQ1MzMzIDg2LjY5ODY2Ny00OC40NjkzMzMgMTQ2LjA5MDY2Ni00OC40NjkzMzR6IG02Ni4yMTg2NjcgMTg2LjM2OGMtMTI0LjkyOCAxNS4wMTg2NjctMTY3LjI1MzMzMyA0NS43Mzg2NjctMTY3LjI1MzMzMyA5My41MjUzMzQgMCA0Mi4zMjUzMzMgMjguNjcyIDU5LjM5MiA2NS41MzYgNTkuMzkyIDM2LjE4MTMzMyAwIDY1LjUzNi0xNy4wNjY2NjcgMTAxLjcxNzMzMy00OS4xNTJ6TTMyMC4zODQgMjcwLjkzMzMzM2gtMy4xMTQ2NjdjLTE3Ljk2MjY2NyA2Ni4wNDgtMzYuNjkzMzMzIDEyNi43Mi01Ny4wMDI2NjYgMTkwLjQ2NGwtMjguMTYgODYuMDE2aDE3My4zOTczMzNsLTI3LjMwNjY2Ny04Ni4wMTZBNDkxMy40OTMzMzMgNDkxMy40OTMzMzMgMCAwIDEgMzIwLjM4NCAyNzAuOTMzMzMzeiIgZmlsbD0iIzQ0NEU2MCI+PC9wYXRoPjwvc3ZnPg==",polygon:"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTkzMy4xMiA0OTAuNjY2NjY3bC0xOTItMzMyLjM3MzMzNGE0Mi42NjY2NjcgNDIuNjY2NjY3IDAgMCAwLTM3LjEyLTIxLjMzMzMzM2gtMzg0YTQyLjY2NjY2NyA0Mi42NjY2NjcgMCAwIDAtMzcuMTIgMjEuMzMzMzMzbC0xOTIgMzMyLjM3MzMzNGE0Mi42NjY2NjcgNDIuNjY2NjY3IDAgMCAwIDAgNDIuNjY2NjY2bDE5MiAzMzIuMzczMzM0YTQyLjY2NjY2NyA0Mi42NjY2NjcgMCAwIDAgMzcuMTIgMjEuMzMzMzMzaDM4NGE0Mi42NjY2NjcgNDIuNjY2NjY3IDAgMCAwIDM3LjEyLTIxLjMzMzMzM2wxOTItMzMyLjM3MzMzNGE0Mi42NjY2NjcgNDIuNjY2NjY3IDAgMCAwIDAtNDIuNjY2NjY2eiBtLTI1NiAzMTEuMDRIMzQ0Ljc0NjY2N0wxNzcuMDY2NjY3IDUxMmwxNjcuNjgtMjg5LjcwNjY2N2gzMzQuNTA2NjY2TDg0Ni45MzMzMzMgNTEyeiIgZmlsbD0iIzQ0NEU2MCI+PC9wYXRoPjwvc3ZnPg==","polygon-active":"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTkzMy4xMiA0OTAuNjY2NjY3bC0xOTItMzMyLjM3MzMzNGE0Mi42NjY2NjcgNDIuNjY2NjY3IDAgMCAwLTM3LjEyLTIxLjMzMzMzM2gtMzg0YTQyLjY2NjY2NyA0Mi42NjY2NjcgMCAwIDAtMzcuMTIgMjEuMzMzMzMzbC0xOTIgMzMyLjM3MzMzNGE0Mi42NjY2NjcgNDIuNjY2NjY3IDAgMCAwIDAgNDIuNjY2NjY2bDE5MiAzMzIuMzczMzM0YTQyLjY2NjY2NyA0Mi42NjY2NjcgMCAwIDAgMzcuMTIgMjEuMzMzMzMzaDM4NGE0Mi42NjY2NjcgNDIuNjY2NjY3IDAgMCAwIDM3LjEyLTIxLjMzMzMzM2wxOTItMzMyLjM3MzMzNGE0Mi42NjY2NjcgNDIuNjY2NjY3IDAgMCAwIDAtNDIuNjY2NjY2eiBtLTI1NiAzMTEuMDRIMzQ0Ljc0NjY2N0wxNzcuMDY2NjY3IDUxMmwxNjcuNjgtMjg5LjcwNjY2N2gzMzQuNTA2NjY2TDg0Ni45MzMzMzMgNTEyeiIgZmlsbD0iIzMzODFGRiI+PC9wYXRoPjwvc3ZnPg==","polygon-vertex":"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTA3NyAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTU0My40NzQ1MjYgNDIuMzA3MzY4YTExOS4zNzY4NDIgMTE5LjM3Njg0MiAwIDAgMSAxMTAuODA3NTc5IDE2My44NGwxOTAuNTcxNzkgMTM4LjYxNzI2NGExMTkuMzc2ODQyIDExOS4zNzY4NDIgMCAxIDEgODMuMzc1MTU4IDIxOC43MDQ4NDJsLTc0LjMyMDg0MiAyMjguODM3MDUyYTExOS4zMjI5NDcgMTE5LjMyMjk0NyAwIDAgMS02MS4yNzgzMTYgMjIxLjg4NDYzMmMtNDYuNzgwNjMyIDAtODcuMzA5NDc0LTI2Ljk0NzM2OC0xMDYuODczMjYzLTY2LjEyODg0MmgtMjg5LjQxNDczN2ExMTkuMzc2ODQyIDExOS4zNzY4NDIgMCAxIDEtMTc5LjczODk0OC0xNDcuODMzMjYzbC03Mi4yNzI4NDItMjIyLjY5MzA1My0zLjM5NTM2OCAwLjEwNzc4OUExMTkuMzc2ODQyIDExOS4zNzY4NDIgMCAwIDEgMjEuODI3MzY4IDQ2Ni43Mjg0MjFMMjEuNTU3ODk1IDQ1OC4yMTMwNTNhMTE5LjM3Njg0MiAxMTkuMzc2ODQyIDAgMCAxIDE4My44MzQ5NDctMTAwLjUxMzY4NWwyMjMuNTAxNDc0LTE2Mi4zODQ4NDJhMTE5LjQzMDczNyAxMTkuNDMwNzM3IDAgMCAxIDExNC41ODAyMS0xNTMuMDYxMDUyek0yODkuNDE0NzM3IDg0MC4wNTcyNjNhNTQuNzAzMTU4IDU0LjcwMzE1OCAwIDEgMCAwIDEwOS40MDYzMTYgNTQuNzAzMTU4IDU0LjcwMzE1OCAwIDAgMCAwLTEwOS40MDYzMTZ6IG01MDMuMTYxMjYzIDBhNTQuNzAzMTU4IDU0LjcwMzE1OCAwIDEgMCAwIDEwOS40MDYzMTYgNTQuNzAzMTU4IDU0LjcwMzE1OCAwIDAgMCAwLTEwOS40MDYzMTZ6TTQ2Mi42ODYzMTYgMjQ5LjU4NjUyNkwyNDguMTMxMzY4IDQwNS41NTc4OTVhMTE5LjMyMjk0NyAxMTkuMzIyOTQ3IDAgMCAxLTQyLjg0NjMxNSAxNTMuMjIyNzM3bDcwLjcwOTg5NCAyMTcuMzU3NDczYTExOS40MzA3MzcgMTE5LjQzMDczNyAwIDAgMSAxMzIuNDE5MzY5IDEwOC4yMjA2MzJINjczLjY4NDIxMWExMTkuNDMwNzM3IDExOS40MzA3MzcgMCAwIDEgMTE5LjE2MTI2My0xMDguOTc1MTU4bDcxLjE0MTA1Mi0yMTguOTc0MzE2YTExOS40MzA3MzcgMTE5LjQzMDczNyAwIDAgMS02Mi4wODY3MzctMTY0LjIxNzI2M2wtMTg2LjM2OC0xMzUuMjc1Nzg5Yy0xOS45OTQ5NDcgMTUuMDkwNTI2LTQ1LjAwMjEwNSAyNC4xNDQ4NDItNzIuMDU3MjYzIDI0LjE0NDg0MmExMTguOTQ1Njg0IDExOC45NDU2ODQgMCAwIDEtODAuNzg4MjEtMzEuNDc0NTI3eiBtLTMyMS43NTE1NzkgMTUzLjkyMzM2OWE1NC43MDMxNTggNTQuNzAzMTU4IDAgMSAwIDAgMTA5LjQwNjMxNiA1NC43MDMxNTggNTQuNzAzMTU4IDAgMCAwIDAtMTA5LjQwNjMxNnogbTc2Ny43MzA1MjYtMTIuNTU3NDc0YTU0LjcwMzE1OCA1NC43MDMxNTggMCAxIDAgMCAxMDkuNDA2MzE2IDU0LjcwMzE1OCA1NC43MDMxNTggMCAwIDAgMC0xMDkuNDA2MzE2eiBtLTM2NS4xOTA3MzctMjg0LjAyNTI2M2E1NC43MDMxNTggNTQuNzAzMTU4IDAgMSAwIDAgMTA5LjQ2MDIxIDU0LjcwMzE1OCA1NC43MDMxNTggMCAwIDAgMC0xMDkuNDA2MzE1eiIgZmlsbD0iIzQ0NEU2MCI+PC9wYXRoPjwvc3ZnPg==",star:"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTkwOC4xIDM1My4xbC0yNTMuOS0zNi45TDU0MC43IDg2LjFjLTMuMS02LjMtOC4yLTExLjQtMTQuNS0xNC41LTE1LjgtNy44LTM1LTEuMy00Mi45IDE0LjVMMzY5LjggMzE2LjJsLTI1My45IDM2LjljLTcgMS0xMy40IDQuMy0xOC4zIDkuMy0xMi4zIDEyLjctMTIuMSAzMi45IDAuNiA0NS4zbDE4My43IDE3OS4xLTQzLjQgMjUyLjljLTEuMiA2LjktMC4xIDE0LjEgMy4yIDIwLjMgOC4yIDE1LjYgMjcuNiAyMS43IDQzLjIgMTMuNEw1MTIgNzU0bDIyNy4xIDExOS40YzYuMiAzLjMgMTMuNCA0LjQgMjAuMyAzLjIgMTcuNC0zIDI5LjEtMTkuNSAyNi4xLTM2LjlsLTQzLjQtMjUyLjkgMTgzLjctMTc5LjFjNS00LjkgOC4zLTExLjMgOS4zLTE4LjMgMi43LTE3LjUtOS41LTMzLjctMjctMzYuM3pNNjY0LjggNTYxLjZsMzYuMSAyMTAuM0w1MTIgNjcyLjcgMzIzLjEgNzcybDM2LjEtMjEwLjMtMTUyLjgtMTQ5TDQxNy42IDM4MiA1MTIgMTkwLjcgNjA2LjQgMzgybDIxMS4yIDMwLjctMTUyLjggMTQ4Ljl6IiBmaWxsPSIjNDQ0RTYwIj48L3BhdGg+PC9zdmc+","star-active":"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTkwOC4xIDM1My4xbC0yNTMuOS0zNi45TDU0MC43IDg2LjFjLTMuMS02LjMtOC4yLTExLjQtMTQuNS0xNC41LTE1LjgtNy44LTM1LTEuMy00Mi45IDE0LjVMMzY5LjggMzE2LjJsLTI1My45IDM2LjljLTcgMS0xMy40IDQuMy0xOC4zIDkuMy0xMi4zIDEyLjctMTIuMSAzMi45IDAuNiA0NS4zbDE4My43IDE3OS4xLTQzLjQgMjUyLjljLTEuMiA2LjktMC4xIDE0LjEgMy4yIDIwLjMgOC4yIDE1LjYgMjcuNiAyMS43IDQzLjIgMTMuNEw1MTIgNzU0bDIyNy4xIDExOS40YzYuMiAzLjMgMTMuNCA0LjQgMjAuMyAzLjIgMTcuNC0zIDI5LjEtMTkuNSAyNi4xLTM2LjlsLTQzLjQtMjUyLjkgMTgzLjctMTc5LjFjNS00LjkgOC4zLTExLjMgOS4zLTE4LjMgMi43LTE3LjUtOS41LTMzLjctMjctMzYuM3pNNjY0LjggNTYxLjZsMzYuMSAyMTAuM0w1MTIgNjcyLjcgMzIzLjEgNzcybDM2LjEtMjEwLjMtMTUyLjgtMTQ5TDQxNy42IDM4MiA1MTIgMTkwLjcgNjA2LjQgMzgybDIxMS4yIDMwLjctMTUyLjggMTQ4Ljl6IiBmaWxsPSIjMzM4MUZGIj48L3BhdGg+PC9zdmc+","star-innerVertex":"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTg1LjMzMzMzMyAwYTg1LjMzMzMzMyA4NS4zMzMzMzMgMCAwIDEgODEuNDA4IDU5LjczMzMzM2g0OC4yMTMzMzR2ODUuMzMzMzM0TDE3MC42NjY2NjcgMTQ0Ljk4MTMzM1Y4NTMuMzMzMzMzaDY5My4zMzMzMzNsLTI2LjQ1MzMzMy02My40ODggNzguNzYyNjY2LTMyLjc2OCAzMi44NTMzMzQgNzguNzYyNjY3LTQyLjI0IDE3LjQ5MzMzM0g5MzguNjY2NjY3YTg1LjMzMzMzMyA4NS4zMzMzMzMgMCAwIDEgODQuNzM2IDc1LjM0OTMzNEwxMDI0IDkzOC42NjY2NjdhODUuMzMzMzMzIDg1LjMzMzMzMyAwIDAgMS0xNzAuNjY2NjY3IDBIMTcwLjY2NjY2N2E4NS4zMzMzMzMgODUuMzMzMzMzIDAgMSAxLTg1LjMzMzMzNC04NS4zMzMzMzRWMTcwLjY2NjY2N2E4NS4zMzMzMzMgODUuMzMzMzMzIDAgMSAxIDAtMTcwLjY2NjY2N3ogbTc2NS4zNTQ2NjcgNTk5LjQ2NjY2N2wzMi44NTMzMzMgNzguNzYyNjY2LTc4Ljg0OCAzMi44NTMzMzQtMzIuNzY4LTc4Ljc2MjY2NyA3OC43NjI2NjctMzIuODUzMzMzeiBtLTY1LjcwNjY2Ny0xNTcuNTI1MzM0bDMyLjg1MzMzNCA3OC43NjI2NjctNzguNzYyNjY3IDMyLjg1MzMzMy0zMi43NjgtNzguNzYyNjY2IDc4Ljc2MjY2Ny0zMi44NTMzMzR6TTcxOS4zNiAyODQuNDE2bDMyLjg1MzMzMyA3OC43NjI2NjctNzguNzYyNjY2IDMyLjg1MzMzMy0zMi44NTMzMzQtNzguNzYyNjY3IDc4Ljc2MjY2Ny0zMi44NTMzMzN6IG0tNjUuNjIxMzMzLTE1Ny41MjUzMzNsMzIuODUzMzMzIDc4Ljc2MjY2Ni03OC43NjI2NjcgMzIuODUzMzM0LTMyLjg1MzMzMy03OC43NjI2NjcgNzguNzYyNjY3LTMyLjg1MzMzM3pNMzg1LjcwNjY2NyA1OS43MzMzMzN2ODUuMzMzMzM0aC04NS4zMzMzMzR2LTg1LjMzMzMzNGg4NS4zMzMzMzR6IG0xNzAuNjY2NjY2IDB2ODUuMzMzMzM0aC04NS4zMzMzMzN2LTg1LjMzMzMzNGg4NS4zMzMzMzN6IiBmaWxsPSIjNDQ0RTYwIiA+PC9wYXRoPjwvc3ZnPg==","star-innerRatio":"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTU2OS4zNDQgNDQ5LjUzNmwxNDYuOTQ0IDI4LjY3MiAxLjAyNC00LjYwOHY0LjYwOGgxLjAyNGM5LjcyOCAwIDE2Ljg5Ni03LjY4IDIwLjQ4LTE0Ljg0OGwxLjAyNC0yLjA0OHYtMi41NmMwLTUuNjMyIDAtMTEuMjY0LTUuMTItMTYuMzg0LTMuMDcyLTMuMDcyLTcuMTY4LTcuMTY4LTEyLjgtNy42OGwtMTI0LjkyOC0yNC4wNjRMNTQxLjY5NiAyODYuNzJjLTIuMDQ4LTQuNjA4LTYuNjU2LTguMTkyLTExLjc3Ni05LjcyOC01LjEyLTEuNTM2LTEwLjc1Mi0xLjUzNi0xNS4zNiAxLjAyNGwtMS41MzYgMC41MTItMS4wMjQgMS4wMjRjLTguMTkyIDguMTkyLTEwLjc1MiAxOS40NTYtNi42NTYgMjcuMTM2bDY0IDE0Mi44NDh6IiBmaWxsPSIjMzM4MUZGIj48L3BhdGg+PHBhdGggZD0iTTkzMS4zMjggNDAzLjQ1NmMtMTAuMjQtMzUuMzI4LTM4LjQtNjEuNDQtNzEuNjgtNjYuNTZsLTE4NC44MzItMzUuODQtODIuNDMyLTE4Mi43ODRjLTEyLjgtMzMuMjgtNDYuMDgtNTYuMzItODAuMzg0LTU2LjMyLTMzLjc5MiAwLTY0LjUxMiAyMC40OC03OS44NzIgNTMuNzZMMzQ5LjE4NCAyOTkuMDA4bC0xODQuMzIgMzUuMzI4Yy0zMy43OTIgNS4xMi02MS45NTIgMzEuMjMyLTcyLjE5MiA2Ni41Ni05LjcyOCAzNC4zMDQtMS4wMjQgNzIuMTkyIDIzLjA0IDk4LjgxNmwxMzEuNTg0IDEzMy42MzItMzUuODQgMTk2LjYwOGMtNS42MzIgMzQuODE2IDguNzA0IDcxLjY4IDM1Ljg0IDk0LjIwOCAxMy44MjQgMTEuMjY0IDM0LjMwNCAxOC40MzIgNTIuMjI0IDE4LjQzMiAxNi44OTYgMCAyOS42OTYtMy4wNzIgNDEuNDcyLTEwLjI0bDE2OC45Ni05MS4xMzYgMTY2LjkxMiA5MS4xMzYgMS4wMjQgMC41MTJjMTYuODk2IDYuNjU2IDI5LjY5NiA5LjcyOCA0MC40NDggOS43MjggMTQuMzM2IDAgMjcuNjQ4LTQuMDk2IDQwLjQ0OC03LjY4IDQuNjA4LTEuNTM2IDkuNzI4LTMuMDcyIDE0Ljg0OC00LjA5NmwyLjU2LTAuNTEyIDIuMDQ4LTEuNTM2YzI1LjA4OC0yMy4wNCAzNy44ODgtNTguODggMzIuNzY4LTkzLjY5NmwtMzMuMjgtMTk2LjYwOCAxMzEuNTg0LTEzNi4xOTJjMjQuMDY0LTI3LjY0OCAzMi4yNTYtNjIuOTc2IDIyLjAxNi05OC44MTZ6TTI3Ni45OTIgODM2LjA5Nmw0MS45ODQtMjMxLjkzNi0xNTcuMTg0LTE1OS4yMzJjLTUuNjMyLTUuNjMyLTguMTkyLTE3LjQwOC02LjY1Ni0yOS4xODQgMy41ODQtMTAuMjQgMTAuMjQtMTYuMzg0IDE5LjQ1Ni0xNy45MmwyMTguMTEyLTQxLjk4NCA5Ni4yNTYtMjE1LjU1MmMzLjA3Mi03LjE2OCAxMi44LTE0LjMzNiAyMC40OC0xNC4zMzZzMTcuNDA4IDcuMTY4IDIwLjQ4IDE0Ljg0OGw5OC4zMDQgMjE1LjA0IDIxOC4xMTIgNDEuOTg0YzcuMTY4IDEuNTM2IDE1LjM2IDcuMTY4IDE2Ljg5NiAxNi4zODR2My4wNzJjMi4wNDggMTEuNzc2LTAuNTEyIDIyLjUyOC02LjY1NiAzMC43Mkw2OTkuOTA0IDYwOS4yOGwzOS45MzYgMjMxLjQyNGMxLjUzNiAxMC43NTItMi4wNDggMjAuNDgtMTAuMjQgMjcuMTM2bC0xLjAyNCAwLjUxMmMtMi41NiAyLjU2LTYuNjU2IDQuMDk2LTExLjI2NCA0LjA5Ni0yLjA0OCAwLTcuMTY4LTEuNTM2LTExLjI2NC0zLjU4NGwtMTk3LjEyLTEwOC4wMzItMTk5LjE2OCAxMDIuOTEyYy00LjA5NiAyLjA0OC05LjIxNiAzLjU4NC0xMS43NzYgMy41ODQtNC42MDggMC04LjcwNC0xLjUzNi0xMS4yNjQtNC4wOTZsLTEuMDI0LTAuNTEyYy02LjY1Ni02LjE0NC0xMC43NTItMTYuMzg0LTguNzA0LTI2LjYyNHoiIGZpbGw9IiM0NDRFNjAiPjwvcGF0aD48L3N2Zz4=",speechBallon:"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTgzMiA4MzJINDQ4bC0xMjggMTkyLTEyOC0xOTJjLTEwNi4wNDggMC0xOTItODYuMDE2LTE5Mi0xOTJWMTkyYTE5MiAxOTIgMCAwIDEgMTkyLTE5Mmg2NDBjMTA1Ljk4NCAwIDE5MiA4NS45NTIgMTkyIDE5MnY0NDhjMCAxMDUuOTg0LTg2LjAxNiAxOTItMTkyIDE5MnogbTY0LTY0MGE2NCA2NCAwIDAgMC02NC02NEgxOTJDMTU2LjY3MiAxMjggMTI4IDE1Ni42NzIgMTI4IDE5MnY0NDhhNjQgNjQgMCAwIDAgNjQgNjRoNDIuNjg4TDMyMCA4MzJsODUuMzEyLTEyOEg4MzJjMzUuMzkyIDAgNjQtMjguNjA4IDY0LTY0VjE5MnoiIGZpbGw9IiM0NDRFNjAiPjwvcGF0aD48L3N2Zz4=","speechBallon-active":"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTgzMiA4MzJINDQ4bC0xMjggMTkyLTEyOC0xOTJjLTEwNi4wNDggMC0xOTItODYuMDE2LTE5Mi0xOTJWMTkyYTE5MiAxOTIgMCAwIDEgMTkyLTE5Mmg2NDBjMTA1Ljk4NCAwIDE5MiA4NS45NTIgMTkyIDE5MnY0NDhjMCAxMDUuOTg0LTg2LjAxNiAxOTItMTkyIDE5MnogbTY0LTY0MGE2NCA2NCAwIDAgMC02NC02NEgxOTJDMTU2LjY3MiAxMjggMTI4IDE1Ni42NzIgMTI4IDE5MnY0NDhhNjQgNjQgMCAwIDAgNjQgNjRoNDIuNjg4TDMyMCA4MzJsODUuMzEyLTEyOEg4MzJjMzUuMzkyIDAgNjQtMjguNjA4IDY0LTY0VjE5MnoiIGZpbGw9IiMzMzgxRkYiPjwvcGF0aD48L3N2Zz4=","speechBallon-placement":"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggZD0iTTU3NiAyMTMuMzMzMzMzbDIyLjYxMzMzMyAyMi42MTMzMzRhMzIgMzIgMCAwIDAgMC00NS4yMjY2NjdMNTc2IDIxMy4zMzMzMzN6IG0tNjIuNzItMTA3Ljk0NjY2NmEzMiAzMiAwIDEgMC00NS4yMjY2NjcgNDUuMjI2NjY2bDQ1LjIyNjY2Ny00NS4yMjY2NjZ6IG0tNDUuMjI2NjY3IDE3MC42NjY2NjZhMzIgMzIgMCAwIDAgNDUuMjI2NjY3IDQ1LjIyNjY2N2wtNDUuMjI2NjY3LTQ1LjIyNjY2N3pNNDQ4IDgxMC42NjY2NjdsLTIyLjYxMzMzMy0yMi42MTMzMzRhMzIgMzIgMCAwIDAgMCA0NS4yMjY2NjdsMjIuNjEzMzMzLTIyLjYxMzMzM3ogbTEwNy45NDY2NjctNjIuNzJhMzIgMzIgMCAxIDAtNDUuMjI2NjY3LTQ1LjIyNjY2N2w0NS4yMjY2NjcgNDUuMjI2NjY3eiBtLTQ1LjIyNjY2NyAxNzAuNjY2NjY2YTMyIDMyIDAgMSAwIDQ1LjIyNjY2Ny00NS4yMjY2NjZsLTQ1LjIyNjY2NyA0NS4yMjY2NjZ6TTgxMC42NjY2NjcgNTc2bC0yMi42MTMzMzQgMjIuNjEzMzMzYTMyIDMyIDAgMCAwIDQ1LjIyNjY2NyAwTDgxMC42NjY2NjcgNTc2eiBtMTA3Ljk0NjY2Ni02Mi43MmEzMiAzMiAwIDEgMC00NS4yMjY2NjYtNDUuMjI2NjY3bDQ1LjIyNjY2NiA0NS4yMjY2Njd6IG0tMTcwLjY2NjY2Ni00NS4yMjY2NjdhMzIgMzIgMCAxIDAtNDUuMjI2NjY3IDQ1LjIyNjY2N2w0NS4yMjY2NjctNDUuMjI2NjY3ek0yMTMuMzMzMzMzIDQ0OGwyMi42MTMzMzQtMjIuNjEzMzMzYTMyIDMyIDAgMCAwLTQ1LjIyNjY2NyAwbDIyLjYxMzMzMyAyMi42MTMzMzN6IG02Mi43MiAxMDcuOTQ2NjY3YTMyIDMyIDAgMCAwIDQ1LjIyNjY2Ny00NS4yMjY2NjdsLTQ1LjIyNjY2NyA0NS4yMjY2Njd6IG0tMTcwLjY2NjY2Ni00NS4yMjY2NjdhMzIgMzIgMCAxIDAgNDUuMjI2NjY2IDQ1LjIyNjY2N2wtNDUuMjI2NjY2LTQ1LjIyNjY2N3pNMzA5LjMzMzMzMyAyMTMuMzMzMzMzQTc0LjY2NjY2NyA3NC42NjY2NjcgMCAwIDEgMjM0LjY2NjY2NyAyODh2NjRBMTM4LjY2NjY2NyAxMzguNjY2NjY3IDAgMCAwIDM3My4zMzMzMzMgMjEzLjMzMzMzM2gtNjR6TTIzNC42NjY2NjcgMjg4QTc0LjY2NjY2NyA3NC42NjY2NjcgMCAwIDEgMTYwIDIxMy4zMzMzMzNoLTY0QTEzOC42NjY2NjcgMTM4LjY2NjY2NyAwIDAgMCAyMzQuNjY2NjY3IDM1MnYtNjR6TTE2MCAyMTMuMzMzMzMzYzAtNDEuMjE2IDMzLjQ1MDY2Ny03NC42NjY2NjcgNzQuNjY2NjY3LTc0LjY2NjY2NnYtNjRBMTM4LjY2NjY2NyAxMzguNjY2NjY3IDAgMCAwIDk2IDIxMy4zMzMzMzNoNjR6TTIzNC42NjY2NjcgMTM4LjY2NjY2N2M0MS4yMTYgMCA3NC42NjY2NjcgMzMuNDUwNjY3IDc0LjY2NjY2NiA3NC42NjY2NjZoNjRBMTM4LjY2NjY2NyAxMzguNjY2NjY3IDAgMCAwIDIzNC42NjY2NjcgNzQuNjY2NjY3djY0ek0zNDEuMzMzMzMzIDI0NS4zMzMzMzNoMjM0LjY2NjY2N3YtNjRIMzQxLjMzMzMzM3Y2NHogbTI1Ny4yOC01NC42MTMzMzNsLTg1LjMzMzMzMy04NS4zMzMzMzMtNDUuMjI2NjY3IDQ1LjIyNjY2NiA4NS4zMzMzMzQgODUuMzMzMzM0IDQ1LjIyNjY2Ni00NS4yMjY2Njd6IG0tNDUuMjI2NjY2IDBsLTg1LjMzMzMzNCA4NS4zMzMzMzMgNDUuMjI2NjY3IDQ1LjIyNjY2NyA4NS4zMzMzMzMtODUuMzMzMzMzLTQ1LjIyNjY2Ni00NS4yMjY2Njd6TTY1MC42NjY2NjcgODEwLjY2NjY2N2ExMzguNjY2NjY3IDEzOC42NjY2NjcgMCAwIDAgMTM4LjY2NjY2NiAxMzguNjY2NjY2di02NEE3NC42NjY2NjcgNzQuNjY2NjY3IDAgMCAxIDcxNC42NjY2NjcgODEwLjY2NjY2N2gtNjR6IG0xMzguNjY2NjY2IDEzOC42NjY2NjZBMTM4LjY2NjY2NyAxMzguNjY2NjY3IDAgMCAwIDkyOCA4MTAuNjY2NjY3aC02NGE3NC42NjY2NjcgNzQuNjY2NjY3IDAgMCAxLTc0LjY2NjY2NyA3NC42NjY2NjZ2NjR6TTkyOCA4MTAuNjY2NjY3YTEzOC42NjY2NjcgMTM4LjY2NjY2NyAwIDAgMC0xMzguNjY2NjY3LTEzOC42NjY2Njd2NjRjNDEuMjE2IDAgNzQuNjY2NjY3IDMzLjQ1MDY2NyA3NC42NjY2NjcgNzQuNjY2NjY3aDY0eiBtLTEzOC42NjY2NjctMTM4LjY2NjY2N0ExMzguNjY2NjY3IDEzOC42NjY2NjcgMCAwIDAgNjUwLjY2NjY2NyA4MTAuNjY2NjY3aDY0YzAtNDEuMjE2IDMzLjQ1MDY2Ny03NC42NjY2NjcgNzQuNjY2NjY2LTc0LjY2NjY2N3YtNjR6IG0tMTA2LjY2NjY2NiAxMDYuNjY2NjY3aC0yMzQuNjY2NjY3djY0SDY4Mi42NjY2Njd2LTY0eiBtLTIxMi4wNTMzMzQgNTQuNjEzMzMzbDg1LjMzMzMzNC04NS4zMzMzMzMtNDUuMjI2NjY3LTQ1LjIyNjY2Ny04NS4zMzMzMzMgODUuMzMzMzMzIDQ1LjIyNjY2NiA0NS4yMjY2Njd6IG0tNDUuMjI2NjY2IDBsODUuMzMzMzMzIDg1LjMzMzMzMyA0NS4yMjY2NjctNDUuMjI2NjY2LTg1LjMzMzMzNC04NS4zMzMzMzQtNDUuMjI2NjY2IDQ1LjIyNjY2N3pNNjcyIDIzNC42NjY2NjdBMTM4LjY2NjY2NyAxMzguNjY2NjY3IDAgMCAwIDgxMC42NjY2NjcgMzczLjMzMzMzM3YtNjRhNzQuNjY2NjY3IDc0LjY2NjY2NyAwIDAgMS03NC42NjY2NjctNzQuNjY2NjY2aC02NHpNODEwLjY2NjY2NyAzNzMuMzMzMzMzYTEzOC42NjY2NjcgMTM4LjY2NjY2NyAwIDAgMCAxMzguNjY2NjY2LTEzOC42NjY2NjZoLTY0QTc0LjY2NjY2NyA3NC42NjY2NjcgMCAwIDEgODEwLjY2NjY2NyAzMDkuMzMzMzMzdjY0eiBtMTM4LjY2NjY2Ni0xMzguNjY2NjY2QTEzOC42NjY2NjcgMTM4LjY2NjY2NyAwIDAgMCA4MTAuNjY2NjY3IDk2djY0YzQxLjIxNiAwIDc0LjY2NjY2NyAzMy40NTA2NjcgNzQuNjY2NjY2IDc0LjY2NjY2N2g2NHpNODEwLjY2NjY2NyA5NmExMzguNjY2NjY3IDEzOC42NjY2NjcgMCAwIDAtMTM4LjY2NjY2NyAxMzguNjY2NjY3aDY0YzAtNDEuMjE2IDMzLjQ1MDY2Ny03NC42NjY2NjcgNzQuNjY2NjY3LTc0LjY2NjY2N3YtNjR6TTc3OC42NjY2NjcgMzQxLjMzMzMzM3YyMzQuNjY2NjY3aDY0VjM0MS4zMzMzMzNoLTY0eiBtNTQuNjEzMzMzIDI1Ny4yOGw4NS4zMzMzMzMtODUuMzMzMzMzLTQ1LjIyNjY2Ni00NS4yMjY2NjctODUuMzMzMzM0IDg1LjMzMzMzNCA0NS4yMjY2NjcgNDUuMjI2NjY2eiBtMC00NS4yMjY2NjZsLTg1LjMzMzMzMy04NS4zMzMzMzQtNDUuMjI2NjY3IDQ1LjIyNjY2NyA4NS4zMzMzMzMgODUuMzMzMzMzIDQ1LjIyNjY2Ny00NS4yMjY2NjZ6TTEzOC42NjY2NjcgNzg5LjMzMzMzM2MwLTQxLjIxNiAzMy40NTA2NjctNzQuNjY2NjY3IDc0LjY2NjY2Ni03NC42NjY2NjZ2LTY0YTEzOC42NjY2NjcgMTM4LjY2NjY2NyAwIDAgMC0xMzguNjY2NjY2IDEzOC42NjY2NjZoNjR6TTIxMy4zMzMzMzMgNzE0LjY2NjY2N2M0MS4yMTYgMCA3NC42NjY2NjcgMzMuNDUwNjY3IDc0LjY2NjY2NyA3NC42NjY2NjZoNjRBMTM4LjY2NjY2NyAxMzguNjY2NjY3IDAgMCAwIDIxMy4zMzMzMzMgNjUwLjY2NjY2N3Y2NHogbTc0LjY2NjY2NyA3NC42NjY2NjZBNzQuNjY2NjY3IDc0LjY2NjY2NyAwIDAgMSAyMTMuMzMzMzMzIDg2NHY2NGExMzguNjY2NjY3IDEzOC42NjY2NjcgMCAwIDAgMTM4LjY2NjY2Ny0xMzguNjY2NjY3aC02NHpNMjEzLjMzMzMzMyA4NjRhNzQuNjY2NjY3IDc0LjY2NjY2NyAwIDAgMS03NC42NjY2NjYtNzQuNjY2NjY3aC02NEExMzguNjY2NjY3IDEzOC42NjY2NjcgMCAwIDAgMjEzLjMzMzMzMyA5Mjh2LTY0ek0yNDUuMzMzMzMzIDY4Mi42NjY2Njd2LTIzNC42NjY2NjdoLTY0VjY4Mi42NjY2NjdoNjR6IG0tNTQuNjEzMzMzLTIxMi4wNTMzMzRsODUuMzMzMzMzIDg1LjMzMzMzNCA0NS4yMjY2NjctNDUuMjI2NjY3LTg1LjMzMzMzMy04NS4zMzMzMzMtNDUuMjI2NjY3IDQ1LjIyNjY2NnogbTAtNDUuMjI2NjY2bC04NS4zMzMzMzMgODUuMzMzMzMzIDQ1LjIyNjY2NiA0NS4yMjY2NjcgODUuMzMzMzM0LTg1LjMzMzMzNC00NS4yMjY2NjctNDUuMjI2NjY2eiIgIGZpbGw9IiM0NDRFNjAiPjwvcGF0aD48L3N2Zz4="};function Et(i){return pMe[i]}const mMe=i=>{const{workIds:t,mananger:e}=i;return G.createElement("div",{className:"button normal-button",style:{touchAction:"none"},onPointerUp:r=>{r.cancelable&&r.preventDefault(),r.stopPropagation(),r.nativeEvent.stopImmediatePropagation(),We.emitMethod(Fe.MainEngine,Se.DeleteNode,{workIds:t||[De],viewId:e.viewId})}},G.createElement("img",{alt:"icon",src:Et("delete")}))},yMe=i=>{const{workIds:t,viewId:e}=i;return G.createElement("div",{className:"button normal-button",onPointerUp:r=>{r.stopPropagation(),We.emitMethod(Fe.MainEngine,Se.CopyNode,{workIds:t||[De],viewId:e})}},G.createElement("img",{alt:"icon",src:Et("duplicate")}))},Jg=i=>{const{icon:t,onPointerUpHandler:e}=i;return G.createElement("div",{className:"button normal-button",onPointerUp:e},G.createElement("img",{src:Et(t)}))},vMe=i=>{const{open:t,setOpen:e,floatBarRef:r}=i,{floatBarData:n,mananger:s}=G.useContext(ct),[o,a]=G.useState([]),c=G.useMemo(()=>{if(r!=null&&r.current&&ve.isNumber(n==null?void 0:n.y)&&(s!=null&&s.height)){if(r.current.offsetTop&&r.current.offsetTop+n.y>180){const h={};return h.top="inherit",h.bottom=50,h}else if(!r.current.offsetTop&&(s==null?void 0:s.height)-r.current.offsetTop-n.y<120){const h={};return h.top="inherit",h.bottom=50,h}}},[r==null?void 0:r.current,n,s]),l=G.useMemo(()=>t?G.createElement("div",{className:"image-layer-menu",style:c},G.createElement(Jg,{icon:"to-top",onPointerUpHandler:h=>{h.stopPropagation(),We.emitMethod(Fe.MainEngine,Se.ZIndexNode,{workIds:[De],layer:Mn.Top,viewId:s==null?void 0:s.viewId})}}),G.createElement(Jg,{icon:"to-bottom",onPointerUpHandler:h=>{h.stopPropagation(),We.emitMethod(Fe.MainEngine,Se.ZIndexNode,{workIds:[De],layer:Mn.Bottom,viewId:s==null?void 0:s.viewId})}})):null,[t,c]),u=h=>{h.stopPropagation(),h.nativeEvent.stopImmediatePropagation(),e(!t)};return G.useEffect(()=>{ve.isEqual(n==null?void 0:n.selectIds,o)||n!=null&&n.selectIds&&!ve.isEqual(n==null?void 0:n.selectIds,o)&&(a(n==null?void 0:n.selectIds),e(!1))},[t,n,o,e]),G.createElement("div",{className:`button normal-button ${t&&"active"}`,onPointerUp:u},l,G.createElement("img",{alt:"icon",src:Et(t?"layer-pressed":"layer")}))},_s=i=>{i.stopPropagation(),i.nativeEvent.stopImmediatePropagation()},MMe=()=>G.createElement("svg",{style:{marginLeft:"2px"},viewBox:"0 0 1025 1024",width:"14",height:"14"},G.createElement("path",{d:"M1016.5248 493.8752c-9.984-9.984-26.2144-9.984-36.1984 0l-183.6032 183.6032c-29.952 29.952-78.6944 29.952-108.5952 0l-239.2064-239.2064c-14.4384-14.4384-22.3744-33.6896-22.3744-54.3232s7.936-39.8848 22.3744-54.3232l183.6032-183.6032c9.984-9.984 9.984-26.2144 0-36.1984s-26.2144-9.984-36.1984 0l-183.6032 183.6032c-24.1152 24.1152-37.376 56.2176-37.376 90.5216 0 14.592 2.4576 28.8256 7.0656 42.1888l-374.8864 374.8864c-4.8128 4.8128-7.4752 11.3152-7.4752 18.1248l0 76.8c0 14.1312 11.4688 25.6 25.6 25.6l486.4 0c6.8096 0 13.312-2.7136 18.1248-7.4752l170.0864-170.0864c13.3632 4.6592 27.5968 7.0656 42.1888 7.0656 34.2528 0 66.4064-13.2608 90.5216-37.376l183.6032-183.6032c9.984-9.984 9.984-26.2144 0-36.1984zM501.4016 870.4l-450.2016 0 0-40.6016 358.5024-358.5024c1.024 1.0752 1.9968 2.1504 3.0208 3.1744l239.2064 239.2064c1.024 1.024 2.0992 2.048 3.1744 3.0208l-153.7024 153.7024z",fill:"#000000"})),F0=i=>{const{activeColor:t,onPointerUpHandler:e}=i;return G.createElement("div",{className:`font-color-button ${t==="transparent"?"active":""}`,onPointerUp:e},G.createElement("div",{className:"circle none"}))},gc=i=>{const{color:t,activeColor:e,onPointerUpHandler:r}=i;return G.createElement("div",{className:`font-color-button ${t===e?"active":""}`,onPointerUp:r},G.createElement("div",{className:"circle",style:{backgroundColor:St(t,1)}}))},pc=i=>{const{opacity:t,activeColor:e,setCurOpacity:r}=i,[n,s]=G.useState({x:108,y:0}),o=G.useRef(0);if(G.useEffect(()=>{s({x:t*100+8,y:0})},[]),!e)return null;const a=(h,d)=>{const g=Math.min(Math.max(h-8,0),100)/100;(t!==g||d===ge.Done)&&r(g,e,d)},c=(h,d)=>{d.x!==(n==null?void 0:n.x)&&s({x:d.x,y:0}),!o.current&&(o.current=setTimeout(()=>{o.current=0,a(d.x,ge.Doing)},100))},l=()=>{r(t,e,ge.Start)},u=(h,d)=>{d.x!==(n==null?void 0:n.x)&&s({x:d.x,y:0}),o.current&&(clearTimeout(o.current),o.current=0),a(d.x,ge.Done)};return G.createElement("div",{className:"font-color-opacity",style:{marginLeft:"10px"},onPointerUp:h=>{o.current&&(clearTimeout(o.current),o.current=0);const d=h.nativeEvent.offsetX,g=Math.min(Math.max(d-12,0),100)/100;s({x:g*100+8,y:0}),r(g,e,ge.Done)}},G.createElement("div",{className:"range-color",style:{background:`linear-gradient(to right, ${St(e,0)}, ${St(e,1)})`}}),G.createElement("div",{className:"range-opacity"},G.createElement(Bi,{bounds:"parent",axis:"x",position:n,onDrag:c,onStart:l,onStop:u},G.createElement("div",{className:"circle",style:{backgroundColor:St(e,t)},onPointerUp:_s}))))},wMe=i=>{const{min:t,max:e,activeNumber:r,setActiveNumber:n,color:s}=i,[o,a]=G.useState({x:108,y:0}),c=G.useRef(0);if(G.useEffect(()=>{const g=Math.ceil((r-t)/(e-t)*100)+8;a({x:g,y:0})},[]),!r)return null;const l=(g,p)=>{const v=Math.ceil(Math.max(g-8,0)/100*(e-t)+t);(r!==v||p===ge.Done)&&n(v,p)},u=(g,p)=>{p.x!==(o==null?void 0:o.x)&&a({x:p.x,y:0}),!c.current&&(c.current=setTimeout(()=>{c.current=0,l(p.x,ge.Doing)},100))},h=()=>{n(r,ge.Start)},d=(g,p)=>{p.x!==(o==null?void 0:o.x)&&a({x:p.x,y:0}),c.current&&(clearTimeout(c.current),c.current=0),l(p.x,ge.Done)};return G.createElement("div",{className:"font-color-opacity",style:{marginLeft:"10px"},onPointerUp:g=>{c.current&&(clearTimeout(c.current),c.current=0);const p=g.nativeEvent.offsetX,v=Math.ceil(Math.max(p-12,0)/100*(e-t)+t),I=Math.ceil((v-t)/(e-t)*100)+8;a({x:I,y:0}),n(v,ge.Done)}},G.createElement("div",{className:"range-color",style:{backgroundColor:s}}),G.createElement("div",{className:"range-opacity"},G.createElement(Bi,{bounds:"parent",axis:"x",position:o,onDrag:u,onStart:h,onStop:d},G.createElement("div",{className:"circle",style:{backgroundColor:s},onPointerUp:_s},G.createElement("div",{className:"range-opacity-data-icon"},r)))))},TMe=i=>{const{useStroke:t,color:e,activeStrokeType:r,setStrokeType:n}=i;return G.createElement("div",{className:"stroke-type-box"},!!t&&G.createElement("div",{className:`stroke-type-box-item Stroke ${r===ze.Stroke&&"active"}`,style:{backgroundColor:e},onPointerUp:()=>{n(ze.Stroke)}}),G.createElement("div",{className:`stroke-type-box-item Normal ${r===ze.Normal&&"active"}`,style:{borderColor:e},onPointerUp:()=>{n(ze.Normal)}}),G.createElement("div",{className:`stroke-type-box-item Dotted ${r===ze.Dotted&&"active"}`,style:{borderColor:e},onPointerUp:()=>{n(ze.Dotted)}}),G.createElement("div",{className:`stroke-type-box-item LongDotted ${r===ze.LongDotted&&"active"}`,style:{borderColor:e},onPointerUp:()=>{n(ze.LongDotted)}}))},SMe=i=>{const{open:t,setOpen:e,floatBarRef:r}=i,{floatBarData:n,floatBarColors:s,mananger:o,setFloatBarData:a}=G.useContext(ct),[c,l]=G.useState(),[u,h]=G.useState(1);G.useEffect(()=>{if(n!=null&&n.strokeColor){const[x,j]=ac(n.strokeColor);l(x),h(j)}},[n]);const d=G.useMemo(()=>{if(r!=null&&r.current&&n&&ve.isNumber(n==null?void 0:n.y)&&(o!=null&&o.height)){if(r.current.offsetTop&&r.current.offsetTop+n.y>180){const x={};return x.top="inherit",x.bottom=50,x}else if(!r.current.offsetTop&&(o==null?void 0:o.height)-r.current.offsetTop-n.y<120){const x={};return x.top="inherit",x.bottom=50,x}}},[n,r,o==null?void 0:o.height]),g=G.useMemo(()=>G.createElement(pc,{key:"strokeColors",opacity:u,activeColor:c,setCurOpacity:(x,j,w)=>{h(x);const y=St(j,x);n!=null&&n.strokeColor&&a({strokeColor:y}),We.emitMethod(Fe.MainEngine,Se.SetColorNode,{workIds:[De],strokeColor:y,workState:w,viewId:o==null?void 0:o.viewId})}}),[u,c,n==null?void 0:n.strokeColor,o==null?void 0:o.viewId,a]),p=G.useMemo(()=>c&&n&&n.thickness?G.createElement(wMe,{key:"strokeThickness",min:Math.min(n.thickness,(o==null?void 0:o.control.pluginOptions.extras.strokeWidth.min)||He.strokeWidth.min),max:Math.max(n.thickness,(o==null?void 0:o.control.pluginOptions.extras.strokeWidth.max)||He.strokeWidth.max),activeNumber:n.thickness,setActiveNumber:(x,j)=>{n!=null&&n.thickness&&a({thickness:x}),We.emitMethod(Fe.MainEngine,Se.SetColorNode,{workIds:[De],thickness:x,workState:j,viewId:o==null?void 0:o.viewId})},color:c}):null,[c,n,o==null?void 0:o.control.pluginOptions.extras.strokeWidth.max,o==null?void 0:o.control.pluginOptions.extras.strokeWidth.min,o==null?void 0:o.viewId,a]),v=G.useMemo(()=>c&&n&&(n!=null&&n.strokeType)?G.createElement(TMe,{key:"strokeType",useStroke:n==null?void 0:n.useStroke,activeStrokeType:n.strokeType,setStrokeType:x=>{n.strokeType&&a({strokeType:x}),We.emitMethod(Fe.MainEngine,Se.SetColorNode,{workIds:[De],strokeType:x,workState:ge.Done,viewId:o==null?void 0:o.viewId})},color:c}):null,[c,n,o==null?void 0:o.viewId,a]),I=G.useMemo(()=>t?G.createElement("div",{className:"font-colors-menu",style:d,onPointerUp:x=>{x.stopPropagation(),x.nativeEvent.stopImmediatePropagation()}},v,p,G.createElement("div",{className:"font-colors-line"}),s.concat().map((x,j)=>{const w=Js(...x);return G.createElement(gc,{key:j,color:w,activeColor:c,onPointerUpHandler:y=>{y.stopPropagation(),l(w);const f=St(w,u);n!=null&&n.strokeColor&&(n.strokeColor=f,a({strokeColor:f})),We.emitMethod(Fe.MainEngine,Se.SetColorNode,{workIds:[De],workState:ge.Done,strokeColor:f,viewId:o==null?void 0:o.viewId})}})}),g):null,[t,d,v,p,s,g,c,u,n,o==null?void 0:o.viewId,a]),D=G.useMemo(()=>c?G.createElement("div",{className:"color-bar-ring",style:{backgroundColor:St(c,u)}},G.createElement("div",{className:"circle"})):null,[c,u]);return G.createElement("div",{className:`button normal-button font-colors-icon ${t&&"active"}`,onPointerUp:x=>{x.stopPropagation(),x.nativeEvent.stopImmediatePropagation(),e(!t)}},D,I)},IMe=i=>{const{open:t,setOpen:e,floatBarRef:r}=i,{floatBarData:n,floatBarColors:s,mananger:o,setFloatBarData:a}=G.useContext(ct),[c,l]=G.useState(),[u,h]=G.useState(1);G.useEffect(()=>{if(n!=null&&n.fillColor){const[I,D]=(n==null?void 0:n.fillColor)==="transparent"&&["transparent",1]||ac(n.fillColor);l(I),h(D)}},[n]);const d=G.useMemo(()=>{if(r!=null&&r.current&&ve.isNumber(n==null?void 0:n.y)&&(o!=null&&o.height)){if(r.current.offsetTop&&r.current.offsetTop+n.y>200){const I={};return I.top="inherit",I.bottom=50,I}else if(!r.current.offsetTop&&(o==null?void 0:o.height)-r.current.offsetTop-n.y<140){const I={};return I.top="inherit",I.bottom=50,I}}},[r,n,o==null?void 0:o.height]),g=G.useMemo(()=>c&&c!=="transparent"?G.createElement(pc,{key:"fillColors",opacity:u||0,activeColor:c,setCurOpacity:(I,D,x)=>{h(I);const j=St(D,I);n!=null&&n.fillColor&&(n.fillColor=j,a({fillColor:j})),We.emitMethod(Fe.MainEngine,Se.SetColorNode,{workIds:[De],fillColor:c&&St(D,I),workState:x,viewId:o==null?void 0:o.viewId})}}):null,[c,u,n,o==null?void 0:o.viewId,a]),p=G.useMemo(()=>t?G.createElement("div",{className:"font-colors-menu",style:d,onPointerUp:I=>{I.stopPropagation(),I.nativeEvent.stopImmediatePropagation()}},G.createElement(F0,{activeColor:c,onPointerUpHandler:I=>{I.stopPropagation(),l("transparent");const D="transparent";n!=null&&n.fillColor&&(n.fillColor=D,a({fillColor:D})),We.emitMethod(Fe.MainEngine,Se.SetColorNode,{workIds:[De],workState:ge.Done,fillColor:D,viewId:o==null?void 0:o.viewId})}}),s.map((I,D)=>{const x=Js(...I);return G.createElement(gc,{key:D,color:x,activeColor:c,onPointerUpHandler:j=>{j.cancelable&&j.preventDefault(),j.stopPropagation(),l(x);const w=St(x,u);n!=null&&n.fillColor&&(n.fillColor=w,a({fillColor:w})),We.emitMethod(Fe.MainEngine,Se.SetColorNode,{workIds:[De],workState:ge.Done,fillColor:w,viewId:o==null?void 0:o.viewId})}})}),g):null,[t,d,c,s,g,n,o==null?void 0:o.viewId,a,u]),v=G.useMemo(()=>{const I=c&&c!=="transparent"&&St(c,u)||"transparent";return G.createElement("div",{className:"color-bar-fill"},G.createElement("div",{className:"circle",style:{backgroundColor:I}}))},[c,u]);return G.createElement("div",{className:`button normal-button font-colors-icon ${t&&"active"}`,onPointerUp:I=>{I.stopPropagation(),I.nativeEvent.stopImmediatePropagation(),e(!t)}},v,p)},CMe=i=>{const{open:t,setOpen:e,textOpt:r,workIds:n,floatBarRef:s}=i,{floatBarColors:o,mananger:a,setFloatBarData:c,floatBarData:l}=G.useContext(ct),[u,h]=G.useState(),[d,g]=G.useState(1);G.useEffect(()=>{if(r!=null&&r.fontColor){const[x,j]=(r==null?void 0:r.fontColor)==="transparent"&&["transparent",0]||ac(r.fontColor);h(x),g(j)}},[r==null?void 0:r.fontColor]);const p=G.useMemo(()=>{if(s!=null&&s.current&&l&&ve.isNumber(l==null?void 0:l.y)&&(a!=null&&a.height)){if(s.current.offsetTop&&s.current.offsetTop+l.y>180){const x={};return x.top="inherit",x.bottom=50,x}else if(!s.current.offsetTop&&(a==null?void 0:a.height)-s.current.offsetTop-l.y<120){const x={};return x.top="inherit",x.bottom=50,x}}},[s,l,a==null?void 0:a.height]),v=G.useMemo(()=>u&&u!=="transparent"?G.createElement(pc,{key:"fontColors",opacity:d,activeColor:u,setCurOpacity:(x,j,w)=>{g(x);const y=St(j,x);l!=null&&l.textOpt&&(l.textOpt.fontColor=y,c({textOpt:l.textOpt})),We.emitMethod(Fe.MainEngine,Se.SetColorNode,{workIds:n||[De],fontColor:u&&y,workState:w,viewId:a==null?void 0:a.viewId})}}):null,[c,u,d,a==null?void 0:a.control.room,a==null?void 0:a.viewId,l==null?void 0:l.textOpt,n]),I=G.useMemo(()=>t?G.createElement("div",{className:"font-colors-menu",style:p,onPointerUp:x=>{x.stopPropagation(),x.nativeEvent.stopImmediatePropagation()}},o.map((x,j)=>{const w=Js(...x);return G.createElement(gc,{key:j,color:w,activeColor:u,onPointerUpHandler:y=>{y.stopPropagation(),h(w);const f=St(w,d);l!=null&&l.textOpt&&(l.textOpt.fontColor=f,c({textOpt:l.textOpt})),We.emitMethod(Fe.MainEngine,Se.SetColorNode,{workIds:n||[De],workState:ge.Done,fontColor:f,viewId:a==null?void 0:a.viewId})}})}),v):null,[c,t,o,v,u,d,l==null?void 0:l.textOpt,n,a==null?void 0:a.viewId,p]),D=G.useMemo(()=>{const x=u&&u!=="transparent"&&St(u,d)||"transparent";return G.createElement("div",{className:"color-bar"},G.createElement("div",{className:"color-bar-color",style:{backgroundColor:x}}))},[u,d]);return G.createElement("div",{className:`button normal-button font-colors-icon ${t&&"active"}`,onPointerUp:x=>{x.stopPropagation(),x.nativeEvent.stopImmediatePropagation(),e(!t)}},G.createElement("img",{alt:"icon",src:Et("font-colors")}),D,I)},bMe=i=>{const{open:t,setOpen:e,textOpt:r,workIds:n,floatBarRef:s}=i,{floatBarColors:o,mananger:a,setFloatBarData:c,floatBarData:l}=G.useContext(ct),[u,h]=G.useState(),[d,g]=G.useState(1);G.useEffect(()=>{if(r!=null&&r.fontBgColor){const[x,j]=(r==null?void 0:r.fontBgColor)==="transparent"&&["transparent",1]||ac(r.fontBgColor);h(x),g(j)}},[r==null?void 0:r.fontBgColor]);const p=G.useMemo(()=>{if(s!=null&&s.current&&l&&ve.isNumber(l==null?void 0:l.y)&&(a!=null&&a.height)){if(s.current.offsetTop&&s.current.offsetTop+l.y>180){const x={};return x.top="inherit",x.bottom=50,x}else if(!s.current.offsetTop&&(a==null?void 0:a.height)-s.current.offsetTop-l.y<120){const x={};return x.top="inherit",x.bottom=50,x}}},[s,l,a==null?void 0:a.height]),v=G.useMemo(()=>u&&u!=="transparent"?G.createElement(pc,{key:"fontBgColor",opacity:d||0,activeColor:u,setCurOpacity:(x,j,w)=>{g(x);const y=St(j,x);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=y,c({textOpt:l.textOpt})),We.emitMethod(Fe.MainEngine,Se.SetColorNode,{workIds:n||[De],fontBgColor:u&&St(j,x),workState:w,viewId:a==null?void 0:a.viewId})}}):null,[u,d,l==null?void 0:l.textOpt,n,a==null?void 0:a.viewId,c]),I=G.useMemo(()=>t?G.createElement("div",{className:"font-colors-menu",style:p,onPointerUp:x=>{x.stopPropagation(),x.nativeEvent.stopImmediatePropagation()}},G.createElement(F0,{activeColor:u,onPointerUpHandler:x=>{x.stopPropagation();const j="transparent";h(j),l!=null&&l.textOpt&&(l.textOpt.fontBgColor=j,c({textOpt:l.textOpt})),We.emitMethod(Fe.MainEngine,Se.SetColorNode,{workIds:n||[De],workState:ge.Done,fontBgColor:j,viewId:a==null?void 0:a.viewId})}}),o.map((x,j)=>{const w=Js(...x);return G.createElement(gc,{key:j,color:w,activeColor:u,onPointerUpHandler:y=>{y.stopPropagation(),h(w);const f=St(w,d);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=f,c({textOpt:l.textOpt})),We.emitMethod(Fe.MainEngine,Se.SetColorNode,{workIds:n||[De],workState:ge.Done,fontBgColor:St(w,d),viewId:a==null?void 0:a.viewId})}})}),v):null,[c,t,o,v,d,u,l==null?void 0:l.textOpt,n,a==null?void 0:a.viewId,p]),D=G.useMemo(()=>{const x=u&&u!=="transparent"&&St(u,d)||"transparent";return G.createElement("div",{className:"color-bar",style:{marginTop:0}},G.createElement("div",{className:"color-bar-color",style:{backgroundColor:x}}))},[u,d]);return G.createElement("div",{className:`button normal-button font-colors-icon ${t&&"active"}`,onPointerUp:x=>{x.stopPropagation(),x.nativeEvent.stopImmediatePropagation(),e(!t)}},G.createElement(MMe,null),D,I)},xMe=i=>{const{bold:t,setBold:e,workIds:r,viewId:n}=i,s=o=>{const a=t==="bold"?"normal":"bold";o==null||o.stopPropagation(),e(a),We.emitMethod(Fe.MainEngine,Se.SetFontStyle,{workIds:r,viewId:n,bold:a})};return G.createElement("div",{className:"font-style-button",onPointerUp:s},G.createElement("img",{alt:"icon",src:Et(t==="bold"?"bold-active":"bold")}))},EMe=i=>{const{underline:t,setUnderline:e,workIds:r,viewId:n}=i,s=o=>{const a=!t;o==null||o.stopPropagation(),e(a),We.emitMethod(Fe.MainEngine,Se.SetFontStyle,{workIds:r,viewId:n,underline:a})};return G.createElement("div",{className:"font-style-button",onPointerUp:s},G.createElement("img",{alt:"icon",src:Et(t?"underline-active":"underline")}))},AMe=i=>{const{lineThrough:t,setLineThrough:e,workIds:r,viewId:n}=i,s=o=>{const a=!t;o==null||o.stopPropagation(),e(a),We.emitMethod(Fe.MainEngine,Se.SetFontStyle,{workIds:r,viewId:n,lineThrough:a})};return G.createElement("div",{className:"font-style-button",onPointerUp:s},G.createElement("img",{alt:"icon",src:Et(t?"line-through-active":"line-through")}))},NMe=i=>{const{italic:t,setItalic:e,workIds:r,viewId:n}=i,s=o=>{const a=t==="italic"?"normal":"italic";o==null||o.stopPropagation(),e(a),We.emitMethod(Fe.MainEngine,Se.SetFontStyle,{workIds:r,viewId:n,italic:a})};return G.createElement("div",{className:"font-style-button",onPointerUp:s},G.createElement("img",{alt:"icon",src:Et(t==="italic"?"italic-active":"italic")}))},DMe=i=>{const{open:t,setOpen:e,textOpt:r,workIds:n,style:s,floatBarRef:o}=i,{mananger:a,floatBarData:c}=G.useContext(ct),[l,u]=G.useState("normal"),[h,d]=G.useState("normal"),[g,p]=G.useState(!1),[v,I]=G.useState(!1);G.useEffect(()=>{r!=null&&r.bold&&u(r.bold),ve.isBoolean(r==null?void 0:r.underline)&&p(r.underline||!1),ve.isBoolean(r==null?void 0:r.lineThrough)&&I(r.lineThrough||!1),r!=null&&r.italic&&d(r.italic)},[r]);const D=G.useMemo(()=>{if(s&&(o!=null&&o.current)&&ve.isNumber(c==null?void 0:c.y)&&(a!=null&&a.height)){if(o.current.offsetTop&&o.current.offsetTop+c.y>180){const j={};return j.top="inherit",j.bottom=50,j}else if(!o.current.offsetTop&&(a==null?void 0:a.height)-o.current.offsetTop-c.y<120){const j={};return j.top="inherit",j.bottom=50,j}}},[s,o==null?void 0:o.current,c,a]),x=G.useMemo(()=>t?G.createElement("div",{className:"font-style-menu",style:D,onPointerUp:j=>{j.stopPropagation(),j.nativeEvent.stopImmediatePropagation()}},G.createElement(xMe,{workIds:n||[De],bold:l,setBold:u,viewId:a==null?void 0:a.viewId}),G.createElement(EMe,{workIds:n||[De],underline:g,setUnderline:p,viewId:a==null?void 0:a.viewId}),G.createElement(AMe,{workIds:n||[De],lineThrough:v,setLineThrough:I,viewId:a==null?void 0:a.viewId}),G.createElement(NMe,{workIds:n||[De],italic:h,setItalic:d,viewId:a==null?void 0:a.viewId})):null,[t,n,l,a==null?void 0:a.viewId,g,v,h,D]);return G.createElement("div",{className:`button normal-button ${t&&"active"}`,onPointerUp:j=>{j.stopPropagation(),j.nativeEvent.stopImmediatePropagation(),e(!t)}},G.createElement("img",{alt:"icon",src:Et(t?"font-style-active":"font-style")}),x)},PMe=i=>{const{style:t,onClickHandler:e}=i;return G.createElement("div",{className:"font-size-menu",style:t,onPointerUp:r=>{r.stopPropagation(),r.nativeEvent.stopImmediatePropagation()}},Cr.map(r=>G.createElement("div",{className:"font-size-btn",key:r,onPointerUp:()=>{e(r)}},r)))},kMe=i=>{const t=G.useRef(null),{open:e,setOpen:r,textOpt:n,workIds:s,floatBarRef:o}=i,{mananger:a,floatBarData:c}=G.useContext(ct),[l,u]=G.useState(0),h=Cr.length-1;G.useEffect(()=>{n!=null&&n.fontSize&&(u(n.fontSize),t.current&&(t.current.value=n.fontSize.toString()))},[n==null?void 0:n.fontSize]);const d=G.useMemo(()=>{if(o!=null&&o.current&&ve.isNumber(c==null?void 0:c.y)&&(a!=null&&a.height)){if(o.current.offsetTop&&o.current.offsetTop+c.y>180){const D={};return D.top="inherit",D.bottom=35,D}else if(!o.current.offsetTop&&(a==null?void 0:a.height)-o.current.offsetTop-c.y<120){const D={};return D.top="inherit",D.bottom=35,D}}},[o==null?void 0:o.current,c,a]);function g(D){u(D),D&&D>=Cr[0]&&D<=Cr[h]&&We.emitMethod(Fe.MainEngine,Se.SetFontStyle,{workIds:s||[De],fontSize:D,viewId:a==null?void 0:a.viewId})}const p=D=>{var x;(x=t.current)==null||x.blur(),r(!1),I(D)},v=G.useMemo(()=>e?G.createElement(PMe,{onClickHandler:p,style:d}):null,[e,p,d]),I=D=>{D>Cr[h]&&(D=Cr[h]),D<Cr[0]&&(D=Cr[0]),g(D)};return G.createElement("div",{className:"button normal-button font-size-barBtn",style:{width:50},onPointerUp:D=>{D.stopPropagation(),D.nativeEvent.stopImmediatePropagation()}},G.createElement("input",{className:"font-size-input",ref:t,onTouchEnd:()=>{t.current&&t.current.focus()},onClick:()=>{r(!e),t.current&&t.current.focus()},onKeyDown:D=>{if(D.stopPropagation(),D.nativeEvent.stopImmediatePropagation(),D.key==="Backspace"){const x=window.getSelection(),j=x==null?void 0:x.getRangeAt(0);if(j!=null&&j.collapsed)return D.cancelable&&D.preventDefault(),document.execCommand("delete",!1),!1}return!1},onKeyUp:D=>{var x;if(D.stopPropagation(),D.nativeEvent.stopImmediatePropagation(),t.current){const j=t.current.value,w=parseInt(j);isNaN(w)?t.current.value="0":t.current.value=w.toString(),w&&D.key==="Enter"&&(I(w),(x=t.current)==null||x.blur(),r(!1))}}}),G.createElement("div",{className:"font-size-btns"},G.createElement("div",{className:"font-size-add",onPointerUp:()=>{I(l+Cr[0])}}),G.createElement("div",{className:"font-size-cut",onPointerUp:()=>{I(l-Cr[0])}})),v)},LMe=i=>{const{workIds:t,mananger:e,islocked:r}=i;return G.createElement("div",{className:"button normal-button",onPointerUp:n=>{n.stopPropagation(),We.emitMethod(Fe.MainEngine,Se.SetLock,{workIds:t||[De],isLocked:!r,viewId:e==null?void 0:e.viewId})}},G.createElement("img",{alt:"icon",src:Et(r?"unlock-new":"lock-new")}))},mu=i=>{const{icon:t,min:e,max:r,step:n,value:s,onInputHandler:o}=i,[a,c]=G.useState(0),l=G.useRef(null),u=h=>{h>r&&(h=r),h<e&&(h=e),c(h),o(h),l.current&&(l.current.value=h.toString())};return G.useEffect(()=>{s&&(c(s),l.current&&(l.current.value=s.toString()))},[s]),G.createElement("div",{className:"button input-button"},G.createElement("img",{src:Et(t)}),G.createElement("input",{className:"input-number",type:"text",ref:l,onPointerUp:()=>{l.current&&l.current.focus()},onKeyDown:h=>{if(h.stopPropagation(),h.nativeEvent.stopImmediatePropagation(),h.key==="Backspace"){const 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:h=>{if(h.stopPropagation(),h.nativeEvent.stopImmediatePropagation(),l.current){const d=l.current.value,g=parseInt(d);isNaN(g)?l.current.value="0":l.current.value=g.toString()}},onChange:h=>{const d=h.target.value,g=parseInt(d);g&&g&&g>=e&&g<=r&&u(g)}}),G.createElement("div",{className:"input-number-btns"},G.createElement("div",{className:"input-number-add",onPointerUp:()=>{u(a+n)}}),G.createElement("div",{className:"input-number-cut",onPointerUp:()=>{u(a-n)}})))},RMe=i=>{const{icon:t,min:e,max:r,step:n,value:s,onInputHandler:o}=i;return G.createElement("div",{className:"button input-button"},G.createElement("img",{src:Et(t)}),G.createElement(OMe,{min:e,max:r,step:n,value:s,onInputHandler:o}))},OMe=i=>{const{value:t,min:e,max:r,onInputHandler:n}=i,[s,o]=G.useState({x:0,y:0});G.useEffect(()=>{o({x:t*100,y:0})},[]);const a=(u,h)=>{let d=Math.floor(Math.max(h.x,e*100));d=Math.floor(Math.min(d,r*100)),h.x!==(s==null?void 0:s.x)&&o({x:d,y:0});const g=d/100;t!==g&&n(g)},c=()=>{},l=(u,h)=>{let d=Math.floor(Math.max(h.x,e*100));d=Math.floor(Math.min(d,r*100)),h.x!==(s==null?void 0:s.x)&&o({x:d,y:0});const g=d/100;t!==g&&n(g)};return G.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,r*100)),o({x:d,y:0});const g=d/100;t!==g&&n(g)}},G.createElement("div",{className:"range-number-color"}),G.createElement("div",{className:"range-number"},G.createElement(Bi,{bounds:"parent",axis:"x",position:s,onDrag:a,onStart:c,onStop:l},G.createElement("div",{className:"circle",onPointerUp:_s}))))},zMe=i=>{const{icon:t,value:e,onChangeHandler:r,style:n}=i,[s,o]=G.useState(0),[a,c]=G.useState(),l=G.useRef(null),u=G.useCallback(g=>{g>=wi.length&&(g=0),g<0&&(g=wi.length-1),o(g),r(wi[g]),c(!1),l.current&&(l.current.value=wi[g])},[r]),h=G.useMemo(()=>{if(n&&n.bottom){const g={};return g.top="inherit",g.bottom=50,g}},[n]);G.useEffect(()=>{e&&(o(wi.indexOf(e)),l.current&&(l.current.value=e))},[e]);const d=G.useMemo(()=>a?G.createElement(jMe,{options:wi,onClickHandler:u,style:h}):null,[a,u,h]);return G.createElement("div",{className:"button input-button"},G.createElement("img",{src:Et(t)}),G.createElement("input",{readOnly:!0,className:"input-number",type:"text",ref:l,onPointerUp:()=>{l.current&&(l.current.focus(),c(!a))}}),G.createElement("div",{className:"input-number-btns"},G.createElement("div",{className:"input-number-add",onPointerUp:()=>{u(s+1)}}),G.createElement("div",{className:"input-number-cut",onPointerUp:()=>{u(s-1)}})),d)},jMe=i=>{const{options:t,style:e,onClickHandler:r}=i;return G.createElement("div",{className:"select-option-menu",style:e},t.map((n,s)=>G.createElement("div",{className:"select-option-btn",key:n,onPointerUp:()=>{r(s)}},n)))},BMe=i=>{const{innerRatio:t,innerVerticeStep:e,vertices:r,mananger:n,setShapeOpt:s}=i,o=l=>{s({vertices:l}),We.emitMethod(Fe.MainEngine,Se.SetShapeOpt,{workIds:[De],toolsType:K.Star,viewId:n.viewId,vertices:l})},a=l=>{s({innerVerticeStep:l}),We.emitMethod(Fe.MainEngine,Se.SetShapeOpt,{workIds:[De],toolsType:K.Star,viewId:n.viewId,innerVerticeStep:l})},c=l=>{s({innerRatio:l}),We.emitMethod(Fe.MainEngine,Se.SetShapeOpt,{workIds:[De],toolsType:K.Star,viewId:n.viewId,innerRatio:l})};return G.createElement(G.Fragment,null,G.createElement(mu,{value:r,icon:"polygon-vertex",min:3,max:100,step:1,onInputHandler:o}),G.createElement(mu,{value:e,icon:"star-innerVertex",min:1,max:100,step:1,onInputHandler:a}),G.createElement(RMe,{value:t,icon:"star-innerRatio",min:.1,max:1,step:.1,onInputHandler:c}))},UMe=i=>{const{mananger:t,vertices:e,setShapeOpt:r}=i,n=s=>{r({vertices:s}),We.emitMethod(Fe.MainEngine,Se.SetShapeOpt,{workIds:[De],toolsType:K.Polygon,viewId:t.viewId,vertices:s})};return G.createElement(mu,{value:e,icon:"polygon-vertex",min:3,max:100,step:1,onInputHandler:n})},FMe=i=>{const{mananger:t,placement:e,setShapeOpt:r}=i,n=s=>{r({placement:s}),We.emitMethod(Fe.MainEngine,Se.SetShapeOpt,{workIds:[De],toolsType:K.SpeechBalloon,viewId:t.viewId,placement:s})};return G.createElement(zMe,{value:e,icon:"speechBallon-placement",onChangeHandler:n})},vl=i=>{const{icon:t,isActive:e,onPointerUpHandler:r}=i;return G.createElement("div",{className:`button tab-button ${e?"active":""}`,onPointerUp:r},G.createElement("img",{src:Et(t)}))},WMe=i=>{const{toolsTypes:t,style:e,mananger:r,shapeOpt:n,setShapeOpt:s}=i,[o,a]=G.useState();G.useEffect(()=>{t.includes(K.Polygon)?a(K.Polygon):t.includes(K.Star)?a(K.Star):a(K.SpeechBalloon)},[t]);const c=d=>{a(d)},l=G.useMemo(()=>o===K.Polygon&&r&&n.vertices?G.createElement(UMe,{vertices:n.vertices,mananger:r,setShapeOpt:s}):null,[r,o,n,s]),u=G.useMemo(()=>o===K.Star&&r&&n.vertices&&n.innerVerticeStep&&n.innerRatio?G.createElement(BMe,{mananger:r,vertices:n.vertices,innerVerticeStep:n.innerVerticeStep,innerRatio:n.innerRatio,setShapeOpt:s}):null,[r,o,n,s]),h=G.useMemo(()=>o===K.SpeechBalloon&&r&&n.placement?G.createElement(FMe,{mananger:r,placement:n.placement,setShapeOpt:s}):null,[o,r,n.placement,s]);return G.createElement("div",{className:"shapeOpt-sub-menu",style:e,onPointerUp:_s},G.createElement("div",{className:"shapeOpt-sub-menu-tabs"},t.includes(K.Polygon)&&G.createElement(vl,{isActive:o===K.Polygon,icon:o===K.Polygon?"polygon-active":"polygon",onPointerUpHandler:c.bind(void 0,K.Polygon)})||null,t.includes(K.Star)&&G.createElement(vl,{isActive:o===K.Star,icon:o===K.Star?"star-active":"star",onPointerUpHandler:c.bind(void 0,K.Star)})||null,t.includes(K.SpeechBalloon)&&G.createElement(vl,{isActive:o===K.SpeechBalloon,icon:o===K.SpeechBalloon?"speechBallon-active":"speechBallon",onPointerUpHandler:c.bind(void 0,K.SpeechBalloon)})||null),G.createElement("div",{className:"shapeOpt-sub-menu-content"},l,u,h))},$Me=i=>{const{open:t,setOpen:e,floatBarRef:r,toolsTypes:n,shapeOpt:s}=i,{floatBarData:o,mananger:a,setFloatBarData:c}=G.useContext(ct),l=G.useRef(null),u=G.useMemo(()=>{if(r!=null&&r.current&&ve.isNumber(o==null?void 0:o.x)&&ve.isNumber(o==null?void 0:o.y)&&(a!=null&&a.height)){if(r.current.offsetTop&&r.current.offsetTop+o.y>200){const p={};return p.top="inherit",p.bottom=50,p}else if(!r.current.offsetTop&&(a==null?void 0:a.height)-r.current.offsetTop-(o==null?void 0:o.y)<140){const p={};return p.top="inherit",p.bottom=50,p}}},[r,o==null?void 0:o.x,o==null?void 0:o.y,a==null?void 0:a.height]),h=G.useCallback(p=>{c({shapeOpt:{...s,...p}})},[c,s]),d=G.useMemo(()=>t&&n&&a&&s?G.createElement(WMe,{shapeOpt:s,style:u,toolsTypes:n,mananger:a,setShapeOpt:h}):null,[t,u,n,a,s,h]),g=()=>{e(!t)};return G.createElement("div",{ref:l,className:`button normal-button ${t&&"active"}`,onPointerUp:g},d,G.createElement("img",{alt:"icon",src:Et(t?"shapes-active":"shapes")}))},W0=G.memo(i=>{const{textOpt:t,workIds:e,noLayer:r,position:n,noDelete:s,noCopy:o}=i,{floatBarData:a,mananger:c}=G.useContext(ct),[l,u]=G.useState(0),[h,d]=G.useState(),g=G.useRef(null);G.useEffect(()=>{var C,P,E,O;const M={},T=(a==null?void 0:a.w)||((C=t==null?void 0:t.boxSize)==null?void 0:C[0])||0,b=(a==null?void 0:a.h)||((P=t==null?void 0:t.boxSize)==null?void 0:P[1])||0;if(n&&T&&b&&(c!=null&&c.width)&&(c!=null&&c.height)){if(n.y<60?n.y+b<c.height-60?M.bottom=-120:n.y+b<c.height?M.bottom=-58:n.y>0?M.top=62:M.top=-n.y+62:M.top=0,n.x<0)M.left=-n.x+3;else if(n.x+(((E=g.current)==null?void 0:E.offsetWidth)||T)>c.width){const V=c.width-(((O=g.current)==null?void 0:O.offsetWidth)||T)-n.x;M.left=V}d(M);return}d(void 0)},[g,n,a==null?void 0:a.w,a==null?void 0:a.h,c==null?void 0:c.width,c==null?void 0:c.height,t==null?void 0:t.boxSize]);const p=G.useMemo(()=>a!=null&&a.fillColor?G.createElement(IMe,{floatBarRef:g,open:l===3,setOpen:M=>{u(M===!0?3:0)}}):null,[a==null?void 0:a.fillColor,l,g]),v=G.useMemo(()=>a!=null&&a.strokeColor?G.createElement(SMe,{floatBarRef:g,open:l===2,setOpen:M=>{u(M===!0?2:0)}}):null,[a==null?void 0:a.strokeColor,l,g]),I=G.useMemo(()=>t!=null&&t.fontColor&&(c!=null&&c.viewId)?G.createElement(CMe,{floatBarRef:g,open:l===4,setOpen:M=>{u(M===!0?4:0)},textOpt:t,workIds:e}):null,[t,l,e,c,g]),D=G.useMemo(()=>t!=null&&t.fontBgColor&&(c!=null&&c.viewId)?G.createElement(bMe,{floatBarRef:g,open:l===5,setOpen:M=>{u(M===!0?5:0)},textOpt:t,workIds:e}):null,[t,l,e,c,g]),x=G.useMemo(()=>t&&(c!=null&&c.viewId)?G.createElement(DMe,{floatBarRef:g,open:l===6,setOpen:M=>{u(M===!0?6:0)},textOpt:t,workIds:e,style:h}):null,[t,l,e,c,h,g]),j=G.useMemo(()=>t&&(c!=null&&c.viewId)?G.createElement(kMe,{open:l===7,setOpen:M=>{u(M===!0?7:0)},textOpt:t,workIds:e,floatBarRef:g}):null,[t,l,e,c,g]),w=G.useMemo(()=>r?null:G.createElement(vMe,{open:l===1,setOpen:M=>{u(M===!0?1:0)},floatBarRef:g}),[r,l,g]),y=G.useMemo(()=>a!=null&&a.canLock&&c?G.createElement(LMe,{workIds:e,mananger:c,islocked:a.isLocked}):null,[a,c,e]),f=G.useMemo(()=>c&&(c!=null&&c.viewId)&&h&&(a!=null&&a.shapeOpt)&&(a!=null&&a.toolsTypes)?G.createElement($Me,{open:l===8,setOpen:M=>{u(M===!0?8:0)},floatBarRef:g,workIds:e,toolsTypes:a.toolsTypes,shapeOpt:a.shapeOpt}):null,[a,c,l,h,e,g]);return G.createElement("div",{className:"appliance-plugin-floatbtns",style:h,ref:g},c&&!s&&G.createElement(mMe,{workIds:e,mananger:c}),w,y,!!(c!=null&&c.viewId)&&!o&&G.createElement(yMe,{workIds:e,viewId:c.viewId}),f,x,j,I,D,v,p)}),VMe=i=>{const{data:t,workId:e,updateOptInfo:r}=i,{opt:n,scale:s,translate:o,x:a,y:c}=t,l=G.useRef(null),{floatBarData:u}=G.useContext(ct),h=G.useMemo(()=>{const{fontSize:p,fontFamily:v,underline:I,fontColor:D,lineThrough:x,textAlign:j,strokeColor:w,lineHeight:y,bold:f,italic:M}=n,T=y||p*1.2,b={fontSize:`${p}px`,lineHeight:`${T}px`,color:"transparent",caretColor:D,borderColor:w,minHeight:`${T}px`,pointerEvents:"none",paddingRight:`${M==="italic"?Math.round(p*.3):5}px`};return v&&(b.fontFamily=`${v}`),(x||I)&&(b.textDecoration=`${x&&"line-through"||""}${I&&" underline"||""}`),j&&(b.textAlign=`${j}`),f&&(b.fontWeight=`${f}`),M&&(b.fontStyle=`${M}`),b},[n]),d=G.useMemo(()=>{const p=[];if(n.text){const v=Nn(n.text);for(let I=0;I<v.length;I++){const D=v[I];D===""?p.push(G.createElement("div",{key:I})):p.push(G.createElement("div",{key:I},D))}}return p.length?p:G.createElement("div",null)},[n.text]),g=G.useMemo(()=>{if(!u)return{};const p=`scale(${s||1}) ${o&&"translate("+o[0]+"px,"+o[1]+"px)"||""}`;return{left:`${a-u.x}px`,top:`${c-u.y}px`,zIndex:1,transform:p,transformOrigin:"left top",opacity:0,pointerEvents:"auto"}},[s,o,a,c,u]);return G.useEffect(()=>{if(!l.current)return;const p=l.current.offsetWidth,v=l.current.offsetHeight;if(!p||!v)return;const I=n.boxSize;if((I==null?void 0:I[0])!==p||I[1]!==v||!I){r({activeTextId:e,update:{boxSize:[p,v],workState:ge.Done}});return}},[n.fontSize,n.italic,n.bold,n.boxSize,e,r]),G.createElement("div",{className:"editor-box readonly","data-text-work-id":e,style:g},G.createElement("div",{className:"editor",ref:l,style:h},d))},YMe=i=>{const{mananger:t}=G.useContext(ct),e=G.useMemo(()=>{var n;const r=s=>{var u,h;if(!t)return;const{activeTextId:o,update:a,syncData:c}=s,l=o&&ve.cloneDeep(((u=t.control.textEditorManager)==null?void 0:u.get(o))||((h=i.editors)==null?void 0:h.get(o)));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),t.control.textEditorManager.updateForViewEdited(o,l))};if((n=i.editors)!=null&&n.size){const s=[];return i.editors.forEach((o,a)=>{if(i.selectIds&&i.selectIds.includes(a)){const c=G.createElement(VMe,{key:a,workId:a,data:o,updateOptInfo:r});s.push(c)}}),s}return null},[i.editors,i.selectIds,t]);return G.createElement(G.Fragment,null,e)},GMe=i=>{const{position:t,textOpt:e,workIds:r,noLayer:n,noCopy:s,noDelete:o,style:a}=i,c=G.useRef(null);return G.createElement("div",{className:gt.FloatBarBtn,ref:c,style:a},G.createElement(W0,{position:t,textOpt:e,workIds:r,noLayer:n,noCopy:s,noDelete:o}))},HMe=i=>{const{data:t,workId:e,showFloatBtns:r,handleKeyUp:n,handleFocus:s,runAnimation:o,updateSize:a,rightBoundBreak:c}=i,{activeTextEditor:l,activeTextId:u,mananger:h}=G.useContext(ct),{opt:d,scale:g,translate:p,x:v,y:I}=t,{fontSize:D,fontFamily:x,underline:j,fontColor:w,lineThrough:y,textAlign:f,lineHeight:M,bold:T,italic:b}=d,C=G.useRef(null),P=G.useMemo(()=>{const m=D,S=M||m*1.2,F={fontSize:`${m}px`,lineHeight:`${S}px`,caretColor:w,color:"transparent",minHeight:`${S}px`,paddingRight:`${b==="italic"?Math.round(m*.3):5}px`,borderWidth:0};return x&&(F.fontFamily=`${x}`),(y||j)&&(F.textDecoration=`${y&&"line-through"||""} ${j&&" underline"||""}`),f&&(F.textAlign=`${f}`),T&&(F.fontWeight=`${T}`),b&&(F.fontStyle=`${b}`),F},[T,w,x,D,b,M,y,g,f,j]),E=G.useRef(!1),O=G.useRef(6),V=G.useRef(),N=G.useRef(),A=G.useRef(!1),k=G.useRef(!1),U=G.useRef({fontSize:P.fontSize,lineHeight:P.lineHeight,fontStyle:P.fontStyle,fontWeight:P.fontWeight,fontFamily:P.fontFamily}),Z=G.useMemo(()=>typeof window>"u"?!1:navigator.maxTouchPoints>0||"ontouchstart"in window,[]),Q=G.useMemo(()=>u===e?"hover":d.workState===ge.Doing||d.workState===ge.Start?"editing":l?"active":"none",[u,e,d.workState,l]);function ce(m){if(!C.current)return;const F=m&&Uve(m.nativeEvent)?Fve(m.nativeEvent):void 0,Y=()=>{V.current&&(cancelAnimationFrame(V.current),V.current=void 0),N.current&&(window.clearTimeout(N.current),N.current=void 0)},_=re=>{const ne=C.current,J=window==null?void 0:window.getSelection();if(!(!ne||!J||!A.current)){if(document.activeElement!==ne)try{ne.focus({preventScroll:!0})}catch{ne.focus()}if(re){const{x:se,y:ue}=re;if(document.caretPositionFromPoint){const oe=document.caretPositionFromPoint(se,ue);if(oe){const de=ne.contains(oe.offsetNode);if(de){const me=document.createRange();me.setStart(oe.offsetNode,oe.offset),me.collapse(!0),J.removeAllRanges(),J.addRange(me),k.current=!0}if(de)return}}else if(document.caretRangeFromPoint){const oe=document.caretRangeFromPoint(se,ue);if(oe){const de=ne.contains(oe.startContainer);if(de&&(J.removeAllRanges(),J.addRange(oe),k.current=!0),de)return}}if(Hpe(J,ne,re)){k.current=!0;return}}Zpe({hasPoint:!!re,previousByPoint:k.current,hasSelectionInEditor:Lg(J,ne),rangeCount:J.rangeCount,isCollapsed:J.isCollapsed})||(Vpe(J,ne),k.current=!1)}};Y(),_(F),Z&&(V.current=requestAnimationFrame(()=>{_(),N.current=window.setTimeout(()=>{_(),N.current=void 0},32),V.current=void 0}))}const L=G.useMemo(()=>{const m=`scale(${g||1}) ${p&&"translate("+p[0]+"px,"+p[1]+"px)"||""}`;return{left:`${v-Ei*(g||1)}px`,top:`${I-Ei*(g||1)}px`,zIndex:2,transform:m,transformOrigin:"left top",borderColor:Q==="editing"||Q==="hover"?w:"transparent"}},[g,p,v,I,w,Q]),W=G.useMemo(()=>{let m="";const S="<div></div>";if(d.text){const F=Nn(d.text);for(let Y=0;Y<F.length;Y++){const _=F[Y];if(_==="")m=m+S;else{const re=_.replace(/[<>&]/g,ne=>({"<":"&lt;",">":"&gt;","&":"&amp;"})[ne]);m=m+`<div>${re}</div>`}}}else m=S;return m},[d.fontBgColor,d.text]),H=G.useMemo(()=>{var m,S;if(Q==="hover"){if(g&&r&&ve.isNumber(v)&&ve.isNumber(I)&&d.boxSize&&ve.isNumber((m=d.boxSize)==null?void 0:m[0])&&ve.isNumber((S=d.boxSize)==null?void 0:S[1])){const F={x:v,y:I},Y={left:v,top:I,width:d.boxSize[0]*g,height:d.boxSize[1]*g};return G.createElement(GMe,{position:F,style:Y,textOpt:d,workIds:[e],noLayer:!0,noCopy:!0,noDelete:!0})}return null}return null},[d,r,e,v,I,g,Q]);G.useEffect(()=>{A.current=u===e,u!==e&&(V.current&&(cancelAnimationFrame(V.current),V.current=void 0),N.current&&(window.clearTimeout(N.current),N.current=void 0),k.current=!1)},[u,e]),G.useEffect(()=>{if(u===e&&C.current){const m=window==null?void 0:window.getSelection(),S=Lg(m,C.current);(document.activeElement!==C.current||!S)&&ce(),s(C.current)}},[u,s,e,Z]),G.useEffect(()=>{const m=C.current;if(!m)return;const S=g0(m),F=d.text||"";S!==F&&(u===e&&E.current||(m.innerHTML=W))},[u,W,d.boxSize,d.text,d.workState,e]),G.useEffect(()=>()=>{V.current&&cancelAnimationFrame(V.current),N.current&&window.clearTimeout(N.current)},[]),G.useEffect(()=>{if(C.current){const m=parseInt(getComputedStyle(C.current).paddingRight,10)+parseInt(getComputedStyle(C.current).borderWidth,10);O.current=Number(m)}},[]),G.useEffect(()=>{if(C.current){const m={fontSize:P.fontSize,lineHeight:P.lineHeight,fontStyle:P.fontStyle,fontWeight:P.fontWeight,fontFamily:P.fontFamily};if(!ve.isEqual(U.current,m)){U.current=m;const S=[C.current.offsetWidth,C.current.offsetHeight];a(e,S)}}},[P,e,a,Q,l,u]);const $=G.useCallback(m=>{const S=h==null?void 0:h.parentElement,F=C.current;if(!S||!F||!c)return!1;const{lastLine:Y}=Rg(F);if(!Y||Y instanceof Text)return!1;const _=Y==null?void 0:Y.getBoundingClientRect(),re=S==null?void 0:S.getBoundingClientRect();if(!_||!re)return!1;if(_.right+m>re.right){const{textContent:ne,textNodes:J}=Qpe(Y);if(!J.length)return!1;const se=ne.length,ue=us(J,0);if(!ue)return!1;let oe=0,de=0,me=se;for(;de<me;){const ye=Math.floor((de+me)/2),be=us(J,ye);if(!be)break;const Ce=document.createRange();Ce.setStart(ue.node,ue.offset),Ce.setEnd(be.node,be.offset);const Ie=Ce.getBoundingClientRect(),Pe=re.right-Ie.right;if(Pe<m){if(ye>0){const Re=us(J,ye-1);if(!Re)break;const ke=document.createRange();ke.setStart(ue.node,ue.offset),ke.setEnd(Re.node,Re.offset);const Oe=ke.getBoundingClientRect();if(re.right-Oe.right>=m){oe=ye-1;break}}me=ye}else{const Re=ye+1;if(Re<se){const ke=us(J,Re);if(!ke)break;const Oe=document.createRange();Oe.setStart(ue.node,ue.offset),Oe.setEnd(ke.node,ke.offset);const je=Oe.getBoundingClientRect();if(re.right-je.right<=m&&Pe>m){oe=ye;break}}de=Re}}if(!oe){const ye=us(J,de);if(!ye)return!1;const be=document.createRange();be.setStart(ue.node,ue.offset),be.setEnd(ye.node,ye.offset);const Ce=be.getBoundingClientRect();re.right-Ce.right>m?oe=de:de>0&&(oe=de-1)}if(oe>0){const ye=ne.slice(0,oe),be=ne.slice(oe);Y.textContent=ye;const Ce=document.createElement("div");return be&&(Ce.textContent=be),C.current.appendChild(Ce),$(m),!0}}return!1},[h==null?void 0:h.parentElement,d.fontBgColor,c]);function ee(m){if(m.stopPropagation(),m.nativeEvent.stopImmediatePropagation(),m.key==="Backspace"){const S=window.getSelection(),F=S==null?void 0:S.getRangeAt(0);if(F!=null&&F.collapsed)return m.cancelable&&m.preventDefault(),document.execCommand("delete",!1),!1}return!1}function ie(m,S){const F=window==null?void 0:window.getSelection();if(F!=null&&F.rangeCount&&m&&F&&F.anchorNode){const Y=F.anchorOffset,_=F.anchorNode.textContent||"",re=_.slice(0,Y)||"",ne=_.slice(Y)||"",J=re.concat(m)||"";le(J,ne,S)}}function le(m,S,F){const Y=window==null?void 0:window.getSelection();if(!(Y!=null&&Y.rangeCount)||!Y.anchorNode)return;const _=m.split(/\n/);let re=Y.anchorNode.parentNode;re===F&&(re=Y.anchorNode);const ne=[...F.childNodes],J=[];let se,ue=Y.anchorOffset;for(;ne.length;){const oe=ne.pop();if(oe){if(oe===re){let de=_[0];_.length===1&&(ue=_[0].length,de=_[0].concat(S)),re.nodeName==="#text"?(re.textContent=de,se=re):re.nodeName==="DIV"&&(re.innerText=de,se=re.childNodes[0]);break}J.push(oe),F.removeChild(oe)}}if(_.length>1)for(let oe=1;oe<_.length;oe++){let de=_[oe];const me=document.createElement("div");oe===_.length-1&&(ue=de.length,de=de.concat(S)),me.innerText=de,F.appendChild(me),oe===_.length-1&&(se=me.childNodes[0])}if(J.length){J.reverse();for(const oe of J)F.appendChild(oe)}if(se&&se.nodeName==="#text"){Y.deleteFromDocument();const oe=document.createRange(),de=Math.min(ue,(se==null?void 0:se.length)||0);oe.setStart(se,de),oe.collapse(!0),Y.removeAllRanges(),Y.addRange(oe)}}function pe(m){if(m.cancelable&&m.preventDefault(),m.stopPropagation(),m.nativeEvent.stopImmediatePropagation(),C.current){const S=(m.clipboardData||window.clipboardData).getData("text"),F=window==null?void 0:window.getSelection();if(!(F!=null&&F.rangeCount))return;if(S&&F&&F.anchorNode){const Y=Sl(S,{whiteList:{},stripIgnoreTag:!0,stripIgnoreTagBody:["script"]});ie(Y,C.current),$((g||1)*O.current),n(C.current)}o()}return!1}function Te(m){Rg(m)}const z=G.useCallback(()=>{const m=C.current;o(()=>{if(m){Te(m);let S=!1;if(!E.current&&(S=$((g||1)*O.current),S)){const F=window.getSelection();if(!(F!=null&&F.rangeCount))return!1;const Y=document.createRange(),_=C.current.lastChild;Y.selectNodeContents(_),Y.collapse(!1),F.removeAllRanges(),F.addRange(Y)}n(m)}})},[n,$,o,g]);function B(){E.current=!0,o()}function X(){E.current=!1,z()}function ae(){z(),o()}const q=G.useCallback(()=>{if(Q==="active"&&C.current&&C.current.parentElement){const m=C.current.parentElement;m.style.borderColor=w}},[Q,w]),te=G.useCallback(()=>{if(Q==="active"&&C.current&&C.current.parentElement){const m=C.current.parentElement;m.style.borderColor="transparent"}},[Q]);return G.createElement(G.Fragment,null,H,G.createElement("div",{className:`editor-box ${Q}`,style:L,onPointerUp:()=>{var m;if(Q==="editing"){o(()=>{var S;(S=document.activeElement)==null||S.blur(),h==null||h.control.textEditorManager.checkEmptyTextBlur()});return}if(Q==="active"&&h){if((m=h.control.collector)!=null&&m.hasIncludeSelector(e)){o(()=>{var S;(S=document.activeElement)==null||S.blur(),h==null||h.control.textEditorManager.checkEmptyTextBlur()});return}if(h&&u!==e){h.control.textEditorManager.checkEmptyTextBlur(),h.control.textEditorManager.active(e,h.worker.now);return}}},onMouseOver:q,onMouseLeave:te},G.createElement("div",{id:e,suppressContentEditableWarning:!0,contentEditable:!0,className:"editor",ref:C,style:P,onKeyDown:ee,onPaste:pe,onTouchEnd:ce,onInput:z,onCompositionStart:B,onCompositionUpdate:ae,onCompositionEnd:X,dangerouslySetInnerHTML:{__html:W}})))},QMe=i=>{const t=G.useRef(null),{mananger:e}=G.useContext(ct),r=G.useRef(),n=G.useRef(),s=G.useRef();G.useEffect(()=>()=>{r.current&&cancelAnimationFrame(r.current),n.current&&cancelAnimationFrame(n.current),s.current&&cancelAnimationFrame(s.current)},[]);const o=G.useCallback(c=>{var g,p;const{activeTextId:l,update:u,syncData:h}=c;if(!e)return;const d=l&&ve.cloneDeep(((g=e.control.textEditorManager)==null?void 0:g.get(l))||((p=i.editors)==null?void 0:p.get(l)));d&&d.opt&&(d.opt={...d.opt,...u},h&&(d.canSync=Object.keys(h).includes("canSync")&&h.canSync||d.canSync,d.canWorker=Object.keys(h).includes("canWorker")&&h.canWorker||d.canWorker),e.control.textEditorManager.updateForViewEdited(l,d))},[e,i.editors]),a=G.useMemo(()=>{var p;const c=v=>{if(!e)return;const I=v.id,D=e.control.textEditorManager.get(I),x=ge.Doing,j=[v.offsetWidth,v.offsetHeight];(!D||D&&(!ve.isEqual(D.opt.boxSize,j)||!ve.isEqual(D.opt.workState,x)))&&o({activeTextId:I,update:{boxSize:j,workState:x},syncData:{canSync:!0,canWorker:!0}})},l=v=>{var f,M;if(!e)return;const I=f0(v),D=v.id,x=e.control.textEditorManager.get(D),j=g0(v),w=ge.Doing,y=[v.offsetWidth,v.offsetHeight];if(!x||x&&(x.opt.text!==j||!ve.isEqual(x.opt.boxSize,y)||!ve.isEqual(x.opt.workState,w))){const T=D&&ve.cloneDeep(((f=e.control.textEditorManager)==null?void 0:f.get(D))||((M=i.editors)==null?void 0:M.get(D)));T&&T.opt&&(T.opt={...T.opt,text:j,boxSize:y,workState:w},T.canSync=!0,T.canWorker=!0,e.control.textEditorManager.updateForViewEdited(D,T)),e.control.textEditorManager.publicMsgEmitter.emit("textChange",D,v,I,T)}},u=(v,I)=>{if(!e)return;const D=v,x=e.control.textEditorManager.get(D);if(x&&!(!I[0]||!I[1])&&!ve.isEqual(x.opt.boxSize,I)){const j=ve.cloneDeep(x);j.opt={...j.opt,boxSize:I},j.canSync=!1,j.canWorker=!1,e.control.textEditorManager.updateForViewEdited(D,j)}},h=()=>{t.current&&t.current.scrollTo({left:0,top:0,behavior:"instant"})},d=()=>{n.current&&(cancelAnimationFrame(n.current),n.current=void 0),s.current&&(cancelAnimationFrame(s.current),s.current=void 0),n.current=requestAnimationFrame(()=>{h(),n.current=void 0,s.current=requestAnimationFrame(()=>{h(),s.current=void 0})})},g=v=>{r.current&&cancelAnimationFrame(r.current),r.current=requestAnimationFrame(()=>{t!=null&&t.current&&(h(),v&&v(),d(),r.current=void 0)})};if((p=i.editors)!=null&&p.size){const v=[];return i.editors.forEach((I,D)=>{v.push(G.createElement(HMe,{key:D,workId:D,data:I,showFloatBtns:i.showFloatBtns||!1,handleFocus:c,handleKeyUp:l,updateSize:u,runAnimation:g,rightBoundBreak:i.rightBoundBreak||!1}))}),v}return null},[i.editors,i.showFloatBtns,i.rightBoundBreak,e,o]);return G.createElement("div",{className:`${i.className}`,ref:t},a)},sr=(i,t,e)=>({...i,...e==null?void 0:e[t]}),ZMe=()=>{const{floatBarData:i,overwriteSelectorStyles:t}=G.useContext(ct),e={borderColor:i==null?void 0:i.selectorColor,...t.highlightBox},r={backgroundColor:i==null?void 0:i.selectorColor,...t.highlightBoxPoint};return G.createElement("div",{className:"appliance-plugin-highlight-box",style:e},G.createElement("div",{className:"point LT nwse-resize",style:sr(r,"LT",t.highlightBoxPoints)}),G.createElement("div",{className:"point LC ew-resize",style:sr(r,"LC",t.highlightBoxPoints)}),G.createElement("div",{className:"point LB nesw-resize",style:sr(r,"LB",t.highlightBoxPoints)}),G.createElement("div",{className:"point TC ns-resize",style:sr(r,"TC",t.highlightBoxPoints)}),G.createElement("div",{className:"point RT nesw-resize",style:sr(r,"RT",t.highlightBoxPoints)}),G.createElement("div",{className:"point RC ew-resize",style:sr(r,"RC",t.highlightBoxPoints)}),G.createElement("div",{className:"point RB nwse-resize",style:sr(r,"RB",t.highlightBoxPoints)}),G.createElement("div",{className:"point BC ns-resize",style:sr(r,"BC",t.highlightBoxPoints)}))},KMe=()=>{const{floatBarData:i,mananger:t,overwriteSelectorStyles:e}=G.useContext(ct),[r,n]=G.useState(),[s,o]=G.useState();G.useEffect(()=>{const l=[];if(t&&ve.isNumber(i==null?void 0:i.x)&&ve.isNumber(i==null?void 0:i.y)&&(i!=null&&i.points)){const u=t.viewId;if(t.control.viewContainerManager.getView(u))for(const d of i.points){const g=t.control.viewContainerManager.transformToOriginPoint(d,u);l.push(g)}l[0]&&n({x:l[0][0]-((i==null?void 0:i.x)||0),y:l[0][1]-((i==null?void 0:i.y)||0)}),l[1]&&o({x:l[1][0]-((i==null?void 0:i.x)||0),y:l[1][1]-((i==null?void 0:i.y)||0)})}},[t,i==null?void 0:i.points,i==null?void 0:i.x,i==null?void 0:i.y]);const a=G.useMemo(()=>r?G.createElement("div",{className:"point point-dot",style:{borderColor:i==null?void 0:i.selectorColor,...e.highlightBoxPoint,...e.highlightBoxPointDot,left:r.x,top:r.y}}):null,[i==null?void 0:i.selectorColor,r]),c=G.useMemo(()=>s?G.createElement("div",{className:"point point-dot",style:{borderColor:i==null?void 0:i.selectorColor,...e.highlightBoxPoint,...e.highlightBoxPointDot,left:s.x,top:s.y}}):null,[s,i==null?void 0:i.selectorColor]);return G.createElement("div",{className:"appliance-plugin-highlight-box",style:{borderColor:i==null?void 0:i.selectorColor,...e.highlightBox}},a,c)},qMe=()=>{const{floatBarData:i,overwriteSelectorStyles:t}=G.useContext(ct),e={borderColor:i==null?void 0:i.selectorColor,...t.highlightBox},r={backgroundColor:i==null?void 0:i.selectorColor,...t.highlightBoxPoint};return G.createElement("div",{className:"appliance-plugin-highlight-box",style:e},G.createElement("div",{className:"point LT nwse-resize",style:sr(r,"LT",t.highlightBoxPoints)}),G.createElement("div",{className:"point LB nesw-resize",style:sr(r,"LB",t.highlightBoxPoints)}),G.createElement("div",{className:"point RT nesw-resize",style:sr(r,"RT",t.highlightBoxPoints)}),G.createElement("div",{className:"point RB nwse-resize",style:sr(r,"RB",t.highlightBoxPoints)}))},XMe=()=>{const{floatBarData:i,overwriteSelectorStyles:t}=G.useContext(ct);return G.createElement("div",{className:"appliance-plugin-highlight-box",style:{borderColor:i==null?void 0:i.selectorColor,...t.highlightBox}},G.createElement("img",{className:"lock",alt:"lock",src:"https://sdk.netless.link/resource/icons/lock.svg",style:t.highlightBoxLock}))},JMe=i=>{const{className:t}=i,{floatBarData:e,angle:r,setAngle:n,setOperationType:s,mananger:o}=G.useContext(ct),[a,c]=G.useState(ge.Pending),[l,u]=G.useState(),[h,d]=G.useState(!1),[g,p]=G.useState(new Ae),[v,I]=G.useState(new Ae),[D,x]=G.useState(!1),j=G.useRef(0),w=G.useRef(!1),y=G.useRef(null),f=(E,O)=>{n(E),s(O===ge.Done?Se.None:Se.RotateNode),c(O),O===ge.Done?(d(!1),o==null||o.focusElement()):d(!0),We.emitMethod(Fe.MainEngine,Se.RotateNode,{workIds:[De],angle:O===ge.Start?0:E,workState:O,viewId:o==null?void 0:o.viewId})},M=E=>{if(!E){w.current=!0,j.current&&clearTimeout(j.current),j.current=0,x(!0),d(!1),s(Se.None),c(ge.Pending);return}x(!1)},T=(E,O)=>{j.current&&(clearTimeout(j.current),j.current=0),c(ge.Done),d(!1);const V=Math.round(Ae.GetAngleByPoints(g,v,new Ae(O.x,O.y)))||0;f(V,ge.Done)};G.useEffect(()=>{const E=()=>{w.current&&(j.current&&clearTimeout(j.current),j.current=0,c(ge.Pending),d(!1),s(Se.None))};return We.activeListener(M),document.addEventListener("pointercancel",E),()=>{We.unmountActiveListener(M),document.removeEventListener("pointercancel",E)}},[]),G.useEffect(()=>{if(window.__selectorE2E__)return window.__selectorRotateE2E__={start:(E=g.x,O=g.y)=>{if(o!=null&&o.control.worker.isBusy){x(!0),c(ge.Pending);return}const V=Math.round(Ae.GetAngleByPoints(g,v,new Ae(E,O)))||0;f(V,ge.Start)},doing:(E,O)=>{if(w.current)return;if(o!=null&&o.control.worker.isBusy){x(!0);return}const V=Math.round(Ae.GetAngleByPoints(g,v,new Ae(E,O)))||0;u({x:E,y:O}),f(V,ge.Doing)},done:(E,O)=>{const V=Math.round(Ae.GetAngleByPoints(g,v,new Ae(E,O)))||0;u({x:E,y:O}),f(V,ge.Done)}},()=>{window.__selectorRotateE2E__&&delete window.__selectorRotateE2E__}},[v,o,g]),G.useEffect(()=>{if(e&&(a===ge.Pending||a===ge.Done)){const E={x:(e==null?void 0:e.x)-20,y:(e==null?void 0:e.y)+(e==null?void 0:e.h)},O={x:(e==null?void 0:e.x)+(e==null?void 0:e.w)/2,y:(e==null?void 0:e.y)+(e==null?void 0:e.h)/2};I(new Ae(O.x,O.y)),p(new Ae(E.x,E.y)),u({x:E.x,y:E.y})}},[e,a]);const b=(E,O)=>{if(w.current=!1,o!=null&&o.control.worker.isBusy){x(!0),c(ge.Pending);return}j.current&&(clearTimeout(j.current),j.current=0),c(ge.Start),d(!0);const V=Math.round(Ae.GetAngleByPoints(g,v,new Ae(O.x,O.y)))||0;f(V,ge.Start)},C=(E,O)=>{if(w.current){j.current&&clearTimeout(j.current),j.current=0,d(!1),s(Se.None);return}if(o!=null&&o.control.worker.isBusy){x(!0),T(E,O);return}T(E,O)},P=(E,O)=>{if(!w.current){if(o!=null&&o.control.worker.isBusy){x(!0),T(E,O);return}j.current||(u({x:O.x,y:O.y}),d(!0),j.current=setTimeout(()=>{if(j.current=0,w.current)return;const V=Math.round(Ae.GetAngleByPoints(g,v,new Ae(O.x,O.y)))||0;f(V,ge.Doing)},60))}};return G.createElement(Bi,{disabled:D,position:l,onStart:b,onDrag:P,onStop:C},G.createElement("div",{className:`${t}`,style:e?{left:0,top:0,touchAction:"none"}:void 0},!h&&G.createElement("div",{className:"appliance-plugin-rotate-btn",style:{backgroundColor:e==null?void 0:e.selectorColor}},G.createElement("img",{alt:"icon",src:Et("rotation-button")})),G.createElement("div",{ref:y,className:`appliance-plugin-rotate-mouse-pointer ${h?"active":""}`},G.createElement("img",{alt:"icon",src:Et("rotation")}),G.createElement("div",{className:"angle-icon"},r,"°"))))};function _Me(i){const t=i==null?void 0:i.viewId;if(!t)return;const e=i.control.viewContainerManager.getView(t),r=e==null?void 0:e.focusScenePath,n=i.control.viewContainerManager.getUndoTickerId(t);!n||!r||(i.control.internalMsgEmitter.emit("cancelUndoTicker",n,t,r),i.control.worker.abled())}function e1e(i,t){const e=i.control.worker.now;return i.control.textEditorManager.active(t,e),e}const t1e="data-text-work-id";function r1e(i){var t,e;if(i instanceof HTMLElement)return((e=(t=i.closest(`[${t1e}]`))==null?void 0:t.dataset)==null?void 0:e.textWorkId)||void 0}const n1e=G.memo(i=>{const{editors:t,canSelectorSwitch:e}=i,{floatBarData:r,setOperationType:n,mananger:s,isNoPointerEvents:o}=G.useContext(ct),[a,c]=G.useState(),[l,u]=G.useState(!1),h=G.useRef(0),d=G.useRef(),g=G.useRef(ge.Pending),p=G.useRef(!1),v=G.useMemo(()=>!!((r==null?void 0:r.scaleType)===Ve.none&&(r!=null&&r.canLock)),[r]),I=G.useMemo(()=>r&&r.w&&r.h?{position:"absolute",left:0,top:0,width:r.w,height:r.h,zIndex:2,pointerEvents:v||o?"none":"auto",touchAction:"none"}:{display:"none",pointerEvents:"none"},[r,v,o]),D=f=>{if(!f||r!=null&&r.isLocked){p.current=!0,h.current&&clearTimeout(h.current),h.current=0,u(!0),g.current=ge.Pending,n(Se.None);return}u(!1)},x=(f,M)=>{h.current&&(clearTimeout(h.current),h.current=0);const T={x:M.x,y:M.y};n(Se.None),g.current=ge.Done,c(T),We.emitMethod(Fe.MainEngine,Se.TranslateNode,{workIds:[De],position:T,workState:ge.Done,viewId:s==null?void 0:s.viewId})};G.useEffect(()=>{const f=()=>{p.current&&(h.current&&clearTimeout(h.current),h.current=0,d.current=void 0,g.current=ge.Pending,n(Se.None))};return We.activeListener(D),document.addEventListener("pointercancel",f),()=>{We.unmountActiveListener(D),document.removeEventListener("pointercancel",f)}},[]),G.useEffect(()=>{if(r&&(r!=null&&r.isLocked)||s!=null&&s.control.worker.isBusy){u(!0);return}u(!1)},[r,s==null?void 0:s.control.worker.isBusy]),G.useEffect(()=>{(g.current===ge.Pending||g.current===ge.Done)&&ve.isNumber(r==null?void 0:r.x)&&ve.isNumber(r==null?void 0:r.y)&&c({x:r==null?void 0:r.x,y:r==null?void 0:r.y})},[r==null?void 0:r.x,r==null?void 0:r.y]);const j=f=>{p.current=!1;const M=f&&"target"in f?f.target:null,T=e?r1e(M):void 0;if(s!=null&&s.control.worker.isBusy){u(!0);return}h.current&&(clearTimeout(h.current),h.current=0),d.current=T,ve.isNumber(r==null?void 0:r.x)&&ve.isNumber(r==null?void 0:r.y)&&(n(Se.TranslateNode),g.current=ge.Start,We.emitMethod(Fe.MainEngine,Se.TranslateNode,{workIds:[De],position:{x:r==null?void 0:r.x,y:r==null?void 0:r.y},workState:ge.Start,viewId:s==null?void 0:s.viewId}))},w=(f,M)=>{var P,E;if(p.current){h.current&&clearTimeout(h.current),h.current=0,d.current=void 0,n(Se.None);return}s!=null&&s.control.worker.isBusy&&u(!0);const T=g.current,b=d.current;if(!!b&&T===ge.Start&&s&&e){_Me(s),e1e(s,b),d.current=void 0,g.current=ge.Pending,n(Se.None);const O=(P=s.control.viewContainerManager.getView(s.viewId))==null?void 0:P.focusScenePath;O&&s.control.worker.blurSelector(s.viewId,O);return}if(x(f,M),d.current&&(d.current=void 0),T===ge.Start&&(t!=null&&t.size)&&b){const O=(E=s==null?void 0:s.control.viewContainerManager.getView(s.viewId))==null?void 0:E.focusScenePath;O&&(s==null||s.control.worker.blurSelector(s.viewId,O))}s==null||s.focusElement()},y=(f,M)=>{if(p.current)return;if(s!=null&&s.control.worker.isBusy){u(!0),x(f,M);return}if(h.current)return;const T={x:M.x,y:M.y};c(T),h.current=setTimeout(()=>{h.current=0,!p.current&&(T.x!==(a==null?void 0:a.x)||T.y!==(a==null?void 0:a.y))&&(d.current&&(d.current=void 0),g.current=ge.Doing,We.emitMethod(Fe.MainEngine,Se.TranslateNode,{workIds:[De],position:T,workState:ge.Doing,viewId:s==null?void 0:s.viewId}))},60)};return G.createElement(Bi,{disabled:l,position:a,onStart:j,onDrag:y,onStop:w},G.createElement("div",{style:I},G.createElement(i1e,{editors:t,selectIds:(r==null?void 0:r.selectIds)||[]})))},(i,t)=>!!ve.isEqual(i,t)),i1e=G.memo(i=>{const{editors:t,selectIds:e}=i;return t?G.createElement(YMe,{editors:t,selectIds:e||[]}):null},(i,t)=>!(!ve.isEqual(i.editors,t.editors)||!ve.isEqual(i.selectIds,t.selectIds))),s1e=i=>{const{className:t}=i,[e,r]=G.useState({x:0,y:0,h:0,w:0}),[n,s]=G.useState(),[o,a]=G.useState(),[c,l]=G.useState(),{floatBarData:u,mananger:h,isNoPointerEvents:d,setOperationType:g}=G.useContext(ct),[p,v]=G.useState(),[I,D]=G.useState(!1),x=G.useRef(0),j=G.useRef(!1);G.useEffect(()=>{const E=()=>{j.current&&(x.current&&clearTimeout(x.current),x.current=0,g(Se.None))};if(u&&h){const O={x:u.x,y:u.y,w:u.w,h:u.h};r(O)}return We.activeListener(y),document.addEventListener("pointercancel",E),()=>{We.unmountActiveListener(y),document.removeEventListener("pointercancel",E)}},[]),G.useEffect(()=>{if(h!=null&&h.control.worker.isBusy){D(!0);return}D(!1)},[h==null?void 0:h.control.worker.isBusy]);const w=()=>{if(x.current&&(clearTimeout(x.current),x.current=0),p){const{scale:E,translate:O}=p;g(Se.None),We.emitMethod(Fe.MainEngine,Se.ScaleNode,{workIds:[De],scale:E,dir:c,translate:O,originPoint:n,scenePoint:o,workState:ge.Done,viewId:h==null?void 0:h.viewId})}h==null||h.focusElement()},y=E=>{if(!E){j.current=!0,x.current&&clearTimeout(x.current),x.current=0,D(!0);return}D(!1)},f=E=>[[E.x,E.y],[E.x+E.w,E.y],[E.x+E.w,E.y+E.h],[E.x,E.y+E.h]],M=(E,O)=>{switch(O){case"top":case"topLeft":case"left":return E[2];case"topRight":return E[3];case"right":case"bottomRight":case"bottom":return E[0];case"bottomLeft":return E[1]}},T=(E,O,V,N)=>{let A=!1,k=!1;const U={x:e.x,y:e.y,w:e.w,h:e.h},Z=[1,1],Q=[0,0];switch(E){case"top":{const H=O.height+e.h;H<0?(k=!0,U.y=e.y+e.h,U.h=Math.abs(H)):(U.y=e.y-O.height,U.h=e.h+O.height);break}case"topLeft":{const H=O.width+e.w;H<0?(A=!0,U.x=e.x+e.w,U.w=Math.abs(H)):(U.x=e.x-O.width,U.w=e.w+O.width);const $=O.height+e.h;$<0?(k=!0,U.y=e.y+e.h,U.h=Math.abs($)):(U.y=e.y-O.height,U.h=e.h+O.height);break}case"topRight":{const H=O.width+e.w;H<0?(A=!0,U.x=e.x+H,U.w=Math.abs(H)):U.w=e.w+O.width;const $=O.height+e.h;$<0?(k=!0,U.y=e.y+e.h,U.h=Math.abs($)):(U.y=e.y-O.height,U.h=e.h+O.height);break}case"bottom":{const H=O.height+e.h;H<0?(k=!0,U.y=e.y+H,U.h=Math.abs(H)):U.h=e.h+O.height;break}case"bottomLeft":{const H=O.width+e.w;H<0?(A=!0,U.x=e.x+e.w,U.w=Math.abs(H)):(U.x=e.x-O.width,U.w=e.w+O.width);const $=O.height+e.h;$<0?(k=!0,U.y=e.y+$,U.h=Math.abs($)):U.h=e.h+O.height;break}case"left":{const H=O.width+e.w;H<0?(A=!0,U.x=e.x+e.w,U.w=Math.abs(H)):(U.x=e.x-O.width,U.w=e.w+O.width);break}case"bottomRight":{const H=O.width+e.w;H<0?(A=!0,U.x=e.x+H,U.w=Math.abs(H)):U.w=e.w+O.width;const $=O.height+e.h;$<0?(k=!0,U.y=e.y+$,U.h=Math.abs($)):U.h=e.h+O.height;break}case"right":{const H=O.width+e.w;H<0?(A=!0,U.x=e.x+H,U.w=Math.abs(H)):U.w=e.w+O.width;break}}Z[0]=U.w/e.w,Z[1]=U.h/e.h;const L=f(U).map(H=>V.control.viewContainerManager.transformToScenePoint(H,V.viewId)),W=M(L,E);return k&&(Q[1]=W[1]-N[1]),A&&(Q[0]=W[0]-N[0]),{scale:Z,translate:Q}},b=(E,O)=>{if(j.current=!1,x.current&&(clearTimeout(x.current),x.current=0),h!=null&&h.control.worker.isBusy){D(!0);return}if(u!=null&&u.w&&(u!=null&&u.h)&&h){const V={x:u.x,y:u.y,w:u.w,h:u.h},N=f(V),A=N.map(Z=>h.control.viewContainerManager.transformToScenePoint(Z,h.viewId)),k=M(N,O),U=M(A,O);r(V),s(k),a(U),l(O),g(Se.ScaleNode),We.emitMethod(Fe.MainEngine,Se.ScaleNode,{workIds:[De],originPoint:k,scenePoint:U,workState:ge.Start,viewId:h.viewId})}},C=(E,O,V,N)=>{if(!j.current&&!(!h||!n||!o)){if(h!=null&&h.control.worker.isBusy){D(!0),w();return}x.current||(x.current=setTimeout(()=>{if(x.current=0,j.current)return;const{scale:A,translate:k}=T(O,N,h,o);(!ve.isEqual(A,p==null?void 0:p.scale)||!ve.isEqual(k,p==null?void 0:p.translate))&&(v({scale:A,translate:k}),g(Se.ScaleNode),We.emitMethod(Fe.MainEngine,Se.ScaleNode,{workIds:[De],scale:A,dir:O,translate:k,originPoint:n,scenePoint:o,workState:ge.Doing,viewId:h.viewId}))},60))}},P=()=>{if(j.current){x.current&&clearTimeout(x.current),x.current=0,g(Se.None);return}h!=null&&h.control.worker.isBusy&&D(!0),w()};return G.createElement(J0.Resizable,{className:`${t}`,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:I?!1:{top:(u==null?void 0:u.scaleType)===Ve.all&&!0||!1,right:(u==null?void 0:u.scaleType)===Ve.all&&!0||!1,bottom:(u==null?void 0:u.scaleType)===Ve.all&&!0||!1,left:(u==null?void 0:u.scaleType)===Ve.all&&!0||!1,topRight:!0,bottomRight:!0,bottomLeft:!0,topLeft:!0},lockAspectRatio:(u==null?void 0:u.scaleType)===Ve.proportional,onResizeStart:b,onResize:C,onResizeStop:P})},_g=i=>{const{id:t,pos:e,pointMap:r,type:n}=i,{setOperationType:s,mananger:o,floatBarData:a}=G.useContext(ct),[c,l]=G.useState({x:0,y:0}),[u,h]=G.useState(ge.Pending),[d,g]=G.useState(!1),p=G.useRef(0),v=G.useRef(!1),I=G.useMemo(()=>a?{left:0,top:0}:{},[a]),D=f=>{if(!f||a!=null&&a.isLocked){v.current=!0,p.current&&clearTimeout(p.current),p.current=0,g(!0),h(ge.Pending),s(Se.None);return}g(!1)};G.useEffect(()=>{const f=()=>{v.current&&(p.current&&clearTimeout(p.current),p.current=0,h(ge.Pending),s(Se.None))};return We.activeListener(D),document.addEventListener("pointercancel",f),()=>{We.unmountActiveListener(D),document.removeEventListener("pointercancel",f)}},[]),G.useEffect(()=>{ve.isNumber(e.x)&&ve.isNumber(e.y)&&(u===ge.Pending||u===ge.Done)&&l({x:e.x,y:e.y})},[e,u]),G.useEffect(()=>{if(a&&(a!=null&&a.isLocked)||o!=null&&o.control.worker.isBusy){g(!0);return}g(!1)},[a,o==null?void 0:o.control.worker.isBusy]);const x=(f,M)=>{p.current&&(clearTimeout(p.current),p.current=0),s(Se.None),h(ge.Done);const T={x:M.x,y:M.y};if(l(T),o!=null&&o.control.viewContainerManager){const b=o.control.viewContainerManager.transformToScenePoint([T.x,T.y],o.viewId),C=r.get(t);C&&n==="start"?C[0]=b:C&&n==="end"&&(C[1]=b),We.emitMethod(Fe.MainEngine,Se.SetPoint,{workId:De,pointMap:r,workState:ge.Done,viewId:o==null?void 0:o.viewId})}o==null||o.focusElement()},j=()=>{if(v.current=!1,p.current&&(clearTimeout(p.current),p.current=0),o!=null&&o.control.worker.isBusy){g(!0);return}ve.isNumber(e.x)&&ve.isNumber(e.y)&&(s(Se.SetPoint),h(ge.Start),We.emitMethod(Fe.MainEngine,Se.SetPoint,{workId:De,pointMap:r,workState:ge.Start,viewId:o==null?void 0:o.viewId}))},w=(f,M)=>{if(v.current)return;if(o!=null&&o.control.worker.isBusy){g(!0),x(f,M);return}if(p.current)return;const T={x:M.x,y:M.y};l(T),p.current=setTimeout(()=>{if(p.current=0,!v.current&&o!=null&&o.control.viewContainerManager){const b=o.control.viewContainerManager.transformToScenePoint([T.x,T.y],o.viewId),C=r.get(t);C&&n==="start"?C[0]=b:C&&n==="end"&&(C[1]=b),h(ge.Doing),We.emitMethod(Fe.MainEngine,Se.SetPoint,{workId:De,pointMap:r,workState:ge.Doing,viewId:o==null?void 0:o.viewId})}},60)},y=(f,M)=>{if(v.current){p.current&&clearTimeout(p.current),p.current=0,s(Se.None);return}o!=null&&o.control.worker.isBusy&&g(!0),x(f,M)};return G.createElement(Bi,{disabled:d,position:c,onStart:j,onDrag:w,onStop:y},G.createElement("div",{className:"appliance-plugin-point-draggable-btn",style:I}))},o1e=i=>{const{className:t}=i,{floatBarData:e,mananger:r}=G.useContext(ct),[n,s]=G.useState(),[o,a]=G.useState(),[c,l]=G.useState(new Map);G.useEffect(()=>{const d=[];if(r&&(e!=null&&e.points)){const g=r.viewId;if(r.control.viewContainerManager.getView(g))for(const v of e.points){const I=r.control.viewContainerManager.transformToOriginPoint(v,g);d.push(I)}e!=null&&e.selectIds&&e.selectIds.length===1&&(c.set(e.selectIds[0],e.points),l(c))}d[0]&&s({x:d[0][0],y:d[0][1]}),d[1]&&a({x:d[1][0],y:d[1][1]})},[r,e==null?void 0:e.points,e==null?void 0:e.selectIds,c]);const u=G.useMemo(()=>n&&(e!=null&&e.selectIds)?G.createElement(_g,{pos:n,type:"start",id:e.selectIds[0],pointMap:c}):null,[n,e==null?void 0:e.selectIds,c]),h=G.useMemo(()=>o&&(e!=null&&e.selectIds)?G.createElement(_g,{pos:o,type:"end",id:e.selectIds[0],pointMap:c}):null,[o,e==null?void 0:e.selectIds,c]);return G.createElement("div",{className:`${t}`},u,h)},a1e=G.forwardRef((i,t)=>{const{floatBarData:e,operationType:r}=G.useContext(ct),n=G.useMemo(()=>(e==null?void 0:e.scaleType)!==Ve.all||r===Se.RotateNode?null:G.createElement(ZMe,null),[e,r]),s=G.useMemo(()=>(e==null?void 0:e.scaleType)!==Ve.both||r===Se.RotateNode?null:G.createElement(KMe,null),[e,r]),o=G.useMemo(()=>(e==null?void 0:e.scaleType)!==Ve.proportional||r===Se.RotateNode?null:G.createElement(qMe,null),[e,r]),a=G.useMemo(()=>(e==null?void 0:e.scaleType)===Ve.none&&(e!=null&&e.canLock)?G.createElement(XMe,null):null,[e]);return G.createElement("div",{ref:t,style:e?{transform:`translate(${e.x}px,${e.y}px)`,width:e.w,height:e.h,pointerEvents:"none"}:void 0},a,n,s,o,i.children)}),c1e=G.memo(i=>{const{isHide:t,operationType:e,floatBarData:r}=i;return t&&e===Se.None&&ve.isNumber(r==null?void 0:r.x)&&ve.isNumber(r==null?void 0:r.y)&&ve.isNumber(r==null?void 0:r.w)&&ve.isNumber(r==null?void 0:r.h)?G.createElement("div",{className:gt.FloatBarBtn,style:{left:r==null?void 0:r.x,top:r==null?void 0:r.y,width:r.w,height:r.h}},G.createElement(W0,{position:{x:r.x,y:r.y},textOpt:r==null?void 0:r.textOpt,noLayer:r==null?void 0:r.isLocked})):null},(i,t)=>!!ve.isEqual(i,t)),l1e=G.forwardRef((i,t)=>{const{floatBarData:e,operationType:r,mananger:n}=G.useContext(ct),{editors:s,isHide:o,canSelectorSwitch:a}=i,c=G.useRef(null);G.useEffect(()=>{const d=c.current;if(!d)return;const g=p=>{p.stopPropagation(),p.stopImmediatePropagation(),n==null||n.control.worker.blurCursor(n.viewId)};return d.addEventListener("pointerdown",g,!1),()=>{d.removeEventListener("pointerdown",g,!1)}},[n]);const l=G.useMemo(()=>{var d;return e!=null&&e.canRotate&&((d=e==null?void 0:e.selectIds)==null?void 0:d.length)===1&&(r===Se.None||r===Se.RotateNode)?G.createElement(JMe,{className:gt.RotateBtn}):null},[e,r]),u=G.useMemo(()=>((e==null?void 0:e.scaleType)===Ve.all||(e==null?void 0:e.scaleType)===Ve.proportional)&&(r===Se.None||r===Se.ScaleNode)&&ve.isNumber(e==null?void 0:e.x)&&ve.isNumber(e==null?void 0:e.y)?G.createElement(s1e,{className:gt.ResizeBtn}):null,[e==null?void 0:e.scaleType,r,e==null?void 0:e.x,e==null?void 0:e.y]),h=G.useMemo(()=>(e==null?void 0:e.scaleType)===Ve.both&&(r===Se.None||r===Se.SetPoint)?G.createElement(o1e,{className:gt.ResizeTowBox}):null,[e==null?void 0:e.scaleType,r]);return G.createElement("div",{ref:c,className:gt.FloatBar,onPointerOver:d=>(_s(d),n==null||n.control.worker.blurCursor(n.viewId),!1)},G.createElement(a1e,{ref:t}),G.createElement(n1e,{editors:s,canSelectorSwitch:a}),l,u,h,G.createElement(c1e,{isHide:o,operationType:r,floatBarData:e}))}),u1e=G.memo(l1e,(i,t)=>!!ve.isEqual(i,t)),h1e=i=>{var l,u;const{tool:t,visual:e,imageKey:r}=i,n=Xo[t],[s,o]=G.useState(e.images);G.useEffect(()=>o(e.images),[t,r,e.images]);const a=Vh(s),c=a?`${s.standardResolution} 1x, ${a} 2x`:void 0;return G.createElement("img",{className:"appliance-plugin-cursor-image","data-cursor-image-key":r,src:s.standardResolution,srcSet:c,width:(l=e.size)==null?void 0:l.width,height:(u=e.size)==null?void 0:u.height,alt:`${t}Cursor`,onError:()=>{s.standardResolution!==n.images.standardResolution&&o(n.images)}})};class d1e extends G.Component{constructor(){super(...arguments);R(this,"getCursorName",e=>{var r,n,s;return((r=e.payload)==null?void 0:r.nickName)||((n=e.payload)==null?void 0:n.cursorName)||((s=e.payload)==null?void 0:s.uid)});R(this,"detectAvatar",e=>{var r;return!!((r=e.payload)!=null&&r.avatar)});R(this,"getCursorBackgroundColor",e=>{var r;if((r=e.payload)!=null&&r.cursorBackgroundColor)return e.payload.cursorBackgroundColor;if(this.getCursorName(e))return`rgb(${e.memberState.strokeColor[0]}, ${e.memberState.strokeColor[1]}, ${e.memberState.strokeColor[2]})`});R(this,"renderAvatar",(e,r)=>{var s;if(!this.detectAvatar(e))return null;const n=`rgb(${e.memberState.strokeColor[0]}, ${e.memberState.strokeColor[1]}, ${e.memberState.strokeColor[2]})`;return G.createElement("img",{className:"appliance-plugin-cursor-avatar",style:{width:r?19:28,height:r?19:28,position:r?"initial":"absolute",borderColor:r?"white":n,marginRight:r?4:0},src:(s=e.payload)==null?void 0:s.avatar,alt:"avatar"})});R(this,"renderTag",e=>{var r;return(r=e.payload)!=null&&r.cursorTagName?G.createElement("span",{className:"appliance-plugin-cursor-tag",style:{backgroundColor:e.payload.cursorTagBackgroundColor||this.getCursorBackgroundColor(e)}},e.payload.cursorTagName):null})}render(){var p,v,I,D,x;const{roomMember:e,cursorTool:r,resolver:n,labelOptions:s}=this.props;if(!r)return null;const o=n.getSynced(r),a=o.images.key||"external",c=this.getCursorName(e),l=n.getSyncedEnableShowName(r),u=l&&!!c,h=l&&this.detectAvatar(e),d=l&&!!((p=e.payload)!=null&&p.cursorTagName),g=u||h||d;return G.createElement("div",{className:"appliance-plugin-cursor-box","data-appliance":r},G.createElement("div",{className:`appliance-plugin-cursor-visual${o.size?" appliance-plugin-cursor-visual-sized":""}`,style:{width:(v=o.size)==null?void 0:v.width,height:(I=o.size)==null?void 0:I.height,transform:`translate(${o.offset.x}px, calc(-100% + ${o.offset.y}px))`}},g&&G.createElement("div",{className:`appliance-plugin-cursor-label appliance-plugin-cursor-label-${s.placement}`,style:{gap:s.gap,"--cursor-label-gap":`${s.gap}px`}},G.createElement("div",{style:{opacity:g?1:0,backgroundColor:this.getCursorBackgroundColor(e),color:((D=e.payload)==null?void 0:D.cursorTextColor)||"#FFFFFF"},className:(x=e.payload)!=null&&x.theme?"appliance-plugin-cursor-inner-mellow":"appliance-plugin-cursor-inner"},h&&this.renderAvatar(e,u||d),u&&G.createElement("span",{className:"appliance-plugin-cursor-name-text",style:{maxWidth:s.maxWidth}},c),d&&this.renderTag(e))),G.createElement(h1e,{key:`${r}:${a}`,tool:r,visual:o,imageKey:a})))}}const f1e=i=>{var l;const{className:t,info:e,resolver:r,labelOptions:n}=i,{roomMember:s,cursorTool:o,...a}=e||{},c=typeof a.x=="number"&&typeof a.y=="number";return G.createElement("div",{"data-cursor-uid":(l=s==null?void 0:s.payload)==null?void 0:l.uid,className:t,style:c?{transform:`translate(${a.x}px, ${a.y}px)`}:{display:"none"}},s&&G.createElement(d1e,{roomMember:s,cursorTool:o,resolver:r,labelOptions:n}))},g1e=i=>{const{className:t,manager:e}=i,[r,n]=G.useState(),s=G.useMemo(()=>new j0(e.control.pluginOptions.extras.cursor),[e]),o=e.control.pluginOptions.extras.cursor.syncedLabel;G.useEffect(()=>(e.internalMsgEmitter.on([Fe.Cursor,e.viewId],a),()=>{e.internalMsgEmitter.off([Fe.Cursor,e.viewId],a)}),[e]);function a(c){n(c)}return G.useMemo(()=>r!=null&&r.length?G.createElement(G.Fragment,null,r.map(c=>c.roomMember?G.createElement(f1e,{key:c.roomMember.memberId,className:t,info:c,resolver:s,labelOptions:o}):null)):null,[t,r,o,s])},p1e=i=>{const{viewId:t,miniMapCanvas:e,highlightColor:r,miniMapManager:n,contianer:s}=i,[o,a]=G.useState();G.useEffect(()=>(c(),n.listener.addListener([t,"viewCameraUpate"],c),n.listener.emitAsync([t,"miniMapCreate"],!0),()=>{n.listener.removeListener([t,"viewCameraUpate"],c)}),[]);const c=()=>{const h=n.maps.get(t);h&&l(h.miniMapCamera,h.viewCamera)},l=(h,d)=>{const{width:g,height:p}=s.getBoundingClientRect(),v=Math.min(g/h.width,p/h.height),I=d.width/d.scale,D=d.height/d.scale,x=[d.centerX,d.centerY],j=[h.centerX,h.centerY],w=[x[0]-j[0],x[1]-j[1]],y=Math.min(h.scale*v,h.scale*v),f=[w[0]*y,w[1]*y,I,D,y];a(f)},u=h=>{var d;if(n.control.renderControl.isWritable){const g=h.nativeEvent.target||h.nativeEvent.srcElement;if(g&&h.nativeEvent&&o){const{width:p,height:v}=g.getBoundingClientRect(),[I,D]=[p/2,v/2],[x,j]=[(h.nativeEvent.offsetX-I)/o[4],(h.nativeEvent.offsetY-D)/o[4]],w=n.maps.get(t);if(w!=null&&w.viewCamera){const[y,f]=[w.miniMapCamera.centerX+x,w.miniMapCamera.centerY+j];(d=n.control.room)==null||d.moveCamera({centerX:y,centerY:f,animationMode:"immediately"})}}}};return G.createElement("div",{style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",pointerEvents:"auto"},onClick:u},G.createElement("canvas",{style:{pointerEvents:"none"},ref:e}),o&&G.createElement("div",{className:"minimap-highlightBox",style:{position:"absolute",top:"50%",left:"50%",width:o[2]*o[4],height:o[3]*o[4],boxSizing:"content-box",border:`2px solid ${r}`,transform:`translate(calc(-50% + ${o[0]}px), calc(-50% + ${o[1]}px))`,pointerEvents:"none"}}))},m1e=i=>{const{miniMapManager:t,active:e,className:r}=i,n=G.useMemo(()=>{const s=t.maps;if(e){const o=s.get(e);if(o){const{miniMapCamera:a,viewCamera:c,...l}=o;if(l.contianer&&a&&c){const u=t.highlightColor;return Sa.createPortal(G.createElement(p1e,{viewId:e,...l,highlightColor:u,miniMapManager:t}),l.contianer)}}}return null},[e,t]);return G.createElement("div",{className:r},n)},ct=G.createContext({viewId:"",mananger:void 0,floatBarColors:[],overwriteSelectorStyles:{},floatBarData:void 0,dpr:1,angle:0,operationType:Se.None,scale:[1,1],isNoPointerEvents:!1,activeTextEditor:!1,activeTextId:void 0,setAngle:()=>{},setOperationType:()=>{},setFloatBarData:()=>{}});class Yh extends G.Component{constructor(e){var n,s;super(e);R(this,"showTextFloatBar");R(this,"canSelectorSwitch");R(this,"rightBoundBreak");R(this,"setAngle",e=>{this.setState({angle:e})});R(this,"setOperationType",e=>{this.setState({operationType:e})});this.state={floatBarData:void 0,showFloatBar:!1,showFloatBarBtn:!0,dpr:1,angle:0,operationType:Se.None,scale:[1,1],editors:this.editors,activeTextId:(n=this.props.mananger.control.textEditorManager)==null?void 0:n.activeId,activeMiniMapViewId:(s=this.props.mananger.control.miniMapManager)==null?void 0:s.activeViewId};const r=this.props.mananger.control.pluginOptions.extras.textEditor;this.showTextFloatBar=ve.isBoolean(r.showFloatBar)?r.showFloatBar:He.textEditor.showFloatBar,this.canSelectorSwitch=ve.isBoolean(r==null?void 0:r.canSelectorSwitch)?r.canSelectorSwitch:He.textEditor.canSelectorSwitch,this.rightBoundBreak=ve.isBoolean(r==null?void 0:r.rightBoundBreak)?r.rightBoundBreak:He.textEditor.rightBoundBreak}get editors(){return Lt(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,r){const n=e&&r&&{...this.state.floatBarData,...r}||void 0;this.setState({showFloatBar:e,floatBarData:n,angle:0})}activeTextEditor(){this.setState({activeTextEditor:!0})}unActiveTextEditor(){this.setState({activeTextEditor:!1})}updateTextEditorInfo(e,r){this.renderTextEditorInfo(e,r)}renderTextEditorInfo(e,r){this.setState({activeTextId:e,editors:this.editors},r)}setFloatBarData(e){this.state.floatBarData&&this.setState({floatBarData:{...this.state.floatBarData,...e}})}render(){var r,n,s,o,a,c;const e=!!((n=(r=this.props.mananger.control)==null?void 0:r.room)!=null&&n.floatBarOptions);return G.createElement("div",{className:gt.Container},!this.props.mananger.control.hasOffscreenCanvas&&G.createElement("div",{className:gt.CanvasBox,ref:this.props.refs.canvasContainerRef})||G.createElement("div",{className:gt.CanvasBox},G.createElement("canvas",{id:"bgCanvas",ref:this.props.refs.canvasBgRef,style:{width:"100%",height:"100%"}}),G.createElement("canvas",{id:"serviceCanvas",className:gt.FloatCanvas,ref:this.props.refs.canvasServiceFloatRef,style:{width:"100%",height:"100%"}}),G.createElement("canvas",{id:"localCanvas",className:gt.FloatCanvas,ref:this.props.refs.canvasFloatRef,style:{width:"100%",height:"100%"}}),!this.props.mananger.control.isUseSimple&&G.createElement("div",{id:"subLocalCanvas",className:gt.CanvasBoxSub,ref:this.props.refs.subLocalCanvasContainerRef}),!this.props.mananger.control.isUseSimple&&G.createElement("canvas",{id:"topCanvas",className:gt.TopFloatCanvas,ref:this.props.refs.canvasTopRef,style:{width:"100%",height:"100%"}})),!this.props.mananger.control.hasOffscreenCanvas&&this.props.refs.snapshotContainerRef&&G.createElement("div",{className:gt.SnapshotBox,ref:this.props.refs.snapshotContainerRef})||null,this.props.mananger.control.isUseBackgroundThread&&!!this.props.refs.backgroundContainerRef&&G.createElement("div",{className:gt.BackgroundBox},G.createElement("div",{className:gt.BackgroundSvgBox,ref:this.props.refs.backgroundContainerRef}),!!this.props.refs.backgroundSnapshotContainerRef&&G.createElement("div",{className:gt.BackgroundSnapshotBox},G.createElement("div",{className:gt.BackgroundSnapshotContent,ref:this.props.refs.backgroundSnapshotContainerRef})))||null,G.createElement(ct.Provider,{value:{viewId:this.props.viewId,mananger:this.props.mananger,floatBarColors:e&&((a=(o=(s=this.props.mananger.control)==null?void 0:s.room)==null?void 0:o.floatBarOptions)==null?void 0:a.colors)||[],overwriteSelectorStyles:this.props.mananger.control.pluginOptions.extras.overwriteSelectorStyles||{},isNoPointerEvents:!this.state.showFloatBarBtn,floatBarData:this.state.floatBarData,dpr:this.state.dpr,angle:this.state.angle,operationType:this.state.operationType,scale:this.state.scale,activeTextEditor:this.state.activeTextEditor,activeTextId:this.state.activeTextId,setAngle:this.setAngle.bind(this),setOperationType:this.setOperationType.bind(this),setFloatBarData:this.setFloatBarData.bind(this)}},this.state.showFloatBar&&G.createElement(u1e,{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)&&G.createElement(QMe,{className:gt.TextEditorContainer,showFloatBtns:this.showTextFloatBar&&e&&this.state.showFloatBarBtn||!1,editors:this.state.editors,rightBoundBreak:this.rightBoundBreak})||null),G.createElement("div",{className:"appliance-plugin-custom-floatbar-container","data-view-id":this.props.viewId,ref:this.props.refs.customFloatbarContainerRef}),G.createElement(g1e,{className:gt.CursorBox,manager:this.props.mananger}),!this.props.mananger.control.isUseSimple&&G.createElement(m1e,{className:gt.MiniMapBox,active:this.state.activeMiniMapViewId,miniMapManager:this.props.mananger.control.miniMapManager}))}}class y1e extends U0{constructor(e,r){super(e,r);R(this,"width",1e3);R(this,"height",1e3);R(this,"dpr",ji());R(this,"vDom");R(this,"eventTragetElement");R(this,"snapshotContainerRef");R(this,"backgroundSnapshotContainerRef");R(this,"canvasContainerRef",G.createRef());R(this,"subLocalCanvasContainerRef");R(this,"canvasTopRef");R(this,"canvasServiceFloatRef",G.createRef());R(this,"canvasFloatRef",G.createRef());R(this,"canvasBgRef",G.createRef());R(this,"backgroundContainerRef");R(this,"floatBarRef",G.createRef());R(this,"customFloatbarContainerRef",G.createRef());R(this,"containerOffset",{x:0,y:0});this.control.hasOffscreenCanvas||(this.snapshotContainerRef=G.createRef()),this.control.isUseSimple||(this.canvasTopRef=G.createRef(),this.subLocalCanvasContainerRef=G.createRef()),this.control.isUseBackgroundThread&&(this.backgroundContainerRef=G.createRef(),this.backgroundSnapshotContainerRef=G.createRef())}setCanvassStyle(){var e,r;if(this.eventTragetElement){const n=this.eventTragetElement.offsetWidth||this.width,s=this.eventTragetElement.offsetHeight||this.height,o=ji();o!==this.dpr&&(this.dpr=o,this.control.worker.updateDpr(this.viewId,this.dpr)),n&&s&&this.canvasContainerRef.current&&(n!==this.width||s!==this.height)&&(this.width=n,this.height=s,this.canvasContainerRef.current.style.width=`${n}px`,this.canvasContainerRef.current.style.height=`${s}px`),n&&s&&this.snapshotContainerRef&&this.snapshotContainerRef.current&&(n!==this.width||s!==this.height)&&(this.width=n,this.height=s),n&&s&&this.canvasBgRef.current&&(n!==this.width||s!==this.height)&&(this.width=n,this.height=s,this.control.isUseOffscreenTransfer||(this.canvasBgRef.current.width=n*this.dpr,this.canvasBgRef.current.height=s*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=n*this.dpr,this.canvasFloatRef.current.height=s*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=n*this.dpr,this.canvasServiceFloatRef.current.height=s*this.dpr),(e=this.canvasTopRef)!=null&&e.current&&(this.canvasTopRef.current.width=n*this.dpr,this.canvasTopRef.current.height=s*this.dpr))),n&&s&&this.backgroundContainerRef&&((r=this.backgroundContainerRef)!=null&&r.current)&&(n!==this.width||s!==this.height)&&(this.backgroundContainerRef.current.style.width=`${n}px`,this.backgroundContainerRef.current.style.height=`${s}px`,this.backgroundContainerRef.current.classList.toggle("appliance-plugin-background-isWritable",this.control.renderControl.isWritable))}}destroy(){if(super.destroy(),this.eventTragetElement){const e=this.eventTragetElement.parentElement;if(e){const r=e.querySelectorAll(".appliance-plugin-main-view-displayer");for(const n of r)n.remove()}}}createMainViewDisplayer(e){const r=document.createElement("div");return r.className="appliance-plugin-main-view-displayer",e.appendChild(r),this.eventTragetElement=e.children[0],this.containerOffset=this.getContainerOffset(this.eventTragetElement,this.containerOffset),this.bindToolsClass(),Sa.render(G.createElement(Yh,{viewId:this.viewId,mananger:this,refs:{canvasServiceFloatRef:this.canvasServiceFloatRef,canvasFloatRef:this.canvasFloatRef,canvasBgRef:this.canvasBgRef,floatBarRef:this.floatBarRef,customFloatbarContainerRef:this.customFloatbarContainerRef,canvasTopRef:this.canvasTopRef,canvasContainerRef:this.canvasContainerRef,snapshotContainerRef:this.snapshotContainerRef,subLocalCanvasContainerRef:this.subLocalCanvasContainerRef,backgroundContainerRef:this.backgroundContainerRef,backgroundSnapshotContainerRef:this.backgroundSnapshotContainerRef}}),r),this.control.room&&this.bindDisplayerEvent(this.eventTragetElement),this}}class v1e extends Xve{constructor(e,r,n){super(e,r,n);R(this,"dpr",ji());R(this,"width",1e3);R(this,"height",1e3);R(this,"vDom");R(this,"eventTragetElement");R(this,"canvasContainerRef",G.createRef());R(this,"subLocalCanvasContainerRef");R(this,"canvasTopRef");R(this,"canvasServiceFloatRef",G.createRef());R(this,"canvasFloatRef",G.createRef());R(this,"canvasBgRef",G.createRef());R(this,"backgroundContainerRef");R(this,"floatBarRef",G.createRef());R(this,"customFloatbarContainerRef",G.createRef());R(this,"containerOffset",{x:0,y:0});this.control.isUseSimple||(this.canvasTopRef=G.createRef(),this.subLocalCanvasContainerRef=G.createRef()),this.control.isUseBackgroundThread&&(this.backgroundContainerRef=G.createRef())}setCanvassStyle(){var e,r;if(this.eventTragetElement){const n=ji();if(n!==this.dpr&&(this.dpr=n,this.control.worker.updateDpr(this.viewId,this.dpr)),this.canvasContainerRef.current){const s=this.eventTragetElement.offsetWidth||this.width,o=this.eventTragetElement.offsetHeight||this.height;s&&o&&(s!==this.width||o!==this.height)&&(this.width=s,this.height=o,this.canvasContainerRef.current.style.width=`${s}px`,this.canvasContainerRef.current.style.height=`${o}px`)}if(this.canvasBgRef.current){const s=this.eventTragetElement.offsetWidth||this.width,o=this.eventTragetElement.offsetHeight||this.height;s&&o&&(s!==this.width||o!==this.height)&&(this.width=s,this.height=o,this.control.isUseOffscreenTransfer||(this.canvasBgRef.current.width=s*this.dpr,this.canvasBgRef.current.height=o*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=s*this.dpr,this.canvasFloatRef.current.height=o*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=s*this.dpr,this.canvasServiceFloatRef.current.height=o*this.dpr),(e=this.canvasTopRef)!=null&&e.current&&(this.canvasTopRef.current.width=s*this.dpr,this.canvasTopRef.current.height=o*this.dpr)))}if(this.backgroundContainerRef&&((r=this.backgroundContainerRef)!=null&&r.current)){const s=this.eventTragetElement.offsetWidth||this.width,o=this.eventTragetElement.offsetHeight||this.height;s&&o&&(s!==this.width||o!==this.height)&&(this.backgroundContainerRef.current.style.width=`${s}px`,this.backgroundContainerRef.current.style.height=`${o}px`,this.backgroundContainerRef.current.classList.toggle("appliance-plugin-background-isWritable",this.control.renderControl.isWritable))}}}createAppViewDisplayer(e,r){const n=document.createElement("div");return n.className="appliance-plugin-app-view-displayer",r.appendChild(n),this.eventTragetElement=r.children[0],this.containerOffset=this.getContainerOffset(this.eventTragetElement,this.containerOffset),this.bindToolsClass(),Sa.render(G.createElement(Yh,{viewId:e,mananger:this,refs:{canvasServiceFloatRef:this.canvasServiceFloatRef,canvasFloatRef:this.canvasFloatRef,canvasBgRef:this.canvasBgRef,floatBarRef:this.floatBarRef,customFloatbarContainerRef:this.customFloatbarContainerRef,canvasTopRef:this.canvasTopRef,canvasContainerRef:this.canvasContainerRef,subLocalCanvasContainerRef:this.subLocalCanvasContainerRef,backgroundContainerRef:this.backgroundContainerRef}}),n),this.control.room&&this.bindDisplayerEvent(this.eventTragetElement),this}}class gn extends Oi{constructor(e){super(e);R(this,"focuedViewId");R(this,"focuedView");R(this,"control");R(this,"tmpFocusedViewId");R(this,"checkScaleTimer");R(this,"mainViewHotkeyListener",e=>{this.onActiveHotkeyChange(e)});R(this,"appViewListeners",new Map);R(this,"onMainViewRelease",async e=>{this.control.textEditorManager.clear(Ue,!0),this.mainViewDestroy(e),await new Promise(n=>{setTimeout(()=>{n(!0)},0)}),this.onMainViewMounted(e);const r=this.control.getSnapshootData("memberState");this.control.room&&this.control.onMemberChange(r),this.control.clearSnapshootData()});R(this,"mainViewDestroy",e=>{var r;if(this.mainView&&this.mainView.displayer){this.removeMainViewListeners(this.mainView.viewData),this.mainView.displayer.destroy();const n=e.divElement;if(n){const s=n.getElementsByClassName("appliance-plugin-main-view-displayer");for(const o of s)o.remove()}if(this.mainView.container&&n!==this.mainView.container){const s=this.mainView.container.getElementsByClassName("appliance-plugin-main-view-displayer");for(const o of s)o.remove()}(r=this.control.worker)==null||r.destroyViewWorker(this.mainView.id,!0),this.mainView=void 0}});R(this,"onMainViewMounted",e=>{const r=e.divElement;if(!r||!e.focusScenePath||!(e.focusScenePath||e.scenePath))return;const s=new y1e(this.control,Xe.InternalMsgEmitter),o=e.size.width||s.width,a=e.size.height||s.height;s.dpr;const c={cameraOpt:{...gn.defaultCameraOpt,width:o,height:a}},{scale:l,...u}=e.camera;c.cameraOpt={...c.cameraOpt,...u,scale:l===1/0?1:l},this.createMianView({id:Ue,container:r,displayer:s,focusScenePath:e.focusScenePath,cameraOpt:c.cameraOpt,viewData:e}),this.setFocuedViewId(Ue),s.createMainViewDisplayer(r),e.callbacks.on("onSizeUpdated",this.onMainViewSizeUpdated),e.callbacks.on("onCameraUpdated",this.onMainViewCameraUpdated),e.callbacks.on("onActiveHotkey",this.mainViewHotkeyListener)});R(this,"onMainViewSizeUpdated",async()=>{await new Promise(e=>{setTimeout(()=>{e(!0)},0)}),this.mainView&&this.mainView.viewData&&this.updateMainViewCamera()});R(this,"onMainViewCameraUpdated",async()=>{await new Promise(e=>{setTimeout(()=>{e(!0)},0)}),this.updateMainViewCamera()});R(this,"updateMainViewCamera",()=>{if(this.mainView&&this.mainView.viewData){const e=this.mainView.viewData.camera;if(!ve.isNumber(e.scale)||e.scale===1/0)return;const r=this.mainView.cameraOpt;if(r){const n=r.width,s=r.height,{width:o,height:a}=this.mainView.viewData.size;(o!==n||a!==s)&&this.mainView.displayer.updateSize();const c=e.scale===1/0?1:e.scale,l=e.centerX||0,u=e.centerY||0,h={...r,scale:c,centerX:l,centerY:u,width:o,height:a};ve.isEqual(r,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))}}});R(this,"onAppViewMounted",async e=>{var d;const{appId:r,view:n}=e,s=n.divElement;if(!s||!n.focusScenePath)return;const o=this.appViews.get(r);if(o&&o.displayer){let g=s.getElementsByClassName("appliance-plugin-app-view-displayer");for(const p of g)p.remove();if(o.container&&o.container!==s){g=o.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(r,!0),await new Promise(p=>{setTimeout(()=>{p(!0)},0)})}const a=new v1e(r,this.control,Xe.InternalMsgEmitter),c=n.size.width||a.width,l=n.size.height||a.height;a.dpr;const u={cameraOpt:{...gn.defaultCameraOpt,...n.camera,width:c,height:l}};this.createAppView({id:r,container:s,displayer:a,cameraOpt:u.cameraOpt,focusScenePath:n.focusScenePath,viewData:n}),a.createAppViewDisplayer(r,s);const h=this.getAppViewListeners(r);if(n.callbacks.on("onSizeUpdated",h.onSizeUpdated),n.callbacks.on("onCameraUpdated",h.onCameraUpdated),n.callbacks.on("onActiveHotkey",h.onActiveHotkey),this.tmpFocusedViewId===r){const g=this.control.worker.getLocalWorkViewId();g&&g!==r?this.setFocuedViewId(g):this.setFocuedViewId(r),this.tmpFocusedViewId=void 0}setTimeout(()=>{this.onAppViewCameraUpdated(r)},0)});R(this,"onAppViewSizeUpdated",async e=>{await new Promise(n=>{setTimeout(()=>{n(!0)},0)});const r=this.appViews.get(e);r&&r.viewData&&this.updateAppCamera(e)});R(this,"onAppViewCameraUpdated",async e=>{await new Promise(r=>{setTimeout(()=>{r(!0)},0)}),this.updateAppCamera(e)});R(this,"updateAppCamera",e=>{const r=this.appViews.get(e);if(r&&r.viewData){const n=r.viewData.camera,s=r.cameraOpt;if(s){const{width:o,height:a}=r.viewData.size,c=s.width,l=s.height;(o!==c||a!==l)&&r.displayer.updateSize();const u=n.scale===1/0?1:n.scale,h=n.centerX||0,d=n.centerY||0,g={...s,scale:u,centerX:h,centerY:d,width:o,height:a};ve.isEqual(g,s)||(r.cameraOpt=g)}}});this.control=e.control}getAppViewListeners(e){let r=this.appViewListeners.get(e);return r||(r={onSizeUpdated:()=>{this.onAppViewSizeUpdated(e)},onCameraUpdated:()=>{this.onAppViewCameraUpdated(e)},onActiveHotkey:n=>{this.onActiveHotkeyChange(n)}},this.appViewListeners.set(e,r)),r}removeMainViewListeners(e){e&&(e.callbacks.off("onSizeUpdated",this.onMainViewSizeUpdated),e.callbacks.off("onCameraUpdated",this.onMainViewCameraUpdated),e.callbacks.off("onActiveHotkey",this.mainViewHotkeyListener))}removeAppViewListeners(e,r){const n=this.appViewListeners.get(e);r&&n&&(r.callbacks.off("onSizeUpdated",n.onSizeUpdated),r.callbacks.off("onCameraUpdated",n.onCameraUpdated),r.callbacks.off("onActiveHotkey",n.onActiveHotkey)),this.appViewListeners.delete(e)}destroyAppView(e,r=!1){const n=this.appViews.get(e);this.removeAppViewListeners(e,n==null?void 0:n.viewData),super.destroyAppView(e,r)}destroy(){var e;this.removeMainViewListeners((e=this.mainView)==null?void 0:e.viewData);for(const[r,n]of this.appViews.entries())this.removeAppViewListeners(r,n.viewData);super.destroy(),this.appViewListeners.clear()}getViewInitData(e){const r=this.getView(e);if(r){const{width:n,height:s,dpr:o}=r.displayer;this.control.renderingCompatibilityDecision.contextType&&(gn.defaultScreenCanvasOpt.contextType=this.control.renderingCompatibilityDecision.contextType);const a={dpr:o,originalPoint:[n/2,s/2],offscreenCanvasOpt:{...gn.defaultScreenCanvasOpt,width:n,height:s},layerOpt:{...gn.defaultLayerOpt,width:n,height:s},cameraOpt:{...gn.defaultCameraOpt,width:n,height:s}};if(r.viewData){const{scale:c,...l}=r.viewData.camera;a.cameraOpt={...a.cameraOpt,...l,scale:c===1/0?1:c}}return a}}async mountView(e){var n,s,o;const r=this.getView(e);if(r){const a=()=>{this.control.emitInitLoadingChange({loading:!0,phase:"scene",status:"success"}),this.control.emitInitLoadingChange({loading:!1,phase:"ready",status:"success"})};this.control.emitInitLoadingChange({loading:!0,phase:"scene",status:"start"}),e===((n=this.mainView)==null?void 0:n.id)&&(this.control.cursor.activeCollector(),await this.control.activeWorker()),this.control.isUseOffscreenTransfer&&r.displayer.canvasBgRef.current&&r.displayer.canvasServiceFloatRef.current&&r.displayer.canvasFloatRef.current&&r.displayer.setTransferControlToOffscreenCanvas({bgCanvas:r.displayer.canvasBgRef.current,serviceCanvas:r.displayer.canvasServiceFloatRef.current,localCanvas:r.displayer.canvasFloatRef.current});const c=this.getViewInitData(e);if(c&&((s=this.control.worker)==null||s.createViewWorker(e,c,r.displayer)),r.focusScenePath&&this.control.collector){if(this.control.collector.authStorage){const{renderAuth:l,pageAuth:u}=this.control.collector.authStorage;if(l){const h=l[e];if(h){const{render:d,hide:g,clear:p}=h;this.control.renderControl.syncRenderUids(e,d,g,p),a();return}}if(u){const h=u[e];if(h){this.control.renderControl.syncPageAuth(e,h,!0),a();return}}}this.control.worker.pullServiceData(e,r.focusScenePath,{isAsync:!0,useAnimation:!1}),this.control.pluginOptions.extras.undoRedo.enableGlobal&&r.displayer.commiter&&((o=this.control.collector)!=null&&o.globalUndoRedoStackStorage[r.id])&&r.displayer.commiter.pullServiceData(this.control.collector.globalUndoRedoStackStorage[r.id])}a()}}listenerWindowManager(e){e.emitter.on("focusedChange",r=>{const n=r||Ue;if(this.focuedViewId!==n)if(this.getView(n)){const o=this.control.worker.getLocalWorkViewId();o&&o!==n?this.setFocuedViewId(o):this.setFocuedViewId(n)}else this.tmpFocusedViewId=n}),e.emitter.on("mainViewScenePathChange",r=>{this.control.onSceneChange(r,Ue)}),e.emitter.on("onMainViewMounted",this.onMainViewMounted),e.emitter.on("onAppViewMounted",this.onAppViewMounted),e.emitter.on("onMainViewRebind",this.onMainViewRelease),e.emitter.on("onBoxClose",r=>{this.appViews.get(r.appId)&&(this.destroyAppView(r.appId),this.control.worker.destroyViewWorker(r.appId))}),e.emitter.on("onAppScenePathChange",r=>{const{appId:n,view:s}=r;this.control.onSceneChange(s.focusScenePath,n)}),e.emitter.on("appsChange",r=>{for(const n of this.appViews.keys())r.includes(n)||(this.destroyAppView(n),this.control.worker.destroyViewWorker(n,!0))})}onActiveHotkeyChange(e){this.control.hotkeyManager.onActiveHotkey(e)}}class un extends Xe{constructor(e){super(e);R(this,"windowManager");R(this,"viewContainerManager");const r={control:this,internalMsgEmitter:Xe.InternalMsgEmitter,publicMsgEmitter:Xe.PublicMsgEmitter};this.viewContainerManager=new gn(r)}init(){}activePlugin(){this.collector&&(this.collector.addAuthStateListener((e,r)=>{e&&Object.keys(e).forEach(n=>{var o;const s=(o=e[n])==null?void 0:o.newValue;this.renderControl.syncRenderUids(n,s==null?void 0:s.render,s==null?void 0:s.hide,s==null?void 0:s.clear)}),r&&Object.keys(r).forEach(n=>{var o;const s=(o=r[n])==null?void 0:o.newValue;this.renderControl.syncPageAuth(n,s)})}),this.collector.addStorageStateListener(e=>{var a,c;if((a=this.collector)!=null&&a.storage&&Object.keys(this.collector.storage).length===0){(c=this.worker)==null||c.clearViewScenePath(Ue,!0);return}const{diffView:r,diffScenePath:n,diffData:s}=e,o=new Map;if(r){let l;Object.keys(r).forEach(u=>{var d;const h=r[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 v of Object.keys(g))v&&p.add(v);o.set(u,p)}})}if(n){let l;Object.keys(n).forEach(u=>{var d;const h=n[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),o.set(h.viewId,g)}})}s&&Object.keys(s).forEach(l=>{var h,d;const u=s[l];if(u){const{viewId:g}=u,p=o.get(g)||new Set;p.add(l),o.set(g,p),(h=this.worker)==null||h.onServiceDerive(l,u),(d=this.miniMapManager)==null||d.updateMiniMapCamera(g)}});for(const[l,u]of o.entries())Xe.InternalMsgEmitter.emit("excludeIds",[...u],l)}),this.pluginOptions.extras.undoRedo.enableGlobal&&this.collector.addGlobalUndoRedoStackListener(e=>{Object.keys(e).forEach(r=>{var o;const n=e[r],s=(o=this.viewContainerManager.getView(r))==null?void 0:o.displayer.commiter;s&&s.pullServiceData(n==null?void 0:n.newValue)})}),this.worker.isActive&&this.viewContainerManager.getAllViews().forEach(e=>{e&&e.focusScenePath&&this.worker.pullServiceData(e.id,e.focusScenePath,{isAsync:!0,useAnimation:!1})}),this.room&&this.roomMember.onUidChangeHook(e=>{var r,n;(r=this.collector)!=null&&r.serviceStorage&&this.viewContainerManager.getAllViews().forEach(s=>{var o,a,c,l;if(s&&s.focusScenePath&&((o=this.collector)!=null&&o.serviceStorage[s.id])&&this.collector.serviceStorage[s.id][s.focusScenePath]){const u=Object.keys(this.collector.serviceStorage[s.id][s.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:s.id,scenePath:s.focusScenePath,isSync:!0})),this.worker.blurSelector(s.id,s.focusScenePath,h);else{const g=this.textEditorManager.editors.get(h);g&&g.opt&&(g.opt.workState===ge.Doing||g.opt.workState===ge.Start)&&(pa(g.opt.text)?this.textEditorManager.unActive(h):this.textEditorManager.delete(h))}}}}),(n=this.cursor)==null||n.updateRoomMembers(e)}))}async activeWorker(){await this.worker.init()}setWindowManager(e){var r,n,s,o,a;this.windowManager=e,(n=(r=this.windowManager)==null?void 0:r.mainView)!=null&&n.divElement&&this.viewContainerManager.onMainViewMounted(this.windowManager.mainView),(a=(o=(s=this.windowManager.appManager)==null?void 0:s.viewManager)==null?void 0:o.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 Ml=new WeakMap;function ep(i){return/^https?:\/\//i.test(i.trim())}function M1e(i){var e,r;const t=[];for(const[n,s]of Object.entries(i.appearance||{})){if(!s)continue;const o=[["default",s.images],["local",(e=s.local)==null?void 0:e.images],["synced",(r=s.synced)==null?void 0:r.images]];for(const[a,c]of o){if(!c)continue;ep(c.standardResolution)&&t.push({appliance:n,scope:a,density:"standard",key:c.key||"external",url:c.standardResolution});const l=Vh(c);l&&ep(l)&&t.push({appliance:n,scope:a,density:"high",key:c.key||"external",url:l})}}return t}function $0(i){Ml.has(i)||(Ml.set(i,new Map),window.setTimeout(()=>{try{const t=Nh(i),e=M1e(t);if(!e.length)return;const r=Ml.get(i);if(!r)return;const n=new Set;for(const s of e){if(n.has(s.url))continue;n.add(s.url);const o=new Image;let a;const c=()=>{a!==void 0&&window.clearTimeout(a),o.onload=null,o.onerror=null,r.delete(s.url)};o.onload=c,o.onerror=c,r.set(s.url,o),a=window.setTimeout(c,t.preloadTimeout),o.src=s.url}}catch{}},0))}function V0(i,t){var r;if(!t||!Array.isArray(t.sources)||!t.sources.includes("appliance")||typeof t.viewId!="string"||typeof t.scenePath!="string"||typeof t.imageUrl!="string")return!1;const e=(r=i==null?void 0:i[t.viewId])==null?void 0:r[t.scenePath];return e?Object.values(e).some(n=>{var s;return(n==null?void 0:n.toolsType)===K.BackgroundSVG&&((s=n.opt)==null?void 0:s.src)===t.imageUrl}):!1}const we=class we extends cp{constructor(){super(...arguments);R(this,"onPhaseChanged",e=>{var r;e===lp.Reconnecting&&((r=we.currentManager)==null||r.setSnapshootData())});R(this,"updateRoomWritable",()=>{var e;(e=we.currentManager)==null||e.onWritableChange(this.displayer.isWritable)});R(this,"roomStateChangeListener",async e=>{var r,n;e!=null&&e.roomMembers&&((r=we.currentManager)==null||r.onRoomMembersChange(e.roomMembers)),!(Le(this.displayer)&&!this.displayer.isWritable)&&e.memberState&&((n=we.currentManager)==null||n.onMemberChange(e.memberState))})}static async getInstance(e,r){var f,M,T;(b=>{var C;try{(C=r.onInitLoadingChange)==null||C.call(r,b)}catch(P){we.logger.error(`[ApplianceMultiPlugin] onInitLoadingChange error: ${(P==null?void 0:P.message)||P}`)}})({loading:!0,phase:"plugin",status:"start"});const s=e.displayer,o=Le(s)&&s.logger||we.logger,a=typeof navigator>"u"?"unknown":navigator.userAgent;o.info(`[Appliance]: [init-enter] version=${oc} userAgent=${a}`);const c=s.callbacks.on,l=s.callbacks.off,u=s.callbacks.once,h=e.cleanCurrentScene,d=e.mainView.setMemberState;let g;Le(s)&&(g=s.setWritable),r!=null&&r.logger&&(we.logger=new $h(r.logger));let p=s.getInvisiblePlugin(we.kind);p||(p=await we.createApplianceMultiPlugin(s,we.kind)),s&&p&&we.createCurrentManager(e,{cdn:r.options.cdn,extras:Hy(r.options.extras)},p,r.onInitLoadingChange),(f=we.currentManager)==null||f.emitInitLoadingChange({loading:!0,phase:"plugin",status:"success"});const v={displayer:s,windowManager:e,currentManager:we.currentManager,maxScreenshotWidth:10*1024,maxScreenshotHeight:10*1024,getBoundingRectAsync:async function(b){var E;we.logger.info("[ApplianceMultiPlugin] getBoundingRectAsync");const C=(e.mainView||s).getBoundingRect(b),P=await((E=we.currentManager)==null?void 0:E.getBoundingRect(b));return!C.width||!C.height?P:zh(C,P)},screenshotToCanvasAsync:async function(b,C,P,E,O,V){var Q;we.logger.info("[ApplianceMultiPlugin] screenshotToCanvasAsync");let N=P,A=E,k=O.scale;N>this.maxScreenshotWidth&&(k=this.maxScreenshotWidth/N*k,N=this.maxScreenshotWidth),A>this.maxScreenshotHeight&&(k=Math.min(this.maxScreenshotHeight/A*k,k),A=this.maxScreenshotHeight),O.scale=k;const U=document.createElement("canvas"),Z=U.getContext("2d");U.width=N*(V||1),U.height=A*(V||1),Z&&((e.mainView||s).screenshotToCanvas(Z,C,N,A,O,V),b.drawImage(U,Math.floor((P-N)/2),Math.floor((E-A)/2),N*(V||1),A*(V||1),0,0,N,A),U.remove()),we.currentManager&&await((Q=we.currentManager)==null?void 0:Q.screenshotToCanvas(b,C,N,A,O,Math.floor((P-N)/2),Math.floor((E-A)/2)))},scenePreviewAsync:async function(b,C,P,E,O){we.logger.info("[ApplianceMultiPlugin] scenePreviewAsync"),(e.mainView||s).scenePreview(b,C,P,E,O);const V=document.createElement("img");V.className="appliance-plugin-fill-scene-snapshot-img",C.append(V),getComputedStyle(C).position||(C.style.position="relative"),we.currentManager&&await we.currentManager.scenePreview(b,V)},fillSceneSnapshotAsync:async function(b,C,P,E,O){we.logger.info("[ApplianceMultiPlugin] fillSceneSnapshotAsync"),C.innerHTML="",(e.mainView||s).fillSceneSnapshot(b,C,P,E,O);const V=P||e.mainView.size.width,N=E||e.mainView.size.height;let A=await this.getBoundingRectAsync(b);A||(A={originX:0,originY:0,width:V,height:N});let k=Math.max(A==null?void 0:A.width,V),U=Math.max(A==null?void 0:A.height,N),Z=1;const Q=k>V&&Math.min(V/k,Z)||Z,ce=U>N&&Math.min(N/U,Z)||Z;Q<=ce?(k=Q<1&&V||k,U=Math.floor(U*Q)+1,Z=Q):Q>ce&&(U=ce<1&&N||U,k=Math.floor(k*ce)+1,Z=ce);const L={scale:Z,centerX:A.originX+A.width/2,centerY:A.originY+A.height/2},W=document.createElement("canvas"),H=W.getContext("2d");W.width=k,W.height=U,H&&await this.screenshotToCanvasAsync(H,b,k,U,L,devicePixelRatio);const $=document.createElement("img");$.className="appliance-plugin-fill-scene-snapshot-img",$.src=W.toDataURL(),$.onload=()=>{W.remove()},$.onerror=()=>{W.remove(),$.remove()},C.append($),getComputedStyle(C).position||(C.style.position="relative")},_callbacksOn:function(b,C){(b==="onCanUndoStepsUpdate"||b==="onCanRedoStepsUpdate")&&Le(s)&&s.isWritable?un.InternalMsgEmitter.on(b,C):c.call(s.callbacks,b,C)},_callbacksOnce:function(b,C){(b==="onCanUndoStepsUpdate"||b==="onCanRedoStepsUpdate")&&Le(s)&&s.isWritable?un.InternalMsgEmitter.on(b,C):u.call(s.callbacks,b,C)},_callbacksOff:function(b,C){(b==="onCanUndoStepsUpdate"||b==="onCanRedoStepsUpdate")&&Le(s)&&s.isWritable?un.InternalMsgEmitter.off(b,C):l.call(s.callbacks,b,C)},canRedoSteps(){if(we.logger.info("[ApplianceMultiPlugin] canRedoSteps"),we.currentManager&&Le(s)&&!s.disableSerialization){const b=we.currentManager.viewContainerManager.focuedView,C=b==null?void 0:b.focusScenePath;if(b&&C)return b.displayer.commiter.redoStack.filter(P=>P.scenePath===C).length}return 0},canUndoSteps(){if(we.logger.info("[ApplianceMultiPlugin] canUndoSteps"),we.currentManager&&Le(s)&&!s.disableSerialization){const b=we.currentManager.viewContainerManager.focuedView,C=b==null?void 0:b.focusScenePath;if(b&&C)return b.displayer.commiter.undoStack.filter(O=>O.scenePath===C).length}return 0},undo:function(){return we.logger.info("[ApplianceMultiPlugin] undo"),we.currentManager&&Le(s)&&!s.disableSerialization&&s.isWritable?we.currentManager.viewContainerManager.undo():0},redo:function(){return we.logger.info("[ApplianceMultiPlugin] redo"),we.currentManager&&Le(s)&&!s.disableSerialization&&s.isWritable?we.currentManager.viewContainerManager.redo():0},cleanCurrentScene:function(){we.logger.info("[ApplianceMultiPlugin] cleanCurrentScene"),we.currentManager&&Le(s)&&s.isWritable&&(we.currentManager.logger.info("[Appliance]: cleanCurrentScene"),we.currentManager.cleanCurrentScene().then(()=>{h.call(e)}).catch(b=>{var C;(C=we.currentManager)==null||C.logger.error(`[Appliance]: cleanCurrentScene failed: ${(b==null?void 0:b.message)||b}`)}))},insertImage:function(b){if(we.logger.info("[ApplianceMultiPlugin] insertImage"),we.currentManager&&Le(s)&&s.isWritable){const C=we.currentManager.viewContainerManager.focuedViewId||Ue;we.currentManager.worker.insertImage(C,b)}},lockImage:function(b,C){if(we.logger.info("[ApplianceMultiPlugin] lockImage"),we.currentManager&&Le(s)&&s.isWritable){const P=we.currentManager.viewContainerManager.focuedViewId||Ue;we.currentManager.worker.lockImage(P,b,C)}},completeImageUpload:function(b,C){if(we.logger.info("[ApplianceMultiPlugin] completeImageUpload"),we.currentManager&&Le(s)&&s.isWritable){const P=we.currentManager.viewContainerManager.focuedViewId||Ue;we.currentManager.worker.completeImageUpload(P,b,C)}},getImagesInformation:function(b){return we.logger.info("[ApplianceMultiPlugin] completeImageUpload"),we.currentManager&&Le(s)&&s.isWritable?we.currentManager.worker.getImagesInformation(b):[]},insertText:function(b,C,P){if(we.logger.info("[ApplianceMultiPlugin] insertText"),we.currentManager&&Le(s)&&s.isWritable){const E=we.currentManager.viewContainerManager.focuedViewId||Ue;return we.currentManager.textEditorManager.insertText(E,b,C,P)}},updateText:function(b,C){we.logger.info("[ApplianceMultiPlugin] updateText"),we.currentManager&&Le(s)&&s.isWritable&&we.currentManager.textEditorManager.updateText(b,C)},callbacks:()=>({...s.callbacks,on:v._callbacksOn.bind(v),once:v._callbacksOnce.bind(v),off:v._callbacksOff.bind(v)}),destroy(){we.currentManager&&(we.currentManager.logger.info("[Appliance]: [ApplianceMultiPlugin] destroy"),we.currentManager.destroy(),we.currentManager=void 0)},setMemberState(b){if(we.currentManager){we.currentManager.logger.info(`[Appliance]: setMemberState ${JSON.stringify(b)}`);const C=Object.keys(b);if(Le(s)&&s.isWritable){if(C.includes("currentApplianceName"))if(we.currentManager.requestToolChange(b),b.currentApplianceName&&b.currentApplianceName===Ne.laserPen){if(we.currentManager.isUseSimple)throw we.currentManager.logger.error("[Appliance]: [ApplianceMultiPlugin] laserPen must be not support in simple mode"),new Error("[Appliance]: [ApplianceMultiPlugin] laserPen must be not support in simple mode");b.currentApplianceName=Ne.pencil,b.useLaserPen=!0}else b.currentApplianceName&&b.currentApplianceName===Ne.pencil&&(b.useLaserPen=!1);try{d.call(e.mainView,b)}catch(P){throw we.currentManager.setToolChangePending(!1,"set-member-state-error"),P}return}}throw we.logger.error("[Appliance]: [ApplianceMultiPlugin] setMemberState must be called in writable room"),new Error("[Appliance]: [ApplianceMultiPlugin] setMemberState must be called in writable room")},createMiniMap:async function(b,C){if(we.logger.info("[ApplianceMultiPlugin] createMiniMap"),we.currentManager&&Le(s)&&s.isWritable)return we.currentManager.logger.info("[Appliance]: [ApplianceMultiPlugin] createMiniMap"),we.currentManager.createMiniMap(b,C)},destroyMiniMap:async function(b){if(we.logger.info("[ApplianceMultiPlugin] destroyeMiniMap"),we.currentManager&&Le(s)&&s.isWritable)return we.currentManager.logger.info("[Appliance]: [ApplianceMultiPlugin] destroyeMiniMap"),we.currentManager.destroyMiniMap(b)},filterRenderByUid(b,C,P){if(we.logger.info("[ApplianceMultiPlugin] filterRenderByUid"),we.currentManager&&Le(s)&&s.isWritable)return we.currentManager.filterRenderByUid(b,C,P)},cancelFilterRender(b,C){if(we.logger.info("[ApplianceMultiPlugin] filterRenderByUid"),we.currentManager&&Le(s)&&s.isWritable)return we.currentManager.cancelFilterRender(b,C)},addListener:(b,C)=>{un.PublicMsgEmitter.on(b,C)},removeListener:(b,C)=>{un.PublicMsgEmitter.off(b,C)},usePlugin:b=>{var C;we.logger.info("[ApplianceMultiPlugin] usePlugin",b.kind),(C=we.currentManager)==null||C.usePlugin(b)},getDisableDeviceInputs(){if(we.currentManager&&Le(s))return we.currentManager.disableDeviceInputs},setDisableDeviceInputs(b){we.logger.info(`[ApplianceMultiPlugin] setDisableDeviceInputs ${b}`),we.currentManager&&Le(s)&&(we.currentManager.disableDeviceInputs=b)},getDisableCameraTransform(){if(we.currentManager&&Le(s))return we.currentManager.disableCameraTransform},setDisableCameraTransform(b){we.logger.info(`[ApplianceMultiPlugin] setDisableCameraTransform ${b}`),we.currentManager&&Le(s)&&(we.currentManager.disableCameraTransform=b)},getDisableEraseImage(){if(we.currentManager&&Le(s))return we.currentManager.disableEraseImage},setDisableEraseImage(b){we.logger.info(`[ApplianceMultiPlugin] setDisableEraseImage ${b}`),we.currentManager&&Le(s)&&(we.currentManager.disableEraseImage=b)},setWritable:async function(b){var C;we.logger.info(`[ApplianceMultiPlugin] setWritable ${b}`),Le(s)&&g&&(await((C=we.currentManager)==null?void 0:C.setWritable(b)),await g.call(s,b))},requestIdleCallback:(b,C)=>{const P=(C==null?void 0:C.timeout)||0,E=performance.now();let O;const V=new MessageChannel;let N;const A=k=>{try{b({didTimeout:k,timeRemaining:()=>{const Z=performance.now()-E;return Math.max(0,P-Z)}})}catch(U){we.logger.error("[ApplianceMultiPlugin] requestIdleCallback error:",U)}finally{V.port1.close(),V.port2.close(),O!==void 0&&cancelAnimationFrame(O),N!==void 0&&clearTimeout(N)}};return V.port1.onmessage=()=>{O=requestAnimationFrame(()=>{P>0&&performance.now()-E>=P?A(!0):A(!1)})},V.port2.postMessage(null),P>0&&(N=setTimeout(()=>{A(!0)},P)),N||O||0},cancelIdleCallback:b=>{try{clearTimeout(b),cancelAnimationFrame(b)}catch(C){we.logger.error("[ApplianceMultiPlugin] cancelIdleCallback error:",C)}},injectMethodToObject:(b,C)=>{if(typeof b[C]=="function"||typeof b[C]>"u"){(C==="requestIdleCallback"||C==="cancelIdleCallback")&&we.currentManager&&we.currentManager.registerPolyfillMethod(C),b[C]=v[C];return}C==="callbacks"&&(b.callbacks.on=v._callbacksOn.bind(v),b.callbacks.off=v._callbacksOff.bind(v),b.callbacks.once=v._callbacksOnce.bind(v))},blurText:()=>{we.logger.info("[ApplianceMultiPlugin] blurText"),we.currentManager&&Le(s)&&s.isWritable&&we.currentManager.textEditorManager.checkEmptyTextBlur()},hasElements:(b,C)=>{var P;if(we.logger.info(`[ApplianceMultiPlugin] hasElements ${b}`),we.currentManager&&Le(s)&&s.isWritable){let E=b;if(!E){const O=we.currentManager.viewContainerManager.focuedView;E=O==null?void 0:O.focusScenePath}if(E){const O=(P=we.currentManager.collector)==null?void 0:P.getScenePathData(E);if(O){const V=Object.values(O);return V.length>0?C?V.some(N=>C(N.toolsType)):!0:!1}return!1}return!1}},getElements:(b,C)=>{var P;if(we.logger.info(`[ApplianceMultiPlugin] getElements ${b}`),we.currentManager&&Le(s)&&s.isWritable){let E=b;if(!E){const O=we.currentManager.viewContainerManager.focuedView;E=O==null?void 0:O.focusScenePath}if(E){const O=(P=we.currentManager.collector)==null?void 0:P.getScenePathData(E),V=O&&Object.values(O)||[];return O&&V.length>0&&C?V.filter(N=>C(N.toolsType)):V}return[]}},hasBackgroundImage:b=>{var C,P;return V0((P=(C=we.currentManager)==null?void 0:C.collector)==null?void 0:P.storage,b)},stopDraw:b=>{if(we.logger.info(`[ApplianceMultiPlugin] stopDraw ${b}`),we.currentManager&&Le(s))return we.currentManager.stopDraw(b)},loadFontFaces:()=>{var b;return we.logger.info("[ApplianceMultiPlugin] loadFontFaces"),((b=we.currentManager)==null?void 0:b.loadFontFaces())||Promise.resolve({status:"error"})},refreshViewRender:b=>{var C;return we.logger.info(`[ApplianceMultiPlugin] refreshViewRender ${b}`),((C=we.currentManager)==null?void 0:C.refreshViewRender(b))||Promise.resolve({status:"error"})},refreshRender:()=>{var b;return we.logger.info("[ApplianceMultiPlugin] refreshRender"),((b=we.currentManager)==null?void 0:b.refreshRender())||Promise.resolve({status:"error"})},refreshViewTextRender:b=>{var C;return we.logger.info(`[ApplianceMultiPlugin] refreshViewTextRender ${b}`),((C=we.currentManager)==null?void 0:C.refreshViewTextRender(b))||Promise.resolve({status:"error"})},refreshTextRender:()=>{var b;return we.logger.info("[ApplianceMultiPlugin] refreshTextRender"),((b=we.currentManager)==null?void 0:b.refreshTextRender())||Promise.resolve({status:"error"})},setViewLocalScenePathChange:async(b,C)=>{we.logger.info(`[ApplianceMultiPlugin] setViewLocalScenePathChange ${b} ${C}`),we.currentManager&&await we.currentManager.setViewLocalScenePathChange(C,b)},insertMarkmap:async(b,C)=>{if(we.logger.info(`[ApplianceMultiPlugin] insertMarkmap: ${b}, info: ${JSON.stringify(C)}`),we.currentManager&&we.currentManager.isUseBackgroundThread)return we.currentManager.worker.insertBackgroundMarkMap(b,C)},updateMarkmap:async(b,C,P)=>{if(we.logger.info(`[ApplianceMultiPlugin] updateMarkmap: ${b}, markmapId: ${C}, info: ${JSON.stringify(P)}`),we.currentManager&&we.currentManager.isUseBackgroundThread)return we.currentManager.worker.updateBackgroundMarkMap(b,C,P)},insertBackgroundImage:async(b,C)=>{if(we.logger.info(`[ApplianceMultiPlugin] insertBackgroundImage: ${b}, info: ${JSON.stringify(C)}`),we.currentManager&&we.currentManager.isUseBackgroundThread)return we.currentManager.worker.insertBackgroundSVG(b,C)},reloadBackgroundImage:async b=>{const C=we.currentManager;return C?C.reloadBackgroundImage(b):{accepted:!1,reloadedCount:0,reason:"viewNotFound"}},getSelectedElements:b=>{var C,P;return(P=(C=we.currentManager)==null?void 0:C.selectorApi)==null?void 0:P.getSelectedElements(b)},isElementPropertySupported:(b,C)=>{var P,E;return((E=(P=we.currentManager)==null?void 0:P.selectorApi)==null?void 0:E.isElementPropertySupported(b,C))||!1},blurSelector:b=>{var C;if(we.currentManager&&Le(s)&&s.isWritable){const P=(C=we.currentManager)==null?void 0:C.selectorApi;return P?P.blurSelector(b):Promise.resolve({ok:!1,requestId:`clear-${Date.now().toString(36)}`,viewId:b||Ue,reason:"no-selection"})}return Promise.resolve({ok:!1,requestId:`clear-${Date.now().toString(36)}`,viewId:b||Ue,reason:"no-selection"})},updateSelectedElements:(b,C)=>{var P;if(we.currentManager&&Le(s)&&s.isWritable){const E=(P=we.currentManager)==null?void 0:P.selectorApi;return E?E.updateSelectedElements(b,C):Promise.resolve({requestId:`update-${Date.now().toString(36)}`,viewId:b,ok:!1,reason:"no-selection"})}return Promise.resolve({requestId:`update-${Date.now().toString(36)}`,viewId:b,ok:!1,reason:"no-writable permission"})},updateElement:(b,C,P,E,O=!0)=>{var V;if(we.currentManager&&Le(s)&&s.isWritable){const N=(V=we.currentManager)==null?void 0:V.selectorApi;return N?N.updateElement(b,C,P,E,O):Promise.resolve(!1)}return Promise.resolve(!1)},copySelectedElements:b=>{var C;if(we.currentManager&&Le(s)&&s.isWritable){const P=(C=we.currentManager)==null?void 0:C.selectorApi;return P?P.copySelectedElements(b):Promise.resolve({ok:!1,requestId:`copy-${Date.now().toString(36)}`,viewId:b||Ue,reason:"no-selection"})}return Promise.resolve({ok:!1,requestId:`copy-${Date.now().toString(36)}`,viewId:b||Ue,reason:"no-selection"})},deleteSelectedElements:b=>{var C;if(we.currentManager&&Le(s)&&s.isWritable){const P=(C=we.currentManager)==null?void 0:C.selectorApi;return P?P.deleteSelectedElements(b):Promise.resolve({ok:!1,requestId:`delete-${Date.now().toString(36)}`,viewId:b||Ue,reason:"no-selection"})}return Promise.resolve({ok:!1,requestId:`delete-${Date.now().toString(36)}`,viewId:b||Ue,reason:"no-selection"})},getFloatbarContainer:b=>{var C;return(C=we.currentManager)==null?void 0:C.viewContainerManager.getFloatbarContainer(b)},getViewOffsetToContainer:(b,C)=>{var P;return(P=we.currentManager)==null?void 0:P.viewContainerManager.getViewOffsetToContainer(b,C)}};v.injectMethodToObject(e,"undo"),v.injectMethodToObject(e,"redo"),v.injectMethodToObject(e,"cleanCurrentScene"),v.injectMethodToObject(e,"blurSelector"),v.injectMethodToObject(e,"updateElement"),v.injectMethodToObject(e,"insertImage"),v.injectMethodToObject(e,"completeImageUpload"),v.injectMethodToObject(e,"lockImage"),v.injectMethodToObject(e,"insertText"),v.injectMethodToObject(e,"updateText"),v.injectMethodToObject(s,"getImagesInformation"),v.injectMethodToObject(s,"callbacks"),v.injectMethodToObject(s,"screenshotToCanvasAsync"),v.injectMethodToObject(s,"getBoundingRectAsync"),v.injectMethodToObject(s,"scenePreviewAsync"),v.injectMethodToObject(s,"fillSceneSnapshotAsync"),v.injectMethodToObject(s,"blurSelector"),v.injectMethodToObject(s,"updateElement"),v.injectMethodToObject(e.mainView,"setMemberState"),Le(s)&&v.injectMethodToObject(s,"setWritable"),Object.defineProperty(e,"canUndoSteps",{get(){return v.canUndoSteps()}}),Object.defineProperty(e,"canRedoSteps",{get(){return v.canRedoSteps()}});const I=(b,C,P=3)=>{const E=e.focused||Ue;P>0&&E!==b?setTimeout(()=>{I(b,C,P-1)},100):e.emitter.emit("canUndoStepsChange",C)};un.InternalMsgEmitter.on("onCanUndoStepsUpdate",(b,C)=>{I(C,b)});const D=(b,C,P=3)=>{const E=e.focused||Ue;P>0&&E!==b?setTimeout(()=>{D(b,C,P-1)},100):e.emitter.emit("canRedoStepsChange",C)};un.InternalMsgEmitter.on("onCanRedoStepsUpdate",(b,C)=>{D(C,b)});const x={...v,callbacks:v.callbacks()};Object.defineProperty(x,"disableDeviceInputs",{set(b){v.setDisableDeviceInputs(b)},get(){return v.getDisableDeviceInputs()}}),Object.defineProperty(x,"disableCameraTransform",{set(b){v.setDisableCameraTransform(b)},get(){return v.getDisableCameraTransform()}}),Object.defineProperty(x,"disableEraseImage",{set(b){v.setDisableEraseImage(b)},get(){return v.getDisableEraseImage()}}),p&&we.currentManager&&(we.currentManager.bindPlugin(p),p.init(s));const j=we.currentManager;e._appliancePlugin=x;const w=(M=we.currentManager)==null?void 0:M.pluginOptions.extras.cursor;w&&((T=we.currentManager)==null||T.worker.afterMainViewInitAck(()=>{$0(w)})),j==null||j.startInitFontFaceLoadAndRender();const y=await(j==null?void 0:j.worker.waitForMainViewInitAck());if(y!=="ready"||we.currentManager!==j)throw e._appliancePlugin===x&&delete e._appliancePlugin,new Error(`ApplianceMultiPlugin initialization ${y==="timeout"?"timed out":"was cancelled"}`);return x}static onCreate(e){e&&we.currentManager&&(we.currentManager.bindPlugin(e),e.init(e.displayer))}static async createApplianceMultiPlugin(e,r){try{await e.createInvisiblePlugin(we,{})}catch(s){if(!e.isWritable){await e.setWritable(!0);const o=await this.createApplianceMultiPlugin(e,r);return await e.setWritable(!1),o}throw s}let n=e.getInvisiblePlugin(r);return n||(n=await we.createApplianceMultiPlugin(e,r)),n}get isReplay(){return bu(this.displayer)}get callbackName(){return this.isReplay?"onPlayerStateChanged":"onRoomStateChanged"}init(e){var n,s;const r=e.state;(n=we.currentManager)==null||n.onRoomMembersChange(r.roomMembers),Le(e)&&((s=we.currentManager)==null||s.onMemberChange(r.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;we.logger.info("[ApplianceMultiPlugin] passive destroy"),(e=we.currentManager)==null||e.destroy(),we.currentManager=void 0}};R(we,"kind","appliance-multi-plugin"),R(we,"currentManager"),R(we,"logger",{info:console.log,warn:console.warn,error:console.error}),R(we,"createCurrentManager",(e,r,n,s)=>{we.currentManager&&we.currentManager.destroy();const o={plugin:n,displayer:e.displayer,options:r,onInitLoadingChange:s},a=new un(o);a.setWindowManager(e),we.currentManager=a});let yu=we;var w1e=Sr,T1e=function(){return w1e.Date.now()},S1e=T1e,I1e=/\s/;function C1e(i){for(var t=i.length;t--&&I1e.test(i.charAt(t)););return t}var b1e=C1e,x1e=b1e,E1e=/^\s+/;function A1e(i){return i&&i.slice(0,x1e(i)+1).replace(E1e,"")}var N1e=A1e,D1e=li,P1e=Nr,k1e="[object Symbol]";function L1e(i){return typeof i=="symbol"||P1e(i)&&D1e(i)==k1e}var R1e=L1e,O1e=N1e,tp=En,z1e=R1e,rp=NaN,j1e=/^[-+]0x[0-9a-f]+$/i,B1e=/^0b[01]+$/i,U1e=/^0o[0-7]+$/i,F1e=parseInt;function W1e(i){if(typeof i=="number")return i;if(z1e(i))return rp;if(tp(i)){var t=typeof i.valueOf=="function"?i.valueOf():i;i=tp(t)?t+"":t}if(typeof i!="string")return i===0?i:+i;i=O1e(i);var e=B1e.test(i);return e||U1e.test(i)?F1e(i.slice(2),e?2:8):j1e.test(i)?rp:+i}var $1e=W1e,V1e=En,wl=S1e,np=$1e,Y1e="Expected a function",G1e=Math.max,H1e=Math.min;function Q1e(i,t,e){var r,n,s,o,a,c,l=0,u=!1,h=!1,d=!0;if(typeof i!="function")throw new TypeError(Y1e);t=np(t)||0,V1e(e)&&(u=!!e.leading,h="maxWait"in e,s=h?G1e(np(e.maxWait)||0,t):s,d="trailing"in e?!!e.trailing:d);function g(f){var M=r,T=n;return r=n=void 0,l=f,o=i.apply(T,M),o}function p(f){return l=f,a=setTimeout(D,t),u?g(f):o}function v(f){var M=f-c,T=f-l,b=t-M;return h?H1e(b,s-T):b}function I(f){var M=f-c,T=f-l;return c===void 0||M>=t||M<0||h&&T>=s}function D(){var f=wl();if(I(f))return x(f);a=setTimeout(D,v(f))}function x(f){return a=void 0,d&&r?g(f):(r=n=void 0,o)}function j(){a!==void 0&&clearTimeout(a),l=0,r=c=n=a=void 0}function w(){return a===void 0?o:x(wl())}function y(){var f=wl(),M=I(f);if(r=arguments,n=this,c=f,M){if(a===void 0)return p(c);if(h)return clearTimeout(a),a=setTimeout(D,t),g(c)}return a===void 0&&(a=setTimeout(D,t)),o}return y.cancel=j,y.flush=w,y}var Z1e=Q1e,K1e=Z1e,q1e=En,X1e="Expected a function";function J1e(i,t,e){var r=!0,n=!0;if(typeof i!="function")throw new TypeError(X1e);return q1e(e)&&(r="leading"in e?!!e.leading:r,n="trailing"in e?!!e.trailing:n),K1e(i,t,{leading:r,maxWait:t,trailing:n})}var _1e=J1e;const ewe=en(_1e);class twe extends U0{constructor(e,r){super(e,r);R(this,"width",1e3);R(this,"height",1e3);R(this,"dpr",ji());R(this,"vDom");R(this,"eventTragetElement");R(this,"snapshotContainerRef");R(this,"backgroundContainerRef");R(this,"backgroundSnapshotContainerRef");R(this,"canvasContainerRef",G.createRef());R(this,"subLocalCanvasContainerRef");R(this,"canvasTopRef");R(this,"canvasServiceFloatRef",G.createRef());R(this,"canvasFloatRef",G.createRef());R(this,"canvasBgRef",G.createRef());R(this,"floatBarRef",G.createRef());R(this,"customFloatbarContainerRef",G.createRef());R(this,"containerOffset",{x:0,y:0});this.control.hasOffscreenCanvas||(this.snapshotContainerRef=G.createRef()),this.control.isUseSimple||(this.canvasTopRef=G.createRef(),this.subLocalCanvasContainerRef=G.createRef()),this.control.isUseBackgroundThread&&(this.backgroundContainerRef=G.createRef(),this.backgroundSnapshotContainerRef=G.createRef())}setCanvassStyle(){var e;if(this.eventTragetElement){const r=this.eventTragetElement.offsetWidth,n=this.eventTragetElement.offsetHeight,s=ji();s!==this.dpr&&(this.dpr=s,this.control.worker.updateDpr(this.viewId,this.dpr)),r&&n&&this.canvasContainerRef.current&&(r!==this.width||n!==this.height)&&(this.width=r,this.height=n),r&&n&&this.backgroundContainerRef&&this.backgroundContainerRef.current&&(r!==this.width||n!==this.height)&&(this.width=r,this.height=n,this.backgroundContainerRef.current.style.width=`${r}px`,this.backgroundContainerRef.current.style.height=`${n}px`,this.backgroundContainerRef.current.classList.toggle("appliance-plugin-background-isWritable",this.control.renderControl.isWritable)),r&&n&&this.canvasBgRef.current&&(r!==this.width||n!==this.height)&&(this.width=r,this.height=n,this.control.isUseOffscreenTransfer||(this.canvasBgRef.current.width=r*this.dpr,this.canvasBgRef.current.height=n*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=r*this.dpr,this.canvasFloatRef.current.height=n*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=r*this.dpr,this.canvasServiceFloatRef.current.height=n*this.dpr),(e=this.canvasTopRef)!=null&&e.current&&(this.canvasTopRef.current.width=r*this.dpr,this.canvasTopRef.current.height=n*this.dpr)))}}createMainViewDisplayer(e){return this.vDom||(this.containerOffset=this.getContainerOffset(e,this.containerOffset),this.eventTragetElement=e.parentElement.children[0],e.innerHTML="",Sa.render(G.createElement(Yh,{viewId:this.viewId,mananger:this,refs:{canvasServiceFloatRef:this.canvasServiceFloatRef,canvasFloatRef:this.canvasFloatRef,canvasBgRef:this.canvasBgRef,floatBarRef:this.floatBarRef,customFloatbarContainerRef:this.customFloatbarContainerRef,canvasTopRef:this.canvasTopRef,canvasContainerRef:this.canvasContainerRef,snapshotContainerRef:this.snapshotContainerRef,subLocalCanvasContainerRef:this.subLocalCanvasContainerRef,backgroundContainerRef:this.backgroundContainerRef,backgroundSnapshotContainerRef:this.backgroundSnapshotContainerRef}}),e),this.control.room&&this.bindDisplayerEvent(this.eventTragetElement)),this}}class Yn extends Oi{constructor(e){super(e);R(this,"focuedViewId");R(this,"control");R(this,"focuedView");this.control=e.control}bindMainView(){if(!this.control.divMainView)return;const e=new twe(this.control,Xe.InternalMsgEmitter),{width:r,height:n,dpr:s}=e,o={cameraOpt:{...Yn.defaultCameraOpt,width:r,height:n}},a=this.control.room&&this.control.room.mainView||this.control.play&&this.control.play.mainView;if(a){const{scale:c,...l}=a.camera;o.cameraOpt={...o.cameraOpt,...l,scale:c===1/0?1:c},this.createMianView({id:Ue,displayer:e,focusScenePath:a.focusScenePath||a.scenePath,cameraOpt:o.cameraOpt,viewData:a}),this.setFocuedViewId(Ue),e.createMainViewDisplayer(this.control.divMainView)}}getViewInitData(e){const r=this.getView(e);if(r){const{width:n,height:s,dpr:o}=r.displayer;this.control.renderingCompatibilityDecision.contextType&&(Yn.defaultScreenCanvasOpt.contextType=this.control.renderingCompatibilityDecision.contextType);const a={dpr:o,originalPoint:[n/2,s/2],offscreenCanvasOpt:{...Yn.defaultScreenCanvasOpt,width:n,height:s},layerOpt:{...Yn.defaultLayerOpt,width:n,height:s},cameraOpt:{...Yn.defaultCameraOpt,width:n,height:s}};if(r.viewData){const{scale:c,...l}=r.viewData.camera;a.cameraOpt={...a.cameraOpt,...l,scale:c===1/0?1:c}}return a}}async mountView(e){var n;const r=this.getView(e);if(r){this.control.emitInitLoadingChange({loading:!0,phase:"scene",status:"start"}),this.control.worker.isActive||(this.control.cursor.activeCollector(),this.control.isUseOffscreenTransfer&&r.displayer.canvasBgRef.current&&r.displayer.canvasServiceFloatRef.current&&r.displayer.canvasFloatRef.current&&r.displayer.setTransferControlToOffscreenCanvas({bgCanvas:r.displayer.canvasBgRef.current,serviceCanvas:r.displayer.canvasServiceFloatRef.current,localCanvas:r.displayer.canvasFloatRef.current}),await this.control.activeWorker());const s=this.getViewInitData(e);s&&((n=this.control.worker)==null||n.createViewWorker(e,s,r.displayer)),r.focusScenePath&&this.control.collector&&this.control.worker.pullServiceData(e,r.focusScenePath,{isAsync:!0,useAnimation:!1}),this.control.emitInitLoadingChange({loading:!0,phase:"scene",status:"success"}),this.control.emitInitLoadingChange({loading:!1,phase:"ready",status:"success"})}}}class or extends Xe{constructor(e){super(e);R(this,"viewContainerManager");R(this,"divMainView");R(this,"onCameraChange",ewe(e=>{var n;const r=this.viewContainerManager.mainView;r&&r.cameraOpt&&(r.cameraOpt.width!==e.width||r.cameraOpt.height!==e.height)&&((n=this.viewContainerManager.mainView)==null||n.displayer.updateSize()),this.viewContainerManager.setFocuedViewCameraOpt(e)},Ia,{leading:!1}));const r={control:this,internalMsgEmitter:or.InternalMsgEmitter,publicMsgEmitter:or.PublicMsgEmitter};this.viewContainerManager=new Yn(r)}init(){or.InternalMsgEmitter.on(Fe.BindMainView,e=>{this.divMainView=e,this.plugin&&!this.viewContainerManager.mainView&&this.viewContainerManager.bindMainView()})}activePlugin(){this.plugin&&this.divMainView&&!this.viewContainerManager.mainView&&this.viewContainerManager.bindMainView(),this.collector&&(this.collector.addStorageStateListener(e=>{var a,c;if((a=this.collector)!=null&&a.storage&&Object.keys(this.collector.storage).length===0){(c=this.worker)==null||c.clearViewScenePath(Ue,!0);return}const{diffView:r,diffScenePath:n,diffData:s}=e,o=new Map;if(r){let l;Object.keys(r).forEach(u=>{var d;const h=r[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 v of Object.keys(g))v&&p.add(v);o.set(u,p)}})}if(n){let l;Object.keys(n).forEach(u=>{var d;const h=n[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),o.set(h.viewId,g)}})}s&&Object.keys(s).forEach(l=>{var h,d;const u=s[l];if(u){const{viewId:g}=u,p=o.get(g)||new Set;p.add(l),o.set(g,p),(h=this.worker)==null||h.onServiceDerive(l,u),(d=this.miniMapManager)==null||d.updateMiniMapCamera(g)}});for(const[l,u]of o.entries())Xe.InternalMsgEmitter.emit("excludeIds",[...u],l)}),this.room&&(this.roomMember.onUidChangeHook(e=>{var r;(r=this.collector)!=null&&r.serviceStorage&&this.viewContainerManager.getAllViews().forEach(n=>{var s,o,a,c,l,u;if(n&&n.focusScenePath&&((s=this.collector)!=null&&s.serviceStorage[n.id])&&((o=this.collector)!=null&&o.serviceStorage[n.id][n.focusScenePath])){const h=Object.keys((a=this.collector)==null?void 0:a.serviceStorage[n.id][n.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:n.id,scenePath:n.focusScenePath,isSync:!0})),this.worker.blurSelector(n.id,n.focusScenePath,d);else{const p=this.textEditorManager.editors.get(d);p&&p.opt&&(p.opt.workState===ge.Doing||p.opt.workState===ge.Start)&&(pa(p.opt.text)?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 Me=class Me extends cp{constructor(){super(...arguments);R(this,"onPhaseChanged",e=>{var r;e===lp.Reconnecting&&((r=Me.currentManager)==null||r.setSnapshootData())});R(this,"updateRoomWritable",()=>{var e;(e=Me.currentManager)==null||e.onWritableChange(this.displayer.isWritable)});R(this,"roomStateChangeListener",async e=>{var r,n;Me.currentManager instanceof or&&(e.cameraState&&Me.currentManager.onCameraChange(e.cameraState),e.sceneState&&Me.currentManager.onSceneChange(e.sceneState.scenePath,Ue)),e!=null&&e.roomMembers&&((r=Me.currentManager)==null||r.onRoomMembersChange(e.roomMembers)),!(Le(this.displayer)&&!this.displayer.isWritable)&&e.memberState&&((n=Me.currentManager)==null||n.onMemberChange(e.memberState))})}static async getInstance(e,r){var j,w,y;const n=Le(e)&&e.logger||Me.logger,s=typeof navigator>"u"?"unknown":navigator.userAgent;n.info(`[Appliance]: [init-enter] version=${oc} userAgent=${s}`),(f=>{var M;try{(M=r.onInitLoadingChange)==null||M.call(r,f)}catch(T){Me.logger.error(`[ApplianceSinglePlugin] onInitLoadingChange error: ${(T==null?void 0:T.message)||T}`)}})({loading:!0,phase:"plugin",status:"start"});const a=e.callbacks.on,c=e.callbacks.off,l=e.callbacks.once,u=e.cleanCurrentScene.bind(e),h=e.setMemberState.bind(e);let d;Le(e)&&(d=e.setWritable),r!=null&&r.logger&&(Me.logger=new $h(r.logger));let g=e.getInvisiblePlugin(Me.kind);g||(g=await Me.createAppliancePlugin(e,Me.kind)),e&&g&&Me.createCurrentManager(e,{cdn:r.options.cdn,extras:Hy(r.options.extras)},g,r.onInitLoadingChange),g&&Me.currentManager&&(Me.currentManager.bindPlugin(g),g.init(e)),r!=null&&r.cursorAdapter&&(Me.cursorAdapter=r.cursorAdapter),Me.effectInstance(),(j=Me.currentManager)==null||j.emitInitLoadingChange({loading:!0,phase:"plugin",status:"success"});const p={displayer:e,currentManager:Me.currentManager,maxScreenshotWidth:10*1024,maxScreenshotHeight:10*1024,_injectTargetObject:void 0,getBoundingRectAsync:async function(f){var b;Me.logger.info("[ApplianceSinglePlugin] getBoundingRectAsync");const M=e.getBoundingRect(f),T=await((b=Me.currentManager)==null?void 0:b.getBoundingRect(f));return!M.width||!M.height?T:zh(M,T)},screenshotToCanvasAsync:async function(f,M,T,b,C,P){var k;Me.logger.info("[ApplianceSinglePlugin] screenshotToCanvasAsync");let E=T,O=b,V=C.scale;E>this.maxScreenshotWidth&&(V=this.maxScreenshotWidth/E*V,E=this.maxScreenshotWidth),O>this.maxScreenshotHeight&&(V=Math.min(this.maxScreenshotHeight/O*V,V),O=this.maxScreenshotHeight),C.scale=V;const N=document.createElement("canvas"),A=N.getContext("2d");N.width=E*(P||1),N.height=O*(P||1),A&&(e.screenshotToCanvas(A,M,E,O,C,P),f.drawImage(N,Math.floor((T-E)/2),Math.floor((b-O)/2),E*(P||1),O*(P||1),0,0,E,O),N.remove()),Me.currentManager&&await((k=Me.currentManager)==null?void 0:k.screenshotToCanvas(f,M,E,O,C,Math.floor((T-E)/2),Math.floor((b-O)/2)))},scenePreviewAsync:async function(f,M,T,b,C){Me.logger.info("[ApplianceSinglePlugin] scenePreviewAsync"),e.scenePreview(f,M,T,b,C);const P=document.createElement("img");P.className="appliance-plugin-fill-scene-snapshot-img",M.append(P),getComputedStyle(M).position||(M.style.position="relative"),Me.currentManager&&await Me.currentManager.scenePreview(f,P)},fillSceneSnapshotAsync:async function(f,M,T,b,C){var W,H;Me.logger.info("[ApplianceSinglePlugin] fillSceneSnapshotAsync"),M.innerHTML="",e.fillSceneSnapshot(f,M,T,b,C);const P=T||((W=e.state.cameraState)==null?void 0:W.width)||0,E=b||((H=e.state.cameraState)==null?void 0:H.height)||0;let O=await this.getBoundingRectAsync(f);O||(O={originX:0,originY:0,width:P,height:E});let V=Math.max(O==null?void 0:O.width,P),N=Math.max(O==null?void 0:O.height,E),A=1;const k=V>P&&Math.min(P/V,A)||A,U=N>E&&Math.min(E/N,A)||A;k<=U?(V=k<1&&P||V,N=Math.floor(N*k)+1,A=k):k>U&&(N=U<1&&E||N,V=Math.floor(V*U)+1,A=U);const Z={scale:A,centerX:O.originX+O.width/2,centerY:O.originY+O.height/2},Q=document.createElement("canvas"),ce=Q.getContext("2d");Q.width=V,Q.height=N,ce&&await this.screenshotToCanvasAsync(ce,f,V,N,Z,devicePixelRatio);const L=document.createElement("img");L.className="appliance-plugin-fill-scene-snapshot-img",L.src=Q.toDataURL(),L.onload=()=>{Q.remove()},L.onerror=()=>{Q.remove(),L.remove()},M.append(L),getComputedStyle(M).position||(M.style.position="relative")},_callbacksOn:function(f,M){(f==="onCanUndoStepsUpdate"||f==="onCanRedoStepsUpdate")&&Le(e)&&e.isWritable?or.InternalMsgEmitter.on(f,M):a.call(e.callbacks,f,M)},_callbacksOnce:function(f,M){(f==="onCanUndoStepsUpdate"||f==="onCanRedoStepsUpdate")&&Le(e)&&e.isWritable?or.InternalMsgEmitter.on(f,M):l.call(e.callbacks,f,M)},_callbacksOff:function(f,M){(f==="onCanUndoStepsUpdate"||f==="onCanRedoStepsUpdate")&&Le(e)&&e.isWritable?or.InternalMsgEmitter.off(f,M):c.call(e.callbacks,f,M)},canRedoSteps(){if(Me.logger.info("[ApplianceSinglePlugin] canRedoSteps"),Me.currentManager&&Le(e)&&!e.disableSerialization){const f=Me.currentManager.viewContainerManager.focuedView,M=f==null?void 0:f.focusScenePath;if(f&&M)return f.displayer.commiter.redoStack.filter(T=>T.scenePath===M).length}return 0},canUndoSteps(){if(Me.logger.info("[ApplianceSinglePlugin] canUndoSteps"),Me.currentManager&&Le(e)&&!e.disableSerialization){const f=Me.currentManager.viewContainerManager.focuedView,M=f==null?void 0:f.focusScenePath;if(f&&M)return f.displayer.commiter.undoStack.filter(T=>T.scenePath===M).length}return 0},undo:function(){return Me.logger.info("[ApplianceSinglePlugin] undo"),Me.currentManager&&Le(e)&&!e.disableSerialization?Me.currentManager.viewContainerManager.undo():0},redo:function(){return Me.logger.info("[ApplianceSinglePlugin] redo"),Me.currentManager&&Le(e)&&!e.disableSerialization?Me.currentManager.viewContainerManager.redo():0},cleanCurrentScene:function(f){Me.logger.info("[ApplianceSinglePlugin] cleanCurrentScene"),Me.currentManager&&Le(e)&&e.isWritable&&Me.currentManager.cleanCurrentScene().then(()=>{u.call(e,f)}).catch(M=>{var T;(T=Me.currentManager)==null||T.logger.error(`[Appliance]: cleanCurrentScene failed: ${(M==null?void 0:M.message)||M}`)})},insertImage:function(f){Me.logger.info("[ApplianceSinglePlugin] insertImage"),Me.currentManager&&Le(e)&&e.isWritable&&Me.currentManager.worker.insertImage(Ue,f)},lockImage:function(f,M){Me.logger.info("[ApplianceSinglePlugin] lockImage"),Me.currentManager&&Le(e)&&e.isWritable&&Me.currentManager.worker.lockImage(Ue,f,M)},completeImageUpload:function(f,M){Me.logger.info("[ApplianceSinglePlugin] completeImageUpload"),Me.currentManager&&Le(e)&&e.isWritable&&Me.currentManager.worker.completeImageUpload(Ue,f,M)},getImagesInformation:function(f){return Me.logger.info("[ApplianceSinglePlugin] completeImageUpload"),Me.currentManager&&Le(e)&&e.isWritable?Me.currentManager.worker.getImagesInformation(f):[]},insertText:function(f,M,T){if(Me.logger.info("[ApplianceSinglePlugin] insertText"),Me.currentManager&&Le(e)&&e.isWritable)return Me.currentManager.textEditorManager.insertText(Ue,f,M,T)},updateText:function(f,M){Me.logger.info("[ApplianceMultiPlugin] updateText"),Me.currentManager&&Le(e)&&e.isWritable&&Me.currentManager.textEditorManager.updateText(f,M)},callbacks:()=>({...e.callbacks,on:p._callbacksOn.bind(p),once:p._callbacksOnce.bind(p),off:p._callbacksOff.bind(p)}),destroy(){Me.currentManager&&(Me.logger.info("[ApplianceSinglePlugin] destroy"),Me.currentManager.destroy(),Me.currentManager=void 0,Me.cursorAdapter=void 0)},setMemberState(f){var T,b,C;Me.logger.info(`[ApplianceSinglePlugin] setMemberState ${JSON.stringify(f)}`);const M=Object.keys(f);if(Le(e)&&e.isWritable){if(M.includes("currentApplianceName"))if((T=Me.currentManager)==null||T.requestToolChange(f),f.currentApplianceName&&f.currentApplianceName===Ne.laserPen){if((b=Me.currentManager)!=null&&b.isUseSimple)throw new Error("[ApplianceMultiPlugin] laserPen must be not support in simple mode");f.currentApplianceName=Ne.pencil,f.useLaserPen=!0}else f.currentApplianceName&&f.currentApplianceName===Ne.pencil&&(f.useLaserPen=!1);try{h(f)}catch(P){throw(C=Me.currentManager)==null||C.setToolChangePending(!1,"set-member-state-error"),P}return}throw new Error("setMemberState must be called in writable room")},createMiniMap:async function(f,M){if(Me.logger.info("[ApplianceSinglePlugin] createMiniMap"),Me.currentManager&&Le(e)&&e.isWritable)return Me.currentManager.createMiniMap(f,M)},destroyMiniMap:async function(f){if(Me.logger.info("[ApplianceMultiPlugin] destroyeMiniMap"),Me.currentManager&&Le(e)&&e.isWritable)return Me.currentManager.destroyMiniMap(f)},filterRenderByUid(f,M,T){if(Me.logger.info("[ApplianceSinglePlugin] filterRenderByUid"),Me.currentManager&&Le(e)&&e.isWritable)return Me.currentManager.filterRenderByUid(f,M,T)},cancelFilterRender(f,M){if(Me.logger.info("[ApplianceSinglePlugin] filterRenderByUid"),Me.currentManager&&Le(e)&&e.isWritable)return Me.currentManager.cancelFilterRender(f,M)},addListener:(f,M)=>{or.PublicMsgEmitter.on(f,M)},removeListener:(f,M)=>{or.PublicMsgEmitter.off(f,M)},usePlugin:f=>{var M;Me.logger.info("[ApplianceSinglePlugin] usePlugin",f.kind),(M=Me.currentManager)==null||M.usePlugin(f)},getDisableDeviceInputs(){if(Me.currentManager&&Le(e))return Me.currentManager.disableDeviceInputs},setDisableDeviceInputs(f){Me.logger.info(`[ApplianceSinglePlugin] setDisableDeviceInputs ${f}`),Me.currentManager&&Le(e)&&(Me.currentManager.disableDeviceInputs=f)},getDisableCameraTransform(){if(Me.currentManager&&Le(e))return Me.currentManager.disableCameraTransform},setDisableCameraTransform(f){Me.logger.info(`[ApplianceSinglePlugin] setDisableCameraTransform ${f}`),Me.currentManager&&Le(e)&&(Me.currentManager.disableCameraTransform=f)},getDisableEraseImage(){if(Me.currentManager&&Le(e))return Me.currentManager.disableEraseImage},setDisableEraseImage(f){Me.logger.info(`[ApplianceSinglePlugin] setDisableEraseImage ${f}`),Me.currentManager&&Le(e)&&(Me.currentManager.disableEraseImage=f)},setWritable:async function(f){var M;Me.logger.info(`[ApplianceSinglePlugin] setWritable ${f}`),Le(e)&&d&&(await((M=Me.currentManager)==null?void 0:M.setWritable(f)),await d.call(e,f))},requestIdleCallback:(f,M)=>{const T=(M==null?void 0:M.timeout)||0,b=performance.now();let C;const P=new MessageChannel;let E;const O=V=>{try{f({didTimeout:V,timeRemaining:()=>{const A=performance.now()-b;return Math.max(0,T-A)}})}catch(N){Me.logger.error("[ApplianceSinglePlugin] requestIdleCallback error:",N)}finally{P.port1.close(),P.port2.close(),C!==void 0&&cancelAnimationFrame(C),E!==void 0&&clearTimeout(E)}};return P.port1.onmessage=()=>{C=requestAnimationFrame(()=>{T>0&&performance.now()-b>=T?O(!0):O(!1)})},P.port2.postMessage(null),T>0&&(E=setTimeout(()=>{O(!0)},T)),E||C||0},cancelIdleCallback:f=>{try{clearTimeout(f),cancelAnimationFrame(f)}catch(M){Me.logger.error("[ApplianceSinglePlugin] cancelIdleCallback error:",M)}},injectMethodToObject:(f,M)=>{if(typeof f[M]=="function"||typeof f[M]>"u"){f[M]=p[M];return}M==="callbacks"&&(f.callbacks.on=p._callbacksOn.bind(p),f.callbacks.off=p._callbacksOff.bind(p),f.callbacks.once=p._callbacksOnce.bind(p))},blurText:()=>{Me.logger.info("[ApplianceSinglePlugin] blurText"),Me.currentManager&&Le(e)&&e.isWritable&&Me.currentManager.textEditorManager.checkEmptyTextBlur()},hasElements:(f,M)=>{var T;if(Me.logger.info(`[ApplianceSinglePlugin] hasElements ${f}`),Me.currentManager&&Le(e)&&e.isWritable){let b=f;if(!b){const C=Me.currentManager.viewContainerManager.focuedView;b=C==null?void 0:C.focusScenePath}if(b){const C=(T=Me.currentManager.collector)==null?void 0:T.getScenePathData(b);if(C){const P=Object.values(C);return P.length>0?M?P.some(E=>M(E.toolsType)):!0:!1}return!1}return!1}},getElements:(f,M)=>{var T;if(Me.logger.info(`[ApplianceSinglePlugin] getElements ${f}`),Me.currentManager&&Le(e)&&e.isWritable){let b=f;if(!b){const C=Me.currentManager.viewContainerManager.focuedView;b=C==null?void 0:C.focusScenePath}if(b){const C=(T=Me.currentManager.collector)==null?void 0:T.getScenePathData(b),P=C&&Object.values(C)||[];return C&&P.length>0&&M?P.filter(E=>M(E.toolsType)):P}return[]}},hasBackgroundImage:f=>{var M,T;return V0((T=(M=Me.currentManager)==null?void 0:M.collector)==null?void 0:T.storage,f)},stopDraw:f=>{if(Me.logger.info(`[ApplianceSinglePlugin] stopDraw ${f}`),Me.currentManager&&Le(e))return Me.currentManager.stopDraw(f)},loadFontFaces:()=>{var f;return Me.logger.info("[ApplianceSinglePlugin] loadFontFaces"),((f=Me.currentManager)==null?void 0:f.loadFontFaces())||Promise.resolve({status:"error"})},refreshViewRender:f=>{var M;return Me.logger.info(`[ApplianceSinglePlugin] refreshViewRender ${f}`),((M=Me.currentManager)==null?void 0:M.refreshViewRender(f))||Promise.resolve({status:"error"})},refreshRender:()=>{var f;return Me.logger.info("[ApplianceSinglePlugin] refreshRender"),((f=Me.currentManager)==null?void 0:f.refreshRender())||Promise.resolve({status:"error"})},refreshViewTextRender:f=>{var M;return Me.logger.info(`[ApplianceSinglePlugin] refreshViewTextRender ${f}`),((M=Me.currentManager)==null?void 0:M.refreshViewTextRender(f))||Promise.resolve({status:"error"})},refreshTextRender:()=>{var f;return Me.logger.info("[ApplianceSinglePlugin] refreshTextRender"),((f=Me.currentManager)==null?void 0:f.refreshTextRender())||Promise.resolve({status:"error"})},setViewLocalScenePathChange:async(f,M)=>{Me.logger.info(`[ApplianceSinglePlugin] setViewLocalScenePathChange ${f} ${M}`),Me.currentManager&&await Me.currentManager.setViewLocalScenePathChange(f,M)},insertMarkmap:async(f,M)=>{if(Me.logger.info(`[ApplianceSinglePlugin] insertMarkmap: ${f}, info: ${JSON.stringify(M)}`),Me.currentManager&&Me.currentManager.isUseBackgroundThread)return Me.currentManager.worker.insertBackgroundMarkMap(f,M)},updateMarkmap:async(f,M,T)=>{if(Me.logger.info(`[ApplianceSinglePlugin] updateMarkmap: ${f}, markmapId: ${M}, info: ${JSON.stringify(T)}`),Me.currentManager&&Me.currentManager.isUseBackgroundThread)return Me.currentManager.worker.updateBackgroundMarkMap(f,M,T)},insertBackgroundImage:async(f,M)=>{if(Me.logger.info(`[ApplianceSinglePlugin] insertBackgroundImage: ${f}, info: ${JSON.stringify(M)}`),Me.currentManager&&Me.currentManager.isUseBackgroundThread)return Me.currentManager.worker.insertBackgroundSVG(f,M)},reloadBackgroundImage:async f=>{const M=Me.currentManager;return M?M.reloadBackgroundImage(f):{accepted:!1,reloadedCount:0,reason:"viewNotFound"}},getSelectedElements:f=>{var M,T;return(T=(M=Me.currentManager)==null?void 0:M.selectorApi)==null?void 0:T.getSelectedElements(f)},isElementPropertySupported:(f,M)=>{var T,b;return((b=(T=Me.currentManager)==null?void 0:T.selectorApi)==null?void 0:b.isElementPropertySupported(f,M))||!1},blurSelector:f=>{var M;if(Me.currentManager&&Le(e)&&e.isWritable){const T=(M=Me.currentManager)==null?void 0:M.selectorApi;return T?T.blurSelector(f):Promise.resolve({ok:!1,requestId:`clear-${Date.now().toString(36)}`,viewId:f||Ue,reason:"no-selection"})}return Promise.resolve({ok:!1,requestId:`clear-${Date.now().toString(36)}`,viewId:f||Ue,reason:"no-selection"})},updateSelectedElements:f=>{var M;if(Me.currentManager&&Le(e)&&e.isWritable){const T=(M=Me.currentManager)==null?void 0:M.selectorApi;return T?T.updateSelectedElements(Ue,f):Promise.resolve({requestId:`update-${Date.now().toString(36)}`,viewId:Ue,ok:!1,reason:"no-selection"})}return Promise.resolve({requestId:`update-${Date.now().toString(36)}`,viewId:Ue,ok:!1,reason:"no-writable permission"})},updateElement:(f,M,T,b,C=!0)=>{var P;if(Me.currentManager&&Le(e)&&e.isWritable){const E=(P=Me.currentManager)==null?void 0:P.selectorApi;return E?E.updateElement(f,M,T,b,C):Promise.resolve(!1)}return Promise.resolve(!1)},copySelectedElements:f=>{var M;if(Me.currentManager&&Le(e)&&e.isWritable){const T=(M=Me.currentManager)==null?void 0:M.selectorApi;return T?T.copySelectedElements(f):Promise.resolve({ok:!1,requestId:`copy-${Date.now().toString(36)}`,viewId:f||Ue,reason:"no-selection"})}return Promise.resolve({ok:!1,requestId:`copy-${Date.now().toString(36)}`,viewId:f||Ue,reason:"no-selection"})},deleteSelectedElements:f=>{var M;if(Me.currentManager&&Le(e)&&e.isWritable){const T=(M=Me.currentManager)==null?void 0:M.selectorApi;return T?T.deleteSelectedElements(f):Promise.resolve({ok:!1,requestId:`delete-${Date.now().toString(36)}`,viewId:f||Ue,reason:"no-selection"})}return Promise.resolve({ok:!1,requestId:`delete-${Date.now().toString(36)}`,viewId:f||Ue,reason:"no-selection"})},getFloatbarContainer:f=>{var M;return(M=Me.currentManager)==null?void 0:M.viewContainerManager.getFloatbarContainer(f)},getViewOffsetToContainer:(f,M)=>{var T;return(T=Me.currentManager)==null?void 0:T.viewContainerManager.getViewOffsetToContainer(f,M)}};p.injectMethodToObject(e,"undo"),p.injectMethodToObject(e,"redo"),p.injectMethodToObject(e,"cleanCurrentScene"),p.injectMethodToObject(e,"blurSelector"),p.injectMethodToObject(e,"updateElement"),p.injectMethodToObject(e,"insertImage"),p.injectMethodToObject(e,"completeImageUpload"),p.injectMethodToObject(e,"lockImage"),p.injectMethodToObject(e,"getImagesInformation"),p.injectMethodToObject(e,"insertText"),p.injectMethodToObject(e,"updateText"),p.injectMethodToObject(e,"callbacks"),p.injectMethodToObject(e,"screenshotToCanvasAsync"),p.injectMethodToObject(e,"getBoundingRectAsync"),p.injectMethodToObject(e,"scenePreviewAsync"),p.injectMethodToObject(e,"fillSceneSnapshotAsync"),p.injectMethodToObject(e,"setMemberState"),Le(e)&&p.injectMethodToObject(e,"setWritable"),Object.defineProperty(e,"canUndoSteps",{get(){return p.canUndoSteps()}}),Object.defineProperty(e,"canRedoSteps",{get(){return p.canRedoSteps()}});const v={...p,callbacks:p.callbacks()};Object.defineProperty(v,"disableDeviceInputs",{set(f){p.setDisableDeviceInputs(f)},get(){return p.getDisableDeviceInputs()}}),Object.defineProperty(v,"disableEraseImage",{set(f){p.setDisableEraseImage(f)},get(){return p.getDisableEraseImage()}}),Object.defineProperty(v,"disableCameraTransform",{set(f){p.setDisableCameraTransform(f)},get(){return p.getDisableCameraTransform()}});const I=Me.currentManager;e._appliancePlugin=v;const D=(w=Me.currentManager)==null?void 0:w.pluginOptions.extras.cursor;D&&((y=Me.currentManager)==null||y.worker.afterMainViewInitAck(()=>{$0(D)})),I==null||I.startInitFontFaceLoadAndRender();const x=await(I==null?void 0:I.worker.waitForMainViewInitAck());if(x!=="ready"||Me.currentManager!==I)throw e._appliancePlugin===v&&delete e._appliancePlugin,new Error(`ApplianceSinglePlugin initialization ${x==="timeout"?"timed out":"was cancelled"}`);return v}static onCreate(e){e&&Me.currentManager&&(Me.currentManager.bindPlugin(e),e.init(e.displayer))}static async createAppliancePlugin(e,r){try{await e.createInvisiblePlugin(Me,{})}catch(s){if(!e.isWritable){await e.setWritable(!0);const o=await this.createAppliancePlugin(e,r);return await e.setWritable(!1),o}throw s}let n=e.getInvisiblePlugin(r);return n||(n=await Me.createAppliancePlugin(e,r)),n}static effectInstance(){if(Me.cursorAdapter){const e=Me.cursorAdapter.onAddedCursor;Me.cursorAdapter.onAddedCursor=function(r){r.onCursorMemberChanged=n=>{try{n.appliance===Ne.pencil||n.appliance===Ne.shape||n.appliance===Ne.text||n.appliance===Ne.arrow||n.appliance===Ne.straight||n.appliance===Ne.rectangle||n.appliance===Ne.ellipse||n.appliance===Ne.eraser||n.appliance===Ne.selector?r!=null&&r.divElement&&(r.divElement.style.display="none"):r!=null&&r.divElement&&(r.divElement.style.display="block")}catch(s){throw s}},e.call(Me.cursorAdapter,r)}}}get isReplay(){return bu(this.displayer)}get callbackName(){return this.isReplay?"onPlayerStateChanged":"onRoomStateChanged"}init(e){var n,s;const r=e.state;(n=Me.currentManager)==null||n.onRoomMembersChange(r.roomMembers),Le(e)&&r!=null&&r.memberState&&((s=Me.currentManager)==null||s.onMemberChange(r.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;Me.logger.info("[ApplianceSinglePlugin] passive destroy"),(e=Me.currentManager)==null||e.destroy(),Me.currentManager=void 0,Me.cursorAdapter=void 0}};R(Me,"kind","appliance-single-plugin"),R(Me,"cursorAdapter"),R(Me,"currentManager"),R(Me,"logger",{info:console.log,warn:console.warn,error:console.error}),R(Me,"createCurrentManager",(e,r,n,s)=>{Me.currentManager&&Me.currentManager.destroy();const o={plugin:n,displayer:e,options:r,onInitLoadingChange:s},a=new or(o);a.init(),Me.logger.info("[ApplianceSinglePlugin] refresh ApplianceSingleManager object"),Me.currentManager=a});let vu=Me;const ki=class ki extends G.Component{constructor(){super(...arguments);R(this,"mainViewRef",null)}componentDidMount(){ki.emiter||(ki.emiter=or.InternalMsgEmitter),ki.emiter.emit(Fe.BindMainView,this.mainViewRef)}render(){return G.createElement(G.Fragment,null,this.props.children,G.createElement("div",{className:"appliance-plugin-main-view-displayer",ref:e=>this.mainViewRef=e}))}};R(ki,"emiter");let Mu=ki;const rwe=Object.freeze(Object.defineProperty({__proto__:null,ActiveContainerType:op,ApplianceMultiPlugin:yu,ApplianceNames:Ne,AppliancePluginCursorNames:rr,ApplianceSigleWrapper:Mu,ApplianceSinglePlugin:vu,Cursor_Hover_Id:ap,ECanvasShowType:_e,EDataType:Ee,EForceStopReason:Cu,EImageType:qr,EMatrixrRelationType:Kr,EOperationType:yt,EPostMessageType:he,ERenderFilterType:gr,ESVGType:Li,EScaleType:Ve,EStrokeType:ze,EToolsKey:K,ElayerType:Mn,EmitEventType:Se,EventMessageType:Ts,EventWorkState:ge,EvevtWorkState:ge,InternalMsgEmitterType:Fe,Main_View_Id:Ue,ShapeType:Gt,Task_Time_Interval:Ia,WorkerCanvasContextBlacklistLevel:Qn,WorkerImageBitmapFeatureBlacklistLevel:Iu,WorkerMaskTextureFormatBlacklistLevel:Tu,WorkerMaskTextureUploadBlacklistLevel:Su,WorkerRenderModeBlacklistLevel:mr},Symbol.toStringTag,{value:"Module"}));exports.Cursor_Hover_Id=ap;exports.DefaultAppliancePluginExtrasOptions=He;exports.ECanvasShowType=_e;exports.EDataType=Ee;exports.EImageType=qr;exports.EMatrixrRelationType=Kr;exports.EPostMessageType=he;exports.ESVGType=Li;exports.EToolsKey=K;exports.EmitEventType=Se;exports.EventWorkState=ge;exports.Group=dt;exports.Main_View_Id=Ue;exports.MaxDelayBatchScheduler=w0;exports.ObserverMap=au;exports.Scene=qa;exports.Storage_Selector_key=De;exports.Storage_Splitter=Rt;exports.Storage_ViewId_ALL=ou;exports.Task_Time_Interval=Ia;exports.VNodeManager=v0;exports.ViewContainerManager=Oi;exports.acceptIncomingEraserGeometryDelta=dge;exports.cancelDoingForGeometryMismatch=oge;exports.computRect=Ge;exports.getEraserBatchDelay=T0;exports.getIconImageSrc=M0;exports.getMarkmapRuntimeOrThrow=O0;exports.getOutgoingEraserGeometryDelta=ige;exports.getRectMatrixrRelation=hc;exports.getSafetyRect=fn;exports.getShapeInstance=Oh;exports.index=rwe;exports.isEqual=Zr;exports.isIntersectForPoint=A0;exports.isNumber=It;exports.removeAllChildren=ar;exports.removeTexture=cr;exports.resolveCursorToolName=cc;exports.transformToNormalData=Nn;exports.transformToSerializableData=xt;