@netless/appliance-plugin 1.1.39 → 1.1.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/appliance-plugin.js +1 -1
- package/dist/appliance-plugin.mjs +1 -1
- package/dist/{bridge-CHAFBa3k.js → bridge-DLEmhE7Y.js} +1 -1
- package/dist/{bridge-CYWXPQ84.mjs → bridge-b23MKtwT.mjs} +1 -1
- package/dist/bridge.js +1 -1
- package/dist/bridge.mjs +1 -1
- package/dist/component/textEditor/utils.d.ts +1 -0
- package/dist/core/currentSceneGuard.d.ts +8 -0
- package/dist/core/mainThread/base.d.ts +1 -0
- package/dist/core/mainThread/lifecycle.d.ts +14 -0
- package/dist/fullWorker.js +78 -78
- package/dist/{index-b8vebU--.mjs → index-BSR23bx5.mjs} +95 -70
- package/dist/{index-CR1hkggk.mjs → index-C3XOupI-.mjs} +95 -70
- package/dist/{index-CcC63woo.js → index-CDDMgpaL.js} +1 -1
- package/dist/{index-BZgfPcL0.js → index-CDbcv4B7.js} +1 -1
- package/dist/{index-YgdyZP_3.js → index-DKaa5HSe.js} +1 -1
- package/dist/index-DoIyQYzA.js +570 -0
- package/dist/{index-BPWZCEwU.js → index-DwW4gzgA.js} +1 -1
- package/dist/{index-CYV4mPpp.mjs → index-GpA_9BZu.mjs} +2746 -2641
- package/dist/index-RKd-OVPO.js +570 -0
- package/dist/{index-C7gY405v.mjs → index-WifS74pI.mjs} +1 -1
- package/dist/{index-C8KlJXk3.mjs → index-pyv2KvXa.mjs} +1 -1
- package/dist/{index-cYVyBD7Q.mjs → index-rhSRO8Tb.mjs} +5621 -5530
- package/dist/plugin/sceneChangeProgress.d.ts +7 -0
- package/dist/subWorker.js +77 -77
- package/package.json +3 -2
- package/dist/index-dVlV22UP.js +0 -570
- package/dist/index-gq2ek7io.js +0 -570
package/dist/index-dVlV22UP.js
DELETED
|
@@ -1,570 +0,0 @@
|
|
|
1
|
-
"use strict";var B0=Object.defineProperty;var U0=(i,t,e)=>t in i?B0(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var L=(i,t,e)=>U0(i,typeof t!="symbol"?t+"":t,e);const Ne=require("white-web-sdk"),Tt=require("clipper-lib"),Jg=require("lz-string"),pu=require("lineclip"),vl=require("xss"),ve=require("lodash"),F0=require("rbush"),Ml=require("eventemitter2"),W0=require("./markmap-runtime-CsBCTpRs.js"),G=require("react"),Ma=require("react-dom"),zi=require("react-draggable"),$0=require("re-resizable");var De=(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))(De||{}),mr=(i=>(i[i.OffscreenTransfer=1]="OffscreenTransfer",i[i.ImageBitmap=2]="ImageBitmap",i))(mr||{}),wa=(i=>(i[i.WebGL=1]="WebGL",i))(wa||{}),mu=(i=>(i[i.SingleChannelTexture=1]="SingleChannelTexture",i))(mu||{}),yu=(i=>(i[i.TextureSubImage2D=1]="TextureSubImage2D",i))(yu||{}),vu=(i=>(i[i.DirtyRect=1]="DirtyRect",i))(vu||{}),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||{}),_g=(i=>(i[i.MainView=0]="MainView",i[i.Plugin=1]="Plugin",i[i.Both=2]="Both",i))(_g||{}),Mu=(i=>(i.longPencil="longPencil",i))(Mu||{}),Z=(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))(Z||{}),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||{}),tt=(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))(tt||{}),vs=(i=>(i[i.Cursor=1]="Cursor",i[i.TextCreate=2]="TextCreate",i))(vs||{}),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||{}),pn=(i=>(i[i.inside=0]="inside",i[i.outside=1]="outside",i[i.intersect=2]="intersect",i))(pn||{}),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||{}),mn=(i=>(i.Image="image",i.Iconify="iconify",i))(mn||{}),Ms=(i=>(i.url="url",i.markmap="markmap",i))(Ms||{});const V0="cursorhover",wu=20,Ue="mainView",Y0={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=Y0.easeInQuad(s/(r-1)),a=fe.Lrp(t,e,o);a.z=Math.min(1,.5+Math.abs(.5-G0(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 G0=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 di=1e-6,xs=typeof Float32Array<"u"?Float32Array:Array;function qe(i){xs=i}function H0(){var i=new xs(6);return xs!=Float32Array&&(i[1]=0,i[2]=0,i[4]=0,i[5]=0),i[0]=1,i[3]=1,i}function Q0(i){var t=new xs(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 Z0(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 K0(i){return i[0]=1,i[1]=0,i[2]=0,i[3]=1,i[4]=0,i[5]=0,i}function Hn(i,t,e,r,n,s){var o=new xs(6);return o[0]=i,o[1]=t,o[2]=e,o[3]=r,o[4]=n,o[5]=s,o}function q0(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 qo(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 X0(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 ep(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 J0(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 wl(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 _0(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 ev(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 tv(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 rv(i){return"mat2d("+i[0]+", "+i[1]+", "+i[2]+", "+i[3]+", "+i[4]+", "+i[5]+")"}function nv(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 iv(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 tp(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 sv(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 ov(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 av(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 cv(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)<=di*Math.max(1,Math.abs(e),Math.abs(c))&&Math.abs(r-l)<=di*Math.max(1,Math.abs(r),Math.abs(l))&&Math.abs(n-u)<=di*Math.max(1,Math.abs(n),Math.abs(u))&&Math.abs(s-h)<=di*Math.max(1,Math.abs(s),Math.abs(h))&&Math.abs(o-d)<=di*Math.max(1,Math.abs(o),Math.abs(d))&&Math.abs(a-g)<=di*Math.max(1,Math.abs(a),Math.abs(g))}var lv=Er,uv=tp;const rp=Object.freeze(Object.defineProperty({__proto__:null,add:iv,clone:Q0,copy:Z0,create:H0,determinant:X0,equals:cv,exactEquals:av,frob:nv,fromRotation:_0,fromScaling:ev,fromTranslation:tv,fromValues:Hn,identity:K0,invert:qo,mul:lv,multiply:Er,multiplyScalar:sv,multiplyScalarAndAdd:ov,rotate:ep,scale:J0,set:q0,str:rv,sub:uv,subtract:tp,translate:wl},Symbol.toStringTag,{value:"Module"}));var vt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Jr(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var np={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 M}),n.d(r,"multiply",function(){return I}),n.d(r,"rotate",function(){return D}),n.d(r,"scale",function(){return C}),n.d(r,"fromRotation",function(){return B}),n.d(r,"fromScaling",function(){return T}),n.d(r,"str",function(){return f}),n.d(r,"frob",function(){return m}),n.d(r,"LDU",function(){return w}),n.d(r,"add",function(){return v}),n.d(r,"subtract",function(){return b}),n.d(r,"exactEquals",function(){return x}),n.d(r,"equals",function(){return z}),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 P=new s.ARRAY_TYPE(4);return P[0]=A[0],P[1]=A[1],P[2]=A[2],P[3]=A[3],P}function c(A,P){return A[0]=P[0],A[1]=P[1],A[2]=P[2],A[3]=P[3],A}function l(A){return A[0]=1,A[1]=0,A[2]=0,A[3]=1,A}function u(A,P,U,Q){var K=new s.ARRAY_TYPE(4);return K[0]=A,K[1]=P,K[2]=U,K[3]=Q,K}function h(A,P,U,Q,K){return A[0]=P,A[1]=U,A[2]=Q,A[3]=K,A}function d(A,P){if(A===P){var U=P[1];A[1]=P[2],A[2]=U}else A[0]=P[0],A[1]=P[2],A[2]=P[1],A[3]=P[3];return A}function g(A,P){var U=P[0],Q=P[1],K=P[2],ce=P[3],k=U*ce-K*Q;return k?(k=1/k,A[0]=ce*k,A[1]=-Q*k,A[2]=-K*k,A[3]=U*k,A):null}function p(A,P){var U=P[0];return A[0]=P[3],A[1]=-P[1],A[2]=-P[2],A[3]=U,A}function M(A){return A[0]*A[3]-A[2]*A[1]}function I(A,P,U){var Q=P[0],K=P[1],ce=P[2],k=P[3],W=U[0],H=U[1],$=U[2],ee=U[3];return A[0]=Q*W+ce*H,A[1]=K*W+k*H,A[2]=Q*$+ce*ee,A[3]=K*$+k*ee,A}function D(A,P,U){var Q=P[0],K=P[1],ce=P[2],k=P[3],W=Math.sin(U),H=Math.cos(U);return A[0]=Q*H+ce*W,A[1]=K*H+k*W,A[2]=Q*-W+ce*H,A[3]=K*-W+k*H,A}function C(A,P,U){var Q=P[0],K=P[1],ce=P[2],k=P[3],W=U[0],H=U[1];return A[0]=Q*W,A[1]=K*W,A[2]=ce*H,A[3]=k*H,A}function B(A,P){var U=Math.sin(P),Q=Math.cos(P);return A[0]=Q,A[1]=U,A[2]=-U,A[3]=Q,A}function T(A,P){return A[0]=P[0],A[1]=0,A[2]=0,A[3]=P[1],A}function f(A){return"mat2("+A[0]+", "+A[1]+", "+A[2]+", "+A[3]+")"}function m(A){return Math.hypot(A[0],A[1],A[2],A[3])}function w(A,P,U,Q){return A[2]=Q[2]/Q[0],U[0]=Q[0],U[1]=Q[1],U[3]=Q[3]-A[2]*U[1],[A,P,U]}function v(A,P,U){return A[0]=P[0]+U[0],A[1]=P[1]+U[1],A[2]=P[2]+U[2],A[3]=P[3]+U[3],A}function b(A,P,U){return A[0]=P[0]-U[0],A[1]=P[1]-U[1],A[2]=P[2]-U[2],A[3]=P[3]-U[3],A}function x(A,P){return A[0]===P[0]&&A[1]===P[1]&&A[2]===P[2]&&A[3]===P[3]}function z(A,P){var U=A[0],Q=A[1],K=A[2],ce=A[3],k=P[0],W=P[1],H=P[2],$=P[3];return Math.abs(U-k)<=s.EPSILON*Math.max(1,Math.abs(U),Math.abs(k))&&Math.abs(Q-W)<=s.EPSILON*Math.max(1,Math.abs(Q),Math.abs(W))&&Math.abs(K-H)<=s.EPSILON*Math.max(1,Math.abs(K),Math.abs(H))&&Math.abs(ce-$)<=s.EPSILON*Math.max(1,Math.abs(ce),Math.abs($))}function E(A,P,U){return A[0]=P[0]*U,A[1]=P[1]*U,A[2]=P[2]*U,A[3]=P[3]*U,A}function O(A,P,U,Q){return A[0]=P[0]+U[0]*Q,A[1]=P[1]+U[1]*Q,A[2]=P[2]+U[2]*Q,A[3]=P[3]+U[3]*Q,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 M}),n.d(r,"scale",function(){return I}),n.d(r,"translate",function(){return D}),n.d(r,"fromRotation",function(){return C}),n.d(r,"fromScaling",function(){return B}),n.d(r,"fromTranslation",function(){return T}),n.d(r,"str",function(){return f}),n.d(r,"frob",function(){return m}),n.d(r,"add",function(){return w}),n.d(r,"subtract",function(){return v}),n.d(r,"multiplyScalar",function(){return b}),n.d(r,"multiplyScalarAndAdd",function(){return x}),n.d(r,"exactEquals",function(){return z}),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,P,U,Q,K){var ce=new s.ARRAY_TYPE(6);return ce[0]=N,ce[1]=A,ce[2]=P,ce[3]=U,ce[4]=Q,ce[5]=K,ce}function h(N,A,P,U,Q,K,ce){return N[0]=A,N[1]=P,N[2]=U,N[3]=Q,N[4]=K,N[5]=ce,N}function d(N,A){var P=A[0],U=A[1],Q=A[2],K=A[3],ce=A[4],k=A[5],W=P*K-U*Q;return W?(W=1/W,N[0]=K*W,N[1]=-U*W,N[2]=-Q*W,N[3]=P*W,N[4]=(Q*k-K*ce)*W,N[5]=(U*ce-P*k)*W,N):null}function g(N){return N[0]*N[3]-N[1]*N[2]}function p(N,A,P){var U=A[0],Q=A[1],K=A[2],ce=A[3],k=A[4],W=A[5],H=P[0],$=P[1],ee=P[2],ie=P[3],le=P[4],pe=P[5];return N[0]=U*H+K*$,N[1]=Q*H+ce*$,N[2]=U*ee+K*ie,N[3]=Q*ee+ce*ie,N[4]=U*le+K*pe+k,N[5]=Q*le+ce*pe+W,N}function M(N,A,P){var U=A[0],Q=A[1],K=A[2],ce=A[3],k=A[4],W=A[5],H=Math.sin(P),$=Math.cos(P);return N[0]=U*$+K*H,N[1]=Q*$+ce*H,N[2]=U*-H+K*$,N[3]=Q*-H+ce*$,N[4]=k,N[5]=W,N}function I(N,A,P){var U=A[0],Q=A[1],K=A[2],ce=A[3],k=A[4],W=A[5],H=P[0],$=P[1];return N[0]=U*H,N[1]=Q*H,N[2]=K*$,N[3]=ce*$,N[4]=k,N[5]=W,N}function D(N,A,P){var U=A[0],Q=A[1],K=A[2],ce=A[3],k=A[4],W=A[5],H=P[0],$=P[1];return N[0]=U,N[1]=Q,N[2]=K,N[3]=ce,N[4]=U*H+K*$+k,N[5]=Q*H+ce*$+W,N}function C(N,A){var P=Math.sin(A),U=Math.cos(A);return N[0]=U,N[1]=P,N[2]=-P,N[3]=U,N[4]=0,N[5]=0,N}function B(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 T(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 f(N){return"mat2d("+N[0]+", "+N[1]+", "+N[2]+", "+N[3]+", "+N[4]+", "+N[5]+")"}function m(N){return Math.hypot(N[0],N[1],N[2],N[3],N[4],N[5],1)}function w(N,A,P){return N[0]=A[0]+P[0],N[1]=A[1]+P[1],N[2]=A[2]+P[2],N[3]=A[3]+P[3],N[4]=A[4]+P[4],N[5]=A[5]+P[5],N}function v(N,A,P){return N[0]=A[0]-P[0],N[1]=A[1]-P[1],N[2]=A[2]-P[2],N[3]=A[3]-P[3],N[4]=A[4]-P[4],N[5]=A[5]-P[5],N}function b(N,A,P){return N[0]=A[0]*P,N[1]=A[1]*P,N[2]=A[2]*P,N[3]=A[3]*P,N[4]=A[4]*P,N[5]=A[5]*P,N}function x(N,A,P,U){return N[0]=A[0]+P[0]*U,N[1]=A[1]+P[1]*U,N[2]=A[2]+P[2]*U,N[3]=A[3]+P[3]*U,N[4]=A[4]+P[4]*U,N[5]=A[5]+P[5]*U,N}function z(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 P=N[0],U=N[1],Q=N[2],K=N[3],ce=N[4],k=N[5],W=A[0],H=A[1],$=A[2],ee=A[3],ie=A[4],le=A[5];return Math.abs(P-W)<=s.EPSILON*Math.max(1,Math.abs(P),Math.abs(W))&&Math.abs(U-H)<=s.EPSILON*Math.max(1,Math.abs(U),Math.abs(H))&&Math.abs(Q-$)<=s.EPSILON*Math.max(1,Math.abs(Q),Math.abs($))&&Math.abs(K-ee)<=s.EPSILON*Math.max(1,Math.abs(K),Math.abs(ee))&&Math.abs(ce-ie)<=s.EPSILON*Math.max(1,Math.abs(ce),Math.abs(ie))&&Math.abs(k-le)<=s.EPSILON*Math.max(1,Math.abs(k),Math.abs(le))}var O=p,V=v},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 M}),n.d(r,"determinant",function(){return I}),n.d(r,"multiply",function(){return D}),n.d(r,"translate",function(){return C}),n.d(r,"rotate",function(){return B}),n.d(r,"scale",function(){return T}),n.d(r,"fromTranslation",function(){return f}),n.d(r,"fromRotation",function(){return m}),n.d(r,"fromScaling",function(){return w}),n.d(r,"fromMat2d",function(){return v}),n.d(r,"fromQuat",function(){return b}),n.d(r,"normalFromMat4",function(){return x}),n.d(r,"projection",function(){return z}),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 P}),n.d(r,"exactEquals",function(){return U}),n.d(r,"equals",function(){return Q}),n.d(r,"mul",function(){return K}),n.d(r,"sub",function(){return ce});var s=n(2);function o(){var k=new s.ARRAY_TYPE(9);return s.ARRAY_TYPE!=Float32Array&&(k[1]=0,k[2]=0,k[3]=0,k[5]=0,k[6]=0,k[7]=0),k[0]=1,k[4]=1,k[8]=1,k}function a(k,W){return k[0]=W[0],k[1]=W[1],k[2]=W[2],k[3]=W[4],k[4]=W[5],k[5]=W[6],k[6]=W[8],k[7]=W[9],k[8]=W[10],k}function c(k){var W=new s.ARRAY_TYPE(9);return W[0]=k[0],W[1]=k[1],W[2]=k[2],W[3]=k[3],W[4]=k[4],W[5]=k[5],W[6]=k[6],W[7]=k[7],W[8]=k[8],W}function l(k,W){return k[0]=W[0],k[1]=W[1],k[2]=W[2],k[3]=W[3],k[4]=W[4],k[5]=W[5],k[6]=W[6],k[7]=W[7],k[8]=W[8],k}function u(k,W,H,$,ee,ie,le,pe,we){var R=new s.ARRAY_TYPE(9);return R[0]=k,R[1]=W,R[2]=H,R[3]=$,R[4]=ee,R[5]=ie,R[6]=le,R[7]=pe,R[8]=we,R}function h(k,W,H,$,ee,ie,le,pe,we,R){return k[0]=W,k[1]=H,k[2]=$,k[3]=ee,k[4]=ie,k[5]=le,k[6]=pe,k[7]=we,k[8]=R,k}function d(k){return k[0]=1,k[1]=0,k[2]=0,k[3]=0,k[4]=1,k[5]=0,k[6]=0,k[7]=0,k[8]=1,k}function g(k,W){if(k===W){var H=W[1],$=W[2],ee=W[5];k[1]=W[3],k[2]=W[6],k[3]=H,k[5]=W[7],k[6]=$,k[7]=ee}else k[0]=W[0],k[1]=W[3],k[2]=W[6],k[3]=W[1],k[4]=W[4],k[5]=W[7],k[6]=W[2],k[7]=W[5],k[8]=W[8];return k}function p(k,W){var H=W[0],$=W[1],ee=W[2],ie=W[3],le=W[4],pe=W[5],we=W[6],R=W[7],j=W[8],X=j*le-pe*R,ae=-j*ie+pe*we,q=R*ie-le*we,te=H*X+$*ae+ee*q;return te?(te=1/te,k[0]=X*te,k[1]=(-j*$+ee*R)*te,k[2]=(pe*$-ee*le)*te,k[3]=ae*te,k[4]=(j*H-ee*we)*te,k[5]=(-pe*H+ee*ie)*te,k[6]=q*te,k[7]=(-R*H+$*we)*te,k[8]=(le*H-$*ie)*te,k):null}function M(k,W){var H=W[0],$=W[1],ee=W[2],ie=W[3],le=W[4],pe=W[5],we=W[6],R=W[7],j=W[8];return k[0]=le*j-pe*R,k[1]=ee*R-$*j,k[2]=$*pe-ee*le,k[3]=pe*we-ie*j,k[4]=H*j-ee*we,k[5]=ee*ie-H*pe,k[6]=ie*R-le*we,k[7]=$*we-H*R,k[8]=H*le-$*ie,k}function I(k){var W=k[0],H=k[1],$=k[2],ee=k[3],ie=k[4],le=k[5],pe=k[6],we=k[7],R=k[8];return W*(R*ie-le*we)+H*(-R*ee+le*pe)+$*(we*ee-ie*pe)}function D(k,W,H){var $=W[0],ee=W[1],ie=W[2],le=W[3],pe=W[4],we=W[5],R=W[6],j=W[7],X=W[8],ae=H[0],q=H[1],te=H[2],y=H[3],S=H[4],F=H[5],Y=H[6],_=H[7],re=H[8];return k[0]=ae*$+q*le+te*R,k[1]=ae*ee+q*pe+te*j,k[2]=ae*ie+q*we+te*X,k[3]=y*$+S*le+F*R,k[4]=y*ee+S*pe+F*j,k[5]=y*ie+S*we+F*X,k[6]=Y*$+_*le+re*R,k[7]=Y*ee+_*pe+re*j,k[8]=Y*ie+_*we+re*X,k}function C(k,W,H){var $=W[0],ee=W[1],ie=W[2],le=W[3],pe=W[4],we=W[5],R=W[6],j=W[7],X=W[8],ae=H[0],q=H[1];return k[0]=$,k[1]=ee,k[2]=ie,k[3]=le,k[4]=pe,k[5]=we,k[6]=ae*$+q*le+R,k[7]=ae*ee+q*pe+j,k[8]=ae*ie+q*we+X,k}function B(k,W,H){var $=W[0],ee=W[1],ie=W[2],le=W[3],pe=W[4],we=W[5],R=W[6],j=W[7],X=W[8],ae=Math.sin(H),q=Math.cos(H);return k[0]=q*$+ae*le,k[1]=q*ee+ae*pe,k[2]=q*ie+ae*we,k[3]=q*le-ae*$,k[4]=q*pe-ae*ee,k[5]=q*we-ae*ie,k[6]=R,k[7]=j,k[8]=X,k}function T(k,W,H){var $=H[0],ee=H[1];return k[0]=$*W[0],k[1]=$*W[1],k[2]=$*W[2],k[3]=ee*W[3],k[4]=ee*W[4],k[5]=ee*W[5],k[6]=W[6],k[7]=W[7],k[8]=W[8],k}function f(k,W){return k[0]=1,k[1]=0,k[2]=0,k[3]=0,k[4]=1,k[5]=0,k[6]=W[0],k[7]=W[1],k[8]=1,k}function m(k,W){var H=Math.sin(W),$=Math.cos(W);return k[0]=$,k[1]=H,k[2]=0,k[3]=-H,k[4]=$,k[5]=0,k[6]=0,k[7]=0,k[8]=1,k}function w(k,W){return k[0]=W[0],k[1]=0,k[2]=0,k[3]=0,k[4]=W[1],k[5]=0,k[6]=0,k[7]=0,k[8]=1,k}function v(k,W){return k[0]=W[0],k[1]=W[1],k[2]=0,k[3]=W[2],k[4]=W[3],k[5]=0,k[6]=W[4],k[7]=W[5],k[8]=1,k}function b(k,W){var H=W[0],$=W[1],ee=W[2],ie=W[3],le=H+H,pe=$+$,we=ee+ee,R=H*le,j=$*le,X=$*pe,ae=ee*le,q=ee*pe,te=ee*we,y=ie*le,S=ie*pe,F=ie*we;return k[0]=1-X-te,k[3]=j-F,k[6]=ae+S,k[1]=j+F,k[4]=1-R-te,k[7]=q-y,k[2]=ae-S,k[5]=q+y,k[8]=1-R-X,k}function x(k,W){var H=W[0],$=W[1],ee=W[2],ie=W[3],le=W[4],pe=W[5],we=W[6],R=W[7],j=W[8],X=W[9],ae=W[10],q=W[11],te=W[12],y=W[13],S=W[14],F=W[15],Y=H*pe-$*le,_=H*we-ee*le,re=H*R-ie*le,ne=$*we-ee*pe,J=$*R-ie*pe,se=ee*R-ie*we,ue=j*y-X*te,oe=j*S-ae*te,de=j*F-q*te,me=X*S-ae*y,ye=X*F-q*y,xe=ae*F-q*S,Ce=Y*xe-_*ye+re*me+ne*de-J*oe+se*ue;return Ce?(Ce=1/Ce,k[0]=(pe*xe-we*ye+R*me)*Ce,k[1]=(we*de-le*xe-R*oe)*Ce,k[2]=(le*ye-pe*de+R*ue)*Ce,k[3]=(ee*ye-$*xe-ie*me)*Ce,k[4]=(H*xe-ee*de+ie*oe)*Ce,k[5]=($*de-H*ye-ie*ue)*Ce,k[6]=(y*se-S*J+F*ne)*Ce,k[7]=(S*re-te*se-F*_)*Ce,k[8]=(te*J-y*re+F*Y)*Ce,k):null}function z(k,W,H){return k[0]=2/W,k[1]=0,k[2]=0,k[3]=0,k[4]=-2/H,k[5]=0,k[6]=-1,k[7]=1,k[8]=1,k}function E(k){return"mat3("+k[0]+", "+k[1]+", "+k[2]+", "+k[3]+", "+k[4]+", "+k[5]+", "+k[6]+", "+k[7]+", "+k[8]+")"}function O(k){return Math.hypot(k[0],k[1],k[2],k[3],k[4],k[5],k[6],k[7],k[8])}function V(k,W,H){return k[0]=W[0]+H[0],k[1]=W[1]+H[1],k[2]=W[2]+H[2],k[3]=W[3]+H[3],k[4]=W[4]+H[4],k[5]=W[5]+H[5],k[6]=W[6]+H[6],k[7]=W[7]+H[7],k[8]=W[8]+H[8],k}function N(k,W,H){return k[0]=W[0]-H[0],k[1]=W[1]-H[1],k[2]=W[2]-H[2],k[3]=W[3]-H[3],k[4]=W[4]-H[4],k[5]=W[5]-H[5],k[6]=W[6]-H[6],k[7]=W[7]-H[7],k[8]=W[8]-H[8],k}function A(k,W,H){return k[0]=W[0]*H,k[1]=W[1]*H,k[2]=W[2]*H,k[3]=W[3]*H,k[4]=W[4]*H,k[5]=W[5]*H,k[6]=W[6]*H,k[7]=W[7]*H,k[8]=W[8]*H,k}function P(k,W,H,$){return k[0]=W[0]+H[0]*$,k[1]=W[1]+H[1]*$,k[2]=W[2]+H[2]*$,k[3]=W[3]+H[3]*$,k[4]=W[4]+H[4]*$,k[5]=W[5]+H[5]*$,k[6]=W[6]+H[6]*$,k[7]=W[7]+H[7]*$,k[8]=W[8]+H[8]*$,k}function U(k,W){return k[0]===W[0]&&k[1]===W[1]&&k[2]===W[2]&&k[3]===W[3]&&k[4]===W[4]&&k[5]===W[5]&&k[6]===W[6]&&k[7]===W[7]&&k[8]===W[8]}function Q(k,W){var H=k[0],$=k[1],ee=k[2],ie=k[3],le=k[4],pe=k[5],we=k[6],R=k[7],j=k[8],X=W[0],ae=W[1],q=W[2],te=W[3],y=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-y)<=s.EPSILON*Math.max(1,Math.abs(le),Math.abs(y))&&Math.abs(pe-S)<=s.EPSILON*Math.max(1,Math.abs(pe),Math.abs(S))&&Math.abs(we-F)<=s.EPSILON*Math.max(1,Math.abs(we),Math.abs(F))&&Math.abs(R-Y)<=s.EPSILON*Math.max(1,Math.abs(R),Math.abs(Y))&&Math.abs(j-_)<=s.EPSILON*Math.max(1,Math.abs(j),Math.abs(_))}var K=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 M}),n.d(r,"multiply",function(){return I}),n.d(r,"translate",function(){return D}),n.d(r,"scale",function(){return C}),n.d(r,"rotate",function(){return B}),n.d(r,"rotateX",function(){return T}),n.d(r,"rotateY",function(){return f}),n.d(r,"rotateZ",function(){return m}),n.d(r,"fromTranslation",function(){return w}),n.d(r,"fromScaling",function(){return v}),n.d(r,"fromRotation",function(){return b}),n.d(r,"fromXRotation",function(){return x}),n.d(r,"fromYRotation",function(){return z}),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 P}),n.d(r,"fromRotationTranslationScale",function(){return U}),n.d(r,"fromRotationTranslationScaleOrigin",function(){return Q}),n.d(r,"fromQuat",function(){return K}),n.d(r,"frustum",function(){return ce}),n.d(r,"perspective",function(){return k}),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 we}),n.d(r,"multiplyScalar",function(){return R}),n.d(r,"multiplyScalarAndAdd",function(){return j}),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 y=new s.ARRAY_TYPE(16);return s.ARRAY_TYPE!=Float32Array&&(y[1]=0,y[2]=0,y[3]=0,y[4]=0,y[6]=0,y[7]=0,y[8]=0,y[9]=0,y[11]=0,y[12]=0,y[13]=0,y[14]=0),y[0]=1,y[5]=1,y[10]=1,y[15]=1,y}function a(y){var S=new s.ARRAY_TYPE(16);return S[0]=y[0],S[1]=y[1],S[2]=y[2],S[3]=y[3],S[4]=y[4],S[5]=y[5],S[6]=y[6],S[7]=y[7],S[8]=y[8],S[9]=y[9],S[10]=y[10],S[11]=y[11],S[12]=y[12],S[13]=y[13],S[14]=y[14],S[15]=y[15],S}function c(y,S){return y[0]=S[0],y[1]=S[1],y[2]=S[2],y[3]=S[3],y[4]=S[4],y[5]=S[5],y[6]=S[6],y[7]=S[7],y[8]=S[8],y[9]=S[9],y[10]=S[10],y[11]=S[11],y[12]=S[12],y[13]=S[13],y[14]=S[14],y[15]=S[15],y}function l(y,S,F,Y,_,re,ne,J,se,ue,oe,de,me,ye,xe,Ce){var Ie=new s.ARRAY_TYPE(16);return Ie[0]=y,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]=xe,Ie[15]=Ce,Ie}function u(y,S,F,Y,_,re,ne,J,se,ue,oe,de,me,ye,xe,Ce,Ie){return y[0]=S,y[1]=F,y[2]=Y,y[3]=_,y[4]=re,y[5]=ne,y[6]=J,y[7]=se,y[8]=ue,y[9]=oe,y[10]=de,y[11]=me,y[12]=ye,y[13]=xe,y[14]=Ce,y[15]=Ie,y}function h(y){return y[0]=1,y[1]=0,y[2]=0,y[3]=0,y[4]=0,y[5]=1,y[6]=0,y[7]=0,y[8]=0,y[9]=0,y[10]=1,y[11]=0,y[12]=0,y[13]=0,y[14]=0,y[15]=1,y}function d(y,S){if(y===S){var F=S[1],Y=S[2],_=S[3],re=S[6],ne=S[7],J=S[11];y[1]=S[4],y[2]=S[8],y[3]=S[12],y[4]=F,y[6]=S[9],y[7]=S[13],y[8]=Y,y[9]=re,y[11]=S[14],y[12]=_,y[13]=ne,y[14]=J}else y[0]=S[0],y[1]=S[4],y[2]=S[8],y[3]=S[12],y[4]=S[1],y[5]=S[5],y[6]=S[9],y[7]=S[13],y[8]=S[2],y[9]=S[6],y[10]=S[10],y[11]=S[14],y[12]=S[3],y[13]=S[7],y[14]=S[11],y[15]=S[15];return y}function g(y,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],xe=S[12],Ce=S[13],Ie=S[14],ke=S[15],Re=F*J-Y*ne,Le=F*se-_*ne,Oe=F*ue-re*ne,je=Y*se-_*J,Be=Y*ue-re*J,Je=_*ue-re*se,et=oe*Ce-de*xe,rt=oe*Ie-me*xe,nt=oe*ke-ye*xe,st=de*Ie-me*Ce,ut=de*ke-ye*Ce,lt=me*ke-ye*Ie,Ze=Re*lt-Le*ut+Oe*st+je*nt-Be*rt+Je*et;return Ze?(Ze=1/Ze,y[0]=(J*lt-se*ut+ue*st)*Ze,y[1]=(_*ut-Y*lt-re*st)*Ze,y[2]=(Ce*Je-Ie*Be+ke*je)*Ze,y[3]=(me*Be-de*Je-ye*je)*Ze,y[4]=(se*nt-ne*lt-ue*rt)*Ze,y[5]=(F*lt-_*nt+re*rt)*Ze,y[6]=(Ie*Oe-xe*Je-ke*Le)*Ze,y[7]=(oe*Je-me*Oe+ye*Le)*Ze,y[8]=(ne*ut-J*nt+ue*et)*Ze,y[9]=(Y*nt-F*ut-re*et)*Ze,y[10]=(xe*Be-Ce*Oe+ke*Re)*Ze,y[11]=(de*Oe-oe*Be-ye*Re)*Ze,y[12]=(J*rt-ne*st-se*et)*Ze,y[13]=(F*st-Y*rt+_*et)*Ze,y[14]=(Ce*Le-xe*je-Ie*Re)*Ze,y[15]=(oe*je-de*Le+me*Re)*Ze,y):null}function p(y,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],xe=S[12],Ce=S[13],Ie=S[14],ke=S[15];return y[0]=J*(me*ke-ye*Ie)-de*(se*ke-ue*Ie)+Ce*(se*ye-ue*me),y[1]=-(Y*(me*ke-ye*Ie)-de*(_*ke-re*Ie)+Ce*(_*ye-re*me)),y[2]=Y*(se*ke-ue*Ie)-J*(_*ke-re*Ie)+Ce*(_*ue-re*se),y[3]=-(Y*(se*ye-ue*me)-J*(_*ye-re*me)+de*(_*ue-re*se)),y[4]=-(ne*(me*ke-ye*Ie)-oe*(se*ke-ue*Ie)+xe*(se*ye-ue*me)),y[5]=F*(me*ke-ye*Ie)-oe*(_*ke-re*Ie)+xe*(_*ye-re*me),y[6]=-(F*(se*ke-ue*Ie)-ne*(_*ke-re*Ie)+xe*(_*ue-re*se)),y[7]=F*(se*ye-ue*me)-ne*(_*ye-re*me)+oe*(_*ue-re*se),y[8]=ne*(de*ke-ye*Ce)-oe*(J*ke-ue*Ce)+xe*(J*ye-ue*de),y[9]=-(F*(de*ke-ye*Ce)-oe*(Y*ke-re*Ce)+xe*(Y*ye-re*de)),y[10]=F*(J*ke-ue*Ce)-ne*(Y*ke-re*Ce)+xe*(Y*ue-re*J),y[11]=-(F*(J*ye-ue*de)-ne*(Y*ye-re*de)+oe*(Y*ue-re*J)),y[12]=-(ne*(de*Ie-me*Ce)-oe*(J*Ie-se*Ce)+xe*(J*me-se*de)),y[13]=F*(de*Ie-me*Ce)-oe*(Y*Ie-_*Ce)+xe*(Y*me-_*de),y[14]=-(F*(J*Ie-se*Ce)-ne*(Y*Ie-_*Ce)+xe*(Y*se-_*J)),y[15]=F*(J*me-se*de)-ne*(Y*me-_*de)+oe*(Y*se-_*J),y}function M(y){var S=y[0],F=y[1],Y=y[2],_=y[3],re=y[4],ne=y[5],J=y[6],se=y[7],ue=y[8],oe=y[9],de=y[10],me=y[11],ye=y[12],xe=y[13],Ce=y[14],Ie=y[15],ke=S*ne-F*re,Re=S*J-Y*re,Le=S*se-_*re,Oe=F*J-Y*ne,je=F*se-_*ne,Be=Y*se-_*J,Je=ue*xe-oe*ye,et=ue*Ce-de*ye,rt=ue*Ie-me*ye,nt=oe*Ce-de*xe,st=oe*Ie-me*xe,ut=de*Ie-me*Ce;return ke*ut-Re*st+Le*nt+Oe*rt-je*et+Be*Je}function I(y,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],xe=S[11],Ce=S[12],Ie=S[13],ke=S[14],Re=S[15],Le=F[0],Oe=F[1],je=F[2],Be=F[3];return y[0]=Le*Y+Oe*J+je*de+Be*Ce,y[1]=Le*_+Oe*se+je*me+Be*Ie,y[2]=Le*re+Oe*ue+je*ye+Be*ke,y[3]=Le*ne+Oe*oe+je*xe+Be*Re,Le=F[4],Oe=F[5],je=F[6],Be=F[7],y[4]=Le*Y+Oe*J+je*de+Be*Ce,y[5]=Le*_+Oe*se+je*me+Be*Ie,y[6]=Le*re+Oe*ue+je*ye+Be*ke,y[7]=Le*ne+Oe*oe+je*xe+Be*Re,Le=F[8],Oe=F[9],je=F[10],Be=F[11],y[8]=Le*Y+Oe*J+je*de+Be*Ce,y[9]=Le*_+Oe*se+je*me+Be*Ie,y[10]=Le*re+Oe*ue+je*ye+Be*ke,y[11]=Le*ne+Oe*oe+je*xe+Be*Re,Le=F[12],Oe=F[13],je=F[14],Be=F[15],y[12]=Le*Y+Oe*J+je*de+Be*Ce,y[13]=Le*_+Oe*se+je*me+Be*Ie,y[14]=Le*re+Oe*ue+je*ye+Be*ke,y[15]=Le*ne+Oe*oe+je*xe+Be*Re,y}function D(y,S,F){var Y=F[0],_=F[1],re=F[2],ne,J,se,ue,oe,de,me,ye,xe,Ce,Ie,ke;return S===y?(y[12]=S[0]*Y+S[4]*_+S[8]*re+S[12],y[13]=S[1]*Y+S[5]*_+S[9]*re+S[13],y[14]=S[2]*Y+S[6]*_+S[10]*re+S[14],y[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],xe=S[8],Ce=S[9],Ie=S[10],ke=S[11],y[0]=ne,y[1]=J,y[2]=se,y[3]=ue,y[4]=oe,y[5]=de,y[6]=me,y[7]=ye,y[8]=xe,y[9]=Ce,y[10]=Ie,y[11]=ke,y[12]=ne*Y+oe*_+xe*re+S[12],y[13]=J*Y+de*_+Ce*re+S[13],y[14]=se*Y+me*_+Ie*re+S[14],y[15]=ue*Y+ye*_+ke*re+S[15]),y}function C(y,S,F){var Y=F[0],_=F[1],re=F[2];return y[0]=S[0]*Y,y[1]=S[1]*Y,y[2]=S[2]*Y,y[3]=S[3]*Y,y[4]=S[4]*_,y[5]=S[5]*_,y[6]=S[6]*_,y[7]=S[7]*_,y[8]=S[8]*re,y[9]=S[9]*re,y[10]=S[10]*re,y[11]=S[11]*re,y[12]=S[12],y[13]=S[13],y[14]=S[14],y[15]=S[15],y}function B(y,S,F,Y){var _=Y[0],re=Y[1],ne=Y[2],J=Math.hypot(_,re,ne),se,ue,oe,de,me,ye,xe,Ce,Ie,ke,Re,Le,Oe,je,Be,Je,et,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],xe=S[3],Ce=S[4],Ie=S[5],ke=S[6],Re=S[7],Le=S[8],Oe=S[9],je=S[10],Be=S[11],Je=_*_*oe+ue,et=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,y[0]=de*Je+Ce*et+Le*rt,y[1]=me*Je+Ie*et+Oe*rt,y[2]=ye*Je+ke*et+je*rt,y[3]=xe*Je+Re*et+Be*rt,y[4]=de*nt+Ce*st+Le*ut,y[5]=me*nt+Ie*st+Oe*ut,y[6]=ye*nt+ke*st+je*ut,y[7]=xe*nt+Re*st+Be*ut,y[8]=de*lt+Ce*Ze+Le*Ut,y[9]=me*lt+Ie*Ze+Oe*Ut,y[10]=ye*lt+ke*Ze+je*Ut,y[11]=xe*lt+Re*Ze+Be*Ut,S!==y&&(y[12]=S[12],y[13]=S[13],y[14]=S[14],y[15]=S[15]),y)}function T(y,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!==y&&(y[0]=S[0],y[1]=S[1],y[2]=S[2],y[3]=S[3],y[12]=S[12],y[13]=S[13],y[14]=S[14],y[15]=S[15]),y[4]=re*_+ue*Y,y[5]=ne*_+oe*Y,y[6]=J*_+de*Y,y[7]=se*_+me*Y,y[8]=ue*_-re*Y,y[9]=oe*_-ne*Y,y[10]=de*_-J*Y,y[11]=me*_-se*Y,y}function f(y,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!==y&&(y[4]=S[4],y[5]=S[5],y[6]=S[6],y[7]=S[7],y[12]=S[12],y[13]=S[13],y[14]=S[14],y[15]=S[15]),y[0]=re*_-ue*Y,y[1]=ne*_-oe*Y,y[2]=J*_-de*Y,y[3]=se*_-me*Y,y[8]=re*Y+ue*_,y[9]=ne*Y+oe*_,y[10]=J*Y+de*_,y[11]=se*Y+me*_,y}function m(y,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!==y&&(y[8]=S[8],y[9]=S[9],y[10]=S[10],y[11]=S[11],y[12]=S[12],y[13]=S[13],y[14]=S[14],y[15]=S[15]),y[0]=re*_+ue*Y,y[1]=ne*_+oe*Y,y[2]=J*_+de*Y,y[3]=se*_+me*Y,y[4]=ue*_-re*Y,y[5]=oe*_-ne*Y,y[6]=de*_-J*Y,y[7]=me*_-se*Y,y}function w(y,S){return y[0]=1,y[1]=0,y[2]=0,y[3]=0,y[4]=0,y[5]=1,y[6]=0,y[7]=0,y[8]=0,y[9]=0,y[10]=1,y[11]=0,y[12]=S[0],y[13]=S[1],y[14]=S[2],y[15]=1,y}function v(y,S){return y[0]=S[0],y[1]=0,y[2]=0,y[3]=0,y[4]=0,y[5]=S[1],y[6]=0,y[7]=0,y[8]=0,y[9]=0,y[10]=S[2],y[11]=0,y[12]=0,y[13]=0,y[14]=0,y[15]=1,y}function b(y,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,y[0]=Y*Y*ue+se,y[1]=_*Y*ue+re*J,y[2]=re*Y*ue-_*J,y[3]=0,y[4]=Y*_*ue-re*J,y[5]=_*_*ue+se,y[6]=re*_*ue+Y*J,y[7]=0,y[8]=Y*re*ue+_*J,y[9]=_*re*ue-Y*J,y[10]=re*re*ue+se,y[11]=0,y[12]=0,y[13]=0,y[14]=0,y[15]=1,y)}function x(y,S){var F=Math.sin(S),Y=Math.cos(S);return y[0]=1,y[1]=0,y[2]=0,y[3]=0,y[4]=0,y[5]=Y,y[6]=F,y[7]=0,y[8]=0,y[9]=-F,y[10]=Y,y[11]=0,y[12]=0,y[13]=0,y[14]=0,y[15]=1,y}function z(y,S){var F=Math.sin(S),Y=Math.cos(S);return y[0]=Y,y[1]=0,y[2]=-F,y[3]=0,y[4]=0,y[5]=1,y[6]=0,y[7]=0,y[8]=F,y[9]=0,y[10]=Y,y[11]=0,y[12]=0,y[13]=0,y[14]=0,y[15]=1,y}function E(y,S){var F=Math.sin(S),Y=Math.cos(S);return y[0]=Y,y[1]=F,y[2]=0,y[3]=0,y[4]=-F,y[5]=Y,y[6]=0,y[7]=0,y[8]=0,y[9]=0,y[10]=1,y[11]=0,y[12]=0,y[13]=0,y[14]=0,y[15]=1,y}function O(y,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,xe=_*ue,Ce=re*ue,Ie=ne*J,ke=ne*se,Re=ne*ue;return y[0]=1-(ye+Ce),y[1]=de+Re,y[2]=me-ke,y[3]=0,y[4]=de-Re,y[5]=1-(oe+Ce),y[6]=xe+Ie,y[7]=0,y[8]=me+ke,y[9]=xe-Ie,y[10]=1-(oe+ye),y[11]=0,y[12]=F[0],y[13]=F[1],y[14]=F[2],y[15]=1,y}function V(y,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(y,S,F),y}function N(y,S){return y[0]=S[12],y[1]=S[13],y[2]=S[14],y}function A(y,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 y[0]=Math.hypot(F,Y,_),y[1]=Math.hypot(re,ne,J),y[2]=Math.hypot(se,ue,oe),y}function P(y,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]*_,xe=S[10]*re,Ce=ne+oe+xe,Ie=0;return Ce>0?(Ie=Math.sqrt(Ce+1)*2,y[3]=.25*Ie,y[0]=(de-ye)/Ie,y[1]=(me-se)/Ie,y[2]=(J-ue)/Ie):ne>oe&&ne>xe?(Ie=Math.sqrt(1+ne-oe-xe)*2,y[3]=(de-ye)/Ie,y[0]=.25*Ie,y[1]=(J+ue)/Ie,y[2]=(me+se)/Ie):oe>xe?(Ie=Math.sqrt(1+oe-ne-xe)*2,y[3]=(me-se)/Ie,y[0]=(J+ue)/Ie,y[1]=.25*Ie,y[2]=(de+ye)/Ie):(Ie=Math.sqrt(1+xe-ne-oe)*2,y[3]=(J-ue)/Ie,y[0]=(me+se)/Ie,y[1]=(de+ye)/Ie,y[2]=.25*Ie),y}function U(y,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,xe=re*ue,Ce=re*oe,Ie=ne*oe,ke=J*se,Re=J*ue,Le=J*oe,Oe=Y[0],je=Y[1],Be=Y[2];return y[0]=(1-(xe+Ie))*Oe,y[1]=(me+Le)*Oe,y[2]=(ye-Re)*Oe,y[3]=0,y[4]=(me-Le)*je,y[5]=(1-(de+Ie))*je,y[6]=(Ce+ke)*je,y[7]=0,y[8]=(ye+Re)*Be,y[9]=(Ce-ke)*Be,y[10]=(1-(de+xe))*Be,y[11]=0,y[12]=F[0],y[13]=F[1],y[14]=F[2],y[15]=1,y}function Q(y,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,xe=re*de,Ce=ne*oe,Ie=ne*de,ke=J*de,Re=se*ue,Le=se*oe,Oe=se*de,je=Y[0],Be=Y[1],Je=Y[2],et=_[0],rt=_[1],nt=_[2],st=(1-(Ce+ke))*je,ut=(ye+Oe)*je,lt=(xe-Le)*je,Ze=(ye-Oe)*Be,Ut=(1-(me+ke))*Be,Dr=(Ie+Re)*Be,Pr=(xe+Le)*Je,hi=(Ie-Re)*Je,Js=(1-(me+Ce))*Je;return y[0]=st,y[1]=ut,y[2]=lt,y[3]=0,y[4]=Ze,y[5]=Ut,y[6]=Dr,y[7]=0,y[8]=Pr,y[9]=hi,y[10]=Js,y[11]=0,y[12]=F[0]+et-(st*et+Ze*rt+Pr*nt),y[13]=F[1]+rt-(ut*et+Ut*rt+hi*nt),y[14]=F[2]+nt-(lt*et+Dr*rt+Js*nt),y[15]=1,y}function K(y,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,xe=_*se,Ce=re*ne,Ie=re*J,ke=re*se;return y[0]=1-de-xe,y[1]=oe+ke,y[2]=me-Ie,y[3]=0,y[4]=oe-ke,y[5]=1-ue-xe,y[6]=ye+Ce,y[7]=0,y[8]=me+Ie,y[9]=ye-Ce,y[10]=1-ue-de,y[11]=0,y[12]=0,y[13]=0,y[14]=0,y[15]=1,y}function ce(y,S,F,Y,_,re,ne){var J=1/(F-S),se=1/(_-Y),ue=1/(re-ne);return y[0]=re*2*J,y[1]=0,y[2]=0,y[3]=0,y[4]=0,y[5]=re*2*se,y[6]=0,y[7]=0,y[8]=(F+S)*J,y[9]=(_+Y)*se,y[10]=(ne+re)*ue,y[11]=-1,y[12]=0,y[13]=0,y[14]=ne*re*2*ue,y[15]=0,y}function k(y,S,F,Y,_){var re=1/Math.tan(S/2),ne;return y[0]=re/F,y[1]=0,y[2]=0,y[3]=0,y[4]=0,y[5]=re,y[6]=0,y[7]=0,y[8]=0,y[9]=0,y[11]=-1,y[12]=0,y[13]=0,y[15]=0,_!=null&&_!==1/0?(ne=1/(Y-_),y[10]=(_+Y)*ne,y[14]=2*_*Y*ne):(y[10]=-1,y[14]=-2*Y),y}function W(y,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 y[0]=se,y[1]=0,y[2]=0,y[3]=0,y[4]=0,y[5]=ue,y[6]=0,y[7]=0,y[8]=-((ne-J)*se*.5),y[9]=(_-re)*ue*.5,y[10]=Y/(F-Y),y[11]=-1,y[12]=0,y[13]=0,y[14]=Y*F/(F-Y),y[15]=0,y}function H(y,S,F,Y,_,re,ne){var J=1/(S-F),se=1/(Y-_),ue=1/(re-ne);return y[0]=-2*J,y[1]=0,y[2]=0,y[3]=0,y[4]=0,y[5]=-2*se,y[6]=0,y[7]=0,y[8]=0,y[9]=0,y[10]=2*ue,y[11]=0,y[12]=(S+F)*J,y[13]=(_+Y)*se,y[14]=(ne+re)*ue,y[15]=1,y}function $(y,S,F,Y){var _,re,ne,J,se,ue,oe,de,me,ye,xe=S[0],Ce=S[1],Ie=S[2],ke=Y[0],Re=Y[1],Le=Y[2],Oe=F[0],je=F[1],Be=F[2];return Math.abs(xe-Oe)<s.EPSILON&&Math.abs(Ce-je)<s.EPSILON&&Math.abs(Ie-Be)<s.EPSILON?h(y):(oe=xe-Oe,de=Ce-je,me=Ie-Be,ye=1/Math.hypot(oe,de,me),oe*=ye,de*=ye,me*=ye,_=Re*me-Le*de,re=Le*oe-ke*me,ne=ke*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),y[0]=_,y[1]=J,y[2]=oe,y[3]=0,y[4]=re,y[5]=se,y[6]=de,y[7]=0,y[8]=ne,y[9]=ue,y[10]=me,y[11]=0,y[12]=-(_*xe+re*Ce+ne*Ie),y[13]=-(J*xe+se*Ce+ue*Ie),y[14]=-(oe*xe+de*Ce+me*Ie),y[15]=1,y)}function ee(y,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 xe=se*me-ue*de,Ce=ue*oe-J*me,Ie=J*de-se*oe;return ye=xe*xe+Ce*Ce+Ie*Ie,ye>0&&(ye=1/Math.sqrt(ye),xe*=ye,Ce*=ye,Ie*=ye),y[0]=xe,y[1]=Ce,y[2]=Ie,y[3]=0,y[4]=de*Ie-me*Ce,y[5]=me*xe-oe*Ie,y[6]=oe*Ce-de*xe,y[7]=0,y[8]=oe,y[9]=de,y[10]=me,y[11]=0,y[12]=_,y[13]=re,y[14]=ne,y[15]=1,y}function ie(y){return"mat4("+y[0]+", "+y[1]+", "+y[2]+", "+y[3]+", "+y[4]+", "+y[5]+", "+y[6]+", "+y[7]+", "+y[8]+", "+y[9]+", "+y[10]+", "+y[11]+", "+y[12]+", "+y[13]+", "+y[14]+", "+y[15]+")"}function le(y){return Math.hypot(y[0],y[1],y[2],y[3],y[4],y[5],y[6],y[7],y[8],y[9],y[10],y[11],y[12],y[13],y[14],y[15])}function pe(y,S,F){return y[0]=S[0]+F[0],y[1]=S[1]+F[1],y[2]=S[2]+F[2],y[3]=S[3]+F[3],y[4]=S[4]+F[4],y[5]=S[5]+F[5],y[6]=S[6]+F[6],y[7]=S[7]+F[7],y[8]=S[8]+F[8],y[9]=S[9]+F[9],y[10]=S[10]+F[10],y[11]=S[11]+F[11],y[12]=S[12]+F[12],y[13]=S[13]+F[13],y[14]=S[14]+F[14],y[15]=S[15]+F[15],y}function we(y,S,F){return y[0]=S[0]-F[0],y[1]=S[1]-F[1],y[2]=S[2]-F[2],y[3]=S[3]-F[3],y[4]=S[4]-F[4],y[5]=S[5]-F[5],y[6]=S[6]-F[6],y[7]=S[7]-F[7],y[8]=S[8]-F[8],y[9]=S[9]-F[9],y[10]=S[10]-F[10],y[11]=S[11]-F[11],y[12]=S[12]-F[12],y[13]=S[13]-F[13],y[14]=S[14]-F[14],y[15]=S[15]-F[15],y}function R(y,S,F){return y[0]=S[0]*F,y[1]=S[1]*F,y[2]=S[2]*F,y[3]=S[3]*F,y[4]=S[4]*F,y[5]=S[5]*F,y[6]=S[6]*F,y[7]=S[7]*F,y[8]=S[8]*F,y[9]=S[9]*F,y[10]=S[10]*F,y[11]=S[11]*F,y[12]=S[12]*F,y[13]=S[13]*F,y[14]=S[14]*F,y[15]=S[15]*F,y}function j(y,S,F,Y){return y[0]=S[0]+F[0]*Y,y[1]=S[1]+F[1]*Y,y[2]=S[2]+F[2]*Y,y[3]=S[3]+F[3]*Y,y[4]=S[4]+F[4]*Y,y[5]=S[5]+F[5]*Y,y[6]=S[6]+F[6]*Y,y[7]=S[7]+F[7]*Y,y[8]=S[8]+F[8]*Y,y[9]=S[9]+F[9]*Y,y[10]=S[10]+F[10]*Y,y[11]=S[11]+F[11]*Y,y[12]=S[12]+F[12]*Y,y[13]=S[13]+F[13]*Y,y[14]=S[14]+F[14]*Y,y[15]=S[15]+F[15]*Y,y}function X(y,S){return y[0]===S[0]&&y[1]===S[1]&&y[2]===S[2]&&y[3]===S[3]&&y[4]===S[4]&&y[5]===S[5]&&y[6]===S[6]&&y[7]===S[7]&&y[8]===S[8]&&y[9]===S[9]&&y[10]===S[10]&&y[11]===S[11]&&y[12]===S[12]&&y[13]===S[13]&&y[14]===S[14]&&y[15]===S[15]}function ae(y,S){var F=y[0],Y=y[1],_=y[2],re=y[3],ne=y[4],J=y[5],se=y[6],ue=y[7],oe=y[8],de=y[9],me=y[10],ye=y[11],xe=y[12],Ce=y[13],Ie=y[14],ke=y[15],Re=S[0],Le=S[1],Oe=S[2],je=S[3],Be=S[4],Je=S[5],et=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-Le)<=s.EPSILON*Math.max(1,Math.abs(Y),Math.abs(Le))&&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-et)<=s.EPSILON*Math.max(1,Math.abs(se),Math.abs(et))&&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(xe-Ze)<=s.EPSILON*Math.max(1,Math.abs(xe),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(ke-Pr)<=s.EPSILON*Math.max(1,Math.abs(ke),Math.abs(Pr))}var q=I,te=we},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 M}),n.d(r,"rotateY",function(){return I}),n.d(r,"rotateZ",function(){return D}),n.d(r,"calculateW",function(){return C}),n.d(r,"exp",function(){return B}),n.d(r,"ln",function(){return T}),n.d(r,"pow",function(){return f}),n.d(r,"slerp",function(){return m}),n.d(r,"random",function(){return w}),n.d(r,"invert",function(){return v}),n.d(r,"conjugate",function(){return b}),n.d(r,"fromMat3",function(){return x}),n.d(r,"fromEuler",function(){return z}),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 P}),n.d(r,"mul",function(){return U}),n.d(r,"scale",function(){return Q}),n.d(r,"dot",function(){return K}),n.d(r,"lerp",function(){return ce}),n.d(r,"length",function(){return k}),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 we}),n.d(r,"setAxes",function(){return R});var s=n(2),o=n(5),a=n(8),c=n(9);function l(){var j=new s.ARRAY_TYPE(4);return s.ARRAY_TYPE!=Float32Array&&(j[0]=0,j[1]=0,j[2]=0),j[3]=1,j}function u(j){return j[0]=0,j[1]=0,j[2]=0,j[3]=1,j}function h(j,X,ae){ae=ae*.5;var q=Math.sin(ae);return j[0]=q*X[0],j[1]=q*X[1],j[2]=q*X[2],j[3]=Math.cos(ae),j}function d(j,X){var ae=Math.acos(X[3])*2,q=Math.sin(ae/2);return q>s.EPSILON?(j[0]=X[0]/q,j[1]=X[1]/q,j[2]=X[2]/q):(j[0]=1,j[1]=0,j[2]=0),ae}function g(j,X){var ae=K(j,X);return Math.acos(2*ae*ae-1)}function p(j,X,ae){var q=X[0],te=X[1],y=X[2],S=X[3],F=ae[0],Y=ae[1],_=ae[2],re=ae[3];return j[0]=q*re+S*F+te*_-y*Y,j[1]=te*re+S*Y+y*F-q*_,j[2]=y*re+S*_+q*Y-te*F,j[3]=S*re-q*F-te*Y-y*_,j}function M(j,X,ae){ae*=.5;var q=X[0],te=X[1],y=X[2],S=X[3],F=Math.sin(ae),Y=Math.cos(ae);return j[0]=q*Y+S*F,j[1]=te*Y+y*F,j[2]=y*Y-te*F,j[3]=S*Y-q*F,j}function I(j,X,ae){ae*=.5;var q=X[0],te=X[1],y=X[2],S=X[3],F=Math.sin(ae),Y=Math.cos(ae);return j[0]=q*Y-y*F,j[1]=te*Y+S*F,j[2]=y*Y+q*F,j[3]=S*Y-te*F,j}function D(j,X,ae){ae*=.5;var q=X[0],te=X[1],y=X[2],S=X[3],F=Math.sin(ae),Y=Math.cos(ae);return j[0]=q*Y+te*F,j[1]=te*Y-q*F,j[2]=y*Y+S*F,j[3]=S*Y-y*F,j}function C(j,X){var ae=X[0],q=X[1],te=X[2];return j[0]=ae,j[1]=q,j[2]=te,j[3]=Math.sqrt(Math.abs(1-ae*ae-q*q-te*te)),j}function B(j,X){var ae=X[0],q=X[1],te=X[2],y=X[3],S=Math.sqrt(ae*ae+q*q+te*te),F=Math.exp(y),Y=S>0?F*Math.sin(S)/S:0;return j[0]=ae*Y,j[1]=q*Y,j[2]=te*Y,j[3]=F*Math.cos(S),j}function T(j,X){var ae=X[0],q=X[1],te=X[2],y=X[3],S=Math.sqrt(ae*ae+q*q+te*te),F=S>0?Math.atan2(S,y)/S:0;return j[0]=ae*F,j[1]=q*F,j[2]=te*F,j[3]=.5*Math.log(ae*ae+q*q+te*te+y*y),j}function f(j,X,ae){return T(j,X),Q(j,j,ae),B(j,j),j}function m(j,X,ae,q){var te=X[0],y=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+y*_+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),j[0]=oe*te+de*Y,j[1]=oe*y+de*_,j[2]=oe*S+de*re,j[3]=oe*F+de*ne,j}function w(j){var X=s.RANDOM(),ae=s.RANDOM(),q=s.RANDOM(),te=Math.sqrt(1-X),y=Math.sqrt(X);return j[0]=te*Math.sin(2*Math.PI*ae),j[1]=te*Math.cos(2*Math.PI*ae),j[2]=y*Math.sin(2*Math.PI*q),j[3]=y*Math.cos(2*Math.PI*q),j}function v(j,X){var ae=X[0],q=X[1],te=X[2],y=X[3],S=ae*ae+q*q+te*te+y*y,F=S?1/S:0;return j[0]=-ae*F,j[1]=-q*F,j[2]=-te*F,j[3]=y*F,j}function b(j,X){return j[0]=-X[0],j[1]=-X[1],j[2]=-X[2],j[3]=X[3],j}function x(j,X){var ae=X[0]+X[4]+X[8],q;if(ae>0)q=Math.sqrt(ae+1),j[3]=.5*q,q=.5/q,j[0]=(X[5]-X[7])*q,j[1]=(X[6]-X[2])*q,j[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 y=(te+1)%3,S=(te+2)%3;q=Math.sqrt(X[te*3+te]-X[y*3+y]-X[S*3+S]+1),j[te]=.5*q,q=.5/q,j[3]=(X[y*3+S]-X[S*3+y])*q,j[y]=(X[y*3+te]+X[te*3+y])*q,j[S]=(X[S*3+te]+X[te*3+S])*q}return j}function z(j,X,ae,q){var te=.5*Math.PI/180;X*=te,ae*=te,q*=te;var y=Math.sin(X),S=Math.cos(X),F=Math.sin(ae),Y=Math.cos(ae),_=Math.sin(q),re=Math.cos(q);return j[0]=y*Y*re-S*F*_,j[1]=S*F*re+y*Y*_,j[2]=S*Y*_-y*F*re,j[3]=S*Y*re+y*F*_,j}function E(j){return"quat("+j[0]+", "+j[1]+", "+j[2]+", "+j[3]+")"}var O=c.clone,V=c.fromValues,N=c.copy,A=c.set,P=c.add,U=p,Q=c.scale,K=c.dot,ce=c.lerp,k=c.length,W=k,H=c.squaredLength,$=H,ee=c.normalize,ie=c.exactEquals,le=c.equals,pe=function(){var j=a.create(),X=a.fromValues(1,0,0),ae=a.fromValues(0,1,0);return function(q,te,y){var S=a.dot(te,y);return S<-.999999?(a.cross(j,X,te),a.len(j)<1e-6&&a.cross(j,ae,te),a.normalize(j,j),h(q,j,Math.PI),q):S>.999999?(q[0]=0,q[1]=0,q[2]=0,q[3]=1,q):(a.cross(j,te,y),q[0]=j[0],q[1]=j[1],q[2]=j[2],q[3]=1+S,ee(q,q))}}(),we=function(){var j=l(),X=l();return function(ae,q,te,y,S,F){return m(j,q,S,F),m(X,te,y,F),m(ae,j,X,2*F*(1-F)),ae}}(),R=function(){var j=o.create();return function(X,ae,q,te){return j[0]=q[0],j[3]=q[1],j[6]=q[2],j[1]=te[0],j[4]=te[1],j[7]=te[2],j[2]=-ae[0],j[5]=-ae[1],j[8]=-ae[2],ee(X,x(X,j))}}()},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 M}),n.d(r,"ceil",function(){return I}),n.d(r,"floor",function(){return D}),n.d(r,"min",function(){return C}),n.d(r,"max",function(){return B}),n.d(r,"round",function(){return T}),n.d(r,"scale",function(){return f}),n.d(r,"scaleAndAdd",function(){return m}),n.d(r,"distance",function(){return w}),n.d(r,"squaredDistance",function(){return v}),n.d(r,"squaredLength",function(){return b}),n.d(r,"negate",function(){return x}),n.d(r,"inverse",function(){return z}),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 P}),n.d(r,"random",function(){return U}),n.d(r,"transformMat4",function(){return Q}),n.d(r,"transformMat3",function(){return K}),n.d(r,"transformQuat",function(){return ce}),n.d(r,"rotateX",function(){return k}),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 we}),n.d(r,"mul",function(){return R}),n.d(r,"div",function(){return j}),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 y});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 M(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 C(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 B(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 T(S,F){return S[0]=Math.round(F[0]),S[1]=Math.round(F[1]),S[2]=Math.round(F[2]),S}function f(S,F,Y){return S[0]=F[0]*Y,S[1]=F[1]*Y,S[2]=F[2]*Y,S}function m(S,F,Y,_){return S[0]=F[0]+Y[0]*_,S[1]=F[1]+Y[1]*_,S[2]=F[2]+Y[2]*_,S}function w(S,F){var Y=F[0]-S[0],_=F[1]-S[1],re=F[2]-S[2];return Math.hypot(Y,_,re)}function v(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 x(S,F){return S[0]=-F[0],S[1]=-F[1],S[2]=-F[2],S}function z(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 P(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 Q(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 K(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,xe=re*ye-ne*me,Ce=ne*de-_*ye,Ie=_*me-re*de,ke=J*2;return de*=ke,me*=ke,ye*=ke,xe*=2,Ce*=2,Ie*=2,S[0]=se+de+xe,S[1]=ue+me+Ce,S[2]=oe+ye+Ie,S}function k(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 we=g,R=p,j=M,X=w,ae=v,q=c,te=b,y=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 M}),n.d(r,"floor",function(){return I}),n.d(r,"min",function(){return D}),n.d(r,"max",function(){return C}),n.d(r,"round",function(){return B}),n.d(r,"scale",function(){return T}),n.d(r,"scaleAndAdd",function(){return f}),n.d(r,"distance",function(){return m}),n.d(r,"squaredDistance",function(){return w}),n.d(r,"length",function(){return v}),n.d(r,"squaredLength",function(){return b}),n.d(r,"negate",function(){return x}),n.d(r,"inverse",function(){return z}),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 P}),n.d(r,"transformQuat",function(){return U}),n.d(r,"zero",function(){return Q}),n.d(r,"str",function(){return K}),n.d(r,"exactEquals",function(){return ce}),n.d(r,"equals",function(){return k}),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 we});var s=n(2);function o(){var R=new s.ARRAY_TYPE(4);return s.ARRAY_TYPE!=Float32Array&&(R[0]=0,R[1]=0,R[2]=0,R[3]=0),R}function a(R){var j=new s.ARRAY_TYPE(4);return j[0]=R[0],j[1]=R[1],j[2]=R[2],j[3]=R[3],j}function c(R,j,X,ae){var q=new s.ARRAY_TYPE(4);return q[0]=R,q[1]=j,q[2]=X,q[3]=ae,q}function l(R,j){return R[0]=j[0],R[1]=j[1],R[2]=j[2],R[3]=j[3],R}function u(R,j,X,ae,q){return R[0]=j,R[1]=X,R[2]=ae,R[3]=q,R}function h(R,j,X){return R[0]=j[0]+X[0],R[1]=j[1]+X[1],R[2]=j[2]+X[2],R[3]=j[3]+X[3],R}function d(R,j,X){return R[0]=j[0]-X[0],R[1]=j[1]-X[1],R[2]=j[2]-X[2],R[3]=j[3]-X[3],R}function g(R,j,X){return R[0]=j[0]*X[0],R[1]=j[1]*X[1],R[2]=j[2]*X[2],R[3]=j[3]*X[3],R}function p(R,j,X){return R[0]=j[0]/X[0],R[1]=j[1]/X[1],R[2]=j[2]/X[2],R[3]=j[3]/X[3],R}function M(R,j){return R[0]=Math.ceil(j[0]),R[1]=Math.ceil(j[1]),R[2]=Math.ceil(j[2]),R[3]=Math.ceil(j[3]),R}function I(R,j){return R[0]=Math.floor(j[0]),R[1]=Math.floor(j[1]),R[2]=Math.floor(j[2]),R[3]=Math.floor(j[3]),R}function D(R,j,X){return R[0]=Math.min(j[0],X[0]),R[1]=Math.min(j[1],X[1]),R[2]=Math.min(j[2],X[2]),R[3]=Math.min(j[3],X[3]),R}function C(R,j,X){return R[0]=Math.max(j[0],X[0]),R[1]=Math.max(j[1],X[1]),R[2]=Math.max(j[2],X[2]),R[3]=Math.max(j[3],X[3]),R}function B(R,j){return R[0]=Math.round(j[0]),R[1]=Math.round(j[1]),R[2]=Math.round(j[2]),R[3]=Math.round(j[3]),R}function T(R,j,X){return R[0]=j[0]*X,R[1]=j[1]*X,R[2]=j[2]*X,R[3]=j[3]*X,R}function f(R,j,X,ae){return R[0]=j[0]+X[0]*ae,R[1]=j[1]+X[1]*ae,R[2]=j[2]+X[2]*ae,R[3]=j[3]+X[3]*ae,R}function m(R,j){var X=j[0]-R[0],ae=j[1]-R[1],q=j[2]-R[2],te=j[3]-R[3];return Math.hypot(X,ae,q,te)}function w(R,j){var X=j[0]-R[0],ae=j[1]-R[1],q=j[2]-R[2],te=j[3]-R[3];return X*X+ae*ae+q*q+te*te}function v(R){var j=R[0],X=R[1],ae=R[2],q=R[3];return Math.hypot(j,X,ae,q)}function b(R){var j=R[0],X=R[1],ae=R[2],q=R[3];return j*j+X*X+ae*ae+q*q}function x(R,j){return R[0]=-j[0],R[1]=-j[1],R[2]=-j[2],R[3]=-j[3],R}function z(R,j){return R[0]=1/j[0],R[1]=1/j[1],R[2]=1/j[2],R[3]=1/j[3],R}function E(R,j){var X=j[0],ae=j[1],q=j[2],te=j[3],y=X*X+ae*ae+q*q+te*te;return y>0&&(y=1/Math.sqrt(y)),R[0]=X*y,R[1]=ae*y,R[2]=q*y,R[3]=te*y,R}function O(R,j){return R[0]*j[0]+R[1]*j[1]+R[2]*j[2]+R[3]*j[3]}function V(R,j,X,ae){var q=X[0]*ae[1]-X[1]*ae[0],te=X[0]*ae[2]-X[2]*ae[0],y=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],_=j[0],re=j[1],ne=j[2],J=j[3];return R[0]=re*Y-ne*F+J*S,R[1]=-(_*Y)+ne*y-J*te,R[2]=_*F-re*y+J*q,R[3]=-(_*S)+re*te-ne*q,R}function N(R,j,X,ae){var q=j[0],te=j[1],y=j[2],S=j[3];return R[0]=q+ae*(X[0]-q),R[1]=te+ae*(X[1]-te),R[2]=y+ae*(X[2]-y),R[3]=S+ae*(X[3]-S),R}function A(R,j){j=j||1;var X,ae,q,te,y,S;do X=s.RANDOM()*2-1,ae=s.RANDOM()*2-1,y=X*X+ae*ae;while(y>=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-y)/S);return R[0]=j*X,R[1]=j*ae,R[2]=j*q*F,R[3]=j*te*F,R}function P(R,j,X){var ae=j[0],q=j[1],te=j[2],y=j[3];return R[0]=X[0]*ae+X[4]*q+X[8]*te+X[12]*y,R[1]=X[1]*ae+X[5]*q+X[9]*te+X[13]*y,R[2]=X[2]*ae+X[6]*q+X[10]*te+X[14]*y,R[3]=X[3]*ae+X[7]*q+X[11]*te+X[15]*y,R}function U(R,j,X){var ae=j[0],q=j[1],te=j[2],y=X[0],S=X[1],F=X[2],Y=X[3],_=Y*ae+S*te-F*q,re=Y*q+F*ae-y*te,ne=Y*te+y*q-S*ae,J=-y*ae-S*q-F*te;return R[0]=_*Y+J*-y+re*-F-ne*-S,R[1]=re*Y+J*-S+ne*-y-_*-F,R[2]=ne*Y+J*-F+_*-S-re*-y,R[3]=j[3],R}function Q(R){return R[0]=0,R[1]=0,R[2]=0,R[3]=0,R}function K(R){return"vec4("+R[0]+", "+R[1]+", "+R[2]+", "+R[3]+")"}function ce(R,j){return R[0]===j[0]&&R[1]===j[1]&&R[2]===j[2]&&R[3]===j[3]}function k(R,j){var X=R[0],ae=R[1],q=R[2],te=R[3],y=j[0],S=j[1],F=j[2],Y=j[3];return Math.abs(X-y)<=s.EPSILON*Math.max(1,Math.abs(X),Math.abs(y))&&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=m,ie=w,le=v,pe=b,we=function(){var R=o();return function(j,X,ae,q,te,y){var S,F;for(X||(X=4),ae||(ae=0),q?F=Math.min(q*X+ae,j.length):F=j.length,S=ae;S<F;S+=X)R[0]=j[S],R[1]=j[S+1],R[2]=j[S+2],R[3]=j[S+3],te(R,R,y),j[S]=R[0],j[S+1]=R[1],j[S+2]=R[2],j[S+3]=R[3];return j}}()},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 M}),n.d(r,"copy",function(){return I}),n.d(r,"identity",function(){return D}),n.d(r,"set",function(){return C}),n.d(r,"getReal",function(){return B}),n.d(r,"getDual",function(){return T}),n.d(r,"setReal",function(){return f}),n.d(r,"setDual",function(){return m}),n.d(r,"getTranslation",function(){return w}),n.d(r,"translate",function(){return v}),n.d(r,"rotateX",function(){return b}),n.d(r,"rotateY",function(){return x}),n.d(r,"rotateZ",function(){return z}),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 P}),n.d(r,"scale",function(){return U}),n.d(r,"dot",function(){return Q}),n.d(r,"lerp",function(){return K}),n.d(r,"invert",function(){return ce}),n.d(r,"conjugate",function(){return k}),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 we});var s=n(2),o=n(7),a=n(6);function c(){var R=new s.ARRAY_TYPE(8);return s.ARRAY_TYPE!=Float32Array&&(R[0]=0,R[1]=0,R[2]=0,R[4]=0,R[5]=0,R[6]=0,R[7]=0),R[3]=1,R}function l(R){var j=new s.ARRAY_TYPE(8);return j[0]=R[0],j[1]=R[1],j[2]=R[2],j[3]=R[3],j[4]=R[4],j[5]=R[5],j[6]=R[6],j[7]=R[7],j}function u(R,j,X,ae,q,te,y,S){var F=new s.ARRAY_TYPE(8);return F[0]=R,F[1]=j,F[2]=X,F[3]=ae,F[4]=q,F[5]=te,F[6]=y,F[7]=S,F}function h(R,j,X,ae,q,te,y){var S=new s.ARRAY_TYPE(8);S[0]=R,S[1]=j,S[2]=X,S[3]=ae;var F=q*.5,Y=te*.5,_=y*.5;return S[4]=F*ae+Y*X-_*j,S[5]=Y*ae+_*R-F*X,S[6]=_*ae+F*j-Y*R,S[7]=-F*R-Y*j-_*X,S}function d(R,j,X){var ae=X[0]*.5,q=X[1]*.5,te=X[2]*.5,y=j[0],S=j[1],F=j[2],Y=j[3];return R[0]=y,R[1]=S,R[2]=F,R[3]=Y,R[4]=ae*Y+q*F-te*S,R[5]=q*Y+te*y-ae*F,R[6]=te*Y+ae*S-q*y,R[7]=-ae*y-q*S-te*F,R}function g(R,j){return R[0]=0,R[1]=0,R[2]=0,R[3]=1,R[4]=j[0]*.5,R[5]=j[1]*.5,R[6]=j[2]*.5,R[7]=0,R}function p(R,j){return R[0]=j[0],R[1]=j[1],R[2]=j[2],R[3]=j[3],R[4]=0,R[5]=0,R[6]=0,R[7]=0,R}function M(R,j){var X=o.create();a.getRotation(X,j);var ae=new s.ARRAY_TYPE(3);return a.getTranslation(ae,j),d(R,X,ae),R}function I(R,j){return R[0]=j[0],R[1]=j[1],R[2]=j[2],R[3]=j[3],R[4]=j[4],R[5]=j[5],R[6]=j[6],R[7]=j[7],R}function D(R){return R[0]=0,R[1]=0,R[2]=0,R[3]=1,R[4]=0,R[5]=0,R[6]=0,R[7]=0,R}function C(R,j,X,ae,q,te,y,S,F){return R[0]=j,R[1]=X,R[2]=ae,R[3]=q,R[4]=te,R[5]=y,R[6]=S,R[7]=F,R}var B=o.copy;function T(R,j){return R[0]=j[4],R[1]=j[5],R[2]=j[6],R[3]=j[7],R}var f=o.copy;function m(R,j){return R[4]=j[0],R[5]=j[1],R[6]=j[2],R[7]=j[3],R}function w(R,j){var X=j[4],ae=j[5],q=j[6],te=j[7],y=-j[0],S=-j[1],F=-j[2],Y=j[3];return R[0]=(X*Y+te*y+ae*F-q*S)*2,R[1]=(ae*Y+te*S+q*y-X*F)*2,R[2]=(q*Y+te*F+X*S-ae*y)*2,R}function v(R,j,X){var ae=j[0],q=j[1],te=j[2],y=j[3],S=X[0]*.5,F=X[1]*.5,Y=X[2]*.5,_=j[4],re=j[5],ne=j[6],J=j[7];return R[0]=ae,R[1]=q,R[2]=te,R[3]=y,R[4]=y*S+q*Y-te*F+_,R[5]=y*F+te*S-ae*Y+re,R[6]=y*Y+ae*F-q*S+ne,R[7]=-ae*S-q*F-te*Y+J,R}function b(R,j,X){var ae=-j[0],q=-j[1],te=-j[2],y=j[3],S=j[4],F=j[5],Y=j[6],_=j[7],re=S*y+_*ae+F*te-Y*q,ne=F*y+_*q+Y*ae-S*te,J=Y*y+_*te+S*q-F*ae,se=_*y-S*ae-F*q-Y*te;return o.rotateX(R,j,X),ae=R[0],q=R[1],te=R[2],y=R[3],R[4]=re*y+se*ae+ne*te-J*q,R[5]=ne*y+se*q+J*ae-re*te,R[6]=J*y+se*te+re*q-ne*ae,R[7]=se*y-re*ae-ne*q-J*te,R}function x(R,j,X){var ae=-j[0],q=-j[1],te=-j[2],y=j[3],S=j[4],F=j[5],Y=j[6],_=j[7],re=S*y+_*ae+F*te-Y*q,ne=F*y+_*q+Y*ae-S*te,J=Y*y+_*te+S*q-F*ae,se=_*y-S*ae-F*q-Y*te;return o.rotateY(R,j,X),ae=R[0],q=R[1],te=R[2],y=R[3],R[4]=re*y+se*ae+ne*te-J*q,R[5]=ne*y+se*q+J*ae-re*te,R[6]=J*y+se*te+re*q-ne*ae,R[7]=se*y-re*ae-ne*q-J*te,R}function z(R,j,X){var ae=-j[0],q=-j[1],te=-j[2],y=j[3],S=j[4],F=j[5],Y=j[6],_=j[7],re=S*y+_*ae+F*te-Y*q,ne=F*y+_*q+Y*ae-S*te,J=Y*y+_*te+S*q-F*ae,se=_*y-S*ae-F*q-Y*te;return o.rotateZ(R,j,X),ae=R[0],q=R[1],te=R[2],y=R[3],R[4]=re*y+se*ae+ne*te-J*q,R[5]=ne*y+se*q+J*ae-re*te,R[6]=J*y+se*te+re*q-ne*ae,R[7]=se*y-re*ae-ne*q-J*te,R}function E(R,j,X){var ae=X[0],q=X[1],te=X[2],y=X[3],S=j[0],F=j[1],Y=j[2],_=j[3];return R[0]=S*y+_*ae+F*te-Y*q,R[1]=F*y+_*q+Y*ae-S*te,R[2]=Y*y+_*te+S*q-F*ae,R[3]=_*y-S*ae-F*q-Y*te,S=j[4],F=j[5],Y=j[6],_=j[7],R[4]=S*y+_*ae+F*te-Y*q,R[5]=F*y+_*q+Y*ae-S*te,R[6]=Y*y+_*te+S*q-F*ae,R[7]=_*y-S*ae-F*q-Y*te,R}function O(R,j,X){var ae=j[0],q=j[1],te=j[2],y=j[3],S=X[0],F=X[1],Y=X[2],_=X[3];return R[0]=ae*_+y*S+q*Y-te*F,R[1]=q*_+y*F+te*S-ae*Y,R[2]=te*_+y*Y+ae*F-q*S,R[3]=y*_-ae*S-q*F-te*Y,S=X[4],F=X[5],Y=X[6],_=X[7],R[4]=ae*_+y*S+q*Y-te*F,R[5]=q*_+y*F+te*S-ae*Y,R[6]=te*_+y*Y+ae*F-q*S,R[7]=y*_-ae*S-q*F-te*Y,R}function V(R,j,X,ae){if(Math.abs(ae)<s.EPSILON)return I(R,j);var q=Math.hypot(X[0],X[1],X[2]);ae=ae*.5;var te=Math.sin(ae),y=te*X[0]/q,S=te*X[1]/q,F=te*X[2]/q,Y=Math.cos(ae),_=j[0],re=j[1],ne=j[2],J=j[3];R[0]=_*Y+J*y+re*F-ne*S,R[1]=re*Y+J*S+ne*y-_*F,R[2]=ne*Y+J*F+_*S-re*y,R[3]=J*Y-_*y-re*S-ne*F;var se=j[4],ue=j[5],oe=j[6],de=j[7];return R[4]=se*Y+de*y+ue*F-oe*S,R[5]=ue*Y+de*S+oe*y-se*F,R[6]=oe*Y+de*F+se*S-ue*y,R[7]=de*Y-se*y-ue*S-oe*F,R}function N(R,j,X){return R[0]=j[0]+X[0],R[1]=j[1]+X[1],R[2]=j[2]+X[2],R[3]=j[3]+X[3],R[4]=j[4]+X[4],R[5]=j[5]+X[5],R[6]=j[6]+X[6],R[7]=j[7]+X[7],R}function A(R,j,X){var ae=j[0],q=j[1],te=j[2],y=j[3],S=X[4],F=X[5],Y=X[6],_=X[7],re=j[4],ne=j[5],J=j[6],se=j[7],ue=X[0],oe=X[1],de=X[2],me=X[3];return R[0]=ae*me+y*ue+q*de-te*oe,R[1]=q*me+y*oe+te*ue-ae*de,R[2]=te*me+y*de+ae*oe-q*ue,R[3]=y*me-ae*ue-q*oe-te*de,R[4]=ae*_+y*S+q*Y-te*F+re*me+se*ue+ne*de-J*oe,R[5]=q*_+y*F+te*S-ae*Y+ne*me+se*oe+J*ue-re*de,R[6]=te*_+y*Y+ae*F-q*S+J*me+se*de+re*oe-ne*ue,R[7]=y*_-ae*S-q*F-te*Y+se*me-re*ue-ne*oe-J*de,R}var P=A;function U(R,j,X){return R[0]=j[0]*X,R[1]=j[1]*X,R[2]=j[2]*X,R[3]=j[3]*X,R[4]=j[4]*X,R[5]=j[5]*X,R[6]=j[6]*X,R[7]=j[7]*X,R}var Q=o.dot;function K(R,j,X,ae){var q=1-ae;return Q(j,X)<0&&(ae=-ae),R[0]=j[0]*q+X[0]*ae,R[1]=j[1]*q+X[1]*ae,R[2]=j[2]*q+X[2]*ae,R[3]=j[3]*q+X[3]*ae,R[4]=j[4]*q+X[4]*ae,R[5]=j[5]*q+X[5]*ae,R[6]=j[6]*q+X[6]*ae,R[7]=j[7]*q+X[7]*ae,R}function ce(R,j){var X=$(j);return R[0]=-j[0]/X,R[1]=-j[1]/X,R[2]=-j[2]/X,R[3]=j[3]/X,R[4]=-j[4]/X,R[5]=-j[5]/X,R[6]=-j[6]/X,R[7]=j[7]/X,R}function k(R,j){return R[0]=-j[0],R[1]=-j[1],R[2]=-j[2],R[3]=j[3],R[4]=-j[4],R[5]=-j[5],R[6]=-j[6],R[7]=j[7],R}var W=o.length,H=W,$=o.squaredLength,ee=$;function ie(R,j){var X=$(j);if(X>0){X=Math.sqrt(X);var ae=j[0]/X,q=j[1]/X,te=j[2]/X,y=j[3]/X,S=j[4],F=j[5],Y=j[6],_=j[7],re=ae*S+q*F+te*Y+y*_;R[0]=ae,R[1]=q,R[2]=te,R[3]=y,R[4]=(S-ae*re)/X,R[5]=(F-q*re)/X,R[6]=(Y-te*re)/X,R[7]=(_-y*re)/X}return R}function le(R){return"quat2("+R[0]+", "+R[1]+", "+R[2]+", "+R[3]+", "+R[4]+", "+R[5]+", "+R[6]+", "+R[7]+")"}function pe(R,j){return R[0]===j[0]&&R[1]===j[1]&&R[2]===j[2]&&R[3]===j[3]&&R[4]===j[4]&&R[5]===j[5]&&R[6]===j[6]&&R[7]===j[7]}function we(R,j){var X=R[0],ae=R[1],q=R[2],te=R[3],y=R[4],S=R[5],F=R[6],Y=R[7],_=j[0],re=j[1],ne=j[2],J=j[3],se=j[4],ue=j[5],oe=j[6],de=j[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(y-se)<=s.EPSILON*Math.max(1,Math.abs(y),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 M}),n.d(r,"floor",function(){return I}),n.d(r,"min",function(){return D}),n.d(r,"max",function(){return C}),n.d(r,"round",function(){return B}),n.d(r,"scale",function(){return T}),n.d(r,"scaleAndAdd",function(){return f}),n.d(r,"distance",function(){return m}),n.d(r,"squaredDistance",function(){return w}),n.d(r,"length",function(){return v}),n.d(r,"squaredLength",function(){return b}),n.d(r,"negate",function(){return x}),n.d(r,"inverse",function(){return z}),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 P}),n.d(r,"transformMat2d",function(){return U}),n.d(r,"transformMat3",function(){return Q}),n.d(r,"transformMat4",function(){return K}),n.d(r,"rotate",function(){return ce}),n.d(r,"angle",function(){return k}),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 we}),n.d(r,"dist",function(){return R}),n.d(r,"sqrDist",function(){return j}),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 y=new s.ARRAY_TYPE(2);return y[0]=q,y[1]=te,y}function l(q,te){return q[0]=te[0],q[1]=te[1],q}function u(q,te,y){return q[0]=te,q[1]=y,q}function h(q,te,y){return q[0]=te[0]+y[0],q[1]=te[1]+y[1],q}function d(q,te,y){return q[0]=te[0]-y[0],q[1]=te[1]-y[1],q}function g(q,te,y){return q[0]=te[0]*y[0],q[1]=te[1]*y[1],q}function p(q,te,y){return q[0]=te[0]/y[0],q[1]=te[1]/y[1],q}function M(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,y){return q[0]=Math.min(te[0],y[0]),q[1]=Math.min(te[1],y[1]),q}function C(q,te,y){return q[0]=Math.max(te[0],y[0]),q[1]=Math.max(te[1],y[1]),q}function B(q,te){return q[0]=Math.round(te[0]),q[1]=Math.round(te[1]),q}function T(q,te,y){return q[0]=te[0]*y,q[1]=te[1]*y,q}function f(q,te,y,S){return q[0]=te[0]+y[0]*S,q[1]=te[1]+y[1]*S,q}function m(q,te){var y=te[0]-q[0],S=te[1]-q[1];return Math.hypot(y,S)}function w(q,te){var y=te[0]-q[0],S=te[1]-q[1];return y*y+S*S}function v(q){var te=q[0],y=q[1];return Math.hypot(te,y)}function b(q){var te=q[0],y=q[1];return te*te+y*y}function x(q,te){return q[0]=-te[0],q[1]=-te[1],q}function z(q,te){return q[0]=1/te[0],q[1]=1/te[1],q}function E(q,te){var y=te[0],S=te[1],F=y*y+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,y){var S=te[0]*y[1]-te[1]*y[0];return q[0]=q[1]=0,q[2]=S,q}function N(q,te,y,S){var F=te[0],Y=te[1];return q[0]=F+S*(y[0]-F),q[1]=Y+S*(y[1]-Y),q}function A(q,te){te=te||1;var y=s.RANDOM()*2*Math.PI;return q[0]=Math.cos(y)*te,q[1]=Math.sin(y)*te,q}function P(q,te,y){var S=te[0],F=te[1];return q[0]=y[0]*S+y[2]*F,q[1]=y[1]*S+y[3]*F,q}function U(q,te,y){var S=te[0],F=te[1];return q[0]=y[0]*S+y[2]*F+y[4],q[1]=y[1]*S+y[3]*F+y[5],q}function Q(q,te,y){var S=te[0],F=te[1];return q[0]=y[0]*S+y[3]*F+y[6],q[1]=y[1]*S+y[4]*F+y[7],q}function K(q,te,y){var S=te[0],F=te[1];return q[0]=y[0]*S+y[4]*F+y[12],q[1]=y[1]*S+y[5]*F+y[13],q}function ce(q,te,y,S){var F=te[0]-y[0],Y=te[1]-y[1],_=Math.sin(S),re=Math.cos(S);return q[0]=F*re-Y*_+y[0],q[1]=F*_+Y*re+y[1],q}function k(q,te){var y=q[0],S=q[1],F=te[0],Y=te[1],_=Math.sqrt(y*y+S*S)*Math.sqrt(F*F+Y*Y),re=_&&(y*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 y=q[0],S=q[1],F=te[0],Y=te[1];return Math.abs(y-F)<=s.EPSILON*Math.max(1,Math.abs(y),Math.abs(F))&&Math.abs(S-Y)<=s.EPSILON*Math.max(1,Math.abs(S),Math.abs(Y))}var ie=v,le=d,pe=g,we=p,R=m,j=w,X=b,ae=function(){var q=o();return function(te,y,S,F,Y,_){var re,ne;for(y||(y=2),S||(S=0),F?ne=Math.min(F*y+S,te.length):ne=te.length,re=S;re<ne;re+=y)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 k});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),M=n(36),I=n(43),D=n(41),C=n(56),B=n(73),T=n(45),f=n(78),m=n(37),w=n(82);n(1).glMatrix.setMatrixArrayType(Array);function v(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(j){throw j},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,we;return{s:function(){$=W[Symbol.iterator]()},n:function(){var j=$.next();return le=j.done,j},e:function(j){pe=!0,we=j},f:function(){try{!le&&$.return!=null&&$.return()}finally{if(pe)throw we}}}}function b(W,H){if(W){if(typeof W=="string")return x(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 x(W,H)}}function x(W,H){(H==null||H>W.length)&&(H=W.length);for(var $=0,ee=new Array(H);$<H;$++)ee[$]=W[$];return ee}var z={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"),P=Symbol("globalTransform"),U=Symbol("applyGlobalTransform"),Q=Symbol("canvas");function K(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 B.default({contours:le});pe.setTexture(ie),W.setMeshData([pe.meshData]),K(W),ie.delete(),H.clearRect(0,0,$,ee),delete H._filter}var k=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[Q]=H,ee!=="webgl"&&ee!=="webgl2"&&ee!=="2d")throw new Error("Unknown context type ".concat(ee));if($.contextType=ee,this[A]=Object.assign({},z,$),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(w.createShaders)(le),Object(w.applyShader)(le),Object(w.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 M.default(H,this[A]);this[P]=[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],we=p.mat3.multiply(Array.of(0,0,0,0,0,0,0,0,0),pe,le);this.projectionMatrix=we,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,we=pe===void 0?null:pe,R=ee.strokeColor,j=R===void 0?null:R,X=ee.strokeWidth,ae=X===void 0?1:X;if(this[V]){var q=m.default.createText($,{font:le,fillColor:we,strokeColor:j,strokeWidth:ae});return{image:this.createTexture(q.image),rect:q.rect}}return{_img:{font:le,fillColor:we,strokeColor:j,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,we=$.options;return this.createProgram({vertex:ie,fragment:pe,options:we})}},{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,we=pe===void 0?null:pe,R=this[V]||this[N],j=we||$.program;if(this[V]){var X=R.gl;if(le&&X.clear(X.COLOR_BUFFER_BIT),j)R.program!==j&&this.useProgram(j,{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,y=!!ae.uniforms.u_radialGradientVector,S=$.hasCloudColor,F=$.hasCloudFilter,Y=!!ae.uniforms.u_clipSampler;Object(w.applyCloudShader)(R,{hasTexture:q,hasFilter:te,hasGradient:y,hasCloudColor:S,hasCloudFilter:F,hasClipPath:Y})}this[U](),R.setMeshData([$.meshData]),$.beforeRender&&$.beforeRender(X,$),K(R),$.afterRender&&$.afterRender(X,$)}else R.setTransform(this.globalTransformMatrix),R.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,we=ie.program,R=we===void 0?null:we,j=this[V]||this[N];this[V]?function(){var X=j.fbo,ae=Object(I.default)(ee,$,R==null),q=j.gl;pe&&q.clear(q.COLOR_BUFFER_BIT);var te=!Object(f.isUnitTransform)(ee.globalTransformMatrix);ee._drawCalls=0;var y=v(ae),S;try{var F=function(){var _=S.value;ee._drawCalls++;var re=R||_.program;if(_ instanceof T.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:j.createFBO(),buffer:j.createFBO(),swap:function(){var je=[this.buffer,this.target];this.target=je[0],this.buffer=je[1]}}),j.bindFBO(ee.fbo.target)),!re&&_.filterCanvas){Object(w.applyShader)(j,{hasTexture:!0});var ue=ee.filterContext;if(!ue){var oe=m.default.createCanvas(J,se);ue=oe.getContext("2d"),ee.filterContext=ue}var de=$[_.packIndex],me=de.filter,ye=$[_.packIndex+1],xe=$[_.packIndex-1];(!xe||!xe.filterCanvas||xe.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(j,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(j,ue,J,se)))}else{if(re)j.program!==re&&ee.useProgram(re,{a_color:{type:"UNSIGNED_BYTE",normalize:!0}});else{var Ce=!!_.uniforms.u_texSampler,Ie=!!_.uniforms.u_filterFlag,ke=!!_.uniforms.u_radialGradientVector,Re=!!_.uniforms.u_clipSampler;Object(w.applyShader)(j,{hasTexture:Ce,hasFilter:Ie,hasGradient:ke,hasClipPath:Re})}_.filterCanvas&&console.warn("User program ignored some filter effects."),ee[U](),j.setMeshData([_]),K(j)}if(_.pass.length){var Le=_.pass.length;_.pass.forEach(function(Oe,je){Oe.blend=_.enableBlend,Oe.setTexture(j.fbo.texture),je===Le-1?j.bindFBO(X):(ee.fbo.swap(),j.bindFBO(ee.fbo.target)),Oe.program?j.useProgram(Oe.program):(ee.defaultPassProgram=ee.defaultPassProgram||ee.createPassProgram(),j.useProgram(ee.defaultPassProgram)),j.setMeshData([Oe.meshData]),q.clear(q.COLOR_BUFFER_BIT),K(j)})}_.afterRender&&_.afterRender(q,_)}};for(y.s();!(S=y.n()).done;)F()}catch(Y){y.e(Y)}finally{y.f()}}():(j.setTransform(this.globalTransformMatrix),j.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 we=null,R=null;pe===2?we=[ie[0],ie[1],$.width,$.height]:pe===4?we=ie:pe===8&&(R=ie.slice(0,4),we=ie.slice(4));var j=this.createTexture($),X=this.canvas,ae=X.width,q=X.height,te=new C.default;te.rect(we[0],we[1],ae,q);var y=new B.default(te,{width:ae,height:q});y.setTexture(j,{rect:we,srcRect:R}),this.drawMeshes([y]),this.deleteTexture(j)}},{key:"setGlobalTransform",value:function(){return this[P]=[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[P],ee=arguments.length,ie=new Array(ee),le=0;le<ee;le++)ie[le]=arguments[le];return this[P]=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],we=p.mat3.create();return we=p.mat3.translate(Array.of(0,0,0,0,0,0,0,0,0),we,[le,pe]),we=p.mat3.rotate(Array.of(0,0,0,0,0,0,0,0,0),we,$),we=p.mat3.translate(Array.of(0,0,0,0,0,0,0,0,0),we,[-le,-pe]),this.globalTransform.apply(this,c()(we))}},{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],we=le[1],R=p.mat3.create();return R=p.mat3.translate(Array.of(0,0,0,0,0,0,0,0,0),R,[pe,we]),R=p.mat3.scale(Array.of(0,0,0,0,0,0,0,0,0),R,[$,ee]),R=p.mat3.translate(Array.of(0,0,0,0,0,0,0,0,0),R,[-pe,-we]),this.globalTransform.apply(this,c()(R))}},{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],we=le[1],R=p.mat3.create();return R=p.mat3.translate(Array.of(0,0,0,0,0,0,0,0,0),R,[pe,we]),R=p.mat3.multiply(Array.of(0,0,0,0,0,0,0,0,0),R,p.mat3.fromValues(1,Math.tan(ee),Math.tan($),1,0,0)),R=p.mat3.translate(Array.of(0,0,0,0,0,0,0,0,0),R,[-pe,-we]),this.globalTransform.apply(this,c()(R))}},{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],we=$*le[1]+ee*le[3]+le[5];return[pe,we]}},{key:"canvas",get:function(){return this[Q]}},{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[P];return[$[0],$[1],$[3],$[4],$[6],$[7]]}},{key:"viewMatrix",get:function(){return this[P]}}]),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),M=n(24),I=n.n(M),D=n(30),C=n.n(D),B=n(31),T=n(33),f=n(34),m=n(35);n(1).glMatrix.setMatrixArrayType(Array);var w={};function v(O){for(var V=arguments.length>1&&arguments[1]!==void 0?arguments[1]:3,N=[],A=O.length,P=0;P<A;P++)P%V<2&&N.push(.5*(O[P]+1));return N}function b(O,V){var N=V._buffers;Object.values(N).forEach(function(A){O.deleteBuffer(A)}),V._buffers={}}function x(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 z={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(w,N)}},{key:"FLOAT",value:function(N,A){return Object(B.pointsToBuffer)(N,Float32Array,A)}},{key:"UNSIGNED_BYTE",value:function(N,A){return Object(B.pointsToBuffer)(N,Uint8Array,A)}},{key:"UNSIGNED_SHORT",value:function(N,A){return Object(B.pointsToBuffer)(N,Uint16Array,A)}},{key:"BYTE",value:function(N,A){return Object(B.pointsToBuffer)(N,Int8Array,A)}},{key:"SHORT",value:function(N,A){return Object(B.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(B.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 P=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"1f",U=this.gl,Q=U.getUniformLocation(N,A),K,ce=this;if(/^sampler/.test(P)){var k=N._samplerMap,W=N._bindTextures;Object.defineProperty(N.uniforms,A,{get:function(){return K},set:function(le){K=le;var pe=k[A]!=null?k[A]:W.length;W[pe]=le,x(U,le,pe),k[A]||(k[A]=pe,U.uniform1i(Q,pe)),ce.options.autoUpdate&&ce.update()},configurable:!1,enumerable:!0})}else{var H=P.indexOf("Matrix")===0,$=!H&&/v$/.test(P),ee=U["uniform".concat(P)].bind(U);Object.defineProperty(N.uniforms,A,{get:function(){return K},set:function(le){K=le,typeof le=="number"&&(le=[le]),H?ee(Q,!1,le):$?ee(Q,le):ee.apply(void 0,[Q].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(P,U){var Q=P.positions,K=P.cells,ce=P.instanceCount,k=P.cellsCount,W=P.attributes,H=P.uniforms,$=P.textureCoord,ee=P.enableBlend,ie=N.gl,le=P.mode!=null?P.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,Q,ie.STATIC_DRAW),K&&(ie.bindBuffer(ie.ELEMENT_ARRAY_BUFFER,A._buffers.cellsBuffer),ie.bufferData(ie.ELEMENT_ARRAY_BUFFER,K,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 y=ie.getAttribLocation(A,ae);y>=0&&(ie.enableVertexAttribArray(y),pe.push(y),ie.vertexAttribDivisor?ie.vertexAttribDivisor(y,te):N.aia_ext&&N.aia_ext.vertexAttribDivisorANGLE(y,te))}}),H&&Object.entries(H).forEach(function(X){var ae=u()(X,2),q=ae[0],te=ae[1];N.uniforms[q]=te});var we;if(!K){var R=A._dimension;we=Q.length/R}if(A._enableTextures&&A._buffers.texCoordBuffer){var j=$||v(Q,A._dimension);ie.bindBuffer(ie.ARRAY_BUFFER,A._buffers.texCoordBuffer),ie.bufferData(ie.ARRAY_BUFFER,O.FLOAT(j),ie.STATIC_DRAW)}ce!=null?(K?ie.drawElementsInstanced?ie.drawElementsInstanced(le,k,ie.UNSIGNED_SHORT,0,ce):N.aia_ext&&N.aia_ext.drawElementsInstancedANGLE(le,k,ie.UNSIGNED_SHORT,0,ce):ie.drawArraysInstanced?ie.drawArraysInstanced(le,0,we,ce):N.aia_ext.drawArraysInstancedANGLE(le,0,we,ce),pe.forEach(function(X){ie.vertexAttribDivisor?ie.vertexAttribDivisor(X,null):N.aia_ext&&N.aia_ext.vertexAttribDivisorANGLE(X,null)})):K?ie.drawElements(le,k,ie.UNSIGNED_SHORT,0):ie.drawArrays(le,0,we)})}},{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 P=this.programs.indexOf(N);P>=0&&this.programs.splice(P,1),b(A,N),A.deleteProgram(N)}},{key:"setMeshData",value:function(N){var A=this;Array.isArray(N)||(N=[N]);var P=this.program;P.meshData=N.map(function(U){var Q=U.mode,K=U.positions,ce=U.instanceCount,k=U.cells,W=U.cellsCount,H=U.attributes,$=U.uniforms,ee=U.textureCoord,ie=U.enableBlend,le={positions:O.FLOAT(K),uniforms:$,enableBlend:!!ie,textureCoord:O.FLOAT(ee)};if(k&&(le.cells=O.USHORT(k),le.cellsCount=W||le.cells.length),Q!=null&&(le.mode=Q),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(we){var R=u()(we,2),j=R[0],X=R[1];if(!P._attribute[j])P._attribute[j]="ignored";else if(P._attribute[j]!=="ignored"){var ae=P._attribute[j],q=ae.name,te=ae.type,y=X.data||X;if(Array.isArray(y)&&(y=O[te](y)),pe[j]={name:q,data:y},X.divisor!=null){if(!A.isWebGL2&&!A.aia_ext)throw new Error("Cannot use divisor in this rendering context, use webgl2 context instead.");pe[j].divisor=X.divisor}}}),le.attributes=pe}return le}),this.options.autoUpdate&&this.update()}},{key:"createProgram",value:function(N,A){var P=this,U=/^\s*uniform\s+sampler/mg.test(N);N==null&&(N=f.default),A==null&&(A=U?m.default:T.default);var Q=this.gl,K=Object(B.createProgram)(Q,A,N);K.shaderText={vertexShader:A,fragmentShader:N},K._buffers={},K._attribute={},K.uniforms={},K._samplerMap={},K._bindTextures=[];var ce=new RegExp("(?:attribute|in) vec(\\d) ".concat(this.options.vertexPosition),"im"),k=A.match(ce);k&&(K._dimension=Number(k[1]));var W=new RegExp("(?:attribute|in) vec(\\d) ".concat(this.options.vertexTextureCoord),"im");k=A.match(W),k&&(K._texCoordSize=Number(k[1]));var H=/^\s*(?:attribute|in) (\w+?)(\d*) (\w+)/gim;if(k=A.match(H),k)for(var $=0;$<k.length;$++){var ee=/^\s*(?:attribute|in) (\w+?)(\d*) (\w+)/im,ie=k[$].match(ee);if(ie&&ie[3]!==this.options.vertexPosition&&ie[3]!==this.options.vertexTextureCoord){var le=u()(ie,4),pe=le[1],we=le[2],R=le[3];pe==="mat"&&(we=Math.pow(we,2)),K._buffers[R]=Q.createBuffer(),K._attribute[R]={name:R,type:pe,size:Number(we)||1}}}var j=/^\s*uniform\s+(\w+)\s+(\w+)(\[\d+\])?/mg;k=A.match(j)||[],k=k.concat(N.match(j)||[]),k.forEach(function(ae){var q=ae.match(/^\s*uniform\s+(\w+)\s+(\w+)(\[\d+\])?/),te=q.slice(1),y=u()(te,3),S=y[0],F=y[1],Y=y[2];S=z[S],Y=!!Y,S.indexOf("Matrix")!==0&&Y&&(S+="v"),P._declareUniform(K,F,S)}),K._buffers.verticesBuffer=Q.createBuffer(),K._buffers.cellsBuffer=Q.createBuffer();var X=Q.getAttribLocation(K,this.options.vertexTextureCoord);return K._enableTextures=X>=0,K._enableTextures&&(K._buffers.texCoordBuffer=Q.createBuffer()),this.programs.push(K),K}},{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 P=this.gl;P.useProgram(N);var U=N._dimension;P.bindBuffer(P.ARRAY_BUFFER,N._buffers.verticesBuffer);var Q=P.getAttribLocation(N,this.options.vertexPosition);if(P.vertexAttribPointer(Q,U,P.FLOAT,!1,0,0),P.enableVertexAttribArray(Q),N._enableTextures){P.bindBuffer(P.ARRAY_BUFFER,N._buffers.texCoordBuffer);var K=P.getAttribLocation(N,this.options.vertexTextureCoord);P.vertexAttribPointer(K,N._texCoordSize||2,P.FLOAT,!1,0,0),P.enableVertexAttribArray(K)}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,we=le.type||"FLOAT",R=le.key||$;we==="UBYTE"&&(we="UNSIGNED_BYTE"),we==="USHORT"&&(we="UNSIGNED_SHORT"),ee.type=we,R&&R!==$&&(N._attribute[R]=ee),P.bindBuffer(P.ARRAY_BUFFER,N._buffers[$]);var j=P.getAttribLocation(N,$);j>=0&&(P.vertexAttribPointer(j,ie,P[we],pe,0,0),P.enableVertexAttribArray(j))}}),!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)],k=[[0,1,3],[3,1,2]];this.setMeshData({positions:ce,cells:k})}return N}},{key:"compileSync",value:function(N,A){N=N||f.default;var P={};function U(k){k=k.replace(/^\s*/mg,"");var W=[],H=k.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"),P[pe])W.push("/* included ".concat(pe," */"));else if(P[pe]=!0,le==="lib"){var we=U(w[pe]);W.push(we)}else if(le==="link")throw new Error("Cannot load external links synchronously. Use compile instead of compileSync.")}}W.forEach(function(R){k=k.replace(/^#pragma\s+include\s+.*/m,R)})}return k}var Q=U(N),K=A?U(A):null,ce=this.createProgram(Q,K);return ce}},{key:"compile",value:function(){var V=c()(o.a.mark(function A(P,U){var Q,K,ce,k,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 we,R,j,X,ae,q,te,y,S;return o.a.wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:if(pe=pe.replace(/^\s*/mg,""),we=[],R=pe.match(/^#pragma\s+include\s+.*/mg),!R){Y.next=36;break}j=0;case 5:if(!(j<R.length)){Y.next=35;break}if(X=R[j],ae=X.match(/(?:<|")(.*)(?:>|")/),!ae){Y.next=32;break}if(q=ae[0].indexOf("<")===0?"lib":"link",te=ae[1],te==="graph"&&(te="graphics"),Q[te]){Y.next=31;break}if(Q[te]=!0,q!=="lib"){Y.next=21;break}return Y.next=17,K(w[te]);case 17:y=Y.sent,we.push(y),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,K(S);case 27:S=Y.sent,we.push(S);case 29:Y.next=32;break;case 31:we.push("/* included ".concat(te," */"));case 32:j++,Y.next=5;break;case 35:we.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)},K=function(le){return ce.apply(this,arguments)},P=P||f.default,Q={},ee.next=6,K(P);case 6:if(k=ee.sent,!U){ee.next=13;break}return ee.next=10,K(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(k,W),ee.abrupt("return",H);case 17:case"end":return ee.stop()}},A,this)}));function N(A,P){return V.apply(this,arguments)}return N}()},{key:"load",value:function(){var V=c()(o.a.mark(function A(P){var U,Q=arguments;return o.a.wrap(function(ce){for(;;)switch(ce.prev=ce.next){case 0:return U=Q.length>1&&Q[1]!==void 0?Q[1]:null,ce.next=3,O.fetchShader(P);case 3:if(P=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(P,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,P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},U=P.wrapS,Q=U===void 0?this.gl.CLAMP_TO_EDGE:U,K=P.wrapT,ce=K===void 0?this.gl.CLAMP_TO_EDGE:K,k=P.minFilter,W=k===void 0?this.gl.LINEAR:k,H=P.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,we=pe.width,R=pe.height;if(A)if(ie===ee.TEXTURE_CUBE_MAP)for(var j=0;j<6;j++)ee.texImage2D(ee.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,ee.RGBA,ee.RGBA,ee.UNSIGNED_BYTE,A[j]);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,we,R,0,ee.RGBA,ee.UNSIGNED_BYTE,null);else ee.texImage2D(ie,0,ee.RGBA,we,R,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,Q),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:we,height:R},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(P){var U,Q,K,ce,k=arguments;return o.a.wrap(function(H){for(;;)switch(H.prev=H.next){case 0:return U=k.length>1&&k[1]!==void 0?k[1]:{},Q=U.useImageBitmap,K=Q===void 0?!0:Q,H.next=3,O.loadImage(P,{useImageBitmap:K});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,P=A===void 0?1:A,U=N.blend,Q=U===void 0?!1:U,K=N.depth,ce=K===void 0?this.options.depth!==!1:K,k=N.stencil,W=k===void 0?!!this.options.stencil:k,H=this.gl,$=H.createFramebuffer();H.bindFramebuffer(H.FRAMEBUFFER,$);for(var ee=[],ie=0;ie<P;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=Q;var pe=this.canvas,we=pe.width,R=pe.height;return ce&&!W&&($.depthBuffer=H.createRenderbuffer(),H.bindRenderbuffer(H.RENDERBUFFER,$.depthBuffer),H.renderbufferStorage(H.RENDERBUFFER,H.DEPTH_COMPONENT16,we,R),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,we,R),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,we,R),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,P=this.program;P||(P=this.createProgram(),this.useProgram(P)),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 Q=this._renderFrameID;this._draw(),this.fbo&&A.bindFramebuffer(A.FRAMEBUFFER,null),this._renderFrameID===Q&&(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}();C()(E,"defaultOptions",{preserveDrawingBuffer:!0,autoUpdate:!0,vertexPosition:"a_vertexPosition",vertexTextureCoord:"a_vertexTextureCoord",webgl2:!1}),C()(E,"UBYTE",E.UNSIGNED_BYTE),C()(E,"USHORT",E.UNSIGNED_SHORT),C()(E,"fetchShader",B.fetchShader),C()(E,"loadImage",B.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(k,W,H){return Object.defineProperty(k,W,{value:H,enumerable:!0,configurable:!0,writable:!0}),k[W]}try{p({},"")}catch{p=function(W,H,$){return W[H]=$}}function M(k,W,H,$){var ee=W&&W.prototype instanceof m?W:m,ie=Object.create(ee.prototype),le=new Q($||[]);return ie._invoke=N(k,H,le),ie}o.wrap=M;function I(k,W,H){try{return{type:"normal",arg:k.call(W,H)}}catch($){return{type:"throw",arg:$}}}var D="suspendedStart",C="suspendedYield",B="executing",T="completed",f={};function m(){}function w(){}function v(){}var b={};b[h]=function(){return this};var x=Object.getPrototypeOf,z=x&&x(x(K([])));z&&z!==a&&c.call(z,h)&&(b=z);var E=v.prototype=m.prototype=Object.create(b);w.prototype=E.constructor=v,v.constructor=w,w.displayName=p(v,g,"GeneratorFunction");function O(k){["next","throw","return"].forEach(function(W){p(k,W,function(H){return this._invoke(W,H)})})}o.isGeneratorFunction=function(k){var W=typeof k=="function"&&k.constructor;return W?W===w||(W.displayName||W.name)==="GeneratorFunction":!1},o.mark=function(k){return Object.setPrototypeOf?Object.setPrototypeOf(k,v):(k.__proto__=v,p(k,g,"GeneratorFunction")),k.prototype=Object.create(E),k},o.awrap=function(k){return{__await:k}};function V(k,W){function H(ie,le,pe,we){var R=I(k[ie],k,le);if(R.type==="throw")we(R.arg);else{var j=R.arg,X=j.value;return X&&typeof X=="object"&&c.call(X,"__await")?W.resolve(X.__await).then(function(ae){H("next",ae,pe,we)},function(ae){H("throw",ae,pe,we)}):W.resolve(X).then(function(ae){j.value=ae,pe(j)},function(ae){return H("throw",ae,pe,we)})}}var $;function ee(ie,le){function pe(){return new W(function(we,R){H(ie,le,we,R)})}return $=$?$.then(pe,pe):pe()}this._invoke=ee}O(V.prototype),V.prototype[d]=function(){return this},o.AsyncIterator=V,o.async=function(k,W,H,$,ee){ee===void 0&&(ee=Promise);var ie=new V(M(k,W,H,$),ee);return o.isGeneratorFunction(W)?ie:ie.next().then(function(le){return le.done?le.value:ie.next()})};function N(k,W,H){var $=D;return function(ie,le){if($===B)throw new Error("Generator is already running");if($===T){if(ie==="throw")throw le;return ce()}for(H.method=ie,H.arg=le;;){var pe=H.delegate;if(pe){var we=A(pe,H);if(we){if(we===f)continue;return we}}if(H.method==="next")H.sent=H._sent=H.arg;else if(H.method==="throw"){if($===D)throw $=T,H.arg;H.dispatchException(H.arg)}else H.method==="return"&&H.abrupt("return",H.arg);$=B;var R=I(k,W,H);if(R.type==="normal"){if($=H.done?T:C,R.arg===f)continue;return{value:R.arg,done:H.done}}else R.type==="throw"&&($=T,H.method="throw",H.arg=R.arg)}}}function A(k,W){var H=k.iterator[W.method];if(H===l){if(W.delegate=null,W.method==="throw"){if(k.iterator.return&&(W.method="return",W.arg=l,A(k,W),W.method==="throw"))return f;W.method="throw",W.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var $=I(H,k.iterator,W.arg);if($.type==="throw")return W.method="throw",W.arg=$.arg,W.delegate=null,f;var ee=$.arg;if(!ee)return W.method="throw",W.arg=new TypeError("iterator result is not an object"),W.delegate=null,f;if(ee.done)W[k.resultName]=ee.value,W.next=k.nextLoc,W.method!=="return"&&(W.method="next",W.arg=l);else return ee;return W.delegate=null,f}O(E),p(E,g,"Generator"),E[h]=function(){return this},E.toString=function(){return"[object Generator]"};function P(k){var W={tryLoc:k[0]};1 in k&&(W.catchLoc=k[1]),2 in k&&(W.finallyLoc=k[2],W.afterLoc=k[3]),this.tryEntries.push(W)}function U(k){var W=k.completion||{};W.type="normal",delete W.arg,k.completion=W}function Q(k){this.tryEntries=[{tryLoc:"root"}],k.forEach(P,this),this.reset(!0)}o.keys=function(k){var W=[];for(var H in k)W.push(H);return W.reverse(),function $(){for(;W.length;){var ee=W.pop();if(ee in k)return $.value=ee,$.done=!1,$}return $.done=!0,$}};function K(k){if(k){var W=k[h];if(W)return W.call(k);if(typeof k.next=="function")return k;if(!isNaN(k.length)){var H=-1,$=function ee(){for(;++H<k.length;)if(c.call(k,H))return ee.value=k[H],ee.done=!1,ee;return ee.value=l,ee.done=!0,ee};return $.next=$}}return{next:ce}}o.values=K;function ce(){return{value:l,done:!0}}return Q.prototype={constructor:Q,reset:function(k){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),!k)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 k=this.tryEntries[0],W=k.completion;if(W.type==="throw")throw W.arg;return this.rval},dispatchException:function(k){if(this.done)throw k;var W=this;function H(we,R){return ie.type="throw",ie.arg=k,W.next=we,R&&(W.method="next",W.arg=l),!!R}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(k,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&&(k==="break"||k==="continue")&&ee.tryLoc<=W&&W<=ee.finallyLoc&&(ee=null);var ie=ee?ee.completion:{};return ie.type=k,ie.arg=W,ee?(this.method="next",this.next=ee.finallyLoc,f):this.complete(ie)},complete:function(k,W){if(k.type==="throw")throw k.arg;return k.type==="break"||k.type==="continue"?this.next=k.arg:k.type==="return"?(this.rval=this.arg=k.arg,this.method="return",this.next="end"):k.type==="normal"&&W&&(this.next=W),f},finish:function(k){for(var W=this.tryEntries.length-1;W>=0;--W){var H=this.tryEntries[W];if(H.finallyLoc===k)return this.complete(H.completion,H.afterLoc),U(H),f}},catch:function(k){for(var W=this.tryEntries.length-1;W>=0;--W){var H=this.tryEntries[W];if(H.tryLoc===k){var $=H.completion;if($.type==="throw"){var ee=$.arg;U(H)}return ee}}throw new Error("illegal catch attempt")},delegateYield:function(k,W,H){return this.delegate={iterator:K(k),resultName:W,nextLoc:H},this.method==="next"&&(this.arg=l),f}},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(M){c(M);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 C});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(T,f){for(var m=["webgl","experimental-webgl","webkit-3d","moz-webgl"],w=null,v=0;v<m.length;++v){try{w=T.getContext(m[v],f)}catch{}if(w)break}return w}function d(T,f){var m=h(T,f);if(!m)throw new Error("Sorry, your browser doesn't support WebGL.");return m}function g(T,f,m){var w=T.createShader(T.VERTEX_SHADER);if(T.shaderSource(w,f),T.compileShader(w),!T.getShaderParameter(w,T.COMPILE_STATUS)){var v="Vertex shader failed to compile. The error log is:".concat(T.getShaderInfoLog(w));throw new Error(v)}var b=T.createShader(T.FRAGMENT_SHADER);if(T.shaderSource(b,m),T.compileShader(b),!T.getShaderParameter(b,T.COMPILE_STATUS)){var x="Fragment shader failed to compile. The error log is:".concat(T.getShaderInfoLog(b));throw new Error(x)}var z=T.createProgram();if(T.attachShader(z,w),T.attachShader(z,b),T.linkProgram(z),!T.getProgramParameter(z,T.LINK_STATUS)){var E="Shader program failed to link. The error log is:".concat(T.getProgramInfoLog(z));throw new Error(E)}return T.deleteShader(w),T.deleteShader(b),z}function p(T){var f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Float32Array,m=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null;if(m&&!(m instanceof f))throw new TypeError("Wrong buffer type.");if(T==null||T instanceof f)return T;if(T[0]==null||T[0].length==null)return m?(m.set(T,0),m):new f(T);var w=T[0].length,v=T.length;m||(m=new f(w*v));for(var b=0,x=0;x<v;x++)for(var z=0;z<w;z++)m[b++]=T[x][z];return m}var M={};function I(T){var f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},m=f.useImageBitmap,w=m===void 0?!0:m,v=f.alias,b=v===void 0?null:v;if(!M[T]){if(typeof Image=="function"){var x=new Image;typeof T=="string"&&!((typeof location>"u"?"undefined":u()(location))==="object"&&/^file:/.test(location.href))&&!/^data:/.test(T)&&(x.crossOrigin="anonymous"),M[T]=new Promise(function(z){x.onload=function(){w&&typeof createImageBitmap=="function"?createImageBitmap(x,{imageOrientation:"flipY"}).then(function(E){M[T]=E,b&&(M[b]=E),z(E)}):(M[T]=x,b&&(M[b]=x),z(x))},x.src=T}),b&&(M[b]=M[T])}else if(typeof fetch=="function")return fetch(T,{method:"GET",mode:"cors",cache:"default"}).then(function(z){return z.blob()}).then(function(z){return createImageBitmap(z,{imageOrientation:"flipY"}).then(function(E){return M[T]=E,b&&(M[b]=E),E})})}return M[T]}var D={};function C(T){return B.apply(this,arguments)}function B(){return B=c()(o.a.mark(function T(f){var m,w;return o.a.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(!D[f]){b.next=2;break}return b.abrupt("return",D[f]);case 2:return b.next=4,fetch(f);case 4:if(m=b.sent,!(m.status>=200&&m.status<300)){b.next=11;break}return b.next=8,m.text();case 8:return w=b.sent,D[f]=w,b.abrupt("return",w);case 11:throw new Error("Shader loaded error.");case 12:case"end":return b.stop()}},T)})),B.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 T});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),M=n(24),I=n.n(M),D=n(37),C=n(41);n(1).glMatrix.setMatrixArrayType(Array);var B=Symbol("transform"),T=function(){function f(m,w){p()(this,f),this.context=m.getContext("2d"),this.options=w,this[B]=[1,0,0,1,0,0]}return I()(f,[{key:"createTexture",value:function(w){var v={_img:w};return v}},{key:"loadTexture",value:function(){var m=d()(u.a.mark(function v(b){var x;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 x=E.sent,E.abrupt("return",this.createTexture(x));case 4:case"end":return E.stop()}},v,this)}));function w(v){return m.apply(this,arguments)}return w}()},{key:"deleteTexture",value:function(w){return w}},{key:"clear",value:function(w,v,b,x){var z=this.context;w=w||0,v=v||0,b=b||z.canvas.width-w,x=x||z.canvas.height-v,z.clearRect(w,v,b,x)}},{key:"drawMeshCloud",value:function(w){for(var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},b=v.clear,x=b===void 0?!1:b,z=[],E=0;E<w.amount;E++){var O=w.getTransform(E),V=w.getTextureFrame(E);V&&(V=V._img);var N=w.getFilter(E),A=w.getCloudRGBA(E),P=A.fill,U=A.stroke;z.push({mesh:w.mesh,_cloudOptions:[P,U,V,O,N]})}w.beforeRender&&w.beforeRender(this.context,w),this.drawMeshes(z,{clear:x,hook:!1}),w.afterRender&&w.afterRender(this.context,w)}},{key:"drawMeshes",value:function(w){var v=this,b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},x=b.clear,z=x===void 0?!1:x,E=b.hook,O=E===void 0?!0:E,V=this.context;z&&V.clearRect(0,0,V.canvas.width,V.canvas.height);var N=null,A=V.canvas,P=A.width,U=A.height,Q=w.length;w.forEach(function(K,ce){var k,W,H,$,ee;if(O&&K.beforeRender&&K.beforeRender(V,K),K._cloudOptions){var ie=c()(K._cloudOptions,5);k=ie[0],W=ie[1],H=ie[2],$=ie[3],ee=ie[4],K=K.mesh}var le=K.filter;if(ee&&(le=le?"".concat(le," ").concat(ee):ee),le&&!v.filterBuffer&&v.filterBuffer!==!1){var pe=D.default.createCanvas(P,U);pe?v.filterBuffer=pe.getContext("2d"):v.filterBuffer=!1}if(N&&N!==le&&(Object(C.applyFilter)(v.filterBuffer,N),V.drawImage(v.filterBuffer.canvas,0,0,P,U),v.filterBuffer.clearRect(0,0,P,U),N=null),le&&v.filterBuffer){var we;v.filterBuffer.save(),(we=v.filterBuffer).transform.apply(we,o()(v[B])),Object(C.drawMesh2D)(K,v.filterBuffer,!1,k,W,H,$),v.filterBuffer.restore(),ce===Q-1?(Object(C.applyFilter)(v.filterBuffer,le),V.drawImage(v.filterBuffer.canvas,0,0,P,U),v.filterBuffer.clearRect(0,0,P,U)):N=le}else V.save(),V.transform.apply(V,o()(v[B])),Object(C.drawMesh2D)(K,V,!1,k,W,H,$),V.restore();O&&K.afterRender&&K.afterRender(V,K)})}},{key:"setTransform",value:function(w){this[B]=w}}]),f}()},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(T,f){var m=T.style,w=T.variant,v=T.weight,b=T.stretch,x=T.size,z=T.pxLineHeight,E=T.family;return b==="normal"?"".concat(m," ").concat(w," ").concat(v," ").concat(x*f,"px/").concat(z*f,"px ").concat(E):"".concat(m," ").concat(w," ").concat(v," ").concat(b," ").concat(x*f,"px/").concat(z*f,"px ").concat(E)}function M(T,f){var m=f.font,w=f.fillColor,v=f.strokeColor,b=f.strokeWidth,x=f.ratio,z=x===void 0?1:x,E=f.textCanvas,O=f.cachable,V=O===void 0?!1:O,N;if(V){N=[T,m,String(w),String(v),String(b)].join("###");var A=g[N];if(A)return A}E||(E=C(1,1));var P=E.getContext("2d");P.save(),P.font=m;var U=P.measureText(T),Q=U.width;P.restore();var K=Object(h.default)(m),ce=Math.max(K.pxLineHeight,K.pxHeight*1.13);/italic|oblique/.test(m)&&(Q+=ce*Math.tan(15*Math.PI/180)),!w&&!v&&(w="#000");var k=P.canvas,W=Math.ceil(Q),H=Math.ceil(ce);k.width=Math.round(W*z),k.height=Math.round(H*z),P.save(),P.font=p(K,z),P.textAlign="center",P.textBaseline="middle";var $=k.height*.5+K.pxHeight*.05*z,ee=k.width*.5;if(w){if(Array.isArray(w))w=Object(d.default)(w);else if(w.vector){var ie,le=w,pe=le.vector,we=le.colors;pe.length===6?ie=P.createRadialGradient.apply(P,l()(pe)):ie=P.createLinearGradient.apply(P,l()(pe)),we.forEach(function(te){var y=te.offset,S=te.color;ie.addColorStop(y,S)}),w=ie}P.fillStyle=w,P.fillText(T,ee,$)}if(v){if(P.lineWidth=b*z,Array.isArray(v))v=Object(d.default)(v);else if(v.vector){var R,j=v,X=j.vector,ae=j.colors;X.length===6?R=P.createRadialGradient.apply(P,l()(X)):R=P.createLinearGradient.apply(P,l()(X)),ae.forEach(function(te){var y=te.offset,S=te.color;R.addColorStop(y,S)}),v=R}P.strokeStyle=v,P.strokeText(T,ee,$)}P.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 C(T,f){var m=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},w=m.offscreen||!I&&m.offscreen!==!1,v;return typeof s<"u"&&typeof s.createCanvas=="function"?v=s.createCanvas(T,f,m):w&&typeof OffscreenCanvas=="function"?v=new OffscreenCanvas(T,f):(v=document.createElement("canvas"),v.width=T,v.height=f),v}var B={createCanvas:C,createText:M,loadImage:u.default.loadImage};r.default=B}).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(C,B){if(typeof C=="string"){var T=C.trim().match(/^([\d.]+)(px|pt|pc|in|cm|mm|em|ex|rem|q|vw|vh|vmax|vmin|%)$/);T?C={size:parseFloat(T[1]),unit:T[2]}:C={size:parseInt(C,10),unit:"px"}}var f=C,m=f.size,w=f.unit;if(w==="pt")m/=.75;else if(w==="pc")m*=16;else if(w==="in")m*=96;else if(w==="cm")m*=96/2.54;else if(w==="mm")m*=96/25.4;else if(w==="em"||w==="rem"||w==="ex"){if(!B&&typeof getComputedStyle=="function"&&typeof document<"u"){var v=getComputedStyle(document.documentElement).fontSize;B=s(v,16)}m*=B,w==="ex"&&(m/=2)}else if(w==="q")m*=96/25.4/4;else if(w==="vw"||w==="vh"){if(typeof document<"u"){var b=w==="vw"?document.documentElement.clientWidth:document.documentElement.clientHeight;m*=b/100}}else if((w==="vmax"||w==="vmin")&&typeof document<"u"){var x=document.documentElement.clientWidth,z=document.documentElement.clientHeight;w==="vmax"?m*=Math.max(x,z)/100:m*=Math.min(x,z)/100}return m}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"),M=new RegExp("(".concat(l,") +"),"i"),I=new RegExp("([\\d\\.]+)("+u+")(?:\\/([\\d\\.]+)("+u+"))? *((?:"+h+")( *, *(?:"+h+"))*)");function D(C,B){var T=I.exec(C);if(T){var f=parseFloat(T[3]),m={weight:"normal",style:"normal",stretch:"normal",variant:"normal",size:parseFloat(T[1]),unit:T[2],lineHeight:Number.isFinite(f)?f:void 0,lineHeightUnit:T[4],family:T[5].replace(/ *, */g,",")},w=C.substring(0,T.index),v=d.exec(w),b=g.exec(w),x=p.exec(w),z=M.exec(w);return v&&(m.weight=v[1]),b&&(m.style=b[1]),x&&(m.variant=x[1]),z&&(m.stretch=z[1]),m.pxHeight=s({size:m.size,unit:m.unit},B),m.pxLineHeight=s({size:m.lineHeight||m.size,unit:m.lineHeightUnit||m.unit},B),m}}},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,M){var I=p.canvas;p.save(),p.filter=M,p.drawImage(I,0,0,I.width,I.height),p.restore()}function d(p,M){var I=/rgba\((\d+),(\d+),(\d+),(\d+)\)/;p=p.match(I).slice(1,5).map(Number),M=M.match(I).slice(1,5).map(Number);for(var D=[],C=M[3],B=0;B<4;B++)D[B]=Object(u.mix)(p[B],M[B],C);return"rgba(".concat(D.join(),")")}function g(p,M){var I=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,D=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null,C=arguments.length>4&&arguments[4]!==void 0?arguments[4]:null,B=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null,T=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null;M.save();var f=!1,m=!1;if(M.globalAlpha=p.getOpacity(),p._updateMatrix){var w=p.transformScale/p.contours.scale;w>1.5&&p.accurate(p.transformScale)}if(p.lineWidth){var v=p.gradient&&p.gradient.stroke;if(v){var b=v,x=b.vector,z=b.colors;if(x.length===6)v=M.createRadialGradient.apply(M,o()(x));else if(x.length===4)v=M.createLinearGradient.apply(M,o()(x));else if(x.length===3)v=M.createCircularGradient.apply(M,o()(x));else throw new TypeError("Invalid vector dimension.");z.forEach(function(K){var ce=K.offset,k=K.color,W=Object(c.default)(k);C&&(W=d(W,C)),v.addColorStop(ce,W)}),M.strokeStyle=v,f=!0}else p.strokeStyle&&(C?M.strokeStyle=d(p.strokeStyle,C):M.strokeStyle=p.strokeStyle,f=!0)}f&&(M.lineWidth=p.lineWidth,M.lineJoin=p.lineJoin,M.lineCap=p.lineCap,M.miterLimit=p.miterLimit,p.lineDash&&(M.setLineDash(p.lineDash),p.lineDashOffset&&(M.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=M.createRadialGradient.apply(M,o()(V));else if(V.length===4)E=M.createLinearGradient.apply(M,o()(V));else if(V.length===3)E=M.createCircularGradient.apply(M,o()(V));else throw new TypeError("Invalid vector dimension.");N.forEach(function(K){var ce=K.offset,k=K.color,W=Object(c.default)(k);C&&(W=d(W,C)),E.addColorStop(ce,W)}),M.fillStyle=E,m=!0}else p.fillStyle&&(D?M.fillStyle=d(p.fillStyle,D):M.fillStyle=p.fillStyle,m=!0);if(T&&M.transform.apply(M,o()(T)),M.transform.apply(M,o()(p.transformMatrix)),p.clipPath){var A=p.clipPath,P=new Path2D(A);M.clip(P)}var U=p.contours.length;if(p.contours.forEach(function(K,ce){var k=K.length,W=k>1&&a.vec2.equals(K[0],K[k-1]),H=ce===U-1&&p.texture;if(K&&k>0){if(m||f||H){M.beginPath(),M.moveTo.apply(M,o()(K[0]));for(var $=1;$<k;$++)$===k-1&&W?M.closePath():M.lineTo.apply(M,o()(K[$]))}if(m&&M.fill(p.fillRule),H){M.save(),M.clip();var ee=p.texture,ie=ee.image,le=ee.options;if(B&&(ie=B),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,we=pe.font,R=pe.fillColor,j=pe.strokeColor,X=pe.strokeWidth,ae=pe.text;!R&&!j&&(R="#000"),Array.isArray(R)&&(R=Object(c.default)(R)),Array.isArray(j)&&(j=Object(c.default)(j)),M.font=we;var q=M.measureText(ae),te=q.width,y=Object(l.default)(we),S=Math.max(y.pxLineHeight,y.pxHeight*1.13);M.textAlign="center",M.textBaseline="middle";var F=le.rect,Y=F[0]+S*.5+y.pxHeight*.06,_=F[1]+te*.5;F[2]!=null&&M.scale(F[2]/te,F[3]/S),R&&(M.fillStyle=R,M.fillText(ae,_,Y)),j&&(M.lineWidth=X,M.strokeStyle=j,M.strokeText(ae,_,Y))}else{var re=le.rect,ne=le.srcRect;le.scale&&(re=[0,0,M.canvas.width,M.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&&(M.translate(0,re?re[2]:ie.width),M.rotate(-.5*Math.PI)),ne?M.drawImage.apply(M,[ie].concat(o()(ne),o()(re))):re?M.drawImage.apply(M,[ie].concat(o()(re))):M.drawImage(ie,0,0)}M.restore()}f&&M.stroke()}}),M.restore(),I){var Q=p.filter;Q&&h(M,Q)}}},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,M,I){var D=p.uniforms||{},C=M.uniforms||{};if(D.u_texSampler&&C.u_texSampler&&D.u_texSampler!==C.u_texSampler)return!1;var B=Object.keys(D),T=Object.keys(C),f=B.indexOf("u_texSampler"),m=T.indexOf("u_texSampler");if(f>=0&&B.splice(f,1),m>=0&&T.splice(m,1),B.length!==T.length)return!1;var w=B.every(function(b){var x=D[b],z=C[b];if(x===z)return!0;if(x.length&&z.length&&x.length===z.length){for(var E=0;E<x.length;E++)if(x[E]!==z[E])return!1;return!0}return!1});if(w){if(D.u_texSampler&&!C.u_texSampler)M.setTexture(D.u_texSampler,{hidden:!0});else if(!D.u_texSampler&&C.u_texSampler)for(var v=0;v<I.length;v++)I[v].setTexture(C.u_texSampler,{hidden:!0})}return w}var h={};function d(p,M){if(p.length){var I=Object(a.default)(p,h);return I.enableBlend=M,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,M){var I,D,C,B,T,f,m,w,v,b,x,z,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=[],C=p.options.bufferSize,B=0,T=!1,f=0;case 6:if(!(f<M.length)){V.next=50;break}if(m=M[f],!(m instanceof c.default)){V.next=18;break}if(!D.length){V.next=12;break}return V.next=12,d(D,T);case 12:return B=0,T=!1,V.next=16,m;case 16:V.next=47;break;case 18:if(w=m.meshData,w.clipPath&&!w.uniforms.u_clipSampler&&(v=p.createTexture(w.clipPath),w.uniforms.u_clipSampler=v),b=0,!((!I||!m.canIgnore())&&w&&w.positions.length)){V.next=43;break}if(m.packIndex=f,x=m.filterCanvas,b=w.positions.length,!(x||B+b>C)){V.next=33;break}if(!D.length){V.next=29;break}return V.next=29,d(D,T);case 29:B=0,T=!1,V.next=40;break;case 33:if(!B){V.next=40;break}if(z=D[D.length-1],!(z&&(z.filterCanvas||z.afterRender||m.beforeRender||z.pass.length||m.pass.length||z.program!==m.program||!u(z,m,D)))){V.next=40;break}return V.next=38,d(D,T);case 38:B=0,T=!1;case 40:D.push(m),T=T||m.enableBlend,B+=b;case 43:if(f!==M.length-1){V.next=47;break}if(!D.length){V.next=47;break}return V.next=47,d(D,T);case 47:f++,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,M=0,I=0,D=0,C=0,B=0,T=0,f=d[0].program,m=0;m<d.length;m++){var w=d[m].meshData;if(w){T+=w.positions.length;var v=w.positions[0].length;p+=w.positions.length*v,M+=w.cells.length*3,B+=w.attributes.a_color.length*4;var b=w.textureCoord;b&&(I+=b.length*b[0].length);var x=w.attributes.a_sourceRect;x&&(D+=x.length*4);var z=w.attributes.a_clipUV;z&&(C+=z.length*2)}}if((!g.positions||g.positions.length<p)&&(g.positions=new Float32Array(p)),(!g.cells||g.cells.length<M)&&(g.cells=new Uint16Array(M)),I&&(!g.textureCoord||g.textureCoord.length<I)&&(g.textureCoord=new Float32Array(I)),(!g.a_color||g.a_color.length<B)&&(g.a_color=new Uint8Array(B)),D&&(!g.a_sourceRect||g.a_sourceRect.length<D)&&(g.a_sourceRect=new Float32Array(D)),C&&(!g.a_clipUV||g.a_clipUV.length<C)&&(g.a_clipUV=new Float32Array(C)),f)for(var E=Object.entries(f._attribute),O=f._attribOpts||{},V=0;V<E.length;V++){var N=c()(E[V],2),A=N[0],P=N[1];if(A!=="a_color"&&A!=="a_sourceRect"&&P!=="ignored"){var U=O[A]?O[A].type:"FLOAT",Q=l[U],K=P.size*T;(!g[A]||g[A].length<K)&&(g[A]=new Q(K))}}return g}function h(d,g){var p=[],M=[],I=[],D=[],C=[],B=[],T=0,f=0,m=d[0]?d[0].uniforms||{}:{},w=d[0]?d[0].program:null;g&&(u(d,g),M=g.cells,p=g.positions,I=g.textureCoord,D=g.a_color,C=g.a_sourceRect,B=g.a_clipUV);for(var v=!1,b=!1,x={},z=0;z<d.length;z++){var E=d[z];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*(T+V),P=0;P<N.length;P++)p[A+P]=N[P];else{var U;(U=p).push.apply(U,o()(E.positions))}for(var Q=E.cells,K=0;K<Q.length;K++){var ce=Q[K];if(g){var k=3*(f+K);M[k]=ce[0]+T,M[k+1]=ce[1]+T,M[k+2]=ce[2]+T}else M.push([ce[0]+T,ce[1]+T,ce[2]+T])}if(g)for(var W=E.attributes.a_color,H=0;H<W.length;H++){var $=W[H],ee=4*(T+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(v=!0,g)for(var le=E.attributes.a_sourceRect,pe=0;pe<le.length;pe++){var we=le[pe],R=4*(T+pe);C[R]=we[0],C[R+1]=we[1],C[R+2]=we[2],C[R+3]=we[3]}else{var j;(j=C).push.apply(j,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*(T+ae);B[te]=q[0],B[te+1]=q[1]}else{var y;(y=B).push.apply(y,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*(T+F),re=0;re<Y.length;re++)I[_+re]=Y[re];else{var ne;(ne=I).push.apply(ne,o()(E.textureCoord))}if(w)for(var J=Object.entries(w._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(x[oe]=[],g){x[oe]=g[oe];for(var me=E.attributes[oe],ye=me[0].length,xe=0;xe<me.length;xe++)for(var Ce=me[xe],Ie=ye*(T+xe),ke=0;ke<Ce.length;ke++)x[oe][Ie+ke]=Ce[ke]}else{var Re;(Re=x[oe]).push.apply(Re,o()(E.attributes[oe]))}}T+=E.positions.length,f+=E.cells.length}}x.a_color=D,v&&C&&C.length>0&&(x.a_sourceRect=C);var Le={positions:p,cells:M,attributes:x,uniforms:m,cellsCount:f*3,program:w};return I&&I.length&&(Le.textureCoord=I),b&&B.length>0&&(x.a_clipUV=B),Le}},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),M=n(1),I=n(46),D=n(42),C=n(47);n(1).glMatrix.setMatrixArrayType(Array);function B(A,P){var U=Object.keys(A);if(Object.getOwnPropertySymbols){var Q=Object.getOwnPropertySymbols(A);P&&(Q=Q.filter(function(K){return Object.getOwnPropertyDescriptor(A,K).enumerable})),U.push.apply(U,Q)}return U}function T(A){for(var P=1;P<arguments.length;P++){var U=arguments[P]!=null?arguments[P]:{};P%2?B(Object(U),!0).forEach(function(Q){o()(A,Q,U[Q])}):Object.getOwnPropertyDescriptors?Object.defineProperties(A,Object.getOwnPropertyDescriptors(U)):B(Object(U)).forEach(function(Q){Object.defineProperty(A,Q,Object.getOwnPropertyDescriptor(U,Q))})}return A}var f=Symbol("mesh"),m=Symbol("count"),w=Symbol("blend"),v=Symbol("filter"),b=Symbol("textures"),x=Symbol("textureOptions"),z=Symbol("cloudColor"),E=Symbol("cloudFilter"),O=Symbol("buffer");function V(A){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,U=new Float32Array(3*A),Q=new Float32Array(3*A),K=new Float32Array(4*A),ce=new Float32Array(4*A),k=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 P&&(U.set(P.transform0,0),Q.set(P.transform1,0),K.set(P.color0,0),ce.set(P.color1,0),k.set(P.color2,0),W.set(P.color3,0),H.set(P.color4,0),$.set(P.frameIndex,0),ee.set(P.fillColor,0),ie.set(P.strokeColor,0)),{bufferSize:A,transform0:U,transform1:Q,color0:K,color1:ce,color2:k,color3:W,color4:H,frameIndex:$,fillColor:ee,strokeColor:ie}}var N=function(){function A(P){var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,Q=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},K=Q.buffer,ce=K===void 0?1e3:K;d()(this,A),ce=Math.max(ce,U),this[m]=U,this[f]=P,this[O]=V(ce),this[b]=[],this[v]=[],this[z]=!1,this[E]=!1,this[w]=!1,this.initBuffer()}return p()(A,[{key:"initBuffer",value:function(){for(var U=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,Q=this[m],K=U;K<Q;K++)this[O].transform0.set([1,0,0],K*3),this[O].transform1.set([0,1,0],K*3),this[O].frameIndex.set([-1],K),this[O].fillColor.set([0,0,0,0],K*4),this[O].strokeColor.set([0,0,0,0],K*4),this.setColorTransform(K,null)}},{key:"_getFilter",value:function(U){return this[v][U]=this[v][U]||[],this[v][U]}},{key:"getFilter",value:function(U){return this._getFilter(U).join(" ")}},{key:"canIgnore",value:function(){return this[f].canIgnore()}},{key:"delete",value:function(U){if(U>=this[m]||U<0)throw new Error("Out of range.");var Q=this[O],K=Q.transform0,ce=Q.transform1,k=Q.color0,W=Q.color1,H=Q.color2,$=Q.color3,ee=Q.color4,ie=Q.frameIndex,le=Q.fillColor,pe=Q.strokeColor;K.set(K.subarray(3*(U+1)),3*U),ce.set(ce.subarray(3*(U+1)),3*U),k.set(k.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 we in this[v])we===U?delete this[v][we]:we>U&&(this[v][we-1]=this[v][we],delete this[v][we]);this[m]--}},{key:"setColorTransform",value:function(U,Q){if(U>=this[m]||U<0)throw new Error("Out of range.");U*=4;var K=this[O],ce=K.color0,k=K.color1,W=K.color2,H=K.color3,$=K.color4;return Q!=null?(ce.set([Q[0],Q[5],Q[10],Q[15]],U),k.set([Q[1],Q[6],Q[11],Q[16]],U),W.set([Q[2],Q[7],Q[12],Q[17]],U),H.set([Q[3],Q[8],Q[13],Q[18]],U),$.set([Q[4],Q[9],Q[14],Q[19]],U),this[w]=this[w]||Q[18]<1,this[E]=!0):(ce.set([1,0,0,0],U),k.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[m]||U<0)throw new Error("Out of range.");U*=4;var Q=this[O],K=Q.color0,ce=Q.color1,k=Q.color2,W=Q.color3,H=Q.color4;return[K[U],ce[U],k[U],W[U],H[U],K[U+1],ce[U+1],k[U+1],W[U+1],H[U+1],K[U+2],ce[U+2],k[U+2],W[U+2],H[U+2],K[U+3],ce[U+3],k[U+3],W[U+3],H[U+3]]}},{key:"transformColor",value:function(U,Q){var K=this.getColorTransform(U);return K=Object(I.multiply)(K,Q),this.setColorTransform(U,K),this}},{key:"setFillColor",value:function(U,Q){if(U>=this[m]||U<0)throw new Error("Out of range.");typeof Q=="string"&&(Q=Object(C.default)(Q)),Q[3]>0&&(this[z]=!0),this[O].fillColor.set(Q.map(function(K){return Math.round(255*K)}),4*U)}},{key:"setStrokeColor",value:function(U,Q){if(U>=this[m]||U<0)throw new Error("Out of range.");typeof Q=="string"&&(Q=Object(C.default)(Q)),Q[3]>0&&(this[z]=!0),this[O].strokeColor.set(Q.map(function(K){return Math.round(255*K)}),4*U)}},{key:"getCloudRGBA",value:function(U){if(U>=this[m]||U<0)throw new Error("Out of range.");U*=4;var Q=this[O],K=Q.fillColor,ce=Q.strokeColor,k=[K[U],K[U+1],K[U+2],K[U+3]],W=[ce[U],ce[U+1],ce[U+2],ce[U+3]];return k[3]/=255,W[3]/=255,{fill:"rgba(".concat(k.join(),")"),stroke:"rgba(".concat(W.join(),")")}}},{key:"grayscale",value:function(U,Q){this.transformColor(U,Object(I.grayscale)(Q)),this._getFilter(U).push("grayscale(".concat(100*Q,"%)"))}},{key:"brightness",value:function(U,Q){this.transformColor(U,Object(I.brightness)(Q)),this._getFilter(U).push("brightness(".concat(100*Q,"%)"))}},{key:"saturate",value:function(U,Q){this.transformColor(U,Object(I.saturate)(Q)),this._getFilter(U).push("saturate(".concat(100*Q,"%)"))}},{key:"contrast",value:function(U,Q){this.transformColor(U,Object(I.contrast)(Q)),this._getFilter(U).push("contrast(".concat(100*Q,"%)"))}},{key:"invert",value:function(U,Q){this.transformColor(U,Object(I.invert)(Q)),this._getFilter(U).push("invert(".concat(100*Q,"%)"))}},{key:"sepia",value:function(U,Q){this.transformColor(U,Object(I.sepia)(Q)),this._getFilter(U).push("sepia(".concat(100*Q,"%)"))}},{key:"opacity",value:function(U,Q){this.transformColor(U,Object(I.opacity)(Q)),this._getFilter(U).push("opacity(".concat(100*Q,"%)"))}},{key:"hueRotate",value:function(U,Q){this.transformColor(U,Object(I.hueRotate)(Q)),this._getFilter(U).push("hue-rotate(".concat(Q,"deg)"))}},{key:"setTransform",value:function(U,Q){if(U>=this[m]||U<0)throw new Error("Out of range.");U*=3,Q==null&&(Q=[1,0,0,1,0,0]);var K=this[O],ce=K.transform0,k=K.transform1;return ce.set([Q[0],Q[2],Q[4]],U),k.set([Q[1],Q[3],Q[5]],U),this}},{key:"getTransform",value:function(U){if(U>=this[m]||U<0)throw new Error("Out of range.");U*=3;var Q=this[O],K=Q.transform0,ce=Q.transform1,k=[K[U],ce[U],K[U+1],ce[U+1],K[U+2],ce[U+2]];return k}},{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]:[],Q=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 K=this[f];K.setTexture(U[0],Q)}this[b]=U,this[x]=Q}},{key:"setFrameIndex",value:function(U,Q){if(U>=this[m]||U<0)throw new Error("Out of range.");var K=this[b].length;if(K<=0)throw new Error("No frames");this[O].frameIndex[U]=Q%K}},{key:"setProgram",value:function(U){this[f].setProgram(U)}},{key:"transform",value:function(U,Q){var K=this.getTransform(U);return Q=M.mat2d.multiply(Array.of(0,0,0,0,0,0),K,Q),this.setTransform(U,Q),this}},{key:"translate",value:function(U,Q){var K=u()(Q,2),ce=K[0],k=K[1],W=M.mat2d.create();return W=M.mat2d.translate(Array.of(0,0,0,0,0,0),W,[ce,k]),this.transform(U,W)}},{key:"rotate",value:function(U,Q){var K=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[0,0],ce=u()(K,2),k=ce[0],W=ce[1],H=M.mat2d.create();return H=M.mat2d.translate(Array.of(0,0,0,0,0,0),H,[k,W]),H=M.mat2d.rotate(Array.of(0,0,0,0,0,0),H,Q),H=M.mat2d.translate(Array.of(0,0,0,0,0,0),H,[-k,-W]),this.transform(U,H)}},{key:"scale",value:function(U,Q){var K=u()(Q,2),ce=K[0],k=K[1],W=k===void 0?ce:k,H=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[0,0],$=u()(H,2),ee=$[0],ie=$[1],le=M.mat2d.create();return le=M.mat2d.translate(Array.of(0,0,0,0,0,0),le,[ee,ie]),le=M.mat2d.scale(Array.of(0,0,0,0,0,0),le,[ce,W]),le=M.mat2d.translate(Array.of(0,0,0,0,0,0),le,[-ee,-ie]),this.transform(U,le)}},{key:"skew",value:function(U,Q){var K=u()(Q,2),ce=K[0],k=K[1],W=k===void 0?ce:k,H=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[0,0],$=u()(H,2),ee=$[0],ie=$[1],le=M.mat2d.create();return le=M.mat2d.translate(Array.of(0,0,0,0,0,0),le,[ee,ie]),le=M.mat2d.multiply(Array.of(0,0,0,0,0,0),le,M.mat2d.fromValues(1,Math.tan(W),Math.tan(ce),1,0,0)),le=M.mat2d.translate(Array.of(0,0,0,0,0,0),le,[-ee,-ie]),this.transform(U,le)}},{key:"isPointCollision",value:function(U,Q){var K,ce=u()(Q,2),k=ce[0],W=ce[1],H=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"both",$=this.getTransform(U),ee=Object(D.transformPoint)([k,W],M.mat2d.invert(Array.of(0,0,0,0,0,0),$));return(K=this[f]).isPointCollision.apply(K,c()(ee).concat([H]))}},{key:"isPointInFill",value:function(U,Q){var K=u()(Q,2),ce=K[0],k=K[1];return this.isPointCollision(U,[ce,k],"fill")}},{key:"isPointInStroke",value:function(U,Q){var K=u()(Q,2),ce=K[0],k=K[1];return this.isPointCollision(U,[ce,k],"stroke")}},{key:"bufferSize",get:function(){return this[O].bufferSize}},{key:"mesh",get:function(){return this[f]},set:function(U){this[f]=U,this[b]&&this.setTextureFrames(this[b],this[x])}},{key:"hasCloudColor",get:function(){return this[z]}},{key:"hasCloudFilter",get:function(){return this[E]}},{key:"enableBlend",get:function(){return this[f].enableBlend||this[w]}},{key:"amount",get:function(){return this[m]},set:function(U){var Q=this[m];U!==Q&&(U>this[O].bufferSize&&(this[O]=V(Math.max(U,this[O].bufferSize+1e3),this[O])),this[m]=U,U>Q&&this.initBuffer(Q))}},{key:"meshData",get:function(){var U=this[f].meshData,Q=U.attributes,K=U.cells,ce=U.positions,k=U.textureCoord,W=U.uniforms,H=this[b],$={attributes:T({},Q),cells:K,positions:ce,textureCoord:k,uniforms:T({},W),instanceCount:this[m],enableBlend:this.enableBlend};H.length&&H.forEach(function(y,S){$.uniforms["u_texFrame".concat(S)]=y});var ee=this[O],ie=ee.transform0,le=ee.transform1,pe=ee.color0,we=ee.color1,R=ee.color2,j=ee.color3,X=ee.color4,ae=ee.fillColor,q=ee.strokeColor,te=ee.frameIndex;return this[f].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:we,divisor:1},$.attributes.a_colorCloud2={data:R,divisor:1},$.attributes.a_colorCloud3={data:j,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[f].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(M,I){var D=[],C=M[0],B=M[1],T=M[2],f=M[3],m=M[4],w=M[5],v=M[6],b=M[7],x=M[8],z=M[9],E=M[10],O=M[11],V=M[12],N=M[13],A=M[14],P=M[15],U=M[16],Q=M[17],K=M[18],ce=M[19],k=I[0],W=I[1],H=I[2],$=I[3],ee=I[4];return D[0]=k*C+W*w+H*E+$*P,D[1]=k*B+W*v+H*O+$*U,D[2]=k*T+W*b+H*V+$*Q,D[3]=k*f+W*x+H*N+$*K,D[4]=k*m+W*z+H*A+$*ce+ee,k=I[5],W=I[6],H=I[7],$=I[8],ee=I[9],D[5]=k*C+W*w+H*E+$*P,D[6]=k*B+W*v+H*O+$*U,D[7]=k*T+W*b+H*V+$*Q,D[8]=k*f+W*x+H*N+$*K,D[9]=k*m+W*z+H*A+$*ce+ee,k=I[10],W=I[11],H=I[12],$=I[13],ee=I[14],D[10]=k*C+W*w+H*E+$*P,D[11]=k*B+W*v+H*O+$*U,D[12]=k*T+W*b+H*V+$*Q,D[13]=k*f+W*x+H*N+$*K,D[14]=k*m+W*z+H*A+$*ce+ee,k=I[15],W=I[16],H=I[17],$=I[18],ee=I[19],D[15]=k*C+W*w+H*E+$*P,D[16]=k*B+W*v+H*O+$*U,D[17]=k*T+W*b+H*V+$*Q,D[18]=k*f+W*x+H*N+$*K,D[19]=k*m+W*z+H*A+$*ce+ee,D}function a(M){M=Object(s.clamp)(0,1,M);var I=.2126*M,D=.7152*M,C=.0722*M;return[I+1-M,D,C,0,0,I,D+1-M,C,0,0,I,D,C+1-M,0,0,0,0,0,1,0]}function c(M){return[M,0,0,0,0,0,M,0,0,0,0,0,M,0,0,0,0,0,1,0]}function l(M){var I=.2126*(1-M),D=.7152*(1-M),C=.0722*(1-M);return[I+M,D,C,0,0,I,D+M,C,0,0,I,D,C+M,0,0,0,0,0,1,0]}function u(M){var I=.5*(1-M);return[M,0,0,0,I,0,M,0,0,I,0,0,M,0,I,0,0,0,1,0]}function h(M){var I=1-2*M;return[I,0,0,0,M,0,I,0,0,M,0,0,I,0,M,0,0,0,1,0]}function d(M){return[1-.607*M,.769*M,.189*M,0,0,.349*M,1-.314*M,.168*M,0,0,.272*M,.534*M,1-.869*M,0,0,0,0,0,1,0]}function g(M){return[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,M,0]}function p(M){var I=M/180*Math.PI,D=Math.cos(I),C=Math.sin(I),B=.2126,T=.7152,f=.0722;return[B+D*(1-B)+C*-B,T+D*-T+C*-T,f+D*-f+C*(1-f),0,0,B+D*-B+C*.143,T+D*(1-T)+C*.14,f+D*-f+C*-.283,0,0,B+D*-B+C*-.7874,T+D*-T+C*T,f+D*(1-f)+C*f,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,M;if(typeof h=="string")if(o[h])g=o[h].slice(),M="rgb";else if(h==="transparent")p=0,M="rgb",g=[0,0,0];else if(/^#[A-Fa-f0-9]+$/.test(h)){var I=h.slice(1),D=I.length,C=D<=4;p=1,C?(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),M="rgb"}else if(d=/^((?:rgb|hs[lvb]|hwb|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms)a?)\s*\(([^\)]*)\)/.exec(h)){var B=d[1],T=B==="rgb",I=B.replace(/a$/,"");M=I;var D=I==="cmyk"?4:I==="gray"?1:3;g=d[2].trim().split(/\s*,\s*/).map(function(v,b){if(/%$/.test(v))return b===D?parseFloat(v)/100:I==="rgb"?parseFloat(v)*255/100:parseFloat(v);if(I[b]==="h"){if(/deg$/.test(v))return parseFloat(v);if(l[v]!==void 0)return l[v]}return parseFloat(v)}),B===I&&g.push(1),p=T||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(m){return parseFloat(m)}),M=h.match(/([a-z])/ig).join("").toLowerCase());else if(!isNaN(h))M="rgb",g=[h>>>16,(h&65280)>>>8,h&255];else if(a(h)){var f=c(h.r,h.red,h.R,null);f!==null?(M="rgb",g=[f,c(h.g,h.green,h.G),c(h.b,h.blue,h.B)]):(M="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]],M="rgb",p=h.length===4?h[3]:1);return{space:M,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 M=0;M<3;M++)d=a+1/3*-(M-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[M]=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,M;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),M=(u+h)/2,h===u?p=0:M<=.5?p=d/(h+u):p=d/(2-h-u),[g,p*100,M*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),M=n(59),I=n.n(M),D=n(60),C=n.n(D),B=n(61),T=n(63),f=n.n(T),m=n(70),w=n(72);n(1).glMatrix.setMatrixArrayType(Array);var v=Symbol("contours"),b=Symbol("path"),x=Symbol("simplify"),z=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[v]=null,this[x]=N.simplify!=null?N.simplify:0,this[z]=N.scale!=null?N.scale:2}return d()(V,[{key:"normalize",value:function(){var A,P=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,Q=Object(B.default)(C()(this[b])).map(function(K){for(var ce=c()(K),k=ce[0],W=ce.slice(1),H=[k],$=0;$<W.length;$+=2){var ee=W[$]-P,ie=W[$+1]-U;H.push(ee,ie)}return H});return this.beginPath(),(A=this[b]).push.apply(A,o()(Q)),this}},{key:"getPointAtLength",value:function(A){return this.contours?Object(m.getPointAtLength)(this[v],A):null}},{key:"getTotalLength",value:function(){return this.contours?Object(m.getTotalLength)(this[v]):0}},{key:"addPath",value:function(A){var P;this[v]=null,typeof A=="string"&&(A=p()(A)),(P=this[b]).push.apply(P,o()(A))}},{key:"beginPath",value:function(){this[b]=[],this[v]=null}},{key:"clear",value:function(){this.beginPath()}},{key:"ellipse",value:function(A,P,U,Q,K,ce,k){var W=arguments.length>7&&arguments[7]!==void 0?arguments[7]:0;if(ce+=K,k+=K,!(U<=0||Q<=0||k===ce)){k<ce&&(k=ce+E+(k-ce)%E),k-ce>E&&(k=ce+E);var H=k-ce;H>=E&&(k-=.001);var $=this[b].length>0&&H<E?"L":"M",ee=Object(w.getPoint)(A,P,U,Q,ce),ie=Object(w.getPoint)(A,P,U,Q,k),le=+!W,pe=H>Math.PI?1:0;W&&(pe=1-pe),$+=ee.join(" "),$+="A".concat(U," ").concat(Q," 0 ").concat(pe," ").concat(le," ").concat(ie.join(" ")),H>=E&&($+="Z"),this.addPath($)}}},{key:"arc",value:function(A,P,U,Q,K){var ce=arguments.length>5&&arguments[5]!==void 0?arguments[5]:0;return this.ellipse(A,P,U,U,0,Q,K,ce)}},{key:"arcTo",value:function(A,P,U,Q,K,ce,k){this[v]=null,this[b].push(["A",A,P,U,Q,K,ce,k])}},{key:"moveTo",value:function(A,P){this[v]=null,this[b].push(["M",A,P])}},{key:"lineTo",value:function(A,P){this[v]=null,this[b].push(["L",A,P])}},{key:"bezierCurveTo",value:function(A,P,U,Q,K,ce){this[v]=null,this[b].push(["C",A,P,U,Q,K,ce])}},{key:"quadraticCurveTo",value:function(A,P,U,Q){this[v]=null,this[b].push(["Q",A,P,U,Q])}},{key:"rect",value:function(A,P,U,Q){var K="M".concat(A," ").concat(P,"L").concat(A+U," ").concat(P,"L").concat(A+U," ").concat(P+Q,"L").concat(A," ").concat(P+Q,"Z");this.addPath(K)}},{key:"closePath",value:function(){this[v]=null;var A=[],P=this[b].length;P>0&&(A=this[b][P-1]),A[0]!=="Z"&&A[0]!=="z"&&this[b].push(["Z"])}},{key:"contours",get:function(){var A=null;if(!this[v]&&this[b]){var P=Object(B.default)(C()(this[b]));this[v]=f()(P,this[z],this[x]),this[v].path=P,this[v].simplify=this[x],this[v].scale=this[z]}return this[v]&&(A=this[v].map(function(U){return o()(U)}),A.path=this[v].path,A.simplify=this[v].simplify,A.scale=this[v].scale),A}},{key:"path",get:function(){return this[b]}},{key:"simplify",get:function(){return this[x]}},{key:"boundingBox",get:function(){var A=this.contours;if(A&&A.length){var P=A.reduce(function(U,Q){return[].concat(o()(U),o()(Q))});return I()(P)}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,M=0,I=0,D=0,C=null,B=null,T=0,f=0,m=0,w=h.length;m<w;m++){var v=h[m],b=v[0];switch(b){case"M":I=v[1],D=v[2];break;case"A":var x=Object(a.default)(T,f,v[6],v[7],v[4],v[5],v[1],v[2],v[3]);if(!x.length)continue;x=x.map(function(N){var A=o()(N,8);A[0],A[1];var P=A[2],U=A[3],Q=A[4],K=A[5],ce=A[6],k=A[7];return{x1:P,y1:U,x2:Q,y2:K,x:ce,y:k}});for(var z=0,E;z<x.length;z++)E=x[z],v=["C",E.x1,E.y1,E.x2,E.y2,E.x,E.y],z<x.length-1&&g.push(v);break;case"S":var O=T,V=f;(d=="C"||d=="S")&&(O+=O-p,V+=V-M),v=["C",O,V,v[1],v[2],v[3],v[4]];break;case"T":d=="Q"||d=="T"?(C=T*2-C,B=f*2-B):(C=T,B=f),v=u(T,f,C,B,v[1],v[2]);break;case"Q":C=v[1],B=v[2],v=u(T,f,v[1],v[2],v[3],v[4]);break;case"L":v=l(T,f,v[1],v[2]);break;case"H":v=l(T,f,v[1],f);break;case"V":v=l(T,f,T,v[1]);break;case"Z":v=l(T,f,I,D);break}d=b,T=v[v.length-2],f=v[v.length-1],v.length>4?(p=v[v.length-4],M=v[v.length-3]):(p=T,M=f),g.push(v)}return g}function l(h,d,g,p){return["C",h,d,g,p,g,p]}function u(h,d,g,p,M,I){return["C",h/3+2/3*g,d/3+2/3*p,M/3+2/3*g,I/3+2/3*p,M,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,M=u*d+h*g;return M>1&&(M=1),M<-1&&(M=-1),p*Math.acos(M)}function a(u,h,d,g,p,M,I,D,C,B){var T=B*(u-d)/2+C*(h-g)/2,f=-C*(u-d)/2+B*(h-g)/2,m=I*I,w=D*D,v=T*T,b=f*f,x=m*w-m*b-w*v;x<0&&(x=0),x/=m*b+w*v,x=Math.sqrt(x)*(p===M?-1:1);var z=x*I/D*f,E=x*-D/I*T,O=B*z-C*E+(u+d)/2,V=C*z+B*E+(h+g)/2,N=(T-z)/I,A=(f-E)/D,P=(-T-z)/I,U=(-f-E)/D,Q=o(1,0,N,A),K=o(N,A,P,U);return M===0&&K>0&&(K-=s),M===1&&K<0&&(K+=s),[O,V,Q,K]}function c(u,h){var d=1.3333333333333333*Math.tan(h/4),g=Math.cos(u),p=Math.sin(u),M=Math.cos(u+h),I=Math.sin(u+h);return[g,p,g-p*d,p+g*d,M+I*d,I-M*d,M,I]}function l(u,h,d,g,p,M,I,D,C){var B=Math.sin(C*s/360),T=Math.cos(C*s/360),f=T*(u-d)/2+B*(h-g)/2,m=-B*(u-d)/2+T*(h-g)/2;if(f===0&&m===0)return[];if(I===0||D===0)return[];I=Math.abs(I),D=Math.abs(D);var w=f*f/(I*I)+m*m/(D*D);w>1&&(I*=Math.sqrt(w),D*=Math.sqrt(w));var v=a(u,h,d,g,p,M,I,D,B,T),b=[],x=v[2],z=v[3],E=Math.max(Math.ceil(Math.abs(z)/(s/4)),1);z/=E;for(var O=0;O<E;O++)b.push(c(x,z)),x+=z;return b.map(function(V){for(var N=0;N<V.length;N+=2){var A=V[N+0],P=V[N+1];A*=I,P*=D;var U=T*A-B*P,Q=B*A+T*P;V[N+0]=U+v[0],V[N+1]=Q+v[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,M,I){return p[0]=M,p[1]=I,p}var u=[0,0],h=[0,0],d=[0,0];function g(p,M,I,D){s(I,l(u,D[1],D[2]),l(h,D[3],D[4]),l(d,D[5],D[6]),M,p)}e.exports=function(M,I,D){var C=[],B=[],T=[0,0];return M.forEach(function(f,m,w){if(f[0]==="M")a(T,f.slice(1)),B.length>0&&(C.push(B),B=[]);else if(f[0]==="C")g(B,I,T,f),l(T,f[5],f[6]);else throw new Error("illegal type in SVG: "+f[0])}),B.length>0&&C.push(B),C.map(function(f){return c(f,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,C,B,T,f,m){m||(m=[]),f=typeof f=="number"?f:1;var w=u/f;return w*=w,p(D,C,B,T,m,w),m};function p(I,D,C,B,T,f){T.push(n(I));var m=I[0],w=I[1],v=D[0],b=D[1],x=C[0],z=C[1],E=B[0],O=B[1];M(m,w,v,b,x,z,E,O,T,f,0),T.push(n(B))}function M(I,D,C,B,T,f,m,w,v,b,x){if(!(x>c)){var z=Math.PI,E=(I+C)/2,O=(D+B)/2,V=(C+T)/2,N=(B+f)/2,A=(T+m)/2,P=(f+w)/2,U=(E+V)/2,Q=(O+N)/2,K=(V+A)/2,ce=(N+P)/2,k=(U+K)/2,W=(Q+ce)/2;if(x>0){var H=m-I,$=w-D,ee=Math.abs((C-m)*$-(B-w)*H),ie=Math.abs((T-m)*$-(f-w)*H),le,pe;if(ee>l&&ie>l){if((ee+ie)*(ee+ie)<=b*(H*H+$*$)){if(d<h){v.push(s(k,W));return}var we=Math.atan2(f-B,T-C);if(le=Math.abs(we-Math.atan2(B-D,C-I)),pe=Math.abs(Math.atan2(w-f,m-T)-we),le>=z&&(le=2*z-le),pe>=z&&(pe=2*z-pe),le+pe<d){v.push(s(k,W));return}if(g!==0){if(le>g){v.push(s(C,B));return}if(pe>g){v.push(s(T,f));return}}}}else if(ee>l){if(ee*ee<=b*(H*H+$*$)){if(d<h){v.push(s(k,W));return}if(le=Math.abs(Math.atan2(f-B,T-C)-Math.atan2(B-D,C-I)),le>=z&&(le=2*z-le),le<d){v.push(s(C,B)),v.push(s(T,f));return}if(g!==0&&le>g){v.push(s(C,B));return}}}else if(ie>l){if(ie*ie<=b*(H*H+$*$)){if(d<h){v.push(s(k,W));return}if(le=Math.abs(Math.atan2(w-f,m-T)-Math.atan2(f-B,T-C)),le>=z&&(le=2*z-le),le<d){v.push(s(C,B)),v.push(s(T,f));return}if(g!==0&&le>g){v.push(s(T,f));return}}}else if(H=k-(I+m)/2,$=W-(D+w)/2,H*H+$*$<=b){v.push(s(k,W));return}}M(I,D,E,O,U,Q,k,W,v,b,x+1),M(k,W,K,ce,A,P,m,w,v,b,x+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 C}),n.d(r,"normal",function(){return B}),n.d(r,"direction",function(){return T});var s=n(1);n(1).glMatrix.setMatrixArrayType(Array);function o(f){return[f[0],f[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,M=s.vec2.normalize,I=s.vec2.set,D=a();function C(f,m,w,v,b){p(f,w,v),M(f,f),I(m,-f[1],f[0]),I(D,-w[1],w[0]);var x=b/u(m,D);return Math.abs(x)}function B(f,m){return I(f,-m[1],m[0]),f}function T(f,m,w){return g(f,m,w),M(f,f),f}},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 M=p[0],I=1;I<p.length;I++){var D=p[I];g+=Object(a.distance)(M,D),M=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 M=c(d);if(g>=M){var I=d[d.length-1],D=I[I.length-2],C=I[I.length-1],B=Math.atan2(C[1]-D[1],C[0]-D[0]);return{current:d.map(function(A){return o()(A)}),point:{x:C[0],y:C[1],angle:B}}}for(var T=[],f=0;f<d.length;f++){T[f]=[];for(var m=d[f],w=m[0],v=1;v<m.length;v++){var b=m[v],x=Object(a.distance)(w,b);if(g<x){var z=g/x,E=Math.atan2(b[1]-w[1],b[0]-w[0]),O={x:w[0]*(1-z)+b[0]*z,y:w[1]*(1-z)+b[1]*z,angle:E};if(T[f].push(w),g>0&&T[f].push([O.x,O.y]),!p)return{current:T,point:O};for(var V=[],N=f;f<d.length;f++){for(V[f-N]=[],f===N&&V[0].push([O.x,O.y]);v<m.length;v++)V[f-N].push(m[v]);v=0}return{current:T,point:O,rest:V}}g-=x,T[f].push(w),w=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],M=d[0][1],I=Math.atan2(M[1]-p[1],M[0]-p[0]);return{x:p[0],y:p[1],angle:I}}return l(d,g,!1).point}function h(d,g,p){var M=0,I=g[0],D=d,C=[],B=g.length;if(p>0){do p-=g[M%B],M++;while(p>0);p<0&&(I=-p,M--)}else if(p<0){M=-1;do p+=g[M%B+B-1],M--;while(p<0);p>=0&&(M++,I=g[M%B+B-1]-p)}do{var T=l(D,I);D=T.rest,++M%2&&C.push.apply(C,o()(T.current));var f=M%B;f<0&&(f+=B),I=g[f]}while(D);return C}},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],M=g[1],I=g[2];return p=p*2/u-1,M=1-M*2/h,Number.isFinite(d)?(I=I*2/d-1,[p,M,I]):[p,M]}function c(l,u){var h=o()(l,3),d=h[0],g=h[1],p=h[2],M=p===void 0?0:p,I=o()(u,3),D=I[0],C=I[1],B=I[2],T=B===void 0?0:B;return Math.hypot(D-d,C-g,T-M)}},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),M=-1;(h<=Math.PI/2||h>3*Math.PI/2)&&(M=1);var I=M*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),M=n(1),I=n(59),D=n.n(I),C=n(76),B=n(44),T=n(40),f=n(46),m=n(78),w=n(70),v=n(79),b=n.n(v),x=n(63),z=n.n(x),E=n(47),O=n(56),V=n(37);n(1).glMatrix.setMatrixArrayType(Array);var N=Symbol("mesh"),A=Symbol("contours"),P=Symbol("stroke"),U=Symbol("fill"),Q=Symbol("strokeColor"),K=Symbol("fillColor"),ce=Symbol("transform"),k=Symbol("invertTransform"),W=Symbol("uniforms"),H=Symbol("texOptions"),$=Symbol("blend"),ee=Symbol("applyTexture"),ie=Symbol("applyTransform"),le=Symbol("applyGradientTransform"),pe=Symbol("applyProgram"),we=Symbol("gradient"),R=Symbol("filter"),j=Symbol("opacity"),X=Symbol("program"),ae=Symbol("attributes"),q=Symbol("pass"),te=Symbol("clipContext"),y=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],xe=de[2],Ce=de[3],Ie=J.scale;return Ie||(ue/=xe,oe=1-oe/Ce,ue-=me,oe+=ye),[ue,oe,0]}function Y(re,ne,J){var se=z()(re,ne,J);return se.path=re,se.simplify=J,se.scale=ne,se}var _=function(){function re(ne){u()(this,re),this[P]=null,this[U]=null,this[ce]=[1,0,0,1,0,0],this[j]=1,this[W]={},this[R]=[],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[j]}},{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[j]=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[y]()}},{key:y,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 xe=this[te].getContext("2d"),Ce=new Path2D(this.clipPath);xe.clearRect(0,0,this[te].width,this[te].height),xe.save(),xe.translate(-ue,-oe),xe.fillStyle="white",xe.fill(Ce),xe.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(w.getPointAtLength)(this[A],J)}},{key:"getTotalLength",value:function(){return Object(w.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],xe=me[1];if(ye!=="a_color"&&ye!=="a_sourceRect"&&xe!=="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 ke=0;ke<ue.length;ke++){var Re=ue[ke];this[N].attributes[ye].push(Ce?Ce(Re,de,ue):Array(xe.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],xe=me[1],Ce=ue[de];Ce[0]=ye*se[0]+xe*se[2]+se[4],Ce[1]=ye*se[1]+xe*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,Le){return Re==null&&Le==null?!0:Re==null||Le==null?!1:Re[0]===Le[0]&&Re[1]===Le[1]&&Re[2]===Le[2]&&Re[3]===Le[3]}var oe=this[W].u_texSampler;if(oe){var de=oe._img,me=de.width,ye=de.height,xe=se.srcRect,Ce=se.rect||[0,0];if(se.rotated&&(Ce=[-Ce[1],Ce[0],Ce[3],Ce[2]]),Ce[2]==null&&(Ce[2]=xe?xe[2]:me),Ce[3]==null&&(Ce[3]=xe?xe[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=M.mat2d.rotate(Array.of(0,0,0,0,0,0),M.mat2d.fromValues(1,0,0,1,0,0),.5*Math.PI),Ie=M.mat2d.translate(Array.of(0,0,0,0,0,0),Ie,[0,-Ce[2]])),J.textureCoord=J.position0.map(function(Re){var Le=p()(Re,3),Oe=Le[0],je=Le[1],Be=Le[2];if(1/Be>0){if(se.rotated){var Je=Oe*Ie[0]+je*Ie[2]+Ie[4],et=Oe*Ie[1]+je*Ie[3]+Ie[5];Oe=Je,je=et}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(xe){var ke=[xe[0]/me,xe[1]/ye,xe[2]/me,xe[3]/ye];J.attributes.a_sourceRect=J.positions.map(function(){return[].concat(ke)})}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[P]==null||this[P].lineWidth===0||this[Q][3]===0,se=this[U]==null||this[K][3]===0,ue=this[W].u_radialGradientVector==null,oe=this[W].u_texSampler==null;return this[j]===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,xe=J.miterLimit,Ce=xe===void 0?10:xe,Ie=J.color,ke=Ie===void 0?[0,0,0,0]:Ie,Re=J.lineDash,Le=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[P]=new C.default({lineWidth:ue,lineCap:de,lineJoin:ye,miterLimit:Ce,roundSegments:Je}),typeof ke=="string"&&(ke=Object(E.default)(ke)),this[Q]=ke,this[P].lineDash=Le,this[P].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[K]=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(xe){var Ce=xe.offset,Ie=xe.color;return typeof Ie=="string"&&(Ie=Object(E.default)(Ie)),{offset:Ce,color:Ie}}),this[we]=this[we]||{},this[we][de]={vector:se,colors:ue},ue.sort(function(xe,Ce){return xe.offset-Ce.offset});var me=[];ue.forEach(function(xe){var Ce=xe.offset,Ie=xe.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 M.mat2d.equals(ue,J)||(this[ce]=ue,delete this[k],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]=M.mat2d.multiply(Array.of(0,0,0,0,0,0),J,ue),delete this[k],this._updateMatrix=!0,this}},{key:"translate",value:function(J,se){var ue=M.mat2d.create();return ue=M.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=M.mat2d.create();return me=M.mat2d.translate(Array.of(0,0,0,0,0,0),me,[oe,de]),me=M.mat2d.rotate(Array.of(0,0,0,0,0,0),me,J),me=M.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=M.mat2d.create();return ye=M.mat2d.translate(Array.of(0,0,0,0,0,0),ye,[de,me]),ye=M.mat2d.scale(Array.of(0,0,0,0,0,0),ye,[J,se]),ye=M.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=M.mat2d.create();return ye=M.mat2d.translate(Array.of(0,0,0,0,0,0),ye,[de,me]),ye=M.mat2d.multiply(Array.of(0,0,0,0,0,0),ye,M.mat2d.fromValues(1,Math.tan(se),Math.tan(J),1,0,0)),ye=M.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[R].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(f.multiply)(J,ue):J=ue,this.setColorTransform.apply(this,c()(J)),this}},{key:"blur",value:function(J){return this[R].push("blur(".concat(J,"px)")),this}},{key:"brightness",value:function(){var J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;return this[R].push("brightness(".concat(100*J,"%)")),this.transformColor.apply(this,c()(Object(f.brightness)(J)))}},{key:"contrast",value:function(){var J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;return this[R].push("contrast(".concat(100*J,"%)")),this.transformColor.apply(this,c()(Object(f.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(T.default)(oe)),this[R].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[R].push("grayscale(".concat(100*J,"%)")),this.transformColor.apply(this,c()(Object(f.grayscale)(J)))}},{key:"hueRotate",value:function(){var J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return this[R].push("hue-rotate(".concat(J,"deg)")),this.transformColor.apply(this,c()(Object(f.hueRotate)(J)))}},{key:"invert",value:function(){var J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;return this[R].push("invert(".concat(100*J,"%)")),this.transformColor.apply(this,c()(Object(f.invert)(J)))}},{key:"opacity",value:function(){var J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;return this[R].push("opacity(".concat(100*J,"%)")),this.transformColor.apply(this,c()(Object(f.opacity)(J)))}},{key:"saturate",value:function(){var J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;return this[R].push("saturate(".concat(100*J,"%)")),this.transformColor.apply(this,c()(Object(f.saturate)(J)))}},{key:"sepia",value:function(){var J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;return this[R].push("sepia(".concat(100*J,"%)")),this.transformColor.apply(this,c()(Object(f.sepia)(J)))}},{key:"url",value:function(J){return this[R].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,xe=ye[0]*J+ye[2]*se+ye[4],Ce=ye[1]*J+ye[3]*se+ye[5],Ie=this.boundingBox;if(xe<Ie[0][0]||xe>Ie[1][0]||Ce<Ie[0][1]||Ce>Ie[1][1])return!1;function ke(hi,Js,L0){var Uh=p()(hi,2),R0=Uh[0],O0=Uh[1],Fh=p()(Js,2),Wh=Fh[0],$h=Fh[1],Vh=p()(L0,2),z0=Vh[0],j0=Vh[1],Yh=z0-Wh,Gh=j0-$h,Hh=((R0-Wh)*Yh+(O0-$h)*Gh)/(Math.pow(Yh,2)+Math.pow(Gh,2));return Hh>=0&&Hh<=1}for(var Re=0;Re<me.length;Re++){var Le=me[Re];if(ue==="fill"&&Le[0]>=oe.fillPointCount)break;if(!(ue==="stroke"&&Le[0]<oe.fillPointCount)){var Oe=Le.map(function(hi){return de[hi]}),je=p()(Oe,3),Be=p()(je[0],2),Je=Be[0],et=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-et)-(nt-Je)*(se-et));if(Ut===0&&ke([J,se],[Je,et],[nt,st]))return!0;var Dr=Math.sign((J-nt)*(Ze-st)-(lt-nt)*(se-st));if(Dr===0&&ke([J,se],[nt,st],[lt,Ze]))return!0;var Pr=Math.sign((J-lt)*(et-Ze)-(Je-lt)*(se-Ze));if(Pr===0&&ke([J,se],[lt,Ze],[Je,et])||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[P]?this[P].lineWidth:0}},{key:"lineCap",get:function(){return this[P]?this[P].lineCap:""}},{key:"lineJoin",get:function(){return this[P]?this[P].lineJoin:""}},{key:"miterLimit",get:function(){return this[P]?this[P].miterLimit:0}},{key:"strokeStyle",get:function(){return this[Q]&&this[Q][3]!==0?Object(T.default)(this[Q]):""}},{key:"lineDash",get:function(){return this[P]?this[P].lineDash:null}},{key:"lineDashOffset",get:function(){return this[P]?this[P].lineDashOffset:0}},{key:"fillStyle",get:function(){return this[K]&&this[K][3]!==0?Object(T.default)(this[K]):""}},{key:"gradient",get:function(){return this[we]}},{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[j]<1||this[Q]!=null&&this[Q][3]<1||this[K]!=null&&this[K][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[R].join(" ")}},{key:"transformMatrix",get:function(){return this[ce]}},{key:"invertMatrix",get:function(){if(!this[k]){var J=M.mat2d.invert(Array.of(0,0,0,0,0,0),this[ce]);this[k]=J}return this[k]}},{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[P]&&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[j]),Re}),de.attributes={a_color:Array.from({length:de.positions.length}).map(function(){return J[K].map(function(Re){return Math.round(255*Re)})})},oe.fill=de}catch{}if(this[P]){var me=this[P].lineDash,ye=ue;if(me){var xe=this[P].lineDashOffset;ye=Object(w.getDashContours)(ue,me,xe)}var Ce=ye.map(function(Re,Le){var Oe=Re.length>1&&M.vec2.equals(Re[0],Re[Re.length-1]),je=J[P].build(Re,Oe);return b()([je])});Ce.forEach(function(Re){Re.positions=Re.positions.map(function(Le){return Le.push(-J[j]),Le}),Re.attributes={a_color:Array.from({length:Re.positions.length}).map(function(){return J[Q].map(function(Le){return Math.round(255*Le)})})}}),oe.stroke=Object(B.default)(Ce)}}var Ie=Object(B.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 Le=p()(Re,3),Oe=Le[0],je=Le[1],Be=Le[2];return[Oe,je,Be]}),Ie.uniforms=this[W],this[N]=Ie,this[W].u_texSampler&&this[ee](Ie,this[H]);var ke=this[ce];Object(m.isUnitTransform)(ke)||(this[ie](Ie,ke),this[W].u_radialGradientVector&&this[le]()),this.clipPath&&this[y](),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 C});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)(),M=Object(h.create)(),I=Object(h.create)(),D=1e20,C=function(){function m(){var w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},v=w.lineWidth,b=v===void 0?1:v,x=w.lineJoin,z=x===void 0?"miter":x,E=w.miterLimit,O=E===void 0?10:E,V=w.lineCap,N=V===void 0?"butt":V,A=w.roundSegments,P=A===void 0?20:A;c()(this,m),this.lineWidth=b,this.lineJoin=z,this.miterLimit=O,this.lineCap=N,this.roundSegments=P,this._normal=null}return u()(m,[{key:"build",value:function(v){var b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,x=v.length;if(v=o()(v),x<2)return v;b&&((v[0][0]!==v[x-1][0]||v[0][1]!==v[x-1][1])&&v.push(o()(v[0])),v.push(o()(v[1]))),x=v.length,this._normal=null;var z={left:[],right:[]},E=this.lineWidth/2,O=this.lineCap;if(!b&&O==="square"){Object(h.direction)(g,v[0],v[1]),Object(h.scaleAndAdd)(v[0],v[0],g,E);var V=v.length-1;Object(h.direction)(g,v[V],v[V-1]),Object(h.scaleAndAdd)(v[V],v[V],g,E)}for(var N=1;N<x;N++){var A=v[N-1],P=v[N],U=v[N+1];this._seg(z,A,P,U,E,b)}!b&&O==="round"&&f(z,this.roundSegments);var Q=[].concat(o()(z.left),o()(z.right.reverse()));return Q}},{key:"_seg",value:function(v,b,x,z,E,O){var V=this.lineJoin==="bevel",N=this.lineJoin==="round";if(Object(h.direction)(g,x,b),this._normal||(this._normal=Object(h.create)(),Object(h.normal)(this._normal,g)),v.left.length||T(v,b,this._normal,E),!z)Object(h.normal)(this._normal,g),O?T(v,b,this._normal,E):T(v,x,this._normal,E);else{Object(h.direction)(p,z,x);var A=Object(h.computeMiter)(M,I,g,p,E);A=Math.min(A,D);var P=Object(h.dot)(M,this._normal)<0?-1:1,U=V||N;if(!U&&this.lineJoin==="miter"){var Q=A/E;Q>this.miterLimit&&(U=!0)}if(U){Object(h.scaleAndAdd)(d,x,this._normal,-E*P),B(v,d,P);var K=1/0;b&&(K=Math.min(K,Math.hypot(x[0]-b[0],x[1]-b[1]))),z&&(K=Math.min(K,Math.hypot(z[0]-x[0],z[1]-x[1])));var ce=Math.max(E,Math.min(A,K));if(Object(h.scaleAndAdd)(d,x,I,ce*P),B(v,d,-P),z)if(Object(h.normal)(d,p),Object(h.copy)(this._normal,d),Object(h.scaleAndAdd)(d,x,d,-E*P),N){for(var k=Object(h.clone)(d),W=P>0?v.left[v.left.length-1]:v.right[v.right.length-1],H=Object(h.clone)(x),$=Object(h.sub)(Object(h.create)(),W,H),ee=Object(h.sub)(Object(h.create)(),k,H),ie=Math.PI/this.roundSegments,le=0;le<this.roundSegments&&(Object(h.rotate)($,$,[0,0],P*ie),Math.sign(Object(h.cross)(d,$,ee)[2])===P);le++)Object(h.add)(d,$,H),B(v,d,P);B(v,k,P)}else B(v,d,P)}else T(v,x,I,A),Object(h.copy)(this._normal,I)}}}]),m}();function B(m,w,v){v>0?m.left.push(Object(h.clone)(w)):m.right.push(Object(h.clone)(w))}function T(m,w,v,b){var x=arguments.length>4&&arguments[4]!==void 0?arguments[4]:-1;Object(h.scaleAndAdd)(d,w,v,-b),B(m,d,-x),Object(h.scaleAndAdd)(d,w,v,b),B(m,d,x)}function f(m,w){var v=m.left,b=m.right,x=Object(h.create)(),z=Object(h.create)(),E=v[0],O=b[0],V=[.5*(E[0]+O[0]),.5*(E[1]+O[1])];Object(h.sub)(z,E,V);for(var N=1;N<=w;N++){var A=-1*Math.PI*N/w;Object(h.rotate)(x,z,[0,0],A),Object(h.add)(d,V,x),v.unshift(Object(h.clone)(d))}E=b[b.length-1],O=v[v.length-1],V=[.5*(E[0]+O[0]),.5*(E[1]+O[1])],Object(h.sub)(z,E,V);for(var P=1;P<=w;P++){var U=-1*Math.PI*P/w;Object(h.rotate)(x,z,[0,0],U),Object(h.add)(d,V,x),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(C){return C.length>2}),a.length===0)return{positions:[],cells:[]};typeof c.vertexSize!="number"&&(c.vertexSize=a[0][0].length),a=a.map(function(C){return C.reduce(function(B,T){return B.concat(T)})});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 M=u.elements[d],I=u.elements[d+1],D=u.elements[d+2];p.push([M,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(T){for(var f=T.debug||!1,m=new B,w=0;w<T.contours.length;w++)m.addContour(T.vertexSize||2,T.contours[w]);return m.tesselate(T.windingRule||s.WINDING_ODD,T.elementType||s.POLYGONS,T.polySize||3,T.vertexSize||2,T.normal||[0,0,1]),{vertices:m.vertices,vertexIndices:m.vertexIndices,vertexCount:m.vertexCount,elements:m.elements,elementCount:m.elementCount,mesh:f?m.mesh:void 0}};var a=function(f){if(!f)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(T){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=T}u.prototype={get Rface(){return this.Sym.Lface},set Rface(T){this.Sym.Lface=T},get Dst(){return this.Sym.Org},set Dst(T){this.Sym.Org=T},get Oprev(){return this.Sym.Lnext},set Oprev(T){this.Sym.Lnext=T},get Lprev(){return this.Onext.Sym},set Lprev(T){this.Onext.Sym=T},get Dprev(){return this.Lnext.Sym},set Dprev(T){this.Lnext.Sym=T},get Rprev(){return this.Sym.Onext},set Rprev(T){this.Sym.Onext=T},get Dnext(){return this.Sym.Onext.Sym},set Dnext(T){this.Sym.Onext.Sym=T},get Rnext(){return this.Sym.Lnext.Sym},set Rnext(T){this.Sym.Lnext.Sym=T}};function h(){var T=new c,f=new l,m=new u(0),w=new u(1);T.next=T.prev=T,T.anEdge=null,f.next=f.prev=f,f.anEdge=null,f.trail=null,f.marked=!1,f.inside=!1,m.next=m,m.Sym=w,m.Onext=null,m.Lnext=null,m.Org=null,m.Lface=null,m.winding=0,m.activeRegion=null,w.next=w,w.Sym=m,w.Onext=null,w.Lnext=null,w.Org=null,w.Lface=null,w.winding=0,w.activeRegion=null,this.vHead=T,this.fHead=f,this.eHead=m,this.eHeadSym=w}h.prototype={makeEdge_:function(f){var m=new u(0),w=new u(1);f.Sym.side<f.side&&(f=f.Sym);var v=f.Sym.next;return w.next=v,v.Sym.next=m,m.next=f,f.Sym.next=w,m.Sym=w,m.Onext=m,m.Lnext=w,m.Org=null,m.Lface=null,m.winding=0,m.activeRegion=null,w.Sym=m,w.Onext=w,w.Lnext=m,w.Org=null,w.Lface=null,w.winding=0,w.activeRegion=null,m},splice_:function(f,m){var w=f.Onext,v=m.Onext;w.Sym.Lnext=m,v.Sym.Lnext=f,f.Onext=v,m.Onext=w},makeVertex_:function(f,m,w){var v=f;a(v!==null);var b=w.prev;v.prev=b,b.next=v,v.next=w,w.prev=v,v.anEdge=m;var x=m;do x.Org=v,x=x.Onext;while(x!==m)},makeFace_:function(f,m,w){var v=f;a(v!==null);var b=w.prev;v.prev=b,b.next=v,v.next=w,w.prev=v,v.anEdge=m,v.trail=null,v.marked=!1,v.inside=w.inside;var x=m;do x.Lface=v,x=x.Lnext;while(x!==m)},killEdge_:function(f){f.Sym.side<f.side&&(f=f.Sym);var m=f.next,w=f.Sym.next;m.Sym.next=w,w.Sym.next=m},killVertex_:function(f,m){var w=f.anEdge,v=w;do v.Org=m,v=v.Onext;while(v!==w);var b=f.prev,x=f.next;x.prev=b,b.next=x},killFace_:function(f,m){var w=f.anEdge,v=w;do v.Lface=m,v=v.Lnext;while(v!==w);var b=f.prev,x=f.next;x.prev=b,b.next=x},makeEdge:function(){var f=new c,m=new c,w=new l,v=this.makeEdge_(this.eHead);return this.makeVertex_(f,v,this.vHead),this.makeVertex_(m,v.Sym,this.vHead),this.makeFace_(w,v,this.fHead),v},splice:function(f,m){var w=!1,v=!1;if(f!==m){if(m.Org!==f.Org&&(v=!0,this.killVertex_(m.Org,f.Org)),m.Lface!==f.Lface&&(w=!0,this.killFace_(m.Lface,f.Lface)),this.splice_(m,f),!v){var b=new c;this.makeVertex_(b,m,f.Org),f.Org.anEdge=f}if(!w){var x=new l;this.makeFace_(x,m,f.Lface),f.Lface.anEdge=f}}},delete:function(f){var m=f.Sym,w=!1;if(f.Lface!==f.Rface&&(w=!0,this.killFace_(f.Lface,f.Rface)),f.Onext===f)this.killVertex_(f.Org,null);else if(f.Rface.anEdge=f.Oprev,f.Org.anEdge=f.Onext,this.splice_(f,f.Oprev),!w){var v=new l;this.makeFace_(v,f,f.Lface)}m.Onext===m?(this.killVertex_(m.Org,null),this.killFace_(m.Lface,null)):(f.Lface.anEdge=m.Oprev,m.Org.anEdge=m.Onext,this.splice_(m,m.Oprev)),this.killEdge_(f)},addEdgeVertex:function(f){var m=this.makeEdge_(f),w=m.Sym;this.splice_(m,f.Lnext),m.Org=f.Dst;var v=new c;return this.makeVertex_(v,w,m.Org),m.Lface=w.Lface=f.Lface,m},splitEdge:function(f,m){var w=this.addEdgeVertex(f),v=w.Sym;return this.splice_(f.Sym,f.Sym.Oprev),this.splice_(f.Sym,v),f.Dst=v.Org,v.Dst.anEdge=v.Sym,v.Rface=f.Rface,v.winding=f.winding,v.Sym.winding=f.Sym.winding,v},connect:function(f,m){var w=!1,v=this.makeEdge_(f),b=v.Sym;if(m.Lface!==f.Lface&&(w=!0,this.killFace_(m.Lface,f.Lface)),this.splice_(v,f.Lnext),this.splice_(b,m),v.Org=f.Dst,b.Org=m.Org,v.Lface=b.Lface=f.Lface,f.Lface.anEdge=b,!w){var x=new l;this.makeFace_(x,v,f.Lface)}return v},zapFace:function(f){var m=f.anEdge,w,v,b,x,z;v=m.Lnext;do w=v,v=w.Lnext,w.Lface=null,w.Rface===null&&(w.Onext===w?this.killVertex_(w.Org,null):(w.Org.anEdge=w.Onext,this.splice_(w,w.Oprev)),b=w.Sym,b.Onext===b?this.killVertex_(b.Org,null):(b.Org.anEdge=b.Onext,this.splice_(b,b.Oprev)),this.killEdge_(w));while(w!=m);x=f.prev,z=f.next,z.prev=x,x.next=z},countFaceVerts_:function(f){var m=f.anEdge,w=0;do w++,m=m.Lnext;while(m!==f.anEdge);return w},mergeConvexFaces:function(f){var m,w,v,b,x,z,E;for(m=this.fHead.next;m!==this.fHead;m=m.next)if(m.inside)for(w=m.anEdge,x=w.Org;v=w.Lnext,b=w.Sym,b&&b.Lface&&b.Lface.inside&&(z=this.countFaceVerts_(m),E=this.countFaceVerts_(b.Lface),z+E-2<=f&&o.vertCCW(w.Lprev.Org,w.Org,b.Lnext.Lnext.Org)&&o.vertCCW(b.Lprev.Org,b.Org,w.Lnext.Lnext.Org)&&(v=b.Lnext,this.delete(b),w=null,b=null)),!(w&&w.Lnext.Org===x);)w=v;return!0},check:function(){var f=this.fHead,m=this.vHead,w=this.eHead,v,b,x,z,E,O;for(b=f,b=f;(v=b.next)!==f;b=v){a(v.prev===b),E=v.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===v),E=E.Lnext;while(E!==v.anEdge)}for(a(v.prev===b&&v.anEdge===null),z=m,z=m;(x=z.next)!==m;z=x){a(x.prev===z),E=x.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===x),E=E.Onext;while(E!==x.anEdge)}for(a(x.prev===z&&x.anEdge===null),O=w,O=w;(E=O.next)!==w;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(T,f){return T.s===f.s&&T.t===f.t},o.vertLeq=function(T,f){return T.s<f.s||T.s===f.s&&T.t<=f.t},o.transLeq=function(T,f){return T.t<f.t||T.t===f.t&&T.s<=f.s},o.edgeGoesLeft=function(T){return o.vertLeq(T.Dst,T.Org)},o.edgeGoesRight=function(T){return o.vertLeq(T.Org,T.Dst)},o.vertL1dist=function(T,f){return Math.abs(T.s-f.s)+Math.abs(T.t-f.t)},o.edgeEval=function(T,f,m){a(o.vertLeq(T,f)&&o.vertLeq(f,m));var w=f.s-T.s,v=m.s-f.s;return w+v>0?w<v?f.t-T.t+(T.t-m.t)*(w/(w+v)):f.t-m.t+(m.t-T.t)*(v/(w+v)):0},o.edgeSign=function(T,f,m){a(o.vertLeq(T,f)&&o.vertLeq(f,m));var w=f.s-T.s,v=m.s-f.s;return w+v>0?(f.t-m.t)*w+(f.t-T.t)*v:0},o.transEval=function(T,f,m){a(o.transLeq(T,f)&&o.transLeq(f,m));var w=f.t-T.t,v=m.t-f.t;return w+v>0?w<v?f.s-T.s+(T.s-m.s)*(w/(w+v)):f.s-m.s+(m.s-T.s)*(v/(w+v)):0},o.transSign=function(T,f,m){a(o.transLeq(T,f)&&o.transLeq(f,m));var w=f.t-T.t,v=m.t-f.t;return w+v>0?(f.s-m.s)*w+(f.s-T.s)*v:0},o.vertCCW=function(T,f,m){return T.s*(f.t-m.t)+f.s*(m.t-T.t)+m.s*(T.t-f.t)>=0},o.interpolate=function(T,f,m,w){return T=T<0?0:T,m=m<0?0:m,T<=m?m===0?(f+w)/2:f+(w-f)*(T/(T+m)):w+(f-w)*(m/(T+m))},o.intersect=function(T,f,m,w,v){var b,x,z;o.vertLeq(T,f)||(z=T,T=f,f=z),o.vertLeq(m,w)||(z=m,m=w,w=z),o.vertLeq(T,m)||(z=T,T=m,m=z,z=f,f=w,w=z),o.vertLeq(m,f)?o.vertLeq(f,w)?(b=o.edgeEval(T,m,f),x=o.edgeEval(m,f,w),b+x<0&&(b=-b,x=-x),v.s=o.interpolate(b,m.s,x,f.s)):(b=o.edgeSign(T,m,f),x=-o.edgeSign(T,w,f),b+x<0&&(b=-b,x=-x),v.s=o.interpolate(b,m.s,x,w.s)):v.s=(m.s+f.s)/2,o.transLeq(T,f)||(z=T,T=f,f=z),o.transLeq(m,w)||(z=m,m=w,w=z),o.transLeq(T,m)||(z=T,T=m,m=z,z=f,f=w,w=z),o.transLeq(m,f)?o.transLeq(f,w)?(b=o.transEval(T,m,f),x=o.transEval(m,f,w),b+x<0&&(b=-b,x=-x),v.t=o.interpolate(b,m.t,x,f.t)):(b=o.transSign(T,m,f),x=-o.transSign(T,w,f),b+x<0&&(b=-b,x=-x),v.t=o.interpolate(b,m.t,x,w.t)):v.t=(m.t+f.t)/2};function d(){this.key=null,this.next=null,this.prev=null}function g(T,f){this.head=new d,this.head.next=this.head,this.head.prev=this.head,this.frame=T,this.leq=f}g.prototype={min:function(){return this.head.next},max:function(){return this.head.prev},insert:function(f){return this.insertBefore(this.head,f)},search:function(f){var m=this.head;do m=m.next;while(m.key!==null&&!this.leq(this.frame,f,m.key));return m},insertBefore:function(f,m){do f=f.prev;while(f.key!==null&&!this.leq(this.frame,f.key,m));var w=new d;return w.key=m,w.next=f.next,f.next.prev=w,w.prev=f,f.next=w,w},delete:function(f){f.next.prev=f.prev,f.prev.next=f.next}};function p(){this.handle=null}function M(){this.key=null,this.node=null}function I(T,f){this.size=0,this.max=T,this.nodes=[],this.nodes.length=T+1;var m;for(m=0;m<this.nodes.length;m++)this.nodes[m]=new p;for(this.handles=[],this.handles.length=T+1,m=0;m<this.handles.length;m++)this.handles[m]=new M;this.initialized=!1,this.freeList=0,this.leq=f,this.nodes[1].handle=1,this.handles[1].key=null}I.prototype={floatDown_:function(f){var m=this.nodes,w=this.handles,v,b,x;for(v=m[f].handle;;){if(x=f<<1,x<this.size&&this.leq(w[m[x+1].handle].key,w[m[x].handle].key)&&++x,a(x<=this.max),b=m[x].handle,x>this.size||this.leq(w[v].key,w[b].key)){m[f].handle=v,w[v].node=f;break}m[f].handle=b,w[b].node=f,f=x}},floatUp_:function(f){var m=this.nodes,w=this.handles,v,b,x;for(v=m[f].handle;;){if(x=f>>1,b=m[x].handle,x===0||this.leq(w[b].key,w[v].key)){m[f].handle=v,w[v].node=f;break}m[f].handle=b,w[b].node=f,f=x}},init:function(){for(var f=this.size;f>=1;--f)this.floatDown_(f);this.initialized=!0},min:function(){return this.handles[this.nodes[1].handle].key},insert:function(f){var m,w;if(m=++this.size,m*2>this.max){this.max*=2;var v,b;for(b=this.nodes.length,this.nodes.length=this.max+1,v=b;v<this.nodes.length;v++)this.nodes[v]=new p;for(b=this.handles.length,this.handles.length=this.max+1,v=b;v<this.handles.length;v++)this.handles[v]=new M}return this.freeList===0?w=m:(w=this.freeList,this.freeList=this.handles[w].node),this.nodes[m].handle=w,this.handles[w].node=m,this.handles[w].key=f,this.initialized&&this.floatUp_(m),w},extractMin:function(){var f=this.nodes,m=this.handles,w=f[1].handle,v=m[w].key;return this.size>0&&(f[1].handle=f[this.size].handle,m[f[1].handle].node=1,m[w].key=null,m[w].node=this.freeList,this.freeList=w,--this.size,this.size>0&&this.floatDown_(1)),v},delete:function(f){var m=this.nodes,w=this.handles,v;a(f>=1&&f<=this.max&&w[f].key!==null),v=w[f].node,m[v].handle=m[this.size].handle,w[m[v].handle].node=v,--this.size,v<=this.size&&(v<=1||this.leq(w[m[v>>1].handle].key,w[m[v].handle].key)?this.floatDown_(v):this.floatUp_(v)),w[f].key=null,w[f].node=this.freeList,this.freeList=f}};function D(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}var C={};C.regionBelow=function(T){return T.nodeUp.prev.key},C.regionAbove=function(T){return T.nodeUp.next.key},C.debugEvent=function(T){},C.addWinding=function(T,f){T.winding+=f.winding,T.Sym.winding+=f.Sym.winding},C.edgeLeq=function(T,f,m){var w=T.event,x,z,v=f.eUp,b=m.eUp;if(v.Dst===w)return b.Dst===w?o.vertLeq(v.Org,b.Org)?o.edgeSign(b.Dst,v.Org,b.Org)<=0:o.edgeSign(v.Dst,b.Org,v.Org)>=0:o.edgeSign(b.Dst,w,b.Org)<=0;if(b.Dst===w)return o.edgeSign(v.Dst,w,v.Org)>=0;var x=o.edgeEval(v.Dst,w,v.Org),z=o.edgeEval(b.Dst,w,b.Org);return x>=z},C.deleteRegion=function(T,f){f.fixUpperEdge&&a(f.eUp.winding===0),f.eUp.activeRegion=null,T.dict.delete(f.nodeUp)},C.fixUpperEdge=function(T,f,m){a(f.fixUpperEdge),T.mesh.delete(f.eUp),f.fixUpperEdge=!1,f.eUp=m,m.activeRegion=f},C.topLeftRegion=function(T,f){var m=f.eUp.Org,w;do f=C.regionAbove(f);while(f.eUp.Org===m);if(f.fixUpperEdge){if(w=T.mesh.connect(C.regionBelow(f).eUp.Sym,f.eUp.Lnext),w===null)return null;C.fixUpperEdge(T,f,w),f=C.regionAbove(f)}return f},C.topRightRegion=function(T){var f=T.eUp.Dst;do T=C.regionAbove(T);while(T.eUp.Dst===f);return T},C.addRegionBelow=function(T,f,m){var w=new D;return w.eUp=m,w.nodeUp=T.dict.insertBefore(f.nodeUp,w),w.fixUpperEdge=!1,w.sentinel=!1,w.dirty=!1,m.activeRegion=w,w},C.isWindingInside=function(T,f){switch(T.windingRule){case s.WINDING_ODD:return(f&1)!==0;case s.WINDING_NONZERO:return f!==0;case s.WINDING_POSITIVE:return f>0;case s.WINDING_NEGATIVE:return f<0;case s.WINDING_ABS_GEQ_TWO:return f>=2||f<=-2}return a(!1),!1},C.computeWinding=function(T,f){f.windingNumber=C.regionAbove(f).windingNumber+f.eUp.winding,f.inside=C.isWindingInside(T,f.windingNumber)},C.finishRegion=function(T,f){var m=f.eUp,w=m.Lface;w.inside=f.inside,w.anEdge=m,C.deleteRegion(T,f)},C.finishLeftRegions=function(T,f,m){for(var w,x,v=null,b=f,x=f.eUp;b!==m;){if(b.fixUpperEdge=!1,v=C.regionBelow(b),w=v.eUp,w.Org!=x.Org){if(!v.fixUpperEdge){C.finishRegion(T,b);break}w=T.mesh.connect(x.Lprev,w.Sym),C.fixUpperEdge(T,v,w)}x.Onext!==w&&(T.mesh.splice(w.Oprev,w),T.mesh.splice(x,w)),C.finishRegion(T,b),x=v.eUp,b=v}return x},C.addRightEdges=function(T,f,m,w,v,b){var x,z,E,O,V=!0;E=m;do a(o.vertLeq(E.Org,E.Dst)),C.addRegionBelow(T,f,E.Sym),E=E.Onext;while(E!==w);for(v===null&&(v=C.regionBelow(f).eUp.Rprev),z=f,O=v;x=C.regionBelow(z),E=x.eUp.Sym,E.Org===O.Org;)E.Onext!==O&&(T.mesh.splice(E.Oprev,E),T.mesh.splice(O.Oprev,E)),x.windingNumber=z.windingNumber-E.winding,x.inside=C.isWindingInside(T,x.windingNumber),z.dirty=!0,!V&&C.checkForRightSplice(T,z)&&(C.addWinding(E,O),C.deleteRegion(T,z),T.mesh.delete(O)),V=!1,z=x,O=E;z.dirty=!0,a(z.windingNumber-E.winding===x.windingNumber),b&&C.walkDirtyRegions(T,z)},C.spliceMergeVertices=function(T,f,m){T.mesh.splice(f,m)},C.vertexWeights=function(T,f,m){var w=o.vertL1dist(f,T),v=o.vertL1dist(m,T),b=.5*v/(w+v),x=.5*w/(w+v);T.coords[0]+=b*f.coords[0]+x*m.coords[0],T.coords[1]+=b*f.coords[1]+x*m.coords[1],T.coords[2]+=b*f.coords[2]+x*m.coords[2]},C.getIntersectData=function(T,f,m,w,v,b){f.coords[0]=f.coords[1]=f.coords[2]=0,f.idx=-1,C.vertexWeights(f,m,w),C.vertexWeights(f,v,b)},C.checkForRightSplice=function(T,f){var m=C.regionBelow(f),w=f.eUp,v=m.eUp;if(o.vertLeq(w.Org,v.Org)){if(o.edgeSign(v.Dst,w.Org,v.Org)>0)return!1;o.vertEq(w.Org,v.Org)?w.Org!==v.Org&&(T.pq.delete(w.Org.pqHandle),C.spliceMergeVertices(T,v.Oprev,w)):(T.mesh.splitEdge(v.Sym),T.mesh.splice(w,v.Oprev),f.dirty=m.dirty=!0)}else{if(o.edgeSign(w.Dst,v.Org,w.Org)<0)return!1;C.regionAbove(f).dirty=f.dirty=!0,T.mesh.splitEdge(w.Sym),T.mesh.splice(v.Oprev,w)}return!0},C.checkForLeftSplice=function(T,f){var m=C.regionBelow(f),w=f.eUp,v=m.eUp,b;if(a(!o.vertEq(w.Dst,v.Dst)),o.vertLeq(w.Dst,v.Dst)){if(o.edgeSign(w.Dst,v.Dst,w.Org)<0)return!1;C.regionAbove(f).dirty=f.dirty=!0,b=T.mesh.splitEdge(w),T.mesh.splice(v.Sym,b),b.Lface.inside=f.inside}else{if(o.edgeSign(v.Dst,w.Dst,v.Org)>0)return!1;f.dirty=m.dirty=!0,b=T.mesh.splitEdge(v),T.mesh.splice(w.Lnext,v.Sym),b.Rface.inside=f.inside}return!0},C.checkForIntersect=function(T,f){var m=C.regionBelow(f),w=f.eUp,v=m.eUp,b=w.Org,x=v.Org,z=w.Dst,E=v.Dst,O,V,N=new c,A,P;if(a(!o.vertEq(E,z)),a(o.edgeSign(z,T.event,b)<=0),a(o.edgeSign(E,T.event,x)>=0),a(b!==T.event&&x!==T.event),a(!f.fixUpperEdge&&!m.fixUpperEdge),b===x||(O=Math.min(b.t,z.t),V=Math.max(x.t,E.t),O>V))return!1;if(o.vertLeq(b,x)){if(o.edgeSign(E,b,x)>0)return!1}else if(o.edgeSign(z,x,b)<0)return!1;return C.debugEvent(T),o.intersect(z,b,E,x,N),a(Math.min(b.t,z.t)<=N.t),a(N.t<=Math.max(x.t,E.t)),a(Math.min(E.s,z.s)<=N.s),a(N.s<=Math.max(x.s,b.s)),o.vertLeq(N,T.event)&&(N.s=T.event.s,N.t=T.event.t),A=o.vertLeq(b,x)?b:x,o.vertLeq(A,N)&&(N.s=A.s,N.t=A.t),o.vertEq(N,b)||o.vertEq(N,x)?(C.checkForRightSplice(T,f),!1):!o.vertEq(z,T.event)&&o.edgeSign(z,T.event,N)>=0||!o.vertEq(E,T.event)&&o.edgeSign(E,T.event,N)<=0?E===T.event?(T.mesh.splitEdge(w.Sym),T.mesh.splice(v.Sym,w),f=C.topLeftRegion(T,f),w=C.regionBelow(f).eUp,C.finishLeftRegions(T,C.regionBelow(f),m),C.addRightEdges(T,f,w.Oprev,w,w,!0),!0):z===T.event?(T.mesh.splitEdge(v.Sym),T.mesh.splice(w.Lnext,v.Oprev),m=f,f=C.topRightRegion(f),P=C.regionBelow(f).eUp.Rprev,m.eUp=v.Oprev,v=C.finishLeftRegions(T,m,null),C.addRightEdges(T,f,v.Onext,w.Rprev,P,!0),!0):(o.edgeSign(z,T.event,N)>=0&&(C.regionAbove(f).dirty=f.dirty=!0,T.mesh.splitEdge(w.Sym),w.Org.s=T.event.s,w.Org.t=T.event.t),o.edgeSign(E,T.event,N)<=0&&(f.dirty=m.dirty=!0,T.mesh.splitEdge(v.Sym),v.Org.s=T.event.s,v.Org.t=T.event.t),!1):(T.mesh.splitEdge(w.Sym),T.mesh.splitEdge(v.Sym),T.mesh.splice(v.Oprev,w),w.Org.s=N.s,w.Org.t=N.t,w.Org.pqHandle=T.pq.insert(w.Org),C.getIntersectData(T,w.Org,b,z,x,E),C.regionAbove(f).dirty=f.dirty=m.dirty=!0,!1)},C.walkDirtyRegions=function(T,f){for(var m=C.regionBelow(f),w,v;;){for(;m.dirty;)f=m,m=C.regionBelow(m);if(!f.dirty&&(m=f,f=C.regionAbove(f),f===null||!f.dirty))return;if(f.dirty=!1,w=f.eUp,v=m.eUp,w.Dst!==v.Dst&&C.checkForLeftSplice(T,f)&&(m.fixUpperEdge?(C.deleteRegion(T,m),T.mesh.delete(v),m=C.regionBelow(f),v=m.eUp):f.fixUpperEdge&&(C.deleteRegion(T,f),T.mesh.delete(w),f=C.regionAbove(m),w=f.eUp)),w.Org!==v.Org)if(w.Dst!==v.Dst&&!f.fixUpperEdge&&!m.fixUpperEdge&&(w.Dst===T.event||v.Dst===T.event)){if(C.checkForIntersect(T,f))return}else C.checkForRightSplice(T,f);w.Org===v.Org&&w.Dst===v.Dst&&(C.addWinding(v,w),C.deleteRegion(T,f),T.mesh.delete(w),f=C.regionAbove(m))}},C.connectRightVertex=function(T,f,m){var w,v=m.Onext,b=C.regionBelow(f),x=f.eUp,z=b.eUp,E=!1;if(x.Dst!==z.Dst&&C.checkForIntersect(T,f),o.vertEq(x.Org,T.event)&&(T.mesh.splice(v.Oprev,x),f=C.topLeftRegion(T,f),v=C.regionBelow(f).eUp,C.finishLeftRegions(T,C.regionBelow(f),b),E=!0),o.vertEq(z.Org,T.event)&&(T.mesh.splice(m,z.Oprev),m=C.finishLeftRegions(T,b,null),E=!0),E){C.addRightEdges(T,f,m.Onext,v,v,!0);return}o.vertLeq(z.Org,x.Org)?w=z.Oprev:w=x,w=T.mesh.connect(m.Lprev,w),C.addRightEdges(T,f,w,w.Onext,w.Onext,!1),w.Sym.activeRegion.fixUpperEdge=!0,C.walkDirtyRegions(T,f)},C.connectLeftDegenerate=function(T,f,m){var w,v,b,x,z;if(w=f.eUp,o.vertEq(w.Org,m)){a(!1),C.spliceMergeVertices(T,w,m.anEdge);return}if(!o.vertEq(w.Dst,m)){T.mesh.splitEdge(w.Sym),f.fixUpperEdge&&(T.mesh.delete(w.Onext),f.fixUpperEdge=!1),T.mesh.splice(m.anEdge,w),C.sweepEvent(T,m);return}a(!1),f=C.topRightRegion(f),z=C.regionBelow(f),b=z.eUp.Sym,v=x=b.Onext,z.fixUpperEdge&&(a(v!==b),C.deleteRegion(T,z),T.mesh.delete(b),b=v.Oprev),T.mesh.splice(m.anEdge,b),o.edgeGoesLeft(v)||(v=null),C.addRightEdges(T,f,b.Onext,x,v,!0)},C.connectLeftVertex=function(T,f){var m,w,v,b,x,z,E=new D;if(E.eUp=f.anEdge.Sym,m=T.dict.search(E).key,w=C.regionBelow(m),!!w){if(b=m.eUp,x=w.eUp,o.edgeSign(b.Dst,f,b.Org)===0){C.connectLeftDegenerate(T,m,f);return}if(v=o.vertLeq(x.Dst,b.Dst)?m:w,m.inside||v.fixUpperEdge){if(v===m)z=T.mesh.connect(f.anEdge.Sym,b.Lnext);else{var O=T.mesh.connect(x.Dnext,f.anEdge);z=O.Sym}v.fixUpperEdge?C.fixUpperEdge(T,v,z):C.computeWinding(T,C.addRegionBelow(T,m,z)),C.sweepEvent(T,f)}else C.addRightEdges(T,m,f.anEdge,f.anEdge,null,!0)}},C.sweepEvent=function(T,f){T.event=f,C.debugEvent(T);for(var m=f.anEdge;m.activeRegion===null;)if(m=m.Onext,m===f.anEdge){C.connectLeftVertex(T,f);return}var w=C.topLeftRegion(T,m.activeRegion);a(w!==null);var v=C.regionBelow(w),b=v.eUp,x=C.finishLeftRegions(T,v,null);x.Onext===b?C.connectRightVertex(T,w,x):C.addRightEdges(T,w,x.Onext,b,b,!0)},C.addSentinel=function(T,f,m,w){var v=new D,b=T.mesh.makeEdge();b.Org.s=m,b.Org.t=w,b.Dst.s=f,b.Dst.t=w,T.event=b.Dst,v.eUp=b,v.windingNumber=0,v.inside=!1,v.fixUpperEdge=!1,v.sentinel=!0,v.dirty=!1,v.nodeUp=T.dict.insert(v)},C.initEdgeDict=function(T){T.dict=new g(T,C.edgeLeq);var f=T.bmax[0]-T.bmin[0],m=T.bmax[1]-T.bmin[1],w=T.bmin[0]-f,v=T.bmax[0]+f,b=T.bmin[1]-m,x=T.bmax[1]+m;C.addSentinel(T,w,v,b),C.addSentinel(T,w,v,x)},C.doneEdgeDict=function(T){for(var f,m=0;(f=T.dict.min().key)!==null;)f.sentinel||(a(f.fixUpperEdge),a(++m===1)),a(f.windingNumber===0),C.deleteRegion(T,f)},C.removeDegenerateEdges=function(T){var f,m,w,v=T.mesh.eHead;for(f=v.next;f!==v;f=m)m=f.next,w=f.Lnext,o.vertEq(f.Org,f.Dst)&&f.Lnext.Lnext!==f&&(C.spliceMergeVertices(T,w,f),T.mesh.delete(f),f=w,w=f.Lnext),w.Lnext===f&&(w!==f&&((w===m||w===m.Sym)&&(m=m.next),T.mesh.delete(w)),(f===m||f===m.Sym)&&(m=m.next),T.mesh.delete(f))},C.initPriorityQ=function(T){var f,m,w,v=0;for(w=T.mesh.vHead,m=w.next;m!==w;m=m.next)v++;for(v+=8,f=T.pq=new I(v,o.vertLeq),w=T.mesh.vHead,m=w.next;m!==w;m=m.next)m.pqHandle=f.insert(m);return m!==w?!1:(f.init(),!0)},C.donePriorityQ=function(T){T.pq=null},C.removeDegenerateFaces=function(T,f){var m,w,v;for(m=f.fHead.next;m!==f.fHead;m=w)w=m.next,v=m.anEdge,a(v.Lnext!==v),v.Lnext.Lnext===v&&(C.addWinding(v.Onext,v),T.mesh.delete(v));return!0},C.computeInterior=function(T){var f,m;if(C.removeDegenerateEdges(T),!C.initPriorityQ(T))return!1;for(C.initEdgeDict(T);(f=T.pq.extractMin())!==null;){for(;m=T.pq.min(),!(m===null||!o.vertEq(m,f));)m=T.pq.extractMin(),C.spliceMergeVertices(T,f.anEdge,m.anEdge);C.sweepEvent(T,f)}return T.event=T.dict.min().key.eUp.Org,C.debugEvent(T),C.doneEdgeDict(T),C.donePriorityQ(T),C.removeDegenerateFaces(T,T.mesh)?(T.mesh.check(),!0):!1};function B(){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}B.prototype={dot_:function(f,m){return f[0]*m[0]+f[1]*m[1]+f[2]*m[2]},normalize_:function(f){var m=f[0]*f[0]+f[1]*f[1]+f[2]*f[2];a(m>0),m=Math.sqrt(m),f[0]/=m,f[1]/=m,f[2]/=m},longAxis_:function(f){var m=0;return Math.abs(f[1])>Math.abs(f[0])&&(m=1),Math.abs(f[2])>Math.abs(f[m])&&(m=2),m},computeNormal_:function(f){var m,w,v,b,x,z,E=[0,0,0],O=[0,0,0],V=[0,0,0],N=[0,0,0],A=[0,0,0],P=[null,null,null],U=[null,null,null],Q=this.mesh.vHead,K;for(m=Q.next,K=0;K<3;++K)b=m.coords[K],O[K]=b,U[K]=m,E[K]=b,P[K]=m;for(m=Q.next;m!==Q;m=m.next)for(K=0;K<3;++K)b=m.coords[K],b<O[K]&&(O[K]=b,U[K]=m),b>E[K]&&(E[K]=b,P[K]=m);if(K=0,E[1]-O[1]>E[0]-O[0]&&(K=1),E[2]-O[2]>E[K]-O[K]&&(K=2),O[K]>=E[K]){f[0]=0,f[1]=0,f[2]=1;return}for(z=0,w=U[K],v=P[K],V[0]=w.coords[0]-v.coords[0],V[1]=w.coords[1]-v.coords[1],V[2]=w.coords[2]-v.coords[2],m=Q.next;m!==Q;m=m.next)N[0]=m.coords[0]-v.coords[0],N[1]=m.coords[1]-v.coords[1],N[2]=m.coords[2]-v.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],x=A[0]*A[0]+A[1]*A[1]+A[2]*A[2],x>z&&(z=x,f[0]=A[0],f[1]=A[1],f[2]=A[2]);z<=0&&(f[0]=f[1]=f[2]=0,f[this.longAxis_(V)]=1)},checkOrientation_:function(){var f,m,w=this.mesh.fHead,v,b=this.mesh.vHead,x;for(f=0,m=w.next;m!==w;m=m.next)if(x=m.anEdge,!(x.winding<=0))do f+=(x.Org.s-x.Dst.s)*(x.Org.t+x.Dst.t),x=x.Lnext;while(x!==m.anEdge);if(f<0){for(v=b.next;v!==b;v=v.next)v.t=-v.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},projectPolygon_:function(){var f,m=this.mesh.vHead,w=[0,0,0],v,b,x,z,E=!1;for(w[0]=this.normal[0],w[1]=this.normal[1],w[2]=this.normal[2],w[0]===0&&w[1]===0&&w[2]===0&&(this.computeNormal_(w),E=!0),v=this.sUnit,b=this.tUnit,x=this.longAxis_(w),v[x]=0,v[(x+1)%3]=1,v[(x+2)%3]=0,b[x]=0,b[(x+1)%3]=0,b[(x+2)%3]=w[x]>0?1:-1,f=m.next;f!==m;f=f.next)f.s=this.dot_(f.coords,v),f.t=this.dot_(f.coords,b);for(E&&this.checkOrientation_(),z=!0,f=m.next;f!==m;f=f.next)z?(this.bmin[0]=this.bmax[0]=f.s,this.bmin[1]=this.bmax[1]=f.t,z=!1):(f.s<this.bmin[0]&&(this.bmin[0]=f.s),f.s>this.bmax[0]&&(this.bmax[0]=f.s),f.t<this.bmin[1]&&(this.bmin[1]=f.t),f.t>this.bmax[1]&&(this.bmax[1]=f.t))},addWinding_:function(f,m){f.winding+=m.winding,f.Sym.winding+=m.Sym.winding},tessellateMonoRegion_:function(f,m){var w,v;for(w=m.anEdge,a(w.Lnext!==w&&w.Lnext.Lnext!==w);o.vertLeq(w.Dst,w.Org);w=w.Lprev);for(;o.vertLeq(w.Org,w.Dst);w=w.Lnext);for(v=w.Lprev;w.Lnext!==v;)if(o.vertLeq(w.Dst,v.Org)){for(;v.Lnext!==w&&(o.edgeGoesLeft(v.Lnext)||o.edgeSign(v.Org,v.Dst,v.Lnext.Dst)<=0);){var b=f.connect(v.Lnext,v);v=b.Sym}v=v.Lprev}else{for(;v.Lnext!==w&&(o.edgeGoesRight(w.Lprev)||o.edgeSign(w.Dst,w.Org,w.Lprev.Org)>=0);){var b=f.connect(w,w.Lprev);w=b.Sym}w=w.Lnext}for(a(v.Lnext!==w);v.Lnext.Lnext!==w;){var b=f.connect(v.Lnext,v);v=b.Sym}return!0},tessellateInterior_:function(f){var m,w;for(m=f.fHead.next;m!==f.fHead;m=w)if(w=m.next,m.inside&&!this.tessellateMonoRegion_(f,m))return!1;return!0},discardExterior_:function(f){var m,w;for(m=f.fHead.next;m!==f.fHead;m=w)w=m.next,m.inside||f.zapFace(m)},setWindingNumber_:function(f,m,w){var v,b;for(v=f.eHead.next;v!==f.eHead;v=b)b=v.next,v.Rface.inside!==v.Lface.inside?v.winding=v.Lface.inside?m:-m:w?f.delete(v):v.winding=0},getNeighbourFace_:function(f){return!f.Rface||!f.Rface.inside?-1:f.Rface.n},outputPolymesh_:function(f,m,w,v){var b,x,z,E=0,O=0,V,N;for(w>3&&f.mergeConvexFaces(w),b=f.vHead.next;b!==f.vHead;b=b.next)b.n=-1;for(x=f.fHead.next;x!==f.fHead;x=x.next)if(x.n=-1,!!x.inside){z=x.anEdge,V=0;do b=z.Org,b.n===-1&&(b.n=O,O++),V++,z=z.Lnext;while(z!==x.anEdge);a(V<=w),x.n=E,++E}for(this.elementCount=E,m===s.CONNECTED_POLYGONS&&(E*=2),this.elements=[],this.elements.length=E*w,this.vertexCount=O,this.vertices=[],this.vertices.length=O*v,this.vertexIndices=[],this.vertexIndices.length=O,b=f.vHead.next;b!==f.vHead;b=b.next)if(b.n!==-1){var A=b.n*v;this.vertices[A+0]=b.coords[0],this.vertices[A+1]=b.coords[1],v>2&&(this.vertices[A+2]=b.coords[2]),this.vertexIndices[b.n]=b.idx}var P=0;for(x=f.fHead.next;x!==f.fHead;x=x.next)if(x.inside){z=x.anEdge,V=0;do b=z.Org,this.elements[P++]=b.n,V++,z=z.Lnext;while(z!==x.anEdge);for(N=V;N<w;++N)this.elements[P++]=-1;if(m===s.CONNECTED_POLYGONS){z=x.anEdge;do this.elements[P++]=this.getNeighbourFace_(z),z=z.Lnext;while(z!==x.anEdge);for(N=V;N<w;++N)this.elements[P++]=-1}}},outputContours_:function(f,m){var w,v,b,x=0,z=0;for(this.vertexCount=0,this.elementCount=0,w=f.fHead.next;w!==f.fHead;w=w.next)if(w.inside){b=v=w.anEdge;do this.vertexCount++,v=v.Lnext;while(v!==b);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*m,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var E=0,O=0,V=0;for(x=0,w=f.fHead.next;w!==f.fHead;w=w.next)if(w.inside){z=0,b=v=w.anEdge;do this.vertices[E++]=v.Org.coords[0],this.vertices[E++]=v.Org.coords[1],m>2&&(this.vertices[E++]=v.Org.coords[2]),this.vertexIndices[O++]=v.Org.idx,z++,v=v.Lnext;while(v!==b);this.elements[V++]=x,this.elements[V++]=z,x+=z}},addContour:function(f,m){var w,v;for(this.mesh===null&&(this.mesh=new h),f<2&&(f=2),f>3&&(f=3),w=null,v=0;v<m.length;v+=f)w===null?(w=this.mesh.makeEdge(),this.mesh.splice(w,w.Sym)):(this.mesh.splitEdge(w),w=w.Lnext),w.Org.coords[0]=m[v+0],w.Org.coords[1]=m[v+1],f>2?w.Org.coords[2]=m[v+2]:w.Org.coords[2]=0,w.Org.idx=this.vertexIndexCounter++,w.winding=1,w.Sym.winding=-1},tesselate:function(f,m,w,v,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=f,v<2&&(v=2),v>3&&(v=3),!this.mesh)return!1;this.projectPolygon_(),C.computeInterior(this);var x=this.mesh;return m===s.BOUNDARY_CONTOURS?this.setWindingNumber_(x,1,!0):this.tessellateInterior_(x),x.check(),m===s.BOUNDARY_CONTOURS?this.outputContours_(x,v):this.outputPolymesh_(x,m,w,v),!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 M}),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 C=0;C<16;C++){var B=[],T=!!(C&1),f=!!(C&2),m=!!(C&4),w=!!(C&8);T&&B.push("#define TEXTURE 1"),f&&B.push("#define FILTER 1"),m&&B.push("#define GRADIENT 1"),w&&B.push("#define CLIPPATH 1");var v="".concat(B.join(`
|
|
42
|
-
`),`
|
|
43
|
-
`),b=[];T&&b.push("uniform sampler2D u_texSampler;"),w&&b.push("uniform sampler2D u_clipSampler;"),D[h][C]=[v+b.join(`
|
|
44
|
-
`)+c.default,v+a.default]}}function g(D){var C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},B=C.hasTexture,T=B===void 0?!1:B,f=C.hasFilter,m=f===void 0?!1:f,w=C.hasGradient,v=w===void 0?!1:w,b=C.hasClipPath,x=b===void 0?!1:b,z=T|m<<1|v<<2|x<<3,E=D[h][z];Array.isArray(E)&&(E=D.createProgram.apply(D,o()(E)),D[h][z]=E),D.program!==E&&D.useProgram(E,{a_color:{type:"UNSIGNED_BYTE",normalize:!0}})}var p=[];function M(D){for(var C=0;C<64;C++){var B=[],T=!!(C&1),f=!!(C&2),m=!!(C&4),w=!!(C&8),v=!!(C&16),b=!!(C&32);T&&B.push("#define TEXTURE 1"),f&&B.push("#define FILTER 1"),m&&B.push("#define GRADIENT 1"),w&&B.push("#define CLOUDCOLOR 1"),v&&B.push("#define CLOUDFILTER 1"),b&&B.push("#define CLIPPATH 1");var x="".concat(B.join(`
|
|
45
|
-
`),`
|
|
46
|
-
`),z=[];if(T){z.push("uniform sampler2D u_texSampler;");for(var E=0;E<12;E++)z.push("uniform sampler2D u_texFrame".concat(E,";"))}b&&z.push("uniform sampler2D u_clipSampler;"),p[C]=[x+z.join(`
|
|
47
|
-
`)+u.default,x+l.default]}}function I(D){var C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},B=C.hasTexture,T=B===void 0?!1:B,f=C.hasFilter,m=f===void 0?!1:f,w=C.hasGradient,v=w===void 0?!1:w,b=C.hasCloudColor,x=b===void 0?!1:b,z=C.hasCloudFilter,E=z===void 0?!1:z,O=C.hasClipPath,V=O===void 0?!1:O,N=T|m<<1|v<<2|x<<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
|
-
}`}])})})(np);var ht=np.exports;qe(Array);function Tu(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=Tu(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=Tu(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 Tl(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 fc=Symbol.for("spritejs_setAttributeDefault"),gc=Symbol.for("spritejs_declareAlias"),Ct=Symbol.for("spritejs_setAttribute"),ft=Symbol.for("spritejs_getAttribute"),Qh=Symbol.for("spritejs_attributes"),Zh=Symbol.for("spritejs_changedAttrs"),Fo=Symbol("subject"),Ur=Symbol("attr"),pc=Symbol("default"),_s=Symbol("alias");function hv(i,[t,e]){let r=Hn(1,0,0,1,0,0);return[...i].forEach(([n,s])=>{if((t||e)&&(r=wl(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=ep(Array.of(0,0,0,0,0,0),r,s);else if(n==="skew"){const[o,a]=s;r=Er(r,r,Hn(1,Math.tan(a),Math.tan(o),1,0,0))}else rp[n](r,r,s);(t||e)&&(r=wl(Array.of(0,0,0,0,0,0),r,[-t,-e]))}),r}const un=Symbol("transformMatrix"),ws=Symbol("transforms"),Zi=Symbol("changedAttrs"),ip=Symbol("lastChangedAttr"),Wo=Symbol("offsetFigure");function eo(i,t,e){const r=i[Ur][t];if(i[Ct](t,e,!1)||i[ip]!==t){const s=i[ws];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[un]=null,i[Fo].onPropertyChange(t,e,r,i)}}function mc(i){const t=i[Wo],e=i.offsetDistance*t.getTotalLength(),r=t.getPointAtLength(e);if(r){const n=i[ws];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[un]=null}}let Su=class{static setDefault(t,...e){return t[fc](...e)}static declareAlias(t,...e){return t[gc](...e)}static setAttribute(t,...e){return t[Ct](...e)}static getAttribute(t,...e){return t[ft](...e)}static getAttributes(t){return t[Qh]}static getChangedAttributes(t){return t[Zh]}constructor(t){this[Fo]=t,this[Ur]={},this[un]=Hn(1,0,0,1,0,0),this[ws]=new Map,this[pc]={},this[_s]=[],Object.defineProperty(t,"transformMatrix",{get:()=>(this[un]||(this[un]=hv(this[ws],this.transformOrigin)),[...this[un]])}),this[fc]({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[gc]("class","pos"),this[Zi]=new Set,this[Wo]=new ht.Figure2D({scale:5,simplify:0})}get[Zh](){const t={};return[...this[Zi]].forEach(e=>{t[e]=this[Ur][e]}),t}get[Qh](){const t=Object.assign({},this[Ur]);for(let e=0;e<this[_s].length;e++){const r=this[_s][e];t[r]=this[r]}return t}[fc](t){Object.assign(this[pc],t),Object.assign(this[Ur],t)}[gc](...t){this[_s].push(...t)}[Ct](t,e,r=!0){const n=this[Ur][t],s=this[Fo];return e==null&&(e=this[pc][t]),Tl(n,e)?!1:(this[Ur][t]=e,this[Zi].has(t)&&this[Zi].delete(t),this[Zi].add(t),this[ip]=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[ws];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=Hn(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,Hn(1,Math.tan(h[1]),Math.tan(h[0]),1,0,0)):rp[u](o,o,h),n.set("matrix",o)}}}else throw new TypeError("Invalid transform value.")}this[un]=null,this[Fo].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[un]=null)}get rotate(){return this[ft]("rotate")}set rotate(t){eo(this,"rotate",t)}get translate(){return this[ft]("translate")}set translate(t){t=mt(t,!0),t!=null&&!Array.isArray(t)&&(t=[t,t]),eo(this,"translate",t)}get scale(){return this[ft]("scale")}set scale(t){t=mt(t,!0),t!=null&&!Array.isArray(t)&&(t=[t,t]),eo(this,"scale",t)}get skew(){return this[ft]("skew")}set skew(t){t=mt(t,!0),t!=null&&!Array.isArray(t)&&(t=[t,t]),eo(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[Wo].beginPath(),t!=null&&this[Wo].addPath(t),mc(this))}get offsetDistance(){return this[ft]("offsetDistance")}set offsetDistance(t){this[Ct]("offsetDistance",Qe(t))&&mc(this)}get offsetRotate(){return this[ft]("offsetRotate")}set offsetRotate(t){this[Ct]("offsetRotate",t),mc(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={},Ta={},Os={},sp=function(i,t){return{value:t,done:!!i}},ji={},dv={}.toString,zs=function(i){return dv.call(i).slice(8,-1)},fv=zs,Iu=Object("z").propertyIsEnumerable(0)?Object:function(i){return fv(i)=="String"?i.split(""):Object(i)},Cu=function(i){if(i==null)throw TypeError("Can't call method on "+i);return i},gv=Iu,pv=Cu,Jn=function(i){return gv(pv(i))},mv=!0,op={exports:{}},yv=op.exports=typeof window<"u"&&window.Math==Math?window:typeof self<"u"&&self.Math==Math?self:Function("return this")();typeof __g=="number"&&(__g=yv);var Kt=op.exports,ap={exports:{}},vv=ap.exports={version:"2.6.12"};typeof __e=="number"&&(__e=vv);var At=ap.exports,js=function(i){if(typeof i!="function")throw TypeError(i+" is not a function!");return i},Mv=js,Cn=function(i,t,e){if(Mv(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"},wv=Ar,_r=function(i){if(!wv(i))throw TypeError(i+" is not an object!");return i},_n=function(i){try{return!!i()}catch{return!0}},ur=!_n(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7}),Kh=Ar,Sl=Kt.document,Tv=Kh(Sl)&&Kh(Sl.createElement),xu=function(i){return Tv?Sl.createElement(i):{}},cp=!ur&&!_n(function(){return Object.defineProperty(xu("div"),"a",{get:function(){return 7}}).a!=7}),to=Ar,bu=function(i,t){if(!to(i))return i;var e,r;if(t&&typeof(e=i.toString)=="function"&&!to(r=e.call(i))||typeof(e=i.valueOf)=="function"&&!to(r=e.call(i))||!t&&typeof(e=i.toString)=="function"&&!to(r=e.call(i)))return r;throw TypeError("Can't convert object to primitive value")},qh=_r,Sv=cp,Iv=bu,Cv=Object.defineProperty;lr.f=ur?Object.defineProperty:function(t,e,r){if(qh(t),e=Iv(e,!0),qh(r),Sv)try{return Cv(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 Bs=function(i,t){return{enumerable:!(i&1),configurable:!(i&2),writable:!(i&4),value:t}},xv=lr,bv=Bs,xn=ur?function(i,t,e){return xv.f(i,t,bv(1,e))}:function(i,t,e){return i[t]=e,i},Ev={}.hasOwnProperty,ei=function(i,t){return Ev.call(i,t)},ro=Kt,yc=At,Xh=Cn,Av=xn,Nv=ei,no="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?yc:yc[t]||(yc[t]={}),u=l[no],h=n?ro:s?ro[t]:(ro[t]||{})[no],d,g,p;n&&(e=t);for(d in e)g=!r&&h&&h[d]!==void 0,!(g&&Nv(l,d))&&(p=g?h[d]:e[d],l[d]=n&&typeof h[d]!="function"?e[d]:a&&g?Xh(p,ro):c&&h[d]==p?function(M){var I=function(D,C,B){if(this instanceof M){switch(arguments.length){case 0:return new M;case 1:return new M(D);case 2:return new M(D,C)}return new M(D,C,B)}return M.apply(this,arguments)};return I[no]=M[no],I}(p):o&&typeof p=="function"?Xh(Function.call,p):p,o&&((l.virtual||(l.virtual={}))[d]=p,i&jt.R&&u&&!u[d]&&Av(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,lp=xn,Dv=Math.ceil,Pv=Math.floor,Eu=function(i){return isNaN(i=+i)?0:(i>0?Pv:Dv)(i)},kv=Eu,Lv=Math.min,Sa=function(i){return i>0?Lv(kv(i),9007199254740991):0},Rv=Eu,Ov=Math.max,zv=Math.min,jv=function(i,t){return i=Rv(i),i<0?Ov(i+t,0):zv(i,t)},Bv=Jn,Uv=Sa,Fv=jv,Wv=function(i){return function(t,e,r){var n=Bv(t),s=Uv(n.length),o=Fv(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}},up={exports:{}},$v=At,Jh=Kt,_h="__core-js_shared__",ed=Jh[_h]||(Jh[_h]={});(up.exports=function(i,t){return ed[i]||(ed[i]=t!==void 0?t:{})})("versions",[]).push({version:$v.version,mode:"pure",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"});var Au=up.exports,Vv=0,Yv=Math.random(),Ia=function(i){return"Symbol(".concat(i===void 0?"":i,")_",(++Vv+Yv).toString(36))},td=Au("keys"),Gv=Ia,Nu=function(i){return td[i]||(td[i]=Gv(i))},rd=ei,Hv=Jn,Qv=Wv(!1),Zv=Nu("IE_PROTO"),hp=function(i,t){var e=Hv(i),r=0,n=[],s;for(s in e)s!=Zv&&rd(e,s)&&n.push(s);for(;t.length>r;)rd(e,s=t[r++])&&(~Qv(n,s)||n.push(s));return n},Du="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","),Kv=hp,qv=Du,Bi=Object.keys||function(t){return Kv(t,qv)},Xv=lr,Jv=_r,_v=Bi,eM=ur?Object.defineProperties:function(t,e){Jv(t);for(var r=_v(e),n=r.length,s=0,o;n>s;)Xv.f(t,o=r[s++],e[o]);return t},nd=Kt.document,dp=nd&&nd.documentElement,tM=_r,rM=eM,id=Du,nM=Nu("IE_PROTO"),vc=function(){},Il="prototype",$o=function(){var i=xu("iframe"),t=id.length,e="<",r=">",n;for(i.style.display="none",dp.appendChild(i),i.src="javascript:",n=i.contentWindow.document,n.open(),n.write(e+"script"+r+"document.F=Object"+e+"/script"+r),n.close(),$o=n.F;t--;)delete $o[Il][id[t]];return $o()},Pu=Object.create||function(t,e){var r;return t!==null?(vc[Il]=tM(t),r=new vc,vc[Il]=null,r[nM]=t):r=$o(),e===void 0?r:rM(r,e)},fp={exports:{}},Cl=Au("wks"),iM=Ia,xl=Kt.Symbol,sd=typeof xl=="function",sM=fp.exports=function(i){return Cl[i]||(Cl[i]=sd&&xl[i]||(sd?xl:iM)("Symbol."+i))};sM.store=Cl;var Wt=fp.exports,oM=lr.f,aM=ei,od=Wt("toStringTag"),Us=function(i,t,e){i&&!aM(i=e?i:i.prototype,od)&&oM(i,od,{configurable:!0,value:t})},cM=Pu,lM=Bs,uM=Us,gp={};xn(gp,Wt("iterator"),function(){return this});var hM=function(i,t,e){i.prototype=cM(gp,{next:lM(1,e)}),uM(i,t+" Iterator")},dM=Cu,Ui=function(i){return Object(dM(i))},fM=ei,gM=Ui,ad=Nu("IE_PROTO"),pM=Object.prototype,mM=Object.getPrototypeOf||function(i){return i=gM(i),fM(i,ad)?i[ad]:typeof i.constructor=="function"&&i instanceof i.constructor?i.constructor.prototype:i instanceof Object?pM:null},Mc=qt,yM=lp,vM=xn,cd=ji,MM=hM,wM=Us,TM=mM,wc=Wt("iterator"),Tc=!([].keys&&"next"in[].keys()),SM="@@iterator",ld="keys",io="values",IM=function(){return this},ku=function(i,t,e,r,n,s,o){MM(e,t,r);var a=function(B){if(!Tc&&B in h)return h[B];switch(B){case ld:return function(){return new e(this,B)};case io:return function(){return new e(this,B)}}return function(){return new e(this,B)}},c=t+" Iterator",l=n==io,u=!1,h=i.prototype,d=h[wc]||h[SM]||n&&h[n],g=d||a(n),p=n?l?a("entries"):g:void 0,M=t=="Array"&&h.entries||d,I,D,C;if(M&&(C=TM(M.call(new i)),C!==Object.prototype&&C.next&&wM(C,c,!0)),l&&d&&d.name!==io&&(u=!0,g=function(){return d.call(this)}),o&&(Tc||u||!h[wc])&&vM(h,wc,g),cd[t]=g,cd[c]=IM,n)if(I={values:l?g:a(io),keys:s?g:a(ld),entries:p},o)for(D in I)D in h||yM(h,D,I[D]);else Mc(Mc.P+Mc.F*(Tc||u),t,I);return I},so=sp,ud=ji,CM=Jn;ku(Array,"Array",function(i,t){this._t=CM(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,so(1)):t=="keys"?so(0,e):t=="values"?so(0,i[e]):so(0,[e,i[e]])},"values");ud.Arguments=ud.Array;var xM=Kt,bM=xn,hd=ji,dd=Wt("toStringTag"),fd="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 Sc=0;Sc<fd.length;Sc++){var Ic=fd[Sc],gd=xM[Ic],Cc=gd&&gd.prototype;Cc&&!Cc[dd]&&bM(Cc,dd,Ic),hd[Ic]=hd.Array}var EM=Eu,AM=Cu,NM=function(i){return function(t,e){var r=String(AM(t)),n=EM(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)}},DM=NM(!0);ku(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=DM(i,t),this._i+=e.length,{value:e,done:!1})});var bl=zs,PM=Wt("toStringTag"),kM=bl(function(){return arguments}())=="Arguments",LM=function(i,t){try{return i[t]}catch{}},Ca=function(i){var t,e,r;return i===void 0?"Undefined":i===null?"Null":typeof(e=LM(t=Object(i),PM))=="string"?e:kM?bl(t):(r=bl(t))=="Object"&&typeof t.callee=="function"?"Arguments":r},RM=Ca,OM=Wt("iterator"),zM=ji,jM=At.isIterable=function(i){var t=Object(i);return t[OM]!==void 0||"@@iterator"in t||zM.hasOwnProperty(RM(t))},BM=jM,UM={default:BM,__esModule:!0},FM=Ca,WM=Wt("iterator"),$M=ji,Lu=At.getIteratorMethod=function(i){if(i!=null)return i[WM]||i["@@iterator"]||$M[FM(i)]},VM=_r,YM=Lu,GM=At.getIterator=function(i){var t=YM(i);if(typeof t!="function")throw TypeError(i+" is not iterable!");return VM(t.call(i))},HM=GM,QM={default:HM,__esModule:!0};Os.__esModule=!0;var ZM=UM,KM=pp(ZM),qM=QM,XM=pp(qM);function pp(i){return i&&i.__esModule?i:{default:i}}Os.default=function(){function i(t,e){var r=[],n=!0,s=!1,o=void 0;try{for(var a=(0,XM.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,KM.default)(Object(t)))return i(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();var xa={},pd=_r,mp=function(i,t,e,r){try{return r?t(pd(e)[0],e[1]):t(e)}catch(s){var n=i.return;throw n!==void 0&&pd(n.call(i)),s}},JM=ji,_M=Wt("iterator"),e1=Array.prototype,yp=function(i){return i!==void 0&&(JM.Array===i||e1[_M]===i)},t1=lr,r1=Bs,n1=function(i,t,e){t in i?t1.f(i,t,r1(0,e)):i[t]=e},xc,md;function vp(){if(md)return xc;md=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 xc=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},xc}var i1=Cn,bc=qt,s1=Ui,o1=mp,a1=yp,c1=Sa,yd=n1,l1=Lu;bc(bc.S+bc.F*!vp()(function(i){Array.from(i)}),"Array",{from:function(t){var e=s1(t),r=typeof this=="function"?this:Array,n=arguments.length,s=n>1?arguments[1]:void 0,o=s!==void 0,a=0,c=l1(e),l,u,h,d;if(o&&(s=i1(s,n>2?arguments[2]:void 0,2)),c!=null&&!(r==Array&&a1(c)))for(d=c.call(e),u=new r;!(h=d.next()).done;a++)yd(u,a,o?o1(d,s,[h.value,a],!0):h.value);else for(l=c1(e.length),u=new r(l);l>a;a++)yd(u,a,o?s(e[a],a):e[a]);return u.length=a,u}});var u1=At.Array.from,h1={default:u1,__esModule:!0};xa.__esModule=!0;var d1=h1,f1=g1(d1);function g1(i){return i&&i.__esModule?i:{default:i}}xa.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,f1.default)(i)};var p1=xn,Ru=function(i,t,e){for(var r in t)e&&i[r]?i[r]=t[r]:p1(i,r,t[r]);return i},Ou=function(i,t,e,r){if(!(i instanceof t)||r!==void 0&&r in i)throw TypeError(e+": incorrect invocation!");return i},Mp={exports:{}},m1=Cn,y1=mp,v1=yp,M1=_r,w1=Sa,T1=Lu,El={},Al={},wp=Mp.exports=function(i,t,e,r,n){var s=n?function(){return i}:T1(i),o=m1(e,r,t?2:1),a=0,c,l,u,h;if(typeof s!="function")throw TypeError(i+" is not iterable!");if(v1(s)){for(c=w1(i.length);c>a;a++)if(h=t?o(M1(l=i[a])[0],l[1]):o(i[a]),h===El||h===Al)return h}else for(u=s.call(i);!(l=u.next()).done;)if(h=y1(u,o,l.value,t),h===El||h===Al)return h};wp.BREAK=El;wp.RETURN=Al;var Fs=Mp.exports,S1=Kt,vd=At,I1=lr,C1=ur,Md=Wt("species"),Tp=function(i){var t=typeof vd[i]=="function"?vd[i]:S1[i];C1&&t&&!t[Md]&&I1.f(t,Md,{configurable:!0,get:function(){return this}})},Sp={exports:{}},qn=Ia("meta"),x1=Ar,zu=ei,b1=lr.f,E1=0,ba=Object.isExtensible||function(){return!0},A1=!_n(function(){return ba(Object.preventExtensions({}))}),ju=function(i){b1(i,qn,{value:{i:"O"+ ++E1,w:{}}})},N1=function(i,t){if(!x1(i))return typeof i=="symbol"?i:(typeof i=="string"?"S":"P")+i;if(!zu(i,qn)){if(!ba(i))return"F";if(!t)return"E";ju(i)}return i[qn].i},D1=function(i,t){if(!zu(i,qn)){if(!ba(i))return!0;if(!t)return!1;ju(i)}return i[qn].w},P1=function(i){return A1&&k1.NEED&&ba(i)&&!zu(i,qn)&&ju(i),i},k1=Sp.exports={KEY:qn,NEED:!1,fastKey:N1,getWeak:D1,onFreeze:P1},Bu=Sp.exports,L1=Ar,Ip=function(i,t){if(!L1(i)||i._t!==t)throw TypeError("Incompatible receiver, "+t+" required!");return i},R1=lr.f,O1=Pu,z1=Ru,j1=Cn,B1=Ou,U1=Fs,F1=ku,oo=sp,W1=Tp,Cp=ur,xp=Bu.fastKey,fi=Ip,Ki=Cp?"_s":"size",ao=function(i,t){var e=xp(t),r;if(e!=="F")return i._i[e];for(r=i._f;r;r=r.n)if(r.k==t)return r},$1={getConstructor:function(i,t,e,r){var n=i(function(s,o){B1(s,n,t,"_i"),s._t=t,s._i=O1(null),s._f=void 0,s._l=void 0,s[Ki]=0,o!=null&&U1(o,e,s[r],s)});return z1(n.prototype,{clear:function(){for(var o=fi(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[Ki]=0},delete:function(s){var o=fi(this,t),a=ao(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[Ki]--}return!!a},forEach:function(o){fi(this,t);for(var a=j1(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!!ao(fi(this,t),o)}}),Cp&&R1(n.prototype,"size",{get:function(){return fi(this,t)[Ki]}}),n},def:function(i,t,e){var r=ao(i,t),n,s;return r?r.v=e:(i._l=r={i:s=xp(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[Ki]++,s!=="F"&&(i._i[s]=r)),i},getEntry:ao,setStrong:function(i,t,e){F1(i,t,function(r,n){this._t=fi(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,oo(1)):n=="keys"?oo(0,s.k):n=="values"?oo(0,s.v):oo(0,[s.k,s.v])},e?"entries":"values",!e,!0),W1(t)}},V1=zs,bp=Array.isArray||function(t){return V1(t)=="Array"},Y1=Ar,wd=bp,G1=Wt("species"),H1=function(i){var t;return wd(i)&&(t=i.constructor,typeof t=="function"&&(t===Array||wd(t.prototype))&&(t=void 0),Y1(t)&&(t=t[G1],t===null&&(t=void 0))),t===void 0?Array:t},Q1=H1,Z1=function(i,t){return new(Q1(i))(t)},K1=Cn,q1=Iu,X1=Ui,J1=Sa,_1=Z1,ew=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||_1;return function(l,u,h){for(var d=X1(l),g=q1(d),p=K1(u,h,3),M=J1(g.length),I=0,D=e?c(l,M):r?c(l,0):void 0,C,B;M>I;I++)if((a||I in g)&&(C=g[I],B=p(C,I,d),i)){if(e)D[I]=B;else if(B)switch(i){case 3:return!0;case 5:return C;case 6:return I;case 2:D.push(C)}else if(s)return!1}return o?-1:n||s?s:D}},tw=Kt,co=qt,rw=Bu,nw=_n,iw=xn,sw=Ru,ow=Fs,Td=Ou,aw=Ar,cw=Us,lw=lr.f,uw=ew(0),hw=ur,dw=function(i,t,e,r,n,s){var o=tw[i],a=o,c=n?"set":"add",l=a&&a.prototype,u={};return!hw||typeof a!="function"||!(s||l.forEach&&!nw(function(){new a().entries().next()}))?(a=r.getConstructor(t,i,n,c),sw(a.prototype,e),rw.NEED=!0):(a=t(function(h,d){Td(h,a,i,"_c"),h._c=new o,d!=null&&ow(d,n,h[c],h)}),uw("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")&&iw(a.prototype,h,function(g,p){if(Td(this,a,h),!d&&s&&!aw(g))return h=="get"?void 0:!1;var M=this._c[h](g===0?0:g,p);return d?this:M})}),s||lw(a.prototype,"size",{get:function(){return this._c.size}})),cw(a,i),u[i]=a,co(co.G+co.W+co.F,u),s||r.setStrong(a,i,n),a},Ec=$1,Sd=Ip,Ac="Map";dw(Ac,function(i){return function(){return i(this,arguments.length>0?arguments[0]:void 0)}},{get:function(t){var e=Ec.getEntry(Sd(this,Ac),t);return e&&e.v},set:function(t,e){return Ec.def(Sd(this,Ac),t===0?0:t,e)}},Ec,!0);var Nc,Id;function fw(){if(Id)return Nc;Id=1;var i=Fs;return Nc=function(t,e){var r=[];return i(t,!1,r.push,r,e),r},Nc}var Dc,Cd;function gw(){if(Cd)return Dc;Cd=1;var i=Ca,t=fw();return Dc=function(e){return function(){if(i(this)!=e)throw TypeError(e+"#toJSON isn't generic");return t(this)}},Dc}var Pc=qt;Pc(Pc.P+Pc.R,"Map",{toJSON:gw()("Map")});var xd=qt,pw=function(i){xd(xd.S,i,{of:function(){for(var e=arguments.length,r=new Array(e);e--;)r[e]=arguments[e];return new this(r)}})};pw("Map");var bd=qt,Ed=js,mw=Cn,Ad=Fs,yw=function(i){bd(bd.S,i,{from:function(e){var r=arguments[1],n,s,o,a;return Ed(this),n=r!==void 0,n&&Ed(r),e==null?new this:(s=[],n?(o=0,a=mw(r,arguments[2],2),Ad(e,!1,function(c){s.push(a(c,o++))})):Ad(e,!1,s.push,s),new this(s))}})};yw("Map");var vw=At.Map,Ep={default:vw,__esModule:!0},Ea={};Ea.f=Object.getOwnPropertySymbols;var Fi={};Fi.f={}.propertyIsEnumerable;var kc,Nd;function Mw(){if(Nd)return kc;Nd=1;var i=ur,t=Bi,e=Ea,r=Fi,n=Ui,s=Iu,o=Object.assign;return kc=!o||_n(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 M=s(arguments[d++]),I=g?t(M).concat(g(M)):t(M),D=I.length,C=0,B;D>C;)B=I[C++],(!i||p.call(M,B))&&(u[B]=M[B]);return u}:o,kc}var Lc=qt;Lc(Lc.S+Lc.F,"Object",{assign:Mw()});var ww=At.Object.assign,Uu={default:ww,__esModule:!0},Aa={};Aa.__esModule=!0;Aa.default=function(i,t){if(!(i instanceof t))throw new TypeError("Cannot call a class as a function")};var Na={},Rc=qt;Rc(Rc.S+Rc.F*!ur,"Object",{defineProperty:lr.f});var Tw=At.Object,Sw=function(t,e,r){return Tw.defineProperty(t,e,r)},Iw={default:Sw,__esModule:!0};Na.__esModule=!0;var Cw=Iw,xw=bw(Cw);function bw(i){return i&&i.__esModule?i:{default:i}}Na.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,xw.default)(t,n.key,n)}}return function(t,e,r){return e&&i(t.prototype,e),r&&i(t,r),t}}();var Fu={};Fu.f=Wt;var Dd=At,Ew=Fu,Aw=lr.f,Wu=function(i){var t=Dd.Symbol||(Dd.Symbol={});i.charAt(0)!="_"&&!(i in t)&&Aw(t,i,{value:Ew.f(i)})},Nw=Bi,Dw=Ea,Pw=Fi,kw=function(i){var t=Nw(i),e=Dw.f;if(e)for(var r=e(i),n=Pw.f,s=0,o;r.length>s;)n.call(i,o=r[s++])&&t.push(o);return t},Ap={},$u={},Lw=hp,Rw=Du.concat("length","prototype");$u.f=Object.getOwnPropertyNames||function(t){return Lw(t,Rw)};var Ow=Jn,Np=$u.f,zw={}.toString,Dp=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],jw=function(i){try{return Np(i)}catch{return Dp.slice()}};Ap.f=function(t){return Dp&&zw.call(t)=="[object Window]"?jw(t):Np(Ow(t))};var Pp={},Bw=Fi,Uw=Bs,Fw=Jn,Ww=bu,$w=ei,Vw=cp,Pd=Object.getOwnPropertyDescriptor;Pp.f=ur?Pd:function(t,e){if(t=Fw(t),e=Ww(e,!0),Vw)try{return Pd(t,e)}catch{}if($w(t,e))return Uw(!Bw.f.call(t,e),t[e])};var Da=Kt,xt=ei,kp=ur,Bt=qt,Yw=lp,Gw=Bu.KEY,Vu=_n,Yu=Au,Gu=Us,Hw=Ia,Ws=Wt,Qw=Fu,Zw=Wu,Kw=kw,qw=bp,Nl=_r,Xw=Ar,Jw=Ui,Pa=Jn,Hu=bu,Dl=Bs,bs=Pu,Lp=Ap,Rp=Pp,ka=Ea,Op=lr,_w=Bi,zp=Rp.f,Un=Op.f,jp=Lp.f,Qt=Da.Symbol,Xo=Da.JSON,lo=Xo&&Xo.stringify,yn="prototype",Ht=Ws("_hidden"),kd=Ws("toPrimitive"),eT={}.propertyIsEnumerable,qi=Yu("symbol-registry"),Xr=Yu("symbols"),$s=Yu("op-symbols"),yr=Object[yn],Wi=typeof Qt=="function"&&!!ka.f,Oc=Da.QObject,Pl=!Oc||!Oc[yn]||!Oc[yn].findChild,kl=kp&&Vu(function(){return bs(Un({},"a",{get:function(){return Un(this,"a",{value:7}).a}})).a!=7})?function(i,t,e){var r=zp(yr,t);r&&delete yr[t],Un(i,t,e),r&&i!==yr&&Un(yr,t,r)}:Un,Ld=function(i){var t=Xr[i]=bs(Qt[yn]);return t._k=i,t},Ll=Wi&&typeof Qt.iterator=="symbol"?function(i){return typeof i=="symbol"}:function(i){return i instanceof Qt},La=function(t,e,r){return t===yr&&La($s,e,r),Nl(t),e=Hu(e,!0),Nl(r),xt(Xr,e)?(r.enumerable?(xt(t,Ht)&&t[Ht][e]&&(t[Ht][e]=!1),r=bs(r,{enumerable:Dl(0,!1)})):(xt(t,Ht)||Un(t,Ht,Dl(1,{})),t[Ht][e]=!0),kl(t,e,r)):Un(t,e,r)},Bp=function(t,e){Nl(t);for(var r=Kw(e=Pa(e)),n=0,s=r.length,o;s>n;)La(t,o=r[n++],e[o]);return t},tT=function(t,e){return e===void 0?bs(t):Bp(bs(t),e)},rT=function(t){var e=eT.call(this,t=Hu(t,!0));return this===yr&&xt(Xr,t)&&!xt($s,t)?!1:e||!xt(this,t)||!xt(Xr,t)||xt(this,Ht)&&this[Ht][t]?e:!0},Up=function(t,e){if(t=Pa(t),e=Hu(e,!0),!(t===yr&&xt(Xr,e)&&!xt($s,e))){var r=zp(t,e);return r&&xt(Xr,e)&&!(xt(t,Ht)&&t[Ht][e])&&(r.enumerable=!0),r}},Fp=function(t){for(var e=jp(Pa(t)),r=[],n=0,s;e.length>n;)!xt(Xr,s=e[n++])&&s!=Ht&&s!=Gw&&r.push(s);return r},Wp=function(t){for(var e=t===yr,r=jp(e?$s:Pa(t)),n=[],s=0,o;r.length>s;)xt(Xr,o=r[s++])&&(!e||xt(yr,o))&&n.push(Xr[o]);return n};Wi||(Qt=function(){if(this instanceof Qt)throw TypeError("Symbol is not a constructor!");var t=Hw(arguments.length>0?arguments[0]:void 0),e=function(r){this===yr&&e.call($s,r),xt(this,Ht)&&xt(this[Ht],t)&&(this[Ht][t]=!1),kl(this,t,Dl(1,r))};return kp&&Pl&&kl(yr,t,{configurable:!0,set:e}),Ld(t)},Yw(Qt[yn],"toString",function(){return this._k}),Rp.f=Up,Op.f=La,$u.f=Lp.f=Fp,Fi.f=rT,ka.f=Wp,Qw.f=function(i){return Ld(Ws(i))});Bt(Bt.G+Bt.W+Bt.F*!Wi,{Symbol:Qt});for(var Rd="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),Od=0;Rd.length>Od;)Ws(Rd[Od++]);for(var zd=_w(Ws.store),jd=0;zd.length>jd;)Zw(zd[jd++]);Bt(Bt.S+Bt.F*!Wi,"Symbol",{for:function(i){return xt(qi,i+="")?qi[i]:qi[i]=Qt(i)},keyFor:function(t){if(!Ll(t))throw TypeError(t+" is not a symbol!");for(var e in qi)if(qi[e]===t)return e},useSetter:function(){Pl=!0},useSimple:function(){Pl=!1}});Bt(Bt.S+Bt.F*!Wi,"Object",{create:tT,defineProperty:La,defineProperties:Bp,getOwnPropertyDescriptor:Up,getOwnPropertyNames:Fp,getOwnPropertySymbols:Wp});var nT=Vu(function(){ka.f(1)});Bt(Bt.S+Bt.F*nT,"Object",{getOwnPropertySymbols:function(t){return ka.f(Jw(t))}});Xo&&Bt(Bt.S+Bt.F*(!Wi||Vu(function(){var i=Qt();return lo([i])!="[null]"||lo({a:i})!="{}"||lo(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],!(!Xw(n)&&t===void 0||Ll(t)))return qw(n)||(n=function(o,a){if(typeof s=="function"&&(a=s.call(this,o,a)),!Ll(a))return a}),e[1]=n,lo.apply(Xo,e)}});Qt[yn][kd]||xn(Qt[yn],kd,Qt[yn].valueOf);Gu(Qt,"Symbol");Gu(Math,"Math",!0);Gu(Da.JSON,"JSON",!0);Wu("asyncIterator");Wu("observable");var iT=At.Symbol,$p={default:iT,__esModule:!0},Ra={};Object.defineProperty(Ra,"__esModule",{value:!0});Ra.createNowTime=sT;Ra.formatDelay=oT;function sT(){var i=null;return Date.now?i=Date.now:i=function(){return new Date().getTime()},i}function oT(i){return typeof i=="number"?i={delay:i}:"entropy"in i&&(i={delay:i.entropy,isEntropy:!0}),i}Object.defineProperty(Ta,"__esModule",{value:!0});var aT=Os,Bd=ri(aT),cT=xa,zc=ri(cT),lT=Ep,uT=ri(lT),hT=Uu,dT=ri(hT),fT=Aa,gT=ri(fT),pT=Na,mT=ri(pT),yT=$p,ti=ri(yT),Vp=Ra;function ri(i){return i&&i.__esModule?i:{default:i}}var vT=(0,Vp.createNowTime)(),MT={originTime:0,playbackRate:1},kr=(0,ti.default)("timeMark"),jc=(0,ti.default)("playbackRate"),Lr=(0,ti.default)("timers"),wT=(0,ti.default)("originTime"),Xi=(0,ti.default)("setTimer"),Rr=(0,ti.default)("parent"),TT=function(){function i(t,e){(0,gT.default)(this,i),t instanceof i&&(e=t,t={}),t=(0,dT.default)({},MT,t),e&&(this[Rr]=e);var r=t.nowtime||vT;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[wT]=t.originTime,this[jc]=t.playbackRate,this[Lr]=new uT.default}return(0,mT.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,zc.default)(this[Lr]));r.forEach(function(n){var s=(0,Bd.default)(n,2),o=s[0],a=s[1];e[Xi](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,zc.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[Xi](e,r)}},{key:"setInterval",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{delay:0},n=this,s=this[Xi](function o(){n[Xi](o,r,s),e()},r);return s}},{key:Xi,value:function(e,r){var n=this,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:(0,ti.default)("timerID");r=(0,Vp.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,zc.default)(o)).forEach(function(a){var c=(0,Bd.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,M=u.handler,I=u.startTime;if(d)g===0&&(M(),r.clearTimeout(l));else{var D=I+g;(g===0||p!==!1&&(s-n)*g<=0||n<=D&&D<=s||n>=D&&D>=s)&&(M(),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[jc]},set:function(e){e!==this.playbackRate&&(this.markTime({playbackRate:e}),this[jc]=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}();Ta.default=TT;var Oa={};Object.defineProperty(Oa,"__esModule",{value:!0});Oa.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={},ST=4,IT=.001,CT=1e-7,xT=10,gs=11,uo=1/(gs-1),bT=typeof Float32Array=="function";function Yp(i,t){return 1-3*t+3*i}function Gp(i,t){return 3*t-6*i}function Hp(i){return 3*i}function Jo(i,t,e){return((Yp(t,e)*i+Gp(t,e))*i+Hp(t))*i}function Qp(i,t,e){return 3*Yp(t,e)*i*i+2*Gp(t,e)*i+Hp(t)}function ET(i,t,e,r,n){var s,o,a=0;do o=t+(e-t)/2,s=Jo(o,r,n)-i,s>0?e=o:t=o;while(Math.abs(s)>CT&&++a<xT);return o}function AT(i,t,e,r){for(var n=0;n<ST;++n){var s=Qp(t,e,r);if(s===0)return t;var o=Jo(t,e,r)-i;t-=o/s}return t}function NT(i){return i}var DT=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 NT;for(var s=bT?new Float32Array(gs):new Array(gs),o=0;o<gs;++o)s[o]=Jo(o*uo,t,r);function a(c){for(var l=0,u=1,h=gs-1;u!==h&&s[u]<=c;++u)l+=uo;--u;var d=(c-s[u])/(s[u+1]-s[u]),g=l+d*uo,p=Qp(g,t,r);return p>=IT?AT(c,g,t,r):p===0?g:ET(c,l,l+uo,t,r)}return function(l){return l===0?0:l===1?1:Jo(a(l),e,n)}};Object.defineProperty(wn,"__esModule",{value:!0});wn.parseEasing=wn.Easings=void 0;var PT=Os,kT=Qu(PT),LT=xa,Zp=Qu(LT),RT=Ep,OT=Qu(RT);function Qu(i){return i&&i.__esModule?i:{default:i}}var zT=DT,Ud=new OT.default;function Ii(){for(var i=arguments.length,t=Array(i),e=0;e<i;e++)t[e]=arguments[e];var r=Ud.get(t);return r||(r=zT.apply(void 0,t),Ud.set(t,r),r)}function _o(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 jT(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())}),Ii.apply(void 0,(0,Zp.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,kT.default)(s,2),a=o[0],c=o[1];return _o(parseInt(a,10),c)}return i}var Rl={linear:function(t){return t},ease:Ii(.25,.1,.25,1),"ease-in":Ii(.42,0,1,1),"ease-out":Ii(0,0,.58,1),"ease-in-out":Ii(.42,0,.58,1),"step-start":_o(1,"start"),"step-end":_o(1,"end")};function BT(i){return typeof i=="string"?Rl[i]?i=Rl[i]:i=jT(i):i.type==="cubic-bezier"?i=Ii.apply(void 0,(0,Zp.default)(i.value)):i.type==="steps"&&(i=_o(i.step,i.pos)),i}wn.Easings=Rl;wn.parseEasing=BT;var Zu={},Fd=_r,UT=js,FT=Wt("species"),Kp=function(i,t){var e=Fd(i).constructor,r;return e===void 0||(r=Fd(e)[FT])==null?t:UT(r)},WT=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)},ho=Cn,$T=WT,Wd=dp,$d=xu,Hr=Kt,Vd=Hr.process,Ol=Hr.setImmediate,Yd=Hr.clearImmediate,Gd=Hr.MessageChannel,Bc=Hr.Dispatch,Uc=0,Ts={},Hd="onreadystatechange",Nn,Fc,Wc,ps=function(){var i=+this;if(Ts.hasOwnProperty(i)){var t=Ts[i];delete Ts[i],t()}},Qd=function(i){ps.call(i.data)};(!Ol||!Yd)&&(Ol=function(t){for(var e=[],r=1;arguments.length>r;)e.push(arguments[r++]);return Ts[++Uc]=function(){$T(typeof t=="function"?t:Function(t),e)},Nn(Uc),Uc},Yd=function(t){delete Ts[t]},zs(Vd)=="process"?Nn=function(i){Vd.nextTick(ho(ps,i,1))}:Bc&&Bc.now?Nn=function(i){Bc.now(ho(ps,i,1))}:Gd?(Fc=new Gd,Wc=Fc.port2,Fc.port1.onmessage=Qd,Nn=ho(Wc.postMessage,Wc,1)):Hr.addEventListener&&typeof postMessage=="function"&&!Hr.importScripts?(Nn=function(i){Hr.postMessage(i+"","*")},Hr.addEventListener("message",Qd,!1)):Hd in $d("script")?Nn=function(i){Wd.appendChild($d("script"))[Hd]=function(){Wd.removeChild(this),ps.call(i)}}:Nn=function(i){setTimeout(ho(ps,i,1),0)});var qp={set:Ol},Qn=Kt,VT=qp.set,Zd=Qn.MutationObserver||Qn.WebKitMutationObserver,zl=Qn.process,$c=Qn.Promise,Kd=zs(zl)=="process",YT=function(){var i,t,e,r=function(){var a,c;for(Kd&&(a=zl.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(Kd)e=function(){zl.nextTick(r)};else if(Zd&&!(Qn.navigator&&Qn.navigator.standalone)){var n=!0,s=document.createTextNode("");new Zd(r).observe(s,{characterData:!0}),e=function(){s.data=n=!n}}else if($c&&$c.resolve){var o=$c.resolve(void 0);e=function(){o.then(r)}}else e=function(){VT.call(Qn,r)};return function(a){var c={fn:a,next:void 0};t&&(t.next=c),i||(i=c,e()),t=c}},za={},qd=js;function GT(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=qd(t),this.reject=qd(e)}za.f=function(i){return new GT(i)};var Xp=function(i){try{return{e:!1,v:i()}}catch(t){return{e:!0,v:t}}},HT=Kt,Xd=HT.navigator,QT=Xd&&Xd.userAgent||"",ZT=_r,KT=Ar,qT=za,Jp=function(i,t){if(ZT(i),KT(t)&&t.constructor===i)return t;var e=qT.f(i),r=e.resolve;return r(t),e.promise},XT=mv,vn=Kt,Ci=Cn,JT=Ca,nr=qt,_T=Ar,eS=js,tS=Ou,Jd=Fs,rS=Kp,_p=qp.set,em=YT(),tm=za,jl=Xp,nS=QT,iS=Jp,bn="Promise",rm=vn.TypeError,Ri=vn.process,_d=Ri&&Ri.versions,sS=_d&&_d.v8||"",xr=vn[bn],Es=JT(Ri)=="process",Vo=function(){},fo,nm,ef,Ku,As=nm=tm.f,ja=!!function(){try{var i=xr.resolve(1),t=(i.constructor={})[Wt("species")]=function(e){e(Vo,Vo)};return(Es||typeof PromiseRejectionEvent=="function")&&i.then(Vo)instanceof t&&sS.indexOf("6.6")!==0&&nS.indexOf("Chrome/66")===-1}catch{}}(),im=function(i){var t;return _T(i)&&typeof(t=i.then)=="function"?t:!1},qu=function(i,t){if(!i._n){i._n=!0;var e=i._c;em(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&&aS(i),i._h=1),c===!0?d=r:(h&&h.enter(),d=c(r),h&&(h.exit(),p=!0)),d===a.promise?u(rm("Promise-chain cycle")):(g=im(d))?g.call(d,l,u):l(d)):u(r)}catch(M){h&&!p&&h.exit(),u(M)}};e.length>s;)o(e[s++]);i._c=[],i._n=!1,t&&!i._h&&oS(i)})}},oS=function(i){_p.call(vn,function(){var t=i._v,e=tf(i),r,n,s;if(e&&(r=jl(function(){Es?Ri.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=Es||tf(i)?2:1),i._a=void 0,e&&r.e)throw r.v})},tf=function(i){return i._h!==1&&(i._a||i._c).length===0},aS=function(i){_p.call(vn,function(){var t;Es?Ri.emit("rejectionHandled",i):(t=vn.onrejectionhandled)&&t({promise:i,reason:i._v})})},ki=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()),qu(t,!0))},Bl=function(i){var t=this,e;if(!t._d){t._d=!0,t=t._w||t;try{if(t===i)throw rm("Promise can't be resolved itself");(e=im(i))?em(function(){var r={_w:t,_d:!1};try{e.call(i,Ci(Bl,r,1),Ci(ki,r,1))}catch(n){ki.call(r,n)}}):(t._v=i,t._s=1,qu(t,!1))}catch(r){ki.call({_w:t,_d:!1},r)}}};ja||(xr=function(t){tS(this,xr,bn,"_h"),eS(t),fo.call(this);try{t(Ci(Bl,this,1),Ci(ki,this,1))}catch(e){ki.call(this,e)}},fo=function(t){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},fo.prototype=Ru(xr.prototype,{then:function(t,e){var r=As(rS(this,xr));return r.ok=typeof t=="function"?t:!0,r.fail=typeof e=="function"&&e,r.domain=Es?Ri.domain:void 0,this._c.push(r),this._a&&this._a.push(r),this._s&&qu(this,!1),r.promise},catch:function(i){return this.then(void 0,i)}}),ef=function(){var i=new fo;this.promise=i,this.resolve=Ci(Bl,i,1),this.reject=Ci(ki,i,1)},tm.f=As=function(i){return i===xr||i===Ku?new ef(i):nm(i)});nr(nr.G+nr.W+nr.F*!ja,{Promise:xr});Us(xr,bn);Tp(bn);Ku=At[bn];nr(nr.S+nr.F*!ja,bn,{reject:function(t){var e=As(this),r=e.reject;return r(t),e.promise}});nr(nr.S+nr.F*XT,bn,{resolve:function(t){return iS(this===Ku?xr:this,t)}});nr(nr.S+nr.F*!(ja&&vp()(function(i){xr.all(i).catch(Vo)})),bn,{all:function(t){var e=this,r=As(e),n=r.resolve,s=r.reject,o=jl(function(){var a=[],c=0,l=1;Jd(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=As(e),n=r.reject,s=jl(function(){Jd(t,!1,function(o){e.resolve(o).then(r.resolve,n)})});return s.e&&n(s.v),r.promise}});var Vc=qt,cS=At,lS=Kt,uS=Kp,rf=Jp;Vc(Vc.P+Vc.R,"Promise",{finally:function(i){var t=uS(this,cS.Promise||lS.Promise),e=typeof i=="function";return this.then(e?function(r){return rf(t,i()).then(function(){return r})}:i,e?function(r){return rf(t,i()).then(function(){throw r})}:i)}});var nf=qt,hS=za,dS=Xp;nf(nf.S,"Promise",{try:function(i){var t=hS.f(this),e=dS(i);return(e.e?t.reject:t.resolve)(e.v),t.promise}});var fS=At.Promise,sm={default:fS,__esModule:!0},Yc=qt,gS=At,pS=_n,mS=function(i,t){var e=(gS.Object||{})[i]||Object[i],r={};r[i]=t(e),Yc(Yc.S+Yc.F*pS(function(){e(1)}),"Object",r)},yS=Ui,vS=Bi;mS("keys",function(){return function(t){return vS(yS(t))}});var MS=At.Object.keys,wS={default:MS,__esModule:!0},ni={},TS=ur,SS=Bi,IS=Jn,CS=Fi.f,xS=function(i){return function(t){for(var e=IS(t),r=SS(e),n=r.length,s=0,o=[],a;n>s;)a=r[s++],(!TS||CS.call(e,a))&&o.push(i?[a,e[a]]:e[a]);return o}},sf=qt,bS=xS(!0);sf(sf.S,"Object",{entries:function(t){return bS(t)}});var ES=At.Object.entries,AS={default:ES,__esModule:!0};Object.defineProperty(ni,"__esModule",{value:!0});var NS=Os,DS=Vs(NS),PS=AS,kS=Vs(PS),LS=Uu,om=Vs(LS),RS=sm,OS=Vs(RS);ni.defer=US;ni.periodicity=FS;ni.calculateFramesOffset=WS;ni.getProgress=$S;ni.getCurrentFrame=YS;var zS=wn,jS=Oa,BS=Vs(jS);function Vs(i){return i&&i.__esModule?i:{default:i}}function US(){var i={};return i.promise=new OS.default(function(t,e){i.resolve=t,i.reject=e}),i}function FS(i,t){var e=Math.floor(i/t),r=i-e*t;return r===0&&e>0&&(r=t,e--),[e,r]}function WS(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,zS.parseEasing)(o.easing)),s>0){var u=i[s].easing!=null;i[s]=(0,om.default)({},i[s-1],i[s]),u||delete i[s].easing}}return i}function $S(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 VS(i,t,e,r){var n={};return(0,kS.default)(t).forEach(function(s){var o=(0,DS.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 YS(i,t,e,r){var n=i.easing,s=i.effect;s||(e=(0,om.default)({},BS.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=VS(u,c,e,g);break}}return o}Object.defineProperty(Zu,"__esModule",{value:!0});var GS=sm,Gc=ii(GS),HS=wS,QS=ii(HS),ZS=Uu,Ji=ii(ZS),KS=Aa,qS=ii(KS),XS=Na,JS=ii(XS),_S=$p,en=ii(_S),eI=Ta,tI=ii(eI),tn=ni,rI=wn;function ii(i){return i&&i.__esModule?i:{default:i}}var Ot=(0,en.default)("timing"),Or=(0,en.default)("keyframes"),_i=(0,en.default)("initState"),Nt=(0,en.default)("readyDefer"),Xt=(0,en.default)("finishedDefer"),go=(0,en.default)("effects"),po=(0,en.default)("activeReadyTimer"),Hc=(0,en.default)("activeFinishTimer"),zr=(0,en.default)("removeDefer"),nI={delay:0,endDelay:0,fill:"auto",iterations:1,playbackRate:1,direction:"normal",easing:"linear",effect:null},iI=function(){function i(t,e,r){var n=this;if((0,qS.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,Ji.default)({},nI,r),this[Ot].easing=(0,rI.parseEasing)(this[Ot].easing),this[Or]=(0,tn.calculateFramesOffset)(e);var o=this[Or][this[Or].length-1];this[_i]={},(0,QS.default)(o).forEach(function(a){Object.prototype.hasOwnProperty.call(t,a)&&a!=="easing"&&a!=="offset"&&(n[_i][a]=t[a])}),this[Or]=this[Or].map(function(a){return(0,Ji.default)({},n[_i],a)}),this[Or][0].offset!==0&&this[Or].unshift((0,Ji.default)({},this[_i],{offset:0})),o.offset<1&&this[Or].push((0,Ji.default)({},o,{offset:1})),this[go]={},this.timeline=null}return(0,JS.default)(i,[{key:"pause",value:function(){this.timeline.playbackRate=0}},{key:po,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:Hc,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 tI.default({originTime:r,playbackRate:n},s),this[po](),this[Hc]()}else this.playState==="paused"&&(this.timeline.playbackRate=this.playbackRate,this[po]())}},{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,Ji.default)(this[go],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,tn.periodicity)(c,r)[1]/r}else(o==="running"||o==="paused")&&(a=(0,tn.periodicity)(s.currentTime,r)[1]/r);return o==="finished"&&(a=(0,tn.periodicity)(n,1)[1]),a}},{key:"frame",get:function(){var e=this.playState,r=this[_i],n=this[Ot].fill;if(e==="idle")return r;var s=this.timeline.currentTime,o=this[Or].slice(0),a=(0,tn.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,tn.getCurrentFrame)(this[Ot],o,this[go],c)),u}},{key:"timing",get:function(){return this[Ot]}},{key:"effects",get:function(){return this[go]}},{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"?Gc.default.resolve():(this[Nt]=(0,tn.defer)(),this.timeline&&this[po](),this[Nt]?this[Nt].promise:Gc.default.resolve())}},{key:"finished",get:function(){return this.playState==="finished"?Gc.default.resolve():(this[Xt]||(this[Xt]=(0,tn.defer)(),this.timeline&&this[Hc]()),this[Xt].promise)}}]),i}();Zu.default=iI;Object.defineProperty(Gr,"__esModule",{value:!0});var am=Gr.Timeline=Mr=Gr.Effects=Gr.Easings=cm=Gr.Animator=void 0,sI=Ta,oI=Xu(sI),aI=Oa,cI=Xu(aI),lI=wn,uI=Zu,hI=Xu(uI);function Xu(i){return i&&i.__esModule?i:{default:i}}var cm=Gr.Animator=hI.default;Gr.Easings=lI.Easings;var Mr=Gr.Effects=cI.default;am=Gr.Timeline=oI.default;var dI={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 of=Jr(dI);var af={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};function fI(i){var t,e=[],r=1,n;if(typeof i=="string")if(i=i.toLowerCase(),of[i])e=of[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(af[d]!==void 0)return af[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 Ul={min:[0,0,0],max:[255,255,255]};var Qc={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}};Ul.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 Fl(i){Array.isArray(i)&&i.raw&&(i=String.raw(...arguments));var t,e=fI(i);if(!e.space)return[];const r=e.space[0]==="h"?Qc.min:Ul.min,n=e.space[0]==="h"?Qc.max:Ul.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=Qc.rgb(t)),t.push(Math.min(Math.max(e.alpha,0),1)),t}qe(Array);function gI(){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,Zn;typeof global<"u"&&typeof global.requestAnimationFrame=="function"?(Qr=global.requestAnimationFrame,Zn=global.cancelAnimationFrame):(Qr=function(i){return setTimeout(()=>{i(gI())},16)},Zn=function(i){return clearTimeout(i)});qe(Array);function cf(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 Tu(i)}return i}function Ba(i,t,e,r,n){return typeof i=="string"&&(i=Fl(i)),typeof t=="string"&&(t=Fl(t)),Mr.default(i,t,e,r,n)}function pI(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=Ba;Mr.strokeColor=Ba;Mr.bgcolor=Ba;Mr.borderColor=Ba;Mr.text=pI;class mI extends cm{constructor(t,e,r){const n=t.attr();Object.entries(n).forEach(([s,o])=>{n[s]=Mr[s]?o:cf(o)}),e=e.map(({...s})=>{const o={};return Object.entries(s).forEach(([a,c])=>{o[a]=Mr[a]?c:cf(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"?(Zn(t.requestId),e()):Qr(r)}r()})})}finish(){super.finish(),Zn(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){Zn(this.requestId),t?(this.setter(this.frame,this.target),super.cancel()):(super.cancel(),this.setter(this.frame,this.target))}}qe(Array);const Yo=new Map;function lf(i,t={},e=[]){i=i.toLowerCase();const r=Yo.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(),Yo.has(t))throw new TypeError(`Cannot registerNode, ${t} has been taken.`);Yo.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:lf,createElementNS(i,t){return lf(t)},isSpriteNode(i){return Yo.has(i.toLowerCase())}};qe(Array);const mo=Symbol("type"),Zc=Symbol("bubbles"),Kc=Symbol("originalEvent"),uf=Symbol("detail");class Kn{constructor(t,{bubbles:e=null}={}){if(typeof t=="string"?(this[mo]=t,this[Zc]=!!e):(this[mo]=t.type,this[Kc]=t,this[Zc]=e!=null?!!e:!!t.bubbles,t.detail&&(this[uf]=t.detail)),!this[mo])throw new TypeError("Invalid event type.");this.cancelBubble=!1}setOriginalEvent(t){this[Kc]=t}get originalEvent(){return this[Kc]}get type(){return this[mo]}get bubbles(){return this[Zc]}get detail(){return this[uf]}stopPropagation(){this.cancelBubble=!0}}qe(Array);function yI(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 vI(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 MI(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 wI=Symbol.for("spritejs_changedAttrs"),TI=Symbol.for("spritejs_attributes"),yo=Symbol("resolution"),gi=Symbol("animations"),Dn=Symbol("eventListeners"),Pn=Symbol("captureEventListeners"),hf=Symbol("filters"),df=Symbol("display"),vo=Symbol("program"),es=Symbol("shaderAttrs"),pi=Symbol("uniforms"),Mo=Symbol("mask");var yl;let Ua=(yl=class{constructor(t={}){this.attributes=new this.constructor.Attr(this),this[yo]={width:300,height:150},Object.assign(this.attributes,t),this[gi]=new Set,this[Dn]={},this[Pn]={}}get ancestors(){let t=this.parent;const e=[];for(;t;)e.push(t),t=t.parent;return e}get animations(){return this[gi]}get filters(){return this[hf]||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[Mo]?{...this[Mo],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[vo]}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[pi]}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[es]||{}}activateAnimations(){const t=this.layer;if(t){const e=this[gi];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?Pn:Dn;return this[o][t]=this[o][t]||[],this[o][t].push({listener:e,once:s}),this}animate(t,e){const r=new mI(this,t,e);return this.effects&&r.applyEffects(this.effects),this.layer&&(r.baseTimeline=this.layer.timeline,r.play(),r.finished.then(()=>{this[gi].delete(r)})),this[gi].add(r),r}attr(...t){if(t.length===0)return this.attributes[TI];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[wI];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[gi].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 Kn||(t=new Kn(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[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}if(!t.cancelBubble)for(let s=0;s<r.length;s++){const o=r[s],a=o[Dn]&&o[Dn][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(vI(e,this.filters),this._applyMask(e),t.push(e),this[vo]){e.setProgram(this[vo]);const r=this[es];r&&Object.entries(r).forEach(([s,o])=>{e.setAttribute(s,o)});const n=this[pi];if(this[pi]){const s={};Object.entries(n).forEach(([o,a])=>{typeof a=="function"&&(a=a(this,o)),s[o]=a}),e.setUniforms(s)}}MI(this,e)}return t}forceUpdate(){this.parent&&this.parent.forceUpdate()}getAttribute(t){return this.attributes[t]}getListeners(t,{capture:e=!1}={}){return[...this[e?Pn:Dn][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=qo(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[yo]}}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[hf]=yI(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[Mo]={handle:t,rect:e.rect||t.rect},this.forceUpdate(),this):this.clearMask()}clearMask(){return this[Mo]=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=qo(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[vo]=t,this.forceUpdate()}setShaderAttribute(t,e){this[es]=this[es]||{},this[es][t]=e,this.forceUpdate()}setUniforms(t){this[pi]=this[pi]||{},Object.assign(this[pi],t),this.forceUpdate()}setResolution({width:t,height:e}){const{width:r,height:n}=this[yo];(r!==t||n!==e)&&(this[yo]={width:t,height:e},this.forceUpdate(),this.dispatchEvent({type:"resolutionchange",detail:{width:t,height:e}}))}show(){this.attributes.display==="none"&&(this.attributes.display=this[df]||"")}hide(){this.attributes.display!=="none"&&(this[df]=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?Pn:Dn;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?Pn:Dn;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(){}},L(yl,"Attr",Su),yl);$t.registerNode(Ua,"node");qe(Array);class SI{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 SI))return i;const t=Fl(i);if(!t||!t.length)throw new TypeError("Invalid color value.");return`rgba(${t.join()})`}function lm(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 ea(i,{color:t,rule:e="nonzero"}){return lm(i,"fill",t),t.vector||i.setFill({color:t,rule:e}),i}function ta(i,{color:t,lineWidth:e,lineCap:r,lineJoin:n,lineDash:s,lineDashOffset:o,miterLimit:a,roundSegments:c}){lm(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"),II=Symbol.for("spritejs_setAttributeDefault"),CI=Symbol.for("spritejs_declareAlias");let Fa=class extends Su{constructor(t){super(t),this[II]({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[CI]("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 wo(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 xI(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,M)=>M%2?Math.min(p,n/2):Math.min(p,r/2));i.beginPath(),i.moveTo(t,e+a),wo(i,t,e,o*2,a*2,"leftTop"),i.lineTo(t+r-c,e),wo(i,t+r-c*2,e,c*2,l*2,"rightTop"),i.lineTo(t+r,e+n-h),wo(i,t+r-u*2,e+n-h*2,u*2,h*2,"rightBottom"),i.lineTo(t+d,e+n),wo(i,t,e+n-g*2,d*2,g*2,"leftBottom"),i.closePath()}return i}qe(Array);function um(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),M=Math.min(a,l,h,g),I=Math.max(o,c,u,d),D=Math.max(a,l,h,g);return{x:p,y:M,width:I-p,height:D-M,left:p,top:M,right:I,bottom:D}}qe(Array);const jr=Symbol("mesh");class Ys extends Ua{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(ea(e,{color:n}),this.hasBorder){const{borderColor:o,borderWidth:a,borderDash:c,borderDashOffset:l}=this.attributes;ta(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 um(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"&&ea(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;ta(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,xI(this.clientBox,[l,u,s,o],n)}}L(Ys,"Attr",Fa);$t.registerNode(Ys,"block");qe(Array);let bI=class extends Fa{};var hm={exports:{}},Ju={Text:"text",CDATA:"cdata",isTag:function(i){return i.type==="tag"||i.type==="script"||i.type==="style"}},dm={exports:{}},fm={};(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})(fm);var gm={},Kr={};const EI="Á",AI="á",NI="Ă",DI="ă",PI="∾",kI="∿",LI="∾̳",RI="Â",OI="â",zI="´",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="⍼",x2="Ą",b2="ą",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="ℶ",xC="≬",bC="𝔅",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="=⃥",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="╧",xx="╨",bx="╩",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="˘",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="⩇",xb="⩀",bb="ⅅ",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="✓",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="’",xE="♣",bE="♣",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="⤼",xA="⋞",bA="⋟",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="♦",xN="¨",bN="ⅆ",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="⥗",xD="⇁",bD="↧",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="ē",xP="∅",bP="∅",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="ⅇ",xk="ⅇ",bk="≒",Ek="Ф",Ak="ф",Nk="♀",Dk="ffi",Pk="ff",kk="ffl",Lk="𝔉",Rk="𝔣",Ok="fi",zk="◼",jk="▪",Bk="fj",Uk="♭",Fk="fl",Wk="▱",$k="ƒ",Vk="𝔽",Yk="𝕗",Gk="∀",Hk="∀",Qk="⋔",Zk="⫙",Kk="ℱ",qk="⨍",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="Ģ",xL="Ĝ",bL="ĝ",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="⪐",xR="⪧",bR="⩺",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="≎",xO="≏",bO="⁃",EO="‐",AO="Í",NO="í",DO="",PO="Î",kO="î",LO="И",RO="и",OO="İ",zO="Е",jO="е",BO="¡",UO="⇔",FO="𝔦",WO="ℑ",$O="Ì",VO="ì",YO="ⅈ",GO="⨌",HO="∭",QO="⧜",ZO="℩",KO="IJ",qO="ij",XO="Ī",JO="ī",_O="ℑ",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="ё",xz="Į",bz="į",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="𝕜",xj="𝒦",bj="𝓀",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="↲",x3="≤",b3="≦",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="⪋",x4="⋚",b4="≦",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="↬",xB="⦅",bB="𝕃",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="✠",x5="✠",b5="↦",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="ʼn",TU="≉",SU="♮",IU="ℕ",CU="♮",xU=" ",bU="≎̸",EU="≏̸",AU="⩃",NU="Ň",DU="ň",PU="Ņ",kU="ņ",LU="≇",RU="⩭̸",OU="⩂",zU="Н",jU="н",BU="–",UU="⤤",FU="↗",WU="⇗",$U="↗",VU="≠",YU="≐̸",GU="",HU="",QU="",ZU="",KU="≢",qU="⤨",XU="≂̸",JU="≫",_U="≪",eF=`
|
|
568
|
-
`,tF="∄",rF="∄",nF="𝔑",iF="𝔫",sF="≧̸",oF="≱",aF="≱",cF="≧̸",lF="⩾̸",uF="⩾̸",hF="⋙̸",dF="≵",fF="≫⃒",gF="≯",pF="≯",mF="≫̸",yF="↮",vF="⇎",MF="⫲",wF="∋",TF="⋼",SF="⋺",IF="∋",CF="Њ",xF="њ",bF="↚",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="⋬",xW="≮",bW="≰",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$="⋭",x$="⊁",b$="⋡",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="⊴⃒",xV="⤃",bV="⊵⃒",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="⊕",xY="↻",bY="⩔",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="⋔",xG="ϖ",bG="ℏ",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="∝",x8="≾",b8="⊰",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="⤏",x6="⤐",b6="❳",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="⇂",x9="⌋",b9="⇁",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="⊵",xH="▸",bH="⧎",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="↑",x7="",b7="Σ",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="⊑",xQ="⊐",bQ="⊒",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="∑",xZ="♪",bZ="¹",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="Θ",xK="θ",bK="ϑ",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="ћ",xq="Ŧ",bq="ŧ",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="⇅",xX="↕",bX="↕",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="⫫",xJ="⫩",bJ="В",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_="𝒲",x_="𝓌",b_="⋂",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="ž",xee="З",bee="з",Eee="Ż",Aee="ż",Nee="ℨ",Dee="",Pee="Ζ",kee="ζ",Lee="𝔷",Ree="ℨ",Oee="Ж",zee="ж",jee="⇝",Bee="𝕫",Uee="ℤ",Fee="𝒵",Wee="𝓏",$ee="",Vee="",pm={Aacute:EI,aacute:AI,Abreve:NI,abreve:DI,ac:PI,acd:kI,acE:LI,Acirc:RI,acirc:OI,acute:zI,Acy:jI,acy:BI,AElig:UI,aelig:FI,af:WI,Afr:$I,afr:VI,Agrave:YI,agrave:GI,alefsym:HI,aleph:QI,Alpha:ZI,alpha:KI,Amacr:qI,amacr:XI,amalg:JI,amp:_I,AMP:e2,andand:t2,And:r2,and:n2,andd:i2,andslope:s2,andv:o2,ang:a2,ange:c2,angle:l2,angmsdaa:u2,angmsdab:h2,angmsdac:d2,angmsdad:f2,angmsdae:g2,angmsdaf:p2,angmsdag:m2,angmsdah:y2,angmsd:v2,angrt:M2,angrtvb:w2,angrtvbd:T2,angsph:S2,angst:I2,angzarr:C2,Aogon:x2,aogon:b2,Aopf:E2,aopf:A2,apacir:N2,ap:D2,apE:P2,ape:k2,apid:L2,apos:R2,ApplyFunction:O2,approx:z2,approxeq:j2,Aring:B2,aring:U2,Ascr:F2,ascr:W2,Assign:$2,ast:V2,asymp:Y2,asympeq:G2,Atilde:H2,atilde:Q2,Auml:Z2,auml:K2,awconint:q2,awint:X2,backcong:J2,backepsilon:_2,backprime:eC,backsim:tC,backsimeq:rC,Backslash:nC,Barv:iC,barvee:sC,barwed:oC,Barwed:aC,barwedge:cC,bbrk:lC,bbrktbrk:uC,bcong:hC,Bcy:dC,bcy:fC,bdquo:gC,becaus:pC,because:mC,Because:yC,bemptyv:vC,bepsi:MC,bernou:wC,Bernoullis:TC,Beta:SC,beta:IC,beth:CC,between:xC,Bfr:bC,bfr:EC,bigcap:AC,bigcirc:NC,bigcup:DC,bigodot:PC,bigoplus:kC,bigotimes:LC,bigsqcup:RC,bigstar:OC,bigtriangledown:zC,bigtriangleup:jC,biguplus:BC,bigvee:UC,bigwedge:FC,bkarow:WC,blacklozenge:$C,blacksquare:VC,blacktriangle:YC,blacktriangledown:GC,blacktriangleleft:HC,blacktriangleright:QC,blank:ZC,blk12:KC,blk14:qC,blk34:XC,block:JC,bne:_C,bnequiv:ex,bNot:tx,bnot:rx,Bopf:nx,bopf:ix,bot:sx,bottom:ox,bowtie:ax,boxbox:cx,boxdl:lx,boxdL:ux,boxDl:hx,boxDL:dx,boxdr:fx,boxdR:gx,boxDr:px,boxDR:mx,boxh:yx,boxH:vx,boxhd:Mx,boxHd:wx,boxhD:Tx,boxHD:Sx,boxhu:Ix,boxHu:Cx,boxhU:xx,boxHU:bx,boxminus:Ex,boxplus:Ax,boxtimes:Nx,boxul:Dx,boxuL:Px,boxUl:kx,boxUL:Lx,boxur:Rx,boxuR:Ox,boxUr:zx,boxUR:jx,boxv:Bx,boxV:Ux,boxvh:Fx,boxvH:Wx,boxVh:$x,boxVH:Vx,boxvl:Yx,boxvL:Gx,boxVl:Hx,boxVL:Qx,boxvr:Zx,boxvR:Kx,boxVr:qx,boxVR:Xx,bprime:Jx,breve:_x,Breve:eb,brvbar:tb,bscr:rb,Bscr:nb,bsemi:ib,bsim:sb,bsime:ob,bsolb:ab,bsol:cb,bsolhsub:lb,bull:ub,bullet:hb,bump:db,bumpE:fb,bumpe:gb,Bumpeq:pb,bumpeq:mb,Cacute:yb,cacute:vb,capand:Mb,capbrcup:wb,capcap:Tb,cap:Sb,Cap:Ib,capcup:Cb,capdot:xb,CapitalDifferentialD:bb,caps:Eb,caret:Ab,caron:Nb,Cayleys:Db,ccaps:Pb,Ccaron:kb,ccaron:Lb,Ccedil:Rb,ccedil:Ob,Ccirc:zb,ccirc:jb,Cconint:Bb,ccups:Ub,ccupssm:Fb,Cdot:Wb,cdot:$b,cedil:Vb,Cedilla:Yb,cemptyv:Gb,cent:Hb,centerdot:Qb,CenterDot:Zb,cfr:Kb,Cfr:qb,CHcy:Xb,chcy:Jb,check:_b,checkmark:eE,Chi:tE,chi:rE,circ:nE,circeq:iE,circlearrowleft:sE,circlearrowright:oE,circledast:aE,circledcirc:cE,circleddash:lE,CircleDot:uE,circledR:hE,circledS:dE,CircleMinus:fE,CirclePlus:gE,CircleTimes:pE,cir:mE,cirE:yE,cire:vE,cirfnint:ME,cirmid:wE,cirscir:TE,ClockwiseContourIntegral:SE,CloseCurlyDoubleQuote:IE,CloseCurlyQuote:CE,clubs:xE,clubsuit:bE,colon:EE,Colon:AE,Colone:NE,colone:DE,coloneq:PE,comma:kE,commat:LE,comp:RE,compfn:OE,complement:zE,complexes:jE,cong:BE,congdot:UE,Congruent:FE,conint:WE,Conint:$E,ContourIntegral:VE,copf:YE,Copf:GE,coprod:HE,Coproduct:QE,copy:ZE,COPY:KE,copysr:qE,CounterClockwiseContourIntegral:XE,crarr:JE,cross:_E,Cross:eA,Cscr:tA,cscr:rA,csub:nA,csube:iA,csup:sA,csupe:oA,ctdot:aA,cudarrl:cA,cudarrr:lA,cuepr:uA,cuesc:hA,cularr:dA,cularrp:fA,cupbrcap:gA,cupcap:pA,CupCap:mA,cup:yA,Cup:vA,cupcup:MA,cupdot:wA,cupor:TA,cups:SA,curarr:IA,curarrm:CA,curlyeqprec:xA,curlyeqsucc:bA,curlyvee:EA,curlywedge:AA,curren:NA,curvearrowleft:DA,curvearrowright:PA,cuvee:kA,cuwed:LA,cwconint:RA,cwint:OA,cylcty:zA,dagger:jA,Dagger:BA,daleth:UA,darr:FA,Darr:WA,dArr:$A,dash:VA,Dashv:YA,dashv:GA,dbkarow:HA,dblac:QA,Dcaron:ZA,dcaron:KA,Dcy:qA,dcy:XA,ddagger:JA,ddarr:_A,DD:eN,dd:tN,DDotrahd:rN,ddotseq:nN,deg:iN,Del:sN,Delta:oN,delta:aN,demptyv:cN,dfisht:lN,Dfr:uN,dfr:hN,dHar:dN,dharl:fN,dharr:gN,DiacriticalAcute:pN,DiacriticalDot:mN,DiacriticalDoubleAcute:yN,DiacriticalGrave:vN,DiacriticalTilde:MN,diam:wN,diamond:TN,Diamond:SN,diamondsuit:IN,diams:CN,die:xN,DifferentialD:bN,digamma:EN,disin:AN,div:NN,divide:DN,divideontimes:PN,divonx:kN,DJcy:LN,djcy:RN,dlcorn:ON,dlcrop:zN,dollar:jN,Dopf:BN,dopf:UN,Dot:FN,dot:WN,DotDot:$N,doteq:VN,doteqdot:YN,DotEqual:GN,dotminus:HN,dotplus:QN,dotsquare:ZN,doublebarwedge:KN,DoubleContourIntegral:qN,DoubleDot:XN,DoubleDownArrow:JN,DoubleLeftArrow:_N,DoubleLeftRightArrow:eD,DoubleLeftTee:tD,DoubleLongLeftArrow:rD,DoubleLongLeftRightArrow:nD,DoubleLongRightArrow:iD,DoubleRightArrow:sD,DoubleRightTee:oD,DoubleUpArrow:aD,DoubleUpDownArrow:cD,DoubleVerticalBar:lD,DownArrowBar:uD,downarrow:hD,DownArrow:dD,Downarrow:fD,DownArrowUpArrow:gD,DownBreve:pD,downdownarrows:mD,downharpoonleft:yD,downharpoonright:vD,DownLeftRightVector:MD,DownLeftTeeVector:wD,DownLeftVectorBar:TD,DownLeftVector:SD,DownRightTeeVector:ID,DownRightVectorBar:CD,DownRightVector:xD,DownTeeArrow:bD,DownTee:ED,drbkarow:AD,drcorn:ND,drcrop:DD,Dscr:PD,dscr:kD,DScy:LD,dscy:RD,dsol:OD,Dstrok:zD,dstrok:jD,dtdot:BD,dtri:UD,dtrif:FD,duarr:WD,duhar:$D,dwangle:VD,DZcy:YD,dzcy:GD,dzigrarr:HD,Eacute:QD,eacute:ZD,easter:KD,Ecaron:qD,ecaron:XD,Ecirc:JD,ecirc:_D,ecir:eP,ecolon:tP,Ecy:rP,ecy:nP,eDDot:iP,Edot:sP,edot:oP,eDot:aP,ee:cP,efDot:lP,Efr:uP,efr:hP,eg:dP,Egrave:fP,egrave:gP,egs:pP,egsdot:mP,el:yP,Element:vP,elinters:MP,ell:wP,els:TP,elsdot:SP,Emacr:IP,emacr:CP,empty:xP,emptyset:bP,EmptySmallSquare:EP,emptyv:AP,EmptyVerySmallSquare:NP,emsp13:DP,emsp14:PP,emsp:kP,ENG:LP,eng:RP,ensp:OP,Eogon:zP,eogon:jP,Eopf:BP,eopf:UP,epar:FP,eparsl:WP,eplus:$P,epsi:VP,Epsilon:YP,epsilon:GP,epsiv:HP,eqcirc:QP,eqcolon:ZP,eqsim:KP,eqslantgtr:qP,eqslantless:XP,Equal:JP,equals:_P,EqualTilde:ek,equest:tk,Equilibrium:rk,equiv:nk,equivDD:ik,eqvparsl:sk,erarr:ok,erDot:ak,escr:ck,Escr:lk,esdot:uk,Esim:hk,esim:dk,Eta:fk,eta:gk,ETH:pk,eth:mk,Euml:yk,euml:vk,euro:Mk,excl:wk,exist:Tk,Exists:Sk,expectation:Ik,exponentiale:Ck,ExponentialE:xk,fallingdotseq:bk,Fcy:Ek,fcy:Ak,female:Nk,ffilig:Dk,fflig:Pk,ffllig:kk,Ffr:Lk,ffr:Rk,filig:Ok,FilledSmallSquare:zk,FilledVerySmallSquare:jk,fjlig:Bk,flat:Uk,fllig:Fk,fltns:Wk,fnof:$k,Fopf:Vk,fopf:Yk,forall:Gk,ForAll:Hk,fork:Qk,forkv:Zk,Fouriertrf:Kk,fpartint:qk,frac12:Xk,frac13:Jk,frac14:_k,frac15:eL,frac16:tL,frac18:rL,frac23:nL,frac25:iL,frac34:sL,frac35:oL,frac38:aL,frac45:cL,frac56:lL,frac58:uL,frac78:hL,frasl:dL,frown:fL,fscr:gL,Fscr:pL,gacute:mL,Gamma:yL,gamma:vL,Gammad:ML,gammad:wL,gap:TL,Gbreve:SL,gbreve:IL,Gcedil:CL,Gcirc:xL,gcirc:bL,Gcy:EL,gcy:AL,Gdot:NL,gdot:DL,ge:PL,gE:kL,gEl:LL,gel:RL,geq:OL,geqq:zL,geqslant:jL,gescc:BL,ges:UL,gesdot:FL,gesdoto:WL,gesdotol:$L,gesl:VL,gesles:YL,Gfr:GL,gfr:HL,gg:QL,Gg:ZL,ggg:KL,gimel:qL,GJcy:XL,gjcy:JL,gla:_L,gl:eR,glE:tR,glj:rR,gnap:nR,gnapprox:iR,gne:sR,gnE:oR,gneq:aR,gneqq:cR,gnsim:lR,Gopf:uR,gopf:hR,grave:dR,GreaterEqual:fR,GreaterEqualLess:gR,GreaterFullEqual:pR,GreaterGreater:mR,GreaterLess:yR,GreaterSlantEqual:vR,GreaterTilde:MR,Gscr:wR,gscr:TR,gsim:SR,gsime:IR,gsiml:CR,gtcc:xR,gtcir:bR,gt:ER,GT:AR,Gt:NR,gtdot:DR,gtlPar:PR,gtquest:kR,gtrapprox:LR,gtrarr:RR,gtrdot:OR,gtreqless:zR,gtreqqless:jR,gtrless:BR,gtrsim:UR,gvertneqq:FR,gvnE:WR,Hacek:$R,hairsp:VR,half:YR,hamilt:GR,HARDcy:HR,hardcy:QR,harrcir:ZR,harr:KR,hArr:qR,harrw:XR,Hat:JR,hbar:_R,Hcirc:eO,hcirc:tO,hearts:rO,heartsuit:nO,hellip:iO,hercon:sO,hfr:oO,Hfr:aO,HilbertSpace:cO,hksearow:lO,hkswarow:uO,hoarr:hO,homtht:dO,hookleftarrow:fO,hookrightarrow:gO,hopf:pO,Hopf:mO,horbar:yO,HorizontalLine:vO,hscr:MO,Hscr:wO,hslash:TO,Hstrok:SO,hstrok:IO,HumpDownHump:CO,HumpEqual:xO,hybull:bO,hyphen:EO,Iacute:AO,iacute:NO,ic:DO,Icirc:PO,icirc:kO,Icy:LO,icy:RO,Idot:OO,IEcy:zO,iecy:jO,iexcl:BO,iff:UO,ifr:FO,Ifr:WO,Igrave:$O,igrave:VO,ii:YO,iiiint:GO,iiint:HO,iinfin:QO,iiota:ZO,IJlig:KO,ijlig:qO,Imacr:XO,imacr:JO,image:_O,ImaginaryI:ez,imagline:tz,imagpart:rz,imath:nz,Im:iz,imof:sz,imped:oz,Implies:az,incare:cz,in:"∈",infin:lz,infintie:uz,inodot:hz,intcal:dz,int:fz,Int:gz,integers:pz,Integral:mz,intercal:yz,Intersection:vz,intlarhk:Mz,intprod:wz,InvisibleComma:Tz,InvisibleTimes:Sz,IOcy:Iz,iocy:Cz,Iogon:xz,iogon:bz,Iopf:Ez,iopf:Az,Iota:Nz,iota:Dz,iprod:Pz,iquest:kz,iscr:Lz,Iscr:Rz,isin:Oz,isindot:zz,isinE:jz,isins:Bz,isinsv:Uz,isinv:Fz,it:Wz,Itilde:$z,itilde:Vz,Iukcy:Yz,iukcy:Gz,Iuml:Hz,iuml:Qz,Jcirc:Zz,jcirc:Kz,Jcy:qz,jcy:Xz,Jfr:Jz,jfr:_z,jmath:ej,Jopf:tj,jopf:rj,Jscr:nj,jscr:ij,Jsercy:sj,jsercy:oj,Jukcy:aj,jukcy:cj,Kappa:lj,kappa:uj,kappav:hj,Kcedil:dj,kcedil:fj,Kcy:gj,kcy:pj,Kfr:mj,kfr:yj,kgreen:vj,KHcy:Mj,khcy:wj,KJcy:Tj,kjcy:Sj,Kopf:Ij,kopf:Cj,Kscr:xj,kscr:bj,lAarr:Ej,Lacute:Aj,lacute:Nj,laemptyv:Dj,lagran:Pj,Lambda:kj,lambda:Lj,lang:Rj,Lang:Oj,langd:zj,langle:jj,lap:Bj,Laplacetrf:Uj,laquo:Fj,larrb:Wj,larrbfs:$j,larr:Vj,Larr:Yj,lArr:Gj,larrfs:Hj,larrhk:Qj,larrlp:Zj,larrpl:Kj,larrsim:qj,larrtl:Xj,latail:Jj,lAtail:_j,lat:e3,late:t3,lates:r3,lbarr:n3,lBarr:i3,lbbrk:s3,lbrace:o3,lbrack:a3,lbrke:c3,lbrksld:l3,lbrkslu:u3,Lcaron:h3,lcaron:d3,Lcedil:f3,lcedil:g3,lceil:p3,lcub:m3,Lcy:y3,lcy:v3,ldca:M3,ldquo:w3,ldquor:T3,ldrdhar:S3,ldrushar:I3,ldsh:C3,le:x3,lE:b3,LeftAngleBracket:E3,LeftArrowBar:A3,leftarrow:N3,LeftArrow:D3,Leftarrow:P3,LeftArrowRightArrow:k3,leftarrowtail:L3,LeftCeiling:R3,LeftDoubleBracket:O3,LeftDownTeeVector:z3,LeftDownVectorBar:j3,LeftDownVector:B3,LeftFloor:U3,leftharpoondown:F3,leftharpoonup:W3,leftleftarrows:$3,leftrightarrow:V3,LeftRightArrow:Y3,Leftrightarrow:G3,leftrightarrows:H3,leftrightharpoons:Q3,leftrightsquigarrow:Z3,LeftRightVector:K3,LeftTeeArrow:q3,LeftTee:X3,LeftTeeVector:J3,leftthreetimes:_3,LeftTriangleBar:e4,LeftTriangle:t4,LeftTriangleEqual:r4,LeftUpDownVector:n4,LeftUpTeeVector:i4,LeftUpVectorBar:s4,LeftUpVector:o4,LeftVectorBar:a4,LeftVector:c4,lEg:l4,leg:u4,leq:h4,leqq:d4,leqslant:f4,lescc:g4,les:p4,lesdot:m4,lesdoto:y4,lesdotor:v4,lesg:M4,lesges:w4,lessapprox:T4,lessdot:S4,lesseqgtr:I4,lesseqqgtr:C4,LessEqualGreater:x4,LessFullEqual:b4,LessGreater:E4,lessgtr:A4,LessLess:N4,lesssim:D4,LessSlantEqual:P4,LessTilde:k4,lfisht:L4,lfloor:R4,Lfr:O4,lfr:z4,lg:j4,lgE:B4,lHar:U4,lhard:F4,lharu:W4,lharul:$4,lhblk:V4,LJcy:Y4,ljcy:G4,llarr:H4,ll:Q4,Ll:Z4,llcorner:K4,Lleftarrow:q4,llhard:X4,lltri:J4,Lmidot:_4,lmidot:eB,lmoustache:tB,lmoust:rB,lnap:nB,lnapprox:iB,lne:sB,lnE:oB,lneq:aB,lneqq:cB,lnsim:lB,loang:uB,loarr:hB,lobrk:dB,longleftarrow:fB,LongLeftArrow:gB,Longleftarrow:pB,longleftrightarrow:mB,LongLeftRightArrow:yB,Longleftrightarrow:vB,longmapsto:MB,longrightarrow:wB,LongRightArrow:TB,Longrightarrow:SB,looparrowleft:IB,looparrowright:CB,lopar:xB,Lopf:bB,lopf:EB,loplus:AB,lotimes:NB,lowast:DB,lowbar:PB,LowerLeftArrow:kB,LowerRightArrow:LB,loz:RB,lozenge:OB,lozf:zB,lpar:jB,lparlt:BB,lrarr:UB,lrcorner:FB,lrhar:WB,lrhard:$B,lrm:VB,lrtri:YB,lsaquo:GB,lscr:HB,Lscr:QB,lsh:ZB,Lsh:KB,lsim:qB,lsime:XB,lsimg:JB,lsqb:_B,lsquo:e5,lsquor:t5,Lstrok:r5,lstrok:n5,ltcc:i5,ltcir:s5,lt:o5,LT:a5,Lt:c5,ltdot:l5,lthree:u5,ltimes:h5,ltlarr:d5,ltquest:f5,ltri:g5,ltrie:p5,ltrif:m5,ltrPar:y5,lurdshar:v5,luruhar:M5,lvertneqq:w5,lvnE:T5,macr:S5,male:I5,malt:C5,maltese:x5,Map:"⤅",map:b5,mapsto:E5,mapstodown:A5,mapstoleft:N5,mapstoup:D5,marker:P5,mcomma:k5,Mcy:L5,mcy:R5,mdash:O5,mDDot:z5,measuredangle:j5,MediumSpace:B5,Mellintrf:U5,Mfr:F5,mfr:W5,mho:$5,micro:V5,midast:Y5,midcir:G5,mid:H5,middot:Q5,minusb:Z5,minus:K5,minusd:q5,minusdu:X5,MinusPlus:J5,mlcp:_5,mldr:eU,mnplus:tU,models:rU,Mopf:nU,mopf:iU,mp:sU,mscr:oU,Mscr:aU,mstpos:cU,Mu:lU,mu:uU,multimap:hU,mumap:dU,nabla:fU,Nacute:gU,nacute:pU,nang:mU,nap:yU,napE:vU,napid:MU,napos:wU,napprox:TU,natural:SU,naturals:IU,natur:CU,nbsp:xU,nbump:bU,nbumpe:EU,ncap:AU,Ncaron:NU,ncaron:DU,Ncedil:PU,ncedil:kU,ncong:LU,ncongdot:RU,ncup:OU,Ncy:zU,ncy:jU,ndash:BU,nearhk:UU,nearr:FU,neArr:WU,nearrow:$U,ne:VU,nedot:YU,NegativeMediumSpace:GU,NegativeThickSpace:HU,NegativeThinSpace:QU,NegativeVeryThinSpace:ZU,nequiv:KU,nesear:qU,nesim:XU,NestedGreaterGreater:JU,NestedLessLess:_U,NewLine:eF,nexist:tF,nexists:rF,Nfr:nF,nfr:iF,ngE:sF,nge:oF,ngeq:aF,ngeqq:cF,ngeqslant:lF,nges:uF,nGg:hF,ngsim:dF,nGt:fF,ngt:gF,ngtr:pF,nGtv:mF,nharr:yF,nhArr:vF,nhpar:MF,ni:wF,nis:TF,nisd:SF,niv:IF,NJcy:CF,njcy:xF,nlarr:bF,nlArr:EF,nldr:AF,nlE:NF,nle:DF,nleftarrow:PF,nLeftarrow:kF,nleftrightarrow:LF,nLeftrightarrow:RF,nleq:OF,nleqq:zF,nleqslant:jF,nles:BF,nless:UF,nLl:FF,nlsim:WF,nLt:$F,nlt:VF,nltri:YF,nltrie:GF,nLtv:HF,nmid:QF,NoBreak:ZF,NonBreakingSpace:KF,nopf:qF,Nopf:XF,Not:JF,not:_F,NotCongruent:eW,NotCupCap:tW,NotDoubleVerticalBar:rW,NotElement:nW,NotEqual:iW,NotEqualTilde:sW,NotExists:oW,NotGreater:aW,NotGreaterEqual:cW,NotGreaterFullEqual:lW,NotGreaterGreater:uW,NotGreaterLess:hW,NotGreaterSlantEqual:dW,NotGreaterTilde:fW,NotHumpDownHump:gW,NotHumpEqual:pW,notin:mW,notindot:yW,notinE:vW,notinva:MW,notinvb:wW,notinvc:TW,NotLeftTriangleBar:SW,NotLeftTriangle:IW,NotLeftTriangleEqual:CW,NotLess:xW,NotLessEqual:bW,NotLessGreater:EW,NotLessLess:AW,NotLessSlantEqual:NW,NotLessTilde:DW,NotNestedGreaterGreater:PW,NotNestedLessLess:kW,notni:LW,notniva:RW,notnivb:OW,notnivc:zW,NotPrecedes:jW,NotPrecedesEqual:BW,NotPrecedesSlantEqual:UW,NotReverseElement:FW,NotRightTriangleBar:WW,NotRightTriangle:$W,NotRightTriangleEqual:VW,NotSquareSubset:YW,NotSquareSubsetEqual:GW,NotSquareSuperset:HW,NotSquareSupersetEqual:QW,NotSubset:ZW,NotSubsetEqual:KW,NotSucceeds:qW,NotSucceedsEqual:XW,NotSucceedsSlantEqual:JW,NotSucceedsTilde:_W,NotSuperset:e$,NotSupersetEqual:t$,NotTilde:r$,NotTildeEqual:n$,NotTildeFullEqual:i$,NotTildeTilde:s$,NotVerticalBar:o$,nparallel:a$,npar:c$,nparsl:l$,npart:u$,npolint:h$,npr:d$,nprcue:f$,nprec:g$,npreceq:p$,npre:m$,nrarrc:y$,nrarr:v$,nrArr:M$,nrarrw:w$,nrightarrow:T$,nRightarrow:S$,nrtri:I$,nrtrie:C$,nsc:x$,nsccue:b$,nsce:E$,Nscr:A$,nscr:N$,nshortmid:D$,nshortparallel:P$,nsim:k$,nsime:L$,nsimeq:R$,nsmid:O$,nspar:z$,nsqsube:j$,nsqsupe:B$,nsub:U$,nsubE:F$,nsube:W$,nsubset:$$,nsubseteq:V$,nsubseteqq:Y$,nsucc:G$,nsucceq:H$,nsup:Q$,nsupE:Z$,nsupe:K$,nsupset:q$,nsupseteq:X$,nsupseteqq:J$,ntgl:_$,Ntilde:eV,ntilde:tV,ntlg:rV,ntriangleleft:nV,ntrianglelefteq:iV,ntriangleright:sV,ntrianglerighteq:oV,Nu:aV,nu:cV,num:lV,numero:uV,numsp:hV,nvap:dV,nvdash:fV,nvDash:gV,nVdash:pV,nVDash:mV,nvge:yV,nvgt:vV,nvHarr:MV,nvinfin:wV,nvlArr:TV,nvle:SV,nvlt:IV,nvltrie:CV,nvrArr:xV,nvrtrie:bV,nvsim:EV,nwarhk:AV,nwarr:NV,nwArr:DV,nwarrow:PV,nwnear:kV,Oacute:LV,oacute:RV,oast:OV,Ocirc:zV,ocirc:jV,ocir:BV,Ocy:UV,ocy:FV,odash:WV,Odblac:$V,odblac:VV,odiv:YV,odot:GV,odsold:HV,OElig:QV,oelig:ZV,ofcir:KV,Ofr:qV,ofr:XV,ogon:JV,Ograve:_V,ograve:eY,ogt:tY,ohbar:rY,ohm:nY,oint:iY,olarr:sY,olcir:oY,olcross:aY,oline:cY,olt:lY,Omacr:uY,omacr:hY,Omega:dY,omega:fY,Omicron:gY,omicron:pY,omid:mY,ominus:yY,Oopf:vY,oopf:MY,opar:wY,OpenCurlyDoubleQuote:TY,OpenCurlyQuote:SY,operp:IY,oplus:CY,orarr:xY,Or:bY,or:EY,ord:AY,order:NY,orderof:DY,ordf:PY,ordm:kY,origof:LY,oror:RY,orslope:OY,orv:zY,oS:jY,Oscr:BY,oscr:UY,Oslash:FY,oslash:WY,osol:$Y,Otilde:VY,otilde:YY,otimesas:GY,Otimes:HY,otimes:QY,Ouml:ZY,ouml:KY,ovbar:qY,OverBar:XY,OverBrace:JY,OverBracket:_Y,OverParenthesis:eG,para:tG,parallel:rG,par:nG,parsim:iG,parsl:sG,part:oG,PartialD:aG,Pcy:cG,pcy:lG,percnt:uG,period:hG,permil:dG,perp:fG,pertenk:gG,Pfr:pG,pfr:mG,Phi:yG,phi:vG,phiv:MG,phmmat:wG,phone:TG,Pi:SG,pi:IG,pitchfork:CG,piv:xG,planck:bG,planckh:EG,plankv:AG,plusacir:NG,plusb:DG,pluscir:PG,plus:kG,plusdo:LG,plusdu:RG,pluse:OG,PlusMinus:zG,plusmn:jG,plussim:BG,plustwo:UG,pm:FG,Poincareplane:WG,pointint:$G,popf:VG,Popf:YG,pound:GG,prap:HG,Pr:QG,pr:ZG,prcue:KG,precapprox:qG,prec:XG,preccurlyeq:JG,Precedes:_G,PrecedesEqual:e8,PrecedesSlantEqual:t8,PrecedesTilde:r8,preceq:n8,precnapprox:i8,precneqq:s8,precnsim:o8,pre:a8,prE:c8,precsim:l8,prime:u8,Prime:h8,primes:d8,prnap:f8,prnE:g8,prnsim:p8,prod:m8,Product:y8,profalar:v8,profline:M8,profsurf:w8,prop:T8,Proportional:S8,Proportion:I8,propto:C8,prsim:x8,prurel:b8,Pscr:E8,pscr:A8,Psi:N8,psi:D8,puncsp:P8,Qfr:k8,qfr:L8,qint:R8,qopf:O8,Qopf:z8,qprime:j8,Qscr:B8,qscr:U8,quaternions:F8,quatint:W8,quest:$8,questeq:V8,quot:Y8,QUOT:G8,rAarr:H8,race:Q8,Racute:Z8,racute:K8,radic:q8,raemptyv:X8,rang:J8,Rang:_8,rangd:e6,range:t6,rangle:r6,raquo:n6,rarrap:i6,rarrb:s6,rarrbfs:o6,rarrc:a6,rarr:c6,Rarr:l6,rArr:u6,rarrfs:h6,rarrhk:d6,rarrlp:f6,rarrpl:g6,rarrsim:p6,Rarrtl:m6,rarrtl:y6,rarrw:v6,ratail:M6,rAtail:w6,ratio:T6,rationals:S6,rbarr:I6,rBarr:C6,RBarr:x6,rbbrk:b6,rbrace:E6,rbrack:A6,rbrke:N6,rbrksld:D6,rbrkslu:P6,Rcaron:k6,rcaron:L6,Rcedil:R6,rcedil:O6,rceil:z6,rcub:j6,Rcy:B6,rcy:U6,rdca:F6,rdldhar:W6,rdquo:$6,rdquor:V6,rdsh:Y6,real:G6,realine:H6,realpart:Q6,reals:Z6,Re:K6,rect:q6,reg:X6,REG:J6,ReverseElement:_6,ReverseEquilibrium:e9,ReverseUpEquilibrium:t9,rfisht:r9,rfloor:n9,rfr:i9,Rfr:s9,rHar:o9,rhard:a9,rharu:c9,rharul:l9,Rho:u9,rho:h9,rhov:d9,RightAngleBracket:f9,RightArrowBar:g9,rightarrow:p9,RightArrow:m9,Rightarrow:y9,RightArrowLeftArrow:v9,rightarrowtail:M9,RightCeiling:w9,RightDoubleBracket:T9,RightDownTeeVector:S9,RightDownVectorBar:I9,RightDownVector:C9,RightFloor:x9,rightharpoondown:b9,rightharpoonup:E9,rightleftarrows:A9,rightleftharpoons:N9,rightrightarrows:D9,rightsquigarrow:P9,RightTeeArrow:k9,RightTee:L9,RightTeeVector:R9,rightthreetimes:O9,RightTriangleBar:z9,RightTriangle:j9,RightTriangleEqual:B9,RightUpDownVector:U9,RightUpTeeVector:F9,RightUpVectorBar:W9,RightUpVector:$9,RightVectorBar:V9,RightVector:Y9,ring:G9,risingdotseq:H9,rlarr:Q9,rlhar:Z9,rlm:K9,rmoustache:q9,rmoust:X9,rnmid:J9,roang:_9,roarr:eH,robrk:tH,ropar:rH,ropf:nH,Ropf:iH,roplus:sH,rotimes:oH,RoundImplies:aH,rpar:cH,rpargt:lH,rppolint:uH,rrarr:hH,Rrightarrow:dH,rsaquo:fH,rscr:gH,Rscr:pH,rsh:mH,Rsh:yH,rsqb:vH,rsquo:MH,rsquor:wH,rthree:TH,rtimes:SH,rtri:IH,rtrie:CH,rtrif:xH,rtriltri:bH,RuleDelayed:EH,ruluhar:AH,rx:NH,Sacute:DH,sacute:PH,sbquo:kH,scap:LH,Scaron:RH,scaron:OH,Sc:zH,sc:jH,sccue:BH,sce:UH,scE:FH,Scedil:WH,scedil:$H,Scirc:VH,scirc:YH,scnap:GH,scnE:HH,scnsim:QH,scpolint:ZH,scsim:KH,Scy:qH,scy:XH,sdotb:JH,sdot:_H,sdote:e7,searhk:t7,searr:r7,seArr:n7,searrow:i7,sect:s7,semi:o7,seswar:a7,setminus:c7,setmn:l7,sext:u7,Sfr:h7,sfr:d7,sfrown:f7,sharp:g7,SHCHcy:p7,shchcy:m7,SHcy:y7,shcy:v7,ShortDownArrow:M7,ShortLeftArrow:w7,shortmid:T7,shortparallel:S7,ShortRightArrow:I7,ShortUpArrow:C7,shy:x7,Sigma:b7,sigma:E7,sigmaf:A7,sigmav:N7,sim:D7,simdot:P7,sime:k7,simeq:L7,simg:R7,simgE:O7,siml:z7,simlE:j7,simne:B7,simplus:U7,simrarr:F7,slarr:W7,SmallCircle:$7,smallsetminus:V7,smashp:Y7,smeparsl:G7,smid:H7,smile:Q7,smt:Z7,smte:K7,smtes:q7,SOFTcy:X7,softcy:J7,solbar:_7,solb:eQ,sol:tQ,Sopf:rQ,sopf:nQ,spades:iQ,spadesuit:sQ,spar:oQ,sqcap:aQ,sqcaps:cQ,sqcup:lQ,sqcups:uQ,Sqrt:hQ,sqsub:dQ,sqsube:fQ,sqsubset:gQ,sqsubseteq:pQ,sqsup:mQ,sqsupe:yQ,sqsupset:vQ,sqsupseteq:MQ,square:wQ,Square:TQ,SquareIntersection:SQ,SquareSubset:IQ,SquareSubsetEqual:CQ,SquareSuperset:xQ,SquareSupersetEqual:bQ,SquareUnion:EQ,squarf:AQ,squ:NQ,squf:DQ,srarr:PQ,Sscr:kQ,sscr:LQ,ssetmn:RQ,ssmile:OQ,sstarf:zQ,Star:jQ,star:BQ,starf:UQ,straightepsilon:FQ,straightphi:WQ,strns:$Q,sub:VQ,Sub:YQ,subdot:GQ,subE:HQ,sube:QQ,subedot:ZQ,submult:KQ,subnE:qQ,subne:XQ,subplus:JQ,subrarr:_Q,subset:eZ,Subset:tZ,subseteq:rZ,subseteqq:nZ,SubsetEqual:iZ,subsetneq:sZ,subsetneqq:oZ,subsim:aZ,subsub:cZ,subsup:lZ,succapprox:uZ,succ:hZ,succcurlyeq:dZ,Succeeds:fZ,SucceedsEqual:gZ,SucceedsSlantEqual:pZ,SucceedsTilde:mZ,succeq:yZ,succnapprox:vZ,succneqq:MZ,succnsim:wZ,succsim:TZ,SuchThat:SZ,sum:IZ,Sum:CZ,sung:xZ,sup1:bZ,sup2:EZ,sup3:AZ,sup:NZ,Sup:DZ,supdot:PZ,supdsub:kZ,supE:LZ,supe:RZ,supedot:OZ,Superset:zZ,SupersetEqual:jZ,suphsol:BZ,suphsub:UZ,suplarr:FZ,supmult:WZ,supnE:$Z,supne:VZ,supplus:YZ,supset:GZ,Supset:HZ,supseteq:QZ,supseteqq:ZZ,supsetneq:KZ,supsetneqq:qZ,supsim:XZ,supsub:JZ,supsup:_Z,swarhk:eK,swarr:tK,swArr:rK,swarrow:nK,swnwar:iK,szlig:sK,Tab:oK,target:aK,Tau:cK,tau:lK,tbrk:uK,Tcaron:hK,tcaron:dK,Tcedil:fK,tcedil:gK,Tcy:pK,tcy:mK,tdot:yK,telrec:vK,Tfr:MK,tfr:wK,there4:TK,therefore:SK,Therefore:IK,Theta:CK,theta:xK,thetasym:bK,thetav:EK,thickapprox:AK,thicksim:NK,ThickSpace:DK,ThinSpace:PK,thinsp:kK,thkap:LK,thksim:RK,THORN:OK,thorn:zK,tilde:jK,Tilde:BK,TildeEqual:UK,TildeFullEqual:FK,TildeTilde:WK,timesbar:$K,timesb:VK,times:YK,timesd:GK,tint:HK,toea:QK,topbot:ZK,topcir:KK,top:qK,Topf:XK,topf:JK,topfork:_K,tosa:eq,tprime:tq,trade:rq,TRADE:nq,triangle:iq,triangledown:sq,triangleleft:oq,trianglelefteq:aq,triangleq:cq,triangleright:lq,trianglerighteq:uq,tridot:hq,trie:dq,triminus:fq,TripleDot:gq,triplus:pq,trisb:mq,tritime:yq,trpezium:vq,Tscr:Mq,tscr:wq,TScy:Tq,tscy:Sq,TSHcy:Iq,tshcy:Cq,Tstrok:xq,tstrok:bq,twixt:Eq,twoheadleftarrow:Aq,twoheadrightarrow:Nq,Uacute:Dq,uacute:Pq,uarr:kq,Uarr:Lq,uArr:Rq,Uarrocir:Oq,Ubrcy:zq,ubrcy:jq,Ubreve:Bq,ubreve:Uq,Ucirc:Fq,ucirc:Wq,Ucy:$q,ucy:Vq,udarr:Yq,Udblac:Gq,udblac:Hq,udhar:Qq,ufisht:Zq,Ufr:Kq,ufr:qq,Ugrave:Xq,ugrave:Jq,uHar:_q,uharl:eX,uharr:tX,uhblk:rX,ulcorn:nX,ulcorner:iX,ulcrop:sX,ultri:oX,Umacr:aX,umacr:cX,uml:lX,UnderBar:uX,UnderBrace:hX,UnderBracket:dX,UnderParenthesis:fX,Union:gX,UnionPlus:pX,Uogon:mX,uogon:yX,Uopf:vX,uopf:MX,UpArrowBar:wX,uparrow:TX,UpArrow:SX,Uparrow:IX,UpArrowDownArrow:CX,updownarrow:xX,UpDownArrow:bX,Updownarrow:EX,UpEquilibrium:AX,upharpoonleft:NX,upharpoonright:DX,uplus:PX,UpperLeftArrow:kX,UpperRightArrow:LX,upsi:RX,Upsi:OX,upsih:zX,Upsilon:jX,upsilon:BX,UpTeeArrow:UX,UpTee:FX,upuparrows:WX,urcorn:$X,urcorner:VX,urcrop:YX,Uring:GX,uring:HX,urtri:QX,Uscr:ZX,uscr:KX,utdot:qX,Utilde:XX,utilde:JX,utri:_X,utrif:eJ,uuarr:tJ,Uuml:rJ,uuml:nJ,uwangle:iJ,vangrt:sJ,varepsilon:oJ,varkappa:aJ,varnothing:cJ,varphi:lJ,varpi:uJ,varpropto:hJ,varr:dJ,vArr:fJ,varrho:gJ,varsigma:pJ,varsubsetneq:mJ,varsubsetneqq:yJ,varsupsetneq:vJ,varsupsetneqq:MJ,vartheta:wJ,vartriangleleft:TJ,vartriangleright:SJ,vBar:IJ,Vbar:CJ,vBarv:xJ,Vcy:bJ,vcy:EJ,vdash:AJ,vDash:NJ,Vdash:DJ,VDash:PJ,Vdashl:kJ,veebar:LJ,vee:RJ,Vee:OJ,veeeq:zJ,vellip:jJ,verbar:BJ,Verbar:UJ,vert:FJ,Vert:WJ,VerticalBar:$J,VerticalLine:VJ,VerticalSeparator:YJ,VerticalTilde:GJ,VeryThinSpace:HJ,Vfr:QJ,vfr:ZJ,vltri:KJ,vnsub:qJ,vnsup:XJ,Vopf:JJ,vopf:_J,vprop:e_,vrtri:t_,Vscr:r_,vscr:n_,vsubnE:i_,vsubne:s_,vsupnE:o_,vsupne:a_,Vvdash:c_,vzigzag:l_,Wcirc:u_,wcirc:h_,wedbar:d_,wedge:f_,Wedge:g_,wedgeq:p_,weierp:m_,Wfr:y_,wfr:v_,Wopf:M_,wopf:w_,wp:T_,wr:S_,wreath:I_,Wscr:C_,wscr:x_,xcap:b_,xcirc:E_,xcup:A_,xdtri:N_,Xfr:D_,xfr:P_,xharr:k_,xhArr:L_,Xi:R_,xi:O_,xlarr:z_,xlArr:j_,xmap:B_,xnis:U_,xodot:F_,Xopf:W_,xopf:$_,xoplus:V_,xotime:Y_,xrarr:G_,xrArr:H_,Xscr:Q_,xscr:Z_,xsqcup:K_,xuplus:q_,xutri:X_,xvee:J_,xwedge:__,Yacute:eee,yacute:tee,YAcy:ree,yacy:nee,Ycirc:iee,ycirc:see,Ycy:oee,ycy:aee,yen:cee,Yfr:lee,yfr:uee,YIcy:hee,yicy:dee,Yopf:fee,yopf:gee,Yscr:pee,yscr:mee,YUcy:yee,yucy:vee,yuml:Mee,Yuml:wee,Zacute:Tee,zacute:See,Zcaron:Iee,zcaron:Cee,Zcy:xee,zcy:bee,Zdot:Eee,zdot:Aee,zeetrf:Nee,ZeroWidthSpace:Dee,Zeta:Pee,zeta:kee,zfr:Lee,Zfr:Ree,ZHcy:Oee,zhcy:zee,zigrarr:jee,zopf:Bee,Zopf:Uee,Zscr:Fee,zscr:Wee,zwj:$ee,zwnj:Vee},Yee="Á",Gee="á",Hee="Â",Qee="â",Zee="´",Kee="Æ",qee="æ",Xee="À",Jee="à",_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="ð",xte="Ë",bte="ë",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="³",xre="ß",bre="Þ",Ere="þ",Are="×",Nre="Ú",Dre="ú",Pre="Û",kre="û",Lre="Ù",Rre="ù",Ore="¨",zre="Ü",jre="ü",Bre="Ý",Ure="ý",Fre="¥",Wre="ÿ",$re={Aacute:Yee,aacute:Gee,Acirc:Hee,acirc:Qee,acute:Zee,AElig:Kee,aelig:qee,Agrave:Xee,agrave:Jee,amp:_ee,AMP:ete,Aring:tte,aring:rte,Atilde:nte,atilde:ite,Auml:ste,auml:ote,brvbar:ate,Ccedil:cte,ccedil:lte,cedil:ute,cent:hte,copy:dte,COPY:fte,curren:gte,deg:pte,divide:mte,Eacute:yte,eacute:vte,Ecirc:Mte,ecirc:wte,Egrave:Tte,egrave:Ste,ETH:Ite,eth:Cte,Euml:xte,euml:bte,frac12:Ete,frac14:Ate,frac34:Nte,gt:Dte,GT:Pte,Iacute:kte,iacute:Lte,Icirc:Rte,icirc:Ote,iexcl:zte,Igrave:jte,igrave:Bte,iquest:Ute,Iuml:Fte,iuml:Wte,laquo:$te,lt:Vte,LT:Yte,macr:Gte,micro:Hte,middot:Qte,nbsp:Zte,not:Kte,Ntilde:qte,ntilde:Xte,Oacute:Jte,oacute:_te,Ocirc:ere,ocirc:tre,Ograve:rre,ograve:nre,ordf:ire,ordm:sre,Oslash:ore,oslash:are,Otilde:cre,otilde:lre,Ouml:ure,ouml:hre,para:dre,plusmn:fre,pound:gre,quot:pre,QUOT:mre,raquo:yre,reg:vre,REG:Mre,sect:wre,shy:Tre,sup1:Sre,sup2:Ire,sup3:Cre,szlig:xre,THORN:bre,thorn:Ere,times:Are,Uacute:Nre,uacute:Dre,Ucirc:Pre,ucirc:kre,Ugrave:Lre,ugrave:Rre,uml:Ore,Uuml:zre,uuml:jre,Yacute:Bre,yacute:Ure,yen:Fre,yuml:Wre},Vre="&",Yre="'",Gre=">",Hre="<",Qre='"',mm={amp:Vre,apos:Yre,gt:Gre,lt:Hre,quot:Qre};var _u={};const Zre={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 Kre=vt&&vt.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(_u,"__esModule",{value:!0});var ff=Kre(Zre),qre=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 Xre(i){return i>=55296&&i<=57343||i>1114111?"�":(i in ff.default&&(i=ff.default[i]),qre(i))}_u.default=Xre;var Wa=vt&&vt.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(Kr,"__esModule",{value:!0});Kr.decodeHTML=Kr.decodeHTMLStrict=Kr.decodeXML=void 0;var Wl=Wa(pm),Jre=Wa($re),_re=Wa(mm),gf=Wa(_u),ene=/&(?:[a-zA-Z0-9]+|#[xX][\da-fA-F]+|#\d+);/g;Kr.decodeXML=ym(_re.default);Kr.decodeHTMLStrict=ym(Wl.default);function ym(i){var t=vm(i);return function(e){return String(e).replace(ene,t)}}var pf=function(i,t){return i<t?1:-1};Kr.decodeHTML=function(){for(var i=Object.keys(Jre.default).sort(pf),t=Object.keys(Wl.default).sort(pf),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=vm(Wl.default);function o(a){return a.substr(-1)!==";"&&(a+=";"),s(a)}return function(a){return String(a).replace(n,o)}}();function vm(i){return function(e){if(e.charAt(1)==="#"){var r=e.charAt(2);return r==="X"||r==="x"?gf.default(parseInt(e.substr(3),16)):gf.default(parseInt(e.substr(2),10))}return i[e.slice(1,-1)]||e}}var tr={},Mm=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 tne=Mm(mm),wm=Sm(tne.default),Tm=Im(wm);tr.encodeXML=bm(wm);var rne=Mm(pm),eh=Sm(rne.default),nne=Im(eh);tr.encodeHTML=sne(eh,nne);tr.encodeNonAsciiHTML=bm(eh);function Sm(i){return Object.keys(i).sort().reduce(function(t,e){return t[i[e]]="&"+e+";",t},{})}function Im(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 Cm=/(?:[\x80-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/g,ine=String.prototype.codePointAt!=null?function(i){return i.codePointAt(0)}:function(i){return(i.charCodeAt(0)-55296)*1024+i.charCodeAt(1)-56320+65536};function $a(i){return"&#x"+(i.length>1?ine(i):i.charCodeAt(0)).toString(16).toUpperCase()+";"}function sne(i,t){return function(e){return e.replace(t,function(r){return i[r]}).replace(Cm,$a)}}var xm=new RegExp(Tm.source+"|"+Cm.source,"g");function one(i){return i.replace(xm,$a)}tr.escape=one;function ane(i){return i.replace(Tm,$a)}tr.escapeUTF8=ane;function bm(i){return function(t){return t.replace(xm,function(e){return i[e]||$a(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=Kr,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=Kr;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}})})(gm);const cne={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"},lne={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"},une={elementNames:cne,attributeNames:lne};var To=fm,Em=gm,Va=une;Va.elementNames.__proto__=null;Va.attributeNames.__proto__=null;var hne={__proto__:null,style:!0,script:!0,xmp:!0,iframe:!0,noembed:!0,noframes:!0,plaintext:!0,noscript:!0};function dne(i,t){if(i){var e="",r;for(var n in i)r=i[n],e&&(e+=" "),t.xmlMode==="foreign"&&(n=Va.attributeNames[n]||n),e+=n,(r!==null&&r!==""||t.xmlMode)&&(e+='="'+(t.decodeEntities?Em.encodeXML(r):r.replace(/\"/g,"""))+'"');return e}}var fne={__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},Am=dm.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+=Am(n.children,t):To.isTag(n)?e+=pne(n,t):n.type===To.Directive?e+=mne(n):n.type===To.Comment?e+=Mne(n):n.type===To.CDATA?e+=vne(n):e+=yne(n,t)}return e},gne=["mi","mo","mn","ms","mtext","annotation-xml","foreignObject","desc","title"];function pne(i,t){t.xmlMode==="foreign"&&(i.name=Va.elementNames[i.name]||i.name,i.parent&&gne.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=dne(i.attribs,t);return r&&(e+=" "+r),t.xmlMode&&(!i.children||i.children.length===0)?e+="/>":(e+=">",i.children&&(e+=Am(i.children,t)),(!fne[i.name]||t.xmlMode)&&(e+="</"+i.name+">")),e}function mne(i){return"<"+i.data+">"}function yne(i,t){var e=i.data||"";return t.decodeEntities&&!(i.parent&&i.parent.name in hne)&&(e=Em.encodeXML(e)),e}function vne(i){return"<![CDATA["+i.children[0].data+"]]>"}function Mne(i){return"<!--"+i.data+"-->"}var wne=dm.exports,$l=Ju,Nm=wne,Tne=$l.isTag,Sne={getInnerHTML:Ine,getOuterHTML:Nm,getText:Go};function Ine(i,t){return i.children?i.children.map(function(e){return Nm(e,t)}).join(""):""}function Go(i){return Array.isArray(i)?i.map(Go).join(""):Tne(i)?i.name==="br"?`
|
|
569
|
-
`:Go(i.children):i.type===$l.CDATA?Go(i.children):i.type===$l.Text?i.data:""}var si={},Cne=si.getChildren=function(i){return i.children},xne=si.getParent=function(i){return i.parent};si.getSiblings=function(i){var t=xne(i);return t?Cne(t):[i]};si.getAttributeValue=function(i,t){return i.attribs&&i.attribs[t]};si.hasAttrib=function(i,t){return!!i.attribs&&hasOwnProperty.call(i.attribs,t)};si.getName=function(i){return i.name};var $i={};$i.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)}};$i.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}};$i.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}};$i.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)};$i.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 th=Ju.isTag,bne={filter:Ene,find:rh,findOneChild:Ane,findOne:Dm,existsOne:Pm,findAll:Nne};function Ene(i,t,e,r){return Array.isArray(t)||(t=[t]),(typeof r!="number"||!isFinite(r))&&(r=1/0),rh(i,t,e!==!1,r)}function rh(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=rh(i,s,e,r),n=n.concat(s),r-=s.length,r<=0)));o++);return n}function Ane(i,t){for(var e=0,r=t.length;e<r;e++)if(i(t[e]))return t[e];return null}function Dm(i,t){for(var e=null,r=0,n=t.length;r<n&&!e;r++)if(th(t[r]))i(t[r])?e=t[r]:t[r].children.length>0&&(e=Dm(i,t[r].children));else continue;return e}function Pm(i,t){for(var e=0,r=t.length;e<r;e++)if(th(t[e])&&(i(t[e])||t[e].children.length>0&&Pm(i,t[e].children)))return!0;return!1}function Nne(i,t){for(var e=[],r=t.slice();r.length;){var n=r.shift();th(n)&&(n.children&&n.children.length>0&&r.unshift.apply(r,n.children),i(n)&&e.push(n))}return e}var oi={},Dne=Ju,Fn=oi.isTag=Dne.isTag;oi.testElement=function(i,t){for(var e in i)if(i.hasOwnProperty(e)){if(e==="tag_name"){if(!Fn(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(Fn(t)||!i.tag_contains(t.data))return!1}else if(!t.attribs||!i[e](t.attribs[e]))return!1}return!0};var ra={tag_name:function(i){return typeof i=="function"?function(t){return Fn(t)&&i(t.name)}:i==="*"?Fn:function(t){return Fn(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!Fn(t)&&i(t.data)}:function(t){return!Fn(t)&&t.data===i}}};function km(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 Pne(i,t){return function(e){return i(e)||t(e)}}oi.getElements=function(i,t,e,r){var n=Object.keys(i).map(function(s){var o=i[s];return s in ra?ra[s](o):km(s,o)});return n.length===0?[]:this.filter(n.reduce(Pne),t,e,r)};oi.getElementById=function(i,t,e){return Array.isArray(t)||(t=[t]),this.findOne(km("id",i),t,e!==!1)};oi.getElementsByTagName=function(i,t,e,r){return this.filter(ra.tag_name(i),t,e,r)};oi.getElementsByTagType=function(i,t,e,r){return this.filter(ra.tag_type(i),t,e,r)};var Ya={};Ya.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},kne=Ya.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)};Ya.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=kne(n,s);return o&Wr.PRECEDING?-1:o&Wr.FOLLOWING?1:0}),i};(function(i){var t=i.exports;[Sne,si,$i,bne,oi,Ya].forEach(function(e){Object.keys(e).forEach(function(r){t[r]=e[r].bind(t)})})})(hm);var Lne=hm.exports,Gs={trueFunc:function(){return!0},falseFunc:function(){return!1}},Lm={},na={};Object.defineProperty(na,"__esModule",{value:!0});na.default=Fne;var mf=/^[^\\]?(?:\\(?:[\da-f]{1,6}\s?|.)|[\w\-\u00b0-\uFFFF])+/,Rne=/\\([\da-f]{1,6}\s?|(\s)|.)/gi,One=/^\s*((?:\\.|[\w\u00b0-\uFFFF-])+)\s*(?:(\S?)=\s*(?:(['"])((?:[^\\]|\\[^])*?)\3|(#?(?:\\.|[\w\u00b0-\uFFFF-])*)|)|)\s*(i)?\]/,zne={undefined:"exists","":"equals","~":"element","^":"start",$:"end","*":"any","!":"not","|":"hyphen"},yf={">":"child","<":"parent","~":"sibling","+":"adjacent"},vf={"#":["id","equals"],".":["class","element"]},jne=new Set(["has","not","matches","is","host","host-context"]),Bne=new Set(["contains","icontains"]),Mf=new Set(['"',"'"]);function Une(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 So(i){return i.replace(Rne,Une)}function wf(i){return i===" "||i===`
|
|
570
|
-
`||i===" "||i==="\f"||i==="\r"}function Fne(i,t){var e=[];if(i=Rm(e,""+i,t),i!=="")throw new Error("Unmatched selector: "+i);return e}function Rm(i,t,e){var r,n;e===void 0&&(e={});var s=[],o=!1;function a(){var N=t.match(mf);if(!N)throw new Error("Expected name, found "+t);var A=N[0];return t=t.substr(A.length),So(A)}function c(N){for(;wf(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(wf(u))o=!0,c(1);else if(u in yf)s.push({type:yf[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 vf){var h=vf[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(One);if(!p)throw new Error("Malformed attribute selector: "+t);var M=p[0],I=p[1],D=p[2],C=p[4],B=C===void 0?"":C,T=p[5],f=T===void 0?B:T,m=p[6];t=t.substr(M.length);var w=So(I);((r=e.lowerCaseAttributeNames)!==null&&r!==void 0?r:!e.xmlMode)&&(w=w.toLowerCase()),s.push({type:"attribute",name:w,action:zne[D],value:So(f),ignoreCase:!!m})}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 v=a().toLowerCase(),b=null;if(t.startsWith("("))if(jne.has(v)){var x=t.charAt(1),z=Mf.has(x);if(t=t.substr(z?2:1),b=[],t=Rm(b,t,e),z)if(t.startsWith(x))t=t.substr(1);else throw new Error("Unmatched quotes in :"+v);if(!t.startsWith(")"))throw new Error("Missing closing parenthesis in :"+v+" ("+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),Bne.has(v)){var x=b.charAt(0);x===b.slice(-1)&&Mf.has(x)&&(b=b.slice(1,-1)),b=So(b)}}s.push({type:"pseudo",name:v,data:b})}else if(mf.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(),Tf(i,s),t}return Tf(i,s),t}function Tf(i,t){if(i.length>0&&t.length===0)throw new Error("Empty sub-selector");i.push(t)}var nh={},Wne=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(nh,"__esModule",{value:!0});var Vl={equals:"",element:"~",start:"^",end:"$",any:"*",not:"!",hyphen:"|"},$ne=new Set(Wne(Object.keys(Vl).map(function(i){return Vl[i]}).filter(Boolean),[":","[","]"," ","\\"]));function Om(i){return i.map(Vne).join(", ")}nh.default=Om;function Vne(i){return i.map(Yne).join("")}function Yne(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)+"("+Om(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)+Vl[i.action]+"='"+Ir(i.value)+"'"+(i.ignoreCase?"i":"")+"]"}}function Ir(i){return i.split("").map(function(t){return $ne.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(na,i);var n=na;Object.defineProperty(i,"parse",{enumerable:!0,get:function(){return r(n).default}});var s=nh;Object.defineProperty(i,"stringify",{enumerable:!0,get:function(){return r(s).default}})})(Lm);const Gne=50,Hne=30,Qne=1,Zne=0,Kne=-1,qne=-1,Xne=-1,Jne=-1,_ne=-1,zm={universal:Gne,tag:Hne,attribute:Qne,pseudo:Zne,descendant:Kne,child:qne,parent:Xne,sibling:Jne,adjacent:_ne};var eie=tie,qc=zm,Sf={__proto__:null,exists:10,equals:8,not:7,start:6,end:6,any:5,hyphen:4,element:4};function tie(i){for(var t=i.map(jm),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 jm(i){var t=qc[i.type];if(t===qc.attribute)t=Sf[i.action],t===Sf.equals&&i.name==="id"&&(t=9),i.ignoreCase&&(t>>=1);else if(t===qc.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=jm(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 Io=Gs.falseFunc,If=/[-[\]{}()*+?.,\\^$|#\s]/g,Cf={__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 Io;n=n.replace(If,"\\$&");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?Io: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?Io: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 Io;if(t.ignoreCase){var o=new RegExp(n.replace(If,"\\$&"),"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)}}},Bm={compile:function(i,t,e){if(e&&e.strict&&(t.ignoreCase||t.action==="not"))throw new Error("Unsupported attribute selector");return Cf[t.action](i,t,e)},rules:Cf},Ga={exports:{}},rie=iie,nie=/^([+\-]?\d*n)?\s*(?:([+\-]?)\s*(\d+))?$/;function iie(i){if(i=i.trim().toLowerCase(),i==="even")return[2,0];if(i==="odd")return[2,1];var t=i.match(nie);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 sie=cie,Um=Gs,oie=Um.trueFunc,aie=Um.falseFunc;function cie(i){var t=i[0],e=i[1]-1;if(e<0&&t<=0)return aie;if(t===-1)return function(n){return n<=e};if(t===0)return function(n){return n===e};if(t===1)return e<0?oie: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 Fm=rie,Wm=sie;Ga.exports=function(t){return Wm(Fm(t))};Ga.exports.parse=Fm;Ga.exports.compile=Wm;var lie=Ga.exports,Co=lie,$m=Gs,uie=Bm,ms=$m.trueFunc,ln=$m.falseFunc,hie=uie.rules.equals;function kn(i,t){var e={name:i,value:t};return function(n,s,o){return hie(n,e,o)}}function xo(i,t){return function(e){return!!t.getParent(e)&&i(e)}}var Ho={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=Co(t),n=e.adapter;return r===ln?r:r===ms?xo(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=Co(t),n=e.adapter;return r===ln?r:r===ms?xo(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=Co(t),n=e.adapter;return r===ln?r:r===ms?xo(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=Co(t),n=e.adapter;return r===ln?r:r===ms?xo(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 Ho.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:kn("type","checkbox"),file:kn("type","file"),password:kn("type","password"),radio:kn("type","radio"),reset:kn("type","reset"),image:kn("type","image"),submit:kn("type","submit"),hover:function(i,t,e){var r=e.adapter;return typeof r.isHovered=="function"?function(s){return i(s)&&r.isHovered(s)}:ln},visited:function(i,t,e){var r=e.adapter;return typeof r.isVisited=="function"?function(s){return i(s)&&r.isVisited(s)}:ln},active:function(i,t,e){var r=e.adapter;return typeof r.isActive=="function"?function(s){return i(s)&&r.isActive(s)}:ln}};function die(i,t){for(var e=0;i&&e<i.length;e++)if(t.isTag(i[e]))return i[e]}var Ss={empty:function(i,t){return!t.getChildren(i).some(function(e){return t.isTag(e)||e.type==="text"})},"first-child":function(i,t){return die(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")||Ss.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!Ss.empty(i,t)},header:xf(["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:xf(["input","textarea","select","button"]),text:function(i,t){var e;return t.getName(i)==="input"&&(!(e=t.getAttributeValue(i,"type"))||e.toLowerCase()==="text")}};function xf(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 fie(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 gie=/^(?:(?:nth|last|first|only)-(?:child|of-type)|root|empty|(?:en|dis)abled|checked|not)$/,Vm={compile:function(i,t,e,r){var n=t.name,s=t.data,o=e.adapter;if(e&&e.strict&&!gie.test(n))throw new Error(":"+n+" isn't part of CSS3");if(typeof Ho[n]=="function")return Ho[n](i,s,e,r);if(typeof Ss[n]=="function"){var a=Ss[n];return fie(a,n,s),a===ln?a:i===ms?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:Ho,pseudos:Ss},pie=Bm,mie=Vm,yie={__proto__:null,attribute:pie.compile,pseudo:mie.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}},vie=Ha,Mie=Lm.parse,Ym=Gs,wie=eie,Tie=zm,bf=yie,Gm=Vm,Ns=Ym.trueFunc,Sn=Ym.falseFunc,ih=Gm.filters;function Ha(i,t,e){var r=Qm(i,t,e);return Hm(r,t)}function Hm(i,t){var e=t.adapter;return function(n){return e.isTag(n)&&i(n)}}function Qm(i,t,e){var r=Mie(i,t);return Hs(r,t,e)}function Yl(i){return i.type==="pseudo"&&(i.name==="scope"||Array.isArray(i.data)&&i.data.some(function(t){return t.some(Yl)}))}var Sie={type:"descendant"},Iie={type:"_flexibleDescendant"},Cie={type:"pseudo",name:"scope"},Zm={};function xie(i,t,e){var r=t.adapter,n=!!e&&!!e.length&&e.every(function(s){return s===Zm||!!r.getParent(s)});i.forEach(function(s){if(!(s.length>0&&Km(s[0])&&s[0].type!=="descendant"))if(n&&!(Array.isArray(s)?s.some(Yl):Yl(s)))s.unshift(Sie);else return;s.unshift(Cie)})}function Hs(i,t,e){i=i.filter(function(o){return o.length>0}),i.forEach(wie);var r=Array.isArray(e);e=t&&t.context||e,e&&!r&&(e=[e]),xie(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]=Iie:(a==="adjacent"||a==="sibling")&&(n=!0)}return bie(o,t,e)}).reduce(Eie,Sn);return s.shouldTestNextSiblings=n,s}function Km(i){return Tie[i.type]<0}function bie(i,t,e){return i.reduce(function(r,n){if(r===Sn)return r;if(!(n.type in bf))throw new Error("Rule type "+n.type+" is not supported by css-select");return bf[n.type](r,n,t,e)},t&&t.rootFunc||Ns)}function Eie(i,t){return t===Sn||i===Ns?i:i===Sn||t===Ns?t:function(r){return i(r)||t(r)}}function qm(i){return i.some(Km)}ih.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(qm)))throw new Error("complex selectors in :not aren't allowed in strict mode");var s=Hs(t,n,r);return s===Sn?i:s===Ns?Sn:function(a){return!s(a)&&i(a)}};ih.has=function(i,t,e){var r=e.adapter,n={xmlMode:!!(e&&e.xmlMode),strict:!!(e&&e.strict),adapter:r},s=t.some(qm)?[Zm]:null,o=Hs(t,n,s);return o===Sn?Sn:o===Ns?function(c){return r.getChildren(c).some(r.isTag)&&i(c)}:(o=Hm(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))})};ih.matches=function(i,t,e,r){var n={xmlMode:!!(e&&e.xmlMode),strict:!!(e&&e.strict),rootFunc:i,adapter:e.adapter};return Hs(t,n,r)};Ha.compileToken=Hs;Ha.compileUnsafe=Qm;Ha.Pseudos=Gm;var Aie=Tr,sh=Lne,Xm=Gs.falseFunc,Qs=vie;function Jm(i){return function(e,r,n){return r=r||{},r.adapter=r.adapter||sh,i(e,r,n)}}var oh=Jm(Qs),_m=Jm(Qs.compileUnsafe);function ey(i){return function(e,r,n){return n=n||{},n.adapter=n.adapter||sh,typeof e!="function"&&(e=_m(e,n,r)),e.shouldTestNextSiblings&&(r=Die(n&&n.context||r,n.adapter)),Array.isArray(r)?r=n.adapter.removeSubsets(r):r=n.adapter.getChildren(r),i(e,r,n)}}function Nie(i,t){var e=t.getSiblings(i);if(!Array.isArray(e))return[];for(e=e.slice(0);e.shift()!==i;);return e}function Die(i,t){Array.isArray(i)||(i=[i]);for(var e=i.slice(0),r=0,n=i.length;r<n;r++){var s=Nie(e[r],t);e.push.apply(e,s)}return e}var ah=ey(function(t,e,r){return t===Xm||!e||e.length===0?[]:r.adapter.findAll(t,e)}),Pie=ey(function(t,e,r){return t===Xm||!e||e.length===0?null:r.adapter.findOne(t,e)});function kie(i,t,e){return e=e||{},e.adapter=e.adapter||sh,(typeof t=="function"?t:oh(t,e))(i)}function Tr(i,t,e){return ah(i,t,e)}Tr.compile=oh;Tr.filters=Qs.Pseudos.filters;Tr.pseudos=Qs.Pseudos.pseudos;Tr.selectAll=ah;Tr.selectOne=Pie;Tr.is=kie;Tr.parse=oh;Tr.iterate=ah;Tr._compileUnsafe=_m;Tr._compileToken=Qs.compileToken;const ty=Jr(Aie);qe(Array);function bo(i){return i.nodeType===1||$t.isSpriteNode(i.nodeName)}function mi(i){return Array.from(i.childNodes||[])}function Gl(i){return $t.isSpriteNode(i.nodeName)?i.parent||i.canvas||i.container:i.parentElement}function Lie(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=Gl(r)}n&&(i[t]=e)}return i}const ch={isTag:bo,existsOne(i,t){return t.some(e=>bo(e)?i(e)||ch.existsOne(i,mi(e)):!1)},getSiblings(i){const t=Gl(i);return t&&mi(t)},getChildren:mi,getParent:Gl,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:Lie,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=mi(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(!bo(e[n]))continue;t(e[n])&&r.push(e[n]);const o=mi(e[n]);o&&(r=r.concat(i(t,o)))}return r},getText:function i(t){return Array.isArray(t)?t.map(i).join(""):bo(t)?i(mi(t)):t.nodeType===3?t.nodeValue:$t.isSpriteNode(t.nodeName)?t.text:""}};function ry(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 Eo(i,t){return ty.selectAll(ry(i),t,{adapter:ch})}function Ef(i,t){return ty.selectOne(ry(i),t,{adapter:ch})}qe(Array);const Af=Symbol("zOrder"),pt=Symbol("ordered"),Dt=Symbol("children"),Xc=Symbol("sealed"),ya=class ya extends Ys{constructor(t={}){super(t),this[Dt]=[],this[pt]=null,this[Af]=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[Af]++),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[Xc]&&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 Ef(`#${t}`,this)}getElementsByClassName(t){return Eo(`.${t}`,this)}getElementsByName(t){return Eo(`[name="${t}"]`,this)}getElementsByTagName(t){return Eo(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 Ef(t,this)}querySelectorAll(t){return Eo(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 ya&&(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[Xc]=!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[Xc]||super.updateContours()}};L(ya,"Attr",bI);let dt=ya;$t.registerNode(dt,"group");qe(Array);const Hl={};function ia(i,t){if(Hl[i])return Hl[i];const e=ht.ENV.loadImage(i,{alias:t,useImageBitmap:!1});return e??i}async function ny(i,t,e){let r=t;if(typeof t=="string"&&(r=ia(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 iy(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 sy(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 Jc=Symbol("textureContext");function oy(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[Jc]&&i[Jc]!==s||n.image!==e||n.options.repeat!==c||!Tl(n.options.rect,a)||!Tl(n.options.srcRect,l)){const u=iy(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[Jc]=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 Rie(i,t){typeof t=="string"&&(t=await(await fetch(t,{method:"GET",mode:"cors",cache:"default"})).json());const e=await ia(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]]),Hl[n]={image:e,sourceRect:u,rotated:h}}),e}qe(Array);const Oie={antialias:!0,autoRender:!0,alpha:!0},Ao=Symbol("autoRender"),ts=Symbol("renderer"),Nf=Symbol("timeline"),zt=Symbol("prepareRender"),_c=Symbol("tickRender"),rn=Symbol("pass"),Ln=Symbol("fbo"),yi=Symbol("tickers"),nn=Symbol("layerTransformInvert");function zie(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({},Oie,t);this[Ao]=r.autoRender,delete t.autoRender;const n=r.Renderer||ht.Renderer;this[ts]=new n(e,r),zie(this[ts]),this.options=t,this.id=t.id,this[rn]=[],this.setResolution(e),this.canvas=e,this[Nf]=new am,this.__mouseCapturedTarget=null,this[nn]=null}get autoRender(){return this[Ao]}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[rn]}get prepareRender(){return this[zt]?this[zt]:Promise.resolve()}get renderer(){return this[ts]}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[Nf]}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[nn])return this[nn];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[nn]=qo(Array.of(0,0,0,0,0,0),t),this[nn])}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[rn].push(l),this.forceUpdate(),l}return null}deleteTexture(t){return sy(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[Ao]&&(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[Ln]||this[Ln].width!==e||this[Ln].height!==r)?(this[Ln]={width:e,height:r,target:t.createFBO(),buffer:t.createFBO(),swap(){[this.target,this.buffer]=[this.buffer,this.target]}},this[Ln]):this[Ln]?this[Ln]:null}updateGlobalTransform(){if(this.layerTransformInvert){const t=this.renderer,e=t.__globalTransformMatrix||t.globalTransformMatrix;t.__globalTransformMatrix=e;const r=Hn(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[nn];if(this[nn]=null,this.updateGlobalTransform(),n&&!this.layerTransformInvert){const s=this.renderer,o=s.__globalTransformMatrix||s.globalTransformMatrix;s.setGlobalTransform(...o)}}}_prepareRenderFinished(){this[zt]&&(this[zt]._requestID&&Zn(this[zt]._requestID),this[zt]._resolve(),delete this[zt])}render({clear:t=!0}={}){const e=this[rn].length?this.getFBO():null;e&&this.renderer.glRenderer.bindFBO(e.target),t&&this[ts].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[rn].length,{width:o,height:a}=this.getResolution(),c=[0,0,o/this.displayRatio,a/this.displayRatio];this[rn].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[ts].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[rn].length&&this[rn].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[nn]=null,this.updateGlobalTransform(),this.forceUpdate())}tick(t=null,{duration:e=1/0,...r}={}){const n=this.timeline.fork(r),s=this;this[yi]=this[yi]||[],this[yi].push({handler:t,duration:e});const o=()=>{let a=null,c=null;const l=()=>{const u=this[yi].map(({handler:h,duration:d})=>{const g=Math.min(1,n.currentTime/d);return{value:h?h(n.currentTime,g):null,p:g}});s[_c]||(s[_c]=Promise.resolve().then(()=>{s[Ao]&&s.render(),delete s[_c];for(let h=u.length-1;h>=0;h--){const{value:d,p:g}=u[h];(d===!1||g>=1)&&this[yi].splice(h,1)}this[yi].length>0&&o()}))};if(this[zt]&&this[zt]._type!=="ticker"&&(Zn(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 Df=Symbol("inited");let ay=null;typeof Worker=="function"&&(ay=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[Df])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[Df]=!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}})}});const No=ay;qe(Array);function jie(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 M=0;M<g.length;M++){const I=g[M],D=I.identifier,{clientX:C,clientY:B}=I;C!=null&&B!=null&&o.push({x:Math.round((C|0)-a),y:Math.round((B|0)-c),identifier:D})}o.length<=0&&o.push({x:n,y:s});const p=[];return o.forEach(M=>{M.x!=null&&M.y!=null&&(n=(M.x*h/l-e)/r,s=(M.y*d/u-t)/r);const I=new Kn(i);Object.defineProperties(I,{layerX:{value:n,configurable:!0},layerY:{value:s,configurable:!0},originalX:{value:M.x},originalY:{value:M.y},x:{value:n,configurable:!0},y:{value:s,configurable:!0},identifier:{value:M.identifier}}),p.push(I)}),p}qe(Array);const Qo=Symbol("enteredTargets");function Pf(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 kf(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 Lf(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 el={};function Bie(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[Qo];if(n.size){const s=new Kn("mouseleave");s.setOriginalEvent(r),[...n].forEach(o=>{o.dispatchEvent(s)}),i[Qo].clear()}},{passive:!0}),t.forEach(r=>{e.addEventListener(r,n=>{const{left:s,top:o,displayRatio:a}=i.options,c=i.orderedChildren;jie(n,{offsetLeft:s,offsetTop:o,displayRatio:a}).forEach(u=>{const h=u.identifier;if(u.type==="touchmove"||u.type==="touchend"){const g=el[h];g&&g.dispatchEvent(u),u.type==="touchend"&&delete el[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"&&(el[h]=u.target),u.type==="mousemove"){const g=i[Qo];let p;if(d){const D=d.ancestors||[];p=new Set([d,...D])}else p=new Set;const M=Object.entries(n);if(!g.has(d)&&d){const D=new Kn("mouseenter");D.setOriginalEvent(n),M.forEach(([B,T])=>{D[B]=T}),g.add(d),d.dispatchEvent(D);const C=d.ancestors;C&&C.forEach(B=>{B instanceof Ua&&!g.has(B)&&(g.add(B),B.dispatchEvent(D))})}const I=new Kn("mouseleave");I.setOriginalEvent(n),M.forEach(([D,C])=>{I[D]=C}),[...g].forEach(D=>{p.has(D)||(g.delete(D),D.dispatchEvent(I))})}})},{passive:r!=="contextmenu"})})}function Do(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 rs=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[Qo]=new Set,this.setResolution(t),Bie(this),this[rs]=0}get hasOffscreenCanvas(){return this[rs]>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 No)&&Pf(t);const e=super.appendChild(t),r=t.canvas;return t.offscreen?this[rs]++:this.container.appendChild(r),Do(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 No)&&Pf(t);const r=super.insertBefore(t,e),n=t.canvas;if(!t.offscreen){const s=kf(this,t);this.container.insertBefore(n,s)}return Do(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 No(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=ia(o);else if(Array.isArray(o))a=Rie(...o);else{const{id:c,src:l}=o;a=ia(l,c)}a instanceof Promise||(a=Promise.resolve(a)),r.push(a.then(c=>{e.push(c),n[s]=c;const l=new Kn({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[rs]--}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(),Lf(s,c)}r.length=0,s.render({clear:!1})}else s.prepareRender&&s.render();else s.offscreen?e?(s.prepareRender&&s.render(),Lf(e,s)):r.push(s):s instanceof No&&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[rs]--;const n=t.canvas;if(!t.offscreen){const s=kf(this,t);this.container.insertBefore(n,s)}return Do(this.options,n),t.setResolution(this.getResolution()),r}resize(){const t=this.options;this.children.forEach(e=>{Do(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 cy={exports:{}};(function(i,t){(function(e,r){i.exports=r()})(vt,function(){var e=function(){function x(z,E){var O=[],V=!0,N=!1,A=void 0;try{for(var P=z[Symbol.iterator](),U;!(V=(U=P.next()).done)&&(O.push(U.value),!(E&&O.length===E));V=!0);}catch(Q){N=!0,A=Q}finally{try{!V&&P.return&&P.return()}finally{if(N)throw A}}return O}return function(z,E){if(Array.isArray(z))return z;if(Symbol.iterator in Object(z))return x(z,E);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),r=Math.PI*2,n=function(z,E,O,V,N,A,P){var U=z.x,Q=z.y;U*=E,Q*=O;var K=V*U-N*Q,ce=N*U+V*Q;return{x:K+A,y:ce+P}},s=function(z,E){var O=1.3333333333333333*Math.tan(E/4),V=Math.cos(z),N=Math.sin(z),A=Math.cos(z+E),P=Math.sin(z+E);return[{x:V-N*O,y:N+V*O},{x:A+P*O,y:P-A*O},{x:A,y:P}]},o=function(z,E,O,V){var N=z*V-E*O<0?-1:1,A=Math.sqrt(z*z+E*E),P=Math.sqrt(z*z+E*E),U=z*O+E*V,Q=U/(A*P);return Q>1&&(Q=1),Q<-1&&(Q=-1),N*Math.acos(Q)},a=function(z,E,O,V,N,A,P,U,Q,K,ce,k){var W=Math.pow(N,2),H=Math.pow(A,2),$=Math.pow(ce,2),ee=Math.pow(k,2),ie=W*H-W*ee-H*$;ie<0&&(ie=0),ie/=W*ee+H*$,ie=Math.sqrt(ie)*(P===U?-1:1);var le=ie*N/A*k,pe=ie*-A/N*ce,we=K*le-Q*pe+(z+O)/2,R=Q*le+K*pe+(E+V)/2,j=(ce-le)/N,X=(k-pe)/A,ae=(-ce-le)/N,q=(-k-pe)/A,te=o(1,0,j,X),y=o(j,X,ae,q);return U===0&&y>0&&(y-=r),U===1&&y<0&&(y+=r),[we,R,te,y]},c=function(z){var E=z.px,O=z.py,V=z.cx,N=z.cy,A=z.rx,P=z.ry,U=z.xAxisRotation,Q=U===void 0?0:U,K=z.largeArcFlag,ce=K===void 0?0:K,k=z.sweepFlag,W=k===void 0?0:k,H=[];if(A===0||P===0)return[];var $=Math.sin(Q*r/360),ee=Math.cos(Q*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),P=Math.abs(P);var pe=Math.pow(ie,2)/Math.pow(A,2)+Math.pow(le,2)/Math.pow(P,2);pe>1&&(A*=Math.sqrt(pe),P*=Math.sqrt(pe));var we=a(E,O,V,N,A,P,ce,W,$,ee,ie,le),R=e(we,4),j=R[0],X=R[1],ae=R[2],q=R[3],te=Math.max(Math.ceil(Math.abs(q)/(r/4)),1);q/=te;for(var y=0;y<te;y++)H.push(s(ae,q)),ae+=q;return H.map(function(S){var F=n(S[0],A,P,ee,$,j,X),Y=F.x,_=F.y,re=n(S[1],A,P,ee,$,j,X),ne=re.x,J=re.y,se=n(S[2],A,P,ee,$,j,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(x){var z=[];return x.replace(u,function(E,O,V){var N=O.toLowerCase();for(V=g(V),N=="m"&&V.length>2&&(z.push([O].concat(V.splice(0,2))),N="l",O=O=="m"?"l":"L");;){if(V.length==l[N])return V.unshift(O),z.push(V);if(V.length<l[N])throw new Error("malformed path data");z.push([O].concat(V.splice(0,l[N])))}}),z}var d=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function g(x){var z=x.match(d);return z?z.map(Number):[]}function p(x){var z=x[0][0],E=x[0][1],O=z,V=E;return x.forEach(function(N){var A=N[0],P=N[2],U=N[4],Q=N[6],K=N[1],ce=N[3],k=N[5],W=N[7];z=Math.min(z,A,P,U,Q),E=Math.min(E,K,ce,k,W),O=Math.max(O,A,P,U,Q),V=Math.max(V,K,ce,k,W)}),[z,E,O,V]}function M(x,z){return Math.sqrt(Math.pow(x[0]-z[0],2)+Math.pow(x[1]-z[1],2))+Math.sqrt(Math.pow(x[2]-z[2],2)+Math.pow(x[3]-z[3],2))}function I(x,z){var E=x[0],O=x[2],V=x[4],N=x[6],A=x[1],P=x[3],U=x[5],Q=x[7],K=z[0],ce=z[2],k=z[4],W=z[6],H=z[1],$=z[3],ee=z[5],ie=z[7];return Math.sqrt(Math.pow(K-E,2)+Math.pow(H-A,2))+Math.sqrt(Math.pow(ce-O,2)+Math.pow($-P,2))+Math.sqrt(Math.pow(k-V,2)+Math.pow(ee-U,2))+Math.sqrt(Math.pow(W-N,2)+Math.pow(ie-Q,2))}function D(x,z){var E=B(x.length),O=[];E.forEach(function(N){var A=0,P=0;N.forEach(function(U){A+=I(x[U],z[P++])}),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(x[N])}),V}function C(x,z){var E=T(x.length),O=[];E.forEach(function(N){var A=0;N.forEach(function(P){A+=M(p(x[P]),p(z[P]))}),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(x[N])}),V}function B(x){for(var z=[],E=0;E<x;E++){for(var O=[],V=0;V<x;V++){var N=V+E;N>x-1&&(N-=x),O[N]=V}z.push(O)}return z}function T(x){for(var z=[],E=0;E<x;E++)z.push(E);return f(z)}function f(x){var z=[],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&&z.push(E.slice()),O(V),V.splice(N,0,A),E.pop();return z}return O(x)}var m={};m.parser=h,m.lerpCurve=function(x,z,E){return m.lerpPoints(x[0],x[1],z[0],z[1],E).concat(m.lerpPoints(x[2],x[3],z[2],z[3],E)).concat(m.lerpPoints(x[4],x[5],z[4],z[5],E)).concat(m.lerpPoints(x[6],x[7],z[6],z[7],E))},m.lerpPoints=function(x,z,E,O,V){return[x+(E-x)*V,z+(O-z)*V]},m.q2b=function(x,z,E,O,V,N){return[x,z,(x+2*E)/3,(z+2*O)/3,(V+2*E)/3,(N+2*O)/3,V,N]},m.path2shapes=function(x){for(var z=m.parser(x),E=0,O=0,V=0,N=z.length,A=[],P=null,U=void 0,Q=void 0,K=void 0,ce=void 0,k=void 0,W=void 0,H=void 0;V<N;V++){var $=z[V],ee=$[0],ie=z[V-1];switch(ee){case"m":k=A.length,A[k]=[],P=A[k],E=E+$[1],O=O+$[2];break;case"M":k=A.length,A[k]=[],P=A[k],E=$[1],O=$[2];break;case"l":P.push([E,O,E,O,E,O,E+$[1],O+$[2]]),E+=$[1],O+=$[2];break;case"L":P.push([E,O,$[1],$[2],$[1],$[2],$[1],$[2]]),E=$[1],O=$[2];break;case"h":P.push([E,O,E,O,E,O,E+$[1],O]),E+=$[1];break;case"H":P.push([E,O,$[1],O,$[1],O,$[1],O]),E=$[1];break;case"v":P.push([E,O,E,O,E,O,E,O+$[1]]),O+=$[1];break;case"V":P.push([E,O,E,$[1],E,$[1],E,$[1]]),O=$[1];break;case"C":P.push([E,O,$[1],$[2],$[3],$[4],$[5],$[6]]),E=$[5],O=$[6];break;case"S":ie[0]==="C"||ie[0]==="c"?P.push([E,O,E+ie[5]-ie[3],O+ie[6]-ie[4],$[1],$[2],$[3],$[4]]):(ie[0]==="S"||ie[0]==="s")&&P.push([E,O,E+ie[3]-ie[1],O+ie[4]-ie[2],$[1],$[2],$[3],$[4]]),E=$[3],O=$[4];break;case"c":P.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"?P.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")&&P.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?P.push([E,O,le.x1,le.y1,le.x2,le.y2,le.x,le.y]):P.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?P.push([E,O,le.x1,le.y1,le.x2,le.y2,le.x,le.y]):P.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":P.push(m.q2b(E,O,$[1],$[2],$[3],$[4])),E=$[3],O=$[4];break;case"q":P.push(m.q2b(E,O,E+$[1],O+$[2],$[3]+E,$[4]+O)),E+=$[3],O+=$[4];break;case"T":ie[0]==="Q"||ie[0]==="q"?(K=E+ie[3]-ie[1],ce=O+ie[4]-ie[2],P.push(m.q2b(E,O,K,ce,$[1],$[2]))):(ie[0]==="T"||ie[0]==="t")&&(P.push(m.q2b(E,O,E+E-K,O+O-ce,$[1],$[2])),K=E+E-K,ce=O+O-ce),E=$[1],O=$[2];break;case"t":ie[0]==="Q"||ie[0]==="q"?(K=E+ie[3]-ie[1],ce=O+ie[4]-ie[2],P.push(m.q2b(E,O,K,ce,E+$[1],O+$[2]))):(ie[0]==="T"||ie[0]==="t")&&(P.push(m.q2b(E,O,E+E-K,O+O-ce,E+$[1],O+$[2])),K=E+E-K,ce=O+O-ce),E+=$[1],O+=$[2];break;case"Z":U=P[0][0],Q=P[0][1],P.push([E,O,U,Q,U,Q,U,Q]);break;case"z":U=P[0][0],Q=P[0][1],P.push([E,O,U,Q,U,Q,U,Q]);break}}return A},m._upCurves=function(x,z){for(var E=0,O=0,V=x.length;E<z;E++)x.push(x[O].slice(0)),O++,O>V-1&&(O-=V)};function w(x,z,E,O,V,N,A,P,U){return{left:v(x,z,E,O,V,N,A,P,U),right:v(A,P,V,N,E,O,x,z,1-U,!0)}}function v(x,z,E,O,V,N,A,P,U,Q){var K=(E-x)*U+x,ce=(O-z)*U+z,k=(V-E)*U+E,W=(N-O)*U+O,H=(A-V)*U+V,$=(P-N)*U+N,ee=(k-K)*U+K,ie=(W-ce)*U+ce,le=(H-k)*U+k,pe=($-W)*U+W,we=(le-ee)*U+ee,R=(pe-ie)*U+ie;return Q?[we,R,ee,ie,K,ce,x,z]:[x,z,K,ce,ee,ie,we,R]}m._splitCurves=function(x,z){for(var E=0,O=0;E<z;E++){var V=x[O],N=w(V[0],V[1],V[2],V[3],V[4],V[5],V[6],V[7],.5);x.splice(O,1),x.splice(O,0,N.left,N.right),O+=2,O>=x.length-1&&(O=0)}};function b(x,z){for(var E=function(N){var A=x[x.length-1],P=[];A.forEach(function(U){P.push(U.slice(0))}),x.push(P)},O=0;O<z;O++)E()}return m.lerp=function(x,z,E){return m._lerp(m.path2shapes(x),m.path2shapes(z),E)},m.MIM_CURVES_COUNT=100,m._preprocessing=function(x,z){var E=x.length,O=z.length,V=JSON.parse(JSON.stringify(x)),N=JSON.parse(JSON.stringify(z));return E>O?b(N,E-O):E<O&&b(V,O-E),V=C(V,N),V.forEach(function(A,P){var U=A.length,Q=N[P].length;U>Q?U<m.MIM_CURVES_COUNT?(m._splitCurves(A,m.MIM_CURVES_COUNT-U),m._splitCurves(N[P],m.MIM_CURVES_COUNT-Q)):m._splitCurves(N[P],U-Q):U<Q&&(Q<m.MIM_CURVES_COUNT?(m._splitCurves(A,m.MIM_CURVES_COUNT-U),m._splitCurves(N[P],m.MIM_CURVES_COUNT-Q)):m._splitCurves(A,Q-U))}),V.forEach(function(A,P){V[P]=D(A,N[P])}),[V,N]},m._lerp=function(x,z,E){var O=[];return x.forEach(function(V,N){var A=[];V.forEach(function(P,U){A.push(m.lerpCurve(P,z[N][U],E))}),O.push(A)}),O},m.animate=function(x){var z=m.path2shapes(x.from),E=m.path2shapes(x.to),O=m._preprocessing(z,E),V=new Date,N=x.end||function(){},A=x.progress||function(){},P=x.begin||function(){},U=x.easing||function(W){return W},Q=null,K=null,ce=x.time;P(z);var k=function W(){var H=new Date-V;if(H>=ce){K=E,A(K,1),N(K),cancelAnimationFrame(Q);return}var $=U(H/ce);K=m._lerp(O[0],O[1],$),A(K,$),Q=requestAnimationFrame(W)};k()},m})})(cy);var Uie=cy.exports;const Po=Jr(Uie);qe(Array);const Fie=Symbol.for("spritejs_setAttributeDefault"),Pt=Symbol.for("spritejs_setAttribute"),kt=Symbol.for("spritejs_getAttribute");let Za=class extends Su{constructor(t){super(t),this[Fie]({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 Ua{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=Po._preprocessing(Po.path2shapes(e),Po.path2shapes(r)),l=Po._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&&ea(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;ta(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&&oy(this,e),t}getBoundingClientRect(){let t=null;return this.mesh&&(t=this.mesh.boundingBox),um(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;ea(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;ta(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"&&ny(this,e)}updateContours(){this.path=new ht.Figure2D,this.path.addPath(this.attributes.d),this.attributes.normalize&&this.path.normalize(...this.path.boundingCenter)}}L(Zt,"Attr",Za);$t.registerNode(Zt,"path");qe(Array);function Wie(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 $ie=Symbol.for("spritejs_setAttributeDefault"),sn=Symbol.for("spritejs_setAttribute"),ns=Symbol.for("spritejs_getAttribute"),Vie=Symbol.for("spritejs_declareAlias");function ko(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=Wie(s,r):s.length&&(o=`M${s.map(a=>a.join(" ")).join("L")}`),o&&n&&(o+="Z"),o}let Yie=class extends Za{constructor(t){super(t),this[$ie]({points:[],smooth:!1,smoothRange:[0],closeType:"none"}),this[Vie]("close")}get d(){return this[ns]("d")}set d(t){}get close(){return this.closeType!=="none"}set close(t){t=t?"normal":"none",this.closeType=t}get closeType(){return this[ns]("closeType")}set closeType(t){if(t!=null&&t!=="none"&&t!=="normal")throw new TypeError("Invalid closeType type.");if(this[sn]("closeType",t)){const e=ko(this);this[sn]("d",e)}}get smooth(){return this[ns]("smooth")}set smooth(t){if(this[sn]("smooth",t)){const e=ko(this);this[sn]("d",e)}}get smoothRange(){return this[ns]("smoothRange")}set smoothRange(t){if(t&&!Array.isArray(t)&&(t=[t]),this[sn]("smoothRange",t)&&this.smooth){const e=ko(this);this[sn]("d",e)}}get points(){return this[ns]("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[sn]("points",t)){const e=ko(this);this[sn]("d",e)}}};qe(Array);class wr extends Zt{get isVisible(){const{points:t}=this.attributes;return t.length>0&&super.isVisible}}L(wr,"Attr",Yie);$t.registerNode(wr,"polyline");qe(Array);const Gie=Symbol.for("spritejs_setAttributeDefault"),Lo=Symbol.for("spritejs_setAttribute"),tl=Symbol.for("spritejs_getAttribute"),Hie=Symbol.for("spritejs_declareAlias");function Rf(i){const{width:t,height:e}=i;return`M0 0L${t} 0L${t} ${e}L0 ${e}Z`}let Qie=class extends Za{constructor(t){super(t),this[Gie]({width:0,height:0}),this[Hie]("size")}get d(){return this[tl]("d")}set d(t){}get width(){return this[tl]("width")}set width(t){if(t=Qe(t),this[Lo]("width",t)){const e=Rf(this);this[Lo]("d",e)}}get height(){return this[tl]("height")}set height(t){if(t=Qe(t),this[Lo]("height",t)){const e=Rf(this);this[Lo]("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 Ds extends Zt{get isVisible(){const{width:t,height:e}=this.attributes;return t>0&&e>0&&super.isVisible}}L(Ds,"Attr",Qie);$t.registerNode(Ds,"rect");qe(Array);const Zie=Symbol.for("spritejs_setAttributeDefault"),dr=Symbol.for("spritejs_setAttribute"),Rn=Symbol.for("spritejs_getAttribute"),Kie=Symbol.for("spritejs_declareAlias");function is(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 qie=class extends Za{constructor(t){super(t),this[Zie]({radiusX:0,radiusY:0,startAngle:0,endAngle:360,direction:"clockwise",closeType:"none"}),this[Kie]("radius","angle")}get d(){return this[Rn]("d")}set d(t){}get radiusX(){return this[Rn]("radiusX")}set radiusX(t){if(t=Qe(t),this[dr]("radiusX",t)){const e=is(this);this[dr]("d",e)}}get radiusY(){return this[Rn]("radiusY")}set radiusY(t){if(t=Qe(t),this[dr]("radiusY",t)){const e=is(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[Rn]("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[Rn]("startAngle")}set startAngle(t){if(t=Qe(t),this[dr]("startAngle",t)){const e=is(this);this[dr]("d",e)}}get endAngle(){return this[Rn]("endAngle")}set endAngle(t){if(t=Qe(t),this[dr]("endAngle",t)){const e=is(this);this[dr]("d",e)}}get closeType(){return this[Rn]("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=is(this);this[dr]("d",e)}}};qe(Array);class lh extends Zt{get isVisible(){const{radiusX:t,radiusY:e,startAngle:r,endAngle:n}=this.attributes;return t>0&&e>0&&r!==n&&super.isVisible}}L(lh,"Attr",qie);$t.registerNode(lh,"ellipse");qe(Array);const Xie=Symbol.for("spritejs_setAttributeDefault"),Ro=Symbol.for("spritejs_setAttribute"),Oo=Symbol.for("spritejs_getAttribute");let Jie=class extends Fa{constructor(t){super(t),this[Xie]({texture:void 0,textureRect:void 0,textureRepeat:!1,sourceRect:void 0})}get texture(){return this[Oo]("texture")}set texture(t){this[Ro]("texture",t)}get textureRect(){return this[Oo]("textureRect")}set textureRect(t){this[Ro]("textureRect",t)}get sourceRect(){return this[Oo]("sourceRect")}set sourceRect(t){this[Ro]("sourceRect",t)}get textureRepeat(){return this[Oo]("textureRepeat")}set textureRepeat(t){this[Ro]("textureRepeat",!!t)}};qe(Array);const Of=Symbol("textureTask");class Ka extends Ys{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[Of]||Promise.resolve()}draw(t=[]){super.draw(t);const e=this.mesh;return e&&oy(this,e),t}onPropertyChange(t,e,r){if(super.onPropertyChange(t,e,r),t==="texture"&&(this[Of]=ny(this,e,!0)),t==="textureRect"){const{width:n,height:s}=this.attributes;(n==null||s==null)&&this.updateContours()}}}L(Ka,"Attr",Jie);$t.registerNode(Ka,"sprite");qe(Array);const _ie=Symbol.for("spritejs_setAttributeDefault"),Jt=Symbol.for("spritejs_setAttribute"),_t=Symbol.for("spritejs_getAttribute"),ese=Symbol.for("spritejs_declareAlias");let tse=class extends Fa{constructor(t){super(t),this[_ie]({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[ese]("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 vi=Symbol("textImage"),zo=Symbol("textImageTask"),rl=Symbol("textureContext"),ss=Symbol("updateTextureRect"),nl=Symbol("textCanvas");class uh extends Ys{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[vi];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[vi]||{}}get textImageReady(){return this[zo]||Promise.resolve()}draw(t){super.draw(t);const e=this.mesh;if(e){const r=this[vi];if(r){let n=e.texture;if(!n||this[rl]&&this[rl]!==this.renderer||r.needsUpdate?(r.needsUpdate=!1,sy(r.image,this.renderer),n=iy(r.image,this.renderer),this[ss]=!0):n=e.uniforms.u_texSampler,this[ss]){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:M,paddingTop:I}=this.attributes,{borderWidth:D}=this.attributes;h+=M+D,p+=I+D;const{anchorX:C,anchorY:B}=this.attributes;h-=this.offsetSize[0]*C,p-=this.offsetSize[1]*B,e.setTexture(n,{rect:[h,p,s,o]}),this[ss]=!1,this[rl]=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[ss]=!0),super.onPropertyChange(t,e,r))}updateContours(){super.updateContours(),this[ss]=!0}updateText(){this[zo]||(this[zo]=Promise.resolve().then(()=>{this[zo]=null;const{text:t,font:e,fillColor:r,strokeColor:n,strokeWidth:s}=this.attributes,o=this.layer?this.layer.displayRatio:1;return this[nl]=this[nl]||ht.ENV.createCanvas(1,1),this[vi]=ht.ENV.createText(t,{font:e,fillColor:r,strokeColor:n,strokeWidth:s,parseFont:ht.parseFont,ratio:o,textCanvas:this[nl]}),this[vi].needsUpdate=!0,this.updateContours(),this.forceUpdate(),this[vi]}))}}L(uh,"Attr",tse);$t.registerNode(uh,"label");qe(Array);function rse(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 nse{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=rse(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 M=p&&p.getContext("2d");if(!M)return!1;M.clearRect(0,0,d,g),M.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 ise=typeof vt=="object"&&vt&&vt.Object===Object&&vt,ly=ise,sse=ly,ose=typeof self=="object"&&self&&self.Object===Object&&self,ase=sse||ose||Function("return this")(),Sr=ase,cse=Sr,lse=cse.Symbol,Zs=lse,zf=Zs,uy=Object.prototype,use=uy.hasOwnProperty,hse=uy.toString,os=zf?zf.toStringTag:void 0;function dse(i){var t=use.call(i,os),e=i[os];try{i[os]=void 0;var r=!0}catch{}var n=hse.call(i);return r&&(t?i[os]=e:delete i[os]),n}var fse=dse,gse=Object.prototype,pse=gse.toString;function mse(i){return pse.call(i)}var yse=mse,jf=Zs,vse=fse,Mse=yse,wse="[object Null]",Tse="[object Undefined]",Bf=jf?jf.toStringTag:void 0;function Sse(i){return i==null?i===void 0?Tse:wse:Bf&&Bf in Object(i)?vse(i):Mse(i)}var ai=Sse;function Ise(i){return i!=null&&typeof i=="object"}var Nr=Ise,Cse=ai,xse=Nr,bse="[object Number]";function Ese(i){return typeof i=="number"||xse(i)&&Cse(i)==bse}var Ase=Ese;const It=Jr(Ase);function Nse(){this.__data__=[],this.size=0}var Dse=Nse;function Pse(i,t){return i===t||i!==i&&t!==t}var hh=Pse,kse=hh;function Lse(i,t){for(var e=i.length;e--;)if(kse(i[e][0],t))return e;return-1}var qa=Lse,Rse=qa,Ose=Array.prototype,zse=Ose.splice;function jse(i){var t=this.__data__,e=Rse(t,i);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():zse.call(t,e,1),--this.size,!0}var Bse=jse,Use=qa;function Fse(i){var t=this.__data__,e=Use(t,i);return e<0?void 0:t[e][1]}var Wse=Fse,$se=qa;function Vse(i){return $se(this.__data__,i)>-1}var Yse=Vse,Gse=qa;function Hse(i,t){var e=this.__data__,r=Gse(e,i);return r<0?(++this.size,e.push([i,t])):e[r][1]=t,this}var Qse=Hse,Zse=Dse,Kse=Bse,qse=Wse,Xse=Yse,Jse=Qse;function Vi(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])}}Vi.prototype.clear=Zse;Vi.prototype.delete=Kse;Vi.prototype.get=qse;Vi.prototype.has=Xse;Vi.prototype.set=Jse;var Xa=Vi,_se=Xa;function eoe(){this.__data__=new _se,this.size=0}var toe=eoe;function roe(i){var t=this.__data__,e=t.delete(i);return this.size=t.size,e}var noe=roe;function ioe(i){return this.__data__.get(i)}var soe=ioe;function ooe(i){return this.__data__.has(i)}var aoe=ooe;function coe(i){var t=typeof i;return i!=null&&(t=="object"||t=="function")}var En=coe,loe=ai,uoe=En,hoe="[object AsyncFunction]",doe="[object Function]",foe="[object GeneratorFunction]",goe="[object Proxy]";function poe(i){if(!uoe(i))return!1;var t=loe(i);return t==doe||t==foe||t==hoe||t==goe}var hy=poe,moe=Sr,yoe=moe["__core-js_shared__"],voe=yoe,il=voe,Uf=function(){var i=/[^.]+$/.exec(il&&il.keys&&il.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function Moe(i){return!!Uf&&Uf in i}var woe=Moe,Toe=Function.prototype,Soe=Toe.toString;function Ioe(i){if(i!=null){try{return Soe.call(i)}catch{}try{return i+""}catch{}}return""}var dy=Ioe,Coe=hy,xoe=woe,boe=En,Eoe=dy,Aoe=/[\\^$.*+?()[\]{}|]/g,Noe=/^\[object .+?Constructor\]$/,Doe=Function.prototype,Poe=Object.prototype,koe=Doe.toString,Loe=Poe.hasOwnProperty,Roe=RegExp("^"+koe.call(Loe).replace(Aoe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ooe(i){if(!boe(i)||xoe(i))return!1;var t=Coe(i)?Roe:Noe;return t.test(Eoe(i))}var zoe=Ooe;function joe(i,t){return i==null?void 0:i[t]}var Boe=joe,Uoe=zoe,Foe=Boe;function Woe(i,t){var e=Foe(i,t);return Uoe(e)?e:void 0}var ci=Woe,$oe=ci,Voe=Sr,Yoe=$oe(Voe,"Map"),dh=Yoe,Goe=ci,Hoe=Goe(Object,"create"),Ja=Hoe,Ff=Ja;function Qoe(){this.__data__=Ff?Ff(null):{},this.size=0}var Zoe=Qoe;function Koe(i){var t=this.has(i)&&delete this.__data__[i];return this.size-=t?1:0,t}var qoe=Koe,Xoe=Ja,Joe="__lodash_hash_undefined__",_oe=Object.prototype,eae=_oe.hasOwnProperty;function tae(i){var t=this.__data__;if(Xoe){var e=t[i];return e===Joe?void 0:e}return eae.call(t,i)?t[i]:void 0}var rae=tae,nae=Ja,iae=Object.prototype,sae=iae.hasOwnProperty;function oae(i){var t=this.__data__;return nae?t[i]!==void 0:sae.call(t,i)}var aae=oae,cae=Ja,lae="__lodash_hash_undefined__";function uae(i,t){var e=this.__data__;return this.size+=this.has(i)?0:1,e[i]=cae&&t===void 0?lae:t,this}var hae=uae,dae=Zoe,fae=qoe,gae=rae,pae=aae,mae=hae;function Yi(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])}}Yi.prototype.clear=dae;Yi.prototype.delete=fae;Yi.prototype.get=gae;Yi.prototype.has=pae;Yi.prototype.set=mae;var yae=Yi,Wf=yae,vae=Xa,Mae=dh;function wae(){this.size=0,this.__data__={hash:new Wf,map:new(Mae||vae),string:new Wf}}var Tae=wae;function Sae(i){var t=typeof i;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?i!=="__proto__":i===null}var Iae=Sae,Cae=Iae;function xae(i,t){var e=i.__data__;return Cae(t)?e[typeof t=="string"?"string":"hash"]:e.map}var _a=xae,bae=_a;function Eae(i){var t=bae(this,i).delete(i);return this.size-=t?1:0,t}var Aae=Eae,Nae=_a;function Dae(i){return Nae(this,i).get(i)}var Pae=Dae,kae=_a;function Lae(i){return kae(this,i).has(i)}var Rae=Lae,Oae=_a;function zae(i,t){var e=Oae(this,i),r=e.size;return e.set(i,t),this.size+=e.size==r?0:1,this}var jae=zae,Bae=Tae,Uae=Aae,Fae=Pae,Wae=Rae,$ae=jae;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=Bae;Gi.prototype.delete=Uae;Gi.prototype.get=Fae;Gi.prototype.has=Wae;Gi.prototype.set=$ae;var fy=Gi,Vae=Xa,Yae=dh,Gae=fy,Hae=200;function Qae(i,t){var e=this.__data__;if(e instanceof Vae){var r=e.__data__;if(!Yae||r.length<Hae-1)return r.push([i,t]),this.size=++e.size,this;e=this.__data__=new Gae(r)}return e.set(i,t),this.size=e.size,this}var Zae=Qae,Kae=Xa,qae=toe,Xae=noe,Jae=soe,_ae=aoe,ece=Zae;function Hi(i){var t=this.__data__=new Kae(i);this.size=t.size}Hi.prototype.clear=qae;Hi.prototype.delete=Xae;Hi.prototype.get=Jae;Hi.prototype.has=_ae;Hi.prototype.set=ece;var gy=Hi;function tce(i,t){for(var e=-1,r=i==null?0:i.length;++e<r&&t(i[e],e,i)!==!1;);return i}var rce=tce,nce=ci,ice=function(){try{var i=nce(Object,"defineProperty");return i({},"",{}),i}catch{}}(),py=ice,$f=py;function sce(i,t,e){t=="__proto__"&&$f?$f(i,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):i[t]=e}var my=sce,oce=my,ace=hh,cce=Object.prototype,lce=cce.hasOwnProperty;function uce(i,t,e){var r=i[t];(!(lce.call(i,t)&&ace(r,e))||e===void 0&&!(t in i))&&oce(i,t,e)}var yy=uce,hce=yy,dce=my;function fce(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?dce(e,a,c):hce(e,a,c)}return e}var ec=fce;function gce(i,t){for(var e=-1,r=Array(i);++e<i;)r[e]=t(e);return r}var pce=gce,mce=ai,yce=Nr,vce="[object Arguments]";function Mce(i){return yce(i)&&mce(i)==vce}var wce=Mce,Vf=wce,Tce=Nr,vy=Object.prototype,Sce=vy.hasOwnProperty,Ice=vy.propertyIsEnumerable,Cce=Vf(function(){return arguments}())?Vf:function(i){return Tce(i)&&Sce.call(i,"callee")&&!Ice.call(i,"callee")},My=Cce,xce=Array.isArray,Ks=xce,sa={exports:{}};function bce(){return!1}var Ece=bce;sa.exports;(function(i,t){var e=Sr,r=Ece,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})(sa,sa.exports);var fh=sa.exports,Ace=9007199254740991,Nce=/^(?:0|[1-9]\d*)$/;function Dce(i,t){var e=typeof i;return t=t??Ace,!!t&&(e=="number"||e!="symbol"&&Nce.test(i))&&i>-1&&i%1==0&&i<t}var Pce=Dce,kce=9007199254740991;function Lce(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=kce}var wy=Lce,Rce=ai,Oce=wy,zce=Nr,jce="[object Arguments]",Bce="[object Array]",Uce="[object Boolean]",Fce="[object Date]",Wce="[object Error]",$ce="[object Function]",Vce="[object Map]",Yce="[object Number]",Gce="[object Object]",Hce="[object RegExp]",Qce="[object Set]",Zce="[object String]",Kce="[object WeakMap]",qce="[object ArrayBuffer]",Xce="[object DataView]",Jce="[object Float32Array]",_ce="[object Float64Array]",ele="[object Int8Array]",tle="[object Int16Array]",rle="[object Int32Array]",nle="[object Uint8Array]",ile="[object Uint8ClampedArray]",sle="[object Uint16Array]",ole="[object Uint32Array]",at={};at[Jce]=at[_ce]=at[ele]=at[tle]=at[rle]=at[nle]=at[ile]=at[sle]=at[ole]=!0;at[jce]=at[Bce]=at[qce]=at[Uce]=at[Xce]=at[Fce]=at[Wce]=at[$ce]=at[Vce]=at[Yce]=at[Gce]=at[Hce]=at[Qce]=at[Zce]=at[Kce]=!1;function ale(i){return zce(i)&&Oce(i.length)&&!!at[Rce(i)]}var cle=ale;function lle(i){return function(t){return i(t)}}var tc=lle,oa={exports:{}};oa.exports;(function(i,t){var e=ly,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})(oa,oa.exports);var gh=oa.exports,ule=cle,hle=tc,Yf=gh,Gf=Yf&&Yf.isTypedArray,dle=Gf?hle(Gf):ule,Ty=dle,fle=pce,gle=My,ple=Ks,mle=fh,yle=Pce,vle=Ty,Mle=Object.prototype,wle=Mle.hasOwnProperty;function Tle(i,t){var e=ple(i),r=!e&&gle(i),n=!e&&!r&&mle(i),s=!e&&!r&&!n&&vle(i),o=e||r||n||s,a=o?fle(i.length,String):[],c=a.length;for(var l in i)(t||wle.call(i,l))&&!(o&&(l=="length"||n&&(l=="offset"||l=="parent")||s&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||yle(l,c)))&&a.push(l);return a}var Sy=Tle,Sle=Object.prototype;function Ile(i){var t=i&&i.constructor,e=typeof t=="function"&&t.prototype||Sle;return i===e}var ph=Ile;function Cle(i,t){return function(e){return i(t(e))}}var Iy=Cle,xle=Iy,ble=xle(Object.keys,Object),Ele=ble,Ale=ph,Nle=Ele,Dle=Object.prototype,Ple=Dle.hasOwnProperty;function kle(i){if(!Ale(i))return Nle(i);var t=[];for(var e in Object(i))Ple.call(i,e)&&e!="constructor"&&t.push(e);return t}var Lle=kle,Rle=hy,Ole=wy;function zle(i){return i!=null&&Ole(i.length)&&!Rle(i)}var mh=zle,jle=Sy,Ble=Lle,Ule=mh;function Fle(i){return Ule(i)?jle(i):Ble(i)}var yh=Fle,Wle=ec,$le=yh;function Vle(i,t){return i&&Wle(t,$le(t),i)}var Yle=Vle;function Gle(i){var t=[];if(i!=null)for(var e in Object(i))t.push(e);return t}var Hle=Gle,Qle=En,Zle=ph,Kle=Hle,qle=Object.prototype,Xle=qle.hasOwnProperty;function Jle(i){if(!Qle(i))return Kle(i);var t=Zle(i),e=[];for(var r in i)r=="constructor"&&(t||!Xle.call(i,r))||e.push(r);return e}var _le=Jle,eue=Sy,tue=_le,rue=mh;function nue(i){return rue(i)?eue(i,!0):tue(i)}var vh=nue,iue=ec,sue=vh;function oue(i,t){return i&&iue(t,sue(t),i)}var aue=oue,aa={exports:{}};aa.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})(aa,aa.exports);var cue=aa.exports;function lue(i,t){var e=-1,r=i.length;for(t||(t=Array(r));++e<r;)t[e]=i[e];return t}var uue=lue;function hue(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 Cy=hue;function due(){return[]}var xy=due,fue=Cy,gue=xy,pue=Object.prototype,mue=pue.propertyIsEnumerable,Hf=Object.getOwnPropertySymbols,yue=Hf?function(i){return i==null?[]:(i=Object(i),fue(Hf(i),function(t){return mue.call(i,t)}))}:gue,Mh=yue,vue=ec,Mue=Mh;function wue(i,t){return vue(i,Mue(i),t)}var Tue=wue;function Sue(i,t){for(var e=-1,r=t.length,n=i.length;++e<r;)i[n+e]=t[e];return i}var wh=Sue,Iue=Iy,Cue=Iue(Object.getPrototypeOf,Object),by=Cue,xue=wh,bue=by,Eue=Mh,Aue=xy,Nue=Object.getOwnPropertySymbols,Due=Nue?function(i){for(var t=[];i;)xue(t,Eue(i)),i=bue(i);return t}:Aue,Ey=Due,Pue=ec,kue=Ey;function Lue(i,t){return Pue(i,kue(i),t)}var Rue=Lue,Oue=wh,zue=Ks;function jue(i,t,e){var r=t(i);return zue(i)?r:Oue(r,e(i))}var Ay=jue,Bue=Ay,Uue=Mh,Fue=yh;function Wue(i){return Bue(i,Fue,Uue)}var Ny=Wue,$ue=Ay,Vue=Ey,Yue=vh;function Gue(i){return $ue(i,Yue,Vue)}var Hue=Gue,Que=ci,Zue=Sr,Kue=Que(Zue,"DataView"),que=Kue,Xue=ci,Jue=Sr,_ue=Xue(Jue,"Promise"),ehe=_ue,the=ci,rhe=Sr,nhe=the(rhe,"Set"),Dy=nhe,ihe=ci,she=Sr,ohe=ihe(she,"WeakMap"),ahe=ohe,Ql=que,Zl=dh,Kl=ehe,ql=Dy,Xl=ahe,Py=ai,Qi=dy,Qf="[object Map]",che="[object Object]",Zf="[object Promise]",Kf="[object Set]",qf="[object WeakMap]",Xf="[object DataView]",lhe=Qi(Ql),uhe=Qi(Zl),hhe=Qi(Kl),dhe=Qi(ql),fhe=Qi(Xl),Bn=Py;(Ql&&Bn(new Ql(new ArrayBuffer(1)))!=Xf||Zl&&Bn(new Zl)!=Qf||Kl&&Bn(Kl.resolve())!=Zf||ql&&Bn(new ql)!=Kf||Xl&&Bn(new Xl)!=qf)&&(Bn=function(i){var t=Py(i),e=t==che?i.constructor:void 0,r=e?Qi(e):"";if(r)switch(r){case lhe:return Xf;case uhe:return Qf;case hhe:return Zf;case dhe:return Kf;case fhe:return qf}return t});var rc=Bn,ghe=Object.prototype,phe=ghe.hasOwnProperty;function mhe(i){var t=i.length,e=new i.constructor(t);return t&&typeof i[0]=="string"&&phe.call(i,"index")&&(e.index=i.index,e.input=i.input),e}var yhe=mhe,vhe=Sr,Mhe=vhe.Uint8Array,ky=Mhe,Jf=ky;function whe(i){var t=new i.constructor(i.byteLength);return new Jf(t).set(new Jf(i)),t}var Th=whe,The=Th;function She(i,t){var e=t?The(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.byteLength)}var Ihe=She,Che=/\w*$/;function xhe(i){var t=new i.constructor(i.source,Che.exec(i));return t.lastIndex=i.lastIndex,t}var bhe=xhe,_f=Zs,eg=_f?_f.prototype:void 0,tg=eg?eg.valueOf:void 0;function Ehe(i){return tg?Object(tg.call(i)):{}}var Ahe=Ehe,Nhe=Th;function Dhe(i,t){var e=t?Nhe(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.length)}var Phe=Dhe,khe=Th,Lhe=Ihe,Rhe=bhe,Ohe=Ahe,zhe=Phe,jhe="[object Boolean]",Bhe="[object Date]",Uhe="[object Map]",Fhe="[object Number]",Whe="[object RegExp]",$he="[object Set]",Vhe="[object String]",Yhe="[object Symbol]",Ghe="[object ArrayBuffer]",Hhe="[object DataView]",Qhe="[object Float32Array]",Zhe="[object Float64Array]",Khe="[object Int8Array]",qhe="[object Int16Array]",Xhe="[object Int32Array]",Jhe="[object Uint8Array]",_he="[object Uint8ClampedArray]",ede="[object Uint16Array]",tde="[object Uint32Array]";function rde(i,t,e){var r=i.constructor;switch(t){case Ghe:return khe(i);case jhe:case Bhe:return new r(+i);case Hhe:return Lhe(i,e);case Qhe:case Zhe:case Khe:case qhe:case Xhe:case Jhe:case _he:case ede:case tde:return zhe(i,e);case Uhe:return new r;case Fhe:case Vhe:return new r(i);case Whe:return Rhe(i);case $he:return new r;case Yhe:return Ohe(i)}}var nde=rde,ide=En,rg=Object.create,sde=function(){function i(){}return function(t){if(!ide(t))return{};if(rg)return rg(t);i.prototype=t;var e=new i;return i.prototype=void 0,e}}(),ode=sde,ade=ode,cde=by,lde=ph;function ude(i){return typeof i.constructor=="function"&&!lde(i)?ade(cde(i)):{}}var hde=ude,dde=rc,fde=Nr,gde="[object Map]";function pde(i){return fde(i)&&dde(i)==gde}var mde=pde,yde=mde,vde=tc,ng=gh,ig=ng&&ng.isMap,Mde=ig?vde(ig):yde,wde=Mde,Tde=rc,Sde=Nr,Ide="[object Set]";function Cde(i){return Sde(i)&&Tde(i)==Ide}var xde=Cde,bde=xde,Ede=tc,sg=gh,og=sg&&sg.isSet,Ade=og?Ede(og):bde,Ly=Ade;const Nde=Jr(Ly);var Dde=gy,Pde=rce,kde=yy,Lde=Yle,Rde=aue,Ode=cue,zde=uue,jde=Tue,Bde=Rue,Ude=Ny,Fde=Hue,Wde=rc,$de=yhe,Vde=nde,Yde=hde,Gde=Ks,Hde=fh,Qde=wde,Zde=En,Kde=Ly,qde=yh,Xde=vh,Jde=1,_de=2,efe=4,Ry="[object Arguments]",tfe="[object Array]",rfe="[object Boolean]",nfe="[object Date]",ife="[object Error]",Oy="[object Function]",sfe="[object GeneratorFunction]",ofe="[object Map]",afe="[object Number]",zy="[object Object]",cfe="[object RegExp]",lfe="[object Set]",ufe="[object String]",hfe="[object Symbol]",dfe="[object WeakMap]",ffe="[object ArrayBuffer]",gfe="[object DataView]",pfe="[object Float32Array]",mfe="[object Float64Array]",yfe="[object Int8Array]",vfe="[object Int16Array]",Mfe="[object Int32Array]",wfe="[object Uint8Array]",Tfe="[object Uint8ClampedArray]",Sfe="[object Uint16Array]",Ife="[object Uint32Array]",it={};it[Ry]=it[tfe]=it[ffe]=it[gfe]=it[rfe]=it[nfe]=it[pfe]=it[mfe]=it[yfe]=it[vfe]=it[Mfe]=it[ofe]=it[afe]=it[zy]=it[cfe]=it[lfe]=it[ufe]=it[hfe]=it[wfe]=it[Tfe]=it[Sfe]=it[Ife]=!0;it[ife]=it[Oy]=it[dfe]=!1;function Zo(i,t,e,r,n,s){var o,a=t&Jde,c=t&_de,l=t&efe;if(e&&(o=n?e(i,r,n,s):e(i)),o!==void 0)return o;if(!Zde(i))return i;var u=Gde(i);if(u){if(o=$de(i),!a)return zde(i,o)}else{var h=Wde(i),d=h==Oy||h==sfe;if(Hde(i))return Ode(i,a);if(h==zy||h==Ry||d&&!n){if(o=c||d?{}:Yde(i),!a)return c?Bde(i,Rde(o,i)):jde(i,Lde(o,i))}else{if(!it[h])return n?i:{};o=Vde(i,h,a)}}s||(s=new Dde);var g=s.get(i);if(g)return g;s.set(i,o),Kde(i)?i.forEach(function(I){o.add(Zo(I,t,e,I,i,s))}):Qde(i)&&i.forEach(function(I,D){o.set(D,Zo(I,t,e,D,i,s))});var p=l?c?Fde:Ude:c?Xde:qde,M=u?void 0:p(i);return Pde(M||i,function(I,D){M&&(D=I,I=i[D]),kde(o,D,Zo(I,t,e,D,i,s))}),o}var Cfe=Zo,xfe=Cfe,bfe=1,Efe=4;function Afe(i){return xfe(i,bfe|Efe)}var Nfe=Afe;const Lt=Jr(Nfe),Dfe="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==",Pfe="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=",kfe="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==",Lfe="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",Rfe="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",Ofe="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]),Mi=["top","topLeft","topRight","bottom","bottomLeft","bottomRight","left","leftTop","leftBottom","right","rightTop","rightBottom"],as=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+"]]),Sh=new Map([["selector",{key:"selector",standardResolution:as.get("selector"),highResolution:kfe}],["shapeSynced",{key:"shape",standardResolution:Rfe}],["textSynced",{key:"text",standardResolution:Ofe}],["pencil",{key:"pencil",standardResolution:as.get("pencil"),highResolution:Dfe}],["eraser",{key:"eraser",standardResolution:as.get("eraser"),highResolution:Pfe}],["text",{key:"text",standardResolution:as.get("text")}],["shape",{key:"shape",standardResolution:as.get("shape")}],["clicker",{key:"clicker",standardResolution:Lfe}]]),Fr={enable:!0,expirationTime:5e3,moveDelayTime:40,preloadTimeout:5e3,appearance:{},syncedLabel:{enableShowName:!0,placement:"top",gap:2,maxWidth:88}};function Ih(i){var e,r,n,s;const t={...i==null?void 0:i.appearance};return delete t[De.hand],delete t[De.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 jfe(i,t){return{...i,...t,cursor:Ih(t==null?void 0:t.cursor)}}const nc="1.1.39",Bfe="@netless/appliance-plugin";if(typeof window<"u"){let i=window.__netlessUA||"";i+=` ${Bfe}@${nc}`,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:{},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:{}},An=(i,t,e)=>({images:Sh.get(i),size:{width:26,height:26},offset:{x:0,y:0},local:{size:t,offset:e},synced:{}}),ag={...An("pencil",{width:26,height:26},{x:-2,y:4}),synced:{offset:{x:0,y:9}}},Ufe={...An("selector",{width:25,height:25},{x:-5,y:21}),synced:{offset:{x:0,y:26}}},Ffe={...An("eraser",{width:26,height:26},{x:-8,y:8}),synced:{offset:{x:-5,y:13}}},Wfe={...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}),Vfe={...An("text",{width:47,height:40},{x:-20,y:20}),synced:{images:Sh.get("textSynced"),offset:{x:-13,y:16}}},on={...An("shape",{width:40,height:40},{x:-20,y:20}),synced:{images:Sh.get("shapeSynced"),offset:{x:-9,y:16}}},Yfe={...An("clicker",{width:24,height:24},{x:-4,y:21}),synced:{offset:{x:0,y:26}}},Ko=Object.freeze({[De.selector]:Ufe,[De.clicker]:Yfe,[De.pencil]:ag,[De.rectangle]:on,[De.ellipse]:on,[De.shape]:on,[De.eraser]:Ffe,[De.pencilEraser]:Wfe,[De.text]:Vfe,[De.straight]:on,[De.arrow]:on,[De.laserPen]:ag,[rr.star]:on,[rr.polygon]:on,[rr.speechBalloon]:on,[rr.bitMapEraser]:$fe});function jy(i){return{...jfe(He,i),syncLogger:{...He.syncLogger,...i==null?void 0:i.syncLogger}}}const Jl=new WeakMap,_l=new WeakMap,By=new WeakMap;function Gfe(i,t){By.set(i,t)}function Hfe(i){return By.get(i)}function Qfe(i,t,e,r){let n=Jl.get(i);n||(n=new Map,Jl.set(i,n));let s=n.get(t);s||(s=new Set,n.set(t,s)),s.add(e);let o=_l.get(i);o||(o=new Map,_l.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 Uy(i,t,e){var r;for(const n of((r=Jl.get(i))==null?void 0:r.get(t))||[])n(e)}function Zfe(i,t){var e;for(const r of((e=_l.get(i))==null?void 0:e.get(t))||[])r()}function Kfe(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 Ch=16,qfe=1;function gn(i){return Object.prototype.hasOwnProperty.call(i,"eraserFaces")}function Xfe(i,t){return t!==void 0&&i.has(t)}function eu(i,t){const e={...t};return gn(t)?delete e.eraserlines:i&&gn(i)&&(e.eraserFaces=i.eraserFaces??null,delete e.eraserlines),e}function tu(i){const t={...i};return delete t.doingLines,t}function Jfe(i,t){const e=gn(i)?i.eraserFaces?ca(i.eraserFaces):[]:cg(i.eraserlines||[]);return{eraserFaces:Fy(_fe(e,cg(t)))}}function Fy(i,t=Ch){if(!Number.isSafeInteger(t)||t<=0)throw new Error("eraserFaces scale must be a positive safe integer");const e=[];Is(e,i.length);for(const r of i){Is(e,r.rings.length);for(const n of r.rings){Is(e,n.length);let s=0,o=0;n.forEach(([a,c],l)=>{const u=ug(a,t),h=ug(c,t);hg(e,l===0?u:u-s),hg(e,l===0?h:h-o),s=u,o=h})}}return{v:1,s:t,e:1,d:Vy(e)}}function ca(i){if(i.v!==1||i.e!==1||i.s<=0)throw new Error("unsupported eraserFaces payload");const t=new rge(nge(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 cg(i,t=Ch){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 $y(e,t)}function _fe(i,t,e=Ch){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 $y(r,e)}function la(i,t){const e=[qfe];return dg(e,i),dg(e,t),Vy(Array.from(tge(Uint8Array.from(e)).slice(0,16)))}function Wy(i,t,e){return i.matrix.length===6&&i.matrix.every(Number.isFinite)&&i.fromDigest===la(t,e)&&/^[A-Za-z0-9_-]{22}$/.test(i.toDigest)}function ege(i,t,e,r,n){return!Wy(e,r.op,r.centerPos)||e.toDigest!==la(n.op,n.centerPos)?!1:(Uy(i,t,e.matrix),!0)}function sl(i,t){if(!i)return null;const e=ca(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 Fy(e,i.s)}function $y(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=[lg(a.Contour(),t)];for(const l of a.Childs())l.IsHole()&&c.push(lg(l.Contour(),t));n.push({rings:c})}s(a)}};return s(r),n}function lg(i,t){return i.map(({X:e,Y:r})=>[e/t,r/t])}function ug(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 Is(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 hg(i,t){const e=t>=0?t*2:-t*2-1;Is(i,e)}function dg(i,t){Is(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 tge(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 T=0;T<16;T++)a[T]=s.getUint32(h+T*4,!1);for(let T=16;T<64;T++){const f=a[T-15],m=a[T-2],w=c(f,7)^c(f,18)^f>>>3,v=c(m,17)^c(m,19)^m>>>10;a[T]=a[T-16]+w+a[T-7]+v>>>0}let[d,g,p,M,I,D,C,B]=o;for(let T=0;T<64;T++){const f=c(I,6)^c(I,11)^c(I,25),m=I&D^~I&C,w=B+f+m+t[T]+a[T]>>>0,v=c(d,2)^c(d,13)^c(d,22),b=d&g^d&p^g&p,x=v+b>>>0;B=C,C=D,D=I,I=M+w>>>0,M=p,p=g,g=d,d=w+x>>>0}o[0]=o[0]+d>>>0,o[1]=o[1]+g>>>0,o[2]=o[2]+p>>>0,o[3]=o[3]+M>>>0,o[4]=o[4]+I>>>0,o[5]=o[5]+D>>>0,o[6]=o[6]+C>>>0,o[7]=o[7]+B>>>0}const l=new Uint8Array(32),u=new DataView(l.buffer);return o.forEach((h,d)=>u.setUint32(d*4,h,!1)),l}class rge{constructor(t){L(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 Vy(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 nge(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 qr(i,t=!0){const e=i.length;if(e<2)return"";let r=i[0],n=i[1];if(e===2)return`M${wi(r)}L${wi(n)}`;let s="";for(let o=2,a=e-1;o<a;o++)r=i[o],n=i[o+1],s+=Ti(r,n);return t?`M${Ti(i[0],i[1])}Q${wi(i[1])}${Ti(i[1],i[2])}T${s}${Ti(i[e-1],i[0])}${Ti(i[0],i[1])}Z`:`M${wi(i[0])}Q${wi(i[1])}${Ti(i[1],i[2])}${i.length>3?"T":""}${s}L${wi(i[e-1])}`}function ige(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 sge(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 oge(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 li(i){return JSON.parse(Jg.decompress(i))}function bt(i){return Jg.compress(JSON.stringify(i))}const ot=Object.keys,fg=new WeakMap,Vt=class Vt{constructor(t){L(this,"maxImageWidth",He.pencilEraser.maxImageWidth);L(this,"maxImageHeight",He.pencilEraser.maxImageHeight);L(this,"syncUnitTime",He.syncOpt.interval);L(this,"vNodes");L(this,"drawLayer");L(this,"fullLayer");L(this,"workId");L(this,"confirmEraserDeletion",!1);L(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=tu(e.opt);e.opt=eu(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=bt(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=eu(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=tu(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 M=a.getAttribute("scale");M=[M[0]*p,M[1]*p];const I=a.parent.parent,D=a.getAttribute("translate"),C=this.createVmRenderNode(`${this.workId}_bitMapLayer`,I,{offscreen:c.offscreen,width:c.width,height:c.height,contextType:"2d",autoRender:!1,bufferSize:500},M,D),B=r.cloneNode(!0);if(!n.length&&!s)return;s&&this.addEraserFaces(B,s,o,!1),this.addEraserlines(B,n,o,!1),C.appendChild(B);const T=C.parent;T.render();const f=C.renderer.canvasRenderer,m=f.context;if(!m)return;const w=f.options.displayRatio,v=B.getBoundingClientRect(),b={x:v.x,y:v.y,w:v.width,h:v.height},x={x:0,y:0,w:I.width,h:I.height};if(cc(b,x)===pn.outside){ar(B,T),I.removeChild(T),this.isDelete=!0;return}const E=sge(b,w),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,w),N=V.x,A=V.y,P=V.w,U=V.h;let Q=m.getImageData(N,A,P,U);if(this.confirmEraserDeletion&&this.isTransparentRectByCanvas(Q)){ar(B,T),I.removeChild(T),this.isDelete=!0,Q=null;return}if(this.confirmEraserDeletion&&c.renderer.glRenderer&&this.drawEraserMask({group:r,eraserlines:n,eraserFaces:s,pos:o,layer:a,targetScale:p})){ar(B,T),I.removeChild(T),Q=null;return}ar(r,c);const K=this.createSpriteNode({imageData:Q,safariRect:O,originRect:E,worldScaling:C.worldScaling});K&&r.append(K),ar(B,T),I.removeChild(T),c.deleteTexture(Q),Q=null}catch(l){console.error("[BaseShapeTool] drawEraserlines error:",l);return}}drawEraserMask(t){var m,w;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 M=fg.get(o);M||(M=new Map,fg.set(o,M)),this.pruneEraserMaskCaches(o,M,u);let I=M.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;M.set(this.workId,I)}if(!I)return!1;const C=d/c,B=g/l;I.context.setTransform(C,0,0,B,d/2,g/2),D&&n&&(this.appendEraserMaskFaces(I.context,n,s),I.facesKey=n.d);let T=D,f;for(const v of r){const b=I.commands.get(v.workId),x=D?0:(b==null?void 0:b.count)||0;for(let z=x;z<v.op.length;z++)T=!0,f=Ge(f,this.appendEraserMaskStroke(I.context,v.op[z],v.thickness,s));I.commands.set(v.workId,{count:v.op.length,thickness:v.thickness,first:(m=v.op[0])==null?void 0:m.slice(0,2),last:(w=v.op[v.op.length-1])==null?void 0:w.slice(-2)})}return T&&I.handle.update({rect:p,dirtyRect:D||!f?void 0:[f.x,f.y,f.w,f.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 nse(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 ca(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 ige(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,M)=>M%2?p-r[1]:p-r[0]),u=this.computEraserPoints(l,o),h=qr(u,!0),d={pos:[0,0],d:h,fillColor:"rgba(0,0,0,1)"},g=new Zt(d);g.addEventListener("beforerender",({detail:p})=>{const M=p.context;n?M.blendFuncSeparate(M.ZERO,M.ZERO,M.ZERO,M.ZERO):M.globalCompositeOperation="destination-out"}),g.addEventListener("afterrender",({detail:p})=>{const M=p.context;n?M.blendFuncSeparate(M.SRC_ALPHA,M.ONE_MINUS_SRC_ALPHA,M.ONE,M.ONE_MINUS_SRC_ALPHA):M.globalCompositeOperation="source-over"}),t.append(g)}}}addEraserFaces(t,e,r,n=!0){const s=ca(e).flatMap(a=>a.rings.map(c=>qr(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}=oge(n,s,r),l={name:"eraserTexture",anchor:[.5,.5],pos:[0,0],size:a,texture:o,textureRect:c},u=new Ka(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?Fye(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 f;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 M;const I=o&&Lt(o)||n.get(e.name);if(!I)return;const D=r.eraserGeometryDelta,C=gn(I.opt)?la(I.op,I.centerPos):void 0;if(D&&(!C||!Wy(D,I.op,I.centerPos)))return;D&&Uy(n,e.name,D.matrix);let B;It(a)&&(e.setAttribute("zIndex",a),I.opt.zIndex=a);const T=e.parent;if(T){if(u&&d&&o){if(B=[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)],ac(I.op,h,d,c),Cs(I.centerPos,h,d,c),I.opt.translate=void 0,I.opt.scale=void 0,I.opt.eraserlines)for(let m=0;m<I.opt.eraserlines.length;m++){const{op:w,thickness:v}=I.opt.eraserlines[m];I.opt.eraserlines[m].thickness=Math.round(v*Math.max(d[0],d[1]));for(let b=0;b<w.length;b++)Cs(w[b],h,d,c)}gn(I.opt)&&(I.opt.eraserFaces=sl(I.opt.eraserFaces??null,m=>Cs(m,h,d,c)),delete I.opt.eraserlines)}else if(c)if(e.setAttribute("translate",c),I.opt.translate=c,o){const m=[c[0]*T.worldScaling[0],c[1]*T.worldScaling[1]];M=Rs(I.rect,m),I.rect=M}else{const m=Vt.getRectFromLayer(T,e.name);I.rect=m||I.rect}else if(It(l))if(e.setAttribute("rotate",l),I.opt.rotate=l,o)M=Ph(I.rect,l),I.rect=M;else{const m=Vt.getRectFromLayer(T,e.name);I.rect=m||I.rect}if(g){const m=g.get(e.name);if(m)for(let w=0,v=0;w<I.op.length;w+=3,v++)I.op[w]=m[v][0],I.op[w+1]=m[v][1]}if(p&&((f=I==null?void 0:I.opt)!=null&&f.thickness)&&(I.opt.thickness=p),s&&!(u&&d&&o)){if(c){B=[1,0,0,1,c[0],c[1]];const m=I.op.map((w,v)=>{const b=v%3;return b===0?w+c[0]:b===1?w+c[1]:w});if(I.op=m,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 w=0;w<I.opt.eraserlines.length;w++){const{op:v}=I.opt.eraserlines[w];for(let b=0;b<v.length;b++){const x=v[b].map((z,E)=>E%2?z+c[1]:z+c[0]);I.opt.eraserlines[w].op[b]=x}}gn(I.opt)&&(I.opt.eraserFaces=sl(I.opt.eraserFaces??null,w=>{for(let v=0;v<w.length;v+=2)w[v]+=c[0],w[v+1]+=c[1]}),delete I.opt.eraserlines)}else if(It(l)){const m=Math.PI*l/180,w=Math.cos(m),v=Math.sin(m),[b,x]=I.centerPos;B=[w,v,-v,w,b-w*b+v*x,x-v*b-w*x];const z=I.op;if(Rye(z,I.centerPos,l),I.op=z,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++)Og(O[V],I.centerPos,l)}gn(I.opt)&&(I.opt.eraserFaces=sl(I.opt.eraserFaces??null,E=>Og(E,I.centerPos,l)),delete I.opt.eraserlines)}}if(C&&B&&gn(I.opt)){const m=la(I.op,I.centerPos);if(D&&D.toDigest!==m)return;D||Gfe(I.opt,{matrix:B,fromDigest:C,toDigest:m})}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===Z.Text&&(s.fontSize||s.translate||s.textInfos&&s.textInfos.get(n.name))||e===Z.BackgroundSVG&&(s.translate||s.scale)||e===Z.Image&&(s.angle||s.translate||s.scale||s.strokeColor&&r.type===mn.Iconify)||e===s.toolsType&&s.willRefresh||r.eraserlines&&r.eraserlines.length&&(s.strokeColor||s.fillColor))}};L(Vt,"SafeBorderPadding",10);let be=Vt;const xh=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 Yy(i,t,e=.01){return Math.abs(i[0]-t[0])<e&&Math.abs(i[1]-t[1])<e}function age(i,t=.01){if(i.length===0)return[];const e=[[i[0][0],i[0][1]]];for(let r=1;r<i.length;r++)Yy([i[r][0],i[r][1]],e[e.length-1],t)||e.push([i[r][0],i[r][1]]);return e}function cge(i,t=.01){if(i.length<=2)return i;const e=i[0],r=i[i.length-1];return Yy(e,r,t)?i.slice(0,-1):i}function lge(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 gg(i,t){return Math.atan2(t[1]-i[1],t[0]-i[0])}function uge(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=lge(e);return e.sort((n,s)=>{const o=gg(r,n),a=gg(r,s);return o-a})}function hge(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 dge(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=>cge(uge(age(h.map(d=>[d.X/1e3,d.Y/1e3]),e),e),e)).filter(h=>h.length>=2);return hge(u,i)}class Gy extends be{constructor(e){super(e);L(this,"canRotate",!0);L(this,"scaleType",Ve.all);L(this,"toolsType",Z.Pencil);L(this,"syncTimestamp");L(this,"syncIndex",0);L(this,"tmpPoints",[]);L(this,"MAX_REPEAR",10);L(this,"uniThickness");L(this,"workOptions");L(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 M={name:u,id:It(a)&&a.toString()||void 0};let I,D=!1;const C=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 f=n?this.fullLayer:this.drawLayer||this.fullLayer;I=this.draw({attrs:M,tasks:d,effects:g,layer:f,removeDrawCount:c})}if(l){const f=[];this.tmpPoints.slice(C).forEach(w=>{f.push(w.x,w.y,this.computRadius(w.z,this.workOptions.thickness))});const m=!this.workOptions.previewLocalOnly&&D;return{...this.baseConsumeResult,type:he.DrawWork,dataType:Ee.Local,op:m?f:void 0,index:m?C*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 B=[];this.tmpPoints.slice(C).forEach(f=>{B.push(f.x,f.y,this.computRadius(f.z,this.workOptions.thickness))});const T=!this.workOptions.previewLocalOnly&&D;return{...this.baseConsumeResult,type:he.DrawWork,dataType:Ee.Local,rect:I,op:T?B:void 0,index:T?C*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=bt(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&&be.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 M=this.tmpPoints[this.tmpPoints.length-1];if(!this.setPointVector(p,M))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&&be.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 M=[];for(let D=0;D<p.length;D+=2){const C=new Ae(p[D],p[D+1]);if(M.length>0){const B=M[M.length-1].point;if(!this.setPointVector(C,B))continue}M.push({point:C,radius:o})}const{ps:I}=this.computStroke(M,!1);d.push(I.map(D=>D.XY))}dge(h,d,.01).forEach(p=>{r.push(p.map(M=>[M[0],M[1],M[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:M,translate:I,eraserlines:D,eraserFaces:C,doingLines:B,lineCap:T,lineDash:f}=this.workOptions;o!=null&&o.size&&(o.forEach(z=>{var E;(E=a.getElementById(z+""))==null||E.remove()}),o.clear()),c&&this.removeDrawCountNodes(a,c);let m;const w=[],v=a.worldPosition,b=a.worldScaling;for(let z=0;z<n.length;z++){const{pos:E,points:O}=n[z],{ps:V,rect:N}=this.computDrawPoints(O);let A;const P=O.length===1;h===ze.Stroke||P?A=qr(V,!0):A=qr(V,!1);const U={pos:E,d:A,fillColor:h===ze.Stroke||P?u:void 0,lineDash:P?void 0:h===ze.Dotted?[f&&f[0]||1,(f&&f[1]||2)*d]:h===ze.LongDotted?[(f&&f[0]||1)*d,(f&&f[1]||2)*d]:void 0,strokeColor:u,lineCap:P?void 0:T,lineWidth:h===ze.Stroke||P?0:d};m=Ge(m,{x:Math.floor((N.x+E[0])*b[0]+v[0]-be.SafeBorderPadding),y:Math.floor((N.y+E[1])*b[1]+v[1]-be.SafeBorderPadding),w:Math.floor(N.w*b[0]+2*be.SafeBorderPadding),h:Math.floor(N.h*b[1]+2*be.SafeBorderPadding)}),w.push(U)}p&&(r.scale=p),M&&(r.rotate=M),I&&(r.translate=I);const x=new dt;if(m){this.centerPos=be.getCenterPos(m,a);const z=h===ze.Stroke&&!D&&!C&&!B;x.attr({...r,normalize:!0,anchor:[.5,.5],bgcolor:z?u:void 0,pos:this.centerPos,size:[(m.w-2*be.SafeBorderPadding)/b[0],(m.h-2*be.SafeBorderPadding)/b[1]],zIndex:g});const E=w.map(O=>(O.pos=[O.pos[0]-this.centerPos[0],O.pos[1]-this.centerPos[1]],new Zt(O)));x.append(...E),z&&x.seal(),(D||C||B)&&(this.scaleType=Ve.proportional,this.drawEraserlines({group:x,eraserlines:this.getRenderableEraserLines(this.workOptions),eraserFaces:C,pos:this.centerPos,layer:a},l)),this.replace(a,s,x)}if(p||M||I){const z=x==null?void 0:x.getBoundingClientRect();z&&(m={x:Math.floor(z.x-be.SafeBorderPadding),y:Math.floor(z.y-be.SafeBorderPadding),w:Math.floor(z.width+be.SafeBorderPadding*2),h:Math.floor(z.height+be.SafeBorderPadding*2)})}return this.isDelete&&x.setAttribute("opacity",0),m}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:_e(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:_e(u)}}const a=n.concat(s.reverse());return{ps:a,rect:_e(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,M=d.z,I=r?this.computRadius(M,r):M;if(l.push({point:new Ae(g,p,M,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 C=(h=l.pop())==null?void 0:h.point.clone();C&&n.push({taskId:u,pos:c,points:[...l,{point:C,radius:I}]}),o=e[s].x,a=e[s].y,c=[o,a];const B=d.x-o,T=d.y-a;l=[{point:new Ae(B,T,M),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 T=u-1;for(;T>0;){const f=this.tmpPoints[T].distance(this.tmpPoints[T-1]),m=Math.max(this.tmpPoints[T].z-this.uniThickness*f,0);if(this.tmpPoints[T-1].z>=m)break;this.tmpPoints[T-1].setz(m),a=Math.min(a,T-1),T--}}if(a=Math.min(a,d),g.t){h.setz(D),h.setv(p),this.tmpPoints.push(h);continue}const C=this.tmpPoints[d-1],B=C?fe.Sub(h,C).uni():g.v;g.set(h.x,h.y,D,B);continue}h.setv(p);const M=h.distance(g),I=Math.max(g.z-this.uniThickness*M,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 M=fe.Sub(d,p).uni();if(d.isNear(p,r/2)){if(p.t){d.setz(p.z),d.setv(M),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(M,p.v,.01)&&(p.t||this.tmpPoints.pop(),a=Math.min(g,a)),d.setv(M),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 C=this.tmpPoints[D].distance(this.tmpPoints[D-1]),B=Math.max(this.tmpPoints[D].z-this.uniThickness*C,-r/4);if(this.tmpPoints[D-1].z>=B)break;this.tmpPoints[D-1].setz(B),D--}}if(u.t){c.setz(p),c.setv(h),this.tmpPoints.push(c);continue}const M=this.tmpPoints[l-1],I=M?fe.Sub(c,M).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"?Uye(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),be.updateNodeOpt(e)}}class Hy extends be{constructor(e){super(e);L(this,"toolsType",Z.LaserPen);L(this,"canRotate",!1);L(this,"scaleType",Ve.none);L(this,"syncTimestamp");L(this,"syncIndex",0);L(this,"tmpPoints",[]);L(this,"workOptions");L(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=_e(this.tmpPoints,l);let p=!1;const M=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]},C=this.getTaskPoints(I);if(C.length){const T=Date.now();T-this.syncTimestamp>this.syncUnitTime&&(p=!0,this.syncTimestamp=T,this.syncIndex=this.tmpPoints.length),n&&this.draw({attrs:D,tasks:C,isDot:!1,layer:this.drawLayer||this.fullLayer})}const B=[];return this.tmpPoints.slice(M).forEach(T=>{B.push(T.x,T.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?B:void 0,index:p?M*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=_e(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=bt(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 M;const{op:r,replaceId:n,isFullWork:s}=e,{strokeColor:o,thickness:a,strokeType:c}=this.workOptions;if(!r.length){const I=_e(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=_e(this.tmpPoints,a);const g={name:(M=this.workId)==null?void 0:M.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=qr(h,!0):d=qr(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 M=u.x-s,I=u.y-o;c=[new Ae(M,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 Ai=class Ai extends be{constructor(e,r){super(e);L(this,"canRotate",!1);L(this,"scaleType",Ve.none);L(this,"toolsType",Z.Eraser);L(this,"serviceWork");L(this,"tmpPoints",[]);L(this,"workOptions");L(this,"worldPosition");L(this,"worldScaling");L(this,"eraserRect");L(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}=Ai.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}=Ai.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}=Ai.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&&pa(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&&_e(c)||o.rect;pa(u,this.eraserRect)&&(l.length>1?pu.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-=be.SafeBorderPadding,s.y-=be.SafeBorderPadding,s.w+=be.SafeBorderPadding*2,s.h+=be.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}};L(Ai,"eraserSizes",xh);let ua=Ai;const Rt="++",Pe="selector",ru="all";var fge="__lodash_hash_undefined__";function gge(i){return this.__data__.set(i,fge),this}var pge=gge;function mge(i){return this.__data__.has(i)}var yge=mge,vge=fy,Mge=pge,wge=yge;function ha(i){var t=-1,e=i==null?0:i.length;for(this.__data__=new vge;++t<e;)this.add(i[t])}ha.prototype.add=ha.prototype.push=Mge;ha.prototype.has=wge;var bh=ha;function Tge(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 Sge=Tge;function Ige(i,t){return i.has(t)}var Eh=Ige,Cge=bh,xge=Sge,bge=Eh,Ege=1,Age=2;function Nge(i,t,e,r,n,s){var o=e&Ege,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&Age?new Cge:void 0;for(s.set(i,t),s.set(t,i);++h<a;){var p=i[h],M=t[h];if(r)var I=o?r(M,p,h,t,i,s):r(p,M,h,i,t,s);if(I!==void 0){if(I)continue;d=!1;break}if(g){if(!xge(t,function(D,C){if(!bge(g,C)&&(p===D||n(p,D,e,r,s)))return g.push(C)})){d=!1;break}}else if(!(p===M||n(p,M,e,r,s))){d=!1;break}}return s.delete(i),s.delete(t),d}var Qy=Nge;function Dge(i){var t=-1,e=Array(i.size);return i.forEach(function(r,n){e[++t]=[n,r]}),e}var Pge=Dge;function kge(i){var t=-1,e=Array(i.size);return i.forEach(function(r){e[++t]=r}),e}var Ah=kge,pg=Zs,mg=ky,Lge=hh,Rge=Qy,Oge=Pge,zge=Ah,jge=1,Bge=2,Uge="[object Boolean]",Fge="[object Date]",Wge="[object Error]",$ge="[object Map]",Vge="[object Number]",Yge="[object RegExp]",Gge="[object Set]",Hge="[object String]",Qge="[object Symbol]",Zge="[object ArrayBuffer]",Kge="[object DataView]",yg=pg?pg.prototype:void 0,ol=yg?yg.valueOf:void 0;function qge(i,t,e,r,n,s,o){switch(e){case Kge:if(i.byteLength!=t.byteLength||i.byteOffset!=t.byteOffset)return!1;i=i.buffer,t=t.buffer;case Zge:return!(i.byteLength!=t.byteLength||!s(new mg(i),new mg(t)));case Uge:case Fge:case Vge:return Lge(+i,+t);case Wge:return i.name==t.name&&i.message==t.message;case Yge:case Hge:return i==t+"";case $ge:var a=Oge;case Gge:var c=r&jge;if(a||(a=zge),i.size!=t.size&&!c)return!1;var l=o.get(i);if(l)return l==t;r|=Bge,o.set(i,t);var u=Rge(a(i),a(t),r,n,s,o);return o.delete(i),u;case Qge:if(ol)return ol.call(i)==ol.call(t)}return!1}var Xge=qge,vg=Ny,Jge=1,_ge=Object.prototype,epe=_ge.hasOwnProperty;function tpe(i,t,e,r,n,s){var o=e&Jge,a=vg(i),c=a.length,l=vg(t),u=l.length;if(c!=u&&!o)return!1;for(var h=c;h--;){var d=a[h];if(!(o?d in t:epe.call(t,d)))return!1}var g=s.get(i),p=s.get(t);if(g&&p)return g==t&&p==i;var M=!0;s.set(i,t),s.set(t,i);for(var I=o;++h<c;){d=a[h];var D=i[d],C=t[d];if(r)var B=o?r(C,D,d,t,i,s):r(D,C,d,i,t,s);if(!(B===void 0?D===C||n(D,C,e,r,s):B)){M=!1;break}I||(I=d=="constructor")}if(M&&!I){var T=i.constructor,f=t.constructor;T!=f&&"constructor"in i&&"constructor"in t&&!(typeof T=="function"&&T instanceof T&&typeof f=="function"&&f instanceof f)&&(M=!1)}return s.delete(i),s.delete(t),M}var rpe=tpe,al=gy,npe=Qy,ipe=Xge,spe=rpe,Mg=rc,wg=Ks,Tg=fh,ope=Ty,ape=1,Sg="[object Arguments]",Ig="[object Array]",jo="[object Object]",cpe=Object.prototype,Cg=cpe.hasOwnProperty;function lpe(i,t,e,r,n,s){var o=wg(i),a=wg(t),c=o?Ig:Mg(i),l=a?Ig:Mg(t);c=c==Sg?jo:c,l=l==Sg?jo:l;var u=c==jo,h=l==jo,d=c==l;if(d&&Tg(i)){if(!Tg(t))return!1;o=!0,u=!1}if(d&&!u)return s||(s=new al),o||ope(i)?npe(i,t,e,r,n,s):ipe(i,t,c,e,r,n,s);if(!(e&ape)){var g=u&&Cg.call(i,"__wrapped__"),p=h&&Cg.call(t,"__wrapped__");if(g||p){var M=g?i.value():i,I=p?t.value():t;return s||(s=new al),n(M,I,e,r,s)}}return d?(s||(s=new al),spe(i,t,e,r,n,s)):!1}var upe=lpe,hpe=upe,xg=Nr;function Zy(i,t,e,r,n){return i===t?!0:i==null||t==null||!xg(i)&&!xg(t)?i!==i&&t!==t:hpe(i,t,e,r,Zy,n)}var dpe=Zy,fpe=dpe;function gpe(i,t){return fpe(i,t)}var ppe=gpe;const Zr=Jr(ppe);function qs(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 Wn(i,t,e,r=1){return`rgba(${i},${t},${e},${r})`}function ic(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[qs(e,r,n),s]}function ys(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 Bo(i){return i==="transparent"}const va=class va extends be{constructor(e){super(e);L(this,"toolsType",Z.Selector);L(this,"tmpPoints",[]);L(this,"subTmpPoints",[]);L(this,"workOptions");L(this,"vNodes");L(this,"selectIds");L(this,"selectorColor");L(this,"strokeColor");L(this,"fillColor");L(this,"oldSelectRect");L(this,"oldSubSelectRect");L(this,"canRotate",!1);L(this,"canTextEdit",!1);L(this,"canLock",!1);L(this,"scaleType",Ve.all);L(this,"toolsTypes");L(this,"shapeOpt");L(this,"textOpt");L(this,"isLocked");L(this,"thickness");L(this,"strokeType");L(this,"useStroke");this.workOptions=e.toolsOpt,this.vNodes=e.vNodes}computSelector(e=!0){const r=_e(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 Ds({normalize:!0,pos:[r.w/2,r.h/2],lineWidth:1,strokeColor:this.selectorColor||this.workOptions.strokeColor,width:r.w,height:r.h,name:va.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 Ds({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!==Z.Pencil&&(s=!1),a.strokeType&&(this.strokeType=a.strokeType),u===Z.SpeechBalloon&&(r.add(u),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.placement=a.placement),u===Z.Polygon&&(r.add(u),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=a.vertices),u===Z.Star&&(r.add(u),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=a.vertices,this.shapeOpt.innerRatio=a.innerRatio,this.shapeOpt.innerVerticeStep=a.innerVerticeStep),u===Z.Text&&(this.textOpt=a),e.size===1&&(this.textOpt&&(this.canTextEdit=!0),this.canRotate=c,this.scaleType=l),(u===Z.Image||u===Z.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(Pe,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,Pe,!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=_e(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),M=1/n.worldScaling[0],I=o&&ys(o)||[0,0,0,0],D={close:!0,normalize:!0,points:d,lineWidth:M,fillColor:Wn(I[0],I[1],I[2],.1),strokeColor:Wn(I[0],I[1],I[2],1),lineJoin:"round",lineCap:"round"};let C={x:Math.floor(g.x*h[0]+u[0]-be.SafeBorderPadding),y:Math.floor(g.y*h[1]+u[1]-be.SafeBorderPadding),w:Math.floor(g.w*h[0]+2*be.SafeBorderPadding),h:Math.floor(g.h*h[0]+2*be.SafeBorderPadding)};const B=new dt({name:r,id:r,pos:p,anchor:[.5,.5],size:[g.w,g.h],scale:a,rotate:c,translate:l}),T=new wr({...D,pos:[0,0]});if(B.appendChild(T),this.replace(n,r,B),a||c||l){const f=B.getBoundingClientRect();C={x:Math.floor(f.x-be.SafeBorderPadding),y:Math.floor(f.y-be.SafeBorderPadding),w:Math.floor(f.width+2*be.SafeBorderPadding),h:Math.floor(f.height+2*be.SafeBorderPadding)}}return C}transformData(e){const r=_e(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=Pe,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(i0(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===Z.Ellipse||e===Z.Triangle||e===Z.Rectangle||e===Z.Polygon||e===Z.Star||e===Z.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:M,dir:I,scale:D}=r;c&&(M?r.translate=[M[0]+c[0],M[1]+c[1]]:r.translate=c);let C;if(d||M||It(p)){if(g===ge.Start&&n)return s.setTargetAssignKeys(n),{type:he.Select,dataType:Ee.Local,selectRect:this.oldSelectRect,rect:this.oldSelectRect};if(C=s.getLastTarget(),!C)return}if(n)for(const f of n){const m=s.get(f);if(m){const{toolsType:w,opt:v}=m,b=(l==null?void 0:l.getElementsByName(f))[0];if(b){const x={...r};let z;const E=be.isWillRefresh({toolsType:w,opt:v,updateOpt:x,vNodes:s,node:b,willSerializeData:o});if(w){z=C==null?void 0:C.get(f);const O=oc(w);O==null||O.updateNodeOpt({node:b,opt:x,vNodes:s,willSerializeData:o,targetNode:z});const V=s.get(f)||m;if(V&&a&&E){const N=a.createWorkShapeNode({workId:f,toolsType:w,toolsOpt:V.opt});N==null||N.setWorkId(f);let A;if(w===Z.BackgroundSVG)A=N.consumeService({isFullWork:!0,replaceId:f});else if(w===Z.Image)A=await N.consumeServiceAsync({isFullWork:!0,replaceId:f,worker:a});else if(w===Z.Text)A=await N.consumeServiceAsync({isFullWork:!0,replaceId:f,isDrawLabel:!0});else try{A=N==null?void 0:N.consumeService({op:V.op,isFullWork:!0,replaceId:f,workState:g})}catch(P){console.error("consumeService error",P);continue}A&&(V.rect=A)}V&&(h.set(f,V),u=Ge(u,V.rect))}}}}C&&g===ge.Done&&(s.deleteLastTarget(),C=void 0);const B=u;if(d&&M&&D&&I&&B&&!c){const f=[[B.x,B.y],[B.x+B.w,B.y],[B.x+B.w,B.y+B.h],[B.x,B.y+B.h]];let m;switch(I){case"top":case"topLeft":case"left":M[0]>0&&M[1]>0?m=f[0]:M[0]>0?m=f[3]:M[1]>0?m=f[1]:m=f[2];break;case"topRight":M[0]<0&&M[1]>0?m=f[1]:M[0]<0?m=f[2]:M[1]>0?m=f[0]:m=f[3];break;case"right":case"bottomRight":case"bottom":M[0]<0&&M[1]<0?m=f[2]:M[0]<0?m=f[1]:M[1]<0?m=f[3]:m=f[0];break;case"bottomLeft":M[0]>0&&M[1]<0?m=f[3]:M[0]>0?m=f[0]:M[1]<0?m=f[2]:m=f[1];break}const w=m&&[d[0]-m[0],d[1]-m[1]]||[0,0];if(!Zr(w,[0,0]))return await this.updateSelector({...e,updateSelectorOpt:{workState:g},offset:w})}this.getSelecteorInfo(h),this.draw(Pe,l,{selectIds:n||[],subNodeMap:h,intersectRect:B});const T=Ge(this.oldSelectRect,B);return this.oldSelectRect=B,{type:he.Select,dataType:Ee.Local,selectRect:B,renderRect:u,rect:Ge(T,B),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(Pe,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()})}};L(va,"selectorBorderId","selector-border");let da=va;class Ky extends be{constructor(e){super(e);L(this,"canRotate",!1);L(this,"scaleType",Ve.both);L(this,"toolsType",Z.Arrow);L(this,"tmpPoints",[]);L(this,"workOptions");L(this,"oldRect");L(this,"arrowTipWidth");L(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 C=Date.now();C-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=C,D.op=this.tmpPoints.map(B=>[...B.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 M=Ge(p,this.oldRect);return this.oldRect=p,{rect:M,...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=bt(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:be.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:M,lineDash:I,lineCap:D}=this.workOptions,C=n.worldPosition,B=n.worldScaling,{points:T,pos:f,rect:m,isTriangle:w,trianglePoints:v,trianglePos:b}=this.computDrawPoints(a),x=[m.x+m.w/2,m.y+m.h/2],z={pos:x,name:r,id:r,zIndex:c,anchor:[.5,.5],size:[m.w,m.h]};l&&(z.scale=l),u&&(z.rotate=u),h&&(z.translate=h);const E=new dt(z),O={points:v,pos:[b[0]-x[0],b[1]-x[1]],fillColor:o,strokeColor:o,lineWidth:0,normalize:!1},V=new wr(O);if(E.append(V),!w&&T&&f){const A={points:T,pos:[f[0]-x[0],f[1]-x[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},P=new wr(A);E.append(P)}(g||p||M)&&(this.scaleType=Ve.proportional,this.drawEraserlines({group:E,eraserlines:this.getRenderableEraserLines(this.workOptions),eraserFaces:p,pos:x,layer:n},s)),this.replace(n,r,E);let N={x:Math.floor(m.x*B[0]+C[0]-be.SafeBorderPadding),y:Math.floor(m.y*B[1]+C[1]-be.SafeBorderPadding),w:Math.floor(m.w*B[0]+2*be.SafeBorderPadding),h:Math.floor(m.h*B[1]+2*be.SafeBorderPadding)};if(l||u||h){const A=E.getBoundingClientRect();N={x:Math.floor(A.x-be.SafeBorderPadding),y:Math.floor(A.y-be.SafeBorderPadding),w:Math.floor(A.width+be.SafeBorderPadding*2),h:Math.floor(A.height+be.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],M=[d,this.tmpPoints[1],g],I=[s,o,...M,l,u];return{trianglePoints:M.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:_e(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:_e(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:be.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),be.updateNodeOpt(e)}}class qy extends be{constructor(e){super(e);L(this,"canRotate",!1);L(this,"scaleType",Ve.all);L(this,"toolsType",Z.Ellipse);L(this,"tmpPoints",[]);L(this,"workOptions");L(this,"oldRect");L(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 M=n?this.fullLayer:this.drawLayer||this.fullLayer;p=this.draw({workId:l,layer:M,isDrawing:!0});const I=M.parent.parent,D={x:0,y:0,w:Math.floor(I.width),h:Math.floor(I.height)},C={type:he.DrawWork,dataType:Ee.Local,...this.baseConsumeResult};if(cc(p,D)!==pn.outside){const T=Ge(p,this.oldRect);if(this.oldRect=p,C.rect=T,!c)return C}if(c){const T=Date.now();return T-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=T,C.op=this.tmpPoints.map(f=>[...f.XY,0]).flat(1),C.index=0,C.isSync=!0),C}return{type:he.None}}if(!s&&!o&&!c&&a){const M=Date.now();return M-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=M,{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=bt(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&&be.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:M,eraserFaces:I,doingLines:D,lineDash:C,lineCap:B}=this.workOptions,T=n.worldScaling,{radius:f,rect:m,pos:w}=this.computDrawPoints(l),v={closeType:"normal",radius:f,lineWidth:l,fillColor:c!=="transparent"&&c||void 0,strokeColor:a,normalize:!0,lineCap:B,lineDash:p===ze.Dotted?[C&&C[0]||1,(C&&C[1]||2)*l]:p===ze.LongDotted?[(C&&C[0]||1)*l,(C&&C[1]||2)*l]:void 0},b={name:r,id:r,zIndex:u,pos:w,anchor:[.5,.5],size:[m.w,m.h]};h&&(b.scale=h),d&&(b.rotate=d),g&&(b.translate=g);const x=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/T[0],1/T[1]]});x.append(O)}const z=new lh({...v,pos:[0,0]});x.append(z),(M||I||D)&&(this.scaleType=Ve.proportional,this.drawEraserlines({group:x,eraserlines:this.getRenderableEraserLines(this.workOptions),eraserFaces:I,pos:w,layer:n},o)),this.replace(n,r,x);const E=x.getBoundingClientRect();return this.isDelete&&x.setAttribute("opacity",0),{x:Math.floor(E.x-be.SafeBorderPadding),y:Math.floor(E.y-be.SafeBorderPadding),w:Math.floor(E.width+be.SafeBorderPadding*2),h:Math.floor(E.height+be.SafeBorderPadding*2)}}computDrawPoints(e){const r=_e(this.tmpPoints),n=_e(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:be.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),be.updateNodeOpt(e)}}class Xy extends be{constructor(e){super(e);L(this,"canRotate",!0);L(this,"scaleType",Ve.all);L(this,"toolsType",Z.Rectangle);L(this,"tmpPoints",[]);L(this,"workOptions");L(this,"oldRect");L(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}static normalizeStorageData(e){return this.normalizeDrawableStorageData(e)}transformData(){const e=_e(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=_e(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 C=Date.now();C-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=C,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 M=Ge(p,this.oldRect);return this.oldRect=p,{rect:M,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=bt(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&&be.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:M,strokeType:I,eraserlines:D,eraserFaces:C,doingLines:B,lineCap:T,lineDash:f}=this.workOptions,m=n.worldPosition,w=n.worldScaling,{points:v,rect:b,pos:x}=this.computDrawPoints(o),z={close:!0,normalize:!0,points:v,lineWidth:h,fillColor:u!=="transparent"&&u||void 0,strokeColor:l,lineCap:T,lineDash:I===ze.Dotted?[f&&f[0]||1,(f&&f[1]||2)*h]:I===ze.LongDotted?[(f&&f[0]||1)*h,(f&&f[1]||2)*h]:void 0};let E={x:Math.floor(b.x*w[0]+m[0]-be.SafeBorderPadding),y:Math.floor(b.y*w[1]+m[1]-be.SafeBorderPadding),w:Math.floor(b.w*w[0]+2*be.SafeBorderPadding),h:Math.floor(b.h*w[0]+2*be.SafeBorderPadding)};const O=new dt({name:r,id:r,zIndex:d,pos:x,anchor:[.5,.5],size:[b.w,b.h],scale:g,rotate:p,translate:M}),V=new wr({...z,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/w[0],1/w[1]]});O.appendChild(N)}if((D||C||B)&&(this.scaleType=Ve.proportional,this.drawEraserlines({group:O,eraserlines:this.getRenderableEraserLines(this.workOptions),eraserFaces:C,pos:x,layer:n},c)),this.replace(n,a||r,O),g||p||M){const N=O.getBoundingClientRect();E={x:Math.floor(N.x-be.SafeBorderPadding),y:Math.floor(N.y-be.SafeBorderPadding),w:Math.floor(N.width+2*be.SafeBorderPadding),h:Math.floor(N.height+2*be.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&&be.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),be.updateNodeOpt(e)}}class Jy extends be{constructor(e){super(e);L(this,"canRotate",!1);L(this,"scaleType",Ve.all);L(this,"toolsType",Z.Star);L(this,"tmpPoints",[]);L(this,"workOptions");L(this,"oldRect");L(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 C=Date.now();C-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=C,D.op=this.tmpPoints.map(B=>[...B.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 M=Ge(p,this.oldRect);return this.oldRect=p,{rect:M,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=bt(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&&be.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:M,translate:I,strokeType:D,eraserlines:C,eraserFaces:B,doingLines:T,lineDash:f,lineCap:m}=this.workOptions,w=n.worldScaling,{rect:v,pos:b,points:x}=this.computDrawPoints(l,h,d,g),z={close:!0,points:x,lineWidth:l,fillColor:c!=="transparent"&&c||void 0,strokeColor:a,normalize:!0,lineCap:m,lineDash:D===ze.Dotted?[f&&f[0]||1,(f&&f[1]||2)*l]:D===ze.LongDotted?[(f&&f[0]||1)*l,(f&&f[1]||2)*l]:void 0},E={name:r,id:r,zIndex:u,pos:b,anchor:[.5,.5],size:[v.w,v.h]};p&&(E.scale=p),M&&(E.rotate=M),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/w[0],1/w[1]]});O.append(A)}const V=new wr({...z,pos:[0,0]});O.append(V),(C||B||T)&&(this.scaleType=Ve.proportional,this.drawEraserlines({group:O,eraserlines:this.getRenderableEraserLines(this.workOptions),eraserFaces:B,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-be.SafeBorderPadding),y:Math.floor(N.y-be.SafeBorderPadding),w:Math.floor(N.width+be.SafeBorderPadding*2),h:Math.floor(N.height+be.SafeBorderPadding*2)}}computDrawPoints(e,r,n,s){const o=_e(this.tmpPoints),a=[Math.floor(o.x+o.w/2),Math.floor(o.y+o.h/2)],c=m0(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 M=p*d-.5*Math.PI;let I,D;p%n===1?(I=u*c[0]*Math.cos(M),D=u*c[1]*Math.sin(M)):(I=l*c[0]*Math.cos(M),D=l*c[1]*Math.sin(M),h.push(I,D)),h.push(I,D)}return{rect:_e(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&&be.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 M=r;return r.tagName==="GROUP"&&(M=r.children[0]),o&&(M.setAttribute("strokeColor",o),p!=null&&p.strokeColor&&(p.strokeColor=o)),a&&(a==="transparent"?M.setAttribute("fillColor","rgba(0,0,0,0)"):M.setAttribute("fillColor",a),p!=null&&p.fillColor&&(p.fillColor=a)),c===Z.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}),be.updateNodeOpt(e)}}class _y extends be{constructor(e){super(e);L(this,"canRotate",!1);L(this,"scaleType",Ve.all);L(this,"toolsType",Z.Polygon);L(this,"tmpPoints",[]);L(this,"workOptions");L(this,"oldRect");L(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 C=Date.now();C-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=C,D.op=this.tmpPoints.map(B=>[...B.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 M=Ge(p,this.oldRect);return this.oldRect=p,{rect:M,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=bt(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&&be.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:M,eraserlines:I,eraserFaces:D,doingLines:C,lineCap:B,lineDash:T}=this.workOptions,f=n.worldScaling,{rect:m,pos:w,points:v}=this.computDrawPoints(l,h),b={close:!0,points:v,lineWidth:l,fillColor:c!=="transparent"&&c||void 0,strokeColor:a,normalize:!0,lineCap:B,lineDash:M===ze.Dotted?[T&&T[0]||1,(T&&T[1]||2)*l]:M===ze.LongDotted?[(T&&T[0]||1)*l,(T&&T[1]||2)*l]:void 0},x={name:r,id:r,zIndex:u,pos:w,anchor:[.5,.5],size:[m.w,m.h]};d&&(x.scale=d),g&&(x.rotate=g),p&&(x.translate=p);const z=new dt(x);if(s){const V=new Zt({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:a,lineWidth:1,scale:[1/f[0],1/f[1]]});z.append(V)}const E=new wr({...b,pos:[0,0]});z.append(E),(I||D||C)&&(this.scaleType=Ve.proportional,this.drawEraserlines({group:z,eraserlines:this.getRenderableEraserLines(this.workOptions),eraserFaces:D,pos:w,layer:n},o)),this.replace(n,r,z);const O=z.getBoundingClientRect();return this.isDelete&&z.setAttribute("opacity",0),{x:Math.floor(O.x-be.SafeBorderPadding),y:Math.floor(O.y-be.SafeBorderPadding),w:Math.floor(O.width+be.SafeBorderPadding*2),h:Math.floor(O.height+be.SafeBorderPadding*2)}}computDrawPoints(e,r){const n=_e(this.tmpPoints),s=[Math.floor(n.x+n.w/2),Math.floor(n.y+n.h/2)],o=m0(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:_e(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&&be.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===Z.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}),be.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 e0 extends be{constructor(e){super(e);L(this,"canRotate",!1);L(this,"scaleType",Ve.all);L(this,"toolsType",Z.SpeechBalloon);L(this,"ratio",.8);L(this,"tmpPoints",[]);L(this,"workOptions");L(this,"oldRect");L(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}static normalizeStorageData(e){return this.normalizeDrawableStorageData(e)}consume(e){var M;const{data:r,isFullWork:n,isSubWorker:s,isMainThread:o,smoothSync:a,isSimpleWorker:c}=e,l=(M=r==null?void 0:r.workId)==null?void 0:M.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 C=Date.now();C-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=C,D.op=this.tmpPoints.map(B=>[...B.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=bt(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&&be.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:M,eraserFaces:I,doingLines:D,lineDash:C,lineCap:B}=this.workOptions,{rect:T,pos:f,points:m}=this.computDrawPoints(c,u),w={points:m.map(E=>E.XY),lineWidth:c,fillColor:a!=="transparent"&&a||void 0,strokeColor:o,normalize:!0,className:`${f[0]},${f[1]}`,close:!0,lineCap:B,lineDash:p===ze.Dotted?[C&&C[0]||1,(C&&C[1]||2)*c]:p===ze.LongDotted?[(C&&C[0]||1)*c,(C&&C[1]||2)*c]:void 0},v={name:r,id:r,zIndex:l,pos:f,anchor:[.5,.5],size:[T.w,T.h]};h&&(v.scale=h),d&&(v.rotate=d),g&&(v.translate=g);const b=new dt(v),x=new wr({...w,pos:[0,0]});b.append(x),(M||I||D)&&(this.scaleType=Ve.proportional,this.drawEraserlines({group:b,eraserlines:this.getRenderableEraserLines(this.workOptions),eraserFaces:I,pos:f,layer:n},s)),this.replace(n,r,b);const z=b.getBoundingClientRect();return this.isDelete&&b.setAttribute("opacity",0),{x:Math.floor(z.x-be.SafeBorderPadding),y:Math.floor(z.y-be.SafeBorderPadding),w:Math.floor(z.width+be.SafeBorderPadding*2),h:Math.floor(z.height+be.SafeBorderPadding*2)}}transformControlPoints(e){const r=_e(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=_e(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),M=fe.Sub(s[2],new fe(0,a,0)),I=fe.Sub(s[2],new fe(o,0,0)),D=fr.getBezierPoints(10,M,s[2],I),C=fe.Add(s[3],new fe(o,0,0)),B=fe.Sub(s[3],new fe(0,a,0)),T=fr.getBezierPoints(10,C,s[3],B),f=o*(1-this.ratio)*10,m=a*(1-this.ratio)*10;switch(r){case"bottom":{const b=fe.Sub(s[2],new fe(o*5-f/2,0,0)),x=fe.Sub(s[2],new fe(o*5,-m,0)),z=fe.Sub(s[2],new fe(o*5+f/2,0,0));c.push(x,z,...T,...h,...p,...D,b);break}case"bottomRight":{const b=fe.Sub(s[2],new fe(o*1.1,0,0)),x=fe.Sub(s[2],new fe(o*1.1+f/2,-m,0)),z=fe.Sub(s[2],new fe(o*1.1+f,0,0));c.push(x,z,...T,...h,...p,...D,b);break}case"bottomLeft":{const b=fe.Add(s[3],new fe(o*1.1+f,0,0)),x=fe.Add(s[3],new fe(o*1.1+f/2,m,0)),z=fe.Add(s[3],new fe(o*1.1,0,0));c.push(x,z,...T,...h,...p,...D,b);break}case"top":{const b=fe.Sub(s[1],new fe(o*5-f/2,0,0)),x=fe.Sub(s[1],new fe(o*5,m,0)),z=fe.Sub(s[1],new fe(o*5+f/2,0,0));c.push(x,b,...p,...D,...T,...h,z);break}case"topRight":{const b=fe.Sub(s[1],new fe(o*1.1,0,0)),x=fe.Sub(s[1],new fe(o*1.1+f/2,m,0)),z=fe.Sub(s[1],new fe(o*1.1+f,0,0));c.push(x,b,...p,...D,...T,...h,z);break}case"topLeft":{const b=fe.Add(s[0],new fe(o*1.1+f,0,0)),x=fe.Add(s[0],new fe(o*1.1+f/2,-m,0)),z=fe.Add(s[0],new fe(o*1.1,0,0));c.push(x,b,...p,...D,...T,...h,z);break}case"left":{const b=fe.Add(s[0],new fe(0,a*5-m/2,0)),x=fe.Add(s[0],new fe(-f,a*5,0)),z=fe.Add(s[0],new fe(0,a*5+m/2,0));c.push(x,b,...h,...p,...D,...T,z);break}case"leftTop":{const b=fe.Add(s[0],new fe(0,a*1.1,0)),x=fe.Add(s[0],new fe(-f,a*1.1+m/2,0)),z=fe.Add(s[0],new fe(0,a*1.1+m,0));c.push(x,b,...h,...p,...D,...T,z);break}case"leftBottom":{const b=fe.Sub(s[3],new fe(0,a*1.1+m,0)),x=fe.Sub(s[3],new fe(f,a*1.1+m/2,0)),z=fe.Sub(s[3],new fe(0,a*1.1,0));c.push(x,b,...h,...p,...D,...T,z);break}case"right":{const b=fe.Add(s[1],new fe(0,a*5-m/2,0)),x=fe.Add(s[1],new fe(f,a*5,0)),z=fe.Add(s[1],new fe(0,a*5+m/2,0));c.push(x,z,...D,...T,...h,...p,b);break}case"rightTop":{const b=fe.Add(s[1],new fe(0,a*1.1,0)),x=fe.Add(s[1],new fe(f,a*1.1+m/2,0)),z=fe.Add(s[1],new fe(0,a*1.1+m,0));c.push(x,z,...D,...T,...h,...p,b);break}case"rightBottom":{const b=fe.Sub(s[2],new fe(0,a*1.1+m,0)),x=fe.Sub(s[2],new fe(-f,a*1.1+m/2,0)),z=fe.Sub(s[2],new fe(0,a*1.1,0));c.push(x,z,...D,...T,...h,...p,b);break}}const w=_e(this.tmpPoints,e),v=[Math.floor(w.x+w.w/2),Math.floor(w.y+w.h/2)];return{rect:w,pos:v,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&&be.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===Z.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}),be.updateNodeOpt(e)}}var mpe=ai,ype=Nr,vpe="[object Boolean]";function Mpe(i){return i===!0||i===!1||ype(i)&&mpe(i)==vpe}var wpe=Mpe;const Gn=Jr(wpe);class t0 extends be{constructor(e){super(e);L(this,"canRotate",!1);L(this,"scaleType",Ve.both);L(this,"toolsType",Z.Straight);L(this,"tmpPoints",[]);L(this,"workOptions");L(this,"oldRect");L(this,"straightTipWidth");L(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 C=Date.now();C-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=C,D.op=this.tmpPoints.map(B=>[...B.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 M=Ge(p,this.oldRect);return this.oldRect=p,{rect:M,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=bt(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&&be.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:M,lineCap:I,lineDash:D}=this.workOptions,C=n.worldPosition,B=n.worldScaling,{d:T,rect:f,isDot:m}=this.computDrawPoints(a,d),w=[f.x+f.w/2,f.y+f.h/2],v=new dt({pos:w,anchor:[.5,.5],size:[f.w,f.h],name:r,id:r,normalize:!0,zIndex:c}),b={pos:[0,0],normalize:!0,d:T,fillColor:o,strokeColor:o,lineDash:m?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:m?void 0:I,lineWidth:d===ze.Normal||m?0:a};l&&(b.scale=l),u&&(b.rotate=u),h&&(b.translate=h);const x=new Zt(b);v.append(x),(g||p||M)&&(this.scaleType=Ve.proportional,this.drawEraserlines({group:v,eraserlines:this.getRenderableEraserLines(this.workOptions),eraserFaces:p,pos:w,layer:n},s)),this.replace(n,r,v);let z={x:Math.floor(f.x*B[0]+C[0]-be.SafeBorderPadding),y:Math.floor(f.y*B[1]+C[1]-be.SafeBorderPadding),w:Math.floor(f.w*B[0]+2*be.SafeBorderPadding),h:Math.floor(f.h*B[1]+2*be.SafeBorderPadding)};if(u||l||h){const E=x.getBoundingClientRect();z={x:Math.floor(E.x-be.SafeBorderPadding),y:Math.floor(E.y-be.SafeBorderPadding),w:Math.floor(E.width+be.SafeBorderPadding*2),h:Math.floor(E.height+be.SafeBorderPadding*2)}}return this.isDelete&&v.setAttribute("opacity",0),z}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=qr(this.tmpPoints,!1):g=qr(d,!0),{d:g,rect:_e(d),isDot:!1,pos:this.tmpPoints[0].XY}}computDotPoints(e){const r=Ae.GetDotStroke(this.tmpPoints[0],e/2,8);return{d:qr(r,!0),rect:_e(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&&be.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),be.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}};L(Yt,"proxyToRaw",new WeakMap),L(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 $n=Yt;const Xn="__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 Tpe(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 Spe(i,t){t&&(i.meta={...i.meta,...t})}function Ipe(i){return(!i.expectedRender||i.gotRender)&&(!i.expectedStorage||i.gotStorage)}function Cpe(i){return!i.ackTimer&&i.finalizeRequested}function xpe(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(Xn)?t===Xn:!!t&&i.has(t):!t||i.has(t)}function cl(i,t){const e=t.toString();return i.isLocalId(e)?i.transformKey(e):e}function ll(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===Xn){n.add(Xn);continue}const l=cl(i,c),u=s==null?void 0:s[l];if(i.getLocalId(l)===Pe){(o=u==null?void 0:u.selectIds)==null||o.forEach(h=>{n.add(cl(i,h))});continue}n.add(l),(a=u==null?void 0:u.selectIds)==null||a.forEach(h=>{n.add(cl(i,h))})}return n}function bg(i,t,e){return e!=null&&e.has(Xn)?!t.has(i):e!=null&&e.size?e.has(i):!t.has(i)}const Epe={[Z.Selector]:De.selector,[Z.Clicker]:De.clicker,[Z.Text]:De.text,[Z.Pencil]:De.pencil,[Z.LaserPen]:De.laserPen,[Z.Arrow]:De.arrow,[Z.Straight]:De.straight,[Z.Rectangle]:De.rectangle,[Z.Ellipse]:De.ellipse,[Z.Star]:rr.star,[Z.Polygon]:rr.polygon,[Z.SpeechBalloon]:rr.speechBalloon,[Z.Eraser]:De.eraser,[Z.PencilEraser]:De.pencilEraser,[Z.BitMapEraser]:rr.bitMapEraser};function sc(i){return i===void 0?void 0:Epe[i]}function Ape(i,t){return i||t}function Npe(i){return sc(i)}const bi=5;class Dpe{constructor(t){L(this,"internalMsgEmitter");L(this,"publicMsgEmitter");L(this,"control");L(this,"editors");L(this,"activeId");L(this,"proxyMap");L(this,"taskqueue",new Map);L(this,"undoTickerId");L(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&&(e.opt.text&&e.opt.text.replace(/\s*,/g,"")?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 $n;const o=this,a=$n.interceptors.set;$n.interceptors.set=function(l,u){return o.interceptors.set(l,u),a.call(this,l,u)};const c=$n.interceptors.delete;$n.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 C,B,T,f,m,w,v,b,x;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=((C=this.collector)==null?void 0:C.isLocalId(t))?(B=this.collector)==null?void 0:B.transformKey(t):t,D=((T=this.collector)==null?void 0:T.storage[r])&&this.collector.storage[r][n]&&this.collector.storage[r][n][I]||void 0;D?D.toolsType===Z.Text&&(o&&(this.control.worker.queryTaskBatchData({workId:t,msgType:he.UpdateNode}).forEach(z=>{var E;(E=this.control.worker)==null||E.taskBatchData.delete(z)}),(v=this.control.worker)==null||v.taskBatchData.add({workId:t,msgType:he.UpdateNode,dataType:l||Ee.Local,toolsType:Z.Text,opt:c,viewId:r,scenePath:n,willRefresh:!0}),(b=this.control.worker)==null||b.runAnimation()),s&&!g&&((x=this.collector)==null||x.dispatch({type:he.UpdateNode,workId:t,toolsType:Z.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&&((f=this.collector)==null||f.dispatch({type:c.text&&he.FullWork||he.CreateWork,workId:t,toolsType:Z.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&&((m=this.control.worker)==null||m.taskBatchData.add({workId:t,msgType:c.text&&he.FullWork||he.CreateWork,dataType:l||Ee.Local,toolsType:Z.Text,opt:c,viewId:r,scenePath:n,willRefresh:!0}),(w=this.control.worker)==null||w.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:Z.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:Z.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);(r==null?void 0:r.opt.text)&&(r==null?void 0:r.opt.text.replace(/\s*,/g,""))?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,C;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),M={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 T=l==null?void 0:l.uid;if(!T){const f=this.editors.get(u);T=f&&((C=f.opt)==null?void 0:C.uid)}T&&this.control.cursor.collectServiceCursor({op:h&&[h[0]+d[0],h[1]+d[1]],uid:T,workState:ge.Done,cursorTool:sc(Z.Text),viewId:o,type:he.Cursor})}return this.editors.set(u,M),c===Ee.Service&&n.workState===ge.Done&&this.activeId===u&&(this.activeId=void 0),(e.updateView??!0)&&this.control.viewContainerManager.updateTextEditorInfo(o,this.activeId),M}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,M;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(Z.Text,s);if(!c)return;const l=(M=this.control.viewContainerManager)==null?void 0:M.transformToOriginPoint([e,r],t),h=vl(n,{whiteList:{},stripIgnoreTag:!0,stripIgnoreTagBody:["script"]}).split(/\n/),d=c.toolsOpt;d.text=bt(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=vl(e,{whiteList:{},stripIgnoreTag:!0,stripIgnoreTagBody:["script"]}).split(/\n/);r.opt.text=bt(s),this.control.textEditorManager.updateTextForMasterController({workId:t,opt:r.opt,viewId:r.viewId,canSync:!0,canWorker:!0},this.control.worker.now)}}const fn=class fn extends be{constructor(e){super(e);L(this,"canRotate",!1);L(this,"scaleType",Ve.proportional);L(this,"toolsType",Z.Text);L(this,"tmpPoints",[]);L(this,"workOptions");L(this,"oldRect");this.workOptions=e.toolsOpt}static async normalizeStorageData(e){return this.normalizeStorageDataSync(e)}static normalizeStorageDataSync(e){const r=be.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]-bi,c[1]-bi],anchor:[0,0],size:a,zIndex:l},g=new dt(d),p={x:c[0]-bi,y:c[1]-bi,w:a[0],h:a[1]},M={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=cc(M,o)),(s||o&&I!==pn.outside)&&n&&this.workOptions.text){const D=await fn.createLabels(this.workOptions,n,M),{labels:C,maxWidth:B}=D;g.append(...C),M.w=Math.ceil(Math.max(B*n.worldScaling[0],M.w))}return M}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&&be.getCenterPos(l,c)}),l}updataOptService(){}async updataOptServiceAsync(e,r,n){var M,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=(M=this.vNodes)==null?void 0:M.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),Gn(u)&&(g.opt.lineThrough=u),Gn(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&&be.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(fn.textImageSnippetSize*3/4/e)||1}static async createLabels(e,r,n){var z;const s=[],{x:o,y:a}=n,{width:c,height:l}=(z=r.parent)==null?void 0:z.parent,u=li(e.text),h=u.length,{fontSize:d,lineHeight:g,bold:p,textAlign:M,italic:I,fontFamily:D,verticalAlign:C,fontColor:B,fontBgColor:T,underline:f,lineThrough:m}=e,w=fn.getSafetySnippetRatio(r)||1,v=Math.floor(d*w),b=fn.getSafetySnippetFontLength(v);let x=0;for(let E=0;E<h;E++){const O=u[E],V=g||v*1.5;if(O){const N=$ye(O),A=[0,0],P=[0,d*1.2];C==="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 Q=Math.sin(Math.PI/180*20);let K=0;const ce=[];let k=0;for(;k<N;){M==="left"&&(U[0]=K),k===0&&I==="italic"&&(U[0]=U[0]-Q/2*d);const H=O.slice(k,k+b),$={anchor:[0,0],pos:U,text:H,fontFamily:D,fontSize:v,lineHeight:V,strokeColor:B,fontWeight:p,fillColor:B,textAlign:M,fontStyle:I,scale:[1/w,1/w]},ee=new uh($),ie=await ee.textImageReady;let le=!0;if(ie){const pe=ie.rect&&ie.rect[2],we=ie.rect&&ie.rect[3];if(pe&&we){const R=pe/w,j=we/w;K=R+K,I==="italic"&&(p==="bold"?K=K-Q*d*1.2:K=K-Q*d),((U[0]+A[0]+R)*r.worldScaling[0]+o<=0||(U[0]+A[0])*r.worldScaling[0]+o>=c||(U[1]+A[1]+j)*r.worldScaling[1]+a<=0||(U[1]+A[1])*r.worldScaling[1]+a>=l)&&(ee.disconnect(),le=!1),le&&ce.push(ee)}}k+=b}P[0]=K,I==="italic"&&(P[0]=P[0]+Q*d),x=Math.max(x,P[0]);let W=!0;if(((A[0]+P[0])*r.worldScaling[0]+o<=0||A[0]*r.worldScaling[0]+o>=c||(A[1]+P[1])*r.worldScaling[0]+a<=0||A[1]*r.worldScaling[1]+a>=l)&&(W=!1),W){if(f){const ee=Math.floor(d/10),ie={normalize:!1,pos:[0,d*1.1+ee/2],lineWidth:ee,points:[0,0,Math.ceil(P[0]),0],strokeColor:B,className:"underline"},le=new wr(ie);ce.push(le)}if(m){const ee={normalize:!1,pos:[0,d*1.2/2],lineWidth:Math.floor(d/10),points:[0,0,Math.ceil(P[0]),0],strokeColor:B,className:"lineThrough"},ie=new wr(ee);ce.push(ie)}const H={pos:A,anchor:[0,0],size:P,bgcolor:T},$=new dt(H);$.append(...ce),s.push($)}}}return{labels:s,maxWidth:x}}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:M,underline:I,fontSize:D,textInfos:C,zIndex:B}=n,T=o&&Lt(o)||s.get(r.name);if(!T||!r.parent)return;const m=T.opt;if(It(B)&&(r.setAttribute("zIndex",B),T.opt.zIndex=B),c&&m.fontColor&&(m.fontColor=c,r.children.forEach(w=>{w.tagName==="GROUP"&&w.children.forEach(v=>{v.tagName==="LABEL"?(v.setAttribute("fillColor",c),v.setAttribute("strokeColor",c)):v.tagName==="POLYLINE"&&v.setAttribute("strokeColor",c)})})),a&&m.fontBgColor&&(m.fontBgColor=a,r.children.forEach(w=>{w.tagName==="GROUP"&&w.setAttribute("bgcolor",a)})),g&&(m.bold=g),p&&(m.italic=p),Gn(M)&&(m.lineThrough=M),Gn(I)&&(m.underline=I),D&&(m.fontSize=D),u&&h&&d&&o&&m.boxPoint){const w=C==null?void 0:C.get(r.name);if(w){const{fontSize:z,boxSize:E}=w;m.boxSize=E||m.boxSize,m.fontSize=z||m.fontSize}const v=[m.boxPoint[0],m.boxPoint[1]];ac(m.boxPoint,h,d,l);const b=[T.op[0],T.op[1]],x=[b[0]-v[0],b[1]-v[1]];if(T.centerPos=[T.centerPos[0]+x[0],T.centerPos[1]+x[1]],T.opt.eraserlines)for(const z of T.opt.eraserlines){const{op:E,thickness:O}=z;z.thickness=Math.round(O*Math.max(d[0],d[1]));for(let V=0;V<E.length;V++)Cs(E[V],h,d,l)}}else if(l&&m.boxPoint&&(m.boxPoint=[Math.round(m.boxPoint[0]+l[0]),Math.round(m.boxPoint[1]+l[1])],T.centerPos=[T.centerPos[0]+l[0],T.centerPos[1]+l[1]],T.opt.eraserlines))for(const w of T.opt.eraserlines){const{op:v}=w;for(let b=0;b<v.length;b++){const x=v[b].map((z,E)=>E%2?z+l[1]:z+l[0]);w.op[b]=x}}return T&&s.setInfo(r.name,T),T==null?void 0:T.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}}};L(fn,"textImageSnippetSize",1024*4),L(fn,"SafeBorderPadding",30);let Ps=fn;const Ppe=.01;function r0(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,Ppe)&&(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 Ni=class Ni extends be{constructor(e){super(e);L(this,"canRotate",!1);L(this,"scaleType",Ve.none);L(this,"toolsType",Z.PencilEraser);L(this,"tmpPoints",[]);L(this,"workOptions");L(this,"worldPosition");L(this,"worldScaling");L(this,"eraserRect");L(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}=Ni.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 r0(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=_e(this.tmpPoints,e);c=Rs(c,a),c=g0(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!==Z.Pencil)continue;let g=Rs(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],M=[],I=[];for(const D of u)pu.polyline(D,p,M);if(M.length&&d.opt)for(const D of M){const C=[];for(let B=0;B<D.length;B++)B!==0&&Zr(D[B],D[B-1])||C.push(...D[B]);I.push(C)}if(I.length&&r){const D=r.createWorkShapeNode({workId:h,toolsType:Z.Pencil,toolsOpt:d.opt});D.setWorkId(h);const C=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),C.length)for(let B=0;B<C.length;B++){const T=`${h}_${Date.now()}_${B}`,f=T,w=r.setFullWork({workId:f,opt:d.opt,toolsType:Z.Pencil}).consumeService({op:C[B],isFullWork:!0,replaceId:f});r.clearWorkShapeNodeCache(f),o=Ge(o,w),n.set(T,{...d,toolsType:Z.Pencil,rect:w??d.rect,name:T,op:C[B]})}}}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}=Ni.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}=Ni.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=bt(h);return{...this.baseConsumeResult,type:he.FullWork,dataType:Ee.Local,rect:u,ops:d,willNewNodes:l,willDeleteNodes:c}}clearTmpPoints(){this.tmpPoints.length=0}};L(Ni,"eraserSizes",xh);let fa=Ni;const kpe=new Set([Z.Image,Z.BackgroundSVG]),Eg={"shape.vertices":new Set([Z.Polygon,Z.Star]),"shape.innerVerticeStep":new Set([Z.Star]),"shape.innerRatio":new Set([Z.Star]),"shape.placement":new Set([Z.SpeechBalloon])},Lpe=new Set(["fontColor","fontBgColor","fontSize","bold","italic","underline","lineThrough"]),Rpe=new Set(["strokeColor","thickness","strokeType"]),Ope=new Set(["fillColor"]),zpe=new Set(["zIndexLayer"]),jpe=new Set([Z.Pencil,Z.LaserPen,Z.Arrow,Z.Straight]),Ag=new Set([Z.Rectangle,Z.Ellipse,Z.Triangle,Z.Rhombus,Z.Polygon,Z.Star,Z.SpeechBalloon]),Bpe=new Set([Z.Pencil,Z.Arrow,Z.Straight,Z.Rectangle,Z.Ellipse,Z.Star,Z.Triangle,Z.Rhombus,Z.Polygon,Z.SpeechBalloon]);function Upe(i){return i!==void 0&&Bpe.has(i)}const Fpe=new Set([Z.Pencil]),Wpe=new Set([Z.LaserPen,Z.Arrow,Z.Straight,Z.Rectangle,Z.Ellipse,Z.Star,Z.Polygon,Z.SpeechBalloon]);function n0(i){return i===ze.Normal||i===ze.Stroke||i===ze.Dotted||i===ze.LongDotted}function Ei(i,t){return i?zpe.has(t)?!0:t==="isLocked"?kpe.has(i):Lpe.has(t)?i===Z.Text:t in Eg?Eg[t].has(i):Ope.has(t)?Ag.has(i):Rpe.has(t)?jpe.has(i)||Ag.has(i):!1:!1}function $pe(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=>Ei(i,e))}function cs(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 Ng(i,t){return!i||t===void 0||!Ei(i,"strokeType")?!1:Fpe.has(i)?n0(t):Wpe.has(i)?t===ze.Normal||t===ze.Dotted||t===ze.LongDotted:!1}function Vpe(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 Di=class Di extends be{constructor(e){super(e);L(this,"canRotate",!1);L(this,"scaleType",Ve.none);L(this,"toolsType",Z.BitMapEraser);L(this,"tmpPoints",[]);L(this,"workOptions");L(this,"worldPosition");L(this,"worldScaling");L(this,"eraserRect");L(this,"eraserPolyline");L(this,"oldRect");L(this,"committedPointIndex",-1);L(this,"changedNodes",new Map);L(this,"doingLines",new Map);L(this,"doingTransformDisposers",new Map);L(this,"deletedNodes",new Set);L(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}=Di.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 r0(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=_e(e,r);l=Rs(l,c),l=g0(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(!Upe(g.toolsType))continue;let p=Rs(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 M=[p.x,p.y,p.x+p.w,p.y+p.h],I=[],D=[];for(const T of h)pu.polyline(T,M,I);if(I.length&&g.opt)for(const T of I){const f=[];for(let m=0;m<T.length&&!(isNaN(T[m][0])||isNaN(T[m][1]));m++){const w=T[m].map(v=>Math.round(v*100)/100);if(m!==0){const v=T[m-1].map(b=>Math.round(b*100)/100);if(Zr(w,v))continue}f.push(...w)}f.length!==0&&D.push(f)}if(!D.length)continue;let C=this.doingLines.get(d);C||(C=[],this.doingLines.set(d,C),this.vNodes&&this.doingTransformDisposers.set(d,Qfe(this.vNodes,d,T=>{const f=this.doingLines.get(d);f&&Kfe(f,T)},()=>{this.doingLines.delete(d),this.changedNodes.delete(d)})));const B=C.find(T=>T.workId===this.workId);if(B?B.op.push(...D):C.push({workId:this.workId,op:D,thickness:r}),n){const{toolsType:T}=g,f=n.createWorkShapeNode({workId:d,toolsType:T,toolsOpt:{...g.opt,doingLines:C}});f==null||f.setWorkId(d);const m=f==null?void 0:f.consumeService({op:g.op,isFullWork:!0,replaceId:d});a=Ge(a,m)}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}=Di.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}=Di.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=bt(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=Jfe(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=Vpe(this.tmpPoints.length,this.committedPointIndex,e);if(r)return{points:this.tmpPoints.slice(r.start,r.end+1),committedIndex:r.committedIndex}}};L(Di,"eraserSizes",xh);let ga=Di;class ks extends be{constructor(e){super(e);L(this,"canRotate",!1);L(this,"scaleType",Ve.all);L(this,"toolsType",Z.BackgroundSVG);L(this,"tmpPoints",[]);L(this,"workOptions");L(this,"oldRect");this.workOptions=e.toolsOpt,this.scaleType=ks.getScaleType(this.workOptions)}static normalizeStorageData(e){return be.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 Ds({normalize:!0,pos:[0,0],width:c,height:l});g.appendChild(p),this.replace(r,s||n,g);const M=g.getBoundingClientRect();if(M)return{x:Math.floor(M.x-be.SafeBorderPadding),y:Math.floor(M.y-be.SafeBorderPadding),w:Math.floor(M.width+be.SafeBorderPadding*2),h:Math.floor(M.height+be.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&&be.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 M=r.parent;if(M){if(It(g)){const I=(g||0)-100;r.setAttribute("zIndex",I),p.opt.zIndex=g}if(Gn(d)&&(p.opt.locked=d),c&&l&&u&&a){const{centerX:I,centerY:D,width:C,height:B,uniformScale:T}=p.opt,f=T!==!1?[u[0],u[0]]:u,m=[I,D],w=[I,D];ac(w,l,f,a);const v=[w[0]-m[0],w[1]-m[1]];p.centerPos=[p.centerPos[0]+v[0],p.centerPos[1]+v[1]],p.opt.width=Math.round(C*f[0]),p.opt.height=Math.round(B*f[1]),p.opt.centerX=w[0],p.opt.centerY=w[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=ks.getScaleType(p.opt),o){const I=Ph(p.rect,h);p.rect=I}else{const I=be.getRectFromLayer(M,r.name);p.rect=I||p.rect}return p&&s.setInfo(r.name,p),p==null?void 0:p.rect}}}function oc(i){switch(i){case Z.Arrow:return Ky;case Z.Pencil:return Gy;case Z.Straight:return t0;case Z.Ellipse:return qy;case Z.Polygon:case Z.Triangle:return _y;case Z.Star:case Z.Rhombus:return Jy;case Z.Rectangle:return Xy;case Z.SpeechBalloon:return e0;case Z.Text:return Ps;case Z.LaserPen:return Hy;case Z.Eraser:return ua;case Z.PencilEraser:return fa;case Z.BitMapEraser:return ga;case Z.Selector:return da;case Z.Image:return Ls;case Z.BackgroundSVG:return ks}}async function Ype(i){const t=i.toolsType;if(t===void 0)return{status:"unrecoverable",reason:"missing-tools-type"};const e=oc(t);return e?e.normalizeStorageData(i):{status:"unrecoverable",reason:`unsupported-tool:${t}`}}function Gpe(i){const t=i.toolsType;if(t===void 0)return{status:"unrecoverable",reason:"missing-tools-type"};const e=oc(t);return e?t===Z.Text?Ps.normalizeStorageDataSync(i):[Z.Pencil,Z.Arrow,Z.Straight,Z.Ellipse,Z.Rectangle,Z.Polygon,Z.Triangle,Z.Star,Z.Rhombus,Z.SpeechBalloon].includes(t)?be.normalizeDrawableStorageDataSync(i):e.normalizeStorageDataSync(i):{status:"unrecoverable",reason:`unsupported-tool:${t}`}}function Nh(i,t){const{toolsType:e,...r}=i;switch(e){case Z.Arrow:return new Ky(r);case Z.Pencil:return new Gy(r);case Z.Straight:return new t0(r);case Z.Ellipse:return new qy(r);case Z.Polygon:case Z.Triangle:return new _y(r);case Z.Star:case Z.Rhombus:return new Jy(r);case Z.Rectangle:return new Xy(r);case Z.SpeechBalloon:return new e0(r);case Z.Text:return new Ps(r);case Z.LaserPen:return new Hy(r);case Z.Eraser:return new ua(r,t);case Z.BitMapEraser:return new ga(r);case Z.PencilEraser:return new fa(r);case Z.Selector:return r.vNodes?new da({...r,vNodes:r.vNodes,drawLayer:r.fullLayer}):void 0;case Z.Image:return new Ls(r);case Z.BackgroundSVG:return new ks({...r,toolsOpt:r.toolsOpt});default:return}}function i0(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=i0(r.children);t.push(...n)}r.tagName&&e.includes(r.tagName)&&t.push(r)}return t}class nu{constructor(t){L(this,"_map");L(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 s0{constructor(t,e){L(this,"viewId");L(this,"scene");L(this,"fullLayer");L(this,"curNodeMap");L(this,"targetNodeMap",[]);L(this,"highLevelIds");L(this,"canClearUids");L(this,"localUid");L(this,"spatialIndex",new F0);L(this,"spatialEntries",new Map);L(this,"verifySpatialIndex",!1);this.viewId=t,this.scene=e,this.curNodeMap=new nu}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!==Z.BackgroundSVG&&(s.toolsType===Z.Image&&s.opt.type===mn.Image&&(s.opt.locked||e&&e.disableEraseImage)||s.toolsType===Z.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&&Oye(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)),Gn(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||!pa(t,l.rect)||e&&l.toolsType===Z.Image&&l.opt.locked||r&&l.toolsType===Z.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=oc(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())pa(t,n.rect)&&e.push(r);return e}setTargetAssignKeys(t){const e=new nu;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(Nde(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 o0=(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()},Hpe=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 a0{constructor(){L(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 Qpe=30,Zpe=1e3/Qpe;function c0(i){return Math.min(Math.max(0,i),Zpe)}const ul=()=>typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now();class Kpe{constructor(t=1e3/30){L(this,"timer");L(this,"pending");L(this,"resolvePending");L(this,"activeWorkId");L(this,"generation",0);L(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-ul());return r===0?(this.lastReleaseTime=ul(),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=ul(),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 qpe{constructor(t,e,r){L(this,"viewId");L(this,"type");L(this,"scene");L(this,"fullLayer");L(this,"vNodes");L(this,"dpr");L(this,"contextType");L(this,"opt");L(this,"cameraOpt");L(this,"isSafari",!1);L(this,"combinePostMsg",new Set);L(this,"workerTaskId");L(this,"protectedTask");L(this,"delayPostDoneResolve");L(this,"cacheImages",new Map);L(this,"imageResolveMap",new Map);L(this,"taskUpdateCameraId");L(this,"taskUpdateCameraResolve");L(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 s0(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===Z.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===mn.Iconify){const[I,D]=this.getIconSize(l,u,this.dpr);d=o0(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 M=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 C=this.imageResolveMap.get(d);C!=null&&C.resolve&&C.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(M),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===iu.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===iu.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 l0{constructor(t){L(this,"viewId");L(this,"vNodes");L(this,"thread");L(this,"fullLayer");L(this,"drawLayer");L(this,"_post");L(this,"tmpOpt");L(this,"workShapes",new Map);L(this,"drawCount",0);L(this,"consumeCount",0);L(this,"syncUnitTime",He.syncOpt.interval);L(this,"combineUnitTime",He.bezier.combineUnitTime);L(this,"maxCombineEraserTime",He.pencilEraser.maxCombineTime);L(this,"eraserBatchScheduler",new a0);L(this,"drawAckBackpressure",new Kpe);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 c0(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 Nh({...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 Xpe(i){return i}var u0=Xpe;function Jpe(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 _pe=Jpe,eme=_pe,Dg=Math.max;function tme(i,t,e){return t=Dg(t===void 0?i.length-1:t,0),function(){for(var r=arguments,n=-1,s=Dg(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),eme(i,this,a)}}var rme=tme;function nme(i){return function(){return i}}var ime=nme,sme=ime,Pg=py,ome=u0,ame=Pg?function(i,t){return Pg(i,"toString",{configurable:!0,enumerable:!1,value:sme(t),writable:!0})}:ome,cme=ame,lme=800,ume=16,hme=Date.now;function dme(i){var t=0,e=0;return function(){var r=hme(),n=ume-(r-e);if(e=r,n>0){if(++t>=lme)return arguments[0]}else t=0;return i.apply(void 0,arguments)}}var fme=dme,gme=cme,pme=fme,mme=pme(gme),yme=mme,vme=u0,Mme=rme,wme=yme;function Tme(i,t){return wme(Mme(i,t,vme),i+"")}var Sme=Tme;function Ime(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 Cme=Ime;function xme(i){return i!==i}var bme=xme;function Eme(i,t,e){for(var r=e-1,n=i.length;++r<n;)if(i[r]===t)return r;return-1}var Ame=Eme,Nme=Cme,Dme=bme,Pme=Ame;function kme(i,t,e){return t===t?Pme(i,t,e):Nme(i,Dme,e)}var Lme=kme,Rme=Lme;function Ome(i,t){var e=i==null?0:i.length;return!!e&&Rme(i,t,0)>-1}var h0=Ome;function zme(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 d0=zme;function jme(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 Bme=jme,Ume=bh,Fme=h0,Wme=d0,$me=Bme,Vme=tc,Yme=Eh,Gme=200;function Hme(i,t,e,r){var n=-1,s=Fme,o=!0,a=i.length,c=[],l=t.length;if(!a)return c;e&&(t=$me(t,Vme(e))),r?(s=Wme,o=!1):t.length>=Gme&&(s=Yme,o=!1,t=new Ume(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 Qme=Hme,kg=Zs,Zme=My,Kme=Ks,Lg=kg?kg.isConcatSpreadable:void 0;function qme(i){return Kme(i)||Zme(i)||!!(Lg&&i&&i[Lg])}var Xme=qme,Jme=wh,_me=Xme;function f0(i,t,e,r,n){var s=-1,o=i.length;for(e||(e=_me),n||(n=[]);++s<o;){var a=i[s];t>0&&e(a)?t>1?f0(a,t-1,e,r,n):Jme(n,a):r||(n[n.length]=a)}return n}var eye=f0;function tye(){}var rye=tye,hl=Dy,nye=rye,iye=Ah,sye=1/0,oye=hl&&1/iye(new hl([,-0]))[1]==sye?function(i){return new hl(i)}:nye,aye=oye,cye=bh,lye=h0,uye=d0,hye=Eh,dye=aye,fye=Ah,gye=200;function pye(i,t,e){var r=-1,n=lye,s=i.length,o=!0,a=[],c=a;if(e)o=!1,n=uye;else if(s>=gye){var l=t?null:dye(i);if(l)return fye(l);o=!1,n=hye,c=new cye}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 mye=pye,yye=Qme,vye=eye,Rg=mye;function Mye(i,t,e){var r=i.length;if(r<2)return r?Rg(i[0]):[];for(var n=-1,s=Array(r);++n<r;)for(var o=i[n],a=-1;++a<r;)a!=n&&(s[n]=yye(s[n]||o,i[a],t,e));return Rg(vye(s,1),t,e)}var wye=Mye,Tye=mh,Sye=Nr;function Iye(i){return Sye(i)&&Tye(i)}var Cye=Iye,xye=Cy,bye=Sme,Eye=wye,Aye=Cye;bye(function(i){return Eye(xye(i,Aye))});class Nye extends l0{constructor(e){super(e);L(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!==Pe&&(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 Z.Selector:l&&(this.drawCount++,await this.drawSelector(l));break;case Z.Ellipse:case Z.Arrow:case Z.Straight:case Z.Rectangle:case Z.Star:case Z.Polygon:case Z.SpeechBalloon:{l&&(this.drawCount++,await this.drawShape(l));break}case Z.Pencil:{l&&(this.drawCount++,await this.drawPencil(l,r==null?void 0:r.toString()));break}case Z.BitMapEraser:case Z.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 Z.Selector:this.drawCount=0,ar(this.fullLayer,this.fullLayer.parent),this.clearWorkShapeNodeCache(n),this._post({render:[{isClearAll:!0,clearCanvas:tt.Float,viewId:this.viewId}]});break;case Z.Arrow:case Z.Straight:case Z.Ellipse:case Z.Pencil:case Z.Rectangle:case Z.Star:case Z.Polygon:case Z.SpeechBalloon:case Z.BitMapEraser:case Z.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:hn(s),clearCanvas:tt.Float,isClear:!0,viewId:this.viewId},{rect:hn(s),drawCanvas:tt.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-be.SafeBorderPadding,y:o.y-be.SafeBorderPadding,w:o.width+be.SafeBorderPadding*2,h:o.height+be.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:tt.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)&&hn(e.rect),isClear:!0,clearCanvas:tt.Float,viewId:this.viewId},{rect:(e==null?void 0:e.rect)&&hn(e.rect),drawCanvas:tt.Float,viewId:this.viewId}]})}async drawSelector(e){await this._post({subWorkerDrawCount:this.drawCount,consumeCount:this.consumeCount,render:[{rect:(e==null?void 0:e.rect)&&hn(e.rect),isClear:!0,clearCanvas:tt.Float,viewId:this.viewId},{rect:(e==null?void 0:e.rect)&&hn(e.rect),drawCanvas:tt.Float,viewId:this.viewId}]})}}class Dye{constructor(t){L(this,"viewId");L(this,"vNodes");L(this,"topLayer");L(this,"thread");L(this,"post");L(this,"serviceWorkShapes",new Map);L(this,"localWorkShapes",new Map);L(this,"tmpOpt");L(this,"syncUnitTime",He.syncOpt.interval);L(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===Z.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===Z.LaserPen)return Nh({...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=li(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 Z.LaserPen:{const g=this.computNextAnimationIndex(h,8),p=Math.max(0,h.animationIndex||0),M=(h.animationWorkData||[]).slice(p,g);if((h.animationIndex||0)<g){const I=(o=h.node)==null?void 0:o.consumeService({op:M,isFullWork:!1});h.totalRect=Ge(h.totalRect,I),h.animationIndex=g,M.length&&e.set(u,{cursorTool:Npe(h.toolsType),workState:p===0?ge.Start:g===((a=h.animationWorkData)==null?void 0:a.length)?ge.Done:ge.Doing,op:M.slice(-2)})}if(n.push({isClear:!0,rect:h.totalRect,clearCanvas:tt.TopFloat,viewId:this.viewId}),r.push({rect:h.totalRect,drawCanvas:tt.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:M,workState:I}=h;switch(g){case Z.LaserPen:{if(p&&(n.push({isClear:!0,rect:p,clearCanvas:tt.TopFloat,viewId:this.viewId}),r.push({rect:p,drawCanvas:tt.TopFloat,viewId:this.viewId})),M){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 Pye extends l0{constructor(e){super(e);L(this,"opt");L(this,"scene");L(this,"cameraOpt");L(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&&li(e.ops);if(r){let o,a;const c=(s=r.getWorkId())==null?void 0:s.toString();return r.toolsType===Z.BackgroundSVG?o=r.consumeService({isFullWork:!0,replaceId:c}):r.toolsType===Z.Image?o=await r.consumeServiceAsync({isFullWork:!0,worker:this.thread}):r.toolsType===Z.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:tt.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 iu=(i=>(i.Full="full",i.Sub="sub",i))(iu||{});class kye extends qpe{constructor(e,r,n){super(e,r,"sub");L(this,"type","sub");L(this,"_post");L(this,"topLayer");L(this,"serviceWork");L(this,"localWork");L(this,"topLayerWork");L(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 Nye(o),r.isUseSimple||(this.topLayerWork=new Dye(o)),this.snapshotWork=new Pye({...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=Wye(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===Z.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 tt.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:tt.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:tt.Float,viewId:this.viewId}),r&&s.push({isClearAll:!0,clearCanvas:tt.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:tt.Float,viewId:this.viewId}),o&&this.topLayerWork){r.push({isClearAll:!0,clearCanvas:tt.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=hn({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 Ls extends be{constructor(e){super(e);L(this,"canRotate",!0);L(this,"scaleType",Ve.all);L(this,"toolsType",Z.Image);L(this,"tmpPoints",[]);L(this,"workOptions");L(this,"oldRect");this.workOptions=e.toolsOpt,this.scaleType=Ls.getScaleType(this.workOptions)}static normalizeStorageData(e){return be.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:M}=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 C=new Ka(D);I.append(C),(g||p||M)&&this.drawEraserlines({group:I,eraserlines:this.getRenderableEraserLines(this.workOptions),eraserFaces:p,pos:[a,c],layer:r}),this.replace(r,s||n,I);const B=I.getBoundingClientRect();if(B)return{x:Math.floor(B.x-be.SafeBorderPadding),y:Math.floor(B.y-be.SafeBorderPadding),w:Math.floor(B.width+be.SafeBorderPadding*2),h:Math.floor(B.height+be.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 kye});if(p){const M=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:M,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:M&&be.getCenterPos(M,l)}),M}}}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,M=o&&Lt(o)||s.get(r.name);if(!M)return;const I=r.parent;if(I){if(p&&(M.opt.strokeColor=p),It(g)&&(r.setAttribute("zIndex",g),M.opt.zIndex=g),Gn(d)&&(M.opt.locked=d),c&&l&&u&&a){const{centerX:D,centerY:C,width:B,height:T,uniformScale:f}=M.opt,m=f!==!1?[u[0],u[0]]:u,w=[D,C],v=[D,C];ac(v,l,m,a);const b=[v[0]-w[0],v[1]-w[1]];if(M.centerPos=[M.centerPos[0]+b[0],M.centerPos[1]+b[1]],M.opt.width=Math.round(B*m[0]),M.opt.height=Math.round(T*m[1]),M.opt.centerX=v[0],M.opt.centerY=v[1],M.opt.eraserlines)for(const x of M.opt.eraserlines){const{op:z,thickness:E}=x;x.thickness=Math.round(E*Math.max(u[0],u[1]));for(let O=0;O<z.length;O++)Cs(z[O],l,u,a)}}else if(a){if(M.opt.centerX=M.opt.centerX+a[0],M.opt.centerY=M.opt.centerY+a[1],M.centerPos=[M.centerPos[0]+a[0],M.centerPos[1]+a[1]],M.opt.eraserlines)for(const D of M.opt.eraserlines){const{op:C}=D;for(let B=0;B<C.length;B++){const T=C[B].map((f,m)=>m%2?f+a[1]:f+a[0]);D.op[B]=T}}}else if(It(h))if(M.opt.rotate=h,M.scaleType=Ls.getScaleType(M.opt),o){const D=Ph(M.rect,h);M.rect=D}else{const D=be.getRectFromLayer(I,r.name);M.rect=D||M.rect}return M&&s.setInfo(r.name,M),M==null?void 0:M.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 Dh(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 _e(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 pa(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 hn(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 Rs(i,t){return{x:i.x+t[0],y:i.y+t[1],w:i.w,h:i.h}}function Lye(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 Ph(i,t){const e=Lye(i,t);return _e(e)}function g0(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 _e([l,u,h,d])}function Rye(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 Og(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 ac(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 Cs(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 p0(i,t){return i[0]>=t.x&&i[0]<=t.x+t.w&&i[1]>=t.y&&i[1]<=t.y+t.h}function m0(i,t){const e=i<=t?1:i/t,r=t<=i?1:t/i;return[e,r]}function Oye(i){for(const t of i)if(isNaN(t)||t===1/0||t===-1/0)return!1;return!0}function zye(i){return i!==Math.floor(i)}function jye(i){const t=i.toString();return t.indexOf(".")!==-1?t.split(".")[1].length:0}function Bye(i,t){for(;t!==0;)[i,t]=[t,i%t];return i}const Uye=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()},Fye=(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)},Wye=(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)),zye(e)){const o=jye(e),a=Math.pow(10,o),c=Bye(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 wi(i){return`${ma(i.x)},${ma(i.y)} `}function Ti(i,t){return`${ma((i.x+t.x)/2)},${ma((i.y+t.y)/2)} `}function ma(i){return+i.toFixed(4)}const br=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()})},Oi=i=>Math.max(1,(window.devicePixelRatio||1)/1),cc=(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?pn.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?pn.inside:pn.intersect;function $ye(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 Vye(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 Yye{constructor(t,e){L(this,"plugin");L(this,"uid");L(this,"control");this.control=t,this.plugin=e,this.uid=e.displayer.uid}getNamespaceData(){var t;return Ne.toJS((t=this.plugin)==null?void 0:t.attributes[this.namespace])||{}}getAuthSpaceData(){var t;return Ne.toJS((t=this.plugin)==null?void 0:t.attributes[this.authSpace])||{}}getGlobalUndoRedoStackData(){var t;return Ne.toJS((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)===Pe}}const Ft=class Ft extends Yye{constructor(e,r,n){super(e,r);L(this,"namespace");L(this,"authSpace");L(this,"globalUndoRedoStackSpace");L(this,"serviceStorage",{});L(this,"storage",{});L(this,"authStorage",{});L(this,"globalUndoRedoStackStorage",{});L(this,"stateDisposer");L(this,"authDisposer");L(this,"asyncClockState",!1);L(this,"limitNums",new Map);L(this,"syncInterval");L(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),M=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,M))),!M){this.Logger.error(`[Appliance]: exceeds the limit of ${s} components, current: ${n}`),(g=this.control.room)==null||g.disconnect().then(()=>{var D,C,B,T,f;(B=(C=(D=this.control.room)==null?void 0:D.callbacks)==null?void 0:C.listeners)!=null&&B.map.onKickedWithReason&&(this.Logger.info("[Appliance]: onKickedWithReason callback is called"),(f=(T=this.control.room)==null?void 0:T.callbacks)==null||f.dispatch("onKickedWithReason",m=>m("kickByAdmin")))});return}console.warn(`exceeds the limit of ${s} components, current: ${n}`);const I=M?Ft.componentsLimits[p+1]:0;this.limitNums.set(`${e}/${r}`,I)}},2e3,{maxWait:5e3}));L(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)===Pe))}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)===Pe){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=Ne.autorun(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,M]of Object.entries(n))M&&!ve.isEqual((c=this.storage)==null?void 0:c[p],M.newValue)&&(a.diffView||(a.diffView={}),a.diffView[p]=M,this.storage||(this.storage={}),M.newValue===void 0?delete this.storage[p]:this.storage[p]=ve.cloneDeep(M.newValue));if(Object.keys(s).length>0){for(const[p,M]of Object.entries(s))if(M){const{viewId:I,newValue:D}=M;M&&!ve.isEqual((u=(l=this.storage)==null?void 0:l[I])==null?void 0:u[p],D)&&(a.diffScenePath||(a.diffScenePath={}),a.diffScenePath[p]=M,this.storage||(this.storage={}),this.storage[I]||(this.storage[I]={}),M.newValue===void 0?delete this.storage[I][p]:this.storage[I][p]=ve.cloneDeep(M.newValue))}}if(Object.keys(o).length>0){for(const[p,M]of Object.entries(o))if(M){const{viewId:I,scenePath:D,newValue:C}=M;M&&!ve.isEqual((g=(d=(h=this.storage)==null?void 0:h[I])==null?void 0:d[D])==null?void 0:g[p],C)&&(a.diffData||(a.diffData={}),a.diffData[p]=M,this.storage||(this.storage={}),this.storage[I]||(this.storage[I]={}),this.storage[I][D]||(this.storage[I][D]={}),M.newValue===void 0?delete this.storage[I][D][p]:this.storage[I][D][p]=ve.cloneDeep(M.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 C,B;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:M}=e;if(!M)return;const I=Number(e.needUndoTicker??e.collectUndoTicker??void 0),D=T=>{I?this.control.internalMsgEmitter.emit("ackStorageUndoTicker",I,M,p,T,{requestId:e.requestId,emitEventType:e.emitEventType}):e.emitEventType===Se.TranslateNode||(e.emitEventType,Se.CopyNode)};switch(r){case he.Clear:const T={};p&&this.storage[M]&&this.storage[M][p]?(delete this.storage[M][p],this.setState(T,{isSync:g,viewId:M,scenePath:p})):this.storage[M]&&(delete this.storage[M],this.setState(T,{isSync:g,viewId:M,scenePath:""})),br(()=>{var b,x;(b=this.control.pluginManager)==null||b.dispatchPluginEvent("syncStorage",M,p),this.control.isUseSimple||(x=this.control.miniMapManager)==null||x.updateMiniMapCamera(M),this.clearLimitComponents(M,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(M)&&this.control.renderControl.addRenderPageElementId({viewId:M,scenePath:p,elementId:b.toString()}),this.updateValue(b.toString(),{type:he.CreateWork,workId:n,toolsType:c,opt:a},{isSync:g,viewId:M,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,x=this.storage[M]&&this.storage[M][p]&&this.storage[M][p][b]||void 0;if(x!=null&&x.ops||(x==null?void 0:x.type)===he.FullWork)return;const z=o?((x==null?void 0:x.op)||[]).slice(0,o).concat(h):h||(x==null?void 0:x.op),E=c||(x==null?void 0:x.toolsType),O=a||(x==null?void 0:x.opt),V=u||(x==null?void 0:x.updateNodeOpt);n&&E&&O&&z&&(this.control.renderControl.isUsePageAuth(M)&&this.control.renderControl.addRenderPageElementId({viewId:M,scenePath:p,elementId:b.toString()}),this.updateValue(b.toString(),{...x,type:he.DrawWork,workId:n,updateNodeOpt:V,toolsType:E,opt:O,op:z,index:o},{isSync:g,viewId:M,scenePath:p,onApplied:()=>D(b.toString())}))}break;case he.FullWork:if(p&&n){const b=this.isLocalId(n.toString())?this.transformKey(n):n,x=this.storage[M]&&this.storage[M][p]&&this.storage[M][p][b]||void 0,z=u||(x==null?void 0:x.updateNodeOpt),E=c||(x==null?void 0:x.toolsType),O=a||(x==null?void 0:x.opt),V=s||(x==null?void 0:x.ops);E&&O&&(this.control.renderControl.isUsePageAuth(M)&&this.control.renderControl.addRenderPageElementId({viewId:M,scenePath:p,elementId:b.toString()}),this.updateValue(b.toString(),{type:he.FullWork,updateNodeOpt:z,workId:b,toolsType:E,opt:O,ops:V},{isSync:g,viewId:M,scenePath:p,onApplied:()=>{D(b.toString())}}),br(()=>{var N,A;(N=this.control.pluginManager)==null||N.dispatchPluginEvent("syncStorage",M,p),this.control.isUseSimple||(A=this.control.miniMapManager)==null||A.updateMiniMapCamera(M),this.limitComponents(M,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 x=0;const z=(C=this.storage[M])==null?void 0:C[p];z&&(Object.keys(z).map(E=>{b!=null&&b.includes(E)&&(x++,this.control.renderControl.isUsePageAuth(M)&&this.control.renderControl.delRenderPageElementId({viewId:M,scenePath:p,elementId:E}),this.updateValue(E,void 0,{isSync:g,viewId:M,scenePath:p,onApplied:()=>D(E)}))}),(B=this.control.pluginManager)==null||B.dispatchPluginEvent("syncStorage",M,p),this.control.isUseSimple||br(()=>{var E;(E=this.control.miniMapManager)==null||E.updateMiniMapCamera(M)},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback"))),I&&x===0&&D()}break;case he.UpdateNode:if(p&&n&&(u||s||a)){const b=this.isLocalId(n.toString())?this.transformKey(n):n,x=this.storage[M]&&this.storage[M][p]&&this.storage[M][p][b]||void 0;x&&(x.updateNodeOpt=u,(s||h)&&(x.ops=s,x.op=h),a&&(x.opt=tu(eu(x.opt,a))),x.type=he.FullWork,this.updateValue(b.toString(),x,{isSync:g,viewId:M,scenePath:p,onApplied:()=>D(b.toString())}),this.control.isUseSimple||br(()=>{var z;(z=this.control.miniMapManager)==null||z.updateMiniMapCamera(M)},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback")))}break;case he.Select:if(!p)return;let f;d!=null&&d.length&&(f=d.map(b=>this.isLocalId(b+"")?this.transformKey(b):b));const m=this.transformKey(Pe),w=this.storage[M]&&this.storage[M][p]&&this.storage[M][p][m]||void 0,v=a||(w==null?void 0:w.opt);f&&this.checkOtherSelector(m,f,{isSync:g,viewId:M,scenePath:p}),this.updateValue(m,f&&{type:he.Select,toolsType:Z.Selector,opt:v,selectIds:f},{isSync:g,viewId:M,scenePath:p,onApplied:()=>D(m)});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)===Pe){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)):br(()=>{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 M=u[p],I=h[p];ve.isEqual(M,I)||g.push({key:p,type:I==null?void 0:I.type,toolsType:(I==null?void 0:I.toolsType)??(M==null?void 0:M.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=Ne.autorun(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,M,I,D,C,B,T,f,m,w,v,b,x,z,E,O,V,N,A,P,U,Q,K,ce,k,W,H,$,ee,ie,le,pe,we;const{operation:n,viewId:s,scenePath:o,pageId:a,pageData:c}=e;switch(n){case yt.addPage:{if(!s||!o||!a)return;const R=[this.authSpace];Object.keys(this.authStorage).length&&R.push("pageAuth");const j=this.authStorage.pageAuth||{};this.authStorage.pageAuth=j,Object.keys(j).length&&R.push(s),j[s]=j[s]||{},Object.keys(j[s]).length&&R.push(o),j[s][o]=j[s][o]||{render:(c==null?void 0:c.render)||"localSelf",pages:{}},Object.keys(j[s][o].pages).length&&R.push("pages",a);const X={};if(c!=null&&c.elementIds)for(const ae of c.elementIds.keys())X[ae]=!0;j[s][o].pages[a]=X,r&&(R.length===1?(l=this.plugin)==null||l.updateAttributes(R,ve.cloneDeep(this.authStorage)):R.length===2?(u=this.plugin)==null||u.updateAttributes(R,ve.cloneDeep(j)):R.length===3?(h=this.plugin)==null||h.updateAttributes(R,ve.cloneDeep(j[s])):R.length===4?(d=this.plugin)==null||d.updateAttributes(R,ve.cloneDeep(j[s][o])):(g=this.plugin)==null||g.updateAttributes(R,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;(B=(C=(D=(I=(M=this.authStorage)==null?void 0:M.pageAuth)==null?void 0:I[s])==null?void 0:D[o])==null?void 0:C.pages)!=null&&B[a]&&(delete this.authStorage.pageAuth[s][o].pages[a],r&&((T=this.plugin)==null||T.updateAttributes([this.authSpace,"pageAuth",s,o,"pages",a],void 0)));return}case yt.clearPage:{if(!s||!o||!a)return;(b=(v=(w=(m=(f=this.authStorage)==null?void 0:f.pageAuth)==null?void 0:m[s])==null?void 0:w[o])==null?void 0:v.pages)!=null&&b[a]&&(delete this.authStorage.pageAuth[s][o].pages[a],r&&((x=this.plugin)==null||x.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=(z=this.authStorage)==null?void 0:z.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;(k=(ce=(K=(Q=(U=(P=this.authStorage)==null?void 0:P.pageAuth)==null?void 0:U[s])==null?void 0:Q[o])==null?void 0:K.pages)==null?void 0:ce[a])!=null&&k[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&&((we=this.plugin)==null||we.updateAttributes([this.authSpace,"pageAuth",s],void 0)));return}}}dispatchRenderAuth(e,r=!0){var l,u,h,d,g,p,M,I,D,C,B,T,f,m,w,v,b,x,z,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:P}=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(P===!0)V[s].clear=!0;else if(ve.isSet(P)){V[s].clear={};for(const U of P.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?(M=this.plugin)==null||M.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])):(C=this.plugin)==null||C.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&&((B=V[s].render)!=null&&B[o])&&(delete V[s].render[o],r&&((T=this.plugin)==null||T.updateAttributes([this.authSpace,"renderAuth",s,"render",o],void 0))),r&&(O.length===1?(f=this.plugin)==null||f.updateAttributes(O,ve.cloneDeep(this.authStorage)):O.length===2?(m=this.plugin)==null||m.updateAttributes(O,ve.cloneDeep(V)):O.length===3?(w=this.plugin)==null||w.updateAttributes(O,ve.cloneDeep(V[s])):(v=this.plugin)==null||v.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?(x=this.plugin)==null||x.updateAttributes(O,ve.cloneDeep(V)):O.length===3?(z=this.plugin)==null||z.updateAttributes(O,ve.cloneDeep(V[s])):(E=this.plugin)==null||E.updateAttributes(O,c?!0:void 0));return}}}addAuthStateListener(e){this.authDisposer=Ne.autorun(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}};L(Ft,"namespace","PluginState"),L(Ft,"authSpace","PluginAuth"),L(Ft,"globalUndoRedoStackSpace","GlobalUndoRedoStack"),L(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 Gye{constructor(){L(this,"roomMembers",[]);L(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 zg(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 Hye{constructor(t){L(this,"expirationTime",He.cursor.expirationTime);L(this,"isEnableCursor");L(this,"internalMsgEmitter");L(this,"publicMsgEmitter");L(this,"control");L(this,"eventName","applianc-cursor");L(this,"displayer");L(this,"roomMember");L(this,"animationId");L(this,"maxLastSyncTime");L(this,"willSendEventWorkers",[]);L(this,"willConsumeEventWorkers",new Map);L(this,"sendEventTimerId");L(this,"animationDrawWorkers",new Map);L(this,"animationEventWorkers",new Map);L(this,"drawActiveUids",new Set);L(this,"cursorInfoMap",new Map);L(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===vs.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:M}=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),zg(I,D,h.memberId)),I.set(h.memberId,{x:d[0],y:d[1],roomMember:h,timestamp:g,type:1,workState:p,cursorTool:M})}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 M=(n=l.payload)==null?void 0:n.uid;M&&(this.removeRenderedCursorByUid(M,u),zg(p,M,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 M=(o=(s=p.roomMember)==null?void 0:s.payload)==null?void 0:o.uid;M&&p.type===1&&p.workState!==ge.Done&&this.drawActiveUids.delete(M),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&&Ne.isRoom(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:sc((r=this.control.worker.getCurrentToolsData())==null?void 0:r.toolsType)}),this.sendEventTimerId||(this.sendEventTimerId=setTimeout(()=>{this.dispatchMagixEvent()},this.maxLastSyncTime))}}dispatchMagixEvent(){var t;this.displayer&&Ne.isRoom(this.displayer)&&this.displayer.isWritable&&this.displayer.dispatchMagixEvent(this.eventName,{type:vs.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,C]=this.control.viewContainerManager.transformToOriginPoint(e,s);g=[D,C]}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),M=Ape(o,p)||De.pencil,I={consumPoint:g,workState:n,viewId:s,timestamp:this.control.worker.now,cursorTool:M};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&&Ne.isRoom(this.displayer)&&(this.willSendEventWorkers.length=0,this.displayer.dispatchMagixEvent(this.eventName,{type:vs.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()}}class hr{constructor(){L(this,"activeScenePath");L(this,"activeUndoTickerId");L(this,"forceEndedContext");L(this,"useEmtMsg");L(this,"emtType");L(this,"control");L(this,"mainEngine");L(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){br(()=>{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 y0(i,t,e){return`${e.isLocalId(i)?i:e.getLocalId(i)}-${t}`}function Qye(i,t,e){const r=new Map,n=[];for(const s of i){const o=y0(s,t,e);r.set(s,o),n.push(o)}return{copyNodeKeyBySourceKey:r,expectedWorkIds:n}}class Zye extends hr{constructor(){super(...arguments);L(this,"lastEmtData");L(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===Pe){const M=p&&this.copySelector({viewId:n,store:p});M&&this.pasteSelector({...M,viewId:n,scenePath:a,undoTickerId:c,requestId:s});break}if(p.toolsType===Z.Text&&p.opt&&p.opt.workState&&p.opt.workState!==ge.Done){const M=p&&this.copyText({viewId:n,store:p});M&&this.pasteText({...M,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],M=y0(o,l,this.serviceColloctor);if(s.toolsType===Z.Text&&s.opt){const C=s.opt;if(C&&C.boxPoint&&C.text){C.workState=ge.Done;const B=C.boxPoint;C.boxPoint=[Math.round(B[0]+p[0]),Math.round(B[1]+p[1])],C.workState=ge.Done;const T=this.control.viewContainerManager.transformToOriginPoint(C.boxPoint,a);this.control.textEditorManager.createTextForMasterController({workId:M,x:T[0],y:T[1],opt:C,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:C,type:he.FullWork,workId:M,viewId:a,scenePath:c,needUndoTicker:l,requestId:u,emitEventType:Se.CopyNode}]),l&&this.mainEngine.internalMsgEmitter.emit("finalizeRequested",l,a,[M],c)}}}copySelector(e){var M,I,D,C,B,T,f,m,w;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:((M=s.cameraOpt)==null?void 0:M.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&&((C=s.displayer.canvasBgRef.current)==null?void 0:C.getBoundingClientRect())||((B=s.displayer.canvasContainerRef.current)==null?void 0:B.getBoundingClientRect()),u=(f=(T=s.displayer)==null?void 0:T.floatBarRef.current)==null?void 0:f.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 v of o){const b=this.serviceColloctor.isLocalId(v)?this.serviceColloctor.transformKey(v):v,x=(w=(m=this.serviceColloctor)==null?void 0:m.getStorageData(s.id,s.focusScenePath))==null?void 0:w[b];x&&a.set(v,x)}return{copyStores:a,copyCoordInfo:c}}pasteSelector(e){var B,T,f,m;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],M=[],I=[],{copyNodeKeyBySourceKey:D,expectedWorkIds:C}=Qye(r.keys(),a,this.serviceColloctor);a&&C.length&&this.mainEngine.internalMsgEmitter.emit("finalizeRequested",a,s,C,o);for(const[w,v]of r.entries()){const b=D.get(w);if(!b)continue;const x={useAnimation:!1};if(v.toolsType===Z.Text&&v.opt){const z=v.opt;if(z&&z.boxPoint&&z.text){z.workState=ge.Done;const E=z.boxPoint;z.boxPoint=[Math.round(E[0]+p[0]),Math.round(E[1]+p[1])],z.workState=ge.Done;const O=this.control.viewContainerManager.transformToOriginPoint(z.boxPoint,s);this.control.textEditorManager.createTextForMasterController({workId:b,x:O[0],y:O[1],opt:z,scale:((B=l.cameraOpt)==null?void 0:B.scale)||1,type:vr.Text,isActive:!1,viewId:s,scenePath:o,requestId:c,emitEventType:Se.CopyNode})}I.push({...v,opt:z,type:he.FullWork,workId:b,viewId:s,scenePath:o,requestId:c,needUndoTicker:a,emitEventType:Se.CopyNode});continue}if((v.toolsType===Z.Image||v.toolsType===Z.BackgroundSVG)&&(v.opt.uuid=b,v.opt.centerX=v.opt.centerX+p[0],v.opt.centerY=v.opt.centerY+p[1]),v.ops){const z=li(v.ops).map((O,V)=>{const N=V%3;return N===0?O+p[0]:N===1?O+p[1]:O}),E=bt(z);v.ops=E}if((T=v==null?void 0:v.opt)!=null&&T.eraserlines&&(f=v==null?void 0:v.opt)!=null&&f.eraserlines.length)for(const z of(m=v==null?void 0:v.opt)==null?void 0:m.eraserlines){const{op:E}=z;for(let O=0;O<E.length;O++){const V=E[O].map((N,A)=>A%2?N+p[1]:N+p[0]);z.op[O]=V}}I.push({...v,updateNodeOpt:x,type:he.FullWork,workId:b,viewId:s,scenePath:o,requestId:c,needUndoTicker:a,emitEventType:Se.CopyNode}),M.push([{...v,updateNodeOpt:x,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}])}M.length&&this.collectForLocalWorker(M),I.length&&this.collectForServiceWorker(I)}}class Kye extends hr{constructor(){super(...arguments);L(this,"lastEmtData");L(this,"emitEventType",Se.SetColorNode);L(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 m,w;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 M=e.scenePath||this.activeScenePath||p.focusScenePath;u!==ge.Done&&(this.lastEmtData={...e,scenePath:M});const I=[...n],D=this.serviceColloctor.storage,C=[],B={},T=this.ensureUndoTicker(l,M,u,n);this.undoTickerId&&(this.control.textEditorManager.UndoTickerId=this.undoTickerId);const f=new Set;for(;I.length;){const v=I.pop();if(!v)continue;const b=v.toString(),x=this.serviceColloctor.isLocalId(b),z=x?this.serviceColloctor.transformKey(v):b;let E=b;!x&&this.serviceColloctor.isOwn(E)&&(E=this.serviceColloctor.getLocalId(E));const O=(w=(m=D==null?void 0:D[l])==null?void 0:m[M])==null?void 0:w[z];if(O){const V=O.updateNodeOpt||{};if(a||c){if(a){V.fontColor=a;const[A,P,U,Q]=ys(a);B.textColor=[A,P,U],B.textOpacity=Q}if(c)if(V.fontBgColor=Bo(c)?"transparent":c,Bo(c))B.textBgColor=void 0,B.textBgOpacity=void 0;else{const[A,P,U,Q]=ys(c);B.textBgColor=[A,P,U],B.textBgOpacity=Q}if(O.toolsType===Z.Text&&O.opt&&u!==ge.Start){E&&u===ge.Done&&f.add(E.toString()),this.setTextColor(E,Lt(O),V,l,g,u===ge.Done&&T||void 0);continue}}if(s){V.strokeColor=s;const[A,P,U,Q]=ys(s);B.strokeColor=[A,P,U],B.strokeOpacity=Q}if(o)if(V.fillColor=Bo(o)?"transparent":o,Bo(o))B.fillColor=void 0,B.fillOpacity=void 0;else{const[A,P,U,Q]=ys(o);B.fillColor=[A,P,U],B.fillOpacity=Q}h&&(V.thickness=h,B.strokeWidth=h),d&&(B.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:M,requestId:g,needUndoTicker:u===ge.Done&&T||void 0};E&&u===ge.Done&&f.add(E.toString()),C.push([N,{workId:E,msgType:he.UpdateNode,emitEventType:this.emitEventType}])}}if(u===ge.Done&&T){const v=[...f];v.length&&this.mainEngine.internalMsgEmitter.emit("finalizeRequested",T,l,v,M)}C.length?(u===ge.Done&&(this.undoTickerId=void 0,this.control.textEditorManager.UndoTickerId=void 0),this.collectForLocalWorker(C,r)):u===ge.Done&&(this.undoTickerId=void 0,this.control.textEditorManager.UndoTickerId=void 0),Object.keys(B).length&&setTimeout(()=>{var v;(v=this.control.room)==null||v.setMemberState(B)},0),u===ge.Done&&(this.lastEmtData=void 0,this.activeScenePath=void 0,this.activeUndoTickerId=void 0)}}class qye extends hr{constructor(){super(...arguments);L(this,"lastEmtData");L(this,"emitEventType",Se.ZIndexNode);L(this,"zIndexMap",new Map);L(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 C=l.pop();if(!C)continue;const B=C.toString(),T=this.serviceColloctor.isLocalId(B),f=T?this.serviceColloctor.transformKey(C):B;let m=B;!T&&this.serviceColloctor.isOwn(m)&&(m=this.serviceColloctor.getLocalId(m));const w=Lt(u[s][c][f]);let v,b;if(w&&m===Pe){if(w.selectIds){for(const E of w.selectIds){const O=M(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===Z.BackgroundSVG?(g.push(E),g.sort((N,A)=>{var Q,K,ce,k;const P=((K=(Q=u[M(N,this.serviceColloctor)])==null?void 0:Q.opt)==null?void 0:K.zIndex)||0,U=((k=(ce=u[M(N,this.serviceColloctor)])==null?void 0:ce.opt)==null?void 0:k.zIndex)||0;return P>U?1:N<A?-1:0})):(d.push(E),d.sort((N,A)=>{var Q,K,ce,k;const P=((K=(Q=u[M(N,this.serviceColloctor)])==null?void 0:Q.opt)==null?void 0:K.zIndex)||0,U=((k=(ce=u[M(N,this.serviceColloctor)])==null?void 0:ce.opt)==null?void 0:k.zIndex)||0;return P>U?1:N<A?-1:0}))}const x=w.updateNodeOpt||{};x.zIndexLayer=n;const z={workId:C,msgType:he.UpdateNode,dataType:Ee.Local,updateNodeOpt:x,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),v=this.getMaxZIndex(s)):(this.addMinLayer(s),v=this.getMinZIndex(s)),d.forEach(E=>{var A,P,U,Q,K;const O=(A=this.serviceColloctor)==null?void 0:A.isLocalId(E);let V=O&&((P=this.serviceColloctor)==null?void 0:P.transformKey(E))||E;const N=(Q=(U=u==null?void 0:u[s])==null?void 0:U[c])==null?void 0:Q[V];N&&(!O&&((K=this.serviceColloctor)!=null&&K.isOwn(V))&&(V=this.serviceColloctor.getLocalId(V)),x.zIndex=v,N!=null&&N.opt&&(N.opt.zIndex=v))})),g.length&&(n===Mn.Top?(this.addMaxLayerForBackgroundSVG(s),b=this.getMaxZIndexForBackgroundSVG(s)):(this.addMinLayerForBackgroundSVG(s),b=this.getMinZIndexForBackgroundSVG(s)),g.forEach(E=>{var A,P,U,Q,K;const O=(A=this.serviceColloctor)==null?void 0:A.isLocalId(E);let V=O&&((P=this.serviceColloctor)==null?void 0:P.transformKey(E))||E;const N=(Q=(U=u==null?void 0:u[s])==null?void 0:U[c])==null?void 0:Q[V];N&&(!O&&((K=this.serviceColloctor)!=null&&K.isOwn(V))&&(V=this.serviceColloctor.getLocalId(V)),x.zIndexForBackgroundSVG=b,N!=null&&N.opt&&(N.opt.zIndex=b))})),z.willSerializeData=!0,h.push([z,{workId:C,msgType:he.UpdateNode,emitEventType:this.emitEventType}])}continue}}h.length&&(this.mainEngine.internalMsgEmitter.emit("finalizeRequested",p,s,h.map(([C])=>{var B;return(B=C.workId)==null?void 0:B.toString()}).filter(Boolean),c),this.collectForLocalWorker(h));function M(C,B){return B.isLocalId(C)&&B.transformKey(C)||C}}}class Xye extends hr{constructor(){super(...arguments);L(this,"lastEmtData");L(this,"emitEventType",Se.TranslateNode);L(this,"cachePosition")}collect(e,r){var M,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=(M=this.serviceColloctor)==null?void 0:M.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 C=u.pop();if(!C)continue;const B=C.toString(),T=this.serviceColloctor.isLocalId(B),f=T&&this.serviceColloctor.transformKey(C)||B;let m=B;!T&&this.serviceColloctor.isOwn(m)&&(m=this.serviceColloctor.getLocalId(m));const w=(D=(I=h==null?void 0:h[a])==null?void 0:I[l])==null?void 0:D[f];if(w&&m===Pe){if(w.selectIds){o===ge.Done&&w.selectIds.forEach(b=>{g.add(b.toString())});const v=this.control.viewContainerManager.transformToScenePoint([s.x,s.y],a);if(o===ge.Start&&(this.cachePosition=v),this.cachePosition){const b=w.updateNodeOpt||{};b.translate=[v[0]-this.cachePosition[0],v[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 x={workId:C,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&&(x.textUpdateForWoker=!0,x.willSerializeData=!0,this.cachePosition=void 0,x.needUndoTicker=this.activeUndoTickerId),d.push([x,{workId:C,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 C=this.activeUndoTickerId;if(C){const B=[...g];this.mainEngine.internalMsgEmitter.emit("finalizeRequested",C,a,B,l)}}this.collectForLocalWorker(d,r)}o===ge.Done&&(this.activeScenePath=void 0,this.activeUndoTickerId=void 0)}}class Jye extends hr{constructor(){super(...arguments);L(this,"lastEmtData");L(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 M=l.pop();if(!M)continue;const I=M.toString(),D=this.serviceColloctor.isLocalId(I),C=D?this.serviceColloctor.transformKey(M):I,B=(p=(g=c==null?void 0:c[n])==null?void 0:g[a])==null?void 0:p[C];if(B){let T=I;if(!D&&this.serviceColloctor.isOwn(T)&&(T=this.serviceColloctor.getLocalId(T)),B.toolsType===Z.Text){this.control.textEditorManager.delete(T,!0,!0);continue}h.push(T)}}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 _ye extends hr{constructor(){super(...arguments);L(this,"lastEmtData");L(this,"emitEventType",Se.ScaleNode);L(this,"targetText",new Map);L(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 C,B,T,f,m,w,v;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],M=(C=this.serviceColloctor)==null?void 0:C.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 x=b.toString(),z=this.serviceColloctor.isLocalId(x),E=z&&this.serviceColloctor.transformKey(b)||x;let O=x;!z&&this.serviceColloctor.isOwn(O)&&(O=this.serviceColloctor.getLocalId(O));const V=(T=(B=M==null?void 0:M[o])==null?void 0:B[g])==null?void 0:T[E];if(V&&O===Pe&&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 P of V.selectIds){const U=(f=this.serviceColloctor)==null?void 0:f.isLocalId(P),Q=U&&((m=this.serviceColloctor)==null?void 0:m.transformKey(P))||P;let K=Q;!U&&((w=this.serviceColloctor)!=null&&w.isOwn(Q))&&(K=this.serviceColloctor.getLocalId(Q));const ce=this.control.textEditorManager.get(K);ce&&s===ge.Start&&this.targetText.set(K,Lt(ce))}}if(this.targetText.size&&s!==ge.Start&&u){const P=[];for(const[Q,K]of this.targetText.entries()){const{opt:ce}=K,k=Math.floor(ce.fontSize*u[0]),W=this.cacheTextInfo.get(Q),H=!W&&ce.fontSize!==k||W&&W.fontSize!==k||!1,$=(v=this.control.textEditorManager.get(Q))==null?void 0:v.opt;if(H&&$&&ce.boxSize&&ce.boxPoint){const ee=this.setTextStyle(Q,{...$,fontSize:k},o);P.push(ee)}}const U=await Promise.all(P);for(const Q of U)if(Q){const{key:K,textInfo:ce}=Q;this.cacheTextInfo.set(K,{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(([x])=>{var z;return(z=x.workId)==null?void 0:z.toString()}).filter(Boolean),g)}this.collectForLocalWorker(I,r)}s===ge.Done&&(this.activeScenePath=void 0,this.activeUndoTickerId=void 0)}}class e0e extends hr{constructor(){super(...arguments);L(this,"lastEmtData");L(this,"emitEventType",Se.RotateNode);L(this,"cacheOriginRotate",0)}collect(e,r){var M,I,D,C,B,T,f;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=(M=this.serviceColloctor)==null?void 0:M.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 m=u.pop();if(!m)continue;const w=m.toString(),v=this.serviceColloctor.isLocalId(w),b=v&&this.serviceColloctor.transformKey(m)||w;let x=w;!v&&this.serviceColloctor.isOwn(x)&&(x=this.serviceColloctor.getLocalId(x));const z=(D=(I=h==null?void 0:h[a])==null?void 0:I[l])==null?void 0:D[b];if(z&&x===Pe){if(((C=z.selectIds)==null?void 0:C.length)===1){const E=z.selectIds[0];if(o===ge.Done&&g.add(E.toString()),o===ge.Start){const A=((B=this.serviceColloctor)==null?void 0:B.isLocalId(E))&&((T=this.serviceColloctor)==null?void 0:T.transformKey(E))||E,P=h[a][l][A];this.cacheOriginRotate=((f=P==null?void 0:P.opt)==null?void 0:f.rotate)||0}const O=z.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:m,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:m,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 m=this.activeUndoTickerId;if(m){const w=[...g];this.mainEngine.internalMsgEmitter.emit("finalizeRequested",m,a,w,l)}}this.collectForLocalWorker(d,r)}o===ge.Done&&(this.activeScenePath=void 0,this.activeUndoTickerId=void 0)}}function t0e(i){switch(i){case Z.Text:return vr.Text;case Z.SpeechBalloon:case Z.Star:case Z.Ellipse:case Z.Rectangle:case Z.Triangle:case Z.Rhombus:case Z.Polygon:return vr.Shape}}function v0(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 r0e(i,t){var n;const e=document.createRange(),r=v0(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 M0(i){const t=document.createTreeWalker(i,NodeFilter.SHOW_TEXT,null),e=[];let r;for(;(r=t.nextNode())!==null;)e.push(r);return e}function n0e(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 i0e(i,t){var n;const e=M0(i);if(!e.length){const s=v0(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=n0e(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 s0e(i,t,e){const r=i0e(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 jg(i,t){return!!(i!=null&&i.anchorNode)&&t.contains(i.anchorNode)}function Bg(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 o0e(i){const t=M0(i);return{textContent:t.map(e=>e.textContent||"").join(""),textNodes:t}}function w0(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 T0(i){return bt(w0(i))}function ls(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 a0e(i){const{hasPoint:t,previousByPoint:e,hasSelectionInEditor:r,rangeCount:n,isCollapsed:s}=i;return!t&&e&&r&&n>0&&s}class c0e extends hr{constructor(){super(...arguments);L(this,"lastEmtData");L(this,"emitEventType",Se.SetFontStyle);L(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&&t0e(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 T,f,m,w,v,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,M={},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=[],C=[];for(;g.length;){const x=g.pop();if(!x)continue;const z=x.toString(),E=this.serviceColloctor.isLocalId(z),O=E?this.serviceColloctor.transformKey(x):z;let V=z;!E&&this.serviceColloctor.isOwn(V)&&(V=this.serviceColloctor.getLocalId(V));const N=(f=(T=p==null?void 0:p[c])==null?void 0:T[d])==null?void 0:f[O];if(N){const A=N.updateNodeOpt||{};if(n&&(A.bold=n,M.bold=n==="bold"),s&&(A.italic=s,M.italic=s==="italic"),ve.isBoolean(o)&&(A.lineThrough=o,M.lineThrough=o),ve.isBoolean(a)&&(A.underline=a,M.underline=a),l&&(A.fontSize=l,M.textSize=l),N.toolsType===Z.Text&&N.opt){const P=this.setTextStyle(V,ve.cloneDeep(N),A,c,u,I);D.push(V),C.push(P);continue}if(N&&V===Pe&&((m=N.selectIds)!=null&&m.length))for(const P of N.selectIds){const U=(w=this.serviceColloctor)==null?void 0:w.isLocalId(P);let Q=U&&((v=this.serviceColloctor)==null?void 0:v.transformKey(P))||P;const K=p[c][d][Q]||void 0;if(!U&&((b=this.serviceColloctor)!=null&&b.isOwn(Q))&&(Q=this.serviceColloctor.getLocalId(Q)),K&&K.toolsType===Z.Text&&N.opt){const ce=this.setTextStyle(Q,ve.cloneDeep(K),A,c,u,I);D.push(Q),C.push(ce);continue}}}}const B=await Promise.all(C);for(const x of B)if(x){const{key:z,textInfo:E}=x;E&&(E.canSync=!0,E.canWorker=!0,this.control.textEditorManager.updateForViewEdited(z,E))}Object.keys(M).length&&(this.timerId&&(clearTimeout(this.timerId),this.timerId=void 0),this.timerId=setTimeout(()=>{var x;this.timerId=void 0,(x=this.control.room)==null||x.setMemberState(M)},0)),D.length&&this.mainEngine.internalMsgEmitter.emit("finalizeRequested",I,c,D,d)}}class l0e extends hr{constructor(){super(...arguments);L(this,"lastEmtData");L(this,"emitEventType",Se.SetPoint)}collect(e,r){var B,T,f;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=(B=this.serviceColloctor)==null?void 0:B.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(),M=this.serviceColloctor.isLocalId(p),I=M&&this.serviceColloctor.transformKey(g)||p;let D=p;!M&&this.serviceColloctor.isOwn(D)&&(D=this.serviceColloctor.getLocalId(D));const C=(f=(T=u==null?void 0:u[a])==null?void 0:T[l])==null?void 0:f[I];if(C&&D===Pe&&C.selectIds){const m=C.updateNodeOpt||{};m.pointMap=s,m.workState=o;const w={workId:g,msgType:he.UpdateNode,dataType:Ee.Local,updateNodeOpt:m,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:a,scenePath:l,needUndoTicker:o===ge.Done&&this.activeUndoTickerId||void 0};h.push([w,{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(([m])=>{var w;return(w=m.workId)==null?void 0:w.toString()}).filter(Boolean),l),this.collectForLocalWorker(h,r)),o===ge.Done&&(this.lastEmtData=void 0,this.activeScenePath=void 0,this.activeUndoTickerId=void 0)}}class u0e extends hr{constructor(){super(...arguments);L(this,"lastEmtData");L(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 M=l.pop();if(!M)continue;const I=M.toString(),D=this.serviceColloctor.isLocalId(I),C=D?this.serviceColloctor.transformKey(M):I;let B=I;!D&&this.serviceColloctor.isOwn(B)&&(B=this.serviceColloctor.getLocalId(B));const T=(p=(g=u==null?void 0:u[s])==null?void 0:g[c])==null?void 0:p[C];if(T){const f=T.updateNodeOpt||{};f.isLocked=n;const m={workId:B,msgType:he.UpdateNode,dataType:Ee.Local,updateNodeOpt:f,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,viewId:s,requestId:o,needUndoTicker:this.control.viewContainerManager.getUndoTickerId(s)};h.push([m,{workId:B,msgType:he.UpdateNode,emitEventType:this.emitEventType}])}}h.length&&(this.mainEngine.internalMsgEmitter.emit("finalizeRequested",d,s,h.map(([M])=>{var I;return(I=M.workId)==null?void 0:I.toString()}).filter(Boolean),c),this.collectForLocalWorker(h))}}class h0e extends hr{constructor(){super(...arguments);L(this,"lastEmtData");L(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 M=l.pop();if(!M)continue;const I=M.toString(),D=this.serviceColloctor.isLocalId(I),C=D?this.serviceColloctor.transformKey(M):I;let B=I;!D&&this.serviceColloctor.isOwn(B)&&(B=this.serviceColloctor.getLocalId(B));const T=(p=(g=u==null?void 0:u[n])==null?void 0:g[c])==null?void 0:p[C];if(T){const f={...T.updateNodeOpt,...o,willRefresh:!0};if(T&&B===Pe){const m={workId:B,msgType:he.UpdateNode,dataType:Ee.Local,updateNodeOpt:f,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,viewId:n,requestId:s,needUndoTicker:this.control.viewContainerManager.getUndoTickerId(n)};h.push([m,{workId:B,msgType:he.UpdateNode,emitEventType:this.emitEventType}])}}}h.length&&(this.mainEngine.internalMsgEmitter.emit("finalizeRequested",d,n,h.map(([M])=>{var I;return(I=M.workId)==null?void 0:I.toString()}).filter(Boolean),c),this.collectForLocalWorker(h))}}class We{constructor(t){L(this,"builders",new Map);this.builders=new Map(t.map(e=>[e,this.build(e)]))}build(t){switch(t){case Se.TranslateNode:return new Xye;case Se.ZIndexNode:return new qye;case Se.CopyNode:return new Zye;case Se.SetColorNode:return new Kye;case Se.DeleteNode:return new Jye;case Se.ScaleNode:return new _ye;case Se.RotateNode:return new e0e;case Se.SetFontStyle:return new c0e;case Se.SetPoint:return new l0e;case Se.SetLock:return new u0e;case Se.SetShapeOpt:return new h0e}}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 d0e(i){return i===ze.Stroke?ze.Normal:i}function ui(i){const{pencilOptions:t}=i,e=d0e(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 S0(i){return[i.start[0],i.start[1],0,i.end[0],i.end[1],0]}function lc(i){const{minX:t,minY:e,maxX:r,maxY:n}=i.bbox;return[t,e,0,r,n,0]}function f0e(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 g0e=(i,t)=>({toolsType:Z.Straight,opt:ui(t),op:S0(i)}),p0e=(i,t)=>({toolsType:Z.Arrow,opt:ui(t),op:S0(i)}),m0e=(i,t)=>({toolsType:Z.Rectangle,opt:{...ui(t),fillColor:"transparent"},op:f0e(i)}),y0e=(i,t)=>({toolsType:Z.Ellipse,opt:{...ui(t),fillColor:"transparent"},op:lc(i)}),v0e=(i,t)=>({toolsType:Z.Polygon,opt:{...ui(t),fillColor:"transparent",vertices:3,shapeType:Gt.Triangle},op:lc(i)}),M0e=(i,t)=>({toolsType:Z.Polygon,opt:{...ui(t),fillColor:"transparent",vertices:4,shapeType:Gt.Rhombus},op:lc(i)}),w0e=(i,t)=>({toolsType:Z.Star,opt:{...ui(t),fillColor:"transparent",vertices:10,innerVerticeStep:2,innerRatio:.4,shapeType:Gt.Pentagram},op:lc(i)}),On={straight:g0e,arrow:p0e,rectangle:m0e,ellipse:y0e,triangle:v0e,rhombus:M0e,star:w0e};function T0e(i){return bt(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 S0e(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 kh(i){return[...i].reverse()}function Si(i,t,e,r,n){const s=[];for(let o=0;o<n;o++){const a=S0e(e,o),c=kh(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 I0e(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:kh(s),threshold:r})}),n}const Ug=[[0,.5],[.25,.5],[.5,.5],[.75,.5],[1,.5]],C0e=[[.05,.5],[.3,.5],[.55,.5],[.78,.5],[1,.5],[.8,.32],[1,.5],[.8,.68]],x0e=[[.05,.5],[.3,.5],[.55,.5],[.78,.5],[1,.5],[.8,.68],[1,.5],[.8,.32]],b0e=In([[.15,.2],[.85,.2],[.85,.8],[.15,.8]]),E0e=In([[.5,.12],[.88,.82],[.12,.82]]),A0e=In([[.5,.08],[.92,.5],[.5,.92],[.08,.5]]),N0e=In([[.5,.04],[.62,.34],[.95,.36],[.68,.56],[.78,.9],[.5,.7],[.22,.9],[.32,.56],[.05,.36],[.38,.34]]),D0e=In([[.5,.04],[.74,.88],[.08,.34],[.92,.34],[.26,.88]]),P0e=Array.from({length:24},(i,t)=>{const e=Math.PI*2*t/24;return[.5+Math.cos(e)*.42,.5+Math.sin(e)*.3]}),zn=[{id:"straight-base",semanticKind:"straight",points:Ug,threshold:.72},{id:"straight-reverse",semanticKind:"straight",points:kh(Ug),threshold:.72},...I0e("arrow","arrow",[C0e,x0e],.71),...Si("rectangle","rectangle",b0e,.68,4),...Si("ellipse","ellipse",In(P0e),.64,12),...Si("triangle","triangle",E0e,.68,3),...Si("rhombus","rhombus",A0e,.66,4),...Si("star","star",N0e,.7,5),...Si("star","pentagram",D0e,.68,5)];function us(i,t,e,r){const{metrics:n}=t;return n.closureRatio>.24||n.cornerCount<e||n.cornerCount>r?null:i}const k0e=[{kind:"straight",templates:zn.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:On.straight,enabledInV1:!0},{kind:"arrow",templates:zn.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:On.arrow,enabledInV1:!0},{kind:"rectangle",templates:zn.filter(i=>i.semanticKind==="rectangle"),postProcessor(i,t){const e=us(i,t,4,6);return!e||t.metrics.bboxCornerCloseness>.15||t.metrics.bboxCornerCloseness>=t.metrics.diamondCloseness?null:e},mapper:On.rectangle,enabledInV1:!0},{kind:"ellipse",templates:zn.filter(i=>i.semanticKind==="ellipse"),postProcessor(i,t){const e=us(i,t,6,12);return!e||t.metrics.radialVariance>.5?null:e},mapper:On.ellipse,enabledInV1:!0},{kind:"triangle",templates:zn.filter(i=>i.semanticKind==="triangle"),postProcessor(i,t){return us(i,t,3,4)},mapper:On.triangle,enabledInV1:!0},{kind:"rhombus",templates:zn.filter(i=>i.semanticKind==="rhombus"),postProcessor(i,t){const e=us(i,t,4,5);return!e||t.metrics.diamondCloseness>=t.metrics.bboxCornerCloseness?null:e},mapper:On.rhombus,enabledInV1:!0},{kind:"star",templates:zn.filter(i=>i.semanticKind==="star"),postProcessor(i,t){const e=i.templateId.startsWith("pentagram"),r=us(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:On.star,enabledInV1:!0}];function Lh(){return k0e}const L0e=64,su=250;function Yr(i,t){const e=i[0]-t[0],r=i[1]-t[1];return Math.hypot(e,r)}function R0e(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 I0(i){let t=0;for(let e=1;e<i.length;e++)t+=Yr(i[e-1],i[e]);return t}function C0(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 O0e(i,t=L0e){if(i.length<=1)return i;const e=I0(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 uc(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 z0e(i,t){const e=uc(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=uc(i);return Math.atan2(t[1]-i[0][1],t[0]-i[0][0])}function B0e(i,t=su){const e=C0(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 U0e(i){const t=uc(i);return i.map(([e,r])=>[e-t[0],r-t[1]])}function x0(i){const t=O0e(i),e=z0e(t,-j0e(t)),r=B0e(e);return U0e(r)}function F0e(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 W0e(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 ou(i,t){if(i.length<=2)return i;let e=0,r=0;for(let o=1;o<i.length-1;o++){const a=W0e(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=ou(i.slice(0,r+1),t),s=ou(i.slice(r),t);return n.slice(0,-1).concat(s)}function $0e(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 V0e(i){const t=C0(i),e=Math.max(t.maxX-t.minX,1),r=Math.max(t.maxY-t.minY,1),n=Math.hypot(e,r)||1,s=I0(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=ou(h,l),g=$0e(d),p=g.length>0?Math.max(...g.map(w=>Math.abs(w-90))):90,M=d.map(([w,v])=>[(w-t.minX)/e,(v-t.minY)/r]),I=[[0,0],[1,0],[1,1],[0,1]],D=[[.5,0],[1,.5],[.5,1],[0,.5]],C=(w,v)=>w.reduce((b,x)=>{const z=Math.min(...v.map(E=>Yr(x,E)));return b+z},0)/Math.max(w.length,1),B=uc(i),T=i.map(w=>Yr(w,B)),f=T.reduce((w,v)=>w+v,0)/Math.max(T.length,1),m=f>0?T.reduce((w,v)=>w+Math.abs(v-f)/f,0)/Math.max(T.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:m,bboxCornerCloseness:C(M,I),diamondCloseness:C(M,D)}}}function Y0e(i){return i.map(t=>({template:t,normalized:x0(t.points)}))}const G0e=Y0e(Lh().flatMap(i=>i.templates));function H0e(i){const t=R0e(i.rawPoints);if(t.length<2)return null;const{bbox:e,metrics:r}=V0e(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 Q0e(i){const t=x0(i.points),e=new Map;for(const{template:r,normalized:n}of G0e){const s=F0e(t,n),o=Math.max(0,1-s/(.5*Math.sqrt(2*su*su))),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 Z0e(i){const t=Lh(),e=Q0e(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 K0e(i){return H0e(i)}function q0e(i){return Z0e(i)}function Fg(i,t){if(!i.recognized||i.kind==="none")return null;const e=Lh().find(r=>r.kind===i.kind);return(e==null?void 0:e.mapper(i,t))||null}const Yn=class Yn{constructor(){L(this,"fontDB");L(this,"FONT_DB_NAME","__APPLIANCE_PLUGIN_FONT_DB");L(this,"FONT_STORE_NAME","fonts");L(this,"FONT_DB_VERSION",1)}static getInstance(){return Yn.instance||(Yn.instance=new Yn),Yn.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}}}};L(Yn,"instance");let au=Yn;class X0e{constructor(t){L(this,"control");L(this,"getFullWorker");L(this,"getSubWorker");L(this,"indexDBUtils",au.getInstance());L(this,"fontFaceWorkerResolveMap",new Map);L(this,"fontFacesLoadingPromise");L(this,"lastFontFacesAlreadyReady",!1);L(this,"fontFaceLoadStateStarted",!1);L(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 J0e=new Set([Z.Eraser,Z.PencilEraser,Z.BitMapEraser]),_0e=new Set([Z.Pencil,Z.Arrow,Z.Straight,Z.Ellipse,Z.Rectangle,Z.Star,Z.Polygon,Z.SpeechBalloon]);function Wg(i){return i===Z.Pencil?$e.DrawingPencil:i===Z.Arrow||i===Z.Straight?$e.DrawingArrow:i===Z.Eraser?$e.DrawingEraser:i===Z.PencilEraser?$e.DrawingPencilEraser:i===Z.BitMapEraser?$e.DrawingBitMapEraser:$e.DrawingShape}function eve(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 hs=i=>typeof i=="number"&&J0e.has(i),tve=i=>i===he.FullWork||i===he.UpdateNode||i===he.RemoveNode||i===he.DrawWork;class rve{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 nve extends rve{constructor(e){super();L(this,"maxLastSyncTime",He.syncOpt.interval);L(this,"combineUnitTime",He.bezier.combineUnitTime);L(this,"maxCombineEraserTime",He.pencilEraser.maxCombineTime);L(this,"smoothSync",He.syncOpt.smoothSync);L(this,"isActive",!1);L(this,"currentToolsData");L(this,"currentLocalWorkData");L(this,"control");L(this,"internalMsgEmitter");L(this,"publicMsgEmitter");L(this,"taskBatchData",new Set);L(this,"fullWorker");L(this,"subWorker");L(this,"fullWorkerUrl");L(this,"subWorkerUrl");L(this,"methodBuilder");L(this,"zIndexNodeMethod");L(this,"subWorkerDrawCount",0);L(this,"fullWorkerDrawCount",0);L(this,"maxDrawCount",0);L(this,"_consumeCount",0);L(this,"_postCount",0);L(this,"reRenders",new Map);L(this,"localWorkViewId");L(this,"localPointsBatchData",new Map);L(this,"tasksqueue",new Map);L(this,"cameraUpdateStateByView",new Map);L(this,"cameraUpdateEndWaitersByView",new Map);L(this,"cameraTaskSequenceByView",new Map);L(this,"localWorkFinalizeQueue",Promise.resolve());L(this,"operationBarrierQueueByView",new Map);L(this,"cancelledEraseTxnIds",new Set);L(this,"snapshotMap",new Map);L(this,"boundingRectMap",new Map);L(this,"clearAllResolveMap",new Map);L(this,"localEventQueue",Promise.resolve());L(this,"localEventSequence",0);L(this,"queuedLocalEventCount",0);L(this,"activeLocalEvent");L(this,"localDoneWait");L(this,"delayWorkStateToDoneResolve");L(this,"animationId");L(this,"tmpImageConfigMap",new Map);L(this,"mainThread");L(this,"backgroundThreadManager");L(this,"willSelectorWorkId");L(this,"isLockSentEventCursor",!1);L(this,"getVNodeInfoResolveMap",new Map);L(this,"refreshTextRenderResolveMap",new Map);L(this,"fontFaceManager");L(this,"isLocalWorkActive",!1);L(this,"hasMainViewInitAck",!1);L(this,"serviceSyncReadyViews",new Set);L(this,"mainViewInitAckCallbacks",new Set);L(this,"initAckedViewIds",new Set);L(this,"pendingTransportMessages",new Map);L(this,"isRenderTransportReady",!1);L(this,"renderProbeResolve");L(this,"renderProbeRequestId");L(this,"renderProbeTimer");L(this,"initGeneration",0);L(this,"viewGenerationById",new Map);L(this,"initCameraOptByView",new Map);L(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 X0e({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}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);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),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{W0.getMarkmapRuntimeOrThrow()}catch(n){const s=n instanceof Error?n.message:String(n);throw this.Logger.error(`[Appliance]: [markmap] ${e} failed: ${s}; viewId=${r}`),n}}destroy(){var e,r,n,s,o,a;this.initGeneration++,this.renderProbeTimer&&clearTimeout(this.renderProbeTimer),this.renderProbeTimer=void 0,this.renderProbeRequestId=void 0,(e=this.renderProbeResolve)==null||e.call(this,!1),this.renderProbeResolve=void 0,this.hasMainViewInitAck=!1,this.serviceSyncReadyViews.clear(),this.initAckedViewIds.clear(),this.pendingTransportMessages.clear(),this.isRenderTransportReady=!1,this.initCameraOptByView.clear(),this.mainViewInitAckCallbacks.clear(),(r=this.methodBuilder)==null||r.destroy(),this.unWritable(),this.destroyTaskQueue(),this.taskBatchData.clear(),this.cameraUpdateStateByView.clear(),this.cameraTaskSequenceByView.clear(),this.operationBarrierQueueByView.clear(),this.cameraUpdateEndWaitersByView.forEach(c=>{c.forEach(l=>l())}),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:c,resolve:l})=>{c&&clearTimeout(c),l==null||l(!1)}),this.refreshTextRenderResolveMap.clear(),this.fontFaceManager.destroy(),(n=this.mainThread)==null||n.destroy(),this.mainThread=void 0,(s=this.backgroundThreadManager)==null||s.destroy(),this.backgroundThreadManager=void 0,(o=this.fullWorker)==null||o.terminate(),this.fullWorker=void 0,(a=this.subWorker)==null||a.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===Z.Pencil||e===Z.PencilEraser||e===Z.BitMapEraser||e===Z.LaserPen||e===Z.Arrow||e===Z.Straight||e===Z.Ellipse||e===Z.Rectangle||e===Z.Star||e===Z.Polygon||e===Z.SpeechBalloon||e===Z.Selector}get isCanDrawWork(){var r;const e=(r=this.currentToolsData)==null?void 0:r.toolsType;return e===Z.Pencil||e===Z.LaserPen||e===Z.Arrow||e===Z.Straight||e===Z.Ellipse||e===Z.Rectangle||e===Z.Star||e===Z.Polygon||e===Z.SpeechBalloon||e===Z.Triangle||e===Z.Rhombus||e===Z.BitMapEraser||e===Z.PencilEraser}get isUseZIndex(){var r;const e=(r=this.currentToolsData)==null?void 0:r.toolsType;return e===Z.Pencil||e===Z.Arrow||e===Z.Straight||e===Z.Ellipse||e===Z.Rectangle||e===Z.Star||e===Z.Polygon||e===Z.SpeechBalloon||e===Z.Text||e===Z.Image}get isCanRecordUndoRedo(){var r;const e=(r=this.currentToolsData)==null?void 0:r.toolsType;return e===Z.Pencil||e===Z.Eraser||e===Z.PencilEraser||e===Z.BitMapEraser||e===Z.Arrow||e===Z.Straight||e===Z.Ellipse||e===Z.Rectangle||e===Z.Star||e===Z.Polygon||e===Z.SpeechBalloon||e===Z.Text||e===Z.Image}get isCanSentCursor(){var r;const e=(r=this.currentToolsData)==null?void 0:r.toolsType;return e===Z.Pencil||e===Z.Text||e===Z.LaserPen||e===Z.Arrow||e===Z.Straight||e===Z.Ellipse||e===Z.Rectangle||e===Z.Star||e===Z.Polygon||e===Z.SpeechBalloon||e===Z.Triangle||e===Z.Rhombus||e===Z.Eraser||e===Z.PencilEraser||e===Z.BitMapEraser||e===Z.Selector||e===Z.Clicker}get isPostCountType(){var r;const e=(r=this.currentToolsData)==null?void 0:r.toolsType;return e===Z.Pencil||e===Z.Arrow||e===Z.Straight||e===Z.Ellipse||e===Z.Rectangle||e===Z.Star||e===Z.Polygon||e===Z.SpeechBalloon||e===Z.Triangle||e===Z.Rhombus||e===Z.Eraser||e===Z.PencilEraser||e===Z.BitMapEraser||e===Z.Selector}get isCanPostDraw(){var r;const e=(r=this.currentToolsData)==null?void 0:r.toolsType;return e===Z.Pencil||e===Z.PencilEraser||e===Z.BitMapEraser}get isCanStartEventConsum(){var r;const e=(r=this.currentToolsData)==null?void 0:r.toolsType;return e===Z.Selector||e===Z.Eraser||e===Z.PencilEraser||e===Z.BitMapEraser}async init(){this.destroy(),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.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-BPWZCEwU.js"));this.backgroundThreadManager=new e(this)}async useMainThread(){this.Logger.info("[Appliance]: no OffscreenCanvas");const{MainThreadManagerImpl:e}=await Promise.resolve().then(()=>require("./index-CcC63woo.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){this.Logger.error("[Appliance]: no worker url config");return}if(this.fullWorker=new Worker(this.fullWorkerUrl,{type:"classic"}),this.control.isUseSimple||(this.subWorker=new Worker(this.subWorkerUrl,{type:"classic"})),this.fullWorker.onmessage=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,C=(D==null?void 0:D.offscreenCanvas)===!0&&D.contextSupported===!0;this.control.applyWorkerRenderProbe(C),(s=this.renderProbeResolve)==null||s.call(this,C),this.renderProbeResolve=void 0;return}const{render:a,sp:c,fullWorkerDrawCount:l,workerTasksqueueCount:u,cameraTaskId:h,cameraSettledTaskId:d,viewId:g,consumeCount:p,consumeWorkId:M}=n.data;if(this.acceptConsumeAck(p,M),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:Z.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,M,I,D,C;let r=!1;for(const B of e){if(Xfe(this.cancelledEraseTxnIds,B.eraseTxnId)||this.fontFaceManager.handleWorkerMessage(B))continue;const{type:T,selectIds:f,opt:m,selectRect:w,strokeColor:v,fillColor:b,willSyncService:x,isSync:z,imageBitmap:E,canvasHeight:O,canvasWidth:V,rect:N,op:A,canTextEdit:P,points:U,selectorColor:Q,canRotate:K,scaleType:ce,textOpt:k,toolsType:W,workId:H,viewId:$,dataType:ee,canLock:ie,isLocked:le,shapeOpt:pe,toolsTypes:we,thickness:R,strokeType:j,useStroke:X,isgl:ae,imageSrc:q,isSubWorker:te,updateNodeOpt:y,emitEventType:S,requestId:F,reportString:Y,index:_,imageElement:re,workState:ne,isSelecting:J,needUndoTicker:se}=B;if(T===he.Init&&$){this.ackMainViewInit($,B.viewGeneration);continue}if(!$)return;const ue=B.scenePath||this.viewContainerManager.getCurScenePath($);switch(T){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=f!=null&&f.length?{...w,selectIds:f,canvasHeight:O,canvasWidth:V,points:U}:void 0;if(oe&&(m!=null&&m.strokeColor)&&(oe.selectorColor=m.strokeColor),oe&&Q&&(oe.selectorColor=Q),oe&&v&&(oe.strokeColor=v),oe&&(m!=null&&m.fillColor)&&(oe.fillColor=m.fillColor),oe&&b&&(oe.fillColor=b),oe&&ve.isBoolean(K)&&(oe.canRotate=K),oe&&ce&&(oe.scaleType=ce),oe&&P&&(oe.canTextEdit=P),oe&&k&&(oe.textOpt=k),oe&&ve.isBoolean(ie)&&(oe.canLock=ie),oe&&ve.isBoolean(le)&&(oe.isLocked=le),oe&&pe&&(oe.shapeOpt=pe),oe&&we&&(oe.toolsTypes=we),oe&&R&&(oe.thickness=R),oe&&j&&(oe.strokeType=j),oe&&ve.isBoolean(X)&&(oe.useStroke=X),$&&this.viewContainerManager.showFloatBar($,!!oe,oe),x&&((a=this.collector)==null||a.dispatch({type:T,selectIds:f,opt:m,isSync:z,viewId:$,scenePath:ue,needUndoTicker:se,requestId:F,emitEventType:S})),J)break;try{(c=this.control.selectorApi)==null||c.onSelectorSync({viewId:$,scenePath:ue,selectIds:f,selectRect:w,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(xe=>xe!==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({...B});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($,{...B,msgType:he.BackgroundSVGDelete,viewId:$,dataType:Ee.Local});break;case he.BackgroundSVGUpdate:this.backgroundThreadManager&&$&&this.backgroundThreadManager.consumeTargetOne($,{...B,msgType:he.BackgroundSVGUpdate,viewId:$,dataType:Ee.Local});break;case he.TextUpdate:if(W===Z.Text&&H&&$){const oe=S===Se.TranslateNode;S&&[Se.SetColorNode,Se.SetFontStyle,Se.SetLock,Se.SetShapeOpt,Se.ZIndexNode].includes(S)&&((M=this.control.selectorApi)==null||M.onPropertyApplied({type:S,viewId:$,scenePath:ue,requestId:F,data:this.buildPropertyAppliedData(S,m,y)}));const de=this.viewContainerManager.transformToOriginPoint((m==null?void 0:m.boxPoint)||[0,0],$),me=(m==null?void 0:m.boxSize)||[0,0],ye=(I=this.viewContainerManager.getView($))==null?void 0:I.cameraOpt;m?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:m,dataType:ee,viewId:$,canSync:x||!1,canWorker:!1,updateNodeOpt:y,skipStorageDispatch:!0}):this.control.textEditorManager.delete(H,x||!1,!1),!!(se||oe&&x)&&((D=this.collector)==null||D.dispatch({type:he.UpdateNode,workId:H,toolsType:Z.Text,opt:m,updateNodeOpt:y,isSync:x||!1,viewId:$,scenePath:ue,needUndoTicker:se,requestId:F,emitEventType:S}))}break;case he.GetTextActive:W===Z.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&&Hpe({src:q,isgl:ae,useImageBitmap:this.control.hasOffscreenCanvas}).then(oe=>{var xe;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)(xe=this.mainThread)==null||xe.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=(C=this.getVNodeInfoResolveMap.get(oe))==null?void 0:C.resolve,me={...B,uuid:oe};de&&de(me)}break;case he.ReportError:case he.ReportLog:Y&&(T===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:M,opt:I,updateNodeOpt:D,emitEventType:C,requestId:B,toolsType:T,isSync:f,viewId:m,isLockSentEventCursor:w,nextTasks:v,needUndoTicker:b,collectUndoTicker:x,undoScopeIds:z,undoScopePhase:E}=l;if(!m){console.error("[MasterControlForWorker] collectorAsyncData on viewId in",l);return}const O=l.scenePath||this.viewContainerManager.getCurScenePath(m),V=Number(x??b??void 0);if(V&&(z!=null&&z.length)&&(E==="collect"||E==="finalize")&&this.internalMsgEmitter.emit("collectExpectedWorkIds",V,m,z,O),E==="finalize"&&b&&Number(b)&&O){const N=Number(b);this.internalMsgEmitter.emit("finalizeRequested",N,m,z||[],O)}switch(b&&Number(b)&&tve(u)&&(z!=null&&z.length)&&this.internalMsgEmitter.emit("reopenStorageAck",Number(b),m,z,O),u){case he.None:{w&&br(()=>{this.setLockSentEventCursor(!1)},this.maxLastSyncTime,this.control.hasPolyfillMethod("requestIdleCallback")),b&&Number(b)&&br(()=>{this.internalMsgEmitter.emit("ackRenderUndoTicker",Number(b),m,O,{requestId:B,emitEventType:C})},0,this.control.hasPolyfillMethod("requestIdleCallback"));break}case he.DrawWork:{(r=this.collector)==null||r.dispatch({type:u,op:h,opt:I,toolsType:T,workId:d,index:g,isSync:f,viewId:m,scenePath:O,updateNodeOpt:D,needUndoTicker:b,collectUndoTicker:x,requestId:B,emitEventType:C});break}case he.FullWork:{if((n=this.collector)==null||n.dispatch({type:u,ops:M,workId:d,updateNodeOpt:D,opt:I,toolsType:T,isSync:f,viewId:m,scenePath:O,needUndoTicker:b,collectUndoTicker:x,requestId:B,emitEventType:C}),T===Z.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,m),this.willSelectorWorkId=void 0});break}case he.UpdateNode:{C&&[Se.SetColorNode,Se.SetFontStyle,Se.SetLock,Se.SetShapeOpt,Se.ZIndexNode].includes(C)&&((s=this.control.selectorApi)==null||s.onPropertyApplied({type:C,viewId:m,scenePath:O,requestId:B,data:this.buildPropertyAppliedData(C,I,D)})),(o=this.collector)==null||o.dispatch({type:u,updateNodeOpt:D,workId:d,opt:I,ops:M,op:h,isSync:f,viewId:m,scenePath:O,needUndoTicker:b,collectUndoTicker:x,requestId:B,emitEventType:C});break}case he.RemoveNode:{C===Se.DeleteNode&&((a=this.control.selectorApi)==null||a.onRemoveNodeApplied({viewId:m,requestId:B,removeIds:p})),p&&this.control.textEditorManager.deleteBatch(p,!1,!1),(c=this.collector)==null||c.dispatch({type:u,removeIds:p,isSync:f,viewId:m,scenePath:O,needUndoTicker:b,collectUndoTicker:x,requestId:B,emitEventType:C}),this.willSelectorWorkId&&(p!=null&&p.includes(this.willSelectorWorkId))&&(this.willSelectorWorkId=void 0);break}}v&&this.collectorAsyncData(v)}}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,Z.Pencil;for(const[d,g]of this.localPointsBatchData)if(g.toolsType===Z.Text){const M=g.state;if(M&&M===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 M=this.getLocalPointInfo(d);if(M){const I=this.createAutoShapeTask({workId:d,viewId:r,scenePath:s,points:[...M.rawPoints],opt:M.opt});I&&l.push(I),hs(M.toolsType)&&M.toolsType!==Z.BitMapEraser&&M.undoTickerId&&s&&u.set(M.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)===Z.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===Z.Selector?Pe:this.newWorkId,o=this.setZIndex(r);let a;if(n!==void 0&&n!==Z.Text&&this.isCanRecordUndoRedo){a=this.now;const h=hs(n)?{render:!0,storage:!0,scopeMode:"dynamic",source:Wg(n)}:{render:!0,storage:!0,source:Wg(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!==Z.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)===Z.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=K0e({rawPoints:this.toAutoShapePoints(o),pencilOptions:ve.cloneDeep(a),viewId:n,scenePath:s});if(!c)return;const l=q0e(c),u=Fg(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:T0e(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?Fg({...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,C;const p=(D=(I=e[g])==null?void 0:I.opt)==null?void 0:D.zIndex,M=(C=e[g])==null?void 0:C.toolsType;ve.isNumber(p)&&(M&&M===Z.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 M=e[g];M.opt&&ve.isNumber(M.opt.zIndex)&&M.opt.zIndex!==p&&(M.opt.zIndex=p,s.set(g,M))}s.size&&s.forEach((g,p)=>{var M;(M=this.collector)==null||M.updateValue(p,g,{viewId:r,scenePath:n,isSync:!0}),e[p]=g});for(const[g,p]of u){if(!e[g])continue;const M=e[g];M.opt&&ve.isNumber(M.opt.zIndex)&&M.opt.zIndex!==p&&(M.opt.zIndex=p,a.set(g,M))}return a.size&&a.forEach((g,p)=>{var M;(M=this.collector)==null||M.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 M,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=(M=n==null?void 0:n.displayer)==null?void 0:M.commiter;if(!(n!=null&&n.displayer)||!a||(await this.waitForLocalEventQueue(),!o()))return;const l=a.getPendingTickerSnapshots(r).filter(C=>C.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(C=>a.waitForUndoStackEnd(C,u)),g=l.filter(C=>!C.finalizeRequested).map(C=>a.waitForFinalizeRequested(C,h));let p=!1;for(const C of l){if(C.finalizeRequested||C.phase!=="doing")continue;const B=eve(C.source);if(B.kind==="stop-event"){if(!p&&(p=!0,await n.displayer.stopEventHandler(),!o()))return;continue}if(B.kind==="method-pause"&&(await((D=(I=this.methodBuilder)==null?void 0:I.getBuilder(B.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)===Z.Selector;switch((h=this.currentToolsData)==null?void 0:h.toolsType){case Z.Eraser:case Z.PencilEraser:case Z.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),br(()=>{var d;(d=this.control.pluginManager)==null||d.dispatchPluginEvent("localEvent",n,e,r)},wu,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:ru,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 p,M,I,D,C,B,T,f,m;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&&((p=this.collector)==null?void 0:p.getLocalId(l))===Pe){this.collector.isOwn(l)?this.blurSelector(o,a):this.blurSelector(o,a,l);return}if(s.toolsType===Z.LaserPen)return}const h=(M=this.viewContainerManager.getView(o))==null?void 0:M.focusScenePath;if(h&&h!==a)return;if((I=this.collector)!=null&&I.isSelector(e)){const w=(D=this.collector)==null?void 0:D.getUidFromKey(e);if(w&&!this.control.roomMember.isOnLine(w))return}if(u&&l){if(!this.control.renderControl.isFilterAble({viewId:o,elementId:e,scenePath:a},u))return;const w=c;if(w.workId=(C=this.collector)!=null&&C.isOwn(l)?(B=this.collector)==null?void 0:B.getLocalId(l):l,w.msgType=u,w.toolsType===Z.LaserPen&&(w.isRunSubWork=!0),w.toolsType===Z.BackgroundSVG){if(!this.control.isUseBackgroundThread)return;w.isRunBackgroundThread=!0}if(w.dataType=Ee.Service,w.viewId=o,w.scenePath=a,w.useAnimation=this.smoothSync&&((T=w.updateNodeOpt)==null?void 0:T.useAnimation)||!1,w.selectIds&&(w.selectIds=w.selectIds.map(v=>{var b,x;return(b=this.collector)!=null&&b.isOwn(v)?(x=this.collector)==null?void 0:x.getLocalId(v):v})),w&&w.toolsType===Z.Text||(s==null?void 0:s.toolsType)===Z.Text){this.control.textEditorManager.onServiceDerive(w);return}w.isEnableCursor=this.control.cursor.isEnableCursor,this.taskBatchData.add(w)}this.runAnimation();const d=r.newValue&&((f=r.newValue)==null?void 0:f.toolsType),g=r.newValue&&((m=r.newValue.opt)==null?void 0:m.zIndex);if(d&&d===Z.BackgroundSVG){if(this.zIndexNodeMethod&&ve.isNumber(g)){const w=this.zIndexNodeMethod.getMinZIndexForBackgroundSVG(o);this.zIndexNodeMethod.getMaxZIndexForBackgroundSVG(o)<g&&this.zIndexNodeMethod.setMaxZIndexForBackgroundSVG(g,o),w>g&&this.zIndexNodeMethod.setMinZIndexForBackgroundSVG(g,o)}}else if(this.zIndexNodeMethod&&ve.isNumber(g)){const w=this.zIndexNodeMethod.getMinZIndex(o);this.zIndexNodeMethod.getMaxZIndex(o)<g&&this.zIndexNodeMethod.setMaxZIndex(g,o),w>g&&this.zIndexNodeMethod.setMinZIndex(g,o)}}pullServiceData(e,r,n={isAsync:!1,useAnimation:!1}){var c,l,u,h,d,g,p;if(!this.isViewInitAck(e))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 M=Object.keys(s);for(const I of M){if((l=this.collector)!=null&&l.isSelector(I)){const C=(u=this.collector)==null?void 0:u.getUidFromKey(I);if(C&&!this.control.roomMember.isOnLine(C))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 C=s[I];if(C.workId=(d=this.collector)!=null&&d.isOwn(I)?(g=this.collector)==null?void 0:g.getLocalId(I):I,C.msgType=D,C.dataType=Ee.Service,C.viewId=e,C.scenePath=r,C.useAnimation=this.smoothSync&&(C.ops?!!a:(p=C.updateNodeOpt)==null?void 0:p.useAnimation)||!1,C.selectIds&&(C.selectIds=C.selectIds.map(B=>{var T,f;return(T=this.collector)!=null&&T.isOwn(B)?(f=this.collector)==null?void 0:f.getLocalId(B):B})),C.toolsType===Z.Text){this.control.shouldHoldServiceTextRenderForFontFace()?this.control.markInitFontFaceTextRenderSkipped():this.control.textEditorManager.onServiceDerive(C);continue}if(C.toolsType===Z.BackgroundSVG){if(!this.control.isUseBackgroundThread)continue;C.isRunBackgroundThread=!0}o&&C.updateNodeOpt&&C.updateNodeOpt.useAnimation&&(C.updateNodeOpt.useAnimation=!1),C.isEnableCursor=this.control.cursor.isEnableCursor,this.taskBatchData.add(C)}this.internalMsgEmitter.emit("excludeIds",M,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&&_0e.has(c)&&c!==Z.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&&hs(c)&&l||void 0}),o.length=0}}if(this.taskBatchData.size){const r=new Set(this.taskBatchData),n=new Set;for(const s of r)(!s.viewId||s.viewId===ru||this.isViewInitAck(s.viewId))&&n.add(s);this.post(n),this.taskBatchData.clear()}this.taskBatchData.size&&(this.animationId=requestAnimationFrame(this.consume.bind(this)))}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(o=>{this.cameraUpdateStateByView.get(e)===n&&(n.preparePromise=void 0,this.Logger.warn(`[Appliance]: [transaction-barrier] event=failed ts=${Date.now()} reason=camera-update viewId=${e} error=${o instanceof Error?o.message:String(o)}`),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({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===Z.Text)continue;o.state=ge.Done,o.isFullWork=!0,this.localPointsBatchData.set(s,o),u&&(r.add(u),hs(l)&&l!==Z.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),hs(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!==Pe&&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)===Z.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(p0(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)!==Z.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===Z.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 Z.Eraser:case Z.PencilEraser:case Z.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))===Pe&&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 M;((M=this.collector)==null?void 0:M.getLocalId(p))===Pe&&delete g[p]}),Object.keys(g).length){const p=this.viewContainerManager.mainView;if(!p)return;const M=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:M,h:I,cameraOpt:s&&{...s,width:M,height:I}||p.cameraOpt,isRunSubWork:!0,isRunBackgroundThread:this.control.isUseBackgroundThread,viewId:d};return this.taskBatchData.add(D),this.runAnimation(),new Promise(C=>{this.snapshotMap.set(e,{resolve:C,value:this.control.isUseBackgroundThread?[void 0,void 0]:[void 0]})}).then(C=>(this.snapshotMap.delete(e),C.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:mn.Iconify};this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayer(e),l.zIndex=this.zIndexNodeMethod.getMaxZIndex(e)),this.taskBatchData.add({msgType:he.FullWork,dataType:Ee.Local,toolsType:Z.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:Ms.url};this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayerForBackgroundSVG(e),a.zIndex=this.zIndexNodeMethod.getMaxZIndexForBackgroundSVG(e)),this.taskBatchData.add({msgType:he.FullWork,dataType:Ee.Local,toolsType:Z.BackgroundSVG,workId:r.uuid,opt:a,viewId:e,willRefresh:!0,willSyncService:!0,needUndoTicker:o,isRunBackgroundThread:!0}),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&&!Vye(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:Ms.markmap};return this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayerForBackgroundSVG(e),l.zIndex=this.zIndexNodeMethod.getMaxZIndexForBackgroundSVG(e)),this.taskBatchData.add({msgType:he.FullWork,dataType:Ee.Local,toolsType:Z.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:Ms.markmap};this.taskBatchData.add({msgType:he.UpdateNode,dataType:Ee.Local,toolsType:Z.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:mn.Image};this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayer(e),l.zIndex=this.zIndexNodeMethod.getMaxZIndex(e)),this.taskBatchData.add({msgType:he.FullWork,dataType:Ee.Local,toolsType:Z.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===Z.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:mn.Image};this.taskBatchData.add({msgType:he.FullWork,dataType:Ee.Local,toolsType:Z.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===Z.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:Pe,selectIds:[e],msgType:he.Select,dataType:Ee.Local,viewId:r,willSyncService:!0}),this.runAnimation()}blurSelector(e,r,n){this.taskBatchData.add({workId:n||Pe,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){L(this,"internalMsgEmitter");L(this,"control");L(this,"roomHotkeyCheckers");L(this,"tmpCopyStore",new Map);L(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)===Z.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:[Pe],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:De.pencil,useNewPencil:!0});break;case"changeToArrow":this.setMemberState({currentApplianceName:De.arrow});break;case"changeToClick":this.setMemberState({currentApplianceName:De.clicker});break;case"changeToEllipse":this.setMemberState({currentApplianceName:De.ellipse});break;case"changeToEraser":this.setMemberState({currentApplianceName:De.eraser});break;case"changeToHand":this.setMemberState({currentApplianceName:De.hand});break;case"changeToLaserPointer":this.setMemberState({currentApplianceName:De.laserPointer});break;case"changeToSelector":this.setMemberState({currentApplianceName:De.selector});break;case"changeToRectangle":this.setMemberState({currentApplianceName:De.rectangle});break;case"changeToStraight":this.setMemberState({currentApplianceName:De.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:De.text});break;case"changeToPencilEraser":this.setMemberState({currentApplianceName:De.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(Pe),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 $g=50;function sve(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 ove{constructor(t,e){L(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=sve(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+=$g){const l=e.items.slice(a,a+$g).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 ave={worker:!1,offscreenCanvas:!1,workerUrl:!1,offscreenTransfer:!1,imageBitmap:!1,webgl2:!1,webgl:!1},cve=new Set(["__proto__","constructor","prototype"]),dl=64;function Rh(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 an(i,t){const e=i.match(t);return e?Rh(e[1]):void 0}function lve(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 uve(i=typeof navigator>"u"?"":navigator.userAgent){if(an(i,/\bArkWeb\/(\d+(?:\.\d+)*)/i)){const a=an(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=an(i,/\bChrome\/(\d+(?:\.\d+)*)/i);return c?{kind:"androidWebView",version:c}:void 0}const e=an(i,/\b(?:iPhone|iPad|iPod).*?\bOS\s+(\d+(?:[_.]\d+)*)/i);if(e)return{kind:"iosWebView",version:e};const r=an(i,/\bEdg(?:A)?\/(\d+(?:\.\d+)*)/i);if(r)return{kind:"web",browser:"edge",version:r};const n=an(i,/\bChrome\/(\d+(?:\.\d+)*)/i);if(n)return{kind:"web",browser:"chrome",version:n};const s=an(i,/\bFirefox\/(\d+(?:\.\d+)*)/i);if(s)return{kind:"web",browser:"firefox",version:s};const o=an(i,/\bVersion\/(\d+(?:\.\d+)*).*\bSafari\//i);return o?{kind:"web",browser:"safari",version:o}:void 0}function Oh(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 b0(i,t){if(!Number.isInteger(i))return!1;switch(t){case"renderMode":return i===mr.OffscreenTransfer||i===mr.ImageBitmap;case"canvasContext":return i===wa.WebGL;case"maskTextureFormat":return i===mu.SingleChannelTexture;case"maskTextureUpload":return i===yu.TextureSubImage2D;case"imageBitmapFeature":return i===vu.DirtyRect}}function hve(i,t,e,r=[]){if(!Oh(t))return;const n=Object.entries(t);n.length>dl&&r.push(`worker blacklist exceeds ${dl} rules`);let s;for(const[o,a]of n.slice(0,dl)){if(cve.has(o))continue;const c=Rh(o);if(!c||!b0(a,e)){r.push(`invalid ${e} blacklist rule: ${o}`);continue}lve(i,c)<=0&&(s=s===void 0?a:Math.max(s,a))}return s}function dve(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 ds(i,t,e){const r=[];if(!Oh(i))return{issues:r};if(!t)return r.push(`${e} blacklist runtime version unavailable`),{issues:r};const n=dve(i,t);return n?{level:hve(t.version,n,e,r),runtime:t,issues:r}:{runtime:t,issues:r}}function jn(i,t,e){const r={};for(const n of[i,t])if(Oh(n))for(const[s,o]of Object.entries(n)){const a=Rh(s);!a||!b0(o,e)||(r[a]=Math.max(r[a]??0,o))}return Object.keys(r).length>0?r:void 0}function fs(i,t,e){var s,o,a,c,l,u,h,d;const r={chrome:jn((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:jn((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:jn((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:jn((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:jn(i==null?void 0:i.androidWebView,t==null?void 0:t.androidWebView,e),iosWebView:jn(i==null?void 0:i.iosWebView,t==null?void 0:t.iosWebView,e),harmonyArkWeb:jn(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 Vg(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 fve(){if(typeof OffscreenCanvas!="function")return!1;try{return!!new OffscreenCanvas(1,1).getContext("2d")}catch{return!1}}function gve(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&&fve()&&typeof createImageBitmap=="function"&&typeof ImageBitmap=="function"&&e,webgl2:Vg("webgl2"),webgl:Vg("webgl")}}function pve(i,t,e,r){return i==="main-thread"||t==="2d"||e===wa.WebGL?"2d":t==="webgl"?r.webgl?"webgl":"2d":r.webgl2?"webgl2":r.webgl?"webgl":"2d"}function mve(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??ave,issues:[]};const e=i.capabilities??gve(i.workerUrl),r=C=>({renderMode:"main-thread",contextType:"2d",reason:C,capabilities:e,issues:[]});if(!e.worker||!e.offscreenCanvas||!e.workerUrl)return r("worker-capability-missing");const n=uve(t),s=[],o=ds(i.workerRenderModeBlacklist,n,"renderMode"),a=ds(i.workerCanvasContextBlacklist,n,"canvasContext"),c=ds(i.workerMaskTextureFormatBlacklist,n,"maskTextureFormat"),l=ds(i.workerMaskTextureUploadBlacklist,n,"maskTextureUpload"),u=ds(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,M=u.level,I=(C,B)=>({renderMode:C,contextType:pve(C,i.requestedContextType,d||void 0,e),reason:B,capabilities:e,runtime:n,effectiveRenderModeLevel:h,effectiveContextLevel:d,effectiveMaskTextureFormatLevel:g,effectiveMaskTextureUploadLevel:p,effectiveImageBitmapFeatureLevel:M,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 C=h===mr.OffscreenTransfer?"render-mode-blacklist":i.useSimple?"worker-capability-missing":"use-simple-false";return I("worker-image-bitmap",C)}return I("main-thread","image-bitmap-unavailable")}class yve{constructor(t){L(this,"control");L(this,"roomMemberManager");L(this,"worker");L(this,"publicMsgEmitter");L(this,"renderUids",new Map);L(this,"pageAuth",new Map);L(this,"isLocalRender",!1);L(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 M=g.get(p)||new Set;M.add(s),g.set(p,M),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 M=g.get(p);M&&(M.delete(s),g.set(p,M),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 M=(h=this.control.collector)==null?void 0:h.uid,I=g==="localSelf"?M: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,M]of Object.entries(l))d.set(p,new Set(Object.keys(M)));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 vve{constructor(t){L(this,"internalMsgEmitter");L(this,"control");L(this,"maps",new Map);L(this,"showId");L(this,"color");L(this,"timer");L(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(),M=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*M}px`,c.style.height=`${h.height*M}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=Dh(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))}}class Mve{constructor(){L(this,"control");L(this,"_listeners",{})}_inject(t){this.control=t}_onEvent(t,e){this._listeners[t]&&this._listeners[t](...e)}callbacks(t,e){this._listeners[t]=e}removeCallback(t){delete this._listeners[t]}}class wve{constructor(t){L(this,"control");L(this,"worker");L(this,"publicMsgEmitter");L(this,"plugins",new Map);const{control:e,publicMsgEmitter:r}=t;this.control=e,this.publicMsgEmitter=r,this.worker=e.worker}use(t){this.plugins.set(t.kind,t),t._inject(this.control),t.onCreate()}destroy(){this.plugins.forEach(t=>{this.plugins.delete(t.kind),t.onDestroy()})}dispatchPluginEvent(t,...e){this.plugins.forEach(r=>{r._onEvent(t,e)})}}const fl=200;function Tve(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 Sve(i){return Tve(i)&&(i.touches&&i.touches.length===1||i.changedTouches&&i.changedTouches.length===1)}function Ive(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 Cve(i){const t=i.touches&&i.touches[0]||i.changedTouches&&i.changedTouches[0]||i;return{x:t.clientX,y:t.clientY}}class zh{constructor(t){L(this,"_logger");L(this,"pendingArgsByChannel",new Map);L(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,fl)}infoDebounced(t,...e){this.debounce("info",t,e,fl)}warnDebounced(t,...e){this.debounce("warn",t,e,fl)}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]",xve=["bold","normal"],bve=["italic","normal"],Eve=["top","left","right","bottom","topLeft","topRight","bottomLeft","bottomRight","leftTop","leftBottom","rightTop","rightBottom"];class Ave{constructor(t){L(this,"control");L(this,"logger");L(this,"lastSelectedIdsByView",new Map);L(this,"lastViewRectByView",new Map);L(this,"updateResolveMap",new Map);L(this,"clearResolveMap",new Map);L(this,"copyResolveMap",new Map);L(this,"deleteResolveMap",new Map);L(this,"lastRemoteSelectorByView",new Map);L(this,"cameraEmitThrottleByView",new Map);L(this,"pendingCameraChangeByView",new Map);L(this,"pendingPropertyGeometryByKey",new Map);L(this,"publicStorageHandler");L(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 cs(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=cs(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=>Ei(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 Ei(t,e)}async blurSelector(t){var c,l,u,h,d,g,p,M,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};(M=(p=this.logger)==null?void 0:p.info)==null||M.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 B,T,f;const C=setTimeout(()=>{var m,w;this.clearResolveMap.has(e)&&(this.clearResolveMap.delete(e),(w=(m=this.logger)==null?void 0:m.warn)==null||w.call(m,`${Ye} blurSelector timeout requestId=${e} viewId=${r}`),D({ok:!1,requestId:e,reason:"busy"}))},5e3);this.clearResolveMap.set(e,{timer:C,resolve:D,viewId:r});try{(B=this.control.worker)==null||B.blurSelector(r,a||"",Pe)}catch(m){this.clearResolveMap.delete(e),clearTimeout(C),(f=(T=this.logger)==null?void 0:T.error)==null||f.call(T,`${Ye} blurSelector failed requestId=${e} viewId=${r} err=${m==null?void 0:m.message}`),D({ok:!1,requestId:e,reason:"busy"})}})}async updateSelectedElements(t,e){var D,C,B,T,f,m,w,v,b,x,z,E,O,V;const r=this.genRequestId("update"),n=this.resolveViewId(t),s=e||{};if(!n)return(C=(D=this.logger)==null?void 0:D.warn)==null||C.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(T=(B=this.logger)==null?void 0:B.warn)==null||T.call(B,`${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(m=(f=this.logger)==null?void 0:f.warn)==null||m.call(f,`${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(v=(w=this.logger)==null?void 0:w.warn)==null||v.call(w,`${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 P=this.validateStrokeTypeForChanges(N,g,A,u);P.strokeType!==g.strokeType&&(g=P)}if(g.strokeType!==void 0){const N=a.map(P=>this.lookupToolsType(n,o==null?void 0:o.scenePath,P)).filter(P=>!!P&&Ei(P,"strokeType"));N.length>0?g.strokeType===ze.Stroke&&(N.every(U=>U===Z.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),(x=(b=this.logger)==null?void 0:b.warn)==null||x.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 M=cs(g);for(const N of a){const A=this.lookupToolsType(n,o==null?void 0:o.scenePath,N),P=this.hasShapeChanges(g)&&!!g.toolsType&&A!==g.toolsType;this.hasApplicableChangesForToolsType(g,A)?d.push(N):h.includes(N)||(h.push(N),A&&M.length&&u.push({id:N,field:M.join(","),code:"unsupported-by-toolsType",toolsType:A,message:P?`selected element id=${N} toolsType=${A} skipped by requested toolsType=${g.toolsType}`:`selected element id=${N} toolsType=${A} does not support requested fields=[${M.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,Q;const A=setTimeout(()=>{var ce,k;const K=this.updateResolveMap.get(r);K&&(this.updateResolveMap.delete(r),(k=(ce=this.logger)==null?void 0:ce.warn)==null||k.call(ce,`${Ye} updateSelectedElements timeout requestId=${r} viewId=${n}`),N({requestId:r,viewId:n,ok:!1,reason:"worker-failed",selectedIds:K.selectedIds,skippedIds:K.skippedIds.length?K.skippedIds:void 0,warnings:K.warnings.length?K.warnings:void 0,geometryChanged:K.geometryChanged}))},8e3);this.updateResolveMap.set(r,{timer:A,resolve:N,viewId:n,selectedIds:a,appliedIds:d,skippedIds:h,warnings:u,geometryChanged:!1});const P=this.captureUndoTickerDuringDispatch(n);try{this.dispatchUpdate(n,[Pe],g,r,I)}catch(K){this.updateResolveMap.delete(r),clearTimeout(A),this.cancelUndoTicker(this.resolveCancelableUndoTickerId(P.getUndoTickerId(),n),n,o==null?void 0:o.scenePath),(Q=(U=this.logger)==null?void 0:U.error)==null||Q.call(U,`${Ye} updateSelectedElements dispatch failed requestId=${r} viewId=${n} err=${K==null?void 0:K.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{P.dispose()}})):(this.flushUpdateSelectedElementsWarnings(n,r,u),(E=(z=this.logger)==null?void 0:z.warn)==null||E.call(z,`${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(M=>{var C,B;const I=setTimeout(()=>{var T,f;this.copyResolveMap.has(e)&&(this.copyResolveMap.delete(e),(f=(T=this.logger)==null?void 0:T.warn)==null||f.call(T,`${Ye} copySelectedElements timeout requestId=${e} viewId=${r}`),M({ok:!1,requestId:e,reason:"busy"}))},5e3);this.copyResolveMap.set(e,{timer:I,resolve:M,viewId:r,sourceSelectedIds:s});const D=this.captureUndoTickerDuringDispatch(r);try{We.emitMethod(Fe.MainEngine,Se.CopyNode,{workIds:[Pe],viewId:r,requestId:e})}catch(T){this.copyResolveMap.delete(e),clearTimeout(I),this.cancelUndoTicker(this.resolveCancelableUndoTickerId(D.getUndoTickerId(),r),r,n==null?void 0:n.scenePath),(B=(C=this.logger)==null?void 0:C.error)==null||B.call(C,`${Ye} copySelectedElements failed requestId=${e} viewId=${r} err=${T==null?void 0:T.message}`),M({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(M=>{var C,B;const I=setTimeout(()=>{var T,f;this.deleteResolveMap.has(e)&&(this.deleteResolveMap.delete(e),(f=(T=this.logger)==null?void 0:T.warn)==null||f.call(T,`${Ye} deleteSelectedElements timeout requestId=${e} viewId=${r}`),M({ok:!1,requestId:e,reason:"busy"}))},5e3);this.deleteResolveMap.set(e,{timer:I,resolve:M,viewId:r,removedIds:s.slice()});const D=this.captureUndoTickerDuringDispatch(r);try{We.emitMethod(Fe.MainEngine,Se.DeleteNode,{workIds:[Pe],viewId:r,requestId:e})}catch(T){this.deleteResolveMap.delete(e),clearTimeout(I),this.cancelUndoTicker(this.resolveCancelableUndoTickerId(D.getUndoTickerId(),r),r,n==null?void 0:n.scenePath),(B=(C=this.logger)==null?void 0:C.error)==null||B.call(C,`${Ye} deleteSelectedElements failed requestId=${e} viewId=${r} err=${T==null?void 0:T.message}`),M({ok:!1,requestId:e,reason:"busy"})}finally{D.dispose()}}))}async updateElement(t,e,r,n,s=!0){var p,M,I,D,C,B,T,f,m,w,v,b,x;const o=this.control.collector,a=this.control.worker;if(!o||!a||!t||!e||!r||!n)return(M=(p=this.logger)==null?void 0:p.warn)==null||M.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(B=(C=this.logger)==null?void 0:C.warn)==null||B.call(C,`${Ye} updateElement ignored: selector-not-allowed viewId=${r} scenePath=${e}`),!1;let l=(m=(f=(T=o.storage)==null?void 0:T[r])==null?void 0:f[e])==null?void 0:m[c];if(!l)return(v=(w=this.logger)==null?void 0:w.warn)==null||v.call(w,`${Ye} updateElement ignored: not-found viewId=${r} scenePath=${e} elementId=${t}`),!1;const u=l.toolsType;if(!u||n.toolsType!==u)return(x=(b=this.logger)==null?void 0:b.warn)==null||x.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(z=>{br(()=>{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)),z(!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=[${cs(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}`),z(!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 M,I,D,C;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 B=this.getSelectedElements(e),T={viewId:e,scenePath:r,selectorId:Pe,reason:n!=null&&n.length?"select":"clear",viewRect:u,selectedIds:(B==null?void 0:B.selectedIds)??n??[],selectorInfo:o};this.lastSelectedIdsByView.set(e,a),this.control.publicMsgEmitter.emit("selectedElementsChange",T);const f=`${Ye} selectedElementsChange reason=${T.reason} viewId=${e} count=${T.selectedIds.length}`,m=this.getDebounceLogger();m!=null&&m.infoDebounced?m.infoDebounced(`selected-elements-change:${e}`,f):(I=(M=this.logger)==null?void 0:M.info)==null||I.call(M,f)}const g=this.lastViewRectByView.get(e),p=!this.isRectEqual(g,u);if(p||l){let B="selector-action",T=n!=null&&n.length?"select":"clear";d&&p?(B="camera-change",T="cameraTransform"):p&&!l&&(n!=null&&n.length)&&(T="selectorTransform"),this.lastViewRectByView.set(e,u);const f={viewId:e,scenePath:r,selectorId:Pe,source:B,action:T,viewRect:u};this.control.publicMsgEmitter.emit("selectorGeometryChange",f),this.logGeometry(e,T,(n==null?void 0:n.length)||0),B==="camera-change"&&this.clearPendingCameraChange(e)}if(!(n!=null&&n.length)&&l)for(const[B,T]of this.clearResolveMap.entries())T.viewId===e&&(this.clearResolveMap.delete(B),T.timer&&clearTimeout(T.timer),(C=(D=this.logger)==null?void 0:D.info)==null||C.call(D,`${Ye} blurSelector done requestId=${B} viewId=${e}`),T.resolve({ok:!0,requestId:B}))}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:Pe,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:Pe,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:Pe,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)!==Pe)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}${Pe}`,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 M=s,I=(M.selectIds||[]).slice().sort(),D=a.selectedIds,C=!this.isArrayEqual(I,D);!D.length&&I.length?c="select":C&&!I.length?c="clear":c=C?"select":"update",l=M.selectIds||[];const B=M.selectRect||M.rect||((p=M.updateNodeOpt)==null?void 0:p.rect);B&&ve.isNumber(B.x)&&ve.isNumber(B.y)&&ve.isNumber(B.w)&&ve.isNumber(B.h)&&(u={x:B.x,y:B.y,w:B.w,h:B.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:Pe,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:n0(e.strokeType)?(Ng(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?cs(t).some(r=>r.startsWith("shape.")&&t.toolsType&&e!==t.toolsType?!1:Ei(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 M,I;p in r&&(delete r[p],n.push(p),(I=(M=this.logger)==null?void 0:M.warn)==null||I.call(M,`${Ye} updateElement warn unsupported-by-toolsType toolsType=${e} field=${p}`))},o=p=>{var M,I;r.shape&&p in r.shape&&(delete r.shape[p],n.push(`shape.${p}`),(I=(M=this.logger)==null?void 0:M.warn)==null||I.call(M,`${Ye} updateElement warn unsupported-by-toolsType toolsType=${e} field=shape.${p}`)),r.shape&&!Object.keys(r.shape).length&&delete r.shape},a=p=>{var M,I;p in r&&(n.push(p),(I=(M=this.logger)==null?void 0:M.warn)==null||I.call(M,`${Ye} updateElement warn invalid-format toolsType=${e} field=${p} value=${JSON.stringify(r[p])}`),delete r[p])},c=p=>{var M,I;!r.shape||!(p in r.shape)||(n.push(`shape.${p}`),(I=(M=this.logger)==null?void 0:M.warn)==null||I.call(M,`${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&&!Ng(e,r.strokeType)&&s("strokeType"),"bold"in r&&!xve.includes(r.bold)&&a("bold"),"italic"in r&&!bve.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&&!Eve.includes(r.shape.placement)&&c("placement"));const l=new Set($pe(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 M,I,D;const s=this.control.collector,o=s&&s.isLocalId(r)?s.transformKey(r):r,a=(D=(I=(M=s==null?void 0:s.storage)==null?void 0:M[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===Z.Text&&l){const C=l,B={text:C.text,fontSize:C.fontSize,fontFamily:C.fontFamily,bold:C.bold,italic:C.italic,underline:C.underline,lineThrough:C.lineThrough,textAlign:C.textAlign,verticalAlign:C.verticalAlign,boxPoint:C.boxPoint,boxSize:C.boxSize};d.text=B}if(c===Z.Polygon){const C=l;d.shape={vertices:C.vertices}}else if(c===Z.Star){const C=l;d.shape={vertices:C.vertices,innerVerticeStep:C.innerVerticeStep,innerRatio:C.innerRatio}}else if(c===Z.SpeechBalloon){const C=l;d.shape={placement:C.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)}}const ir=class ir{constructor(t){L(this,"toolChangePending",!1);L(this,"toolChangePendingTimer");L(this,"pendingSceneChecks",new Set);L(this,"pendingSceneChanges",new Map);L(this,"pendingClears",new Map);L(this,"clearQueueByView",new Map);L(this,"viewOperationQueueByView",new Map);L(this,"lifecycleGeneration",0);L(this,"viewLifecycleGeneration",new Map);L(this,"version",nc);L(this,"plugin");L(this,"logger");L(this,"syncLogger");L(this,"room");L(this,"play");L(this,"collector");L(this,"hasSwitchToSelectorEffect");L(this,"snapshootStateMap");L(this,"_disableDeviceInputs");L(this,"_disableEraseImage");L(this,"_disableEraseText");L(this,"_disableCameraTransform");L(this,"initFontFaceTextRenderGate",!1);L(this,"initFontFaceTextRenderSkipped",!1);L(this,"effectResolve");L(this,"hotkeyManager");L(this,"pluginOptions");L(this,"renderMode");L(this,"renderingCompatibilityDecision");L(this,"roomMember");L(this,"cursor");L(this,"textEditorManager");L(this,"worker");L(this,"renderControl");L(this,"miniMapManager");L(this,"pluginManager");L(this,"onInitLoadingChange");L(this,"selectorApi");L(this,"_isPolyfill",{requestIdleCallback:!1,cancelIdleCallback:!1});L(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});L(this,"onRoomMembersChange",t=>{this.roomMember.setRoomMembers(Ne.toJS(t))});L(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===Z.Selector&&e!==Z.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}));L(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})}))});L(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 M,I;const{displayer:e,plugin:r,options:n,onInitLoadingChange:s}=t;this.plugin=r,this.onInitLoadingChange=s,this.room=Ne.isRoom(e)?e:void 0,this.play=Ne.isPlayer(e)?e:void 0;let o;this.room&&(o=(M=this.room)==null?void 0:M.logger,this._disableDeviceInputs=this.room.disableDeviceInputs,this._disableEraseImage=this.room.disableEraseImage,this._disableEraseText=!1);const a=!!(n.cdn.fullWorkerUrl&&n.cdn.subWorkerUrl),c=fs(He.workerRenderModeBlacklist,n.extras.workerRenderModeBlacklist,"renderMode"),l=fs(He.workerCanvasContextBlacklist,n.extras.workerCanvasContextBlacklist,"canvasContext"),u=fs(He.workerMaskTextureFormatBlacklist,n.extras.workerMaskTextureFormatBlacklist,"maskTextureFormat"),h=fs(He.workerMaskTextureUploadBlacklist,n.extras.workerMaskTextureUploadBlacklist,"maskTextureUpload"),d=fs(He.workerImageBitmapFeatureBlacklist,n.extras.workerImageBitmapFeatureBlacklist,"imageBitmapFeature");this.renderingCompatibilityDecision=mve({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.renderMode=this.renderingCompatibilityDecision.renderMode,this.roomMember=new Gye;const g={control:this,internalMsgEmitter:ir.InternalMsgEmitter,publicMsgEmitter:ir.PublicMsgEmitter};this.cursor=new Hye(g),this.textEditorManager=new Dpe(g),this.worker=new nve(g),this.hotkeyManager=new ive(g),this.renderControl=new yve(g),this.pluginManager=new wve(g),this.isUseSimple||(this.miniMapManager=new vve(g)),this.logger=new zh(o);const p=this.pluginOptions.extras.syncLogger.batchWindowMs??He.syncLogger.batchWindowMs;this.syncLogger=new ove(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!==Z.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 Ave(this)}destroy(){var t,e,r,n,s,o,a,c;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,M;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,[Xn],u);const d=(M=(p=this.viewContainerManager.getView(e))==null?void 0:p.displayer)==null?void 0:M.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,Xn),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)===Z.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,o;try{for(;this.pendingSceneChanges.get(t)===e;){const a=(r=this.viewContainerManager.getView(t))==null?void 0:r.focusScenePath,c=e.targetScenePath;if(!a||a===c||(await this.applySceneChange(t,a,e),((n=this.viewContainerManager.getView(t))==null?void 0:n.focusScenePath)===e.targetScenePath))break}}finally{const a=this.pendingSceneChanges.get(t)===e,c=a?e.deferredCamera:void 0;e.running=!1,e.isSceneBusy=!1,a&&this.pendingSceneChanges.delete(t),a&&((o=(s=this.viewContainerManager.getView(t))==null?void 0:s.displayer)==null||o.setActive(!0)),e.waiters.forEach(l=>l()),e.waiters.clear(),a&&c&&(!c.scenePath||c.scenePath===e.targetScenePath)?this.worker.updateCamera(t,c.cameraOpt):a&&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)===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===Pe||this.collector.isOwn(o)&&this.collector.getLocalId(o)===Pe){this.collector.updateValue(o,void 0,{viewId:t,scenePath:e,isSync:!0});continue}if(!this.collector.isOwn(o))continue;const l=await Ype(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 De.text:return t.textCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),Z.Text;case De.pencil:return t.useLaserPen?Z.LaserPen:Z.Pencil;case De.eraser:return Z.Eraser;case De.pencilEraser:return this.pluginOptions.extras.pencilEraser.useBitMap===!1?Z.PencilEraser:Z.BitMapEraser;case De.selector:return Z.Selector;case De.clicker:return Z.Clicker;case De.hand:return Z.Hand;case De.laserPointer:return Z.Hand;case De.arrow:return t.arrowCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),Z.Arrow;case De.straight:return t.straightCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),Z.Straight;case De.ellipse:return t.ellipseCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),Z.Ellipse;case De.rectangle:return t.rectangleCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),Z.Rectangle;case De.shape:if(t.shapeCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),t.shapeType===Gt.Pentagram||t.shapeType===Gt.Star)return Z.Star;if(t.shapeType===Gt.Polygon||t.shapeType===Gt.Triangle||t.shapeType===Gt.Rhombus)return Z.Polygon;if(t.shapeType===Gt.SpeechBalloon)return Z.SpeechBalloon;break}return Z.Hand}getToolsOpt(t,e){if(t===Z.Clicker)return{toolsType:t,toolsOpt:{}};const r={strokeColor:Wn(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 Z.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)&&Wn(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)&&Wn(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 Z.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 Z.PencilEraser:case Z.BitMapEraser:case Z.Eraser:r.thickness=Math.min(4,Math.max(1,Math.floor(e.pencilEraserSize||1)))-1,t===Z.BitMapEraser&&(r.removeOnDone=this.pluginOptions.extras.pencilEraser.removeOnDone!==!1);break;case Z.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 Z.Arrow:case Z.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 Z.Ellipse:case Z.Rectangle:case Z.Star:case Z.Polygon:case Z.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===Z.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===Z.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)&&Wn(e.fillColor[0],e.fillColor[1],e.fillColor[2],e==null?void 0:e.fillOpacity)||"transparent",t===Z.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!==Z.Text&&this.viewContainerManager.focuedViewId&&this.viewContainerManager.unActiveTextEditor(this.viewContainerManager.focuedViewId),t){case Z.Text:case Z.Pencil:case Z.LaserPen:case Z.Arrow:case Z.Straight:case Z.Rectangle:case Z.Ellipse:case Z.Star:case Z.Polygon:case Z.SpeechBalloon:case Z.Triangle:case Z.Rhombus:case Z.Eraser:case Z.PencilEraser:case Z.BitMapEraser:case Z.Selector:case Z.Clicker:this.room.disableDeviceInputs=!0,(n=this.worker)==null||n.abled(),t===Z.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:De.text})}switchToSelector(){var t;(t=this.room)==null||t.setMemberState({currentApplianceName:De.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=Wn(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)}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)}};L(ir,"InternalMsgEmitter",new Ml),L(ir,"PublicMsgEmitter",new Ml);let Xe=ir;var cu=(i=>(i.Undo="undo",i.Redo="redo",i))(cu||{});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}};L(Ke,"proxyToRaw",new WeakMap),L(Ke,"proxyCallbacks",new WeakMap),L(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 lu=Ke;const $r=class $r{constructor(t){L(this,"emitter",new Ml);L(this,"undoStack");L(this,"redoStack");L(this,"worker");L(this,"control");L(this,"room");L(this,"viewId");L(this,"enableGlobal");L(this,"isTicking");L(this,"_undoTickerId");L(this,"scenePath");L(this,"tickStartStorerCache");L(this,"excludeIds",new Set);L(this,"pendingState",new Map);L(this,"tickerEndWaiters",new Map);L(this,"undoLifecycleListeners",new Set);L(this,"lifecycleCache",new Map);L(this,"stackRevision",0);L(this,"tickStartCaches",new Map);L(this,"tickStartExcludeIds",new Map);L(this,"timingFix");L(this,"ackTimeout");L(this,"gracePeriodTimeout");L(this,"doingFallbackTimeout");L(this,"isGlobalStackTransaction",!1);L(this,"pendingGlobalServiceData");L(this,"pendingArrayChanges",[]);L(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 lu,c=[],l=[];this.undoStack=a.createProxy(c,u=>{this.control.renderControl.isWritable&&this.handleArrayChange(u,yt.syncUndoStack)},cu.Undo),this.redoStack=a.createProxy(l,u=>{this.control.renderControl.isWritable&&this.handleArrayChange(u,yt.syncRedoStack)},cu.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;ll(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=ll(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=ll(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=xpe(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){Spe(t,e)}armAckTimeout(t,e){e.finalizeRequested&&Cpe(e)&&(e.ackTimer=setTimeout(()=>{this.forceFlushPending(t)},this.ackTimeout))}tryEnd(t){const e=this.pendingState.get(t);if(!e||!Ipe(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(Pe);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,Tpe({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(Pe);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 Z.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 Z.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))===Pe||e.toolsType===Z.Selector)return;const r=Gpe(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(!bg(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(!bg(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,M,I,D,C,B,T,f,m,w,v,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 x of s.values()){const{dataType:z,data:E,key:O}=x,V=this.collector.getStorageData(this.viewId,n),N=V&&Object.keys(V)||[];switch(z){case er.Draw:if(r=e?this.isDrawEffectiveScene(x,N):this.isDeleteEffectiveScene(x,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))===Pe&&((h=this.collector)!=null&&h.isOwn(x.key))){const A=E.selectIds;if(A){const P=N.filter(Q=>{var K,ce;return((K=this.collector)==null?void 0:K.getLocalId(Q))===Pe&&!((ce=this.collector)!=null&&ce.isOwn(Q))}).map(Q=>{var K;return(K=this.collector)==null?void 0:K.storage[this.viewId][n][Q]});let U=!1;for(const Q of P)for(let K=0;K<A.length;K++)(d=Q==null?void 0:Q.selectIds)!=null&&d.includes(A[K])&&(delete A[K],U=!0);U&&(E.selectIds=A.filter(Q=>!!Q))}}a[x.key]=E,c=!0}else!e&&!Array.isArray(x.data)&&(delete a[x.key],c=!0);break;case er.Delete:if(r=e?this.isDeleteEffectiveScene(x,N):this.isDrawEffectiveScene(x,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(x.key))===Pe&&((M=this.collector)!=null&&M.isOwn(x.key))){const A=E.selectIds;if(A){const P=N.filter(Q=>{var K,ce;return((K=this.collector)==null?void 0:K.getLocalId(Q))===Pe&&!((ce=this.collector)!=null&&ce.isOwn(Q))}).map(Q=>{var K;return(K=this.collector)==null?void 0:K.storage[this.viewId][n][Q]});let U=!1;for(const Q of P)for(let K=0;K<A.length;K++)(I=Q==null?void 0:Q.selectIds)!=null&&I.includes(A[K])&&(delete A[K],U=!0);U&&(E.selectIds=A.filter(Q=>!!Q))}}a[x.key]=E,c=!0}}break;case er.Update:if(r=e?this.isNewEffectiveScene(x,N):this.isOldEffectiveScene(x,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),((C=this.collector)==null?void 0:C.getLocalId(x.key))===Pe&&((B=this.collector)!=null&&B.isOwn(x.key))){const P=A.selectIds;if(P){const U=N.filter(K=>{var ce,k;return((ce=this.collector)==null?void 0:ce.getLocalId(K))===Pe&&!((k=this.collector)!=null&&k.isOwn(K))}).map(K=>{var ce;return(ce=this.collector)==null?void 0:ce.storage[this.viewId][n][K]});let Q=!1;for(const K of U)for(let ce=0;ce<P.length;ce++)K!=null&&K.selectIds&&((T=K.selectIds)!=null&&T.includes(P[ce]))&&(delete P[ce],Q=!0);Q&&(A.selectIds=P.filter(K=>!!K))}}a[O]=A,c=!0}else if(!e&&Array.isArray(E)&&E.length===2){const A=E[0];if((f=A.updateNodeOpt)!=null&&f.useAnimation&&(A.updateNodeOpt.useAnimation=!1),((m=this.collector)==null?void 0:m.getLocalId(x.key))===Pe&&((w=this.collector)!=null&&w.isOwn(x.key))){const P=A.selectIds;if(P){const U=N.filter(K=>{var ce,k;return((ce=this.collector)==null?void 0:ce.getLocalId(K))===Pe&&!((k=this.collector)!=null&&k.isOwn(K))}).map(K=>{var ce;return(ce=this.collector)==null?void 0:ce.storage[this.viewId][n][K]});let Q=!1;for(const K of U)for(let ce=0;ce<P.length;ce++)K!=null&&K.selectIds&&K.selectIds.includes(P[ce])&&(delete P[ce],Q=!0);Q&&(A.selectIds=P.filter(K=>!!K))}}a[x.key]=A,c=!0}}break}}if(c){const x=this.collector.plugin,z=(v=x==null?void 0:x.getAttributesValue)==null?void 0:v.call(x,[Vr.namespace]),E=(b=x==null?void 0:x.getAttributesValue)==null?void 0:b.call(x,[Vr.namespace,this.viewId]);z?E?x==null||x.updateAttributes([Vr.namespace,this.viewId,n],a):x==null||x.updateAttributes([Vr.namespace,this.viewId],{[n]:a}):x==null||x.updateAttributes([Vr.namespace],{[this.viewId]:{[n]:a}})}}};L($r,"sdkCallBack"),L($r,"MaxStackLength",He.undoRedo.maxStackLength),L($r,"waitTime",100);let uu=$r;const Nve=(i,t)=>({...i,...t}),Yg=(i,...t)=>t.reduce((e,r)=>({images:Nve(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),Uo={[Z.Selector]:{applianceKey:De.selector,classSuffix:"selector",hostClassName:"cursor-selector"},[Z.Clicker]:{applianceKey:De.clicker,classSuffix:"clicker",hostClassName:"cursor-clicker"},[Z.Text]:{applianceKey:De.text,classSuffix:"text",hostClassName:"cursor-text"},[Z.Pencil]:{applianceKey:De.pencil,classSuffix:"pencil",hostClassName:"cursor-pencil"},[Z.LaserPen]:{applianceKey:De.laserPen,classSuffix:"laser-pen",hostClassName:"cursor-pencil"},[Z.Arrow]:{applianceKey:De.arrow,classSuffix:"arrow",hostClassName:"cursor-arrow"},[Z.Straight]:{applianceKey:De.straight,classSuffix:"straight",hostClassName:"cursor-straight"},[Z.Rectangle]:{applianceKey:De.rectangle,classSuffix:"rectangle",hostClassName:"cursor-rectangle"},[Z.Ellipse]:{applianceKey:De.ellipse,classSuffix:"ellipse",hostClassName:"cursor-ellipse"},[Z.Star]:{applianceKey:rr.star,classSuffix:"star",hostClassName:"cursor-shape"},[Z.Polygon]:{applianceKey:rr.polygon,classSuffix:"polygon",hostClassName:"cursor-shape"},[Z.SpeechBalloon]:{applianceKey:rr.speechBalloon,classSuffix:"speech-balloon",hostClassName:"cursor-shape"},[Z.Eraser]:{applianceKey:De.eraser,classSuffix:"eraser",hostClassName:"cursor-eraser"},[Z.PencilEraser]:{applianceKey:De.pencilEraser,classSuffix:"pencil-eraser",hostClassName:"cursor-eraser"},[Z.BitMapEraser]:{applianceKey:rr.bitMapEraser,classSuffix:"bitmap-eraser",hostClassName:"cursor-eraser"}},Dve={[Z.Selector]:De.selector,[Z.Clicker]:De.clicker,[Z.Text]:De.text,[Z.Pencil]:De.pencil,[Z.Arrow]:De.arrow,[Z.Straight]:De.straight,[Z.Rectangle]:De.rectangle,[Z.Ellipse]:De.ellipse,[Z.Eraser]:De.eraser,[Z.PencilEraser]:De.pencilEraser};function Pve(i,t){if(!(!i||t===void 0)&&i.currentApplianceName!==De.laserPointer)return t===Z.LaserPen?i.currentApplianceName===De.pencil&&i.useLaserPen?Uo[t]:void 0:t===Z.Star||t===Z.Polygon||t===Z.SpeechBalloon?i.currentApplianceName===De.shape?Uo[t]:void 0:t===Z.BitMapEraser?i.currentApplianceName===De.pencilEraser?Uo[t]:void 0:Dve[t]===i.currentApplianceName?Uo[t]:void 0}class E0{constructor(t){L(this,"options");this.options=Ih(t)}getAppearance(t){return this.options.appearance[t]||Ko[t]}getLocal(t){var s;const e=Ko[t],r=this.getAppearance(t),n=Yg(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=Ko[t],r=this.getAppearance(t);return Yg(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 Gg(i){const t=i.trim().toLowerCase();return t.startsWith("data:image/svg+xml")||/\.svg(?:[?#]|$)/i.test(t)}function jh(i){const t=i.highResolution;if(!(!t||t===i.standardResolution||Gg(i.standardResolution)||Gg(t)))return t}function kve(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=jh(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 Li{constructor(t){L(this,"internalMsgEmitter");L(this,"control");L(this,"mainView");L(this,"appViews",new Map);L(this,"undoTickerStart",(t,e,r)=>{const n=this.getView(e);n&&n.displayer&&n.focusScenePath&&n.displayer.commiter.undoTickerStart(t,n.focusScenePath,r)});L(this,"addExcludeIds",(t,e)=>{const r=this.getView(e);r&&r.displayer&&r.focusScenePath&&r.displayer.commiter.addExcludeIds(t)});L(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)});L(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)});L(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)});L(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)});L(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)});L(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"&&r&&!ve.isEqual(n,s)&&(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.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===Z.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,M,I,D,C;for(const B of t){const{rect:T,imageBitmap:f,isClear:m,isUnClose:w,drawCanvas:v,clearCanvas:b,viewId:x}=B,z=(e=this.getView(x))==null?void 0:e.displayer;if(z&&T){const{dpr:E,canvasBgRef:O,canvasFloatRef:V,canvasServiceFloatRef:N,canvasTopRef:A}=z,P=Math.floor(T.w*E),U=Math.floor(T.h*E),Q=T.x*E,K=T.y*E;if(m){switch(b){case tt.TopFloat:(n=(r=A==null?void 0:A.current)==null?void 0:r.getContext("2d"))==null||n.clearRect(Q,K,P,U);break;case tt.Float:(o=(s=V.current)==null?void 0:s.getContext("2d"))==null||o.clearRect(Q,K,P,U);break;case tt.ServiceFloat:(c=(a=N.current)==null?void 0:a.getContext("2d"))==null||c.clearRect(Q,K,P,U);break;case tt.Bg:(u=(l=O.current)==null?void 0:l.getContext("2d"))==null||u.clearRect(Q,K,P,U);break}continue}if(v&&f)switch(v){case tt.TopFloat:(d=(h=A==null?void 0:A.current)==null?void 0:h.getContext("2d"))==null||d.drawImage(f,0,0,P,U,Q,K,P,U);break;case tt.Float:{(p=(g=V.current)==null?void 0:g.getContext("2d"))==null||p.drawImage(f,0,0,P,U,Q,K,P,U);break}case tt.ServiceFloat:{(I=(M=N.current)==null?void 0:M.getContext("2d"))==null||I.drawImage(f,0,0,P,U,Q,K,P,U);break}case tt.Bg:{(C=(D=O.current)==null?void 0:D.getContext("2d"))==null||C.drawImage(f,0,0,P,U,Q,K,P,U);break}}if(w)continue;f==null||f.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)}}L(Li,"defaultCameraOpt",{centerX:0,centerY:0,scale:1}),L(Li,"defaultScreenCanvasOpt",{autoRender:!1,contextType:"2d"}),L(Li,"defaultLayerOpt",{offscreen:!0,handleEvent:!1,depth:!1});class A0{constructor(t,e,r){L(this,"control");L(this,"internalMsgEmitter");L(this,"commiter");L(this,"cachePoint");L(this,"cacheCursorPoint");L(this,"active",!0);L(this,"toolsKey");L(this,"activePointers",new Set);L(this,"currentDrawingPointerId");L(this,"pointerDrawingSession",0);L(this,"currentPointerDrawingSession");L(this,"isTouchDrawing",!1);L(this,"cursorMouseMove");L(this,"cursorMouseMoveDebounced");L(this,"cursorMouseMoveThrottled");L(this,"cursorMouseMoveFun");L(this,"cursorEventElement");L(this,"appliedCursorClassNames",[]);L(this,"_transferControlToOffscreenCanvas");L(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)});L(this,"keydown",t=>{t.stopPropagation(),t.stopImmediatePropagation(),this.control.hotkeyManager.colloctHotkey(t)});L(this,"windowBlur",()=>{this.currentDrawingPointerId!==void 0&&this.cancelPointerDrawing("window-blur")});L(this,"visibilitychange",()=>{document.visibilityState==="hidden"&&this.currentDrawingPointerId!==void 0&&this.cancelPointerDrawing("document-hidden")});L(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())}}});L(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)}}});L(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()}});L(this,"pointercancel",t=>{this.currentDrawingPointerId!==void 0&&t.pointerId!==this.currentDrawingPointerId||this.cancelPointerDrawing("pointer-cancel")});L(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))});L(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)});L(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)});L(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 uu(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)!==Z.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=Pve(n,t),o=[],a=e&&r;if(a&&s){o.push(s.hostClassName),o.push(`cursor-tool-${s.classSuffix}`);const h=new E0(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",kve(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=Cve(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===Z.Pencil&&t>this.maxDrawCount?(this.stopEventHandler().finally(()=>{this.worker.publicMsgEmitter.emit("forceStop",Mu.longPencil,this.viewId)}),!0):!1}}class Lve extends A0{constructor(e,r,n){super(r,n,e);L(this,"_viewId");this._viewId=e}get viewId(){return this._viewId}setViewId(e){this._viewId=e}}class N0 extends A0{constructor(t,e){super(t,e,Ue)}get viewId(){return Ue}updateSize(){this.setCanvassStyle()}destroy(){super.destroy(),this.control.cursor.destroy()}}const Rve="index-module__Container__nLsM3",Ove="index-module__BackgroundBox__zfthZ",zve="index-module__BackgroundSvgBox__Fv1ay",jve="index-module__BackgroundSnapshotContent__NFLAl",Bve="index-module__BackgroundSnapshotBox__NEM-C",Uve="index-module__CanvasBox__j2Xe-",Fve="index-module__FloatCanvas__d1YR7",Wve="index-module__TopFloatCanvas__7IaCw",$ve="index-module__CanvasBoxSub__hcMeK",Vve="index-module__SnapshotBox__--eeE",Yve="index-module__FloatBar__cm-EL",Gve="index-module__RotateBtn__HSSkf",Hve="index-module__ResizeBtn__yjvda",Qve="index-module__CursorBox__2UHvI",Zve="index-module__TextEditorContainer__Qm8KC",Kve="index-module__ResizeTowBox__HOllX",qve="index-module__FloatBarBtn__FJrOG",gt={Container:Rve,BackgroundBox:Ove,BackgroundSvgBox:zve,BackgroundSnapshotContent:jve,BackgroundSnapshotBox:Bve,CanvasBox:Uve,FloatCanvas:Fve,TopFloatCanvas:Wve,CanvasBoxSub:$ve,SnapshotBox:Vve,FloatBar:Yve,RotateBtn:Gve,ResizeBtn:Hve,CursorBox:Qve,TextEditorContainer:Zve,ResizeTowBox:Kve,FloatBarBtn:qve},Xve={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 Xve[i]}const Jve=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||[Pe],viewId:e.viewId})}},G.createElement("img",{alt:"icon",src:Et("delete")}))},_ve=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||[Pe],viewId:e})}},G.createElement("img",{alt:"icon",src:Et("duplicate")}))},Hg=i=>{const{icon:t,onPointerUpHandler:e}=i;return G.createElement("div",{className:"button normal-button",onPointerUp:e},G.createElement("img",{src:Et(t)}))},eMe=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(Hg,{icon:"to-top",onPointerUpHandler:h=>{h.stopPropagation(),We.emitMethod(Fe.MainEngine,Se.ZIndexNode,{workIds:[Pe],layer:Mn.Top,viewId:s==null?void 0:s.viewId})}}),G.createElement(Hg,{icon:"to-bottom",onPointerUpHandler:h=>{h.stopPropagation(),We.emitMethod(Fe.MainEngine,Se.ZIndexNode,{workIds:[Pe],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")}))},Xs=i=>{i.stopPropagation(),i.nativeEvent.stopImmediatePropagation()},tMe=()=>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"})),D0=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"}))},hc=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)}}))},dc=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(zi,{bounds:"parent",axis:"x",position:n,onDrag:c,onStart:l,onStop:u},G.createElement("div",{className:"circle",style:{backgroundColor:St(e,t)},onPointerUp:Xs}))))},rMe=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 M=Math.ceil(Math.max(g-8,0)/100*(e-t)+t);(r!==M||p===ge.Done)&&n(M,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,M=Math.ceil(Math.max(p-12,0)/100*(e-t)+t),I=Math.ceil((M-t)/(e-t)*100)+8;a({x:I,y:0}),n(M,ge.Done)}},G.createElement("div",{className:"range-color",style:{backgroundColor:s}}),G.createElement("div",{className:"range-opacity"},G.createElement(zi,{bounds:"parent",axis:"x",position:o,onDrag:u,onStart:h,onStop:d},G.createElement("div",{className:"circle",style:{backgroundColor:s},onPointerUp:Xs},G.createElement("div",{className:"range-opacity-data-icon"},r)))))},nMe=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)}}))},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.strokeColor){const[C,B]=ic(n.strokeColor);l(C),h(B)}},[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 C={};return C.top="inherit",C.bottom=50,C}else if(!r.current.offsetTop&&(o==null?void 0:o.height)-r.current.offsetTop-n.y<120){const C={};return C.top="inherit",C.bottom=50,C}}},[n,r,o==null?void 0:o.height]),g=G.useMemo(()=>G.createElement(dc,{key:"strokeColors",opacity:u,activeColor:c,setCurOpacity:(C,B,T)=>{h(C);const f=St(B,C);n!=null&&n.strokeColor&&a({strokeColor:f}),We.emitMethod(Fe.MainEngine,Se.SetColorNode,{workIds:[Pe],strokeColor:f,workState:T,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(rMe,{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:(C,B)=>{n!=null&&n.thickness&&a({thickness:C}),We.emitMethod(Fe.MainEngine,Se.SetColorNode,{workIds:[Pe],thickness:C,workState:B,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]),M=G.useMemo(()=>c&&n&&(n!=null&&n.strokeType)?G.createElement(nMe,{key:"strokeType",useStroke:n==null?void 0:n.useStroke,activeStrokeType:n.strokeType,setStrokeType:C=>{n.strokeType&&a({strokeType:C}),We.emitMethod(Fe.MainEngine,Se.SetColorNode,{workIds:[Pe],strokeType:C,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:C=>{C.stopPropagation(),C.nativeEvent.stopImmediatePropagation()}},M,p,G.createElement("div",{className:"font-colors-line"}),s.concat().map((C,B)=>{const T=qs(...C);return G.createElement(hc,{key:B,color:T,activeColor:c,onPointerUpHandler:f=>{f.stopPropagation(),l(T);const m=St(T,u);n!=null&&n.strokeColor&&(n.strokeColor=m,a({strokeColor:m})),We.emitMethod(Fe.MainEngine,Se.SetColorNode,{workIds:[Pe],workState:ge.Done,strokeColor:m,viewId:o==null?void 0:o.viewId})}})}),g):null,[t,d,M,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:C=>{C.stopPropagation(),C.nativeEvent.stopImmediatePropagation(),e(!t)}},D,I)},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.fillColor){const[I,D]=(n==null?void 0:n.fillColor)==="transparent"&&["transparent",1]||ic(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(dc,{key:"fillColors",opacity:u||0,activeColor:c,setCurOpacity:(I,D,C)=>{h(I);const B=St(D,I);n!=null&&n.fillColor&&(n.fillColor=B,a({fillColor:B})),We.emitMethod(Fe.MainEngine,Se.SetColorNode,{workIds:[Pe],fillColor:c&&St(D,I),workState:C,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(D0,{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:[Pe],workState:ge.Done,fillColor:D,viewId:o==null?void 0:o.viewId})}}),s.map((I,D)=>{const C=qs(...I);return G.createElement(hc,{key:D,color:C,activeColor:c,onPointerUpHandler:B=>{B.cancelable&&B.preventDefault(),B.stopPropagation(),l(C);const T=St(C,u);n!=null&&n.fillColor&&(n.fillColor=T,a({fillColor:T})),We.emitMethod(Fe.MainEngine,Se.SetColorNode,{workIds:[Pe],workState:ge.Done,fillColor:T,viewId:o==null?void 0:o.viewId})}})}),g):null,[t,d,c,s,g,n,o==null?void 0:o.viewId,a,u]),M=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)}},M,p)},oMe=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[C,B]=(r==null?void 0:r.fontColor)==="transparent"&&["transparent",0]||ic(r.fontColor);h(C),g(B)}},[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 C={};return C.top="inherit",C.bottom=50,C}else if(!s.current.offsetTop&&(a==null?void 0:a.height)-s.current.offsetTop-l.y<120){const C={};return C.top="inherit",C.bottom=50,C}}},[s,l,a==null?void 0:a.height]),M=G.useMemo(()=>u&&u!=="transparent"?G.createElement(dc,{key:"fontColors",opacity:d,activeColor:u,setCurOpacity:(C,B,T)=>{g(C);const f=St(B,C);l!=null&&l.textOpt&&(l.textOpt.fontColor=f,c({textOpt:l.textOpt})),We.emitMethod(Fe.MainEngine,Se.SetColorNode,{workIds:n||[Pe],fontColor:u&&f,workState:T,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:C=>{C.stopPropagation(),C.nativeEvent.stopImmediatePropagation()}},o.map((C,B)=>{const T=qs(...C);return G.createElement(hc,{key:B,color:T,activeColor:u,onPointerUpHandler:f=>{f.stopPropagation(),h(T);const m=St(T,d);l!=null&&l.textOpt&&(l.textOpt.fontColor=m,c({textOpt:l.textOpt})),We.emitMethod(Fe.MainEngine,Se.SetColorNode,{workIds:n||[Pe],workState:ge.Done,fontColor:m,viewId:a==null?void 0:a.viewId})}})}),M):null,[c,t,o,M,u,d,l==null?void 0:l.textOpt,n,a==null?void 0:a.viewId,p]),D=G.useMemo(()=>{const C=u&&u!=="transparent"&&St(u,d)||"transparent";return G.createElement("div",{className:"color-bar"},G.createElement("div",{className:"color-bar-color",style:{backgroundColor:C}}))},[u,d]);return G.createElement("div",{className:`button normal-button font-colors-icon ${t&&"active"}`,onPointerUp:C=>{C.stopPropagation(),C.nativeEvent.stopImmediatePropagation(),e(!t)}},G.createElement("img",{alt:"icon",src:Et("font-colors")}),D,I)},aMe=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[C,B]=(r==null?void 0:r.fontBgColor)==="transparent"&&["transparent",1]||ic(r.fontBgColor);h(C),g(B)}},[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 C={};return C.top="inherit",C.bottom=50,C}else if(!s.current.offsetTop&&(a==null?void 0:a.height)-s.current.offsetTop-l.y<120){const C={};return C.top="inherit",C.bottom=50,C}}},[s,l,a==null?void 0:a.height]),M=G.useMemo(()=>u&&u!=="transparent"?G.createElement(dc,{key:"fontBgColor",opacity:d||0,activeColor:u,setCurOpacity:(C,B,T)=>{g(C);const f=St(B,C);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=f,c({textOpt:l.textOpt})),We.emitMethod(Fe.MainEngine,Se.SetColorNode,{workIds:n||[Pe],fontBgColor:u&&St(B,C),workState:T,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:C=>{C.stopPropagation(),C.nativeEvent.stopImmediatePropagation()}},G.createElement(D0,{activeColor:u,onPointerUpHandler:C=>{C.stopPropagation();const B="transparent";h(B),l!=null&&l.textOpt&&(l.textOpt.fontBgColor=B,c({textOpt:l.textOpt})),We.emitMethod(Fe.MainEngine,Se.SetColorNode,{workIds:n||[Pe],workState:ge.Done,fontBgColor:B,viewId:a==null?void 0:a.viewId})}}),o.map((C,B)=>{const T=qs(...C);return G.createElement(hc,{key:B,color:T,activeColor:u,onPointerUpHandler:f=>{f.stopPropagation(),h(T);const m=St(T,d);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=m,c({textOpt:l.textOpt})),We.emitMethod(Fe.MainEngine,Se.SetColorNode,{workIds:n||[Pe],workState:ge.Done,fontBgColor:St(T,d),viewId:a==null?void 0:a.viewId})}})}),M):null,[c,t,o,M,d,u,l==null?void 0:l.textOpt,n,a==null?void 0:a.viewId,p]),D=G.useMemo(()=>{const C=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:C}}))},[u,d]);return G.createElement("div",{className:`button normal-button font-colors-icon ${t&&"active"}`,onPointerUp:C=>{C.stopPropagation(),C.nativeEvent.stopImmediatePropagation(),e(!t)}},G.createElement(tMe,null),D,I)},cMe=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")}))},lMe=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")}))},uMe=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")}))},hMe=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),[M,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 B={};return B.top="inherit",B.bottom=50,B}else if(!o.current.offsetTop&&(a==null?void 0:a.height)-o.current.offsetTop-c.y<120){const B={};return B.top="inherit",B.bottom=50,B}}},[s,o==null?void 0:o.current,c,a]),C=G.useMemo(()=>t?G.createElement("div",{className:"font-style-menu",style:D,onPointerUp:B=>{B.stopPropagation(),B.nativeEvent.stopImmediatePropagation()}},G.createElement(cMe,{workIds:n||[Pe],bold:l,setBold:u,viewId:a==null?void 0:a.viewId}),G.createElement(lMe,{workIds:n||[Pe],underline:g,setUnderline:p,viewId:a==null?void 0:a.viewId}),G.createElement(uMe,{workIds:n||[Pe],lineThrough:M,setLineThrough:I,viewId:a==null?void 0:a.viewId}),G.createElement(hMe,{workIds:n||[Pe],italic:h,setItalic:d,viewId:a==null?void 0:a.viewId})):null,[t,n,l,a==null?void 0:a.viewId,g,M,h,D]);return G.createElement("div",{className:`button normal-button ${t&&"active"}`,onPointerUp:B=>{B.stopPropagation(),B.nativeEvent.stopImmediatePropagation(),e(!t)}},G.createElement("img",{alt:"icon",src:Et(t?"font-style-active":"font-style")}),C)},fMe=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)))},gMe=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||[Pe],fontSize:D,viewId:a==null?void 0:a.viewId})}const p=D=>{var C;(C=t.current)==null||C.blur(),r(!1),I(D)},M=G.useMemo(()=>e?G.createElement(fMe,{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 C=window.getSelection(),B=C==null?void 0:C.getRangeAt(0);if(B!=null&&B.collapsed)return D.cancelable&&D.preventDefault(),document.execCommand("delete",!1),!1}return!1},onKeyUp:D=>{var C;if(D.stopPropagation(),D.nativeEvent.stopImmediatePropagation(),t.current){const B=t.current.value,T=parseInt(B);isNaN(T)?t.current.value="0":t.current.value=T.toString(),T&&D.key==="Enter"&&(I(T),(C=t.current)==null||C.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])}})),M)},pMe=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||[Pe],isLocked:!r,viewId:e==null?void 0:e.viewId})}},G.createElement("img",{alt:"icon",src:Et(r?"unlock-new":"lock-new")}))},hu=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)}})))},mMe=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(yMe,{min:e,max:r,step:n,value:s,onInputHandler:o}))},yMe=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(zi,{bounds:"parent",axis:"x",position:s,onDrag:a,onStart:c,onStop:l},G.createElement("div",{className:"circle",onPointerUp:Xs}))))},vMe=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>=Mi.length&&(g=0),g<0&&(g=Mi.length-1),o(g),r(Mi[g]),c(!1),l.current&&(l.current.value=Mi[g])},[r]),h=G.useMemo(()=>{if(n&&n.bottom){const g={};return g.top="inherit",g.bottom=50,g}},[n]);G.useEffect(()=>{e&&(o(Mi.indexOf(e)),l.current&&(l.current.value=e))},[e]);const d=G.useMemo(()=>a?G.createElement(MMe,{options:Mi,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)},MMe=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)))},wMe=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:[Pe],toolsType:Z.Star,viewId:n.viewId,vertices:l})},a=l=>{s({innerVerticeStep:l}),We.emitMethod(Fe.MainEngine,Se.SetShapeOpt,{workIds:[Pe],toolsType:Z.Star,viewId:n.viewId,innerVerticeStep:l})},c=l=>{s({innerRatio:l}),We.emitMethod(Fe.MainEngine,Se.SetShapeOpt,{workIds:[Pe],toolsType:Z.Star,viewId:n.viewId,innerRatio:l})};return G.createElement(G.Fragment,null,G.createElement(hu,{value:r,icon:"polygon-vertex",min:3,max:100,step:1,onInputHandler:o}),G.createElement(hu,{value:e,icon:"star-innerVertex",min:1,max:100,step:1,onInputHandler:a}),G.createElement(mMe,{value:t,icon:"star-innerRatio",min:.1,max:1,step:.1,onInputHandler:c}))},TMe=i=>{const{mananger:t,vertices:e,setShapeOpt:r}=i,n=s=>{r({vertices:s}),We.emitMethod(Fe.MainEngine,Se.SetShapeOpt,{workIds:[Pe],toolsType:Z.Polygon,viewId:t.viewId,vertices:s})};return G.createElement(hu,{value:e,icon:"polygon-vertex",min:3,max:100,step:1,onInputHandler:n})},SMe=i=>{const{mananger:t,placement:e,setShapeOpt:r}=i,n=s=>{r({placement:s}),We.emitMethod(Fe.MainEngine,Se.SetShapeOpt,{workIds:[Pe],toolsType:Z.SpeechBalloon,viewId:t.viewId,placement:s})};return G.createElement(vMe,{value:e,icon:"speechBallon-placement",onChangeHandler:n})},gl=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)}))},IMe=i=>{const{toolsTypes:t,style:e,mananger:r,shapeOpt:n,setShapeOpt:s}=i,[o,a]=G.useState();G.useEffect(()=>{t.includes(Z.Polygon)?a(Z.Polygon):t.includes(Z.Star)?a(Z.Star):a(Z.SpeechBalloon)},[t]);const c=d=>{a(d)},l=G.useMemo(()=>o===Z.Polygon&&r&&n.vertices?G.createElement(TMe,{vertices:n.vertices,mananger:r,setShapeOpt:s}):null,[r,o,n,s]),u=G.useMemo(()=>o===Z.Star&&r&&n.vertices&&n.innerVerticeStep&&n.innerRatio?G.createElement(wMe,{mananger:r,vertices:n.vertices,innerVerticeStep:n.innerVerticeStep,innerRatio:n.innerRatio,setShapeOpt:s}):null,[r,o,n,s]),h=G.useMemo(()=>o===Z.SpeechBalloon&&r&&n.placement?G.createElement(SMe,{mananger:r,placement:n.placement,setShapeOpt:s}):null,[o,r,n.placement,s]);return G.createElement("div",{className:"shapeOpt-sub-menu",style:e,onPointerUp:Xs},G.createElement("div",{className:"shapeOpt-sub-menu-tabs"},t.includes(Z.Polygon)&&G.createElement(gl,{isActive:o===Z.Polygon,icon:o===Z.Polygon?"polygon-active":"polygon",onPointerUpHandler:c.bind(void 0,Z.Polygon)})||null,t.includes(Z.Star)&&G.createElement(gl,{isActive:o===Z.Star,icon:o===Z.Star?"star-active":"star",onPointerUpHandler:c.bind(void 0,Z.Star)})||null,t.includes(Z.SpeechBalloon)&&G.createElement(gl,{isActive:o===Z.SpeechBalloon,icon:o===Z.SpeechBalloon?"speechBallon-active":"speechBallon",onPointerUpHandler:c.bind(void 0,Z.SpeechBalloon)})||null),G.createElement("div",{className:"shapeOpt-sub-menu-content"},l,u,h))},CMe=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(IMe,{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")}))},P0=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 x,z,E,O;const w={},v=(a==null?void 0:a.w)||((x=t==null?void 0:t.boxSize)==null?void 0:x[0])||0,b=(a==null?void 0:a.h)||((z=t==null?void 0:t.boxSize)==null?void 0:z[1])||0;if(n&&v&&b&&(c!=null&&c.width)&&(c!=null&&c.height)){if(n.y<60?n.y+b<c.height-60?w.bottom=-120:n.y+b<c.height?w.bottom=-58:n.y>0?w.top=62:w.top=-n.y+62:w.top=0,n.x<0)w.left=-n.x+3;else if(n.x+(((E=g.current)==null?void 0:E.offsetWidth)||v)>c.width){const V=c.width-(((O=g.current)==null?void 0:O.offsetWidth)||v)-n.x;w.left=V}d(w);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(sMe,{floatBarRef:g,open:l===3,setOpen:w=>{u(w===!0?3:0)}}):null,[a==null?void 0:a.fillColor,l,g]),M=G.useMemo(()=>a!=null&&a.strokeColor?G.createElement(iMe,{floatBarRef:g,open:l===2,setOpen:w=>{u(w===!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(oMe,{floatBarRef:g,open:l===4,setOpen:w=>{u(w===!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(aMe,{floatBarRef:g,open:l===5,setOpen:w=>{u(w===!0?5:0)},textOpt:t,workIds:e}):null,[t,l,e,c,g]),C=G.useMemo(()=>t&&(c!=null&&c.viewId)?G.createElement(dMe,{floatBarRef:g,open:l===6,setOpen:w=>{u(w===!0?6:0)},textOpt:t,workIds:e,style:h}):null,[t,l,e,c,h,g]),B=G.useMemo(()=>t&&(c!=null&&c.viewId)?G.createElement(gMe,{open:l===7,setOpen:w=>{u(w===!0?7:0)},textOpt:t,workIds:e,floatBarRef:g}):null,[t,l,e,c,g]),T=G.useMemo(()=>r?null:G.createElement(eMe,{open:l===1,setOpen:w=>{u(w===!0?1:0)},floatBarRef:g}),[r,l,g]),f=G.useMemo(()=>a!=null&&a.canLock&&c?G.createElement(pMe,{workIds:e,mananger:c,islocked:a.isLocked}):null,[a,c,e]),m=G.useMemo(()=>c&&(c!=null&&c.viewId)&&h&&(a!=null&&a.shapeOpt)&&(a!=null&&a.toolsTypes)?G.createElement(CMe,{open:l===8,setOpen:w=>{u(w===!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(Jve,{workIds:e,mananger:c}),T,f,!!(c!=null&&c.viewId)&&!o&&G.createElement(_ve,{workIds:e,viewId:c.viewId}),m,C,B,I,D,M,p)}),xMe=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:M,underline:I,fontColor:D,lineThrough:C,textAlign:B,strokeColor:T,lineHeight:f,bold:m,italic:w}=n,v=f||p*1.2,b={fontSize:`${p}px`,lineHeight:`${v}px`,color:"transparent",caretColor:D,borderColor:T,minHeight:`${v}px`,pointerEvents:"none",paddingRight:`${w==="italic"?Math.round(p*.3):5}px`};return M&&(b.fontFamily=`${M}`),(C||I)&&(b.textDecoration=`${C&&"line-through"||""}${I&&" underline"||""}`),B&&(b.textAlign=`${B}`),m&&(b.fontWeight=`${m}`),w&&(b.fontStyle=`${w}`),b},[n]),d=G.useMemo(()=>{const p=[];if(n.text){const M=li(n.text);for(let I=0;I<M.length;I++){const D=M[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,M=l.current.offsetHeight;if(!p||!M)return;const I=n.boxSize;if((I==null?void 0:I[0])!==p||I[1]!==M||!I){r({activeTextId:e,update:{boxSize:[p,M],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))},bMe=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(xMe,{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)},EMe=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(P0,{position:t,textOpt:e,workIds:r,noLayer:n,noCopy:s,noDelete:o}))},AMe=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:M,y:I}=t,{fontSize:D,fontFamily:C,underline:B,fontColor:T,lineThrough:f,textAlign:m,lineHeight:w,bold:v,italic:b}=d,x=G.useRef(null),z=G.useMemo(()=>{const y=D,S=w||y*1.2,F={fontSize:`${y}px`,lineHeight:`${S}px`,caretColor:T,color:"transparent",minHeight:`${S}px`,paddingRight:`${b==="italic"?Math.round(y*.3):5}px`,borderWidth:0};return C&&(F.fontFamily=`${C}`),(f||B)&&(F.textDecoration=`${f&&"line-through"||""} ${B&&" underline"||""}`),m&&(F.textAlign=`${m}`),v&&(F.fontWeight=`${v}`),b&&(F.fontStyle=`${b}`),F},[v,T,C,D,b,w,f,g,m,B]),E=G.useRef(!1),O=G.useRef(6),V=G.useRef(),N=G.useRef(),A=G.useRef(!1),P=G.useRef(!1),U=G.useRef({fontSize:z.fontSize,lineHeight:z.lineHeight,fontStyle:z.fontStyle,fontWeight:z.fontWeight,fontFamily:z.fontFamily}),Q=G.useMemo(()=>typeof window>"u"?!1:navigator.maxTouchPoints>0||"ontouchstart"in window,[]),K=G.useMemo(()=>u===e?"hover":d.workState===ge.Doing||d.workState===ge.Start?"editing":l?"active":"none",[u,e,d.workState,l]);function ce(y){if(!x.current)return;const F=y&&Sve(y.nativeEvent)?Ive(y.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=x.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),P.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),P.current=!0),de)return}}if(s0e(J,ne,re)){P.current=!0;return}}a0e({hasPoint:!!re,previousByPoint:P.current,hasSelectionInEditor:jg(J,ne),rangeCount:J.rangeCount,isCollapsed:J.isCollapsed})||(r0e(J,ne),P.current=!1)}};Y(),_(F),Q&&(V.current=requestAnimationFrame(()=>{_(),N.current=window.setTimeout(()=>{_(),N.current=void 0},32),V.current=void 0}))}const k=G.useMemo(()=>{const y=`scale(${g||1}) ${p&&"translate("+p[0]+"px,"+p[1]+"px)"||""}`;return{left:`${M-bi*(g||1)}px`,top:`${I-bi*(g||1)}px`,zIndex:2,transform:y,transformOrigin:"left top",borderColor:K==="editing"||K==="hover"?T:"transparent"}},[g,p,M,I,T,K]),W=G.useMemo(()=>{let y="";const S="<div></div>";if(d.text){const F=li(d.text);for(let Y=0;Y<F.length;Y++){const _=F[Y];if(_==="")y=y+S;else{const re=_.replace(/[<>&]/g,ne=>({"<":"<",">":">","&":"&"})[ne]);y=y+`<div>${re}</div>`}}}else y=S;return y},[d.fontBgColor,d.text]),H=G.useMemo(()=>{var y,S;if(K==="hover"){if(g&&r&&ve.isNumber(M)&&ve.isNumber(I)&&d.boxSize&&ve.isNumber((y=d.boxSize)==null?void 0:y[0])&&ve.isNumber((S=d.boxSize)==null?void 0:S[1])){const F={x:M,y:I},Y={left:M,top:I,width:d.boxSize[0]*g,height:d.boxSize[1]*g};return G.createElement(EMe,{position:F,style:Y,textOpt:d,workIds:[e],noLayer:!0,noCopy:!0,noDelete:!0})}return null}return null},[d,r,e,M,I,g,K]);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),P.current=!1)},[u,e]),G.useEffect(()=>{if(u===e&&x.current){const y=window==null?void 0:window.getSelection(),S=jg(y,x.current);(document.activeElement!==x.current||!S)&&ce(),s(x.current)}},[u,s,e,Q]),G.useEffect(()=>{const y=x.current;if(!y)return;const S=T0(y),F=d.text||"";S!==F&&(u===e&&E.current||(y.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(x.current){const y=parseInt(getComputedStyle(x.current).paddingRight,10)+parseInt(getComputedStyle(x.current).borderWidth,10);O.current=Number(y)}},[]),G.useEffect(()=>{if(x.current){const y={fontSize:z.fontSize,lineHeight:z.lineHeight,fontStyle:z.fontStyle,fontWeight:z.fontWeight,fontFamily:z.fontFamily};if(!ve.isEqual(U.current,y)){U.current=y;const S=[x.current.offsetWidth,x.current.offsetHeight];a(e,S)}}},[z,e,a,K,l,u]);const $=G.useCallback(y=>{const S=h==null?void 0:h.parentElement,F=x.current;if(!S||!F||!c)return!1;const{lastLine:Y}=Bg(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+y>re.right){const{textContent:ne,textNodes:J}=o0e(Y);if(!J.length)return!1;const se=ne.length,ue=ls(J,0);if(!ue)return!1;let oe=0,de=0,me=se;for(;de<me;){const ye=Math.floor((de+me)/2),xe=ls(J,ye);if(!xe)break;const Ce=document.createRange();Ce.setStart(ue.node,ue.offset),Ce.setEnd(xe.node,xe.offset);const Ie=Ce.getBoundingClientRect(),ke=re.right-Ie.right;if(ke<y){if(ye>0){const Re=ls(J,ye-1);if(!Re)break;const Le=document.createRange();Le.setStart(ue.node,ue.offset),Le.setEnd(Re.node,Re.offset);const Oe=Le.getBoundingClientRect();if(re.right-Oe.right>=y){oe=ye-1;break}}me=ye}else{const Re=ye+1;if(Re<se){const Le=ls(J,Re);if(!Le)break;const Oe=document.createRange();Oe.setStart(ue.node,ue.offset),Oe.setEnd(Le.node,Le.offset);const je=Oe.getBoundingClientRect();if(re.right-je.right<=y&&ke>y){oe=ye;break}}de=Re}}if(!oe){const ye=ls(J,de);if(!ye)return!1;const xe=document.createRange();xe.setStart(ue.node,ue.offset),xe.setEnd(ye.node,ye.offset);const Ce=xe.getBoundingClientRect();re.right-Ce.right>y?oe=de:de>0&&(oe=de-1)}if(oe>0){const ye=ne.slice(0,oe),xe=ne.slice(oe);Y.textContent=ye;const Ce=document.createElement("div");return xe&&(Ce.textContent=xe),x.current.appendChild(Ce),$(y),!0}}return!1},[h==null?void 0:h.parentElement,d.fontBgColor,c]);function ee(y){if(y.stopPropagation(),y.nativeEvent.stopImmediatePropagation(),y.key==="Backspace"){const S=window.getSelection(),F=S==null?void 0:S.getRangeAt(0);if(F!=null&&F.collapsed)return y.cancelable&&y.preventDefault(),document.execCommand("delete",!1),!1}return!1}function ie(y,S){const F=window==null?void 0:window.getSelection();if(F!=null&&F.rangeCount&&y&&F&&F.anchorNode){const Y=F.anchorOffset,_=F.anchorNode.textContent||"",re=_.slice(0,Y)||"",ne=_.slice(Y)||"",J=re.concat(y)||"";le(J,ne,S)}}function le(y,S,F){const Y=window==null?void 0:window.getSelection();if(!(Y!=null&&Y.rangeCount)||!Y.anchorNode)return;const _=y.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(y){if(y.cancelable&&y.preventDefault(),y.stopPropagation(),y.nativeEvent.stopImmediatePropagation(),x.current){const S=(y.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=vl(S,{whiteList:{},stripIgnoreTag:!0,stripIgnoreTagBody:["script"]});ie(Y,x.current),$((g||1)*O.current),n(x.current)}o()}return!1}function we(y){Bg(y)}const R=G.useCallback(()=>{const y=x.current;o(()=>{if(y){we(y);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(),_=x.current.lastChild;Y.selectNodeContents(_),Y.collapse(!1),F.removeAllRanges(),F.addRange(Y)}n(y)}})},[n,$,o,g]);function j(){E.current=!0,o()}function X(){E.current=!1,R()}function ae(){R(),o()}const q=G.useCallback(()=>{if(K==="active"&&x.current&&x.current.parentElement){const y=x.current.parentElement;y.style.borderColor=T}},[K,T]),te=G.useCallback(()=>{if(K==="active"&&x.current&&x.current.parentElement){const y=x.current.parentElement;y.style.borderColor="transparent"}},[K]);return G.createElement(G.Fragment,null,H,G.createElement("div",{className:`editor-box ${K}`,style:k,onPointerUp:()=>{var y;if(K==="editing"){o(()=>{var S;(S=document.activeElement)==null||S.blur(),h==null||h.control.textEditorManager.checkEmptyTextBlur()});return}if(K==="active"&&h){if((y=h.control.collector)!=null&&y.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:x,style:z,onKeyDown:ee,onPaste:pe,onTouchEnd:ce,onInput:R,onCompositionStart:j,onCompositionUpdate:ae,onCompositionEnd:X,dangerouslySetInnerHTML:{__html:W}})))},NMe=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=M=>{if(!e)return;const I=M.id,D=e.control.textEditorManager.get(I),C=ge.Doing,B=[M.offsetWidth,M.offsetHeight];(!D||D&&(!ve.isEqual(D.opt.boxSize,B)||!ve.isEqual(D.opt.workState,C)))&&o({activeTextId:I,update:{boxSize:B,workState:C},syncData:{canSync:!0,canWorker:!0}})},l=M=>{var m,w;if(!e)return;const I=w0(M),D=M.id,C=e.control.textEditorManager.get(D),B=T0(M),T=ge.Doing,f=[M.offsetWidth,M.offsetHeight];if(!C||C&&(C.opt.text!==B||!ve.isEqual(C.opt.boxSize,f)||!ve.isEqual(C.opt.workState,T))){const v=D&&ve.cloneDeep(((m=e.control.textEditorManager)==null?void 0:m.get(D))||((w=i.editors)==null?void 0:w.get(D)));v&&v.opt&&(v.opt={...v.opt,text:B,boxSize:f,workState:T},v.canSync=!0,v.canWorker=!0,e.control.textEditorManager.updateForViewEdited(D,v)),e.control.textEditorManager.publicMsgEmitter.emit("textChange",D,M,I,v)}},u=(M,I)=>{if(!e)return;const D=M,C=e.control.textEditorManager.get(D);if(C&&!(!I[0]||!I[1])&&!ve.isEqual(C.opt.boxSize,I)){const B=ve.cloneDeep(C);B.opt={...B.opt,boxSize:I},B.canSync=!1,B.canWorker=!1,e.control.textEditorManager.updateForViewEdited(D,B)}},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=M=>{r.current&&cancelAnimationFrame(r.current),r.current=requestAnimationFrame(()=>{t!=null&&t.current&&(h(),M&&M(),d(),r.current=void 0)})};if((p=i.editors)!=null&&p.size){const M=[];return i.editors.forEach((I,D)=>{M.push(G.createElement(AMe,{key:D,workId:D,data:I,showFloatBtns:i.showFloatBtns||!1,handleFocus:c,handleKeyUp:l,updateSize:u,runAnimation:g,rightBoundBreak:i.rightBoundBreak||!1}))}),M}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]}),DMe=()=>{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)}))},PMe=()=>{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)},kMe=()=>{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)}))},LMe=()=>{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}))},RMe=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),[M,I]=G.useState(new Ae),[D,C]=G.useState(!1),B=G.useRef(0),T=G.useRef(!1),f=G.useRef(null),m=(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:[Pe],angle:O===ge.Start?0:E,workState:O,viewId:o==null?void 0:o.viewId})},w=E=>{if(!E){T.current=!0,B.current&&clearTimeout(B.current),B.current=0,C(!0),d(!1),s(Se.None),c(ge.Pending);return}C(!1)},v=(E,O)=>{B.current&&(clearTimeout(B.current),B.current=0),c(ge.Done),d(!1);const V=Math.round(Ae.GetAngleByPoints(g,M,new Ae(O.x,O.y)))||0;m(V,ge.Done)};G.useEffect(()=>{const E=()=>{T.current&&(B.current&&clearTimeout(B.current),B.current=0,c(ge.Pending),d(!1),s(Se.None))};return We.activeListener(w),document.addEventListener("pointercancel",E),()=>{We.unmountActiveListener(w),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){C(!0),c(ge.Pending);return}const V=Math.round(Ae.GetAngleByPoints(g,M,new Ae(E,O)))||0;m(V,ge.Start)},doing:(E,O)=>{if(T.current)return;if(o!=null&&o.control.worker.isBusy){C(!0);return}const V=Math.round(Ae.GetAngleByPoints(g,M,new Ae(E,O)))||0;u({x:E,y:O}),m(V,ge.Doing)},done:(E,O)=>{const V=Math.round(Ae.GetAngleByPoints(g,M,new Ae(E,O)))||0;u({x:E,y:O}),m(V,ge.Done)}},()=>{window.__selectorRotateE2E__&&delete window.__selectorRotateE2E__}},[M,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(T.current=!1,o!=null&&o.control.worker.isBusy){C(!0),c(ge.Pending);return}B.current&&(clearTimeout(B.current),B.current=0),c(ge.Start),d(!0);const V=Math.round(Ae.GetAngleByPoints(g,M,new Ae(O.x,O.y)))||0;m(V,ge.Start)},x=(E,O)=>{if(T.current){B.current&&clearTimeout(B.current),B.current=0,d(!1),s(Se.None);return}if(o!=null&&o.control.worker.isBusy){C(!0),v(E,O);return}v(E,O)},z=(E,O)=>{if(!T.current){if(o!=null&&o.control.worker.isBusy){C(!0),v(E,O);return}B.current||(u({x:O.x,y:O.y}),d(!0),B.current=setTimeout(()=>{if(B.current=0,T.current)return;const V=Math.round(Ae.GetAngleByPoints(g,M,new Ae(O.x,O.y)))||0;m(V,ge.Doing)},60))}};return G.createElement(zi,{disabled:D,position:l,onStart:b,onDrag:z,onStop:x},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:f,className:`appliance-plugin-rotate-mouse-pointer ${h?"active":""}`},G.createElement("img",{alt:"icon",src:Et("rotation")}),G.createElement("div",{className:"angle-icon"},r,"°"))))};function OMe(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 zMe(i,t){const e=i.control.worker.now;return i.control.textEditorManager.active(t,e),e}const jMe="data-text-work-id";function BMe(i){var t,e;if(i instanceof HTMLElement)return((e=(t=i.closest(`[${jMe}]`))==null?void 0:t.dataset)==null?void 0:e.textWorkId)||void 0}const UMe=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),M=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:M||o?"none":"auto",touchAction:"none"}:{display:"none",pointerEvents:"none"},[r,M,o]),D=m=>{if(!m||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)},C=(m,w)=>{h.current&&(clearTimeout(h.current),h.current=0);const v={x:w.x,y:w.y};n(Se.None),g.current=ge.Done,c(v),We.emitMethod(Fe.MainEngine,Se.TranslateNode,{workIds:[Pe],position:v,workState:ge.Done,viewId:s==null?void 0:s.viewId})};G.useEffect(()=>{const m=()=>{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",m),()=>{We.unmountActiveListener(D),document.removeEventListener("pointercancel",m)}},[]),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 B=m=>{p.current=!1;const w=m&&"target"in m?m.target:null,v=e?BMe(w):void 0;if(s!=null&&s.control.worker.isBusy){u(!0);return}h.current&&(clearTimeout(h.current),h.current=0),d.current=v,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:[Pe],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}))},T=(m,w)=>{var z,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 v=g.current,b=d.current;if(!!b&&v===ge.Start&&s&&e){OMe(s),zMe(s,b),d.current=void 0,g.current=ge.Pending,n(Se.None);const O=(z=s.control.viewContainerManager.getView(s.viewId))==null?void 0:z.focusScenePath;O&&s.control.worker.blurSelector(s.viewId,O);return}if(C(m,w),d.current&&(d.current=void 0),v===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()},f=(m,w)=>{if(p.current)return;if(s!=null&&s.control.worker.isBusy){u(!0),C(m,w);return}if(h.current)return;const v={x:w.x,y:w.y};c(v),h.current=setTimeout(()=>{h.current=0,!p.current&&(v.x!==(a==null?void 0:a.x)||v.y!==(a==null?void 0:a.y))&&(d.current&&(d.current=void 0),g.current=ge.Doing,We.emitMethod(Fe.MainEngine,Se.TranslateNode,{workIds:[Pe],position:v,workState:ge.Doing,viewId:s==null?void 0:s.viewId}))},60)};return G.createElement(zi,{disabled:l,position:a,onStart:B,onDrag:f,onStop:T},G.createElement("div",{style:I},G.createElement(FMe,{editors:t,selectIds:(r==null?void 0:r.selectIds)||[]})))},(i,t)=>!!ve.isEqual(i,t)),FMe=G.memo(i=>{const{editors:t,selectIds:e}=i;return t?G.createElement(bMe,{editors:t,selectIds:e||[]}):null},(i,t)=>!(!ve.isEqual(i.editors,t.editors)||!ve.isEqual(i.selectIds,t.selectIds))),WMe=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,M]=G.useState(),[I,D]=G.useState(!1),C=G.useRef(0),B=G.useRef(!1);G.useEffect(()=>{const E=()=>{B.current&&(C.current&&clearTimeout(C.current),C.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(f),document.addEventListener("pointercancel",E),()=>{We.unmountActiveListener(f),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 T=()=>{if(C.current&&(clearTimeout(C.current),C.current=0),p){const{scale:E,translate:O}=p;g(Se.None),We.emitMethod(Fe.MainEngine,Se.ScaleNode,{workIds:[Pe],scale:E,dir:c,translate:O,originPoint:n,scenePoint:o,workState:ge.Done,viewId:h==null?void 0:h.viewId})}h==null||h.focusElement()},f=E=>{if(!E){B.current=!0,C.current&&clearTimeout(C.current),C.current=0,D(!0);return}D(!1)},m=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]],w=(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]}},v=(E,O,V,N)=>{let A=!1,P=!1;const U={x:e.x,y:e.y,w:e.w,h:e.h},Q=[1,1],K=[0,0];switch(E){case"top":{const H=O.height+e.h;H<0?(P=!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?(P=!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?(P=!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?(P=!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?(P=!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?(P=!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}}Q[0]=U.w/e.w,Q[1]=U.h/e.h;const k=m(U).map(H=>V.control.viewContainerManager.transformToScenePoint(H,V.viewId)),W=w(k,E);return P&&(K[1]=W[1]-N[1]),A&&(K[0]=W[0]-N[0]),{scale:Q,translate:K}},b=(E,O)=>{if(B.current=!1,C.current&&(clearTimeout(C.current),C.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=m(V),A=N.map(Q=>h.control.viewContainerManager.transformToScenePoint(Q,h.viewId)),P=w(N,O),U=w(A,O);r(V),s(P),a(U),l(O),g(Se.ScaleNode),We.emitMethod(Fe.MainEngine,Se.ScaleNode,{workIds:[Pe],originPoint:P,scenePoint:U,workState:ge.Start,viewId:h.viewId})}},x=(E,O,V,N)=>{if(!B.current&&!(!h||!n||!o)){if(h!=null&&h.control.worker.isBusy){D(!0),T();return}C.current||(C.current=setTimeout(()=>{if(C.current=0,B.current)return;const{scale:A,translate:P}=v(O,N,h,o);(!ve.isEqual(A,p==null?void 0:p.scale)||!ve.isEqual(P,p==null?void 0:p.translate))&&(M({scale:A,translate:P}),g(Se.ScaleNode),We.emitMethod(Fe.MainEngine,Se.ScaleNode,{workIds:[Pe],scale:A,dir:O,translate:P,originPoint:n,scenePoint:o,workState:ge.Doing,viewId:h.viewId}))},60))}},z=()=>{if(B.current){C.current&&clearTimeout(C.current),C.current=0,g(Se.None);return}h!=null&&h.control.worker.isBusy&&D(!0),T()};return G.createElement($0.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:x,onResizeStop:z})},Qg=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),M=G.useRef(!1),I=G.useMemo(()=>a?{left:0,top:0}:{},[a]),D=m=>{if(!m||a!=null&&a.isLocked){M.current=!0,p.current&&clearTimeout(p.current),p.current=0,g(!0),h(ge.Pending),s(Se.None);return}g(!1)};G.useEffect(()=>{const m=()=>{M.current&&(p.current&&clearTimeout(p.current),p.current=0,h(ge.Pending),s(Se.None))};return We.activeListener(D),document.addEventListener("pointercancel",m),()=>{We.unmountActiveListener(D),document.removeEventListener("pointercancel",m)}},[]),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 C=(m,w)=>{p.current&&(clearTimeout(p.current),p.current=0),s(Se.None),h(ge.Done);const v={x:w.x,y:w.y};if(l(v),o!=null&&o.control.viewContainerManager){const b=o.control.viewContainerManager.transformToScenePoint([v.x,v.y],o.viewId),x=r.get(t);x&&n==="start"?x[0]=b:x&&n==="end"&&(x[1]=b),We.emitMethod(Fe.MainEngine,Se.SetPoint,{workId:Pe,pointMap:r,workState:ge.Done,viewId:o==null?void 0:o.viewId})}o==null||o.focusElement()},B=()=>{if(M.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:Pe,pointMap:r,workState:ge.Start,viewId:o==null?void 0:o.viewId}))},T=(m,w)=>{if(M.current)return;if(o!=null&&o.control.worker.isBusy){g(!0),C(m,w);return}if(p.current)return;const v={x:w.x,y:w.y};l(v),p.current=setTimeout(()=>{if(p.current=0,!M.current&&o!=null&&o.control.viewContainerManager){const b=o.control.viewContainerManager.transformToScenePoint([v.x,v.y],o.viewId),x=r.get(t);x&&n==="start"?x[0]=b:x&&n==="end"&&(x[1]=b),h(ge.Doing),We.emitMethod(Fe.MainEngine,Se.SetPoint,{workId:Pe,pointMap:r,workState:ge.Doing,viewId:o==null?void 0:o.viewId})}},60)},f=(m,w)=>{if(M.current){p.current&&clearTimeout(p.current),p.current=0,s(Se.None);return}o!=null&&o.control.worker.isBusy&&g(!0),C(m,w)};return G.createElement(zi,{disabled:d,position:c,onStart:B,onDrag:T,onStop:f},G.createElement("div",{className:"appliance-plugin-point-draggable-btn",style:I}))},$Me=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 M of e.points){const I=r.control.viewContainerManager.transformToOriginPoint(M,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(Qg,{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(Qg,{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)},VMe=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(DMe,null),[e,r]),s=G.useMemo(()=>(e==null?void 0:e.scaleType)!==Ve.both||r===Se.RotateNode?null:G.createElement(PMe,null),[e,r]),o=G.useMemo(()=>(e==null?void 0:e.scaleType)!==Ve.proportional||r===Se.RotateNode?null:G.createElement(kMe,null),[e,r]),a=G.useMemo(()=>(e==null?void 0:e.scaleType)===Ve.none&&(e!=null&&e.canLock)?G.createElement(LMe,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)}),YMe=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(P0,{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)),GMe=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(RMe,{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(WMe,{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($Me,{className:gt.ResizeTowBox}):null,[e==null?void 0:e.scaleType,r]);return G.createElement("div",{ref:c,className:gt.FloatBar,onPointerOver:d=>(Xs(d),n==null||n.control.worker.blurCursor(n.viewId),!1)},G.createElement(VMe,{ref:t}),G.createElement(UMe,{editors:s,canSelectorSwitch:a}),l,u,h,G.createElement(YMe,{isHide:o,operationType:r,floatBarData:e}))}),HMe=G.memo(GMe,(i,t)=>!!ve.isEqual(i,t)),QMe=i=>{var l,u;const{tool:t,visual:e,imageKey:r}=i,n=Ko[t],[s,o]=G.useState(e.images);G.useEffect(()=>o(e.images),[t,r,e.images]);const a=jh(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 ZMe extends G.Component{constructor(){super(...arguments);L(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)});L(this,"detectAvatar",e=>{var r;return!!((r=e.payload)!=null&&r.avatar)});L(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]})`});L(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"})});L(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,M,I,D,C;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:(M=o.size)==null?void 0:M.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:(C=e.payload)!=null&&C.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(QMe,{key:`${r}:${a}`,tool:r,visual:o,imageKey:a})))}}const KMe=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(ZMe,{roomMember:s,cursorTool:o,resolver:r,labelOptions:n}))},qMe=i=>{const{className:t,manager:e}=i,[r,n]=G.useState(),s=G.useMemo(()=>new E0(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(KMe,{key:c.roomMember.memberId,className:t,info:c,resolver:s,labelOptions:o}):null)):null,[t,r,o,s])},XMe=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(),M=Math.min(g/h.width,p/h.height),I=d.width/d.scale,D=d.height/d.scale,C=[d.centerX,d.centerY],B=[h.centerX,h.centerY],T=[C[0]-B[0],C[1]-B[1]],f=Math.min(h.scale*M,h.scale*M),m=[T[0]*f,T[1]*f,I,D,f];a(m)},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:M}=g.getBoundingClientRect(),[I,D]=[p/2,M/2],[C,B]=[(h.nativeEvent.offsetX-I)/o[4],(h.nativeEvent.offsetY-D)/o[4]],T=n.maps.get(t);if(T!=null&&T.viewCamera){const[f,m]=[T.miniMapCamera.centerX+C,T.miniMapCamera.centerY+B];(d=n.control.room)==null||d.moveCamera({centerX:f,centerY:m,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"}}))},JMe=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 Ma.createPortal(G.createElement(XMe,{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 Bh extends G.Component{constructor(e){var n,s;super(e);L(this,"showTextFloatBar");L(this,"canSelectorSwitch");L(this,"rightBoundBreak");L(this,"setAngle",e=>{this.setState({angle:e})});L(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(HMe,{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(NMe,{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(qMe,{className:gt.CursorBox,manager:this.props.mananger}),!this.props.mananger.control.isUseSimple&&G.createElement(JMe,{className:gt.MiniMapBox,active:this.state.activeMiniMapViewId,miniMapManager:this.props.mananger.control.miniMapManager}))}}class _Me extends N0{constructor(e,r){super(e,r);L(this,"width",1e3);L(this,"height",1e3);L(this,"dpr",Oi());L(this,"vDom");L(this,"eventTragetElement");L(this,"snapshotContainerRef");L(this,"backgroundSnapshotContainerRef");L(this,"canvasContainerRef",G.createRef());L(this,"subLocalCanvasContainerRef");L(this,"canvasTopRef");L(this,"canvasServiceFloatRef",G.createRef());L(this,"canvasFloatRef",G.createRef());L(this,"canvasBgRef",G.createRef());L(this,"backgroundContainerRef");L(this,"floatBarRef",G.createRef());L(this,"customFloatbarContainerRef",G.createRef());L(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=Oi();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(),Ma.render(G.createElement(Bh,{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 e1e extends Lve{constructor(e,r,n){super(e,r,n);L(this,"dpr",Oi());L(this,"width",1e3);L(this,"height",1e3);L(this,"vDom");L(this,"eventTragetElement");L(this,"canvasContainerRef",G.createRef());L(this,"subLocalCanvasContainerRef");L(this,"canvasTopRef");L(this,"canvasServiceFloatRef",G.createRef());L(this,"canvasFloatRef",G.createRef());L(this,"canvasBgRef",G.createRef());L(this,"backgroundContainerRef");L(this,"floatBarRef",G.createRef());L(this,"customFloatbarContainerRef",G.createRef());L(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=Oi();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(),Ma.render(G.createElement(Bh,{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 dn extends Li{constructor(e){super(e);L(this,"focuedViewId");L(this,"focuedView");L(this,"control");L(this,"tmpFocusedViewId");L(this,"checkScaleTimer");L(this,"mainViewHotkeyListener",e=>{this.onActiveHotkeyChange(e)});L(this,"appViewListeners",new Map);L(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()});L(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}});L(this,"onMainViewMounted",e=>{const r=e.divElement;if(!r||!e.focusScenePath||!(e.focusScenePath||e.scenePath))return;const s=new _Me(this.control,Xe.InternalMsgEmitter),o=e.size.width||s.width,a=e.size.height||s.height;s.dpr;const c={cameraOpt:{...dn.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)});L(this,"onMainViewSizeUpdated",async()=>{await new Promise(e=>{setTimeout(()=>{e(!0)},0)}),this.mainView&&this.mainView.viewData&&this.updateMainViewCamera()});L(this,"onMainViewCameraUpdated",async()=>{await new Promise(e=>{setTimeout(()=>{e(!0)},0)}),this.updateMainViewCamera()});L(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))}}});L(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 e1e(r,this.control,Xe.InternalMsgEmitter),c=n.size.width||a.width,l=n.size.height||a.height;a.dpr;const u={cameraOpt:{...dn.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)});L(this,"onAppViewSizeUpdated",async e=>{await new Promise(n=>{setTimeout(()=>{n(!0)},0)});const r=this.appViews.get(e);r&&r.viewData&&this.updateAppCamera(e)});L(this,"onAppViewCameraUpdated",async e=>{await new Promise(r=>{setTimeout(()=>{r(!0)},0)}),this.updateAppCamera(e)});L(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&&(dn.defaultScreenCanvasOpt.contextType=this.control.renderingCompatibilityDecision.contextType);const a={dpr:o,originalPoint:[n/2,s/2],offscreenCanvasOpt:{...dn.defaultScreenCanvasOpt,width:n,height:s},layerOpt:{...dn.defaultLayerOpt,width:n,height:s},cameraOpt:{...dn.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 cn extends Xe{constructor(e){super(e);L(this,"windowManager");L(this,"viewContainerManager");const r={control:this,internalMsgEmitter:Xe.InternalMsgEmitter,publicMsgEmitter:Xe.PublicMsgEmitter};this.viewContainerManager=new dn(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 M of Object.keys(g))M&&p.add(M);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)&&(g.opt.text&&g.opt.text.replace(/\s*,/g,"")?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 pl=new WeakMap;function Zg(i){return/^https?:\/\//i.test(i.trim())}function t1e(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;Zg(c.standardResolution)&&t.push({appliance:n,scope:a,density:"standard",key:c.key||"external",url:c.standardResolution});const l=jh(c);l&&Zg(l)&&t.push({appliance:n,scope:a,density:"high",key:c.key||"external",url:l})}}return t}function k0(i){pl.has(i)||(pl.set(i,new Map),window.setTimeout(()=>{try{const t=Ih(i),e=t1e(t);if(!e.length)return;const r=pl.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))}const Te=class Te extends Ne.InvisiblePlugin{constructor(){super(...arguments);L(this,"onPhaseChanged",e=>{var r;e===Ne.RoomPhase.Reconnecting&&((r=Te.currentManager)==null||r.setSnapshootData())});L(this,"updateRoomWritable",()=>{var e;(e=Te.currentManager)==null||e.onWritableChange(this.displayer.isWritable)});L(this,"roomStateChangeListener",async e=>{var r,n;e!=null&&e.roomMembers&&((r=Te.currentManager)==null||r.onRoomMembersChange(e.roomMembers)),!(Ne.isRoom(this.displayer)&&!this.displayer.isWritable)&&e.memberState&&((n=Te.currentManager)==null||n.onMemberChange(e.memberState))})}static async getInstance(e,r){var T,f,m,w;(v=>{var b;try{(b=r.onInitLoadingChange)==null||b.call(r,v)}catch(x){Te.logger.error(`[ApplianceMultiPlugin] onInitLoadingChange error: ${(x==null?void 0:x.message)||x}`)}})({loading:!0,phase:"plugin",status:"start"});const s=e.displayer,o=Ne.isRoom(s)&&s.logger||Te.logger,a=typeof navigator>"u"?"unknown":navigator.userAgent;o.info(`[Appliance]: [init-enter] version=${nc} userAgent=${a}`);const c=s.callbacks.on,l=s.callbacks.off,u=s.callbacks.once,h=e.cleanCurrentScene,d=e.mainView.setMemberState;let g;Ne.isRoom(s)&&(g=s.setWritable),r!=null&&r.logger&&(Te.logger=new zh(r.logger));let p=s.getInvisiblePlugin(Te.kind);p||(p=await Te.createApplianceMultiPlugin(s,Te.kind)),s&&p&&Te.createCurrentManager(e,{cdn:r.options.cdn,extras:jy(r.options.extras)},p,r.onInitLoadingChange),(T=Te.currentManager)==null||T.emitInitLoadingChange({loading:!0,phase:"plugin",status:"success"});const M={displayer:s,windowManager:e,currentManager:Te.currentManager,maxScreenshotWidth:10*1024,maxScreenshotHeight:10*1024,getBoundingRectAsync:async function(v){var z;Te.logger.info("[ApplianceMultiPlugin] getBoundingRectAsync");const b=(e.mainView||s).getBoundingRect(v),x=await((z=Te.currentManager)==null?void 0:z.getBoundingRect(v));return!b.width||!b.height?x:Dh(b,x)},screenshotToCanvasAsync:async function(v,b,x,z,E,O){var Q;Te.logger.info("[ApplianceMultiPlugin] screenshotToCanvasAsync");let V=x,N=z,A=E.scale;V>this.maxScreenshotWidth&&(A=this.maxScreenshotWidth/V*A,V=this.maxScreenshotWidth),N>this.maxScreenshotHeight&&(A=Math.min(this.maxScreenshotHeight/N*A,A),N=this.maxScreenshotHeight),E.scale=A;const P=document.createElement("canvas"),U=P.getContext("2d");P.width=V*(O||1),P.height=N*(O||1),U&&((e.mainView||s).screenshotToCanvas(U,b,V,N,E,O),v.drawImage(P,Math.floor((x-V)/2),Math.floor((z-N)/2),V*(O||1),N*(O||1),0,0,V,N),P.remove()),Te.currentManager&&await((Q=Te.currentManager)==null?void 0:Q.screenshotToCanvas(v,b,V,N,E,Math.floor((x-V)/2),Math.floor((z-N)/2)))},scenePreviewAsync:async function(v,b,x,z,E){Te.logger.info("[ApplianceMultiPlugin] scenePreviewAsync"),(e.mainView||s).scenePreview(v,b,x,z,E);const O=document.createElement("img");O.className="appliance-plugin-fill-scene-snapshot-img",b.append(O),getComputedStyle(b).position||(b.style.position="relative"),Te.currentManager&&await Te.currentManager.scenePreview(v,O)},fillSceneSnapshotAsync:async function(v,b,x,z,E){Te.logger.info("[ApplianceMultiPlugin] fillSceneSnapshotAsync"),b.innerHTML="",(e.mainView||s).fillSceneSnapshot(v,b,x,z,E);const O=x||e.mainView.size.width,V=z||e.mainView.size.height;let N=await this.getBoundingRectAsync(v);N||(N={originX:0,originY:0,width:O,height:V});let A=Math.max(N==null?void 0:N.width,O),P=Math.max(N==null?void 0:N.height,V),U=1;const Q=A>O&&Math.min(O/A,U)||U,K=P>V&&Math.min(V/P,U)||U;Q<=K?(A=Q<1&&O||A,P=Math.floor(P*Q)+1,U=Q):Q>K&&(P=K<1&&V||P,A=Math.floor(A*K)+1,U=K);const ce={scale:U,centerX:N.originX+N.width/2,centerY:N.originY+N.height/2},k=document.createElement("canvas"),W=k.getContext("2d");k.width=A,k.height=P,W&&await this.screenshotToCanvasAsync(W,v,A,P,ce,devicePixelRatio);const H=document.createElement("img");H.className="appliance-plugin-fill-scene-snapshot-img",H.src=k.toDataURL(),H.onload=()=>{k.remove()},H.onerror=()=>{k.remove(),H.remove()},b.append(H),getComputedStyle(b).position||(b.style.position="relative")},_callbacksOn:function(v,b){(v==="onCanUndoStepsUpdate"||v==="onCanRedoStepsUpdate")&&Ne.isRoom(s)&&s.isWritable?cn.InternalMsgEmitter.on(v,b):c.call(s.callbacks,v,b)},_callbacksOnce:function(v,b){(v==="onCanUndoStepsUpdate"||v==="onCanRedoStepsUpdate")&&Ne.isRoom(s)&&s.isWritable?cn.InternalMsgEmitter.on(v,b):u.call(s.callbacks,v,b)},_callbacksOff:function(v,b){(v==="onCanUndoStepsUpdate"||v==="onCanRedoStepsUpdate")&&Ne.isRoom(s)&&s.isWritable?cn.InternalMsgEmitter.off(v,b):l.call(s.callbacks,v,b)},canRedoSteps(){if(Te.logger.info("[ApplianceMultiPlugin] canRedoSteps"),Te.currentManager&&Ne.isRoom(s)&&!s.disableSerialization){const v=Te.currentManager.viewContainerManager.focuedView,b=v==null?void 0:v.focusScenePath;if(v&&b)return v.displayer.commiter.redoStack.filter(x=>x.scenePath===b).length}return 0},canUndoSteps(){if(Te.logger.info("[ApplianceMultiPlugin] canUndoSteps"),Te.currentManager&&Ne.isRoom(s)&&!s.disableSerialization){const v=Te.currentManager.viewContainerManager.focuedView,b=v==null?void 0:v.focusScenePath;if(v&&b)return v.displayer.commiter.undoStack.filter(E=>E.scenePath===b).length}return 0},undo:function(){return Te.logger.info("[ApplianceMultiPlugin] undo"),Te.currentManager&&Ne.isRoom(s)&&!s.disableSerialization&&s.isWritable?Te.currentManager.viewContainerManager.undo():0},redo:function(){return Te.logger.info("[ApplianceMultiPlugin] redo"),Te.currentManager&&Ne.isRoom(s)&&!s.disableSerialization&&s.isWritable?Te.currentManager.viewContainerManager.redo():0},cleanCurrentScene:function(){Te.logger.info("[ApplianceMultiPlugin] cleanCurrentScene"),Te.currentManager&&Ne.isRoom(s)&&s.isWritable&&(Te.currentManager.logger.info("[Appliance]: cleanCurrentScene"),Te.currentManager.cleanCurrentScene().then(()=>{h.call(e)}).catch(v=>{var b;(b=Te.currentManager)==null||b.logger.error(`[Appliance]: cleanCurrentScene failed: ${(v==null?void 0:v.message)||v}`)}))},insertImage:function(v){if(Te.logger.info("[ApplianceMultiPlugin] insertImage"),Te.currentManager&&Ne.isRoom(s)&&s.isWritable){const b=Te.currentManager.viewContainerManager.focuedViewId||Ue;Te.currentManager.worker.insertImage(b,v)}},lockImage:function(v,b){if(Te.logger.info("[ApplianceMultiPlugin] lockImage"),Te.currentManager&&Ne.isRoom(s)&&s.isWritable){const x=Te.currentManager.viewContainerManager.focuedViewId||Ue;Te.currentManager.worker.lockImage(x,v,b)}},completeImageUpload:function(v,b){if(Te.logger.info("[ApplianceMultiPlugin] completeImageUpload"),Te.currentManager&&Ne.isRoom(s)&&s.isWritable){const x=Te.currentManager.viewContainerManager.focuedViewId||Ue;Te.currentManager.worker.completeImageUpload(x,v,b)}},getImagesInformation:function(v){return Te.logger.info("[ApplianceMultiPlugin] completeImageUpload"),Te.currentManager&&Ne.isRoom(s)&&s.isWritable?Te.currentManager.worker.getImagesInformation(v):[]},insertText:function(v,b,x){if(Te.logger.info("[ApplianceMultiPlugin] insertText"),Te.currentManager&&Ne.isRoom(s)&&s.isWritable){const z=Te.currentManager.viewContainerManager.focuedViewId||Ue;return Te.currentManager.textEditorManager.insertText(z,v,b,x)}},updateText:function(v,b){Te.logger.info("[ApplianceMultiPlugin] updateText"),Te.currentManager&&Ne.isRoom(s)&&s.isWritable&&Te.currentManager.textEditorManager.updateText(v,b)},callbacks:()=>({...s.callbacks,on:M._callbacksOn.bind(M),once:M._callbacksOnce.bind(M),off:M._callbacksOff.bind(M)}),destroy(){Te.currentManager&&(Te.currentManager.logger.info("[Appliance]: [ApplianceMultiPlugin] destroy"),Te.currentManager.destroy(),Te.currentManager=void 0)},setMemberState(v){if(Te.currentManager){Te.currentManager.logger.info(`[Appliance]: setMemberState ${JSON.stringify(v)}`);const b=Object.keys(v);if(Ne.isRoom(s)&&s.isWritable){if(b.includes("currentApplianceName"))if(Te.currentManager.requestToolChange(v),v.currentApplianceName&&v.currentApplianceName===De.laserPen){if(Te.currentManager.isUseSimple)throw Te.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");v.currentApplianceName=De.pencil,v.useLaserPen=!0}else v.currentApplianceName&&v.currentApplianceName===De.pencil&&(v.useLaserPen=!1);try{d.call(e.mainView,v)}catch(x){throw Te.currentManager.setToolChangePending(!1,"set-member-state-error"),x}return}}throw Te.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(v,b){if(Te.logger.info("[ApplianceMultiPlugin] createMiniMap"),Te.currentManager&&Ne.isRoom(s)&&s.isWritable)return Te.currentManager.logger.info("[Appliance]: [ApplianceMultiPlugin] createMiniMap"),Te.currentManager.createMiniMap(v,b)},destroyMiniMap:async function(v){if(Te.logger.info("[ApplianceMultiPlugin] destroyeMiniMap"),Te.currentManager&&Ne.isRoom(s)&&s.isWritable)return Te.currentManager.logger.info("[Appliance]: [ApplianceMultiPlugin] destroyeMiniMap"),Te.currentManager.destroyMiniMap(v)},filterRenderByUid(v,b,x){if(Te.logger.info("[ApplianceMultiPlugin] filterRenderByUid"),Te.currentManager&&Ne.isRoom(s)&&s.isWritable)return Te.currentManager.filterRenderByUid(v,b,x)},cancelFilterRender(v,b){if(Te.logger.info("[ApplianceMultiPlugin] filterRenderByUid"),Te.currentManager&&Ne.isRoom(s)&&s.isWritable)return Te.currentManager.cancelFilterRender(v,b)},addListener:(v,b)=>{cn.PublicMsgEmitter.on(v,b)},removeListener:(v,b)=>{cn.PublicMsgEmitter.off(v,b)},usePlugin:v=>{var b;Te.logger.info("[ApplianceMultiPlugin] usePlugin",v.kind),(b=Te.currentManager)==null||b.usePlugin(v)},getDisableDeviceInputs(){if(Te.currentManager&&Ne.isRoom(s))return Te.currentManager.disableDeviceInputs},setDisableDeviceInputs(v){Te.logger.info(`[ApplianceMultiPlugin] setDisableDeviceInputs ${v}`),Te.currentManager&&Ne.isRoom(s)&&(Te.currentManager.disableDeviceInputs=v)},getDisableCameraTransform(){if(Te.currentManager&&Ne.isRoom(s))return Te.currentManager.disableCameraTransform},setDisableCameraTransform(v){Te.logger.info(`[ApplianceMultiPlugin] setDisableCameraTransform ${v}`),Te.currentManager&&Ne.isRoom(s)&&(Te.currentManager.disableCameraTransform=v)},getDisableEraseImage(){if(Te.currentManager&&Ne.isRoom(s))return Te.currentManager.disableEraseImage},setDisableEraseImage(v){Te.logger.info(`[ApplianceMultiPlugin] setDisableEraseImage ${v}`),Te.currentManager&&Ne.isRoom(s)&&(Te.currentManager.disableEraseImage=v)},setWritable:async function(v){var b;Te.logger.info(`[ApplianceMultiPlugin] setWritable ${v}`),Ne.isRoom(s)&&g&&(await((b=Te.currentManager)==null?void 0:b.setWritable(v)),await g.call(s,v))},requestIdleCallback:(v,b)=>{const x=(b==null?void 0:b.timeout)||0,z=performance.now();let E;const O=new MessageChannel;let V;const N=A=>{try{v({didTimeout:A,timeRemaining:()=>{const U=performance.now()-z;return Math.max(0,x-U)}})}catch(P){Te.logger.error("[ApplianceMultiPlugin] requestIdleCallback error:",P)}finally{O.port1.close(),O.port2.close(),E!==void 0&&cancelAnimationFrame(E),V!==void 0&&clearTimeout(V)}};return O.port1.onmessage=()=>{E=requestAnimationFrame(()=>{x>0&&performance.now()-z>=x?N(!0):N(!1)})},O.port2.postMessage(null),x>0&&(V=setTimeout(()=>{N(!0)},x)),V||E||0},cancelIdleCallback:v=>{try{clearTimeout(v),cancelAnimationFrame(v)}catch(b){Te.logger.error("[ApplianceMultiPlugin] cancelIdleCallback error:",b)}},injectMethodToObject:(v,b)=>{if(typeof v[b]=="function"||typeof v[b]>"u"){(b==="requestIdleCallback"||b==="cancelIdleCallback")&&Te.currentManager&&Te.currentManager.registerPolyfillMethod(b),v[b]=M[b];return}b==="callbacks"&&(v.callbacks.on=M._callbacksOn.bind(M),v.callbacks.off=M._callbacksOff.bind(M),v.callbacks.once=M._callbacksOnce.bind(M))},blurText:()=>{Te.logger.info("[ApplianceMultiPlugin] blurText"),Te.currentManager&&Ne.isRoom(s)&&s.isWritable&&Te.currentManager.textEditorManager.checkEmptyTextBlur()},hasElements:(v,b)=>{var x;if(Te.logger.info(`[ApplianceMultiPlugin] hasElements ${v}`),Te.currentManager&&Ne.isRoom(s)&&s.isWritable){let z=v;if(!z){const E=Te.currentManager.viewContainerManager.focuedView;z=E==null?void 0:E.focusScenePath}if(z){const E=(x=Te.currentManager.collector)==null?void 0:x.getScenePathData(z);if(E){const O=Object.values(E);return O.length>0?b?O.some(V=>b(V.toolsType)):!0:!1}return!1}return!1}},getElements:(v,b)=>{var x;if(Te.logger.info(`[ApplianceMultiPlugin] getElements ${v}`),Te.currentManager&&Ne.isRoom(s)&&s.isWritable){let z=v;if(!z){const E=Te.currentManager.viewContainerManager.focuedView;z=E==null?void 0:E.focusScenePath}if(z){const E=(x=Te.currentManager.collector)==null?void 0:x.getScenePathData(z),O=E&&Object.values(E)||[];return E&&O.length>0&&b?O.filter(V=>b(V.toolsType)):O}return[]}},stopDraw:v=>{if(Te.logger.info(`[ApplianceMultiPlugin] stopDraw ${v}`),Te.currentManager&&Ne.isRoom(s))return Te.currentManager.stopDraw(v)},loadFontFaces:()=>{var v;return Te.logger.info("[ApplianceMultiPlugin] loadFontFaces"),((v=Te.currentManager)==null?void 0:v.loadFontFaces())||Promise.resolve({status:"error"})},refreshViewRender:v=>{var b;return Te.logger.info(`[ApplianceMultiPlugin] refreshViewRender ${v}`),((b=Te.currentManager)==null?void 0:b.refreshViewRender(v))||Promise.resolve({status:"error"})},refreshRender:()=>{var v;return Te.logger.info("[ApplianceMultiPlugin] refreshRender"),((v=Te.currentManager)==null?void 0:v.refreshRender())||Promise.resolve({status:"error"})},refreshViewTextRender:v=>{var b;return Te.logger.info(`[ApplianceMultiPlugin] refreshViewTextRender ${v}`),((b=Te.currentManager)==null?void 0:b.refreshViewTextRender(v))||Promise.resolve({status:"error"})},refreshTextRender:()=>{var v;return Te.logger.info("[ApplianceMultiPlugin] refreshTextRender"),((v=Te.currentManager)==null?void 0:v.refreshTextRender())||Promise.resolve({status:"error"})},setViewLocalScenePathChange:async(v,b)=>{Te.logger.info(`[ApplianceMultiPlugin] setViewLocalScenePathChange ${v} ${b}`),Te.currentManager&&await Te.currentManager.setViewLocalScenePathChange(b,v)},insertMarkmap:async(v,b)=>{if(Te.logger.info(`[ApplianceMultiPlugin] insertMarkmap: ${v}, info: ${JSON.stringify(b)}`),Te.currentManager&&Te.currentManager.isUseBackgroundThread)return Te.currentManager.worker.insertBackgroundMarkMap(v,b)},updateMarkmap:async(v,b,x)=>{if(Te.logger.info(`[ApplianceMultiPlugin] updateMarkmap: ${v}, markmapId: ${b}, info: ${JSON.stringify(x)}`),Te.currentManager&&Te.currentManager.isUseBackgroundThread)return Te.currentManager.worker.updateBackgroundMarkMap(v,b,x)},insertBackgroundImage:async(v,b)=>{if(Te.logger.info(`[ApplianceMultiPlugin] insertBackgroundImage: ${v}, info: ${JSON.stringify(b)}`),Te.currentManager&&Te.currentManager.isUseBackgroundThread)return Te.currentManager.worker.insertBackgroundSVG(v,b)},getSelectedElements:v=>{var b,x;return(x=(b=Te.currentManager)==null?void 0:b.selectorApi)==null?void 0:x.getSelectedElements(v)},isElementPropertySupported:(v,b)=>{var x,z;return((z=(x=Te.currentManager)==null?void 0:x.selectorApi)==null?void 0:z.isElementPropertySupported(v,b))||!1},blurSelector:v=>{var b;if(Te.currentManager&&Ne.isRoom(s)&&s.isWritable){const x=(b=Te.currentManager)==null?void 0:b.selectorApi;return x?x.blurSelector(v):Promise.resolve({ok:!1,requestId:`clear-${Date.now().toString(36)}`,viewId:v||Ue,reason:"no-selection"})}return Promise.resolve({ok:!1,requestId:`clear-${Date.now().toString(36)}`,viewId:v||Ue,reason:"no-selection"})},updateSelectedElements:(v,b)=>{var x;if(Te.currentManager&&Ne.isRoom(s)&&s.isWritable){const z=(x=Te.currentManager)==null?void 0:x.selectorApi;return z?z.updateSelectedElements(v,b):Promise.resolve({requestId:`update-${Date.now().toString(36)}`,viewId:v,ok:!1,reason:"no-selection"})}return Promise.resolve({requestId:`update-${Date.now().toString(36)}`,viewId:v,ok:!1,reason:"no-writable permission"})},updateElement:(v,b,x,z,E=!0)=>{var O;if(Te.currentManager&&Ne.isRoom(s)&&s.isWritable){const V=(O=Te.currentManager)==null?void 0:O.selectorApi;return V?V.updateElement(v,b,x,z,E):Promise.resolve(!1)}return Promise.resolve(!1)},copySelectedElements:v=>{var b;if(Te.currentManager&&Ne.isRoom(s)&&s.isWritable){const x=(b=Te.currentManager)==null?void 0:b.selectorApi;return x?x.copySelectedElements(v):Promise.resolve({ok:!1,requestId:`copy-${Date.now().toString(36)}`,viewId:v||Ue,reason:"no-selection"})}return Promise.resolve({ok:!1,requestId:`copy-${Date.now().toString(36)}`,viewId:v||Ue,reason:"no-selection"})},deleteSelectedElements:v=>{var b;if(Te.currentManager&&Ne.isRoom(s)&&s.isWritable){const x=(b=Te.currentManager)==null?void 0:b.selectorApi;return x?x.deleteSelectedElements(v):Promise.resolve({ok:!1,requestId:`delete-${Date.now().toString(36)}`,viewId:v||Ue,reason:"no-selection"})}return Promise.resolve({ok:!1,requestId:`delete-${Date.now().toString(36)}`,viewId:v||Ue,reason:"no-selection"})},getFloatbarContainer:v=>{var b;return(b=Te.currentManager)==null?void 0:b.viewContainerManager.getFloatbarContainer(v)},getViewOffsetToContainer:(v,b)=>{var x;return(x=Te.currentManager)==null?void 0:x.viewContainerManager.getViewOffsetToContainer(v,b)}};M.injectMethodToObject(e,"undo"),M.injectMethodToObject(e,"redo"),M.injectMethodToObject(e,"cleanCurrentScene"),M.injectMethodToObject(e,"blurSelector"),M.injectMethodToObject(e,"updateElement"),M.injectMethodToObject(e,"insertImage"),M.injectMethodToObject(e,"completeImageUpload"),M.injectMethodToObject(e,"lockImage"),M.injectMethodToObject(e,"insertText"),M.injectMethodToObject(e,"updateText"),M.injectMethodToObject(s,"getImagesInformation"),M.injectMethodToObject(s,"callbacks"),M.injectMethodToObject(s,"screenshotToCanvasAsync"),M.injectMethodToObject(s,"getBoundingRectAsync"),M.injectMethodToObject(s,"scenePreviewAsync"),M.injectMethodToObject(s,"fillSceneSnapshotAsync"),M.injectMethodToObject(s,"blurSelector"),M.injectMethodToObject(s,"updateElement"),M.injectMethodToObject(e.mainView,"setMemberState"),Ne.isRoom(s)&&M.injectMethodToObject(s,"setWritable"),Object.defineProperty(e,"canUndoSteps",{get(){return M.canUndoSteps()}}),Object.defineProperty(e,"canRedoSteps",{get(){return M.canRedoSteps()}});const I=(v,b,x=3)=>{const z=e.focused||Ue;x>0&&z!==v?setTimeout(()=>{I(v,b,x-1)},100):e.emitter.emit("canUndoStepsChange",b)};cn.InternalMsgEmitter.on("onCanUndoStepsUpdate",(v,b)=>{I(b,v)});const D=(v,b,x=3)=>{const z=e.focused||Ue;x>0&&z!==v?setTimeout(()=>{D(v,b,x-1)},100):e.emitter.emit("canRedoStepsChange",b)};cn.InternalMsgEmitter.on("onCanRedoStepsUpdate",(v,b)=>{D(b,v)});const C={...M,callbacks:M.callbacks()};Object.defineProperty(C,"disableDeviceInputs",{set(v){M.setDisableDeviceInputs(v)},get(){return M.getDisableDeviceInputs()}}),Object.defineProperty(C,"disableCameraTransform",{set(v){M.setDisableCameraTransform(v)},get(){return M.getDisableCameraTransform()}}),Object.defineProperty(C,"disableEraseImage",{set(v){M.setDisableEraseImage(v)},get(){return M.getDisableEraseImage()}}),p&&Te.currentManager&&(Te.currentManager.bindPlugin(p),p.init(s)),e._appliancePlugin=C;const B=(f=Te.currentManager)==null?void 0:f.pluginOptions.extras.cursor;return B&&((m=Te.currentManager)==null||m.worker.afterMainViewInitAck(()=>{k0(B)})),(w=Te.currentManager)==null||w.startInitFontFaceLoadAndRender(),e._appliancePlugin}static onCreate(e){e&&Te.currentManager&&(Te.currentManager.bindPlugin(e),e.init(e.displayer))}static async createApplianceMultiPlugin(e,r){try{await e.createInvisiblePlugin(Te,{})}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 Te.createApplianceMultiPlugin(e,r)),n}get isReplay(){return Ne.isPlayer(this.displayer)}get callbackName(){return this.isReplay?"onPlayerStateChanged":"onRoomStateChanged"}init(e){var n,s;const r=e.state;(n=Te.currentManager)==null||n.onRoomMembersChange(r.roomMembers),Ne.isRoom(e)&&((s=Te.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;Te.logger.info("[ApplianceMultiPlugin] passive destroy"),(e=Te.currentManager)==null||e.destroy(),Te.currentManager=void 0}};L(Te,"kind","appliance-multi-plugin"),L(Te,"currentManager"),L(Te,"logger",{info:console.log,warn:console.warn,error:console.error}),L(Te,"createCurrentManager",(e,r,n,s)=>{Te.currentManager&&Te.currentManager.destroy();const o={plugin:n,displayer:e.displayer,options:r,onInitLoadingChange:s},a=new cn(o);a.setWindowManager(e),Te.currentManager=a});let du=Te;var r1e=Sr,n1e=function(){return r1e.Date.now()},i1e=n1e,s1e=/\s/;function o1e(i){for(var t=i.length;t--&&s1e.test(i.charAt(t)););return t}var a1e=o1e,c1e=a1e,l1e=/^\s+/;function u1e(i){return i&&i.slice(0,c1e(i)+1).replace(l1e,"")}var h1e=u1e,d1e=ai,f1e=Nr,g1e="[object Symbol]";function p1e(i){return typeof i=="symbol"||f1e(i)&&d1e(i)==g1e}var m1e=p1e,y1e=h1e,Kg=En,v1e=m1e,qg=NaN,M1e=/^[-+]0x[0-9a-f]+$/i,w1e=/^0b[01]+$/i,T1e=/^0o[0-7]+$/i,S1e=parseInt;function I1e(i){if(typeof i=="number")return i;if(v1e(i))return qg;if(Kg(i)){var t=typeof i.valueOf=="function"?i.valueOf():i;i=Kg(t)?t+"":t}if(typeof i!="string")return i===0?i:+i;i=y1e(i);var e=w1e.test(i);return e||T1e.test(i)?S1e(i.slice(2),e?2:8):M1e.test(i)?qg:+i}var C1e=I1e,x1e=En,ml=i1e,Xg=C1e,b1e="Expected a function",E1e=Math.max,A1e=Math.min;function N1e(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(b1e);t=Xg(t)||0,x1e(e)&&(u=!!e.leading,h="maxWait"in e,s=h?E1e(Xg(e.maxWait)||0,t):s,d="trailing"in e?!!e.trailing:d);function g(m){var w=r,v=n;return r=n=void 0,l=m,o=i.apply(v,w),o}function p(m){return l=m,a=setTimeout(D,t),u?g(m):o}function M(m){var w=m-c,v=m-l,b=t-w;return h?A1e(b,s-v):b}function I(m){var w=m-c,v=m-l;return c===void 0||w>=t||w<0||h&&v>=s}function D(){var m=ml();if(I(m))return C(m);a=setTimeout(D,M(m))}function C(m){return a=void 0,d&&r?g(m):(r=n=void 0,o)}function B(){a!==void 0&&clearTimeout(a),l=0,r=c=n=a=void 0}function T(){return a===void 0?o:C(ml())}function f(){var m=ml(),w=I(m);if(r=arguments,n=this,c=m,w){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 f.cancel=B,f.flush=T,f}var D1e=N1e,P1e=D1e,k1e=En,L1e="Expected a function";function R1e(i,t,e){var r=!0,n=!0;if(typeof i!="function")throw new TypeError(L1e);return k1e(e)&&(r="leading"in e?!!e.leading:r,n="trailing"in e?!!e.trailing:n),P1e(i,t,{leading:r,maxWait:t,trailing:n})}var O1e=R1e;const z1e=Jr(O1e);class j1e extends N0{constructor(e,r){super(e,r);L(this,"width",1e3);L(this,"height",1e3);L(this,"dpr",Oi());L(this,"vDom");L(this,"eventTragetElement");L(this,"snapshotContainerRef");L(this,"backgroundContainerRef");L(this,"backgroundSnapshotContainerRef");L(this,"canvasContainerRef",G.createRef());L(this,"subLocalCanvasContainerRef");L(this,"canvasTopRef");L(this,"canvasServiceFloatRef",G.createRef());L(this,"canvasFloatRef",G.createRef());L(this,"canvasBgRef",G.createRef());L(this,"floatBarRef",G.createRef());L(this,"customFloatbarContainerRef",G.createRef());L(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=Oi();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="",Ma.render(G.createElement(Bh,{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 Vn extends Li{constructor(e){super(e);L(this,"focuedViewId");L(this,"control");L(this,"focuedView");this.control=e.control}bindMainView(){if(!this.control.divMainView)return;const e=new j1e(this.control,Xe.InternalMsgEmitter),{width:r,height:n,dpr:s}=e,o={cameraOpt:{...Vn.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&&(Vn.defaultScreenCanvasOpt.contextType=this.control.renderingCompatibilityDecision.contextType);const a={dpr:o,originalPoint:[n/2,s/2],offscreenCanvasOpt:{...Vn.defaultScreenCanvasOpt,width:n,height:s},layerOpt:{...Vn.defaultLayerOpt,width:n,height:s},cameraOpt:{...Vn.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);L(this,"viewContainerManager");L(this,"divMainView");L(this,"onCameraChange",z1e(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)},wu,{leading:!1}));const r={control:this,internalMsgEmitter:or.InternalMsgEmitter,publicMsgEmitter:or.PublicMsgEmitter};this.viewContainerManager=new Vn(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 M of Object.keys(g))M&&p.add(M);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)&&(p.opt.text&&p.opt.text.replace(/\s*,/g,"")?this.textEditorManager.unActive(d):this.textEditorManager.delete(d))}}}})}),this.worker.isActive&&this.viewContainerManager.getAllViews().forEach(e=>{e&&e.focusScenePath&&this.worker.pullServiceData(e.id,e.focusScenePath,{isAsync:!0,useAnimation:!1})})))}async activeWorker(){await this.worker.init()}}const Me=class Me extends Ne.InvisiblePlugin{constructor(){super(...arguments);L(this,"onPhaseChanged",e=>{var r;e===Ne.RoomPhase.Reconnecting&&((r=Me.currentManager)==null||r.setSnapshootData())});L(this,"updateRoomWritable",()=>{var e;(e=Me.currentManager)==null||e.onWritableChange(this.displayer.isWritable)});L(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)),!(Ne.isRoom(this.displayer)&&!this.displayer.isWritable)&&e.memberState&&((n=Me.currentManager)==null||n.onMemberChange(e.memberState))})}static async getInstance(e,r){var D,C,B,T;const n=Ne.isRoom(e)&&e.logger||Me.logger,s=typeof navigator>"u"?"unknown":navigator.userAgent;n.info(`[Appliance]: [init-enter] version=${nc} userAgent=${s}`),(f=>{var m;try{(m=r.onInitLoadingChange)==null||m.call(r,f)}catch(w){Me.logger.error(`[ApplianceSinglePlugin] onInitLoadingChange error: ${(w==null?void 0:w.message)||w}`)}})({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;Ne.isRoom(e)&&(d=e.setWritable),r!=null&&r.logger&&(Me.logger=new zh(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:jy(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(),(D=Me.currentManager)==null||D.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 v;Me.logger.info("[ApplianceSinglePlugin] getBoundingRectAsync");const m=e.getBoundingRect(f),w=await((v=Me.currentManager)==null?void 0:v.getBoundingRect(f));return!m.width||!m.height?w:Dh(m,w)},screenshotToCanvasAsync:async function(f,m,w,v,b,x){var A;Me.logger.info("[ApplianceSinglePlugin] screenshotToCanvasAsync");let z=w,E=v,O=b.scale;z>this.maxScreenshotWidth&&(O=this.maxScreenshotWidth/z*O,z=this.maxScreenshotWidth),E>this.maxScreenshotHeight&&(O=Math.min(this.maxScreenshotHeight/E*O,O),E=this.maxScreenshotHeight),b.scale=O;const V=document.createElement("canvas"),N=V.getContext("2d");V.width=z*(x||1),V.height=E*(x||1),N&&(e.screenshotToCanvas(N,m,z,E,b,x),f.drawImage(V,Math.floor((w-z)/2),Math.floor((v-E)/2),z*(x||1),E*(x||1),0,0,z,E),V.remove()),Me.currentManager&&await((A=Me.currentManager)==null?void 0:A.screenshotToCanvas(f,m,z,E,b,Math.floor((w-z)/2),Math.floor((v-E)/2)))},scenePreviewAsync:async function(f,m,w,v,b){Me.logger.info("[ApplianceSinglePlugin] scenePreviewAsync"),e.scenePreview(f,m,w,v,b);const x=document.createElement("img");x.className="appliance-plugin-fill-scene-snapshot-img",m.append(x),getComputedStyle(m).position||(m.style.position="relative"),Me.currentManager&&await Me.currentManager.scenePreview(f,x)},fillSceneSnapshotAsync:async function(f,m,w,v,b){var k,W;Me.logger.info("[ApplianceSinglePlugin] fillSceneSnapshotAsync"),m.innerHTML="",e.fillSceneSnapshot(f,m,w,v,b);const x=w||((k=e.state.cameraState)==null?void 0:k.width)||0,z=v||((W=e.state.cameraState)==null?void 0:W.height)||0;let E=await this.getBoundingRectAsync(f);E||(E={originX:0,originY:0,width:x,height:z});let O=Math.max(E==null?void 0:E.width,x),V=Math.max(E==null?void 0:E.height,z),N=1;const A=O>x&&Math.min(x/O,N)||N,P=V>z&&Math.min(z/V,N)||N;A<=P?(O=A<1&&x||O,V=Math.floor(V*A)+1,N=A):A>P&&(V=P<1&&z||V,O=Math.floor(O*P)+1,N=P);const U={scale:N,centerX:E.originX+E.width/2,centerY:E.originY+E.height/2},Q=document.createElement("canvas"),K=Q.getContext("2d");Q.width=O,Q.height=V,K&&await this.screenshotToCanvasAsync(K,f,O,V,U,devicePixelRatio);const ce=document.createElement("img");ce.className="appliance-plugin-fill-scene-snapshot-img",ce.src=Q.toDataURL(),ce.onload=()=>{Q.remove()},ce.onerror=()=>{Q.remove(),ce.remove()},m.append(ce),getComputedStyle(m).position||(m.style.position="relative")},_callbacksOn:function(f,m){(f==="onCanUndoStepsUpdate"||f==="onCanRedoStepsUpdate")&&Ne.isRoom(e)&&e.isWritable?or.InternalMsgEmitter.on(f,m):a.call(e.callbacks,f,m)},_callbacksOnce:function(f,m){(f==="onCanUndoStepsUpdate"||f==="onCanRedoStepsUpdate")&&Ne.isRoom(e)&&e.isWritable?or.InternalMsgEmitter.on(f,m):l.call(e.callbacks,f,m)},_callbacksOff:function(f,m){(f==="onCanUndoStepsUpdate"||f==="onCanRedoStepsUpdate")&&Ne.isRoom(e)&&e.isWritable?or.InternalMsgEmitter.off(f,m):c.call(e.callbacks,f,m)},canRedoSteps(){if(Me.logger.info("[ApplianceSinglePlugin] canRedoSteps"),Me.currentManager&&Ne.isRoom(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(w=>w.scenePath===m).length}return 0},canUndoSteps(){if(Me.logger.info("[ApplianceSinglePlugin] canUndoSteps"),Me.currentManager&&Ne.isRoom(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(w=>w.scenePath===m).length}return 0},undo:function(){return Me.logger.info("[ApplianceSinglePlugin] undo"),Me.currentManager&&Ne.isRoom(e)&&!e.disableSerialization?Me.currentManager.viewContainerManager.undo():0},redo:function(){return Me.logger.info("[ApplianceSinglePlugin] redo"),Me.currentManager&&Ne.isRoom(e)&&!e.disableSerialization?Me.currentManager.viewContainerManager.redo():0},cleanCurrentScene:function(f){Me.logger.info("[ApplianceSinglePlugin] cleanCurrentScene"),Me.currentManager&&Ne.isRoom(e)&&e.isWritable&&Me.currentManager.cleanCurrentScene().then(()=>{u.call(e,f)}).catch(m=>{var w;(w=Me.currentManager)==null||w.logger.error(`[Appliance]: cleanCurrentScene failed: ${(m==null?void 0:m.message)||m}`)})},insertImage:function(f){Me.logger.info("[ApplianceSinglePlugin] insertImage"),Me.currentManager&&Ne.isRoom(e)&&e.isWritable&&Me.currentManager.worker.insertImage(Ue,f)},lockImage:function(f,m){Me.logger.info("[ApplianceSinglePlugin] lockImage"),Me.currentManager&&Ne.isRoom(e)&&e.isWritable&&Me.currentManager.worker.lockImage(Ue,f,m)},completeImageUpload:function(f,m){Me.logger.info("[ApplianceSinglePlugin] completeImageUpload"),Me.currentManager&&Ne.isRoom(e)&&e.isWritable&&Me.currentManager.worker.completeImageUpload(Ue,f,m)},getImagesInformation:function(f){return Me.logger.info("[ApplianceSinglePlugin] completeImageUpload"),Me.currentManager&&Ne.isRoom(e)&&e.isWritable?Me.currentManager.worker.getImagesInformation(f):[]},insertText:function(f,m,w){if(Me.logger.info("[ApplianceSinglePlugin] insertText"),Me.currentManager&&Ne.isRoom(e)&&e.isWritable)return Me.currentManager.textEditorManager.insertText(Ue,f,m,w)},updateText:function(f,m){Me.logger.info("[ApplianceMultiPlugin] updateText"),Me.currentManager&&Ne.isRoom(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 w,v,b;Me.logger.info(`[ApplianceSinglePlugin] setMemberState ${JSON.stringify(f)}`);const m=Object.keys(f);if(Ne.isRoom(e)&&e.isWritable){if(m.includes("currentApplianceName"))if((w=Me.currentManager)==null||w.requestToolChange(f),f.currentApplianceName&&f.currentApplianceName===De.laserPen){if((v=Me.currentManager)!=null&&v.isUseSimple)throw new Error("[ApplianceMultiPlugin] laserPen must be not support in simple mode");f.currentApplianceName=De.pencil,f.useLaserPen=!0}else f.currentApplianceName&&f.currentApplianceName===De.pencil&&(f.useLaserPen=!1);try{h(f)}catch(x){throw(b=Me.currentManager)==null||b.setToolChangePending(!1,"set-member-state-error"),x}return}throw new Error("setMemberState must be called in writable room")},createMiniMap:async function(f,m){if(Me.logger.info("[ApplianceSinglePlugin] createMiniMap"),Me.currentManager&&Ne.isRoom(e)&&e.isWritable)return Me.currentManager.createMiniMap(f,m)},destroyMiniMap:async function(f){if(Me.logger.info("[ApplianceMultiPlugin] destroyeMiniMap"),Me.currentManager&&Ne.isRoom(e)&&e.isWritable)return Me.currentManager.destroyMiniMap(f)},filterRenderByUid(f,m,w){if(Me.logger.info("[ApplianceSinglePlugin] filterRenderByUid"),Me.currentManager&&Ne.isRoom(e)&&e.isWritable)return Me.currentManager.filterRenderByUid(f,m,w)},cancelFilterRender(f,m){if(Me.logger.info("[ApplianceSinglePlugin] filterRenderByUid"),Me.currentManager&&Ne.isRoom(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&&Ne.isRoom(e))return Me.currentManager.disableDeviceInputs},setDisableDeviceInputs(f){Me.logger.info(`[ApplianceSinglePlugin] setDisableDeviceInputs ${f}`),Me.currentManager&&Ne.isRoom(e)&&(Me.currentManager.disableDeviceInputs=f)},getDisableCameraTransform(){if(Me.currentManager&&Ne.isRoom(e))return Me.currentManager.disableCameraTransform},setDisableCameraTransform(f){Me.logger.info(`[ApplianceSinglePlugin] setDisableCameraTransform ${f}`),Me.currentManager&&Ne.isRoom(e)&&(Me.currentManager.disableCameraTransform=f)},getDisableEraseImage(){if(Me.currentManager&&Ne.isRoom(e))return Me.currentManager.disableEraseImage},setDisableEraseImage(f){Me.logger.info(`[ApplianceSinglePlugin] setDisableEraseImage ${f}`),Me.currentManager&&Ne.isRoom(e)&&(Me.currentManager.disableEraseImage=f)},setWritable:async function(f){var m;Me.logger.info(`[ApplianceSinglePlugin] setWritable ${f}`),Ne.isRoom(e)&&d&&(await((m=Me.currentManager)==null?void 0:m.setWritable(f)),await d.call(e,f))},requestIdleCallback:(f,m)=>{const w=(m==null?void 0:m.timeout)||0,v=performance.now();let b;const x=new MessageChannel;let z;const E=O=>{try{f({didTimeout:O,timeRemaining:()=>{const N=performance.now()-v;return Math.max(0,w-N)}})}catch(V){Me.logger.error("[ApplianceSinglePlugin] requestIdleCallback error:",V)}finally{x.port1.close(),x.port2.close(),b!==void 0&&cancelAnimationFrame(b),z!==void 0&&clearTimeout(z)}};return x.port1.onmessage=()=>{b=requestAnimationFrame(()=>{w>0&&performance.now()-v>=w?E(!0):E(!1)})},x.port2.postMessage(null),w>0&&(z=setTimeout(()=>{E(!0)},w)),z||b||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&&Ne.isRoom(e)&&e.isWritable&&Me.currentManager.textEditorManager.checkEmptyTextBlur()},hasElements:(f,m)=>{var w;if(Me.logger.info(`[ApplianceSinglePlugin] hasElements ${f}`),Me.currentManager&&Ne.isRoom(e)&&e.isWritable){let v=f;if(!v){const b=Me.currentManager.viewContainerManager.focuedView;v=b==null?void 0:b.focusScenePath}if(v){const b=(w=Me.currentManager.collector)==null?void 0:w.getScenePathData(v);if(b){const x=Object.values(b);return x.length>0?m?x.some(z=>m(z.toolsType)):!0:!1}return!1}return!1}},getElements:(f,m)=>{var w;if(Me.logger.info(`[ApplianceSinglePlugin] getElements ${f}`),Me.currentManager&&Ne.isRoom(e)&&e.isWritable){let v=f;if(!v){const b=Me.currentManager.viewContainerManager.focuedView;v=b==null?void 0:b.focusScenePath}if(v){const b=(w=Me.currentManager.collector)==null?void 0:w.getScenePathData(v),x=b&&Object.values(b)||[];return b&&x.length>0&&m?x.filter(z=>m(z.toolsType)):x}return[]}},stopDraw:f=>{if(Me.logger.info(`[ApplianceSinglePlugin] stopDraw ${f}`),Me.currentManager&&Ne.isRoom(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,w)=>{if(Me.logger.info(`[ApplianceSinglePlugin] updateMarkmap: ${f}, markmapId: ${m}, info: ${JSON.stringify(w)}`),Me.currentManager&&Me.currentManager.isUseBackgroundThread)return Me.currentManager.worker.updateBackgroundMarkMap(f,m,w)},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)},getSelectedElements:f=>{var m,w;return(w=(m=Me.currentManager)==null?void 0:m.selectorApi)==null?void 0:w.getSelectedElements(f)},isElementPropertySupported:(f,m)=>{var w,v;return((v=(w=Me.currentManager)==null?void 0:w.selectorApi)==null?void 0:v.isElementPropertySupported(f,m))||!1},blurSelector:f=>{var m;if(Me.currentManager&&Ne.isRoom(e)&&e.isWritable){const w=(m=Me.currentManager)==null?void 0:m.selectorApi;return w?w.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&&Ne.isRoom(e)&&e.isWritable){const w=(m=Me.currentManager)==null?void 0:m.selectorApi;return w?w.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,w,v,b=!0)=>{var x;if(Me.currentManager&&Ne.isRoom(e)&&e.isWritable){const z=(x=Me.currentManager)==null?void 0:x.selectorApi;return z?z.updateElement(f,m,w,v,b):Promise.resolve(!1)}return Promise.resolve(!1)},copySelectedElements:f=>{var m;if(Me.currentManager&&Ne.isRoom(e)&&e.isWritable){const w=(m=Me.currentManager)==null?void 0:m.selectorApi;return w?w.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&&Ne.isRoom(e)&&e.isWritable){const w=(m=Me.currentManager)==null?void 0:m.selectorApi;return w?w.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 w;return(w=Me.currentManager)==null?void 0:w.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"),Ne.isRoom(e)&&p.injectMethodToObject(e,"setWritable"),Object.defineProperty(e,"canUndoSteps",{get(){return p.canUndoSteps()}}),Object.defineProperty(e,"canRedoSteps",{get(){return p.canRedoSteps()}});const M={...p,callbacks:p.callbacks()};Object.defineProperty(M,"disableDeviceInputs",{set(f){p.setDisableDeviceInputs(f)},get(){return p.getDisableDeviceInputs()}}),Object.defineProperty(M,"disableEraseImage",{set(f){p.setDisableEraseImage(f)},get(){return p.getDisableEraseImage()}}),Object.defineProperty(M,"disableCameraTransform",{set(f){p.setDisableCameraTransform(f)},get(){return p.getDisableCameraTransform()}}),e._appliancePlugin=M;const I=(C=Me.currentManager)==null?void 0:C.pluginOptions.extras.cursor;return I&&((B=Me.currentManager)==null||B.worker.afterMainViewInitAck(()=>{k0(I)})),(T=Me.currentManager)==null||T.startInitFontFaceLoadAndRender(),e._appliancePlugin}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===De.pencil||n.appliance===De.shape||n.appliance===De.text||n.appliance===De.arrow||n.appliance===De.straight||n.appliance===De.rectangle||n.appliance===De.ellipse||n.appliance===De.eraser||n.appliance===De.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 Ne.isPlayer(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),Ne.isRoom(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}};L(Me,"kind","appliance-single-plugin"),L(Me,"cursorAdapter"),L(Me,"currentManager"),L(Me,"logger",{info:console.log,warn:console.warn,error:console.error}),L(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 fu=Me;const Pi=class Pi extends G.Component{constructor(){super(...arguments);L(this,"mainViewRef",null)}componentDidMount(){Pi.emiter||(Pi.emiter=or.InternalMsgEmitter),Pi.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}))}};L(Pi,"emiter");let gu=Pi;exports.ActiveContainerType=_g;exports.ApplianceMultiPlugin=du;exports.ApplianceNames=De;exports.AppliancePluginCursorNames=rr;exports.ApplianceSigleWrapper=gu;exports.ApplianceSinglePlugin=fu;exports.Cursor_Hover_Id=V0;exports.DefaultAppliancePluginExtrasOptions=He;exports.ECanvasShowType=tt;exports.EDataType=Ee;exports.EForceStopReason=Mu;exports.EImageType=mn;exports.EMatrixrRelationType=pn;exports.EOperationType=yt;exports.EPostMessageType=he;exports.ERenderFilterType=gr;exports.ESVGType=Ms;exports.EScaleType=Ve;exports.EStrokeType=ze;exports.EToolsKey=Z;exports.ElayerType=Mn;exports.EmitEventType=Se;exports.EventMessageType=vs;exports.EventWorkState=ge;exports.Group=dt;exports.InternalMsgEmitterType=Fe;exports.Main_View_Id=Ue;exports.MaxDelayBatchScheduler=a0;exports.ObserverMap=nu;exports.Plugin=Mve;exports.Scene=Qa;exports.ShapeType=Gt;exports.Storage_Selector_key=Pe;exports.Storage_Splitter=Rt;exports.Storage_ViewId_ALL=ru;exports.Task_Time_Interval=wu;exports.VNodeManager=s0;exports.ViewContainerManager=Li;exports.WorkerCanvasContextBlacklistLevel=wa;exports.WorkerImageBitmapFeatureBlacklistLevel=vu;exports.WorkerMaskTextureFormatBlacklistLevel=mu;exports.WorkerMaskTextureUploadBlacklistLevel=yu;exports.WorkerRenderModeBlacklistLevel=mr;exports.acceptIncomingEraserGeometryDelta=ege;exports.cancelDoingForGeometryMismatch=Zfe;exports.computRect=Ge;exports.getEraserBatchDelay=c0;exports.getIconImageSrc=o0;exports.getOutgoingEraserGeometryDelta=Hfe;exports.getRectMatrixrRelation=cc;exports.getSafetyRect=hn;exports.getShapeInstance=Nh;exports.isEqual=Zr;exports.isIntersectForPoint=p0;exports.isNumber=It;exports.removeAllChildren=ar;exports.removeTexture=cr;exports.resolveCursorToolName=sc;exports.transformToNormalData=li;exports.transformToSerializableData=bt;
|