@netless/appliance-plugin 1.1.43-beta.5 → 1.1.43-beta.6
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-lN5XJgmt.mjs → bridge-BkznO_2I.mjs} +1 -1
- package/dist/{bridge-BU5rR3K9.js → bridge-eqcSdNuO.js} +1 -1
- package/dist/bridge.js +1 -1
- package/dist/bridge.mjs +1 -1
- package/dist/core/serviceRenderScheduler.d.ts +5 -1
- package/dist/core/types.d.ts +2 -0
- package/dist/core/worker/base.d.ts +11 -0
- package/dist/fullWorker.js +113 -105
- package/dist/{index-DSZYEn11.mjs → index-5NhESa-E.mjs} +1 -1
- package/dist/{index-AuMV5vJ_.js → index-Ao4lCeza.js} +1 -1
- package/dist/{index-1psceXIi.mjs → index-B2mao9Qt.mjs} +1 -1
- package/dist/index-B6a4M9h0.js +570 -0
- package/dist/{index-8Q-KG_bu.mjs → index-BIGq6SHu.mjs} +1 -1
- package/dist/{index-ERLPRSvt.js → index-BvII1U5g.js} +1 -1
- package/dist/{index-qlVmoCd1.js → index-C0vx0A6X.js} +1 -1
- package/dist/index-C6YB3jua.js +570 -0
- package/dist/{index-Do5kJ_zq.js → index-CIKC1p1Z.js} +1 -1
- package/dist/{index-BtLlVwbN.mjs → index-Cf8qdTfA.mjs} +4905 -4874
- package/dist/{index-CjzGgT9M.mjs → index-D8wP-XSi.mjs} +1 -1
- package/dist/{index-CGGk-ErK.mjs → index-WZBBEAwF.mjs} +9048 -9031
- package/dist/subWorker.js +81 -73
- package/package.json +1 -1
- package/dist/index-C8jhD21B.js +0 -570
- package/dist/index-D48waKFn.js +0 -570
package/dist/index-D48waKFn.js
DELETED
|
@@ -1,570 +0,0 @@
|
|
|
1
|
-
"use strict";var vM=Object.defineProperty;var MM=(s,t,e)=>t in s?vM(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var x=(s,t,e)=>MM(s,typeof t!="symbol"?t+"":t,e);const cm=require("./bridge-BU5rR3K9.js"),Ct=require("clipper-lib"),lm=require("lz-string"),th=require("lineclip"),eu=require("xss"),ye=require("lodash"),wM=require("rbush"),tu=require("eventemitter2"),SM=require("spark-md5"),Q=require("react"),Ga=require("react-dom"),Qi=require("react-draggable"),TM=require("re-resizable");var De=(s=>(s.selector="selector",s.clicker="clicker",s.laserPointer="laserPointer",s.pencil="pencil",s.rectangle="rectangle",s.ellipse="ellipse",s.shape="shape",s.eraser="eraser",s.pencilEraser="pencilEraser",s.text="text",s.straight="straight",s.arrow="arrow",s.hand="hand",s.laserPen="laserPen",s))(De||{}),Ar=(s=>(s[s.OffscreenTransfer=1]="OffscreenTransfer",s[s.ImageBitmap=2]="ImageBitmap",s[s.MainThread=3]="MainThread",s))(Ar||{}),Ha=(s=>(s[s.WebGL=1]="WebGL",s))(Ha||{}),rh=(s=>(s[s.SingleChannelTexture=1]="SingleChannelTexture",s))(rh||{}),nh=(s=>(s[s.TextureSubImage2D=1]="TextureSubImage2D",s))(nh||{}),Js=(s=>(s[s.RefreshTextRender=1]="RefreshTextRender",s))(Js||{}),Be=(s=>(s.Normal="Normal",s.Stroke="Stroke",s.Dotted="Dotted",s.LongDotted="LongDotted",s))(Be||{}),Zt=(s=>(s.Triangle="triangle",s.Rhombus="rhombus",s.Pentagram="pentagram",s.SpeechBalloon="speechBalloon",s.Star="star",s.Polygon="polygon",s))(Zt||{});const or={star:"star",polygon:"polygon",speechBalloon:"speechBalloon",bitMapEraser:"bitMapEraser"};var Te=(s=>(s.None="None",s.ShowFloatBar="ShowFloatBar",s.ZIndexFloatBar="ZIndexFloatBar",s.DeleteNode="DeleteNode",s.CopyNode="CopyNode",s.ZIndexNode="ZIndexNode",s.ZIndexBackgroundSVG="ZIndexBackgroundSVG",s.RotateNode="RotateNode",s.SetColorNode="SetColorNode",s.TranslateNode="TranslateNode",s.ScaleNode="ScaleNode",s.OriginalEvent="OriginalEvent",s.CreateScene="CreateScene",s.ActiveCursor="ActiveCursor",s.MoveCursor="MoveCursor",s.CommandEditor="CommandEditor",s.SetEditorData="SetEditorData",s.SetFontStyle="SetFontStyle",s.SetPoint="SetPoint",s.SetLock="SetLock",s.SetShapeOpt="SetShapeOpt",s.CameraChange="CameraChange",s.ActiveMethod="ActiveMethod",s.HidFloatBarBtn="HidFloatBarBtn",s.SelectMethod="SelectMethod",s))(Te||{}),We=(s=>(s.MainEngine="MainEngine",s.Cursor="Cursor",s.BindMainView="BindMainView",s))(We||{}),um=(s=>(s[s.MainView=0]="MainView",s[s.Plugin=1]="Plugin",s[s.Both=2]="Both",s))(um||{}),Ds=(s=>(s.longPencil="longPencil",s.longBitmapEraser="longBitmapEraser",s))(Ds||{}),q=(s=>(s[s.Pencil=1]="Pencil",s[s.Eraser=2]="Eraser",s[s.PencilEraser=3]="PencilEraser",s[s.BitMapEraser=4]="BitMapEraser",s[s.Selector=5]="Selector",s[s.Clicker=6]="Clicker",s[s.Arrow=7]="Arrow",s[s.Hand=8]="Hand",s[s.LaserPen=9]="LaserPen",s[s.Text=10]="Text",s[s.Straight=11]="Straight",s[s.Rectangle=12]="Rectangle",s[s.Ellipse=13]="Ellipse",s[s.Star=14]="Star",s[s.Triangle=15]="Triangle",s[s.Rhombus=16]="Rhombus",s[s.Polygon=17]="Polygon",s[s.SpeechBalloon=18]="SpeechBalloon",s[s.Image=19]="Image",s[s.BackgroundSVG=20]="BackgroundSVG",s))(q||{}),xe=(s=>(s[s.Local=1]="Local",s[s.Service=2]="Service",s[s.Worker=3]="Worker",s))(xe||{}),de=(s=>(s[s.Pending=0]="Pending",s[s.Start=1]="Start",s[s.Doing=2]="Doing",s[s.Done=3]="Done",s[s.Unwritable=4]="Unwritable",s))(de||{}),le=(s=>(s[s.None=0]="None",s[s.Init=1]="Init",s[s.UpdateCamera=2]="UpdateCamera",s[s.UpdateTools=3]="UpdateTools",s[s.CreateWork=4]="CreateWork",s[s.DrawWork=5]="DrawWork",s[s.FullWork=6]="FullWork",s[s.UpdateNode=7]="UpdateNode",s[s.RemoveNode=8]="RemoveNode",s[s.Clear=9]="Clear",s[s.Select=10]="Select",s[s.Destroy=11]="Destroy",s[s.Snapshot=12]="Snapshot",s[s.BoundingBox=13]="BoundingBox",s[s.Cursor=14]="Cursor",s[s.TextUpdate=15]="TextUpdate",s[s.GetTextActive=16]="GetTextActive",s[s.TasksQueue=17]="TasksQueue",s[s.CursorHover=18]="CursorHover",s[s.CursorBlur=19]="CursorBlur",s[s.Console=20]="Console",s[s.GetImageBitMap=23]="GetImageBitMap",s[s.AuthWriter=24]="AuthWriter",s[s.AuthReader=25]="AuthReader",s[s.AuthClear=26]="AuthClear",s[s.AuthPage=27]="AuthPage",s[s.GetVNodeInfo=28]="GetVNodeInfo",s[s.UpdateDpr=29]="UpdateDpr",s[s.SetFontFace=30]="SetFontFace",s[s.ReportError=31]="ReportError",s[s.ReportLog=32]="ReportLog",s[s.BackgroundSVGUpdate=33]="BackgroundSVGUpdate",s[s.BackgroundSVGDelete=34]="BackgroundSVGDelete",s[s.SelectorTransform=35]="SelectorTransform",s[s.CheckFontFace=36]="CheckFontFace",s[s.RefreshTextRender=37]="RefreshTextRender",s[s.ProbeRenderCapabilities=38]="ProbeRenderCapabilities",s[s.ServiceSyncCommit=39]="ServiceSyncCommit",s[s.CancelFontFace=40]="CancelFontFace",s[s.CancelBitmapEraser=41]="CancelBitmapEraser",s))(le||{}),_e=(s=>(s[s.None=0]="None",s[s.Bg=1]="Bg",s[s.ServiceFloat=2]="ServiceFloat",s[s.Float=3]="Float",s[s.TopFloat=4]="TopFloat",s))(_e||{}),Ls=(s=>(s[s.Cursor=1]="Cursor",s[s.TextCreate=2]="TextCreate",s))(Ls||{}),Cn=(s=>(s[s.Top=1]="Top",s[s.Bottom=2]="Bottom",s))(Cn||{}),Ye=(s=>(s[s.none=1]="none",s[s.all=2]="all",s[s.both=3]="both",s[s.proportional=4]="proportional",s))(Ye||{}),sn=(s=>(s[s.inside=0]="inside",s[s.outside=1]="outside",s[s.intersect=2]="intersect",s))(sn||{}),wt=(s=>(s.renderPage="renderPage",s.addPage="addPage",s.deletePage="deletePage",s.addElement="addElement",s.deleteElement="deleteElement",s.clearPage="clearPage",s.clearViewScenePath="clearViewScenePath",s.clearView="clearView",s.syncUndoStack="syncUndoStack",s.syncRedoStack="syncRedoStack",s))(wt||{}),Mr=(s=>(s.setAuth="setAuth",s.setShow="addShow",s.setHide="setHide",s.setClear="setClear",s))(Mr||{}),on=(s=>(s.Image="image",s.Iconify="iconify",s))(on||{}),Wi=(s=>(s.url="url",s.markmap="markmap",s))(Wi||{});const hm="cursorhover",Qa=20,Fe="mainView",qa=500,dm=qa,ru=500,sa=1e3,IM=cm.getWhiteWebSdkBridgeRuntime(),{toJS:oa,autorun:Vc,isRoom:ze,isPlayer:ih,InvisiblePlugin:fm,RoomPhase:Pi}=IM,va=new WeakMap,$c=(s,t)=>{try{s.error(t)}catch{}};function gm(s,t,e){const r=Symbol("appliance-room-lifecycle-owner"),n=va.get(s);if(n)return n.owner=r,n.getManager=t,n.logger=e,n.active=!0,()=>Wd(s,n,r);const i=s.setWritable,o=s.disconnect,a={},c=d=>{const f=a.transitionQueue.then(d,d);return a.transitionQueue=f.then(()=>{},()=>{}),f},l=async d=>{try{const f=a.getManager();if(d==="set-readonly"){const g=await(f==null?void 0:f.setWritable(!1));(g==null?void 0:g.status)==="failed"&&$c(a.logger,`[Appliance]: force-Done before ${d} failed ACK: ${g.failureReasons.join("; ")}`)}else{const g=await(f==null?void 0:f.forceDoneLocalWorks(d));(g==null?void 0:g.status)==="failed"&&$c(a.logger,`[Appliance]: force-Done before ${d} failed ACK: ${g.failureReasons.join("; ")}`)}}catch(f){$c(a.logger,`[Appliance]: force-Done before ${d} failed: ${(f==null?void 0:f.message)||f}`)}},u=function(d){var y;if(a.disconnectPromise)return a.disconnectPromise;if(!a.active||a.phase==="terminal")return Promise.reject(new Error("room lifecycle disposed"));const f=this,g=d||(y=a.getManager())==null?void 0:y.acquireLocalMutationFence();return c(async()=>{try{return d&&a.disconnectRequested?void 0:(d?a.phase==="readonly"&&(a.phase="active"):(a.phase="preparing-readonly",await l("set-readonly"),a.phase="readonly"),await i.call(f,d))}finally{g==null||g()}})},h=function(d){if(a.disconnectPromise)return a.disconnectPromise;if(!a.active||a.phase==="terminal")return Promise.reject(new Error("room lifecycle disposed"));a.disconnectRequested=!0;const f=this,g=a.getManager(),y=g==null?void 0:g.acquireLocalMutationFence();a.disconnectFenceRelease=y;const S=c(async()=>{var b;try{return a.phase="disconnecting",await l("disconnect"),await o.call(f,d)}finally{a.phase="terminal",a.active=!1,(b=g==null?void 0:g.markRoomLifecycleTerminal)==null||b.call(g)}});return a.disconnectPromise=S,S};return Object.assign(a,{owner:r,getManager:t,logger:e,transitionQueue:Promise.resolve(),disconnectRequested:!1,originalSetWritable:i,originalDisconnect:o,setWritableWrapper:u,disconnectWrapper:h,phase:"active",active:!0}),va.set(s,a),s.setWritable=u,s.disconnect=h,()=>Wd(s,a,r)}function Wd(s,t,e){var r;e&&t.owner!==e||(t.active=!1,t.phase="terminal",(r=t.disconnectFenceRelease)==null||r.call(t),t.disconnectFenceRelease=void 0,s.setWritable===t.setWritableWrapper&&(s.setWritable=t.originalSetWritable),s.disconnect===t.disconnectWrapper&&(s.disconnect=t.originalDisconnect),va.get(s)===t&&va.delete(s))}const CM={linear:s=>s,easeInQuad:s=>s*s,easeOutQuad:s=>s*(2-s),easeInOutQuad:s=>s<.5?2*s*s:-1+(4-2*s)*s,easeInCubic:s=>s*s*s,easeOutCubic:s=>--s*s*s+1,easeInOutCubic:s=>s<.5?4*s*s*s:(s-1)*(2*s-2)*(2*s-2)+1,easeInQuart:s=>s*s*s*s,easeOutQuart:s=>1- --s*s*s*s,easeInOutQuart:s=>s<.5?8*s*s*s*s:1-8*--s*s*s*s,easeInQuint:s=>s*s*s*s*s,easeOutQuint:s=>1+--s*s*s*s*s,easeInOutQuint:s=>s<.5?16*s*s*s*s*s:1+16*--s*s*s*s*s,easeInSine:s=>1-Math.cos(s*Math.PI/2),easeOutSine:s=>Math.sin(s*Math.PI/2),easeInOutSine:s=>-(Math.cos(Math.PI*s)-1)/2,easeInExpo:s=>s<=0?0:Math.pow(2,10*s-10),easeOutExpo:s=>s>=1?1:1-Math.pow(2,-10*s),easeInOutExpo:s=>s<=0?0:s>=1?1:s<.5?Math.pow(2,20*s-10)/2:(2-Math.pow(2,-20*s+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),i=Math.cos(t);return this.x=e*i-r*n,this.y=e*n+r*i,this}rotWith(t,e){if(e===0)return this;const r=this.x-t.x,n=this.y-t.y,i=Math.sin(e),o=Math.cos(e);return this.x=t.x+(r*o-n*i),this.y=t.y+(r*i+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,i=t.y-e.y,o=Math.sin(r),a=Math.cos(r);return new fe(e.x+(n*a-i*o),e.y+(n*o+i*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 i=fe.Tan(e,t),o=fe.Add(t,fe.Mul(i,fe.Sub(r,t).pry(i)));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 i=0;i<r;i++){const o=CM.easeInQuad(i/(r-1)),a=fe.Lrp(t,e,o);a.z=Math.min(1,.5+Math.abs(.5-bM(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 bM=s=>s<.5?2*s*s:-1+(4-2*s)*s;class Pe extends fe{constructor(t=0,e=0,r=0,n={x:0,y:0},i=0,o=0){super(t,e,r),this.x=t,this.y=e,this.z=r,this.v=n,this.t=i,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,i=this.t,o=this.a){return this.x=t,this.y=e,this.z=r,this.v=n,this.t=i,this.a=o,this}clone(){const{x:t,y:e,z:r,v:n,t:i,a:o}=this,a={x:n.x,y:n.y};return new Pe(t,e,r,a,i,o)}distance(t){return Pe.GetDistance(this,t)}isNear(t,e){return Pe.IsNear(this,t,e)}getAngleByPoints(t,e){return Pe.GetAngleByPoints(t,this,e)}static Sub(t,e){return new Pe(t.x-e.x,t.y-e.y)}static Add(t,e){return new Pe(t.x+e.x,t.y+e.y)}static GetDistance(t,e){return Pe.Len(t.clone().sub(e))}static GetAngleByPoints(t,e,r){const n=e.x-t.x,i=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(i*i+a*a);if(l&&u){const h=n*i+o*a;c=Math.acos(h/(l*u)),c=c/Math.PI*180;let d=n*a-o*i;d=d>0?1:-1,c=180+d*c}return c}static IsNear(t,e,r){return Pe.Len(t.clone().sub(e))<r}static RotWith(t,e,r,n=2){const i=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+(i*c-o*a))*l)/l,h=Math.floor((e.y+(i*a+o*c))*l)/l;return new Pe(u,h)}static GetDotStroke(t,e,r=16){const n=new fe(1,1),i=Math.PI+.001,o=Pe.Add(t,Pe.Sub(t,n).uni().per().mul(-e)),a=[];for(let c=1/r,l=c;l<=1;l+=c)a.push(Pe.RotWith(o,t,i*2*l));return a}static GetSemicircleStroke(t,e,r=-1,n=8){const i=r*(Math.PI+.001),o=[];for(let a=1/n,c=a;c<=1;c+=a)o.push(Pe.RotWith(e,t,i*c));return o}}var Mi=1e-6,Us=typeof Float32Array<"u"?Float32Array:Array;function Ze(s){Us=s}function EM(){var s=new Us(6);return Us!=Float32Array&&(s[1]=0,s[2]=0,s[4]=0,s[5]=0),s[0]=1,s[3]=1,s}function xM(s){var t=new Us(6);return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t}function RM(s,t){return s[0]=t[0],s[1]=t[1],s[2]=t[2],s[3]=t[3],s[4]=t[4],s[5]=t[5],s}function kM(s){return s[0]=1,s[1]=0,s[2]=0,s[3]=1,s[4]=0,s[5]=0,s}function ei(s,t,e,r,n,i){var o=new Us(6);return o[0]=s,o[1]=t,o[2]=e,o[3]=r,o[4]=n,o[5]=i,o}function AM(s,t,e,r,n,i,o){return s[0]=t,s[1]=e,s[2]=r,s[3]=n,s[4]=i,s[5]=o,s}function Ma(s,t){var e=t[0],r=t[1],n=t[2],i=t[3],o=t[4],a=t[5],c=e*i-r*n;return c?(c=1/c,s[0]=i*c,s[1]=-r*c,s[2]=-n*c,s[3]=e*c,s[4]=(n*a-i*o)*c,s[5]=(r*o-e*a)*c,s):null}function PM(s){return s[0]*s[3]-s[1]*s[2]}function Nr(s,t,e){var r=t[0],n=t[1],i=t[2],o=t[3],a=t[4],c=t[5],l=e[0],u=e[1],h=e[2],d=e[3],f=e[4],g=e[5];return s[0]=r*l+i*u,s[1]=n*l+o*u,s[2]=r*h+i*d,s[3]=n*h+o*d,s[4]=r*f+i*g+a,s[5]=n*f+o*g+c,s}function pm(s,t,e){var r=t[0],n=t[1],i=t[2],o=t[3],a=t[4],c=t[5],l=Math.sin(e),u=Math.cos(e);return s[0]=r*u+i*l,s[1]=n*u+o*l,s[2]=r*-l+i*u,s[3]=n*-l+o*u,s[4]=a,s[5]=c,s}function DM(s,t,e){var r=t[0],n=t[1],i=t[2],o=t[3],a=t[4],c=t[5],l=e[0],u=e[1];return s[0]=r*l,s[1]=n*l,s[2]=i*u,s[3]=o*u,s[4]=a,s[5]=c,s}function nu(s,t,e){var r=t[0],n=t[1],i=t[2],o=t[3],a=t[4],c=t[5],l=e[0],u=e[1];return s[0]=r,s[1]=n,s[2]=i,s[3]=o,s[4]=r*l+i*u+a,s[5]=n*l+o*u+c,s}function LM(s,t){var e=Math.sin(t),r=Math.cos(t);return s[0]=r,s[1]=e,s[2]=-e,s[3]=r,s[4]=0,s[5]=0,s}function NM(s,t){return s[0]=t[0],s[1]=0,s[2]=0,s[3]=t[1],s[4]=0,s[5]=0,s}function OM(s,t){return s[0]=1,s[1]=0,s[2]=0,s[3]=1,s[4]=t[0],s[5]=t[1],s}function zM(s){return"mat2d("+s[0]+", "+s[1]+", "+s[2]+", "+s[3]+", "+s[4]+", "+s[5]+")"}function BM(s){return Math.sqrt(s[0]*s[0]+s[1]*s[1]+s[2]*s[2]+s[3]*s[3]+s[4]*s[4]+s[5]*s[5]+1)}function jM(s,t,e){return s[0]=t[0]+e[0],s[1]=t[1]+e[1],s[2]=t[2]+e[2],s[3]=t[3]+e[3],s[4]=t[4]+e[4],s[5]=t[5]+e[5],s}function mm(s,t,e){return s[0]=t[0]-e[0],s[1]=t[1]-e[1],s[2]=t[2]-e[2],s[3]=t[3]-e[3],s[4]=t[4]-e[4],s[5]=t[5]-e[5],s}function FM(s,t,e){return s[0]=t[0]*e,s[1]=t[1]*e,s[2]=t[2]*e,s[3]=t[3]*e,s[4]=t[4]*e,s[5]=t[5]*e,s}function UM(s,t,e,r){return s[0]=t[0]+e[0]*r,s[1]=t[1]+e[1]*r,s[2]=t[2]+e[2]*r,s[3]=t[3]+e[3]*r,s[4]=t[4]+e[4]*r,s[5]=t[5]+e[5]*r,s}function WM(s,t){return s[0]===t[0]&&s[1]===t[1]&&s[2]===t[2]&&s[3]===t[3]&&s[4]===t[4]&&s[5]===t[5]}function VM(s,t){var e=s[0],r=s[1],n=s[2],i=s[3],o=s[4],a=s[5],c=t[0],l=t[1],u=t[2],h=t[3],d=t[4],f=t[5];return Math.abs(e-c)<=Mi*Math.max(1,Math.abs(e),Math.abs(c))&&Math.abs(r-l)<=Mi*Math.max(1,Math.abs(r),Math.abs(l))&&Math.abs(n-u)<=Mi*Math.max(1,Math.abs(n),Math.abs(u))&&Math.abs(i-h)<=Mi*Math.max(1,Math.abs(i),Math.abs(h))&&Math.abs(o-d)<=Mi*Math.max(1,Math.abs(o),Math.abs(d))&&Math.abs(a-f)<=Mi*Math.max(1,Math.abs(a),Math.abs(f))}var $M=Nr,YM=mm;const ym=Object.freeze(Object.defineProperty({__proto__:null,add:jM,clone:xM,copy:RM,create:EM,determinant:PM,equals:VM,exactEquals:WM,frob:BM,fromRotation:LM,fromScaling:NM,fromTranslation:OM,fromValues:ei,identity:kM,invert:Ma,mul:$M,multiply:Nr,multiplyScalar:FM,multiplyScalarAndAdd:UM,rotate:pm,scale:DM,set:AM,str:zM,sub:YM,subtract:mm,translate:nu},Symbol.toStringTag,{value:"Module"}));var St=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ln(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var vm={exports:{}};(function(s,t){(function(r,n){s.exports=n()})(St,function(){return function(e){var r={};function n(i){if(r[i])return r[i].exports;var o=r[i]={i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=r,n.d=function(i,o,a){n.o(i,o)||Object.defineProperty(i,o,{enumerable:!0,get:a})},n.r=function(i){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(i,"__esModule",{value:!0})},n.t=function(i,o){if(o&1&&(i=n(i)),o&8||o&4&&typeof i=="object"&&i&&i.__esModule)return i;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:i}),o&2&&typeof i!="string")for(var c in i)n.d(a,c,(function(l){return i[l]}).bind(null,c));return a},n.n=function(i){var o=i&&i.__esModule?function(){return i.default}:function(){return i};return n.d(o,"a",o),o},n.o=function(i,o){return Object.prototype.hasOwnProperty.call(i,o)},n.p="/js/",n(n.s=0)}([function(e,r,n){n.r(r);var i=n(12);n.d(r,"Renderer",function(){return i.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 i=n(2);n.d(r,"glMatrix",function(){return i});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 f=n(8);n.d(r,"vec3",function(){return f});var g=n(9);n.d(r,"vec4",function(){return g})},function(e,r,n){n.r(r),n.d(r,"EPSILON",function(){return i}),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 i=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,f){return Math.abs(d-f)<=i*Math.max(1,Math.abs(d),Math.abs(f))}Math.hypot||(Math.hypot=function(){for(var d=0,f=arguments.length;f--;)d+=arguments[f]*arguments[f];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 f}),n.d(r,"adjoint",function(){return g}),n.d(r,"determinant",function(){return y}),n.d(r,"multiply",function(){return S}),n.d(r,"rotate",function(){return b}),n.d(r,"scale",function(){return I}),n.d(r,"fromRotation",function(){return N}),n.d(r,"fromScaling",function(){return T}),n.d(r,"str",function(){return p}),n.d(r,"frob",function(){return m}),n.d(r,"LDU",function(){return v}),n.d(r,"add",function(){return M}),n.d(r,"subtract",function(){return k}),n.d(r,"exactEquals",function(){return E}),n.d(r,"equals",function(){return D}),n.d(r,"multiplyScalar",function(){return P}),n.d(r,"multiplyScalarAndAdd",function(){return z}),n.d(r,"mul",function(){return j}),n.d(r,"sub",function(){return A});var i=n(2);function o(){var R=new i.ARRAY_TYPE(4);return i.ARRAY_TYPE!=Float32Array&&(R[1]=0,R[2]=0),R[0]=1,R[3]=1,R}function a(R){var L=new i.ARRAY_TYPE(4);return L[0]=R[0],L[1]=R[1],L[2]=R[2],L[3]=R[3],L}function c(R,L){return R[0]=L[0],R[1]=L[1],R[2]=L[2],R[3]=L[3],R}function l(R){return R[0]=1,R[1]=0,R[2]=0,R[3]=1,R}function u(R,L,W,Y){var H=new i.ARRAY_TYPE(4);return H[0]=R,H[1]=L,H[2]=W,H[3]=Y,H}function h(R,L,W,Y,H){return R[0]=L,R[1]=W,R[2]=Y,R[3]=H,R}function d(R,L){if(R===L){var W=L[1];R[1]=L[2],R[2]=W}else R[0]=L[0],R[1]=L[2],R[2]=L[1],R[3]=L[3];return R}function f(R,L){var W=L[0],Y=L[1],H=L[2],ie=L[3],O=W*ie-H*Y;return O?(O=1/O,R[0]=ie*O,R[1]=-Y*O,R[2]=-H*O,R[3]=W*O,R):null}function g(R,L){var W=L[0];return R[0]=L[3],R[1]=-L[1],R[2]=-L[2],R[3]=W,R}function y(R){return R[0]*R[3]-R[2]*R[1]}function S(R,L,W){var Y=L[0],H=L[1],ie=L[2],O=L[3],V=W[0],Z=W[1],$=W[2],ee=W[3];return R[0]=Y*V+ie*Z,R[1]=H*V+O*Z,R[2]=Y*$+ie*ee,R[3]=H*$+O*ee,R}function b(R,L,W){var Y=L[0],H=L[1],ie=L[2],O=L[3],V=Math.sin(W),Z=Math.cos(W);return R[0]=Y*Z+ie*V,R[1]=H*Z+O*V,R[2]=Y*-V+ie*Z,R[3]=H*-V+O*Z,R}function I(R,L,W){var Y=L[0],H=L[1],ie=L[2],O=L[3],V=W[0],Z=W[1];return R[0]=Y*V,R[1]=H*V,R[2]=ie*Z,R[3]=O*Z,R}function N(R,L){var W=Math.sin(L),Y=Math.cos(L);return R[0]=Y,R[1]=W,R[2]=-W,R[3]=Y,R}function T(R,L){return R[0]=L[0],R[1]=0,R[2]=0,R[3]=L[1],R}function p(R){return"mat2("+R[0]+", "+R[1]+", "+R[2]+", "+R[3]+")"}function m(R){return Math.hypot(R[0],R[1],R[2],R[3])}function v(R,L,W,Y){return R[2]=Y[2]/Y[0],W[0]=Y[0],W[1]=Y[1],W[3]=Y[3]-R[2]*W[1],[R,L,W]}function M(R,L,W){return R[0]=L[0]+W[0],R[1]=L[1]+W[1],R[2]=L[2]+W[2],R[3]=L[3]+W[3],R}function k(R,L,W){return R[0]=L[0]-W[0],R[1]=L[1]-W[1],R[2]=L[2]-W[2],R[3]=L[3]-W[3],R}function E(R,L){return R[0]===L[0]&&R[1]===L[1]&&R[2]===L[2]&&R[3]===L[3]}function D(R,L){var W=R[0],Y=R[1],H=R[2],ie=R[3],O=L[0],V=L[1],Z=L[2],$=L[3];return Math.abs(W-O)<=i.EPSILON*Math.max(1,Math.abs(W),Math.abs(O))&&Math.abs(Y-V)<=i.EPSILON*Math.max(1,Math.abs(Y),Math.abs(V))&&Math.abs(H-Z)<=i.EPSILON*Math.max(1,Math.abs(H),Math.abs(Z))&&Math.abs(ie-$)<=i.EPSILON*Math.max(1,Math.abs(ie),Math.abs($))}function P(R,L,W){return R[0]=L[0]*W,R[1]=L[1]*W,R[2]=L[2]*W,R[3]=L[3]*W,R}function z(R,L,W,Y){return R[0]=L[0]+W[0]*Y,R[1]=L[1]+W[1]*Y,R[2]=L[2]+W[2]*Y,R[3]=L[3]+W[3]*Y,R}var j=S,A=k},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 f}),n.d(r,"multiply",function(){return g}),n.d(r,"rotate",function(){return y}),n.d(r,"scale",function(){return S}),n.d(r,"translate",function(){return b}),n.d(r,"fromRotation",function(){return I}),n.d(r,"fromScaling",function(){return N}),n.d(r,"fromTranslation",function(){return T}),n.d(r,"str",function(){return p}),n.d(r,"frob",function(){return m}),n.d(r,"add",function(){return v}),n.d(r,"subtract",function(){return M}),n.d(r,"multiplyScalar",function(){return k}),n.d(r,"multiplyScalarAndAdd",function(){return E}),n.d(r,"exactEquals",function(){return D}),n.d(r,"equals",function(){return P}),n.d(r,"mul",function(){return z}),n.d(r,"sub",function(){return j});var i=n(2);function o(){var A=new i.ARRAY_TYPE(6);return i.ARRAY_TYPE!=Float32Array&&(A[1]=0,A[2]=0,A[4]=0,A[5]=0),A[0]=1,A[3]=1,A}function a(A){var R=new i.ARRAY_TYPE(6);return R[0]=A[0],R[1]=A[1],R[2]=A[2],R[3]=A[3],R[4]=A[4],R[5]=A[5],R}function c(A,R){return A[0]=R[0],A[1]=R[1],A[2]=R[2],A[3]=R[3],A[4]=R[4],A[5]=R[5],A}function l(A){return A[0]=1,A[1]=0,A[2]=0,A[3]=1,A[4]=0,A[5]=0,A}function u(A,R,L,W,Y,H){var ie=new i.ARRAY_TYPE(6);return ie[0]=A,ie[1]=R,ie[2]=L,ie[3]=W,ie[4]=Y,ie[5]=H,ie}function h(A,R,L,W,Y,H,ie){return A[0]=R,A[1]=L,A[2]=W,A[3]=Y,A[4]=H,A[5]=ie,A}function d(A,R){var L=R[0],W=R[1],Y=R[2],H=R[3],ie=R[4],O=R[5],V=L*H-W*Y;return V?(V=1/V,A[0]=H*V,A[1]=-W*V,A[2]=-Y*V,A[3]=L*V,A[4]=(Y*O-H*ie)*V,A[5]=(W*ie-L*O)*V,A):null}function f(A){return A[0]*A[3]-A[1]*A[2]}function g(A,R,L){var W=R[0],Y=R[1],H=R[2],ie=R[3],O=R[4],V=R[5],Z=L[0],$=L[1],ee=L[2],se=L[3],ce=L[4],me=L[5];return A[0]=W*Z+H*$,A[1]=Y*Z+ie*$,A[2]=W*ee+H*se,A[3]=Y*ee+ie*se,A[4]=W*ce+H*me+O,A[5]=Y*ce+ie*me+V,A}function y(A,R,L){var W=R[0],Y=R[1],H=R[2],ie=R[3],O=R[4],V=R[5],Z=Math.sin(L),$=Math.cos(L);return A[0]=W*$+H*Z,A[1]=Y*$+ie*Z,A[2]=W*-Z+H*$,A[3]=Y*-Z+ie*$,A[4]=O,A[5]=V,A}function S(A,R,L){var W=R[0],Y=R[1],H=R[2],ie=R[3],O=R[4],V=R[5],Z=L[0],$=L[1];return A[0]=W*Z,A[1]=Y*Z,A[2]=H*$,A[3]=ie*$,A[4]=O,A[5]=V,A}function b(A,R,L){var W=R[0],Y=R[1],H=R[2],ie=R[3],O=R[4],V=R[5],Z=L[0],$=L[1];return A[0]=W,A[1]=Y,A[2]=H,A[3]=ie,A[4]=W*Z+H*$+O,A[5]=Y*Z+ie*$+V,A}function I(A,R){var L=Math.sin(R),W=Math.cos(R);return A[0]=W,A[1]=L,A[2]=-L,A[3]=W,A[4]=0,A[5]=0,A}function N(A,R){return A[0]=R[0],A[1]=0,A[2]=0,A[3]=R[1],A[4]=0,A[5]=0,A}function T(A,R){return A[0]=1,A[1]=0,A[2]=0,A[3]=1,A[4]=R[0],A[5]=R[1],A}function p(A){return"mat2d("+A[0]+", "+A[1]+", "+A[2]+", "+A[3]+", "+A[4]+", "+A[5]+")"}function m(A){return Math.hypot(A[0],A[1],A[2],A[3],A[4],A[5],1)}function v(A,R,L){return A[0]=R[0]+L[0],A[1]=R[1]+L[1],A[2]=R[2]+L[2],A[3]=R[3]+L[3],A[4]=R[4]+L[4],A[5]=R[5]+L[5],A}function M(A,R,L){return A[0]=R[0]-L[0],A[1]=R[1]-L[1],A[2]=R[2]-L[2],A[3]=R[3]-L[3],A[4]=R[4]-L[4],A[5]=R[5]-L[5],A}function k(A,R,L){return A[0]=R[0]*L,A[1]=R[1]*L,A[2]=R[2]*L,A[3]=R[3]*L,A[4]=R[4]*L,A[5]=R[5]*L,A}function E(A,R,L,W){return A[0]=R[0]+L[0]*W,A[1]=R[1]+L[1]*W,A[2]=R[2]+L[2]*W,A[3]=R[3]+L[3]*W,A[4]=R[4]+L[4]*W,A[5]=R[5]+L[5]*W,A}function D(A,R){return A[0]===R[0]&&A[1]===R[1]&&A[2]===R[2]&&A[3]===R[3]&&A[4]===R[4]&&A[5]===R[5]}function P(A,R){var L=A[0],W=A[1],Y=A[2],H=A[3],ie=A[4],O=A[5],V=R[0],Z=R[1],$=R[2],ee=R[3],se=R[4],ce=R[5];return Math.abs(L-V)<=i.EPSILON*Math.max(1,Math.abs(L),Math.abs(V))&&Math.abs(W-Z)<=i.EPSILON*Math.max(1,Math.abs(W),Math.abs(Z))&&Math.abs(Y-$)<=i.EPSILON*Math.max(1,Math.abs(Y),Math.abs($))&&Math.abs(H-ee)<=i.EPSILON*Math.max(1,Math.abs(H),Math.abs(ee))&&Math.abs(ie-se)<=i.EPSILON*Math.max(1,Math.abs(ie),Math.abs(se))&&Math.abs(O-ce)<=i.EPSILON*Math.max(1,Math.abs(O),Math.abs(ce))}var z=g,j=M},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 f}),n.d(r,"invert",function(){return g}),n.d(r,"adjoint",function(){return y}),n.d(r,"determinant",function(){return S}),n.d(r,"multiply",function(){return b}),n.d(r,"translate",function(){return I}),n.d(r,"rotate",function(){return N}),n.d(r,"scale",function(){return T}),n.d(r,"fromTranslation",function(){return p}),n.d(r,"fromRotation",function(){return m}),n.d(r,"fromScaling",function(){return v}),n.d(r,"fromMat2d",function(){return M}),n.d(r,"fromQuat",function(){return k}),n.d(r,"normalFromMat4",function(){return E}),n.d(r,"projection",function(){return D}),n.d(r,"str",function(){return P}),n.d(r,"frob",function(){return z}),n.d(r,"add",function(){return j}),n.d(r,"subtract",function(){return A}),n.d(r,"multiplyScalar",function(){return R}),n.d(r,"multiplyScalarAndAdd",function(){return L}),n.d(r,"exactEquals",function(){return W}),n.d(r,"equals",function(){return Y}),n.d(r,"mul",function(){return H}),n.d(r,"sub",function(){return ie});var i=n(2);function o(){var O=new i.ARRAY_TYPE(9);return i.ARRAY_TYPE!=Float32Array&&(O[1]=0,O[2]=0,O[3]=0,O[5]=0,O[6]=0,O[7]=0),O[0]=1,O[4]=1,O[8]=1,O}function a(O,V){return O[0]=V[0],O[1]=V[1],O[2]=V[2],O[3]=V[4],O[4]=V[5],O[5]=V[6],O[6]=V[8],O[7]=V[9],O[8]=V[10],O}function c(O){var V=new i.ARRAY_TYPE(9);return V[0]=O[0],V[1]=O[1],V[2]=O[2],V[3]=O[3],V[4]=O[4],V[5]=O[5],V[6]=O[6],V[7]=O[7],V[8]=O[8],V}function l(O,V){return O[0]=V[0],O[1]=V[1],O[2]=V[2],O[3]=V[3],O[4]=V[4],O[5]=V[5],O[6]=V[6],O[7]=V[7],O[8]=V[8],O}function u(O,V,Z,$,ee,se,ce,me,pe){var B=new i.ARRAY_TYPE(9);return B[0]=O,B[1]=V,B[2]=Z,B[3]=$,B[4]=ee,B[5]=se,B[6]=ce,B[7]=me,B[8]=pe,B}function h(O,V,Z,$,ee,se,ce,me,pe,B){return O[0]=V,O[1]=Z,O[2]=$,O[3]=ee,O[4]=se,O[5]=ce,O[6]=me,O[7]=pe,O[8]=B,O}function d(O){return O[0]=1,O[1]=0,O[2]=0,O[3]=0,O[4]=1,O[5]=0,O[6]=0,O[7]=0,O[8]=1,O}function f(O,V){if(O===V){var Z=V[1],$=V[2],ee=V[5];O[1]=V[3],O[2]=V[6],O[3]=Z,O[5]=V[7],O[6]=$,O[7]=ee}else O[0]=V[0],O[1]=V[3],O[2]=V[6],O[3]=V[1],O[4]=V[4],O[5]=V[7],O[6]=V[2],O[7]=V[5],O[8]=V[8];return O}function g(O,V){var Z=V[0],$=V[1],ee=V[2],se=V[3],ce=V[4],me=V[5],pe=V[6],B=V[7],F=V[8],J=F*ce-me*B,oe=-F*se+me*pe,K=B*se-ce*pe,te=Z*J+$*oe+ee*K;return te?(te=1/te,O[0]=J*te,O[1]=(-F*$+ee*B)*te,O[2]=(me*$-ee*ce)*te,O[3]=oe*te,O[4]=(F*Z-ee*pe)*te,O[5]=(-me*Z+ee*se)*te,O[6]=K*te,O[7]=(-B*Z+$*pe)*te,O[8]=(ce*Z-$*se)*te,O):null}function y(O,V){var Z=V[0],$=V[1],ee=V[2],se=V[3],ce=V[4],me=V[5],pe=V[6],B=V[7],F=V[8];return O[0]=ce*F-me*B,O[1]=ee*B-$*F,O[2]=$*me-ee*ce,O[3]=me*pe-se*F,O[4]=Z*F-ee*pe,O[5]=ee*se-Z*me,O[6]=se*B-ce*pe,O[7]=$*pe-Z*B,O[8]=Z*ce-$*se,O}function S(O){var V=O[0],Z=O[1],$=O[2],ee=O[3],se=O[4],ce=O[5],me=O[6],pe=O[7],B=O[8];return V*(B*se-ce*pe)+Z*(-B*ee+ce*me)+$*(pe*ee-se*me)}function b(O,V,Z){var $=V[0],ee=V[1],se=V[2],ce=V[3],me=V[4],pe=V[5],B=V[6],F=V[7],J=V[8],oe=Z[0],K=Z[1],te=Z[2],w=Z[3],C=Z[4],U=Z[5],G=Z[6],_=Z[7],re=Z[8];return O[0]=oe*$+K*ce+te*B,O[1]=oe*ee+K*me+te*F,O[2]=oe*se+K*pe+te*J,O[3]=w*$+C*ce+U*B,O[4]=w*ee+C*me+U*F,O[5]=w*se+C*pe+U*J,O[6]=G*$+_*ce+re*B,O[7]=G*ee+_*me+re*F,O[8]=G*se+_*pe+re*J,O}function I(O,V,Z){var $=V[0],ee=V[1],se=V[2],ce=V[3],me=V[4],pe=V[5],B=V[6],F=V[7],J=V[8],oe=Z[0],K=Z[1];return O[0]=$,O[1]=ee,O[2]=se,O[3]=ce,O[4]=me,O[5]=pe,O[6]=oe*$+K*ce+B,O[7]=oe*ee+K*me+F,O[8]=oe*se+K*pe+J,O}function N(O,V,Z){var $=V[0],ee=V[1],se=V[2],ce=V[3],me=V[4],pe=V[5],B=V[6],F=V[7],J=V[8],oe=Math.sin(Z),K=Math.cos(Z);return O[0]=K*$+oe*ce,O[1]=K*ee+oe*me,O[2]=K*se+oe*pe,O[3]=K*ce-oe*$,O[4]=K*me-oe*ee,O[5]=K*pe-oe*se,O[6]=B,O[7]=F,O[8]=J,O}function T(O,V,Z){var $=Z[0],ee=Z[1];return O[0]=$*V[0],O[1]=$*V[1],O[2]=$*V[2],O[3]=ee*V[3],O[4]=ee*V[4],O[5]=ee*V[5],O[6]=V[6],O[7]=V[7],O[8]=V[8],O}function p(O,V){return O[0]=1,O[1]=0,O[2]=0,O[3]=0,O[4]=1,O[5]=0,O[6]=V[0],O[7]=V[1],O[8]=1,O}function m(O,V){var Z=Math.sin(V),$=Math.cos(V);return O[0]=$,O[1]=Z,O[2]=0,O[3]=-Z,O[4]=$,O[5]=0,O[6]=0,O[7]=0,O[8]=1,O}function v(O,V){return O[0]=V[0],O[1]=0,O[2]=0,O[3]=0,O[4]=V[1],O[5]=0,O[6]=0,O[7]=0,O[8]=1,O}function M(O,V){return O[0]=V[0],O[1]=V[1],O[2]=0,O[3]=V[2],O[4]=V[3],O[5]=0,O[6]=V[4],O[7]=V[5],O[8]=1,O}function k(O,V){var Z=V[0],$=V[1],ee=V[2],se=V[3],ce=Z+Z,me=$+$,pe=ee+ee,B=Z*ce,F=$*ce,J=$*me,oe=ee*ce,K=ee*me,te=ee*pe,w=se*ce,C=se*me,U=se*pe;return O[0]=1-J-te,O[3]=F-U,O[6]=oe+C,O[1]=F+U,O[4]=1-B-te,O[7]=K-w,O[2]=oe-C,O[5]=K+w,O[8]=1-B-J,O}function E(O,V){var Z=V[0],$=V[1],ee=V[2],se=V[3],ce=V[4],me=V[5],pe=V[6],B=V[7],F=V[8],J=V[9],oe=V[10],K=V[11],te=V[12],w=V[13],C=V[14],U=V[15],G=Z*me-$*ce,_=Z*pe-ee*ce,re=Z*B-se*ce,ne=$*pe-ee*me,X=$*B-se*me,ae=ee*B-se*pe,ue=F*w-J*te,he=F*C-oe*te,ge=F*U-K*te,Me=J*C-oe*w,we=J*U-K*w,be=oe*U-K*C,Ce=G*be-_*we+re*Me+ne*ge-X*he+ae*ue;return Ce?(Ce=1/Ce,O[0]=(me*be-pe*we+B*Me)*Ce,O[1]=(pe*ge-ce*be-B*he)*Ce,O[2]=(ce*we-me*ge+B*ue)*Ce,O[3]=(ee*we-$*be-se*Me)*Ce,O[4]=(Z*be-ee*ge+se*he)*Ce,O[5]=($*ge-Z*we-se*ue)*Ce,O[6]=(w*ae-C*X+U*ne)*Ce,O[7]=(C*re-te*ae-U*_)*Ce,O[8]=(te*X-w*re+U*G)*Ce,O):null}function D(O,V,Z){return O[0]=2/V,O[1]=0,O[2]=0,O[3]=0,O[4]=-2/Z,O[5]=0,O[6]=-1,O[7]=1,O[8]=1,O}function P(O){return"mat3("+O[0]+", "+O[1]+", "+O[2]+", "+O[3]+", "+O[4]+", "+O[5]+", "+O[6]+", "+O[7]+", "+O[8]+")"}function z(O){return Math.hypot(O[0],O[1],O[2],O[3],O[4],O[5],O[6],O[7],O[8])}function j(O,V,Z){return O[0]=V[0]+Z[0],O[1]=V[1]+Z[1],O[2]=V[2]+Z[2],O[3]=V[3]+Z[3],O[4]=V[4]+Z[4],O[5]=V[5]+Z[5],O[6]=V[6]+Z[6],O[7]=V[7]+Z[7],O[8]=V[8]+Z[8],O}function A(O,V,Z){return O[0]=V[0]-Z[0],O[1]=V[1]-Z[1],O[2]=V[2]-Z[2],O[3]=V[3]-Z[3],O[4]=V[4]-Z[4],O[5]=V[5]-Z[5],O[6]=V[6]-Z[6],O[7]=V[7]-Z[7],O[8]=V[8]-Z[8],O}function R(O,V,Z){return O[0]=V[0]*Z,O[1]=V[1]*Z,O[2]=V[2]*Z,O[3]=V[3]*Z,O[4]=V[4]*Z,O[5]=V[5]*Z,O[6]=V[6]*Z,O[7]=V[7]*Z,O[8]=V[8]*Z,O}function L(O,V,Z,$){return O[0]=V[0]+Z[0]*$,O[1]=V[1]+Z[1]*$,O[2]=V[2]+Z[2]*$,O[3]=V[3]+Z[3]*$,O[4]=V[4]+Z[4]*$,O[5]=V[5]+Z[5]*$,O[6]=V[6]+Z[6]*$,O[7]=V[7]+Z[7]*$,O[8]=V[8]+Z[8]*$,O}function W(O,V){return O[0]===V[0]&&O[1]===V[1]&&O[2]===V[2]&&O[3]===V[3]&&O[4]===V[4]&&O[5]===V[5]&&O[6]===V[6]&&O[7]===V[7]&&O[8]===V[8]}function Y(O,V){var Z=O[0],$=O[1],ee=O[2],se=O[3],ce=O[4],me=O[5],pe=O[6],B=O[7],F=O[8],J=V[0],oe=V[1],K=V[2],te=V[3],w=V[4],C=V[5],U=V[6],G=V[7],_=V[8];return Math.abs(Z-J)<=i.EPSILON*Math.max(1,Math.abs(Z),Math.abs(J))&&Math.abs($-oe)<=i.EPSILON*Math.max(1,Math.abs($),Math.abs(oe))&&Math.abs(ee-K)<=i.EPSILON*Math.max(1,Math.abs(ee),Math.abs(K))&&Math.abs(se-te)<=i.EPSILON*Math.max(1,Math.abs(se),Math.abs(te))&&Math.abs(ce-w)<=i.EPSILON*Math.max(1,Math.abs(ce),Math.abs(w))&&Math.abs(me-C)<=i.EPSILON*Math.max(1,Math.abs(me),Math.abs(C))&&Math.abs(pe-U)<=i.EPSILON*Math.max(1,Math.abs(pe),Math.abs(U))&&Math.abs(B-G)<=i.EPSILON*Math.max(1,Math.abs(B),Math.abs(G))&&Math.abs(F-_)<=i.EPSILON*Math.max(1,Math.abs(F),Math.abs(_))}var H=b,ie=A},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 f}),n.d(r,"adjoint",function(){return g}),n.d(r,"determinant",function(){return y}),n.d(r,"multiply",function(){return S}),n.d(r,"translate",function(){return b}),n.d(r,"scale",function(){return I}),n.d(r,"rotate",function(){return N}),n.d(r,"rotateX",function(){return T}),n.d(r,"rotateY",function(){return p}),n.d(r,"rotateZ",function(){return m}),n.d(r,"fromTranslation",function(){return v}),n.d(r,"fromScaling",function(){return M}),n.d(r,"fromRotation",function(){return k}),n.d(r,"fromXRotation",function(){return E}),n.d(r,"fromYRotation",function(){return D}),n.d(r,"fromZRotation",function(){return P}),n.d(r,"fromRotationTranslation",function(){return z}),n.d(r,"fromQuat2",function(){return j}),n.d(r,"getTranslation",function(){return A}),n.d(r,"getScaling",function(){return R}),n.d(r,"getRotation",function(){return L}),n.d(r,"fromRotationTranslationScale",function(){return W}),n.d(r,"fromRotationTranslationScaleOrigin",function(){return Y}),n.d(r,"fromQuat",function(){return H}),n.d(r,"frustum",function(){return ie}),n.d(r,"perspective",function(){return O}),n.d(r,"perspectiveFromFieldOfView",function(){return V}),n.d(r,"ortho",function(){return Z}),n.d(r,"lookAt",function(){return $}),n.d(r,"targetTo",function(){return ee}),n.d(r,"str",function(){return se}),n.d(r,"frob",function(){return ce}),n.d(r,"add",function(){return me}),n.d(r,"subtract",function(){return pe}),n.d(r,"multiplyScalar",function(){return B}),n.d(r,"multiplyScalarAndAdd",function(){return F}),n.d(r,"exactEquals",function(){return J}),n.d(r,"equals",function(){return oe}),n.d(r,"mul",function(){return K}),n.d(r,"sub",function(){return te});var i=n(2);function o(){var w=new i.ARRAY_TYPE(16);return i.ARRAY_TYPE!=Float32Array&&(w[1]=0,w[2]=0,w[3]=0,w[4]=0,w[6]=0,w[7]=0,w[8]=0,w[9]=0,w[11]=0,w[12]=0,w[13]=0,w[14]=0),w[0]=1,w[5]=1,w[10]=1,w[15]=1,w}function a(w){var C=new i.ARRAY_TYPE(16);return C[0]=w[0],C[1]=w[1],C[2]=w[2],C[3]=w[3],C[4]=w[4],C[5]=w[5],C[6]=w[6],C[7]=w[7],C[8]=w[8],C[9]=w[9],C[10]=w[10],C[11]=w[11],C[12]=w[12],C[13]=w[13],C[14]=w[14],C[15]=w[15],C}function c(w,C){return w[0]=C[0],w[1]=C[1],w[2]=C[2],w[3]=C[3],w[4]=C[4],w[5]=C[5],w[6]=C[6],w[7]=C[7],w[8]=C[8],w[9]=C[9],w[10]=C[10],w[11]=C[11],w[12]=C[12],w[13]=C[13],w[14]=C[14],w[15]=C[15],w}function l(w,C,U,G,_,re,ne,X,ae,ue,he,ge,Me,we,be,Ce){var Ie=new i.ARRAY_TYPE(16);return Ie[0]=w,Ie[1]=C,Ie[2]=U,Ie[3]=G,Ie[4]=_,Ie[5]=re,Ie[6]=ne,Ie[7]=X,Ie[8]=ae,Ie[9]=ue,Ie[10]=he,Ie[11]=ge,Ie[12]=Me,Ie[13]=we,Ie[14]=be,Ie[15]=Ce,Ie}function u(w,C,U,G,_,re,ne,X,ae,ue,he,ge,Me,we,be,Ce,Ie){return w[0]=C,w[1]=U,w[2]=G,w[3]=_,w[4]=re,w[5]=ne,w[6]=X,w[7]=ae,w[8]=ue,w[9]=he,w[10]=ge,w[11]=Me,w[12]=we,w[13]=be,w[14]=Ce,w[15]=Ie,w}function h(w){return w[0]=1,w[1]=0,w[2]=0,w[3]=0,w[4]=0,w[5]=1,w[6]=0,w[7]=0,w[8]=0,w[9]=0,w[10]=1,w[11]=0,w[12]=0,w[13]=0,w[14]=0,w[15]=1,w}function d(w,C){if(w===C){var U=C[1],G=C[2],_=C[3],re=C[6],ne=C[7],X=C[11];w[1]=C[4],w[2]=C[8],w[3]=C[12],w[4]=U,w[6]=C[9],w[7]=C[13],w[8]=G,w[9]=re,w[11]=C[14],w[12]=_,w[13]=ne,w[14]=X}else w[0]=C[0],w[1]=C[4],w[2]=C[8],w[3]=C[12],w[4]=C[1],w[5]=C[5],w[6]=C[9],w[7]=C[13],w[8]=C[2],w[9]=C[6],w[10]=C[10],w[11]=C[14],w[12]=C[3],w[13]=C[7],w[14]=C[11],w[15]=C[15];return w}function f(w,C){var U=C[0],G=C[1],_=C[2],re=C[3],ne=C[4],X=C[5],ae=C[6],ue=C[7],he=C[8],ge=C[9],Me=C[10],we=C[11],be=C[12],Ce=C[13],Ie=C[14],Ae=C[15],Ee=U*X-G*ne,ke=U*ae-_*ne,Ne=U*ue-re*ne,Oe=G*ae-_*X,je=G*ue-re*X,Je=_*ue-re*ae,rt=he*Ce-ge*be,et=he*Ie-Me*be,nt=he*Ae-we*be,Qe=ge*Ie-Me*Ce,st=ge*Ae-we*Ce,ut=Me*Ae-we*Ie,Ke=Ee*ut-ke*st+Ne*Qe+Oe*nt-je*et+Je*rt;return Ke?(Ke=1/Ke,w[0]=(X*ut-ae*st+ue*Qe)*Ke,w[1]=(_*st-G*ut-re*Qe)*Ke,w[2]=(Ce*Je-Ie*je+Ae*Oe)*Ke,w[3]=(Me*je-ge*Je-we*Oe)*Ke,w[4]=(ae*nt-ne*ut-ue*et)*Ke,w[5]=(U*ut-_*nt+re*et)*Ke,w[6]=(Ie*Ne-be*Je-Ae*ke)*Ke,w[7]=(he*Je-Me*Ne+we*ke)*Ke,w[8]=(ne*st-X*nt+ue*rt)*Ke,w[9]=(G*nt-U*st-re*rt)*Ke,w[10]=(be*je-Ce*Ne+Ae*Ee)*Ke,w[11]=(ge*Ne-he*je-we*Ee)*Ke,w[12]=(X*et-ne*Qe-ae*rt)*Ke,w[13]=(U*Qe-G*et+_*rt)*Ke,w[14]=(Ce*ke-be*Oe-Ie*Ee)*Ke,w[15]=(he*Oe-ge*ke+Me*Ee)*Ke,w):null}function g(w,C){var U=C[0],G=C[1],_=C[2],re=C[3],ne=C[4],X=C[5],ae=C[6],ue=C[7],he=C[8],ge=C[9],Me=C[10],we=C[11],be=C[12],Ce=C[13],Ie=C[14],Ae=C[15];return w[0]=X*(Me*Ae-we*Ie)-ge*(ae*Ae-ue*Ie)+Ce*(ae*we-ue*Me),w[1]=-(G*(Me*Ae-we*Ie)-ge*(_*Ae-re*Ie)+Ce*(_*we-re*Me)),w[2]=G*(ae*Ae-ue*Ie)-X*(_*Ae-re*Ie)+Ce*(_*ue-re*ae),w[3]=-(G*(ae*we-ue*Me)-X*(_*we-re*Me)+ge*(_*ue-re*ae)),w[4]=-(ne*(Me*Ae-we*Ie)-he*(ae*Ae-ue*Ie)+be*(ae*we-ue*Me)),w[5]=U*(Me*Ae-we*Ie)-he*(_*Ae-re*Ie)+be*(_*we-re*Me),w[6]=-(U*(ae*Ae-ue*Ie)-ne*(_*Ae-re*Ie)+be*(_*ue-re*ae)),w[7]=U*(ae*we-ue*Me)-ne*(_*we-re*Me)+he*(_*ue-re*ae),w[8]=ne*(ge*Ae-we*Ce)-he*(X*Ae-ue*Ce)+be*(X*we-ue*ge),w[9]=-(U*(ge*Ae-we*Ce)-he*(G*Ae-re*Ce)+be*(G*we-re*ge)),w[10]=U*(X*Ae-ue*Ce)-ne*(G*Ae-re*Ce)+be*(G*ue-re*X),w[11]=-(U*(X*we-ue*ge)-ne*(G*we-re*ge)+he*(G*ue-re*X)),w[12]=-(ne*(ge*Ie-Me*Ce)-he*(X*Ie-ae*Ce)+be*(X*Me-ae*ge)),w[13]=U*(ge*Ie-Me*Ce)-he*(G*Ie-_*Ce)+be*(G*Me-_*ge),w[14]=-(U*(X*Ie-ae*Ce)-ne*(G*Ie-_*Ce)+be*(G*ae-_*X)),w[15]=U*(X*Me-ae*ge)-ne*(G*Me-_*ge)+he*(G*ae-_*X),w}function y(w){var C=w[0],U=w[1],G=w[2],_=w[3],re=w[4],ne=w[5],X=w[6],ae=w[7],ue=w[8],he=w[9],ge=w[10],Me=w[11],we=w[12],be=w[13],Ce=w[14],Ie=w[15],Ae=C*ne-U*re,Ee=C*X-G*re,ke=C*ae-_*re,Ne=U*X-G*ne,Oe=U*ae-_*ne,je=G*ae-_*X,Je=ue*be-he*we,rt=ue*Ce-ge*we,et=ue*Ie-Me*we,nt=he*Ce-ge*be,Qe=he*Ie-Me*be,st=ge*Ie-Me*Ce;return Ae*st-Ee*Qe+ke*nt+Ne*et-Oe*rt+je*Je}function S(w,C,U){var G=C[0],_=C[1],re=C[2],ne=C[3],X=C[4],ae=C[5],ue=C[6],he=C[7],ge=C[8],Me=C[9],we=C[10],be=C[11],Ce=C[12],Ie=C[13],Ae=C[14],Ee=C[15],ke=U[0],Ne=U[1],Oe=U[2],je=U[3];return w[0]=ke*G+Ne*X+Oe*ge+je*Ce,w[1]=ke*_+Ne*ae+Oe*Me+je*Ie,w[2]=ke*re+Ne*ue+Oe*we+je*Ae,w[3]=ke*ne+Ne*he+Oe*be+je*Ee,ke=U[4],Ne=U[5],Oe=U[6],je=U[7],w[4]=ke*G+Ne*X+Oe*ge+je*Ce,w[5]=ke*_+Ne*ae+Oe*Me+je*Ie,w[6]=ke*re+Ne*ue+Oe*we+je*Ae,w[7]=ke*ne+Ne*he+Oe*be+je*Ee,ke=U[8],Ne=U[9],Oe=U[10],je=U[11],w[8]=ke*G+Ne*X+Oe*ge+je*Ce,w[9]=ke*_+Ne*ae+Oe*Me+je*Ie,w[10]=ke*re+Ne*ue+Oe*we+je*Ae,w[11]=ke*ne+Ne*he+Oe*be+je*Ee,ke=U[12],Ne=U[13],Oe=U[14],je=U[15],w[12]=ke*G+Ne*X+Oe*ge+je*Ce,w[13]=ke*_+Ne*ae+Oe*Me+je*Ie,w[14]=ke*re+Ne*ue+Oe*we+je*Ae,w[15]=ke*ne+Ne*he+Oe*be+je*Ee,w}function b(w,C,U){var G=U[0],_=U[1],re=U[2],ne,X,ae,ue,he,ge,Me,we,be,Ce,Ie,Ae;return C===w?(w[12]=C[0]*G+C[4]*_+C[8]*re+C[12],w[13]=C[1]*G+C[5]*_+C[9]*re+C[13],w[14]=C[2]*G+C[6]*_+C[10]*re+C[14],w[15]=C[3]*G+C[7]*_+C[11]*re+C[15]):(ne=C[0],X=C[1],ae=C[2],ue=C[3],he=C[4],ge=C[5],Me=C[6],we=C[7],be=C[8],Ce=C[9],Ie=C[10],Ae=C[11],w[0]=ne,w[1]=X,w[2]=ae,w[3]=ue,w[4]=he,w[5]=ge,w[6]=Me,w[7]=we,w[8]=be,w[9]=Ce,w[10]=Ie,w[11]=Ae,w[12]=ne*G+he*_+be*re+C[12],w[13]=X*G+ge*_+Ce*re+C[13],w[14]=ae*G+Me*_+Ie*re+C[14],w[15]=ue*G+we*_+Ae*re+C[15]),w}function I(w,C,U){var G=U[0],_=U[1],re=U[2];return w[0]=C[0]*G,w[1]=C[1]*G,w[2]=C[2]*G,w[3]=C[3]*G,w[4]=C[4]*_,w[5]=C[5]*_,w[6]=C[6]*_,w[7]=C[7]*_,w[8]=C[8]*re,w[9]=C[9]*re,w[10]=C[10]*re,w[11]=C[11]*re,w[12]=C[12],w[13]=C[13],w[14]=C[14],w[15]=C[15],w}function N(w,C,U,G){var _=G[0],re=G[1],ne=G[2],X=Math.hypot(_,re,ne),ae,ue,he,ge,Me,we,be,Ce,Ie,Ae,Ee,ke,Ne,Oe,je,Je,rt,et,nt,Qe,st,ut,Ke,Wt;return X<i.EPSILON?null:(X=1/X,_*=X,re*=X,ne*=X,ae=Math.sin(U),ue=Math.cos(U),he=1-ue,ge=C[0],Me=C[1],we=C[2],be=C[3],Ce=C[4],Ie=C[5],Ae=C[6],Ee=C[7],ke=C[8],Ne=C[9],Oe=C[10],je=C[11],Je=_*_*he+ue,rt=re*_*he+ne*ae,et=ne*_*he-re*ae,nt=_*re*he-ne*ae,Qe=re*re*he+ue,st=ne*re*he+_*ae,ut=_*ne*he+re*ae,Ke=re*ne*he-_*ae,Wt=ne*ne*he+ue,w[0]=ge*Je+Ce*rt+ke*et,w[1]=Me*Je+Ie*rt+Ne*et,w[2]=we*Je+Ae*rt+Oe*et,w[3]=be*Je+Ee*rt+je*et,w[4]=ge*nt+Ce*Qe+ke*st,w[5]=Me*nt+Ie*Qe+Ne*st,w[6]=we*nt+Ae*Qe+Oe*st,w[7]=be*nt+Ee*Qe+je*st,w[8]=ge*ut+Ce*Ke+ke*Wt,w[9]=Me*ut+Ie*Ke+Ne*Wt,w[10]=we*ut+Ae*Ke+Oe*Wt,w[11]=be*ut+Ee*Ke+je*Wt,C!==w&&(w[12]=C[12],w[13]=C[13],w[14]=C[14],w[15]=C[15]),w)}function T(w,C,U){var G=Math.sin(U),_=Math.cos(U),re=C[4],ne=C[5],X=C[6],ae=C[7],ue=C[8],he=C[9],ge=C[10],Me=C[11];return C!==w&&(w[0]=C[0],w[1]=C[1],w[2]=C[2],w[3]=C[3],w[12]=C[12],w[13]=C[13],w[14]=C[14],w[15]=C[15]),w[4]=re*_+ue*G,w[5]=ne*_+he*G,w[6]=X*_+ge*G,w[7]=ae*_+Me*G,w[8]=ue*_-re*G,w[9]=he*_-ne*G,w[10]=ge*_-X*G,w[11]=Me*_-ae*G,w}function p(w,C,U){var G=Math.sin(U),_=Math.cos(U),re=C[0],ne=C[1],X=C[2],ae=C[3],ue=C[8],he=C[9],ge=C[10],Me=C[11];return C!==w&&(w[4]=C[4],w[5]=C[5],w[6]=C[6],w[7]=C[7],w[12]=C[12],w[13]=C[13],w[14]=C[14],w[15]=C[15]),w[0]=re*_-ue*G,w[1]=ne*_-he*G,w[2]=X*_-ge*G,w[3]=ae*_-Me*G,w[8]=re*G+ue*_,w[9]=ne*G+he*_,w[10]=X*G+ge*_,w[11]=ae*G+Me*_,w}function m(w,C,U){var G=Math.sin(U),_=Math.cos(U),re=C[0],ne=C[1],X=C[2],ae=C[3],ue=C[4],he=C[5],ge=C[6],Me=C[7];return C!==w&&(w[8]=C[8],w[9]=C[9],w[10]=C[10],w[11]=C[11],w[12]=C[12],w[13]=C[13],w[14]=C[14],w[15]=C[15]),w[0]=re*_+ue*G,w[1]=ne*_+he*G,w[2]=X*_+ge*G,w[3]=ae*_+Me*G,w[4]=ue*_-re*G,w[5]=he*_-ne*G,w[6]=ge*_-X*G,w[7]=Me*_-ae*G,w}function v(w,C){return w[0]=1,w[1]=0,w[2]=0,w[3]=0,w[4]=0,w[5]=1,w[6]=0,w[7]=0,w[8]=0,w[9]=0,w[10]=1,w[11]=0,w[12]=C[0],w[13]=C[1],w[14]=C[2],w[15]=1,w}function M(w,C){return w[0]=C[0],w[1]=0,w[2]=0,w[3]=0,w[4]=0,w[5]=C[1],w[6]=0,w[7]=0,w[8]=0,w[9]=0,w[10]=C[2],w[11]=0,w[12]=0,w[13]=0,w[14]=0,w[15]=1,w}function k(w,C,U){var G=U[0],_=U[1],re=U[2],ne=Math.hypot(G,_,re),X,ae,ue;return ne<i.EPSILON?null:(ne=1/ne,G*=ne,_*=ne,re*=ne,X=Math.sin(C),ae=Math.cos(C),ue=1-ae,w[0]=G*G*ue+ae,w[1]=_*G*ue+re*X,w[2]=re*G*ue-_*X,w[3]=0,w[4]=G*_*ue-re*X,w[5]=_*_*ue+ae,w[6]=re*_*ue+G*X,w[7]=0,w[8]=G*re*ue+_*X,w[9]=_*re*ue-G*X,w[10]=re*re*ue+ae,w[11]=0,w[12]=0,w[13]=0,w[14]=0,w[15]=1,w)}function E(w,C){var U=Math.sin(C),G=Math.cos(C);return w[0]=1,w[1]=0,w[2]=0,w[3]=0,w[4]=0,w[5]=G,w[6]=U,w[7]=0,w[8]=0,w[9]=-U,w[10]=G,w[11]=0,w[12]=0,w[13]=0,w[14]=0,w[15]=1,w}function D(w,C){var U=Math.sin(C),G=Math.cos(C);return w[0]=G,w[1]=0,w[2]=-U,w[3]=0,w[4]=0,w[5]=1,w[6]=0,w[7]=0,w[8]=U,w[9]=0,w[10]=G,w[11]=0,w[12]=0,w[13]=0,w[14]=0,w[15]=1,w}function P(w,C){var U=Math.sin(C),G=Math.cos(C);return w[0]=G,w[1]=U,w[2]=0,w[3]=0,w[4]=-U,w[5]=G,w[6]=0,w[7]=0,w[8]=0,w[9]=0,w[10]=1,w[11]=0,w[12]=0,w[13]=0,w[14]=0,w[15]=1,w}function z(w,C,U){var G=C[0],_=C[1],re=C[2],ne=C[3],X=G+G,ae=_+_,ue=re+re,he=G*X,ge=G*ae,Me=G*ue,we=_*ae,be=_*ue,Ce=re*ue,Ie=ne*X,Ae=ne*ae,Ee=ne*ue;return w[0]=1-(we+Ce),w[1]=ge+Ee,w[2]=Me-Ae,w[3]=0,w[4]=ge-Ee,w[5]=1-(he+Ce),w[6]=be+Ie,w[7]=0,w[8]=Me+Ae,w[9]=be-Ie,w[10]=1-(he+we),w[11]=0,w[12]=U[0],w[13]=U[1],w[14]=U[2],w[15]=1,w}function j(w,C){var U=new i.ARRAY_TYPE(3),G=-C[0],_=-C[1],re=-C[2],ne=C[3],X=C[4],ae=C[5],ue=C[6],he=C[7],ge=G*G+_*_+re*re+ne*ne;return ge>0?(U[0]=(X*ne+he*G+ae*re-ue*_)*2/ge,U[1]=(ae*ne+he*_+ue*G-X*re)*2/ge,U[2]=(ue*ne+he*re+X*_-ae*G)*2/ge):(U[0]=(X*ne+he*G+ae*re-ue*_)*2,U[1]=(ae*ne+he*_+ue*G-X*re)*2,U[2]=(ue*ne+he*re+X*_-ae*G)*2),z(w,C,U),w}function A(w,C){return w[0]=C[12],w[1]=C[13],w[2]=C[14],w}function R(w,C){var U=C[0],G=C[1],_=C[2],re=C[4],ne=C[5],X=C[6],ae=C[8],ue=C[9],he=C[10];return w[0]=Math.hypot(U,G,_),w[1]=Math.hypot(re,ne,X),w[2]=Math.hypot(ae,ue,he),w}function L(w,C){var U=new i.ARRAY_TYPE(3);R(U,C);var G=1/U[0],_=1/U[1],re=1/U[2],ne=C[0]*G,X=C[1]*_,ae=C[2]*re,ue=C[4]*G,he=C[5]*_,ge=C[6]*re,Me=C[8]*G,we=C[9]*_,be=C[10]*re,Ce=ne+he+be,Ie=0;return Ce>0?(Ie=Math.sqrt(Ce+1)*2,w[3]=.25*Ie,w[0]=(ge-we)/Ie,w[1]=(Me-ae)/Ie,w[2]=(X-ue)/Ie):ne>he&&ne>be?(Ie=Math.sqrt(1+ne-he-be)*2,w[3]=(ge-we)/Ie,w[0]=.25*Ie,w[1]=(X+ue)/Ie,w[2]=(Me+ae)/Ie):he>be?(Ie=Math.sqrt(1+he-ne-be)*2,w[3]=(Me-ae)/Ie,w[0]=(X+ue)/Ie,w[1]=.25*Ie,w[2]=(ge+we)/Ie):(Ie=Math.sqrt(1+be-ne-he)*2,w[3]=(X-ue)/Ie,w[0]=(Me+ae)/Ie,w[1]=(ge+we)/Ie,w[2]=.25*Ie),w}function W(w,C,U,G){var _=C[0],re=C[1],ne=C[2],X=C[3],ae=_+_,ue=re+re,he=ne+ne,ge=_*ae,Me=_*ue,we=_*he,be=re*ue,Ce=re*he,Ie=ne*he,Ae=X*ae,Ee=X*ue,ke=X*he,Ne=G[0],Oe=G[1],je=G[2];return w[0]=(1-(be+Ie))*Ne,w[1]=(Me+ke)*Ne,w[2]=(we-Ee)*Ne,w[3]=0,w[4]=(Me-ke)*Oe,w[5]=(1-(ge+Ie))*Oe,w[6]=(Ce+Ae)*Oe,w[7]=0,w[8]=(we+Ee)*je,w[9]=(Ce-Ae)*je,w[10]=(1-(ge+be))*je,w[11]=0,w[12]=U[0],w[13]=U[1],w[14]=U[2],w[15]=1,w}function Y(w,C,U,G,_){var re=C[0],ne=C[1],X=C[2],ae=C[3],ue=re+re,he=ne+ne,ge=X+X,Me=re*ue,we=re*he,be=re*ge,Ce=ne*he,Ie=ne*ge,Ae=X*ge,Ee=ae*ue,ke=ae*he,Ne=ae*ge,Oe=G[0],je=G[1],Je=G[2],rt=_[0],et=_[1],nt=_[2],Qe=(1-(Ce+Ae))*Oe,st=(we+Ne)*Oe,ut=(be-ke)*Oe,Ke=(we-Ne)*je,Wt=(1-(Me+Ae))*je,Br=(Ie+Ee)*je,jr=(be+ke)*Je,vi=(Ie-Ee)*Je,yo=(1-(Me+Ce))*Je;return w[0]=Qe,w[1]=st,w[2]=ut,w[3]=0,w[4]=Ke,w[5]=Wt,w[6]=Br,w[7]=0,w[8]=jr,w[9]=vi,w[10]=yo,w[11]=0,w[12]=U[0]+rt-(Qe*rt+Ke*et+jr*nt),w[13]=U[1]+et-(st*rt+Wt*et+vi*nt),w[14]=U[2]+nt-(ut*rt+Br*et+yo*nt),w[15]=1,w}function H(w,C){var U=C[0],G=C[1],_=C[2],re=C[3],ne=U+U,X=G+G,ae=_+_,ue=U*ne,he=G*ne,ge=G*X,Me=_*ne,we=_*X,be=_*ae,Ce=re*ne,Ie=re*X,Ae=re*ae;return w[0]=1-ge-be,w[1]=he+Ae,w[2]=Me-Ie,w[3]=0,w[4]=he-Ae,w[5]=1-ue-be,w[6]=we+Ce,w[7]=0,w[8]=Me+Ie,w[9]=we-Ce,w[10]=1-ue-ge,w[11]=0,w[12]=0,w[13]=0,w[14]=0,w[15]=1,w}function ie(w,C,U,G,_,re,ne){var X=1/(U-C),ae=1/(_-G),ue=1/(re-ne);return w[0]=re*2*X,w[1]=0,w[2]=0,w[3]=0,w[4]=0,w[5]=re*2*ae,w[6]=0,w[7]=0,w[8]=(U+C)*X,w[9]=(_+G)*ae,w[10]=(ne+re)*ue,w[11]=-1,w[12]=0,w[13]=0,w[14]=ne*re*2*ue,w[15]=0,w}function O(w,C,U,G,_){var re=1/Math.tan(C/2),ne;return w[0]=re/U,w[1]=0,w[2]=0,w[3]=0,w[4]=0,w[5]=re,w[6]=0,w[7]=0,w[8]=0,w[9]=0,w[11]=-1,w[12]=0,w[13]=0,w[15]=0,_!=null&&_!==1/0?(ne=1/(G-_),w[10]=(_+G)*ne,w[14]=2*_*G*ne):(w[10]=-1,w[14]=-2*G),w}function V(w,C,U,G){var _=Math.tan(C.upDegrees*Math.PI/180),re=Math.tan(C.downDegrees*Math.PI/180),ne=Math.tan(C.leftDegrees*Math.PI/180),X=Math.tan(C.rightDegrees*Math.PI/180),ae=2/(ne+X),ue=2/(_+re);return w[0]=ae,w[1]=0,w[2]=0,w[3]=0,w[4]=0,w[5]=ue,w[6]=0,w[7]=0,w[8]=-((ne-X)*ae*.5),w[9]=(_-re)*ue*.5,w[10]=G/(U-G),w[11]=-1,w[12]=0,w[13]=0,w[14]=G*U/(U-G),w[15]=0,w}function Z(w,C,U,G,_,re,ne){var X=1/(C-U),ae=1/(G-_),ue=1/(re-ne);return w[0]=-2*X,w[1]=0,w[2]=0,w[3]=0,w[4]=0,w[5]=-2*ae,w[6]=0,w[7]=0,w[8]=0,w[9]=0,w[10]=2*ue,w[11]=0,w[12]=(C+U)*X,w[13]=(_+G)*ae,w[14]=(ne+re)*ue,w[15]=1,w}function $(w,C,U,G){var _,re,ne,X,ae,ue,he,ge,Me,we,be=C[0],Ce=C[1],Ie=C[2],Ae=G[0],Ee=G[1],ke=G[2],Ne=U[0],Oe=U[1],je=U[2];return Math.abs(be-Ne)<i.EPSILON&&Math.abs(Ce-Oe)<i.EPSILON&&Math.abs(Ie-je)<i.EPSILON?h(w):(he=be-Ne,ge=Ce-Oe,Me=Ie-je,we=1/Math.hypot(he,ge,Me),he*=we,ge*=we,Me*=we,_=Ee*Me-ke*ge,re=ke*he-Ae*Me,ne=Ae*ge-Ee*he,we=Math.hypot(_,re,ne),we?(we=1/we,_*=we,re*=we,ne*=we):(_=0,re=0,ne=0),X=ge*ne-Me*re,ae=Me*_-he*ne,ue=he*re-ge*_,we=Math.hypot(X,ae,ue),we?(we=1/we,X*=we,ae*=we,ue*=we):(X=0,ae=0,ue=0),w[0]=_,w[1]=X,w[2]=he,w[3]=0,w[4]=re,w[5]=ae,w[6]=ge,w[7]=0,w[8]=ne,w[9]=ue,w[10]=Me,w[11]=0,w[12]=-(_*be+re*Ce+ne*Ie),w[13]=-(X*be+ae*Ce+ue*Ie),w[14]=-(he*be+ge*Ce+Me*Ie),w[15]=1,w)}function ee(w,C,U,G){var _=C[0],re=C[1],ne=C[2],X=G[0],ae=G[1],ue=G[2],he=_-U[0],ge=re-U[1],Me=ne-U[2],we=he*he+ge*ge+Me*Me;we>0&&(we=1/Math.sqrt(we),he*=we,ge*=we,Me*=we);var be=ae*Me-ue*ge,Ce=ue*he-X*Me,Ie=X*ge-ae*he;return we=be*be+Ce*Ce+Ie*Ie,we>0&&(we=1/Math.sqrt(we),be*=we,Ce*=we,Ie*=we),w[0]=be,w[1]=Ce,w[2]=Ie,w[3]=0,w[4]=ge*Ie-Me*Ce,w[5]=Me*be-he*Ie,w[6]=he*Ce-ge*be,w[7]=0,w[8]=he,w[9]=ge,w[10]=Me,w[11]=0,w[12]=_,w[13]=re,w[14]=ne,w[15]=1,w}function se(w){return"mat4("+w[0]+", "+w[1]+", "+w[2]+", "+w[3]+", "+w[4]+", "+w[5]+", "+w[6]+", "+w[7]+", "+w[8]+", "+w[9]+", "+w[10]+", "+w[11]+", "+w[12]+", "+w[13]+", "+w[14]+", "+w[15]+")"}function ce(w){return Math.hypot(w[0],w[1],w[2],w[3],w[4],w[5],w[6],w[7],w[8],w[9],w[10],w[11],w[12],w[13],w[14],w[15])}function me(w,C,U){return w[0]=C[0]+U[0],w[1]=C[1]+U[1],w[2]=C[2]+U[2],w[3]=C[3]+U[3],w[4]=C[4]+U[4],w[5]=C[5]+U[5],w[6]=C[6]+U[6],w[7]=C[7]+U[7],w[8]=C[8]+U[8],w[9]=C[9]+U[9],w[10]=C[10]+U[10],w[11]=C[11]+U[11],w[12]=C[12]+U[12],w[13]=C[13]+U[13],w[14]=C[14]+U[14],w[15]=C[15]+U[15],w}function pe(w,C,U){return w[0]=C[0]-U[0],w[1]=C[1]-U[1],w[2]=C[2]-U[2],w[3]=C[3]-U[3],w[4]=C[4]-U[4],w[5]=C[5]-U[5],w[6]=C[6]-U[6],w[7]=C[7]-U[7],w[8]=C[8]-U[8],w[9]=C[9]-U[9],w[10]=C[10]-U[10],w[11]=C[11]-U[11],w[12]=C[12]-U[12],w[13]=C[13]-U[13],w[14]=C[14]-U[14],w[15]=C[15]-U[15],w}function B(w,C,U){return w[0]=C[0]*U,w[1]=C[1]*U,w[2]=C[2]*U,w[3]=C[3]*U,w[4]=C[4]*U,w[5]=C[5]*U,w[6]=C[6]*U,w[7]=C[7]*U,w[8]=C[8]*U,w[9]=C[9]*U,w[10]=C[10]*U,w[11]=C[11]*U,w[12]=C[12]*U,w[13]=C[13]*U,w[14]=C[14]*U,w[15]=C[15]*U,w}function F(w,C,U,G){return w[0]=C[0]+U[0]*G,w[1]=C[1]+U[1]*G,w[2]=C[2]+U[2]*G,w[3]=C[3]+U[3]*G,w[4]=C[4]+U[4]*G,w[5]=C[5]+U[5]*G,w[6]=C[6]+U[6]*G,w[7]=C[7]+U[7]*G,w[8]=C[8]+U[8]*G,w[9]=C[9]+U[9]*G,w[10]=C[10]+U[10]*G,w[11]=C[11]+U[11]*G,w[12]=C[12]+U[12]*G,w[13]=C[13]+U[13]*G,w[14]=C[14]+U[14]*G,w[15]=C[15]+U[15]*G,w}function J(w,C){return w[0]===C[0]&&w[1]===C[1]&&w[2]===C[2]&&w[3]===C[3]&&w[4]===C[4]&&w[5]===C[5]&&w[6]===C[6]&&w[7]===C[7]&&w[8]===C[8]&&w[9]===C[9]&&w[10]===C[10]&&w[11]===C[11]&&w[12]===C[12]&&w[13]===C[13]&&w[14]===C[14]&&w[15]===C[15]}function oe(w,C){var U=w[0],G=w[1],_=w[2],re=w[3],ne=w[4],X=w[5],ae=w[6],ue=w[7],he=w[8],ge=w[9],Me=w[10],we=w[11],be=w[12],Ce=w[13],Ie=w[14],Ae=w[15],Ee=C[0],ke=C[1],Ne=C[2],Oe=C[3],je=C[4],Je=C[5],rt=C[6],et=C[7],nt=C[8],Qe=C[9],st=C[10],ut=C[11],Ke=C[12],Wt=C[13],Br=C[14],jr=C[15];return Math.abs(U-Ee)<=i.EPSILON*Math.max(1,Math.abs(U),Math.abs(Ee))&&Math.abs(G-ke)<=i.EPSILON*Math.max(1,Math.abs(G),Math.abs(ke))&&Math.abs(_-Ne)<=i.EPSILON*Math.max(1,Math.abs(_),Math.abs(Ne))&&Math.abs(re-Oe)<=i.EPSILON*Math.max(1,Math.abs(re),Math.abs(Oe))&&Math.abs(ne-je)<=i.EPSILON*Math.max(1,Math.abs(ne),Math.abs(je))&&Math.abs(X-Je)<=i.EPSILON*Math.max(1,Math.abs(X),Math.abs(Je))&&Math.abs(ae-rt)<=i.EPSILON*Math.max(1,Math.abs(ae),Math.abs(rt))&&Math.abs(ue-et)<=i.EPSILON*Math.max(1,Math.abs(ue),Math.abs(et))&&Math.abs(he-nt)<=i.EPSILON*Math.max(1,Math.abs(he),Math.abs(nt))&&Math.abs(ge-Qe)<=i.EPSILON*Math.max(1,Math.abs(ge),Math.abs(Qe))&&Math.abs(Me-st)<=i.EPSILON*Math.max(1,Math.abs(Me),Math.abs(st))&&Math.abs(we-ut)<=i.EPSILON*Math.max(1,Math.abs(we),Math.abs(ut))&&Math.abs(be-Ke)<=i.EPSILON*Math.max(1,Math.abs(be),Math.abs(Ke))&&Math.abs(Ce-Wt)<=i.EPSILON*Math.max(1,Math.abs(Ce),Math.abs(Wt))&&Math.abs(Ie-Br)<=i.EPSILON*Math.max(1,Math.abs(Ie),Math.abs(Br))&&Math.abs(Ae-jr)<=i.EPSILON*Math.max(1,Math.abs(Ae),Math.abs(jr))}var K=S,te=pe},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 f}),n.d(r,"multiply",function(){return g}),n.d(r,"rotateX",function(){return y}),n.d(r,"rotateY",function(){return S}),n.d(r,"rotateZ",function(){return b}),n.d(r,"calculateW",function(){return I}),n.d(r,"exp",function(){return N}),n.d(r,"ln",function(){return T}),n.d(r,"pow",function(){return p}),n.d(r,"slerp",function(){return m}),n.d(r,"random",function(){return v}),n.d(r,"invert",function(){return M}),n.d(r,"conjugate",function(){return k}),n.d(r,"fromMat3",function(){return E}),n.d(r,"fromEuler",function(){return D}),n.d(r,"str",function(){return P}),n.d(r,"clone",function(){return z}),n.d(r,"fromValues",function(){return j}),n.d(r,"copy",function(){return A}),n.d(r,"set",function(){return R}),n.d(r,"add",function(){return L}),n.d(r,"mul",function(){return W}),n.d(r,"scale",function(){return Y}),n.d(r,"dot",function(){return H}),n.d(r,"lerp",function(){return ie}),n.d(r,"length",function(){return O}),n.d(r,"len",function(){return V}),n.d(r,"squaredLength",function(){return Z}),n.d(r,"sqrLen",function(){return $}),n.d(r,"normalize",function(){return ee}),n.d(r,"exactEquals",function(){return se}),n.d(r,"equals",function(){return ce}),n.d(r,"rotationTo",function(){return me}),n.d(r,"sqlerp",function(){return pe}),n.d(r,"setAxes",function(){return B});var i=n(2),o=n(5),a=n(8),c=n(9);function l(){var F=new i.ARRAY_TYPE(4);return i.ARRAY_TYPE!=Float32Array&&(F[0]=0,F[1]=0,F[2]=0),F[3]=1,F}function u(F){return F[0]=0,F[1]=0,F[2]=0,F[3]=1,F}function h(F,J,oe){oe=oe*.5;var K=Math.sin(oe);return F[0]=K*J[0],F[1]=K*J[1],F[2]=K*J[2],F[3]=Math.cos(oe),F}function d(F,J){var oe=Math.acos(J[3])*2,K=Math.sin(oe/2);return K>i.EPSILON?(F[0]=J[0]/K,F[1]=J[1]/K,F[2]=J[2]/K):(F[0]=1,F[1]=0,F[2]=0),oe}function f(F,J){var oe=H(F,J);return Math.acos(2*oe*oe-1)}function g(F,J,oe){var K=J[0],te=J[1],w=J[2],C=J[3],U=oe[0],G=oe[1],_=oe[2],re=oe[3];return F[0]=K*re+C*U+te*_-w*G,F[1]=te*re+C*G+w*U-K*_,F[2]=w*re+C*_+K*G-te*U,F[3]=C*re-K*U-te*G-w*_,F}function y(F,J,oe){oe*=.5;var K=J[0],te=J[1],w=J[2],C=J[3],U=Math.sin(oe),G=Math.cos(oe);return F[0]=K*G+C*U,F[1]=te*G+w*U,F[2]=w*G-te*U,F[3]=C*G-K*U,F}function S(F,J,oe){oe*=.5;var K=J[0],te=J[1],w=J[2],C=J[3],U=Math.sin(oe),G=Math.cos(oe);return F[0]=K*G-w*U,F[1]=te*G+C*U,F[2]=w*G+K*U,F[3]=C*G-te*U,F}function b(F,J,oe){oe*=.5;var K=J[0],te=J[1],w=J[2],C=J[3],U=Math.sin(oe),G=Math.cos(oe);return F[0]=K*G+te*U,F[1]=te*G-K*U,F[2]=w*G+C*U,F[3]=C*G-w*U,F}function I(F,J){var oe=J[0],K=J[1],te=J[2];return F[0]=oe,F[1]=K,F[2]=te,F[3]=Math.sqrt(Math.abs(1-oe*oe-K*K-te*te)),F}function N(F,J){var oe=J[0],K=J[1],te=J[2],w=J[3],C=Math.sqrt(oe*oe+K*K+te*te),U=Math.exp(w),G=C>0?U*Math.sin(C)/C:0;return F[0]=oe*G,F[1]=K*G,F[2]=te*G,F[3]=U*Math.cos(C),F}function T(F,J){var oe=J[0],K=J[1],te=J[2],w=J[3],C=Math.sqrt(oe*oe+K*K+te*te),U=C>0?Math.atan2(C,w)/C:0;return F[0]=oe*U,F[1]=K*U,F[2]=te*U,F[3]=.5*Math.log(oe*oe+K*K+te*te+w*w),F}function p(F,J,oe){return T(F,J),Y(F,F,oe),N(F,F),F}function m(F,J,oe,K){var te=J[0],w=J[1],C=J[2],U=J[3],G=oe[0],_=oe[1],re=oe[2],ne=oe[3],X,ae,ue,he,ge;return ae=te*G+w*_+C*re+U*ne,ae<0&&(ae=-ae,G=-G,_=-_,re=-re,ne=-ne),1-ae>i.EPSILON?(X=Math.acos(ae),ue=Math.sin(X),he=Math.sin((1-K)*X)/ue,ge=Math.sin(K*X)/ue):(he=1-K,ge=K),F[0]=he*te+ge*G,F[1]=he*w+ge*_,F[2]=he*C+ge*re,F[3]=he*U+ge*ne,F}function v(F){var J=i.RANDOM(),oe=i.RANDOM(),K=i.RANDOM(),te=Math.sqrt(1-J),w=Math.sqrt(J);return F[0]=te*Math.sin(2*Math.PI*oe),F[1]=te*Math.cos(2*Math.PI*oe),F[2]=w*Math.sin(2*Math.PI*K),F[3]=w*Math.cos(2*Math.PI*K),F}function M(F,J){var oe=J[0],K=J[1],te=J[2],w=J[3],C=oe*oe+K*K+te*te+w*w,U=C?1/C:0;return F[0]=-oe*U,F[1]=-K*U,F[2]=-te*U,F[3]=w*U,F}function k(F,J){return F[0]=-J[0],F[1]=-J[1],F[2]=-J[2],F[3]=J[3],F}function E(F,J){var oe=J[0]+J[4]+J[8],K;if(oe>0)K=Math.sqrt(oe+1),F[3]=.5*K,K=.5/K,F[0]=(J[5]-J[7])*K,F[1]=(J[6]-J[2])*K,F[2]=(J[1]-J[3])*K;else{var te=0;J[4]>J[0]&&(te=1),J[8]>J[te*3+te]&&(te=2);var w=(te+1)%3,C=(te+2)%3;K=Math.sqrt(J[te*3+te]-J[w*3+w]-J[C*3+C]+1),F[te]=.5*K,K=.5/K,F[3]=(J[w*3+C]-J[C*3+w])*K,F[w]=(J[w*3+te]+J[te*3+w])*K,F[C]=(J[C*3+te]+J[te*3+C])*K}return F}function D(F,J,oe,K){var te=.5*Math.PI/180;J*=te,oe*=te,K*=te;var w=Math.sin(J),C=Math.cos(J),U=Math.sin(oe),G=Math.cos(oe),_=Math.sin(K),re=Math.cos(K);return F[0]=w*G*re-C*U*_,F[1]=C*U*re+w*G*_,F[2]=C*G*_-w*U*re,F[3]=C*G*re+w*U*_,F}function P(F){return"quat("+F[0]+", "+F[1]+", "+F[2]+", "+F[3]+")"}var z=c.clone,j=c.fromValues,A=c.copy,R=c.set,L=c.add,W=g,Y=c.scale,H=c.dot,ie=c.lerp,O=c.length,V=O,Z=c.squaredLength,$=Z,ee=c.normalize,se=c.exactEquals,ce=c.equals,me=function(){var F=a.create(),J=a.fromValues(1,0,0),oe=a.fromValues(0,1,0);return function(K,te,w){var C=a.dot(te,w);return C<-.999999?(a.cross(F,J,te),a.len(F)<1e-6&&a.cross(F,oe,te),a.normalize(F,F),h(K,F,Math.PI),K):C>.999999?(K[0]=0,K[1]=0,K[2]=0,K[3]=1,K):(a.cross(F,te,w),K[0]=F[0],K[1]=F[1],K[2]=F[2],K[3]=1+C,ee(K,K))}}(),pe=function(){var F=l(),J=l();return function(oe,K,te,w,C,U){return m(F,K,C,U),m(J,te,w,U),m(oe,F,J,2*U*(1-U)),oe}}(),B=function(){var F=o.create();return function(J,oe,K,te){return F[0]=K[0],F[3]=K[1],F[6]=K[2],F[1]=te[0],F[4]=te[1],F[7]=te[2],F[2]=-oe[0],F[5]=-oe[1],F[8]=-oe[2],ee(J,E(J,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,"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 f}),n.d(r,"multiply",function(){return g}),n.d(r,"divide",function(){return y}),n.d(r,"ceil",function(){return S}),n.d(r,"floor",function(){return b}),n.d(r,"min",function(){return I}),n.d(r,"max",function(){return N}),n.d(r,"round",function(){return T}),n.d(r,"scale",function(){return p}),n.d(r,"scaleAndAdd",function(){return m}),n.d(r,"distance",function(){return v}),n.d(r,"squaredDistance",function(){return M}),n.d(r,"squaredLength",function(){return k}),n.d(r,"negate",function(){return E}),n.d(r,"inverse",function(){return D}),n.d(r,"normalize",function(){return P}),n.d(r,"dot",function(){return z}),n.d(r,"cross",function(){return j}),n.d(r,"lerp",function(){return A}),n.d(r,"hermite",function(){return R}),n.d(r,"bezier",function(){return L}),n.d(r,"random",function(){return W}),n.d(r,"transformMat4",function(){return Y}),n.d(r,"transformMat3",function(){return H}),n.d(r,"transformQuat",function(){return ie}),n.d(r,"rotateX",function(){return O}),n.d(r,"rotateY",function(){return V}),n.d(r,"rotateZ",function(){return Z}),n.d(r,"angle",function(){return $}),n.d(r,"zero",function(){return ee}),n.d(r,"str",function(){return se}),n.d(r,"exactEquals",function(){return ce}),n.d(r,"equals",function(){return me}),n.d(r,"sub",function(){return pe}),n.d(r,"mul",function(){return B}),n.d(r,"div",function(){return F}),n.d(r,"dist",function(){return J}),n.d(r,"sqrDist",function(){return oe}),n.d(r,"len",function(){return K}),n.d(r,"sqrLen",function(){return te}),n.d(r,"forEach",function(){return w});var i=n(2);function o(){var C=new i.ARRAY_TYPE(3);return i.ARRAY_TYPE!=Float32Array&&(C[0]=0,C[1]=0,C[2]=0),C}function a(C){var U=new i.ARRAY_TYPE(3);return U[0]=C[0],U[1]=C[1],U[2]=C[2],U}function c(C){var U=C[0],G=C[1],_=C[2];return Math.hypot(U,G,_)}function l(C,U,G){var _=new i.ARRAY_TYPE(3);return _[0]=C,_[1]=U,_[2]=G,_}function u(C,U){return C[0]=U[0],C[1]=U[1],C[2]=U[2],C}function h(C,U,G,_){return C[0]=U,C[1]=G,C[2]=_,C}function d(C,U,G){return C[0]=U[0]+G[0],C[1]=U[1]+G[1],C[2]=U[2]+G[2],C}function f(C,U,G){return C[0]=U[0]-G[0],C[1]=U[1]-G[1],C[2]=U[2]-G[2],C}function g(C,U,G){return C[0]=U[0]*G[0],C[1]=U[1]*G[1],C[2]=U[2]*G[2],C}function y(C,U,G){return C[0]=U[0]/G[0],C[1]=U[1]/G[1],C[2]=U[2]/G[2],C}function S(C,U){return C[0]=Math.ceil(U[0]),C[1]=Math.ceil(U[1]),C[2]=Math.ceil(U[2]),C}function b(C,U){return C[0]=Math.floor(U[0]),C[1]=Math.floor(U[1]),C[2]=Math.floor(U[2]),C}function I(C,U,G){return C[0]=Math.min(U[0],G[0]),C[1]=Math.min(U[1],G[1]),C[2]=Math.min(U[2],G[2]),C}function N(C,U,G){return C[0]=Math.max(U[0],G[0]),C[1]=Math.max(U[1],G[1]),C[2]=Math.max(U[2],G[2]),C}function T(C,U){return C[0]=Math.round(U[0]),C[1]=Math.round(U[1]),C[2]=Math.round(U[2]),C}function p(C,U,G){return C[0]=U[0]*G,C[1]=U[1]*G,C[2]=U[2]*G,C}function m(C,U,G,_){return C[0]=U[0]+G[0]*_,C[1]=U[1]+G[1]*_,C[2]=U[2]+G[2]*_,C}function v(C,U){var G=U[0]-C[0],_=U[1]-C[1],re=U[2]-C[2];return Math.hypot(G,_,re)}function M(C,U){var G=U[0]-C[0],_=U[1]-C[1],re=U[2]-C[2];return G*G+_*_+re*re}function k(C){var U=C[0],G=C[1],_=C[2];return U*U+G*G+_*_}function E(C,U){return C[0]=-U[0],C[1]=-U[1],C[2]=-U[2],C}function D(C,U){return C[0]=1/U[0],C[1]=1/U[1],C[2]=1/U[2],C}function P(C,U){var G=U[0],_=U[1],re=U[2],ne=G*G+_*_+re*re;return ne>0&&(ne=1/Math.sqrt(ne)),C[0]=U[0]*ne,C[1]=U[1]*ne,C[2]=U[2]*ne,C}function z(C,U){return C[0]*U[0]+C[1]*U[1]+C[2]*U[2]}function j(C,U,G){var _=U[0],re=U[1],ne=U[2],X=G[0],ae=G[1],ue=G[2];return C[0]=re*ue-ne*ae,C[1]=ne*X-_*ue,C[2]=_*ae-re*X,C}function A(C,U,G,_){var re=U[0],ne=U[1],X=U[2];return C[0]=re+_*(G[0]-re),C[1]=ne+_*(G[1]-ne),C[2]=X+_*(G[2]-X),C}function R(C,U,G,_,re,ne){var X=ne*ne,ae=X*(2*ne-3)+1,ue=X*(ne-2)+ne,he=X*(ne-1),ge=X*(3-2*ne);return C[0]=U[0]*ae+G[0]*ue+_[0]*he+re[0]*ge,C[1]=U[1]*ae+G[1]*ue+_[1]*he+re[1]*ge,C[2]=U[2]*ae+G[2]*ue+_[2]*he+re[2]*ge,C}function L(C,U,G,_,re,ne){var X=1-ne,ae=X*X,ue=ne*ne,he=ae*X,ge=3*ne*ae,Me=3*ue*X,we=ue*ne;return C[0]=U[0]*he+G[0]*ge+_[0]*Me+re[0]*we,C[1]=U[1]*he+G[1]*ge+_[1]*Me+re[1]*we,C[2]=U[2]*he+G[2]*ge+_[2]*Me+re[2]*we,C}function W(C,U){U=U||1;var G=i.RANDOM()*2*Math.PI,_=i.RANDOM()*2-1,re=Math.sqrt(1-_*_)*U;return C[0]=Math.cos(G)*re,C[1]=Math.sin(G)*re,C[2]=_*U,C}function Y(C,U,G){var _=U[0],re=U[1],ne=U[2],X=G[3]*_+G[7]*re+G[11]*ne+G[15];return X=X||1,C[0]=(G[0]*_+G[4]*re+G[8]*ne+G[12])/X,C[1]=(G[1]*_+G[5]*re+G[9]*ne+G[13])/X,C[2]=(G[2]*_+G[6]*re+G[10]*ne+G[14])/X,C}function H(C,U,G){var _=U[0],re=U[1],ne=U[2];return C[0]=_*G[0]+re*G[3]+ne*G[6],C[1]=_*G[1]+re*G[4]+ne*G[7],C[2]=_*G[2]+re*G[5]+ne*G[8],C}function ie(C,U,G){var _=G[0],re=G[1],ne=G[2],X=G[3],ae=U[0],ue=U[1],he=U[2],ge=re*he-ne*ue,Me=ne*ae-_*he,we=_*ue-re*ae,be=re*we-ne*Me,Ce=ne*ge-_*we,Ie=_*Me-re*ge,Ae=X*2;return ge*=Ae,Me*=Ae,we*=Ae,be*=2,Ce*=2,Ie*=2,C[0]=ae+ge+be,C[1]=ue+Me+Ce,C[2]=he+we+Ie,C}function O(C,U,G,_){var re=[],ne=[];return re[0]=U[0]-G[0],re[1]=U[1]-G[1],re[2]=U[2]-G[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(_),C[0]=ne[0]+G[0],C[1]=ne[1]+G[1],C[2]=ne[2]+G[2],C}function V(C,U,G,_){var re=[],ne=[];return re[0]=U[0]-G[0],re[1]=U[1]-G[1],re[2]=U[2]-G[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(_),C[0]=ne[0]+G[0],C[1]=ne[1]+G[1],C[2]=ne[2]+G[2],C}function Z(C,U,G,_){var re=[],ne=[];return re[0]=U[0]-G[0],re[1]=U[1]-G[1],re[2]=U[2]-G[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],C[0]=ne[0]+G[0],C[1]=ne[1]+G[1],C[2]=ne[2]+G[2],C}function $(C,U){var G=C[0],_=C[1],re=C[2],ne=U[0],X=U[1],ae=U[2],ue=Math.sqrt(G*G+_*_+re*re),he=Math.sqrt(ne*ne+X*X+ae*ae),ge=ue*he,Me=ge&&z(C,U)/ge;return Math.acos(Math.min(Math.max(Me,-1),1))}function ee(C){return C[0]=0,C[1]=0,C[2]=0,C}function se(C){return"vec3("+C[0]+", "+C[1]+", "+C[2]+")"}function ce(C,U){return C[0]===U[0]&&C[1]===U[1]&&C[2]===U[2]}function me(C,U){var G=C[0],_=C[1],re=C[2],ne=U[0],X=U[1],ae=U[2];return Math.abs(G-ne)<=i.EPSILON*Math.max(1,Math.abs(G),Math.abs(ne))&&Math.abs(_-X)<=i.EPSILON*Math.max(1,Math.abs(_),Math.abs(X))&&Math.abs(re-ae)<=i.EPSILON*Math.max(1,Math.abs(re),Math.abs(ae))}var pe=f,B=g,F=y,J=v,oe=M,K=c,te=k,w=function(){var C=o();return function(U,G,_,re,ne,X){var ae,ue;for(G||(G=3),_||(_=0),re?ue=Math.min(re*G+_,U.length):ue=U.length,ae=_;ae<ue;ae+=G)C[0]=U[ae],C[1]=U[ae+1],C[2]=U[ae+2],ne(C,C,X),U[ae]=C[0],U[ae+1]=C[1],U[ae+2]=C[2];return U}}()},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 f}),n.d(r,"divide",function(){return g}),n.d(r,"ceil",function(){return y}),n.d(r,"floor",function(){return S}),n.d(r,"min",function(){return b}),n.d(r,"max",function(){return I}),n.d(r,"round",function(){return N}),n.d(r,"scale",function(){return T}),n.d(r,"scaleAndAdd",function(){return p}),n.d(r,"distance",function(){return m}),n.d(r,"squaredDistance",function(){return v}),n.d(r,"length",function(){return M}),n.d(r,"squaredLength",function(){return k}),n.d(r,"negate",function(){return E}),n.d(r,"inverse",function(){return D}),n.d(r,"normalize",function(){return P}),n.d(r,"dot",function(){return z}),n.d(r,"cross",function(){return j}),n.d(r,"lerp",function(){return A}),n.d(r,"random",function(){return R}),n.d(r,"transformMat4",function(){return L}),n.d(r,"transformQuat",function(){return W}),n.d(r,"zero",function(){return Y}),n.d(r,"str",function(){return H}),n.d(r,"exactEquals",function(){return ie}),n.d(r,"equals",function(){return O}),n.d(r,"sub",function(){return V}),n.d(r,"mul",function(){return Z}),n.d(r,"div",function(){return $}),n.d(r,"dist",function(){return ee}),n.d(r,"sqrDist",function(){return se}),n.d(r,"len",function(){return ce}),n.d(r,"sqrLen",function(){return me}),n.d(r,"forEach",function(){return pe});var i=n(2);function o(){var B=new i.ARRAY_TYPE(4);return i.ARRAY_TYPE!=Float32Array&&(B[0]=0,B[1]=0,B[2]=0,B[3]=0),B}function a(B){var F=new i.ARRAY_TYPE(4);return F[0]=B[0],F[1]=B[1],F[2]=B[2],F[3]=B[3],F}function c(B,F,J,oe){var K=new i.ARRAY_TYPE(4);return K[0]=B,K[1]=F,K[2]=J,K[3]=oe,K}function l(B,F){return B[0]=F[0],B[1]=F[1],B[2]=F[2],B[3]=F[3],B}function u(B,F,J,oe,K){return B[0]=F,B[1]=J,B[2]=oe,B[3]=K,B}function h(B,F,J){return B[0]=F[0]+J[0],B[1]=F[1]+J[1],B[2]=F[2]+J[2],B[3]=F[3]+J[3],B}function d(B,F,J){return B[0]=F[0]-J[0],B[1]=F[1]-J[1],B[2]=F[2]-J[2],B[3]=F[3]-J[3],B}function f(B,F,J){return B[0]=F[0]*J[0],B[1]=F[1]*J[1],B[2]=F[2]*J[2],B[3]=F[3]*J[3],B}function g(B,F,J){return B[0]=F[0]/J[0],B[1]=F[1]/J[1],B[2]=F[2]/J[2],B[3]=F[3]/J[3],B}function y(B,F){return B[0]=Math.ceil(F[0]),B[1]=Math.ceil(F[1]),B[2]=Math.ceil(F[2]),B[3]=Math.ceil(F[3]),B}function S(B,F){return B[0]=Math.floor(F[0]),B[1]=Math.floor(F[1]),B[2]=Math.floor(F[2]),B[3]=Math.floor(F[3]),B}function b(B,F,J){return B[0]=Math.min(F[0],J[0]),B[1]=Math.min(F[1],J[1]),B[2]=Math.min(F[2],J[2]),B[3]=Math.min(F[3],J[3]),B}function I(B,F,J){return B[0]=Math.max(F[0],J[0]),B[1]=Math.max(F[1],J[1]),B[2]=Math.max(F[2],J[2]),B[3]=Math.max(F[3],J[3]),B}function N(B,F){return B[0]=Math.round(F[0]),B[1]=Math.round(F[1]),B[2]=Math.round(F[2]),B[3]=Math.round(F[3]),B}function T(B,F,J){return B[0]=F[0]*J,B[1]=F[1]*J,B[2]=F[2]*J,B[3]=F[3]*J,B}function p(B,F,J,oe){return B[0]=F[0]+J[0]*oe,B[1]=F[1]+J[1]*oe,B[2]=F[2]+J[2]*oe,B[3]=F[3]+J[3]*oe,B}function m(B,F){var J=F[0]-B[0],oe=F[1]-B[1],K=F[2]-B[2],te=F[3]-B[3];return Math.hypot(J,oe,K,te)}function v(B,F){var J=F[0]-B[0],oe=F[1]-B[1],K=F[2]-B[2],te=F[3]-B[3];return J*J+oe*oe+K*K+te*te}function M(B){var F=B[0],J=B[1],oe=B[2],K=B[3];return Math.hypot(F,J,oe,K)}function k(B){var F=B[0],J=B[1],oe=B[2],K=B[3];return F*F+J*J+oe*oe+K*K}function E(B,F){return B[0]=-F[0],B[1]=-F[1],B[2]=-F[2],B[3]=-F[3],B}function D(B,F){return B[0]=1/F[0],B[1]=1/F[1],B[2]=1/F[2],B[3]=1/F[3],B}function P(B,F){var J=F[0],oe=F[1],K=F[2],te=F[3],w=J*J+oe*oe+K*K+te*te;return w>0&&(w=1/Math.sqrt(w)),B[0]=J*w,B[1]=oe*w,B[2]=K*w,B[3]=te*w,B}function z(B,F){return B[0]*F[0]+B[1]*F[1]+B[2]*F[2]+B[3]*F[3]}function j(B,F,J,oe){var K=J[0]*oe[1]-J[1]*oe[0],te=J[0]*oe[2]-J[2]*oe[0],w=J[0]*oe[3]-J[3]*oe[0],C=J[1]*oe[2]-J[2]*oe[1],U=J[1]*oe[3]-J[3]*oe[1],G=J[2]*oe[3]-J[3]*oe[2],_=F[0],re=F[1],ne=F[2],X=F[3];return B[0]=re*G-ne*U+X*C,B[1]=-(_*G)+ne*w-X*te,B[2]=_*U-re*w+X*K,B[3]=-(_*C)+re*te-ne*K,B}function A(B,F,J,oe){var K=F[0],te=F[1],w=F[2],C=F[3];return B[0]=K+oe*(J[0]-K),B[1]=te+oe*(J[1]-te),B[2]=w+oe*(J[2]-w),B[3]=C+oe*(J[3]-C),B}function R(B,F){F=F||1;var J,oe,K,te,w,C;do J=i.RANDOM()*2-1,oe=i.RANDOM()*2-1,w=J*J+oe*oe;while(w>=1);do K=i.RANDOM()*2-1,te=i.RANDOM()*2-1,C=K*K+te*te;while(C>=1);var U=Math.sqrt((1-w)/C);return B[0]=F*J,B[1]=F*oe,B[2]=F*K*U,B[3]=F*te*U,B}function L(B,F,J){var oe=F[0],K=F[1],te=F[2],w=F[3];return B[0]=J[0]*oe+J[4]*K+J[8]*te+J[12]*w,B[1]=J[1]*oe+J[5]*K+J[9]*te+J[13]*w,B[2]=J[2]*oe+J[6]*K+J[10]*te+J[14]*w,B[3]=J[3]*oe+J[7]*K+J[11]*te+J[15]*w,B}function W(B,F,J){var oe=F[0],K=F[1],te=F[2],w=J[0],C=J[1],U=J[2],G=J[3],_=G*oe+C*te-U*K,re=G*K+U*oe-w*te,ne=G*te+w*K-C*oe,X=-w*oe-C*K-U*te;return B[0]=_*G+X*-w+re*-U-ne*-C,B[1]=re*G+X*-C+ne*-w-_*-U,B[2]=ne*G+X*-U+_*-C-re*-w,B[3]=F[3],B}function Y(B){return B[0]=0,B[1]=0,B[2]=0,B[3]=0,B}function H(B){return"vec4("+B[0]+", "+B[1]+", "+B[2]+", "+B[3]+")"}function ie(B,F){return B[0]===F[0]&&B[1]===F[1]&&B[2]===F[2]&&B[3]===F[3]}function O(B,F){var J=B[0],oe=B[1],K=B[2],te=B[3],w=F[0],C=F[1],U=F[2],G=F[3];return Math.abs(J-w)<=i.EPSILON*Math.max(1,Math.abs(J),Math.abs(w))&&Math.abs(oe-C)<=i.EPSILON*Math.max(1,Math.abs(oe),Math.abs(C))&&Math.abs(K-U)<=i.EPSILON*Math.max(1,Math.abs(K),Math.abs(U))&&Math.abs(te-G)<=i.EPSILON*Math.max(1,Math.abs(te),Math.abs(G))}var V=d,Z=f,$=g,ee=m,se=v,ce=M,me=k,pe=function(){var B=o();return function(F,J,oe,K,te,w){var C,U;for(J||(J=4),oe||(oe=0),K?U=Math.min(K*J+oe,F.length):U=F.length,C=oe;C<U;C+=J)B[0]=F[C],B[1]=F[C+1],B[2]=F[C+2],B[3]=F[C+3],te(B,B,w),F[C]=B[0],F[C+1]=B[1],F[C+2]=B[2],F[C+3]=B[3];return F}}()},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 f}),n.d(r,"fromRotation",function(){return g}),n.d(r,"fromMat4",function(){return y}),n.d(r,"copy",function(){return S}),n.d(r,"identity",function(){return b}),n.d(r,"set",function(){return I}),n.d(r,"getReal",function(){return N}),n.d(r,"getDual",function(){return T}),n.d(r,"setReal",function(){return p}),n.d(r,"setDual",function(){return m}),n.d(r,"getTranslation",function(){return v}),n.d(r,"translate",function(){return M}),n.d(r,"rotateX",function(){return k}),n.d(r,"rotateY",function(){return E}),n.d(r,"rotateZ",function(){return D}),n.d(r,"rotateByQuatAppend",function(){return P}),n.d(r,"rotateByQuatPrepend",function(){return z}),n.d(r,"rotateAroundAxis",function(){return j}),n.d(r,"add",function(){return A}),n.d(r,"multiply",function(){return R}),n.d(r,"mul",function(){return L}),n.d(r,"scale",function(){return W}),n.d(r,"dot",function(){return Y}),n.d(r,"lerp",function(){return H}),n.d(r,"invert",function(){return ie}),n.d(r,"conjugate",function(){return O}),n.d(r,"length",function(){return V}),n.d(r,"len",function(){return Z}),n.d(r,"squaredLength",function(){return $}),n.d(r,"sqrLen",function(){return ee}),n.d(r,"normalize",function(){return se}),n.d(r,"str",function(){return ce}),n.d(r,"exactEquals",function(){return me}),n.d(r,"equals",function(){return pe});var i=n(2),o=n(7),a=n(6);function c(){var B=new i.ARRAY_TYPE(8);return i.ARRAY_TYPE!=Float32Array&&(B[0]=0,B[1]=0,B[2]=0,B[4]=0,B[5]=0,B[6]=0,B[7]=0),B[3]=1,B}function l(B){var F=new i.ARRAY_TYPE(8);return F[0]=B[0],F[1]=B[1],F[2]=B[2],F[3]=B[3],F[4]=B[4],F[5]=B[5],F[6]=B[6],F[7]=B[7],F}function u(B,F,J,oe,K,te,w,C){var U=new i.ARRAY_TYPE(8);return U[0]=B,U[1]=F,U[2]=J,U[3]=oe,U[4]=K,U[5]=te,U[6]=w,U[7]=C,U}function h(B,F,J,oe,K,te,w){var C=new i.ARRAY_TYPE(8);C[0]=B,C[1]=F,C[2]=J,C[3]=oe;var U=K*.5,G=te*.5,_=w*.5;return C[4]=U*oe+G*J-_*F,C[5]=G*oe+_*B-U*J,C[6]=_*oe+U*F-G*B,C[7]=-U*B-G*F-_*J,C}function d(B,F,J){var oe=J[0]*.5,K=J[1]*.5,te=J[2]*.5,w=F[0],C=F[1],U=F[2],G=F[3];return B[0]=w,B[1]=C,B[2]=U,B[3]=G,B[4]=oe*G+K*U-te*C,B[5]=K*G+te*w-oe*U,B[6]=te*G+oe*C-K*w,B[7]=-oe*w-K*C-te*U,B}function f(B,F){return B[0]=0,B[1]=0,B[2]=0,B[3]=1,B[4]=F[0]*.5,B[5]=F[1]*.5,B[6]=F[2]*.5,B[7]=0,B}function g(B,F){return B[0]=F[0],B[1]=F[1],B[2]=F[2],B[3]=F[3],B[4]=0,B[5]=0,B[6]=0,B[7]=0,B}function y(B,F){var J=o.create();a.getRotation(J,F);var oe=new i.ARRAY_TYPE(3);return a.getTranslation(oe,F),d(B,J,oe),B}function S(B,F){return B[0]=F[0],B[1]=F[1],B[2]=F[2],B[3]=F[3],B[4]=F[4],B[5]=F[5],B[6]=F[6],B[7]=F[7],B}function b(B){return B[0]=0,B[1]=0,B[2]=0,B[3]=1,B[4]=0,B[5]=0,B[6]=0,B[7]=0,B}function I(B,F,J,oe,K,te,w,C,U){return B[0]=F,B[1]=J,B[2]=oe,B[3]=K,B[4]=te,B[5]=w,B[6]=C,B[7]=U,B}var N=o.copy;function T(B,F){return B[0]=F[4],B[1]=F[5],B[2]=F[6],B[3]=F[7],B}var p=o.copy;function m(B,F){return B[4]=F[0],B[5]=F[1],B[6]=F[2],B[7]=F[3],B}function v(B,F){var J=F[4],oe=F[5],K=F[6],te=F[7],w=-F[0],C=-F[1],U=-F[2],G=F[3];return B[0]=(J*G+te*w+oe*U-K*C)*2,B[1]=(oe*G+te*C+K*w-J*U)*2,B[2]=(K*G+te*U+J*C-oe*w)*2,B}function M(B,F,J){var oe=F[0],K=F[1],te=F[2],w=F[3],C=J[0]*.5,U=J[1]*.5,G=J[2]*.5,_=F[4],re=F[5],ne=F[6],X=F[7];return B[0]=oe,B[1]=K,B[2]=te,B[3]=w,B[4]=w*C+K*G-te*U+_,B[5]=w*U+te*C-oe*G+re,B[6]=w*G+oe*U-K*C+ne,B[7]=-oe*C-K*U-te*G+X,B}function k(B,F,J){var oe=-F[0],K=-F[1],te=-F[2],w=F[3],C=F[4],U=F[5],G=F[6],_=F[7],re=C*w+_*oe+U*te-G*K,ne=U*w+_*K+G*oe-C*te,X=G*w+_*te+C*K-U*oe,ae=_*w-C*oe-U*K-G*te;return o.rotateX(B,F,J),oe=B[0],K=B[1],te=B[2],w=B[3],B[4]=re*w+ae*oe+ne*te-X*K,B[5]=ne*w+ae*K+X*oe-re*te,B[6]=X*w+ae*te+re*K-ne*oe,B[7]=ae*w-re*oe-ne*K-X*te,B}function E(B,F,J){var oe=-F[0],K=-F[1],te=-F[2],w=F[3],C=F[4],U=F[5],G=F[6],_=F[7],re=C*w+_*oe+U*te-G*K,ne=U*w+_*K+G*oe-C*te,X=G*w+_*te+C*K-U*oe,ae=_*w-C*oe-U*K-G*te;return o.rotateY(B,F,J),oe=B[0],K=B[1],te=B[2],w=B[3],B[4]=re*w+ae*oe+ne*te-X*K,B[5]=ne*w+ae*K+X*oe-re*te,B[6]=X*w+ae*te+re*K-ne*oe,B[7]=ae*w-re*oe-ne*K-X*te,B}function D(B,F,J){var oe=-F[0],K=-F[1],te=-F[2],w=F[3],C=F[4],U=F[5],G=F[6],_=F[7],re=C*w+_*oe+U*te-G*K,ne=U*w+_*K+G*oe-C*te,X=G*w+_*te+C*K-U*oe,ae=_*w-C*oe-U*K-G*te;return o.rotateZ(B,F,J),oe=B[0],K=B[1],te=B[2],w=B[3],B[4]=re*w+ae*oe+ne*te-X*K,B[5]=ne*w+ae*K+X*oe-re*te,B[6]=X*w+ae*te+re*K-ne*oe,B[7]=ae*w-re*oe-ne*K-X*te,B}function P(B,F,J){var oe=J[0],K=J[1],te=J[2],w=J[3],C=F[0],U=F[1],G=F[2],_=F[3];return B[0]=C*w+_*oe+U*te-G*K,B[1]=U*w+_*K+G*oe-C*te,B[2]=G*w+_*te+C*K-U*oe,B[3]=_*w-C*oe-U*K-G*te,C=F[4],U=F[5],G=F[6],_=F[7],B[4]=C*w+_*oe+U*te-G*K,B[5]=U*w+_*K+G*oe-C*te,B[6]=G*w+_*te+C*K-U*oe,B[7]=_*w-C*oe-U*K-G*te,B}function z(B,F,J){var oe=F[0],K=F[1],te=F[2],w=F[3],C=J[0],U=J[1],G=J[2],_=J[3];return B[0]=oe*_+w*C+K*G-te*U,B[1]=K*_+w*U+te*C-oe*G,B[2]=te*_+w*G+oe*U-K*C,B[3]=w*_-oe*C-K*U-te*G,C=J[4],U=J[5],G=J[6],_=J[7],B[4]=oe*_+w*C+K*G-te*U,B[5]=K*_+w*U+te*C-oe*G,B[6]=te*_+w*G+oe*U-K*C,B[7]=w*_-oe*C-K*U-te*G,B}function j(B,F,J,oe){if(Math.abs(oe)<i.EPSILON)return S(B,F);var K=Math.hypot(J[0],J[1],J[2]);oe=oe*.5;var te=Math.sin(oe),w=te*J[0]/K,C=te*J[1]/K,U=te*J[2]/K,G=Math.cos(oe),_=F[0],re=F[1],ne=F[2],X=F[3];B[0]=_*G+X*w+re*U-ne*C,B[1]=re*G+X*C+ne*w-_*U,B[2]=ne*G+X*U+_*C-re*w,B[3]=X*G-_*w-re*C-ne*U;var ae=F[4],ue=F[5],he=F[6],ge=F[7];return B[4]=ae*G+ge*w+ue*U-he*C,B[5]=ue*G+ge*C+he*w-ae*U,B[6]=he*G+ge*U+ae*C-ue*w,B[7]=ge*G-ae*w-ue*C-he*U,B}function A(B,F,J){return B[0]=F[0]+J[0],B[1]=F[1]+J[1],B[2]=F[2]+J[2],B[3]=F[3]+J[3],B[4]=F[4]+J[4],B[5]=F[5]+J[5],B[6]=F[6]+J[6],B[7]=F[7]+J[7],B}function R(B,F,J){var oe=F[0],K=F[1],te=F[2],w=F[3],C=J[4],U=J[5],G=J[6],_=J[7],re=F[4],ne=F[5],X=F[6],ae=F[7],ue=J[0],he=J[1],ge=J[2],Me=J[3];return B[0]=oe*Me+w*ue+K*ge-te*he,B[1]=K*Me+w*he+te*ue-oe*ge,B[2]=te*Me+w*ge+oe*he-K*ue,B[3]=w*Me-oe*ue-K*he-te*ge,B[4]=oe*_+w*C+K*G-te*U+re*Me+ae*ue+ne*ge-X*he,B[5]=K*_+w*U+te*C-oe*G+ne*Me+ae*he+X*ue-re*ge,B[6]=te*_+w*G+oe*U-K*C+X*Me+ae*ge+re*he-ne*ue,B[7]=w*_-oe*C-K*U-te*G+ae*Me-re*ue-ne*he-X*ge,B}var L=R;function W(B,F,J){return B[0]=F[0]*J,B[1]=F[1]*J,B[2]=F[2]*J,B[3]=F[3]*J,B[4]=F[4]*J,B[5]=F[5]*J,B[6]=F[6]*J,B[7]=F[7]*J,B}var Y=o.dot;function H(B,F,J,oe){var K=1-oe;return Y(F,J)<0&&(oe=-oe),B[0]=F[0]*K+J[0]*oe,B[1]=F[1]*K+J[1]*oe,B[2]=F[2]*K+J[2]*oe,B[3]=F[3]*K+J[3]*oe,B[4]=F[4]*K+J[4]*oe,B[5]=F[5]*K+J[5]*oe,B[6]=F[6]*K+J[6]*oe,B[7]=F[7]*K+J[7]*oe,B}function ie(B,F){var J=$(F);return B[0]=-F[0]/J,B[1]=-F[1]/J,B[2]=-F[2]/J,B[3]=F[3]/J,B[4]=-F[4]/J,B[5]=-F[5]/J,B[6]=-F[6]/J,B[7]=F[7]/J,B}function O(B,F){return B[0]=-F[0],B[1]=-F[1],B[2]=-F[2],B[3]=F[3],B[4]=-F[4],B[5]=-F[5],B[6]=-F[6],B[7]=F[7],B}var V=o.length,Z=V,$=o.squaredLength,ee=$;function se(B,F){var J=$(F);if(J>0){J=Math.sqrt(J);var oe=F[0]/J,K=F[1]/J,te=F[2]/J,w=F[3]/J,C=F[4],U=F[5],G=F[6],_=F[7],re=oe*C+K*U+te*G+w*_;B[0]=oe,B[1]=K,B[2]=te,B[3]=w,B[4]=(C-oe*re)/J,B[5]=(U-K*re)/J,B[6]=(G-te*re)/J,B[7]=(_-w*re)/J}return B}function ce(B){return"quat2("+B[0]+", "+B[1]+", "+B[2]+", "+B[3]+", "+B[4]+", "+B[5]+", "+B[6]+", "+B[7]+")"}function me(B,F){return B[0]===F[0]&&B[1]===F[1]&&B[2]===F[2]&&B[3]===F[3]&&B[4]===F[4]&&B[5]===F[5]&&B[6]===F[6]&&B[7]===F[7]}function pe(B,F){var J=B[0],oe=B[1],K=B[2],te=B[3],w=B[4],C=B[5],U=B[6],G=B[7],_=F[0],re=F[1],ne=F[2],X=F[3],ae=F[4],ue=F[5],he=F[6],ge=F[7];return Math.abs(J-_)<=i.EPSILON*Math.max(1,Math.abs(J),Math.abs(_))&&Math.abs(oe-re)<=i.EPSILON*Math.max(1,Math.abs(oe),Math.abs(re))&&Math.abs(K-ne)<=i.EPSILON*Math.max(1,Math.abs(K),Math.abs(ne))&&Math.abs(te-X)<=i.EPSILON*Math.max(1,Math.abs(te),Math.abs(X))&&Math.abs(w-ae)<=i.EPSILON*Math.max(1,Math.abs(w),Math.abs(ae))&&Math.abs(C-ue)<=i.EPSILON*Math.max(1,Math.abs(C),Math.abs(ue))&&Math.abs(U-he)<=i.EPSILON*Math.max(1,Math.abs(U),Math.abs(he))&&Math.abs(G-ge)<=i.EPSILON*Math.max(1,Math.abs(G),Math.abs(ge))}},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 f}),n.d(r,"divide",function(){return g}),n.d(r,"ceil",function(){return y}),n.d(r,"floor",function(){return S}),n.d(r,"min",function(){return b}),n.d(r,"max",function(){return I}),n.d(r,"round",function(){return N}),n.d(r,"scale",function(){return T}),n.d(r,"scaleAndAdd",function(){return p}),n.d(r,"distance",function(){return m}),n.d(r,"squaredDistance",function(){return v}),n.d(r,"length",function(){return M}),n.d(r,"squaredLength",function(){return k}),n.d(r,"negate",function(){return E}),n.d(r,"inverse",function(){return D}),n.d(r,"normalize",function(){return P}),n.d(r,"dot",function(){return z}),n.d(r,"cross",function(){return j}),n.d(r,"lerp",function(){return A}),n.d(r,"random",function(){return R}),n.d(r,"transformMat2",function(){return L}),n.d(r,"transformMat2d",function(){return W}),n.d(r,"transformMat3",function(){return Y}),n.d(r,"transformMat4",function(){return H}),n.d(r,"rotate",function(){return ie}),n.d(r,"angle",function(){return O}),n.d(r,"zero",function(){return V}),n.d(r,"str",function(){return Z}),n.d(r,"exactEquals",function(){return $}),n.d(r,"equals",function(){return ee}),n.d(r,"len",function(){return se}),n.d(r,"sub",function(){return ce}),n.d(r,"mul",function(){return me}),n.d(r,"div",function(){return pe}),n.d(r,"dist",function(){return B}),n.d(r,"sqrDist",function(){return F}),n.d(r,"sqrLen",function(){return J}),n.d(r,"forEach",function(){return oe});var i=n(2);function o(){var K=new i.ARRAY_TYPE(2);return i.ARRAY_TYPE!=Float32Array&&(K[0]=0,K[1]=0),K}function a(K){var te=new i.ARRAY_TYPE(2);return te[0]=K[0],te[1]=K[1],te}function c(K,te){var w=new i.ARRAY_TYPE(2);return w[0]=K,w[1]=te,w}function l(K,te){return K[0]=te[0],K[1]=te[1],K}function u(K,te,w){return K[0]=te,K[1]=w,K}function h(K,te,w){return K[0]=te[0]+w[0],K[1]=te[1]+w[1],K}function d(K,te,w){return K[0]=te[0]-w[0],K[1]=te[1]-w[1],K}function f(K,te,w){return K[0]=te[0]*w[0],K[1]=te[1]*w[1],K}function g(K,te,w){return K[0]=te[0]/w[0],K[1]=te[1]/w[1],K}function y(K,te){return K[0]=Math.ceil(te[0]),K[1]=Math.ceil(te[1]),K}function S(K,te){return K[0]=Math.floor(te[0]),K[1]=Math.floor(te[1]),K}function b(K,te,w){return K[0]=Math.min(te[0],w[0]),K[1]=Math.min(te[1],w[1]),K}function I(K,te,w){return K[0]=Math.max(te[0],w[0]),K[1]=Math.max(te[1],w[1]),K}function N(K,te){return K[0]=Math.round(te[0]),K[1]=Math.round(te[1]),K}function T(K,te,w){return K[0]=te[0]*w,K[1]=te[1]*w,K}function p(K,te,w,C){return K[0]=te[0]+w[0]*C,K[1]=te[1]+w[1]*C,K}function m(K,te){var w=te[0]-K[0],C=te[1]-K[1];return Math.hypot(w,C)}function v(K,te){var w=te[0]-K[0],C=te[1]-K[1];return w*w+C*C}function M(K){var te=K[0],w=K[1];return Math.hypot(te,w)}function k(K){var te=K[0],w=K[1];return te*te+w*w}function E(K,te){return K[0]=-te[0],K[1]=-te[1],K}function D(K,te){return K[0]=1/te[0],K[1]=1/te[1],K}function P(K,te){var w=te[0],C=te[1],U=w*w+C*C;return U>0&&(U=1/Math.sqrt(U)),K[0]=te[0]*U,K[1]=te[1]*U,K}function z(K,te){return K[0]*te[0]+K[1]*te[1]}function j(K,te,w){var C=te[0]*w[1]-te[1]*w[0];return K[0]=K[1]=0,K[2]=C,K}function A(K,te,w,C){var U=te[0],G=te[1];return K[0]=U+C*(w[0]-U),K[1]=G+C*(w[1]-G),K}function R(K,te){te=te||1;var w=i.RANDOM()*2*Math.PI;return K[0]=Math.cos(w)*te,K[1]=Math.sin(w)*te,K}function L(K,te,w){var C=te[0],U=te[1];return K[0]=w[0]*C+w[2]*U,K[1]=w[1]*C+w[3]*U,K}function W(K,te,w){var C=te[0],U=te[1];return K[0]=w[0]*C+w[2]*U+w[4],K[1]=w[1]*C+w[3]*U+w[5],K}function Y(K,te,w){var C=te[0],U=te[1];return K[0]=w[0]*C+w[3]*U+w[6],K[1]=w[1]*C+w[4]*U+w[7],K}function H(K,te,w){var C=te[0],U=te[1];return K[0]=w[0]*C+w[4]*U+w[12],K[1]=w[1]*C+w[5]*U+w[13],K}function ie(K,te,w,C){var U=te[0]-w[0],G=te[1]-w[1],_=Math.sin(C),re=Math.cos(C);return K[0]=U*re-G*_+w[0],K[1]=U*_+G*re+w[1],K}function O(K,te){var w=K[0],C=K[1],U=te[0],G=te[1],_=Math.sqrt(w*w+C*C)*Math.sqrt(U*U+G*G),re=_&&(w*U+C*G)/_;return Math.acos(Math.min(Math.max(re,-1),1))}function V(K){return K[0]=0,K[1]=0,K}function Z(K){return"vec2("+K[0]+", "+K[1]+")"}function $(K,te){return K[0]===te[0]&&K[1]===te[1]}function ee(K,te){var w=K[0],C=K[1],U=te[0],G=te[1];return Math.abs(w-U)<=i.EPSILON*Math.max(1,Math.abs(w),Math.abs(U))&&Math.abs(C-G)<=i.EPSILON*Math.max(1,Math.abs(C),Math.abs(G))}var se=M,ce=d,me=f,pe=g,B=m,F=v,J=k,oe=function(){var K=o();return function(te,w,C,U,G,_){var re,ne;for(w||(w=2),C||(C=0),U?ne=Math.min(U*w+C,te.length):ne=te.length,re=C;re<ne;re+=w)K[0]=te[re],K[1]=te[re+1],G(K,K,_),te[re]=K[0],te[re+1]=K[1];return te}}()},function(e,r,n){n.r(r),n.d(r,"default",function(){return O});var i=n(13),o=n.n(i),a=n(19),c=n.n(a),l=n(23),u=n.n(l),h=n(24),d=n.n(h),f=n(25),g=n(1),y=n(36),S=n(43),b=n(41),I=n(56),N=n(73),T=n(45),p=n(78),m=n(37),v=n(82);n(1).glMatrix.setMatrixArrayType(Array);function M(V,Z){var $;if(typeof Symbol>"u"||V[Symbol.iterator]==null){if(Array.isArray(V)||($=k(V))||Z){$&&(V=$);var ee=0,se=function(){};return{s:se,n:function(){return ee>=V.length?{done:!0}:{done:!1,value:V[ee++]}},e:function(F){throw F},f:se}}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 ce=!0,me=!1,pe;return{s:function(){$=V[Symbol.iterator]()},n:function(){var F=$.next();return ce=F.done,F},e:function(F){me=!0,pe=F},f:function(){try{!ce&&$.return!=null&&$.return()}finally{if(me)throw pe}}}}function k(V,Z){if(V){if(typeof V=="string")return E(V,Z);var $=Object.prototype.toString.call(V).slice(8,-1);if($==="Object"&&V.constructor&&($=V.constructor.name),$==="Map"||$==="Set")return Array.from(V);if($==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test($))return E(V,Z)}}function E(V,Z){(Z==null||Z>V.length)&&(Z=V.length);for(var $=0,ee=new Array(Z);$<Z;$++)ee[$]=V[$];return ee}var D={autoUpdate:!1,preserveDrawingBuffer:!1,bufferSize:1500},P=`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
|
-
`,z=`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
|
-
`,j=Symbol("glRenderer"),A=Symbol("canvasRenderer"),R=Symbol("options"),L=Symbol("globalTransform"),W=Symbol("applyGlobalTransform"),Y=Symbol("canvas");function H(V){var Z=V.gl,$=V.fbo;$&&Z.bindFramebuffer(Z.FRAMEBUFFER,$),V._draw(),$&&Z.bindFramebuffer(Z.FRAMEBUFFER,null)}function ie(V,Z,$,ee){var se=V.createTexture(Z.canvas),ce=[[[0,0],[$,0],[$,ee],[0,ee],[0,0]]];ce.closed=!0;var me=new N.default({contours:ce});me.setTexture(se),V.setMeshData([me.meshData]),H(V),se.delete(),Z.clearRect(0,0,$,ee),delete Z._filter}var O=function(){function V(Z){var $=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};u()(this,V);var ee=$.contextType;if(ee||(typeof WebGL2RenderingContext=="function"?ee="webgl2":typeof WebGLRenderingContext=="function"?ee="webgl":ee="2d"),!Z.getContext){var se=Z;Z={getContext:function(){return se},width:$.width,height:$.height},se.canvas=Z,ee="2d"}if(this[Y]=Z,ee!=="webgl"&&ee!=="webgl2"&&ee!=="2d")throw new Error("Unknown context type ".concat(ee));if($.contextType=ee,this[R]=Object.assign({},D,$),ee==="webgl"||ee==="webgl2"){ee==="webgl2"&&(this[R].webgl2=!0);var ce=new f.default(Z,this[R]);ee==="webgl2"&&!ce.isWebGL2&&($.contextType="webgl"),Object(v.createShaders)(ce),Object(v.applyShader)(ce),Object(v.createCloudShaders)(ce);var me=ce.gl;me.clearColor(0,0,0,0),me.blendFuncSeparate(me.SRC_ALPHA,me.ONE_MINUS_SRC_ALPHA,me.ONE,me.ONE_MINUS_SRC_ALPHA),this[j]=ce}else this[A]=new y.default(Z,this[R]);this[L]=[1,0,0,0,1,0,0,0,1],this.updateResolution()}return d()(V,[{key:W,value:function(){var $=this[j]||this[A];if(this[j]){var ee=this.canvas,se=ee.width,ce=ee.height;$.uniforms.viewMatrix=this.viewMatrix,$.uniforms.projectionMatrix=this.projectionMatrix,$.uniforms.u_resolution=[se,ce]}}},{key:"updateResolution",value:function(){var $=this.canvas,ee=$.width,se=$.height,ce=[1,0,0,0,1,0,-ee/2,-se/2,1],me=[2/ee,0,0,0,-2/se,0,0,0,1],pe=g.mat3.multiply(Array.of(0,0,0,0,0,0,0,0,0),me,ce);this.projectionMatrix=pe,this[j]&&this[j].gl.viewport(0,0,ee,se)}},{key:"createTexture",value:function($,ee){var se=this[j]||this[A];return se.createTexture($,ee)}},{key:"loadTexture",value:function($){var ee=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},se=ee.useImageBitmap,ce=se===void 0?!1:se,me=this[j]||this[A];return me.loadTexture($,{useImageBitmap:ce})}},{key:"createText",value:function($){var ee=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},se=ee.font,ce=se===void 0?"16px arial":se,me=ee.fillColor,pe=me===void 0?null:me,B=ee.strokeColor,F=B===void 0?null:B,J=ee.strokeWidth,oe=J===void 0?1:J;if(this[j]){var K=m.default.createText($,{font:ce,fillColor:pe,strokeColor:F,strokeWidth:oe});return{image:this.createTexture(K.image),rect:K.rect}}return{_img:{font:ce,fillColor:pe,strokeColor:F,strokeWidth:oe,text:$}}}},{key:"createProgram",value:function(){var $=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ee=$.vertex,se=$.fragment,ce=$.options;if(this[j]){var me=this[j].compileSync(se,ee);return me._attribOpts=ce,me}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,se=ee===void 0?P:ee,ce=$.fragment,me=ce===void 0?z:ce,pe=$.options;return this.createProgram({vertex:se,fragment:me,options:pe})}},{key:"useProgram",value:function($){var ee=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this[j]){var se=Object.assign({},$._attribOpts,ee);return this[j].useProgram($,se)}throw new Error("Context 2D cannot use webgl program.")}},{key:"deleteTexture",value:function($){var ee=this[j]||this[A];return ee.deleteTexture($)}},{key:"clear",value:function(){if(this[j]){var $=this[j].gl;$.clear($.COLOR_BUFFER_BIT)}else{var ee;(ee=this[A]).clear.apply(ee,arguments)}}},{key:"drawMeshCloud",value:function($){var ee=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},se=ee.clear,ce=se===void 0?!1:se,me=ee.program,pe=me===void 0?null:me,B=this[j]||this[A],F=pe||$.program;if(this[j]){var J=B.gl;if(ce&&J.clear(J.COLOR_BUFFER_BIT),F)B.program!==F&&this.useProgram(F,{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 oe=$.mesh.meshData,K=!!oe.uniforms.u_texSampler,te=!!oe.uniforms.u_filterFlag,w=!!oe.uniforms.u_radialGradientVector,C=$.hasCloudColor,U=$.hasCloudFilter,G=!!oe.uniforms.u_clipSampler;Object(v.applyCloudShader)(B,{hasTexture:K,hasFilter:te,hasGradient:w,hasCloudColor:C,hasCloudFilter:U,hasClipPath:G})}this[W](),B.setMeshData([$.meshData]),$.beforeRender&&$.beforeRender(J,$),H(B),$.afterRender&&$.afterRender(J,$)}else B.setTransform(this.globalTransformMatrix),B.drawMeshCloud($,{clear:ce,hook:!1})}},{key:"drawMeshes",value:function($){var ee=this,se=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ce=se.clear,me=ce===void 0?!1:ce,pe=se.program,B=pe===void 0?null:pe,F=this[j]||this[A];this[j]?function(){var J=F.fbo,oe=Object(S.default)(ee,$,B==null),K=F.gl;me&&K.clear(K.COLOR_BUFFER_BIT);var te=!Object(p.isUnitTransform)(ee.globalTransformMatrix);ee._drawCalls=0;var w=M(oe),C;try{var U=function(){var _=C.value;ee._drawCalls++;var re=B||_.program;if(_ instanceof T.default)ee.drawMeshCloud(_,{clear:me,program:re});else{var ne=ee.canvas,X=ne.width,ae=ne.height;if(_.beforeRender&&_.beforeRender(K,_),_.pass.length&&((!ee.fbo||ee.fbo.width!==X||ee.fbo.height!==ae)&&(ee.fbo={width:X,height:ae,target:F.createFBO(),buffer:F.createFBO(),swap:function(){var Oe=[this.buffer,this.target];this.target=Oe[0],this.buffer=Oe[1]}}),F.bindFBO(ee.fbo.target)),!re&&_.filterCanvas){Object(v.applyShader)(F,{hasTexture:!0});var ue=ee.filterContext;if(!ue){var he=m.default.createCanvas(X,ae);ue=he.getContext("2d"),ee.filterContext=ue}var ge=$[_.packIndex],Me=ge.filter,we=$[_.packIndex+1],be=$[_.packIndex-1];(!be||!be.filterCanvas||be.filter!==Me)&&(!we||!we.filterCanvas||we.filter!==Me)?(te?(ue.save(),Object(b.drawMesh2D)(ge,ue,!1),ue.restore(),Object(b.applyFilter)(ue,Me)):Object(b.drawMesh2D)(ge,ue,!0),ee[W](),ie(F,ue,X,ae)):(te&&ue.save(),Object(b.drawMesh2D)(ge,ue,!1),te&&ue.restore(),(!we||!we.filterCanvas||ge.filter!==we.filter)&&(Object(b.applyFilter)(ue,Me),ee[W](),ie(F,ue,X,ae)))}else{if(re)F.program!==re&&ee.useProgram(re,{a_color:{type:"UNSIGNED_BYTE",normalize:!0}});else{var Ce=!!_.uniforms.u_texSampler,Ie=!!_.uniforms.u_filterFlag,Ae=!!_.uniforms.u_radialGradientVector,Ee=!!_.uniforms.u_clipSampler;Object(v.applyShader)(F,{hasTexture:Ce,hasFilter:Ie,hasGradient:Ae,hasClipPath:Ee})}_.filterCanvas&&console.warn("User program ignored some filter effects."),ee[W](),F.setMeshData([_]),H(F)}if(_.pass.length){var ke=_.pass.length;_.pass.forEach(function(Ne,Oe){Ne.blend=_.enableBlend,Ne.setTexture(F.fbo.texture),Oe===ke-1?F.bindFBO(J):(ee.fbo.swap(),F.bindFBO(ee.fbo.target)),Ne.program?F.useProgram(Ne.program):(ee.defaultPassProgram=ee.defaultPassProgram||ee.createPassProgram(),F.useProgram(ee.defaultPassProgram)),F.setMeshData([Ne.meshData]),K.clear(K.COLOR_BUFFER_BIT),H(F)})}_.afterRender&&_.afterRender(K,_)}};for(w.s();!(C=w.n()).done;)U()}catch(G){w.e(G)}finally{w.f()}}():(F.setTransform(this.globalTransformMatrix),F.drawMeshes($,{clear:me}))}},{key:"drawImage",value:function($){for(var ee=arguments.length,se=new Array(ee>1?ee-1:0),ce=1;ce<ee;ce++)se[ce-1]=arguments[ce];var me=se.length;if(me<2)throw new TypeError("Failed to execute 'drawImage' on 'Renderer': 3 arguments required, but only ".concat(se.length+1," present."));if(me!==2&&me!==4&&me!==8)throw new TypeError("Failed to execute 'drawImage' on 'Renderer': Valid arities are: [3, 5, 9], but ".concat(se.length+1," arguments provided."));var pe=null,B=null;me===2?pe=[se[0],se[1],$.width,$.height]:me===4?pe=se:me===8&&(B=se.slice(0,4),pe=se.slice(4));var F=this.createTexture($),J=this.canvas,oe=J.width,K=J.height,te=new I.default;te.rect(pe[0],pe[1],oe,K);var w=new N.default(te,{width:oe,height:K});w.setTexture(F,{rect:pe,srcRect:B}),this.drawMeshes([w]),this.deleteTexture(F)}},{key:"setGlobalTransform",value:function(){return this[L]=[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[L],ee=arguments.length,se=new Array(ee),ce=0;ce<ee;ce++)se[ce]=arguments[ce];return this[L]=g.mat3.multiply(Array.of(0,0,0,0,0,0,0,0,0),$,se),this}},{key:"globalTranslate",value:function($,ee){var se=g.mat3.create();return se=g.mat3.translate(Array.of(0,0,0,0,0,0,0,0,0),se,[$,ee]),this.globalTransform.apply(this,c()(se))}},{key:"globalRotate",value:function($){var ee=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[0,0],se=o()(ee,2),ce=se[0],me=se[1],pe=g.mat3.create();return pe=g.mat3.translate(Array.of(0,0,0,0,0,0,0,0,0),pe,[ce,me]),pe=g.mat3.rotate(Array.of(0,0,0,0,0,0,0,0,0),pe,$),pe=g.mat3.translate(Array.of(0,0,0,0,0,0,0,0,0),pe,[-ce,-me]),this.globalTransform.apply(this,c()(pe))}},{key:"globalScale",value:function($){var ee=arguments.length>1&&arguments[1]!==void 0?arguments[1]:$,se=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[0,0],ce=o()(se,2),me=ce[0],pe=ce[1],B=g.mat3.create();return B=g.mat3.translate(Array.of(0,0,0,0,0,0,0,0,0),B,[me,pe]),B=g.mat3.scale(Array.of(0,0,0,0,0,0,0,0,0),B,[$,ee]),B=g.mat3.translate(Array.of(0,0,0,0,0,0,0,0,0),B,[-me,-pe]),this.globalTransform.apply(this,c()(B))}},{key:"globalSkew",value:function($){var ee=arguments.length>1&&arguments[1]!==void 0?arguments[1]:$,se=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[0,0],ce=o()(se,2),me=ce[0],pe=ce[1],B=g.mat3.create();return B=g.mat3.translate(Array.of(0,0,0,0,0,0,0,0,0),B,[me,pe]),B=g.mat3.multiply(Array.of(0,0,0,0,0,0,0,0,0),B,g.mat3.fromValues(1,Math.tan(ee),Math.tan($),1,0,0)),B=g.mat3.translate(Array.of(0,0,0,0,0,0,0,0,0),B,[-me,-pe]),this.globalTransform.apply(this,c()(B))}},{key:"transformPoint",value:function($,ee,se){var ce=this.globalTransformMatrix;se&&(ce=g.mat3.multiply(Array.of(0,0,0,0,0,0,0,0,0),ce,se));var me=$*ce[0]+ee*ce[2]+ce[4],pe=$*ce[1]+ee*ce[3]+ce[5];return[me,pe]}},{key:"canvas",get:function(){return this[Y]}},{key:"canvasRenderer",get:function(){return this[A]}},{key:"glRenderer",get:function(){return this[j]}},{key:"isWebGL2",get:function(){return this[j]&&this[j].isWebGL2}},{key:"options",get:function(){return this[R]}},{key:"globalTransformMatrix",get:function(){var $=this[L];return[$[0],$[1],$[3],$[4],$[6],$[7]]}},{key:"viewMatrix",get:function(){return this[L]}}]),V}()},function(e,r,n){var i=n(14),o=n(15),a=n(16),c=n(18);function l(u,h){return i(u)||o(u,h)||a(u,h)||c()}e.exports=l},function(e,r){function n(i){if(Array.isArray(i))return i}e.exports=n},function(e,r){function n(i,o){if(!(typeof Symbol>"u"||!(Symbol.iterator in Object(i)))){var a=[],c=!0,l=!1,u=void 0;try{for(var h=i[Symbol.iterator](),d;!(c=(d=h.next()).done)&&(a.push(d.value),!(o&&a.length===o));c=!0);}catch(f){l=!0,u=f}finally{try{!c&&h.return!=null&&h.return()}finally{if(l)throw u}}return a}}e.exports=n},function(e,r,n){var i=n(17);function o(a,c){if(a){if(typeof a=="string")return i(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 i(a,c)}}e.exports=o},function(e,r){function n(i,o){(o==null||o>i.length)&&(o=i.length);for(var a=0,c=new Array(o);a<o;a++)c[a]=i[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 i=n(20),o=n(21),a=n(16),c=n(22);function l(u){return i(u)||o(u)||a(u)||c()}e.exports=l},function(e,r,n){var i=n(17);function o(a){if(Array.isArray(a))return i(a)}e.exports=o},function(e,r){function n(i){if(typeof Symbol<"u"&&Symbol.iterator in Object(i))return Array.from(i)}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(i,o){if(!(i 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 i(o,a,c){return a&&n(o.prototype,a),c&&n(o,c),o}e.exports=i},function(e,r,n){n.r(r);var i=n(26);n(1).glMatrix.setMatrixArrayType(Array),r.default=i.default},function(e,r,n){n.r(r),n.d(r,"default",function(){return P});var i=n(27),o=n.n(i),a=n(29),c=n.n(a),l=n(13),u=n.n(l),h=n(19),d=n.n(h),f=n(23),g=n.n(f),y=n(24),S=n.n(y),b=n(30),I=n.n(b),N=n(31),T=n(33),p=n(34),m=n(35);n(1).glMatrix.setMatrixArrayType(Array);var v={};function M(z){for(var j=arguments.length>1&&arguments[1]!==void 0?arguments[1]:3,A=[],R=z.length,L=0;L<R;L++)L%j<2&&A.push(.5*(z[L]+1));return A}function k(z,j){var A=j._buffers;Object.values(A).forEach(function(R){z.deleteBuffer(R)}),j._buffers={}}function E(z,j,A){return z.activeTexture(z.TEXTURE0+A),Array.isArray(j._img)?z.bindTexture(z.TEXTURE_CUBE_MAP,j):z.bindTexture(z.TEXTURE_2D,j),j}var D={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"},P=function(){S()(z,null,[{key:"addLibs",value:function(){var A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.assign(v,A)}},{key:"FLOAT",value:function(A,R){return Object(N.pointsToBuffer)(A,Float32Array,R)}},{key:"UNSIGNED_BYTE",value:function(A,R){return Object(N.pointsToBuffer)(A,Uint8Array,R)}},{key:"UNSIGNED_SHORT",value:function(A,R){return Object(N.pointsToBuffer)(A,Uint16Array,R)}},{key:"BYTE",value:function(A,R){return Object(N.pointsToBuffer)(A,Int8Array,R)}},{key:"SHORT",value:function(A,R){return Object(N.pointsToBuffer)(A,Int16Array,R)}}]);function z(j){var A=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};g()(this,z),this.options=Object.assign({},z.defaultOptions,A),this.canvas=j;var R;this.options.webgl2&&(R=j.getContext("webgl2",this.options)),R==null&&(R=Object(N.setupWebGL)(j,this.options),this.aia_ext=R.getExtension("ANGLE_instanced_arrays")),this.gl=R,R.viewport(0,0,j.width,j.height),R.clearColor(0,0,0,0),R.blendFuncSeparate(R.SRC_ALPHA,R.ONE_MINUS_SRC_ALPHA,R.ONE,R.ONE_MINUS_SRC_ALPHA),this.programs=[],this._events={}}return S()(z,[{key:"_declareUniform",value:function(A,R){var L=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"1f",W=this.gl,Y=W.getUniformLocation(A,R),H,ie=this;if(/^sampler/.test(L)){var O=A._samplerMap,V=A._bindTextures;Object.defineProperty(A.uniforms,R,{get:function(){return H},set:function(ce){H=ce;var me=O[R]!=null?O[R]:V.length;V[me]=ce,E(W,ce,me),O[R]||(O[R]=me,W.uniform1i(Y,me)),ie.options.autoUpdate&&ie.update()},configurable:!1,enumerable:!0})}else{var Z=L.indexOf("Matrix")===0,$=!Z&&/v$/.test(L),ee=W["uniform".concat(L)].bind(W);Object.defineProperty(A.uniforms,R,{get:function(){return H},set:function(ce){H=ce,typeof ce=="number"&&(ce=[ce]),Z?ee(Y,!1,ce):$?ee(Y,ce):ee.apply(void 0,[Y].concat(d()(ce))),ie.options.autoUpdate&&ie.update()},configurable:!1,enumerable:!0})}}},{key:"_draw",value:function(){var A=this,R=this.program;R.meshData.forEach(function(L,W){var Y=L.positions,H=L.cells,ie=L.instanceCount,O=L.cellsCount,V=L.attributes,Z=L.uniforms,$=L.textureCoord,ee=L.enableBlend,se=A.gl,ce=L.mode!=null?L.mode:se.TRIANGLES;typeof ce=="string"&&(ce=se[ce]),ee?se.enable(se.BLEND):se.disable(se.BLEND),se.bindBuffer(se.ARRAY_BUFFER,R._buffers.verticesBuffer),se.bufferData(se.ARRAY_BUFFER,Y,se.STATIC_DRAW),H&&(se.bindBuffer(se.ELEMENT_ARRAY_BUFFER,R._buffers.cellsBuffer),se.bufferData(se.ELEMENT_ARRAY_BUFFER,H,se.STATIC_DRAW));var me=[];V&&Object.values(V).forEach(function(J){var oe=J.name,K=J.data,te=J.divisor;if(se.bindBuffer(se.ARRAY_BUFFER,R._buffers[oe]),se.bufferData(se.ARRAY_BUFFER,K,se.STATIC_DRAW),te!=null){var w=se.getAttribLocation(R,oe);w>=0&&(se.enableVertexAttribArray(w),me.push(w),se.vertexAttribDivisor?se.vertexAttribDivisor(w,te):A.aia_ext&&A.aia_ext.vertexAttribDivisorANGLE(w,te))}}),Z&&Object.entries(Z).forEach(function(J){var oe=u()(J,2),K=oe[0],te=oe[1];A.uniforms[K]=te});var pe;if(!H){var B=R._dimension;pe=Y.length/B}if(R._enableTextures&&R._buffers.texCoordBuffer){var F=$||M(Y,R._dimension);se.bindBuffer(se.ARRAY_BUFFER,R._buffers.texCoordBuffer),se.bufferData(se.ARRAY_BUFFER,z.FLOAT(F),se.STATIC_DRAW)}ie!=null?(H?se.drawElementsInstanced?se.drawElementsInstanced(ce,O,se.UNSIGNED_SHORT,0,ie):A.aia_ext&&A.aia_ext.drawElementsInstancedANGLE(ce,O,se.UNSIGNED_SHORT,0,ie):se.drawArraysInstanced?se.drawArraysInstanced(ce,0,pe,ie):A.aia_ext.drawArraysInstancedANGLE(ce,0,pe,ie),me.forEach(function(J){se.vertexAttribDivisor?se.vertexAttribDivisor(J,null):A.aia_ext&&A.aia_ext.vertexAttribDivisorANGLE(J,null)})):H?se.drawElements(ce,O,se.UNSIGNED_SHORT,0):se.drawArrays(ce,0,pe)})}},{key:"deleteProgram",value:function(A){var R=this.gl;this.program===A&&(this.startRender=!1,this._renderFrameID&&(cancelAnimationFrame(this._renderFrameID),delete this._renderFrameID),R.useProgram(null));var L=this.programs.indexOf(A);L>=0&&this.programs.splice(L,1),k(R,A),R.deleteProgram(A)}},{key:"setMeshData",value:function(A){var R=this;Array.isArray(A)||(A=[A]);var L=this.program;L.meshData=A.map(function(W){var Y=W.mode,H=W.positions,ie=W.instanceCount,O=W.cells,V=W.cellsCount,Z=W.attributes,$=W.uniforms,ee=W.textureCoord,se=W.enableBlend,ce={positions:z.FLOAT(H),uniforms:$,enableBlend:!!se,textureCoord:z.FLOAT(ee)};if(O&&(ce.cells=z.USHORT(O),ce.cellsCount=V||ce.cells.length),Y!=null&&(ce.mode=Y),ie!=null){if(!R.isWebGL2&&!R.aia_ext)throw new Error("Cannot use instanceCount in this rendering context, use webgl2 context instead.");ce.instanceCount=ie}if(Z){var me={};Object.entries(Z).forEach(function(pe){var B=u()(pe,2),F=B[0],J=B[1];if(!L._attribute[F])L._attribute[F]="ignored";else if(L._attribute[F]!=="ignored"){var oe=L._attribute[F],K=oe.name,te=oe.type,w=J.data||J;if(Array.isArray(w)&&(w=z[te](w)),me[F]={name:K,data:w},J.divisor!=null){if(!R.isWebGL2&&!R.aia_ext)throw new Error("Cannot use divisor in this rendering context, use webgl2 context instead.");me[F].divisor=J.divisor}}}),ce.attributes=me}return ce}),this.options.autoUpdate&&this.update()}},{key:"createProgram",value:function(A,R){var L=this,W=/^\s*uniform\s+sampler/mg.test(A);A==null&&(A=p.default),R==null&&(R=W?m.default:T.default);var Y=this.gl,H=Object(N.createProgram)(Y,R,A);H.shaderText={vertexShader:R,fragmentShader:A},H._buffers={},H._attribute={},H.uniforms={},H._samplerMap={},H._bindTextures=[];var ie=new RegExp("(?:attribute|in) vec(\\d) ".concat(this.options.vertexPosition),"im"),O=R.match(ie);O&&(H._dimension=Number(O[1]));var V=new RegExp("(?:attribute|in) vec(\\d) ".concat(this.options.vertexTextureCoord),"im");O=R.match(V),O&&(H._texCoordSize=Number(O[1]));var Z=/^\s*(?:attribute|in) (\w+?)(\d*) (\w+)/gim;if(O=R.match(Z),O)for(var $=0;$<O.length;$++){var ee=/^\s*(?:attribute|in) (\w+?)(\d*) (\w+)/im,se=O[$].match(ee);if(se&&se[3]!==this.options.vertexPosition&&se[3]!==this.options.vertexTextureCoord){var ce=u()(se,4),me=ce[1],pe=ce[2],B=ce[3];me==="mat"&&(pe=Math.pow(pe,2)),H._buffers[B]=Y.createBuffer(),H._attribute[B]={name:B,type:me,size:Number(pe)||1}}}var F=/^\s*uniform\s+(\w+)\s+(\w+)(\[\d+\])?/mg;O=R.match(F)||[],O=O.concat(A.match(F)||[]),O.forEach(function(oe){var K=oe.match(/^\s*uniform\s+(\w+)\s+(\w+)(\[\d+\])?/),te=K.slice(1),w=u()(te,3),C=w[0],U=w[1],G=w[2];C=D[C],G=!!G,C.indexOf("Matrix")!==0&&G&&(C+="v"),L._declareUniform(H,U,C)}),H._buffers.verticesBuffer=Y.createBuffer(),H._buffers.cellsBuffer=Y.createBuffer();var J=Y.getAttribLocation(H,this.options.vertexTextureCoord);return H._enableTextures=J>=0,H._enableTextures&&(H._buffers.texCoordBuffer=Y.createBuffer()),this.programs.push(H),H}},{key:"useProgram",value:function(A){var R=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.startRender=!1,this._renderFrameID&&(cancelAnimationFrame(this._renderFrameID),delete this._renderFrameID);var L=this.gl;L.useProgram(A);var W=A._dimension;L.bindBuffer(L.ARRAY_BUFFER,A._buffers.verticesBuffer);var Y=L.getAttribLocation(A,this.options.vertexPosition);if(L.vertexAttribPointer(Y,W,L.FLOAT,!1,0,0),L.enableVertexAttribArray(Y),A._enableTextures){L.bindBuffer(L.ARRAY_BUFFER,A._buffers.texCoordBuffer);var H=L.getAttribLocation(A,this.options.vertexTextureCoord);L.vertexAttribPointer(H,A._texCoordSize||2,L.FLOAT,!1,0,0),L.enableVertexAttribArray(H)}if(Object.entries(A._attribute).forEach(function(V){var Z=u()(V,2),$=Z[0],ee=Z[1];if(ee!=="ignored"){var se=ee.size,ce=R[$]||{},me=!!ce.normalize,pe=ce.type||"FLOAT",B=ce.key||$;pe==="UBYTE"&&(pe="UNSIGNED_BYTE"),pe==="USHORT"&&(pe="UNSIGNED_SHORT"),ee.type=pe,B&&B!==$&&(A._attribute[B]=ee),L.bindBuffer(L.ARRAY_BUFFER,A._buffers[$]);var F=L.getAttribLocation(A,$);F>=0&&(L.vertexAttribPointer(F,se,L[pe],me,0,0),L.enableVertexAttribArray(F))}}),!A.meshData){var ie=[[-1,-1,0,1].slice(0,W),[1,-1,0,1].slice(0,W),[1,1,0,1].slice(0,W),[-1,1,0,1].slice(0,W)],O=[[0,1,3],[3,1,2]];this.setMeshData({positions:ie,cells:O})}return A}},{key:"compileSync",value:function(A,R){A=A||p.default;var L={};function W(O){O=O.replace(/^\s*/mg,"");var V=[],Z=O.match(/^#pragma\s+include\s+.*/mg);if(Z){for(var $=0;$<Z.length;$++){var ee=Z[$],se=ee.match(/(?:<|")(.*)(?:>|")/);if(se){var ce=se[0].indexOf("<")===0?"lib":"link",me=se[1];if(me==="graph"&&(me="graphics"),L[me])V.push("/* included ".concat(me," */"));else if(L[me]=!0,ce==="lib"){var pe=W(v[me]);V.push(pe)}else if(ce==="link")throw new Error("Cannot load external links synchronously. Use compile instead of compileSync.")}}V.forEach(function(B){O=O.replace(/^#pragma\s+include\s+.*/m,B)})}return O}var Y=W(A),H=R?W(R):null,ie=this.createProgram(Y,H);return ie}},{key:"compile",value:function(){var j=c()(o.a.mark(function R(L,W){var Y,H,ie,O,V,Z;return o.a.wrap(function(ee){for(;;)switch(ee.prev=ee.next){case 0:return ie=function(){return ie=c()(o.a.mark(function ce(me){var pe,B,F,J,oe,K,te,w,C;return o.a.wrap(function(G){for(;;)switch(G.prev=G.next){case 0:if(me=me.replace(/^\s*/mg,""),pe=[],B=me.match(/^#pragma\s+include\s+.*/mg),!B){G.next=36;break}F=0;case 5:if(!(F<B.length)){G.next=35;break}if(J=B[F],oe=J.match(/(?:<|")(.*)(?:>|")/),!oe){G.next=32;break}if(K=oe[0].indexOf("<")===0?"lib":"link",te=oe[1],te==="graph"&&(te="graphics"),Y[te]){G.next=31;break}if(Y[te]=!0,K!=="lib"){G.next=21;break}return G.next=17,H(v[te]);case 17:w=G.sent,pe.push(w),G.next=29;break;case 21:if(K!=="link"){G.next=29;break}return G.next=24,z.fetchShader(te);case 24:return C=G.sent,G.next=27,H(C);case 27:C=G.sent,pe.push(C);case 29:G.next=32;break;case 31:pe.push("/* included ".concat(te," */"));case 32:F++,G.next=5;break;case 35:pe.forEach(function(_){me=me.replace(/^#pragma\s+include\s+.*/m,_)});case 36:return G.abrupt("return",me);case 37:case"end":return G.stop()}},ce)})),ie.apply(this,arguments)},H=function(ce){return ie.apply(this,arguments)},L=L||p.default,Y={},ee.next=6,H(L);case 6:if(O=ee.sent,!W){ee.next=13;break}return ee.next=10,H(W);case 10:ee.t0=ee.sent,ee.next=14;break;case 13:ee.t0=null;case 14:return V=ee.t0,Z=this.createProgram(O,V),ee.abrupt("return",Z);case 17:case"end":return ee.stop()}},R,this)}));function A(R,L){return j.apply(this,arguments)}return A}()},{key:"load",value:function(){var j=c()(o.a.mark(function R(L){var W,Y=arguments;return o.a.wrap(function(ie){for(;;)switch(ie.prev=ie.next){case 0:return W=Y.length>1&&Y[1]!==void 0?Y[1]:null,ie.next=3,z.fetchShader(L);case 3:if(L=ie.sent,!W){ie.next=8;break}return ie.next=7,z.fetchShader(W);case 7:W=ie.sent;case 8:return ie.abrupt("return",this.compile(L,W));case 9:case"end":return ie.stop()}},R,this)}));function A(R){return j.apply(this,arguments)}return A}()},{key:"createTexture",value:function(){var A=this,R=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,L=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},W=L.wrapS,Y=W===void 0?this.gl.CLAMP_TO_EDGE:W,H=L.wrapT,ie=H===void 0?this.gl.CLAMP_TO_EDGE:H,O=L.minFilter,V=O===void 0?this.gl.LINEAR:O,Z=L.magFilter,$=Z===void 0?this.gl.LINEAR:Z,ee=this.gl,se=Array.isArray(R)?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 ce=ee.createTexture();ee.bindTexture(se,ce),ee.pixelStorei(ee.UNPACK_FLIP_Y_WEBGL,!0);var me=this.canvas,pe=me.width,B=me.height;if(R)if(se===ee.TEXTURE_CUBE_MAP)for(var F=0;F<6;F++)ee.texImage2D(ee.TEXTURE_CUBE_MAP_POSITIVE_X+F,0,ee.RGBA,ee.RGBA,ee.UNSIGNED_BYTE,R[F]);else ee.texImage2D(se,0,ee.RGBA,ee.RGBA,ee.UNSIGNED_BYTE,R);else if(se===ee.TEXTURE_CUBE_MAP)for(var J=0;J<6;J++)this.gl.texImage2D(this.gl.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,ee.RGBA,pe,B,0,ee.RGBA,ee.UNSIGNED_BYTE,null);else ee.texImage2D(se,0,ee.RGBA,pe,B,0,ee.RGBA,ee.UNSIGNED_BYTE,null);return ee.texParameteri(se,ee.TEXTURE_MIN_FILTER,V),ee.texParameteri(se,ee.TEXTURE_MAG_FILTER,$),ee.texParameteri(se,ee.TEXTURE_WRAP_S,Y),ee.texParameteri(se,ee.TEXTURE_WRAP_T,ie),se===ee.TEXTURE_CUBE_MAP&&(R.width=R[0].width,R.height=R[0].height),ee.bindTexture(se,null),ce._img=R||{width:pe,height:B},ce.delete=function(){A.deleteTexture(ce)},ce}},{key:"deleteTexture",value:function(A){var R=A._img;this.gl.deleteTexture(A),typeof R.close=="function"&&R.close()}},{key:"loadTexture",value:function(){var j=c()(o.a.mark(function R(L){var W,Y,H,ie,O=arguments;return o.a.wrap(function(Z){for(;;)switch(Z.prev=Z.next){case 0:return W=O.length>1&&O[1]!==void 0?O[1]:{},Y=W.useImageBitmap,H=Y===void 0?!0:Y,Z.next=3,z.loadImage(L,{useImageBitmap:H});case 3:return ie=Z.sent,Z.abrupt("return",this.createTexture(ie));case 5:case"end":return Z.stop()}},R,this)}));function A(R){return j.apply(this,arguments)}return A}()},{key:"createFBO",value:function(){var A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},R=A.color,L=R===void 0?1:R,W=A.blend,Y=W===void 0?!1:W,H=A.depth,ie=H===void 0?this.options.depth!==!1:H,O=A.stencil,V=O===void 0?!!this.options.stencil:O,Z=this.gl,$=Z.createFramebuffer();Z.bindFramebuffer(Z.FRAMEBUFFER,$);for(var ee=[],se=0;se<L;se++){var ce=this.createTexture();Z.framebufferTexture2D(Z.FRAMEBUFFER,Z.COLOR_ATTACHMENT0+se,Z.TEXTURE_2D,ce,0),ee.push(ce)}$.textures=ee,$.texture=ee[0],$.blend=Y;var me=this.canvas,pe=me.width,B=me.height;return ie&&!V&&($.depthBuffer=Z.createRenderbuffer(),Z.bindRenderbuffer(Z.RENDERBUFFER,$.depthBuffer),Z.renderbufferStorage(Z.RENDERBUFFER,Z.DEPTH_COMPONENT16,pe,B),Z.framebufferRenderbuffer(Z.FRAMEBUFFER,Z.DEPTH_ATTACHMENT,Z.RENDERBUFFER,$.depthBuffer)),V&&!ie&&($.stencilBuffer=Z.createRenderbuffer(),Z.bindRenderbuffer(Z.RENDERBUFFER,$.stencilBuffer),Z.renderbufferStorage(Z.RENDERBUFFER,Z.STENCIL_INDEX8,pe,B),Z.framebufferRenderbuffer(Z.FRAMEBUFFER,Z.STENCIL_ATTACHMENT,Z.RENDERBUFFER,$.stencilBuffer)),ie&&V&&($.depthStencilBuffer=Z.createRenderbuffer(),Z.bindRenderbuffer(Z.RENDERBUFFER,$.depthStencilBuffer),Z.renderbufferStorage(Z.RENDERBUFFER,Z.DEPTH_STENCIL,pe,B),Z.framebufferRenderbuffer(Z.FRAMEBUFFER,Z.DEPTH_STENCIL_ATTACHMENT,Z.RENDERBUFFER,$.depthStencilBuffer)),Z.bindFramebuffer(Z.FRAMEBUFFER,null),$}},{key:"bindFBO",value:function(){var A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null;this.fbo=A}},{key:"render",value:function(){var A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};A.clearBuffer,this.startRender=!0;var R=this.gl,L=this.program;L||(L=this.createProgram(),this.useProgram(L)),this.fbo&&R.bindFramebuffer(R.FRAMEBUFFER,this.fbo);var W=this.options.depth;W&&R.enable(R.DEPTH_TEST),this.gl.clear(this.gl.COLOR_BUFFER_BIT|(W?this.gl.DEPTH_BUFFER_BIT:0)|(this.options.stencil?this.gl.STENCIL_BUFFER_BIT:0));var Y=this._renderFrameID;this._draw(),this.fbo&&R.bindFramebuffer(R.FRAMEBUFFER,null),this._renderFrameID===Y&&(this._renderFrameID=null)}},{key:"update",value:function(){this.startRender&&this._renderFrameID==null&&(this._renderFrameID=requestAnimationFrame(this.render.bind(this)))}},{key:"program",get:function(){var A=this.gl;return A.getParameter(A.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 A=this.program;if(!A||!A.uniforms)throw Error("No avaliable program.");return A.uniforms}}]),z}();I()(P,"defaultOptions",{preserveDrawingBuffer:!0,autoUpdate:!0,vertexPosition:"a_vertexPosition",vertexTextureCoord:"a_vertexTextureCoord",webgl2:!1}),I()(P,"UBYTE",P.UNSIGNED_BYTE),I()(P,"USHORT",P.UNSIGNED_SHORT),I()(P,"fetchShader",N.fetchShader),I()(P,"loadImage",N.loadImage)},function(e,r,n){e.exports=n(28)},function(e,r,n){var i=function(o){var a=Object.prototype,c=a.hasOwnProperty,l,u=typeof Symbol=="function"?Symbol:{},h=u.iterator||"@@iterator",d=u.asyncIterator||"@@asyncIterator",f=u.toStringTag||"@@toStringTag";function g(O,V,Z){return Object.defineProperty(O,V,{value:Z,enumerable:!0,configurable:!0,writable:!0}),O[V]}try{g({},"")}catch{g=function(V,Z,$){return V[Z]=$}}function y(O,V,Z,$){var ee=V&&V.prototype instanceof m?V:m,se=Object.create(ee.prototype),ce=new Y($||[]);return se._invoke=A(O,Z,ce),se}o.wrap=y;function S(O,V,Z){try{return{type:"normal",arg:O.call(V,Z)}}catch($){return{type:"throw",arg:$}}}var b="suspendedStart",I="suspendedYield",N="executing",T="completed",p={};function m(){}function v(){}function M(){}var k={};k[h]=function(){return this};var E=Object.getPrototypeOf,D=E&&E(E(H([])));D&&D!==a&&c.call(D,h)&&(k=D);var P=M.prototype=m.prototype=Object.create(k);v.prototype=P.constructor=M,M.constructor=v,v.displayName=g(M,f,"GeneratorFunction");function z(O){["next","throw","return"].forEach(function(V){g(O,V,function(Z){return this._invoke(V,Z)})})}o.isGeneratorFunction=function(O){var V=typeof O=="function"&&O.constructor;return V?V===v||(V.displayName||V.name)==="GeneratorFunction":!1},o.mark=function(O){return Object.setPrototypeOf?Object.setPrototypeOf(O,M):(O.__proto__=M,g(O,f,"GeneratorFunction")),O.prototype=Object.create(P),O},o.awrap=function(O){return{__await:O}};function j(O,V){function Z(se,ce,me,pe){var B=S(O[se],O,ce);if(B.type==="throw")pe(B.arg);else{var F=B.arg,J=F.value;return J&&typeof J=="object"&&c.call(J,"__await")?V.resolve(J.__await).then(function(oe){Z("next",oe,me,pe)},function(oe){Z("throw",oe,me,pe)}):V.resolve(J).then(function(oe){F.value=oe,me(F)},function(oe){return Z("throw",oe,me,pe)})}}var $;function ee(se,ce){function me(){return new V(function(pe,B){Z(se,ce,pe,B)})}return $=$?$.then(me,me):me()}this._invoke=ee}z(j.prototype),j.prototype[d]=function(){return this},o.AsyncIterator=j,o.async=function(O,V,Z,$,ee){ee===void 0&&(ee=Promise);var se=new j(y(O,V,Z,$),ee);return o.isGeneratorFunction(V)?se:se.next().then(function(ce){return ce.done?ce.value:se.next()})};function A(O,V,Z){var $=b;return function(se,ce){if($===N)throw new Error("Generator is already running");if($===T){if(se==="throw")throw ce;return ie()}for(Z.method=se,Z.arg=ce;;){var me=Z.delegate;if(me){var pe=R(me,Z);if(pe){if(pe===p)continue;return pe}}if(Z.method==="next")Z.sent=Z._sent=Z.arg;else if(Z.method==="throw"){if($===b)throw $=T,Z.arg;Z.dispatchException(Z.arg)}else Z.method==="return"&&Z.abrupt("return",Z.arg);$=N;var B=S(O,V,Z);if(B.type==="normal"){if($=Z.done?T:I,B.arg===p)continue;return{value:B.arg,done:Z.done}}else B.type==="throw"&&($=T,Z.method="throw",Z.arg=B.arg)}}}function R(O,V){var Z=O.iterator[V.method];if(Z===l){if(V.delegate=null,V.method==="throw"){if(O.iterator.return&&(V.method="return",V.arg=l,R(O,V),V.method==="throw"))return p;V.method="throw",V.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var $=S(Z,O.iterator,V.arg);if($.type==="throw")return V.method="throw",V.arg=$.arg,V.delegate=null,p;var ee=$.arg;if(!ee)return V.method="throw",V.arg=new TypeError("iterator result is not an object"),V.delegate=null,p;if(ee.done)V[O.resultName]=ee.value,V.next=O.nextLoc,V.method!=="return"&&(V.method="next",V.arg=l);else return ee;return V.delegate=null,p}z(P),g(P,f,"Generator"),P[h]=function(){return this},P.toString=function(){return"[object Generator]"};function L(O){var V={tryLoc:O[0]};1 in O&&(V.catchLoc=O[1]),2 in O&&(V.finallyLoc=O[2],V.afterLoc=O[3]),this.tryEntries.push(V)}function W(O){var V=O.completion||{};V.type="normal",delete V.arg,O.completion=V}function Y(O){this.tryEntries=[{tryLoc:"root"}],O.forEach(L,this),this.reset(!0)}o.keys=function(O){var V=[];for(var Z in O)V.push(Z);return V.reverse(),function $(){for(;V.length;){var ee=V.pop();if(ee in O)return $.value=ee,$.done=!1,$}return $.done=!0,$}};function H(O){if(O){var V=O[h];if(V)return V.call(O);if(typeof O.next=="function")return O;if(!isNaN(O.length)){var Z=-1,$=function ee(){for(;++Z<O.length;)if(c.call(O,Z))return ee.value=O[Z],ee.done=!1,ee;return ee.value=l,ee.done=!0,ee};return $.next=$}}return{next:ie}}o.values=H;function ie(){return{value:l,done:!0}}return Y.prototype={constructor:Y,reset:function(O){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(W),!O)for(var V in this)V.charAt(0)==="t"&&c.call(this,V)&&!isNaN(+V.slice(1))&&(this[V]=l)},stop:function(){this.done=!0;var O=this.tryEntries[0],V=O.completion;if(V.type==="throw")throw V.arg;return this.rval},dispatchException:function(O){if(this.done)throw O;var V=this;function Z(pe,B){return se.type="throw",se.arg=O,V.next=pe,B&&(V.method="next",V.arg=l),!!B}for(var $=this.tryEntries.length-1;$>=0;--$){var ee=this.tryEntries[$],se=ee.completion;if(ee.tryLoc==="root")return Z("end");if(ee.tryLoc<=this.prev){var ce=c.call(ee,"catchLoc"),me=c.call(ee,"finallyLoc");if(ce&&me){if(this.prev<ee.catchLoc)return Z(ee.catchLoc,!0);if(this.prev<ee.finallyLoc)return Z(ee.finallyLoc)}else if(ce){if(this.prev<ee.catchLoc)return Z(ee.catchLoc,!0)}else if(me){if(this.prev<ee.finallyLoc)return Z(ee.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(O,V){for(var Z=this.tryEntries.length-1;Z>=0;--Z){var $=this.tryEntries[Z];if($.tryLoc<=this.prev&&c.call($,"finallyLoc")&&this.prev<$.finallyLoc){var ee=$;break}}ee&&(O==="break"||O==="continue")&&ee.tryLoc<=V&&V<=ee.finallyLoc&&(ee=null);var se=ee?ee.completion:{};return se.type=O,se.arg=V,ee?(this.method="next",this.next=ee.finallyLoc,p):this.complete(se)},complete:function(O,V){if(O.type==="throw")throw O.arg;return O.type==="break"||O.type==="continue"?this.next=O.arg:O.type==="return"?(this.rval=this.arg=O.arg,this.method="return",this.next="end"):O.type==="normal"&&V&&(this.next=V),p},finish:function(O){for(var V=this.tryEntries.length-1;V>=0;--V){var Z=this.tryEntries[V];if(Z.finallyLoc===O)return this.complete(Z.completion,Z.afterLoc),W(Z),p}},catch:function(O){for(var V=this.tryEntries.length-1;V>=0;--V){var Z=this.tryEntries[V];if(Z.tryLoc===O){var $=Z.completion;if($.type==="throw"){var ee=$.arg;W(Z)}return ee}}throw new Error("illegal catch attempt")},delegateYield:function(O,V,Z){return this.delegate={iterator:H(O),resultName:V,nextLoc:Z},this.method==="next"&&(this.arg=l),p}},o}(e.exports);try{regeneratorRuntime=i}catch{Function("r","regeneratorRuntime = r")(i)}},function(e,r){function n(o,a,c,l,u,h,d){try{var f=o[h](d),g=f.value}catch(y){c(y);return}f.done?a(g):Promise.resolve(g).then(l,u)}function i(o){return function(){var a=this,c=arguments;return new Promise(function(l,u){var h=o.apply(a,c);function d(g){n(h,l,u,d,f,"next",g)}function f(g){n(h,l,u,d,f,"throw",g)}d(void 0)})}}e.exports=i},function(e,r){function n(i,o,a){return o in i?Object.defineProperty(i,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[o]=a,i}e.exports=n},function(e,r,n){n.r(r),n.d(r,"setupWebGL",function(){return d}),n.d(r,"createProgram",function(){return f}),n.d(r,"pointsToBuffer",function(){return g}),n.d(r,"loadImage",function(){return S}),n.d(r,"fetchShader",function(){return I});var i=n(27),o=n.n(i),a=n(29),c=n.n(a),l=n(32),u=n.n(l);n(1).glMatrix.setMatrixArrayType(Array);function h(T,p){for(var m=["webgl","experimental-webgl","webkit-3d","moz-webgl"],v=null,M=0;M<m.length;++M){try{v=T.getContext(m[M],p)}catch{}if(v)break}return v}function d(T,p){var m=h(T,p);if(!m)throw new Error("Sorry, your browser doesn't support WebGL.");return m}function f(T,p,m){var v=T.createShader(T.VERTEX_SHADER);if(T.shaderSource(v,p),T.compileShader(v),!T.getShaderParameter(v,T.COMPILE_STATUS)){var M="Vertex shader failed to compile. The error log is:".concat(T.getShaderInfoLog(v));throw new Error(M)}var k=T.createShader(T.FRAGMENT_SHADER);if(T.shaderSource(k,m),T.compileShader(k),!T.getShaderParameter(k,T.COMPILE_STATUS)){var E="Fragment shader failed to compile. The error log is:".concat(T.getShaderInfoLog(k));throw new Error(E)}var D=T.createProgram();if(T.attachShader(D,v),T.attachShader(D,k),T.linkProgram(D),!T.getProgramParameter(D,T.LINK_STATUS)){var P="Shader program failed to link. The error log is:".concat(T.getProgramInfoLog(D));throw new Error(P)}return T.deleteShader(v),T.deleteShader(k),D}function g(T){var p=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 p))throw new TypeError("Wrong buffer type.");if(T==null||T instanceof p)return T;if(T[0]==null||T[0].length==null)return m?(m.set(T,0),m):new p(T);var v=T[0].length,M=T.length;m||(m=new p(v*M));for(var k=0,E=0;E<M;E++)for(var D=0;D<v;D++)m[k++]=T[E][D];return m}var y={};function S(T){var p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},m=p.useImageBitmap,v=m===void 0?!0:m,M=p.alias,k=M===void 0?null:M;if(!y[T]){if(typeof Image=="function"){var E=new Image;typeof T=="string"&&!((typeof location>"u"?"undefined":u()(location))==="object"&&/^file:/.test(location.href))&&!/^data:/.test(T)&&(E.crossOrigin="anonymous"),y[T]=new Promise(function(D){E.onload=function(){v&&typeof createImageBitmap=="function"?createImageBitmap(E,{imageOrientation:"flipY"}).then(function(P){y[T]=P,k&&(y[k]=P),D(P)}):(y[T]=E,k&&(y[k]=E),D(E))},E.src=T}),k&&(y[k]=y[T])}else if(typeof fetch=="function")return fetch(T,{method:"GET",mode:"cors",cache:"default"}).then(function(D){return D.blob()}).then(function(D){return createImageBitmap(D,{imageOrientation:"flipY"}).then(function(P){return y[T]=P,k&&(y[k]=P),P})})}return y[T]}var b={};function I(T){return N.apply(this,arguments)}function N(){return N=c()(o.a.mark(function T(p){var m,v;return o.a.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:if(!b[p]){k.next=2;break}return k.abrupt("return",b[p]);case 2:return k.next=4,fetch(p);case 4:if(m=k.sent,!(m.status>=200&&m.status<300)){k.next=11;break}return k.next=8,m.text();case 8:return v=k.sent,b[p]=v,k.abrupt("return",v);case 11:throw new Error("Shader loaded error.");case 12:case"end":return k.stop()}},T)})),N.apply(this,arguments)}},function(e,r){function n(i){"@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(i)}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 i=n(19),o=n.n(i),a=n(13),c=n.n(a),l=n(27),u=n.n(l),h=n(29),d=n.n(h),f=n(23),g=n.n(f),y=n(24),S=n.n(y),b=n(37),I=n(41);n(1).glMatrix.setMatrixArrayType(Array);var N=Symbol("transform"),T=function(){function p(m,v){g()(this,p),this.context=m.getContext("2d"),this.options=v,this[N]=[1,0,0,1,0,0]}return S()(p,[{key:"createTexture",value:function(v){var M={_img:v};return M}},{key:"loadTexture",value:function(){var m=d()(u.a.mark(function M(k){var E;return u.a.wrap(function(P){for(;;)switch(P.prev=P.next){case 0:return P.next=2,b.default.loadImage(k,{useImageBitmap:!1});case 2:return E=P.sent,P.abrupt("return",this.createTexture(E));case 4:case"end":return P.stop()}},M,this)}));function v(M){return m.apply(this,arguments)}return v}()},{key:"deleteTexture",value:function(v){return v}},{key:"clear",value:function(v,M,k,E){var D=this.context;v=v||0,M=M||0,k=k||D.canvas.width-v,E=E||D.canvas.height-M,D.clearRect(v,M,k,E)}},{key:"drawMeshCloud",value:function(v){for(var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},k=M.clear,E=k===void 0?!1:k,D=[],P=0;P<v.amount;P++){var z=v.getTransform(P),j=v.getTextureFrame(P);j&&(j=j._img);var A=v.getFilter(P),R=v.getCloudRGBA(P),L=R.fill,W=R.stroke;D.push({mesh:v.mesh,_cloudOptions:[L,W,j,z,A]})}v.beforeRender&&v.beforeRender(this.context,v),this.drawMeshes(D,{clear:E,hook:!1}),v.afterRender&&v.afterRender(this.context,v)}},{key:"drawMeshes",value:function(v){var M=this,k=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},E=k.clear,D=E===void 0?!1:E,P=k.hook,z=P===void 0?!0:P,j=this.context;D&&j.clearRect(0,0,j.canvas.width,j.canvas.height);var A=null,R=j.canvas,L=R.width,W=R.height,Y=v.length;v.forEach(function(H,ie){var O,V,Z,$,ee;if(z&&H.beforeRender&&H.beforeRender(j,H),H._cloudOptions){var se=c()(H._cloudOptions,5);O=se[0],V=se[1],Z=se[2],$=se[3],ee=se[4],H=H.mesh}var ce=H.filter;if(ee&&(ce=ce?"".concat(ce," ").concat(ee):ee),ce&&!M.filterBuffer&&M.filterBuffer!==!1){var me=b.default.createCanvas(L,W);me?M.filterBuffer=me.getContext("2d"):M.filterBuffer=!1}if(A&&A!==ce&&(Object(I.applyFilter)(M.filterBuffer,A),j.drawImage(M.filterBuffer.canvas,0,0,L,W),M.filterBuffer.clearRect(0,0,L,W),A=null),ce&&M.filterBuffer){var pe;M.filterBuffer.save(),(pe=M.filterBuffer).transform.apply(pe,o()(M[N])),Object(I.drawMesh2D)(H,M.filterBuffer,!1,O,V,Z,$),M.filterBuffer.restore(),ie===Y-1?(Object(I.applyFilter)(M.filterBuffer,ce),j.drawImage(M.filterBuffer.canvas,0,0,L,W),M.filterBuffer.clearRect(0,0,L,W)):A=ce}else j.save(),j.transform.apply(j,o()(M[N])),Object(I.drawMesh2D)(H,j,!1,O,V,Z,$),j.restore();z&&H.afterRender&&H.afterRender(j,H)})}},{key:"setTransform",value:function(v){this[N]=v}}]),p}()},function(e,r,n){n.r(r),(function(i){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 f={};function g(T,p){var m=T.style,v=T.variant,M=T.weight,k=T.stretch,E=T.size,D=T.pxLineHeight,P=T.family;return k==="normal"?"".concat(m," ").concat(v," ").concat(M," ").concat(E*p,"px/").concat(D*p,"px ").concat(P):"".concat(m," ").concat(v," ").concat(M," ").concat(k," ").concat(E*p,"px/").concat(D*p,"px ").concat(P)}function y(T,p){var m=p.font,v=p.fillColor,M=p.strokeColor,k=p.strokeWidth,E=p.ratio,D=E===void 0?1:E,P=p.textCanvas,z=p.cachable,j=z===void 0?!1:z,A;if(j){A=[T,m,String(v),String(M),String(k)].join("###");var R=f[A];if(R)return R}P||(P=I(1,1));var L=P.getContext("2d");L.save(),L.font=m;var W=L.measureText(T),Y=W.width;L.restore();var H=Object(h.default)(m),ie=Math.max(H.pxLineHeight,H.pxHeight*1.13);/italic|oblique/.test(m)&&(Y+=ie*Math.tan(15*Math.PI/180)),!v&&!M&&(v="#000");var O=L.canvas,V=Math.ceil(Y),Z=Math.ceil(ie);O.width=Math.round(V*D),O.height=Math.round(Z*D),L.save(),L.font=g(H,D),L.textAlign="center",L.textBaseline="middle";var $=O.height*.5+H.pxHeight*.05*D,ee=O.width*.5;if(v){if(Array.isArray(v))v=Object(d.default)(v);else if(v.vector){var se,ce=v,me=ce.vector,pe=ce.colors;me.length===6?se=L.createRadialGradient.apply(L,l()(me)):se=L.createLinearGradient.apply(L,l()(me)),pe.forEach(function(te){var w=te.offset,C=te.color;se.addColorStop(w,C)}),v=se}L.fillStyle=v,L.fillText(T,ee,$)}if(M){if(L.lineWidth=k*D,Array.isArray(M))M=Object(d.default)(M);else if(M.vector){var B,F=M,J=F.vector,oe=F.colors;J.length===6?B=L.createRadialGradient.apply(L,l()(J)):B=L.createLinearGradient.apply(L,l()(J)),oe.forEach(function(te){var w=te.offset,C=te.color;B.addColorStop(w,C)}),M=B}L.strokeStyle=M,L.strokeText(T,ee,$)}L.restore();var K={image:P,rect:[0,0,V,Z]};return j&&(f[A]=K),K}var S=!1;if((typeof navigator>"u"?"undefined":a()(navigator))==="object"&&typeof navigator.userAgent=="string"){var b=navigator.userAgent.toLowerCase().match(/chrome\/(\d+)/);b&&(S=Number(b[1])<70)}function I(T,p){var m=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},v=m.offscreen||!S&&m.offscreen!==!1,M;return typeof i<"u"&&typeof i.createCanvas=="function"?M=i.createCanvas(T,p,m):v&&typeof OffscreenCanvas=="function"?M=new OffscreenCanvas(T,p):(M=document.createElement("canvas"),M.width=T,M.height=p),M}var N={createCanvas:I,createText:y,loadImage:u.default.loadImage};r.default=N}).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 b}),n(1).glMatrix.setMatrixArrayType(Array);function i(I,N){if(typeof I=="string"){var T=I.trim().match(/^([\d.]+)(px|pt|pc|in|cm|mm|em|ex|rem|q|vw|vh|vmax|vmin|%)$/);T?I={size:parseFloat(T[1]),unit:T[2]}:I={size:parseInt(I,10),unit:"px"}}var p=I,m=p.size,v=p.unit;if(v==="pt")m/=.75;else if(v==="pc")m*=16;else if(v==="in")m*=96;else if(v==="cm")m*=96/2.54;else if(v==="mm")m*=96/25.4;else if(v==="em"||v==="rem"||v==="ex"){if(!N&&typeof getComputedStyle=="function"&&typeof document<"u"){var M=getComputedStyle(document.documentElement).fontSize;N=i(M,16)}m*=N,v==="ex"&&(m/=2)}else if(v==="q")m*=96/25.4/4;else if(v==="vw"||v==="vh"){if(typeof document<"u"){var k=v==="vw"?document.documentElement.clientWidth:document.documentElement.clientHeight;m*=k/100}}else if((v==="vmax"||v==="vmin")&&typeof document<"u"){var E=document.documentElement.clientWidth,D=document.documentElement.clientHeight;v==="vmax"?m*=Math.max(E,D)/100:m*=Math.min(E,D)/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"),f=new RegExp("(".concat(a,") +"),"i"),g=new RegExp("(".concat(c,") +"),"i"),y=new RegExp("(".concat(l,") +"),"i"),S=new RegExp("([\\d\\.]+)("+u+")(?:\\/([\\d\\.]+)("+u+"))? *((?:"+h+")( *, *(?:"+h+"))*)");function b(I,N){var T=S.exec(I);if(T){var p=parseFloat(T[3]),m={weight:"normal",style:"normal",stretch:"normal",variant:"normal",size:parseFloat(T[1]),unit:T[2],lineHeight:Number.isFinite(p)?p:void 0,lineHeightUnit:T[4],family:T[5].replace(/ *, */g,",")},v=I.substring(0,T.index),M=d.exec(v),k=f.exec(v),E=g.exec(v),D=y.exec(v);return M&&(m.weight=M[1]),k&&(m.style=k[1]),E&&(m.variant=E[1]),D&&(m.stretch=D[1]),m.pxHeight=i({size:m.size,unit:m.unit},N),m.pxLineHeight=i({size:m.lineHeight||m.size,unit:m.lineHeightUnit||m.unit},N),m}}},function(e,r,n){n.r(r),n.d(r,"default",function(){return i}),n(1).glMatrix.setMatrixArrayType(Array);function i(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 f});var i=n(19),o=n.n(i),a=n(1),c=n(40),l=n(39),u=n(42);n(1).glMatrix.setMatrixArrayType(Array);function h(g,y){var S=g.canvas;g.save(),g.filter=y,g.drawImage(S,0,0,S.width,S.height),g.restore()}function d(g,y){var S=/rgba\((\d+),(\d+),(\d+),(\d+)\)/;g=g.match(S).slice(1,5).map(Number),y=y.match(S).slice(1,5).map(Number);for(var b=[],I=y[3],N=0;N<4;N++)b[N]=Object(u.mix)(g[N],y[N],I);return"rgba(".concat(b.join(),")")}function f(g,y){var S=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,b=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null,I=arguments.length>4&&arguments[4]!==void 0?arguments[4]:null,N=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null,T=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null;y.save();var p=!1,m=!1;if(y.globalAlpha=g.getOpacity(),g._updateMatrix){var v=g.transformScale/g.contours.scale;v>1.5&&g.accurate(g.transformScale)}if(g.lineWidth){var M=g.gradient&&g.gradient.stroke;if(M){var k=M,E=k.vector,D=k.colors;if(E.length===6)M=y.createRadialGradient.apply(y,o()(E));else if(E.length===4)M=y.createLinearGradient.apply(y,o()(E));else if(E.length===3)M=y.createCircularGradient.apply(y,o()(E));else throw new TypeError("Invalid vector dimension.");D.forEach(function(H){var ie=H.offset,O=H.color,V=Object(c.default)(O);I&&(V=d(V,I)),M.addColorStop(ie,V)}),y.strokeStyle=M,p=!0}else g.strokeStyle&&(I?y.strokeStyle=d(g.strokeStyle,I):y.strokeStyle=g.strokeStyle,p=!0)}p&&(y.lineWidth=g.lineWidth,y.lineJoin=g.lineJoin,y.lineCap=g.lineCap,y.miterLimit=g.miterLimit,g.lineDash&&(y.setLineDash(g.lineDash),g.lineDashOffset&&(y.lineDashOffset=g.lineDashOffset)));var P=g.gradient&&g.gradient.fill;if(P){var z=P,j=z.vector,A=z.colors;if(j.length===6)P=y.createRadialGradient.apply(y,o()(j));else if(j.length===4)P=y.createLinearGradient.apply(y,o()(j));else if(j.length===3)P=y.createCircularGradient.apply(y,o()(j));else throw new TypeError("Invalid vector dimension.");A.forEach(function(H){var ie=H.offset,O=H.color,V=Object(c.default)(O);I&&(V=d(V,I)),P.addColorStop(ie,V)}),y.fillStyle=P,m=!0}else g.fillStyle&&(b?y.fillStyle=d(g.fillStyle,b):y.fillStyle=g.fillStyle,m=!0);if(T&&y.transform.apply(y,o()(T)),y.transform.apply(y,o()(g.transformMatrix)),g.clipPath){var R=g.clipPath,L=new Path2D(R);y.clip(L)}var W=g.contours.length;if(g.contours.forEach(function(H,ie){var O=H.length,V=O>1&&a.vec2.equals(H[0],H[O-1]),Z=ie===W-1&&g.texture;if(H&&O>0){if(m||p||Z){y.beginPath(),y.moveTo.apply(y,o()(H[0]));for(var $=1;$<O;$++)$===O-1&&V?y.closePath():y.lineTo.apply(y,o()(H[$]))}if(m&&y.fill(g.fillRule),Z){y.save(),y.clip();var ee=g.texture,se=ee.image,ce=ee.options;if(N&&(se=N),ce.repeat&&console.warn("Context 2D not supported image repeat yet."),se.font){ce.scale&&console.warn("Context 2D not supported text scale yet."),ce.srcRect&&console.warn("Context 2D not supported text srcRect yet.");var me=se,pe=me.font,B=me.fillColor,F=me.strokeColor,J=me.strokeWidth,oe=me.text;!B&&!F&&(B="#000"),Array.isArray(B)&&(B=Object(c.default)(B)),Array.isArray(F)&&(F=Object(c.default)(F)),y.font=pe;var K=y.measureText(oe),te=K.width,w=Object(l.default)(pe),C=Math.max(w.pxLineHeight,w.pxHeight*1.13);y.textAlign="center",y.textBaseline="middle";var U=ce.rect,G=U[0]+C*.5+w.pxHeight*.06,_=U[1]+te*.5;U[2]!=null&&y.scale(U[2]/te,U[3]/C),B&&(y.fillStyle=B,y.fillText(oe,_,G)),F&&(y.lineWidth=J,y.strokeStyle=F,y.strokeText(oe,_,G))}else{var re=ce.rect,ne=ce.srcRect;ce.scale&&(re=[0,0,y.canvas.width,y.canvas.height]),ce.rotated&&re&&(re=[-re[1],re[0],re[3],re[2]]),ne&&(re=re||[0,0,ne[2],ne[3]]),ce.rotated&&(y.translate(0,re?re[2]:se.width),y.rotate(-.5*Math.PI)),ne?y.drawImage.apply(y,[se].concat(o()(ne),o()(re))):re?y.drawImage.apply(y,[se].concat(o()(re))):y.drawImage(se,0,0)}y.restore()}p&&y.stroke()}}),y.restore(),S){var Y=g.filter;Y&&h(y,Y)}}},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 i=n(13),o=n.n(i);n(1).glMatrix.setMatrixArrayType(Array);function a(u,h,d){if(h>d){var f=[d,h];h=f[0],d=f[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),f=d[0],g=d[1];return[f*h[0]+g*h[2]+h[4],f*h[1]+g*h[3]+h[5]]}},function(e,r,n){n.r(r),n.d(r,"default",function(){return f});var i=n(27),o=n.n(i),a=n(44),c=n(45);n(1).glMatrix.setMatrixArrayType(Array);var l=o.a.mark(f);function u(g,y,S){var b=g.uniforms||{},I=y.uniforms||{};if(b.u_texSampler&&I.u_texSampler&&b.u_texSampler!==I.u_texSampler)return!1;var N=Object.keys(b),T=Object.keys(I),p=N.indexOf("u_texSampler"),m=T.indexOf("u_texSampler");if(p>=0&&N.splice(p,1),m>=0&&T.splice(m,1),N.length!==T.length)return!1;var v=N.every(function(k){var E=b[k],D=I[k];if(E===D)return!0;if(E.length&&D.length&&E.length===D.length){for(var P=0;P<E.length;P++)if(E[P]!==D[P])return!1;return!0}return!1});if(v){if(b.u_texSampler&&!I.u_texSampler)y.setTexture(b.u_texSampler,{hidden:!0});else if(!b.u_texSampler&&I.u_texSampler)for(var M=0;M<S.length;M++)S[M].setTexture(I.u_texSampler,{hidden:!0})}return v}var h={};function d(g,y){if(g.length){var S=Object(a.default)(g,h);return S.enableBlend=y,g[0].filterCanvas&&(S.filterCanvas=!0),S.packIndex=g[0].packIndex,S.packLength=g.length,S.beforeRender=g[0].beforeRender,S.pass=g[0].pass,S.afterRender=g[g.length-1].afterRender,g.length=0,S}}function f(g,y){var S,b,I,N,T,p,m,v,M,k,E,D,P=arguments;return o.a.wrap(function(j){for(;;)switch(j.prev=j.next){case 0:S=P.length>2&&P[2]!==void 0?P[2]:!1,b=[],I=g.options.bufferSize,N=0,T=!1,p=0;case 6:if(!(p<y.length)){j.next=50;break}if(m=y[p],!(m instanceof c.default)){j.next=18;break}if(!b.length){j.next=12;break}return j.next=12,d(b,T);case 12:return N=0,T=!1,j.next=16,m;case 16:j.next=47;break;case 18:if(v=m.meshData,v.clipPath&&!v.uniforms.u_clipSampler&&(M=g.createTexture(v.clipPath),v.uniforms.u_clipSampler=M),k=0,!((!S||!m.canIgnore())&&v&&v.positions.length)){j.next=43;break}if(m.packIndex=p,E=m.filterCanvas,k=v.positions.length,!(E||N+k>I)){j.next=33;break}if(!b.length){j.next=29;break}return j.next=29,d(b,T);case 29:N=0,T=!1,j.next=40;break;case 33:if(!N){j.next=40;break}if(D=b[b.length-1],!(D&&(D.filterCanvas||D.afterRender||m.beforeRender||D.pass.length||m.pass.length||D.program!==m.program||!u(D,m,b)))){j.next=40;break}return j.next=38,d(b,T);case 38:N=0,T=!1;case 40:b.push(m),T=T||m.enableBlend,N+=k;case 43:if(p!==y.length-1){j.next=47;break}if(!b.length){j.next=47;break}return j.next=47,d(b,T);case 47:p++,j.next=6;break;case 50:case"end":return j.stop()}},l)}},function(e,r,n){n.r(r),n.d(r,"default",function(){return h});var i=n(19),o=n.n(i),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,f){for(var g=0,y=0,S=0,b=0,I=0,N=0,T=0,p=d[0].program,m=0;m<d.length;m++){var v=d[m].meshData;if(v){T+=v.positions.length;var M=v.positions[0].length;g+=v.positions.length*M,y+=v.cells.length*3,N+=v.attributes.a_color.length*4;var k=v.textureCoord;k&&(S+=k.length*k[0].length);var E=v.attributes.a_sourceRect;E&&(b+=E.length*4);var D=v.attributes.a_clipUV;D&&(I+=D.length*2)}}if((!f.positions||f.positions.length<g)&&(f.positions=new Float32Array(g)),(!f.cells||f.cells.length<y)&&(f.cells=new Uint16Array(y)),S&&(!f.textureCoord||f.textureCoord.length<S)&&(f.textureCoord=new Float32Array(S)),(!f.a_color||f.a_color.length<N)&&(f.a_color=new Uint8Array(N)),b&&(!f.a_sourceRect||f.a_sourceRect.length<b)&&(f.a_sourceRect=new Float32Array(b)),I&&(!f.a_clipUV||f.a_clipUV.length<I)&&(f.a_clipUV=new Float32Array(I)),p)for(var P=Object.entries(p._attribute),z=p._attribOpts||{},j=0;j<P.length;j++){var A=c()(P[j],2),R=A[0],L=A[1];if(R!=="a_color"&&R!=="a_sourceRect"&&L!=="ignored"){var W=z[R]?z[R].type:"FLOAT",Y=l[W],H=L.size*T;(!f[R]||f[R].length<H)&&(f[R]=new Y(H))}}return f}function h(d,f){var g=[],y=[],S=[],b=[],I=[],N=[],T=0,p=0,m=d[0]?d[0].uniforms||{}:{},v=d[0]?d[0].program:null;f&&(u(d,f),y=f.cells,g=f.positions,S=f.textureCoord,b=f.a_color,I=f.a_sourceRect,N=f.a_clipUV);for(var M=!1,k=!1,E={},D=0;D<d.length;D++){var P=d[D];if(P){if(P.meshData&&(P=P.meshData),f)for(var z=P.positions,j=0;j<z.length;j++)for(var A=z[j],R=3*(T+j),L=0;L<A.length;L++)g[R+L]=A[L];else{var W;(W=g).push.apply(W,o()(P.positions))}for(var Y=P.cells,H=0;H<Y.length;H++){var ie=Y[H];if(f){var O=3*(p+H);y[O]=ie[0]+T,y[O+1]=ie[1]+T,y[O+2]=ie[2]+T}else y.push([ie[0]+T,ie[1]+T,ie[2]+T])}if(f)for(var V=P.attributes.a_color,Z=0;Z<V.length;Z++){var $=V[Z],ee=4*(T+Z);b[ee]=$[0],b[ee+1]=$[1],b[ee+2]=$[2],b[ee+3]=$[3]}else{var se;(se=b).push.apply(se,o()(P.attributes.a_color))}if(P.attributes.a_sourceRect)if(M=!0,f)for(var ce=P.attributes.a_sourceRect,me=0;me<ce.length;me++){var pe=ce[me],B=4*(T+me);I[B]=pe[0],I[B+1]=pe[1],I[B+2]=pe[2],I[B+3]=pe[3]}else{var F;(F=I).push.apply(F,o()(P.attributes.a_sourceRect))}if(P.attributes.a_clipUV)if(k=!0,f)for(var J=P.attributes.a_clipUV,oe=0;oe<J.length;oe++){var K=J[oe],te=2*(T+oe);N[te]=K[0],N[te+1]=K[1]}else{var w;(w=N).push.apply(w,o()(P.attributes.a_clipUV))}if(P.textureCoord)if(f)for(var C=P.textureCoord,U=0;U<C.length;U++)for(var G=C[U],_=3*(T+U),re=0;re<G.length;re++)S[_+re]=G[re];else{var ne;(ne=S).push.apply(ne,o()(P.textureCoord))}if(v)for(var X=Object.entries(v._attribute),ae=0;ae<X.length;ae++){var ue=c()(X[ae],2),he=ue[0],ge=ue[1];if(he!=="a_color"&&he!=="a_sourceRect"&&ge!=="ignored")if(E[he]=[],f){E[he]=f[he];for(var Me=P.attributes[he],we=Me[0].length,be=0;be<Me.length;be++)for(var Ce=Me[be],Ie=we*(T+be),Ae=0;Ae<Ce.length;Ae++)E[he][Ie+Ae]=Ce[Ae]}else{var Ee;(Ee=E[he]).push.apply(Ee,o()(P.attributes[he]))}}T+=P.positions.length,p+=P.cells.length}}E.a_color=b,M&&I&&I.length>0&&(E.a_sourceRect=I);var ke={positions:g,cells:y,attributes:E,uniforms:m,cellsCount:p*3,program:v};return S&&S.length&&(ke.textureCoord=S),k&&N.length>0&&(E.a_clipUV=N),ke}},function(e,r,n){n.r(r),n.d(r,"default",function(){return A});var i=n(30),o=n.n(i),a=n(19),c=n.n(a),l=n(13),u=n.n(l),h=n(23),d=n.n(h),f=n(24),g=n.n(f),y=n(1),S=n(46),b=n(42),I=n(47);n(1).glMatrix.setMatrixArrayType(Array);function N(R,L){var W=Object.keys(R);if(Object.getOwnPropertySymbols){var Y=Object.getOwnPropertySymbols(R);L&&(Y=Y.filter(function(H){return Object.getOwnPropertyDescriptor(R,H).enumerable})),W.push.apply(W,Y)}return W}function T(R){for(var L=1;L<arguments.length;L++){var W=arguments[L]!=null?arguments[L]:{};L%2?N(Object(W),!0).forEach(function(Y){o()(R,Y,W[Y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(R,Object.getOwnPropertyDescriptors(W)):N(Object(W)).forEach(function(Y){Object.defineProperty(R,Y,Object.getOwnPropertyDescriptor(W,Y))})}return R}var p=Symbol("mesh"),m=Symbol("count"),v=Symbol("blend"),M=Symbol("filter"),k=Symbol("textures"),E=Symbol("textureOptions"),D=Symbol("cloudColor"),P=Symbol("cloudFilter"),z=Symbol("buffer");function j(R){var L=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,W=new Float32Array(3*R),Y=new Float32Array(3*R),H=new Float32Array(4*R),ie=new Float32Array(4*R),O=new Float32Array(4*R),V=new Float32Array(4*R),Z=new Float32Array(4*R),$=new Uint8Array(R),ee=new Uint8Array(4*R),se=new Uint8Array(4*R);return L&&(W.set(L.transform0,0),Y.set(L.transform1,0),H.set(L.color0,0),ie.set(L.color1,0),O.set(L.color2,0),V.set(L.color3,0),Z.set(L.color4,0),$.set(L.frameIndex,0),ee.set(L.fillColor,0),se.set(L.strokeColor,0)),{bufferSize:R,transform0:W,transform1:Y,color0:H,color1:ie,color2:O,color3:V,color4:Z,frameIndex:$,fillColor:ee,strokeColor:se}}var A=function(){function R(L){var W=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,Y=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},H=Y.buffer,ie=H===void 0?1e3:H;d()(this,R),ie=Math.max(ie,W),this[m]=W,this[p]=L,this[z]=j(ie),this[k]=[],this[M]=[],this[D]=!1,this[P]=!1,this[v]=!1,this.initBuffer()}return g()(R,[{key:"initBuffer",value:function(){for(var W=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,Y=this[m],H=W;H<Y;H++)this[z].transform0.set([1,0,0],H*3),this[z].transform1.set([0,1,0],H*3),this[z].frameIndex.set([-1],H),this[z].fillColor.set([0,0,0,0],H*4),this[z].strokeColor.set([0,0,0,0],H*4),this.setColorTransform(H,null)}},{key:"_getFilter",value:function(W){return this[M][W]=this[M][W]||[],this[M][W]}},{key:"getFilter",value:function(W){return this._getFilter(W).join(" ")}},{key:"canIgnore",value:function(){return this[p].canIgnore()}},{key:"delete",value:function(W){if(W>=this[m]||W<0)throw new Error("Out of range.");var Y=this[z],H=Y.transform0,ie=Y.transform1,O=Y.color0,V=Y.color1,Z=Y.color2,$=Y.color3,ee=Y.color4,se=Y.frameIndex,ce=Y.fillColor,me=Y.strokeColor;H.set(H.subarray(3*(W+1)),3*W),ie.set(ie.subarray(3*(W+1)),3*W),O.set(O.subarray(4*(W+1)),4*W),V.set(V.subarray(4*(W+1)),4*W),Z.set(Z.subarray(4*(W+1)),4*W),$.set($.subarray(4*(W+1)),4*W),ee.set(ee.subarray(4*(W+1)),4*W),se.set(se.subarray(W+1),W),ce.set(ce.subarray(4*(W+1)),4*W),me.set(me.subarray(4*(W+1)),4*W);for(var pe in this[M])pe===W?delete this[M][pe]:pe>W&&(this[M][pe-1]=this[M][pe],delete this[M][pe]);this[m]--}},{key:"setColorTransform",value:function(W,Y){if(W>=this[m]||W<0)throw new Error("Out of range.");W*=4;var H=this[z],ie=H.color0,O=H.color1,V=H.color2,Z=H.color3,$=H.color4;return Y!=null?(ie.set([Y[0],Y[5],Y[10],Y[15]],W),O.set([Y[1],Y[6],Y[11],Y[16]],W),V.set([Y[2],Y[7],Y[12],Y[17]],W),Z.set([Y[3],Y[8],Y[13],Y[18]],W),$.set([Y[4],Y[9],Y[14],Y[19]],W),this[v]=this[v]||Y[18]<1,this[P]=!0):(ie.set([1,0,0,0],W),O.set([0,1,0,0],W),V.set([0,0,1,0],W),Z.set([0,0,0,1],W),$.set([0,0,0,0],W)),this}},{key:"getColorTransform",value:function(W){if(W>=this[m]||W<0)throw new Error("Out of range.");W*=4;var Y=this[z],H=Y.color0,ie=Y.color1,O=Y.color2,V=Y.color3,Z=Y.color4;return[H[W],ie[W],O[W],V[W],Z[W],H[W+1],ie[W+1],O[W+1],V[W+1],Z[W+1],H[W+2],ie[W+2],O[W+2],V[W+2],Z[W+2],H[W+3],ie[W+3],O[W+3],V[W+3],Z[W+3]]}},{key:"transformColor",value:function(W,Y){var H=this.getColorTransform(W);return H=Object(S.multiply)(H,Y),this.setColorTransform(W,H),this}},{key:"setFillColor",value:function(W,Y){if(W>=this[m]||W<0)throw new Error("Out of range.");typeof Y=="string"&&(Y=Object(I.default)(Y)),Y[3]>0&&(this[D]=!0),this[z].fillColor.set(Y.map(function(H){return Math.round(255*H)}),4*W)}},{key:"setStrokeColor",value:function(W,Y){if(W>=this[m]||W<0)throw new Error("Out of range.");typeof Y=="string"&&(Y=Object(I.default)(Y)),Y[3]>0&&(this[D]=!0),this[z].strokeColor.set(Y.map(function(H){return Math.round(255*H)}),4*W)}},{key:"getCloudRGBA",value:function(W){if(W>=this[m]||W<0)throw new Error("Out of range.");W*=4;var Y=this[z],H=Y.fillColor,ie=Y.strokeColor,O=[H[W],H[W+1],H[W+2],H[W+3]],V=[ie[W],ie[W+1],ie[W+2],ie[W+3]];return O[3]/=255,V[3]/=255,{fill:"rgba(".concat(O.join(),")"),stroke:"rgba(".concat(V.join(),")")}}},{key:"grayscale",value:function(W,Y){this.transformColor(W,Object(S.grayscale)(Y)),this._getFilter(W).push("grayscale(".concat(100*Y,"%)"))}},{key:"brightness",value:function(W,Y){this.transformColor(W,Object(S.brightness)(Y)),this._getFilter(W).push("brightness(".concat(100*Y,"%)"))}},{key:"saturate",value:function(W,Y){this.transformColor(W,Object(S.saturate)(Y)),this._getFilter(W).push("saturate(".concat(100*Y,"%)"))}},{key:"contrast",value:function(W,Y){this.transformColor(W,Object(S.contrast)(Y)),this._getFilter(W).push("contrast(".concat(100*Y,"%)"))}},{key:"invert",value:function(W,Y){this.transformColor(W,Object(S.invert)(Y)),this._getFilter(W).push("invert(".concat(100*Y,"%)"))}},{key:"sepia",value:function(W,Y){this.transformColor(W,Object(S.sepia)(Y)),this._getFilter(W).push("sepia(".concat(100*Y,"%)"))}},{key:"opacity",value:function(W,Y){this.transformColor(W,Object(S.opacity)(Y)),this._getFilter(W).push("opacity(".concat(100*Y,"%)"))}},{key:"hueRotate",value:function(W,Y){this.transformColor(W,Object(S.hueRotate)(Y)),this._getFilter(W).push("hue-rotate(".concat(Y,"deg)"))}},{key:"setTransform",value:function(W,Y){if(W>=this[m]||W<0)throw new Error("Out of range.");W*=3,Y==null&&(Y=[1,0,0,1,0,0]);var H=this[z],ie=H.transform0,O=H.transform1;return ie.set([Y[0],Y[2],Y[4]],W),O.set([Y[1],Y[3],Y[5]],W),this}},{key:"getTransform",value:function(W){if(W>=this[m]||W<0)throw new Error("Out of range.");W*=3;var Y=this[z],H=Y.transform0,ie=Y.transform1,O=[H[W],ie[W],H[W+1],ie[W+1],H[W+2],ie[W+2]];return O}},{key:"getTextureFrame",value:function(W){return this[k][this[z].frameIndex[W]]}},{key:"setTextureFrames",value:function(){var W=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(W.length>12)throw new Error("Max frames exceed. Allow 12 frames.");if(W.length){var H=this[p];H.setTexture(W[0],Y)}this[k]=W,this[E]=Y}},{key:"setFrameIndex",value:function(W,Y){if(W>=this[m]||W<0)throw new Error("Out of range.");var H=this[k].length;if(H<=0)throw new Error("No frames");this[z].frameIndex[W]=Y%H}},{key:"setProgram",value:function(W){this[p].setProgram(W)}},{key:"transform",value:function(W,Y){var H=this.getTransform(W);return Y=y.mat2d.multiply(Array.of(0,0,0,0,0,0),H,Y),this.setTransform(W,Y),this}},{key:"translate",value:function(W,Y){var H=u()(Y,2),ie=H[0],O=H[1],V=y.mat2d.create();return V=y.mat2d.translate(Array.of(0,0,0,0,0,0),V,[ie,O]),this.transform(W,V)}},{key:"rotate",value:function(W,Y){var H=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[0,0],ie=u()(H,2),O=ie[0],V=ie[1],Z=y.mat2d.create();return Z=y.mat2d.translate(Array.of(0,0,0,0,0,0),Z,[O,V]),Z=y.mat2d.rotate(Array.of(0,0,0,0,0,0),Z,Y),Z=y.mat2d.translate(Array.of(0,0,0,0,0,0),Z,[-O,-V]),this.transform(W,Z)}},{key:"scale",value:function(W,Y){var H=u()(Y,2),ie=H[0],O=H[1],V=O===void 0?ie:O,Z=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[0,0],$=u()(Z,2),ee=$[0],se=$[1],ce=y.mat2d.create();return ce=y.mat2d.translate(Array.of(0,0,0,0,0,0),ce,[ee,se]),ce=y.mat2d.scale(Array.of(0,0,0,0,0,0),ce,[ie,V]),ce=y.mat2d.translate(Array.of(0,0,0,0,0,0),ce,[-ee,-se]),this.transform(W,ce)}},{key:"skew",value:function(W,Y){var H=u()(Y,2),ie=H[0],O=H[1],V=O===void 0?ie:O,Z=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[0,0],$=u()(Z,2),ee=$[0],se=$[1],ce=y.mat2d.create();return ce=y.mat2d.translate(Array.of(0,0,0,0,0,0),ce,[ee,se]),ce=y.mat2d.multiply(Array.of(0,0,0,0,0,0),ce,y.mat2d.fromValues(1,Math.tan(V),Math.tan(ie),1,0,0)),ce=y.mat2d.translate(Array.of(0,0,0,0,0,0),ce,[-ee,-se]),this.transform(W,ce)}},{key:"isPointCollision",value:function(W,Y){var H,ie=u()(Y,2),O=ie[0],V=ie[1],Z=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"both",$=this.getTransform(W),ee=Object(b.transformPoint)([O,V],y.mat2d.invert(Array.of(0,0,0,0,0,0),$));return(H=this[p]).isPointCollision.apply(H,c()(ee).concat([Z]))}},{key:"isPointInFill",value:function(W,Y){var H=u()(Y,2),ie=H[0],O=H[1];return this.isPointCollision(W,[ie,O],"fill")}},{key:"isPointInStroke",value:function(W,Y){var H=u()(Y,2),ie=H[0],O=H[1];return this.isPointCollision(W,[ie,O],"stroke")}},{key:"bufferSize",get:function(){return this[z].bufferSize}},{key:"mesh",get:function(){return this[p]},set:function(W){this[p]=W,this[k]&&this.setTextureFrames(this[k],this[E])}},{key:"hasCloudColor",get:function(){return this[D]}},{key:"hasCloudFilter",get:function(){return this[P]}},{key:"enableBlend",get:function(){return this[p].enableBlend||this[v]}},{key:"amount",get:function(){return this[m]},set:function(W){var Y=this[m];W!==Y&&(W>this[z].bufferSize&&(this[z]=j(Math.max(W,this[z].bufferSize+1e3),this[z])),this[m]=W,W>Y&&this.initBuffer(Y))}},{key:"meshData",get:function(){var W=this[p].meshData,Y=W.attributes,H=W.cells,ie=W.positions,O=W.textureCoord,V=W.uniforms,Z=this[k],$={attributes:T({},Y),cells:H,positions:ie,textureCoord:O,uniforms:T({},V),instanceCount:this[m],enableBlend:this.enableBlend};Z.length&&Z.forEach(function(w,C){$.uniforms["u_texFrame".concat(C)]=w});var ee=this[z],se=ee.transform0,ce=ee.transform1,me=ee.color0,pe=ee.color1,B=ee.color2,F=ee.color3,J=ee.color4,oe=ee.fillColor,K=ee.strokeColor,te=ee.frameIndex;return this[p].uniforms.u_texSampler&&($.attributes.a_frameIndex={data:te,divisor:1}),$.attributes.a_transform0={data:se,divisor:1},$.attributes.a_transform1={data:ce,divisor:1},$.attributes.a_colorCloud0={data:me,divisor:1},$.attributes.a_colorCloud1={data:pe,divisor:1},$.attributes.a_colorCloud2={data:B,divisor:1},$.attributes.a_colorCloud3={data:F,divisor:1},$.attributes.a_colorCloud4={data:J,divisor:1},this.hasCloudColor&&($.attributes.a_fillCloudColor={data:oe,divisor:1},$.attributes.a_strokeCloudColor={data:K,divisor:1}),$}},{key:"program",get:function(){return this[p].program}}]),R}()},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 f}),n.d(r,"hueRotate",function(){return g});var i=n(42);n(1).glMatrix.setMatrixArrayType(Array);function o(y,S){var b=[],I=y[0],N=y[1],T=y[2],p=y[3],m=y[4],v=y[5],M=y[6],k=y[7],E=y[8],D=y[9],P=y[10],z=y[11],j=y[12],A=y[13],R=y[14],L=y[15],W=y[16],Y=y[17],H=y[18],ie=y[19],O=S[0],V=S[1],Z=S[2],$=S[3],ee=S[4];return b[0]=O*I+V*v+Z*P+$*L,b[1]=O*N+V*M+Z*z+$*W,b[2]=O*T+V*k+Z*j+$*Y,b[3]=O*p+V*E+Z*A+$*H,b[4]=O*m+V*D+Z*R+$*ie+ee,O=S[5],V=S[6],Z=S[7],$=S[8],ee=S[9],b[5]=O*I+V*v+Z*P+$*L,b[6]=O*N+V*M+Z*z+$*W,b[7]=O*T+V*k+Z*j+$*Y,b[8]=O*p+V*E+Z*A+$*H,b[9]=O*m+V*D+Z*R+$*ie+ee,O=S[10],V=S[11],Z=S[12],$=S[13],ee=S[14],b[10]=O*I+V*v+Z*P+$*L,b[11]=O*N+V*M+Z*z+$*W,b[12]=O*T+V*k+Z*j+$*Y,b[13]=O*p+V*E+Z*A+$*H,b[14]=O*m+V*D+Z*R+$*ie+ee,O=S[15],V=S[16],Z=S[17],$=S[18],ee=S[19],b[15]=O*I+V*v+Z*P+$*L,b[16]=O*N+V*M+Z*z+$*W,b[17]=O*T+V*k+Z*j+$*Y,b[18]=O*p+V*E+Z*A+$*H,b[19]=O*m+V*D+Z*R+$*ie+ee,b}function a(y){y=Object(i.clamp)(0,1,y);var S=.2126*y,b=.7152*y,I=.0722*y;return[S+1-y,b,I,0,0,S,b+1-y,I,0,0,S,b,I+1-y,0,0,0,0,0,1,0]}function c(y){return[y,0,0,0,0,0,y,0,0,0,0,0,y,0,0,0,0,0,1,0]}function l(y){var S=.2126*(1-y),b=.7152*(1-y),I=.0722*(1-y);return[S+y,b,I,0,0,S,b+y,I,0,0,S,b,I+y,0,0,0,0,0,1,0]}function u(y){var S=.5*(1-y);return[y,0,0,0,S,0,y,0,0,S,0,0,y,0,S,0,0,0,1,0]}function h(y){var S=1-2*y;return[S,0,0,0,y,0,S,0,0,y,0,0,S,0,y,0,0,0,1,0]}function d(y){return[1-.607*y,.769*y,.189*y,0,0,.349*y,1-.314*y,.168*y,0,0,.272*y,.534*y,1-.869*y,0,0,0,0,0,1,0]}function f(y){return[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,y,0]}function g(y){var S=y/180*Math.PI,b=Math.cos(S),I=Math.sin(S),N=.2126,T=.7152,p=.0722;return[N+b*(1-N)+I*-N,T+b*-T+I*-T,p+b*-p+I*(1-p),0,0,N+b*-N+I*.143,T+b*(1-T)+I*.14,p+b*-p+I*-.283,0,0,N+b*-N+I*-.7874,T+b*-T+I*T,p+b*(1-p)+I*p,0,0,0,0,0,1,0]}},function(e,r,n){n.r(r),n.d(r,"default",function(){return a});var i=n(48),o=n.n(i);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 i=n(49),o=n(53),a=n(55);e.exports=function(l){var u,h=i(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(i){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,f=[],g=1,y;if(typeof h=="string")if(o[h])f=o[h].slice(),y="rgb";else if(h==="transparent")g=0,y="rgb",f=[0,0,0];else if(/^#[A-Fa-f0-9]+$/.test(h)){var S=h.slice(1),b=S.length,I=b<=4;g=1,I?(f=[parseInt(S[0]+S[0],16),parseInt(S[1]+S[1],16),parseInt(S[2]+S[2],16)],b===4&&(g=parseInt(S[3]+S[3],16)/255)):(f=[parseInt(S[0]+S[1],16),parseInt(S[2]+S[3],16),parseInt(S[4]+S[5],16)],b===8&&(g=parseInt(S[6]+S[7],16)/255)),f[0]||(f[0]=0),f[1]||(f[1]=0),f[2]||(f[2]=0),y="rgb"}else if(d=/^((?:rgb|hs[lvb]|hwb|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms)a?)\s*\(([^\)]*)\)/.exec(h)){var N=d[1],T=N==="rgb",S=N.replace(/a$/,"");y=S;var b=S==="cmyk"?4:S==="gray"?1:3;f=d[2].trim().split(/\s*,\s*/).map(function(M,k){if(/%$/.test(M))return k===b?parseFloat(M)/100:S==="rgb"?parseFloat(M)*255/100:parseFloat(M);if(S[k]==="h"){if(/deg$/.test(M))return parseFloat(M);if(l[M]!==void 0)return l[M]}return parseFloat(M)}),N===S&&f.push(1),g=T||f[b]===void 0?1:f[b],f=f.slice(0,b)}else h.length>10&&/[0-9](?:\s|\/)/.test(h)&&(f=h.match(/([0-9]+)/g).map(function(m){return parseFloat(m)}),y=h.match(/([a-z])/ig).join("").toLowerCase());else if(!isNaN(h))y="rgb",f=[h>>>16,(h&65280)>>>8,h&255];else if(a(h)){var p=c(h.r,h.red,h.R,null);p!==null?(y="rgb",f=[p,c(h.g,h.green,h.G),c(h.b,h.blue,h.B)]):(y="hsl",f=[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)]),g=c(h.a,h.alpha,h.opacity,1),h.opacity!=null&&(g/=100)}else(Array.isArray(h)||i.ArrayBuffer&&ArrayBuffer.isView&&ArrayBuffer.isView(h))&&(f=[h[0],h[1],h[2]],y="rgb",g=h.length===4?h[3]:1);return{space:y,values:f,alpha:g}}}).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 i=Object.prototype.toString;e.exports=function(o){var a;return i.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 i=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,f,g;if(c===0)return g=l*255,[g,g,g];l<.5?h=l*(1+c):h=l+c-l*c,u=2*l-h,f=[0,0,0];for(var y=0;y<3;y++)d=a+1/3*-(y-1),d<0?d++:d>1&&d--,6*d<1?g=u+(h-u)*6*d:2*d<1?g=h:3*d<2?g=u+(h-u)*(2/3-d)*6:g=u,f[y]=g*255;return f}},i.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,f,g,y;return h===u?f=0:a===h?f=(c-l)/d:c===h?f=2+(l-a)/d:l===h&&(f=4+(a-c)/d),f=Math.min(f*60,360),f<0&&(f+=360),y=(u+h)/2,h===u?g=0:y<=.5?g=d/(h+u):g=d/(2-h-u),[f,g*100,y*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(i,o,a){return o<a?i<o?o:i>a?a:i:i<a?a:i>o?o:i}},function(e,r,n){n.r(r),n.d(r,"default",function(){return z});var i=n(19),o=n.n(i),a=n(57),c=n.n(a),l=n(23),u=n.n(l),h=n(24),d=n.n(h),f=n(58),g=n.n(f),y=n(59),S=n.n(y),b=n(60),I=n.n(b),N=n(61),T=n(63),p=n.n(T),m=n(70),v=n(72);n(1).glMatrix.setMatrixArrayType(Array);var M=Symbol("contours"),k=Symbol("path"),E=Symbol("simplify"),D=Symbol("scale"),P=2*Math.PI,z=function(){function j(){var A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};u()(this,j),typeof A=="string"&&(A={path:A}),A.path?this[k]=g()(A.path):this[k]=[],this[M]=null,this[E]=A.simplify!=null?A.simplify:0,this[D]=A.scale!=null?A.scale:2}return d()(j,[{key:"normalize",value:function(){var R,L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,W=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,Y=Object(N.default)(I()(this[k])).map(function(H){for(var ie=c()(H),O=ie[0],V=ie.slice(1),Z=[O],$=0;$<V.length;$+=2){var ee=V[$]-L,se=V[$+1]-W;Z.push(ee,se)}return Z});return this.beginPath(),(R=this[k]).push.apply(R,o()(Y)),this}},{key:"getPointAtLength",value:function(R){return this.contours?Object(m.getPointAtLength)(this[M],R):null}},{key:"getTotalLength",value:function(){return this.contours?Object(m.getTotalLength)(this[M]):0}},{key:"addPath",value:function(R){var L;this[M]=null,typeof R=="string"&&(R=g()(R)),(L=this[k]).push.apply(L,o()(R))}},{key:"beginPath",value:function(){this[k]=[],this[M]=null}},{key:"clear",value:function(){this.beginPath()}},{key:"ellipse",value:function(R,L,W,Y,H,ie,O){var V=arguments.length>7&&arguments[7]!==void 0?arguments[7]:0;if(ie+=H,O+=H,!(W<=0||Y<=0||O===ie)){O<ie&&(O=ie+P+(O-ie)%P),O-ie>P&&(O=ie+P);var Z=O-ie;Z>=P&&(O-=.001);var $=this[k].length>0&&Z<P?"L":"M",ee=Object(v.getPoint)(R,L,W,Y,ie),se=Object(v.getPoint)(R,L,W,Y,O),ce=+!V,me=Z>Math.PI?1:0;V&&(me=1-me),$+=ee.join(" "),$+="A".concat(W," ").concat(Y," 0 ").concat(me," ").concat(ce," ").concat(se.join(" ")),Z>=P&&($+="Z"),this.addPath($)}}},{key:"arc",value:function(R,L,W,Y,H){var ie=arguments.length>5&&arguments[5]!==void 0?arguments[5]:0;return this.ellipse(R,L,W,W,0,Y,H,ie)}},{key:"arcTo",value:function(R,L,W,Y,H,ie,O){this[M]=null,this[k].push(["A",R,L,W,Y,H,ie,O])}},{key:"moveTo",value:function(R,L){this[M]=null,this[k].push(["M",R,L])}},{key:"lineTo",value:function(R,L){this[M]=null,this[k].push(["L",R,L])}},{key:"bezierCurveTo",value:function(R,L,W,Y,H,ie){this[M]=null,this[k].push(["C",R,L,W,Y,H,ie])}},{key:"quadraticCurveTo",value:function(R,L,W,Y){this[M]=null,this[k].push(["Q",R,L,W,Y])}},{key:"rect",value:function(R,L,W,Y){var H="M".concat(R," ").concat(L,"L").concat(R+W," ").concat(L,"L").concat(R+W," ").concat(L+Y,"L").concat(R," ").concat(L+Y,"Z");this.addPath(H)}},{key:"closePath",value:function(){this[M]=null;var R=[],L=this[k].length;L>0&&(R=this[k][L-1]),R[0]!=="Z"&&R[0]!=="z"&&this[k].push(["Z"])}},{key:"contours",get:function(){var R=null;if(!this[M]&&this[k]){var L=Object(N.default)(I()(this[k]));this[M]=p()(L,this[D],this[E]),this[M].path=L,this[M].simplify=this[E],this[M].scale=this[D]}return this[M]&&(R=this[M].map(function(W){return o()(W)}),R.path=this[M].path,R.simplify=this[M].simplify,R.scale=this[M].scale),R}},{key:"path",get:function(){return this[k]}},{key:"simplify",get:function(){return this[E]}},{key:"boundingBox",get:function(){var R=this.contours;if(R&&R.length){var L=R.reduce(function(W,Y){return[].concat(o()(W),o()(Y))});return S()(L)}return[[0,0],[0,0]]}},{key:"boundingCenter",get:function(){var R=this.boundingBox;return R?[.5*(R[0][0]+R[1][0]),.5*(R[0][1]+R[1][1])]:[0,0]}}]),j}()},function(e,r,n){var i=n(14),o=n(21),a=n(16),c=n(18);function l(u){return i(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},i=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function o(l){var u=[];return l.replace(i,function(h,d,f){var g=d.toLowerCase();for(f=c(f),g=="m"&&f.length>2&&(u.push([d].concat(f.splice(0,2))),g="l",d=d=="m"?"l":"L");;){if(f.length==n[g])return f.unshift(d),u.push(f);if(f.length<n[g])throw new Error("malformed path data");u.push([d].concat(f.splice(0,n[g])))}}),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=i;function i(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],f=0;f<c;++f){var g=d[f];l[f]=Math.min(l[f],g),u[f]=Math.max(u[f],g)}return[l,u]}},function(e,r){e.exports=n;function n(i){var o=0,a=0,c=0,l=0;return i.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 f=1;f<u.length;)u[f++]+=c,u[f++]+=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 i=n(13),o=n.n(i),a=n(62);n(1).glMatrix.setMatrixArrayType(Array);function c(h){for(var d,f=[],g=0,y=0,S=0,b=0,I=null,N=null,T=0,p=0,m=0,v=h.length;m<v;m++){var M=h[m],k=M[0];switch(k){case"M":S=M[1],b=M[2];break;case"A":var E=Object(a.default)(T,p,M[6],M[7],M[4],M[5],M[1],M[2],M[3]);if(!E.length)continue;E=E.map(function(A){var R=o()(A,8);R[0],R[1];var L=R[2],W=R[3],Y=R[4],H=R[5],ie=R[6],O=R[7];return{x1:L,y1:W,x2:Y,y2:H,x:ie,y:O}});for(var D=0,P;D<E.length;D++)P=E[D],M=["C",P.x1,P.y1,P.x2,P.y2,P.x,P.y],D<E.length-1&&f.push(M);break;case"S":var z=T,j=p;(d=="C"||d=="S")&&(z+=z-g,j+=j-y),M=["C",z,j,M[1],M[2],M[3],M[4]];break;case"T":d=="Q"||d=="T"?(I=T*2-I,N=p*2-N):(I=T,N=p),M=u(T,p,I,N,M[1],M[2]);break;case"Q":I=M[1],N=M[2],M=u(T,p,M[1],M[2],M[3],M[4]);break;case"L":M=l(T,p,M[1],M[2]);break;case"H":M=l(T,p,M[1],p);break;case"V":M=l(T,p,T,M[1]);break;case"Z":M=l(T,p,S,b);break}d=k,T=M[M.length-2],p=M[M.length-1],M.length>4?(g=M[M.length-4],y=M[M.length-3]):(g=T,y=p),f.push(M)}return f}function l(h,d,f,g){return["C",h,d,f,g,f,g]}function u(h,d,f,g,y,S){return["C",h/3+2/3*f,d/3+2/3*g,y/3+2/3*f,S/3+2/3*g,y,S]}},function(e,r,n){n.r(r),n.d(r,"default",function(){return l}),n(1).glMatrix.setMatrixArrayType(Array);var i=Math.PI*2;function o(u,h,d,f){var g=u*f-h*d<0?-1:1,y=u*d+h*f;return y>1&&(y=1),y<-1&&(y=-1),g*Math.acos(y)}function a(u,h,d,f,g,y,S,b,I,N){var T=N*(u-d)/2+I*(h-f)/2,p=-I*(u-d)/2+N*(h-f)/2,m=S*S,v=b*b,M=T*T,k=p*p,E=m*v-m*k-v*M;E<0&&(E=0),E/=m*k+v*M,E=Math.sqrt(E)*(g===y?-1:1);var D=E*S/b*p,P=E*-b/S*T,z=N*D-I*P+(u+d)/2,j=I*D+N*P+(h+f)/2,A=(T-D)/S,R=(p-P)/b,L=(-T-D)/S,W=(-p-P)/b,Y=o(1,0,A,R),H=o(A,R,L,W);return y===0&&H>0&&(H-=i),y===1&&H<0&&(H+=i),[z,j,Y,H]}function c(u,h){var d=1.3333333333333333*Math.tan(h/4),f=Math.cos(u),g=Math.sin(u),y=Math.cos(u+h),S=Math.sin(u+h);return[f,g,f-g*d,g+f*d,y+S*d,S-y*d,y,S]}function l(u,h,d,f,g,y,S,b,I){var N=Math.sin(I*i/360),T=Math.cos(I*i/360),p=T*(u-d)/2+N*(h-f)/2,m=-N*(u-d)/2+T*(h-f)/2;if(p===0&&m===0)return[];if(S===0||b===0)return[];S=Math.abs(S),b=Math.abs(b);var v=p*p/(S*S)+m*m/(b*b);v>1&&(S*=Math.sqrt(v),b*=Math.sqrt(v));var M=a(u,h,d,f,g,y,S,b,N,T),k=[],E=M[2],D=M[3],P=Math.max(Math.ceil(Math.abs(D)/(i/4)),1);D/=P;for(var z=0;z<P;z++)k.push(c(E,D)),E+=D;return k.map(function(j){for(var A=0;A<j.length;A+=2){var R=j[A+0],L=j[A+1];R*=S,L*=b;var W=T*R-N*L,Y=N*R+T*L;j[A+0]=W+M[0],j[A+1]=Y+M[1]}return j})}},function(e,r,n){n(1).glMatrix.setMatrixArrayType(Array);var i=n(64),o=n(66),a=o.copy,c=n(67);function l(g,y,S){return g[0]=y,g[1]=S,g}var u=[0,0],h=[0,0],d=[0,0];function f(g,y,S,b){i(S,l(u,b[1],b[2]),l(h,b[3],b[4]),l(d,b[5],b[6]),y,g)}e.exports=function(y,S,b){var I=[],N=[],T=[0,0];return y.forEach(function(p,m,v){if(p[0]==="M")a(T,p.slice(1)),N.length>0&&(I.push(N),N=[]);else if(p[0]==="C")f(N,S,T,p),l(T,p[5],p[6]);else throw new Error("illegal type in SVG: "+p[0])}),N.length>0&&I.push(N),I.map(function(p){return c(p,b||0)})}},function(e,r,n){e.exports=n(65)()},function(e,r){function n(o){return[o[0],o[1]]}function i(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,f=a.cuspLimit||0;return function(b,I,N,T,p,m){m||(m=[]),p=typeof p=="number"?p:1;var v=u/p;return v*=v,g(b,I,N,T,m,v),m};function g(S,b,I,N,T,p){T.push(n(S));var m=S[0],v=S[1],M=b[0],k=b[1],E=I[0],D=I[1],P=N[0],z=N[1];y(m,v,M,k,E,D,P,z,T,p,0),T.push(n(N))}function y(S,b,I,N,T,p,m,v,M,k,E){if(!(E>c)){var D=Math.PI,P=(S+I)/2,z=(b+N)/2,j=(I+T)/2,A=(N+p)/2,R=(T+m)/2,L=(p+v)/2,W=(P+j)/2,Y=(z+A)/2,H=(j+R)/2,ie=(A+L)/2,O=(W+H)/2,V=(Y+ie)/2;if(E>0){var Z=m-S,$=v-b,ee=Math.abs((I-m)*$-(N-v)*Z),se=Math.abs((T-m)*$-(p-v)*Z),ce,me;if(ee>l&&se>l){if((ee+se)*(ee+se)<=k*(Z*Z+$*$)){if(d<h){M.push(i(O,V));return}var pe=Math.atan2(p-N,T-I);if(ce=Math.abs(pe-Math.atan2(N-b,I-S)),me=Math.abs(Math.atan2(v-p,m-T)-pe),ce>=D&&(ce=2*D-ce),me>=D&&(me=2*D-me),ce+me<d){M.push(i(O,V));return}if(f!==0){if(ce>f){M.push(i(I,N));return}if(me>f){M.push(i(T,p));return}}}}else if(ee>l){if(ee*ee<=k*(Z*Z+$*$)){if(d<h){M.push(i(O,V));return}if(ce=Math.abs(Math.atan2(p-N,T-I)-Math.atan2(N-b,I-S)),ce>=D&&(ce=2*D-ce),ce<d){M.push(i(I,N)),M.push(i(T,p));return}if(f!==0&&ce>f){M.push(i(I,N));return}}}else if(se>l){if(se*se<=k*(Z*Z+$*$)){if(d<h){M.push(i(O,V));return}if(ce=Math.abs(Math.atan2(v-p,m-T)-Math.atan2(p-N,T-I)),ce>=D&&(ce=2*D-ce),ce<d){M.push(i(I,N)),M.push(i(T,p));return}if(f!==0&&ce>f){M.push(i(T,p));return}}}else if(Z=O-(S+m)/2,$=V-(b+v)/2,Z*Z+$*$<=k){M.push(i(O,V));return}}y(S,b,P,z,W,Y,O,V,M,k,E+1),y(O,V,H,ie,R,L,m,v,M,k,E+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 f}),n.d(r,"add",function(){return g}),n.d(r,"computeMiter",function(){return I}),n.d(r,"normal",function(){return N}),n.d(r,"direction",function(){return T});var i=n(1);n(1).glMatrix.setMatrixArrayType(Array);function o(p){return[p[0],p[1]]}function a(){return[0,0]}var c=i.vec2.copy,l=i.vec2.scaleAndAdd,u=i.vec2.dot,h=i.vec2.rotate,d=i.vec2.cross,f=i.vec2.sub,g=i.vec2.add,y=i.vec2.normalize,S=i.vec2.set,b=a();function I(p,m,v,M,k){g(p,v,M),y(p,p),S(m,-p[1],p[0]),S(b,-v[1],v[0]);var E=k/u(m,b);return Math.abs(E)}function N(p,m){return S(p,-m[1],m[0]),p}function T(p,m,v){return f(p,m,v),y(p,p),p}},function(e,r,n){var i=n(68),o=n(69);e.exports=function(c,l){return c=i(c,l),c=o(c,l),c},e.exports.radialDistance=i,e.exports.douglasPeucker=o},function(e,r){function n(i,o){var a=i[0]-o[0],c=i[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,f=o.length;d<f;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 f=((o[0]-l)*h+(o[1]-u)*d)/(h*h+d*d);f>1?(l=c[0],u=c[1]):f>0&&(l+=h*f,u+=d*f)}return h=o[0]-l,d=o[1]-u,h*h+d*d}function i(o,a,c,l,u){for(var h=l,d,f=a+1;f<c;f++){var g=n(o[f],o[a],o[c]);g>h&&(d=f,h=g)}h>l&&(d-a>1&&i(o,a,d,l,u),u.push(o[d]),c-d>1&&i(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 i(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 i=n(19),o=n.n(i),a=n(71);n(1).glMatrix.setMatrixArrayType(Array);function c(d){if(d.totalLength!=null)return d.totalLength;var f=0;return d.forEach(function(g){for(var y=g[0],S=1;S<g.length;S++){var b=g[S];f+=Object(a.distance)(y,b),y=b}}),d.totalLength=f,f}function l(d,f){var g=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(f=Number(f),!Number.isFinite(f))throw new TypeError("Failed to execute 'getPointAtLength' on figure: The provided float value is non-finite.");if(f<=0)throw new TypeError("Length must > 0");var y=c(d);if(f>=y){var S=d[d.length-1],b=S[S.length-2],I=S[S.length-1],N=Math.atan2(I[1]-b[1],I[0]-b[0]);return{current:d.map(function(R){return o()(R)}),point:{x:I[0],y:I[1],angle:N}}}for(var T=[],p=0;p<d.length;p++){T[p]=[];for(var m=d[p],v=m[0],M=1;M<m.length;M++){var k=m[M],E=Object(a.distance)(v,k);if(f<E){var D=f/E,P=Math.atan2(k[1]-v[1],k[0]-v[0]),z={x:v[0]*(1-D)+k[0]*D,y:v[1]*(1-D)+k[1]*D,angle:P};if(T[p].push(v),f>0&&T[p].push([z.x,z.y]),!g)return{current:T,point:z};for(var j=[],A=p;p<d.length;p++){for(j[p-A]=[],p===A&&j[0].push([z.x,z.y]);M<m.length;M++)j[p-A].push(m[M]);M=0}return{current:T,point:z,rest:j}}f-=E,T[p].push(v),v=k}}}function u(d,f){if(f=Number(f),!Number.isFinite(f))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(f<=0){var g=d[0][0],y=d[0][1],S=Math.atan2(y[1]-g[1],y[0]-g[0]);return{x:g[0],y:g[1],angle:S}}return l(d,f,!1).point}function h(d,f,g){var y=0,S=f[0],b=d,I=[],N=f.length;if(g>0){do g-=f[y%N],y++;while(g>0);g<0&&(S=-g,y--)}else if(g<0){y=-1;do g+=f[y%N+N-1],y--;while(g<0);g>=0&&(y++,S=f[y%N+N-1]-g)}do{var T=l(b,S);b=T.rest,++y%2&&I.push.apply(I,o()(T.current));var p=y%N;p<0&&(p+=N),S=f[p]}while(b);return I}},function(e,r,n){n.r(r),n.d(r,"normalize",function(){return a}),n.d(r,"distance",function(){return c});var i=n(13),o=n.n(i);n(1).glMatrix.setMatrixArrayType(Array);function a(l,u,h,d){var f=o()(l,3),g=f[0],y=f[1],S=f[2];return g=g*2/u-1,y=1-y*2/h,Number.isFinite(d)?(S=S*2/d-1,[g,y,S]):[g,y]}function c(l,u){var h=o()(l,3),d=h[0],f=h[1],g=h[2],y=g===void 0?0:g,S=o()(u,3),b=S[0],I=S[1],N=S[2],T=N===void 0?0:N;return Math.hypot(b-d,I-f,T-y)}},function(e,r,n){n.r(r),n.d(r,"getPoint",function(){return o}),n(1).glMatrix.setMatrixArrayType(Array);var i=Math.PI*2;function o(a,c,l,u,h){h%=i,h<0&&(h+=i);var d=Math.tan(h);if(Math.abs(d)<1e5){var f=c-d*a,g=1/Math.pow(l,2)+Math.pow(d,2)/Math.pow(u,2),y=-1;(h<=Math.PI/2||h>3*Math.PI/2)&&(y=1);var S=y*Math.sqrt(1/g)+a,b=d*S+f;return[S,b]}return h<Math.PI?[a,c+u]:[a,c-u]}},function(e,r,n){n.r(r),n.d(r,"default",function(){return _});var i=n(74),o=n.n(i),a=n(19),c=n.n(a),l=n(23),u=n.n(l),h=n(24),d=n.n(h),f=n(13),g=n.n(f),y=n(1),S=n(59),b=n.n(S),I=n(76),N=n(44),T=n(40),p=n(46),m=n(78),v=n(70),M=n(79),k=n.n(M),E=n(63),D=n.n(E),P=n(47),z=n(56),j=n(37);n(1).glMatrix.setMatrixArrayType(Array);var A=Symbol("mesh"),R=Symbol("contours"),L=Symbol("stroke"),W=Symbol("fill"),Y=Symbol("strokeColor"),H=Symbol("fillColor"),ie=Symbol("transform"),O=Symbol("invertTransform"),V=Symbol("uniforms"),Z=Symbol("texOptions"),$=Symbol("blend"),ee=Symbol("applyTexture"),se=Symbol("applyTransform"),ce=Symbol("applyGradientTransform"),me=Symbol("applyProgram"),pe=Symbol("gradient"),B=Symbol("filter"),F=Symbol("opacity"),J=Symbol("program"),oe=Symbol("attributes"),K=Symbol("pass"),te=Symbol("clipContext"),w=Symbol("applyClipPath");function C(re,ne){for(var X=re[1][0]-re[0][0],ae=re[1][1]-re[0][1],ue=[],he=0;he<ne.length;he++){var ge=ne[he],Me=[(ge[0]-re[0][0])/X,1-(ge[1]-re[0][1])/ae];ue.push(Me)}return ue}function U(re,ne,X){var ae=g()(re,2),ue=ae[0],he=ae[1],ge=g()(ne,4),Me=ge[0],we=ge[1],be=ge[2],Ce=ge[3],Ie=X.scale;return Ie||(ue/=be,he=1-he/Ce,ue-=Me,he+=we),[ue,he,0]}function G(re,ne,X){var ae=D()(re,ne,X);return ae.path=re,ae.simplify=X,ae.scale=ne,ae}var _=function(){function re(ne){u()(this,re),this[L]=null,this[W]=null,this[ie]=[1,0,0,1,0,0],this[F]=1,this[V]={},this[B]=[],this[$]=null,this[Z]={},this.contours=ne.contours,this[J]=null,this[oe]={},this[K]=[]}return d()(re,[{key:"setProgram",value:function(X){this[J]=X,this[A]&&this[me](X)}},{key:"setAttribute",value:function(X,ae){ae==null?delete this[oe][X]:this[oe][X]=ae}},{key:"getOpacity",value:function(){return this[F]}},{key:"setOpacity",value:function(X){if(X<0||X>1)throw new TypeError("Invalid opacity value.");this[A]&&this[A].positions.forEach(function(ae){ae[2]=1/ae[2]>0?X:-X}),this[F]=X}},{key:"setClipPath",value:function(X){this.clipPath=X,this[V].u_clipSampler&&this[V].u_clipSampler.delete(),this.setUniforms({u_clipSampler:null}),this[A]&&delete this[A].attributes.a_clipUV,X&&this[A]&&this[w]()}},{key:w,value:function(){if(this.clipPath){this[te]||(this[te]=j.default.createCanvas(1,1));var X=g()(this.boundingBox,2),ae=g()(X[0],2),ue=ae[0],he=ae[1],ge=g()(X[1],2),Me=ge[0],we=ge[1];Me&&we&&(this[te].width=Me-ue,this[te].height=we-he);var be=this[te].getContext("2d"),Ce=new Path2D(this.clipPath);be.clearRect(0,0,this[te].width,this[te].height),be.save(),be.translate(-ue,-he),be.fillStyle="white",be.fill(Ce),be.restore(),this[A].clipPath=this[te];var Ie=C(this.boundingBox,this[A].position0);this[A].attributes.a_clipUV=Ie}}},{key:"getPointAtLength",value:function(X){return Object(v.getPointAtLength)(this[R],X)}},{key:"getTotalLength",value:function(){return Object(v.getTotalLength)(this[R])}},{key:me,value:function(X){for(var ae=this[oe],ue=this[A].position0,he=Object.entries(X._attribute),ge=0;ge<he.length;ge++){var Me=g()(he[ge],2),we=Me[0],be=Me[1];if(we!=="a_color"&&we!=="a_sourceRect"&&be!=="ignored"){var Ce=ae[we];if(we==="uv"&&!Ce){var Ie=this[A].boundingBox||b()(ue);this[A].attributes[we]=C(Ie,ue)}else{this[A].attributes[we]=[];for(var Ae=0;Ae<ue.length;Ae++){var Ee=ue[Ae];this[A].attributes[we].push(Ce?Ce(Ee,ge,ue):Array(be.size).fill(0))}}}}}},{key:se,value:function(X,ae){for(var ue=X.positions,he=X.position0,ge=0;ge<ue.length;ge++){var Me=g()(he[ge],2),we=Me[0],be=Me[1],Ce=ue[ge];Ce[0]=we*ae[0]+be*ae[2]+ae[4],Ce[1]=we*ae[1]+be*ae[3]+ae[5]}this._updateMatrix=!1}},{key:ce,value:function(){var X=this[ie],ae=c()(this._radialGradientVector);if(ae){var ue=g()(ae,5),he=ue[0],ge=ue[1],Me=ue[3],we=ue[4];ae[0]=he*X[0]+ge*X[2]+X[4],ae[1]=he*X[1]+ge*X[3]+X[5],ae[3]=Me*X[0]+we*X[2]+X[4],ae[4]=Me*X[1]+we*X[3]+X[5],this[V].u_radialGradientVector=ae}}},{key:ee,value:function(X,ae){function ue(Ee,ke){return Ee==null&&ke==null?!0:Ee==null||ke==null?!1:Ee[0]===ke[0]&&Ee[1]===ke[1]&&Ee[2]===ke[2]&&Ee[3]===ke[3]}var he=this[V].u_texSampler;if(he){var ge=he._img,Me=ge.width,we=ge.height,be=ae.srcRect,Ce=ae.rect||[0,0];if(ae.rotated&&(Ce=[-Ce[1],Ce[0],Ce[3],Ce[2]]),Ce[2]==null&&(Ce[2]=be?be[2]:Me),Ce[3]==null&&(Ce[3]=be?be[3]:we),ae.hidden)X.textureCoord=X.positions.map(function(){return[-1,-1,-1]});else if(!X.textureCoord||!ue(this[Z].rect,ae.rect)||this[Z].hidden!==ae.hidden||this[Z].rotated!==ae.rotated){var Ie=null;ae.rotated&&(Ie=y.mat2d.rotate(Array.of(0,0,0,0,0,0),y.mat2d.fromValues(1,0,0,1,0,0),.5*Math.PI),Ie=y.mat2d.translate(Array.of(0,0,0,0,0,0),Ie,[0,-Ce[2]])),X.textureCoord=X.position0.map(function(Ee){var ke=g()(Ee,3),Ne=ke[0],Oe=ke[1],je=ke[2];if(1/je>0){if(ae.rotated){var Je=Ne*Ie[0]+Oe*Ie[2]+Ie[4],rt=Ne*Ie[1]+Oe*Ie[3]+Ie[5];Ne=Je,Oe=rt}var et=U([Ne,Oe],[Ce[0]/Ce[2],Ce[1]/Ce[3],Ce[2],Ce[3]],ae);return ae.repeat&&(et[2]=1),et}return[-1,-1,-1]})}if(be){var Ae=[be[0]/Me,be[1]/we,be[2]/Me,be[3]/we];X.attributes.a_sourceRect=X.positions.map(function(){return[].concat(Ae)})}else X.attributes.a_sourceRect=X.positions.map(function(){return[0,0,0,0]})}}},{key:"accurate",value:function(X){if(this.contours){var ae=this.contours.path;if(ae){var ue=this.contours.simplify,he=G(this.contours.path,2*X,ue);this[A]=null,this[R]=he}}}},{key:"canIgnore",value:function(){var X=this[L]==null||this[L].lineWidth===0||this[Y][3]===0,ae=this[W]==null||this[H][3]===0,ue=this[V].u_radialGradientVector==null,he=this[V].u_texSampler==null;return this[F]===0||this[J]==null&&X&&ae&&ue&&he&&!this.beforeRender&&!this.afterRender}},{key:"setStroke",value:function(){var X=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ae=X.thickness,ue=ae===void 0?1:ae,he=X.cap,ge=he===void 0?"butt":he,Me=X.join,we=Me===void 0?"miter":Me,be=X.miterLimit,Ce=be===void 0?10:be,Ie=X.color,Ae=Ie===void 0?[0,0,0,0]:Ie,Ee=X.lineDash,ke=Ee===void 0?null:Ee,Ne=X.lineDashOffset,Oe=Ne===void 0?0:Ne,je=X.roundSegments,Je=je===void 0?20:je;return this[A]=null,this[L]=new I.default({lineWidth:ue,lineCap:ge,lineJoin:we,miterLimit:Ce,roundSegments:Je}),typeof Ae=="string"&&(Ae=Object(P.default)(Ae)),this[Y]=Ae,this[L].lineDash=ke,this[L].lineDashOffset=Oe,this}},{key:"setFill",value:function(){var X=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ae=X.rule,ue=ae===void 0?this.fillRule:ae,he=X.color,ge=he===void 0?[0,0,0,0]:he;return this[A]=null,this[W]={rule:ue},typeof ge=="string"&&(ge=Object(P.default)(ge)),this[H]=ge,this}},{key:"setTexture",value:function(X){var ae=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(X&&X.image){var ue=X,he=ue.image,ge=ue.rect;if(X=he,ae.rect)for(var Me=0;Me<ae.rect.length;Me++)ge[Me]=ae.rect[Me];ae.rect=ge}return this[W]||this.setFill(),this.setUniforms({u_texSampler:X}),this[A]&&this[ee](this[A],ae),this[Z]=ae,this}},{key:"setCircularGradient",value:function(){var X=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ae=X.vector,ue=X.colors,he=X.type,ge=he===void 0?"fill":he;if(ae.length!==3)throw new TypeError("Invalid linearGradient.");this.setGradient({vector:ae,colors:ue,type:ge})}},{key:"setLinearGradient",value:function(){var X=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ae=X.vector,ue=X.colors,he=X.type,ge=he===void 0?"fill":he;if(ae.length!==4)throw new TypeError("Invalid linearGradient.");this.setGradient({vector:ae,colors:ue,type:ge})}},{key:"setRadialGradient",value:function(){var X=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ae=X.vector,ue=X.colors,he=X.type,ge=he===void 0?"fill":he;if(ae.length!==6)throw new TypeError("Invalid radialGradient.");this.setGradient({vector:ae,colors:ue,type:ge})}},{key:"setGradient",value:function(){var X=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ae=X.vector,ue=X.colors,he=X.type,ge=he===void 0?"fill":he;ue=ue.map(function(be){var Ce=be.offset,Ie=be.color;return typeof Ie=="string"&&(Ie=Object(P.default)(Ie)),{offset:Ce,color:Ie}}),this[pe]=this[pe]||{},this[pe][ge]={vector:ae,colors:ue},ue.sort(function(be,Ce){return be.offset-Ce.offset});var Me=[];ue.forEach(function(be){var Ce=be.offset,Ie=be.color;Me.push.apply(Me,[Ce].concat(c()(Ie)))});var we;if(ae.length===4?we=[ae[0],ae[1],0,ae[2],ae[3],0]:we=c()(ae),Me.length<40&&Me.push(-1),Me.length>40)throw new Error("Too many colors, should be less than 8 colors");return this._radialGradientVector=we,this[V].u_colorSteps=Me,ge==="fill"?this[V].u_gradientType=1:this[V].u_gradientType=0,this[ce](),this}},{key:"setUniforms",value:function(){var X=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return Object.assign(this[V],X),this}},{key:"setTransform",value:function(){for(var X=this[ie],ae=arguments.length,ue=new Array(ae),he=0;he<ae;he++)ue[he]=arguments[he];return y.mat2d.equals(ue,X)||(this[ie]=ue,delete this[O],this._updateMatrix=!0),this}},{key:"transform",value:function(){for(var X=this[ie],ae=arguments.length,ue=new Array(ae),he=0;he<ae;he++)ue[he]=arguments[he];return this[ie]=y.mat2d.multiply(Array.of(0,0,0,0,0,0),X,ue),delete this[O],this._updateMatrix=!0,this}},{key:"translate",value:function(X,ae){var ue=y.mat2d.create();return ue=y.mat2d.translate(Array.of(0,0,0,0,0,0),ue,[X,ae]),this.transform.apply(this,c()(ue))}},{key:"rotate",value:function(X){var ae=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[0,0],ue=g()(ae,2),he=ue[0],ge=ue[1],Me=y.mat2d.create();return Me=y.mat2d.translate(Array.of(0,0,0,0,0,0),Me,[he,ge]),Me=y.mat2d.rotate(Array.of(0,0,0,0,0,0),Me,X),Me=y.mat2d.translate(Array.of(0,0,0,0,0,0),Me,[-he,-ge]),this.transform.apply(this,c()(Me))}},{key:"scale",value:function(X){var ae=arguments.length>1&&arguments[1]!==void 0?arguments[1]:X,ue=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[0,0],he=g()(ue,2),ge=he[0],Me=he[1],we=y.mat2d.create();return we=y.mat2d.translate(Array.of(0,0,0,0,0,0),we,[ge,Me]),we=y.mat2d.scale(Array.of(0,0,0,0,0,0),we,[X,ae]),we=y.mat2d.translate(Array.of(0,0,0,0,0,0),we,[-ge,-Me]),this.transform.apply(this,c()(we))}},{key:"skew",value:function(X){var ae=arguments.length>1&&arguments[1]!==void 0?arguments[1]:X,ue=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[0,0],he=g()(ue,2),ge=he[0],Me=he[1],we=y.mat2d.create();return we=y.mat2d.translate(Array.of(0,0,0,0,0,0),we,[ge,Me]),we=y.mat2d.multiply(Array.of(0,0,0,0,0,0),we,y.mat2d.fromValues(1,Math.tan(ae),Math.tan(X),1,0,0)),we=y.mat2d.translate(Array.of(0,0,0,0,0,0),we,[-ge,-Me]),this.transform.apply(this,c()(we))}},{key:"clearFilter",value:function(){return this.setColorTransform(null),this[B].length=0,this}},{key:"setColorTransform",value:function(){for(var X=arguments.length,ae=new Array(X),ue=0;ue<X;ue++)ae[ue]=arguments[ue];return ae[0]===null?this.setUniforms({u_filterFlag:0,u_colorMatrix:0}):this.setUniforms({u_filterFlag:1,u_colorMatrix:ae}),this}},{key:"transformColor",value:function(){for(var X=this.uniforms.u_colorMatrix,ae=arguments.length,ue=new Array(ae),he=0;he<ae;he++)ue[he]=arguments[he];return X?X=Object(p.multiply)(X,ue):X=ue,this.setColorTransform.apply(this,c()(X)),this}},{key:"blur",value:function(X){return this[B].push("blur(".concat(X,"px)")),this}},{key:"brightness",value:function(){var X=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;return this[B].push("brightness(".concat(100*X,"%)")),this.transformColor.apply(this,c()(Object(p.brightness)(X)))}},{key:"contrast",value:function(){var X=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;return this[B].push("contrast(".concat(100*X,"%)")),this.transformColor.apply(this,c()(Object(p.contrast)(X)))}},{key:"dropShadow",value:function(X,ae){var ue=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,he=arguments.length>3&&arguments[3]!==void 0?arguments[3]:[0,0,0,1];return Array.isArray(he)&&(he=Object(T.default)(he)),this[B].push("drop-shadow(".concat(X,"px ").concat(ae,"px ").concat(ue,"px ").concat(he,")")),this}},{key:"grayscale",value:function(){var X=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;return this[B].push("grayscale(".concat(100*X,"%)")),this.transformColor.apply(this,c()(Object(p.grayscale)(X)))}},{key:"hueRotate",value:function(){var X=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return this[B].push("hue-rotate(".concat(X,"deg)")),this.transformColor.apply(this,c()(Object(p.hueRotate)(X)))}},{key:"invert",value:function(){var X=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;return this[B].push("invert(".concat(100*X,"%)")),this.transformColor.apply(this,c()(Object(p.invert)(X)))}},{key:"opacity",value:function(){var X=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;return this[B].push("opacity(".concat(100*X,"%)")),this.transformColor.apply(this,c()(Object(p.opacity)(X)))}},{key:"saturate",value:function(){var X=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;return this[B].push("saturate(".concat(100*X,"%)")),this.transformColor.apply(this,c()(Object(p.saturate)(X)))}},{key:"sepia",value:function(){var X=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;return this[B].push("sepia(".concat(100*X,"%)")),this.transformColor.apply(this,c()(Object(p.sepia)(X)))}},{key:"url",value:function(X){return this[B].push("url(".concat(X,")")),this}},{key:"isPointCollision",value:function(X,ae){var ue=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"both",he=this.meshData,ge=he.positions,Me=he.cells,we=this.invertMatrix,be=we[0]*X+we[2]*ae+we[4],Ce=we[1]*X+we[3]*ae+we[5],Ie=this.boundingBox;if(be<Ie[0][0]||be>Ie[1][0]||Ce<Ie[0][1]||Ce>Ie[1][1])return!1;function Ae(vi,yo,fM){var Ld=g()(vi,2),gM=Ld[0],pM=Ld[1],Nd=g()(yo,2),Od=Nd[0],zd=Nd[1],Bd=g()(fM,2),mM=Bd[0],yM=Bd[1],jd=mM-Od,Fd=yM-zd,Ud=((gM-Od)*jd+(pM-zd)*Fd)/(Math.pow(jd,2)+Math.pow(Fd,2));return Ud>=0&&Ud<=1}for(var Ee=0;Ee<Me.length;Ee++){var ke=Me[Ee];if(ue==="fill"&&ke[0]>=he.fillPointCount)break;if(!(ue==="stroke"&&ke[0]<he.fillPointCount)){var Ne=ke.map(function(vi){return ge[vi]}),Oe=g()(Ne,3),je=g()(Oe[0],2),Je=je[0],rt=je[1],et=g()(Oe[1],2),nt=et[0],Qe=et[1],st=g()(Oe[2],2),ut=st[0],Ke=st[1],Wt=Math.sign((X-Je)*(Qe-rt)-(nt-Je)*(ae-rt));if(Wt===0&&Ae([X,ae],[Je,rt],[nt,Qe]))return!0;var Br=Math.sign((X-nt)*(Ke-Qe)-(ut-nt)*(ae-Qe));if(Br===0&&Ae([X,ae],[nt,Qe],[ut,Ke]))return!0;var jr=Math.sign((X-ut)*(rt-Ke)-(Je-ut)*(ae-Ke));if(jr===0&&Ae([X,ae],[ut,Ke],[Je,rt])||Wt===1&&Br===1&&jr===1||Wt===-1&&Br===-1&&jr===-1)return!0}}return!1}},{key:"isPointInFill",value:function(X,ae){return this.isPointCollision(X,ae,"fill")}},{key:"isPointInStroke",value:function(X,ae){return this.isPointCollision(X,ae,"stroke")}},{key:"addPass",value:function(X){var ae=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ue=ae.width,he=ae.height,ge=o()(ae,["width","height"]),Me=new z.default;Me.rect(0,0,ue,he);var we=new re(Me);we.setUniforms(ge),we.setProgram(X),this[K].push(we)}},{key:"contours",get:function(){return this[R]},set:function(X){this[A]=null,this[R]=X;var ae=X.scale,ue=this.transformScale/ae;ue>1.5&&this.accurate(this.transformScale)}},{key:"program",get:function(){return this[J]}},{key:"blend",get:function(){return this[$]==null?"auto":this[$]},set:function(X){this[$]=X,this[A]&&(this[A].enableBlend=this.enableBlend)}},{key:"boundingBox",get:function(){if(this[A]&&this[A].boundingBox)return this[A].boundingBox;var X=this.meshData;if(X){var ae=X.position0;if(ae.length)X.boundingBox=b()(ae);else return[[0,0],[0,0]];return X.boundingBox}return[[0,0],[0,0]]}},{key:"boundingCenter",get:function(){var X=this.boundingBox;return X?[.5*(X[0][0]+X[1][0]),.5*(X[0][1]+X[1][1])]:[0,0]}},{key:"fillRule",get:function(){return this[W]?this[W].rule:"nonzero"}},{key:"lineWidth",get:function(){return this[L]?this[L].lineWidth:0}},{key:"lineCap",get:function(){return this[L]?this[L].lineCap:""}},{key:"lineJoin",get:function(){return this[L]?this[L].lineJoin:""}},{key:"miterLimit",get:function(){return this[L]?this[L].miterLimit:0}},{key:"strokeStyle",get:function(){return this[Y]&&this[Y][3]!==0?Object(T.default)(this[Y]):""}},{key:"lineDash",get:function(){return this[L]?this[L].lineDash:null}},{key:"lineDashOffset",get:function(){return this[L]?this[L].lineDashOffset:0}},{key:"fillStyle",get:function(){return this[H]&&this[H][3]!==0?Object(T.default)(this[H]):""}},{key:"gradient",get:function(){return this[pe]}},{key:"texture",get:function(){return this[V].u_texSampler?{image:this[V].u_texSampler._img,options:this[Z]}:null}},{key:"enableBlend",get:function(){return this[$]===!0||this[$]===!1?this[$]:this[F]<1||this[Y]!=null&&this[Y][3]<1||this[H]!=null&&this[H][3]<1||this[V].u_colorMatrix!=null&&this[V].u_colorMatrix[18]<1||this[V].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[B].join(" ")}},{key:"transformMatrix",get:function(){return this[ie]}},{key:"invertMatrix",get:function(){if(!this[O]){var X=y.mat2d.invert(Array.of(0,0,0,0,0,0),this[ie]);this[O]=X}return this[O]}},{key:"transformScale",get:function(){var X=this[ie];return Math.max(Math.hypot(X[0],X[1]),Math.hypot(X[2],X[3]))}},{key:"uniforms",get:function(){return this[V]}},{key:"pass",get:function(){return this[K]}},{key:"meshData",get:function(){var X=this;if(this._updateMatrix){var ae=this.transformScale/this.contours.scale;ae>1.5&&this.accurate(this.transformScale)}if(!this[A]){!this[W]&&!this[L]&&this.setFill();var ue=this[R],he={};if(ue&&ue.length){if(this[W])try{var ge=k()(ue,this[W]);ge.positions=ge.positions.map(function(Ee){return Ee.push(X[F]),Ee}),ge.attributes={a_color:Array.from({length:ge.positions.length}).map(function(){return X[H].map(function(Ee){return Math.round(255*Ee)})})},he.fill=ge}catch{}if(this[L]){var Me=this[L].lineDash,we=ue;if(Me){var be=this[L].lineDashOffset;we=Object(v.getDashContours)(ue,Me,be)}var Ce=we.map(function(Ee,ke){var Ne=Ee.length>1&&y.vec2.equals(Ee[0],Ee[Ee.length-1]),Oe=X[L].build(Ee,Ne);return k()([Oe])});Ce.forEach(function(Ee){Ee.positions=Ee.positions.map(function(ke){return ke.push(-X[F]),ke}),Ee.attributes={a_color:Array.from({length:Ee.positions.length}).map(function(){return X[Y].map(function(ke){return Math.round(255*ke)})})}}),he.stroke=Object(N.default)(Ce)}}var Ie=Object(N.default)([he.fill,he.stroke]);Ie.fillPointCount=he.fill?he.fill.positions.length:0,Ie.enableBlend=this.enableBlend,Ie.position0=Ie.positions.map(function(Ee){var ke=g()(Ee,3),Ne=ke[0],Oe=ke[1],je=ke[2];return[Ne,Oe,je]}),Ie.uniforms=this[V],this[A]=Ie,this[V].u_texSampler&&this[ee](Ie,this[Z]);var Ae=this[ie];Object(m.isUnitTransform)(Ae)||(this[se](Ie,Ae),this[V].u_radialGradientVector&&this[ce]()),this.clipPath&&this[w](),this[J]&&this[me](this[J])}return this._updateMatrix&&(this[A].matrix=this[ie],this[se](this[A],this[ie]),this[V].u_radialGradientVector&&this[ce]()),this[A]}}]),re}()},function(e,r,n){var i=n(75);function o(a,c){if(a==null)return{};var l=i(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(i,o){if(i==null)return{};var a={},c=Object.keys(i),l,u;for(u=0;u<c.length;u++)l=c[u],!(o.indexOf(l)>=0)&&(a[l]=i[l]);return a}e.exports=n},function(e,r,n){n.r(r);var i=n(77);n(1).glMatrix.setMatrixArrayType(Array),r.default=i.Stroke},function(e,r,n){n.r(r),n.d(r,"Stroke",function(){return I});var i=n(19),o=n.n(i),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)(),f=Object(h.create)(),g=Object(h.create)(),y=Object(h.create)(),S=Object(h.create)(),b=1e20,I=function(){function m(){var v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},M=v.lineWidth,k=M===void 0?1:M,E=v.lineJoin,D=E===void 0?"miter":E,P=v.miterLimit,z=P===void 0?10:P,j=v.lineCap,A=j===void 0?"butt":j,R=v.roundSegments,L=R===void 0?20:R;c()(this,m),this.lineWidth=k,this.lineJoin=D,this.miterLimit=z,this.lineCap=A,this.roundSegments=L,this._normal=null}return u()(m,[{key:"build",value:function(M){var k=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,E=M.length;if(M=o()(M),E<2)return M;k&&((M[0][0]!==M[E-1][0]||M[0][1]!==M[E-1][1])&&M.push(o()(M[0])),M.push(o()(M[1]))),E=M.length,this._normal=null;var D={left:[],right:[]},P=this.lineWidth/2,z=this.lineCap;if(!k&&z==="square"){Object(h.direction)(f,M[0],M[1]),Object(h.scaleAndAdd)(M[0],M[0],f,P);var j=M.length-1;Object(h.direction)(f,M[j],M[j-1]),Object(h.scaleAndAdd)(M[j],M[j],f,P)}for(var A=1;A<E;A++){var R=M[A-1],L=M[A],W=M[A+1];this._seg(D,R,L,W,P,k)}!k&&z==="round"&&p(D,this.roundSegments);var Y=[].concat(o()(D.left),o()(D.right.reverse()));return Y}},{key:"_seg",value:function(M,k,E,D,P,z){var j=this.lineJoin==="bevel",A=this.lineJoin==="round";if(Object(h.direction)(f,E,k),this._normal||(this._normal=Object(h.create)(),Object(h.normal)(this._normal,f)),M.left.length||T(M,k,this._normal,P),!D)Object(h.normal)(this._normal,f),z?T(M,k,this._normal,P):T(M,E,this._normal,P);else{Object(h.direction)(g,D,E);var R=Object(h.computeMiter)(y,S,f,g,P);R=Math.min(R,b);var L=Object(h.dot)(y,this._normal)<0?-1:1,W=j||A;if(!W&&this.lineJoin==="miter"){var Y=R/P;Y>this.miterLimit&&(W=!0)}if(W){Object(h.scaleAndAdd)(d,E,this._normal,-P*L),N(M,d,L);var H=1/0;k&&(H=Math.min(H,Math.hypot(E[0]-k[0],E[1]-k[1]))),D&&(H=Math.min(H,Math.hypot(D[0]-E[0],D[1]-E[1])));var ie=Math.max(P,Math.min(R,H));if(Object(h.scaleAndAdd)(d,E,S,ie*L),N(M,d,-L),D)if(Object(h.normal)(d,g),Object(h.copy)(this._normal,d),Object(h.scaleAndAdd)(d,E,d,-P*L),A){for(var O=Object(h.clone)(d),V=L>0?M.left[M.left.length-1]:M.right[M.right.length-1],Z=Object(h.clone)(E),$=Object(h.sub)(Object(h.create)(),V,Z),ee=Object(h.sub)(Object(h.create)(),O,Z),se=Math.PI/this.roundSegments,ce=0;ce<this.roundSegments&&(Object(h.rotate)($,$,[0,0],L*se),Math.sign(Object(h.cross)(d,$,ee)[2])===L);ce++)Object(h.add)(d,$,Z),N(M,d,L);N(M,O,L)}else N(M,d,L)}else T(M,E,S,R),Object(h.copy)(this._normal,S)}}}]),m}();function N(m,v,M){M>0?m.left.push(Object(h.clone)(v)):m.right.push(Object(h.clone)(v))}function T(m,v,M,k){var E=arguments.length>4&&arguments[4]!==void 0?arguments[4]:-1;Object(h.scaleAndAdd)(d,v,M,-k),N(m,d,-E),Object(h.scaleAndAdd)(d,v,M,k),N(m,d,E)}function p(m,v){var M=m.left,k=m.right,E=Object(h.create)(),D=Object(h.create)(),P=M[0],z=k[0],j=[.5*(P[0]+z[0]),.5*(P[1]+z[1])];Object(h.sub)(D,P,j);for(var A=1;A<=v;A++){var R=-1*Math.PI*A/v;Object(h.rotate)(E,D,[0,0],R),Object(h.add)(d,j,E),M.unshift(Object(h.clone)(d))}P=k[k.length-1],z=M[M.length-1],j=[.5*(P[0]+z[0]),.5*(P[1]+z[1])],Object(h.sub)(D,P,j);for(var L=1;L<=v;L++){var W=-1*Math.PI*L/v;Object(h.rotate)(E,D,[0,0],W),Object(h.add)(d,j,E),k.push(Object(h.clone)(d))}}},function(e,r,n){n.r(r),n.d(r,"isUnitTransform",function(){return i}),n(1).glMatrix.setMatrixArrayType(Array);function i(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 i=n(80),o=n(81);e.exports=function(a,c){if(c=c||{},a=a.filter(function(I){return I.length>2}),a.length===0)return{positions:[],cells:[]};typeof c.vertexSize!="number"&&(c.vertexSize=a[0][0].length),a=a.map(function(I){return I.reduce(function(N,T){return N.concat(T)})});for(var l=c.rule==="evenodd"?i.WINDING_ODD:i.WINDING_NONZERO,u=i.tesselate(o({contours:a,windingRule:l,elementType:i.POLYGONS,polySize:3,vertexSize:2},c)),h=[],d=0;d<u.vertices.length;d+=c.vertexSize){var f=u.vertices.slice(d,d+c.vertexSize);h.push(f)}var g=[];for(d=0;d<u.elements.length;d+=3){var y=u.elements[d],S=u.elements[d+1],b=u.elements[d+2];g.push([y,S,b])}return{positions:h,cells:g}}},function(e,r,n){n(1).glMatrix.setMatrixArrayType(Array);var i={},o={};e.exports=i,i.WINDING_ODD=0,i.WINDING_NONZERO=1,i.WINDING_POSITIVE=2,i.WINDING_NEGATIVE=3,i.WINDING_ABS_GEQ_TWO=4,i.POLYGONS=0,i.CONNECTED_POLYGONS=1,i.BOUNDARY_CONTOURS=2,i.tesselate=function(T){for(var p=T.debug||!1,m=new N,v=0;v<T.contours.length;v++)m.addContour(T.vertexSize||2,T.contours[v]);return m.tesselate(T.windingRule||i.WINDING_ODD,T.elementType||i.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:p?m.mesh:void 0}};var a=function(p){if(!p)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,p=new l,m=new u(0),v=new u(1);T.next=T.prev=T,T.anEdge=null,p.next=p.prev=p,p.anEdge=null,p.trail=null,p.marked=!1,p.inside=!1,m.next=m,m.Sym=v,m.Onext=null,m.Lnext=null,m.Org=null,m.Lface=null,m.winding=0,m.activeRegion=null,v.next=v,v.Sym=m,v.Onext=null,v.Lnext=null,v.Org=null,v.Lface=null,v.winding=0,v.activeRegion=null,this.vHead=T,this.fHead=p,this.eHead=m,this.eHeadSym=v}h.prototype={makeEdge_:function(p){var m=new u(0),v=new u(1);p.Sym.side<p.side&&(p=p.Sym);var M=p.Sym.next;return v.next=M,M.Sym.next=m,m.next=p,p.Sym.next=v,m.Sym=v,m.Onext=m,m.Lnext=v,m.Org=null,m.Lface=null,m.winding=0,m.activeRegion=null,v.Sym=m,v.Onext=v,v.Lnext=m,v.Org=null,v.Lface=null,v.winding=0,v.activeRegion=null,m},splice_:function(p,m){var v=p.Onext,M=m.Onext;v.Sym.Lnext=m,M.Sym.Lnext=p,p.Onext=M,m.Onext=v},makeVertex_:function(p,m,v){var M=p;a(M!==null);var k=v.prev;M.prev=k,k.next=M,M.next=v,v.prev=M,M.anEdge=m;var E=m;do E.Org=M,E=E.Onext;while(E!==m)},makeFace_:function(p,m,v){var M=p;a(M!==null);var k=v.prev;M.prev=k,k.next=M,M.next=v,v.prev=M,M.anEdge=m,M.trail=null,M.marked=!1,M.inside=v.inside;var E=m;do E.Lface=M,E=E.Lnext;while(E!==m)},killEdge_:function(p){p.Sym.side<p.side&&(p=p.Sym);var m=p.next,v=p.Sym.next;m.Sym.next=v,v.Sym.next=m},killVertex_:function(p,m){var v=p.anEdge,M=v;do M.Org=m,M=M.Onext;while(M!==v);var k=p.prev,E=p.next;E.prev=k,k.next=E},killFace_:function(p,m){var v=p.anEdge,M=v;do M.Lface=m,M=M.Lnext;while(M!==v);var k=p.prev,E=p.next;E.prev=k,k.next=E},makeEdge:function(){var p=new c,m=new c,v=new l,M=this.makeEdge_(this.eHead);return this.makeVertex_(p,M,this.vHead),this.makeVertex_(m,M.Sym,this.vHead),this.makeFace_(v,M,this.fHead),M},splice:function(p,m){var v=!1,M=!1;if(p!==m){if(m.Org!==p.Org&&(M=!0,this.killVertex_(m.Org,p.Org)),m.Lface!==p.Lface&&(v=!0,this.killFace_(m.Lface,p.Lface)),this.splice_(m,p),!M){var k=new c;this.makeVertex_(k,m,p.Org),p.Org.anEdge=p}if(!v){var E=new l;this.makeFace_(E,m,p.Lface),p.Lface.anEdge=p}}},delete:function(p){var m=p.Sym,v=!1;if(p.Lface!==p.Rface&&(v=!0,this.killFace_(p.Lface,p.Rface)),p.Onext===p)this.killVertex_(p.Org,null);else if(p.Rface.anEdge=p.Oprev,p.Org.anEdge=p.Onext,this.splice_(p,p.Oprev),!v){var M=new l;this.makeFace_(M,p,p.Lface)}m.Onext===m?(this.killVertex_(m.Org,null),this.killFace_(m.Lface,null)):(p.Lface.anEdge=m.Oprev,m.Org.anEdge=m.Onext,this.splice_(m,m.Oprev)),this.killEdge_(p)},addEdgeVertex:function(p){var m=this.makeEdge_(p),v=m.Sym;this.splice_(m,p.Lnext),m.Org=p.Dst;var M=new c;return this.makeVertex_(M,v,m.Org),m.Lface=v.Lface=p.Lface,m},splitEdge:function(p,m){var v=this.addEdgeVertex(p),M=v.Sym;return this.splice_(p.Sym,p.Sym.Oprev),this.splice_(p.Sym,M),p.Dst=M.Org,M.Dst.anEdge=M.Sym,M.Rface=p.Rface,M.winding=p.winding,M.Sym.winding=p.Sym.winding,M},connect:function(p,m){var v=!1,M=this.makeEdge_(p),k=M.Sym;if(m.Lface!==p.Lface&&(v=!0,this.killFace_(m.Lface,p.Lface)),this.splice_(M,p.Lnext),this.splice_(k,m),M.Org=p.Dst,k.Org=m.Org,M.Lface=k.Lface=p.Lface,p.Lface.anEdge=k,!v){var E=new l;this.makeFace_(E,M,p.Lface)}return M},zapFace:function(p){var m=p.anEdge,v,M,k,E,D;M=m.Lnext;do v=M,M=v.Lnext,v.Lface=null,v.Rface===null&&(v.Onext===v?this.killVertex_(v.Org,null):(v.Org.anEdge=v.Onext,this.splice_(v,v.Oprev)),k=v.Sym,k.Onext===k?this.killVertex_(k.Org,null):(k.Org.anEdge=k.Onext,this.splice_(k,k.Oprev)),this.killEdge_(v));while(v!=m);E=p.prev,D=p.next,D.prev=E,E.next=D},countFaceVerts_:function(p){var m=p.anEdge,v=0;do v++,m=m.Lnext;while(m!==p.anEdge);return v},mergeConvexFaces:function(p){var m,v,M,k,E,D,P;for(m=this.fHead.next;m!==this.fHead;m=m.next)if(m.inside)for(v=m.anEdge,E=v.Org;M=v.Lnext,k=v.Sym,k&&k.Lface&&k.Lface.inside&&(D=this.countFaceVerts_(m),P=this.countFaceVerts_(k.Lface),D+P-2<=p&&o.vertCCW(v.Lprev.Org,v.Org,k.Lnext.Lnext.Org)&&o.vertCCW(k.Lprev.Org,k.Org,v.Lnext.Lnext.Org)&&(M=k.Lnext,this.delete(k),v=null,k=null)),!(v&&v.Lnext.Org===E);)v=M;return!0},check:function(){var p=this.fHead,m=this.vHead,v=this.eHead,M,k,E,D,P,z;for(k=p,k=p;(M=k.next)!==p;k=M){a(M.prev===k),P=M.anEdge;do a(P.Sym!==P),a(P.Sym.Sym===P),a(P.Lnext.Onext.Sym===P),a(P.Onext.Sym.Lnext===P),a(P.Lface===M),P=P.Lnext;while(P!==M.anEdge)}for(a(M.prev===k&&M.anEdge===null),D=m,D=m;(E=D.next)!==m;D=E){a(E.prev===D),P=E.anEdge;do a(P.Sym!==P),a(P.Sym.Sym===P),a(P.Lnext.Onext.Sym===P),a(P.Onext.Sym.Lnext===P),a(P.Org===E),P=P.Onext;while(P!==E.anEdge)}for(a(E.prev===D&&E.anEdge===null),z=v,z=v;(P=z.next)!==v;z=P)a(P.Sym.next===z.Sym),a(P.Sym!==P),a(P.Sym.Sym===P),a(P.Org!==null),a(P.Dst!==null),a(P.Lnext.Onext.Sym===P),a(P.Onext.Sym.Lnext===P);a(P.Sym.next===z.Sym&&P.Sym===this.eHeadSym&&P.Sym.Sym===P&&P.Org===null&&P.Dst===null&&P.Lface===null&&P.Rface===null)}},o.vertEq=function(T,p){return T.s===p.s&&T.t===p.t},o.vertLeq=function(T,p){return T.s<p.s||T.s===p.s&&T.t<=p.t},o.transLeq=function(T,p){return T.t<p.t||T.t===p.t&&T.s<=p.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,p){return Math.abs(T.s-p.s)+Math.abs(T.t-p.t)},o.edgeEval=function(T,p,m){a(o.vertLeq(T,p)&&o.vertLeq(p,m));var v=p.s-T.s,M=m.s-p.s;return v+M>0?v<M?p.t-T.t+(T.t-m.t)*(v/(v+M)):p.t-m.t+(m.t-T.t)*(M/(v+M)):0},o.edgeSign=function(T,p,m){a(o.vertLeq(T,p)&&o.vertLeq(p,m));var v=p.s-T.s,M=m.s-p.s;return v+M>0?(p.t-m.t)*v+(p.t-T.t)*M:0},o.transEval=function(T,p,m){a(o.transLeq(T,p)&&o.transLeq(p,m));var v=p.t-T.t,M=m.t-p.t;return v+M>0?v<M?p.s-T.s+(T.s-m.s)*(v/(v+M)):p.s-m.s+(m.s-T.s)*(M/(v+M)):0},o.transSign=function(T,p,m){a(o.transLeq(T,p)&&o.transLeq(p,m));var v=p.t-T.t,M=m.t-p.t;return v+M>0?(p.s-m.s)*v+(p.s-T.s)*M:0},o.vertCCW=function(T,p,m){return T.s*(p.t-m.t)+p.s*(m.t-T.t)+m.s*(T.t-p.t)>=0},o.interpolate=function(T,p,m,v){return T=T<0?0:T,m=m<0?0:m,T<=m?m===0?(p+v)/2:p+(v-p)*(T/(T+m)):v+(p-v)*(m/(T+m))},o.intersect=function(T,p,m,v,M){var k,E,D;o.vertLeq(T,p)||(D=T,T=p,p=D),o.vertLeq(m,v)||(D=m,m=v,v=D),o.vertLeq(T,m)||(D=T,T=m,m=D,D=p,p=v,v=D),o.vertLeq(m,p)?o.vertLeq(p,v)?(k=o.edgeEval(T,m,p),E=o.edgeEval(m,p,v),k+E<0&&(k=-k,E=-E),M.s=o.interpolate(k,m.s,E,p.s)):(k=o.edgeSign(T,m,p),E=-o.edgeSign(T,v,p),k+E<0&&(k=-k,E=-E),M.s=o.interpolate(k,m.s,E,v.s)):M.s=(m.s+p.s)/2,o.transLeq(T,p)||(D=T,T=p,p=D),o.transLeq(m,v)||(D=m,m=v,v=D),o.transLeq(T,m)||(D=T,T=m,m=D,D=p,p=v,v=D),o.transLeq(m,p)?o.transLeq(p,v)?(k=o.transEval(T,m,p),E=o.transEval(m,p,v),k+E<0&&(k=-k,E=-E),M.t=o.interpolate(k,m.t,E,p.t)):(k=o.transSign(T,m,p),E=-o.transSign(T,v,p),k+E<0&&(k=-k,E=-E),M.t=o.interpolate(k,m.t,E,v.t)):M.t=(m.t+p.t)/2};function d(){this.key=null,this.next=null,this.prev=null}function f(T,p){this.head=new d,this.head.next=this.head,this.head.prev=this.head,this.frame=T,this.leq=p}f.prototype={min:function(){return this.head.next},max:function(){return this.head.prev},insert:function(p){return this.insertBefore(this.head,p)},search:function(p){var m=this.head;do m=m.next;while(m.key!==null&&!this.leq(this.frame,p,m.key));return m},insertBefore:function(p,m){do p=p.prev;while(p.key!==null&&!this.leq(this.frame,p.key,m));var v=new d;return v.key=m,v.next=p.next,p.next.prev=v,v.prev=p,p.next=v,v},delete:function(p){p.next.prev=p.prev,p.prev.next=p.next}};function g(){this.handle=null}function y(){this.key=null,this.node=null}function S(T,p){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 g;for(this.handles=[],this.handles.length=T+1,m=0;m<this.handles.length;m++)this.handles[m]=new y;this.initialized=!1,this.freeList=0,this.leq=p,this.nodes[1].handle=1,this.handles[1].key=null}S.prototype={floatDown_:function(p){var m=this.nodes,v=this.handles,M,k,E;for(M=m[p].handle;;){if(E=p<<1,E<this.size&&this.leq(v[m[E+1].handle].key,v[m[E].handle].key)&&++E,a(E<=this.max),k=m[E].handle,E>this.size||this.leq(v[M].key,v[k].key)){m[p].handle=M,v[M].node=p;break}m[p].handle=k,v[k].node=p,p=E}},floatUp_:function(p){var m=this.nodes,v=this.handles,M,k,E;for(M=m[p].handle;;){if(E=p>>1,k=m[E].handle,E===0||this.leq(v[k].key,v[M].key)){m[p].handle=M,v[M].node=p;break}m[p].handle=k,v[k].node=p,p=E}},init:function(){for(var p=this.size;p>=1;--p)this.floatDown_(p);this.initialized=!0},min:function(){return this.handles[this.nodes[1].handle].key},insert:function(p){var m,v;if(m=++this.size,m*2>this.max){this.max*=2;var M,k;for(k=this.nodes.length,this.nodes.length=this.max+1,M=k;M<this.nodes.length;M++)this.nodes[M]=new g;for(k=this.handles.length,this.handles.length=this.max+1,M=k;M<this.handles.length;M++)this.handles[M]=new y}return this.freeList===0?v=m:(v=this.freeList,this.freeList=this.handles[v].node),this.nodes[m].handle=v,this.handles[v].node=m,this.handles[v].key=p,this.initialized&&this.floatUp_(m),v},extractMin:function(){var p=this.nodes,m=this.handles,v=p[1].handle,M=m[v].key;return this.size>0&&(p[1].handle=p[this.size].handle,m[p[1].handle].node=1,m[v].key=null,m[v].node=this.freeList,this.freeList=v,--this.size,this.size>0&&this.floatDown_(1)),M},delete:function(p){var m=this.nodes,v=this.handles,M;a(p>=1&&p<=this.max&&v[p].key!==null),M=v[p].node,m[M].handle=m[this.size].handle,v[m[M].handle].node=M,--this.size,M<=this.size&&(M<=1||this.leq(v[m[M>>1].handle].key,v[m[M].handle].key)?this.floatDown_(M):this.floatUp_(M)),v[p].key=null,v[p].node=this.freeList,this.freeList=p}};function b(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}var I={};I.regionBelow=function(T){return T.nodeUp.prev.key},I.regionAbove=function(T){return T.nodeUp.next.key},I.debugEvent=function(T){},I.addWinding=function(T,p){T.winding+=p.winding,T.Sym.winding+=p.Sym.winding},I.edgeLeq=function(T,p,m){var v=T.event,E,D,M=p.eUp,k=m.eUp;if(M.Dst===v)return k.Dst===v?o.vertLeq(M.Org,k.Org)?o.edgeSign(k.Dst,M.Org,k.Org)<=0:o.edgeSign(M.Dst,k.Org,M.Org)>=0:o.edgeSign(k.Dst,v,k.Org)<=0;if(k.Dst===v)return o.edgeSign(M.Dst,v,M.Org)>=0;var E=o.edgeEval(M.Dst,v,M.Org),D=o.edgeEval(k.Dst,v,k.Org);return E>=D},I.deleteRegion=function(T,p){p.fixUpperEdge&&a(p.eUp.winding===0),p.eUp.activeRegion=null,T.dict.delete(p.nodeUp)},I.fixUpperEdge=function(T,p,m){a(p.fixUpperEdge),T.mesh.delete(p.eUp),p.fixUpperEdge=!1,p.eUp=m,m.activeRegion=p},I.topLeftRegion=function(T,p){var m=p.eUp.Org,v;do p=I.regionAbove(p);while(p.eUp.Org===m);if(p.fixUpperEdge){if(v=T.mesh.connect(I.regionBelow(p).eUp.Sym,p.eUp.Lnext),v===null)return null;I.fixUpperEdge(T,p,v),p=I.regionAbove(p)}return p},I.topRightRegion=function(T){var p=T.eUp.Dst;do T=I.regionAbove(T);while(T.eUp.Dst===p);return T},I.addRegionBelow=function(T,p,m){var v=new b;return v.eUp=m,v.nodeUp=T.dict.insertBefore(p.nodeUp,v),v.fixUpperEdge=!1,v.sentinel=!1,v.dirty=!1,m.activeRegion=v,v},I.isWindingInside=function(T,p){switch(T.windingRule){case i.WINDING_ODD:return(p&1)!==0;case i.WINDING_NONZERO:return p!==0;case i.WINDING_POSITIVE:return p>0;case i.WINDING_NEGATIVE:return p<0;case i.WINDING_ABS_GEQ_TWO:return p>=2||p<=-2}return a(!1),!1},I.computeWinding=function(T,p){p.windingNumber=I.regionAbove(p).windingNumber+p.eUp.winding,p.inside=I.isWindingInside(T,p.windingNumber)},I.finishRegion=function(T,p){var m=p.eUp,v=m.Lface;v.inside=p.inside,v.anEdge=m,I.deleteRegion(T,p)},I.finishLeftRegions=function(T,p,m){for(var v,E,M=null,k=p,E=p.eUp;k!==m;){if(k.fixUpperEdge=!1,M=I.regionBelow(k),v=M.eUp,v.Org!=E.Org){if(!M.fixUpperEdge){I.finishRegion(T,k);break}v=T.mesh.connect(E.Lprev,v.Sym),I.fixUpperEdge(T,M,v)}E.Onext!==v&&(T.mesh.splice(v.Oprev,v),T.mesh.splice(E,v)),I.finishRegion(T,k),E=M.eUp,k=M}return E},I.addRightEdges=function(T,p,m,v,M,k){var E,D,P,z,j=!0;P=m;do a(o.vertLeq(P.Org,P.Dst)),I.addRegionBelow(T,p,P.Sym),P=P.Onext;while(P!==v);for(M===null&&(M=I.regionBelow(p).eUp.Rprev),D=p,z=M;E=I.regionBelow(D),P=E.eUp.Sym,P.Org===z.Org;)P.Onext!==z&&(T.mesh.splice(P.Oprev,P),T.mesh.splice(z.Oprev,P)),E.windingNumber=D.windingNumber-P.winding,E.inside=I.isWindingInside(T,E.windingNumber),D.dirty=!0,!j&&I.checkForRightSplice(T,D)&&(I.addWinding(P,z),I.deleteRegion(T,D),T.mesh.delete(z)),j=!1,D=E,z=P;D.dirty=!0,a(D.windingNumber-P.winding===E.windingNumber),k&&I.walkDirtyRegions(T,D)},I.spliceMergeVertices=function(T,p,m){T.mesh.splice(p,m)},I.vertexWeights=function(T,p,m){var v=o.vertL1dist(p,T),M=o.vertL1dist(m,T),k=.5*M/(v+M),E=.5*v/(v+M);T.coords[0]+=k*p.coords[0]+E*m.coords[0],T.coords[1]+=k*p.coords[1]+E*m.coords[1],T.coords[2]+=k*p.coords[2]+E*m.coords[2]},I.getIntersectData=function(T,p,m,v,M,k){p.coords[0]=p.coords[1]=p.coords[2]=0,p.idx=-1,I.vertexWeights(p,m,v),I.vertexWeights(p,M,k)},I.checkForRightSplice=function(T,p){var m=I.regionBelow(p),v=p.eUp,M=m.eUp;if(o.vertLeq(v.Org,M.Org)){if(o.edgeSign(M.Dst,v.Org,M.Org)>0)return!1;o.vertEq(v.Org,M.Org)?v.Org!==M.Org&&(T.pq.delete(v.Org.pqHandle),I.spliceMergeVertices(T,M.Oprev,v)):(T.mesh.splitEdge(M.Sym),T.mesh.splice(v,M.Oprev),p.dirty=m.dirty=!0)}else{if(o.edgeSign(v.Dst,M.Org,v.Org)<0)return!1;I.regionAbove(p).dirty=p.dirty=!0,T.mesh.splitEdge(v.Sym),T.mesh.splice(M.Oprev,v)}return!0},I.checkForLeftSplice=function(T,p){var m=I.regionBelow(p),v=p.eUp,M=m.eUp,k;if(a(!o.vertEq(v.Dst,M.Dst)),o.vertLeq(v.Dst,M.Dst)){if(o.edgeSign(v.Dst,M.Dst,v.Org)<0)return!1;I.regionAbove(p).dirty=p.dirty=!0,k=T.mesh.splitEdge(v),T.mesh.splice(M.Sym,k),k.Lface.inside=p.inside}else{if(o.edgeSign(M.Dst,v.Dst,M.Org)>0)return!1;p.dirty=m.dirty=!0,k=T.mesh.splitEdge(M),T.mesh.splice(v.Lnext,M.Sym),k.Rface.inside=p.inside}return!0},I.checkForIntersect=function(T,p){var m=I.regionBelow(p),v=p.eUp,M=m.eUp,k=v.Org,E=M.Org,D=v.Dst,P=M.Dst,z,j,A=new c,R,L;if(a(!o.vertEq(P,D)),a(o.edgeSign(D,T.event,k)<=0),a(o.edgeSign(P,T.event,E)>=0),a(k!==T.event&&E!==T.event),a(!p.fixUpperEdge&&!m.fixUpperEdge),k===E||(z=Math.min(k.t,D.t),j=Math.max(E.t,P.t),z>j))return!1;if(o.vertLeq(k,E)){if(o.edgeSign(P,k,E)>0)return!1}else if(o.edgeSign(D,E,k)<0)return!1;return I.debugEvent(T),o.intersect(D,k,P,E,A),a(Math.min(k.t,D.t)<=A.t),a(A.t<=Math.max(E.t,P.t)),a(Math.min(P.s,D.s)<=A.s),a(A.s<=Math.max(E.s,k.s)),o.vertLeq(A,T.event)&&(A.s=T.event.s,A.t=T.event.t),R=o.vertLeq(k,E)?k:E,o.vertLeq(R,A)&&(A.s=R.s,A.t=R.t),o.vertEq(A,k)||o.vertEq(A,E)?(I.checkForRightSplice(T,p),!1):!o.vertEq(D,T.event)&&o.edgeSign(D,T.event,A)>=0||!o.vertEq(P,T.event)&&o.edgeSign(P,T.event,A)<=0?P===T.event?(T.mesh.splitEdge(v.Sym),T.mesh.splice(M.Sym,v),p=I.topLeftRegion(T,p),v=I.regionBelow(p).eUp,I.finishLeftRegions(T,I.regionBelow(p),m),I.addRightEdges(T,p,v.Oprev,v,v,!0),!0):D===T.event?(T.mesh.splitEdge(M.Sym),T.mesh.splice(v.Lnext,M.Oprev),m=p,p=I.topRightRegion(p),L=I.regionBelow(p).eUp.Rprev,m.eUp=M.Oprev,M=I.finishLeftRegions(T,m,null),I.addRightEdges(T,p,M.Onext,v.Rprev,L,!0),!0):(o.edgeSign(D,T.event,A)>=0&&(I.regionAbove(p).dirty=p.dirty=!0,T.mesh.splitEdge(v.Sym),v.Org.s=T.event.s,v.Org.t=T.event.t),o.edgeSign(P,T.event,A)<=0&&(p.dirty=m.dirty=!0,T.mesh.splitEdge(M.Sym),M.Org.s=T.event.s,M.Org.t=T.event.t),!1):(T.mesh.splitEdge(v.Sym),T.mesh.splitEdge(M.Sym),T.mesh.splice(M.Oprev,v),v.Org.s=A.s,v.Org.t=A.t,v.Org.pqHandle=T.pq.insert(v.Org),I.getIntersectData(T,v.Org,k,D,E,P),I.regionAbove(p).dirty=p.dirty=m.dirty=!0,!1)},I.walkDirtyRegions=function(T,p){for(var m=I.regionBelow(p),v,M;;){for(;m.dirty;)p=m,m=I.regionBelow(m);if(!p.dirty&&(m=p,p=I.regionAbove(p),p===null||!p.dirty))return;if(p.dirty=!1,v=p.eUp,M=m.eUp,v.Dst!==M.Dst&&I.checkForLeftSplice(T,p)&&(m.fixUpperEdge?(I.deleteRegion(T,m),T.mesh.delete(M),m=I.regionBelow(p),M=m.eUp):p.fixUpperEdge&&(I.deleteRegion(T,p),T.mesh.delete(v),p=I.regionAbove(m),v=p.eUp)),v.Org!==M.Org)if(v.Dst!==M.Dst&&!p.fixUpperEdge&&!m.fixUpperEdge&&(v.Dst===T.event||M.Dst===T.event)){if(I.checkForIntersect(T,p))return}else I.checkForRightSplice(T,p);v.Org===M.Org&&v.Dst===M.Dst&&(I.addWinding(M,v),I.deleteRegion(T,p),T.mesh.delete(v),p=I.regionAbove(m))}},I.connectRightVertex=function(T,p,m){var v,M=m.Onext,k=I.regionBelow(p),E=p.eUp,D=k.eUp,P=!1;if(E.Dst!==D.Dst&&I.checkForIntersect(T,p),o.vertEq(E.Org,T.event)&&(T.mesh.splice(M.Oprev,E),p=I.topLeftRegion(T,p),M=I.regionBelow(p).eUp,I.finishLeftRegions(T,I.regionBelow(p),k),P=!0),o.vertEq(D.Org,T.event)&&(T.mesh.splice(m,D.Oprev),m=I.finishLeftRegions(T,k,null),P=!0),P){I.addRightEdges(T,p,m.Onext,M,M,!0);return}o.vertLeq(D.Org,E.Org)?v=D.Oprev:v=E,v=T.mesh.connect(m.Lprev,v),I.addRightEdges(T,p,v,v.Onext,v.Onext,!1),v.Sym.activeRegion.fixUpperEdge=!0,I.walkDirtyRegions(T,p)},I.connectLeftDegenerate=function(T,p,m){var v,M,k,E,D;if(v=p.eUp,o.vertEq(v.Org,m)){a(!1),I.spliceMergeVertices(T,v,m.anEdge);return}if(!o.vertEq(v.Dst,m)){T.mesh.splitEdge(v.Sym),p.fixUpperEdge&&(T.mesh.delete(v.Onext),p.fixUpperEdge=!1),T.mesh.splice(m.anEdge,v),I.sweepEvent(T,m);return}a(!1),p=I.topRightRegion(p),D=I.regionBelow(p),k=D.eUp.Sym,M=E=k.Onext,D.fixUpperEdge&&(a(M!==k),I.deleteRegion(T,D),T.mesh.delete(k),k=M.Oprev),T.mesh.splice(m.anEdge,k),o.edgeGoesLeft(M)||(M=null),I.addRightEdges(T,p,k.Onext,E,M,!0)},I.connectLeftVertex=function(T,p){var m,v,M,k,E,D,P=new b;if(P.eUp=p.anEdge.Sym,m=T.dict.search(P).key,v=I.regionBelow(m),!!v){if(k=m.eUp,E=v.eUp,o.edgeSign(k.Dst,p,k.Org)===0){I.connectLeftDegenerate(T,m,p);return}if(M=o.vertLeq(E.Dst,k.Dst)?m:v,m.inside||M.fixUpperEdge){if(M===m)D=T.mesh.connect(p.anEdge.Sym,k.Lnext);else{var z=T.mesh.connect(E.Dnext,p.anEdge);D=z.Sym}M.fixUpperEdge?I.fixUpperEdge(T,M,D):I.computeWinding(T,I.addRegionBelow(T,m,D)),I.sweepEvent(T,p)}else I.addRightEdges(T,m,p.anEdge,p.anEdge,null,!0)}},I.sweepEvent=function(T,p){T.event=p,I.debugEvent(T);for(var m=p.anEdge;m.activeRegion===null;)if(m=m.Onext,m===p.anEdge){I.connectLeftVertex(T,p);return}var v=I.topLeftRegion(T,m.activeRegion);a(v!==null);var M=I.regionBelow(v),k=M.eUp,E=I.finishLeftRegions(T,M,null);E.Onext===k?I.connectRightVertex(T,v,E):I.addRightEdges(T,v,E.Onext,k,k,!0)},I.addSentinel=function(T,p,m,v){var M=new b,k=T.mesh.makeEdge();k.Org.s=m,k.Org.t=v,k.Dst.s=p,k.Dst.t=v,T.event=k.Dst,M.eUp=k,M.windingNumber=0,M.inside=!1,M.fixUpperEdge=!1,M.sentinel=!0,M.dirty=!1,M.nodeUp=T.dict.insert(M)},I.initEdgeDict=function(T){T.dict=new f(T,I.edgeLeq);var p=T.bmax[0]-T.bmin[0],m=T.bmax[1]-T.bmin[1],v=T.bmin[0]-p,M=T.bmax[0]+p,k=T.bmin[1]-m,E=T.bmax[1]+m;I.addSentinel(T,v,M,k),I.addSentinel(T,v,M,E)},I.doneEdgeDict=function(T){for(var p,m=0;(p=T.dict.min().key)!==null;)p.sentinel||(a(p.fixUpperEdge),a(++m===1)),a(p.windingNumber===0),I.deleteRegion(T,p)},I.removeDegenerateEdges=function(T){var p,m,v,M=T.mesh.eHead;for(p=M.next;p!==M;p=m)m=p.next,v=p.Lnext,o.vertEq(p.Org,p.Dst)&&p.Lnext.Lnext!==p&&(I.spliceMergeVertices(T,v,p),T.mesh.delete(p),p=v,v=p.Lnext),v.Lnext===p&&(v!==p&&((v===m||v===m.Sym)&&(m=m.next),T.mesh.delete(v)),(p===m||p===m.Sym)&&(m=m.next),T.mesh.delete(p))},I.initPriorityQ=function(T){var p,m,v,M=0;for(v=T.mesh.vHead,m=v.next;m!==v;m=m.next)M++;for(M+=8,p=T.pq=new S(M,o.vertLeq),v=T.mesh.vHead,m=v.next;m!==v;m=m.next)m.pqHandle=p.insert(m);return m!==v?!1:(p.init(),!0)},I.donePriorityQ=function(T){T.pq=null},I.removeDegenerateFaces=function(T,p){var m,v,M;for(m=p.fHead.next;m!==p.fHead;m=v)v=m.next,M=m.anEdge,a(M.Lnext!==M),M.Lnext.Lnext===M&&(I.addWinding(M.Onext,M),T.mesh.delete(M));return!0},I.computeInterior=function(T){var p,m;if(I.removeDegenerateEdges(T),!I.initPriorityQ(T))return!1;for(I.initEdgeDict(T);(p=T.pq.extractMin())!==null;){for(;m=T.pq.min(),!(m===null||!o.vertEq(m,p));)m=T.pq.extractMin(),I.spliceMergeVertices(T,p.anEdge,m.anEdge);I.sweepEvent(T,p)}return T.event=T.dict.min().key.eUp.Org,I.debugEvent(T),I.doneEdgeDict(T),I.donePriorityQ(T),I.removeDegenerateFaces(T,T.mesh)?(T.mesh.check(),!0):!1};function N(){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=i.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}N.prototype={dot_:function(p,m){return p[0]*m[0]+p[1]*m[1]+p[2]*m[2]},normalize_:function(p){var m=p[0]*p[0]+p[1]*p[1]+p[2]*p[2];a(m>0),m=Math.sqrt(m),p[0]/=m,p[1]/=m,p[2]/=m},longAxis_:function(p){var m=0;return Math.abs(p[1])>Math.abs(p[0])&&(m=1),Math.abs(p[2])>Math.abs(p[m])&&(m=2),m},computeNormal_:function(p){var m,v,M,k,E,D,P=[0,0,0],z=[0,0,0],j=[0,0,0],A=[0,0,0],R=[0,0,0],L=[null,null,null],W=[null,null,null],Y=this.mesh.vHead,H;for(m=Y.next,H=0;H<3;++H)k=m.coords[H],z[H]=k,W[H]=m,P[H]=k,L[H]=m;for(m=Y.next;m!==Y;m=m.next)for(H=0;H<3;++H)k=m.coords[H],k<z[H]&&(z[H]=k,W[H]=m),k>P[H]&&(P[H]=k,L[H]=m);if(H=0,P[1]-z[1]>P[0]-z[0]&&(H=1),P[2]-z[2]>P[H]-z[H]&&(H=2),z[H]>=P[H]){p[0]=0,p[1]=0,p[2]=1;return}for(D=0,v=W[H],M=L[H],j[0]=v.coords[0]-M.coords[0],j[1]=v.coords[1]-M.coords[1],j[2]=v.coords[2]-M.coords[2],m=Y.next;m!==Y;m=m.next)A[0]=m.coords[0]-M.coords[0],A[1]=m.coords[1]-M.coords[1],A[2]=m.coords[2]-M.coords[2],R[0]=j[1]*A[2]-j[2]*A[1],R[1]=j[2]*A[0]-j[0]*A[2],R[2]=j[0]*A[1]-j[1]*A[0],E=R[0]*R[0]+R[1]*R[1]+R[2]*R[2],E>D&&(D=E,p[0]=R[0],p[1]=R[1],p[2]=R[2]);D<=0&&(p[0]=p[1]=p[2]=0,p[this.longAxis_(j)]=1)},checkOrientation_:function(){var p,m,v=this.mesh.fHead,M,k=this.mesh.vHead,E;for(p=0,m=v.next;m!==v;m=m.next)if(E=m.anEdge,!(E.winding<=0))do p+=(E.Org.s-E.Dst.s)*(E.Org.t+E.Dst.t),E=E.Lnext;while(E!==m.anEdge);if(p<0){for(M=k.next;M!==k;M=M.next)M.t=-M.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},projectPolygon_:function(){var p,m=this.mesh.vHead,v=[0,0,0],M,k,E,D,P=!1;for(v[0]=this.normal[0],v[1]=this.normal[1],v[2]=this.normal[2],v[0]===0&&v[1]===0&&v[2]===0&&(this.computeNormal_(v),P=!0),M=this.sUnit,k=this.tUnit,E=this.longAxis_(v),M[E]=0,M[(E+1)%3]=1,M[(E+2)%3]=0,k[E]=0,k[(E+1)%3]=0,k[(E+2)%3]=v[E]>0?1:-1,p=m.next;p!==m;p=p.next)p.s=this.dot_(p.coords,M),p.t=this.dot_(p.coords,k);for(P&&this.checkOrientation_(),D=!0,p=m.next;p!==m;p=p.next)D?(this.bmin[0]=this.bmax[0]=p.s,this.bmin[1]=this.bmax[1]=p.t,D=!1):(p.s<this.bmin[0]&&(this.bmin[0]=p.s),p.s>this.bmax[0]&&(this.bmax[0]=p.s),p.t<this.bmin[1]&&(this.bmin[1]=p.t),p.t>this.bmax[1]&&(this.bmax[1]=p.t))},addWinding_:function(p,m){p.winding+=m.winding,p.Sym.winding+=m.Sym.winding},tessellateMonoRegion_:function(p,m){var v,M;for(v=m.anEdge,a(v.Lnext!==v&&v.Lnext.Lnext!==v);o.vertLeq(v.Dst,v.Org);v=v.Lprev);for(;o.vertLeq(v.Org,v.Dst);v=v.Lnext);for(M=v.Lprev;v.Lnext!==M;)if(o.vertLeq(v.Dst,M.Org)){for(;M.Lnext!==v&&(o.edgeGoesLeft(M.Lnext)||o.edgeSign(M.Org,M.Dst,M.Lnext.Dst)<=0);){var k=p.connect(M.Lnext,M);M=k.Sym}M=M.Lprev}else{for(;M.Lnext!==v&&(o.edgeGoesRight(v.Lprev)||o.edgeSign(v.Dst,v.Org,v.Lprev.Org)>=0);){var k=p.connect(v,v.Lprev);v=k.Sym}v=v.Lnext}for(a(M.Lnext!==v);M.Lnext.Lnext!==v;){var k=p.connect(M.Lnext,M);M=k.Sym}return!0},tessellateInterior_:function(p){var m,v;for(m=p.fHead.next;m!==p.fHead;m=v)if(v=m.next,m.inside&&!this.tessellateMonoRegion_(p,m))return!1;return!0},discardExterior_:function(p){var m,v;for(m=p.fHead.next;m!==p.fHead;m=v)v=m.next,m.inside||p.zapFace(m)},setWindingNumber_:function(p,m,v){var M,k;for(M=p.eHead.next;M!==p.eHead;M=k)k=M.next,M.Rface.inside!==M.Lface.inside?M.winding=M.Lface.inside?m:-m:v?p.delete(M):M.winding=0},getNeighbourFace_:function(p){return!p.Rface||!p.Rface.inside?-1:p.Rface.n},outputPolymesh_:function(p,m,v,M){var k,E,D,P=0,z=0,j,A;for(v>3&&p.mergeConvexFaces(v),k=p.vHead.next;k!==p.vHead;k=k.next)k.n=-1;for(E=p.fHead.next;E!==p.fHead;E=E.next)if(E.n=-1,!!E.inside){D=E.anEdge,j=0;do k=D.Org,k.n===-1&&(k.n=z,z++),j++,D=D.Lnext;while(D!==E.anEdge);a(j<=v),E.n=P,++P}for(this.elementCount=P,m===i.CONNECTED_POLYGONS&&(P*=2),this.elements=[],this.elements.length=P*v,this.vertexCount=z,this.vertices=[],this.vertices.length=z*M,this.vertexIndices=[],this.vertexIndices.length=z,k=p.vHead.next;k!==p.vHead;k=k.next)if(k.n!==-1){var R=k.n*M;this.vertices[R+0]=k.coords[0],this.vertices[R+1]=k.coords[1],M>2&&(this.vertices[R+2]=k.coords[2]),this.vertexIndices[k.n]=k.idx}var L=0;for(E=p.fHead.next;E!==p.fHead;E=E.next)if(E.inside){D=E.anEdge,j=0;do k=D.Org,this.elements[L++]=k.n,j++,D=D.Lnext;while(D!==E.anEdge);for(A=j;A<v;++A)this.elements[L++]=-1;if(m===i.CONNECTED_POLYGONS){D=E.anEdge;do this.elements[L++]=this.getNeighbourFace_(D),D=D.Lnext;while(D!==E.anEdge);for(A=j;A<v;++A)this.elements[L++]=-1}}},outputContours_:function(p,m){var v,M,k,E=0,D=0;for(this.vertexCount=0,this.elementCount=0,v=p.fHead.next;v!==p.fHead;v=v.next)if(v.inside){k=M=v.anEdge;do this.vertexCount++,M=M.Lnext;while(M!==k);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 P=0,z=0,j=0;for(E=0,v=p.fHead.next;v!==p.fHead;v=v.next)if(v.inside){D=0,k=M=v.anEdge;do this.vertices[P++]=M.Org.coords[0],this.vertices[P++]=M.Org.coords[1],m>2&&(this.vertices[P++]=M.Org.coords[2]),this.vertexIndices[z++]=M.Org.idx,D++,M=M.Lnext;while(M!==k);this.elements[j++]=E,this.elements[j++]=D,E+=D}},addContour:function(p,m){var v,M;for(this.mesh===null&&(this.mesh=new h),p<2&&(p=2),p>3&&(p=3),v=null,M=0;M<m.length;M+=p)v===null?(v=this.mesh.makeEdge(),this.mesh.splice(v,v.Sym)):(this.mesh.splitEdge(v),v=v.Lnext),v.Org.coords[0]=m[M+0],v.Org.coords[1]=m[M+1],p>2?v.Org.coords[2]=m[M+2]:v.Org.coords[2]=0,v.Org.idx=this.vertexIndexCounter++,v.winding=1,v.Sym.winding=-1},tesselate:function(p,m,v,M,k){if(this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,k&&(this.normal[0]=k[0],this.normal[1]=k[1],this.normal[2]=k[2]),this.windingRule=p,M<2&&(M=2),M>3&&(M=3),!this.mesh)return!1;this.projectPolygon_(),I.computeInterior(this);var E=this.mesh;return m===i.BOUNDARY_CONTOURS?this.setWindingNumber_(E,1,!0):this.tessellateInterior_(E),E.check(),m===i.BOUNDARY_CONTOURS?this.outputContours_(E,M):this.outputPolymesh_(E,m,v,M),!0}}},function(e,r){e.exports=i;var n=Object.prototype.hasOwnProperty;function i(){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 f}),n.d(r,"createCloudShaders",function(){return y}),n.d(r,"applyCloudShader",function(){return S});var i=n(19),o=n.n(i),a=n(83),c=n(84),l=n(85),u=n(86);n(1).glMatrix.setMatrixArrayType(Array);var h=Symbol("shaders");function d(b){b[h]=[];for(var I=0;I<16;I++){var N=[],T=!!(I&1),p=!!(I&2),m=!!(I&4),v=!!(I&8);T&&N.push("#define TEXTURE 1"),p&&N.push("#define FILTER 1"),m&&N.push("#define GRADIENT 1"),v&&N.push("#define CLIPPATH 1");var M="".concat(N.join(`
|
|
42
|
-
`),`
|
|
43
|
-
`),k=[];T&&k.push("uniform sampler2D u_texSampler;"),v&&k.push("uniform sampler2D u_clipSampler;"),b[h][I]=[M+k.join(`
|
|
44
|
-
`)+c.default,M+a.default]}}function f(b){var I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},N=I.hasTexture,T=N===void 0?!1:N,p=I.hasFilter,m=p===void 0?!1:p,v=I.hasGradient,M=v===void 0?!1:v,k=I.hasClipPath,E=k===void 0?!1:k,D=T|m<<1|M<<2|E<<3,P=b[h][D];Array.isArray(P)&&(P=b.createProgram.apply(b,o()(P)),b[h][D]=P),b.program!==P&&b.useProgram(P,{a_color:{type:"UNSIGNED_BYTE",normalize:!0}})}var g=[];function y(b){for(var I=0;I<64;I++){var N=[],T=!!(I&1),p=!!(I&2),m=!!(I&4),v=!!(I&8),M=!!(I&16),k=!!(I&32);T&&N.push("#define TEXTURE 1"),p&&N.push("#define FILTER 1"),m&&N.push("#define GRADIENT 1"),v&&N.push("#define CLOUDCOLOR 1"),M&&N.push("#define CLOUDFILTER 1"),k&&N.push("#define CLIPPATH 1");var E="".concat(N.join(`
|
|
45
|
-
`),`
|
|
46
|
-
`),D=[];if(T){D.push("uniform sampler2D u_texSampler;");for(var P=0;P<12;P++)D.push("uniform sampler2D u_texFrame".concat(P,";"))}k&&D.push("uniform sampler2D u_clipSampler;"),g[I]=[E+D.join(`
|
|
47
|
-
`)+u.default,E+l.default]}}function S(b){var I=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},N=I.hasTexture,T=N===void 0?!1:N,p=I.hasFilter,m=p===void 0?!1:p,v=I.hasGradient,M=v===void 0?!1:v,k=I.hasCloudColor,E=k===void 0?!1:k,D=I.hasCloudFilter,P=D===void 0?!1:D,z=I.hasClipPath,j=z===void 0?!1:z,A=T|m<<1|M<<2|E<<3|P<<4|j<<5,R=g[A];Array.isArray(R)&&(R=b.createProgram.apply(b,o()(R)),g[A]=R),b.program!==R&&b.useProgram(R,{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
|
-
}`}])})})(vm);var ft=vm.exports;Ze(Array);function sh(s,t){const e=s.trim().match(/^([\d.]+)(px|pt|pc|in|cm|mm|em|ex|rem|q|vw|vh|vmax|vmin)$/);e?s={size:parseFloat(e[1]),unit:e[2]}:s={size:parseFloat(s),unit:"px"};let{size:r,unit:n}=s;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 i=getComputedStyle(document.documentElement).fontSize;i?t=sh(i,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 i=n==="vw"?window.innerWidth||document.documentElement.clientWidth:window.innerHeight||document.documentElement.clientHeight;r*=i/100}}else if((n==="vmax"||n==="vmin")&&typeof document<"u"){const i=window.innerWidth||document.documentElement.clientWidth,o=window.innerHeight||document.documentElement.clientHeight;n==="vmax"?r*=Math.max(i,o)/100:r*=Math.min(i,o)/100}return r}function qe(s){if(s==null)return s;if(typeof s=="string"&&(s=sh(s)),!Number.isFinite(s))throw new TypeError("Invalid value");return s}function Mt(s,t=!1){return s===""?null:(typeof s=="string"&&(s=s.split(/[\s,]+/g)),Array.isArray(s)&&(t&&(s=s.map(qe)),s.length===1)?s[0]:s)}function iu(s,t){if(Array.isArray(s)&&Array.isArray(t)){if(s.length!==t.length)return!1;for(let e=0;e<s.length;e++)if(s[e]!==t[e])return!1;return!0}return s==null&&t==null||s===t}Ze(Array);const Yc=Symbol.for("spritejs_setAttributeDefault"),Gc=Symbol.for("spritejs_declareAlias"),Rt=Symbol.for("spritejs_setAttribute"),gt=Symbol.for("spritejs_getAttribute"),Vd=Symbol.for("spritejs_attributes"),$d=Symbol.for("spritejs_changedAttrs"),aa=Symbol("subject"),qr=Symbol("attr"),Hc=Symbol("default"),vo=Symbol("alias");function GM(s,[t,e]){let r=ei(1,0,0,1,0,0);return[...s].forEach(([n,i])=>{if((t||e)&&(r=nu(Array.of(0,0,0,0,0,0),r,[t,e])),n==="matrix")r=Nr(r,r,i);else if(n==="offsetTranslate")r[4]+=i[0],r[5]+=i[1];else if(n==="offsetRotate")r=pm(Array.of(0,0,0,0,0,0),r,i);else if(n==="skew"){const[o,a]=i;r=Nr(r,r,ei(1,Math.tan(a),Math.tan(o),1,0,0))}else ym[n](r,r,i);(t||e)&&(r=nu(Array.of(0,0,0,0,0,0),r,[-t,-e]))}),r}const Mn=Symbol("transformMatrix"),Ns=Symbol("transforms"),ss=Symbol("changedAttrs"),Mm=Symbol("lastChangedAttr"),ca=Symbol("offsetFigure");function Mo(s,t,e){const r=s[qr][t];if(s[Rt](t,e,!1)||s[Mm]!==t){const i=s[Ns];i.has(t)&&i.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)),i.set(t,e)),s[Mn]=null,s[aa].onPropertyChange(t,e,r,s)}}function Qc(s){const t=s[ca],e=s.offsetDistance*t.getTotalLength(),r=t.getPointAtLength(e);if(r){const n=s[Ns];let i=s.offsetRotate;i==="auto"?i=r.angle:i==="reverse"?i=Math.PI+r.angle:i=Math.PI*i/180,n.set("offsetRotate",i),n.set("offsetTranslate",[r.x,r.y]),s[Mn]=null}}let oh=class{static setDefault(t,...e){return t[Yc](...e)}static declareAlias(t,...e){return t[Gc](...e)}static setAttribute(t,...e){return t[Rt](...e)}static getAttribute(t,...e){return t[gt](...e)}static getAttributes(t){return t[Vd]}static getChangedAttributes(t){return t[$d]}constructor(t){this[aa]=t,this[qr]={},this[Mn]=ei(1,0,0,1,0,0),this[Ns]=new Map,this[Hc]={},this[vo]=[],Object.defineProperty(t,"transformMatrix",{get:()=>(this[Mn]||(this[Mn]=GM(this[Ns],this.transformOrigin)),[...this[Mn]])}),this[Yc]({id:"",name:"",className:"",x:0,y:0,transformOrigin:[0,0],transform:"",translate:[0,0],rotate:0,scale:[1,1],skew:[0,0],opacity:1,zIndex:0,offsetPath:void 0,offsetDistance:0,offsetRotate:"auto",pointerEvents:"visible",filter:"none",display:""}),this[Gc]("class","pos"),this[ss]=new Set,this[ca]=new ft.Figure2D({scale:5,simplify:0})}get[$d](){const t={};return[...this[ss]].forEach(e=>{t[e]=this[qr][e]}),t}get[Vd](){const t=Object.assign({},this[qr]);for(let e=0;e<this[vo].length;e++){const r=this[vo][e];t[r]=this[r]}return t}[Yc](t){Object.assign(this[Hc],t),Object.assign(this[qr],t)}[Gc](...t){this[vo].push(...t)}[Rt](t,e,r=!0){const n=this[qr][t],i=this[aa];return e==null&&(e=this[Hc][t]),iu(n,e)?!1:(this[qr][t]=e,this[ss].has(t)&&this[ss].delete(t),this[ss].add(t),this[Mm]=t,r&&i.onPropertyChange(t,e,n,this),!0)}[gt](t){return this[qr][t]}set id(t){this[Rt]("id",t)}get id(){return this[gt]("id")}set name(t){this[Rt]("name",t)}get name(){return this[gt]("name")}set className(t){this[Rt]("className",t)}get className(){return this[gt]("className")}set class(t){this.className=t}get class(){return this.className}get x(){return this[gt]("x")}set x(t){this[Rt]("x",qe(t))}get y(){return this[gt]("y")}set y(t){this[Rt]("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[gt]("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[qr].transform;if(this[Rt]("transform",t,!1)){const n=this[Ns];if(n.has("matrix")&&n.delete("matrix"),e)n.set("matrix",e);else if(t){const i=t.match(/(matrix|translate|rotate|scale|skew)\([^()]+\)/g);if(i){let o=ei(1,0,0,1,0,0);for(let a=0;a<i.length;a++){const l=i[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=Nr(o,o,h):u==="skew"?o=Nr(o,o,ei(1,Math.tan(h[1]),Math.tan(h[0]),1,0,0)):ym[u](o,o,h),n.set("matrix",o)}}}else throw new TypeError("Invalid transform value.")}this[Mn]=null,this[aa].onPropertyChange("transform",t,r,this)}}get transformOrigin(){return this[gt]("transformOrigin")}set transformOrigin(t){t=Mt(t,!0),t!=null&&!Array.isArray(t)&&(t=[t,t]),this[Rt]("transformOrigin",t)&&(this[Mn]=null)}get rotate(){return this[gt]("rotate")}set rotate(t){Mo(this,"rotate",t)}get translate(){return this[gt]("translate")}set translate(t){t=Mt(t,!0),t!=null&&!Array.isArray(t)&&(t=[t,t]),Mo(this,"translate",t)}get scale(){return this[gt]("scale")}set scale(t){t=Mt(t,!0),t!=null&&!Array.isArray(t)&&(t=[t,t]),Mo(this,"scale",t)}get skew(){return this[gt]("skew")}set skew(t){t=Mt(t,!0),t!=null&&!Array.isArray(t)&&(t=[t,t]),Mo(this,"skew",t)}get opacity(){return this[gt]("opacity")}set opacity(t){t!=null&&(t=Number(t)),this[Rt]("opacity",t)}get zIndex(){return this[gt]("zIndex")}set zIndex(t){t!=null&&(t=Number(t)),this[Rt]("zIndex",t)}get offsetPath(){return this[gt]("offsetPath")}set offsetPath(t){this[Rt]("offsetPath",t)&&(this[ca].beginPath(),t!=null&&this[ca].addPath(t),Qc(this))}get offsetDistance(){return this[gt]("offsetDistance")}set offsetDistance(t){this[Rt]("offsetDistance",qe(t))&&Qc(this)}get offsetRotate(){return this[gt]("offsetRotate")}set offsetRotate(t){this[Rt]("offsetRotate",t),Qc(this)}get pointerEvents(){return this[gt]("pointerEvents")}set pointerEvents(t){if(t!=null&&t!=="none"&&t!=="visible"&&t!=="visibleFill"&&t!=="visibleStroke"&&t!=="all")throw new TypeError("Invalid pointerEvents type.");this[Rt]("pointerEvents",t)}get filter(){return this[gt]("filter")}set filter(t){this[Rt]("filter",t)}get display(){return this[gt]("display")}set display(t){this[Rt]("display",t)}set offset(t){}};var en={},Za={},_s={},wm=function(s,t){return{value:t,done:!!s}},qi={},HM={}.toString,eo=function(s){return HM.call(s).slice(8,-1)},QM=eo,ah=Object("z").propertyIsEnumerable(0)?Object:function(s){return QM(s)=="String"?s.split(""):Object(s)},ch=function(s){if(s==null)throw TypeError("Can't call method on "+s);return s},qM=ah,ZM=ch,oi=function(s){return qM(ZM(s))},KM=!0,Sm={exports:{}},XM=Sm.exports=typeof window<"u"&&window.Math==Math?window:typeof self<"u"&&self.Math==Math?self:Function("return this")();typeof __g=="number"&&(__g=XM);var Jt=Sm.exports,Tm={exports:{}},JM=Tm.exports={version:"2.6.12"};typeof __e=="number"&&(__e=JM);var Pt=Tm.exports,to=function(s){if(typeof s!="function")throw TypeError(s+" is not a function!");return s},_M=to,kn=function(s,t,e){if(_M(s),t===void 0)return s;switch(e){case 1:return function(r){return s.call(t,r)};case 2:return function(r,n){return s.call(t,r,n)};case 3:return function(r,n,i){return s.call(t,r,n,i)}}return function(){return s.apply(t,arguments)}},dr={},Or=function(s){return typeof s=="object"?s!==null:typeof s=="function"},ew=Or,un=function(s){if(!ew(s))throw TypeError(s+" is not an object!");return s},ai=function(s){try{return!!s()}catch{return!0}},fr=!ai(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7}),Yd=Or,su=Jt.document,tw=Yd(su)&&Yd(su.createElement),lh=function(s){return tw?su.createElement(s):{}},Im=!fr&&!ai(function(){return Object.defineProperty(lh("div"),"a",{get:function(){return 7}}).a!=7}),wo=Or,uh=function(s,t){if(!wo(s))return s;var e,r;if(t&&typeof(e=s.toString)=="function"&&!wo(r=e.call(s))||typeof(e=s.valueOf)=="function"&&!wo(r=e.call(s))||!t&&typeof(e=s.toString)=="function"&&!wo(r=e.call(s)))return r;throw TypeError("Can't convert object to primitive value")},Gd=un,rw=Im,nw=uh,iw=Object.defineProperty;dr.f=fr?Object.defineProperty:function(t,e,r){if(Gd(t),e=nw(e,!0),Gd(r),rw)try{return iw(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 ro=function(s,t){return{enumerable:!(s&1),configurable:!(s&2),writable:!(s&4),value:t}},sw=dr,ow=ro,An=fr?function(s,t,e){return sw.f(s,t,ow(1,e))}:function(s,t,e){return s[t]=e,s},aw={}.hasOwnProperty,ci=function(s,t){return aw.call(s,t)},So=Jt,qc=Pt,Hd=kn,cw=An,lw=ci,To="prototype",Ft=function(s,t,e){var r=s&Ft.F,n=s&Ft.G,i=s&Ft.S,o=s&Ft.P,a=s&Ft.B,c=s&Ft.W,l=n?qc:qc[t]||(qc[t]={}),u=l[To],h=n?So:i?So[t]:(So[t]||{})[To],d,f,g;n&&(e=t);for(d in e)f=!r&&h&&h[d]!==void 0,!(f&&lw(l,d))&&(g=f?h[d]:e[d],l[d]=n&&typeof h[d]!="function"?e[d]:a&&f?Hd(g,So):c&&h[d]==g?function(y){var S=function(b,I,N){if(this instanceof y){switch(arguments.length){case 0:return new y;case 1:return new y(b);case 2:return new y(b,I)}return new y(b,I,N)}return y.apply(this,arguments)};return S[To]=y[To],S}(g):o&&typeof g=="function"?Hd(Function.call,g):g,o&&((l.virtual||(l.virtual={}))[d]=g,s&Ft.R&&u&&!u[d]&&cw(u,d,g)))};Ft.F=1;Ft.G=2;Ft.S=4;Ft.P=8;Ft.B=16;Ft.W=32;Ft.U=64;Ft.R=128;var _t=Ft,Cm=An,uw=Math.ceil,hw=Math.floor,hh=function(s){return isNaN(s=+s)?0:(s>0?hw:uw)(s)},dw=hh,fw=Math.min,Ka=function(s){return s>0?fw(dw(s),9007199254740991):0},gw=hh,pw=Math.max,mw=Math.min,yw=function(s,t){return s=gw(s),s<0?pw(s+t,0):mw(s,t)},vw=oi,Mw=Ka,ww=yw,Sw=function(s){return function(t,e,r){var n=vw(t),i=Mw(n.length),o=ww(r,i),a;if(s&&e!=e){for(;i>o;)if(a=n[o++],a!=a)return!0}else for(;i>o;o++)if((s||o in n)&&n[o]===e)return s||o||0;return!s&&-1}},bm={exports:{}},Tw=Pt,Qd=Jt,qd="__core-js_shared__",Zd=Qd[qd]||(Qd[qd]={});(bm.exports=function(s,t){return Zd[s]||(Zd[s]=t!==void 0?t:{})})("versions",[]).push({version:Tw.version,mode:"pure",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"});var dh=bm.exports,Iw=0,Cw=Math.random(),Xa=function(s){return"Symbol(".concat(s===void 0?"":s,")_",(++Iw+Cw).toString(36))},Kd=dh("keys"),bw=Xa,fh=function(s){return Kd[s]||(Kd[s]=bw(s))},Xd=ci,Ew=oi,xw=Sw(!1),Rw=fh("IE_PROTO"),Em=function(s,t){var e=Ew(s),r=0,n=[],i;for(i in e)i!=Rw&&Xd(e,i)&&n.push(i);for(;t.length>r;)Xd(e,i=t[r++])&&(~xw(n,i)||n.push(i));return n},gh="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","),kw=Em,Aw=gh,Zi=Object.keys||function(t){return kw(t,Aw)},Pw=dr,Dw=un,Lw=Zi,Nw=fr?Object.defineProperties:function(t,e){Dw(t);for(var r=Lw(e),n=r.length,i=0,o;n>i;)Pw.f(t,o=r[i++],e[o]);return t},Jd=Jt.document,xm=Jd&&Jd.documentElement,Ow=un,zw=Nw,_d=gh,Bw=fh("IE_PROTO"),Zc=function(){},ou="prototype",la=function(){var s=lh("iframe"),t=_d.length,e="<",r=">",n;for(s.style.display="none",xm.appendChild(s),s.src="javascript:",n=s.contentWindow.document,n.open(),n.write(e+"script"+r+"document.F=Object"+e+"/script"+r),n.close(),la=n.F;t--;)delete la[ou][_d[t]];return la()},ph=Object.create||function(t,e){var r;return t!==null?(Zc[ou]=Ow(t),r=new Zc,Zc[ou]=null,r[Bw]=t):r=la(),e===void 0?r:zw(r,e)},Rm={exports:{}},au=dh("wks"),jw=Xa,cu=Jt.Symbol,ef=typeof cu=="function",Fw=Rm.exports=function(s){return au[s]||(au[s]=ef&&cu[s]||(ef?cu:jw)("Symbol."+s))};Fw.store=au;var Yt=Rm.exports,Uw=dr.f,Ww=ci,tf=Yt("toStringTag"),no=function(s,t,e){s&&!Ww(s=e?s:s.prototype,tf)&&Uw(s,tf,{configurable:!0,value:t})},Vw=ph,$w=ro,Yw=no,km={};An(km,Yt("iterator"),function(){return this});var Gw=function(s,t,e){s.prototype=Vw(km,{next:$w(1,e)}),Yw(s,t+" Iterator")},Hw=ch,Ki=function(s){return Object(Hw(s))},Qw=ci,qw=Ki,rf=fh("IE_PROTO"),Zw=Object.prototype,Kw=Object.getPrototypeOf||function(s){return s=qw(s),Qw(s,rf)?s[rf]:typeof s.constructor=="function"&&s instanceof s.constructor?s.constructor.prototype:s instanceof Object?Zw:null},Kc=_t,Xw=Cm,Jw=An,nf=qi,_w=Gw,eS=no,tS=Kw,Xc=Yt("iterator"),Jc=!([].keys&&"next"in[].keys()),rS="@@iterator",sf="keys",Io="values",nS=function(){return this},mh=function(s,t,e,r,n,i,o){_w(e,t,r);var a=function(N){if(!Jc&&N in h)return h[N];switch(N){case sf:return function(){return new e(this,N)};case Io:return function(){return new e(this,N)}}return function(){return new e(this,N)}},c=t+" Iterator",l=n==Io,u=!1,h=s.prototype,d=h[Xc]||h[rS]||n&&h[n],f=d||a(n),g=n?l?a("entries"):f:void 0,y=t=="Array"&&h.entries||d,S,b,I;if(y&&(I=tS(y.call(new s)),I!==Object.prototype&&I.next&&eS(I,c,!0)),l&&d&&d.name!==Io&&(u=!0,f=function(){return d.call(this)}),o&&(Jc||u||!h[Xc])&&Jw(h,Xc,f),nf[t]=f,nf[c]=nS,n)if(S={values:l?f:a(Io),keys:i?f:a(sf),entries:g},o)for(b in S)b in h||Xw(h,b,S[b]);else Kc(Kc.P+Kc.F*(Jc||u),t,S);return S},Co=wm,of=qi,iS=oi;mh(Array,"Array",function(s,t){this._t=iS(s),this._i=0,this._k=t},function(){var s=this._t,t=this._k,e=this._i++;return!s||e>=s.length?(this._t=void 0,Co(1)):t=="keys"?Co(0,e):t=="values"?Co(0,s[e]):Co(0,[e,s[e]])},"values");of.Arguments=of.Array;var sS=Jt,oS=An,af=qi,cf=Yt("toStringTag"),lf="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 _c=0;_c<lf.length;_c++){var el=lf[_c],uf=sS[el],tl=uf&&uf.prototype;tl&&!tl[cf]&&oS(tl,cf,el),af[el]=af.Array}var aS=hh,cS=ch,lS=function(s){return function(t,e){var r=String(cS(t)),n=aS(e),i=r.length,o,a;return n<0||n>=i?s?"":void 0:(o=r.charCodeAt(n),o<55296||o>56319||n+1===i||(a=r.charCodeAt(n+1))<56320||a>57343?s?r.charAt(n):o:s?r.slice(n,n+2):(o-55296<<10)+(a-56320)+65536)}},uS=lS(!0);mh(String,"String",function(s){this._t=String(s),this._i=0},function(){var s=this._t,t=this._i,e;return t>=s.length?{value:void 0,done:!0}:(e=uS(s,t),this._i+=e.length,{value:e,done:!1})});var lu=eo,hS=Yt("toStringTag"),dS=lu(function(){return arguments}())=="Arguments",fS=function(s,t){try{return s[t]}catch{}},Ja=function(s){var t,e,r;return s===void 0?"Undefined":s===null?"Null":typeof(e=fS(t=Object(s),hS))=="string"?e:dS?lu(t):(r=lu(t))=="Object"&&typeof t.callee=="function"?"Arguments":r},gS=Ja,pS=Yt("iterator"),mS=qi,yS=Pt.isIterable=function(s){var t=Object(s);return t[pS]!==void 0||"@@iterator"in t||mS.hasOwnProperty(gS(t))},vS=yS,MS={default:vS,__esModule:!0},wS=Ja,SS=Yt("iterator"),TS=qi,yh=Pt.getIteratorMethod=function(s){if(s!=null)return s[SS]||s["@@iterator"]||TS[wS(s)]},IS=un,CS=yh,bS=Pt.getIterator=function(s){var t=CS(s);if(typeof t!="function")throw TypeError(s+" is not iterable!");return IS(t.call(s))},ES=bS,xS={default:ES,__esModule:!0};_s.__esModule=!0;var RS=MS,kS=Am(RS),AS=xS,PS=Am(AS);function Am(s){return s&&s.__esModule?s:{default:s}}_s.default=function(){function s(t,e){var r=[],n=!0,i=!1,o=void 0;try{for(var a=(0,PS.default)(t),c;!(n=(c=a.next()).done)&&(r.push(c.value),!(e&&r.length===e));n=!0);}catch(l){i=!0,o=l}finally{try{!n&&a.return&&a.return()}finally{if(i)throw o}}return r}return function(t,e){if(Array.isArray(t))return t;if((0,kS.default)(Object(t)))return s(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();var _a={},hf=un,Pm=function(s,t,e,r){try{return r?t(hf(e)[0],e[1]):t(e)}catch(i){var n=s.return;throw n!==void 0&&hf(n.call(s)),i}},DS=qi,LS=Yt("iterator"),NS=Array.prototype,Dm=function(s){return s!==void 0&&(DS.Array===s||NS[LS]===s)},OS=dr,zS=ro,BS=function(s,t,e){t in s?OS.f(s,t,zS(0,e)):s[t]=e},rl,df;function Lm(){if(df)return rl;df=1;var s=Yt("iterator"),t=!1;try{var e=[7][s]();e.return=function(){t=!0},Array.from(e,function(){throw 2})}catch{}return rl=function(r,n){if(!n&&!t)return!1;var i=!1;try{var o=[7],a=o[s]();a.next=function(){return{done:i=!0}},o[s]=function(){return a},r(o)}catch{}return i},rl}var jS=kn,nl=_t,FS=Ki,US=Pm,WS=Dm,VS=Ka,ff=BS,$S=yh;nl(nl.S+nl.F*!Lm()(function(s){Array.from(s)}),"Array",{from:function(t){var e=FS(t),r=typeof this=="function"?this:Array,n=arguments.length,i=n>1?arguments[1]:void 0,o=i!==void 0,a=0,c=$S(e),l,u,h,d;if(o&&(i=jS(i,n>2?arguments[2]:void 0,2)),c!=null&&!(r==Array&&WS(c)))for(d=c.call(e),u=new r;!(h=d.next()).done;a++)ff(u,a,o?US(d,i,[h.value,a],!0):h.value);else for(l=VS(e.length),u=new r(l);l>a;a++)ff(u,a,o?i(e[a],a):e[a]);return u.length=a,u}});var YS=Pt.Array.from,GS={default:YS,__esModule:!0};_a.__esModule=!0;var HS=GS,QS=qS(HS);function qS(s){return s&&s.__esModule?s:{default:s}}_a.default=function(s){if(Array.isArray(s)){for(var t=0,e=Array(s.length);t<s.length;t++)e[t]=s[t];return e}else return(0,QS.default)(s)};var ZS=An,vh=function(s,t,e){for(var r in t)e&&s[r]?s[r]=t[r]:ZS(s,r,t[r]);return s},Mh=function(s,t,e,r){if(!(s instanceof t)||r!==void 0&&r in s)throw TypeError(e+": incorrect invocation!");return s},Nm={exports:{}},KS=kn,XS=Pm,JS=Dm,_S=un,eT=Ka,tT=yh,uu={},hu={},Om=Nm.exports=function(s,t,e,r,n){var i=n?function(){return s}:tT(s),o=KS(e,r,t?2:1),a=0,c,l,u,h;if(typeof i!="function")throw TypeError(s+" is not iterable!");if(JS(i)){for(c=eT(s.length);c>a;a++)if(h=t?o(_S(l=s[a])[0],l[1]):o(s[a]),h===uu||h===hu)return h}else for(u=i.call(s);!(l=u.next()).done;)if(h=XS(u,o,l.value,t),h===uu||h===hu)return h};Om.BREAK=uu;Om.RETURN=hu;var io=Nm.exports,rT=Jt,gf=Pt,nT=dr,iT=fr,pf=Yt("species"),zm=function(s){var t=typeof gf[s]=="function"?gf[s]:rT[s];iT&&t&&!t[pf]&&nT.f(t,pf,{configurable:!0,get:function(){return this}})},Bm={exports:{}},ii=Xa("meta"),sT=Or,wh=ci,oT=dr.f,aT=0,ec=Object.isExtensible||function(){return!0},cT=!ai(function(){return ec(Object.preventExtensions({}))}),Sh=function(s){oT(s,ii,{value:{i:"O"+ ++aT,w:{}}})},lT=function(s,t){if(!sT(s))return typeof s=="symbol"?s:(typeof s=="string"?"S":"P")+s;if(!wh(s,ii)){if(!ec(s))return"F";if(!t)return"E";Sh(s)}return s[ii].i},uT=function(s,t){if(!wh(s,ii)){if(!ec(s))return!0;if(!t)return!1;Sh(s)}return s[ii].w},hT=function(s){return cT&&dT.NEED&&ec(s)&&!wh(s,ii)&&Sh(s),s},dT=Bm.exports={KEY:ii,NEED:!1,fastKey:lT,getWeak:uT,onFreeze:hT},Th=Bm.exports,fT=Or,jm=function(s,t){if(!fT(s)||s._t!==t)throw TypeError("Incompatible receiver, "+t+" required!");return s},gT=dr.f,pT=ph,mT=vh,yT=kn,vT=Mh,MT=io,wT=mh,bo=wm,ST=zm,Fm=fr,Um=Th.fastKey,wi=jm,os=Fm?"_s":"size",Eo=function(s,t){var e=Um(t),r;if(e!=="F")return s._i[e];for(r=s._f;r;r=r.n)if(r.k==t)return r},TT={getConstructor:function(s,t,e,r){var n=s(function(i,o){vT(i,n,t,"_i"),i._t=t,i._i=pT(null),i._f=void 0,i._l=void 0,i[os]=0,o!=null&&MT(o,e,i[r],i)});return mT(n.prototype,{clear:function(){for(var o=wi(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[os]=0},delete:function(i){var o=wi(this,t),a=Eo(o,i);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[os]--}return!!a},forEach:function(o){wi(this,t);for(var a=yT(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!!Eo(wi(this,t),o)}}),Fm&&gT(n.prototype,"size",{get:function(){return wi(this,t)[os]}}),n},def:function(s,t,e){var r=Eo(s,t),n,i;return r?r.v=e:(s._l=r={i:i=Um(t,!0),k:t,v:e,p:n=s._l,n:void 0,r:!1},s._f||(s._f=r),n&&(n.n=r),s[os]++,i!=="F"&&(s._i[i]=r)),s},getEntry:Eo,setStrong:function(s,t,e){wT(s,t,function(r,n){this._t=wi(r,t),this._k=n,this._l=void 0},function(){for(var r=this,n=r._k,i=r._l;i&&i.r;)i=i.p;return!r._t||!(r._l=i=i?i.n:r._t._f)?(r._t=void 0,bo(1)):n=="keys"?bo(0,i.k):n=="values"?bo(0,i.v):bo(0,[i.k,i.v])},e?"entries":"values",!e,!0),ST(t)}},IT=eo,Wm=Array.isArray||function(t){return IT(t)=="Array"},CT=Or,mf=Wm,bT=Yt("species"),ET=function(s){var t;return mf(s)&&(t=s.constructor,typeof t=="function"&&(t===Array||mf(t.prototype))&&(t=void 0),CT(t)&&(t=t[bT],t===null&&(t=void 0))),t===void 0?Array:t},xT=ET,RT=function(s,t){return new(xT(s))(t)},kT=kn,AT=ah,PT=Ki,DT=Ka,LT=RT,NT=function(s,t){var e=s==1,r=s==2,n=s==3,i=s==4,o=s==6,a=s==5||o,c=t||LT;return function(l,u,h){for(var d=PT(l),f=AT(d),g=kT(u,h,3),y=DT(f.length),S=0,b=e?c(l,y):r?c(l,0):void 0,I,N;y>S;S++)if((a||S in f)&&(I=f[S],N=g(I,S,d),s)){if(e)b[S]=N;else if(N)switch(s){case 3:return!0;case 5:return I;case 6:return S;case 2:b.push(I)}else if(i)return!1}return o?-1:n||i?i:b}},OT=Jt,xo=_t,zT=Th,BT=ai,jT=An,FT=vh,UT=io,yf=Mh,WT=Or,VT=no,$T=dr.f,YT=NT(0),GT=fr,HT=function(s,t,e,r,n,i){var o=OT[s],a=o,c=n?"set":"add",l=a&&a.prototype,u={};return!GT||typeof a!="function"||!(i||l.forEach&&!BT(function(){new a().entries().next()}))?(a=r.getConstructor(t,s,n,c),FT(a.prototype,e),zT.NEED=!0):(a=t(function(h,d){yf(h,a,s,"_c"),h._c=new o,d!=null&&UT(d,n,h[c],h)}),YT("add,clear,delete,forEach,get,has,set,keys,values,entries,toJSON".split(","),function(h){var d=h=="add"||h=="set";h in l&&!(i&&h=="clear")&&jT(a.prototype,h,function(f,g){if(yf(this,a,h),!d&&i&&!WT(f))return h=="get"?void 0:!1;var y=this._c[h](f===0?0:f,g);return d?this:y})}),i||$T(a.prototype,"size",{get:function(){return this._c.size}})),VT(a,s),u[s]=a,xo(xo.G+xo.W+xo.F,u),i||r.setStrong(a,s,n),a},il=TT,vf=jm,sl="Map";HT(sl,function(s){return function(){return s(this,arguments.length>0?arguments[0]:void 0)}},{get:function(t){var e=il.getEntry(vf(this,sl),t);return e&&e.v},set:function(t,e){return il.def(vf(this,sl),t===0?0:t,e)}},il,!0);var ol,Mf;function QT(){if(Mf)return ol;Mf=1;var s=io;return ol=function(t,e){var r=[];return s(t,!1,r.push,r,e),r},ol}var al,wf;function qT(){if(wf)return al;wf=1;var s=Ja,t=QT();return al=function(e){return function(){if(s(this)!=e)throw TypeError(e+"#toJSON isn't generic");return t(this)}},al}var cl=_t;cl(cl.P+cl.R,"Map",{toJSON:qT()("Map")});var Sf=_t,ZT=function(s){Sf(Sf.S,s,{of:function(){for(var e=arguments.length,r=new Array(e);e--;)r[e]=arguments[e];return new this(r)}})};ZT("Map");var Tf=_t,If=to,KT=kn,Cf=io,XT=function(s){Tf(Tf.S,s,{from:function(e){var r=arguments[1],n,i,o,a;return If(this),n=r!==void 0,n&&If(r),e==null?new this:(i=[],n?(o=0,a=KT(r,arguments[2],2),Cf(e,!1,function(c){i.push(a(c,o++))})):Cf(e,!1,i.push,i),new this(i))}})};XT("Map");var JT=Pt.Map,Vm={default:JT,__esModule:!0},tc={};tc.f=Object.getOwnPropertySymbols;var Xi={};Xi.f={}.propertyIsEnumerable;var ll,bf;function _T(){if(bf)return ll;bf=1;var s=fr,t=Zi,e=tc,r=Xi,n=Ki,i=ah,o=Object.assign;return ll=!o||ai(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,f=e.f,g=r.f;h>d;)for(var y=i(arguments[d++]),S=f?t(y).concat(f(y)):t(y),b=S.length,I=0,N;b>I;)N=S[I++],(!s||g.call(y,N))&&(u[N]=y[N]);return u}:o,ll}var ul=_t;ul(ul.S+ul.F,"Object",{assign:_T()});var e1=Pt.Object.assign,Ih={default:e1,__esModule:!0},rc={};rc.__esModule=!0;rc.default=function(s,t){if(!(s instanceof t))throw new TypeError("Cannot call a class as a function")};var nc={},hl=_t;hl(hl.S+hl.F*!fr,"Object",{defineProperty:dr.f});var t1=Pt.Object,r1=function(t,e,r){return t1.defineProperty(t,e,r)},n1={default:r1,__esModule:!0};nc.__esModule=!0;var i1=n1,s1=o1(i1);function o1(s){return s&&s.__esModule?s:{default:s}}nc.default=function(){function s(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,s1.default)(t,n.key,n)}}return function(t,e,r){return e&&s(t.prototype,e),r&&s(t,r),t}}();var Ch={};Ch.f=Yt;var Ef=Pt,a1=Ch,c1=dr.f,bh=function(s){var t=Ef.Symbol||(Ef.Symbol={});s.charAt(0)!="_"&&!(s in t)&&c1(t,s,{value:a1.f(s)})},l1=Zi,u1=tc,h1=Xi,d1=function(s){var t=l1(s),e=u1.f;if(e)for(var r=e(s),n=h1.f,i=0,o;r.length>i;)n.call(s,o=r[i++])&&t.push(o);return t},$m={},Eh={},f1=Em,g1=gh.concat("length","prototype");Eh.f=Object.getOwnPropertyNames||function(t){return f1(t,g1)};var p1=oi,Ym=Eh.f,m1={}.toString,Gm=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],y1=function(s){try{return Ym(s)}catch{return Gm.slice()}};$m.f=function(t){return Gm&&m1.call(t)=="[object Window]"?y1(t):Ym(p1(t))};var Hm={},v1=Xi,M1=ro,w1=oi,S1=uh,T1=ci,I1=Im,xf=Object.getOwnPropertyDescriptor;Hm.f=fr?xf:function(t,e){if(t=w1(t),e=S1(e,!0),I1)try{return xf(t,e)}catch{}if(T1(t,e))return M1(!v1.f.call(t,e),t[e])};var ic=Jt,kt=ci,Qm=fr,Ut=_t,C1=Cm,b1=Th.KEY,xh=ai,Rh=dh,kh=no,E1=Xa,so=Yt,x1=Ch,R1=bh,k1=d1,A1=Wm,du=un,P1=Or,D1=Ki,sc=oi,Ah=uh,fu=ro,Ws=ph,qm=$m,Zm=Hm,oc=tc,Km=dr,L1=Zi,Xm=Zm.f,Hn=Km.f,Jm=qm.f,Xt=ic.Symbol,wa=ic.JSON,Ro=wa&&wa.stringify,Tn="prototype",Kt=so("_hidden"),Rf=so("toPrimitive"),N1={}.propertyIsEnumerable,as=Rh("symbol-registry"),cn=Rh("symbols"),oo=Rh("op-symbols"),Sr=Object[Tn],Ji=typeof Xt=="function"&&!!oc.f,dl=ic.QObject,gu=!dl||!dl[Tn]||!dl[Tn].findChild,pu=Qm&&xh(function(){return Ws(Hn({},"a",{get:function(){return Hn(this,"a",{value:7}).a}})).a!=7})?function(s,t,e){var r=Xm(Sr,t);r&&delete Sr[t],Hn(s,t,e),r&&s!==Sr&&Hn(Sr,t,r)}:Hn,kf=function(s){var t=cn[s]=Ws(Xt[Tn]);return t._k=s,t},mu=Ji&&typeof Xt.iterator=="symbol"?function(s){return typeof s=="symbol"}:function(s){return s instanceof Xt},ac=function(t,e,r){return t===Sr&&ac(oo,e,r),du(t),e=Ah(e,!0),du(r),kt(cn,e)?(r.enumerable?(kt(t,Kt)&&t[Kt][e]&&(t[Kt][e]=!1),r=Ws(r,{enumerable:fu(0,!1)})):(kt(t,Kt)||Hn(t,Kt,fu(1,{})),t[Kt][e]=!0),pu(t,e,r)):Hn(t,e,r)},_m=function(t,e){du(t);for(var r=k1(e=sc(e)),n=0,i=r.length,o;i>n;)ac(t,o=r[n++],e[o]);return t},O1=function(t,e){return e===void 0?Ws(t):_m(Ws(t),e)},z1=function(t){var e=N1.call(this,t=Ah(t,!0));return this===Sr&&kt(cn,t)&&!kt(oo,t)?!1:e||!kt(this,t)||!kt(cn,t)||kt(this,Kt)&&this[Kt][t]?e:!0},ey=function(t,e){if(t=sc(t),e=Ah(e,!0),!(t===Sr&&kt(cn,e)&&!kt(oo,e))){var r=Xm(t,e);return r&&kt(cn,e)&&!(kt(t,Kt)&&t[Kt][e])&&(r.enumerable=!0),r}},ty=function(t){for(var e=Jm(sc(t)),r=[],n=0,i;e.length>n;)!kt(cn,i=e[n++])&&i!=Kt&&i!=b1&&r.push(i);return r},ry=function(t){for(var e=t===Sr,r=Jm(e?oo:sc(t)),n=[],i=0,o;r.length>i;)kt(cn,o=r[i++])&&(!e||kt(Sr,o))&&n.push(cn[o]);return n};Ji||(Xt=function(){if(this instanceof Xt)throw TypeError("Symbol is not a constructor!");var t=E1(arguments.length>0?arguments[0]:void 0),e=function(r){this===Sr&&e.call(oo,r),kt(this,Kt)&&kt(this[Kt],t)&&(this[Kt][t]=!1),pu(this,t,fu(1,r))};return Qm&&gu&&pu(Sr,t,{configurable:!0,set:e}),kf(t)},C1(Xt[Tn],"toString",function(){return this._k}),Zm.f=ey,Km.f=ac,Eh.f=qm.f=ty,Xi.f=z1,oc.f=ry,x1.f=function(s){return kf(so(s))});Ut(Ut.G+Ut.W+Ut.F*!Ji,{Symbol:Xt});for(var Af="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),Pf=0;Af.length>Pf;)so(Af[Pf++]);for(var Df=L1(so.store),Lf=0;Df.length>Lf;)R1(Df[Lf++]);Ut(Ut.S+Ut.F*!Ji,"Symbol",{for:function(s){return kt(as,s+="")?as[s]:as[s]=Xt(s)},keyFor:function(t){if(!mu(t))throw TypeError(t+" is not a symbol!");for(var e in as)if(as[e]===t)return e},useSetter:function(){gu=!0},useSimple:function(){gu=!1}});Ut(Ut.S+Ut.F*!Ji,"Object",{create:O1,defineProperty:ac,defineProperties:_m,getOwnPropertyDescriptor:ey,getOwnPropertyNames:ty,getOwnPropertySymbols:ry});var B1=xh(function(){oc.f(1)});Ut(Ut.S+Ut.F*B1,"Object",{getOwnPropertySymbols:function(t){return oc.f(D1(t))}});wa&&Ut(Ut.S+Ut.F*(!Ji||xh(function(){var s=Xt();return Ro([s])!="[null]"||Ro({a:s})!="{}"||Ro(Object(s))!="{}"})),"JSON",{stringify:function(t){for(var e=[t],r=1,n,i;arguments.length>r;)e.push(arguments[r++]);if(i=n=e[1],!(!P1(n)&&t===void 0||mu(t)))return A1(n)||(n=function(o,a){if(typeof i=="function"&&(a=i.call(this,o,a)),!mu(a))return a}),e[1]=n,Ro.apply(wa,e)}});Xt[Tn][Rf]||An(Xt[Tn],Rf,Xt[Tn].valueOf);kh(Xt,"Symbol");kh(Math,"Math",!0);kh(ic.JSON,"JSON",!0);bh("asyncIterator");bh("observable");var j1=Pt.Symbol,ny={default:j1,__esModule:!0},cc={};Object.defineProperty(cc,"__esModule",{value:!0});cc.createNowTime=F1;cc.formatDelay=U1;function F1(){var s=null;return Date.now?s=Date.now:s=function(){return new Date().getTime()},s}function U1(s){return typeof s=="number"?s={delay:s}:"entropy"in s&&(s={delay:s.entropy,isEntropy:!0}),s}Object.defineProperty(Za,"__esModule",{value:!0});var W1=_s,Nf=ui(W1),V1=_a,fl=ui(V1),$1=Vm,Y1=ui($1),G1=Ih,H1=ui(G1),Q1=rc,q1=ui(Q1),Z1=nc,K1=ui(Z1),X1=ny,li=ui(X1),iy=cc;function ui(s){return s&&s.__esModule?s:{default:s}}var J1=(0,iy.createNowTime)(),_1={originTime:0,playbackRate:1},Fr=(0,li.default)("timeMark"),gl=(0,li.default)("playbackRate"),Ur=(0,li.default)("timers"),eI=(0,li.default)("originTime"),cs=(0,li.default)("setTimer"),Wr=(0,li.default)("parent"),tI=function(){function s(t,e){(0,q1.default)(this,s),t instanceof s&&(e=t,t={}),t=(0,H1.default)({},_1,t),e&&(this[Wr]=e);var r=t.nowtime||J1;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[Fr]=[{globalTime:this.globalTime,localTime:-t.originTime,entropy:-t.originTime,playbackRate:t.playbackRate,globalEntropy:0}],this[Wr]&&(this[Fr][0].globalEntropy=this[Wr].entropy),this[eI]=t.originTime,this[gl]=t.playbackRate,this[Ur]=new Y1.default}return(0,K1.default)(s,[{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,i=e.entropy,o=i===void 0?this.entropy:i,a=e.playbackRate,c=a===void 0?this.playbackRate:a,l={globalTime:this.globalTime,localTime:n,entropy:o,playbackRate:c,globalEntropy:this.globalEntropy};this[Fr].push(l)}},{key:"fork",value:function(e){return new s(e,this)}},{key:"seekGlobalTime",value:function(e){var r=this.seekTimeMark(e),n=this[Fr][r],i=n.entropy,o=n.playbackRate,a=n.globalTime;return a+(e-i)/Math.abs(o)}},{key:"seekLocalTime",value:function(e){var r=this.seekTimeMark(e),n=this[Fr][r],i=n.localTime,o=n.entropy,a=n.playbackRate;return a>0?i+(e-o):i-(e-o)}},{key:"seekTimeMark",value:function(e){var r=this[Fr],n=0,i=r.length-1;if(e<=r[n].entropy)return n;if(e>=r[i].entropy)return i;for(var o=Math.floor((n+i)/2);o>n&&o<i;){if(e===r[o].entropy)return o;e<r[o].entropy?i=o:e>r[o].entropy&&(n=o),o=Math.floor((n+i)/2)}return n}},{key:"updateTimers",value:function(){var e=this,r=[].concat((0,fl.default)(this[Ur]));r.forEach(function(n){var i=(0,Nf.default)(n,2),o=i[0],a=i[1];e[cs](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[Ur].get(t);e&&e.timerID!=null&&(this[Wr]?this[Wr].clearTimeout(e.timerID):clearTimeout(e.timerID)),this[Ur].delete(t)})},{key:"clearInterval",value:function(e){return this.clearTimeout(e)}},{key:"clear",value:function(){var e=this,r=this[Ur];[].concat((0,fl.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[cs](e,r)}},{key:"setInterval",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{delay:0},n=this,i=this[cs](function o(){n[cs](o,r,i),e()},r);return i}},{key:cs,value:function(e,r){var n=this,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:(0,li.default)("timerID");r=(0,iy.formatDelay)(r);var o=this[Ur].get(i),a=void 0,c=null,l=void 0,u=void 0;o?(this.clearTimeout(i),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[Wr],d=h?h.setTimeout.bind(h):setTimeout,f=r.heading;return!h&&f===!1&&a<0&&(a=1/0),(isFinite(a)||h)&&(a=Math.ceil(a),d!==setTimeout&&(a={delay:a,heading:f}),c=d(function(){n[Ur].delete(i),e()},a)),this[Ur].set(i,{timerID:c,handler:e,time:r,startTime:l,startEntropy:u}),i}},{key:"parent",get:function(){return this[Wr]}},{key:"lastTimeMark",get:function(){return this[Fr][this[Fr].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,i=e,o=this[Ur];this.markTime({time:e}),[].concat((0,fl.default)(o)).forEach(function(a){var c=(0,Nf.default)(a,2),l=c[0],u=c[1];if(o.has(l)){var h=u.time,d=h.isEntropy,f=h.delay,g=h.heading,y=u.handler,S=u.startTime;if(d)f===0&&(y(),r.clearTimeout(l));else{var b=S+f;(f===0||g!==!1&&(i-n)*f<=0||n<=b&&b<=i||n>=b&&b>=i)&&(y(),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[Fr].length=r+1}this.markTime({entropy:e}),this.updateTimers()}},{key:"globalEntropy",get:function(){return this[Wr]?this[Wr].entropy:this.globalTime}},{key:"playbackRate",get:function(){return this[gl]},set:function(e){e!==this.playbackRate&&(this.markTime({playbackRate:e}),this[gl]=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}}]),s}();Za.default=tI;var lc={};Object.defineProperty(lc,"__esModule",{value:!0});lc.default={default:function(t,e,r,n,i){return typeof t=="number"&&typeof e=="number"?t+(r-n)/(i-n)*(e-t):r-n>i-r?e:t}};var bn={},rI=4,nI=.001,iI=1e-7,sI=10,Es=11,ko=1/(Es-1),oI=typeof Float32Array=="function";function sy(s,t){return 1-3*t+3*s}function oy(s,t){return 3*t-6*s}function ay(s){return 3*s}function Sa(s,t,e){return((sy(t,e)*s+oy(t,e))*s+ay(t))*s}function cy(s,t,e){return 3*sy(t,e)*s*s+2*oy(t,e)*s+ay(t)}function aI(s,t,e,r,n){var i,o,a=0;do o=t+(e-t)/2,i=Sa(o,r,n)-s,i>0?e=o:t=o;while(Math.abs(i)>iI&&++a<sI);return o}function cI(s,t,e,r){for(var n=0;n<rI;++n){var i=cy(t,e,r);if(i===0)return t;var o=Sa(t,e,r)-s;t-=o/i}return t}function lI(s){return s}var uI=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 lI;for(var i=oI?new Float32Array(Es):new Array(Es),o=0;o<Es;++o)i[o]=Sa(o*ko,t,r);function a(c){for(var l=0,u=1,h=Es-1;u!==h&&i[u]<=c;++u)l+=ko;--u;var d=(c-i[u])/(i[u+1]-i[u]),f=l+d*ko,g=cy(f,t,r);return g>=nI?cI(c,f,t,r):g===0?f:aI(c,l,l+ko,t,r)}return function(l){return l===0?0:l===1?1:Sa(a(l),e,n)}};Object.defineProperty(bn,"__esModule",{value:!0});bn.parseEasing=bn.Easings=void 0;var hI=_s,dI=Ph(hI),fI=_a,ly=Ph(fI),gI=Vm,pI=Ph(gI);function Ph(s){return s&&s.__esModule?s:{default:s}}var mI=uI,Of=new pI.default;function Di(){for(var s=arguments.length,t=Array(s),e=0;e<s;e++)t[e]=arguments[e];var r=Of.get(t);return r||(r=mI.apply(void 0,t),Of.set(t,r),r)}function Ta(s){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 i=r[n].offset;if(e<=i){var o=r[n-1].offset,a=i,c=(e-o)/(a-o),l=1/s,u=c/l;return t==="end"?u=Math.floor(u):u=Math.ceil(u),l*u*(a-o)+o}}return 0}}function yI(s){var t=/^cubic-bezier\((.*)\)/,e=s.match(t);if(e){var r=e[1].trim();return r=r.split(",").map(function(l){return parseFloat(l.trim())}),Di.apply(void 0,(0,ly.default)(r))}if(t=/^steps\((.*)\)/,e=s.match(t),e){var n=e[1].trim();n=n.split(",").map(function(l){return l.trim()});var i=n,o=(0,dI.default)(i,2),a=o[0],c=o[1];return Ta(parseInt(a,10),c)}return s}var yu={linear:function(t){return t},ease:Di(.25,.1,.25,1),"ease-in":Di(.42,0,1,1),"ease-out":Di(0,0,.58,1),"ease-in-out":Di(.42,0,.58,1),"step-start":Ta(1,"start"),"step-end":Ta(1,"end")};function vI(s){return typeof s=="string"?yu[s]?s=yu[s]:s=yI(s):s.type==="cubic-bezier"?s=Di.apply(void 0,(0,ly.default)(s.value)):s.type==="steps"&&(s=Ta(s.step,s.pos)),s}bn.Easings=yu;bn.parseEasing=vI;var Dh={},zf=un,MI=to,wI=Yt("species"),uy=function(s,t){var e=zf(s).constructor,r;return e===void 0||(r=zf(e)[wI])==null?t:MI(r)},SI=function(s,t,e){var r=e===void 0;switch(t.length){case 0:return r?s():s.call(e);case 1:return r?s(t[0]):s.call(e,t[0]);case 2:return r?s(t[0],t[1]):s.call(e,t[0],t[1]);case 3:return r?s(t[0],t[1],t[2]):s.call(e,t[0],t[1],t[2]);case 4:return r?s(t[0],t[1],t[2],t[3]):s.call(e,t[0],t[1],t[2],t[3])}return s.apply(e,t)},Ao=kn,TI=SI,Bf=xm,jf=lh,tn=Jt,Ff=tn.process,vu=tn.setImmediate,Uf=tn.clearImmediate,Wf=tn.MessageChannel,pl=tn.Dispatch,ml=0,Os={},Vf="onreadystatechange",On,yl,vl,xs=function(){var s=+this;if(Os.hasOwnProperty(s)){var t=Os[s];delete Os[s],t()}},$f=function(s){xs.call(s.data)};(!vu||!Uf)&&(vu=function(t){for(var e=[],r=1;arguments.length>r;)e.push(arguments[r++]);return Os[++ml]=function(){TI(typeof t=="function"?t:Function(t),e)},On(ml),ml},Uf=function(t){delete Os[t]},eo(Ff)=="process"?On=function(s){Ff.nextTick(Ao(xs,s,1))}:pl&&pl.now?On=function(s){pl.now(Ao(xs,s,1))}:Wf?(yl=new Wf,vl=yl.port2,yl.port1.onmessage=$f,On=Ao(vl.postMessage,vl,1)):tn.addEventListener&&typeof postMessage=="function"&&!tn.importScripts?(On=function(s){tn.postMessage(s+"","*")},tn.addEventListener("message",$f,!1)):Vf in jf("script")?On=function(s){Bf.appendChild(jf("script"))[Vf]=function(){Bf.removeChild(this),xs.call(s)}}:On=function(s){setTimeout(Ao(xs,s,1),0)});var hy={set:vu},ti=Jt,II=hy.set,Yf=ti.MutationObserver||ti.WebKitMutationObserver,Mu=ti.process,Ml=ti.Promise,Gf=eo(Mu)=="process",CI=function(){var s,t,e,r=function(){var a,c;for(Gf&&(a=Mu.domain)&&a.exit();s;){c=s.fn,s=s.next;try{c()}catch(l){throw s?e():t=void 0,l}}t=void 0,a&&a.enter()};if(Gf)e=function(){Mu.nextTick(r)};else if(Yf&&!(ti.navigator&&ti.navigator.standalone)){var n=!0,i=document.createTextNode("");new Yf(r).observe(i,{characterData:!0}),e=function(){i.data=n=!n}}else if(Ml&&Ml.resolve){var o=Ml.resolve(void 0);e=function(){o.then(r)}}else e=function(){II.call(ti,r)};return function(a){var c={fn:a,next:void 0};t&&(t.next=c),s||(s=c,e()),t=c}},uc={},Hf=to;function bI(s){var t,e;this.promise=new s(function(r,n){if(t!==void 0||e!==void 0)throw TypeError("Bad Promise constructor");t=r,e=n}),this.resolve=Hf(t),this.reject=Hf(e)}uc.f=function(s){return new bI(s)};var dy=function(s){try{return{e:!1,v:s()}}catch(t){return{e:!0,v:t}}},EI=Jt,Qf=EI.navigator,xI=Qf&&Qf.userAgent||"",RI=un,kI=Or,AI=uc,fy=function(s,t){if(RI(s),kI(t)&&t.constructor===s)return t;var e=AI.f(s),r=e.resolve;return r(t),e.promise},PI=KM,In=Jt,Li=kn,DI=Ja,ar=_t,LI=Or,NI=to,OI=Mh,qf=io,zI=uy,gy=hy.set,py=CI(),my=uc,wu=dy,BI=xI,jI=fy,Pn="Promise",yy=In.TypeError,Gi=In.process,Zf=Gi&&Gi.versions,FI=Zf&&Zf.v8||"",Pr=In[Pn],Vs=DI(Gi)=="process",ua=function(){},Po,vy,Kf,Lh,$s=vy=my.f,hc=!!function(){try{var s=Pr.resolve(1),t=(s.constructor={})[Yt("species")]=function(e){e(ua,ua)};return(Vs||typeof PromiseRejectionEvent=="function")&&s.then(ua)instanceof t&&FI.indexOf("6.6")!==0&&BI.indexOf("Chrome/66")===-1}catch{}}(),My=function(s){var t;return LI(s)&&typeof(t=s.then)=="function"?t:!1},Nh=function(s,t){if(!s._n){s._n=!0;var e=s._c;py(function(){for(var r=s._v,n=s._s==1,i=0,o=function(a){var c=n?a.ok:a.fail,l=a.resolve,u=a.reject,h=a.domain,d,f,g;try{c?(n||(s._h==2&&WI(s),s._h=1),c===!0?d=r:(h&&h.enter(),d=c(r),h&&(h.exit(),g=!0)),d===a.promise?u(yy("Promise-chain cycle")):(f=My(d))?f.call(d,l,u):l(d)):u(r)}catch(y){h&&!g&&h.exit(),u(y)}};e.length>i;)o(e[i++]);s._c=[],s._n=!1,t&&!s._h&&UI(s)})}},UI=function(s){gy.call(In,function(){var t=s._v,e=Xf(s),r,n,i;if(e&&(r=wu(function(){Vs?Gi.emit("unhandledRejection",t,s):(n=In.onunhandledrejection)?n({promise:s,reason:t}):(i=In.console)&&i.error&&i.error("Unhandled promise rejection",t)}),s._h=Vs||Xf(s)?2:1),s._a=void 0,e&&r.e)throw r.v})},Xf=function(s){return s._h!==1&&(s._a||s._c).length===0},WI=function(s){gy.call(In,function(){var t;Vs?Gi.emit("rejectionHandled",s):(t=In.onrejectionhandled)&&t({promise:s,reason:s._v})})},Vi=function(s){var t=this;t._d||(t._d=!0,t=t._w||t,t._v=s,t._s=2,t._a||(t._a=t._c.slice()),Nh(t,!0))},Su=function(s){var t=this,e;if(!t._d){t._d=!0,t=t._w||t;try{if(t===s)throw yy("Promise can't be resolved itself");(e=My(s))?py(function(){var r={_w:t,_d:!1};try{e.call(s,Li(Su,r,1),Li(Vi,r,1))}catch(n){Vi.call(r,n)}}):(t._v=s,t._s=1,Nh(t,!1))}catch(r){Vi.call({_w:t,_d:!1},r)}}};hc||(Pr=function(t){OI(this,Pr,Pn,"_h"),NI(t),Po.call(this);try{t(Li(Su,this,1),Li(Vi,this,1))}catch(e){Vi.call(this,e)}},Po=function(t){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},Po.prototype=vh(Pr.prototype,{then:function(t,e){var r=$s(zI(this,Pr));return r.ok=typeof t=="function"?t:!0,r.fail=typeof e=="function"&&e,r.domain=Vs?Gi.domain:void 0,this._c.push(r),this._a&&this._a.push(r),this._s&&Nh(this,!1),r.promise},catch:function(s){return this.then(void 0,s)}}),Kf=function(){var s=new Po;this.promise=s,this.resolve=Li(Su,s,1),this.reject=Li(Vi,s,1)},my.f=$s=function(s){return s===Pr||s===Lh?new Kf(s):vy(s)});ar(ar.G+ar.W+ar.F*!hc,{Promise:Pr});no(Pr,Pn);zm(Pn);Lh=Pt[Pn];ar(ar.S+ar.F*!hc,Pn,{reject:function(t){var e=$s(this),r=e.reject;return r(t),e.promise}});ar(ar.S+ar.F*PI,Pn,{resolve:function(t){return jI(this===Lh?Pr:this,t)}});ar(ar.S+ar.F*!(hc&&Lm()(function(s){Pr.all(s).catch(ua)})),Pn,{all:function(t){var e=this,r=$s(e),n=r.resolve,i=r.reject,o=wu(function(){var a=[],c=0,l=1;qf(t,!1,function(u){var h=c++,d=!1;a.push(void 0),l++,e.resolve(u).then(function(f){d||(d=!0,a[h]=f,--l||n(a))},i)}),--l||n(a)});return o.e&&i(o.v),r.promise},race:function(t){var e=this,r=$s(e),n=r.reject,i=wu(function(){qf(t,!1,function(o){e.resolve(o).then(r.resolve,n)})});return i.e&&n(i.v),r.promise}});var wl=_t,VI=Pt,$I=Jt,YI=uy,Jf=fy;wl(wl.P+wl.R,"Promise",{finally:function(s){var t=YI(this,VI.Promise||$I.Promise),e=typeof s=="function";return this.then(e?function(r){return Jf(t,s()).then(function(){return r})}:s,e?function(r){return Jf(t,s()).then(function(){throw r})}:s)}});var _f=_t,GI=uc,HI=dy;_f(_f.S,"Promise",{try:function(s){var t=GI.f(this),e=HI(s);return(e.e?t.reject:t.resolve)(e.v),t.promise}});var QI=Pt.Promise,wy={default:QI,__esModule:!0},Sl=_t,qI=Pt,ZI=ai,KI=function(s,t){var e=(qI.Object||{})[s]||Object[s],r={};r[s]=t(e),Sl(Sl.S+Sl.F*ZI(function(){e(1)}),"Object",r)},XI=Ki,JI=Zi;KI("keys",function(){return function(t){return JI(XI(t))}});var _I=Pt.Object.keys,eC={default:_I,__esModule:!0},hi={},tC=fr,rC=Zi,nC=oi,iC=Xi.f,sC=function(s){return function(t){for(var e=nC(t),r=rC(e),n=r.length,i=0,o=[],a;n>i;)a=r[i++],(!tC||iC.call(e,a))&&o.push(s?[a,e[a]]:e[a]);return o}},eg=_t,oC=sC(!0);eg(eg.S,"Object",{entries:function(t){return oC(t)}});var aC=Pt.Object.entries,cC={default:aC,__esModule:!0};Object.defineProperty(hi,"__esModule",{value:!0});var lC=_s,uC=ao(lC),hC=cC,dC=ao(hC),fC=Ih,Sy=ao(fC),gC=wy,pC=ao(gC);hi.defer=MC;hi.periodicity=wC;hi.calculateFramesOffset=SC;hi.getProgress=TC;hi.getCurrentFrame=CC;var mC=bn,yC=lc,vC=ao(yC);function ao(s){return s&&s.__esModule?s:{default:s}}function MC(){var s={};return s.promise=new pC.default(function(t,e){s.resolve=t,s.reject=e}),s}function wC(s,t){var e=Math.floor(s/t),r=s-e*t;return r===0&&e>0&&(r=t,e--),[e,r]}function SC(s){s=s.slice(0);var t=s[0],e=s[s.length-1];e.offset=e.offset||1,t.offset=t.offset||0;for(var r=0,n=-1,i=0;i<s.length;i++){var o=s[i];if(o.offset!=null){var a=i-n;if(a>1)for(var c=(o.offset-r)/a,l=0;l<a-1;l++)s[n+l+1].offset=r+c*(l+1);r=o.offset,n=i}if(o.easing!=null&&(o.easing=(0,mC.parseEasing)(o.easing)),i>0){var u=s[i].easing!=null;s[i]=(0,Sy.default)({},s[i-1],s[i]),u||delete s[i].easing}}return s}function TC(s,t,e){var r=s.currentTime,n=t.direction,i=t.duration,o=!1;if(n==="reverse")e=1-e,o=!0;else if(n==="alternate"||n==="alternate-reverse"){var a=Math.floor(r/i);e===1&&a--,a%2^n==="alternate-reverse"&&(e=1-e,o=!0)}return{p:e,inverted:o}}function IC(s,t,e,r){var n={};return(0,dC.default)(t).forEach(function(i){var o=(0,uC.default)(i,2),a=o[0],c=o[1];if(a!=="offset"&&a!=="easing"){var l=e[a]||e.default,u=l(s[a],c,r,s.offset,t.offset);u!=null&&(n[a]=u)}}),n}function CC(s,t,e,r){var n=s.easing,i=s.effect;i||(e=(0,Sy.default)({},vC.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,f=r;if(d){var g=l-h;f=d((r-h)/g)*g+h}i?o=i(u,c,f,h,l):o=IC(u,c,e,f);break}}return o}Object.defineProperty(Dh,"__esModule",{value:!0});var bC=wy,Tl=di(bC),EC=eC,xC=di(EC),RC=Ih,ls=di(RC),kC=rc,AC=di(kC),PC=nc,DC=di(PC),LC=ny,hn=di(LC),NC=Za,OC=di(NC),dn=hi,zC=bn;function di(s){return s&&s.__esModule?s:{default:s}}var jt=(0,hn.default)("timing"),Vr=(0,hn.default)("keyframes"),us=(0,hn.default)("initState"),Dt=(0,hn.default)("readyDefer"),er=(0,hn.default)("finishedDefer"),Do=(0,hn.default)("effects"),Lo=(0,hn.default)("activeReadyTimer"),Il=(0,hn.default)("activeFinishTimer"),$r=(0,hn.default)("removeDefer"),BC={delay:0,endDelay:0,fill:"auto",iterations:1,playbackRate:1,direction:"normal",easing:"linear",effect:null},jC=function(){function s(t,e,r){var n=this;if((0,AC.default)(this,s),Array.isArray(t)){var i=[t[0],t,e];t=i[0],e=i[1],r=i[2]}typeof r=="number"&&(r={duration:r}),this[jt]=(0,ls.default)({},BC,r),this[jt].easing=(0,zC.parseEasing)(this[jt].easing),this[Vr]=(0,dn.calculateFramesOffset)(e);var o=this[Vr][this[Vr].length-1];this[us]={},(0,xC.default)(o).forEach(function(a){Object.prototype.hasOwnProperty.call(t,a)&&a!=="easing"&&a!=="offset"&&(n[us][a]=t[a])}),this[Vr]=this[Vr].map(function(a){return(0,ls.default)({},n[us],a)}),this[Vr][0].offset!==0&&this[Vr].unshift((0,ls.default)({},this[us],{offset:0})),o.offset<1&&this[Vr].push((0,ls.default)({},o,{offset:1})),this[Do]={},this.timeline=null}return(0,DC.default)(s,[{key:"pause",value:function(){this.timeline.playbackRate=0}},{key:Lo,value:function(){var e=this;this[Dt]&&!this[Dt].timerID&&(this.timeline.currentTime<0?this[Dt].timerID=this.timeline.setTimeout(function(){e[Dt].resolve(),delete e[Dt]},{delay:-this.timeline.currentTime,heading:!1}):this[Dt].timerID=this.timeline.setTimeout(function(){e[Dt].resolve(),delete e[Dt]},{delay:0,isEntropy:!0}))}},{key:Il,value:function(){var e=this,r=this[jt],n=r.duration,i=r.iterations,o=r.endDelay,a=Math.ceil(n*i+o-this.timeline.currentTime)+1;this[er]&&!this[er].timerID&&(this[er].timerID=this.timeline.setTimeout(function(){e[er].resolve(),e[$r](Dt),e[$r](er)},{delay:a,heading:!1}),this[er].reverseTimerID=this.timeline.setTimeout(function(){e[er].resolve(),e[$r](Dt),e[$r](er),e.timeline=null},{delay:-this[jt].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[jt],r=e.delay,n=e.playbackRate,i=e.timeline;this.timeline=new OC.default({originTime:r,playbackRate:n},i),this[Lo](),this[Il]()}else this.playState==="paused"&&(this.timeline.playbackRate=this.playbackRate,this[Lo]())}},{key:$r,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[$r](Dt),this[$r](er),this.timeline=null}},{key:"finish",value:function(){this.timeline&&(this.timeline.currentTime=1/0/this.playbackRate),this[$r](Dt),this[$r](er)}},{key:"applyEffects",value:function(e){return(0,ls.default)(this[Do],e)}},{key:"playbackRate",get:function(){return this[jt].playbackRate},set:function(e){this.timeline&&(this.timeline.playbackRate=e),this[jt].playbackRate=e}},{key:"playState",get:function(){var e=this.timeline,r=this[jt],n=r.iterations,i=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*i;c>0&&c<o?a="pending":c>=o&&(a="finished")}return a}},{key:"progress",get:function(){if(!this.timeline)return 0;var e=this[jt],r=e.duration,n=e.iterations,i=this.timeline,o=this.playState,a=void 0;if(o==="idle")a=0;else if(o==="paused"&&i.currentTime<0)a=0;else if(o==="pending")if(i.currentTime<0)a=0;else{var c=i.seekLocalTime(n*r);a=(0,dn.periodicity)(c,r)[1]/r}else(o==="running"||o==="paused")&&(a=(0,dn.periodicity)(i.currentTime,r)[1]/r);return o==="finished"&&(a=(0,dn.periodicity)(n,1)[1]),a}},{key:"frame",get:function(){var e=this.playState,r=this[us],n=this[jt].fill;if(e==="idle")return r;var i=this.timeline.currentTime,o=this[Vr].slice(0),a=(0,dn.getProgress)(this.timeline,this[jt],this.progress),c=a.p,l=a.inverted,u=r;return i<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,dn.getCurrentFrame)(this[jt],o,this[Do],c)),u}},{key:"timing",get:function(){return this[jt]}},{key:"effects",get:function(){return this[Do]}},{key:"baseTimeline",set:function(e){this[jt].timeline=e},get:function(){return this[jt].timeline}},{key:"ready",get:function(){return this[Dt]?this[Dt].promise:this.timeline&&this.timeline.currentTime>=0&&this.playState!=="paused"?Tl.default.resolve():(this[Dt]=(0,dn.defer)(),this.timeline&&this[Lo](),this[Dt]?this[Dt].promise:Tl.default.resolve())}},{key:"finished",get:function(){return this.playState==="finished"?Tl.default.resolve():(this[er]||(this[er]=(0,dn.defer)(),this.timeline&&this[Il]()),this[er].promise)}}]),s}();Dh.default=jC;Object.defineProperty(en,"__esModule",{value:!0});var Ty=en.Timeline=Ir=en.Effects=en.Easings=Iy=en.Animator=void 0,FC=Za,UC=Oh(FC),WC=lc,VC=Oh(WC),$C=bn,YC=Dh,GC=Oh(YC);function Oh(s){return s&&s.__esModule?s:{default:s}}var Iy=en.Animator=GC.default;en.Easings=$C.Easings;var Ir=en.Effects=VC.default;Ty=en.Timeline=UC.default;var HC={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 tg=ln(HC);var rg={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};function QC(s){var t,e=[],r=1,n;if(typeof s=="string")if(s=s.toLowerCase(),tg[s])e=tg[s].slice(),n="rgb";else if(s==="transparent")r=0,n="rgb",e=[0,0,0];else if(/^#[A-Fa-f0-9]+$/.test(s)){var i=s.slice(1),o=i.length,a=o<=4;r=1,a?(e=[parseInt(i[0]+i[0],16),parseInt(i[1]+i[1],16),parseInt(i[2]+i[2],16)],o===4&&(r=parseInt(i[3]+i[3],16)/255)):(e=[parseInt(i[0]+i[1],16),parseInt(i[2]+i[3],16),parseInt(i[4]+i[5],16)],o===8&&(r=parseInt(i[6]+i[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(s)){var c=t[1],l=c==="rgb",i=c.replace(/a$/,"");n=i;var o=i==="cmyk"?4:i==="gray"?1:3;e=t[2].trim().split(/\s*[,\/]\s*|\s+/).map(function(d,f){if(/%$/.test(d))return f===o?parseFloat(d)/100:i==="rgb"?parseFloat(d)*255/100:parseFloat(d);if(i[f]==="h"){if(/deg$/.test(d))return parseFloat(d);if(rg[d]!==void 0)return rg[d]}return parseFloat(d)}),c===i&&e.push(1),r=l||e[o]===void 0?1:e[o],e=e.slice(0,o)}else s.length>10&&/[0-9](?:\s|\/)/.test(s)&&(e=s.match(/([0-9]+)/g).map(function(u){return parseFloat(u)}),n=s.match(/([a-z])/ig).join("").toLowerCase());else isNaN(s)?Array.isArray(s)||s.length?(e=[s[0],s[1],s[2]],n="rgb",r=s.length===4?s[3]:1):s instanceof Object&&(s.r!=null||s.red!=null||s.R!=null?(n="rgb",e=[s.r||s.red||s.R||0,s.g||s.green||s.G||0,s.b||s.blue||s.B||0]):(n="hsl",e=[s.h||s.hue||s.H||0,s.s||s.saturation||s.S||0,s.l||s.lightness||s.L||s.b||s.brightness]),r=s.a||s.alpha||s.opacity||1,s.opacity!=null&&(r/=100)):(n="rgb",e=[s>>>16,(s&65280)>>>8,s&255]);return{space:n,values:e,alpha:r}}const Tu={min:[0,0,0],max:[255,255,255]};var Cl={name:"hsl",min:[0,0,0],max:[360,100,100],channel:["hue","saturation","lightness"],alias:["HSL"],rgb:function(s){var t=s[0]/360,e=s[1]/100,r=s[2]/100,n,i,o,a,c,l=0;if(e===0)return c=r*255,[c,c,c];for(i=r<.5?r*(1+e):r+e-r*e,n=2*r-i,a=[0,0,0];l<3;)o=t+1/3*-(l-1),o<0?o++:o>1&&o--,c=6*o<1?n+(i-n)*6*o:2*o<1?i:3*o<2?n+(i-n)*(2/3-o)*6:n,a[l++]=c*255;return a}};Tu.hsl=function(s){var t=s[0]/255,e=s[1]/255,r=s[2]/255,n=Math.min(t,e,r),i=Math.max(t,e,r),o=i-n,a,c,l;return i===n?a=0:t===i?a=(e-r)/o:e===i?a=2+(r-t)/o:r===i&&(a=4+(t-e)/o),a=Math.min(a*60,360),a<0&&(a+=360),l=(n+i)/2,i===n?c=0:l<=.5?c=o/(i+n):c=o/(2-i-n),[a,c*100,l*100]};function Iu(s){Array.isArray(s)&&s.raw&&(s=String.raw(...arguments));var t,e=QC(s);if(!e.space)return[];const r=e.space[0]==="h"?Cl.min:Tu.min,n=e.space[0]==="h"?Cl.max:Tu.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=Cl.rgb(t)),t.push(Math.min(Math.max(e.alpha,0),1)),t}Ze(Array);function qC(){if(typeof performance<"u"&&performance.now)return performance.now();if(typeof process<"u"&&process.hrtime){const[s,t]=process.hrtime();return s*1e3+t*1e-6}return Date.now?Date.now():new Date().getTime()}let rn,ri;typeof global<"u"&&typeof global.requestAnimationFrame=="function"?(rn=global.requestAnimationFrame,ri=global.cancelAnimationFrame):(rn=function(s){return setTimeout(()=>{s(qC())},16)},ri=function(s){return clearTimeout(s)});Ze(Array);function ng(s){if(typeof s=="string"){if(s=s.trim(),/^[0-9.]+%$/.test(s))return parseFloat(s)/100;if(/^([\d.]+)(px|pt|pc|in|cm|mm|em|ex|rem|q|vw|vh|vmax|vmin)$/.test(s))return sh(s)}return s}function dc(s,t,e,r,n){return typeof s=="string"&&(s=Iu(s)),typeof t=="string"&&(t=Iu(t)),Ir.default(s,t,e,r,n)}function ZC(s,t,e,r,n){return Ir.default(s,t,e,r,n)}Ir.default=function(s,t,e,r,n){return Array.isArray(s)&&Array.isArray(t)?s.map((i,o)=>i+(e-r)/(n-r)*(t[o]-i)):typeof s=="number"&&typeof t=="number"?s+(e-r)/(n-r)*(t-s):e-r>n-e?t:s};Ir.fillColor=dc;Ir.strokeColor=dc;Ir.bgcolor=dc;Ir.borderColor=dc;Ir.text=ZC;class KC extends Iy{constructor(t,e,r){const n=t.attr();Object.entries(n).forEach(([i,o])=>{n[i]=Ir[i]?o:ng(o)}),e=e.map(({...i})=>{const o={};return Object.entries(i).forEach(([a,c])=>{o[a]=Ir[a]?c:ng(c)}),o}),super(n,e,r),this.target=t,this.setter=function(i,o){o.attr(i)}}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"?(ri(t.requestId),e()):rn(r)}r()})})}finish(){super.finish(),ri(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=rn(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=rn(e):(n==="paused"||n==="pending"&&t.timeline.currentTime<0)&&t.ready.then(()=>{t.setter(t.frame,t.target),t.requestId=rn(e)}))})})}cancel(t=!1){ri(this.requestId),t?(this.setter(this.frame,this.target),super.cancel()):(super.cancel(),this.setter(this.frame,this.target))}}Ze(Array);const ha=new Map;function ig(s,t={},e=[]){s=s.toLowerCase();const r=ha.get(s);if(!r)throw new TypeError(`Invalid node: ${s}`);const n=new r(t);return e.forEach(i=>{n.appendChild(i)}),n}const Gt={registerNode(s,t,e=100){if(t=t.toLowerCase(),ha.has(t))throw new TypeError(`Cannot registerNode, ${t} has been taken.`);ha.set(t,s),Object.defineProperties(s.prototype,{nodeType:{value:e},tagName:{value:t.toUpperCase()},nodeName:{value:t},ownerDocument:{value:Gt},namespaceURI:{value:`http://spritejs.com/${t}`}})},createElement:ig,createElementNS(s,t){return ig(t)},isSpriteNode(s){return ha.has(s.toLowerCase())}};Ze(Array);const No=Symbol("type"),bl=Symbol("bubbles"),El=Symbol("originalEvent"),sg=Symbol("detail");class ni{constructor(t,{bubbles:e=null}={}){if(typeof t=="string"?(this[No]=t,this[bl]=!!e):(this[No]=t.type,this[El]=t,this[bl]=e!=null?!!e:!!t.bubbles,t.detail&&(this[sg]=t.detail)),!this[No])throw new TypeError("Invalid event type.");this.cancelBubble=!1}setOriginalEvent(t){this[El]=t}get originalEvent(){return this[El]}get type(){return this[No]}get bubbles(){return this[bl]}get detail(){return this[sg]}stopPropagation(){this.cancelBubble=!0}}Ze(Array);function XC(s){if(s=s.trim(),!s||s==="none")return null;const t=/^(?:(url|blur|brightness|contrast|drop-shadow|grayscale|hue-rotate|invert|opacity|saturate|sepia)\(([^()]*(?:\(.*\))*[^()]*)\))+$/i,e=s.match(/(?:(url|blur|brightness|contrast|drop-shadow|grayscale|hue-rotate|invert|opacity|saturate|sepia)\(([^()]*(?:\(.*\))*[^()]*)\))+?/ig),r=[];return e&&e.forEach(n=>{const i=n.match(t);if(!i)throw new TypeError("Invalid fitler string.");let[,o,a]=i;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 JC(s,t){s.clearFilter(),t&&t.forEach(({type:e,args:r})=>{let n=e;n==="drop-shadow"?n="dropShadow":n==="hue-rotate"&&(n="hueRotate"),s[n](...r)})}Ze(Array);function _C(s,t){if(!t)return;const e=s.getListeners("beforerender"),r=s.getListeners("afterrender");e.length&&!t.beforeRender?t.beforeRender=n=>{s.dispatchEvent({type:"beforerender",detail:{context:n}})}:e.length||(t.beforeRender=null),r.length&&!t.afterRender?t.afterRender=n=>{s.dispatchEvent({type:"afterrender",detail:{context:n}})}:r.length||(t.afterRender=null)}Ze(Array);const eb=Symbol.for("spritejs_changedAttrs"),tb=Symbol.for("spritejs_attributes"),Oo=Symbol("resolution"),Si=Symbol("animations"),zn=Symbol("eventListeners"),Bn=Symbol("captureEventListeners"),og=Symbol("filters"),ag=Symbol("display"),zo=Symbol("program"),hs=Symbol("shaderAttrs"),Ti=Symbol("uniforms"),Bo=Symbol("mask");var _l;let fc=(_l=class{constructor(t={}){this.attributes=new this.constructor.Attr(this),this[Oo]={width:300,height:150},Object.assign(this.attributes,t),this[Si]=new Set,this[zn]={},this[Bn]={}}get ancestors(){let t=this.parent;const e=[];for(;t;)e.push(t),t=t.parent;return e}get animations(){return this[Si]}get filters(){return this[og]||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[Bo]?{...this[Bo],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[zo]}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=Nr(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[Ti]}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[hs]||{}}activateAnimations(){const t=this.layer;if(t){const e=this[Si];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:i}=r,o=n?Bn:zn;return this[o][t]=this[o][t]||[],this[o][t].push({listener:e,once:i}),this}animate(t,e){const r=new KC(this,t,e);return this.effects&&r.applyEffects(this.effects),this.layer&&(r.baseTimeline=this.layer.timeline,r.play(),r.finished.then(()=>{this[Si].delete(r)})),this[Si].add(r),r}attr(...t){if(t.length===0)return this.attributes[tb];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[eb];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[Si].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 ni||(t=new ni(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 i=r.length-1;i>=0;i--){const o=r[i],a=o[Bn]&&o[Bn][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 i=0;i<r.length;i++){const o=r[i],a=o[zn]&&o[zn][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(JC(e,this.filters),this._applyMask(e),t.push(e),this[zo]){e.setProgram(this[zo]);const r=this[hs];r&&Object.entries(r).forEach(([i,o])=>{e.setAttribute(i,o)});const n=this[Ti];if(this[Ti]){const i={};Object.entries(n).forEach(([o,a])=>{typeof a=="function"&&(a=a(this,o)),i[o]=a}),e.setUniforms(i)}}_C(this,e)}return t}forceUpdate(){this.parent&&this.parent.forceUpdate()}getAttribute(t){return this.attributes[t]}getListeners(t,{capture:e=!1}={}){return[...this[e?Bn:zn][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],i=t*r[1]+e*r[3]+r[5];return[n,i]}getOffsetPosition(t,e){const r=Ma(Array.of(0,0,0,0,0,0),this.renderMatrix),n=t*r[0]+e*r[2]+r[4],i=t*r[1]+e*r[3]+r[5];return[n,i]}getResolution(){return{...this[Oo]}}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[og]=XC(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[Bo]={handle:t,rect:e.rect||t.rect},this.forceUpdate(),this):this.clearMask()}clearMask(){return this[Bo]=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),i=e.rect;if(!n||!i||i[2]<=0||i[3]<=0)return;const o=Ma(Array.of(0,0,0,0,0,0),e.owner.renderMatrix);if(!o)return;const a=Nr(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],f=u*a[1]+h*a[3]+a[5];return[(d-i[0])/i[2],1-(f-i[1])/i[3]]}),t.__spriteMaskApplied||(t.__spriteMaskBlend=t.blend),t.blend=!0,t.__spriteMaskApplied=!0}setProgram(t){this[zo]=t,this.forceUpdate()}setShaderAttribute(t,e){this[hs]=this[hs]||{},this[hs][t]=e,this.forceUpdate()}setUniforms(t){this[Ti]=this[Ti]||{},Object.assign(this[Ti],t),this.forceUpdate()}setResolution({width:t,height:e}){const{width:r,height:n}=this[Oo];(r!==t||n!==e)&&(this[Oo]={width:t,height:e},this.forceUpdate(),this.dispatchEvent({type:"resolutionchange",detail:{width:t,height:e}}))}show(){this.attributes.display==="none"&&(this.attributes.display=this[ag]||"")}hide(){this.attributes.display!=="none"&&(this[ag]=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?Bn:zn;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 i=r.capture?Bn:zn;if(this[i][t]){const o=this[i][t];if(o)for(let a=0;a<o.length;a++){const{listener:c}=o[a];if(c===e){this[i][t].splice(a,1);break}}}return this}transition(t,e="linear"){const r=this,n=Symbol("animation");e=e||"linear";let i=0;return typeof t=="object"&&(i=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:i*1e3,fill:"forwards",easing:e}),this[n].finished}}}updateContours(){}},x(_l,"Attr",oh),_l);Gt.registerNode(fc,"node");Ze(Array);class rb{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:En(n)}))}toString(){return JSON.stringify({vector:this.vector,colors:this.colors})}}function En(s){if(s==null||(s||(s="transparent"),s instanceof rb))return s;const t=Iu(s);if(!t||!t.length)throw new TypeError("Invalid color value.");return`rgba(${t.join()})`}function Cy(s,t,e){const r=s.boundingBox[0];if(e.vector){let{vector:n,colors:i}=e;n.length===4?(n=[n[0]+r[0],n[1]+r[1],n[2]+r[0],n[3]+r[1]],s.setLinearGradient({vector:n,colors:i,type:t})):n.length===3?(n=[n[0]+r[0],n[1]+r[1],n[2]],s.setCircularGradient({vector:n,colors:i,type:t})):(n=[n[0]+r[0],n[1]+r[1],n[2],n[3]+r[0],n[4]+r[1],n[5]],s.setRadialGradient({vector:n,colors:i,type:t}))}else s.gradient&&s.gradient[t]&&(delete s.gradient[t],delete s.uniforms.u_radialGradientVector)}function Ia(s,{color:t,rule:e="nonzero"}){return Cy(s,"fill",t),t.vector||s.setFill({color:t,rule:e}),s}function Ca(s,{color:t,lineWidth:e,lineCap:r,lineJoin:n,lineDash:i,lineDashOffset:o,miterLimit:a,roundSegments:c}){Cy(s,"stroke",t),t.vector&&(t=[0,0,0,1]),s.setStroke({color:t,thickness:e,cap:r,join:n,miterLimit:a,lineDash:i,lineDashOffset:o,roundSegments:c})}Ze(Array);const Tt=Symbol.for("spritejs_setAttribute"),It=Symbol.for("spritejs_getAttribute"),nb=Symbol.for("spritejs_setAttributeDefault"),ib=Symbol.for("spritejs_declareAlias");let gc=class extends oh{constructor(t){super(t),this[nb]({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[ib]("anchor","size","border","borderRadius","padding")}get anchorX(){return this[It]("anchorX")}set anchorX(t){this[Tt]("anchorX",qe(t))}get anchorY(){return this[It]("anchorY")}set anchorY(t){this[Tt]("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[It]("width")}set width(t){this[Tt]("width",qe(t))}get height(){return this[It]("height")}set height(t){this[Tt]("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[It]("borderWidth")}set borderWidth(t){this[Tt]("borderWidth",qe(t))}get borderColor(){return this[It]("borderColor")}set borderColor(t){this[Tt]("borderColor",En(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[It]("borderDash")}set borderDash(t){t=Mt(t,!0),t!=null&&!Array.isArray(t)&&(t=[t]),this[Tt]("borderDash",t?t.map(qe):null)}get borderDashOffset(){return this[It]("borderDashOffset")}set borderDashOffset(t){this[Tt]("borderDashOffset",qe(t))}get borderTopLeftRadius(){return this[It]("borderTopLeftRadius")}set borderTopLeftRadius(t){t=Mt(t,!0),Array.isArray(t)||(t=[t,t]),this[Tt]("borderTopLeftRadius",t.map(qe))}get borderTopRightRadius(){return this[It]("borderTopRightRadius")}set borderTopRightRadius(t){t=Mt(t,!0),Array.isArray(t)||(t=[t,t]),this[Tt]("borderTopRightRadius",t.map(qe))}get borderBottomRightRadius(){return this[It]("borderBottomRightRadius")}set borderBottomRightRadius(t){t=Mt(t,!0),Array.isArray(t)||(t=[t,t]),this[Tt]("borderBottomRightRadius",t.map(qe))}get borderBottomLeftRadius(){return this[It]("borderBottomLeftRadius")}set borderBottomLeftRadius(t){t=Mt(t,!0),Array.isArray(t)||(t=[t,t]),this[Tt]("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[It]("bgcolor")}set bgcolor(t){this[Tt]("bgcolor",En(t))}get paddingTop(){return this[It]("paddingTop")}set paddingTop(t){this[Tt]("paddingTop",qe(t))}get paddingRight(){return this[It]("paddingRight")}set paddingRight(t){this[Tt]("paddingRight",qe(t))}get paddingBottom(){return this[It]("paddingBottom")}set paddingBottom(t){this[Tt]("paddingBottom",qe(t))}get paddingLeft(){return this[It]("paddingLeft")}set paddingLeft(t){this[Tt]("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[It]("clipPath")}set clipPath(t){this[Tt]("clipPath",t)}get boxSizing(){return this[It]("boxSizing")}set boxSizing(t){if(t!=null&&t!=="border-box"&&t!=="content-box")throw new TypeError("Invalid boxSizing type.");this[Tt]("boxSizing",t)}};Ze(Array);function jo(s,t,e,r,n,i="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;i==="leftTop"?(s.moveTo(t,d),s.bezierCurveTo(t,d-c,h-a,e,h,e)):i==="rightTop"?s.bezierCurveTo(h+a,e,l,d-c,l,d):i==="rightBottom"?s.bezierCurveTo(l,d+c,h+a,u,h,u):i==="leftBottom"&&s.bezierCurveTo(h-a,u,t,d+c,t,d)}function sb(s,[t,e,r,n],i){if(!i||Array.isArray(i)&&i.every(o=>o===0))s.beginPath(),s.rect(t,e,r,n);else{typeof i=="number"&&(i=Array(8).fill(i));const[o,a,c,l,u,h,d,f]=i.map((g,y)=>y%2?Math.min(g,n/2):Math.min(g,r/2));s.beginPath(),s.moveTo(t,e+a),jo(s,t,e,o*2,a*2,"leftTop"),s.lineTo(t+r-c,e),jo(s,t+r-c*2,e,c*2,l*2,"rightTop"),s.lineTo(t+r,e+n-h),jo(s,t+r-u*2,e+n-h*2,u*2,h*2,"rightBottom"),s.lineTo(t+d,e+n),jo(s,t,e+n-f*2,d*2,f*2,"leftBottom"),s.closePath()}return s}Ze(Array);function by(s,t){if(!s)return{x:0,y:0,width:0,height:0,left:0,top:0,right:0,bottom:0};const[[e,r],[n,i]]=s,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]+i*t[2]+t[4],h=n*t[1]+i*t[3]+t[5],d=e*t[0]+i*t[2]+t[4],f=e*t[1]+i*t[3]+t[5],g=Math.min(o,c,u,d),y=Math.min(a,l,h,f),S=Math.max(o,c,u,d),b=Math.max(a,l,h,f);return{x:g,y,width:S-g,height:b-y,left:g,top:y,right:S,bottom:b}}Ze(Array);const Yr=Symbol("mesh");class co extends fc{constructor(t={}){super(t)}get borderSize(){const{paddingTop:t,paddingRight:e,paddingBottom:r,paddingLeft:n,borderWidth:i}=this.attributes,[o,a]=this.contentSize;return[n+o+e+i,t+a+r+i]}get clientSize(){const{paddingTop:t,paddingRight:e,paddingBottom:r,paddingLeft:n}=this.attributes,[i,o]=this.contentSize;return[n+i+e,t+o+r]}get contentSize(){let{width:t,height:e,boxSizing:r,paddingTop:n,paddingRight:i,paddingBottom:o,paddingLeft:a}=this.attributes;if(t=t||0,e=e||0,r==="border-box"){const c=2*this.attributes.borderWidth;t-=c+i+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[Yr];if(e)e.box!==t&&(e.contours=t.contours,e.box=t);else{e=new ft.Mesh2D(t),e.box=t;const n=this.attributes.bgcolor;if(Ia(e,{color:n}),this.hasBorder){const{borderColor:o,borderWidth:a,borderDash:c,borderDashOffset:l}=this.attributes;Ca(e,{color:o,lineWidth:a,lineDash:c,lineDashOffset:l})}this[Yr]=e;const i=this.attributes.clipPath;i&&this[Yr].setClipPath(i)}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:i}=this.attributes,[o,a]=this.contentSize,c=2*i;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,i=this.attributes.padding;return[t+i[0],e+i[1],r-i[0]-i[2],n-i[1]-i[3]]}getBoundingClientRect(){let t=this.renderMatrix;this.layer&&this.layer.layerTransformInvert&&(t=Nr(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 by(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[Yr]&&t==="clipPath"&&this[Yr].setClipPath(e),this[Yr]&&t==="bgcolor"&&Ia(this[Yr],{color:e}),this[Yr]&&(t==="borderColor"||t==="borderWidth"||t==="borderDash"||t==="borderDashOffset")){const{borderColor:n,borderWidth:i,borderDash:o,borderDashOffset:a}=this.attributes;Ca(this[Yr],{color:n,lineWidth:i,lineDash:i?o:0,lineDashOffset:a})}}updateContours(){const{anchorX:t,anchorY:e,borderWidth:r,borderRadius:n}=this.attributes,[i,o]=this.borderSize,a=this.offsetSize,c=.5*r,l=-t*a[0]+c,u=-e*a[1]+c;this.clientBox=new ft.Figure2D,sb(this.clientBox,[l,u,i,o],n)}}x(co,"Attr",gc);Gt.registerNode(co,"block");Ze(Array);let ob=class extends gc{};var Ey={exports:{}},zh={Text:"text",CDATA:"cdata",isTag:function(s){return s.type==="tag"||s.type==="script"||s.type==="style"}},xy={exports:{}},Ry={};(function(s){Object.defineProperty(s,"__esModule",{value:!0}),s.Doctype=s.CDATA=s.Tag=s.Style=s.Script=s.Comment=s.Directive=s.Text=s.Root=s.isTag=s.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=s.ElementType||(s.ElementType={}));function e(r){return r.type===t.Tag||r.type===t.Script||r.type===t.Style}s.isTag=e,s.Root=t.Root,s.Text=t.Text,s.Directive=t.Directive,s.Comment=t.Comment,s.Script=t.Script,s.Style=t.Style,s.Tag=t.Tag,s.CDATA=t.CDATA,s.Doctype=t.Doctype})(Ry);var ky={},an={};const ab="Á",cb="á",lb="Ă",ub="ă",hb="∾",db="∿",fb="∾̳",gb="Â",pb="â",mb="´",yb="А",vb="а",Mb="Æ",wb="æ",Sb="",Tb="𝔄",Ib="𝔞",Cb="À",bb="à",Eb="ℵ",xb="ℵ",Rb="Α",kb="α",Ab="Ā",Pb="ā",Db="⨿",Lb="&",Nb="&",Ob="⩕",zb="⩓",Bb="∧",jb="⩜",Fb="⩘",Ub="⩚",Wb="∠",Vb="⦤",$b="∠",Yb="⦨",Gb="⦩",Hb="⦪",Qb="⦫",qb="⦬",Zb="⦭",Kb="⦮",Xb="⦯",Jb="∡",_b="∟",eE="⊾",tE="⦝",rE="∢",nE="Å",iE="⍼",sE="Ą",oE="ą",aE="𝔸",cE="𝕒",lE="⩯",uE="≈",hE="⩰",dE="≊",fE="≋",gE="'",pE="",mE="≈",yE="≊",vE="Å",ME="å",wE="𝒜",SE="𝒶",TE="≔",IE="*",CE="≈",bE="≍",EE="Ã",xE="ã",RE="Ä",kE="ä",AE="∳",PE="⨑",DE="≌",LE="϶",NE="‵",OE="∽",zE="⋍",BE="∖",jE="⫧",FE="⊽",UE="⌅",WE="⌆",VE="⌅",$E="⎵",YE="⎶",GE="≌",HE="Б",QE="б",qE="„",ZE="∵",KE="∵",XE="∵",JE="⦰",_E="϶",e2="ℬ",t2="ℬ",r2="Β",n2="β",i2="ℶ",s2="≬",o2="𝔅",a2="𝔟",c2="⋂",l2="◯",u2="⋃",h2="⨀",d2="⨁",f2="⨂",g2="⨆",p2="★",m2="▽",y2="△",v2="⨄",M2="⋁",w2="⋀",S2="⤍",T2="⧫",I2="▪",C2="▴",b2="▾",E2="◂",x2="▸",R2="␣",k2="▒",A2="░",P2="▓",D2="█",L2="=⃥",N2="≡⃥",O2="⫭",z2="⌐",B2="𝔹",j2="𝕓",F2="⊥",U2="⊥",W2="⋈",V2="⧉",$2="┐",Y2="╕",G2="╖",H2="╗",Q2="┌",q2="╒",Z2="╓",K2="╔",X2="─",J2="═",_2="┬",ex="╤",tx="╥",rx="╦",nx="┴",ix="╧",sx="╨",ox="╩",ax="⊟",cx="⊞",lx="⊠",ux="┘",hx="╛",dx="╜",fx="╝",gx="└",px="╘",mx="╙",yx="╚",vx="│",Mx="║",wx="┼",Sx="╪",Tx="╫",Ix="╬",Cx="┤",bx="╡",Ex="╢",xx="╣",Rx="├",kx="╞",Ax="╟",Px="╠",Dx="‵",Lx="˘",Nx="˘",Ox="¦",zx="𝒷",Bx="ℬ",jx="⁏",Fx="∽",Ux="⋍",Wx="⧅",Vx="\\",$x="⟈",Yx="•",Gx="•",Hx="≎",Qx="⪮",qx="≏",Zx="≎",Kx="≏",Xx="Ć",Jx="ć",_x="⩄",eR="⩉",tR="⩋",rR="∩",nR="⋒",iR="⩇",sR="⩀",oR="ⅅ",aR="∩︀",cR="⁁",lR="ˇ",uR="ℭ",hR="⩍",dR="Č",fR="č",gR="Ç",pR="ç",mR="Ĉ",yR="ĉ",vR="∰",MR="⩌",wR="⩐",SR="Ċ",TR="ċ",IR="¸",CR="¸",bR="⦲",ER="¢",xR="·",RR="·",kR="𝔠",AR="ℭ",PR="Ч",DR="ч",LR="✓",NR="✓",OR="Χ",zR="χ",BR="ˆ",jR="≗",FR="↺",UR="↻",WR="⊛",VR="⊚",$R="⊝",YR="⊙",GR="®",HR="Ⓢ",QR="⊖",qR="⊕",ZR="⊗",KR="○",XR="⧃",JR="≗",_R="⨐",ek="⫯",tk="⧂",rk="∲",nk="”",ik="’",sk="♣",ok="♣",ak=":",ck="∷",lk="⩴",uk="≔",hk="≔",dk=",",fk="@",gk="∁",pk="∘",mk="∁",yk="ℂ",vk="≅",Mk="⩭",wk="≡",Sk="∮",Tk="∯",Ik="∮",Ck="𝕔",bk="ℂ",Ek="∐",xk="∐",Rk="©",kk="©",Ak="℗",Pk="∳",Dk="↵",Lk="✗",Nk="⨯",Ok="𝒞",zk="𝒸",Bk="⫏",jk="⫑",Fk="⫐",Uk="⫒",Wk="⋯",Vk="⤸",$k="⤵",Yk="⋞",Gk="⋟",Hk="↶",Qk="⤽",qk="⩈",Zk="⩆",Kk="≍",Xk="∪",Jk="⋓",_k="⩊",eA="⊍",tA="⩅",rA="∪︀",nA="↷",iA="⤼",sA="⋞",oA="⋟",aA="⋎",cA="⋏",lA="¤",uA="↶",hA="↷",dA="⋎",fA="⋏",gA="∲",pA="∱",mA="⌭",yA="†",vA="‡",MA="ℸ",wA="↓",SA="↡",TA="⇓",IA="‐",CA="⫤",bA="⊣",EA="⤏",xA="˝",RA="Ď",kA="ď",AA="Д",PA="д",DA="‡",LA="⇊",NA="ⅅ",OA="ⅆ",zA="⤑",BA="⩷",jA="°",FA="∇",UA="Δ",WA="δ",VA="⦱",$A="⥿",YA="𝔇",GA="𝔡",HA="⥥",QA="⇃",qA="⇂",ZA="´",KA="˙",XA="˝",JA="`",_A="˜",eP="⋄",tP="⋄",rP="⋄",nP="♦",iP="♦",sP="¨",oP="ⅆ",aP="ϝ",cP="⋲",lP="÷",uP="÷",hP="⋇",dP="⋇",fP="Ђ",gP="ђ",pP="⌞",mP="⌍",yP="$",vP="𝔻",MP="𝕕",wP="¨",SP="˙",TP="⃜",IP="≐",CP="≑",bP="≐",EP="∸",xP="∔",RP="⊡",kP="⌆",AP="∯",PP="¨",DP="⇓",LP="⇐",NP="⇔",OP="⫤",zP="⟸",BP="⟺",jP="⟹",FP="⇒",UP="⊨",WP="⇑",VP="⇕",$P="∥",YP="⤓",GP="↓",HP="↓",QP="⇓",qP="⇵",ZP="̑",KP="⇊",XP="⇃",JP="⇂",_P="⥐",eD="⥞",tD="⥖",rD="↽",nD="⥟",iD="⥗",sD="⇁",oD="↧",aD="⊤",cD="⤐",lD="⌟",uD="⌌",hD="𝒟",dD="𝒹",fD="Ѕ",gD="ѕ",pD="⧶",mD="Đ",yD="đ",vD="⋱",MD="▿",wD="▾",SD="⇵",TD="⥯",ID="⦦",CD="Џ",bD="џ",ED="⟿",xD="É",RD="é",kD="⩮",AD="Ě",PD="ě",DD="Ê",LD="ê",ND="≖",OD="≕",zD="Э",BD="э",jD="⩷",FD="Ė",UD="ė",WD="≑",VD="ⅇ",$D="≒",YD="𝔈",GD="𝔢",HD="⪚",QD="È",qD="è",ZD="⪖",KD="⪘",XD="⪙",JD="∈",_D="⏧",eL="ℓ",tL="⪕",rL="⪗",nL="Ē",iL="ē",sL="∅",oL="∅",aL="◻",cL="∅",lL="▫",uL=" ",hL=" ",dL=" ",fL="Ŋ",gL="ŋ",pL=" ",mL="Ę",yL="ę",vL="𝔼",ML="𝕖",wL="⋕",SL="⧣",TL="⩱",IL="ε",CL="Ε",bL="ε",EL="ϵ",xL="≖",RL="≕",kL="≂",AL="⪖",PL="⪕",DL="⩵",LL="=",NL="≂",OL="≟",zL="⇌",BL="≡",jL="⩸",FL="⧥",UL="⥱",WL="≓",VL="ℯ",$L="ℰ",YL="≐",GL="⩳",HL="≂",QL="Η",qL="η",ZL="Ð",KL="ð",XL="Ë",JL="ë",_L="€",eN="!",tN="∃",rN="∃",nN="ℰ",iN="ⅇ",sN="ⅇ",oN="≒",aN="Ф",cN="ф",lN="♀",uN="ffi",hN="ff",dN="ffl",fN="𝔉",gN="𝔣",pN="fi",mN="◼",yN="▪",vN="fj",MN="♭",wN="fl",SN="▱",TN="ƒ",IN="𝔽",CN="𝕗",bN="∀",EN="∀",xN="⋔",RN="⫙",kN="ℱ",AN="⨍",PN="½",DN="⅓",LN="¼",NN="⅕",ON="⅙",zN="⅛",BN="⅔",jN="⅖",FN="¾",UN="⅗",WN="⅜",VN="⅘",$N="⅚",YN="⅝",GN="⅞",HN="⁄",QN="⌢",qN="𝒻",ZN="ℱ",KN="ǵ",XN="Γ",JN="γ",_N="Ϝ",eO="ϝ",tO="⪆",rO="Ğ",nO="ğ",iO="Ģ",sO="Ĝ",oO="ĝ",aO="Г",cO="г",lO="Ġ",uO="ġ",hO="≥",dO="≧",fO="⪌",gO="⋛",pO="≥",mO="≧",yO="⩾",vO="⪩",MO="⩾",wO="⪀",SO="⪂",TO="⪄",IO="⋛︀",CO="⪔",bO="𝔊",EO="𝔤",xO="≫",RO="⋙",kO="⋙",AO="ℷ",PO="Ѓ",DO="ѓ",LO="⪥",NO="≷",OO="⪒",zO="⪤",BO="⪊",jO="⪊",FO="⪈",UO="≩",WO="⪈",VO="≩",$O="⋧",YO="𝔾",GO="𝕘",HO="`",QO="≥",qO="⋛",ZO="≧",KO="⪢",XO="≷",JO="⩾",_O="≳",ez="𝒢",tz="ℊ",rz="≳",nz="⪎",iz="⪐",sz="⪧",oz="⩺",az=">",cz=">",lz="≫",uz="⋗",hz="⦕",dz="⩼",fz="⪆",gz="⥸",pz="⋗",mz="⋛",yz="⪌",vz="≷",Mz="≳",wz="≩︀",Sz="≩︀",Tz="ˇ",Iz=" ",Cz="½",bz="ℋ",Ez="Ъ",xz="ъ",Rz="⥈",kz="↔",Az="⇔",Pz="↭",Dz="^",Lz="ℏ",Nz="Ĥ",Oz="ĥ",zz="♥",Bz="♥",jz="…",Fz="⊹",Uz="𝔥",Wz="ℌ",Vz="ℋ",$z="⤥",Yz="⤦",Gz="⇿",Hz="∻",Qz="↩",qz="↪",Zz="𝕙",Kz="ℍ",Xz="―",Jz="─",_z="𝒽",eB="ℋ",tB="ℏ",rB="Ħ",nB="ħ",iB="≎",sB="≏",oB="⁃",aB="‐",cB="Í",lB="í",uB="",hB="Î",dB="î",fB="И",gB="и",pB="İ",mB="Е",yB="е",vB="¡",MB="⇔",wB="𝔦",SB="ℑ",TB="Ì",IB="ì",CB="ⅈ",bB="⨌",EB="∭",xB="⧜",RB="℩",kB="IJ",AB="ij",PB="Ī",DB="ī",LB="ℑ",NB="ⅈ",OB="ℐ",zB="ℑ",BB="ı",jB="ℑ",FB="⊷",UB="Ƶ",WB="⇒",VB="℅",$B="∞",YB="⧝",GB="ı",HB="⊺",QB="∫",qB="∬",ZB="ℤ",KB="∫",XB="⊺",JB="⋂",_B="⨗",ej="⨼",tj="",rj="",nj="Ё",ij="ё",sj="Į",oj="į",aj="𝕀",cj="𝕚",lj="Ι",uj="ι",hj="⨼",dj="¿",fj="𝒾",gj="ℐ",pj="∈",mj="⋵",yj="⋹",vj="⋴",Mj="⋳",wj="∈",Sj="",Tj="Ĩ",Ij="ĩ",Cj="І",bj="і",Ej="Ï",xj="ï",Rj="Ĵ",kj="ĵ",Aj="Й",Pj="й",Dj="𝔍",Lj="𝔧",Nj="ȷ",Oj="𝕁",zj="𝕛",Bj="𝒥",jj="𝒿",Fj="Ј",Uj="ј",Wj="Є",Vj="є",$j="Κ",Yj="κ",Gj="ϰ",Hj="Ķ",Qj="ķ",qj="К",Zj="к",Kj="𝔎",Xj="𝔨",Jj="ĸ",_j="Х",e3="х",t3="Ќ",r3="ќ",n3="𝕂",i3="𝕜",s3="𝒦",o3="𝓀",a3="⇚",c3="Ĺ",l3="ĺ",u3="⦴",h3="ℒ",d3="Λ",f3="λ",g3="⟨",p3="⟪",m3="⦑",y3="⟨",v3="⪅",M3="ℒ",w3="«",S3="⇤",T3="⤟",I3="←",C3="↞",b3="⇐",E3="⤝",x3="↩",R3="↫",k3="⤹",A3="⥳",P3="↢",D3="⤙",L3="⤛",N3="⪫",O3="⪭",z3="⪭︀",B3="⤌",j3="⤎",F3="❲",U3="{",W3="[",V3="⦋",$3="⦏",Y3="⦍",G3="Ľ",H3="ľ",Q3="Ļ",q3="ļ",Z3="⌈",K3="{",X3="Л",J3="л",_3="⤶",e4="“",t4="„",r4="⥧",n4="⥋",i4="↲",s4="≤",o4="≦",a4="⟨",c4="⇤",l4="←",u4="←",h4="⇐",d4="⇆",f4="↢",g4="⌈",p4="⟦",m4="⥡",y4="⥙",v4="⇃",M4="⌊",w4="↽",S4="↼",T4="⇇",I4="↔",C4="↔",b4="⇔",E4="⇆",x4="⇋",R4="↭",k4="⥎",A4="↤",P4="⊣",D4="⥚",L4="⋋",N4="⧏",O4="⊲",z4="⊴",B4="⥑",j4="⥠",F4="⥘",U4="↿",W4="⥒",V4="↼",$4="⪋",Y4="⋚",G4="≤",H4="≦",Q4="⩽",q4="⪨",Z4="⩽",K4="⩿",X4="⪁",J4="⪃",_4="⋚︀",eF="⪓",tF="⪅",rF="⋖",nF="⋚",iF="⪋",sF="⋚",oF="≦",aF="≶",cF="≶",lF="⪡",uF="≲",hF="⩽",dF="≲",fF="⥼",gF="⌊",pF="𝔏",mF="𝔩",yF="≶",vF="⪑",MF="⥢",wF="↽",SF="↼",TF="⥪",IF="▄",CF="Љ",bF="љ",EF="⇇",xF="≪",RF="⋘",kF="⌞",AF="⇚",PF="⥫",DF="◺",LF="Ŀ",NF="ŀ",OF="⎰",zF="⎰",BF="⪉",jF="⪉",FF="⪇",UF="≨",WF="⪇",VF="≨",$F="⋦",YF="⟬",GF="⇽",HF="⟦",QF="⟵",qF="⟵",ZF="⟸",KF="⟷",XF="⟷",JF="⟺",_F="⟼",eU="⟶",tU="⟶",rU="⟹",nU="↫",iU="↬",sU="⦅",oU="𝕃",aU="𝕝",cU="⨭",lU="⨴",uU="∗",hU="_",dU="↙",fU="↘",gU="◊",pU="◊",mU="⧫",yU="(",vU="⦓",MU="⇆",wU="⌟",SU="⇋",TU="⥭",IU="",CU="⊿",bU="‹",EU="𝓁",xU="ℒ",RU="↰",kU="↰",AU="≲",PU="⪍",DU="⪏",LU="[",NU="‘",OU="‚",zU="Ł",BU="ł",jU="⪦",FU="⩹",UU="<",WU="<",VU="≪",$U="⋖",YU="⋋",GU="⋉",HU="⥶",QU="⩻",qU="◃",ZU="⊴",KU="◂",XU="⦖",JU="⥊",_U="⥦",e5="≨︀",t5="≨︀",r5="¯",n5="♂",i5="✠",s5="✠",o5="↦",a5="↦",c5="↧",l5="↤",u5="↥",h5="▮",d5="⨩",f5="М",g5="м",p5="—",m5="∺",y5="∡",v5=" ",M5="ℳ",w5="𝔐",S5="𝔪",T5="℧",I5="µ",C5="*",b5="⫰",E5="∣",x5="·",R5="⊟",k5="−",A5="∸",P5="⨪",D5="∓",L5="⫛",N5="…",O5="∓",z5="⊧",B5="𝕄",j5="𝕞",F5="∓",U5="𝓂",W5="ℳ",V5="∾",$5="Μ",Y5="μ",G5="⊸",H5="⊸",Q5="∇",q5="Ń",Z5="ń",K5="∠⃒",X5="≉",J5="⩰̸",_5="≋̸",eW="ʼn",tW="≉",rW="♮",nW="ℕ",iW="♮",sW=" ",oW="≎̸",aW="≏̸",cW="⩃",lW="Ň",uW="ň",hW="Ņ",dW="ņ",fW="≇",gW="⩭̸",pW="⩂",mW="Н",yW="н",vW="–",MW="⤤",wW="↗",SW="⇗",TW="↗",IW="≠",CW="≐̸",bW="",EW="",xW="",RW="",kW="≢",AW="⤨",PW="≂̸",DW="≫",LW="≪",NW=`
|
|
568
|
-
`,OW="∄",zW="∄",BW="𝔑",jW="𝔫",FW="≧̸",UW="≱",WW="≱",VW="≧̸",$W="⩾̸",YW="⩾̸",GW="⋙̸",HW="≵",QW="≫⃒",qW="≯",ZW="≯",KW="≫̸",XW="↮",JW="⇎",_W="⫲",eV="∋",tV="⋼",rV="⋺",nV="∋",iV="Њ",sV="њ",oV="↚",aV="⇍",cV="‥",lV="≦̸",uV="≰",hV="↚",dV="⇍",fV="↮",gV="⇎",pV="≰",mV="≦̸",yV="⩽̸",vV="⩽̸",MV="≮",wV="⋘̸",SV="≴",TV="≪⃒",IV="≮",CV="⋪",bV="⋬",EV="≪̸",xV="∤",RV="",kV=" ",AV="𝕟",PV="ℕ",DV="⫬",LV="¬",NV="≢",OV="≭",zV="∦",BV="∉",jV="≠",FV="≂̸",UV="∄",WV="≯",VV="≱",$V="≧̸",YV="≫̸",GV="≹",HV="⩾̸",QV="≵",qV="≎̸",ZV="≏̸",KV="∉",XV="⋵̸",JV="⋹̸",_V="∉",e$="⋷",t$="⋶",r$="⧏̸",n$="⋪",i$="⋬",s$="≮",o$="≰",a$="≸",c$="≪̸",l$="⩽̸",u$="≴",h$="⪢̸",d$="⪡̸",f$="∌",g$="∌",p$="⋾",m$="⋽",y$="⊀",v$="⪯̸",M$="⋠",w$="∌",S$="⧐̸",T$="⋫",I$="⋭",C$="⊏̸",b$="⋢",E$="⊐̸",x$="⋣",R$="⊂⃒",k$="⊈",A$="⊁",P$="⪰̸",D$="⋡",L$="≿̸",N$="⊃⃒",O$="⊉",z$="≁",B$="≄",j$="≇",F$="≉",U$="∤",W$="∦",V$="∦",$$="⫽⃥",Y$="∂̸",G$="⨔",H$="⊀",Q$="⋠",q$="⊀",Z$="⪯̸",K$="⪯̸",X$="⤳̸",J$="↛",_$="⇏",eY="↝̸",tY="↛",rY="⇏",nY="⋫",iY="⋭",sY="⊁",oY="⋡",aY="⪰̸",cY="𝒩",lY="𝓃",uY="∤",hY="∦",dY="≁",fY="≄",gY="≄",pY="∤",mY="∦",yY="⋢",vY="⋣",MY="⊄",wY="⫅̸",SY="⊈",TY="⊂⃒",IY="⊈",CY="⫅̸",bY="⊁",EY="⪰̸",xY="⊅",RY="⫆̸",kY="⊉",AY="⊃⃒",PY="⊉",DY="⫆̸",LY="≹",NY="Ñ",OY="ñ",zY="≸",BY="⋪",jY="⋬",FY="⋫",UY="⋭",WY="Ν",VY="ν",$Y="#",YY="№",GY=" ",HY="≍⃒",QY="⊬",qY="⊭",ZY="⊮",KY="⊯",XY="≥⃒",JY=">⃒",_Y="⤄",eG="⧞",tG="⤂",rG="≤⃒",nG="<⃒",iG="⊴⃒",sG="⤃",oG="⊵⃒",aG="∼⃒",cG="⤣",lG="↖",uG="⇖",hG="↖",dG="⤧",fG="Ó",gG="ó",pG="⊛",mG="Ô",yG="ô",vG="⊚",MG="О",wG="о",SG="⊝",TG="Ő",IG="ő",CG="⨸",bG="⊙",EG="⦼",xG="Œ",RG="œ",kG="⦿",AG="𝔒",PG="𝔬",DG="˛",LG="Ò",NG="ò",OG="⧁",zG="⦵",BG="Ω",jG="∮",FG="↺",UG="⦾",WG="⦻",VG="‾",$G="⧀",YG="Ō",GG="ō",HG="Ω",QG="ω",qG="Ο",ZG="ο",KG="⦶",XG="⊖",JG="𝕆",_G="𝕠",e8="⦷",t8="“",r8="‘",n8="⦹",i8="⊕",s8="↻",o8="⩔",a8="∨",c8="⩝",l8="ℴ",u8="ℴ",h8="ª",d8="º",f8="⊶",g8="⩖",p8="⩗",m8="⩛",y8="Ⓢ",v8="𝒪",M8="ℴ",w8="Ø",S8="ø",T8="⊘",I8="Õ",C8="õ",b8="⨶",E8="⨷",x8="⊗",R8="Ö",k8="ö",A8="⌽",P8="‾",D8="⏞",L8="⎴",N8="⏜",O8="¶",z8="∥",B8="∥",j8="⫳",F8="⫽",U8="∂",W8="∂",V8="П",$8="п",Y8="%",G8=".",H8="‰",Q8="⊥",q8="‱",Z8="𝔓",K8="𝔭",X8="Φ",J8="φ",_8="ϕ",e6="ℳ",t6="☎",r6="Π",n6="π",i6="⋔",s6="ϖ",o6="ℏ",a6="ℎ",c6="ℏ",l6="⨣",u6="⊞",h6="⨢",d6="+",f6="∔",g6="⨥",p6="⩲",m6="±",y6="±",v6="⨦",M6="⨧",w6="±",S6="ℌ",T6="⨕",I6="𝕡",C6="ℙ",b6="£",E6="⪷",x6="⪻",R6="≺",k6="≼",A6="⪷",P6="≺",D6="≼",L6="≺",N6="⪯",O6="≼",z6="≾",B6="⪯",j6="⪹",F6="⪵",U6="⋨",W6="⪯",V6="⪳",$6="≾",Y6="′",G6="″",H6="ℙ",Q6="⪹",q6="⪵",Z6="⋨",K6="∏",X6="∏",J6="⌮",_6="⌒",e9="⌓",t9="∝",r9="∝",n9="∷",i9="∝",s9="≾",o9="⊰",a9="𝒫",c9="𝓅",l9="Ψ",u9="ψ",h9=" ",d9="𝔔",f9="𝔮",g9="⨌",p9="𝕢",m9="ℚ",y9="⁗",v9="𝒬",M9="𝓆",w9="ℍ",S9="⨖",T9="?",I9="≟",C9='"',b9='"',E9="⇛",x9="∽̱",R9="Ŕ",k9="ŕ",A9="√",P9="⦳",D9="⟩",L9="⟫",N9="⦒",O9="⦥",z9="⟩",B9="»",j9="⥵",F9="⇥",U9="⤠",W9="⤳",V9="→",$9="↠",Y9="⇒",G9="⤞",H9="↪",Q9="↬",q9="⥅",Z9="⥴",K9="⤖",X9="↣",J9="↝",_9="⤚",eH="⤜",tH="∶",rH="ℚ",nH="⤍",iH="⤏",sH="⤐",oH="❳",aH="}",cH="]",lH="⦌",uH="⦎",hH="⦐",dH="Ř",fH="ř",gH="Ŗ",pH="ŗ",mH="⌉",yH="}",vH="Р",MH="р",wH="⤷",SH="⥩",TH="”",IH="”",CH="↳",bH="ℜ",EH="ℛ",xH="ℜ",RH="ℝ",kH="ℜ",AH="▭",PH="®",DH="®",LH="∋",NH="⇋",OH="⥯",zH="⥽",BH="⌋",jH="𝔯",FH="ℜ",UH="⥤",WH="⇁",VH="⇀",$H="⥬",YH="Ρ",GH="ρ",HH="ϱ",QH="⟩",qH="⇥",ZH="→",KH="→",XH="⇒",JH="⇄",_H="↣",e7="⌉",t7="⟧",r7="⥝",n7="⥕",i7="⇂",s7="⌋",o7="⇁",a7="⇀",c7="⇄",l7="⇌",u7="⇉",h7="↝",d7="↦",f7="⊢",g7="⥛",p7="⋌",m7="⧐",y7="⊳",v7="⊵",M7="⥏",w7="⥜",S7="⥔",T7="↾",I7="⥓",C7="⇀",b7="˚",E7="≓",x7="⇄",R7="⇌",k7="",A7="⎱",P7="⎱",D7="⫮",L7="⟭",N7="⇾",O7="⟧",z7="⦆",B7="𝕣",j7="ℝ",F7="⨮",U7="⨵",W7="⥰",V7=")",$7="⦔",Y7="⨒",G7="⇉",H7="⇛",Q7="›",q7="𝓇",Z7="ℛ",K7="↱",X7="↱",J7="]",_7="’",eQ="’",tQ="⋌",rQ="⋊",nQ="▹",iQ="⊵",sQ="▸",oQ="⧎",aQ="⧴",cQ="⥨",lQ="℞",uQ="Ś",hQ="ś",dQ="‚",fQ="⪸",gQ="Š",pQ="š",mQ="⪼",yQ="≻",vQ="≽",MQ="⪰",wQ="⪴",SQ="Ş",TQ="ş",IQ="Ŝ",CQ="ŝ",bQ="⪺",EQ="⪶",xQ="⋩",RQ="⨓",kQ="≿",AQ="С",PQ="с",DQ="⊡",LQ="⋅",NQ="⩦",OQ="⤥",zQ="↘",BQ="⇘",jQ="↘",FQ="§",UQ=";",WQ="⤩",VQ="∖",$Q="∖",YQ="✶",GQ="𝔖",HQ="𝔰",QQ="⌢",qQ="♯",ZQ="Щ",KQ="щ",XQ="Ш",JQ="ш",_Q="↓",eq="←",tq="∣",rq="∥",nq="→",iq="↑",sq="",oq="Σ",aq="σ",cq="ς",lq="ς",uq="∼",hq="⩪",dq="≃",fq="≃",gq="⪞",pq="⪠",mq="⪝",yq="⪟",vq="≆",Mq="⨤",wq="⥲",Sq="←",Tq="∘",Iq="∖",Cq="⨳",bq="⧤",Eq="∣",xq="⌣",Rq="⪪",kq="⪬",Aq="⪬︀",Pq="Ь",Dq="ь",Lq="⌿",Nq="⧄",Oq="/",zq="𝕊",Bq="𝕤",jq="♠",Fq="♠",Uq="∥",Wq="⊓",Vq="⊓︀",$q="⊔",Yq="⊔︀",Gq="√",Hq="⊏",Qq="⊑",qq="⊏",Zq="⊑",Kq="⊐",Xq="⊒",Jq="⊐",_q="⊒",eZ="□",tZ="□",rZ="⊓",nZ="⊏",iZ="⊑",sZ="⊐",oZ="⊒",aZ="⊔",cZ="▪",lZ="□",uZ="▪",hZ="→",dZ="𝒮",fZ="𝓈",gZ="∖",pZ="⌣",mZ="⋆",yZ="⋆",vZ="☆",MZ="★",wZ="ϵ",SZ="ϕ",TZ="¯",IZ="⊂",CZ="⋐",bZ="⪽",EZ="⫅",xZ="⊆",RZ="⫃",kZ="⫁",AZ="⫋",PZ="⊊",DZ="⪿",LZ="⥹",NZ="⊂",OZ="⋐",zZ="⊆",BZ="⫅",jZ="⊆",FZ="⊊",UZ="⫋",WZ="⫇",VZ="⫕",$Z="⫓",YZ="⪸",GZ="≻",HZ="≽",QZ="≻",qZ="⪰",ZZ="≽",KZ="≿",XZ="⪰",JZ="⪺",_Z="⪶",eK="⋩",tK="≿",rK="∋",nK="∑",iK="∑",sK="♪",oK="¹",aK="²",cK="³",lK="⊃",uK="⋑",hK="⪾",dK="⫘",fK="⫆",gK="⊇",pK="⫄",mK="⊃",yK="⊇",vK="⟉",MK="⫗",wK="⥻",SK="⫂",TK="⫌",IK="⊋",CK="⫀",bK="⊃",EK="⋑",xK="⊇",RK="⫆",kK="⊋",AK="⫌",PK="⫈",DK="⫔",LK="⫖",NK="⤦",OK="↙",zK="⇙",BK="↙",jK="⤪",FK="ß",UK=" ",WK="⌖",VK="Τ",$K="τ",YK="⎴",GK="Ť",HK="ť",QK="Ţ",qK="ţ",ZK="Т",KK="т",XK="⃛",JK="⌕",_K="𝔗",eX="𝔱",tX="∴",rX="∴",nX="∴",iX="Θ",sX="θ",oX="ϑ",aX="ϑ",cX="≈",lX="∼",uX=" ",hX=" ",dX=" ",fX="≈",gX="∼",pX="Þ",mX="þ",yX="˜",vX="∼",MX="≃",wX="≅",SX="≈",TX="⨱",IX="⊠",CX="×",bX="⨰",EX="∭",xX="⤨",RX="⌶",kX="⫱",AX="⊤",PX="𝕋",DX="𝕥",LX="⫚",NX="⤩",OX="‴",zX="™",BX="™",jX="▵",FX="▿",UX="◃",WX="⊴",VX="≜",$X="▹",YX="⊵",GX="◬",HX="≜",QX="⨺",qX="⃛",ZX="⨹",KX="⧍",XX="⨻",JX="⏢",_X="𝒯",eJ="𝓉",tJ="Ц",rJ="ц",nJ="Ћ",iJ="ћ",sJ="Ŧ",oJ="ŧ",aJ="≬",cJ="↞",lJ="↠",uJ="Ú",hJ="ú",dJ="↑",fJ="↟",gJ="⇑",pJ="⥉",mJ="Ў",yJ="ў",vJ="Ŭ",MJ="ŭ",wJ="Û",SJ="û",TJ="У",IJ="у",CJ="⇅",bJ="Ű",EJ="ű",xJ="⥮",RJ="⥾",kJ="𝔘",AJ="𝔲",PJ="Ù",DJ="ù",LJ="⥣",NJ="↿",OJ="↾",zJ="▀",BJ="⌜",jJ="⌜",FJ="⌏",UJ="◸",WJ="Ū",VJ="ū",$J="¨",YJ="_",GJ="⏟",HJ="⎵",QJ="⏝",qJ="⋃",ZJ="⊎",KJ="Ų",XJ="ų",JJ="𝕌",_J="𝕦",e_="⤒",t_="↑",r_="↑",n_="⇑",i_="⇅",s_="↕",o_="↕",a_="⇕",c_="⥮",l_="↿",u_="↾",h_="⊎",d_="↖",f_="↗",g_="υ",p_="ϒ",m_="ϒ",y_="Υ",v_="υ",M_="↥",w_="⊥",S_="⇈",T_="⌝",I_="⌝",C_="⌎",b_="Ů",E_="ů",x_="◹",R_="𝒰",k_="𝓊",A_="⋰",P_="Ũ",D_="ũ",L_="▵",N_="▴",O_="⇈",z_="Ü",B_="ü",j_="⦧",F_="⦜",U_="ϵ",W_="ϰ",V_="∅",$_="ϕ",Y_="ϖ",G_="∝",H_="↕",Q_="⇕",q_="ϱ",Z_="ς",K_="⊊︀",X_="⫋︀",J_="⊋︀",__="⫌︀",eee="ϑ",tee="⊲",ree="⊳",nee="⫨",iee="⫫",see="⫩",oee="В",aee="в",cee="⊢",lee="⊨",uee="⊩",hee="⊫",dee="⫦",fee="⊻",gee="∨",pee="⋁",mee="≚",yee="⋮",vee="|",Mee="‖",wee="|",See="‖",Tee="∣",Iee="|",Cee="❘",bee="≀",Eee=" ",xee="𝔙",Ree="𝔳",kee="⊲",Aee="⊂⃒",Pee="⊃⃒",Dee="𝕍",Lee="𝕧",Nee="∝",Oee="⊳",zee="𝒱",Bee="𝓋",jee="⫋︀",Fee="⊊︀",Uee="⫌︀",Wee="⊋︀",Vee="⊪",$ee="⦚",Yee="Ŵ",Gee="ŵ",Hee="⩟",Qee="∧",qee="⋀",Zee="≙",Kee="℘",Xee="𝔚",Jee="𝔴",_ee="𝕎",ete="𝕨",tte="℘",rte="≀",nte="≀",ite="𝒲",ste="𝓌",ote="⋂",ate="◯",cte="⋃",lte="▽",ute="𝔛",hte="𝔵",dte="⟷",fte="⟺",gte="Ξ",pte="ξ",mte="⟵",yte="⟸",vte="⟼",Mte="⋻",wte="⨀",Ste="𝕏",Tte="𝕩",Ite="⨁",Cte="⨂",bte="⟶",Ete="⟹",xte="𝒳",Rte="𝓍",kte="⨆",Ate="⨄",Pte="△",Dte="⋁",Lte="⋀",Nte="Ý",Ote="ý",zte="Я",Bte="я",jte="Ŷ",Fte="ŷ",Ute="Ы",Wte="ы",Vte="¥",$te="𝔜",Yte="𝔶",Gte="Ї",Hte="ї",Qte="𝕐",qte="𝕪",Zte="𝒴",Kte="𝓎",Xte="Ю",Jte="ю",_te="ÿ",ere="Ÿ",tre="Ź",rre="ź",nre="Ž",ire="ž",sre="З",ore="з",are="Ż",cre="ż",lre="ℨ",ure="",hre="Ζ",dre="ζ",fre="𝔷",gre="ℨ",pre="Ж",mre="ж",yre="⇝",vre="𝕫",Mre="ℤ",wre="𝒵",Sre="𝓏",Tre="",Ire="",Ay={Aacute:ab,aacute:cb,Abreve:lb,abreve:ub,ac:hb,acd:db,acE:fb,Acirc:gb,acirc:pb,acute:mb,Acy:yb,acy:vb,AElig:Mb,aelig:wb,af:Sb,Afr:Tb,afr:Ib,Agrave:Cb,agrave:bb,alefsym:Eb,aleph:xb,Alpha:Rb,alpha:kb,Amacr:Ab,amacr:Pb,amalg:Db,amp:Lb,AMP:Nb,andand:Ob,And:zb,and:Bb,andd:jb,andslope:Fb,andv:Ub,ang:Wb,ange:Vb,angle:$b,angmsdaa:Yb,angmsdab:Gb,angmsdac:Hb,angmsdad:Qb,angmsdae:qb,angmsdaf:Zb,angmsdag:Kb,angmsdah:Xb,angmsd:Jb,angrt:_b,angrtvb:eE,angrtvbd:tE,angsph:rE,angst:nE,angzarr:iE,Aogon:sE,aogon:oE,Aopf:aE,aopf:cE,apacir:lE,ap:uE,apE:hE,ape:dE,apid:fE,apos:gE,ApplyFunction:pE,approx:mE,approxeq:yE,Aring:vE,aring:ME,Ascr:wE,ascr:SE,Assign:TE,ast:IE,asymp:CE,asympeq:bE,Atilde:EE,atilde:xE,Auml:RE,auml:kE,awconint:AE,awint:PE,backcong:DE,backepsilon:LE,backprime:NE,backsim:OE,backsimeq:zE,Backslash:BE,Barv:jE,barvee:FE,barwed:UE,Barwed:WE,barwedge:VE,bbrk:$E,bbrktbrk:YE,bcong:GE,Bcy:HE,bcy:QE,bdquo:qE,becaus:ZE,because:KE,Because:XE,bemptyv:JE,bepsi:_E,bernou:e2,Bernoullis:t2,Beta:r2,beta:n2,beth:i2,between:s2,Bfr:o2,bfr:a2,bigcap:c2,bigcirc:l2,bigcup:u2,bigodot:h2,bigoplus:d2,bigotimes:f2,bigsqcup:g2,bigstar:p2,bigtriangledown:m2,bigtriangleup:y2,biguplus:v2,bigvee:M2,bigwedge:w2,bkarow:S2,blacklozenge:T2,blacksquare:I2,blacktriangle:C2,blacktriangledown:b2,blacktriangleleft:E2,blacktriangleright:x2,blank:R2,blk12:k2,blk14:A2,blk34:P2,block:D2,bne:L2,bnequiv:N2,bNot:O2,bnot:z2,Bopf:B2,bopf:j2,bot:F2,bottom:U2,bowtie:W2,boxbox:V2,boxdl:$2,boxdL:Y2,boxDl:G2,boxDL:H2,boxdr:Q2,boxdR:q2,boxDr:Z2,boxDR:K2,boxh:X2,boxH:J2,boxhd:_2,boxHd:ex,boxhD:tx,boxHD:rx,boxhu:nx,boxHu:ix,boxhU:sx,boxHU:ox,boxminus:ax,boxplus:cx,boxtimes:lx,boxul:ux,boxuL:hx,boxUl:dx,boxUL:fx,boxur:gx,boxuR:px,boxUr:mx,boxUR:yx,boxv:vx,boxV:Mx,boxvh:wx,boxvH:Sx,boxVh:Tx,boxVH:Ix,boxvl:Cx,boxvL:bx,boxVl:Ex,boxVL:xx,boxvr:Rx,boxvR:kx,boxVr:Ax,boxVR:Px,bprime:Dx,breve:Lx,Breve:Nx,brvbar:Ox,bscr:zx,Bscr:Bx,bsemi:jx,bsim:Fx,bsime:Ux,bsolb:Wx,bsol:Vx,bsolhsub:$x,bull:Yx,bullet:Gx,bump:Hx,bumpE:Qx,bumpe:qx,Bumpeq:Zx,bumpeq:Kx,Cacute:Xx,cacute:Jx,capand:_x,capbrcup:eR,capcap:tR,cap:rR,Cap:nR,capcup:iR,capdot:sR,CapitalDifferentialD:oR,caps:aR,caret:cR,caron:lR,Cayleys:uR,ccaps:hR,Ccaron:dR,ccaron:fR,Ccedil:gR,ccedil:pR,Ccirc:mR,ccirc:yR,Cconint:vR,ccups:MR,ccupssm:wR,Cdot:SR,cdot:TR,cedil:IR,Cedilla:CR,cemptyv:bR,cent:ER,centerdot:xR,CenterDot:RR,cfr:kR,Cfr:AR,CHcy:PR,chcy:DR,check:LR,checkmark:NR,Chi:OR,chi:zR,circ:BR,circeq:jR,circlearrowleft:FR,circlearrowright:UR,circledast:WR,circledcirc:VR,circleddash:$R,CircleDot:YR,circledR:GR,circledS:HR,CircleMinus:QR,CirclePlus:qR,CircleTimes:ZR,cir:KR,cirE:XR,cire:JR,cirfnint:_R,cirmid:ek,cirscir:tk,ClockwiseContourIntegral:rk,CloseCurlyDoubleQuote:nk,CloseCurlyQuote:ik,clubs:sk,clubsuit:ok,colon:ak,Colon:ck,Colone:lk,colone:uk,coloneq:hk,comma:dk,commat:fk,comp:gk,compfn:pk,complement:mk,complexes:yk,cong:vk,congdot:Mk,Congruent:wk,conint:Sk,Conint:Tk,ContourIntegral:Ik,copf:Ck,Copf:bk,coprod:Ek,Coproduct:xk,copy:Rk,COPY:kk,copysr:Ak,CounterClockwiseContourIntegral:Pk,crarr:Dk,cross:Lk,Cross:Nk,Cscr:Ok,cscr:zk,csub:Bk,csube:jk,csup:Fk,csupe:Uk,ctdot:Wk,cudarrl:Vk,cudarrr:$k,cuepr:Yk,cuesc:Gk,cularr:Hk,cularrp:Qk,cupbrcap:qk,cupcap:Zk,CupCap:Kk,cup:Xk,Cup:Jk,cupcup:_k,cupdot:eA,cupor:tA,cups:rA,curarr:nA,curarrm:iA,curlyeqprec:sA,curlyeqsucc:oA,curlyvee:aA,curlywedge:cA,curren:lA,curvearrowleft:uA,curvearrowright:hA,cuvee:dA,cuwed:fA,cwconint:gA,cwint:pA,cylcty:mA,dagger:yA,Dagger:vA,daleth:MA,darr:wA,Darr:SA,dArr:TA,dash:IA,Dashv:CA,dashv:bA,dbkarow:EA,dblac:xA,Dcaron:RA,dcaron:kA,Dcy:AA,dcy:PA,ddagger:DA,ddarr:LA,DD:NA,dd:OA,DDotrahd:zA,ddotseq:BA,deg:jA,Del:FA,Delta:UA,delta:WA,demptyv:VA,dfisht:$A,Dfr:YA,dfr:GA,dHar:HA,dharl:QA,dharr:qA,DiacriticalAcute:ZA,DiacriticalDot:KA,DiacriticalDoubleAcute:XA,DiacriticalGrave:JA,DiacriticalTilde:_A,diam:eP,diamond:tP,Diamond:rP,diamondsuit:nP,diams:iP,die:sP,DifferentialD:oP,digamma:aP,disin:cP,div:lP,divide:uP,divideontimes:hP,divonx:dP,DJcy:fP,djcy:gP,dlcorn:pP,dlcrop:mP,dollar:yP,Dopf:vP,dopf:MP,Dot:wP,dot:SP,DotDot:TP,doteq:IP,doteqdot:CP,DotEqual:bP,dotminus:EP,dotplus:xP,dotsquare:RP,doublebarwedge:kP,DoubleContourIntegral:AP,DoubleDot:PP,DoubleDownArrow:DP,DoubleLeftArrow:LP,DoubleLeftRightArrow:NP,DoubleLeftTee:OP,DoubleLongLeftArrow:zP,DoubleLongLeftRightArrow:BP,DoubleLongRightArrow:jP,DoubleRightArrow:FP,DoubleRightTee:UP,DoubleUpArrow:WP,DoubleUpDownArrow:VP,DoubleVerticalBar:$P,DownArrowBar:YP,downarrow:GP,DownArrow:HP,Downarrow:QP,DownArrowUpArrow:qP,DownBreve:ZP,downdownarrows:KP,downharpoonleft:XP,downharpoonright:JP,DownLeftRightVector:_P,DownLeftTeeVector:eD,DownLeftVectorBar:tD,DownLeftVector:rD,DownRightTeeVector:nD,DownRightVectorBar:iD,DownRightVector:sD,DownTeeArrow:oD,DownTee:aD,drbkarow:cD,drcorn:lD,drcrop:uD,Dscr:hD,dscr:dD,DScy:fD,dscy:gD,dsol:pD,Dstrok:mD,dstrok:yD,dtdot:vD,dtri:MD,dtrif:wD,duarr:SD,duhar:TD,dwangle:ID,DZcy:CD,dzcy:bD,dzigrarr:ED,Eacute:xD,eacute:RD,easter:kD,Ecaron:AD,ecaron:PD,Ecirc:DD,ecirc:LD,ecir:ND,ecolon:OD,Ecy:zD,ecy:BD,eDDot:jD,Edot:FD,edot:UD,eDot:WD,ee:VD,efDot:$D,Efr:YD,efr:GD,eg:HD,Egrave:QD,egrave:qD,egs:ZD,egsdot:KD,el:XD,Element:JD,elinters:_D,ell:eL,els:tL,elsdot:rL,Emacr:nL,emacr:iL,empty:sL,emptyset:oL,EmptySmallSquare:aL,emptyv:cL,EmptyVerySmallSquare:lL,emsp13:uL,emsp14:hL,emsp:dL,ENG:fL,eng:gL,ensp:pL,Eogon:mL,eogon:yL,Eopf:vL,eopf:ML,epar:wL,eparsl:SL,eplus:TL,epsi:IL,Epsilon:CL,epsilon:bL,epsiv:EL,eqcirc:xL,eqcolon:RL,eqsim:kL,eqslantgtr:AL,eqslantless:PL,Equal:DL,equals:LL,EqualTilde:NL,equest:OL,Equilibrium:zL,equiv:BL,equivDD:jL,eqvparsl:FL,erarr:UL,erDot:WL,escr:VL,Escr:$L,esdot:YL,Esim:GL,esim:HL,Eta:QL,eta:qL,ETH:ZL,eth:KL,Euml:XL,euml:JL,euro:_L,excl:eN,exist:tN,Exists:rN,expectation:nN,exponentiale:iN,ExponentialE:sN,fallingdotseq:oN,Fcy:aN,fcy:cN,female:lN,ffilig:uN,fflig:hN,ffllig:dN,Ffr:fN,ffr:gN,filig:pN,FilledSmallSquare:mN,FilledVerySmallSquare:yN,fjlig:vN,flat:MN,fllig:wN,fltns:SN,fnof:TN,Fopf:IN,fopf:CN,forall:bN,ForAll:EN,fork:xN,forkv:RN,Fouriertrf:kN,fpartint:AN,frac12:PN,frac13:DN,frac14:LN,frac15:NN,frac16:ON,frac18:zN,frac23:BN,frac25:jN,frac34:FN,frac35:UN,frac38:WN,frac45:VN,frac56:$N,frac58:YN,frac78:GN,frasl:HN,frown:QN,fscr:qN,Fscr:ZN,gacute:KN,Gamma:XN,gamma:JN,Gammad:_N,gammad:eO,gap:tO,Gbreve:rO,gbreve:nO,Gcedil:iO,Gcirc:sO,gcirc:oO,Gcy:aO,gcy:cO,Gdot:lO,gdot:uO,ge:hO,gE:dO,gEl:fO,gel:gO,geq:pO,geqq:mO,geqslant:yO,gescc:vO,ges:MO,gesdot:wO,gesdoto:SO,gesdotol:TO,gesl:IO,gesles:CO,Gfr:bO,gfr:EO,gg:xO,Gg:RO,ggg:kO,gimel:AO,GJcy:PO,gjcy:DO,gla:LO,gl:NO,glE:OO,glj:zO,gnap:BO,gnapprox:jO,gne:FO,gnE:UO,gneq:WO,gneqq:VO,gnsim:$O,Gopf:YO,gopf:GO,grave:HO,GreaterEqual:QO,GreaterEqualLess:qO,GreaterFullEqual:ZO,GreaterGreater:KO,GreaterLess:XO,GreaterSlantEqual:JO,GreaterTilde:_O,Gscr:ez,gscr:tz,gsim:rz,gsime:nz,gsiml:iz,gtcc:sz,gtcir:oz,gt:az,GT:cz,Gt:lz,gtdot:uz,gtlPar:hz,gtquest:dz,gtrapprox:fz,gtrarr:gz,gtrdot:pz,gtreqless:mz,gtreqqless:yz,gtrless:vz,gtrsim:Mz,gvertneqq:wz,gvnE:Sz,Hacek:Tz,hairsp:Iz,half:Cz,hamilt:bz,HARDcy:Ez,hardcy:xz,harrcir:Rz,harr:kz,hArr:Az,harrw:Pz,Hat:Dz,hbar:Lz,Hcirc:Nz,hcirc:Oz,hearts:zz,heartsuit:Bz,hellip:jz,hercon:Fz,hfr:Uz,Hfr:Wz,HilbertSpace:Vz,hksearow:$z,hkswarow:Yz,hoarr:Gz,homtht:Hz,hookleftarrow:Qz,hookrightarrow:qz,hopf:Zz,Hopf:Kz,horbar:Xz,HorizontalLine:Jz,hscr:_z,Hscr:eB,hslash:tB,Hstrok:rB,hstrok:nB,HumpDownHump:iB,HumpEqual:sB,hybull:oB,hyphen:aB,Iacute:cB,iacute:lB,ic:uB,Icirc:hB,icirc:dB,Icy:fB,icy:gB,Idot:pB,IEcy:mB,iecy:yB,iexcl:vB,iff:MB,ifr:wB,Ifr:SB,Igrave:TB,igrave:IB,ii:CB,iiiint:bB,iiint:EB,iinfin:xB,iiota:RB,IJlig:kB,ijlig:AB,Imacr:PB,imacr:DB,image:LB,ImaginaryI:NB,imagline:OB,imagpart:zB,imath:BB,Im:jB,imof:FB,imped:UB,Implies:WB,incare:VB,in:"∈",infin:$B,infintie:YB,inodot:GB,intcal:HB,int:QB,Int:qB,integers:ZB,Integral:KB,intercal:XB,Intersection:JB,intlarhk:_B,intprod:ej,InvisibleComma:tj,InvisibleTimes:rj,IOcy:nj,iocy:ij,Iogon:sj,iogon:oj,Iopf:aj,iopf:cj,Iota:lj,iota:uj,iprod:hj,iquest:dj,iscr:fj,Iscr:gj,isin:pj,isindot:mj,isinE:yj,isins:vj,isinsv:Mj,isinv:wj,it:Sj,Itilde:Tj,itilde:Ij,Iukcy:Cj,iukcy:bj,Iuml:Ej,iuml:xj,Jcirc:Rj,jcirc:kj,Jcy:Aj,jcy:Pj,Jfr:Dj,jfr:Lj,jmath:Nj,Jopf:Oj,jopf:zj,Jscr:Bj,jscr:jj,Jsercy:Fj,jsercy:Uj,Jukcy:Wj,jukcy:Vj,Kappa:$j,kappa:Yj,kappav:Gj,Kcedil:Hj,kcedil:Qj,Kcy:qj,kcy:Zj,Kfr:Kj,kfr:Xj,kgreen:Jj,KHcy:_j,khcy:e3,KJcy:t3,kjcy:r3,Kopf:n3,kopf:i3,Kscr:s3,kscr:o3,lAarr:a3,Lacute:c3,lacute:l3,laemptyv:u3,lagran:h3,Lambda:d3,lambda:f3,lang:g3,Lang:p3,langd:m3,langle:y3,lap:v3,Laplacetrf:M3,laquo:w3,larrb:S3,larrbfs:T3,larr:I3,Larr:C3,lArr:b3,larrfs:E3,larrhk:x3,larrlp:R3,larrpl:k3,larrsim:A3,larrtl:P3,latail:D3,lAtail:L3,lat:N3,late:O3,lates:z3,lbarr:B3,lBarr:j3,lbbrk:F3,lbrace:U3,lbrack:W3,lbrke:V3,lbrksld:$3,lbrkslu:Y3,Lcaron:G3,lcaron:H3,Lcedil:Q3,lcedil:q3,lceil:Z3,lcub:K3,Lcy:X3,lcy:J3,ldca:_3,ldquo:e4,ldquor:t4,ldrdhar:r4,ldrushar:n4,ldsh:i4,le:s4,lE:o4,LeftAngleBracket:a4,LeftArrowBar:c4,leftarrow:l4,LeftArrow:u4,Leftarrow:h4,LeftArrowRightArrow:d4,leftarrowtail:f4,LeftCeiling:g4,LeftDoubleBracket:p4,LeftDownTeeVector:m4,LeftDownVectorBar:y4,LeftDownVector:v4,LeftFloor:M4,leftharpoondown:w4,leftharpoonup:S4,leftleftarrows:T4,leftrightarrow:I4,LeftRightArrow:C4,Leftrightarrow:b4,leftrightarrows:E4,leftrightharpoons:x4,leftrightsquigarrow:R4,LeftRightVector:k4,LeftTeeArrow:A4,LeftTee:P4,LeftTeeVector:D4,leftthreetimes:L4,LeftTriangleBar:N4,LeftTriangle:O4,LeftTriangleEqual:z4,LeftUpDownVector:B4,LeftUpTeeVector:j4,LeftUpVectorBar:F4,LeftUpVector:U4,LeftVectorBar:W4,LeftVector:V4,lEg:$4,leg:Y4,leq:G4,leqq:H4,leqslant:Q4,lescc:q4,les:Z4,lesdot:K4,lesdoto:X4,lesdotor:J4,lesg:_4,lesges:eF,lessapprox:tF,lessdot:rF,lesseqgtr:nF,lesseqqgtr:iF,LessEqualGreater:sF,LessFullEqual:oF,LessGreater:aF,lessgtr:cF,LessLess:lF,lesssim:uF,LessSlantEqual:hF,LessTilde:dF,lfisht:fF,lfloor:gF,Lfr:pF,lfr:mF,lg:yF,lgE:vF,lHar:MF,lhard:wF,lharu:SF,lharul:TF,lhblk:IF,LJcy:CF,ljcy:bF,llarr:EF,ll:xF,Ll:RF,llcorner:kF,Lleftarrow:AF,llhard:PF,lltri:DF,Lmidot:LF,lmidot:NF,lmoustache:OF,lmoust:zF,lnap:BF,lnapprox:jF,lne:FF,lnE:UF,lneq:WF,lneqq:VF,lnsim:$F,loang:YF,loarr:GF,lobrk:HF,longleftarrow:QF,LongLeftArrow:qF,Longleftarrow:ZF,longleftrightarrow:KF,LongLeftRightArrow:XF,Longleftrightarrow:JF,longmapsto:_F,longrightarrow:eU,LongRightArrow:tU,Longrightarrow:rU,looparrowleft:nU,looparrowright:iU,lopar:sU,Lopf:oU,lopf:aU,loplus:cU,lotimes:lU,lowast:uU,lowbar:hU,LowerLeftArrow:dU,LowerRightArrow:fU,loz:gU,lozenge:pU,lozf:mU,lpar:yU,lparlt:vU,lrarr:MU,lrcorner:wU,lrhar:SU,lrhard:TU,lrm:IU,lrtri:CU,lsaquo:bU,lscr:EU,Lscr:xU,lsh:RU,Lsh:kU,lsim:AU,lsime:PU,lsimg:DU,lsqb:LU,lsquo:NU,lsquor:OU,Lstrok:zU,lstrok:BU,ltcc:jU,ltcir:FU,lt:UU,LT:WU,Lt:VU,ltdot:$U,lthree:YU,ltimes:GU,ltlarr:HU,ltquest:QU,ltri:qU,ltrie:ZU,ltrif:KU,ltrPar:XU,lurdshar:JU,luruhar:_U,lvertneqq:e5,lvnE:t5,macr:r5,male:n5,malt:i5,maltese:s5,Map:"⤅",map:o5,mapsto:a5,mapstodown:c5,mapstoleft:l5,mapstoup:u5,marker:h5,mcomma:d5,Mcy:f5,mcy:g5,mdash:p5,mDDot:m5,measuredangle:y5,MediumSpace:v5,Mellintrf:M5,Mfr:w5,mfr:S5,mho:T5,micro:I5,midast:C5,midcir:b5,mid:E5,middot:x5,minusb:R5,minus:k5,minusd:A5,minusdu:P5,MinusPlus:D5,mlcp:L5,mldr:N5,mnplus:O5,models:z5,Mopf:B5,mopf:j5,mp:F5,mscr:U5,Mscr:W5,mstpos:V5,Mu:$5,mu:Y5,multimap:G5,mumap:H5,nabla:Q5,Nacute:q5,nacute:Z5,nang:K5,nap:X5,napE:J5,napid:_5,napos:eW,napprox:tW,natural:rW,naturals:nW,natur:iW,nbsp:sW,nbump:oW,nbumpe:aW,ncap:cW,Ncaron:lW,ncaron:uW,Ncedil:hW,ncedil:dW,ncong:fW,ncongdot:gW,ncup:pW,Ncy:mW,ncy:yW,ndash:vW,nearhk:MW,nearr:wW,neArr:SW,nearrow:TW,ne:IW,nedot:CW,NegativeMediumSpace:bW,NegativeThickSpace:EW,NegativeThinSpace:xW,NegativeVeryThinSpace:RW,nequiv:kW,nesear:AW,nesim:PW,NestedGreaterGreater:DW,NestedLessLess:LW,NewLine:NW,nexist:OW,nexists:zW,Nfr:BW,nfr:jW,ngE:FW,nge:UW,ngeq:WW,ngeqq:VW,ngeqslant:$W,nges:YW,nGg:GW,ngsim:HW,nGt:QW,ngt:qW,ngtr:ZW,nGtv:KW,nharr:XW,nhArr:JW,nhpar:_W,ni:eV,nis:tV,nisd:rV,niv:nV,NJcy:iV,njcy:sV,nlarr:oV,nlArr:aV,nldr:cV,nlE:lV,nle:uV,nleftarrow:hV,nLeftarrow:dV,nleftrightarrow:fV,nLeftrightarrow:gV,nleq:pV,nleqq:mV,nleqslant:yV,nles:vV,nless:MV,nLl:wV,nlsim:SV,nLt:TV,nlt:IV,nltri:CV,nltrie:bV,nLtv:EV,nmid:xV,NoBreak:RV,NonBreakingSpace:kV,nopf:AV,Nopf:PV,Not:DV,not:LV,NotCongruent:NV,NotCupCap:OV,NotDoubleVerticalBar:zV,NotElement:BV,NotEqual:jV,NotEqualTilde:FV,NotExists:UV,NotGreater:WV,NotGreaterEqual:VV,NotGreaterFullEqual:$V,NotGreaterGreater:YV,NotGreaterLess:GV,NotGreaterSlantEqual:HV,NotGreaterTilde:QV,NotHumpDownHump:qV,NotHumpEqual:ZV,notin:KV,notindot:XV,notinE:JV,notinva:_V,notinvb:e$,notinvc:t$,NotLeftTriangleBar:r$,NotLeftTriangle:n$,NotLeftTriangleEqual:i$,NotLess:s$,NotLessEqual:o$,NotLessGreater:a$,NotLessLess:c$,NotLessSlantEqual:l$,NotLessTilde:u$,NotNestedGreaterGreater:h$,NotNestedLessLess:d$,notni:f$,notniva:g$,notnivb:p$,notnivc:m$,NotPrecedes:y$,NotPrecedesEqual:v$,NotPrecedesSlantEqual:M$,NotReverseElement:w$,NotRightTriangleBar:S$,NotRightTriangle:T$,NotRightTriangleEqual:I$,NotSquareSubset:C$,NotSquareSubsetEqual:b$,NotSquareSuperset:E$,NotSquareSupersetEqual:x$,NotSubset:R$,NotSubsetEqual:k$,NotSucceeds:A$,NotSucceedsEqual:P$,NotSucceedsSlantEqual:D$,NotSucceedsTilde:L$,NotSuperset:N$,NotSupersetEqual:O$,NotTilde:z$,NotTildeEqual:B$,NotTildeFullEqual:j$,NotTildeTilde:F$,NotVerticalBar:U$,nparallel:W$,npar:V$,nparsl:$$,npart:Y$,npolint:G$,npr:H$,nprcue:Q$,nprec:q$,npreceq:Z$,npre:K$,nrarrc:X$,nrarr:J$,nrArr:_$,nrarrw:eY,nrightarrow:tY,nRightarrow:rY,nrtri:nY,nrtrie:iY,nsc:sY,nsccue:oY,nsce:aY,Nscr:cY,nscr:lY,nshortmid:uY,nshortparallel:hY,nsim:dY,nsime:fY,nsimeq:gY,nsmid:pY,nspar:mY,nsqsube:yY,nsqsupe:vY,nsub:MY,nsubE:wY,nsube:SY,nsubset:TY,nsubseteq:IY,nsubseteqq:CY,nsucc:bY,nsucceq:EY,nsup:xY,nsupE:RY,nsupe:kY,nsupset:AY,nsupseteq:PY,nsupseteqq:DY,ntgl:LY,Ntilde:NY,ntilde:OY,ntlg:zY,ntriangleleft:BY,ntrianglelefteq:jY,ntriangleright:FY,ntrianglerighteq:UY,Nu:WY,nu:VY,num:$Y,numero:YY,numsp:GY,nvap:HY,nvdash:QY,nvDash:qY,nVdash:ZY,nVDash:KY,nvge:XY,nvgt:JY,nvHarr:_Y,nvinfin:eG,nvlArr:tG,nvle:rG,nvlt:nG,nvltrie:iG,nvrArr:sG,nvrtrie:oG,nvsim:aG,nwarhk:cG,nwarr:lG,nwArr:uG,nwarrow:hG,nwnear:dG,Oacute:fG,oacute:gG,oast:pG,Ocirc:mG,ocirc:yG,ocir:vG,Ocy:MG,ocy:wG,odash:SG,Odblac:TG,odblac:IG,odiv:CG,odot:bG,odsold:EG,OElig:xG,oelig:RG,ofcir:kG,Ofr:AG,ofr:PG,ogon:DG,Ograve:LG,ograve:NG,ogt:OG,ohbar:zG,ohm:BG,oint:jG,olarr:FG,olcir:UG,olcross:WG,oline:VG,olt:$G,Omacr:YG,omacr:GG,Omega:HG,omega:QG,Omicron:qG,omicron:ZG,omid:KG,ominus:XG,Oopf:JG,oopf:_G,opar:e8,OpenCurlyDoubleQuote:t8,OpenCurlyQuote:r8,operp:n8,oplus:i8,orarr:s8,Or:o8,or:a8,ord:c8,order:l8,orderof:u8,ordf:h8,ordm:d8,origof:f8,oror:g8,orslope:p8,orv:m8,oS:y8,Oscr:v8,oscr:M8,Oslash:w8,oslash:S8,osol:T8,Otilde:I8,otilde:C8,otimesas:b8,Otimes:E8,otimes:x8,Ouml:R8,ouml:k8,ovbar:A8,OverBar:P8,OverBrace:D8,OverBracket:L8,OverParenthesis:N8,para:O8,parallel:z8,par:B8,parsim:j8,parsl:F8,part:U8,PartialD:W8,Pcy:V8,pcy:$8,percnt:Y8,period:G8,permil:H8,perp:Q8,pertenk:q8,Pfr:Z8,pfr:K8,Phi:X8,phi:J8,phiv:_8,phmmat:e6,phone:t6,Pi:r6,pi:n6,pitchfork:i6,piv:s6,planck:o6,planckh:a6,plankv:c6,plusacir:l6,plusb:u6,pluscir:h6,plus:d6,plusdo:f6,plusdu:g6,pluse:p6,PlusMinus:m6,plusmn:y6,plussim:v6,plustwo:M6,pm:w6,Poincareplane:S6,pointint:T6,popf:I6,Popf:C6,pound:b6,prap:E6,Pr:x6,pr:R6,prcue:k6,precapprox:A6,prec:P6,preccurlyeq:D6,Precedes:L6,PrecedesEqual:N6,PrecedesSlantEqual:O6,PrecedesTilde:z6,preceq:B6,precnapprox:j6,precneqq:F6,precnsim:U6,pre:W6,prE:V6,precsim:$6,prime:Y6,Prime:G6,primes:H6,prnap:Q6,prnE:q6,prnsim:Z6,prod:K6,Product:X6,profalar:J6,profline:_6,profsurf:e9,prop:t9,Proportional:r9,Proportion:n9,propto:i9,prsim:s9,prurel:o9,Pscr:a9,pscr:c9,Psi:l9,psi:u9,puncsp:h9,Qfr:d9,qfr:f9,qint:g9,qopf:p9,Qopf:m9,qprime:y9,Qscr:v9,qscr:M9,quaternions:w9,quatint:S9,quest:T9,questeq:I9,quot:C9,QUOT:b9,rAarr:E9,race:x9,Racute:R9,racute:k9,radic:A9,raemptyv:P9,rang:D9,Rang:L9,rangd:N9,range:O9,rangle:z9,raquo:B9,rarrap:j9,rarrb:F9,rarrbfs:U9,rarrc:W9,rarr:V9,Rarr:$9,rArr:Y9,rarrfs:G9,rarrhk:H9,rarrlp:Q9,rarrpl:q9,rarrsim:Z9,Rarrtl:K9,rarrtl:X9,rarrw:J9,ratail:_9,rAtail:eH,ratio:tH,rationals:rH,rbarr:nH,rBarr:iH,RBarr:sH,rbbrk:oH,rbrace:aH,rbrack:cH,rbrke:lH,rbrksld:uH,rbrkslu:hH,Rcaron:dH,rcaron:fH,Rcedil:gH,rcedil:pH,rceil:mH,rcub:yH,Rcy:vH,rcy:MH,rdca:wH,rdldhar:SH,rdquo:TH,rdquor:IH,rdsh:CH,real:bH,realine:EH,realpart:xH,reals:RH,Re:kH,rect:AH,reg:PH,REG:DH,ReverseElement:LH,ReverseEquilibrium:NH,ReverseUpEquilibrium:OH,rfisht:zH,rfloor:BH,rfr:jH,Rfr:FH,rHar:UH,rhard:WH,rharu:VH,rharul:$H,Rho:YH,rho:GH,rhov:HH,RightAngleBracket:QH,RightArrowBar:qH,rightarrow:ZH,RightArrow:KH,Rightarrow:XH,RightArrowLeftArrow:JH,rightarrowtail:_H,RightCeiling:e7,RightDoubleBracket:t7,RightDownTeeVector:r7,RightDownVectorBar:n7,RightDownVector:i7,RightFloor:s7,rightharpoondown:o7,rightharpoonup:a7,rightleftarrows:c7,rightleftharpoons:l7,rightrightarrows:u7,rightsquigarrow:h7,RightTeeArrow:d7,RightTee:f7,RightTeeVector:g7,rightthreetimes:p7,RightTriangleBar:m7,RightTriangle:y7,RightTriangleEqual:v7,RightUpDownVector:M7,RightUpTeeVector:w7,RightUpVectorBar:S7,RightUpVector:T7,RightVectorBar:I7,RightVector:C7,ring:b7,risingdotseq:E7,rlarr:x7,rlhar:R7,rlm:k7,rmoustache:A7,rmoust:P7,rnmid:D7,roang:L7,roarr:N7,robrk:O7,ropar:z7,ropf:B7,Ropf:j7,roplus:F7,rotimes:U7,RoundImplies:W7,rpar:V7,rpargt:$7,rppolint:Y7,rrarr:G7,Rrightarrow:H7,rsaquo:Q7,rscr:q7,Rscr:Z7,rsh:K7,Rsh:X7,rsqb:J7,rsquo:_7,rsquor:eQ,rthree:tQ,rtimes:rQ,rtri:nQ,rtrie:iQ,rtrif:sQ,rtriltri:oQ,RuleDelayed:aQ,ruluhar:cQ,rx:lQ,Sacute:uQ,sacute:hQ,sbquo:dQ,scap:fQ,Scaron:gQ,scaron:pQ,Sc:mQ,sc:yQ,sccue:vQ,sce:MQ,scE:wQ,Scedil:SQ,scedil:TQ,Scirc:IQ,scirc:CQ,scnap:bQ,scnE:EQ,scnsim:xQ,scpolint:RQ,scsim:kQ,Scy:AQ,scy:PQ,sdotb:DQ,sdot:LQ,sdote:NQ,searhk:OQ,searr:zQ,seArr:BQ,searrow:jQ,sect:FQ,semi:UQ,seswar:WQ,setminus:VQ,setmn:$Q,sext:YQ,Sfr:GQ,sfr:HQ,sfrown:QQ,sharp:qQ,SHCHcy:ZQ,shchcy:KQ,SHcy:XQ,shcy:JQ,ShortDownArrow:_Q,ShortLeftArrow:eq,shortmid:tq,shortparallel:rq,ShortRightArrow:nq,ShortUpArrow:iq,shy:sq,Sigma:oq,sigma:aq,sigmaf:cq,sigmav:lq,sim:uq,simdot:hq,sime:dq,simeq:fq,simg:gq,simgE:pq,siml:mq,simlE:yq,simne:vq,simplus:Mq,simrarr:wq,slarr:Sq,SmallCircle:Tq,smallsetminus:Iq,smashp:Cq,smeparsl:bq,smid:Eq,smile:xq,smt:Rq,smte:kq,smtes:Aq,SOFTcy:Pq,softcy:Dq,solbar:Lq,solb:Nq,sol:Oq,Sopf:zq,sopf:Bq,spades:jq,spadesuit:Fq,spar:Uq,sqcap:Wq,sqcaps:Vq,sqcup:$q,sqcups:Yq,Sqrt:Gq,sqsub:Hq,sqsube:Qq,sqsubset:qq,sqsubseteq:Zq,sqsup:Kq,sqsupe:Xq,sqsupset:Jq,sqsupseteq:_q,square:eZ,Square:tZ,SquareIntersection:rZ,SquareSubset:nZ,SquareSubsetEqual:iZ,SquareSuperset:sZ,SquareSupersetEqual:oZ,SquareUnion:aZ,squarf:cZ,squ:lZ,squf:uZ,srarr:hZ,Sscr:dZ,sscr:fZ,ssetmn:gZ,ssmile:pZ,sstarf:mZ,Star:yZ,star:vZ,starf:MZ,straightepsilon:wZ,straightphi:SZ,strns:TZ,sub:IZ,Sub:CZ,subdot:bZ,subE:EZ,sube:xZ,subedot:RZ,submult:kZ,subnE:AZ,subne:PZ,subplus:DZ,subrarr:LZ,subset:NZ,Subset:OZ,subseteq:zZ,subseteqq:BZ,SubsetEqual:jZ,subsetneq:FZ,subsetneqq:UZ,subsim:WZ,subsub:VZ,subsup:$Z,succapprox:YZ,succ:GZ,succcurlyeq:HZ,Succeeds:QZ,SucceedsEqual:qZ,SucceedsSlantEqual:ZZ,SucceedsTilde:KZ,succeq:XZ,succnapprox:JZ,succneqq:_Z,succnsim:eK,succsim:tK,SuchThat:rK,sum:nK,Sum:iK,sung:sK,sup1:oK,sup2:aK,sup3:cK,sup:lK,Sup:uK,supdot:hK,supdsub:dK,supE:fK,supe:gK,supedot:pK,Superset:mK,SupersetEqual:yK,suphsol:vK,suphsub:MK,suplarr:wK,supmult:SK,supnE:TK,supne:IK,supplus:CK,supset:bK,Supset:EK,supseteq:xK,supseteqq:RK,supsetneq:kK,supsetneqq:AK,supsim:PK,supsub:DK,supsup:LK,swarhk:NK,swarr:OK,swArr:zK,swarrow:BK,swnwar:jK,szlig:FK,Tab:UK,target:WK,Tau:VK,tau:$K,tbrk:YK,Tcaron:GK,tcaron:HK,Tcedil:QK,tcedil:qK,Tcy:ZK,tcy:KK,tdot:XK,telrec:JK,Tfr:_K,tfr:eX,there4:tX,therefore:rX,Therefore:nX,Theta:iX,theta:sX,thetasym:oX,thetav:aX,thickapprox:cX,thicksim:lX,ThickSpace:uX,ThinSpace:hX,thinsp:dX,thkap:fX,thksim:gX,THORN:pX,thorn:mX,tilde:yX,Tilde:vX,TildeEqual:MX,TildeFullEqual:wX,TildeTilde:SX,timesbar:TX,timesb:IX,times:CX,timesd:bX,tint:EX,toea:xX,topbot:RX,topcir:kX,top:AX,Topf:PX,topf:DX,topfork:LX,tosa:NX,tprime:OX,trade:zX,TRADE:BX,triangle:jX,triangledown:FX,triangleleft:UX,trianglelefteq:WX,triangleq:VX,triangleright:$X,trianglerighteq:YX,tridot:GX,trie:HX,triminus:QX,TripleDot:qX,triplus:ZX,trisb:KX,tritime:XX,trpezium:JX,Tscr:_X,tscr:eJ,TScy:tJ,tscy:rJ,TSHcy:nJ,tshcy:iJ,Tstrok:sJ,tstrok:oJ,twixt:aJ,twoheadleftarrow:cJ,twoheadrightarrow:lJ,Uacute:uJ,uacute:hJ,uarr:dJ,Uarr:fJ,uArr:gJ,Uarrocir:pJ,Ubrcy:mJ,ubrcy:yJ,Ubreve:vJ,ubreve:MJ,Ucirc:wJ,ucirc:SJ,Ucy:TJ,ucy:IJ,udarr:CJ,Udblac:bJ,udblac:EJ,udhar:xJ,ufisht:RJ,Ufr:kJ,ufr:AJ,Ugrave:PJ,ugrave:DJ,uHar:LJ,uharl:NJ,uharr:OJ,uhblk:zJ,ulcorn:BJ,ulcorner:jJ,ulcrop:FJ,ultri:UJ,Umacr:WJ,umacr:VJ,uml:$J,UnderBar:YJ,UnderBrace:GJ,UnderBracket:HJ,UnderParenthesis:QJ,Union:qJ,UnionPlus:ZJ,Uogon:KJ,uogon:XJ,Uopf:JJ,uopf:_J,UpArrowBar:e_,uparrow:t_,UpArrow:r_,Uparrow:n_,UpArrowDownArrow:i_,updownarrow:s_,UpDownArrow:o_,Updownarrow:a_,UpEquilibrium:c_,upharpoonleft:l_,upharpoonright:u_,uplus:h_,UpperLeftArrow:d_,UpperRightArrow:f_,upsi:g_,Upsi:p_,upsih:m_,Upsilon:y_,upsilon:v_,UpTeeArrow:M_,UpTee:w_,upuparrows:S_,urcorn:T_,urcorner:I_,urcrop:C_,Uring:b_,uring:E_,urtri:x_,Uscr:R_,uscr:k_,utdot:A_,Utilde:P_,utilde:D_,utri:L_,utrif:N_,uuarr:O_,Uuml:z_,uuml:B_,uwangle:j_,vangrt:F_,varepsilon:U_,varkappa:W_,varnothing:V_,varphi:$_,varpi:Y_,varpropto:G_,varr:H_,vArr:Q_,varrho:q_,varsigma:Z_,varsubsetneq:K_,varsubsetneqq:X_,varsupsetneq:J_,varsupsetneqq:__,vartheta:eee,vartriangleleft:tee,vartriangleright:ree,vBar:nee,Vbar:iee,vBarv:see,Vcy:oee,vcy:aee,vdash:cee,vDash:lee,Vdash:uee,VDash:hee,Vdashl:dee,veebar:fee,vee:gee,Vee:pee,veeeq:mee,vellip:yee,verbar:vee,Verbar:Mee,vert:wee,Vert:See,VerticalBar:Tee,VerticalLine:Iee,VerticalSeparator:Cee,VerticalTilde:bee,VeryThinSpace:Eee,Vfr:xee,vfr:Ree,vltri:kee,vnsub:Aee,vnsup:Pee,Vopf:Dee,vopf:Lee,vprop:Nee,vrtri:Oee,Vscr:zee,vscr:Bee,vsubnE:jee,vsubne:Fee,vsupnE:Uee,vsupne:Wee,Vvdash:Vee,vzigzag:$ee,Wcirc:Yee,wcirc:Gee,wedbar:Hee,wedge:Qee,Wedge:qee,wedgeq:Zee,weierp:Kee,Wfr:Xee,wfr:Jee,Wopf:_ee,wopf:ete,wp:tte,wr:rte,wreath:nte,Wscr:ite,wscr:ste,xcap:ote,xcirc:ate,xcup:cte,xdtri:lte,Xfr:ute,xfr:hte,xharr:dte,xhArr:fte,Xi:gte,xi:pte,xlarr:mte,xlArr:yte,xmap:vte,xnis:Mte,xodot:wte,Xopf:Ste,xopf:Tte,xoplus:Ite,xotime:Cte,xrarr:bte,xrArr:Ete,Xscr:xte,xscr:Rte,xsqcup:kte,xuplus:Ate,xutri:Pte,xvee:Dte,xwedge:Lte,Yacute:Nte,yacute:Ote,YAcy:zte,yacy:Bte,Ycirc:jte,ycirc:Fte,Ycy:Ute,ycy:Wte,yen:Vte,Yfr:$te,yfr:Yte,YIcy:Gte,yicy:Hte,Yopf:Qte,yopf:qte,Yscr:Zte,yscr:Kte,YUcy:Xte,yucy:Jte,yuml:_te,Yuml:ere,Zacute:tre,zacute:rre,Zcaron:nre,zcaron:ire,Zcy:sre,zcy:ore,Zdot:are,zdot:cre,zeetrf:lre,ZeroWidthSpace:ure,Zeta:hre,zeta:dre,zfr:fre,Zfr:gre,ZHcy:pre,zhcy:mre,zigrarr:yre,zopf:vre,Zopf:Mre,Zscr:wre,zscr:Sre,zwj:Tre,zwnj:Ire},Cre="Á",bre="á",Ere="Â",xre="â",Rre="´",kre="Æ",Are="æ",Pre="À",Dre="à",Lre="&",Nre="&",Ore="Å",zre="å",Bre="Ã",jre="ã",Fre="Ä",Ure="ä",Wre="¦",Vre="Ç",$re="ç",Yre="¸",Gre="¢",Hre="©",Qre="©",qre="¤",Zre="°",Kre="÷",Xre="É",Jre="é",_re="Ê",ene="ê",tne="È",rne="è",nne="Ð",ine="ð",sne="Ë",one="ë",ane="½",cne="¼",lne="¾",une=">",hne=">",dne="Í",fne="í",gne="Î",pne="î",mne="¡",yne="Ì",vne="ì",Mne="¿",wne="Ï",Sne="ï",Tne="«",Ine="<",Cne="<",bne="¯",Ene="µ",xne="·",Rne=" ",kne="¬",Ane="Ñ",Pne="ñ",Dne="Ó",Lne="ó",Nne="Ô",One="ô",zne="Ò",Bne="ò",jne="ª",Fne="º",Une="Ø",Wne="ø",Vne="Õ",$ne="õ",Yne="Ö",Gne="ö",Hne="¶",Qne="±",qne="£",Zne='"',Kne='"',Xne="»",Jne="®",_ne="®",eie="§",tie="",rie="¹",nie="²",iie="³",sie="ß",oie="Þ",aie="þ",cie="×",lie="Ú",uie="ú",hie="Û",die="û",fie="Ù",gie="ù",pie="¨",mie="Ü",yie="ü",vie="Ý",Mie="ý",wie="¥",Sie="ÿ",Tie={Aacute:Cre,aacute:bre,Acirc:Ere,acirc:xre,acute:Rre,AElig:kre,aelig:Are,Agrave:Pre,agrave:Dre,amp:Lre,AMP:Nre,Aring:Ore,aring:zre,Atilde:Bre,atilde:jre,Auml:Fre,auml:Ure,brvbar:Wre,Ccedil:Vre,ccedil:$re,cedil:Yre,cent:Gre,copy:Hre,COPY:Qre,curren:qre,deg:Zre,divide:Kre,Eacute:Xre,eacute:Jre,Ecirc:_re,ecirc:ene,Egrave:tne,egrave:rne,ETH:nne,eth:ine,Euml:sne,euml:one,frac12:ane,frac14:cne,frac34:lne,gt:une,GT:hne,Iacute:dne,iacute:fne,Icirc:gne,icirc:pne,iexcl:mne,Igrave:yne,igrave:vne,iquest:Mne,Iuml:wne,iuml:Sne,laquo:Tne,lt:Ine,LT:Cne,macr:bne,micro:Ene,middot:xne,nbsp:Rne,not:kne,Ntilde:Ane,ntilde:Pne,Oacute:Dne,oacute:Lne,Ocirc:Nne,ocirc:One,Ograve:zne,ograve:Bne,ordf:jne,ordm:Fne,Oslash:Une,oslash:Wne,Otilde:Vne,otilde:$ne,Ouml:Yne,ouml:Gne,para:Hne,plusmn:Qne,pound:qne,quot:Zne,QUOT:Kne,raquo:Xne,reg:Jne,REG:_ne,sect:eie,shy:tie,sup1:rie,sup2:nie,sup3:iie,szlig:sie,THORN:oie,thorn:aie,times:cie,Uacute:lie,uacute:uie,Ucirc:hie,ucirc:die,Ugrave:fie,ugrave:gie,uml:pie,Uuml:mie,uuml:yie,Yacute:vie,yacute:Mie,yen:wie,yuml:Sie},Iie="&",Cie="'",bie=">",Eie="<",xie='"',Py={amp:Iie,apos:Cie,gt:bie,lt:Eie,quot:xie};var Bh={};const Rie={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 kie=St&&St.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Bh,"__esModule",{value:!0});var cg=kie(Rie),Aie=String.fromCodePoint||function(s){var t="";return s>65535&&(s-=65536,t+=String.fromCharCode(s>>>10&1023|55296),s=56320|s&1023),t+=String.fromCharCode(s),t};function Pie(s){return s>=55296&&s<=57343||s>1114111?"�":(s in cg.default&&(s=cg.default[s]),Aie(s))}Bh.default=Pie;var pc=St&&St.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(an,"__esModule",{value:!0});an.decodeHTML=an.decodeHTMLStrict=an.decodeXML=void 0;var Cu=pc(Ay),Die=pc(Tie),Lie=pc(Py),lg=pc(Bh),Nie=/&(?:[a-zA-Z0-9]+|#[xX][\da-fA-F]+|#\d+);/g;an.decodeXML=Dy(Lie.default);an.decodeHTMLStrict=Dy(Cu.default);function Dy(s){var t=Ly(s);return function(e){return String(e).replace(Nie,t)}}var ug=function(s,t){return s<t?1:-1};an.decodeHTML=function(){for(var s=Object.keys(Die.default).sort(ug),t=Object.keys(Cu.default).sort(ug),e=0,r=0;e<t.length;e++)s[r]===t[e]?(t[e]+=";?",r++):t[e]+=";";var n=new RegExp("&(?:"+t.join("|")+"|#[xX][\\da-fA-F]+;?|#\\d+;?)","g"),i=Ly(Cu.default);function o(a){return a.substr(-1)!==";"&&(a+=";"),i(a)}return function(a){return String(a).replace(n,o)}}();function Ly(s){return function(e){if(e.charAt(1)==="#"){var r=e.charAt(2);return r==="X"||r==="x"?lg.default(parseInt(e.substr(3),16)):lg.default(parseInt(e.substr(2),10))}return s[e.slice(1,-1)]||e}}var sr={},Ny=St&&St.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(sr,"__esModule",{value:!0});sr.escapeUTF8=sr.escape=sr.encodeNonAsciiHTML=sr.encodeHTML=sr.encodeXML=void 0;var Oie=Ny(Py),Oy=By(Oie.default),zy=jy(Oy);sr.encodeXML=Wy(Oy);var zie=Ny(Ay),jh=By(zie.default),Bie=jy(jh);sr.encodeHTML=Fie(jh,Bie);sr.encodeNonAsciiHTML=Wy(jh);function By(s){return Object.keys(s).sort().reduce(function(t,e){return t[s[e]]="&"+e+";",t},{})}function jy(s){for(var t=[],e=[],r=0,n=Object.keys(s);r<n.length;r++){var i=n[r];i.length===1?t.push("\\"+i):e.push(i)}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 Fy=/(?:[\x80-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/g,jie=String.prototype.codePointAt!=null?function(s){return s.codePointAt(0)}:function(s){return(s.charCodeAt(0)-55296)*1024+s.charCodeAt(1)-56320+65536};function mc(s){return"&#x"+(s.length>1?jie(s):s.charCodeAt(0)).toString(16).toUpperCase()+";"}function Fie(s,t){return function(e){return e.replace(t,function(r){return s[r]}).replace(Fy,mc)}}var Uy=new RegExp(zy.source+"|"+Fy.source,"g");function Uie(s){return s.replace(Uy,mc)}sr.escape=Uie;function Wie(s){return s.replace(zy,mc)}sr.escapeUTF8=Wie;function Wy(s){return function(t){return t.replace(Uy,function(e){return s[e]||mc(e)})}}(function(s){Object.defineProperty(s,"__esModule",{value:!0}),s.decodeXMLStrict=s.decodeHTML5Strict=s.decodeHTML4Strict=s.decodeHTML5=s.decodeHTML4=s.decodeHTMLStrict=s.decodeHTML=s.decodeXML=s.encodeHTML5=s.encodeHTML4=s.escapeUTF8=s.escape=s.encodeNonAsciiHTML=s.encodeHTML=s.encodeXML=s.encode=s.decodeStrict=s.decode=void 0;var t=an,e=sr;function r(c,l){return(!l||l<=0?t.decodeXML:t.decodeHTML)(c)}s.decode=r;function n(c,l){return(!l||l<=0?t.decodeXML:t.decodeHTMLStrict)(c)}s.decodeStrict=n;function i(c,l){return(!l||l<=0?e.encodeXML:e.encodeHTML)(c)}s.encode=i;var o=sr;Object.defineProperty(s,"encodeXML",{enumerable:!0,get:function(){return o.encodeXML}}),Object.defineProperty(s,"encodeHTML",{enumerable:!0,get:function(){return o.encodeHTML}}),Object.defineProperty(s,"encodeNonAsciiHTML",{enumerable:!0,get:function(){return o.encodeNonAsciiHTML}}),Object.defineProperty(s,"escape",{enumerable:!0,get:function(){return o.escape}}),Object.defineProperty(s,"escapeUTF8",{enumerable:!0,get:function(){return o.escapeUTF8}}),Object.defineProperty(s,"encodeHTML4",{enumerable:!0,get:function(){return o.encodeHTML}}),Object.defineProperty(s,"encodeHTML5",{enumerable:!0,get:function(){return o.encodeHTML}});var a=an;Object.defineProperty(s,"decodeXML",{enumerable:!0,get:function(){return a.decodeXML}}),Object.defineProperty(s,"decodeHTML",{enumerable:!0,get:function(){return a.decodeHTML}}),Object.defineProperty(s,"decodeHTMLStrict",{enumerable:!0,get:function(){return a.decodeHTMLStrict}}),Object.defineProperty(s,"decodeHTML4",{enumerable:!0,get:function(){return a.decodeHTML}}),Object.defineProperty(s,"decodeHTML5",{enumerable:!0,get:function(){return a.decodeHTML}}),Object.defineProperty(s,"decodeHTML4Strict",{enumerable:!0,get:function(){return a.decodeHTMLStrict}}),Object.defineProperty(s,"decodeHTML5Strict",{enumerable:!0,get:function(){return a.decodeHTMLStrict}}),Object.defineProperty(s,"decodeXMLStrict",{enumerable:!0,get:function(){return a.decodeXML}})})(ky);const Vie={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"},$ie={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"},Yie={elementNames:Vie,attributeNames:$ie};var Fo=Ry,Vy=ky,yc=Yie;yc.elementNames.__proto__=null;yc.attributeNames.__proto__=null;var Gie={__proto__:null,style:!0,script:!0,xmp:!0,iframe:!0,noembed:!0,noframes:!0,plaintext:!0,noscript:!0};function Hie(s,t){if(s){var e="",r;for(var n in s)r=s[n],e&&(e+=" "),t.xmlMode==="foreign"&&(n=yc.attributeNames[n]||n),e+=n,(r!==null&&r!==""||t.xmlMode)&&(e+='="'+(t.decodeEntities?Vy.encodeXML(r):r.replace(/\"/g,"""))+'"');return e}}var Qie={__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},$y=xy.exports=function(s,t){!Array.isArray(s)&&!s.cheerio&&(s=[s]),t=t||{};for(var e="",r=0;r<s.length;r++){var n=s[r];n.type==="root"?e+=$y(n.children,t):Fo.isTag(n)?e+=Zie(n,t):n.type===Fo.Directive?e+=Kie(n):n.type===Fo.Comment?e+=_ie(n):n.type===Fo.CDATA?e+=Jie(n):e+=Xie(n,t)}return e},qie=["mi","mo","mn","ms","mtext","annotation-xml","foreignObject","desc","title"];function Zie(s,t){t.xmlMode==="foreign"&&(s.name=yc.elementNames[s.name]||s.name,s.parent&&qie.indexOf(s.parent.name)>=0&&(t=Object.assign({},t,{xmlMode:!1}))),!t.xmlMode&&["svg","math"].indexOf(s.name)>=0&&(t=Object.assign({},t,{xmlMode:"foreign"}));var e="<"+s.name,r=Hie(s.attribs,t);return r&&(e+=" "+r),t.xmlMode&&(!s.children||s.children.length===0)?e+="/>":(e+=">",s.children&&(e+=$y(s.children,t)),(!Qie[s.name]||t.xmlMode)&&(e+="</"+s.name+">")),e}function Kie(s){return"<"+s.data+">"}function Xie(s,t){var e=s.data||"";return t.decodeEntities&&!(s.parent&&s.parent.name in Gie)&&(e=Vy.encodeXML(e)),e}function Jie(s){return"<![CDATA["+s.children[0].data+"]]>"}function _ie(s){return"<!--"+s.data+"-->"}var ese=xy.exports,bu=zh,Yy=ese,tse=bu.isTag,rse={getInnerHTML:nse,getOuterHTML:Yy,getText:da};function nse(s,t){return s.children?s.children.map(function(e){return Yy(e,t)}).join(""):""}function da(s){return Array.isArray(s)?s.map(da).join(""):tse(s)?s.name==="br"?`
|
|
569
|
-
`:da(s.children):s.type===bu.CDATA?da(s.children):s.type===bu.Text?s.data:""}var fi={},ise=fi.getChildren=function(s){return s.children},sse=fi.getParent=function(s){return s.parent};fi.getSiblings=function(s){var t=sse(s);return t?ise(t):[s]};fi.getAttributeValue=function(s,t){return s.attribs&&s.attribs[t]};fi.hasAttrib=function(s,t){return!!s.attribs&&hasOwnProperty.call(s.attribs,t)};fi.getName=function(s){return s.name};var _i={};_i.removeElement=function(s){if(s.prev&&(s.prev.next=s.next),s.next&&(s.next.prev=s.prev),s.parent){var t=s.parent.children;t.splice(t.lastIndexOf(s),1)}};_i.replaceElement=function(s,t){var e=t.prev=s.prev;e&&(e.next=t);var r=t.next=s.next;r&&(r.prev=t);var n=t.parent=s.parent;if(n){var i=n.children;i[i.lastIndexOf(s)]=t}};_i.appendChild=function(s,t){if(t.parent=s,s.children.push(t)!==1){var e=s.children[s.children.length-2];e.next=t,t.prev=e,t.next=null}};_i.append=function(s,t){var e=s.parent,r=s.next;if(t.next=r,t.prev=s,s.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(s,t){var e=s.parent;if(e){var r=e.children;r.splice(r.lastIndexOf(s),0,t)}s.prev&&(s.prev.next=t),t.parent=e,t.prev=s.prev,t.next=s,s.prev=t};var Fh=zh.isTag,ose={filter:ase,find:Uh,findOneChild:cse,findOne:Gy,existsOne:Hy,findAll:lse};function ase(s,t,e,r){return Array.isArray(t)||(t=[t]),(typeof r!="number"||!isFinite(r))&&(r=1/0),Uh(s,t,e!==!1,r)}function Uh(s,t,e,r){for(var n=[],i,o=0,a=t.length;o<a&&!(s(t[o])&&(n.push(t[o]),--r<=0)||(i=t[o].children,e&&i&&i.length>0&&(i=Uh(s,i,e,r),n=n.concat(i),r-=i.length,r<=0)));o++);return n}function cse(s,t){for(var e=0,r=t.length;e<r;e++)if(s(t[e]))return t[e];return null}function Gy(s,t){for(var e=null,r=0,n=t.length;r<n&&!e;r++)if(Fh(t[r]))s(t[r])?e=t[r]:t[r].children.length>0&&(e=Gy(s,t[r].children));else continue;return e}function Hy(s,t){for(var e=0,r=t.length;e<r;e++)if(Fh(t[e])&&(s(t[e])||t[e].children.length>0&&Hy(s,t[e].children)))return!0;return!1}function lse(s,t){for(var e=[],r=t.slice();r.length;){var n=r.shift();Fh(n)&&(n.children&&n.children.length>0&&r.unshift.apply(r,n.children),s(n)&&e.push(n))}return e}var gi={},use=zh,Qn=gi.isTag=use.isTag;gi.testElement=function(s,t){for(var e in s)if(s.hasOwnProperty(e)){if(e==="tag_name"){if(!Qn(t)||!s.tag_name(t.name))return!1}else if(e==="tag_type"){if(!s.tag_type(t.type))return!1}else if(e==="tag_contains"){if(Qn(t)||!s.tag_contains(t.data))return!1}else if(!t.attribs||!s[e](t.attribs[e]))return!1}return!0};var ba={tag_name:function(s){return typeof s=="function"?function(t){return Qn(t)&&s(t.name)}:s==="*"?Qn:function(t){return Qn(t)&&t.name===s}},tag_type:function(s){return typeof s=="function"?function(t){return s(t.type)}:function(t){return t.type===s}},tag_contains:function(s){return typeof s=="function"?function(t){return!Qn(t)&&s(t.data)}:function(t){return!Qn(t)&&t.data===s}}};function Qy(s,t){return typeof t=="function"?function(e){return e.attribs&&t(e.attribs[s])}:function(e){return e.attribs&&e.attribs[s]===t}}function hse(s,t){return function(e){return s(e)||t(e)}}gi.getElements=function(s,t,e,r){var n=Object.keys(s).map(function(i){var o=s[i];return i in ba?ba[i](o):Qy(i,o)});return n.length===0?[]:this.filter(n.reduce(hse),t,e,r)};gi.getElementById=function(s,t,e){return Array.isArray(t)||(t=[t]),this.findOne(Qy("id",s),t,e!==!1)};gi.getElementsByTagName=function(s,t,e,r){return this.filter(ba.tag_name(s),t,e,r)};gi.getElementsByTagType=function(s,t,e,r){return this.filter(ba.tag_type(s),t,e,r)};var vc={};vc.removeSubsets=function(s){for(var t=s.length,e,r,n;--t>-1;){for(e=r=s[t],s[t]=null,n=!0;r;){if(s.indexOf(r)>-1){n=!1,s.splice(t,1);break}r=r.parent}n&&(s[t]=e)}return s};var Kr={DISCONNECTED:1,PRECEDING:2,FOLLOWING:4,CONTAINS:8,CONTAINED_BY:16},dse=vc.compareDocumentPosition=function(s,t){var e=[],r=[],n,i,o,a,c,l;if(s===t)return 0;for(n=s;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?Kr.DISCONNECTED:(i=e[l-1],o=i.children,a=e[l],c=r[l],o.indexOf(a)>o.indexOf(c)?i===t?Kr.FOLLOWING|Kr.CONTAINED_BY:Kr.FOLLOWING:i===s?Kr.PRECEDING|Kr.CONTAINS:Kr.PRECEDING)};vc.uniqueSort=function(s){var t=s.length,e,r;for(s=s.slice();--t>-1;)e=s[t],r=s.indexOf(e),r>-1&&r<t&&s.splice(t,1);return s.sort(function(n,i){var o=dse(n,i);return o&Kr.PRECEDING?-1:o&Kr.FOLLOWING?1:0}),s};(function(s){var t=s.exports;[rse,fi,_i,ose,gi,vc].forEach(function(e){Object.keys(e).forEach(function(r){t[r]=e[r].bind(t)})})})(Ey);var fse=Ey.exports,lo={trueFunc:function(){return!0},falseFunc:function(){return!1}},qy={},Ea={};Object.defineProperty(Ea,"__esModule",{value:!0});Ea.default=wse;var hg=/^[^\\]?(?:\\(?:[\da-f]{1,6}\s?|.)|[\w\-\u00b0-\uFFFF])+/,gse=/\\([\da-f]{1,6}\s?|(\s)|.)/gi,pse=/^\s*((?:\\.|[\w\u00b0-\uFFFF-])+)\s*(?:(\S?)=\s*(?:(['"])((?:[^\\]|\\[^])*?)\3|(#?(?:\\.|[\w\u00b0-\uFFFF-])*)|)|)\s*(i)?\]/,mse={undefined:"exists","":"equals","~":"element","^":"start",$:"end","*":"any","!":"not","|":"hyphen"},dg={">":"child","<":"parent","~":"sibling","+":"adjacent"},fg={"#":["id","equals"],".":["class","element"]},yse=new Set(["has","not","matches","is","host","host-context"]),vse=new Set(["contains","icontains"]),gg=new Set(['"',"'"]);function Mse(s,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 Uo(s){return s.replace(gse,Mse)}function pg(s){return s===" "||s===`
|
|
570
|
-
`||s===" "||s==="\f"||s==="\r"}function wse(s,t){var e=[];if(s=Zy(e,""+s,t),s!=="")throw new Error("Unmatched selector: "+s);return e}function Zy(s,t,e){var r,n;e===void 0&&(e={});var i=[],o=!1;function a(){var A=t.match(hg);if(!A)throw new Error("Expected name, found "+t);var R=A[0];return t=t.substr(R.length),Uo(R)}function c(A){for(;pg(t.charAt(A));)A++;t=t.substr(A)}function l(A){for(var R=0;t.charAt(--A)==="\\";)R++;return(R&1)===1}for(c(0);t!=="";){var u=t.charAt(0);if(pg(u))o=!0,c(1);else if(u in dg)i.push({type:dg[u]}),o=!1,c(1);else if(u===","){if(i.length===0)throw new Error("Empty sub-selector");s.push(i),i=[],o=!1,c(1)}else if(o&&(i.length>0&&i.push({type:"descendant"}),o=!1),u==="*")t=t.substr(1),i.push({type:"universal"});else if(u in fg){var h=fg[u],d=h[0],f=h[1];t=t.substr(1),i.push({type:"attribute",name:d,action:f,value:a(),ignoreCase:!1})}else if(u==="["){t=t.substr(1);var g=t.match(pse);if(!g)throw new Error("Malformed attribute selector: "+t);var y=g[0],S=g[1],b=g[2],I=g[4],N=I===void 0?"":I,T=g[5],p=T===void 0?N:T,m=g[6];t=t.substr(y.length);var v=Uo(S);((r=e.lowerCaseAttributeNames)!==null&&r!==void 0?r:!e.xmlMode)&&(v=v.toLowerCase()),i.push({type:"attribute",name:v,action:mse[b],value:Uo(p),ignoreCase:!!m})}else if(u===":"){if(t.charAt(1)===":"){t=t.substr(2),i.push({type:"pseudo-element",name:a().toLowerCase()});continue}t=t.substr(1);var M=a().toLowerCase(),k=null;if(t.startsWith("("))if(yse.has(M)){var E=t.charAt(1),D=gg.has(E);if(t=t.substr(D?2:1),k=[],t=Zy(k,t,e),D)if(t.startsWith(E))t=t.substr(1);else throw new Error("Unmatched quotes in :"+M);if(!t.startsWith(")"))throw new Error("Missing closing parenthesis in :"+M+" ("+t+")");t=t.substr(1)}else{for(var P=1,z=1;z>0&&P<t.length;P++)t.charAt(P)==="("&&!l(P)?z++:t.charAt(P)===")"&&!l(P)&&z--;if(z)throw new Error("Parenthesis not matched");if(k=t.substr(1,P-2),t=t.substr(P),vse.has(M)){var E=k.charAt(0);E===k.slice(-1)&&gg.has(E)&&(k=k.slice(1,-1)),k=Uo(k)}}i.push({type:"pseudo",name:M,data:k})}else if(hg.test(t)){var j=a();((n=e.lowerCaseTags)!==null&&n!==void 0?n:!e.xmlMode)&&(j=j.toLowerCase()),i.push({type:"tag",name:j})}else return i.length&&i[i.length-1].type==="descendant"&&i.pop(),mg(s,i),t}return mg(s,i),t}function mg(s,t){if(s.length>0&&t.length===0)throw new Error("Empty sub-selector");s.push(t)}var Wh={},Sse=St&&St.__spreadArrays||function(){for(var s=0,t=0,e=arguments.length;t<e;t++)s+=arguments[t].length;for(var r=Array(s),n=0,t=0;t<e;t++)for(var i=arguments[t],o=0,a=i.length;o<a;o++,n++)r[n]=i[o];return r};Object.defineProperty(Wh,"__esModule",{value:!0});var Eu={equals:"",element:"~",start:"^",end:"$",any:"*",not:"!",hyphen:"|"},Tse=new Set(Sse(Object.keys(Eu).map(function(s){return Eu[s]}).filter(Boolean),[":","[","]"," ","\\"]));function Ky(s){return s.map(Ise).join(", ")}Wh.default=Ky;function Ise(s){return s.map(Cse).join("")}function Cse(s){switch(s.type){case"child":return" > ";case"parent":return" < ";case"sibling":return" ~ ";case"adjacent":return" + ";case"descendant":return" ";case"universal":return"*";case"tag":return xr(s.name);case"pseudo-element":return"::"+xr(s.name);case"pseudo":return s.data===null?":"+xr(s.name):typeof s.data=="string"?":"+xr(s.name)+"("+s.data+")":":"+xr(s.name)+"("+Ky(s.data)+")";case"attribute":return s.action==="exists"?"["+xr(s.name)+"]":s.name==="id"&&s.action==="equals"&&!s.ignoreCase?"#"+xr(s.value):s.name==="class"&&s.action==="element"&&!s.ignoreCase?"."+xr(s.value):"["+xr(s.name)+Eu[s.action]+"='"+xr(s.value)+"'"+(s.ignoreCase?"i":"")+"]"}}function xr(s){return s.split("").map(function(t){return Tse.has(t)?"\\"+t:t}).join("")}(function(s){var t=St&&St.__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=St&&St.__exportStar||function(o,a){for(var c in o)c!=="default"&&!Object.prototype.hasOwnProperty.call(a,c)&&t(a,o,c)},r=St&&St.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(s,"__esModule",{value:!0}),s.stringify=s.parse=void 0,e(Ea,s);var n=Ea;Object.defineProperty(s,"parse",{enumerable:!0,get:function(){return r(n).default}});var i=Wh;Object.defineProperty(s,"stringify",{enumerable:!0,get:function(){return r(i).default}})})(qy);const bse=50,Ese=30,xse=1,Rse=0,kse=-1,Ase=-1,Pse=-1,Dse=-1,Lse=-1,Xy={universal:bse,tag:Ese,attribute:xse,pseudo:Rse,descendant:kse,child:Ase,parent:Pse,sibling:Dse,adjacent:Lse};var Nse=Ose,xl=Xy,yg={__proto__:null,exists:10,equals:8,not:7,start:6,end:6,any:5,hyphen:4,element:4};function Ose(s){for(var t=s.map(Jy),e=1;e<s.length;e++){var r=t[e];if(!(r<0))for(var n=e-1;n>=0&&r<t[n];n--){var i=s[n+1];s[n+1]=s[n],s[n]=i,t[n+1]=t[n],t[n]=r}}}function Jy(s){var t=xl[s.type];if(t===xl.attribute)t=yg[s.action],t===yg.equals&&s.name==="id"&&(t=9),s.ignoreCase&&(t>>=1);else if(t===xl.pseudo)if(!s.data)t=3;else if(s.name==="has"||s.name==="contains")t=0;else if(s.name==="matches"||s.name==="not"){t=0;for(var e=0;e<s.data.length;e++)if(s.data[e].length===1){var r=Jy(s.data[e][0]);if(r===0){t=0;break}r>t&&(t=r)}s.data.length>1&&t>0&&(t-=1)}else t=1;return t}var Wo=lo.falseFunc,vg=/[-[\]{}()*+?.,\\^$|#\s]/g,Mg={__proto__:null,equals:function(s,t,e){var r=t.name,n=t.value,i=e.adapter;return t.ignoreCase?(n=n.toLowerCase(),function(a){var c=i.getAttributeValue(a,r);return c!=null&&c.toLowerCase()===n&&s(a)}):function(a){return i.getAttributeValue(a,r)===n&&s(a)}},hyphen:function(s,t,e){var r=t.name,n=t.value,i=n.length,o=e.adapter;return t.ignoreCase?(n=n.toLowerCase(),function(c){var l=o.getAttributeValue(c,r);return l!=null&&(l.length===i||l.charAt(i)==="-")&&l.substr(0,i).toLowerCase()===n&&s(c)}):function(c){var l=o.getAttributeValue(c,r);return l!=null&&l.substr(0,i)===n&&(l.length===i||l.charAt(i)==="-")&&s(c)}},element:function(s,t,e){var r=t.name,n=t.value,i=e.adapter;if(/\s/.test(n))return Wo;n=n.replace(vg,"\\$&");var o="(?:^|\\s)"+n+"(?:$|\\s)",a=t.ignoreCase?"i":"",c=new RegExp(o,a);return function(u){var h=i.getAttributeValue(u,r);return h!=null&&c.test(h)&&s(u)}},exists:function(s,t,e){var r=t.name,n=e.adapter;return function(o){return n.hasAttrib(o,r)&&s(o)}},start:function(s,t,e){var r=t.name,n=t.value,i=n.length,o=e.adapter;return i===0?Wo:t.ignoreCase?(n=n.toLowerCase(),function(c){var l=o.getAttributeValue(c,r);return l!=null&&l.substr(0,i).toLowerCase()===n&&s(c)}):function(c){var l=o.getAttributeValue(c,r);return l!=null&&l.substr(0,i)===n&&s(c)}},end:function(s,t,e){var r=t.name,n=t.value,i=-n.length,o=e.adapter;return i===0?Wo:t.ignoreCase?(n=n.toLowerCase(),function(c){var l=o.getAttributeValue(c,r);return l!=null&&l.substr(i).toLowerCase()===n&&s(c)}):function(c){var l=o.getAttributeValue(c,r);return l!=null&&l.substr(i)===n&&s(c)}},any:function(s,t,e){var r=t.name,n=t.value,i=e.adapter;if(n==="")return Wo;if(t.ignoreCase){var o=new RegExp(n.replace(vg,"\\$&"),"i");return function(c){var l=i.getAttributeValue(c,r);return l!=null&&o.test(l)&&s(c)}}return function(c){var l=i.getAttributeValue(c,r);return l!=null&&l.indexOf(n)>=0&&s(c)}},not:function(s,t,e){var r=t.name,n=t.value,i=e.adapter;return n===""?function(a){return!!i.getAttributeValue(a,r)&&s(a)}:t.ignoreCase?(n=n.toLowerCase(),function(a){var c=i.getAttributeValue(a,r);return c!=null&&c.toLowerCase()!==n&&s(a)}):function(a){return i.getAttributeValue(a,r)!==n&&s(a)}}},_y={compile:function(s,t,e){if(e&&e.strict&&(t.ignoreCase||t.action==="not"))throw new Error("Unsupported attribute selector");return Mg[t.action](s,t,e)},rules:Mg},Mc={exports:{}},zse=jse,Bse=/^([+\-]?\d*n)?\s*(?:([+\-]?)\s*(\d+))?$/;function jse(s){if(s=s.trim().toLowerCase(),s==="even")return[2,0];if(s==="odd")return[2,1];var t=s.match(Bse);if(!t)throw new SyntaxError("n-th rule couldn't be parsed ('"+s+"')");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 Fse=Vse,ev=lo,Use=ev.trueFunc,Wse=ev.falseFunc;function Vse(s){var t=s[0],e=s[1]-1;if(e<0&&t<=0)return Wse;if(t===-1)return function(n){return n<=e};if(t===0)return function(n){return n===e};if(t===1)return e<0?Use: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 tv=zse,rv=Fse;Mc.exports=function(t){return rv(tv(t))};Mc.exports.parse=tv;Mc.exports.compile=rv;var $se=Mc.exports,Vo=$se,nv=lo,Yse=_y,Rs=nv.trueFunc,vn=nv.falseFunc,Gse=Yse.rules.equals;function jn(s,t){var e={name:s,value:t};return function(n,i,o){return Gse(n,e,o)}}function $o(s,t){return function(e){return!!t.getParent(e)&&s(e)}}var fa={contains:function(s,t,e){var r=e.adapter;return function(i){return s(i)&&r.getText(i).indexOf(t)>=0}},icontains:function(s,t,e){var r=t.toLowerCase(),n=e.adapter;return function(o){return s(o)&&n.getText(o).toLowerCase().indexOf(r)>=0}},"nth-child":function(s,t,e){var r=Vo(t),n=e.adapter;return r===vn?r:r===Rs?$o(s,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)&&s(o)}},"nth-last-child":function(s,t,e){var r=Vo(t),n=e.adapter;return r===vn?r:r===Rs?$o(s,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)&&s(o)}},"nth-of-type":function(s,t,e){var r=Vo(t),n=e.adapter;return r===vn?r:r===Rs?$o(s,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)&&s(o)}},"nth-last-of-type":function(s,t,e){var r=Vo(t),n=e.adapter;return r===vn?r:r===Rs?$o(s,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)&&s(o)}},root:function(s,t,e){var r=e.adapter;return function(n){return!r.getParent(n)&&s(n)}},scope:function(s,t,e,r){var n=e.adapter;if(!r||r.length===0)return fa.root(s,t,e);function i(o,a){return typeof n.equals=="function"?n.equals(o,a):o===a}return r.length===1?function(o){return i(r[0],o)&&s(o)}:function(o){return r.indexOf(o)>=0&&s(o)}},checkbox:jn("type","checkbox"),file:jn("type","file"),password:jn("type","password"),radio:jn("type","radio"),reset:jn("type","reset"),image:jn("type","image"),submit:jn("type","submit"),hover:function(s,t,e){var r=e.adapter;return typeof r.isHovered=="function"?function(i){return s(i)&&r.isHovered(i)}:vn},visited:function(s,t,e){var r=e.adapter;return typeof r.isVisited=="function"?function(i){return s(i)&&r.isVisited(i)}:vn},active:function(s,t,e){var r=e.adapter;return typeof r.isActive=="function"?function(i){return s(i)&&r.isActive(i)}:vn}};function Hse(s,t){for(var e=0;s&&e<s.length;e++)if(t.isTag(s[e]))return s[e]}var zs={empty:function(s,t){return!t.getChildren(s).some(function(e){return t.isTag(e)||e.type==="text"})},"first-child":function(s,t){return Hse(t.getSiblings(s),t)===s},"last-child":function(s,t){for(var e=t.getSiblings(s),r=e.length-1;r>=0;r--){if(e[r]===s)return!0;if(t.isTag(e[r]))break}return!1},"first-of-type":function(s,t){for(var e=t.getSiblings(s),r=0;r<e.length;r++)if(t.isTag(e[r])){if(e[r]===s)return!0;if(t.getName(e[r])===t.getName(s))break}return!1},"last-of-type":function(s,t){for(var e=t.getSiblings(s),r=e.length-1;r>=0;r--)if(t.isTag(e[r])){if(e[r]===s)return!0;if(t.getName(e[r])===t.getName(s))break}return!1},"only-of-type":function(s,t){for(var e=t.getSiblings(s),r=0,n=e.length;r<n;r++)if(t.isTag(e[r])){if(e[r]===s)continue;if(t.getName(e[r])===t.getName(s))return!1}return!0},"only-child":function(s,t){for(var e=t.getSiblings(s),r=0;r<e.length;r++)if(t.isTag(e[r])&&e[r]!==s)return!1;return!0},link:function(s,t){return t.hasAttrib(s,"href")},selected:function(s,t){if(t.hasAttrib(s,"selected"))return!0;if(t.getName(s)!=="option")return!1;var e=t.getParent(s);if(!e||t.getName(e)!=="select"||t.hasAttrib(e,"multiple"))return!1;for(var r=t.getChildren(e),n=!1,i=0;i<r.length;i++)if(t.isTag(r[i]))if(r[i]===s)n=!0;else if(n){if(t.hasAttrib(r[i],"selected"))return!1}else return!1;return n},disabled:function(s,t){return t.hasAttrib(s,"disabled")},enabled:function(s,t){return!t.hasAttrib(s,"disabled")},checked:function(s,t){return t.hasAttrib(s,"checked")||zs.selected(s,t)},required:function(s,t){return t.hasAttrib(s,"required")},optional:function(s,t){return!t.hasAttrib(s,"required")},parent:function(s,t){return!zs.empty(s,t)},header:wg(["h1","h2","h3","h4","h5","h6"]),button:function(s,t){var e=t.getName(s);return e==="button"||e==="input"&&t.getAttributeValue(s,"type")==="button"},input:wg(["input","textarea","select","button"]),text:function(s,t){var e;return t.getName(s)==="input"&&(!(e=t.getAttributeValue(s,"type"))||e.toLowerCase()==="text")}};function wg(s){if(typeof Set<"u"){var t=new Set(s);return function(e,r){return t.has(r.getName(e))}}return function(e,r){return s.indexOf(r.getName(e))>=0}}function Qse(s,t,e){if(e===null){if(s.length>2&&t!=="scope")throw new Error("pseudo-selector :"+t+" requires an argument")}else if(s.length===2)throw new Error("pseudo-selector :"+t+" doesn't have any arguments")}var qse=/^(?:(?:nth|last|first|only)-(?:child|of-type)|root|empty|(?:en|dis)abled|checked|not)$/,iv={compile:function(s,t,e,r){var n=t.name,i=t.data,o=e.adapter;if(e&&e.strict&&!qse.test(n))throw new Error(":"+n+" isn't part of CSS3");if(typeof fa[n]=="function")return fa[n](s,i,e,r);if(typeof zs[n]=="function"){var a=zs[n];return Qse(a,n,i),a===vn?a:s===Rs?function(l){return a(l,o,i)}:function(l){return a(l,o,i)&&s(l)}}else throw new Error("unmatched pseudo-class :"+n)},filters:fa,pseudos:zs},Zse=_y,Kse=iv,Xse={__proto__:null,attribute:Zse.compile,pseudo:Kse.compile,tag:function(s,t,e){var r=t.name,n=e.adapter;return function(o){return n.getName(o)===r&&s(o)}},descendant:function(s,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=s(o),!a&&r&&r.add(o));return a}},_flexibleDescendant:function(s,t,e){var r=e.adapter;return function(i){for(var o=s(i);!o&&(i=r.getParent(i));)o=s(i);return o}},parent:function(s,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(i){return r.isTag(i)&&s(i)}},child:function(s,t,e){var r=e.adapter;return function(i){var o=r.getParent(i);return!!o&&s(o)}},sibling:function(s,t,e){var r=e.adapter;return function(i){for(var o=r.getSiblings(i),a=0;a<o.length;a++)if(r.isTag(o[a])){if(o[a]===i)break;if(s(o[a]))return!0}return!1}},adjacent:function(s,t,e){var r=e.adapter;return function(i){for(var o=r.getSiblings(i),a,c=0;c<o.length;c++)if(r.isTag(o[c])){if(o[c]===i)break;a=o[c]}return!!a&&s(a)}},universal:function(s){return s}},Jse=wc,_se=qy.parse,sv=lo,eoe=Nse,toe=Xy,Sg=Xse,ov=iv,Ys=sv.trueFunc,xn=sv.falseFunc,Vh=ov.filters;function wc(s,t,e){var r=cv(s,t,e);return av(r,t)}function av(s,t){var e=t.adapter;return function(n){return e.isTag(n)&&s(n)}}function cv(s,t,e){var r=_se(s,t);return uo(r,t,e)}function xu(s){return s.type==="pseudo"&&(s.name==="scope"||Array.isArray(s.data)&&s.data.some(function(t){return t.some(xu)}))}var roe={type:"descendant"},noe={type:"_flexibleDescendant"},ioe={type:"pseudo",name:"scope"},lv={};function soe(s,t,e){var r=t.adapter,n=!!e&&!!e.length&&e.every(function(i){return i===lv||!!r.getParent(i)});s.forEach(function(i){if(!(i.length>0&&uv(i[0])&&i[0].type!=="descendant"))if(n&&!(Array.isArray(i)?i.some(xu):xu(i)))i.unshift(roe);else return;i.unshift(ioe)})}function uo(s,t,e){s=s.filter(function(o){return o.length>0}),s.forEach(eoe);var r=Array.isArray(e);e=t&&t.context||e,e&&!r&&(e=[e]),soe(s,t,e);var n=!1,i=s.map(function(o){if(o[0]&&o[1]&&o[0].name==="scope"){var a=o[1].type;r&&a==="descendant"?o[1]=noe:(a==="adjacent"||a==="sibling")&&(n=!0)}return ooe(o,t,e)}).reduce(aoe,xn);return i.shouldTestNextSiblings=n,i}function uv(s){return toe[s.type]<0}function ooe(s,t,e){return s.reduce(function(r,n){if(r===xn)return r;if(!(n.type in Sg))throw new Error("Rule type "+n.type+" is not supported by css-select");return Sg[n.type](r,n,t,e)},t&&t.rootFunc||Ys)}function aoe(s,t){return t===xn||s===Ys?s:s===xn||t===Ys?t:function(r){return s(r)||t(r)}}function hv(s){return s.some(uv)}Vh.not=function(s,t,e,r){var n={xmlMode:!!(e&&e.xmlMode),strict:!!(e&&e.strict),adapter:e.adapter};if(n.strict&&(t.length>1||t.some(hv)))throw new Error("complex selectors in :not aren't allowed in strict mode");var i=uo(t,n,r);return i===xn?s:i===Ys?xn:function(a){return!i(a)&&s(a)}};Vh.has=function(s,t,e){var r=e.adapter,n={xmlMode:!!(e&&e.xmlMode),strict:!!(e&&e.strict),adapter:r},i=t.some(hv)?[lv]:null,o=uo(t,n,i);return o===xn?xn:o===Ys?function(c){return r.getChildren(c).some(r.isTag)&&s(c)}:(o=av(o,e),i?function(c){return s(c)&&(i[0]=c,r.existsOne(o,r.getChildren(c)))}:function(c){return s(c)&&r.existsOne(o,r.getChildren(c))})};Vh.matches=function(s,t,e,r){var n={xmlMode:!!(e&&e.xmlMode),strict:!!(e&&e.strict),rootFunc:s,adapter:e.adapter};return uo(t,n,r)};wc.compileToken=uo;wc.compileUnsafe=cv;wc.Pseudos=ov;var coe=br,$h=fse,dv=lo.falseFunc,ho=Jse;function fv(s){return function(e,r,n){return r=r||{},r.adapter=r.adapter||$h,s(e,r,n)}}var Yh=fv(ho),gv=fv(ho.compileUnsafe);function pv(s){return function(e,r,n){return n=n||{},n.adapter=n.adapter||$h,typeof e!="function"&&(e=gv(e,n,r)),e.shouldTestNextSiblings&&(r=uoe(n&&n.context||r,n.adapter)),Array.isArray(r)?r=n.adapter.removeSubsets(r):r=n.adapter.getChildren(r),s(e,r,n)}}function loe(s,t){var e=t.getSiblings(s);if(!Array.isArray(e))return[];for(e=e.slice(0);e.shift()!==s;);return e}function uoe(s,t){Array.isArray(s)||(s=[s]);for(var e=s.slice(0),r=0,n=s.length;r<n;r++){var i=loe(e[r],t);e.push.apply(e,i)}return e}var Gh=pv(function(t,e,r){return t===dv||!e||e.length===0?[]:r.adapter.findAll(t,e)}),hoe=pv(function(t,e,r){return t===dv||!e||e.length===0?null:r.adapter.findOne(t,e)});function doe(s,t,e){return e=e||{},e.adapter=e.adapter||$h,(typeof t=="function"?t:Yh(t,e))(s)}function br(s,t,e){return Gh(s,t,e)}br.compile=Yh;br.filters=ho.Pseudos.filters;br.pseudos=ho.Pseudos.pseudos;br.selectAll=Gh;br.selectOne=hoe;br.is=doe;br.parse=Yh;br.iterate=Gh;br._compileUnsafe=gv;br._compileToken=ho.compileToken;const mv=ln(coe);Ze(Array);function Yo(s){return s.nodeType===1||Gt.isSpriteNode(s.nodeName)}function Ii(s){return Array.from(s.childNodes||[])}function Ru(s){return Gt.isSpriteNode(s.nodeName)?s.parent||s.canvas||s.container:s.parentElement}function foe(s){let t=s.length,e,r,n;for(;--t>-1;){for(e=r=s[t],s[t]=null,n=!0;r;){if(s.indexOf(r)>-1){n=!1,s.splice(t,1);break}r=Ru(r)}n&&(s[t]=e)}return s}const Hh={isTag:Yo,existsOne(s,t){return t.some(e=>Yo(e)?s(e)||Hh.existsOne(s,Ii(e)):!1)},getSiblings(s){const t=Ru(s);return t&&Ii(t)},getChildren:Ii,getParent:Ru,getAttributeValue(s,t){if(s.nodeType===1&&t==="class"||t==="id")return s[t];if(this.hasAttrib(s,t)){let e=s.attributes[t];return Array.isArray(e)&&(e=`[${e.join()}]`),String(e)}},hasAttrib(s,t){return s.attributes[t]!=null},removeSubsets:foe,getName(s){return s.tagName?s.tagName.toLowerCase():null},findOne:function s(t,e){let r=null;for(let n=0,i=e.length;n<i&&!r;n++)if(t(e[n]))r=e[n];else{const o=Ii(e[n]);o&&o.length>0&&(r=s(t,o))}return r},findAll:function s(t,e){let r=[];for(let n=0,i=e.length;n<i;n++){if(!Yo(e[n]))continue;t(e[n])&&r.push(e[n]);const o=Ii(e[n]);o&&(r=r.concat(s(t,o)))}return r},getText:function s(t){return Array.isArray(t)?t.map(s).join(""):Yo(t)?s(Ii(t)):t.nodeType===3?t.nodeValue:Gt.isSpriteNode(t.nodeName)?t.text:""}};function yv(s){if(typeof s!="string")return s;let t=s.match(/\[(bgcolor|fillColor|strokeColor|color)\s*=\s*['"]?\w+['"]?\]/g);return t&&(t=t.map(e=>{const r=e.slice(1,-1).split("="),n=En(r[1].replace(/['"]/g,""));return[e,`[${r[0]}="${n}"]`]}),t.forEach(([e,r])=>{s=s.replace(e,r)})),t=s.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(i=>i.trim());return[e,`[${r[0]}="[${n}]"]`]}),t.forEach(([e,r])=>{s=s.replace(e,r)})),s}function Go(s,t){return mv.selectAll(yv(s),t,{adapter:Hh})}function Tg(s,t){return mv.selectOne(yv(s),t,{adapter:Hh})}Ze(Array);const Ig=Symbol("zOrder"),vt=Symbol("ordered"),Lt=Symbol("children"),Rl=Symbol("sealed"),Va=class Va extends co{constructor(t={}){super(t),this[Lt]=[],this[vt]=null,this[Ig]=0}get childNodes(){return this[Lt]}get children(){return this[Lt]}get orderedChildren(){return this[vt]||(this[vt]=[...this[Lt]],this[vt].sort((t,e)=>t.zIndex-e.zIndex||t.zOrder-e.zOrder)),this[vt]}append(...t){return t.map(e=>this.appendChild(e))}appendChild(t){return t.remove(),this[Lt].push(t),t.connect(this,this[Ig]++),this[vt]&&(this[vt].length&&t.zIndex<this[vt][this[vt].length-1].zIndex?this.reorder():this[vt].push(t)),t}cloneNode(t=!1){const e=super.cloneNode();return t&&this[Lt].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[Rl]&&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 Tg(`#${t}`,this)}getElementsByClassName(t){return Go(`.${t}`,this)}getElementsByName(t){return Go(`[name="${t}"]`,this)}getElementsByTagName(t){return Go(t,this)}insertBefore(t,e){if(e==null)return this.appendChild(t);t.remove();const r=this[Lt].indexOf(e);if(r<0)throw new Error("Invalid reference node.");const n=e.zOrder;for(let i=r;i<this[Lt].length;i++){const o=this[Lt][i].zOrder,a=this[Lt][i];delete a.zOrder,Object.defineProperty(a,"zOrder",{value:o+1,writable:!1,configurable:!0})}if(this[Lt].splice(r,0,t),t.connect(this,n),this[vt])if(t.zIndex!==e.zIndex)this.reorder();else{const i=this[vt].indexOf(e);this[vt].splice(i,0,t)}return t}querySelector(t){return Tg(t,this)}querySelectorAll(t){return Go(t,this)}replaceChild(t,e){t.remove();const r=this[Lt].indexOf(e);if(r<0)throw new Error("Invalid reference node.");if(this[Lt][r]=t,t.connect(this,e.zOrder),this[vt])if(t.zIndex!==e.zIndex)this.reorder();else{const n=this[vt].indexOf(e);this[vt][n]=t}return e.disconnect(this),t}removeAllChildren(){const t=this[Lt];for(let e=t.length-1;e>=0;e--)t[e].remove()}removeChild(t){const e=this[Lt].indexOf(t);if(e>=0){if(this[Lt].splice(e,1),this[vt]){const r=this[vt].indexOf(t);this[vt].splice(r,1)}return t.disconnect(this),t}return null}reorder(){this[vt]=null}seal(){function t(i,o){const a=[];for(let c=0;c<i.length;c++){const l=[...i[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 ft.Figure2D,n=this.localMatrix;for(let i=0;i<e.length;i++){let o=e[i];if(o instanceof Va&&(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[Rl]=!0,this.clientBox=r,{clientBox:r,localMatrix:n}}setResolution({width:t,height:e}){super.setResolution({width:t,height:e}),this[Lt].forEach(r=>{r.setResolution({width:t,height:e})})}updateContours(){this[Rl]||super.updateContours()}};x(Va,"Attr",ob);let dt=Va;Gt.registerNode(dt,"group");Ze(Array);const ku={};function xa(s,t){if(ku[s])return ku[s];const e=ft.ENV.loadImage(s,{alias:t,useImageBitmap:!1});return e??s}async function vv(s,t,e){let r=t;if(typeof t=="string"&&(r=xa(t)),r&&typeof r.then=="function"&&(r=await r),t===s.attributes.texture){r&&r.image&&(r.sourceRect&&(s.attributes.sourceRect=r.sourceRect),s.textureImageRotated=!!r.rotated,r=r.image);const{width:n,height:i,textureRect:o}=s.attributes,a=s.textureImage;s.textureImage=r,e&&a!==r&&!o&&(n==null||i==null)&&s.updateContours(),s.forceUpdate()}return r}const wr=Symbol("textureMap");function Mv(s,t){if(t[wr]=t[wr]||new Map,t[wr].has(s))return t[wr].get(s);const e=t.createTexture(s);return!/^blob:/.test(s.src)&&typeof s.getContext!="function"&&t[wr].set(s,e),e}function wv(s,t){if(t[wr]&&t[wr].has(s)){const e=t[wr].get(s);return t.deleteTexture(e),t[wr].delete(s),!0}return!1}const kl=Symbol("textureContext");function Sv(s,t){const e=s.textureImage instanceof String?String(s.textureImage):s.textureImage,r=s.textureImageRotated,n=t.texture,i=s.renderer;if(e){const o=s.originalContentRect;let a=s.attributes.textureRect;const c=s.attributes.textureRepeat,l=s.attributes.sourceRect;if(!n||s[kl]&&s[kl]!==i||n.image!==e||n.options.repeat!==c||!iu(n.options.rect,a)||!iu(n.options.srcRect,l)){const u=Mv(e,i);a?(a[0]+=o[0],a[1]+=o[1]):a=o;let h=null;n&&!i[wr].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(),s[kl]=i}}else if(n){let o=null;!i[wr].has(n.image)&&(!n.options||!n.options.hidden)&&(o=t.uniforms.u_texSampler),t.setTexture(null),o&&o.delete&&o.delete()}}async function goe(s,t){typeof t=="string"&&(t=await(await fetch(t,{method:"GET",mode:"cors",cache:"default"})).json());const e=await xa(s),r=t.frames;return Object.entries(r).forEach(([n,i])=>{const{x:o,y:a,w:c,h:l}=i.frame;let u=[o,a,c,l];const h=i.rotated;h&&(u=[u[0],u[1],u[3],u[2]]),ku[n]={image:e,sourceRect:u,rotated:h}}),e}Ze(Array);const poe={antialias:!0,autoRender:!0,alpha:!0},ds=Symbol("autoRender"),fs=Symbol("renderer"),Cg=Symbol("timeline"),Nt=Symbol("prepareRender"),Al=Symbol("tickRender"),Gr=Symbol("pass"),fn=Symbol("fbo"),Fn=Symbol("tickers"),Un=Symbol("destroyed"),gn=Symbol("layerTransformInvert");function moe(s){if(!s||!s.options)return null;let t="2d";return s.glRenderer&&(t=s.isWebGL2?"webgl2":"webgl"),s.options.contextType=t,s.options.webgl2=t==="webgl2",t}let Jn=class extends dt{constructor(t={}){if(super(),!t.canvas){const{width:i,height:o}=this.getResolution(),a=ft.ENV.createCanvas(i,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({},poe,t);this[ds]=r.autoRender,delete t.autoRender;const n=r.Renderer||ft.Renderer;this[fs]=new n(e,r),moe(this[fs]),this.options=t,this.id=t.id,this[Gr]=[],this.setResolution(e),this.canvas=e,this[Cg]=new Ty,this[Un]=!1,this.__mouseCapturedTarget=null,this[gn]=null}get autoRender(){return this[ds]}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[Gr]}get prepareRender(){return this[Nt]?this[Nt]:Promise.resolve()}get renderer(){return this[fs]}transferToImageBitmap(){const t=this.canvas;if(!t||typeof t.transferToImageBitmap!="function")throw new Error("transfer-to-image-bitmap-unavailable");const e=t.transferToImageBitmap();if(!e)throw new Error("transfer-to-image-bitmap-empty");return e}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[Cg]}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[gn])return this[gn];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[gn]=Ma(Array.of(0,0,0,0,0,0),t),this[gn])}forceContextLoss(){const t=this.renderer.glRenderer&&this.renderer.glRenderer.gl;if(t&&typeof t.getExtension=="function"){const e=t.getExtension("WEBGL_lose_context");if(e)return e.loseContext(),!0}return!1}destroy(){if(this[Un])return!1;this[Un]=!0,this[ds]=!1;let t;const e=i=>{try{i()}catch(o){t=t||o}};this[Fn]=[],this.__mouseCapturedTarget=null,e(()=>this.cancelPendingRender()),e(()=>this.removeAllChildren()),e(()=>this.deactivateAnimations()),this[Gr]=[],this[fn]=null;const r=this.renderer.glRenderer;let n=[];if(r&&r.programs&&(e(()=>{n=[...r.programs]}),n.forEach(i=>e(()=>r.deleteProgram(i)))),e(()=>this.forceContextLoss()),e(()=>this.remove()),t)throw t;return!0}addPass({vertex:t,fragment:e,options:r,uniforms:n}={}){if(this.renderer.glRenderer){const{width:i,height:o}=this.getResolution(),a=this.renderer.createPassProgram({vertex:t,fragment:e,options:r}),c=new ft.Figure2D;c.rect(0,0,i/this.displayRatio,o/this.displayRatio);const l=new ft.Mesh2D(c);return l.setUniforms(n),l.setProgram(a),this[Gr].push(l),this.forceUpdate(),l}return null}deleteTexture(t){return wv(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 i=this.layerTransformInvert;if(i){r=t.x,n=t.y;const a=i,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 i&&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[Un]&&!this[Nt])if(this.parent&&this.parent.hasOffscreenCanvas){this.parent.forceUpdate();let t=null;const e=new Promise(r=>{t=r});e._resolve=t,this[Nt]=e}else{let t=null,e=null;const r=new Promise(n=>{t=n,this[ds]&&(e=rn(()=>{delete r._requestID,this.render()}))});r._resolve=t,r._requestID=e,this[Nt]=r}}getFBO(){const t=this.renderer.glRenderer,{width:e,height:r}=this.getResolution();return t&&(!this[fn]||this[fn].width!==e||this[fn].height!==r)?(this[fn]={width:e,height:r,target:t.createFBO(),buffer:t.createFBO(),swap(){[this.target,this.buffer]=[this.buffer,this.target]}},this[fn]):this[fn]?this[fn]:null}updateGlobalTransform(){if(this.layerTransformInvert){const t=this.renderer,e=t.__globalTransformMatrix||t.globalTransformMatrix;t.__globalTransformMatrix=e;const r=ei(1,0,0,1,0,0);t.setGlobalTransform(...Nr(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[gn];if(this[gn]=null,this.updateGlobalTransform(),n&&!this.layerTransformInvert){const i=this.renderer,o=i.__globalTransformMatrix||i.globalTransformMatrix;i.setGlobalTransform(...o)}}}_prepareRenderFinished(){this[Nt]&&(this[Nt]._requestID!=null&&ri(this[Nt]._requestID),this[Nt]._resolve(),delete this[Nt])}cancelPendingRender(){const t=!!this[Nt];return this._prepareRenderFinished(),t}render({clear:t=!0}={}){if(!this[Un])try{const e=this[Gr].length?this.getFBO():null;e&&this.renderer.glRenderer.bindFBO(e.target),t&&this[fs].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,i=this[Gr].length,{width:o,height:a}=this.getResolution(),c=[0,0,o/this.displayRatio,a/this.displayRatio];this[Gr].forEach((l,u)=>{l.blend=!0,l.setTexture(e.target.texture,{rect:c}),u===i-1?n.bindFBO(null):(e.swap(),n.bindFBO(e.target)),this[fs].clear(),this.renderer.drawMeshes([l])})}}finally{this._prepareRenderFinished()}}setResolution({width:t,height:e}){const r=this.renderer,n=r.__globalTransformMatrix||r.globalTransformMatrix,i=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[Gr].length&&this[Gr].forEach(f=>{const g=new ft.Figure2D;g.rect(0,0,t/this.displayRatio,e/this.displayRatio),f.contours=g.contours}));const[u,h]=this.renderOffset,d=this.displayRatio;(i!==u||o!==h||a!==d)&&(r.setGlobalTransform(d,0,0,d,u,h),r.__globalTransformMatrix=null,this[gn]=null,this.updateGlobalTransform(),this.forceUpdate())}tick(t=null,{duration:e=1/0,...r}={}){if(this[Un])return;const n=this.timeline.fork(r),i=this;this[Fn]=this[Fn]||[],this[Fn].push({handler:t,duration:e});const o=()=>{let a=null,c=null;const l=()=>{const u=this[Fn].map(({handler:h,duration:d})=>{const f=Math.min(1,n.currentTime/d);return{value:h?h(n.currentTime,f):null,p:f}});i[Al]||(i[Al]=Promise.resolve().then(()=>{if(delete i[Al],!i[Un]){i[ds]&&i.render();for(let h=u.length-1;h>=0;h--){const{value:d,p:f}=u[h];(d===!1||f>=1)&&this[Fn].splice(h,1)}this[Fn].length>0&&o()}}))};if(this[Nt]&&this[Nt]._type!=="ticker"&&(ri(this[Nt]._requestID),delete this[Nt]),!this[Nt]){const u=new Promise(h=>{a=h,c=rn(l)});u._resolve=a,u._requestID=c,u._type="ticker",this[Nt]=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(),i=this.renderOffset,o=[this.canvas.clientWidth,this.canvas.clientHeight];t=t*o[0]/r+i[0],e=e*o[1]/n+i[1];const a=this.displayRatio;return t*=a,e*=a,[t,e]}toLocalPos(t,e){const{width:r,height:n}=this.getResolution(),i=this.renderOffset,o=[this.canvas.clientWidth,this.canvas.clientHeight];t=t*r/o[0]-i[0],e=e*n/o[1]-i[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]}};Gt.registerNode(Jn,"layer");Ze(Array);const bg=Symbol("inited");let ks=null;typeof Worker=="function"&&(ks=class extends Worker{constructor(s){if(s.worker===!0&&(s.worker=`./${s.id}.worker.js`),super(s.worker),this.options=s,!s.canvas){const{width:t,height:e}=this.getResolution(),r=ft.ENV.createCanvas(t,e,{offscreen:!1});r.style&&(r.style.position="absolute"),r.dataset&&(r.dataset.layerId=s.id),s.canvas=r}this.canvas=s.canvas}get id(){return this.options.id}setResolution({width:s,height:t}){if(this[bg])this.postMessage({type:"resolution_change",width:s,height:t});else{this.canvas.width=s,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[bg]=!0}}getResolution(){if(this.canvas){const{width:s,height:t}=this.canvas;return{width:s,height:t}}return{width:300,height:150}}remove(){return this.parent&&this.parent.removeChild?(this.parent.removeChild(this),!0):!1}connect(s,t){Object.defineProperty(this,"parent",{value:s,writable:!1,configurable:!0}),Object.defineProperty(this,"zOrder",{value:t,writable:!1,configurable:!0})}disconnect(){delete this.parent,delete this.zOrder}dispatchPointerEvent(s){this.postMessage({type:"event",event:{cancelBubble:s.cancelBubble,bubbles:s.bubbles,detail:s.detail,identifier:s.identifier,layerX:s.layerX,layerY:s.layerY,originalX:s.originalX,originalY:s.originalY,type:s.type,x:s.x,y:s.y}})}});Ze(Array);function yoe(s,{offsetTop:t=0,offsetLeft:e=0,displayRatio:r=1}={}){let n,i;const o=[],{left:a,top:c,width:l,height:u}=s.target.getBoundingClientRect(),h=s.target.width,d=s.target.height,f=s.changedTouches||[s];for(let y=0;y<f.length;y++){const S=f[y],b=S.identifier,{clientX:I,clientY:N}=S;I!=null&&N!=null&&o.push({x:Math.round((I|0)-a),y:Math.round((N|0)-c),identifier:b})}o.length<=0&&o.push({x:n,y:i});const g=[];return o.forEach(y=>{y.x!=null&&y.y!=null&&(n=(y.x*h/l-e)/r,i=(y.y*d/u-t)/r);const S=new ni(s);Object.defineProperties(S,{layerX:{value:n,configurable:!0},layerY:{value:i,configurable:!0},originalX:{value:y.x},originalY:{value:y.y},x:{value:n,configurable:!0},y:{value:i,configurable:!0},identifier:{value:y.identifier}}),g.push(S)}),g}Ze(Array);const ga=Symbol("enteredTargets");function Eg(s){return s.id=s.id||`_layer${Math.random().toString(36).slice(2,12)}`,s.dataset||(s.dataset={}),s.dataset.layerId=s.id,s.connect=(t,e)=>{s.parent=t,Object.defineProperty(s,"zOrder",{value:e,writable:!1,configurable:!0})},s.disconnect=t=>{delete s.zOrder},s.canvas=s,s.getResolution=()=>({width:0,height:0}),s.setResolution=()=>!1,s.options={handleEvent:!1},s}function xg(s,t){const e=s.children;let r=null;for(let n=0;n<e.length;n++){const i=e[n];if((t===i||r!=null)&&(r=i),r&&r!==t&&!r.offscreen)return r.canvas}return null}function Rg(s,t){const[e,r]=s.renderOffset,{width:n,height:i}=s.getResolution(),o=s.displayRatio;s.renderer.drawImage(t.canvas,-e/o,-r/o,n/o,i/o)}const Pl={};function voe(s){const t=["mousedown","mouseup","mousemove","mousewheel","wheel","touchstart","touchend","touchmove","touchcancel","click","dblclick","longpress","tap","contextmenu"],e=s.container;e.addEventListener("mouseleave",r=>{const n=s[ga];if(n.size){const i=new ni("mouseleave");i.setOriginalEvent(r),[...n].forEach(o=>{o.dispatchEvent(i)}),s[ga].clear()}},{passive:!0}),t.forEach(r=>{e.addEventListener(r,n=>{const{left:i,top:o,displayRatio:a}=s.options,c=s.orderedChildren;yoe(n,{offsetLeft:i,offsetTop:o,displayRatio:a}).forEach(u=>{const h=u.identifier;if(u.type==="touchmove"||u.type==="touchend"){const f=Pl[h];f&&f.dispatchEvent(u),u.type==="touchend"&&delete Pl[h]}else{for(let f=c.length-1;f>=0;f--){const g=c[f];if(g.options.handleEvent!==!1){if(g.dispatchPointerEvent(u)&&u.target!==g)break;u.cancelBubble=!1}}if(u.target===c[0])for(let f=c.length-1;f>=0;f--){const g=c[f];if(g.options.handleEvent!==!1){u.target=g;break}}}const d=u.target;if(u.type==="touchstart"&&(Pl[h]=u.target),u.type==="mousemove"){const f=s[ga];let g;if(d){const b=d.ancestors||[];g=new Set([d,...b])}else g=new Set;const y=Object.entries(n);if(!f.has(d)&&d){const b=new ni("mouseenter");b.setOriginalEvent(n),y.forEach(([N,T])=>{b[N]=T}),f.add(d),d.dispatchEvent(b);const I=d.ancestors;I&&I.forEach(N=>{N instanceof fc&&!f.has(N)&&(f.add(N),N.dispatchEvent(b))})}const S=new ni("mouseleave");S.setOriginalEvent(n),y.forEach(([b,I])=>{S[b]=I}),[...f].forEach(b=>{g.has(b)||(f.delete(b),b.dispatchEvent(S))})}})},{passive:r!=="contextmenu"})})}function Ho(s,t){if(t&&t.style){let{width:e,height:r,mode:n,container:i}=s;const{clientWidth:o,clientHeight:a}=i;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 gs=Symbol("offscreenLayerCount");class Sc extends dt{constructor(t={}){if(super(),!t.container)if(typeof ft.ENV.Container=="function")t.container=new ft.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[ga]=new Set,this.setResolution(t),voe(this),this[gs]=0}get hasOffscreenCanvas(){return this[gs]>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 Jn)&&!(t instanceof ks)&&Eg(t);const e=super.appendChild(t),r=t.canvas;return t.offscreen?this[gs]++:this.container.appendChild(r),Ho(this.options,r),t.setResolution(this.getResolution()),e}forceUpdate(){this.hasOffscreenCanvas&&!this._requestID&&(this._requestID=rn(()=>{delete this._requestID,this.render()}))}insertBefore(t,e){!(t instanceof Jn)&&!(t instanceof ks)&&Eg(t);const r=super.insertBefore(t,e),n=t.canvas;if(!t.offscreen){const i=xg(this,t);this.container.insertBefore(n,i)}return Ho(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 i;return n?i=new ks(e):i=new Jn(e),this.appendChild(i),i}async preload(...t){const e=[],r=[],n=[];for(let i=0;i<t.length;i++){const o=t[i];let a;if(typeof o=="string")a=xa(o);else if(Array.isArray(o))a=goe(...o);else{const{id:c,src:l}=o;a=xa(l,c)}a instanceof Promise||(a=Promise.resolve(a)),r.push(a.then(c=>{e.push(c),n[i]=c;const l=new ni({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[gs]--}return e}render(){const t=this.orderedChildren;let e=null;const r=[];for(let n=0;n<t.length;n++){const i=t[n],o=r.length>0;if(i instanceof Jn&&!i.offscreen)if(!i.autoRender)o&&(console.warn("Some offscreen canvas will not be rendered."),r.length=0);else if(e=i,o){i.renderer.clear();for(let a=0;a<r.length;a++){const c=r[a];c.render(),Rg(i,c)}r.length=0,i.render({clear:!1})}else i.prepareRender&&i.render();else i.offscreen?e?(i.prepareRender&&i.render(),Rg(e,i)):r.push(i):i instanceof ks&&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[gs]--;const n=t.canvas;if(!t.offscreen){const i=xg(this,t);this.container.insertBefore(n,i)}return Ho(this.options,n),t.setResolution(this.getResolution()),r}resize(){const t=this.options;this.children.forEach(e=>{Ho(t,e.canvas)}),this.setResolution(t),this.dispatchEvent({type:"resize"})}setResolution({width:t,height:e}={}){const r=this.container,{clientWidth:n,clientHeight:i}=r;(t==null||e==null)&&(t=t??n,e=e??i);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/i,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=i*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:i}=this.getResolution();this[r]=this[r]||ft.ENV.createCanvas(n,i,{offscreen:t});const o=this[r].getContext("2d");e=e||this.orderedChildren,this[r].width=n,this[r].height=i;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,i)}}return this[r]}}typeof document<"u"&&(Sc.prototype.layer3d=function(s,t={}){const e=t.url||"https://unpkg.com/sprite-extend-3d/dist/sprite-extend-3d.min.js";return new Promise((r,n)=>{const i=document.createElement("script");i.async=!1,i.src=e,i.onload=()=>{try{r(this.layer3d(s,t))}catch(o){n(o)}},document.documentElement.appendChild(i)})});Gt.registerNode(Sc,"scene");var Tv={exports:{}};(function(s,t){(function(e,r){s.exports=r()})(St,function(){var e=function(){function E(D,P){var z=[],j=!0,A=!1,R=void 0;try{for(var L=D[Symbol.iterator](),W;!(j=(W=L.next()).done)&&(z.push(W.value),!(P&&z.length===P));j=!0);}catch(Y){A=!0,R=Y}finally{try{!j&&L.return&&L.return()}finally{if(A)throw R}}return z}return function(D,P){if(Array.isArray(D))return D;if(Symbol.iterator in Object(D))return E(D,P);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),r=Math.PI*2,n=function(D,P,z,j,A,R,L){var W=D.x,Y=D.y;W*=P,Y*=z;var H=j*W-A*Y,ie=A*W+j*Y;return{x:H+R,y:ie+L}},i=function(D,P){var z=1.3333333333333333*Math.tan(P/4),j=Math.cos(D),A=Math.sin(D),R=Math.cos(D+P),L=Math.sin(D+P);return[{x:j-A*z,y:A+j*z},{x:R+L*z,y:L-R*z},{x:R,y:L}]},o=function(D,P,z,j){var A=D*j-P*z<0?-1:1,R=Math.sqrt(D*D+P*P),L=Math.sqrt(D*D+P*P),W=D*z+P*j,Y=W/(R*L);return Y>1&&(Y=1),Y<-1&&(Y=-1),A*Math.acos(Y)},a=function(D,P,z,j,A,R,L,W,Y,H,ie,O){var V=Math.pow(A,2),Z=Math.pow(R,2),$=Math.pow(ie,2),ee=Math.pow(O,2),se=V*Z-V*ee-Z*$;se<0&&(se=0),se/=V*ee+Z*$,se=Math.sqrt(se)*(L===W?-1:1);var ce=se*A/R*O,me=se*-R/A*ie,pe=H*ce-Y*me+(D+z)/2,B=Y*ce+H*me+(P+j)/2,F=(ie-ce)/A,J=(O-me)/R,oe=(-ie-ce)/A,K=(-O-me)/R,te=o(1,0,F,J),w=o(F,J,oe,K);return W===0&&w>0&&(w-=r),W===1&&w<0&&(w+=r),[pe,B,te,w]},c=function(D){var P=D.px,z=D.py,j=D.cx,A=D.cy,R=D.rx,L=D.ry,W=D.xAxisRotation,Y=W===void 0?0:W,H=D.largeArcFlag,ie=H===void 0?0:H,O=D.sweepFlag,V=O===void 0?0:O,Z=[];if(R===0||L===0)return[];var $=Math.sin(Y*r/360),ee=Math.cos(Y*r/360),se=ee*(P-j)/2+$*(z-A)/2,ce=-$*(P-j)/2+ee*(z-A)/2;if(se===0&&ce===0)return[];R=Math.abs(R),L=Math.abs(L);var me=Math.pow(se,2)/Math.pow(R,2)+Math.pow(ce,2)/Math.pow(L,2);me>1&&(R*=Math.sqrt(me),L*=Math.sqrt(me));var pe=a(P,z,j,A,R,L,ie,V,$,ee,se,ce),B=e(pe,4),F=B[0],J=B[1],oe=B[2],K=B[3],te=Math.max(Math.ceil(Math.abs(K)/(r/4)),1);K/=te;for(var w=0;w<te;w++)Z.push(i(oe,K)),oe+=K;return Z.map(function(C){var U=n(C[0],R,L,ee,$,F,J),G=U.x,_=U.y,re=n(C[1],R,L,ee,$,F,J),ne=re.x,X=re.y,ae=n(C[2],R,L,ee,$,F,J),ue=ae.x,he=ae.y;return{x1:G,y1:_,x2:ne,y2:X,x:ue,y:he}})},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(E){var D=[];return E.replace(u,function(P,z,j){var A=z.toLowerCase();for(j=f(j),A=="m"&&j.length>2&&(D.push([z].concat(j.splice(0,2))),A="l",z=z=="m"?"l":"L");;){if(j.length==l[A])return j.unshift(z),D.push(j);if(j.length<l[A])throw new Error("malformed path data");D.push([z].concat(j.splice(0,l[A])))}}),D}var d=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function f(E){var D=E.match(d);return D?D.map(Number):[]}function g(E){var D=E[0][0],P=E[0][1],z=D,j=P;return E.forEach(function(A){var R=A[0],L=A[2],W=A[4],Y=A[6],H=A[1],ie=A[3],O=A[5],V=A[7];D=Math.min(D,R,L,W,Y),P=Math.min(P,H,ie,O,V),z=Math.max(z,R,L,W,Y),j=Math.max(j,H,ie,O,V)}),[D,P,z,j]}function y(E,D){return Math.sqrt(Math.pow(E[0]-D[0],2)+Math.pow(E[1]-D[1],2))+Math.sqrt(Math.pow(E[2]-D[2],2)+Math.pow(E[3]-D[3],2))}function S(E,D){var P=E[0],z=E[2],j=E[4],A=E[6],R=E[1],L=E[3],W=E[5],Y=E[7],H=D[0],ie=D[2],O=D[4],V=D[6],Z=D[1],$=D[3],ee=D[5],se=D[7];return Math.sqrt(Math.pow(H-P,2)+Math.pow(Z-R,2))+Math.sqrt(Math.pow(ie-z,2)+Math.pow($-L,2))+Math.sqrt(Math.pow(O-j,2)+Math.pow(ee-W,2))+Math.sqrt(Math.pow(V-A,2)+Math.pow(se-Y,2))}function b(E,D){var P=N(E.length),z=[];P.forEach(function(A){var R=0,L=0;A.forEach(function(W){R+=S(E[W],D[L++])}),z.push({index:A,distance:R})}),z.sort(function(A,R){return A.distance-R.distance});var j=[];return z[0].index.forEach(function(A){j.push(E[A])}),j}function I(E,D){var P=T(E.length),z=[];P.forEach(function(A){var R=0;A.forEach(function(L){R+=y(g(E[L]),g(D[L]))}),z.push({index:A,distance:R})}),z.sort(function(A,R){return A.distance-R.distance});var j=[];return z[0].index.forEach(function(A){j.push(E[A])}),j}function N(E){for(var D=[],P=0;P<E;P++){for(var z=[],j=0;j<E;j++){var A=j+P;A>E-1&&(A-=E),z[A]=j}D.push(z)}return D}function T(E){for(var D=[],P=0;P<E;P++)D.push(P);return p(D)}function p(E){var D=[],P=[];function z(j){var A,R;for(A=0;A<j.length;A++)R=j.splice(A,1)[0],P.push(R),j.length==0&&D.push(P.slice()),z(j),j.splice(A,0,R),P.pop();return D}return z(E)}var m={};m.parser=h,m.lerpCurve=function(E,D,P){return m.lerpPoints(E[0],E[1],D[0],D[1],P).concat(m.lerpPoints(E[2],E[3],D[2],D[3],P)).concat(m.lerpPoints(E[4],E[5],D[4],D[5],P)).concat(m.lerpPoints(E[6],E[7],D[6],D[7],P))},m.lerpPoints=function(E,D,P,z,j){return[E+(P-E)*j,D+(z-D)*j]},m.q2b=function(E,D,P,z,j,A){return[E,D,(E+2*P)/3,(D+2*z)/3,(j+2*P)/3,(A+2*z)/3,j,A]},m.path2shapes=function(E){for(var D=m.parser(E),P=0,z=0,j=0,A=D.length,R=[],L=null,W=void 0,Y=void 0,H=void 0,ie=void 0,O=void 0,V=void 0,Z=void 0;j<A;j++){var $=D[j],ee=$[0],se=D[j-1];switch(ee){case"m":O=R.length,R[O]=[],L=R[O],P=P+$[1],z=z+$[2];break;case"M":O=R.length,R[O]=[],L=R[O],P=$[1],z=$[2];break;case"l":L.push([P,z,P,z,P,z,P+$[1],z+$[2]]),P+=$[1],z+=$[2];break;case"L":L.push([P,z,$[1],$[2],$[1],$[2],$[1],$[2]]),P=$[1],z=$[2];break;case"h":L.push([P,z,P,z,P,z,P+$[1],z]),P+=$[1];break;case"H":L.push([P,z,$[1],z,$[1],z,$[1],z]),P=$[1];break;case"v":L.push([P,z,P,z,P,z,P,z+$[1]]),z+=$[1];break;case"V":L.push([P,z,P,$[1],P,$[1],P,$[1]]),z=$[1];break;case"C":L.push([P,z,$[1],$[2],$[3],$[4],$[5],$[6]]),P=$[5],z=$[6];break;case"S":se[0]==="C"||se[0]==="c"?L.push([P,z,P+se[5]-se[3],z+se[6]-se[4],$[1],$[2],$[3],$[4]]):(se[0]==="S"||se[0]==="s")&&L.push([P,z,P+se[3]-se[1],z+se[4]-se[2],$[1],$[2],$[3],$[4]]),P=$[3],z=$[4];break;case"c":L.push([P,z,P+$[1],z+$[2],P+$[3],z+$[4],P+$[5],z+$[6]]),P=P+$[5],z=z+$[6];break;case"s":se[0]==="C"||se[0]==="c"?L.push([P,z,P+se[5]-se[3],z+se[6]-se[4],P+$[1],z+$[2],P+$[3],z+$[4]]):(se[0]==="S"||se[0]==="s")&&L.push([P,z,P+se[3]-se[1],z+se[4]-se[2],P+$[1],z+$[2],P+$[3],z+$[4]]),P=P+$[3],z=z+$[4];break;case"a":V=c({rx:$[1],ry:$[2],px:P,py:z,xAxisRotation:$[3],largeArcFlag:$[4],sweepFlag:$[5],cx:P+$[6],cy:z+$[7]}),Z=V[V.length-1],V.forEach(function(ce,me){me===0?L.push([P,z,ce.x1,ce.y1,ce.x2,ce.y2,ce.x,ce.y]):L.push([V[me-1].x,V[me-1].y,ce.x1,ce.y1,ce.x2,ce.y2,ce.x,ce.y])}),P=Z.x,z=Z.y;break;case"A":V=c({rx:$[1],ry:$[2],px:P,py:z,xAxisRotation:$[3],largeArcFlag:$[4],sweepFlag:$[5],cx:$[6],cy:$[7]}),Z=V[V.length-1],V.forEach(function(ce,me){me===0?L.push([P,z,ce.x1,ce.y1,ce.x2,ce.y2,ce.x,ce.y]):L.push([V[me-1].x,V[me-1].y,ce.x1,ce.y1,ce.x2,ce.y2,ce.x,ce.y])}),P=Z.x,z=Z.y;break;case"Q":L.push(m.q2b(P,z,$[1],$[2],$[3],$[4])),P=$[3],z=$[4];break;case"q":L.push(m.q2b(P,z,P+$[1],z+$[2],$[3]+P,$[4]+z)),P+=$[3],z+=$[4];break;case"T":se[0]==="Q"||se[0]==="q"?(H=P+se[3]-se[1],ie=z+se[4]-se[2],L.push(m.q2b(P,z,H,ie,$[1],$[2]))):(se[0]==="T"||se[0]==="t")&&(L.push(m.q2b(P,z,P+P-H,z+z-ie,$[1],$[2])),H=P+P-H,ie=z+z-ie),P=$[1],z=$[2];break;case"t":se[0]==="Q"||se[0]==="q"?(H=P+se[3]-se[1],ie=z+se[4]-se[2],L.push(m.q2b(P,z,H,ie,P+$[1],z+$[2]))):(se[0]==="T"||se[0]==="t")&&(L.push(m.q2b(P,z,P+P-H,z+z-ie,P+$[1],z+$[2])),H=P+P-H,ie=z+z-ie),P+=$[1],z+=$[2];break;case"Z":W=L[0][0],Y=L[0][1],L.push([P,z,W,Y,W,Y,W,Y]);break;case"z":W=L[0][0],Y=L[0][1],L.push([P,z,W,Y,W,Y,W,Y]);break}}return R},m._upCurves=function(E,D){for(var P=0,z=0,j=E.length;P<D;P++)E.push(E[z].slice(0)),z++,z>j-1&&(z-=j)};function v(E,D,P,z,j,A,R,L,W){return{left:M(E,D,P,z,j,A,R,L,W),right:M(R,L,j,A,P,z,E,D,1-W,!0)}}function M(E,D,P,z,j,A,R,L,W,Y){var H=(P-E)*W+E,ie=(z-D)*W+D,O=(j-P)*W+P,V=(A-z)*W+z,Z=(R-j)*W+j,$=(L-A)*W+A,ee=(O-H)*W+H,se=(V-ie)*W+ie,ce=(Z-O)*W+O,me=($-V)*W+V,pe=(ce-ee)*W+ee,B=(me-se)*W+se;return Y?[pe,B,ee,se,H,ie,E,D]:[E,D,H,ie,ee,se,pe,B]}m._splitCurves=function(E,D){for(var P=0,z=0;P<D;P++){var j=E[z],A=v(j[0],j[1],j[2],j[3],j[4],j[5],j[6],j[7],.5);E.splice(z,1),E.splice(z,0,A.left,A.right),z+=2,z>=E.length-1&&(z=0)}};function k(E,D){for(var P=function(A){var R=E[E.length-1],L=[];R.forEach(function(W){L.push(W.slice(0))}),E.push(L)},z=0;z<D;z++)P()}return m.lerp=function(E,D,P){return m._lerp(m.path2shapes(E),m.path2shapes(D),P)},m.MIM_CURVES_COUNT=100,m._preprocessing=function(E,D){var P=E.length,z=D.length,j=JSON.parse(JSON.stringify(E)),A=JSON.parse(JSON.stringify(D));return P>z?k(A,P-z):P<z&&k(j,z-P),j=I(j,A),j.forEach(function(R,L){var W=R.length,Y=A[L].length;W>Y?W<m.MIM_CURVES_COUNT?(m._splitCurves(R,m.MIM_CURVES_COUNT-W),m._splitCurves(A[L],m.MIM_CURVES_COUNT-Y)):m._splitCurves(A[L],W-Y):W<Y&&(Y<m.MIM_CURVES_COUNT?(m._splitCurves(R,m.MIM_CURVES_COUNT-W),m._splitCurves(A[L],m.MIM_CURVES_COUNT-Y)):m._splitCurves(R,Y-W))}),j.forEach(function(R,L){j[L]=b(R,A[L])}),[j,A]},m._lerp=function(E,D,P){var z=[];return E.forEach(function(j,A){var R=[];j.forEach(function(L,W){R.push(m.lerpCurve(L,D[A][W],P))}),z.push(R)}),z},m.animate=function(E){var D=m.path2shapes(E.from),P=m.path2shapes(E.to),z=m._preprocessing(D,P),j=new Date,A=E.end||function(){},R=E.progress||function(){},L=E.begin||function(){},W=E.easing||function(V){return V},Y=null,H=null,ie=E.time;L(D);var O=function V(){var Z=new Date-j;if(Z>=ie){H=P,R(H,1),A(H),cancelAnimationFrame(Y);return}var $=W(Z/ie);H=m._lerp(z[0],z[1],$),R(H,$),Y=requestAnimationFrame(V)};O()},m})})(Tv);var Moe=Tv.exports;const Qo=ln(Moe);Ze(Array);const woe=Symbol.for("spritejs_setAttributeDefault"),Ot=Symbol.for("spritejs_setAttribute"),zt=Symbol.for("spritejs_getAttribute");let Tc=class extends oh{constructor(t){super(t),this[woe]({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[zt]("d")}set d(t){this[Ot]("d",t)}get normalize(){return this[zt]("normalize")}set normalize(t){this[Ot]("normalize",!!t)}get fillColor(){return this[zt]("fillColor")}set fillColor(t){this[Ot]("fillColor",En(t))}get fillRule(){return this[zt]("fillRule")}set fillRule(t){if(t!=null&&t!=="nonzero"&&t!=="evenodd")throw new TypeError("Invalid fill rule.");this[Ot]("fillRule",t)}get strokeColor(){return this[zt]("strokeColor")}set strokeColor(t){this[Ot]("strokeColor",En(t))}get lineWidth(){return this[zt]("lineWidth")}set lineWidth(t){this[Ot]("lineWidth",qe(t))}get lineJoin(){return this[zt]("lineJoin")}set lineJoin(t){if(t!=null&&t!=="miter"&&t!=="bevel"&&t!=="round")throw new TypeError("Invalid lineJoin type.");this[Ot]("lineJoin",t)}get lineCap(){return this[zt]("lineCap")}set lineCap(t){if(t!=null&&t!=="butt"&&t!=="square"&&t!=="round")throw new TypeError("Invalid lineCap type.");this[Ot]("lineCap",t)}get lineDash(){return this[zt]("lineDash")}set lineDash(t){t=Mt(t,!0),t!=null&&!Array.isArray(t)&&(t=[t]),this[Ot]("lineDash",t?t.map(qe):null)}get lineDashOffset(){return this[zt]("lineDashOffset")}set lineDashOffset(t){this[Ot]("lineDashOffset",qe(t))}get miterLimit(){return this[zt]("miterLimit")}set miterLimit(t){this[Ot]("miterLimit",qe(t))}get roundSegments(){return this[zt]("roundSegments")}set roundSegments(t){this[Ot]("roundSegments",t)}get texture(){return this[zt]("texture")}set texture(t){this[Ot]("texture",t)}get textureRect(){return this[zt]("textureRect")}set textureRect(t){this[Ot]("textureRect",t)}get sourceRect(){return this[zt]("sourceRect")}set sourceRect(t){this[Ot]("sourceRect",t)}get textureRepeat(){return this[zt]("textureRepeat")}set textureRepeat(t){this[Ot]("textureRepeat",!!t)}get clipPath(){return this[zt]("clipPath")}set clipPath(t){this[Ot]("clipPath",t)}};Ze(Array);const Hr=Symbol("mesh");class $t extends fc{constructor(t={}){typeof t=="string"&&(t={d:t}),super(t),this.effects={d(e,r,n,i,o){const a=(n-i)/(o-i);if(a<=0)return e;if(a>=1)return r;const c=Qo._preprocessing(Qo.path2shapes(e),Qo.path2shapes(r)),l=Qo._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[Hr];if(e)e.path!==t&&(e.contours=t.contours,e.path=t);else{e=new ft.Mesh2D(this.path),e.path=t;const n=this.attributes.fillColor,i=this.attributes.fillRule;n&&Ia(e,{color:n,rule:i});const o=this.attributes.lineWidth,a=this.attributes.strokeColor;if(a&&o>0){const{lineCap:l,lineJoin:u,miterLimit:h,lineDash:d,lineDashOffset:f,roundSegments:g}=this.attributes;Ca(e,{color:a,lineWidth:o,lineCap:l,lineJoin:u,miterLimit:h,lineDash:d,lineDashOffset:f,roundSegments:g})}this[Hr]=e;const c=this.attributes.clipPath;c&&this[Hr].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&&Sv(this,e),t}getBoundingClientRect(){let t=null;return this.mesh&&(t=this.mesh.boundingBox),by(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[Hr]&&(t==="fillColor"||t==="fillRule")){const{fillColor:n,fillRule:i}=this.attributes;Ia(this[Hr],{color:n,rule:i})}if(this[Hr]&&(t==="strokeColor"||t==="lineWidth"||t==="lineCap"||t==="lineJoin"||t==="lineDash"||t==="lineDashOffset"||t==="roundSegments")){const{strokeColor:n,lineWidth:i}=this.attributes;if(n&&i>0){const{lineCap:o,lineJoin:a,lineDash:c,lineDashOffset:l,miterLimit:u,roundSegments:h}=this.attributes;Ca(this[Hr],{color:n,lineCap:o,lineJoin:a,lineWidth:i,lineDash:c,lineDashOffset:l,miterLimit:u,roundSegments:h})}}this[Hr]&&t==="clipPath"&&this[Hr].setClipPath(e),t==="texture"&&vv(this,e)}updateContours(){this.path=new ft.Figure2D,this.path.addPath(this.attributes.d),this.attributes.normalize&&this.path.normalize(...this.path.boundingCenter)}}x($t,"Attr",Tc);Gt.registerNode($t,"path");Ze(Array);function Soe(s,t=[0]){function e(i,o=.168,a=.168){let c,l,u,h;if((s[i].x===s[i+1].x||s[i].y===s[i+1].y)&&(o=0,a=0),i<1?(c=s[0].x+(s[1].x-s[0].x)*o,l=s[0].y+(s[1].y-s[0].y)*o):(c=s[i].x+(s[i+1].x-s[i-1].x)*o,l=s[i].y+(s[i+1].y-s[i-1].y)*o),i>s.length-3){const d=s.length-1;u=s[d].x-(s[d].x-s[d-1].x)*a,h=s[d].y-(s[d].y-s[d-1].y)*a}else u=s[i+1].x-(s[i+2].x-s[i].x)*a,h=s[i+1].y-(s[i+2].y-s[i].y)*a;return[{x:c,y:l},{x:u,y:h}]}s=s.map(([i,o])=>({x:i,y:o}));let r="",n=0;return s.forEach((i,o)=>{if(o===0)r+=`M${i.x} ${i.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,i.x,i.y].join(" ")}`}else r+=`L${i.x} ${i.y}`}}),r}Ze(Array);const Toe=Symbol.for("spritejs_setAttributeDefault"),pn=Symbol.for("spritejs_setAttribute"),ps=Symbol.for("spritejs_getAttribute"),Ioe=Symbol.for("spritejs_declareAlias");function qo(s){const{points:t,smooth:e,smoothRange:r,close:n}=s,i=[];for(let a=0;a<t.length;a+=2)i.push([t[a],t[a+1]]);let o="";return e?o=Soe(i,r):i.length&&(o=`M${i.map(a=>a.join(" ")).join("L")}`),o&&n&&(o+="Z"),o}let Coe=class extends Tc{constructor(t){super(t),this[Toe]({points:[],smooth:!1,smoothRange:[0],closeType:"none"}),this[Ioe]("close")}get d(){return this[ps]("d")}set d(t){}get close(){return this.closeType!=="none"}set close(t){t=t?"normal":"none",this.closeType=t}get closeType(){return this[ps]("closeType")}set closeType(t){if(t!=null&&t!=="none"&&t!=="normal")throw new TypeError("Invalid closeType type.");if(this[pn]("closeType",t)){const e=qo(this);this[pn]("d",e)}}get smooth(){return this[ps]("smooth")}set smooth(t){if(this[pn]("smooth",t)){const e=qo(this);this[pn]("d",e)}}get smoothRange(){return this[ps]("smoothRange")}set smoothRange(t){if(t&&!Array.isArray(t)&&(t=[t]),this[pn]("smoothRange",t)&&this.smooth){const e=qo(this);this[pn]("d",e)}}get points(){return this[ps]("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[pn]("points",t)){const e=qo(this);this[pn]("d",e)}}};Ze(Array);class Cr extends $t{get isVisible(){const{points:t}=this.attributes;return t.length>0&&super.isVisible}}x(Cr,"Attr",Coe);Gt.registerNode(Cr,"polyline");Ze(Array);const boe=Symbol.for("spritejs_setAttributeDefault"),Zo=Symbol.for("spritejs_setAttribute"),Dl=Symbol.for("spritejs_getAttribute"),Eoe=Symbol.for("spritejs_declareAlias");function kg(s){const{width:t,height:e}=s;return`M0 0L${t} 0L${t} ${e}L0 ${e}Z`}let xoe=class extends Tc{constructor(t){super(t),this[boe]({width:0,height:0}),this[Eoe]("size")}get d(){return this[Dl]("d")}set d(t){}get width(){return this[Dl]("width")}set width(t){if(t=qe(t),this[Zo]("width",t)){const e=kg(this);this[Zo]("d",e)}}get height(){return this[Dl]("height")}set height(t){if(t=qe(t),this[Zo]("height",t)){const e=kg(this);this[Zo]("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]}};Ze(Array);class Gs extends $t{get isVisible(){const{width:t,height:e}=this.attributes;return t>0&&e>0&&super.isVisible}}x(Gs,"Attr",xoe);Gt.registerNode(Gs,"rect");Ze(Array);const Roe=Symbol.for("spritejs_setAttributeDefault"),pr=Symbol.for("spritejs_setAttribute"),Wn=Symbol.for("spritejs_getAttribute"),koe=Symbol.for("spritejs_declareAlias");function ms(s){const{radiusX:t,radiusY:e,startAngle:r,endAngle:n,direction:i,closeType:o}=s,a=i==="anitclockwise",c=new ft.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 Aoe=class extends Tc{constructor(t){super(t),this[Roe]({radiusX:0,radiusY:0,startAngle:0,endAngle:360,direction:"clockwise",closeType:"none"}),this[koe]("radius","angle")}get d(){return this[Wn]("d")}set d(t){}get radiusX(){return this[Wn]("radiusX")}set radiusX(t){if(t=qe(t),this[pr]("radiusX",t)){const e=ms(this);this[pr]("d",e)}}get radiusY(){return this[Wn]("radiusY")}set radiusY(t){if(t=qe(t),this[pr]("radiusY",t)){const e=ms(this);this[pr]("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[Wn]("direction")}set direction(t){if(t!=null&&t!=="clockwise"&&t!=="anticlockwise")throw new TypeError("Invalid direction type.");this[pr]("direction",t)}get startAngle(){return this[Wn]("startAngle")}set startAngle(t){if(t=qe(t),this[pr]("startAngle",t)){const e=ms(this);this[pr]("d",e)}}get endAngle(){return this[Wn]("endAngle")}set endAngle(t){if(t=qe(t),this[pr]("endAngle",t)){const e=ms(this);this[pr]("d",e)}}get closeType(){return this[Wn]("closeType")}set closeType(t){if(t!=null&&t!=="none"&&t!=="sector"&&t!=="normal")throw new TypeError("Invalid closeType type.");if(this[pr]("closeType",t)){const e=ms(this);this[pr]("d",e)}}};Ze(Array);class Qh extends $t{get isVisible(){const{radiusX:t,radiusY:e,startAngle:r,endAngle:n}=this.attributes;return t>0&&e>0&&r!==n&&super.isVisible}}x(Qh,"Attr",Aoe);Gt.registerNode(Qh,"ellipse");Ze(Array);const Poe=Symbol.for("spritejs_setAttributeDefault"),Ko=Symbol.for("spritejs_setAttribute"),Xo=Symbol.for("spritejs_getAttribute");let Doe=class extends gc{constructor(t){super(t),this[Poe]({texture:void 0,textureRect:void 0,textureRepeat:!1,sourceRect:void 0})}get texture(){return this[Xo]("texture")}set texture(t){this[Ko]("texture",t)}get textureRect(){return this[Xo]("textureRect")}set textureRect(t){this[Ko]("textureRect",t)}get sourceRect(){return this[Xo]("sourceRect")}set sourceRect(t){this[Ko]("sourceRect",t)}get textureRepeat(){return this[Xo]("textureRepeat")}set textureRepeat(t){this[Ko]("textureRepeat",!!t)}};Ze(Array);const Ag=Symbol("textureTask");class Ic extends co{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 i=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(i){const c=this.layer?this.layer.displayRatio:1;r==null&&(t=i.width/c),n==null&&(e=i.height/c)}}return[t,e]}get textureImageReady(){return this[Ag]||Promise.resolve()}draw(t=[]){super.draw(t);const e=this.mesh;return e&&Sv(this,e),t}onPropertyChange(t,e,r){if(super.onPropertyChange(t,e,r),t==="texture"&&(this[Ag]=vv(this,e,!0)),t==="textureRect"){const{width:n,height:i}=this.attributes;(n==null||i==null)&&this.updateContours()}}}x(Ic,"Attr",Doe);Gt.registerNode(Ic,"sprite");Ze(Array);const Loe=Symbol.for("spritejs_setAttributeDefault"),tr=Symbol.for("spritejs_setAttribute"),rr=Symbol.for("spritejs_getAttribute"),Noe=Symbol.for("spritejs_declareAlias");let Ooe=class extends gc{constructor(t){super(t),this[Loe]({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[Noe]("font")}get text(){return this[rr]("text")||" "}set text(t){this[tr]("text",t)}get fontSize(){return this[rr]("fontSize")}set fontSize(t){this[tr]("fontSize",qe(t))}get fontFamily(){return this[rr]("fontFamily")}set fontFamily(t){this[tr]("fontFamily",t)}get fontStyle(){return this[rr]("fontStyle")}set fontStyle(t){this[tr]("fontStyle",t)}get fontVariant(){return this[rr]("fontVariant")}set fontVariant(t){this[tr]("fontVariant",t)}get fontWeight(){return this[rr]("fontWeight")}set fontWeight(t){this[tr]("fontWeight",t)}get fontStretch(){return this[rr]("fontStretch")}set fontStretch(t){this[tr]("fontStretch",t)}get lineHeight(){return this[rr]("lineHeight")||this.fontSize}set lineHeight(t){this[tr]("lineHeight",qe(t))}get textAlign(){return this[rr]("textAlign")}set textAlign(t){this[tr]("textAlign",t)}get strokeColor(){return this[rr]("strokeColor")}set strokeColor(t){this[tr]("strokeColor",En(t))}get strokeWidth(){return this[rr]("strokeWidth")}set strokeWidth(t){this[tr]("strokeWidth",qe(t))}get verticalAlign(){return this[rr]("verticalAlign")}set verticalAlign(t){this[tr]("verticalAlign",t)}get fillColor(){return this[rr]("fillColor")}set fillColor(t){this[tr]("fillColor",En(t))}get font(){const{fontStyle:t,fontVariant:e,fontWeight:r,fontStretch:n,fontSize:i,lineHeight:o,fontFamily:a}=this;return`${t} ${e} ${r} ${n} ${i}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=ft.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}}};Ze(Array);const Ci=Symbol("textImage"),Jo=Symbol("textImageTask"),Ll=Symbol("textureContext"),ys=Symbol("updateTextureRect"),Nl=Symbol("textCanvas");class qh extends co{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 i=this[Ci];i&&(r==null&&(t=i.rect[2]),n==null&&(e=i.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[Ci]||{}}get textImageReady(){return this[Jo]||Promise.resolve()}draw(t){super.draw(t);const e=this.mesh;if(e){const r=this[Ci];if(r){let n=e.texture;if(!n||this[Ll]&&this[Ll]!==this.renderer||r.needsUpdate?(r.needsUpdate=!1,wv(r.image,this.renderer),n=Mv(r.image,this.renderer),this[ys]=!0):n=e.uniforms.u_texSampler,this[ys]){const[i,o]=r.rect.slice(2),[a,c]=this.contentSize,l=this.attributes.textAlign,u=this.attributes.verticalAlign;let h=0;l==="center"?h=(a-i)/2:(l==="right"||l==="end")&&(h=a-i);const d=this.attributes.fontSize,f=this.attributes.lineHeight;let g=0;u==="top"?g=(d-f)/2:u==="bottom"&&(g=(f-d)/2);const{paddingLeft:y,paddingTop:S}=this.attributes,{borderWidth:b}=this.attributes;h+=y+b,g+=S+b;const{anchorX:I,anchorY:N}=this.attributes;h-=this.offsetSize[0]*I,g-=this.offsetSize[1]*N,e.setTexture(n,{rect:[h,g,i,o]}),this[ys]=!1,this[Ll]=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[ys]=!0),super.onPropertyChange(t,e,r))}updateContours(){super.updateContours(),this[ys]=!0}updateText(){this[Jo]||(this[Jo]=Promise.resolve().then(()=>{this[Jo]=null;const{text:t,font:e,fillColor:r,strokeColor:n,strokeWidth:i}=this.attributes,o=this.layer?this.layer.displayRatio:1;return this[Nl]=this[Nl]||ft.ENV.createCanvas(1,1),this[Ci]=ft.ENV.createText(t,{font:e,fillColor:r,strokeColor:n,strokeWidth:i,parseFont:ft.parseFont,ratio:o,textCanvas:this[Nl]}),this[Ci].needsUpdate=!0,this.updateContours(),this.forceUpdate(),this[Ci]}))}}x(qh,"Attr",Ooe);Gt.registerNode(qh,"label");Ze(Array);function zoe(s,t){if(!s)return t&&[...t];if(!t)return s;const e=Math.min(s[0],t[0]),r=Math.min(s[1],t[1]);return[e,r,Math.max(s[0]+s[2],t[0]+t[2])-e,Math.max(s[1]+s[3],t[1]+t[3])-r]}class Boe{constructor(t,{rect:e,revision:r=0,singleChannelTexture:n=!0,textureSubImage2D:i=!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=i,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=zoe(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:i}=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,i)||(i?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,i,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]-i)/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]-i)/a*this.source.height)),d=u-c,f=h-l;if(d<=0||f<=0)return!0;let g=this._stagingCanvas;(!g||g.width!==d||g.height!==f)&&(g=ft.ENV.createCanvas(d,f,{offscreen:!0}),this._stagingCanvas=g);const y=g&&g.getContext("2d");if(!y)return!1;y.clearRect(0,0,d,f),y.drawImage(this.source,c,l,d,f,0,0,d,f);try{return t.texSubImage2D(t.TEXTURE_2D,0,c,this.source.height-h,r?t.RED:t.RGBA,t.UNSIGNED_BYTE,g),!0}catch{return this.textureSubImage2D=!1,!1}}}Ze(Array);Ze(Array);var joe=typeof St=="object"&&St&&St.Object===Object&&St,Iv=joe,Foe=Iv,Uoe=typeof self=="object"&&self&&self.Object===Object&&self,Woe=Foe||Uoe||Function("return this")(),Er=Woe,Voe=Er,$oe=Voe.Symbol,fo=$oe,Pg=fo,Cv=Object.prototype,Yoe=Cv.hasOwnProperty,Goe=Cv.toString,vs=Pg?Pg.toStringTag:void 0;function Hoe(s){var t=Yoe.call(s,vs),e=s[vs];try{s[vs]=void 0;var r=!0}catch{}var n=Goe.call(s);return r&&(t?s[vs]=e:delete s[vs]),n}var Qoe=Hoe,qoe=Object.prototype,Zoe=qoe.toString;function Koe(s){return Zoe.call(s)}var Xoe=Koe,Dg=fo,Joe=Qoe,_oe=Xoe,eae="[object Null]",tae="[object Undefined]",Lg=Dg?Dg.toStringTag:void 0;function rae(s){return s==null?s===void 0?tae:eae:Lg&&Lg in Object(s)?Joe(s):_oe(s)}var pi=rae;function nae(s){return s!=null&&typeof s=="object"}var zr=nae,iae=pi,sae=zr,oae="[object Number]";function aae(s){return typeof s=="number"||sae(s)&&iae(s)==oae}var cae=aae;const yt=ln(cae);function lae(){this.__data__=[],this.size=0}var uae=lae;function hae(s,t){return s===t||s!==s&&t!==t}var Zh=hae,dae=Zh;function fae(s,t){for(var e=s.length;e--;)if(dae(s[e][0],t))return e;return-1}var Cc=fae,gae=Cc,pae=Array.prototype,mae=pae.splice;function yae(s){var t=this.__data__,e=gae(t,s);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():mae.call(t,e,1),--this.size,!0}var vae=yae,Mae=Cc;function wae(s){var t=this.__data__,e=Mae(t,s);return e<0?void 0:t[e][1]}var Sae=wae,Tae=Cc;function Iae(s){return Tae(this.__data__,s)>-1}var Cae=Iae,bae=Cc;function Eae(s,t){var e=this.__data__,r=bae(e,s);return r<0?(++this.size,e.push([s,t])):e[r][1]=t,this}var xae=Eae,Rae=uae,kae=vae,Aae=Sae,Pae=Cae,Dae=xae;function es(s){var t=-1,e=s==null?0:s.length;for(this.clear();++t<e;){var r=s[t];this.set(r[0],r[1])}}es.prototype.clear=Rae;es.prototype.delete=kae;es.prototype.get=Aae;es.prototype.has=Pae;es.prototype.set=Dae;var bc=es,Lae=bc;function Nae(){this.__data__=new Lae,this.size=0}var Oae=Nae;function zae(s){var t=this.__data__,e=t.delete(s);return this.size=t.size,e}var Bae=zae;function jae(s){return this.__data__.get(s)}var Fae=jae;function Uae(s){return this.__data__.has(s)}var Wae=Uae;function Vae(s){var t=typeof s;return s!=null&&(t=="object"||t=="function")}var Dn=Vae,$ae=pi,Yae=Dn,Gae="[object AsyncFunction]",Hae="[object Function]",Qae="[object GeneratorFunction]",qae="[object Proxy]";function Zae(s){if(!Yae(s))return!1;var t=$ae(s);return t==Hae||t==Qae||t==Gae||t==qae}var bv=Zae,Kae=Er,Xae=Kae["__core-js_shared__"],Jae=Xae,Ol=Jae,Ng=function(){var s=/[^.]+$/.exec(Ol&&Ol.keys&&Ol.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""}();function _ae(s){return!!Ng&&Ng in s}var ece=_ae,tce=Function.prototype,rce=tce.toString;function nce(s){if(s!=null){try{return rce.call(s)}catch{}try{return s+""}catch{}}return""}var Ev=nce,ice=bv,sce=ece,oce=Dn,ace=Ev,cce=/[\\^$.*+?()[\]{}|]/g,lce=/^\[object .+?Constructor\]$/,uce=Function.prototype,hce=Object.prototype,dce=uce.toString,fce=hce.hasOwnProperty,gce=RegExp("^"+dce.call(fce).replace(cce,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function pce(s){if(!oce(s)||sce(s))return!1;var t=ice(s)?gce:lce;return t.test(ace(s))}var mce=pce;function yce(s,t){return s==null?void 0:s[t]}var vce=yce,Mce=mce,wce=vce;function Sce(s,t){var e=wce(s,t);return Mce(e)?e:void 0}var mi=Sce,Tce=mi,Ice=Er,Cce=Tce(Ice,"Map"),Kh=Cce,bce=mi,Ece=bce(Object,"create"),Ec=Ece,Og=Ec;function xce(){this.__data__=Og?Og(null):{},this.size=0}var Rce=xce;function kce(s){var t=this.has(s)&&delete this.__data__[s];return this.size-=t?1:0,t}var Ace=kce,Pce=Ec,Dce="__lodash_hash_undefined__",Lce=Object.prototype,Nce=Lce.hasOwnProperty;function Oce(s){var t=this.__data__;if(Pce){var e=t[s];return e===Dce?void 0:e}return Nce.call(t,s)?t[s]:void 0}var zce=Oce,Bce=Ec,jce=Object.prototype,Fce=jce.hasOwnProperty;function Uce(s){var t=this.__data__;return Bce?t[s]!==void 0:Fce.call(t,s)}var Wce=Uce,Vce=Ec,$ce="__lodash_hash_undefined__";function Yce(s,t){var e=this.__data__;return this.size+=this.has(s)?0:1,e[s]=Vce&&t===void 0?$ce:t,this}var Gce=Yce,Hce=Rce,Qce=Ace,qce=zce,Zce=Wce,Kce=Gce;function ts(s){var t=-1,e=s==null?0:s.length;for(this.clear();++t<e;){var r=s[t];this.set(r[0],r[1])}}ts.prototype.clear=Hce;ts.prototype.delete=Qce;ts.prototype.get=qce;ts.prototype.has=Zce;ts.prototype.set=Kce;var Xce=ts,zg=Xce,Jce=bc,_ce=Kh;function ele(){this.size=0,this.__data__={hash:new zg,map:new(_ce||Jce),string:new zg}}var tle=ele;function rle(s){var t=typeof s;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?s!=="__proto__":s===null}var nle=rle,ile=nle;function sle(s,t){var e=s.__data__;return ile(t)?e[typeof t=="string"?"string":"hash"]:e.map}var xc=sle,ole=xc;function ale(s){var t=ole(this,s).delete(s);return this.size-=t?1:0,t}var cle=ale,lle=xc;function ule(s){return lle(this,s).get(s)}var hle=ule,dle=xc;function fle(s){return dle(this,s).has(s)}var gle=fle,ple=xc;function mle(s,t){var e=ple(this,s),r=e.size;return e.set(s,t),this.size+=e.size==r?0:1,this}var yle=mle,vle=tle,Mle=cle,wle=hle,Sle=gle,Tle=yle;function rs(s){var t=-1,e=s==null?0:s.length;for(this.clear();++t<e;){var r=s[t];this.set(r[0],r[1])}}rs.prototype.clear=vle;rs.prototype.delete=Mle;rs.prototype.get=wle;rs.prototype.has=Sle;rs.prototype.set=Tle;var xv=rs,Ile=bc,Cle=Kh,ble=xv,Ele=200;function xle(s,t){var e=this.__data__;if(e instanceof Ile){var r=e.__data__;if(!Cle||r.length<Ele-1)return r.push([s,t]),this.size=++e.size,this;e=this.__data__=new ble(r)}return e.set(s,t),this.size=e.size,this}var Rle=xle,kle=bc,Ale=Oae,Ple=Bae,Dle=Fae,Lle=Wae,Nle=Rle;function ns(s){var t=this.__data__=new kle(s);this.size=t.size}ns.prototype.clear=Ale;ns.prototype.delete=Ple;ns.prototype.get=Dle;ns.prototype.has=Lle;ns.prototype.set=Nle;var Rv=ns;function Ole(s,t){for(var e=-1,r=s==null?0:s.length;++e<r&&t(s[e],e,s)!==!1;);return s}var zle=Ole,Ble=mi,jle=function(){try{var s=Ble(Object,"defineProperty");return s({},"",{}),s}catch{}}(),kv=jle,Bg=kv;function Fle(s,t,e){t=="__proto__"&&Bg?Bg(s,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):s[t]=e}var Av=Fle,Ule=Av,Wle=Zh,Vle=Object.prototype,$le=Vle.hasOwnProperty;function Yle(s,t,e){var r=s[t];(!($le.call(s,t)&&Wle(r,e))||e===void 0&&!(t in s))&&Ule(s,t,e)}var Pv=Yle,Gle=Pv,Hle=Av;function Qle(s,t,e,r){var n=!e;e||(e={});for(var i=-1,o=t.length;++i<o;){var a=t[i],c=r?r(e[a],s[a],a,e,s):void 0;c===void 0&&(c=s[a]),n?Hle(e,a,c):Gle(e,a,c)}return e}var Rc=Qle;function qle(s,t){for(var e=-1,r=Array(s);++e<s;)r[e]=t(e);return r}var Zle=qle,Kle=pi,Xle=zr,Jle="[object Arguments]";function _le(s){return Xle(s)&&Kle(s)==Jle}var eue=_le,jg=eue,tue=zr,Dv=Object.prototype,rue=Dv.hasOwnProperty,nue=Dv.propertyIsEnumerable,iue=jg(function(){return arguments}())?jg:function(s){return tue(s)&&rue.call(s,"callee")&&!nue.call(s,"callee")},Lv=iue,sue=Array.isArray,go=sue,Ra={exports:{}};function oue(){return!1}var aue=oue;Ra.exports;(function(s,t){var e=Er,r=aue,n=t&&!t.nodeType&&t,i=n&&!0&&s&&!s.nodeType&&s,o=i&&i.exports===n,a=o?e.Buffer:void 0,c=a?a.isBuffer:void 0,l=c||r;s.exports=l})(Ra,Ra.exports);var Xh=Ra.exports,cue=9007199254740991,lue=/^(?:0|[1-9]\d*)$/;function uue(s,t){var e=typeof s;return t=t??cue,!!t&&(e=="number"||e!="symbol"&&lue.test(s))&&s>-1&&s%1==0&&s<t}var hue=uue,due=9007199254740991;function fue(s){return typeof s=="number"&&s>-1&&s%1==0&&s<=due}var Nv=fue,gue=pi,pue=Nv,mue=zr,yue="[object Arguments]",vue="[object Array]",Mue="[object Boolean]",wue="[object Date]",Sue="[object Error]",Tue="[object Function]",Iue="[object Map]",Cue="[object Number]",bue="[object Object]",Eue="[object RegExp]",xue="[object Set]",Rue="[object String]",kue="[object WeakMap]",Aue="[object ArrayBuffer]",Pue="[object DataView]",Due="[object Float32Array]",Lue="[object Float64Array]",Nue="[object Int8Array]",Oue="[object Int16Array]",zue="[object Int32Array]",Bue="[object Uint8Array]",jue="[object Uint8ClampedArray]",Fue="[object Uint16Array]",Uue="[object Uint32Array]",ct={};ct[Due]=ct[Lue]=ct[Nue]=ct[Oue]=ct[zue]=ct[Bue]=ct[jue]=ct[Fue]=ct[Uue]=!0;ct[yue]=ct[vue]=ct[Aue]=ct[Mue]=ct[Pue]=ct[wue]=ct[Sue]=ct[Tue]=ct[Iue]=ct[Cue]=ct[bue]=ct[Eue]=ct[xue]=ct[Rue]=ct[kue]=!1;function Wue(s){return mue(s)&&pue(s.length)&&!!ct[gue(s)]}var Vue=Wue;function $ue(s){return function(t){return s(t)}}var kc=$ue,ka={exports:{}};ka.exports;(function(s,t){var e=Iv,r=t&&!t.nodeType&&t,n=r&&!0&&s&&!s.nodeType&&s,i=n&&n.exports===r,o=i&&e.process,a=function(){try{var c=n&&n.require&&n.require("util").types;return c||o&&o.binding&&o.binding("util")}catch{}}();s.exports=a})(ka,ka.exports);var Jh=ka.exports,Yue=Vue,Gue=kc,Fg=Jh,Ug=Fg&&Fg.isTypedArray,Hue=Ug?Gue(Ug):Yue,Ov=Hue,Que=Zle,que=Lv,Zue=go,Kue=Xh,Xue=hue,Jue=Ov,_ue=Object.prototype,ehe=_ue.hasOwnProperty;function the(s,t){var e=Zue(s),r=!e&&que(s),n=!e&&!r&&Kue(s),i=!e&&!r&&!n&&Jue(s),o=e||r||n||i,a=o?Que(s.length,String):[],c=a.length;for(var l in s)(t||ehe.call(s,l))&&!(o&&(l=="length"||n&&(l=="offset"||l=="parent")||i&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||Xue(l,c)))&&a.push(l);return a}var zv=the,rhe=Object.prototype;function nhe(s){var t=s&&s.constructor,e=typeof t=="function"&&t.prototype||rhe;return s===e}var _h=nhe;function ihe(s,t){return function(e){return s(t(e))}}var Bv=ihe,she=Bv,ohe=she(Object.keys,Object),ahe=ohe,che=_h,lhe=ahe,uhe=Object.prototype,hhe=uhe.hasOwnProperty;function dhe(s){if(!che(s))return lhe(s);var t=[];for(var e in Object(s))hhe.call(s,e)&&e!="constructor"&&t.push(e);return t}var fhe=dhe,ghe=bv,phe=Nv;function mhe(s){return s!=null&&phe(s.length)&&!ghe(s)}var ed=mhe,yhe=zv,vhe=fhe,Mhe=ed;function whe(s){return Mhe(s)?yhe(s):vhe(s)}var td=whe,She=Rc,The=td;function Ihe(s,t){return s&&She(t,The(t),s)}var Che=Ihe;function bhe(s){var t=[];if(s!=null)for(var e in Object(s))t.push(e);return t}var Ehe=bhe,xhe=Dn,Rhe=_h,khe=Ehe,Ahe=Object.prototype,Phe=Ahe.hasOwnProperty;function Dhe(s){if(!xhe(s))return khe(s);var t=Rhe(s),e=[];for(var r in s)r=="constructor"&&(t||!Phe.call(s,r))||e.push(r);return e}var Lhe=Dhe,Nhe=zv,Ohe=Lhe,zhe=ed;function Bhe(s){return zhe(s)?Nhe(s,!0):Ohe(s)}var rd=Bhe,jhe=Rc,Fhe=rd;function Uhe(s,t){return s&&jhe(t,Fhe(t),s)}var Whe=Uhe,Aa={exports:{}};Aa.exports;(function(s,t){var e=Er,r=t&&!t.nodeType&&t,n=r&&!0&&s&&!s.nodeType&&s,i=n&&n.exports===r,o=i?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}s.exports=c})(Aa,Aa.exports);var Vhe=Aa.exports;function $he(s,t){var e=-1,r=s.length;for(t||(t=Array(r));++e<r;)t[e]=s[e];return t}var Yhe=$he;function Ghe(s,t){for(var e=-1,r=s==null?0:s.length,n=0,i=[];++e<r;){var o=s[e];t(o,e,s)&&(i[n++]=o)}return i}var jv=Ghe;function Hhe(){return[]}var Fv=Hhe,Qhe=jv,qhe=Fv,Zhe=Object.prototype,Khe=Zhe.propertyIsEnumerable,Wg=Object.getOwnPropertySymbols,Xhe=Wg?function(s){return s==null?[]:(s=Object(s),Qhe(Wg(s),function(t){return Khe.call(s,t)}))}:qhe,nd=Xhe,Jhe=Rc,_he=nd;function ede(s,t){return Jhe(s,_he(s),t)}var tde=ede;function rde(s,t){for(var e=-1,r=t.length,n=s.length;++e<r;)s[n+e]=t[e];return s}var id=rde,nde=Bv,ide=nde(Object.getPrototypeOf,Object),Uv=ide,sde=id,ode=Uv,ade=nd,cde=Fv,lde=Object.getOwnPropertySymbols,ude=lde?function(s){for(var t=[];s;)sde(t,ade(s)),s=ode(s);return t}:cde,Wv=ude,hde=Rc,dde=Wv;function fde(s,t){return hde(s,dde(s),t)}var gde=fde,pde=id,mde=go;function yde(s,t,e){var r=t(s);return mde(s)?r:pde(r,e(s))}var Vv=yde,vde=Vv,Mde=nd,wde=td;function Sde(s){return vde(s,wde,Mde)}var $v=Sde,Tde=Vv,Ide=Wv,Cde=rd;function bde(s){return Tde(s,Cde,Ide)}var Ede=bde,xde=mi,Rde=Er,kde=xde(Rde,"DataView"),Ade=kde,Pde=mi,Dde=Er,Lde=Pde(Dde,"Promise"),Nde=Lde,Ode=mi,zde=Er,Bde=Ode(zde,"Set"),Yv=Bde,jde=mi,Fde=Er,Ude=jde(Fde,"WeakMap"),Wde=Ude,Au=Ade,Pu=Kh,Du=Nde,Lu=Yv,Nu=Wde,Gv=pi,is=Ev,Vg="[object Map]",Vde="[object Object]",$g="[object Promise]",Yg="[object Set]",Gg="[object WeakMap]",Hg="[object DataView]",$de=is(Au),Yde=is(Pu),Gde=is(Du),Hde=is(Lu),Qde=is(Nu),Gn=Gv;(Au&&Gn(new Au(new ArrayBuffer(1)))!=Hg||Pu&&Gn(new Pu)!=Vg||Du&&Gn(Du.resolve())!=$g||Lu&&Gn(new Lu)!=Yg||Nu&&Gn(new Nu)!=Gg)&&(Gn=function(s){var t=Gv(s),e=t==Vde?s.constructor:void 0,r=e?is(e):"";if(r)switch(r){case $de:return Hg;case Yde:return Vg;case Gde:return $g;case Hde:return Yg;case Qde:return Gg}return t});var Ac=Gn,qde=Object.prototype,Zde=qde.hasOwnProperty;function Kde(s){var t=s.length,e=new s.constructor(t);return t&&typeof s[0]=="string"&&Zde.call(s,"index")&&(e.index=s.index,e.input=s.input),e}var Xde=Kde,Jde=Er,_de=Jde.Uint8Array,Hv=_de,Qg=Hv;function efe(s){var t=new s.constructor(s.byteLength);return new Qg(t).set(new Qg(s)),t}var sd=efe,tfe=sd;function rfe(s,t){var e=t?tfe(s.buffer):s.buffer;return new s.constructor(e,s.byteOffset,s.byteLength)}var nfe=rfe,ife=/\w*$/;function sfe(s){var t=new s.constructor(s.source,ife.exec(s));return t.lastIndex=s.lastIndex,t}var ofe=sfe,qg=fo,Zg=qg?qg.prototype:void 0,Kg=Zg?Zg.valueOf:void 0;function afe(s){return Kg?Object(Kg.call(s)):{}}var cfe=afe,lfe=sd;function ufe(s,t){var e=t?lfe(s.buffer):s.buffer;return new s.constructor(e,s.byteOffset,s.length)}var hfe=ufe,dfe=sd,ffe=nfe,gfe=ofe,pfe=cfe,mfe=hfe,yfe="[object Boolean]",vfe="[object Date]",Mfe="[object Map]",wfe="[object Number]",Sfe="[object RegExp]",Tfe="[object Set]",Ife="[object String]",Cfe="[object Symbol]",bfe="[object ArrayBuffer]",Efe="[object DataView]",xfe="[object Float32Array]",Rfe="[object Float64Array]",kfe="[object Int8Array]",Afe="[object Int16Array]",Pfe="[object Int32Array]",Dfe="[object Uint8Array]",Lfe="[object Uint8ClampedArray]",Nfe="[object Uint16Array]",Ofe="[object Uint32Array]";function zfe(s,t,e){var r=s.constructor;switch(t){case bfe:return dfe(s);case yfe:case vfe:return new r(+s);case Efe:return ffe(s,e);case xfe:case Rfe:case kfe:case Afe:case Pfe:case Dfe:case Lfe:case Nfe:case Ofe:return mfe(s,e);case Mfe:return new r;case wfe:case Ife:return new r(s);case Sfe:return gfe(s);case Tfe:return new r;case Cfe:return pfe(s)}}var Bfe=zfe,jfe=Dn,Xg=Object.create,Ffe=function(){function s(){}return function(t){if(!jfe(t))return{};if(Xg)return Xg(t);s.prototype=t;var e=new s;return s.prototype=void 0,e}}(),Ufe=Ffe,Wfe=Ufe,Vfe=Uv,$fe=_h;function Yfe(s){return typeof s.constructor=="function"&&!$fe(s)?Wfe(Vfe(s)):{}}var Gfe=Yfe,Hfe=Ac,Qfe=zr,qfe="[object Map]";function Zfe(s){return Qfe(s)&&Hfe(s)==qfe}var Kfe=Zfe,Xfe=Kfe,Jfe=kc,Jg=Jh,_g=Jg&&Jg.isMap,_fe=_g?Jfe(_g):Xfe,ege=_fe,tge=Ac,rge=zr,nge="[object Set]";function ige(s){return rge(s)&&tge(s)==nge}var sge=ige,oge=sge,age=kc,ep=Jh,tp=ep&&ep.isSet,cge=tp?age(tp):oge,Qv=cge;const lge=ln(Qv);var uge=Rv,hge=zle,dge=Pv,fge=Che,gge=Whe,pge=Vhe,mge=Yhe,yge=tde,vge=gde,Mge=$v,wge=Ede,Sge=Ac,Tge=Xde,Ige=Bfe,Cge=Gfe,bge=go,Ege=Xh,xge=ege,Rge=Dn,kge=Qv,Age=td,Pge=rd,Dge=1,Lge=2,Nge=4,qv="[object Arguments]",Oge="[object Array]",zge="[object Boolean]",Bge="[object Date]",jge="[object Error]",Zv="[object Function]",Fge="[object GeneratorFunction]",Uge="[object Map]",Wge="[object Number]",Kv="[object Object]",Vge="[object RegExp]",$ge="[object Set]",Yge="[object String]",Gge="[object Symbol]",Hge="[object WeakMap]",Qge="[object ArrayBuffer]",qge="[object DataView]",Zge="[object Float32Array]",Kge="[object Float64Array]",Xge="[object Int8Array]",Jge="[object Int16Array]",_ge="[object Int32Array]",epe="[object Uint8Array]",tpe="[object Uint8ClampedArray]",rpe="[object Uint16Array]",npe="[object Uint32Array]",ot={};ot[qv]=ot[Oge]=ot[Qge]=ot[qge]=ot[zge]=ot[Bge]=ot[Zge]=ot[Kge]=ot[Xge]=ot[Jge]=ot[_ge]=ot[Uge]=ot[Wge]=ot[Kv]=ot[Vge]=ot[$ge]=ot[Yge]=ot[Gge]=ot[epe]=ot[tpe]=ot[rpe]=ot[npe]=!0;ot[jge]=ot[Zv]=ot[Hge]=!1;function pa(s,t,e,r,n,i){var o,a=t&Dge,c=t&Lge,l=t&Nge;if(e&&(o=n?e(s,r,n,i):e(s)),o!==void 0)return o;if(!Rge(s))return s;var u=bge(s);if(u){if(o=Tge(s),!a)return mge(s,o)}else{var h=Sge(s),d=h==Zv||h==Fge;if(Ege(s))return pge(s,a);if(h==Kv||h==qv||d&&!n){if(o=c||d?{}:Cge(s),!a)return c?vge(s,gge(o,s)):yge(s,fge(o,s))}else{if(!ot[h])return n?s:{};o=Ige(s,h,a)}}i||(i=new uge);var f=i.get(s);if(f)return f;i.set(s,o),kge(s)?s.forEach(function(S){o.add(pa(S,t,e,S,s,i))}):xge(s)&&s.forEach(function(S,b){o.set(b,pa(S,t,e,b,s,i))});var g=l?c?wge:Mge:c?Pge:Age,y=u?void 0:g(s);return hge(y||s,function(S,b){y&&(b=S,S=s[b]),dge(o,b,pa(S,t,e,b,s,i))}),o}var ipe=pa,spe=ipe,ope=1,ape=4;function cpe(s){return spe(s,ope|ape)}var lpe=cpe;const ht=ln(lpe),upe={maxRetries:3,timeoutMs:15e3,retryIntervalMs:1e3};function od(s){const t={...upe,...s};if(t.maxRetries!==-1&&(!Number.isInteger(t.maxRetries)||t.maxRetries<0||t.maxRetries>10))throw new RangeError("backgroundImageLoadOptions.maxRetries must be -1 (infinite retry) or an integer from 0 to 10");if(t.maxRetries===-1&&(t.maxRetries=Number.POSITIVE_INFINITY),!Number.isFinite(t.timeoutMs)||t.timeoutMs<1e3||t.timeoutMs>12e4)throw new RangeError("backgroundImageLoadOptions.timeoutMs must be from 1000 to 120000");if(!Number.isFinite(t.retryIntervalMs)||t.retryIntervalMs<0||t.retryIntervalMs>3e4)throw new RangeError("backgroundImageLoadOptions.retryIntervalMs must be from 0 to 30000");return t}class hpe{constructor(t,e){x(this,"tasks",new Map);x(this,"failedTasks",new Map);x(this,"options");x(this,"queue",[]);x(this,"activeAttempts",0);x(this,"maxActiveAttempts",4);this.onEvent=e,this.options=od(t)}load(t){const e=this.keyOf(t);if(this.cancel(e),this.failedTasks.delete(e),!t.isActive())return Promise.resolve();const r={...t,key:e,attempt:0,generation:0,settled:!1};return this.tasks.set(e,r),this.enqueue(r),Promise.resolve()}cancelByViewScene(t,e){for(const r of this.tasks.values())r.viewId===t&&(!e||r.scenePath===e)&&this.cancel(r.key);for(const[r,n]of this.failedTasks)n.viewId===t&&(!e||n.scenePath===e)&&this.failedTasks.delete(r)}cancelResource(t,e,r){const n=this.keyOf({viewId:t,scenePath:e,resourceId:r});this.cancel(n),this.failedTasks.delete(n)}cancelAll(){for(const t of[...this.tasks.keys()])this.cancel(t);this.failedTasks.clear()}reload(t){var i;if(t.source!=="appliance")return{accepted:!1,reloadedCount:0,reason:"resourceNotFound"};const e=[...this.failedTasks.values()].filter(o=>o.viewId===t.viewId&&o.scenePath===t.scenePath);if(!e.length)return{accepted:!1,reloadedCount:0,reason:[...this.tasks.values()].some(a=>a.viewId===t.viewId&&a.scenePath===t.scenePath)?"alreadyLoading":"resourceNotFound"};const r=e.filter(o=>o.isActive());if(!r.length)return{accepted:!1,reloadedCount:0,reason:"sceneNotFocused"};let n=0;for(const o of r)this.failedTasks.delete(this.keyOf(o)),t.url&&((i=o.onReloadUrl)==null||i.call(o,t.url)),this.load(t.url?{...o,src:t.url}:o),n+=1;return{accepted:!0,reloadedCount:n}}keyOf(t){return`${t.viewId}\0${t.scenePath}\0${t.resourceId}`}async attempt(t){if(!this.canRun(t)){this.cancel(t.key);return}t.attempt+=1;const e=++t.generation;try{if(await this.loadImage(t,e),!this.canRun(t)||t.generation!==e)return;t.settled=!0,this.tasks.delete(t.key),this.emit(t,"success")}catch{if(!this.canRun(t)||t.generation!==e)return;if(this.options.maxRetries===-1||this.options.maxRetries===Number.POSITIVE_INFINITY||t.attempt<=this.options.maxRetries){const r=Math.floor(Math.random()*Math.min(100,this.options.retryIntervalMs));t.timer=setTimeout(()=>{t.timer=void 0,this.enqueue(t)},this.options.retryIntervalMs+r)}else t.settled=!0,this.tasks.delete(t.key),this.failedTasks.set(t.key,{viewId:t.viewId,scenePath:t.scenePath,resourceId:t.resourceId,src:t.src,image:t.image,isActive:t.isActive,onReloadUrl:t.onReloadUrl}),this.emit(t,"failed")}}enqueue(t){!this.canRun(t)||this.queue.includes(t)||(this.queue.push(t),this.drain())}drain(){for(;this.activeAttempts<this.maxActiveAttempts&&this.queue.length;){const t=this.queue.shift();this.canRun(t)&&(this.activeAttempts+=1,this.attempt(t).finally(()=>{this.activeAttempts-=1,this.drain()}))}}loadImage(t,e){return new Promise((r,n)=>{const i=t.image,o=()=>{t.timer&&(clearTimeout(t.timer),t.timer=void 0),i.onload=null,i.onerror=null,t.cancelAttempt=void 0};i.dataset.netlessBackgroundImageManaged="true",i.onload=()=>{o(),r()},i.onerror=()=>{o(),n(new Error("background image load failed"))},t.timer=setTimeout(()=>{o(),i.removeAttribute("src");const a=new Error("background image load timed out");a.name="TimeoutError",n(a)},this.options.timeoutMs),t.cancelAttempt=()=>{o(),n(new Error("background image load cancelled"))},t.generation===e&&(i.src=t.src)})}canRun(t){return!t.settled&&this.tasks.get(t.key)===t&&t.isActive()}cancel(t){var r;const e=this.tasks.get(t);!e||e.settled||(e.settled=!0,e.generation+=1,(r=e.cancelAttempt)==null||r.call(e),e.timer&&(clearTimeout(e.timer),e.timer=void 0),e.image.onload=null,e.image.onerror=null,e.image.removeAttribute("src"),this.tasks.delete(t),this.emit(e,"cancelled"))}emit(t,e){var r;try{(r=this.onEvent)==null||r.call(this,{name:"backgroundImageLoad",state:e,source:"appliance",resourceId:t.resourceId,resourceUrl:t.src,viewId:t.viewId,scenePath:t.scenePath})}catch(n){console.error("[backgroundImage] onBackgroundImageLoadEvent callback failed",n)}}}const dpe="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==",fpe="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=",gpe="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==",ppe="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",mpe="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",ype="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",kr=Object.freeze([12,14,18,24,36,48,64,80,144,288]),bi=["top","topLeft","topRight","bottom","bottomLeft","bottomRight","left","leftTop","leftBottom","right","rightTop","rightBottom"],Ms=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+"]]),ad=new Map([["selector",{key:"selector",standardResolution:Ms.get("selector"),highResolution:gpe}],["shapeSynced",{key:"shape",standardResolution:mpe}],["textSynced",{key:"text",standardResolution:ype}],["pencil",{key:"pencil",standardResolution:Ms.get("pencil"),highResolution:dpe}],["eraser",{key:"eraser",standardResolution:Ms.get("eraser"),highResolution:fpe}],["text",{key:"text",standardResolution:Ms.get("text")}],["shape",{key:"shape",standardResolution:Ms.get("shape")}],["clicker",{key:"clicker",standardResolution:ppe}]]),Zr={enable:!0,expirationTime:5e3,moveDelayTime:40,preloadTimeout:5e3,appearance:{},syncedLabel:{enableShowName:!0,placement:"top",gap:2,maxWidth:88}};function cd(s){var e,r,n,i;const t={...s==null?void 0:s.appearance};return delete t[De.hand],delete t[De.laserPointer],{enable:(s==null?void 0:s.enable)??Zr.enable,expirationTime:(s==null?void 0:s.expirationTime)??Zr.expirationTime,moveDelayTime:(s==null?void 0:s.moveDelayTime)??Zr.moveDelayTime,preloadTimeout:typeof(s==null?void 0:s.preloadTimeout)=="number"&&Number.isFinite(s.preloadTimeout)&&s.preloadTimeout>0?s.preloadTimeout:Zr.preloadTimeout,appearance:t,syncedLabel:{enableShowName:((e=s==null?void 0:s.syncedLabel)==null?void 0:e.enableShowName)??Zr.syncedLabel.enableShowName,placement:((r=s==null?void 0:s.syncedLabel)==null?void 0:r.placement)??Zr.syncedLabel.placement,gap:((n=s==null?void 0:s.syncedLabel)==null?void 0:n.gap)??Zr.syncedLabel.gap,maxWidth:((i=s==null?void 0:s.syncedLabel)==null?void 0:i.maxWidth)??Zr.syncedLabel.maxWidth}}}function vpe(s,t){var e,r;return((r=(e=s.appearance[t])==null?void 0:e.synced)==null?void 0:r.enableShowName)??s.syncedLabel.enableShowName}function Mpe(s,t){return{...s,...t,cursor:cd(t==null?void 0:t.cursor)}}const Xv=500;function Pc(s){return typeof s!="number"||!Number.isFinite(s)||s<=0?Xv:Math.max(1,Math.floor(s))}const Dc="1.1.43-beta.5",wpe="@netless/appliance-plugin",Spe=typeof __RENDER_RUNTIME_BUILD_MARKER__=="string"?__RENDER_RUNTIME_BUILD_MARKER__:"",Ou=5e3,Tpe=1e4,Ipe=1e4;if(typeof window<"u"){let s=window.__netlessUA||"";s+=` ${wpe}@${Dc}`,window.__netlessUA=s}const He={useWorker:"auto",allowImageBitmapFallback:!0,useSimple:!0,workerRenderModeBlacklist:{},workerCanvasContextBlacklist:{},workerMaskTextureFormatBlacklist:{},workerMaskTextureUploadBlacklist:{},fontFaceFallbackBlacklist:{iosWebView:{12:Js.RefreshTextRender}},useBackgroundThread:!1,syncOpt:{interval:300,smoothSync:!0},syncLogger:{batchWindowMs:4e3},cursor:{...Zr},bufferSize:{full:4e3,sub:600},bezier:{enable:!1,maxDrawCount:1/0,combineUnitTime:300},pencilEraser:{useBitMap:!0,fullLayerDoingMaskMaxInputPoints:Xv,removeOnDone:!0,maxImageWidth:1920,maxImageHeight:1920},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:Ou},markmap:{enable:!0,timeout:1e4,options:{autoFit:!0,duration:0,zoom:!1,pan:!1,maxInitialScale:10}},overwriteSelectorStyles:{},backgroundImageLoadOptions:od()},Ln=(s,t,e)=>({images:ad.get(s),size:{width:26,height:26},offset:{x:0,y:0},local:{size:t,offset:e},synced:{}}),rp={...Ln("pencil",{width:26,height:26},{x:-2,y:4}),synced:{offset:{x:0,y:9}}},Cpe={...Ln("selector",{width:25,height:25},{x:-5,y:21}),synced:{offset:{x:0,y:26}}},bpe={...Ln("eraser",{width:26,height:26},{x:-8,y:8}),synced:{offset:{x:-5,y:13}}},Epe={...Ln("eraser",{width:26,height:26},{x:-8,y:8}),synced:{offset:{x:-5,y:13}}},xpe=Ln("eraser",{width:26,height:26},{x:-8,y:8}),Rpe={...Ln("text",{width:47,height:40},{x:-20,y:20}),synced:{images:ad.get("textSynced"),offset:{x:-13,y:16}}},mn={...Ln("shape",{width:40,height:40},{x:-20,y:20}),synced:{images:ad.get("shapeSynced"),offset:{x:-9,y:16}}},kpe={...Ln("clicker",{width:24,height:24},{x:-4,y:21}),synced:{offset:{x:0,y:26}}},ma=Object.freeze({[De.selector]:Cpe,[De.clicker]:kpe,[De.pencil]:rp,[De.rectangle]:mn,[De.ellipse]:mn,[De.shape]:mn,[De.eraser]:bpe,[De.pencilEraser]:Epe,[De.text]:Rpe,[De.straight]:mn,[De.arrow]:mn,[De.laserPen]:rp,[or.star]:mn,[or.polygon]:mn,[or.speechBalloon]:mn,[or.bitMapEraser]:xpe});function Jv(s){var e;return{...Mpe(He,s),pencilEraser:{...He.pencilEraser,...s==null?void 0:s.pencilEraser,fullLayerDoingMaskMaxInputPoints:Pc((e=s==null?void 0:s.pencilEraser)==null?void 0:e.fullLayerDoingMaskMaxInputPoints)},syncLogger:{...He.syncLogger,...s==null?void 0:s.syncLogger},backgroundImageLoadOptions:od(s==null?void 0:s.backgroundImageLoadOptions)}}const _v=new WeakMap,Ape=new WeakMap,Pa=new WeakMap,np=new WeakMap,ip=new WeakMap;function Ppe(s,t,e,r){let n=Pa.get(s);n||(n=new Map,Pa.set(s,n)),n.set(t,{...e,gestureOwner:r})}function Dpe(s,t){if(!s)return;const e=Pa.get(s),r=e==null?void 0:e.get(t);if(!r)return;if(e==null||e.delete(t),e!=null&&e.size||Pa.delete(s),!r.gestureOwner)return r;const n=np.get(r.gestureOwner),i=e0(r.matrix,n==null?void 0:n.matrix);if(np.set(r.gestureOwner,{matrix:r.matrix,toDigest:r.toDigest}),!!i)return{matrix:i,fromDigest:(n==null?void 0:n.toDigest)||r.fromDigest,toDigest:r.toDigest}}function Lpe(s,t,e,r){const n=e?e0(r,ip.get(e)):r;return e&&ip.set(e,r),n?(ld(s,t,n),!0):(t0(s,t),!1)}function e0(s,t){if(!t)return[...s];const e=Ope(t);return e?Npe(s,e):void 0}function Npe(s,t){return[s[0]*t[0]+s[2]*t[1],s[1]*t[0]+s[3]*t[1],s[0]*t[2]+s[2]*t[3],s[1]*t[2]+s[3]*t[3],s[0]*t[4]+s[2]*t[5]+s[4],s[1]*t[4]+s[3]*t[5]+s[5]]}function Ope(s){const[t,e,r,n,i,o]=s,a=t*n-e*r;if(!(!Number.isFinite(a)||Math.abs(a)<=Number.EPSILON))return[n/a,-e/a,-r/a,t/a,(r*o-n*i)/a,(e*i-t*o)/a]}function ld(s,t,e){var r;for(const n of((r=_v.get(s))==null?void 0:r.get(t))||[])n(e)}function zpe(s,t){var e,r;return!!((r=(e=_v.get(s))==null?void 0:e.get(t))!=null&&r.size)}function t0(s,t){var e;for(const r of((e=Ape.get(s))==null?void 0:e.get(t))||[])r()}const ud=16,Bpe=1;function $i(s){return Object.prototype.hasOwnProperty.call(s,"eraserFaces")}function zu(s,t){const e={...t};return $i(t)?delete e.eraserlines:s&&$i(s)&&(e.eraserFaces=s.eraserFaces??null,delete e.eraserlines),e}function Da(s){const t={...s};return delete t.doingLines,t}function jpe(s,t,e){const r=$i(s)?s.eraserFaces?La(s.eraserFaces):[]:sp(s.eraserlines||[]);return{eraserFaces:r0(op(r,op([],sp(t))))}}function r0(s,t=ud){if(!Number.isSafeInteger(t)||t<=0)throw new Error("eraserFaces scale must be a positive safe integer");const e=[];Bs(e,s.length);for(const r of s){Bs(e,r.rings.length);for(const n of r.rings){Bs(e,n.length);let i=0,o=0;n.forEach(([a,c],l)=>{const u=cp(a,t),h=cp(c,t);lp(e,l===0?u:u-i),lp(e,l===0?h:h-o),i=u,o=h})}}return{v:1,s:t,e:1,d:s0(e)}}function La(s){if(s.v!==1||s.e!==1||s.s<=0)throw new Error("unsupported eraserFaces payload");const t=new Wpe(Vpe(s.d)),e=[],r=t.readUVarint();for(let n=0;n<r;n++){const i=[],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 f=t.readSVarint(),g=t.readSVarint();u=d===0?f:u+f,h=d===0?g:h+g,c.push([u/s.s,h/s.s])}i.push(c)}e.push({rings:i})}if(!t.done)throw new Error("trailing eraserFaces bytes");return e}function sp(s,t=ud){const e=[];for(const r of s){const n=new Ct.ClipperOffset;n.ArcTolerance=Math.max(.25,t*.05);for(const i of r.op){const o=[];for(let a=0;a<i.length;a+=2)o.push({X:Math.round(i[a]*t),Y:Math.round(i[a+1]*t)});o.length===1&&o.push({...o[0]}),o.length>=2&&n.AddPath(o,Ct.JoinType.jtRound,Ct.EndType.etOpenRound)}n.Execute(e,r.thickness*t/2)}return i0(e,t)}function op(s,t,e=ud){const r=[...s,...t].flatMap(n=>n.rings.map(i=>i.map(([o,a])=>({X:Math.round(o*e),Y:Math.round(a*e)}))));return i0(r,e)}function Hs(s,t){const e=[Bpe];return up(e,s),up(e,t),s0(Array.from(Upe(Uint8Array.from(e)).slice(0,16)))}function n0(s,t,e){return s.matrix.length===6&&s.matrix.every(Number.isFinite)&&s.fromDigest===Hs(t,e)&&/^[A-Za-z0-9_-]{22}$/.test(s.toDigest)}function Fpe(s,t,e,r,n){return!n0(e,r.op,r.centerPos)||e.toDigest!==Hs(n.op,n.centerPos)?!1:(ld(s,t,e.matrix),!0)}function zl(s,t){if(!s)return null;const e=La(s);for(const r of e)for(const n of r.rings){const i=n.flat();t(i),r.rings[r.rings.indexOf(n)]=Array.from({length:i.length/2},(o,a)=>[i[a*2],i[a*2+1]])}return r0(e,s.s)}function i0(s,t){if(!s.length)return[];const e=new Ct.Clipper;e.AddPaths(s,Ct.PolyType.ptSubject,!0);const r=new Ct.PolyTree;e.Execute(Ct.ClipType.ctUnion,r,Ct.PolyFillType.pftNonZero,Ct.PolyFillType.pftNonZero);const n=[],i=o=>{for(const a of o.Childs()){if(!a.IsHole()){const c=[ap(a.Contour(),t)];for(const l of a.Childs())l.IsHole()&&c.push(ap(l.Contour(),t));n.push({rings:c})}i(a)}};return i(r),n}function ap(s,t){return s.map(({X:e,Y:r})=>[e/t,r/t])}function cp(s,t){if(!Number.isFinite(s))throw new Error("eraserFaces coordinate must be finite");const e=Math.round(s*t);if(!Number.isSafeInteger(e))throw new Error("eraserFaces coordinate is out of range");return Object.is(e,-0)?0:e}function Bs(s,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),s.push(e)}while(t)}function lp(s,t){const e=t>=0?t*2:-t*2-1;Bs(s,e)}function up(s,t){Bs(s,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 i=Object.is(n,-0)?0:n;r.setFloat64(0,i,!0);for(let o=0;o<8;o++)s.push(r.getUint8(o))}}function Upe(s){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=s.length*8,r=Math.ceil((s.length+9)/64)*64,n=new Uint8Array(r);n.set(s),n[s.length]=128;const i=new DataView(n.buffer);i.setUint32(r-8,Math.floor(e/4294967296),!1),i.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]=i.getUint32(h+T*4,!1);for(let T=16;T<64;T++){const p=a[T-15],m=a[T-2],v=c(p,7)^c(p,18)^p>>>3,M=c(m,17)^c(m,19)^m>>>10;a[T]=a[T-16]+v+a[T-7]+M>>>0}let[d,f,g,y,S,b,I,N]=o;for(let T=0;T<64;T++){const p=c(S,6)^c(S,11)^c(S,25),m=S&b^~S&I,v=N+p+m+t[T]+a[T]>>>0,M=c(d,2)^c(d,13)^c(d,22),k=d&f^d&g^f&g,E=M+k>>>0;N=I,I=b,b=S,S=y+v>>>0,y=g,g=f,f=d,d=v+E>>>0}o[0]=o[0]+d>>>0,o[1]=o[1]+f>>>0,o[2]=o[2]+g>>>0,o[3]=o[3]+y>>>0,o[4]=o[4]+S>>>0,o[5]=o[5]+b>>>0,o[6]=o[6]+I>>>0,o[7]=o[7]+N>>>0}const l=new Uint8Array(32),u=new DataView(l.buffer);return o.forEach((h,d)=>u.setUint32(d*4,h,!1)),l}class Wpe{constructor(t){x(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 s0(s){let t="";for(let e=0;e<s.length;e+=32768)t+=String.fromCharCode(...s.slice(e,e+32768));return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Vpe(s){const t=s.replace(/-/g,"+").replace(/_/g,"/").padEnd(Math.ceil(s.length/4)*4,"="),e=atob(t);return Uint8Array.from(e,r=>r.charCodeAt(0))}function Lr(s,t=!0){const e=s.length;if(e<2)return"";let r=s[0],n=s[1];if(e===2)return`M${Ei(r)}L${Ei(n)}`;let i="";for(let o=2,a=e-1;o<a;o++)r=s[o],n=s[o+1],i+=xi(r,n);return t?`M${xi(s[0],s[1])}Q${Ei(s[1])}${xi(s[1],s[2])}T${i}${xi(s[e-1],s[0])}${xi(s[0],s[1])}Z`:`M${Ei(s[0])}Q${Ei(s[1])}${xi(s[1],s[2])}${s.length>3?"T":""}${i}L${Ei(s[e-1])}`}function $pe(s,t){const e=t>0?t:1,r=Math.floor(s.x*e),n=Math.floor(s.y*e),i=Math.ceil((s.x+s.w)*e),o=Math.ceil((s.y+s.h)*e);return{x:r,y:n,w:Math.max(1,i-r),h:Math.max(1,o-n)}}function Ype(s,t){const r=1/(t>0?t:1);return{x:s.x-r,y:s.y-r,w:s.w+r*2,h:s.h+r*2}}function Gpe(s,t,e){const r=Math.abs(e[0])||1,n=Math.abs(e[1])||1;return{size:[t.w/r,t.h/n],textureRect:[(s.x-t.x)/r,(s.y-t.y)/n,s.w/r,s.h/n]}}function Nn(s){return JSON.parse(lm.decompress(s))}function xt(s){return lm.compress(JSON.stringify(s))}const at=Object.keys,hp=new WeakMap,Qt=class Qt{constructor(t){x(this,"maxImageWidth",He.pencilEraser.maxImageWidth);x(this,"maxImageHeight",He.pencilEraser.maxImageHeight);x(this,"syncUnitTime",He.syncOpt.interval);x(this,"vNodes");x(this,"drawLayer");x(this,"fullLayer");x(this,"workId");x(this,"confirmEraserDeletion",!1);x(this,"isDelete",!1);const{vNodes:e,fullLayer:r,drawLayer:n,workId:i,toolsOpt:o}=t;this.vNodes=e,this.fullLayer=r,this.drawLayer=n,this.workId=i,this.syncUnitTime=o.syncUnitTime||this.syncUnitTime}static async normalizeStorageData(t){return this.normalizeStorageDataSync(t)}static normalizeStorageDataSync(t){const e=ht(t),r=JSON.stringify(t);if(e.opt){const n=Da(e.opt);e.opt=zu(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=Qt.normalizeStorageDataSync(t);if(e.status==="unrecoverable")return e;const r=e.value;return r.type===le.DrawWork&&!r.ops&&Array.isArray(r.op)&&r.op.length?(r.type=le.FullWork,r.ops=xt(r.op),{status:"stable",value:r}):e}get baseConsumeResult(){return{workId:this.workId,toolsType:this.toolsType,opt:this.workOptions}}filterSamePoints(t,e=.01){return t.reduce((r,n)=>{const i=r[r.length-1];return(n&&!i||n&&i&&!n.isNear(i,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 i,o,a;const e=zu(this.workOptions,t);this.workOptions=e,this.syncUnitTime=t.syncUnitTime||this.syncUnitTime;const r=(i=this.workId)==null?void 0:i.toString(),n=r&&((o=this.vNodes)==null?void 0:o.get(r))||void 0;r&&n&&(n.opt=Da(e),(a=this.vNodes)==null||a.setInfo(r,n))}getRenderableEraserLines(t){return[...t.eraserlines||[],...t.doingLines||[]]}updataOptService(t){var n,i;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,f={};yt(l)&&(f.zIndex=l),c&&(f.pos=[c[0],c[1]]),u&&(f.scale=u),h&&(f.rotate=h),d&&(f.translate=d),a.attr(f);const g=a==null?void 0:a.getBoundingClientRect();return g&&(e=Ue(e,{x:Math.floor(g.x-Qt.SafeBorderPadding),y:Math.floor(g.y-Qt.SafeBorderPadding),w:Math.floor(g.width+Qt.SafeBorderPadding*2),h:Math.floor(g.height+Qt.SafeBorderPadding*2)})),(i=this.vNodes)==null||i.setInfo(r,{rect:e,centerPos:c}),e}}drawEraserlines(t,e){const{group:r,eraserlines:n=[],eraserFaces:i,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],f=h.height*u*a.worldScaling[1];let g=1;if((d>this.maxImageWidth||f>this.maxImageHeight)&&(g=Math.min(this.maxImageWidth/d,this.maxImageHeight/f)),c.renderer.glRenderer&&!this.confirmEraserDeletion&&this.drawEraserMask({group:r,eraserlines:n,eraserFaces:i,pos:o,layer:a,targetScale:g}))return;let y=a.getAttribute("scale");y=[y[0]*g,y[1]*g];const S=a.parent.parent,b=a.getAttribute("translate"),I=this.createVmRenderNode(`${this.workId}_bitMapLayer`,S,{offscreen:c.offscreen,width:c.width,height:c.height,contextType:"2d",autoRender:!1,bufferSize:500},y,b),N=r.cloneNode(!0);if(!n.length&&!i)return;i&&this.addEraserFaces(N,i,o,!1),this.addEraserlines(N,n,o,!1),I.appendChild(N);const T=I.parent;T.render();const p=I.renderer.canvasRenderer,m=p.context;if(!m)return;const v=p.options.displayRatio,M=N.getBoundingClientRect(),k={x:M.x,y:M.y,w:M.width,h:M.height},E={x:0,y:0,w:S.width,h:S.height};if(Bc(k,E)===sn.outside){ur(N,T),S.removeChild(T),this.isDelete=!0;return}const P=Ype(k,v),z=ht(P);z.x=Math.floor(Math.max(P.x,0)),z.y=Math.floor(Math.max(P.y,0)),z.w=Math.min(P.x+P.w,S.width)-z.x,z.h=Math.min(P.y+P.h,S.height)-z.y;const j=this.getGroupRect(z,v),A=j.x,R=j.y,L=j.w,W=j.h;let Y=m.getImageData(A,R,L,W);if(this.confirmEraserDeletion&&this.isTransparentRectByCanvas(Y)){ur(N,T),S.removeChild(T),this.isDelete=!0,Y=null;return}if(this.confirmEraserDeletion&&c.renderer.glRenderer&&this.drawEraserMask({group:r,eraserlines:n,eraserFaces:i,pos:o,layer:a,targetScale:g})){ur(N,T),S.removeChild(T),Y=null;return}ur(r,c);const H=this.createSpriteNode({imageData:Y,safariRect:z,originRect:P,worldScaling:I.worldScaling});H&&r.append(H),ur(N,T),S.removeChild(T),c.deleteTexture(Y),Y=null}catch(l){console.error("[BaseShapeTool] drawEraserlines error:",l);return}}drawEraserMask(t){var m,v;const{group:e,eraserlines:r,eraserFaces:n,pos:i,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)),f=Math.max(1,Math.ceil(l*h*o.worldScaling[1]*a)),g=[-c/2,-l/2,c,l];let y=hp.get(o);y||(y=new Map,hp.set(o,y)),this.pruneEraserMaskCaches(o,y,u);let S=y.get(this.workId),b=!S||S.pixelWidth!==d||S.pixelHeight!==f||S.facesKey!==(n==null?void 0:n.d);if(S&&!b&&(b=this.isEraserMaskPrefixChanged(S,r)),b){if(S==null||S.handle.destroy(u),S=this.createEraserMaskCache(d,f,g),!S)return!1;y.set(this.workId,S)}if(!S)return!1;const I=d/c,N=f/l;S.context.setTransform(I,0,0,N,d/2,f/2),b&&n&&(this.appendEraserMaskFaces(S.context,n,i),S.facesKey=n.d);let T=b,p;for(const M of r){const k=S.commands.get(M.workId),E=b?0:(k==null?void 0:k.count)||0;for(let D=E;D<M.op.length;D++)T=!0,p=Ue(p,this.appendEraserMaskStroke(S.context,M.op[D],M.thickness,i));S.commands.set(M.workId,{count:M.op.length,thickness:M.thickness,first:(m=M.op[0])==null?void 0:m.slice(0,2),last:(v=M.op[M.op.length-1])==null?void 0:v.slice(-2)})}return T&&S.handle.update({rect:g,dirtyRect:b||!p?void 0:[p.x,p.y,p.w,p.h]}),e.setMask(S.handle,{rect:g}),!0}pruneEraserMaskCaches(t,e,r){for(const[n,i]of e)n!==this.workId&&t.getElementsByName(n).length===0&&(i.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 i=n==null?void 0:n.getContext("2d");if(!(!n||!i))return i.save(),i.setTransform(1,0,0,1,0,0),i.fillStyle="#fff",i.fillRect(0,0,t,e),i.restore(),{canvas:n,context:i,handle:new Boe(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 i=e[0]-n[0],o=e[1]-n[1];if(e.length===2)t.beginPath(),t.arc(i,o,r/2,0,Math.PI*2),t.fill();else{t.beginPath(),t.moveTo(i,o);for(let g=2;g<e.length;g+=2)t.lineTo(e[g]-n[0],e[g+1]-n[1]);t.stroke()}t.restore();const a=[],c=[];for(let g=0;g<e.length;g+=2)a.push(e[g]-n[0]),c.push(e[g+1]-n[1]);const l=r/2+1,u=Math.min(...a),h=Math.min(...c),d=Math.max(...a),f=Math.max(...c);return{x:u-l,y:h-l,w:d-u+l*2,h:f-h+l*2}}appendEraserMaskFaces(t,e,r){t.save(),t.fillStyle="#000",t.beginPath();for(const n of La(e))for(const i of n.rings)i.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 i of e){const o=t.commands.get(i.workId);if(o&&(i.op.length<o.count||i.thickness!==o.thickness||!this.isSamePoint(o.first,(r=i.op[0])==null?void 0:r.slice(0,2))||!this.isSamePoint(o.last,(n=i.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,i){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",i),l.append(u),u}getGroupRect(t,e){return $pe(t,e)}addEraserlines(t,e,r,n=!0){for(const i of e){const{thickness:o,op:a}=i;for(const c of a){const l=c.map((g,y)=>y%2?g-r[1]:g-r[0]),u=this.computEraserPoints(l,o),h=Lr(u,!0),d={pos:[0,0],d:h,fillColor:"rgba(0,0,0,1)"},f=new $t(d);f.addEventListener("beforerender",({detail:g})=>{const y=g.context;n?y.blendFuncSeparate(y.ZERO,y.ZERO,y.ZERO,y.ZERO):y.globalCompositeOperation="destination-out"}),f.addEventListener("afterrender",({detail:g})=>{const y=g.context;n?y.blendFuncSeparate(y.SRC_ALPHA,y.ONE_MINUS_SRC_ALPHA,y.ONE,y.ONE_MINUS_SRC_ALPHA):y.globalCompositeOperation="source-over"}),t.append(f)}}}addEraserFaces(t,e,r,n=!0){const i=La(e).flatMap(a=>a.rings.map(c=>Lr(c.map(([l,u])=>new Pe(l-r[0],u-r[1])),!0))).join(" ");if(!i)return;const o=new $t({pos:[0,0],d:i,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:i}=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}=Gpe(n,i,r),l={name:"eraserTexture",anchor:[.5,.5],pos:[0,0],size:a,texture:o,textureRect:c},u=new Ic(l);let h=!0;return u.addEventListener("beforerender",({detail:d})=>{const f=d.context;typeof f.imageSmoothingEnabled=="boolean"&&(h=f.imageSmoothingEnabled,f.imageSmoothingEnabled=!1)}),u.addEventListener("afterrender",({detail:d})=>{const f=d.context;typeof f.imageSmoothingEnabled=="boolean"&&(f.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 Pe(t[0],t[1]);return Pe.GetDotStroke(r,e,8)}computLine(t,e){const r=[],n=[];let i,o;for(let a=0;a<t.length;a+=2){const c=new Pe(t[a],t[a+1]);let l;if(a==t.length-2){const u=new Pe(t[a-2],t[a-1]);l=fe.Sub(c,u).uni(),i=c}else{a===0&&(o=c);const u=new Pe(t[a+2],t[a+3]);l=fe.Sub(u,c).uni()}if(l){const u=fe.Per(l).mul(e);r.push(Pe.Sub(c,u)),n.push(Pe.Add(c,u))}}if(i&&o){const a=Pe.GetSemicircleStroke(i,r[r.length-1],-1,8),c=Pe.GetSemicircleStroke(o,n[0],-1,8);return r.concat(a,n.reverse(),c)}return[]}replace(t,e,r){var i;if(!e){r&&t.append(r);return}const n=t.getElementsByName(e);if(n.length)for(const o of n)r?Y0e(r,o,t):(o.remove(),hr(o,t.parent));else r&&t.append(r);this.fullLayer!==this.drawLayer&&(this.fullLayer===t?(i=this.drawLayer)==null||i.getElementsByName(e).forEach(a=>{var c;a.remove(),hr(a,(c=this.drawLayer)==null?void 0:c.parent)}):this.fullLayer.getElementsByName(e).forEach(a=>{a.remove(),hr(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(),hr(n,t.parent)}static updateNodeOpt(t){var m;const{node:e,opt:r,vNodes:n,willSerializeData:i,targetNode:o}=t,{zIndex:a,translate:c,angle:l,originPoint:u,scenePoint:h,scale:d,pointMap:f,thickness:g}=r;let y;const S=o&&ht(o)||n.get(e.name);if(!S)return;const b=r.eraserGeometryDelta,N=!!b||!!u&&!!d&&!!o||!!i&&(!!c||yt(l))?Hs(S.op,S.centerPos):void 0;if(b&&(!N||!n0(b,S.op,S.centerPos)))return;b&&ld(n,e.name,b.matrix);let T;yt(a)&&(e.setAttribute("zIndex",a),S.opt.zIndex=a);const p=e.parent;if(p){if(u&&d&&o){if(T=[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)],zc(S.op,h,d,c),Fs(S.centerPos,h,d,c),S.opt.translate=void 0,S.opt.scale=void 0,S.opt.eraserlines)for(let v=0;v<S.opt.eraserlines.length;v++){const{op:M,thickness:k}=S.opt.eraserlines[v];S.opt.eraserlines[v].thickness=Math.round(k*Math.max(Math.abs(d[0]),Math.abs(d[1])));for(let E=0;E<M.length;E++)Fs(M[E],h,d,c)}$i(S.opt)&&(S.opt.eraserFaces=zl(S.opt.eraserFaces??null,v=>Fs(v,h,d,c)),delete S.opt.eraserlines)}else if(c)if(e.setAttribute("translate",c),S.opt.translate=c,o){const v=[c[0]*p.worldScaling[0],c[1]*p.worldScaling[1]];y=Ks(S.rect,v),S.rect=y}else{const v=Qt.getRectFromLayer(p,e.name);S.rect=v||S.rect}else if(yt(l))if(e.setAttribute("rotate",l),S.opt.rotate=l,o)y=Md(S.rect,l),S.rect=y;else{const v=Qt.getRectFromLayer(p,e.name);S.rect=v||S.rect}if(f){const v=f.get(e.name);if(v)for(let M=0,k=0;M<S.op.length;M+=3,k++)S.op[M]=v[k][0],S.op[M+1]=v[k][1]}if(g&&((m=S==null?void 0:S.opt)!=null&&m.thickness)&&(S.opt.thickness=g),i&&!(u&&d&&o)){if(c){T=[1,0,0,1,c[0],c[1]];const v=S.op.map((M,k)=>{const E=k%3;return E===0?M+c[0]:E===1?M+c[1]:M});if(S.op=v,S.centerPos=[S.centerPos[0]+c[0],S.centerPos[1]+c[1]],S!=null&&S.opt&&(S.opt.translate=void 0),S.opt.eraserlines)for(let M=0;M<S.opt.eraserlines.length;M++){const{op:k}=S.opt.eraserlines[M];for(let E=0;E<k.length;E++){const D=k[E].map((P,z)=>z%2?P+c[1]:P+c[0]);S.opt.eraserlines[M].op[E]=D}}$i(S.opt)&&(S.opt.eraserFaces=zl(S.opt.eraserFaces??null,M=>{for(let k=0;k<M.length;k+=2)M[k]+=c[0],M[k+1]+=c[1]}),delete S.opt.eraserlines)}else if(yt(l)){const v=Math.PI*l/180,M=Math.cos(v),k=Math.sin(v),[E,D]=S.centerPos;T=[M,k,-k,M,E-M*E+k*D,D-k*E-M*D];const P=S.op;if(j0e(P,S.centerPos,l),S.op=P,S!=null&&S.opt&&(S.opt.rotate=void 0),S.opt.eraserlines)for(let z=0;z<S.opt.eraserlines.length;z++){const{op:j}=S.opt.eraserlines[z];for(let A=0;A<j.length;A++)Bp(j[A],S.centerPos,l)}$i(S.opt)&&(S.opt.eraserFaces=zl(S.opt.eraserFaces??null,z=>Bp(z,S.centerPos,l)),delete S.opt.eraserlines)}}if(N&&T){const v=Hs(S.op,S.centerPos);if(b&&b.toDigest!==v)return;b||(Lpe(n,e.name,o,T),Ppe(n,e.name,{matrix:T,fromDigest:N,toDigest:v},o))}S&&n.setInfo(e.name,S)}}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-Qt.SafeBorderPadding),y:Math.floor(n.y-Qt.SafeBorderPadding),w:Math.floor(n.width+Qt.SafeBorderPadding*2),h:Math.floor(n.height+Qt.SafeBorderPadding*2)}}}static isWillRefresh(t){const{toolsType:e,opt:r,node:n,updateOpt:i,willSerializeData:o}=t;return!!(o&&(i.angle||i.translate)||i.thickness&&r.thickness&&r.thickness!==i.thickness||i.strokeType&&r.strokeType&&r.strokeType!==i.strokeType||i.originPoint&&i.scenePoint&&i.scale||i.pointMap&&i.pointMap.has(n.name)||e===q.Text&&(i.fontSize||i.translate||i.textInfos&&i.textInfos.get(n.name))||e===q.BackgroundSVG&&(i.translate||i.scale)||e===q.Image&&(i.angle||i.translate||i.scale||i.strokeColor&&r.type===on.Iconify)||e===i.toolsType&&i.willRefresh||r.eraserlines&&r.eraserlines.length&&(i.strokeColor||i.fillColor))}};x(Qt,"SafeBorderPadding",10);let Re=Qt;const hd=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 o0(s,t,e=.01){return Math.abs(s[0]-t[0])<e&&Math.abs(s[1]-t[1])<e}function Hpe(s,t=.01){if(s.length===0)return[];const e=[[s[0][0],s[0][1]]];for(let r=1;r<s.length;r++)o0([s[r][0],s[r][1]],e[e.length-1],t)||e.push([s[r][0],s[r][1]]);return e}function Qpe(s,t=.01){if(s.length<=2)return s;const e=s[0],r=s[s.length-1];return o0(e,r,t)?s.slice(0,-1):s}function qpe(s){const t=s.reduce((r,n)=>r+n[0],0)/s.length,e=s.reduce((r,n)=>r+n[1],0)/s.length;return[t,e]}function dp(s,t){return Math.atan2(t[1]-s[1],t[0]-s[0])}function Zpe(s,t=.01){if(s.length<=2)return s;const e=[];for(const n of s)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=qpe(e);return e.sort((n,i)=>{const o=dp(r,n),a=dp(r,i);return o-a})}function Kpe(s,t){const e=t[0].x<t[t.length-1].x;return s.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],f=Math.sqrt(Math.pow(d.x-a[0],2)+Math.pow(d.y-a[1],2));f<l&&(l=f,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,i)=>{const o=n[0][0],a=i[0][0];return e?o-a:a-o})}function Xpe(s,t,e=.01){const n=s.map(h=>[h.x,h.y]),i=(h,d)=>h.map(([f,g])=>({X:Math.round(f*d),Y:Math.round(g*d)})),o=new Ct.ClipperOffset;o.AddPath(i(n,1e3),Ct.JoinType.jtRound,Ct.EndType.etOpenButt);const a=[];o.Execute(a,1);const c=new Ct.Clipper;c.AddPaths(a,Ct.PolyType.ptSubject,!0),t.forEach(h=>{c.AddPath(i(h,1e3),Ct.PolyType.ptClip,!0)});const l=new Ct.Paths;c.Execute(Ct.ClipType.ctDifference,l,Ct.PolyFillType.pftNonZero,Ct.PolyFillType.pftNonZero);const u=l.map(h=>Qpe(Zpe(Hpe(h.map(d=>[d.X/1e3,d.Y/1e3]),e),e),e)).filter(h=>h.length>=2);return Kpe(u,s)}class a0 extends Re{constructor(e){super(e);x(this,"canRotate",!0);x(this,"scaleType",Ye.all);x(this,"toolsType",q.Pencil);x(this,"syncTimestamp");x(this,"syncIndex",0);x(this,"tmpPoints",[]);x(this,"MAX_REPEAR",10);x(this,"uniThickness");x(this,"workOptions");x(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,i=e.y-r.y;if(n===0&&i===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:le.None};const r=this.transformDataAll(!0),n={name:e};let i;const o=this.drawLayer||this.fullLayer;return r.length&&(i=this.draw({attrs:n,tasks:r,replaceId:e,layer:o})),{rect:i,type:le.DrawWork,dataType:xe.Local}}setWorkOptions(e){super.setWorkOptions(e),this.syncTimestamp=Date.now()}consume(e){const{data:r,isFullWork:n,isSubWorker:i,isMainThread:o,drawCount:a,removeDrawCount:c,isSimpleWorker:l}=e,{workId:u,syncUnitTime:h}=r;h&&(this.syncUnitTime=h);const{tasks:d,effects:f,consumeIndex:g}=this.transformData(r,!1);this.syncIndex=Math.min(this.syncIndex,g,Math.max(0,this.tmpPoints.length-2));const y={name:u,id:yt(a)&&a.toString()||void 0};let S,b=!1;const I=this.syncIndex;if(this.syncTimestamp===0&&(this.syncTimestamp=Date.now()),d.length&&(d[0].taskId-this.syncTimestamp>this.syncUnitTime&&(b=!0,this.syncTimestamp=d[0].taskId,this.syncIndex=this.tmpPoints.length),i||o||l)){const p=n?this.fullLayer:this.drawLayer||this.fullLayer;S=this.draw({attrs:y,tasks:d,effects:f,layer:p,removeDrawCount:c})}if(l){const p=[];this.tmpPoints.slice(I).forEach(v=>{p.push(v.x,v.y,this.computRadius(v.z,this.workOptions.thickness))});const m=!this.workOptions.previewLocalOnly&&b;return{...this.baseConsumeResult,type:le.DrawWork,dataType:xe.Local,op:m?p:void 0,index:m?I*3:void 0,rect:S,updateNodeOpt:{useAnimation:!0}}}if(i)return g>10&&this.tmpPoints.splice(0,g-10),{rect:S,type:le.DrawWork,dataType:xe.Local};const N=[];this.tmpPoints.slice(I).forEach(p=>{N.push(p.x,p.y,this.computRadius(p.z,this.workOptions.thickness))});const T=!this.workOptions.previewLocalOnly&&b;return{...this.baseConsumeResult,type:le.DrawWork,dataType:xe.Local,rect:S,op:T?N:void 0,index:T?I*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===de.Done&&this.workOptions.strokeType===Be.Stroke&&this.updateTempPointsWithPressureWhenDone(h)}const n=this.fullLayer;if(this.tmpPoints.length<2)return this.replace(n,r),{type:le.RemoveNode,removeIds:[r]};const i=this.transformDataAll(!0),o={name:r};let a;i.length&&(a=this.draw({attrs:o,tasks:i,replaceId:r,layer:n}));const c=[];this.tmpPoints.map(h=>{c.push(h.x,h.y,h.z)}),this.syncTimestamp=0,delete this.workOptions.syncUnitTime;const l=xt(c);return(u=this.vNodes)==null||u.setInfo(r,{rect:a,op:c,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&Re.getCenterPos(a,n)}),{...this.baseConsumeResult,rect:a,type:le.FullWork,dataType:xe.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:i,workState:o=de.Done}=e;this.tmpPoints.length=0;for(let f=0;f<r.length;f+=3){const g=new Pe(r[f],r[f+1],r[f+2]);if(this.tmpPoints.length>0){const y=this.tmpPoints[this.tmpPoints.length-1];if(!this.setPointVector(g,y))continue}this.tmpPoints.push(g)}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 f=n?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({attrs:l,tasks:a,replaceId:i,layer:f,isDrawEraserlines:o===de.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&&Re.getCenterPos(u,f)})}return u}computPencilPoints(e){const r=[],{op:n,eraserPolylines:i,eraserThickness:o}=e;this.tmpPoints.length=0;for(let c=0;c<n.length;c+=3){const l=new Pe(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(g=>g.point.addXY(l[0],l[1])),d=[];for(const g of i){const y=[];for(let b=0;b<g.length;b+=2){const I=new Pe(g[b],g[b+1]);if(y.length>0){const N=y[y.length-1].point;if(!this.setPointVector(I,N))continue}y.push({point:I,radius:o})}const{ps:S}=this.computStroke(y,!1);d.push(S.map(b=>b.XY))}Xpe(h,d,.01).forEach(g=>{r.push(g.map(y=>[y[0],y[1],y[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:i,effects:o,layer:a,removeDrawCount:c,isDrawEraserlines:l=!0}=e,{strokeColor:u,strokeType:h,thickness:d,zIndex:f,scale:g,rotate:y,translate:S,eraserlines:b,eraserFaces:I,doingLines:N,lineCap:T,lineDash:p}=this.workOptions;o!=null&&o.size&&(o.forEach(D=>{var P;(P=a.getElementById(D+""))==null||P.remove()}),o.clear()),c&&this.removeDrawCountNodes(a,c);let m;const v=[],M=a.worldPosition,k=a.worldScaling;for(let D=0;D<n.length;D++){const{pos:P,points:z}=n[D],{ps:j,rect:A}=this.computDrawPoints(z);let R;const L=z.length===1;h===Be.Stroke||L?R=Lr(j,!0):R=Lr(j,!1);const W={pos:P,d:R,fillColor:h===Be.Stroke||L?u:void 0,lineDash:L?void 0:h===Be.Dotted?[p&&p[0]||1,(p&&p[1]||2)*d]:h===Be.LongDotted?[(p&&p[0]||1)*d,(p&&p[1]||2)*d]:void 0,strokeColor:u,lineCap:L?void 0:T,lineWidth:h===Be.Stroke||L?0:d};m=Ue(m,{x:Math.floor((A.x+P[0])*k[0]+M[0]-Re.SafeBorderPadding),y:Math.floor((A.y+P[1])*k[1]+M[1]-Re.SafeBorderPadding),w:Math.floor(A.w*k[0]+2*Re.SafeBorderPadding),h:Math.floor(A.h*k[1]+2*Re.SafeBorderPadding)}),v.push(W)}g&&(r.scale=g),y&&(r.rotate=y),S&&(r.translate=S);const E=new dt;if(m){this.centerPos=Re.getCenterPos(m,a);const D=h===Be.Stroke&&!b&&!I&&!N;E.attr({...r,normalize:!0,anchor:[.5,.5],bgcolor:D?u:void 0,pos:this.centerPos,size:[(m.w-2*Re.SafeBorderPadding)/k[0],(m.h-2*Re.SafeBorderPadding)/k[1]],zIndex:f});const P=v.map(z=>(z.pos=[z.pos[0]-this.centerPos[0],z.pos[1]-this.centerPos[1]],new $t(z)));E.append(...P),D&&E.seal(),(b||I||N)&&(this.scaleType=Ye.proportional,this.drawEraserlines({group:E,eraserlines:this.getRenderableEraserLines(this.workOptions),eraserFaces:I,pos:this.centerPos,layer:a},l)),this.replace(a,i,E)}if(g||y||S){const D=E==null?void 0:E.getBoundingClientRect();D&&(m={x:Math.floor(D.x-Re.SafeBorderPadding),y:Math.floor(D.y-Re.SafeBorderPadding),w:Math.floor(D.width+Re.SafeBorderPadding*2),h:Math.floor(D.height+Re.SafeBorderPadding*2)})}return this.isDelete&&E.setAttribute("opacity",0),m}computDrawPoints(e){return this.workOptions.strokeType===Be.Stroke||e.length===1?this.computStroke(e):this.computNomal(e)}computNomal(e){let r=this.workOptions.thickness;const n=e.map(i=>(r=Math.max(r,i.radius),i.point));return{ps:n,rect:it(n,r)}}computStroke(e,r=!0){return e.length===1?this.computDotStroke(e[0]):this.computLineStroke(e,r)}computLineStroke(e,r=!0){const n=[],i=[];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(Pe.Sub(l,d)),i.push(Pe.Add(l,d))}const o=e[e.length-1];if(r){const c=Pe.GetSemicircleStroke(o.point,n[n.length-1],-1,8),l=Pe.GetSemicircleStroke(e[0].point,i[0],-1,8),u=n.concat(c,i.reverse(),l);return{ps:u,rect:it(u)}}const a=n.concat(i.reverse());return{ps:a,rect:it(a)}}computDotStroke(e){const{point:r,radius:n}=e,i={x:r.x-n,y:r.y-n,w:n*2,h:n*2};return{ps:Pe.GetDotStroke(r,n,8),rect:i}}transformData(e,r){const{op:n,workState:i}=e;let o=this.tmpPoints.length-1,a=[];if(n!=null&&n.length&&i){const{strokeType:c,thickness:l}=this.workOptions,u=new Set,h=Math.max(0,this.tmpPoints.length-1);c===Be.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 i=0,o=e[0].x,a=e[0].y,c=[o,a],l=[],u=e[0].t;for(;i<e.length;){const d=e[i],f=d.x-o,g=d.y-a,y=d.z,S=r?this.computRadius(y,r):y;if(l.push({point:new Pe(f,g,y,e[i].v),radius:S}),i>0&&i<e.length-1){const b=e[i].getAngleByPoints(e[i-1],e[i+1]);if(b<60||b>300){const I=(h=l.pop())==null?void 0:h.point.clone();I&&n.push({taskId:u,pos:c,points:[...l,{point:I,radius:S}]}),o=e[i].x,a=e[i].y,c=[o,a];const N=d.x-o,T=d.y-a;l=[{point:new Pe(N,T,y),radius:S}],u=Date.now()}}i++}return n.push({taskId:u,pos:c,points:l}),n}updateTempPointsWithPressure(e,r,n){const i=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 Pe(e[l],e[l+1]);if(u===0){this.tmpPoints.push(h);continue}const d=u-1,f=this.tmpPoints[d];if(h.x===f.x&&h.y===f.y){f.z<this.MAX_REPEAR&&f.setz(Math.min(f.z+1,this.MAX_REPEAR));continue}const g=fe.Sub(h,f).uni();if(h.isNear(f,r)){let b=f.z;if(f.z<this.MAX_REPEAR&&(b=Math.min(f.z+1,this.MAX_REPEAR),u>1)){let T=u-1;for(;T>0;){const p=this.tmpPoints[T].distance(this.tmpPoints[T-1]),m=Math.max(this.tmpPoints[T].z-this.uniThickness*p,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),f.t){h.setz(b),h.setv(g),this.tmpPoints.push(h);continue}const I=this.tmpPoints[d-1],N=I?fe.Sub(h,I).uni():f.v;f.set(h.x,h.y,b,N);continue}h.setv(g);const y=h.distance(f),S=Math.max(f.z-this.uniThickness*y,0);u>1&&fe.Equals(g,f.v,.01)&&(S>0||f.z<=0)&&(f.t||this.tmpPoints.pop(),a=Math.min(d,a)),h.setz(S),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(i),c}updateTempPoints(e,r,n){var l;const i=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 Pe(e[u],e[u+1]);if(h===0){this.tmpPoints.push(d);continue}const f=h-1,g=this.tmpPoints[f];if(d.x===g.x&&d.y===g.y)continue;const y=fe.Sub(d,g).uni();if(d.isNear(g,r/2)){if(g.t){d.setz(g.z),d.setv(y),this.tmpPoints.push(d),a=Math.min(f,a);continue}const S=this.tmpPoints[f-1],b=S?fe.Sub(d,S).uni():g.v;g.set(d.x,d.y,g.z,b),a=Math.min(f,a);continue}fe.Equals(y,g.v,.01)&&(g.t||this.tmpPoints.pop(),a=Math.min(f,a)),d.setv(y),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(i),c}updateTempPointsWithPressureWhenDone(e){const{thickness:r}=this.workOptions,n=e.length,i=this.getMinZ(r);for(let o=0;o<n;o+=2){const a=this.tmpPoints.length,c=new Pe(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===i)break;if(c.isNear(u,r/2)){let g=u.z;if(n<3&&u.z<this.MAX_REPEAR&&(g=Math.min(u.z+1,this.MAX_REPEAR),a>1)){let b=a-1;for(;b>0;){const I=this.tmpPoints[b].distance(this.tmpPoints[b-1]),N=Math.max(this.tmpPoints[b].z-this.uniThickness*I,-r/4);if(this.tmpPoints[b-1].z>=N)break;this.tmpPoints[b-1].setz(N),b--}}if(u.t){c.setz(g),c.setv(h),this.tmpPoints.push(c);continue}const y=this.tmpPoints[l-1],S=y?fe.Sub(c,y).uni():u.v;u.set(c.x,c.y,g,S);continue}c.setv(h);const f=Math.max(u.z-this.uniThickness*d,i);a>1&&fe.Equals(h,u.v,.01)&&u.z<=0&&(u.t||this.tmpPoints.pop()),c.setz(f),this.tmpPoints.push(c)}}static updateNodeOpt(e){var h,d;const{node:r,opt:n,vNodes:i}=e,{strokeColor:o,strokeType:a,lineCap:c,lineDash:l}=n,u=i.get(r.name);return o&&(r.tagName==="GROUP"?$0e(r)?r.setAttribute("bgcolor",o):r.children.forEach(f=>{f.setAttribute("strokeColor",o),f.getAttribute("fillColor")&&f.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&&i.setInfo(r.name,u),Re.updateNodeOpt(e)}}class c0 extends Re{constructor(e){super(e);x(this,"toolsType",q.LaserPen);x(this,"canRotate",!1);x(this,"scaleType",Ye.none);x(this,"syncTimestamp");x(this,"syncIndex",0);x(this,"tmpPoints",[]);x(this,"workOptions");x(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:i,op:o,syncUnitTime:a}=r;if((o==null?void 0:o.length)===0)return{type:le.None};if(a&&(this.syncUnitTime=a),this.updateTempPoints(o||[]),this.consumeIndex>this.tmpPoints.length-4)return{type:le.None};const{strokeColor:c,thickness:l,strokeType:u,lineDash:h,lineCap:d}=this.workOptions,f=it(this.tmpPoints,l);let g=!1;const y=this.syncIndex,S=this.tmpPoints.slice(this.consumeIndex);this.consumeIndex=this.tmpPoints.length-1,this.syncTimestamp===0&&(this.syncTimestamp=Date.now());const b={name:i==null?void 0:i.toString(),opacity:1,lineDash:u===Be.Dotted?[h&&h[0]||1,(h&&h[1]||2)*l]:u===Be.LongDotted?[(h&&h[0]||1)*l,(h&&h[1]||2)*l]:void 0,strokeColor:c,lineCap:d,lineWidth:l,anchor:[.5,.5]},I=this.getTaskPoints(S);if(I.length){const T=Date.now();T-this.syncTimestamp>this.syncUnitTime&&(g=!0,this.syncTimestamp=T,this.syncIndex=this.tmpPoints.length),n&&this.draw({attrs:b,tasks:I,isDot:!1,layer:this.drawLayer||this.fullLayer})}const N=[];return this.tmpPoints.slice(y).forEach(T=>{N.push(T.x,T.y)}),{rect:{x:f.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:f.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:f.w*this.fullLayer.worldScaling[0],h:f.h*this.fullLayer.worldScaling[1]},type:le.DrawWork,dataType:xe.Local,op:g?N:void 0,index:g?y*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 g=this.computDotStroke({point:a[0],radius:u/2});a=g.ps,r=g.rect}else r=it(this.tmpPoints,u);const d={name:e==null?void 0:e.toString(),fillColor:c?l:void 0,opacity:1,lineDash:h===Be.Dotted&&!c?[1,u*2]:h===Be.LongDotted&&!c?[u,u*2]:void 0,strokeColor:l,lineCap:c?void 0:"round",lineWidth:c?0:u,anchor:[.5,.5]},f=this.getTaskPoints(a);f.length&&this.draw({attrs:d,tasks:f,isDot:c,layer:this.drawLayer||this.fullLayer})}const n=[];this.tmpPoints.forEach(a=>{n.push(a.x,a.y)});const i=xt(n);return{rect:r&&{x:r.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:r.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:r.w*this.fullLayer.worldScaling[0],h:r.h*this.fullLayer.worldScaling[1]},type:le.FullWork,dataType:xe.Local,ops:i,index:this.syncIndex*2,...this.baseConsumeResult}}clearTmpPoints(){this.tmpPoints.length=0,this.syncTimestamp=0,this.syncIndex=0}consumeService(e){var y;const{op:r,replaceId:n,isFullWork:i}=e,{strokeColor:o,thickness:a,strokeType:c}=this.workOptions;if(!r.length){const S=it(this.tmpPoints,a);return{x:S.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:S.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:S.w*this.fullLayer.worldScaling[0],h:S.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 S=this.computDotStroke({point:h[0],radius:a/2});h=S.ps,u=S.rect}else u=it(this.tmpPoints,a);const f={name:(y=this.workId)==null?void 0:y.toString(),fillColor:d?o:void 0,opacity:1,lineDash:c===Be.Dotted&&!d?[1,a*2]:c===Be.LongDotted&&!d?[a,a*2]:void 0,strokeColor:o,lineCap:d?void 0:"round",lineWidth:d?0:a,anchor:[.5,.5]},g=this.getTaskPoints(h);if(g.length){const S=i?this.fullLayer:this.drawLayer||this.fullLayer;this.draw({attrs:f,tasks:g,isDot:d,replaceId:n,layer:S})}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,i={x:r.x-n,y:r.y-n,w:n*2,h:n*2};return{ps:Pe.GetDotStroke(r,n,8),rect:i}}updateTempPoints(e){const r=this.tmpPoints.length;for(let n=0;n<e.length;n+=2){if(r){const i=this.tmpPoints.slice(-1)[0];i&&i.x===e[n]&&i.y===e[n+1]&&this.tmpPoints.pop()}this.tmpPoints.push(new Pe(e[n],e[n+1]))}}async draw(e){const{attrs:r,tasks:n,isDot:i,layer:o}=e,{duration:a}=this.workOptions;for(const c of n){const l=new $t,{pos:u,points:h}=c;let d;i?d=Lr(h,!0):d=Lr(h,!1),l.attr({...r,pos:u,d}),o.appendChild(l),l.transition(a).attr({scale:i?[.1,.1]:[1,1],lineWidth:i?0:1}).then(()=>{l.remove()})}}getTaskPoints(e){var l;const r=[];if(e.length===0)return[];let n=0,i=e[0].x,o=e[0].y,a=[i,o],c=[];for(;n<e.length;){const u=e[n],h=u.x-i,d=u.y-o;if(c.push(new Pe(h,d)),n>0&&n<e.length-1){const f=e[n].getAngleByPoints(e[n-1],e[n+1]);if(f<60||f>300){const g=(l=c.pop())==null?void 0:l.clone();g&&r.push({pos:a,points:[...c,g]}),i=e[n].x,o=e[n].y,a=[i,o];const y=u.x-i,S=u.y-o;c=[new Pe(y,S)]}}n++}return r.push({pos:a,points:c}),r}removeLocal(){}removeService(e){let r;const n=[];return this.fullLayer.getElementsByName(e).forEach(i=>{if(i.name===e){const o=i.getBoundingClientRect();r=Ue(r,{x:o.x,y:o.y,w:o.width,h:o.height}),n.push(i)}}),n.length&&n.forEach(i=>i.remove()),r}}const ji=class ji extends Re{constructor(e,r){super(e);x(this,"canRotate",!1);x(this,"scaleType",Ye.none);x(this,"toolsType",q.Eraser);x(this,"serviceWork");x(this,"tmpPoints",[]);x(this,"workOptions");x(this,"worldPosition");x(this,"worldScaling");x(this,"eraserRect");x(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:i,height:o}=ji.eraserSizes[this.workOptions.thickness];this.eraserRect={x:r-i*.5,y:n-o*.5,w:i,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]),i=fe.Sub(n,r).uni(),o=fe.Dist(r,n),{width:a,height:c}=ji.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 f=fe.Mul(i,d*l);h.push(this.tmpPoints[0]+f.x,this.tmpPoints[1]+f.y)}return h.concat(e)}}return e}isNear(e,r){const n=new fe(e[0],e[1]),i=new fe(r[0],r[1]),{width:o,height:a}=ji.eraserSizes[this.workOptions.thickness];return fe.Dist(n,i)<Math.hypot(o,a)*.5}remove(e){const{curNodeMap:r,removeIds:n}=e;let i;for(const o of r.values())if(o.rect&&this.eraserRect&&this.eraserPolyline&&Ua(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 Pe(d.x,d.y))}const u=c.length&&it(c)||o.rect;Ua(u,this.eraserRect)&&(l.length>1?th.polyline(l.map(d=>d.XY),this.eraserPolyline).length&&n.add(o.name):n.add(o.name),i=Ue(i,o.rect||u))}return n.forEach(o=>{var c;const a=this.fullLayer.getElementsByName(o);a[0]&&(a[0].remove(),hr(a[0],this.fullLayer.parent),(c=this.vNodes)==null||c.delete(o))}),i&&(i.x-=Re.SafeBorderPadding,i.y-=Re.SafeBorderPadding,i.w+=Re.SafeBorderPadding*2,i.h+=Re.SafeBorderPadding*2),i}consume(e){const{op:r,disableEraseImage:n,disableEraseText:i}=e.data;if(!r||r.length===0)return{type:le.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:le.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:le.None,...this.baseConsumeResult};const u=this.getCanEraserNodeMap(this.vNodes.getCanEraserNodes(this.vNodes.curNodeMap,{disableEraseImage:n,disableEraseText:i}));for(let h=0;h<a.length-1;h+=2){this.createEraserRect(a.slice(h,h+2));const d=this.remove({curNodeMap:u,removeIds:l});c=Ue(c,d)}return c&&l.size?{type:le.RemoveNode,rect:c,removeIds:[...l]}:{type:le.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),i=this.serviceWork.selectorWorkShapes,o=this.serviceWork.workShapes;for(const a of i.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}};x(ji,"eraserSizes",hd);let Na=ji;const Bt="++",Le="selector",Bu="all";var Jpe="__lodash_hash_undefined__";function _pe(s){return this.__data__.set(s,Jpe),this}var eme=_pe;function tme(s){return this.__data__.has(s)}var rme=tme,nme=xv,ime=eme,sme=rme;function Oa(s){var t=-1,e=s==null?0:s.length;for(this.__data__=new nme;++t<e;)this.add(s[t])}Oa.prototype.add=Oa.prototype.push=ime;Oa.prototype.has=sme;var dd=Oa;function ome(s,t){for(var e=-1,r=s==null?0:s.length;++e<r;)if(t(s[e],e,s))return!0;return!1}var ame=ome;function cme(s,t){return s.has(t)}var fd=cme,lme=dd,ume=ame,hme=fd,dme=1,fme=2;function gme(s,t,e,r,n,i){var o=e&dme,a=s.length,c=t.length;if(a!=c&&!(o&&c>a))return!1;var l=i.get(s),u=i.get(t);if(l&&u)return l==t&&u==s;var h=-1,d=!0,f=e&fme?new lme:void 0;for(i.set(s,t),i.set(t,s);++h<a;){var g=s[h],y=t[h];if(r)var S=o?r(y,g,h,t,s,i):r(g,y,h,s,t,i);if(S!==void 0){if(S)continue;d=!1;break}if(f){if(!ume(t,function(b,I){if(!hme(f,I)&&(g===b||n(g,b,e,r,i)))return f.push(I)})){d=!1;break}}else if(!(g===y||n(g,y,e,r,i))){d=!1;break}}return i.delete(s),i.delete(t),d}var l0=gme;function pme(s){var t=-1,e=Array(s.size);return s.forEach(function(r,n){e[++t]=[n,r]}),e}var mme=pme;function yme(s){var t=-1,e=Array(s.size);return s.forEach(function(r){e[++t]=r}),e}var gd=yme,fp=fo,gp=Hv,vme=Zh,Mme=l0,wme=mme,Sme=gd,Tme=1,Ime=2,Cme="[object Boolean]",bme="[object Date]",Eme="[object Error]",xme="[object Map]",Rme="[object Number]",kme="[object RegExp]",Ame="[object Set]",Pme="[object String]",Dme="[object Symbol]",Lme="[object ArrayBuffer]",Nme="[object DataView]",pp=fp?fp.prototype:void 0,Bl=pp?pp.valueOf:void 0;function Ome(s,t,e,r,n,i,o){switch(e){case Nme:if(s.byteLength!=t.byteLength||s.byteOffset!=t.byteOffset)return!1;s=s.buffer,t=t.buffer;case Lme:return!(s.byteLength!=t.byteLength||!i(new gp(s),new gp(t)));case Cme:case bme:case Rme:return vme(+s,+t);case Eme:return s.name==t.name&&s.message==t.message;case kme:case Pme:return s==t+"";case xme:var a=wme;case Ame:var c=r&Tme;if(a||(a=Sme),s.size!=t.size&&!c)return!1;var l=o.get(s);if(l)return l==t;r|=Ime,o.set(s,t);var u=Mme(a(s),a(t),r,n,i,o);return o.delete(s),u;case Dme:if(Bl)return Bl.call(s)==Bl.call(t)}return!1}var zme=Ome,mp=$v,Bme=1,jme=Object.prototype,Fme=jme.hasOwnProperty;function Ume(s,t,e,r,n,i){var o=e&Bme,a=mp(s),c=a.length,l=mp(t),u=l.length;if(c!=u&&!o)return!1;for(var h=c;h--;){var d=a[h];if(!(o?d in t:Fme.call(t,d)))return!1}var f=i.get(s),g=i.get(t);if(f&&g)return f==t&&g==s;var y=!0;i.set(s,t),i.set(t,s);for(var S=o;++h<c;){d=a[h];var b=s[d],I=t[d];if(r)var N=o?r(I,b,d,t,s,i):r(b,I,d,s,t,i);if(!(N===void 0?b===I||n(b,I,e,r,i):N)){y=!1;break}S||(S=d=="constructor")}if(y&&!S){var T=s.constructor,p=t.constructor;T!=p&&"constructor"in s&&"constructor"in t&&!(typeof T=="function"&&T instanceof T&&typeof p=="function"&&p instanceof p)&&(y=!1)}return i.delete(s),i.delete(t),y}var Wme=Ume,jl=Rv,Vme=l0,$me=zme,Yme=Wme,yp=Ac,vp=go,Mp=Xh,Gme=Ov,Hme=1,wp="[object Arguments]",Sp="[object Array]",_o="[object Object]",Qme=Object.prototype,Tp=Qme.hasOwnProperty;function qme(s,t,e,r,n,i){var o=vp(s),a=vp(t),c=o?Sp:yp(s),l=a?Sp:yp(t);c=c==wp?_o:c,l=l==wp?_o:l;var u=c==_o,h=l==_o,d=c==l;if(d&&Mp(s)){if(!Mp(t))return!1;o=!0,u=!1}if(d&&!u)return i||(i=new jl),o||Gme(s)?Vme(s,t,e,r,n,i):$me(s,t,c,e,r,n,i);if(!(e&Hme)){var f=u&&Tp.call(s,"__wrapped__"),g=h&&Tp.call(t,"__wrapped__");if(f||g){var y=f?s.value():s,S=g?t.value():t;return i||(i=new jl),n(y,S,e,r,i)}}return d?(i||(i=new jl),Yme(s,t,e,r,n,i)):!1}var Zme=qme,Kme=Zme,Ip=zr;function u0(s,t,e,r,n){return s===t?!0:s==null||t==null||!Ip(s)&&!Ip(t)?s!==s&&t!==t:Kme(s,t,e,r,u0,n)}var Xme=u0,Jme=Xme;function _me(s,t){return Jme(s,t)}var eye=_me;const nn=ln(eye);function po(s,t,e){return"#"+((s<<16)+(t<<8)+e).toString(16).padStart(6,"0")}function Et(s,t=1){return"rgba("+parseInt("0x"+s.slice(1,3))+","+parseInt("0x"+s.slice(3,5))+","+parseInt("0x"+s.slice(5,7))+","+t+")"}function qn(s,t,e,r=1){return`rgba(${s},${t},${e},${r})`}function Lc(s){const t=s.split(","),e=parseInt(t[0].split("(")[1]),r=parseInt(t[1]),n=parseInt(t[2]),i=Number(t[3].split(")")[0]);return[po(e,r,n),i]}function As(s){const t=s.split(","),e=parseInt(t[0].split("(")[1]),r=parseInt(t[1]),n=parseInt(t[2]),i=Number(t[3].split(")")[0]);return[e,r,n,i]}function ea(s){return s==="transparent"}const Fl="rgb(177,177,177)",$a=class $a extends Re{constructor(e){var r;super(e);x(this,"toolsType",q.Selector);x(this,"tmpPoints",[]);x(this,"subTmpPoints",[]);x(this,"workOptions");x(this,"vNodes");x(this,"selectIds");x(this,"selectorColor");x(this,"strokeColor");x(this,"fillColor");x(this,"oldSelectRect");x(this,"oldSubSelectRect");x(this,"canRotate",!1);x(this,"canTextEdit",!1);x(this,"canLock",!1);x(this,"scaleType",Ye.all);x(this,"toolsTypes");x(this,"shapeOpt");x(this,"textOpt");x(this,"isLocked");x(this,"thickness");x(this,"strokeType");x(this,"useStroke");this.workOptions={...e.toolsOpt,strokeColor:((r=e.toolsOpt)==null?void 0:r.strokeColor)||Fl},this.vNodes=e.vNodes}computSelector(e=!0){const r=it(this.tmpPoints);if(r.w===0||r.h===0)return{selectIds:[],intersectRect:void 0,subNodeMap:new Map};const{rectRange:n,nodeRange:i}=this.vNodes.getRectIntersectRange(r,e);return{selectIds:[...i.keys()],intersectRect:n,subNodeMap:i}}updateTempPoints(e){const r=this.tmpPoints.length,n=e.length;if(n>1){const i=new Pe(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,i):this.tmpPoints.push(i)}}drawSelector(e){const{drawRect:r,subNodeMap:n,selectorId:i,layer:o,isService:a}=e,c=new dt({pos:[r.x,r.y],anchor:[0,0],size:[r.w,r.h],id:i,name:i,zIndex:9999}),l=[];if(a){const u=new Gs({normalize:!0,pos:[r.w/2,r.h/2],lineWidth:1,strokeColor:this.selectorColor||this.workOptions.strokeColor||Fl,width:r.w,height:r.h,name:$a.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],f=new Gs({normalize:!0,pos:d,lineWidth:1,strokeColor:n.size>1?this.selectorColor||this.workOptions.strokeColor||Fl:void 0,width:u.rect.w,height:u.rect.h,id:`selector-${h}`,name:`selector-${h}`});l.push(f)}),l&&c.append(...l),(o==null?void 0:o.parent).appendChild(c)}draw(e,r,n,i=!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:i})}getSelecteorInfo(e){this.scaleType=Ye.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,i=!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!==q.Pencil&&(i=!1),a.strokeType&&(this.strokeType=a.strokeType),u===q.SpeechBalloon&&(r.add(u),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.placement=a.placement),u===q.Polygon&&(r.add(u),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=a.vertices),u===q.Star&&(r.add(u),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=a.vertices,this.shapeOpt.innerRatio=a.innerRatio,this.shapeOpt.innerVerticeStep=a.innerVerticeStep),u===q.Text&&(this.textOpt=a),e.size===1&&(this.textOpt&&(this.canTextEdit=!0),this.canRotate=c,this.scaleType=l),(u===q.Image||u===q.BackgroundSVG)&&(n=o),(l===Ye.proportional&&this.scaleType!==Ye.none||l===Ye.none)&&(this.scaleType=l)}i&&(this.useStroke=!0),r.size&&(this.toolsTypes=[...r]),n&&(e.size===1?(this.canLock=!0,(n.toolsType===q.BackgroundSVG?n.opt.locked!==!1:n.opt.locked)&&(this.isLocked=!0,this.scaleType=Ye.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===Ye.both&&((e=this.selectIds)==null?void 0:e.length)===1){const n=this.selectIds[0],i=(r=this.vNodes.get(n))==null?void 0:r.op;if(i){const o=[];for(let a=0;a<i.length;a+=3)o.push([i[a],i[a+1]]);return o}}}consume(e){if(e.isSubWorker)return this.subWorkerConsume(e);let r={type:le.Select,dataType:xe.Local,...this.baseConsumeResult};if(e.isSimpleWorker){const u=this.subWorkerConsume(e);r.subRect=u.rect}const{op:n,workState:i}=e.data;let o=this.oldSelectRect;if(i===de.Start&&(o=this.unSelectedAllIds()),!(n!=null&&n.length)||!this.vNodes.curNodeMap.size)return e.isSimpleWorker?r:{type:le.None};this.updateTempPoints(n);const a=this.computSelector();if(this.selectIds&&nn(this.selectIds,a.selectIds))return e.isSimpleWorker?r:{type:le.None};this.selectIds=a.selectIds;const c=a.intersectRect;this.getSelecteorInfo(a.subNodeMap),this.draw(Le,this.fullLayer,a),this.oldSelectRect=c;const l=this.getChildrenPoints();return r={...r,rect:Ue(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 o,a;let e=this.oldSelectRect;const r=this.tmpPoints[0],n=this.tmpPoints[this.tmpPoints.length-1],i=r&&(!n||r.isNear(n,1));if(!((o=this.selectIds)!=null&&o.length)&&r&&i&&this.selectSingleTool(this.tmpPoints[0].XY,Le,!1),(a=this.selectIds)!=null&&a.length&&(e=this.selectedByIds(this.selectIds)),e){const c=this.getChildrenPoints();return{type:le.Select,dataType:xe.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:c,isLocked:this.isLocked,toolsTypes:this.toolsTypes,shapeOpt:this.shapeOpt,thickness:this.thickness,useStroke:this.useStroke,strokeType:this.strokeType,...this.baseConsumeResult}}return{type:le.Select,dataType:xe.Local,...this.baseConsumeResult}}consumeService(){}updateTempPointsForSubWorker(e){const r=e.slice(-2),n=new Pe(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 i=it(n,r),o=[i.x+i.w/2,i.y+i.h/2];return{rect:i,pos:o,points:n.map(a=>a.XY).flat(1)}}drawForSubWorker(e){const{workId:r,layer:n,ps:i}=e,{strokeColor:o,scale:a,rotate:c,translate:l}=this.workOptions,u=n.worldPosition,h=n.worldScaling,{points:d,rect:f,pos:g}=this.computDrawPoints(i),y=1/n.worldScaling[0],S=o&&As(o)||[0,0,0,0],b={close:!0,normalize:!0,points:d,lineWidth:y,fillColor:qn(S[0],S[1],S[2],.1),strokeColor:qn(S[0],S[1],S[2],1),lineJoin:"round",lineCap:"round"};let I={x:Math.floor(f.x*h[0]+u[0]-Re.SafeBorderPadding),y:Math.floor(f.y*h[1]+u[1]-Re.SafeBorderPadding),w:Math.floor(f.w*h[0]+2*Re.SafeBorderPadding),h:Math.floor(f.h*h[0]+2*Re.SafeBorderPadding)};const N=new dt({name:r,id:r,pos:g,anchor:[.5,.5],size:[f.w,f.h],scale:a,rotate:c,translate:l}),T=new Cr({...b,pos:[0,0]});if(N.appendChild(T),this.replace(n,r,N),a||c||l){const p=N.getBoundingClientRect();I={x:Math.floor(p.x-Re.SafeBorderPadding),y:Math.floor(p.y-Re.SafeBorderPadding),w:Math.floor(p.width+2*Re.SafeBorderPadding),h:Math.floor(p.height+2*Re.SafeBorderPadding)}}return I}transformData(e){const r=it(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:i,syncUnitTime:o}=r;o&&(this.syncUnitTime=o);const a=i==null?void 0:i.length;if(!a||a<2)return{type:le.None,rect:void 0};let c;if(this.subTmpPoints.length===0?(this.subTmpPoints=[new Pe(i[0],i[1])],c=!1):c=this.updateTempPointsForSubWorker(i),!c)return{type:le.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=Ue(h,this.oldSubSelectRect);return this.oldSubSelectRect=h,{rect:d,type:le.DrawWork,dataType:xe.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:le.FullWork,dataType:xe.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=Le,n=!1){if(e.length===2){const i=e[0],o=e[1];let a;const{nodeRange:c}=this.vNodes.getRectIntersectRange({x:i,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(b0(h).find(f=>f.isPointCollision(i,o))){a=u;break}}if(a){const u=a.name;if(!nn(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=Ue(e,n.rect),this.vNodes.unSelected(r));return e}unSelectedByIds(e){let r;for(const n of e){const i=this.vNodes.get(n);i&&i.isSelected&&(r=Ue(r,i.rect),this.vNodes.unSelected(n))}return r}selectedByIds(e){let r;for(const n of e){const i=this.vNodes.get(n);i&&(r=Ue(r,i.rect),this.vNodes.selected(n))}return r}getSelectorRect(e,r){var a;let n;const i=(a=e.parent)==null?void 0:a.getElementById(r),o=i==null?void 0:i.getBoundingClientRect();return o&&(n=Ue(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===q.Ellipse||e===q.Triangle||e===q.Rectangle||e===q.Polygon||e===q.Star||e===q.SpeechBalloon}async updateSelector(e){const{updateSelectorOpt:r,selectIds:n,vNodes:i,willSerializeData:o,worker:a,offset:c}=e,l=this.fullLayer;if(!l)return;let u;const h=new Map,{originPoint:d,workState:f,angle:g,translate:y,dir:S,scale:b}=r;c&&(y?r.translate=[y[0]+c[0],y[1]+c[1]]:r.translate=c);let I;if(d||y||yt(g)){if(f===de.Start&&n)return i.setTargetAssignKeys(n),{type:le.Select,dataType:xe.Local,selectRect:this.oldSelectRect,rect:this.oldSelectRect};if(I=i.getLastTarget(),!I)return}if(n)for(const p of n){const m=i.get(p);if(m){const{toolsType:v,opt:M}=m,k=(l==null?void 0:l.getElementsByName(p))[0];if(k){const E={...r};let D;const P=Re.isWillRefresh({toolsType:v,opt:M,updateOpt:E,vNodes:i,node:k,willSerializeData:o});if(v){D=I==null?void 0:I.get(p);const z=Oc(v);z==null||z.updateNodeOpt({node:k,opt:E,vNodes:i,willSerializeData:o,targetNode:D});const j=i.get(p)||m;if(j&&a&&P){const A=a.createWorkShapeNode({workId:p,toolsType:v,toolsOpt:j.opt});A==null||A.setWorkId(p);let R;if(v===q.BackgroundSVG)R=A.consumeService({isFullWork:!0,replaceId:p});else if(v===q.Image)R=await A.consumeServiceAsync({isFullWork:!0,replaceId:p,worker:a});else if(v===q.Text)R=await A.consumeServiceAsync({isFullWork:!0,replaceId:p,isDrawLabel:!0});else try{R=A==null?void 0:A.consumeService({op:j.op,isFullWork:!0,replaceId:p,workState:f})}catch(L){console.error("consumeService error",L);continue}R&&(j.rect=R)}j&&(h.set(p,j),u=Ue(u,j.rect))}}}}I&&f===de.Done&&(i.deleteLastTarget(),I=void 0);const N=u;if(d&&y&&b&&S&&N&&!c){const p=[[N.x,N.y],[N.x+N.w,N.y],[N.x+N.w,N.y+N.h],[N.x,N.y+N.h]];let m;switch(S){case"top":case"topLeft":case"left":y[0]>0&&y[1]>0?m=p[0]:y[0]>0?m=p[3]:y[1]>0?m=p[1]:m=p[2];break;case"topRight":y[0]<0&&y[1]>0?m=p[1]:y[0]<0?m=p[2]:y[1]>0?m=p[0]:m=p[3];break;case"right":case"bottomRight":case"bottom":y[0]<0&&y[1]<0?m=p[2]:y[0]<0?m=p[1]:y[1]<0?m=p[3]:m=p[0];break;case"bottomLeft":y[0]>0&&y[1]<0?m=p[3]:y[0]>0?m=p[0]:y[1]<0?m=p[2]:m=p[1];break}const v=m&&[d[0]-m[0],d[1]-m[1]]||[0,0];if(!nn(v,[0,0]))return await this.updateSelector({...e,updateSelectorOpt:{workState:f},offset:v})}this.getSelecteorInfo(h),this.draw(Le,l,{selectIds:n||[],subNodeMap:h,intersectRect:N});const T=Ue(this.oldSelectRect,N);return this.oldSelectRect=N,{type:le.Select,dataType:xe.Local,selectRect:N,renderRect:u,rect:Ue(T,N),selectIds:n}}blurSelector(){const e=this.unSelectedAllIds();return{type:le.Select,dataType:xe.Local,rect:e,selectIds:[],willSyncService:!0}}getRightServiceId(e){return e.replace(Bt,"-")}selectServiceNode(e,r,n){const{selectIds:i}=r,o=this.getRightServiceId(e),a=this.getSelectorRect(this.fullLayer,o);let c;const l=new Map;return i==null||i.forEach(u=>{const h=this.vNodes.get(u);h&&(c=Ue(c,h.rect),l.set(u,h))}),this.getSelecteorInfo(l),this.draw(o,this.fullLayer,{intersectRect:c,selectIds:i||[],subNodeMap:l},n),Ue(c,a)}reRenderSelector(){var n;let e;const r=new Map;return(n=this.selectIds)==null||n.forEach(i=>{const o=this.vNodes.get(i);o&&(e=Ue(e,o.rect),r.set(i,o))},this),this.getSelecteorInfo(r),this.draw(Le,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=Ue(r,a)}this.selectIds=e;const i=this.reRenderSelector();return{bgRect:r,selectRect:i}}cursorHover(e){var o,a;const r=this.oldSelectRect;this.selectIds=[];const n=(o=this.workId)==null?void 0:o.toString(),i=[e[0]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],e[1]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[1]];if(this.selectSingleTool(i,n,!0),this.oldSelectRect&&!nn(r,this.oldSelectRect))return{type:le.CursorHover,dataType:xe.Local,rect:Ue(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:le.CursorHover,dataType:xe.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(i=>{i.name===e&&i.remove()})}};x($a,"selectorBorderId","selector-border");let za=$a;class h0 extends Re{constructor(e){super(e);x(this,"canRotate",!1);x(this,"scaleType",Ye.both);x(this,"toolsType",q.Arrow);x(this,"tmpPoints",[]);x(this,"workOptions");x(this,"oldRect");x(this,"arrowTipWidth");x(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:i,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:le.None};let f;if(this.tmpPoints.length===0?(this.tmpPoints=[new Pe(u[0],u[1])],f=!1):f=this.updateTempPoints(u),!f)return{type:le.None};let g;if(i||o||c){const S=n?this.fullLayer:this.drawLayer||this.fullLayer;g=this.draw({workId:l,layer:S})}if(c){const S=Ue(g,this.oldRect);this.oldRect=g;const b={rect:S,type:le.DrawWork,dataType:xe.Local,...this.baseConsumeResult};if(a){const I=Date.now();I-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=I,b.op=this.tmpPoints.map(N=>[...N.XY,0]).flat(1),b.index=0,b.isSync=!0)}return b}if(!i&&a){const S=Date.now();return S-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=S,{...this.baseConsumeResult,type:le.DrawWork,dataType:xe.Local,op:this.tmpPoints.map(b=>[...b.XY,0]).flat(1),isSync:!0,index:0}):{type:le.None}}const y=Ue(g,this.oldRect);return this.oldRect=g,{rect:y,...this.baseConsumeResult,type:le.DrawWork,dataType:xe.Local}}consumeAll(){var a;const e=this.workId;if(this.tmpPoints.length<2)return{type:le.RemoveNode,removeIds:[e]};const r=this.fullLayer,n=this.draw({workId:e,layer:r});this.oldRect=n;const i=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),o=xt(i);return(a=this.vNodes)==null||a.setInfo(e,{rect:n,op:i,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:Re.getCenterPos(n,r)}),{rect:n,...this.baseConsumeResult,type:le.FullWork,dataType:xe.Local,ops:o,isSync:!0,updateNodeOpt:{useAnimation:!0}}}draw(e){const{workId:r,layer:n,isDrawEraserlines:i}=e,{strokeColor:o,thickness:a,zIndex:c,scale:l,rotate:u,translate:h,strokeType:d,eraserlines:f,eraserFaces:g,doingLines:y,lineDash:S,lineCap:b}=this.workOptions,I=n.worldPosition,N=n.worldScaling,{points:T,pos:p,rect:m,isTriangle:v,trianglePoints:M,trianglePos:k}=this.computDrawPoints(a),E=[m.x+m.w/2,m.y+m.h/2],D={pos:E,name:r,id:r,zIndex:c,anchor:[.5,.5],size:[m.w,m.h]};l&&(D.scale=l),u&&(D.rotate=u),h&&(D.translate=h);const P=new dt(D),z={points:M,pos:[k[0]-E[0],k[1]-E[1]],fillColor:o,strokeColor:o,lineWidth:0,normalize:!1},j=new Cr(z);if(P.append(j),!v&&T&&p){const R={points:T,pos:[p[0]-E[0],p[1]-E[1]],fillColor:o,strokeColor:o,lineDash:d===Be.Dotted?[S&&S[0]||1,(S&&S[1]||2)*a]:d===Be.LongDotted?[(S&&S[0]||1)*a,(S&&S[1]||2)*a]:void 0,lineCap:d===Be.Normal?void 0:b,lineWidth:a,normalize:!1},L=new Cr(R);P.append(L)}(f||g||y)&&(this.scaleType=Ye.proportional,this.drawEraserlines({group:P,eraserlines:this.getRenderableEraserLines(this.workOptions),eraserFaces:g,pos:E,layer:n},i)),this.replace(n,r,P);let A={x:Math.floor(m.x*N[0]+I[0]-Re.SafeBorderPadding),y:Math.floor(m.y*N[1]+I[1]-Re.SafeBorderPadding),w:Math.floor(m.w*N[0]+2*Re.SafeBorderPadding),h:Math.floor(m.h*N[1]+2*Re.SafeBorderPadding)};if(l||u||h){const R=P.getBoundingClientRect();A={x:Math.floor(R.x-Re.SafeBorderPadding),y:Math.floor(R.y-Re.SafeBorderPadding),w:Math.floor(R.width+Re.SafeBorderPadding*2),h:Math.floor(R.height+Re.SafeBorderPadding*2)}}return this.isDelete&&P.setAttribute("opacity",0),A}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),i=Pe.Sub(this.tmpPoints[0],n),o=Pe.Add(this.tmpPoints[0],n),a=fe.Mul(r,this.arrowTipWidth),c=fe.Sub(this.tmpPoints[1],a),l=Pe.Sub(c,n),u=Pe.Add(c,n),h=fe.Per(r).mul(e*1.5),d=Pe.Sub(c,h),f=Pe.Add(c,h),g=[this.tmpPoints[0],c],y=[d,this.tmpPoints[1],f],S=[i,o,...y,l,u];return{trianglePoints:y.map(b=>Pe.Sub(b,this.tmpPoints[1]).XY).flat(1),trianglePos:this.tmpPoints[1].XY,points:g.map(b=>Pe.Sub(b,this.tmpPoints[0]).XY).flat(1),rect:it(S),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)),i=Pe.Sub(this.tmpPoints[0],n),o=Pe.Add(this.tmpPoints[0],n),a=[i,this.tmpPoints[1],o];return{trianglePoints:a.map(c=>Pe.Sub(c,this.tmpPoints[1]).XY).flat(1),trianglePos:this.tmpPoints[1].XY,rect:it(a),isTriangle:!0}}updateTempPoints(e){const r=e.slice(-2),n=new Pe(r[0],r[1]),i=this.tmpPoints[0],{thickness:o}=this.workOptions;if(i.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:i=de.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 Pe(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:i===de.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:Re.getCenterPos(c,a)}),c}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var l,u;const{node:r,opt:n,vNodes:i}=e,{strokeColor:o,strokeType:a}=n,c=i.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&&i.setInfo(r.name,c),Re.updateNodeOpt(e)}}class d0 extends Re{constructor(e){super(e);x(this,"canRotate",!1);x(this,"scaleType",Ye.all);x(this,"toolsType",q.Ellipse);x(this,"tmpPoints",[]);x(this,"workOptions");x(this,"oldRect");x(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:i,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:le.None};let f;if(this.tmpPoints.length===0?(this.tmpPoints=[new Pe(u[0],u[1])],f=!1):f=this.updateTempPoints(u),!f)return{type:le.None};let g;if(i||o||c){const y=n?this.fullLayer:this.drawLayer||this.fullLayer;g=this.draw({workId:l,layer:y,isDrawing:!0});const S=y.parent.parent,b={x:0,y:0,w:Math.floor(S.width),h:Math.floor(S.height)},I={type:le.DrawWork,dataType:xe.Local,...this.baseConsumeResult};if(Bc(g,b)!==sn.outside){const T=Ue(g,this.oldRect);if(this.oldRect=g,I.rect=T,!c)return I}if(c){const T=Date.now();return T-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=T,I.op=this.tmpPoints.map(p=>[...p.XY,0]).flat(1),I.index=0,I.isSync=!0),I}return{type:le.None}}if(!i&&!o&&!c&&a){const y=Date.now();return y-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=y,{type:le.DrawWork,dataType:xe.Local,...this.baseConsumeResult,op:this.tmpPoints.map(S=>[...S.XY,0]).flat(1),isSync:!0,index:0}):{type:le.None}}return{type:le.None}}consumeAll(){var a;const e=this.workId;if(this.tmpPoints.length<2)return{type:le.RemoveNode,removeIds:[e]};const r=this.fullLayer,n=this.draw({workId:e,layer:r,isDrawing:!1});this.oldRect=n;const i=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),o=xt(i);return(a=this.vNodes)==null||a.setInfo(e,{rect:n,op:i,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:n&&Re.getCenterPos(n,r)}),{rect:n,type:le.FullWork,dataType:xe.Local,...this.baseConsumeResult,ops:o,isSync:!0,updateNodeOpt:{useAnimation:!0}}}draw(e){const{workId:r,layer:n,isDrawing:i,isDrawEraserlines:o}=e,{strokeColor:a,fillColor:c,thickness:l,zIndex:u,scale:h,rotate:d,translate:f,strokeType:g,eraserlines:y,eraserFaces:S,doingLines:b,lineDash:I,lineCap:N}=this.workOptions,T=n.worldScaling,{radius:p,rect:m,pos:v}=this.computDrawPoints(l),M={closeType:"normal",radius:p,lineWidth:l,fillColor:c!=="transparent"&&c||void 0,strokeColor:a,normalize:!0,lineCap:N,lineDash:g===Be.Dotted?[I&&I[0]||1,(I&&I[1]||2)*l]:g===Be.LongDotted?[(I&&I[0]||1)*l,(I&&I[1]||2)*l]:void 0},k={name:r,id:r,zIndex:u,pos:v,anchor:[.5,.5],size:[m.w,m.h]};h&&(k.scale=h),d&&(k.rotate=d),f&&(k.translate=f);const E=new dt(k);if(i){const z=new $t({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:a,lineWidth:1,scale:[1/T[0],1/T[1]]});E.append(z)}const D=new Qh({...M,pos:[0,0]});E.append(D),(y||S||b)&&(this.scaleType=Ye.proportional,this.drawEraserlines({group:E,eraserlines:this.getRenderableEraserLines(this.workOptions),eraserFaces:S,pos:v,layer:n},o)),this.replace(n,r,E);const P=E.getBoundingClientRect();return this.isDelete&&E.setAttribute("opacity",0),{x:Math.floor(P.x-Re.SafeBorderPadding),y:Math.floor(P.y-Re.SafeBorderPadding),w:Math.floor(P.width+Re.SafeBorderPadding*2),h:Math.floor(P.height+Re.SafeBorderPadding*2)}}computDrawPoints(e){const r=it(this.tmpPoints),n=it(this.tmpPoints,e),i=[Math.floor(r.x+r.w/2),Math.floor(r.y+r.h/2)];return{rect:n,pos:i,radius:[Math.floor(r.w/2),Math.floor(r.h/2)]}}updateTempPoints(e){const r=e.slice(-2),n=new Pe(r[0],r[1]),i=this.tmpPoints[0],{thickness:o}=this.workOptions;if(i.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:i=de.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 Pe(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:i===de.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:Re.getCenterPos(c,a)}),c}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var h,d,f;const{node:r,opt:n,vNodes:i}=e,{strokeColor:o,fillColor:a,strokeType:c}=n,l=i.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)&&((f=l.opt)!=null&&f.strokeType)&&(l.opt.strokeType=c),l&&i.setInfo(r.name,l),Re.updateNodeOpt(e)}}class f0 extends Re{constructor(e){super(e);x(this,"canRotate",!0);x(this,"scaleType",Ye.all);x(this,"toolsType",q.Rectangle);x(this,"tmpPoints",[]);x(this,"workOptions");x(this,"oldRect");x(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}static normalizeStorageData(e){return this.normalizeDrawableStorageData(e)}transformData(){const e=it(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 i=it(n,r),o=[i.x+i.w/2,i.y+i.h/2];return{rect:i,pos:o,points:n.map(a=>a.XY).flat(1)}}consume(e){const{data:r,isFullWork:n,isSubWorker:i,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:le.None};let d;if(this.tmpPoints.length===0?(this.tmpPoints=[new Pe(u[0],u[1])],d=!1):d=this.updateTempPoints(u),!d)return{type:le.None};const f=this.transformData();let g;if(i||o||c){const S=n?this.fullLayer:this.drawLayer||this.fullLayer;g=this.draw({ps:f,workId:l,layer:S,isDrawing:!0})}if(c){const S=Ue(g,this.oldRect);this.oldRect=g;const b={rect:S,type:le.DrawWork,dataType:xe.Local,...this.baseConsumeResult};if(a){const I=Date.now();I-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=I,b.op=f.flat(1),b.index=0,b.isSync=!0)}return b}if(!i&&a){const S=Date.now();return S-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=S,{type:le.DrawWork,dataType:xe.Local,op:f.flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:le.None}}const y=Ue(g,this.oldRect);return this.oldRect=g,{rect:y,type:le.DrawWork,dataType:xe.Local,...this.baseConsumeResult}}consumeAll(){var c;const e=this.workId;if(this.tmpPoints.length<2)return{type:le.RemoveNode,removeIds:[e]};const r=this.transformData(),n=this.fullLayer,i=this.draw({ps:r,workId:e,layer:n,isDrawing:!1});this.oldRect=i;const o=r.flat(1),a=xt(o);return(c=this.vNodes)==null||c.setInfo(e,{rect:i,op:o,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:i&&Re.getCenterPos(i,n)}),{rect:i,type:le.FullWork,dataType:xe.Local,ops:a,isSync:!0,...this.baseConsumeResult,updateNodeOpt:{useAnimation:!0}}}draw(e){const{workId:r,layer:n,isDrawing:i,ps:o,replaceId:a,isDrawEraserlines:c=!0}=e,{strokeColor:l,fillColor:u,thickness:h,zIndex:d,scale:f,rotate:g,translate:y,strokeType:S,eraserlines:b,eraserFaces:I,doingLines:N,lineCap:T,lineDash:p}=this.workOptions,m=n.worldPosition,v=n.worldScaling,{points:M,rect:k,pos:E}=this.computDrawPoints(o),D={close:!0,normalize:!0,points:M,lineWidth:h,fillColor:u!=="transparent"&&u||void 0,strokeColor:l,lineCap:T,lineDash:S===Be.Dotted?[p&&p[0]||1,(p&&p[1]||2)*h]:S===Be.LongDotted?[(p&&p[0]||1)*h,(p&&p[1]||2)*h]:void 0};let P={x:Math.floor(k.x*v[0]+m[0]-Re.SafeBorderPadding),y:Math.floor(k.y*v[1]+m[1]-Re.SafeBorderPadding),w:Math.floor(k.w*v[0]+2*Re.SafeBorderPadding),h:Math.floor(k.h*v[0]+2*Re.SafeBorderPadding)};const z=new dt({name:r,id:r,zIndex:d,pos:E,anchor:[.5,.5],size:[k.w,k.h],scale:f,rotate:g,translate:y}),j=new Cr({...D,pos:[0,0]});if(z.appendChild(j),i){const A=new $t({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:l,lineWidth:1,scale:[1/v[0],1/v[1]]});z.appendChild(A)}if((b||I||N)&&(this.scaleType=Ye.proportional,this.drawEraserlines({group:z,eraserlines:this.getRenderableEraserLines(this.workOptions),eraserFaces:I,pos:E,layer:n},c)),this.replace(n,a||r,z),f||g||y){const A=z.getBoundingClientRect();P={x:Math.floor(A.x-Re.SafeBorderPadding),y:Math.floor(A.y-Re.SafeBorderPadding),w:Math.floor(A.width+2*Re.SafeBorderPadding),h:Math.floor(A.height+2*Re.SafeBorderPadding)}}return this.isDelete&&z.setAttribute("opacity",0),P}updateTempPoints(e){const r=e.slice(-2),n=new Pe(r[0],r[1]),i=this.tmpPoints[0],{thickness:o}=this.workOptions;if(i.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:i,workState:o=de.Done}=e,a=(h=this.workId)==null?void 0:h.toString();if(!a)return;const c=[];for(let f=0;f<r.length;f+=3)c.push([r[f],r[f+1],r[f+2]]);const l=n?this.fullLayer:this.drawLayer||this.fullLayer,u=this.draw({ps:c,workId:a,layer:l,isDrawing:!1,replaceId:i,isDrawEraserlines:o===de.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&&Re.getCenterPos(u,l)}),u}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var h,d,f;const{node:r,opt:n,vNodes:i}=e,{strokeColor:o,fillColor:a,strokeType:c}=n,l=i.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)&&((f=l.opt)!=null&&f.strokeType)&&(l.opt.strokeType=c),l&&i.setInfo(r.name,l),Re.updateNodeOpt(e)}}class g0 extends Re{constructor(e){super(e);x(this,"canRotate",!1);x(this,"scaleType",Ye.all);x(this,"toolsType",q.Star);x(this,"tmpPoints",[]);x(this,"workOptions");x(this,"oldRect");x(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:i,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:le.None};h&&(this.syncUnitTime=h);let f;if(this.tmpPoints.length===0?(this.tmpPoints=[new Pe(u[0],u[1])],f=!1):f=this.updateTempPoints(u),!f)return{type:le.None};let g;if(i||o||c){const S=n?this.fullLayer:this.drawLayer||this.fullLayer;g=this.draw({workId:l,layer:S,isDrawing:!0})}if(c){const S=Ue(g,this.oldRect);this.oldRect=g;const b={rect:S,type:le.DrawWork,dataType:xe.Local,...this.baseConsumeResult};if(a){const I=Date.now();I-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=I,b.op=this.tmpPoints.map(N=>[...N.XY,0]).flat(1),b.index=0,b.isSync=!0)}return b}if(!i&&a){const S=Date.now();return S-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=S,{type:le.DrawWork,dataType:xe.Local,op:this.tmpPoints.map(b=>[...b.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:le.None}}const y=Ue(g,this.oldRect);return this.oldRect=g,{rect:y,type:le.DrawWork,dataType:xe.Local,...this.baseConsumeResult}}consumeAll(){var a;const e=this.workId;if(this.tmpPoints.length<2)return{type:le.RemoveNode,removeIds:[e]};const r=this.fullLayer,n=this.draw({workId:e,layer:r,isDrawing:!1});this.oldRect=n;const i=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),o=xt(i);return(a=this.vNodes)==null||a.setInfo(e,{rect:n,op:i,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:n&&Re.getCenterPos(n,r)}),{rect:n,type:le.FullWork,dataType:xe.Local,ops:o,isSync:!0,...this.baseConsumeResult,updateNodeOpt:{useAnimation:!0}}}draw(e){const{workId:r,layer:n,isDrawing:i,isDrawEraserlines:o=!0}=e,{strokeColor:a,fillColor:c,thickness:l,zIndex:u,vertices:h,innerVerticeStep:d,innerRatio:f,scale:g,rotate:y,translate:S,strokeType:b,eraserlines:I,eraserFaces:N,doingLines:T,lineDash:p,lineCap:m}=this.workOptions,v=n.worldScaling,{rect:M,pos:k,points:E}=this.computDrawPoints(l,h,d,f),D={close:!0,points:E,lineWidth:l,fillColor:c!=="transparent"&&c||void 0,strokeColor:a,normalize:!0,lineCap:m,lineDash:b===Be.Dotted?[p&&p[0]||1,(p&&p[1]||2)*l]:b===Be.LongDotted?[(p&&p[0]||1)*l,(p&&p[1]||2)*l]:void 0},P={name:r,id:r,zIndex:u,pos:k,anchor:[.5,.5],size:[M.w,M.h]};g&&(P.scale=g),y&&(P.rotate=y),S&&(P.translate=S);const z=new dt(P);if(i){const R=new $t({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:a,lineWidth:1,scale:[1/v[0],1/v[1]]});z.append(R)}const j=new Cr({...D,pos:[0,0]});z.append(j),(I||N||T)&&(this.scaleType=Ye.proportional,this.drawEraserlines({group:z,eraserlines:this.getRenderableEraserLines(this.workOptions),eraserFaces:N,pos:k,layer:n},o)),this.replace(n,r,z);const A=z.getBoundingClientRect();return this.isDelete&&z.setAttribute("opacity",0),{x:Math.floor(A.x-Re.SafeBorderPadding),y:Math.floor(A.y-Re.SafeBorderPadding),w:Math.floor(A.width+Re.SafeBorderPadding*2),h:Math.floor(A.height+Re.SafeBorderPadding*2)}}computDrawPoints(e,r,n,i){const o=it(this.tmpPoints),a=[Math.floor(o.x+o.w/2),Math.floor(o.y+o.h/2)],c=G0(o.w,o.h),l=Math.floor(Math.min(o.w,o.h)/2),u=i*l,h=[],d=2*Math.PI/r;for(let g=0;g<r;g++){const y=g*d-.5*Math.PI;let S,b;g%n===1?(S=u*c[0]*Math.cos(y),b=u*c[1]*Math.sin(y)):(S=l*c[0]*Math.cos(y),b=l*c[1]*Math.sin(y),h.push(S,b)),h.push(S,b)}return{rect:it(this.tmpPoints,e),pos:a,points:h}}updateTempPoints(e){const r=e.slice(-2),n=new Pe(r[0],r[1]),i=this.tmpPoints[0],{thickness:o}=this.workOptions;if(i.isNear(n,o)||Pe.Sub(i,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:i=de.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 Pe(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:i===de.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&&Re.getCenterPos(c,a)}),c}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var S;const{node:r,opt:n,vNodes:i}=e,{strokeColor:o,fillColor:a,toolsType:c,vertices:l,innerVerticeStep:u,innerRatio:h,strokeType:d}=n,f=i.get(r.name),g=f==null?void 0:f.opt;let y=r;return r.tagName==="GROUP"&&(y=r.children[0]),o&&(y.setAttribute("strokeColor",o),g!=null&&g.strokeColor&&(g.strokeColor=o)),a&&(a==="transparent"?y.setAttribute("fillColor","rgba(0,0,0,0)"):y.setAttribute("fillColor",a),g!=null&&g.fillColor&&(g.fillColor=a)),c===q.Star&&(l&&(g.vertices=l),u&&(g.innerVerticeStep=u),h&&(g.innerRatio=h)),d&&(f!=null&&f.opt)&&((S=f.opt)!=null&&S.strokeType)&&(f.opt.strokeType=d),f&&i.setInfo(r.name,{...f,opt:g}),Re.updateNodeOpt(e)}}class p0 extends Re{constructor(e){super(e);x(this,"canRotate",!1);x(this,"scaleType",Ye.all);x(this,"toolsType",q.Polygon);x(this,"tmpPoints",[]);x(this,"workOptions");x(this,"oldRect");x(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:i,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:le.None};let f;if(this.tmpPoints.length===0?(this.tmpPoints=[new Pe(l[0],l[1])],f=!1):f=this.updateTempPoints(l),!f)return{type:le.None};let g;if(i||o||c){const S=n?this.fullLayer:this.drawLayer||this.fullLayer;g=this.draw({workId:h,layer:S,isDrawing:!0})}if(c){const S=Ue(g,this.oldRect);this.oldRect=g;const b={type:le.DrawWork,rect:S,dataType:xe.Local,...this.baseConsumeResult};if(a){const I=Date.now();I-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=I,b.op=this.tmpPoints.map(N=>[...N.XY,0]).flat(1),b.index=0,b.isSync=!0)}return b}if(!i&&a){const S=Date.now();return S-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=S,{type:le.DrawWork,dataType:xe.Local,op:this.tmpPoints.map(b=>[...b.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:le.None}}const y=Ue(g,this.oldRect);return this.oldRect=g,{rect:y,type:le.DrawWork,dataType:xe.Local,...this.baseConsumeResult}}consumeAll(){var a;const e=this.workId;if(this.tmpPoints.length<2)return{type:le.RemoveNode,removeIds:[e]};const r=this.fullLayer,n=this.draw({workId:e,layer:r,isDrawing:!1});this.oldRect=n;const i=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),o=xt(i);return(a=this.vNodes)==null||a.setInfo(e,{rect:n,op:i,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:n&&Re.getCenterPos(n,r)}),{rect:n,type:le.FullWork,dataType:xe.Local,ops:o,isSync:!0,...this.baseConsumeResult,updateNodeOpt:{useAnimation:!0}}}draw(e){const{workId:r,layer:n,isDrawing:i,isDrawEraserlines:o=!0}=e,{strokeColor:a,fillColor:c,thickness:l,zIndex:u,vertices:h,scale:d,rotate:f,translate:g,strokeType:y,eraserlines:S,eraserFaces:b,doingLines:I,lineCap:N,lineDash:T}=this.workOptions,p=n.worldScaling,{rect:m,pos:v,points:M}=this.computDrawPoints(l,h),k={close:!0,points:M,lineWidth:l,fillColor:c!=="transparent"&&c||void 0,strokeColor:a,normalize:!0,lineCap:N,lineDash:y===Be.Dotted?[T&&T[0]||1,(T&&T[1]||2)*l]:y===Be.LongDotted?[(T&&T[0]||1)*l,(T&&T[1]||2)*l]:void 0},E={name:r,id:r,zIndex:u,pos:v,anchor:[.5,.5],size:[m.w,m.h]};d&&(E.scale=d),f&&(E.rotate=f),g&&(E.translate=g);const D=new dt(E);if(i){const j=new $t({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:a,lineWidth:1,scale:[1/p[0],1/p[1]]});D.append(j)}const P=new Cr({...k,pos:[0,0]});D.append(P),(S||b||I)&&(this.scaleType=Ye.proportional,this.drawEraserlines({group:D,eraserlines:this.getRenderableEraserLines(this.workOptions),eraserFaces:b,pos:v,layer:n},o)),this.replace(n,r,D);const z=D.getBoundingClientRect();return this.isDelete&&D.setAttribute("opacity",0),{x:Math.floor(z.x-Re.SafeBorderPadding),y:Math.floor(z.y-Re.SafeBorderPadding),w:Math.floor(z.width+Re.SafeBorderPadding*2),h:Math.floor(z.height+Re.SafeBorderPadding*2)}}computDrawPoints(e,r){const n=it(this.tmpPoints),i=[Math.floor(n.x+n.w/2),Math.floor(n.y+n.h/2)],o=G0(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,f=a*o[0]*Math.cos(d),g=a*o[1]*Math.sin(d);c.push(f,g)}return{rect:it(this.tmpPoints,e),pos:i,points:c}}updateTempPoints(e){const r=e.slice(-2),n=new Pe(r[0],r[1]),i=this.tmpPoints[0],{thickness:o}=this.workOptions;if(i.isNear(n,o)||Pe.Sub(i,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:i=de.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 Pe(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:i===de.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&&Re.getCenterPos(c,a)}),c}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var g;const{node:r,opt:n,vNodes:i}=e,{strokeColor:o,fillColor:a,toolsType:c,vertices:l,strokeType:u}=n,h=i.get(r.name),d=h==null?void 0:h.opt;let f=r;return r.tagName==="GROUP"&&(f=r.children[0]),o&&(f.setAttribute("strokeColor",o),d!=null&&d.strokeColor&&(d.strokeColor=o)),a&&(a==="transparent"?f.setAttribute("fillColor","rgba(0,0,0,0)"):f.setAttribute("fillColor",a),d!=null&&d.fillColor&&(d.fillColor=a)),c===q.Polygon&&l&&(d.vertices=l),u&&(h!=null&&h.opt)&&((g=h.opt)!=null&&g.strokeType)&&(h.opt.strokeType=u),h&&i.setInfo(r.name,{...h,opt:d}),Re.updateNodeOpt(e)}}class vr{static bezier(t,e){const r=[];for(let n=0;n<e.length;n+=4){const i=e[n],o=e[n+1],a=e[n+2],c=e[n+3];i&&o&&a&&c?r.push(...vr.getBezierPoints(t,i,o,a,c)):i&&o&&a?r.push(...vr.getBezierPoints(t,i,o,a)):i&&o?r.push(...vr.getBezierPoints(t,i,o)):i&&r.push(i)}return r}static getBezierPoints(t=10,e,r,n,i){let o=null;const a=[];!n&&!i?o=vr.oneBezier:n&&!i?o=vr.twoBezier:n&&i&&(o=vr.threeBezier);for(let c=0;c<t;c++)o&&a.push(o(c/t,e,r,n,i));return i?a.push(i):n&&a.push(n),a}static oneBezier(t,e,r){const n=e.x+(r.x-e.x)*t,i=e.y+(r.y-e.y)*t;return new fe(n,i)}static twoBezier(t,e,r,n){const i=(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(i,o)}static threeBezier(t,e,r,n,i){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)+i.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)+i.y*t*t*t;return new fe(o,a)}}class m0 extends Re{constructor(e){super(e);x(this,"canRotate",!1);x(this,"scaleType",Ye.all);x(this,"toolsType",q.SpeechBalloon);x(this,"ratio",.8);x(this,"tmpPoints",[]);x(this,"workOptions");x(this,"oldRect");x(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}static normalizeStorageData(e){return this.normalizeDrawableStorageData(e)}consume(e){var y;const{data:r,isFullWork:n,isSubWorker:i,isMainThread:o,smoothSync:a,isSimpleWorker:c}=e,l=(y=r==null?void 0:r.workId)==null?void 0:y.toString();if(!l)return{type:le.None};const{op:u}=r,h=u==null?void 0:u.length;if(!h||h<2)return{type:le.None};let d;if(this.tmpPoints.length===0?(this.tmpPoints=[new Pe(u[0],u[1])],d=!1):d=this.updateTempPoints(u),!d)return{type:le.None};let f;if(i||o||c){const S=n?this.fullLayer:this.drawLayer||this.fullLayer;f=this.draw({workId:l,layer:S,isDrawing:!0})}if(c){const S=Ue(f,this.oldRect);this.oldRect=f;const b={rect:S,type:le.DrawWork,dataType:xe.Local,...this.baseConsumeResult};if(a){const I=Date.now();I-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=I,b.op=this.tmpPoints.map(N=>[...N.XY,0]).flat(1),b.index=0,b.isSync=!0)}return b}if(!i&&a){const S=Date.now();return S-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=S,{type:le.DrawWork,dataType:xe.Local,op:this.tmpPoints.map(b=>[...b.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:le.None}}const g=Ue(f,this.oldRect);return this.oldRect=f,{rect:g,type:le.DrawWork,dataType:xe.Local,...this.baseConsumeResult}}consumeAll(){var a;const e=this.workId;if(this.tmpPoints.length<2)return{type:le.RemoveNode,removeIds:[e]};const r=this.fullLayer,n=this.draw({workId:e,layer:r,isDrawing:!1});this.oldRect=n;const i=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),o=xt(i);return(a=this.vNodes)==null||a.setInfo(e,{rect:n,op:i,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:n&&Re.getCenterPos(n,r)}),{rect:n,type:le.FullWork,dataType:xe.Local,ops:o,isSync:!0,...this.baseConsumeResult,updateNodeOpt:{useAnimation:!0}}}draw(e){const{workId:r,layer:n,isDrawEraserlines:i=!0}=e,{strokeColor:o,fillColor:a,thickness:c,zIndex:l,placement:u,scale:h,rotate:d,translate:f,strokeType:g,eraserlines:y,eraserFaces:S,doingLines:b,lineDash:I,lineCap:N}=this.workOptions,{rect:T,pos:p,points:m}=this.computDrawPoints(c,u),v={points:m.map(P=>P.XY),lineWidth:c,fillColor:a!=="transparent"&&a||void 0,strokeColor:o,normalize:!0,className:`${p[0]},${p[1]}`,close:!0,lineCap:N,lineDash:g===Be.Dotted?[I&&I[0]||1,(I&&I[1]||2)*c]:g===Be.LongDotted?[(I&&I[0]||1)*c,(I&&I[1]||2)*c]:void 0},M={name:r,id:r,zIndex:l,pos:p,anchor:[.5,.5],size:[T.w,T.h]};h&&(M.scale=h),d&&(M.rotate=d),f&&(M.translate=f);const k=new dt(M),E=new Cr({...v,pos:[0,0]});k.append(E),(y||S||b)&&(this.scaleType=Ye.proportional,this.drawEraserlines({group:k,eraserlines:this.getRenderableEraserLines(this.workOptions),eraserFaces:S,pos:p,layer:n},i)),this.replace(n,r,k);const D=k.getBoundingClientRect();return this.isDelete&&k.setAttribute("opacity",0),{x:Math.floor(D.x-Re.SafeBorderPadding),y:Math.floor(D.y-Re.SafeBorderPadding),w:Math.floor(D.width+Re.SafeBorderPadding*2),h:Math.floor(D.height+Re.SafeBorderPadding*2)}}transformControlPoints(e){const r=it(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=it(this.tmpPoints),i=this.transformControlPoints(r),o=Math.floor(n.w*.1),a=Math.floor(n.h*.1),c=[],l=fe.Add(i[0],new fe(0,a,0)),u=fe.Add(i[0],new fe(o,0,0)),h=vr.getBezierPoints(10,l,i[0],u),d=fe.Sub(i[1],new fe(o,0,0)),f=fe.Add(i[1],new fe(0,a,0)),g=vr.getBezierPoints(10,d,i[1],f),y=fe.Sub(i[2],new fe(0,a,0)),S=fe.Sub(i[2],new fe(o,0,0)),b=vr.getBezierPoints(10,y,i[2],S),I=fe.Add(i[3],new fe(o,0,0)),N=fe.Sub(i[3],new fe(0,a,0)),T=vr.getBezierPoints(10,I,i[3],N),p=o*(1-this.ratio)*10,m=a*(1-this.ratio)*10;switch(r){case"bottom":{const k=fe.Sub(i[2],new fe(o*5-p/2,0,0)),E=fe.Sub(i[2],new fe(o*5,-m,0)),D=fe.Sub(i[2],new fe(o*5+p/2,0,0));c.push(E,D,...T,...h,...g,...b,k);break}case"bottomRight":{const k=fe.Sub(i[2],new fe(o*1.1,0,0)),E=fe.Sub(i[2],new fe(o*1.1+p/2,-m,0)),D=fe.Sub(i[2],new fe(o*1.1+p,0,0));c.push(E,D,...T,...h,...g,...b,k);break}case"bottomLeft":{const k=fe.Add(i[3],new fe(o*1.1+p,0,0)),E=fe.Add(i[3],new fe(o*1.1+p/2,m,0)),D=fe.Add(i[3],new fe(o*1.1,0,0));c.push(E,D,...T,...h,...g,...b,k);break}case"top":{const k=fe.Sub(i[1],new fe(o*5-p/2,0,0)),E=fe.Sub(i[1],new fe(o*5,m,0)),D=fe.Sub(i[1],new fe(o*5+p/2,0,0));c.push(E,k,...g,...b,...T,...h,D);break}case"topRight":{const k=fe.Sub(i[1],new fe(o*1.1,0,0)),E=fe.Sub(i[1],new fe(o*1.1+p/2,m,0)),D=fe.Sub(i[1],new fe(o*1.1+p,0,0));c.push(E,k,...g,...b,...T,...h,D);break}case"topLeft":{const k=fe.Add(i[0],new fe(o*1.1+p,0,0)),E=fe.Add(i[0],new fe(o*1.1+p/2,-m,0)),D=fe.Add(i[0],new fe(o*1.1,0,0));c.push(E,k,...g,...b,...T,...h,D);break}case"left":{const k=fe.Add(i[0],new fe(0,a*5-m/2,0)),E=fe.Add(i[0],new fe(-p,a*5,0)),D=fe.Add(i[0],new fe(0,a*5+m/2,0));c.push(E,k,...h,...g,...b,...T,D);break}case"leftTop":{const k=fe.Add(i[0],new fe(0,a*1.1,0)),E=fe.Add(i[0],new fe(-p,a*1.1+m/2,0)),D=fe.Add(i[0],new fe(0,a*1.1+m,0));c.push(E,k,...h,...g,...b,...T,D);break}case"leftBottom":{const k=fe.Sub(i[3],new fe(0,a*1.1+m,0)),E=fe.Sub(i[3],new fe(p,a*1.1+m/2,0)),D=fe.Sub(i[3],new fe(0,a*1.1,0));c.push(E,k,...h,...g,...b,...T,D);break}case"right":{const k=fe.Add(i[1],new fe(0,a*5-m/2,0)),E=fe.Add(i[1],new fe(p,a*5,0)),D=fe.Add(i[1],new fe(0,a*5+m/2,0));c.push(E,D,...b,...T,...h,...g,k);break}case"rightTop":{const k=fe.Add(i[1],new fe(0,a*1.1,0)),E=fe.Add(i[1],new fe(p,a*1.1+m/2,0)),D=fe.Add(i[1],new fe(0,a*1.1+m,0));c.push(E,D,...b,...T,...h,...g,k);break}case"rightBottom":{const k=fe.Sub(i[2],new fe(0,a*1.1+m,0)),E=fe.Sub(i[2],new fe(-p,a*1.1+m/2,0)),D=fe.Sub(i[2],new fe(0,a*1.1,0));c.push(E,D,...b,...T,...h,...g,k);break}}const v=it(this.tmpPoints,e),M=[Math.floor(v.x+v.w/2),Math.floor(v.y+v.h/2)];return{rect:v,pos:M,points:c}}updateTempPoints(e){const r=e.slice(-2),n=new Pe(r[0],r[1]),i=this.tmpPoints[0],{thickness:o}=this.workOptions;if(i.isNear(n,o)||Pe.Sub(i,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:i=de.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 Pe(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:i===de.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&&Re.getCenterPos(c,a)}),c}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var g;const{node:r,opt:n,vNodes:i}=e,{strokeColor:o,fillColor:a,toolsType:c,placement:l,strokeType:u}=n,h=i.get(r.name),d=h==null?void 0:h.opt;let f=r;return r.tagName==="GROUP"&&(f=r.children[0]),o&&(f.setAttribute("strokeColor",o),d!=null&&d.strokeColor&&(d.strokeColor=o)),a&&(a==="transparent"?f.setAttribute("fillColor","rgba(0,0,0,0)"):f.setAttribute("fillColor",a),d!=null&&d.fillColor&&(d.fillColor=a)),c===q.SpeechBalloon&&l&&(d.placement=l),u&&(h!=null&&h.opt)&&((g=h.opt)!=null&&g.strokeType)&&(h.opt.strokeType=u),h&&i.setInfo(r.name,{...h,opt:d}),Re.updateNodeOpt(e)}}var tye=pi,rye=zr,nye="[object Boolean]";function iye(s){return s===!0||s===!1||rye(s)&&tye(s)==nye}var sye=iye;const _n=ln(sye);class y0 extends Re{constructor(e){super(e);x(this,"canRotate",!1);x(this,"scaleType",Ye.both);x(this,"toolsType",q.Straight);x(this,"tmpPoints",[]);x(this,"workOptions");x(this,"oldRect");x(this,"straightTipWidth");x(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:i,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:le.None};h&&(this.syncUnitTime=h);let f;if(this.tmpPoints.length===0?(this.tmpPoints=[new Pe(u[0],u[1])],f=!1):f=this.updateTempPoints(u),!f)return{type:le.None};let g;if(i||o||c){const S=n?this.fullLayer:this.drawLayer||this.fullLayer;g=this.draw({workId:l,layer:S})}if(c){const S=Ue(g,this.oldRect);this.oldRect=g;const b={rect:S,type:le.DrawWork,dataType:xe.Local,...this.baseConsumeResult};if(a){const I=Date.now();I-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=I,b.op=this.tmpPoints.map(N=>[...N.XY,0]).flat(1),b.index=0,b.isSync=!0)}return b}if(!i&&a){const S=Date.now();return S-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=S,{type:le.DrawWork,dataType:xe.Local,op:this.tmpPoints.map(b=>[...b.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:le.None}}const y=Ue(g,this.oldRect);return this.oldRect=g,{rect:y,type:le.DrawWork,dataType:xe.Local,...this.baseConsumeResult}}consumeAll(){var a;const e=this.workId;if(this.tmpPoints.length<2)return{type:le.RemoveNode,removeIds:[e]};const r=this.fullLayer,n=this.draw({workId:e,layer:r});this.oldRect=n;const i=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),o=xt(i);return(a=this.vNodes)==null||a.setInfo(e,{rect:n,op:i,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:n&&Re.getCenterPos(n,r)}),{rect:n,type:le.FullWork,dataType:xe.Local,ops:o,isSync:!0,...this.baseConsumeResult,updateNodeOpt:{useAnimation:!0}}}draw(e){const{workId:r,layer:n,isDrawEraserlines:i=!0}=e,{strokeColor:o,thickness:a,zIndex:c,scale:l,rotate:u,translate:h,strokeType:d,eraserlines:f,eraserFaces:g,doingLines:y,lineCap:S,lineDash:b}=this.workOptions,I=n.worldPosition,N=n.worldScaling,{d:T,rect:p,isDot:m}=this.computDrawPoints(a,d),v=[p.x+p.w/2,p.y+p.h/2],M=new dt({pos:v,anchor:[.5,.5],size:[p.w,p.h],name:r,id:r,normalize:!0,zIndex:c}),k={pos:[0,0],normalize:!0,d:T,fillColor:o,strokeColor:o,lineDash:m?void 0:d===Be.Dotted?[b&&b[0]||1,(b&&b[1]||2)*a]:d===Be.LongDotted?[(b&&b[0]||1)*a,(b&&b[1]||2)*a]:void 0,lineCap:m?void 0:S,lineWidth:d===Be.Normal||m?0:a};l&&(k.scale=l),u&&(k.rotate=u),h&&(k.translate=h);const E=new $t(k);M.append(E),(f||g||y)&&(this.scaleType=Ye.proportional,this.drawEraserlines({group:M,eraserlines:this.getRenderableEraserLines(this.workOptions),eraserFaces:g,pos:v,layer:n},i)),this.replace(n,r,M);let D={x:Math.floor(p.x*N[0]+I[0]-Re.SafeBorderPadding),y:Math.floor(p.y*N[1]+I[1]-Re.SafeBorderPadding),w:Math.floor(p.w*N[0]+2*Re.SafeBorderPadding),h:Math.floor(p.h*N[1]+2*Re.SafeBorderPadding)};if(u||l||h){const P=E.getBoundingClientRect();D={x:Math.floor(P.x-Re.SafeBorderPadding),y:Math.floor(P.y-Re.SafeBorderPadding),w:Math.floor(P.width+Re.SafeBorderPadding*2),h:Math.floor(P.height+Re.SafeBorderPadding*2)}}return this.isDelete&&M.setAttribute("opacity",0),D}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(),i=fe.Per(n).mul(e/2),o=Pe.Sub(this.tmpPoints[0],i),a=Pe.Add(this.tmpPoints[0],i),c=Pe.Sub(this.tmpPoints[1],i),l=Pe.Add(this.tmpPoints[1],i),u=Pe.GetSemicircleStroke(this.tmpPoints[1],c,-1,8),h=Pe.GetSemicircleStroke(this.tmpPoints[0],a,-1,8),d=[o,c,...u,l,a,...h];let f;return r!==Be.Normal?f=Lr(this.tmpPoints,!1):f=Lr(d,!0),{d:f,rect:it(d),isDot:!1,pos:this.tmpPoints[0].XY}}computDotPoints(e){const r=Pe.GetDotStroke(this.tmpPoints[0],e/2,8);return{d:Lr(r,!0),rect:it(r),isDot:!0,pos:this.tmpPoints[0].XY}}updateTempPoints(e){const r=e.slice(-2),n=new Pe(r[0],r[1]),i=this.tmpPoints[0],{thickness:o}=this.workOptions;if(i.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:i=de.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 Pe(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:i===de.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&&Re.getCenterPos(c,a)}),c}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var l,u;const{node:r,opt:n,vNodes:i}=e,{strokeColor:o,strokeType:a}=n,c=i.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&&i.setInfo(r.name,c),Re.updateNodeOpt(e)}}var Tr=(s=>(s[s.Text=1]="Text",s[s.Shape=2]="Shape",s))(Tr||{});const qt=class qt{createProxy(t){const e=new Proxy(t,{get(r,n,i){const o=qt.interceptors.hasOwnProperty(n)?qt.interceptors:r;return Reflect.get(o,n,i)}});return qt.proxyToRaw.set(e,t),e}};x(qt,"proxyToRaw",new WeakMap),x(qt,"interceptors",{entries(...t){return qt.proxyToRaw.get(this).entries(...t)},forEach(...t){return qt.proxyToRaw.get(this).forEach(...t)},size(){return qt.proxyToRaw.get(this).size},get(t){return qt.proxyToRaw.get(this).get(t)},set(t,e){return qt.proxyToRaw.get(this).set(t,e)},delete(t){return qt.proxyToRaw.get(this).delete(t)},clear(){return qt.proxyToRaw.get(this).clear()}});let Zn=qt;const si="__undo_scope_clear_all__",Cp=s=>Math.max(s,1e3),oye=s=>Math.max(s+1e3,6e3);var $e=(s=>(s.DrawingPencil="drawing:pencil",s.DrawingArrow="drawing:arrow",s.DrawingShape="drawing:shape",s.DrawingEraser="drawing:eraser",s.DrawingPencilEraser="drawing:pencil-eraser",s.DrawingBitMapEraser="drawing:bitmap-eraser",s.MethodTranslateNode="method:translate-node",s.MethodScaleNode="method:scale-node",s.MethodRotateNode="method:rotate-node",s.MethodSetPoint="method:set-point",s.MethodSetColorNode="method:set-color-node",s.AsyncCopyNode="async:copy-node",s.AsyncPasteNode="async:paste-node",s.AsyncDeleteNode="async:delete-node",s.AsyncSetFontStyle="async:set-font-style",s.AsyncSetShapeOpt="async:set-shape-opt",s.AsyncZIndexNode="async:z-index-node",s.AsyncSetLock="async:set-lock",s.AsyncUpdateElement="async:update-element",s.AsyncImage="async:image",s.AsyncIcon="async:icon",s.AsyncMarkmap="async:markmap",s.Text="text",s.Clear="command:clear",s))($e||{});function aye(s){const{tickerId:t,viewId:e,scenePath:r,expectedAcks:n}=s;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}}}function cye(s,t){t&&(s.meta={...s.meta,...t})}function lye(s){return(!s.expectedRender||s.gotRender)&&(!s.expectedStorage||s.gotStorage)}function uye(s){return!s.ackTimer&&s.finalizeRequested}function hye(s){return s.expectedStorage?s.finalizeRequested?s.scopeKeys.size?[...s.scopeKeys].every(t=>s.ackedStorageKeys.has(t)):!0:!1:!0}function dye(s,t){return s.size>0?s.has(si)?t===si:!!t&&s.has(t):!t||s.has(t)}function Ul(s,t){const e=t.toString();return s.isLocalId(e)?s.transformKey(e):e}function Wl(s,t,e,r){var o,a;const n=new Set;if(!s)return n;const i=s.getStorageData(t,e);for(const c of r){if(c==null)continue;if(c===si){n.add(si);continue}const l=Ul(s,c),u=i==null?void 0:i[l];if(s.getLocalId(l)===Le){(o=u==null?void 0:u.selectIds)==null||o.forEach(h=>{n.add(Ul(s,h))});continue}n.add(l),(a=u==null?void 0:u.selectIds)==null||a.forEach(h=>{n.add(Ul(s,h))})}return n}function bp(s,t,e){return e!=null&&e.has(si)?!t.has(s):e!=null&&e.size?e.has(s):!t.has(s)}const fye={[q.Selector]:De.selector,[q.Clicker]:De.clicker,[q.Text]:De.text,[q.Pencil]:De.pencil,[q.LaserPen]:De.laserPen,[q.Arrow]:De.arrow,[q.Straight]:De.straight,[q.Rectangle]:De.rectangle,[q.Ellipse]:De.ellipse,[q.Star]:or.star,[q.Polygon]:or.polygon,[q.SpeechBalloon]:or.speechBalloon,[q.Eraser]:De.eraser,[q.PencilEraser]:De.pencilEraser,[q.BitMapEraser]:or.bitMapEraser};function Nc(s){return s===void 0?void 0:fye[s]}function gye(s,t){return s||t}function pye(s){return Nc(s)}function mye(s){switch(s){case q.Text:return Tr.Text;case q.SpeechBalloon:case q.Star:case q.Ellipse:case q.Rectangle:case q.Triangle:case q.Rhombus:case q.Polygon:return Tr.Shape}}function js(s){if(!s)return!1;try{const t=Nn(s);if(Array.isArray(t))return t.some(e=>String(e??"").trim().length>0);if(typeof t=="string")return t.trim().length>0}catch{}return s.split(",").some(t=>t.trim().length>0)}function v0(s){const t=s.lastChild;if(!t){const n=document.createElement("div"),i=document.createTextNode("");return n.appendChild(i),s.appendChild(n),i}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 yye(s,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),s.removeAllRanges(),s.addRange(e)}function M0(s){const t=document.createTreeWalker(s,NodeFilter.SHOW_TEXT,null),e=[];let r;for(;(r=t.nextNode())!==null;)e.push(r);return e}function vye(s,t,e){var a;const r=document.createRange();r.setStart(s,t),r.collapse(!0);const n=r.getBoundingClientRect();if(!n.width&&!n.height){const c=(a=s.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 i=n.left+n.width/2,o=n.top+n.height/2;return Math.abs(e.x-i)+Math.abs(e.y-o)*4}function Mye(s,t){var n;const e=M0(s);if(!e.length){const i=v0(s);return i.nodeType===Node.TEXT_NODE?{node:i,offset:0}:void 0}let r;for(const i of e){const o=((n=i.textContent)==null?void 0:n.length)||0;for(let a=0;a<=o;a++){const c=vye(i,a,t);(!r||c<r.distance)&&(r={node:i,offset:a,distance:c})}}return r?{node:r.node,offset:r.offset}:void 0}function wye(s,t,e){const r=Mye(t,e);if(!r)return!1;const n=document.createRange();return n.setStart(r.node,r.offset),n.collapse(!0),s.removeAllRanges(),s.addRange(n),!0}function Ep(s,t){return!!(s!=null&&s.anchorNode)&&t.contains(s.anchorNode)}function xp(s){let t=null,e=!1;for(const n of Array.from(s.childNodes)){if(n instanceof HTMLDivElement){t=n;continue}n.nodeType===Node.TEXT_NODE&&(t||(t=document.createElement("div"),s.insertBefore(t,n),e=!0),t.appendChild(n),e=!0)}const r=Array.from(s.childNodes).reverse().find(n=>n instanceof HTMLDivElement);return{changed:e,lastLine:r||null}}function Sye(s){const t=M0(s);return{textContent:t.map(e=>e.textContent||"").join(""),textNodes:t}}function w0(s){const t=[];for(let e=0;e<s.childNodes.length;e++){const r=s.childNodes[e];if(r.nodeName==="#text"&&e===0){const n=r.textContent.split(/\n/),i=n.pop();t.push(...n),i&&t.push(i)}else if(r.nodeName==="DIV"){const i=(r.innerText??r.textContent??"").split(/\n/);if(i.length===2&&i[0]===""&&i[1]==="")t.push("");else{const o=i.shift();(o||o==="")&&t.push(o);const a=i.pop();t.push(...i),a&&t.push(a)}}}return t}function S0(s){return xt(w0(s))}function ws(s,t){var n,i;if(!s.length)return;let e=Math.max(0,t);for(const o of s){const a=((n=o.textContent)==null?void 0:n.length)||0;if(e<=a)return{node:o,offset:e};e-=a}const r=s[s.length-1];return{node:r,offset:((i=r.textContent)==null?void 0:i.length)||0}}function Tye(s){const{hasPoint:t,previousByPoint:e,hasSelectionInEditor:r,rangeCount:n,isCollapsed:i}=s;return!t&&e&&r&&n>0&&i}const Ni=5;class Iye{constructor(t){x(this,"internalMsgEmitter");x(this,"publicMsgEmitter");x(this,"control");x(this,"editors");x(this,"activeId");x(this,"proxyMap");x(this,"taskqueue",new Map);x(this,"undoTickerId");x(this,"checkLocalTextBlur",ye.debounce(()=>{if(this.collector)for(const[t,e]of this.editors.entries())e.opt.workState!==de.Done&&this.collector.isLocalId(t)&&this.activeId!==t&&(js(e.opt.text)?this.unActive(t):this.delete(t,!0,!0))},100));const{control:e,internalMsgEmitter:r,publicMsgEmitter:n}=t;this.control=e,this.internalMsgEmitter=r,this.publicMsgEmitter=n;const i=new Map;this.proxyMap=new Zn;const o=this,a=Zn.interceptors.set;Zn.interceptors.set=function(l,u){return o.interceptors.set(l,u),a.call(this,l,u)};const c=Zn.interceptors.delete;Zn.interceptors.delete=function(l){return o.interceptors.delete(l),c.call(this,l)},this.editors=this.proxyMap.createProxy(i)}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,i=this.control.viewContainerManager.getUndoTickerId(t);if(n===de.Done)return this.undoTickerId&&i===this.undoTickerId?this.undoTickerId:i}ackDoneRender(t,e,r,n,i){t&&(this.internalMsgEmitter.emit("ackRenderUndoTicker",t,e,r,{requestId:n,emitEventType:i}),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 I,N,T,p,m,v,M,k,E;if(!this.collector)return!0;const{viewId:r,scenePath:n,canSync:i,canWorker:o,type:a,opt:c,dataType:l,updateNodeOpt:u,requestId:h,emitEventType:d,skipStorageDispatch:f}=e,g=e.needUndoTicker??this.getDoneUndoTicker(r,c==null?void 0:c.workState,u==null?void 0:u.workState);if(!o&&!i)return!0;const S=((I=this.collector)==null?void 0:I.isLocalId(t))?(N=this.collector)==null?void 0:N.transformKey(t):t,b=((T=this.collector)==null?void 0:T.storage[r])&&this.collector.storage[r][n]&&this.collector.storage[r][n][S]||void 0;b?b.toolsType===q.Text&&(o&&(this.control.worker.queryTaskBatchData({workId:t,msgType:le.UpdateNode}).forEach(D=>{var P;(P=this.control.worker)==null||P.taskBatchData.delete(D)}),(M=this.control.worker)==null||M.taskBatchData.add({workId:t,msgType:le.UpdateNode,dataType:l||xe.Local,toolsType:q.Text,opt:c,viewId:r,scenePath:n,willRefresh:!0}),(k=this.control.worker)==null||k.runAnimation()),i&&!f&&((E=this.collector)==null||E.dispatch({type:le.UpdateNode,workId:t,toolsType:q.Text,opt:c,viewId:r,scenePath:n,updateNodeOpt:u,requestId:h,emitEventType:d,needUndoTicker:g}),this.ackDoneRender(g,r,n,h,d),delete e.needUndoTicker,c.workState===de.Done&&this.control.runEffectWork(()=>{this.control.worker.setShapeSelectorByWorkId(t,r)}))):a===Tr.Text&&(i&&!f&&((p=this.collector)==null||p.dispatch({type:c.text&&le.FullWork||le.CreateWork,workId:t,toolsType:q.Text,opt:c,isSync:!0,viewId:r,scenePath:n,updateNodeOpt:u,requestId:h,emitEventType:d,needUndoTicker:g}),this.ackDoneRender(g,r,n,h,d),delete e.needUndoTicker),o&&((m=this.control.worker)==null||m.taskBatchData.add({workId:t,msgType:c.text&&le.FullWork||le.CreateWork,dataType:l||xe.Local,toolsType:q.Text,opt:c,viewId:r,scenePath:n,willRefresh:!0}),(v=this.control.worker)==null||v.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:i,canWorker:o}=e,a=this.getDoneUndoTicker(r,de.Done);if(!o&&!i)return!0;o&&((c=this.control.worker)==null||c.taskBatchData.add({workId:t,toolsType:q.Text,msgType:le.RemoveNode,dataType:xe.Local,viewId:r,scenePath:n,willRefresh:!0}),(l=this.control.worker)==null||l.runAnimation()),i&&((u=this.collector)==null||u.dispatch({type:le.RemoveNode,removeIds:[t],toolsType:q.Text,viewId:r,scenePath:n,needUndoTicker:a}),this.ackDoneRender(a,r,n))},clear(){return!0}}}computeTextActive(t,e){var i,o,a,c;const r=(i=this.control.viewContainerManager)==null?void 0:i.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:le.GetTextActive,dataType:xe.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);js(r==null?void 0:r.opt.text)?this.unActive(t):this.delete(t,!0,!0)}this.checkLocalTextBlur()}forceDoneLocalText(t){const e=t?new Set(t):void 0;[...this.editors.entries()].filter(([n,i])=>{var o,a;return i.opt.workState!==de.Done&&(!e||e.has(i.viewId))&&(i.opt.uid===((o=this.collector)==null?void 0:o.uid)||((a=this.collector)==null?void 0:a.isLocalId(n)))}).map(([n])=>n).forEach(n=>{const i=this.editors.get(n);js(i==null?void 0:i.opt.text)?this.unActive(n):this.delete(n,!0,!0)})}onCameraChange(t,e){var r,n;for(const[i,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:Tr.Text,viewId:e,scenePath:u,canWorker:!1,canSync:!1};this.editors.set(i,h),this.control.viewContainerManager.updateTextEditorInfo(e,this.activeId)}}}deriveTextEditorInfoFromServiceData(t,e={}){var N,T,p;const{workId:r,opt:n,msgType:i,viewId:o,scenePath:a,dataType:c,updateNodeOpt:l,lastOperator:u}=t;if(!r||!o||!a)return;const h=r.toString();if(i===le.RemoveNode){this.delete(h,!0,!0);return}const d=n,f=d.workState!==de.Done&&!d.uid&&u?{...d,uid:u}:d,{boxPoint:g,boxSize:y}=f,S=g&&((N=this.control.viewContainerManager)==null?void 0:N.transformToOriginPoint(g,o)),b=this.control.viewContainerManager.getView(o),I={x:S&&S[0]||0,y:S&&S[1]||0,w:y&&y[0]||0,h:y&&y[1]||0,opt:f,type:Tr.Text,canWorker:e.canWorker??!0,canSync:e.canSync??!1,dataType:c,scale:((T=b==null?void 0:b.cameraOpt)==null?void 0:T.scale)||1,viewId:o,scenePath:a};if(f.workState===de.Done&&!this.control.cursor.isEnableCursor&&g&&y){let v=l==null?void 0:l.uid;if(!v){const M=this.editors.get(h);v=M&&((p=M.opt)==null?void 0:p.uid)}v&&this.control.cursor.collectServiceCursor({op:g&&[g[0]+y[0],g[1]+y[1]],uid:v,workState:de.Done,cursorTool:Nc(q.Text),viewId:o,type:le.Cursor})}return this.editors.set(h,I),c===xe.Service&&f.workState===de.Done&&this.activeId===h&&(this.activeId=void 0),(e.updateView??!0)&&this.control.viewContainerManager.updateTextEditorInfo(o,this.activeId),I}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=de.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=de.Done,e.opt.uid=void 0,e.canWorker=!0,e.canSync=!0,this.editors.set(t,e),this.activeId=void 0;const i=(r=this.control.viewContainerManager.getView(e.viewId))==null?void 0:r.container;if(i){const o=CSS.escape(t),a=i.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,...i}=t;e&&this.addUndoTicker(e,i.viewId),i.opt.uid=(o=this.collector)==null?void 0:o.uid,i.undoTickerId=e||i.undoTickerId||this.undoTickerId,n&&(this.activeId=r),i.dataType=xe.Local,i.canWorker=!0,i.canSync=!0,this.editors.set(r,i),this.control.viewContainerManager.updateTextEditorInfo(i.viewId,this.activeId)}updateTextForMasterController(t,e){var o;const{workId:r,...n}=t;e&&this.addUndoTicker(e,n.viewId);const i=this.editors.get(r)||{};n.opt&&(n.opt.uid=(o=this.collector)==null?void 0:o.uid),n.undoTickerId=e||i.undoTickerId||this.undoTickerId,n.dataType=xe.Local,this.editors.set(r,{...i,...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 i=this.editors.get(r)||{};n.opt&&(n.opt.uid=(u=this.collector)==null?void 0:u.uid),n.undoTickerId=e||i.undoTickerId||this.undoTickerId,n.dataType=xe.Local;const o={...i,...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,...i}=t,o=this.editors.get(r)||{},a={...o,...i};if(e&&this.addUndoTicker(e,i.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(i.viewId,this.activeId)}get(t){return this.editors.get(t)}delete(t,e,r){const n=this.editors.get(t);if(n){const i=n.viewId;n.canSync=e,n.canWorker=r,this.editors.delete(t),this.activeId===t&&(this.activeId=void 0),this.control.viewContainerManager.updateTextEditorInfo(i,this.activeId)}}deleteBatch(t,e,r){const n=new Set;for(const i of t){const o=this.editors.get(i);if(o){const a=o.viewId;o.canSync=e,o.canWorker=r,this.editors.delete(i),this.activeId===i&&(this.activeId=void 0),n.add(a)}}for(const i of n)this.control.viewContainerManager.updateTextEditorInfo(i,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 g,y;if(!this.control.canAcceptLocalMutation(t))return;const i=(g=this.control.room)==null?void 0:g.state.memberState;if(!i)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(q.Text,i);if(!c)return;const l=(y=this.control.viewContainerManager)==null?void 0:y.transformToOriginPoint([e,r],t),h=eu(n,{whiteList:{},stripIgnoreTag:!0,stripIgnoreTagBody:["script"]}).split(/\n/),d=c.toolsOpt;d.text=xt(h),d.workState=de.Doing,d.boxPoint=[Math.round(e),Math.round(r)],d.boxSize=[d.fontSize,d.fontSize];const f=this.control.worker.now;return this.control.textEditorManager.checkEmptyTextBlur(),this.control.textEditorManager.createTextForMasterController({workId:f.toString(),x:l&&l[0]||0,y:l&&l[1]||0,scale:(a==null?void 0:a.scale)||1,opt:d,type:Tr.Text,isActive:!0,viewId:t,scenePath:o.focusScenePath},f),f.toString()}updateText(t,e){const r=this.editors.get(t.toString());if(!r||!this.control.canAcceptLocalMutation(r.viewId))return;const i=eu(e,{whiteList:{},stripIgnoreTag:!0,stripIgnoreTagBody:["script"]}).split(/\n/);r.opt.text=xt(i),this.control.textEditorManager.updateTextForMasterController({workId:t,opt:r.opt,viewId:r.viewId,canSync:!0,canWorker:!0},this.control.worker.now)}}const Sn=class Sn extends Re{constructor(e){super(e);x(this,"canRotate",!1);x(this,"scaleType",Ye.proportional);x(this,"toolsType",q.Text);x(this,"tmpPoints",[]);x(this,"workOptions");x(this,"oldRect");this.workOptions=e.toolsOpt}static async normalizeStorageData(e){return this.normalizeStorageDataSync(e)}static normalizeStorageDataSync(e){const r=Re.normalizeStorageDataSync(e);if(r.status==="unrecoverable")return r;const n=r.value,i=n.opt;return i&&i.workState!==de.Done?(n.type=le.FullWork,n.opt={...i,workState:de.Done},{status:"stable",value:n}):r}consume(){return{type:le.None}}consumeAll(){return{type:le.None}}consumeService(){}async draw(e){const{workId:r,layer:n,isDrawLabel:i,boxRect:o,isActive:a}=e;if(a&&!a())return;const{boxSize:c,boxPoint:l,zIndex:u}=this.workOptions,h=n.worldPosition,d=n.worldScaling;if(!l||!c)return;const f={name:r,id:r,pos:[l[0]-Ni,l[1]-Ni],anchor:[0,0],size:c,zIndex:u},g=new dt(f),y={x:l[0]-Ni,y:l[1]-Ni,w:c[0],h:c[1]},S={x:Math.floor(y.x*d[0]+h[0]),y:Math.floor(y.y*d[1]+h[1]),w:Math.floor(y.w*d[0])+2,h:Math.floor(y.h*d[1])+2};let b;if(o&&(b=Bc(S,o)),(i||o&&b!==sn.outside)&&n&&this.workOptions.text){const I=await Sn.createLabels(this.workOptions,n,S,a),{labels:N,maxWidth:T}=I;if(a&&!a())return N.forEach(p=>p.disconnect()),S;g.append(...N),S.w=Math.ceil(Math.max(T*n.worldScaling[0],S.w))}return a&&!a()?(g.removeAllChildren(),g.disconnect(),S):(this.replace(n,r,g),S)}async consumeServiceAsync(e){var h,d,f,g;const r=(h=this.workId)==null?void 0:h.toString();if(!r)return;const{isFullWork:n,replaceId:i,isDrawLabel:o,boxRect:a,isActive:c}=e;this.oldRect=i&&((f=(d=this.vNodes)==null?void 0:d.get(i))==null?void 0:f.rect)||void 0;const l=n?this.fullLayer:this.drawLayer||this.fullLayer,u=await this.draw({workId:r,layer:l,isDrawLabel:typeof o>"u"&&this.workOptions.workState===de.Done||o,boxRect:a,isActive:c});return c&&!c()||(g=this.vNodes)==null||g.setInfo(r,{rect:u,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:u&&Re.getCenterPos(u,l)}),u}updataOptService(){}async updataOptServiceAsync(e,r,n){var y,S;if(!this.workId)return;const i=this.workId.toString(),{fontColor:o,fontBgColor:a,bold:c,italic:l,lineThrough:u,underline:h,zIndex:d}=e,f=(y=this.vNodes)==null?void 0:y.get(i);if(!f)return;o&&(f.opt.fontColor=o),a&&(f.opt.fontBgColor=a),c&&(f.opt.bold=c),l&&(f.opt.italic=l),_n(u)&&(f.opt.lineThrough=u),_n(h)&&(f.opt.underline=h),yt(d)&&(f.opt.zIndex=d),this.oldRect=f.rect;const g=await this.draw({workId:i,layer:this.fullLayer,isDrawLabel:typeof r>"u"&&this.workOptions.workState===de.Done||r,boxRect:n});return(S=this.vNodes)==null||S.setInfo(i,{rect:g,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:g&&Re.getCenterPos(g,this.fullLayer)}),g}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 i=n;return n<=2?i=n*r*2:n>2&&n<=3?i=n*r*1.6:n>3&&n<=4?i=n*r*1.2:n>4&&(i=n*r),Math.floor(i*1e3)/1e3}static getSafetySnippetFontLength(e){return Math.floor(Sn.textImageSnippetSize*3/4/e)||1}static async createLabels(e,r,n,i){var P;const o=[],{x:a,y:c}=n,{width:l,height:u}=(P=r.parent)==null?void 0:P.parent,h=Nn(e.text),d=h.length,{fontSize:f,lineHeight:g,bold:y,textAlign:S,italic:b,fontFamily:I,verticalAlign:N,fontColor:T,fontBgColor:p,underline:m,lineThrough:v}=e,M=Sn.getSafetySnippetRatio(r)||1,k=Math.floor(f*M),E=Sn.getSafetySnippetFontLength(k);let D=0;for(let z=0;z<d;z++){const j=h[z],A=g||k*1.5;if(j){const R=H0e(j),L=[0,0],W=[0,f*1.2];N==="middle"&&(L[1]=Math.floor(z*f*1.2+6+f*(1.1-1)));const Y=[0,Math.floor(-f*.15)];L[0]=6;const H=Math.sin(Math.PI/180*20);let ie=0;const O=[];let V=0;for(;V<R;){if(i&&!i())return O.forEach(pe=>pe.disconnect()),o.forEach(pe=>pe.disconnect()),{labels:[],maxWidth:D};S==="left"&&(Y[0]=ie),V===0&&b==="italic"&&(Y[0]=Y[0]-H/2*f);const $=j.slice(V,V+E),ee={anchor:[0,0],pos:Y,text:$,fontFamily:I,fontSize:k,lineHeight:A,strokeColor:T,fontWeight:y,fillColor:T,textAlign:S,fontStyle:b,scale:[1/M,1/M]},se=new qh(ee),ce=await se.textImageReady;if(i&&!i())return se.disconnect(),O.forEach(pe=>pe.disconnect()),o.forEach(pe=>pe.disconnect()),{labels:[],maxWidth:D};let me=!0;if(ce){const pe=ce.rect&&ce.rect[2],B=ce.rect&&ce.rect[3];if(pe&&B){const F=pe/M,J=B/M;ie=F+ie,b==="italic"&&(y==="bold"?ie=ie-H*f*1.2:ie=ie-H*f),((Y[0]+L[0]+F)*r.worldScaling[0]+a<=0||(Y[0]+L[0])*r.worldScaling[0]+a>=l||(Y[1]+L[1]+J)*r.worldScaling[1]+c<=0||(Y[1]+L[1])*r.worldScaling[1]+c>=u)&&(se.disconnect(),me=!1),me&&O.push(se)}}V+=E}W[0]=ie,b==="italic"&&(W[0]=W[0]+H*f),D=Math.max(D,W[0]);let Z=!0;if(((L[0]+W[0])*r.worldScaling[0]+a<=0||L[0]*r.worldScaling[0]+a>=l||(L[1]+W[1])*r.worldScaling[0]+c<=0||L[1]*r.worldScaling[1]+c>=u)&&(Z=!1),Z){if(m){const se=Math.floor(f/10),ce={normalize:!1,pos:[0,f*1.1+se/2],lineWidth:se,points:[0,0,Math.ceil(W[0]),0],strokeColor:T,className:"underline"},me=new Cr(ce);O.push(me)}if(v){const se={normalize:!1,pos:[0,f*1.2/2],lineWidth:Math.floor(f/10),points:[0,0,Math.ceil(W[0]),0],strokeColor:T,className:"lineThrough"},ce=new Cr(se);O.push(ce)}const $={pos:L,anchor:[0,0],size:W,bgcolor:p},ee=new dt($);ee.append(...O),o.push(ee)}}}return{labels:o,maxWidth:D}}static updateNodeOpt(e){const{node:r,opt:n,vNodes:i,targetNode:o}=e,{fontBgColor:a,fontColor:c,translate:l,originPoint:u,scenePoint:h,scale:d,bold:f,italic:g,lineThrough:y,underline:S,fontSize:b,textInfos:I,zIndex:N}=n,T=o&&ht(o)||i.get(r.name);if(!T||!r.parent)return;const m=T.opt;if(yt(N)&&(r.setAttribute("zIndex",N),T.opt.zIndex=N),c&&m.fontColor&&(m.fontColor=c,r.children.forEach(v=>{v.tagName==="GROUP"&&v.children.forEach(M=>{M.tagName==="LABEL"?(M.setAttribute("fillColor",c),M.setAttribute("strokeColor",c)):M.tagName==="POLYLINE"&&M.setAttribute("strokeColor",c)})})),a&&m.fontBgColor&&(m.fontBgColor=a,r.children.forEach(v=>{v.tagName==="GROUP"&&v.setAttribute("bgcolor",a)})),f&&(m.bold=f),g&&(m.italic=g),_n(y)&&(m.lineThrough=y),_n(S)&&(m.underline=S),b&&(m.fontSize=b),u&&h&&d&&o&&m.boxPoint){const v=I==null?void 0:I.get(r.name);if(v){const{fontSize:D,boxSize:P}=v;m.boxSize=P||m.boxSize,m.fontSize=D||m.fontSize}const M=[m.boxPoint[0],m.boxPoint[1]];zc(m.boxPoint,h,d,l);const k=[T.op[0],T.op[1]],E=[k[0]-M[0],k[1]-M[1]];if(T.centerPos=[T.centerPos[0]+E[0],T.centerPos[1]+E[1]],T.opt.eraserlines)for(const D of T.opt.eraserlines){const{op:P,thickness:z}=D;D.thickness=Math.round(z*Math.max(d[0],d[1]));for(let j=0;j<P.length;j++)Fs(P[j],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 v of T.opt.eraserlines){const{op:M}=v;for(let k=0;k<M.length;k++){const E=M[k].map((D,P)=>P%2?D+l[1]:D+l[0]);v.op[k]=E}}return T&&i.setInfo(r.name,T),T==null?void 0:T.rect}static getRectFromLayer(e,r){const n=e.getElementsByName(r)[0];if(n){const i=n.getBoundingClientRect();let o={x:Math.floor(i.x),y:Math.floor(i.y),w:Math.floor(i.width+2),h:Math.floor(i.height+2)};return n.children.forEach(a=>{if(a.tagName==="GROUP"){const c=n.getBoundingClientRect();o=Ue(o,{x:Math.floor(c.x),y:Math.floor(c.y),w:Math.floor(c.width+2),h:Math.floor(c.height+2)})}}),o}}};x(Sn,"textImageSnippetSize",1024*4),x(Sn,"SafeBorderPadding",30);let Qs=Sn;const Cye=.01;function T0(s,t,e={}){let r=s.length-1;const n=e.protectedIndex??-1,i=e.timestamp??Date.now();for(let o=0;o<t.length;o+=2){const a=new Pe(t[o],t[o+1]),c=s[s.length-1];if(!c){a.setT(i),s.push(a);continue}if(a.x===c.x&&a.y===c.y){c.setT(i);continue}const l=s.length-1;if(s.length>1&&l>n){const h=s[l-1],d=fe.Sub(c,h).uni(),f=fe.Sub(a,c).uni();Number.isFinite(d.x)&&Number.isFinite(d.y)&&Number.isFinite(f.x)&&Number.isFinite(f.y)&&fe.Equals(d,f,Cye)&&(s.pop(),r--)}const u=s[s.length-1];a.setv(fe.Sub(a,u).uni()),a.setT(i),s.push(a)}return Math.max(r,0)}const Fi=class Fi extends Re{constructor(e){super(e);x(this,"canRotate",!1);x(this,"scaleType",Ye.none);x(this,"toolsType",q.PencilEraser);x(this,"tmpPoints",[]);x(this,"workOptions");x(this,"worldPosition");x(this,"worldScaling");x(this,"eraserRect");x(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:le.None};const{thickness:n}=this.workOptions,{width:i,height:o}=Fi.eraserSizes[n],a=Math.round(Math.max(i,o)/this.worldScaling[0]),{rect:c,willNewNodes:l,willDeleteNodes:u}=this.getChangeNodes(a,r);return{...this.baseConsumeResult,type:le.DrawWork,rect:c,willNewNodes:l,willDeleteNodes:u}}consumeService(){}updateTempPoints(e,r){return T0(this.tmpPoints,e)}getChangeNodes(e,r){const n=new Map,i=new Set;let o;if(!this.vNodes)return{willDeleteNodes:i,willNewNodes:n,rect:o};const a=this.worldPosition;let c=it(this.tmpPoints,e);c=Ks(c,a),c=$0(c,this.worldScaling,a);const{nodeRange:l}=this.vNodes.getRectIntersectRange(c);if(!l.size)return{willDeleteNodes:i,willNewNodes:n,rect:o};const u=this.computEraserPointLines(this.tmpPoints,90);for(const[h,d]of l.entries()){if(d.toolsType!==q.Pencil)continue;let f=Ks(d.rect,[-a[0],-a[1]]);f={x:f.x/this.worldScaling[0],y:f.y/this.worldScaling[1],w:f.w/this.worldScaling[0],h:f.h/this.worldScaling[1]};const g=[f.x,f.y,f.x+f.w,f.y+f.h],y=[],S=[];for(const b of u)th.polyline(b,g,y);if(y.length&&d.opt)for(const b of y){const I=[];for(let N=0;N<b.length;N++)N!==0&&nn(b[N],b[N-1])||I.push(...b[N]);S.push(I)}if(S.length&&r){const b=r.createWorkShapeNode({workId:h,toolsType:q.Pencil,toolsOpt:d.opt});b.setWorkId(h);const I=b==null?void 0:b.computPencilPoints({op:d.op,eraserPolylines:S,eraserThickness:e});if(o=Ue(o,d.rect),i.add(h),r.removeNode(h),I.length)for(let N=0;N<I.length;N++){const T=`${h}_${Date.now()}_${N}`,p=T,v=r.setFullWork({workId:p,opt:d.opt,toolsType:q.Pencil}).consumeService({op:I[N],isFullWork:!0,replaceId:p});r.clearWorkShapeNodeCache(p),o=Ue(o,v),n.set(T,{...d,toolsType:q.Pencil,rect:v??d.rect,name:T,op:I[N]})}}}return{willNewNodes:n,willDeleteNodes:i,rect:o}}consume(e){const{data:r}=e,{op:n}=r;if(!n||n.length===0)return{type:le.None,...this.baseConsumeResult};const{thickness:i}=this.workOptions,{width:o,height:a}=Fi.eraserSizes[i],c=Math.max(o,a)/this.worldScaling[0];return this.updateTempPoints(n,c),{type:le.None,...this.baseConsumeResult}}computEraserPointLines(e,r=60){const n=[];let i=0;const o=360-r;for(let a=1;a<e.length;a++){const c=e[a-1],l=e[a];if(a===1&&i===0&&(n[i]=[c.XY]),n[i].push(l.XY),a<e.length-1){const u=l.getAngleByPoints(c,e[a+1]);(u<r||u>o)&&(i++,n[i]=[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:le.None,...this.baseConsumeResult};const{thickness:n}=this.workOptions,{width:i,height:o}=Fi.eraserSizes[n],a=Math.max(i,o)/this.worldScaling[0],{willDeleteNodes:c,willNewNodes:l,rect:u}=this.getChangeNodes(a,r);if(c.size===0&&l.size===0)return{type:le.FullWork,...this.baseConsumeResult,rect:u};const h=[];this.tmpPoints.map(f=>{h.push(f.x,f.y,a/2)});const d=xt(h);return{...this.baseConsumeResult,type:le.FullWork,dataType:xe.Local,rect:u,ops:d,willNewNodes:l,willDeleteNodes:c}}clearTmpPoints(){this.tmpPoints.length=0}};x(Fi,"eraserSizes",hd);let Ba=Fi;const bye=new Set([q.Image,q.BackgroundSVG]),Rp={"shape.vertices":new Set([q.Polygon,q.Star]),"shape.innerVerticeStep":new Set([q.Star]),"shape.innerRatio":new Set([q.Star]),"shape.placement":new Set([q.SpeechBalloon])},Eye=new Set(["fontColor","fontBgColor","fontSize","bold","italic","underline","lineThrough"]),xye=new Set(["strokeColor","thickness","strokeType"]),Rye=new Set(["fillColor"]),kye=new Set(["zIndexLayer"]),Aye=new Set([q.Pencil,q.LaserPen,q.Arrow,q.Straight]),kp=new Set([q.Rectangle,q.Ellipse,q.Triangle,q.Rhombus,q.Polygon,q.Star,q.SpeechBalloon]),Pye=new Set([q.Pencil,q.Arrow,q.Straight,q.Rectangle,q.Ellipse,q.Star,q.Triangle,q.Rhombus,q.Polygon,q.SpeechBalloon]);function I0(s){return s!==void 0&&Pye.has(s)}const Dye=new Set([q.Pencil]),Lye=new Set([q.LaserPen,q.Arrow,q.Straight,q.Rectangle,q.Ellipse,q.Star,q.Polygon,q.SpeechBalloon]);function C0(s){return s===Be.Normal||s===Be.Stroke||s===Be.Dotted||s===Be.LongDotted}function Oi(s,t){return s?kye.has(t)?!0:t==="isLocked"?bye.has(s):Eye.has(t)?s===q.Text:t in Rp?Rp[t].has(s):Rye.has(t)?kp.has(s):xye.has(t)?Aye.has(s)||kp.has(s):!1:!1}function Nye(s){return["strokeColor","fillColor","thickness","strokeType","fontColor","fontBgColor","fontSize","bold","italic","underline","lineThrough","isLocked","zIndexLayer","shape.vertices","shape.innerVerticeStep","shape.innerRatio","shape.placement"].filter(e=>Oi(s,e))}function Ss(s){var e,r,n,i;const t=[];return s.strokeColor!==void 0&&t.push("strokeColor"),s.fillColor!==void 0&&t.push("fillColor"),s.thickness!==void 0&&t.push("thickness"),s.strokeType!==void 0&&t.push("strokeType"),s.fontColor!==void 0&&t.push("fontColor"),s.fontBgColor!==void 0&&t.push("fontBgColor"),s.fontSize!==void 0&&t.push("fontSize"),s.bold!==void 0&&t.push("bold"),s.italic!==void 0&&t.push("italic"),s.underline!==void 0&&t.push("underline"),s.lineThrough!==void 0&&t.push("lineThrough"),s.isLocked!==void 0&&t.push("isLocked"),s.zIndexLayer!==void 0&&t.push("zIndexLayer"),((e=s.shape)==null?void 0:e.vertices)!==void 0&&t.push("shape.vertices"),((r=s.shape)==null?void 0:r.innerVerticeStep)!==void 0&&t.push("shape.innerVerticeStep"),((n=s.shape)==null?void 0:n.innerRatio)!==void 0&&t.push("shape.innerRatio"),((i=s.shape)==null?void 0:i.placement)!==void 0&&t.push("shape.placement"),t}function Ap(s,t){return!s||t===void 0||!Oi(s,"strokeType")?!1:Dye.has(s)?C0(t):Lye.has(s)?t===Be.Normal||t===Be.Dotted||t===Be.LongDotted:!1}function Oye(s,t,e){const r=s-(e?1:2);if(!(r<1||r<=t))return{start:Math.max(t,0),end:r,committedIndex:r}}function Vl(s){return s.toolsType===q.Image||s.toolsType===q.Text?"delete-on-done":s.isSelected?"blocked":I0(s.toolsType)?"vector":"blocked"}function zye(s,t,e){return s.map(({x:r,y:n})=>[r*e[0]+t[0],n*e[1]+t[1]])}function $l(s,t,e){if(!s.length)return!1;if(s.length===1)return ju(s[0],e)<=t*t;for(let r=1;r<s.length;r++)if(Bye(s[r-1],s[r],e)<=t*t)return!0;return!1}function ju(s,t){const e=Math.max(t.x-s[0],0,s[0]-(t.x+t.w)),r=Math.max(t.y-s[1],0,s[1]-(t.y+t.h));return e*e+r*r}function Bye(s,t,e){if(jye(s,t,e))return 0;const r=e.x,n=e.y,i=e.x+e.w,o=e.y+e.h,a=[[[r,n],[i,n]],[[i,n],[i,o]],[[i,o],[r,o]],[[r,o],[r,n]]];let c=Math.min(ju(s,e),ju(t,e));for(const[l,u]of a)c=Math.min(c,Fye(s,t,l,u));return c}function jye(s,t,e){let r=0,n=1;const i=t[0]-s[0],o=t[1]-s[1],a=[[-i,s[0]-e.x],[i,e.x+e.w-s[0]],[-o,s[1]-e.y],[o,e.y+e.h-s[1]]];for(const[c,l]of a){if(c===0){if(l<0)return!1;continue}const u=l/c;if(c<0?r=Math.max(r,u):n=Math.min(n,u),r>n)return!1}return!0}function Fye(s,t,e,r){const n=t[0]-s[0],i=t[1]-s[1],o=r[0]-e[0],a=r[1]-e[1],c=s[0]-e[0],l=s[1]-e[1],u=n*n+i*i,h=n*o+i*a,d=o*o+a*a,f=n*c+i*l,g=o*c+a*l,y=u*d-h*h;let S=y,b=y,I=y,N=y;y<Number.EPSILON?(S=0,I=1,b=g,N=d):(S=h*g-d*f,b=u*g-h*f,S<0?(S=0,b=g,N=d):S>I&&(S=I,b=g+h,N=d)),b<0?(b=0,-f<0?S=0:-f>u?S=I:(S=-f,I=u)):b>N&&(b=N,-f+h<0?S=0:-f+h>u?S=I:(S=-f+h,I=u));const T=Math.abs(S)<Number.EPSILON?0:S/I,p=Math.abs(b)<Number.EPSILON?0:b/N,m=c+T*n-p*o,v=l+T*i-p*a;return m*m+v*v}const Ya=class Ya extends Re{constructor(e){super(e);x(this,"canRotate",!1);x(this,"scaleType",Ye.none);x(this,"toolsType",q.BitMapEraser);x(this,"tmpPoints",[]);x(this,"workOptions");x(this,"worldPosition");x(this,"worldScaling");x(this,"eraserRect");x(this,"eraserPolyline");x(this,"oldRect");x(this,"committedPointIndex",-1);x(this,"candidateWorkIds",new Set);x(this,"doingPointBatches",[]);x(this,"doingLines",new Map);x(this,"changedNodes",new Map);x(this,"deletedNodes",new Set);x(this,"changedRect");x(this,"lastSceneRevision",-1);x(this,"pendingDeleteIds",new Set);x(this,"hiddenRenderNodes",new Map);x(this,"fullLayerPreviewGroup");x(this,"disposeVNodeObserver");x(this,"beforeImages",new Map);this.workOptions=e.toolsOpt,this.worldPosition=this.fullLayer.worldPosition,this.worldScaling=this.fullLayer.worldScaling,this.startVNodeObservation()}combineConsume(e){var l;this.syncWorldTransform(),this.startVNodeObservation();const r=this.getDeltaPoints(!0),n=((l=this.vNodes)==null?void 0:l.getRevision())??0,i=n!==this.lastSceneRevision;let o=this.restoreNoLongerClearablePendingDeletes();const a=i?this.tmpPoints:r==null?void 0:r.points;if(a!=null&&a.length){const u=this.getEraserThickness();o=Ue(o,this.hideDeleteCandidatesForPoints(a,u)),this.collectVectorCandidateWorkIds(a,u)}if(this.lastSceneRevision=n,!r)return{...this.baseConsumeResult,type:o?le.DrawWork:le.None,rect:o};const c=this.getEraserThickness();return this.recordDoingPointBatch(r.points),o=Ue(o,this.appendFullLayerPreview(r.points,c)),this.committedPointIndex=r.committedIndex,this.changedRect=Ue(this.changedRect,o),{...this.baseConsumeResult,type:o?le.DrawWork:le.None,rect:o}}consumeService(){}consume(e){const{op:r}=e.data;return r!=null&&r.length?(this.syncWorldTransform(),this.updateTempPoints(r),{type:le.None,...this.baseConsumeResult}):{type:le.None,...this.baseConsumeResult}}async consumeAll(e){const{workerEngine:r}=e;if(this.syncWorldTransform(),this.clearFullLayerPreview(!1),!this.tmpPoints.length)return this.clearFullLayerPreview(!0),{type:le.None,...this.baseConsumeResult};const n=this.getEraserThickness(),i=new Map(this.beforeImages);try{this.recordFinalPointBatch(),this.getCandidateWorkIds().clear(),this.collectVectorCandidateWorkIds(this.tmpPoints,n),this.collectDeleteCandidatesForDone(this.tmpPoints,n);for(const[u,h]of this.snapshotDoneCandidates())i.set(u,h);r&&typeof r.publishBitmapEraserBeforeImages=="function"&&r.publishBitmapEraserBeforeImages(this.workId,i),this.collectDoneVectorChanges(n),this.commitDoingFaces(),this.renderChangedNodes(r,this.workOptions.removeOnDone!==!1),this.commitPendingDeletions(r);const o=new Set(this.deletedNodes),a=new Map(this.changedNodes),c=this.changedRect;if(o.size===0&&a.size===0)return{type:le.FullWork,...this.baseConsumeResult,rect:c,eraseTxnBeforeImages:new Map(i),eraseTxnCommitStatus:"applied"};const l=[];for(const u of this.tmpPoints)l.push(u.x,u.y,n/2);return{...this.baseConsumeResult,type:le.FullWork,dataType:xe.Local,rect:c,ops:xt(l),willUpdateNodes:a,willDeleteNodes:o,eraseTxnBeforeImages:new Map(i),eraseTxnCommitStatus:"applied"}}catch(o){let a=!0;try{a=!await this.restoreFailedDoneCandidates(i,r)}catch(l){console.warn("[BitMapEraser] Done recovery threw after commit error:",l)}const c=this.changedRect;try{this.clearFullLayerPreview(!0)}catch(l){console.warn("[BitMapEraser] Done preview cleanup failed:",l)}return this.changedNodes.clear(),this.getCandidateWorkIds().clear(),this.getDoingPointBatches().length=0,this.getDoingLines().clear(),this.deletedNodes.clear(),this.pendingDeleteIds.clear(),console.warn("[BitMapEraser] Done commit aborted:",o),{type:le.FullWork,...this.baseConsumeResult,rect:c,willUpdateNodes:new Map,willDeleteNodes:new Set,eraseTxnBeforeImages:new Map(i),eraseTxnRecoveryRequired:a,eraseTxnCommitStatus:"failed"}}}clearTmpPoints(){this.clearFullLayerPreview(!0),this.stopVNodeObservation(),this.tmpPoints.length=0,this.committedPointIndex=-1,this.changedNodes.clear(),this.getCandidateWorkIds().clear(),this.getDoingPointBatches().length=0,this.getDoingLines().clear(),this.deletedNodes.clear(),this.pendingDeleteIds.clear(),this.changedRect=void 0,this.lastSceneRevision=-1}shouldRevalidateVNodeRevision(){return this.tmpPoints.length>0}syncWorldTransform(){this.worldPosition=this.fullLayer.worldPosition,this.worldScaling=this.fullLayer.worldScaling}getEraserThickness(){const{thickness:e}=this.workOptions,{width:r,height:n}=Ya.eraserSizes[e];return Math.round(Math.max(r,n)/this.worldScaling[0])}updateTempPoints(e){T0(this.tmpPoints,e,{protectedIndex:this.committedPointIndex})}getDeltaPoints(e){const r=Oye(this.tmpPoints.length,this.committedPointIndex,e);if(r)return{points:this.tmpPoints.slice(r.start,r.end+1),committedIndex:r.committedIndex}}recordFinalPointBatch(){const e=this.getDeltaPoints(!0);if(e){this.recordDoingPointBatch(e.points),this.committedPointIndex=e.committedIndex;return}!this.getDoingPointBatches().length&&this.tmpPoints.length&&(this.recordDoingPointBatch(this.tmpPoints),this.committedPointIndex=this.tmpPoints.length-1)}recordDoingPointBatch(e){e.length&&this.getDoingPointBatches().push(e.map(r=>new Pe(r.x,r.y,r.z)))}getDoingPointBatches(){return this.doingPointBatches||(this.doingPointBatches=[]),this.doingPointBatches}getDoingLines(){return this.doingLines||(this.doingLines=new Map),this.doingLines}getCandidateWorkIds(){return this.candidateWorkIds||(this.candidateWorkIds=new Set),this.candidateWorkIds}appendFullLayerPreview(e,r){if(!e.length)return;const n=this.computEraserPointLines(e).map(c=>{const l=c.flatMap(([u,h])=>[u,h]);return Lr(this.computEraserPoints(l,r),!0)}).filter(Boolean);if(!n.length)return;const i=new $t({pos:[0,0],d:n.join(" "),fillColor:"rgba(0,0,0,1)",fillRule:"evenodd"});let o=!1;i.addEventListener("beforerender",({detail:c})=>{const l=c.context;typeof l.blendFuncSeparate=="function"?l.blendFuncSeparate(l.ZERO,l.ZERO,l.ZERO,l.ZERO):(l.save(),o=!0,l.globalCompositeOperation="destination-out")}),i.addEventListener("afterrender",({detail:c})=>{const l=c.context;typeof l.blendFuncSeparate=="function"?l.blendFuncSeparate(l.SRC_ALPHA,l.ONE_MINUS_SRC_ALPHA,l.ONE,l.ONE_MINUS_SRC_ALPHA):o&&(o=!1,l.restore())}),this.getFullLayerPreviewGroup().append(i);let a=it(e,r);return a=Ks(a,this.worldPosition),$0(a,this.worldScaling,this.worldPosition)}getFullLayerPreviewGroup(){if(this.fullLayerPreviewGroup)return this.fullLayerPreviewGroup;const e=new dt({name:this.workId,pos:[0,0],zIndex:9999});return this.fullLayer.append(e),this.fullLayerPreviewGroup=e,e}getTrackRect(e,r){let n=e[0][0],i=e[0][1],o=n,a=i;for(let c=1;c<e.length;c++){const[l,u]=e[c];n=Math.min(n,l),i=Math.min(i,u),o=Math.max(o,l),a=Math.max(a,u)}return{x:n-r,y:i-r,w:o-n+r*2,h:a-i+r*2}}getScreenTrack(e,r){const n=zye(e,this.worldPosition,this.worldScaling),i=r*Math.max(Math.abs(this.worldScaling[0]),Math.abs(this.worldScaling[1]))/2;return{screenPoints:n,radius:i,rect:this.getTrackRect(n,i+1)}}collectVectorCandidateWorkIds(e,r){if(!this.vNodes||!e.length)return;const n=this.getScreenTrack(e,r),{nodeRange:i}=this.vNodes.getRectIntersectRange(n.rect,!1,!1);for(const[o,a]of i)!this.vNodes.isCanClearWorkId(o)||Vl(a)!=="vector"||!$l(n.screenPoints,n.radius,a.rect)||this.getCandidateWorkIds().add(o)}hideDeleteCandidatesForPoints(e,r){if(!this.vNodes||!e.length)return;const n=this.getScreenTrack(e,r);let i;const{nodeRange:o}=this.vNodes.getRectIntersectRange(n.rect,!1,!1);for(const[a,c]of o)this.pendingDeleteIds.has(a)||!this.vNodes.isCanClearWorkId(a)||Vl(c)!=="delete-on-done"||!$l(n.screenPoints,n.radius,c.rect)||(this.pendingDeleteIds.add(a),this.hideRenderNodesForId(a),i=Ue(i,c.rect),this.changedRect=Ue(this.changedRect,c.rect));return i}collectDeleteCandidatesForDone(e,r){if(!this.vNodes||!e.length)return;const n=this.getScreenTrack(e,r),{nodeRange:i}=this.vNodes.getRectIntersectRange(n.rect,!1,!1);for(const[o,a]of i)this.vNodes.isCanClearWorkId(o)&&Vl(a)==="delete-on-done"&&$l(n.screenPoints,n.radius,a.rect)&&(this.pendingDeleteIds.add(o),this.changedRect=Ue(this.changedRect,a.rect))}hideRenderNodesForId(e){this.captureBeforeImage(e);const r=this.hiddenRenderNodes.get(e)||[],n=new Set(r.map(({node:i})=>i));for(const i of this.fullLayer.getElementsByName(e))n.has(i)||r.push({node:i,display:i.getAttribute("display")}),i.setAttribute("display","none");this.hiddenRenderNodes.set(e,r)}restoreNoLongerClearablePendingDeletes(){var r,n,i;let e;for(const o of[...this.pendingDeleteIds])if(!((r=this.vNodes)!=null&&r.isCanClearWorkId(o))){for(const{node:a,display:c}of this.hiddenRenderNodes.get(o)||[])a.setAttribute("display",c);e=Ue(e,(i=(n=this.vNodes)==null?void 0:n.get(o))==null?void 0:i.rect),this.hiddenRenderNodes.delete(o),this.pendingDeleteIds.delete(o)}return e}snapshotDoneCandidates(){var r;const e=new Map;for(const n of[...this.getCandidateWorkIds(),...this.pendingDeleteIds]){if(e.has(n)||!((r=this.vNodes)!=null&&r.isCanClearWorkId(n)))continue;const i=this.vNodes.get(n);if(i){const o=ht(i);e.set(n,o),this.beforeImages.has(n)||this.beforeImages.set(n,o)}}return e}captureBeforeImage(e){var n;if(this.beforeImages.has(e)||!((n=this.vNodes)!=null&&n.isCanClearWorkId(e)))return;const r=this.vNodes.get(e);r&&this.beforeImages.set(e,ht(r))}collectDoneVectorChanges(e){if(!this.vNodes)return;const r=this.worldPosition;for(const n of this.getCandidateWorkIds()){if(!this.vNodes.isCanClearWorkId(n))continue;const i=this.vNodes.get(n);if(!(i!=null&&i.opt)||!I0(i.toolsType))continue;let o=Ks(i.rect,[-r[0],-r[1]]);o={x:o.x/this.worldScaling[0],y:o.y/this.worldScaling[1],w:o.w/this.worldScaling[0],h:o.h/this.worldScaling[1]};const a=[o.x,o.y,o.x+o.w,o.y+o.h],c=[];for(const l of this.getDoingPointBatches())for(const u of this.computEraserPointLines(l,120)){const h=[];th.polyline(u,a,h);for(const d of h){const f=this.normalizeClippedLine(d);f.length&&c.push(f)}}c.length&&(this.getDoingLines().set(n,[{workId:this.workId,op:c,thickness:e}]),this.changedNodes.set(n,i),this.changedRect=Ue(this.changedRect,i.rect))}}normalizeClippedLine(e){const r=[];for(let n=0;n<e.length&&!(isNaN(e[n][0])||isNaN(e[n][1]));n++){const i=e[n].map(o=>Math.round(o*100)/100);if(n>0){const o=e[n-1].map(a=>Math.round(a*100)/100);if(nn(i,o))continue}r.push(...i)}return r}commitDoingFaces(){var e;for(const[r,n]of this.getDoingLines()){if(!((e=this.vNodes)!=null&&e.isCanClearWorkId(r))){this.changedNodes.delete(r);continue}const i=this.vNodes.get(r);if(!(i!=null&&i.opt)||!n.length){this.changedNodes.delete(r);continue}const o=jpe(i.opt,n),a=Da({...i.opt,...o});delete a.eraserlines,i.opt=a,this.changedNodes.set(r,i),this.vNodes.setInfo(r,{opt:a})}}renderChangedNodes(e,r){if(e)for(const[n,i]of[...this.changedNodes]){const o=e.createWorkShapeNode({workId:n,toolsType:i.toolsType,toolsOpt:i.opt});o==null||o.setWorkId(n),o==null||o.setEraserDeleteConfirmation(r);const a=o==null?void 0:o.consumeService({op:i.op,isFullWork:!0,replaceId:n});this.changedRect=Ue(this.changedRect,a),r&&(o!=null&&o.isDelete)&&(e.removeNode(n),this.deletedNodes.add(n),this.changedNodes.delete(n))}}commitPendingDeletions(e){var r;for(const n of this.pendingDeleteIds){if(!((r=this.vNodes)!=null&&r.isCanClearWorkId(n))){for(const{node:o,display:a}of this.hiddenRenderNodes.get(n)||[])o.setAttribute("display",a);continue}const i=this.vNodes.get(n);i&&(this.changedRect=Ue(this.changedRect,i.rect)),e==null||e.removeNode(n),this.deletedNodes.add(n),this.changedNodes.delete(n)}this.pendingDeleteIds.clear(),this.hiddenRenderNodes.clear(),this.stopVNodeObservation()}clearFullLayerPreview(e){var r;if((r=this.fullLayerPreviewGroup)==null||r.remove(),this.fullLayerPreviewGroup=void 0,!!e){for(const n of this.hiddenRenderNodes.values())for(const{node:i,display:o}of n)i.setAttribute("display",o);this.hiddenRenderNodes.clear(),this.pendingDeleteIds.clear()}}startVNodeObservation(){!this.vNodes||this.disposeVNodeObserver||typeof this.vNodes.observeRevision!="function"||(this.disposeVNodeObserver=this.vNodes.observeRevision((e,r,n)=>{n&&(e==="add"||e==="update")&&this.pendingDeleteIds.has(n)&&this.hideRenderNodesForId(n)}))}stopVNodeObservation(){var e;(e=this.disposeVNodeObserver)==null||e.call(this),this.disposeVNodeObserver=void 0}async restoreFailedDoneCandidates(e,r){var i;let n=!0;for(const[o,a]of e)try{const c=ht(a);if((i=this.vNodes)==null||i.setInfo(o,c),!r)continue;const l=r.createWorkShapeNode({workId:o,toolsType:c.toolsType,toolsOpt:c.opt});if(!l){n=!1;continue}l.setWorkId(o),c.toolsType===q.Image?await l.consumeServiceAsync({isFullWork:!0,replaceId:o,worker:r})||(n=!1):c.toolsType===q.Text?await l.consumeServiceAsync({isFullWork:!0,replaceId:o,boxRect:r.thread.getSceneRect()})||(n=!1):l.consumeService({op:c.op,isFullWork:!0,replaceId:o})}catch(c){n=!1,console.warn(`[BitMapEraser] Failed to restore ${o} after Done error:`,c)}return n}computEraserPointLines(e,r=60){const n=[];let i=0;const o=360-r;for(let a=1;a<e.length;a++){const c=e[a-1],l=e[a];if(a===1&&i===0&&(n[i]=[c.XY]),n[i].push(l.XY),a<e.length-1){const u=l.getAngleByPoints(c,e[a+1]);(u<r||u>o)&&(i++,n[i]=[l.XY])}}return e.length===1&&n.push([e[0].XY,e[0].XY]),n}};x(Ya,"eraserSizes",hd);let ja=Ya;class qs extends Re{constructor(e){super(e);x(this,"canRotate",!1);x(this,"scaleType",Ye.all);x(this,"toolsType",q.BackgroundSVG);x(this,"tmpPoints",[]);x(this,"workOptions");x(this,"oldRect");this.workOptions=e.toolsOpt,this.scaleType=qs.getScaleType(this.workOptions)}static normalizeStorageData(e){return Re.normalizeStorageData(e)}consume(){return{type:le.None}}consumeAll(){return{type:le.None}}draw(e){const{layer:r,workId:n,replaceId:i}=e,{centerX:o,centerY:a,width:c,height:l,rotate:u,zIndex:h}=this.workOptions,d=(h||0)-100,f=new dt({anchor:[.5,.5],pos:[o,a],name:n,size:[c,l],zIndex:d,rotate:u}),g=new Gs({normalize:!0,pos:[0,0],width:c,height:l});f.appendChild(g),this.replace(r,i||n,f);const y=f.getBoundingClientRect();if(y)return{x:Math.floor(y.x-Re.SafeBorderPadding),y:Math.floor(y.y-Re.SafeBorderPadding),w:Math.floor(y.width+Re.SafeBorderPadding*2),h:Math.floor(y.height+Re.SafeBorderPadding*2)}}consumeService(e){var o;const{replaceId:r}=e,n=this.workId,i=this.draw({workId:n,layer:this.fullLayer,replaceId:r});return(o=this.vNodes)==null||o.setInfo(n,{rect:i,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:i&&Re.getCenterPos(i,this.fullLayer)}),i}clearTmpPoints(){this.tmpPoints.length=0}static getScaleType(e){const{uniformScale:r,rotate:n}=e;return r!==!1||n&&Math.abs(n)%90>0?Ye.proportional:Ye.all}static updateNodeOpt(e){const{node:r,opt:n,vNodes:i,targetNode:o}=e,{translate:a,originPoint:c,scenePoint:l,scale:u,angle:h,isLocked:d,zIndexForBackgroundSVG:f}=n,g=o&&ht(o)||i.get(r.name);if(!g)return;const y=r.parent;if(y){if(yt(f)){const S=(f||0)-100;r.setAttribute("zIndex",S),g.opt.zIndex=f}if(_n(d)&&(g.opt.locked=d),c&&l&&u&&a){const{centerX:S,centerY:b,width:I,height:N,uniformScale:T}=g.opt,p=T!==!1?[u[0],u[0]]:u,m=[S,b],v=[S,b];zc(v,l,p,a);const M=[v[0]-m[0],v[1]-m[1]];g.centerPos=[g.centerPos[0]+M[0],g.centerPos[1]+M[1]],g.opt.width=Math.round(I*p[0]),g.opt.height=Math.round(N*p[1]),g.opt.centerX=v[0],g.opt.centerY=v[1]}else if(a)g.opt.centerX=g.opt.centerX+a[0],g.opt.centerY=g.opt.centerY+a[1],g.centerPos=[g.centerPos[0]+a[0],g.centerPos[1]+a[1]];else if(yt(h))if(g.opt.rotate=h,g.scaleType=qs.getScaleType(g.opt),o){const S=Md(g.rect,h);g.rect=S}else{const S=Re.getRectFromLayer(y,r.name);g.rect=S||g.rect}return g&&i.setInfo(r.name,g),g==null?void 0:g.rect}}}function Oc(s){switch(s){case q.Arrow:return h0;case q.Pencil:return a0;case q.Straight:return y0;case q.Ellipse:return d0;case q.Polygon:case q.Triangle:return p0;case q.Star:case q.Rhombus:return g0;case q.Rectangle:return f0;case q.SpeechBalloon:return m0;case q.Text:return Qs;case q.LaserPen:return c0;case q.Eraser:return Na;case q.PencilEraser:return Ba;case q.BitMapEraser:return ja;case q.Selector:return za;case q.Image:return Zs;case q.BackgroundSVG:return qs}}async function Pp(s){const t=s.toolsType;if(t===void 0)return{status:"unrecoverable",reason:"missing-tools-type"};const e=Oc(t);return e?e.normalizeStorageData(s):{status:"unrecoverable",reason:`unsupported-tool:${t}`}}function Uye(s){const t=s.toolsType;if(t===void 0)return{status:"unrecoverable",reason:"missing-tools-type"};const e=Oc(t);return e?t===q.Text?Qs.normalizeStorageDataSync(s):[q.Pencil,q.Arrow,q.Straight,q.Ellipse,q.Rectangle,q.Polygon,q.Triangle,q.Star,q.Rhombus,q.SpeechBalloon].includes(t)?Re.normalizeDrawableStorageDataSync(s):e.normalizeStorageDataSync(s):{status:"unrecoverable",reason:`unsupported-tool:${t}`}}function pd(s,t){const{toolsType:e,...r}=s;switch(e){case q.Arrow:return new h0(r);case q.Pencil:return new a0(r);case q.Straight:return new y0(r);case q.Ellipse:return new d0(r);case q.Polygon:case q.Triangle:return new p0(r);case q.Star:case q.Rhombus:return new g0(r);case q.Rectangle:return new f0(r);case q.SpeechBalloon:return new m0(r);case q.Text:return new Qs(r);case q.LaserPen:return new c0(r);case q.Eraser:return new Na(r,t);case q.BitMapEraser:return new ja(r);case q.PencilEraser:return new Ba(r);case q.Selector:return r.vNodes?new za({...r,vNodes:r.vNodes,drawLayer:r.fullLayer}):void 0;case q.Image:return new Zs(r);case q.BackgroundSVG:return new qs({...r,toolsOpt:r.toolsOpt});default:return}}function b0(s){const t=[],e=["PATH","SPRITE","POLYLINE","RECT","ELLIPSE","LABEL","SPRITESVG"];for(const r of s){if(r.tagName==="GROUP"&&r.children.length){const n=b0(r.children);t.push(...n)}r.tagName&&e.includes(r.tagName)&&t.push(r)}return t}class Fu{constructor(t){x(this,"_map");x(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 E0{constructor(t,e){x(this,"viewId");x(this,"scene");x(this,"fullLayer");x(this,"curNodeMap");x(this,"targetNodeMap",[]);x(this,"highLevelIds");x(this,"canClearUids");x(this,"localUid");x(this,"spatialIndex",new wM);x(this,"spatialEntries",new Map);x(this,"verifySpatialIndex",!1);x(this,"revision",0);x(this,"revisionObservers",new Set);this.viewId=t,this.scene=e,this.curNodeMap=new Fu}init(t){this.fullLayer=t}get(t){return this.curNodeMap.get(t)}getRevision(){return this.revision}observeRevision(t){return this.revisionObservers.add(t),()=>this.revisionObservers.delete(t)}setLocalUid(t){this.localUid=t}getLocalUid(){return this.localUid}setSpatialIndexVerification(t){this.verifySpatialIndex=t}setCanClearUids(t){this.canClearUids=t,this.revision++,this.notifyRevisionObservers("permission")}getCanClearUids(){return this.canClearUids}getCanEraserNodes(t,e){const r=new Map;for(const[n,i]of t.entries())i.toolsType!==q.BackgroundSVG&&(i.toolsType===q.Image&&i.opt.type===on.Image&&(i.opt.locked||e&&e.disableEraseImage)||i.toolsType===q.Text&&(i.opt.workState===de.Doing||i.opt.workState===de.Start||e&&e.disableEraseText)||this.isCanClearWorkId(n)&&r.set(n,i));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 this.curNodeMap.size>0}has(t){return this.curNodeMap.has(t)}setInfo(t,e){const r=this.curNodeMap.has(t)?"update":"add",n=this.curNodeMap.get(t)||{name:t,rect:e.rect};e.rect&&(n.rect=ht(e.rect)),e.op&&F0e(e.op)&&(n.op=ht(e.op)),e.canRotate&&(n.canRotate=e.canRotate),e.scaleType&&(n.scaleType=e.scaleType),e.opt&&(n.opt=ht(e.opt)),e.toolsType&&(n.toolsType=e.toolsType),e.centerPos&&(n.centerPos=ht(e.centerPos)),_n(e.isSelected)&&(n.isSelected=e.isSelected),n.rect?(this.curNodeMap.set(t,n),this.updateSpatialEntry(t,n.rect),this.revision++,this.notifyRevisionObservers(r,t)):this.delete(t)}selected(t){this.setInfo(t,{isSelected:!0})}unSelected(t){this.setInfo(t,{isSelected:!1})}delete(t){const e=this.curNodeMap.delete(t),r=this.spatialEntries.get(t);r&&(this.spatialIndex.remove(r),this.spatialEntries.delete(t)),e&&(this.revision++,this.notifyRevisionObservers("delete",t))}clear(){const t=this.curNodeMap.size>0;this.curNodeMap.clear(),this.spatialIndex.clear(),this.spatialEntries.clear(),this.targetNodeMap.length=0,t&&(this.revision++,this.notifyRevisionObservers("clear"))}notifyRevisionObservers(t,e){for(const r of this.revisionObservers)r(t,this.revision,e)}getRectIntersectRange(t,e=!0,r=!0){const n=this.spatialIndex.search(this.toSpatialBox(t)).map(c=>c.key);let i=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`),i=c)}let o;const a=new Map;for(const c of i){const l=this.curNodeMap.get(c);!l||!Ua(t,l.rect)||e&&(l.toolsType===q.Image&&l.opt.locked||l.toolsType===q.BackgroundSVG&&l.opt.locked!==!1)||r&&l.toolsType===q.Text&&(l.opt.workState===de.Doing||l.opt.workState===de.Start)||(o=Ue(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())Ua(t,n.rect)&&e.push(r);return e}setTargetAssignKeys(t){const e=new Fu;for(const r of t){const n=this.curNodeMap.get(r);n&&e.set(r,ht(n))}return this.targetNodeMap.push(ht(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(Bt).length===1}isCanClearWorkId(t){if(this.canClearUids===void 0||this.canClearUids===!0)return!0;if(lge(this.canClearUids)){const e=t.split(Bt);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 x0=(s,t,e,r)=>{const n=new URL(s);return n.searchParams.set("width",t.toString()),n.searchParams.set("height",e.toString()),r&&n.searchParams.set("color",r),n.toString()},Wye=async(s,t)=>{const{src:e,isgl:r,isCache:n,useImageBitmap:i=!0}=s;if(typeof Image=="function"){const o=new Image;return typeof e=="string"&&(o.crossOrigin="anonymous"),new Promise(a=>{o.onload=async function(){if(!i){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))};function R0(s,t,e){if(t&&typeof t=="object"&&typeof t.code=="string"&&typeof t.business=="string"&&typeof t.message=="string")return t;if(!(s!=="failed"&&s!=="timeout"))return{code:s==="timeout"?"RENDERER_BUSINESS_TIMEOUT":"RENDERER_BUSINESS_ERROR",business:"updateCamera",message:`Camera task returned ${s} ACK without cameraTaskError`,stage:"camera-ack",workerType:e}}class k0 extends Error{constructor(e,r){super(`updateCamera timed out after ${r}ms`);x(this,"code","RENDERER_BUSINESS_TIMEOUT");x(this,"business","updateCamera");x(this,"cameraTaskId");x(this,"elapsedMs");x(this,"stage");x(this,"blockingWorks");this.name="CameraUpdateTimeoutError",this.cameraTaskId=e.cameraTaskId,this.elapsedMs=r,this.stage=e.stage,this.blockingWorks=e.blockingWorks?[...e.blockingWorks]:void 0}}class Vye extends Error{constructor(e){super("updateCamera aborted because the owning renderer was destroyed");x(this,"code","RENDERER_BUSINESS_ABORTED");x(this,"business","updateCamera");x(this,"cameraTaskId");x(this,"stage");x(this,"blockingWorks");this.name="CameraUpdateAbortedError",this.cameraTaskId=e.cameraTaskId,this.stage=e.stage,this.blockingWorks=e.blockingWorks?[...e.blockingWorks]:void 0}}async function A0(s,t,e=dm){const r=Date.now();let n,i;const o=new Promise(g=>{n=g}),a={cameraTaskId:s,startedAt:r,deadlineAt:r+e,abortPromise:o,aborted:!1,stage:"update-camera"},c=()=>{a.aborted||(a.aborted=!0,n==null||n(),i==null||i(l||new Vye(a)))};a.abort=c;let l,u;const h=Promise.resolve().then(()=>t(a));h.catch(()=>{});const d=new Promise((g,y)=>{u=setTimeout(()=>{l=new k0(a,e),c(),y(l)},e)}),f=new Promise((g,y)=>{i=y});try{await Promise.race([h,d,f])}catch(g){throw c(),l||g}finally{u!==void 0&&clearTimeout(u)}}async function P0(s,t,e){return s.stage=e,await Promise.race([t,s.abortPromise]),!s.aborted}function $ye(s){return s instanceof k0||s instanceof Error&&s.code==="RENDERER_BUSINESS_TIMEOUT"}function yr(s){if(s instanceof Error||s&&typeof s=="object"&&"message"in s&&typeof s.message=="string")return s.message;if(typeof s=="string")return s;try{const t=JSON.stringify(s);if(t!==void 0)return t}catch{}return String(s)}class D0 extends Error{constructor(e){const r=e.timeoutMs??qa;super(`${e.business} timed out at ${e.stage} after ${r}ms`);x(this,"code","RENDERER_BUSINESS_TIMEOUT");x(this,"business");x(this,"stage");x(this,"elapsedMs");x(this,"reported",!1);this.name="RendererBusinessTimeoutError",this.business=e.business,this.stage=e.stage,this.elapsedMs=r}}class md extends Error{constructor(e,r){super(yr(e));x(this,"code","RENDERER_BUSINESS_ERROR");x(this,"business");x(this,"stage");x(this,"cause");x(this,"reported",!1);this.name="RendererBusinessError",this.business=r.business,this.stage=r.stage,this.cause=e}}async function Uu(s,t){const e=t.timeoutMs??qa;let r;const n=new Promise((i,o)=>{r=setTimeout(()=>{o(new D0({...t,timeoutMs:e}))},e)});try{return await Promise.race([Promise.resolve(s),n])}finally{r!==void 0&&clearTimeout(r)}}function L0(s){return s instanceof D0||s instanceof Error&&s.code==="RENDERER_BUSINESS_TIMEOUT"}function Fa(s){return L0(s)||s instanceof md||s instanceof Error&&s.code==="RENDERER_BUSINESS_ERROR"}function Wu(s,t){return Fa(s)?s:new md(s,t)}function N0(s,t,e){const r=L0(s),n=Fa(s),i=n?s.business:t.business,o=n?s.stage:t.stage,a=r?s.elapsedMs:0,c=yr(s);return`[rendererBusiness] ${r?"timeout":"failed"} viewId=${e.viewId} renderer=${e.renderer} business=${i} stage=${o} elapsedMs=${a} error=${c}`}class O0{constructor(){x(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 Yye=30,yd=1e3/Yye;function z0(s){return Math.min(Math.max(0,s),yd)}const Yl=()=>typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now();class Gye{constructor(t=1e3/30){x(this,"timer");x(this,"pending");x(this,"resolvePending");x(this,"activeWorkId");x(this,"generation",0);x(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-Yl());return r===0?(this.lastReleaseTime=Yl(),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=Yl(),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()}}function Hye(s,t){return s?t||"webgl2":"2d"}function Qye(s){var r;if(!s)return{};const t={};try{t.contextLost=((r=s.isContextLost)==null?void 0:r.call(s))||!1}catch{}let e;try{e=s.getParameter(s.CURRENT_PROGRAM),t.currentProgram=!!e}catch{}if(e){try{t.programLinked=!!s.getProgramParameter(e,s.LINK_STATUS)}catch{}try{t.programHasUniforms=!!e.uniforms}catch{}}try{const n=s.getError();n!==s.NO_ERROR&&(t.glError=n)}catch{}return t}function qye(s){var t,e;if(s)return s.gl||(t=s.renderer)!=null&&t.glRenderer?(e=s.renderer)!=null&&e.isWebGL2?"webgl2":"webgl":"2d"}function Zye(s,t){const e=s==null?void 0:s.canvas;if(!(s!=null&&s.gl)||!(e!=null&&e.addEventListener))return()=>{};let r=!0;const n=i=>{var o;r&&(r=!1,(o=i.preventDefault)==null||o.call(i),t(Qye(s.gl),i))};return e.addEventListener("webglcontextlost",n),e.addEventListener("contextlost",n),()=>{r=!1,e.removeEventListener("webglcontextlost",n),e.removeEventListener("contextlost",n)}}async function B0(s,t){await(s==null?void 0:s.flush()),await Promise.all(t.map(e=>e.prepareRender))}class Kye{constructor(t){x(this,"scheduledHandle");x(this,"activeTask");x(this,"flushTask");x(this,"pending",!1);x(this,"destroyed",!1);x(this,"failure");this.options=t}request(t=!1){if(!this.destroyed){if(this.pending=!0,t){this.cancelScheduledTask(),!this.activeTask&&!this.flushTask&&this.startTask();return}!this.activeTask&&!this.flushTask&&this.scheduleTask()}}flush(){if(this.destroyed)return Promise.reject(new Error("Cannot flush a destroyed service render scheduler"));if(!this.flushTask){const t=this.flushPending();this.flushTask=t;const e=()=>{this.flushTask===t&&(this.flushTask=void 0,this.pending&&!this.destroyed&&this.failure===void 0&&this.scheduleTask())};t.then(e,e)}return this.flushTask}destroy(){this.destroyed||(this.destroyed=!0,this.pending=!1,this.failure=void 0,this.cancelScheduledTask())}scheduleTask(){this.destroyed||this.scheduledHandle!==void 0||this.activeTask||this.flushTask||!this.pending||(this.scheduledHandle=this.options.schedule(()=>{this.scheduledHandle=void 0,this.startTask()}))}cancelScheduledTask(){this.scheduledHandle!==void 0&&(this.options.cancel(this.scheduledHandle),this.scheduledHandle=void 0)}startTask(){if(this.destroyed||this.activeTask||!this.pending)return this.activeTask;this.pending=!1;const t=Promise.resolve().then(()=>this.options.run()).catch(e=>{var r,n;if(!this.destroyed){this.failure===void 0&&(this.failure=e);try{(n=(r=this.options).onError)==null||n.call(r,e)}catch{}}}).then(()=>{this.activeTask===t&&(this.activeTask=void 0,this.pending&&!this.destroyed&&!this.flushTask&&this.failure===void 0&&this.scheduleTask())});return this.activeTask=t,t}async flushPending(){for(this.cancelScheduledTask();!this.destroyed;){if(this.activeTask&&await this.activeTask,this.failure!==void 0)throw this.failure;if(!this.pending)return;const t=this.startTask();t&&await t}}}class Xye{constructor(t,e,r){x(this,"viewId");x(this,"viewGeneration");x(this,"type");x(this,"scene");x(this,"fullLayer");x(this,"vNodes");x(this,"dpr");x(this,"contextType");x(this,"opt");x(this,"cameraOpt");x(this,"isSafari",!1);x(this,"combinePostMsg",new Set);x(this,"workerTaskId");x(this,"protectedTask");x(this,"delayPostDoneWaiter");x(this,"activePostDoneWaiter");x(this,"isCombiningPost",!1);x(this,"combinePostTaskSequence",0);x(this,"activeCombinePostTaskId");x(this,"combinePostTransfersByTask",new Map);x(this,"cacheImages",new Map);x(this,"imageResolveMap",new Map);x(this,"taskUpdateCameraId");x(this,"taskUpdateCameraResolve");x(this,"debounceUpdateCameraId");x(this,"activeCameraSettledRender");x(this,"activeCameraTaskContext");x(this,"destroyed",!1);x(this,"contextLossCleanup");var n,i;if(this.viewId=t,this.viewGeneration=e.viewGeneration,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",(i=this.scene)==null||i.disconnect(),this.scene=this.createScene(e),this.createRenderLayer(this.scene,e);else throw o}this.registerContextLossListener(),this.vNodes=new E0(t,this.scene)}getActualContextType(){var t;return qye((t=this.fullLayer)==null?void 0:t.parent)}registerContextLossListener(){var e;const t=(e=this.fullLayer)==null?void 0:e.parent;this.contextLossCleanup=Zye(t,r=>{if(this.destroyed)return;const n=this.getActualContextType(),i=`[WorkThreadEngine] WebGL context lost; viewId=${this.viewId}; generation=${this.viewGeneration??"unknown"}; context=${n||"unknown"}`;try{this._post({sp:[{type:le.ReportError,viewId:this.viewId,viewGeneration:this.viewGeneration,reportString:i,reportError:"WebGL context lost",reportErrorCode:"RENDERER_RUNTIME_ERROR",reportStage:"context-lost",reportContextType:n,reportContextLost:!0,reportGlError:r.glError,reportCurrentProgram:r.currentProgram,reportProgramLinked:r.programLinked,reportProgramHasUniforms:r.programHasUniforms}]})}catch(o){console.error(i,o)}})}removeContextLossListener(){var t;(t=this.contextLossCleanup)==null||t.call(this),this.contextLossCleanup=void 0}createRenderLayer(t,e){const r=He.bufferSize.full,n=He.bufferSize.sub;this.fullLayer=this.createLayer("fullLayer",t,{...e.layerOpt,bufferSize:this.viewId===Fe?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&&(this.closeImageBitmap(n.imageBitmap),this.cacheImages.delete(r))}clearCacheImages(){this.cacheImages.forEach(t=>this.closeImageBitmap(t.imageBitmap)),this.cacheImages.clear()}closeImageBitmap(t){if(t)try{t.close()}catch{}}clearImageResolveMap(){this.imageResolveMap.forEach(({timer:t,resolve:e},r)=>{t&&clearTimeout(t),e==null||e(r)}),this.imageResolveMap.clear()}setIsSafari(t){this.isSafari=t}async on(t){var u,h,d,f;if(this.destroyed){try{(u=t.imageBitmap)==null||u.close()}catch{}return}const{msgType:e,toolsType:r,opt:n,imageSrc:i,imageBitmap:o,workId:a,dpr:c,requestId:l}=t;switch(e){case le.UpdateDpr:{yt(c)&&await this.updateDpr(c);break}case le.UpdateCamera:{try{await A0(t.cameraTaskId,async g=>{this.activeCameraTaskContext=g;try{await this.updateCamera(t,g)}finally{this.activeCameraTaskContext===g&&(this.activeCameraTaskContext=void 0)}})}catch(g){throw this.cameraOpt=void 0,this.cancelCameraSettledRender(),g}break}case le.Destroy:{this.destroy();break}case le.CancelBitmapEraser:{const g=(h=t.workId)==null?void 0:h.toString();g&&"abortBitmapEraser"in this.localWork&&this.localWork.abortBitmapEraser(g);break}case le.Clear:{await this.clearAll();break}case le.ServiceSyncCommit:{const g=this,y=[(d=this.fullLayer)==null?void 0:d.parent,(f=g.topLayer)==null?void 0:f.parent].filter(Boolean);try{await Uu((async()=>{await B0(this.serviceWork,y)})(),{business:"service-sync-commit",stage:"flush-and-prepare-render",timeoutMs:5e3})}catch(S){const b=Wu(S,{business:"service-sync-commit",stage:"flush-and-prepare-render"});throw this.reportRendererBusinessError(b,{business:"service-sync-commit",stage:"flush-and-prepare-render"}),b}if(this.destroyed)break;await this.post({sp:[{type:le.ServiceSyncCommit,viewId:this.viewId,viewGeneration:this.viewGeneration,scenePath:t.scenePath,serviceSyncId:t.serviceSyncId,serviceRevision:t.serviceRevision}]});break}case le.UpdateTools:{if(r&&n){const g={toolsType:r,toolsOpt:n,combineUnitTime:t.combineUnitTime,maxCombineEraserTime:t.maxCombineEraserTime};this.localWork.setToolsOpt(g)}break}case le.GetImageBitMap:{if(i&&o&&a){const g=a.toString(),y=this.imageResolveMap.get(i);if(!y||y.requestId!==l){this.closeImageBitmap(o);break}this.cacheImages.set(i,{imageBitmap:o,workId:g});const{resolve:S,timer:b}=y;b&&clearTimeout(b),S&&S(i),this.deleteCachedImagesByWorkId(g,i)}break}}}getIconSize(t,e,r){const n=t*r,i=e*r;return n<=50||i<=50?[50,50]:n<=100||i<=100?[100,100]:n<=200||i<=200?[200,200]:n<=400||i<=400?[400,400]:n<=800||i<=800?[800,800]:[1600,1600]}async loadImageBitMap(t){const{toolsType:e,opt:r,workId:n,isSubWorker:i,requestId:o}=t;if(e===q.Image&&r&&n){const a=n.toString(),{src:c,type:l,width:u,height:h,strokeColor:d}=r;if(!c||!l||!u||!h)return;let f=c;if(l===on.Iconify){const[N,T]=this.getIconSize(u,h,this.dpr);f=x0(c,N,T,d)}if(this.cacheImages.has(f)){const N=this.getCachedImages(f);if(N)return N}const y=this.imageResolveMap.get(f);if(y)return await y.promise,this.getCachedImages(f);let S;const b=new Promise(N=>{S=N}),I={resolve:S,timer:void 0,requestId:o,promise:b};return I.timer=setTimeout(()=>{this.imageResolveMap.get(f)===I&&S(f)},5e3),this.imageResolveMap.set(f,I),this._post({sp:[{imageSrc:f,workId:a,viewId:this.viewId,isgl:!!this.fullLayer.parent.gl,isSubWorker:i,requestId:o,type:le.GetImageBitMap}]}),await b,this.imageResolveMap.get(f)===I&&this.imageResolveMap.delete(f),this.getCachedImages(f)}}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:i}=e;t.container.width=n,t.container.height=i,t.width=n,t.height=i,this.updateLayer({width:n,height:i},r)}updateLayer(t,e){const{width:r,height:n}=t,i=e||this.fullLayer;i&&(i.parent.setAttribute("width",r),i.parent.setAttribute("height",n),i.setAttribute("size",[r,n]),i.setAttribute("pos",[r*.5,n*.5]))}getSupportContextType(t,e){return Hye(t===Vu.Full&&this.viewId===Fe,e)}createScene(t){const{offscreenCanvasOpt:e}=t,{width:r,height:n}=e,i=new OffscreenCanvas(r,n);e.contextType&&delete e.contextType;const o=new Sc({container:i,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 i=`offscreen-${t}`,{width:o,height:a}=r;n&&(r.offscreen=!0,r.canvas=n);const c=e.layer(i,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;this.fullLayer&&(this.fullLayer.parent.children.forEach(e=>{e.name!=="viewport"&&e.remove()}),ur(this.fullLayer,this.fullLayer.parent)),this.cancelCameraBlockingWait(),this.cancelCameraSettledRender(),this.clearCacheImages(),this.clearImageResolveMap(),this.localWork.destroy(),(t=this.serviceWork)==null||t.clearAll()}setToolsOpt(t){this.localWork.setToolsOpt(t)}setWorkOpt(t){const{workId:e,toolsOpt:r}=t;e&&r&&this.localWork.setWorkOptions(e.toString(),r)}destroy(){var r,n;if(this.destroyed)return;this.destroyed=!0,(n=(r=this.activeCameraTaskContext)==null?void 0:r.abort)==null||n.call(r),this.activeCameraTaskContext=void 0;const t=[],e=(i,o)=>{try{o()}catch(a){t.push(`${i}: ${a instanceof Error?a.message:String(a)}`)}};e("context-loss-listener",()=>this.removeContextLossListener()),e("camera-blocking-wait",()=>this.cancelCameraBlockingWait()),e("camera-render",()=>this.cancelCameraSettledRender()),e("worker-task",()=>{this.workerTaskId!==void 0&&(clearTimeout(this.workerTaskId),this.workerTaskId=void 0)}),e("post-waiters",()=>{var i,o;(i=this.delayPostDoneWaiter)==null||i.resolve(),(o=this.activePostDoneWaiter)==null||o.resolve(),this.delayPostDoneWaiter=void 0,this.activePostDoneWaiter=void 0}),e("post-transfers",()=>{this.activeCombinePostTaskId=void 0,this.combinePostTaskSequence++;for(const i of[...this.combinePostTransfersByTask.keys()])this.releaseCombinePostTransfers(i);this.combinePostMsg.clear()}),e("v-nodes",()=>this.vNodes.clear()),e("full-layer",()=>{const i=this.fullLayer.parent;i&&hr(this.fullLayer,i),this.fullLayer.remove()}),e("image-cache",()=>this.clearCacheImages()),e("image-waiters",()=>this.clearImageResolveMap()),e("scene",()=>this.scene.remove()),e("local-work",()=>this.localWork.destroy()),e("service-work",()=>{var i;return(i=this.serviceWork)==null?void 0:i.destroy()}),t.length&&console.error(`[WorkThreadEngine]: destroy completed with cleanup errors viewId=${this.viewId}: ${t.join("; ")}`)}cancelCameraSettledRender(){var e;this.debounceUpdateCameraId!==void 0&&(clearTimeout(this.debounceUpdateCameraId),this.debounceUpdateCameraId=void 0);const t=this.activeCameraSettledRender;t&&(t.cancelled=!0,(e=t.renderLayers)==null||e.forEach(r=>r.cancelPendingRender()),this.activeCameraSettledRender=void 0)}retargetCameraSettledRender(t){var r;if(!yt(t))return!1;const e=this.activeCameraSettledRender;return!e||e.cancelled||(r=e.context)!=null&&r.aborted?!1:(e.cameraTaskId=t,!0)}hasCameraSettledRender(){return!!this.activeCameraSettledRender}cancelCameraBlockingWait(){this.taskUpdateCameraId!==void 0&&(clearTimeout(this.taskUpdateCameraId),this.taskUpdateCameraId=void 0);const t=this.taskUpdateCameraResolve;this.taskUpdateCameraResolve=void 0,t==null||t(!1)}startCameraSettledRender(t,e){const r={cancelled:!1,cameraTaskId:t,context:e};return this.activeCameraSettledRender=r,{isActive:()=>!this.destroyed&&!r.cancelled&&this.activeCameraSettledRender===r&&!(e!=null&&e.aborted),getCameraTaskId:()=>r.cameraTaskId,setRenderLayers:n=>{r.renderLayers=n},finish:()=>{r.renderLayers=void 0,this.activeCameraSettledRender===r&&(this.activeCameraSettledRender=void 0)}}}post(t,e={}){var n;if(this.destroyed)return(n=t.render)==null||n.forEach(i=>this.closeImageBitmap(i.imageBitmap)),Promise.resolve();this.combinePostMsg.add(t);const r=this.type===Vu.Full?this.getOrCreatePostDoneWaiter(e.reportFailureAtRendererBoundary!==!1):void 0;return this.runBatchPostData(),r?(r.promise.catch(()=>{}),r.promise):Promise.resolve()}getOrCreatePostDoneWaiter(t){if(this.delayPostDoneWaiter)t||(this.delayPostDoneWaiter.reportFailureAtRendererBoundary=!1);else{let e,r;const n=new Promise((i,o)=>{e=i,r=o});this.delayPostDoneWaiter={promise:n,resolve:e,reject:r,reportFailureAtRendererBoundary:t}}return this.delayPostDoneWaiter}runBatchPostData(){this.destroyed||!this.workerTaskId&&!this.isCombiningPost&&(this.workerTaskId=setTimeout(()=>{this.workerTaskId=void 0;const t=this.delayPostDoneWaiter;this.delayPostDoneWaiter=void 0,this.activePostDoneWaiter=t,this.isCombiningPost=!0;const e=++this.combinePostTaskSequence;this.activeCombinePostTaskId=e,this.combinePostTransfersByTask.set(e,new Set),(async()=>{let r=!1,n;try{await this.waitForRendererBusiness(this.combinePost(e),{business:"combine-post",stage:"flush"})}catch(i){r=!0;const o=Wu(i,{business:"combine-post",stage:"flush"});n=o,(t==null?void 0:t.reportFailureAtRendererBoundary)!==!1&&this.reportRendererBusinessError(o,{business:"combine-post",stage:"flush"})}finally{this.releaseCombinePostTransfers(e),this.activePostDoneWaiter===t&&(this.activePostDoneWaiter=void 0),this.activeCombinePostTaskId===e&&(this.activeCombinePostTaskId=void 0),this.isCombiningPost=!1,this.combinePostMsg.size&&this.runBatchPostData()}r?t==null||t.reject(n):t==null||t.resolve()})()},16))}waitForRendererBusiness(t,e){return Uu(t,e)}reportRendererBusinessError(t,e,r=!1){if(Fa(t)&&t.reported)return;const n=N0(t,e,{viewId:this.viewId,renderer:this.type});Fa(t)&&(t.reported=!0);try{this._post({sp:[{type:le.ReportError,viewId:this.viewId,viewGeneration:this.viewGeneration,reportString:n,reportErrorCode:r?"RENDERER_RUNTIME_ERROR":void 0,reportStage:e.stage,reportError:t instanceof Error?t.message:String(t)}]})}catch(i){console.error(n,i)}}isCombinePostTaskActive(t){return this.activeCombinePostTaskId===t}trackCombinePostTransfer(t,e){const r=this.combinePostTransfersByTask.get(t);return!r||!this.isCombinePostTaskActive(t)?(this.closeCombinePostTransfers([e]),!1):(r.add(e),!0)}commitCombinePostTransfers(t){this.combinePostTransfersByTask.delete(t)}releaseCombinePostTransfers(t){const e=this.combinePostTransfersByTask.get(t);e&&(this.combinePostTransfersByTask.delete(t),this.closeCombinePostTransfers([...e]))}closeCombinePostTransfers(t){for(const e of t||[]){const r=e.close;if(typeof r=="function")try{r.call(e)}catch{}}}transferLayerToImageBitmap(t){const e=this.getLayer(t),r=e==null?void 0:e.parent;if(!(r instanceof Jn))throw new Error(`render Layer is unavailable: ${String(t)}`);return r.transferToImageBitmap()}combinePostData(){var l,u;const t=this.combinePostMsg;this.combinePostMsg=new Set;const e=[],r=[];let n,i,o,a;const c=new Set;for(const h of t.values()){if((l=h.render)!=null&&l.length)for(const d of h.render){let f=!1;if(d.workId&&c.add(d.workId),d.viewId||(d.viewId=this.viewId),d.viewGeneration===void 0&&(d.viewGeneration=this.viewGeneration),d.isClearAll&&(d.rect=this.getSceneRect(),d.isClear=!0,delete d.isClearAll),d.drawCanvas){const g=this.getLayer(d.drawCanvas);if(!g||!(g.parent instanceof Jn))continue;if(g.parent.render(),d.isDrawAll){const y=this.getSceneRect();d.rect=y,delete d.isDrawAll}}for(const g of e)if(d.viewId===g.viewId&&d.eraseTxnId===g.eraseTxnId){d.isClear&&g.clearCanvas&&g.isClear&&g.clearCanvas===d.clearCanvas&&(g.rect=Ue(g.rect,d.rect),f=!0),g.drawCanvas&&g.drawCanvas===d.drawCanvas&&(g.rect=Ue(g.rect,d.rect),f=!0);continue}f||(d.isClear&&!d.drawCanvas?e.unshift(d):e.push(d))}if((u=h.sp)!=null&&u.length)for(const d of h.sp){const f={...d,viewId:d.viewId||this.viewId,viewGeneration:d.viewGeneration??this.viewGeneration};let g=!1;for(const y of r)if(nn(f,y)){g=!0;break}g||r.push(f)}yt(h.fullWorkerDrawCount)&&(n=h.fullWorkerDrawCount),yt(h.subWorkerDrawCount)&&(i=h.subWorkerDrawCount),yt(h.consumeCount)&&(o=h.consumeCount,a=h.consumeWorkId)}return{render:e,sp:r,fullWorkerDrawCount:n,subWorkerDrawCount:i,consumeCount:o,consumeWorkId:a,workIds:c,viewId:this.viewId,viewGeneration:this.viewGeneration}}getSceneRect(){const{width:t,height:e}=this.scene;return{x:0,y:0,w:Math.floor(t),h:Math.floor(e)}}}class j0{constructor(t){x(this,"viewId");x(this,"vNodes");x(this,"thread");x(this,"fullLayer");x(this,"drawLayer");x(this,"_post");x(this,"tmpOpt");x(this,"workShapes",new Map);x(this,"drawCount",0);x(this,"consumeCount",0);x(this,"syncUnitTime",He.syncOpt.interval);x(this,"combineUnitTime",He.bezier.combineUnitTime);x(this,"maxCombineEraserTime",yd);x(this,"eraserBatchScheduler",new O0);x(this,"drawAckBackpressure",new Gye);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 z0(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.forEach(t=>t.clearTmpPoints()),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 pd({...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();for(const[t,e]of this.workShapes)t!==Le&&(e.clearTmpPoints(),this.workShapes.delete(t))}setFullWork(t){const{workId:e,opt:r,toolsType:n}=t;if(e&&r&&n){const i=e.toString();let o;return e&&this.workShapes.has(i)?(o=this.workShapes.get(i),(o==null?void 0:o.toolsType)!==n?(o==null||o.clearTmpPoints(),this.workShapes.delete(i),o=void 0):o==null||o.setWorkOptions(r)):o=this.createWorkShapeNode({toolsOpt:r,toolsType:n,workId:i}),o||(o=this.createWorkShapeNode({toolsOpt:r,toolsType:n,workId:i})),o?(this.workShapes.set(i,o),o):void 0}}}function Jye(s){return s}var F0=Jye;function _ye(s,t,e){switch(e.length){case 0:return s.call(t);case 1:return s.call(t,e[0]);case 2:return s.call(t,e[0],e[1]);case 3:return s.call(t,e[0],e[1],e[2])}return s.apply(t,e)}var eve=_ye,tve=eve,Dp=Math.max;function rve(s,t,e){return t=Dp(t===void 0?s.length-1:t,0),function(){for(var r=arguments,n=-1,i=Dp(r.length-t,0),o=Array(i);++n<i;)o[n]=r[t+n];n=-1;for(var a=Array(t+1);++n<t;)a[n]=r[n];return a[t]=e(o),tve(s,this,a)}}var nve=rve;function ive(s){return function(){return s}}var sve=ive,ove=sve,Lp=kv,ave=F0,cve=Lp?function(s,t){return Lp(s,"toString",{configurable:!0,enumerable:!1,value:ove(t),writable:!0})}:ave,lve=cve,uve=800,hve=16,dve=Date.now;function fve(s){var t=0,e=0;return function(){var r=dve(),n=hve-(r-e);if(e=r,n>0){if(++t>=uve)return arguments[0]}else t=0;return s.apply(void 0,arguments)}}var gve=fve,pve=lve,mve=gve,yve=mve(pve),vve=yve,Mve=F0,wve=nve,Sve=vve;function Tve(s,t){return Sve(wve(s,t,Mve),s+"")}var Ive=Tve;function Cve(s,t,e,r){for(var n=s.length,i=e+(r?1:-1);r?i--:++i<n;)if(t(s[i],i,s))return i;return-1}var bve=Cve;function Eve(s){return s!==s}var xve=Eve;function Rve(s,t,e){for(var r=e-1,n=s.length;++r<n;)if(s[r]===t)return r;return-1}var kve=Rve,Ave=bve,Pve=xve,Dve=kve;function Lve(s,t,e){return t===t?Dve(s,t,e):Ave(s,Pve,e)}var Nve=Lve,Ove=Nve;function zve(s,t){var e=s==null?0:s.length;return!!e&&Ove(s,t,0)>-1}var U0=zve;function Bve(s,t,e){for(var r=-1,n=s==null?0:s.length;++r<n;)if(e(t,s[r]))return!0;return!1}var W0=Bve;function jve(s,t){for(var e=-1,r=s==null?0:s.length,n=Array(r);++e<r;)n[e]=t(s[e],e,s);return n}var Fve=jve,Uve=dd,Wve=U0,Vve=W0,$ve=Fve,Yve=kc,Gve=fd,Hve=200;function Qve(s,t,e,r){var n=-1,i=Wve,o=!0,a=s.length,c=[],l=t.length;if(!a)return c;e&&(t=$ve(t,Yve(e))),r?(i=Vve,o=!1):t.length>=Hve&&(i=Gve,o=!1,t=new Uve(t));e:for(;++n<a;){var u=s[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 i(t,h,r)||c.push(u)}return c}var qve=Qve,Np=fo,Zve=Lv,Kve=go,Op=Np?Np.isConcatSpreadable:void 0;function Xve(s){return Kve(s)||Zve(s)||!!(Op&&s&&s[Op])}var Jve=Xve,_ve=id,e0e=Jve;function V0(s,t,e,r,n){var i=-1,o=s.length;for(e||(e=e0e),n||(n=[]);++i<o;){var a=s[i];t>0&&e(a)?t>1?V0(a,t-1,e,r,n):_ve(n,a):r||(n[n.length]=a)}return n}var t0e=V0;function r0e(){}var n0e=r0e,Gl=Yv,i0e=n0e,s0e=gd,o0e=1/0,a0e=Gl&&1/s0e(new Gl([,-0]))[1]==o0e?function(s){return new Gl(s)}:i0e,c0e=a0e,l0e=dd,u0e=U0,h0e=W0,d0e=fd,f0e=c0e,g0e=gd,p0e=200;function m0e(s,t,e){var r=-1,n=u0e,i=s.length,o=!0,a=[],c=a;if(e)o=!1,n=h0e;else if(i>=p0e){var l=t?null:f0e(s);if(l)return g0e(l);o=!1,n=d0e,c=new l0e}else c=t?[]:a;e:for(;++r<i;){var u=s[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 y0e=m0e,v0e=qve,M0e=t0e,zp=y0e;function w0e(s,t,e){var r=s.length;if(r<2)return r?zp(s[0]):[];for(var n=-1,i=Array(r);++n<r;)for(var o=s[n],a=-1;++a<r;)a!=n&&(i[n]=v0e(i[n]||o,s[a],t,e));return zp(M0e(i,1),t,e)}var S0e=w0e,T0e=ed,I0e=zr;function C0e(s){return I0e(s)&&T0e(s)}var b0e=C0e,E0e=jv,x0e=Ive,R0e=S0e,k0e=b0e;x0e(function(s){return R0e(E0e(s,k0e))});class A0e extends j0{constructor(e){super(e);x(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);ur(this.fullLayer,this.fullLayer.parent)}async consumeDraw(e){const{workId:r,fullWorkerDrawCount:n,postCount:i}=e,o=r==null?void 0:r.toString(),a=o&&this.workShapes.get(o);if(!a){o&&yt(i)&&await this.drawAckBackpressure.wait(o)&&await this._post({consumeCount:i,consumeWorkId:o});return}this.drawWorkActiveId&&this.drawWorkActiveId!==o&&(await this.consumeDrawAll({workId:this.drawWorkActiveId,viewId:this.viewId,msgType:le.DrawWork,dataType:xe.Local}),this.drawWorkActiveId=void 0),!this.drawWorkActiveId&&o!==Le&&(this.drawWorkActiveId=o);const c=a.toolsType;yt(i)&&(this.consumeCount=i);const l=a.consume({data:e,drawCount:this.drawCount,isFullWork:!0,isSubWorker:!0,removeDrawCount:n});switch(c){case q.Selector:l&&(this.drawCount++,await this.drawSelector(l));break;case q.Ellipse:case q.Arrow:case q.Straight:case q.Rectangle:case q.Star:case q.Polygon:case q.SpeechBalloon:{l&&(this.drawCount++,await this.drawShape(l));break}case q.Pencil:{l&&(this.drawCount++,await this.drawPencil(l,r==null?void 0:r.toString()));break}case q.PencilEraser:{l&&(this.drawCount++,await this.drawAckBackpressure.wait(o)&&await this._post({subWorkerDrawCount:this.drawCount,consumeCount:this.consumeCount,consumeWorkId:o}));break}case q.BitMapEraser:l&&this.drawCount++;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 i=this.workShapes.get(n);if(!i)return;switch(i.toolsType){case q.Selector:this.drawCount=0,ur(this.fullLayer,this.fullLayer.parent),this.clearWorkShapeNodeCache(n),this._post({render:[{isClearAll:!0,clearCanvas:_e.Float,viewId:this.viewId}]});break;case q.Arrow:case q.Straight:case q.Ellipse:case q.Pencil:case q.Rectangle:case q.Star:case q.Polygon:case q.SpeechBalloon:case q.BitMapEraser:case q.PencilEraser:this.drawCount=0,ur(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 i=this.removeNode(n);if(i){const o=[];o.push({rect:wn(i),clearCanvas:_e.Float,isClear:!0,viewId:this.viewId},{rect:wn(i),drawCanvas:_e.Float,viewId:this.viewId}),await this._post({render:o})}}}removeNode(e){const r=this.workShapes.has(e);let n;return r&&(this.fullLayer.getElementsByName(e).forEach(i=>{const o=i.getBoundingClientRect();n=Ue(n,{x:o.x-Re.SafeBorderPadding,y:o.y-Re.SafeBorderPadding,w:o.width+Re.SafeBorderPadding*2,h:o.height+Re.SafeBorderPadding*2}),i.remove(),hr(i,this.fullLayer.parent)}),n&&this.clearWorkShapeNodeCache(e)),n}async drawPencil(e,r){!r||!await this.drawAckBackpressure.wait(r)||await this._post({subWorkerDrawCount:this.drawCount,consumeCount:this.consumeCount,consumeWorkId:r,render:[{rect:e==null?void 0:e.rect,workId:r,drawCanvas:_e.Float,viewId:this.viewId}],sp:(e==null?void 0:e.op)&&[e]})}async drawShape(e){await this._post({subWorkerDrawCount:this.drawCount,consumeCount:this.consumeCount,render:[{rect:(e==null?void 0:e.rect)&&wn(e.rect),isClear:!0,clearCanvas:_e.Float,viewId:this.viewId},{rect:(e==null?void 0:e.rect)&&wn(e.rect),drawCanvas:_e.Float,viewId:this.viewId}]})}async drawSelector(e){await this._post({subWorkerDrawCount:this.drawCount,consumeCount:this.consumeCount,render:[{rect:(e==null?void 0:e.rect)&&wn(e.rect),isClear:!0,clearCanvas:_e.Float,viewId:this.viewId},{rect:(e==null?void 0:e.rect)&&wn(e.rect),drawCanvas:_e.Float,viewId:this.viewId}]})}}class P0e{constructor(t){x(this,"viewId");x(this,"vNodes");x(this,"topLayer");x(this,"thread");x(this,"post");x(this,"serviceWorkShapes",new Map);x(this,"localWorkShapes",new Map);x(this,"tmpOpt");x(this,"syncUnitTime",He.syncOpt.interval);x(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===q.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:de.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===q.LaserPen)return pd({...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===xe.Service)this.activeServiceWorkShape(t);else{const n=e==null?void 0:e.toString(),i=n&&this.localWorkShapes.get(n);if(!i)return;const o=i.node.consume({data:t,isFullWork:!1,isSubWorker:!0});o.rect&&(i.totalRect=Ue(o.rect,i.totalRect),i.result=o,i.workState=de.Doing,n&&this.localWorkShapes.set(n,i))}this.runAnimation()}consumeDrawAll(t){const{workId:e,dataType:r}=t;if(r===xe.Service)this.activeServiceWorkShape(t);else{const n=e==null?void 0:e.toString(),i=n&&this.localWorkShapes.get(n);if(!i)return;const o=i.node.consumeAll({data:t});i.totalRect=Ue(o.rect,i.totalRect),i.result=o,i.workState=de.Done,n&&this.localWorkShapes.set(n,i)}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,f;const{workId:e,opt:r,toolsType:n,type:i,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(!((f=this.serviceWorkShapes)!=null&&f.has(l))){let g={toolsType:n,animationWorkData:c||[],animationIndex:0,type:i,updateNodeOpt:o,ops:a,oldRect:u};n&&r&&(g=this.setNodeKey(l,g,n,r)),this.serviceWorkShapes.set(l,g)}const h=this.serviceWorkShapes.get(l);i&&(h.type=i),a&&(h.animationWorkData=Nn(a),h.ops=a),o&&(h.updateNodeOpt=o),c&&(h.animationWorkData=c),h.node&&h.node.getWorkId()!==l&&h.node.setWorkId(l),u&&(h.oldRect=u),n&&r?(h.toolsType!==n&&n&&r&&this.setNodeKey(l,h,n,r),h.node&&h.node.setWorkOptions(r)):n&&(h.toolsType=n)}computNextAnimationIndex(t,e){const r=Math.floor((t.animationWorkData||[]).slice(t.animationIndex).length*32/e/this.syncUnitTime)*e;return Math.min((t.animationIndex||0)+(r||e),(t.animationWorkData||[]).length)}async animationDraw(){var o,a,c,l;this.animationId=void 0;let t=!1;const e=new Map,r=[],n=[],i=[];for(const[u,h]of this.serviceWorkShapes.entries())switch(h.toolsType){case q.LaserPen:{const f=this.computNextAnimationIndex(h,8),g=Math.max(0,h.animationIndex||0),y=(h.animationWorkData||[]).slice(g,f);if((h.animationIndex||0)<f){const S=(o=h.node)==null?void 0:o.consumeService({op:y,isFullWork:!1});h.totalRect=Ue(h.totalRect,S),h.animationIndex=f,y.length&&e.set(u,{cursorTool:pye(h.toolsType),workState:g===0?de.Start:f===((a=h.animationWorkData)==null?void 0:a.length)?de.Done:de.Doing,op:y.slice(-2)})}if(n.push({isClear:!0,rect:h.totalRect,clearCanvas:_e.TopFloat,viewId:this.viewId}),r.push({rect:h.totalRect,drawCanvas:_e.TopFloat,viewId:this.viewId}),h.isDel){(c=h.node)==null||c.clearTmpPoints(),this.serviceWorkShapes.delete(u);break}h.ops&&h.animationIndex===((l=h.animationWorkData)==null?void 0:l.length)&&!h.isDel&&(this.topLayer.getElementsByName(u.toString())[0]||(h.isDel=!0,this.serviceWorkShapes.set(u,h))),t=!0;break}}for(const[u,h]of this.localWorkShapes.entries()){const{result:d,toolsType:f,totalRect:g,isDel:y,workState:S}=h;switch(f){case q.LaserPen:{if(g&&(n.push({isClear:!0,rect:g,clearCanvas:_e.TopFloat,viewId:this.viewId}),r.push({rect:g,drawCanvas:_e.TopFloat,viewId:this.viewId})),y){h.node.clearTmpPoints(),this.localWorkShapes.delete(u),i.push({removeIds:[u.toString()],viewId:this.viewId,type:le.RemoveNode});break}d&&((d.op||d.ops)&&i.push(d),h.result=void 0),!this.topLayer.getElementsByName(u.toString())[0]&&S===de.Done&&(h.isDel=!0,this.localWorkShapes.set(u,h)),t=!0;break}}}t&&this.runAnimation(),e.size&&e.forEach((u,h)=>{i.push({type:le.Cursor,uid:h.split(Bt)[0],op:u.op,workState:u.workState,cursorTool:u.cursorTool,viewId:this.viewId})}),(r.length||n.length||i.length)&&this.post({render:[...n,...r],sp:i})}runAnimation(){this.animationId||(this.animationId=setTimeout(()=>{this.animationId=void 0,this.animationDraw()},16))}}class D0e extends j0{constructor(e){super(e);x(this,"opt");x(this,"scene");x(this,"cameraOpt");x(this,"vNodes");this.opt=e,this.vNodes=void 0}reportRequestFailure(e,r,n,i){const o=n instanceof Error?n.message:String(n);try{this.thread._post({sp:[{type:le.ReportError,viewId:this.viewId,viewGeneration:this.thread.viewGeneration,scenePath:r.scenePath,requestId:r.requestId,reportBusiness:e,reportStage:i,reportError:o,reportString:`[SnapshotWork] ${e} failed; stage=${i}; requestId=${r.requestId||"unknown"}; error=${o}`}]})}catch(a){console.error(`[SnapshotWork] ${e} failure report failed`,a)}}createSnapshotFullLayer(e,r){this.scene=this.opt.createScene(e),this.fullLayer=this.opt.createLayer("snapshotFullLayer",this.scene,r)}destroySnapshotFullLayer(){var e,r,n;ur(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:i,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,-i])}getOffscreen(){var r;return((r=this.fullLayer)==null?void 0:r.parent).canvas}getRectImageBitmap(e,r){const{rect:n}=e,i=this.thread.dpr,o=Math.floor(n.x*i),a=Math.floor(n.y*i),c=Math.floor(n.w*i),l=Math.floor(n.h*i);return createImageBitmap(this.getOffscreen(),o,a,c,l,r)}async getSnapshot(e){const{scenePath:r,scenes:n,cameraOpt:i,w:o,h:a,requestId:c}=e;try{if(!(r&&n&&i&&this.fullLayer))throw new Error("snapshot input is incomplete");this.setCameraOpt(i);for(const[u,h]of Object.entries(n))if(h!=null&&h.type)switch(h==null?void 0:h.type){case le.UpdateNode:case le.FullWork:{const{opt:d}=h,f={...h,opt:d,workId:u,msgType:le.FullWork,dataType:xe.Service,viewId:this.viewId,requestId:c};await this.runFullWork(f);break}default:break}let l;o&&a&&(l={resizeWidth:o,resizeHeight:a}),await this.getSnapshotRender({scenePath:r,options:l,requestId:c})}catch(l){this.reportRequestFailure("snapshot",e,l,"render")}}async runFullWork(e){var i;const r=this.setFullWork(e),n=e.ops&&Nn(e.ops);if(r){let o,a;const c=(i=r.getWorkId())==null?void 0:i.toString();return r.toolsType===q.BackgroundSVG?o=r.consumeService({isFullWork:!0,replaceId:c}):r.toolsType===q.Image?o=await r.consumeServiceAsync({isFullWork:!0,worker:this.thread,requestId:e.requestId}):r.toolsType===q.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()),Ue(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 a;const{scenePath:r,options:n,requestId:i}=e;((a=this.fullLayer)==null?void 0:a.parent).render();const o=await this.getRectImageBitmap({rect:this.getSceneRect(),drawCanvas:_e.None},n);o&&(this.thread._post({sp:[{type:le.Snapshot,scenePath:r,imageBitmap:o,viewId:this.viewId,index:0,requestId:i}]},[o]),o.close())}async getBoundingRect(e){const{scenePath:r,scenes:n,cameraOpt:i,requestId:o}=e;try{if(!(r&&n&&i&&this.fullLayer))throw new Error("bounding-box input is incomplete");this.setCameraOpt(i);let a;for(const[c,l]of Object.entries(n))if(l!=null&&l.type)switch(l==null?void 0:l.type){case le.UpdateNode:case le.FullWork:{const u=await this.runFullWork({...l,workId:c,msgType:le.FullWork,dataType:xe.Service,viewId:this.viewId,requestId:o});a=Ue(a,u);break}default:break}a?this.thread._post({sp:[{type:le.BoundingBox,scenePath:r,rect:a,viewId:this.viewId,requestId:o}]}):this.thread._post({sp:[{type:le.BoundingBox,scenePath:r,rect:{x:0,y:0,w:0,h:0},viewId:this.viewId,viewGeneration:this.thread.viewGeneration,requestId:o}]})}catch(a){this.reportRequestFailure("bounding-box",e,a,"compute")}}}const L0e="WEBGL_PROGRAM_UNAVAILABLE";var Vu=(s=>(s.Full="full",s.Sub="sub",s))(Vu||{});function N0e(s,t){const e=s==null?void 0:s.canvas,r=t.width,n=t.height,i=e==null?void 0:e.width,o=e==null?void 0:e.height;if(!Number.isFinite(r)||!Number.isFinite(n)||r<=0||n<=0||typeof i!="number"||typeof o!="number"||!Number.isFinite(i)||!Number.isFinite(o)||i<=0||o<=0||r!==i||n!==o){try{t.close()}catch{}throw new Error(`FullLayer ImageBitmap size mismatch: bitmap=${r}x${n}; layer=${i??"unavailable"}x${o??"unavailable"}`)}}function O0e(s,t,e){const r=[],n=new Map;for(const i of s){if(!i.rect)continue;const o=G0e(ht(i.rect),t,e);if(!o)continue;i.rect=o;const a=r.push(i)-1;if(i.drawCanvas!==_e.Bg||o.w<=0||o.h<=0)continue;const l=n.get(i.drawCanvas)||{rect:o,lastIndex:a,workIds:new Set,eraseTxnIds:new Set};l.rect=Ue(l.rect,o),l.lastIndex=a;for(const u of i.renderWorkIds||[])l.workIds.add(u);i.workId!==void 0&&l.workIds.add(i.workId.toString());for(const u of i.renderEraseTxnIds||[])l.eraseTxnIds.add(u);i.eraseTxnId!==void 0&&l.eraseTxnIds.add(i.eraseTxnId),n.set(i.drawCanvas,l)}return r.filter((i,o)=>{if(i.drawCanvas!==_e.Bg)return!0;const a=n.get(i.drawCanvas);return!a||a.lastIndex!==o?!1:(i.rect=a.rect,i.renderWorkIds=a.workIds.size?[...a.workIds]:void 0,i.renderEraseTxnIds=a.eraseTxnIds.size?[...a.eraseTxnIds]:void 0,!0)})}class z0e extends Xye{constructor(e,r,n){super(e,r,"sub");x(this,"type","sub");x(this,"_post");x(this,"topLayer");x(this,"serviceWork");x(this,"localWork");x(this,"topLayerWork");x(this,"snapshotWork");x(this,"fullLayerFrameSequence",0);this._post=n;const i=He.bufferSize.sub;this.topLayer=r.isUseSimple?void 0:this.createLayer("topLayer",this.scene,{...r.layerOpt,bufferSize:i,contextType:"2d"});const o={thread:this,viewId:this.viewId,vNodes:this.vNodes,fullLayer:this.fullLayer,topLayer:this.topLayer,isUseSimple:r.isUseSimple};this.localWork=new A0e(o),r.isUseSimple||(this.topLayerWork=new P0e(o)),this.snapshotWork=new D0e({...o,createScene:this.createScene.bind(this),createLayer:this.createLayer.bind(this)}),this.vNodes.init(this.fullLayer)}async combinePost(e){var a,c,l;const{render:r,...n}=this.combinePostData();let i;if(r!=null&&r.length){const u=[];for(const h of O0e(r,this.scene,this.dpr))if(h.rect){if(h.drawCanvas&&h.rect&&h.rect.w>0&&h.rect.h>0)try{const d=h.drawCanvas===_e.Bg,f=d?(a=this.getLayer(h.drawCanvas))==null?void 0:a.parent:void 0,g=d?this.transferLayerToImageBitmap(h.drawCanvas):await this.getRectImageBitmap(h);if(d&&N0e(f,g),!this.trackCombinePostTransfer(e,g))return;h.imageBitmap=g,d&&(h.isFullFrameImageBitmap=!0,h.viewGeneration=this.viewGeneration,h.frameSequence=++this.fullLayerFrameSequence,h.taskId=e,h.rect=this.getSceneRect()),i||(i=[]),i.push(g)}catch(d){throw new md(d,{business:"combine-post",stage:"transfer-layer-image-bitmap"})}u.push(h)}n.render=u}const o=(c=n.sp)==null?void 0:c.filter(u=>u.type!==le.None||u.isLockSentEventCursor||u.needUndoTicker||u.collectUndoTicker||u.eraseTxnPhase);o!=null&&o.length?n.sp=o.map(u=>({...u,viewId:u.viewId||this.viewId,viewGeneration:u.viewGeneration??this.viewGeneration})):delete n.sp,n.consumeCount===void 0&&delete n.consumeCount,n.subWorkerDrawCount===void 0&&delete n.subWorkerDrawCount,this.isCombinePostTaskActive(e)&&(o!=null&&o.length||n.consumeCount||n.subWorkerDrawCount||(l=n==null?void 0:n.render)!=null&&l.length)&&(this._post(n,i),this.commitCombinePostTransfers(e))}async on(e){var l,u;const{msgType:r,toolsType:n,opt:i,dataType:o,workState:a,isLockSentEventCursor:c}=e;switch(r){case le.UpdateTools:{if(n&&((l=this.topLayerWork)!=null&&l.canUseTopLayer(n))&&i){const h={toolsType:n,toolsOpt:i};this.topLayerWork.setToolsOpt(h);return}break}case le.CreateWork:{this.createLocalWork(e);return}case le.DrawWork:{a===de.Done&&o===xe.Local?(await this.consumeDrawAll(o,e),n===q.LaserPen&&c&&this.post({sp:[{type:le.None,isLockSentEventCursor:c}]})):await this.consumeDraw(o,e);return}case le.RemoveNode:{await this.removeNode(e);return}case le.FullWork:{n&&((u=this.topLayerWork)!=null&&u.canUseTopLayer(n))?await this.consumeDrawAll(o,e):o===xe.Local&&e.clearPreviewLocalWork&&e.workId&&await this.localWork.consumeDrawAll({...e,msgType:le.DrawWork,workState:de.Done});return}case le.Snapshot:{this.snapshotWork.createSnapshotFullLayer(this.opt,{...this.opt.layerOpt,bufferSize:this.viewId===Fe?6e3:3e3,contextType:"2d"}),await this.snapshotWork.getSnapshot(e),this.snapshotWork.destroySnapshotFullLayer();return}case le.BoundingBox:{this.snapshotWork.createSnapshotFullLayer(this.opt,{...this.opt.layerOpt,bufferSize:this.viewId===Fe?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:i}=e;if(n&&((o=this.topLayerWork)!=null&&o.canUseTopLayer(n))&&r&&i){this.topLayerWork.getToolsOpt()||this.topLayerWork.setToolsOpt({toolsType:n,toolsOpt:i}),this.topLayerWork.setWorkOptions(r.toString(),i);return}n&&super.createLocalWork(e)}async removeNode(e){const{dataType:r}=e;r===xe.Local&&await this.localWork.removeWork(e)}getLayer(e){switch(e){case _e.TopFloat:return this.topLayer||this.fullLayer;default:return this.fullLayer}}getOffscreen(e){var n;return((n=this.getLayer(e))==null?void 0:n.parent).canvas}async consumeDraw(e,r){var o;const{workId:n,toolsType:i}=r;if(n){if(i&&((o=this.topLayerWork)!=null&&o.canUseTopLayer(i))){e===xe.Local&&(this.topLayerWork.getWorkShape(n.toString())||this.createLocalWork(r)),this.topLayerWork.consumeDraw(r);return}i&&(this.localWork.getWorkShape(n.toString())||this.createLocalWork(r),await this.localWork.consumeDraw(r));return}}async consumeDrawAll(e,r){var a;const{workId:n,toolsType:i,dataType:o}=r;if(n){const c=n.toString();if(i&&((a=this.topLayerWork)!=null&&a.canUseTopLayer(i))){o===xe.Local&&(this.topLayerWork.getWorkShape(c)||this.createLocalWork(r)),this.topLayerWork.consumeDrawAll(r);return}i&&(this.localWork.getWorkShape(c)||super.createLocalWork(r),await 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()}),ur(this.topLayer,this.topLayer.parent)),await this.post({render:[{isClearAll:!0,clearCanvas:_e.TopFloat,viewId:this.viewId}],sp:[{type:le.Clear}]})}async getRectImageBitmap(e,r){const{rect:n,drawCanvas:i}=e,o=Math.floor(n.x*this.dpr),a=Math.floor(n.y*this.dpr),c=Math.max(1,Math.floor(n.w*this.dpr)),l=Math.max(1,Math.floor(n.h*this.dpr));return await createImageBitmap(this.getOffscreen(i),o,a,c,l,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,i=[];n&&i.push({isClearAll:!0,clearCanvas:_e.Float,viewId:this.viewId}),r&&i.push({isClearAll:!0,clearCanvas:_e.TopFloat,viewId:this.viewId}),i.length&&await this.post({render:i})}async updateCamera(e,r){var o;if(r!=null&&r.aborted)return;const n=[],{cameraOpt:i}=e;if(i&&!nn(this.cameraOpt,i)){const a=this.topLayerWork&&!!this.topLayerWork.localWorkShapes.size||!1,c=!!this.localWork.getWorkShapes().size;if(c&&this.localWork.workShapesDone(),this.setCameraOpt(i),c&&n.push({isClearAll:!0,clearCanvas:_e.Float,viewId:this.viewId}),a&&this.topLayerWork){n.push({isClearAll:!0,clearCanvas:_e.TopFloat,viewId:this.viewId});for(const[l,u]of this.topLayerWork.localWorkShapes.entries()||[])if(u.totalRect){let h;(o=this.topLayer)==null||o.getElementsByName(l.toString()).forEach(d=>{const f=d.getBoundingClientRect(),g=wn({x:f.x,y:f.y,w:f.width,h:f.height});h=Ue(h,g)}),u.totalRect=h,this.topLayerWork.localWorkShapes.set(l,u)}}if(n.length){const l=this.post({render:n});if(r&&!await P0(r,l,"update-camera"))return;r||await l}if(r!=null&&r.aborted)return}}setCameraOpt(e,r){var l,u;this.cameraOpt=e;const{scale:n,centerX:i,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",[-i,-o])):(this.fullLayer.setAttribute("scale",[n,n]),this.fullLayer.setAttribute("translate",[-i,-o]),(l=this.topLayer)==null||l.setAttribute("scale",[n,n]),(u=this.topLayer)==null||u.setAttribute("translate",[-i,-o]))}}class Zs extends Re{constructor(e){super(e);x(this,"canRotate",!0);x(this,"scaleType",Ye.all);x(this,"toolsType",q.Image);x(this,"tmpPoints",[]);x(this,"workOptions");x(this,"oldRect");this.workOptions=e.toolsOpt,this.scaleType=Zs.getScaleType(this.workOptions)}static normalizeStorageData(e){return Re.normalizeStorageData(e)}consume(){return{type:le.None}}consumeAll(){return{type:le.None}}draw(e){const{layer:r,workId:n,replaceId:i,imageBitmap:o}=e,{centerX:a,centerY:c,width:l,height:u,rotate:h,zIndex:d,eraserlines:f,eraserFaces:g,doingLines:y}=this.workOptions,S=new dt({anchor:[.5,.5],pos:[a,c],name:n,size:[l,u],zIndex:d,rotate:h}),b={anchor:[.5,.5],pos:[0,0],size:[l,u],texture:o};o||(b.bgcolor="rgba(0,0,0,0.3)");const I=new Ic(b);S.append(I),(f||g||y)&&this.drawEraserlines({group:S,eraserlines:this.getRenderableEraserLines(this.workOptions),eraserFaces:g,pos:[a,c],layer:r}),this.replace(r,i||n,S);const N=S.getBoundingClientRect();if(N)return{x:Math.floor(N.x-Re.SafeBorderPadding),y:Math.floor(N.y-Re.SafeBorderPadding),w:Math.floor(N.width+Re.SafeBorderPadding*2),h:Math.floor(N.height+Re.SafeBorderPadding*2)}}consumeService(){}async consumeServiceAsync(e){var h,d,f,g;const{isFullWork:r,replaceId:n,worker:i,requestId:o}=e,{src:a,uuid:c}=this.workOptions,l=((h=this.workId)==null?void 0:h.toString())||c,u=r?this.fullLayer:this.drawLayer||this.fullLayer;if(a){const y=await i.loadImageBitMap({toolsType:this.toolsType,opt:this.workOptions,workId:l,requestId:o,isSubWorker:i instanceof z0e});if(y){const S=this.draw({workId:l,layer:u,replaceId:n,imageBitmap:y});return this.oldRect=l&&((f=(d=this.vNodes)==null?void 0:d.get(l))==null?void 0:f.rect)||void 0,(g=this.vNodes)==null||g.setInfo(l,{rect:S,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:S&&Re.getCenterPos(S,u)}),S}}}clearTmpPoints(){this.tmpPoints.length=0}static getScaleType(e){const{uniformScale:r,rotate:n}=e;return r!==!1||n&&Math.abs(n)%90>0?Ye.proportional:Ye.all}static updateNodeOpt(e){const{node:r,opt:n,vNodes:i,targetNode:o}=e,{translate:a,originPoint:c,scenePoint:l,scale:u,angle:h,isLocked:d,zIndex:f,strokeColor:g}=n,y=o&&ht(o)||i.get(r.name);if(!y)return;const S=r.parent;if(S){if(g&&(y.opt.strokeColor=g),yt(f)&&(r.setAttribute("zIndex",f),y.opt.zIndex=f),_n(d)&&(y.opt.locked=d),c&&l&&u&&a){const{centerX:b,centerY:I,width:N,height:T,uniformScale:p}=y.opt,m=p!==!1?[u[0],u[0]]:u,v=[b,I],M=[b,I];zc(M,l,m,a);const k=[M[0]-v[0],M[1]-v[1]];if(y.centerPos=[y.centerPos[0]+k[0],y.centerPos[1]+k[1]],y.opt.width=Math.round(N*m[0]),y.opt.height=Math.round(T*m[1]),y.opt.centerX=M[0],y.opt.centerY=M[1],y.opt.eraserlines)for(const E of y.opt.eraserlines){const{op:D,thickness:P}=E;E.thickness=Math.round(P*Math.max(u[0],u[1]));for(let z=0;z<D.length;z++)Fs(D[z],l,u,a)}}else if(a){if(y.opt.centerX=y.opt.centerX+a[0],y.opt.centerY=y.opt.centerY+a[1],y.centerPos=[y.centerPos[0]+a[0],y.centerPos[1]+a[1]],y.opt.eraserlines)for(const b of y.opt.eraserlines){const{op:I}=b;for(let N=0;N<I.length;N++){const T=I[N].map((p,m)=>m%2?p+a[1]:p+a[0]);b.op[N]=T}}}else if(yt(h))if(y.opt.rotate=h,y.scaleType=Zs.getScaleType(y.opt),o){const b=Md(y.rect,h);y.rect=b}else{const b=Re.getRectFromLayer(S,r.name);y.rect=b||y.rect}return y&&i.setInfo(r.name,y),y==null?void 0:y.rect}}}function Ue(s,t){if(s&&t){const e=Math.min(s.x,t.x),r=Math.min(s.y,t.y),n=Math.max(s.x+s.w,t.x+t.w),i=Math.max(s.y+s.h,t.y+t.h),o=n-e,a=i-r;return{x:e,y:r,w:o,h:a}}return t||s}function vd(s,t){if(s&&t){const e=Math.min(s.originX,t.originX),r=Math.min(s.originY,t.originY),n=Math.max(s.originX+s.width,t.originX+t.width),i=Math.max(s.originY+s.height,t.originY+t.height),o=n-e,a=i-r;return{originX:e,originY:r,width:o,height:a}}return t||s}function it(s,t=0){const e={x:0,y:0,w:0,h:0};let r=1/0,n=1/0,i=-1/0,o=-1/0;return s.forEach(a=>{const[c,l]=a.XY;r=Math.min(r,c-t),n=Math.min(n,l-t),i=Math.max(i,c+t),o=Math.max(o,l+t)}),e.x=r,e.y=n,e.w=i-r,e.h=o-n,e}function Ua(s,t){return!(s.x+s.w<t.x||s.x>t.x+t.w||s.y+s.h<t.y||s.y>t.y+t.h)}function wn(s,t=10){return{x:Math.floor(s.x-t),y:Math.floor(s.y-t),w:Math.ceil(s.w+t*2),h:Math.ceil(s.h+t*2)}}function Ks(s,t){return{x:s.x+t[0],y:s.y+t[1],w:s.w,h:s.h}}function B0e(s,t){const e=new fe(s.x,s.y),r=new fe(s.x+s.w,s.y),n=new fe(s.x+s.w,s.y+s.h),i=new fe(s.x,s.y+s.h),o=new fe(s.x+s.w/2,s.y+s.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(i,o,a);return[c,l,u,h]}function Md(s,t){const e=B0e(s,t);return it(e)}function $0(s,t,e){const r=new fe(s.x,s.y),n=new fe(s.x+s.w,s.y),i=new fe(s.x+s.w,s.y+s.h),o=new fe(s.x,s.y+s.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(i,c,a),d=fe.ScaleWOrigin(o,c,a);return it([l,u,h,d])}function j0e(s,t,e){const r=new fe(t[0],t[1]);for(let n=0;n<s.length;n+=3){const i=new fe(s[n],s[n+1]),o=Math.PI*e/180,a=fe.RotWith(i,r,o);s[n]=a.x,s[n+1]=a.y}}function Bp(s,t,e){const r=new fe(t[0],t[1]);for(let n=0;n<s.length;n+=2){const i=new fe(s[n],s[n+1]),o=Math.PI*e/180,a=fe.RotWith(i,r,o);s[n]=a.x,s[n+1]=a.y}}function zc(s,t,e,r=[0,0]){const n=new fe(t[0],t[1]);for(let i=0;i<s.length;i+=3){const o=new fe(s[i],s[i+1]),a=new fe(e[0],e[1]),c=fe.ScaleWOrigin(o,a,n);s[i]=c.x+r[0],s[i+1]=c.y+r[1]}}function Fs(s,t,e,r=[0,0]){const n=new fe(t[0],t[1]);for(let i=0;i<s.length;i+=2){const o=new fe(s[i],s[i+1]),a=new fe(e[0],e[1]),c=fe.ScaleWOrigin(o,a,n);s[i]=c.x+r[0],s[i+1]=c.y+r[1]}}function Y0(s,t){return s[0]>=t.x&&s[0]<=t.x+t.w&&s[1]>=t.y&&s[1]<=t.y+t.h}function G0(s,t){const e=s<=t?1:s/t,r=t<=s?1:t/s;return[e,r]}function F0e(s){for(const t of s)if(isNaN(t)||t===1/0||t===-1/0)return!1;return!0}function U0e(s){return s!==Math.floor(s)}function W0e(s){const t=s.toString();return t.indexOf(".")!==-1?t.split(".")[1].length:0}function V0e(s,t){for(;t!==0;)[s,t]=[t,s%t];return s}const $0e=s=>{if(s.tagName==="GROUP"){const t=Object.getOwnPropertySymbols(s).find(e=>e.toString()==="Symbol(sealed)");if(t&&s[t])return!0}return!1},hr=(s,t)=>{if(s.mesh&&s.mesh.texture&&s.name==="eraserTexture"){const e=s.mesh.texture.image;t.deleteTexture(e)}else if(s.tagName==="GROUP"&&s&&s.children)for(const e of s.children)hr(e,t)},ur=(s,t)=>{hr(s,t),s.removeAllChildren()},Y0e=(s,t,e)=>{const r=e.parent;if(t){const n=t.children;if(n){for(const i of n)if(hr(i,r),i.tagName==="GROUP")for(const o of i.children)hr(o,r)}}t.parent.replaceChild(s,t)},G0e=(s,t,e)=>{if(s.w+s.x<=0||s.h+s.y<=0||s.w<=0||s.h<=0)return;const r=t.width,n=t.height,i={x:Math.floor(Math.max(0,s.x)),y:Math.floor(Math.max(0,s.y)),w:Math.floor(Math.min(r,s.w)),h:Math.floor(Math.min(n,s.h))};if(i.x+i.w>r&&(i.w=Math.floor(r-i.x)),i.y+i.h>n&&(i.h=Math.floor(n-i.y)),U0e(e)){const o=W0e(e),a=Math.pow(10,o),c=V0e(a,e*a),l=i.x%c,u=i.x-l;u>=0?(i.x=u,i.w=i.w+l):(i.x=0,i.w=i.w+l-u);const h=i.y%c,d=i.y-h;d>=0?(i.y=d,i.h=i.h+h):(i.y=0,i.h=i.h+h-d)}return i};function Ei(s){return`${Wa(s.x)},${Wa(s.y)} `}function xi(s,t){return`${Wa((s.x+t.x)/2)},${Wa((s.y+t.y)/2)} `}function Wa(s){return+s.toFixed(4)}const Dr=async(s,t,e=!1)=>{let r,n;return new Promise(function(i){if(e&&requestIdleCallback)requestIdleCallback(()=>{i(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),i(1)},{timeout:o})}r=setTimeout(()=>{n&&window.cancelIdleCallback(n),i(1)},t||0)}}).then(function(){s()}).catch(function(){s()})},Hi=s=>Math.max(1,(window.devicePixelRatio||1)/1),Bc=(s,t)=>s.x+s.w<t.x||s.x>t.x+t.w||s.y+s.h<t.y||s.y>t.y+t.h?sn.outside:s.x>=t.x&&s.y>=t.y&&s.x+s.w<=t.x+t.w&&s.y+s.h<=t.y+t.h?sn.inside:sn.intersect;function H0e(s){let t=0;for(let e=0;e<s.length;e++){const r=s.charCodeAt(e);r>=1&&r<=126||65376<=r&&r<=65439?t++:t+=2}return t}function Q0e(s){if(!s||typeof s!="string")return!1;const t=s.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 i=[/^\s*#{1,6}\s+/m,/^\s*[-*+]\s+/m,/^\s*\d+\.\s+/m,/```[\s\S]*?```/,/^\s*\|.+\|/m].some(o=>o.test(t));return r>=2||i}class q0e{constructor(t,e){x(this,"plugin");x(this,"uid");x(this,"control");this.control=t,this.plugin=e,this.uid=e.displayer.uid}getNamespaceData(){var t;return oa((t=this.plugin)==null?void 0:t.attributes[this.namespace])||{}}getAuthSpaceData(){var t;return oa((t=this.plugin)==null?void 0:t.attributes[this.authSpace])||{}}getGlobalUndoRedoStackData(){var t;return oa((t=this.plugin)==null?void 0:t.attributes[this.globalUndoRedoStackSpace])||{}}getUidFromKey(t){return t.split(Bt).length===2&&t.split(Bt)[0]||this.uid}isLocalId(t){return t.split(Bt).length===1}getLocalId(t){return t.split(Bt)[1]}isSelector(t){return this.getLocalId(t)===Le}}const Z0e=new Set([Te.TranslateNode,Te.ScaleNode,Te.RotateNode,Te.SetPoint,Te.SetColorNode]),Vt=class Vt extends q0e{constructor(e,r,n){super(e,r);x(this,"namespace");x(this,"authSpace");x(this,"globalUndoRedoStackSpace");x(this,"serviceStorage",{});x(this,"storage",{});x(this,"authStorage",{});x(this,"globalUndoRedoStackStorage",{});x(this,"stateDisposer");x(this,"authDisposer");x(this,"asyncClockState",!1);x(this,"pendingSyncViews",new Set);x(this,"pendingSyncStorage");x(this,"limitNums",new Map);x(this,"destroyed",!1);x(this,"storageRevision",0);x(this,"viewStorageRevisions",new Map);x(this,"sceneStorageRevisions",new Map);x(this,"discardedSyncViews",new Set);x(this,"syncInterval");x(this,"limitComponents",ye.debounce((e,r)=>{var o,a,c,l,u,h,d,f;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 i=this.limitNums.get(`${e}/${r}`);if(!i){const g=this.getLimitNum(n);this.limitNums.set(`${e}/${r}`,g),i=g}if(i>0&&n>=i){const g=Vt.componentsLimits.indexOf(i),y=g>=0&&g<Vt.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",b=>b(i,y))),!y){this.Logger.error(`[Appliance]: exceeds the limit of ${i} components, current: ${n}`),(f=this.control.room)==null||f.disconnect().then(()=>{var b,I,N,T,p;(N=(I=(b=this.control.room)==null?void 0:b.callbacks)==null?void 0:I.listeners)!=null&&N.map.onKickedWithReason&&(this.Logger.info("[Appliance]: onKickedWithReason callback is called"),(p=(T=this.control.room)==null?void 0:T.callbacks)==null||p.dispatch("onKickedWithReason",m=>m("kickByAdmin")))});return}console.warn(`exceeds the limit of ${i} components, current: ${n}`);const S=y?Vt.componentsLimits[g+1]:0;this.limitNums.set(`${e}/${r}`,S)}},2e3,{maxWait:5e3}));x(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=Vt.namespace,this.authSpace=Vt.authSpace,this.globalUndoRedoStackSpace=Vt.globalUndoRedoStackSpace,this.serviceStorage=this.getNamespaceData(),this.storage=ye.cloneDeep(this.serviceStorage),this.authStorage=this.getAuthSpaceData(),this.globalUndoRedoStackStorage={},this.getLimitNums()}get Logger(){return this.control.logger}discardViewPendingSync(e){e&&(this.discardedSyncViews.add(e),this.pendingSyncViews.delete(e))}restoreViewPendingSync(e){e&&this.discardedSyncViews.delete(e)}isViewPendingSyncDiscarded(e){return this.discardedSyncViews.has(e)}canRunSync(e){return!this.destroyed&&(!e||!this.discardedSyncViews.has(e))}getSceneRevisionKey(e,r){return`${e}\0${r}`}getSceneDiffKey(e,r){return JSON.stringify([e,r])}getDataDiffKey(e,r,n){return JSON.stringify([e,r,n])}bumpStorageRevision(e,r){this.storageRevision+=1,this.viewStorageRevisions.set(e,this.storageRevision),r!==void 0&&this.sceneStorageRevisions.set(this.getSceneRevisionKey(e,r),this.storageRevision)}filterDiscardedViews(e){if(!this.discardedSyncViews.size)return e;const r={};for(const[n,i]of Object.entries(e))this.discardedSyncViews.has(n)||(r[n]=i);return r}hasId(e,r,n){const i=this.getLocalId(n)?this.transformKey(n):n;return!!(this.storage[e]&&this.storage[e][r]&&this.storage[e][r][i])}getLimitNum(e){return e>=Vt.componentsLimits[0]?Vt.componentsLimits[1]:Vt.componentsLimits[0]}getLimitNums(){for(const[e,r]of Object.entries(this.storage))if(e&&r){for(const[n,i]of Object.entries(r))if(n&&i){const o=this.getLimitNum(Object.keys(i).length);this.limitNums.set(`${e}/${n}`,o)}}}getViewIdBySecenPath(e){const r=this.getNamespaceData();for(const[n,i]of Object.entries(r))if(i){for(const o of Object.keys(i))if(o===e)return n}}getScenePathData(e){const r=this.getNamespaceData();for(const n of Object.values(r))if(n){for(const i of Object.keys(n))if(i===e)return ye.cloneDeep(n[i])}}hasTargetDataByViewId(e,r){const n=this.getNamespaceData();if(n&&n[e]){for(const i of Object.values(n[e]))for(const o of Object.keys(i))if(o===r)return!0}}getTargetDataByViewId(e,r){const n=this.getNamespaceData();let i,o;if(n&&n[e])for(const[a,c]of Object.entries(n[e]))for(const l of Object.keys(c))l===r&&(i=ye.cloneDeep(c[l]),o=a);return{data:i,scenePath:o}}getStorageData(e,r){var n;return(n=this.storage[e])!=null&&n[r]?ye.cloneDeep(this.storage[e][r]):void 0}getServiceStorageViewSnapshot(e){return this.storage[e]?ye.cloneDeep(this.storage[e]):{}}readViewStorageSnapshot(e){return{revision:this.viewStorageRevisions.get(e)||0,storage:this.getServiceStorageViewSnapshot(e)}}readSceneStorageSnapshot(e,r){return{revision:this.sceneStorageRevisions.get(this.getSceneRevisionKey(e,r))||0,storage:this.getStorageData(e,r)||{}}}hasSelector(e,r){const n=this.storage&&this.storage[e]&&this.storage[e][r];return!!(n&&Object.keys(n).find(i=>this.isOwn(i)&&this.getLocalId(i)===Le))}hasIncludeSelector(e,r,n){for(const i of Object.keys(this.storage))if(!(r&&i!==r)){for(const o of Object.keys(this.storage[i]))if(!(n&&o!==n)){for(const a of Object.keys(this.storage[i][o]))if(this.getLocalId(a)===Le){const c=this.storage[i][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=Vc(async()=>{var c,l,u,h,d,f,g;const r=this.getNamespaceData(),{diffView:n,diffScenePath:i,diffData:o}=this.diffFunByView(this.serviceStorage,r);this.serviceStorage=r;const a={};if(Object.keys(n).length>0){for(const[y,S]of Object.entries(n))if(S&&!ye.isEqual((c=this.storage)==null?void 0:c[y],S.newValue)){const b=new Set([...Object.keys(((l=this.storage)==null?void 0:l[y])||{}),...Object.keys(S.newValue||{})]);a.diffView||(a.diffView={}),a.diffView[y]=S,this.storage||(this.storage={}),S.newValue===void 0?delete this.storage[y]:this.storage[y]=ye.cloneDeep(S.newValue),b.size?b.forEach(I=>this.bumpStorageRevision(y,I)):this.bumpStorageRevision(y)}}if(Object.keys(i).length>0){for(const[y,S]of Object.entries(i))if(S){const{viewId:b,newValue:I}=S,N=S.scenePath??y;S&&!ye.isEqual((h=(u=this.storage)==null?void 0:u[b])==null?void 0:h[N],I)&&(a.diffScenePath||(a.diffScenePath={}),a.diffScenePath[y]=S,this.storage||(this.storage={}),this.storage[b]||(this.storage[b]={}),S.newValue===void 0?delete this.storage[b][N]:this.storage[b][N]=ye.cloneDeep(S.newValue),this.bumpStorageRevision(b,N))}}if(Object.keys(o).length>0){for(const[y,S]of Object.entries(o))if(S){const{viewId:b,scenePath:I,newValue:N}=S,T=S.storageKey??y;S&&!ye.isEqual((g=(f=(d=this.storage)==null?void 0:d[b])==null?void 0:f[I])==null?void 0:g[T],N)&&(a.diffData||(a.diffData={}),a.diffData[y]=S,this.storage||(this.storage={}),this.storage[b]||(this.storage[b]={}),this.storage[b][I]||(this.storage[b][I]={}),S.newValue===void 0?delete this.storage[b][I][T]:this.storage[b][I][T]=ye.cloneDeep(S.newValue),this.bumpStorageRevision(b,I))}}this.logServiceDiff(a),Object.keys(a).length>0&&e(a),this.control.worker.publicMsgEmitter.emit("syncStorageChange",this.serviceStorage)})}logServiceDiff(e){var r,n,i;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||{})){if(!a||!this.control.isServiceSyncReady(a.viewId))continue;const c=a.scenePath??o;this.control.syncLogger.append("serviceDiff",a.viewId,c,[{diffType:"scenePath",viewId:a.viewId,scenePath:c}])}for(const[o,a]of Object.entries(e.diffData||{})){if(!a||!this.control.isServiceSyncReady(a.viewId))continue;const c=a.storageKey??o;this.control.syncLogger.append("serviceDiff",a.viewId,a.scenePath,[{diffType:"data",viewId:a.viewId,scenePath:a.scenePath,key:c,type:(r=a.newValue)==null?void 0:r.type,toolsType:((n=a.newValue)==null?void 0:n.toolsType)??((i=a.oldValue)==null?void 0:i.toolsType)}])}}removeStorageStateListener(){this.stateDisposer&&this.stateDisposer()}diffFunByView(e,r){const n=at(e),i=at(r),o={},a={},c={};for(const l of i)if(!n.includes(l)||e[l]===void 0){o[l]={newValue:r[l],oldValue:void 0};continue}for(const l of n){if(ye.isEqual(e[l],r[l]))continue;if(!i.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 i=at(e),o=at(r),a={},c={};for(const l of o)if(!i.includes(l)||e[l]===void 0){a[this.getSceneDiffKey(n,l)]={newValue:r[l],oldValue:void 0,viewId:n,scenePath:l};continue}for(const l of i){if(ye.isEqual(e[l],r[l]))continue;if(!o.includes(l)||r[l]===void 0){a[this.getSceneDiffKey(n,l)]={newValue:void 0,oldValue:e[l],viewId:n,scenePath:l};continue}const u=this.diffFunByKeys(e[l],r[l],l,n);Object.assign(c,u)}return{diffScenePath:a,diffData:c}}diffFunByKeys(e,r,n,i){const o=at(e),a=at(r),c={};for(const l of a)(!o.includes(l)||e[l]===void 0)&&(c[this.getDataDiffKey(i,n,l)]={oldValue:void 0,newValue:r[l],viewId:i,scenePath:n,storageKey:l});for(const l of o)if(!ye.isEqual(e[l],r[l])){if(!a.includes(l)||r[l]===void 0){c[this.getDataDiffKey(i,n,l)]={newValue:void 0,oldValue:e[l],viewId:i,scenePath:n,storageKey:l};continue}a.includes(l)&&(c[this.getDataDiffKey(i,n,l)]={oldValue:e[l],newValue:r[l],viewId:i,scenePath:n,storageKey:l})}return c}transformKey(e){return this.uid+Bt+e}isOwn(e){return e.split(Bt)[0]===this.uid}dispatch(e){var I,N,T;if(this.destroyed)return;const{type:r,workId:n,ops:i,index:o,opt:a,toolsType:c,removeIds:l,updateNodeOpt:u,op:h,selectIds:d,isSync:f,scenePath:g,viewId:y}=e;if(!y||r!==le.Clear&&!this.canRunSync(y))return;const S=Number(e.needUndoTicker??e.collectUndoTicker??void 0),b=p=>{S?this.control.internalMsgEmitter.emit("ackStorageUndoTicker",S,y,g,p,{requestId:e.requestId,emitEventType:e.emitEventType}):e.emitEventType===Te.TranslateNode||(e.emitEventType,Te.CopyNode)};switch(r){case le.Clear:const p={};if(g&&this.storage[y]&&this.storage[y][g])delete this.storage[y][g],this.setState(p,{isSync:f,viewId:y,scenePath:g});else if(this.storage[y]){const E=Object.keys(this.storage[y]);delete this.storage[y],E.length?E.forEach(D=>this.bumpStorageRevision(y,D)):this.bumpStorageRevision(y),this.runSyncService({isSync:f,viewId:y})}Dr(()=>{var E,D;this.canRunSync(y)&&((E=this.control.pluginManager)==null||E.dispatchPluginEvent("syncStorage",y,g),this.control.isUseSimple||(D=this.control.miniMapManager)==null||D.updateMiniMapCamera(y),this.clearLimitComponents(y,g))},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback"));break;case le.CreateWork:if(g&&n&&c&&a){const E=this.isLocalId(n.toString())?this.transformKey(n):n;this.control.renderControl.isUsePageAuth(y)&&this.control.renderControl.addRenderPageElementId({viewId:y,scenePath:g,elementId:E.toString()}),this.updateValue(E.toString(),{type:le.CreateWork,workId:n,toolsType:c,opt:a},{isSync:f,viewId:y,scenePath:g,onApplied:()=>b(E.toString())})}break;case le.DrawWork:if(g&&n&&typeof o=="number"&&(h!=null&&h.length)){const E=this.isLocalId(n.toString())?this.transformKey(n):n,D=this.storage[y]&&this.storage[y][g]&&this.storage[y][g][E]||void 0;if(D!=null&&D.ops||(D==null?void 0:D.type)===le.FullWork)return;const P=o?((D==null?void 0:D.op)||[]).slice(0,o).concat(h):h||(D==null?void 0:D.op),z=c||(D==null?void 0:D.toolsType),j=a||(D==null?void 0:D.opt),A=u||(D==null?void 0:D.updateNodeOpt);n&&z&&j&&P&&(this.control.renderControl.isUsePageAuth(y)&&this.control.renderControl.addRenderPageElementId({viewId:y,scenePath:g,elementId:E.toString()}),this.updateValue(E.toString(),{...D,type:le.DrawWork,workId:n,updateNodeOpt:A,toolsType:z,opt:j,op:P,index:o},{isSync:f,viewId:y,scenePath:g,onApplied:()=>b(E.toString())}))}break;case le.FullWork:if(g&&n){const E=this.isLocalId(n.toString())?this.transformKey(n):n,D=this.storage[y]&&this.storage[y][g]&&this.storage[y][g][E]||void 0,P=u||(D==null?void 0:D.updateNodeOpt),z=c||(D==null?void 0:D.toolsType),j=a||(D==null?void 0:D.opt),A=i||(D==null?void 0:D.ops);if(!D&&e.emitEventType!==void 0&&Z0e.has(e.emitEventType)){b(E.toString());break}z&&j&&(this.control.renderControl.isUsePageAuth(y)&&this.control.renderControl.addRenderPageElementId({viewId:y,scenePath:g,elementId:E.toString()}),this.updateValue(E.toString(),{type:le.FullWork,updateNodeOpt:P,workId:E,toolsType:z,opt:j,ops:A},{isSync:f,viewId:y,scenePath:g,onApplied:()=>{b(E.toString())}}),Dr(()=>{var R,L;this.canRunSync(y)&&((R=this.control.pluginManager)==null||R.dispatchPluginEvent("syncStorage",y,g),this.control.isUseSimple||(L=this.control.miniMapManager)==null||L.updateMiniMapCamera(y),this.limitComponents(y,g))},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback")))}break;case le.RemoveNode:if(g&&(l!=null&&l.length)){const E=l.map(z=>this.isLocalId(z+"")?this.transformKey(z):z);let D=0;const P=(I=this.storage[y])==null?void 0:I[g];P&&(Object.keys(P).map(z=>{E!=null&&E.includes(z)&&(D++,this.control.renderControl.isUsePageAuth(y)&&this.control.renderControl.delRenderPageElementId({viewId:y,scenePath:g,elementId:z}),this.updateValue(z,void 0,{isSync:f,viewId:y,scenePath:g,onApplied:()=>b(z)}))}),(N=this.control.pluginManager)==null||N.dispatchPluginEvent("syncStorage",y,g),this.control.isUseSimple||Dr(()=>{var z;this.canRunSync(y)&&((z=this.control.miniMapManager)==null||z.updateMiniMapCamera(y))},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback"))),S&&D===0&&b()}break;case le.UpdateNode:if(g&&n&&(u||i||a)){const E=this.isLocalId(n.toString())?this.transformKey(n):n,D=this.storage[y]&&this.storage[y][g]&&this.storage[y][g][E]||void 0;D&&(D.updateNodeOpt=u,(i||h)&&(D.ops=i,D.op=h),a&&(D.opt=Da(zu(D.opt,a))),D.type=le.FullWork,this.updateValue(E.toString(),D,{isSync:f,viewId:y,scenePath:g,onApplied:()=>b(E.toString())}),this.control.isUseSimple||Dr(()=>{var P;this.canRunSync(y)&&((P=this.control.miniMapManager)==null||P.updateMiniMapCamera(y))},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback")))}break;case le.Select:if(!g)return;let m;d!=null&&d.length&&(m=d.map(E=>this.isLocalId(E+"")?this.transformKey(E):E));const v=this.transformKey(Le);if(m&&!((T=this.storage[y])!=null&&T[g]))return;const M=this.storage[y]&&this.storage[y][g]&&this.storage[y][g][v]||void 0,k=a||(M==null?void 0:M.opt);m&&this.checkOtherSelector(v,m,{isSync:f,viewId:y,scenePath:g}),this.updateValue(v,m&&{type:le.Select,toolsType:q.Selector,opt:k,selectIds:m},{isSync:f,viewId:y,scenePath:g,onApplied:()=>b(v)});break}}checkOtherSelector(e,r,n){var c;const{viewId:i,scenePath:o}=n,a=(c=this.storage[i])==null?void 0:c[o];if(a){for(const l of Object.keys(a))if(l!==e&&this.getLocalId(l)===Le){const u=a[l];if(u&&u.selectIds){const h=u.selectIds.filter(d=>!r.includes(d));h.length>0&&(u.selectIds=h),this.updateValue(l,h.length&&u||void 0,n)}}}}setState(e,r){const{viewId:n,scenePath:i}=r,o=at(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][i]||(this.storage[n][i]={}),this.storage[n][i][c]=l):delete this.storage[n][i][c]}this.bumpStorageRevision(n,i),this.runSyncService(r)}updateValue(e,r,n){var u,h,d,f;const{viewId:i,scenePath:o,storage:a}=n,c=a||this.storage,l=(h=(u=c[i])==null?void 0:u[o])==null?void 0:h[e];if(r&&typeof r=="object"&&this.uid&&(r={...r,lastOperator:n.preserveLastOperator?r.lastOperator:this.uid},r.toolsType===q.Text&&r.opt)){const g={...r.opt};delete g.uid,r.opt=g}if(r===void 0){const g=(d=c[i])==null?void 0:d[o];g&&delete g[e]}else c[i]||(c[i]={}),c[i][o]||(c[i][o]={}),c[i][o][e]=r;c===this.storage&&!ye.isEqual(l,r)&&this.bumpStorageRevision(i,o),n.onApplied,(f=n.onApplied)==null||f.call(n),this.runSyncService(n)}updateExistingValue(e,r,n){var a;const i=(a=this.storage[n.viewId])==null?void 0:a[n.scenePath];if(!i)return!1;const o=Object.prototype.hasOwnProperty.call(i,e)||!this.isLocalId(e)?e:this.transformKey(e);return Object.prototype.hasOwnProperty.call(i,o)?(this.updateValue(o,r,n),!0):!1}runSyncService(e){if(this.canRunSync(e.viewId)){if(e.viewId&&this.pendingSyncViews.add(e.viewId),e.storage&&(this.pendingSyncStorage=e.storage),!this.control.renderControl.isWritable){this.Logger.error("[Appliance]: The current state is not writable and synchronization cannot be synchronized");return}if(e.isSync){this.pendingSyncViews.clear();const r=this.pendingSyncStorage||this.storage;this.pendingSyncStorage=void 0,this.syncSerivice({storage:r});return}this.asyncClockState||(this.asyncClockState=!0,Dr(()=>{if(this.asyncClockState=!1,this.destroyed)return;const r=[...this.pendingSyncViews].filter(i=>this.canRunSync(i));this.pendingSyncViews.clear();const n=this.filterDiscardedViews(this.pendingSyncStorage||this.storage);this.pendingSyncStorage=void 0,r.length&&this.syncSerivice({storage:n})},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback")))}}syncSerivice(e={storage:this.storage}){if(this.destroyed)return;const{storage:r}=e,n=this.filterDiscardedViews(r||this.storage);this.logLocalSyncChanges(this.serviceStorage,n);const i=at(this.serviceStorage),o=at(n),a=new Map;for(const c of i){if(!o.includes(c)){a.set(c,void 0);continue}ye.isEqual(this.serviceStorage[c],n[c])||this.syncViewData(n,c)}for(const c of o)i.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([...at(e),...at(r)]);for(const i of n){const o=e[i]||{},a=r[i]||{},c=new Set([...at(o),...at(a)]);for(const l of c){const u=o[l]||{},h=a[l]||{},d=new Set([...at(u),...at(h)]),f=[];for(const g of d){const y=u[g],S=h[g];ye.isEqual(y,S)||f.push({key:g,type:S==null?void 0:S.type,toolsType:(S==null?void 0:S.toolsType)??(y==null?void 0:y.toolsType)})}this.control.syncLogger.append("localSync",i,l,f)}}}syncViewData(e,r){const n=at(this.serviceStorage[r]),i=at(e[r]),o=new Map;for(const a of n){if(!i.includes(a)){o.set(a,void 0);continue}ye.isEqual(this.serviceStorage[r][a],e[r][a])||this.syncScenePathData(e,r,a)}for(const a of i)n.includes(a)||o.set(a,e[r][a]);if(o.size>=i.length||o.size>5&&i.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 i=at(this.serviceStorage[r][n]),o=at(e[r][n]),a=new Map;for(const c of i){if(!o.includes(c)){a.set(c,void 0);continue}ye.isEqual(this.serviceStorage[r][n][c],e[r][n][c])||a.set(c,e[r][n][c])}for(const c of o)i.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,i){var a;Object.keys(this.serviceStorage[r]).length?(a=this.plugin)==null||a.updateAttributes([this.namespace,r,n],i):this.syncStorageScenePath(r,e[r])}syncStorageScenePath(e,r){var n;(n=this.plugin)==null||n.updateAttributes([this.namespace,e],r)}syncUpdataKey(e,r,n,i,o){var c;Object.keys(this.serviceStorage[r][n]).length?(c=this.plugin)==null||c.updateAttributes([this.namespace,r,n,i],o):this.syncStorageKey(r,n,e[r][n])}syncStorageKey(e,r,n){var i;(i=this.plugin)==null||i.updateAttributes([this.namespace,e,r],n)}keyTransformWorkId(e){const r=e.split(Bt);return r.length===2?r[1]:e}destroy(){this.destroyed||(this.destroyed=!0,this.limitComponents.cancel(),this.pendingSyncViews.clear(),this.pendingSyncStorage=void 0,this.discardedSyncViews.clear(),this.removeStorageStateListener(),this.serviceStorage={},this.storage={},this.storageRevision=0,this.viewStorageRevisions.clear(),this.sceneStorageRevisions.clear(),this.removeAuthStateListener(),this.authStorage={},this.globalUndoRedoStackStorage={})}transformToSerializableUndoStackItemData(e){const{data:r,scenePath:n}=e,i={};for(const o of r)i[o.key]={dataType:o.dataType,data:o.data};return{data:i,scenePath:n}}dispatchUndoTicker(e){const{viewId:r,undoTickerId:n,data:i,syncType:o,operation:a}=e,c=a===wt.syncUndoStack?"undoStack":"redoStack",l=o==="delete"?void 0:this.transformToSerializableUndoStackItemData(i);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=Vc(async()=>{const r=this.getGlobalUndoRedoStackData();if(ye.isEqual(this.globalUndoRedoStackStorage,r))return;const n=this.diffGlobalUndoRedoStackFun(this.globalUndoRedoStackStorage,r);this.globalUndoRedoStackStorage=r,e(n)})}diffGlobalUndoRedoStackFun(e,r){const n=at(e),i=at(r),o={};for(const a of i)if(!n.includes(a)||e[a]===void 0){o[a]={newValue:r[a],oldValue:void 0};continue}for(const a of n)if(!ye.isEqual(e[a],r[a])){if(!i.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,f,g,y,S,b,I,N,T,p,m,v,M,k,E,D,P,z,j,A,R,L,W,Y,H,ie,O,V,Z,$,ee,se,ce,me,pe;const{operation:n,viewId:i,scenePath:o,pageId:a,pageData:c}=e;switch(n){case wt.addPage:{if(!i||!o||!a)return;const B=[this.authSpace];Object.keys(this.authStorage).length&&B.push("pageAuth");const F=this.authStorage.pageAuth||{};this.authStorage.pageAuth=F,Object.keys(F).length&&B.push(i),F[i]=F[i]||{},Object.keys(F[i]).length&&B.push(o),F[i][o]=F[i][o]||{render:(c==null?void 0:c.render)||"localSelf",pages:{}},Object.keys(F[i][o].pages).length&&B.push("pages",a);const J={};if(c!=null&&c.elementIds)for(const oe of c.elementIds.keys())J[oe]=!0;F[i][o].pages[a]=J,r&&(B.length===1?(l=this.plugin)==null||l.updateAttributes(B,ye.cloneDeep(this.authStorage)):B.length===2?(u=this.plugin)==null||u.updateAttributes(B,ye.cloneDeep(F)):B.length===3?(h=this.plugin)==null||h.updateAttributes(B,ye.cloneDeep(F[i])):B.length===4?(d=this.plugin)==null||d.updateAttributes(B,ye.cloneDeep(F[i][o])):(f=this.plugin)==null||f.updateAttributes(B,ye.cloneDeep(J)));return}case wt.renderPage:{if(!i||!o||!(c!=null&&c.render))return;this.authStorage.pageAuth&&this.authStorage.pageAuth[i]&&this.authStorage.pageAuth[i][o]&&c.render!==this.authStorage.pageAuth[i][o].render&&(this.authStorage.pageAuth[i][o].render=c.render,r&&((g=this.plugin)==null||g.updateAttributes([this.authSpace,"pageAuth",i,o,"render"],c.render)));return}case wt.deletePage:{if(!i||!o||!a)return;(N=(I=(b=(S=(y=this.authStorage)==null?void 0:y.pageAuth)==null?void 0:S[i])==null?void 0:b[o])==null?void 0:I.pages)!=null&&N[a]&&(delete this.authStorage.pageAuth[i][o].pages[a],r&&((T=this.plugin)==null||T.updateAttributes([this.authSpace,"pageAuth",i,o,"pages",a],void 0)));return}case wt.clearPage:{if(!i||!o||!a)return;(k=(M=(v=(m=(p=this.authStorage)==null?void 0:p.pageAuth)==null?void 0:m[i])==null?void 0:v[o])==null?void 0:M.pages)!=null&&k[a]&&(delete this.authStorage.pageAuth[i][o].pages[a],r&&((E=this.plugin)==null||E.updateAttributes([this.authSpace,"pageAuth",i,o,"pages",a],{})));return}case wt.addElement:{if(!i||!o||!a||!(c!=null&&c.elementId))return;(A=(j=(z=(P=(D=this.authStorage)==null?void 0:D.pageAuth)==null?void 0:P[i])==null?void 0:z[o])==null?void 0:j.pages)!=null&&A[a]&&(this.authStorage.pageAuth[i][o].pages[a][c.elementId]=!0,r&&((R=this.plugin)==null||R.updateAttributes([this.authSpace,"pageAuth",i,o,"pages",a,c.elementId],!0)));return}case wt.deleteElement:{if(!i||!o||!a||!(c!=null&&c.elementId))return;(O=(ie=(H=(Y=(W=(L=this.authStorage)==null?void 0:L.pageAuth)==null?void 0:W[i])==null?void 0:Y[o])==null?void 0:H.pages)==null?void 0:ie[a])!=null&&O[c.elementId]&&(delete this.authStorage.pageAuth[i][o].pages[a][c.elementId],r&&((V=this.plugin)==null||V.updateAttributes([this.authSpace,"pageAuth",i,o,"pages",a,c.elementId],void 0)));return}case wt.clearViewScenePath:{if(!i||!o)return;(ee=($=(Z=this.authStorage)==null?void 0:Z.pageAuth)==null?void 0:$[i])!=null&&ee[o]&&(delete this.authStorage.pageAuth[i][o],r&&((se=this.plugin)==null||se.updateAttributes([this.authSpace,"pageAuth",i,o],void 0)));return}case wt.clearView:{if(!i)return;(me=(ce=this.authStorage)==null?void 0:ce.pageAuth)!=null&&me[i]&&(delete this.authStorage.pageAuth[i],r&&((pe=this.plugin)==null||pe.updateAttributes([this.authSpace,"pageAuth",i],void 0)));return}}}dispatchRenderAuth(e,r=!0){var l,u,h,d,f,g,y,S,b,I,N,T,p,m,v,M,k,E,D,P;const{operation:n,viewId:i,uid:o,renderData:a,isClear:c}=e;if(i)switch(n){case Mr.setAuth:{if(!a||a.render===void 0&&a.hide===void 0&&a.clear===void 0){this.authStorage.renderAuth&&this.authStorage.renderAuth[i]&&(delete this.authStorage.renderAuth[i],r&&((l=this.plugin)==null||l.updateAttributes([this.authSpace,"renderAuth",i],void 0)));return}const z=[this.authSpace];Object.keys(this.authStorage).length&&z.push("renderAuth");const j=this.authStorage.renderAuth||{};Object.keys(j).length&&z.push(i),j[i]={},this.authStorage.renderAuth=j;const{render:A,hide:R,clear:L}=a;if(A===!0)j[i].render=!0;else if(ye.isSet(A)){j[i].render={};for(const W of A.keys())j[i].render[W]=!0}if(R===!0)j[i].hide=!0;else if(ye.isSet(R)){j[i].hide={};for(const W of R.keys())j[i].hide[W]=!0}if(L===!0)j[i].clear=!0;else if(ye.isSet(L)){j[i].clear={};for(const W of L.keys())j[i].clear[W]=!0}r&&(z.length===1?(u=this.plugin)==null||u.updateAttributes(z,ye.cloneDeep(this.authStorage)):z.length===2?(h=this.plugin)==null||h.updateAttributes(z,ye.cloneDeep(j)):(d=this.plugin)==null||d.updateAttributes(z,ye.cloneDeep(j[i])));return}case Mr.setShow:{if(!o)return;const z=[this.authSpace];Object.keys(this.authStorage).length&&z.push("renderAuth");const j=this.authStorage.renderAuth||{};Object.keys(j).length&&z.push(i),j[i]=j[i]||{},this.authStorage.renderAuth=j,Object.keys(j[i]).length&&z.push("render"),j[i].render=j[i].render||{},j[i].render!==!0&&(Object.keys(j[i].render).length&&z.push(o),j[i].render[o]=!0),j[i].hide!==!0&&((f=j[i].hide)!=null&&f[o])&&(delete j[i].hide[o],r&&((g=this.plugin)==null||g.updateAttributes([this.authSpace,"renderAuth",i,"hide",o],void 0))),r&&(z.length===1?(y=this.plugin)==null||y.updateAttributes(z,ye.cloneDeep(this.authStorage)):z.length===2?(S=this.plugin)==null||S.updateAttributes(z,ye.cloneDeep(j)):z.length===3?(b=this.plugin)==null||b.updateAttributes(z,ye.cloneDeep(j[i])):(I=this.plugin)==null||I.updateAttributes(z,!0));return}case Mr.setHide:{if(!o)return;const z=[this.authSpace];Object.keys(this.authStorage).length&&z.push("renderAuth");const j=this.authStorage.renderAuth||{};Object.keys(j).length&&z.push(i),j[i]=j[i]||{},this.authStorage.renderAuth=j,Object.keys(j[i]).length&&z.push("hide"),j[i].hide=j[i].hide||{},j[i].hide!==!0&&(Object.keys(j[i].hide).length&&z.push(o),j[i].hide[o]=!0),j[i].render!==!0&&((N=j[i].render)!=null&&N[o])&&(delete j[i].render[o],r&&((T=this.plugin)==null||T.updateAttributes([this.authSpace,"renderAuth",i,"render",o],void 0))),r&&(z.length===1?(p=this.plugin)==null||p.updateAttributes(z,ye.cloneDeep(this.authStorage)):z.length===2?(m=this.plugin)==null||m.updateAttributes(z,ye.cloneDeep(j)):z.length===3?(v=this.plugin)==null||v.updateAttributes(z,ye.cloneDeep(j[i])):(M=this.plugin)==null||M.updateAttributes(z,!0));return}case Mr.setClear:{if(!o)return;const z=[this.authSpace];Object.keys(this.authStorage).length&&z.push("renderAuth");const j=this.authStorage.renderAuth||{};Object.keys(j).length&&z.push(i),j[i]=j[i]||{},this.authStorage.renderAuth=j,Object.keys(j[i]).length&&z.push("clear"),j[i].clear=j[i].clear||{},j[i].clear!==!0&&(Object.keys(j[i].clear).length&&z.push(o),c?j[i].clear[o]=!0:delete j[i].clear[o]),r&&(z.length===1?(k=this.plugin)==null||k.updateAttributes(z,ye.cloneDeep(this.authStorage)):z.length===2?(E=this.plugin)==null||E.updateAttributes(z,ye.cloneDeep(j)):z.length===3?(D=this.plugin)==null||D.updateAttributes(z,ye.cloneDeep(j[i])):(P=this.plugin)==null||P.updateAttributes(z,c?!0:void 0));return}}}addAuthStateListener(e){this.authDisposer=Vc(async()=>{const r=this.getAuthSpaceData(),{renderAuth:n,pageAuth:i}=r;let o,a;ye.isEqual(n,this.authStorage.renderAuth)||(o=this.diffAuthFun(this.authStorage.renderAuth||{},n||{}),this.authStorage.renderAuth=n),ye.isEqual(i,this.authStorage.pageAuth)||(a=this.diffAuthPageFun(this.authStorage.pageAuth||{},i||{}),this.authStorage.pageAuth=i),(o||a)&&e(o,a)})}removeAuthStateListener(){this.authDisposer&&this.authDisposer()}diffAuthFun(e,r){const n=at(e),i=at(r),o={};for(const a of i)if(!n.includes(a)||e[a]===void 0){o[a]={newValue:r[a],oldValue:void 0};continue}for(const a of n)if(!ye.isEqual(e[a],r[a])){if(!i.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=at(e),i=at(r),o={};for(const a of i)if(!n.includes(a)||e[a]===void 0){o[a]={newValue:r[a],oldValue:void 0};continue}for(const a of n)if(!ye.isEqual(e[a],r[a])){if(!i.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}};x(Vt,"namespace","PluginState"),x(Vt,"authSpace","PluginAuth"),x(Vt,"globalUndoRedoStackSpace","GlobalUndoRedoStack"),x(Vt,"componentsLimits",[500,1e3]);let Jr=Vt;var nr=(s=>(s[s.Draw=1]="Draw",s[s.Delete=2]="Delete",s[s.Update=3]="Update",s))(nr||{});class H0{constructor(){x(this,"state","pending");x(this,"waiters",new Set)}wait(t){return this.state==="ready"?Promise.resolve("ready"):this.state==="cancelled"?Promise.resolve("cancelled"):new Promise(e=>{let r;const n=i=>{r&&clearTimeout(r),e(i)};this.waiters.add(n),t!==void 0&&(r=setTimeout(()=>{this.waiters.delete(n),e("timeout")},t))})}isReady(){return this.state==="ready"}begin(){this.state="pending"}markReady(){if(this.state==="ready")return;this.state="ready";const t=[...this.waiters];this.waiters.clear(),t.forEach(e=>e("ready"))}cancel(){this.state="cancelled";const t=[...this.waiters];this.waiters.clear(),t.forEach(e=>e("cancelled"))}}class K0e{constructor(){x(this,"roomMembers",[]);x(this,"onChangeHooks",new Set)}setRoomMembers(t){this.executChangeUidHook(this.roomMembers,t),this.roomMembers=t}executChangeUidHook(t,e){const r={online:e.map(n=>{var i;return((i=n.payload)==null?void 0:i.uid)||n.session}),offline:t.map(n=>{var i;return((i=n.payload)==null?void 0:i.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 jp(s,t,e){var r,n;for(const[i,o]of s.entries())((n=(r=o.roomMember)==null?void 0:r.payload)==null?void 0:n.uid)===t&&i!==e&&s.delete(i)}class X0e{constructor(t){x(this,"expirationTime",He.cursor.expirationTime);x(this,"isEnableCursor");x(this,"internalMsgEmitter");x(this,"publicMsgEmitter");x(this,"control");x(this,"eventName","applianc-cursor");x(this,"displayer");x(this,"roomMember");x(this,"animationId");x(this,"maxLastSyncTime");x(this,"willSendEventWorkers",[]);x(this,"willConsumeEventWorkers",new Map);x(this,"sendEventTimerId");x(this,"animationDrawWorkers",new Map);x(this,"animationEventWorkers",new Map);x(this,"drawActiveUids",new Set);x(this,"cursorInfoMap",new Map);x(this,"doneRenderCursorInfoMap",new Map);const{control:e,internalMsgEmitter:r,publicMsgEmitter:n}=t;this.internalMsgEmitter=r,this.publicMsgEmitter=n,this.expirationTime=ye.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:i,type:o}=r;if(((a=this.control.collector)==null?void 0:a.uid)!==n&&o===Ls.Cursor&&(i!=null&&i.length)){if(this.drawActiveUids.has(n))return;const c=this.willConsumeEventWorkers.get(n)||[];for(const l of i){const{viewId:u}=l;ye.isNumber(l.consumPoint[0])&&ye.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 i of this.drawActiveUids)e.has(i)||this.drawActiveUids.delete(i);for(const[i,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(i)}}getKey(t,e){return`${t}${Bt}${e}`}getUidAndviewId(t){const[e,r]=t.split(Bt);return{uid:e,viewId:r}}removeRenderedCursorByUid(t,e){var r,n;for(const[i,o]of this.cursorInfoMap.entries()){if(!o||i===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(i),this.doneRenderCursorInfoMap.delete(i),this.internalMsgEmitter.emit([We.Cursor,i],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,i]of this.cursorInfoMap.entries()){if(!i)continue;let o=!1;for(const[a,c]of i.entries())c.type===0&&((r=(e=c.roomMember)==null?void 0:e.payload)==null?void 0:r.uid)===t&&(i.delete(a),o=!0);o&&(i.size===0&&this.cursorInfoMap.delete(n),this.doneRenderCursorInfoMap.delete(n),this.internalMsgEmitter.emit([We.Cursor,n],i.size?Array.from(i.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:i,uid:o}=this.getUidAndviewId(r);o!==((e=this.control.collector)==null?void 0:e.uid)&&i!==t&&n.workState===de.Done&&(n.consumPoint=[void 0,void 0])}}animationCursor(){var r,n,i,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:f,workState:g,cursorTool:y}=c,S=this.cursorInfoMap.get(u)||new Map;if(d&&ye.isNumber(d[0])&&ye.isNumber(d[1])&&f+this.expirationTime>t){const b=(r=h.payload)==null?void 0:r.uid;b&&(this.removeRenderedCursorByUid(b,u),jp(S,b,h.memberId)),S.set(h.memberId,{x:d[0],y:d[1],roomMember:h,timestamp:f,type:1,workState:g,cursorTool:y})}else S.delete(h.memberId),this.drawActiveUids.delete(l);S.size?this.cursorInfoMap.set(u,S):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!==de.Done&&e.add(l);else this.cursorInfoMap.delete(a);for(const[a,c]of this.willConsumeEventWorkers.entries()){const l=this.roomMember.getRoomMember(a);if(ye.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:f}=c,g=this.cursorInfoMap.get(u)||new Map;if(h&&ye.isNumber(h[0])&&ye.isNumber(h[1])&&d+this.expirationTime>t){const y=(n=l.payload)==null?void 0:n.uid;y&&(this.removeRenderedCursorByUid(y,u),jp(g,y,l.memberId)),g.set(l.memberId,{x:h[0],y:h[1],roomMember:l,timestamp:d,type:0,cursorTool:f})}else g.delete(l.memberId);g.size?this.cursorInfoMap.set(u,g):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([We.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:f,...g}=d;if(f+this.expirationTime>t)l.push(g);else{const y=(o=(i=g.roomMember)==null?void 0:i.payload)==null?void 0:o.uid;y&&g.type===1&&g.workState!==de.Done&&this.drawActiveUids.delete(y),c.delete(h),c.size===0&&(this.cursorInfoMap.delete(a),this.doneRenderCursorInfoMap.delete(a),this.internalMsgEmitter.emit([We.Cursor,a],[]))}}const u=this.doneRenderCursorInfoMap.get(a);ye.isEqual(u,l)||(this.doneRenderCursorInfoMap.set(a,l),this.internalMsgEmitter.emit([We.Cursor,a],l))}else this.cursorInfoMap.delete(a),this.doneRenderCursorInfoMap.delete(a),this.internalMsgEmitter.emit([We.Cursor,a],[]);(this.willConsumeEventWorkers.size||this.cursorInfoMap.size)&&this.runAnimation()}sendEvent(t,e){var r;if(this.displayer&&ze(this.displayer)){const n=ye.isNumber(t[0])&&ye.isNumber(t[1])&&this.control.viewContainerManager.transformToScenePoint(t,e)||[void 0,void 0];this.willSendEventWorkers.push({consumPoint:n,viewId:e,cursorTool:Nc((r=this.control.worker.getCurrentToolsData())==null?void 0:r.toolsType)}),this.sendEventTimerId||(this.sendEventTimerId=setTimeout(()=>{this.dispatchMagixEvent()},this.maxLastSyncTime))}}dispatchMagixEvent(){var t;this.displayer&&ze(this.displayer)&&this.displayer.isWritable&&this.displayer.dispatchMagixEvent(this.eventName,{type:Ls.Cursor,op:ye.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:i,cursorTool:o}=t;if(r&&e&&n&&i){const h=this.roomMember.getRoomMember(r);if(!h||r===((a=this.control.collector)==null?void 0:a.uid))return;this.dropAllEventCursor(r),n===de.Done?this.drawActiveUids.delete(r):this.drawActiveUids.add(r);const d=this.getKey(r,i);let f=[void 0,void 0];if(ye.isNumber(e[0])&&ye.isNumber(e[1])){const[b,I]=this.control.viewContainerManager.transformToOriginPoint(e,i);f=[b,I]}const g=((c=this.animationDrawWorkers.get(d))==null?void 0:c.cursorTool)||((u=(l=this.cursorInfoMap.get(i))==null?void 0:l.get(h.memberId))==null?void 0:u.cursorTool),y=gye(o,g)||De.pencil,S={consumPoint:f,workState:n,viewId:i,timestamp:this.control.worker.now,cursorTool:y};if(n===de.Start||n===de.Done){const b=this.willConsumeEventWorkers.get(r);n===de.Start&&b&&this.willConsumeEventWorkers.delete(r)}this.animationDrawWorkers.set(d,S),this.runAnimation()}}unabled(){var t;this.displayer&&ze(this.displayer)&&(this.willSendEventWorkers.length=0,this.displayer.dispatchMagixEvent(this.eventName,{type:Ls.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(i=>i.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([We.Cursor,t],[])}stopAnimation(){this.animationId!==void 0&&(cancelAnimationFrame(this.animationId),this.animationId=void 0),this.animationDrawWorkers.clear(),this.willConsumeEventWorkers.clear(),this.animationEventWorkers.clear(),this.drawActiveUids.clear(),this.cursorInfoMap.clear(),this.doneRenderCursorInfoMap.clear(),this.willSendEventWorkers.length=0,this.sendEventTimerId!==void 0&&(clearTimeout(this.sendEventTimerId),this.sendEventTimerId=void 0)}destroy(){var t;(t=this.displayer)==null||t.removeMagixEventListener(this.eventName),this.stopAnimation()}}function $u(s,t,e){const r=e(s);return!!t&&!!r&&t===r}function J0e(s,t){return!s.isService||!s.viewId||s.isAllViews?!0:$u(s.viewId,s.scenePath,t)}function _0e(s,t,e){return J0e(s,e)?!s.viewId||s.isAllViews||t(s.viewId)?"dispatch":"pending":"discard"}class gr{constructor(){x(this,"activeScenePath");x(this,"activeUndoTickerId");x(this,"forceEndedContext");x(this,"useEmtMsg");x(this,"emtType");x(this,"control");x(this,"mainEngine");x(this,"collectListener",(t,e)=>{const r=t;if(r.workState===de.Start)this.forceEndedContext=void 0,this.useEmtMsg=!1;else if(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=tt.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,i;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}(i=this.mainEngine)==null||i.runAnimation()}collectForServiceWorker(t){Dr(()=>{t.forEach(e=>{var r;(r=this.serviceColloctor)==null||r.dispatch(e)})},this.mainEngine.maxLastSyncTime,this.control.hasPolyfillMethod("requestIdleCallback"))}onAbort(t){}abort(t,e){var u;const r=this.lastEmtData,n=(u=this.control)==null?void 0:u.collector,i=e?(n==null?void 0:n.getLocalId(e))||e:void 0,o=r?[r.workId,...r.workIds||[]].filter(h=>h!==void 0).map(h=>h.toString()):[],a=i===void 0||o.some(h=>{const d=(n==null?void 0:n.getLocalId(h))||h;return h===e||d===i}),c=!!r&&(!t||r.viewId===t)&&a,l=!!this.forceEndedContext&&(!t||this.forceEndedContext.viewId===t);if(!c&&!l)return!1;if(c){const h=this.activeUndoTickerId;this.onAbort(h),this.forceEndedContext={viewId:r.viewId,scenePath:this.activeScenePath||r.scenePath},this.lastEmtData=void 0,this.activeScenePath=void 0,this.activeUndoTickerId=void 0}return this.useEmtMsg=!1,c}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 i=this.activeUndoTickerId,o={...n,scenePath:this.activeScenePath||n.scenePath,workState:de.Done};return await this.collect(o,!0),this.forceEndedContext={viewId:n.viewId,scenePath:o.scenePath},(r=tt.InternalMsgEmitter)==null||r.emit(Te.ActiveMethod,!1,n.viewId),i}}recover(t,e){var n;const r=this.forceEndedContext;!this.useEmtMsg||!r||t&&r.viewId!==t||e&&r.scenePath!==e||(this.useEmtMsg=!1,this.forceEndedContext=void 0,tt.InternalMsgEmitter.hasListeners(Te.ActiveMethod)&&((n=tt.InternalMsgEmitter)==null||n.emit(Te.ActiveMethod,!0,r.viewId)))}discardRecovery(t,e){const r=this.forceEndedContext;!r||t&&r.viewId!==t||e&&r.scenePath!==e||(this.useEmtMsg=!1,this.forceEndedContext=void 0)}}function Q0(s,t,e){return`${e.isLocalId(s)?s:e.getLocalId(s)}-${t}`}function eMe(s,t,e){const r=new Map,n=[];for(const i of s){const o=Q0(i,t,e);r.set(i,o),n.push(o)}return{copyNodeKeyBySourceKey:r,expectedWorkIds:n}}class tMe extends gr{constructor(){super(...arguments);x(this,"lastEmtData");x(this,"emitEventType",Te.CopyNode)}collect(e){var l;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:r,viewId:n,requestId:i}=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(),f=this.serviceColloctor.isLocalId(h)?this.serviceColloctor.transformKey(u):h,g=(l=this.serviceColloctor.getStorageData(n,a))==null?void 0:l[f];if(g){if(u===Le){const y=g&&this.copySelector({viewId:n,store:ht(g)});y&&this.pasteSelector({...y,viewId:n,scenePath:a,undoTickerId:c,requestId:i});break}if(g.toolsType===q.Text&&g.opt&&g.opt.workState&&g.opt.workState!==de.Done){const y=g&&this.copyText({viewId:n,store:ht(g)});y&&this.pasteText({...y,viewId:n,scenePath:a,key:f,store:g,undoTickerId:c,requestId:i});break}}}}copyText(e){const{viewId:r,store:n}=e,i=this.control.viewContainerManager.getView(r);if(!this.serviceColloctor||!i)return;const o=i==null?void 0:i.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 S,b;const{bgCenter:r,textCenter:n,store:i,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),f=((S=h.cameraOpt)==null?void 0:S.scale)||1,g=r&&n&&[r[0]-n[0]+d,r[1]-n[1]+d]||[d/f,d/f],y=Q0(o,l,this.serviceColloctor);if(i.toolsType===q.Text&&i.opt){const I=i.opt;if(I&&I.boxPoint&&I.text){I.workState=de.Done;const N=I.boxPoint;I.boxPoint=[Math.round(N[0]+g[0]),Math.round(N[1]+g[1])],I.workState=de.Done;const T=this.control.viewContainerManager.transformToOriginPoint(I.boxPoint,a);this.control.textEditorManager.createTextForMasterController({workId:y,x:T[0],y:T[1],opt:I,scale:((b=h.cameraOpt)==null?void 0:b.scale)||1,type:Tr.Text,isActive:!1,viewId:a,scenePath:c,requestId:u,emitEventType:Te.CopyNode}),this.collectForServiceWorker([{...i,opt:I,type:le.FullWork,workId:y,viewId:a,scenePath:c,needUndoTicker:l,requestId:u,emitEventType:Te.CopyNode}]),l&&this.mainEngine.internalMsgEmitter.emit("finalizeRequested",l,a,[y],c)}}}copySelector(e){var y,S,b,I,N,T,p,m,v;const{viewId:r,store:n}=e,i=this.control.viewContainerManager.getView(r),o=n.selectIds;if(!this.serviceColloctor||!(o!=null&&o.length)||!i)return;const a=new Map,c={offset:{x:0,y:0},cameraOpt:{centerX:((y=i.cameraOpt)==null?void 0:y.centerX)||0,centerY:((S=i.cameraOpt)==null?void 0:S.centerY)||0,scale:((b=i.cameraOpt)==null?void 0:b.scale)||1}},l=this.control.hasOffscreenCanvas&&((I=i.displayer.canvasBgRef.current)==null?void 0:I.getBoundingClientRect())||((N=i.displayer.canvasContainerRef.current)==null?void 0:N.getBoundingClientRect()),u=(p=(T=i.displayer)==null?void 0:T.floatBarRef.current)==null?void 0:p.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],f=h&&i.viewData&&i.viewData.convertToPointInWorld({x:h[0],y:h[1]}),g=d&&i.viewData&&i.viewData.convertToPointInWorld({x:d[0],y:d[1]});f&&g&&(c.offset={x:f.x-g.x,y:f.y-g.y});for(const M of o){const k=this.serviceColloctor.isLocalId(M)?this.serviceColloctor.transformKey(M):M,E=(v=(m=this.serviceColloctor)==null?void 0:m.getStorageData(i.id,i.focusScenePath))==null?void 0:v[k];E&&a.set(M,ht(E))}return{copyStores:a,copyCoordInfo:c}}pasteSelector(e){var N,T,p,m;const{copyStores:r,copyCoordInfo:n,viewId:i,scenePath:o,undoTickerId:a,requestId:c}=e,l=this.control.viewContainerManager.getView(i);if(!r.size||!this.serviceColloctor||!l)return;const{offset:u,cameraOpt:h}=n,{scale:d}=h,f=Math.floor(Math.random()*30+1),g=u&&[u.x+f,u.y+f]||[f/d,f/d],y=[],S=[],{copyNodeKeyBySourceKey:b,expectedWorkIds:I}=eMe(r.keys(),a,this.serviceColloctor);a&&I.length&&this.mainEngine.internalMsgEmitter.emit("finalizeRequested",a,i,I,o);for(const[v,M]of r.entries()){const k=b.get(v);if(!k)continue;const E={useAnimation:!1};if(M.toolsType===q.Text&&M.opt){const D=M.opt;if(D&&D.boxPoint&&D.text){D.workState=de.Done;const P=D.boxPoint;D.boxPoint=[Math.round(P[0]+g[0]),Math.round(P[1]+g[1])],D.workState=de.Done;const z=this.control.viewContainerManager.transformToOriginPoint(D.boxPoint,i);this.control.textEditorManager.createTextForMasterController({workId:k,x:z[0],y:z[1],opt:D,scale:((N=l.cameraOpt)==null?void 0:N.scale)||1,type:Tr.Text,isActive:!1,viewId:i,scenePath:o,requestId:c,emitEventType:Te.CopyNode})}S.push({...M,opt:D,type:le.FullWork,workId:k,viewId:i,scenePath:o,requestId:c,needUndoTicker:a,emitEventType:Te.CopyNode});continue}if((M.toolsType===q.Image||M.toolsType===q.BackgroundSVG)&&(M.opt.uuid=k,M.opt.centerX=M.opt.centerX+g[0],M.opt.centerY=M.opt.centerY+g[1]),M.ops){const D=Nn(M.ops).map((z,j)=>{const A=j%3;return A===0?z+g[0]:A===1?z+g[1]:z}),P=xt(D);M.ops=P}if((T=M==null?void 0:M.opt)!=null&&T.eraserlines&&(p=M==null?void 0:M.opt)!=null&&p.eraserlines.length)for(const D of(m=M==null?void 0:M.opt)==null?void 0:m.eraserlines){const{op:P}=D;for(let z=0;z<P.length;z++){const j=P[z].map((A,R)=>R%2?A+g[1]:A+g[0]);D.op[z]=j}}S.push({...M,updateNodeOpt:E,type:le.FullWork,workId:k,viewId:i,scenePath:o,requestId:c,needUndoTicker:a,emitEventType:Te.CopyNode}),y.push([{...M,updateNodeOpt:E,workId:k,msgType:le.FullWork,dataType:xe.Local,emitEventType:Te.CopyNode,willSyncService:!1,willRefresh:!0,viewId:i,scenePath:o,requestId:c,needUndoTicker:this.control.viewContainerManager.getUndoTickerId(i),isRunBackgroundThread:this.control.isUseBackgroundThread},{workId:k,msgType:le.FullWork,emitEventType:Te.CopyNode}])}y.length&&this.collectForLocalWorker(y),S.length&&this.collectForServiceWorker(S)}}class rMe extends gr{constructor(){super(...arguments);x(this,"lastEmtData");x(this,"emitEventType",Te.SetColorNode);x(this,"undoTickerId")}onAbort(e){this.undoTickerId=void 0,this.control.textEditorManager.UndoTickerId===e&&(this.control.textEditorManager.UndoTickerId=void 0)}ensureUndoTicker(e,r,n,i){if(!(n===de.Start||n===de.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,i,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:i,canSync:!0,canWorker:!0,requestId:o,needUndoTicker:a}))}collect(e,r){var m,v;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:n,strokeColor:i,fillColor:o,fontColor:a,fontBgColor:c,viewId:l,workState:u,thickness:h,strokeType:d,requestId:f}=e,g=this.control.viewContainerManager.getView(l);if(!(g!=null&&g.displayer))return;if(u===de.Start)this.activeScenePath=e.scenePath||g.focusScenePath;else if(u===de.Doing&&!this.activeScenePath)return;const y=e.scenePath||this.activeScenePath||g.focusScenePath;u!==de.Done&&(this.lastEmtData={...e,scenePath:y});const S=[...n],b=this.serviceColloctor.storage,I=[],N={},T=this.ensureUndoTicker(l,y,u,n);this.undoTickerId&&(this.control.textEditorManager.UndoTickerId=this.undoTickerId);const p=new Set;for(;S.length;){const M=S.pop();if(!M)continue;const k=M.toString(),E=this.serviceColloctor.isLocalId(k),D=E?this.serviceColloctor.transformKey(M):k;let P=k;!E&&this.serviceColloctor.isOwn(P)&&(P=this.serviceColloctor.getLocalId(P));const z=(v=(m=b==null?void 0:b[l])==null?void 0:m[y])==null?void 0:v[D];if(z){const j=z.updateNodeOpt||{};if(a||c){if(a){j.fontColor=a;const[R,L,W,Y]=As(a);N.textColor=[R,L,W],N.textOpacity=Y}if(c)if(j.fontBgColor=ea(c)?"transparent":c,ea(c))N.textBgColor=void 0,N.textBgOpacity=void 0;else{const[R,L,W,Y]=As(c);N.textBgColor=[R,L,W],N.textBgOpacity=Y}if(z.toolsType===q.Text&&z.opt&&u!==de.Start){P&&u===de.Done&&p.add(P.toString()),this.setTextColor(P,ht(z),j,l,f,u===de.Done&&T||void 0);continue}}if(i){j.strokeColor=i;const[R,L,W,Y]=As(i);N.strokeColor=[R,L,W],N.strokeOpacity=Y}if(o)if(j.fillColor=ea(o)?"transparent":o,ea(o))N.fillColor=void 0,N.fillOpacity=void 0;else{const[R,L,W,Y]=As(o);N.fillColor=[R,L,W],N.fillOpacity=Y}h&&(j.thickness=h,N.strokeWidth=h),d&&(N.strokeType=d,j.strokeType=d,j.lineCap=this.control.getLineCap(d),j.lineDash=this.control.getLineDash(d));const A={workId:P,msgType:le.UpdateNode,dataType:xe.Local,updateNodeOpt:j,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,textUpdateForWoker:!0,viewId:l,scenePath:y,requestId:f,needUndoTicker:u===de.Done&&T||void 0};P&&u===de.Done&&p.add(P.toString()),I.push([A,{workId:P,msgType:le.UpdateNode,emitEventType:this.emitEventType}])}}if(u===de.Done&&T){const M=[...p];M.length&&this.mainEngine.internalMsgEmitter.emit("finalizeRequested",T,l,M,y)}I.length?(u===de.Done&&(this.undoTickerId=void 0,this.control.textEditorManager.UndoTickerId=void 0),this.collectForLocalWorker(I,r)):u===de.Done&&(this.undoTickerId=void 0,this.control.textEditorManager.UndoTickerId=void 0),Object.keys(N).length&&setTimeout(()=>{var M;(M=this.control.room)==null||M.setMemberState(N)},0),u===de.Done&&(this.lastEmtData=void 0,this.activeScenePath=void 0,this.activeUndoTickerId=void 0)}}class nMe extends gr{constructor(){super(...arguments);x(this,"lastEmtData");x(this,"emitEventType",Te.ZIndexNode);x(this,"zIndexMap",new Map);x(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,i)=>n[1]-i[1]);for(let n=1;n<r.length;n++){const i=r[n][1],o=r[n-1][1];i<=o&&(r[n][1]=o+1)}return r}collect(e){var S,b;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:r,layer:n,viewId:i,requestId:o}=e,a=this.control.viewContainerManager.getView(i);if(!(a!=null&&a.displayer))return;const c=a.focusScenePath,l=[...r],u=this.serviceColloctor.storage,h=[],d=[],f=[],g=this.mainEngine.now;for(this.mainEngine.internalMsgEmitter.emit("addUndoTicker",g,i,{render:!0,storage:!0,source:$e.AsyncZIndexNode});l.length;){const I=l.pop();if(!I)continue;const N=I.toString(),T=this.serviceColloctor.isLocalId(N),p=T?this.serviceColloctor.transformKey(I):N;let m=N;!T&&this.serviceColloctor.isOwn(m)&&(m=this.serviceColloctor.getLocalId(m));const v=ht(u[i][c][p]);let M,k;if(v&&m===Le){if(v.selectIds){for(const P of v.selectIds){const z=y(P,this.serviceColloctor),j=(b=(S=u==null?void 0:u[i])==null?void 0:S[c])==null?void 0:b[z];j&&j.toolsType===q.BackgroundSVG?(f.push(P),f.sort((A,R)=>{var Y,H,ie,O;const L=((H=(Y=u[y(A,this.serviceColloctor)])==null?void 0:Y.opt)==null?void 0:H.zIndex)||0,W=((O=(ie=u[y(A,this.serviceColloctor)])==null?void 0:ie.opt)==null?void 0:O.zIndex)||0;return L>W?1:A<R?-1:0})):(d.push(P),d.sort((A,R)=>{var Y,H,ie,O;const L=((H=(Y=u[y(A,this.serviceColloctor)])==null?void 0:Y.opt)==null?void 0:H.zIndex)||0,W=((O=(ie=u[y(A,this.serviceColloctor)])==null?void 0:ie.opt)==null?void 0:O.zIndex)||0;return L>W?1:A<R?-1:0}))}const E=v.updateNodeOpt||{};E.zIndexLayer=n;const D={workId:I,msgType:le.UpdateNode,dataType:xe.Local,updateNodeOpt:E,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:i,requestId:o,needUndoTicker:this.control.viewContainerManager.getUndoTickerId(i)};d.length&&(n===Cn.Top?(this.addMaxLayer(i),M=this.getMaxZIndex(i)):(this.addMinLayer(i),M=this.getMinZIndex(i)),d.forEach(P=>{var R,L,W,Y,H;const z=(R=this.serviceColloctor)==null?void 0:R.isLocalId(P);let j=z&&((L=this.serviceColloctor)==null?void 0:L.transformKey(P))||P;const A=(Y=(W=u==null?void 0:u[i])==null?void 0:W[c])==null?void 0:Y[j];A&&(!z&&((H=this.serviceColloctor)!=null&&H.isOwn(j))&&(j=this.serviceColloctor.getLocalId(j)),E.zIndex=M,A!=null&&A.opt&&(A.opt.zIndex=M))})),f.length&&(n===Cn.Top?(this.addMaxLayerForBackgroundSVG(i),k=this.getMaxZIndexForBackgroundSVG(i)):(this.addMinLayerForBackgroundSVG(i),k=this.getMinZIndexForBackgroundSVG(i)),f.forEach(P=>{var R,L,W,Y,H;const z=(R=this.serviceColloctor)==null?void 0:R.isLocalId(P);let j=z&&((L=this.serviceColloctor)==null?void 0:L.transformKey(P))||P;const A=(Y=(W=u==null?void 0:u[i])==null?void 0:W[c])==null?void 0:Y[j];A&&(!z&&((H=this.serviceColloctor)!=null&&H.isOwn(j))&&(j=this.serviceColloctor.getLocalId(j)),E.zIndexForBackgroundSVG=k,A!=null&&A.opt&&(A.opt.zIndex=k))})),D.willSerializeData=!0,h.push([D,{workId:I,msgType:le.UpdateNode,emitEventType:this.emitEventType}])}continue}}h.length&&(this.mainEngine.internalMsgEmitter.emit("finalizeRequested",g,i,h.map(([I])=>{var N;return(N=I.workId)==null?void 0:N.toString()}).filter(Boolean),c),this.collectForLocalWorker(h));function y(I,N){return N.isLocalId(I)&&N.transformKey(I)||I}}}class iMe extends gr{constructor(){super(...arguments);x(this,"lastEmtData");x(this,"emitEventType",Te.TranslateNode);x(this,"cachePosition")}onAbort(){this.cachePosition=void 0}collect(e,r){var y,S,b;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:n,position:i,workState:o,viewId:a}=e,c=this.control.viewContainerManager.getView(a);if(!(c!=null&&c.displayer))return;if(o===de.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=(y=this.serviceColloctor)==null?void 0:y.storage,d=[],f=new Set,g=o===de.Start&&this.mainEngine.now||void 0;for(g&&(this.activeUndoTickerId=g,this.mainEngine.internalMsgEmitter.emit("addUndoTicker",g,a,{render:!0,storage:!0,isWritable:!0,source:$e.MethodTranslateNode}));u.length;){const I=u.pop();if(!I)continue;const N=I.toString(),T=this.serviceColloctor.isLocalId(N),p=T&&this.serviceColloctor.transformKey(I)||N;let m=N;!T&&this.serviceColloctor.isOwn(m)&&(m=this.serviceColloctor.getLocalId(m));const v=(b=(S=h==null?void 0:h[a])==null?void 0:S[l])==null?void 0:b[p];if(v&&m===Le){if(v.selectIds){o===de.Done&&v.selectIds.forEach(k=>{f.add(k.toString())});const M=this.control.viewContainerManager.transformToScenePoint([i.x,i.y],a);if(o===de.Start&&(this.cachePosition=M),this.cachePosition){const k=v.updateNodeOpt||{};k.translate=[M[0]-this.cachePosition[0],M[1]-this.cachePosition[1]],k.workState=o,this.control.cursor.isEnableCursor?k.useAnimation=!1:(k.uid=this.serviceColloctor.uid,o===de.Start?k.useAnimation=!1:o===de.Done&&(k.useAnimation=!0));const E={workId:I,msgType:le.UpdateNode,dataType:xe.Local,updateNodeOpt:k,emitEventType:this.emitEventType,willSyncService:!0,textUpdateForWoker:!0,viewId:a,scenePath:l,smoothSync:this.mainEngine.smoothSync};o===de.Done&&(E.textUpdateForWoker=!0,E.willSerializeData=!0,this.cachePosition=void 0,E.needUndoTicker=this.activeUndoTickerId),d.push([E,{workId:I,msgType:le.UpdateNode,emitEventType:this.emitEventType,workState:o}])}}continue}}if(o===de.Start?this.mainEngine.unWritable():o===de.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),d.length){if(o===de.Done){const I=this.activeUndoTickerId;if(I){const N=[...f];this.mainEngine.internalMsgEmitter.emit("finalizeRequested",I,a,N,l)}}this.collectForLocalWorker(d,r)}o===de.Done&&(this.activeScenePath=void 0,this.activeUndoTickerId=void 0)}}class sMe extends gr{constructor(){super(...arguments);x(this,"lastEmtData");x(this,"emitEventType",Te.DeleteNode)}collect(e){var f,g;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:r,viewId:n,requestId:i}=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 y=l.pop();if(!y)continue;const S=y.toString(),b=this.serviceColloctor.isLocalId(S),I=b?this.serviceColloctor.transformKey(y):S,N=(g=(f=c==null?void 0:c[n])==null?void 0:f[a])==null?void 0:g[I];if(N){let T=S;if(!b&&this.serviceColloctor.isOwn(T)&&(T=this.serviceColloctor.getLocalId(T)),N.toolsType===q.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:le.RemoveNode,emitEventType:Te.DeleteNode,removeIds:h,dataType:xe.Local,willSyncService:!0,willRefresh:!0,viewId:n,requestId:i,isRunBackgroundThread:this.control.isUseBackgroundThread,needUndoTicker:this.control.viewContainerManager.getUndoTickerId(n)},void 0]),this.collectForLocalWorker(u))}}class oMe extends gr{constructor(){super(...arguments);x(this,"lastEmtData");x(this,"emitEventType",Te.ScaleNode);x(this,"targetText",new Map);x(this,"cacheTextInfo",new Map)}onAbort(e){this.targetText.clear(),this.cacheTextInfo.clear(),this.control.textEditorManager.UndoTickerId===e&&(this.control.textEditorManager.UndoTickerId=void 0)}async setTextStyle(e,r,n){const i=await this.control.textEditorManager.updateTextControllerWithEffectAsync({workId:e,opt:r,viewId:n,canSync:!1,canWorker:!1});return{key:e,textInfo:i}}async collect(e,r){var I,N,T,p,m,v,M;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:n,workState:i,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(i===de.Start)this.activeScenePath=e.scenePath||d.focusScenePath;else if(!this.activeScenePath)return;const f=e.scenePath||this.activeScenePath;this.lastEmtData={...e,scenePath:f};const g=[...n],y=(I=this.serviceColloctor)==null?void 0:I.storage,S=[],b=i===de.Start&&this.mainEngine.now||void 0;for(b&&(this.activeUndoTickerId=b,this.mainEngine.internalMsgEmitter.emit("addUndoTicker",b,o,{render:!0,storage:!0,isWritable:!0,source:$e.MethodScaleNode}),this.control.textEditorManager.UndoTickerId=b);g.length;){const k=g.pop();if(!k)continue;const E=k.toString(),D=this.serviceColloctor.isLocalId(E),P=D&&this.serviceColloctor.transformKey(k)||E;let z=E;!D&&this.serviceColloctor.isOwn(z)&&(z=this.serviceColloctor.getLocalId(z));const j=(T=(N=y==null?void 0:y[o])==null?void 0:N[f])==null?void 0:T[P];if(j&&z===Le&&j.selectIds){const A=j.updateNodeOpt||{};if(A.dir=l,A.originPoint=a,A.scenePoint=c,A.workState=i,A.scale=u,A.translate=h,i===de.Start){this.cacheTextInfo.clear();for(const L of j.selectIds){const W=(p=this.serviceColloctor)==null?void 0:p.isLocalId(L),Y=W&&((m=this.serviceColloctor)==null?void 0:m.transformKey(L))||L;let H=Y;!W&&((v=this.serviceColloctor)!=null&&v.isOwn(Y))&&(H=this.serviceColloctor.getLocalId(Y));const ie=this.control.textEditorManager.get(H);ie&&i===de.Start&&this.targetText.set(H,ht(ie))}}if(this.targetText.size&&i!==de.Start&&u){const L=[];for(const[Y,H]of this.targetText.entries()){const{opt:ie}=H,O=Math.floor(ie.fontSize*u[0]),V=this.cacheTextInfo.get(Y),Z=!V&&ie.fontSize!==O||V&&V.fontSize!==O||!1,$=(M=this.control.textEditorManager.get(Y))==null?void 0:M.opt;if(Z&&$&&ie.boxSize&&ie.boxPoint){const ee=this.setTextStyle(Y,{...$,fontSize:O},o);L.push(ee)}}const W=await Promise.all(L);for(const Y of W)if(Y){const{key:H,textInfo:ie}=Y;this.cacheTextInfo.set(H,{fontSize:ie.opt.fontSize,boxSize:ie.opt.boxSize,boxPoint:ie.opt.boxPoint})}A.textInfos=this.cacheTextInfo}this.control.cursor.isEnableCursor?A.useAnimation=!1:(A.uid=this.serviceColloctor.uid,i===de.Start?A.useAnimation=!1:i===de.Done&&(A.useAnimation=!0));const R={workId:k,msgType:le.UpdateNode,dataType:xe.Local,updateNodeOpt:A,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:o,scenePath:f,smoothSync:this.mainEngine.smoothSync};i===de.Done&&(R.willSerializeData=!0,this.targetText.clear(),R.needUndoTicker=this.activeUndoTickerId),S.push([R,{workId:k,msgType:le.UpdateNode,emitEventType:this.emitEventType,workState:i}]);continue}}if(i===de.Start?this.mainEngine.unWritable():i===de.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),S.length){if(i===de.Done){const k=this.activeUndoTickerId;k&&this.mainEngine.internalMsgEmitter.emit("finalizeRequested",k,o,S.map(([E])=>{var D;return(D=E.workId)==null?void 0:D.toString()}).filter(Boolean),f)}this.collectForLocalWorker(S,r)}i===de.Done&&(this.activeScenePath=void 0,this.activeUndoTickerId=void 0)}}class aMe extends gr{constructor(){super(...arguments);x(this,"lastEmtData");x(this,"emitEventType",Te.RotateNode);x(this,"cacheOriginRotate",0)}onAbort(){this.cacheOriginRotate=0}collect(e,r){var y,S,b,I,N,T,p;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:n,angle:i,workState:o,viewId:a}=e,c=this.control.viewContainerManager.getView(a);if(!(c!=null&&c.displayer))return;if(o===de.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=(y=this.serviceColloctor)==null?void 0:y.storage,d=[],f=new Set,g=o===de.Start&&this.mainEngine.now||void 0;for(g&&(this.activeUndoTickerId=g,this.mainEngine.internalMsgEmitter.emit("addUndoTicker",g,a,{render:!0,storage:!0,isWritable:!0,source:$e.MethodRotateNode}));u.length;){const m=u.pop();if(!m)continue;const v=m.toString(),M=this.serviceColloctor.isLocalId(v),k=M&&this.serviceColloctor.transformKey(m)||v;let E=v;!M&&this.serviceColloctor.isOwn(E)&&(E=this.serviceColloctor.getLocalId(E));const D=(b=(S=h==null?void 0:h[a])==null?void 0:S[l])==null?void 0:b[k];if(D&&E===Le){if(((I=D.selectIds)==null?void 0:I.length)===1){const P=D.selectIds[0];if(o===de.Done&&f.add(P.toString()),o===de.Start){const R=((N=this.serviceColloctor)==null?void 0:N.isLocalId(P))&&((T=this.serviceColloctor)==null?void 0:T.transformKey(P))||P,L=h[a][l][R];this.cacheOriginRotate=((p=L==null?void 0:L.opt)==null?void 0:p.rotate)||0}const z=D.updateNodeOpt||{};z.angle=(i+this.cacheOriginRotate)%360,z.workState=o,this.control.cursor.isEnableCursor?z.useAnimation=!1:(z.uid=this.serviceColloctor.uid,o===de.Start?z.useAnimation=!1:o===de.Done&&(z.useAnimation=!0));const j={workId:m,msgType:le.UpdateNode,dataType:xe.Local,updateNodeOpt:z,emitEventType:this.emitEventType,willRefreshSelector:!1,willSyncService:!0,viewId:a,scenePath:l,smoothSync:this.mainEngine.smoothSync};o===de.Done&&(j.willRefreshSelector=!0,j.willSerializeData=!0,this.cacheOriginRotate=0,j.needUndoTicker=this.activeUndoTickerId),d.push([j,{workId:m,msgType:le.UpdateNode,emitEventType:this.emitEventType,workState:o}])}continue}}if(o===de.Start?this.mainEngine.unWritable():o===de.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),d.length){if(o===de.Done){const m=this.activeUndoTickerId;if(m){const v=[...f];this.mainEngine.internalMsgEmitter.emit("finalizeRequested",m,a,v,l)}}this.collectForLocalWorker(d,r)}o===de.Done&&(this.activeScenePath=void 0,this.activeUndoTickerId=void 0)}}class cMe extends gr{constructor(){super(...arguments);x(this,"lastEmtData");x(this,"emitEventType",Te.SetFontStyle);x(this,"timerId")}async setTextStyle(e,r,n,i,o,a){const{bold:c,underline:l,lineThrough:u,italic:h,fontSize:d}=n;if(r.toolsType&&mye(r.toolsType)===Tr.Text){r.opt&&(c&&(r.opt.bold=c),ye.isBoolean(l)&&(r.opt.underline=l),ye.isBoolean(u)&&(r.opt.lineThrough=u),h&&(r.opt.italic=h),d&&(r.opt.fontSize=d));const g=await this.control.textEditorManager.updateTextControllerWithEffectAsync({workId:e,opt:r.opt,viewId:i,canSync:!1,canWorker:!1,requestId:o,needUndoTicker:a});return{key:e,textInfo:g}}}async collect(e){var p,m,v,M,k,E;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:r,bold:n,italic:i,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,f=[...r],g=this.serviceColloctor.storage,y={},S=this.mainEngine.now;this.mainEngine.internalMsgEmitter.emit("addUndoTicker",S,c,{render:!0,storage:!0,source:$e.AsyncSetFontStyle}),this.control.textEditorManager.UndoTickerId=S;const b=new Set,I=[];for(;f.length;){const D=f.pop();if(!D)continue;const P=D.toString(),z=this.serviceColloctor.isLocalId(P),j=z?this.serviceColloctor.transformKey(D):P;let A=P;!z&&this.serviceColloctor.isOwn(A)&&(A=this.serviceColloctor.getLocalId(A));const R=(m=(p=g==null?void 0:g[c])==null?void 0:p[d])==null?void 0:m[j];if(R){const L=R.updateNodeOpt||{};if(n&&(L.bold=n,y.bold=n==="bold"),i&&(L.italic=i,y.italic=i==="italic"),ye.isBoolean(o)&&(L.lineThrough=o,y.lineThrough=o),ye.isBoolean(a)&&(L.underline=a,y.underline=a),l&&(L.fontSize=l,y.textSize=l),R.toolsType===q.Text&&R.opt){const W=this.setTextStyle(A,ye.cloneDeep(R),L,c,u,S);b.add(A),I.push(W);continue}if(R&&A===Le&&((v=R.selectIds)!=null&&v.length))for(const W of R.selectIds){const Y=(M=this.serviceColloctor)==null?void 0:M.isLocalId(W);let H=Y&&((k=this.serviceColloctor)==null?void 0:k.transformKey(W))||W;const ie=g[c][d][H]||void 0;if(!Y&&((E=this.serviceColloctor)!=null&&E.isOwn(H))&&(H=this.serviceColloctor.getLocalId(H)),ie&&ie.toolsType===q.Text&&ie.opt){const O=this.setTextStyle(H,ye.cloneDeep(ie),L,c,u,S);b.add(H),I.push(O);continue}}}}const N=[...b];if(!N.length){this.mainEngine.internalMsgEmitter.emit("cancelUndoTicker",S,c,d),this.control.textEditorManager.UndoTickerId===S&&(this.control.textEditorManager.UndoTickerId=void 0);return}this.mainEngine.internalMsgEmitter.emit("finalizeRequested",S,c,N,d);const T=await Promise.all(I);for(const D of T)if(D){const{key:P,textInfo:z}=D;z&&(z.canSync=!0,z.canWorker=!0,z.needUndoTicker=S,this.control.textEditorManager.updateForViewEdited(P,z))}Object.keys(y).length&&(this.timerId&&(clearTimeout(this.timerId),this.timerId=void 0),this.timerId=setTimeout(()=>{var D;this.timerId=void 0,(D=this.control.room)==null||D.setMemberState(y)},0))}}class lMe extends gr{constructor(){super(...arguments);x(this,"lastEmtData");x(this,"emitEventType",Te.SetPoint)}collect(e,r){var N,T,p;if(!this.serviceColloctor||!this.mainEngine)return;const{workId:n,pointMap:i,workState:o,viewId:a}=e,c=this.control.viewContainerManager.getView(a);if(!(c!=null&&c.displayer))return;if(o===de.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=this.serviceColloctor)==null?void 0:N.storage,h=[],d=o===de.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 f=n;if(!f)return;const g=f.toString(),y=this.serviceColloctor.isLocalId(g),S=y&&this.serviceColloctor.transformKey(f)||g;let b=g;!y&&this.serviceColloctor.isOwn(b)&&(b=this.serviceColloctor.getLocalId(b));const I=(p=(T=u==null?void 0:u[a])==null?void 0:T[l])==null?void 0:p[S];if(I&&b===Le&&I.selectIds){const m=I.updateNodeOpt||{};m.pointMap=i,m.workState=o;const v={workId:f,msgType:le.UpdateNode,dataType:xe.Local,updateNodeOpt:m,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:a,scenePath:l,needUndoTicker:o===de.Done&&this.activeUndoTickerId||void 0};h.push([v,{workId:f,msgType:le.UpdateNode,emitEventType:this.emitEventType}])}o===de.Start?this.mainEngine.unWritable():o===de.Done&&this.mainEngine.abled(),h.length&&(o===de.Done&&this.activeUndoTickerId&&this.mainEngine.internalMsgEmitter.emit("finalizeRequested",this.activeUndoTickerId,a,h.map(([m])=>{var v;return(v=m.workId)==null?void 0:v.toString()}).filter(Boolean),l),this.collectForLocalWorker(h,r)),o===de.Done&&(this.lastEmtData=void 0,this.activeScenePath=void 0,this.activeUndoTickerId=void 0)}}class uMe extends gr{constructor(){super(...arguments);x(this,"lastEmtData");x(this,"emitEventType",Te.SetLock)}collect(e){var f,g;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:r,isLocked:n,viewId:i,requestId:o}=e,a=this.control.viewContainerManager.getView(i);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,i,{render:!0,storage:!0,source:$e.AsyncSetLock});l.length;){const y=l.pop();if(!y)continue;const S=y.toString(),b=this.serviceColloctor.isLocalId(S),I=b?this.serviceColloctor.transformKey(y):S;let N=S;!b&&this.serviceColloctor.isOwn(N)&&(N=this.serviceColloctor.getLocalId(N));const T=(g=(f=u==null?void 0:u[i])==null?void 0:f[c])==null?void 0:g[I];if(T){const p=T.updateNodeOpt||{};p.isLocked=n;const m={workId:N,msgType:le.UpdateNode,dataType:xe.Local,updateNodeOpt:p,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,viewId:i,requestId:o,needUndoTicker:this.control.viewContainerManager.getUndoTickerId(i)};h.push([m,{workId:N,msgType:le.UpdateNode,emitEventType:this.emitEventType}])}}h.length&&(this.mainEngine.internalMsgEmitter.emit("finalizeRequested",d,i,h.map(([y])=>{var S;return(S=y.workId)==null?void 0:S.toString()}).filter(Boolean),c),this.collectForLocalWorker(h))}}class hMe extends gr{constructor(){super(...arguments);x(this,"lastEmtData");x(this,"emitEventType",Te.SetShapeOpt)}collect(e){var f,g;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:r,viewId:n,requestId:i,...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 y=l.pop();if(!y)continue;const S=y.toString(),b=this.serviceColloctor.isLocalId(S),I=b?this.serviceColloctor.transformKey(y):S;let N=S;!b&&this.serviceColloctor.isOwn(N)&&(N=this.serviceColloctor.getLocalId(N));const T=(g=(f=u==null?void 0:u[n])==null?void 0:f[c])==null?void 0:g[I];if(T){const p={...T.updateNodeOpt,...o,willRefresh:!0};if(T&&N===Le){const m={workId:N,msgType:le.UpdateNode,dataType:xe.Local,updateNodeOpt:p,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,viewId:n,requestId:i,needUndoTicker:this.control.viewContainerManager.getUndoTickerId(n)};h.push([m,{workId:N,msgType:le.UpdateNode,emitEventType:this.emitEventType}])}}}h.length&&(this.mainEngine.internalMsgEmitter.emit("finalizeRequested",d,n,h.map(([y])=>{var S;return(S=y.workId)==null?void 0:S.toString()}).filter(Boolean),c),this.collectForLocalWorker(h))}}const Fp=[Te.TranslateNode,Te.ScaleNode,Te.RotateNode,Te.SetPoint,Te.SetColorNode];class Ve{constructor(t){x(this,"builders",new Map);this.builders=new Map(t.map(e=>[e,this.build(e)]))}build(t){switch(t){case Te.TranslateNode:return new iMe;case Te.ZIndexNode:return new nMe;case Te.CopyNode:return new tMe;case Te.SetColorNode:return new rMe;case Te.DeleteNode:return new sMe;case Te.ScaleNode:return new oMe;case Te.RotateNode:return new aMe;case Te.SetFontStyle:return new cMe;case Te.SetPoint:return new lMe;case Te.SetLock:return new uMe;case Te.SetShapeOpt:return new hMe}}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){return(await Promise.all(Fp.map(n=>{var i;return(i=this.builders.get(n))==null?void 0:i.pause(t,e)}))).filter(n=>n!==void 0)}abortActiveContinuousMethods(t,e){var n;let r=!1;return Fp.forEach(i=>{var o;r=((o=this.builders.get(i))==null?void 0:o.abort(t,e))||r}),r&&((n=tt.InternalMsgEmitter)==null||n.emit(Te.ActiveMethod,!1,t)),r}recover(t,e){return this.builders.forEach(r=>{r&&r.recover(t,e)}),this}discardRecovery(t,e){return this.builders.forEach(r=>{r==null||r.discardRecovery(t,e)}),this}static emitMethod(t,e,r){gr.dispatch(t,e,r)}static activeListener(t){tt.InternalMsgEmitter.on(Te.ActiveMethod,t)}static unmountActiveListener(t){tt.InternalMsgEmitter.off(Te.ActiveMethod,t)}}const dMe="xiaomi-android-webview-offscreen-v1",fMe=new Set(["offscreenTransfer+webgl2","offscreenTransfer+webgl","offscreenTransfer+canvas2d","imageBitmap+webgl2","imageBitmap+webgl","imageBitmap+canvas2d","mainThread+canvas2d"]);function q0(s){return typeof s=="string"&&fMe.has(s)}function gMe(s){if(s==="mainThread+canvas2d")return{renderMode:"main-thread",contextType:"2d"};const[t,e]=s.split("+");return{renderMode:t==="offscreenTransfer"?"worker-offscreen-transfer":"worker-image-bitmap",contextType:e==="canvas2d"?"2d":e}}function Ht(s,t){return s==="main-thread"?"mainThread+canvas2d":`${s==="worker-offscreen-transfer"?"offscreenTransfer":"imageBitmap"}+${t==="2d"?"canvas2d":t}`}function pMe(s,t){return!!(s.fullWorkerUrl&&(t||s.subWorkerUrl))}const mMe={worker:!1,offscreenCanvas:!1,workerUrl:!1,offscreenTransfer:!1,imageBitmap:!1,webgl2:!1,webgl:!1},yMe=new Set(["__proto__","constructor","prototype"]),Hl=64;function wd(s){const e=s.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 yn(s,t){const e=s.match(t);return e?wd(e[1]):void 0}function Z0(s,t){const e=s.split(".").map(Number),r=t.split(".").map(Number);for(let n=0;n<r.length;n+=1){const i=(e[n]??0)-r[n];if(i!==0)return i}return 0}function Sd(s=typeof navigator>"u"?"":navigator.userAgent){if(yn(s,/\bArkWeb\/(\d+(?:\.\d+)*)/i)){const a=yn(s,/\bChrome\/(\d+(?:\.\d+)*)/i);return a?{kind:"harmonyArkWeb",version:a}:void 0}if(/\bAndroid\b/i.test(s)&&(/;\s*wv\)/i.test(s)||/\bVersion\/4\.0\b/i.test(s)&&/\bChrome\/\d+/i.test(s))){const c=yn(s,/\bChrome\/(\d+(?:\.\d+)*)/i);return c?{kind:"androidWebView",version:c}:void 0}const e=yn(s,/\b(?:iPhone|iPad|iPod).*?\bOS\s+(\d+(?:[_.]\d+)*)/i);if(e)return{kind:"iosWebView",version:e};const r=yn(s,/\bEdg(?:A)?\/(\d+(?:\.\d+)*)/i);if(r)return{kind:"web",browser:"edge",version:r};const n=yn(s,/\bChrome\/(\d+(?:\.\d+)*)/i);if(n)return{kind:"web",browser:"chrome",version:n};const i=yn(s,/\bFirefox\/(\d+(?:\.\d+)*)/i);if(i)return{kind:"web",browser:"firefox",version:i};const o=yn(s,/\bVersion\/(\d+(?:\.\d+)*).*\bSafari\//i);return o?{kind:"web",browser:"safari",version:o}:void 0}function vMe(s,t=Sd(s)){return(t==null?void 0:t.kind)!=="androidWebView"||Z0(t.version,"77")>0?!1:/\b(?:xiaomi|miui|mi[\s_-]*8)\b/i.test(s)}function Td(s){if(!s||typeof s!="object"||Array.isArray(s))return!1;try{const t=Object.getPrototypeOf(s);return t===Object.prototype||t===null}catch{return!1}}function K0(s,t){if(!Number.isInteger(s))return!1;switch(t){case"renderMode":return s===Ar.OffscreenTransfer||s===Ar.ImageBitmap||s===Ar.MainThread;case"canvasContext":return s===Ha.WebGL;case"maskTextureFormat":return s===rh.SingleChannelTexture;case"maskTextureUpload":return s===nh.TextureSubImage2D;case"fontFaceFallback":return s===Js.RefreshTextRender}}function MMe(s,t,e,r=[]){if(!Td(t))return;const n=Object.entries(t);n.length>Hl&&r.push(`worker blacklist exceeds ${Hl} rules`);let i;for(const[o,a]of n.slice(0,Hl)){if(yMe.has(o))continue;const c=wd(o);if(!c||!K0(a,e)){r.push(`invalid ${e} blacklist rule: ${o}`);continue}Z0(s,c)<=0&&(i=i===void 0?a:Math.max(i,a))}return i}function wMe(s,t){var e;return t.kind==="web"?(e=s==null?void 0:s.web)==null?void 0:e[t.browser]:s==null?void 0:s[t.kind]}function Ps(s,t,e){const r=[];if(!Td(s))return{issues:r};if(!t)return r.push(`${e} blacklist runtime version unavailable`),{issues:r};const n=wMe(s,t);return n?{level:MMe(t.version,n,e,r),runtime:t,issues:r}:{runtime:t,issues:r}}function Vn(s,t,e){const r={};for(const n of[s,t])if(Td(n))for(const[i,o]of Object.entries(n)){const a=wd(i);!a||!K0(o,e)||(r[a]=Math.max(r[a]??0,o))}return Object.keys(r).length>0?r:void 0}function Ts(s,t,e){var i,o,a,c,l,u,h,d;const r={chrome:Vn((i=s==null?void 0:s.web)==null?void 0:i.chrome,(o=t==null?void 0:t.web)==null?void 0:o.chrome,e),edge:Vn((a=s==null?void 0:s.web)==null?void 0:a.edge,(c=t==null?void 0:t.web)==null?void 0:c.edge,e),firefox:Vn((l=s==null?void 0:s.web)==null?void 0:l.firefox,(u=t==null?void 0:t.web)==null?void 0:u.firefox,e),safari:Vn((h=s==null?void 0:s.web)==null?void 0:h.safari,(d=t==null?void 0:t.web)==null?void 0:d.safari,e)},n={androidWebView:Vn(s==null?void 0:s.androidWebView,t==null?void 0:t.androidWebView,e),iosWebView:Vn(s==null?void 0:s.iosWebView,t==null?void 0:t.iosWebView,e),harmonyArkWeb:Vn(s==null?void 0:s.harmonyArkWeb,t==null?void 0:t.harmonyArkWeb,e),web:Object.values(r).some(Boolean)?r:void 0};return Object.fromEntries(Object.entries(n).filter(([,f])=>f!==void 0))}function SMe(s,t=typeof navigator>"u"?"":navigator.userAgent){const e=Sd(t);return Ps(s,e,"fontFaceFallback").level===Js.RefreshTextRender}function Up(s){var t,e;if(typeof OffscreenCanvas!="function")return!1;try{const r=new OffscreenCanvas(1,1).getContext(s);return r?((e=(t=r.getExtension)==null?void 0:t.call(r,"WEBGL_lose_context"))==null||e.loseContext(),!0):!1}catch{return!1}}function TMe(){if(typeof OffscreenCanvas!="function")return!1;try{return!!new OffscreenCanvas(1,1).getContext("2d")}catch{return!1}}function IMe(){return typeof OffscreenCanvas=="function"&&typeof OffscreenCanvas.prototype.transferToImageBitmap=="function"}function CMe(s=!0){const t=typeof OffscreenCanvas=="function",e=typeof CanvasRenderingContext2D=="function"&&typeof CanvasRenderingContext2D.prototype.drawImage=="function";return{worker:typeof Worker=="function",offscreenCanvas:t,workerUrl:s,offscreenTransfer:typeof HTMLCanvasElement=="function"&&typeof HTMLCanvasElement.prototype.transferControlToOffscreen=="function",imageBitmap:t&&TMe()&&IMe()&&e,webgl2:Up("webgl2"),webgl:Up("webgl")}}function bMe(s,t,e,r){return s==="main-thread"||t==="2d"||e===Ha.WebGL?"2d":t==="webgl"?r.webgl?"webgl":"2d":r.webgl2?"webgl2":r.webgl?"webgl":"2d"}function EMe(s){const t=s.userAgent??(typeof navigator>"u"?"":navigator.userAgent),e=s.capabilities??(s.useWorker==="mainThread"?mMe:CMe(s.workerUrl)),r=Sd(t),n=s.allowImageBitmapFallback!==!1,i=[],o=Ps(s.workerRenderModeBlacklist,r,"renderMode"),a=Ps(s.workerCanvasContextBlacklist,r,"canvasContext"),c=Ps(s.workerMaskTextureFormatBlacklist,r,"maskTextureFormat"),l=Ps(s.workerMaskTextureUploadBlacklist,r,"maskTextureUpload");i.push(...o.issues,...a.issues,...c.issues,...l.issues);let u=o.level;const h=a.level,d=c.level,f=l.level;vMe(t,r)&&(u=Math.max(u||0,Ar.OffscreenTransfer),i.push(`compatibility-policy:${dMe}:skip-offscreen-transfer`));const g=(S,b)=>({renderMode:S,mainThreadRenderMode:u===Ar.MainThread?"readback":"normal",contextType:bMe(S,s.requestedContextType,h||void 0,e),reason:b,capabilities:e,runtime:r,effectiveRenderModeLevel:u,effectiveContextLevel:h,effectiveMaskTextureFormatLevel:d,effectiveMaskTextureUploadLevel:f,issues:i});if(s.useWorker==="mainThread")return g("main-thread","use-worker-main-thread");if(!e.worker||!e.offscreenCanvas||!e.workerUrl)return g("main-thread","worker-capability-missing");if(u!==void 0&&u>=Ar.ImageBitmap)return g("main-thread","render-mode-blacklist");if(!(!s.useSimple||u!==void 0&&u>=Ar.OffscreenTransfer)&&e.offscreenTransfer)return g("worker-offscreen-transfer","default-offscreen-transfer");if(!n)return g("main-thread","image-bitmap-fallback-disabled");if(e.imageBitmap){const S=u===Ar.OffscreenTransfer?"render-mode-blacklist":s.useSimple?"worker-capability-missing":"use-simple-false";return g("worker-image-bitmap",S)}return g("main-thread","image-bitmap-unavailable")}const xMe=500;function Id(s){const t=Object.fromEntries(Object.entries(s).filter(([,e])=>e!==void 0));return Object.keys(t).length?` details=${JSON.stringify(t)}`:""}function RMe(s){return`[Appliance]: [${s.category}] stage=${s.stage} viewId=${s.viewId} generation=${s.generation??"pending"}${Id(s.details||{})}`}function kMe(s){return`[Appliance]: [view-init] status=success viewId=${s.viewId} generation=${s.generation??"pending"} state=init-reconcile currentStage=ready${Id(s.details||{})}`}class AMe{constructor(t,e={}){x(this,"delayMs");x(this,"schedule");x(this,"cancel");x(this,"states",new Map);x(this,"destroyed",!1);this.emit=t,this.delayMs=e.delayMs??xMe;const r=e.schedule,n=e.cancel;this.schedule=r?(i,o)=>r(i,o):(i,o)=>globalThis.setTimeout(i,o),this.cancel=n?i=>n(i):i=>globalThis.clearTimeout(i)}record(t){if(this.destroyed)return;t.restartView&&!this.hasViewLifecycle(t.viewId,t.lifecycleGeneration)&&this.cancelView(t.viewId);const e=t.viewId;let r=this.states.get(e);if(r&&t.generation!==void 0&&r.generation!==void 0&&t.generation!==r.generation&&(this.clearState(e,r),r=void 0),!r){const n={viewId:t.viewId,generation:t.generation,lifecycleGeneration:t.lifecycleGeneration,currentCategory:t.category,currentStage:t.stage,details:{},status:"pending"};r=n,this.states.set(e,n),this.updateState(n,t),this.scheduleState(e,n);return}this.updateState(r,t),this.scheduleState(e,r)}completeView(t){if(this.destroyed)return;this.record({category:"init-reconcile",viewId:t.viewId,generation:t.generation,stage:"ready",details:t.details});const e=this.states.get(t.viewId);e&&(t.generation!==void 0&&(e.generation=t.generation),e.status="success")}cancelView(t){const e=this.states.get(t);e&&this.clearState(t,e)}destroy(){if(!this.destroyed){this.destroyed=!0;for(const[t,e]of this.states)this.clearState(t,e)}}updateState(t,e){t.generation=e.generation??t.generation,t.lifecycleGeneration=e.lifecycleGeneration??t.lifecycleGeneration,t.currentCategory=e.category,t.currentStage=e.stage,t.details={...e.details||{}}}scheduleState(t,e){e.timer!==void 0&&(this.cancel(e.timer),e.timer=void 0);try{e.timer=this.schedule(()=>{this.states.get(t)===e&&(e.timer=void 0,this.emitSummary(e),e.status==="success"&&this.states.get(t)===e&&this.states.delete(t))},this.delayMs)}catch(r){throw this.states.get(t)===e&&this.states.delete(t),r}}clearState(t,e){e.timer!==void 0&&(this.cancel(e.timer),e.timer=void 0),this.states.get(t)===e&&this.states.delete(t)}hasViewLifecycle(t,e){var r;return e===void 0?!1:((r=this.states.get(t))==null?void 0:r.lifecycleGeneration)===e}formatSummary(t){return`[Appliance]: [view-init] status=${t.status} viewId=${t.viewId} generation=${t.generation??"pending"} state=${t.currentCategory} currentStage=${t.currentStage}${Id(t.details)}`}emitSummary(t){try{this.emit(this.formatSummary(t))}catch{}}}const Ql=200;function PMe(s){return s instanceof TouchEvent||s instanceof window.TouchEvent||(s==null?void 0:s.touches)&&(s==null?void 0:s.touches.length)||(s==null?void 0:s.changedTouches)&&(s==null?void 0:s.changedTouches.length)}function DMe(s){return PMe(s)&&(s.touches&&s.touches.length===1||s.changedTouches&&s.changedTouches.length===1)}function LMe(s){return s.touches&&s.touches.length?{x:s.touches[0].pageX,y:s.touches[0].pageY}:s.changedTouches&&s.changedTouches.length?{x:s.changedTouches[0].pageX,y:s.changedTouches[0].pageY}:{x:s.pageX,y:s.pageY}}function NMe(s){const t=s.touches&&s.touches[0]||s.changedTouches&&s.changedTouches[0]||s;return{x:t.clientX,y:t.clientY}}class Xs{constructor(t){x(this,"_logger");x(this,"initLogAggregator");x(this,"pendingArgsByChannel",new Map);x(this,"flushTimerByChannel",new Map);this._logger=t,this.initLogAggregator=new AMe(e=>this.emit("info",[e]))}emit(t,e){try{if(this._logger){this._logger[t](...e);return}(t==="info"?console.info:t==="warn"?console.warn:console.error)(...e)}catch{}}flush(t,e){const r=this.pendingArgsByChannel.get(e)||null;this.flushTimerByChannel.delete(e),this.pendingArgsByChannel.delete(e),r&&this.emit(t,r)}debounce(t,e,r,n){this.pendingArgsByChannel.set(e,r);const i=this.flushTimerByChannel.get(e);i!=null&&clearTimeout(i),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,Ql)}infoDebounced(t,...e){this.debounce("info",t,e,Ql)}warnDebounced(t,...e){this.debounce("warn",t,e,Ql)}recordInitLogProgress(t){try{this.initLogAggregator.record(t)}catch{}}completeInitViewLogs(t){try{this.initLogAggregator.completeView(t)}catch{}}cancelInitViewLogs(t){try{this.initLogAggregator.cancelView(t)}catch{}}destroy(){this.initLogAggregator.destroy();for(const t of this.flushTimerByChannel.keys()){const e=this.flushTimerByChannel.get(t);e!==void 0&&clearTimeout(e)}this.flushTimerByChannel.clear(),this.pendingArgsByChannel.clear()}}function pt(s,t){try{const e=s;if(e.recordInitLogProgress){e.recordInitLogProgress(t);return}s.info(RMe(t))}catch{}}function OMe(s,t){try{const e=s;if(e.completeInitViewLogs){e.completeInitViewLogs(t);return}s.info(kMe(t))}catch{}}function ya(s,t){var e;try{(e=s==null?void 0:s.cancelInitViewLogs)==null||e.call(s,t)}catch{}}function zMe(s){return s===Be.Stroke?Be.Normal:s}function yi(s){const{pencilOptions:t}=s,e=zMe(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===Be.Normal?void 0:t.lineCap,lineDash:e===Be.Normal?void 0:t.lineDash}}function X0(s){return[s.start[0],s.start[1],0,s.end[0],s.end[1],0]}function jc(s){const{minX:t,minY:e,maxX:r,maxY:n}=s.bbox;return[t,e,0,r,n,0]}function BMe(s){const{minX:t,minY:e,maxX:r,maxY:n}=s.bbox;return[t,e,0,r,e,0,r,n,0,t,n,0]}const jMe=(s,t)=>({toolsType:q.Straight,opt:yi(t),op:X0(s)}),FMe=(s,t)=>({toolsType:q.Arrow,opt:yi(t),op:X0(s)}),UMe=(s,t)=>({toolsType:q.Rectangle,opt:{...yi(t),fillColor:"transparent"},op:BMe(s)}),WMe=(s,t)=>({toolsType:q.Ellipse,opt:{...yi(t),fillColor:"transparent"},op:jc(s)}),VMe=(s,t)=>({toolsType:q.Polygon,opt:{...yi(t),fillColor:"transparent",vertices:3,shapeType:Zt.Triangle},op:jc(s)}),$Me=(s,t)=>({toolsType:q.Polygon,opt:{...yi(t),fillColor:"transparent",vertices:4,shapeType:Zt.Rhombus},op:jc(s)}),YMe=(s,t)=>({toolsType:q.Star,opt:{...yi(t),fillColor:"transparent",vertices:10,innerVerticeStep:2,innerRatio:.4,shapeType:Zt.Pentagram},op:jc(s)}),$n={straight:jMe,arrow:FMe,rectangle:UMe,ellipse:WMe,triangle:VMe,rhombus:$Me,star:YMe};function GMe(s){return xt(s.op)}function Rn(s){if(!s.length)return s;const[t,e]=s[0],[r,n]=s[s.length-1];return t===r&&e===n?s:[...s,s[0]]}function HMe(s,t){const e=Rn(s).slice(0,-1),r=(t%e.length+e.length)%e.length;return Rn(e.slice(r).concat(e.slice(0,r)))}function Cd(s){return[...s].reverse()}function Ri(s,t,e,r,n){const i=[];for(let o=0;o<n;o++){const a=HMe(e,o),c=Cd(a);i.push({id:`${t}-cw-${o}`,semanticKind:s,points:a,threshold:r},{id:`${t}-ccw-${o}`,semanticKind:s,points:c,threshold:r})}return i}function QMe(s,t,e,r){const n=[];return e.forEach((i,o)=>{n.push({id:`${t}-forward-${o}`,semanticKind:s,points:i,threshold:r},{id:`${t}-reverse-${o}`,semanticKind:s,points:Cd(i),threshold:r})}),n}const Wp=[[0,.5],[.25,.5],[.5,.5],[.75,.5],[1,.5]],qMe=[[.05,.5],[.3,.5],[.55,.5],[.78,.5],[1,.5],[.8,.32],[1,.5],[.8,.68]],ZMe=[[.05,.5],[.3,.5],[.55,.5],[.78,.5],[1,.5],[.8,.68],[1,.5],[.8,.32]],KMe=Rn([[.15,.2],[.85,.2],[.85,.8],[.15,.8]]),XMe=Rn([[.5,.12],[.88,.82],[.12,.82]]),JMe=Rn([[.5,.08],[.92,.5],[.5,.92],[.08,.5]]),_Me=Rn([[.5,.04],[.62,.34],[.95,.36],[.68,.56],[.78,.9],[.5,.7],[.22,.9],[.32,.56],[.05,.36],[.38,.34]]),ewe=Rn([[.5,.04],[.74,.88],[.08,.34],[.92,.34],[.26,.88]]),twe=Array.from({length:24},(s,t)=>{const e=Math.PI*2*t/24;return[.5+Math.cos(e)*.42,.5+Math.sin(e)*.3]}),Yn=[{id:"straight-base",semanticKind:"straight",points:Wp,threshold:.72},{id:"straight-reverse",semanticKind:"straight",points:Cd(Wp),threshold:.72},...QMe("arrow","arrow",[qMe,ZMe],.71),...Ri("rectangle","rectangle",KMe,.68,4),...Ri("ellipse","ellipse",Rn(twe),.64,12),...Ri("triangle","triangle",XMe,.68,3),...Ri("rhombus","rhombus",JMe,.66,4),...Ri("star","star",_Me,.7,5),...Ri("star","pentagram",ewe,.68,5)];function Is(s,t,e,r){const{metrics:n}=t;return n.closureRatio>.24||n.cornerCount<e||n.cornerCount>r?null:s}const rwe=[{kind:"straight",templates:Yn.filter(s=>s.semanticKind==="straight"),postProcessor(s,t){const{metrics:e}=t;return e.bboxDiagonal<8||e.closureRatio<.75||e.straightness<.94&&s.score<.8?null:s},mapper:$n.straight,enabledInV1:!0},{kind:"arrow",templates:Yn.filter(s=>s.semanticKind==="arrow"),postProcessor(s,t){const{metrics:e}=t;return e.closureRatio<.12||e.cornerCount<4||e.cornerCount>7||e.straightness>.93?null:s.score>=Math.max(s.threshold,.71)?s:null},mapper:$n.arrow,enabledInV1:!0},{kind:"rectangle",templates:Yn.filter(s=>s.semanticKind==="rectangle"),postProcessor(s,t){const e=Is(s,t,4,6);return!e||t.metrics.bboxCornerCloseness>.15||t.metrics.bboxCornerCloseness>=t.metrics.diamondCloseness?null:e},mapper:$n.rectangle,enabledInV1:!0},{kind:"ellipse",templates:Yn.filter(s=>s.semanticKind==="ellipse"),postProcessor(s,t){const e=Is(s,t,6,12);return!e||t.metrics.radialVariance>.5?null:e},mapper:$n.ellipse,enabledInV1:!0},{kind:"triangle",templates:Yn.filter(s=>s.semanticKind==="triangle"),postProcessor(s,t){return Is(s,t,3,4)},mapper:$n.triangle,enabledInV1:!0},{kind:"rhombus",templates:Yn.filter(s=>s.semanticKind==="rhombus"),postProcessor(s,t){const e=Is(s,t,4,5);return!e||t.metrics.diamondCloseness>=t.metrics.bboxCornerCloseness?null:e},mapper:$n.rhombus,enabledInV1:!0},{kind:"star",templates:Yn.filter(s=>s.semanticKind==="star"),postProcessor(s,t){const e=s.templateId.startsWith("pentagram"),r=Is(s,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:$n.star,enabledInV1:!0}];function bd(){return rwe}const nwe=64,Yu=250;function _r(s,t){const e=s[0]-t[0],r=s[1]-t[1];return Math.hypot(e,r)}function iwe(s){const t=[];for(const e of s){const r=t[t.length-1];(!r||_r(r,e)>.5)&&t.push(e)}return t}function J0(s){let t=0;for(let e=1;e<s.length;e++)t+=_r(s[e-1],s[e]);return t}function _0(s){let t=Number.POSITIVE_INFINITY,e=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,n=Number.NEGATIVE_INFINITY;for(const[i,o]of s)t=Math.min(t,i),e=Math.min(e,o),r=Math.max(r,i),n=Math.max(n,o);return{minX:t,minY:e,maxX:r,maxY:n}}function swe(s,t=nwe){if(s.length<=1)return s;const e=J0(s)/Math.max(t-1,1),r=[s[0]];let n=0,i=s[0],o=1;const a=[...s];for(;o<a.length;){const c=a[o],l=_r(i,c);if(l===0){o++;continue}if(n+l>=e){const u=(e-n)/l,h=[i[0]+u*(c[0]-i[0]),i[1]+u*(c[1]-i[1])];r.push(h),a.splice(o,0,h),n=0,i=h,o++}else n+=l,i=c,o++}for(;r.length<t;)r.push(a[a.length-1]);return r}function Fc(s){const t=s.reduce((e,r)=>[e[0]+r[0],e[1]+r[1]],[0,0]);return[t[0]/s.length,t[1]/s.length]}function owe(s,t){const e=Fc(s),r=Math.cos(t),n=Math.sin(t);return s.map(([i,o])=>{const a=i-e[0],c=o-e[1];return[a*r-c*n+e[0],a*n+c*r+e[1]]})}function awe(s){const t=Fc(s);return Math.atan2(t[1]-s[0][1],t[0]-s[0][0])}function cwe(s,t=Yu){const e=_0(s),r=Math.max(e.maxX-e.minX,1),n=Math.max(e.maxY-e.minY,1);return s.map(([i,o])=>[(i-e.minX)/r*t,(o-e.minY)/n*t])}function lwe(s){const t=Fc(s);return s.map(([e,r])=>[e-t[0],r-t[1]])}function eM(s){const t=swe(s),e=owe(t,-awe(t)),r=cwe(e);return lwe(r)}function uwe(s,t){let e=0;const r=Math.min(s.length,t.length);for(let n=0;n<r;n++)e+=_r(s[n],t[n]);return e/Math.max(r,1)}function hwe(s,t,e){const[r,n]=s,[i,o]=t,[a,c]=e,l=Math.abs((c-o)*r-(a-i)*n+a*o-c*i),u=Math.hypot(c-o,a-i)||1;return l/u}function Gu(s,t){if(s.length<=2)return s;let e=0,r=0;for(let o=1;o<s.length-1;o++){const a=hwe(s[o],s[0],s[s.length-1]);a>e&&(e=a,r=o)}if(e<=t)return[s[0],s[s.length-1]];const n=Gu(s.slice(0,r+1),t),i=Gu(s.slice(r),t);return n.slice(0,-1).concat(i)}function dwe(s){if(s.length<3)return[];const t=[];for(let e=0;e<s.length;e++){const r=s[(e-1+s.length)%s.length],n=s[e],i=s[(e+1)%s.length],o=[r[0]-n[0],r[1]-n[1]],a=[i[0]-n[0],i[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 fwe(s){const t=_0(s),e=Math.max(t.maxX-t.minX,1),r=Math.max(t.maxY-t.minY,1),n=Math.hypot(e,r)||1,i=J0(s),o=_r(s[0],s[s.length-1]),a=_r(s[0],s[s.length-1]),c=a/n,l=n*.045,h=c<.24&&s.length>2?s.slice(0,_r(s[0],s[s.length-1])<.5?-1:s.length):s,d=Gu(h,l),f=dwe(d),g=f.length>0?Math.max(...f.map(v=>Math.abs(v-90))):90,y=d.map(([v,M])=>[(v-t.minX)/e,(M-t.minY)/r]),S=[[0,0],[1,0],[1,1],[0,1]],b=[[.5,0],[1,.5],[.5,1],[0,.5]],I=(v,M)=>v.reduce((k,E)=>{const D=Math.min(...M.map(P=>_r(E,P)));return k+D},0)/Math.max(v.length,1),N=Fc(s),T=s.map(v=>_r(v,N)),p=T.reduce((v,M)=>v+M,0)/Math.max(T.length,1),m=p>0?T.reduce((v,M)=>v+Math.abs(M-p)/p,0)/Math.max(T.length,1):0;return{bbox:t,metrics:{pathLength:i,chordLength:o,straightness:o/Math.max(i,1),closureDistance:a,closureRatio:c,bboxWidth:e,bboxHeight:r,bboxDiagonal:n,aspectRatio:e/r,cornerCount:Math.max(0,d.length),angleVariance:g,radialVariance:m,bboxCornerCloseness:I(y,S),diamondCloseness:I(y,b)}}}function gwe(s){return s.map(t=>({template:t,normalized:eM(t.points)}))}const pwe=gwe(bd().flatMap(s=>s.templates));function mwe(s){const t=iwe(s.rawPoints);if(t.length<2)return null;const{bbox:e,metrics:r}=fwe(t);return{rawPoints:s.rawPoints,points:t,pencilOptions:s.pencilOptions,viewId:s.viewId,scenePath:s.scenePath,start:t[0],end:t[t.length-1],bbox:e,metrics:r}}function ywe(s){const t=eM(s.points),e=new Map;for(const{template:r,normalized:n}of pwe){const i=uwe(t,n),o=Math.max(0,1-i/(.5*Math.sqrt(2*Yu*Yu))),a={kind:r.semanticKind,templateId:r.id,threshold:r.threshold||.7,distance:i,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 vwe(s){const t=bd(),e=ywe(s);if(s.metrics.bboxDiagonal>=8&&s.metrics.straightness>.975&&s.metrics.closureRatio>.75){const n=e.find(i=>i.kind==="straight")||{templateId:"straight-heuristic",score:.99,threshold:.72};return{kind:"straight",score:n.score,threshold:n.threshold,recognized:!0,bbox:s.bbox,start:s.start,end:s.end,points:s.points,templateId:n.templateId,metrics:s.metrics,candidates:e}}for(const n of e){const i=t.find(a=>a.kind===n.kind);if(!i||n.score<n.threshold)continue;const o=i.postProcessor?i.postProcessor(n,s):n;if(o)return{kind:i.kind,score:o.score,threshold:o.threshold,recognized:!0,bbox:s.bbox,start:s.start,end:s.end,points:s.points,templateId:o.templateId,metrics:s.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:s.bbox,start:s.start,end:s.end,points:s.points,templateId:r==null?void 0:r.templateId,metrics:s.metrics,candidates:e}}function Mwe(s){return mwe(s)}function wwe(s){return vwe(s)}function Vp(s,t){if(!s.recognized||s.kind==="none")return null;const e=bd().find(r=>r.kind===s.kind);return(e==null?void 0:e.mapper(s,t))||null}const Swe="__netless_appliance_plugin_markmap_runtime__";function Twe(){return globalThis}function Iwe(){return Twe()[Swe]}function Cwe(){return new Error('Markmap runtime is not registered. Install "markmap-lib", "markmap-view", and "mermaid", then import "@netless/appliance-plugin/markmap" before using insertMarkmap/updateMarkmap.')}function tM(){const s=Iwe();if(!s)throw Cwe();return s}function mr(){const s=new Error("Font database operation aborted");return s.name="AbortError",s}const Xn=class Xn{constructor(){x(this,"fontDB");x(this,"FONT_DB_NAME","__APPLIANCE_PLUGIN_FONT_DB");x(this,"FONT_STORE_NAME","fonts");x(this,"FONT_DB_VERSION",1)}static getInstance(){return Xn.instance||(Xn.instance=new Xn),Xn.instance}async initFontDB(t){if(t!=null&&t.aborted)throw mr();return this.fontDB?this.fontDB:new Promise((e,r)=>{let n=!1;const i=()=>{t==null||t.removeEventListener("abort",a)},o=l=>{n||(n=!0,i(),l())},a=()=>o(()=>r(mr())),c=indexedDB.open(this.FONT_DB_NAME,this.FONT_DB_VERSION);t==null||t.addEventListener("abort",a,{once:!0}),c.onerror=()=>o(()=>r(new Error(`Failed to open font database: ${c.error}`))),c.onsuccess=()=>{const l=c.result;if(n||t!=null&&t.aborted){l.close(),n||o(()=>r(mr()));return}o(()=>{this.fontDB=l,e(l)})},c.onupgradeneeded=l=>{const u=l.target.result;u.objectStoreNames.contains(this.FONT_STORE_NAME)||u.createObjectStore(this.FONT_STORE_NAME,{keyPath:"fontFamily"}).createIndex("url","url",{unique:!1})}})}async getFontFromDB(t,e,r){try{if(r!=null&&r.aborted||(this.fontDB||(this.fontDB=await this.initFontDB(r)),r!=null&&r.aborted))throw mr();return new Promise((n,i)=>{const o=this.fontDB.transaction([this.FONT_STORE_NAME],"readonly"),c=o.objectStore(this.FONT_STORE_NAME).get(t);let l=!1,u=null;const h=()=>{r==null||r.removeEventListener("abort",f)},d=g=>{l||(l=!0,h(),g())},f=()=>{try{o.abort()}catch{}d(()=>i(mr()))};r==null||r.addEventListener("abort",f,{once:!0}),c.onsuccess=()=>{c.result&&c.result.buffer&&(!e||c.result.url===e)?u=c.result.buffer:u=null},c.onerror=()=>d(()=>i(c.error)),o.onerror=()=>d(()=>i(o.error||c.error)),o.onabort=()=>d(()=>i(o.error||mr())),o.oncomplete=()=>d(()=>n(u)),r!=null&&r.aborted&&f()})}catch(n){if(r!=null&&r.aborted)throw n;return console.error(`Failed to get font from database for ${t}:`,n),null}}async saveFontToDB(t,e,r,n){try{if(n!=null&&n.aborted||(this.fontDB||(this.fontDB=await this.initFontDB(n)),n!=null&&n.aborted))throw mr();return new Promise((i,o)=>{const a=this.fontDB.transaction([this.FONT_STORE_NAME],"readwrite"),c=a.objectStore(this.FONT_STORE_NAME),l={fontFamily:t,url:e,buffer:r,timestamp:Date.now()},u=c.put(l);let h=!1;const d=()=>{n==null||n.removeEventListener("abort",g)},f=y=>{h||(h=!0,d(),y())},g=()=>{try{a.abort()}catch{}f(()=>o(mr()))};n==null||n.addEventListener("abort",g,{once:!0}),u.onsuccess=()=>{},u.onerror=()=>f(()=>o(u.error)),a.onerror=()=>f(()=>o(a.error||u.error)),a.onabort=()=>f(()=>o(a.error||mr())),a.oncomplete=()=>f(()=>i(!0)),n!=null&&n.aborted&&g()})}catch(i){if(n!=null&&n.aborted)throw i;return console.error(`Failed to save font to database for ${t}:`,i),!1}}async clearFontCache(){try{return this.fontDB||(this.fontDB=await this.initFontDB()),new Promise((t,e)=>{const i=this.fontDB.transaction([this.FONT_STORE_NAME],"readwrite").objectStore(this.FONT_STORE_NAME).clear();i.onsuccess=()=>{t(!0)},i.onerror=()=>{e(i.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 i=this.fontDB.transaction([this.FONT_STORE_NAME],"readonly").objectStore(this.FONT_STORE_NAME).getAll();i.onsuccess=()=>{const o=i.result||[],a=o.reduce((c,l)=>c+(l.buffer?l.buffer.byteLength:0),0);t({count:o.length,totalSize:a})},i.onerror=()=>{e(i.error)}})}catch(t){return console.error("Failed to get font cache status:",t),{count:0,totalSize:0}}}};x(Xn,"instance");let Hu=Xn;const bwe=3e3;function ta(s){const t=new Error(s);return t.name="AbortError",t}class Ewe{constructor(t){x(this,"control");x(this,"getFullWorker");x(this,"getSubWorker");x(this,"indexDBUtils",Hu.getInstance());x(this,"fontFaceWorkerResolveMap",new Map);x(this,"fontFaceLoadGeneration",0);x(this,"activeFontFaceAttempt");x(this,"lastFontFacesAlreadyReady",!1);x(this,"documentFontsReadyLogged",!1);x(this,"documentFontsReadyWaiters",new Set);this.control=t.control,this.getFullWorker=t.getFullWorker,this.getSubWorker=t.getSubWorker}destroy(){this.fontFaceLoadGeneration+=1;const t=this.activeFontFaceAttempt;this.activeFontFaceAttempt=void 0,t&&!t.settled&&(t.settled=!0,t.timer&&clearTimeout(t.timer),t.controller.abort(),t.resolve({status:"timeout"}));for(const e of this.documentFontsReadyWaiters)e.cancel();this.documentFontsReadyWaiters.clear();for(const e of[...this.fontFaceWorkerResolveMap.keys()])this.resolveFontFaceWorkerRequest(e,!1,!0);this.lastFontFacesAlreadyReady=!1,this.documentFontsReadyLogged=!1}get Logger(){return this.control.logger}async waitDocumentFontsReady(t,e=bwe,r){var n;r!=null&&r.aborted||typeof document>"u"||!((n=document.fonts)!=null&&n.ready)||await new Promise(i=>{let o=!1;const a=()=>{o||(o=!0,clearTimeout(c.timer),this.documentFontsReadyWaiters.delete(c),r==null||r.removeEventListener("abort",a),i())},c={timer:setTimeout(()=>{this.Logger.warn(`[Appliance]: document fonts ready timeout for ${t}; timeoutMs=${e}`),a()},e),cancel:a};this.documentFontsReadyWaiters.add(c),r==null||r.addEventListener("abort",a,{once:!0}),Promise.resolve(document.fonts.ready).then(()=>{o||(this.documentFontsReadyLogged||(this.documentFontsReadyLogged=!0,this.Logger.info(`[Appliance]: document fonts ready for ${t}`)),a())},l=>{o||(this.Logger.warn(`[Appliance]: document fonts ready failed for ${t}: ${(l==null?void 0:l.message)||l}`),a())})})}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,r=!1){const n=this.fontFaceWorkerResolveMap.get(t);if(n){if(clearTimeout(n.timer),n.signal&&n.onAbort&&n.signal.removeEventListener("abort",n.onAbort),this.fontFaceWorkerResolveMap.delete(t),r)try{n.worker.postMessage(new Set([{msgType:le.CancelFontFace,dataType:xe.Local,viewId:"",requestId:t}]))}catch{}n.resolve(e)}}requestFontFaceWorker(t,e,r,n){const i=e.requestId;return i?new Promise(o=>{const a=setTimeout(()=>{this.Logger.warn(`[Appliance]: font face worker request timeout: ${i}`),this.resolveFontFaceWorkerRequest(i,!1,!0)},this.control.loadFontFacesTimeout),c=()=>this.resolveFontFaceWorkerRequest(i,!1,!0);if(this.fontFaceWorkerResolveMap.set(i,{timer:a,resolve:o,worker:t,signal:n,onAbort:c}),n==null||n.addEventListener("abort",c,{once:!0}),n!=null&&n.aborted){c();return}try{t.postMessage(new Set([e]),r||[])}catch{this.resolveFontFaceWorkerRequest(i,!1,!0)}}):Promise.resolve(!1)}getWorkers(){return[this.getFullWorker(),this.getSubWorker()].filter(Boolean)}async areWorkerFontFacesReady(t){if(!this.control.hasOffscreenCanvas)return!0;const e=this.getWorkers();if(!e.length)return!1;const r=this.control.extendFontFaces.map(({fontFamily:i})=>({fontFamily:i}));return(await Promise.all(e.map(i=>this.requestFontFaceWorker(i,{msgType:le.CheckFontFace,dataType:xe.Local,viewId:"",fontFaces:r,requestId:this.createFontFaceRequestId("check")},void 0,t)))).every(Boolean)}async waitWorkerReadyForFontFaces(t){if(!this.control.hasOffscreenCanvas)return!0;const e=()=>this.control.isUseSimple?!!this.getFullWorker():!!this.getFullWorker()&&!!this.getSubWorker();if(e())return!0;const r=Date.now();return new Promise(n=>{let i=!1,o;const a=u=>{i||(i=!0,o&&clearTimeout(o),t==null||t.removeEventListener("abort",c),n(u))},c=()=>a(!1),l=()=>{if(t!=null&&t.aborted){a(!1);return}if(e()){a(!0);return}if(Date.now()-r>=this.control.loadFontFacesTimeout){a(!1);return}o=setTimeout(l,16)};t==null||t.addEventListener("abort",c,{once:!0}),l()})}assertAttemptActive(t,e){if(t.aborted||!e())throw ta("Font face load attempt is no longer active")}async getRuntimeFontFacesReadyState(t){if(!this.control.hasExtendFontFaces)return{documentReady:!0,workerReady:!0};const e=this.areDocumentFontFacesReady(),r=await this.areWorkerFontFacesReady(t);return{documentReady:e,workerReady:r}}async loadFontFaceBuffers(t,e){const r=[];for(const n of this.control.extendFontFaces){this.assertAttemptActive(t,e);let i;const o=await this.indexDBUtils.getFontFromDB(n.fontFamily,n.src,t);if(this.assertAttemptActive(t,e),o&&o.byteLength>0&&this.validateFontData(new Uint8Array(o))&&(i=o),!i&&(i=await this.loadFontInMainThread(n.src,t),this.assertAttemptActive(t,e),i&&i.byteLength>0)){const a=await this.indexDBUtils.saveFontToDB(n.fontFamily,n.src,i,t);this.assertAttemptActive(t,e),a||this.Logger.warn(`[Appliance]: Failed to save font ${n.fontFamily} to IndexedDB, but continuing with font loading`)}i&&i.byteLength>0?r.push({fontFamily:n.fontFamily,buffer:i}):this.Logger.warn(`[Appliance]: Font ${n.fontFamily} could not be loaded from any source`)}return r}async setDocumentFontFaces(t,e,r){if(typeof document>"u"||!document.fonts)return!1;for(const{fontFamily:n,buffer:i}of t){let o;try{if(this.assertAttemptActive(e,r),this.isDocumentFontFaceReady(n))continue;o=new FontFace(n,i.slice(0)),await o.load(),this.assertAttemptActive(e,r),document.fonts.add(o),await o.loaded,this.assertAttemptActive(e,r)}catch(a){if(e.aborted||!r()){if(o)try{document.fonts.delete(o)}catch{}throw ta("Document font load attempt is no longer active")}return this.Logger.error(`[Appliance]: set document font faces error: ${(a==null?void 0:a.message)||a}`),!1}}return this.assertAttemptActive(e,r),this.areDocumentFontFacesReady()}async setWorkerFontFaces(t,e,r){if(!this.control.hasOffscreenCanvas)return!0;const n=this.getWorkers();if(!n.length)return!1;const i=await Promise.all(n.map(o=>{const a=t.map(({fontFamily:c,buffer:l})=>({fontFamily:c,buffer:l.slice(0)}));return this.requestFontFaceWorker(o,{msgType:le.SetFontFace,dataType:xe.Local,viewId:"",fontBuffers:a,requestId:this.createFontFaceRequestId("set")},a.map(({buffer:c})=>c),e)}));return this.assertAttemptActive(e,r),i.every(Boolean)&&await this.areWorkerFontFacesReady(e)}async doLoadFontFaces(t,e,r=()=>!0){if(!e)throw new Error("Font face load requires an attempt signal");if(this.assertAttemptActive(e,r),this.lastFontFacesAlreadyReady=!1,!this.control.hasExtendFontFaces)return this.assertAttemptActive(e,r),this.lastFontFacesAlreadyReady=!0,{status:"success"};if(await this.waitDocumentFontsReady("fontFaceLoad",void 0,e),this.assertAttemptActive(e,r),!await this.waitWorkerReadyForFontFaces(e))return this.assertAttemptActive(e,r),{status:"timeout"};this.assertAttemptActive(e,r);const n=await this.getRuntimeFontFacesReadyState(e);if(this.assertAttemptActive(e,r),n.documentReady&&n.workerReady)return this.lastFontFacesAlreadyReady=!0,{status:"success"};t==null||t(),this.Logger.info(`[Appliance]: load font faces ${JSON.stringify(this.control.extendFontFaces)}`);const i=await this.loadFontFaceBuffers(e,r);if(this.assertAttemptActive(e,r),i.length!==this.control.extendFontFaces.length)return{status:"error"};const o=n.documentReady||await this.setDocumentFontFaces(i,e,r);this.assertAttemptActive(e,r);const a=n.workerReady||await this.setWorkerFontFaces(i,e,r);return this.assertAttemptActive(e,r),o&&a?(this.Logger.info("[Appliance]: set font faces success"),{status:"success"}):{status:"error"}}getLastFontFacesAlreadyReady(){return this.lastFontFacesAlreadyReady}async loadFontFaces(){const t=this.activeFontFaceAttempt;if(t&&t.generation===this.fontFaceLoadGeneration)return t.promise;const e=++this.fontFaceLoadGeneration,r=new AbortController;let n;const i={generation:e,controller:r,promise:new Promise(l=>{n=l}),resolve:l=>n(l),settled:!1,started:!1};this.activeFontFaceAttempt=i,this.lastFontFacesAlreadyReady=!1;const o=()=>this.activeFontFaceAttempt===i&&this.fontFaceLoadGeneration===i.generation,a=()=>{!o()||i.started||(i.started=!0,this.control.emitFontFaceLoadState({status:"start"}))},c=(l,u)=>{if(i.settled)return;const h=o();i.settled=!0,i.timer&&clearTimeout(i.timer),h&&i.started&&this.control.emitFontFaceLoadState(l),h&&l.status!=="success"&&(this.activeFontFaceAttempt=void 0,this.fontFaceLoadGeneration+=1),u&&r.abort(),i.resolve(l)};return i.timer=setTimeout(()=>c({status:"timeout"},!0),this.control.loadFontFacesTimeout),this.doLoadFontFaces(a,r.signal,o).then(l=>c(l,l.status!=="success"),l=>{!i.settled&&o()&&this.Logger.error(`[Appliance]: load font faces error: ${(l==null?void 0:l.message)||l}`),c(r.signal.aborted?{status:"timeout"}:{status:"error"},!0)}),i.promise}async loadFontInMainThread(t,e){try{if(e.aborted)throw ta("Font fetch aborted");const r=await fetch(t,{signal:e});if(!r.ok)throw new Error(`HTTP ${r.status}: ${r.statusText}`);const n=await r.arrayBuffer();if(e.aborted)throw ta("Font fetch aborted");if(!n||n.byteLength===0)throw new Error("Empty font data received");const i=new Uint8Array(n);if(!this.validateFontData(i))throw new Error("Invalid font data format: not a valid font file");return n}catch(r){if(e.aborted)throw r;this.Logger.error(`[Appliance]: Failed to load font from ${t}: ${r instanceof Error?r.message:String(r)}`);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:i,failedFonts:o}=t;return e!==le.SetFontFace&&e!==le.CheckFontFace?!1:(e===le.SetFontFace&&(o!=null&&o.length)&&this.Logger.info("[Appliance]: set font face has failed fonts: "+o.join(", ")),r&&this.resolveFontFaceWorkerRequest(r,e===le.CheckFontFace?!!i:!!n&&!(o!=null&&o.length)),!0)}}const xwe=new Set([q.Eraser,q.PencilEraser,q.BitMapEraser]),Cs=2e3,ra=8e3,Rwe=32,$p=8,kwe={x:1,y:1,width:3,height:2},Yp=2;function Gp(s,t){return t.map(({x:e,y:r,expected:n,inside:i})=>{const o=Array.from(s.getImageData(e,r,1,1).data.slice(0,4));return{x:e,y:r,expected:n,actual:o,inside:i,ok:i?o[3]>=16&&o[0]>=o[3]-5&&o[1]<=5&&o[2]<=5:o[3]<=5}})}function Qu(s){return!!s&&s.length>=4&&s.every(({ok:t})=>t)}function na(s){const t=s==null?void 0:s.programProbe;return(s==null?void 0:s.offscreenCanvas)===!0&&s.contextSupported===!0&&(t==null?void 0:t.passed)===!0&&Qu(t.destinationPixelChecks)}function Hp(s,t){var e;return{renderMode:s.renderMode,contextType:((e=t==null?void 0:t.programProbe)==null?void 0:e.actualContextType)||s.contextType}}function Awe(s){const t=Math.max(0,s-Date.now());return t===0?Promise.resolve():new Promise(e=>{let r=!1,n,i;const o=()=>{r||(r=!0,i!==void 0&&clearTimeout(i),n!==void 0&&typeof globalThis.cancelAnimationFrame=="function"&&globalThis.cancelAnimationFrame(n),e())};i=setTimeout(o,Math.min(Rwe,t)),typeof globalThis.requestAnimationFrame=="function"&&(n=globalThis.requestAnimationFrame(o))})}function Qr(s,t){var e,r;return((e=s.getRenderContextTypeForView)==null?void 0:e.call(s,t))??((r=s.renderingCompatibilityDecision)==null?void 0:r.contextType)??"2d"}function Pwe(s,t){const e=s||{},r=t||{},n=[],i=[],o=[];for(const a of Object.keys(r))a in e?ye.isEqual(e[a],r[a])||i.push(a):n.push(a);for(const a of Object.keys(e))a in r||o.push(a);return{added:n,updated:i,removed:o}}const ql=new Set([q.Pencil,q.Arrow,q.Straight,q.Ellipse,q.Rectangle,q.Star,q.Polygon,q.Triangle,q.Rhombus,q.SpeechBalloon]);function Qp(s){return s===q.Pencil?$e.DrawingPencil:s===q.Arrow||s===q.Straight?$e.DrawingArrow:s===q.Eraser?$e.DrawingEraser:s===q.PencilEraser?$e.DrawingPencilEraser:s===q.BitMapEraser?$e.DrawingBitMapEraser:$e.DrawingShape}function bs(s){switch(s){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:Te.TranslateNode};case $e.MethodScaleNode:return{kind:"method-pause",emitEventType:Te.ScaleNode};case $e.MethodRotateNode:return{kind:"method-pause",emitEventType:Te.RotateNode};case $e.MethodSetPoint:return{kind:"method-pause",emitEventType:Te.SetPoint};case $e.MethodSetColorNode:return{kind:"method-pause",emitEventType:Te.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 ki=s=>typeof s=="number"&&xwe.has(s),qp=s=>s===le.FullWork||s===le.UpdateNode||s===le.RemoveNode||s===le.DrawWork||s===le.Select||s===le.TextUpdate,Zl=4096;class Dwe{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 Ai extends Error{constructor(){super("render runtime recovery cancelled"),this.name="RenderRuntimeRecoveryCancelledError"}}class Lwe extends Dwe{constructor(e){super();x(this,"maxLastSyncTime",He.syncOpt.interval);x(this,"combineUnitTime",He.bezier.combineUnitTime);x(this,"maxCombineEraserTime",yd);x(this,"smoothSync",He.syncOpt.smoothSync);x(this,"isActive",!1);x(this,"currentToolsData");x(this,"currentLocalWorkData");x(this,"control");x(this,"internalMsgEmitter");x(this,"publicMsgEmitter");x(this,"taskBatchData",new Set);x(this,"fullWorker");x(this,"subWorker");x(this,"fullWorkerUrl");x(this,"subWorkerUrl");x(this,"methodBuilder");x(this,"zIndexNodeMethod");x(this,"subWorkerDrawCount",0);x(this,"fullWorkerDrawCount",0);x(this,"maxDrawCount",0);x(this,"_consumeCount",0);x(this,"_postCount",0);x(this,"reRenders",new Map);x(this,"localWorkViewId");x(this,"localPointsBatchData",new Map);x(this,"tasksqueue",new Map);x(this,"cameraUpdateStateByView",new Map);x(this,"cameraClearReplayByView",new Map);x(this,"cameraClearReplaySequence",0);x(this,"cameraFailureSequenceByView",new Map);x(this,"cameraUpdateEndWaitersByView",new Map);x(this,"viewLifecycleIdleWaitersByView",new Map);x(this,"cameraTaskSequenceByView",new Map);x(this,"cameraRecoverySequence",0);x(this,"pendingDprOwnerByView",new Map);x(this,"dprUpdateSequence",0);x(this,"localWorkFinalizeQueueByView",new Map);x(this,"localWorkFinalizeQueue",Promise.resolve());x(this,"operationBarrierQueueByView",new Map);x(this,"operationBarrierEpochByView",new Map);x(this,"operationBarrierInvalidationWaitersByView",new Map);x(this,"cancelledEraseTxnIds",new Set);x(this,"cancelledEraseTxnOwners",new Map);x(this,"cancelledLocalWorkOwners",new Map);x(this,"fullLayerBitmapEraseTxns",new Map);x(this,"fullLayerBitmapEraseTxnWaiters",new Map);x(this,"snapshotMap",new Map);x(this,"snapshotRequestIdByViewScene",new Map);x(this,"boundingRectMap",new Map);x(this,"boundingRectRequestIdByViewScene",new Map);x(this,"clearAllResolveMap",new Map);x(this,"localEventQueue",Promise.resolve());x(this,"localEventQueueByView",new Map);x(this,"localDoneDispatchTimersByView",new Map);x(this,"localEventSequence",0);x(this,"localInputEpochByView",new Map);x(this,"localInputTransactionEpochByView",new Map);x(this,"localDoneWaitSequence",0);x(this,"queuedLocalEventCount",0);x(this,"activeLocalEvent");x(this,"localDoneWaitByView",new Map);x(this,"delayWorkStateToDoneResolveByView",new Map);x(this,"localDoneWait");x(this,"delayWorkStateToDoneResolve");x(this,"animationId");x(this,"tmpImageConfigMap",new Map);x(this,"mainThread");x(this,"backgroundThreadManager");x(this,"willSelectorWorkIdByView",new Map);x(this,"isLockSentEventCursor",!1);x(this,"getVNodeInfoResolveMap",new Map);x(this,"refreshTextRenderResolveMap",new Map);x(this,"fontFaceManager");x(this,"isLocalWorkActive",!1);x(this,"hasMainViewInitAck",!1);x(this,"mainViewInitReady",new H0);x(this,"serviceSyncReadyViews",new Set);x(this,"mainViewInitAckCallbacks",new Set);x(this,"initAckedViewIds",new Set);x(this,"viewInitAckTimeoutTimers",new Map);x(this,"renderRuntimeCacheSavePromise");x(this,"pendingTransportMessages",new Map);x(this,"isRenderTransportReady",!1);x(this,"renderRuntimeFallbackSequence",0);x(this,"activeRenderRuntimeRecovery");x(this,"viewInitRecoveryAttempts",new Map);x(this,"viewInitRecoveryDestroying",new Set);x(this,"viewInitAckWaiters",new Map);x(this,"serviceSyncCommitWaiters",new Map);x(this,"viewServiceReadyWaiters",new Map);x(this,"initReconcileTasks",new Map);x(this,"serviceSyncSequence",0);x(this,"initGeneration",0);x(this,"viewGenerationById",new Map);x(this,"fullLayerFrameStateByView",new Map);x(this,"pendingDprByView",new Map);x(this,"viewRecoveryQueueByView",new Map);x(this,"initCameraOptByView",new Map);x(this,"markmapIdResolveMap",new Map);const{control:r,internalMsgEmitter:n,publicMsgEmitter:i}=e;this.control=r,this.maxLastSyncTime=this.control.pluginOptions.extras.syncOpt.interval,this.combineUnitTime=this.control.pluginOptions.extras.bezier.combineUnitTime||this.combineUnitTime,this.smoothSync=ye.isBoolean(this.control.pluginOptions.extras.syncOpt.smoothSync)?this.control.pluginOptions.extras.syncOpt.smoothSync:this.smoothSync,this.fullWorkerUrl=this.control.pluginOptions.cdn.fullWorkerUrl||"",this.subWorkerUrl=this.control.pluginOptions.cdn.subWorkerUrl||"",this.internalMsgEmitter=n,this.publicMsgEmitter=i,this.currentLocalWorkData={workState:de.Pending},this.fontFaceManager=new Ewe({control:this.control,getFullWorker:()=>this.fullWorker,getSubWorker:()=>this.subWorker})}getDoneWaitForView(e){var i;const r=(i=this.localDoneWaitByView)==null?void 0:i.get(e);if(r)return r;const n=this.localDoneWait;if(n&&(!n.viewId||n.viewId===e))return{...n,viewId:e}}getDoneResolverForView(e){var i,o;const r=(i=this.delayWorkStateToDoneResolveByView)==null?void 0:i.get(e);if(r)return r;const n=this.localDoneWait;if(this.delayWorkStateToDoneResolve&&!((o=this.delayWorkStateToDoneResolveByView)!=null&&o.size)&&(!(n!=null&&n.viewId)||n.viewId===e))return this.delayWorkStateToDoneResolve}getLocalWorkFinalizeQueue(e){return this.localWorkFinalizeQueueByView?this.localWorkFinalizeQueueByView.get(e)||Promise.resolve():this.localWorkFinalizeQueue||Promise.resolve()}setLocalWorkFinalizeQueue(e,r){if(this.localWorkFinalizeQueueByView){this.localWorkFinalizeQueueByView.set(e,r);return}this.localWorkFinalizeQueue=r}clearLocalWorkFinalizeQueue(e,r){if(this.localWorkFinalizeQueueByView){this.localWorkFinalizeQueueByView.get(e)===r&&this.localWorkFinalizeQueueByView.delete(e);return}this.localWorkFinalizeQueue===r&&(this.localWorkFinalizeQueue=Promise.resolve())}clearDoneWaitForView(e,r){var i,o,a,c,l,u;const n=(i=this.localDoneWaitByView)==null?void 0:i.get(e);r&&(n==null?void 0:n.token)!==r||((o=this.localDoneWaitByView)==null||o.delete(e),(a=this.delayWorkStateToDoneResolveByView)==null||a.delete(e),(!r||((c=this.localDoneWait)==null?void 0:c.token)===r)&&(((l=this.localDoneWait)==null?void 0:l.viewId)===void 0||((u=this.localDoneWait)==null?void 0:u.viewId)===e)&&(this.localDoneWait=void 0,this.delayWorkStateToDoneResolve=void 0))}get isBezier(){return this.control.pluginOptions.extras.bezier.enable}get Logger(){return this.control.logger}logRenderRuntimeFallback(e,r,n="info"){const i=`[Appliance]: [render-runtime-fallback] stage=${e} ${JSON.stringify(r)}`;this.Logger[n](i)}logMainViewCameraTrace(e,r){const n=this.Logger,i=`[Appliance]: [main-view-camera] stage=${e} ${JSON.stringify(r)}`;n.infoDebounced?n.infoDebounced(`main-view-camera:${e}`,i):n.info(i)}logAppViewCameraTrace(e,r,n){const i=this.Logger,o=`[Appliance]: [app-view-camera] stage=${r} ${JSON.stringify({viewId:e,...n})}`;i!=null&&i.infoDebounced?i.infoDebounced(`app-view-camera:${e}:${r}`,o):i&&i.info(o)}closeImageBitmap(e){var r;if(e)try{(r=e.close)==null||r.call(e)}catch(n){this.logLocalWorkBarrierError(`[Appliance]: ImageBitmap release failed; error=${n instanceof Error?n.message:String(n)}`)}}getViewSceneRequestKey(e,r){return`${e}\0${r}`}settleSnapshotFailure(e,r,n){const i=this.getViewSceneRequestKey(e,r);if(this.snapshotRequestIdByViewScene.get(i)!==n)return;const o=this.snapshotMap.get(i);!o||o.requestId!==n||o.resolve(o.value.map(a=>a||null))}settleBoundingRectFailure(e,r,n){const i=this.getViewSceneRequestKey(e,r);if(this.boundingRectRequestIdByViewScene.get(i)!==n)return;const o=this.boundingRectMap.get(i);!o||o.requestId!==n||o.resolve({x:0,y:0,w:0,h:0})}settleViewRenderRequests(e){var r,n;for(const[i,o]of this.snapshotMap)o.viewId===e&&(this.snapshotMap.delete(i),this.snapshotRequestIdByViewScene.get(i)===o.requestId&&this.snapshotRequestIdByViewScene.delete(i),o.resolve(o.value.map(a=>a||null)));for(const[i,o]of this.boundingRectMap)o.viewId===e&&(this.boundingRectMap.delete(i),this.boundingRectRequestIdByViewScene.get(i)===o.requestId&&this.boundingRectRequestIdByViewScene.delete(i),o.resolve({x:0,y:0,w:0,h:0}));try{(r=this.mainThread)==null||r.discardView(e)}catch(i){this.logLocalWorkBarrierError(`[Appliance]: main snapshot cleanup failed; viewId=${e}; error=${i instanceof Error?i.message:String(i)}`)}try{(n=this.backgroundThreadManager)==null||n.discardView(e)}catch(i){this.logLocalWorkBarrierError(`[Appliance]: background snapshot cleanup failed; viewId=${e}; error=${i instanceof Error?i.message:String(i)}`)}}afterMainViewInitAck(e){const r=this.initGeneration;if(this.hasMainViewInitAck){window.setTimeout(()=>{if(this.initGeneration===r)try{e()}catch{}},0);return}this.mainViewInitAckCallbacks.add(e)}get isMainViewInitAck(){return this.hasMainViewInitAck}waitForMainViewInitAck(e=6e4){return this.mainViewInitReady.wait(e)}isViewInitAck(e){return this.initAckedViewIds.has(e)}ackMainViewInit(e,r,n){var d;const i=this.viewGenerationById.get(e),o=Qr(this.control,e),a=Ht(this.control.renderMode,o);if(r!==void 0&&i!==r){this.Logger.warn(`[Appliance]: [render-init] stage=ack-ignored viewId=${e} receivedGeneration=${r} currentGeneration=${i} reason=generation-mismatch`);return}if(this.initAckedViewIds.has(e)){this.Logger.warn(`[Appliance]: [render-init] stage=ack-ignored viewId=${e} reason=duplicate-ack`);return}if(pt(this.Logger,{category:"render-init",viewId:e,generation:r??i??"unknown",stage:"ack-received",details:{transport:this.control.renderMode,context:o,actualWorkerContext:n||"unreported"}}),this.control.renderMode!=="main-thread"&&n!==o){this.Logger.error(`[Appliance]: [render-init] stage=ack-context-mismatch viewId=${e} generation=${r??i??"unknown"} expectedContext=${o} actualContext=${n||"unreported"}`),ya(this.Logger,e),this.scheduleRenderRuntimeFallback({type:le.ReportError,viewId:e,viewGeneration:r??i,reportErrorCode:"RENDERER_RUNTIME_ERROR",reportStage:"init-context-mismatch",reportError:`expected ${o}, actual ${n||"unreported"}`,reportContextType:n});return}this.initAckedViewIds.add(e);const c=`${e}:${r??i}`,l=(d=this.viewInitAckTimeoutTimers)==null?void 0:d.get(c);l&&(clearTimeout(l),this.viewInitAckTimeoutTimers.delete(c)),this.activeRenderRuntimeRecovery&&this.logRenderRuntimeFallback("init-acked",{recoveryId:this.activeRenderRuntimeRecovery.recoveryId,viewId:e,generation:r,elapsedMs:Date.now()-this.activeRenderRuntimeRecovery.startedAt});const u=this.viewInitAckWaiters.get(e);if(u){for(const f of[...u])r!==void 0&&f.generation!==r||(clearTimeout(f.timer),u.delete(f),f.resolve(!0));u.size||this.viewInitAckWaiters.delete(e)}if(e===Fe&&!this.hasMainViewInitAck&&(this.hasMainViewInitAck=!0,this.mainViewInitReady.markReady()),pt(this.Logger,{category:"render-init",viewId:e,generation:i??"unknown",stage:"ack-completed",details:{transport:this.control.renderMode,context:o,renderModel:a}}),i!==void 0&&this.scheduleInitReconcile(e,i),e!==Fe)return;const h=[...this.mainViewInitAckCallbacks];this.mainViewInitAckCallbacks.clear();for(const f of h)window.setTimeout(()=>{try{f()}catch{}},0)}scheduleInitReconcile(e,r){if(this.initReconcileTasks.has(e))return;pt(this.Logger,{category:"init-reconcile",viewId:e,generation:r,stage:"ack-reconcile"});const n=this.reconcileViewInit(e,r).catch(i=>{this.viewGenerationById.get(e)===r&&(this.Logger.error(`[Appliance]: [init-reconcile] stage=failed viewId=${e} generation=${r} error=${i instanceof Error?i.message:String(i)}`),ya(this.Logger,e))}).finally(()=>{this.initReconcileTasks.get(e)===n&&this.initReconcileTasks.delete(e)});this.initReconcileTasks.set(e,n)}isCurrentViewGeneration(e,r){return this.viewGenerationById.get(e)===r&&!!this.viewContainerManager.getView(e)}async reconcileViewInit(e,r){var i,o,a,c,l,u,h,d,f,g,y,S,b,I,N,T,p,m,v,M,k,E,D,P;let n=0;for(;this.isCurrentViewGeneration(e,r);){const z=this.viewContainerManager.getView(e);if(!z)return;const j=((o=(i=this.control).getPendingInitTargetScenePath)==null?void 0:o.call(i,e))||z.focusScenePath;if(!j){this.finalizeViewInitReady(e,r,void 0);return}const A=((c=(a=this.control).getPendingInitReconcileRevision)==null?void 0:c.call(a,e,j))||{anchorRevision:0,cameraRevision:0,forceFullRevision:0};if(z.focusScenePath!==j){const B=this.viewContainerManager.setViewScenePathBeforeRenderInit(e,j);pt(this.Logger,{category:"init-reconcile",viewId:e,generation:r,stage:"retrigger-scene",details:{scenePath:j,applied:B}})}const R=(u=(l=this.control).getPendingInitCameraForScene)==null?void 0:u.call(l,e,j),L=R||z.cameraOpt,W=this.initCameraOptByView.get(e),Y=((h=this.cameraUpdateStateByView.get(e))==null?void 0:h.isRecovering)===!0,H=!!(!Y&&L&&(!W||!this.isSameCameraOpt(W,L)));if(pt(this.Logger,{category:"init-reconcile",viewId:e,generation:r,stage:"retrigger-camera",details:{scenePath:j,source:Y?"camera-recovery":R?"padding":"window-manager",applied:H}}),H&&L){const B=((d=this.cameraFailureSequenceByView)==null?void 0:d.get(e))||0;this.updateCameraForReadyRenderer(e,L);const F=await this.waitForInitCameraCatchUp(e,r);if(!this.isCurrentViewGeneration(e,r))return;if(!F||(((f=this.cameraFailureSequenceByView)==null?void 0:f.get(e))||0)!==B){this.scheduleRenderRuntimeFallback({type:le.ReportError,viewId:e,viewGeneration:r,reportErrorCode:"INIT_CAMERA_CATCH_UP_FAILED",reportStage:"init-camera-catch-up",reportError:F?"camera renderer reported failure":"camera catch-up timeout"});return}this.initCameraOptByView.set(e,{...L})}const ie=((g=this.collector)==null?void 0:g.readSceneStorageSnapshot(e,j))||{revision:0,storage:{}},O=((b=(S=(y=this.control).getPendingInitLastApplied)==null?void 0:S.call(y,e,j))==null?void 0:b.storage)||((N=(I=this.control).getPendingInitServiceBaseline)==null?void 0:N.call(I,e,j))||{},V=Pwe(O,ie.storage),Z=!((p=(T=this.control).hasPendingInitAppliedSnapshot)!=null&&p.call(T,e,j));pt(this.Logger,{category:"init-reconcile",viewId:e,generation:r,stage:"read-service-snapshot",details:{scenePath:j,revision:ie.revision,keys:Object.keys(ie.storage).length}}),pt(this.Logger,{category:"init-reconcile",viewId:e,generation:r,stage:"service-diff",details:{scenePath:j,added:V.added.length,updated:V.updated.length,removed:V.removed.length}}),pt(this.Logger,{category:"init-reconcile",viewId:e,generation:r,stage:"service-full-sync",details:{scenePath:j,reason:Z?"first-init":"post-commit-dirty"}});const $=await this.submitInitServiceSnapshot(e,j,r,ie.revision);if(!this.isCurrentViewGeneration(e,r))return;if(!$){if(n+=1,n<2)continue;this.scheduleRenderRuntimeFallback({type:le.ReportError,viewId:e,viewGeneration:r,reportErrorCode:"SERVICE_SYNC_COMMIT_TIMEOUT",reportStage:"init-service-commit",reportError:"service sync commit timeout"});return}n=0,(v=(m=this.control).markPendingInitServiceApplied)==null||v.call(m,e,j,ie.storage,ie.revision);const ee=this.viewContainerManager.getView(e),se=((k=(M=this.control).getPendingInitTargetScenePath)==null?void 0:k.call(M,e))||(ee==null?void 0:ee.focusScenePath),ce=((D=(E=this.control).getPendingInitReconcileRevision)==null?void 0:D.call(E,e,j))||{anchorRevision:0,cameraRevision:0,forceFullRevision:0},me=((P=this.collector)==null?void 0:P.readSceneStorageSnapshot(e,j).revision)||0,pe=[];if((se!==j||ce.anchorRevision!==A.anchorRevision)&&pe.push("scene"),ce.cameraRevision!==A.cameraRevision&&pe.push("camera"),me!==ie.revision&&pe.push("service"),ce.forceFullRevision!==A.forceFullRevision&&pe.push("force"),pe.length){pt(this.Logger,{category:"init-reconcile",viewId:e,generation:r,stage:"post-commit-dirty",details:{scenePath:j,reason:pe.join(",")}});continue}this.finalizeViewInitReady(e,r,j);return}}submitInitServiceSnapshot(e,r,n,i){const o=`init-service-${n}-${++this.serviceSyncSequence}`,a=this.waitForServiceSyncCommit(o,e,n);return this.control.textEditorManager.clear(e,!0),this.taskBatchData.add({msgType:le.Clear,dataType:xe.Service,viewId:e,viewGeneration:n,scenePath:r}),this.pullServiceDataForReadyRenderer(e,r,{isAsync:!1,useAnimation:!1}),this.taskBatchData.add({msgType:le.ServiceSyncCommit,dataType:xe.Service,viewId:e,viewGeneration:n,scenePath:r,serviceSyncId:o,serviceRevision:i}),pt(this.Logger,{category:"init-reconcile",viewId:e,generation:n,stage:"service-commit-sent",details:{scenePath:r,syncId:o,revision:i}}),this.consume(),a}waitForInitCameraCatchUp(e,r,n=sa+1e3){let i;const o=new Promise(c=>{i=setTimeout(()=>c(!1),n)}),a=this.waitForCameraUpdateEnd(e).then(()=>this.isCurrentViewGeneration(e,r),()=>!1);return Promise.race([a,o]).finally(()=>{i&&clearTimeout(i)})}waitForServiceSyncCommit(e,r,n,i=5e3){return new Promise(o=>{const a=setTimeout(()=>{this.serviceSyncCommitWaiters.delete(e),this.Logger.error(`[Appliance]: [init-reconcile] stage=service-commit-timeout viewId=${r} generation=${n} syncId=${e}`),o(!1)},i);this.serviceSyncCommitWaiters.set(e,{viewId:r,generation:n,resolve:o,timer:a})})}ackServiceSyncCommit(e){const r=e.serviceSyncId;if(!r)return;const n=this.serviceSyncCommitWaiters.get(r);!n||n.viewId!==e.viewId||n.generation!==e.viewGeneration||this.viewGenerationById.get(n.viewId)!==n.generation||(this.serviceSyncCommitWaiters.delete(r),clearTimeout(n.timer),pt(this.Logger,{category:"init-reconcile",viewId:n.viewId,generation:n.generation,stage:"service-commit-acked",details:{scenePath:e.scenePath||"none",syncId:r,revision:e.serviceRevision??0}}),n.resolve(!0))}finalizeViewInitReady(e,r,n){var o,a,c,l,u,h,d,f,g;if(!this.isCurrentViewGeneration(e,r))return;(o=this.cameraUpdateStateByView.get(e))!=null&&o.isRecovering||(a=this.viewInitRecoveryAttempts)==null||a.delete(e),(c=this.viewInitRecoveryDestroying)==null||c.delete(e),this.initCameraOptByView.delete(e),this.markServiceSyncReady(e),(u=(l=this.control).clearPendingViewInitState)==null||u.call(l,e),this.activeRenderRuntimeRecovery||(this.control.onViewServiceReady(e),this.dispatchCameraRecoveryReplay(e,r)),OMe(this.Logger,{viewId:e,generation:r,details:{finalScenePath:n||"none",serviceSync:"ready"}}),this.control.emitInitLoadingChange({loading:!0,phase:"scene",status:"success"}),this.control.emitInitLoadingChange({loading:!1,phase:"ready",status:"success"});for(const[y,S]of this.viewInitAckTimeoutTimers||[])y.startsWith(`${e}:`)&&(clearTimeout(S),this.viewInitAckTimeoutTimers.delete(y));const i=this.viewServiceReadyWaiters.get(e);i==null||i.forEach(y=>{y.generation===r&&(clearTimeout(y.timer),y.resolve(!0),i.delete(y))}),i!=null&&i.size||this.viewServiceReadyWaiters.delete(e),((d=(h=this.control.pluginOptions)==null?void 0:h.extras)==null?void 0:d.useWorker)==="auto"&&this.control.renderingCompatibilityDecision.renderRuntimeCacheState!=="hit"&&!this.activeRenderRuntimeRecovery&&!this.renderRuntimeCacheSavePromise&&(this.renderRuntimeCacheSavePromise=((g=(f=this.control).persistRenderRuntimeDecision)==null?void 0:g.call(f))||Promise.resolve())}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)r.viewGeneration!==void 0&&this.armViewInitAckTimeout(r.viewId,r.viewGeneration),pt(this.Logger,{category:"render-init",viewId:r.viewId,generation:r.viewGeneration,stage:"sent",details:{renderModel:Ht(this.control.renderMode,Qr(this.control,r.viewId)),context:Qr(this.control,r.viewId),source:this.control.renderingCompatibilityDecision.renderRuntimeSource||"config"}});e.size&&this.dispatchMessages(e)}}getPendingInitMessageKey(e){return`${e.msgType}:${e.viewId}:${e.scenePath||""}`}markServiceSyncReady(e){this.serviceSyncReadyViews.add(e)}waitForViewInitAck(e,r,n=5e3){return this.initAckedViewIds.has(e)&&this.viewGenerationById.get(e)===r?Promise.resolve(!0):new Promise(i=>{const o=this.viewInitAckWaiters.get(e)||new Set,a={generation:r,resolve:i,timer:setTimeout(()=>{o.delete(a),o.size||this.viewInitAckWaiters.delete(e),i(!1)},n)};o.add(a),this.viewInitAckWaiters.set(e,o)})}waitForViewServiceReady(e,r,n=1e4){return this.serviceSyncReadyViews.has(e)&&this.viewGenerationById.get(e)===r?Promise.resolve(!0):new Promise(i=>{const o=this.viewServiceReadyWaiters.get(e)||new Set,a={generation:r,resolve:i,timer:setTimeout(()=>{o.delete(a),o.size||this.viewServiceReadyWaiters.delete(e),i(!1)},n)};o.add(a),this.viewServiceReadyWaiters.set(e,o)})}armViewInitAckTimeout(e,r,n=1e4){const i=`${e}:${r}`,o=this.viewInitAckTimeoutTimers.get(i);o&&clearTimeout(o);const a=window.setTimeout(()=>{this.viewInitAckTimeoutTimers.delete(i),!(this.initAckedViewIds.has(e)||this.viewGenerationById.get(e)!==r)&&(this.Logger.error(`[Appliance]: [render-init] stage=ack-timeout viewId=${e} generation=${r}`),ya(this.Logger,e),this.scheduleRenderRuntimeFallback({type:le.ReportError,viewId:e,viewGeneration:r,reportErrorCode:"RENDER_INIT_TIMEOUT",reportStage:"worker-init-ack",reportError:"render init ack timeout"}))},n);this.viewInitAckTimeoutTimers.set(i,a)}async waitForViewInitCompletion(e){const r=this.viewGenerationById.get(e);if(r===void 0)return"stale";const n=await this.waitForViewInitAck(e,r,1e4);if(this.viewGenerationById.get(e)!==r)return"stale";if(!n)return"timeout";const i=await this.waitForViewServiceReady(e,r,15e3);return this.viewGenerationById.get(e)!==r?"stale":i?"completed":(this.scheduleRenderRuntimeFallback({type:le.ReportError,viewId:e,viewGeneration:r,reportErrorCode:"RENDER_INIT_TIMEOUT",reportStage:"worker-service-ready",reportError:"render service ready timeout"}),"timeout")}failViewInitOnTerminalRuntime(e){var n,i,o,a;const r=[...new Set([...this.viewInitAckWaiters.keys(),...this.viewServiceReadyWaiters.keys(),...[...this.serviceSyncCommitWaiters.values()].map(({viewId:c})=>c),...this.initReconcileTasks.keys(),...this.viewGenerationById.keys(),...this.viewContainerManager.getAllViews().filter(c=>!!c).map(c=>c.id)])];(i=(n=this.control).invalidateAllPendingViewInit)==null||i.call(n),this.serviceSyncCommitWaiters.forEach(c=>{clearTimeout(c.timer),c.resolve(!1)}),this.serviceSyncCommitWaiters.clear();for(const c of r){this.releaseCameraRecovery(c,`terminal-render-runtime:${e.reportErrorCode||"unknown"}`);const l=e.viewId===c?e.viewGeneration??this.viewGenerationById.get(c):this.viewGenerationById.get(c);this.viewGenerationById.set(c,(this.viewGenerationById.get(c)??0)+1),this.initAckedViewIds.delete(c),this.serviceSyncReadyViews.delete(c);const u=this.viewInitAckWaiters.get(c);u==null||u.forEach(d=>{clearTimeout(d.timer),d.resolve(!1)}),this.viewInitAckWaiters.delete(c);const h=this.viewServiceReadyWaiters.get(c);h==null||h.forEach(d=>{clearTimeout(d.timer),d.resolve(!1)}),this.viewServiceReadyWaiters.delete(c);for(const[d,f]of this.viewInitAckTimeoutTimers)d.startsWith(`${c}:`)&&(clearTimeout(f),this.viewInitAckTimeoutTimers.delete(d));this.initCameraOptByView.delete(c),this.Logger.error(`[Appliance]: [render-init] stage=failed viewId=${c} generation=${l??"unknown"} errorCode=${e.reportErrorCode} reason=terminal-main-thread-runtime`)}this.initReconcileTasks.clear(),this.pendingTransportMessages.clear(),(o=this.viewInitRecoveryAttempts)==null||o.clear(),(a=this.viewInitRecoveryDestroying)==null||a.clear(),this.control.emitInitLoadingChange({loading:!1,phase:"ready",status:"error"})}settlePendingViewInitWaitersForRecovery(){var e,r,n,i,o,a,c,l;(e=this.viewInitAckWaiters)==null||e.forEach(u=>{u.forEach(h=>{clearTimeout(h.timer),h.resolve(!1)})}),(r=this.viewInitAckWaiters)==null||r.clear(),(n=this.viewServiceReadyWaiters)==null||n.forEach(u=>{u.forEach(h=>{clearTimeout(h.timer),h.resolve(!1)})}),(i=this.viewServiceReadyWaiters)==null||i.clear(),(o=this.serviceSyncCommitWaiters)==null||o.forEach(u=>{clearTimeout(u.timer),u.resolve(!1)}),(a=this.serviceSyncCommitWaiters)==null||a.clear();for(const u of((c=this.viewInitAckTimeoutTimers)==null?void 0:c.values())||[])clearTimeout(u);(l=this.viewInitAckTimeoutTimers)==null||l.clear()}isViewScopedInitFailure(e){return e.reportErrorCode==="INIT_CAMERA_CATCH_UP_FAILED"||e.reportErrorCode==="SERVICE_SYNC_COMMIT_TIMEOUT"||e.reportErrorCode==="RENDER_INIT_TIMEOUT"&&e.reportStage==="worker-service-ready"}scheduleViewInitRecovery(e,r){const{viewId:n,viewGeneration:i}=e;if(!n||i===void 0){this.failViewInitOnTerminalRuntime(e);return}const o=this.cameraUpdateStateByView.get(n),a=o==null?void 0:o.recoveryOwner;if(this.viewGenerationById.get(n)!==i||!this.viewContainerManager.getView(n)){this.logRenderRuntimeFallback("ignored-stale-view",{recoveryId:r,viewId:n,generation:i,errorCode:e.reportErrorCode},"warn"),this.releaseCameraRecovery(n,"stale-or-removed-view",o,a);return}if(this.viewInitRecoveryAttempts||(this.viewInitRecoveryAttempts=new Map),this.viewInitRecoveryDestroying||(this.viewInitRecoveryDestroying=new Set),this.viewInitRecoveryDestroying.has(n)){this.logRenderRuntimeFallback("ignored-view-recovery-running",{recoveryId:r,viewId:n,generation:i,errorCode:e.reportErrorCode},"warn");return}const c=this.viewInitRecoveryAttempts.get(n)||0,l=c>=Yp;l||this.viewInitRecoveryAttempts.set(n,c+1),this.logRenderRuntimeFallback(l?"view-init-recovery-exhausted":"view-init-recovery-start",{recoveryId:r,viewId:n,generation:i,attempt:c+1,maxAttempts:Yp,errorCode:e.reportErrorCode},l?"error":"warn"),l&&(this.viewInitRecoveryAttempts.delete(n),this.releaseCameraRecovery(n,"view-init-recovery-exhausted",o,a)),this.viewInitRecoveryDestroying.add(n);try{this.destroyViewWorker(n,"preserve-storage",!l&&(o==null?void 0:o.isRecovering)===!0)}finally{this.viewInitRecoveryDestroying.delete(n)}if(l){this.Logger.error(`[Appliance]: [render-init] stage=failed viewId=${n} generation=${i} errorCode=${e.reportErrorCode} reason=view-init-recovery-exhausted`),n===Fe&&this.control.emitInitLoadingChange({loading:!1,phase:"ready",status:"error"});return}const u=this.viewContainerManager.mountView(n);if(o!=null&&o.isRecovering){const d=o.replayCamera;d&&this.control.queuePendingInitCamera(n,d.cameraOpt,d.scenePath)}const h=this.viewGenerationById.get(n);u.catch(d=>{var f;this.Logger.error(`[Appliance]: [render-init] stage=remount-failed viewId=${n} error=${d instanceof Error?d.message:String(d)}`),this.viewGenerationById.get(n)===h&&((f=this.viewInitRecoveryAttempts)==null||f.delete(n)),this.releaseCameraRecovery(n,"view-remount-failed",o,a)})}scheduleRenderRuntimeFallback(e){var c,l,u,h;if(e.reportErrorCode!==L0e&&e.reportErrorCode!=="SERVICE_SYNC_COMMIT_TIMEOUT"&&e.reportErrorCode!=="IMAGE_BITMAP_RENDER_FAILED"&&e.reportErrorCode!=="INIT_CAMERA_CATCH_UP_FAILED"&&e.reportErrorCode!=="RENDER_INIT_TIMEOUT"&&e.reportErrorCode!=="CAMERA_TRANSPORT_TIMEOUT"&&e.reportErrorCode!=="RENDERER_RUNTIME_ERROR")return;if(((l=(c=this.control).isRenderRuntimeRecoveryAllowed)==null?void 0:l.call(c))===!1){e.viewId&&this.releaseCameraRecovery(e.viewId,"manager-lifecycle-ended");return}const r=`render-recovery-${Date.now()}-${++this.renderRuntimeFallbackSequence}`,n=this.activeRenderRuntimeRecovery;if(n){if(e.reportErrorCode==="CAMERA_TRANSPORT_TIMEOUT"&&e.viewId){const d=this.cameraUpdateStateByView.get(e.viewId),f=n.views.find(g=>g.viewId===e.viewId);d!=null&&d.isRecovering&&d.replayCamera&&f?(f.replayCamera=this.cloneCameraReplay(d.replayCamera),f.cameraRecoveryOwner=d.recoveryOwner,this.control.queuePendingInitCamera(e.viewId,d.replayCamera.cameraOpt,d.replayCamera.scenePath)):d!=null&&d.isRecovering&&!f&&this.releaseCameraRecovery(e.viewId,"view-not-in-active-runtime-recovery",d)}this.logRenderRuntimeFallback("ignored-already-running",{recoveryId:n.recoveryId,viewId:e.viewId,generation:e.viewGeneration,errorCode:e.reportErrorCode},"warn");return}if(this.isViewScopedInitFailure(e)||e.reportErrorCode==="CAMERA_TRANSPORT_TIMEOUT"&&this.control.renderMode==="main-thread"){this.scheduleViewInitRecovery(e,r);return}if(this.control.renderMode==="main-thread"){this.logRenderRuntimeFallback("ignored-terminal-runtime",{recoveryId:r,viewId:e.viewId,generation:e.viewGeneration,errorCode:e.reportErrorCode,renderModel:"mainThread+canvas2d"},"warn"),this.failViewInitOnTerminalRuntime(e);return}(h=(u=this.control).invalidateAllPendingViewInit)==null||h.call(u),this.serviceSyncReadyViews.clear();const i=this.viewContainerManager.getAllViews().filter(d=>!!d).map(d=>{var y,S;const f=this.cameraUpdateStateByView.get(d.id),g=f?this.beginCameraRecovery(d.id,f):void 0;return(S=(y=this.control).armPendingViewInit)==null||S.call(y,d.id),g&&this.control.queuePendingInitCamera(d.id,g.cameraOpt,g.scenePath),{viewId:d.id,view:d,lifecycleGeneration:this.control.getViewLifecycleGeneration(d.id),viewGeneration:this.viewGenerationById.get(d.id),scenePath:d.focusScenePath,cameraOpt:d.cameraOpt?{...d.cameraOpt}:void 0,replayCamera:g,cameraRecoveryOwner:f==null?void 0:f.recoveryOwner}}),o={recoveryId:r,startedAt:Date.now(),fromRenderMode:this.control.renderMode,fromContextType:this.control.renderingCompatibilityDecision.contextType,views:i,cacheInvalidation:Promise.resolve()};this.activeRenderRuntimeRecovery=o,this.settlePendingViewInitWaitersForRecovery(),o.cacheInvalidation=(this.renderRuntimeCacheSavePromise||Promise.resolve()).catch(()=>{}).then(()=>{var d,f;return(f=(d=this.control).invalidateRenderRuntimeDecision)==null?void 0:f.call(d)}).then(()=>{}).catch(d=>{this.logRenderRuntimeFallback("cache-invalidate-failed",{recoveryId:o.recoveryId,error:d instanceof Error?d.message:String(d)},"warn")}),this.control.queuePendingRuntimeReset(()=>this.runRenderRuntimeFallback(e,o)).then(d=>{d&&this.persistRecoveredRenderRuntime(o,d)}).catch(d=>{this.releaseRenderRuntimeRecoveryCameras(o,"unexpected-runtime-recovery-failure"),this.activeRenderRuntimeRecovery===o&&(this.activeRenderRuntimeRecovery=void 0),this.logRenderRuntimeFallback("failed",{recoveryId:o.recoveryId,errorCode:e.reportErrorCode,failureStage:"unexpected",error:d instanceof Error?d.message:String(d),elapsedMs:Date.now()-o.startedAt},"error")})}isRenderRuntimeRecoveryCurrent(e){return this.activeRenderRuntimeRecovery===e}assertRenderRuntimeRecoveryCurrent(e){var r,n;if(!this.isRenderRuntimeRecoveryCurrent(e))throw new Ai;if(((n=(r=this.control).isRenderRuntimeRecoveryAllowed)==null?void 0:n.call(r))===!1)throw e.cancelReason||(e.cancelReason="manager-lifecycle-ended"),new Ai;if(!this.viewContainerManager.getAllViews().some(i=>!!i))throw e.cancelReason||(e.cancelReason="no-active-views"),new Ai}isRenderRuntimeRecoveryViewCurrent(e){return this.viewContainerManager.getView(e.viewId)===e.view&&this.control.isPendingViewInitCurrent(e.viewId,e.lifecycleGeneration)}finishRenderRuntimeRecovery(e){var n,i;this.assertRenderRuntimeRecoveryCurrent(e);const r=[];for(const o of e.views)this.isRenderRuntimeRecoveryViewCurrent(o)&&(r.push(o.viewId),(i=(n=this.control).invalidatePendingViewInit)==null||i.call(n,o.viewId));this.activeRenderRuntimeRecovery=void 0,r.forEach(o=>{if(this.isServiceSyncReady(o)){this.control.onViewServiceReady(o);const a=this.viewGenerationById.get(o);a!==void 0&&this.dispatchCameraRecoveryReplay(o,a)}})}persistRecoveredRenderRuntime(e,r){const n=e.cacheInvalidation.then(async()=>{var i,o,a,c;this.activeRenderRuntimeRecovery||((o=(i=this.control).isRenderRuntimeRecoveryAllowed)==null?void 0:o.call(i))!==!1&&(this.control.renderMode!==r.renderMode||this.control.renderingCompatibilityDecision.contextType!==r.contextType||await((c=(a=this.control).persistRenderRuntimeDecision)==null?void 0:c.call(a)))}).catch(i=>{this.logRenderRuntimeFallback("cache-save-failed",{recoveryId:e.recoveryId,error:i instanceof Error?i.message:String(i)},"warn")});this.renderRuntimeCacheSavePromise=n}cancelRenderRuntimeRecovery(e){const r=this.activeRenderRuntimeRecovery;r&&(r.cancelReason=e,this.activeRenderRuntimeRecovery=void 0)}async runRenderRuntimeFallback(e,r=this.activeRenderRuntimeRecovery){if(r)try{return await this.runActiveRenderRuntimeFallback(e,r)}catch(n){if(!(n instanceof Ai))throw this.activeRenderRuntimeRecovery===r&&(this.activeRenderRuntimeRecovery=void 0),n;this.logRenderRuntimeFallback("cancelled",{recoveryId:r.recoveryId,reason:r.cancelReason||"runtime-recovery-cancelled",elapsedMs:Date.now()-r.startedAt}),this.releaseRenderRuntimeRecoveryCameras(r,r.cancelReason||"runtime-recovery-cancelled"),this.activeRenderRuntimeRecovery===r&&(this.activeRenderRuntimeRecovery=void 0);return}}async runActiveRenderRuntimeFallback(e,r){var m,v,M,k,E,D;const{recoveryId:n,startedAt:i,fromRenderMode:o,fromContextType:a}=r,{views:c}=r;this.assertRenderRuntimeRecoveryCurrent(r),this.serviceSyncReadyViews.clear(),this.logRenderRuntimeFallback("triggered",{recoveryId:n,from:`${o}/${a}`,viewId:e.viewId,generation:e.viewGeneration,errorCode:e.reportErrorCode,reportStage:e.reportStage,contextLost:e.reportContextLost,glError:e.reportGlError,currentProgram:e.reportCurrentProgram,programLinked:e.reportProgramLinked,programHasUniforms:e.reportProgramHasUniforms,elapsedMs:Date.now()-i}),this.logRenderRuntimeFallback("drain-start",{recoveryId:n,viewIds:c.map(({viewId:P})=>P)});const l=await Promise.all(c.map(async P=>{const{viewId:z,scenePath:j}=P;if(!this.isRenderRuntimeRecoveryViewCurrent(P))return{viewId:z,status:"stale"};if(!j)return{viewId:z,status:"success"};try{return await this.forceDoneLocalWorks(z,j,"render-runtime-fallback")}catch(A){return{viewId:z,status:"failed",failureReason:A instanceof Error?A.message:String(A)}}}));this.assertRenderRuntimeRecoveryCurrent(r);const u=l.filter(P=>P.status==="failed");this.logRenderRuntimeFallback("drain-result",{recoveryId:n,status:u.length?"partial-failure":"success",failures:u.map(P=>({viewId:P.viewId,reason:P.failureReason})),elapsedMs:Date.now()-i},u.length?"warn":"info");const h=this.getRenderProbeCandidates(),d=Date.now(),f=h.findIndex(P=>P.renderMode===o&&(P.contextType===a||P.contextType==="webgl2"&&a==="webgl")),y=((v=(m=this.control.pluginOptions)==null?void 0:m.extras)==null?void 0:v.allowImageBitmapFallback)===!1&&o==="worker-image-bitmap"?h.length:f,S=this.getRenderProbeProfile();let b=S&&this.createRenderProbeSession(S);const I=new Map,N=new Set,T=P=>`${P.renderMode}:${P.contextType}`,p=(P,z)=>{const j=T(P);let A=I.get(j);if(!A&&(A=this.probeRenderRuntimeCandidate(P,Math.min(Cs,z),b||void 0),I.set(j,A),P.renderMode==="worker-image-bitmap"&&P.contextType!=="2d")){const R=h.find(L=>L.renderMode===P.renderMode&&L.contextType==="2d");R&&!I.has(T(R))&&I.set(T(R),this.probeRenderRuntimeCandidate(R,Math.min(Cs,z),b||void 0))}return A||Promise.resolve(void 0)};try{for(let P=y+1;P<h.length;P+=1){this.assertRenderRuntimeRecoveryCurrent(r);const z=h[P];if(N.has(T(z)))continue;const j=Ht(z.renderMode,z.contextType);this.logRenderRuntimeFallback("triggered",{recoveryId:n,from:`${o}/${a}`,to:j,viewId:e.viewId,generation:e.viewGeneration,errorCode:e.reportErrorCode,elapsedMs:Date.now()-i});const A=ra-(Date.now()-d);if(A<=0){this.logRenderRuntimeFallback("failed",{recoveryId:n,target:j,errorCode:e.reportErrorCode,failureStage:"candidate-probe-budget"},"warn");break}const R=await p(z,A);this.assertRenderRuntimeRecoveryCurrent(r);let L=na(R);if(L&&z.contextType!=="2d"&&((k=(M=this.control).requiresCanvas2DCompanionRenderProbe)!=null&&k.call(M))){const H=ra-(Date.now()-d),ie=h.find(V=>V.renderMode===z.renderMode&&V.contextType==="2d"),O=H>0&&ie?await p(ie,H):void 0;ie&&N.add(T(ie)),this.assertRenderRuntimeRecoveryCurrent(r),L=L&&na(O)}const W=Hp(z,R),Y=Ht(W.renderMode,W.contextType);if(this.logRenderRuntimeFallback(L?"candidate-probe-success":"candidate-probe-failed",{recoveryId:n,target:Y,errorCode:e.reportErrorCode,probeStage:(E=R==null?void 0:R.programProbe)==null?void 0:E.stage,probeError:((D=R==null?void 0:R.programProbe)==null?void 0:D.error)||(R?void 0:"timeout")},L?"info":"warn"),!!L){b&&(this.closeRenderProbeSession(b),b=void 0),this.control.applyRuntimeRenderingDecision(W.renderMode,W.contextType,"runtime-webgl-program-failure",`Runtime render recovery selected ${Y}`),this.control.renderingCompatibilityDecision.renderRuntimeSource="fallback";try{return await this.rebuildRenderRuntimeOnSerialQueue(c,W.renderMode,r),this.assertRenderRuntimeRecoveryCurrent(r),this.logRenderRuntimeFallback("success",{recoveryId:n,from:`${o}/${a}`,to:Y,elapsedMs:Date.now()-i}),this.finishRenderRuntimeRecovery(r),{renderMode:W.renderMode,contextType:W.contextType}}catch(H){if(H instanceof Ai)throw H;this.logRenderRuntimeFallback("failed",{recoveryId:n,target:j,errorCode:e.reportErrorCode,failureStage:"candidate-rebuild",error:H instanceof Error?H.message:String(H),elapsedMs:Date.now()-i},"warn"),I.clear(),b=S&&this.createRenderProbeSession(S)}}}}finally{b&&this.closeRenderProbeSession(b)}this.assertRenderRuntimeRecoveryCurrent(r),this.logRenderRuntimeFallback("fallback-main-thread-start",{recoveryId:n,from:`${o}/${a}`,to:"mainThread+canvas2d",errorCode:e.reportErrorCode,elapsedMs:Date.now()-i});try{return this.control.applyRuntimeRenderingDecision("main-thread","2d","runtime-webgl-program-failure","All worker render candidates failed; downgraded to mainThread Canvas2D"),this.control.renderingCompatibilityDecision.renderRuntimeSource="fallback",await this.rebuildRenderRuntimeOnSerialQueue(c,"main-thread",r),this.assertRenderRuntimeRecoveryCurrent(r),this.logRenderRuntimeFallback("fallback-main-thread-success",{recoveryId:n,to:"mainThread+canvas2d",elapsedMs:Date.now()-i}),this.logRenderRuntimeFallback("success",{recoveryId:n,to:"mainThread+canvas2d",elapsedMs:Date.now()-i}),this.finishRenderRuntimeRecovery(r),{renderMode:"main-thread",contextType:"2d"}}catch(P){if(P instanceof Ai)throw P;const z=P instanceof Error?P.message:String(P);this.logRenderRuntimeFallback("fallback-main-thread-failed",{recoveryId:n,errorCode:e.reportErrorCode,failureStage:"main-thread-canvas2d-rebuild",error:z,elapsedMs:Date.now()-i},"error"),this.logRenderRuntimeFallback("failed",{recoveryId:n,target:"mainThread+canvas2d",errorCode:e.reportErrorCode,failureStage:"main-thread-canvas2d-rebuild",error:z,elapsedMs:Date.now()-i},"error"),this.failViewInitOnTerminalRuntime(e),this.activeRenderRuntimeRecovery===r&&(this.activeRenderRuntimeRecovery=void 0);return}}async rebuildRenderRuntimeOnSerialQueue(e,r,n){var o,a,c,l,u,h,d,f,g,y,S,b;const{recoveryId:i}=n;this.assertRenderRuntimeRecoveryCurrent(n),this.destroy(!0,!0);for(const I of e){if(this.assertRenderRuntimeRecoveryCurrent(n),!this.isRenderRuntimeRecoveryViewCurrent(I)){this.logRenderRuntimeFallback("surface-reset",{recoveryId:i,viewId:I.viewId,status:"view-stale"});continue}const{view:N}=I;(a=(o=this.control).clearPendingViewInitState)==null||a.call(o,I.viewId),(l=(c=this.control).armPendingViewInit)==null||l.call(c,I.viewId);const T=this.cameraUpdateStateByView.get(I.viewId),p=T!=null&&T.isRecovering&&T.replayCamera?this.cloneCameraReplay(T.replayCamera):I.replayCamera;p&&(I.replayCamera=this.cloneCameraReplay(p),(T==null?void 0:T.recoveryOwner)!==void 0&&(I.cameraRecoveryOwner=T.recoveryOwner),this.control.queuePendingInitCamera(I.viewId,p.cameraOpt,p.scenePath)),N.focusScenePath=I.scenePath;const m=(p==null?void 0:p.cameraOpt)||I.cameraOpt;if(m&&(N.cameraOpt={...m}),this.logRenderRuntimeFallback("surface-reset-start",{recoveryId:i,viewId:I.viewId,elapsedMs:Date.now()-(((u=this.activeRenderRuntimeRecovery)==null?void 0:u.startedAt)||Date.now())}),await N.displayer.resetRenderSurface(),this.assertRenderRuntimeRecoveryCurrent(n),this.logRenderRuntimeFallback("surface-reset-completed",{recoveryId:i,viewId:I.viewId,elapsedMs:Date.now()-(((h=this.activeRenderRuntimeRecovery)==null?void 0:h.startedAt)||Date.now())}),!this.isRenderRuntimeRecoveryViewCurrent(I)){this.logRenderRuntimeFallback("surface-reset",{recoveryId:i,viewId:I.viewId,status:"view-removed",elapsedMs:Date.now()-(((d=this.activeRenderRuntimeRecovery)==null?void 0:d.startedAt)||Date.now())});continue}if(this.logRenderRuntimeFallback("surface-reset",{recoveryId:i,viewId:I.viewId,generation:this.viewGenerationById.get(I.viewId),target:`${r}/${this.control.renderingCompatibilityDecision.contextType}`,elapsedMs:Date.now()-(((f=this.activeRenderRuntimeRecovery)==null?void 0:f.startedAt)||Date.now())}),this.control.isUseOffscreenTransfer){const v=N.displayer.canvasBgRef.current,M=N.displayer.canvasServiceFloatRef.current,k=N.displayer.canvasFloatRef.current;if(!v||!M||!k)throw new Error(`render surface unavailable: ${I.viewId}`);N.displayer.setTransferControlToOffscreenCanvas({bgCanvas:v,serviceCanvas:M,localCanvas:k})}this.logRenderRuntimeFallback("surface-created",{recoveryId:i,viewId:I.viewId,elapsedMs:Date.now()-(((g=this.activeRenderRuntimeRecovery)==null?void 0:g.startedAt)||Date.now())})}if(this.logRenderRuntimeFallback("reinit-start",{recoveryId:i,target:`${r}/${this.control.renderingCompatibilityDecision.contextType}`,elapsedMs:Date.now()-(((y=this.activeRenderRuntimeRecovery)==null?void 0:y.startedAt)||Date.now())}),await this.init(!0),this.assertRenderRuntimeRecoveryCurrent(n),this.control.renderMode!==r)throw new Error(`render mode changed during reinit: expected=${r}, actual=${this.control.renderMode}`);for(const I of e){if(this.assertRenderRuntimeRecoveryCurrent(n),!this.isRenderRuntimeRecoveryViewCurrent(I))continue;const{view:N}=I,T=this.cameraUpdateStateByView.get(I.viewId);T!=null&&T.isRecovering&&T.replayCamera&&(I.replayCamera=this.cloneCameraReplay(T.replayCamera),I.cameraRecoveryOwner=T.recoveryOwner,N.cameraOpt={...T.replayCamera.cameraOpt});const p=this.viewContainerManager.getViewInitData(I.viewId);if(!p)throw new Error(`view init data unavailable: ${I.viewId}`);(b=(S=this.control).resetPendingInitRendererBaseline)==null||b.call(S,I.viewId),this.createViewWorker(I.viewId,p,N.displayer);const m=this.viewGenerationById.get(I.viewId);if(m===void 0)throw new Error(`view generation unavailable: ${I.viewId}`);this.logRenderRuntimeFallback("init-sent",{recoveryId:i,viewId:I.viewId,generation:m,elapsedMs:Date.now()-n.startedAt});const v=await this.waitForViewInitCompletion(I.viewId);if(this.assertRenderRuntimeRecoveryCurrent(n),!!this.isRenderRuntimeRecoveryViewCurrent(I)&&v==="timeout")throw new Error(`render view init completion timeout: ${I.viewId}`)}}assertMarkmapRuntimeRegistered(e,r){try{tM()}catch(n){const i=n instanceof Error?n.message:String(n);throw this.Logger.error(`[Appliance]: [markmap] ${e} failed: ${i}; viewId=${r}`),n}}destroy(e=!1,r=!1){var o,a,c,l,u,h,d,f,g,y,S,b,I,N,T,p,m,v;const n=[],i=(M,k)=>{try{k()}catch(E){n.push(`${M}: ${E instanceof Error?E.message:String(E)}`)}};e||this.cancelRenderRuntimeRecovery("external-destroy"),this.initGeneration++,this.viewGenerationById.forEach((M,k)=>{this.viewGenerationById.set(k,M+1)}),this.animationId!==void 0&&(cancelAnimationFrame(this.animationId),this.animationId=void 0),this.viewInitAckWaiters.forEach(M=>{M.forEach(k=>{clearTimeout(k.timer),k.resolve(!1)})}),this.viewInitAckWaiters.clear(),this.serviceSyncCommitWaiters.forEach(M=>{clearTimeout(M.timer),M.resolve(!1)}),this.serviceSyncCommitWaiters.clear(),this.viewServiceReadyWaiters.forEach(M=>{M.forEach(k=>{clearTimeout(k.timer),k.resolve(!1)})}),this.viewServiceReadyWaiters.clear(),this.initReconcileTasks.clear(),this.fullLayerFrameStateByView.clear(),this.hasMainViewInitAck=!1,e||this.mainViewInitReady.cancel(),this.serviceSyncReadyViews.clear(),this.initAckedViewIds.clear(),this.pendingTransportMessages.clear(),(o=this.viewInitRecoveryAttempts)==null||o.clear(),(a=this.viewInitRecoveryDestroying)==null||a.clear();for(const M of this.viewInitAckTimeoutTimers.values())clearTimeout(M);this.viewInitAckTimeoutTimers.clear(),this.renderRuntimeCacheSavePromise=void 0,this.isRenderTransportReady=!1,this.initCameraOptByView.clear(),this.mainViewInitAckCallbacks.clear(),i("method-builder",()=>{var M;return(M=this.methodBuilder)==null?void 0:M.destroy()}),i("un-writable",()=>this.unWritable()),i("task-queue",()=>this.destroyTaskQueue(r)),this.taskBatchData.clear(),r||(this.cameraUpdateStateByView.clear(),(c=this.cameraClearReplayByView)==null||c.clear()),this.cameraFailureSequenceByView.clear(),this.cameraTaskSequenceByView.clear(),(l=this.localWorkFinalizeQueueByView)==null||l.clear(),this.operationBarrierQueueByView.clear(),(u=this.willSelectorWorkIdByView)==null||u.clear(),(h=this.operationBarrierInvalidationWaitersByView)==null||h.forEach(M=>{M.forEach(k=>k())}),(d=this.operationBarrierInvalidationWaitersByView)==null||d.clear(),(f=this.operationBarrierEpochByView)==null||f.clear(),[...this.fullLayerBitmapEraseTxns.keys()].forEach(M=>{this.finishFullLayerBitmapEraseTxn(M,"aborted")}),this.fullLayerBitmapEraseTxnWaiters.forEach(M=>{M.forEach(k=>k("aborted"))}),this.fullLayerBitmapEraseTxnWaiters.clear(),this.cancelledEraseTxnIds.clear(),this.cancelledEraseTxnOwners.clear(),(g=this.cancelledLocalWorkOwners)==null||g.clear();for(const M of this.pendingDprByView.keys())(S=(y=this.control)==null?void 0:y.viewContainerManager.getView(M))==null||S.displayer.cancelDprUpdate();this.pendingDprByView.clear(),(b=this.pendingDprOwnerByView)==null||b.clear(),this.viewRecoveryQueueByView.clear(),this.cameraUpdateEndWaitersByView.forEach((M,k)=>{var E;r&&((E=this.cameraUpdateStateByView.get(k))!=null&&E.isRecovering)||(M.forEach(D=>D()),this.cameraUpdateEndWaitersByView.delete(k))}),this.viewLifecycleIdleWaitersByView.forEach((M,k)=>{var E;r&&((E=this.cameraUpdateStateByView.get(k))!=null&&E.isRecovering)||(M.forEach(D=>D()),this.viewLifecycleIdleWaitersByView.delete(k))}),this.tmpImageConfigMap.clear(),this.localPointsBatchData.clear(),this.localEventQueueByView.clear(),(I=this.localInputEpochByView)==null||I.clear(),(N=this.localInputTransactionEpochByView)==null||N.clear(),this.localEventQueue=Promise.resolve(),this.localDoneDispatchTimersByView.forEach(M=>{M.forEach(k=>clearTimeout(k)),M.clear()}),this.localDoneDispatchTimersByView.clear();for(const M of((T=this.delayWorkStateToDoneResolveByView)==null?void 0:T.values())||[])M(!1);(p=this.delayWorkStateToDoneResolveByView)==null||p.clear(),(m=this.localDoneWaitByView)==null||m.clear(),(v=this.delayWorkStateToDoneResolve)==null||v.call(this,!1),this.delayWorkStateToDoneResolve=void 0,this.localDoneWait=void 0,this.isActive=!1,this.clearAllResolveMap.forEach(({timer:M,resolve:k},E)=>{M&&clearTimeout(M),k==null||k(E)}),this.clearAllResolveMap.clear(),this.snapshotMap.forEach(({resolve:M,value:k})=>{M(k.map(E=>E||null))}),this.snapshotMap.clear(),this.snapshotRequestIdByViewScene.clear(),this.boundingRectMap.forEach(({resolve:M})=>{M({x:0,y:0,w:0,h:0})}),this.boundingRectMap.clear(),this.boundingRectRequestIdByViewScene.clear(),this.refreshTextRenderResolveMap.forEach(({timer:M,resolve:k})=>{M&&clearTimeout(M),k==null||k(!1)}),this.refreshTextRenderResolveMap.clear(),this.settlePendingMarkmapRequestsOnDestroy(),this.getVNodeInfoResolveMap.forEach(({timer:M,resolve:k},E)=>{M&&clearTimeout(M),k==null||k({uuid:E})}),this.getVNodeInfoResolveMap.clear(),this.clearReRenders(1/0),i("font-face",()=>this.fontFaceManager.destroy()),i("main-thread",()=>{var M;return(M=this.mainThread)==null?void 0:M.destroy()}),this.mainThread=void 0,i("background-thread",()=>{var M;return(M=this.backgroundThreadManager)==null?void 0:M.destroy()}),this.backgroundThreadManager=void 0,i("full-worker",()=>{var M;return(M=this.fullWorker)==null?void 0:M.terminate()}),this.fullWorker=void 0,i("sub-worker",()=>{var M;return(M=this.subWorker)==null?void 0:M.terminate()}),this.subWorker=void 0,n.length&&this.Logger.error(`[Appliance]: MainEngine destroy completed with cleanup errors: ${n.join("; ")}`)}settlePendingMarkmapRequestsOnDestroy(){this.markmapIdResolveMap.forEach(({timer:e,resolve:r})=>{e&&clearTimeout(e),r==null||r()}),this.markmapIdResolveMap.clear()}get consumeCount(){return this._consumeCount}set consumeCount(e){this._consumeCount=e}acceptConsumeAck(e,r){if(!ye.isNumber(e)||r&&!Array.from(this.localPointsBatchData.keys()).some(i=>i.toString()===r))return!1;const n=Math.max(this.consumeCount,e);if(n===this.consumeCount)return!1;if(this.consumeCount=n,r){const i=this.getFullLayerBitmapEraseTxns().get(r);i&&i.phase!=="committed"&&i.phase!=="aborting"&&i.phase!=="aborted"&&(i.doingAckCount=Math.max(i.doingAckCount||0,n))}return this.runAnimation(),!0}get postCount(){return this._postCount}isServiceSyncReady(e){return this.serviceSyncReadyViews.has(e)}isRenderRuntimeRecovering(){return this.activeRenderRuntimeRecovery!==void 0}isViewInitReady(e){return this.isViewInitAck(e)&&this.isServiceSyncReady(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===q.Pencil||e===q.PencilEraser||e===q.BitMapEraser||e===q.LaserPen||e===q.Arrow||e===q.Straight||e===q.Ellipse||e===q.Rectangle||e===q.Star||e===q.Polygon||e===q.SpeechBalloon||e===q.Selector}get isCanDrawWork(){var r;const e=(r=this.currentToolsData)==null?void 0:r.toolsType;return e===q.Pencil||e===q.LaserPen||e===q.Arrow||e===q.Straight||e===q.Ellipse||e===q.Rectangle||e===q.Star||e===q.Polygon||e===q.SpeechBalloon||e===q.Triangle||e===q.Rhombus||e===q.BitMapEraser||e===q.PencilEraser}get isUseZIndex(){var r;const e=(r=this.currentToolsData)==null?void 0:r.toolsType;return e===q.Pencil||e===q.Arrow||e===q.Straight||e===q.Ellipse||e===q.Rectangle||e===q.Star||e===q.Polygon||e===q.SpeechBalloon||e===q.Text||e===q.Image}get isCanRecordUndoRedo(){var r;const e=(r=this.currentToolsData)==null?void 0:r.toolsType;return e===q.Pencil||e===q.Eraser||e===q.PencilEraser||e===q.BitMapEraser||e===q.Arrow||e===q.Straight||e===q.Ellipse||e===q.Rectangle||e===q.Star||e===q.Polygon||e===q.SpeechBalloon||e===q.Text||e===q.Image}get isCanSentCursor(){var r;const e=(r=this.currentToolsData)==null?void 0:r.toolsType;return e===q.Pencil||e===q.Text||e===q.LaserPen||e===q.Arrow||e===q.Straight||e===q.Ellipse||e===q.Rectangle||e===q.Star||e===q.Polygon||e===q.SpeechBalloon||e===q.Triangle||e===q.Rhombus||e===q.Eraser||e===q.PencilEraser||e===q.BitMapEraser||e===q.Selector||e===q.Clicker}get isPostCountType(){var r;const e=(r=this.currentToolsData)==null?void 0:r.toolsType;return e===q.Pencil||e===q.Arrow||e===q.Straight||e===q.Ellipse||e===q.Rectangle||e===q.Star||e===q.Polygon||e===q.SpeechBalloon||e===q.Triangle||e===q.Rhombus||e===q.Eraser||e===q.PencilEraser||e===q.BitMapEraser||e===q.Selector}get isCanPostDraw(){var r;const e=(r=this.currentToolsData)==null?void 0:r.toolsType;return e===q.Pencil||e===q.PencilEraser||e===q.BitMapEraser}get isCanStartEventConsum(){var r;const e=(r=this.currentToolsData)==null?void 0:r.toolsType;return e===q.Selector||e===q.Eraser||e===q.PencilEraser||e===q.BitMapEraser}async init(e=!1){e||this.destroy(!0),this.mainViewInitReady.begin(),this.control.emitInitLoadingChange({loading:!0,phase:"worker",status:"start"});try{this.Logger.info(`[Appliance]: [plugin-options] ${JSON.stringify(this.control.pluginOptions.extras)}`)}catch(r){this.Logger.warn(`[Appliance]: [plugin-options] stringify failed: ${(r==null?void 0:r.message)||r}`)}try{if(await this.on()===!1)return;this.internalMsgEmitterListener(),this.isActive=!0,this.control.emitInitLoadingChange({loading:!0,phase:"worker",status:"success"})}catch(r){throw this.mainViewInitReady.cancel(),this.control.emitInitLoadingChange({loading:!1,phase:"worker",status:"error"}),r}}async useBackgroundThread(){this.Logger.info("[Appliance]: use background thread");const{BackgroundThreadManagerImpl:e}=await Promise.resolve().then(()=>require("./index-qlVmoCd1.js"));this.backgroundThreadManager=new e(this)}async useMainThread(){this.Logger.info("[Appliance]: no OffscreenCanvas");const{MainThreadManagerImpl:e}=await Promise.resolve().then(()=>require("./index-Do5kJ_zq.js"));this.mainThread=new e(this),this.isRenderTransportReady=!0,this.flushPendingTransportInitMessages()}getRenderProbeCandidates(){var c,l;const e=this.control.renderingCompatibilityDecision,r=e.capabilities,n=((l=(c=this.control.pluginOptions)==null?void 0:c.extras)==null?void 0:l.allowImageBitmapFallback)!==!1,i=e.contextType==="webgl2"?["webgl2","2d"]:e.contextType==="webgl"?["webgl","2d"]:["2d"],o=e.renderMode==="worker-image-bitmap"&&e.reason!=="use-simple-false"?["worker-image-bitmap"]:["worker-offscreen-transfer","worker-image-bitmap"],a=[];for(const u of o)if(!(u==="worker-offscreen-transfer"&&!r.offscreenTransfer||u==="worker-image-bitmap"&&(!r.imageBitmap||!n)))for(const h of i)h==="webgl2"&&!r.webgl2||h==="webgl"&&!r.webgl||a.push({renderMode:u,contextType:h});return a}getRenderProbeProfile(){return{width:$p,height:$p,dpr:1,testRect:{...kwe}}}createRenderProbeDOMCanvas(e){if(typeof document>"u")return;const r=document.createElement("div");r.className="appliance-render-test-container",r.setAttribute("aria-hidden","true"),Object.assign(r.style,{position:"fixed",left:"0",top:"0",width:"1px",height:"1px",overflow:"hidden",pointerEvents:"none",zIndex:"-2147483647",contain:"layout style size"});let n;const i=()=>(n==null||n.remove(),n=document.createElement("canvas"),n.className="appliance-render-test-canvas",n.width=Math.max(1,Math.floor(e.width*e.dpr)),n.height=Math.max(1,Math.floor(e.height*e.dpr)),Object.assign(n.style,{width:"1px",height:"1px",opacity:"0",pointerEvents:"none"}),r.appendChild(n),n);return document.body.appendChild(r),i(),{get canvas(){return n},replaceCanvas:i,cleanup:()=>r.remove()}}async probeRenderRuntimeCandidate(e,r=Cs,n){const i=!n,o=(n==null?void 0:n.profile)||this.getRenderProbeProfile(),a=n||o&&this.createRenderProbeSession(o);if(a)try{return await this.requestRenderProbeCandidate(a,e,r)}finally{i&&this.closeRenderProbeSession(a)}}createRenderProbeSession(e){const r=this.createRenderProbeDOMCanvas(e);if(!r)return;let n;try{n=new Worker(this.fullWorkerUrl,{type:"classic"})}catch{r.cleanup();return}const i={worker:n,profile:e,domTest:r,pending:new Map,destinationQueue:Promise.resolve(),closed:!1};n.onmessage=a=>{var h,d,f;const c=a.data;if(!c||c.type!==le.ProbeRenderCapabilities||!c.requestId)return;const l=i.pending.get(c.requestId);if(!l){try{(f=(d=(h=c.workerCapabilities)==null?void 0:h.programProbe)==null?void 0:d.imageBitmap)==null||f.close()}catch{}return}clearTimeout(l.timer);const u=i.destinationQueue.then(()=>this.finalizeRenderProbeResponse(i,l,c.workerCapabilities));i.destinationQueue=u.then(()=>{},()=>{}),u.then(g=>this.resolveRenderProbeEntry(i,c.requestId,l,g),()=>this.resolveRenderProbeEntry(i,c.requestId,l,void 0))};const o=()=>{i.closed=!0;for(const[a,c]of i.pending)i.pending.delete(a),clearTimeout(c.timer),c.resolve(void 0)};return n.onerror=o,n.onmessageerror=o,i}closeRenderProbeSession(e){if(e.closed&&e.pending.size===0){e.worker.terminate(),e.domTest.cleanup();return}e.closed=!0;for(const[r,n]of e.pending)e.pending.delete(r),clearTimeout(n.timer),n.resolve(void 0);e.worker.terminate(),e.domTest.cleanup()}resolveRenderProbeEntry(e,r,n,i){e.pending.get(r)===n&&(e.pending.delete(r),clearTimeout(n.timer),n.resolve(i))}requestRenderProbeCandidate(e,r,n){if(e.closed)return Promise.resolve(void 0);const i=`render-probe-${Date.now()}-${Math.random().toString(36).slice(2)}`,o=Date.now()+n;let a,c,l;try{if(r.renderMode==="worker-offscreen-transfer"){const u=e.domTest.replaceCanvas();c=u,a=u.transferControlToOffscreen()}else e.imageBitmapDestination||(e.imageBitmapDestination=e.domTest.replaceCanvas()),l=e.imageBitmapDestination;return new Promise(u=>{var d;const h=setTimeout(()=>{const f=e.pending.get(i);f&&(e.pending.delete(i),f.resolve(void 0))},n);e.pending.set(i,{candidate:r,sourceCanvas:c,destinationCanvas:l,deadlineAt:o,timer:h,resolve:u});try{e.worker.postMessage(new Set([{msgType:le.ProbeRenderCapabilities,type:le.ProbeRenderCapabilities,requestId:i,requestedContextType:r.contextType,probeTransport:r.renderMode,probeCanvas:a,probeProfile:e.profile}]),a?[a]:[])}catch{if(((d=e.pending.get(i))==null?void 0:d.resolve)!==u)return;e.pending.delete(i),clearTimeout(h),u(void 0)}})}catch{return Promise.resolve(void 0)}}async finalizeRenderProbeResponse(e,r,n){var a,c,l;const i=n==null?void 0:n.programProbe,o=i==null?void 0:i.imageBitmap;if(!n||!i)return n;try{if(i.passed!==!0)return n;const u=r.candidate.renderMode==="worker-image-bitmap"&&i.expectedPixelChecks||i.pixelChecks;if(!u||u.length<4)throw new Error("probe-pixel-check-template-missing");const h={width:Math.max(1,Math.floor(e.profile.width*e.profile.dpr)),height:Math.max(1,Math.floor(e.profile.height*e.profile.dpr))};if(((a=i.canvasSize)==null?void 0:a.width)!==h.width||((c=i.canvasSize)==null?void 0:c.height)!==h.height)throw new Error("probe-canvas-size-mismatch");let d;if(r.candidate.renderMode==="worker-offscreen-transfer"){if(!r.sourceCanvas)throw new Error("offscreen-transfer-dom-canvas-unavailable");d=await this.readTransferredCanvasDestinationPixels(r.sourceCanvas,h,u,r.deadlineAt)}else{if(!o)throw new Error("image-bitmap-missing");if(!i.imageBitmapRect)throw new Error("image-bitmap-rect-missing");const g=(l=r.destinationCanvas)==null?void 0:l.getContext("2d");if(!g)throw new Error("destination-2d-context-unavailable");g.clearRect(0,0,h.width,h.height);const{x:y,y:S,width:b,height:I}=i.imageBitmapRect;g.drawImage(o,0,0,b,I,y,S,b,I),d=Gp(g,u)}const f=Qu(d);return n.contextSupported=n.contextSupported&&f,n.programProbe={...i,passed:i.passed===!0&&f,stage:f?i.stage:"destination-pixel-check",error:f?i.error:r.candidate.renderMode==="worker-offscreen-transfer"?"offscreen-transfer-destination-pixel-check-failed":"destination-pixel-check-failed",destinationPixelChecks:d,imageBitmap:void 0},n}catch(u){return n.contextSupported=!1,n.programProbe={...i,passed:!1,stage:"destination-pixel-check",error:yr(u),destinationPixelChecks:void 0,imageBitmap:void 0},n}finally{try{o==null||o.close()}catch{}}}async readTransferredCanvasDestinationPixels(e,r,n,i){if(typeof document>"u")return;const o=document.createElement("canvas");o.width=r.width,o.height=r.height;const a=o.getContext("2d");if(!a)return;let c,l=0;for(;Date.now()<i;)if(await Awe(i),l+=1,!(l<2)&&(a.clearRect(0,0,r.width,r.height),a.drawImage(e,0,0,r.width,r.height,0,0,r.width,r.height),c=Gp(a,n),Qu(c)))return c;return c}async probeAndLockRenderRuntime(){var u,h;const e=this.getRenderProbeCandidates(),r=this.getRenderProbeProfile(),n=Date.now();this.Logger.info(`[Appliance]: [render-probe] stage=probe-start candidates=${e.map(d=>Ht(d.renderMode,d.contextType)).join(",")}`);const i=r&&this.createRenderProbeSession(r),o=new Map,a=new Set,c=d=>`${d.renderMode}:${d.contextType}`,l=(d,f)=>{const g=c(d);let y=o.get(g);if(!y&&(y=this.probeRenderRuntimeCandidate(d,Math.min(Cs,f),i||void 0),o.set(g,y),d.renderMode==="worker-image-bitmap"&&d.contextType!=="2d")){const S=e.find(b=>b.renderMode===d.renderMode&&b.contextType==="2d");S&&!o.has(c(S))&&o.set(c(S),this.probeRenderRuntimeCandidate(S,Math.min(Cs,f),i||void 0))}return y||Promise.resolve(void 0)};try{for(const d of e){if(a.has(c(d)))continue;const f=ra-(Date.now()-n);if(f<=0)break;const g=Ht(d.renderMode,d.contextType);this.Logger.info(`[Appliance]: [render-probe] stage=candidate-start renderModel=${g} canvasSize=${r?`${Math.floor(r.width*r.dpr)}x${Math.floor(r.height*r.dpr)}`:"unavailable"} logicalSize=${r?`${r.width}x${r.height}`:"unavailable"} dpr=${(r==null?void 0:r.dpr)??"unavailable"} rect=${r?`${r.testRect.x},${r.testRect.y},${r.testRect.width}x${r.testRect.height}`:"unavailable"}`);const y=await l(d,f),S=na(y);let b=S,I,N;if(b&&d.contextType!=="2d"&&((h=(u=this.control).requiresCanvas2DCompanionRenderProbe)!=null&&h.call(u))){I=e.find(v=>v.renderMode===d.renderMode&&v.contextType==="2d");const m=ra-(Date.now()-n);N=I&&m>0?await l(I,m):void 0,I&&a.add(c(I)),b=b&&na(N)}const T=Hp(d,y),p=Ht(T.renderMode,T.contextType);if(!b){const m=S?"companion":"primary",v=S?N:y,M=v==null?void 0:v.programProbe,k=S?Ht((I==null?void 0:I.renderMode)||d.renderMode,(I==null?void 0:I.contextType)||"2d"):p,E=(M==null?void 0:M.error)||(v?"probe-result-incomplete":S?"timeout-or-budget":"timeout");this.Logger.warn(`[Appliance]: [render-probe] stage=candidate-failed renderModel=${p} requestedRenderModel=${g} failureSource=${m} failedRenderModel=${k} stageDetail=${(M==null?void 0:M.stage)||"probe-result-incomplete"} error=${E} canvasSize=${M!=null&&M.canvasSize?`${M.canvasSize.width}x${M.canvasSize.height}`:"unavailable"} rect=${M!=null&&M.testRect?`${M.testRect.x},${M.testRect.y},${M.testRect.width}x${M.testRect.height}`:"unavailable"} expected=rgba(255,0,0,255)/transparent workerActual=${JSON.stringify((M==null?void 0:M.pixelChecks)||[])} destinationActual=${JSON.stringify((M==null?void 0:M.destinationPixelChecks)||[])}`)}if(b)return this.control.applyRuntimeRenderingDecision(T.renderMode,T.contextType,"render-probe-passed",`render-probe-passed:${p}`),this.control.renderingCompatibilityDecision.renderRuntimeSource="probe",this.Logger.info(`[Appliance]: [render-probe] stage=probe-success renderModel=${p}${I?" companion=passed":""}`),!0}}finally{i&&this.closeRenderProbeSession(i)}return this.Logger.warn("[Appliance]: [render-probe] stage=probe-failed renderModel=mainThread+canvas2d"),this.control.applyRuntimeRenderingDecision("main-thread","2d","worker-program-probe-failed","All worker render candidates failed"),this.control.renderingCompatibilityDecision.renderRuntimeSource="fallback",await this.useMainThread(),!1}async on(e=!1){var a,c;const r=++this.initGeneration;if(!e&&(this.control.isUseBackgroundThread&&await this.useBackgroundThread(),r!==this.initGeneration))return!1;if(!this.control.hasOffscreenCanvas){await this.useMainThread(),this.control.logFinalRenderDecision();return}if(!this.fullWorkerUrl||!this.control.isUseSimple&&!this.subWorkerUrl)throw new Error("[Appliance]: no worker url config");if(((c=(a=this.control.pluginOptions)==null?void 0:a.extras)==null?void 0:c.useWorker)==="auto"&&this.control.renderingCompatibilityDecision.renderRuntimeCacheState!=="hit"&&!this.control.isRenderRuntimeDecisionLocked()){const l=await this.probeAndLockRenderRuntime();if(r!==this.initGeneration)return!1;if(!l){this.control.logFinalRenderDecision();return}}else this.control.renderingCompatibilityDecision.renderRuntimeCacheState==="hit"&&this.Logger.info(`[Appliance]: [render-probe] stage=probe-skipped reason=cache-hit renderModel=${Ht(this.control.renderMode,this.control.renderingCompatibilityDecision.contextType)}`);const i=(l,u)=>()=>{r!==this.initGeneration||!u()||this.scheduleRenderRuntimeFallback({type:le.ReportError,reportErrorCode:"RENDERER_RUNTIME_ERROR",reportStage:`${l}-transport-error`,reportError:`${l} transport error`})};if(this.fullWorker=new Worker(this.fullWorkerUrl,{type:"classic"}),!this.control.isUseSimple){this.subWorker=new Worker(this.subWorkerUrl,{type:"classic"});const l=this.subWorker;l.onerror=i("subWorker",()=>this.subWorker===l),l.onmessageerror=i("subWorker-message",()=>this.subWorker===l)}const o=this.fullWorker;o.onerror=i("fullWorker",()=>this.fullWorker===o),o.onmessageerror=i("fullWorker-message",()=>this.fullWorker===o),this.fullWorker.onmessage=l=>{if(l.data){if(!this.acceptWorkerBatch(l.data,"fullWorker"))return;const{render:u,sp:h,fullWorkerDrawCount:d,workerTasksqueueCount:f,cameraTaskId:g,cameraTaskStatus:y,cameraTaskError:S,cameraSettledTaskId:b,viewId:I,viewGeneration:N,consumeCount:T,consumeWorkId:p}=l.data;if(I&&ye.isNumber(g)){const D=R0(y,S,"fullWorker");D?this.failCameraTask(I,g,D,N):this.ackCameraTask(I,g,N)}I&&ye.isNumber(b)?this.ackCameraSettledTask(I,b,N):this.isBusy&&f&&this.setWorkerTasksqueueCount(f);const m=this.control.isUseOffscreenTransfer?[]:(h||[]).filter(({type:D})=>D===le.ServiceSyncCommit),v=m.length?(h||[]).filter(({type:D})=>D!==le.ServiceSyncCommit):h;v!=null&&v.length&&this.collectorSyncData(v);const M=this.filterCancelledEraseRenders(u);if(this.control.isUseSimple){if(this.control.isUseOffscreenTransfer){this.acceptConsumeAck(T,p);return}let D=!0;if(M.length)try{this.viewContainerManager.render(M)}catch(P){D=!1,this.Logger.error(`[Appliance]: Bitmap/Pencil render apply failed; viewId=${I||"unknown"}; workId=${p||"unknown"}; error=${P instanceof Error?P.message:String(P)}`),this.scheduleRenderRuntimeFallback({type:le.ReportError,viewId:I,viewGeneration:I?this.viewGenerationById.get(I):void 0,reportErrorCode:"IMAGE_BITMAP_RENDER_FAILED",reportStage:"main-thread-draw-image-bitmap",reportError:P instanceof Error?P.message:String(P)})}D&&m.length&&this.collectorSyncData(m),this.acceptConsumeAck(T,p);return}const k=M;if(d&&I){if(this.fullWorkerDrawCount=d,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())k.push(...D)}let E=!0;if(k.length)try{this.viewContainerManager.render(k)}catch(D){E=!1,this.Logger.error(`[Appliance]: Bitmap/Pencil render apply failed; viewId=${I||"unknown"}; workId=${p||"unknown"}; error=${D instanceof Error?D.message:String(D)}`),this.scheduleRenderRuntimeFallback({type:le.ReportError,viewId:I,viewGeneration:I?this.viewGenerationById.get(I):void 0,reportErrorCode:"IMAGE_BITMAP_RENDER_FAILED",reportStage:"main-thread-draw-image-bitmap",reportError:D instanceof Error?D.message:String(D)})}E&&m.length&&this.collectorSyncData(m),this.acceptConsumeAck(T,p)}},this.isRenderTransportReady=!0,this.control.lockRenderRuntimeDecision(),this.control.logFinalRenderDecision(),this.flushPendingTransportInitMessages(),this.subWorker&&(this.subWorker.onmessage=l=>{if(l.data){if(!this.acceptWorkerBatch(l.data,"subWorker"))return;const{render:u,sp:h,subWorkerDrawCount:d,consumeCount:f,consumeWorkId:g}=l.data;h!=null&&h.length&&this.collectorSyncData(h);const y=this.filterCancelledEraseRenders(u),S=y;if(ye.isNumber(d)){if(this.subWorkerDrawCount=d,this.fullWorkerDrawCount<1/0){const b=Math.max(this.maxDrawCount,this.subWorkerDrawCount);this.setMaxDrawCount(b)}if(y.length)if(this.subWorkerDrawCount>this.fullWorkerDrawCount){const b=[];for(const I of y)I.imageBitmap&&(I.isUnClose=!0,b.push(I));this.reRenders.set(this.subWorkerDrawCount,b)}else this.reRenders.size&&this.clearReRenders(this.subWorkerDrawCount)}if(S.length)try{this.viewContainerManager.render(S)}catch(b){this.Logger.error(`[Appliance]: SubWorker render apply failed; workId=${g||"unknown"}; error=${b instanceof Error?b.message:String(b)}`)}this.acceptConsumeAck(f,g)}})}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 i;if(!e)return;const n=this.refreshTextRenderResolveMap.get(e);n&&(n.timer&&clearTimeout(n.timer),(i=n.resolve)==null||i.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.isViewInitReady(o.viewId))continue;const a=this.createInternalRequestId("refresh_text_render");n.push(this.waitRefreshTextRender(a)),r.add({...o,requestId:a,msgType:le.UpdateNode,type:le.UpdateNode,dataType:xe.Service,toolsType:q.Text,refreshTextRender:!0,useAnimation:!1,willRefresh:!0})}return this.post(r),(await Promise.all(n)).every(Boolean)}buildPropertyAppliedData(e,r,n){switch(e){case Te.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 Te.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 Te.SetLock:return{isLocked:n==null?void 0:n.isLocked};case Te.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 Te.ZIndexNode:return{zIndexLayer:n==null?void 0:n.zIndexLayer};default:return{}}}clearReRenders(e=1/0){for(const r of this.reRenders.keys())if(ye.isNumber(Number(r))&&Number(r)<=e){const n=this.reRenders.get(Number(r));n==null||n.forEach(i=>{try{this.retireRenderedImageBitmap(i)}catch(o){this.Logger.error(`[Appliance]: releasing deferred render bitmap failed; drawCount=${r}; error=${o instanceof Error?o.message:String(o)}`)}}),this.reRenders.delete(r)}}retireRenderedImageBitmap(e){var n;const r=(n=this.control)==null?void 0:n.viewContainerManager;r?r.retireRenderImageBitmap(e.viewId,e.imageBitmap):this.closeImageBitmap(e.imageBitmap)}getFullLayerBitmapEraseTxns(){return this.fullLayerBitmapEraseTxns||(this.fullLayerBitmapEraseTxns=new Map),this.fullLayerBitmapEraseTxns}getBitmapEraserRenderer(){return this.control.disableUseWorker?"main-thread":this.control.isUseSimple?"simple-worker":"full-worker"}logBitmapEraserTrace(e,r,n={}){try{const i=this.Logger,o=`[Appliance]: [bitmap-eraser] stage=${e} ${JSON.stringify({viewId:r.viewId,scenePath:r.scenePath,workId:r.workId,renderer:this.getBitmapEraserRenderer(),...n})}`;if(e==="point-limit-force-done"){i.info(o);return}i.infoDebounced?i.infoDebounced(`bitmap-eraser:${r.viewId}:${r.workId}`,o):i.info(o)}catch{}}finishFullLayerBitmapEraseTxn(e,r){var o,a,c,l;const n=this.getFullLayerBitmapEraseTxns().get(e);n!=null&&n.commitTimeoutId&&clearTimeout(n.commitTimeoutId),n&&(n.phase=r==="committed"?"committed":"aborted",this.logBitmapEraserTrace("terminal",n,{status:r,elapsedMs:Math.max(0,Date.now()-(n.startedAt??Date.now())),forceDoneReason:n.forceDoneReason,doingAckCount:n.doingAckCount||0,pointCount:n.inputPointCount||0,updatedTargets:((o=n.updatedTargetIds)==null?void 0:o.size)||0,deletedTargets:((a=n.deletedTargetIds)==null?void 0:a.size)||0})),this.getFullLayerBitmapEraseTxns().delete(e);const i=(c=this.fullLayerBitmapEraseTxnWaiters)==null?void 0:c.get(e);i==null||i.forEach(u=>u(r)),(l=this.fullLayerBitmapEraseTxnWaiters)==null||l.delete(e)}async waitForFullLayerBitmapEraseTxns(e,r){const n=[...r].filter(a=>this.getFullLayerBitmapEraseTxns().has(a));if(!n.length)return;if(this.fullLayerBitmapEraseTxnWaiters||(this.fullLayerBitmapEraseTxnWaiters=new Map),(await Promise.all(n.map(a=>new Promise(c=>{let l=this.fullLayerBitmapEraseTxnWaiters.get(a);l||(l=new Set,this.fullLayerBitmapEraseTxnWaiters.set(a,l)),l.add(c)})))).includes("aborted")){const a=this.viewRecoveryQueueByView.get(e);a&&await a.catch(()=>{})}}rememberCancelledEraseTxn(e){var o;this.cancelledEraseTxnOwners||(this.cancelledEraseTxnOwners=new Map),this.cancelledEraseTxnIds.delete(e),this.cancelledEraseTxnIds.add(e);const r=this.getFullLayerBitmapEraseTxns().get(e),n=this.localPointsBatchData.get(e),i=(r==null?void 0:r.viewId)||(n==null?void 0:n.viewId);for(this.cancelledEraseTxnOwners.set(e,{viewId:i,viewGeneration:i?(o=this.viewGenerationById)==null?void 0:o.get(i):void 0});this.cancelledEraseTxnOwners.size>Zl;){const a=this.cancelledEraseTxnOwners.keys().next().value;if(a===void 0)break;this.cancelledEraseTxnOwners.delete(a),this.cancelledEraseTxnIds.delete(a)}for(;this.cancelledEraseTxnIds.size>Zl;){const a=this.cancelledEraseTxnIds.values().next().value;if(a===void 0)break;this.cancelledEraseTxnIds.delete(a),this.cancelledEraseTxnOwners.delete(a)}}isCancelledEraseResult(e,r,n){var o;if(!e||!this.cancelledEraseTxnIds.has(e))return!1;const i=(o=this.cancelledEraseTxnOwners)==null?void 0:o.get(e);return i?!(i.viewId&&r&&i.viewId!==r):!0}rememberCancelledLocalWork(e,r){var n;for(this.cancelledLocalWorkOwners||(this.cancelledLocalWorkOwners=new Map),this.cancelledLocalWorkOwners.delete(e),this.cancelledLocalWorkOwners.set(e,{viewId:r,viewGeneration:(n=this.viewGenerationById)==null?void 0:n.get(r)});this.cancelledLocalWorkOwners.size>Zl;){const i=this.cancelledLocalWorkOwners.keys().next().value;if(i===void 0)break;this.cancelledLocalWorkOwners.delete(i)}}isCancelledLocalWorkResult(e){return e.dataType===xe.Service||e.workId===void 0?!1:this.isCancelledLocalWork(e.workId.toString(),e.viewId)}isCancelledLocalWork(e,r){var c,l,u,h;const n=e.toString(),o=typeof((c=this.collector)==null?void 0:c.isOwn)=="function"&&typeof((l=this.collector)==null?void 0:l.getLocalId)=="function"&&((u=this.collector)!=null&&u.isOwn(n))?this.collector.getLocalId(n):n,a=(h=this.cancelledLocalWorkOwners)==null?void 0:h.get(o);return a?!r||a.viewId===r:!1}filterCancelledEraseRenders(e){return e!=null&&e.length?e.filter(r=>{const n=this.viewGenerationById.get(r.viewId);if(r.viewGeneration!==void 0&&n!==void 0&&r.viewGeneration!==n)return this.closeImageBitmap(r.imageBitmap),!1;if(r.drawCanvas!==void 0&&[...r.renderWorkIds||[],...r.workId!==void 0?[r.workId.toString()]:[]].some(o=>this.isCancelledLocalWork(o,r.viewId)))return this.closeImageBitmap(r.imageBitmap),!1;const i=[...r.renderEraseTxnIds||[],...r.eraseTxnId!==void 0?[r.eraseTxnId]:[]].some(o=>this.isCancelledEraseResult(o,r.viewId,r.viewGeneration));if(i)try{this.closeImageBitmap(r.imageBitmap)}catch(o){this.logLocalWorkBarrierError(`[Appliance]: releasing cancelled erase bitmap failed; viewId=${r.viewId}; eraseTxnId=${r.eraseTxnId}; error=${o instanceof Error?o.message:String(o)}`)}return!i}):[]}reportRenderFrameError(e,r){this.Logger.error(`[Appliance]: [render-image-bitmap-frame] stage=rejected reason=${e} source=${r.source} layer=Bg viewId=${r.viewId} receivedGeneration=${r.receivedGeneration??"unknown"} currentGeneration=${r.currentGeneration??"unknown"} taskId=${r.taskId??"unknown"} sequence=${r.sequence??"unknown"} lastTaskId=${r.lastTaskId??"unknown"} lastSequence=${r.lastSequence??"unknown"} maxSequence=${r.maxSequence??"unknown"}`)}acceptFullLayerFrame(e,r,n){if(!e.isFullFrameImageBitmap||e.frameSequence===void 0)return!0;const i=e.viewGeneration??n;if(i===void 0)return!0;const o=this.fullLayerFrameStateByView.get(e.viewId),a=(o==null?void 0:o.generation)===i?o:{generation:i,maxSequence:0},c=a[r];if(c){if(e.frameSequence===c.sequence)return this.reportRenderFrameError("duplicate-sequence",{source:r,viewId:e.viewId,receivedGeneration:i,currentGeneration:this.viewGenerationById.get(e.viewId),taskId:e.taskId,sequence:e.frameSequence,lastTaskId:c.taskId,lastSequence:c.sequence,maxSequence:a.maxSequence}),!1;if(e.frameSequence<c.sequence)return this.reportRenderFrameError("out-of-order-sequence",{source:r,viewId:e.viewId,receivedGeneration:i,currentGeneration:this.viewGenerationById.get(e.viewId),taskId:e.taskId,sequence:e.frameSequence,lastTaskId:c.taskId,lastSequence:c.sequence,maxSequence:a.maxSequence}),!1}return this.fullLayerFrameStateByView.set(e.viewId,{...a,generation:i,maxSequence:Math.max(a.maxSequence,e.frameSequence),[r]:{sequence:e.frameSequence,taskId:e.taskId}}),!0}acceptWorkerBatch(e,r="fullWorker"){var a,c,l,u;const{viewId:n,viewGeneration:i,render:o}=e;if(n&&i!==void 0&&this.viewGenerationById.get(n)!==i){const h=o==null?void 0:o.find(d=>d.isFullFrameImageBitmap);return o!=null&&o.length&&this.reportRenderFrameError("stale-generation",{source:r,viewId:n,receivedGeneration:i,currentGeneration:this.viewGenerationById.get(n),taskId:h==null?void 0:h.taskId,sequence:h==null?void 0:h.frameSequence,maxSequence:(c=(a=this.fullLayerFrameStateByView)==null?void 0:a.get(n))==null?void 0:c.maxSequence}),o==null||o.forEach(d=>{try{this.closeImageBitmap(d.imageBitmap)}catch(f){this.logLocalWorkBarrierError(`[Appliance]: releasing stale render bitmap failed; viewId=${n}; error=${f instanceof Error?f.message:String(f)}`)}}),(l=e.sp)==null||l.forEach(d=>{try{this.closeImageBitmap(d.imageBitmap)}catch(f){this.logLocalWorkBarrierError(`[Appliance]: releasing stale message bitmap failed; viewId=${n}; error=${f instanceof Error?f.message:String(f)}`)}}),!1}return(u=e.sp)!=null&&u.length&&i!==void 0&&(e.sp=e.sp.map(h=>{const d=h.viewId||n;return h.viewGeneration!==void 0||h.viewId&&h.viewId!==n?h:{...h,viewId:d,viewGeneration:i}})),o!=null&&o.length&&(e.render=o.filter(h=>{var y,S;const d=h.viewId||n,f=d?this.viewGenerationById.get(d):void 0,g=h.viewGeneration??i;return d&&f!==void 0&&g!==void 0&&g!==f?(this.reportRenderFrameError("stale-generation",{source:r,viewId:d,receivedGeneration:g,currentGeneration:f,taskId:h.taskId,sequence:h.frameSequence,maxSequence:(S=(y=this.fullLayerFrameStateByView)==null?void 0:y.get(d))==null?void 0:S.maxSequence}),this.closeImageBitmap(h.imageBitmap),!1):this.acceptFullLayerFrame(h,r,i)?!0:(this.closeImageBitmap(h.imageBitmap),!1)})),!0}scheduleViewRecovery(e,r){const n=this.viewGenerationById.get(e),o=(this.viewRecoveryQueueByView.get(e)||Promise.resolve()).catch(()=>{}).then(async()=>{if(this.viewGenerationById.get(e)!==n||!this.viewContainerManager.getView(e))return;const a=this.viewContainerManager.getCurScenePath(e);a&&(this.Logger.error(`[Appliance]: rebuilding view after bitmap eraser failure; viewId=${e}; reason=${r}`),await this.clearViewScenePath(e,!0),!(this.viewGenerationById.get(e)!==n||this.viewContainerManager.getCurScenePath(e)!==a)&&this.pullServiceData(e,a,{isAsync:!0,useAnimation:!1}))});return this.viewRecoveryQueueByView.set(e,o),o.then(()=>{this.viewRecoveryQueueByView.get(e)===o&&(this.viewRecoveryQueueByView.delete(e),this.resolveViewLifecycleIdleWaiters(e))},a=>{this.viewRecoveryQueueByView.get(e)===o&&(this.viewRecoveryQueueByView.delete(e),this.resolveViewLifecycleIdleWaiters(e)),this.logLocalWorkBarrierError(`[Appliance]: view recovery failed; viewId=${e}; error=${a instanceof Error?a.message:String(a)}`)}),o}get isBusy(){return this.cameraUpdateStateByView.size>0||this.pendingDprByView.size>0||this.viewRecoveryQueueByView.size>0}isViewBusy(e){var r;return((r=this.cameraUpdateStateByView.get(e))==null?void 0:r.isBusy)===!0||this.pendingDprByView.has(e)||this.viewRecoveryQueueByView.has(e)||this.control.isClearBusy(e)}getLockSentEventCursor(){return this.isLockSentEventCursor}setLockSentEventCursor(e){this.isLockSentEventCursor=e}getTasksqueueState(){return this.isBusy&&de.Doing||de.Done}setMaxDrawCount(e){this.maxDrawCount=e}getFullWorkDrawCount(){return this.fullWorkerDrawCount}getMaxDrawCount(){return this.maxDrawCount}setSubWorkerDrawCount(e){this.subWorkerDrawCount=e}setConsumeCount(e,r){this.acceptConsumeAck(e,r)}getConsumeCount(){return this.consumeCount}getLocalInputPointCount(e,r){let n=0;for(const i of this.localPointsBatchData.values())i.viewId!==e||r&&i.toolsType!==r||(n=Math.max(n,Math.floor(i.rawPoints.length/2)));return n}setWorkerTasksqueueCount(e){ye.isNumber(e)}collectorSyncData(e){var c,l,u,h,d,f,g,y,S,b,I,N,T,p,m,v;const r=e.filter(M=>{if(this.isStaleViewStorageMessage(M))return M.imageBitmap&&this.closeImageBitmap(M.imageBitmap),!1;if(this.isCancelledLocalWorkResult(M))return this.closeImageBitmap(M.imageBitmap),!1;const k=this.isCancelledEraseResult(M.eraseTxnId,M.viewId,M.viewGeneration);return k&&this.closeImageBitmap(M.imageBitmap),!k}),n=new Set(r.filter(M=>M.eraseTxnId&&M.eraseTxnPhase==="applied").map(M=>M.eraseTxnId)),i=new Set(r.filter(M=>M.eraseTxnId&&M.eraseTxnPhase==="failed").map(M=>M.eraseTxnId)),o=new Map;for(const M of r){if(M.eraseTxnRecoveryRequired&&M.viewId&&o.set(M.viewId,"bitmap-eraser-done-restore-failed"),!M.eraseTxnId)continue;const k=this.getFullLayerBitmapEraseTxns().get(M.eraseTxnId);if(k){if(M.eraseTxnBeforeImages){k.beforeImages||(k.beforeImages=new Map);const E=M.eraseTxnBeforeImages;E instanceof Map?E.forEach((D,P)=>{k.beforeImages.has(P)||k.beforeImages.set(P,ye.cloneDeep(D)),(k.affectedTargetIds||(k.affectedTargetIds=new Set)).add(P)}):Object.entries(E).forEach(([D,P])=>{k.beforeImages.has(D)||k.beforeImages.set(D,ye.cloneDeep(P)),(k.affectedTargetIds||(k.affectedTargetIds=new Set)).add(D)})}if(M.type===le.UpdateNode&&M.workId!==void 0&&M.workId.toString()!==M.eraseTxnId&&((k.updatedTargetIds||(k.updatedTargetIds=new Set)).add(M.workId.toString()),(k.appliedTargetIds||(k.appliedTargetIds=new Set)).add(M.workId.toString())),M.type===le.RemoveNode&&((c=M.removeIds)!=null&&c.length)){const E=k.deletedTargetIds||(k.deletedTargetIds=new Set);M.removeIds.forEach(D=>{const P=D.toString();P!==M.eraseTxnId&&(E.add(P),(k.appliedTargetIds||(k.appliedTargetIds=new Set)).add(P))})}}}let a=!1;for(const M of r){if(this.fontFaceManager.handleWorkerMessage(M))continue;const{type:k,selectIds:E,opt:D,selectRect:P,strokeColor:z,fillColor:j,willSyncService:A,isSync:R,imageBitmap:L,canvasHeight:W,canvasWidth:Y,rect:H,op:ie,canTextEdit:O,points:V,selectorColor:Z,canRotate:$,scaleType:ee,textOpt:se,toolsType:ce,workId:me,viewId:pe,dataType:B,canLock:F,isLocked:J,shapeOpt:oe,toolsTypes:K,thickness:te,strokeType:w,useStroke:C,isgl:U,imageSrc:G,isSubWorker:_,updateNodeOpt:re,emitEventType:ne,requestId:X,viewOwner:ae,reportString:ue,reportBusiness:he,reportErrorCode:ge,index:Me,imageElement:we,workState:be,isSelecting:Ce,needUndoTicker:Ie}=M;if(k===le.Init&&pe){this.ackMainViewInit(pe,M.viewGeneration,M.reportContextType);continue}if(k===le.ServiceSyncCommit&&pe){Promise.resolve().then(()=>this.ackServiceSyncCommit(M));continue}if(!pe)continue;const Ae=M.scenePath||this.viewContainerManager.getCurScenePath(pe);switch(k){case le.RefreshTextRender:this.resolveRefreshTextRender(X,!0);break;case le.SelectorTransform:{if(ne&&be)try{(l=this.control.selectorApi)==null||l.onSelectorTransform({viewId:pe,emitEventType:ne,workState:be})}catch(Ee){(h=(u=this.Logger)==null?void 0:u.error)==null||h.call(u,`[Appliance]: [selector] onSelectorTransform failed: ${Ee==null?void 0:Ee.message}`)}break}case le.Select:{const Ee=E!=null&&E.length?{...P,selectIds:E,canvasHeight:W,canvasWidth:Y,points:V}:void 0;if(Ee&&(D!=null&&D.strokeColor)&&(Ee.selectorColor=D.strokeColor),Ee&&Z&&(Ee.selectorColor=Z),Ee&&z&&(Ee.strokeColor=z),Ee&&(D!=null&&D.fillColor)&&(Ee.fillColor=D.fillColor),Ee&&j&&(Ee.fillColor=j),Ee&&ye.isBoolean($)&&(Ee.canRotate=$),Ee&&ee&&(Ee.scaleType=ee),Ee&&O&&(Ee.canTextEdit=O),Ee&&se&&(Ee.textOpt=se),Ee&&ye.isBoolean(F)&&(Ee.canLock=F),Ee&&ye.isBoolean(J)&&(Ee.isLocked=J),Ee&&oe&&(Ee.shapeOpt=oe),Ee&&K&&(Ee.toolsTypes=K),Ee&&te&&(Ee.thickness=te),Ee&&w&&(Ee.strokeType=w),Ee&&ye.isBoolean(C)&&(Ee.useStroke=C),pe&&this.viewContainerManager.showFloatBar(pe,!!Ee,Ee),A&&((d=this.collector)==null||d.dispatch({type:k,selectIds:E,opt:D,isSync:R,viewId:pe,scenePath:Ae,needUndoTicker:Ie,requestId:X,emitEventType:ne})),Ce)break;try{(f=this.control.selectorApi)==null||f.onSelectorSync({viewId:pe,scenePath:Ae,selectIds:E,selectRect:P,selectorInfo:Ee})}catch(ke){(y=(g=this.Logger)==null?void 0:g.error)==null||y.call(g,`[Appliance]: [selector] onSelectorSync failed: ${ke==null?void 0:ke.message}`)}break}case le.Snapshot:if((L||we)&&Ae){const Ee=this.getViewSceneRequestKey(pe,Ae);if(!X||this.snapshotRequestIdByViewScene.get(Ee)!==X){this.closeImageBitmap(L);break}const ke=this.snapshotMap.get(Ee);if(ke&&ke.requestId===X){const{resolve:Ne,value:Oe}=ke;if(Oe&&Ne){const je=Me||0;Oe[je]=L||we,Oe.every(Je=>Je!==void 0)&&Ne(Oe)}}else this.closeImageBitmap(L)}break;case le.BoundingBox:if(H&&Ae){const Ee=this.getViewSceneRequestKey(pe,Ae);if(!X||this.boundingRectRequestIdByViewScene.get(Ee)!==X)break;const ke=this.boundingRectMap.get(Ee);ke&&ke.requestId===X&&ke.resolve(H)}break;case le.Cursor:ie&&this.control.cursor.collectServiceCursor({...M});break;case le.Clear:if(pe){this.viewContainerManager.showFloatBar(pe,!1);const Ee=(S=this.clearAllResolveMap.get(pe))==null?void 0:S.resolve;Ee&&Ee(pe);try{(b=this.control.selectorApi)==null||b.onSelectorCleared({viewId:pe,scenePath:Ae})}catch(ke){(N=(I=this.Logger)==null?void 0:I.error)==null||N.call(I,`[Appliance]: [selector] onSelectorCleared failed: ${ke==null?void 0:ke.message}`)}}break;case le.BackgroundSVGDelete:this.backgroundThreadManager&&pe&&this.backgroundThreadManager.consumeTargetOne(pe,{...M,msgType:le.BackgroundSVGDelete,viewId:pe,scenePath:Ae,dataType:xe.Local}).catch(Ee=>{this.logLocalWorkBarrierError(`[Appliance]: background SVG delete failed; viewId=${pe}; error=${Ee instanceof Error?Ee.message:String(Ee)}`)});break;case le.BackgroundSVGUpdate:this.backgroundThreadManager&&pe&&this.backgroundThreadManager.consumeTargetOne(pe,{...M,msgType:le.BackgroundSVGUpdate,viewId:pe,scenePath:Ae,dataType:xe.Local}).catch(Ee=>{this.logLocalWorkBarrierError(`[Appliance]: background SVG update failed; viewId=${pe}; error=${Ee instanceof Error?Ee.message:String(Ee)}`)});break;case le.TextUpdate:if(ce===q.Text&&me&&pe){const Ee=ne===Te.TranslateNode;ne&&[Te.SetColorNode,Te.SetFontStyle,Te.SetLock,Te.SetShapeOpt,Te.ZIndexNode].includes(ne)&&((T=this.control.selectorApi)==null||T.onPropertyApplied({type:ne,viewId:pe,scenePath:Ae,requestId:X,data:this.buildPropertyAppliedData(ne,D,re)}));const ke=this.viewContainerManager.transformToOriginPoint((D==null?void 0:D.boxPoint)||[0,0],pe),Ne=(D==null?void 0:D.boxSize)||[0,0],Oe=(p=this.viewContainerManager.getView(pe))==null?void 0:p.cameraOpt;D?this.control.textEditorManager.updateTextForWorker({x:ke[0],y:ke[1],w:Ne[0],h:Ne[1],scale:(Oe==null?void 0:Oe.scale)||1,workId:me,opt:D,dataType:B,viewId:pe,canSync:A||!1,canWorker:!1,updateNodeOpt:re,skipStorageDispatch:!0}):this.control.textEditorManager.delete(me,A||!1,!1),!!(Ie||Ee&&A)&&((m=this.collector)==null||m.dispatch({type:le.UpdateNode,workId:me,toolsType:q.Text,opt:D,updateNodeOpt:re,isSync:A||!1,viewId:pe,scenePath:Ae,needUndoTicker:Ie,requestId:X,emitEventType:ne}))}break;case le.GetTextActive:ce===q.Text&&me&&pe&&this.control.textEditorManager.updateTextForWorker({workId:me,isActive:!0,viewId:pe,dataType:xe.Local,canWorker:!1,canSync:!0},this.now);break;case le.GetImageBitMap:if(G&&pe&&me){const Ee=this.initGeneration,ke=this.viewGenerationById.get(pe),Ne=this.control.hasOffscreenCanvas;Wye({src:G,isgl:U,useImageBitmap:Ne}).then(Oe=>{var nt;const je=Ne?Oe:void 0,Je=Ne?void 0:Oe;if(!(Ee===this.initGeneration&&this.viewGenerationById.get(pe)===ke&&!!this.viewContainerManager.getView(pe))){this.closeImageBitmap(je);return}const et=new Set;et.add({msgType:le.GetImageBitMap,dataType:xe.Local,workId:me,viewId:pe,viewGeneration:ke,viewOwner:ae,imageSrc:G,requestId:X,isSubWorker:_,imageBitmap:je,imageElement:Je});try{if(Ne){const Qe=_&&this.subWorker?this.subWorker:this.fullWorker;if(!Qe||typeof Qe.postMessage!="function"){this.closeImageBitmap(je);return}je?Qe.postMessage(et,[je]):Qe.postMessage(et)}else{const Qe=(nt=this.mainThread)==null?void 0:nt.consume(et);Qe==null||Qe.catch(st=>{this.logLocalWorkBarrierError(`[Appliance]: image bitmap delivery failed; viewId=${pe}; workId=${me}; error=${st instanceof Error?st.message:String(st)}`)})}}catch(Qe){this.closeImageBitmap(je),this.logLocalWorkBarrierError(`[Appliance]: image bitmap delivery failed; viewId=${pe}; workId=${me}; error=${Qe instanceof Error?Qe.message:String(Qe)}`)}}).catch(Oe=>{this.logLocalWorkBarrierError(`[Appliance]: image bitmap load failed; viewId=${pe}; workId=${me}; src=${G}; error=${Oe instanceof Error?Oe.message:String(Oe)}`)})}break;case le.GetVNodeInfo:if(me){const Ee=me.toString(),ke=(v=this.getVNodeInfoResolveMap.get(Ee))==null?void 0:v.resolve,Ne={...M,uuid:Ee};ke&&ke(Ne)}break;case le.ReportError:case le.ReportLog:k===le.ReportError&&ge&&this.scheduleRenderRuntimeFallback(M),k===le.ReportError&&he&&Ae&&X&&(he==="snapshot"?this.settleSnapshotFailure(pe,Ae,X):this.settleBoundingRectFailure(pe,Ae,X)),ue&&(k===le.ReportError?this.Logger.error(`[Appliance]: [MasterControlForWorker] reportError ${ue}`):this.Logger.info(`[Appliance]: [MasterControlForWorker] reportLog ${ue}`));break;default:a=!0;break}}a&&this.collectorAsyncData(r),n.forEach(M=>{this.finishFullLayerBitmapEraseTxn(M,"committed")}),i.forEach(M=>{this.finishFullLayerBitmapEraseTxn(M,"aborted")}),o.forEach((M,k)=>{this.scheduleViewRecovery(k,M)})}collectorAsyncData(e){var r,n,i,o,a,c,l,u,h,d;for(const f of e){if(this.isStaleViewStorageMessage(f)){f.imageBitmap&&this.closeImageBitmap(f.imageBitmap);continue}if(this.isCancelledLocalWorkResult(f)){this.closeImageBitmap(f.imageBitmap);continue}if(this.isCancelledEraseResult(f.eraseTxnId,f.viewId,f.viewGeneration)){this.closeImageBitmap(f.imageBitmap);continue}const{type:g,op:y,workId:S,index:b,removeIds:I,ops:N,opt:T,updateNodeOpt:p,emitEventType:m,requestId:v,toolsType:M,isSync:k,viewId:E,isLockSentEventCursor:D,nextTasks:P,needUndoTicker:z,collectUndoTicker:j,undoScopeIds:A,undoScopePhase:R}=f;if(!E){console.error("[MasterControlForWorker] collectorAsyncData on viewId in",f);return}const L=f.scenePath||this.viewContainerManager.getCurScenePath(E),W=Number(j??z??void 0);if(W&&(A!=null&&A.length)&&(R==="collect"||R==="finalize")&&this.internalMsgEmitter.emit("collectExpectedWorkIds",W,E,A,L),R==="finalize"&&z&&Number(z)&&L){const Y=Number(z);Array.isArray(A)&&A.length===0?this.internalMsgEmitter.emit("cancelUndoTicker",Y,E,L):this.internalMsgEmitter.emit("finalizeRequested",Y,E,A||[],L)}switch(z&&Number(z)&&qp(g)&&(A!=null&&A.length)&&this.internalMsgEmitter.emit("reopenStorageAck",Number(z),E,A,L),g){case le.None:{const Y=this.initGeneration,H=(r=this.viewGenerationById)==null?void 0:r.get(E),ie=()=>{var O;return this.isActive&&this.initGeneration===Y&&((O=this.viewGenerationById)==null?void 0:O.get(E))===H};D&&Dr(()=>{ie()&&this.setLockSentEventCursor(!1)},this.maxLastSyncTime,this.control.hasPolyfillMethod("requestIdleCallback")),z&&Number(z)&&Dr(()=>{ie()&&this.internalMsgEmitter.emit("ackRenderUndoTicker",Number(z),E,L,{requestId:v,emitEventType:m})},0,this.control.hasPolyfillMethod("requestIdleCallback"));break}case le.DrawWork:{(n=this.collector)==null||n.dispatch({type:g,op:y,opt:T,toolsType:M,workId:S,index:b,isSync:k,viewId:E,scenePath:L,updateNodeOpt:p,needUndoTicker:z,collectUndoTicker:j,requestId:v,emitEventType:m});break}case le.FullWork:{if((i=this.collector)==null||i.dispatch({type:g,ops:N,workId:S,updateNodeOpt:p,opt:T,toolsType:M,isSync:k,viewId:E,scenePath:L,needUndoTicker:z,collectUndoTicker:j,requestId:v,emitEventType:m}),M===q.BackgroundSVG&&S&&this.markmapIdResolveMap.has(S.toString())){const H=this.markmapIdResolveMap.get(S.toString());H!=null&&H.timer&&(clearTimeout(H.timer),H.timer=void 0),H!=null&&H.resolve&&H.resolve(S.toString()),this.markmapIdResolveMap.delete(S.toString())}const Y=E?(o=this.willSelectorWorkIdByView)==null?void 0:o.get(E):void 0;Y&&S&&S.toString()===Y&&this.control.runEffectWork(()=>{var H;this.setShapeSelectorByWorkId(Y,E),(H=this.willSelectorWorkIdByView)==null||H.delete(E)});break}case le.UpdateNode:{m&&[Te.SetColorNode,Te.SetFontStyle,Te.SetLock,Te.SetShapeOpt,Te.ZIndexNode].includes(m)&&((a=this.control.selectorApi)==null||a.onPropertyApplied({type:m,viewId:E,scenePath:L,requestId:v,data:this.buildPropertyAppliedData(m,T,p)})),(c=this.collector)==null||c.dispatch({type:g,updateNodeOpt:p,workId:S,opt:T,ops:N,op:y,isSync:k,viewId:E,scenePath:L,needUndoTicker:z,collectUndoTicker:j,requestId:v,emitEventType:m});break}case le.RemoveNode:{if(m===Te.DeleteNode&&((l=this.control.selectorApi)==null||l.onRemoveNodeApplied({viewId:E,requestId:v,removeIds:I})),I&&this.control.textEditorManager.deleteBatch(I,!1,!1),(u=this.collector)==null||u.dispatch({type:g,removeIds:I,isSync:k,viewId:E,scenePath:L,needUndoTicker:z,collectUndoTicker:j,requestId:v,emitEventType:m}),E){const Y=(h=this.willSelectorWorkIdByView)==null?void 0:h.get(E);Y&&(I!=null&&I.includes(Y))&&((d=this.willSelectorWorkIdByView)==null||d.delete(E))}break}}P&&this.collectorAsyncData(P)}}isStaleViewStorageMessage(e){var n;if(!e.viewId)return!1;const r=(n=this.viewGenerationById)==null?void 0:n.get(e.viewId);return r===void 0?!1:e.viewGeneration!==void 0?e.viewGeneration!==r:qp(e.type)}async onLocalEventEnd(e,r,n=this.initGeneration,i=(o=>(o=this.localInputEpochByView)==null?void 0:o.get(r))()||0){var y,S,b,I,N;const a=this.viewContainerManager.getView(r),c=this.viewGenerationById.get(r);if(!a||!this.isActive||this.initGeneration!==n||(((y=this.localInputEpochByView)==null?void 0:y.get(r))||0)!==i||this.viewGenerationById.get(r)!==c)return;const{focusScenePath:l,cameraOpt:u}=a,h=this.viewContainerManager.transformToScenePoint(e,r),d=[],f=[],g=new Map;for(const[T,p]of this.localPointsBatchData){if(p.viewId!==r)continue;if(p.toolsType===q.Text){const v=p.state;if(v&&v===de.Start){const M=p.opt;M.workState=de.Doing,M.boxPoint=[Math.round(h[0]),Math.round(h[1])],M.boxSize=[M.fontSize,M.fontSize],this.control.textEditorManager.checkEmptyTextBlur(),this.control.textEditorManager.createTextForMasterController({workId:this.newWorkId,x:e[0],y:e[1],scale:(u==null?void 0:u.scale)||1,opt:M,type:Tr.Text,isActive:!0,viewId:r,scenePath:l},this.now)}this.deleteLocalPoint(T);continue}else{const v=this.getFullLayerBitmapEraseTxns().get(T.toString());if(v&&v.phase!=="doing")continue;const M=this.getLocalPointInfo(T);v&&Math.floor(((M==null?void 0:M.rawPoints.length)||0)/2)>=this.getFullLayerBitmapEraserMaxInputPoints(M)||this.pushLocalPoint(T,h,de.Done,r),(v==null?void 0:v.phase)==="doing"&&this.markFullLayerBitmapEraseDoneStaging(v);const E=this.getLocalPointInfo(T);if(E){const D=this.createAutoShapeTask({workId:T,viewId:r,scenePath:l,points:[...E.rawPoints],opt:E.opt});D&&f.push(D),ki(E.toolsType)&&E.toolsType!==q.BitMapEraser&&E.undoTickerId&&l?g.set(E.undoTickerId,{scenePath:l,workIds:[]}):ql.has(E.toolsType)&&E.undoTickerId&&l&&g.set(E.undoTickerId,{scenePath:l,workIds:[T.toString()]})}d.push(T)}}if(d.length){let T;g.forEach(({scenePath:m,workIds:v},M)=>{this.internalMsgEmitter.emit("finalizeRequested",M,r,v,m)});try{this.localDoneWaitByView||(this.localDoneWaitByView=new Map),this.delayWorkStateToDoneResolveByView||(this.delayWorkStateToDoneResolveByView=new Map),T=`${r}:done:${++this.localDoneWaitSequence}`,this.localDoneWaitByView.set(r,{token:T,workIds:d.map(String),viewId:r,startedAt:Date.now()});const m=((I=(b=(S=this.control.pluginOptions)==null?void 0:S.extras)==null?void 0:b.undoRedo)==null?void 0:I.ackTimeout)||Ou,v=Cp(m);if(await new Promise(k=>{let E=!1,D,P;const z=()=>{if(P===void 0)return;const R=this.localDoneDispatchTimersByView.get(r);R==null||R.delete(P),R&&R.size===0&&this.localDoneDispatchTimersByView.delete(r),P=void 0},j=R=>{var L;E||(E=!0,D!==void 0&&clearTimeout(D),P!==void 0&&(clearTimeout(P),z()),((L=this.delayWorkStateToDoneResolveByView)==null?void 0:L.get(r))===j&&this.delayWorkStateToDoneResolveByView.delete(r),k(R))};D=setTimeout(()=>{const R=d.filter(L=>!this.getFullLayerBitmapEraseTxns().has(L.toString()));if(!R.length){j(!1);return}this.logLocalWorkBarrierError(`[Appliance]: local Done business wait failed; viewId=${r}; workIds=${R.join(",")}; timeoutMs=${v}`);try{this.timeoutLocalWorks(r,l||"","local-done-timeout",new Set(R.map(String)))}catch(L){this.logLocalWorkBarrierError(`[Appliance]: local Done timeout cleanup failed; viewId=${r}; error=${L instanceof Error?L.message:String(L)}`)}j(!1)},v),P=setTimeout(async()=>{var W;if(z(),E||!this.isActive||this.initGeneration!==n||(((W=this.localInputEpochByView)==null?void 0:W.get(r))||0)!==i||this.viewGenerationById.get(r)!==c||!this.viewContainerManager.getView(r)){j(!1);return}const R=new Set(f.map(Y=>{var H;return(H=Y.workId)==null?void 0:H.toString()}).filter(Boolean));if(d.forEach(Y=>{if(R.has(Y.toString())){this.deleteLocalPoint(Y);return}this.setLocalPointIsFullWork(Y)}),f.forEach(Y=>{Y.needUndoTicker&&l&&Y.workId!==void 0&&Y.workId!==null&&this.internalMsgEmitter.emit("finalizeRequested",Number(Y.needUndoTicker),r,[Y.workId.toString()],l),this.taskBatchData.add(Y)}),this.delayWorkStateToDoneResolveByView.set(r,j),!d.some(Y=>this.localPointsBatchData.has(Y))){j(!1);return}f.length&&R.size===d.length&&j(!0),this.consume()},0);let A=this.localDoneDispatchTimersByView.get(r);A||(A=new Set,this.localDoneDispatchTimersByView.set(r,A)),P!==void 0&&A.add(P)})&&d[0]){const k=d[0];d.forEach(E=>{this.deleteLocalPoint(E)}),this.willSelectorWorkIdByView||(this.willSelectorWorkIdByView=new Map),this.willSelectorWorkIdByView.set(r,k.toString())}}catch(m){this.Logger.error(`[Appliance]: [MasterControlForWorker] onLocalEventEnd error: ${m instanceof Error?m.message:String(m)}`)}const p=this.getDoneWaitForView(r);T!==void 0&&(p==null?void 0:p.token)===T&&p.workIds.every(m=>d.some(v=>v.toString()===m))&&this.clearDoneWaitForView(r,T),T!==void 0&&((N=this.getDoneWaitForView(r))==null?void 0:N.token)===T&&this.clearDoneWaitForView(r,T),d.length=0}}onLocalEventDoing(e,r){var i;if(((i=this.currentToolsData)==null?void 0:i.toolsType)===q.Text)return;this.currentLocalWorkData.workState===de.Start&&this.setCurrentLocalWorkData({...this.currentLocalWorkData,workState:de.Doing});let n=!1;for(const[o,{state:a}]of this.localPointsBatchData.entries()){const c=this.localPointsBatchData.get(o);if(!c||c.viewId!==r)continue;const l=this.getFullLayerBitmapEraseTxns().get(o.toString());if(!(l&&l.phase!=="doing")&&this.isAbled()&&a!==de.Pending){const u=this.viewContainerManager.transformToScenePoint(e,r);this.pushLocalPoint(o,u,a===de.Start?de.Doing:a,r),n=!0}}if(!this.forceDoneFullLayerBitmapEraseAtPointLimit(r)&&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,i=n===q.Selector?Le:this.newWorkId,o=this.setZIndex(r);let a;if(n!==void 0&&n!==q.Text&&n!==q.Selector&&this.isCanRecordUndoRedo){a=this.now;const h=ki(n)?{render:!0,storage:!0,scopeMode:"dynamic",source:Qp(n)}:{render:!0,storage:!0,source:Qp(n)};this.internalMsgEmitter.emit("addUndoTicker",a,r,h)}this.setCurrentLocalWorkData({workState:de.Start,toolsOpt:o,viewId:r,undoTickerId:a});const c=this.viewContainerManager.transformToScenePoint(e,r);if(this.pushLocalPoint(i,c,de.Start,r,o),n===q.BitMapEraser){const h={workId:i.toString(),viewId:r,scenePath:this.viewContainerManager.getCurScenePath(r),undoTickerId:a,phase:"doing",startedAt:Date.now(),doingAckCount:0,updatedTargetIds:new Set,deletedTargetIds:new Set};this.getFullLayerBitmapEraseTxns().set(i.toString(),h),this.logBitmapEraserTrace("start",h,{maxInputPoints:this.getFullLayerBitmapEraserMaxInputPoints(this.getLocalPointInfo(i))})}if(n!==q.Text){if(this.control.textEditorManager.checkEmptyTextBlur(),i&&o&&n&&this.isCanStartEventConsum&&this.prepareOnceWork({workId:i,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))}getFullLayerBitmapEraserMaxInputPoints(e){var r;return Pc(((r=e==null?void 0:e.opt)==null?void 0:r.fullLayerDoingMaskMaxInputPoints)??this.control.pluginOptions.extras.pencilEraser.fullLayerDoingMaskMaxInputPoints)}forceDoneFullLayerBitmapEraseAtPointLimit(e){var n;if(((n=this.currentToolsData)==null?void 0:n.toolsType)!==q.BitMapEraser)return!1;let r=!1;for(const[i,o]of this.localPointsBatchData.entries()){if(o.viewId!==e||o.toolsType!==q.BitMapEraser||o.state!==de.Start&&o.state!==de.Doing)continue;const a=this.getFullLayerBitmapEraseTxns().get(i.toString()),c=this.getFullLayerBitmapEraserMaxInputPoints(o);!a||a.phase!=="doing"||Math.floor(o.rawPoints.length/2)<c||(o.state=de.Done,o.isFullWork=!0,a.forceDoneReason??(a.forceDoneReason="point-limit"),this.logBitmapEraserTrace("point-limit-force-done",a,{pointCount:Math.floor(o.rawPoints.length/2),maxInputPoints:c}),this.markFullLayerBitmapEraseDoneStaging(a),this.localPointsBatchData.set(i,o),r=!0)}return r&&this.checkDrawingWork(e),r}pushLocalPoint(e,r,n,i,o){var c;let a=this.getLocalPointInfo(e);if(n===de.Start)a={state:de.Start,points:[...r],rawPoints:[...r],toolsType:(c=this.currentToolsData)==null?void 0:c.toolsType,opt:o||this.currentLocalWorkData.toolsOpt,isFullWork:!1,viewId:i,undoTickerId:this.currentLocalWorkData.undoTickerId,scenePath:this.viewContainerManager.getCurScenePath(i)};else if(a){a.state=n;const l=a.rawPoints.length-2;n===de.Done&&l>=0&&a.rawPoints[l]===r[0]&&a.rawPoints[l+1]===r[1]||(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 c,l,u,h;const e=Date.now(),r=[...this.localPointsBatchData.entries()].map(([d,f])=>({workId:d,state:f.state,toolsType:f.toolsType,undoTickerId:f.undoTickerId,isFullWork:f.isFullWork,pointCount:Math.floor(f.points.length/2),rawPointCount:Math.floor(f.rawPoints.length/2),viewId:f.viewId})),n=[],i=this.viewContainerManager.getAllViews().flatMap(d=>{if(!d)return[];const f=d.focusScenePath;return f?d.displayer.commiter.getPendingTickerSnapshots(f):[]});this.control.isToolChangePending&&n.push("tool-change-pending"),this.queuedLocalEventCount>0&&n.push("local-event-queue-pending");const o=[...((c=this.localDoneWaitByView)==null?void 0:c.values())||[],...(l=this.localDoneWaitByView)!=null&&l.size?[]:this.localDoneWait?[this.localDoneWait]:[]];o.length&&(n.push("local-done-waiting"),r.length?r.every(d=>d.state===de.Done&&!d.pointCount)&&n.push("done-work-has-no-points"):n.push("done-waiting-without-local-work")),this.isLocalWorkActive&&this.currentLocalWorkData.workState===de.Pending&&n.push("active-work-with-pending-state"),i.some(d=>d.phase==="failed")&&n.push("undo-ticker-failed");const a=this.viewContainerManager.getAllViews().filter(d=>d&&this.control.isClearBusy(d.id)).map(d=>d.id);return a.length&&n.push("clear-operation-pending"),{timestamp:e,suspectedBlockers:n,toolChangePending:this.control.isToolChangePending,isAbled:this.isAbled(),isWritable:this.control.renderControl.isWritable,currentTool:(u=this.currentToolsData)==null?void 0:u.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:o[0]?{...o[0],waitingMs:e-(o[0].startedAt||e)}:void 0,localDoneWaits:o.map(d=>({...d,waitingMs:e-(d.startedAt||e)})),hasDoneResolver:(((h=this.delayWorkStateToDoneResolveByView)==null?void 0:h.size)||0)>0||!!this.delayWorkStateToDoneResolve,localPoints:r,taskBatchSize:this.taskBatchData.size,tasksqueueSize:this.tasksqueue.size,animationScheduled:this.animationId!==void 0,cameraStates:[...this.cameraUpdateStateByView.entries()].map(([d,f])=>{var g,y,S,b;return{viewId:d,isBusy:f.isBusy,hasPending:!!f.pendingCamera,hasPrepare:!!f.preparePromise,isRecovering:f.isRecovering===!0,recoveryFromGeneration:f.recoveryFromGeneration,recoveryOwner:f.recoveryOwner,hasReplayCamera:!!f.replayCamera,currentTaskId:f.currentTaskId,transactionTaskId:(g=f.transaction)==null?void 0:g.taskId,transactionGeneration:(y=f.transaction)==null?void 0:y.viewGeneration,coreAckReceived:(S=f.transaction)==null?void 0:S.coreAckReceived,settledAckReceived:(b=f.transaction)==null?void 0:b.settledAckReceived}}),operationBarrierViews:[...this.operationBarrierQueueByView.keys()],clearBusyViews:a,pendingTickers:i}}shouldUseAutoShape(e){var r;return((r=this.currentToolsData)==null?void 0:r.toolsType)===q.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}emitAutoShapeResult(e){const{viewId:r,workId:n,scenePath:i,result:o,recognized:a,mappedToolsType:c}=e,l=o.candidates[0],u={workId:n.toString(),viewId:r,scenePath:i,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:i,points:o,opt:a}=e;if(!this.shouldUseAutoShape(a))return;const c=Mwe({rawPoints:this.toAutoShapePoints(o),pencilOptions:ye.cloneDeep(a),viewId:n,scenePath:i});if(!c)return;const l=wwe(c),u=Vp(l,c)||this.mapAutoShapeFallback(l,c);if(this.emitAutoShapeResult({viewId:n,workId:r,scenePath:i,result:l,recognized:!!u,mappedToolsType:u==null?void 0:u.toolsType}),!!u)return{msgType:le.FullWork,dataType:xe.Local,workId:r,viewId:n,scenePath:i,toolsType:u.toolsType,opt:u.opt,ops:GMe(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 i;return n.cornerCount>=4&&n.cornerCount<=6&&n.bboxCornerCloseness<=.15&&n.diamondCloseness>n.bboxCornerCloseness+.15?i="rectangle":n.cornerCount===3&&n.radialVariance<.28?i="triangle":n.cornerCount>=8&&n.cornerCount<=12&&n.radialVariance>.28?i="star":n.cornerCount>=5&&n.radialVariance<.22&&n.bboxCornerCloseness>.2&&(i="ellipse"),i?Vp({...e,kind:i,recognized:!0},r):null}correctStorage(e,r,n){var h,d;const i=new Map,o=[],a=new Map,c=[];Object.keys(e).forEach(f=>{var S,b,I;const g=(b=(S=e[f])==null?void 0:S.opt)==null?void 0:b.zIndex,y=(I=e[f])==null?void 0:I.toolsType;ye.isNumber(g)&&(y&&y===q.BackgroundSVG?c.push([f,g]):o.push([f,g]))});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[f,g]of l){if(!e[f])continue;const y=e[f];y.opt&&ye.isNumber(y.opt.zIndex)&&y.opt.zIndex!==g&&(y.opt.zIndex=g,i.set(f,y))}i.size&&i.forEach((f,g)=>{var y;(y=this.collector)==null||y.updateValue(g,f,{viewId:r,scenePath:n,isSync:!0}),e[g]=f});for(const[f,g]of u){if(!e[f])continue;const y=e[f];y.opt&&ye.isNumber(y.opt.zIndex)&&y.opt.zIndex!==g&&(y.opt.zIndex=g,a.set(f,y))}return a.size&&a.forEach((f,g)=>{var y;(y=this.collector)==null||y.updateValue(g,f,{viewId:r,scenePath:n,isSync:!0}),e[g]=f}),e}originalEventLintener(e,r,n){var f,g;const i=((f=this.localInputTransactionEpochByView)==null?void 0:f.has(n))===!0;if(e===de.Start){if(!this.control.canAcceptLocalMutation(n))return Promise.resolve()}else if(e===de.Doing&&!this.control.canAcceptLocalMutation(n)||(e===de.Doing||e===de.Done)&&!i)return Promise.resolve();const o=++this.localEventSequence,a=this.initGeneration,c=this.viewGenerationById.get(n),l=((g=this.localInputEpochByView)==null?void 0:g.get(n))||0;this.localInputTransactionEpochByView||(this.localInputTransactionEpochByView=new Map),e===de.Start&&this.localInputTransactionEpochByView.set(n,l);const u=this.localInputTransactionEpochByView.get(n)??l;this.queuedLocalEventCount++;const h=this.localEventQueue.then(async()=>{var y,S,b;this.activeLocalEvent={sequence:o,state:e,viewId:n,startedAt:Date.now()};try{if(this.initGeneration!==a||!this.isActive||(((y=this.localInputEpochByView)==null?void 0:y.get(n))||0)!==u||this.viewGenerationById.get(n)!==c||!this.viewContainerManager.getView(n))return;await this.consumeOriginalEvent(e,r,n,o,a,u)}finally{this.queuedLocalEventCount=Math.max(0,this.queuedLocalEventCount-1),((S=this.activeLocalEvent)==null?void 0:S.sequence)===o&&(this.activeLocalEvent=void 0),e===de.Done&&((b=this.localInputTransactionEpochByView)==null?void 0:b.get(n))===u&&this.localInputTransactionEpochByView.delete(n)}}),d=h.catch(()=>{});return this.localEventQueue=d,this.localEventQueueByView.set(n,d),d.then(()=>{this.localEventQueueByView.get(n)===d&&this.localEventQueueByView.delete(n)}),h}async waitForLocalEventQueue(e){await(e&&this.localEventQueueByView?this.localEventQueueByView.get(e)||Promise.resolve():this.localEventQueue)}async finishActiveContinuousMethods(e,r){var l,u,h;const n=this.viewContainerManager.getUndoTickerId(e),i=await((l=this.methodBuilder)==null?void 0:l.finishActiveContinuousMethods(e,r))||[],o=new Set(i);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 forceDoneLocalWorks(e,r,n){var h;this.operationBarrierQueueByView||(this.operationBarrierQueueByView=new Map);const i=this.operationBarrierQueueByView.get(e)||Promise.resolve(),o=((h=this.operationBarrierEpochByView)==null?void 0:h.get(e))||0,a=this.viewContainerManager.getView(e),c=this.viewGenerationById.get(e),l=i.then(()=>this.executeTransactionBarrier(e,r,n,o)).then(()=>{var f;return(((f=this.operationBarrierEpochByView)==null?void 0:f.get(e))||0)===o&&this.viewGenerationById.get(e)===c&&this.viewContainerManager.getView(e)===a?{status:"success",viewId:e,scenePath:r,reason:n}:{status:"failed",viewId:e,scenePath:r,reason:n,failureReason:"lifecycle-invalidated"}}).catch(d=>{const f=yr(d);let g="";try{this.timeoutLocalWorks(e,r,`${n}-barrier-failed`,void 0,d)}catch(y){g=yr(y),this.logLocalWorkBarrierError(`[Appliance]: force-Done failure cleanup failed; viewId=${e}; scenePath=${r}; reason=${n}; error=${g}`)}return{status:"failed",viewId:e,scenePath:r,reason:n,failureReason:g?`${f}; cleanup=${g}`:f}}),u=l.then(()=>{},()=>{});this.operationBarrierQueueByView.set(e,u);try{return await l}finally{this.operationBarrierQueueByView.get(e)===u&&this.operationBarrierQueueByView.delete(e)}}invalidateTransactionBarrier(e){var r,n,i;this.operationBarrierEpochByView||(this.operationBarrierEpochByView=new Map),this.operationBarrierEpochByView.set(e,(this.operationBarrierEpochByView.get(e)||0)+1),(n=(r=this.operationBarrierInvalidationWaitersByView)==null?void 0:r.get(e))==null||n.forEach(o=>o()),(i=this.operationBarrierInvalidationWaitersByView)==null||i.delete(e)}async waitForCurrentTransactionBarrier(e,r,n){if(!r())return!1;this.operationBarrierInvalidationWaitersByView||(this.operationBarrierInvalidationWaitersByView=new Map);let i;const o=new Promise(c=>{i=c});let a=this.operationBarrierInvalidationWaitersByView.get(e);a||(a=new Set,this.operationBarrierInvalidationWaitersByView.set(e,a)),a.add(i);try{return await Promise.race([n,o]),r()}finally{a.delete(i),a.size||this.operationBarrierInvalidationWaitersByView.delete(e)}}async executeTransactionBarrier(e,r,n="camera-update",i=(o=>(o=this.operationBarrierEpochByView)==null?void 0:o.get(e))()||0){var E,D,P,z,j,A;const a=this.viewContainerManager.getView(e),c=this.viewGenerationById.get(e),l=()=>{var R;return this.viewGenerationById.get(e)===c&&(((R=this.operationBarrierEpochByView)==null?void 0:R.get(e))||0)===i&&this.viewContainerManager.getView(e)===a};if(!await this.waitForCurrentTransactionBarrier(e,l,this.waitForLocalEventQueue(e)))return;const u=(E=a==null?void 0:a.displayer)==null?void 0:E.commiter,h=[...this.getFullLayerBitmapEraseTxns().values()].filter(R=>R.viewId===e&&(!R.scenePath||R.scenePath===r)&&R.phase!=="aborting"&&R.phase!=="aborted"),d=new Set(h.map(R=>R.workId));h.forEach(R=>{R.phase==="doing"&&(R.forceDoneReason??(R.forceDoneReason=n),this.logBitmapEraserTrace("force-done",R,{reason:n}))});const f=n==="set-readonly"||n==="disconnect"||n==="destroy"||n==="view-destroy",g=n==="set-readonly"||n==="disconnect",y=f||n==="scene-change",S=()=>((u==null?void 0:u.getPendingTickerSnapshots(r))||[]).filter(R=>R.source===$e.Text?y:f||bs(R.source).kind!=="wait-owner");let b=S();const I=((z=(P=(D=this.control.pluginOptions)==null?void 0:D.extras)==null?void 0:P.undoRedo)==null?void 0:z.ackTimeout)||Ou,N=oye(I),T=Cp(I),p=[...this.localPointsBatchData.values()].some(R=>R.viewId===e&&(!R.scenePath||R.scenePath===r)&&R.toolsType!==q.Text&&(R.state===de.Start||R.state===de.Doing));let m=!1;for(const R of b){if(R.finalizeRequested||R.phase!=="doing")continue;const L=bs(R.source);if(L.kind==="stop-event"){if(!m&&(a!=null&&a.displayer)&&(m=!0,!await this.waitForCurrentTransactionBarrier(e,l,a.displayer.stopEventHandler())))return;continue}if(L.kind==="method-pause"&&!await this.waitForCurrentTransactionBarrier(e,l,Promise.resolve((A=(j=this.methodBuilder)==null?void 0:j.getBuilder(L.emitEventType))==null?void 0:A.pause(e,r))))return}if(p&&!m&&(a!=null&&a.displayer)&&(m=!0,!await this.waitForCurrentTransactionBarrier(e,l,a.displayer.stopEventHandler()))||!await this.waitForCurrentTransactionBarrier(e,l,this.waitForLocalEventQueue(e))||[...this.localPointsBatchData.values()].some(R=>R.viewId===e&&(!R.scenePath||R.scenePath===r)&&R.toolsType!==q.Text&&(R.state===de.Start||R.state===de.Doing))&&(!await this.waitForCurrentTransactionBarrier(e,l,this.checkDrawingWork(e))||!await this.waitForCurrentTransactionBarrier(e,l,this.waitForLocalEventQueue(e)))||!await this.waitForCurrentTransactionBarrier(e,l,this.waitForFullLayerBitmapEraseTxns(e,d)))return;if(u&&(b=S()),u){const R=b.filter(L=>!L.finalizeRequested&&bs(L.source).kind!=="wait-owner");for(const L of R)try{typeof u.cancelUndoTicker=="function"&&(u.cancelUndoTicker(L.tickerId,e,L.scenePath),this.logLocalWorkBarrierError(`[Appliance]: cancelled unfinalized Undo ticker before ${n}; viewId=${e}; tickerId=${L.tickerId}; source=${L.source}`))}catch(W){this.logLocalWorkBarrierError(`[Appliance]: cancelling unfinalized Undo ticker failed; viewId=${e}; tickerId=${L.tickerId}; source=${L.source}; error=${W instanceof Error?W.message:String(W)}`)}if(R.length){b=S();const L=b.filter(W=>!W.finalizeRequested&&bs(W.source).kind!=="wait-owner");typeof u.cancelUndoTicker=="function"&&L.length&&(L.forEach(W=>{this.logLocalWorkBarrierError(`[Appliance]: unfinalized Undo ticker was not removed by cancellation; continuing without waiting; viewId=${e}; tickerId=${W.tickerId}; source=${W.source}`)}),b=b.filter(W=>W.finalizeRequested||bs(W.source).kind==="wait-owner"))}}const M=u?b.filter(R=>!R.finalizeRequested).map(R=>u.waitForFinalizeRequested(R,T)):[];if(!await this.waitForCurrentTransactionBarrier(e,l,Promise.all(M)))return;const k=u?b.map(R=>u.waitForDataDone(R,T)):[];!await this.waitForCurrentTransactionBarrier(e,l,Promise.all(k))||!g||await this.waitForCurrentTransactionBarrier(e,l,Promise.all(b.map(R=>u==null?void 0:u.waitForUndoStackEnd(R,N))))}async consumeOriginalEvent(e,r,n,i,o=this.initGeneration,a=(c=>(c=this.localInputEpochByView)==null?void 0:c.get(n))()||0){var f,g,y,S,b;const l=(f=this.viewGenerationById)==null?void 0:f.get(n);if(!this.isAbled()||!this.isActive||this.initGeneration!==o||(((g=this.localInputEpochByView)==null?void 0:g.get(n))||0)!==a||(e===de.Start||e===de.Doing)&&!this.control.canAcceptLocalMutation(n))return;const u=(y=this.collector)==null?void 0:y.uid,h=this.viewContainerManager.getCurScenePath(n);if(u&&!this.control.renderControl.isWritable)return;const d=((S=this.currentToolsData)==null?void 0:S.toolsType)===q.Selector;switch((b=this.currentToolsData)==null?void 0:b.toolsType){case q.Eraser:case q.PencilEraser:case q.BitMapEraser:{if(u&&!this.control.renderControl.isClearAble({uid:u,viewId:n,scenePath:h}))return;break}default:{if(u&&!this.control.renderControl.isRenderAble({uid:u,viewId:n,scenePath:h}))return;break}}switch(e){case de.Start:{const I=this.control.isSceneBusy(n);if(this.isViewBusy(n)||I||this.control.isToolChangePending)return;this.isLocalWorkActive=!0,this.setLocalWorkViewId(n),n&&this.onLocalEventStart(r,n),d&&this.viewContainerManager.showFloatBarBtn(n,!1)}break;case de.Doing:n&&n===this.getLocalWorkViewId()&&this.onLocalEventDoing(r,n);break;case de.Done:if(n&&n===this.getLocalWorkViewId()){this.setCurrentLocalWorkData({...this.currentLocalWorkData,workState:de.Done});try{await this.onLocalEventEnd(r,n,o,a)}finally{this.isLocalWorkActive=!1,this.setCurrentLocalWorkData({workState:de.Pending}),d&&this.viewContainerManager.showFloatBarBtn(n,!0),this.setLocalWorkViewId(void 0)}}break}this.isLocalWorkActive&&this.viewContainerManager.focuedViewId===n&&this.publicMsgEmitter.emit("workState",e,n),Dr(()=>{var I,N,T;!this.isActive||this.initGeneration!==o||(((I=this.localInputEpochByView)==null?void 0:I.get(n))||0)!==a||((N=this.viewGenerationById)==null?void 0:N.get(n))!==l||(T=this.control.pluginManager)==null||T.dispatchPluginEvent("localEvent",n,e,r)},Qa,this.control.hasPolyfillMethod("requestIdleCallback"))}getLocalWorkViewId(){return this.localWorkViewId}setLocalWorkViewId(e){this.localWorkViewId=e}setCurrentToolsData(e){var a,c,l,u;const r=e.toolsType,i=((a=this.currentToolsData)==null?void 0:a.toolsType)!==e.toolsType,o=this.getLocalWorkViewId()||((c=this.viewContainerManager)==null?void 0:c.focuedViewId);if(i){const h=new Map;for(const d of this.getFullLayerBitmapEraseTxns().values()){if(d.phase!=="doing"||o&&d.viewId!==o)continue;let f=h.get(d.viewId);f||(f=new Set,h.set(d.viewId,f)),f.add(d.workId)}h.forEach((d,f)=>{this.cancelLocalWorks(f,!1,d)})}if(super.setCurrentToolsData(e),i){const h=o?(l=this.viewContainerManager)==null?void 0:l.getView(o):void 0;h!=null&&h.focusScenePath&&((u=this.collector)!=null&&u.hasSelector(h.id,h.focusScenePath)&&this.blurSelector(h.id,h.focusScenePath),this.control.textEditorManager.checkEmptyTextBlur()),this.taskBatchData.add({msgType:le.UpdateTools,dataType:xe.Local,toolsType:r,opt:{...e.toolsOpt,syncUnitTime:this.maxLastSyncTime},combineUnitTime:this.isBezier?this.combineUnitTime:1/0,maxCombineEraserTime:this.maxCombineEraserTime,isRunSubWork:this.isRunSubWork,viewId:Bu,isRunBackgroundThread:this.control.isUseBackgroundThread}),this.runAnimation()}}prepareOnceWork(e,r){const{workId:n,toolsOpt:i,viewId:o}=e,a={msgType:le.CreateWork,dataType:xe.Local,viewId:o,toolsType:r};this.queryTaskBatchData(a).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add({...a,workId:n,opt:{...i,syncUnitTime:this.maxLastSyncTime},dataType:xe.Local,isRunSubWork:this.isRunSubWork}),this.runAnimation()}createViewWorker(e,r,n){var d,f,g,y;(d=this.collector)==null||d.restoreViewPendingSync(e),this.fullLayerFrameStateByView.delete(e);const i=(this.viewGenerationById.get(e)||0)+1;this.viewGenerationById.set(e,i),(g=(f=this.control).bindPendingViewInit)==null||g.call(f,e,i),pt(this.Logger,{category:"render-init",viewId:e,generation:i,stage:"create-view",details:{renderModel:Ht(this.control.renderMode,Qr(this.control,e)),context:Qr(this.control,e),source:this.control.renderingCompatibilityDecision.renderRuntimeSource||"config"}}),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},h={msgType:le.Init,dataType:xe.Local,viewId:e,viewGeneration:i,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),pt(this.Logger,{category:"render-init",viewId:e,generation:i,stage:"sent-queued",details:{renderModel:Ht(this.control.renderMode,Qr(this.control,e)),context:Qr(this.control,e),reason:"transport-not-ready"}});return}pt(this.Logger,{category:"render-init",viewId:e,generation:i,stage:"sent",details:{renderModel:Ht(this.control.renderMode,Qr(this.control,e)),context:Qr(this.control,e),source:this.control.renderingCompatibilityDecision.renderRuntimeSource||"config"}}),(y=this.cameraUpdateStateByView.get(e))!=null&&y.isRecovering||this.cameraUpdateDestroy(e),this.armViewInitAckTimeout(e,i),this.post(new Set([h])),this.taskBatchData.size&&this.consume()}discardViewTransactions(e){var a,c,l,u,h,d,f,g;this.invalidateTransactionBarrier(e);const r=(a=this.localDoneDispatchTimersByView)==null?void 0:a.get(e);r==null||r.forEach(y=>clearTimeout(y)),r==null||r.clear(),(c=this.localDoneDispatchTimersByView)==null||c.delete(e);const n=new Set;for(const[y,S]of this.localPointsBatchData){if(S.viewId!==e)continue;const b=y.toString();n.add(b),ki(S.toolsType)&&this.rememberCancelledEraseTxn(b),this.localPointsBatchData.delete(y)}for(const[y,S]of this.getFullLayerBitmapEraseTxns())S.viewId===e&&(n.add(y),this.rememberCancelledEraseTxn(y),this.finishFullLayerBitmapEraseTxn(y,"aborted"));for(const y of[...this.taskBatchData])y.viewId===e&&this.taskBatchData.delete(y);this.tasksqueue.delete(e);for(const[y,S]of this.tasksqueue)S.viewId===e&&this.tasksqueue.delete(y);for(const[y,S]of this.reRenders){const b=S.filter(I=>{const N=I.viewId===e;return N&&this.retireRenderedImageBitmap(I),!N});b.length?this.reRenders.set(y,b):this.reRenders.delete(y)}const i=this.getDoneWaitForView(e);if(i&&i.workIds.some(y=>n.has(y))){const y=this.getDoneResolverForView(e);this.clearDoneWaitForView(e),y==null||y(!1)}this.currentLocalWorkData.viewId===e&&(this.setCurrentLocalWorkData({workState:de.Pending}),this.isLocalWorkActive=!1),(l=this.localEventQueueByView)==null||l.delete(e),this.getLocalWorkViewId()===e&&this.setLocalWorkViewId(void 0),(h=(u=this.control)==null?void 0:u.viewContainerManager.getView(e))==null||h.displayer.cancelDprUpdate(),this.pendingDprByView.delete(e),(d=this.pendingDprOwnerByView)==null||d.delete(e),this.viewRecoveryQueueByView.delete(e),this.resolveViewLifecycleIdleWaiters(e),this.operationBarrierQueueByView.delete(e),(f=this.willSelectorWorkIdByView)==null||f.delete(e);const o=this.clearAllResolveMap.get(e);o!=null&&o.timer&&clearTimeout(o.timer),(g=o==null?void 0:o.resolve)==null||g.call(o,e),this.clearAllResolveMap.delete(e),this.settleViewRenderRequests(e)}destroyViewWorker(e,r,n=!1){var u,h,d,f,g,y;(u=this.viewInitRecoveryDestroying)!=null&&u.has(e)||(h=this.viewInitRecoveryAttempts)==null||h.delete(e),this.discardViewTransactions(e),this.fullLayerFrameStateByView.delete(e);const o=(this.viewGenerationById.get(e)||0)+1;this.viewGenerationById.set(e,o),this.initAckedViewIds.delete(e),this.serviceSyncReadyViews.delete(e);for(const[S,b]of this.serviceSyncCommitWaiters)b.viewId===e&&(clearTimeout(b.timer),b.resolve(!1),this.serviceSyncCommitWaiters.delete(S));const a=this.viewServiceReadyWaiters.get(e);a==null||a.forEach(S=>{clearTimeout(S.timer),S.resolve(!1)}),this.viewServiceReadyWaiters.delete(e);const c=this.viewInitAckWaiters.get(e);c==null||c.forEach(S=>{clearTimeout(S.timer),S.resolve(!1)}),this.viewInitAckWaiters.delete(e);for(const[S,b]of this.viewInitAckTimeoutTimers)S.startsWith(`${e}:`)&&(clearTimeout(b),this.viewInitAckTimeoutTimers.delete(S));this.initReconcileTasks.delete(e),this.control.invalidatePendingViewInit(e),(!n||!((d=this.cameraUpdateStateByView.get(e))!=null&&d.isRecovering))&&this.cameraUpdateDestroy(e,!1),this.initCameraOptByView.delete(e);for(const[S,b]of this.pendingTransportMessages)b.viewId===e&&this.pendingTransportMessages.delete(S);this.zIndexNodeMethod&&this.zIndexNodeMethod.clearZIndex(e);const l={msgType:le.Destroy,dataType:xe.Local,viewId:e,viewGeneration:o,isRunSubWork:!0};this.isRenderTransportReady?this.dispatchMessages(new Set([l])):this.pendingTransportMessages.set(`destroy:${e}`,l),r==="delete-storage"?((f=this.collector)==null||f.dispatch({type:le.Clear,viewId:e,isSync:!0}),(g=this.collector)==null||g.discardViewPendingSync(e)):r==="storage-already-deleted"&&((y=this.collector)==null||y.discardViewPendingSync(e)),this.control.renderControl.destoryByViewId(e,r!=="delete-storage")}onServiceDerive(e,r){var f,g,y,S,b,I,N,T;const{viewId:n}=r;if(!n||!this.isViewInitAck(n)||!this.isServiceSyncReady(n)){n&&this.control.queuePendingServiceDerive(n,e,r);return}const{newValue:i,oldValue:o,scenePath:a}=r,c=ye.cloneDeep(i)||{},l=e;let u=c.type;if(!i&&o&&(u=le.RemoveNode),!i&&o){if(l&&((f=this.collector)==null?void 0:f.getLocalId(l))===Le){this.collector.isOwn(l)?this.blurSelector(n,a):this.blurSelector(n,a,l);return}if(o.toolsType===q.LaserPen)return}if(!$u(n,a,p=>{var m;return(m=this.viewContainerManager.getView(p))==null?void 0:m.focusScenePath}))return;if((g=this.collector)!=null&&g.isSelector(e)){const p=(y=this.collector)==null?void 0:y.getUidFromKey(e);if(p&&!this.control.roomMember.isOnLine(p))return}if(u&&l){if(!this.control.renderControl.isFilterAble({viewId:n,elementId:e,scenePath:a},u))return;const p=c;if(p.workId=(S=this.collector)!=null&&S.isOwn(l)?(b=this.collector)==null?void 0:b.getLocalId(l):l,p.msgType=u,p.toolsType===q.LaserPen&&(p.isRunSubWork=!0),p.toolsType===q.BackgroundSVG){if(!this.control.isUseBackgroundThread)return;p.isRunBackgroundThread=!0}if(p.dataType=xe.Service,p.viewId=n,p.scenePath=a,p.useAnimation=this.smoothSync&&((I=p.updateNodeOpt)==null?void 0:I.useAnimation)||!1,p.selectIds&&(p.selectIds=p.selectIds.map(m=>{var v,M;return(v=this.collector)!=null&&v.isOwn(m)?(M=this.collector)==null?void 0:M.getLocalId(m):m})),p&&p.toolsType===q.Text||(o==null?void 0:o.toolsType)===q.Text){this.control.textEditorManager.onServiceDerive(p);return}p.isEnableCursor=this.control.cursor.isEnableCursor,this.taskBatchData.add(p)}this.runAnimation();const h=r.newValue&&((N=r.newValue)==null?void 0:N.toolsType),d=r.newValue&&((T=r.newValue.opt)==null?void 0:T.zIndex);if(h&&h===q.BackgroundSVG){if(this.zIndexNodeMethod&&ye.isNumber(d)){const p=this.zIndexNodeMethod.getMinZIndexForBackgroundSVG(n);this.zIndexNodeMethod.getMaxZIndexForBackgroundSVG(n)<d&&this.zIndexNodeMethod.setMaxZIndexForBackgroundSVG(d,n),p>d&&this.zIndexNodeMethod.setMinZIndexForBackgroundSVG(d,n)}}else if(this.zIndexNodeMethod&&ye.isNumber(d)){const p=this.zIndexNodeMethod.getMinZIndex(n);this.zIndexNodeMethod.getMaxZIndex(n)<d&&this.zIndexNodeMethod.setMaxZIndex(d,n),p>d&&this.zIndexNodeMethod.setMinZIndex(d,n)}}pullServiceData(e,r,n={isAsync:!1,useAnimation:!1}){if(!this.isViewInitReady(e)){this.control.queuePendingInitServicePull(e,r);return}this.pullServiceDataForReadyRenderer(e,r,n)}pullServiceDataForReadyRenderer(e,r,n){var c,l,u,h,d,f,g;if(!$u(e,r,y=>{var S;return(S=this.viewContainerManager.getView(y))==null?void 0:S.focusScenePath}))return;let i=(c=this.collector)==null?void 0:c.getStorageData(e,r);const{isAsync:o,useAnimation:a}=n;if(i){this.control.syncLogger.append("pullServiceData",e,r,Object.entries(i).map(([S,b])=>({key:S,type:b==null?void 0:b.type,toolsType:b==null?void 0:b.toolsType}))),this.control.renderControl.isWritable&&(i=this.correctStorage(i,e,r));const y=Object.keys(i);for(const S of y){if((l=this.collector)!=null&&l.isSelector(S)){const I=(u=this.collector)==null?void 0:u.getUidFromKey(S);if(I&&!this.control.roomMember.isOnLine(I))continue}const b=(h=i[S])==null?void 0:h.type;if(b&&S){if(!this.control.renderControl.isFilterAble({viewId:e,elementId:S,scenePath:r},b))continue;const I=i[S];if(I.workId=(d=this.collector)!=null&&d.isOwn(S)?(f=this.collector)==null?void 0:f.getLocalId(S):S,I.msgType=b,I.dataType=xe.Service,I.viewId=e,I.scenePath=r,I.useAnimation=this.smoothSync&&(I.ops?!!a:(g=I.updateNodeOpt)==null?void 0:g.useAnimation)||!1,I.selectIds&&(I.selectIds=I.selectIds.map(N=>{var T,p;return(T=this.collector)!=null&&T.isOwn(N)?(p=this.collector)==null?void 0:p.getLocalId(N):N})),I.toolsType===q.Text){this.control.shouldHoldServiceTextRenderForFontFace()?this.control.markInitFontFaceTextRenderSkipped():this.control.textEditorManager.onServiceDerive(I);continue}if(I.toolsType===q.BackgroundSVG){if(!this.control.isUseBackgroundThread)continue;I.isRunBackgroundThread=!0}o&&I.updateNodeOpt&&I.updateNodeOpt.useAnimation&&(I.updateNodeOpt.useAnimation=!1),I.isEnableCursor=this.control.cursor.isEnableCursor,this.taskBatchData.add(I)}this.internalMsgEmitter.emit("excludeIds",y,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:i,points:o,opt:a,toolsType:c,undoTickerId:l,viewId:u}]of this.localPointsBatchData.entries()){if(!u||n===de.Done&&!i||n===de.Start&&!this.isCanStartEventConsum)continue;const h=o.map(d=>d);if(h.length||n===de.Done){if(this.isPostCountType&&n===de.Doing){if(this.postCount>this.consumeCount)continue;this.postCount++}const d=this.getDoneResolverForView(u),f=this.getDoneWaitForView(u);d&&n===de.Done&&(f!=null&&f.workIds.includes(r.toString()))&&(d(!0),this.setLockSentEventCursor(!0));const g=((e=this.getLocalPointInfo(r))==null?void 0:e.scenePath)||u&&this.viewContainerManager.getCurScenePath(u);n===de.Done&&l&&g&&ql.has(c)&&this.internalMsgEmitter.emit("finalizeRequested",l,u,[r.toString()],g),this.taskBatchData.add({op:h,workState:n,workId:r,dataType:xe.Local,msgType:le.DrawWork,isRunSubWork:this.isRunSubWork,toolsType:c,viewId:u,scenePath:g,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===de.Done&&l||void 0,collectUndoTicker:n!==de.Done&&ki(c)&&l||void 0}),o.length=0}}if(this.taskBatchData.size){const r=new Set(this.taskBatchData),n=new Set,i=new Set;for(const o of r){const a=_0e({isService:o.dataType===xe.Service,isAllViews:o.viewId===Bu,viewId:o.viewId,scenePath:o.scenePath},c=>this.isViewInitAck(c),c=>{var l;return(l=this.viewContainerManager.getView(c))==null?void 0:l.focusScenePath});a==="dispatch"?n.add(o):a==="pending"&&i.add(o)}for(const o of n)if(o.msgType===le.DrawWork&&o.workState===de.Done&&o.workId!==void 0){const a=this.getFullLayerBitmapEraseTxns().get(o.workId.toString());a&&a.phase!=="aborting"&&(a.phase="committing",this.armBitmapEraserCommitTimeout(a))}this.post(n),this.taskBatchData.clear(),i.forEach(o=>this.taskBatchData.add(o))}}armBitmapEraserCommitTimeout(e){e.commitTimeoutId&&clearTimeout(e.commitTimeoutId),e.commitDeadlineAt??(e.commitDeadlineAt=Date.now()+Ipe);const r=Math.max(0,e.commitDeadlineAt-Date.now());e.commitTimeoutId=setTimeout(()=>{const n=this.getFullLayerBitmapEraseTxns().get(e.workId);!n||n.phase!=="done-staging"&&n.phase!=="committing"||this.timeoutLocalWorks(e.viewId,e.scenePath||this.viewContainerManager.getCurScenePath(e.viewId)||"","bitmap-eraser-commit-timeout",new Set([e.workId]))},r)}markFullLayerBitmapEraseDoneStaging(e){var r;e.phase==="doing"&&(e.phase="done-staging",e.inputPointCount=Math.floor((((r=this.getLocalPointInfo(e.workId))==null?void 0:r.rawPoints.length)||0)/2),this.logBitmapEraserTrace("done-staging",e,{pointCount:e.inputPointCount,doingAckCount:e.doingAckCount||0}),this.armBitmapEraserCommitTimeout(e))}unWritable(){const e=new Set;this.localPointsBatchData.forEach(({viewId:r})=>{e.add(r)}),this.getFullLayerBitmapEraseTxns().forEach(({viewId:r})=>{e.add(r)}),e.forEach(r=>this.cancelLocalWorks(r,!1)),this.setCurrentLocalWorkData({workState:de.Unwritable}),this.setLockSentEventCursor(!0)}abled(){this.setCurrentLocalWorkData({workState:de.Pending}),this.setLockSentEventCursor(!1)}isAbled(){return this.currentLocalWorkData.workState!==de.Unwritable}postMainThread(e){if(!this.control.hasOffscreenCanvas&&this.mainThread){this.mainThread.consume(e).catch(r=>{this.logLocalWorkBarrierError(`[Appliance]: main-thread message consumption failed; error=${r instanceof Error?r.message:String(r)}`)});return}}postWebWorker(e){if(this.control.isUseSimple){const r=[...e].find(n=>n.msgType===le.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 i=n.msgType;(i===le.Init||i===le.Clear||i===le.Destroy||i===le.UpdateCamera||i===le.Console||n.isRunSubWork)&&r.add(n)}r.size&&this.subWorker.postMessage(r)}}post(e){!this.isRenderTransportReady||!e.size||this.dispatchMessages(e)}dispatchMessages(e){const r=this.initGeneration,n=()=>{const i=ye.cloneDeep([...e]);setTimeout(()=>{if(this.initGeneration===r)for(const o of i)this.taskBatchData.add(o)},0)};if(this.control.isUseBackgroundThread){if(!this.backgroundThreadManager){n();return}const i=new Set;for(const o of e.values()){const a=o.msgType;(a===le.Init||a===le.Clear||a===le.Destroy||a===le.Console||o.isRunBackgroundThread)&&i.add(o)}i.size&&this.backgroundThreadManager.consume(i).catch(o=>{this.logLocalWorkBarrierError(`[Appliance]: background-thread message consumption failed; error=${o instanceof Error?o.message:String(o)}`)})}if(!this.control.hasOffscreenCanvas){if(!this.mainThread){n();return}this.postMainThread(e);return}this.postWebWorker(e)}updateNode(e,r,n,i){this.taskBatchData.add({msgType:le.UpdateNode,workId:e,updateNodeOpt:r,viewId:n,scenePath:i,dataType:xe.Local}),this.runAnimation()}destroyTaskQueue(e=!1){for(const[r,n]of this.cameraUpdateStateByView){if(e&&n.isRecovering){this.clearCameraTaskTimeouts(n),n.pendingCamera=void 0,n.transaction=void 0,n.preparePromise=void 0,n.currentTaskId=void 0;continue}this.cameraUpdateDestroy(r,!1)}this.tasksqueue.clear()}updateDpr(e,r){this.pendingDprOwnerByView||(this.pendingDprOwnerByView=new Map);const n=(this.dprUpdateSequence||0)+1;this.dprUpdateSequence=n,this.pendingDprOwnerByView.set(e,n),this.pendingDprByView.set(e,r);const i=this.initGeneration,o=this.viewGenerationById.get(e),a=()=>{var h;return((h=this.pendingDprOwnerByView)==null?void 0:h.get(e))===n},c=()=>a()&&(this.initGeneration!==i||this.viewGenerationById.get(e)!==o)?(this.releasePendingDprUpdate(e,n),!0):!a(),u=this.getLocalWorkFinalizeQueue(e).then(async()=>{if(await this.waitForLocalEventQueue(e),c())return;const h=this.viewContainerManager.getCurScenePath(e);if(h&&await this.forceDoneLocalWorks(e,h,"dpr-update"),c())return;const d=this.pendingDprByView.get(e);d!==void 0&&(this.applyDprUpdate(e,d),this.releasePendingDprUpdate(e,n))}).catch(async h=>{if(c())return;this.Logger.error(`[Appliance]: DPR transaction barrier failed; viewId=${e}; error=${h instanceof Error?h.message:String(h)}`);try{await this.scheduleViewRecovery(e,"dpr-transaction-barrier-failed")}catch{this.cancelPendingDprUpdate(e,n);return}if(c())return;const d=this.pendingDprByView.get(e);if(d!==void 0)try{this.applyDprUpdate(e,d),this.releasePendingDprUpdate(e,n)}catch(f){this.Logger.error(`[Appliance]: DPR apply failed after view recovery; viewId=${e}; error=${f instanceof Error?f.message:String(f)}`),this.cancelPendingDprUpdate(e,n)}});this.setLocalWorkFinalizeQueue(e,u),u.then(()=>this.clearLocalWorkFinalizeQueue(e,u),()=>this.clearLocalWorkFinalizeQueue(e,u))}releasePendingDprUpdate(e,r){var n;return((n=this.pendingDprOwnerByView)==null?void 0:n.get(e))!==r?!1:(this.pendingDprOwnerByView.delete(e),this.pendingDprByView.delete(e),this.resolveViewLifecycleIdleWaiters(e),!0)}cancelPendingDprUpdate(e,r){var n,i;((n=this.pendingDprOwnerByView)==null?void 0:n.get(e))===r&&((i=this.viewContainerManager.getView(e))==null||i.displayer.cancelDprUpdate(),this.releasePendingDprUpdate(e,r))}applyDprUpdate(e,r){var n;(n=this.viewContainerManager.getView(e))==null||n.displayer.commitDprUpdate(r),this.queryTaskBatchData({msgType:le.UpdateDpr,dataType:xe.Local,viewId:e}).forEach(i=>{this.taskBatchData.delete(i)}),this.taskBatchData.add({dataType:xe.Local,msgType:le.UpdateDpr,viewId:e,dpr:r,isRunSubWork:!0}),this.runAnimation()}cloneCameraReplay(e){return{cameraOpt:{...e.cameraOpt},scenePath:e.scenePath}}beginCameraClearReplay(e,r){this.cameraClearReplayByView||(this.cameraClearReplayByView=new Map);const n=this.cameraClearReplayByView.get(e),i=this.cameraUpdateStateByView.get(e),o=this.getActiveRenderRuntimeRecoveryView(e),a=(n==null?void 0:n.replay)||(i?this.getCameraReplayCandidate(e,i):o==null?void 0:o.replayCamera);this.cameraClearReplaySequence=(this.cameraClearReplaySequence||0)+1;const c={owner:this.cameraClearReplaySequence,viewGeneration:this.viewGenerationById.get(e),replay:a?{...this.cloneCameraReplay(a),scenePath:a.scenePath||r}:void 0,preserveRecovery:(n==null?void 0:n.preserveRecovery)===!0||(i==null?void 0:i.isRecovering)===!0||(i==null?void 0:i.recoveryOwner)!==void 0||!!o};if(this.cameraClearReplayByView.set(e,c),c.preserveRecovery&&a){let l=i;!l&&o&&(l={isBusy:!0},this.cameraUpdateStateByView.set(e,l)),l&&(this.clearCameraTaskTimeouts(l),l.pendingCamera=void 0,l.transaction=void 0,l.preparePromise=void 0,l.currentTaskId=void 0,l.isRecovering=!0,l.recoveryFromGeneration??(l.recoveryFromGeneration=(o==null?void 0:o.viewGeneration)??c.viewGeneration),l.recoveryOwner??(l.recoveryOwner=(o==null?void 0:o.cameraRecoveryOwner)??this.nextCameraRecoveryOwner()),this.updateCameraRecoveryReplay(e,l,a))}return c}finishCameraClearReplay(e,r){var u,h;if(((h=(u=this.cameraClearReplayByView)==null?void 0:u.get(e))==null?void 0:h.owner)!==r.owner)return;this.cameraClearReplayByView.delete(e);const n=r.replay,i=this.cameraUpdateStateByView.get(e),o=this.getActiveRenderRuntimeRecoveryView(e),a=(i==null?void 0:i.isRecovering)===!0||!!o,c=d=>{!r.preserveRecovery||!i||!i.isRecovering&&i.recoveryOwner===void 0||(i.isRecovering=!0,this.releaseCameraRecovery(e,d,i,i.recoveryOwner))};if(!n){c("missing-replay-camera-after-clear");return}if(this.viewGenerationById.get(e)!==r.viewGeneration&&!r.preserveRecovery&&!a)return;if(!this.viewContainerManager.getView(e)){c("view-removed-during-clear");return}const l=this.viewContainerManager.getCurScenePath(e);if(!l||n.scenePath&&n.scenePath!==l){c(`scene-superseded-during-clear:${n.scenePath||"unknown"}->${l||"unknown"}`);return}if(i!=null&&i.isRecovering){this.updateCameraRecoveryReplay(e,i,n);const d=this.viewGenerationById.get(e);d!==void 0&&!this.activeRenderRuntimeRecovery&&this.isViewInitReady(e)&&this.dispatchCameraRecoveryReplay(e,d);return}this.updateCamera(e,n.cameraOpt)}getCameraReplayCandidate(e,r){if(r.pendingCamera)return this.cloneCameraReplay(r.pendingCamera);if(r.replayCamera)return this.cloneCameraReplay(r.replayCamera);if(r.transaction)return{cameraOpt:{...r.transaction.camera},scenePath:r.transaction.scenePath};const n=this.viewContainerManager.getView(e);if(n!=null&&n.cameraOpt)return{cameraOpt:{...n.cameraOpt},scenePath:n.focusScenePath}}getActiveRenderRuntimeRecoveryView(e){var r;return(r=this.activeRenderRuntimeRecovery)==null?void 0:r.views.find(n=>n.viewId===e)}nextCameraRecoveryOwner(){return this.cameraRecoverySequence=(this.cameraRecoverySequence||0)+1,this.cameraRecoverySequence}updateCameraRecoveryReplay(e,r,n){const i=this.cloneCameraReplay(n);r.replayCamera=i;const o=this.getActiveRenderRuntimeRecoveryView(e);o&&(o.replayCamera=this.cloneCameraReplay(i),o.cameraRecoveryOwner=r.recoveryOwner),(!this.initAckedViewIds||!this.serviceSyncReadyViews||!this.isViewInitReady(e))&&this.control.queuePendingInitCamera(e,i.cameraOpt,i.scenePath)}beginCameraRecovery(e,r){const n=this.getCameraReplayCandidate(e,r);if(this.clearCameraTaskTimeouts(r),r.pendingCamera=void 0,r.transaction=void 0,r.preparePromise=void 0,r.currentTaskId=void 0,!n)return;r.isRecovering=!0,r.recoveryFromGeneration=this.viewGenerationById.get(e),r.recoveryOwner=this.nextCameraRecoveryOwner(),r.replayCamera=this.cloneCameraReplay(n);const i=this.getActiveRenderRuntimeRecoveryView(e);return i&&(i.replayCamera=this.cloneCameraReplay(n),i.cameraRecoveryOwner=r.recoveryOwner),this.cloneCameraReplay(n)}releaseCameraRecovery(e,r,n,i){const o=this.cameraUpdateStateByView.get(e);!(o!=null&&o.isRecovering)||n!==void 0&&o!==n||i!==void 0&&o.recoveryOwner!==i||(this.Logger.error(`[Appliance]: Camera recovery failed viewId=${e} recoveryOwner=${o.recoveryOwner??"unknown"} fromGeneration=${o.recoveryFromGeneration??"unknown"} reason=${r}`),this.cameraUpdateDestroy(e,!1))}releaseRenderRuntimeRecoveryCameras(e,r){for(const n of e.views){const i=this.cameraUpdateStateByView.get(n.viewId);!(i!=null&&i.isRecovering)||n.cameraRecoveryOwner===void 0||this.releaseCameraRecovery(n.viewId,r,i,n.cameraRecoveryOwner)}}dispatchCameraRecoveryReplay(e,r){var c,l,u;const n=this.cameraUpdateStateByView.get(e);if(!(n!=null&&n.isRecovering)||this.viewGenerationById.get(e)!==r)return!1;if(((l=(c=this.control).isRenderRuntimeRecoveryAllowed)==null?void 0:l.call(c))===!1)return this.releaseCameraRecovery(e,"manager-lifecycle-ended",n,n.recoveryOwner),!1;if(!this.viewContainerManager.getView(e))return this.releaseCameraRecovery(e,"view-removed-before-replay",n,n.recoveryOwner),!1;if(n.recoveryOwner===void 0)return this.releaseCameraRecovery(e,"missing-recovery-owner",n),!1;if(n.recoveryFromGeneration===r)return!1;const i=n.replayCamera;if(!i)return this.releaseCameraRecovery(e,"missing-replay-camera",n),!1;const o=this.viewContainerManager.getCurScenePath(e);if(!o)return this.releaseCameraRecovery(e,"missing-current-scene",n,n.recoveryOwner),!1;if(i.scenePath&&i.scenePath!==o)return this.releaseCameraRecovery(e,`scene-superseded:${i.scenePath}->${o}`,n,n.recoveryOwner),!1;const a=(u=this.cameraClearReplayByView)==null?void 0:u.get(e);return a?(a.preserveRecovery=!0,a.viewGeneration=r,a.replay=this.cloneCameraReplay(i),!1):(n.isRecovering=!1,n.replayCamera=void 0,n.pendingCamera=this.cloneCameraReplay(i),this.schedulePendingCameraForView(e,n),!0)}updateCamera(e,r){var a;const n=(a=this.cameraClearReplayByView)==null?void 0:a.get(e);let i=this.cameraUpdateStateByView.get(e);const o=this.getActiveRenderRuntimeRecoveryView(e);if(n){const c={cameraOpt:{...r},scenePath:this.viewContainerManager.getCurScenePath(e)};n.replay=c,n.viewGeneration=this.viewGenerationById.get(e),i!=null&&i.isRecovering?(n.preserveRecovery=!0,this.updateCameraRecoveryReplay(e,i,c)):o&&(n.preserveRecovery=!0,i||(i={isBusy:!0},this.cameraUpdateStateByView.set(e,i)),this.clearCameraTaskTimeouts(i),i.pendingCamera=void 0,i.transaction=void 0,i.preparePromise=void 0,i.currentTaskId=void 0,i.isRecovering=!0,i.recoveryFromGeneration=o.viewGeneration,i.recoveryOwner=this.nextCameraRecoveryOwner(),this.updateCameraRecoveryReplay(e,i,c));return}if(i!=null&&i.isRecovering){this.updateCameraRecoveryReplay(e,i,{cameraOpt:r,scenePath:this.viewContainerManager.getCurScenePath(e)});return}if(o){i||(i={isBusy:!0},this.cameraUpdateStateByView.set(e,i)),this.clearCameraTaskTimeouts(i),i.pendingCamera=void 0,i.transaction=void 0,i.preparePromise=void 0,i.currentTaskId=void 0,i.isRecovering=!0,i.recoveryFromGeneration=o.viewGeneration,i.recoveryOwner=this.nextCameraRecoveryOwner(),this.updateCameraRecoveryReplay(e,i,{cameraOpt:r,scenePath:this.viewContainerManager.getCurScenePath(e)});return}if(!this.isViewInitReady(e)){this.control.queuePendingInitCamera(e,r,this.viewContainerManager.getCurScenePath(e));return}this.updateCameraForReadyRenderer(e,r)}updateCameraForReadyRenderer(e,r){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);n||(n={isBusy:!0},this.cameraUpdateStateByView.set(e,n)),n.pendingCamera={cameraOpt:r,scenePath:this.viewContainerManager.getCurScenePath(e)},this.schedulePendingCameraForView(e,n)}schedulePendingCameraForView(e,r){if(!r.isRecovering&&!r.preparePromise&&r.currentTaskId===void 0){if(!r.transaction){const n=this.enqueueCameraPreparation(e);r.preparePromise=n,n.then(()=>{this.cameraUpdateStateByView.get(e)!==r||(r==null?void 0:r.preparePromise)!==n||r.isRecovering||this.control.isSceneBusy(e)||(r.preparePromise=void 0,this.consumePendingCameraForView(e,r))}).catch(()=>{this.cameraUpdateStateByView.get(e)!==r||r.preparePromise!==n||r.isRecovering||(r.preparePromise=void 0,this.cameraUpdateDestroy(e))});return}this.consumePendingCameraForView(e,r)}}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.getLocalWorkFinalizeQueue(e).then(async()=>{await this.waitForLocalEventQueue(e);const i=this.viewContainerManager.getCurScenePath(e);!i||this.control.isSceneBusy(e)||await this.forceDoneLocalWorks(e,i,"camera-update")}),n=r.catch(()=>{});return this.setLocalWorkFinalizeQueue(e,n),n.then(()=>this.clearLocalWorkFinalizeQueue(e,n),()=>this.clearLocalWorkFinalizeQueue(e,n)),r}consumePendingCameraForView(e,r){var l,u,h;if(this.cameraUpdateStateByView.get(e)!==r||r.preparePromise||r.currentTaskId!==void 0||r.isRecovering||this.control.isSceneBusy(e))return;const n=r.pendingCamera;if(!n)return;const i=this.viewContainerManager.getCurScenePath(e);if(n.scenePath&&n.scenePath!==i){r.pendingCamera=void 0;return}r.pendingCamera=void 0;const o=(this.cameraTaskSequenceByView.get(e)||0)+1,a=this.viewGenerationById.get(e);this.cameraTaskSequenceByView.set(e,o),r.currentTaskId=o,r.transaction={taskId:o,camera:{...n.cameraOpt},scenePath:i,viewGeneration:a,recoveryOwner:r.recoveryOwner,coreAckReceived:!1,settledAckReceived:!1},this.blurCursor(e);const c={msgType:le.UpdateCamera,dataType:xe.Local,cameraOpt:n.cameraOpt,scenePath:i,isRunSubWork:!0,viewId:e,viewGeneration:a,cameraTaskId:o};this.post(new Set([{msgType:le.TasksQueue,dataType:xe.Local,isRunSubWork:!0,isRunBackgroundThread:this.control.isUseBackgroundThread,mainTasksqueueCount:o,cameraTaskId:o,tasksqueue:new Map([[e,c]]),viewId:e,viewGeneration:a}])),this.control.textEditorManager.onCameraChange(n.cameraOpt,e);try{(l=this.control.selectorApi)==null||l.onCameraChange(e)}catch(d){(h=(u=this.Logger)==null?void 0:u.error)==null||h.call(u,`[Appliance]: [selector] onCameraChange failed: ${d==null?void 0:d.message}`)}this.startCameraTaskTimeouts(e,r,o,a)}clearCameraTaskTimeouts(e){e.cameraAckSlowTimeoutId&&(clearTimeout(e.cameraAckSlowTimeoutId),e.cameraAckSlowTimeoutId=void 0),e.cameraTransportTimeoutId&&(clearTimeout(e.cameraTransportTimeoutId),e.cameraTransportTimeoutId=void 0)}startCameraTaskTimeouts(e,r,n,i){this.clearCameraTaskTimeouts(r),r.cameraAckSlowTimeoutId=setTimeout(()=>{var o,a;!this.isCurrentCameraTransaction(e,r,n,i)||r.currentTaskId!==n||(r.cameraAckSlowTimeoutId=void 0,(a=(o=this.Logger)==null?void 0:o.warn)==null||a.call(o,`[Appliance]: camera render ACK slow viewId=${e} taskId=${n} hasPending=${!!r.pendingCamera} elapsedMs=${ru}`))},ru),r.cameraTransportTimeoutId=setTimeout(()=>{!this.isCurrentCameraTransaction(e,r,n,i)||r.currentTaskId!==n||(r.cameraTransportTimeoutId=void 0,this.failCameraTask(e,n,{code:"CAMERA_TRANSPORT_TIMEOUT",business:"updateCamera",message:"renderer returned neither success nor failure ACK",elapsedMs:sa,stage:"transport"},i))},sa)}isCurrentCameraTransaction(e,r,n,i){const o=r.transaction;return this.cameraUpdateStateByView.get(e)===r&&(o==null?void 0:o.taskId)===n&&o.viewGeneration===i&&this.viewGenerationById.get(e)===i}completeCameraTransactionIfReady(e,r){const n=r.transaction;!n||!this.isCurrentCameraTransaction(e,r,n.taskId,n.viewGeneration)||r.currentTaskId!==void 0||r.pendingCamera||!n.coreAckReceived||!n.settledAckReceived||(e===Fe?this.logMainViewCameraTrace("completed",{taskId:n.taskId,scenePath:n.scenePath,camera:n.camera,renderFinished:!0}):this.logAppViewCameraTrace(e,"completed",{taskId:n.taskId,scenePath:n.scenePath,camera:n.camera,renderFinished:!0}),this.cameraUpdateDestroy(e))}ackCameraTask(e,r,n){const i=this.cameraUpdateStateByView.get(e);!i||i.currentTaskId!==r||!this.isCurrentCameraTransaction(e,i,r,n)||(this.clearCameraTaskTimeouts(i),i.currentTaskId=void 0,i.transaction.coreAckReceived=!0,i.pendingCamera?this.consumePendingCameraForView(e,i):this.completeCameraTransactionIfReady(e,i))}failCameraTask(e,r,n,i){var a,c;const o=this.cameraUpdateStateByView.get(e);if(!(!o||!this.isCurrentCameraTransaction(e,o,r,i))){if(this.cameraFailureSequenceByView.set(e,(this.cameraFailureSequenceByView.get(e)||0)+1),this.clearCameraTaskTimeouts(o),o.currentTaskId=void 0,this.Logger.error(`[Appliance]: renderer Camera task failed code=${n.code} business=${n.business} viewId=${e} taskId=${r} stage=${n.stage||"unknown"} elapsedMs=${n.elapsedMs??0} blockers=${JSON.stringify(n.blockingWorks||[])} error=${n.message}`),n.code==="CAMERA_TRANSPORT_TIMEOUT"){if(!this.beginCameraRecovery(e,o)){this.Logger.error(`[Appliance]: Camera recovery cannot start viewId=${e} taskId=${r} reason=missing-replay-camera`),this.cameraUpdateDestroy(e,!1);return}if(((c=(a=this.control).isRenderRuntimeRecoveryAllowed)==null?void 0:c.call(a))===!1){this.releaseCameraRecovery(e,"manager-lifecycle-ended",o);return}this.scheduleRenderRuntimeFallback({type:le.ReportError,viewId:e,viewGeneration:i,reportErrorCode:"CAMERA_TRANSPORT_TIMEOUT",reportStage:n.stage||"camera-transport",reportError:n.message});return}o.pendingCamera?this.consumePendingCameraForView(e,o):this.cameraUpdateDestroy(e)}}ackCameraSettledTask(e,r,n){const i=this.cameraUpdateStateByView.get(e);!i||!this.isCurrentCameraTransaction(e,i,r,n)||(i.transaction.settledAckReceived=!0,this.completeCameraTransactionIfReady(e,i))}cameraUpdateDestroy(e,r=!0){var o,a,c,l;const n=this.cameraUpdateStateByView.get(e),i=this.getActiveRenderRuntimeRecoveryView(e);if(i&&(i.replayCamera=void 0,i.cameraRecoveryOwner=void 0),(n==null?void 0:n.recoveryOwner)!==void 0&&((o=this.viewInitRecoveryAttempts)==null||o.delete(e)),!n){r||(a=this.methodBuilder)==null||a.discardRecovery(e),this.resolveCameraUpdateEndWaiters(e);return}if(this.clearCameraTaskTimeouts(n),n.pendingCamera=void 0,n.transaction=void 0,n.preparePromise=void 0,n.currentTaskId=void 0,this.cameraUpdateStateByView.delete(e),this.resolveCameraUpdateEndWaiters(e),this.resolveViewLifecycleIdleWaiters(e),!r){(c=this.methodBuilder)==null||c.discardRecovery(e);return}!this.control.isSceneBusy(e)&&!this.control.isClearBusy(e)&&((l=this.methodBuilder)==null||l.recover(e,this.viewContainerManager.getCurScenePath(e)),this.runAnimation())}resolveCameraUpdateEndWaiters(e){var n;const r=(n=this.cameraUpdateEndWaitersByView)==null?void 0:n.get(e);r&&(this.cameraUpdateEndWaitersByView.delete(e),r.forEach(i=>i()))}waitForCameraUpdateEnd(e){var r;return(r=this.cameraUpdateStateByView)!=null&&r.has(e)?(this.cameraUpdateEndWaitersByView||(this.cameraUpdateEndWaitersByView=new Map),new Promise(n=>{const i=this.cameraUpdateEndWaitersByView.get(e)||new Set;i.add(n),this.cameraUpdateEndWaitersByView.set(e,i)})):Promise.resolve()}waitForViewLifecycleIdle(e){return this.hasPendingViewLifecycleWork(e)?(this.viewLifecycleIdleWaitersByView||(this.viewLifecycleIdleWaitersByView=new Map),new Promise(r=>{const n=this.viewLifecycleIdleWaitersByView.get(e)||new Set;n.add(r),this.viewLifecycleIdleWaitersByView.set(e,n)})):Promise.resolve()}hasPendingViewLifecycleWork(e){var r,n,i;return((r=this.cameraUpdateStateByView)==null?void 0:r.has(e))||((n=this.pendingDprByView)==null?void 0:n.has(e))||((i=this.viewRecoveryQueueByView)==null?void 0:i.has(e))||!1}resolveViewLifecycleIdleWaiters(e){var n;if(this.hasPendingViewLifecycleWork(e))return;const r=(n=this.viewLifecycleIdleWaitersByView)==null?void 0:n.get(e);r&&(this.viewLifecycleIdleWaitersByView.delete(e),r.forEach(i=>i()))}recoverAfterSceneChange(e){var r;(r=this.methodBuilder)==null||r.recover(e),this.runAnimation()}abortActiveContinuousMethods(e,r){var n;return((n=this.methodBuilder)==null?void 0:n.abortActiveContinuousMethods(e,r))||!1}abortActiveLocalInput(e,r){var g,y,S,b,I;const n=r==null?void 0:r.toString(),i=n?((g=this.collector)==null?void 0:g.getLocalId(n))||n:void 0,o=[...this.localPointsBatchData.entries()].filter(([,N])=>N.viewId===e).map(([N])=>N.toString()),a=[...this.getFullLayerBitmapEraseTxns().values()].filter(N=>N.viewId===e&&N.phase!=="committed"&&N.phase!=="aborted"),c=!n||((y=this.collector)==null?void 0:y.isLocalId(n))||((S=this.collector)==null?void 0:S.isOwn(n)),l=i!==void 0&&!!c&&o.includes(i),u=i!==void 0&&a.some(N=>{var T,p,m,v;return N.workId===i||((T=N.updatedTargetIds)==null?void 0:T.has(i))||((p=N.updatedTargetIds)==null?void 0:p.has(n||i))||((m=N.deletedTargetIds)==null?void 0:m.has(i))||((v=N.deletedTargetIds)==null?void 0:v.has(n||i))}),h=i===void 0||l||u,d=((b=this.localEventQueueByView)==null?void 0:b.has(e))||!1;return!(this.getLocalWorkViewId()===e||this.currentLocalWorkData.viewId===e||((I=this.activeLocalEvent)==null?void 0:I.viewId)===e||o.length>0||a.length>0||d)||!h?!1:(this.localInputEpochByView||(this.localInputEpochByView=new Map),this.localInputEpochByView.set(e,(this.localInputEpochByView.get(e)||0)+1),o.forEach(N=>this.rememberCancelledLocalWork(N,e)),this.currentLocalWorkData.viewId===e&&this.setCurrentLocalWorkData({workState:de.Pending}),this.getLocalWorkViewId()===e&&this.setLocalWorkViewId(void 0),this.isLocalWorkActive=!1,!0)}async clearViewScenePath(e,r,n){var c,l;const i=this.viewContainerManager.getCurScenePath(e),o=this.isViewInitReady(e);if(n){const u=(c=this.collector)==null?void 0:c.uid;if(!(!u||this.control.renderControl.isClearAble({uid:u,viewId:e,scenePath:i})))return}const a=this.beginCameraClearReplay(e,i);try{if(o||this.control.queuePendingInitClear(e,i),a.preserveRecovery||this.cameraUpdateDestroy(e),this.cancelLocalWorks(e,!r),this.control.textEditorManager.clear(e,r),o&&(this.queryTaskBatchData({dataType:xe.Service,viewId:e}).forEach(u=>{this.taskBatchData.delete(u)}),this.queryTaskBatchData({msgType:le.Clear,dataType:xe.Local,viewId:e}).forEach(u=>{this.taskBatchData.delete(u)}),this.taskBatchData.add({dataType:xe.Local,msgType:le.Clear,viewId:e}),this.runAnimation()),r||(this.control.renderControl.isUsePageAuth(e)&&i?this.control.renderControl.clearRenderPage(e,i):(l=this.collector)==null||l.dispatch({type:le.Clear,viewId:e,scenePath:i})),this.zIndexNodeMethod&&this.zIndexNodeMethod.clearZIndex(e),!o)return;await new Promise(u=>{const h=this.clearAllResolveMap.get(e)||{resolve:void 0,timer:void 0};h.timer&&clearTimeout(h.timer),h.resolve=u,h.timer=setTimeout(()=>{const d=this.clearAllResolveMap.get(e);d!=null&&d.resolve&&d.resolve(e)},this.maxLastSyncTime),this.clearAllResolveMap.set(e,h)}).then(u=>{this.clearAllResolveMap.delete(u)})}finally{this.finishCameraClearReplay(e,a)}}internalMsgEmitterListener(){var e;this.methodBuilder=new Ve([Te.CopyNode,Te.SetColorNode,Te.DeleteNode,Te.RotateNode,Te.ScaleNode,Te.TranslateNode,Te.ZIndexNode,Te.SetFontStyle,Te.SetPoint,Te.SetLock,Te.SetShapeOpt]).registerForMainEngine(We.MainEngine,this.control),this.zIndexNodeMethod=(e=this.methodBuilder)==null?void 0:e.getBuilder(Te.ZIndexNode)}setZIndex(e){const r=this.currentToolsData&&ye.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[i,o]of this.localPointsBatchData.entries()){const{state:a,viewId:c,toolsType:l,undoTickerId:u}=o,h=this.getFullLayerBitmapEraseTxns().get(i.toString()),d=a===de.Done&&o.isFullWork===!0&&l===q.BitMapEraser&&(h==null?void 0:h.phase)==="done-staging";if(e===c&&(a===de.Start||a===de.Doing||d)){if(l===q.Text)continue;o.state=de.Done,o.isFullWork=!0,this.localPointsBatchData.set(i,o),(h==null?void 0:h.phase)==="doing"&&this.markFullLayerBitmapEraseDoneStaging(h),u&&(r.add(u),o.scenePath&&l&&ql.has(l)?this.internalMsgEmitter.emit("finalizeRequested",u,c,[i.toString()],o.scenePath):l&&ki(l)&&l!==q.BitMapEraser&&o.scenePath&&this.internalMsgEmitter.emit("finalizeRequested",u,c,[],o.scenePath)),n=!0}}if(n){this.consume();for(const[i,o]of this.localPointsBatchData.entries())o.viewId===e&&o.state===de.Done&&this.deleteLocalPoint(i)}return[...r]}cancelLocalWorks(e,r=!0,n){var f;const i=this.viewContainerManager.getCurScenePath(e);let o=i;const a=new Set,c=new Set,l=new Map;let u=!1;const h=new Set(n||[]);if(!n){for(const[g,y]of this.localPointsBatchData.entries())y.viewId===e&&h.add(g.toString());for(const g of this.getFullLayerBitmapEraseTxns().values())g.viewId===e&&h.add(g.workId)}for(const g of h){const y=this.getFullLayerBitmapEraseTxns().get(g);!y||y.viewId!==e||(y.phase="aborting",y.commitTimeoutId&&clearTimeout(y.commitTimeoutId),y.scenePath&&(o=y.scenePath),y.undoTickerId&&y.scenePath&&l.set(y.undoTickerId,y.scenePath),this.rememberCancelledEraseTxn(g))}for(const[g,y]of this.localPointsBatchData.entries()){const S=g.toString();if(y.viewId!==e||!h.has(S))continue;const b=y.scenePath||i;y.scenePath&&(o=y.scenePath),y.undoTickerId&&b&&l.set(y.undoTickerId,b),ki(y.toolsType)&&this.rememberCancelledEraseTxn(S);const I=this.getDoneWaitForView(e);I!=null&&I.workIds.includes(g.toString())&&(u=!0),g!==Le&&(this.rememberCancelledLocalWork(S,e),a.add(S),y.state!==de.Start&&c.add(S)),this.localPointsBatchData.delete(g)}for(const g of h)g!==Le&&(this.rememberCancelledLocalWork(g,e),a.add(g)),this.finishFullLayerBitmapEraseTxn(g,"aborted");const d=this.getDoneWaitForView(e);d!=null&&d.workIds.some(g=>h.has(g))&&(u=!0);for(const g of[...this.taskBatchData])g.viewId===e&&g.workId!==void 0&&h.has(g.workId.toString())&&(g.msgType===le.CreateWork||g.msgType===le.DrawWork||g.msgType===le.RemoveNode)&&this.taskBatchData.delete(g);this.reRenders||(this.reRenders=new Map);for(const[g,y]of this.reRenders.entries()){const S=y.filter(b=>{const N=[...b.renderEraseTxnIds||[],...b.eraseTxnId!==void 0?[b.eraseTxnId]:[]].some(T=>h.has(T));return N&&this.retireRenderedImageBitmap(b),!N});S.length?this.reRenders.set(g,S):this.reRenders.delete(g)}if(u){const g=this.getDoneResolverForView(e);this.clearDoneWaitForView(e),g==null||g(!1)}l.forEach((g,y)=>{this.internalMsgEmitter.emit("cancelUndoTicker",y,e,g)}),a.size&&([...a].forEach(y=>{this.taskBatchData.add({msgType:le.RemoveNode,workId:y,viewId:e,dataType:xe.Local,isRunSubWork:!0,scenePath:o})}),r&&c.size&&((f=this.collector)==null||f.dispatch({type:le.RemoveNode,removeIds:[...c],viewId:e,scenePath:o})),this.consume()),this.currentLocalWorkData.viewId===e&&this.setCurrentLocalWorkData({workState:de.Pending})}timeoutLocalWorks(e,r,n,i,o){var d,f;this.invalidateTransactionBarrier(e);const a=(f=(d=this.viewContainerManager.getView(e))==null?void 0:d.displayer)==null?void 0:f.commiter,c=new Set;i&&i.forEach(g=>{const y=this.getFullLayerBitmapEraseTxns().get(g);(y==null?void 0:y.undoTickerId)!==void 0&&c.add(y.undoTickerId);const S=this.localPointsBatchData.get(g);(S==null?void 0:S.undoTickerId)!==void 0&&c.add(S.undoTickerId)});let l=[];try{l=(a==null?void 0:a.getPendingTickerSnapshots(r))||[],i&&(l=l.filter(g=>c.has(g.tickerId)))}catch(g){this.logLocalWorkBarrierError(`[Appliance]: reading pending Undo tickers failed; viewId=${e}; reason=${n}; error=${yr(g)}`)}const u=o?`; error=${yr(o)}`:"";this.logLocalWorkBarrierError(`[Appliance]: local work barrier failed; viewId=${e}; scenePath=${r}; reason=${n}${u}`);const h=new Set;[...i||this.getFullLayerBitmapEraseTxns().keys()].forEach(g=>{const y=this.getFullLayerBitmapEraseTxns().get(g.toString());(y==null?void 0:y.viewId)===e&&h.add(g.toString())}),h.forEach(g=>{const y=this.getFullLayerBitmapEraseTxns().get(g);y&&this.rollbackBitmapEraserTxn(y)});try{this.cancelLocalWorks(e,!1,i)}catch(g){this.logLocalWorkBarrierError(`[Appliance]: cancelling timed-out local work failed; viewId=${e}; reason=${n}; error=${yr(g)}`)}finally{l.forEach(g=>{try{a==null||a.cancelUndoTicker(g.tickerId,e,g.scenePath)}catch(y){this.logLocalWorkBarrierError(`[Appliance]: forcing Undo stack-end failed; viewId=${e}; tickerId=${g.tickerId}; reason=${n}; error=${yr(y)}`)}})}}rollbackBitmapEraserTxn(e){var o,a,c,l;if(e.phase==="aborted"||e.phase==="committed")return;e.phase="aborting",e.rollbackStartedAt=Date.now(),this.rememberCancelledEraseTxn(e.workId);try{this.post(new Set([{msgType:le.CancelBitmapEraser,dataType:xe.Local,viewId:e.viewId,workId:e.workId,isRunSubWork:!0,isRunBackgroundThread:!0}]))}catch(u){this.logLocalWorkBarrierError(`[Appliance]: bitmap eraser abort notification failed; viewId=${e.viewId}; workId=${e.workId}; error=${yr(u)}`)}const r=this.localPointsBatchData.get(e.workId);r&&(r.state=de.Pending,r.points=[],r.isFullWork=!1,this.localPointsBatchData.set(e.workId,r));const n=e.beforeImages;if(!(n!=null&&n.size)){this.scheduleViewRecovery(e.viewId,"bitmap-eraser-timeout-without-snapshot");return}const i=e.scenePath||this.viewContainerManager.getCurScenePath(e.viewId)||"";for(const[u,h]of n){const d=xt(h.op||[]);this.taskBatchData.add({msgType:le.FullWork,dataType:xe.Local,viewId:e.viewId,scenePath:i,workId:u,toolsType:h.toolsType,opt:ye.cloneDeep(h.opt),ops:d,isFullWork:!0,isRunSubWork:!0,updateNodeOpt:{useAnimation:!1}});const f=(o=e.deletedTargetIds)==null?void 0:o.has(u),g=(a=this.collector)==null?void 0:a.hasId(e.viewId,i,u);f||!g?(c=this.collector)==null||c.dispatch({type:le.FullWork,viewId:e.viewId,scenePath:i,workId:u,toolsType:h.toolsType,opt:ye.cloneDeep(h.opt),ops:d,isSync:!0}):(l=this.collector)==null||l.dispatch({type:le.UpdateNode,viewId:e.viewId,scenePath:i,workId:u,toolsType:h.toolsType,opt:ye.cloneDeep(h.opt),ops:d,isSync:!0,updateNodeOpt:{useAnimation:!1}})}try{this.consume()}catch(u){this.scheduleViewRecovery(e.viewId,"bitmap-eraser-timeout-render-compensation-failed"),this.logLocalWorkBarrierError(`[Appliance]: bitmap eraser render compensation enqueue failed; viewId=${e.viewId}; workId=${e.workId}; error=${yr(u)}`)}}logLocalWorkBarrierError(e){var r;(r=this.Logger)==null||r.error(e)}removeDrawingWork(e){this.abortActiveLocalInput(e),this.cancelLocalWorks(e)}removeNodes(e,r){var i,o;const n=(i=this.viewContainerManager.getView(e))==null?void 0:i.focusScenePath;if(n&&r.length){for(const a of r)this.taskBatchData.add({msgType:le.RemoveNode,workId:a,viewId:e,dataType:xe.Local,isRunSubWork:!1});this.consume(),(o=this.collector)==null||o.dispatch({type:le.RemoveNode,removeIds:r,viewId:e,scenePath:n})}}hoverCursor(e,r){var n;if(((n=this.currentToolsData)==null?void 0:n.toolsType)===q.Selector&&!this.isViewBusy(r)){const i=this.viewContainerManager.getView(r);if(i&&i.displayer&&i.displayer.vDom){const c=i.displayer.vDom.state.floatBarData;if(c){const{x:l,y:u,w:h,h:d}=c;if(Y0(e,{x:l,y:u,w:h,h:d}))return}}const o=this.viewContainerManager.transformToScenePoint(e,r),a={msgType:le.CursorHover,dataType:xe.Local,point:o,toolsType:this.currentToolsData.toolsType,opt:this.currentToolsData.toolsOpt,isRunSubWork:!1,viewId:r};this.queryTaskBatchData({msgType:le.CursorHover,dataType:xe.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)!==q.Selector)return;const r={msgType:le.CursorBlur,dataType:xe.Local,isRunSubWork:!1,viewId:e};this.queryTaskBatchData({msgType:le.CursorHover,dataType:xe.Local,viewId:e}).forEach(i=>{this.taskBatchData.delete(i)}),this.taskBatchData.add(r),this.consume()}sendCursorEvent(e,r){var c,l,u;if(!this.currentLocalWorkData||this.currentLocalWorkData.workState===de.Unwritable||this.isViewBusy(r))return;const n=(c=this.currentToolsData)==null?void 0:c.toolsType;if(this.workState===de.Pending&&n===q.Selector&&(ye.isNumber(e[0])&&ye.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 i=(l=this.collector)==null?void 0:l.uid,o=this.viewContainerManager.getCurScenePath(r);switch((u=this.currentToolsData)==null?void 0:u.toolsType){case q.Eraser:case q.PencilEraser:case q.BitMapEraser:{if(i&&!this.control.renderControl.isClearAble({uid:i,viewId:r,filterLocalSelf:!1,scenePath:o}))return;break}default:if(i&&!this.control.renderControl.isWritable||i&&!this.control.renderControl.isRenderAble({uid:i,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 r,n;{const i=(r=this.collector)==null?void 0:r.getScenePathData(e);if(!i)return;if(Object.keys(i).forEach(o=>{var a;((a=this.collector)==null?void 0:a.getLocalId(o))===Le&&delete i[o]}),Object.keys(i).length&&this.viewContainerManager.mainView&&this.viewContainerManager.mainView.cameraOpt){const o=this.viewContainerManager.mainView.id,a=this.getViewSceneRequestKey(o,e),c=(n=this.boundingRectMap)==null?void 0:n.get(a);if(c)return c.promise;const l=this.createInternalRequestId("bounding_rect");let u;const d=new Promise(g=>{u=g}).then(g=>{const y=this.boundingRectMap.get(a);return(y==null?void 0:y.requestId)===l&&(this.boundingRectMap.delete(a),this.boundingRectRequestIdByViewScene.delete(a)),g});this.boundingRectMap.set(a,{resolve:u,requestId:l,viewId:o,promise:d});const f={msgType:le.BoundingBox,dataType:xe.Local,scenePath:e,scenes:i,cameraOpt:{...this.viewContainerManager.mainView.cameraOpt},isRunSubWork:!0,viewId:o,requestId:l};return this.boundingRectRequestIdByViewScene.set(a,f.requestId),this.taskBatchData.add(f),this.runAnimation(),d}}}getSnapshot(e,r,n,i){var o,a,c,l,u;{const h=(o=this.collector)==null?void 0:o.getViewIdBySecenPath(e);if(!h)return;const d=this.getViewSceneRequestKey(h,e),f=(a=this.snapshotMap)==null?void 0:a.get(d);if(f)return f.promise;const g=(c=this.collector)==null?void 0:c.getStorageData(h,e);if(!g)return;if(Object.keys(g).forEach(y=>{var S;((S=this.collector)==null?void 0:S.getLocalId(y))===Le&&delete g[y]}),Object.keys(g).length){const y=this.viewContainerManager.mainView;if(!y)return;const S=r||((l=y.cameraOpt)==null?void 0:l.width),b=n||((u=y.cameraOpt)==null?void 0:u.height),I=this.createInternalRequestId("snapshot"),N=this.control.isUseBackgroundThread?[void 0,void 0]:[void 0];let T;const m=new Promise(M=>{T=M}).then(M=>{const k=this.snapshotMap.get(d);return(k==null?void 0:k.requestId)===I&&(this.snapshotMap.delete(d),this.snapshotRequestIdByViewScene.delete(d)),M.reverse()});this.snapshotMap.set(d,{resolve:T,value:N,requestId:I,viewId:h,promise:m});const v={msgType:le.Snapshot,dataType:xe.Local,scenePath:e,scenes:g,w:S,h:b,cameraOpt:i&&{...i,width:S,height:b}||y.cameraOpt,isRunSubWork:!0,isRunBackgroundThread:this.control.isUseBackgroundThread,viewId:h,requestId:I};return this.snapshotRequestIdByViewScene.set(d,v.requestId),this.taskBatchData.add(v),this.runAnimation(),m}}}queryTaskBatchData(e){const r=[];if(e)for(const n of this.taskBatchData.values()){let i=!0;for(const[o,a]of Object.entries(e))if(n[o]!==a){i=!1;break}i&&r.push(n)}return r}insertIconify(e,r){var a;if(!this.control.canAcceptLocalMutation(e))return;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;tt.InternalMsgEmitter.emit("addUndoTicker",c,e,{render:!0,storage:!0,source:$e.AsyncIcon}),tt.InternalMsgEmitter.emit("finalizeRequested",c,e,[r.uuid],o);const l={...r,type:on.Iconify};this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayer(e),l.zIndex=this.zIndexNodeMethod.getMaxZIndex(e)),this.taskBatchData.add({msgType:le.FullWork,dataType:xe.Local,toolsType:q.Image,workId:r.uuid,opt:l,viewId:e,willRefresh:!0,willSyncService:!0,needUndoTicker:c}),this.runAnimation()}}insertBackgroundSVG(e,r){if(!this.control.canAcceptLocalMutation(e))return;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 i=n==null?void 0:n.focusScenePath;if(e&&i){const o=this.now;tt.InternalMsgEmitter.emit("addUndoTicker",o,e,{render:!0,storage:!0,source:$e.AsyncIcon}),tt.InternalMsgEmitter.emit("finalizeRequested",o,e,[r.uuid],i);const a={...r,locked:r.locked??!0,type:Wi.url};this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayerForBackgroundSVG(e),a.zIndex=this.zIndexNodeMethod.getMaxZIndexForBackgroundSVG(e)),this.taskBatchData.add({msgType:le.FullWork,dataType:xe.Local,toolsType:q.BackgroundSVG,workId:r.uuid,opt:a,viewId:e,willRefresh:!0,willSyncService:!0,needUndoTicker:o,isRunBackgroundThread:!0,scenePath:i}),this.runAnimation()}}async insertBackgroundMarkMap(e,r){var o;if(!this.control.canAcceptLocalMutation(e))return;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&&!Q0e(r.data))throw new Error("data must be markdown string");const i=n==null?void 0:n.focusScenePath;if(e&&i){const a=r.uuid.toString();if((o=this.collector)!=null&&o.hasId(e,i,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;tt.InternalMsgEmitter.emit("addUndoTicker",c,e,{render:!0,storage:!0,source:$e.AsyncMarkmap}),tt.InternalMsgEmitter.emit("finalizeRequested",c,e,[a],i);const l={...r,locked:r.locked??!0,type:Wi.markmap};return this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayerForBackgroundSVG(e),l.zIndex=this.zIndexNodeMethod.getMaxZIndexForBackgroundSVG(e)),this.taskBatchData.add({msgType:le.FullWork,dataType:xe.Local,toolsType:q.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),tt.InternalMsgEmitter.emit("ackRenderUndoTicker",c,e,i),tt.InternalMsgEmitter.emit("ackStorageUndoTicker",c,e,i),new Error(`instertBackgroundMarkMap svgInfo.uuid ${u} insert timeout`)})}}async updateBackgroundMarkMap(e,r,n){var l;if(!this.control.canAcceptLocalMutation(e))return;this.assertMarkmapRuntimeRegistered("updateBackgroundMarkMap",e);const i=this.viewContainerManager.getView(e);if(!i)throw new Error("updateBackgroundMarkMap viewId is not exist");const o=i==null?void 0:i.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;tt.InternalMsgEmitter.emit("addUndoTicker",a,e,{render:!0,storage:!0,source:$e.AsyncMarkmap}),tt.InternalMsgEmitter.emit("finalizeRequested",a,e,[r],o);const c={...n,type:Wi.markmap};this.taskBatchData.add({msgType:le.UpdateNode,dataType:xe.Local,toolsType:q.BackgroundSVG,workId:r,opt:c,viewId:e,willRefresh:!0,willSyncService:!0,needUndoTicker:a,isRunBackgroundThread:!0}),this.runAnimation()}insertImage(e,r){if(!this.control.canAcceptLocalMutation(e))return;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 i=n==null?void 0:n.focusScenePath;if(e&&i){const{src:o,uuid:a}=r;if(a&&!o){this.tmpImageConfigMap.set(a,r);return}const c=this.now;tt.InternalMsgEmitter.emit("addUndoTicker",c,e,{render:!0,storage:!0,source:$e.AsyncImage});const l={...r,type:on.Image};this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayer(e),l.zIndex=this.zIndexNodeMethod.getMaxZIndex(e)),this.taskBatchData.add({msgType:le.FullWork,dataType:xe.Local,toolsType:q.Image,workId:r.uuid,opt:l,viewId:e,willRefresh:!0,willSyncService:!0,needUndoTicker:c}),this.runAnimation(),tt.InternalMsgEmitter.emit("finalizeRequested",c,e,[r.uuid],i)}}lockImage(e,r,n){var a,c;if(!this.control.canAcceptLocalMutation(e))return;const i=this.viewContainerManager.getView(e);if(!i)throw new Error("insertImage viewId is not exist");const o=i==null?void 0:i.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===q.Image&&h.opt.uuid===r){const d=this.now,f=(a=this.collector)!=null&&a.isOwn(u)?(c=this.collector)==null?void 0:c.getLocalId(u):u;tt.InternalMsgEmitter.emit("addUndoTicker",d,e,{render:!0,storage:!0,source:$e.AsyncImage});const g={...h.opt,locked:n,type:on.Image};this.taskBatchData.add({msgType:le.FullWork,dataType:xe.Local,toolsType:q.Image,workId:f,opt:g,viewId:e,willRefresh:!0,willSyncService:!0,needUndoTicker:d}),this.runAnimation(),tt.InternalMsgEmitter.emit("finalizeRequested",d,e,[f],o);return}}}completeImageUpload(e,r,n){if(!this.control.canAcceptLocalMutation(e))return;const i=this.viewContainerManager.getView(e);if(!i)throw new Error("insertImage viewId is not exist");const o=i==null?void 0:i.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 i of Object.values(n))if(i&&i.toolsType===q.Image){const o=i.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:Le,selectIds:[e],msgType:le.Select,dataType:xe.Local,viewId:r,willSyncService:!0}),this.runAnimation()}blurSelector(e,r,n){this.taskBatchData.add({workId:n||Le,selectIds:[],msgType:le.Select,dataType:xe.Service,viewId:e,scenePath:r}),this.runAnimation()}consoleWorkerInfo(){this.taskBatchData.add({msgType:le.Console,dataType:xe.Local,isRunSubWork:!0,viewId:""}),this.consume()}sendClearUids(e,r){var i,o;const n=new Set;if(n.add({msgType:le.AuthClear,dataType:xe.Local,viewId:e,clearUids:r,localUid:(i=this.collector)==null?void 0:i.uid}),this.control.hasOffscreenCanvas)this.fullWorker.postMessage(n);else{const a=(o=this.mainThread)==null?void 0:o.consume(n);a==null||a.catch(c=>{this.logLocalWorkBarrierError(`[Appliance]: AuthClear delivery failed; viewId=${e}; error=${c instanceof Error?c.message:String(c)}`)})}}async getVNodeInfo(e,r,n){if(!this.getVNodeInfoResolveMap.has(e))return this.taskBatchData.add({msgType:le.GetVNodeInfo,dataType:xe.Local,isRunSubWork:!0,viewId:r,workIds:n,workId:e}),this.consume(),await new Promise(i=>{const o=this.getVNodeInfoResolveMap.get(e)||{resolve:void 0,timer:void 0};o.timer&&clearTimeout(o.timer),o.resolve=i,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(i=>{const{uuid:o}=i;return this.getVNodeInfoResolveMap.delete(o),i})}}class Nwe{constructor(t){x(this,"internalMsgEmitter");x(this,"control");x(this,"roomHotkeyCheckers");x(this,"tmpCopyStore",new Map);x(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)===q.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,i,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&&((i=this.collector)!=null&&i.hasSelector(e,r))&&Ve.emitMethod(We.MainEngine,Te.DeleteNode,{workIds:[Le],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(Te.CopyNode);if(!r||!this.collector||!n)return;const i=this.collector.transformKey(Le),o=this.collector.getStorageData(t,e);if(!o)return;const a=o[i],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 i,o;const r=this.control.viewContainerManager.getView(t),n=(o=(i=this.mainEngine)==null?void 0:i.methodBuilder)==null?void 0:o.getBuilder(Te.CopyNode);if(!(!r||!this.tmpCopyCoordInfo||!this.tmpCopyStore.size||!this.collector||!n)&&r.viewData&&this.tmpCopyCoordInfo){const a=ye.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:ye.cloneDeep(this.tmpCopyStore),copyCoordInfo:{offset:a,cameraOpt:l},undoTickerId:u})}}setMemberState(t){var e;(e=this.control.room)==null||e.setMemberState(t)}}const Zp=50;function Owe(s){if("diffType"in s){if(s.diffType==="view")return`view:${s.viewId}`;if(s.diffType==="scenePath")return`scenePath:${s.viewId}:${s.scenePath}`}return`data:${s.key}:${s.type??""}:${s.toolsType??""}`}class zwe{constructor(t,e){x(this,"batches",new Map);this.logger=t,this.batchWindowMs=e}append(t,e,r,n){if(!n.length)return;const i=`${t}:${e}:${r}`;let o=this.batches.get(i);o||(o={items:[],indexByIdentity:new Map,flushTimer:setTimeout(()=>this.flush(i),this.batchWindowMs)},this.batches.set(i,o));const a=Date.now();for(const c of n){const l=Owe(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,...i]=t.split(":"),o=i.join(":"),a=o?` viewId=${n} scenePath=${o}`:` viewId=${n} scope=view`;for(let c=0;c<e.items.length;c+=Zp){const u=e.items.slice(c,c+Zp).map(({timestamp:h,item:d})=>"diffType"in d&&d.diffType!=="data"?{timestamp:h,...d}:`${d.key},${d.type??""},${d.toolsType??""},${h}`);this.logger.info(`[Appliance]: [sync-data] source=${r}${a} changesLength=${u.length} changes=${JSON.stringify(u)}`)}}destroy(){this.clearPending()}clearPending(){for(const t of this.batches.values())clearTimeout(t.flushTimer);this.batches.clear()}}const Kp=3,Bwe="__APPLIANCE_PLUGIN_RENDER_MODE_DB",zi="renderModes",jwe="appliance-plugin-render-runtime",Ed=1500,xd=1500;function Fwe(s){return SM.hash(s)}function Rd(){return globalThis.indexedDB}const Xp=new WeakSet;function Uwe(s){if(!(typeof s!="object"||s===null)&&!Xp.has(s)&&(Xp.add(s),!!s.deleteDatabase))try{const t=s.deleteDatabase(jwe),e=()=>{t.onerror=null,t.onsuccess=null,t.onblocked=null};t.onerror=e,t.onsuccess=e,t.onblocked=e}catch{}}function kd(s,t){return Uwe(s),new Promise((e,r)=>{const n=s.open(Bwe,Kp);let i=!1;const o=()=>{n.onerror=null,n.onsuccess=null,n.onupgradeneeded=null,n.onblocked=null},a=(l,u=!1)=>{i||(i=!0,clearTimeout(c),u?n.onblocked=null:o(),r(l))},c=setTimeout(()=>{a(new Error("render runtime cache open timeout"),!0)},t);n.onerror=()=>{if(i){o();return}a(n.error||new Error("render runtime cache open failed"))},n.onblocked=()=>{a(new Error("render runtime cache open blocked"),!0)},n.onupgradeneeded=l=>{var u;try{const h=l.oldVersion||0;h>0&&h<Kp&&n.result.objectStoreNames.contains(zi)&&n.result.deleteObjectStore(zi),n.result.objectStoreNames.contains(zi)||n.result.createObjectStore(zi)}catch(h){try{(u=n.transaction)==null||u.abort()}catch{}a(h instanceof Error?h:new Error(`render runtime cache upgrade failed: ${String(h)}`),!0)}},n.onsuccess=()=>{const l=n.result;if(i){l.close(),o();return}i=!0,clearTimeout(c),o(),e(l)}})}function Ad(s,t,e,r){return new Promise((n,i)=>{let o,a;try{o=s.transaction(zi,t),a=e(o.objectStore(zi))}catch(d){i(d);return}let c=!1;const l=()=>{clearTimeout(h),a.onsuccess=null,a.onerror=null,o.oncomplete=null,o.onabort=null,o.onerror=null},u=(d,f=!1)=>{if(!c){if(c=!0,l(),f)try{o.abort()}catch{}i(d instanceof Error?d:new Error(`render runtime cache request failed: ${String(d)}`))}},h=setTimeout(()=>{u(new Error("render runtime cache operation timeout"),!0)},r);a.onsuccess=()=>{},a.onerror=()=>u(a.error||new Error("render runtime cache request failed")),o.onabort=()=>u(o.error||new Error("render runtime cache transaction aborted")),o.onerror=()=>u(o.error||new Error("render runtime cache transaction failed")),o.oncomplete=()=>{if(c)return;c=!0;let d;try{d=a.result}catch(f){l(),i(f);return}l(),n(d)}})}async function Wwe(s,t=Rd(),e={}){if(!t)return{reason:"indexeddb-unavailable"};const r=e.timeoutMs??xd;let n;try{n=await kd(t,e.timeoutMs??Ed)}catch(i){return{readFailed:!0,reason:i instanceof Error?i.message:String(i)}}try{const i=await Ad(n,"readonly",o=>o.get(s),r);return i===void 0?{reason:"miss"}:q0(i)?{renderModel:i}:{reason:"invalid-render-model"}}catch(i){return{readFailed:!0,reason:i instanceof Error?i.message:String(i)}}finally{n.close()}}async function Vwe(s,t,e=Rd(),r={}){if(!e||!q0(t))return!1;const n=r.timeoutMs??xd;let i;try{i=await kd(e,r.timeoutMs??Ed)}catch{return!1}try{return await Ad(i,"readwrite",o=>o.put(t,s),n),!0}catch{return!1}finally{i.close()}}async function $we(s,t=Rd(),e={}){if(!t)return!1;const r=e.timeoutMs??xd;let n;try{n=await kd(t,e.timeoutMs??Ed)}catch{return!1}try{return await Ad(n,"readwrite",i=>i.delete(s),r),!0}catch{return!1}finally{n.close()}}class Ywe{constructor(t){x(this,"control");x(this,"roomMemberManager");x(this,"worker");x(this,"publicMsgEmitter");x(this,"renderUids",new Map);x(this,"pageAuth",new Map);x(this,"isLocalRender",!1);x(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:i,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=i&&this.cloneElementIds(r,c,i,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:wt.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 i=r.get(n);if(i){const{render:c,pages:l}=i,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:wt.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:wt.clearView,viewId:t},e)))}clearRenderPage(t,e,r=!0){var a,c;const n=this.pageAuth.get(t);if(!n)return;const i=n.get(e);let o;if(i){const{render:l,pages:u}=i,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:wt.clearPage,viewId:t,scenePath:e,pageId:o},r))}hasPage(t,e,r){const n=this.pageAuth.get(e);if(!n)return!1;const i=n.get(r);return i?i.pages.has(t):!1}getPageInfo(t,e,r){const n=this.pageAuth.get(e);if(!n)return;const i=n.get(r);if(i)return i.pages.get(t)}addRenderPageElementId(t,e=!0,r=!1){var u,h;const{viewId:n,elementId:i,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:f}=c,g=d==="localSelf"?(u=this.control.collector)==null?void 0:u.uid:d;if(g&&f.has(g)){const y=f.get(g)||new Set;y.add(i),f.set(g,y),l=g}}r&&this.pageAuthEffect(n),e&&l&&((h=this.control.collector)==null||h.dispatchPageAuth({operation:wt.addElement,viewId:n,scenePath:o,pageId:l,pageData:{elementId:i}},e))}delRenderPageElementId(t,e=!0,r=!1){var u,h;const{viewId:n,elementId:i,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:f}=c,g=d==="localSelf"?(u=this.control.collector)==null?void 0:u.uid:d;if(g&&f.has(g)){const y=f.get(g);y&&(y.delete(i),f.set(g,y),l=g)}}r&&this.pageAuthEffect(n),e&&l&&((h=this.control.collector)==null||h.dispatchPageAuth({operation:wt.deleteElement,viewId:n,scenePath:o,pageId:l,pageData:{elementId:i}},e))}setPageRender(t,e,r,n=!0){var a;const i=this.pageAuth.get(t);if(!i)throw new Error(`no view info in viewId: ${t}`);const o=i.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:wt.renderPage,viewId:t,scenePath:e,pageData:{render:r}},n))}isRenderAble(t){var c,l;const{uid:e,viewId:r,filterLocalSelf:n=!0,scenePath:i}=t,o=this.renderUids.get(r);if(o){const{render:u,hide:h}=o;if(u===void 0&&h===void 0)return!0;if(ye.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||ye.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&&i){const u=a.get(i);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:i}=t,o=this.renderUids.get(r);if(o){const{clear:l}=o;return!!(l===void 0||l===!0||ye.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&&i){const l=a.get(i);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:i}=t,o=this.renderUids.get(r);if(o&&i){const{render:d,hide:f}=o;if(d===void 0&&f===void 0)return!0;const g=(c=this.control.collector)==null?void 0:c.getUidFromKey(i);return g?!!(ye.isSet(d)&&(d.has(g)||d.has("localSelf")&&((l=this.control.collector)==null?void 0:l.uid)===g)||d===!0&&(!f||ye.isSet(f)&&!f.has(g)&&!(f.has("localSelf")&&((u=this.control.collector)==null?void 0:u.uid)===g))):!1}const a=this.pageAuth.get(r);if(a&&n&&i){const d=a.get(n);if(d){const{render:f,pages:g}=d;if(!f)return!0;const y=(h=this.control.collector)==null?void 0:h.uid,S=f==="localSelf"?y:f,b=S&&g.get(S)||void 0;if(b)switch(e){case le.RemoveNode:return!0;default:return b.has(i)}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:i}=n;return i!=="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,i={};if(r){const{render:a,hide:c,clear:l}=r;a&&(i.render=a===!0&&!0||new Set(a)),c&&(i.hide=c===!0&&!0||new Set(c)),l&&(i.clear=l===!0&&!0||new Set(l)),this.renderUids.set(e,i)}else this.renderUids.delete(e);n&&((o=this.control.collector)==null||o.dispatchRenderAuth({operation:Mr.setAuth,viewId:e,renderData:i},n)),this.renderEffect(e)}publishOneRender(t,e,r,n=!0){var a;const i=this.renderUids.get(t);let o;switch(r){case"show":i?(i.render||(i.render=new Set),ye.isSet(i.render)&&i.render.add(e),ye.isSet(i.hide)&&i.hide.delete(e)):this.renderUids.set(t,{render:new Set([e])}),o=Mr.setShow;break;case"hide":i?(i.hide||(i.hide=new Set),ye.isSet(i.hide)&&i.hide.add(e),ye.isSet(i.render)&&i.render.delete(e)):this.renderUids.set(t,{hide:new Set([e])}),o=Mr.setHide;break}i?this.renderUids.set(t,i):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 i=this.renderUids.get(t);r?i?(i.clear||(i.clear=new Set),ye.isSet(i.clear)&&i.clear.add(e)):this.renderUids.set(t,{clear:new Set([e])}):i&&ye.isSet(i.clear)&&i.clear.has(e)&&i.clear.delete(e),i?this.renderUids.set(t,i):this.renderUids.delete(t),n&&((o=this.control.collector)==null||o.dispatchRenderAuth({operation:Mr.setClear,viewId:t,uid:e,isClear:r},n)),this.renderEffect(t)}syncRenderUids(t,e,r,n){const i=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;i||o||a?this.renderUids.set(t,{render:i,hide:o,clear:a}):this.renderUids.delete(t),this.renderEffect(t),this.publicMsgEmitter.emit("syncRenderUids",t,{render:i,hide:o,clear:a})}syncPageAuth(t,e,r=!1){let n=!1;if(!e)this.pageAuth.delete(t);else{const i=this.pageAuth.get(t)||new Map;for(const[o,a]of Object.entries(e)){const{render:c,pages:l}=a,u=i.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[g,y]of Object.entries(l))d.set(g,new Set(Object.keys(y)));const f={render:h,pages:d};d.size&&i.set(o,f)}}i.size&&(this.pageAuth.set(t,i),this.publicMsgEmitter.emit("syncPageAuth",t,i))}(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:Mr.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 i=(a=this.control.collector)==null?void 0:a.getStorageData(t,e),o=new Set;if(i){for(const l of Object.keys(i))if(r.has(l)){const u=`${l}_${n}`;if(o.add(u),!Object.keys(i).includes(u)){const h=ye.cloneDeep(i[l]);(c=this.control.collector)==null||c.updateValue(u,{type:le.FullWork,...h,workId:u},{isSync:!0,viewId:t,scenePath:e})}}}return o}delElementIds(t,e,r){var i,o;const n=(i=this.control.collector)==null?void 0:i.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 Gwe{constructor(t){x(this,"internalMsgEmitter");x(this,"control");x(this,"maps",new Map);x(this,"showId");x(this,"color");x(this,"timer");x(this,"updateMiniMapCamera",ye.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,i=r.height/r.scale,o=e.miniMapCamera.width/e.miniMapCamera.scale,a=e.miniMapCamera.height/e.miniMapCamera.scale;(n>=o||i>=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:f,height:g}=d.getBoundingClientRect(),y=Math.min(f/h.width,g/h.height);l.clearRect(0,0,c.width,c.height),c.width=h.width,c.height=h.height,c.style.width=`${h.width*y}px`,c.style.height=`${h.height*y}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 i=n.cameraOpt;if(!i)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=Q.createRef();this.maps.set(t,{contianer:e,miniMapCanvas:c,miniMapCamera:r,viewCamera:i}),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 i={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)||i;o=vd(o,i)||i;let a=o.width,c=o.height,l=1;const u=a>r.width&&Math.min(r.width/a,l)||l,h=c>r.height&&Math.min(r.height/c,l)||l;return u<=h?(a=u<1&&r.width||a,c=Math.floor(c*u)+1,l=u):u>h&&(c=h<1&&r.height||c,a=Math.floor(a*h)+1,l=h),{scale:l,centerX:o.originX+o.width/2,centerY:o.originY+o.height/2,width:a,height:c}}getMiniMapCanvas(t){const e=this.maps.get(t);return(e==null?void 0:e.miniMapCanvas.current)||null}updateViewCamera(t,e){const r=this.maps.get(t);r&&(r.viewCamera=e,this.listener.emitAsync([t,"viewCameraUpate"],1))}destroyMiniMap(t){const e=t||this.showId;e&&(this.maps.delete(e),this.control.viewContainerManager.setActiveMiniMap(e,!1))}}const Ge="[Appliance]: [selector]",Hwe=["bold","normal"],Qwe=["italic","normal"],qwe=["top","left","right","bottom","topLeft","topRight","bottomLeft","bottomRight","leftTop","leftBottom","rightTop","rightBottom"];class Zwe{constructor(t){x(this,"control");x(this,"logger");x(this,"lastSelectedIdsByView",new Map);x(this,"lastViewRectByView",new Map);x(this,"updateResolveMap",new Map);x(this,"clearResolveMap",new Map);x(this,"copyResolveMap",new Map);x(this,"deleteResolveMap",new Map);x(this,"lastRemoteSelectorByView",new Map);x(this,"cameraEmitThrottleByView",new Map);x(this,"pendingCameraChangeByView",new Map);x(this,"pendingPropertyGeometryByKey",new Map);x(this,"publicStorageHandler");x(this,"onUndoAckApplied",t=>{var a,c;const{viewId:e,scenePath:r,requestId:n,emitEventType:i}=t;if(!n)return;const o=this.copyResolveMap.get(n);!o||o.viewId!==e||i===Te.CopyNode&&(this.copyResolveMap.delete(n),o.timer&&clearTimeout(o.timer),(c=(a=this.logger)==null?void 0:a.info)==null||c.call(a,`${Ge} 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)}canAcceptLocalMutation(t){const e=this.control.canAcceptLocalMutation;return typeof e!="function"||e.call(this.control,t)}formatFieldsFromChanges(t){return Ss(t).join("/")||"-"}hasShapeChanges(t){var e,r,n,i;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||((i=t.shape)==null?void 0:i.placement)!==void 0}resolveShapeDispatchToolsTypes(t,e,r,n){if(!this.hasShapeChanges(n))return[];const i=Ss(n).filter(a=>a.startsWith("shape.")),o=[];return r.forEach(a=>{const c=this.lookupToolsType(t,e,a);c&&(!n.toolsType||c===n.toolsType)&&i.some(l=>Oi(c,l))&&!o.includes(c)&&o.push(c)}),o}cancelUndoTicker(t,e,r){var i,o,a;if(!t)return;const n=r||((i=this.control.viewContainerManager)==null?void 0:i.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,i;let e;const r=(o,a)=>{a===t&&e===void 0&&(e=o)};return(i=(n=this.control.internalMsgEmitter)==null?void 0:n.on)==null||i.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()}disposeView(t){var r;for(const[n,i]of this.updateResolveMap)i.viewId===t&&(i.timer&&clearTimeout(i.timer),i.resolve({requestId:"",ok:!1,viewId:t,reason:"busy",selectedIds:i.selectedIds,skippedIds:i.skippedIds.length?i.skippedIds:void 0,warnings:i.warnings.length?i.warnings:void 0,geometryChanged:i.geometryChanged}),this.updateResolveMap.delete(n));for(const[n,i]of this.clearResolveMap)i.viewId===t&&(i.timer&&clearTimeout(i.timer),i.resolve({ok:!1,requestId:"",reason:"busy"}),this.clearResolveMap.delete(n));for(const[n,i]of this.copyResolveMap)i.viewId===t&&(i.timer&&clearTimeout(i.timer),i.resolve({ok:!1,requestId:"",reason:"busy"}),this.copyResolveMap.delete(n));for(const[n,i]of this.deleteResolveMap)i.viewId===t&&(i.timer&&clearTimeout(i.timer),i.resolve({ok:!1,requestId:"",reason:"busy"}),this.deleteResolveMap.delete(n));const e=this.cameraEmitThrottleByView.get(t);(r=e==null?void 0:e.cancel)==null||r.call(e),this.cameraEmitThrottleByView.delete(t),this.clearPendingCameraChange(t),this.lastSelectedIdsByView.delete(t),this.lastViewRectByView.delete(t),this.lastRemoteSelectorByView.delete(t);for(const[n,i]of this.pendingPropertyGeometryByKey)i.viewId===t&&(i.timer&&clearTimeout(i.timer),this.pendingPropertyGeometryByKey.delete(n))}resolveViewId(t){const e=this.control.viewContainerManager;return t||(e==null?void 0:e.focuedViewId)||Fe}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 i=(d=(h=(u=n.displayer)==null?void 0:u.vDom)==null?void 0:h.state)==null?void 0:d.floatBarData,o=(i==null?void 0:i.selectIds)??[],a=i&&ye.isNumber(i.x)&&ye.isNumber(i.y)&&ye.isNumber(i.w)&&ye.isNumber(i.h)?{x:i.x,y:i.y,w:i.w,h:i.h}:void 0,c=n.focusScenePath,l=[];for(const f of o){const g=this.buildSelectedElementInfo(e,c,f,i);g&&l.push(g)}return{viewId:e,scenePath:c,viewRect:a,selectedIds:o,selectedElements:l}}isElementPropertySupported(t,e){return Oi(t,e)}async blurSelector(t){var c,l,u,h,d,f,g,y,S;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,`${Ge} blurSelector rejected: no-view requestId=${e}`),{ok:!1,requestId:e,reason:"no-selection"};if(!this.canAcceptLocalMutation(r))return{ok:!1,requestId:e,reason:"busy"};const n=this.getSelectedElements(r),i=(n==null?void 0:n.selectedIds)??[];if(!i.length)return(h=(u=this.logger)==null?void 0:u.warn)==null||h.call(u,`${Ge} blurSelector rejected: no-selection requestId=${e} viewId=${r}`),{ok:!1,requestId:e,reason:"no-selection"};const o=this.detectSelectorTransforming(r);if(o)return(f=(d=this.logger)==null?void 0:d.warn)==null||f.call(d,`${Ge} blurSelector rejected: ${o} requestId=${e} viewId=${r}`),{ok:!1,requestId:e,reason:o};(y=(g=this.logger)==null?void 0:g.info)==null||y.call(g,`${Ge} blurSelector request requestId=${e} viewId=${r} selectedCount=${i.length}`);const a=(n==null?void 0:n.scenePath)||((S=this.control.viewContainerManager)==null?void 0:S.getCurScenePath(r));return new Promise(b=>{var N,T,p;const I=setTimeout(()=>{var m,v;this.clearResolveMap.has(e)&&(this.clearResolveMap.delete(e),(v=(m=this.logger)==null?void 0:m.warn)==null||v.call(m,`${Ge} blurSelector timeout requestId=${e} viewId=${r}`),b({ok:!1,requestId:e,reason:"busy"}))},5e3);this.clearResolveMap.set(e,{timer:I,resolve:b,viewId:r});try{(N=this.control.worker)==null||N.blurSelector(r,a||"",Le)}catch(m){this.clearResolveMap.delete(e),clearTimeout(I),(p=(T=this.logger)==null?void 0:T.error)==null||p.call(T,`${Ge} blurSelector failed requestId=${e} viewId=${r} err=${m==null?void 0:m.message}`),b({ok:!1,requestId:e,reason:"busy"})}})}async updateSelectedElements(t,e){var b,I,N,T,p,m,v,M,k,E,D,P,z,j;const r=this.genRequestId("update"),n=this.resolveViewId(t),i=e||{};if(!n)return(I=(b=this.logger)==null?void 0:b.warn)==null||I.call(b,`${Ge} updateSelectedElements rejected: no-view requestId=${r}`),{requestId:r,viewId:"",ok:!1,reason:"no-selection"};if(!this.canAcceptLocalMutation(n))return{requestId:r,viewId:n,ok:!1,reason:"busy"};const o=this.getSelectedElements(n),a=(o==null?void 0:o.selectedIds)??[];if(!a.length)return(T=(N=this.logger)==null?void 0:N.warn)==null||T.call(N,`${Ge} 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=(p=this.logger)==null?void 0:p.warn)==null||m.call(p,`${Ge} updateSelectedElements rejected: ${c} requestId=${r} viewId=${n}`),{requestId:r,viewId:n,ok:!1,reason:c,selectedIds:a};if(!Object.keys(i).some(A=>i[A]!==void 0))return(M=(v=this.logger)==null?void 0:v.warn)==null||M.call(v,`${Ge} updateSelectedElements rejected: unsupported-change requestId=${r} viewId=${n}`),{requestId:r,viewId:n,ok:!1,reason:"unsupported-change",selectedIds:a};const u=[],h=[],d=[];let f={...i};for(const A of a){const R=this.lookupToolsType(n,o==null?void 0:o.scenePath,A);if(!R){h.push(A);continue}const L=this.validateStrokeTypeForChanges(A,f,R,u);L.strokeType!==f.strokeType&&(f=L)}if(f.strokeType!==void 0){const A=a.map(L=>this.lookupToolsType(n,o==null?void 0:o.scenePath,L)).filter(L=>!!L&&Oi(L,"strokeType"));A.length>0?f.strokeType===Be.Stroke&&(A.every(W=>W===q.Pencil)||(delete f.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 f.strokeType}if(!this.collectPendingMethods(f).size)return this.flushUpdateSelectedElementsWarnings(n,r,u),(E=(k=this.logger)==null?void 0:k.warn)==null||E.call(k,`${Ge} 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 y=Ss(f);for(const A of a){const R=this.lookupToolsType(n,o==null?void 0:o.scenePath,A),L=this.hasShapeChanges(f)&&!!f.toolsType&&R!==f.toolsType;this.hasApplicableChangesForToolsType(f,R)?d.push(A):h.includes(A)||(h.push(A),R&&y.length&&u.push({id:A,field:y.join(","),code:"unsupported-by-toolsType",toolsType:R,message:L?`selected element id=${A} toolsType=${R} skipped by requested toolsType=${f.toolsType}`:`selected element id=${A} toolsType=${R} does not support requested fields=[${y.join(",")}]`}))}const S=this.resolveShapeDispatchToolsTypes(n,o==null?void 0:o.scenePath,d,f);return d.length?((j=(z=this.logger)==null?void 0:z.info)==null||j.call(z,`${Ge} updateSelectedElements request requestId=${r} viewId=${n} scenePath=${(o==null?void 0:o.scenePath)||"-"} selectedCount=${a.length} fields=[${this.formatFieldsFromChanges(i)}]`),this.flushUpdateSelectedElementsWarnings(n,r,u),new Promise(A=>{var W,Y;const R=setTimeout(()=>{var ie,O;const H=this.updateResolveMap.get(r);H&&(this.updateResolveMap.delete(r),(O=(ie=this.logger)==null?void 0:ie.warn)==null||O.call(ie,`${Ge} updateSelectedElements timeout requestId=${r} viewId=${n}`),A({requestId:r,viewId:n,ok:!1,reason:"worker-failed",selectedIds:H.selectedIds,skippedIds:H.skippedIds.length?H.skippedIds:void 0,warnings:H.warnings.length?H.warnings:void 0,geometryChanged:H.geometryChanged}))},8e3);this.updateResolveMap.set(r,{timer:R,resolve:A,viewId:n,selectedIds:a,appliedIds:d,skippedIds:h,warnings:u,geometryChanged:!1});const L=this.captureUndoTickerDuringDispatch(n);try{this.dispatchUpdate(n,[Le],f,r,S)}catch(H){this.updateResolveMap.delete(r),clearTimeout(R),this.cancelUndoTicker(this.resolveCancelableUndoTickerId(L.getUndoTickerId(),n),n,o==null?void 0:o.scenePath),(Y=(W=this.logger)==null?void 0:W.error)==null||Y.call(W,`${Ge} updateSelectedElements dispatch failed requestId=${r} viewId=${n} err=${H==null?void 0:H.message}`),A({requestId:r,viewId:n,ok:!1,reason:"worker-failed",selectedIds:a,skippedIds:h.length?h:void 0,warnings:u.length?u:void 0})}finally{L.dispose()}})):(this.flushUpdateSelectedElementsWarnings(n,r,u),(P=(D=this.logger)==null?void 0:D.warn)==null||P.call(D,`${Ge} 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,f,g;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,`${Ge} copySelectedElements rejected: no-view requestId=${e}`),{ok:!1,requestId:e,reason:"no-selection"};if(!this.canAcceptLocalMutation(r))return{ok:!1,requestId:e,reason:"busy"};const n=this.getSelectedElements(r),i=(n==null?void 0:n.selectedIds)??[];if(!i.length)return(u=(l=this.logger)==null?void 0:l.warn)==null||u.call(l,`${Ge} 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,`${Ge} copySelectedElements rejected: ${o} requestId=${e} viewId=${r}`),{ok:!1,requestId:e,reason:o}):((g=(f=this.logger)==null?void 0:f.info)==null||g.call(f,`${Ge} copySelectedElements request requestId=${e} viewId=${r} scenePath=${(n==null?void 0:n.scenePath)||"-"} selectedCount=${i.length}`),new Promise(y=>{var I,N;const S=setTimeout(()=>{var T,p;this.copyResolveMap.has(e)&&(this.copyResolveMap.delete(e),(p=(T=this.logger)==null?void 0:T.warn)==null||p.call(T,`${Ge} copySelectedElements timeout requestId=${e} viewId=${r}`),y({ok:!1,requestId:e,reason:"busy"}))},5e3);this.copyResolveMap.set(e,{timer:S,resolve:y,viewId:r,sourceSelectedIds:i});const b=this.captureUndoTickerDuringDispatch(r);try{Ve.emitMethod(We.MainEngine,Te.CopyNode,{workIds:[Le],viewId:r,requestId:e})}catch(T){this.copyResolveMap.delete(e),clearTimeout(S),this.cancelUndoTicker(this.resolveCancelableUndoTickerId(b.getUndoTickerId(),r),r,n==null?void 0:n.scenePath),(N=(I=this.logger)==null?void 0:I.error)==null||N.call(I,`${Ge} copySelectedElements failed requestId=${e} viewId=${r} err=${T==null?void 0:T.message}`),y({ok:!1,requestId:e,reason:"busy"})}finally{b.dispose()}}))}async deleteSelectedElements(t){var a,c,l,u,h,d,f,g;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,`${Ge} deleteSelectedElements rejected: no-view requestId=${e}`),{ok:!1,requestId:e,reason:"no-selection"};if(!this.canAcceptLocalMutation(r))return{ok:!1,requestId:e,reason:"busy"};const n=this.getSelectedElements(r),i=(n==null?void 0:n.selectedIds)??[];if(!i.length)return(u=(l=this.logger)==null?void 0:l.warn)==null||u.call(l,`${Ge} 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,`${Ge} deleteSelectedElements rejected: ${o} requestId=${e} viewId=${r}`),{ok:!1,requestId:e,reason:o}):((g=(f=this.logger)==null?void 0:f.info)==null||g.call(f,`${Ge} deleteSelectedElements request requestId=${e} viewId=${r} scenePath=${(n==null?void 0:n.scenePath)||"-"} selectedCount=${i.length}`),new Promise(y=>{var I,N;const S=setTimeout(()=>{var T,p;this.deleteResolveMap.has(e)&&(this.deleteResolveMap.delete(e),(p=(T=this.logger)==null?void 0:T.warn)==null||p.call(T,`${Ge} deleteSelectedElements timeout requestId=${e} viewId=${r}`),y({ok:!1,requestId:e,reason:"busy"}))},5e3);this.deleteResolveMap.set(e,{timer:S,resolve:y,viewId:r,removedIds:i.slice()});const b=this.captureUndoTickerDuringDispatch(r);try{Ve.emitMethod(We.MainEngine,Te.DeleteNode,{workIds:[Le],viewId:r,requestId:e})}catch(T){this.deleteResolveMap.delete(e),clearTimeout(S),this.cancelUndoTicker(this.resolveCancelableUndoTickerId(b.getUndoTickerId(),r),r,n==null?void 0:n.scenePath),(N=(I=this.logger)==null?void 0:I.error)==null||N.call(I,`${Ge} deleteSelectedElements failed requestId=${e} viewId=${r} err=${T==null?void 0:T.message}`),y({ok:!1,requestId:e,reason:"busy"})}finally{b.dispose()}}))}async updateElement(t,e,r,n,i=!0){var g,y,S,b,I,N,T,p,m,v,M,k,E;if(!this.canAcceptLocalMutation(r))return!1;const o=this.control.collector,a=this.control.worker;if(!o||!a||!t||!e||!r||!n)return(y=(g=this.logger)==null?void 0:g.warn)==null||y.call(g,`${Ge} updateElement ignored: invalid-args viewId=${r||"-"} scenePath=${e||"-"} elementId=${t||"-"}`),!1;const c=(S=o.isLocalId)!=null&&S.call(o,t)&&typeof o.transformKey=="function"?o.transformKey(t):t;if((b=o.isSelector)!=null&&b.call(o,c))return(N=(I=this.logger)==null?void 0:I.warn)==null||N.call(I,`${Ge} updateElement ignored: selector-not-allowed viewId=${r} scenePath=${e}`),!1;let l=(m=(p=(T=o.storage)==null?void 0:T[r])==null?void 0:p[e])==null?void 0:m[c];if(!l)return(M=(v=this.logger)==null?void 0:v.warn)==null||M.call(v,`${Ge} updateElement ignored: not-found viewId=${r} scenePath=${e} elementId=${t}`),!1;const u=l.toolsType;if(!u||n.toolsType!==u)return(E=(k=this.logger)==null?void 0:k.warn)==null||E.call(k,`${Ge} 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),f=a.now;return i&&(a.internalMsgEmitter.emit("addUndoTicker",f,r,{render:!0,storage:!0,source:$e.AsyncUpdateElement}),a.internalMsgEmitter.emit("finalizeRequested",f,r,[c],e)),await new Promise(D=>{Dr(()=>{var z,j;if(!this.canAcceptLocalMutation(r)){i&&this.cancelUndoTicker(f,r,e),D(!1);return}const P=o.plugin;P==null||P.updateAttributes([Jr.namespace,r,e,c],d),i&&(a.internalMsgEmitter.emit("ackRenderUndoTicker",f,r,e),a.internalMsgEmitter.emit("ackStorageUndoTicker",f,r,e,c)),D(!0),(j=(z=this.logger)==null?void 0:z.info)==null||j.call(z,`${Ge} updateElement notify viewId=${r} scenePath=${e} elementId=${t} toolsType=${u} fields=[${Ss(h).join("/")||"-"}]`)},0,this.control.hasPolyfillMethod("requestIdleCallback")).catch(P=>{var z,j;this.cancelUndoTicker(f,r,e),(j=(z=this.logger)==null?void 0:z.warn)==null||j.call(z,`${Ge} updateElement err: ${P.message??"has unknown error"} viewId=${r} scenePath=${e} elementId=${t}`),D(!1)})})}onSelectorTransform(t){var a,c;const{viewId:e,emitEventType:r,workState:n}=t;this.control.publicMsgEmitter.emit("selectorTransformChange",t);const i=`${Ge} selectorTransformChange viewId=${e} emitEventType=${r} workState=${n}`,o=this.getDebounceLogger();o!=null&&o.infoDebounced?o.infoDebounced(`selector-transform-change:${e}`,i):(c=(a=this.logger)==null?void 0:a.info)==null||c.call(a,i)}onSelectorSync(t){var y,S,b,I;const{viewId:e,scenePath:r,selectIds:n,selectRect:i,selectorInfo:o}=t,a=n&&n.slice().sort()||[],c=this.lastSelectedIdsByView.get(e)||[],l=!this.isArrayEqual(a,c),u=i&&ye.isNumber(i.x)&&ye.isNumber(i.y)&&ye.isNumber(i.w)&&ye.isNumber(i.h)?{x:i.x,y:i.y,w:i.w,h:i.h}:void 0,d=!!this.pendingCameraChangeByView.get(e)&&!l&&!!(n!=null&&n.length);if(l){const N=this.getSelectedElements(e),T={viewId:e,scenePath:r,selectorId:Le,reason:n!=null&&n.length?"select":"clear",viewRect:u,selectedIds:(N==null?void 0:N.selectedIds)??n??[],selectorInfo:o};this.lastSelectedIdsByView.set(e,a),this.control.publicMsgEmitter.emit("selectedElementsChange",T);const p=`${Ge} selectedElementsChange reason=${T.reason} viewId=${e} count=${T.selectedIds.length}`,m=this.getDebounceLogger();m!=null&&m.infoDebounced?m.infoDebounced(`selected-elements-change:${e}`,p):(S=(y=this.logger)==null?void 0:y.info)==null||S.call(y,p)}const f=this.lastViewRectByView.get(e),g=!this.isRectEqual(f,u);if(g||l){let N="selector-action",T=n!=null&&n.length?"select":"clear";d&&g?(N="camera-change",T="cameraTransform"):g&&!l&&(n!=null&&n.length)&&(T="selectorTransform"),this.lastViewRectByView.set(e,u);const p={viewId:e,scenePath:r,selectorId:Le,source:N,action:T,viewRect:u};this.control.publicMsgEmitter.emit("selectorGeometryChange",p),this.logGeometry(e,T,(n==null?void 0:n.length)||0),N==="camera-change"&&this.clearPendingCameraChange(e)}if(!(n!=null&&n.length)&&l)for(const[N,T]of this.clearResolveMap.entries())T.viewId===e&&(this.clearResolveMap.delete(N),T.timer&&clearTimeout(T.timer),(I=(b=this.logger)==null?void 0:b.info)==null||I.call(b,`${Ge} blurSelector done requestId=${N} viewId=${e}`),T.resolve({ok:!0,requestId:N}))}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:Le,reason:"clear",viewRect:void 0,selectedIds:[]};this.lastSelectedIdsByView.set(e,[]),this.control.publicMsgEmitter.emit("selectedElementsChange",h);const d=`${Ge} selectedElementsChange reason=clear viewId=${e} requestId=${n||"-"}`,f=this.logger;f!=null&&f.infoDebounced?f.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:Le,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,`${Ge} 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=ye.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:Le,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 i=this.updateResolveMap.get(e);!i||i.viewId!==t||(i.geometryChanged=i.geometryChanged||n,this.updateResolveMap.delete(e),i.timer&&clearTimeout(i.timer),(a=(o=this.logger)==null?void 0:o.info)==null||a.call(o,`${Ge} updateSelectedElements done requestId=${e} viewId=${t} type=${r} geometryChanged=${i.geometryChanged} applied=${i.appliedIds.length}`),i.resolve({requestId:e,viewId:t,ok:!0,selectedIds:i.selectedIds,appliedIds:i.appliedIds,skippedIds:i.skippedIds.length?i.skippedIds:void 0,warnings:i.warnings.length?i.warnings:void 0,geometryChanged:i.geometryChanged}))}onRemoveNodeApplied(t){var i,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=(i=this.logger)==null?void 0:i.info)==null||o.call(i,`${Ge} deleteSelectedElements done requestId=${r} viewId=${e} removedCount=${c.length}`),a.resolve({ok:!0,requestId:r,removedIds:c});return}}}onSyncStorageChange(t){var n,i,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[f,g]of Object.entries(d)){if(((n=e.isLocalId)!=null&&n.call(e,f)?f:((i=e.getLocalId)==null?void 0:i.call(e,f))??f)!==Le)continue;const S=((o=e.getUidFromKey)==null?void 0:o.call(e,f))??(f.split(Bt)[0]||"");!S||S===r||(u.add(S),this.handleRemoteSelectorState(a,h,S,f,g,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}${Bt}${Le}`,void 0,l)}}}handleRemoteSelectorState(t,e,r,n,i,o){var g;const a=o.get(r)||{selectedIds:[]};let c="update",l=[],u;if(i){const y=i,S=(y.selectIds||[]).slice().sort(),b=a.selectedIds,I=!this.isArrayEqual(S,b);!b.length&&S.length?c="select":I&&!S.length?c="clear":c=I?"select":"update",l=y.selectIds||[];const N=y.selectRect||y.rect||((g=y.updateNodeOpt)==null?void 0:g.rect);N&&ye.isNumber(N.x)&&ye.isNumber(N.y)&&ye.isNumber(N.w)&&ye.isNumber(N.h)&&(u={x:N.x,y:N.y,w:N.w,h:N.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 f={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",f),this.logRemoteSelector(t,r,c,l.length)}logRemoteSelector(t,e,r,n){var a,c;const i=`${Ge} remoteSelectorChange uid=${e} action=${r} viewId=${t} count=${n}`,o=this.getDebounceLogger();if(o!=null&&o.infoDebounced){o.infoDebounced(`remote-selector:${t}@${e}`,i);return}(c=(a=this.logger)==null?void 0:a.info)==null||c.call(a,i)}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,f;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,i=(u=e.currentLocalWorkData)==null?void 0:u.workState,o=(f=(d=(h=this.control.viewContainerManager.getView(t))==null?void 0:h.displayer)==null?void 0:d.vDom)==null?void 0:f.state,a=o==null?void 0:o.operationType,c=a===Te.TranslateNode||a===Te.ScaleNode||a===Te.RotateNode||a===Te.SetPoint;return n&&c&&i&&i!==de.Pending&&i!==de.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:i}=t,o=e===Te.SetFontStyle&&i.fontSize!==void 0||e===Te.SetColorNode&&i.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}`,i=this.pendingPropertyGeometryByKey.get(n);i!=null&&i.timer&&clearTimeout(i.timer);const o=setTimeout(()=>{this.pendingPropertyGeometryByKey.delete(n);const a=this.getSelectedElements(t);if(!a||!a.selectedIds.length)return;const c=e===Te.SetFontStyle?"setFontStyle":"setStyle",l={viewId:t,scenePath:a.scenePath,selectorId:Le,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 i=(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[i];return o==null?void 0:o.toolsType}validateStrokeTypeForChanges(t,e,r,n){return e.strokeType===void 0?e:C0(e.strokeType)?(Ap(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,i=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=i.get(u.field)||[];h.push(u.id),i.set(u.field,h)}for(const[u,h]of n.entries()){const d=[...new Set(h.toolsTypes.filter(Boolean))].join(","),f=[...new Set(h.ids)].join(",");(a=(o=this.logger)==null?void 0:o.warn)==null||a.call(o,`${Ge} updateSelectedElements warn unsupported-by-toolsType requestId=${e} viewId=${t} field=${u} toolsTypes=[${d}] ids=[${f}]`)}for(const[u,h]of i.entries())(l=(c=this.logger)==null?void 0:c.warn)==null||l.call(c,`${Ge} updateSelectedElements warn unsupported-value requestId=${e} viewId=${t} field=${u} ids=[${[...new Set(h)].join(",")}]`)}collectPendingMethods(t){var r,n,i,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(Te.SetColorNode),(t.fontSize!==void 0||t.bold!==void 0||t.italic!==void 0||t.underline!==void 0||t.lineThrough!==void 0)&&e.add(Te.SetFontStyle),t.isLocked!==void 0&&e.add(Te.SetLock),t.zIndexLayer!==void 0&&e.add(Te.ZIndexNode),(((r=t.shape)==null?void 0:r.vertices)!==void 0||((n=t.shape)==null?void 0:n.innerVerticeStep)!==void 0||((i=t.shape)==null?void 0:i.innerRatio)!==void 0||((o=t.shape)==null?void 0:o.placement)!==void 0)&&e.add(Te.SetShapeOpt),e}hasApplicableChangesForToolsType(t,e){return e?Ss(t).some(r=>r.startsWith("shape.")&&t.toolsType&&e!==t.toolsType?!1:Oi(e,r)):!1}buildUpdatedElementValue(t,e){var o,a,c,l;const r=e,n={...t,opt:t.opt?{...t.opt}:void 0},i=n.opt||{};return r.strokeColor!==void 0&&(i.strokeColor=r.strokeColor),r.fillColor!==void 0&&(i.fillColor=r.fillColor),r.thickness!==void 0&&(i.thickness=r.thickness),r.strokeType!==void 0&&(i.strokeType=r.strokeType),r.fontColor!==void 0&&(i.fontColor=r.fontColor),r.fontBgColor!==void 0&&(i.fontBgColor=r.fontBgColor),r.fontSize!==void 0&&(i.fontSize=r.fontSize),r.bold!==void 0&&(i.bold=r.bold),r.italic!==void 0&&(i.italic=r.italic),r.underline!==void 0&&(i.underline=r.underline),r.lineThrough!==void 0&&(i.lineThrough=r.lineThrough),r.isLocked!==void 0&&(i.locked=r.isLocked),((o=r.shape)==null?void 0:o.vertices)!==void 0&&(i.vertices=r.shape.vertices),((a=r.shape)==null?void 0:a.innerVerticeStep)!==void 0&&(i.innerVerticeStep=r.shape.innerVerticeStep),((c=r.shape)==null?void 0:c.innerRatio)!==void 0&&(i.innerRatio=r.shape.innerRatio),((l=r.shape)==null?void 0:l.placement)!==void 0&&(i.placement=r.shape.placement),n.opt=i,r.zIndexLayer!==void 0&&(n.updateNodeOpt={...n.updateNodeOpt||{},zIndexLayer:r.zIndexLayer}),n}normalizeUpdateElementInfo(t,e){var d,f;const r={...t},n=[],i=g=>{var y,S;g in r&&(delete r[g],n.push(g),(S=(y=this.logger)==null?void 0:y.warn)==null||S.call(y,`${Ge} updateElement warn unsupported-by-toolsType toolsType=${e} field=${g}`))},o=g=>{var y,S;r.shape&&g in r.shape&&(delete r.shape[g],n.push(`shape.${g}`),(S=(y=this.logger)==null?void 0:y.warn)==null||S.call(y,`${Ge} updateElement warn unsupported-by-toolsType toolsType=${e} field=shape.${g}`)),r.shape&&!Object.keys(r.shape).length&&delete r.shape},a=g=>{var y,S;g in r&&(n.push(g),(S=(y=this.logger)==null?void 0:y.warn)==null||S.call(y,`${Ge} updateElement warn invalid-format toolsType=${e} field=${g} value=${JSON.stringify(r[g])}`),delete r[g])},c=g=>{var y,S;!r.shape||!(g in r.shape)||(n.push(`shape.${g}`),(S=(y=this.logger)==null?void 0:y.warn)==null||S.call(y,`${Ge} updateElement warn invalid-format toolsType=${e} field=shape.${g} value=${JSON.stringify(r.shape[g])}`),delete r.shape[g],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(Be).includes(r.strokeType)&&a("strokeType"),"strokeType"in r&&r.strokeType!==void 0&&!Ap(e,r.strokeType)&&i("strokeType"),"bold"in r&&!Hwe.includes(r.bold)&&a("bold"),"italic"in r&&!Qwe.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&&![Cn.Top,Cn.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&&!qwe.includes(r.shape.placement)&&c("placement"));const l=new Set(Nye(e));return["strokeColor","fillColor","thickness","strokeType","fontColor","fontBgColor","fontSize","bold","italic","underline","lineThrough","isLocked","zIndexLayer"].forEach(g=>{l.has(g)||i(g)}),["vertices","innerVerticeStep","innerRatio","placement"].forEach(g=>{l.has(`shape.${g}`)||o(g)}),n.length&&((f=(d=this.logger)==null?void 0:d.info)==null||f.call(d,`${Ge} updateElement filtered toolsType=${e} dropped=[${n.join(",")}]`)),r}dispatchUpdate(t,e,r,n,i=[]){const o=We.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&&Ve.emitMethod(o,Te.SetColorNode,{workIds:e,viewId:t,requestId:n,workState:de.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&&Ve.emitMethod(o,Te.SetFontStyle,{workIds:e,viewId:t,requestId:n,workState:de.Done,...c}),r.isLocked!==void 0&&Ve.emitMethod(o,Te.SetLock,{workIds:e,viewId:t,requestId:n,workState:de.Done,isLocked:r.isLocked}),r.zIndexLayer!==void 0&&Ve.emitMethod(o,Te.ZIndexNode,{workIds:e,viewId:t,requestId:n,workState:de.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(!i.length)return;i.forEach(u=>{Ve.emitMethod(o,Te.SetShapeOpt,{workIds:e,viewId:t,toolsType:u,requestId:n,workState:de.Done,...l})})}}}buildSelectedElementInfo(t,e,r,n){var y,S,b;const i=this.control.collector,o=i&&i.isLocalId(r)?i.transformKey(r):r,a=(b=(S=(y=i==null?void 0:i.storage)==null?void 0:y[t])==null?void 0:S[e||""])==null?void 0:b[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&&(ye.isBoolean(n.canRotate)&&(d.canRotate=n.canRotate),ye.isBoolean(n.canLock)&&(d.canLock=n.canLock),n.scaleType&&(d.scaleType=n.scaleType),ye.isBoolean(n.isLocked)&&(d.isLocked=n.isLocked)),c===q.Text&&l){const I=l,N={text:I.text,fontSize:I.fontSize,fontFamily:I.fontFamily,bold:I.bold,italic:I.italic,underline:I.underline,lineThrough:I.lineThrough,textAlign:I.textAlign,verticalAlign:I.verticalAlign,boxPoint:I.boxPoint,boxSize:I.boxSize};d.text=N}if(c===q.Polygon){const I=l;d.shape={vertices:I.vertices}}else if(c===q.Star){const I=l;d.shape={vertices:I.vertices,innerVerticeStep:I.innerVerticeStep,innerRatio:I.innerRatio}}else if(c===q.SpeechBalloon){const I=l;d.shape={placement:I.placement}}const f=u.rect;f&&(d.rect={x:f.x,y:f.y,w:f.w,h:f.h});const g=u.centerPos;return g&&(d.centerPos=g),d}buildRemoteSelectedElements(t,e,r,n){if(!n.length)return[];const i=[];for(const o of n){const a=this.buildSelectedElementInfo(t,e,`${r}${Bt}${o}`,void 0);a&&(a.id=o,i.push(a))}return i}logGeometry(t,e,r){var a,c;const n=`${Ge} selectorGeometryChange action=${e} viewId=${t} count=${r}`,i=this.getDebounceLogger();if((e==="select"||e==="selectorTransform"||e==="cameraTransform")&&i!=null&&i.infoDebounced){i.infoDebounced(`selector-geometry:${t}:${e}`,n);return}(c=(a=this.logger)==null?void 0:a.info)==null||c.call(a,n)}}async function Kwe({previousScenePath:s,attemptedScenePath:t,getCurrentScenePath:e,getTargetScenePath:r,yieldToNextTask:n=()=>new Promise(i=>window.setTimeout(i,0))}){const i=e(),o=r();if(i===o)return!1;if(i!==s||o!==t)return!0;await n();const a=e(),c=r();return a===c?!1:a!==s||c!==t}const cr=class cr{constructor(t){x(this,"backgroundImageLoadCoordinator");x(this,"toolChangePending",!1);x(this,"toolChangePendingTimer");x(this,"pendingSceneChecks",new Set);x(this,"pendingSceneChanges",new Map);x(this,"pendingClears",new Map);x(this,"pendingViewInitStates",new Map);x(this,"renderRuntimeCacheKey");x(this,"renderRuntimeBuildMarker",Spe);x(this,"renderRuntimeActivationPromise");x(this,"pendingViewInitQueue",Promise.resolve());x(this,"clearQueueByView",new Map);x(this,"viewOperationQueueByView",new Map);x(this,"forceDoneQueue",Promise.resolve());x(this,"forceDoneQueueByView",new Map);x(this,"localMutationFenceCount",0);x(this,"localMutationFenceByView",new Map);x(this,"roomLifecycleTerminal",!1);x(this,"destroyPromise");x(this,"isDestroying",!1);x(this,"isDestroyed",!1);x(this,"orphanRepairTimer");x(this,"lifecycleGeneration",0);x(this,"viewLifecycleGeneration",new Map);x(this,"version",Dc);x(this,"plugin");x(this,"logger");x(this,"syncLogger");x(this,"room");x(this,"play");x(this,"collector");x(this,"hasSwitchToSelectorEffect");x(this,"snapshootStateMap");x(this,"_disableDeviceInputs");x(this,"_disableEraseImage");x(this,"_disableEraseText");x(this,"_disableCameraTransform");x(this,"initFontFaceTextRenderGate",!1);x(this,"initFontFaceTextRenderSkipped",!1);x(this,"mainViewMountedReady",new H0);x(this,"effectResolve");x(this,"hotkeyManager");x(this,"pluginOptions");x(this,"renderMode");x(this,"renderRuntimeDecisionLocked",!1);x(this,"renderingCompatibilityDecision");x(this,"roomMember");x(this,"cursor");x(this,"textEditorManager");x(this,"worker");x(this,"renderControl");x(this,"miniMapManager");x(this,"pluginManager");x(this,"callbacks");x(this,"selectorApi");x(this,"_isPolyfill",{requestIdleCallback:!1,cancelIdleCallback:!1});x(this,"onSceneChange",(t,e)=>{var a,c,l,u,h;if(this.isDestroying||this.isDestroyed)return Promise.resolve();const r=typeof t=="string"&&t.trim()?t:void 0,n=r||this.viewContainerManager.getAuthoritativeScenePath(e);if(!e||!n)return(c=(a=this.logger).warn)==null||c.call(a,`[Appliance]: [scene-path] stage=dropped-empty viewId=${e||""}`),Promise.resolve();if(r||this.logger.info(`[Appliance]: [scene-path] stage=authoritative-fallback viewId=${e} scenePath=${n}`),!this.worker.isViewInitAck(e)||!this.worker.isServiceSyncReady(e))return this.queuePendingInitScenePath(e,n),this.logger.info(`[Appliance]: [scene-path] stage=queued-before-ready viewId=${e} scenePath=${n}`),Promise.resolve();let i=this.pendingSceneChanges.get(e);i?(i.targetScenePath=n,i.isSceneBusy=!0,(l=i.deferredCamera)!=null&&l.scenePath&&i.deferredCamera.scenePath!==n&&(i.deferredCamera=void 0)):(i={targetScenePath:n,isSceneBusy:!0,running:!1,releaseMutationFence:this.acquireLocalMutationFence([e]),waiters:new Set},this.pendingSceneChanges.set(e,i)),this.worker.cameraUpdateDestroy(e),(h=(u=this.viewContainerManager.getView(e))==null?void 0:u.displayer)==null||h.setActive(!1);const o=new Promise(d=>{i==null||i.waiters.add(d)});return i.running||(i.running=!0,this.consumePendingSceneChanges(e,i).catch(d=>{var f,g;(g=(f=this.logger)==null?void 0:f.error)==null||g.call(f,`[Appliance]: scene change failed viewId=${e} scenePath=${(i==null?void 0:i.targetScenePath)||""} error=${(d==null?void 0:d.message)||d}`)})),o});x(this,"onRoomMembersChange",t=>{this.isDestroying||this.isDestroyed||(this.roomMember.setRoomMembers(oa(t)),this.scheduleOrphanRepair())});x(this,"onMemberChange",ye.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===q.Selector&&e!==q.Selector&&this.worker.blurCursor(n);const i=this.getToolsOpt(e,t);this.worker.setCurrentToolsData(i),(a=this.pluginManager)==null||a.dispatchPluginEvent("setToolkey",e),this.effectViewContainer(e),this.effectResolve&&this.effectResolve(!0)},100,{leading:!1}));x(this,"internalSceneChange",(t,e)=>{var r,n,i,o;if(!this.worker.isViewInitAck(t)||!this.worker.isServiceSyncReady(t)){this.queuePendingInitScenePath(t,e);return}this.isUseSimple||((r=this.miniMapManager)==null?void 0:r.activeViewId)===t&&((n=this.miniMapManager)==null||n.destroyMiniMap(t)),(i=this.pluginManager)==null||i.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})})});x(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 S,b,I;const{displayer:e,plugin:r,options:n,callbacks:i}=t;this.plugin=r,this.callbacks=i,this.room=ze(e)?e:void 0,this.play=ih(e)?e:void 0;let o;this.room&&(o=(S=this.room)==null?void 0:S.logger,this._disableDeviceInputs=this.room.disableDeviceInputs,this._disableEraseImage=this.room.disableEraseImage,this._disableEraseText=!1);const a=pMe(n.cdn,n.extras.useSimple),c=Ts(He.workerRenderModeBlacklist,n.extras.workerRenderModeBlacklist,"renderMode"),l=Ts(He.workerCanvasContextBlacklist,n.extras.workerCanvasContextBlacklist,"canvasContext"),u=Ts(He.workerMaskTextureFormatBlacklist,n.extras.workerMaskTextureFormatBlacklist,"maskTextureFormat"),h=Ts(He.workerMaskTextureUploadBlacklist,n.extras.workerMaskTextureUploadBlacklist,"maskTextureUpload"),d=Ts(He.fontFaceFallbackBlacklist,n.extras.fontFaceFallbackBlacklist,"fontFaceFallback"),f=typeof navigator>"u"?"":navigator.userAgent;this.renderRuntimeCacheKey=Fwe(f),this.renderingCompatibilityDecision=EMe({useWorker:n.extras.useWorker,allowImageBitmapFallback:n.extras.allowImageBitmapFallback,useSimple:n.extras.useSimple,requestedContextType:(b=n.extras.canvasOpt)==null?void 0:b.contextType,workerRenderModeBlacklist:c,workerCanvasContextBlacklist:l,workerMaskTextureFormatBlacklist:u,workerMaskTextureUploadBlacklist:h,workerUrl:a}),this.pluginOptions={...n,extras:{...n.extras,canvasOpt:n.extras.canvasOpt,workerRenderModeBlacklist:c,workerCanvasContextBlacklist:l,workerMaskTextureFormatBlacklist:u,workerMaskTextureUploadBlacklist:h,fontFaceFallbackBlacklist:d}},this.backgroundImageLoadCoordinator=new hpe(this.pluginOptions.extras.backgroundImageLoadOptions,(I=this.callbacks)==null?void 0:I.onBackgroundImageLoadEvent),this.renderMode=this.renderingCompatibilityDecision.renderMode,this.renderingCompatibilityDecision.renderRuntimeSource="config",this.roomMember=new K0e;const g={control:this,internalMsgEmitter:cr.InternalMsgEmitter,publicMsgEmitter:cr.PublicMsgEmitter};this.cursor=new X0e(g),this.textEditorManager=new Iye(g),this.worker=new Lwe(g),this.hotkeyManager=new Nwe(g),this.renderControl=new Ywe(g),this.pluginManager=new cm.PluginManager(g),this.isUseSimple||(this.miniMapManager=new Gwe(g)),this.logger=new Xs(o);const y=this.pluginOptions.extras.syncLogger.batchWindowMs??He.syncLogger.batchWindowMs;this.syncLogger=new zwe(this.logger,y>0?y:He.syncLogger.batchWindowMs)}get publicMsgEmitter(){return cr.PublicMsgEmitter}get internalMsgEmitter(){return cr.InternalMsgEmitter}emitInitLoadingChange(t){var e,r,n,i;try{(r=(e=this.callbacks)==null?void 0:e.onInitLoadingChange)==null||r.call(e,t)}catch(o){(i=(n=this.logger)==null?void 0:n.error)==null||i.call(n,`[Appliance]: onInitLoadingChange error: ${(o==null?void 0:o.message)||o}`)}}notifyMainViewMounted(){this.mainViewMountedReady.markReady()}isMainViewMounted(){var t;return((t=this.mainViewMountedReady)==null?void 0:t.isReady())??!0}waitForMainViewMounted(t){var e;return((e=this.mainViewMountedReady)==null?void 0:e.wait(t))??Promise.resolve("ready")}isRenderRuntimeRecoveryAllowed(){return!this.isDestroying&&!this.isDestroyed&&!this.roomLifecycleTerminal}appendPendingViewInitTask(t){this.pendingViewInitQueue||(this.pendingViewInitQueue=Promise.resolve());const e=this.pendingViewInitQueue.catch(()=>{}).then(t);return this.pendingViewInitQueue=e.then(()=>{},()=>{}),e}queuePendingRuntimeReset(t){return this.appendPendingViewInitTask(t)}queuePendingViewInit(t,e,r=this.getViewLifecycleGeneration(t)){const n=()=>this.appendPendingViewInitTask(async()=>{this.isPendingViewInitCurrent(t,r)&&await e()});return t===Fe||this.isMainViewMounted()?n():this.waitForMainViewMounted().then(i=>{if(!(i!=="ready"||!this.isPendingViewInitCurrent(t,r)))return n()})}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(){if(!this.hasExtendFontFaces)return;this.beginInitFontFaceTextRenderGate();const t=this.lifecycleGeneration;setTimeout(()=>{if(this.isDestroying||this.isDestroyed||this.lifecycleGeneration!==t){this.endInitFontFaceTextRenderGate();return}this.loadFontFaces().then(e=>{if(this.isDestroying||this.isDestroyed||this.lifecycleGeneration!==t)return;const r=this.hasInitFontFaceTextRenderSkipped();if(e.status==="success"&&(!this.worker.getLastFontFacesAlreadyReady()||r)||e.status!=="success"&&r&&SMe(this.pluginOptions.extras.fontFaceFallbackBlacklist))return this.refreshTextRender()}).catch(e=>{var r,n;(n=(r=this.logger)==null?void 0:r.error)==null||n.call(r,`[Appliance]: init font face load and render failed: ${(e==null?void 0:e.message)||e}`)}).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 i;const r=`.editor-box #${this.escapeCssIdentifier(e)}`,n=[];t.container&&n.push(t.container),(i=t.viewData)!=null&&i.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]&&!ye.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!==q.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:xe.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:i,tasks:o}=this.measureViewTextEditorsForRender(t);return i&&(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 i=await this.refreshViewTextRenderInternal(t);return e&&this.emitFontFaceRenderState({status:i.status==="success"?"success":"error"}),i}catch(i){return(n=(r=this.logger)==null?void 0:r.error)==null||n.call(r,`[Appliance]: refreshViewTextRender failed: ${(i==null?void 0:i.message)||i}`),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),i=(n==null?void 0:n.focusScenePath)||this.viewContainerManager.getAuthoritativeScenePath(t);return i?n!=null&&n.focusScenePath?(await this.worker.clearViewScenePath(t,!0),this.worker.pullServiceData(t,i,{isAsync:!0,useAnimation:!1}),await this.viewContainerManager.updateTextEditorInfoAsync(t,this.textEditorManager.activeId),await this.waitNextFrame(),{status:"success"}):(await this.onSceneChange(i,t),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)}onViewServiceReady(t){const e=this.viewContainerManager.getView(t);e&&e.displayer.setActive(this.canAcceptLocalMutation(t))}lockRenderRuntimeDecision(){this.renderRuntimeDecisionLocked=!0}isRenderRuntimeDecisionLocked(){return this.renderRuntimeDecisionLocked}ensureRenderRuntimeReady(){return this.worker.isActive?Promise.resolve():(this.renderRuntimeActivationPromise||(this.renderRuntimeActivationPromise=this.activeWorker().catch(t=>{throw this.renderRuntimeActivationPromise=void 0,t})),this.renderRuntimeActivationPromise)}getRenderContextTypeForView(t){var e,r;return((r=(e=this.viewContainerManager)==null?void 0:e.mainView)==null?void 0:r.id)===t?this.renderingCompatibilityDecision.contextType:"2d"}requiresCanvas2DCompanionRenderProbe(){return!1}async restoreCachedRenderRuntimeDecision(){if(this.pluginOptions.extras.useWorker!=="auto")return;const t=await Wwe(this.renderRuntimeCacheKey),e=t.renderModel;let r;const n=e?gMe(e):void 0;if(n){const i=this.renderingCompatibilityDecision;if(n.renderMode==="worker-image-bitmap"&&this.pluginOptions.extras.allowImageBitmapFallback===!1){this.applyRuntimeRenderingDecision("main-thread","2d","image-bitmap-fallback-disabled",`cached-render-runtime:${e}:skip-image-bitmap-fallback`),i.renderRuntimeCacheState="hit",i.renderRuntimeSource="config",this.logger.info(`[Appliance]: [render-cache] stage=read-result renderModel=${e} action=skip-image-bitmap-fallback fallback=mainThread+canvas2d reason=config-disabled`),this.logFinalRenderDecision();return}const o={"worker-offscreen-transfer":0,"worker-image-bitmap":1,"main-thread":2},a={webgl2:0,webgl:1,"2d":2},c=n.renderMode==="main-thread"||n.renderMode==="worker-offscreen-transfer"&&i.capabilities.offscreenTransfer||n.renderMode==="worker-image-bitmap"&&i.capabilities.imageBitmap,l=n.contextType==="2d"||n.contextType==="webgl2"&&i.capabilities.webgl2||n.contextType==="webgl"&&i.capabilities.webgl,u=o[n.renderMode]>=o[i.renderMode]&&a[n.contextType]>=a[i.contextType];(!c||!l||!u)&&(r="cache-capability-mismatch")}if(n&&e&&!r){const i=this.renderingCompatibilityDecision;this.renderMode=n.renderMode,i.renderMode=n.renderMode,i.contextType=n.contextType,i.reason="cached-render-runtime-decision",i.renderRuntimeCacheState="hit",i.renderRuntimeSource="cache";const o=`cached-render-runtime:${n.renderMode}/${n.contextType}`;i.issues.includes(o)||(i.issues=[...i.issues,o]),this.logger.info(`[Appliance]: [render-cache] stage=read-result renderModel=${e}`),this.logFinalRenderDecision();return}this.logger.info(`[Appliance]: [render-cache] stage=read-result renderModel=none${t.reason||r?` reason=${r||t.reason}`:""}`)}async persistRenderRuntimeDecision(){var n,i;if(this.pluginOptions.extras.useWorker!=="auto")return;const t=this.renderingCompatibilityDecision;if(this.pluginOptions.extras.allowImageBitmapFallback===!1&&t.renderMode==="main-thread")return;const e=Ht(t.renderMode,t.contextType);await Vwe(this.renderRuntimeCacheKey,e)?this.logger.info(`[Appliance]: [render-cache] stage=save renderModel=${e}`):(i=(n=this.logger).warn)==null||i.call(n,`[Appliance]: [render-cache] stage=save-failed renderModel=${e} reason=indexeddb-write-failed`)}async invalidateRenderRuntimeDecision(){var r,n;if(this.pluginOptions.extras.useWorker!=="auto")return;const t=await $we(this.renderRuntimeCacheKey);this.renderingCompatibilityDecision.renderRuntimeCacheState=void 0;const e=Ht(this.renderMode,this.renderingCompatibilityDecision.contextType);t?this.logger.info(`[Appliance]: [render-cache] stage=invalidate renderModel=${e}`):(n=(r=this.logger).warn)==null||n.call(r,`[Appliance]: [render-cache] stage=invalidate-failed renderModel=${e}`)}ensurePendingViewInitState(t){var r,n,i,o;let e=this.pendingViewInitStates.get(t);if(!e){const a=(n=(r=this.collector)==null?void 0:r.readViewStorageSnapshot)==null?void 0:n.call(r,t);e={sequence:0,anchorRevision:0,serviceBaselineRevision:(a==null?void 0:a.revision)||0,serviceBaseline:(a==null?void 0:a.storage)||((o=(i=this.collector)==null?void 0:i.getServiceStorageViewSnapshot)==null?void 0:o.call(i,t))||{},scenes:new Map},this.pendingViewInitStates.set(t,e)}return e}armPendingViewInit(t){var n;const e=this.ensurePendingViewInitState(t),r=this.getViewLifecycleGeneration(t);(n=this.viewContainerManager.getView(t))==null||n.displayer.setActive(!1),pt(this.logger,{category:"init-padding",viewId:t,stage:"armed",restartView:!0,lifecycleGeneration:r,details:{lifecycleGeneration:r,baselineRevision:e.serviceBaselineRevision}})}bindPendingViewInit(t,e){const r=this.pendingViewInitStates.get(t);r&&(r.generation=e)}nextInitPaddingSequence(t){return t.sequence+=1,t.sequence}getSceneInitPaddingState(t,e){let r=t.scenes.get(e);return r||(r={cameraRevision:0,serviceDirty:!1,forceFullRefresh:!1,forceFullRevision:0,journal:[]},t.scenes.set(e,r)),r}appendInitPaddingJournal(t,e,r,n){const i=this.getSceneInitPaddingState(t,e);i.journal.push({kind:r,sequence:this.nextInitPaddingSequence(t),storageKey:n}),i.journal.length>128&&i.journal.shift()}queuePendingInitScenePath(t,e){if(!t||!e)return;const r=this.ensurePendingViewInitState(t);r.latestScenePath=e,r.anchorRevision=this.nextInitPaddingSequence(r),pt(this.logger,{category:"init-padding",viewId:t,generation:r.generation,stage:"accepted-scene",details:{scenePath:e,revision:r.anchorRevision}})}queuePendingInitServicePull(t,e){if(!t||!e)return;const r=this.ensurePendingViewInitState(t),n=this.getSceneInitPaddingState(r,e);n.serviceDirty=!0,n.forceFullRefresh=!0,n.forceFullRevision=this.nextInitPaddingSequence(r),this.appendInitPaddingJournal(r,e,"servicePull"),pt(this.logger,{category:"init-padding",viewId:t,generation:r.generation,stage:"accepted-service-pull",details:{scenePath:e,revision:n.forceFullRevision}})}queuePendingInitCamera(t,e,r){var a,c,l,u;if(!t)return;const n=r||((c=(a=this.viewContainerManager)==null?void 0:a.getView(t))==null?void 0:c.focusScenePath)||((u=(l=this.viewContainerManager)==null?void 0:l.getCurScenePath)==null?void 0:u.call(l,t));if(!n)return;const i=this.ensurePendingViewInitState(t),o=this.getSceneInitPaddingState(i,n);o.camera={...e},o.cameraRevision=this.nextInitPaddingSequence(i),pt(this.logger,{category:"init-padding",viewId:t,generation:i.generation,stage:"accepted-camera",details:{scenePath:n,revision:o.cameraRevision}})}queuePendingServiceDerive(t,e,r){if(!t||!e||!(r!=null&&r.scenePath))return;const n=this.ensurePendingViewInitState(t),i=this.getSceneInitPaddingState(n,r.scenePath);i.serviceDirty=!0,this.appendInitPaddingJournal(n,r.scenePath,"serviceDerive",e),pt(this.logger,{category:"init-padding",viewId:t,generation:n.generation,stage:"accepted-service-diff",details:{scenePath:r.scenePath,revision:n.sequence}})}queuePendingInitClear(t,e){var o,a,c,l;if(!t)return;const r=e||((a=(o=this.viewContainerManager)==null?void 0:o.getView(t))==null?void 0:a.focusScenePath)||((l=(c=this.viewContainerManager)==null?void 0:c.getCurScenePath)==null?void 0:l.call(c,t));if(!r)return;const n=this.ensurePendingViewInitState(t),i=this.getSceneInitPaddingState(n,r);i.serviceDirty=!0,i.forceFullRefresh=!0,i.forceFullRevision=this.nextInitPaddingSequence(n),this.appendInitPaddingJournal(n,r,"clear"),pt(this.logger,{category:"init-padding",viewId:t,generation:n.generation,stage:"accepted-clear",details:{scenePath:r,revision:n.sequence}})}getPendingInitTargetScenePath(t){var e;return(e=this.pendingViewInitStates.get(t))==null?void 0:e.latestScenePath}getPendingInitCameraForScene(t,e){var n,i;const r=(i=(n=this.pendingViewInitStates.get(t))==null?void 0:n.scenes.get(e))==null?void 0:i.camera;return r?{...r}:void 0}markPendingInitServiceApplied(t,e,r,n){const i=this.pendingViewInitStates.get(t);if(!i)return;const o=this.getSceneInitPaddingState(i,e);o.lastApplied=r?ye.cloneDeep(r):{},o.lastAppliedRevision=n,o.serviceDirty=!1,o.forceFullRefresh=!1}resetPendingInitRendererBaseline(t){var r,n;const e=[...((r=this.pendingViewInitStates.get(t))==null?void 0:r.scenes.keys())||[]];for(const i of e){const o=(n=this.pendingViewInitStates.get(t))==null?void 0:n.scenes.get(i);o&&(o.lastApplied=void 0,o.serviceDirty=!0,o.forceFullRefresh=!0)}}getPendingInitServiceBaseline(t,e){var r;return ye.cloneDeep(((r=this.pendingViewInitStates.get(t))==null?void 0:r.serviceBaseline[e])||{})}getPendingInitReconcileRevision(t,e){const r=this.pendingViewInitStates.get(t),n=r==null?void 0:r.scenes.get(e);return{anchorRevision:(r==null?void 0:r.anchorRevision)||0,cameraRevision:(n==null?void 0:n.cameraRevision)||0,forceFullRevision:(n==null?void 0:n.forceFullRevision)||0}}getPendingInitLastApplied(t,e){var n;const r=(n=this.pendingViewInitStates.get(t))==null?void 0:n.scenes.get(e);return{revision:r==null?void 0:r.lastAppliedRevision,storage:r!=null&&r.lastApplied?ye.cloneDeep(r.lastApplied):void 0}}hasPendingInitAppliedSnapshot(t,e){var r,n;return((n=(r=this.pendingViewInitStates.get(t))==null?void 0:r.scenes.get(e))==null?void 0:n.lastApplied)!==void 0}isPendingInitForceFullRefresh(t,e){var r,n;return((n=(r=this.pendingViewInitStates.get(t))==null?void 0:r.scenes.get(e))==null?void 0:n.forceFullRefresh)===!0}hasPendingInitServiceChanges(t,e){var r,n;return((n=(r=this.pendingViewInitStates.get(t))==null?void 0:r.scenes.get(e))==null?void 0:n.serviceDirty)===!0}clearPendingViewInitState(t){var e;(e=this.pendingViewInitStates)==null||e.delete(t)}getViewLifecycleGeneration(t){return this.viewLifecycleGeneration.get(t)||0}isPendingViewInitCurrent(t,e){return this.getViewLifecycleGeneration(t)===e}invalidatePendingViewInit(t){const e=this.getViewLifecycleGeneration(t)+1;return this.viewLifecycleGeneration.set(t,e),this.clearPendingViewInitState(t),ya(this.logger,t),e}invalidateAllPendingViewInit(){const t=new Set(this.viewLifecycleGeneration.keys());for(const e of this.viewContainerManager.getAllViews())e!=null&&e.id&&t.add(e.id);for(const e of t)this.invalidatePendingViewInit(e);return this.pendingViewInitStates.clear(),t.size}applyWorkerRenderProbe(t){const e=this.renderingCompatibilityDecision,r=t.contextSupported;e.workerProbe=r?"passed":"failed",e.workerProgramProbe=t.programProbe,this.logFinalRenderDecision()}applyRuntimeRenderingDecision(t,e,r,n){this.renderMode=t;const i=this.renderingCompatibilityDecision;i.renderMode=t,i.contextType=e,i.reason=r,i.issues.includes(n)||(i.issues=[...i.issues,n])}logFinalRenderDecision(){const t=this.renderingCompatibilityDecision;this.logger.info(`[Appliance]: [render-capabilities] ${JSON.stringify({renderMode:t.renderMode,mainThreadRenderMode:t.mainThreadRenderMode,contextType:t.contextType,reason:t.reason,workerProbe:t.workerProbe,workerProgramProbe:t.workerProgramProbe,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 Jr(this,t,this.pluginOptions.extras.syncOpt.interval),this.activePlugin(),this.selectorApi&&this.selectorApi.destroy(),this.selectorApi=new Zwe(this)}handleRemoteStorageRemoval(t,e,r={}){var a,c,l,u,h;const n=r.clearView===!0,i=(c=(a=this.worker)==null?void 0:a.abortActiveLocalInput)==null?void 0:c.call(a,t,e),o=(l=this.worker)==null?void 0:l.abortActiveContinuousMethods(t,r.abortAllContinuousMethods?void 0:e);i&&!n&&((u=this.worker)==null||u.cancelLocalWorks(t,!1)),(n||r.cancelTicker||i||o)&&this.viewContainerManager.cancelViewUndoTicker(t),n&&((h=this.worker)==null||h.clearViewScenePath(t,!0))}canForceDoneLocalWorks(){return!this.isDestroyed&&!!this.room&&this.room.phase===Pi.Connected&&this.room.isWritable&&this.renderControl.isWritable}isLocalMutationRuntimeAvailable(t){var e,r,n,i;return this.isDestroying||this.isDestroyed||this.roomLifecycleTerminal||!this.room||this.room.phase!==Pi.Connected||!this.room.isWritable||!this.renderControl.isWritable||this.localMutationFenceCount>0||((r=(e=this.worker)==null?void 0:e.isRenderRuntimeRecovering)==null?void 0:r.call(e))===!0?!1:!t||((i=(n=this.worker)==null?void 0:n.isServiceSyncReady)==null?void 0:i.call(n,t))===!0}canAcceptLocalMutation(t){var e,r;return this.isLocalMutationRuntimeAvailable(t)?!t||!this.localMutationFenceByView.has(t)&&!this.isSceneBusy(t)&&!this.isClearBusy(t)&&!((r=(e=this.worker)==null?void 0:e.isViewBusy)!=null&&r.call(e,t)):!1}markRoomLifecycleTerminal(){var t,e;this.roomLifecycleTerminal||(this.roomLifecycleTerminal=!0,(e=(t=this.worker)==null?void 0:t.cancelRenderRuntimeRecovery)==null||e.call(t,"room-lifecycle-terminal"),this.viewContainerManager.getAllViews().forEach(r=>{r==null||r.displayer.setActive(!1)}))}canQueueViewLifecycleOperation(t){return this.isLocalMutationRuntimeAvailable(t)&&!!this.viewContainerManager.getView(t)}acquireLocalMutationFence(t){const e=t?new Set(t):void 0;e?e.forEach(n=>{this.localMutationFenceByView.set(n,(this.localMutationFenceByView.get(n)||0)+1)}):this.localMutationFenceCount++,this.viewContainerManager.getAllViews().forEach(n=>{n&&(!e||e.has(n.id))&&n.displayer.setActive(!1)});let r=!1;return()=>{r||(r=!0,e?e.forEach(n=>{const i=this.localMutationFenceByView.get(n)||0;i<=1?this.localMutationFenceByView.delete(n):this.localMutationFenceByView.set(n,i-1)}):this.localMutationFenceCount=Math.max(0,this.localMutationFenceCount-1),this.viewContainerManager.getAllViews().forEach(n=>{n&&(!e||e.has(n.id))&&this.canAcceptLocalMutation(n.id)&&!this.isSceneBusy(n.id)&&!this.isClearBusy(n.id)&&n.displayer.setActive(!0)}))}}forceDoneLocalWorks(t,e){this.forceDoneQueueByView||(this.forceDoneQueueByView=new Map);const r=this.acquireLocalMutationFence(e),n=e?[...new Set(e)]:void 0,i=n?[this.forceDoneQueue,...n.map(c=>this.forceDoneQueueByView.get(c)||Promise.resolve())]:[this.forceDoneQueue,...this.forceDoneQueueByView.values()],o=Promise.all(i).then(async()=>{if(!this.canForceDoneLocalWorks())return this.logLifecycleError(`[Appliance]: force-Done unavailable reason=${t}`),{status:"failed",reason:t,views:[],failureReasons:["lifecycle-unavailable"]};const c=[];try{this.textEditorManager.forceDoneLocalText(e)}catch(g){const y=g instanceof Error?g.message:String(g);c.push(`text-finalize: ${y}`),this.logLifecycleError(`[Appliance]: force-Done Text finalize failed reason=${t} error=${y}`)}const l=e?new Set(e):void 0,u=this.viewContainerManager.getAllViews().filter(g=>!!g&&(!l||l.has(g.id))),h=await Promise.allSettled(u.map(async g=>{if(!this.canForceDoneLocalWorks())return{status:"failed",viewId:g.id,scenePath:g.focusScenePath,reason:t,failureReason:"lifecycle-unavailable"};const y=this.worker.forceDoneLocalWorks(g.id,g.focusScenePath,t);return this.waitForForceDoneOrInvalidation(y,g,t)})),d=[];let f=c.length===0;return h.forEach((g,y)=>{var S,b,I,N,T;if(g.status==="rejected"){f=!1;const p=((S=g.reason)==null?void 0:S.message)||String(g.reason);d.push({status:"failed",viewId:((b=u[y])==null?void 0:b.id)||"unknown",scenePath:((I=u[y])==null?void 0:I.focusScenePath)||"",reason:t,failureReason:p}),c.push(`view=${((N=u[y])==null?void 0:N.id)||"unknown"}: ${p}`),this.logLifecycleError(`[Appliance]: force-Done failed viewId=${((T=u[y])==null?void 0:T.id)||"unknown"} reason=${t} error=${p}`)}else{if(d.push(g.value),g.value.status==="success")return;f=!1,c.push(`view=${g.value.viewId}: ${g.value.failureReason||"barrier-failed"}`),this.logLifecycleError(`[Appliance]: force-Done failed ACK viewId=${g.value.viewId} scenePath=${g.value.scenePath} reason=${t} error=${g.value.failureReason||"barrier-failed"}`)}}),this.canForceDoneLocalWorks()||(f=!1,c.push("lifecycle-invalidated"),this.logLifecycleError(`[Appliance]: force-Done lifecycle invalidated reason=${t}`)),{status:f?"success":"failed",reason:t,views:d,failureReasons:c}}).catch(c=>{const l=c instanceof Error?c.message:String(c);return this.logLifecycleError(`[Appliance]: force-Done aggregation failed reason=${t} error=${l}`),{status:"failed",reason:t,views:[],failureReasons:[`aggregation: ${l}`]}}).finally(()=>{try{r()}catch(c){this.logLifecycleError(`[Appliance]: force-Done mutation fence release failed reason=${t} error=${c instanceof Error?c.message:String(c)}`)}}),a=o.then(()=>{},()=>{});if(n){n.forEach(l=>{this.forceDoneQueueByView.set(l,a)});const c=()=>{n.forEach(l=>{this.forceDoneQueueByView.get(l)===a&&this.forceDoneQueueByView.delete(l)})};o.then(c,c)}else this.forceDoneQueue=a;return o}waitForForceDoneOrInvalidation(t,e,r){return new Promise((n,i)=>{let o=!1;const a=l=>{o||(o=!0,clearInterval(c),n(l))},c=setInterval(()=>{this.canForceDoneLocalWorks()||(this.worker.invalidateTransactionBarrier(e.id),a({status:"failed",viewId:e.id,scenePath:e.focusScenePath,reason:r,failureReason:"lifecycle-invalidated"}))},25);t.then(l=>a(l),l=>{o||(o=!0,clearInterval(c),i(l))})})}logLifecycleError(t){var e;(e=this.logger)==null||e.error(t)}destroy(t={}){var r,n;if(this.destroyPromise)return this.destroyPromise;const e=t.preserveStorage!==!1;return this.isDestroying=!0,(n=(r=this.worker)==null?void 0:r.cancelRenderRuntimeRecovery)==null||n.call(r,"manager-destroy"),this.destroyPromise=(async()=>{try{e&&this.canForceDoneLocalWorks()&&await this.forceDoneLocalWorks("destroy")}catch(i){this.logLifecycleError(`[Appliance]: force-Done before destroy failed: ${(i==null?void 0:i.message)||i}`)}finally{this.destroyImmediately()}})(),this.destroyPromise}destroyImmediately(){var r,n;if(this.isDestroyed)return;this.isDestroyed=!0;const t=[],e=(i,o)=>{try{o()}catch(a){t.push(`${i}: ${(a==null?void 0:a.message)||a}`)}};e("background-image",()=>this.backgroundImageLoadCoordinator.cancelAll()),e("main-view-ready",()=>this.mainViewMountedReady.cancel()),this.lifecycleGeneration++,this.viewLifecycleGeneration.forEach((i,o)=>{this.viewLifecycleGeneration.set(o,this.viewLifecycleGeneration.get(o)+1)}),e("sync-logger",()=>this.syncLogger.destroy()),this.pendingSceneChecks.clear(),(r=this.pendingViewInitStates)==null||r.clear(),this.pendingSceneChanges.forEach(i=>{i.releaseMutationFence(),i.waiters.forEach(o=>o())}),this.pendingSceneChanges.clear(),this.pendingClears.clear(),this.clearQueueByView.clear(),this.viewOperationQueueByView.clear(),(n=this.forceDoneQueueByView)==null||n.clear(),e("room-member",()=>this.roomMember.destroy()),e("orphan-repair",()=>{this.orphanRepairTimer&&clearTimeout(this.orphanRepairTimer),this.orphanRepairTimer=void 0}),e("tool-change",()=>{this.toolChangePendingTimer!==void 0&&(clearTimeout(this.toolChangePendingTimer),this.toolChangePendingTimer=void 0),this.toolChangePending=!1,this.onMemberChange.cancel()}),e("effect-waiter",()=>{const i=this.effectResolve;this.effectResolve=void 0,i==null||i(!1)}),e("view-container",()=>{var i;return(i=this.viewContainerManager)==null?void 0:i.destroy()}),e("worker",()=>{var i;return(i=this.worker)==null?void 0:i.destroy()}),e("collector",()=>{var i;return(i=this.collector)==null?void 0:i.destroy()}),e("cursor",()=>{var i;return(i=this.cursor)==null?void 0:i.destroy()}),e("text-editor",()=>{var i;return(i=this.textEditorManager)==null?void 0:i.destory()}),e("plugin-manager",()=>{var i;return(i=this.pluginManager)==null?void 0:i.destroy()}),e("mini-map",()=>{var i;return(i=this.miniMapManager)==null?void 0:i.destroyMiniMap()}),e("selector-api",()=>{var i;return(i=this.selectorApi)==null?void 0:i.destroy()}),this.selectorApi=void 0,e("logger",()=>{var i,o;return(o=(i=this.logger).destroy)==null?void 0:o.call(i)}),t.length&&this.logger.error(`[Appliance]: destroy completed with disposer errors: ${t.join("; ")}`)}async cleanCurrentScene(t=!0){if(this.isDestroying)return!1;const e=this.viewContainerManager.getPreferredFocusedViewId();if(!this.canQueueViewLifecycleOperation(e))return!1;const r=this.lifecycleGeneration,n=this.viewLifecycleGeneration.get(e)||0,i=()=>r===this.lifecycleGeneration&&(this.viewLifecycleGeneration.get(e)||0)===n&&!!this.viewContainerManager.getView(e);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 g,y;const u=this.viewContainerManager.getCurScenePath(e);if(!u||(await this.worker.waitForViewLifecycleIdle(e),!i())||t&&(await this.worker.forceDoneLocalWorks(e,u,"clean-scene"),!i()))return!1;const h=this.worker.now;cr.InternalMsgEmitter.emit("addUndoTicker",h,e,{render:!0,storage:!0,source:$e.Clear}),cr.InternalMsgEmitter.emit("finalizeRequested",h,e,[si],u);const d=(y=(g=this.viewContainerManager.getView(e))==null?void 0:g.displayer)==null?void 0:y.commiter,f=d==null?void 0:d.getPendingTickerSnapshots(u).find(S=>S.tickerId===h);if(await this.worker.clearViewScenePath(e,!1,!0),!i())return!1;if(cr.InternalMsgEmitter.emit("ackRenderUndoTicker",h,e,u),cr.InternalMsgEmitter.emit("ackStorageUndoTicker",h,e,u,si),f&&d){try{await d.waitForUndoStackEnd(f,Tpe)}catch(S){if(!i())return!1;this.logger.error(`[Appliance]: Clear Undo stack-end wait failed; viewId=${e}; scenePath=${u}; tickerId=${h}; error=${S instanceof Error?S.message:String(S)}`);try{d.cancelUndoTicker(h,e,u)}catch(b){this.logger.error(`[Appliance]: forcing Clear Undo stack-end failed; viewId=${e}; scenePath=${u}; tickerId=${h}; error=${b instanceof Error?b.message:String(b)}`)}}if(!i())return!1}return!0}),c=a.then(()=>{},()=>{});this.clearQueueByView.set(e,c);let l=!1;try{const u=await a;return l=!0,u}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()),i=n.then(()=>{},()=>{});this.viewOperationQueueByView.set(t,i);const o=()=>{this.viewOperationQueueByView.get(t)===i&&this.viewOperationQueueByView.delete(t)};return n.then(o,o),n}async setWritable(t){var r,n;let e;if(!t){if(e=await this.forceDoneLocalWorks("set-readonly"),this.isDestroyed)return e;(r=this.cursor)==null||r.unabled(),this.textEditorManager.checkEmptyTextBlur();const i=this.viewContainerManager.getAllViews();for(const o of i){o!=null&&o.focusScenePath&&(n=this.collector)!=null&&n.hasSelector(o.id,o.focusScenePath)&&this.worker.blurSelector(o.id,o.focusScenePath);const a=o==null?void 0:o.displayer;a&&(a.setActive(!1),await a.stopEventHandler())}}return e}onWritableChange(t){var n;if(this.isDestroying||this.isDestroyed)return;t?(this.worker.abled(),this.scheduleOrphanRepair()):this.worker.unWritable(),((n=this.worker.getCurrentToolsData())==null?void 0:n.toolsType)===q.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(i=>{const o=i==null?void 0:i.displayer;o&&(o.bindToolsClass(),t?this.canAcceptLocalMutation(i==null?void 0:i.id)&&!this.isSceneBusy(i==null?void 0:i.id)&&!this.isClearBusy(i==null?void 0:i.id)&&o.setActive(!0):o.setActive(!1))})}async consumePendingSceneChanges(t,e){var r,n;try{for(;this.pendingSceneChanges.get(t)===e;){const i=(r=this.viewContainerManager.getView(t))==null?void 0:r.focusScenePath,o=e.targetScenePath;if(i===o)break;if(!i){if(this.logger.info(`[Appliance]: [scene-path] stage=recover-missing-current viewId=${t} scenePath=${o}`),this.viewContainerManager.setViewScenePath(t,o),((n=this.viewContainerManager.getView(t))==null?void 0:n.focusScenePath)!==o)break;continue}if(await this.applySceneChange(t,i,e),!await Kwe({previousScenePath:i,attemptedScenePath:o,getCurrentScenePath:()=>{var c;return(c=this.viewContainerManager.getView(t))==null?void 0:c.focusScenePath},getTargetScenePath:()=>e.targetScenePath}))break}}finally{const i=this.pendingSceneChanges.get(t)===e,o=i?e.deferredCamera:void 0;e.running=!1,e.isSceneBusy=!1,i&&this.pendingSceneChanges.delete(t);try{i&&o&&(!o.scenePath||o.scenePath===e.targetScenePath)?this.worker.updateCamera(t,o.cameraOpt):i&&this.worker.recoverAfterSceneChange(t)}finally{try{e.releaseMutationFence()}finally{e.waiters.forEach(a=>a()),e.waiters.clear()}}}}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.invalidatePendingViewInit(t);const e=this.pendingSceneChanges.get(t);this.pendingClears.delete(t),this.clearQueueByView.delete(t),this.viewOperationQueueByView.delete(t),e&&(e.isSceneBusy=!1,e.waiters.forEach(r=>r()),e.waiters.clear(),this.pendingSceneChanges.delete(t),e.releaseMutationFence())}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,i=this.viewLifecycleGeneration.get(t)||0,o=()=>n===this.lifecycleGeneration&&(this.viewLifecycleGeneration.get(t)||0)===i&&!!this.viewContainerManager.getView(t),a=this.viewContainerManager.getView(t);this.textEditorManager.forceDoneLocalText([t]);const c=a==null?void 0:a.displayer;if(c&&c.setActive(!1),await this.worker.forceDoneLocalWorks(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 i;if(this.isDestroying||this.isDestroyed)return;const r=this.getPendingSceneCheckKey(t,e),n=(i=this.collector)==null?void 0:i.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===Le||this.collector.isOwn(o)&&this.collector.getLocalId(o)===Le){this.collector.updateValue(o,void 0,{viewId:t,scenePath:e,isSync:!0});continue}if(!this.collector.isOwn(o))continue;const l=await Pp(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=this.lifecycleGeneration,n=()=>{if(this.isDestroying||this.isDestroyed||this.lifecycleGeneration!==r)return;const o=this.getPendingSceneCheckKey(t,e);for(const a of[...this.pendingSceneChecks]){if(a===o||!this.pendingSceneChecks.has(a))continue;const c=this.parsePendingSceneCheckKey(a);c?this.reconcileSceneStorage(c[0],c[1]):this.pendingSceneChecks.delete(a)}},i=window.requestIdleCallback;i?i(n,{timeout:500}):window.setTimeout(n,0)}scheduleOrphanRepair(){this.isDestroying||this.isDestroyed||(this.orphanRepairTimer&&clearTimeout(this.orphanRepairTimer),this.orphanRepairTimer=setTimeout(()=>{this.orphanRepairTimer=void 0,this.repairOrphanStorage()},750))}captureOrphanRepairMembers(){var o;const t=this.roomMember.getAllRoomMembers(),e=(o=this.collector)==null?void 0:o.uid;if(!e)return;const r=t.filter(a=>{var c;return typeof a.memberId=="number"&&!!((c=a.payload)!=null&&c.uid)}).map(a=>{var c;return{memberId:a.memberId,uid:(c=a.payload)==null?void 0:c.uid}}).sort((a,c)=>a.memberId-c.memberId),n=r.find(a=>a.uid===e),i=r[0];if(!(!n||!i))return{digest:JSON.stringify(r),leaderMemberId:i.memberId,selfMemberId:n.memberId,selfUid:e,onlineUids:new Set(r.map(a=>a.uid))}}isCurrentOrphanRepairMembers(t){var r;if(this.isDestroying||this.isDestroyed||!((r=this.room)!=null&&r.isWritable)||this.room.phase!==Pi.Connected)return!1;const e=this.captureOrphanRepairMembers();return!!e&&e.digest===t.digest}async repairOrphanStorage(){var n,i,o,a,c,l,u;if(this.isDestroying||this.isDestroyed||!((n=this.room)!=null&&n.isWritable)||this.room.phase!==Pi.Connected||!this.collector)return;const t=this.collector,e=this.captureOrphanRepairMembers();if(!e||e.selfUid!==t.uid||e.selfMemberId!==e.leaderMemberId)return;const r=e.onlineUids;for(const[h,d]of Object.entries(t.storage)){if(this.isDestroying||this.isDestroyed)return;if(!t.isViewPendingSyncDiscarded(h))for(const[f,g]of Object.entries(d||{})){if(t.isViewPendingSyncDiscarded(h))break;for(const[y,S]of Object.entries(g||{})){if(!this.isCurrentOrphanRepairMembers(e))return;if(!S)continue;const b=S.lastOperator||((i=S.opt)==null?void 0:i.uid);if(!b||r.has(b)||!((((o=S.opt)==null?void 0:o.workState)||((a=S.updateNodeOpt)==null?void 0:a.workState))!==de.Done||!!((c=S.op)!=null&&c.length)&&!S.ops))continue;if(t.getLocalId(y)===Le||S.toolsType===q.Selector){t.updateExistingValue(y,void 0,{viewId:h,scenePath:f,isSync:!0});continue}const T=await Pp(S);if(!this.isCurrentOrphanRepairMembers(e))return;if(T.status==="unrecoverable"||T.status==="already-stable")continue;const p=(u=(l=t.storage[h])==null?void 0:l[f])==null?void 0:u[y];!p||p!==S||(T.value.lastOperator=b,t.updateExistingValue(y,T.value,{viewId:h,scenePath:f,isSync:!0,preserveLastOperator:!0}))}}}}requestToolChange(t){var i,o;const e={...(i=this.room)==null?void 0:i.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||this.isDestroying}getToolsKey(t){const e=t.currentApplianceName;switch(this.hasSwitchToSelectorEffect=!1,e){case De.text:return t.textCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),q.Text;case De.pencil:return t.useLaserPen?q.LaserPen:q.Pencil;case De.eraser:return q.Eraser;case De.pencilEraser:return this.pluginOptions.extras.pencilEraser.useBitMap===!1?q.PencilEraser:q.BitMapEraser;case De.selector:return q.Selector;case De.clicker:return q.Clicker;case De.hand:return q.Hand;case De.laserPointer:return q.Hand;case De.arrow:return t.arrowCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),q.Arrow;case De.straight:return t.straightCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),q.Straight;case De.ellipse:return t.ellipseCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),q.Ellipse;case De.rectangle:return t.rectangleCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),q.Rectangle;case De.shape:if(t.shapeCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),t.shapeType===Zt.Pentagram||t.shapeType===Zt.Star)return q.Star;if(t.shapeType===Zt.Polygon||t.shapeType===Zt.Triangle||t.shapeType===Zt.Rhombus)return q.Polygon;if(t.shapeType===Zt.SpeechBalloon)return q.SpeechBalloon;break}return q.Hand}getToolsOpt(t,e){if(t===q.Clicker)return{toolsType:t,toolsOpt:{}};const r={strokeColor:qn(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 q.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)&&qn(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)&&qn(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 q.Pencil:{const n=(e==null?void 0:e.strokeType)||Be.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 q.PencilEraser:case q.BitMapEraser:case q.Eraser:if(r.thickness=Math.min(4,Math.max(1,Math.floor(e.pencilEraserSize||1)))-1,t===q.BitMapEraser){const n=r;n.fullLayerDoingMaskMaxInputPoints=Pc(this.pluginOptions.extras.pencilEraser.fullLayerDoingMaskMaxInputPoints),n.removeOnDone=this.pluginOptions.extras.pencilEraser.removeOnDone!==!1,n.maxImageWidth=this.pluginOptions.extras.pencilEraser.maxImageWidth,n.maxImageHeight=this.pluginOptions.extras.pencilEraser.maxImageHeight}break;case q.LaserPen:{r.duration=(e==null?void 0:e.duration)||1,e!=null&&e.strokeType&&(e==null?void 0:e.strokeType)===Be.Stroke?r.strokeType=Be.Normal:r.strokeType=(e==null?void 0:e.strokeType)||Be.Normal;const n=r.strokeType;r.lineCap=this.getLineCap(n),r.lineDash=this.getLineDash(n);break}case q.Arrow:case q.Straight:{e!=null&&e.strokeType&&(e==null?void 0:e.strokeType)===Be.Stroke?r.strokeType=Be.Normal:r.strokeType=(e==null?void 0:e.strokeType)||Be.Normal;const n=r.strokeType;r.strokeType=n,r.lineCap=this.getLineCap(n),r.lineDash=this.getLineDash(n);break}case q.Ellipse:case q.Rectangle:case q.Star:case q.Polygon:case q.SpeechBalloon:{e!=null&&e.strokeType&&(e==null?void 0:e.strokeType)===Be.Stroke?r.strokeType=Be.Normal:r.strokeType=(e==null?void 0:e.strokeType)||Be.Normal;const n=r.strokeType;r.lineCap=this.getLineCap(n),r.lineDash=this.getLineDash(n),t===q.Star&&(e.shapeType===Zt.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===q.Polygon&&(e.shapeType===Zt.Triangle?r.vertices=3:e.shapeType===Zt.Rhombus?r.vertices=4:e.vertices&&(r.vertices=e.vertices)),r.fillColor=(e==null?void 0:e.fillColor)&&qn(e.fillColor[0],e.fillColor[1],e.fillColor[2],e==null?void 0:e.fillOpacity)||"transparent",t===q.SpeechBalloon&&(r.placement=e.placement||"bottomLeft");break}}return{toolsType:t,toolsOpt:r}}getLineCap(t){switch(t){case Be.Normal:return this.pluginOptions.extras.normalStroke.lineCap||He.normalStroke.lineCap;case Be.Dotted:return this.pluginOptions.extras.dottedStroke.lineCap||He.dottedStroke.lineCap;case Be.LongDotted:return this.pluginOptions.extras.longDottedStroke.lineCap||He.longDottedStroke.lineCap;default:return}}getLineDash(t){switch(t){case Be.Normal:return;case Be.Dotted:{const{segment:e,gap:r}=this.pluginOptions.extras.dottedStroke||He.dottedStroke;return[e,r]}case Be.LongDotted:{const{segment:e,gap:r}=this.pluginOptions.extras.longDottedStroke||He.longDottedStroke;return[e,r]}default:return}}effectViewContainer(t){var r,n,i,o,a;if(this.disableDeviceInputs===!0)this.room.disableDeviceInputs=!0,(r=this.worker)==null||r.unWritable(),(n=this.cursor)==null||n.unabled();else switch(t!==q.Text&&this.viewContainerManager.focuedViewId&&this.viewContainerManager.unActiveTextEditor(this.viewContainerManager.focuedViewId),t){case q.Text:case q.Pencil:case q.LaserPen:case q.Arrow:case q.Straight:case q.Rectangle:case q.Ellipse:case q.Star:case q.Polygon:case q.SpeechBalloon:case q.Triangle:case q.Rhombus:case q.Eraser:case q.PencilEraser:case q.BitMapEraser:case q.Selector:case q.Clicker:this.room.disableDeviceInputs=!0,(i=this.worker)==null||i.abled(),t===q.Text&&this.viewContainerManager.focuedViewId&&this.viewContainerManager.activeTextEditor(this.viewContainerManager.focuedViewId);break;default:this.room.disableDeviceInputs=!1,(o=this.worker)==null||o.unWritable(),(a=this.cursor)==null||a.unabled();break}const e=this.lifecycleGeneration;setTimeout(()=>{if(this.isDestroying||this.isDestroyed||this.lifecycleGeneration!==e)return;this.viewContainerManager.getAllViews().forEach(l=>{l!=null&&l.displayer&&l.displayer.bindToolsClass()})},0)}async getBoundingRect(t){var r,n,i,o,a;const e=await((r=this.worker)==null?void 0:r.getBoundingRect(t));if(e){const c=((i=(n=this.viewContainerManager.mainView)==null?void 0:n.viewData)==null?void 0:i.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,i,o,a){const c=await this.worker.getSnapshot(e,r,n,i);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 i=await((l=this.worker)==null?void 0:l.getSnapshot(t));if(i&&this.worker){const u=document.createElement("canvas"),h=u.getContext("2d"),{width:d,height:f}=n.cameraOpt;u.width=d,u.height=f,h&&(i.forEach(g=>{g&&(h.drawImage(g,0,0),g instanceof ImageBitmap?g.close():g instanceof HTMLImageElement&&g.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.effectResolve=r;try{this.switchToSelector()}catch(n){this.effectResolve=void 0,this.logLifecycleError(`[Appliance]: switchToSelector effect failed: ${n instanceof Error?n.message:String(n)}`),r(!1)}});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;this.logger.info(`[Appliance]: [render-runtime] buildMarker=${this.renderRuntimeBuildMarker}`),(t=this.worker)==null||t.consoleWorkerInfo()}filterRenderByUid(t,e,r=!0){var i;this.viewContainerManager.getView(t)&&((i=this.renderControl)==null||i.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,i,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((i=this.miniMapManager)==null?void 0:i.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 i=this.room.state.memberState,o=qn(i.strokeColor[0],i.strokeColor[1],i.strokeColor[2],i.strokeOpacity||1);(n=this.worker)==null||n.insertIconify(t,{...e,strokeColor:o})}}insertBackgroundSVG(t,e){var r;if(!this.isUseBackgroundThread)throw new Error("useBackgroundThread of pluginOptions should be true");(r=this.worker)==null||r.insertBackgroundSVG(t,e)}reloadBackgroundImage(t){if(t.source!=="appliance")return{accepted:!1,reloadedCount:0,reason:"resourceNotFound"};const e=this.viewContainerManager.getView(t.viewId);return e?!e.focusScenePath||t.scenePath!==void 0&&e.focusScenePath!==t.scenePath?{accepted:!1,reloadedCount:0,reason:"sceneNotFocused"}:this.backgroundImageLoadCoordinator.reload({...t,scenePath:t.scenePath??e.focusScenePath}):{accepted:!1,reloadedCount:0,reason:"viewNotFound"}}async insertBackgroundMarkMap(t,e){var r;if(!this.isUseBackgroundThread)throw new Error("useBackgroundThread of pluginOptions should be true");return await((r=this.worker)==null?void 0:r.insertBackgroundMarkMap(t,e))}updateBackgroundMarkMap(t,e,r){var i;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)(i=this.worker)==null||i.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)}};x(cr,"InternalMsgEmitter",new tu),x(cr,"PublicMsgEmitter",new tu);let tt=cr;var qu=(s=>(s.Undo="undo",s.Redo="redo",s))(qu||{});const Xe=class Xe{createProxy(t,e,r){const n=new Proxy(t,{get(i,o,a){if(typeof o=="string"&&/^\d+$/.test(o))return Reflect.get(i,o,a);const c=Xe.interceptors.hasOwnProperty(o)?Xe.interceptors:i,l=Reflect.get(c,o,a);return typeof l=="function"&&c===Xe.interceptors?l.bind(n):l},set(i,o,a,c){const l=Xe.proxyCallbacks.get(c),u=(l==null?void 0:l.arrayType)||"undo";if(o==="length"){const h=i.length,d=[];if(a<h)for(let g=a;g<h;g++)d.push(i[g]);const f=Reflect.set(i,o,a,c);if(l!=null&&l.callback)for(let g=0;g<d.length;g++)l.callback({operation:"delete",index:a+g,oldValue:d[g],arrayType:u});return f}return typeof o=="string"&&/^\d+$/.test(o),Reflect.set(i,o,a,c)},deleteProperty(i,o){const a=Xe.proxyCallbacks.get(n),c=(a==null?void 0:a.arrayType)||"undo";if(typeof o=="string"&&/^\d+$/.test(o)){const l=parseInt(o,10),u=i[l],h=Reflect.deleteProperty(i,o);return a!=null&&a.callback&&u!==void 0&&a.callback({operation:"delete",index:l,oldValue:u,arrayType:c}),h}return Reflect.deleteProperty(i,o)}});return Xe.proxyToRaw.set(n,t),Xe.proxyCallbacks.set(n,{callback:e,arrayType:r}),n}};x(Xe,"proxyToRaw",new WeakMap),x(Xe,"proxyCallbacks",new WeakMap),x(Xe,"interceptors",{entries(...t){return Xe.proxyToRaw.get(this).entries(...t)},forEach(...t){return Xe.proxyToRaw.get(this).forEach(...t)},map(...t){return Xe.proxyToRaw.get(this).map(...t)},filter(...t){return Xe.proxyToRaw.get(this).filter(...t)},find(...t){return Xe.proxyToRaw.get(this).find(...t)},findIndex(...t){return Xe.proxyToRaw.get(this).findIndex(...t)},includes(...t){return Xe.proxyToRaw.get(this).includes(...t)},indexOf(...t){return Xe.proxyToRaw.get(this).indexOf(...t)},slice(...t){return Xe.proxyToRaw.get(this).slice(...t)},concat(...t){return Xe.proxyToRaw.get(this).concat(...t)},push(...t){const e=Xe.proxyToRaw.get(this),r=this,n=Xe.proxyCallbacks.get(r),i=(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:i});return a},customPush(...t){return Xe.proxyToRaw.get(this).push(...t)},pop(){const t=Xe.proxyToRaw.get(this),e=this,r=Xe.proxyCallbacks.get(e),n=(r==null?void 0:r.arrayType)||"undo",i=t.length,o=t[i-1],a=t.pop();return r!=null&&r.callback&&i>0&&r.callback({operation:"delete",index:i-1,oldValue:o,arrayType:n}),a},shift(){const t=Xe.proxyToRaw.get(this),e=this,r=Xe.proxyCallbacks.get(e),n=(r==null?void 0:r.arrayType)||"undo",i=t[0],o=t.shift();return r!=null&&r.callback&&t.length>0&&r.callback({operation:"delete",index:0,oldValue:i,arrayType:n}),o},unshift(...t){const e=Xe.proxyToRaw.get(this),r=this,n=Xe.proxyCallbacks.get(r),i=(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:i});return o},splice(t,e,...r){const n=Xe.proxyToRaw.get(this),i=this,o=Xe.proxyCallbacks.get(i),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=Xe.proxyToRaw.get(this),i=e??n.length-t;return n.splice(t,i,...r)},get length(){return Xe.proxyToRaw.get(this).length},set length(t){const e=Xe.proxyToRaw.get(this),r=this,n=Xe.proxyCallbacks.get(r),i=(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:i})}});let Zu=Xe;const Xr=class Xr{constructor(t){x(this,"emitter",new tu);x(this,"undoStack");x(this,"redoStack");x(this,"worker");x(this,"control");x(this,"room");x(this,"viewId");x(this,"enableGlobal");x(this,"isTicking");x(this,"_undoTickerId");x(this,"scenePath");x(this,"tickStartStorerCache");x(this,"excludeIds",new Set);x(this,"pendingState",new Map);x(this,"tickerEndWaiters",new Map);x(this,"undoLifecycleListeners",new Set);x(this,"pendingWaitCancels",new Set);x(this,"destroyed",!1);x(this,"lifecycleCache",new Map);x(this,"stackRevision",0);x(this,"tickStartCaches",new Map);x(this,"tickStartExcludeIds",new Map);x(this,"timingFix");x(this,"ackTimeout");x(this,"isGlobalStackTransaction",!1);x(this,"pendingGlobalServiceData");x(this,"pendingArrayChanges",[]);x(this,"onChangeScene",ye.debounce(()=>{if(this.destroyed)return;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)}},Xr.waitTime));const{control:e,internalMsgEmitter:r,viewId:n,enableGlobal:i}=t;this.control=e,this.emitter=r;const o=this.control.pluginOptions.extras.undoRedo;Xr.MaxStackLength=o.maxStackLength||He.undoRedo.maxStackLength,this.timingFix=o.timingFix??He.undoRedo.timingFix,this.ackTimeout=o.ackTimeout||He.undoRedo.ackTimeout;const a=new Zu,c=[],l=[];this.undoStack=a.createProxy(c,u=>{this.control.renderControl.isWritable&&this.handleArrayChange(u,wt.syncUndoStack)},qu.Undo),this.redoStack=a.createProxy(l,u=>{this.control.renderControl.isWritable&&this.handleArrayChange(u,wt.syncRedoStack)},qu.Redo),this.room=e.room,this.worker=e.worker,this.isTicking=!1,this.viewId=n,this.enableGlobal=i}reportStackLength(t,e=this.undoStack.length,r=this.redoStack.length){var n,i,o;(o=(i=(n=this.room)==null?void 0:n.logger)==null?void 0:i.info)==null||o.call(i,`[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){if(this.destroyed)return;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.destroyed?()=>{}:(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){if(this.destroyed)return Promise.reject(new Error(`undo view destroyed: ${this.viewId}`));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,i)=>{let o,a=!1,c=!1,l=()=>{};const u=()=>{o!==void 0&&clearTimeout(o),l(),this.pendingWaitCancels.delete(h)},h=()=>{c||(c=!0,u(),i(new Error(`undo view destroyed: ${this.viewId}`)))},d=y=>{if(a)return;a=!0;const S=Math.max(0,y+e-Date.now());o=setTimeout(()=>{c=!0,u(),i(new Error(`undo stack end timeout: ${this.lifecycleKey(t)}`))},S)},f=()=>{const y=this.pendingState.get(t.tickerId);(y==null?void 0:y.transactionId)===t.transactionId&&y.finalizedAt!==void 0&&d(y.finalizedAt)},g=y=>{if(this.lifecycleKey(y)===this.lifecycleKey(t)){if(y.phase==="finalize-requested"){d(y.finalizedAt);return}if(y.phase==="data-done"){f();return}c=!0,u(),y.phase==="stack-end"?n(y):i(y)}};l=this.onUndoLifecycle(g),this.pendingWaitCancels.add(h),(r==null?void 0:r.phase)==="finalize-requested"?d(r.finalizedAt):(r==null?void 0:r.phase)==="data-done"&&f()})}waitForDataDone(t,e){if(this.destroyed)return Promise.reject(new Error(`undo view destroyed: ${this.viewId}`));const r=this.lifecycleCache.get(this.lifecycleKey(t));return(r==null?void 0:r.phase)==="data-done"||(r==null?void 0:r.phase)==="stack-end"?Promise.resolve():(r==null?void 0:r.phase)==="failed"?Promise.reject(r):new Promise((n,i)=>{let o=!1,a,c=()=>{};const l=()=>{a!==void 0&&clearTimeout(a),c(),this.pendingWaitCancels.delete(u)},u=()=>{o||(o=!0,l(),i(new Error(`undo view destroyed: ${this.viewId}`)))},h=d=>{this.lifecycleKey(d)===this.lifecycleKey(t)&&d.phase!=="finalize-requested"&&(o=!0,l(),d.phase==="data-done"||d.phase==="stack-end"?n():i(d))};c=this.onUndoLifecycle(h),this.pendingWaitCancels.add(u),e!==void 0&&e>0&&(a=setTimeout(()=>{o||(o=!0,l(),i(new Error(`undo data done timeout: ${this.lifecycleKey(t)}`)))},e))})}waitForFinalizeRequested(t,e){if(this.destroyed)return Promise.reject(new Error(`undo view destroyed: ${this.viewId}`));const r=this.lifecycleCache.get(this.lifecycleKey(t));return(r==null?void 0:r.phase)==="finalize-requested"||(r==null?void 0:r.phase)==="data-done"||(r==null?void 0:r.phase)==="stack-end"?Promise.resolve():(r==null?void 0:r.phase)==="failed"?Promise.reject(r):new Promise((n,i)=>{let o,a=!1,c=()=>{};const l=()=>{o!==void 0&&clearTimeout(o),c(),this.pendingWaitCancels.delete(u)},u=()=>{a||(a=!0,l(),i(new Error(`undo view destroyed: ${this.viewId}`)))},h=d=>{this.lifecycleKey(d)===this.lifecycleKey(t)&&(a=!0,l(),d.phase==="finalize-requested"||d.phase==="data-done"||d.phase==="stack-end"?n():i(d))};c=this.onUndoLifecycle(h),this.pendingWaitCancels.add(u),o=setTimeout(()=>{a=!0,l(),i(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 i=this.pendingState.get(t);!i||i.scenePath!==e||(r&&i.ackedStorageKeys.add(r),dye(i.scopeKeys,r)&&i.finalizeRequested&&(i.scopeKeys.size?i.gotStorage=[...i.scopeKeys].every(a=>i.ackedStorageKeys.has(a)):i.gotStorage=!0),this.mergeMeta(i,n),!i.finalizeRequested)||(this.armAckTimeout(t,i),this.tryEnd(t))}collectExpectedWorkIds(t,e,r){const n=this.pendingState.get(t);if(!n||n.scenePath!==e||!r.length)return;Wl(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 i=Wl(this.collector,this.viewId,e,r);i.size&&(i.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 i=n.finalizeRequested,o=Wl(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.finalizedAt??(n.finalizedAt=Date.now()),n.phase="finalizing",n.gotStorage=hye(n),this.armAckTimeout(t,n),i||this.emitUndoLifecycle({...this.getIdentity(t,n),phase:"finalize-requested",source:n.source,scopeMode:n.scopeMode,finalizedAt:n.finalizedAt}),this.tryEnd(t)}mergeMeta(t,e){cye(t,e)}armAckTimeout(t,e){e.finalizeRequested&&uye(e)&&(e.ackTimer=setTimeout(()=>{this.forceFlushPending(t)},this.ackTimeout))}tryEnd(t){const e=this.pendingState.get(t);if(!e||!lye(e))return;const r=e.meta,n=e.phase==="failed";if(n||this.emitUndoLifecycle({...this.getIdentity(t,e),phase:"data-done",source:e.source,completedAt:Date.now()}),this.undoTickerEndSync(t,e.viewId,e.scenePath,!0),!n){const i=this.undoStack.some(o=>o.id===`${t}-${this.uid}`);e.phase="completed",this.stackRevision++,this.emitUndoLifecycle({...this.getIdentity(t,e),phase:"stack-end",source:e.source,outcome:i?"committed":"no-change",undoItemCreated:i,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)}clearPendingState(t){const e=this.pendingState.get(t);e&&(e.ackTimer&&clearTimeout(e.ackTimer),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 i=()=>{n!==void 0&&clearTimeout(n);const a=this.tickerEndWaiters.get(t);a==null||a.delete(i),(a==null?void 0:a.size)===0&&this.tickerEndWaiters.delete(t),r()},o=this.tickerEndWaiters.get(t)||new Set;o.add(i),this.tickerEndWaiters.set(t,o),e!==void 0&&(n=setTimeout(i,e))})}disposeViewTickers(t="view-destroyed"){var o,a,c;if(this.destroyed)return;const e=this.undoStack.length,r=this.redoStack.length,n=this.pendingState.size,i=this.isTicking;this.onChangeScene.cancel();for(const l of[...this.pendingWaitCancels])l();this.pendingWaitCancels.clear();for(const l of[...this.pendingState.keys()])this.clearPendingState(l);this.tickerEndWaiters.forEach(l=>{l.forEach(u=>u())}),this.tickerEndWaiters.clear(),this.undoLifecycleListeners.clear(),this.lifecycleCache.clear(),this.tickStartCaches.clear(),this.tickStartExcludeIds.clear(),this.excludeIds.clear(),this.pendingArrayChanges.length=0,this.pendingGlobalServiceData=void 0,this.isGlobalStackTransaction=!1,this.isTicking=!1,this._undoTickerId=void 0,this.scenePath=void 0,this.tickStartStorerCache=void 0,this.destroyed=!0,this.undoStack.customSplice(0),this.redoStack.customSplice(0),(e>0||r>0||n>0||i)&&((c=(a=(o=this.room)==null?void 0:o.logger)==null?void 0:a.info)==null||c.call(a,`[Appliance]: [undo-stack] undo-disposed:${t} viewId=${this.viewId} discardedUndoLength=${e} discardedRedoLength=${r} pendingTickerCount=${n} wasTicking=${i}`))}cancelUndoTicker(t,e,r){const n=this.pendingState.has(t),i=this.undoTickerId===t&&this.viewId===e&&this.scenePath===r;if(!n&&!i)return;const o=this.pendingState.get(t);i&&(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}))}cancelViewUndoTicker(){const t=this.undoTickerId,e=this.scenePath;t===void 0||!e||this.cancelUndoTicker(t,this.viewId,e)}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:i}=t;let o,a;r==="delete"&&n?(o=n,a=n.id):r==="add"&&i&&(o=i,a=i.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,i,o;if(!this.destroyed){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 h=this.undoTickerId;this.pendingState.get(h)||this.undoTickerEndSync(h,this.viewId,this.scenePath)}this.isTicking=!0;const a=this.collector.transformKey(Le);this.excludeIds.add(a),this._undoTickerId=t,this.scenePath=e;const c=((n=this.collector)==null?void 0:n.storage[this.viewId])&&((i=this.collector)==null?void 0:i.storage[this.viewId][this.scenePath])||{},l=new Map(Object.entries(ye.cloneDeep(c))),u=new Set([a]);this.tickStartStorerCache=l,this.tickStartCaches.set(t,l),this.tickStartExcludeIds.set(t,u),this.pendingState.set(t,aye({tickerId:t,viewId:this.viewId,scenePath:e,expectedAcks:r})),(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 i=this.collector.transformKey(Le);this.excludeIds.add(i),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(ye.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,i){var c,l;if(i&&i.length)for(const u of i)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:ye.cloneDeep(d),scenePath:r}),this.undoStack.length>Xr.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 i=new Set;for(const[o,a]of Object.entries(n.data))i.add({key:o,dataType:a.dataType,data:a.data});e.push({id:r,scenePath:n.scenePath,data:i})}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 i=this.undoStack.length-1;i>=0;i--){const o=this.undoStack[i];n.findIndex(c=>c.id===o.id)===-1&&this.undoStack.customSplice(i,1)}for(const i of n){const o=this.undoStack.findIndex(a=>a.id===i.id);o!==-1?this.undoStack[o]=i:this.undoStack.customPush(i)}this.undoStack.sort((i,o)=>{const a=parseInt(i.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 i=this.redoStack.length-1;i>=0;i--){const o=this.redoStack[i];n.findIndex(c=>c.id===o.id)===-1&&this.redoStack.customSplice(i,1)}for(const i of n){const o=this.redoStack.findIndex(a=>a.id===i.id);o!==-1?this.redoStack[o]=i:this.redoStack.customPush(i)}this.redoStack.sort((i,o)=>{const a=parseInt(i.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),f=this.diffFun(l,new Map(Object.entries(h)),!0,this.getExcludeIds(a),u==null?void 0:u.scopeKeys);d.size===f.size?(this.undoStack.push({id:`${a}-${this.uid}`,data:ye.cloneDeep(d),scenePath:c}),this.undoStack.length>Xr.MaxStackLength&&this.undoStack.shift()):d.size&&!f.size&&(e={id:`${a}-${this.uid}`,data:ye.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 i=this.undoStack.filter(a=>a.scenePath===t).length,o=this.redoStack.filter(a=>a.scenePath===t).length;return this.emitUndoStepsUpdate(i),this.emitRedoStepsUpdate(o),this.reportStackLength("undo-final",i,o),i}finally{this.endGlobalStackTransaction()}}redo(t){this.beginGlobalStackTransaction();try{let e=this.redoStack.length-1;for(;e>=0;){const i=this.redoStack[e];if(i.scenePath===t){const o=i.id;i&&(this.undoStack.push(i),i.data&&this.refreshPlugin(i,!0));const a=this.redoStack.findIndex(c=>c.id===o);a!==-1&&this.redoStack.splice(a,1);break}e--}const r=this.undoStack.filter(i=>i.scenePath===t).length,n=this.redoStack.filter(i=>i.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()}destroy(){this.destroyed||(this.onChangeScene.cancel(),this.disposeViewTickers("plugin-destroyed"),this.undoStack.customSplice(0),this.redoStack.customSplice(0))}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(){if(this.destroyed)return;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===nr.Update)switch(r==null?void 0:r.toolsType){case q.Text:{if(n!=null&&n.opt&&(r!=null&&r.opt)){const o=ye.omit(n.opt,["uid","workState"]),a=ye.omit(r.opt,["uid","workState"]);if(t&&ye.isEqual(o,a))return!0;n.opt.workState!==de.Done&&(n.opt.workState=de.Done),r.opt.workState!==de.Done&&(r.opt.workState=de.Done)}break}}else if(e===nr.Draw||e===nr.Delete)switch(r==null?void 0:r.toolsType){case q.Text:{if(r!=null&&r.opt){const o=r.opt.text;if(t&&!o)return!0;r.opt.workState!==de.Done&&(r.opt.workState=de.Done)}break}}return!1}normalizeUndoSnapshotValue(t,e){var n,i;if(!e)return e;if(((i=(n=this.collector)==null?void 0:n.getLocalId)==null?void 0:i.call(n,t))===Le||e.toolsType===q.Selector)return;const r=Uye(e);return r.status==="unrecoverable"?ye.cloneDeep(e):r.value}diffFun(t,e,r=!0,n=this.excludeIds,i){const o=new Set,a=t.keys(),c=e.keys();for(const l of a){if(!bp(l,n,i))continue;const u=this.normalizeUndoSnapshotValue(l,t.get(l)),h=this.normalizeUndoSnapshotValue(l,e.get(l));if(!(!u&&!h)){if(u&&h){if(ye.isEqual(h,u)||this.especialDiff(r,nr.Update,h,u))continue;o.add({dataType:nr.Update,key:l,data:[u,h]});continue}this.especialDiff(r,nr.Delete,u)||u&&o.add({dataType:nr.Delete,key:l,data:u})}}for(const l of c){if(!bp(l,n,i))continue;const u=this.normalizeUndoSnapshotValue(l,e.get(l));if(u&&!t.has(l)){if(this.especialDiff(r,nr.Draw,u))continue;o.add({dataType:nr.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,f,g,y,S,b,I,N,T,p,m,v,M,k;let r;const{scenePath:n}=t,i=t.data;if(!i||!this.collector)return;const a={...this.collector.getStorageData(this.viewId,n)||{}};let c=!1;for(const E of i.values()){const{dataType:D,data:P,key:z}=E,j=this.collector.getStorageData(this.viewId,n),A=j&&Object.keys(j)||[];switch(D){case nr.Draw:if(r=e?this.isDrawEffectiveScene(E,A):this.isDeleteEffectiveScene(E,A),r)if(e&&!Array.isArray(P)){if((l=P.updateNodeOpt)!=null&&l.useAnimation&&(P.updateNodeOpt.useAnimation=!1),((u=this.collector)==null?void 0:u.getLocalId(z))===Le&&((h=this.collector)!=null&&h.isOwn(E.key))){const R=P.selectIds;if(R){const L=A.filter(Y=>{var H,ie;return((H=this.collector)==null?void 0:H.getLocalId(Y))===Le&&!((ie=this.collector)!=null&&ie.isOwn(Y))}).map(Y=>{var H;return(H=this.collector)==null?void 0:H.storage[this.viewId][n][Y]});let W=!1;for(const Y of L)for(let H=0;H<R.length;H++)(d=Y==null?void 0:Y.selectIds)!=null&&d.includes(R[H])&&(delete R[H],W=!0);W&&(P.selectIds=R.filter(Y=>!!Y))}}a[E.key]=P,c=!0}else!e&&!Array.isArray(E.data)&&(delete a[E.key],c=!0);break;case nr.Delete:if(r=e?this.isDeleteEffectiveScene(E,A):this.isDrawEffectiveScene(E,A),r){if(e&&!Array.isArray(P))delete a[z],c=!0;else if(!e&&!Array.isArray(P)){if((f=P.updateNodeOpt)!=null&&f.useAnimation&&(P.updateNodeOpt.useAnimation=!1),((g=this.collector)==null?void 0:g.getLocalId(E.key))===Le&&((y=this.collector)!=null&&y.isOwn(E.key))){const R=P.selectIds;if(R){const L=A.filter(Y=>{var H,ie;return((H=this.collector)==null?void 0:H.getLocalId(Y))===Le&&!((ie=this.collector)!=null&&ie.isOwn(Y))}).map(Y=>{var H;return(H=this.collector)==null?void 0:H.storage[this.viewId][n][Y]});let W=!1;for(const Y of L)for(let H=0;H<R.length;H++)(S=Y==null?void 0:Y.selectIds)!=null&&S.includes(R[H])&&(delete R[H],W=!0);W&&(P.selectIds=R.filter(Y=>!!Y))}}a[E.key]=P,c=!0}}break;case nr.Update:if(r=e?this.isNewEffectiveScene(E,A):this.isOldEffectiveScene(E,A),r){if(e&&Array.isArray(P)&&P.length===2){const R=P[1];if((b=R.updateNodeOpt)!=null&&b.useAnimation&&(R.updateNodeOpt.useAnimation=!1),((I=this.collector)==null?void 0:I.getLocalId(E.key))===Le&&((N=this.collector)!=null&&N.isOwn(E.key))){const L=R.selectIds;if(L){const W=A.filter(H=>{var ie,O;return((ie=this.collector)==null?void 0:ie.getLocalId(H))===Le&&!((O=this.collector)!=null&&O.isOwn(H))}).map(H=>{var ie;return(ie=this.collector)==null?void 0:ie.storage[this.viewId][n][H]});let Y=!1;for(const H of W)for(let ie=0;ie<L.length;ie++)H!=null&&H.selectIds&&((T=H.selectIds)!=null&&T.includes(L[ie]))&&(delete L[ie],Y=!0);Y&&(R.selectIds=L.filter(H=>!!H))}}a[z]=R,c=!0}else if(!e&&Array.isArray(P)&&P.length===2){const R=P[0];if((p=R.updateNodeOpt)!=null&&p.useAnimation&&(R.updateNodeOpt.useAnimation=!1),((m=this.collector)==null?void 0:m.getLocalId(E.key))===Le&&((v=this.collector)!=null&&v.isOwn(E.key))){const L=R.selectIds;if(L){const W=A.filter(H=>{var ie,O;return((ie=this.collector)==null?void 0:ie.getLocalId(H))===Le&&!((O=this.collector)!=null&&O.isOwn(H))}).map(H=>{var ie;return(ie=this.collector)==null?void 0:ie.storage[this.viewId][n][H]});let Y=!1;for(const H of W)for(let ie=0;ie<L.length;ie++)H!=null&&H.selectIds&&H.selectIds.includes(L[ie])&&(delete L[ie],Y=!0);Y&&(R.selectIds=L.filter(H=>!!H))}}a[E.key]=R,c=!0}}break}}if(c){const E=this.collector.plugin,D=(M=E==null?void 0:E.getAttributesValue)==null?void 0:M.call(E,[Jr.namespace]),P=(k=E==null?void 0:E.getAttributesValue)==null?void 0:k.call(E,[Jr.namespace,this.viewId]);D?P?E==null||E.updateAttributes([Jr.namespace,this.viewId,n],a):E==null||E.updateAttributes([Jr.namespace,this.viewId],{[n]:a}):E==null||E.updateAttributes([Jr.namespace],{[this.viewId]:{[n]:a}})}}};x(Xr,"sdkCallBack"),x(Xr,"MaxStackLength",He.undoRedo.maxStackLength),x(Xr,"waitTime",100);let Ku=Xr;const Xwe=(s,t)=>({...s,...t}),Jp=(s,...t)=>t.reduce((e,r)=>({images:Xwe(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}}),s),ia={[q.Selector]:{applianceKey:De.selector,classSuffix:"selector",hostClassName:"cursor-selector"},[q.Clicker]:{applianceKey:De.clicker,classSuffix:"clicker",hostClassName:"cursor-clicker"},[q.Text]:{applianceKey:De.text,classSuffix:"text",hostClassName:"cursor-text"},[q.Pencil]:{applianceKey:De.pencil,classSuffix:"pencil",hostClassName:"cursor-pencil"},[q.LaserPen]:{applianceKey:De.laserPen,classSuffix:"laser-pen",hostClassName:"cursor-pencil"},[q.Arrow]:{applianceKey:De.arrow,classSuffix:"arrow",hostClassName:"cursor-arrow"},[q.Straight]:{applianceKey:De.straight,classSuffix:"straight",hostClassName:"cursor-straight"},[q.Rectangle]:{applianceKey:De.rectangle,classSuffix:"rectangle",hostClassName:"cursor-rectangle"},[q.Ellipse]:{applianceKey:De.ellipse,classSuffix:"ellipse",hostClassName:"cursor-ellipse"},[q.Star]:{applianceKey:or.star,classSuffix:"star",hostClassName:"cursor-shape"},[q.Polygon]:{applianceKey:or.polygon,classSuffix:"polygon",hostClassName:"cursor-shape"},[q.SpeechBalloon]:{applianceKey:or.speechBalloon,classSuffix:"speech-balloon",hostClassName:"cursor-shape"},[q.Eraser]:{applianceKey:De.eraser,classSuffix:"eraser",hostClassName:"cursor-eraser"},[q.PencilEraser]:{applianceKey:De.pencilEraser,classSuffix:"pencil-eraser",hostClassName:"cursor-eraser"},[q.BitMapEraser]:{applianceKey:or.bitMapEraser,classSuffix:"bitmap-eraser",hostClassName:"cursor-eraser"}},Jwe={[q.Selector]:De.selector,[q.Clicker]:De.clicker,[q.Text]:De.text,[q.Pencil]:De.pencil,[q.Arrow]:De.arrow,[q.Straight]:De.straight,[q.Rectangle]:De.rectangle,[q.Ellipse]:De.ellipse,[q.Eraser]:De.eraser,[q.PencilEraser]:De.pencilEraser};function _we(s,t){if(!(!s||t===void 0)&&s.currentApplianceName!==De.laserPointer)return t===q.LaserPen?s.currentApplianceName===De.pencil&&s.useLaserPen?ia[t]:void 0:t===q.Star||t===q.Polygon||t===q.SpeechBalloon?s.currentApplianceName===De.shape?ia[t]:void 0:t===q.BitMapEraser?s.currentApplianceName===De.pencilEraser?ia[t]:void 0:Jwe[t]===s.currentApplianceName?ia[t]:void 0}class rM{constructor(t){x(this,"options");this.options=cd(t)}getAppearance(t){return this.options.appearance[t]||ma[t]}getLocal(t){var i;const e=ma[t],r=this.getAppearance(t),n=Jp(e,e.local,r,r.local);return{...n,size:n.size||e.local.size,fallback:((i=r.local)==null?void 0:i.fallback)||"auto"}}getSynced(t){const e=ma[t],r=this.getAppearance(t);return Jp(e,e.synced,r,r.synced)}getSyncedEnableShowName(t){return vpe(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 _p(s){const t=s.trim().toLowerCase();return t.startsWith("data:image/svg+xml")||/\.svg(?:[?#]|$)/i.test(t)}function Pd(s){const t=s.highResolution;if(!(!t||t===s.standardResolution||_p(s.standardResolution)||_p(t)))return t}function eSe(s){var c,l;const t=Math.round(-s.offset.x),e=Math.round(s.size.height-s.offset.y),r=s.fallback,n=`url("${s.images.standardResolution}") ${t} ${e}, ${r}`,i=Pd(s.images);if(!i)return n;const o=`image-set(url("${s.images.standardResolution}") 1x, url("${i}") 2x) ${t} ${e}, ${r}`,a=`-webkit-image-set(url("${s.images.standardResolution}") 1x, url("${i}") 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}const nM=5e3,iM=128*1024*1024,sM=128,tSe=5e3;function rSe(s,t){if(t.activeCount!==0||t.estimatedBytes!==0||t.closeErrorCount!==0)return"error";if(s.activeCount>0||t.totalRetiredCount>0||t.totalReleasedCount>0)return"info"}class nSe{constructor(t={}){x(this,"pending",new Set);x(this,"awaitingPaint",new Set);x(this,"entries",new Map);x(this,"timeoutMs");x(this,"memoryPressureBytes");x(this,"memoryPressureCount");x(this,"memoryPressureReportIntervalMs");x(this,"scheduler");x(this,"onCloseError");x(this,"onScheduleError");x(this,"onTimeout");x(this,"onMemoryPressure");x(this,"activeEstimatedBytes",0);x(this,"peakActiveCount",0);x(this,"peakEstimatedBytes",0);x(this,"totalRetiredCount",0);x(this,"totalReleasedCount",0);x(this,"watchdogReleasedCount",0);x(this,"closeErrorCount",0);x(this,"lastMemoryPressureReportAt",-1/0);x(this,"frameHandle");x(this,"watchdogHandle");x(this,"destroyed",!1);x(this,"onFrame",()=>{if(this.frameHandle=void 0,!this.destroyed){for(const t of[...this.awaitingPaint])this.releaseEntry(t);this.awaitingPaint=this.pending,this.pending=new Set,this.entries.size?this.ensureFrame():this.stopSchedulersWhenEmpty()}});x(this,"onWatchdog",()=>{var o;if(this.watchdogHandle=void 0,this.destroyed)return;const t=this.scheduler.now(),e=new Set;let r=0,n=0,i=0;for(const a of[...this.entries.values()])a.deadlineAt<=t&&(e.add(a.viewId),r+=1,n+=a.estimatedBytes,i=Math.max(i,t-a.createdAt),this.releaseEntry(a));e.size&&(this.watchdogReleasedCount+=r,(o=this.onTimeout)==null||o.call(this,{viewIds:e,releasedCount:r,releasedEstimatedBytes:n,oldestAgeMs:i,snapshot:this.getMemorySnapshot()})),this.entries.size?this.ensureWatchdog():this.stopSchedulersWhenEmpty()});this.timeoutMs=t.timeoutMs??nM,this.memoryPressureBytes=t.memoryPressureBytes??iM,this.memoryPressureCount=t.memoryPressureCount??sM,this.memoryPressureReportIntervalMs=t.memoryPressureReportIntervalMs??tSe,this.scheduler={requestFrame:e=>requestAnimationFrame(e),cancelFrame:e=>cancelAnimationFrame(e),setTimer:(e,r)=>setTimeout(e,r),clearTimer:e=>clearTimeout(e),now:()=>Date.now(),...t.scheduler},this.onCloseError=t.onCloseError,this.onScheduleError=t.onScheduleError,this.onTimeout=t.onTimeout,this.onMemoryPressure=t.onMemoryPressure}retire(t,e){if(this.destroyed){this.closeBitmap(t,e);return}if(this.entries.has(e))return;const r=this.scheduler.now(),n={bitmap:e,viewId:t,createdAt:r,deadlineAt:r+this.timeoutMs,estimatedBytes:this.estimateBitmapBytes(e)};this.entries.set(e,n),this.pending.add(n),this.activeEstimatedBytes+=n.estimatedBytes,this.totalRetiredCount+=1,this.peakActiveCount=Math.max(this.peakActiveCount,this.entries.size),this.peakEstimatedBytes=Math.max(this.peakEstimatedBytes,this.activeEstimatedBytes),this.reportMemoryPressure(r),this.ensureWatchdog(),this.ensureFrame()}getMemorySnapshot(){const t=this.scheduler.now(),e=new Map;let r=0;for(const i of this.entries.values()){const o=Math.max(0,t-i.createdAt);r=Math.max(r,o);const a=e.get(i.viewId)||{activeCount:0,estimatedBytes:0,oldestAgeMs:0};a.activeCount+=1,a.estimatedBytes+=i.estimatedBytes,a.oldestAgeMs=Math.max(a.oldestAgeMs,o),e.set(i.viewId,a)}const n=[...e.entries()].map(([i,o])=>({viewId:i,...o})).sort((i,o)=>i.viewId.localeCompare(o.viewId));return{activeCount:this.entries.size,estimatedBytes:this.activeEstimatedBytes,peakActiveCount:this.peakActiveCount,peakEstimatedBytes:this.peakEstimatedBytes,totalRetiredCount:this.totalRetiredCount,totalReleasedCount:this.totalReleasedCount,watchdogReleasedCount:this.watchdogReleasedCount,closeErrorCount:this.closeErrorCount,oldestAgeMs:r,activeViews:n,destroyed:this.destroyed}}closeNow(t,e){const r=this.entries.get(e);r?this.releaseEntry(r):this.closeBitmap(t,e),this.stopSchedulersWhenEmpty()}releaseView(t){for(const e of[...this.entries.values()])e.viewId===t&&this.releaseEntry(e);this.stopSchedulersWhenEmpty()}destroy(){if(this.destroyed)return this.getMemorySnapshot();this.destroyed=!0,this.cancelSchedulers();for(const t of[...this.entries.values()])this.releaseEntry(t);return this.getMemorySnapshot()}ensureFrame(){var t;if(!(this.frameHandle!==void 0||!this.entries.size))try{this.frameHandle=this.scheduler.requestFrame(this.onFrame)}catch(e){(t=this.onScheduleError)==null||t.call(this,"request-frame",e,this.getMemorySnapshot())}}ensureWatchdog(){var e;if(this.watchdogHandle!==void 0||!this.entries.size)return;let t=1/0;for(const r of this.entries.values())t=Math.min(t,r.deadlineAt);try{this.watchdogHandle=this.scheduler.setTimer(this.onWatchdog,Math.max(0,t-this.scheduler.now()))}catch(r){(e=this.onScheduleError)==null||e.call(this,"set-watchdog",r,this.getMemorySnapshot());for(const n of[...this.entries.values()])this.releaseEntry(n)}}releaseEntry(t){this.entries.delete(t.bitmap)&&(this.pending.delete(t),this.awaitingPaint.delete(t),this.activeEstimatedBytes=Math.max(0,this.activeEstimatedBytes-t.estimatedBytes),this.closeBitmap(t.viewId,t.bitmap))}closeBitmap(t,e){var r;try{e.close(),this.totalReleasedCount+=1}catch(n){this.closeErrorCount+=1,(r=this.onCloseError)==null||r.call(this,t,n,this.getMemorySnapshot())}}estimateBitmapBytes(t){const e=Number.isFinite(t.width)?Math.max(0,t.width):0,r=Number.isFinite(t.height)?Math.max(0,t.height):0,n=Math.ceil(e*r*4);return Number.isSafeInteger(n)?n:0}reportMemoryPressure(t){var e;this.entries.size<this.memoryPressureCount&&this.activeEstimatedBytes<this.memoryPressureBytes||t-this.lastMemoryPressureReportAt<this.memoryPressureReportIntervalMs||(this.lastMemoryPressureReportAt=t,(e=this.onMemoryPressure)==null||e.call(this,this.getMemorySnapshot()))}stopSchedulersWhenEmpty(){this.entries.size||this.cancelSchedulers()}cancelSchedulers(){this.frameHandle!==void 0&&(this.scheduler.cancelFrame(this.frameHandle),this.frameHandle=void 0),this.watchdogHandle!==void 0&&(this.scheduler.clearTimer(this.watchdogHandle),this.watchdogHandle=void 0)}}const em=3,tm=128;function iSe(){return globalThis.__APPLIANCE_IMAGE_BITMAP_PIXEL_DIAGNOSTIC__===!0}class Yi{constructor(t){x(this,"internalMsgEmitter");x(this,"control");x(this,"mainView");x(this,"mainViewOrigin");x(this,"appViewOrigins",new Map);x(this,"appViews",new Map);x(this,"renderImageBitmapRetirement");x(this,"renderImageBitmapRecoveryViews",new Set);x(this,"renderImageBitmapPixelDiagnosticCanvas");x(this,"undoTickerStart",(t,e,r)=>{const n=this.getView(e);n&&n.displayer&&n.focusScenePath&&n.displayer.commiter.undoTickerStart(t,n.focusScenePath,r)});x(this,"addExcludeIds",(t,e)=>{const r=this.getView(e);r&&r.displayer&&r.focusScenePath&&r.displayer.commiter.addExcludeIds(t)});x(this,"onAckRenderUndoTicker",(t,e,r,n)=>{const i=this.getView(e);if(!(i!=null&&i.displayer)||!i.focusScenePath)return;const o=r||i.focusScenePath;i.displayer.commiter.ackRender(t,o,n)});x(this,"onAckStorageUndoTicker",(t,e,r,n,i)=>{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,i)});x(this,"onCollectExpectedWorkIds",(t,e,r,n)=>{const i=this.getView(e);if(!(i!=null&&i.displayer)||!i.focusScenePath)return;const o=n||i.focusScenePath;i.displayer.commiter.collectExpectedWorkIds(t,o,r)});x(this,"onFinalizeRequested",(t,e,r,n)=>{const i=this.getView(e);if(!(i!=null&&i.displayer)||!i.focusScenePath)return;const o=n||i.focusScenePath;i.displayer.commiter.finalizeRequested(t,o,r)});x(this,"onReopenStorageAck",(t,e,r,n)=>{const i=this.getView(e);if(!(i!=null&&i.displayer)||!i.focusScenePath)return;const o=n||i.focusScenePath;i.displayer.commiter.reopenStorageAck(t,o,r)});x(this,"onCancelUndoTicker",(t,e,r)=>{const n=this.getView(e);if(!(n!=null&&n.displayer)||!n.focusScenePath)return;const i=r||n.focusScenePath;n.displayer.commiter.cancelUndoTicker(t,e,i)});const{control:e,internalMsgEmitter:r}=t;this.control=e,this.internalMsgEmitter=r,this.renderImageBitmapRetirement=new nSe({onCloseError:(n,i,o)=>{var a,c;(c=(a=this.control.logger)==null?void 0:a.error)==null||c.call(a,`[Appliance]: [render-image-bitmap-memory] stage=close-error viewId=${n} activeCount=${o.activeCount} estimatedBytes=${o.estimatedBytes} closeErrorCount=${o.closeErrorCount} error=${i instanceof Error?i.message:String(i)}`)},onScheduleError:(n,i,o)=>{var a,c;(c=(a=this.control.logger)==null?void 0:a.error)==null||c.call(a,`[Appliance]: [render-image-bitmap-memory] stage=${n} activeCount=${o.activeCount} estimatedBytes=${o.estimatedBytes} error=${i instanceof Error?i.message:String(i)}`)},onMemoryPressure:n=>{var i,o;(o=(i=this.control.logger)==null?void 0:i.warn)==null||o.call(i,`[Appliance]: [render-image-bitmap-memory] stage=pressure activeCount=${n.activeCount} estimatedBytes=${n.estimatedBytes} peakActiveCount=${n.peakActiveCount} peakEstimatedBytes=${n.peakEstimatedBytes} oldestAgeMs=${n.oldestAgeMs} countThreshold=${sM} bytesThreshold=${iM}`)},onTimeout:n=>{var i,o;(o=(i=this.control.logger)==null?void 0:i.error)==null||o.call(i,`[Appliance]: [render-image-bitmap-memory] stage=watchdog-timeout viewIds=${[...n.viewIds].join(",")} timeoutMs=${nM} releasedCount=${n.releasedCount} releasedEstimatedBytes=${n.releasedEstimatedBytes} oldestAgeMs=${n.oldestAgeMs} remainingCount=${n.snapshot.activeCount} remainingEstimatedBytes=${n.snapshot.estimatedBytes}`);for(const a of n.viewIds)!this.getView(a)||this.renderImageBitmapRecoveryViews.has(a)||(this.renderImageBitmapRecoveryViews.add(a),this.control.refreshViewRender(a).catch(c=>{var l,u;(u=(l=this.control.logger)==null?void 0:l.error)==null||u.call(l,`[Appliance]: render ImageBitmap timeout recovery failed; viewId=${a}; error=${c instanceof Error?c.message:String(c)}`)}).finally(()=>this.renderImageBitmapRecoveryViews.delete(a)))}}),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}cancelViewUndoTicker(t){var r;const e=this.getView(t);(r=e==null?void 0:e.displayer)==null||r.commiter.cancelViewUndoTicker()}undo(){const t=this.focuedView;let e=0;if(t&&this.control.canAcceptLocalMutation(t.id)){const r=t.focusScenePath;e=t.displayer.commiter.undo(r)||0}return e}redo(){const t=this.focuedView;let e=0;if(t&&this.control.canAcceptLocalMutation(t.id)){const r=t.focusScenePath;e=t.displayer.commiter.redo(r)||0}return e}validator(t,e,r){var o;const n=ye.clone(t[e]),i=ye.clone(r);e==="focusScenePath"&&!ye.isEqual(n,i)&&(this.control.backgroundImageLoadCoordinator.cancelByViewScene(t.id,n),this.control.internalSceneChange(t.id,i),(o=t.displayer)==null||o.commiter.onChangeScene()),e==="cameraOpt"&&!ye.isEqual(n,i)&&this.control.internalCameraChange(t.id,i)}destroyAppView(t,e=!1){var n;this.disposeViewRenderImageBitmaps(t),this.renderImageBitmapRecoveryViews.delete(t),this.control.backgroundImageLoadCoordinator.cancelByViewScene(t),this.control.destroySceneChange(t),this.control.worker.cameraUpdateDestroy(t,!1);const r=this.appViews.get(t);r&&(r.displayer.commiter.disposeViewTickers("view-destroyed"),(n=this.control.selectorApi)==null||n.disposeView(t),this.control.textEditorManager.clear(t,e),r.displayer.destroy(),this.appViewOrigins.delete(t),this.appViews.delete(t))}createMianView(t){this.mainView&&this.disposeViewRenderImageBitmaps(Fe),this.mainViewOrigin=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;this.appViews.has(e)&&this.disposeViewRenderImageBitmaps(e),this.appViewOrigins.set(e,t);const r=new Proxy(t,{set:(n,i,o)=>(this.worker.isActive&&this.validator(n,i,o),n[i]=o,!0)});this.appViews.set(e,r)}isAppView(t){return t!==Fe&&this.appViews.has(t)}getPreferredFocusedViewId(){return this.focuedViewId||Fe}getView(t){var e;return t===Fe?this.mainView:(e=this.appViews)==null?void 0:e.get(t)}resolveView(t){const e=t||this.focuedViewId||Fe,r=this.getView(e);return!t&&!r&&e!==Fe?{viewId:Fe,view:this.getView(Fe)}:{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 i=this.getViewElement(n);if(!i)return;const o=i.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}getAuthoritativeScenePath(t){return this.getCurScenePath(t)}getAllViews(){return[this.mainView,...this.appViews.values()]}setViewScenePath(t,e){var r;if(t===Fe&&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)}}setViewScenePathBeforeRenderInit(t,e){var i,o;const r=t===Fe?this.mainViewOrigin:this.appViewOrigins.get(t);if(!r)return!1;const n=r.focusScenePath!==e;return r.focusScenePath=e,n&&((o=(i=r.displayer)==null?void 0:i.commiter)==null||o.onChangeScene()),!0}setViewData(t,e){var r;if(t===Fe&&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===Fe?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===q.Text&&this.activeTextEditor(t),this.control.cursor.onFocusViewChange(),this.focuedView&&this.focuedView.displayer.commiter.onFocusView()}setViewFocusScenePath(t,e){var n;let r;t===Fe?r=this.mainView:r=(n=this.appViews)==null?void 0:n.get(t),r&&(r.focusScenePath=e)}destroy(){var o,a,c,l,u,h;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),this.mainView&&(this.disposeViewRenderImageBitmaps(this.mainView.id),this.mainView.displayer.commiter.disposeViewTickers("view-destroyed"),(o=this.control.selectorApi)==null||o.disposeView(this.mainView.id)),(a=this.mainView)==null||a.displayer.destroy(),this.control.destroyMiniMap(Fe),this.appViews.forEach(d=>{this.destroyAppView(d.id,!0),this.control.destroyMiniMap(d.id)});const t=this.getRenderImageBitmapMemoryState(),e=this.renderImageBitmapRetirement.destroy(),r=e.closeErrorCount-t.closeErrorCount,n=`[Appliance]: [render-image-bitmap-memory] stage=destroy releasedCount=${t.activeCount-e.activeCount} releasedEstimatedBytes=${t.estimatedBytes-e.estimatedBytes} activeCount=${e.activeCount} estimatedBytes=${e.estimatedBytes} peakActiveCount=${e.peakActiveCount} peakEstimatedBytes=${e.peakEstimatedBytes} totalRetiredCount=${e.totalRetiredCount} totalReleasedCount=${e.totalReleasedCount} watchdogReleasedCount=${e.watchdogReleasedCount} closeErrorCount=${e.closeErrorCount} closeErrorsDuringDestroy=${r}`,i=rSe(t,e);i==="error"?(l=(c=this.control.logger)==null?void 0:c.error)==null||l.call(c,n):i==="info"&&((h=(u=this.control.logger)==null?void 0:u.info)==null||h.call(u,n)),this.renderImageBitmapRecoveryViews.clear()}setFocuedViewCameraOpt(t){if(this.focuedView){const e=this.focuedView.cameraOpt;ye.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}inspectRenderImageBitmapPixels(t,e,r){const n=Math.min(1,tm/Math.max(e,1),tm/Math.max(r,1)),i=Math.max(1,Math.round(e*n)),o=Math.max(1,Math.round(r*n)),a=this.renderImageBitmapPixelDiagnosticCanvas||document.createElement("canvas");this.renderImageBitmapPixelDiagnosticCanvas=a,a.width!==i&&(a.width=i),a.height!==o&&(a.height=o);const c=a.getContext("2d");if(!c)throw new Error("render ImageBitmap pixel probe unavailable");c.clearRect(0,0,i,o),c.drawImage(t,0,0,i,o);const l=c.getImageData(0,0,i,o).data;let u=0,h=0;for(let d=0;d<l.length;d+=4){const f=l[d],g=l[d+1],y=l[d+2];l[d+3]!==0&&(u+=1,(f!==0||g!==0||y!==0)&&(h+=1))}return{sampleWidth:i,sampleHeight:o,visiblePixels:u,nonBlackPixels:h}}render(t){var n,i,o,a,c,l,u;let e,r=!1;for(const h of t){const{rect:d,imageBitmap:f,isFullFrameImageBitmap:g,isClear:y,isUnClose:S,drawCanvas:b,clearCanvas:I,viewId:N,viewGeneration:T,frameSequence:p,taskId:m}=h,v=(n=this.getView(N))==null?void 0:n.displayer;let M=!1;try{if(!(y&&I!==_e.None||b!==void 0&&b!==_e.None))continue;if(!v)throw new Error(`render View is unavailable: ${N}`);if(!d)throw new Error(`render rect is unavailable: ${N}`);const{dpr:E,canvasBgRef:D,canvasFloatRef:P,canvasServiceFloatRef:z,canvasTopRef:j}=v,A=Math.floor(d.w*E),R=Math.floor(d.h*E),L=d.x*E,W=d.y*E,Y=H=>{let ie;switch(H){case _e.TopFloat:ie=j==null?void 0:j.current;break;case _e.Float:ie=P.current;break;case _e.ServiceFloat:ie=z.current;break;case _e.Bg:ie=D.current;break;default:throw new Error(`render canvas target is unavailable: ${N}/${String(H)}`)}if(!ie)throw new Error(`render canvas is unavailable: ${N}/${String(H)}`);const O=ie.getContext("2d");if(!O)throw new Error(`render 2d context is unavailable: ${N}/${String(H)}`);return O};if(y&&I!==_e.None){Y(I).clearRect(L,W,A,R);continue}if(b!==void 0&&b!==_e.None){if(!f)throw new Error(`render ImageBitmap is unavailable: ${N}/${String(b)}`);const H=Y(b);let ie;const O=iSe()&&g&&b===_e.Bg;if(O)try{ie=this.inspectRenderImageBitmapPixels(f,f.width,f.height)}catch(V){(o=(i=this.control.logger)==null?void 0:i.warn)==null||o.call(i,`[Appliance]: [render-image-bitmap] stage=pixel-diagnostic-failed source=bitmap viewId=${N} generation=${T??"unknown"} taskId=${m??"unknown"} sequence=${p??"unknown"} error=${V instanceof Error?V.message:String(V)}`)}if(g?(H.clearRect(0,0,H.canvas.width,H.canvas.height),H.drawImage(f,0,0,H.canvas.width,H.canvas.height)):H.drawImage(f,0,0,A,R,L,W,A,R),O&&ie)try{const V=this.inspectRenderImageBitmapPixels(H.canvas,H.canvas.width,H.canvas.height);(ie.visiblePixels>0&&V.visiblePixels===0||ie.nonBlackPixels>0&&V.nonBlackPixels===0)&&((c=(a=this.control.logger)==null?void 0:a.warn)==null||c.call(a,`[Appliance]: [render-image-bitmap] stage=destination-pixel-loss viewId=${N} generation=${T??"unknown"} taskId=${m??"unknown"} sequence=${p??"unknown"} sourceVisible=${ie.visiblePixels} destinationVisible=${V.visiblePixels} sourceNonBlack=${ie.nonBlackPixels} destinationNonBlack=${V.nonBlackPixels}`))}catch(V){(u=(l=this.control.logger)==null?void 0:l.warn)==null||u.call(l,`[Appliance]: [render-image-bitmap] stage=pixel-diagnostic-failed source=destination viewId=${N} generation=${T??"unknown"} taskId=${m??"unknown"} sequence=${p??"unknown"} error=${V instanceof Error?V.message:String(V)}`)}M=!0}}catch(k){r||(e=k,r=!0)}finally{f&&!S&&(M?this.retireRenderImageBitmap(N,f):this.renderImageBitmapRetirement.closeNow(N,f))}}if(r)throw e}retireRenderImageBitmap(t,e){e&&this.renderImageBitmapRetirement.retire(t,e)}disposeViewRenderImageBitmaps(t){this.renderImageBitmapRetirement.releaseView(t)}getRenderImageBitmapMemoryState(){return this.renderImageBitmapRetirement.getMemorySnapshot()}showFloatBar(t,e,r){const n=this.getView(t),i=n==null?void 0:n.displayer.vDom;i&&i.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),i=n==null?void 0:n.displayer.vDom;if(i){i.updateTextEditorInfo(e,r);return}r==null||r()}renderTextEditorInfo(t,e,r){const n=this.getView(t),i=n==null?void 0:n.displayer.vDom;if(i){i.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)}}x(Yi,"defaultCameraOpt",{centerX:0,centerY:0,scale:1}),x(Yi,"defaultScreenCanvasOpt",{autoRender:!1,contextType:"2d"}),x(Yi,"defaultLayerOpt",{offscreen:!0,handleEvent:!1,depth:!1});class oM{constructor(t,e,r){x(this,"control");x(this,"internalMsgEmitter");x(this,"commiter");x(this,"cachePoint");x(this,"cacheCursorPoint");x(this,"active",!0);x(this,"toolsKey");x(this,"activePointers",new Set);x(this,"currentDrawingPointerId");x(this,"pointerDrawingSession",0);x(this,"currentPointerDrawingSession");x(this,"pointerDonePromise");x(this,"isTouchDrawing",!1);x(this,"cursorMouseMove");x(this,"cursorMouseMoveDebounced");x(this,"cursorMouseMoveThrottled");x(this,"cursorMouseMoveFun");x(this,"cursorEventElement");x(this,"eventTargetTouchAction");x(this,"appliedCursorClassNames",[]);x(this,"pendingDpr");x(this,"dprMediaQuery");x(this,"dprMediaQueryListener");x(this,"pointLimitStopPending",!1);x(this,"localBitmapEraserPointCount",0);x(this,"_transferControlToOffscreenCanvas");x(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)});x(this,"keydown",t=>{t.stopPropagation(),t.stopImmediatePropagation(),this.control.hotkeyManager.colloctHotkey(t)});x(this,"windowBlur",()=>{this.currentDrawingPointerId!==void 0&&this.cancelPointerDrawing("window-blur")});x(this,"visibilitychange",()=>{document.visibilityState==="hidden"&&this.currentDrawingPointerId!==void 0&&this.cancelPointerDrawing("document-hidden")});x(this,"pointerdown",t=>{var e;if(!this.pointerDonePromise){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.localBitmapEraserPointCount=this.isBitmapEraserTool()?1:0,this.currentDrawingPointerId=t.pointerId,this.currentPointerDrawingSession=++this.pointerDrawingSession,this.worker.originalEventLintener(de.Start,r,this.viewId),this.addPointerDocumentEvents())}}}});x(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.checkConsumeCount(e!==void 0))return;this.cachePoint=e,e&&this.worker.originalEventLintener(de.Doing,e,this.viewId)}}});x(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(!this.pointLimitStopPending){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;e?this.finishPointerDone(e):this.cancelPointerDrawing("pointer-up-without-point")}t.pointerType==="touch"&&this.activePointers.size===0&&this.activePointers.clear()}}});x(this,"pointercancel",t=>{this.pointLimitStopPending||this.currentDrawingPointerId!==void 0&&t.pointerId!==this.currentDrawingPointerId||this.cancelPointerDrawing("pointer-cancel")});x(this,"touchstart",t=>{var r;if(this.pointerDonePromise)return;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.localBitmapEraserPointCount=this.isBitmapEraserTool()?1:0,this.isTouchDrawing=!0,this.worker.originalEventLintener(de.Start,e,this.viewId),document.addEventListener("touchmove",this.touchmove,{passive:!1}),document.addEventListener("touchend",this.touchend,!1),document.addEventListener("touchcancel",this.touchcancel,!1))});x(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.checkConsumeCount(e!==void 0)||(this.cachePoint=e,e&&this.worker.originalEventLintener(de.Doing,e,this.viewId))});x(this,"touchend",t=>{if(!this.active||!this.isTouchDrawing||this.pointLimitStopPending)return;if(t.touches.length>0||!this.worker.isAbled()){this.cancelTouchDrawing();return}t.preventDefault();const e=this.getPoint(t)||this.cachePoint;e?this.finishPointerDone(e):(this.clearTouchDocumentEvents(),this.cachePoint=void 0,this.isTouchDrawing=!1,this.localBitmapEraserPointCount=0)});x(this,"touchcancel",()=>{this.pointLimitStopPending||this.cancelTouchDrawing("touch-cancel",!1)});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 Ku(n),this.cursorMouseMoveFun=i=>{const o=this.getPoint(i);this.cacheCursorPoint&&ye.isEqual(o,this.cacheCursorPoint)||(this.cacheCursorPoint=o,o&&this.worker.sendCursorEvent(o,this.viewId))},this.cursorMouseMoveDebounced=ye.debounce(this.cursorMouseMoveFun,this.moveDelayTime,{trailing:!0}),this.cursorMouseMoveThrottled=ye.throttle(this.cursorMouseMoveFun,this.moveDelayTime,{leading:!0}),this.cursorMouseMove=i=>{this.consumeClickerEvent(i),this.control.pluginOptions.extras.cursor.enable?this.cursorMouseMoveThrottled(i):this.cursorMouseMoveDebounced(i)},this.setActive(t.renderControl.isWritable)}consumeClickerEvent(t){var e;return((e=this.worker.getCurrentToolsData())==null?void 0:e.toolsType)!==q.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}requestDprUpdate(t){t===this.dpr&&this.pendingDpr===void 0||this.pendingDpr!==t&&(this.pendingDpr=t,this.worker.updateDpr(this.viewId,t))}commitDprUpdate(t){var e;this.pendingDpr===t&&(this.pendingDpr=void 0),this.dpr!==t&&(this.dpr=t,this.resizeCanvasBackingStore(),(e=this.vDom)==null||e.setDpr(t))}cancelDprUpdate(){this.pendingDpr=void 0}resizeCanvasBackingStore(){var n;if(this.control.isUseOffscreenTransfer)return;const t=this.width*this.dpr,e=this.height*this.dpr,r=[this.canvasBgRef.current,this.canvasFloatRef.current,this.canvasServiceFloatRef.current,(n=this.canvasTopRef)==null?void 0:n.current];for(const i of r)i&&(i.width=t,i.height=e)}observeDpr(){if(this.stopObservingDpr(),typeof window>"u"||!window.matchMedia)return;const t=window.devicePixelRatio||1,e=window.matchMedia(`(resolution: ${t}dppx)`),r=()=>{this.observeDpr(),this.setCanvassStyle()};this.dprMediaQuery=e,this.dprMediaQueryListener=r,e.addEventListener?e.addEventListener("change",r):e.addListener(r)}stopObservingDpr(){const t=this.dprMediaQuery,e=this.dprMediaQueryListener;t&&e&&(t.removeEventListener?t.removeEventListener("change",e):t.removeListener(e)),this.dprMediaQuery=void 0,this.dprMediaQueryListener=void 0}setTransferControlToOffscreenCanvas(t){this._transferControlToOffscreenCanvas={bgCanvas:t.bgCanvas.transferControlToOffscreen(),serviceCanvas:t.serviceCanvas.transferControlToOffscreen(),localCanvas:t.localCanvas.transferControlToOffscreen()}}async resetRenderSurface(){var t;this._transferControlToOffscreenCanvas=void 0,await((t=this.vDom)==null?void 0:t.resetRenderSurface()),this.resizeCanvasBackingStore()}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,i=_we(n,t),o=[],a=e&&r;if(a&&i){o.push(i.hostClassName),o.push(`cursor-tool-${i.classSuffix}`);const h=new rM(this.control.pluginOptions.extras.cursor),d=h.getLocalCursorOwnership(i.applianceKey),f=h.getLocal(i.applianceKey);o.push(d==="custom"?"custom-cursor":"plugin-cursor",`${d==="custom"?"custom-cursor":"plugin-cursor"}-${i.classSuffix}`),this.eventTragetElement&&this.eventTragetElement.style.setProperty("cursor",eSe(f),"important")}this.eventTragetElement&&(this.eventTragetElement.classList.remove(...this.appliedCursorClassNames),o.length&&this.eventTragetElement.classList.add(...o),this.appliedCursorClassNames=o,(!a||!i)&&this.eventTragetElement.style.removeProperty("cursor"))}mountView(){this.setCanvassStyle(),this.observeDpr(),this.control.viewContainerManager.mountView(this.viewId).catch(t=>{var r,n;const e=t instanceof Error?t.message:String(t);(n=(r=this.control.logger)==null?void 0:r.error)==null||n.call(r,`[Appliance]: view mount failed viewId=${this.viewId} error=${e}`)})}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.pointerDonePromise=void 0,this.cancelDprUpdate(),this.stopObservingDpr(),this.cursorMouseMoveDebounced.cancel(),this.cursorMouseMoveThrottled.cancel(),this.commiter.destroy(),this.eventTragetElement&&this.removeDisplayerEvent(this.eventTragetElement),this.vDom=void 0,this.control.cursor.clearViewCursor(this.viewId),this.internalMsgEmitter.removeAllListeners([We.Cursor,this.viewId])}getPoint(t){if(!this.eventTragetElement)return;const e=NMe(t);if(!ye.isNumber(e.x)||!ye.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(){if(this.pointerDonePromise){await this.pointerDonePromise;return}this.cachePoint&&await this.finishPointerDone(this.cachePoint)}finishPointerDone(t,e=0){if(this.pointerDonePromise)return this.pointerDonePromise;const r=this.currentPointerDrawingSession,n=this.viewId,i=this.toolsKey;this.clearPointerDocumentEvents(),this.clearTouchDocumentEvents(),this.cachePoint=void 0,this.activePointers.clear(),this.currentDrawingPointerId=void 0,this.currentPointerDrawingSession=void 0,this.isTouchDrawing=!1,this.localBitmapEraserPointCount=0;let o;try{e>0?o=(async()=>{if(await this.worker.waitForLocalEventQueue(n),this.worker.getLocalInputPointCount(n,i)<e){this.worker.removeDrawingWork(n);return}await this.worker.originalEventLintener(de.Done,t,n)})():o=Promise.resolve(this.worker.originalEventLintener(de.Done,t,n))}catch(c){o=Promise.reject(c)}const a=o.finally(()=>{this.pointerDonePromise===a&&(this.pointerDonePromise=void 0,this.clearPointerDocumentEvents(),this.clearTouchDocumentEvents(),this.cachePoint=void 0,this.activePointers.clear(),this.currentDrawingPointerId=void 0,(r===void 0||r===this.currentPointerDrawingSession)&&(this.currentPointerDrawingSession=void 0),this.isTouchDrawing=!1,this.localBitmapEraserPointCount=0)});return this.pointerDonePromise=a,a.catch(()=>{}),a}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,i=r&&parseInt(r[1])||0;return[n,i]}getContainerOffset(t,e){var i;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(i=t.offsetParent)!=null&&i.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(),this.localBitmapEraserPointCount=0}cancelPointerDrawing(t,e=!1){const r=this.currentDrawingPointerId!==void 0;if(r&&t!=="destroy"&&!e&&this.toolsKey===q.Pencil&&this.cachePoint){this.finishPointerDone(this.cachePoint,em);return}r&&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(t="invalid-touch",e=!0){if(this.isTouchDrawing&&t==="touch-cancel"&&!e&&this.toolsKey===q.Pencil&&this.cachePoint){this.finishPointerDone(this.cachePoint,em);return}this.isTouchDrawing&&(e&&this.worker.unWritable(),this.viewId&&this.worker.removeDrawingWork(this.viewId)),this.clearTouchDocumentEvents(),this.cachePoint=void 0,this.localBitmapEraserPointCount=0,this.isTouchDrawing=!1}suppressNativeTouchGestures(t){var e;((e=this.eventTargetTouchAction)==null?void 0:e.element)!==t&&(this.restoreNativeTouchGestures(),this.eventTargetTouchAction={element:t,value:t.style.getPropertyValue("touch-action"),priority:t.style.getPropertyPriority("touch-action")},t.style.setProperty("touch-action","none","important"))}restoreNativeTouchGestures(t){const e=this.eventTargetTouchAction;!e||t&&e.element!==t||(e.value?e.element.style.setProperty("touch-action",e.value,e.priority):e.element.style.removeProperty("touch-action"),this.eventTargetTouchAction=void 0)}bindDisplayerEvent(t){this.suppressNativeTouchGestures(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.restoreNativeTouchGestures(t),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}isBitmapEraserTool(){const t=this.worker.getCurrentToolsData();return this.toolsKey===q.BitMapEraser&&(t==null?void 0:t.toolsType)===q.BitMapEraser}getFullLayerBitmapEraserMaxInputPoints(){var e;const t=this.worker.getCurrentToolsData();return this.toolsKey!==q.BitMapEraser||(t==null?void 0:t.toolsType)!==q.BitMapEraser?0:Pc((e=t.toolsOpt)==null?void 0:e.fullLayerDoingMaskMaxInputPoints)}checkConsumeCount(t=!0){if(this.pointLimitStopPending)return!0;const e=this.isBitmapEraserTool(),r=e?this.getFullLayerBitmapEraserMaxInputPoints():0;if(e&&t&&Math.max(this.localBitmapEraserPointCount,this.worker.getLocalInputPointCount(this.viewId,q.BitMapEraser))>=r)return this.pointLimitStopPending=!0,this.stopEventHandler().catch(i=>{this.control.logger.error(`[Appliance]: Bitmap Eraser force-Done failed: ${i instanceof Error?i.message:String(i)}`)}).finally(()=>{this.worker.publicMsgEmitter.emit("forceStop",Ds.longBitmapEraser,this.viewId),this.pointLimitStopPending=!1,this.localBitmapEraserPointCount=0}),!0;e&&t&&(this.localBitmapEraserPointCount++,this.localBitmapEraserPointCount>=r&&(this.pointLimitStopPending=!0,Promise.resolve().then(()=>this.stopEventHandler()).catch(i=>{this.control.logger.error(`[Appliance]: Bitmap Eraser force-Done failed: ${i instanceof Error?i.message:String(i)}`)}).finally(()=>{this.worker.publicMsgEmitter.emit("forceStop",Ds.longBitmapEraser,this.viewId),this.pointLimitStopPending=!1,this.localBitmapEraserPointCount=0})));const n=this.worker.getConsumeCount();return this.cachePoint&&this.toolsKey&&this.toolsKey===q.Pencil&&n>this.maxDrawCount?(this.stopEventHandler().catch(i=>{this.control.logger.error(`[Appliance]: Pencil force-Done failed: ${i instanceof Error?i.message:String(i)}`)}).finally(()=>{this.worker.publicMsgEmitter.emit("forceStop",Ds.longPencil,this.viewId)}),!0):!1}}class sSe extends oM{constructor(e,r,n){super(r,n,e);x(this,"_viewId");this._viewId=e}get viewId(){return this._viewId}setViewId(e){this._viewId=e}}class aM extends oM{constructor(t,e){super(t,e,Fe)}get viewId(){return Fe}updateSize(){this.setCanvassStyle()}}const oSe="index-module__Container__nLsM3",aSe="index-module__BackgroundBox__zfthZ",cSe="index-module__BackgroundSvgBox__Fv1ay",lSe="index-module__BackgroundSnapshotContent__NFLAl",uSe="index-module__BackgroundSnapshotBox__NEM-C",hSe="index-module__CanvasBox__j2Xe-",dSe="index-module__FloatCanvas__d1YR7",fSe="index-module__TopFloatCanvas__7IaCw",gSe="index-module__CanvasBoxSub__hcMeK",pSe="index-module__SnapshotBox__--eeE",mSe="index-module__FloatBar__cm-EL",ySe="index-module__RotateBtn__HSSkf",vSe="index-module__ResizeBtn__yjvda",MSe="index-module__CursorBox__2UHvI",wSe="index-module__TextEditorContainer__Qm8KC",SSe="index-module__ResizeTowBox__HOllX",TSe="index-module__FloatBarBtn__FJrOG",mt={Container:oSe,BackgroundBox:aSe,BackgroundSvgBox:cSe,BackgroundSnapshotContent:lSe,BackgroundSnapshotBox:uSe,CanvasBox:hSe,FloatCanvas:dSe,TopFloatCanvas:fSe,CanvasBoxSub:gSe,SnapshotBox:pSe,FloatBar:mSe,RotateBtn:ySe,ResizeBtn:vSe,CursorBox:MSe,TextEditorContainer:wSe,ResizeTowBox:SSe,FloatBarBtn:TSe},ISe={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 At(s){return ISe[s]}const CSe=s=>{const{workIds:t,mananger:e}=s;return Q.createElement("div",{className:"button normal-button",style:{touchAction:"none"},onPointerUp:r=>{r.cancelable&&r.preventDefault(),r.stopPropagation(),r.nativeEvent.stopImmediatePropagation(),Ve.emitMethod(We.MainEngine,Te.DeleteNode,{workIds:t||[Le],viewId:e.viewId})}},Q.createElement("img",{alt:"icon",src:At("delete")}))},bSe=s=>{const{workIds:t,viewId:e}=s;return Q.createElement("div",{className:"button normal-button",onPointerUp:r=>{r.stopPropagation(),Ve.emitMethod(We.MainEngine,Te.CopyNode,{workIds:t||[Le],viewId:e})}},Q.createElement("img",{alt:"icon",src:At("duplicate")}))},rm=s=>{const{icon:t,onPointerUpHandler:e}=s;return Q.createElement("div",{className:"button normal-button",onPointerUp:e},Q.createElement("img",{src:At(t)}))},ESe=s=>{const{open:t,setOpen:e,floatBarRef:r}=s,{floatBarData:n,mananger:i}=Q.useContext(lt),[o,a]=Q.useState([]),c=Q.useMemo(()=>{if(r!=null&&r.current&&ye.isNumber(n==null?void 0:n.y)&&(i!=null&&i.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&&(i==null?void 0:i.height)-r.current.offsetTop-n.y<120){const h={};return h.top="inherit",h.bottom=50,h}}},[r==null?void 0:r.current,n,i]),l=Q.useMemo(()=>t?Q.createElement("div",{className:"image-layer-menu",style:c},Q.createElement(rm,{icon:"to-top",onPointerUpHandler:h=>{h.stopPropagation(),Ve.emitMethod(We.MainEngine,Te.ZIndexNode,{workIds:[Le],layer:Cn.Top,viewId:i==null?void 0:i.viewId})}}),Q.createElement(rm,{icon:"to-bottom",onPointerUpHandler:h=>{h.stopPropagation(),Ve.emitMethod(We.MainEngine,Te.ZIndexNode,{workIds:[Le],layer:Cn.Bottom,viewId:i==null?void 0:i.viewId})}})):null,[t,c]),u=h=>{h.stopPropagation(),h.nativeEvent.stopImmediatePropagation(),e(!t)};return Q.useEffect(()=>{ye.isEqual(n==null?void 0:n.selectIds,o)||n!=null&&n.selectIds&&!ye.isEqual(n==null?void 0:n.selectIds,o)&&(a(n==null?void 0:n.selectIds),e(!1))},[t,n,o,e]),Q.createElement("div",{className:`button normal-button ${t&&"active"}`,onPointerUp:u},l,Q.createElement("img",{alt:"icon",src:At(t?"layer-pressed":"layer")}))},mo=s=>{s.stopPropagation(),s.nativeEvent.stopImmediatePropagation()},xSe=()=>Q.createElement("svg",{style:{marginLeft:"2px"},viewBox:"0 0 1025 1024",width:"14",height:"14"},Q.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"})),cM=s=>{const{activeColor:t,onPointerUpHandler:e}=s;return Q.createElement("div",{className:`font-color-button ${t==="transparent"?"active":""}`,onPointerUp:e},Q.createElement("div",{className:"circle none"}))},Uc=s=>{const{color:t,activeColor:e,onPointerUpHandler:r}=s;return Q.createElement("div",{className:`font-color-button ${t===e?"active":""}`,onPointerUp:r},Q.createElement("div",{className:"circle",style:{backgroundColor:Et(t,1)}}))},Wc=s=>{const{opacity:t,activeColor:e,setCurOpacity:r}=s,[n,i]=Q.useState({x:108,y:0}),o=Q.useRef(0);if(Q.useEffect(()=>{i({x:t*100+8,y:0})},[]),!e)return null;const a=(h,d)=>{const f=Math.min(Math.max(h-8,0),100)/100;(t!==f||d===de.Done)&&r(f,e,d)},c=(h,d)=>{d.x!==(n==null?void 0:n.x)&&i({x:d.x,y:0}),!o.current&&(o.current=setTimeout(()=>{o.current=0,a(d.x,de.Doing)},100))},l=()=>{r(t,e,de.Start)},u=(h,d)=>{d.x!==(n==null?void 0:n.x)&&i({x:d.x,y:0}),o.current&&(clearTimeout(o.current),o.current=0),a(d.x,de.Done)};return Q.createElement("div",{className:"font-color-opacity",style:{marginLeft:"10px"},onPointerUp:h=>{o.current&&(clearTimeout(o.current),o.current=0);const d=h.nativeEvent.offsetX,f=Math.min(Math.max(d-12,0),100)/100;i({x:f*100+8,y:0}),r(f,e,de.Done)}},Q.createElement("div",{className:"range-color",style:{background:`linear-gradient(to right, ${Et(e,0)}, ${Et(e,1)})`}}),Q.createElement("div",{className:"range-opacity"},Q.createElement(Qi,{bounds:"parent",axis:"x",position:n,onDrag:c,onStart:l,onStop:u},Q.createElement("div",{className:"circle",style:{backgroundColor:Et(e,t)},onPointerUp:mo}))))},RSe=s=>{const{min:t,max:e,activeNumber:r,setActiveNumber:n,color:i}=s,[o,a]=Q.useState({x:108,y:0}),c=Q.useRef(0);if(Q.useEffect(()=>{const f=Math.ceil((r-t)/(e-t)*100)+8;a({x:f,y:0})},[]),!r)return null;const l=(f,g)=>{const y=Math.ceil(Math.max(f-8,0)/100*(e-t)+t);(r!==y||g===de.Done)&&n(y,g)},u=(f,g)=>{g.x!==(o==null?void 0:o.x)&&a({x:g.x,y:0}),!c.current&&(c.current=setTimeout(()=>{c.current=0,l(g.x,de.Doing)},100))},h=()=>{n(r,de.Start)},d=(f,g)=>{g.x!==(o==null?void 0:o.x)&&a({x:g.x,y:0}),c.current&&(clearTimeout(c.current),c.current=0),l(g.x,de.Done)};return Q.createElement("div",{className:"font-color-opacity",style:{marginLeft:"10px"},onPointerUp:f=>{c.current&&(clearTimeout(c.current),c.current=0);const g=f.nativeEvent.offsetX,y=Math.ceil(Math.max(g-12,0)/100*(e-t)+t),S=Math.ceil((y-t)/(e-t)*100)+8;a({x:S,y:0}),n(y,de.Done)}},Q.createElement("div",{className:"range-color",style:{backgroundColor:i}}),Q.createElement("div",{className:"range-opacity"},Q.createElement(Qi,{bounds:"parent",axis:"x",position:o,onDrag:u,onStart:h,onStop:d},Q.createElement("div",{className:"circle",style:{backgroundColor:i},onPointerUp:mo},Q.createElement("div",{className:"range-opacity-data-icon"},r)))))},kSe=s=>{const{useStroke:t,color:e,activeStrokeType:r,setStrokeType:n}=s;return Q.createElement("div",{className:"stroke-type-box"},!!t&&Q.createElement("div",{className:`stroke-type-box-item Stroke ${r===Be.Stroke&&"active"}`,style:{backgroundColor:e},onPointerUp:()=>{n(Be.Stroke)}}),Q.createElement("div",{className:`stroke-type-box-item Normal ${r===Be.Normal&&"active"}`,style:{borderColor:e},onPointerUp:()=>{n(Be.Normal)}}),Q.createElement("div",{className:`stroke-type-box-item Dotted ${r===Be.Dotted&&"active"}`,style:{borderColor:e},onPointerUp:()=>{n(Be.Dotted)}}),Q.createElement("div",{className:`stroke-type-box-item LongDotted ${r===Be.LongDotted&&"active"}`,style:{borderColor:e},onPointerUp:()=>{n(Be.LongDotted)}}))},ASe=s=>{const{open:t,setOpen:e,floatBarRef:r}=s,{floatBarData:n,floatBarColors:i,mananger:o,setFloatBarData:a}=Q.useContext(lt),[c,l]=Q.useState(),[u,h]=Q.useState(1);Q.useEffect(()=>{if(n!=null&&n.strokeColor){const[I,N]=Lc(n.strokeColor);l(I),h(N)}},[n]);const d=Q.useMemo(()=>{if(r!=null&&r.current&&n&&ye.isNumber(n==null?void 0:n.y)&&(o!=null&&o.height)){if(r.current.offsetTop&&r.current.offsetTop+n.y>180){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<120){const I={};return I.top="inherit",I.bottom=50,I}}},[n,r,o==null?void 0:o.height]),f=Q.useMemo(()=>Q.createElement(Wc,{key:"strokeColors",opacity:u,activeColor:c,setCurOpacity:(I,N,T)=>{h(I);const p=Et(N,I);n!=null&&n.strokeColor&&a({strokeColor:p}),Ve.emitMethod(We.MainEngine,Te.SetColorNode,{workIds:[Le],strokeColor:p,workState:T,viewId:o==null?void 0:o.viewId})}}),[u,c,n==null?void 0:n.strokeColor,o==null?void 0:o.viewId,a]),g=Q.useMemo(()=>c&&n&&n.thickness?Q.createElement(RSe,{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:(I,N)=>{n!=null&&n.thickness&&a({thickness:I}),Ve.emitMethod(We.MainEngine,Te.SetColorNode,{workIds:[Le],thickness:I,workState:N,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]),y=Q.useMemo(()=>c&&n&&(n!=null&&n.strokeType)?Q.createElement(kSe,{key:"strokeType",useStroke:n==null?void 0:n.useStroke,activeStrokeType:n.strokeType,setStrokeType:I=>{n.strokeType&&a({strokeType:I}),Ve.emitMethod(We.MainEngine,Te.SetColorNode,{workIds:[Le],strokeType:I,workState:de.Done,viewId:o==null?void 0:o.viewId})},color:c}):null,[c,n,o==null?void 0:o.viewId,a]),S=Q.useMemo(()=>t?Q.createElement("div",{className:"font-colors-menu",style:d,onPointerUp:I=>{I.stopPropagation(),I.nativeEvent.stopImmediatePropagation()}},y,g,Q.createElement("div",{className:"font-colors-line"}),i.concat().map((I,N)=>{const T=po(...I);return Q.createElement(Uc,{key:N,color:T,activeColor:c,onPointerUpHandler:p=>{p.stopPropagation(),l(T);const m=Et(T,u);n!=null&&n.strokeColor&&(n.strokeColor=m,a({strokeColor:m})),Ve.emitMethod(We.MainEngine,Te.SetColorNode,{workIds:[Le],workState:de.Done,strokeColor:m,viewId:o==null?void 0:o.viewId})}})}),f):null,[t,d,y,g,i,f,c,u,n,o==null?void 0:o.viewId,a]),b=Q.useMemo(()=>c?Q.createElement("div",{className:"color-bar-ring",style:{backgroundColor:Et(c,u)}},Q.createElement("div",{className:"circle"})):null,[c,u]);return Q.createElement("div",{className:`button normal-button font-colors-icon ${t&&"active"}`,onPointerUp:I=>{I.stopPropagation(),I.nativeEvent.stopImmediatePropagation(),e(!t)}},b,S)},PSe=s=>{const{open:t,setOpen:e,floatBarRef:r}=s,{floatBarData:n,floatBarColors:i,mananger:o,setFloatBarData:a}=Q.useContext(lt),[c,l]=Q.useState(),[u,h]=Q.useState(1);Q.useEffect(()=>{if(n!=null&&n.fillColor){const[S,b]=(n==null?void 0:n.fillColor)==="transparent"&&["transparent",1]||Lc(n.fillColor);l(S),h(b)}},[n]);const d=Q.useMemo(()=>{if(r!=null&&r.current&&ye.isNumber(n==null?void 0:n.y)&&(o!=null&&o.height)){if(r.current.offsetTop&&r.current.offsetTop+n.y>200){const S={};return S.top="inherit",S.bottom=50,S}else if(!r.current.offsetTop&&(o==null?void 0:o.height)-r.current.offsetTop-n.y<140){const S={};return S.top="inherit",S.bottom=50,S}}},[r,n,o==null?void 0:o.height]),f=Q.useMemo(()=>c&&c!=="transparent"?Q.createElement(Wc,{key:"fillColors",opacity:u||0,activeColor:c,setCurOpacity:(S,b,I)=>{h(S);const N=Et(b,S);n!=null&&n.fillColor&&(n.fillColor=N,a({fillColor:N})),Ve.emitMethod(We.MainEngine,Te.SetColorNode,{workIds:[Le],fillColor:c&&Et(b,S),workState:I,viewId:o==null?void 0:o.viewId})}}):null,[c,u,n,o==null?void 0:o.viewId,a]),g=Q.useMemo(()=>t?Q.createElement("div",{className:"font-colors-menu",style:d,onPointerUp:S=>{S.stopPropagation(),S.nativeEvent.stopImmediatePropagation()}},Q.createElement(cM,{activeColor:c,onPointerUpHandler:S=>{S.stopPropagation(),l("transparent");const b="transparent";n!=null&&n.fillColor&&(n.fillColor=b,a({fillColor:b})),Ve.emitMethod(We.MainEngine,Te.SetColorNode,{workIds:[Le],workState:de.Done,fillColor:b,viewId:o==null?void 0:o.viewId})}}),i.map((S,b)=>{const I=po(...S);return Q.createElement(Uc,{key:b,color:I,activeColor:c,onPointerUpHandler:N=>{N.cancelable&&N.preventDefault(),N.stopPropagation(),l(I);const T=Et(I,u);n!=null&&n.fillColor&&(n.fillColor=T,a({fillColor:T})),Ve.emitMethod(We.MainEngine,Te.SetColorNode,{workIds:[Le],workState:de.Done,fillColor:T,viewId:o==null?void 0:o.viewId})}})}),f):null,[t,d,c,i,f,n,o==null?void 0:o.viewId,a,u]),y=Q.useMemo(()=>{const S=c&&c!=="transparent"&&Et(c,u)||"transparent";return Q.createElement("div",{className:"color-bar-fill"},Q.createElement("div",{className:"circle",style:{backgroundColor:S}}))},[c,u]);return Q.createElement("div",{className:`button normal-button font-colors-icon ${t&&"active"}`,onPointerUp:S=>{S.stopPropagation(),S.nativeEvent.stopImmediatePropagation(),e(!t)}},y,g)},DSe=s=>{const{open:t,setOpen:e,textOpt:r,workIds:n,floatBarRef:i}=s,{floatBarColors:o,mananger:a,setFloatBarData:c,floatBarData:l}=Q.useContext(lt),[u,h]=Q.useState(),[d,f]=Q.useState(1);Q.useEffect(()=>{if(r!=null&&r.fontColor){const[I,N]=(r==null?void 0:r.fontColor)==="transparent"&&["transparent",0]||Lc(r.fontColor);h(I),f(N)}},[r==null?void 0:r.fontColor]);const g=Q.useMemo(()=>{if(i!=null&&i.current&&l&&ye.isNumber(l==null?void 0:l.y)&&(a!=null&&a.height)){if(i.current.offsetTop&&i.current.offsetTop+l.y>180){const I={};return I.top="inherit",I.bottom=50,I}else if(!i.current.offsetTop&&(a==null?void 0:a.height)-i.current.offsetTop-l.y<120){const I={};return I.top="inherit",I.bottom=50,I}}},[i,l,a==null?void 0:a.height]),y=Q.useMemo(()=>u&&u!=="transparent"?Q.createElement(Wc,{key:"fontColors",opacity:d,activeColor:u,setCurOpacity:(I,N,T)=>{f(I);const p=Et(N,I);l!=null&&l.textOpt&&(l.textOpt.fontColor=p,c({textOpt:l.textOpt})),Ve.emitMethod(We.MainEngine,Te.SetColorNode,{workIds:n||[Le],fontColor:u&&p,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]),S=Q.useMemo(()=>t?Q.createElement("div",{className:"font-colors-menu",style:g,onPointerUp:I=>{I.stopPropagation(),I.nativeEvent.stopImmediatePropagation()}},o.map((I,N)=>{const T=po(...I);return Q.createElement(Uc,{key:N,color:T,activeColor:u,onPointerUpHandler:p=>{p.stopPropagation(),h(T);const m=Et(T,d);l!=null&&l.textOpt&&(l.textOpt.fontColor=m,c({textOpt:l.textOpt})),Ve.emitMethod(We.MainEngine,Te.SetColorNode,{workIds:n||[Le],workState:de.Done,fontColor:m,viewId:a==null?void 0:a.viewId})}})}),y):null,[c,t,o,y,u,d,l==null?void 0:l.textOpt,n,a==null?void 0:a.viewId,g]),b=Q.useMemo(()=>{const I=u&&u!=="transparent"&&Et(u,d)||"transparent";return Q.createElement("div",{className:"color-bar"},Q.createElement("div",{className:"color-bar-color",style:{backgroundColor:I}}))},[u,d]);return Q.createElement("div",{className:`button normal-button font-colors-icon ${t&&"active"}`,onPointerUp:I=>{I.stopPropagation(),I.nativeEvent.stopImmediatePropagation(),e(!t)}},Q.createElement("img",{alt:"icon",src:At("font-colors")}),b,S)},LSe=s=>{const{open:t,setOpen:e,textOpt:r,workIds:n,floatBarRef:i}=s,{floatBarColors:o,mananger:a,setFloatBarData:c,floatBarData:l}=Q.useContext(lt),[u,h]=Q.useState(),[d,f]=Q.useState(1);Q.useEffect(()=>{if(r!=null&&r.fontBgColor){const[I,N]=(r==null?void 0:r.fontBgColor)==="transparent"&&["transparent",1]||Lc(r.fontBgColor);h(I),f(N)}},[r==null?void 0:r.fontBgColor]);const g=Q.useMemo(()=>{if(i!=null&&i.current&&l&&ye.isNumber(l==null?void 0:l.y)&&(a!=null&&a.height)){if(i.current.offsetTop&&i.current.offsetTop+l.y>180){const I={};return I.top="inherit",I.bottom=50,I}else if(!i.current.offsetTop&&(a==null?void 0:a.height)-i.current.offsetTop-l.y<120){const I={};return I.top="inherit",I.bottom=50,I}}},[i,l,a==null?void 0:a.height]),y=Q.useMemo(()=>u&&u!=="transparent"?Q.createElement(Wc,{key:"fontBgColor",opacity:d||0,activeColor:u,setCurOpacity:(I,N,T)=>{f(I);const p=Et(N,I);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=p,c({textOpt:l.textOpt})),Ve.emitMethod(We.MainEngine,Te.SetColorNode,{workIds:n||[Le],fontBgColor:u&&Et(N,I),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]),S=Q.useMemo(()=>t?Q.createElement("div",{className:"font-colors-menu",style:g,onPointerUp:I=>{I.stopPropagation(),I.nativeEvent.stopImmediatePropagation()}},Q.createElement(cM,{activeColor:u,onPointerUpHandler:I=>{I.stopPropagation();const N="transparent";h(N),l!=null&&l.textOpt&&(l.textOpt.fontBgColor=N,c({textOpt:l.textOpt})),Ve.emitMethod(We.MainEngine,Te.SetColorNode,{workIds:n||[Le],workState:de.Done,fontBgColor:N,viewId:a==null?void 0:a.viewId})}}),o.map((I,N)=>{const T=po(...I);return Q.createElement(Uc,{key:N,color:T,activeColor:u,onPointerUpHandler:p=>{p.stopPropagation(),h(T);const m=Et(T,d);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=m,c({textOpt:l.textOpt})),Ve.emitMethod(We.MainEngine,Te.SetColorNode,{workIds:n||[Le],workState:de.Done,fontBgColor:Et(T,d),viewId:a==null?void 0:a.viewId})}})}),y):null,[c,t,o,y,d,u,l==null?void 0:l.textOpt,n,a==null?void 0:a.viewId,g]),b=Q.useMemo(()=>{const I=u&&u!=="transparent"&&Et(u,d)||"transparent";return Q.createElement("div",{className:"color-bar",style:{marginTop:0}},Q.createElement("div",{className:"color-bar-color",style:{backgroundColor:I}}))},[u,d]);return Q.createElement("div",{className:`button normal-button font-colors-icon ${t&&"active"}`,onPointerUp:I=>{I.stopPropagation(),I.nativeEvent.stopImmediatePropagation(),e(!t)}},Q.createElement(xSe,null),b,S)},NSe=s=>{const{bold:t,setBold:e,workIds:r,viewId:n}=s,i=o=>{const a=t==="bold"?"normal":"bold";o==null||o.stopPropagation(),e(a),Ve.emitMethod(We.MainEngine,Te.SetFontStyle,{workIds:r,viewId:n,bold:a})};return Q.createElement("div",{className:"font-style-button",onPointerUp:i},Q.createElement("img",{alt:"icon",src:At(t==="bold"?"bold-active":"bold")}))},OSe=s=>{const{underline:t,setUnderline:e,workIds:r,viewId:n}=s,i=o=>{const a=!t;o==null||o.stopPropagation(),e(a),Ve.emitMethod(We.MainEngine,Te.SetFontStyle,{workIds:r,viewId:n,underline:a})};return Q.createElement("div",{className:"font-style-button",onPointerUp:i},Q.createElement("img",{alt:"icon",src:At(t?"underline-active":"underline")}))},zSe=s=>{const{lineThrough:t,setLineThrough:e,workIds:r,viewId:n}=s,i=o=>{const a=!t;o==null||o.stopPropagation(),e(a),Ve.emitMethod(We.MainEngine,Te.SetFontStyle,{workIds:r,viewId:n,lineThrough:a})};return Q.createElement("div",{className:"font-style-button",onPointerUp:i},Q.createElement("img",{alt:"icon",src:At(t?"line-through-active":"line-through")}))},BSe=s=>{const{italic:t,setItalic:e,workIds:r,viewId:n}=s,i=o=>{const a=t==="italic"?"normal":"italic";o==null||o.stopPropagation(),e(a),Ve.emitMethod(We.MainEngine,Te.SetFontStyle,{workIds:r,viewId:n,italic:a})};return Q.createElement("div",{className:"font-style-button",onPointerUp:i},Q.createElement("img",{alt:"icon",src:At(t==="italic"?"italic-active":"italic")}))},jSe=s=>{const{open:t,setOpen:e,textOpt:r,workIds:n,style:i,floatBarRef:o}=s,{mananger:a,floatBarData:c}=Q.useContext(lt),[l,u]=Q.useState("normal"),[h,d]=Q.useState("normal"),[f,g]=Q.useState(!1),[y,S]=Q.useState(!1);Q.useEffect(()=>{r!=null&&r.bold&&u(r.bold),ye.isBoolean(r==null?void 0:r.underline)&&g(r.underline||!1),ye.isBoolean(r==null?void 0:r.lineThrough)&&S(r.lineThrough||!1),r!=null&&r.italic&&d(r.italic)},[r]);const b=Q.useMemo(()=>{if(i&&(o!=null&&o.current)&&ye.isNumber(c==null?void 0:c.y)&&(a!=null&&a.height)){if(o.current.offsetTop&&o.current.offsetTop+c.y>180){const N={};return N.top="inherit",N.bottom=50,N}else if(!o.current.offsetTop&&(a==null?void 0:a.height)-o.current.offsetTop-c.y<120){const N={};return N.top="inherit",N.bottom=50,N}}},[i,o==null?void 0:o.current,c,a]),I=Q.useMemo(()=>t?Q.createElement("div",{className:"font-style-menu",style:b,onPointerUp:N=>{N.stopPropagation(),N.nativeEvent.stopImmediatePropagation()}},Q.createElement(NSe,{workIds:n||[Le],bold:l,setBold:u,viewId:a==null?void 0:a.viewId}),Q.createElement(OSe,{workIds:n||[Le],underline:f,setUnderline:g,viewId:a==null?void 0:a.viewId}),Q.createElement(zSe,{workIds:n||[Le],lineThrough:y,setLineThrough:S,viewId:a==null?void 0:a.viewId}),Q.createElement(BSe,{workIds:n||[Le],italic:h,setItalic:d,viewId:a==null?void 0:a.viewId})):null,[t,n,l,a==null?void 0:a.viewId,f,y,h,b]);return Q.createElement("div",{className:`button normal-button ${t&&"active"}`,onPointerUp:N=>{N.stopPropagation(),N.nativeEvent.stopImmediatePropagation(),e(!t)}},Q.createElement("img",{alt:"icon",src:At(t?"font-style-active":"font-style")}),I)},FSe=s=>{const{style:t,onClickHandler:e}=s;return Q.createElement("div",{className:"font-size-menu",style:t,onPointerUp:r=>{r.stopPropagation(),r.nativeEvent.stopImmediatePropagation()}},kr.map(r=>Q.createElement("div",{className:"font-size-btn",key:r,onPointerUp:()=>{e(r)}},r)))},USe=s=>{const t=Q.useRef(null),{open:e,setOpen:r,textOpt:n,workIds:i,floatBarRef:o}=s,{mananger:a,floatBarData:c}=Q.useContext(lt),[l,u]=Q.useState(0),h=kr.length-1;Q.useEffect(()=>{n!=null&&n.fontSize&&(u(n.fontSize),t.current&&(t.current.value=n.fontSize.toString()))},[n==null?void 0:n.fontSize]);const d=Q.useMemo(()=>{if(o!=null&&o.current&&ye.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=35,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=35,b}}},[o==null?void 0:o.current,c,a]);function f(b){u(b),b&&b>=kr[0]&&b<=kr[h]&&Ve.emitMethod(We.MainEngine,Te.SetFontStyle,{workIds:i||[Le],fontSize:b,viewId:a==null?void 0:a.viewId})}const g=b=>{var I;(I=t.current)==null||I.blur(),r(!1),S(b)},y=Q.useMemo(()=>e?Q.createElement(FSe,{onClickHandler:g,style:d}):null,[e,g,d]),S=b=>{b>kr[h]&&(b=kr[h]),b<kr[0]&&(b=kr[0]),f(b)};return Q.createElement("div",{className:"button normal-button font-size-barBtn",style:{width:50},onPointerUp:b=>{b.stopPropagation(),b.nativeEvent.stopImmediatePropagation()}},Q.createElement("input",{className:"font-size-input",ref:t,onTouchEnd:()=>{t.current&&t.current.focus()},onClick:()=>{r(!e),t.current&&t.current.focus()},onKeyDown:b=>{if(b.stopPropagation(),b.nativeEvent.stopImmediatePropagation(),b.key==="Backspace"){const I=window.getSelection(),N=I==null?void 0:I.getRangeAt(0);if(N!=null&&N.collapsed)return b.cancelable&&b.preventDefault(),document.execCommand("delete",!1),!1}return!1},onKeyUp:b=>{var I;if(b.stopPropagation(),b.nativeEvent.stopImmediatePropagation(),t.current){const N=t.current.value,T=parseInt(N);isNaN(T)?t.current.value="0":t.current.value=T.toString(),T&&b.key==="Enter"&&(S(T),(I=t.current)==null||I.blur(),r(!1))}}}),Q.createElement("div",{className:"font-size-btns"},Q.createElement("div",{className:"font-size-add",onPointerUp:()=>{S(l+kr[0])}}),Q.createElement("div",{className:"font-size-cut",onPointerUp:()=>{S(l-kr[0])}})),y)},WSe=s=>{const{workIds:t,mananger:e,islocked:r}=s;return Q.createElement("div",{className:"button normal-button",onPointerUp:n=>{n.stopPropagation(),Ve.emitMethod(We.MainEngine,Te.SetLock,{workIds:t||[Le],isLocked:!r,viewId:e==null?void 0:e.viewId})}},Q.createElement("img",{alt:"icon",src:At(r?"unlock-new":"lock-new")}))},Xu=s=>{const{icon:t,min:e,max:r,step:n,value:i,onInputHandler:o}=s,[a,c]=Q.useState(0),l=Q.useRef(null),u=h=>{h>r&&(h=r),h<e&&(h=e),c(h),o(h),l.current&&(l.current.value=h.toString())};return Q.useEffect(()=>{i&&(c(i),l.current&&(l.current.value=i.toString()))},[i]),Q.createElement("div",{className:"button input-button"},Q.createElement("img",{src:At(t)}),Q.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(),f=d==null?void 0:d.getRangeAt(0);if(f!=null&&f.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,f=parseInt(d);isNaN(f)?l.current.value="0":l.current.value=f.toString()}},onChange:h=>{const d=h.target.value,f=parseInt(d);f&&f&&f>=e&&f<=r&&u(f)}}),Q.createElement("div",{className:"input-number-btns"},Q.createElement("div",{className:"input-number-add",onPointerUp:()=>{u(a+n)}}),Q.createElement("div",{className:"input-number-cut",onPointerUp:()=>{u(a-n)}})))},VSe=s=>{const{icon:t,min:e,max:r,step:n,value:i,onInputHandler:o}=s;return Q.createElement("div",{className:"button input-button"},Q.createElement("img",{src:At(t)}),Q.createElement($Se,{min:e,max:r,step:n,value:i,onInputHandler:o}))},$Se=s=>{const{value:t,min:e,max:r,onInputHandler:n}=s,[i,o]=Q.useState({x:0,y:0});Q.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!==(i==null?void 0:i.x)&&o({x:d,y:0});const f=d/100;t!==f&&n(f)},c=()=>{},l=(u,h)=>{let d=Math.floor(Math.max(h.x,e*100));d=Math.floor(Math.min(d,r*100)),h.x!==(i==null?void 0:i.x)&&o({x:d,y:0});const f=d/100;t!==f&&n(f)};return Q.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 f=d/100;t!==f&&n(f)}},Q.createElement("div",{className:"range-number-color"}),Q.createElement("div",{className:"range-number"},Q.createElement(Qi,{bounds:"parent",axis:"x",position:i,onDrag:a,onStart:c,onStop:l},Q.createElement("div",{className:"circle",onPointerUp:mo}))))},YSe=s=>{const{icon:t,value:e,onChangeHandler:r,style:n}=s,[i,o]=Q.useState(0),[a,c]=Q.useState(),l=Q.useRef(null),u=Q.useCallback(f=>{f>=bi.length&&(f=0),f<0&&(f=bi.length-1),o(f),r(bi[f]),c(!1),l.current&&(l.current.value=bi[f])},[r]),h=Q.useMemo(()=>{if(n&&n.bottom){const f={};return f.top="inherit",f.bottom=50,f}},[n]);Q.useEffect(()=>{e&&(o(bi.indexOf(e)),l.current&&(l.current.value=e))},[e]);const d=Q.useMemo(()=>a?Q.createElement(GSe,{options:bi,onClickHandler:u,style:h}):null,[a,u,h]);return Q.createElement("div",{className:"button input-button"},Q.createElement("img",{src:At(t)}),Q.createElement("input",{readOnly:!0,className:"input-number",type:"text",ref:l,onPointerUp:()=>{l.current&&(l.current.focus(),c(!a))}}),Q.createElement("div",{className:"input-number-btns"},Q.createElement("div",{className:"input-number-add",onPointerUp:()=>{u(i+1)}}),Q.createElement("div",{className:"input-number-cut",onPointerUp:()=>{u(i-1)}})),d)},GSe=s=>{const{options:t,style:e,onClickHandler:r}=s;return Q.createElement("div",{className:"select-option-menu",style:e},t.map((n,i)=>Q.createElement("div",{className:"select-option-btn",key:n,onPointerUp:()=>{r(i)}},n)))},HSe=s=>{const{innerRatio:t,innerVerticeStep:e,vertices:r,mananger:n,setShapeOpt:i}=s,o=l=>{i({vertices:l}),Ve.emitMethod(We.MainEngine,Te.SetShapeOpt,{workIds:[Le],toolsType:q.Star,viewId:n.viewId,vertices:l})},a=l=>{i({innerVerticeStep:l}),Ve.emitMethod(We.MainEngine,Te.SetShapeOpt,{workIds:[Le],toolsType:q.Star,viewId:n.viewId,innerVerticeStep:l})},c=l=>{i({innerRatio:l}),Ve.emitMethod(We.MainEngine,Te.SetShapeOpt,{workIds:[Le],toolsType:q.Star,viewId:n.viewId,innerRatio:l})};return Q.createElement(Q.Fragment,null,Q.createElement(Xu,{value:r,icon:"polygon-vertex",min:3,max:100,step:1,onInputHandler:o}),Q.createElement(Xu,{value:e,icon:"star-innerVertex",min:1,max:100,step:1,onInputHandler:a}),Q.createElement(VSe,{value:t,icon:"star-innerRatio",min:.1,max:1,step:.1,onInputHandler:c}))},QSe=s=>{const{mananger:t,vertices:e,setShapeOpt:r}=s,n=i=>{r({vertices:i}),Ve.emitMethod(We.MainEngine,Te.SetShapeOpt,{workIds:[Le],toolsType:q.Polygon,viewId:t.viewId,vertices:i})};return Q.createElement(Xu,{value:e,icon:"polygon-vertex",min:3,max:100,step:1,onInputHandler:n})},qSe=s=>{const{mananger:t,placement:e,setShapeOpt:r}=s,n=i=>{r({placement:i}),Ve.emitMethod(We.MainEngine,Te.SetShapeOpt,{workIds:[Le],toolsType:q.SpeechBalloon,viewId:t.viewId,placement:i})};return Q.createElement(YSe,{value:e,icon:"speechBallon-placement",onChangeHandler:n})},Kl=s=>{const{icon:t,isActive:e,onPointerUpHandler:r}=s;return Q.createElement("div",{className:`button tab-button ${e?"active":""}`,onPointerUp:r},Q.createElement("img",{src:At(t)}))},ZSe=s=>{const{toolsTypes:t,style:e,mananger:r,shapeOpt:n,setShapeOpt:i}=s,[o,a]=Q.useState();Q.useEffect(()=>{t.includes(q.Polygon)?a(q.Polygon):t.includes(q.Star)?a(q.Star):a(q.SpeechBalloon)},[t]);const c=d=>{a(d)},l=Q.useMemo(()=>o===q.Polygon&&r&&n.vertices?Q.createElement(QSe,{vertices:n.vertices,mananger:r,setShapeOpt:i}):null,[r,o,n,i]),u=Q.useMemo(()=>o===q.Star&&r&&n.vertices&&n.innerVerticeStep&&n.innerRatio?Q.createElement(HSe,{mananger:r,vertices:n.vertices,innerVerticeStep:n.innerVerticeStep,innerRatio:n.innerRatio,setShapeOpt:i}):null,[r,o,n,i]),h=Q.useMemo(()=>o===q.SpeechBalloon&&r&&n.placement?Q.createElement(qSe,{mananger:r,placement:n.placement,setShapeOpt:i}):null,[o,r,n.placement,i]);return Q.createElement("div",{className:"shapeOpt-sub-menu",style:e,onPointerUp:mo},Q.createElement("div",{className:"shapeOpt-sub-menu-tabs"},t.includes(q.Polygon)&&Q.createElement(Kl,{isActive:o===q.Polygon,icon:o===q.Polygon?"polygon-active":"polygon",onPointerUpHandler:c.bind(void 0,q.Polygon)})||null,t.includes(q.Star)&&Q.createElement(Kl,{isActive:o===q.Star,icon:o===q.Star?"star-active":"star",onPointerUpHandler:c.bind(void 0,q.Star)})||null,t.includes(q.SpeechBalloon)&&Q.createElement(Kl,{isActive:o===q.SpeechBalloon,icon:o===q.SpeechBalloon?"speechBallon-active":"speechBallon",onPointerUpHandler:c.bind(void 0,q.SpeechBalloon)})||null),Q.createElement("div",{className:"shapeOpt-sub-menu-content"},l,u,h))},KSe=s=>{const{open:t,setOpen:e,floatBarRef:r,toolsTypes:n,shapeOpt:i}=s,{floatBarData:o,mananger:a,setFloatBarData:c}=Q.useContext(lt),l=Q.useRef(null),u=Q.useMemo(()=>{if(r!=null&&r.current&&ye.isNumber(o==null?void 0:o.x)&&ye.isNumber(o==null?void 0:o.y)&&(a!=null&&a.height)){if(r.current.offsetTop&&r.current.offsetTop+o.y>200){const g={};return g.top="inherit",g.bottom=50,g}else if(!r.current.offsetTop&&(a==null?void 0:a.height)-r.current.offsetTop-(o==null?void 0:o.y)<140){const g={};return g.top="inherit",g.bottom=50,g}}},[r,o==null?void 0:o.x,o==null?void 0:o.y,a==null?void 0:a.height]),h=Q.useCallback(g=>{c({shapeOpt:{...i,...g}})},[c,i]),d=Q.useMemo(()=>t&&n&&a&&i?Q.createElement(ZSe,{shapeOpt:i,style:u,toolsTypes:n,mananger:a,setShapeOpt:h}):null,[t,u,n,a,i,h]),f=()=>{e(!t)};return Q.createElement("div",{ref:l,className:`button normal-button ${t&&"active"}`,onPointerUp:f},d,Q.createElement("img",{alt:"icon",src:At(t?"shapes-active":"shapes")}))},lM=Q.memo(s=>{const{textOpt:t,workIds:e,noLayer:r,position:n,noDelete:i,noCopy:o}=s,{floatBarData:a,mananger:c}=Q.useContext(lt),[l,u]=Q.useState(0),[h,d]=Q.useState(),f=Q.useRef(null);Q.useEffect(()=>{var E,D,P,z;const v={},M=(a==null?void 0:a.w)||((E=t==null?void 0:t.boxSize)==null?void 0:E[0])||0,k=(a==null?void 0:a.h)||((D=t==null?void 0:t.boxSize)==null?void 0:D[1])||0;if(n&&M&&k&&(c!=null&&c.width)&&(c!=null&&c.height)){if(n.y<60?n.y+k<c.height-60?v.bottom=-120:n.y+k<c.height?v.bottom=-58:n.y>0?v.top=62:v.top=-n.y+62:v.top=0,n.x<0)v.left=-n.x+3;else if(n.x+(((P=f.current)==null?void 0:P.offsetWidth)||M)>c.width){const j=c.width-(((z=f.current)==null?void 0:z.offsetWidth)||M)-n.x;v.left=j}d(v);return}d(void 0)},[f,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 g=Q.useMemo(()=>a!=null&&a.fillColor?Q.createElement(PSe,{floatBarRef:f,open:l===3,setOpen:v=>{u(v===!0?3:0)}}):null,[a==null?void 0:a.fillColor,l,f]),y=Q.useMemo(()=>a!=null&&a.strokeColor?Q.createElement(ASe,{floatBarRef:f,open:l===2,setOpen:v=>{u(v===!0?2:0)}}):null,[a==null?void 0:a.strokeColor,l,f]),S=Q.useMemo(()=>t!=null&&t.fontColor&&(c!=null&&c.viewId)?Q.createElement(DSe,{floatBarRef:f,open:l===4,setOpen:v=>{u(v===!0?4:0)},textOpt:t,workIds:e}):null,[t,l,e,c,f]),b=Q.useMemo(()=>t!=null&&t.fontBgColor&&(c!=null&&c.viewId)?Q.createElement(LSe,{floatBarRef:f,open:l===5,setOpen:v=>{u(v===!0?5:0)},textOpt:t,workIds:e}):null,[t,l,e,c,f]),I=Q.useMemo(()=>t&&(c!=null&&c.viewId)?Q.createElement(jSe,{floatBarRef:f,open:l===6,setOpen:v=>{u(v===!0?6:0)},textOpt:t,workIds:e,style:h}):null,[t,l,e,c,h,f]),N=Q.useMemo(()=>t&&(c!=null&&c.viewId)?Q.createElement(USe,{open:l===7,setOpen:v=>{u(v===!0?7:0)},textOpt:t,workIds:e,floatBarRef:f}):null,[t,l,e,c,f]),T=Q.useMemo(()=>r?null:Q.createElement(ESe,{open:l===1,setOpen:v=>{u(v===!0?1:0)},floatBarRef:f}),[r,l,f]),p=Q.useMemo(()=>a!=null&&a.canLock&&c?Q.createElement(WSe,{workIds:e,mananger:c,islocked:a.isLocked}):null,[a,c,e]),m=Q.useMemo(()=>c&&(c!=null&&c.viewId)&&h&&(a!=null&&a.shapeOpt)&&(a!=null&&a.toolsTypes)?Q.createElement(KSe,{open:l===8,setOpen:v=>{u(v===!0?8:0)},floatBarRef:f,workIds:e,toolsTypes:a.toolsTypes,shapeOpt:a.shapeOpt}):null,[a,c,l,h,e,f]);return Q.createElement("div",{className:"appliance-plugin-floatbtns",style:h,ref:f},c&&!i&&Q.createElement(CSe,{workIds:e,mananger:c}),T,p,!!(c!=null&&c.viewId)&&!o&&Q.createElement(bSe,{workIds:e,viewId:c.viewId}),m,I,N,S,b,y,g)}),XSe=s=>{const{data:t,workId:e,updateOptInfo:r}=s,{opt:n,scale:i,translate:o,x:a,y:c}=t,l=Q.useRef(null),{floatBarData:u}=Q.useContext(lt),h=Q.useMemo(()=>{const{fontSize:g,fontFamily:y,underline:S,fontColor:b,lineThrough:I,textAlign:N,strokeColor:T,lineHeight:p,bold:m,italic:v}=n,M=p||g*1.2,k={fontSize:`${g}px`,lineHeight:`${M}px`,color:"transparent",caretColor:b,borderColor:T,minHeight:`${M}px`,pointerEvents:"none",paddingRight:`${v==="italic"?Math.round(g*.3):5}px`};return y&&(k.fontFamily=`${y}`),(I||S)&&(k.textDecoration=`${I&&"line-through"||""}${S&&" underline"||""}`),N&&(k.textAlign=`${N}`),m&&(k.fontWeight=`${m}`),v&&(k.fontStyle=`${v}`),k},[n]),d=Q.useMemo(()=>{const g=[];if(n.text){const y=Nn(n.text);for(let S=0;S<y.length;S++){const b=y[S];b===""?g.push(Q.createElement("div",{key:S})):g.push(Q.createElement("div",{key:S},b))}}return g.length?g:Q.createElement("div",null)},[n.text]),f=Q.useMemo(()=>{if(!u)return{};const g=`scale(${i||1}) ${o&&"translate("+o[0]+"px,"+o[1]+"px)"||""}`;return{left:`${a-u.x}px`,top:`${c-u.y}px`,zIndex:1,transform:g,transformOrigin:"left top",opacity:0,pointerEvents:"auto"}},[i,o,a,c,u]);return Q.useEffect(()=>{if(!l.current)return;const g=l.current.offsetWidth,y=l.current.offsetHeight;if(!g||!y)return;const S=n.boxSize;if((S==null?void 0:S[0])!==g||S[1]!==y||!S){r({activeTextId:e,update:{boxSize:[g,y],workState:de.Done}});return}},[n.fontSize,n.italic,n.bold,n.boxSize,e,r]),Q.createElement("div",{className:"editor-box readonly","data-text-work-id":e,style:f},Q.createElement("div",{className:"editor",ref:l,style:h},d))},JSe=s=>{const{mananger:t}=Q.useContext(lt),e=Q.useMemo(()=>{var n;const r=i=>{var u,h;if(!t)return;const{activeTextId:o,update:a,syncData:c}=i,l=o&&ye.cloneDeep(((u=t.control.textEditorManager)==null?void 0:u.get(o))||((h=s.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=s.editors)!=null&&n.size){const i=[];return s.editors.forEach((o,a)=>{if(s.selectIds&&s.selectIds.includes(a)){const c=Q.createElement(XSe,{key:a,workId:a,data:o,updateOptInfo:r});i.push(c)}}),i}return null},[s.editors,s.selectIds,t]);return Q.createElement(Q.Fragment,null,e)},_Se=s=>{const{position:t,textOpt:e,workIds:r,noLayer:n,noCopy:i,noDelete:o,style:a}=s,c=Q.useRef(null);return Q.createElement("div",{className:mt.FloatBarBtn,ref:c,style:a},Q.createElement(lM,{position:t,textOpt:e,workIds:r,noLayer:n,noCopy:i,noDelete:o}))},eTe=s=>{const{data:t,workId:e,showFloatBtns:r,handleKeyUp:n,handleFocus:i,runAnimation:o,updateSize:a,rightBoundBreak:c}=s,{activeTextEditor:l,activeTextId:u,mananger:h}=Q.useContext(lt),{opt:d,scale:f,translate:g,x:y,y:S}=t,{fontSize:b,fontFamily:I,underline:N,fontColor:T,lineThrough:p,textAlign:m,lineHeight:v,bold:M,italic:k}=d,E=Q.useRef(null),D=Q.useMemo(()=>{const w=b,C=v||w*1.2,U={fontSize:`${w}px`,lineHeight:`${C}px`,caretColor:T,color:"transparent",minHeight:`${C}px`,paddingRight:`${k==="italic"?Math.round(w*.3):5}px`,borderWidth:0};return I&&(U.fontFamily=`${I}`),(p||N)&&(U.textDecoration=`${p&&"line-through"||""} ${N&&" underline"||""}`),m&&(U.textAlign=`${m}`),M&&(U.fontWeight=`${M}`),k&&(U.fontStyle=`${k}`),U},[M,T,I,b,k,v,p,f,m,N]),P=Q.useRef(!1),z=Q.useRef(6),j=Q.useRef(),A=Q.useRef(),R=Q.useRef(!1),L=Q.useRef(!1),W=Q.useRef({fontSize:D.fontSize,lineHeight:D.lineHeight,fontStyle:D.fontStyle,fontWeight:D.fontWeight,fontFamily:D.fontFamily}),Y=Q.useMemo(()=>typeof window>"u"?!1:navigator.maxTouchPoints>0||"ontouchstart"in window,[]),H=Q.useMemo(()=>u===e?"hover":d.workState===de.Doing||d.workState===de.Start?"editing":l?"active":"none",[u,e,d.workState,l]);function ie(w){if(!E.current)return;const U=w&&DMe(w.nativeEvent)?LMe(w.nativeEvent):void 0,G=()=>{j.current&&(cancelAnimationFrame(j.current),j.current=void 0),A.current&&(window.clearTimeout(A.current),A.current=void 0)},_=re=>{const ne=E.current,X=window==null?void 0:window.getSelection();if(!(!ne||!X||!R.current)){if(document.activeElement!==ne)try{ne.focus({preventScroll:!0})}catch{ne.focus()}if(re){const{x:ae,y:ue}=re;if(document.caretPositionFromPoint){const he=document.caretPositionFromPoint(ae,ue);if(he){const ge=ne.contains(he.offsetNode);if(ge){const Me=document.createRange();Me.setStart(he.offsetNode,he.offset),Me.collapse(!0),X.removeAllRanges(),X.addRange(Me),L.current=!0}if(ge)return}}else if(document.caretRangeFromPoint){const he=document.caretRangeFromPoint(ae,ue);if(he){const ge=ne.contains(he.startContainer);if(ge&&(X.removeAllRanges(),X.addRange(he),L.current=!0),ge)return}}if(wye(X,ne,re)){L.current=!0;return}}Tye({hasPoint:!!re,previousByPoint:L.current,hasSelectionInEditor:Ep(X,ne),rangeCount:X.rangeCount,isCollapsed:X.isCollapsed})||(yye(X,ne),L.current=!1)}};G(),_(U),Y&&(j.current=requestAnimationFrame(()=>{_(),A.current=window.setTimeout(()=>{_(),A.current=void 0},32),j.current=void 0}))}const O=Q.useMemo(()=>{const w=`scale(${f||1}) ${g&&"translate("+g[0]+"px,"+g[1]+"px)"||""}`;return{left:`${y-Ni*(f||1)}px`,top:`${S-Ni*(f||1)}px`,zIndex:2,transform:w,transformOrigin:"left top",borderColor:H==="editing"||H==="hover"?T:"transparent"}},[f,g,y,S,T,H]),V=Q.useMemo(()=>{let w="";const C="<div></div>";if(d.text){const U=Nn(d.text);for(let G=0;G<U.length;G++){const _=U[G];if(_==="")w=w+C;else{const re=_.replace(/[<>&]/g,ne=>({"<":"<",">":">","&":"&"})[ne]);w=w+`<div>${re}</div>`}}}else w=C;return w},[d.fontBgColor,d.text]),Z=Q.useMemo(()=>{var w,C;if(H==="hover"){if(f&&r&&ye.isNumber(y)&&ye.isNumber(S)&&d.boxSize&&ye.isNumber((w=d.boxSize)==null?void 0:w[0])&&ye.isNumber((C=d.boxSize)==null?void 0:C[1])){const U={x:y,y:S},G={left:y,top:S,width:d.boxSize[0]*f,height:d.boxSize[1]*f};return Q.createElement(_Se,{position:U,style:G,textOpt:d,workIds:[e],noLayer:!0,noCopy:!0,noDelete:!0})}return null}return null},[d,r,e,y,S,f,H]);Q.useEffect(()=>{R.current=u===e,u!==e&&(j.current&&(cancelAnimationFrame(j.current),j.current=void 0),A.current&&(window.clearTimeout(A.current),A.current=void 0),L.current=!1)},[u,e]),Q.useEffect(()=>{if(u===e&&E.current){const w=window==null?void 0:window.getSelection(),C=Ep(w,E.current);(document.activeElement!==E.current||!C)&&ie(),i(E.current)}},[u,i,e,Y]),Q.useEffect(()=>{const w=E.current;if(!w)return;const C=S0(w),U=d.text||"";C!==U&&(u===e&&P.current||(w.innerHTML=V))},[u,V,d.boxSize,d.text,d.workState,e]),Q.useEffect(()=>()=>{j.current&&cancelAnimationFrame(j.current),A.current&&window.clearTimeout(A.current)},[]),Q.useEffect(()=>{if(E.current){const w=parseInt(getComputedStyle(E.current).paddingRight,10)+parseInt(getComputedStyle(E.current).borderWidth,10);z.current=Number(w)}},[]),Q.useEffect(()=>{if(E.current){const w={fontSize:D.fontSize,lineHeight:D.lineHeight,fontStyle:D.fontStyle,fontWeight:D.fontWeight,fontFamily:D.fontFamily};if(!ye.isEqual(W.current,w)){W.current=w;const C=[E.current.offsetWidth,E.current.offsetHeight];a(e,C)}}},[D,e,a,H,l,u]);const $=Q.useCallback(w=>{const C=h==null?void 0:h.parentElement,U=E.current;if(!C||!U||!c)return!1;const{lastLine:G}=xp(U);if(!G||G instanceof Text)return!1;const _=G==null?void 0:G.getBoundingClientRect(),re=C==null?void 0:C.getBoundingClientRect();if(!_||!re)return!1;if(_.right+w>re.right){const{textContent:ne,textNodes:X}=Sye(G);if(!X.length)return!1;const ae=ne.length,ue=ws(X,0);if(!ue)return!1;let he=0,ge=0,Me=ae;for(;ge<Me;){const we=Math.floor((ge+Me)/2),be=ws(X,we);if(!be)break;const Ce=document.createRange();Ce.setStart(ue.node,ue.offset),Ce.setEnd(be.node,be.offset);const Ie=Ce.getBoundingClientRect(),Ae=re.right-Ie.right;if(Ae<w){if(we>0){const Ee=ws(X,we-1);if(!Ee)break;const ke=document.createRange();ke.setStart(ue.node,ue.offset),ke.setEnd(Ee.node,Ee.offset);const Ne=ke.getBoundingClientRect();if(re.right-Ne.right>=w){he=we-1;break}}Me=we}else{const Ee=we+1;if(Ee<ae){const ke=ws(X,Ee);if(!ke)break;const Ne=document.createRange();Ne.setStart(ue.node,ue.offset),Ne.setEnd(ke.node,ke.offset);const Oe=Ne.getBoundingClientRect();if(re.right-Oe.right<=w&&Ae>w){he=we;break}}ge=Ee}}if(!he){const we=ws(X,ge);if(!we)return!1;const be=document.createRange();be.setStart(ue.node,ue.offset),be.setEnd(we.node,we.offset);const Ce=be.getBoundingClientRect();re.right-Ce.right>w?he=ge:ge>0&&(he=ge-1)}if(he>0){const we=ne.slice(0,he),be=ne.slice(he);G.textContent=we;const Ce=document.createElement("div");return be&&(Ce.textContent=be),E.current.appendChild(Ce),$(w),!0}}return!1},[h==null?void 0:h.parentElement,d.fontBgColor,c]);function ee(w){if(w.stopPropagation(),w.nativeEvent.stopImmediatePropagation(),w.key==="Backspace"){const C=window.getSelection(),U=C==null?void 0:C.getRangeAt(0);if(U!=null&&U.collapsed)return w.cancelable&&w.preventDefault(),document.execCommand("delete",!1),!1}return!1}function se(w,C){const U=window==null?void 0:window.getSelection();if(U!=null&&U.rangeCount&&w&&U&&U.anchorNode){const G=U.anchorOffset,_=U.anchorNode.textContent||"",re=_.slice(0,G)||"",ne=_.slice(G)||"",X=re.concat(w)||"";ce(X,ne,C)}}function ce(w,C,U){const G=window==null?void 0:window.getSelection();if(!(G!=null&&G.rangeCount)||!G.anchorNode)return;const _=w.split(/\n/);let re=G.anchorNode.parentNode;re===U&&(re=G.anchorNode);const ne=[...U.childNodes],X=[];let ae,ue=G.anchorOffset;for(;ne.length;){const he=ne.pop();if(he){if(he===re){let ge=_[0];_.length===1&&(ue=_[0].length,ge=_[0].concat(C)),re.nodeName==="#text"?(re.textContent=ge,ae=re):re.nodeName==="DIV"&&(re.innerText=ge,ae=re.childNodes[0]);break}X.push(he),U.removeChild(he)}}if(_.length>1)for(let he=1;he<_.length;he++){let ge=_[he];const Me=document.createElement("div");he===_.length-1&&(ue=ge.length,ge=ge.concat(C)),Me.innerText=ge,U.appendChild(Me),he===_.length-1&&(ae=Me.childNodes[0])}if(X.length){X.reverse();for(const he of X)U.appendChild(he)}if(ae&&ae.nodeName==="#text"){G.deleteFromDocument();const he=document.createRange(),ge=Math.min(ue,(ae==null?void 0:ae.length)||0);he.setStart(ae,ge),he.collapse(!0),G.removeAllRanges(),G.addRange(he)}}function me(w){if(w.cancelable&&w.preventDefault(),w.stopPropagation(),w.nativeEvent.stopImmediatePropagation(),E.current){const C=(w.clipboardData||window.clipboardData).getData("text"),U=window==null?void 0:window.getSelection();if(!(U!=null&&U.rangeCount))return;if(C&&U&&U.anchorNode){const G=eu(C,{whiteList:{},stripIgnoreTag:!0,stripIgnoreTagBody:["script"]});se(G,E.current),$((f||1)*z.current),n(E.current)}o()}return!1}function pe(w){xp(w)}const B=Q.useCallback(()=>{const w=E.current;o(()=>{if(w){pe(w);let C=!1;if(!P.current&&(C=$((f||1)*z.current),C)){const U=window.getSelection();if(!(U!=null&&U.rangeCount))return!1;const G=document.createRange(),_=E.current.lastChild;G.selectNodeContents(_),G.collapse(!1),U.removeAllRanges(),U.addRange(G)}n(w)}})},[n,$,o,f]);function F(){P.current=!0,o()}function J(){P.current=!1,B()}function oe(){B(),o()}const K=Q.useCallback(()=>{if(H==="active"&&E.current&&E.current.parentElement){const w=E.current.parentElement;w.style.borderColor=T}},[H,T]),te=Q.useCallback(()=>{if(H==="active"&&E.current&&E.current.parentElement){const w=E.current.parentElement;w.style.borderColor="transparent"}},[H]);return Q.createElement(Q.Fragment,null,Z,Q.createElement("div",{className:`editor-box ${H}`,style:O,onPointerUp:()=>{var w;if(H==="editing"){o(()=>{var C;(C=document.activeElement)==null||C.blur(),h==null||h.control.textEditorManager.checkEmptyTextBlur()});return}if(H==="active"&&h){if((w=h.control.collector)!=null&&w.hasIncludeSelector(e)){o(()=>{var C;(C=document.activeElement)==null||C.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:K,onMouseLeave:te},Q.createElement("div",{id:e,suppressContentEditableWarning:!0,contentEditable:!0,className:"editor",ref:E,style:D,onKeyDown:ee,onPaste:me,onTouchEnd:ie,onInput:B,onCompositionStart:F,onCompositionUpdate:oe,onCompositionEnd:J,dangerouslySetInnerHTML:{__html:V}})))},tTe=s=>{const t=Q.useRef(null),{mananger:e}=Q.useContext(lt),r=Q.useRef(),n=Q.useRef(),i=Q.useRef();Q.useEffect(()=>()=>{r.current&&cancelAnimationFrame(r.current),n.current&&cancelAnimationFrame(n.current),i.current&&cancelAnimationFrame(i.current)},[]);const o=Q.useCallback(c=>{var f,g;const{activeTextId:l,update:u,syncData:h}=c;if(!e)return;const d=l&&ye.cloneDeep(((f=e.control.textEditorManager)==null?void 0:f.get(l))||((g=s.editors)==null?void 0:g.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,s.editors]),a=Q.useMemo(()=>{var g;const c=y=>{if(!e)return;const S=y.id,b=e.control.textEditorManager.get(S),I=de.Doing,N=[y.offsetWidth,y.offsetHeight];(!b||b&&(!ye.isEqual(b.opt.boxSize,N)||!ye.isEqual(b.opt.workState,I)))&&o({activeTextId:S,update:{boxSize:N,workState:I},syncData:{canSync:!0,canWorker:!0}})},l=y=>{var m,v;if(!e)return;const S=w0(y),b=y.id,I=e.control.textEditorManager.get(b),N=S0(y),T=de.Doing,p=[y.offsetWidth,y.offsetHeight];if(!I||I&&(I.opt.text!==N||!ye.isEqual(I.opt.boxSize,p)||!ye.isEqual(I.opt.workState,T))){const M=b&&ye.cloneDeep(((m=e.control.textEditorManager)==null?void 0:m.get(b))||((v=s.editors)==null?void 0:v.get(b)));M&&M.opt&&(M.opt={...M.opt,text:N,boxSize:p,workState:T},M.canSync=!0,M.canWorker=!0,e.control.textEditorManager.updateForViewEdited(b,M)),e.control.textEditorManager.publicMsgEmitter.emit("textChange",b,y,S,M)}},u=(y,S)=>{if(!e)return;const b=y,I=e.control.textEditorManager.get(b);if(I&&!(!S[0]||!S[1])&&!ye.isEqual(I.opt.boxSize,S)){const N=ye.cloneDeep(I);N.opt={...N.opt,boxSize:S},N.canSync=!1,N.canWorker=!1,e.control.textEditorManager.updateForViewEdited(b,N)}},h=()=>{t.current&&t.current.scrollTo({left:0,top:0,behavior:"instant"})},d=()=>{n.current&&(cancelAnimationFrame(n.current),n.current=void 0),i.current&&(cancelAnimationFrame(i.current),i.current=void 0),n.current=requestAnimationFrame(()=>{h(),n.current=void 0,i.current=requestAnimationFrame(()=>{h(),i.current=void 0})})},f=y=>{r.current&&cancelAnimationFrame(r.current),r.current=requestAnimationFrame(()=>{t!=null&&t.current&&(h(),y&&y(),d(),r.current=void 0)})};if((g=s.editors)!=null&&g.size){const y=[];return s.editors.forEach((S,b)=>{y.push(Q.createElement(eTe,{key:b,workId:b,data:S,showFloatBtns:s.showFloatBtns||!1,handleFocus:c,handleKeyUp:l,updateSize:u,runAnimation:f,rightBoundBreak:s.rightBoundBreak||!1}))}),y}return null},[s.editors,s.showFloatBtns,s.rightBoundBreak,e,o]);return Q.createElement("div",{className:`${s.className}`,ref:t},a)},lr=(s,t,e)=>({...s,...e==null?void 0:e[t]}),rTe=()=>{const{floatBarData:s,overwriteSelectorStyles:t}=Q.useContext(lt),e={borderColor:s==null?void 0:s.selectorColor,...t.highlightBox},r={backgroundColor:s==null?void 0:s.selectorColor,...t.highlightBoxPoint};return Q.createElement("div",{className:"appliance-plugin-highlight-box",style:e},Q.createElement("div",{className:"point LT nwse-resize",style:lr(r,"LT",t.highlightBoxPoints)}),Q.createElement("div",{className:"point LC ew-resize",style:lr(r,"LC",t.highlightBoxPoints)}),Q.createElement("div",{className:"point LB nesw-resize",style:lr(r,"LB",t.highlightBoxPoints)}),Q.createElement("div",{className:"point TC ns-resize",style:lr(r,"TC",t.highlightBoxPoints)}),Q.createElement("div",{className:"point RT nesw-resize",style:lr(r,"RT",t.highlightBoxPoints)}),Q.createElement("div",{className:"point RC ew-resize",style:lr(r,"RC",t.highlightBoxPoints)}),Q.createElement("div",{className:"point RB nwse-resize",style:lr(r,"RB",t.highlightBoxPoints)}),Q.createElement("div",{className:"point BC ns-resize",style:lr(r,"BC",t.highlightBoxPoints)}))},nTe=()=>{const{floatBarData:s,mananger:t,overwriteSelectorStyles:e}=Q.useContext(lt),[r,n]=Q.useState(),[i,o]=Q.useState();Q.useEffect(()=>{const l=[];if(t&&ye.isNumber(s==null?void 0:s.x)&&ye.isNumber(s==null?void 0:s.y)&&(s!=null&&s.points)){const u=t.viewId;if(t.control.viewContainerManager.getView(u))for(const d of s.points){const f=t.control.viewContainerManager.transformToOriginPoint(d,u);l.push(f)}l[0]&&n({x:l[0][0]-((s==null?void 0:s.x)||0),y:l[0][1]-((s==null?void 0:s.y)||0)}),l[1]&&o({x:l[1][0]-((s==null?void 0:s.x)||0),y:l[1][1]-((s==null?void 0:s.y)||0)})}},[t,s==null?void 0:s.points,s==null?void 0:s.x,s==null?void 0:s.y]);const a=Q.useMemo(()=>r?Q.createElement("div",{className:"point point-dot",style:{borderColor:s==null?void 0:s.selectorColor,...e.highlightBoxPoint,...e.highlightBoxPointDot,left:r.x,top:r.y}}):null,[s==null?void 0:s.selectorColor,r]),c=Q.useMemo(()=>i?Q.createElement("div",{className:"point point-dot",style:{borderColor:s==null?void 0:s.selectorColor,...e.highlightBoxPoint,...e.highlightBoxPointDot,left:i.x,top:i.y}}):null,[i,s==null?void 0:s.selectorColor]);return Q.createElement("div",{className:"appliance-plugin-highlight-box",style:{borderColor:s==null?void 0:s.selectorColor,...e.highlightBox}},a,c)},iTe=()=>{const{floatBarData:s,overwriteSelectorStyles:t}=Q.useContext(lt),e={borderColor:s==null?void 0:s.selectorColor,...t.highlightBox},r={backgroundColor:s==null?void 0:s.selectorColor,...t.highlightBoxPoint};return Q.createElement("div",{className:"appliance-plugin-highlight-box",style:e},Q.createElement("div",{className:"point LT nwse-resize",style:lr(r,"LT",t.highlightBoxPoints)}),Q.createElement("div",{className:"point LB nesw-resize",style:lr(r,"LB",t.highlightBoxPoints)}),Q.createElement("div",{className:"point RT nesw-resize",style:lr(r,"RT",t.highlightBoxPoints)}),Q.createElement("div",{className:"point RB nwse-resize",style:lr(r,"RB",t.highlightBoxPoints)}))},sTe=()=>{const{floatBarData:s,overwriteSelectorStyles:t}=Q.useContext(lt);return Q.createElement("div",{className:"appliance-plugin-highlight-box",style:{borderColor:s==null?void 0:s.selectorColor,...t.highlightBox}},Q.createElement("img",{className:"lock",alt:"lock",src:"https://sdk.netless.link/resource/icons/lock.svg",style:t.highlightBoxLock}))};function bt(s){return!!(s&&s.control.canAcceptLocalMutation(s.viewId))}const oTe=s=>{const{className:t}=s,{floatBarData:e,angle:r,setAngle:n,setOperationType:i,mananger:o,viewId:a}=Q.useContext(lt),[c,l]=Q.useState(de.Pending),[u,h]=Q.useState(),[d,f]=Q.useState(!1),[g,y]=Q.useState(new Pe),[S,b]=Q.useState(new Pe),[I,N]=Q.useState(!1),T=Q.useRef(0),p=Q.useRef(!1),m=Q.useRef(null),v=(z,j)=>{n(z),i(j===de.Done?Te.None:Te.RotateNode),l(j),j===de.Done?(f(!1),o==null||o.focusElement()):f(!0),Ve.emitMethod(We.MainEngine,Te.RotateNode,{workIds:[Le],angle:j===de.Start?0:z,workState:j,viewId:o==null?void 0:o.viewId})},M=(z,j)=>{if(!(j&&j!==a)){if(!z){p.current=!0,T.current&&clearTimeout(T.current),T.current=0,N(!0),f(!1),i(Te.None),l(de.Pending);return}N(!1)}},k=(z,j)=>{T.current&&(clearTimeout(T.current),T.current=0),l(de.Done),f(!1);const A=Math.round(Pe.GetAngleByPoints(g,S,new Pe(j.x,j.y)))||0;v(A,de.Done)};Q.useEffect(()=>{const z=()=>{p.current&&(T.current&&clearTimeout(T.current),T.current=0,l(de.Pending),f(!1),i(Te.None))};return Ve.activeListener(M),document.addEventListener("pointercancel",z),()=>{Ve.unmountActiveListener(M),document.removeEventListener("pointercancel",z)}},[]),Q.useEffect(()=>{if(window.__selectorE2E__)return window.__selectorRotateE2E__={start:(z=g.x,j=g.y)=>{if(!bt(o))return;p.current=!1;const A=Math.round(Pe.GetAngleByPoints(g,S,new Pe(z,j)))||0;v(A,de.Start)},doing:(z,j)=>{if(p.current)return;if(!bt(o)){p.current=!0,l(de.Pending),i(Te.None);return}const A=Math.round(Pe.GetAngleByPoints(g,S,new Pe(z,j)))||0;h({x:z,y:j}),v(A,de.Doing)},done:(z,j)=>{if(p.current||!bt(o))return;const A=Math.round(Pe.GetAngleByPoints(g,S,new Pe(z,j)))||0;h({x:z,y:j}),v(A,de.Done)}},()=>{window.__selectorRotateE2E__&&delete window.__selectorRotateE2E__}},[S,o,g]),Q.useEffect(()=>{if(e&&(c===de.Pending||c===de.Done)){const z={x:(e==null?void 0:e.x)-20,y:(e==null?void 0:e.y)+(e==null?void 0:e.h)},j={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};b(new Pe(j.x,j.y)),y(new Pe(z.x,z.y)),h({x:z.x,y:z.y})}},[e,c]);const E=(z,j)=>{if(!bt(o))return!1;p.current=!1,T.current&&(clearTimeout(T.current),T.current=0),l(de.Start),f(!0);const A=Math.round(Pe.GetAngleByPoints(g,S,new Pe(j.x,j.y)))||0;v(A,de.Start)},D=(z,j)=>{if(p.current){T.current&&clearTimeout(T.current),T.current=0,f(!1),i(Te.None);return}if(!bt(o)){p.current=!0,l(de.Pending),f(!1),i(Te.None);return}k(z,j)},P=(z,j)=>{if(!p.current){if(!bt(o))return p.current=!0,T.current&&clearTimeout(T.current),T.current=0,l(de.Pending),f(!1),i(Te.None),!1;T.current||(h({x:j.x,y:j.y}),f(!0),T.current=setTimeout(()=>{if(T.current=0,p.current||!bt(o))return;const A=Math.round(Pe.GetAngleByPoints(g,S,new Pe(j.x,j.y)))||0;v(A,de.Doing)},60))}};return Q.createElement(Qi,{disabled:I,position:u,onStart:E,onDrag:P,onStop:D},Q.createElement("div",{className:`${t}`,style:e?{left:0,top:0,touchAction:"none"}:void 0},!d&&Q.createElement("div",{className:"appliance-plugin-rotate-btn",style:{backgroundColor:e==null?void 0:e.selectorColor}},Q.createElement("img",{alt:"icon",src:At("rotation-button")})),Q.createElement("div",{ref:m,className:`appliance-plugin-rotate-mouse-pointer ${d?"active":""}`},Q.createElement("img",{alt:"icon",src:At("rotation")}),Q.createElement("div",{className:"angle-icon"},r,"°"))))};function aTe(s){const t=s==null?void 0:s.viewId;if(!t)return;const e=s.control.viewContainerManager.getView(t),r=e==null?void 0:e.focusScenePath,n=s.control.viewContainerManager.getUndoTickerId(t);!n||!r||(s.control.internalMsgEmitter.emit("cancelUndoTicker",n,t,r),s.control.worker.abled())}function cTe(s,t){const e=s.control.worker.now;return s.control.textEditorManager.active(t,e),e}const lTe="data-text-work-id";function uTe(s){var t,e;if(s instanceof HTMLElement)return((e=(t=s.closest(`[${lTe}]`))==null?void 0:t.dataset)==null?void 0:e.textWorkId)||void 0}const hTe=Q.memo(s=>{const{editors:t,canSelectorSwitch:e}=s,{floatBarData:r,setOperationType:n,mananger:i,isNoPointerEvents:o,viewId:a}=Q.useContext(lt),[c,l]=Q.useState(),[u,h]=Q.useState(!1),d=Q.useRef(0),f=Q.useRef(),g=Q.useRef(de.Pending),y=Q.useRef(!1),S=Q.useMemo(()=>!!((r==null?void 0:r.scaleType)===Ye.none&&(r!=null&&r.canLock)),[r]),b=Q.useMemo(()=>r&&r.w&&r.h?{position:"absolute",left:0,top:0,width:r.w,height:r.h,zIndex:2,pointerEvents:S||o?"none":"auto",touchAction:"none"}:{display:"none",pointerEvents:"none"},[r,S,o]),I=(v,M)=>{if(!(M&&M!==a)){if(!v||r!=null&&r.isLocked){y.current=!0,d.current&&clearTimeout(d.current),d.current=0,h(!0),g.current=de.Pending,n(Te.None);return}h(!1)}},N=(v,M)=>{d.current&&(clearTimeout(d.current),d.current=0);const k={x:M.x,y:M.y};n(Te.None),g.current=de.Done,l(k),Ve.emitMethod(We.MainEngine,Te.TranslateNode,{workIds:[Le],position:k,workState:de.Done,viewId:i==null?void 0:i.viewId})};Q.useEffect(()=>{const v=()=>{y.current&&(d.current&&clearTimeout(d.current),d.current=0,f.current=void 0,g.current=de.Pending,n(Te.None))};return Ve.activeListener(I),document.addEventListener("pointercancel",v),()=>{Ve.unmountActiveListener(I),document.removeEventListener("pointercancel",v)}},[]),Q.useEffect(()=>{if(r&&(r!=null&&r.isLocked)){h(!0);return}h(!1)},[r]),Q.useEffect(()=>{(g.current===de.Pending||g.current===de.Done)&&ye.isNumber(r==null?void 0:r.x)&&ye.isNumber(r==null?void 0:r.y)&&l({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 T=v=>{const M=v&&"target"in v?v.target:null,k=e?uTe(M):void 0;if(!bt(i)||!ye.isNumber(r==null?void 0:r.x)||!ye.isNumber(r==null?void 0:r.y))return!1;y.current=!1,d.current&&(clearTimeout(d.current),d.current=0),f.current=k,n(Te.TranslateNode),g.current=de.Start,Ve.emitMethod(We.MainEngine,Te.TranslateNode,{workIds:[Le],position:{x:r.x,y:r.y},workState:de.Start,viewId:i==null?void 0:i.viewId})},p=(v,M)=>{var P,z;if(y.current){d.current&&clearTimeout(d.current),d.current=0,f.current=void 0,n(Te.None);return}if(!bt(i)){y.current=!0,d.current&&clearTimeout(d.current),d.current=0,f.current=void 0,g.current=de.Pending,n(Te.None);return}const k=g.current,E=f.current;if(!!E&&k===de.Start&&i&&e){aTe(i),cTe(i,E),f.current=void 0,g.current=de.Pending,n(Te.None);const j=(P=i.control.viewContainerManager.getView(i.viewId))==null?void 0:P.focusScenePath;j&&i.control.worker.blurSelector(i.viewId,j);return}if(N(v,M),f.current&&(f.current=void 0),k===de.Start&&(t!=null&&t.size)&&E){const j=(z=i==null?void 0:i.control.viewContainerManager.getView(i.viewId))==null?void 0:z.focusScenePath;j&&(i==null||i.control.worker.blurSelector(i.viewId,j))}i==null||i.focusElement()},m=(v,M)=>{if(y.current)return;if(!bt(i))return y.current=!0,d.current&&clearTimeout(d.current),d.current=0,f.current=void 0,g.current=de.Pending,n(Te.None),!1;if(d.current)return;const k={x:M.x,y:M.y};l(k),d.current=setTimeout(()=>{d.current=0,!(y.current||!bt(i))&&(k.x!==(c==null?void 0:c.x)||k.y!==(c==null?void 0:c.y))&&(f.current&&(f.current=void 0),g.current=de.Doing,Ve.emitMethod(We.MainEngine,Te.TranslateNode,{workIds:[Le],position:k,workState:de.Doing,viewId:i==null?void 0:i.viewId}))},60)};return Q.createElement(Qi,{disabled:u,position:c,onStart:T,onDrag:m,onStop:p},Q.createElement("div",{style:b},Q.createElement(dTe,{editors:t,selectIds:(r==null?void 0:r.selectIds)||[]})))},(s,t)=>!!ye.isEqual(s,t)),dTe=Q.memo(s=>{const{editors:t,selectIds:e}=s;return t?Q.createElement(JSe,{editors:t,selectIds:e||[]}):null},(s,t)=>!(!ye.isEqual(s.editors,t.editors)||!ye.isEqual(s.selectIds,t.selectIds))),fTe=s=>{const{className:t}=s,[e,r]=Q.useState({x:0,y:0,h:0,w:0}),[n,i]=Q.useState(),[o,a]=Q.useState(),[c,l]=Q.useState(),{floatBarData:u,mananger:h,isNoPointerEvents:d,setOperationType:f,viewId:g}=Q.useContext(lt),[y,S]=Q.useState(),[b,I]=Q.useState(!1),N=Q.useRef(0),T=Q.useRef(!1);Q.useEffect(()=>{const z=()=>{T.current&&(N.current&&clearTimeout(N.current),N.current=0,f(Te.None))};if(u&&h){const j={x:u.x,y:u.y,w:u.w,h:u.h};r(j)}return Ve.activeListener(m),document.addEventListener("pointercancel",z),()=>{Ve.unmountActiveListener(m),document.removeEventListener("pointercancel",z)}},[]);const p=()=>{if(N.current&&(clearTimeout(N.current),N.current=0),y){const{scale:z,translate:j}=y;f(Te.None),Ve.emitMethod(We.MainEngine,Te.ScaleNode,{workIds:[Le],scale:z,dir:c,translate:j,originPoint:n,scenePoint:o,workState:de.Done,viewId:h==null?void 0:h.viewId})}h==null||h.focusElement()},m=(z,j)=>{if(!(j&&j!==g)){if(!z){T.current=!0,N.current&&clearTimeout(N.current),N.current=0,S(void 0),I(!0);return}I(!1)}},v=z=>[[z.x,z.y],[z.x+z.w,z.y],[z.x+z.w,z.y+z.h],[z.x,z.y+z.h]],M=(z,j)=>{switch(j){case"top":case"topLeft":case"left":return z[2];case"topRight":return z[3];case"right":case"bottomRight":case"bottom":return z[0];case"bottomLeft":return z[1]}},k=(z,j,A,R)=>{let L=!1,W=!1;const Y={x:e.x,y:e.y,w:e.w,h:e.h},H=[1,1],ie=[0,0];switch(z){case"top":{const $=j.height+e.h;$<0?(W=!0,Y.y=e.y+e.h,Y.h=Math.abs($)):(Y.y=e.y-j.height,Y.h=e.h+j.height);break}case"topLeft":{const $=j.width+e.w;$<0?(L=!0,Y.x=e.x+e.w,Y.w=Math.abs($)):(Y.x=e.x-j.width,Y.w=e.w+j.width);const ee=j.height+e.h;ee<0?(W=!0,Y.y=e.y+e.h,Y.h=Math.abs(ee)):(Y.y=e.y-j.height,Y.h=e.h+j.height);break}case"topRight":{const $=j.width+e.w;$<0?(L=!0,Y.x=e.x+$,Y.w=Math.abs($)):Y.w=e.w+j.width;const ee=j.height+e.h;ee<0?(W=!0,Y.y=e.y+e.h,Y.h=Math.abs(ee)):(Y.y=e.y-j.height,Y.h=e.h+j.height);break}case"bottom":{const $=j.height+e.h;$<0?(W=!0,Y.y=e.y+$,Y.h=Math.abs($)):Y.h=e.h+j.height;break}case"bottomLeft":{const $=j.width+e.w;$<0?(L=!0,Y.x=e.x+e.w,Y.w=Math.abs($)):(Y.x=e.x-j.width,Y.w=e.w+j.width);const ee=j.height+e.h;ee<0?(W=!0,Y.y=e.y+ee,Y.h=Math.abs(ee)):Y.h=e.h+j.height;break}case"left":{const $=j.width+e.w;$<0?(L=!0,Y.x=e.x+e.w,Y.w=Math.abs($)):(Y.x=e.x-j.width,Y.w=e.w+j.width);break}case"bottomRight":{const $=j.width+e.w;$<0?(L=!0,Y.x=e.x+$,Y.w=Math.abs($)):Y.w=e.w+j.width;const ee=j.height+e.h;ee<0?(W=!0,Y.y=e.y+ee,Y.h=Math.abs(ee)):Y.h=e.h+j.height;break}case"right":{const $=j.width+e.w;$<0?(L=!0,Y.x=e.x+$,Y.w=Math.abs($)):Y.w=e.w+j.width;break}}H[0]=Y.w/e.w,H[1]=Y.h/e.h;const V=v(Y).map($=>A.control.viewContainerManager.transformToScenePoint($,A.viewId)),Z=M(V,z);return W&&(ie[1]=Z[1]-R[1]),L&&(ie[0]=Z[0]-R[0]),{scale:H,translate:ie}},E=(z,j)=>{if(!bt(h)||!(u!=null&&u.w)||!(u!=null&&u.h))return!1;T.current=!1,S(void 0),N.current&&(clearTimeout(N.current),N.current=0);const A={x:u.x,y:u.y,w:u.w,h:u.h},R=v(A),L=R.map(H=>h.control.viewContainerManager.transformToScenePoint(H,h.viewId)),W=M(R,j),Y=M(L,j);r(A),i(W),a(Y),l(j),f(Te.ScaleNode),Ve.emitMethod(We.MainEngine,Te.ScaleNode,{workIds:[Le],originPoint:W,scenePoint:Y,workState:de.Start,viewId:h.viewId})},D=(z,j,A,R)=>{if(!T.current&&!(!h||!n||!o)){if(!bt(h))return T.current=!0,N.current&&clearTimeout(N.current),N.current=0,f(Te.None),!1;N.current||(N.current=setTimeout(()=>{if(N.current=0,T.current||!bt(h))return;const{scale:L,translate:W}=k(j,R,h,o);(!ye.isEqual(L,y==null?void 0:y.scale)||!ye.isEqual(W,y==null?void 0:y.translate))&&(S({scale:L,translate:W}),f(Te.ScaleNode),Ve.emitMethod(We.MainEngine,Te.ScaleNode,{workIds:[Le],scale:L,dir:j,translate:W,originPoint:n,scenePoint:o,workState:de.Doing,viewId:h.viewId}))},60))}},P=()=>{if(T.current){N.current&&clearTimeout(N.current),N.current=0,f(Te.None);return}if(!bt(h)){T.current=!0,N.current&&clearTimeout(N.current),N.current=0,f(Te.None);return}p()};return Q.createElement(TM.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:b?!1:{top:(u==null?void 0:u.scaleType)===Ye.all&&!0||!1,right:(u==null?void 0:u.scaleType)===Ye.all&&!0||!1,bottom:(u==null?void 0:u.scaleType)===Ye.all&&!0||!1,left:(u==null?void 0:u.scaleType)===Ye.all&&!0||!1,topRight:!0,bottomRight:!0,bottomLeft:!0,topLeft:!0},lockAspectRatio:(u==null?void 0:u.scaleType)===Ye.proportional,onResizeStart:E,onResize:D,onResizeStop:P})},nm=s=>{const{id:t,pos:e,pointMap:r,type:n}=s,{setOperationType:i,mananger:o,floatBarData:a,viewId:c}=Q.useContext(lt),[l,u]=Q.useState({x:0,y:0}),[h,d]=Q.useState(de.Pending),[f,g]=Q.useState(!1),y=Q.useRef(0),S=Q.useRef(!1),b=Q.useMemo(()=>a?{left:0,top:0}:{},[a]),I=(v,M)=>{if(!(M&&M!==c)){if(!v||a!=null&&a.isLocked){S.current=!0,y.current&&clearTimeout(y.current),y.current=0,g(!0),d(de.Pending),i(Te.None);return}g(!1)}};Q.useEffect(()=>{const v=()=>{S.current&&(y.current&&clearTimeout(y.current),y.current=0,d(de.Pending),i(Te.None))};return Ve.activeListener(I),document.addEventListener("pointercancel",v),()=>{Ve.unmountActiveListener(I),document.removeEventListener("pointercancel",v)}},[]),Q.useEffect(()=>{ye.isNumber(e.x)&&ye.isNumber(e.y)&&(h===de.Pending||h===de.Done)&&u({x:e.x,y:e.y})},[e,h]),Q.useEffect(()=>{if(a&&(a!=null&&a.isLocked)){g(!0);return}g(!1)},[a]);const N=(v,M)=>{y.current&&(clearTimeout(y.current),y.current=0),i(Te.None),d(de.Done);const k={x:M.x,y:M.y};if(u(k),o!=null&&o.control.viewContainerManager){const E=o.control.viewContainerManager.transformToScenePoint([k.x,k.y],o.viewId),D=r.get(t);D&&n==="start"?D[0]=E:D&&n==="end"&&(D[1]=E),Ve.emitMethod(We.MainEngine,Te.SetPoint,{workId:Le,pointMap:r,workState:de.Done,viewId:o==null?void 0:o.viewId})}o==null||o.focusElement()},T=()=>{if(!bt(o)||!ye.isNumber(e.x)||!ye.isNumber(e.y))return!1;S.current=!1,y.current&&(clearTimeout(y.current),y.current=0),i(Te.SetPoint),d(de.Start),Ve.emitMethod(We.MainEngine,Te.SetPoint,{workId:Le,pointMap:r,workState:de.Start,viewId:o==null?void 0:o.viewId})},p=(v,M)=>{if(S.current)return;if(!bt(o))return S.current=!0,y.current&&clearTimeout(y.current),y.current=0,d(de.Pending),i(Te.None),!1;if(y.current)return;const k={x:M.x,y:M.y};u(k),y.current=setTimeout(()=>{if(y.current=0,!(S.current||!bt(o))&&o!=null&&o.control.viewContainerManager){const E=o.control.viewContainerManager.transformToScenePoint([k.x,k.y],o.viewId),D=r.get(t);D&&n==="start"?D[0]=E:D&&n==="end"&&(D[1]=E),d(de.Doing),Ve.emitMethod(We.MainEngine,Te.SetPoint,{workId:Le,pointMap:r,workState:de.Doing,viewId:o==null?void 0:o.viewId})}},60)},m=(v,M)=>{if(S.current){y.current&&clearTimeout(y.current),y.current=0,i(Te.None);return}if(!bt(o)){S.current=!0,y.current&&clearTimeout(y.current),y.current=0,d(de.Pending),i(Te.None);return}N(v,M)};return Q.createElement(Qi,{disabled:f,position:l,onStart:T,onDrag:p,onStop:m},Q.createElement("div",{className:"appliance-plugin-point-draggable-btn",style:b}))},gTe=s=>{const{className:t}=s,{floatBarData:e,mananger:r}=Q.useContext(lt),[n,i]=Q.useState(),[o,a]=Q.useState(),[c,l]=Q.useState(new Map);Q.useEffect(()=>{const d=[];if(r&&(e!=null&&e.points)){const f=r.viewId;if(r.control.viewContainerManager.getView(f))for(const y of e.points){const S=r.control.viewContainerManager.transformToOriginPoint(y,f);d.push(S)}e!=null&&e.selectIds&&e.selectIds.length===1&&(c.set(e.selectIds[0],e.points),l(c))}d[0]&&i({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=Q.useMemo(()=>n&&(e!=null&&e.selectIds)?Q.createElement(nm,{pos:n,type:"start",id:e.selectIds[0],pointMap:c}):null,[n,e==null?void 0:e.selectIds,c]),h=Q.useMemo(()=>o&&(e!=null&&e.selectIds)?Q.createElement(nm,{pos:o,type:"end",id:e.selectIds[0],pointMap:c}):null,[o,e==null?void 0:e.selectIds,c]);return Q.createElement("div",{className:`${t}`},u,h)},pTe=Q.forwardRef((s,t)=>{const{floatBarData:e,operationType:r}=Q.useContext(lt),n=Q.useMemo(()=>(e==null?void 0:e.scaleType)!==Ye.all||r===Te.RotateNode?null:Q.createElement(rTe,null),[e,r]),i=Q.useMemo(()=>(e==null?void 0:e.scaleType)!==Ye.both||r===Te.RotateNode?null:Q.createElement(nTe,null),[e,r]),o=Q.useMemo(()=>(e==null?void 0:e.scaleType)!==Ye.proportional||r===Te.RotateNode?null:Q.createElement(iTe,null),[e,r]),a=Q.useMemo(()=>(e==null?void 0:e.scaleType)===Ye.none&&(e!=null&&e.canLock)?Q.createElement(sTe,null):null,[e]);return Q.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,i,o,s.children)}),mTe=Q.memo(s=>{const{isHide:t,operationType:e,floatBarData:r}=s;return t&&e===Te.None&&ye.isNumber(r==null?void 0:r.x)&&ye.isNumber(r==null?void 0:r.y)&&ye.isNumber(r==null?void 0:r.w)&&ye.isNumber(r==null?void 0:r.h)?Q.createElement("div",{className:mt.FloatBarBtn,style:{left:r==null?void 0:r.x,top:r==null?void 0:r.y,width:r.w,height:r.h}},Q.createElement(lM,{position:{x:r.x,y:r.y},textOpt:r==null?void 0:r.textOpt,noLayer:r==null?void 0:r.isLocked})):null},(s,t)=>!!ye.isEqual(s,t)),yTe=Q.forwardRef((s,t)=>{const{floatBarData:e,operationType:r,mananger:n}=Q.useContext(lt),{editors:i,isHide:o,canSelectorSwitch:a}=s,c=Q.useRef(null);Q.useEffect(()=>{const d=c.current;if(!d)return;const f=g=>{g.stopPropagation(),g.stopImmediatePropagation(),n==null||n.control.worker.blurCursor(n.viewId)};return d.addEventListener("pointerdown",f,!1),()=>{d.removeEventListener("pointerdown",f,!1)}},[n]);const l=Q.useMemo(()=>{var d;return e!=null&&e.canRotate&&((d=e==null?void 0:e.selectIds)==null?void 0:d.length)===1&&(r===Te.None||r===Te.RotateNode)?Q.createElement(oTe,{className:mt.RotateBtn}):null},[e,r]),u=Q.useMemo(()=>((e==null?void 0:e.scaleType)===Ye.all||(e==null?void 0:e.scaleType)===Ye.proportional)&&(r===Te.None||r===Te.ScaleNode)&&ye.isNumber(e==null?void 0:e.x)&&ye.isNumber(e==null?void 0:e.y)?Q.createElement(fTe,{className:mt.ResizeBtn}):null,[e==null?void 0:e.scaleType,r,e==null?void 0:e.x,e==null?void 0:e.y]),h=Q.useMemo(()=>(e==null?void 0:e.scaleType)===Ye.both&&(r===Te.None||r===Te.SetPoint)?Q.createElement(gTe,{className:mt.ResizeTowBox}):null,[e==null?void 0:e.scaleType,r]);return Q.createElement("div",{ref:c,className:mt.FloatBar,onPointerOver:d=>(mo(d),n==null||n.control.worker.blurCursor(n.viewId),!1)},Q.createElement(pTe,{ref:t}),Q.createElement(hTe,{editors:i,canSelectorSwitch:a}),l,u,h,Q.createElement(mTe,{isHide:o,operationType:r,floatBarData:e}))}),vTe=Q.memo(yTe,(s,t)=>!!ye.isEqual(s,t)),MTe=s=>{var l,u;const{tool:t,visual:e,imageKey:r}=s,n=ma[t],[i,o]=Q.useState(e.images);Q.useEffect(()=>o(e.images),[t,r,e.images]);const a=Pd(i),c=a?`${i.standardResolution} 1x, ${a} 2x`:void 0;return Q.createElement("img",{className:"appliance-plugin-cursor-image","data-cursor-image-key":r,src:i.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:()=>{i.standardResolution!==n.images.standardResolution&&o(n.images)}})};class wTe extends Q.Component{constructor(){super(...arguments);x(this,"getCursorName",e=>{var r,n,i;return((r=e.payload)==null?void 0:r.nickName)||((n=e.payload)==null?void 0:n.cursorName)||((i=e.payload)==null?void 0:i.uid)});x(this,"detectAvatar",e=>{var r;return!!((r=e.payload)!=null&&r.avatar)});x(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]})`});x(this,"renderAvatar",(e,r)=>{var i;if(!this.detectAvatar(e))return null;const n=`rgb(${e.memberState.strokeColor[0]}, ${e.memberState.strokeColor[1]}, ${e.memberState.strokeColor[2]})`;return Q.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:(i=e.payload)==null?void 0:i.avatar,alt:"avatar"})});x(this,"renderTag",e=>{var r;return(r=e.payload)!=null&&r.cursorTagName?Q.createElement("span",{className:"appliance-plugin-cursor-tag",style:{backgroundColor:e.payload.cursorTagBackgroundColor||this.getCursorBackgroundColor(e)}},e.payload.cursorTagName):null})}render(){var g,y,S,b,I;const{roomMember:e,cursorTool:r,resolver:n,labelOptions:i}=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&&!!((g=e.payload)!=null&&g.cursorTagName),f=u||h||d;return Q.createElement("div",{className:"appliance-plugin-cursor-box","data-appliance":r},Q.createElement("div",{className:`appliance-plugin-cursor-visual${o.size?" appliance-plugin-cursor-visual-sized":""}`,style:{width:(y=o.size)==null?void 0:y.width,height:(S=o.size)==null?void 0:S.height,transform:`translate(${o.offset.x}px, calc(-100% + ${o.offset.y}px))`}},f&&Q.createElement("div",{className:`appliance-plugin-cursor-label appliance-plugin-cursor-label-${i.placement}`,style:{gap:i.gap,"--cursor-label-gap":`${i.gap}px`}},Q.createElement("div",{style:{opacity:f?1:0,backgroundColor:this.getCursorBackgroundColor(e),color:((b=e.payload)==null?void 0:b.cursorTextColor)||"#FFFFFF"},className:(I=e.payload)!=null&&I.theme?"appliance-plugin-cursor-inner-mellow":"appliance-plugin-cursor-inner"},h&&this.renderAvatar(e,u||d),u&&Q.createElement("span",{className:"appliance-plugin-cursor-name-text",style:{maxWidth:i.maxWidth}},c),d&&this.renderTag(e))),Q.createElement(MTe,{key:`${r}:${a}`,tool:r,visual:o,imageKey:a})))}}const STe=s=>{var l;const{className:t,info:e,resolver:r,labelOptions:n}=s,{roomMember:i,cursorTool:o,...a}=e||{},c=typeof a.x=="number"&&typeof a.y=="number";return Q.createElement("div",{"data-cursor-uid":(l=i==null?void 0:i.payload)==null?void 0:l.uid,className:t,style:c?{transform:`translate(${a.x}px, ${a.y}px)`}:{display:"none"}},i&&Q.createElement(wTe,{roomMember:i,cursorTool:o,resolver:r,labelOptions:n}))},TTe=s=>{const{className:t,manager:e}=s,[r,n]=Q.useState(),i=Q.useMemo(()=>new rM(e.control.pluginOptions.extras.cursor),[e]),o=e.control.pluginOptions.extras.cursor.syncedLabel;Q.useEffect(()=>(e.internalMsgEmitter.on([We.Cursor,e.viewId],a),()=>{e.internalMsgEmitter.off([We.Cursor,e.viewId],a)}),[e]);function a(c){n(c)}return Q.useMemo(()=>r!=null&&r.length?Q.createElement(Q.Fragment,null,r.map(c=>c.roomMember?Q.createElement(STe,{key:c.roomMember.memberId,className:t,info:c,resolver:i,labelOptions:o}):null)):null,[t,r,o,i])},ITe=s=>{const{viewId:t,miniMapCanvas:e,highlightColor:r,miniMapManager:n,contianer:i}=s,[o,a]=Q.useState();Q.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:f,height:g}=i.getBoundingClientRect(),y=Math.min(f/h.width,g/h.height),S=d.width/d.scale,b=d.height/d.scale,I=[d.centerX,d.centerY],N=[h.centerX,h.centerY],T=[I[0]-N[0],I[1]-N[1]],p=Math.min(h.scale*y,h.scale*y),m=[T[0]*p,T[1]*p,S,b,p];a(m)},u=h=>{var d;if(n.control.renderControl.isWritable){const f=h.nativeEvent.target||h.nativeEvent.srcElement;if(f&&h.nativeEvent&&o){const{width:g,height:y}=f.getBoundingClientRect(),[S,b]=[g/2,y/2],[I,N]=[(h.nativeEvent.offsetX-S)/o[4],(h.nativeEvent.offsetY-b)/o[4]],T=n.maps.get(t);if(T!=null&&T.viewCamera){const[p,m]=[T.miniMapCamera.centerX+I,T.miniMapCamera.centerY+N];(d=n.control.room)==null||d.moveCamera({centerX:p,centerY:m,animationMode:"immediately"})}}}};return Q.createElement("div",{style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",pointerEvents:"auto"},onClick:u},Q.createElement("canvas",{style:{pointerEvents:"none"},ref:e}),o&&Q.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"}}))},CTe=s=>{const{miniMapManager:t,active:e,className:r}=s,n=Q.useMemo(()=>{const i=t.maps;if(e){const o=i.get(e);if(o){const{miniMapCamera:a,viewCamera:c,...l}=o;if(l.contianer&&a&&c){const u=t.highlightColor;return Ga.createPortal(Q.createElement(ITe,{viewId:e,...l,highlightColor:u,miniMapManager:t}),l.contianer)}}}return null},[e,t]);return Q.createElement("div",{className:r},n)},bTe=s=>{const{hasOffscreenCanvas:t,isUseSimple:e,generation:r,refs:n}=s;return t?Q.createElement("div",{key:`worker-${r}`,className:mt.CanvasBox},Q.createElement("canvas",{id:"bgCanvas",ref:n.canvasBgRef,style:{width:"100%",height:"100%"}}),Q.createElement("canvas",{id:"serviceCanvas",className:mt.FloatCanvas,ref:n.canvasServiceFloatRef,style:{width:"100%",height:"100%"}}),Q.createElement("canvas",{id:"localCanvas",className:mt.FloatCanvas,ref:n.canvasFloatRef,style:{width:"100%",height:"100%"}}),!e&&Q.createElement("div",{id:"subLocalCanvas",className:mt.CanvasBoxSub,ref:n.subLocalCanvasContainerRef}),!e&&Q.createElement("canvas",{id:"topCanvas",className:mt.TopFloatCanvas,ref:n.canvasTopRef,style:{width:"100%",height:"100%"}})):Q.createElement("div",{key:`main-thread-${r}`,className:mt.CanvasBox,ref:n.canvasContainerRef})},ETe=2e3,lt=Q.createContext({viewId:"",mananger:void 0,floatBarColors:[],overwriteSelectorStyles:{},floatBarData:void 0,dpr:1,angle:0,operationType:Te.None,scale:[1,1],isNoPointerEvents:!1,activeTextEditor:!1,activeTextId:void 0,setAngle:()=>{},setOperationType:()=>{},setFloatBarData:()=>{}});class Dd extends Q.Component{constructor(e){var n,i;super(e);x(this,"showTextFloatBar");x(this,"canSelectorSwitch");x(this,"rightBoundBreak");x(this,"isUnmounted",!1);x(this,"renderSurfaceResetWaiters",new Set);x(this,"setAngle",e=>{this.setState({angle:e})});x(this,"setOperationType",e=>{this.setState({operationType:e})});this.state={floatBarData:void 0,showFloatBar:!1,showFloatBarBtn:!0,dpr:1,angle:0,operationType:Te.None,scale:[1,1],editors:this.editors,activeTextId:(n=this.props.mananger.control.textEditorManager)==null?void 0:n.activeId,activeMiniMapViewId:(i=this.props.mananger.control.miniMapManager)==null?void 0:i.activeViewId,renderSurfaceGeneration:0};const r=this.props.mananger.control.pluginOptions.extras.textEditor;this.showTextFloatBar=ye.isBoolean(r.showFloatBar)?r.showFloatBar:He.textEditor.showFloatBar,this.canSelectorSwitch=ye.isBoolean(r==null?void 0:r.canSelectorSwitch)?r.canSelectorSwitch:He.textEditor.canSelectorSwitch,this.rightBoundBreak=ye.isBoolean(r==null?void 0:r.rightBoundBreak)?r.rightBoundBreak:He.textEditor.rightBoundBreak}get editors(){return ht(this.props.mananger.control.textEditorManager.filterEditor(this.props.mananger.viewId))}componentDidMount(){this.isUnmounted=!1,this.props.mananger.vDom=this,this.props.mananger.mountView(),this.setState({dpr:this.props.mananger.dpr})}componentWillUnmount(){this.isUnmounted=!0;for(const e of this.renderSurfaceResetWaiters)clearTimeout(e.timer),e.resolve();this.renderSurfaceResetWaiters.clear(),this.props.mananger.vDom===this&&(this.props.mananger.vDom=void 0)}setDpr(e){this.state.dpr!==e&&this.setState({dpr:e})}resetRenderSurface(e=ETe){return this.isUnmounted?Promise.resolve():new Promise((r,n)=>{let i=!1;const o=c=>{i||(i=!0,clearTimeout(a.timer),this.renderSurfaceResetWaiters.delete(a),c?n(c):r())},a={timer:setTimeout(()=>o(new Error(`render surface reset timeout: ${this.props.viewId}; timeoutMs=${e}`)),e),resolve:()=>o(),reject:c=>o(c)};this.renderSurfaceResetWaiters.add(a),this.setState(c=>({renderSurfaceGeneration:c.renderSurfaceGeneration+1}),a.resolve)})}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,i,o,a,c;const e=!!((n=(r=this.props.mananger.control)==null?void 0:r.room)!=null&&n.floatBarOptions);return Q.createElement("div",{className:mt.Container},Q.createElement(bTe,{hasOffscreenCanvas:this.props.mananger.control.hasOffscreenCanvas,isUseSimple:this.props.mananger.control.isUseSimple,generation:this.state.renderSurfaceGeneration,refs:this.props.refs}),!this.props.mananger.control.hasOffscreenCanvas&&this.props.refs.snapshotContainerRef&&Q.createElement("div",{className:mt.SnapshotBox,ref:this.props.refs.snapshotContainerRef})||null,this.props.mananger.control.isUseBackgroundThread&&!!this.props.refs.backgroundContainerRef&&Q.createElement("div",{className:mt.BackgroundBox},Q.createElement("div",{className:mt.BackgroundSvgBox,ref:this.props.refs.backgroundContainerRef}),!!this.props.refs.backgroundSnapshotContainerRef&&Q.createElement("div",{className:mt.BackgroundSnapshotBox},Q.createElement("div",{className:mt.BackgroundSnapshotContent,ref:this.props.refs.backgroundSnapshotContainerRef})))||null,Q.createElement(lt.Provider,{value:{viewId:this.props.viewId,mananger:this.props.mananger,floatBarColors:e&&((a=(o=(i=this.props.mananger.control)==null?void 0:i.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&&Q.createElement(vTe,{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)&&Q.createElement(tTe,{className:mt.TextEditorContainer,showFloatBtns:this.showTextFloatBar&&e&&this.state.showFloatBarBtn||!1,editors:this.state.editors,rightBoundBreak:this.rightBoundBreak})||null),Q.createElement("div",{className:"appliance-plugin-custom-floatbar-container","data-view-id":this.props.viewId,ref:this.props.refs.customFloatbarContainerRef}),Q.createElement(TTe,{className:mt.CursorBox,manager:this.props.mananger}),!this.props.mananger.control.isUseSimple&&Q.createElement(CTe,{className:mt.MiniMapBox,active:this.state.activeMiniMapViewId,miniMapManager:this.props.mananger.control.miniMapManager}))}}class xTe extends aM{constructor(e,r){super(e,r);x(this,"width",1e3);x(this,"height",1e3);x(this,"dpr",Hi());x(this,"vDom");x(this,"eventTragetElement");x(this,"snapshotContainerRef");x(this,"backgroundSnapshotContainerRef");x(this,"canvasContainerRef",Q.createRef());x(this,"subLocalCanvasContainerRef");x(this,"canvasTopRef");x(this,"canvasServiceFloatRef",Q.createRef());x(this,"canvasFloatRef",Q.createRef());x(this,"canvasBgRef",Q.createRef());x(this,"backgroundContainerRef");x(this,"floatBarRef",Q.createRef());x(this,"customFloatbarContainerRef",Q.createRef());x(this,"containerOffset",{x:0,y:0});this.control.hasOffscreenCanvas||(this.snapshotContainerRef=Q.createRef()),this.control.isUseSimple||(this.canvasTopRef=Q.createRef(),this.subLocalCanvasContainerRef=Q.createRef()),this.control.isUseBackgroundThread&&(this.backgroundContainerRef=Q.createRef(),this.backgroundSnapshotContainerRef=Q.createRef())}setCanvassStyle(){var e;if(this.eventTragetElement){const r=this.eventTragetElement.offsetWidth||this.width,n=this.eventTragetElement.offsetHeight||this.height,i=Hi();i!==this.dpr&&this.requestDprUpdate(i),r&&n&&this.canvasContainerRef.current&&(r!==this.width||n!==this.height)&&(this.width=r,this.height=n,this.canvasContainerRef.current.style.width=`${r}px`,this.canvasContainerRef.current.style.height=`${n}px`),r&&n&&this.snapshotContainerRef&&this.snapshotContainerRef.current&&(r!==this.width||n!==this.height)&&(this.width=r,this.height=n),r&&n&&this.canvasBgRef.current&&(r!==this.width||n!==this.height)&&(this.width=r,this.height=n,this.resizeCanvasBackingStore()),r&&n&&this.backgroundContainerRef&&((e=this.backgroundContainerRef)!=null&&e.current)&&(r!==this.width||n!==this.height)&&(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))}}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(),Ga.render(Q.createElement(Dd,{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 RTe extends sSe{constructor(e,r,n){super(e,r,n);x(this,"dpr",Hi());x(this,"width",1e3);x(this,"height",1e3);x(this,"vDom");x(this,"eventTragetElement");x(this,"canvasContainerRef",Q.createRef());x(this,"subLocalCanvasContainerRef");x(this,"canvasTopRef");x(this,"canvasServiceFloatRef",Q.createRef());x(this,"canvasFloatRef",Q.createRef());x(this,"canvasBgRef",Q.createRef());x(this,"backgroundContainerRef");x(this,"floatBarRef",Q.createRef());x(this,"customFloatbarContainerRef",Q.createRef());x(this,"containerOffset",{x:0,y:0});this.control.isUseSimple||(this.canvasTopRef=Q.createRef(),this.subLocalCanvasContainerRef=Q.createRef()),this.control.isUseBackgroundThread&&(this.backgroundContainerRef=Q.createRef())}setCanvassStyle(){var e;if(this.eventTragetElement){const r=Hi();if(r!==this.dpr&&this.requestDprUpdate(r),this.canvasContainerRef.current){const n=this.eventTragetElement.offsetWidth||this.width,i=this.eventTragetElement.offsetHeight||this.height;n&&i&&(n!==this.width||i!==this.height)&&(this.width=n,this.height=i,this.canvasContainerRef.current.style.width=`${n}px`,this.canvasContainerRef.current.style.height=`${i}px`)}if(this.canvasBgRef.current){const n=this.eventTragetElement.offsetWidth||this.width,i=this.eventTragetElement.offsetHeight||this.height;n&&i&&(n!==this.width||i!==this.height)&&(this.width=n,this.height=i,this.resizeCanvasBackingStore())}if(this.backgroundContainerRef&&((e=this.backgroundContainerRef)!=null&&e.current)){const n=this.eventTragetElement.offsetWidth||this.width,i=this.eventTragetElement.offsetHeight||this.height;n&&i&&(n!==this.width||i!==this.height)&&(this.backgroundContainerRef.current.style.width=`${n}px`,this.backgroundContainerRef.current.style.height=`${i}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(),Ga.render(Q.createElement(Dd,{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 Kn extends Yi{constructor(e){super(e);x(this,"focuedViewId");x(this,"focuedView");x(this,"control");x(this,"tmpFocusedViewId");x(this,"checkScaleTimer");x(this,"windowManager");x(this,"mainViewLifecycleRevision",0);x(this,"appViewLifecycleRevisionById",new Map);x(this,"appScenePathRetryTimerById",new Map);x(this,"focusedChangeListener",e=>{var i;const r=((i=this.windowManager)==null?void 0:i.focused)||e||Fe;this.getView(r)?(this.tmpFocusedViewId=void 0,this.focuedViewId!==r&&this.setFocuedViewId(r)):r!==Fe?this.tmpFocusedViewId=r:this.tmpFocusedViewId=void 0});x(this,"mainViewScenePathChangeListener",e=>{this.control.onSceneChange(e,Fe)});x(this,"boxCloseListener",e=>{this.bumpAppViewLifecycleRevision(e.appId),this.appViews.get(e.appId)&&(this.destroyAppView(e.appId),this.control.worker.destroyViewWorker(e.appId,"delete-storage"))});x(this,"appScenePathChangeListener",e=>{const{appId:r,view:n}=e;!r||!n||this.consumeAppScenePathWhenReady(r,n)});x(this,"appsChangeListener",e=>{for(const r of this.appViews.keys())e.includes(r)||(this.bumpAppViewLifecycleRevision(r),this.destroyAppView(r),this.control.worker.destroyViewWorker(r,"storage-already-deleted"))});x(this,"mainViewHotkeyListener",e=>{this.onActiveHotkeyChange(e)});x(this,"appViewListeners",new Map);x(this,"onMainViewRelease",async e=>{const r=++this.mainViewLifecycleRevision;if(await this.mainViewDestroy(e),r!==this.mainViewLifecycleRevision||(await new Promise(i=>{setTimeout(()=>{i(!0)},0)}),r!==this.mainViewLifecycleRevision))return;this.mountMainView(e,r);const n=this.control.getSnapshootData("memberState");this.control.room&&this.control.onMemberChange(n),this.control.clearSnapshootData()});x(this,"mainViewDestroy",async e=>{var n,i;const r=this.mainView;if(r!=null&&r.displayer){if(this.control.invalidatePendingViewInit(r.id),await this.control.forceDoneLocalWorks("view-destroy",[r.id]),this.mainView!==r)return;this.control.backgroundImageLoadCoordinator.cancelByViewScene(r.id),this.control.destroySceneChange(r.id),(n=this.control.selectorApi)==null||n.disposeView(r.id),this.control.textEditorManager.clear(Fe,!0),this.removeMainViewListeners(r.viewData),this.disposeViewRenderImageBitmaps(r.id),r.displayer.destroy();const o=e.divElement;if(o){const a=o.getElementsByClassName("appliance-plugin-main-view-displayer");for(const c of a)c.remove()}if(r.container&&o!==r.container){const a=r.container.getElementsByClassName("appliance-plugin-main-view-displayer");for(const c of a)c.remove()}(i=this.control.worker)==null||i.destroyViewWorker(r.id,"preserve-storage"),this.mainView===r&&(this.mainView=void 0)}});x(this,"onMainViewMounted",async e=>{const r=++this.mainViewLifecycleRevision;await this.mainViewDestroy(e),r===this.mainViewLifecycleRevision&&this.mountMainView(e,r)});x(this,"onMainViewSizeUpdated",async()=>{await new Promise(e=>{setTimeout(()=>{e(!0)},0)}),this.mainView&&this.mainView.viewData?this.updateMainViewCamera("size-updated"):this.logMainViewCameraTrace("listener-dropped",{source:"size-updated",reason:"main-view-missing"})});x(this,"onMainViewCameraUpdated",async()=>{await new Promise(e=>{setTimeout(()=>{e(!0)},0)}),this.mainView&&this.mainView.viewData?this.updateMainViewCamera("camera-updated"):this.logMainViewCameraTrace("listener-dropped",{source:"camera-updated",reason:"main-view-missing"})});x(this,"updateMainViewCamera",e=>{if(this.mainView&&this.mainView.viewData){const r=this.mainView.viewData.camera;if(!ye.isNumber(r.scale)||r.scale===1/0){this.logMainViewCameraTrace("listener-dropped",{source:e,reason:"invalid-camera-scale",sourceCamera:r,sourceSize:this.mainView.viewData.size});return}const n=this.mainView.cameraOpt;if(n){const i=n.width,o=n.height,{width:a,height:c}=this.mainView.viewData.size;(a!==i||c!==o)&&this.mainView.displayer.updateSize();const l=r.scale===1/0?1:r.scale,u=r.centerX||0,h=r.centerY||0,d={...n,scale:l,centerX:u,centerY:h,width:a,height:c};!ye.isEqual(n,d)&&(this.mainView.cameraOpt=d),this.checkScaleTimer&&r.scale==1/0&&(clearTimeout(this.checkScaleTimer),this.checkScaleTimer=void 0),!this.checkScaleTimer&&r.scale===1/0&&this.mainView.viewData&&this.mainView.viewData.camera.scale===1/0&&(this.checkScaleTimer=setTimeout(()=>{var g,y;(y=(g=this.mainView)==null?void 0:g.viewData)==null||y.moveCamera({scale:l,centerX:u,centerY:h,animationMode:"immediately"}),this.checkScaleTimer=void 0},500))}}});x(this,"onAppViewMounted",async e=>{var f;const{appId:r,view:n}=e,i=this.bumpAppViewLifecycleRevision(r);this.cancelAppScenePathRetry(r);const o=n.divElement;if(!o||!n.focusScenePath)return;const a=this.appViews.get(r);if(a&&a.displayer){if(this.control.invalidatePendingViewInit(r),await this.control.forceDoneLocalWorks("view-destroy",[r]),!this.isCurrentAppViewLifecycleRevision(r,i)||this.appViews.get(r)!==a)return;let g=o.getElementsByClassName("appliance-plugin-app-view-displayer");for(const y of g)y.remove();if(a.container&&a.container!==o){g=a.container.getElementsByClassName("appliance-plugin-app-view-displayer");for(const y of g)y.remove()}if(this.destroyAppView(e.appId,!0),(f=this.control.worker)==null||f.destroyViewWorker(r,"preserve-storage"),await new Promise(y=>{setTimeout(()=>{y(!0)},0)}),!this.isCurrentAppViewLifecycleRevision(r,i))return}if(!this.isCurrentAppViewLifecycleRevision(r,i))return;const c=new RTe(r,this.control,tt.InternalMsgEmitter),l=n.size.width||c.width,u=n.size.height||c.height;c.dpr;const h={cameraOpt:{...Kn.defaultCameraOpt,...n.camera,width:l,height:u}};this.createAppView({id:r,container:o,displayer:c,cameraOpt:h.cameraOpt,focusScenePath:n.focusScenePath,viewData:n}),c.createAppViewDisplayer(r,o);const d=this.getAppViewListeners(r);n.callbacks.on("onSizeUpdated",d.onSizeUpdated),n.callbacks.on("onCameraUpdated",d.onCameraUpdated),n.callbacks.on("onActiveHotkey",d.onActiveHotkey),this.tmpFocusedViewId===r?(this.setFocuedViewId(r),this.tmpFocusedViewId=void 0):this.getPreferredFocusedViewId()===r&&this.setFocuedViewId(r),setTimeout(()=>{this.isCurrentAppViewLifecycleRevision(r,i)&&this.onAppViewCameraUpdated(r)},0)});x(this,"onAppViewSizeUpdated",async e=>{await new Promise(n=>{setTimeout(()=>{n(!0)},0)});const r=this.appViews.get(e);r&&r.viewData&&this.updateAppCamera(e)});x(this,"onAppViewCameraUpdated",async e=>{await new Promise(r=>{setTimeout(()=>{r(!0)},0)}),this.updateAppCamera(e)});x(this,"updateAppCamera",e=>{const r=this.appViews.get(e);if(r&&r.viewData){const n=r.viewData.camera,i=r.cameraOpt;if(i){const{width:o,height:a}=r.viewData.size,c=i.width,l=i.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,f={...i,scale:u,centerX:h,centerY:d,width:o,height:a};ye.isEqual(f,i)||(r.cameraOpt=f)}}});this.control=e.control}bumpAppViewLifecycleRevision(e){const r=(this.appViewLifecycleRevisionById.get(e)||0)+1;return this.appViewLifecycleRevisionById.set(e,r),r}isCurrentAppViewLifecycleRevision(e,r){return this.appViewLifecycleRevisionById.get(e)===r}cancelAppScenePathRetry(e){const r=this.appScenePathRetryTimerById.get(e);r!==void 0&&clearTimeout(r),this.appScenePathRetryTimerById.delete(e)}consumeAppScenePathWhenReady(e,r){const n=this.appViewLifecycleRevisionById.get(e);if(n===void 0)return;this.cancelAppScenePathRetry(e);const i=()=>{var l,u,h,d,f;if(this.appScenePathRetryTimerById.delete(e),!this.isCurrentAppViewLifecycleRevision(e,n)||((l=this.getView(e))==null?void 0:l.viewData)!==r)return;const o=r.focusScenePath,a=(f=(d=(h=(u=this.windowManager)==null?void 0:u.queryOne)==null?void 0:h.call(u,e))==null?void 0:d.getFullScenePath)==null?void 0:f.call(d);if(o&&(!a||o===a)){this.control.onSceneChange(o,e);return}const c=setTimeout(i,0);this.appScenePathRetryTimerById.set(e,c)};i()}getPreferredFocusedViewId(){var r;const e=(r=this.windowManager)==null?void 0:r.focused;return e&&this.getView(e)?e:this.tmpFocusedViewId&&this.getView(this.tmpFocusedViewId)?this.tmpFocusedViewId:Fe}getAuthoritativeScenePath(e){var n,i,o,a,c,l,u,h;if(e!==Fe){const d=(a=(o=(i=(n=this.windowManager)==null?void 0:n.queryOne)==null?void 0:i.call(n,e))==null?void 0:o.getFullScenePath)==null?void 0:a.call(o);if(d)return d}else{const d=(l=(c=this.windowManager)==null?void 0:c.mainView)==null?void 0:l.focusScenePath;if(d)return d}return((h=(u=this.getView(e))==null?void 0:u.viewData)==null?void 0:h.focusScenePath)||super.getAuthoritativeScenePath(e)}logMainViewCameraTrace(e,r){const n=this.control.logger,i=`[Appliance]: [main-view-camera] stage=${e} ${JSON.stringify(r)}`;n.infoDebounced?n.infoDebounced(`main-view-camera:${e}`,i):n.info(i)}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){this.cancelAppScenePathRetry(e);const n=this.appViews.get(e);this.removeAppViewListeners(e,n==null?void 0:n.viewData),super.destroyAppView(e,r)}destroy(){var e;this.mainViewLifecycleRevision++;for(const r of this.appScenePathRetryTimerById.keys())this.cancelAppScenePathRetry(r);this.appViewLifecycleRevisionById.clear(),this.removeWindowManagerListeners(),this.checkScaleTimer&&(clearTimeout(this.checkScaleTimer),this.checkScaleTimer=void 0),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()}removeWindowManagerListeners(){var r;for(const n of this.appScenePathRetryTimerById.keys())this.cancelAppScenePathRetry(n);const e=(r=this.windowManager)==null?void 0:r.emitter;e&&(e.off("focusedChange",this.focusedChangeListener),e.off("mainViewScenePathChange",this.mainViewScenePathChangeListener),e.off("onMainViewMounted",this.onMainViewMounted),e.off("onAppViewMounted",this.onAppViewMounted),e.off("onMainViewRebind",this.onMainViewRelease),e.off("onBoxClose",this.boxCloseListener),e.off("onAppScenePathChange",this.appScenePathChangeListener),e.off("appsChange",this.appsChangeListener),this.windowManager=void 0)}getViewInitData(e){var n,i;const r=this.getView(e);if(r){const{width:o,height:a,dpr:c}=r.displayer,l={dpr:c,originalPoint:[o/2,a/2],offscreenCanvasOpt:{...Kn.defaultScreenCanvasOpt,contextType:((i=(n=this.control).getRenderContextTypeForView)==null?void 0:i.call(n,e))??this.control.renderingCompatibilityDecision.contextType,width:o,height:a},layerOpt:{...Kn.defaultLayerOpt,width:o,height:a},cameraOpt:{...Kn.defaultCameraOpt,width:o,height:a}};if(r.viewData){const{scale:u,...h}=r.viewData.camera;l.cameraOpt={...l.cameraOpt,...h,scale:u===1/0?1:u}}return l}}async mountView(e){const r=this.getView(e);if(!r)return;const n=this.control.getViewLifecycleGeneration(e),i=()=>this.getView(e)===r&&this.control.isPendingViewInitCurrent(e,n);if(i())return this.control.emitInitLoadingChange({loading:!0,phase:"scene",status:"start"}),this.control.armPendingViewInit(e),this.control.queuePendingViewInit(e,async()=>{var a,c,l,u,h,d;if(!i()||(this.control.worker.isActive||(this.control.cursor.activeCollector(),await this.control.ensureRenderRuntimeReady()),!i())||(await r.displayer.resetRenderSurface(),!i()))return;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 o=this.getViewInitData(e);if(o&&((a=this.control.worker)==null||a.createViewWorker(e,o,r.displayer)),r.focusScenePath&&this.control.collector){let f=!1;if(this.control.collector.authStorage){const{renderAuth:g,pageAuth:y}=this.control.collector.authStorage;if(g){const S=g[e];if(S){const{render:b,hide:I,clear:N}=S;this.control.renderControl.syncRenderUids(e,b,I,N),f=!0}}if(!f&&y){const S=y[e];S&&(this.control.renderControl.syncPageAuth(e,S,!0),f=!0)}}(u=(l=(c=this.control.pluginOptions)==null?void 0:c.extras)==null?void 0:l.undoRedo)!=null&&u.enableGlobal&&r.displayer.commiter&&((h=this.control.collector)!=null&&h.globalUndoRedoStackStorage[r.id])&&r.displayer.commiter.pullServiceData(this.control.collector.globalUndoRedoStackStorage[r.id])}if((d=this.control.worker)!=null&&d.isActive){const f=await this.control.worker.waitForViewInitCompletion(e);if(!i())return;if(f==="timeout")throw this.control.emitInitLoadingChange({loading:!1,phase:"ready",status:"timeout"}),new Error(`view init completion timeout: ${e}`)}},n)}listenerWindowManager(e){this.removeWindowManagerListeners(),this.windowManager=e,e.emitter.on("focusedChange",this.focusedChangeListener),e.emitter.on("mainViewScenePathChange",this.mainViewScenePathChangeListener),e.emitter.on("onMainViewMounted",this.onMainViewMounted),e.emitter.on("onAppViewMounted",this.onAppViewMounted),e.emitter.on("onMainViewRebind",this.onMainViewRelease),e.emitter.on("onBoxClose",this.boxCloseListener),e.emitter.on("onAppScenePathChange",this.appScenePathChangeListener),e.emitter.on("appsChange",this.appsChangeListener)}mountMainView(e,r){if(r!==this.mainViewLifecycleRevision)return;const n=e.divElement;if(!n||!e.focusScenePath||!(e.focusScenePath||e.scenePath))return;const o=new xTe(this.control,tt.InternalMsgEmitter),a=e.size.width||o.width,c=e.size.height||o.height;o.dpr;const l={cameraOpt:{...Kn.defaultCameraOpt,width:a,height:c}},{scale:u,...h}=e.camera;l.cameraOpt={...l.cameraOpt,...h,scale:u===1/0?1:u},this.createMianView({id:Fe,container:n,displayer:o,focusScenePath:e.focusScenePath,cameraOpt:l.cameraOpt,viewData:e});const d=this.getPreferredFocusedViewId();(!d||!this.getView(d))&&this.setFocuedViewId(Fe),o.createMainViewDisplayer(n),this.control.notifyMainViewMounted(),e.callbacks.on("onSizeUpdated",this.onMainViewSizeUpdated),e.callbacks.on("onCameraUpdated",this.onMainViewCameraUpdated),e.callbacks.on("onActiveHotkey",this.mainViewHotkeyListener)}onActiveHotkeyChange(e){this.control.hotkeyManager.onActiveHotkey(e)}}class Rr extends tt{constructor(e){super(e);x(this,"windowManager");x(this,"viewContainerManager");const r={control:this,internalMsgEmitter:tt.InternalMsgEmitter,publicMsgEmitter:tt.PublicMsgEmitter};this.viewContainerManager=new Kn(r)}requiresCanvas2DCompanionRenderProbe(){return!0}init(){}activePlugin(){this.collector&&(this.collector.addAuthStateListener((e,r)=>{e&&Object.keys(e).forEach(n=>{var o;const i=(o=e[n])==null?void 0:o.newValue;this.renderControl.syncRenderUids(n,i==null?void 0:i.render,i==null?void 0:i.hide,i==null?void 0:i.clear)}),r&&Object.keys(r).forEach(n=>{var o;const i=(o=r[n])==null?void 0:o.newValue;this.renderControl.syncPageAuth(n,i)})}),this.collector.addStorageStateListener(e=>{var a;if((a=this.collector)!=null&&a.storage&&Object.keys(this.collector.storage).length===0){const l=Object.keys(e.diffView||{});for(const u of l.length?l:[Fe])this.handleRemoteStorageRemoval(u,void 0,{clearView:!0});return}const{diffView:r,diffScenePath:n,diffData:i}=e,o=new Map;if(r){let c;Object.keys(r).forEach(l=>{const u=r[l];if(u&&!u.newValue)this.handleRemoteStorageRemoval(l,void 0,{clearView:!0}),u.oldValue&&(c=u.oldValue);else if(u&&u.newValue){for(const h of Object.keys(u.newValue))this.worker.pullServiceData(l,h,{isAsync:!1,useAnimation:!1});c=u.newValue}if(c)for(const h of Object.values(c)){const d=new Set;for(const f of Object.keys(h))f&&d.add(f);o.set(l,d)}})}if(n){let c;Object.keys(n).forEach(l=>{const u=n[l],h=(u==null?void 0:u.scenePath)??l;if(u&&u.viewId&&!u.newValue?(this.handleRemoteStorageRemoval(u.viewId,void 0,{clearView:!0}),u.oldValue&&(c=u.oldValue)):u&&u.viewId&&u.newValue&&(this.worker.pullServiceData(u.viewId,h,{isAsync:!1,useAnimation:!1}),c=u.newValue),u!=null&&u.viewId&&c){const d=new Set;for(const f of Object.keys(c))f&&d.add(f),o.set(u.viewId,d)}})}i&&Object.keys(i).forEach(c=>{var u,h,d,f;const l=i[c];if(l){const g=l.storageKey??c,{viewId:y}=l,S=!l.newValue&&((u=this.collector)==null?void 0:u.isOwn(g));if(!l.newValue){const I=!!S&&!!((h=this.collector)!=null&&h.isSelector(g));this.handleRemoteStorageRemoval(y,g,{abortAllContinuousMethods:I,cancelTicker:I})}const b=o.get(y)||new Set;b.add(g),o.set(y,b),(d=this.worker)==null||d.onServiceDerive(g,l),(f=this.miniMapManager)==null||f.updateMiniMapCamera(y)}});for(const[c,l]of o.entries())tt.InternalMsgEmitter.emit("excludeIds",[...l],c)}),this.pluginOptions.extras.undoRedo.enableGlobal&&this.collector.addGlobalUndoRedoStackListener(e=>{Object.keys(e).forEach(r=>{var o;const n=e[r],i=(o=this.viewContainerManager.getView(r))==null?void 0:o.displayer.commiter;i&&i.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(i=>{var o,a,c,l;if(i&&i.focusScenePath&&((o=this.collector)!=null&&o.serviceStorage[i.id])&&this.collector.serviceStorage[i.id][i.focusScenePath]){const u=Object.keys(this.collector.serviceStorage[i.id][i.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:i.id,scenePath:i.focusScenePath,isSync:!0})),this.worker.blurSelector(i.id,i.focusScenePath,h);else{const f=this.textEditorManager.editors.get(h);f&&f.opt&&(f.opt.workState===de.Doing||f.opt.workState===de.Start)&&(js(f.opt.text)?this.textEditorManager.unActive(h):this.textEditorManager.delete(h))}}}}),(n=this.cursor)==null||n.updateRoomMembers(e)}))}async activeWorker(){await this.restoreCachedRenderRuntimeDecision(),await this.worker.init()}setWindowManager(e){var r,n,i,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=(i=this.windowManager.appManager)==null?void 0:i.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 Xl=new WeakMap;function im(s){return/^https?:\/\//i.test(s.trim())}function kTe(s){var e,r;const t=[];for(const[n,i]of Object.entries(s.appearance||{})){if(!i)continue;const o=[["default",i.images],["local",(e=i.local)==null?void 0:e.images],["synced",(r=i.synced)==null?void 0:r.images]];for(const[a,c]of o){if(!c)continue;im(c.standardResolution)&&t.push({appliance:n,scope:a,density:"standard",key:c.key||"external",url:c.standardResolution});const l=Pd(c);l&&im(l)&&t.push({appliance:n,scope:a,density:"high",key:c.key||"external",url:l})}}return t}function uM(s){Xl.has(s)||(Xl.set(s,new Map),window.setTimeout(()=>{try{const t=cd(s),e=kTe(t);if(!e.length)return;const r=Xl.get(s);if(!r)return;const n=new Set;for(const i of e){if(n.has(i.url))continue;n.add(i.url);const o=new Image;let a;const c=()=>{a!==void 0&&window.clearTimeout(a),o.onload=null,o.onerror=null,r.delete(i.url)};o.onload=c,o.onerror=c,r.set(i.url,o),a=window.setTimeout(c,t.preloadTimeout),o.src=i.url}}catch{}},0))}function hM(s,t){var r;if(!t||!Array.isArray(t.sources)||!t.sources.includes("appliance")||typeof t.viewId!="string"||typeof t.scenePath!="string"||typeof t.imageUrl!="string")return!1;const e=(r=s==null?void 0:s[t.viewId])==null?void 0:r[t.scenePath];return e?Object.values(e).some(n=>{var i;return(n==null?void 0:n.toolsType)===q.BackgroundSVG&&((i=n.opt)==null?void 0:i.src)===t.imageUrl}):!1}function dM(s,t,e){return new Proxy(s,{get(r,n,i){const o=Reflect.get(r,n,i);if(n==="destroy")return o;if(e()===t)return typeof o!="function"?o:(...a)=>{if(e()===t)return Reflect.apply(o,i,a)}},set(r,n,i,o){return e()!==t?!0:Reflect.set(r,n,i,o)}})}const Se=class Se extends fm{constructor(){super(...arguments);x(this,"callbackDisplayer");x(this,"callbackStateName");x(this,"callbackOwnerManager");x(this,"ownedManager");x(this,"roomLifecycleDisposer");x(this,"roomLifecycleOwnerManager");x(this,"undoStepForwarderDisposer");x(this,"undoStepForwarderOwnerManager");x(this,"onPhaseChanged",e=>{var r;e===Pi.Reconnecting&&((r=this.ownedManager)==null||r.setSnapshootData())});x(this,"updateRoomWritable",()=>{var r;const e=this.callbackDisplayer||this.displayer;(r=this.ownedManager)==null||r.onWritableChange(e.isWritable)});x(this,"roomStateChangeListener",async e=>{var n,i;e!=null&&e.roomMembers&&((n=this.ownedManager)==null||n.onRoomMembersChange(e.roomMembers));const r=this.callbackDisplayer||this.displayer;ze(r)&&!r.isWritable||e.memberState&&((i=this.ownedManager)==null||i.onMemberChange(e.memberState))})}static async getInstance(e,r){var N,T,p;(m=>{var v,M;try{(M=(v=r.callbacks)==null?void 0:v.onInitLoadingChange)==null||M.call(v,m)}catch(k){Se.logger.error(`[ApplianceMultiPlugin] onInitLoadingChange error: ${(k==null?void 0:k.message)||k}`)}})({loading:!0,phase:"plugin",status:"start"});const i=e.displayer,o=new Xs(ze(i)&&i.logger||Se.logger),a=typeof navigator>"u"?"unknown":navigator.userAgent;o.info(`[Appliance]: [init-enter] version=${Dc} userAgent=${a}`);const c=i.callbacks.on,l=i.callbacks.off,u=i.callbacks.once,h=e.cleanCurrentScene,d=e.mainView.setMemberState;r!=null&&r.logger&&(Se.logger=new Xs(r.logger));let f=i.getInvisiblePlugin(Se.kind);f||(f=await Se.createApplianceMultiPlugin(i,Se.kind)),i&&f&&await Se.createCurrentManager(e,{cdn:r.options.cdn,extras:Jv(r.options.extras)},f,r.callbacks),(N=Se.currentManager)==null||N.emitInitLoadingChange({loading:!0,phase:"plugin",status:"success"});const g={displayer:i,windowManager:e,currentManager:Se.currentManager,maxScreenshotWidth:10*1024,maxScreenshotHeight:10*1024,getBoundingRectAsync:async function(m){var k;Se.logger.info("[ApplianceMultiPlugin] getBoundingRectAsync");const v=(e.mainView||i).getBoundingRect(m),M=await((k=Se.currentManager)==null?void 0:k.getBoundingRect(m));return!v.width||!v.height?M:vd(v,M)},screenshotToCanvasAsync:async function(m,v,M,k,E,D){var L;Se.logger.info("[ApplianceMultiPlugin] screenshotToCanvasAsync");let P=M,z=k,j=E.scale;P>this.maxScreenshotWidth&&(j=this.maxScreenshotWidth/P*j,P=this.maxScreenshotWidth),z>this.maxScreenshotHeight&&(j=Math.min(this.maxScreenshotHeight/z*j,j),z=this.maxScreenshotHeight),E.scale=j;const A=document.createElement("canvas"),R=A.getContext("2d");A.width=P*(D||1),A.height=z*(D||1),R&&((e.mainView||i).screenshotToCanvas(R,v,P,z,E,D),m.drawImage(A,Math.floor((M-P)/2),Math.floor((k-z)/2),P*(D||1),z*(D||1),0,0,P,z),A.remove()),Se.currentManager&&await((L=Se.currentManager)==null?void 0:L.screenshotToCanvas(m,v,P,z,E,Math.floor((M-P)/2),Math.floor((k-z)/2)))},scenePreviewAsync:async function(m,v,M,k,E){Se.logger.info("[ApplianceMultiPlugin] scenePreviewAsync"),(e.mainView||i).scenePreview(m,v,M,k,E);const D=document.createElement("img");D.className="appliance-plugin-fill-scene-snapshot-img",v.append(D),getComputedStyle(v).position||(v.style.position="relative"),Se.currentManager&&await Se.currentManager.scenePreview(m,D)},fillSceneSnapshotAsync:async function(m,v,M,k,E){Se.logger.info("[ApplianceMultiPlugin] fillSceneSnapshotAsync"),v.innerHTML="",(e.mainView||i).fillSceneSnapshot(m,v,M,k,E);const D=M||e.mainView.size.width,P=k||e.mainView.size.height;let z=await this.getBoundingRectAsync(m);z||(z={originX:0,originY:0,width:D,height:P});let j=Math.max(z==null?void 0:z.width,D),A=Math.max(z==null?void 0:z.height,P),R=1;const L=j>D&&Math.min(D/j,R)||R,W=A>P&&Math.min(P/A,R)||R;L<=W?(j=L<1&&D||j,A=Math.floor(A*L)+1,R=L):L>W&&(A=W<1&&P||A,j=Math.floor(j*W)+1,R=W);const Y={scale:R,centerX:z.originX+z.width/2,centerY:z.originY+z.height/2},H=document.createElement("canvas"),ie=H.getContext("2d");H.width=j,H.height=A,ie&&await this.screenshotToCanvasAsync(ie,m,j,A,Y,devicePixelRatio);const O=document.createElement("img");O.className="appliance-plugin-fill-scene-snapshot-img",O.src=H.toDataURL(),O.onload=()=>{H.remove()},O.onerror=()=>{H.remove(),O.remove()},v.append(O),getComputedStyle(v).position||(v.style.position="relative")},_callbacksOn:function(m,v){Se.currentManager===g.currentManager&&((m==="onCanUndoStepsUpdate"||m==="onCanRedoStepsUpdate")&&ze(i)&&i.isWritable?Rr.InternalMsgEmitter.on(m,v):c.call(i.callbacks,m,v))},_callbacksOnce:function(m,v){Se.currentManager===g.currentManager&&((m==="onCanUndoStepsUpdate"||m==="onCanRedoStepsUpdate")&&ze(i)&&i.isWritable?Rr.InternalMsgEmitter.on(m,v):u.call(i.callbacks,m,v))},_callbacksOff:function(m,v){Se.currentManager===g.currentManager&&((m==="onCanUndoStepsUpdate"||m==="onCanRedoStepsUpdate")&&ze(i)&&i.isWritable?Rr.InternalMsgEmitter.off(m,v):l.call(i.callbacks,m,v))},canRedoSteps(){if(Se.logger.info("[ApplianceMultiPlugin] canRedoSteps"),Se.currentManager&&ze(i)&&!i.disableSerialization){const m=Se.currentManager.viewContainerManager.focuedView,v=m==null?void 0:m.focusScenePath;if(m&&v)return m.displayer.commiter.redoStack.filter(M=>M.scenePath===v).length}return 0},canUndoSteps(){if(Se.logger.info("[ApplianceMultiPlugin] canUndoSteps"),Se.currentManager&&ze(i)&&!i.disableSerialization){const m=Se.currentManager.viewContainerManager.focuedView,v=m==null?void 0:m.focusScenePath;if(m&&v)return m.displayer.commiter.undoStack.filter(E=>E.scenePath===v).length}return 0},undo:function(){return Se.logger.info("[ApplianceMultiPlugin] undo"),Se.currentManager&&ze(i)&&!i.disableSerialization&&i.isWritable?Se.currentManager.viewContainerManager.undo():0},redo:function(){return Se.logger.info("[ApplianceMultiPlugin] redo"),Se.currentManager&&ze(i)&&!i.disableSerialization&&i.isWritable?Se.currentManager.viewContainerManager.redo():0},cleanCurrentScene:function(){Se.logger.info("[ApplianceMultiPlugin] cleanCurrentScene"),Se.currentManager&&ze(i)&&i.isWritable&&(Se.currentManager.logger.info("[Appliance]: cleanCurrentScene"),Se.currentManager.cleanCurrentScene().then(m=>{m&&h.call(e)}).catch(m=>{var v;(v=Se.currentManager)==null||v.logger.error(`[Appliance]: cleanCurrentScene failed: ${(m==null?void 0:m.message)||m}`)}))},insertImage:function(m){if(Se.logger.info("[ApplianceMultiPlugin] insertImage"),Se.currentManager&&ze(i)&&i.isWritable){const v=Se.currentManager.viewContainerManager.focuedViewId||Fe;Se.currentManager.worker.insertImage(v,m)}},lockImage:function(m,v){if(Se.logger.info("[ApplianceMultiPlugin] lockImage"),Se.currentManager&&ze(i)&&i.isWritable){const M=Se.currentManager.viewContainerManager.focuedViewId||Fe;Se.currentManager.worker.lockImage(M,m,v)}},completeImageUpload:function(m,v){if(Se.logger.info("[ApplianceMultiPlugin] completeImageUpload"),Se.currentManager&&ze(i)&&i.isWritable){const M=Se.currentManager.viewContainerManager.focuedViewId||Fe;Se.currentManager.worker.completeImageUpload(M,m,v)}},getImagesInformation:function(m){return Se.logger.info("[ApplianceMultiPlugin] completeImageUpload"),Se.currentManager&&ze(i)&&i.isWritable?Se.currentManager.worker.getImagesInformation(m):[]},insertText:function(m,v,M){if(Se.logger.info("[ApplianceMultiPlugin] insertText"),Se.currentManager&&ze(i)&&i.isWritable){const k=Se.currentManager.viewContainerManager.focuedViewId||Fe;return Se.currentManager.textEditorManager.insertText(k,m,v,M)}},updateText:function(m,v){Se.logger.info("[ApplianceMultiPlugin] updateText"),Se.currentManager&&ze(i)&&i.isWritable&&Se.currentManager.textEditorManager.updateText(m,v)},callbacks:()=>({...i.callbacks,on:g._callbacksOn.bind(g),once:g._callbacksOnce.bind(g),off:g._callbacksOff.bind(g)}),destroy(){return Se.logger.info("[Appliance]: [ApplianceMultiPlugin] destroy"),f?f.destroyOwnedPluginInstance(g.currentManager):Promise.resolve()},setMemberState(m){if(Se.currentManager){Se.currentManager.logger.info(`[Appliance]: setMemberState ${JSON.stringify(m)}`);const v=Object.keys(m);if(ze(i)&&i.isWritable){if(v.includes("currentApplianceName"))if(Se.currentManager.requestToolChange(m),m.currentApplianceName&&m.currentApplianceName===De.laserPen){if(Se.currentManager.isUseSimple)throw Se.currentManager.logger.error("[Appliance]: [ApplianceMultiPlugin] laserPen must be not support in simple mode"),new Error("[Appliance]: [ApplianceMultiPlugin] laserPen must be not support in simple mode");m.currentApplianceName=De.pencil,m.useLaserPen=!0}else m.currentApplianceName&&m.currentApplianceName===De.pencil&&(m.useLaserPen=!1);try{d.call(e.mainView,m)}catch(M){throw Se.currentManager.setToolChangePending(!1,"set-member-state-error"),M}return}}throw Se.logger.error("[Appliance]: [ApplianceMultiPlugin] setMemberState must be called in writable room"),new Error("[Appliance]: [ApplianceMultiPlugin] setMemberState must be called in writable room")},createMiniMap:async function(m,v){if(Se.logger.info("[ApplianceMultiPlugin] createMiniMap"),Se.currentManager&&ze(i)&&i.isWritable)return Se.currentManager.logger.info("[Appliance]: [ApplianceMultiPlugin] createMiniMap"),Se.currentManager.createMiniMap(m,v)},destroyMiniMap:async function(m){if(Se.logger.info("[ApplianceMultiPlugin] destroyeMiniMap"),Se.currentManager&&ze(i)&&i.isWritable)return Se.currentManager.logger.info("[Appliance]: [ApplianceMultiPlugin] destroyeMiniMap"),Se.currentManager.destroyMiniMap(m)},filterRenderByUid(m,v,M){if(Se.logger.info("[ApplianceMultiPlugin] filterRenderByUid"),Se.currentManager&&ze(i)&&i.isWritable)return Se.currentManager.filterRenderByUid(m,v,M)},cancelFilterRender(m,v){if(Se.logger.info("[ApplianceMultiPlugin] filterRenderByUid"),Se.currentManager&&ze(i)&&i.isWritable)return Se.currentManager.cancelFilterRender(m,v)},addListener:(m,v)=>{Rr.PublicMsgEmitter.on(m,v)},removeListener:(m,v)=>{Rr.PublicMsgEmitter.off(m,v)},usePlugin:m=>{var v;Se.logger.info("[ApplianceMultiPlugin] usePlugin",m.kind),(v=Se.currentManager)==null||v.usePlugin(m)},getDisableDeviceInputs(){if(Se.currentManager&&ze(i))return Se.currentManager.disableDeviceInputs},setDisableDeviceInputs(m){Se.logger.info(`[ApplianceMultiPlugin] setDisableDeviceInputs ${m}`),Se.currentManager&&ze(i)&&(Se.currentManager.disableDeviceInputs=m)},getDisableCameraTransform(){if(Se.currentManager&&ze(i))return Se.currentManager.disableCameraTransform},setDisableCameraTransform(m){Se.logger.info(`[ApplianceMultiPlugin] setDisableCameraTransform ${m}`),Se.currentManager&&ze(i)&&(Se.currentManager.disableCameraTransform=m)},getDisableEraseImage(){if(Se.currentManager&&ze(i))return Se.currentManager.disableEraseImage},setDisableEraseImage(m){Se.logger.info(`[ApplianceMultiPlugin] setDisableEraseImage ${m}`),Se.currentManager&&ze(i)&&(Se.currentManager.disableEraseImage=m)},setWritable:m=>g.setWritable(m),requestIdleCallback:(m,v)=>{const M=(v==null?void 0:v.timeout)||0,k=performance.now();let E;const D=new MessageChannel;let P;const z=j=>{try{m({didTimeout:j,timeRemaining:()=>{const R=performance.now()-k;return Math.max(0,M-R)}})}catch(A){Se.logger.error("[ApplianceMultiPlugin] requestIdleCallback error:",A)}finally{D.port1.close(),D.port2.close(),E!==void 0&&cancelAnimationFrame(E),P!==void 0&&clearTimeout(P)}};return D.port1.onmessage=()=>{E=requestAnimationFrame(()=>{M>0&&performance.now()-k>=M?z(!0):z(!1)})},D.port2.postMessage(null),M>0&&(P=setTimeout(()=>{z(!0)},M)),P||E||0},cancelIdleCallback:m=>{try{clearTimeout(m),cancelAnimationFrame(m)}catch(v){Se.logger.error("[ApplianceMultiPlugin] cancelIdleCallback error:",v)}},injectMethodToObject:(m,v)=>{if(typeof m[v]=="function"||typeof m[v]>"u"){(v==="requestIdleCallback"||v==="cancelIdleCallback")&&Se.currentManager&&Se.currentManager.registerPolyfillMethod(v);const M=g[v];m[v]=function(...k){if(Se.currentManager===g.currentManager)return Reflect.apply(M,this,k)};return}v==="callbacks"&&(m.callbacks.on=g._callbacksOn.bind(g),m.callbacks.off=g._callbacksOff.bind(g),m.callbacks.once=g._callbacksOnce.bind(g))},blurText:()=>{Se.logger.info("[ApplianceMultiPlugin] blurText"),Se.currentManager&&ze(i)&&i.isWritable&&Se.currentManager.textEditorManager.checkEmptyTextBlur()},hasElements:(m,v)=>{var M;if(Se.logger.info(`[ApplianceMultiPlugin] hasElements ${m}`),Se.currentManager&&ze(i)&&i.isWritable){let k=m;if(!k){const E=Se.currentManager.viewContainerManager.focuedView;k=E==null?void 0:E.focusScenePath}if(k){const E=(M=Se.currentManager.collector)==null?void 0:M.getScenePathData(k);if(E){const D=Object.values(E);return D.length>0?v?D.some(P=>v(P.toolsType)):!0:!1}return!1}return!1}},getElements:(m,v)=>{var M;if(Se.logger.info(`[ApplianceMultiPlugin] getElements ${m}`),Se.currentManager&&ze(i)&&i.isWritable){let k=m;if(!k){const E=Se.currentManager.viewContainerManager.focuedView;k=E==null?void 0:E.focusScenePath}if(k){const E=(M=Se.currentManager.collector)==null?void 0:M.getScenePathData(k),D=E&&Object.values(E)||[];return E&&D.length>0&&v?D.filter(P=>v(P.toolsType)):D}return[]}},hasBackgroundImage:m=>{var v,M;return hM((M=(v=Se.currentManager)==null?void 0:v.collector)==null?void 0:M.storage,m)},stopDraw:m=>{if(Se.logger.info(`[ApplianceMultiPlugin] stopDraw ${m}`),Se.currentManager&&ze(i))return Se.currentManager.stopDraw(m)},loadFontFaces:()=>{var m;return Se.logger.info("[ApplianceMultiPlugin] loadFontFaces"),((m=Se.currentManager)==null?void 0:m.loadFontFaces())||Promise.resolve({status:"error"})},refreshViewRender:m=>{var v;return Se.logger.info(`[ApplianceMultiPlugin] refreshViewRender ${m}`),((v=Se.currentManager)==null?void 0:v.refreshViewRender(m))||Promise.resolve({status:"error"})},refreshRender:()=>{var m;return Se.logger.info("[ApplianceMultiPlugin] refreshRender"),((m=Se.currentManager)==null?void 0:m.refreshRender())||Promise.resolve({status:"error"})},refreshViewTextRender:m=>{var v;return Se.logger.info(`[ApplianceMultiPlugin] refreshViewTextRender ${m}`),((v=Se.currentManager)==null?void 0:v.refreshViewTextRender(m))||Promise.resolve({status:"error"})},refreshTextRender:()=>{var m;return Se.logger.info("[ApplianceMultiPlugin] refreshTextRender"),((m=Se.currentManager)==null?void 0:m.refreshTextRender())||Promise.resolve({status:"error"})},setViewLocalScenePathChange:async(m,v)=>{Se.logger.info(`[ApplianceMultiPlugin] setViewLocalScenePathChange ${m} ${v}`),Se.currentManager&&await Se.currentManager.setViewLocalScenePathChange(v,m)},insertMarkmap:async(m,v)=>{if(Se.logger.info(`[ApplianceMultiPlugin] insertMarkmap: ${m}, info: ${JSON.stringify(v)}`),Se.currentManager&&Se.currentManager.isUseBackgroundThread)return Se.currentManager.worker.insertBackgroundMarkMap(m,v)},updateMarkmap:async(m,v,M)=>{if(Se.logger.info(`[ApplianceMultiPlugin] updateMarkmap: ${m}, markmapId: ${v}, info: ${JSON.stringify(M)}`),Se.currentManager&&Se.currentManager.isUseBackgroundThread)return Se.currentManager.worker.updateBackgroundMarkMap(m,v,M)},insertBackgroundImage:async(m,v)=>{if(Se.logger.info(`[ApplianceMultiPlugin] insertBackgroundImage: ${m}, info: ${JSON.stringify(v)}`),Se.currentManager&&Se.currentManager.isUseBackgroundThread)return Se.currentManager.worker.insertBackgroundSVG(m,v)},reloadBackgroundImage:async m=>{const v=Se.currentManager;return v?v.reloadBackgroundImage(m):{accepted:!1,reloadedCount:0,reason:"viewNotFound"}},getSelectedElements:m=>{var v,M;return(M=(v=Se.currentManager)==null?void 0:v.selectorApi)==null?void 0:M.getSelectedElements(m)},isElementPropertySupported:(m,v)=>{var M,k;return((k=(M=Se.currentManager)==null?void 0:M.selectorApi)==null?void 0:k.isElementPropertySupported(m,v))||!1},blurSelector:m=>{var v;if(Se.currentManager&&ze(i)&&i.isWritable){const M=(v=Se.currentManager)==null?void 0:v.selectorApi;return M?M.blurSelector(m):Promise.resolve({ok:!1,requestId:`clear-${Date.now().toString(36)}`,viewId:m||Fe,reason:"no-selection"})}return Promise.resolve({ok:!1,requestId:`clear-${Date.now().toString(36)}`,viewId:m||Fe,reason:"no-selection"})},updateSelectedElements:(m,v)=>{var M;if(Se.currentManager&&ze(i)&&i.isWritable){const k=(M=Se.currentManager)==null?void 0:M.selectorApi;return k?k.updateSelectedElements(m,v):Promise.resolve({requestId:`update-${Date.now().toString(36)}`,viewId:m,ok:!1,reason:"no-selection"})}return Promise.resolve({requestId:`update-${Date.now().toString(36)}`,viewId:m,ok:!1,reason:"no-writable permission"})},updateElement:(m,v,M,k,E=!0)=>{var D;if(Se.currentManager&&ze(i)&&i.isWritable){const P=(D=Se.currentManager)==null?void 0:D.selectorApi;return P?P.updateElement(m,v,M,k,E):Promise.resolve(!1)}return Promise.resolve(!1)},copySelectedElements:m=>{var v;if(Se.currentManager&&ze(i)&&i.isWritable){const M=(v=Se.currentManager)==null?void 0:v.selectorApi;return M?M.copySelectedElements(m):Promise.resolve({ok:!1,requestId:`copy-${Date.now().toString(36)}`,viewId:m||Fe,reason:"no-selection"})}return Promise.resolve({ok:!1,requestId:`copy-${Date.now().toString(36)}`,viewId:m||Fe,reason:"no-selection"})},deleteSelectedElements:m=>{var v;if(Se.currentManager&&ze(i)&&i.isWritable){const M=(v=Se.currentManager)==null?void 0:v.selectorApi;return M?M.deleteSelectedElements(m):Promise.resolve({ok:!1,requestId:`delete-${Date.now().toString(36)}`,viewId:m||Fe,reason:"no-selection"})}return Promise.resolve({ok:!1,requestId:`delete-${Date.now().toString(36)}`,viewId:m||Fe,reason:"no-selection"})},getFloatbarContainer:m=>{var v;return(v=Se.currentManager)==null?void 0:v.viewContainerManager.getFloatbarContainer(m)},getViewOffsetToContainer:(m,v)=>{var M;return(M=Se.currentManager)==null?void 0:M.viewContainerManager.getViewOffsetToContainer(m,v)}};g.injectMethodToObject(e,"undo"),g.injectMethodToObject(e,"redo"),g.injectMethodToObject(e,"cleanCurrentScene"),g.injectMethodToObject(e,"blurSelector"),g.injectMethodToObject(e,"updateElement"),g.injectMethodToObject(e,"insertImage"),g.injectMethodToObject(e,"completeImageUpload"),g.injectMethodToObject(e,"lockImage"),g.injectMethodToObject(e,"insertText"),g.injectMethodToObject(e,"updateText"),g.injectMethodToObject(i,"getImagesInformation"),g.injectMethodToObject(i,"callbacks"),g.injectMethodToObject(i,"screenshotToCanvasAsync"),g.injectMethodToObject(i,"getBoundingRectAsync"),g.injectMethodToObject(i,"scenePreviewAsync"),g.injectMethodToObject(i,"fillSceneSnapshotAsync"),g.injectMethodToObject(i,"blurSelector"),g.injectMethodToObject(i,"updateElement"),g.injectMethodToObject(e.mainView,"setMemberState"),ze(i)&&f&&(f.disposeRoomLifecycleInterceptor(),f.roomLifecycleDisposer=gm(i,()=>g.currentManager,Se.logger),f.roomLifecycleOwnerManager=g.currentManager),Object.defineProperty(e,"canUndoSteps",{get(){return g.canUndoSteps()}}),Object.defineProperty(e,"canRedoSteps",{get(){return g.canRedoSteps()}}),f==null||f.bindUndoStepForwarders(e);const y={...g,callbacks:g.callbacks()};Object.defineProperty(y,"disableDeviceInputs",{set(m){g.setDisableDeviceInputs(m)},get(){return g.getDisableDeviceInputs()}}),Object.defineProperty(y,"disableCameraTransform",{set(m){g.setDisableCameraTransform(m)},get(){return g.getDisableCameraTransform()}}),Object.defineProperty(y,"disableEraseImage",{set(m){g.setDisableEraseImage(m)},get(){return g.getDisableEraseImage()}});const S=dM(y,g.currentManager,()=>Se.currentManager);f&&Se.currentManager&&(Se.currentManager.bindPlugin(f),f.init(i));const b=Se.currentManager;e._appliancePlugin=S;const I=(T=Se.currentManager)==null?void 0:T.pluginOptions.extras.cursor;if(I&&((p=Se.currentManager)==null||p.worker.afterMainViewInitAck(()=>{uM(I)})),!b)throw e._appliancePlugin===S&&delete e._appliancePlugin,new Error("ApplianceMultiPlugin initialization was cancelled");if(b.startInitFontFaceLoadAndRender(),b.isMainViewMounted()){const m=await b.worker.waitForMainViewInitAck();if(m!=="ready"||Se.currentManager!==b)throw e._appliancePlugin===S&&delete e._appliancePlugin,new Error(`ApplianceMultiPlugin initialization ${m==="timeout"?"timed out":"was cancelled"}`)}else b.logger.info("[Appliance]: main view not mounted yet, deferring render-init ack wait"),b.waitForMainViewMounted().then(m=>{if(!(m!=="ready"||Se.currentManager!==b))return b.worker.waitForMainViewInitAck().then(v=>{b.logger.info(`[Appliance]: deferred render-init ${v}`)})}).catch(m=>{b.logger.error(`[Appliance]: deferred render-init failed: ${(m==null?void 0:m.message)||m}`)});return S}static onCreate(e){e&&Se.currentManager&&(Se.currentManager.bindPlugin(e),e.init(e.displayer))}static async createApplianceMultiPlugin(e,r){try{await e.createInvisiblePlugin(Se,{})}catch(i){if(!e.isWritable){await e.setWritable(!0);const a=await this.createApplianceMultiPlugin(e,r);return await e.setWritable(!1),a}throw(e.logger||Se.logger).error(`[Appliance]: create invisible plugin failed: ${(i==null?void 0:i.message)||i}`),i}let n=e.getInvisiblePlugin(r);return n||(n=await Se.createApplianceMultiPlugin(e,r)),n}static beginManagerDestroy(e){if(!e)return Promise.resolve();if(Se.drainingManager===e&&Se.drainingPromise)return Se.drainingPromise;Se.currentManager===e&&(Se.currentManager=void 0),Se.drainingManager=e;const r=e.destroy({preserveStorage:!0}).finally(()=>{Se.drainingManager===e&&(Se.drainingManager=void 0),Se.drainingPromise===r&&(Se.drainingPromise=void 0)});return Se.drainingPromise=r,r}init(e){this.unbindDisplayerCallbacks();const r=this.ownedManager,n=e.state;r==null||r.onRoomMembersChange(n.roomMembers),ze(e)&&(r==null||r.onMemberChange(n.memberState));const i=ih(e)?"onPlayerStateChanged":"onRoomStateChanged";this.callbackDisplayer=e,this.callbackStateName=i,this.callbackOwnerManager=r,e.callbacks.on(i,this.roomStateChangeListener),e.callbacks.on("onEnableWriteNowChanged",this.updateRoomWritable),e.callbacks.on("onPhaseChanged",this.onPhaseChanged)}unbindDisplayerCallbacks(e){if(e!==void 0&&this.callbackOwnerManager!==e)return;const r=this.callbackDisplayer,n=this.callbackStateName;r&&n&&(r.callbacks.off(n,this.roomStateChangeListener),r.callbacks.off("onEnableWriteNowChanged",this.updateRoomWritable),r.callbacks.off("onPhaseChanged",this.onPhaseChanged)),this.callbackDisplayer=void 0,this.callbackStateName=void 0,this.callbackOwnerManager=void 0}disposeRoomLifecycleInterceptor(e){var r;e!==void 0&&this.roomLifecycleOwnerManager!==e||((r=this.roomLifecycleDisposer)==null||r.call(this),this.roomLifecycleDisposer=void 0,this.roomLifecycleOwnerManager=void 0)}bindUndoStepForwarders(e){this.disposeUndoStepForwarders();let r=!0;const n=new Set,i=(l,u,h,d=3)=>{if(!r||this.ownedManager!==o)return;const f=e.focused||Fe;if(d>0&&f!==u){const g=setTimeout(()=>{n.delete(g),i(l,u,h,d-1)},100);n.add(g);return}e.emitter.emit(l,h)},o=this.ownedManager,a=(l,u)=>i("canUndoStepsChange",u,l),c=(l,u)=>i("canRedoStepsChange",u,l);Rr.InternalMsgEmitter.on("onCanUndoStepsUpdate",a),Rr.InternalMsgEmitter.on("onCanRedoStepsUpdate",c),this.undoStepForwarderDisposer=()=>{r=!1,n.forEach(l=>clearTimeout(l)),n.clear(),Rr.InternalMsgEmitter.off("onCanUndoStepsUpdate",a),Rr.InternalMsgEmitter.off("onCanRedoStepsUpdate",c)},this.undoStepForwarderOwnerManager=o}disposeUndoStepForwarders(e){var r;e!==void 0&&this.undoStepForwarderOwnerManager!==e||((r=this.undoStepForwarderDisposer)==null||r.call(this),this.undoStepForwarderDisposer=void 0,this.undoStepForwarderOwnerManager=void 0)}destroyOwnedPluginInstance(e){return this.unbindDisplayerCallbacks(e),this.disposeRoomLifecycleInterceptor(e),this.disposeUndoStepForwarders(e),this.destroyOwnedManager(e)}destroyOwnedManager(e=this.ownedManager){return e?(this.ownedManager===e&&(this.ownedManager=void 0),Se.beginManagerDestroy(e)):Promise.resolve()}destroy(){Se.logger.info("[ApplianceMultiPlugin] passive destroy"),this.unbindDisplayerCallbacks(),this.disposeRoomLifecycleInterceptor(),this.disposeUndoStepForwarders(),this.destroyOwnedManager()}};x(Se,"drainingManager"),x(Se,"drainingPromise"),x(Se,"kind","appliance-multi-plugin"),x(Se,"currentManager"),x(Se,"logger",{info:console.log,warn:console.warn,error:console.error}),x(Se,"createCurrentManager",async(e,r,n,i)=>{Se.drainingPromise&&await Se.drainingPromise;const o=Se.currentManager;if(o)try{await Se.beginManagerDestroy(o),o.logger.info("[Appliance]: replace old manager success")}catch(l){throw o.logger.error(`[Appliance]: replace old manager failed: ${(l==null?void 0:l.message)||l}`),l}const a={plugin:n,displayer:e.displayer,options:r,callbacks:i},c=new Rr(a);c.setWindowManager(e),Se.currentManager=c,n.ownedManager=c});let Ju=Se;var ATe=Er,PTe=function(){return ATe.Date.now()},DTe=PTe,LTe=/\s/;function NTe(s){for(var t=s.length;t--&<e.test(s.charAt(t)););return t}var OTe=NTe,zTe=OTe,BTe=/^\s+/;function jTe(s){return s&&s.slice(0,zTe(s)+1).replace(BTe,"")}var FTe=jTe,UTe=pi,WTe=zr,VTe="[object Symbol]";function $Te(s){return typeof s=="symbol"||WTe(s)&&UTe(s)==VTe}var YTe=$Te,GTe=FTe,sm=Dn,HTe=YTe,om=NaN,QTe=/^[-+]0x[0-9a-f]+$/i,qTe=/^0b[01]+$/i,ZTe=/^0o[0-7]+$/i,KTe=parseInt;function XTe(s){if(typeof s=="number")return s;if(HTe(s))return om;if(sm(s)){var t=typeof s.valueOf=="function"?s.valueOf():s;s=sm(t)?t+"":t}if(typeof s!="string")return s===0?s:+s;s=GTe(s);var e=qTe.test(s);return e||ZTe.test(s)?KTe(s.slice(2),e?2:8):QTe.test(s)?om:+s}var JTe=XTe,_Te=Dn,Jl=DTe,am=JTe,e1e="Expected a function",t1e=Math.max,r1e=Math.min;function n1e(s,t,e){var r,n,i,o,a,c,l=0,u=!1,h=!1,d=!0;if(typeof s!="function")throw new TypeError(e1e);t=am(t)||0,_Te(e)&&(u=!!e.leading,h="maxWait"in e,i=h?t1e(am(e.maxWait)||0,t):i,d="trailing"in e?!!e.trailing:d);function f(m){var v=r,M=n;return r=n=void 0,l=m,o=s.apply(M,v),o}function g(m){return l=m,a=setTimeout(b,t),u?f(m):o}function y(m){var v=m-c,M=m-l,k=t-v;return h?r1e(k,i-M):k}function S(m){var v=m-c,M=m-l;return c===void 0||v>=t||v<0||h&&M>=i}function b(){var m=Jl();if(S(m))return I(m);a=setTimeout(b,y(m))}function I(m){return a=void 0,d&&r?f(m):(r=n=void 0,o)}function N(){a!==void 0&&clearTimeout(a),l=0,r=c=n=a=void 0}function T(){return a===void 0?o:I(Jl())}function p(){var m=Jl(),v=S(m);if(r=arguments,n=this,c=m,v){if(a===void 0)return g(c);if(h)return clearTimeout(a),a=setTimeout(b,t),f(c)}return a===void 0&&(a=setTimeout(b,t)),o}return p.cancel=N,p.flush=T,p}var i1e=n1e,s1e=i1e,o1e=Dn,a1e="Expected a function";function c1e(s,t,e){var r=!0,n=!0;if(typeof s!="function")throw new TypeError(a1e);return o1e(e)&&(r="leading"in e?!!e.leading:r,n="trailing"in e?!!e.trailing:n),s1e(s,t,{leading:r,maxWait:t,trailing:n})}var l1e=c1e;const u1e=ln(l1e);class h1e extends aM{constructor(e,r){super(e,r);x(this,"width",1e3);x(this,"height",1e3);x(this,"dpr",Hi());x(this,"vDom");x(this,"eventTragetElement");x(this,"snapshotContainerRef");x(this,"backgroundContainerRef");x(this,"backgroundSnapshotContainerRef");x(this,"canvasContainerRef",Q.createRef());x(this,"subLocalCanvasContainerRef");x(this,"canvasTopRef");x(this,"canvasServiceFloatRef",Q.createRef());x(this,"canvasFloatRef",Q.createRef());x(this,"canvasBgRef",Q.createRef());x(this,"floatBarRef",Q.createRef());x(this,"customFloatbarContainerRef",Q.createRef());x(this,"containerOffset",{x:0,y:0});this.control.hasOffscreenCanvas||(this.snapshotContainerRef=Q.createRef()),this.control.isUseSimple||(this.canvasTopRef=Q.createRef(),this.subLocalCanvasContainerRef=Q.createRef()),this.control.isUseBackgroundThread&&(this.backgroundContainerRef=Q.createRef(),this.backgroundSnapshotContainerRef=Q.createRef())}setCanvassStyle(){if(this.eventTragetElement){const e=this.eventTragetElement.offsetWidth,r=this.eventTragetElement.offsetHeight,n=Hi();n!==this.dpr&&this.requestDprUpdate(n),e&&r&&this.canvasContainerRef.current&&(e!==this.width||r!==this.height)&&(this.width=e,this.height=r),e&&r&&this.backgroundContainerRef&&this.backgroundContainerRef.current&&(e!==this.width||r!==this.height)&&(this.width=e,this.height=r,this.backgroundContainerRef.current.style.width=`${e}px`,this.backgroundContainerRef.current.style.height=`${r}px`,this.backgroundContainerRef.current.classList.toggle("appliance-plugin-background-isWritable",this.control.renderControl.isWritable)),e&&r&&this.canvasBgRef.current&&(e!==this.width||r!==this.height)&&(this.width=e,this.height=r,this.resizeCanvasBackingStore())}}createMainViewDisplayer(e){return this.vDom||(this.containerOffset=this.getContainerOffset(e,this.containerOffset),this.eventTragetElement=e.parentElement.children[0],e.innerHTML="",Ga.render(Q.createElement(Dd,{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 Bi extends Yi{constructor(e){super(e);x(this,"focuedViewId");x(this,"control");x(this,"focuedView");this.control=e.control}bindMainView(){if(!this.control.divMainView)return;const e=new h1e(this.control,tt.InternalMsgEmitter),{width:r,height:n,dpr:i}=e,o={cameraOpt:{...Bi.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:Fe,displayer:e,focusScenePath:a.focusScenePath||a.scenePath,cameraOpt:o.cameraOpt,viewData:a}),this.setFocuedViewId(Fe),e.createMainViewDisplayer(this.control.divMainView),this.control.notifyMainViewMounted()}}getViewInitData(e){var n,i;const r=this.getView(e);if(r){const{width:o,height:a,dpr:c}=r.displayer,l={dpr:c,originalPoint:[o/2,a/2],offscreenCanvasOpt:{...Bi.defaultScreenCanvasOpt,contextType:((i=(n=this.control).getRenderContextTypeForView)==null?void 0:i.call(n,e))??this.control.renderingCompatibilityDecision.contextType,width:o,height:a},layerOpt:{...Bi.defaultLayerOpt,width:o,height:a},cameraOpt:{...Bi.defaultCameraOpt,width:o,height:a}};if(r.viewData){const{scale:u,...h}=r.viewData.camera;l.cameraOpt={...l.cameraOpt,...h,scale:u===1/0?1:u}}return l}}async mountView(e){const r=this.getView(e);if(!r)return;const n=this.control.getViewLifecycleGeneration(e),i=()=>this.getView(e)===r&&this.control.isPendingViewInitCurrent(e,n);if(i())return this.control.emitInitLoadingChange({loading:!0,phase:"scene",status:"start"}),this.control.armPendingViewInit(e),this.control.queuePendingViewInit(e,async()=>{var a,c;if(!i()||(this.control.worker.isActive||(this.control.cursor.activeCollector(),await this.control.ensureRenderRuntimeReady()),!i())||(await r.displayer.resetRenderSurface(),!i())||(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}),!i()))return;const o=this.getViewInitData(e);if(o&&((a=this.control.worker)==null||a.createViewWorker(e,o,r.displayer)),(c=this.control.worker)!=null&&c.isActive){const l=await this.control.worker.waitForViewInitCompletion(e);if(!i())return;if(l==="timeout")throw this.control.emitInitLoadingChange({loading:!1,phase:"ready",status:"timeout"}),new Error(`view init completion timeout: ${e}`)}},n)}}class ir extends tt{constructor(e){super(e);x(this,"viewContainerManager");x(this,"divMainView");x(this,"bindMainViewListener",e=>{this.divMainView=e,this.plugin&&!this.viewContainerManager.mainView&&this.viewContainerManager.bindMainView()});x(this,"onCameraChange",u1e(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)},Qa,{leading:!1}));const r={control:this,internalMsgEmitter:ir.InternalMsgEmitter,publicMsgEmitter:ir.PublicMsgEmitter};this.viewContainerManager=new Bi(r)}init(){ir.InternalMsgEmitter.on(We.BindMainView,this.bindMainViewListener)}destroy(e={}){return ir.InternalMsgEmitter.off(We.BindMainView,this.bindMainViewListener),this.onCameraChange.cancel(),super.destroy(e)}activePlugin(){this.plugin&&this.divMainView&&!this.viewContainerManager.mainView&&this.viewContainerManager.bindMainView(),this.collector&&(this.collector.addStorageStateListener(e=>{var a;if((a=this.collector)!=null&&a.storage&&Object.keys(this.collector.storage).length===0){const l=Object.keys(e.diffView||{});for(const u of l.length?l:[Fe])this.handleRemoteStorageRemoval(u,void 0,{clearView:!0});return}const{diffView:r,diffScenePath:n,diffData:i}=e,o=new Map;if(r){let c;Object.keys(r).forEach(l=>{const u=r[l];if(u&&!u.newValue)this.handleRemoteStorageRemoval(l,void 0,{clearView:!0}),u.oldValue&&(c=u.oldValue);else if(u&&u.newValue){for(const h of Object.keys(u.newValue))this.worker.pullServiceData(l,h,{isAsync:!1,useAnimation:!0});c=u.newValue}if(c)for(const h of Object.values(c)){const d=new Set;for(const f of Object.keys(h))f&&d.add(f);o.set(l,d)}})}if(n){let c;Object.keys(n).forEach(l=>{const u=n[l],h=(u==null?void 0:u.scenePath)??l;if(u&&u.viewId&&!u.newValue?(this.handleRemoteStorageRemoval(u.viewId,void 0,{clearView:!0}),u.oldValue&&(c=u.oldValue)):u&&u.viewId&&u.newValue&&(this.worker.pullServiceData(u.viewId,h,{isAsync:!1,useAnimation:!0}),c=u.newValue),u!=null&&u.viewId&&c){const d=new Set;for(const f of Object.keys(c))f&&d.add(f),o.set(u.viewId,d)}})}i&&Object.keys(i).forEach(c=>{var u,h,d,f;const l=i[c];if(l){const g=l.storageKey??c,{viewId:y}=l,S=!l.newValue&&((u=this.collector)==null?void 0:u.isOwn(g));if(!l.newValue){const I=!!S&&!!((h=this.collector)!=null&&h.isSelector(g));this.handleRemoteStorageRemoval(y,g,{abortAllContinuousMethods:I,cancelTicker:I})}const b=o.get(y)||new Set;b.add(g),o.set(y,b),(d=this.worker)==null||d.onServiceDerive(g,l),(f=this.miniMapManager)==null||f.updateMiniMapCamera(y)}});for(const[c,l]of o.entries())tt.InternalMsgEmitter.emit("excludeIds",[...l],c)}),this.room&&(this.roomMember.onUidChangeHook(e=>{var r;(r=this.collector)!=null&&r.serviceStorage&&this.viewContainerManager.getAllViews().forEach(n=>{var i,o,a,c,l,u;if(n&&n.focusScenePath&&((i=this.collector)!=null&&i.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 f=(c=this.collector)==null?void 0:c.getUidFromKey(d);if(f&&!e.online.includes(f))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 g=this.textEditorManager.editors.get(d);g&&g.opt&&(g.opt.workState===de.Doing||g.opt.workState===de.Start)&&(js(g.opt.text)?this.textEditorManager.unActive(d):this.textEditorManager.delete(d))}}}})}),this.worker.isActive&&this.viewContainerManager.getAllViews().forEach(e=>{e&&e.focusScenePath&&this.worker.pullServiceData(e.id,e.focusScenePath,{isAsync:!0,useAnimation:!1})})))}async activeWorker(){await this.restoreCachedRenderRuntimeDecision(),await this.worker.init()}}const ve=class ve extends fm{constructor(){super(...arguments);x(this,"callbackDisplayer");x(this,"callbackStateName");x(this,"callbackOwnerManager");x(this,"ownedManager");x(this,"roomLifecycleDisposer");x(this,"roomLifecycleOwnerManager");x(this,"onPhaseChanged",e=>{var r;e===Pi.Reconnecting&&((r=this.ownedManager)==null||r.setSnapshootData())});x(this,"updateRoomWritable",()=>{var r;const e=this.callbackDisplayer||this.displayer;(r=this.ownedManager)==null||r.onWritableChange(e.isWritable)});x(this,"roomStateChangeListener",async e=>{const r=this.ownedManager;r instanceof ir&&(e.cameraState&&r.onCameraChange(e.cameraState),e.sceneState&&r.onSceneChange(e.sceneState.scenePath,Fe)),e!=null&&e.roomMembers&&(r==null||r.onRoomMembersChange(e.roomMembers));const n=this.callbackDisplayer||this.displayer;ze(n)&&!n.isWritable||e.memberState&&(r==null||r.onMemberChange(e.memberState))})}static async getInstance(e,r){var I,N,T;const n=new Xs(ze(e)&&e.logger||ve.logger),i=typeof navigator>"u"?"unknown":navigator.userAgent;n.info(`[Appliance]: [init-enter] version=${Dc} userAgent=${i}`),(p=>{var m,v;try{(v=(m=r.callbacks)==null?void 0:m.onInitLoadingChange)==null||v.call(m,p)}catch(M){ve.logger.error(`[ApplianceSinglePlugin] onInitLoadingChange error: ${(M==null?void 0:M.message)||M}`)}})({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);r!=null&&r.logger&&(ve.logger=new Xs(r.logger));let d=e.getInvisiblePlugin(ve.kind);d||(d=await ve.createAppliancePlugin(e,ve.kind)),e&&d&&await ve.createCurrentManager(e,{cdn:r.options.cdn,extras:Jv(r.options.extras)},d,r.callbacks),d&&ve.currentManager&&(ve.currentManager.bindPlugin(d),d.init(e)),ve.effectInstance(r==null?void 0:r.cursorAdapter,ve.currentManager),(I=ve.currentManager)==null||I.emitInitLoadingChange({loading:!0,phase:"plugin",status:"success"});const f={displayer:e,currentManager:ve.currentManager,maxScreenshotWidth:10*1024,maxScreenshotHeight:10*1024,_injectTargetObject:void 0,getBoundingRectAsync:async function(p){var M;ve.logger.info("[ApplianceSinglePlugin] getBoundingRectAsync");const m=e.getBoundingRect(p),v=await((M=ve.currentManager)==null?void 0:M.getBoundingRect(p));return!m.width||!m.height?v:vd(m,v)},screenshotToCanvasAsync:async function(p,m,v,M,k,E){var R;ve.logger.info("[ApplianceSinglePlugin] screenshotToCanvasAsync");let D=v,P=M,z=k.scale;D>this.maxScreenshotWidth&&(z=this.maxScreenshotWidth/D*z,D=this.maxScreenshotWidth),P>this.maxScreenshotHeight&&(z=Math.min(this.maxScreenshotHeight/P*z,z),P=this.maxScreenshotHeight),k.scale=z;const j=document.createElement("canvas"),A=j.getContext("2d");j.width=D*(E||1),j.height=P*(E||1),A&&(e.screenshotToCanvas(A,m,D,P,k,E),p.drawImage(j,Math.floor((v-D)/2),Math.floor((M-P)/2),D*(E||1),P*(E||1),0,0,D,P),j.remove()),ve.currentManager&&await((R=ve.currentManager)==null?void 0:R.screenshotToCanvas(p,m,D,P,k,Math.floor((v-D)/2),Math.floor((M-P)/2)))},scenePreviewAsync:async function(p,m,v,M,k){ve.logger.info("[ApplianceSinglePlugin] scenePreviewAsync"),e.scenePreview(p,m,v,M,k);const E=document.createElement("img");E.className="appliance-plugin-fill-scene-snapshot-img",m.append(E),getComputedStyle(m).position||(m.style.position="relative"),ve.currentManager&&await ve.currentManager.scenePreview(p,E)},fillSceneSnapshotAsync:async function(p,m,v,M,k){var O,V;ve.logger.info("[ApplianceSinglePlugin] fillSceneSnapshotAsync"),m.innerHTML="",e.fillSceneSnapshot(p,m,v,M,k);const E=v||((O=e.state.cameraState)==null?void 0:O.width)||0,D=M||((V=e.state.cameraState)==null?void 0:V.height)||0;let P=await this.getBoundingRectAsync(p);P||(P={originX:0,originY:0,width:E,height:D});let z=Math.max(P==null?void 0:P.width,E),j=Math.max(P==null?void 0:P.height,D),A=1;const R=z>E&&Math.min(E/z,A)||A,L=j>D&&Math.min(D/j,A)||A;R<=L?(z=R<1&&E||z,j=Math.floor(j*R)+1,A=R):R>L&&(j=L<1&&D||j,z=Math.floor(z*L)+1,A=L);const W={scale:A,centerX:P.originX+P.width/2,centerY:P.originY+P.height/2},Y=document.createElement("canvas"),H=Y.getContext("2d");Y.width=z,Y.height=j,H&&await this.screenshotToCanvasAsync(H,p,z,j,W,devicePixelRatio);const ie=document.createElement("img");ie.className="appliance-plugin-fill-scene-snapshot-img",ie.src=Y.toDataURL(),ie.onload=()=>{Y.remove()},ie.onerror=()=>{Y.remove(),ie.remove()},m.append(ie),getComputedStyle(m).position||(m.style.position="relative")},_callbacksOn:function(p,m){ve.currentManager===f.currentManager&&((p==="onCanUndoStepsUpdate"||p==="onCanRedoStepsUpdate")&&ze(e)&&e.isWritable?ir.InternalMsgEmitter.on(p,m):a.call(e.callbacks,p,m))},_callbacksOnce:function(p,m){ve.currentManager===f.currentManager&&((p==="onCanUndoStepsUpdate"||p==="onCanRedoStepsUpdate")&&ze(e)&&e.isWritable?ir.InternalMsgEmitter.on(p,m):l.call(e.callbacks,p,m))},_callbacksOff:function(p,m){ve.currentManager===f.currentManager&&((p==="onCanUndoStepsUpdate"||p==="onCanRedoStepsUpdate")&&ze(e)&&e.isWritable?ir.InternalMsgEmitter.off(p,m):c.call(e.callbacks,p,m))},canRedoSteps(){if(ve.logger.info("[ApplianceSinglePlugin] canRedoSteps"),ve.currentManager&&ze(e)&&!e.disableSerialization){const p=ve.currentManager.viewContainerManager.focuedView,m=p==null?void 0:p.focusScenePath;if(p&&m)return p.displayer.commiter.redoStack.filter(v=>v.scenePath===m).length}return 0},canUndoSteps(){if(ve.logger.info("[ApplianceSinglePlugin] canUndoSteps"),ve.currentManager&&ze(e)&&!e.disableSerialization){const p=ve.currentManager.viewContainerManager.focuedView,m=p==null?void 0:p.focusScenePath;if(p&&m)return p.displayer.commiter.undoStack.filter(v=>v.scenePath===m).length}return 0},undo:function(){return ve.logger.info("[ApplianceSinglePlugin] undo"),ve.currentManager&&ze(e)&&!e.disableSerialization?ve.currentManager.viewContainerManager.undo():0},redo:function(){return ve.logger.info("[ApplianceSinglePlugin] redo"),ve.currentManager&&ze(e)&&!e.disableSerialization?ve.currentManager.viewContainerManager.redo():0},cleanCurrentScene:function(p){ve.logger.info("[ApplianceSinglePlugin] cleanCurrentScene"),ve.currentManager&&ze(e)&&e.isWritable&&ve.currentManager.cleanCurrentScene().then(m=>{m&&u.call(e,p)}).catch(m=>{var v;(v=ve.currentManager)==null||v.logger.error(`[Appliance]: cleanCurrentScene failed: ${(m==null?void 0:m.message)||m}`)})},insertImage:function(p){ve.logger.info("[ApplianceSinglePlugin] insertImage"),ve.currentManager&&ze(e)&&e.isWritable&&ve.currentManager.worker.insertImage(Fe,p)},lockImage:function(p,m){ve.logger.info("[ApplianceSinglePlugin] lockImage"),ve.currentManager&&ze(e)&&e.isWritable&&ve.currentManager.worker.lockImage(Fe,p,m)},completeImageUpload:function(p,m){ve.logger.info("[ApplianceSinglePlugin] completeImageUpload"),ve.currentManager&&ze(e)&&e.isWritable&&ve.currentManager.worker.completeImageUpload(Fe,p,m)},getImagesInformation:function(p){return ve.logger.info("[ApplianceSinglePlugin] completeImageUpload"),ve.currentManager&&ze(e)&&e.isWritable?ve.currentManager.worker.getImagesInformation(p):[]},insertText:function(p,m,v){if(ve.logger.info("[ApplianceSinglePlugin] insertText"),ve.currentManager&&ze(e)&&e.isWritable)return ve.currentManager.textEditorManager.insertText(Fe,p,m,v)},updateText:function(p,m){ve.logger.info("[ApplianceMultiPlugin] updateText"),ve.currentManager&&ze(e)&&e.isWritable&&ve.currentManager.textEditorManager.updateText(p,m)},callbacks:()=>({...e.callbacks,on:f._callbacksOn.bind(f),once:f._callbacksOnce.bind(f),off:f._callbacksOff.bind(f)}),destroy(){return ve.logger.info("[ApplianceSinglePlugin] destroy"),d?d.destroyOwnedPluginInstance(f.currentManager):Promise.resolve()},setMemberState(p){var v,M,k;ve.logger.info(`[ApplianceSinglePlugin] setMemberState ${JSON.stringify(p)}`);const m=Object.keys(p);if(ze(e)&&e.isWritable){if(m.includes("currentApplianceName"))if((v=ve.currentManager)==null||v.requestToolChange(p),p.currentApplianceName&&p.currentApplianceName===De.laserPen){if((M=ve.currentManager)!=null&&M.isUseSimple)throw new Error("[ApplianceMultiPlugin] laserPen must be not support in simple mode");p.currentApplianceName=De.pencil,p.useLaserPen=!0}else p.currentApplianceName&&p.currentApplianceName===De.pencil&&(p.useLaserPen=!1);try{h(p)}catch(E){throw(k=ve.currentManager)==null||k.setToolChangePending(!1,"set-member-state-error"),E}return}throw new Error("setMemberState must be called in writable room")},createMiniMap:async function(p,m){if(ve.logger.info("[ApplianceSinglePlugin] createMiniMap"),ve.currentManager&&ze(e)&&e.isWritable)return ve.currentManager.createMiniMap(p,m)},destroyMiniMap:async function(p){if(ve.logger.info("[ApplianceMultiPlugin] destroyeMiniMap"),ve.currentManager&&ze(e)&&e.isWritable)return ve.currentManager.destroyMiniMap(p)},filterRenderByUid(p,m,v){if(ve.logger.info("[ApplianceSinglePlugin] filterRenderByUid"),ve.currentManager&&ze(e)&&e.isWritable)return ve.currentManager.filterRenderByUid(p,m,v)},cancelFilterRender(p,m){if(ve.logger.info("[ApplianceSinglePlugin] filterRenderByUid"),ve.currentManager&&ze(e)&&e.isWritable)return ve.currentManager.cancelFilterRender(p,m)},addListener:(p,m)=>{ir.PublicMsgEmitter.on(p,m)},removeListener:(p,m)=>{ir.PublicMsgEmitter.off(p,m)},usePlugin:p=>{var m;ve.logger.info("[ApplianceSinglePlugin] usePlugin",p.kind),(m=ve.currentManager)==null||m.usePlugin(p)},getDisableDeviceInputs(){if(ve.currentManager&&ze(e))return ve.currentManager.disableDeviceInputs},setDisableDeviceInputs(p){ve.logger.info(`[ApplianceSinglePlugin] setDisableDeviceInputs ${p}`),ve.currentManager&&ze(e)&&(ve.currentManager.disableDeviceInputs=p)},getDisableCameraTransform(){if(ve.currentManager&&ze(e))return ve.currentManager.disableCameraTransform},setDisableCameraTransform(p){ve.logger.info(`[ApplianceSinglePlugin] setDisableCameraTransform ${p}`),ve.currentManager&&ze(e)&&(ve.currentManager.disableCameraTransform=p)},getDisableEraseImage(){if(ve.currentManager&&ze(e))return ve.currentManager.disableEraseImage},setDisableEraseImage(p){ve.logger.info(`[ApplianceSinglePlugin] setDisableEraseImage ${p}`),ve.currentManager&&ze(e)&&(ve.currentManager.disableEraseImage=p)},setWritable:p=>f.setWritable(p),requestIdleCallback:(p,m)=>{const v=(m==null?void 0:m.timeout)||0,M=performance.now();let k;const E=new MessageChannel;let D;const P=z=>{try{p({didTimeout:z,timeRemaining:()=>{const A=performance.now()-M;return Math.max(0,v-A)}})}catch(j){ve.logger.error("[ApplianceSinglePlugin] requestIdleCallback error:",j)}finally{E.port1.close(),E.port2.close(),k!==void 0&&cancelAnimationFrame(k),D!==void 0&&clearTimeout(D)}};return E.port1.onmessage=()=>{k=requestAnimationFrame(()=>{v>0&&performance.now()-M>=v?P(!0):P(!1)})},E.port2.postMessage(null),v>0&&(D=setTimeout(()=>{P(!0)},v)),D||k||0},cancelIdleCallback:p=>{try{clearTimeout(p),cancelAnimationFrame(p)}catch(m){ve.logger.error("[ApplianceSinglePlugin] cancelIdleCallback error:",m)}},injectMethodToObject:(p,m)=>{if(typeof p[m]=="function"||typeof p[m]>"u"){const v=f[m];p[m]=function(...M){if(ve.currentManager===f.currentManager)return Reflect.apply(v,this,M)};return}m==="callbacks"&&(p.callbacks.on=f._callbacksOn.bind(f),p.callbacks.off=f._callbacksOff.bind(f),p.callbacks.once=f._callbacksOnce.bind(f))},blurText:()=>{ve.logger.info("[ApplianceSinglePlugin] blurText"),ve.currentManager&&ze(e)&&e.isWritable&&ve.currentManager.textEditorManager.checkEmptyTextBlur()},hasElements:(p,m)=>{var v;if(ve.logger.info(`[ApplianceSinglePlugin] hasElements ${p}`),ve.currentManager&&ze(e)&&e.isWritable){let M=p;if(!M){const k=ve.currentManager.viewContainerManager.focuedView;M=k==null?void 0:k.focusScenePath}if(M){const k=(v=ve.currentManager.collector)==null?void 0:v.getScenePathData(M);if(k){const E=Object.values(k);return E.length>0?m?E.some(D=>m(D.toolsType)):!0:!1}return!1}return!1}},getElements:(p,m)=>{var v;if(ve.logger.info(`[ApplianceSinglePlugin] getElements ${p}`),ve.currentManager&&ze(e)&&e.isWritable){let M=p;if(!M){const k=ve.currentManager.viewContainerManager.focuedView;M=k==null?void 0:k.focusScenePath}if(M){const k=(v=ve.currentManager.collector)==null?void 0:v.getScenePathData(M),E=k&&Object.values(k)||[];return k&&E.length>0&&m?E.filter(D=>m(D.toolsType)):E}return[]}},hasBackgroundImage:p=>{var m,v;return hM((v=(m=ve.currentManager)==null?void 0:m.collector)==null?void 0:v.storage,p)},stopDraw:p=>{if(ve.logger.info(`[ApplianceSinglePlugin] stopDraw ${p}`),ve.currentManager&&ze(e))return ve.currentManager.stopDraw(p)},loadFontFaces:()=>{var p;return ve.logger.info("[ApplianceSinglePlugin] loadFontFaces"),((p=ve.currentManager)==null?void 0:p.loadFontFaces())||Promise.resolve({status:"error"})},refreshViewRender:p=>{var m;return ve.logger.info(`[ApplianceSinglePlugin] refreshViewRender ${p}`),((m=ve.currentManager)==null?void 0:m.refreshViewRender(p))||Promise.resolve({status:"error"})},refreshRender:()=>{var p;return ve.logger.info("[ApplianceSinglePlugin] refreshRender"),((p=ve.currentManager)==null?void 0:p.refreshRender())||Promise.resolve({status:"error"})},refreshViewTextRender:p=>{var m;return ve.logger.info(`[ApplianceSinglePlugin] refreshViewTextRender ${p}`),((m=ve.currentManager)==null?void 0:m.refreshViewTextRender(p))||Promise.resolve({status:"error"})},refreshTextRender:()=>{var p;return ve.logger.info("[ApplianceSinglePlugin] refreshTextRender"),((p=ve.currentManager)==null?void 0:p.refreshTextRender())||Promise.resolve({status:"error"})},setViewLocalScenePathChange:async(p,m)=>{ve.logger.info(`[ApplianceSinglePlugin] setViewLocalScenePathChange ${p} ${m}`),ve.currentManager&&await ve.currentManager.setViewLocalScenePathChange(p,m)},insertMarkmap:async(p,m)=>{if(ve.logger.info(`[ApplianceSinglePlugin] insertMarkmap: ${p}, info: ${JSON.stringify(m)}`),ve.currentManager&&ve.currentManager.isUseBackgroundThread)return ve.currentManager.worker.insertBackgroundMarkMap(p,m)},updateMarkmap:async(p,m,v)=>{if(ve.logger.info(`[ApplianceSinglePlugin] updateMarkmap: ${p}, markmapId: ${m}, info: ${JSON.stringify(v)}`),ve.currentManager&&ve.currentManager.isUseBackgroundThread)return ve.currentManager.worker.updateBackgroundMarkMap(p,m,v)},insertBackgroundImage:async(p,m)=>{if(ve.logger.info(`[ApplianceSinglePlugin] insertBackgroundImage: ${p}, info: ${JSON.stringify(m)}`),ve.currentManager&&ve.currentManager.isUseBackgroundThread)return ve.currentManager.worker.insertBackgroundSVG(p,m)},reloadBackgroundImage:async p=>{const m=ve.currentManager;return m?m.reloadBackgroundImage(p):{accepted:!1,reloadedCount:0,reason:"viewNotFound"}},getSelectedElements:p=>{var m,v;return(v=(m=ve.currentManager)==null?void 0:m.selectorApi)==null?void 0:v.getSelectedElements(p)},isElementPropertySupported:(p,m)=>{var v,M;return((M=(v=ve.currentManager)==null?void 0:v.selectorApi)==null?void 0:M.isElementPropertySupported(p,m))||!1},blurSelector:p=>{var m;if(ve.currentManager&&ze(e)&&e.isWritable){const v=(m=ve.currentManager)==null?void 0:m.selectorApi;return v?v.blurSelector(p):Promise.resolve({ok:!1,requestId:`clear-${Date.now().toString(36)}`,viewId:p||Fe,reason:"no-selection"})}return Promise.resolve({ok:!1,requestId:`clear-${Date.now().toString(36)}`,viewId:p||Fe,reason:"no-selection"})},updateSelectedElements:p=>{var m;if(ve.currentManager&&ze(e)&&e.isWritable){const v=(m=ve.currentManager)==null?void 0:m.selectorApi;return v?v.updateSelectedElements(Fe,p):Promise.resolve({requestId:`update-${Date.now().toString(36)}`,viewId:Fe,ok:!1,reason:"no-selection"})}return Promise.resolve({requestId:`update-${Date.now().toString(36)}`,viewId:Fe,ok:!1,reason:"no-writable permission"})},updateElement:(p,m,v,M,k=!0)=>{var E;if(ve.currentManager&&ze(e)&&e.isWritable){const D=(E=ve.currentManager)==null?void 0:E.selectorApi;return D?D.updateElement(p,m,v,M,k):Promise.resolve(!1)}return Promise.resolve(!1)},copySelectedElements:p=>{var m;if(ve.currentManager&&ze(e)&&e.isWritable){const v=(m=ve.currentManager)==null?void 0:m.selectorApi;return v?v.copySelectedElements(p):Promise.resolve({ok:!1,requestId:`copy-${Date.now().toString(36)}`,viewId:p||Fe,reason:"no-selection"})}return Promise.resolve({ok:!1,requestId:`copy-${Date.now().toString(36)}`,viewId:p||Fe,reason:"no-selection"})},deleteSelectedElements:p=>{var m;if(ve.currentManager&&ze(e)&&e.isWritable){const v=(m=ve.currentManager)==null?void 0:m.selectorApi;return v?v.deleteSelectedElements(p):Promise.resolve({ok:!1,requestId:`delete-${Date.now().toString(36)}`,viewId:p||Fe,reason:"no-selection"})}return Promise.resolve({ok:!1,requestId:`delete-${Date.now().toString(36)}`,viewId:p||Fe,reason:"no-selection"})},getFloatbarContainer:p=>{var m;return(m=ve.currentManager)==null?void 0:m.viewContainerManager.getFloatbarContainer(p)},getViewOffsetToContainer:(p,m)=>{var v;return(v=ve.currentManager)==null?void 0:v.viewContainerManager.getViewOffsetToContainer(p,m)}};f.injectMethodToObject(e,"undo"),f.injectMethodToObject(e,"redo"),f.injectMethodToObject(e,"cleanCurrentScene"),f.injectMethodToObject(e,"blurSelector"),f.injectMethodToObject(e,"updateElement"),f.injectMethodToObject(e,"insertImage"),f.injectMethodToObject(e,"completeImageUpload"),f.injectMethodToObject(e,"lockImage"),f.injectMethodToObject(e,"getImagesInformation"),f.injectMethodToObject(e,"insertText"),f.injectMethodToObject(e,"updateText"),f.injectMethodToObject(e,"callbacks"),f.injectMethodToObject(e,"screenshotToCanvasAsync"),f.injectMethodToObject(e,"getBoundingRectAsync"),f.injectMethodToObject(e,"scenePreviewAsync"),f.injectMethodToObject(e,"fillSceneSnapshotAsync"),f.injectMethodToObject(e,"setMemberState"),ze(e)&&d&&(d.disposeRoomLifecycleInterceptor(),d.roomLifecycleDisposer=gm(e,()=>f.currentManager,ve.logger),d.roomLifecycleOwnerManager=f.currentManager),Object.defineProperty(e,"canUndoSteps",{get(){return f.canUndoSteps()}}),Object.defineProperty(e,"canRedoSteps",{get(){return f.canRedoSteps()}});const g={...f,callbacks:f.callbacks()};Object.defineProperty(g,"disableDeviceInputs",{set(p){f.setDisableDeviceInputs(p)},get(){return f.getDisableDeviceInputs()}}),Object.defineProperty(g,"disableEraseImage",{set(p){f.setDisableEraseImage(p)},get(){return f.getDisableEraseImage()}}),Object.defineProperty(g,"disableCameraTransform",{set(p){f.setDisableCameraTransform(p)},get(){return f.getDisableCameraTransform()}});const y=dM(g,f.currentManager,()=>ve.currentManager),S=ve.currentManager;e._appliancePlugin=y;const b=(N=ve.currentManager)==null?void 0:N.pluginOptions.extras.cursor;if(b&&((T=ve.currentManager)==null||T.worker.afterMainViewInitAck(()=>{uM(b)})),!S)throw e._appliancePlugin===y&&delete e._appliancePlugin,new Error("ApplianceSinglePlugin initialization was cancelled");if(S.startInitFontFaceLoadAndRender(),S.isMainViewMounted()){const p=await S.worker.waitForMainViewInitAck();if(p!=="ready"||ve.currentManager!==S)throw e._appliancePlugin===y&&delete e._appliancePlugin,new Error(`ApplianceSinglePlugin initialization ${p==="timeout"?"timed out":"was cancelled"}`)}else S.logger.info("[Appliance]: main view not mounted yet, deferring render-init ack wait"),S.waitForMainViewMounted().then(p=>{if(!(p!=="ready"||ve.currentManager!==S))return S.worker.waitForMainViewInitAck().then(m=>{S.logger.info(`[Appliance]: deferred render-init ${m}`)})}).catch(p=>{S.logger.error(`[Appliance]: deferred render-init failed: ${(p==null?void 0:p.message)||p}`)});return y}static onCreate(e){e&&ve.currentManager&&(ve.currentManager.bindPlugin(e),e.init(e.displayer))}static async createAppliancePlugin(e,r){try{await e.createInvisiblePlugin(ve,{})}catch(i){if(!e.isWritable){await e.setWritable(!0);const o=await this.createAppliancePlugin(e,r);return await e.setWritable(!1),o}throw i}let n=e.getInvisiblePlugin(r);return n||(n=await ve.createAppliancePlugin(e,r)),n}static beginManagerDestroy(e){if(!e)return Promise.resolve();if(ve.drainingManager===e&&ve.drainingPromise)return ve.drainingPromise;ve.currentManager===e&&(ve.currentManager=void 0),ve.drainingManager=e;const r=e.destroy({preserveStorage:!0}).finally(()=>{ve.drainingManager===e&&(ve.drainingManager=void 0),ve.drainingPromise===r&&(ve.drainingPromise=void 0)});return ve.drainingPromise=r,r}static effectInstance(e=ve.cursorAdapter,r=ve.currentManager){ve.disposeCursorAdapterBinding(),ve.cursorAdapter=e,ve.cursorAdapterOwnerManager=e?r:void 0;const n=e==null?void 0:e.onAddedCursor;if(e&&typeof n=="function"){const i=function(o){o.onCursorMemberChanged=a=>{try{a.appliance===De.pencil||a.appliance===De.shape||a.appliance===De.text||a.appliance===De.arrow||a.appliance===De.straight||a.appliance===De.rectangle||a.appliance===De.ellipse||a.appliance===De.eraser||a.appliance===De.selector?o!=null&&o.divElement&&(o.divElement.style.display="none"):o!=null&&o.divElement&&(o.divElement.style.display="block")}catch(c){throw c}},n.call(e,o)};e.onAddedCursor=i,ve.cursorAdapterBinding={adapter:e,original:n,wrapper:i,owner:r}}}static disposeCursorAdapterBinding(e){const r=ve.cursorAdapterBinding;e!==void 0&&(r==null?void 0:r.owner)!==e&&ve.cursorAdapterOwnerManager!==e||(r&&r.adapter.onAddedCursor===r.wrapper&&(r.adapter.onAddedCursor=r.original),ve.cursorAdapterBinding=void 0,ve.cursorAdapter=void 0,ve.cursorAdapterOwnerManager=void 0)}init(e){this.unbindDisplayerCallbacks();const r=this.ownedManager,n=e.state;r==null||r.onRoomMembersChange(n.roomMembers),ze(e)&&n!=null&&n.memberState&&(r==null||r.onMemberChange(n.memberState));const i=ih(e)?"onPlayerStateChanged":"onRoomStateChanged";this.callbackDisplayer=e,this.callbackStateName=i,this.callbackOwnerManager=r,e.callbacks.on(i,this.roomStateChangeListener),e.callbacks.on("onEnableWriteNowChanged",this.updateRoomWritable),e.callbacks.on("onPhaseChanged",this.onPhaseChanged)}unbindDisplayerCallbacks(e){if(e!==void 0&&this.callbackOwnerManager!==e)return;const r=this.callbackDisplayer,n=this.callbackStateName;r&&n&&(r.callbacks.off(n,this.roomStateChangeListener),r.callbacks.off("onEnableWriteNowChanged",this.updateRoomWritable),r.callbacks.off("onPhaseChanged",this.onPhaseChanged)),this.callbackDisplayer=void 0,this.callbackStateName=void 0,this.callbackOwnerManager=void 0}disposeRoomLifecycleInterceptor(e){var r;e!==void 0&&this.roomLifecycleOwnerManager!==e||((r=this.roomLifecycleDisposer)==null||r.call(this),this.roomLifecycleDisposer=void 0,this.roomLifecycleOwnerManager=void 0)}destroyOwnedPluginInstance(e){return this.unbindDisplayerCallbacks(e),this.disposeRoomLifecycleInterceptor(e),ve.disposeCursorAdapterBinding(e),this.destroyOwnedManager(e)}destroyOwnedManager(e=this.ownedManager){return e?(this.ownedManager===e&&(this.ownedManager=void 0),ve.beginManagerDestroy(e)):Promise.resolve()}destroy(){ve.logger.info("[ApplianceSinglePlugin] passive destroy"),this.unbindDisplayerCallbacks(),this.disposeRoomLifecycleInterceptor(),ve.disposeCursorAdapterBinding(),this.destroyOwnedManager()}};x(ve,"drainingManager"),x(ve,"drainingPromise"),x(ve,"kind","appliance-single-plugin"),x(ve,"cursorAdapter"),x(ve,"cursorAdapterOwnerManager"),x(ve,"cursorAdapterBinding"),x(ve,"currentManager"),x(ve,"logger",{info:console.log,warn:console.warn,error:console.error}),x(ve,"createCurrentManager",async(e,r,n,i)=>{ve.drainingPromise&&await ve.drainingPromise,ve.currentManager&&await ve.beginManagerDestroy(ve.currentManager);const o={plugin:n,displayer:e,options:r,callbacks:i},a=new ir(o);a.init(),ve.logger.info("[ApplianceSinglePlugin] refresh ApplianceSingleManager object"),ve.currentManager=a,n&&(n.ownedManager=a)});let _u=ve;const Ui=class Ui extends Q.Component{constructor(){super(...arguments);x(this,"mainViewRef",null)}componentDidMount(){Ui.emiter||(Ui.emiter=ir.InternalMsgEmitter),Ui.emiter.emit(We.BindMainView,this.mainViewRef)}render(){return Q.createElement(Q.Fragment,null,this.props.children,Q.createElement("div",{className:"appliance-plugin-main-view-displayer",ref:e=>this.mainViewRef=e}))}};x(Ui,"emiter");let eh=Ui;const d1e=Object.freeze(Object.defineProperty({__proto__:null,ActiveContainerType:um,ApplianceMultiPlugin:Ju,ApplianceNames:De,AppliancePluginCursorNames:or,ApplianceSigleWrapper:eh,ApplianceSinglePlugin:_u,Camera_Ack_Slow_Timeout:ru,Camera_Transport_Fallback_Timeout:sa,Camera_Update_Business_Timeout:dm,Cursor_Hover_Id:hm,ECanvasShowType:_e,EDataType:xe,EForceStopReason:Ds,EImageType:on,EMatrixrRelationType:sn,EOperationType:wt,EPostMessageType:le,ERenderFilterType:Mr,ESVGType:Wi,EScaleType:Ye,EStrokeType:Be,EToolsKey:q,ElayerType:Cn,EmitEventType:Te,EventMessageType:Ls,EventWorkState:de,EvevtWorkState:de,FontFaceFallbackBlacklistLevel:Js,InternalMsgEmitterType:We,Main_View_Id:Fe,Renderer_Business_Default_Timeout:qa,ShapeType:Zt,Task_Time_Interval:Qa,WorkerCanvasContextBlacklistLevel:Ha,WorkerMaskTextureFormatBlacklistLevel:rh,WorkerMaskTextureUploadBlacklistLevel:nh,WorkerRenderModeBlacklistLevel:Ar},Symbol.toStringTag,{value:"Module"}));exports.Cursor_Hover_Id=hm;exports.DefaultAppliancePluginExtrasOptions=He;exports.ECanvasShowType=_e;exports.EDataType=xe;exports.EImageType=on;exports.EMatrixrRelationType=sn;exports.EPostMessageType=le;exports.ESVGType=Wi;exports.EToolsKey=q;exports.EmitEventType=Te;exports.EventWorkState=de;exports.Group=dt;exports.Main_View_Id=Fe;exports.MaxDelayBatchScheduler=O0;exports.ObserverMap=Fu;exports.Scene=Sc;exports.ServiceRenderScheduler=Kye;exports.Storage_Selector_key=Le;exports.Storage_Splitter=Bt;exports.Storage_ViewId_ALL=Bu;exports.Task_Time_Interval=Qa;exports.VNodeManager=E0;exports.ViewContainerManager=Yi;exports.acceptIncomingEraserGeometryDelta=Fpe;exports.cancelDoingForGeometryMismatch=t0;exports.computRect=Ue;exports.flushServiceRenderBarrier=B0;exports.formatRendererBusinessError=N0;exports.geometryDigest=Hs;exports.getEraserBatchDelay=z0;exports.getIconImageSrc=x0;exports.getMarkmapRuntimeOrThrow=tM;exports.getOutgoingEraserGeometryDelta=Dpe;exports.getRectMatrixrRelation=Bc;exports.getSafetyRect=wn;exports.getShapeInstance=pd;exports.hasDoingGeometryTransform=zpe;exports.index=d1e;exports.isCameraUpdateTimeoutError=$ye;exports.isEqual=nn;exports.isIntersectForPoint=Y0;exports.isNumber=yt;exports.normalizeCameraTaskError=R0;exports.removeAllChildren=ur;exports.removeTexture=hr;exports.resolveCursorToolName=Nc;exports.runCameraUpdateWithTimeout=A0;exports.toRendererBusinessError=Wu;exports.transformToNormalData=Nn;exports.transformToSerializableData=xt;exports.waitForCameraUpdateTask=P0;exports.waitForRendererBusiness=Uu;
|