@m2c2kit/core 0.3.17 → 0.3.19

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/index.min.js CHANGED
@@ -1,3 +1,3 @@
1
- var dt=(v=>(v.Sequence="Sequence",v.Group="Group",v.Wait="Wait",v.Custom="Custom",v.Move="Move",v.Scale="Scale",v.FadeAlpha="FadeAlpha",v.Rotate="Rotate",v))(dt||{});class mt{}mt.none=(v,e,r,l)=>r+e,mt.linear=(v,e,r,l)=>r*v/l+e,mt.quadraticIn=(v,e,r,l)=>(v/=l,r*v*v+e),mt.quadraticOut=(v,e,r,l)=>(v/=l,-r*v*(v-2)+e),mt.quadraticInOut=(v,e,r,l)=>(v/=l/2,v<1?r/2*v*v+e:(v--,-r/2*(v*(v-2)-1)+e)),mt.cubicIn=(v,e,r,l)=>(v/=l,r*v*v*v+e),mt.cubicOut=(v,e,r,l)=>(v/=l,v--,r*(v*v*v+1)+e),mt.cubicInOut=(v,e,r,l)=>(v/=l/2,v<1?r/2*v*v*v+e:(v-=2,r/2*(v*v*v+2)+e)),mt.quarticIn=(v,e,r,l)=>(v/=l,r*v*v*v*v+e),mt.quarticOut=(v,e,r,l)=>(v/=l,v--,-r*(v*v*v*v-1)+e),mt.quarticInOut=(v,e,r,l)=>(v/=l/2,v<1?r/2*v*v*v*v+e:(v-=2,-r/2*(v*v*v*v-2)+e)),mt.quinticIn=(v,e,r,l)=>(v/=l,r*v*v*v*v*v+e),mt.quinticOut=(v,e,r,l)=>(v/=l,v--,r*(v*v*v*v*v+1)+e),mt.quinticInOut=(v,e,r,l)=>(v/=l/2,v<1?r/2*v*v*v*v*v+e:(v-=2,r/2*(v*v*v*v*v+2)+e)),mt.sinusoidalIn=(v,e,r,l)=>-r*Math.cos(v/l*(Math.PI/2))+r+e,mt.sinusoidalOut=(v,e,r,l)=>r*Math.sin(v/l*(Math.PI/2))+e,mt.sinusoidalInOut=(v,e,r,l)=>-r/2*(Math.cos(Math.PI*v/l)-1)+e,mt.exponentialIn=(v,e,r,l)=>r*Math.pow(2,10*(v/l-1))+e,mt.exponentialOut=(v,e,r,l)=>r*(-Math.pow(2,-10*v/l)+1)+e,mt.exponentialInOut=(v,e,r,l)=>(v/=l/2,v<1?r/2*Math.pow(2,10*(v-1))+e:(v--,r/2*(-Math.pow(2,-10*v)+2)+e)),mt.circularIn=(v,e,r,l)=>(v/=l,-r*(Math.sqrt(1-v*v)-1)+e),mt.circularOut=(v,e,r,l)=>(v/=l,v--,r*Math.sqrt(1-v*v)+e),mt.circularInOut=(v,e,r,l)=>(v/=l/2,v<1?-r/2*(Math.sqrt(1-v*v)-1)+e:(v-=2,r/2*(Math.sqrt(1-v*v)+1)+e));var pt=(v=>(v.Node="Node",v.Scene="Scene",v.Sprite="Sprite",v.Label="Label",v.TextLine="TextLine",v.Shape="Shape",v.Composite="Composite",v))(pt||{}),Bt=(v=>(v.Undefined="Undefined",v.Rectangle="Rectangle",v.Circle="Circle",v.Path="Path",v))(Bt||{});class nt{static getUrlFromManifest(e,r){const l=e.manifest;return l&&l[r]?l[r]:r}static urlHasScheme(e){return/^[a-z]+:\/\//i.test(e)}static calculateRotatedPoints(e){const r=e.ancestors;r.reverse(),r.push(e);const l=r.map(p=>{const u=nt.calculateNodeAbsoluteBoundingBox(p);return nt.boundingBoxToPoints(u)});for(let p=0;p<l.length;p++){if(!Ki(r[p]))continue;const u=l[p],y=r[p].zRotation,x=nt.findCentroid(u);for(let W=p;W<r.length;W++)l[W]=Oa(l[W],y,x)}return l[l.length-1]}static rotateCanvasForDrawableNode(e,r){const l=nt.calculateRotationTransforms(r);if(l.length===0)return;const p=Globals.canvasScale/r.absoluteScale;ka(l,p,e)}static calculateNodeAbsoluteBoundingBox(e){const r=e.anchorPoint,l=e.absoluteScale;let p=e.size.width,u=e.size.height;if(e.type===pt.Shape&&e.shapeType===Bt.Circle){const Q=e.circleOfRadius;if(!Q)throw"circleOfRadius is undefined";p=Q*2,u=Q*2}const y=e.absolutePosition.x-p*r.x*l,x=e.absolutePosition.x+p*(1-r.x)*l,W=e.absolutePosition.y-u*r.y*l,U=e.absolutePosition.y+u*(1-r.y)*l;return{xMin:y,xMax:x,yMin:W,yMax:U}}static radiansToDegrees(e){return-nt.normalizeAngleRadians(e)*(180/Math.PI)}static normalizeAngleRadians(e){const r=Math.floor(e/(2*Math.PI));let l=e-r*(2*Math.PI);return l<0&&(l+=2*Math.PI),l}static arePointsOnSameSideOfLine(e,r,l,p){const u=(p.x-l.x)*(e.y-l.y)-(p.y-l.y)*(e.x-l.x),y=(p.x-l.x)*(r.y-l.y)-(p.y-l.y)*(r.x-l.x);return u*y>=0}static isPointInsideRectangle(e,r){if(r.length!==4)throw new Error("Invalid input: expected an array of four points");return nt.arePointsOnSameSideOfLine(e,r[2],r[0],r[1])&&nt.arePointsOnSameSideOfLine(e,r[3],r[1],r[2])&&nt.arePointsOnSameSideOfLine(e,r[0],r[2],r[3])&&nt.arePointsOnSameSideOfLine(e,r[1],r[3],r[0])}static nodeOrAncestorHasBeenRotated(e){const r=e.ancestors;return r.push(e),r.some(l=>Ki(l))}static boundingBoxToPoints(e){const{xMin:r,xMax:l,yMin:p,yMax:u}=e;return[{x:r,y:p},{x:l,y:p},{x:l,y:u},{x:r,y:u}]}static findCentroid(e){if(e.length!==4)throw new Error("Invalid input: expected an array of four points");let r=0,l=0;for(const y of e)r+=y.x,l+=y.y;const p=r/4,u=l/4;return{x:p,y:u}}static rotatePoint(e,r,l){const p=e.x-l.x,u=e.y-l.y,y=p*Math.cos(-r)-u*Math.sin(-r),x=p*Math.sin(-r)+u*Math.cos(-r);return{x:y+l.x,y:x+l.y}}static calculateRotationTransforms(e){const r=[],l=e.ancestors;return l.reverse(),l.push(e),l.forEach(p=>{if(Ki(p)){const u=p;if(u.type===pt.Scene){const U={x:u.absolutePosition.x+u.size.width*.5,y:u.absolutePosition.y+u.size.height*.5};r.push({radians:u.zRotation,center:U});return}const y=nt.calculateNodeAbsoluteBoundingBox(u),x=nt.boundingBoxToPoints(y),W=nt.findCentroid(x);r.push({radians:u.zRotation,center:W})}}),r}}function ka(v,e,r){v.forEach(l=>{r.rotate(nt.radiansToDegrees(l.radians),l.center.x*e,l.center.y*e)})}function Ki(v){return nt.normalizeAngleRadians(v.zRotation)!==0&&v.isDrawable}function Oa(v,e,r){if(v.length!==4)throw new Error("Invalid input: expected an array of four points");const l=[];for(const p of v)l.push(nt.rotatePoint(p,e,r));return l}class q{constructor(e=!1){this.startOffset=-1,this.endOffset=-1,this.started=!1,this.running=!1,this.completed=!1,this.runStartTime=-1,this.duration=0,this.isParent=!1,this.isChild=!1,this.runDuringTransition=e}static move(e){return new nn(e.point,e.duration,e.easing??mt.linear,e.runDuringTransition??!1)}static wait(e){return new rn(e.duration,e.runDuringTransition??!1)}static custom(e){return new en(e.callback,e.runDuringTransition??!1)}static scale(e){return new an(e.scale,e.duration,e.runDuringTransition)}static fadeAlpha(e){return new sn(e.alpha,e.duration,e.runDuringTransition)}static rotate(e){if(e.byAngle!==void 0&&e.toAngle!==void 0)throw new Error("rotate Action: cannot specify both byAngle and toAngle");if(e.byAngle===void 0&&e.toAngle===void 0)throw new Error("rotate Action: must specify either byAngle or toAngle");if(e.toAngle===void 0&&e.shortestUnitArc!==void 0)throw new Error("rotate Action: shortestUnitArc can only be specified when toAngle is provided");return e.toAngle!==void 0&&e.shortestUnitArc===void 0&&(e.shortestUnitArc=!0),new on(e.byAngle,e.toAngle,e.shortestUnitArc,e.duration,e.runDuringTransition)}static sequence(e){const r=new Zr(e);return r.children=e,r}static group(e){const r=new tn(e);return r.children=e,r}initialize(e,r){this.assignParents(this,this,r);const l=this.flattenActions(this);return l.forEach(u=>u.duration=this.calculateDuration(u)),this.calculateStartEndOffsets(this),l.filter(u=>u.type!==dt.Group&&u.type!==dt.Sequence).map(u=>q.cloneAction(u,r))}static cloneAction(e,r){let l;switch(e.type){case dt.Sequence:{const u=e.children.map(y=>q.cloneAction(y,r));l=q.sequence(u);break}case dt.Group:{const u=e.children.map(y=>q.cloneAction(y,r));l=q.sequence(u);break}case dt.Move:{const p=e;l=q.move({point:p.point,duration:p.duration,easing:p.easing,runDuringTransition:p.runDuringTransition});break}case dt.Custom:{const p=e;l=q.custom({callback:p.callback,runDuringTransition:p.runDuringTransition});break}case dt.Scale:{const p=e;l=q.scale({scale:p.scale,duration:p.duration,runDuringTransition:p.runDuringTransition});break}case dt.FadeAlpha:{const p=e;l=q.fadeAlpha({alpha:p.alpha,duration:p.duration,runDuringTransition:p.runDuringTransition});break}case dt.Rotate:{const p=e;l=q.rotate({byAngle:p.byAngle,toAngle:p.toAngle,shortestUnitArc:p.shortestUnitArc,duration:p.duration,runDuringTransition:p.runDuringTransition});break}case dt.Wait:{const p=e;l=q.wait({duration:p.duration,runDuringTransition:p.runDuringTransition});break}default:throw new Error("unknown action")}return r!==void 0&&(l.key=r),l.startOffset=e.startOffset,l.endOffset=e.endOffset,l}static evaluateAction(e,r,l,p){if(l<e.runStartTime+e.startOffset||(l>=e.runStartTime+e.startOffset&&l<=e.runStartTime+e.startOffset+e.duration?e.running=!0:e.running=!1,e.running===!1&&e.completed===!0))return;const u=l-(e.runStartTime+e.startOffset);if(e.type===dt.Custom){const y=e;y.callback(),y.running=!1,y.completed=!0}if(e.type===dt.Wait){const y=e;l>e.runStartTime+e.startOffset+e.duration&&(y.running=!1,y.completed=!0)}if(e.type===dt.Move){const y=e;y.started||(y.dx=y.point.x-r.position.x,y.dy=y.point.y-r.position.y,y.startPoint.x=r.position.x,y.startPoint.y=r.position.y,y.started=!0),u<y.duration?(r.position.x=y.easing(u,y.startPoint.x,y.dx,y.duration),r.position.y=y.easing(u,y.startPoint.y,y.dy,y.duration)):(r.position.x=y.point.x,r.position.y=y.point.y,y.running=!1,y.completed=!0)}if(e.type===dt.Scale){const y=e;y.started||(y.delta=y.scale-r.scale,y.started=!0),u<y.duration?r.scale=r.scale+y.delta*(p/y.duration):(r.scale=y.scale,y.running=!1,y.completed=!0)}if(e.type===dt.FadeAlpha){const y=e;y.started||(y.delta=y.alpha-r.alpha,y.started=!0),u<y.duration?r.alpha=r.alpha+y.delta*(p/y.duration):(r.alpha=y.alpha,y.running=!1,y.completed=!0)}if(e.type===dt.Rotate){const y=e;y.started||(y.byAngle!==void 0&&(y.delta=y.byAngle),y.toAngle!==void 0&&(y.toAngle=nt.normalizeAngleRadians(y.toAngle),r.zRotation=nt.normalizeAngleRadians(r.zRotation),y.delta=y.toAngle-r.zRotation,y.shortestUnitArc===!0&&Math.abs(y.delta)>Math.PI&&(y.delta=2*Math.PI-Math.abs(y.delta))),y.started=!0,y.finalValue=r.zRotation+y.delta),u<y.duration?(r.zRotation=r.zRotation+y.delta*(p/y.duration),y.delta<=0&&r.zRotation<y.finalValue&&(r.zRotation=y.finalValue),y.delta>0&&r.zRotation>y.finalValue&&(r.zRotation=y.finalValue)):(r.zRotation=y.finalValue,y.running=!1,y.completed=!0)}}calculateDuration(e){return e.type===dt.Group?e.children.map(p=>this.calculateDuration(p)).reduce((p,u)=>Math.max(p,u),0):e.type===dt.Sequence?e.children.map(p=>this.calculateDuration(p)).reduce((p,u)=>p+u,0):e.duration}calculateStartEndOffsets(e){let r;if(e.parent===void 0?r=0:r=e.parent.startOffset,e.parent?.type===dt.Group)e.startOffset=r,e.endOffset=e.startOffset+e.duration;else if(e.parent?.type===dt.Sequence){const l=e.parent;let p=0;for(const u of l.children){if(u===e)break;p=p+u.duration}e.startOffset=r+p,e.endOffset=e.startOffset+e.duration}else e.startOffset=0,e.endOffset=e.startOffset+e.duration;e.isParent&&e.children?.forEach(l=>this.calculateStartEndOffsets(l))}flattenActions(e,r){if(r||(r=new Array,r.push(e)),e.isParent){const l=e,p=l.children;r.push(...p),l.children.filter(u=>u.isParent).forEach(u=>this.flattenActions(u,r))}return r}assignParents(e,r,l){if(l!==void 0&&(e.key=l),e.isParent){const p=e;p.children.forEach(y=>{y.parent=e,y.isChild=!0}),p.children.filter(y=>y.isParent).forEach(y=>this.assignParents(y,r,l))}}}class Zr extends q{constructor(e){super(),this.type=dt.Sequence,this.children=e,this.isParent=!0}}class tn extends q{constructor(e){super(),this.type=dt.Group,this.children=new Array,this.children=e,this.isParent=!0}}class en extends q{constructor(e,r=!1){super(r),this.type=dt.Custom,this.callback=e,this.isParent=!1,this.duration=0}}class rn extends q{constructor(e,r){super(r),this.type=dt.Wait,this.duration=e,this.isParent=!1}}class nn extends q{constructor(e,r,l,p){super(p),this.type=dt.Move,this.dx=0,this.dy=0,this.duration=r,this.point=e,this.isParent=!1,this.startPoint={x:NaN,y:NaN},this.easing=l}}class an extends q{constructor(e,r,l=!1){super(l),this.type=dt.Scale,this.delta=0,this.duration=r,this.scale=e,this.isParent=!1}}class sn extends q{constructor(e,r,l=!1){super(l),this.type=dt.FadeAlpha,this.delta=0,this.duration=r,this.alpha=e,this.isParent=!1}}class on extends q{constructor(e,r,l,p,u=!1){super(u),this.type=dt.Rotate,this.delta=0,this.finalValue=NaN,this.duration=p,this.byAngle=e,this.toAngle=r,this.shortestUnitArc=l,this.isParent=!1}}var Ye=(v=>(v.Game="Game",v.Survey="Survey",v))(Ye||{});class Et{static Dispose(e){e.filter(r=>!r?.isDeleted()).forEach(r=>r?.delete())}static makePaint(e,r,l,p){const u=new e.Paint;return u.setColor(e.Color(r[0],r[1],r[2],r[3])),u.setStyle(l),u.setAntiAlias(p),u}}class Ai{constructor(){this._subpaths=new Array,this.currentPath=new Array}get subpaths(){return this.currentPath.length>0?[...this._subpaths,this.currentPath]:this._subpaths}move(e){this.currentPath.length>0&&this._subpaths.push(this.currentPath),this.currentPath=new Array,this.currentPath.push(e)}addLine(e){this.currentPath.push(e)}clear(){this._subpaths=new Array,this.currentPath=new Array}duplicate(){const e=new Ai;return e._subpaths=JSON.parse(JSON.stringify(this._subpaths)),e.currentPath=JSON.parse(JSON.stringify(this.currentPath)),e}}class F{}F.Transparent=[0,0,0,0],F.MediumVioletRed=[199,21,133,1],F.DeepPink=[255,20,147,1],F.PaleVioletRed=[219,112,147,1],F.HotPink=[255,105,180,1],F.LightPink=[255,182,193,1],F.Pink=[255,192,203,1],F.DarkRed=[139,0,0,1],F.Red=[255,0,0,1],F.Firebrick=[178,34,34,1],F.Crimson=[220,20,60,1],F.IndianRed=[205,92,92,1],F.LightCoral=[240,128,128,1],F.Salmon=[250,128,114,1],F.DarkSalmon=[233,150,122,1],F.LightSalmon=[255,160,122,1],F.OrangeRed=[255,69,0,1],F.Tomato=[255,99,71,1],F.DarkOrange=[255,140,0,1],F.Coral=[255,127,80,1],F.Orange=[255,165,0,1],F.DarkKhaki=[189,183,107,1],F.Gold=[255,215,0,1],F.Khaki=[240,230,140,1],F.PeachPuff=[255,218,185,1],F.Yellow=[255,255,0,1],F.PaleGoldenrod=[238,232,170,1],F.Moccasin=[255,228,181,1],F.PapayaWhip=[255,239,213,1],F.LightGoldenrodYellow=[250,250,210,1],F.LemonChiffon=[255,250,205,1],F.LightYellow=[255,255,224,1],F.Maroon=[128,0,0,1],F.Brown=[165,42,42,1],F.SaddleBrown=[139,69,19,1],F.Sienna=[160,82,45,1],F.Chocolate=[210,105,30,1],F.DarkGoldenrod=[184,134,11,1],F.Peru=[205,133,63,1],F.RosyBrown=[188,143,143,1],F.Goldenrod=[218,165,32,1],F.SandyBrown=[244,164,96,1],F.Tan=[210,180,140,1],F.Burlywood=[222,184,135,1],F.Wheat=[245,222,179,1],F.NavajoWhite=[255,222,173,1],F.Bisque=[255,228,196,1],F.BlanchedAlmond=[255,235,205,1],F.Cornsilk=[255,248,220,1],F.DarkGreen=[0,100,0,1],F.Green=[0,128,0,1],F.DarkOliveGreen=[85,107,47,1],F.ForestGreen=[34,139,34,1],F.SeaGreen=[46,139,87,1],F.Olive=[128,128,0,1],F.OliveDrab=[107,142,35,1],F.MediumSeaGreen=[60,179,113,1],F.LimeGreen=[50,205,50,1],F.Lime=[0,255,0,1],F.SpringGreen=[0,255,127,1],F.MediumSpringGreen=[0,250,154,1],F.DarkSeaGreen=[143,188,143,1],F.MediumAquamarine=[102,205,170,1],F.YellowGreen=[154,205,50,1],F.LawnGreen=[124,252,0,1],F.Chartreuse=[127,255,0,1],F.LightGreen=[144,238,144,1],F.GreenYellow=[173,255,47,1],F.PaleGreen=[152,251,152,1],F.Teal=[0,128,128,1],F.DarkCyan=[0,139,139,1],F.LightSeaGreen=[32,178,170,1],F.CadetBlue=[95,158,160,1],F.DarkTurquoise=[0,206,209,1],F.MediumTurquoise=[72,209,204,1],F.Turquoise=[64,224,208,1],F.Aqua=[0,255,255,1],F.Cyan=[0,255,255,1],F.Aquamarine=[127,255,212,1],F.PaleTurquoise=[175,238,238,1],F.LightCyan=[224,255,255,1],F.Navy=[0,0,128,1],F.DarkBlue=[0,0,139,1],F.MediumBlue=[0,0,205,1],F.Blue=[0,0,255,1],F.MidnightBlue=[25,25,112,1],F.RoyalBlue=[65,105,225,1],F.SteelBlue=[70,130,180,1],F.DodgerBlue=[30,144,255,1],F.DeepSkyBlue=[0,191,255,1],F.CornflowerBlue=[100,149,237,1],F.SkyBlue=[135,206,235,1],F.LightSkyBlue=[135,206,250,1],F.LightSteelBlue=[176,196,222,1],F.LightBlue=[173,216,230,1],F.PowderBlue=[176,224,230,1],F.Indigo=[75,0,130,1],F.Purple=[128,0,128,1],F.DarkMagenta=[139,0,139,1],F.DarkViolet=[148,0,211,1],F.DarkSlateBlue=[72,61,139,1],F.BlueViolet=[138,43,226,1],F.DarkOrchid=[153,50,204,1],F.Fuchsia=[255,0,255,1],F.Magenta=[255,0,255,1],F.SlateBlue=[106,90,205,1],F.MediumSlateBlue=[123,104,238,1],F.MediumOrchid=[186,85,211,1],F.MediumPurple=[147,112,219,1],F.Orchid=[218,112,214,1],F.Violet=[238,130,238,1],F.Plum=[221,160,221,1],F.Thistle=[216,191,216,1],F.Lavender=[230,230,250,1],F.MistyRose=[255,228,225,1],F.AntiqueWhite=[250,235,215,1],F.Linen=[250,240,230,1],F.Beige=[245,245,220,1],F.WhiteSmoke=[245,245,245,1],F.LavenderBlush=[255,240,245,1],F.OldLace=[253,245,230,1],F.AliceBlue=[240,248,255,1],F.Seashell=[255,245,238,1],F.GhostWhite=[248,248,255,1],F.Honeydew=[240,255,240,1],F.FloralWhite=[255,250,240,1],F.Azure=[240,255,255,1],F.MintCream=[245,255,250,1],F.Snow=[255,250,250,1],F.Ivory=[255,255,240,1],F.White=[255,255,255,1],F.Black=[0,0,0,1],F.DarkSlateGray=[47,79,79,1],F.DimGray=[105,105,105,1],F.SlateGray=[112,128,144,1],F.Gray=[128,128,128,1],F.LightSlateGray=[119,136,153,1],F.DarkGray=[169,169,169,1],F.Silver=[192,192,192,1],F.LightGray=[211,211,211,1],F.Gainsboro=[220,220,220,1],F.RebeccaPurple=[102,51,153,1];class V{}V.FPS_DISPLAY_TEXT_FONT_SIZE=12,V.FPS_DISPLAY_TEXT_COLOR=[0,0,0,.5],V.FPS_DISPLAY_UPDATE_INTERVAL=1e3,V.MAXIMUM_RECORDED_ACTIVITY_METRICS=32,V.FPS_METRIC_REPORT_THRESHOLD=59,V.DEFAULT_SCENE_BACKGROUND_COLOR=F.White,V.DEFAULT_SHAPE_FILL_COLOR=F.Red,V.DEFAULT_PATH_STROKE_COLOR=F.Red,V.DEFAULT_PATH_LINE_WIDTH=2,V.DEFAULT_FONT_COLOR=F.Black,V.DEFAULT_FONT_SIZE=16,V.LIMITED_FPS_RATE=5,V.FREE_NODES_SCENE_NAME="__freeNodesScene",V.OUTGOING_SCENE_NAME="__outgoingScene",V.OUTGOING_SCENE_SPRITE_NAME="__outgoingSceneSprite",V.OUTGOING_SCENE_IMAGE_NAME="__outgoingSceneSnapshot",V.SESSION_INITIALIZATION_POLLING_INTERVAL_MS=50,V.MODULE_METADATA_PLACEHOLDER={name:"",version:"",dependencies:{}},V.DEFAULT_ROOT_ELEMENT_ID="m2c2kit";class La extends Ai{constructor(){super(...arguments),this.strokeColor=V.DEFAULT_PATH_STROKE_COLOR,this.lineWidth=V.DEFAULT_PATH_LINE_WIDTH,this.linePresentations=[]}addLine(e){this.isNewLinePresentation()&&this.linePresentations.push({strokeColor:this.strokeColor,lineWidth:this.lineWidth,subpathIndex:this._subpaths.length,pointIndex:this.currentPath.length-1}),this.currentPath.push(e)}isNewLinePresentation(){if(this.linePresentations.length===0)return!0;const e=this.linePresentations[this.linePresentations.length-1];return e.strokeColor!==this.strokeColor||e.lineWidth!==this.lineWidth}clear(){super.clear(),this.linePresentations=[],this.strokeColor=V.DEFAULT_PATH_STROKE_COLOR,this.lineWidth=V.DEFAULT_PATH_LINE_WIDTH}duplicate(){const e=super.duplicate();return e.strokeColor=JSON.parse(JSON.stringify(this.strokeColor)),e.lineWidth=this.lineWidth,e.linePresentations=JSON.parse(JSON.stringify(this.linePresentations)),e}}class ln{constructor(){this.now=NaN,this.deltaTime=NaN,this.canvasScale=NaN,this.rootScale=1,this.canvasCssWidth=NaN,this.canvasCssHeight=NaN}}window.globalThis||(console.log("shimming globalThis"),window.globalThis=window),globalThis.Globals=new ln;var Lt=(v=>(v.topToTopOf="topToTopOf",v.topToBottomOf="topToBottomOf",v.bottomToTopOf="bottomToTopOf",v.bottomToBottomOf="bottomToBottomOf",v.startToStartOf="startToStartOf",v.startToEndOf="startToEndOf",v.endToEndOf="endToEndOf",v.endToStartOf="endToStartOf",v))(Lt||{});class hn{constructor(e,r){this.verticalConstraint=!1,this.focalNodeMinimum=!1,this.alterNodeMinimum=!1,this.verticalTypes=[Lt.topToTopOf,Lt.topToBottomOf,Lt.bottomToTopOf,Lt.bottomToBottomOf],this.focalNodeMinimumTypes=[Lt.topToTopOf,Lt.topToBottomOf,Lt.startToStartOf,Lt.startToEndOf],this.alterNodeMinimumTypes=[Lt.topToTopOf,Lt.bottomToTopOf,Lt.startToStartOf,Lt.endToStartOf],this.type=e,this.alterNode=r,this.verticalTypes.includes(e)?(this.verticalConstraint=!0,this.focalNodeMinimumTypes.includes(e)?this.focalNodeMinimum=!0:this.focalNodeMinimum=!1,this.alterNodeMinimumTypes.includes(e)?this.alterNodeMinimum=!0:this.alterNodeMinimum=!1):(this.verticalConstraint=!1,this.focalNodeMinimumTypes.includes(e)?this.focalNodeMinimum=!0:this.focalNodeMinimum=!1,this.alterNodeMinimumTypes.includes(e)?this.alterNodeMinimum=!0:this.alterNodeMinimum=!1)}}class yi{static generate(){try{return crypto.randomUUID()}catch{let e;try{e=()=>crypto.getRandomValues(new Uint8Array(1))[0]}catch{e=()=>Math.floor(Math.random()*256)}return("10000000-1000-4000-8000"+-1e11).replace(/[018]/g,r=>(Number(r)^e()&15>>Number(r)/4).toString(16))}}}const X={ActivityStart:"ActivityStart",ActivityEnd:"ActivityEnd",ActivityCancel:"ActivityCancel",ActivityData:"ActivityData",GameWarmupStart:"GameWarmupStart",GameWarmupEnd:"GameWarmupEnd",TapDown:"TapDown",TapUp:"TapUp",TapUpAny:"TapUpAny",TapLeave:"TapLeave",PointerDown:"PointerDown",PointerUp:"PointerUp",PointerMove:"PointerMove",PointerLeave:"PointerLeave",Drag:"Drag",DragStart:"DragStart",DragEnd:"DragEnd",CompositeCustom:"CompositeCustom",FrameDidSimulatePhysics:"FrameDidSimulatePhysics",SceneSetup:"SceneSetup",SceneAppear:"SceneAppear"};function Ia(v,e){e.anchorPoint&&(v.anchorPoint=e.anchorPoint),e.zPosition!==void 0&&(v.zPosition=e.zPosition)}function Na(v,e){e.text!==void 0&&(v.text=e.text),e.fontName!==void 0&&(v.fontName=e.fontName),e.fontColor&&(v.fontColor=e.fontColor),e.fontSize!==void 0&&(v.fontSize=e.fontSize)}function ye(v,e){v.isDrawable&&Ia(v,e),v.isText&&Na(v,e)}class we{constructor(e={}){this.type=pt.Node,this.isDrawable=!1,this.isShape=!1,this.isText=!1,this._position={x:0,y:0},this._scale=1,this.alpha=1,this._zRotation=0,this.isUserInteractionEnabled=!1,this.draggable=!1,this.hidden=!1,this.layout={},this.children=new Array,this.absolutePosition={x:0,y:0},this.size={width:0,height:0},this.absoluteScale=1,this.absoluteAlpha=1,this.absoluteAlphaChange=0,this.actions=new Array,this.originalActions=new Array,this.eventListeners=new Array,this.uuid=yi.generate(),this.needsInitialization=!0,this.userData={},this.loopMessages=new Set,this.pressed=!1,this.withinHitArea=!1,this.pressedAndWithinHitArea=!1,this.pressedInitialPointerOffset={x:NaN,y:NaN},this.draggingLastPointerOffset={x:NaN,y:NaN},this.dragging=!1,this.toString=()=>{let r=this.type.toString();return this.type==pt.Composite&&(r=this.compositeType),this.name!==this.uuid?`${this.name} (${r}, ${this.uuid})`:`${r} (${this.uuid})`},e.name===void 0?this.name=this.uuid:this.name=e.name,e.position!==void 0&&(this.position=e.position),e.scale!==void 0&&(this.scale=e.scale),e.alpha!==void 0&&(this.alpha=e.alpha),e.zRotation!==void 0&&(this.zRotation=e.zRotation),e.isUserInteractionEnabled!==void 0&&(this.isUserInteractionEnabled=e.isUserInteractionEnabled),e.draggable!==void 0&&(this.draggable=e.draggable),e.hidden!==void 0&&(this.hidden=e.hidden),e.layout!==void 0&&(this.layout=e.layout)}initialize(){throw new Error("initialize() called in abstract base class Node.")}get game(){const e=r=>{if(r.parent)return r.parent.type===pt.Scene?r.parent:e(r.parent);throw new Error(`Node ${this} has not been added to a scene.`)};return e(this).game}isPartOfGame(){if(this.type===pt.Scene&&this._game===void 0)return!1;if(this.type===pt.Scene&&this._game!==void 0)return!0;const e=r=>{if(r.parent)return r.parent.type===pt.Scene?r.parent:e(r.parent)};return e(this)?._game!==void 0}addChild(e){if(e===this)throw new Error(`Cannot add node ${e.toString()} as a child to itself.`);if(e.type==pt.Scene)throw new Error(`Cannot add scene ${e.toString()} as a child to node ${this.toString()}. A scene cannot be the child of a node. A scene can only be added to a game object.`);if(this.children.filter(p=>p!==e).map(p=>p.name).includes(e.name))throw new Error(`Cannot add child node ${e.toString()} to parent node ${this.toString()}. A child with name "${e.name}" already exists on this parent.`);let r=new Array;if(this.isPartOfGame())r=this.game.nodes.filter(p=>p.children.includes(e));else{const p=this.descendants;p.includes(e)&&(r=p.filter(u=>u.children.includes(e)).map(u=>u.parent??void 0))}if(r.length===0){e.parent=this,this.children.push(e);return}const l=r.find(Boolean);throw l===this?new Error(`Cannot add child node ${e.toString()} to parent node ${this.toString()}. This child already exists on this parent. The child cannot be added again.`):new Error(`Cannot add child node ${e.toString()} to parent node ${this.toString()}. This child already exists on other parent node: ${l?.toString()}}. Remove the child from the other parent first.`)}removeAllChildren(){for(;this.children.length;){const e=this.children.pop();e&&(e.parent=void 0)}}removeChild(e){if(this.children.includes(e))e.parent=void 0,this.children=this.children.filter(r=>r!==e);else throw new Error(`cannot remove node ${e} from parent ${this} because the node is not currently a child of the parent`)}removeChildren(e){e.forEach(r=>{if(!this.children.includes(r))throw new Error(`cannot remove node ${r} from parent ${this} because the node is not currently a child of the parent`);r.parent=void 0}),this.children=this.children.filter(r=>!e.includes(r))}descendant(e){const r=this.descendants.filter(l=>l.name===e).find(Boolean);if(r===void 0)throw new Error(`descendant with name ${e} not found on parent ${this.toString()}`);return r}get descendants(){function e(l,p){p.push(l),l.children.forEach(u=>e(u,p))}const r=new Array;return this.children.forEach(l=>e(l,r)),r}get ancestors(){function e(l,p){return l.type==pt.Scene||!l.parent?p:(p.push(l.parent),e(l.parent,p))}const r=new Array;return e(this,r)}involvedInActionAffectingAppearance(){return this.ancestors.concat(this).flatMap(l=>l.actions).some(l=>l.running&&(l.type===dt.Move||l.type===dt.Scale))}involvedInSceneTransition(){let e;return this.type===pt.Scene?e=this:e=this.parentSceneAsNode,e._transitioning}onTapDown(e,r){this.addEventListener(X.TapDown,e,r)}onTapUp(e,r){this.addEventListener(X.TapUp,e,r)}onTapUpAny(e,r){this.addEventListener(X.TapUpAny,e,r)}onTapLeave(e,r){this.addEventListener(X.TapLeave,e,r)}onPointerDown(e,r){this.addEventListener(X.PointerDown,e,r)}onPointerUp(e,r){this.addEventListener(X.PointerUp,e,r)}onPointerMove(e,r){this.addEventListener(X.PointerMove,e,r)}onPointerLeave(e,r){this.addEventListener(X.PointerLeave,e,r)}onDragStart(e,r){this.addEventListener(X.DragStart,e,r)}onDrag(e,r){this.addEventListener(X.Drag,e,r)}onDragEnd(e,r){this.addEventListener(X.DragEnd,e,r)}addEventListener(e,r,l){const p={type:e,nodeUuid:this.uuid,callback:r};l?.replaceExisting&&(this.eventListeners=this.eventListeners.filter(u=>!(u.nodeUuid===p.nodeUuid&&u.type===p.type))),this.eventListeners.push(p)}parseLayoutConstraints(e,r){const l=new Array;return Object.values(Lt).forEach(u=>{if(e[u]!==void 0){let y,x="";if(typeof e[u]=="object")y=e[u];else{const U=e[u];y=r.filter(Q=>Q.name===U).find(Boolean),x=`. sibling node named "${U}" has not been added to the game object`}if(y===void 0)throw new Error("could not find sibling node for constraint"+x);const W=new hn(u,y);l.push(W)}}),l}calculateYFromConstraint(e,r,l,p){let u=e.alterNode.absolutePosition.y;return e.alterNodeMinimum?e.alterNode.type!==pt.Scene&&(u=u-e.alterNode.size.height*.5*p):e.alterNode.type!==pt.Scene?u=u+e.alterNode.size.height*.5*p:u=u+e.alterNode.size.height*p,e.focalNodeMinimum?(u=u+this.size.height*.5*p,u=u+r*p):(u=u-this.size.height*.5*p,u=u-l*p),u}calculateXFromConstraint(e,r,l,p){let u=e.alterNode.absolutePosition.x;return e.alterNodeMinimum?e.alterNode.type!==pt.Scene&&(u=u-e.alterNode.size.width*.5*p):e.alterNode.type!==pt.Scene?u=u+e.alterNode.size.width*.5*p:u=u+e.alterNode.size.width*p,e.focalNodeMinimum?(u=u+this.size.width*.5*p,u=u+r*p):(u=u-this.size.width*.5*p,u=u-l*p),u}calculateAbsoluteAlpha(e,r){const l=r.reduce((p,u)=>p*u.alpha,1);return e*l}update(){if(this.needsInitialization&&this.initialize(),this.absoluteAlphaChange=this.calculateAbsoluteAlpha(this.alpha,this.ancestors)-this.absoluteAlpha,this.absoluteAlpha+=this.absoluteAlphaChange,this.parent===void 0)this.absolutePosition.x=this.position.x*this.scale,this.absolutePosition.y=this.position.y*this.scale,this.absoluteScale=this.scale;else if(this.absoluteScale=this.parent.absoluteScale*this.scale,this.layout?.constraints===void 0)this.absolutePosition.x=this.parent.absolutePosition.x+this.position.x*this.parent.absoluteScale,this.absolutePosition.y=this.parent.absolutePosition.y+this.position.y*this.parent.absoluteScale;else{const y=this.layout?.constraints?.horizontalBias??.5,x=this.layout?.constraints?.verticalBias??.5,W=this.layout?.marginTop??0,U=this.layout?.marginBottom??0,Q=this.layout?.marginStart??0,ot=this.layout?.marginEnd??0,vt=this.parseLayoutConstraints(this.layout?.constraints,this.parentSceneAsNode.descendants),It=this.parent.absoluteScale,ct=vt.filter(Nt=>Nt.verticalConstraint).map(Nt=>this.calculateYFromConstraint(Nt,W,U,It));ct.length===0||(ct.length===1?this.absolutePosition.y=ct[0]:ct.length===2&&(this.absolutePosition.y=Math.min(ct[0],ct[1])+x*Math.abs(ct[0]-ct[1])));const Pt=vt.filter(Nt=>!Nt.verticalConstraint).map(Nt=>this.calculateXFromConstraint(Nt,Q,ot,It));Pt.length===0||(Pt.length===1?this.absolutePosition.x=Pt[0]:Pt.length===2&&(this.absolutePosition.x=Math.min(Pt[0],Pt[1])+y*Math.abs(Pt[0]-Pt[1])))}const e=this.actions.filter(y=>y.runDuringTransition&&!y.completed),r=this.actions.filter(y=>!y.runDuringTransition&&!y.completed);e.length>0&&(e.forEach(y=>{y.runStartTime===-1&&(y.runStartTime=Globals.now)}),e.forEach(y=>q.evaluateAction(y,this,Globals.now,Globals.deltaTime))),!this.involvedInSceneTransition()&&r.length>0&&(r.forEach(y=>{y.runStartTime===-1&&(y.runStartTime=Globals.now)}),r.forEach(y=>q.evaluateAction(y,this,Globals.now,Globals.deltaTime)));function l(y,x){const W=new Array;return x===void 0||Object.values(Lt).forEach(Q=>{if(x[Q]!==void 0){let ot,vt="";if(typeof x[Q]=="object")ot=x[Q];else{const It=x[Q];let ct;y.type===pt.Scene?ct=y.descendants:ct=y.parentSceneAsNode.descendants,ot=ct.filter(Pt=>Pt.name===It).find(Boolean),ot===void 0&&(vt=`. sibling node named "${It}" has not been added to the game object`)}if(ot===void 0)throw new Error("error getting uuid of sibling constraint"+vt);ot!==y&&W.push(ot.uuid)}}),W}const p=new Map;this.children.forEach(y=>{p.set(y.uuid,l(this,y.layout?.constraints))});const u=this.findTopologicalSort(p);if(u.length>0){const y=u.reverse(),x=new Array;y.forEach(W=>{const U=this.children.filter(Q=>Q.uuid===W).find(Boolean);if(U===void 0)throw new Error("error in dag topological sort");x.push(U)}),x.forEach(W=>W.update())}else this.children.forEach(y=>y.update())}drawChildren(e){this.children.filter(r=>!r.hidden&&r.isDrawable).map(r=>r).sort((r,l)=>r.zPosition-l.zPosition).forEach(r=>r.draw(e))}run(e,r){this.actions.push(...e.initialize(this,r)),this.originalActions=this.actions.filter(l=>l.runDuringTransition===!1).map(l=>q.cloneAction(l,r))}removeAction(e){this.actions=this.actions.filter(r=>r.key!==e)}removeAllActions(){for(;this.actions.length;)this.actions.pop()}getNodeOptions(){return{name:this.name,position:this.position,scale:this.scale,isUserInteractionEnabled:this.isUserInteractionEnabled,hidden:this.hidden}}getDrawableOptions(){if(!this.isDrawable)throw new Error("getDrawableOptions() called object that is not IDrawable");return{anchorPoint:this.anchorPoint,zPosition:this.zPosition}}getTextOptions(){if(!this.isText)throw new Error("getTextOptions() called object that is not IText");return{text:this.text,fontName:this.fontName,fontColor:this.fontColor,fontSize:this.fontSize}}get canvasKit(){return this.game.canvasKit}get parentSceneAsNode(){if(this.type===pt.Scene)throw new Error(`Node ${this} is a scene and cannot have a parent scene`);if(this.parent&&this.parent.type===pt.Scene)return this.parent;if(this.parent)return this.parent.parentSceneAsNode;throw new Error(`Node ${this} has not been added to a scene`)}get position(){const e=this;return{get x(){return e._position.x},set x(r){e._position.x=r},get y(){return e._position.y},set y(r){e._position.y=r}}}set position(e){this._position=e}get zRotation(){return this._zRotation}set zRotation(e){this._zRotation=e}get scale(){return this._scale}set scale(e){this._scale=e}findTopologicalSort(e){const r=[],l=new Map;e.forEach((u,y)=>{l.has(y)||l.set(y,0),u.forEach(x=>{l.has(x)?l.set(x,l.get(x)+1):l.set(x,1)})});const p=[];for(l.forEach((u,y)=>{u==0&&p.push(y)});p.length>0;){const u=p.shift();if(u===void 0)throw"bad";r.push(u),e.has(u)&&e.get(u)?.forEach(y=>{if(l.has(y)&&l.get(y)>0){const x=l.get(y)-1;l.set(y,x),x==0&&p.push(y)}})}return r}}class Da extends we{constructor(e={}){super(e),this.type=pt.Composite,this.compositeType="<compositeType>",this.isDrawable=!0,this.anchorPoint={x:.5,y:.5},this.zPosition=0,ye(this,e)}initialize(){}dispose(){}update(){super.update()}draw(e){super.drawChildren(e)}}var cn=(v=>(v[v.MatchConstraint=0]="MatchConstraint",v))(cn||{});class Ba{static rgbaColor(e,r){return!e||!r?!1:e[0]===r[0]&&e[1]===r[1]&&e[2]===r[2]&&e[3]===r[3]}}const Kt={Deferred:"Deferred",Loading:"Loading",Ready:"Ready",Error:"Error"};class un{constructor(e,r){this.fonts={},this.game=e,this.baseUrls=r,this.canvasKit=e.canvasKit,this.provider=this.canvasKit.TypefaceFontProvider.Make()}initializeFonts(e){return this.loadFonts(e??[])}async loadFonts(e){if(e.length===0)return;const r=e.map((l,p)=>{let u=l.url;nt.urlHasScheme(l.url)||(u=nt.getUrlFromManifest(this.game,`${this.baseUrls.assets}/${l.url}`));const y={fontName:l.fontName,typeface:void 0,data:l.sharedFont?.data,default:p===0,url:l.sharedFont?.url??u,status:l.lazy?Kt.Deferred:Kt.Loading};if(this.fonts[l.fontName]=y,y.status===Kt.Loading)return this.prepareFont(y)});await Promise.all(r)}async prepareFont(e){const r=e.data??await this.fetchFontAsArrayBuffer(e);this.registerFont(r,e),console.log(`\u26AA font ${e.fontName}${e.default?" (default)":""} loaded for game ${this.game.id} from ${e.url}`)}async prepareDeferredFont(e){return e.status=Kt.Loading,this.prepareFont(e)}async fetchFontAsArrayBuffer(e){const r=await fetch(e.url);if(!r.ok)throw new Error(`cannot fetch font ${e.fontName} at url ${e.url}: ${r.statusText}`);return await r.arrayBuffer()}registerFont(e,r){this.provider.registerFont(e,r.fontName);const l=this.canvasKit.Typeface.MakeFreeTypeFaceFromData(e);if(!l)throw new Error(`cannot make typeface for font ${r.fontName} at url ${r.url}`);r.typeface=l,r.status=Kt.Ready}getFont(e){return this.fonts[e]}getDefaultFont(){const e=Object.values(this.fonts).find(r=>r.default);if(!e)throw new Error("no default font found; please make sure at least one font is loaded");return e}dispose(){const e=Object.entries(this.fonts).map(([,r])=>r.typeface);Et.Dispose([...e,this.provider])}getTypeface(e){const r=this.fonts[e]?.typeface;if(!r)throw new Error(`font ${e} not found`);return r}getFontNames(){return Object.keys(this.fonts)}}var Vi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Wa(v){return v&&v.__esModule&&Object.prototype.hasOwnProperty.call(v,"default")?v.default:v}function dn(v){if(v.__esModule)return v;var e=v.default;if(typeof e=="function"){var r=function l(){return this instanceof l?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(v).forEach(function(l){var p=Object.getOwnPropertyDescriptor(v,l);Object.defineProperty(r,l,p.get?p:{enumerable:!0,get:function(){return v[l]}})}),r}var fn={exports:{}},Ga={},Ua=Object.freeze({__proto__:null,default:Ga}),$a=dn(Ua);function pn(v,e){for(var r=0,l=v.length-1;l>=0;l--){var p=v[l];p==="."?v.splice(l,1):p===".."?(v.splice(l,1),r++):r&&(v.splice(l,1),r--)}if(e)for(;r--;r)v.unshift("..");return v}var za=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,Yi=function(v){return za.exec(v).slice(1)};function wi(){for(var v="",e=!1,r=arguments.length-1;r>=-1&&!e;r--){var l=r>=0?arguments[r]:"/";if(typeof l!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!l)continue;v=l+"/"+v,e=l.charAt(0)==="/"}return v=pn(qi(v.split("/"),function(p){return!!p}),!e).join("/"),(e?"/":"")+v||"."}function Xi(v){var e=Ji(v),r=Ha(v,-1)==="/";return v=pn(qi(v.split("/"),function(l){return!!l}),!e).join("/"),!v&&!e&&(v="."),v&&r&&(v+="/"),(e?"/":"")+v}function Ji(v){return v.charAt(0)==="/"}function gn(){var v=Array.prototype.slice.call(arguments,0);return Xi(qi(v,function(e,r){if(typeof e!="string")throw new TypeError("Arguments to path.join must be strings");return e}).join("/"))}function mn(v,e){v=wi(v).substr(1),e=wi(e).substr(1);function r(U){for(var Q=0;Q<U.length&&U[Q]==="";Q++);for(var ot=U.length-1;ot>=0&&U[ot]==="";ot--);return Q>ot?[]:U.slice(Q,ot-Q+1)}for(var l=r(v.split("/")),p=r(e.split("/")),u=Math.min(l.length,p.length),y=u,x=0;x<u;x++)if(l[x]!==p[x]){y=x;break}for(var W=[],x=y;x<l.length;x++)W.push("..");return W=W.concat(p.slice(y)),W.join("/")}var vn="/",yn=":";function wn(v){var e=Yi(v),r=e[0],l=e[1];return!r&&!l?".":(l&&(l=l.substr(0,l.length-1)),r+l)}function Sn(v,e){var r=Yi(v)[2];return e&&r.substr(-1*e.length)===e&&(r=r.substr(0,r.length-e.length)),r}function An(v){return Yi(v)[3]}var ja={extname:An,basename:Sn,dirname:wn,sep:vn,delimiter:yn,relative:mn,join:gn,isAbsolute:Ji,normalize:Xi,resolve:wi};function qi(v,e){if(v.filter)return v.filter(e);for(var r=[],l=0;l<v.length;l++)e(v[l],l,v)&&r.push(v[l]);return r}var Ha="ab".substr(-1)==="b"?function(v,e,r){return v.substr(e,r)}:function(v,e,r){return e<0&&(e=v.length+e),v.substr(e,r)},Ka=Object.freeze({__proto__:null,basename:Sn,default:ja,delimiter:yn,dirname:wn,extname:An,isAbsolute:Ji,join:gn,normalize:Xi,relative:mn,resolve:wi,sep:vn}),Va=dn(Ka);(function(v,e){var r=(()=>{var l=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<"u"&&(l=l||__filename),function(p={}){var u=p,y,x;u.ready=new Promise((t,i)=>{y=t,x=i}),function(t){t.Td=t.Td||[],t.Td.push(function(){t.MakeSWCanvasSurface=function(i){var n=i,o=typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas;if(!(typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||o||(n=document.getElementById(i),n)))throw"Canvas with id "+i+" was not found";return(i=t.MakeSurface(n.width,n.height))&&(i.Ld=n),i},t.MakeCanvasSurface||(t.MakeCanvasSurface=t.MakeSWCanvasSurface),t.MakeSurface=function(i,n){var o={width:i,height:n,colorType:t.ColorType.RGBA_8888,alphaType:t.AlphaType.Unpremul,colorSpace:t.ColorSpace.SRGB},c=i*n*4,g=t._malloc(c);return(o=t.Surface._makeRasterDirect(o,g,4*i))&&(o.Ld=null,o.Hf=i,o.Df=n,o.Ff=c,o.bf=g,o.getCanvas().clear(t.TRANSPARENT)),o},t.MakeRasterDirectSurface=function(i,n,o){return t.Surface._makeRasterDirect(i,n.byteOffset,o)},t.Surface.prototype.flush=function(i){if(t.Md(this.Kd),this._flush(),this.Ld){var n=new Uint8ClampedArray(t.HEAPU8.buffer,this.bf,this.Ff);n=new ImageData(n,this.Hf,this.Df),i?this.Ld.getContext("2d").putImageData(n,0,0,i[0],i[1],i[2]-i[0],i[3]-i[1]):this.Ld.getContext("2d").putImageData(n,0,0)}},t.Surface.prototype.dispose=function(){this.bf&&t._free(this.bf),this.delete()},t.Md=t.Md||function(){},t.Te=t.Te||function(){return null}})}(u),function(t){t.Td=t.Td||[],t.Td.push(function(){function i(m,w,C){return m&&m.hasOwnProperty(w)?m[w]:C}function n(m){var w=_e(zt);return zt[w]=m,w}function o(m){return m.naturalHeight||m.videoHeight||m.displayHeight||m.height}function c(m){return m.naturalWidth||m.videoWidth||m.displayWidth||m.width}function g(m,w,C,L){return m.bindTexture(m.TEXTURE_2D,w),L||C.alphaType!==t.AlphaType.Premul||m.pixelStorei(m.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),w}function b(m,w,C){C||w.alphaType!==t.AlphaType.Premul||m.pixelStorei(m.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),m.bindTexture(m.TEXTURE_2D,null)}t.GetWebGLContext=function(m,w){if(!m)throw"null canvas passed into makeWebGLContext";var C={alpha:i(w,"alpha",1),depth:i(w,"depth",1),stencil:i(w,"stencil",8),antialias:i(w,"antialias",0),premultipliedAlpha:i(w,"premultipliedAlpha",1),preserveDrawingBuffer:i(w,"preserveDrawingBuffer",0),preferLowPowerToHighPerformance:i(w,"preferLowPowerToHighPerformance",0),failIfMajorPerformanceCaveat:i(w,"failIfMajorPerformanceCaveat",0),enableExtensionsByDefault:i(w,"enableExtensionsByDefault",1),explicitSwapControl:i(w,"explicitSwapControl",0),renderViaOffscreenBackBuffer:i(w,"renderViaOffscreenBackBuffer",0)};if(C.majorVersion=w&&w.majorVersion?w.majorVersion:typeof WebGL2RenderingContext<"u"?2:1,C.explicitSwapControl)throw"explicitSwapControl is not supported";return m=sa(m,C),m?(Lr(m),Z.fe.getExtension("WEBGL_debug_renderer_info"),m):0},t.deleteContext=function(m){Z===re[m]&&(Z=null),typeof JSEvents=="object"&&JSEvents.ug(re[m].fe.canvas),re[m]&&re[m].fe.canvas&&(re[m].fe.canvas.zf=void 0),re[m]=null},t._setTextureCleanup({deleteTexture:function(m,w){var C=zt[w];C&&re[m].fe.deleteTexture(C),zt[w]=null}}),t.MakeWebGLContext=function(m){if(!this.Md(m))return null;var w=this._MakeGrContext();if(!w)return null;w.Kd=m;var C=w.delete.bind(w);return w.delete=function(){t.Md(this.Kd),C()}.bind(w),Z.ff=w},t.MakeGrContext=t.MakeWebGLContext,t.GrDirectContext.prototype.getResourceCacheLimitBytes=function(){t.Md(this.Kd),this._getResourceCacheLimitBytes()},t.GrDirectContext.prototype.getResourceCacheUsageBytes=function(){t.Md(this.Kd),this._getResourceCacheUsageBytes()},t.GrDirectContext.prototype.releaseResourcesAndAbandonContext=function(){t.Md(this.Kd),this._releaseResourcesAndAbandonContext()},t.GrDirectContext.prototype.setResourceCacheLimitBytes=function(m){t.Md(this.Kd),this._setResourceCacheLimitBytes(m)},t.MakeOnScreenGLSurface=function(m,w,C,L,D,z){return!this.Md(m.Kd)||(w=D===void 0||z===void 0?this._MakeOnScreenGLSurface(m,w,C,L):this._MakeOnScreenGLSurface(m,w,C,L,D,z),!w)?null:(w.Kd=m.Kd,w)},t.MakeRenderTarget=function(){var m=arguments[0];if(!this.Md(m.Kd))return null;if(arguments.length===3){var w=this._MakeRenderTargetWH(m,arguments[1],arguments[2]);if(!w)return null}else if(arguments.length===2){if(w=this._MakeRenderTargetII(m,arguments[1]),!w)return null}else return null;return w.Kd=m.Kd,w},t.MakeWebGLCanvasSurface=function(m,w,C){w=w||null;var L=m,D=typeof OffscreenCanvas<"u"&&L instanceof OffscreenCanvas;if(!(typeof HTMLCanvasElement<"u"&&L instanceof HTMLCanvasElement||D||(L=document.getElementById(m),L)))throw"Canvas with id "+m+" was not found";if(m=this.GetWebGLContext(L,C),!m||0>m)throw"failed to create webgl context: err "+m;return m=this.MakeWebGLContext(m),w=this.MakeOnScreenGLSurface(m,L.width,L.height,w),w||(w=L.cloneNode(!0),L.parentNode.replaceChild(w,L),w.classList.add("ck-replaced"),t.MakeSWCanvasSurface(w))},t.MakeCanvasSurface=t.MakeWebGLCanvasSurface,t.Surface.prototype.makeImageFromTexture=function(m,w){return t.Md(this.Kd),m=n(m),(w=this._makeImageFromTexture(this.Kd,m,w))&&(w.Le=m),w},t.Surface.prototype.makeImageFromTextureSource=function(m,w,C){w||(w={height:o(m),width:c(m),colorType:t.ColorType.RGBA_8888,alphaType:C?t.AlphaType.Premul:t.AlphaType.Unpremul}),w.colorSpace||(w.colorSpace=t.ColorSpace.SRGB),t.Md(this.Kd);var L=Z.fe;return C=g(L,L.createTexture(),w,C),Z.version===2?L.texImage2D(L.TEXTURE_2D,0,L.RGBA,w.width,w.height,0,L.RGBA,L.UNSIGNED_BYTE,m):L.texImage2D(L.TEXTURE_2D,0,L.RGBA,L.RGBA,L.UNSIGNED_BYTE,m),b(L,w),this._resetContext(),this.makeImageFromTexture(C,w)},t.Surface.prototype.updateTextureFromSource=function(m,w,C){if(m.Le){t.Md(this.Kd);var L=m.getImageInfo(),D=Z.fe,z=g(D,zt[m.Le],L,C);Z.version===2?D.texImage2D(D.TEXTURE_2D,0,D.RGBA,c(w),o(w),0,D.RGBA,D.UNSIGNED_BYTE,w):D.texImage2D(D.TEXTURE_2D,0,D.RGBA,D.RGBA,D.UNSIGNED_BYTE,w),b(D,L,C),this._resetContext(),zt[m.Le]=null,m.Le=n(z),L.colorSpace=m.getColorSpace(),w=this._makeImageFromTexture(this.Kd,m.Le,L),C=m.Jd.Rd,D=m.Jd.Yd,m.Jd.Rd=w.Jd.Rd,m.Jd.Yd=w.Jd.Yd,w.Jd.Rd=C,w.Jd.Yd=D,w.delete(),L.colorSpace.delete()}},t.MakeLazyImageFromTextureSource=function(m,w,C){w||(w={height:o(m),width:c(m),colorType:t.ColorType.RGBA_8888,alphaType:C?t.AlphaType.Premul:t.AlphaType.Unpremul}),w.colorSpace||(w.colorSpace=t.ColorSpace.SRGB);var L={makeTexture:function(){var D=Z,z=D.fe,E=g(z,z.createTexture(),w,C);return D.version===2?z.texImage2D(z.TEXTURE_2D,0,z.RGBA,w.width,w.height,0,z.RGBA,z.UNSIGNED_BYTE,m):z.texImage2D(z.TEXTURE_2D,0,z.RGBA,z.RGBA,z.UNSIGNED_BYTE,m),b(z,w,C),n(E)},freeSrc:function(){}};return m.constructor.name==="VideoFrame"&&(L.freeSrc=function(){m.close()}),t.Image._makeFromGenerator(w,L)},t.Md=function(m){return m?Lr(m):!1},t.Te=function(){return Z&&Z.ff&&!Z.ff.isDeleted()?Z.ff:null}})}(u),function(t){function i(s,a,h,f,P){for(var T=0;T<s.length;T++)a[T*h+(T*P+f+h)%h]=s[T];return a}function n(s){for(var a=s*s,h=Array(a);a--;)h[a]=a%(s+1)===0?1:0;return h}function o(s){return s?s.constructor===Float32Array&&s.length===4:!1}function c(s){return(m(255*s[3])<<24|m(255*s[0])<<16|m(255*s[1])<<8|m(255*s[2])<<0)>>>0}function g(s){if(s&&s._ck)return s;if(s instanceof Float32Array){for(var a=Math.floor(s.length/4),h=new Uint32Array(a),f=0;f<a;f++)h[f]=c(s.slice(4*f,4*(f+1)));return h}if(s instanceof Uint32Array)return s;if(s instanceof Array&&s[0]instanceof Float32Array)return s.map(c)}function b(s){if(s===void 0)return 1;var a=parseFloat(s);return s&&s.indexOf("%")!==-1?a/100:a}function m(s){return Math.round(Math.max(0,Math.min(s||0,255)))}function w(s,a){a&&a._ck||t._free(s)}function C(s,a,h){if(!s||!s.length)return st;if(s&&s._ck)return s.byteOffset;var f=t[a].BYTES_PER_ELEMENT;return h||(h=t._malloc(s.length*f)),t[a].set(s,h/f),h}function L(s){var a={be:st,count:s.length,colorType:t.ColorType.RGBA_F32};if(s instanceof Float32Array)a.be=C(s,"HEAPF32"),a.count=s.length/4;else if(s instanceof Uint32Array)a.be=C(s,"HEAPU32"),a.colorType=t.ColorType.RGBA_8888;else if(s instanceof Array){if(s&&s.length){for(var h=t._malloc(16*s.length),f=0,P=h/4,T=0;T<s.length;T++)for(var k=0;4>k;k++)t.HEAPF32[P+f]=s[T][k],f++;s=h}else s=st;a.be=s}else throw"Invalid argument to copyFlexibleColorArray, Not a color array "+typeof s;return a}function D(s){if(!s)return st;var a=Gi.toTypedArray();if(s.length){if(s.length===6||s.length===9)return C(s,"HEAPF32",ce),s.length===6&&t.HEAPF32.set(xa,6+ce/4),ce;if(s.length===16)return a[0]=s[0],a[1]=s[1],a[2]=s[3],a[3]=s[4],a[4]=s[5],a[5]=s[7],a[6]=s[12],a[7]=s[13],a[8]=s[15],ce;throw"invalid matrix size"}if(s.m11===void 0)throw"invalid matrix argument";return a[0]=s.m11,a[1]=s.m21,a[2]=s.m41,a[3]=s.m12,a[4]=s.m22,a[5]=s.m42,a[6]=s.m14,a[7]=s.m24,a[8]=s.m44,ce}function z(s){if(!s)return st;var a=Ui.toTypedArray();if(s.length){if(s.length!==16&&s.length!==6&&s.length!==9)throw"invalid matrix size";return s.length===16?C(s,"HEAPF32",Ee):(a.fill(0),a[0]=s[0],a[1]=s[1],a[3]=s[2],a[4]=s[3],a[5]=s[4],a[7]=s[5],a[10]=1,a[12]=s[6],a[13]=s[7],a[15]=s[8],s.length===6&&(a[12]=0,a[13]=0,a[15]=1),Ee)}if(s.m11===void 0)throw"invalid matrix argument";return a[0]=s.m11,a[1]=s.m21,a[2]=s.m31,a[3]=s.m41,a[4]=s.m12,a[5]=s.m22,a[6]=s.m32,a[7]=s.m42,a[8]=s.m13,a[9]=s.m23,a[10]=s.m33,a[11]=s.m43,a[12]=s.m14,a[13]=s.m24,a[14]=s.m34,a[15]=s.m44,Ee}function E(s,a){return C(s,"HEAPF32",a||ve)}function H(s,a,h,f){var P=$i.toTypedArray();return P[0]=s,P[1]=a,P[2]=h,P[3]=f,ve}function et(s){for(var a=new Float32Array(4),h=0;4>h;h++)a[h]=t.HEAPF32[s/4+h];return a}function tt(s,a){return C(s,"HEAPF32",a||Ct)}function Dt(s,a){return C(s,"HEAPF32",a||Hi)}function Mt(){for(var s=0,a=0;a<arguments.length-1;a+=2)s+=arguments[a]*arguments[a+1];return s}function ze(s,a,h){for(var f=Array(s.length),P=0;P<h;P++)for(var T=0;T<h;T++){for(var k=0,G=0;G<h;G++)k+=s[h*P+G]*a[h*G+T];f[P*h+T]=k}return f}function je(s,a){for(var h=ze(a[0],a[1],s),f=2;f<a.length;)h=ze(h,a[f],s),f++;return h}t.Color=function(s,a,h,f){return f===void 0&&(f=1),t.Color4f(m(s)/255,m(a)/255,m(h)/255,f)},t.ColorAsInt=function(s,a,h,f){return f===void 0&&(f=255),(m(f)<<24|m(s)<<16|m(a)<<8|m(h)<<0&268435455)>>>0},t.Color4f=function(s,a,h,f){return f===void 0&&(f=1),Float32Array.of(s,a,h,f)},Object.defineProperty(t,"TRANSPARENT",{get:function(){return t.Color4f(0,0,0,0)}}),Object.defineProperty(t,"BLACK",{get:function(){return t.Color4f(0,0,0,1)}}),Object.defineProperty(t,"WHITE",{get:function(){return t.Color4f(1,1,1,1)}}),Object.defineProperty(t,"RED",{get:function(){return t.Color4f(1,0,0,1)}}),Object.defineProperty(t,"GREEN",{get:function(){return t.Color4f(0,1,0,1)}}),Object.defineProperty(t,"BLUE",{get:function(){return t.Color4f(0,0,1,1)}}),Object.defineProperty(t,"YELLOW",{get:function(){return t.Color4f(1,1,0,1)}}),Object.defineProperty(t,"CYAN",{get:function(){return t.Color4f(0,1,1,1)}}),Object.defineProperty(t,"MAGENTA",{get:function(){return t.Color4f(1,0,1,1)}}),t.getColorComponents=function(s){return[Math.floor(255*s[0]),Math.floor(255*s[1]),Math.floor(255*s[2]),s[3]]},t.parseColorString=function(s,a){if(s=s.toLowerCase(),s.startsWith("#")){switch(a=255,s.length){case 9:a=parseInt(s.slice(7,9),16);case 7:var h=parseInt(s.slice(1,3),16),f=parseInt(s.slice(3,5),16),P=parseInt(s.slice(5,7),16);break;case 5:a=17*parseInt(s.slice(4,5),16);case 4:h=17*parseInt(s.slice(1,2),16),f=17*parseInt(s.slice(2,3),16),P=17*parseInt(s.slice(3,4),16)}return t.Color(h,f,P,a/255)}return s.startsWith("rgba")?(s=s.slice(5,-1),s=s.split(","),t.Color(+s[0],+s[1],+s[2],b(s[3]))):s.startsWith("rgb")?(s=s.slice(4,-1),s=s.split(","),t.Color(+s[0],+s[1],+s[2],b(s[3]))):s.startsWith("gray(")||s.startsWith("hsl")||!a||(s=a[s],s===void 0)?t.BLACK:s},t.multiplyByAlpha=function(s,a){return s=s.slice(),s[3]=Math.max(0,Math.min(s[3]*a,1)),s},t.Malloc=function(s,a){var h=t._malloc(a*s.BYTES_PER_ELEMENT);return{_ck:!0,length:a,byteOffset:h,qe:null,subarray:function(f,P){return f=this.toTypedArray().subarray(f,P),f._ck=!0,f},toTypedArray:function(){return this.qe&&this.qe.length?this.qe:(this.qe=new s(t.HEAPU8.buffer,h,a),this.qe._ck=!0,this.qe)}}},t.Free=function(s){t._free(s.byteOffset),s.byteOffset=st,s.toTypedArray=null,s.qe=null};var ce=st,Gi,Ee=st,Ui,ve=st,$i,Zt,Ct=st,Vr,ue=st,Yr,zi=st,Xr,ji=st,vi,He=st,Jr,Hi=st,qr,Qr=st,xa=Float32Array.of(0,0,1),st=0;t.onRuntimeInitialized=function(){function s(a,h,f,P,T,k,G){k||(k=4*P.width,P.colorType===t.ColorType.RGBA_F16?k*=2:P.colorType===t.ColorType.RGBA_F32&&(k*=4));var Y=k*P.height,K=T?T.byteOffset:t._malloc(Y);if(G?!a._readPixels(P,K,k,h,f,G):!a._readPixels(P,K,k,h,f))return T||t._free(K),null;if(T)return T.toTypedArray();switch(P.colorType){case t.ColorType.RGBA_8888:case t.ColorType.RGBA_F16:a=new Uint8Array(t.HEAPU8.buffer,K,Y).slice();break;case t.ColorType.RGBA_F32:a=new Float32Array(t.HEAPU8.buffer,K,Y).slice();break;default:return null}return t._free(K),a}$i=t.Malloc(Float32Array,4),ve=$i.byteOffset,Ui=t.Malloc(Float32Array,16),Ee=Ui.byteOffset,Gi=t.Malloc(Float32Array,9),ce=Gi.byteOffset,Jr=t.Malloc(Float32Array,12),Hi=Jr.byteOffset,qr=t.Malloc(Float32Array,12),Qr=qr.byteOffset,Zt=t.Malloc(Float32Array,4),Ct=Zt.byteOffset,Vr=t.Malloc(Float32Array,4),ue=Vr.byteOffset,Yr=t.Malloc(Float32Array,3),zi=Yr.byteOffset,Xr=t.Malloc(Float32Array,3),ji=Xr.byteOffset,vi=t.Malloc(Int32Array,4),He=vi.byteOffset,t.ColorSpace.SRGB=t.ColorSpace._MakeSRGB(),t.ColorSpace.DISPLAY_P3=t.ColorSpace._MakeDisplayP3(),t.ColorSpace.ADOBE_RGB=t.ColorSpace._MakeAdobeRGB(),t.GlyphRunFlags={IsWhiteSpace:t._GlyphRunFlags_isWhiteSpace},t.Path.MakeFromCmds=function(a){var h=C(a,"HEAPF32"),f=t.Path._MakeFromCmds(h,a.length);return w(h,a),f},t.Path.MakeFromVerbsPointsWeights=function(a,h,f){var P=C(a,"HEAPU8"),T=C(h,"HEAPF32"),k=C(f,"HEAPF32"),G=t.Path._MakeFromVerbsPointsWeights(P,a.length,T,h.length,k,f&&f.length||0);return w(P,a),w(T,h),w(k,f),G},t.Path.prototype.addArc=function(a,h,f){return a=tt(a),this._addArc(a,h,f),this},t.Path.prototype.addCircle=function(a,h,f,P){return this._addCircle(a,h,f,!!P),this},t.Path.prototype.addOval=function(a,h,f){return f===void 0&&(f=1),a=tt(a),this._addOval(a,!!h,f),this},t.Path.prototype.addPath=function(){var a=Array.prototype.slice.call(arguments),h=a[0],f=!1;if(typeof a[a.length-1]=="boolean"&&(f=a.pop()),a.length===1)this._addPath(h,1,0,0,0,1,0,0,0,1,f);else if(a.length===2)a=a[1],this._addPath(h,a[0],a[1],a[2],a[3],a[4],a[5],a[6]||0,a[7]||0,a[8]||1,f);else if(a.length===7||a.length===10)this._addPath(h,a[1],a[2],a[3],a[4],a[5],a[6],a[7]||0,a[8]||0,a[9]||1,f);else return null;return this},t.Path.prototype.addPoly=function(a,h){var f=C(a,"HEAPF32");return this._addPoly(f,a.length/2,h),w(f,a),this},t.Path.prototype.addRect=function(a,h){return a=tt(a),this._addRect(a,!!h),this},t.Path.prototype.addRRect=function(a,h){return a=Dt(a),this._addRRect(a,!!h),this},t.Path.prototype.addVerbsPointsWeights=function(a,h,f){var P=C(a,"HEAPU8"),T=C(h,"HEAPF32"),k=C(f,"HEAPF32");this._addVerbsPointsWeights(P,a.length,T,h.length,k,f&&f.length||0),w(P,a),w(T,h),w(k,f)},t.Path.prototype.arc=function(a,h,f,P,T,k){return a=t.LTRBRect(a-f,h-f,a+f,h+f),T=(T-P)/Math.PI*180-360*!!k,k=new t.Path,k.addArc(a,P/Math.PI*180,T),this.addPath(k,!0),k.delete(),this},t.Path.prototype.arcToOval=function(a,h,f,P){return a=tt(a),this._arcToOval(a,h,f,P),this},t.Path.prototype.arcToRotated=function(a,h,f,P,T,k,G){return this._arcToRotated(a,h,f,!!P,!!T,k,G),this},t.Path.prototype.arcToTangent=function(a,h,f,P,T){return this._arcToTangent(a,h,f,P,T),this},t.Path.prototype.close=function(){return this._close(),this},t.Path.prototype.conicTo=function(a,h,f,P,T){return this._conicTo(a,h,f,P,T),this},t.Path.prototype.computeTightBounds=function(a){this._computeTightBounds(Ct);var h=Zt.toTypedArray();return a?(a.set(h),a):h.slice()},t.Path.prototype.cubicTo=function(a,h,f,P,T,k){return this._cubicTo(a,h,f,P,T,k),this},t.Path.prototype.dash=function(a,h,f){return this._dash(a,h,f)?this:null},t.Path.prototype.getBounds=function(a){this._getBounds(Ct);var h=Zt.toTypedArray();return a?(a.set(h),a):h.slice()},t.Path.prototype.lineTo=function(a,h){return this._lineTo(a,h),this},t.Path.prototype.moveTo=function(a,h){return this._moveTo(a,h),this},t.Path.prototype.offset=function(a,h){return this._transform(1,0,a,0,1,h,0,0,1),this},t.Path.prototype.quadTo=function(a,h,f,P){return this._quadTo(a,h,f,P),this},t.Path.prototype.rArcTo=function(a,h,f,P,T,k,G){return this._rArcTo(a,h,f,P,T,k,G),this},t.Path.prototype.rConicTo=function(a,h,f,P,T){return this._rConicTo(a,h,f,P,T),this},t.Path.prototype.rCubicTo=function(a,h,f,P,T,k){return this._rCubicTo(a,h,f,P,T,k),this},t.Path.prototype.rLineTo=function(a,h){return this._rLineTo(a,h),this},t.Path.prototype.rMoveTo=function(a,h){return this._rMoveTo(a,h),this},t.Path.prototype.rQuadTo=function(a,h,f,P){return this._rQuadTo(a,h,f,P),this},t.Path.prototype.stroke=function(a){return a=a||{},a.width=a.width||1,a.miter_limit=a.miter_limit||4,a.cap=a.cap||t.StrokeCap.Butt,a.join=a.join||t.StrokeJoin.Miter,a.precision=a.precision||1,this._stroke(a)?this:null},t.Path.prototype.transform=function(){if(arguments.length===1){var a=arguments[0];this._transform(a[0],a[1],a[2],a[3],a[4],a[5],a[6]||0,a[7]||0,a[8]||1)}else if(arguments.length===6||arguments.length===9)a=arguments,this._transform(a[0],a[1],a[2],a[3],a[4],a[5],a[6]||0,a[7]||0,a[8]||1);else throw"transform expected to take 1 or 9 arguments. Got "+arguments.length;return this},t.Path.prototype.trim=function(a,h,f){return this._trim(a,h,!!f)?this:null},t.Image.prototype.encodeToBytes=function(a,h){var f=t.Te();return a=a||t.ImageFormat.PNG,h=h||100,f?this._encodeToBytes(a,h,f):this._encodeToBytes(a,h)},t.Image.prototype.makeShaderCubic=function(a,h,f,P,T){return T=D(T),this._makeShaderCubic(a,h,f,P,T)},t.Image.prototype.makeShaderOptions=function(a,h,f,P,T){return T=D(T),this._makeShaderOptions(a,h,f,P,T)},t.Image.prototype.readPixels=function(a,h,f,P,T){var k=t.Te();return s(this,a,h,f,P,T,k)},t.Canvas.prototype.clear=function(a){t.Md(this.Kd),a=E(a),this._clear(a)},t.Canvas.prototype.clipRRect=function(a,h,f){t.Md(this.Kd),a=Dt(a),this._clipRRect(a,h,f)},t.Canvas.prototype.clipRect=function(a,h,f){t.Md(this.Kd),a=tt(a),this._clipRect(a,h,f)},t.Canvas.prototype.concat=function(a){t.Md(this.Kd),a=z(a),this._concat(a)},t.Canvas.prototype.drawArc=function(a,h,f,P,T){t.Md(this.Kd),a=tt(a),this._drawArc(a,h,f,P,T)},t.Canvas.prototype.drawAtlas=function(a,h,f,P,T,k,G){if(a&&P&&h&&f&&h.length===f.length){t.Md(this.Kd),T||(T=t.BlendMode.SrcOver);var Y=C(h,"HEAPF32"),K=C(f,"HEAPF32"),lt=f.length/4,ut=C(g(k),"HEAPU32");if(G&&"B"in G&&"C"in G)this._drawAtlasCubic(a,K,Y,ut,lt,T,G.B,G.C,P);else{let A=t.FilterMode.Linear,O=t.MipmapMode.None;G&&(A=G.filter,"mipmap"in G&&(O=G.mipmap)),this._drawAtlasOptions(a,K,Y,ut,lt,T,A,O,P)}w(Y,h),w(K,f),w(ut,k)}},t.Canvas.prototype.drawCircle=function(a,h,f,P){t.Md(this.Kd),this._drawCircle(a,h,f,P)},t.Canvas.prototype.drawColor=function(a,h){t.Md(this.Kd),a=E(a),h!==void 0?this._drawColor(a,h):this._drawColor(a)},t.Canvas.prototype.drawColorInt=function(a,h){t.Md(this.Kd),this._drawColorInt(a,h||t.BlendMode.SrcOver)},t.Canvas.prototype.drawColorComponents=function(a,h,f,P,T){t.Md(this.Kd),a=H(a,h,f,P),T!==void 0?this._drawColor(a,T):this._drawColor(a)},t.Canvas.prototype.drawDRRect=function(a,h,f){t.Md(this.Kd),a=Dt(a,Hi),h=Dt(h,Qr),this._drawDRRect(a,h,f)},t.Canvas.prototype.drawImage=function(a,h,f,P){t.Md(this.Kd),this._drawImage(a,h,f,P||null)},t.Canvas.prototype.drawImageCubic=function(a,h,f,P,T,k){t.Md(this.Kd),this._drawImageCubic(a,h,f,P,T,k||null)},t.Canvas.prototype.drawImageOptions=function(a,h,f,P,T,k){t.Md(this.Kd),this._drawImageOptions(a,h,f,P,T,k||null)},t.Canvas.prototype.drawImageNine=function(a,h,f,P,T){t.Md(this.Kd),h=C(h,"HEAP32",He),f=tt(f),this._drawImageNine(a,h,f,P,T||null)},t.Canvas.prototype.drawImageRect=function(a,h,f,P,T){t.Md(this.Kd),tt(h,Ct),tt(f,ue),this._drawImageRect(a,Ct,ue,P,!!T)},t.Canvas.prototype.drawImageRectCubic=function(a,h,f,P,T,k){t.Md(this.Kd),tt(h,Ct),tt(f,ue),this._drawImageRectCubic(a,Ct,ue,P,T,k||null)},t.Canvas.prototype.drawImageRectOptions=function(a,h,f,P,T,k){t.Md(this.Kd),tt(h,Ct),tt(f,ue),this._drawImageRectOptions(a,Ct,ue,P,T,k||null)},t.Canvas.prototype.drawLine=function(a,h,f,P,T){t.Md(this.Kd),this._drawLine(a,h,f,P,T)},t.Canvas.prototype.drawOval=function(a,h){t.Md(this.Kd),a=tt(a),this._drawOval(a,h)},t.Canvas.prototype.drawPaint=function(a){t.Md(this.Kd),this._drawPaint(a)},t.Canvas.prototype.drawParagraph=function(a,h,f){t.Md(this.Kd),this._drawParagraph(a,h,f)},t.Canvas.prototype.drawPatch=function(a,h,f,P,T){if(24>a.length)throw"Need 12 cubic points";if(h&&4>h.length)throw"Need 4 colors";if(f&&8>f.length)throw"Need 4 shader coordinates";t.Md(this.Kd);const k=C(a,"HEAPF32"),G=h?C(g(h),"HEAPU32"):st,Y=f?C(f,"HEAPF32"):st;P||(P=t.BlendMode.Modulate),this._drawPatch(k,G,Y,P,T),w(Y,f),w(G,h),w(k,a)},t.Canvas.prototype.drawPath=function(a,h){t.Md(this.Kd),this._drawPath(a,h)},t.Canvas.prototype.drawPicture=function(a){t.Md(this.Kd),this._drawPicture(a)},t.Canvas.prototype.drawPoints=function(a,h,f){t.Md(this.Kd);var P=C(h,"HEAPF32");this._drawPoints(a,P,h.length/2,f),w(P,h)},t.Canvas.prototype.drawRRect=function(a,h){t.Md(this.Kd),a=Dt(a),this._drawRRect(a,h)},t.Canvas.prototype.drawRect=function(a,h){t.Md(this.Kd),a=tt(a),this._drawRect(a,h)},t.Canvas.prototype.drawRect4f=function(a,h,f,P,T){t.Md(this.Kd),this._drawRect4f(a,h,f,P,T)},t.Canvas.prototype.drawShadow=function(a,h,f,P,T,k,G){t.Md(this.Kd);var Y=C(T,"HEAPF32"),K=C(k,"HEAPF32");h=C(h,"HEAPF32",zi),f=C(f,"HEAPF32",ji),this._drawShadow(a,h,f,P,Y,K,G),w(Y,T),w(K,k)},t.getShadowLocalBounds=function(a,h,f,P,T,k,G){return a=D(a),f=C(f,"HEAPF32",zi),P=C(P,"HEAPF32",ji),this._getShadowLocalBounds(a,h,f,P,T,k,Ct)?(h=Zt.toTypedArray(),G?(G.set(h),G):h.slice()):null},t.Canvas.prototype.drawTextBlob=function(a,h,f,P){t.Md(this.Kd),this._drawTextBlob(a,h,f,P)},t.Canvas.prototype.drawVertices=function(a,h,f){t.Md(this.Kd),this._drawVertices(a,h,f)},t.Canvas.prototype.getDeviceClipBounds=function(a){this._getDeviceClipBounds(He);var h=vi.toTypedArray();return a?a.set(h):a=h.slice(),a},t.Canvas.prototype.getLocalToDevice=function(){this._getLocalToDevice(Ee);for(var a=Ee,h=Array(16),f=0;16>f;f++)h[f]=t.HEAPF32[a/4+f];return h},t.Canvas.prototype.getTotalMatrix=function(){this._getTotalMatrix(ce);for(var a=Array(9),h=0;9>h;h++)a[h]=t.HEAPF32[ce/4+h];return a},t.Canvas.prototype.makeSurface=function(a){return a=this._makeSurface(a),a.Kd=this.Kd,a},t.Canvas.prototype.readPixels=function(a,h,f,P,T){return t.Md(this.Kd),s(this,a,h,f,P,T)},t.Canvas.prototype.saveLayer=function(a,h,f,P){return h=tt(h),this._saveLayer(a||null,h,f||null,P||0)},t.Canvas.prototype.writePixels=function(a,h,f,P,T,k,G,Y){if(a.byteLength%(h*f))throw"pixels length must be a multiple of the srcWidth * srcHeight";t.Md(this.Kd);var K=a.byteLength/(h*f);k=k||t.AlphaType.Unpremul,G=G||t.ColorType.RGBA_8888,Y=Y||t.ColorSpace.SRGB;var lt=K*h;return K=C(a,"HEAPU8"),h=this._writePixels({width:h,height:f,colorType:G,alphaType:k,colorSpace:Y},K,lt,P,T),w(K,a),h},t.ColorFilter.MakeBlend=function(a,h,f){return a=E(a),f=f||t.ColorSpace.SRGB,t.ColorFilter._MakeBlend(a,h,f)},t.ColorFilter.MakeMatrix=function(a){if(!a||a.length!==20)throw"invalid color matrix";var h=C(a,"HEAPF32"),f=t.ColorFilter._makeMatrix(h);return w(h,a),f},t.ContourMeasure.prototype.getPosTan=function(a,h){return this._getPosTan(a,Ct),a=Zt.toTypedArray(),h?(h.set(a),h):a.slice()},t.ImageFilter.prototype.getOutputBounds=function(a,h,f){return a=tt(a,Ct),h=D(h),this._getOutputBounds(a,h,He),h=vi.toTypedArray(),f?(f.set(h),f):h.slice()},t.ImageFilter.MakeDropShadow=function(a,h,f,P,T,k){return T=E(T,ve),t.ImageFilter._MakeDropShadow(a,h,f,P,T,k)},t.ImageFilter.MakeDropShadowOnly=function(a,h,f,P,T,k){return T=E(T,ve),t.ImageFilter._MakeDropShadowOnly(a,h,f,P,T,k)},t.ImageFilter.MakeImage=function(a,h,f,P){if(f=tt(f,Ct),P=tt(P,ue),"B"in h&&"C"in h)return t.ImageFilter._MakeImageCubic(a,h.B,h.C,f,P);const T=h.filter;let k=t.MipmapMode.None;return"mipmap"in h&&(k=h.mipmap),t.ImageFilter._MakeImageOptions(a,T,k,f,P)},t.ImageFilter.MakeMatrixTransform=function(a,h,f){if(a=D(a),"B"in h&&"C"in h)return t.ImageFilter._MakeMatrixTransformCubic(a,h.B,h.C,f);const P=h.filter;let T=t.MipmapMode.None;return"mipmap"in h&&(T=h.mipmap),t.ImageFilter._MakeMatrixTransformOptions(a,P,T,f)},t.Paint.prototype.getColor=function(){return this._getColor(ve),et(ve)},t.Paint.prototype.setColor=function(a,h){h=h||null,a=E(a),this._setColor(a,h)},t.Paint.prototype.setColorComponents=function(a,h,f,P,T){T=T||null,a=H(a,h,f,P),this._setColor(a,T)},t.Path.prototype.getPoint=function(a,h){return this._getPoint(a,Ct),a=Zt.toTypedArray(),h?(h[0]=a[0],h[1]=a[1],h):a.slice(0,2)},t.Picture.prototype.makeShader=function(a,h,f,P,T){return P=D(P),T=tt(T),this._makeShader(a,h,f,P,T)},t.Picture.prototype.cullRect=function(a){this._cullRect(Ct);var h=Zt.toTypedArray();return a?(a.set(h),a):h.slice()},t.PictureRecorder.prototype.beginRecording=function(a,h){return a=tt(a),this._beginRecording(a,!!h)},t.Surface.prototype.getCanvas=function(){var a=this._getCanvas();return a.Kd=this.Kd,a},t.Surface.prototype.makeImageSnapshot=function(a){return t.Md(this.Kd),a=C(a,"HEAP32",He),this._makeImageSnapshot(a)},t.Surface.prototype.makeSurface=function(a){return t.Md(this.Kd),a=this._makeSurface(a),a.Kd=this.Kd,a},t.Surface.prototype.Gf=function(a,h){return this.He||(this.He=this.getCanvas()),requestAnimationFrame(function(){t.Md(this.Kd),a(this.He),this.flush(h)}.bind(this))},t.Surface.prototype.requestAnimationFrame||(t.Surface.prototype.requestAnimationFrame=t.Surface.prototype.Gf),t.Surface.prototype.Cf=function(a,h){this.He||(this.He=this.getCanvas()),requestAnimationFrame(function(){t.Md(this.Kd),a(this.He),this.flush(h),this.dispose()}.bind(this))},t.Surface.prototype.drawOnce||(t.Surface.prototype.drawOnce=t.Surface.prototype.Cf),t.PathEffect.MakeDash=function(a,h){if(h||(h=0),!a.length||a.length%2===1)throw"Intervals array must have even length";var f=C(a,"HEAPF32");return h=t.PathEffect._MakeDash(f,a.length,h),w(f,a),h},t.PathEffect.MakeLine2D=function(a,h){return h=D(h),t.PathEffect._MakeLine2D(a,h)},t.PathEffect.MakePath2D=function(a,h){return a=D(a),t.PathEffect._MakePath2D(a,h)},t.Shader.MakeColor=function(a,h){return h=h||null,a=E(a),t.Shader._MakeColor(a,h)},t.Shader.Blend=t.Shader.MakeBlend,t.Shader.Color=t.Shader.MakeColor,t.Shader.MakeLinearGradient=function(a,h,f,P,T,k,G,Y){Y=Y||null;var K=L(f),lt=C(P,"HEAPF32");G=G||0,k=D(k);var ut=Zt.toTypedArray();return ut.set(a),ut.set(h,2),a=t.Shader._MakeLinearGradient(Ct,K.be,K.colorType,lt,K.count,T,G,k,Y),w(K.be,f),P&&w(lt,P),a},t.Shader.MakeRadialGradient=function(a,h,f,P,T,k,G,Y){Y=Y||null;var K=L(f),lt=C(P,"HEAPF32");return G=G||0,k=D(k),a=t.Shader._MakeRadialGradient(a[0],a[1],h,K.be,K.colorType,lt,K.count,T,G,k,Y),w(K.be,f),P&&w(lt,P),a},t.Shader.MakeSweepGradient=function(a,h,f,P,T,k,G,Y,K,lt){lt=lt||null;var ut=L(f),A=C(P,"HEAPF32");return G=G||0,Y=Y||0,K=K||360,k=D(k),a=t.Shader._MakeSweepGradient(a,h,ut.be,ut.colorType,A,ut.count,T,Y,K,G,k,lt),w(ut.be,f),P&&w(A,P),a},t.Shader.MakeTwoPointConicalGradient=function(a,h,f,P,T,k,G,Y,K,lt){lt=lt||null;var ut=L(T),A=C(k,"HEAPF32");K=K||0,Y=D(Y);var O=Zt.toTypedArray();return O.set(a),O.set(f,2),a=t.Shader._MakeTwoPointConicalGradient(Ct,h,P,ut.be,ut.colorType,A,ut.count,G,K,Y,lt),w(ut.be,T),k&&w(A,k),a},t.Vertices.prototype.bounds=function(a){this._bounds(Ct);var h=Zt.toTypedArray();return a?(a.set(h),a):h.slice()},t.Td&&t.Td.forEach(function(a){a()})},t.computeTonalColors=function(s){var a=C(s.ambient,"HEAPF32"),h=C(s.spot,"HEAPF32");this._computeTonalColors(a,h);var f={ambient:et(a),spot:et(h)};return w(a,s.ambient),w(h,s.spot),f},t.LTRBRect=function(s,a,h,f){return Float32Array.of(s,a,h,f)},t.XYWHRect=function(s,a,h,f){return Float32Array.of(s,a,s+h,a+f)},t.LTRBiRect=function(s,a,h,f){return Int32Array.of(s,a,h,f)},t.XYWHiRect=function(s,a,h,f){return Int32Array.of(s,a,s+h,a+f)},t.RRectXY=function(s,a,h){return Float32Array.of(s[0],s[1],s[2],s[3],a,h,a,h,a,h,a,h)},t.MakeAnimatedImageFromEncoded=function(s){s=new Uint8Array(s);var a=t._malloc(s.byteLength);return t.HEAPU8.set(s,a),(s=t._decodeAnimatedImage(a,s.byteLength))?s:null},t.MakeImageFromEncoded=function(s){s=new Uint8Array(s);var a=t._malloc(s.byteLength);return t.HEAPU8.set(s,a),(s=t._decodeImage(a,s.byteLength))?s:null};var Ke=null;t.MakeImageFromCanvasImageSource=function(s){var a=s.width,h=s.height;Ke||(Ke=document.createElement("canvas")),Ke.width=a,Ke.height=h;var f=Ke.getContext("2d",{willReadFrequently:!0});return f.drawImage(s,0,0),s=f.getImageData(0,0,a,h),t.MakeImage({width:a,height:h,alphaType:t.AlphaType.Unpremul,colorType:t.ColorType.RGBA_8888,colorSpace:t.ColorSpace.SRGB},s.data,4*a)},t.MakeImage=function(s,a,h){var f=t._malloc(a.length);return t.HEAPU8.set(a,f),t._MakeImage(s,f,a.length,h)},t.MakeVertices=function(s,a,h,f,P,T){var k=P&&P.length||0,G=0;return h&&h.length&&(G|=1),f&&f.length&&(G|=2),T===void 0||T||(G|=4),s=new t._VerticesBuilder(s,a.length/2,k,G),C(a,"HEAPF32",s.positions()),s.texCoords()&&C(h,"HEAPF32",s.texCoords()),s.colors()&&C(g(f),"HEAPU32",s.colors()),s.indices()&&C(P,"HEAPU16",s.indices()),s.detach()},t.Matrix={},t.Matrix.identity=function(){return n(3)},t.Matrix.invert=function(s){var a=s[0]*s[4]*s[8]+s[1]*s[5]*s[6]+s[2]*s[3]*s[7]-s[2]*s[4]*s[6]-s[1]*s[3]*s[8]-s[0]*s[5]*s[7];return a?[(s[4]*s[8]-s[5]*s[7])/a,(s[2]*s[7]-s[1]*s[8])/a,(s[1]*s[5]-s[2]*s[4])/a,(s[5]*s[6]-s[3]*s[8])/a,(s[0]*s[8]-s[2]*s[6])/a,(s[2]*s[3]-s[0]*s[5])/a,(s[3]*s[7]-s[4]*s[6])/a,(s[1]*s[6]-s[0]*s[7])/a,(s[0]*s[4]-s[1]*s[3])/a]:null},t.Matrix.mapPoints=function(s,a){for(var h=0;h<a.length;h+=2){var f=a[h],P=a[h+1],T=s[6]*f+s[7]*P+s[8],k=s[3]*f+s[4]*P+s[5];a[h]=(s[0]*f+s[1]*P+s[2])/T,a[h+1]=k/T}return a},t.Matrix.multiply=function(){return je(3,arguments)},t.Matrix.rotated=function(s,a,h){a=a||0,h=h||0;var f=Math.sin(s);return s=Math.cos(s),[s,-f,Mt(f,h,1-s,a),f,s,Mt(-f,a,1-s,h),0,0,1]},t.Matrix.scaled=function(s,a,h,f){h=h||0,f=f||0;var P=i([s,a],n(3),3,0,1);return i([h-s*h,f-a*f],P,3,2,0)},t.Matrix.skewed=function(s,a,h,f){h=h||0,f=f||0;var P=i([s,a],n(3),3,1,-1);return i([-s*h,-a*f],P,3,2,0)},t.Matrix.translated=function(s,a){return i(arguments,n(3),3,2,0)},t.Vector={},t.Vector.dot=function(s,a){return s.map(function(h,f){return h*a[f]}).reduce(function(h,f){return h+f})},t.Vector.lengthSquared=function(s){return t.Vector.dot(s,s)},t.Vector.length=function(s){return Math.sqrt(t.Vector.lengthSquared(s))},t.Vector.mulScalar=function(s,a){return s.map(function(h){return h*a})},t.Vector.add=function(s,a){return s.map(function(h,f){return h+a[f]})},t.Vector.sub=function(s,a){return s.map(function(h,f){return h-a[f]})},t.Vector.dist=function(s,a){return t.Vector.length(t.Vector.sub(s,a))},t.Vector.normalize=function(s){return t.Vector.mulScalar(s,1/t.Vector.length(s))},t.Vector.cross=function(s,a){return[s[1]*a[2]-s[2]*a[1],s[2]*a[0]-s[0]*a[2],s[0]*a[1]-s[1]*a[0]]},t.M44={},t.M44.identity=function(){return n(4)},t.M44.translated=function(s){return i(s,n(4),4,3,0)},t.M44.scaled=function(s){return i(s,n(4),4,0,1)},t.M44.rotated=function(s,a){return t.M44.rotatedUnitSinCos(t.Vector.normalize(s),Math.sin(a),Math.cos(a))},t.M44.rotatedUnitSinCos=function(s,a,h){var f=s[0],P=s[1];s=s[2];var T=1-h;return[T*f*f+h,T*f*P-a*s,T*f*s+a*P,0,T*f*P+a*s,T*P*P+h,T*P*s-a*f,0,T*f*s-a*P,T*P*s+a*f,T*s*s+h,0,0,0,0,1]},t.M44.lookat=function(s,a,h){a=t.Vector.normalize(t.Vector.sub(a,s)),h=t.Vector.normalize(h),h=t.Vector.normalize(t.Vector.cross(a,h));var f=t.M44.identity();return i(h,f,4,0,0),i(t.Vector.cross(h,a),f,4,1,0),i(t.Vector.mulScalar(a,-1),f,4,2,0),i(s,f,4,3,0),s=t.M44.invert(f),s===null?t.M44.identity():s},t.M44.perspective=function(s,a,h){var f=1/(a-s);return h/=2,h=Math.cos(h)/Math.sin(h),[h,0,0,0,0,h,0,0,0,0,(a+s)*f,2*a*s*f,0,0,-1,1]},t.M44.rc=function(s,a,h){return s[4*a+h]},t.M44.multiply=function(){return je(4,arguments)},t.M44.invert=function(s){var a=s[0],h=s[4],f=s[8],P=s[12],T=s[1],k=s[5],G=s[9],Y=s[13],K=s[2],lt=s[6],ut=s[10],A=s[14],O=s[3],it=s[7],gt=s[11];s=s[15];var _t=a*k-h*T,jt=a*G-f*T,Ht=a*Y-P*T,Ot=h*G-f*k,N=h*Y-P*k,d=f*Y-P*G,S=K*it-lt*O,M=K*gt-ut*O,R=K*s-A*O,I=lt*gt-ut*it,B=lt*s-A*it,j=ut*s-A*gt,St=_t*j-jt*B+Ht*I+Ot*R-N*M+d*S,At=1/St;return St===0||At===1/0?null:(_t*=At,jt*=At,Ht*=At,Ot*=At,N*=At,d*=At,S*=At,M*=At,R*=At,I*=At,B*=At,j*=At,a=[k*j-G*B+Y*I,G*R-T*j-Y*M,T*B-k*R+Y*S,k*M-T*I-G*S,f*B-h*j-P*I,a*j-f*R+P*M,h*R-a*B-P*S,a*I-h*M+f*S,it*d-gt*N+s*Ot,gt*Ht-O*d-s*jt,O*N-it*Ht+s*_t,it*jt-O*Ot-gt*_t,ut*N-lt*d-A*Ot,K*d-ut*Ht+A*jt,lt*Ht-K*N-A*_t,K*Ot-lt*jt+ut*_t],a.every(function(ne){return!isNaN(ne)&&ne!==1/0&&ne!==-1/0})?a:null)},t.M44.transpose=function(s){return[s[0],s[4],s[8],s[12],s[1],s[5],s[9],s[13],s[2],s[6],s[10],s[14],s[3],s[7],s[11],s[15]]},t.M44.mustInvert=function(s){if(s=t.M44.invert(s),s===null)throw"Matrix not invertible";return s},t.M44.setupCamera=function(s,a,h){var f=t.M44.lookat(h.eye,h.coa,h.up);return h=t.M44.perspective(h.near,h.far,h.angle),a=[(s[2]-s[0])/2,(s[3]-s[1])/2,a],s=t.M44.multiply(t.M44.translated([(s[0]+s[2])/2,(s[1]+s[3])/2,0]),t.M44.scaled(a)),t.M44.multiply(s,h,f,t.M44.mustInvert(s))},t.ColorMatrix={},t.ColorMatrix.identity=function(){var s=new Float32Array(20);return s[0]=1,s[6]=1,s[12]=1,s[18]=1,s},t.ColorMatrix.scaled=function(s,a,h,f){var P=new Float32Array(20);return P[0]=s,P[6]=a,P[12]=h,P[18]=f,P};var Ra=[[6,7,11,12],[0,10,2,12],[0,1,5,6]];t.ColorMatrix.rotated=function(s,a,h){var f=t.ColorMatrix.identity();return s=Ra[s],f[s[0]]=h,f[s[1]]=a,f[s[2]]=-a,f[s[3]]=h,f},t.ColorMatrix.postTranslate=function(s,a,h,f,P){return s[4]+=a,s[9]+=h,s[14]+=f,s[19]+=P,s},t.ColorMatrix.concat=function(s,a){for(var h=new Float32Array(20),f=0,P=0;20>P;P+=5){for(var T=0;4>T;T++)h[f++]=s[P]*a[T]+s[P+1]*a[T+5]+s[P+2]*a[T+10]+s[P+3]*a[T+15];h[f++]=s[P]*a[4]+s[P+1]*a[9]+s[P+2]*a[14]+s[P+3]*a[19]+s[P+4]}return h},function(s){s.Td=s.Td||[],s.Td.push(function(){function a(A){return A&&(A.dir=A.dir===0?s.TextDirection.RTL:s.TextDirection.LTR),A}function h(A){if(!A||!A.length)return[];for(var O=[],it=0;it<A.length;it+=5){var gt=s.LTRBRect(A[it],A[it+1],A[it+2],A[it+3]),_t=s.TextDirection.LTR;A[it+4]===0&&(_t=s.TextDirection.RTL),O.push({rect:gt,dir:_t})}return s._free(A.byteOffset),O}function f(A){return A=A||{},A.weight===void 0&&(A.weight=s.FontWeight.Normal),A.width=A.width||s.FontWidth.Normal,A.slant=A.slant||s.FontSlant.Upright,A}function P(A){if(!A||!A.length)return st;for(var O=[],it=0;it<A.length;it++){var gt=T(A[it]);O.push(gt)}return C(O,"HEAPU32")}function T(A){if(Y[A])return Y[A];var O=Jt(A)+1,it=s._malloc(O);return Xt(A,rt,it,O),Y[A]=it}function k(A){if(A._colorPtr=E(A.color),A._foregroundColorPtr=st,A._backgroundColorPtr=st,A._decorationColorPtr=st,A.foregroundColor&&(A._foregroundColorPtr=E(A.foregroundColor,K)),A.backgroundColor&&(A._backgroundColorPtr=E(A.backgroundColor,lt)),A.decorationColor&&(A._decorationColorPtr=E(A.decorationColor,ut)),Array.isArray(A.fontFamilies)&&A.fontFamilies.length?(A._fontFamiliesPtr=P(A.fontFamilies),A._fontFamiliesLen=A.fontFamilies.length):(A._fontFamiliesPtr=st,A._fontFamiliesLen=0),A.locale){var O=A.locale;A._localePtr=T(O),A._localeLen=Jt(O)+1}else A._localePtr=st,A._localeLen=0;if(Array.isArray(A.shadows)&&A.shadows.length){O=A.shadows;var it=O.map(function(N){return N.color||s.BLACK}),gt=O.map(function(N){return N.blurRadius||0});A._shadowLen=O.length;for(var _t=s._malloc(8*O.length),jt=_t/4,Ht=0;Ht<O.length;Ht++){var Ot=O[Ht].offset||[0,0];s.HEAPF32[jt]=Ot[0],s.HEAPF32[jt+1]=Ot[1],jt+=2}A._shadowColorsPtr=L(it).be,A._shadowOffsetsPtr=_t,A._shadowBlurRadiiPtr=C(gt,"HEAPF32")}else A._shadowLen=0,A._shadowColorsPtr=st,A._shadowOffsetsPtr=st,A._shadowBlurRadiiPtr=st;Array.isArray(A.fontFeatures)&&A.fontFeatures.length?(O=A.fontFeatures,it=O.map(function(N){return N.name}),gt=O.map(function(N){return N.value}),A._fontFeatureLen=O.length,A._fontFeatureNamesPtr=P(it),A._fontFeatureValuesPtr=C(gt,"HEAPU32")):(A._fontFeatureLen=0,A._fontFeatureNamesPtr=st,A._fontFeatureValuesPtr=st),Array.isArray(A.fontVariations)&&A.fontVariations.length?(O=A.fontVariations,it=O.map(function(N){return N.axis}),gt=O.map(function(N){return N.value}),A._fontVariationLen=O.length,A._fontVariationAxesPtr=P(it),A._fontVariationValuesPtr=C(gt,"HEAPF32")):(A._fontVariationLen=0,A._fontVariationAxesPtr=st,A._fontVariationValuesPtr=st)}function G(A){s._free(A._fontFamiliesPtr),s._free(A._shadowColorsPtr),s._free(A._shadowOffsetsPtr),s._free(A._shadowBlurRadiiPtr),s._free(A._fontFeatureNamesPtr),s._free(A._fontFeatureValuesPtr),s._free(A._fontVariationAxesPtr),s._free(A._fontVariationValuesPtr)}s.Paragraph.prototype.getRectsForRange=function(A,O,it,gt){return A=this._getRectsForRange(A,O,it,gt),h(A)},s.Paragraph.prototype.getRectsForPlaceholders=function(){var A=this._getRectsForPlaceholders();return h(A)},s.Paragraph.prototype.getGlyphInfoAt=function(A){return a(this._getGlyphInfoAt(A))},s.Paragraph.prototype.getClosestGlyphInfoAtCoordinate=function(A,O){return a(this._getClosestGlyphInfoAtCoordinate(A,O))},s.TypefaceFontProvider.prototype.registerFont=function(A,O){if(A=s.Typeface.MakeFreeTypeFaceFromData(A),!A)return null;O=T(O),this._registerFont(A,O)},s.ParagraphStyle=function(A){if(A.disableHinting=A.disableHinting||!1,A.ellipsis){var O=A.ellipsis;A._ellipsisPtr=T(O),A._ellipsisLen=Jt(O)+1}else A._ellipsisPtr=st,A._ellipsisLen=0;return A.heightMultiplier==null&&(A.heightMultiplier=-1),A.maxLines=A.maxLines||0,A.replaceTabCharacters=A.replaceTabCharacters||!1,O=(O=A.strutStyle)||{},O.strutEnabled=O.strutEnabled||!1,O.strutEnabled&&Array.isArray(O.fontFamilies)&&O.fontFamilies.length?(O._fontFamiliesPtr=P(O.fontFamilies),O._fontFamiliesLen=O.fontFamilies.length):(O._fontFamiliesPtr=st,O._fontFamiliesLen=0),O.fontStyle=f(O.fontStyle),O.fontSize==null&&(O.fontSize=-1),O.heightMultiplier==null&&(O.heightMultiplier=-1),O.halfLeading=O.halfLeading||!1,O.leading=O.leading||0,O.forceStrutHeight=O.forceStrutHeight||!1,A.strutStyle=O,A.textAlign=A.textAlign||s.TextAlign.Start,A.textDirection=A.textDirection||s.TextDirection.LTR,A.textHeightBehavior=A.textHeightBehavior||s.TextHeightBehavior.All,A.textStyle=s.TextStyle(A.textStyle),A.applyRoundingHack=A.applyRoundingHack!==!1,A},s.TextStyle=function(A){return A.color||(A.color=s.BLACK),A.decoration=A.decoration||0,A.decorationThickness=A.decorationThickness||0,A.decorationStyle=A.decorationStyle||s.DecorationStyle.Solid,A.textBaseline=A.textBaseline||s.TextBaseline.Alphabetic,A.fontSize==null&&(A.fontSize=-1),A.letterSpacing=A.letterSpacing||0,A.wordSpacing=A.wordSpacing||0,A.heightMultiplier==null&&(A.heightMultiplier=-1),A.halfLeading=A.halfLeading||!1,A.fontStyle=f(A.fontStyle),A};var Y={},K=s._malloc(16),lt=s._malloc(16),ut=s._malloc(16);s.ParagraphBuilder.Make=function(A,O){return k(A.textStyle),O=s.ParagraphBuilder._Make(A,O),G(A.textStyle),O},s.ParagraphBuilder.MakeFromFontProvider=function(A,O){return k(A.textStyle),O=s.ParagraphBuilder._MakeFromFontProvider(A,O),G(A.textStyle),O},s.ParagraphBuilder.MakeFromFontCollection=function(A,O){return k(A.textStyle),O=s.ParagraphBuilder._MakeFromFontCollection(A,O),G(A.textStyle),O},s.ParagraphBuilder.ShapeText=function(A,O,it){let gt=0;for(const _t of O)gt+=_t.length;if(gt!==A.length)throw"Accumulated block lengths must equal text.length";return s.ParagraphBuilder._ShapeText(A,O,it)},s.ParagraphBuilder.prototype.pushStyle=function(A){k(A),this._pushStyle(A),G(A)},s.ParagraphBuilder.prototype.pushPaintStyle=function(A,O,it){k(A),this._pushPaintStyle(A,O,it),G(A)},s.ParagraphBuilder.prototype.addPlaceholder=function(A,O,it,gt,_t){it=it||s.PlaceholderAlignment.Baseline,gt=gt||s.TextBaseline.Alphabetic,this._addPlaceholder(A||0,O||0,it,gt,_t||0)},s.ParagraphBuilder.prototype.setWordsUtf8=function(A){var O=C(A,"HEAPU32");this._setWordsUtf8(O,A&&A.length||0),w(O,A)},s.ParagraphBuilder.prototype.setWordsUtf16=function(A){var O=C(A,"HEAPU32");this._setWordsUtf16(O,A&&A.length||0),w(O,A)},s.ParagraphBuilder.prototype.setGraphemeBreaksUtf8=function(A){var O=C(A,"HEAPU32");this._setGraphemeBreaksUtf8(O,A&&A.length||0),w(O,A)},s.ParagraphBuilder.prototype.setGraphemeBreaksUtf16=function(A){var O=C(A,"HEAPU32");this._setGraphemeBreaksUtf16(O,A&&A.length||0),w(O,A)},s.ParagraphBuilder.prototype.setLineBreaksUtf8=function(A){var O=C(A,"HEAPU32");this._setLineBreaksUtf8(O,A&&A.length||0),w(O,A)},s.ParagraphBuilder.prototype.setLineBreaksUtf16=function(A){var O=C(A,"HEAPU32");this._setLineBreaksUtf16(O,A&&A.length||0),w(O,A)}})}(u),t.Td=t.Td||[],t.Td.push(function(){t.Path.prototype.op=function(s,a){return this._op(s,a)?this:null},t.Path.prototype.simplify=function(){return this._simplify()?this:null}}),t.Td=t.Td||[],t.Td.push(function(){t.Canvas.prototype.drawText=function(s,a,h,f,P){var T=Jt(s),k=t._malloc(T+1);Xt(s,rt,k,T+1),this._drawSimpleText(k,T,a,h,P,f),t._free(k)},t.Canvas.prototype.drawGlyphs=function(s,a,h,f,P,T){if(!(2*s.length<=a.length))throw"Not enough positions for the array of gyphs";t.Md(this.Kd);const k=C(s,"HEAPU16"),G=C(a,"HEAPF32");this._drawGlyphs(s.length,k,G,h,f,P,T),w(G,a),w(k,s)},t.Font.prototype.getGlyphBounds=function(s,a,h){var f=C(s,"HEAPU16"),P=t._malloc(16*s.length);return this._getGlyphWidthBounds(f,s.length,st,P,a||null),a=new Float32Array(t.HEAPU8.buffer,P,4*s.length),w(f,s),h?(h.set(a),t._free(P),h):(s=Float32Array.from(a),t._free(P),s)},t.Font.prototype.getGlyphIDs=function(s,a,h){a||(a=s.length);var f=Jt(s)+1,P=t._malloc(f);return Xt(s,rt,P,f),s=t._malloc(2*a),a=this._getGlyphIDs(P,f-1,a,s),t._free(P),0>a?(t._free(s),null):(P=new Uint16Array(t.HEAPU8.buffer,s,a),h?(h.set(P),t._free(s),h):(h=Uint16Array.from(P),t._free(s),h))},t.Font.prototype.getGlyphIntercepts=function(s,a,h,f){var P=C(s,"HEAPU16"),T=C(a,"HEAPF32");return this._getGlyphIntercepts(P,s.length,!(s&&s._ck),T,a.length,!(a&&a._ck),h,f)},t.Font.prototype.getGlyphWidths=function(s,a,h){var f=C(s,"HEAPU16"),P=t._malloc(4*s.length);return this._getGlyphWidthBounds(f,s.length,P,st,a||null),a=new Float32Array(t.HEAPU8.buffer,P,s.length),w(f,s),h?(h.set(a),t._free(P),h):(s=Float32Array.from(a),t._free(P),s)},t.FontMgr.FromData=function(){if(!arguments.length)return null;var s=arguments;if(s.length===1&&Array.isArray(s[0])&&(s=arguments[0]),!s.length)return null;for(var a=[],h=[],f=0;f<s.length;f++){var P=new Uint8Array(s[f]),T=C(P,"HEAPU8");a.push(T),h.push(P.byteLength)}return a=C(a,"HEAPU32"),h=C(h,"HEAPU32"),s=t.FontMgr._fromData(a,h,s.length),t._free(a),t._free(h),s},t.Typeface.MakeFreeTypeFaceFromData=function(s){s=new Uint8Array(s);var a=C(s,"HEAPU8");return(s=t.Typeface._MakeFreeTypeFaceFromData(a,s.byteLength))?s:null},t.Typeface.prototype.getGlyphIDs=function(s,a,h){a||(a=s.length);var f=Jt(s)+1,P=t._malloc(f);return Xt(s,rt,P,f),s=t._malloc(2*a),a=this._getGlyphIDs(P,f-1,a,s),t._free(P),0>a?(t._free(s),null):(P=new Uint16Array(t.HEAPU8.buffer,s,a),h?(h.set(P),t._free(s),h):(h=Uint16Array.from(P),t._free(s),h))},t.TextBlob.MakeOnPath=function(s,a,h,f){if(s&&s.length&&a&&a.countPoints()){if(a.countPoints()===1)return this.MakeFromText(s,h);f||(f=0);var P=h.getGlyphIDs(s);P=h.getGlyphWidths(P);var T=[];a=new t.ContourMeasureIter(a,!1,1);for(var k=a.next(),G=new Float32Array(4),Y=0;Y<s.length&&k;Y++){var K=P[Y];if(f+=K/2,f>k.length()){if(k.delete(),k=a.next(),!k){s=s.substring(0,Y);break}f=K/2}k.getPosTan(f,G);var lt=G[2],ut=G[3];T.push(lt,ut,G[0]-K/2*lt,G[1]-K/2*ut),f+=K/2}return s=this.MakeFromRSXform(s,T,h),k&&k.delete(),a.delete(),s}},t.TextBlob.MakeFromRSXform=function(s,a,h){var f=Jt(s)+1,P=t._malloc(f);return Xt(s,rt,P,f),s=C(a,"HEAPF32"),h=t.TextBlob._MakeFromRSXform(P,f-1,s,h),t._free(P),h||null},t.TextBlob.MakeFromRSXformGlyphs=function(s,a,h){var f=C(s,"HEAPU16");return a=C(a,"HEAPF32"),h=t.TextBlob._MakeFromRSXformGlyphs(f,2*s.length,a,h),w(f,s),h||null},t.TextBlob.MakeFromGlyphs=function(s,a){var h=C(s,"HEAPU16");return a=t.TextBlob._MakeFromGlyphs(h,2*s.length,a),w(h,s),a||null},t.TextBlob.MakeFromText=function(s,a){var h=Jt(s)+1,f=t._malloc(h);return Xt(s,rt,f,h),s=t.TextBlob._MakeFromText(f,h-1,a),t._free(f),s||null},t.MallocGlyphIDs=function(s){return t.Malloc(Uint16Array,s)}}),t.Td=t.Td||[],t.Td.push(function(){t.MakePicture=function(s){s=new Uint8Array(s);var a=t._malloc(s.byteLength);return t.HEAPU8.set(s,a),(s=t._MakePicture(a,s.byteLength))?s:null}}),t.Td=t.Td||[],t.Td.push(function(){t.RuntimeEffect.Make=function(s,a){return t.RuntimeEffect._Make(s,{onError:a||function(h){console.log("RuntimeEffect error",h)}})},t.RuntimeEffect.MakeForBlender=function(s,a){return t.RuntimeEffect._MakeForBlender(s,{onError:a||function(h){console.log("RuntimeEffect error",h)}})},t.RuntimeEffect.prototype.makeShader=function(s,a){var h=!s._ck,f=C(s,"HEAPF32");return a=D(a),this._makeShader(f,4*s.length,h,a)},t.RuntimeEffect.prototype.makeShaderWithChildren=function(s,a,h){var f=!s._ck,P=C(s,"HEAPF32");h=D(h);for(var T=[],k=0;k<a.length;k++)T.push(a[k].Jd.Rd);return a=C(T,"HEAPU32"),this._makeShaderWithChildren(P,4*s.length,f,a,T.length,h)},t.RuntimeEffect.prototype.makeBlender=function(s){var a=!s._ck,h=C(s,"HEAPF32");return this._makeBlender(h,4*s.length,a)}}),function(){function s(N){for(var d=0;d<N.length;d++)if(N[d]!==void 0&&!Number.isFinite(N[d]))return!1;return!0}function a(N){var d=t.getColorComponents(N);N=d[0];var S=d[1],M=d[2];return d=d[3],d===1?(N=N.toString(16).toLowerCase(),S=S.toString(16).toLowerCase(),M=M.toString(16).toLowerCase(),N=N.length===1?"0"+N:N,S=S.length===1?"0"+S:S,M=M.length===1?"0"+M:M,"#"+N+S+M):(d=d===0||d===1?d:d.toFixed(8),"rgba("+N+", "+S+", "+M+", "+d+")")}function h(N){return t.parseColorString(N,jt)}function f(N){if(N=Ht.exec(N),!N)return null;var d=parseFloat(N[4]),S=16;switch(N[5]){case"em":case"rem":S=16*d;break;case"pt":S=4*d/3;break;case"px":S=d;break;case"pc":S=16*d;break;case"in":S=96*d;break;case"cm":S=96*d/2.54;break;case"mm":S=3.7795275590551185*d;break;case"q":S=.9448818897637796*d;break;case"%":S=.21333333333333335*d}return{style:N[1],variant:N[2],weight:N[3],sizePx:S,family:N[6].trim()}}function P(N){this.Ld=N,this.Od=new t.Paint,this.Od.setAntiAlias(!0),this.Od.setStrokeMiter(10),this.Od.setStrokeCap(t.StrokeCap.Butt),this.Od.setStrokeJoin(t.StrokeJoin.Miter),this.Re="10px monospace",this.me=new t.Font(null,10),this.me.setSubpixel(!0),this.ae=this.ge=t.BLACK,this.ve=0,this.Je=t.TRANSPARENT,this.xe=this.we=0,this.Ke=this.ie=1,this.Ie=0,this.ue=[],this.Nd=t.BlendMode.SrcOver,this.Od.setStrokeWidth(this.Ke),this.Od.setBlendMode(this.Nd),this.Qd=new t.Path,this.Sd=t.Matrix.identity(),this.lf=[],this.Be=[],this.le=function(){this.Qd.delete(),this.Od.delete(),this.me.delete(),this.Be.forEach(function(d){d.le()})},Object.defineProperty(this,"currentTransform",{enumerable:!0,get:function(){return{a:this.Sd[0],c:this.Sd[1],e:this.Sd[2],b:this.Sd[3],d:this.Sd[4],f:this.Sd[5]}},set:function(d){d.a&&this.setTransform(d.a,d.b,d.c,d.d,d.e,d.f)}}),Object.defineProperty(this,"fillStyle",{enumerable:!0,get:function(){return o(this.ae)?a(this.ae):this.ae},set:function(d){typeof d=="string"?this.ae=h(d):d.te&&(this.ae=d)}}),Object.defineProperty(this,"font",{enumerable:!0,get:function(){return this.Re},set:function(d){var S=f(d),M=S.family;S.typeface=Ot[M]?Ot[M][(S.style||"normal")+"|"+(S.variant||"normal")+"|"+(S.weight||"normal")]||Ot[M]["*"]:null,S&&(this.me.setSize(S.sizePx),this.me.setTypeface(S.typeface),this.Re=d)}}),Object.defineProperty(this,"globalAlpha",{enumerable:!0,get:function(){return this.ie},set:function(d){!isFinite(d)||0>d||1<d||(this.ie=d)}}),Object.defineProperty(this,"globalCompositeOperation",{enumerable:!0,get:function(){switch(this.Nd){case t.BlendMode.SrcOver:return"source-over";case t.BlendMode.DstOver:return"destination-over";case t.BlendMode.Src:return"copy";case t.BlendMode.Dst:return"destination";case t.BlendMode.Clear:return"clear";case t.BlendMode.SrcIn:return"source-in";case t.BlendMode.DstIn:return"destination-in";case t.BlendMode.SrcOut:return"source-out";case t.BlendMode.DstOut:return"destination-out";case t.BlendMode.SrcATop:return"source-atop";case t.BlendMode.DstATop:return"destination-atop";case t.BlendMode.Xor:return"xor";case t.BlendMode.Plus:return"lighter";case t.BlendMode.Multiply:return"multiply";case t.BlendMode.Screen:return"screen";case t.BlendMode.Overlay:return"overlay";case t.BlendMode.Darken:return"darken";case t.BlendMode.Lighten:return"lighten";case t.BlendMode.ColorDodge:return"color-dodge";case t.BlendMode.ColorBurn:return"color-burn";case t.BlendMode.HardLight:return"hard-light";case t.BlendMode.SoftLight:return"soft-light";case t.BlendMode.Difference:return"difference";case t.BlendMode.Exclusion:return"exclusion";case t.BlendMode.Hue:return"hue";case t.BlendMode.Saturation:return"saturation";case t.BlendMode.Color:return"color";case t.BlendMode.Luminosity:return"luminosity"}},set:function(d){switch(d){case"source-over":this.Nd=t.BlendMode.SrcOver;break;case"destination-over":this.Nd=t.BlendMode.DstOver;break;case"copy":this.Nd=t.BlendMode.Src;break;case"destination":this.Nd=t.BlendMode.Dst;break;case"clear":this.Nd=t.BlendMode.Clear;break;case"source-in":this.Nd=t.BlendMode.SrcIn;break;case"destination-in":this.Nd=t.BlendMode.DstIn;break;case"source-out":this.Nd=t.BlendMode.SrcOut;break;case"destination-out":this.Nd=t.BlendMode.DstOut;break;case"source-atop":this.Nd=t.BlendMode.SrcATop;break;case"destination-atop":this.Nd=t.BlendMode.DstATop;break;case"xor":this.Nd=t.BlendMode.Xor;break;case"lighter":this.Nd=t.BlendMode.Plus;break;case"plus-lighter":this.Nd=t.BlendMode.Plus;break;case"plus-darker":throw"plus-darker is not supported";case"multiply":this.Nd=t.BlendMode.Multiply;break;case"screen":this.Nd=t.BlendMode.Screen;break;case"overlay":this.Nd=t.BlendMode.Overlay;break;case"darken":this.Nd=t.BlendMode.Darken;break;case"lighten":this.Nd=t.BlendMode.Lighten;break;case"color-dodge":this.Nd=t.BlendMode.ColorDodge;break;case"color-burn":this.Nd=t.BlendMode.ColorBurn;break;case"hard-light":this.Nd=t.BlendMode.HardLight;break;case"soft-light":this.Nd=t.BlendMode.SoftLight;break;case"difference":this.Nd=t.BlendMode.Difference;break;case"exclusion":this.Nd=t.BlendMode.Exclusion;break;case"hue":this.Nd=t.BlendMode.Hue;break;case"saturation":this.Nd=t.BlendMode.Saturation;break;case"color":this.Nd=t.BlendMode.Color;break;case"luminosity":this.Nd=t.BlendMode.Luminosity;break;default:return}this.Od.setBlendMode(this.Nd)}}),Object.defineProperty(this,"imageSmoothingEnabled",{enumerable:!0,get:function(){return!0},set:function(){}}),Object.defineProperty(this,"imageSmoothingQuality",{enumerable:!0,get:function(){return"high"},set:function(){}}),Object.defineProperty(this,"lineCap",{enumerable:!0,get:function(){switch(this.Od.getStrokeCap()){case t.StrokeCap.Butt:return"butt";case t.StrokeCap.Round:return"round";case t.StrokeCap.Square:return"square"}},set:function(d){switch(d){case"butt":this.Od.setStrokeCap(t.StrokeCap.Butt);break;case"round":this.Od.setStrokeCap(t.StrokeCap.Round);break;case"square":this.Od.setStrokeCap(t.StrokeCap.Square)}}}),Object.defineProperty(this,"lineDashOffset",{enumerable:!0,get:function(){return this.Ie},set:function(d){isFinite(d)&&(this.Ie=d)}}),Object.defineProperty(this,"lineJoin",{enumerable:!0,get:function(){switch(this.Od.getStrokeJoin()){case t.StrokeJoin.Miter:return"miter";case t.StrokeJoin.Round:return"round";case t.StrokeJoin.Bevel:return"bevel"}},set:function(d){switch(d){case"miter":this.Od.setStrokeJoin(t.StrokeJoin.Miter);break;case"round":this.Od.setStrokeJoin(t.StrokeJoin.Round);break;case"bevel":this.Od.setStrokeJoin(t.StrokeJoin.Bevel)}}}),Object.defineProperty(this,"lineWidth",{enumerable:!0,get:function(){return this.Od.getStrokeWidth()},set:function(d){0>=d||!d||(this.Ke=d,this.Od.setStrokeWidth(d))}}),Object.defineProperty(this,"miterLimit",{enumerable:!0,get:function(){return this.Od.getStrokeMiter()},set:function(d){0>=d||!d||this.Od.setStrokeMiter(d)}}),Object.defineProperty(this,"shadowBlur",{enumerable:!0,get:function(){return this.ve},set:function(d){0>d||!isFinite(d)||(this.ve=d)}}),Object.defineProperty(this,"shadowColor",{enumerable:!0,get:function(){return a(this.Je)},set:function(d){this.Je=h(d)}}),Object.defineProperty(this,"shadowOffsetX",{enumerable:!0,get:function(){return this.we},set:function(d){isFinite(d)&&(this.we=d)}}),Object.defineProperty(this,"shadowOffsetY",{enumerable:!0,get:function(){return this.xe},set:function(d){isFinite(d)&&(this.xe=d)}}),Object.defineProperty(this,"strokeStyle",{enumerable:!0,get:function(){return a(this.ge)},set:function(d){typeof d=="string"?this.ge=h(d):d.te&&(this.ge=d)}}),this.arc=function(d,S,M,R,I,B){A(this.Qd,d,S,M,M,0,R,I,B)},this.arcTo=function(d,S,M,R,I){K(this.Qd,d,S,M,R,I)},this.beginPath=function(){this.Qd.delete(),this.Qd=new t.Path},this.bezierCurveTo=function(d,S,M,R,I,B){var j=this.Qd;s([d,S,M,R,I,B])&&(j.isEmpty()&&j.moveTo(d,S),j.cubicTo(d,S,M,R,I,B))},this.clearRect=function(d,S,M,R){this.Od.setStyle(t.PaintStyle.Fill),this.Od.setBlendMode(t.BlendMode.Clear),this.Ld.drawRect(t.XYWHRect(d,S,M,R),this.Od),this.Od.setBlendMode(this.Nd)},this.clip=function(d,S){typeof d=="string"?(S=d,d=this.Qd):d&&d.af&&(d=d.Ud),d||(d=this.Qd),d=d.copy(),S&&S.toLowerCase()==="evenodd"?d.setFillType(t.FillType.EvenOdd):d.setFillType(t.FillType.Winding),this.Ld.clipPath(d,t.ClipOp.Intersect,!0),d.delete()},this.closePath=function(){lt(this.Qd)},this.createImageData=function(){if(arguments.length===1){var d=arguments[0];return new G(new Uint8ClampedArray(4*d.width*d.height),d.width,d.height)}if(arguments.length===2){d=arguments[0];var S=arguments[1];return new G(new Uint8ClampedArray(4*d*S),d,S)}throw"createImageData expects 1 or 2 arguments, got "+arguments.length},this.createLinearGradient=function(d,S,M,R){if(s(arguments)){var I=new Y(d,S,M,R);return this.Be.push(I),I}},this.createPattern=function(d,S){return d=new gt(d,S),this.Be.push(d),d},this.createRadialGradient=function(d,S,M,R,I,B){if(s(arguments)){var j=new _t(d,S,M,R,I,B);return this.Be.push(j),j}},this.drawImage=function(d){d instanceof k&&(d=d.tf());var S=this.Qe();if(arguments.length===3||arguments.length===5)var M=t.XYWHRect(arguments[1],arguments[2],arguments[3]||d.width(),arguments[4]||d.height()),R=t.XYWHRect(0,0,d.width(),d.height());else if(arguments.length===9)M=t.XYWHRect(arguments[5],arguments[6],arguments[7],arguments[8]),R=t.XYWHRect(arguments[1],arguments[2],arguments[3],arguments[4]);else throw"invalid number of args for drawImage, need 3, 5, or 9; got "+arguments.length;this.Ld.drawImageRect(d,R,M,S,!1),S.dispose()},this.ellipse=function(d,S,M,R,I,B,j,St){A(this.Qd,d,S,M,R,I,B,j,St)},this.Qe=function(){var d=this.Od.copy();if(d.setStyle(t.PaintStyle.Fill),o(this.ae)){var S=t.multiplyByAlpha(this.ae,this.ie);d.setColor(S)}else S=this.ae.te(this.Sd),d.setColor(t.Color(0,0,0,this.ie)),d.setShader(S);return d.dispose=function(){this.delete()},d},this.fill=function(d,S){if(typeof d=="string"?(S=d,d=this.Qd):d&&d.af&&(d=d.Ud),S==="evenodd")this.Qd.setFillType(t.FillType.EvenOdd);else{if(S!=="nonzero"&&S)throw"invalid fill rule";this.Qd.setFillType(t.FillType.Winding)}d||(d=this.Qd),S=this.Qe();var M=this.ye(S);M&&(this.Ld.save(),this.re(),this.Ld.drawPath(d,M),this.Ld.restore(),M.dispose()),this.Ld.drawPath(d,S),S.dispose()},this.fillRect=function(d,S,M,R){var I=this.Qe(),B=this.ye(I);B&&(this.Ld.save(),this.re(),this.Ld.drawRect(t.XYWHRect(d,S,M,R),B),this.Ld.restore(),B.dispose()),this.Ld.drawRect(t.XYWHRect(d,S,M,R),I),I.dispose()},this.fillText=function(d,S,M){var R=this.Qe();d=t.TextBlob.MakeFromText(d,this.me);var I=this.ye(R);I&&(this.Ld.save(),this.re(),this.Ld.drawTextBlob(d,S,M,I),this.Ld.restore(),I.dispose()),this.Ld.drawTextBlob(d,S,M,R),d.delete(),R.dispose()},this.getImageData=function(d,S,M,R){return(d=this.Ld.readPixels(d,S,{width:M,height:R,colorType:t.ColorType.RGBA_8888,alphaType:t.AlphaType.Unpremul,colorSpace:t.ColorSpace.SRGB}))?new G(new Uint8ClampedArray(d.buffer),M,R):null},this.getLineDash=function(){return this.ue.slice()},this.mf=function(d){var S=t.Matrix.invert(this.Sd);return t.Matrix.mapPoints(S,d),d},this.isPointInPath=function(d,S,M){var R=arguments;if(R.length===3)var I=this.Qd;else if(R.length===4)I=R[0],d=R[1],S=R[2],M=R[3];else throw"invalid arg count, need 3 or 4, got "+R.length;return!isFinite(d)||!isFinite(S)||(M=M||"nonzero",M!=="nonzero"&&M!=="evenodd")?!1:(R=this.mf([d,S]),d=R[0],S=R[1],I.setFillType(M==="nonzero"?t.FillType.Winding:t.FillType.EvenOdd),I.contains(d,S))},this.isPointInStroke=function(d,S){var M=arguments;if(M.length===2)var R=this.Qd;else if(M.length===3)R=M[0],d=M[1],S=M[2];else throw"invalid arg count, need 2 or 3, got "+M.length;return!isFinite(d)||!isFinite(S)?!1:(M=this.mf([d,S]),d=M[0],S=M[1],R=R.copy(),R.setFillType(t.FillType.Winding),R.stroke({width:this.lineWidth,miter_limit:this.miterLimit,cap:this.Od.getStrokeCap(),join:this.Od.getStrokeJoin(),precision:.3}),M=R.contains(d,S),R.delete(),M)},this.lineTo=function(d,S){O(this.Qd,d,S)},this.measureText=function(d){d=this.me.getGlyphIDs(d),d=this.me.getGlyphWidths(d);let S=0;for(const M of d)S+=M;return{width:S}},this.moveTo=function(d,S){var M=this.Qd;s([d,S])&&M.moveTo(d,S)},this.putImageData=function(d,S,M,R,I,B,j){if(s([S,M,R,I,B,j])){if(R===void 0)this.Ld.writePixels(d.data,d.width,d.height,S,M);else if(R=R||0,I=I||0,B=B||d.width,j=j||d.height,0>B&&(R+=B,B=Math.abs(B)),0>j&&(I+=j,j=Math.abs(j)),0>R&&(B+=R,R=0),0>I&&(j+=I,I=0),!(0>=B||0>=j)){d=t.MakeImage({width:d.width,height:d.height,alphaType:t.AlphaType.Unpremul,colorType:t.ColorType.RGBA_8888,colorSpace:t.ColorSpace.SRGB},d.data,4*d.width);var St=t.XYWHRect(R,I,B,j);S=t.XYWHRect(S+R,M+I,B,j),M=t.Matrix.invert(this.Sd),this.Ld.save(),this.Ld.concat(M),this.Ld.drawImageRect(d,St,S,null,!1),this.Ld.restore(),d.delete()}}},this.quadraticCurveTo=function(d,S,M,R){var I=this.Qd;s([d,S,M,R])&&(I.isEmpty()&&I.moveTo(d,S),I.quadTo(d,S,M,R))},this.rect=function(d,S,M,R){var I=this.Qd;d=t.XYWHRect(d,S,M,R),s(d)&&I.addRect(d)},this.resetTransform=function(){this.Qd.transform(this.Sd);var d=t.Matrix.invert(this.Sd);this.Ld.concat(d),this.Sd=this.Ld.getTotalMatrix()},this.restore=function(){var d=this.lf.pop();if(d){var S=t.Matrix.multiply(this.Sd,t.Matrix.invert(d.Jf));this.Qd.transform(S),this.Od.delete(),this.Od=d.ag,this.ue=d.Zf,this.Ke=d.mg,this.ge=d.lg,this.ae=d.fs,this.we=d.jg,this.xe=d.kg,this.ve=d.sb,this.Je=d.ig,this.ie=d.ga,this.Nd=d.Qf,this.Ie=d.$f,this.Re=d.Pf,this.Ld.restore(),this.Sd=this.Ld.getTotalMatrix()}},this.rotate=function(d){if(isFinite(d)){var S=t.Matrix.rotated(-d);this.Qd.transform(S),this.Ld.rotate(d/Math.PI*180,0,0),this.Sd=this.Ld.getTotalMatrix()}},this.save=function(){if(this.ae.se){var d=this.ae.se();this.Be.push(d)}else d=this.ae;if(this.ge.se){var S=this.ge.se();this.Be.push(S)}else S=this.ge;this.lf.push({Jf:this.Sd.slice(),Zf:this.ue.slice(),mg:this.Ke,lg:S,fs:d,jg:this.we,kg:this.xe,sb:this.ve,ig:this.Je,ga:this.ie,$f:this.Ie,Qf:this.Nd,ag:this.Od.copy(),Pf:this.Re}),this.Ld.save()},this.scale=function(d,S){if(s(arguments)){var M=t.Matrix.scaled(1/d,1/S);this.Qd.transform(M),this.Ld.scale(d,S),this.Sd=this.Ld.getTotalMatrix()}},this.setLineDash=function(d){for(var S=0;S<d.length;S++)if(!isFinite(d[S])||0>d[S])return;d.length%2===1&&Array.prototype.push.apply(d,d),this.ue=d},this.setTransform=function(d,S,M,R,I,B){s(arguments)&&(this.resetTransform(),this.transform(d,S,M,R,I,B))},this.re=function(){var d=t.Matrix.invert(this.Sd);this.Ld.concat(d),this.Ld.concat(t.Matrix.translated(this.we,this.xe)),this.Ld.concat(this.Sd)},this.ye=function(d){var S=t.multiplyByAlpha(this.Je,this.ie);if(!t.getColorComponents(S)[3]||!(this.ve||this.xe||this.we))return null;d=d.copy(),d.setColor(S);var M=t.MaskFilter.MakeBlur(t.BlurStyle.Normal,this.ve/2,!1);return d.setMaskFilter(M),d.dispose=function(){M.delete(),this.delete()},d},this.cf=function(){var d=this.Od.copy();if(d.setStyle(t.PaintStyle.Stroke),o(this.ge)){var S=t.multiplyByAlpha(this.ge,this.ie);d.setColor(S)}else S=this.ge.te(this.Sd),d.setColor(t.Color(0,0,0,this.ie)),d.setShader(S);if(d.setStrokeWidth(this.Ke),this.ue.length){var M=t.PathEffect.MakeDash(this.ue,this.Ie);d.setPathEffect(M)}return d.dispose=function(){M&&M.delete(),this.delete()},d},this.stroke=function(d){d=d?d.Ud:this.Qd;var S=this.cf(),M=this.ye(S);M&&(this.Ld.save(),this.re(),this.Ld.drawPath(d,M),this.Ld.restore(),M.dispose()),this.Ld.drawPath(d,S),S.dispose()},this.strokeRect=function(d,S,M,R){var I=this.cf(),B=this.ye(I);B&&(this.Ld.save(),this.re(),this.Ld.drawRect(t.XYWHRect(d,S,M,R),B),this.Ld.restore(),B.dispose()),this.Ld.drawRect(t.XYWHRect(d,S,M,R),I),I.dispose()},this.strokeText=function(d,S,M){var R=this.cf();d=t.TextBlob.MakeFromText(d,this.me);var I=this.ye(R);I&&(this.Ld.save(),this.re(),this.Ld.drawTextBlob(d,S,M,I),this.Ld.restore(),I.dispose()),this.Ld.drawTextBlob(d,S,M,R),d.delete(),R.dispose()},this.translate=function(d,S){if(s(arguments)){var M=t.Matrix.translated(-d,-S);this.Qd.transform(M),this.Ld.translate(d,S),this.Sd=this.Ld.getTotalMatrix()}},this.transform=function(d,S,M,R,I,B){d=[d,M,I,S,R,B,0,0,1],S=t.Matrix.invert(d),this.Qd.transform(S),this.Ld.concat(d),this.Sd=this.Ld.getTotalMatrix()},this.addHitRegion=function(){},this.clearHitRegions=function(){},this.drawFocusIfNeeded=function(){},this.removeHitRegion=function(){},this.scrollPathIntoView=function(){},Object.defineProperty(this,"canvas",{value:null,writable:!1})}function T(N){this.df=N,this.Kd=new P(N.getCanvas()),this.Se=[],this.decodeImage=function(d){if(d=t.MakeImageFromEncoded(d),!d)throw"Invalid input";return this.Se.push(d),new k(d)},this.loadFont=function(d,S){if(d=t.Typeface.MakeFreeTypeFaceFromData(d),!d)return null;this.Se.push(d);var M=(S.style||"normal")+"|"+(S.variant||"normal")+"|"+(S.weight||"normal");S=S.family,Ot[S]||(Ot[S]={"*":d}),Ot[S][M]=d},this.makePath2D=function(d){return d=new it(d),this.Se.push(d.Ud),d},this.getContext=function(d){return d==="2d"?this.Kd:null},this.toDataURL=function(d,S){this.df.flush();var M=this.df.makeImageSnapshot();if(M){d=d||"image/png";var R=t.ImageFormat.PNG;if(d==="image/jpeg"&&(R=t.ImageFormat.JPEG),S=M.encodeToBytes(R,S||.92)){if(M.delete(),d="data:"+d+";base64,",typeof Buffer<"u")S=Buffer.from(S).toString("base64");else{M=0,R=S.length;for(var I="",B;M<R;)B=S.slice(M,Math.min(M+32768,R)),I+=String.fromCharCode.apply(null,B),M+=32768;S=btoa(I)}return d+S}}},this.dispose=function(){this.Kd.le(),this.Se.forEach(function(d){d.delete()}),this.df.dispose()}}function k(N){this.width=N.width(),this.height=N.height(),this.naturalWidth=this.width,this.naturalHeight=this.height,this.tf=function(){return N}}function G(N,d,S){if(!d||S===0)throw"invalid dimensions, width and height must be non-zero";if(N.length%4)throw"arr must be a multiple of 4";S=S||N.length/(4*d),Object.defineProperty(this,"data",{value:N,writable:!1}),Object.defineProperty(this,"height",{value:S,writable:!1}),Object.defineProperty(this,"width",{value:d,writable:!1})}function Y(N,d,S,M){this.Wd=null,this.ce=[],this.Zd=[],this.addColorStop=function(R,I){if(0>R||1<R||!isFinite(R))throw"offset must be between 0 and 1 inclusively";I=h(I);var B=this.Zd.indexOf(R);if(B!==-1)this.ce[B]=I;else{for(B=0;B<this.Zd.length&&!(this.Zd[B]>R);B++);this.Zd.splice(B,0,R),this.ce.splice(B,0,I)}},this.se=function(){var R=new Y(N,d,S,M);return R.ce=this.ce.slice(),R.Zd=this.Zd.slice(),R},this.le=function(){this.Wd&&(this.Wd.delete(),this.Wd=null)},this.te=function(R){var I=[N,d,S,M];t.Matrix.mapPoints(R,I),R=I[0];var B=I[1],j=I[2];return I=I[3],this.le(),this.Wd=t.Shader.MakeLinearGradient([R,B],[j,I],this.ce,this.Zd,t.TileMode.Clamp)}}function K(N,d,S,M,R,I){if(s([d,S,M,R,I])){if(0>I)throw"radii cannot be negative";N.isEmpty()&&N.moveTo(d,S),N.arcToTangent(d,S,M,R,I)}}function lt(N){if(!N.isEmpty()){var d=N.getBounds();(d[3]-d[1]||d[2]-d[0])&&N.close()}}function ut(N,d,S,M,R,I,B){B=(B-I)/Math.PI*180,I=I/Math.PI*180,d=t.LTRBRect(d-M,S-R,d+M,S+R),1e-5>Math.abs(Math.abs(B)-360)?(S=B/2,N.arcToOval(d,I,S,!1),N.arcToOval(d,I+S,S,!1)):N.arcToOval(d,I,B,!1)}function A(N,d,S,M,R,I,B,j,St){if(s([d,S,M,R,I,B,j])){if(0>M||0>R)throw"radii cannot be negative";var At=2*Math.PI,ne=B%At;0>ne&&(ne+=At);var Ve=ne-B;B=ne,j+=Ve,!St&&j-B>=At?j=B+At:St&&B-j>=At?j=B-At:!St&&B>j?j=B+(At-(B-j)%At):St&&B<j&&(j=B-(At-(j-B)%At)),I?(St=t.Matrix.rotated(I,d,S),I=t.Matrix.rotated(-I,d,S),N.transform(I),ut(N,d,S,M,R,B,j),N.transform(St)):ut(N,d,S,M,R,B,j)}}function O(N,d,S){s([d,S])&&(N.isEmpty()&&N.moveTo(d,S),N.lineTo(d,S))}function it(N){this.Ud=null,this.Ud=typeof N=="string"?t.Path.MakeFromSVGString(N):N&&N.af?N.Ud.copy():new t.Path,this.af=function(){return this.Ud},this.addPath=function(d,S){S||(S={a:1,c:0,e:0,b:0,d:1,f:0}),this.Ud.addPath(d.Ud,[S.a,S.c,S.e,S.b,S.d,S.f])},this.arc=function(d,S,M,R,I,B){A(this.Ud,d,S,M,M,0,R,I,B)},this.arcTo=function(d,S,M,R,I){K(this.Ud,d,S,M,R,I)},this.bezierCurveTo=function(d,S,M,R,I,B){var j=this.Ud;s([d,S,M,R,I,B])&&(j.isEmpty()&&j.moveTo(d,S),j.cubicTo(d,S,M,R,I,B))},this.closePath=function(){lt(this.Ud)},this.ellipse=function(d,S,M,R,I,B,j,St){A(this.Ud,d,S,M,R,I,B,j,St)},this.lineTo=function(d,S){O(this.Ud,d,S)},this.moveTo=function(d,S){var M=this.Ud;s([d,S])&&M.moveTo(d,S)},this.quadraticCurveTo=function(d,S,M,R){var I=this.Ud;s([d,S,M,R])&&(I.isEmpty()&&I.moveTo(d,S),I.quadTo(d,S,M,R))},this.rect=function(d,S,M,R){var I=this.Ud;d=t.XYWHRect(d,S,M,R),s(d)&&I.addRect(d)}}function gt(N,d){switch(this.Wd=null,N instanceof k&&(N=N.tf()),this.Ef=N,this._transform=t.Matrix.identity(),d===""&&(d="repeat"),d){case"repeat-x":this.ze=t.TileMode.Repeat,this.Ae=t.TileMode.Decal;break;case"repeat-y":this.ze=t.TileMode.Decal,this.Ae=t.TileMode.Repeat;break;case"repeat":this.Ae=this.ze=t.TileMode.Repeat;break;case"no-repeat":this.Ae=this.ze=t.TileMode.Decal;break;default:throw"invalid repetition mode "+d}this.setTransform=function(S){S=[S.a,S.c,S.e,S.b,S.d,S.f,0,0,1],s(S)&&(this._transform=S)},this.se=function(){var S=new gt;return S.ze=this.ze,S.Ae=this.Ae,S},this.le=function(){this.Wd&&(this.Wd.delete(),this.Wd=null)},this.te=function(){return this.le(),this.Wd=this.Ef.makeShaderCubic(this.ze,this.Ae,.3333333333333333,.3333333333333333,this._transform)}}function _t(N,d,S,M,R,I){this.Wd=null,this.ce=[],this.Zd=[],this.addColorStop=function(B,j){if(0>B||1<B||!isFinite(B))throw"offset must be between 0 and 1 inclusively";j=h(j);var St=this.Zd.indexOf(B);if(St!==-1)this.ce[St]=j;else{for(St=0;St<this.Zd.length&&!(this.Zd[St]>B);St++);this.Zd.splice(St,0,B),this.ce.splice(St,0,j)}},this.se=function(){var B=new _t(N,d,S,M,R,I);return B.ce=this.ce.slice(),B.Zd=this.Zd.slice(),B},this.le=function(){this.Wd&&(this.Wd.delete(),this.Wd=null)},this.te=function(B){var j=[N,d,M,R];t.Matrix.mapPoints(B,j);var St=j[0],At=j[1],ne=j[2];j=j[3];var Ve=(Math.abs(B[0])+Math.abs(B[4]))/2;return B=S*Ve,Ve*=I,this.le(),this.Wd=t.Shader.MakeTwoPointConicalGradient([St,At],B,[ne,j],Ve,this.ce,this.Zd,t.TileMode.Clamp)}}t._testing={};var jt={aliceblue:Float32Array.of(.941,.973,1,1),antiquewhite:Float32Array.of(.98,.922,.843,1),aqua:Float32Array.of(0,1,1,1),aquamarine:Float32Array.of(.498,1,.831,1),azure:Float32Array.of(.941,1,1,1),beige:Float32Array.of(.961,.961,.863,1),bisque:Float32Array.of(1,.894,.769,1),black:Float32Array.of(0,0,0,1),blanchedalmond:Float32Array.of(1,.922,.804,1),blue:Float32Array.of(0,0,1,1),blueviolet:Float32Array.of(.541,.169,.886,1),brown:Float32Array.of(.647,.165,.165,1),burlywood:Float32Array.of(.871,.722,.529,1),cadetblue:Float32Array.of(.373,.62,.627,1),chartreuse:Float32Array.of(.498,1,0,1),chocolate:Float32Array.of(.824,.412,.118,1),coral:Float32Array.of(1,.498,.314,1),cornflowerblue:Float32Array.of(.392,.584,.929,1),cornsilk:Float32Array.of(1,.973,.863,1),crimson:Float32Array.of(.863,.078,.235,1),cyan:Float32Array.of(0,1,1,1),darkblue:Float32Array.of(0,0,.545,1),darkcyan:Float32Array.of(0,.545,.545,1),darkgoldenrod:Float32Array.of(.722,.525,.043,1),darkgray:Float32Array.of(.663,.663,.663,1),darkgreen:Float32Array.of(0,.392,0,1),darkgrey:Float32Array.of(.663,.663,.663,1),darkkhaki:Float32Array.of(.741,.718,.42,1),darkmagenta:Float32Array.of(.545,0,.545,1),darkolivegreen:Float32Array.of(.333,.42,.184,1),darkorange:Float32Array.of(1,.549,0,1),darkorchid:Float32Array.of(.6,.196,.8,1),darkred:Float32Array.of(.545,0,0,1),darksalmon:Float32Array.of(.914,.588,.478,1),darkseagreen:Float32Array.of(.561,.737,.561,1),darkslateblue:Float32Array.of(.282,.239,.545,1),darkslategray:Float32Array.of(.184,.31,.31,1),darkslategrey:Float32Array.of(.184,.31,.31,1),darkturquoise:Float32Array.of(0,.808,.82,1),darkviolet:Float32Array.of(.58,0,.827,1),deeppink:Float32Array.of(1,.078,.576,1),deepskyblue:Float32Array.of(0,.749,1,1),dimgray:Float32Array.of(.412,.412,.412,1),dimgrey:Float32Array.of(.412,.412,.412,1),dodgerblue:Float32Array.of(.118,.565,1,1),firebrick:Float32Array.of(.698,.133,.133,1),floralwhite:Float32Array.of(1,.98,.941,1),forestgreen:Float32Array.of(.133,.545,.133,1),fuchsia:Float32Array.of(1,0,1,1),gainsboro:Float32Array.of(.863,.863,.863,1),ghostwhite:Float32Array.of(.973,.973,1,1),gold:Float32Array.of(1,.843,0,1),goldenrod:Float32Array.of(.855,.647,.125,1),gray:Float32Array.of(.502,.502,.502,1),green:Float32Array.of(0,.502,0,1),greenyellow:Float32Array.of(.678,1,.184,1),grey:Float32Array.of(.502,.502,.502,1),honeydew:Float32Array.of(.941,1,.941,1),hotpink:Float32Array.of(1,.412,.706,1),indianred:Float32Array.of(.804,.361,.361,1),indigo:Float32Array.of(.294,0,.51,1),ivory:Float32Array.of(1,1,.941,1),khaki:Float32Array.of(.941,.902,.549,1),lavender:Float32Array.of(.902,.902,.98,1),lavenderblush:Float32Array.of(1,.941,.961,1),lawngreen:Float32Array.of(.486,.988,0,1),lemonchiffon:Float32Array.of(1,.98,.804,1),lightblue:Float32Array.of(.678,.847,.902,1),lightcoral:Float32Array.of(.941,.502,.502,1),lightcyan:Float32Array.of(.878,1,1,1),lightgoldenrodyellow:Float32Array.of(.98,.98,.824,1),lightgray:Float32Array.of(.827,.827,.827,1),lightgreen:Float32Array.of(.565,.933,.565,1),lightgrey:Float32Array.of(.827,.827,.827,1),lightpink:Float32Array.of(1,.714,.757,1),lightsalmon:Float32Array.of(1,.627,.478,1),lightseagreen:Float32Array.of(.125,.698,.667,1),lightskyblue:Float32Array.of(.529,.808,.98,1),lightslategray:Float32Array.of(.467,.533,.6,1),lightslategrey:Float32Array.of(.467,.533,.6,1),lightsteelblue:Float32Array.of(.69,.769,.871,1),lightyellow:Float32Array.of(1,1,.878,1),lime:Float32Array.of(0,1,0,1),limegreen:Float32Array.of(.196,.804,.196,1),linen:Float32Array.of(.98,.941,.902,1),magenta:Float32Array.of(1,0,1,1),maroon:Float32Array.of(.502,0,0,1),mediumaquamarine:Float32Array.of(.4,.804,.667,1),mediumblue:Float32Array.of(0,0,.804,1),mediumorchid:Float32Array.of(.729,.333,.827,1),mediumpurple:Float32Array.of(.576,.439,.859,1),mediumseagreen:Float32Array.of(.235,.702,.443,1),mediumslateblue:Float32Array.of(.482,.408,.933,1),mediumspringgreen:Float32Array.of(0,.98,.604,1),mediumturquoise:Float32Array.of(.282,.82,.8,1),mediumvioletred:Float32Array.of(.78,.082,.522,1),midnightblue:Float32Array.of(.098,.098,.439,1),mintcream:Float32Array.of(.961,1,.98,1),mistyrose:Float32Array.of(1,.894,.882,1),moccasin:Float32Array.of(1,.894,.71,1),navajowhite:Float32Array.of(1,.871,.678,1),navy:Float32Array.of(0,0,.502,1),oldlace:Float32Array.of(.992,.961,.902,1),olive:Float32Array.of(.502,.502,0,1),olivedrab:Float32Array.of(.42,.557,.137,1),orange:Float32Array.of(1,.647,0,1),orangered:Float32Array.of(1,.271,0,1),orchid:Float32Array.of(.855,.439,.839,1),palegoldenrod:Float32Array.of(.933,.91,.667,1),palegreen:Float32Array.of(.596,.984,.596,1),paleturquoise:Float32Array.of(.686,.933,.933,1),palevioletred:Float32Array.of(.859,.439,.576,1),papayawhip:Float32Array.of(1,.937,.835,1),peachpuff:Float32Array.of(1,.855,.725,1),peru:Float32Array.of(.804,.522,.247,1),pink:Float32Array.of(1,.753,.796,1),plum:Float32Array.of(.867,.627,.867,1),powderblue:Float32Array.of(.69,.878,.902,1),purple:Float32Array.of(.502,0,.502,1),rebeccapurple:Float32Array.of(.4,.2,.6,1),red:Float32Array.of(1,0,0,1),rosybrown:Float32Array.of(.737,.561,.561,1),royalblue:Float32Array.of(.255,.412,.882,1),saddlebrown:Float32Array.of(.545,.271,.075,1),salmon:Float32Array.of(.98,.502,.447,1),sandybrown:Float32Array.of(.957,.643,.376,1),seagreen:Float32Array.of(.18,.545,.341,1),seashell:Float32Array.of(1,.961,.933,1),sienna:Float32Array.of(.627,.322,.176,1),silver:Float32Array.of(.753,.753,.753,1),skyblue:Float32Array.of(.529,.808,.922,1),slateblue:Float32Array.of(.416,.353,.804,1),slategray:Float32Array.of(.439,.502,.565,1),slategrey:Float32Array.of(.439,.502,.565,1),snow:Float32Array.of(1,.98,.98,1),springgreen:Float32Array.of(0,1,.498,1),steelblue:Float32Array.of(.275,.51,.706,1),tan:Float32Array.of(.824,.706,.549,1),teal:Float32Array.of(0,.502,.502,1),thistle:Float32Array.of(.847,.749,.847,1),tomato:Float32Array.of(1,.388,.278,1),transparent:Float32Array.of(0,0,0,0),turquoise:Float32Array.of(.251,.878,.816,1),violet:Float32Array.of(.933,.51,.933,1),wheat:Float32Array.of(.961,.871,.702,1),white:Float32Array.of(1,1,1,1),whitesmoke:Float32Array.of(.961,.961,.961,1),yellow:Float32Array.of(1,1,0,1),yellowgreen:Float32Array.of(.604,.804,.196,1)};t._testing.parseColor=h,t._testing.colorToString=a;var Ht=RegExp("(italic|oblique|normal|)\\s*(small-caps|normal|)\\s*(bold|bolder|lighter|[1-9]00|normal|)\\s*([\\d\\.]+)(px|pt|pc|in|cm|mm|%|em|ex|ch|rem|q)(.+)"),Ot={"Noto Mono":{"*":null},monospace:{"*":null}};t._testing.parseFontString=f,t.MakeCanvas=function(N,d){return(N=t.MakeSurface(N,d))?new T(N):null},t.ImageData=function(){if(arguments.length===2){var N=arguments[0],d=arguments[1];return new G(new Uint8ClampedArray(4*N*d),N,d)}if(arguments.length===3){var S=arguments[0];if(S.prototype.constructor!==Uint8ClampedArray)throw"bytes must be given as a Uint8ClampedArray";if(N=arguments[1],d=arguments[2],S%4)throw"bytes must be given in a multiple of 4";if(S%N)throw"bytes must divide evenly by width";if(d&&d!==S/(4*N))throw"invalid height given";return new G(S,N,S/(4*N))}throw"invalid number of arguments - takes 2 or 3, saw "+arguments.length}}()}(u);var W=Object.assign({},u),U="./this.program",Q=(t,i)=>{throw i},ot=typeof window=="object",vt=typeof importScripts=="function",It=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",ct="",Pt,Nt,Se;if(It){var xe=$a,bi=Va;ct=vt?bi.dirname(ct)+"/":__dirname+"/",Pt=(t,i)=>(t=t.startsWith("file://")?new URL(t):bi.normalize(t),xe.readFileSync(t,i?void 0:"utf8")),Se=t=>(t=Pt(t,!0),t.buffer||(t=new Uint8Array(t)),t),Nt=(t,i,n,o=!0)=>{t=t.startsWith("file://")?new URL(t):bi.normalize(t),xe.readFile(t,o?void 0:"utf8",(c,g)=>{c?n(c):i(o?g.buffer:g)})},!u.thisProgram&&1<process.argv.length&&(U=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),Q=(t,i)=>{throw process.exitCode=t,i},u.inspect=()=>"[Emscripten Module object]"}else(ot||vt)&&(vt?ct=self.location.href:typeof document<"u"&&document.currentScript&&(ct=document.currentScript.src),l&&(ct=l),ct.indexOf("blob:")!==0?ct=ct.substr(0,ct.replace(/[?#].*/,"").lastIndexOf("/")+1):ct="",Pt=t=>{var i=new XMLHttpRequest;return i.open("GET",t,!1),i.send(null),i.responseText},vt&&(Se=t=>{var i=new XMLHttpRequest;return i.open("GET",t,!1),i.responseType="arraybuffer",i.send(null),new Uint8Array(i.response)}),Nt=(t,i,n)=>{var o=new XMLHttpRequest;o.open("GET",t,!0),o.responseType="arraybuffer",o.onload=()=>{o.status==200||o.status==0&&o.response?i(o.response):n()},o.onerror=n,o.send(null)});var Rn=u.print||console.log.bind(console),se=u.printErr||console.error.bind(console);Object.assign(u,W),W=null,u.thisProgram&&(U=u.thisProgram),u.quit&&(Q=u.quit);var Re;u.wasmBinary&&(Re=u.wasmBinary);var kn=u.noExitRuntime||!0;typeof WebAssembly!="object"&&_i("no native wasm support detected");var qe,at,Ci=!1,te,rt,oe,Ae,$,yt,J,ar;function sr(){var t=qe.buffer;u.HEAP8=te=new Int8Array(t),u.HEAP16=oe=new Int16Array(t),u.HEAP32=$=new Int32Array(t),u.HEAPU8=rt=new Uint8Array(t),u.HEAPU16=Ae=new Uint16Array(t),u.HEAPU32=yt=new Uint32Array(t),u.HEAPF32=J=new Float32Array(t),u.HEAPF64=ar=new Float64Array(t)}var Tt,or=[],lr=[],hr=[];function On(){var t=u.preRun.shift();or.unshift(t)}var de=0,ke=null;function _i(t){throw u.onAbort&&u.onAbort(t),t="Aborted("+t+")",se(t),Ci=!0,t=new WebAssembly.RuntimeError(t+". Build with -sASSERTIONS for more info."),x(t),t}function cr(t){return t.startsWith("data:application/octet-stream;base64,")}var Pe;if(Pe="canvaskit.wasm",!cr(Pe)){var ur=Pe;Pe=u.locateFile?u.locateFile(ur,ct):ct+ur}function dr(t){if(t==Pe&&Re)return new Uint8Array(Re);if(Se)return Se(t);throw"both async and sync fetching of the wasm failed"}function Ln(t){if(!Re&&(ot||vt)){if(typeof fetch=="function"&&!t.startsWith("file://"))return fetch(t,{credentials:"same-origin"}).then(i=>{if(!i.ok)throw"failed to load wasm binary file at '"+t+"'";return i.arrayBuffer()}).catch(()=>dr(t));if(Nt)return new Promise((i,n)=>{Nt(t,o=>i(new Uint8Array(o)),n)})}return Promise.resolve().then(()=>dr(t))}function fr(t,i,n){return Ln(t).then(o=>WebAssembly.instantiate(o,i)).then(o=>o).then(n,o=>{se("failed to asynchronously prepare wasm: "+o),_i(o)})}function In(t,i){var n=Pe;return Re||typeof WebAssembly.instantiateStreaming!="function"||cr(n)||n.startsWith("file://")||It||typeof fetch!="function"?fr(n,t,i):fetch(n,{credentials:"same-origin"}).then(o=>WebAssembly.instantiateStreaming(o,t).then(i,function(c){return se("wasm streaming compile failed: "+c),se("falling back to ArrayBuffer instantiation"),fr(n,t,i)}))}function Nn(t){this.name="ExitStatus",this.message=`Program terminated with exit(${t})`,this.status=t}var Ti=t=>{for(;0<t.length;)t.shift()(u)},pr=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,fe=(t,i,n)=>{var o=i+n;for(n=i;t[n]&&!(n>=o);)++n;if(16<n-i&&t.buffer&&pr)return pr.decode(t.subarray(i,n));for(o="";i<n;){var c=t[i++];if(c&128){var g=t[i++]&63;if((c&224)==192)o+=String.fromCharCode((c&31)<<6|g);else{var b=t[i++]&63;c=(c&240)==224?(c&15)<<12|g<<6|b:(c&7)<<18|g<<12|b<<6|t[i++]&63,65536>c?o+=String.fromCharCode(c):(c-=65536,o+=String.fromCharCode(55296|c>>10,56320|c&1023))}}else o+=String.fromCharCode(c)}return o},Qe={};function Ei(t){for(;t.length;){var i=t.pop();t.pop()(i)}}function Oe(t){return this.fromWireType($[t>>2])}var be={},pe={},Ze={},gr=void 0;function ti(t){throw new gr(t)}function Yt(t,i,n){function o(m){m=n(m),m.length!==t.length&&ti("Mismatched type converter count");for(var w=0;w<t.length;++w)ee(t[w],m[w])}t.forEach(function(m){Ze[m]=i});var c=Array(i.length),g=[],b=0;i.forEach((m,w)=>{pe.hasOwnProperty(m)?c[w]=pe[m]:(g.push(m),be.hasOwnProperty(m)||(be[m]=[]),be[m].push(()=>{c[w]=pe[m],++b,b===g.length&&o(c)}))}),g.length===0&&o(c)}function ei(t){switch(t){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError(`Unknown type size: ${t}`)}}var mr=void 0;function bt(t){for(var i="";rt[t];)i+=mr[rt[t++]];return i}var Ce=void 0;function ht(t){throw new Ce(t)}function Dn(t,i,n={}){var o=i.name;if(t||ht(`type "${o}" must have a positive integer typeid pointer`),pe.hasOwnProperty(t)){if(n.Wf)return;ht(`Cannot register type '${o}' twice`)}pe[t]=i,delete Ze[t],be.hasOwnProperty(t)&&(i=be[t],delete be[t],i.forEach(c=>c()))}function ee(t,i,n={}){if(!("argPackAdvance"in i))throw new TypeError("registerType registeredInstance requires argPackAdvance");Dn(t,i,n)}function Mi(t){ht(t.Jd.Vd.Pd.name+" instance already deleted")}var Fi=!1;function vr(){}function yr(t){--t.count.value,t.count.value===0&&(t.Yd?t.ee.ke(t.Yd):t.Vd.Pd.ke(t.Rd))}function wr(t,i,n){return i===n?t:n.$d===void 0?null:(t=wr(t,i,n.$d),t===null?null:n.Mf(t))}var Sr={},Le=[];function xi(){for(;Le.length;){var t=Le.pop();t.Jd.Ee=!1,t.delete()}}var Ie=void 0,Ne={};function Bn(t,i){for(i===void 0&&ht("ptr should not be undefined");t.$d;)i=t.Oe(i),t=t.$d;return Ne[i]}function ii(t,i){return i.Vd&&i.Rd||ti("makeClassHandle requires ptr and ptrType"),!!i.ee!=!!i.Yd&&ti("Both smartPtrType and smartPtr must be specified"),i.count={value:1},De(Object.create(t,{Jd:{value:i}}))}function De(t){return typeof FinalizationRegistry>"u"?(De=i=>i,t):(Fi=new FinalizationRegistry(i=>{yr(i.Jd)}),De=i=>{var n=i.Jd;return n.Yd&&Fi.register(i,{Jd:n},i),i},vr=i=>{Fi.unregister(i)},De(t))}function le(){}function Ar(t){if(t===void 0)return"_unknown";t=t.replace(/[^a-zA-Z0-9_]/g,"$");var i=t.charCodeAt(0);return 48<=i&&57>=i?`_${t}`:t}function Ri(t,i){return t=Ar(t),{[t]:function(){return i.apply(this,arguments)}}[t]}function ki(t,i,n){if(t[i].Xd===void 0){var o=t[i];t[i]=function(){return t[i].Xd.hasOwnProperty(arguments.length)||ht(`Function '${n}' called with an invalid number of arguments (${arguments.length}) - expects one of (${t[i].Xd})!`),t[i].Xd[arguments.length].apply(this,arguments)},t[i].Xd=[],t[i].Xd[o.Ce]=o}}function Oi(t,i,n){u.hasOwnProperty(t)?((n===void 0||u[t].Xd!==void 0&&u[t].Xd[n]!==void 0)&&ht(`Cannot register public name '${t}' twice`),ki(u,t,t),u.hasOwnProperty(n)&&ht(`Cannot register multiple overloads of a function with the same number of arguments (${n})!`),u[t].Xd[n]=i):(u[t]=i,n!==void 0&&(u[t].tg=n))}function Wn(t,i,n,o,c,g,b,m){this.name=t,this.constructor=i,this.Fe=n,this.ke=o,this.$d=c,this.Rf=g,this.Oe=b,this.Mf=m,this.cg=[]}function Li(t,i,n){for(;i!==n;)i.Oe||ht(`Expected null or instance of ${n.name}, got an instance of ${i.name}`),t=i.Oe(t),i=i.$d;return t}function Gn(t,i){return i===null?(this.gf&&ht(`null is not a valid ${this.name}`),0):(i.Jd||ht(`Cannot pass "${Ni(i)}" as a ${this.name}`),i.Jd.Rd||ht(`Cannot pass deleted object as a pointer of type ${this.name}`),Li(i.Jd.Rd,i.Jd.Vd.Pd,this.Pd))}function Un(t,i){if(i===null){if(this.gf&&ht(`null is not a valid ${this.name}`),this.Ve){var n=this.hf();return t!==null&&t.push(this.ke,n),n}return 0}if(i.Jd||ht(`Cannot pass "${Ni(i)}" as a ${this.name}`),i.Jd.Rd||ht(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.Ue&&i.Jd.Vd.Ue&&ht(`Cannot convert argument of type ${i.Jd.ee?i.Jd.ee.name:i.Jd.Vd.name} to parameter type ${this.name}`),n=Li(i.Jd.Rd,i.Jd.Vd.Pd,this.Pd),this.Ve)switch(i.Jd.Yd===void 0&&ht("Passing raw pointer to smart pointer is illegal"),this.hg){case 0:i.Jd.ee===this?n=i.Jd.Yd:ht(`Cannot convert argument of type ${i.Jd.ee?i.Jd.ee.name:i.Jd.Vd.name} to parameter type ${this.name}`);break;case 1:n=i.Jd.Yd;break;case 2:if(i.Jd.ee===this)n=i.Jd.Yd;else{var o=i.clone();n=this.dg(n,$t(function(){o.delete()})),t!==null&&t.push(this.ke,n)}break;default:ht("Unsupporting sharing policy")}return n}function $n(t,i){return i===null?(this.gf&&ht(`null is not a valid ${this.name}`),0):(i.Jd||ht(`Cannot pass "${Ni(i)}" as a ${this.name}`),i.Jd.Rd||ht(`Cannot pass deleted object as a pointer of type ${this.name}`),i.Jd.Vd.Ue&&ht(`Cannot convert argument of type ${i.Jd.Vd.name} to parameter type ${this.name}`),Li(i.Jd.Rd,i.Jd.Vd.Pd,this.Pd))}function ie(t,i,n,o,c,g,b,m,w,C,L){this.name=t,this.Pd=i,this.gf=n,this.Ue=o,this.Ve=c,this.bg=g,this.hg=b,this.vf=m,this.hf=w,this.dg=C,this.ke=L,c||i.$d!==void 0?this.toWireType=Un:(this.toWireType=o?Gn:$n,this.de=null)}function Pr(t,i,n){u.hasOwnProperty(t)||ti("Replacing nonexistant public symbol"),u[t].Xd!==void 0&&n!==void 0?u[t].Xd[n]=i:(u[t]=i,u[t].Ce=n)}var zn=(t,i)=>{var n=[];return function(){if(n.length=0,Object.assign(n,arguments),t.includes("j")){var o=u["dynCall_"+t];o=n&&n.length?o.apply(null,[i].concat(n)):o.call(null,i)}else o=Tt.get(i).apply(null,n);return o}};function Ft(t,i){t=bt(t);var n=t.includes("j")?zn(t,i):Tt.get(i);return typeof n!="function"&&ht(`unknown function pointer with signature ${t}: ${i}`),n}var br=void 0;function Cr(t){t=Hr(t);var i=bt(t);return ae(t),i}function Be(t,i){function n(g){c[g]||pe[g]||(Ze[g]?Ze[g].forEach(n):(o.push(g),c[g]=!0))}var o=[],c={};throw i.forEach(n),new br(`${t}: `+o.map(Cr).join([", "]))}function ri(t,i,n,o,c){var g=i.length;2>g&&ht("argTypes array size mismatch! Must at least get return value and 'this' types!");var b=i[1]!==null&&n!==null,m=!1;for(n=1;n<i.length;++n)if(i[n]!==null&&i[n].de===void 0){m=!0;break}var w=i[0].name!=="void",C=g-2,L=Array(C),D=[],z=[];return function(){if(arguments.length!==C&&ht(`function ${t} called with ${arguments.length} arguments, expected ${C} args!`),z.length=0,D.length=b?2:1,D[0]=c,b){var E=i[1].toWireType(z,this);D[1]=E}for(var H=0;H<C;++H)L[H]=i[H+2].toWireType(z,arguments[H]),D.push(L[H]);if(H=o.apply(null,D),m)Ei(z);else for(var et=b?1:2;et<i.length;et++){var tt=et===1?E:L[et-2];i[et].de!==null&&i[et].de(tt)}return E=w?i[0].fromWireType(H):void 0,E}}function ni(t,i){for(var n=[],o=0;o<t;o++)n.push(yt[i+4*o>>2]);return n}function _r(){this.je=[void 0],this.sf=[]}var Gt=new _r;function Ii(t){t>=Gt.Ge&&--Gt.get(t).wf===0&&Gt.Bf(t)}var Ut=t=>(t||ht("Cannot use deleted val. handle = "+t),Gt.get(t).value),$t=t=>{switch(t){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return Gt.Af({wf:1,value:t})}};function jn(t,i,n){switch(i){case 0:return function(o){return this.fromWireType((n?te:rt)[o])};case 1:return function(o){return this.fromWireType((n?oe:Ae)[o>>1])};case 2:return function(o){return this.fromWireType((n?$:yt)[o>>2])};default:throw new TypeError("Unknown integer type: "+t)}}function We(t,i){var n=pe[t];return n===void 0&&ht(i+" has unknown type "+Cr(t)),n}function Ni(t){if(t===null)return"null";var i=typeof t;return i==="object"||i==="array"||i==="function"?t.toString():""+t}function Hn(t,i){switch(i){case 2:return function(n){return this.fromWireType(J[n>>2])};case 3:return function(n){return this.fromWireType(ar[n>>3])};default:throw new TypeError("Unknown float type: "+t)}}function Kn(t,i,n){switch(i){case 0:return n?function(o){return te[o]}:function(o){return rt[o]};case 1:return n?function(o){return oe[o>>1]}:function(o){return Ae[o>>1]};case 2:return n?function(o){return $[o>>2]}:function(o){return yt[o>>2]};default:throw new TypeError("Unknown integer type: "+t)}}var Xt=(t,i,n,o)=>{if(!(0<o))return 0;var c=n;o=n+o-1;for(var g=0;g<t.length;++g){var b=t.charCodeAt(g);if(55296<=b&&57343>=b){var m=t.charCodeAt(++g);b=65536+((b&1023)<<10)|m&1023}if(127>=b){if(n>=o)break;i[n++]=b}else{if(2047>=b){if(n+1>=o)break;i[n++]=192|b>>6}else{if(65535>=b){if(n+2>=o)break;i[n++]=224|b>>12}else{if(n+3>=o)break;i[n++]=240|b>>18,i[n++]=128|b>>12&63}i[n++]=128|b>>6&63}i[n++]=128|b&63}}return i[n]=0,n-c},Jt=t=>{for(var i=0,n=0;n<t.length;++n){var o=t.charCodeAt(n);127>=o?i++:2047>=o?i+=2:55296<=o&&57343>=o?(i+=4,++n):i+=3}return i},Tr=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,Vn=(t,i)=>{for(var n=t>>1,o=n+i/2;!(n>=o)&&Ae[n];)++n;if(n<<=1,32<n-t&&Tr)return Tr.decode(rt.subarray(t,n));for(n="",o=0;!(o>=i/2);++o){var c=oe[t+2*o>>1];if(c==0)break;n+=String.fromCharCode(c)}return n},Yn=(t,i,n)=>{if(n===void 0&&(n=2147483647),2>n)return 0;n-=2;var o=i;n=n<2*t.length?n/2:t.length;for(var c=0;c<n;++c)oe[i>>1]=t.charCodeAt(c),i+=2;return oe[i>>1]=0,i-o},Xn=t=>2*t.length,Jn=(t,i)=>{for(var n=0,o="";!(n>=i/4);){var c=$[t+4*n>>2];if(c==0)break;++n,65536<=c?(c-=65536,o+=String.fromCharCode(55296|c>>10,56320|c&1023)):o+=String.fromCharCode(c)}return o},qn=(t,i,n)=>{if(n===void 0&&(n=2147483647),4>n)return 0;var o=i;n=o+n-4;for(var c=0;c<t.length;++c){var g=t.charCodeAt(c);if(55296<=g&&57343>=g){var b=t.charCodeAt(++c);g=65536+((g&1023)<<10)|b&1023}if($[i>>2]=g,i+=4,i+4>n)break}return $[i>>2]=0,i-o},Qn=t=>{for(var i=0,n=0;n<t.length;++n){var o=t.charCodeAt(n);55296<=o&&57343>=o&&++n,i+=4}return i},Zn={};function ai(t){var i=Zn[t];return i===void 0?bt(t):i}var si=[];function Er(){function t(i){i.$$$embind_global$$$=i;var n=typeof $$$embind_global$$$=="object"&&i.$$$embind_global$$$==i;return n||delete i.$$$embind_global$$$,n}if(typeof globalThis=="object")return globalThis;if(typeof $$$embind_global$$$=="object"||(typeof Vi=="object"&&t(Vi)?$$$embind_global$$$=Vi:typeof self=="object"&&t(self)&&($$$embind_global$$$=self),typeof $$$embind_global$$$=="object"))return $$$embind_global$$$;throw Error("unable to get global object.")}function ta(t){var i=si.length;return si.push(t),i}function ea(t,i){for(var n=Array(t),o=0;o<t;++o)n[o]=We(yt[i+4*o>>2],"parameter "+o);return n}var Mr=[];function ia(t){var i=Array(t+1);return function(n,o,c){i[0]=n;for(var g=0;g<t;++g){var b=We(yt[o+4*g>>2],"parameter "+g);i[g+1]=b.readValueFromPointer(c),c+=b.argPackAdvance}return n=new(n.bind.apply(n,i)),$t(n)}}var Fr={};function ra(t){var i=t.getExtension("ANGLE_instanced_arrays");i&&(t.vertexAttribDivisor=function(n,o){i.vertexAttribDivisorANGLE(n,o)},t.drawArraysInstanced=function(n,o,c,g){i.drawArraysInstancedANGLE(n,o,c,g)},t.drawElementsInstanced=function(n,o,c,g,b){i.drawElementsInstancedANGLE(n,o,c,g,b)})}function na(t){var i=t.getExtension("OES_vertex_array_object");i&&(t.createVertexArray=function(){return i.createVertexArrayOES()},t.deleteVertexArray=function(n){i.deleteVertexArrayOES(n)},t.bindVertexArray=function(n){i.bindVertexArrayOES(n)},t.isVertexArray=function(n){return i.isVertexArrayOES(n)})}function aa(t){var i=t.getExtension("WEBGL_draw_buffers");i&&(t.drawBuffers=function(n,o){i.drawBuffersWEBGL(n,o)})}var xr=1,oi=[],qt=[],li=[],Ge=[],zt=[],Qt=[],hi=[],re=[],ge=[],me=[],Rr={},kr={},Or=4;function wt(t){ci||(ci=t)}function _e(t){for(var i=xr++,n=t.length;n<i;n++)t[n]=null;return i}function sa(t,i){t.Ge||(t.Ge=t.getContext,t.getContext=function(o,c){return c=t.Ge(o,c),o=="webgl"==c instanceof WebGLRenderingContext?c:null});var n=1<i.majorVersion?t.getContext("webgl2",i):t.getContext("webgl",i);return n?oa(n,i):0}function oa(t,i){var n=_e(re),o={handle:n,attributes:i,version:i.majorVersion,fe:t};return t.canvas&&(t.canvas.zf=o),re[n]=o,(typeof i.Nf>"u"||i.Nf)&&la(o),n}function Lr(t){return Z=re[t],u.rg=_=Z&&Z.fe,!(t&&!_)}function la(t){if(t||(t=Z),!t.Xf){t.Xf=!0;var i=t.fe;ra(i),na(i),aa(i),i.pf=i.getExtension("WEBGL_draw_instanced_base_vertex_base_instance"),i.uf=i.getExtension("WEBGL_multi_draw_instanced_base_vertex_base_instance"),2<=t.version&&(i.qf=i.getExtension("EXT_disjoint_timer_query_webgl2")),(2>t.version||!i.qf)&&(i.qf=i.getExtension("EXT_disjoint_timer_query")),i.sg=i.getExtension("WEBGL_multi_draw"),(i.getSupportedExtensions()||[]).forEach(function(n){n.includes("lose_context")||n.includes("debug")||i.getExtension(n)})}}var Z,ci,Di={},Ir=()=>{if(!Bi){var t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:U||"./this.program"},i;for(i in Di)Di[i]===void 0?delete t[i]:t[i]=Di[i];var n=[];for(i in t)n.push(`${i}=${t[i]}`);Bi=n}return Bi},Bi,ha=[null,[],[]];function Nr(t){_.bindVertexArray(hi[t])}function Dr(t,i){for(var n=0;n<t;n++){var o=$[i+4*n>>2];_.deleteVertexArray(hi[o]),hi[o]=null}}var ui=[];function Br(t,i,n,o){_.drawElements(t,i,n,o)}function Te(t,i,n,o){for(var c=0;c<t;c++){var g=_[n](),b=g&&_e(o);g?(g.name=b,o[b]=g):wt(1282),$[i+4*c>>2]=b}}function Wr(t,i){Te(t,i,"createVertexArray",hi)}function Gr(t,i,n){if(i){var o=void 0;switch(t){case 36346:o=1;break;case 36344:n!=0&&n!=1&&wt(1280);return;case 34814:case 36345:o=0;break;case 34466:var c=_.getParameter(34467);o=c?c.length:0;break;case 33309:if(2>Z.version){wt(1282);return}o=2*(_.getSupportedExtensions()||[]).length;break;case 33307:case 33308:if(2>Z.version){wt(1280);return}o=t==33307?3:0}if(o===void 0)switch(c=_.getParameter(t),typeof c){case"number":o=c;break;case"boolean":o=c?1:0;break;case"string":wt(1280);return;case"object":if(c===null)switch(t){case 34964:case 35725:case 34965:case 36006:case 36007:case 32873:case 34229:case 36662:case 36663:case 35053:case 35055:case 36010:case 35097:case 35869:case 32874:case 36389:case 35983:case 35368:case 34068:o=0;break;default:wt(1280);return}else{if(c instanceof Float32Array||c instanceof Uint32Array||c instanceof Int32Array||c instanceof Array){for(t=0;t<c.length;++t)switch(n){case 0:$[i+4*t>>2]=c[t];break;case 2:J[i+4*t>>2]=c[t];break;case 4:te[i+t>>0]=c[t]?1:0}return}try{o=c.name|0}catch(g){wt(1280),se("GL_INVALID_ENUM in glGet"+n+"v: Unknown object returned from WebGL getParameter("+t+")! (error: "+g+")");return}}break;default:wt(1280),se("GL_INVALID_ENUM in glGet"+n+"v: Native code calling glGet"+n+"v("+t+") and it returns "+c+" of type "+typeof c+"!");return}switch(n){case 1:n=o,yt[i>>2]=n,yt[i+4>>2]=(n-yt[i>>2])/4294967296;break;case 0:$[i>>2]=o;break;case 2:J[i>>2]=o;break;case 4:te[i>>0]=o?1:0}}else wt(1281)}var Ue=t=>{var i=Jt(t)+1,n=gi(i);return n&&Xt(t,rt,n,i),n};function Ur(t){return t.slice(-1)=="]"&&t.lastIndexOf("[")}function di(t){return t-=5120,t==0?te:t==1?rt:t==2?oe:t==4?$:t==6?J:t==5||t==28922||t==28520||t==30779||t==30782?yt:Ae}function Wi(t,i,n,o,c){t=di(t);var g=31-Math.clz32(t.BYTES_PER_ELEMENT),b=Or;return t.subarray(c>>g,c+o*(n*({5:3,6:4,8:2,29502:3,29504:4,26917:2,26918:2,29846:3,29847:4}[i-6402]||1)*(1<<g)+b-1&-b)>>g)}function ft(t){var i=_.Kf;if(i){var n=i.Ne[t];return typeof n=="number"&&(i.Ne[t]=n=_.getUniformLocation(i,i.xf[t]+(0<n?"["+n+"]":""))),n}wt(1282)}var he=[],$e=[],fi=t=>t%4===0&&(t%100!==0||t%400===0),$r=[31,29,31,30,31,30,31,31,30,31,30,31],zr=[31,28,31,30,31,30,31,31,30,31,30,31];function ca(t){var i=Array(Jt(t)+1);return Xt(t,i,0,i.length),i}var ua=(t,i,n,o)=>{function c(E,H,et){for(E=typeof E=="number"?E.toString():E||"";E.length<H;)E=et[0]+E;return E}function g(E,H){return c(E,H,"0")}function b(E,H){function et(Dt){return 0>Dt?-1:0<Dt?1:0}var tt;return(tt=et(E.getFullYear()-H.getFullYear()))===0&&(tt=et(E.getMonth()-H.getMonth()))===0&&(tt=et(E.getDate()-H.getDate())),tt}function m(E){switch(E.getDay()){case 0:return new Date(E.getFullYear()-1,11,29);case 1:return E;case 2:return new Date(E.getFullYear(),0,3);case 3:return new Date(E.getFullYear(),0,2);case 4:return new Date(E.getFullYear(),0,1);case 5:return new Date(E.getFullYear()-1,11,31);case 6:return new Date(E.getFullYear()-1,11,30)}}function w(E){var H=E.oe;for(E=new Date(new Date(E.pe+1900,0,1).getTime());0<H;){var et=E.getMonth(),tt=(fi(E.getFullYear())?$r:zr)[et];if(H>tt-E.getDate())H-=tt-E.getDate()+1,E.setDate(1),11>et?E.setMonth(et+1):(E.setMonth(0),E.setFullYear(E.getFullYear()+1));else{E.setDate(E.getDate()+H);break}}return et=new Date(E.getFullYear()+1,0,4),H=m(new Date(E.getFullYear(),0,4)),et=m(et),0>=b(H,E)?0>=b(et,E)?E.getFullYear()+1:E.getFullYear():E.getFullYear()-1}var C=$[o+40>>2];o={pg:$[o>>2],og:$[o+4>>2],Ze:$[o+8>>2],jf:$[o+12>>2],$e:$[o+16>>2],pe:$[o+20>>2],he:$[o+24>>2],oe:$[o+28>>2],vg:$[o+32>>2],ng:$[o+36>>2],qg:C&&C?fe(rt,C):""},n=n?fe(rt,n):"",C={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var L in C)n=n.replace(new RegExp(L,"g"),C[L]);var D="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),z="January February March April May June July August September October November December".split(" ");C={"%a":E=>D[E.he].substring(0,3),"%A":E=>D[E.he],"%b":E=>z[E.$e].substring(0,3),"%B":E=>z[E.$e],"%C":E=>g((E.pe+1900)/100|0,2),"%d":E=>g(E.jf,2),"%e":E=>c(E.jf,2," "),"%g":E=>w(E).toString().substring(2),"%G":E=>w(E),"%H":E=>g(E.Ze,2),"%I":E=>(E=E.Ze,E==0?E=12:12<E&&(E-=12),g(E,2)),"%j":E=>{for(var H=0,et=0;et<=E.$e-1;H+=(fi(E.pe+1900)?$r:zr)[et++]);return g(E.jf+H,3)},"%m":E=>g(E.$e+1,2),"%M":E=>g(E.og,2),"%n":()=>`
2
- `,"%p":E=>0<=E.Ze&&12>E.Ze?"AM":"PM","%S":E=>g(E.pg,2),"%t":()=>" ","%u":E=>E.he||7,"%U":E=>g(Math.floor((E.oe+7-E.he)/7),2),"%V":E=>{var H=Math.floor((E.oe+7-(E.he+6)%7)/7);if(2>=(E.he+371-E.oe-2)%7&&H++,H)H==53&&(et=(E.he+371-E.oe)%7,et==4||et==3&&fi(E.pe)||(H=1));else{H=52;var et=(E.he+7-E.oe-1)%7;(et==4||et==5&&fi(E.pe%400-1))&&H++}return g(H,2)},"%w":E=>E.he,"%W":E=>g(Math.floor((E.oe+7-(E.he+6)%7)/7),2),"%y":E=>(E.pe+1900).toString().substring(2),"%Y":E=>E.pe+1900,"%z":E=>{E=E.ng;var H=0<=E;return E=Math.abs(E)/60,(H?"+":"-")+("0000"+(E/60*100+E%60)).slice(-4)},"%Z":E=>E.qg,"%%":()=>"%"},n=n.replace(/%%/g,"\0\0");for(L in C)n.includes(L)&&(n=n.replace(new RegExp(L,"g"),C[L](o)));return n=n.replace(/\0\0/g,"%"),L=ca(n),L.length>i?0:(te.set(L,t),L.length-1)};gr=u.InternalError=class extends Error{constructor(t){super(t),this.name="InternalError"}};for(var jr=Array(256),pi=0;256>pi;++pi)jr[pi]=String.fromCharCode(pi);mr=jr,Ce=u.BindingError=class extends Error{constructor(t){super(t),this.name="BindingError"}},le.prototype.isAliasOf=function(t){if(!(this instanceof le&&t instanceof le))return!1;var i=this.Jd.Vd.Pd,n=this.Jd.Rd,o=t.Jd.Vd.Pd;for(t=t.Jd.Rd;i.$d;)n=i.Oe(n),i=i.$d;for(;o.$d;)t=o.Oe(t),o=o.$d;return i===o&&n===t},le.prototype.clone=function(){if(this.Jd.Rd||Mi(this),this.Jd.Me)return this.Jd.count.value+=1,this;var t=De,i=Object,n=i.create,o=Object.getPrototypeOf(this),c=this.Jd;return t=t(n.call(i,o,{Jd:{value:{count:c.count,Ee:c.Ee,Me:c.Me,Rd:c.Rd,Vd:c.Vd,Yd:c.Yd,ee:c.ee}}})),t.Jd.count.value+=1,t.Jd.Ee=!1,t},le.prototype.delete=function(){this.Jd.Rd||Mi(this),this.Jd.Ee&&!this.Jd.Me&&ht("Object already scheduled for deletion"),vr(this),yr(this.Jd),this.Jd.Me||(this.Jd.Yd=void 0,this.Jd.Rd=void 0)},le.prototype.isDeleted=function(){return!this.Jd.Rd},le.prototype.deleteLater=function(){return this.Jd.Rd||Mi(this),this.Jd.Ee&&!this.Jd.Me&&ht("Object already scheduled for deletion"),Le.push(this),Le.length===1&&Ie&&Ie(xi),this.Jd.Ee=!0,this},u.getInheritedInstanceCount=function(){return Object.keys(Ne).length},u.getLiveInheritedInstances=function(){var t=[],i;for(i in Ne)Ne.hasOwnProperty(i)&&t.push(Ne[i]);return t},u.flushPendingDeletes=xi,u.setDelayFunction=function(t){Ie=t,Le.length&&Ie&&Ie(xi)},ie.prototype.Sf=function(t){return this.vf&&(t=this.vf(t)),t},ie.prototype.nf=function(t){this.ke&&this.ke(t)},ie.prototype.argPackAdvance=8,ie.prototype.readValueFromPointer=Oe,ie.prototype.deleteObject=function(t){t!==null&&t.delete()},ie.prototype.fromWireType=function(t){function i(){return this.Ve?ii(this.Pd.Fe,{Vd:this.bg,Rd:n,ee:this,Yd:t}):ii(this.Pd.Fe,{Vd:this,Rd:t})}var n=this.Sf(t);if(!n)return this.nf(t),null;var o=Bn(this.Pd,n);if(o!==void 0)return o.Jd.count.value===0?(o.Jd.Rd=n,o.Jd.Yd=t,o.clone()):(o=o.clone(),this.nf(t),o);if(o=this.Pd.Rf(n),o=Sr[o],!o)return i.call(this);o=this.Ue?o.If:o.pointerType;var c=wr(n,this.Pd,o.Pd);return c===null?i.call(this):this.Ve?ii(o.Pd.Fe,{Vd:o,Rd:c,ee:this,Yd:t}):ii(o.Pd.Fe,{Vd:o,Rd:c})},br=u.UnboundTypeError=function(t,i){var n=Ri(i,function(o){this.name=i,this.message=o,o=Error(o).stack,o!==void 0&&(this.stack=this.toString()+`
3
- `+o.replace(/^Error(:[^\n]*)?\n/,""))});return n.prototype=Object.create(t.prototype),n.prototype.constructor=n,n.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},n}(Error,"UnboundTypeError"),Object.assign(_r.prototype,{get(t){return this.je[t]},has(t){return this.je[t]!==void 0},Af(t){var i=this.sf.pop()||this.je.length;return this.je[i]=t,i},Bf(t){this.je[t]=void 0,this.sf.push(t)}}),Gt.je.push({value:void 0},{value:null},{value:!0},{value:!1}),Gt.Ge=Gt.je.length,u.count_emval_handles=function(){for(var t=0,i=Gt.Ge;i<Gt.je.length;++i)Gt.je[i]!==void 0&&++t;return t};for(var _,Wt=0;32>Wt;++Wt)ui.push(Array(Wt));var da=new Float32Array(288);for(Wt=0;288>Wt;++Wt)he[Wt]=da.subarray(0,Wt+1);var fa=new Int32Array(288);for(Wt=0;288>Wt;++Wt)$e[Wt]=fa.subarray(0,Wt+1);var pa={T:function(){return 0},Bb:()=>{},Db:function(){return 0},yb:()=>{},zb:()=>{},U:function(){},Ab:()=>{},C:function(t){var i=Qe[t];delete Qe[t];var n=i.hf,o=i.ke,c=i.rf,g=c.map(b=>b.Vf).concat(c.map(b=>b.fg));Yt([t],g,b=>{var m={};return c.forEach((w,C)=>{var L=b[C],D=w.Tf,z=w.Uf,E=b[C+c.length],H=w.eg,et=w.gg;m[w.Of]={read:tt=>L.fromWireType(D(z,tt)),write:(tt,Dt)=>{var Mt=[];H(et,tt,E.toWireType(Mt,Dt)),Ei(Mt)}}}),[{name:i.name,fromWireType:function(w){var C={},L;for(L in m)C[L]=m[L].read(w);return o(w),C},toWireType:function(w,C){for(var L in m)if(!(L in C))throw new TypeError(`Missing field: "${L}"`);var D=n();for(L in m)m[L].write(D,C[L]);return w!==null&&w.push(o,D),D},argPackAdvance:8,readValueFromPointer:Oe,de:o}]})},qb:function(){},Hb:function(t,i,n,o,c){var g=ei(n);i=bt(i),ee(t,{name:i,fromWireType:function(b){return!!b},toWireType:function(b,m){return m?o:c},argPackAdvance:8,readValueFromPointer:function(b){if(n===1)var m=te;else if(n===2)m=oe;else if(n===4)m=$;else throw new TypeError("Unknown boolean type size: "+i);return this.fromWireType(m[b>>g])},de:null})},m:function(t,i,n,o,c,g,b,m,w,C,L,D,z){L=bt(L),g=Ft(c,g),m&&(m=Ft(b,m)),C&&(C=Ft(w,C)),z=Ft(D,z);var E=Ar(L);Oi(E,function(){Be(`Cannot construct ${L} due to unbound types`,[o])}),Yt([t,i,n],o?[o]:[],function(H){if(H=H[0],o)var et=H.Pd,tt=et.Fe;else tt=le.prototype;H=Ri(E,function(){if(Object.getPrototypeOf(this)!==Dt)throw new Ce("Use 'new' to construct "+L);if(Mt.ne===void 0)throw new Ce(L+" has no accessible constructor");var je=Mt.ne[arguments.length];if(je===void 0)throw new Ce(`Tried to invoke ctor of ${L} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(Mt.ne).toString()}) parameters instead!`);return je.apply(this,arguments)});var Dt=Object.create(tt,{constructor:{value:H}});H.prototype=Dt;var Mt=new Wn(L,H,Dt,z,et,g,m,C);Mt.$d&&(Mt.$d.Pe===void 0&&(Mt.$d.Pe=[]),Mt.$d.Pe.push(Mt)),et=new ie(L,Mt,!0,!1,!1),tt=new ie(L+"*",Mt,!1,!1,!1);var ze=new ie(L+" const*",Mt,!1,!0,!1);return Sr[t]={pointerType:tt,If:ze},Pr(E,H),[et,tt,ze]})},f:function(t,i,n,o,c,g,b){var m=ni(n,o);i=bt(i),g=Ft(c,g),Yt([],[t],function(w){function C(){Be(`Cannot call ${L} due to unbound types`,m)}w=w[0];var L=`${w.name}.${i}`;i.startsWith("@@")&&(i=Symbol[i.substring(2)]);var D=w.Pd.constructor;return D[i]===void 0?(C.Ce=n-1,D[i]=C):(ki(D,i,L),D[i].Xd[n-1]=C),Yt([],m,function(z){if(z=[z[0],null].concat(z.slice(1)),z=ri(L,z,null,g,b),D[i].Xd===void 0?(z.Ce=n-1,D[i]=z):D[i].Xd[n-1]=z,w.Pd.Pe)for(const E of w.Pd.Pe)E.constructor.hasOwnProperty(i)||(E.constructor[i]=z);return[]}),[]})},A:function(t,i,n,o,c,g){var b=ni(i,n);c=Ft(o,c),Yt([],[t],function(m){m=m[0];var w=`constructor ${m.name}`;if(m.Pd.ne===void 0&&(m.Pd.ne=[]),m.Pd.ne[i-1]!==void 0)throw new Ce(`Cannot register multiple constructors with identical number of parameters (${i-1}) for class '${m.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return m.Pd.ne[i-1]=()=>{Be(`Cannot construct ${m.name} due to unbound types`,b)},Yt([],b,function(C){return C.splice(1,0,null),m.Pd.ne[i-1]=ri(w,C,null,c,g),[]}),[]})},b:function(t,i,n,o,c,g,b,m){var w=ni(n,o);i=bt(i),g=Ft(c,g),Yt([],[t],function(C){function L(){Be(`Cannot call ${D} due to unbound types`,w)}C=C[0];var D=`${C.name}.${i}`;i.startsWith("@@")&&(i=Symbol[i.substring(2)]),m&&C.Pd.cg.push(i);var z=C.Pd.Fe,E=z[i];return E===void 0||E.Xd===void 0&&E.className!==C.name&&E.Ce===n-2?(L.Ce=n-2,L.className=C.name,z[i]=L):(ki(z,i,D),z[i].Xd[n-2]=L),Yt([],w,function(H){return H=ri(D,H,C,g,b),z[i].Xd===void 0?(H.Ce=n-2,z[i]=H):z[i].Xd[n-2]=H,[]}),[]})},t:function(t,i,n){t=bt(t),Yt([],[i],function(o){return o=o[0],u[t]=o.fromWireType(n),[]})},Gb:function(t,i){i=bt(i),ee(t,{name:i,fromWireType:function(n){var o=Ut(n);return Ii(n),o},toWireType:function(n,o){return $t(o)},argPackAdvance:8,readValueFromPointer:Oe,de:null})},l:function(t,i,n,o){function c(){}n=ei(n),i=bt(i),c.values={},ee(t,{name:i,constructor:c,fromWireType:function(g){return this.constructor.values[g]},toWireType:function(g,b){return b.value},argPackAdvance:8,readValueFromPointer:jn(i,n,o),de:null}),Oi(i,c)},c:function(t,i,n){var o=We(t,"enum");i=bt(i),t=o.constructor,o=Object.create(o.constructor.prototype,{value:{value:n},constructor:{value:Ri(`${o.name}_${i}`,function(){})}}),t.values[n]=o,t[i]=o},W:function(t,i,n){n=ei(n),i=bt(i),ee(t,{name:i,fromWireType:function(o){return o},toWireType:function(o,c){return c},argPackAdvance:8,readValueFromPointer:Hn(i,n),de:null})},y:function(t,i,n,o,c,g){var b=ni(i,n);t=bt(t),c=Ft(o,c),Oi(t,function(){Be(`Cannot call ${t} due to unbound types`,b)},i-1),Yt([],b,function(m){return m=[m[0],null].concat(m.slice(1)),Pr(t,ri(t,m,null,c,g),i-1),[]})},E:function(t,i,n,o,c){i=bt(i),c===-1&&(c=4294967295),c=ei(n);var g=m=>m;if(o===0){var b=32-8*n;g=m=>m<<b>>>b}n=i.includes("unsigned")?function(m,w){return w>>>0}:function(m,w){return w},ee(t,{name:i,fromWireType:g,toWireType:n,argPackAdvance:8,readValueFromPointer:Kn(i,c,o!==0),de:null})},s:function(t,i,n){function o(g){g>>=2;var b=yt;return new c(b.buffer,b[g+1],b[g])}var c=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][i];n=bt(n),ee(t,{name:n,fromWireType:o,argPackAdvance:8,readValueFromPointer:o},{Wf:!0})},q:function(t,i,n,o,c,g,b,m,w,C,L,D){n=bt(n),g=Ft(c,g),m=Ft(b,m),C=Ft(w,C),D=Ft(L,D),Yt([t],[i],function(z){return z=z[0],[new ie(n,z.Pd,!1,!1,!0,z,o,g,m,C,D)]})},V:function(t,i){i=bt(i);var n=i==="std::string";ee(t,{name:i,fromWireType:function(o){var c=yt[o>>2],g=o+4;if(n)for(var b=g,m=0;m<=c;++m){var w=g+m;if(m==c||rt[w]==0){if(b=b?fe(rt,b,w-b):"",C===void 0)var C=b;else C+="\0",C+=b;b=w+1}}else{for(C=Array(c),m=0;m<c;++m)C[m]=String.fromCharCode(rt[g+m]);C=C.join("")}return ae(o),C},toWireType:function(o,c){c instanceof ArrayBuffer&&(c=new Uint8Array(c));var g=typeof c=="string";g||c instanceof Uint8Array||c instanceof Uint8ClampedArray||c instanceof Int8Array||ht("Cannot pass non-string to std::string");var b=n&&g?Jt(c):c.length,m=gi(4+b+1),w=m+4;if(yt[m>>2]=b,n&&g)Xt(c,rt,w,b+1);else if(g)for(g=0;g<b;++g){var C=c.charCodeAt(g);255<C&&(ae(w),ht("String has UTF-16 code units that do not fit in 8 bits")),rt[w+g]=C}else for(g=0;g<b;++g)rt[w+g]=c[g];return o!==null&&o.push(ae,m),m},argPackAdvance:8,readValueFromPointer:Oe,de:function(o){ae(o)}})},N:function(t,i,n){if(n=bt(n),i===2)var o=Vn,c=Yn,g=Xn,b=()=>Ae,m=1;else i===4&&(o=Jn,c=qn,g=Qn,b=()=>yt,m=2);ee(t,{name:n,fromWireType:function(w){for(var C=yt[w>>2],L=b(),D,z=w+4,E=0;E<=C;++E){var H=w+4+E*i;(E==C||L[H>>m]==0)&&(z=o(z,H-z),D===void 0?D=z:(D+="\0",D+=z),z=H+i)}return ae(w),D},toWireType:function(w,C){typeof C!="string"&&ht(`Cannot pass non-string to C++ string type ${n}`);var L=g(C),D=gi(4+L+i);return yt[D>>2]=L>>m,c(C,D+4,L+i),w!==null&&w.push(ae,D),D},argPackAdvance:8,readValueFromPointer:Oe,de:function(w){ae(w)}})},D:function(t,i,n,o,c,g){Qe[t]={name:bt(i),hf:Ft(n,o),ke:Ft(c,g),rf:[]}},e:function(t,i,n,o,c,g,b,m,w,C){Qe[t].rf.push({Of:bt(i),Vf:n,Tf:Ft(o,c),Uf:g,fg:b,eg:Ft(m,w),gg:C})},Ib:function(t,i){i=bt(i),ee(t,{Yf:!0,name:i,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},Fb:()=>!0,ub:()=>{throw 1/0},F:function(t,i,n){t=Ut(t),i=We(i,"emval::as");var o=[],c=$t(o);return yt[n>>2]=c,i.toWireType(o,t)},Z:function(t,i,n,o,c){t=si[t],i=Ut(i),n=ai(n);var g=[];return yt[o>>2]=$t(g),t(i,n,g,c)},w:function(t,i,n,o){t=si[t],i=Ut(i),n=ai(n),t(i,n,null,o)},d:Ii,K:function(t){return t===0?$t(Er()):(t=ai(t),$t(Er()[t]))},u:function(t,i){var n=ea(t,i),o=n[0];i=o.name+"_$"+n.slice(1).map(function(b){return b.name}).join("_")+"$";var c=Mr[i];if(c!==void 0)return c;var g=Array(t-1);return c=ta((b,m,w,C)=>{for(var L=0,D=0;D<t-1;++D)g[D]=n[D+1].readValueFromPointer(C+L),L+=n[D+1].argPackAdvance;for(b=b[m].apply(b,g),D=0;D<t-1;++D)n[D+1].Lf&&n[D+1].Lf(g[D]);if(!o.Yf)return o.toWireType(w,b)}),Mr[i]=c},z:function(t,i){return t=Ut(t),i=Ut(i),$t(t[i])},p:function(t){4<t&&(Gt.get(t).wf+=1)},J:function(t,i,n,o){t=Ut(t);var c=Fr[i];return c||(c=ia(i),Fr[i]=c),c(t,n,o)},H:function(){return $t([])},g:function(t){return $t(ai(t))},G:function(){return $t({})},kb:function(t){return t=Ut(t),!t},B:function(t){var i=Ut(t);Ei(i),Ii(t)},i:function(t,i,n){t=Ut(t),i=Ut(i),n=Ut(n),t[i]=n},h:function(t,i){return t=We(t,"_emval_take_value"),t=t.readValueFromPointer(i),$t(t)},nb:function(){return-52},ob:function(){},a:()=>{_i("")},Eb:()=>performance.now(),vb:t=>{var i=rt.length;if(t>>>=0,2147483648<t)return!1;for(var n=1;4>=n;n*=2){var o=i*(1+.2/n);o=Math.min(o,t+100663296);var c=Math;o=Math.max(t,o);t:{c=c.min.call(c,2147483648,o+(65536-o%65536)%65536)-qe.buffer.byteLength+65535>>>16;try{qe.grow(c),sr();var g=1;break t}catch{}g=void 0}if(g)return!0}return!1},lb:function(){return Z?Z.handle:0},wb:(t,i)=>{var n=0;return Ir().forEach(function(o,c){var g=i+n;for(c=yt[t+4*c>>2]=g,g=0;g<o.length;++g)te[c++>>0]=o.charCodeAt(g);te[c>>0]=0,n+=o.length+1}),0},xb:(t,i)=>{var n=Ir();yt[t>>2]=n.length;var o=0;return n.forEach(function(c){o+=c.length+1}),yt[i>>2]=o,0},Jb:t=>{kn||(u.onExit&&u.onExit(t),Ci=!0),Q(t,new Nn(t))},M:()=>52,mb:function(){return 52},Cb:()=>52,pb:function(){return 70},S:(t,i,n,o)=>{for(var c=0,g=0;g<n;g++){var b=yt[i>>2],m=yt[i+4>>2];i+=8;for(var w=0;w<m;w++){var C=rt[b+w],L=ha[t];C===0||C===10?((t===1?Rn:se)(fe(L,0)),L.length=0):L.push(C)}c+=m}return yt[o>>2]=c,0},aa:function(t){_.activeTexture(t)},ba:function(t,i){_.attachShader(qt[t],Qt[i])},ca:function(t,i,n){_.bindAttribLocation(qt[t],i,n?fe(rt,n):"")},da:function(t,i){t==35051?_.ef=i:t==35052&&(_.De=i),_.bindBuffer(t,oi[i])},$:function(t,i){_.bindFramebuffer(t,li[i])},fc:function(t,i){_.bindRenderbuffer(t,Ge[i])},Rb:function(t,i){_.bindSampler(t,ge[i])},ea:function(t,i){_.bindTexture(t,zt[i])},zc:Nr,Cc:Nr,fa:function(t,i,n,o){_.blendColor(t,i,n,o)},ga:function(t){_.blendEquation(t)},ha:function(t,i){_.blendFunc(t,i)},$b:function(t,i,n,o,c,g,b,m,w,C){_.blitFramebuffer(t,i,n,o,c,g,b,m,w,C)},ia:function(t,i,n,o){2<=Z.version?n&&i?_.bufferData(t,rt,o,n,i):_.bufferData(t,i,o):_.bufferData(t,n?rt.subarray(n,n+i):i,o)},ja:function(t,i,n,o){2<=Z.version?n&&_.bufferSubData(t,i,rt,o,n):_.bufferSubData(t,i,rt.subarray(o,o+n))},gc:function(t){return _.checkFramebufferStatus(t)},Q:function(t){_.clear(t)},_:function(t,i,n,o){_.clearColor(t,i,n,o)},R:function(t){_.clearStencil(t)},sb:function(t,i,n,o){return _.clientWaitSync(me[t],i,(n>>>0)+4294967296*o)},ka:function(t,i,n,o){_.colorMask(!!t,!!i,!!n,!!o)},la:function(t){_.compileShader(Qt[t])},ma:function(t,i,n,o,c,g,b,m){2<=Z.version?_.De||!b?_.compressedTexImage2D(t,i,n,o,c,g,b,m):_.compressedTexImage2D(t,i,n,o,c,g,rt,m,b):_.compressedTexImage2D(t,i,n,o,c,g,m?rt.subarray(m,m+b):null)},na:function(t,i,n,o,c,g,b,m,w){2<=Z.version?_.De||!m?_.compressedTexSubImage2D(t,i,n,o,c,g,b,m,w):_.compressedTexSubImage2D(t,i,n,o,c,g,b,rt,w,m):_.compressedTexSubImage2D(t,i,n,o,c,g,b,w?rt.subarray(w,w+m):null)},Zb:function(t,i,n,o,c){_.copyBufferSubData(t,i,n,o,c)},oa:function(t,i,n,o,c,g,b,m){_.copyTexSubImage2D(t,i,n,o,c,g,b,m)},pa:function(){var t=_e(qt),i=_.createProgram();return i.name=t,i.Ye=i.We=i.Xe=0,i.kf=1,qt[t]=i,t},qa:function(t){var i=_e(Qt);return Qt[i]=_.createShader(t),i},ra:function(t){_.cullFace(t)},sa:function(t,i){for(var n=0;n<t;n++){var o=$[i+4*n>>2],c=oi[o];c&&(_.deleteBuffer(c),c.name=0,oi[o]=null,o==_.ef&&(_.ef=0),o==_.De&&(_.De=0))}},hc:function(t,i){for(var n=0;n<t;++n){var o=$[i+4*n>>2],c=li[o];c&&(_.deleteFramebuffer(c),c.name=0,li[o]=null)}},ta:function(t){if(t){var i=qt[t];i?(_.deleteProgram(i),i.name=0,qt[t]=null):wt(1281)}},ic:function(t,i){for(var n=0;n<t;n++){var o=$[i+4*n>>2],c=Ge[o];c&&(_.deleteRenderbuffer(c),c.name=0,Ge[o]=null)}},Sb:function(t,i){for(var n=0;n<t;n++){var o=$[i+4*n>>2],c=ge[o];c&&(_.deleteSampler(c),c.name=0,ge[o]=null)}},ua:function(t){if(t){var i=Qt[t];i?(_.deleteShader(i),Qt[t]=null):wt(1281)}},_b:function(t){if(t){var i=me[t];i?(_.deleteSync(i),i.name=0,me[t]=null):wt(1281)}},va:function(t,i){for(var n=0;n<t;n++){var o=$[i+4*n>>2],c=zt[o];c&&(_.deleteTexture(c),c.name=0,zt[o]=null)}},Ac:Dr,Dc:Dr,wa:function(t){_.depthMask(!!t)},xa:function(t){_.disable(t)},ya:function(t){_.disableVertexAttribArray(t)},za:function(t,i,n){_.drawArrays(t,i,n)},xc:function(t,i,n,o){_.drawArraysInstanced(t,i,n,o)},vc:function(t,i,n,o,c){_.pf.drawArraysInstancedBaseInstanceWEBGL(t,i,n,o,c)},tc:function(t,i){for(var n=ui[t],o=0;o<t;o++)n[o]=$[i+4*o>>2];_.drawBuffers(n)},Aa:Br,yc:function(t,i,n,o,c){_.drawElementsInstanced(t,i,n,o,c)},wc:function(t,i,n,o,c,g,b){_.pf.drawElementsInstancedBaseVertexBaseInstanceWEBGL(t,i,n,o,c,g,b)},nc:function(t,i,n,o,c,g){Br(t,o,c,g)},Ba:function(t){_.enable(t)},Ca:function(t){_.enableVertexAttribArray(t)},Xb:function(t,i){return(t=_.fenceSync(t,i))?(i=_e(me),t.name=i,me[i]=t,i):0},Da:function(){_.finish()},Ea:function(){_.flush()},jc:function(t,i,n,o){_.framebufferRenderbuffer(t,i,n,Ge[o])},kc:function(t,i,n,o,c){_.framebufferTexture2D(t,i,n,zt[o],c)},Fa:function(t){_.frontFace(t)},Ga:function(t,i){Te(t,i,"createBuffer",oi)},lc:function(t,i){Te(t,i,"createFramebuffer",li)},mc:function(t,i){Te(t,i,"createRenderbuffer",Ge)},Tb:function(t,i){Te(t,i,"createSampler",ge)},Ha:function(t,i){Te(t,i,"createTexture",zt)},Bc:Wr,Ec:Wr,bc:function(t){_.generateMipmap(t)},Ia:function(t,i,n){n?$[n>>2]=_.getBufferParameter(t,i):wt(1281)},Ja:function(){var t=_.getError()||ci;return ci=0,t},Ka:function(t,i){Gr(t,i,2)},cc:function(t,i,n,o){t=_.getFramebufferAttachmentParameter(t,i,n),(t instanceof WebGLRenderbuffer||t instanceof WebGLTexture)&&(t=t.name|0),$[o>>2]=t},L:function(t,i){Gr(t,i,0)},La:function(t,i,n,o){t=_.getProgramInfoLog(qt[t]),t===null&&(t="(unknown error)"),i=0<i&&o?Xt(t,rt,o,i):0,n&&($[n>>2]=i)},Ma:function(t,i,n){if(n)if(t>=xr)wt(1281);else if(t=qt[t],i==35716)t=_.getProgramInfoLog(t),t===null&&(t="(unknown error)"),$[n>>2]=t.length+1;else if(i==35719){if(!t.Ye)for(i=0;i<_.getProgramParameter(t,35718);++i)t.Ye=Math.max(t.Ye,_.getActiveUniform(t,i).name.length+1);$[n>>2]=t.Ye}else if(i==35722){if(!t.We)for(i=0;i<_.getProgramParameter(t,35721);++i)t.We=Math.max(t.We,_.getActiveAttrib(t,i).name.length+1);$[n>>2]=t.We}else if(i==35381){if(!t.Xe)for(i=0;i<_.getProgramParameter(t,35382);++i)t.Xe=Math.max(t.Xe,_.getActiveUniformBlockName(t,i).length+1);$[n>>2]=t.Xe}else $[n>>2]=_.getProgramParameter(t,i);else wt(1281)},dc:function(t,i,n){n?$[n>>2]=_.getRenderbufferParameter(t,i):wt(1281)},Na:function(t,i,n,o){t=_.getShaderInfoLog(Qt[t]),t===null&&(t="(unknown error)"),i=0<i&&o?Xt(t,rt,o,i):0,n&&($[n>>2]=i)},Ob:function(t,i,n,o){t=_.getShaderPrecisionFormat(t,i),$[n>>2]=t.rangeMin,$[n+4>>2]=t.rangeMax,$[o>>2]=t.precision},Oa:function(t,i,n){n?i==35716?(t=_.getShaderInfoLog(Qt[t]),t===null&&(t="(unknown error)"),$[n>>2]=t?t.length+1:0):i==35720?(t=_.getShaderSource(Qt[t]),$[n>>2]=t?t.length+1:0):$[n>>2]=_.getShaderParameter(Qt[t],i):wt(1281)},P:function(t){var i=Rr[t];if(!i){switch(t){case 7939:i=_.getSupportedExtensions()||[],i=i.concat(i.map(function(o){return"GL_"+o})),i=Ue(i.join(" "));break;case 7936:case 7937:case 37445:case 37446:(i=_.getParameter(t))||wt(1280),i=i&&Ue(i);break;case 7938:i=_.getParameter(7938),i=2<=Z.version?"OpenGL ES 3.0 ("+i+")":"OpenGL ES 2.0 ("+i+")",i=Ue(i);break;case 35724:i=_.getParameter(35724);var n=i.match(/^WebGL GLSL ES ([0-9]\.[0-9][0-9]?)(?:$| .*)/);n!==null&&(n[1].length==3&&(n[1]+="0"),i="OpenGL ES GLSL ES "+n[1]+" ("+i+")"),i=Ue(i);break;default:wt(1280)}Rr[t]=i}return i},jb:function(t,i){if(2>Z.version)return wt(1282),0;var n=kr[t];if(n)return 0>i||i>=n.length?(wt(1281),0):n[i];switch(t){case 7939:return n=_.getSupportedExtensions()||[],n=n.concat(n.map(function(o){return"GL_"+o})),n=n.map(function(o){return Ue(o)}),n=kr[t]=n,0>i||i>=n.length?(wt(1281),0):n[i];default:return wt(1280),0}},Pa:function(t,i){if(i=i?fe(rt,i):"",t=qt[t]){var n=t,o=n.Ne,c=n.yf,g;if(!o)for(n.Ne=o={},n.xf={},g=0;g<_.getProgramParameter(n,35718);++g){var b=_.getActiveUniform(n,g),m=b.name;b=b.size;var w=Ur(m);w=0<w?m.slice(0,w):m;var C=n.kf;for(n.kf+=b,c[w]=[b,C],m=0;m<b;++m)o[C]=m,n.xf[C++]=w}if(n=t.Ne,o=0,c=i,g=Ur(i),0<g&&(o=parseInt(i.slice(g+1))>>>0,c=i.slice(0,g)),(c=t.yf[c])&&o<c[0]&&(o+=c[1],n[o]=n[o]||_.getUniformLocation(t,i)))return o}else wt(1281);return-1},Pb:function(t,i,n){for(var o=ui[i],c=0;c<i;c++)o[c]=$[n+4*c>>2];_.invalidateFramebuffer(t,o)},Qb:function(t,i,n,o,c,g,b){for(var m=ui[i],w=0;w<i;w++)m[w]=$[n+4*w>>2];_.invalidateSubFramebuffer(t,m,o,c,g,b)},Yb:function(t){return _.isSync(me[t])},Qa:function(t){return(t=zt[t])?_.isTexture(t):0},Ra:function(t){_.lineWidth(t)},Sa:function(t){t=qt[t],_.linkProgram(t),t.Ne=0,t.yf={}},rc:function(t,i,n,o,c,g){_.uf.multiDrawArraysInstancedBaseInstanceWEBGL(t,$,i>>2,$,n>>2,$,o>>2,yt,c>>2,g)},sc:function(t,i,n,o,c,g,b,m){_.uf.multiDrawElementsInstancedBaseVertexBaseInstanceWEBGL(t,$,i>>2,n,$,o>>2,$,c>>2,$,g>>2,yt,b>>2,m)},Ta:function(t,i){t==3317&&(Or=i),_.pixelStorei(t,i)},uc:function(t){_.readBuffer(t)},Ua:function(t,i,n,o,c,g,b){if(2<=Z.version)if(_.ef)_.readPixels(t,i,n,o,c,g,b);else{var m=di(g);_.readPixels(t,i,n,o,c,g,m,b>>31-Math.clz32(m.BYTES_PER_ELEMENT))}else(b=Wi(g,c,n,o,b))?_.readPixels(t,i,n,o,c,g,b):wt(1280)},ec:function(t,i,n,o){_.renderbufferStorage(t,i,n,o)},ac:function(t,i,n,o,c){_.renderbufferStorageMultisample(t,i,n,o,c)},Ub:function(t,i,n){_.samplerParameterf(ge[t],i,n)},Vb:function(t,i,n){_.samplerParameteri(ge[t],i,n)},Wb:function(t,i,n){_.samplerParameteri(ge[t],i,$[n>>2])},Va:function(t,i,n,o){_.scissor(t,i,n,o)},Wa:function(t,i,n,o){for(var c="",g=0;g<i;++g){var b=o?$[o+4*g>>2]:-1,m=$[n+4*g>>2];b=m?fe(rt,m,0>b?void 0:b):"",c+=b}_.shaderSource(Qt[t],c)},Xa:function(t,i,n){_.stencilFunc(t,i,n)},Ya:function(t,i,n,o){_.stencilFuncSeparate(t,i,n,o)},Za:function(t){_.stencilMask(t)},_a:function(t,i){_.stencilMaskSeparate(t,i)},$a:function(t,i,n){_.stencilOp(t,i,n)},ab:function(t,i,n,o){_.stencilOpSeparate(t,i,n,o)},bb:function(t,i,n,o,c,g,b,m,w){if(2<=Z.version)if(_.De)_.texImage2D(t,i,n,o,c,g,b,m,w);else if(w){var C=di(m);_.texImage2D(t,i,n,o,c,g,b,m,C,w>>31-Math.clz32(C.BYTES_PER_ELEMENT))}else _.texImage2D(t,i,n,o,c,g,b,m,null);else _.texImage2D(t,i,n,o,c,g,b,m,w?Wi(m,b,o,c,w):null)},cb:function(t,i,n){_.texParameterf(t,i,n)},db:function(t,i,n){_.texParameterf(t,i,J[n>>2])},eb:function(t,i,n){_.texParameteri(t,i,n)},fb:function(t,i,n){_.texParameteri(t,i,$[n>>2])},oc:function(t,i,n,o,c){_.texStorage2D(t,i,n,o,c)},gb:function(t,i,n,o,c,g,b,m,w){if(2<=Z.version)if(_.De)_.texSubImage2D(t,i,n,o,c,g,b,m,w);else if(w){var C=di(m);_.texSubImage2D(t,i,n,o,c,g,b,m,C,w>>31-Math.clz32(C.BYTES_PER_ELEMENT))}else _.texSubImage2D(t,i,n,o,c,g,b,m,null);else C=null,w&&(C=Wi(m,b,c,g,w)),_.texSubImage2D(t,i,n,o,c,g,b,m,C)},hb:function(t,i){_.uniform1f(ft(t),i)},ib:function(t,i,n){if(2<=Z.version)i&&_.uniform1fv(ft(t),J,n>>2,i);else{if(288>=i)for(var o=he[i-1],c=0;c<i;++c)o[c]=J[n+4*c>>2];else o=J.subarray(n>>2,n+4*i>>2);_.uniform1fv(ft(t),o)}},Zc:function(t,i){_.uniform1i(ft(t),i)},_c:function(t,i,n){if(2<=Z.version)i&&_.uniform1iv(ft(t),$,n>>2,i);else{if(288>=i)for(var o=$e[i-1],c=0;c<i;++c)o[c]=$[n+4*c>>2];else o=$.subarray(n>>2,n+4*i>>2);_.uniform1iv(ft(t),o)}},$c:function(t,i,n){_.uniform2f(ft(t),i,n)},ad:function(t,i,n){if(2<=Z.version)i&&_.uniform2fv(ft(t),J,n>>2,2*i);else{if(144>=i)for(var o=he[2*i-1],c=0;c<2*i;c+=2)o[c]=J[n+4*c>>2],o[c+1]=J[n+(4*c+4)>>2];else o=J.subarray(n>>2,n+8*i>>2);_.uniform2fv(ft(t),o)}},Yc:function(t,i,n){_.uniform2i(ft(t),i,n)},Xc:function(t,i,n){if(2<=Z.version)i&&_.uniform2iv(ft(t),$,n>>2,2*i);else{if(144>=i)for(var o=$e[2*i-1],c=0;c<2*i;c+=2)o[c]=$[n+4*c>>2],o[c+1]=$[n+(4*c+4)>>2];else o=$.subarray(n>>2,n+8*i>>2);_.uniform2iv(ft(t),o)}},Wc:function(t,i,n,o){_.uniform3f(ft(t),i,n,o)},Vc:function(t,i,n){if(2<=Z.version)i&&_.uniform3fv(ft(t),J,n>>2,3*i);else{if(96>=i)for(var o=he[3*i-1],c=0;c<3*i;c+=3)o[c]=J[n+4*c>>2],o[c+1]=J[n+(4*c+4)>>2],o[c+2]=J[n+(4*c+8)>>2];else o=J.subarray(n>>2,n+12*i>>2);_.uniform3fv(ft(t),o)}},Uc:function(t,i,n,o){_.uniform3i(ft(t),i,n,o)},Tc:function(t,i,n){if(2<=Z.version)i&&_.uniform3iv(ft(t),$,n>>2,3*i);else{if(96>=i)for(var o=$e[3*i-1],c=0;c<3*i;c+=3)o[c]=$[n+4*c>>2],o[c+1]=$[n+(4*c+4)>>2],o[c+2]=$[n+(4*c+8)>>2];else o=$.subarray(n>>2,n+12*i>>2);_.uniform3iv(ft(t),o)}},Sc:function(t,i,n,o,c){_.uniform4f(ft(t),i,n,o,c)},Rc:function(t,i,n){if(2<=Z.version)i&&_.uniform4fv(ft(t),J,n>>2,4*i);else{if(72>=i){var o=he[4*i-1],c=J;n>>=2;for(var g=0;g<4*i;g+=4){var b=n+g;o[g]=c[b],o[g+1]=c[b+1],o[g+2]=c[b+2],o[g+3]=c[b+3]}}else o=J.subarray(n>>2,n+16*i>>2);_.uniform4fv(ft(t),o)}},Fc:function(t,i,n,o,c){_.uniform4i(ft(t),i,n,o,c)},Gc:function(t,i,n){if(2<=Z.version)i&&_.uniform4iv(ft(t),$,n>>2,4*i);else{if(72>=i)for(var o=$e[4*i-1],c=0;c<4*i;c+=4)o[c]=$[n+4*c>>2],o[c+1]=$[n+(4*c+4)>>2],o[c+2]=$[n+(4*c+8)>>2],o[c+3]=$[n+(4*c+12)>>2];else o=$.subarray(n>>2,n+16*i>>2);_.uniform4iv(ft(t),o)}},Hc:function(t,i,n,o){if(2<=Z.version)i&&_.uniformMatrix2fv(ft(t),!!n,J,o>>2,4*i);else{if(72>=i)for(var c=he[4*i-1],g=0;g<4*i;g+=4)c[g]=J[o+4*g>>2],c[g+1]=J[o+(4*g+4)>>2],c[g+2]=J[o+(4*g+8)>>2],c[g+3]=J[o+(4*g+12)>>2];else c=J.subarray(o>>2,o+16*i>>2);_.uniformMatrix2fv(ft(t),!!n,c)}},Ic:function(t,i,n,o){if(2<=Z.version)i&&_.uniformMatrix3fv(ft(t),!!n,J,o>>2,9*i);else{if(32>=i)for(var c=he[9*i-1],g=0;g<9*i;g+=9)c[g]=J[o+4*g>>2],c[g+1]=J[o+(4*g+4)>>2],c[g+2]=J[o+(4*g+8)>>2],c[g+3]=J[o+(4*g+12)>>2],c[g+4]=J[o+(4*g+16)>>2],c[g+5]=J[o+(4*g+20)>>2],c[g+6]=J[o+(4*g+24)>>2],c[g+7]=J[o+(4*g+28)>>2],c[g+8]=J[o+(4*g+32)>>2];else c=J.subarray(o>>2,o+36*i>>2);_.uniformMatrix3fv(ft(t),!!n,c)}},Jc:function(t,i,n,o){if(2<=Z.version)i&&_.uniformMatrix4fv(ft(t),!!n,J,o>>2,16*i);else{if(18>=i){var c=he[16*i-1],g=J;o>>=2;for(var b=0;b<16*i;b+=16){var m=o+b;c[b]=g[m],c[b+1]=g[m+1],c[b+2]=g[m+2],c[b+3]=g[m+3],c[b+4]=g[m+4],c[b+5]=g[m+5],c[b+6]=g[m+6],c[b+7]=g[m+7],c[b+8]=g[m+8],c[b+9]=g[m+9],c[b+10]=g[m+10],c[b+11]=g[m+11],c[b+12]=g[m+12],c[b+13]=g[m+13],c[b+14]=g[m+14],c[b+15]=g[m+15]}}else c=J.subarray(o>>2,o+64*i>>2);_.uniformMatrix4fv(ft(t),!!n,c)}},Kc:function(t){t=qt[t],_.useProgram(t),_.Kf=t},Lc:function(t,i){_.vertexAttrib1f(t,i)},Mc:function(t,i){_.vertexAttrib2f(t,J[i>>2],J[i+4>>2])},Nc:function(t,i){_.vertexAttrib3f(t,J[i>>2],J[i+4>>2],J[i+8>>2])},Oc:function(t,i){_.vertexAttrib4f(t,J[i>>2],J[i+4>>2],J[i+8>>2],J[i+12>>2])},pc:function(t,i){_.vertexAttribDivisor(t,i)},qc:function(t,i,n,o,c){_.vertexAttribIPointer(t,i,n,o,c)},Pc:function(t,i,n,o,c,g){_.vertexAttribPointer(t,i,n,!!o,c,g)},Qc:function(t,i,n,o){_.viewport(t,i,n,o)},rb:function(t,i,n,o){_.waitSync(me[t],i,(n>>>0)+4294967296*o)},j:ma,n:ba,k:ga,I:_a,Lb:Ta,Y:Ea,X:Fa,O:Sa,o:Pa,x:wa,r:ya,v:Aa,Kb:Ma,Mb:Ca,Nb:va,tb:(t,i,n,o)=>ua(t,i,n,o)};(function(){function t(n){if(at=n=n.exports,qe=at.bd,sr(),Tt=at.dd,lr.unshift(at.cd),de--,u.monitorRunDependencies&&u.monitorRunDependencies(de),de==0&&ke){var o=ke;ke=null,o()}return n}var i={a:pa};if(de++,u.monitorRunDependencies&&u.monitorRunDependencies(de),u.instantiateWasm)try{return u.instantiateWasm(i,t)}catch(n){se("Module.instantiateWasm callback failed with error: "+n),x(n)}return In(i,function(n){t(n.instance)}).catch(x),{}})();var ae=u._free=t=>(ae=u._free=at.ed)(t),gi=u._malloc=t=>(gi=u._malloc=at.fd)(t),Hr=t=>(Hr=at.gd)(t);u.__embind_initialize_bindings=()=>(u.__embind_initialize_bindings=at.hd)();var xt=(t,i)=>(xt=at.id)(t,i),Rt=()=>(Rt=at.jd)(),kt=t=>(kt=at.kd)(t);u.dynCall_viji=(t,i,n,o,c)=>(u.dynCall_viji=at.ld)(t,i,n,o,c),u.dynCall_vijiii=(t,i,n,o,c,g,b)=>(u.dynCall_vijiii=at.md)(t,i,n,o,c,g,b),u.dynCall_viiiiij=(t,i,n,o,c,g,b,m)=>(u.dynCall_viiiiij=at.nd)(t,i,n,o,c,g,b,m),u.dynCall_jiiiijiiiii=(t,i,n,o,c,g,b,m,w,C,L,D)=>(u.dynCall_jiiiijiiiii=at.od)(t,i,n,o,c,g,b,m,w,C,L,D),u.dynCall_viiij=(t,i,n,o,c,g)=>(u.dynCall_viiij=at.pd)(t,i,n,o,c,g),u.dynCall_jii=(t,i,n)=>(u.dynCall_jii=at.qd)(t,i,n),u.dynCall_vij=(t,i,n,o)=>(u.dynCall_vij=at.rd)(t,i,n,o),u.dynCall_iiij=(t,i,n,o,c)=>(u.dynCall_iiij=at.sd)(t,i,n,o,c),u.dynCall_iiiij=(t,i,n,o,c,g)=>(u.dynCall_iiiij=at.td)(t,i,n,o,c,g),u.dynCall_viij=(t,i,n,o,c)=>(u.dynCall_viij=at.ud)(t,i,n,o,c),u.dynCall_ji=(t,i)=>(u.dynCall_ji=at.vd)(t,i),u.dynCall_iij=(t,i,n,o)=>(u.dynCall_iij=at.wd)(t,i,n,o),u.dynCall_jiiiiii=(t,i,n,o,c,g,b)=>(u.dynCall_jiiiiii=at.xd)(t,i,n,o,c,g,b),u.dynCall_jiiiiji=(t,i,n,o,c,g,b,m)=>(u.dynCall_jiiiiji=at.yd)(t,i,n,o,c,g,b,m),u.dynCall_iijj=(t,i,n,o,c,g)=>(u.dynCall_iijj=at.zd)(t,i,n,o,c,g),u.dynCall_iiiji=(t,i,n,o,c,g)=>(u.dynCall_iiiji=at.Ad)(t,i,n,o,c,g),u.dynCall_iiji=(t,i,n,o,c)=>(u.dynCall_iiji=at.Bd)(t,i,n,o,c),u.dynCall_iijjiii=(t,i,n,o,c,g,b,m,w)=>(u.dynCall_iijjiii=at.Cd)(t,i,n,o,c,g,b,m,w),u.dynCall_vijjjii=(t,i,n,o,c,g,b,m,w,C)=>(u.dynCall_vijjjii=at.Dd)(t,i,n,o,c,g,b,m,w,C),u.dynCall_jiji=(t,i,n,o,c)=>(u.dynCall_jiji=at.Ed)(t,i,n,o,c),u.dynCall_viijii=(t,i,n,o,c,g,b)=>(u.dynCall_viijii=at.Fd)(t,i,n,o,c,g,b),u.dynCall_iiiiij=(t,i,n,o,c,g,b)=>(u.dynCall_iiiiij=at.Gd)(t,i,n,o,c,g,b),u.dynCall_iiiiijj=(t,i,n,o,c,g,b,m,w)=>(u.dynCall_iiiiijj=at.Hd)(t,i,n,o,c,g,b,m,w),u.dynCall_iiiiiijj=(t,i,n,o,c,g,b,m,w,C)=>(u.dynCall_iiiiiijj=at.Id)(t,i,n,o,c,g,b,m,w,C);function ga(t,i,n,o){var c=Rt();try{return Tt.get(t)(i,n,o)}catch(g){if(kt(c),g!==g+0)throw g;xt(1,0)}}function ma(t,i){var n=Rt();try{return Tt.get(t)(i)}catch(o){if(kt(n),o!==o+0)throw o;xt(1,0)}}function va(t,i,n,o,c,g,b,m,w,C){var L=Rt();try{Tt.get(t)(i,n,o,c,g,b,m,w,C)}catch(D){if(kt(L),D!==D+0)throw D;xt(1,0)}}function ya(t,i,n,o){var c=Rt();try{Tt.get(t)(i,n,o)}catch(g){if(kt(c),g!==g+0)throw g;xt(1,0)}}function wa(t,i,n){var o=Rt();try{Tt.get(t)(i,n)}catch(c){if(kt(o),c!==c+0)throw c;xt(1,0)}}function Sa(t){var i=Rt();try{Tt.get(t)()}catch(n){if(kt(i),n!==n+0)throw n;xt(1,0)}}function Aa(t,i,n,o,c){var g=Rt();try{Tt.get(t)(i,n,o,c)}catch(b){if(kt(g),b!==b+0)throw b;xt(1,0)}}function Pa(t,i){var n=Rt();try{Tt.get(t)(i)}catch(o){if(kt(n),o!==o+0)throw o;xt(1,0)}}function ba(t,i,n){var o=Rt();try{return Tt.get(t)(i,n)}catch(c){if(kt(o),c!==c+0)throw c;xt(1,0)}}function Ca(t,i,n,o,c,g,b){var m=Rt();try{Tt.get(t)(i,n,o,c,g,b)}catch(w){if(kt(m),w!==w+0)throw w;xt(1,0)}}function _a(t,i,n,o,c){var g=Rt();try{return Tt.get(t)(i,n,o,c)}catch(b){if(kt(g),b!==b+0)throw b;xt(1,0)}}function Ta(t,i,n,o,c,g){var b=Rt();try{return Tt.get(t)(i,n,o,c,g)}catch(m){if(kt(b),m!==m+0)throw m;xt(1,0)}}function Ea(t,i,n,o,c,g,b){var m=Rt();try{return Tt.get(t)(i,n,o,c,g,b)}catch(w){if(kt(m),w!==w+0)throw w;xt(1,0)}}function Ma(t,i,n,o,c,g){var b=Rt();try{Tt.get(t)(i,n,o,c,g)}catch(m){if(kt(b),m!==m+0)throw m;xt(1,0)}}function Fa(t,i,n,o,c,g,b,m,w,C){var L=Rt();try{return Tt.get(t)(i,n,o,c,g,b,m,w,C)}catch(D){if(kt(L),D!==D+0)throw D;xt(1,0)}}var mi;ke=function t(){mi||Kr(),mi||(ke=t)};function Kr(){function t(){if(!mi&&(mi=!0,u.calledRun=!0,!Ci)){if(Ti(lr),y(u),u.onRuntimeInitialized&&u.onRuntimeInitialized(),u.postRun)for(typeof u.postRun=="function"&&(u.postRun=[u.postRun]);u.postRun.length;){var i=u.postRun.shift();hr.unshift(i)}Ti(hr)}}if(!(0<de)){if(u.preRun)for(typeof u.preRun=="function"&&(u.preRun=[u.preRun]);u.preRun.length;)On();Ti(or),0<de||(u.setStatus?(u.setStatus("Running..."),setTimeout(function(){setTimeout(function(){u.setStatus("")},1),t()},1)):t())}}if(u.preInit)for(typeof u.preInit=="function"&&(u.preInit=[u.preInit]);0<u.preInit.length;)u.preInit.pop()();return Kr(),p.ready}})();v.exports=r})(fn);var Ya=fn.exports,Xa=Wa(Ya);const Vt={Deferred:"Deferred",Loading:"Loading",Ready:"Ready",Error:"Error"};class Pi extends we{constructor(e={}){super(e),this.type=pt.Sprite,this.isDrawable=!0,this.anchorPoint={x:.5,y:.5},this.zPosition=0,this._imageName="",ye(this,e),e.imageName!==void 0&&(this.imageName=e.imageName)}initialize(){if(this.m2Image=this.game.imageManager.getImage(this._imageName),!this.m2Image)throw new Error(`could not create sprite. the image named ${this._imageName} has not been loaded`);this.size.width=this.m2Image.width,this.size.height=this.m2Image.height,this._paint||(this.paint=new this.canvasKit.Paint),this.needsInitialization=!1}dispose(){Et.Dispose([this.m2Image?.canvaskitImage,this._paint])}set imageName(e){this._imageName=e,this.needsInitialization=!0}get imageName(){return this._imageName}set paint(e){this._paint=e}get paint(){if(!this._paint)throw new Error(`in paint getter: Sprite node ${this.toString()} paint is undefined.`);return this._paint}duplicate(e){const r=new Pi({...this.getNodeOptions(),...this.getDrawableOptions(),imageName:this.imageName,name:e});return this.children.length>0&&(r.children=this.children.map(l=>{const p=l.duplicate();return p.parent=r,p})),r}update(){super.update()}draw(e){if(!this.hidden){if(this.m2Image){e.save();const r=Globals.canvasScale/this.absoluteScale;e.scale(1/r,1/r),nt.rotateCanvasForDrawableNode(e,this);const l=(this.absolutePosition.x-this.size.width*this.anchorPoint.x*this.absoluteScale)*r,p=(this.absolutePosition.y-this.size.height*this.anchorPoint.y*this.absoluteScale)*r;if(this.absoluteAlphaChange!==0&&this.paint.setAlphaf(this.absoluteAlpha),this.m2Image.status===Vt.Ready&&this.m2Image.canvaskitImage)e.drawImage(this.m2Image.canvaskitImage,l,p,this.paint);else if(this.m2Image.status===Vt.Deferred&&(console.log(`begin loading lazy image ${this.m2Image.imageName} for Sprite node ${this.toString()}`),this.game.imageManager.prepareDeferredImage(this.m2Image)),this.m2Image.status===Vt.Error)throw new Error(`error status on image ${this.m2Image.imageName} for Sprite node ${this.toString()}`);e.restore()}super.drawChildren(e)}}warmup(e){if(this.m2Image?.status===Vt.Ready){if(this.initialize(),!this.m2Image)throw new Error(`in Sprite.warmup(): Sprite node ${this.toString()}: image not loaded.`);if(!this.m2Image.canvaskitImage)throw new Error(`in Sprite.warmup(): Sprite node ${this.toString()} image ${this.m2Image.imageName} is undefined.`);e.drawImage(this.m2Image.canvaskitImage,0,0)}this.children.forEach(r=>{r.isDrawable&&r.warmup(e)})}}class Je extends we{constructor(e={}){super(e),this.type=pt.Scene,this.isDrawable=!0,this.anchorPoint={x:0,y:0},this.zPosition=0,this._backgroundColor=V.DEFAULT_SCENE_BACKGROUND_COLOR,this._active=!1,this._transitioning=!1,ye(this,e),e.backgroundColor&&(this.backgroundColor=e.backgroundColor)}initialize(){this.scale=Globals.rootScale,this.size.width=this.game.canvasCssWidth,this.size.height=this.game.canvasCssHeight,this.backgroundPaint&&this.backgroundPaint.delete(),this.backgroundPaint=Et.makePaint(this.canvasKit,this.backgroundColor,this.canvasKit.PaintStyle.Fill,!1),this.needsInitialization=!1}dispose(){Et.Dispose([this.backgroundPaint])}set game(e){this._game=e}get game(){if(this._game===void 0)throw new Error(`Scene ${this} has not been added to a game.`);return this._game}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=e,this.needsInitialization=!0}duplicate(e){const r=new Je({...this.getNodeOptions(),...this.getDrawableOptions(),backgroundColor:this.backgroundColor,name:e});return r.game=this.game,this.children.length>0&&(r.children=this.children.map(l=>{const p=l.duplicate();return p.parent=r,p})),r}onSetup(e,r){this.addEventListener("SceneSetup",e,r)}onAppear(e,r){this.addEventListener("SceneAppear",e,r)}update(){super.update()}draw(e){e.save();const r=Globals.canvasScale/this.absoluteScale;if(e.scale(1/r,1/r),nt.rotateCanvasForDrawableNode(e,this),!this.backgroundPaint)throw new Error(`in Scene ${this}, background paint is undefined.`);this.absoluteAlphaChange!==0&&this.backgroundPaint.setAlphaf(this.absoluteAlpha),e.drawRect([this.position.x*r*Globals.rootScale,this.position.y*r*Globals.rootScale,(this.position.x+this.size.width)*r*Globals.rootScale,(this.position.y+this.size.height)*r*Globals.rootScale],this.backgroundPaint),e.restore(),super.drawChildren(e)}warmup(e){this.initialize(),e.save();const r=Globals.canvasScale/this.absoluteScale;if(e.scale(1/r,1/r),!this.backgroundPaint)throw new Error(`in Scene ${this}, background paint is undefined.`);e.drawRect([this.position.x*r*Globals.rootScale,this.position.y*r*Globals.rootScale,(this.position.x+this.size.width)*r*Globals.rootScale,(this.position.y+this.size.height)*r*Globals.rootScale],this.backgroundPaint),e.restore(),this.children.forEach(l=>{l.isDrawable&&l.warmup(e)})}}class Si{static slide(e){return new bn(e.direction,e.duration,e.easing??mt.linear)}static none(){return new Pn}}class Pn extends Si{constructor(){super(),this.type="None",this.duration=NaN,this.easing=mt.none}}class bn extends Si{constructor(e,r,l){super(),this.type="Slide",this.direction=e,this.duration=r,this.easing=l}}var Xe=(v=>(v.Slide="Slide",v.None="None",v))(Xe||{}),Me=(v=>(v.Up="Up",v.Down="Down",v.Right="Right",v.Left="Left",v))(Me||{});class Cn{constructor(e,r){this.scene=e,this.transition=r}}const _n=class Fn{constructor(e){this.startTime=NaN,this.stopTime=NaN,this.stopped=!0,this.cumulativeElapsed=NaN,this.name=e}static now(){return window.performance.now()}static new(e){this._timers=this._timers.filter(l=>l.name!==e);const r=new Fn(e);r.cumulativeElapsed=0,this._timers.push(r)}static startNew(e){this.new(e),this.start(e)}static start(e){const r=this._timers.filter(l=>l.name===e).find(Boolean);if(r===void 0)throw new Error(`can't start timer. timer with name ${e} does not exist.`);if(r.stopped===!1)throw new Error(`can't start timer. timer with name ${e} is already started.`);r.startTime=window.performance.now(),r.stopped=!1}static stop(e){const r=this._timers.filter(l=>l.name===e).find(Boolean);if(r===void 0)throw new Error(`can't stop timer. timer with name ${e} does not exist.`);if(r.stopped===!0)throw new Error(`can't stop timer. timer with name ${e} is already stopped.`);r.stopTime=window.performance.now(),r.cumulativeElapsed=r.cumulativeElapsed+r.stopTime-r.startTime,r.stopped=!0}static elapsed(e){const r=this._timers.filter(l=>l.name===e).find(Boolean);if(r===void 0)throw new Error(`can't get elapsed time. timer with name ${e} does not exist.`);return r.stopped?r.cumulativeElapsed:r.cumulativeElapsed+window.performance.now()-r.startTime}static remove(e){if(this._timers.filter(l=>l.name===e).find(Boolean)===void 0)throw new Error(`can't remove timer. timer with name ${e} does not exist.`);this._timers=this._timers.filter(l=>l.name!=e)}static removeAll(){this._timers=new Array}static exists(e){return this._timers.some(r=>r.name===e)}};_n._timers=new Array;let Qi=_n;const Tn={type:"object",description:"Information about the user's device.",properties:{userAgent:{type:"string",description:"The user agent string returned by navigator.userAgent."},devicePixelRatio:{type:"number",description:"Ratio of physical pixels to CSS pixels."},screen:{type:"object",description:"Screen information returned by window.screen.",properties:{availHeight:{type:"number",description:"Height of screen, in pixels, excluding UI features."},availWidth:{type:"number",description:"Width of screen, in pixels, excluding UI features."},colorDepth:{type:"number",description:"Color depth of screen."},height:{type:"number",description:"Height of screen, in pixels"},width:{type:"number",description:"Width of screen, in pixels."},orientation:{type:"object",description:"Information about the device's orientation.",properties:{type:{type:"string",description:"The orientation type (ScreenOrientation.type)."},angle:{type:"number",description:"The orientation angle (ScreenOrientation.angle)."}}},pixelDepth:{type:"number",description:"Pixel depth of screen."}}},webGlRenderer:{type:"string",description:"WebGL driver vendor and renderer. Taken from WEBGL_debug_renderer_info."}}};class Zi{static getRendererString(){const e=document.createElement("canvas");e.id="webgl-renderer-info-canvas",e.height=0,e.width=0,e.hidden=!0,document.body.appendChild(e);const r=e.getContext("webgl");let l="no webgl context";if(!r)return l;const p=r.getExtension("WEBGL_debug_renderer_info");return p!=null?l=String(r.getParameter(p.UNMASKED_VENDOR_WEBGL))+", "+String(r.getParameter(p.UNMASKED_RENDERER_WEBGL)):l="no debug renderer info",e.remove(),l}static dispose(){const e=document.getElementById("webgl-renderer-info-canvas");e&&e.remove()}}class tr{constructor(e){this.locale="",this.fallbackLocale="en",this.environmentLocale=this.getEnvironmentLocale(),this.options=e,this._translations=this.mergeAdditionalTranslations(e.translations,e.additionalTranslations)??{},e.locale.toLowerCase()==="auto"?(this.locale=this.environmentLocale,this.locale||(e.fallbackLocale?(this.fallbackLocale=e.fallbackLocale,console.warn(`auto locale requested, but environment cannot provide locale. Using fallback locale ${e.fallbackLocale}`)):console.warn('auto locale requested, but environment cannot provide locale. Defaulting to "en".'))):(this.locale=e.locale,e.fallbackLocale&&(this.fallbackLocale=e.fallbackLocale))}static makeLocalizationParameters(){return JSON.parse(JSON.stringify({locale:{type:["string","null"],default:null,description:'Locale to use for localization, or "auto" to request from the environment.'},fallback_locale:{type:["string","null"],default:null,description:'Locale to use if requested locale translation is not available, or if "auto" locale was requested and environment cannot provide a locale.'},missing_translation_font_color:{type:["array","null"],default:null,description:"Font color for strings that are missing translation and use the fallback locale or untranslated string, [r,g,b,a].",items:{type:"number"}},translations:{type:["object","null"],default:null,description:"Additional translations for localization."}}))}t(e,r=!1){return r?this._translations[this.fallbackLocale]?.[e]:this._translations[this.locale]?.[e]}get translations(){return this._translations}set translations(e){this._translations=e}getEnvironmentLocale(){return navigator.languages&&navigator.languages.length?navigator.languages[0]:navigator.language}mergeAdditionalTranslations(e,r){if(!e&&!r)return;if(!r)return e;if(!e)return r;const l={},p=new Array;for(const u in e)p.push(u),l[u]={...e[u],...r[u]};for(const u in r)p.includes(u)||(l[u]=r[u]);return l}}class En{constructor(e,r){this.images={},this.game=e,this.baseUrls=r,this.canvasKit=e.canvasKit}initializeImages(e){return this.loadImages(e??[])}async loadImages(e){if(e.length===0)return;this.checkImageNamesForDuplicates(e);const r=e.map(l=>{let p=l.url;l.url&&!nt.urlHasScheme(l.url)&&(p=nt.getUrlFromManifest(this.game,`${this.baseUrls.assets}/${l.url}`));const u={imageName:l.imageName,url:p,svgString:l.svgString,canvaskitImage:void 0,width:l.width,height:l.height,status:l.lazy?Vt.Deferred:Vt.Loading};return this.images[l.imageName]=u,u.status===Vt.Loading?this.renderM2Image(u):Promise.resolve()});await Promise.all(r)}checkImageNamesForDuplicates(e){const l=(p=>p.filter((u,y)=>p.indexOf(u)!=y))(e.map(p=>p.imageName));if(l.length>0)throw new Error(`image names must be unique. these image names are duplicated within a game ${this.game.id}: `+l.join(", "))}prepareDeferredImage(e){return e.status=Vt.Loading,this.renderM2Image(e)}renderM2Image(e){const r=document.createElement("img"),l=p=>{if(!this.scratchCanvas||!this.ctx||!this.scale)throw new Error("image manager not set up");this.scratchCanvas.width=e.width*this.scale,this.scratchCanvas.height=e.height*this.scale,this.ctx.scale(this.scale,this.scale),this.ctx.clearRect(0,0,e.width,e.height),this.ctx.drawImage(r,0,0,e.width,e.height),this.scratchCanvas.toBlob(u=>{if(!u)throw new Error(`renderM2Image(): blob is undefined for ${e.imageName}`);u.arrayBuffer().then(y=>{const x=this.canvasKit.MakeImageFromEncoded(y);if(!x)throw new Error(`could not create image with name "${e.imageName}."`);console.log(`image loaded. name: ${e.imageName}, w: ${e.width}, h: ${e.height}`),this.images[e.imageName].canvaskitImage=x,this.images[e.imageName].status=Vt.Ready,this.game.nodes.filter(U=>U.type==="Sprite").forEach(U=>{U.imageName===e.imageName&&(U.needsInitialization=!0)}),p()})})};return new Promise((p,u)=>{if(r.width=e.width,r.height=e.height,r.crossOrigin="Anonymous",r.onerror=()=>{u(new Error(`unable to render image named ${e.imageName}. image source was ${e.svgString?"svgString":`url: ${e.url}`}`))},r.onload=()=>{l(p)},!e.svgString&&!e.url)throw new Error(`no svgString or url provided for image named ${e.imageName}`);if(e.svgString&&e.url)throw new Error(`provide svgString or url. both were provided for image named ${e.imageName}`);e.svgString?r.src="data:image/svg+xml,"+encodeURIComponent(e.svgString):e.url&&fetch(e.url).then(y=>y.arrayBuffer()).then(y=>{this.arrayBufferToBase64Async(y).then(x=>{const W=this.inferImageSubtypeFromUrl(e.url);r.src="data:image/"+W+";base64,"+x})})})}arrayBufferToBase64Async(e){return new Promise((r,l)=>{const p=new FileReader;p.onload=()=>{r(p.result?.toString().split(",")[1]??"")},p.onerror=l,p.readAsDataURL(new Blob([e]))})}inferImageSubtypeFromUrl(e){let r="jpeg";return e?.includes(".")&&(r=e.split(".").pop()?.toLowerCase()??"jpeg",r===""&&(r="jpeg")),r==="svg"&&(r="svg+xml"),r}getImage(e){return this.images[e]}addImage(e){this.images[e.imageName]=e}get scratchCanvas(){if(!this._scratchCanvas){this._scratchCanvas=document.createElement("canvas"),this._scratchCanvas.id=`m2c2kit-scratch-canvas-${this.game.id}-${Math.floor(Math.random()*1e6)}`,this._scratchCanvas.hidden=!0,document.body.appendChild(this._scratchCanvas);const e=this._scratchCanvas.getContext("2d");if(e===null)throw new Error("could not get 2d canvas context from scratch canvas");this.ctx=e,this.scale=window.devicePixelRatio}return this._scratchCanvas}removeScratchCanvas(){this.ctx=void 0,this._scratchCanvas?.remove()}}class Ja{constructor(e){if(this.type=Ye.Game,this.sessionUuid="",this.uuid=yi.generate(),this.canvasKitWasmVersion="0.39.1",this.beginTimestamp=NaN,this.beginIso8601Timestamp="",this.eventListeners=new Array,this.gameMetrics=new Array,this.stepCount=0,this.steppingNow=0,this.warmupFunctionQueue=new Array,this.warmupFinished=!1,this.plugins=[],this.staticTrialSchema={},this.data={trials:new Array},this.trialIndex=0,this.drawnFrames=0,this.lastFpsUpdate=0,this.nextFpsUpdate=0,this.fpsRate=0,this.animationFramesRequested=0,this.limitFps=!1,this.gameStopRequested=!1,this.webGlRendererInfo="",this.canvasCssWidth=0,this.canvasCssHeight=0,this.scenes=new Array,this.freeNodesScene=new Je({name:V.FREE_NODES_SCENE_NAME,backgroundColor:[255,255,255,0]}),this.incomingSceneTransitions=new Array,this.automaticTrialSchema={document_uuid:{type:"string",format:"uuid",description:"Unique identifier for this data document."},session_uuid:{type:"string",format:"uuid",description:"Unique identifier for all activities in this administration of the session."},activity_uuid:{type:"string",format:"uuid",description:"Unique identifier for all trials in this administration of the activity."},activity_id:{type:"string",description:"Human-readable identifier of the activity."},activity_version:{type:"string",description:"Version of the activity."},device_timezone:{type:"string",description:"Timezone of the device. Calculated from Intl.DateTimeFormat().resolvedOptions().timeZone."},device_timezone_offset_minutes:{type:"integer",description:"Difference in minutes between UTC and device timezone. Calculated from Date.getTimezoneOffset()."}},this.snapshots=new Array,!e.id||e.id.trim()==="")throw new Error("id is required in GameOptions");this.options=e,this.name=e.name,this.id=e.id,this.freeNodesScene.game=this,this.freeNodesScene.needsInitialization=!0,this.fpsMetricReportThreshold=e.fpsMetricReportThreshold??V.FPS_METRIC_REPORT_THRESHOLD,this.maximumRecordedActivityMetrics=e.maximumRecordedActivityMetrics??V.MAXIMUM_RECORDED_ACTIVITY_METRICS,this.addLocalizationParametersToGameParameters(),this.options.trialSchema||(this.options.trialSchema={}),e.moduleMetadata?this.moduleMetadata=e.moduleMetadata:this.moduleMetadata={name:"",version:"",dependencies:{}}}getImportedModuleBaseUrl(e,r){const l=new RegExp(`^.*${e}[^\\/]*`),p=r.match(l);if(!p||p.length===0)throw new Error(`Could not calculate imported assessment package base URL. Package name: ${e}, module URL: ${r}`);return p[0]}addLocalizationParametersToGameParameters(){this.options.parameters={...this.options.parameters,...tr.makeLocalizationParameters()}}async init(){return this.initialize()}loadCanvasKit(e){return Xa({locateFile:()=>e})}async resolveGameBaseUrls(e){let r,l=!1,p=`assets/${e.id}`;if(e.moduleMetadata.name)try{r=await import.meta.resolve(e.moduleMetadata.name),p=e.getImportedModuleBaseUrl(e.moduleMetadata.name,r)+"/assets",l=!0}catch{}let u=`assets/${e.id}`;try{const y=await import.meta.resolve("@m2c2kit/core");u=e.getImportedModuleBaseUrl("@m2c2kit/core",y)+"/assets"}catch{if(l)throw new Error(`the package ${e.moduleMetadata.name} has been imported from a module URL (${r}), but the @m2c2kit/core package module URL could not be determined.`)}return{assets:p,canvasKitWasm:u}}async initialize(){const e=await this.resolveGameBaseUrls(this);if(this.manifest===void 0&&(this.manifest=await this.loadManifest()),this._canvasKit===void 0){const r=nt.getUrlFromManifest(this,e.canvasKitWasm+`/canvaskit-${this.canvasKitWasmVersion}.wasm`);try{this.canvasKit=await this.loadCanvasKit(r)}catch{throw new Error(`game ${this.id} could not load canvaskit wasm file from ${r}`)}}if(this.isLocalizationRequested()){const r=this.getLocalizationOptionsFromGameParameters();this.i18n=new tr(r)}return this.fontManager=new un(this,e),this.imageManager=new En(this,e),Promise.all([this.fontManager.initializeFonts(this.options.fonts),this.imageManager.initializeImages(this.options.images)])}async loadManifest(e="__NO_M2C2KIT_MANIFEST_JSON_URL__"){if(e.includes("NO_M2C2KIT_MANIFEST_JSON_URL"))return{};let r;try{if(r=await fetch(e),!r.ok)throw new Error(`Error ${r.status} on GET manifest.json from ${e}.`)}catch{throw new Error(`Network error on GET manifest.json from ${e}.`)}try{return await r.json()}catch{throw new Error(`Error parsing manifest.json from ${e}.`)}}get fontManager(){if(!this._fontManager)throw new Error("fontManager is undefined");return this._fontManager}set fontManager(e){this._fontManager=e}get imageManager(){if(!this._imageManager)throw new Error("imageManager is undefined");return this._imageManager}set imageManager(e){this._imageManager=e}storeSetItem(e,r,l=!1){const p=l?e:this.id.concat(":",e),u=l?"":this.id;return this.dataStores[0].setItem(p,r,u)}storeGetItem(e,r=!1){const l=r?e:this.id.concat(":",e);return this.dataStores[0].getItem(l)}storeDeleteItem(e,r=!1){const l=r?e:this.id.concat(":",e);return this.dataStores[0].deleteItem(l)}storeClearItems(){return this.dataStores[0].clearItemsByActivityId(this.id)}storeItemsKeys(e=!1){return this.dataStores[0].itemsKeysByActivityId(e?"":this.id)}storeItemExists(e,r=!1){const l=r?e:this.id.concat(":",e);return this.dataStores[0].itemExists(l)}get dataStores(){if(!this._dataStores)throw new Error("dataStores is undefined");return this._dataStores}set dataStores(e){this._dataStores=e}getLocalizationOptionsFromGameParameters(){const e=this.getParameter("locale"),r=this.getParameterOrFallback("fallback_locale",void 0),l=this.getParameterOrFallback("missing_translation_font_color",void 0),p=this.getParameterOrFallback("translations",void 0),u=this.options.translations;return{locale:e,fallbackLocale:r,missingTranslationFontColor:l,additionalTranslations:p,translations:u}}isLocalizationRequested(){const e=this.getParameterOrFallback("locale",void 0);if(e==="")throw new Error("Empty string in locale. Leave locale undefined or null to prevent localization.");return e!=null}setParameters(e){const{parameters:r}=this.options;Object.keys(e).forEach(l=>{!r||!(l in r)?console.warn(`game ${this.options.name} does not have a parameter named ${l}. attempt to set parameter ${l} to value ${e[l]} will be ignored`):this.options.parameters&&this.options.parameters[l]&&(this.options.parameters[l].default=e[l])}),this.additionalParameters=e}get canvasKit(){if(!this._canvasKit)throw new Error("canvaskit is undefined");return this._canvasKit}set canvasKit(e){this._canvasKit=e}addFreeNode(e){this.freeNodesScene.addChild(e)}addFreeEntity(e){this.addFreeNode(e)}removeFreeNode(e){if(typeof e=="string"){if(!this.freeNodesScene.children.map(r=>r.name).includes(e))throw new Error(`cannot remove free node named "${e}" because it is not currently part of the game's free nodes. `);this.freeNodesScene.children=this.freeNodesScene.children.filter(r=>r.name!==e)}else{if(!this.freeNodesScene.children.includes(e))throw new Error(`cannot remove free node "${e.toString()}" because it is not currently part of the game's free nodes. `);this.freeNodesScene.children=this.freeNodesScene.children.filter(r=>r!==e)}}removeFreeEntity(e){this.removeFreeNode(e)}removeAllFreeNodes(){for(;this.freeNodesScene.children.length;)this.freeNodesScene.children.pop()}removeAllFreeEntities(){this.removeAllFreeNodes()}get freeNodes(){return this.freeNodesScene.children}get freeEntities(){return this.freeNodes}addScene(e){e.game=this,e.needsInitialization=!0,this.scenes.push(e)}addScenes(e){e.forEach(r=>{this.addScene(r)})}removeScene(e){if(typeof e=="object")if(this.scenes.includes(e))this.scenes=this.scenes.filter(r=>r!==e);else throw new Error(`cannot remove scene ${e} from game because the scene is not currently added to the game`);else if(this.scenes.map(r=>r.name).includes(e))this.scenes=this.scenes.filter(r=>r.name!==e);else throw new Error(`cannot remove scene named "${e}" from game because the scene is not currently added to the game`)}presentScene(e,r=Si.none()){let l;if(typeof e=="string"){if(l=this.scenes.filter(u=>u.name===e).find(Boolean),l===void 0)throw new Error(`scene ${e} not found`)}else{if(!this.scenes.some(u=>u===e))throw new Error(`scene ${e} exists, but it has not been added to the game object`);l=e}l.initialize(),l.needsInitialization=!1;const p=new Cn(l,r);this.incomingSceneTransitions.push(p),l.game.bodyBackgroundColor!==void 0?document.body.style.backgroundColor=`rgb(${l.game.bodyBackgroundColor[0]},${l.game.bodyBackgroundColor[1]},${l.game.bodyBackgroundColor[2]},${l.game.bodyBackgroundColor[3]})`:document.body.style.backgroundColor=`rgb(${l.backgroundColor[0]},${l.backgroundColor[1]},${l.backgroundColor[2]},${l.backgroundColor[3]})`}getParameter(e){if(this.options.parameters!==void 0&&Object.keys(this.options.parameters).includes(e))return this.options.parameters[e].default;throw new Error(`game parameter ${e} not found`)}getParameterOrFallback(e,r){return this.options.parameters!==void 0&&Object.keys(this.options.parameters).includes(e)?this.options.parameters[e].default:r}hasParameter(e){return!!(this.options.parameters!==void 0&&Object.keys(this.options.parameters).includes(e))}async start(e){const r=this.options;this.setupHtmlCanvases(r.canvasId,r.width,r.height,r.stretch),this.showFps=r.showFps??!1,this.bodyBackgroundColor=r.bodyBackgroundColor,this.initData(),this.setupCanvasKitSurface(),this.setupFpsFont(),this.setupCanvasDomEventHandlers();let l;if(e!==void 0?typeof e=="object"?l=e:l=this.scenes.filter(y=>y.name===e).find(Boolean):this.entryScene!==void 0?typeof this.entryScene=="object"?l=this.entryScene:l=this.scenes.filter(y=>y.name===this.entryScene).find(Boolean):l=this.scenes.find(Boolean),l===void 0)throw new Error("cannot start game. entry scene has not been added to the game object.");if(this.presentScene(l),this.surface===void 0)throw new Error("CanvasKit surface is undefined");this.beginTimestamp=Qi.now(),this.beginIso8601Timestamp=new Date().toISOString(),this.options.timeStepping?(this.addTimeSteppingControlsToDom(),this.updateTimeSteppingOutput()):this.removeTimeSteppingControlsFromDom(),this.warmupFinished=!1;const p={target:this,type:X.GameWarmupStart};this.raiseActivityEventOnListeners(p),this.warmupFunctionQueue.push({warmupFunction:this.warmupShadersWithPrimitives}),this.warmupFunctionQueue.push({warmupFunction:this.warmupShadersWithPrimitives,positionOffset:.10012117}),this.warmupFunctionQueue.push({warmupFunction:this.warmupShadersWithScenes}),this.surface.requestAnimationFrame(this.loop.bind(this));const u={target:this,type:X.ActivityStart};this.raiseActivityEventOnListeners(u)}addTimeSteppingControlsToDom(){if(document.getElementById("m2c2kit-time-stepping-div"))return;const r=document.getElementsByTagName("body")[0];if(r){const l=document.createElement("div");l.id="m2c2kit-time-stepping-div",r.prepend(l);const p=document.createElement("button");p.id="1-step-advance",p.title="advance 1 step (16.667 ms)",p.innerText=">",p.style.marginRight="4px",l.appendChild(p),p.addEventListener("click",this.advanceStepsHandler.bind(this));const u=document.createElement("button");u.id="55-step-advance",u.title="advance 55 steps (916.667 ms)",u.innerText=">>",u.style.marginRight="4px",l.appendChild(u),u.addEventListener("click",this.advanceStepsHandler.bind(this));const y=document.createElement("input");y.id="time-stepping-steps-input",y.title="steps",y.style.width="40px",y.style.marginRight="4px",y.setAttribute("readonly","true"),l.appendChild(y);const x=document.createElement("input");x.id="time-stepping-now-input",x.title="milliseconds",x.style.width="80px",x.style.marginRight="4px",x.setAttribute("readonly","true"),l.appendChild(x)}}updateTimeSteppingOutput(){const e=document.getElementById("time-stepping-steps-input");e&&(e.value=this.stepCount.toString());const r=document.getElementById("time-stepping-now-input");r&&(r.value=this.steppingNow.toFixed(2))}advanceStepsHandler(e){e?.target?.id==="1-step-advance"?(this.steppingNow=this.steppingNow+16.66666666666667,this.stepCount=this.stepCount+1):e?.target?.id==="55-step-advance"&&(this.steppingNow=this.steppingNow+16.66666666666667*55,this.stepCount=this.stepCount+55),this.updateTimeSteppingOutput()}removeTimeSteppingControlsFromDom(){const e=document.getElementById("m2c2kit-time-stepping-div");e&&e.remove()}warmupShadersWithPrimitives(e,r=0){if(e.save(),r==0?e.scale(1/Globals.canvasScale,1/Globals.canvasScale):e.scale(1/Globals.canvasScale*1.13,1/Globals.canvasScale*1.13),!this.surface)throw new Error("surface is undefined");const l=this.surface.width(),p=this.surface.height(),u=Math.round(l/2)+r,y=Math.round(p/2)+r,x=r,W=r,U=Et.makePaint(this.canvasKit,F.White,this.canvasKit.PaintStyle.Fill,!0);e.drawRect([0,0,this.surface.width(),this.surface.height()],U);const Q=Et.makePaint(this.canvasKit,F.Black,this.canvasKit.PaintStyle.Fill,!1),ot=Et.makePaint(this.canvasKit,F.Black,this.canvasKit.PaintStyle.Fill,!0),vt=Et.makePaint(this.canvasKit,F.Black,this.canvasKit.PaintStyle.Stroke,!1);vt.setStrokeWidth(2);const It=Et.makePaint(this.canvasKit,F.Black,this.canvasKit.PaintStyle.Stroke,!0);It.setStrokeWidth(2),e.drawCircle(u,y,32,Q),e.drawCircle(u,y,32,ot),e.drawCircle(u,y,32,vt),e.drawCircle(u,y,32,It);const ct=this.fontManager,Pt=this.fontManager.getFontNames();if(Pt.length>0&&ct.fonts[Pt[0]].status===Kt.Ready){const Se=ct.getTypeface(Pt[0]),xe=new this.canvasKit.Font(Se,16*Globals.canvasScale);e.drawText("abc",u,y,Q,xe),e.drawText("abc",u,y,ot,xe)}const Nt=this.takeCurrentSceneSnapshot();e.drawImage(Nt,x,W),Nt.delete(),e.drawRect([x,W,16,16],Q),e.drawRect([x,W,16,16],ot),e.drawRect([x,W,16,16],vt),e.drawRect([x,W,16,16],It),e.restore()}warmupShadersWithScenes(e){[...this.scenes,this.freeNodesScene].forEach(u=>{u.warmup(e)});const r=this.nodes.filter(u=>u.type===pt.Sprite).map(u=>u.imageName),l=this.imageManager.images;l&&Object.keys(l).filter(y=>y!=="__outgoingSceneSnapshot").forEach(y=>{if(!r.includes(y)&&l[y].status===Vt.Ready){const x=l[y].canvaskitImage;if(!x)throw new Error(`image ${y} is undefined`);e.drawImage(x,0,0)}});const p=new this.canvasKit.Paint;if(p.setColor(this.canvasKit.Color(255,255,255,1)),!this.surface)throw new Error("surface is undefined");e.drawRect([0,0,this.surface.width(),this.surface.height()],p)}stop(){this.currentScene&&(this.currentScene._active=!1),this.gameStopRequested=!0,Qi.removeAll(),this.dispose()}dispose(){this.nodes.filter(e=>e.isDrawable).forEach(e=>e.dispose()),this.fontManager.dispose()}initData(){this.trialIndex=0,this.data={trials:new Array};const e=this.options.trialSchema??{},r=Object.entries(e);for(const[l,p]of r)if(p.type!==void 0&&!this.propertySchemaDataTypeIsValid(p.type))throw new Error(`invalid schema. variable ${l} is type ${p.type}. type must be number, string, boolean, object, or array`)}propertySchemaDataTypeIsValid(e){const r=["string","number","integer","object","array","boolean","null"];if(typeof e=="string")return r.includes(e);let l=!0;if(Array.isArray(e))e.forEach(p=>{r.includes(p)||(l=!1)});else throw new Error(`Invalid data type: ${e}`);return l}getDeviceMetadata(){const e=window.screen;return e.orientation?{userAgent:navigator.userAgent,devicePixelRatio:window.devicePixelRatio,screen:{availHeight:e.availHeight,availWidth:e.availWidth,colorDepth:e.colorDepth,height:e.height,orientation:{type:e.orientation.type,angle:e.orientation.angle},pixelDepth:e.pixelDepth,width:e.width},webGlRenderer:this.webGlRendererInfo}:{userAgent:navigator.userAgent,devicePixelRatio:window.devicePixelRatio,screen:{availHeight:e.availHeight,availWidth:e.availWidth,colorDepth:e.colorDepth,height:e.height,pixelDepth:e.pixelDepth,width:e.width},webGlRenderer:this.webGlRendererInfo}}addTrialData(e,r){if(!this.options.trialSchema)throw new Error("no trial schema were provided in GameOptions. cannot add trial data");if(this.data.trials.length<this.trialIndex+1){const u={},y=Object.entries(this.options.trialSchema);for(const[x]of y)u[x]=null;this.data.trials.push({document_uuid:yi.generate(),session_uuid:this.sessionUuid,activity_uuid:this.uuid,activity_id:this.options.id,activity_version:this.options.version,device_timezone:Intl?.DateTimeFormat()?.resolvedOptions()?.timeZone??"",device_timezone_offset_minutes:new Date().getTimezoneOffset(),...u,device_metadata:this.getDeviceMetadata()})}if(!(e in this.options.trialSchema))throw new Error(`trial variable ${e} not defined in schema`);let l;Array.isArray(this.options.trialSchema[e].type)?l=this.options.trialSchema[e].type:l=[this.options.trialSchema[e].type];let p=typeof r;if(p==="object"&&Object.prototype.toString.call(r)==="[object Array]"&&(p="array"),r==null&&(p="null"),!l.includes(p)&&!(p==="number"&&Number.isInteger(r)&&l.includes("integer")))throw new Error(`type for variable ${e} (value: ${r}) is "${p}". Based on schema for this variable, expected type was "${l}"`);this.data.trials[this.trialIndex][e]=r}addTrialSchema(e){Object.keys(e).forEach(l=>{if(!this.options.trialSchema)throw new Error("trial schema is undefined");this.options.trialSchema[l]=e[l]})}addStaticTrialData(e,r){if(!this.options.trialSchema)throw new Error("trial schema is undefined");if(this.options.trialSchema[e]===void 0)throw new Error(`trial variable ${e} not defined in schema`);this.staticTrialSchema[e]=r}trialComplete(){Object.keys(this.staticTrialSchema).length>0&&(this.data.trials[this.trialIndex]={...this.data.trials[this.trialIndex],...this.staticTrialSchema}),this.trialIndex++;const e={type:X.ActivityData,iso8601Timestamp:new Date().toISOString(),target:this,newData:this.data.trials[this.trialIndex-1],newDataSchema:this.makeNewGameDataSchema(),data:this.data,dataSchema:this.makeGameDataSchema(),activityConfiguration:this.makeGameActivityConfiguration(this.options.parameters??{}),activityConfigurationSchema:this.makeGameActivityConfigurationSchema(this.options.parameters??{}),activityMetrics:this.gameMetrics};this.raiseActivityEventOnListeners(e)}makeNewGameDataSchema(){return{description:`A single trial and metadata from the assessment ${this.name}.`,$comment:`Activity identifier: ${this.options.id}, version: ${this.options.version}.`,$schema:"https://json-schema.org/draft/2019-09/schema",type:"object",properties:{...this.automaticTrialSchema,...this.options.trialSchema,device_metadata:Tn}}}makeGameDataSchema(){return{description:`All trials and metadata from the assessment ${this.name}.`,$comment:`Activity identifier: ${this.options.id}, version: ${this.options.version}.`,$schema:"https://json-schema.org/draft/2019-09/schema",type:"object",required:["trials"],properties:{trials:{type:"array",items:{$ref:"#/$defs/trial"},description:"All trials from the assessment."}},$defs:{trial:{type:"object",properties:{...this.automaticTrialSchema,...this.options.trialSchema,device_metadata:Tn}}}}}makeGameActivityConfiguration(e){const r=JSON.parse(JSON.stringify(e)),{locale:l,fallback_locale:p,missing_translation_font_color:u,translations:y,...x}=r;for(const W in x)for(const U in x[W])U=="default"&&(x[W]=x[W][U]);return x}makeGameActivityConfigurationSchema(e){const r=JSON.parse(JSON.stringify(e)),{locale:l,fallback_locale:p,missing_translation_font_color:u,translations:y,...x}=r;for(const W in x){if(!("type"in x[W])&&"value"in x[W]){const U=typeof x[W].default;U!=="bigint"&&U!=="function"&&U!=="symbol"&&U!=="undefined"&&(x[W].type=U)}for(const U in x[W])U=="default"&&delete x[W][U]}return{description:`activity configuration from the assessment ${this.name}`,type:"object",properties:x}}end(){const e={target:this,type:X.ActivityEnd},r={data:this.data,dataSchema:this.makeGameDataSchema(),activityConfiguration:this.makeGameActivityConfiguration(this.options.parameters??{}),activityConfigurationSchema:this.makeGameActivityConfigurationSchema(this.options.parameters??{}),activityMetrics:this.gameMetrics};this.raiseActivityEventOnListeners(e,r)}cancel(){const e={target:this,type:X.ActivityCancel},r={data:this.data,dataSchema:this.makeGameDataSchema(),activityConfiguration:this.makeGameActivityConfiguration(this.options.parameters??{}),activityConfigurationSchema:this.makeGameActivityConfigurationSchema(this.options.parameters??{}),activityMetrics:this.gameMetrics};this.raiseActivityEventOnListeners(e,r)}setupHtmlCanvases(e,r,l,p){Globals.canvasScale=Math.round(window.devicePixelRatio*100)/100;let u;if(e===void 0){const y=document.getElementsByTagName("canvas");let x=new Array;for(let U=0;U<y.length;U++)x.push(y[U]);if(x=x.filter(U=>U.id!=="m2c2kitscratchcanvas"),x.length===0)throw new Error("no html canvas tag was found in the html");const W=x.filter(U=>U.id==="m2c2kit-canvas")[0];W?(u=W,x.length>1&&console.log("using canvas with id 'm2c2kit-canvas'")):(u=y[0],x.length>1&&console.log("using first canvas"))}else if(u=document.getElementById(e),u===void 0)throw new Error(`could not find canvas HTML element with id "${e}"`);if(p||window.innerWidth<r||window.innerHeight<l){const y=l/r;window.innerHeight/window.innerWidth<y?Globals.rootScale=window.innerHeight/l:Globals.rootScale=window.innerWidth/r}u.style.width=Globals.rootScale*r+"px",u.style.height=Globals.rootScale*l+"px",u.width=Globals.rootScale*r*Globals.canvasScale,u.height=Globals.rootScale*l*Globals.canvasScale,this.htmlCanvas=u,this.canvasCssWidth=r,this.canvasCssHeight=l,Globals.canvasCssWidth=r,Globals.canvasCssHeight=l}setupCanvasKitSurface(){if(this.htmlCanvas===void 0)throw new Error("main html canvas is undefined");window.logWebGl=this.options.logWebGl,this.interceptWebGlCalls();try{this.webGlRendererInfo=Zi.getRendererString()}catch{this.webGlRendererInfo="err",Zi.dispose()}const e=this.canvasKit.MakeWebGLCanvasSurface(this.htmlCanvas);if(e===null)throw new Error("could not make CanvasKit surface from canvas HTML element");this.surface=e,console.log(`\u26AA CanvasKit surface is backed by ${this.surface.reportBackendTypeIsGPU()?"GPU":"CPU"}`),this.surface.getCanvas().scale(Globals.canvasScale,Globals.canvasScale)}interceptWebGlCalls(){if(!this.htmlCanvas.__proto__.m2c2ModifiedGetContext){this.htmlCanvas.__proto__.m2c2ModifiedGetContext=!0;const e=this.htmlCanvas.__proto__.getContext;this.htmlCanvas.__proto__.getContext=function(...r){window.logWebGl&&console.log(`\u{1F53C} getContext(${r.map(p=>p.toString()).join(", ")})`);const l=e.apply(this,[...r]);if(l.__proto__.compileShader&&!l.__proto__.m2c2ModifiedCompileShader){l.__proto__.m2c2ModifiedCompileShader=!0;const p=l.__proto__.compileShader;l.__proto__.compileShader=function(...u){if(window.logWebGl){const y=u[0],x=l.getShaderSource(y);console.log("\u{1F53C} compileShader():"),console.log(x)}return p.apply(this,[...u])}}return l}}}setupFpsFont(){this.fpsTextFont=new this.canvasKit.Font(null,V.FPS_DISPLAY_TEXT_FONT_SIZE*Globals.canvasScale),this.fpsTextPaint=new this.canvasKit.Paint,this.fpsTextPaint.setColor(this.canvasKit.Color(V.FPS_DISPLAY_TEXT_COLOR[0],V.FPS_DISPLAY_TEXT_COLOR[1],V.FPS_DISPLAY_TEXT_COLOR[2],V.FPS_DISPLAY_TEXT_COLOR[3])),this.fpsTextPaint.setAntiAlias(!0)}setupCanvasDomEventHandlers(){if(this.htmlCanvas===void 0)throw new Error("main html canvas is undefined");this.htmlCanvas.addEventListener("pointerdown",this.htmlCanvasPointerDownHandler.bind(this)),this.htmlCanvas.addEventListener("pointerup",this.htmlCanvasPointerUpHandler.bind(this)),this.htmlCanvas.addEventListener("pointermove",this.htmlCanvasPointerMoveHandler.bind(this)),this.htmlCanvas.addEventListener("touchstart",e=>{e.preventDefault()}),this.htmlCanvas.addEventListener("pointerleave",this.htmlCanvasPointerLeaveHandler.bind(this))}loop(e){if(!this.surface)throw new Error("surface is undefined");if(this.warmupFunctionQueue.length>0){const r=this.warmupFunctionQueue.shift();r?.warmupFunction.call(this,e,r.positionOffset),this.surface.requestAnimationFrame(this.loop.bind(this));return}if(!this.warmupFinished){this.warmupFinished=!0;const r={target:this,type:X.GameWarmupEnd};this.raiseActivityEventOnListeners(r),this.surface.requestAnimationFrame(this.loop.bind(this));return}if(this.gameStopRequested){this.surface.deleteLater();return}if(this.animationFramesRequested++,!this.limitFps||this.animationFramesRequested%Math.round(60/V.LIMITED_FPS_RATE)===0){if(this.currentScene===void 0&&this.incomingSceneTransitions.length===0)throw new Error("Can not run game without a current or incoming scene");for(this.updateGameTime(),this.handleIncomingSceneTransitions(this.incomingSceneTransitions),this.update(),this.draw(e);this.snapshots.length>0;)this.snapshots.shift()?.delete();this.snapshots.push(this.takeCurrentSceneSnapshot()),this.freeNodesScene.draw(e),this.pendingScreenshot&&(this.handlePendingScreenshot(this.pendingScreenshot),this.pendingScreenshot=void 0)}this.priorUpdateTime=Globals.now,this.surface.requestAnimationFrame(this.loop.bind(this))}updateGameTime(){this.options.timeStepping?Globals.now=this.steppingNow:Globals.now=performance.now(),this.priorUpdateTime?Globals.deltaTime=Globals.now-this.priorUpdateTime:Globals.deltaTime=0}handleIncomingSceneTransitions(e){if(e.length!==0&&(this.snapshots.length>0||e[0].transition.type===Xe.None)){const r=e.shift();if(r===void 0)throw new Error("no incoming scene transition");const l=r.scene,p=r.transition;if(p.type===Xe.None){this.currentScene&&(this.currentScene._active=!1),this.currentScene=l,this.currentScene._active=!0,this.raiseSceneEvent(l,"SceneSetup"),this.raiseSceneEvent(l,"SceneAppear");return}if(this.currentSceneSnapshot=this.snapshots.shift(),!this.currentSceneSnapshot)throw new Error("No snapshot available for outgoing scene");const u=this.createOutgoingScene(this.currentSceneSnapshot);u._active=!0,this.currentScene&&(this.currentScene._active=!1),this.currentScene=l,this.currentScene._active=!0,this.raiseSceneEvent(l,"SceneSetup"),this.animateSceneTransition(l,p,u)}}createOutgoingScene(e){const r=new Je({name:V.OUTGOING_SCENE_NAME});r.size.width=this.canvasCssWidth,r.size.height=this.canvasCssHeight,this.addScene(r);const l={imageName:V.OUTGOING_SCENE_IMAGE_NAME,canvaskitImage:e,width:this.canvasCssWidth,height:this.canvasCssHeight,status:Vt.Ready};this.imageManager.addImage(l);const p=new Pi({name:V.OUTGOING_SCENE_SPRITE_NAME,imageName:V.OUTGOING_SCENE_IMAGE_NAME,position:{x:this.canvasCssWidth/Globals.rootScale/2,y:this.canvasCssHeight/Globals.rootScale/2}});return p.scale=1/Globals.rootScale,r.addChild(p),r}async registerPlugin(e){if(e.type!==Ye.Game)throw new Error(`registerPlugin(): plugin ${e.id} is not a game plugin. It is a ${e.type} plugin.`);if(this.plugins.includes(e)||this.plugins.map(r=>r.id).includes(e.id))throw new Error(`registerPlugin(): plugin ${e.id} already registered.`);this.plugins.push(e),e.initialize&&await e.initialize(this)}update(){this.plugins.filter(e=>e.beforeUpdate!==void 0&&e.disabled!==!0).forEach(e=>e.beforeUpdate(this,Globals.deltaTime)),this.scenes.filter(e=>e._active).forEach(e=>e.update()),this.freeNodesScene.update(),this.plugins.filter(e=>e.afterUpdate!==void 0&&e.disabled!==!0).forEach(e=>e.afterUpdate(this,Globals.deltaTime))}draw(e){this.scenes.filter(r=>r._active).forEach(r=>r.draw(e)),this.drawnFrames++,this.calculateFps(),this.showFps&&this.drawFps(e)}calculateFps(){this.lastFpsUpdate===0?(this.lastFpsUpdate=Globals.now,this.nextFpsUpdate=Globals.now+V.FPS_DISPLAY_UPDATE_INTERVAL):Globals.now>=this.nextFpsUpdate&&(this.fpsRate=this.drawnFrames/((Globals.now-this.lastFpsUpdate)/1e3),this.drawnFrames=0,this.lastFpsUpdate=Globals.now,this.nextFpsUpdate=Globals.now+V.FPS_DISPLAY_UPDATE_INTERVAL,this.gameMetrics.length<this.maximumRecordedActivityMetrics&&this.fpsRate<this.fpsMetricReportThreshold&&this.gameMetrics.push({fps:Number.parseFloat(this.fpsRate.toFixed(2)),fps_interval_ms:V.FPS_DISPLAY_UPDATE_INTERVAL,fps_report_threshold:this.fpsMetricReportThreshold,activity_type:Ye.Game,activity_uuid:this.uuid,iso8601_timestamp:new Date().toISOString()}))}takeCurrentSceneSnapshot(){if(this.surface===void 0)throw new Error("CanvasKit surface is undefined");return this.surface.makeImageSnapshot()}handlePendingScreenshot(e){if(!this.surface)throw new Error("no surface");let r;if(e.rect.length==4){const p=e.rect[0]*Globals.canvasScale,u=e.rect[1]*Globals.canvasScale,y=e.rect[2]*Globals.canvasScale,x=e.rect[3]*Globals.canvasScale,W=[p,u,p+y,u+x];r=this.surface.makeImageSnapshot(W)}else r=this.surface.makeImageSnapshot();const l=r.encodeToBytes();e.promiseResolve(l)}takeScreenshot(e,r,l,p){if(!this.surface)throw new Error("no canvaskit surface. unable to take screenshot.");const u=[e,r,l,p].map(y=>y?0:1).reduce((y,x)=>y+x);return new Promise((y,x)=>{switch(u){case 0:{if(!e||!r||!l||!p){x("missing values in arguments for takeScreenshot()");return}this.pendingScreenshot={rect:[e,r,l,p],promiseResolve:y};break}case 4:{this.pendingScreenshot={rect:[],promiseResolve:y};break}default:x("Exactly 0 or 4 arguments must be supplied to takeScreenshot()")}})}animateSceneTransition(e,r,l){const p=r.duration;switch(e._transitioning=!0,l._transitioning=!0,r.type){case Xe.Slide:{switch(r.direction){case Me.Left:e.position.x=e.size.width,e.run(q.sequence([q.move({point:{x:0,y:0},duration:p,easing:r.easing,runDuringTransition:!0}),q.custom({callback:()=>{e._transitioning=!1,this.raiseSceneEvent(e,"SceneAppear"),this.removeScene(V.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),l.run(q.sequence([q.move({point:{x:-l.size.width,y:0},duration:p,easing:r.easing,runDuringTransition:!0}),q.custom({callback:()=>{l._active=!1,l._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;case Me.Right:e.position.x=-e.size.width,e.run(q.sequence([q.move({point:{x:0,y:0},duration:p,easing:r.easing,runDuringTransition:!0}),q.custom({callback:()=>{e._transitioning=!1,this.raiseSceneEvent(e,"SceneAppear"),this.removeScene(V.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),l.run(q.sequence([q.move({point:{x:l.size.width,y:0},duration:p,easing:r.easing,runDuringTransition:!0}),q.custom({callback:()=>{l._active=!1,l._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;case Me.Up:e.position.y=e.size.height,e.run(q.sequence([q.move({point:{x:0,y:0},duration:p,easing:r.easing,runDuringTransition:!0}),q.custom({callback:()=>{e._transitioning=!1,this.raiseSceneEvent(e,"SceneAppear"),this.removeScene(V.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),l.run(q.sequence([q.move({point:{x:0,y:-l.size.height},duration:p,easing:r.easing,runDuringTransition:!0}),q.custom({callback:()=>{l._active=!1,l._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;case Me.Down:e.position.y=-e.size.height,e.run(q.sequence([q.move({point:{x:0,y:0},duration:p,easing:r.easing,runDuringTransition:!0}),q.custom({callback:()=>{e._transitioning=!1,this.raiseSceneEvent(e,"SceneAppear"),this.removeScene(V.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),l.run(q.sequence([q.move({point:{x:0,y:l.size.height},duration:p,easing:r.easing,runDuringTransition:!0}),q.custom({callback:()=>{l._active=!1,l._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;default:throw new Error("unknown transition direction")}break}default:throw new Error("unknown transition type")}}drawFps(e){e.save();const r=Globals.canvasScale;if(e.scale(1/r,1/r),!this.fpsTextFont||!this.fpsTextPaint)throw new Error("fps font or paint is undefined");e.drawText("FPS: "+this.fpsRate.toFixed(2),0,0+V.FPS_DISPLAY_TEXT_FONT_SIZE*r,this.fpsTextPaint,this.fpsTextFont),e.restore()}createEventListener(e,r,l,p){const u=this.nodes.filter(x=>x.name===r);u.length>1&&console.warn(`warning: createEventListener() found more than one node with name ${r}. Event listener will be attached to first node found. All nodes that receive tap events should be uniquely named`);const y=u.filter(x=>x.name===r).find(Boolean);if(y===void 0)throw new Error(`could not create event listener. node with name ${r} could not be found in the game node tree`);if(!Object.values(X).includes(e))throw new Error(`game ${this.id}: could not create event listener. event type ${e} is not known`);y.addEventListener(e,l,p)}get nodes(){function e(l,p){p.push(l),l.children.forEach(u=>e(u,p))}const r=new Array;return[...this.scenes,this.freeNodesScene].forEach(l=>e(l,r)),r}get entities(){return this.nodes}htmlCanvasPointerDownHandler(e){e.preventDefault();const r=this.currentScene;if(!r||!this.sceneCanReceiveUserInteraction(r))return;const l={target:r,type:X.PointerDown,handled:!1};this.processDomPointerDown(r,l,e),this.processDomPointerDown(this.freeNodesScene,l,e)}htmlCanvasPointerUpHandler(e){e.preventDefault();const r=this.currentScene;if(!r||!this.sceneCanReceiveUserInteraction(r))return;const l={target:r,type:X.PointerUp,handled:!1};this.processDomPointerUp(r,l,e),this.processDomPointerUp(this.freeNodesScene,l,e)}htmlCanvasPointerMoveHandler(e){e.preventDefault();const r=this.currentScene;if(!r||!this.sceneCanReceiveUserInteraction(r))return;const l={target:r,type:X.PointerMove,handled:!1};this.processDomPointerMove(r,l,e),this.processDomPointerMove(this.freeNodesScene,l,e)}htmlCanvasPointerLeaveHandler(e){if(!this.currentScene)return;e.preventDefault();const r=this.currentScene;if(!r||!this.sceneCanReceiveUserInteraction(r))return;const l={target:r,type:X.PointerLeave,handled:!1};this.processDomPointerLeave(r,l,e),this.processDomPointerLeave(this.freeNodesScene,l,e)}processDomPointerDown(e,r,l){r.handled||(e.isUserInteractionEnabled&&this.IsCanvasPointWithinNodeBounds(e,l.offsetX,l.offsetY)&&(e.pressed=!0,e.pressedAndWithinHitArea=!0,e.pressedInitialPointerOffset={x:l.offsetX,y:l.offsetY},this.raiseM2PointerDownEvent(e,r,l),this.raiseTapDownEvent(e,r,l)),e.children&&e.children.filter(p=>!p.hidden).filter(p=>p.isDrawable).sort((p,u)=>u.zPosition-p.zPosition).forEach(p=>this.processDomPointerDown(p,r,l)))}processDomPointerUp(e,r,l){if(!r.handled){if(e.dragging){e.dragging=!1,e.pressed=!1,e.pressedAndWithinHitArea=!1,this.raiseM2DragEndEvent(e,r,l),r.handled=!0;return}e.isUserInteractionEnabled&&e.pressed&&e.pressedAndWithinHitArea?(e.pressed=!1,e.pressedAndWithinHitArea=!1,this.raiseTapUpEvent(e,r,l),this.raiseTapUpAny(e,r,l),this.raiseM2PointerUpEvent(e,r,l)):e.isUserInteractionEnabled&&e.pressed&&e.pressedAndWithinHitArea==!1?(e.pressed=!1,e.pressedAndWithinHitArea=!1,this.raiseTapUpAny(e,r,l)):e.isUserInteractionEnabled&&this.IsCanvasPointWithinNodeBounds(e,l.offsetX,l.offsetY)&&(e.pressed=!1,e.pressedAndWithinHitArea=!1,this.raiseM2PointerUpEvent(e,r,l)),e.children&&e.children.filter(p=>!p.hidden).filter(p=>p.isDrawable).sort((p,u)=>u.zPosition-p.zPosition).forEach(p=>this.processDomPointerUp(p,r,l))}}processDomPointerMove(e,r,l){if(!r.handled){if(e.isUserInteractionEnabled&&e.draggable&&e.pressed){let p=!1,u,y;e.dragging===!1?(e.dragging=!0,p=!0,u=l.offsetX-e.pressedInitialPointerOffset.x,y=l.offsetY-e.pressedInitialPointerOffset.y):(u=l.offsetX-e.draggingLastPointerOffset.x,y=l.offsetY-e.draggingLastPointerOffset.y),e.position.x+=u,e.position.y+=y,e.draggingLastPointerOffset={x:l.offsetX,y:l.offsetY},r.handled=!0,p?this.raiseM2DragStartEvent(e,r,l):this.raiseM2DragEvent(e,r,l);return}e.isUserInteractionEnabled&&e.pressed&&e.pressedAndWithinHitArea&&!this.IsCanvasPointWithinNodeBounds(e,l.offsetX,l.offsetY)&&(e.pressedAndWithinHitArea=!1,this.raiseTapLeaveEvent(e,r,l)),e.isUserInteractionEnabled&&this.IsCanvasPointWithinNodeBounds(e,l.offsetX,l.offsetY)&&(this.raiseM2PointerMoveEvent(e,r,l),e.withinHitArea=!0),e.isUserInteractionEnabled&&e.withinHitArea&&!this.IsCanvasPointWithinNodeBounds(e,l.offsetX,l.offsetY)&&(e.withinHitArea=!1,this.raiseM2PointerLeaveEvent(e,r,l)),e.children&&e.children.filter(p=>!p.hidden).filter(p=>p.isDrawable).sort((p,u)=>u.zPosition-p.zPosition).forEach(p=>this.processDomPointerMove(p,r,l))}}processDomPointerLeave(e,r,l){if(!r.handled){if(e.dragging){const p={target:e,type:X.DragEnd,handled:!1};e.dragging=!1,e.pressed=!1,e.pressedAndWithinHitArea=!1,this.raiseM2DragEndEvent(e,p,l);return}e.isUserInteractionEnabled&&e.pressed&&e.pressedAndWithinHitArea&&!this.IsCanvasPointWithinNodeBounds(e,l.offsetX,l.offsetY)&&(e.pressedAndWithinHitArea=!1,this.raiseTapLeaveEvent(e,r,l)),e.isUserInteractionEnabled&&e.withinHitArea&&!this.IsCanvasPointWithinNodeBounds(e,l.offsetX,l.offsetY)&&(e.withinHitArea=!1,this.raiseM2PointerLeaveEvent(e,r,l)),e.children&&e.children.filter(p=>!p.hidden).filter(p=>p.isDrawable).sort((p,u)=>u.zPosition-p.zPosition).forEach(p=>this.processDomPointerLeave(p,r,l))}}raiseM2PointerDownEvent(e,r,l){r.target=e,r.type=X.PointerDown,this.raiseEventOnListeningNodes(e,r,l)}raiseTapDownEvent(e,r,l){r.target=e,r.type=X.TapDown,this.raiseEventOnListeningNodes(e,r,l)}raiseTapLeaveEvent(e,r,l){r.target=e,r.type=X.TapLeave,this.raiseEventOnListeningNodes(e,r,l)}raiseM2PointerUpEvent(e,r,l){r.target=e,r.type=X.PointerUp,this.raiseEventOnListeningNodes(e,r,l)}raiseTapUpEvent(e,r,l){r.target=e,r.type=X.TapUp,this.raiseEventOnListeningNodes(e,r,l)}raiseTapUpAny(e,r,l){r.target=e,r.type=X.TapUpAny,this.raiseEventOnListeningNodes(e,r,l)}raiseM2PointerMoveEvent(e,r,l){r.target=e,r.type=X.PointerMove,this.raiseEventOnListeningNodes(e,r,l)}raiseM2PointerLeaveEvent(e,r,l){r.target=e,r.type=X.PointerLeave,this.raiseEventOnListeningNodes(e,r,l)}raiseM2DragStartEvent(e,r,l){r.target=e,r.type=X.DragStart,this.raiseEventOnListeningNodes(e,r,l)}raiseM2DragEvent(e,r,l){r.target=e,r.type=X.Drag,this.raiseEventOnListeningNodes(e,r,l)}raiseM2DragEndEvent(e,r,l){r.target=e,r.type=X.DragEnd,this.raiseEventOnListeningNodes(e,r,l)}raiseSceneEvent(e,r){const l={target:e,type:r};e.eventListeners.filter(p=>p.type===r).forEach(p=>p.callback(l))}calculatePointWithinNodeFromDomPointerEvent(e,r){let l=e.size.width,p=e.size.height;if(e.type===pt.Shape&&e.shapeType===Bt.Circle){const Q=e.circleOfRadius;if(!Q)throw"circleOfRadius is undefined";l=Q*2,p=Q*2}let u=r.offsetX,y=r.offsetY;const x=nt.calculateNodeAbsoluteBoundingBox(e);nt.nodeOrAncestorHasBeenRotated(e)&&nt.calculateRotationTransforms(e).forEach(ot=>{const vt=nt.rotatePoint({x:u,y},-ot.radians,ot.center);u=vt.x,y=vt.y});const W=(u-x.xMin)/(x.xMax-x.xMin)*l,U=(y-x.yMin)/(x.yMax-x.yMin)*p;return{x:W,y:U}}onStart(e,r){this.addEventListener(X.ActivityStart,e,r)}onCancel(e,r){this.addEventListener(X.ActivityCancel,e,r)}onEnd(e,r){this.addEventListener(X.ActivityEnd,e,r)}onData(e,r){this.addEventListener(X.ActivityData,e,r)}onWarmupStart(e,r){this.addEventListener(X.GameWarmupStart,e,r)}onWarmupEnd(e,r){this.addEventListener(X.GameWarmupEnd,e,r)}addEventListener(e,r,l){const p={type:e,activityUuid:this.uuid,callback:r};l?.replaceExisting&&(this.eventListeners=this.eventListeners.filter(u=>!(u.activityUuid===p.activityUuid&&u.type===p.type))),this.eventListeners.push(p)}raiseActivityEventOnListeners(e,r){r&&(e={...e,...r}),this.eventListeners.filter(l=>l.type===e.type).forEach(l=>{l.callback(e)})}raiseEventOnListeningNodes(e,r,l){e.eventListeners.filter(p=>p.type===r.type).forEach(p=>{if(p.nodeUuid===e.uuid)switch(r.target=e,r.type){case X.PointerDown:case X.PointerMove:case X.PointerUp:case X.PointerLeave:r.point=this.calculatePointWithinNodeFromDomPointerEvent(e,l),r.buttons=l.buttons,p.callback(r);break;case X.TapDown:case X.TapUp:case X.TapUpAny:case X.TapLeave:r.point=this.calculatePointWithinNodeFromDomPointerEvent(e,l),r.buttons=l.buttons,p.callback(r);break;case X.DragStart:case X.Drag:case X.DragEnd:r.position={x:e.position.x,y:e.position.y},r.buttons=l.buttons,p.callback(r);break}})}sceneCanReceiveUserInteraction(e){return!!(e._active&&e._transitioning===!1)}IsCanvasPointWithinNodeBounds(e,r,l){if(!e.isDrawable)throw"only drawable nodes can receive pointer events";if(e.type===pt.Shape&&e.shapeType===Bt.Circle){const u=nt.calculateNodeAbsoluteBoundingBox(e),y=e.circleOfRadius;if(!y)throw"circleOfRadius is undefined";const x={x:u.xMin+y*e.absoluteScale,y:u.yMin+y*e.absoluteScale};return Math.sqrt(Math.pow(r-x.x,2)+Math.pow(l-x.y,2))<=y*e.absoluteScale}if(e.size.width===0||e.size.height===0||e.type===pt.TextLine&&isNaN(e.size.width))return!1;const p=nt.calculateRotatedPoints(e);return e.isUserInteractionEnabled&&nt.isPointInsideRectangle({x:r,y:l},p)}}var Fe=(v=>(v[v.Center=0]="Center",v[v.Left=1]="Left",v[v.Right=2]="Right",v))(Fe||{});class er extends we{constructor(e={}){super(e),this.type=pt.Label,this.isDrawable=!0,this.isText=!0,this.anchorPoint={x:.5,y:.5},this.zPosition=0,this._text="",this._fontColor=V.DEFAULT_FONT_COLOR,this._fontSize=V.DEFAULT_FONT_SIZE,this._horizontalAlignmentMode=Fe.Center,this._translatedText="",ye(this,e),e.horizontalAlignmentMode&&(this.horizontalAlignmentMode=e.horizontalAlignmentMode),e.preferredMaxLayoutWidth!==void 0&&(this.preferredMaxLayoutWidth=e.preferredMaxLayoutWidth),e.backgroundColor&&(this.backgroundColor=e.backgroundColor),e.fontNames&&(this.fontNames=e.fontNames)}initialize(){const e=this.game.fontManager;if(this.fontName&&this.fontNames)throw new Error("cannot specify both fontName and fontNames");const r=this.getRequiredLabelFonts(e);if(r.forEach(U=>{if(U.status===Kt.Deferred){e.prepareDeferredFont(U);return}}),!r.every(U=>U.status===Kt.Ready))return;let l=this.canvasKit.TextAlign.Center;switch(this.horizontalAlignmentMode){case Fe.Center:l=this.canvasKit.TextAlign.Center;break;case Fe.Left:l=this.canvasKit.TextAlign.Left;break;case Fe.Right:l=this.canvasKit.TextAlign.Right;break;default:throw new Error("unknown horizontalAlignmentMode")}this.text||(this.text="");let p=this.canvasKit.Color(this.fontColor[0],this.fontColor[1],this.fontColor[2],this.fontColor[3]),u;const y=this.parentSceneAsNode.game.i18n;if(y){let U=y.t(this.text);if(U===void 0){const Q=y.t(this.text,!0);Q===void 0?U=this.text:U=Q,y.options.missingTranslationFontColor&&(p=this.canvasKit.Color(y.options.missingTranslationFontColor[0],y.options.missingTranslationFontColor[1],y.options.missingTranslationFontColor[2],y.options.missingTranslationFontColor[3]))}this._translatedText=U,u=this._translatedText,this._translatedText===""&&console.warn(`warning: empty translated text in label "${this.name}"`)}else u=this.text,this._translatedText="";this.paraStyle=new this.canvasKit.ParagraphStyle({textStyle:{},textAlign:l}),this.builder&&this.builder.delete(),this.builder=this.canvasKit.ParagraphBuilder.MakeFromFontProvider(this.paraStyle,e.provider),this._backgroundPaint||(this._backgroundPaint=new this.canvasKit.Paint),this._fontPaint||(this._fontPaint=new this.canvasKit.Paint),this.fontPaint.setColor(p),this.fontPaint.setAlphaf(this.absoluteAlpha),this.backgroundColor?(this.backgroundPaint.setColor(this.backgroundColor),this.backgroundPaint.setAlphaf(this.absoluteAlpha)):this.backgroundPaint.setColor(this.canvasKit.Color(0,0,0,0)),this.builder.pushPaintStyle({fontFamilies:r.map(U=>U.fontName),fontSize:this.fontSize*Globals.canvasScale,fontStyle:{weight:this.canvasKit.FontWeight.Normal,width:this.canvasKit.FontWidth.Normal,slant:this.canvasKit.FontSlant.Oblique},decoration:0,decorationThickness:1,decorationStyle:this.canvasKit.DecorationStyle.Solid,heightMultiplier:-1,halfLeading:!1,letterSpacing:0,wordSpacing:0},this.fontPaint,this.backgroundPaint),this.builder.addText(u),this.paragraph&&this.paragraph.delete(),this.paragraph=this.builder.build();const x=this.preferredMaxLayoutWidth??Globals.canvasCssWidth;let W=x;if(x===0||this.layout.width===0){if(this.parent===void 0)throw new Error("width is set to match parent, but node has no parent");const U=this.layout.marginStart??0,Q=this.layout.marginEnd??0;W=this.parent.size.width-(U+Q)}this.paragraph.layout(W*Globals.canvasScale),x===0||this.layout.width===0?this.size.width=W:(this.paragraph.layout(Math.ceil(this.paragraph.getLongestLine())),this.size.width=this.paragraph.getMaxWidth()/Globals.canvasScale),this.size.height=this.paragraph.getHeight()/Globals.canvasScale,this.needsInitialization=!1}getRequiredLabelFonts(e){let r;if(this.fontName===void 0&&this.fontNames===void 0)r=[e.getDefaultFont()];else if(this.fontName!==void 0)r=[e.fonts[this.fontName]];else if(this.fontNames!==void 0&&this.fontNames.length>0)r=this.fontNames.map(l=>e.fonts[l]);else throw new Error("cannot determine required fonts");return r}dispose(){Et.Dispose([this.paragraph,this.builder,this._fontPaint,this._backgroundPaint])}get text(){return this._text}set text(e){this._text=e,this.needsInitialization=!0}get translatedText(){return this._translatedText}get fontName(){return this._fontName}set fontName(e){this._fontName=e,this.needsInitialization=!0}get fontNames(){return this._fontNames}set fontNames(e){this._fontNames=e,this.needsInitialization=!0}get fontColor(){return this._fontColor}set fontColor(e){this._fontColor=e,this.needsInitialization=!0}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize=e,this.needsInitialization=!0}get horizontalAlignmentMode(){return this._horizontalAlignmentMode}set horizontalAlignmentMode(e){this._horizontalAlignmentMode=e,this.needsInitialization=!0}get preferredMaxLayoutWidth(){return this._preferredMaxLayoutWidth}set preferredMaxLayoutWidth(e){this._preferredMaxLayoutWidth=e,this.needsInitialization=!0}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=e,this.needsInitialization=!0}get backgroundPaint(){if(!this._backgroundPaint)throw new Error("backgroundPaint cannot be undefined");return this._backgroundPaint}set backgroundPaint(e){this._backgroundPaint=e}get fontPaint(){if(!this._fontPaint)throw new Error("fontPaint cannot be undefined");return this._fontPaint}set fontPaint(e){this._fontPaint=e}duplicate(e){const r=new er({...this.getNodeOptions(),...this.getDrawableOptions(),...this.getTextOptions(),horizontalAlignmentMode:this.horizontalAlignmentMode,preferredMaxLayoutWidth:this.preferredMaxLayoutWidth,backgroundColor:this.backgroundColor,name:e});return this.children.length>0&&(r.children=this.children.map(l=>{const p=l.duplicate();return p.parent=r,p})),r}update(){super.update(),this.absoluteAlphaChange!==0&&this.initialize()}draw(e){if(this.parent&&this.text!==""&&!this.needsInitialization){e.save();const r=Globals.canvasScale/this.absoluteScale;e.scale(1/r,1/r),nt.rotateCanvasForDrawableNode(e,this);const l=(this.absolutePosition.x-this.size.width*this.anchorPoint.x*this.absoluteScale)*r,p=(this.absolutePosition.y-this.size.height*this.anchorPoint.y*this.absoluteScale)*r;if(this.paragraph===void 0)throw new Error("no paragraph");e.drawParagraph(this.paragraph,l,p),e.restore()}super.drawChildren(e)}warmup(e){if(!this.getRequiredLabelFonts(this.game.fontManager).some(l=>l.status===Kt.Deferred)&&Object.keys(this.layout).length===0){if(this.initialize(),!this.paragraph)throw new Error(`warmup Label node ${this.toString()}: paragraph is undefined`);e.drawParagraph(this.paragraph,0,0)}}}const Mn=class xn{constructor(e){this.startTime=NaN,this.stopTime=NaN,this.stopped=!0,this.cumulativeElapsed=NaN,this.name=e}static now(){return window.performance.now()}static start(e){let r=this._timers.filter(l=>l.name===e).find(Boolean);if(r===void 0)r=new xn(e),r.cumulativeElapsed=0,this._timers.push(r);else if(r.stopped==!1)throw new Error(`can't start timer. timer with name ${e} is already started`);r.startTime=window.performance.now(),r.stopped=!1}static stop(e){const r=this._timers.filter(l=>l.name===e).find(Boolean);if(r===void 0)throw new Error(`can't stop timer. timer with name ${e} does not exist`);if(r.stopped===!0)throw new Error(`can't stop timer. timer with name ${e} is already stopped`);r.stopTime=window.performance.now(),r.cumulativeElapsed=r.cumulativeElapsed+r.stopTime-r.startTime,r.stopped=!0}static restart(e){const r=this._timers.filter(l=>l.name===e).find(Boolean);if(r===void 0)throw new Error(`can't restart timer. timer with name ${e} does not exist`);r.startTime=window.performance.now(),r.cumulativeElapsed=0,r.stopped=!1}static elapsed(e){const r=this._timers.filter(l=>l.name===e).find(Boolean);if(r===void 0)throw new Error(`can't get elapsed time. timer with name ${e} does not exist`);return r.stopped?r.cumulativeElapsed:r.cumulativeElapsed+window.performance.now()-r.startTime}static remove(e){if(this._timers.filter(l=>l.name===e).find(Boolean)===void 0)throw new Error(`can't remove timer. timer with name ${e} does not exist`);this._timers=this._timers.filter(l=>l.name!=e)}static removeAll(){this._timers=new Array}static exists(e){return this._timers.some(r=>r.name===e)}};Mn._timers=new Array;let qa=Mn;class ir{static SingleFromRange(e,r){return Math.floor(Math.random()*(r-e+1))+e}static FromRangeWithoutReplacement(e,r,l){if(e>l-r+1)throw new Error(`number of requested draws (n = ${e}) is greater than number of integers in range [ ${r}, ${l}]`);const p=new Array;for(let u=0;u<e;u++){const y=ir.SingleFromRange(r,l);p.includes(y)?e++:p.push(y)}return p}static FromGridWithoutReplacement(e,r,l,p){const u=new Array,y=r*l-1,x=this.FromRangeWithoutReplacement(e,0,y);let W=0,U=NaN;for(;W<e;){const Q=x[W]%l,ot=(x[W]-Q)/l;if(p===void 0||p(ot,Q))u.push({row:ot,column:Q}),W++;else{do U=this.FromRangeWithoutReplacement(1,0,y)[0];while(x.includes(U));x[W]=U}}return u}}class rr extends we{constructor(e={}){if(super(e),this.type=pt.Shape,this.isDrawable=!0,this.isShape=!0,this.anchorPoint={x:.5,y:.5},this.zPosition=0,this.shapeType=Bt.Undefined,this.ckPath=null,this.cornerRadius=0,this._fillColor=V.DEFAULT_SHAPE_FILL_COLOR,this._isAntialiased=!0,this.svgPathScaleForResizing=1,this.svgPathWidth=0,this.svgPathHeight=0,this.svgPreviousAbsoluteX=NaN,this.svgPreviousAbsoluteY=NaN,this.svgFirstPathDraw=!0,this.colorfulPathPaints=new Map,ye(this,e),e.path!==void 0){if(this.path=e.path,this.shapeType=Bt.Path,this.shapeIsM2Path()&&e.size!==void 0&&(this.size=e.size),this.shapeIsSvgStringPath()&&e.size!==void 0)throw new Error("Size cannot be specified when path is SVG string path");if(this.svgPathRequestedWidth=e.path.width,this.svgPathRequestedHeight=e.path.height,this.svgPathRequestedHeight!==void 0&&this.svgPathRequestedWidth!==void 0)throw new Error("Cannot specify both width and height for SVG string path.");if(this.strokeColor||(this.strokeColor=V.DEFAULT_PATH_STROKE_COLOR),this.lineWidth===void 0&&(this.lineWidth=V.DEFAULT_PATH_LINE_WIDTH),e.circleOfRadius||e.rect)throw new Error("Shape must specify only one of: path, circleOfRadius, or rect")}if(e.circleOfRadius!==void 0){if(this.circleOfRadius=e.circleOfRadius,this.shapeType=Bt.Circle,e.size!==void 0)throw new Error("Size cannot be specified for circle shape");if(e.path||e.rect)throw new Error("Shape must specify only one of: path, circleOfRadius, or rect");this.size.width=this.circleOfRadius*2,this.size.height=this.circleOfRadius*2}if(e.rect&&(this.rect=e.rect,e.rect.size?(this.size.width=e.rect.size.width,this.size.height=e.rect.size.height):e.rect.width!==void 0&&e.rect.height!==void 0&&(this.size.width=e.rect.width,this.size.height=e.rect.height),e.rect.origin?this.position=e.rect.origin:e.rect.x!==void 0&&e.rect.y!==void 0&&(this.position={x:e.rect.x,y:e.rect.y}),this.shapeType=Bt.Rectangle,e.size!==void 0))throw new Error("Size cannot be specified for rectangle shape");e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius),e.fillColor&&(this.fillColor=e.fillColor),e.strokeColor&&(this.strokeColor=e.strokeColor),e.lineWidth!==void 0&&(this.lineWidth=e.lineWidth),e.isAntialiased!==void 0&&(this.isAntialiased=e.isAntialiased),e.strokeColor&&!e.lineWidth&&console.warn(`warning: for node ${this}, strokeColor = ${e.strokeColor} but lineWidth is non-zero. In normal usage, both would be set or both would be undefined.`),e.strokeColor===void 0&&e.lineWidth&&console.warn(`warning: for node ${this}, lineWidth = ${e.lineWidth} but strokeColor is undefined. In normal usage, both would be set or both would be undefined.`)}initialize(){if(this.shapeType===Bt.Path&&this.shapeIsSvgStringPath()){const e=this.path.pathString??this.path.svgPathString;if(!e)throw new Error("SVG Path string is null/undefined");if(this.path.svgPathString!==void 0&&console.warn("warning: svgPathString is deprecated. Use pathString instead."),this.ckPath=this.canvasKit.Path.MakeFromSVGString(e),!this.ckPath)throw new Error("could not make CanvasKit Path from SVG string");const r=this.ckPath.getBounds();this.svgPathWidth=r[2]+(r[0]<0?Math.abs(r[0]):0),this.svgPathHeight=r[3]+(r[1]<0?Math.abs(r[1]):0),this.svgPathRequestedHeight!==void 0?this.svgPathScaleForResizing=this.svgPathRequestedHeight/this.svgPathHeight:this.svgPathRequestedWidth!==void 0&&(this.svgPathScaleForResizing=this.svgPathRequestedWidth/this.svgPathWidth),this.size.width=this.svgPathWidth*this.svgPathScaleForResizing,this.size.height=this.svgPathHeight*this.svgPathScaleForResizing,this.svgPreviousAbsoluteX=0,this.svgPreviousAbsoluteY=0}if(this.shapeIsM2Path()&&(this.size.width===0||this.size.height===0||this.size.width===void 0||this.size.height===void 0))throw new Error("Size of shape must have non-zero height and width when path is M2Path");this.fillColor&&(this.fillColorPaintAntialiased=Et.makePaint(this.canvasKit,this.fillColor,this.canvasKit.PaintStyle.Fill,!0),this.fillColorPaintNotAntialiased=Et.makePaint(this.canvasKit,this.fillColor,this.canvasKit.PaintStyle.Fill,!1)),this.strokeColor&&(this.strokeColorPaintAntialiased=Et.makePaint(this.canvasKit,this.strokeColor,this.canvasKit.PaintStyle.Stroke,!0),this.strokeColorPaintNotAntialiased=Et.makePaint(this.canvasKit,this.strokeColor,this.canvasKit.PaintStyle.Stroke,!1)),this.svgFirstPathDraw=!0,this.needsInitialization=!1}dispose(){Et.Dispose([this._strokeColorPaintAntialiased,this._strokeColorPaintNotAntialiased,this._fillColorPaintAntialiased,this._fillColorPaintNotAntialiased,this.ckPath,...Array.from(this.colorfulPathPaints.values())])}duplicate(e){const r=new rr({...this.getNodeOptions(),...this.getDrawableOptions(),shapeType:this.shapeType,circleOfRadius:this.circleOfRadius,rect:this.rect,cornerRadius:this.cornerRadius,fillColor:this.fillColor,strokeColor:this.strokeColor,lineWidth:this.lineWidth,name:e});return this.children.length>0&&(r.children=this.children.map(l=>{const p=l.duplicate();return p.parent=r,p})),r}update(){super.update()}draw(e){e.save();const r=Globals.canvasScale/this.absoluteScale;e.scale(1/r,1/r),nt.rotateCanvasForDrawableNode(e,this),this.absoluteAlphaChange!==0&&this.applyAlphaToPaints(this.absoluteAlpha,[this._fillColorPaintAntialiased,this._fillColorPaintNotAntialiased,this._strokeColorPaintAntialiased,this._strokeColorPaintNotAntialiased]),this.shapeIsM2Path()&&this.drawPathFromM2Path(e),this.shapeIsSvgStringPath()&&this.drawPathFromSvgString(e),this.shapeType===Bt.Circle&&this.drawCircle(e),this.shapeType===Bt.Rectangle&&this.drawRectangle(e),e.restore(),super.drawChildren(e)}applyAlphaToPaints(e,r){r.forEach(l=>{l&&l.setAlphaf(e)})}drawPathFromM2Path(e){const r=Globals.canvasScale/this.absoluteScale,l=(this.absolutePosition.x-this.anchorPoint.x*this.size.width*this.absoluteScale)*r,p=(this.absolutePosition.y-this.anchorPoint.y*this.size.height*this.absoluteScale)*r;if(this.pathIsM2ColorfulPath(this.path)){const u=this.path.linePresentations;let y=0;const x=this.path.subpaths;let W;for(let U=0;U<x.length;U++){const ot=x[U].flat();for(let vt=0;vt<ot.length-1;vt++){if(u[y].subpathIndex===U&&u[y].pointIndex===vt){const It=u[y].strokeColor,ct=u[y].lineWidth,Pt=[...It,ct].toString();W=this.colorfulPathPaints.get(Pt),W===void 0&&(W=Et.makePaint(this.canvasKit,It,this.canvasKit.PaintStyle.Stroke,!0),W.setStrokeWidth(ct*Globals.canvasScale),this.colorfulPathPaints.set(Pt,W)),y<u.length-1&&y++}if(W===void 0)throw new Error("paint is undefined");e.drawLine(l+ot[vt].x*Globals.canvasScale,p+ot[vt].y*Globals.canvasScale,l+ot[vt+1].x*Globals.canvasScale,p+ot[vt+1].y*Globals.canvasScale,W)}}return}if(this.strokeColor&&this.strokeColorPaintAntialiased&&this.lineWidth){this.strokeColorPaintAntialiased.setStrokeWidth(this.lineWidth*Globals.canvasScale);const u=this.path.subpaths;for(const y of u){const x=y.flat();for(let W=0;W<x.length-1;W++)e.drawLine(l+x[W].x*Globals.canvasScale,p+x[W].y*Globals.canvasScale,l+x[W+1].x*Globals.canvasScale,p+x[W+1].y*Globals.canvasScale,this.strokeColorPaintAntialiased)}}}drawPathFromSvgString(e){if(!this.ckPath)return;const r=this.calculateSvgPathX(),l=this.calculateSvgPathY();if(this.pathNeedsTransform(r,l)){const u=Globals.canvasScale/this.absoluteScale*this.svgPathScaleForResizing*Globals.rootScale,y=this.calculateTransformationMatrix(u,r,l);this.ckPath=this.ckPath.transform(y),this.saveSvgPathAbsolutePosition(r,l)}if(this.fillColor){const p=this.getFillPaint();e.drawPath(this.ckPath,p)}if(this.strokeColor&&this.lineWidth){const p=this.getStrokePaint(this.lineWidth);e.drawPath(this.ckPath,p)}}calculateSvgPathY(){const e=Globals.canvasScale/this.absoluteScale;return(this.absolutePosition.y-this.size.height*this.absoluteScale/2)*e}calculateSvgPathX(){const e=Globals.canvasScale/this.absoluteScale;return(this.absolutePosition.x-this.size.width*this.absoluteScale/2)*e}saveSvgPathAbsolutePosition(e,r){this.svgPreviousAbsoluteX=e,this.svgPreviousAbsoluteY=r}calculateTransformationMatrix(e,r,l){let p;this.svgFirstPathDraw?(p=e,this.svgFirstPathDraw=!1):p=1;const u=r-this.svgPreviousAbsoluteX,y=l-this.svgPreviousAbsoluteY;return[p,0,u,0,p,y,0,0,1]}pathNeedsTransform(e,r){return this.svgFirstPathDraw===!0||e!==this.svgPreviousAbsoluteX||r!==this.svgPreviousAbsoluteY}shapeIsSvgStringPath(){return this.path?.pathString!==void 0||this.path?.svgPathString!==void 0}shapeIsM2Path(){return this.path?.subpaths!==void 0}pathIsM2ColorfulPath(e){return e!==void 0&&"linePresentations"in e}drawCircle(e){if(this.circleOfRadius){if(this.fillColor){const r=this.getFillPaint();this.drawCircleWithCanvasKit(e,r)}if(this.strokeColor&&this.lineWidth){const r=this.getStrokePaint(this.lineWidth);this.drawCircleWithCanvasKit(e,r)}}}drawRectangle(e){if(this.fillColor){const r=this.getFillPaint();this.drawRectangleWithCanvasKit(e,r)}if(this.strokeColor&&this.lineWidth){const r=this.getStrokePaint(this.lineWidth);this.drawRectangleWithCanvasKit(e,r)}}drawCircleWithCanvasKit(e,r){if(!this.circleOfRadius)return;const l=Globals.canvasScale/this.absoluteScale,p=this.absolutePosition.x*l,u=this.absolutePosition.y*l,y=this.circleOfRadius*this.absoluteScale*l;e.drawCircle(p,u,y,r)}drawRectangleWithCanvasKit(e,r){const l=this.calculateCKRoundedRectangle();e.drawRRect(l,r)}calculateCKRoundedRectangle(){const e=Globals.canvasScale/this.absoluteScale;return this.canvasKit.RRectXY(this.canvasKit.LTRBRect((this.absolutePosition.x-this.anchorPoint.x*this.size.width*this.absoluteScale)*e,(this.absolutePosition.y-this.anchorPoint.y*this.size.height*this.absoluteScale)*e,(this.absolutePosition.x+this.size.width*this.absoluteScale-this.anchorPoint.x*this.size.width*this.absoluteScale)*e,(this.absolutePosition.y+this.size.height*this.absoluteScale-this.anchorPoint.y*this.size.height*this.absoluteScale)*e),this.cornerRadius*e,this.cornerRadius*e)}getFillPaint(){return this.involvedInActionAffectingAppearance()?this.fillColorPaintNotAntialiased:this.isAntialiased?this.fillColorPaintAntialiased:this.fillColorPaintNotAntialiased}getStrokePaint(e){let r;this.involvedInActionAffectingAppearance()?r=this.strokeColorPaintNotAntialiased:r=this.isAntialiased?this.strokeColorPaintAntialiased:this.strokeColorPaintNotAntialiased;const l=Globals.canvasScale/this.absoluteScale;return r.setStrokeWidth(e*l),r}warmup(e){this.initialize(),e.save();const r=Globals.canvasScale/this.absoluteScale;e.scale(1/r,1/r),this.shapeType===Bt.Circle&&(this.fillColor&&this.warmupFilledCircle(e),this.strokeColor&&this.lineWidth&&this.warmupStrokedCircle(e)),this.shapeType===Bt.Rectangle&&(this.fillColor&&this.warmupFilledRectangle(e),this.strokeColor&&this.lineWidth&&this.warmupStrokedRectangle(e)),e.restore(),this.children.forEach(l=>{l.isDrawable&&l.warmup(e)})}warmupFilledCircle(e){this.circleOfRadius&&(this.drawCircleWithCanvasKit(e,this.fillColorPaintAntialiased),this.drawCircleWithCanvasKit(e,this.fillColorPaintNotAntialiased))}warmupStrokedCircle(e){if(!this.lineWidth||!this.circleOfRadius)return;const r=Globals.canvasScale/this.absoluteScale;this.strokeColorPaintAntialiased.setStrokeWidth(this.lineWidth*r),this.drawCircleWithCanvasKit(e,this.strokeColorPaintAntialiased),this.strokeColorPaintNotAntialiased.setStrokeWidth(this.lineWidth*r),this.drawCircleWithCanvasKit(e,this.strokeColorPaintNotAntialiased)}warmupFilledRectangle(e){this.drawRectangleWithCanvasKit(e,this.fillColorPaintAntialiased),this.drawRectangleWithCanvasKit(e,this.fillColorPaintNotAntialiased)}warmupStrokedRectangle(e){if(!this.lineWidth||!this.circleOfRadius)return;const r=Globals.canvasScale/this.absoluteScale;this.strokeColorPaintAntialiased.setStrokeWidth(this.lineWidth*r),this.drawRectangleWithCanvasKit(e,this.strokeColorPaintAntialiased),this.strokeColorPaintNotAntialiased.setStrokeWidth(this.lineWidth*r),this.drawRectangleWithCanvasKit(e,this.strokeColorPaintNotAntialiased)}get fillColor(){return this._fillColor}set fillColor(e){this._fillColor=e,this.needsInitialization=!0}get strokeColor(){return this._strokeColor}set strokeColor(e){this._strokeColor=e,this.needsInitialization=!0}get isAntialiased(){return this._isAntialiased}set isAntialiased(e){this._isAntialiased=e,this.needsInitialization=!0}get fillColorPaintAntialiased(){if(!this._fillColorPaintAntialiased)throw new Error("fillColorPaintAntiAliased is undefined");return this._fillColorPaintAntialiased}set fillColorPaintAntialiased(e){this._fillColorPaintAntialiased=e}get strokeColorPaintAntialiased(){if(!this._strokeColorPaintAntialiased)throw new Error("strokeColorPaintAntiAliased is undefined");return this._strokeColorPaintAntialiased}set strokeColorPaintAntialiased(e){this._strokeColorPaintAntialiased=e}get fillColorPaintNotAntialiased(){if(!this._fillColorPaintNotAntialiased)throw new Error("fillColorPaintNotAntiAliased is undefined");return this._fillColorPaintNotAntialiased}set fillColorPaintNotAntialiased(e){this._fillColorPaintNotAntialiased=e}get strokeColorPaintNotAntialiased(){if(!this._strokeColorPaintNotAntialiased)throw new Error("strokeColorPaintNotAntiAliased is undefined");return this._strokeColorPaintNotAntialiased}set strokeColorPaintNotAntialiased(e){this._strokeColorPaintNotAntialiased=e}}class Qa{static create(e){return new Array}}class nr extends we{constructor(e={}){super(e),this.type=pt.TextLine,this.isDrawable=!0,this.isText=!0,this.zPosition=0,this.anchorPoint={x:0,y:.5},this._text="",this._fontColor=V.DEFAULT_FONT_COLOR,this._fontSize=V.DEFAULT_FONT_SIZE,this.typeface=null,this._translatedText="",ye(this,e),this.size.height=this.fontSize,this.size.width=e.width??NaN}get text(){return this._text}set text(e){this._text=e,this.needsInitialization=!0}get translatedText(){return this._translatedText}get fontName(){return this._fontName}set fontName(e){this._fontName=e,this.needsInitialization=!0}get fontColor(){return this._fontColor}set fontColor(e){this._fontColor=e,this.needsInitialization=!0}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize=e,this.needsInitialization=!0}update(){super.update()}initialize(){const e=this.game.fontManager,r=this.getRequiredTextLineFont(e);if(r.status===Kt.Deferred){e.prepareDeferredFont(r);return}if(r.status===Kt.Loading)return;this.paint&&this.paint.delete(),this.paint=new this.canvasKit.Paint,this.paint.setColor(this.canvasKit.Color(this.fontColor[0],this.fontColor[1],this.fontColor[2],this.fontColor[3])),this.paint.setStyle(this.canvasKit.PaintStyle.Fill),this.paint.setAntiAlias(!0);const l=this.parentSceneAsNode.game.i18n;if(l&&l.options.missingTranslationFontColor&&(this.missingTranslationPaint=new this.canvasKit.Paint,this.missingTranslationPaint.setColor(this.canvasKit.Color(l.options.missingTranslationFontColor[0],l.options.missingTranslationFontColor[1],l.options.missingTranslationFontColor[2],l.options.missingTranslationFontColor[3])),this.paint.setStyle(this.canvasKit.PaintStyle.Fill),this.paint.setAntiAlias(!0)),this.fontName)this.typeface=e.getTypeface(this.fontName);else{const p=e.getFontNames();p.length>0&&(this.typeface=e.getTypeface(p[0]))}this.font&&this.font.delete(),this.font=new this.canvasKit.Font(this.typeface,this.fontSize*Globals.canvasScale),this.needsInitialization=!1}getRequiredTextLineFont(e){return this.fontName===void 0?e.getDefaultFont():e.getFont(this.fontName)}dispose(){Et.Dispose([this.font,this.typeface,this.paint])}duplicate(e){const r=new nr({...this.getNodeOptions(),...this.getDrawableOptions(),...this.getTextOptions(),width:this.size.width,name:e});return this.children.length>0&&(r.children=this.children.map(l=>{const p=l.duplicate();return p.parent=r,p})),r}draw(e){if(this.parent&&this.text&&!this.needsInitialization){e.save();const r=Globals.canvasScale/this.absoluteScale;e.scale(1/r,1/r),nt.rotateCanvasForDrawableNode(e,this);const l=this.absolutePosition.x*r,p=(this.absolutePosition.y+this.size.height*this.anchorPoint.y*this.absoluteScale)*r;let u,y=this.paint;const x=this.parentSceneAsNode.game.i18n;if(x){let W=x.t(this.text);if(W===void 0){const U=x.t(this.text,!0);U===void 0?W=this.text:W=U,this.missingTranslationPaint&&(y=this.missingTranslationPaint)}this._translatedText=W,u=this._translatedText,this._translatedText===""&&console.warn(`warning: empty translated text in TextLine "${this.name}"`)}else u=this.text,this._translatedText="",this.text===""&&console.warn(`warning: empty text in TextLine "${this.name}"`);if(y===void 0||this.font===void 0)throw new Error(`in TextLine node ${this}, Paint or Font is undefined.`);this.absoluteAlphaChange!==0&&y.setAlphaf(this.absoluteAlpha),e.drawText(u,l,p,y,this.font),e.restore()}super.drawChildren(e)}warmup(e){if(this.getRequiredTextLineFont(this.game.fontManager).status!==Kt.Deferred){if(this.initialize(),this.paint===void 0||this.font===void 0)throw new Error(`warmup TextLine node ${this.toString()}: Paint or Font is undefined.`);e.drawText(this.text,0,0,this.paint,this.font)}}}console.log("\u26AA @m2c2kit/core version 0.3.17 (ebbdc605)");export{q as Action,Ye as ActivityType,Et as CanvasKitHelpers,La as ColorfulMutablePath,Da as Composite,V as Constants,Lt as ConstraintType,en as CustomAction,cn as Dimensions,mt as Easings,Ba as Equals,sn as FadeAlphaAction,un as FontManager,Ja as Game,ln as GlobalVariables,tn as GroupAction,tr as I18n,En as ImageManager,er as Label,Fe as LabelHorizontalAlignmentMode,hn as LayoutConstraint,qa as LegacyTimer,X as M2EventType,Vt as M2ImageStatus,we as M2Node,pt as M2NodeType,nt as M2c2KitHelpers,nn as MoveAction,Ai as MutablePath,Pn as NoneTransition,ir as RandomDraws,on as RotateAction,an as ScaleAction,Je as Scene,Cn as SceneTransition,Zr as SequenceAction,rr as Shape,Bt as ShapeType,bn as SlideTransition,Pi as Sprite,Qa as Story,nr as TextLine,Qi as Timer,Si as Transition,Me as TransitionDirection,Xe as TransitionType,yi as Uuid,rn as WaitAction,F as WebColors,Zi as WebGlInfo,ye as handleInterfaceOptions};
1
+ var at=(g=>(g.Node="Node",g.Scene="Scene",g.Sprite="Sprite",g.Label="Label",g.TextLine="TextLine",g.Shape="Shape",g.Composite="Composite",g.SoundPlayer="SoundPlayer",g.SoundRecorder="SoundRecorder",g))(at||{});const zt={Deferred:"Deferred",WillFetch:"WillFetch",Fetching:"Fetching",Fetched:"Fetched",Decoding:"Decoding",Ready:"Ready",Error:"Error"};var pt=(g=>(g.Sequence="Sequence",g.Group="Group",g.Wait="Wait",g.Custom="Custom",g.Move="Move",g.Scale="Scale",g.FadeAlpha="FadeAlpha",g.Rotate="Rotate",g.Play="Play",g.Repeat="Repeat",g.RepeatForever="RepeatForever",g))(pt||{});const Ct=class tt{static toTypeAsString(t){switch(t){case tt.none:return"None";case tt.linear:return"Linear";case tt.quadraticIn:return"QuadraticIn";case tt.quadraticOut:return"QuadraticOut";case tt.quadraticInOut:return"QuadraticInOut";case tt.cubicIn:return"CubicIn";case tt.cubicOut:return"CubicOut";case tt.cubicInOut:return"CubicInOut";case tt.quarticIn:return"QuarticIn";case tt.quarticOut:return"QuarticOut";case tt.quarticInOut:return"QuarticInOut";case tt.quinticIn:return"QuinticIn";case tt.quinticOut:return"QuinticOut";case tt.quinticInOut:return"QuinticInOut";case tt.sinusoidalIn:return"SinusoidalIn";case tt.sinusoidalOut:return"SinusoidalOut";case tt.sinusoidalInOut:return"SinusoidalInOut";case tt.exponentialIn:return"ExponentialIn";case tt.exponentialOut:return"ExponentialOut";case tt.exponentialInOut:return"ExponentialInOut";case tt.circularIn:return"CircularIn";case tt.circularOut:return"CircularOut";case tt.circularInOut:return"CircularInOut";default:throw new Error("Easings.toTypeAsString(): Unknown easing function")}}static fromTypeAsString(t){switch(t){case"None":return tt.none;case"Linear":return tt.linear;case"QuadraticIn":return tt.quadraticIn;case"QuadraticOut":return tt.quadraticOut;case"QuadraticInOut":return tt.quadraticInOut;case"CubicIn":return tt.cubicIn;case"CubicOut":return tt.cubicOut;case"CubicInOut":return tt.cubicInOut;case"QuarticIn":return tt.quarticIn;case"QuarticOut":return tt.quarticOut;case"QuarticInOut":return tt.quarticInOut;case"QuinticIn":return tt.quinticIn;case"QuinticOut":return tt.quinticOut;case"QuinticInOut":return tt.quinticInOut;case"SinusoidalIn":return tt.sinusoidalIn;case"SinusoidalOut":return tt.sinusoidalOut;case"SinusoidalInOut":return tt.sinusoidalInOut;case"ExponentialIn":return tt.exponentialIn;case"ExponentialOut":return tt.exponentialOut;case"ExponentialInOut":return tt.exponentialInOut;case"CircularIn":return tt.circularIn;case"CircularOut":return tt.circularOut;case"CircularInOut":return tt.circularInOut;default:throw new Error(`Easings.fromTypeAsString(): Unknown easing function type ${t}`)}}};Ct.none=(g,t,i,n)=>i+t,Ct.linear=(g,t,i,n)=>i*g/n+t,Ct.quadraticIn=(g,t,i,n)=>(g/=n,i*g*g+t),Ct.quadraticOut=(g,t,i,n)=>(g/=n,-i*g*(g-2)+t),Ct.quadraticInOut=(g,t,i,n)=>(g/=n/2,g<1?i/2*g*g+t:(g--,-i/2*(g*(g-2)-1)+t)),Ct.cubicIn=(g,t,i,n)=>(g/=n,i*g*g*g+t),Ct.cubicOut=(g,t,i,n)=>(g/=n,g--,i*(g*g*g+1)+t),Ct.cubicInOut=(g,t,i,n)=>(g/=n/2,g<1?i/2*g*g*g+t:(g-=2,i/2*(g*g*g+2)+t)),Ct.quarticIn=(g,t,i,n)=>(g/=n,i*g*g*g*g+t),Ct.quarticOut=(g,t,i,n)=>(g/=n,g--,-i*(g*g*g*g-1)+t),Ct.quarticInOut=(g,t,i,n)=>(g/=n/2,g<1?i/2*g*g*g*g+t:(g-=2,-i/2*(g*g*g*g-2)+t)),Ct.quinticIn=(g,t,i,n)=>(g/=n,i*g*g*g*g*g+t),Ct.quinticOut=(g,t,i,n)=>(g/=n,g--,i*(g*g*g*g*g+1)+t),Ct.quinticInOut=(g,t,i,n)=>(g/=n/2,g<1?i/2*g*g*g*g*g+t:(g-=2,i/2*(g*g*g*g*g+2)+t)),Ct.sinusoidalIn=(g,t,i,n)=>-i*Math.cos(g/n*(Math.PI/2))+i+t,Ct.sinusoidalOut=(g,t,i,n)=>i*Math.sin(g/n*(Math.PI/2))+t,Ct.sinusoidalInOut=(g,t,i,n)=>-i/2*(Math.cos(Math.PI*g/n)-1)+t,Ct.exponentialIn=(g,t,i,n)=>i*Math.pow(2,10*(g/n-1))+t,Ct.exponentialOut=(g,t,i,n)=>i*(-Math.pow(2,-10*g/n)+1)+t,Ct.exponentialInOut=(g,t,i,n)=>(g/=n/2,g<1?i/2*Math.pow(2,10*(g-1))+t:(g--,i/2*(-Math.pow(2,-10*g)+2)+t)),Ct.circularIn=(g,t,i,n)=>(g/=n,-i*(Math.sqrt(1-g*g)-1)+t),Ct.circularOut=(g,t,i,n)=>(g/=n,g--,i*Math.sqrt(1-g*g)+t),Ct.circularInOut=(g,t,i,n)=>(g/=n/2,g<1?-i/2*(Math.sqrt(1-g*g)-1)+t:(g-=2,i/2*(Math.sqrt(1-g*g)+1)+t));let Te=Ct;var Ut=(g=>(g.Undefined="Undefined",g.Rectangle="Rectangle",g.Circle="Circle",g.Path="Path",g))(Ut||{});const cn=class $n{constructor(t){this.startTime=NaN,this.stopTime=NaN,this.stopped=!0,this.cumulativeElapsed=NaN,this.name=t}static now(){return window.performance.now()}static new(t){this._timers=this._timers.filter(n=>n.name!==t);const i=new $n(t);i.cumulativeElapsed=0,this._timers.push(i)}static startNew(t){this.new(t),this.start(t)}static start(t){const i=this._timers.filter(n=>n.name===t).find(Boolean);if(i===void 0)throw new Error(`can't start timer. timer with name ${t} does not exist.`);if(i.stopped===!1)throw new Error(`can't start timer. timer with name ${t} is already started.`);i.startTime=window.performance.now(),i.stopped=!1}static stop(t){const i=this._timers.filter(n=>n.name===t).find(Boolean);if(i===void 0)throw new Error(`can't stop timer. timer with name ${t} does not exist.`);if(i.stopped===!0)throw new Error(`can't stop timer. timer with name ${t} is already stopped.`);i.stopTime=window.performance.now(),i.cumulativeElapsed=i.cumulativeElapsed+i.stopTime-i.startTime,i.stopped=!0}static elapsed(t){const i=this._timers.filter(n=>n.name===t).find(Boolean);if(i===void 0)throw new Error(`can't get elapsed time. timer with name ${t} does not exist.`);return i.stopped?i.cumulativeElapsed:i.cumulativeElapsed+window.performance.now()-i.startTime}static remove(t){if(this._timers.filter(n=>n.name===t).find(Boolean)===void 0)throw new Error(`can't remove timer. timer with name ${t} does not exist.`);this._timers=this._timers.filter(n=>n.name!=t)}static removeAll(){this._timers=new Array}static exists(t){return this._timers.some(i=>i.name===t)}};cn._timers=new Array;let Wt=cn;class q{static getUrlFromManifest(t,i){const n=t.manifest;return n&&n[i]?n[i]:i}static urlHasScheme(t){return/^[a-z]+:\/\//i.test(t)}static registerM2NodeClass(...t){m2c2Globals.m2NodeClassRegistry||(m2c2Globals.m2NodeClassRegistry={}),t.forEach(i=>{m2c2Globals.m2NodeClassRegistry={...m2c2Globals.m2NodeClassRegistry,[i.name]:i}})}static createFrameUpdateTimestamps(){return{timestamp:Number.isNaN(m2c2Globals?.now)||m2c2Globals?.now===void 0?Wt.now():m2c2Globals.now,iso8601Timestamp:m2c2Globals.iso8601Now?m2c2Globals.iso8601Now:new Date().toISOString()}}static createTimestamps(){return{timestamp:Wt.now(),iso8601Timestamp:new Date().toISOString()}}static calculateRotatedPoints(t){const i=t.ancestors;i.reverse(),i.push(t);const n=i.map(u=>{const h=q.calculateNodeAbsoluteBoundingBox(u);return q.boundingBoxToPoints(h)});for(let u=0;u<n.length;u++){if(!nr(i[u]))continue;const h=n[u],C=i[u].zRotation,F=q.findCentroid(h);for(let B=u;B<i.length;B++)n[B]=Ks(n[B],C,F)}return n[n.length-1]}static rotateCanvasForDrawableNode(t,i){const n=q.calculateRotationTransforms(i);if(n.length===0)return;const u=m2c2Globals.canvasScale/i.absoluteScale;Hs(n,u,t)}static calculateNodeAbsoluteBoundingBox(t){const i=t.anchorPoint,n=t.absoluteScale;let u=t.size.width,h=t.size.height;if(t.type===at.Shape&&t.shapeType===Ut.Circle){const et=t.circleOfRadius;if(!et)throw"circleOfRadius is undefined";u=et*2,h=et*2}const C=t.absolutePosition.x-u*i.x*n,F=t.absolutePosition.x+u*(1-i.x)*n,B=t.absolutePosition.y-h*i.y*n,U=t.absolutePosition.y+h*(1-i.y)*n;return{xMin:C,xMax:F,yMin:B,yMax:U}}static radiansToDegrees(t){return-q.normalizeAngleRadians(t)*(180/Math.PI)}static normalizeAngleRadians(t){const i=Math.floor(t/(2*Math.PI));let n=t-i*(2*Math.PI);return n<0&&(n+=2*Math.PI),n}static arePointsOnSameSideOfLine(t,i,n,u){const h=(u.x-n.x)*(t.y-n.y)-(u.y-n.y)*(t.x-n.x),C=(u.x-n.x)*(i.y-n.y)-(u.y-n.y)*(i.x-n.x);return h*C>=0}static isPointInsideRectangle(t,i){if(i.length!==4)throw new Error("Invalid input: expected an array of four points");return q.arePointsOnSameSideOfLine(t,i[2],i[0],i[1])&&q.arePointsOnSameSideOfLine(t,i[3],i[1],i[2])&&q.arePointsOnSameSideOfLine(t,i[0],i[2],i[3])&&q.arePointsOnSameSideOfLine(t,i[1],i[3],i[0])}static nodeOrAncestorHasBeenRotated(t){const i=t.ancestors;return i.push(t),i.some(n=>nr(n))}static boundingBoxToPoints(t){const{xMin:i,xMax:n,yMin:u,yMax:h}=t;return[{x:i,y:u},{x:n,y:u},{x:n,y:h},{x:i,y:h}]}static findCentroid(t){if(t.length!==4)throw new Error("Invalid input: expected an array of four points");let i=0,n=0;for(const C of t)i+=C.x,n+=C.y;const u=i/4,h=n/4;return{x:u,y:h}}static rotatePoint(t,i,n){const u=t.x-n.x,h=t.y-n.y,C=u*Math.cos(-i)-h*Math.sin(-i),F=u*Math.sin(-i)+h*Math.cos(-i);return{x:C+n.x,y:F+n.y}}static calculateRotationTransforms(t){const i=[],n=t.ancestors;return n.reverse(),n.push(t),n.forEach(u=>{if(nr(u)){const h=u;if(h.type===at.Scene){const U={x:h.absolutePosition.x+h.size.width*.5,y:h.absolutePosition.y+h.size.height*.5};i.push({radians:h.zRotation,center:U});return}const C=q.calculateNodeAbsoluteBoundingBox(h),F=q.boundingBoxToPoints(C),B=q.findCentroid(F);i.push({radians:h.zRotation,center:B})}}),i}}function Hs(g,t,i){g.forEach(n=>{i.rotate(q.radiansToDegrees(n.radians),n.center.x*t,n.center.y*t)})}function nr(g){return q.normalizeAngleRadians(g.zRotation)!==0&&g.isDrawable}function Ks(g,t,i){if(g.length!==4)throw new Error("Invalid input: expected an array of four points");const n=[];for(const u of g)n.push(q.rotatePoint(u,t,i));return n}class xt{constructor(t){if(this.expression=new Array,this.WARNING_EXPRESSION_LENGTH=32,typeof t=="number"){this.pushToExpression(t);return}if(t===void 0){this.pushToExpression(1/0);return}this.pushToExpression(t)}pushToExpression(t){if(t===this)throw new Error("Cannot add, subtract, or assign a Futurable with itself.");this.expression.push(t),this.expression.length===this.WARNING_EXPRESSION_LENGTH&&console.warn(`Expression length is ${this.WARNING_EXPRESSION_LENGTH} elements. Something may be wrong.`)}assign(t){for(;this.expression.length>0;)this.expression.pop();this.pushToExpression(t)}add(...t){return this.appendOperation(Mi.Add,...t),this}subtract(...t){return this.appendOperation(Mi.Subtract,...t),this}appendOperation(t,...i){i.forEach(n=>{this.pushToExpression(t),this.pushToExpression(n)})}get value(){let t=0;const i=this.expression.flat(1/0);let n=1;for(let u=0;u<i.length;u++){if(typeof i[u]=="number"){t=t+n*i[u];continue}if(i[u]instanceof xt){t=t+n*i[u].value;continue}if(i[u]===Mi.Add){n=1;continue}if(i[u]===Mi.Subtract){n=-1;continue}}return t}}const Mi={Add:"Add",Subtract:"Subtract"};class V{constructor(t=!1){this.startOffset=new xt(0),this.started=!1,this.running=!1,this._completed=!1,this.runStartTime=-1,this.duration=new xt,this.runDuringTransition=t}initialize(t){const i=this.clone();return this.assignParents(i,i,t),this.propagateRunDuringTransition(i),this.assignDurations(i),this.assignStartOffsets(i),i}assignParents(t,i,n){if(n!==void 0&&(t.key=n),this.isParent(t)){const u=t.children;u.forEach(h=>{h.parent=t}),u.filter(h=>this.isParent(h)).forEach(h=>this.assignParents(h,i,n))}}propagateRunDuringTransition(t){this.isParent(t)&&(t.descendants.some(i=>i.runDuringTransition)&&(t.runDuringTransition=!0),t.children.forEach(i=>this.propagateRunDuringTransition(i)))}assignDurations(t){t.duration=this.calculateDuration(t),this.isParent(t)&&t.children.forEach(i=>this.assignDurations(i))}calculateDuration(t){if(t.type===pt.Group){const n=t.children.map(u=>this.calculateDuration(u)).reduce((u,h)=>Math.max(u,h.value),0);return new xt(n)}if(t.type===pt.Sequence){const n=t.children.map(u=>this.calculateDuration(u)).reduce((u,h)=>u+h.value,0);return new xt(n)}return this.isRepeating(t)?new xt:t.duration}assignStartOffsets(t){t.startOffset=this.calculateStartOffset(t),this.isParent(t)&&t.children.forEach(i=>this.assignStartOffsets(i))}calculateStartOffset(t){if(t.parent===void 0)return new xt(0);if(t.parent.type!==pt.Sequence)return t.parent.startOffset;const i=new xt(0);i.add(t.parent.startOffset);for(const n of t.parent.children){if(n===t)break;i.add(n.duration)}return i}static evaluateAction(t,i,n,u){if(i.involvedInSceneTransition()&&!t.runDuringTransition||(t.runStartTime===-1&&t.assignRunStartTimes(t,n),n<t.runStartTime+t.startOffset.value))return;if(t.shouldBeRunning(n)&&(t.running=!0),t.isParent(t)){if(t.children.forEach(C=>{V.evaluateAction(C,i,n,u)}),!t.isRepeating(t)){t.started||(t.started=!0),t.running&&t.completed&&(t.running=!1);return}V.evaluateRepeatingActions(t,n);return}if(t.shouldBeRunning(n)||(t.running=!1),t.running===!1&&t.completed===!0)return;const h=n-(t.runStartTime+t.startOffset.value);switch(t.type){case pt.Custom:V.evaluateCustomAction(t);break;case pt.Play:V.evaluatePlayAction(i,t);break;case pt.Wait:V.evaluateWaitAction(t,n);break;case pt.Move:V.evaluateMoveAction(t,i,h);break;case pt.Scale:V.evaluateScaleAction(t,i,h,u);break;case pt.FadeAlpha:V.evaluateFadeAlphaAction(t,i,h,u);break;case pt.Rotate:V.evaluateRotateAction(t,i,h,u);break;default:throw new Error(`Action type not recognized: ${t.type}`)}}static evaluateRepeatingActions(t,i){if(t.started||(t.started=!0),t.repetitionHasCompleted){t.completedRepetitions++;const n=t.children[0].duration.value;if(t.cumulativeDuration=t.cumulativeDuration+n,!isFinite(n))throw"repetitionDuration is not finite";if(!t.completed)t.restartAction(t,i);else{if(t.type===pt.RepeatForever)throw new Error("RepeatForever action should never complete");t.duration.assign(t.cumulativeDuration),t.running=!1}}}static evaluateRotateAction(t,i,n,u){const h=t;h.started||(h.byAngle!==void 0&&(h.delta=h.byAngle),h.toAngle!==void 0&&(h.toAngle=q.normalizeAngleRadians(h.toAngle),i.zRotation=q.normalizeAngleRadians(i.zRotation),h.delta=h.toAngle-i.zRotation,h.shortestUnitArc===!0&&Math.abs(h.delta)>Math.PI&&(h.delta=2*Math.PI-Math.abs(h.delta))),h.started=!0,h.finalValue=i.zRotation+h.delta),n<h.duration.value?(i.zRotation=i.zRotation+h.delta*(u/h.duration.value),h.delta<=0&&i.zRotation<h.finalValue&&(i.zRotation=h.finalValue),h.delta>0&&i.zRotation>h.finalValue&&(i.zRotation=h.finalValue)):(i.zRotation=h.finalValue,h.running=!1,h.completed=!0)}static evaluateFadeAlphaAction(t,i,n,u){const h=t;h.started||(h.delta=h.alpha-i.alpha,h.started=!0),n<h.duration.value?i.alpha=i.alpha+h.delta*(u/h.duration.value):(i.alpha=h.alpha,h.running=!1,h.completed=!0)}static evaluateScaleAction(t,i,n,u){const h=t;h.started||(h.delta=h.scale-i.scale,h.started=!0),n<h.duration.value?i.scale=i.scale+h.delta*(u/h.duration.value):(i.scale=h.scale,h.running=!1,h.completed=!0)}static evaluateMoveAction(t,i,n){const u=t;u.started||(u.dx=u.point.x-i.position.x,u.dy=u.point.y-i.position.y,u.startPoint.x=i.position.x,u.startPoint.y=i.position.y,u.started=!0),n<u.duration.value?(i.position.x=u.easing(n,u.startPoint.x,u.dx,u.duration.value),i.position.y=u.easing(n,u.startPoint.y,u.dy,u.duration.value)):(i.position.x=u.point.x,i.position.y=u.point.y,u.running=!1,u.completed=!0)}static evaluateWaitAction(t,i){const n=t;i>t.runStartTime+t.startOffset.value+t.duration.value&&(n.running=!1,n.completed=!0)}static evaluatePlayAction(t,i){if(t.type!==at.SoundPlayer)throw new Error("Play action can only be used with a SoundPlayer");const n=i,u=t,h=u.game.soundManager;if(!n.started){const C=h.getSound(u.soundName);if(C.audioBuffer){const F=h.audioContext.createBufferSource();F.buffer=C.audioBuffer,F.onended=()=>{n.running=!1,n.completed=!0;const B=performance.now()-(i.runStartTime+i.startOffset.value);i.duration.assign(B)},F.connect(h.audioContext.destination),F.start(),n.started=!0}else{if(C.status===zt.Error)throw new Error(`error loading sound ${C.soundName} (url ${C.url})`);console.warn(`Play action: audio buffer not ready for sound ${u.soundName} (url: ${C.url}); will try next frame`),C.status===zt.Deferred&&h.fetchDeferredSound(C)}}}static evaluateCustomAction(t){const i=t;i.callback(),i.running=!1,i.completed=!0}assignRunStartTimes(t,i){t.runStartTime=i,t.isParent(t)&&t.children.forEach(n=>{t.assignRunStartTimes(n,i)})}restartAction(t,i){if(t.runStartTime=i,t.running=!0,t.started=!0,t.type===pt.Play&&(t.duration=new xt),t.isParent(t)){t.children.forEach(n=>{t.restartAction(n,i)});return}t.completed=!1}shouldBeRunning(t){return t>=this.runStartTime+this.startOffset.value&&t<=this.runStartTime+this.startOffset.value+this.duration.value}static move(t){return new vn(t.point,new xt(t.duration),t.easing??Te.linear,t.runDuringTransition??!1)}static wait(t){return new gn(new xt(t.duration),t.runDuringTransition??!1)}static custom(t){return new pn(t.callback,t.runDuringTransition??!1)}static play(t){return new mn(t?.runDuringTransition??!1)}static scale(t){return new yn(t.scale,new xt(t.duration),t.runDuringTransition)}static fadeAlpha(t){return new wn(t.alpha,new xt(t.duration),t.runDuringTransition)}static rotate(t){if(t.byAngle!==void 0&&t.toAngle!==void 0)throw new Error("rotate Action: cannot specify both byAngle and toAngle");if(t.byAngle===void 0&&t.toAngle===void 0)throw new Error("rotate Action: must specify either byAngle or toAngle");if(t.toAngle===void 0&&t.shortestUnitArc!==void 0)throw new Error("rotate Action: shortestUnitArc can only be specified when toAngle is provided");return t.toAngle!==void 0&&t.shortestUnitArc===void 0&&(t.shortestUnitArc=!0),new Sn(t.byAngle,t.toAngle,t.shortestUnitArc,new xt(t.duration),t.runDuringTransition)}static sequence(t){const i=new un(t);return i.children=t,i}static group(t){const i=new dn(t);return i.children=t,i}static repeat(t){return new sr(t.action,t.count,t.runDuringTransition)}static repeatForever(t){return new fn(t.action,t.runDuringTransition)}isParent(t){return t.type===pt.Group||t.type===pt.Sequence||t.type===pt.Repeat||t.type===pt.RepeatForever}isRepeating(t){return t.type===pt.Repeat||t.type===pt.RepeatForever}get completed(){return this._completed}set completed(t){this._completed=t}}class un extends V{constructor(t){super(),this.type=pt.Sequence,this.children=t}clone(){const t=this.children.map(n=>n.clone()),i=V.sequence(t);return i.children.forEach(n=>n.key=this.key),i.key=this.key,i}get completed(){return this.children.every(t=>t.completed)}get descendants(){return ar(this)}}class dn extends V{constructor(t){super(),this.type=pt.Group,this.children=new Array,this.children=t}clone(){const t=this.children.map(n=>n.clone()),i=V.group(t);return i.children.forEach(n=>n.key=this.key),i.key=this.key,i}get completed(){return this.children.every(t=>t.completed)}get descendants(){return ar(this)}}class sr extends V{constructor(t,i,n=!1){super(n),this.type=pt.Repeat,this.completedRepetitions=0,this.cumulativeDuration=0,this.children=[t],this.count=i,this.duration=new xt}clone(){if(this.children.length!==1)throw new Error("Repeat action must have exactly one child");const t=V.repeat({action:this.children[0].clone(),count:this.count,runDuringTransition:this.runDuringTransition});return t.children[0].key=this.key,t.key=this.key,t}get completed(){return this.children.every(t=>t.completed)&&this.completedRepetitions===this.count}get descendantsAreCompleted(){return this.children.every(t=>t.completed)}get repetitionHasCompleted(){return this.running&&this.descendantsAreCompleted&&!this.completed}get descendants(){return ar(this)}}class fn extends sr{constructor(t,i=!1){super(t,1/0,i),this.type=pt.RepeatForever,this.count=1/0}clone(){if(this.children.length!==1)throw new Error("RepeatForever action must have exactly one child");const t=V.repeatForever({action:this.children[0].clone(),runDuringTransition:this.runDuringTransition});return t.children[0].key=this.key,t.key=this.key,t}}function ar(g){const t=[];function i(n){if(n.isParent(n))for(const u of n.children)t.push(u),i(u)}return i(g),t}class pn extends V{constructor(t,i=!1){super(i),this.type=pt.Custom,this.callback=t,this.duration=new xt(0)}clone(){const t=V.custom({callback:this.callback,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class mn extends V{constructor(t=!1){super(t),this.type=pt.Play,this.duration=new xt}clone(){const t=V.play({runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class gn extends V{constructor(t,i){super(i),this.type=pt.Wait,this.duration=t}clone(){const t=V.wait({duration:this.duration.value,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class vn extends V{constructor(t,i,n,u){super(u),this.type=pt.Move,this.startPoint={x:NaN,y:NaN},this.dx=0,this.dy=0,this.duration=i,this.point=t,this.easing=n}clone(){const t=V.move({point:this.point,duration:this.duration.value,easing:this.easing,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class yn extends V{constructor(t,i,n=!1){super(n),this.type=pt.Scale,this.delta=0,this.duration=i,this.scale=t}clone(){const t=V.scale({scale:this.scale,duration:this.duration.value,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class wn extends V{constructor(t,i,n=!1){super(n),this.type=pt.FadeAlpha,this.delta=0,this.duration=i,this.alpha=t}clone(){const t=V.fadeAlpha({alpha:this.alpha,duration:this.duration.value,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class Sn extends V{constructor(t,i,n,u,h=!1){super(h),this.type=pt.Rotate,this.delta=0,this.finalValue=NaN,this.duration=u,this.byAngle=t,this.toAngle=i,this.shortestUnitArc=n}clone(){const t=V.rotate({byAngle:this.byAngle,toAngle:this.toAngle,shortestUnitArc:this.shortestUnitArc,duration:this.duration.value,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}var si=(g=>(g.Game="Game",g.Survey="Survey",g))(si||{});class Ft{static Dispose(t){t.filter(i=>!i?.isDeleted()).forEach(i=>i?.delete())}static makePaint(t,i,n,u){const h=new t.Paint;return h.setColor(t.Color(i[0],i[1],i[2],i[3])),h.setStyle(n),h.setAntiAlias(u),h}}class Ni{constructor(){this._subpaths=new Array,this.currentPath=new Array}get subpaths(){return this.currentPath.length>0?[...this._subpaths,this.currentPath]:this._subpaths}move(t){this.currentPath.length>0&&this._subpaths.push(this.currentPath),this.currentPath=new Array,this.currentPath.push(t)}addLine(t){this.currentPath.push(t)}clear(){this._subpaths=new Array,this.currentPath=new Array}duplicate(){const t=new Ni;return t._subpaths=JSON.parse(JSON.stringify(this._subpaths)),t.currentPath=JSON.parse(JSON.stringify(this.currentPath)),t}}class x{}x.Transparent=[0,0,0,0],x.MediumVioletRed=[199,21,133,1],x.DeepPink=[255,20,147,1],x.PaleVioletRed=[219,112,147,1],x.HotPink=[255,105,180,1],x.LightPink=[255,182,193,1],x.Pink=[255,192,203,1],x.DarkRed=[139,0,0,1],x.Red=[255,0,0,1],x.Firebrick=[178,34,34,1],x.Crimson=[220,20,60,1],x.IndianRed=[205,92,92,1],x.LightCoral=[240,128,128,1],x.Salmon=[250,128,114,1],x.DarkSalmon=[233,150,122,1],x.LightSalmon=[255,160,122,1],x.OrangeRed=[255,69,0,1],x.Tomato=[255,99,71,1],x.DarkOrange=[255,140,0,1],x.Coral=[255,127,80,1],x.Orange=[255,165,0,1],x.DarkKhaki=[189,183,107,1],x.Gold=[255,215,0,1],x.Khaki=[240,230,140,1],x.PeachPuff=[255,218,185,1],x.Yellow=[255,255,0,1],x.PaleGoldenrod=[238,232,170,1],x.Moccasin=[255,228,181,1],x.PapayaWhip=[255,239,213,1],x.LightGoldenrodYellow=[250,250,210,1],x.LemonChiffon=[255,250,205,1],x.LightYellow=[255,255,224,1],x.Maroon=[128,0,0,1],x.Brown=[165,42,42,1],x.SaddleBrown=[139,69,19,1],x.Sienna=[160,82,45,1],x.Chocolate=[210,105,30,1],x.DarkGoldenrod=[184,134,11,1],x.Peru=[205,133,63,1],x.RosyBrown=[188,143,143,1],x.Goldenrod=[218,165,32,1],x.SandyBrown=[244,164,96,1],x.Tan=[210,180,140,1],x.Burlywood=[222,184,135,1],x.Wheat=[245,222,179,1],x.NavajoWhite=[255,222,173,1],x.Bisque=[255,228,196,1],x.BlanchedAlmond=[255,235,205,1],x.Cornsilk=[255,248,220,1],x.DarkGreen=[0,100,0,1],x.Green=[0,128,0,1],x.DarkOliveGreen=[85,107,47,1],x.ForestGreen=[34,139,34,1],x.SeaGreen=[46,139,87,1],x.Olive=[128,128,0,1],x.OliveDrab=[107,142,35,1],x.MediumSeaGreen=[60,179,113,1],x.LimeGreen=[50,205,50,1],x.Lime=[0,255,0,1],x.SpringGreen=[0,255,127,1],x.MediumSpringGreen=[0,250,154,1],x.DarkSeaGreen=[143,188,143,1],x.MediumAquamarine=[102,205,170,1],x.YellowGreen=[154,205,50,1],x.LawnGreen=[124,252,0,1],x.Chartreuse=[127,255,0,1],x.LightGreen=[144,238,144,1],x.GreenYellow=[173,255,47,1],x.PaleGreen=[152,251,152,1],x.Teal=[0,128,128,1],x.DarkCyan=[0,139,139,1],x.LightSeaGreen=[32,178,170,1],x.CadetBlue=[95,158,160,1],x.DarkTurquoise=[0,206,209,1],x.MediumTurquoise=[72,209,204,1],x.Turquoise=[64,224,208,1],x.Aqua=[0,255,255,1],x.Cyan=[0,255,255,1],x.Aquamarine=[127,255,212,1],x.PaleTurquoise=[175,238,238,1],x.LightCyan=[224,255,255,1],x.Navy=[0,0,128,1],x.DarkBlue=[0,0,139,1],x.MediumBlue=[0,0,205,1],x.Blue=[0,0,255,1],x.MidnightBlue=[25,25,112,1],x.RoyalBlue=[65,105,225,1],x.SteelBlue=[70,130,180,1],x.DodgerBlue=[30,144,255,1],x.DeepSkyBlue=[0,191,255,1],x.CornflowerBlue=[100,149,237,1],x.SkyBlue=[135,206,235,1],x.LightSkyBlue=[135,206,250,1],x.LightSteelBlue=[176,196,222,1],x.LightBlue=[173,216,230,1],x.PowderBlue=[176,224,230,1],x.Indigo=[75,0,130,1],x.Purple=[128,0,128,1],x.DarkMagenta=[139,0,139,1],x.DarkViolet=[148,0,211,1],x.DarkSlateBlue=[72,61,139,1],x.BlueViolet=[138,43,226,1],x.DarkOrchid=[153,50,204,1],x.Fuchsia=[255,0,255,1],x.Magenta=[255,0,255,1],x.SlateBlue=[106,90,205,1],x.MediumSlateBlue=[123,104,238,1],x.MediumOrchid=[186,85,211,1],x.MediumPurple=[147,112,219,1],x.Orchid=[218,112,214,1],x.Violet=[238,130,238,1],x.Plum=[221,160,221,1],x.Thistle=[216,191,216,1],x.Lavender=[230,230,250,1],x.MistyRose=[255,228,225,1],x.AntiqueWhite=[250,235,215,1],x.Linen=[250,240,230,1],x.Beige=[245,245,220,1],x.WhiteSmoke=[245,245,245,1],x.LavenderBlush=[255,240,245,1],x.OldLace=[253,245,230,1],x.AliceBlue=[240,248,255,1],x.Seashell=[255,245,238,1],x.GhostWhite=[248,248,255,1],x.Honeydew=[240,255,240,1],x.FloralWhite=[255,250,240,1],x.Azure=[240,255,255,1],x.MintCream=[245,255,250,1],x.Snow=[255,250,250,1],x.Ivory=[255,255,240,1],x.White=[255,255,255,1],x.Black=[0,0,0,1],x.DarkSlateGray=[47,79,79,1],x.DimGray=[105,105,105,1],x.SlateGray=[112,128,144,1],x.Gray=[128,128,128,1],x.LightSlateGray=[119,136,153,1],x.DarkGray=[169,169,169,1],x.Silver=[192,192,192,1],x.LightGray=[211,211,211,1],x.Gainsboro=[220,220,220,1],x.RebeccaPurple=[102,51,153,1];class X{}X.FPS_DISPLAY_TEXT_FONT_SIZE=12,X.FPS_DISPLAY_TEXT_COLOR=[0,0,0,.5],X.FPS_DISPLAY_UPDATE_INTERVAL=1e3,X.MAXIMUM_RECORDED_ACTIVITY_METRICS=32,X.FPS_METRIC_REPORT_THRESHOLD=59,X.DEFAULT_SCENE_BACKGROUND_COLOR=x.White,X.DEFAULT_SHAPE_FILL_COLOR=x.Red,X.DEFAULT_PATH_STROKE_COLOR=x.Red,X.DEFAULT_PATH_LINE_WIDTH=2,X.DEFAULT_FONT_COLOR=x.Black,X.DEFAULT_FONT_SIZE=16,X.LIMITED_FPS_RATE=5,X.FREE_NODES_SCENE_NAME="__freeNodesScene",X.OUTGOING_SCENE_NAME="__outgoingScene",X.OUTGOING_SCENE_SPRITE_NAME="__outgoingSceneSprite",X.OUTGOING_SCENE_IMAGE_NAME="__outgoingSceneSnapshot",X.SESSION_INITIALIZATION_POLLING_INTERVAL_MS=50,X.MODULE_METADATA_PLACEHOLDER={name:"",version:"",dependencies:{}},X.DEFAULT_ROOT_ELEMENT_ID="m2c2kit";class Vs extends Ni{constructor(){super(...arguments),this.strokeColor=X.DEFAULT_PATH_STROKE_COLOR,this.lineWidth=X.DEFAULT_PATH_LINE_WIDTH,this.linePresentations=[]}addLine(t){this.isNewLinePresentation()&&this.linePresentations.push({strokeColor:this.strokeColor,lineWidth:this.lineWidth,subpathIndex:this._subpaths.length,pointIndex:this.currentPath.length-1}),this.currentPath.push(t)}isNewLinePresentation(){if(this.linePresentations.length===0)return!0;const t=this.linePresentations[this.linePresentations.length-1];return t.strokeColor!==this.strokeColor||t.lineWidth!==this.lineWidth}clear(){super.clear(),this.linePresentations=[],this.strokeColor=X.DEFAULT_PATH_STROKE_COLOR,this.lineWidth=X.DEFAULT_PATH_LINE_WIDTH}duplicate(){const t=super.duplicate();return t.strokeColor=JSON.parse(JSON.stringify(this.strokeColor)),t.lineWidth=this.lineWidth,t.linePresentations=JSON.parse(JSON.stringify(this.linePresentations)),t}}var Dt=(g=>(g.topToTopOf="topToTopOf",g.topToBottomOf="topToBottomOf",g.bottomToTopOf="bottomToTopOf",g.bottomToBottomOf="bottomToBottomOf",g.startToStartOf="startToStartOf",g.startToEndOf="startToEndOf",g.endToEndOf="endToEndOf",g.endToStartOf="endToStartOf",g))(Dt||{});class Pn{constructor(t,i){this.verticalConstraint=!1,this.focalNodeMinimum=!1,this.alterNodeMinimum=!1,this.verticalTypes=[Dt.topToTopOf,Dt.topToBottomOf,Dt.bottomToTopOf,Dt.bottomToBottomOf],this.focalNodeMinimumTypes=[Dt.topToTopOf,Dt.topToBottomOf,Dt.startToStartOf,Dt.startToEndOf],this.alterNodeMinimumTypes=[Dt.topToTopOf,Dt.bottomToTopOf,Dt.startToStartOf,Dt.endToStartOf],this.type=t,this.alterNode=i,this.verticalTypes.includes(t)?(this.verticalConstraint=!0,this.focalNodeMinimumTypes.includes(t)?this.focalNodeMinimum=!0:this.focalNodeMinimum=!1,this.alterNodeMinimumTypes.includes(t)?this.alterNodeMinimum=!0:this.alterNodeMinimum=!1):(this.verticalConstraint=!1,this.focalNodeMinimumTypes.includes(t)?this.focalNodeMinimum=!0:this.focalNodeMinimum=!1,this.alterNodeMinimumTypes.includes(t)?this.alterNodeMinimum=!0:this.alterNodeMinimum=!1)}}class De{static generate(){try{return crypto.randomUUID()}catch{let t;try{t=()=>crypto.getRandomValues(new Uint8Array(1))[0]}catch{t=()=>Math.floor(Math.random()*256)}return("10000000-1000-4000-8000"+-1e11).replace(/[018]/g,i=>(Number(i)^t()&15>>Number(i)/4).toString(16))}}static isValid(t){return t?t==="00000000-0000-0000-0000-000000000000"?!0:/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t):!1}}const G={ActivityStart:"ActivityStart",ActivityEnd:"ActivityEnd",ActivityCancel:"ActivityCancel",ActivityData:"ActivityData",GameWarmupStart:"GameWarmupStart",GameWarmupEnd:"GameWarmupEnd",TapDown:"TapDown",TapUp:"TapUp",TapUpAny:"TapUpAny",TapLeave:"TapLeave",PointerDown:"PointerDown",PointerUp:"PointerUp",PointerMove:"PointerMove",PointerLeave:"PointerLeave",Drag:"Drag",DragStart:"DragStart",DragEnd:"DragEnd",Composite:"Composite",FrameDidSimulatePhysics:"FrameDidSimulatePhysics",SceneSetup:"SceneSetup",SceneAppear:"SceneAppear",ScenePresent:"ScenePresent",NodeNew:"NodeNew",NodeAddChild:"NodeAddChild",NodeRemoveChild:"NodeRemoveChild",NodePropertyChange:"NodePropertyChange",DomPointerDown:"DomPointerDown",BrowserImageDataReady:"BrowserImageDataReady",I18nDataReadyEvent:"I18nDataReadyEvent"};class j{static rgbaColor(t,i){return!t||!i?!1:t[0]===i[0]&&t[1]===i[1]&&t[2]===i[2]&&t[3]===i[3]}static value(t,i){return typeof t!=typeof i?!1:t&&typeof t=="object"&&i&&typeof i=="object"?j.objectsDeepEqual(t,i):t===i}static objectsDeepEqual(t,i){if(t===i)return!0;if(Array.isArray(t)&&Array.isArray(i)){if(t.length!==i.length)return!1;for(let n=0;n<t.length;n++)if(!j.objectsDeepEqual(t[n],i[n]))return!1;return!0}if(typeof t=="object"&&!Array.isArray(t)&&t!==null&&typeof i=="object"&&!Array.isArray(i)&&i!==null){const n=Object.keys(t),u=Object.keys(i);if(n.length!==u.length)return!1;for(const h of n)if(!(h in i)||!j.objectsDeepEqual(t[h],i[h]))return!1;return!0}return!1}}function Ys(g,t){t.anchorPoint&&(g.anchorPoint=t.anchorPoint),t.zPosition!==void 0&&(g.zPosition=t.zPosition)}function qs(g,t){t.text!==void 0&&(g.text=t.text),t.fontName!==void 0&&(g.fontName=t.fontName),t.fontColor&&(g.fontColor=t.fontColor),t.fontSize!==void 0&&(g.fontSize=t.fontSize),t.interpolation&&(g.interpolation=t.interpolation),t.localize!==void 0&&(g.localize=t.localize)}function Fe(g,t){g.isDrawable&&Ys(g,t),g.isText&&qs(g,t)}class re{constructor(t={}){this.type=at.Node,this.isDrawable=!1,this.isShape=!1,this.isText=!1,this._suppressEvents=!1,this._position={x:0,y:0},this._scale=1,this._alpha=1,this._zRotation=0,this._isUserInteractionEnabled=!1,this._draggable=!1,this._hidden=!1,this.layout={},this.children=new Array,this.absolutePosition={x:0,y:0},this._size={width:0,height:0},this.absoluteScale=1,this.absoluteAlpha=1,this.absoluteAlphaChange=0,this.actions=new Array,this.eventListeners=new Array,this.uuid=De.generate(),this.needsInitialization=!0,this.userData={},this.loopMessages=new Set,this.nodeEvents=new Array,this.pressed=!1,this.withinHitArea=!1,this.pressedAndWithinHitArea=!1,this.pressedInitialPointerOffset={x:NaN,y:NaN},this.draggingLastPointerOffset={x:NaN,y:NaN},this.dragging=!1,this.toString=()=>{let i=this.type.toString();return this.type==at.Composite&&(i=this.compositeType),this.name!==this.uuid?`${this.name} (${i}, ${this.uuid})`:`${i} (${this.uuid})`},t.suppressEvents!==void 0&&(this.suppressEvents=t.suppressEvents),this.constructionTimeStamp=Number.isNaN(m2c2Globals?.now)||m2c2Globals?.now===void 0?Wt.now():m2c2Globals.now,this.constructionIso8601TimeStamp=new Date().toISOString(),this.constructionSequence=m2c2Globals.eventSequence,this.options=t,t.uuid!==void 0&&(this.uuid=t.uuid),t.name===void 0?this.name=this.uuid:this.name=t.name,t.position!==void 0&&(this.position=t.position),t.scale!==void 0&&(this.scale=t.scale),t.alpha!==void 0&&(this.alpha=t.alpha),t.zRotation!==void 0&&(this.zRotation=t.zRotation),t.isUserInteractionEnabled!==void 0&&(this.isUserInteractionEnabled=t.isUserInteractionEnabled),t.draggable!==void 0&&(this.draggable=t.draggable),t.hidden!==void 0&&(this.hidden=t.hidden),t.layout!==void 0&&(this.layout=t.layout)}initialize(){throw new Error("initialize() called in abstract base class Node.")}get completeNodeOptions(){throw new Error("get completeNodeOptions() called in abstract base class Node.")}saveNodeNewEvent(){if(this.suppressEvents)return;const t={type:G.NodeNew,target:this,nodeType:this.type,compositeType:this.type===at.Composite?this.compositeType:void 0,timestamp:this.constructionTimeStamp,iso8601Timestamp:this.constructionIso8601TimeStamp,nodeOptions:this.completeNodeOptions,sequence:this.constructionSequence};this.saveEvent(t)}savePropertyChangeEvent(t,i){if(this.suppressEvents)return;const n={type:G.NodePropertyChange,target:this,uuid:this.uuid,property:t,value:i,...q.createFrameUpdateTimestamps()};this.saveEvent(n)}saveEvent(t){t.sequence===void 0&&(t.sequence=m2c2Globals.eventSequence);try{this.game.eventStore.addEvent(t)}catch{this.nodeEvents.push(t)}}get game(){const t=i=>{if(i.parent)return i.parent.type===at.Scene?i.parent:t(i.parent);throw new Error(`Node ${this} has not been added to a scene.`)};return t(this).game}isPartOfGame(){if(this.type===at.Scene&&this._game===void 0)return!1;if(this.type===at.Scene&&this._game!==void 0)return!0;const t=i=>{if(i.parent)return i.parent.type===at.Scene?i.parent:t(i.parent)};return t(this)?._game!==void 0}addChild(t){const i=this.suppressEvents||t.suppressEvents;if(t===this)throw new Error(`Cannot add node ${t.toString()} as a child to itself.`);if(t.type==at.Scene)throw new Error(`Cannot add scene ${t.toString()} as a child to node ${this.toString()}. A scene cannot be the child of a node. A scene can only be added to a game object.`);if(this.children.filter(h=>h!==t).map(h=>h.name).includes(t.name))throw new Error(`Cannot add child node ${t.toString()} to parent node ${this.toString()}. A child with name "${t.name}" already exists on this parent.`);let n=new Array;if(this.isPartOfGame())n=this.game.nodes.filter(h=>h.children.includes(t));else{const h=this.descendants;h.includes(t)&&(n=h.filter(C=>C.children.includes(t)).map(C=>C.parent??void 0))}if(n.length===0){t.parent=this,this.children.push(t);const h={type:"NodeAddChild",target:this,uuid:this.uuid,childUuid:t.uuid,...q.createFrameUpdateTimestamps()};i||this.saveEvent(h),this.saveChildEvents(t);return}const u=n.find(Boolean);throw u===this?new Error(`Cannot add child node ${t.toString()} to parent node ${this.toString()}. This child already exists on this parent. The child cannot be added again.`):new Error(`Cannot add child node ${t.toString()} to parent node ${this.toString()}. This child already exists on other parent node: ${u?.toString()}}. Remove the child from the other parent first.`)}saveChildEvents(t){t.nodeEvents.forEach(i=>{this.saveEvent(i)}),t.nodeEvents.length=0;for(const i of t.children)this.saveChildEvents(i)}removeAllChildren(){this.children.forEach(t=>this.removeChild(t))}removeChild(t){const i=this.suppressEvents||t.suppressEvents;if(this.children.includes(t))t.parent=void 0,this.children=this.children.filter(u=>u!==t);else throw new Error(`cannot remove node ${t} from parent ${this} because the node is not currently a child of the parent`);const n={type:"NodeRemoveChild",target:this,uuid:this.uuid,childUuid:t.uuid,...q.createFrameUpdateTimestamps()};i||this.saveEvent(n)}removeChildren(t){t.forEach(i=>{if(!this.children.includes(i))throw new Error(`cannot remove node ${i} from parent ${this} because the node is not currently a child of the parent`);this.removeChild(i)})}descendant(t){const i=this.descendants.filter(n=>n.name===t).find(Boolean);if(i===void 0)throw new Error(`descendant with name ${t} not found on parent ${this.toString()}`);return i}get descendants(){function t(n,u){u.push(n),n.children.forEach(h=>t(h,u))}const i=new Array;return this.children.forEach(n=>t(n,i)),i}get ancestors(){function t(n,u){return n.type==at.Scene||!n.parent?u:(u.push(n.parent),t(n.parent,u))}const i=new Array;return t(this,i)}involvedInActionAffectingAppearance(){return this.ancestors.concat(this).flatMap(n=>n.actions).some(n=>n.running&&(n.type===pt.Move||n.type===pt.Scale))}involvedInSceneTransition(){let t;return this.type===at.Scene?t=this:t=this.parentSceneAsNode,t._transitioning}onTapDown(t,i){this.addEventListener(G.TapDown,t,i)}onTapUp(t,i){this.addEventListener(G.TapUp,t,i)}onTapUpAny(t,i){this.addEventListener(G.TapUpAny,t,i)}onTapLeave(t,i){this.addEventListener(G.TapLeave,t,i)}onPointerDown(t,i){this.addEventListener(G.PointerDown,t,i)}onPointerUp(t,i){this.addEventListener(G.PointerUp,t,i)}onPointerMove(t,i){this.addEventListener(G.PointerMove,t,i)}onPointerLeave(t,i){this.addEventListener(G.PointerLeave,t,i)}onDragStart(t,i){this.addEventListener(G.DragStart,t,i)}onDrag(t,i){this.addEventListener(G.Drag,t,i)}onDragEnd(t,i){this.addEventListener(G.DragEnd,t,i)}addEventListener(t,i,n){const u={type:t,nodeUuid:this.uuid,callback:i};n?.replaceExisting&&(this.eventListeners=this.eventListeners.filter(h=>!(h.nodeUuid===u.nodeUuid&&h.type===u.type))),this.eventListeners.push(u)}parseLayoutConstraints(t,i){const n=new Array;return Object.values(Dt).forEach(h=>{if(t[h]!==void 0){let C,F="";if(typeof t[h]=="object")C=t[h];else{const U=t[h];C=i.filter(et=>et.name===U||et.uuid===U).find(Boolean),C||(C=this.game.materializedNodes.filter(et=>et.name===U||et.uuid===U).find(Boolean)),F=`. sibling node named "${U}" has not been added to the game object`}if(C===void 0)throw new Error("could not find sibling node for constraint"+F);const B=new Pn(h,C);n.push(B)}}),n}calculateYFromConstraint(t,i,n,u){let h=t.alterNode.absolutePosition.y;return t.alterNodeMinimum?t.alterNode.type!==at.Scene&&(h=h-t.alterNode.size.height*.5*u):t.alterNode.type!==at.Scene?h=h+t.alterNode.size.height*.5*u:h=h+t.alterNode.size.height*u,t.focalNodeMinimum?(h=h+this.size.height*.5*u,h=h+i*u):(h=h-this.size.height*.5*u,h=h-n*u),h}calculateXFromConstraint(t,i,n,u){let h=t.alterNode.absolutePosition.x;return t.alterNodeMinimum?t.alterNode.type!==at.Scene&&(h=h-t.alterNode.size.width*.5*u):t.alterNode.type!==at.Scene?h=h+t.alterNode.size.width*.5*u:h=h+t.alterNode.size.width*u,t.focalNodeMinimum?(h=h+this.size.width*.5*u,h=h+i*u):(h=h-this.size.width*.5*u,h=h-n*u),h}calculateAbsoluteAlpha(t,i){const n=i.reduce((u,h)=>u*h.alpha,1);return t*n}update(){if(this.needsInitialization&&this.initialize(),this.absoluteAlphaChange=this.calculateAbsoluteAlpha(this.alpha,this.ancestors)-this.absoluteAlpha,this.absoluteAlpha+=this.absoluteAlphaChange,this.parent===void 0)this.absolutePosition.x=this.position.x*this.scale,this.absolutePosition.y=this.position.y*this.scale,this.absoluteScale=this.scale;else if(this.absoluteScale=this.parent.absoluteScale*this.scale,this.layout?.constraints===void 0)this.absolutePosition.x=this.parent.absolutePosition.x+this.position.x*this.parent.absoluteScale,this.absolutePosition.y=this.parent.absolutePosition.y+this.position.y*this.parent.absoluteScale;else{const u=this.layout?.constraints?.horizontalBias??.5,h=this.layout?.constraints?.verticalBias??.5,C=this.layout?.marginTop??0,F=this.layout?.marginBottom??0,B=this.layout?.marginStart??0,U=this.layout?.marginEnd??0,et=this.parseLayoutConstraints(this.layout?.constraints,this.parentSceneAsNode.descendants),ct=this.parent.absoluteScale,ut=et.filter(yt=>yt.verticalConstraint).map(yt=>this.calculateYFromConstraint(yt,C,F,ct));ut.length===0||(ut.length===1?this.absolutePosition.y=ut[0]:ut.length===2&&(this.absolutePosition.y=Math.min(ut[0],ut[1])+h*Math.abs(ut[0]-ut[1])));const At=et.filter(yt=>!yt.verticalConstraint).map(yt=>this.calculateXFromConstraint(yt,B,U,ct));At.length===0||(At.length===1?this.absolutePosition.x=At[0]:At.length===2&&(this.absolutePosition.x=Math.min(At[0],At[1])+u*Math.abs(At[0]-At[1])))}this.actions.forEach(u=>V.evaluateAction(u,this,m2c2Globals.now,m2c2Globals.deltaTime));function t(u,h){const C=new Array;return h===void 0||Object.values(Dt).forEach(B=>{if(h[B]!==void 0){let U,et="";if(typeof h[B]=="object")U=h[B];else{const ct=h[B];let ut;u.type===at.Scene?ut=u.descendants:ut=u.parentSceneAsNode.descendants,U=ut.filter(At=>At.name===ct||At.uuid===ct).find(Boolean),U===void 0&&(U=u.game.materializedNodes.filter(At=>At.name===ct||At.uuid===ct).find(Boolean)),U===void 0&&(et=`. sibling node named "${ct}" has not been added to the game object`)}if(U===void 0)throw new Error("error getting uuid of sibling constraint"+et);U!==u&&C.push(U.uuid)}}),C}const i=new Map;this.children.forEach(u=>{i.set(u.uuid,t(this,u.layout?.constraints))});const n=this.findTopologicalSort(i);if(n.length>0){const u=n.reverse(),h=new Array;u.forEach(C=>{const F=this.children.filter(B=>B.uuid===C).find(Boolean);if(F===void 0)throw new Error("error in dag topological sort");h.push(F)}),h.forEach(C=>C.update())}else this.children.forEach(u=>u.update())}drawChildren(t){this.children.filter(i=>!i.hidden&&i.isDrawable).map(i=>i).sort((i,n)=>i.zPosition-n.zPosition).forEach(i=>i.draw(t))}run(t,i){this.actions.push(t.initialize(i))}removeAction(t){this.actions=this.actions.filter(i=>i.key!==t)}removeAllActions(){for(;this.actions.length;)this.actions.pop()}getNodeOptions(){return{name:this.name,position:this.position,scale:this.scale,alpha:this.alpha,zRotation:this.zRotation,isUserInteractionEnabled:this.isUserInteractionEnabled,draggable:this.draggable,hidden:this.hidden,layout:this.layout,uuid:this.uuid}}getDrawableOptions(){if(!this.isDrawable)throw new Error("getDrawableOptions() called object that is not IDrawable");return{anchorPoint:this.anchorPoint,zPosition:this.zPosition}}getTextOptions(){if(!this.isText)throw new Error("getTextOptions() called object that is not IText");return{text:this.text,fontName:this.fontName,fontColor:this.fontColor,fontSize:this.fontSize}}get canvasKit(){return this.game.canvasKit}get parentSceneAsNode(){if(this.type===at.Scene)throw new Error(`Node ${this} is a scene and cannot have a parent scene`);if(this.parent&&this.parent.type===at.Scene)return this.parent;if(this.parent)return this.parent.parentSceneAsNode;throw new Error(`Node ${this} has not been added to a scene`)}get size(){const t=this;return{get height(){return t._size.height},set height(i){j.value(t._size.height,i)||(t._size.height=i,t.savePropertyChangeEvent("size",t.size))},get width(){return t._size.width},set width(i){j.value(t._size.width,i)||(t._size.width=i,t.savePropertyChangeEvent("size",t.size))}}}set size(t){j.value(this._size.width,t.width)||(this._size=t,this.savePropertyChangeEvent("size",this.size))}get position(){const t=this;return{get x(){return t._position.x},set x(i){j.value(t._position.x,i)||(t._position.x=i,t.savePropertyChangeEvent("position",t.position))},get y(){return t._position.y},set y(i){j.value(t._position.y,i)||(t._position.y=i,t.savePropertyChangeEvent("position",t.position))}}}set position(t){j.value(this._position,t)||(this._position=t,this.savePropertyChangeEvent("position",this.position))}get zRotation(){return this._zRotation}set zRotation(t){j.value(this._zRotation,t)||(this._zRotation=t,this.savePropertyChangeEvent("zRotation",t))}get scale(){return this._scale}set scale(t){j.value(this._scale,t)||(this._scale=t,this.savePropertyChangeEvent("scale",t))}get alpha(){return this._alpha}set alpha(t){j.value(this._alpha,t)||(this._alpha=t,this.savePropertyChangeEvent("alpha",t))}get isUserInteractionEnabled(){return this._isUserInteractionEnabled}set isUserInteractionEnabled(t){j.value(this._isUserInteractionEnabled,t)||(this._isUserInteractionEnabled=t,this.savePropertyChangeEvent("isUserInteractionEnabled",t))}get hidden(){return this._hidden}set hidden(t){j.value(this._hidden,t)||(this._hidden=t,this.savePropertyChangeEvent("hidden",t))}get draggable(){return this._draggable}set draggable(t){j.value(this._draggable,t)||(this._draggable=t,this.savePropertyChangeEvent("draggable",t))}get suppressEvents(){return this._suppressEvents}set suppressEvents(t){this._suppressEvents=t}findTopologicalSort(t){const i=[],n=new Map;t.forEach((h,C)=>{n.has(C)||n.set(C,0),h.forEach(F=>{if(n.has(F)){const B=n.get(F);if(B===void 0)throw new Error(`Could not find inDegree for edge ${F}`);n.set(F,B+1)}else n.set(F,1)})});const u=[];for(n.forEach((h,C)=>{h==0&&u.push(C)});u.length>0;){const h=u.shift();if(h===void 0)throw"current vertex is undefined";i.push(h),t.has(h)&&t.get(h)?.forEach(C=>{const F=n.get(C);if(F===void 0)throw new Error(`Could not find inDegree for edge ${C}`);if(n.has(C)&&F>0){const B=F-1;n.set(C,B),B==0&&u.push(C)}})}return i}}class Xs extends re{constructor(t={}){super(t),this.type=at.Composite,this.compositeType="<compositeType>",this.isDrawable=!0,this._anchorPoint={x:.5,y:.5},this._zPosition=0,Fe(this,t)}initialize(){}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){j.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){j.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){j.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){j.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}dispose(){}update(){super.update()}draw(t){super.drawChildren(t)}handleCompositeEvent(t){}}var bn=(g=>(g[g.MatchConstraint=0]="MatchConstraint",g))(bn||{});const qt={Deferred:"Deferred",Loading:"Loading",Ready:"Ready",Error:"Error"};class or{constructor(t,i){this.images={},this.game=t,this.baseUrls=i,this.canvasKit=t.canvasKit}initializeImages(t){return this.loadImages(t??[])}async loadImages(t){if(t.length===0)return;this.checkImageNamesForDuplicates(t);const i=t.map(n=>{let u=n.url;n.url&&!q.urlHasScheme(n.url)&&(u=q.getUrlFromManifest(this.game,`${this.baseUrls.assets}/${n.url}`)),n.dataUrl&&(u=n.dataUrl);const h={imageName:n.imageName,url:u,originalUrl:u,isFallback:!1,localize:n.localize??!1,svgString:n.svgString,canvaskitImage:void 0,width:n.width,height:n.height,status:n.lazy?qt.Deferred:qt.Loading};return h.localize&&this.configureImageLocalization(h),this.images[n.imageName]=h,h.status===qt.Loading?this.renderM2Image(h):Promise.resolve()});await Promise.all(i)}configureImageLocalization(t){t.fallbackLocalizationUrls=new Array,t.originalUrl&&this.game.i18n?.locale&&(t.status="Deferred",this.game.i18n?.fallbackLocale&&this.game.i18n?.fallbackLocale!==this.game.i18n?.baseLocale&&t.fallbackLocalizationUrls.push(this.localizeImageUrl(t.originalUrl,this.game.i18n.fallbackLocale)),this.game.i18n?.locale===this.game.i18n?.baseLocale?t.url=t.originalUrl:t.url=this.localizeImageUrl(t.originalUrl,this.game.i18n.locale),t.url!==t.originalUrl&&t.fallbackLocalizationUrls.push(t.originalUrl),this.game.i18n.missingLocalizationColor&&!this.missingLocalizationImagePaint&&(this.missingLocalizationImagePaint=Ft.makePaint(this.canvasKit,this.game.i18n.missingLocalizationColor,this.canvasKit.PaintStyle.Stroke,!0),this.missingLocalizationImagePaint.setStrokeWidth(4)))}localizeImageUrl(t,i){const n=t.lastIndexOf(".");if(n===-1)throw new Error("URL does not have an extension");return t.slice(0,n)+`.${i}`+t.slice(n)}reinitializeLocalizedImages(){Object.keys(this.game.imageManager.images).forEach(i=>{const n=this.game.imageManager.images[i];n.localize&&this.game.imageManager.configureImageLocalization(n)}),this.game.nodes.filter(i=>i.type===at.Sprite).forEach(i=>{i.needsInitialization=!0})}checkImageNamesForDuplicates(t){const n=(u=>u.filter((h,C)=>u.indexOf(h)!=C))(t.map(u=>u.imageName));if(n.length>0)throw new Error(`image names must be unique. these image names are duplicated within a game ${this.game.id}: `+n.join(", "))}prepareDeferredImage(t){return t.status=qt.Loading,t.isFallback=!1,this.renderM2Image(t).catch(async()=>{for(t.isFallback=!0;t.fallbackLocalizationUrls?.length;){t.url=t.fallbackLocalizationUrls.shift();try{await this.renderM2Image(t)}catch(i){if(t.fallbackLocalizationUrls.length===0)throw i instanceof Error?i:new Error(`prepareDeferredImage(): unable to render image named ${t.imageName}. image source was ${t.svgString?"svgString":`url: ${t.url}`}`)}}})}renderM2Image(t){const i=document.createElement("img"),n=u=>{if(!this.scratchCanvas||!this.ctx||!this.scale)throw new Error("image manager not set up");this.scratchCanvas.width=t.width*this.scale,this.scratchCanvas.height=t.height*this.scale,this.ctx.scale(this.scale,this.scale),this.ctx.clearRect(0,0,t.width,t.height),this.ctx.drawImage(i,0,0,t.width,t.height),this.scratchCanvas.toBlob(h=>{if(!h)throw new Error(`renderM2Image(): blob is undefined for ${t.imageName}`);h.arrayBuffer().then(C=>{const F=this.canvasKit.MakeImageFromEncoded(C);if(!F)throw new Error(`could not create image with name "${t.imageName}."`);console.log(`image loaded. name: ${t.imageName}, w: ${t.width}, h: ${t.height}`),this.images[t.imageName].canvaskitImage=F,this.images[t.imageName].status=qt.Ready,this.game.nodes.filter(U=>U.type==="Sprite").forEach(U=>{U.imageName===t.imageName&&(U.needsInitialization=!0)}),u()})})};return new Promise((u,h)=>{if(i.width=t.width,i.height=t.height,i.crossOrigin="Anonymous",i.onerror=()=>{h(new Error(`unable to render image named ${t.imageName}. image source was ${t.svgString?"svgString":`url: ${t.url}`}`))},i.onload=()=>{n(u)},!t.svgString&&!t.url)throw new Error(`no svgString or url provided for image named ${t.imageName}`);if(t.svgString&&t.url)throw new Error(`provide svgString or url. both were provided for image named ${t.imageName}`);if(t.svgString){i.src="data:image/svg+xml,"+encodeURIComponent(t.svgString);const C={type:G.BrowserImageDataReady,target:this,imageName:t.imageName,width:t.width,height:t.height,svgString:t.svgString,...q.createFrameUpdateTimestamps()};this.game.eventStore.addEvent(C)}else t.url&&fetch(t.url).then(C=>C.arrayBuffer()).then(C=>{this.arrayBufferToBase64Async(C).then(F=>{const B=this.inferImageSubtypeFromUrl(t.url);i.src="data:image/"+B+";base64,"+F;const U={type:G.BrowserImageDataReady,target:this,imageName:t.imageName,width:t.width,height:t.height,dataUrl:i.src,...q.createFrameUpdateTimestamps()};this.game.eventStore.addEvent(U)})})})}arrayBufferToBase64Async(t){return new Promise((i,n)=>{const u=new FileReader;u.onload=()=>{i(u.result?.toString().split(",")[1]??"")},u.onerror=n,u.readAsDataURL(new Blob([t]))})}inferImageSubtypeFromUrl(t){if(t?.startsWith("data:image/"))return t.split(";")[0].split("/")[1];let i="jpeg";return t?.includes(".")&&(i=t.split(".").pop()?.toLowerCase()??"jpeg",i===""&&(i="jpeg")),i==="svg"&&(i="svg+xml"),i}getImage(t){return this.images[t]}addImage(t){this.images[t.imageName]=t}get scratchCanvas(){if(!this._scratchCanvas){this._scratchCanvas=document.createElement("canvas"),this._scratchCanvas.id=`m2c2kit-scratch-canvas-${this.game.id}-${Math.floor(Math.random()*1e6)}`,this._scratchCanvas.hidden=!0,document.body.appendChild(this._scratchCanvas);const t=this._scratchCanvas.getContext("2d");if(t===null)throw new Error("could not get 2d canvas context from scratch canvas");this.ctx=t,this.scale=window.devicePixelRatio}return this._scratchCanvas}removeScratchCanvas(){this.ctx=void 0,this._scratchCanvas?.remove()}}class xi{constructor(t,i){this.locale="",this.fallbackLocale="en-US",this.baseLocale="en-US",this.game=t,this._translation=this.mergeAdditionalTranslation(i.translation,i.additionalTranslation)??{},this.translation.configuration?.baseLocale&&(this.baseLocale=this.translation.configuration.baseLocale),i.missingLocalizationColor&&(this.missingLocalizationColor=i.missingLocalizationColor),i.locale&&(this.locale=i.locale),i.fallbackLocale&&(this.fallbackLocale=i.fallbackLocale)}async initialize(){await this.configureInitialLocale()}async configureInitialLocale(){if(this.game.hasDataStores()){const t=await this.game.storeGetItem("locale"),i=await this.game.storeGetItem("fallbackLocale");if(typeof t=="string"&&typeof i=="string"){this.locale=t,this.fallbackLocale=i;return}}if(this.locale?.toLowerCase()==="auto"){const t=this.getEnvironmentLocale();t?this.localeTranslationAvailable(t)?(this.locale=t,this.localeTranslationAvailable(this.fallbackLocale)||(this.fallbackLocale=this.baseLocale)):this.fallbackLocale&&this.localeTranslationAvailable(this.fallbackLocale)?(console.warn(`auto locale requested, but detected locale ${t} does not have translation. Setting locale to fallback locale ${this.fallbackLocale}`),this.locale=this.fallbackLocale,this.fallbackLocale=this.baseLocale):(console.warn(`auto locale requested, but detected locale ${t} does not have translation, and fallback locale does not have translation or was not specified (fallback locale is ${this.fallbackLocale}). Setting locale to base locale ${this.baseLocale}.`),this.locale=this.baseLocale,this.fallbackLocale=this.baseLocale):this.fallbackLocale&&this.localeTranslationAvailable(this.fallbackLocale)?(console.warn(`auto locale requested, but environment cannot detect locale. Setting locale to fallback locale ${this.fallbackLocale}`),this.locale=this.fallbackLocale,this.fallbackLocale=this.baseLocale):(console.warn(`auto locale requested, but environment cannot detect locale, and fallback locale does not have translation or was not specified (fallback locale is ${this.fallbackLocale}). Setting locale to base locale ${this.baseLocale}.`),this.locale=this.baseLocale,this.fallbackLocale=this.baseLocale)}else this.locale=this.locale??"",this.fallbackLocale||(this.fallbackLocale=this.baseLocale)}localeTranslationAvailable(t){return this.translation[t]!==void 0||t===this.baseLocale}switchToLocale(t){this.locale=t,this.game.nodes.filter(i=>i.isText).forEach(i=>i.needsInitialization=!0),this.game.imageManager.reinitializeLocalizedImages(),this.game&&this.game.hasDataStores()&&(this.game.storeSetItem("locale",this.locale),this.game.storeSetItem("fallbackLocale",this.fallbackLocale))}getTextLocalization(t,i){let n="",u=!1,h=this.tf(t,i);return h?.text!==void 0?n=h.text:(h=this.tf(t,{useFallbackLocale:!0,...i}),h===void 0||h.text===void 0?n=t:n=h.text,u=!0),{text:n,fontName:h?.fontName,fontNames:h?.fontNames,isFallbackOrMissingTranslation:u}}t(t,i){const{useFallbackLocale:n,...u}=i??{};if(n!==!0){const C=this.translation[this.locale]?.[t];return this.isStringOrTextWithFontCustomization(C)?this.insertInterpolations(this.getKeyText(C),u):void 0}const h=this.translation[this.fallbackLocale]?.[t];if(this.isStringOrTextWithFontCustomization(h))return this.insertInterpolations(this.getKeyText(h),u)}tf(t,i){const{useFallbackLocale:n,...u}=i??{};if(n!==!0){const C=this.translation[this.locale]?.[t];if(this.isStringOrTextWithFontCustomization(C)){const F=this.getKeyTextAndFont(C,this.locale);return F.text&&(F.text=this.insertInterpolations(F.text,u)),F}return}const h=this.translation[this.fallbackLocale]?.[t];if(this.isStringOrTextWithFontCustomization(h)){const C=this.getKeyTextAndFont(h,this.fallbackLocale);return C.text&&(C.text=this.insertInterpolations(C.text,u)),C}}getKeyText(t){return this.isTextWithFontCustomization(t)?t.text:t}getKeyTextAndFont(t,i){let n=new Array;this.isString(this.translation[i]?.fontName)?n.push(this.translation[i].fontName):this.isStringArray(this.translation[i]?.fontName)?n.push(...this.translation[i].fontName):n.push("default");let u;switch(this.isTextWithFontCustomization(t)?(u=t.text,this.isString(t.additionalFontName)&&n.push(t.additionalFontName),this.isStringArray(t.additionalFontName)&&n.push(...t.additionalFontName),t.overrideFontName&&(n.length=0,this.isString(t.overrideFontName)&&n.push(t.overrideFontName),this.isStringArray(t.overrideFontName)&&n.push(...t.overrideFontName))):u=t,n=n.filter(h=>h!=="default"),n.length){case 0:return{text:u};case 1:return{text:u,fontName:n[0]};default:return{text:u,fontNames:n}}}insertInterpolations(t,i){return i?t.replace(/\{\{(.*?)\}\}/g,(n,u)=>{if(Object.prototype.hasOwnProperty.call(i,u))return i[u];throw new Error(`insertInterpolations(): placeholder "${u}" not found. Text was ${t}, provided interpolation was ${JSON.stringify(i)}`)}):t}get translation(){return this._translation}set translation(t){this._translation=t}getEnvironmentLocale(){return(navigator.languages&&navigator.languages.length?navigator.languages[0]:navigator.language)??""}mergeAdditionalTranslation(t,i){if(!t&&!i)return;if(!i)return t;if(!t)return i;const n={},u=new Array;for(const h in t)u.push(h),n[h]={...t[h],...i[h]};for(const h in i)u.includes(h)||(n[h]=i[h]);return n}static makeLocalizationParameters(){return JSON.parse(JSON.stringify({locale:{type:["string","null"],default:null,description:'Locale to use for localization, or "auto" to request from the environment.'},fallback_locale:{type:["string","null"],default:null,description:'Locale to use if requested locale translation is not available, or if "auto" locale was requested and environment cannot provide a locale.'},missing_localization_color:{type:["array","null"],default:null,description:"Font color for strings that are missing translation and outline color for images that are missing localization, [r,g,b,a].",items:{type:"number"}},translation:{type:["object","null"],default:null,description:"Additional translation for localization."}}))}isTextWithFontCustomization(t){return t?.text!==void 0}isStringOrTextWithFontCustomization(t){return typeof t=="string"||this.isTextWithFontCustomization(t)}isStringArray(t){return Array.isArray(t)&&t.every(i=>typeof i=="string")}isString(t){return typeof t=="string"}}const ce={Disabled:"Disabled",Record:"Record",Replay:"Replay"};class An{constructor(){this.events=new Array,this.replayBeginTimestamp=NaN,this.firstTimestamp=NaN,this.replayThoughSequence=Number.MAX_VALUE,this.serializedEventsBeforeReplay="",this.mode=ce.Disabled}serializeEvent(t){const i=t.target;if(t.type===G.NodeNew&&t.nodeOptions?.layout?.constraints!==void 0){const u=t.nodeOptions?.layout?.constraints,h={};for(const F in u){if(F==="horizontalBias"||F==="verticalBias"){h[F]=u[F];continue}const B=u[F];B instanceof re&&(h[F]=B.uuid)}t.target=i.uuid,t.nodeOptions.layout.constraints=h;const C=JSON.stringify(t);return t.target=i,t.nodeOptions.layout.constraints=u,C}if(i instanceof re){t.target=i.uuid;const u=JSON.stringify(t);return t.target=i,u}if(i instanceof Element){t.target=i.nodeName;const u=JSON.stringify(t);return t.target=i,u}if(i instanceof or){t.target="ImageManager";const u=JSON.stringify(t);return t.target=i,u}if(i instanceof xi){t.target="I18n";const u=JSON.stringify(t);return t.target=i,u}t.target="object";const n=JSON.stringify(t);return t.target=i,n}addEvent(t){if(this.mode===ce.Record){t.sequence===void 0&&(t.sequence=m2c2Globals.eventSequence);const i=this.serializeEvent(t);this.events.push(JSON.parse(i))}}addEvents(t){t.forEach(i=>{this.addEvent(i)})}clearEvents(){this.events=[]}record(){this.mode=ce.Record}replay(t){if(t&&(this.events=t),this.events.length===0)if(this.serializedEventsBeforeReplay!=="")this.events=JSON.parse(this.serializedEventsBeforeReplay);else{console.log("Event store has no events to replay.");return}this.mode=ce.Replay,this.replayBeginTimestamp=Wt.now(),this.sortEventStore(this.events),this.serializedEventsBeforeReplay===""&&(this.serializedEventsBeforeReplay=JSON.stringify(this.events)),this.firstTimestamp=this.events[0].timestamp,console.log(`Event store has ${this.events.length} events. Replay beginning.`);const i=document.getElementById("sequence-number");i&&(this.replayThoughSequence=parseInt(i.value))}getEvents(){return this.sortEventStore(this.events),this.events}dequeueEvents(t){const i=new Array,n=t-this.replayBeginTimestamp+this.firstTimestamp;for(;this.events.length>0&&this.events[0].timestamp<=n;){const u=this.events.shift();if(!u)throw new Error("EventStore.dequeueEvents(): undefined event");u.sequence!==void 0&&u.sequence>this.replayThoughSequence||i.push(u)}return i}get eventQueueLength(){return this.events.length}sortEventStore(t){t.sort((i,n)=>{if(i.sequence===void 0||n.sequence===void 0)throw new Error("EventStore.sortEventStore(): undefined sequence");return i.sequence!==n.sequence?i.sequence-n.sequence:0})}}var ze=(g=>(g[g.Center=0]="Center",g[g.Left=1]="Left",g[g.Right=2]="Right",g))(ze||{});const Xt={Deferred:"Deferred",Loading:"Loading",Ready:"Ready",Error:"Error"};class ki extends re{constructor(t={}){super(t),this.type=at.Label,this.isDrawable=!0,this.isText=!0,this._anchorPoint={x:.5,y:.5},this._zPosition=0,this._text="",this._fontColor=X.DEFAULT_FONT_COLOR,this._fontSize=X.DEFAULT_FONT_SIZE,this._interpolation={},this._horizontalAlignmentMode=ze.Center,this._localize=!0,this.localizedFontNames=[],Fe(this,t),t.horizontalAlignmentMode&&(this.horizontalAlignmentMode=t.horizontalAlignmentMode),t.preferredMaxLayoutWidth!==void 0&&(this.preferredMaxLayoutWidth=t.preferredMaxLayoutWidth),t.backgroundColor&&(this.backgroundColor=t.backgroundColor),t.fontNames&&(this.fontNames=t.fontNames),this.saveNodeNewEvent()}get completeNodeOptions(){return{...this.options,...this.getNodeOptions(),...this.getDrawableOptions(),...this.getTextOptions(),horizontalAlignmentMode:this.horizontalAlignmentMode,preferredMaxLayoutWidth:this.preferredMaxLayoutWidth,backgroundColor:this.backgroundColor,fontNames:this.fontNames}}initialize(){let t=this.canvasKit.TextAlign.Center;switch(this.horizontalAlignmentMode){case ze.Center:t=this.canvasKit.TextAlign.Center;break;case ze.Left:t=this.canvasKit.TextAlign.Left;break;case ze.Right:t=this.canvasKit.TextAlign.Right;break;default:throw new Error("unknown horizontalAlignmentMode")}this.text||(this.text="");let i=this.canvasKit.Color(this.fontColor[0],this.fontColor[1],this.fontColor[2],this.fontColor[3]),n;const u=this.game.i18n;if(u&&this.localize!==!1){const U=u.getTextLocalization(this.text,this.interpolation);n=U.text,this.localizedFontName=U.fontName,this.localizedFontNames=U.fontNames??[],U.isFallbackOrMissingTranslation&&u.missingLocalizationColor&&(i=this.canvasKit.Color(u.missingLocalizationColor[0],u.missingLocalizationColor[1],u.missingLocalizationColor[2],u.missingLocalizationColor[3]))}else n=this.text;if(this.fontName&&this.fontNames)throw new Error("cannot specify both fontName and fontNames");const h=this.game.fontManager,C=this.getRequiredLabelFonts(h);if(C.forEach(U=>{if(U.status===Xt.Deferred){h.prepareDeferredFont(U);return}}),!C.every(U=>U.status===Xt.Ready))return;this.paraStyle=new this.canvasKit.ParagraphStyle({textStyle:{},textAlign:t}),this.builder&&this.builder.delete(),this.builder=this.canvasKit.ParagraphBuilder.MakeFromFontProvider(this.paraStyle,h.provider),this._backgroundPaint||(this._backgroundPaint=new this.canvasKit.Paint),this._fontPaint||(this._fontPaint=new this.canvasKit.Paint),this.fontPaint.setColor(i),this.fontPaint.setAlphaf(this.absoluteAlpha),this.backgroundColor?(this.backgroundPaint.setColor(this.backgroundColor),this.backgroundPaint.setAlphaf(this.absoluteAlpha)):this.backgroundPaint.setColor(this.canvasKit.Color(0,0,0,0)),this.builder.pushPaintStyle({fontFamilies:C.map(U=>U.fontName),fontSize:this.fontSize*m2c2Globals.canvasScale,fontStyle:{weight:this.canvasKit.FontWeight.Normal,width:this.canvasKit.FontWidth.Normal,slant:this.canvasKit.FontSlant.Oblique},decoration:0,decorationThickness:1,decorationStyle:this.canvasKit.DecorationStyle.Solid,heightMultiplier:-1,halfLeading:!1,letterSpacing:0,wordSpacing:0},this.fontPaint,this.backgroundPaint),this.builder.addText(n),this.paragraph&&this.paragraph.delete(),this.paragraph=this.builder.build();const F=this.preferredMaxLayoutWidth??m2c2Globals.canvasCssWidth;let B=F;if(F===0||this.layout.width===0){if(this.parent===void 0)throw new Error("width is set to match parent, but node has no parent");const U=this.layout.marginStart??0,et=this.layout.marginEnd??0;B=this.parent.size.width-(U+et)}this.paragraph.layout(B*m2c2Globals.canvasScale),F===0||this.layout.width===0?this.size.width=B:(this.paragraph.layout(Math.ceil(this.paragraph.getLongestLine())),this.size.width=this.paragraph.getMaxWidth()/m2c2Globals.canvasScale),this.size.height=this.paragraph.getHeight()/m2c2Globals.canvasScale,this.needsInitialization=!1}getRequiredLabelFonts(t){let i;if(this.game.i18n&&this.localize!==!1){if(this.localizedFontName)return i=[t.fonts[this.localizedFontName]],i;if(this.localizedFontNames.length>0)return i=this.localizedFontNames.map(n=>t.fonts[n]),i}if(this.fontName===void 0&&this.fontNames===void 0)i=[t.getDefaultFont()];else if(this.fontName!==void 0)i=[t.fonts[this.fontName]];else if(this.fontNames!==void 0&&this.fontNames.length>0)i=this.fontNames.map(n=>t.fonts[n]);else throw new Error("cannot determine required fonts");return i}dispose(){Ft.Dispose([this.paragraph,this.builder,this._fontPaint,this._backgroundPaint])}get text(){return this._text}set text(t){j.value(this._text,t)||(this._text=t,this.needsInitialization=!0,this.savePropertyChangeEvent("text",t))}get interpolation(){return this._interpolation}set interpolation(t){j.value(this._interpolation,t)||(this._interpolation=t,Object.freeze(this._interpolation),this.needsInitialization=!0,this.savePropertyChangeEvent("interpolation",t))}get fontName(){return this._fontName}set fontName(t){j.value(this._fontName,t)||(this._fontName=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontName",t))}get fontNames(){return this._fontNames}set fontNames(t){j.value(this._fontNames,t)||(this._fontNames=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontNames",t))}get fontColor(){return this._fontColor}set fontColor(t){j.value(this._fontColor,t)||(this._fontColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontColor",t))}get fontSize(){return this._fontSize}set fontSize(t){j.value(this._fontSize,t)||(this._fontSize=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontSize",t))}get horizontalAlignmentMode(){return this._horizontalAlignmentMode}set horizontalAlignmentMode(t){j.value(this._horizontalAlignmentMode,t)||(this._horizontalAlignmentMode=t,this.needsInitialization=!0,this.savePropertyChangeEvent("horizontalAlignmentMode",t))}get preferredMaxLayoutWidth(){return this._preferredMaxLayoutWidth}set preferredMaxLayoutWidth(t){j.value(this._preferredMaxLayoutWidth,t)||(this._preferredMaxLayoutWidth=t,this.needsInitialization=!0,this.savePropertyChangeEvent("preferredMaxLayoutWidth",t))}get backgroundColor(){return this._backgroundColor}set backgroundColor(t){j.value(this._backgroundColor,t)||(this._backgroundColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("backgroundColor",t))}get localize(){return this._localize}set localize(t){j.value(this._localize,t)||(this._localize=t,this.needsInitialization=!0,this.savePropertyChangeEvent("localize",t))}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){j.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){j.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){j.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){j.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}get backgroundPaint(){if(!this._backgroundPaint)throw new Error("backgroundPaint cannot be undefined");return this._backgroundPaint}set backgroundPaint(t){this._backgroundPaint=t}get fontPaint(){if(!this._fontPaint)throw new Error("fontPaint cannot be undefined");return this._fontPaint}set fontPaint(t){this._fontPaint=t}duplicate(t){const i=new ki({...this.getNodeOptions(),...this.getDrawableOptions(),...this.getTextOptions(),horizontalAlignmentMode:this.horizontalAlignmentMode,preferredMaxLayoutWidth:this.preferredMaxLayoutWidth,backgroundColor:this.backgroundColor,name:t});return this.children.length>0&&(i.children=this.children.map(n=>{const u=n.duplicate();return u.parent=i,u})),i}update(){super.update(),this.absoluteAlphaChange!==0&&this.initialize()}draw(t){if(this.parent&&this.text!==""&&!this.needsInitialization){t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;t.scale(1/i,1/i),q.rotateCanvasForDrawableNode(t,this);const n=(this.absolutePosition.x-this.size.width*this.anchorPoint.x*this.absoluteScale)*i,u=(this.absolutePosition.y-this.size.height*this.anchorPoint.y*this.absoluteScale)*i;if(this.paragraph===void 0)throw new Error("no paragraph");t.drawParagraph(this.paragraph,n,u),t.restore()}super.drawChildren(t)}warmup(t){const i=this.game.i18n;if(i&&this.localize!==!1){const u=i.getTextLocalization(this.text,this.interpolation);this.localizedFontName=u.fontName,this.localizedFontNames=u.fontNames??[]}if(!this.getRequiredLabelFonts(this.game.fontManager).some(u=>u.status===Xt.Deferred)&&Object.keys(this.layout).length===0){if(this.initialize(),!this.paragraph)throw new Error(`warmup Label node ${this.toString()}: paragraph is undefined`);t.drawParagraph(this.paragraph,0,0)}}}class Ue extends re{constructor(t={}){super(t),this.type=at.Scene,this.isDrawable=!0,this._anchorPoint={x:0,y:0},this._zPosition=0,this._backgroundColor=X.DEFAULT_SCENE_BACKGROUND_COLOR,this._active=!1,this._transitioning=!1,Fe(this,t),t.backgroundColor&&(this.backgroundColor=t.backgroundColor),this.saveNodeNewEvent()}get completeNodeOptions(){return{...this.options,...this.getNodeOptions(),...this.getDrawableOptions(),backgroundColor:this.backgroundColor}}initialize(){this.scale=m2c2Globals.rootScale,this.size.width=this.game.canvasCssWidth,this.size.height=this.game.canvasCssHeight,this.backgroundPaint&&this.backgroundPaint.delete(),this.backgroundPaint=Ft.makePaint(this.canvasKit,this.backgroundColor,this.canvasKit.PaintStyle.Fill,!1),this.needsInitialization=!1}dispose(){Ft.Dispose([this.backgroundPaint])}set game(t){this._game=t}get game(){if(this._game===void 0)throw new Error(`Scene ${this} has not been added to a game.`);return this._game}get backgroundColor(){return this._backgroundColor}set backgroundColor(t){j.value(this._backgroundColor,t)||(this._backgroundColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("backgroundColor",t))}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){j.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){j.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){j.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){j.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}duplicate(t){const i=new Ue({...this.getNodeOptions(),...this.getDrawableOptions(),backgroundColor:this.backgroundColor,name:t});return i.game=this.game,this.children.length>0&&(i.children=this.children.map(n=>{const u=n.duplicate();return u.parent=i,u})),i}onSetup(t,i){this.addEventListener("SceneSetup",t,i)}onAppear(t,i){this.addEventListener("SceneAppear",t,i)}update(){super.update()}draw(t){t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;if(t.scale(1/i,1/i),q.rotateCanvasForDrawableNode(t,this),!this.backgroundPaint)throw new Error(`in Scene ${this}, background paint is undefined.`);this.absoluteAlphaChange!==0&&this.backgroundPaint.setAlphaf(this.absoluteAlpha),t.drawRect([this.position.x*i*m2c2Globals.rootScale,this.position.y*i*m2c2Globals.rootScale,(this.position.x+this.size.width)*i*m2c2Globals.rootScale,(this.position.y+this.size.height)*i*m2c2Globals.rootScale],this.backgroundPaint),t.restore(),super.drawChildren(t)}warmup(t){this.initialize(),t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;if(t.scale(1/i,1/i),!this.backgroundPaint)throw new Error(`in Scene ${this}, background paint is undefined.`);t.drawRect([this.position.x*i*m2c2Globals.rootScale,this.position.y*i*m2c2Globals.rootScale,(this.position.x+this.size.width)*i*m2c2Globals.rootScale,(this.position.y+this.size.height)*i*m2c2Globals.rootScale],this.backgroundPaint),t.restore(),this.children.forEach(n=>{n.isDrawable&&n.warmup(t)})}}class ai extends re{constructor(t={}){if(super(t),this.type=at.Shape,this.isDrawable=!0,this.isShape=!0,this._anchorPoint={x:.5,y:.5},this._zPosition=0,this.shapeType=Ut.Undefined,this.ckPath=null,this._cornerRadius=0,this._fillColor=X.DEFAULT_SHAPE_FILL_COLOR,this._isAntialiased=!0,this.svgPathScaleForResizing=1,this.svgPathWidth=0,this.svgPathHeight=0,this.svgPreviousAbsoluteX=NaN,this.svgPreviousAbsoluteY=NaN,this.svgFirstPathDraw=!0,this.colorfulPathPaints=new Map,Fe(this,t),t.path!==void 0){if(this.path=t.path,this.shapeType=Ut.Path,this.shapeIsM2Path()&&t.size!==void 0&&(this.size=t.size),this.shapeIsSvgStringPath()&&t.size!==void 0)throw new Error("Size cannot be specified when path is SVG string path");if(this.svgPathRequestedWidth=t.path.width,this.svgPathRequestedHeight=t.path.height,this.svgPathRequestedHeight!==void 0&&this.svgPathRequestedWidth!==void 0)throw new Error("Cannot specify both width and height for SVG string path.");if(this.strokeColor||(this.strokeColor=X.DEFAULT_PATH_STROKE_COLOR),this.lineWidth===void 0&&(this.lineWidth=X.DEFAULT_PATH_LINE_WIDTH),t.circleOfRadius||t.rect)throw new Error("Shape must specify only one of: path, circleOfRadius, or rect")}if(t.circleOfRadius!==void 0){if(this.circleOfRadius=t.circleOfRadius,this.shapeType=Ut.Circle,t.size!==void 0)throw new Error("Size cannot be specified for circle shape");if(t.path||t.rect)throw new Error("Shape must specify only one of: path, circleOfRadius, or rect");this.size.width=this.circleOfRadius*2,this.size.height=this.circleOfRadius*2}if(t.rect&&(this.rect=t.rect,t.rect.size?(this.size.width=t.rect.size.width,this.size.height=t.rect.size.height):t.rect.width!==void 0&&t.rect.height!==void 0&&(this.size.width=t.rect.width,this.size.height=t.rect.height),t.rect.origin?this.position=t.rect.origin:t.rect.x!==void 0&&t.rect.y!==void 0&&(this.position={x:t.rect.x,y:t.rect.y}),this.shapeType=Ut.Rectangle,t.size!==void 0))throw new Error("Size cannot be specified for rectangle shape");t.cornerRadius!==void 0&&(this.cornerRadius=t.cornerRadius),t.fillColor&&(this.fillColor=t.fillColor),t.strokeColor&&(this.strokeColor=t.strokeColor),t.lineWidth!==void 0&&(this.lineWidth=t.lineWidth),t.isAntialiased!==void 0&&(this.isAntialiased=t.isAntialiased),t.strokeColor&&!t.lineWidth&&console.warn(`warning: for node ${this}, strokeColor = ${t.strokeColor} but lineWidth is non-zero. In normal usage, both would be set or both would be undefined.`),t.strokeColor===void 0&&t.lineWidth&&console.warn(`warning: for node ${this}, lineWidth = ${t.lineWidth} but strokeColor is undefined. In normal usage, both would be set or both would be undefined.`),this.saveNodeNewEvent()}get completeNodeOptions(){let t;return this.shapeIsM2Path()&&(t=this.size),{...this.options,...this.getNodeOptions(),...this.getDrawableOptions(),circleOfRadius:this.circleOfRadius,rect:this.rect,cornerRadius:this.cornerRadius,fillColor:this.fillColor,strokeColor:this.strokeColor,lineWidth:this.lineWidth,path:this.path,size:t,isAntialiased:this.isAntialiased}}initialize(){if(this.shapeType===Ut.Path&&this.shapeIsSvgStringPath()){const t=this.path.pathString??this.path.svgPathString;if(!t)throw new Error("SVG Path string is null/undefined");if(this.path.svgPathString!==void 0&&console.warn("warning: svgPathString is deprecated. Use pathString instead."),this.ckPath=this.canvasKit.Path.MakeFromSVGString(t),!this.ckPath)throw new Error("could not make CanvasKit Path from SVG string");const i=this.ckPath.getBounds();this.svgPathWidth=i[2]+(i[0]<0?Math.abs(i[0]):0),this.svgPathHeight=i[3]+(i[1]<0?Math.abs(i[1]):0),this.svgPathRequestedHeight!==void 0?this.svgPathScaleForResizing=this.svgPathRequestedHeight/this.svgPathHeight:this.svgPathRequestedWidth!==void 0&&(this.svgPathScaleForResizing=this.svgPathRequestedWidth/this.svgPathWidth),this.size.width=this.svgPathWidth*this.svgPathScaleForResizing,this.size.height=this.svgPathHeight*this.svgPathScaleForResizing,this.svgPreviousAbsoluteX=0,this.svgPreviousAbsoluteY=0}if(this.shapeIsM2Path()&&(this.size.width===0||this.size.height===0||this.size.width===void 0||this.size.height===void 0))throw new Error("Size of shape must have non-zero height and width when path is M2Path");this.fillColor&&(this.fillColorPaintAntialiased=Ft.makePaint(this.canvasKit,this.fillColor,this.canvasKit.PaintStyle.Fill,!0),this.fillColorPaintNotAntialiased=Ft.makePaint(this.canvasKit,this.fillColor,this.canvasKit.PaintStyle.Fill,!1)),this.strokeColor&&(this.strokeColorPaintAntialiased=Ft.makePaint(this.canvasKit,this.strokeColor,this.canvasKit.PaintStyle.Stroke,!0),this.strokeColorPaintNotAntialiased=Ft.makePaint(this.canvasKit,this.strokeColor,this.canvasKit.PaintStyle.Stroke,!1)),this.svgFirstPathDraw=!0,this.needsInitialization=!1}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){j.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){j.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){j.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){j.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}dispose(){Ft.Dispose([this._strokeColorPaintAntialiased,this._strokeColorPaintNotAntialiased,this._fillColorPaintAntialiased,this._fillColorPaintNotAntialiased,this.ckPath,...Array.from(this.colorfulPathPaints.values())])}duplicate(t){const i=new ai({...this.getNodeOptions(),...this.getDrawableOptions(),shapeType:this.shapeType,circleOfRadius:this.circleOfRadius,rect:this.rect,cornerRadius:this.cornerRadius,fillColor:this.fillColor,strokeColor:this.strokeColor,lineWidth:this.lineWidth,name:t});return this.children.length>0&&(i.children=this.children.map(n=>{const u=n.duplicate();return u.parent=i,u})),i}update(){super.update()}draw(t){t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;t.scale(1/i,1/i),q.rotateCanvasForDrawableNode(t,this),this.absoluteAlphaChange!==0&&this.applyAlphaToPaints(this.absoluteAlpha,[this._fillColorPaintAntialiased,this._fillColorPaintNotAntialiased,this._strokeColorPaintAntialiased,this._strokeColorPaintNotAntialiased]),this.shapeIsM2Path()&&this.drawPathFromM2Path(t),this.shapeIsSvgStringPath()&&this.drawPathFromSvgString(t),this.shapeType===Ut.Circle&&this.drawCircle(t),this.shapeType===Ut.Rectangle&&this.drawRectangle(t),t.restore(),super.drawChildren(t)}applyAlphaToPaints(t,i){i.forEach(n=>{n&&n.setAlphaf(t)})}drawPathFromM2Path(t){const i=m2c2Globals.canvasScale/this.absoluteScale,n=(this.absolutePosition.x-this.anchorPoint.x*this.size.width*this.absoluteScale)*i,u=(this.absolutePosition.y-this.anchorPoint.y*this.size.height*this.absoluteScale)*i;if(this.pathIsM2ColorfulPath(this.path)){const h=this.path.linePresentations;let C=0;const F=this.path.subpaths;let B;for(let U=0;U<F.length;U++){const ct=F[U].flat();for(let ut=0;ut<ct.length-1;ut++){if(h[C].subpathIndex===U&&h[C].pointIndex===ut){const At=h[C].strokeColor,yt=h[C].lineWidth,ne=[...At,yt].toString();B=this.colorfulPathPaints.get(ne),B===void 0&&(B=Ft.makePaint(this.canvasKit,At,this.canvasKit.PaintStyle.Stroke,!0),B.setStrokeWidth(yt*m2c2Globals.canvasScale),this.colorfulPathPaints.set(ne,B)),C<h.length-1&&C++}if(B===void 0)throw new Error("paint is undefined");t.drawLine(n+ct[ut].x*m2c2Globals.canvasScale,u+ct[ut].y*m2c2Globals.canvasScale,n+ct[ut+1].x*m2c2Globals.canvasScale,u+ct[ut+1].y*m2c2Globals.canvasScale,B)}}return}if(this.strokeColor&&this.strokeColorPaintAntialiased&&this.lineWidth){this.strokeColorPaintAntialiased.setStrokeWidth(this.lineWidth*m2c2Globals.canvasScale);const h=this.path.subpaths;for(const C of h){const F=C.flat();for(let B=0;B<F.length-1;B++)t.drawLine(n+F[B].x*m2c2Globals.canvasScale,u+F[B].y*m2c2Globals.canvasScale,n+F[B+1].x*m2c2Globals.canvasScale,u+F[B+1].y*m2c2Globals.canvasScale,this.strokeColorPaintAntialiased)}}}drawPathFromSvgString(t){if(!this.ckPath)return;const i=this.calculateSvgPathX(),n=this.calculateSvgPathY();if(this.pathNeedsTransform(i,n)){const h=m2c2Globals.canvasScale/this.absoluteScale*this.svgPathScaleForResizing*m2c2Globals.rootScale,C=this.calculateTransformationMatrix(h,i,n);this.ckPath=this.ckPath.transform(C),this.saveSvgPathAbsolutePosition(i,n)}if(this.fillColor){const u=this.getFillPaint();t.drawPath(this.ckPath,u)}if(this.strokeColor&&this.lineWidth){const u=this.getStrokePaint(this.lineWidth);t.drawPath(this.ckPath,u)}}calculateSvgPathY(){const t=m2c2Globals.canvasScale/this.absoluteScale;return(this.absolutePosition.y-this.size.height*this.absoluteScale/2)*t}calculateSvgPathX(){const t=m2c2Globals.canvasScale/this.absoluteScale;return(this.absolutePosition.x-this.size.width*this.absoluteScale/2)*t}saveSvgPathAbsolutePosition(t,i){this.svgPreviousAbsoluteX=t,this.svgPreviousAbsoluteY=i}calculateTransformationMatrix(t,i,n){let u;this.svgFirstPathDraw?(u=t,this.svgFirstPathDraw=!1):u=1;const h=i-this.svgPreviousAbsoluteX,C=n-this.svgPreviousAbsoluteY;return[u,0,h,0,u,C,0,0,1]}pathNeedsTransform(t,i){return this.svgFirstPathDraw===!0||t!==this.svgPreviousAbsoluteX||i!==this.svgPreviousAbsoluteY}shapeIsSvgStringPath(){return this.path?.pathString!==void 0||this.path?.svgPathString!==void 0}shapeIsM2Path(){return this.path?.subpaths!==void 0}pathIsM2ColorfulPath(t){return t!==void 0&&"linePresentations"in t}drawCircle(t){if(this.circleOfRadius){if(this.fillColor){const i=this.getFillPaint();this.drawCircleWithCanvasKit(t,i)}if(this.strokeColor&&this.lineWidth){const i=this.getStrokePaint(this.lineWidth);this.drawCircleWithCanvasKit(t,i)}}}drawRectangle(t){if(this.fillColor){const i=this.getFillPaint();this.drawRectangleWithCanvasKit(t,i)}if(this.strokeColor&&this.lineWidth){const i=this.getStrokePaint(this.lineWidth);this.drawRectangleWithCanvasKit(t,i)}}drawCircleWithCanvasKit(t,i){if(!this.circleOfRadius)return;const n=m2c2Globals.canvasScale/this.absoluteScale,u=this.absolutePosition.x*n,h=this.absolutePosition.y*n,C=this.circleOfRadius*this.absoluteScale*n;t.drawCircle(u,h,C,i)}drawRectangleWithCanvasKit(t,i){const n=this.calculateCKRoundedRectangle();t.drawRRect(n,i)}calculateCKRoundedRectangle(){const t=m2c2Globals.canvasScale/this.absoluteScale;return this.canvasKit.RRectXY(this.canvasKit.LTRBRect((this.absolutePosition.x-this.anchorPoint.x*this.size.width*this.absoluteScale)*t,(this.absolutePosition.y-this.anchorPoint.y*this.size.height*this.absoluteScale)*t,(this.absolutePosition.x+this.size.width*this.absoluteScale-this.anchorPoint.x*this.size.width*this.absoluteScale)*t,(this.absolutePosition.y+this.size.height*this.absoluteScale-this.anchorPoint.y*this.size.height*this.absoluteScale)*t),this.cornerRadius*t,this.cornerRadius*t)}getFillPaint(){return this.involvedInActionAffectingAppearance()?this.fillColorPaintNotAntialiased:this.isAntialiased?this.fillColorPaintAntialiased:this.fillColorPaintNotAntialiased}getStrokePaint(t){let i;this.involvedInActionAffectingAppearance()?i=this.strokeColorPaintNotAntialiased:i=this.isAntialiased?this.strokeColorPaintAntialiased:this.strokeColorPaintNotAntialiased;const n=m2c2Globals.canvasScale/this.absoluteScale;return i.setStrokeWidth(t*n),i}warmup(t){this.initialize(),t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;t.scale(1/i,1/i),this.shapeType===Ut.Circle&&(this.fillColor&&this.warmupFilledCircle(t),this.strokeColor&&this.lineWidth&&this.warmupStrokedCircle(t)),this.shapeType===Ut.Rectangle&&(this.fillColor&&this.warmupFilledRectangle(t),this.strokeColor&&this.lineWidth&&this.warmupStrokedRectangle(t)),t.restore(),this.children.forEach(n=>{n.isDrawable&&n.warmup(t)})}warmupFilledCircle(t){this.circleOfRadius&&(this.drawCircleWithCanvasKit(t,this.fillColorPaintAntialiased),this.drawCircleWithCanvasKit(t,this.fillColorPaintNotAntialiased))}warmupStrokedCircle(t){if(!this.lineWidth||!this.circleOfRadius)return;const i=m2c2Globals.canvasScale/this.absoluteScale;this.strokeColorPaintAntialiased.setStrokeWidth(this.lineWidth*i),this.drawCircleWithCanvasKit(t,this.strokeColorPaintAntialiased),this.strokeColorPaintNotAntialiased.setStrokeWidth(this.lineWidth*i),this.drawCircleWithCanvasKit(t,this.strokeColorPaintNotAntialiased)}warmupFilledRectangle(t){this.drawRectangleWithCanvasKit(t,this.fillColorPaintAntialiased),this.drawRectangleWithCanvasKit(t,this.fillColorPaintNotAntialiased)}warmupStrokedRectangle(t){if(!this.lineWidth||!this.circleOfRadius)return;const i=m2c2Globals.canvasScale/this.absoluteScale;this.strokeColorPaintAntialiased.setStrokeWidth(this.lineWidth*i),this.drawRectangleWithCanvasKit(t,this.strokeColorPaintAntialiased),this.strokeColorPaintNotAntialiased.setStrokeWidth(this.lineWidth*i),this.drawRectangleWithCanvasKit(t,this.strokeColorPaintNotAntialiased)}get circleOfRadius(){return this._circleOfRadius}set circleOfRadius(t){j.value(t,this._circleOfRadius)||(this._circleOfRadius=t,this.needsInitialization=!0,this.savePropertyChangeEvent("circleOfRadius",t))}get rect(){return this._rect}set rect(t){j.value(t,this._rect)||(this._rect=t,this.needsInitialization=!0,this.savePropertyChangeEvent("rect",t))}get cornerRadius(){return this._cornerRadius}set cornerRadius(t){j.value(t,this._cornerRadius)||(this._cornerRadius=t??0,this.needsInitialization=!0,this.savePropertyChangeEvent("cornerRadius",t??0))}get lineWidth(){return this._lineWidth}set lineWidth(t){j.value(t,this._lineWidth)||(this._lineWidth=t,this.needsInitialization=!0,this.savePropertyChangeEvent("lineWidth",t))}get path(){return this._path}set path(t){j.value(t,this._path)||(this._path=t,this.needsInitialization=!0,this.savePropertyChangeEvent("path",t))}get fillColor(){return this._fillColor}set fillColor(t){j.value(t,this._fillColor)||(this._fillColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fillColor",t))}get strokeColor(){return this._strokeColor}set strokeColor(t){j.value(t,this._strokeColor)||(this._strokeColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("strokeColor",t))}get isAntialiased(){return this._isAntialiased}set isAntialiased(t){j.value(t,this._isAntialiased)||(this._isAntialiased=t,this.needsInitialization=!0,this.savePropertyChangeEvent("isAntialiased",t))}get fillColorPaintAntialiased(){if(!this._fillColorPaintAntialiased)throw new Error("fillColorPaintAntiAliased is undefined");return this._fillColorPaintAntialiased}set fillColorPaintAntialiased(t){this._fillColorPaintAntialiased=t}get strokeColorPaintAntialiased(){if(!this._strokeColorPaintAntialiased)throw new Error("strokeColorPaintAntiAliased is undefined");return this._strokeColorPaintAntialiased}set strokeColorPaintAntialiased(t){this._strokeColorPaintAntialiased=t}get fillColorPaintNotAntialiased(){if(!this._fillColorPaintNotAntialiased)throw new Error("fillColorPaintNotAntiAliased is undefined");return this._fillColorPaintNotAntialiased}set fillColorPaintNotAntialiased(t){this._fillColorPaintNotAntialiased=t}get strokeColorPaintNotAntialiased(){if(!this._strokeColorPaintNotAntialiased)throw new Error("strokeColorPaintNotAntiAliased is undefined");return this._strokeColorPaintNotAntialiased}set strokeColorPaintNotAntialiased(t){this._strokeColorPaintNotAntialiased=t}}class Oi extends re{constructor(t={}){super(t),this.type=at.TextLine,this.isDrawable=!0,this.isText=!0,this._zPosition=0,this._anchorPoint={x:0,y:.5},this._text="",this._fontColor=X.DEFAULT_FONT_COLOR,this._fontSize=X.DEFAULT_FONT_SIZE,this._interpolation={},this._localize=!0,this.typeface=null,this.tryMissingTranslationPaint=!1,this.textForDraw="",this.localizedFontNames=[],Fe(this,t),this.size.height=this.fontSize,this.size.width=t.width??NaN,this.saveNodeNewEvent()}get completeNodeOptions(){return{...this.options,...this.getNodeOptions(),...this.getDrawableOptions(),...this.getTextOptions(),width:this.size.width}}initialize(){const t=this.game.i18n;if(this.tryMissingTranslationPaint=!1,t&&this.localize!==!1){const n=t.getTextLocalization(this.text,this.interpolation);this.textForDraw=n.text,this.localizedFontName=n.fontName,this.localizedFontNames=n.fontNames??[],n.isFallbackOrMissingTranslation&&(this.tryMissingTranslationPaint=!0)}else this.textForDraw=this.text;const i=this.game.fontManager;if(this.fontForDraw=this.getRequiredTextLineFont(i),this.fontForDraw.status===Xt.Deferred){i.prepareDeferredFont(this.fontForDraw);return}this.fontForDraw.status!==Xt.Loading&&(this.createFontPaint(t),this.createFont(i),this.needsInitialization=!1)}getRequiredTextLineFont(t){if(this.game.i18n){if(this.localizedFontName!==void 0&&this.localizedFontNames.length!==0||this.localizedFontNames.length>1)throw new Error("TextLine supports only one font, but multiple fonts are specified in translation.");if(this.localizedFontName!==void 0)return t.fonts[this.localizedFontName];if(this.localizedFontNames.length==1)return t.fonts[this.localizedFontNames[0]]}return this.fontName===void 0?t.getDefaultFont():t.getFont(this.fontName)}createFontPaint(t){this.paint&&this.paint.delete(),this.paint=new this.canvasKit.Paint,this.tryMissingTranslationPaint&&this.localize!==!1?t?.missingLocalizationColor&&this.paint.setColor(this.canvasKit.Color(t.missingLocalizationColor[0],t.missingLocalizationColor[1],t.missingLocalizationColor[2],t.missingLocalizationColor[3])):this.paint.setColor(this.canvasKit.Color(this.fontColor[0],this.fontColor[1],this.fontColor[2],this.fontColor[3])),this.paint.setStyle(this.canvasKit.PaintStyle.Fill),this.paint.setAntiAlias(!0)}createFont(t){if(this.fontForDraw)this.typeface=t.getTypeface(this.fontForDraw.fontName);else{const i=t.getFontNames();i.length>0&&(this.typeface=t.getTypeface(i[0]))}this.font&&this.font.delete(),this.font=new this.canvasKit.Font(this.typeface,this.fontSize*m2c2Globals.canvasScale)}get text(){return this._text}set text(t){j.value(this._text,t)||(this._text=t,this.needsInitialization=!0,this.savePropertyChangeEvent("text",t))}get fontName(){return this._fontName}set fontName(t){j.value(this._fontName,t)||(this._fontName=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontName",t))}get fontColor(){return this._fontColor}set fontColor(t){j.value(this._fontColor,t)||(this._fontColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontColor",t))}get fontSize(){return this._fontSize}set fontSize(t){j.value(this._fontSize,t)||(this._fontSize=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontSize",t))}get interpolation(){return this._interpolation}set interpolation(t){j.value(this._interpolation,t)||(this._interpolation=t,Object.freeze(this._interpolation),this.needsInitialization=!0,this.savePropertyChangeEvent("interpolation",t))}get localize(){return this._localize}set localize(t){j.value(this._localize,t)||(this._localize=t,this.needsInitialization=!0,this.savePropertyChangeEvent("localize",t))}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){j.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){j.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){j.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){j.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}dispose(){Ft.Dispose([this.font,this.typeface,this.paint])}duplicate(t){const i=new Oi({...this.getNodeOptions(),...this.getDrawableOptions(),...this.getTextOptions(),width:this.size.width,name:t});return this.children.length>0&&(i.children=this.children.map(n=>{const u=n.duplicate();return u.parent=i,u})),i}update(){super.update()}draw(t){if(this.parent&&this.text&&!this.needsInitialization){t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;t.scale(1/i,1/i),q.rotateCanvasForDrawableNode(t,this);const n=this.absolutePosition.x*i,u=(this.absolutePosition.y+this.size.height*this.anchorPoint.y*this.absoluteScale)*i;if(this.paint===void 0||this.font===void 0)throw new Error(`in TextLine node ${this}, Paint or Font is undefined.`);this.absoluteAlphaChange!==0&&this.paint.setAlphaf(this.absoluteAlpha),t.drawText(this.textForDraw,n,u,this.paint,this.font),t.restore()}super.drawChildren(t)}warmup(t){const i=this.game.i18n;if(i&&this.localize!==!1){const u=i.getTextLocalization(this.text,this.interpolation);this.localizedFontName=u.fontName,this.localizedFontNames=u.fontNames??[]}if(this.getRequiredTextLineFont(this.game.fontManager).status!==Xt.Deferred){if(this.initialize(),this.paint===void 0||this.font===void 0)throw new Error(`warmup TextLine node ${this.toString()}: Paint or Font is undefined.`);t.drawText(this.text,0,0,this.paint,this.font)}}}class oi extends re{constructor(t={}){super(t),this.type=at.Sprite,this.isDrawable=!0,this._anchorPoint={x:.5,y:.5},this._zPosition=0,this._imageName="",Fe(this,t),t.imageName!==void 0&&(this.imageName=t.imageName),this.saveNodeNewEvent()}get completeNodeOptions(){return{...this.options,...this.getNodeOptions(),...this.getDrawableOptions(),imageName:this.imageName}}initialize(){if(this.m2Image=this.game.imageManager.getImage(this._imageName),!this.m2Image)throw new Error(`could not create sprite. the image named ${this._imageName} has not been loaded`);this.size.width=this.m2Image.width,this.size.height=this.m2Image.height,this._paint||(this.paint=new this.canvasKit.Paint),this.needsInitialization=!1}dispose(){Ft.Dispose([this.m2Image?.canvaskitImage,this._paint])}get imageName(){return this._imageName}set imageName(t){j.value(this._imageName,t)||(this._imageName=t,this.needsInitialization=!0)}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){j.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){j.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){j.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){j.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}set paint(t){this._paint=t}get paint(){if(!this._paint)throw new Error(`in paint getter: Sprite node ${this.toString()} paint is undefined.`);return this._paint}duplicate(t){const i=new oi({...this.getNodeOptions(),...this.getDrawableOptions(),imageName:this.imageName,name:t});return this.children.length>0&&(i.children=this.children.map(n=>{const u=n.duplicate();return u.parent=i,u})),i}update(){super.update()}draw(t){if(!this.hidden){if(this.m2Image){t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;t.scale(1/i,1/i),q.rotateCanvasForDrawableNode(t,this);const n=(this.absolutePosition.x-this.size.width*this.anchorPoint.x*this.absoluteScale)*i,u=(this.absolutePosition.y-this.size.height*this.anchorPoint.y*this.absoluteScale)*i;if(this.absoluteAlphaChange!==0&&this.paint.setAlphaf(this.absoluteAlpha),this.m2Image.status===qt.Ready&&this.m2Image.canvaskitImage)this.m2Image.isFallback&&this.drawFallbackImageBorder(t),t.drawImage(this.m2Image.canvaskitImage,n,u,this.paint);else if(this.m2Image.status===qt.Deferred&&(console.log(`begin loading lazy image ${this.m2Image.imageName} for Sprite node ${this.toString()}`),this.game.imageManager.prepareDeferredImage(this.m2Image)),this.m2Image.status===qt.Error)throw new Error(`error status on image ${this.m2Image.imageName} for Sprite node ${this.toString()}`);t.restore()}super.drawChildren(t)}}warmup(t){if(this.m2Image?.status===qt.Ready){if(this.initialize(),!this.m2Image)throw new Error(`in Sprite.warmup(): Sprite node ${this.toString()}: image not loaded.`);if(!this.m2Image.canvaskitImage)throw new Error(`in Sprite.warmup(): Sprite node ${this.toString()} image ${this.m2Image.imageName} is undefined.`);t.drawImage(this.m2Image.canvaskitImage,0,0)}this.children.forEach(i=>{i.isDrawable&&i.warmup(t)})}drawFallbackImageBorder(t){const i=this.game.imageManager.missingLocalizationImagePaint;if(!i)return;const n=m2c2Globals.canvasScale/this.absoluteScale,u=this.canvasKit.RRectXY(this.canvasKit.LTRBRect((this.absolutePosition.x-this.anchorPoint.x*this.size.width*this.absoluteScale)*n,(this.absolutePosition.y-this.anchorPoint.y*this.size.height*this.absoluteScale)*n,(this.absolutePosition.x+this.size.width*this.absoluteScale-this.anchorPoint.x*this.size.width*this.absoluteScale)*n,(this.absolutePosition.y+this.size.height*this.absoluteScale-this.anchorPoint.y*this.size.height*this.absoluteScale)*n),0,0);t.drawRRect(u,i)}}class Cn{constructor(){q.registerM2NodeClass(ki,ai,oi,Ue,Oi)}createNode(t,i,n){const u=i||t;if(!this.hasClassRegistration(u))throw new Error(`Unknown node type: ${u}`);if(!m2c2Globals.m2NodeClassRegistry)throw new Error("Node class registry is not initialized.");const h=m2c2Globals.m2NodeClassRegistry[u];return new h(n)}hasClassRegistration(t){return Object.keys(m2c2Globals.m2NodeClassRegistry??{}).includes(t)}}class Js{static rgbaColor(t,i){return!t||!i?!1:t[0]===i[0]&&t[1]===i[1]&&t[2]===i[2]&&t[3]===i[3]}}class _n{constructor(t,i){this.fonts={},this.game=t,this.baseUrls=i,this.canvasKit=t.canvasKit,this.provider=this.canvasKit.TypefaceFontProvider.Make()}initializeFonts(t){return this.loadFonts(t??[])}async loadFonts(t){if(t.length===0)return;const i=t.map((n,u)=>{let h=n.url;q.urlHasScheme(n.url)||(h=q.getUrlFromManifest(this.game,`${this.baseUrls.assets}/${n.url}`));const C={fontName:n.fontName,typeface:void 0,data:n.sharedFont?.data,default:u===0,url:n.sharedFont?.url??h,status:n.lazy?Xt.Deferred:Xt.Loading};if(this.fonts[n.fontName]=C,C.status===Xt.Loading)return this.prepareFont(C)});await Promise.all(i)}async prepareFont(t){const i=t.data??await this.fetchFontAsArrayBuffer(t);this.registerFont(i,t),console.log(`\u26AA font ${t.fontName}${t.default?" (default)":""} loaded for game ${this.game.id} from ${t.url}`)}async prepareDeferredFont(t){return t.status=Xt.Loading,this.prepareFont(t)}async fetchFontAsArrayBuffer(t){const i=await fetch(t.url);if(!i.ok)throw new Error(`cannot fetch font ${t.fontName} at url ${t.url}: ${i.statusText}`);return await i.arrayBuffer()}registerFont(t,i){this.provider.registerFont(t,i.fontName);const n=this.canvasKit.Typeface.MakeFreeTypeFaceFromData(t);if(!n)throw new Error(`cannot make typeface for font ${i.fontName} at url ${i.url}`);i.typeface=n,i.status=Xt.Ready}getFont(t){return this.fonts[t]}getDefaultFont(){const t=Object.values(this.fonts).find(i=>i.default);if(!t)throw new Error("no default font found; please make sure at least one font is loaded");return t}dispose(){const t=Object.entries(this.fonts).map(([,i])=>i.typeface);Ft.Dispose([...t,this.provider])}getTypeface(t){const i=this.fonts[t]?.typeface;if(!i)throw new Error(`font ${t} not found`);return i}getFontNames(){return Object.keys(this.fonts)}}var lr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Qs(g){return g&&g.__esModule&&Object.prototype.hasOwnProperty.call(g,"default")?g.default:g}function En(g){if(g.__esModule)return g;var t=g.default;if(typeof t=="function"){var i=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};i.prototype=t.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(g).forEach(function(n){var u=Object.getOwnPropertyDescriptor(g,n);Object.defineProperty(i,n,u.get?u:{enumerable:!0,get:function(){return g[n]}})}),i}var Tn={exports:{}},Zs={},ta=Object.freeze({__proto__:null,default:Zs}),ea=En(ta);function Fn(g,t){for(var i=0,n=g.length-1;n>=0;n--){var u=g[n];u==="."?g.splice(n,1):u===".."?(g.splice(n,1),i++):i&&(g.splice(n,1),i--)}if(t)for(;i--;i)g.unshift("..");return g}var ia=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,hr=function(g){return ia.exec(g).slice(1)};function Ri(){for(var g="",t=!1,i=arguments.length-1;i>=-1&&!t;i--){var n=i>=0?arguments[i]:"/";if(typeof n!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!n)continue;g=n+"/"+g,t=n.charAt(0)==="/"}return g=Fn(dr(g.split("/"),function(u){return!!u}),!t).join("/"),(t?"/":"")+g||"."}function cr(g){var t=ur(g),i=na(g,-1)==="/";return g=Fn(dr(g.split("/"),function(n){return!!n}),!t).join("/"),!g&&!t&&(g="."),g&&i&&(g+="/"),(t?"/":"")+g}function ur(g){return g.charAt(0)==="/"}function Mn(){var g=Array.prototype.slice.call(arguments,0);return cr(dr(g,function(t,i){if(typeof t!="string")throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))}function xn(g,t){g=Ri(g).substr(1),t=Ri(t).substr(1);function i(U){for(var et=0;et<U.length&&U[et]==="";et++);for(var ct=U.length-1;ct>=0&&U[ct]==="";ct--);return et>ct?[]:U.slice(et,ct-et+1)}for(var n=i(g.split("/")),u=i(t.split("/")),h=Math.min(n.length,u.length),C=h,F=0;F<h;F++)if(n[F]!==u[F]){C=F;break}for(var B=[],F=C;F<n.length;F++)B.push("..");return B=B.concat(u.slice(C)),B.join("/")}var Rn="/",Nn=":";function kn(g){var t=hr(g),i=t[0],n=t[1];return!i&&!n?".":(n&&(n=n.substr(0,n.length-1)),i+n)}function On(g,t){var i=hr(g)[2];return t&&i.substr(-1*t.length)===t&&(i=i.substr(0,i.length-t.length)),i}function In(g){return hr(g)[3]}var ra={extname:In,basename:On,dirname:kn,sep:Rn,delimiter:Nn,relative:xn,join:Mn,isAbsolute:ur,normalize:cr,resolve:Ri};function dr(g,t){if(g.filter)return g.filter(t);for(var i=[],n=0;n<g.length;n++)t(g[n],n,g)&&i.push(g[n]);return i}var na="ab".substr(-1)==="b"?function(g,t,i){return g.substr(t,i)}:function(g,t,i){return t<0&&(t=g.length+t),g.substr(t,i)},sa=Object.freeze({__proto__:null,basename:On,default:ra,delimiter:Nn,dirname:kn,extname:In,isAbsolute:ur,join:Mn,normalize:cr,relative:xn,resolve:Ri,sep:Rn}),aa=En(sa);(function(g,t){var i=(()=>{var n=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<"u"&&(n=n||__filename),function(u={}){var h=u,C,F;h.ready=new Promise((e,r)=>{C=e,F=r}),function(e){e.Td=e.Td||[],e.Td.push(function(){e.MakeSWCanvasSurface=function(r){var s=r,l=typeof OffscreenCanvas<"u"&&s instanceof OffscreenCanvas;if(!(typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||l||(s=document.getElementById(r),s)))throw"Canvas with id "+r+" was not found";return(r=e.MakeSurface(s.width,s.height))&&(r.Ld=s),r},e.MakeCanvasSurface||(e.MakeCanvasSurface=e.MakeSWCanvasSurface),e.MakeSurface=function(r,s){var l={width:r,height:s,colorType:e.ColorType.RGBA_8888,alphaType:e.AlphaType.Unpremul,colorSpace:e.ColorSpace.SRGB},d=r*s*4,m=e._malloc(d);return(l=e.Surface._makeRasterDirect(l,m,4*r))&&(l.Ld=null,l.Hf=r,l.Df=s,l.Ff=d,l.bf=m,l.getCanvas().clear(e.TRANSPARENT)),l},e.MakeRasterDirectSurface=function(r,s,l){return e.Surface._makeRasterDirect(r,s.byteOffset,l)},e.Surface.prototype.flush=function(r){if(e.Md(this.Kd),this._flush(),this.Ld){var s=new Uint8ClampedArray(e.HEAPU8.buffer,this.bf,this.Ff);s=new ImageData(s,this.Hf,this.Df),r?this.Ld.getContext("2d").putImageData(s,0,0,r[0],r[1],r[2]-r[0],r[3]-r[1]):this.Ld.getContext("2d").putImageData(s,0,0)}},e.Surface.prototype.dispose=function(){this.bf&&e._free(this.bf),this.delete()},e.Md=e.Md||function(){},e.Te=e.Te||function(){return null}})}(h),function(e){e.Td=e.Td||[],e.Td.push(function(){function r(v,y,A){return v&&v.hasOwnProperty(y)?v[y]:A}function s(v){var y=Oe(Kt);return Kt[y]=v,y}function l(v){return v.naturalHeight||v.videoHeight||v.displayHeight||v.height}function d(v){return v.naturalWidth||v.videoWidth||v.displayWidth||v.width}function m(v,y,A,O){return v.bindTexture(v.TEXTURE_2D,y),O||A.alphaType!==e.AlphaType.Premul||v.pixelStorei(v.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),y}function b(v,y,A){A||y.alphaType!==e.AlphaType.Premul||v.pixelStorei(v.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),v.bindTexture(v.TEXTURE_2D,null)}e.GetWebGLContext=function(v,y){if(!v)throw"null canvas passed into makeWebGLContext";var A={alpha:r(y,"alpha",1),depth:r(y,"depth",1),stencil:r(y,"stencil",8),antialias:r(y,"antialias",0),premultipliedAlpha:r(y,"premultipliedAlpha",1),preserveDrawingBuffer:r(y,"preserveDrawingBuffer",0),preferLowPowerToHighPerformance:r(y,"preferLowPowerToHighPerformance",0),failIfMajorPerformanceCaveat:r(y,"failIfMajorPerformanceCaveat",0),enableExtensionsByDefault:r(y,"enableExtensionsByDefault",1),explicitSwapControl:r(y,"explicitSwapControl",0),renderViaOffscreenBackBuffer:r(y,"renderViaOffscreenBackBuffer",0)};if(A.majorVersion=y&&y.majorVersion?y.majorVersion:typeof WebGL2RenderingContext<"u"?2:1,A.explicitSwapControl)throw"explicitSwapControl is not supported";return v=ws(v,A),v?(jr(v),it.fe.getExtension("WEBGL_debug_renderer_info"),v):0},e.deleteContext=function(v){it===le[v]&&(it=null),typeof JSEvents=="object"&&JSEvents.ug(le[v].fe.canvas),le[v]&&le[v].fe.canvas&&(le[v].fe.canvas.zf=void 0),le[v]=null},e._setTextureCleanup({deleteTexture:function(v,y){var A=Kt[y];A&&le[v].fe.deleteTexture(A),Kt[y]=null}}),e.MakeWebGLContext=function(v){if(!this.Md(v))return null;var y=this._MakeGrContext();if(!y)return null;y.Kd=v;var A=y.delete.bind(y);return y.delete=function(){e.Md(this.Kd),A()}.bind(y),it.ff=y},e.MakeGrContext=e.MakeWebGLContext,e.GrDirectContext.prototype.getResourceCacheLimitBytes=function(){e.Md(this.Kd),this._getResourceCacheLimitBytes()},e.GrDirectContext.prototype.getResourceCacheUsageBytes=function(){e.Md(this.Kd),this._getResourceCacheUsageBytes()},e.GrDirectContext.prototype.releaseResourcesAndAbandonContext=function(){e.Md(this.Kd),this._releaseResourcesAndAbandonContext()},e.GrDirectContext.prototype.setResourceCacheLimitBytes=function(v){e.Md(this.Kd),this._setResourceCacheLimitBytes(v)},e.MakeOnScreenGLSurface=function(v,y,A,O,D,H){return!this.Md(v.Kd)||(y=D===void 0||H===void 0?this._MakeOnScreenGLSurface(v,y,A,O):this._MakeOnScreenGLSurface(v,y,A,O,D,H),!y)?null:(y.Kd=v.Kd,y)},e.MakeRenderTarget=function(){var v=arguments[0];if(!this.Md(v.Kd))return null;if(arguments.length===3){var y=this._MakeRenderTargetWH(v,arguments[1],arguments[2]);if(!y)return null}else if(arguments.length===2){if(y=this._MakeRenderTargetII(v,arguments[1]),!y)return null}else return null;return y.Kd=v.Kd,y},e.MakeWebGLCanvasSurface=function(v,y,A){y=y||null;var O=v,D=typeof OffscreenCanvas<"u"&&O instanceof OffscreenCanvas;if(!(typeof HTMLCanvasElement<"u"&&O instanceof HTMLCanvasElement||D||(O=document.getElementById(v),O)))throw"Canvas with id "+v+" was not found";if(v=this.GetWebGLContext(O,A),!v||0>v)throw"failed to create webgl context: err "+v;return v=this.MakeWebGLContext(v),y=this.MakeOnScreenGLSurface(v,O.width,O.height,y),y||(y=O.cloneNode(!0),O.parentNode.replaceChild(y,O),y.classList.add("ck-replaced"),e.MakeSWCanvasSurface(y))},e.MakeCanvasSurface=e.MakeWebGLCanvasSurface,e.Surface.prototype.makeImageFromTexture=function(v,y){return e.Md(this.Kd),v=s(v),(y=this._makeImageFromTexture(this.Kd,v,y))&&(y.Le=v),y},e.Surface.prototype.makeImageFromTextureSource=function(v,y,A){y||(y={height:l(v),width:d(v),colorType:e.ColorType.RGBA_8888,alphaType:A?e.AlphaType.Premul:e.AlphaType.Unpremul}),y.colorSpace||(y.colorSpace=e.ColorSpace.SRGB),e.Md(this.Kd);var O=it.fe;return A=m(O,O.createTexture(),y,A),it.version===2?O.texImage2D(O.TEXTURE_2D,0,O.RGBA,y.width,y.height,0,O.RGBA,O.UNSIGNED_BYTE,v):O.texImage2D(O.TEXTURE_2D,0,O.RGBA,O.RGBA,O.UNSIGNED_BYTE,v),b(O,y),this._resetContext(),this.makeImageFromTexture(A,y)},e.Surface.prototype.updateTextureFromSource=function(v,y,A){if(v.Le){e.Md(this.Kd);var O=v.getImageInfo(),D=it.fe,H=m(D,Kt[v.Le],O,A);it.version===2?D.texImage2D(D.TEXTURE_2D,0,D.RGBA,d(y),l(y),0,D.RGBA,D.UNSIGNED_BYTE,y):D.texImage2D(D.TEXTURE_2D,0,D.RGBA,D.RGBA,D.UNSIGNED_BYTE,y),b(D,O,A),this._resetContext(),Kt[v.Le]=null,v.Le=s(H),O.colorSpace=v.getColorSpace(),y=this._makeImageFromTexture(this.Kd,v.Le,O),A=v.Jd.Rd,D=v.Jd.Yd,v.Jd.Rd=y.Jd.Rd,v.Jd.Yd=y.Jd.Yd,y.Jd.Rd=A,y.Jd.Yd=D,y.delete(),O.colorSpace.delete()}},e.MakeLazyImageFromTextureSource=function(v,y,A){y||(y={height:l(v),width:d(v),colorType:e.ColorType.RGBA_8888,alphaType:A?e.AlphaType.Premul:e.AlphaType.Unpremul}),y.colorSpace||(y.colorSpace=e.ColorSpace.SRGB);var O={makeTexture:function(){var D=it,H=D.fe,T=m(H,H.createTexture(),y,A);return D.version===2?H.texImage2D(H.TEXTURE_2D,0,H.RGBA,y.width,y.height,0,H.RGBA,H.UNSIGNED_BYTE,v):H.texImage2D(H.TEXTURE_2D,0,H.RGBA,H.RGBA,H.UNSIGNED_BYTE,v),b(H,y,A),s(T)},freeSrc:function(){}};return v.constructor.name==="VideoFrame"&&(O.freeSrc=function(){v.close()}),e.Image._makeFromGenerator(y,O)},e.Md=function(v){return v?jr(v):!1},e.Te=function(){return it&&it.ff&&!it.ff.isDeleted()?it.ff:null}})}(h),function(e){function r(o,a,c,p,P){for(var E=0;E<o.length;E++)a[E*c+(E*P+p+c)%c]=o[E];return a}function s(o){for(var a=o*o,c=Array(a);a--;)c[a]=a%(o+1)===0?1:0;return c}function l(o){return o?o.constructor===Float32Array&&o.length===4:!1}function d(o){return(v(255*o[3])<<24|v(255*o[0])<<16|v(255*o[1])<<8|v(255*o[2])<<0)>>>0}function m(o){if(o&&o._ck)return o;if(o instanceof Float32Array){for(var a=Math.floor(o.length/4),c=new Uint32Array(a),p=0;p<a;p++)c[p]=d(o.slice(4*p,4*(p+1)));return c}if(o instanceof Uint32Array)return o;if(o instanceof Array&&o[0]instanceof Float32Array)return o.map(d)}function b(o){if(o===void 0)return 1;var a=parseFloat(o);return o&&o.indexOf("%")!==-1?a/100:a}function v(o){return Math.round(Math.max(0,Math.min(o||0,255)))}function y(o,a){a&&a._ck||e._free(o)}function A(o,a,c){if(!o||!o.length)return ht;if(o&&o._ck)return o.byteOffset;var p=e[a].BYTES_PER_ELEMENT;return c||(c=e._malloc(o.length*p)),e[a].set(o,c/p),c}function O(o){var a={be:ht,count:o.length,colorType:e.ColorType.RGBA_F32};if(o instanceof Float32Array)a.be=A(o,"HEAPF32"),a.count=o.length/4;else if(o instanceof Uint32Array)a.be=A(o,"HEAPU32"),a.colorType=e.ColorType.RGBA_8888;else if(o instanceof Array){if(o&&o.length){for(var c=e._malloc(16*o.length),p=0,P=c/4,E=0;E<o.length;E++)for(var N=0;4>N;N++)e.HEAPF32[P+p]=o[E][N],p++;o=c}else o=ht;a.be=o}else throw"Invalid argument to copyFlexibleColorArray, Not a color array "+typeof o;return a}function D(o){if(!o)return ht;var a=Qi.toTypedArray();if(o.length){if(o.length===6||o.length===9)return A(o,"HEAPF32",ye),o.length===6&&e.HEAPF32.set(Gs,6+ye/4),ye;if(o.length===16)return a[0]=o[0],a[1]=o[1],a[2]=o[3],a[3]=o[4],a[4]=o[5],a[5]=o[7],a[6]=o[12],a[7]=o[13],a[8]=o[15],ye;throw"invalid matrix size"}if(o.m11===void 0)throw"invalid matrix argument";return a[0]=o.m11,a[1]=o.m21,a[2]=o.m41,a[3]=o.m12,a[4]=o.m22,a[5]=o.m42,a[6]=o.m14,a[7]=o.m24,a[8]=o.m44,ye}function H(o){if(!o)return ht;var a=Zi.toTypedArray();if(o.length){if(o.length!==16&&o.length!==6&&o.length!==9)throw"invalid matrix size";return o.length===16?A(o,"HEAPF32",Le):(a.fill(0),a[0]=o[0],a[1]=o[1],a[3]=o[2],a[4]=o[3],a[5]=o[4],a[7]=o[5],a[10]=1,a[12]=o[6],a[13]=o[7],a[15]=o[8],o.length===6&&(a[12]=0,a[13]=0,a[15]=1),Le)}if(o.m11===void 0)throw"invalid matrix argument";return a[0]=o.m11,a[1]=o.m21,a[2]=o.m31,a[3]=o.m41,a[4]=o.m12,a[5]=o.m22,a[6]=o.m32,a[7]=o.m42,a[8]=o.m13,a[9]=o.m23,a[10]=o.m33,a[11]=o.m43,a[12]=o.m14,a[13]=o.m24,a[14]=o.m34,a[15]=o.m44,Le}function T(o,a){return A(o,"HEAPF32",a||Ee)}function Y(o,a,c,p){var P=tr.toTypedArray();return P[0]=o,P[1]=a,P[2]=c,P[3]=p,Ee}function nt(o){for(var a=new Float32Array(4),c=0;4>c;c++)a[c]=e.HEAPF32[o/4+c];return a}function rt(o,a){return A(o,"HEAPF32",a||Et)}function Bt(o,a){return A(o,"HEAPF32",a||rr)}function Rt(){for(var o=0,a=0;a<arguments.length-1;a+=2)o+=arguments[a]*arguments[a+1];return o}function ti(o,a,c){for(var p=Array(o.length),P=0;P<c;P++)for(var E=0;E<c;E++){for(var N=0,W=0;W<c;W++)N+=o[c*P+W]*a[c*W+E];p[P*c+E]=N}return p}function ei(o,a){for(var c=ti(a[0],a[1],o),p=2;p<a.length;)c=ti(c,a[p],o),p++;return c}e.Color=function(o,a,c,p){return p===void 0&&(p=1),e.Color4f(v(o)/255,v(a)/255,v(c)/255,p)},e.ColorAsInt=function(o,a,c,p){return p===void 0&&(p=255),(v(p)<<24|v(o)<<16|v(a)<<8|v(c)<<0&268435455)>>>0},e.Color4f=function(o,a,c,p){return p===void 0&&(p=1),Float32Array.of(o,a,c,p)},Object.defineProperty(e,"TRANSPARENT",{get:function(){return e.Color4f(0,0,0,0)}}),Object.defineProperty(e,"BLACK",{get:function(){return e.Color4f(0,0,0,1)}}),Object.defineProperty(e,"WHITE",{get:function(){return e.Color4f(1,1,1,1)}}),Object.defineProperty(e,"RED",{get:function(){return e.Color4f(1,0,0,1)}}),Object.defineProperty(e,"GREEN",{get:function(){return e.Color4f(0,1,0,1)}}),Object.defineProperty(e,"BLUE",{get:function(){return e.Color4f(0,0,1,1)}}),Object.defineProperty(e,"YELLOW",{get:function(){return e.Color4f(1,1,0,1)}}),Object.defineProperty(e,"CYAN",{get:function(){return e.Color4f(0,1,1,1)}}),Object.defineProperty(e,"MAGENTA",{get:function(){return e.Color4f(1,0,1,1)}}),e.getColorComponents=function(o){return[Math.floor(255*o[0]),Math.floor(255*o[1]),Math.floor(255*o[2]),o[3]]},e.parseColorString=function(o,a){if(o=o.toLowerCase(),o.startsWith("#")){switch(a=255,o.length){case 9:a=parseInt(o.slice(7,9),16);case 7:var c=parseInt(o.slice(1,3),16),p=parseInt(o.slice(3,5),16),P=parseInt(o.slice(5,7),16);break;case 5:a=17*parseInt(o.slice(4,5),16);case 4:c=17*parseInt(o.slice(1,2),16),p=17*parseInt(o.slice(2,3),16),P=17*parseInt(o.slice(3,4),16)}return e.Color(c,p,P,a/255)}return o.startsWith("rgba")?(o=o.slice(5,-1),o=o.split(","),e.Color(+o[0],+o[1],+o[2],b(o[3]))):o.startsWith("rgb")?(o=o.slice(4,-1),o=o.split(","),e.Color(+o[0],+o[1],+o[2],b(o[3]))):o.startsWith("gray(")||o.startsWith("hsl")||!a||(o=a[o],o===void 0)?e.BLACK:o},e.multiplyByAlpha=function(o,a){return o=o.slice(),o[3]=Math.max(0,Math.min(o[3]*a,1)),o},e.Malloc=function(o,a){var c=e._malloc(a*o.BYTES_PER_ELEMENT);return{_ck:!0,length:a,byteOffset:c,qe:null,subarray:function(p,P){return p=this.toTypedArray().subarray(p,P),p._ck=!0,p},toTypedArray:function(){return this.qe&&this.qe.length?this.qe:(this.qe=new o(e.HEAPU8.buffer,c,a),this.qe._ck=!0,this.qe)}}},e.Free=function(o){e._free(o.byteOffset),o.byteOffset=ht,o.toTypedArray=null,o.qe=null};var ye=ht,Qi,Le=ht,Zi,Ee=ht,tr,ie,Et=ht,nn,we=ht,sn,er=ht,an,ir=ht,Fi,ii=ht,on,rr=ht,ln,hn=ht,Gs=Float32Array.of(0,0,1),ht=0;e.onRuntimeInitialized=function(){function o(a,c,p,P,E,N,W){N||(N=4*P.width,P.colorType===e.ColorType.RGBA_F16?N*=2:P.colorType===e.ColorType.RGBA_F32&&(N*=4));var Q=N*P.height,J=E?E.byteOffset:e._malloc(Q);if(W?!a._readPixels(P,J,N,c,p,W):!a._readPixels(P,J,N,c,p))return E||e._free(J),null;if(E)return E.toTypedArray();switch(P.colorType){case e.ColorType.RGBA_8888:case e.ColorType.RGBA_F16:a=new Uint8Array(e.HEAPU8.buffer,J,Q).slice();break;case e.ColorType.RGBA_F32:a=new Float32Array(e.HEAPU8.buffer,J,Q).slice();break;default:return null}return e._free(J),a}tr=e.Malloc(Float32Array,4),Ee=tr.byteOffset,Zi=e.Malloc(Float32Array,16),Le=Zi.byteOffset,Qi=e.Malloc(Float32Array,9),ye=Qi.byteOffset,on=e.Malloc(Float32Array,12),rr=on.byteOffset,ln=e.Malloc(Float32Array,12),hn=ln.byteOffset,ie=e.Malloc(Float32Array,4),Et=ie.byteOffset,nn=e.Malloc(Float32Array,4),we=nn.byteOffset,sn=e.Malloc(Float32Array,3),er=sn.byteOffset,an=e.Malloc(Float32Array,3),ir=an.byteOffset,Fi=e.Malloc(Int32Array,4),ii=Fi.byteOffset,e.ColorSpace.SRGB=e.ColorSpace._MakeSRGB(),e.ColorSpace.DISPLAY_P3=e.ColorSpace._MakeDisplayP3(),e.ColorSpace.ADOBE_RGB=e.ColorSpace._MakeAdobeRGB(),e.GlyphRunFlags={IsWhiteSpace:e._GlyphRunFlags_isWhiteSpace},e.Path.MakeFromCmds=function(a){var c=A(a,"HEAPF32"),p=e.Path._MakeFromCmds(c,a.length);return y(c,a),p},e.Path.MakeFromVerbsPointsWeights=function(a,c,p){var P=A(a,"HEAPU8"),E=A(c,"HEAPF32"),N=A(p,"HEAPF32"),W=e.Path._MakeFromVerbsPointsWeights(P,a.length,E,c.length,N,p&&p.length||0);return y(P,a),y(E,c),y(N,p),W},e.Path.prototype.addArc=function(a,c,p){return a=rt(a),this._addArc(a,c,p),this},e.Path.prototype.addCircle=function(a,c,p,P){return this._addCircle(a,c,p,!!P),this},e.Path.prototype.addOval=function(a,c,p){return p===void 0&&(p=1),a=rt(a),this._addOval(a,!!c,p),this},e.Path.prototype.addPath=function(){var a=Array.prototype.slice.call(arguments),c=a[0],p=!1;if(typeof a[a.length-1]=="boolean"&&(p=a.pop()),a.length===1)this._addPath(c,1,0,0,0,1,0,0,0,1,p);else if(a.length===2)a=a[1],this._addPath(c,a[0],a[1],a[2],a[3],a[4],a[5],a[6]||0,a[7]||0,a[8]||1,p);else if(a.length===7||a.length===10)this._addPath(c,a[1],a[2],a[3],a[4],a[5],a[6],a[7]||0,a[8]||0,a[9]||1,p);else return null;return this},e.Path.prototype.addPoly=function(a,c){var p=A(a,"HEAPF32");return this._addPoly(p,a.length/2,c),y(p,a),this},e.Path.prototype.addRect=function(a,c){return a=rt(a),this._addRect(a,!!c),this},e.Path.prototype.addRRect=function(a,c){return a=Bt(a),this._addRRect(a,!!c),this},e.Path.prototype.addVerbsPointsWeights=function(a,c,p){var P=A(a,"HEAPU8"),E=A(c,"HEAPF32"),N=A(p,"HEAPF32");this._addVerbsPointsWeights(P,a.length,E,c.length,N,p&&p.length||0),y(P,a),y(E,c),y(N,p)},e.Path.prototype.arc=function(a,c,p,P,E,N){return a=e.LTRBRect(a-p,c-p,a+p,c+p),E=(E-P)/Math.PI*180-360*!!N,N=new e.Path,N.addArc(a,P/Math.PI*180,E),this.addPath(N,!0),N.delete(),this},e.Path.prototype.arcToOval=function(a,c,p,P){return a=rt(a),this._arcToOval(a,c,p,P),this},e.Path.prototype.arcToRotated=function(a,c,p,P,E,N,W){return this._arcToRotated(a,c,p,!!P,!!E,N,W),this},e.Path.prototype.arcToTangent=function(a,c,p,P,E){return this._arcToTangent(a,c,p,P,E),this},e.Path.prototype.close=function(){return this._close(),this},e.Path.prototype.conicTo=function(a,c,p,P,E){return this._conicTo(a,c,p,P,E),this},e.Path.prototype.computeTightBounds=function(a){this._computeTightBounds(Et);var c=ie.toTypedArray();return a?(a.set(c),a):c.slice()},e.Path.prototype.cubicTo=function(a,c,p,P,E,N){return this._cubicTo(a,c,p,P,E,N),this},e.Path.prototype.dash=function(a,c,p){return this._dash(a,c,p)?this:null},e.Path.prototype.getBounds=function(a){this._getBounds(Et);var c=ie.toTypedArray();return a?(a.set(c),a):c.slice()},e.Path.prototype.lineTo=function(a,c){return this._lineTo(a,c),this},e.Path.prototype.moveTo=function(a,c){return this._moveTo(a,c),this},e.Path.prototype.offset=function(a,c){return this._transform(1,0,a,0,1,c,0,0,1),this},e.Path.prototype.quadTo=function(a,c,p,P){return this._quadTo(a,c,p,P),this},e.Path.prototype.rArcTo=function(a,c,p,P,E,N,W){return this._rArcTo(a,c,p,P,E,N,W),this},e.Path.prototype.rConicTo=function(a,c,p,P,E){return this._rConicTo(a,c,p,P,E),this},e.Path.prototype.rCubicTo=function(a,c,p,P,E,N){return this._rCubicTo(a,c,p,P,E,N),this},e.Path.prototype.rLineTo=function(a,c){return this._rLineTo(a,c),this},e.Path.prototype.rMoveTo=function(a,c){return this._rMoveTo(a,c),this},e.Path.prototype.rQuadTo=function(a,c,p,P){return this._rQuadTo(a,c,p,P),this},e.Path.prototype.stroke=function(a){return a=a||{},a.width=a.width||1,a.miter_limit=a.miter_limit||4,a.cap=a.cap||e.StrokeCap.Butt,a.join=a.join||e.StrokeJoin.Miter,a.precision=a.precision||1,this._stroke(a)?this:null},e.Path.prototype.transform=function(){if(arguments.length===1){var a=arguments[0];this._transform(a[0],a[1],a[2],a[3],a[4],a[5],a[6]||0,a[7]||0,a[8]||1)}else if(arguments.length===6||arguments.length===9)a=arguments,this._transform(a[0],a[1],a[2],a[3],a[4],a[5],a[6]||0,a[7]||0,a[8]||1);else throw"transform expected to take 1 or 9 arguments. Got "+arguments.length;return this},e.Path.prototype.trim=function(a,c,p){return this._trim(a,c,!!p)?this:null},e.Image.prototype.encodeToBytes=function(a,c){var p=e.Te();return a=a||e.ImageFormat.PNG,c=c||100,p?this._encodeToBytes(a,c,p):this._encodeToBytes(a,c)},e.Image.prototype.makeShaderCubic=function(a,c,p,P,E){return E=D(E),this._makeShaderCubic(a,c,p,P,E)},e.Image.prototype.makeShaderOptions=function(a,c,p,P,E){return E=D(E),this._makeShaderOptions(a,c,p,P,E)},e.Image.prototype.readPixels=function(a,c,p,P,E){var N=e.Te();return o(this,a,c,p,P,E,N)},e.Canvas.prototype.clear=function(a){e.Md(this.Kd),a=T(a),this._clear(a)},e.Canvas.prototype.clipRRect=function(a,c,p){e.Md(this.Kd),a=Bt(a),this._clipRRect(a,c,p)},e.Canvas.prototype.clipRect=function(a,c,p){e.Md(this.Kd),a=rt(a),this._clipRect(a,c,p)},e.Canvas.prototype.concat=function(a){e.Md(this.Kd),a=H(a),this._concat(a)},e.Canvas.prototype.drawArc=function(a,c,p,P,E){e.Md(this.Kd),a=rt(a),this._drawArc(a,c,p,P,E)},e.Canvas.prototype.drawAtlas=function(a,c,p,P,E,N,W){if(a&&P&&c&&p&&c.length===p.length){e.Md(this.Kd),E||(E=e.BlendMode.SrcOver);var Q=A(c,"HEAPF32"),J=A(p,"HEAPF32"),dt=p.length/4,mt=A(m(N),"HEAPU32");if(W&&"B"in W&&"C"in W)this._drawAtlasCubic(a,J,Q,mt,dt,E,W.B,W.C,P);else{let S=e.FilterMode.Linear,k=e.MipmapMode.None;W&&(S=W.filter,"mipmap"in W&&(k=W.mipmap)),this._drawAtlasOptions(a,J,Q,mt,dt,E,S,k,P)}y(Q,c),y(J,p),y(mt,N)}},e.Canvas.prototype.drawCircle=function(a,c,p,P){e.Md(this.Kd),this._drawCircle(a,c,p,P)},e.Canvas.prototype.drawColor=function(a,c){e.Md(this.Kd),a=T(a),c!==void 0?this._drawColor(a,c):this._drawColor(a)},e.Canvas.prototype.drawColorInt=function(a,c){e.Md(this.Kd),this._drawColorInt(a,c||e.BlendMode.SrcOver)},e.Canvas.prototype.drawColorComponents=function(a,c,p,P,E){e.Md(this.Kd),a=Y(a,c,p,P),E!==void 0?this._drawColor(a,E):this._drawColor(a)},e.Canvas.prototype.drawDRRect=function(a,c,p){e.Md(this.Kd),a=Bt(a,rr),c=Bt(c,hn),this._drawDRRect(a,c,p)},e.Canvas.prototype.drawImage=function(a,c,p,P){e.Md(this.Kd),this._drawImage(a,c,p,P||null)},e.Canvas.prototype.drawImageCubic=function(a,c,p,P,E,N){e.Md(this.Kd),this._drawImageCubic(a,c,p,P,E,N||null)},e.Canvas.prototype.drawImageOptions=function(a,c,p,P,E,N){e.Md(this.Kd),this._drawImageOptions(a,c,p,P,E,N||null)},e.Canvas.prototype.drawImageNine=function(a,c,p,P,E){e.Md(this.Kd),c=A(c,"HEAP32",ii),p=rt(p),this._drawImageNine(a,c,p,P,E||null)},e.Canvas.prototype.drawImageRect=function(a,c,p,P,E){e.Md(this.Kd),rt(c,Et),rt(p,we),this._drawImageRect(a,Et,we,P,!!E)},e.Canvas.prototype.drawImageRectCubic=function(a,c,p,P,E,N){e.Md(this.Kd),rt(c,Et),rt(p,we),this._drawImageRectCubic(a,Et,we,P,E,N||null)},e.Canvas.prototype.drawImageRectOptions=function(a,c,p,P,E,N){e.Md(this.Kd),rt(c,Et),rt(p,we),this._drawImageRectOptions(a,Et,we,P,E,N||null)},e.Canvas.prototype.drawLine=function(a,c,p,P,E){e.Md(this.Kd),this._drawLine(a,c,p,P,E)},e.Canvas.prototype.drawOval=function(a,c){e.Md(this.Kd),a=rt(a),this._drawOval(a,c)},e.Canvas.prototype.drawPaint=function(a){e.Md(this.Kd),this._drawPaint(a)},e.Canvas.prototype.drawParagraph=function(a,c,p){e.Md(this.Kd),this._drawParagraph(a,c,p)},e.Canvas.prototype.drawPatch=function(a,c,p,P,E){if(24>a.length)throw"Need 12 cubic points";if(c&&4>c.length)throw"Need 4 colors";if(p&&8>p.length)throw"Need 4 shader coordinates";e.Md(this.Kd);const N=A(a,"HEAPF32"),W=c?A(m(c),"HEAPU32"):ht,Q=p?A(p,"HEAPF32"):ht;P||(P=e.BlendMode.Modulate),this._drawPatch(N,W,Q,P,E),y(Q,p),y(W,c),y(N,a)},e.Canvas.prototype.drawPath=function(a,c){e.Md(this.Kd),this._drawPath(a,c)},e.Canvas.prototype.drawPicture=function(a){e.Md(this.Kd),this._drawPicture(a)},e.Canvas.prototype.drawPoints=function(a,c,p){e.Md(this.Kd);var P=A(c,"HEAPF32");this._drawPoints(a,P,c.length/2,p),y(P,c)},e.Canvas.prototype.drawRRect=function(a,c){e.Md(this.Kd),a=Bt(a),this._drawRRect(a,c)},e.Canvas.prototype.drawRect=function(a,c){e.Md(this.Kd),a=rt(a),this._drawRect(a,c)},e.Canvas.prototype.drawRect4f=function(a,c,p,P,E){e.Md(this.Kd),this._drawRect4f(a,c,p,P,E)},e.Canvas.prototype.drawShadow=function(a,c,p,P,E,N,W){e.Md(this.Kd);var Q=A(E,"HEAPF32"),J=A(N,"HEAPF32");c=A(c,"HEAPF32",er),p=A(p,"HEAPF32",ir),this._drawShadow(a,c,p,P,Q,J,W),y(Q,E),y(J,N)},e.getShadowLocalBounds=function(a,c,p,P,E,N,W){return a=D(a),p=A(p,"HEAPF32",er),P=A(P,"HEAPF32",ir),this._getShadowLocalBounds(a,c,p,P,E,N,Et)?(c=ie.toTypedArray(),W?(W.set(c),W):c.slice()):null},e.Canvas.prototype.drawTextBlob=function(a,c,p,P){e.Md(this.Kd),this._drawTextBlob(a,c,p,P)},e.Canvas.prototype.drawVertices=function(a,c,p){e.Md(this.Kd),this._drawVertices(a,c,p)},e.Canvas.prototype.getDeviceClipBounds=function(a){this._getDeviceClipBounds(ii);var c=Fi.toTypedArray();return a?a.set(c):a=c.slice(),a},e.Canvas.prototype.getLocalToDevice=function(){this._getLocalToDevice(Le);for(var a=Le,c=Array(16),p=0;16>p;p++)c[p]=e.HEAPF32[a/4+p];return c},e.Canvas.prototype.getTotalMatrix=function(){this._getTotalMatrix(ye);for(var a=Array(9),c=0;9>c;c++)a[c]=e.HEAPF32[ye/4+c];return a},e.Canvas.prototype.makeSurface=function(a){return a=this._makeSurface(a),a.Kd=this.Kd,a},e.Canvas.prototype.readPixels=function(a,c,p,P,E){return e.Md(this.Kd),o(this,a,c,p,P,E)},e.Canvas.prototype.saveLayer=function(a,c,p,P){return c=rt(c),this._saveLayer(a||null,c,p||null,P||0)},e.Canvas.prototype.writePixels=function(a,c,p,P,E,N,W,Q){if(a.byteLength%(c*p))throw"pixels length must be a multiple of the srcWidth * srcHeight";e.Md(this.Kd);var J=a.byteLength/(c*p);N=N||e.AlphaType.Unpremul,W=W||e.ColorType.RGBA_8888,Q=Q||e.ColorSpace.SRGB;var dt=J*c;return J=A(a,"HEAPU8"),c=this._writePixels({width:c,height:p,colorType:W,alphaType:N,colorSpace:Q},J,dt,P,E),y(J,a),c},e.ColorFilter.MakeBlend=function(a,c,p){return a=T(a),p=p||e.ColorSpace.SRGB,e.ColorFilter._MakeBlend(a,c,p)},e.ColorFilter.MakeMatrix=function(a){if(!a||a.length!==20)throw"invalid color matrix";var c=A(a,"HEAPF32"),p=e.ColorFilter._makeMatrix(c);return y(c,a),p},e.ContourMeasure.prototype.getPosTan=function(a,c){return this._getPosTan(a,Et),a=ie.toTypedArray(),c?(c.set(a),c):a.slice()},e.ImageFilter.prototype.getOutputBounds=function(a,c,p){return a=rt(a,Et),c=D(c),this._getOutputBounds(a,c,ii),c=Fi.toTypedArray(),p?(p.set(c),p):c.slice()},e.ImageFilter.MakeDropShadow=function(a,c,p,P,E,N){return E=T(E,Ee),e.ImageFilter._MakeDropShadow(a,c,p,P,E,N)},e.ImageFilter.MakeDropShadowOnly=function(a,c,p,P,E,N){return E=T(E,Ee),e.ImageFilter._MakeDropShadowOnly(a,c,p,P,E,N)},e.ImageFilter.MakeImage=function(a,c,p,P){if(p=rt(p,Et),P=rt(P,we),"B"in c&&"C"in c)return e.ImageFilter._MakeImageCubic(a,c.B,c.C,p,P);const E=c.filter;let N=e.MipmapMode.None;return"mipmap"in c&&(N=c.mipmap),e.ImageFilter._MakeImageOptions(a,E,N,p,P)},e.ImageFilter.MakeMatrixTransform=function(a,c,p){if(a=D(a),"B"in c&&"C"in c)return e.ImageFilter._MakeMatrixTransformCubic(a,c.B,c.C,p);const P=c.filter;let E=e.MipmapMode.None;return"mipmap"in c&&(E=c.mipmap),e.ImageFilter._MakeMatrixTransformOptions(a,P,E,p)},e.Paint.prototype.getColor=function(){return this._getColor(Ee),nt(Ee)},e.Paint.prototype.setColor=function(a,c){c=c||null,a=T(a),this._setColor(a,c)},e.Paint.prototype.setColorComponents=function(a,c,p,P,E){E=E||null,a=Y(a,c,p,P),this._setColor(a,E)},e.Path.prototype.getPoint=function(a,c){return this._getPoint(a,Et),a=ie.toTypedArray(),c?(c[0]=a[0],c[1]=a[1],c):a.slice(0,2)},e.Picture.prototype.makeShader=function(a,c,p,P,E){return P=D(P),E=rt(E),this._makeShader(a,c,p,P,E)},e.Picture.prototype.cullRect=function(a){this._cullRect(Et);var c=ie.toTypedArray();return a?(a.set(c),a):c.slice()},e.PictureRecorder.prototype.beginRecording=function(a,c){return a=rt(a),this._beginRecording(a,!!c)},e.Surface.prototype.getCanvas=function(){var a=this._getCanvas();return a.Kd=this.Kd,a},e.Surface.prototype.makeImageSnapshot=function(a){return e.Md(this.Kd),a=A(a,"HEAP32",ii),this._makeImageSnapshot(a)},e.Surface.prototype.makeSurface=function(a){return e.Md(this.Kd),a=this._makeSurface(a),a.Kd=this.Kd,a},e.Surface.prototype.Gf=function(a,c){return this.He||(this.He=this.getCanvas()),requestAnimationFrame(function(){e.Md(this.Kd),a(this.He),this.flush(c)}.bind(this))},e.Surface.prototype.requestAnimationFrame||(e.Surface.prototype.requestAnimationFrame=e.Surface.prototype.Gf),e.Surface.prototype.Cf=function(a,c){this.He||(this.He=this.getCanvas()),requestAnimationFrame(function(){e.Md(this.Kd),a(this.He),this.flush(c),this.dispose()}.bind(this))},e.Surface.prototype.drawOnce||(e.Surface.prototype.drawOnce=e.Surface.prototype.Cf),e.PathEffect.MakeDash=function(a,c){if(c||(c=0),!a.length||a.length%2===1)throw"Intervals array must have even length";var p=A(a,"HEAPF32");return c=e.PathEffect._MakeDash(p,a.length,c),y(p,a),c},e.PathEffect.MakeLine2D=function(a,c){return c=D(c),e.PathEffect._MakeLine2D(a,c)},e.PathEffect.MakePath2D=function(a,c){return a=D(a),e.PathEffect._MakePath2D(a,c)},e.Shader.MakeColor=function(a,c){return c=c||null,a=T(a),e.Shader._MakeColor(a,c)},e.Shader.Blend=e.Shader.MakeBlend,e.Shader.Color=e.Shader.MakeColor,e.Shader.MakeLinearGradient=function(a,c,p,P,E,N,W,Q){Q=Q||null;var J=O(p),dt=A(P,"HEAPF32");W=W||0,N=D(N);var mt=ie.toTypedArray();return mt.set(a),mt.set(c,2),a=e.Shader._MakeLinearGradient(Et,J.be,J.colorType,dt,J.count,E,W,N,Q),y(J.be,p),P&&y(dt,P),a},e.Shader.MakeRadialGradient=function(a,c,p,P,E,N,W,Q){Q=Q||null;var J=O(p),dt=A(P,"HEAPF32");return W=W||0,N=D(N),a=e.Shader._MakeRadialGradient(a[0],a[1],c,J.be,J.colorType,dt,J.count,E,W,N,Q),y(J.be,p),P&&y(dt,P),a},e.Shader.MakeSweepGradient=function(a,c,p,P,E,N,W,Q,J,dt){dt=dt||null;var mt=O(p),S=A(P,"HEAPF32");return W=W||0,Q=Q||0,J=J||360,N=D(N),a=e.Shader._MakeSweepGradient(a,c,mt.be,mt.colorType,S,mt.count,E,Q,J,W,N,dt),y(mt.be,p),P&&y(S,P),a},e.Shader.MakeTwoPointConicalGradient=function(a,c,p,P,E,N,W,Q,J,dt){dt=dt||null;var mt=O(E),S=A(N,"HEAPF32");J=J||0,Q=D(Q);var k=ie.toTypedArray();return k.set(a),k.set(p,2),a=e.Shader._MakeTwoPointConicalGradient(Et,c,P,mt.be,mt.colorType,S,mt.count,W,J,Q,dt),y(mt.be,E),N&&y(S,N),a},e.Vertices.prototype.bounds=function(a){this._bounds(Et);var c=ie.toTypedArray();return a?(a.set(c),a):c.slice()},e.Td&&e.Td.forEach(function(a){a()})},e.computeTonalColors=function(o){var a=A(o.ambient,"HEAPF32"),c=A(o.spot,"HEAPF32");this._computeTonalColors(a,c);var p={ambient:nt(a),spot:nt(c)};return y(a,o.ambient),y(c,o.spot),p},e.LTRBRect=function(o,a,c,p){return Float32Array.of(o,a,c,p)},e.XYWHRect=function(o,a,c,p){return Float32Array.of(o,a,o+c,a+p)},e.LTRBiRect=function(o,a,c,p){return Int32Array.of(o,a,c,p)},e.XYWHiRect=function(o,a,c,p){return Int32Array.of(o,a,o+c,a+p)},e.RRectXY=function(o,a,c){return Float32Array.of(o[0],o[1],o[2],o[3],a,c,a,c,a,c,a,c)},e.MakeAnimatedImageFromEncoded=function(o){o=new Uint8Array(o);var a=e._malloc(o.byteLength);return e.HEAPU8.set(o,a),(o=e._decodeAnimatedImage(a,o.byteLength))?o:null},e.MakeImageFromEncoded=function(o){o=new Uint8Array(o);var a=e._malloc(o.byteLength);return e.HEAPU8.set(o,a),(o=e._decodeImage(a,o.byteLength))?o:null};var ri=null;e.MakeImageFromCanvasImageSource=function(o){var a=o.width,c=o.height;ri||(ri=document.createElement("canvas")),ri.width=a,ri.height=c;var p=ri.getContext("2d",{willReadFrequently:!0});return p.drawImage(o,0,0),o=p.getImageData(0,0,a,c),e.MakeImage({width:a,height:c,alphaType:e.AlphaType.Unpremul,colorType:e.ColorType.RGBA_8888,colorSpace:e.ColorSpace.SRGB},o.data,4*a)},e.MakeImage=function(o,a,c){var p=e._malloc(a.length);return e.HEAPU8.set(a,p),e._MakeImage(o,p,a.length,c)},e.MakeVertices=function(o,a,c,p,P,E){var N=P&&P.length||0,W=0;return c&&c.length&&(W|=1),p&&p.length&&(W|=2),E===void 0||E||(W|=4),o=new e._VerticesBuilder(o,a.length/2,N,W),A(a,"HEAPF32",o.positions()),o.texCoords()&&A(c,"HEAPF32",o.texCoords()),o.colors()&&A(m(p),"HEAPU32",o.colors()),o.indices()&&A(P,"HEAPU16",o.indices()),o.detach()},e.Matrix={},e.Matrix.identity=function(){return s(3)},e.Matrix.invert=function(o){var a=o[0]*o[4]*o[8]+o[1]*o[5]*o[6]+o[2]*o[3]*o[7]-o[2]*o[4]*o[6]-o[1]*o[3]*o[8]-o[0]*o[5]*o[7];return a?[(o[4]*o[8]-o[5]*o[7])/a,(o[2]*o[7]-o[1]*o[8])/a,(o[1]*o[5]-o[2]*o[4])/a,(o[5]*o[6]-o[3]*o[8])/a,(o[0]*o[8]-o[2]*o[6])/a,(o[2]*o[3]-o[0]*o[5])/a,(o[3]*o[7]-o[4]*o[6])/a,(o[1]*o[6]-o[0]*o[7])/a,(o[0]*o[4]-o[1]*o[3])/a]:null},e.Matrix.mapPoints=function(o,a){for(var c=0;c<a.length;c+=2){var p=a[c],P=a[c+1],E=o[6]*p+o[7]*P+o[8],N=o[3]*p+o[4]*P+o[5];a[c]=(o[0]*p+o[1]*P+o[2])/E,a[c+1]=N/E}return a},e.Matrix.multiply=function(){return ei(3,arguments)},e.Matrix.rotated=function(o,a,c){a=a||0,c=c||0;var p=Math.sin(o);return o=Math.cos(o),[o,-p,Rt(p,c,1-o,a),p,o,Rt(-p,a,1-o,c),0,0,1]},e.Matrix.scaled=function(o,a,c,p){c=c||0,p=p||0;var P=r([o,a],s(3),3,0,1);return r([c-o*c,p-a*p],P,3,2,0)},e.Matrix.skewed=function(o,a,c,p){c=c||0,p=p||0;var P=r([o,a],s(3),3,1,-1);return r([-o*c,-a*p],P,3,2,0)},e.Matrix.translated=function(o,a){return r(arguments,s(3),3,2,0)},e.Vector={},e.Vector.dot=function(o,a){return o.map(function(c,p){return c*a[p]}).reduce(function(c,p){return c+p})},e.Vector.lengthSquared=function(o){return e.Vector.dot(o,o)},e.Vector.length=function(o){return Math.sqrt(e.Vector.lengthSquared(o))},e.Vector.mulScalar=function(o,a){return o.map(function(c){return c*a})},e.Vector.add=function(o,a){return o.map(function(c,p){return c+a[p]})},e.Vector.sub=function(o,a){return o.map(function(c,p){return c-a[p]})},e.Vector.dist=function(o,a){return e.Vector.length(e.Vector.sub(o,a))},e.Vector.normalize=function(o){return e.Vector.mulScalar(o,1/e.Vector.length(o))},e.Vector.cross=function(o,a){return[o[1]*a[2]-o[2]*a[1],o[2]*a[0]-o[0]*a[2],o[0]*a[1]-o[1]*a[0]]},e.M44={},e.M44.identity=function(){return s(4)},e.M44.translated=function(o){return r(o,s(4),4,3,0)},e.M44.scaled=function(o){return r(o,s(4),4,0,1)},e.M44.rotated=function(o,a){return e.M44.rotatedUnitSinCos(e.Vector.normalize(o),Math.sin(a),Math.cos(a))},e.M44.rotatedUnitSinCos=function(o,a,c){var p=o[0],P=o[1];o=o[2];var E=1-c;return[E*p*p+c,E*p*P-a*o,E*p*o+a*P,0,E*p*P+a*o,E*P*P+c,E*P*o-a*p,0,E*p*o-a*P,E*P*o+a*p,E*o*o+c,0,0,0,0,1]},e.M44.lookat=function(o,a,c){a=e.Vector.normalize(e.Vector.sub(a,o)),c=e.Vector.normalize(c),c=e.Vector.normalize(e.Vector.cross(a,c));var p=e.M44.identity();return r(c,p,4,0,0),r(e.Vector.cross(c,a),p,4,1,0),r(e.Vector.mulScalar(a,-1),p,4,2,0),r(o,p,4,3,0),o=e.M44.invert(p),o===null?e.M44.identity():o},e.M44.perspective=function(o,a,c){var p=1/(a-o);return c/=2,c=Math.cos(c)/Math.sin(c),[c,0,0,0,0,c,0,0,0,0,(a+o)*p,2*a*o*p,0,0,-1,1]},e.M44.rc=function(o,a,c){return o[4*a+c]},e.M44.multiply=function(){return ei(4,arguments)},e.M44.invert=function(o){var a=o[0],c=o[4],p=o[8],P=o[12],E=o[1],N=o[5],W=o[9],Q=o[13],J=o[2],dt=o[6],mt=o[10],S=o[14],k=o[3],st=o[7],vt=o[11];o=o[15];var Tt=a*N-c*E,Vt=a*W-p*E,Yt=a*Q-P*E,Lt=c*W-p*N,L=c*Q-P*N,f=p*Q-P*W,w=J*st-dt*k,M=J*vt-mt*k,R=J*o-S*k,I=dt*vt-mt*st,z=dt*o-S*st,K=mt*o-S*vt,Pt=Tt*K-Vt*z+Yt*I+Lt*R-L*M+f*w,bt=1/Pt;return Pt===0||bt===1/0?null:(Tt*=bt,Vt*=bt,Yt*=bt,Lt*=bt,L*=bt,f*=bt,w*=bt,M*=bt,R*=bt,I*=bt,z*=bt,K*=bt,a=[N*K-W*z+Q*I,W*R-E*K-Q*M,E*z-N*R+Q*w,N*M-E*I-W*w,p*z-c*K-P*I,a*K-p*R+P*M,c*R-a*z-P*w,a*I-c*M+p*w,st*f-vt*L+o*Lt,vt*Yt-k*f-o*Vt,k*L-st*Yt+o*Tt,st*Vt-k*Lt-vt*Tt,mt*L-dt*f-S*Lt,J*f-mt*Yt+S*Vt,dt*Yt-J*L-S*Tt,J*Lt-dt*Vt+mt*Tt],a.every(function(he){return!isNaN(he)&&he!==1/0&&he!==-1/0})?a:null)},e.M44.transpose=function(o){return[o[0],o[4],o[8],o[12],o[1],o[5],o[9],o[13],o[2],o[6],o[10],o[14],o[3],o[7],o[11],o[15]]},e.M44.mustInvert=function(o){if(o=e.M44.invert(o),o===null)throw"Matrix not invertible";return o},e.M44.setupCamera=function(o,a,c){var p=e.M44.lookat(c.eye,c.coa,c.up);return c=e.M44.perspective(c.near,c.far,c.angle),a=[(o[2]-o[0])/2,(o[3]-o[1])/2,a],o=e.M44.multiply(e.M44.translated([(o[0]+o[2])/2,(o[1]+o[3])/2,0]),e.M44.scaled(a)),e.M44.multiply(o,c,p,e.M44.mustInvert(o))},e.ColorMatrix={},e.ColorMatrix.identity=function(){var o=new Float32Array(20);return o[0]=1,o[6]=1,o[12]=1,o[18]=1,o},e.ColorMatrix.scaled=function(o,a,c,p){var P=new Float32Array(20);return P[0]=o,P[6]=a,P[12]=c,P[18]=p,P};var js=[[6,7,11,12],[0,10,2,12],[0,1,5,6]];e.ColorMatrix.rotated=function(o,a,c){var p=e.ColorMatrix.identity();return o=js[o],p[o[0]]=c,p[o[1]]=a,p[o[2]]=-a,p[o[3]]=c,p},e.ColorMatrix.postTranslate=function(o,a,c,p,P){return o[4]+=a,o[9]+=c,o[14]+=p,o[19]+=P,o},e.ColorMatrix.concat=function(o,a){for(var c=new Float32Array(20),p=0,P=0;20>P;P+=5){for(var E=0;4>E;E++)c[p++]=o[P]*a[E]+o[P+1]*a[E+5]+o[P+2]*a[E+10]+o[P+3]*a[E+15];c[p++]=o[P]*a[4]+o[P+1]*a[9]+o[P+2]*a[14]+o[P+3]*a[19]+o[P+4]}return c},function(o){o.Td=o.Td||[],o.Td.push(function(){function a(S){return S&&(S.dir=S.dir===0?o.TextDirection.RTL:o.TextDirection.LTR),S}function c(S){if(!S||!S.length)return[];for(var k=[],st=0;st<S.length;st+=5){var vt=o.LTRBRect(S[st],S[st+1],S[st+2],S[st+3]),Tt=o.TextDirection.LTR;S[st+4]===0&&(Tt=o.TextDirection.RTL),k.push({rect:vt,dir:Tt})}return o._free(S.byteOffset),k}function p(S){return S=S||{},S.weight===void 0&&(S.weight=o.FontWeight.Normal),S.width=S.width||o.FontWidth.Normal,S.slant=S.slant||o.FontSlant.Upright,S}function P(S){if(!S||!S.length)return ht;for(var k=[],st=0;st<S.length;st++){var vt=E(S[st]);k.push(vt)}return A(k,"HEAPU32")}function E(S){if(Q[S])return Q[S];var k=Zt(S)+1,st=o._malloc(k);return Qt(S,ot,st,k),Q[S]=st}function N(S){if(S._colorPtr=T(S.color),S._foregroundColorPtr=ht,S._backgroundColorPtr=ht,S._decorationColorPtr=ht,S.foregroundColor&&(S._foregroundColorPtr=T(S.foregroundColor,J)),S.backgroundColor&&(S._backgroundColorPtr=T(S.backgroundColor,dt)),S.decorationColor&&(S._decorationColorPtr=T(S.decorationColor,mt)),Array.isArray(S.fontFamilies)&&S.fontFamilies.length?(S._fontFamiliesPtr=P(S.fontFamilies),S._fontFamiliesLen=S.fontFamilies.length):(S._fontFamiliesPtr=ht,S._fontFamiliesLen=0),S.locale){var k=S.locale;S._localePtr=E(k),S._localeLen=Zt(k)+1}else S._localePtr=ht,S._localeLen=0;if(Array.isArray(S.shadows)&&S.shadows.length){k=S.shadows;var st=k.map(function(L){return L.color||o.BLACK}),vt=k.map(function(L){return L.blurRadius||0});S._shadowLen=k.length;for(var Tt=o._malloc(8*k.length),Vt=Tt/4,Yt=0;Yt<k.length;Yt++){var Lt=k[Yt].offset||[0,0];o.HEAPF32[Vt]=Lt[0],o.HEAPF32[Vt+1]=Lt[1],Vt+=2}S._shadowColorsPtr=O(st).be,S._shadowOffsetsPtr=Tt,S._shadowBlurRadiiPtr=A(vt,"HEAPF32")}else S._shadowLen=0,S._shadowColorsPtr=ht,S._shadowOffsetsPtr=ht,S._shadowBlurRadiiPtr=ht;Array.isArray(S.fontFeatures)&&S.fontFeatures.length?(k=S.fontFeatures,st=k.map(function(L){return L.name}),vt=k.map(function(L){return L.value}),S._fontFeatureLen=k.length,S._fontFeatureNamesPtr=P(st),S._fontFeatureValuesPtr=A(vt,"HEAPU32")):(S._fontFeatureLen=0,S._fontFeatureNamesPtr=ht,S._fontFeatureValuesPtr=ht),Array.isArray(S.fontVariations)&&S.fontVariations.length?(k=S.fontVariations,st=k.map(function(L){return L.axis}),vt=k.map(function(L){return L.value}),S._fontVariationLen=k.length,S._fontVariationAxesPtr=P(st),S._fontVariationValuesPtr=A(vt,"HEAPF32")):(S._fontVariationLen=0,S._fontVariationAxesPtr=ht,S._fontVariationValuesPtr=ht)}function W(S){o._free(S._fontFamiliesPtr),o._free(S._shadowColorsPtr),o._free(S._shadowOffsetsPtr),o._free(S._shadowBlurRadiiPtr),o._free(S._fontFeatureNamesPtr),o._free(S._fontFeatureValuesPtr),o._free(S._fontVariationAxesPtr),o._free(S._fontVariationValuesPtr)}o.Paragraph.prototype.getRectsForRange=function(S,k,st,vt){return S=this._getRectsForRange(S,k,st,vt),c(S)},o.Paragraph.prototype.getRectsForPlaceholders=function(){var S=this._getRectsForPlaceholders();return c(S)},o.Paragraph.prototype.getGlyphInfoAt=function(S){return a(this._getGlyphInfoAt(S))},o.Paragraph.prototype.getClosestGlyphInfoAtCoordinate=function(S,k){return a(this._getClosestGlyphInfoAtCoordinate(S,k))},o.TypefaceFontProvider.prototype.registerFont=function(S,k){if(S=o.Typeface.MakeFreeTypeFaceFromData(S),!S)return null;k=E(k),this._registerFont(S,k)},o.ParagraphStyle=function(S){if(S.disableHinting=S.disableHinting||!1,S.ellipsis){var k=S.ellipsis;S._ellipsisPtr=E(k),S._ellipsisLen=Zt(k)+1}else S._ellipsisPtr=ht,S._ellipsisLen=0;return S.heightMultiplier==null&&(S.heightMultiplier=-1),S.maxLines=S.maxLines||0,S.replaceTabCharacters=S.replaceTabCharacters||!1,k=(k=S.strutStyle)||{},k.strutEnabled=k.strutEnabled||!1,k.strutEnabled&&Array.isArray(k.fontFamilies)&&k.fontFamilies.length?(k._fontFamiliesPtr=P(k.fontFamilies),k._fontFamiliesLen=k.fontFamilies.length):(k._fontFamiliesPtr=ht,k._fontFamiliesLen=0),k.fontStyle=p(k.fontStyle),k.fontSize==null&&(k.fontSize=-1),k.heightMultiplier==null&&(k.heightMultiplier=-1),k.halfLeading=k.halfLeading||!1,k.leading=k.leading||0,k.forceStrutHeight=k.forceStrutHeight||!1,S.strutStyle=k,S.textAlign=S.textAlign||o.TextAlign.Start,S.textDirection=S.textDirection||o.TextDirection.LTR,S.textHeightBehavior=S.textHeightBehavior||o.TextHeightBehavior.All,S.textStyle=o.TextStyle(S.textStyle),S.applyRoundingHack=S.applyRoundingHack!==!1,S},o.TextStyle=function(S){return S.color||(S.color=o.BLACK),S.decoration=S.decoration||0,S.decorationThickness=S.decorationThickness||0,S.decorationStyle=S.decorationStyle||o.DecorationStyle.Solid,S.textBaseline=S.textBaseline||o.TextBaseline.Alphabetic,S.fontSize==null&&(S.fontSize=-1),S.letterSpacing=S.letterSpacing||0,S.wordSpacing=S.wordSpacing||0,S.heightMultiplier==null&&(S.heightMultiplier=-1),S.halfLeading=S.halfLeading||!1,S.fontStyle=p(S.fontStyle),S};var Q={},J=o._malloc(16),dt=o._malloc(16),mt=o._malloc(16);o.ParagraphBuilder.Make=function(S,k){return N(S.textStyle),k=o.ParagraphBuilder._Make(S,k),W(S.textStyle),k},o.ParagraphBuilder.MakeFromFontProvider=function(S,k){return N(S.textStyle),k=o.ParagraphBuilder._MakeFromFontProvider(S,k),W(S.textStyle),k},o.ParagraphBuilder.MakeFromFontCollection=function(S,k){return N(S.textStyle),k=o.ParagraphBuilder._MakeFromFontCollection(S,k),W(S.textStyle),k},o.ParagraphBuilder.ShapeText=function(S,k,st){let vt=0;for(const Tt of k)vt+=Tt.length;if(vt!==S.length)throw"Accumulated block lengths must equal text.length";return o.ParagraphBuilder._ShapeText(S,k,st)},o.ParagraphBuilder.prototype.pushStyle=function(S){N(S),this._pushStyle(S),W(S)},o.ParagraphBuilder.prototype.pushPaintStyle=function(S,k,st){N(S),this._pushPaintStyle(S,k,st),W(S)},o.ParagraphBuilder.prototype.addPlaceholder=function(S,k,st,vt,Tt){st=st||o.PlaceholderAlignment.Baseline,vt=vt||o.TextBaseline.Alphabetic,this._addPlaceholder(S||0,k||0,st,vt,Tt||0)},o.ParagraphBuilder.prototype.setWordsUtf8=function(S){var k=A(S,"HEAPU32");this._setWordsUtf8(k,S&&S.length||0),y(k,S)},o.ParagraphBuilder.prototype.setWordsUtf16=function(S){var k=A(S,"HEAPU32");this._setWordsUtf16(k,S&&S.length||0),y(k,S)},o.ParagraphBuilder.prototype.setGraphemeBreaksUtf8=function(S){var k=A(S,"HEAPU32");this._setGraphemeBreaksUtf8(k,S&&S.length||0),y(k,S)},o.ParagraphBuilder.prototype.setGraphemeBreaksUtf16=function(S){var k=A(S,"HEAPU32");this._setGraphemeBreaksUtf16(k,S&&S.length||0),y(k,S)},o.ParagraphBuilder.prototype.setLineBreaksUtf8=function(S){var k=A(S,"HEAPU32");this._setLineBreaksUtf8(k,S&&S.length||0),y(k,S)},o.ParagraphBuilder.prototype.setLineBreaksUtf16=function(S){var k=A(S,"HEAPU32");this._setLineBreaksUtf16(k,S&&S.length||0),y(k,S)}})}(h),e.Td=e.Td||[],e.Td.push(function(){e.Path.prototype.op=function(o,a){return this._op(o,a)?this:null},e.Path.prototype.simplify=function(){return this._simplify()?this:null}}),e.Td=e.Td||[],e.Td.push(function(){e.Canvas.prototype.drawText=function(o,a,c,p,P){var E=Zt(o),N=e._malloc(E+1);Qt(o,ot,N,E+1),this._drawSimpleText(N,E,a,c,P,p),e._free(N)},e.Canvas.prototype.drawGlyphs=function(o,a,c,p,P,E){if(!(2*o.length<=a.length))throw"Not enough positions for the array of gyphs";e.Md(this.Kd);const N=A(o,"HEAPU16"),W=A(a,"HEAPF32");this._drawGlyphs(o.length,N,W,c,p,P,E),y(W,a),y(N,o)},e.Font.prototype.getGlyphBounds=function(o,a,c){var p=A(o,"HEAPU16"),P=e._malloc(16*o.length);return this._getGlyphWidthBounds(p,o.length,ht,P,a||null),a=new Float32Array(e.HEAPU8.buffer,P,4*o.length),y(p,o),c?(c.set(a),e._free(P),c):(o=Float32Array.from(a),e._free(P),o)},e.Font.prototype.getGlyphIDs=function(o,a,c){a||(a=o.length);var p=Zt(o)+1,P=e._malloc(p);return Qt(o,ot,P,p),o=e._malloc(2*a),a=this._getGlyphIDs(P,p-1,a,o),e._free(P),0>a?(e._free(o),null):(P=new Uint16Array(e.HEAPU8.buffer,o,a),c?(c.set(P),e._free(o),c):(c=Uint16Array.from(P),e._free(o),c))},e.Font.prototype.getGlyphIntercepts=function(o,a,c,p){var P=A(o,"HEAPU16"),E=A(a,"HEAPF32");return this._getGlyphIntercepts(P,o.length,!(o&&o._ck),E,a.length,!(a&&a._ck),c,p)},e.Font.prototype.getGlyphWidths=function(o,a,c){var p=A(o,"HEAPU16"),P=e._malloc(4*o.length);return this._getGlyphWidthBounds(p,o.length,P,ht,a||null),a=new Float32Array(e.HEAPU8.buffer,P,o.length),y(p,o),c?(c.set(a),e._free(P),c):(o=Float32Array.from(a),e._free(P),o)},e.FontMgr.FromData=function(){if(!arguments.length)return null;var o=arguments;if(o.length===1&&Array.isArray(o[0])&&(o=arguments[0]),!o.length)return null;for(var a=[],c=[],p=0;p<o.length;p++){var P=new Uint8Array(o[p]),E=A(P,"HEAPU8");a.push(E),c.push(P.byteLength)}return a=A(a,"HEAPU32"),c=A(c,"HEAPU32"),o=e.FontMgr._fromData(a,c,o.length),e._free(a),e._free(c),o},e.Typeface.MakeFreeTypeFaceFromData=function(o){o=new Uint8Array(o);var a=A(o,"HEAPU8");return(o=e.Typeface._MakeFreeTypeFaceFromData(a,o.byteLength))?o:null},e.Typeface.prototype.getGlyphIDs=function(o,a,c){a||(a=o.length);var p=Zt(o)+1,P=e._malloc(p);return Qt(o,ot,P,p),o=e._malloc(2*a),a=this._getGlyphIDs(P,p-1,a,o),e._free(P),0>a?(e._free(o),null):(P=new Uint16Array(e.HEAPU8.buffer,o,a),c?(c.set(P),e._free(o),c):(c=Uint16Array.from(P),e._free(o),c))},e.TextBlob.MakeOnPath=function(o,a,c,p){if(o&&o.length&&a&&a.countPoints()){if(a.countPoints()===1)return this.MakeFromText(o,c);p||(p=0);var P=c.getGlyphIDs(o);P=c.getGlyphWidths(P);var E=[];a=new e.ContourMeasureIter(a,!1,1);for(var N=a.next(),W=new Float32Array(4),Q=0;Q<o.length&&N;Q++){var J=P[Q];if(p+=J/2,p>N.length()){if(N.delete(),N=a.next(),!N){o=o.substring(0,Q);break}p=J/2}N.getPosTan(p,W);var dt=W[2],mt=W[3];E.push(dt,mt,W[0]-J/2*dt,W[1]-J/2*mt),p+=J/2}return o=this.MakeFromRSXform(o,E,c),N&&N.delete(),a.delete(),o}},e.TextBlob.MakeFromRSXform=function(o,a,c){var p=Zt(o)+1,P=e._malloc(p);return Qt(o,ot,P,p),o=A(a,"HEAPF32"),c=e.TextBlob._MakeFromRSXform(P,p-1,o,c),e._free(P),c||null},e.TextBlob.MakeFromRSXformGlyphs=function(o,a,c){var p=A(o,"HEAPU16");return a=A(a,"HEAPF32"),c=e.TextBlob._MakeFromRSXformGlyphs(p,2*o.length,a,c),y(p,o),c||null},e.TextBlob.MakeFromGlyphs=function(o,a){var c=A(o,"HEAPU16");return a=e.TextBlob._MakeFromGlyphs(c,2*o.length,a),y(c,o),a||null},e.TextBlob.MakeFromText=function(o,a){var c=Zt(o)+1,p=e._malloc(c);return Qt(o,ot,p,c),o=e.TextBlob._MakeFromText(p,c-1,a),e._free(p),o||null},e.MallocGlyphIDs=function(o){return e.Malloc(Uint16Array,o)}}),e.Td=e.Td||[],e.Td.push(function(){e.MakePicture=function(o){o=new Uint8Array(o);var a=e._malloc(o.byteLength);return e.HEAPU8.set(o,a),(o=e._MakePicture(a,o.byteLength))?o:null}}),e.Td=e.Td||[],e.Td.push(function(){e.RuntimeEffect.Make=function(o,a){return e.RuntimeEffect._Make(o,{onError:a||function(c){console.log("RuntimeEffect error",c)}})},e.RuntimeEffect.MakeForBlender=function(o,a){return e.RuntimeEffect._MakeForBlender(o,{onError:a||function(c){console.log("RuntimeEffect error",c)}})},e.RuntimeEffect.prototype.makeShader=function(o,a){var c=!o._ck,p=A(o,"HEAPF32");return a=D(a),this._makeShader(p,4*o.length,c,a)},e.RuntimeEffect.prototype.makeShaderWithChildren=function(o,a,c){var p=!o._ck,P=A(o,"HEAPF32");c=D(c);for(var E=[],N=0;N<a.length;N++)E.push(a[N].Jd.Rd);return a=A(E,"HEAPU32"),this._makeShaderWithChildren(P,4*o.length,p,a,E.length,c)},e.RuntimeEffect.prototype.makeBlender=function(o){var a=!o._ck,c=A(o,"HEAPF32");return this._makeBlender(c,4*o.length,a)}}),function(){function o(L){for(var f=0;f<L.length;f++)if(L[f]!==void 0&&!Number.isFinite(L[f]))return!1;return!0}function a(L){var f=e.getColorComponents(L);L=f[0];var w=f[1],M=f[2];return f=f[3],f===1?(L=L.toString(16).toLowerCase(),w=w.toString(16).toLowerCase(),M=M.toString(16).toLowerCase(),L=L.length===1?"0"+L:L,w=w.length===1?"0"+w:w,M=M.length===1?"0"+M:M,"#"+L+w+M):(f=f===0||f===1?f:f.toFixed(8),"rgba("+L+", "+w+", "+M+", "+f+")")}function c(L){return e.parseColorString(L,Vt)}function p(L){if(L=Yt.exec(L),!L)return null;var f=parseFloat(L[4]),w=16;switch(L[5]){case"em":case"rem":w=16*f;break;case"pt":w=4*f/3;break;case"px":w=f;break;case"pc":w=16*f;break;case"in":w=96*f;break;case"cm":w=96*f/2.54;break;case"mm":w=3.7795275590551185*f;break;case"q":w=.9448818897637796*f;break;case"%":w=.21333333333333335*f}return{style:L[1],variant:L[2],weight:L[3],sizePx:w,family:L[6].trim()}}function P(L){this.Ld=L,this.Od=new e.Paint,this.Od.setAntiAlias(!0),this.Od.setStrokeMiter(10),this.Od.setStrokeCap(e.StrokeCap.Butt),this.Od.setStrokeJoin(e.StrokeJoin.Miter),this.Re="10px monospace",this.me=new e.Font(null,10),this.me.setSubpixel(!0),this.ae=this.ge=e.BLACK,this.ve=0,this.Je=e.TRANSPARENT,this.xe=this.we=0,this.Ke=this.ie=1,this.Ie=0,this.ue=[],this.Nd=e.BlendMode.SrcOver,this.Od.setStrokeWidth(this.Ke),this.Od.setBlendMode(this.Nd),this.Qd=new e.Path,this.Sd=e.Matrix.identity(),this.lf=[],this.Be=[],this.le=function(){this.Qd.delete(),this.Od.delete(),this.me.delete(),this.Be.forEach(function(f){f.le()})},Object.defineProperty(this,"currentTransform",{enumerable:!0,get:function(){return{a:this.Sd[0],c:this.Sd[1],e:this.Sd[2],b:this.Sd[3],d:this.Sd[4],f:this.Sd[5]}},set:function(f){f.a&&this.setTransform(f.a,f.b,f.c,f.d,f.e,f.f)}}),Object.defineProperty(this,"fillStyle",{enumerable:!0,get:function(){return l(this.ae)?a(this.ae):this.ae},set:function(f){typeof f=="string"?this.ae=c(f):f.te&&(this.ae=f)}}),Object.defineProperty(this,"font",{enumerable:!0,get:function(){return this.Re},set:function(f){var w=p(f),M=w.family;w.typeface=Lt[M]?Lt[M][(w.style||"normal")+"|"+(w.variant||"normal")+"|"+(w.weight||"normal")]||Lt[M]["*"]:null,w&&(this.me.setSize(w.sizePx),this.me.setTypeface(w.typeface),this.Re=f)}}),Object.defineProperty(this,"globalAlpha",{enumerable:!0,get:function(){return this.ie},set:function(f){!isFinite(f)||0>f||1<f||(this.ie=f)}}),Object.defineProperty(this,"globalCompositeOperation",{enumerable:!0,get:function(){switch(this.Nd){case e.BlendMode.SrcOver:return"source-over";case e.BlendMode.DstOver:return"destination-over";case e.BlendMode.Src:return"copy";case e.BlendMode.Dst:return"destination";case e.BlendMode.Clear:return"clear";case e.BlendMode.SrcIn:return"source-in";case e.BlendMode.DstIn:return"destination-in";case e.BlendMode.SrcOut:return"source-out";case e.BlendMode.DstOut:return"destination-out";case e.BlendMode.SrcATop:return"source-atop";case e.BlendMode.DstATop:return"destination-atop";case e.BlendMode.Xor:return"xor";case e.BlendMode.Plus:return"lighter";case e.BlendMode.Multiply:return"multiply";case e.BlendMode.Screen:return"screen";case e.BlendMode.Overlay:return"overlay";case e.BlendMode.Darken:return"darken";case e.BlendMode.Lighten:return"lighten";case e.BlendMode.ColorDodge:return"color-dodge";case e.BlendMode.ColorBurn:return"color-burn";case e.BlendMode.HardLight:return"hard-light";case e.BlendMode.SoftLight:return"soft-light";case e.BlendMode.Difference:return"difference";case e.BlendMode.Exclusion:return"exclusion";case e.BlendMode.Hue:return"hue";case e.BlendMode.Saturation:return"saturation";case e.BlendMode.Color:return"color";case e.BlendMode.Luminosity:return"luminosity"}},set:function(f){switch(f){case"source-over":this.Nd=e.BlendMode.SrcOver;break;case"destination-over":this.Nd=e.BlendMode.DstOver;break;case"copy":this.Nd=e.BlendMode.Src;break;case"destination":this.Nd=e.BlendMode.Dst;break;case"clear":this.Nd=e.BlendMode.Clear;break;case"source-in":this.Nd=e.BlendMode.SrcIn;break;case"destination-in":this.Nd=e.BlendMode.DstIn;break;case"source-out":this.Nd=e.BlendMode.SrcOut;break;case"destination-out":this.Nd=e.BlendMode.DstOut;break;case"source-atop":this.Nd=e.BlendMode.SrcATop;break;case"destination-atop":this.Nd=e.BlendMode.DstATop;break;case"xor":this.Nd=e.BlendMode.Xor;break;case"lighter":this.Nd=e.BlendMode.Plus;break;case"plus-lighter":this.Nd=e.BlendMode.Plus;break;case"plus-darker":throw"plus-darker is not supported";case"multiply":this.Nd=e.BlendMode.Multiply;break;case"screen":this.Nd=e.BlendMode.Screen;break;case"overlay":this.Nd=e.BlendMode.Overlay;break;case"darken":this.Nd=e.BlendMode.Darken;break;case"lighten":this.Nd=e.BlendMode.Lighten;break;case"color-dodge":this.Nd=e.BlendMode.ColorDodge;break;case"color-burn":this.Nd=e.BlendMode.ColorBurn;break;case"hard-light":this.Nd=e.BlendMode.HardLight;break;case"soft-light":this.Nd=e.BlendMode.SoftLight;break;case"difference":this.Nd=e.BlendMode.Difference;break;case"exclusion":this.Nd=e.BlendMode.Exclusion;break;case"hue":this.Nd=e.BlendMode.Hue;break;case"saturation":this.Nd=e.BlendMode.Saturation;break;case"color":this.Nd=e.BlendMode.Color;break;case"luminosity":this.Nd=e.BlendMode.Luminosity;break;default:return}this.Od.setBlendMode(this.Nd)}}),Object.defineProperty(this,"imageSmoothingEnabled",{enumerable:!0,get:function(){return!0},set:function(){}}),Object.defineProperty(this,"imageSmoothingQuality",{enumerable:!0,get:function(){return"high"},set:function(){}}),Object.defineProperty(this,"lineCap",{enumerable:!0,get:function(){switch(this.Od.getStrokeCap()){case e.StrokeCap.Butt:return"butt";case e.StrokeCap.Round:return"round";case e.StrokeCap.Square:return"square"}},set:function(f){switch(f){case"butt":this.Od.setStrokeCap(e.StrokeCap.Butt);break;case"round":this.Od.setStrokeCap(e.StrokeCap.Round);break;case"square":this.Od.setStrokeCap(e.StrokeCap.Square)}}}),Object.defineProperty(this,"lineDashOffset",{enumerable:!0,get:function(){return this.Ie},set:function(f){isFinite(f)&&(this.Ie=f)}}),Object.defineProperty(this,"lineJoin",{enumerable:!0,get:function(){switch(this.Od.getStrokeJoin()){case e.StrokeJoin.Miter:return"miter";case e.StrokeJoin.Round:return"round";case e.StrokeJoin.Bevel:return"bevel"}},set:function(f){switch(f){case"miter":this.Od.setStrokeJoin(e.StrokeJoin.Miter);break;case"round":this.Od.setStrokeJoin(e.StrokeJoin.Round);break;case"bevel":this.Od.setStrokeJoin(e.StrokeJoin.Bevel)}}}),Object.defineProperty(this,"lineWidth",{enumerable:!0,get:function(){return this.Od.getStrokeWidth()},set:function(f){0>=f||!f||(this.Ke=f,this.Od.setStrokeWidth(f))}}),Object.defineProperty(this,"miterLimit",{enumerable:!0,get:function(){return this.Od.getStrokeMiter()},set:function(f){0>=f||!f||this.Od.setStrokeMiter(f)}}),Object.defineProperty(this,"shadowBlur",{enumerable:!0,get:function(){return this.ve},set:function(f){0>f||!isFinite(f)||(this.ve=f)}}),Object.defineProperty(this,"shadowColor",{enumerable:!0,get:function(){return a(this.Je)},set:function(f){this.Je=c(f)}}),Object.defineProperty(this,"shadowOffsetX",{enumerable:!0,get:function(){return this.we},set:function(f){isFinite(f)&&(this.we=f)}}),Object.defineProperty(this,"shadowOffsetY",{enumerable:!0,get:function(){return this.xe},set:function(f){isFinite(f)&&(this.xe=f)}}),Object.defineProperty(this,"strokeStyle",{enumerable:!0,get:function(){return a(this.ge)},set:function(f){typeof f=="string"?this.ge=c(f):f.te&&(this.ge=f)}}),this.arc=function(f,w,M,R,I,z){S(this.Qd,f,w,M,M,0,R,I,z)},this.arcTo=function(f,w,M,R,I){J(this.Qd,f,w,M,R,I)},this.beginPath=function(){this.Qd.delete(),this.Qd=new e.Path},this.bezierCurveTo=function(f,w,M,R,I,z){var K=this.Qd;o([f,w,M,R,I,z])&&(K.isEmpty()&&K.moveTo(f,w),K.cubicTo(f,w,M,R,I,z))},this.clearRect=function(f,w,M,R){this.Od.setStyle(e.PaintStyle.Fill),this.Od.setBlendMode(e.BlendMode.Clear),this.Ld.drawRect(e.XYWHRect(f,w,M,R),this.Od),this.Od.setBlendMode(this.Nd)},this.clip=function(f,w){typeof f=="string"?(w=f,f=this.Qd):f&&f.af&&(f=f.Ud),f||(f=this.Qd),f=f.copy(),w&&w.toLowerCase()==="evenodd"?f.setFillType(e.FillType.EvenOdd):f.setFillType(e.FillType.Winding),this.Ld.clipPath(f,e.ClipOp.Intersect,!0),f.delete()},this.closePath=function(){dt(this.Qd)},this.createImageData=function(){if(arguments.length===1){var f=arguments[0];return new W(new Uint8ClampedArray(4*f.width*f.height),f.width,f.height)}if(arguments.length===2){f=arguments[0];var w=arguments[1];return new W(new Uint8ClampedArray(4*f*w),f,w)}throw"createImageData expects 1 or 2 arguments, got "+arguments.length},this.createLinearGradient=function(f,w,M,R){if(o(arguments)){var I=new Q(f,w,M,R);return this.Be.push(I),I}},this.createPattern=function(f,w){return f=new vt(f,w),this.Be.push(f),f},this.createRadialGradient=function(f,w,M,R,I,z){if(o(arguments)){var K=new Tt(f,w,M,R,I,z);return this.Be.push(K),K}},this.drawImage=function(f){f instanceof N&&(f=f.tf());var w=this.Qe();if(arguments.length===3||arguments.length===5)var M=e.XYWHRect(arguments[1],arguments[2],arguments[3]||f.width(),arguments[4]||f.height()),R=e.XYWHRect(0,0,f.width(),f.height());else if(arguments.length===9)M=e.XYWHRect(arguments[5],arguments[6],arguments[7],arguments[8]),R=e.XYWHRect(arguments[1],arguments[2],arguments[3],arguments[4]);else throw"invalid number of args for drawImage, need 3, 5, or 9; got "+arguments.length;this.Ld.drawImageRect(f,R,M,w,!1),w.dispose()},this.ellipse=function(f,w,M,R,I,z,K,Pt){S(this.Qd,f,w,M,R,I,z,K,Pt)},this.Qe=function(){var f=this.Od.copy();if(f.setStyle(e.PaintStyle.Fill),l(this.ae)){var w=e.multiplyByAlpha(this.ae,this.ie);f.setColor(w)}else w=this.ae.te(this.Sd),f.setColor(e.Color(0,0,0,this.ie)),f.setShader(w);return f.dispose=function(){this.delete()},f},this.fill=function(f,w){if(typeof f=="string"?(w=f,f=this.Qd):f&&f.af&&(f=f.Ud),w==="evenodd")this.Qd.setFillType(e.FillType.EvenOdd);else{if(w!=="nonzero"&&w)throw"invalid fill rule";this.Qd.setFillType(e.FillType.Winding)}f||(f=this.Qd),w=this.Qe();var M=this.ye(w);M&&(this.Ld.save(),this.re(),this.Ld.drawPath(f,M),this.Ld.restore(),M.dispose()),this.Ld.drawPath(f,w),w.dispose()},this.fillRect=function(f,w,M,R){var I=this.Qe(),z=this.ye(I);z&&(this.Ld.save(),this.re(),this.Ld.drawRect(e.XYWHRect(f,w,M,R),z),this.Ld.restore(),z.dispose()),this.Ld.drawRect(e.XYWHRect(f,w,M,R),I),I.dispose()},this.fillText=function(f,w,M){var R=this.Qe();f=e.TextBlob.MakeFromText(f,this.me);var I=this.ye(R);I&&(this.Ld.save(),this.re(),this.Ld.drawTextBlob(f,w,M,I),this.Ld.restore(),I.dispose()),this.Ld.drawTextBlob(f,w,M,R),f.delete(),R.dispose()},this.getImageData=function(f,w,M,R){return(f=this.Ld.readPixels(f,w,{width:M,height:R,colorType:e.ColorType.RGBA_8888,alphaType:e.AlphaType.Unpremul,colorSpace:e.ColorSpace.SRGB}))?new W(new Uint8ClampedArray(f.buffer),M,R):null},this.getLineDash=function(){return this.ue.slice()},this.mf=function(f){var w=e.Matrix.invert(this.Sd);return e.Matrix.mapPoints(w,f),f},this.isPointInPath=function(f,w,M){var R=arguments;if(R.length===3)var I=this.Qd;else if(R.length===4)I=R[0],f=R[1],w=R[2],M=R[3];else throw"invalid arg count, need 3 or 4, got "+R.length;return!isFinite(f)||!isFinite(w)||(M=M||"nonzero",M!=="nonzero"&&M!=="evenodd")?!1:(R=this.mf([f,w]),f=R[0],w=R[1],I.setFillType(M==="nonzero"?e.FillType.Winding:e.FillType.EvenOdd),I.contains(f,w))},this.isPointInStroke=function(f,w){var M=arguments;if(M.length===2)var R=this.Qd;else if(M.length===3)R=M[0],f=M[1],w=M[2];else throw"invalid arg count, need 2 or 3, got "+M.length;return!isFinite(f)||!isFinite(w)?!1:(M=this.mf([f,w]),f=M[0],w=M[1],R=R.copy(),R.setFillType(e.FillType.Winding),R.stroke({width:this.lineWidth,miter_limit:this.miterLimit,cap:this.Od.getStrokeCap(),join:this.Od.getStrokeJoin(),precision:.3}),M=R.contains(f,w),R.delete(),M)},this.lineTo=function(f,w){k(this.Qd,f,w)},this.measureText=function(f){f=this.me.getGlyphIDs(f),f=this.me.getGlyphWidths(f);let w=0;for(const M of f)w+=M;return{width:w}},this.moveTo=function(f,w){var M=this.Qd;o([f,w])&&M.moveTo(f,w)},this.putImageData=function(f,w,M,R,I,z,K){if(o([w,M,R,I,z,K])){if(R===void 0)this.Ld.writePixels(f.data,f.width,f.height,w,M);else if(R=R||0,I=I||0,z=z||f.width,K=K||f.height,0>z&&(R+=z,z=Math.abs(z)),0>K&&(I+=K,K=Math.abs(K)),0>R&&(z+=R,R=0),0>I&&(K+=I,I=0),!(0>=z||0>=K)){f=e.MakeImage({width:f.width,height:f.height,alphaType:e.AlphaType.Unpremul,colorType:e.ColorType.RGBA_8888,colorSpace:e.ColorSpace.SRGB},f.data,4*f.width);var Pt=e.XYWHRect(R,I,z,K);w=e.XYWHRect(w+R,M+I,z,K),M=e.Matrix.invert(this.Sd),this.Ld.save(),this.Ld.concat(M),this.Ld.drawImageRect(f,Pt,w,null,!1),this.Ld.restore(),f.delete()}}},this.quadraticCurveTo=function(f,w,M,R){var I=this.Qd;o([f,w,M,R])&&(I.isEmpty()&&I.moveTo(f,w),I.quadTo(f,w,M,R))},this.rect=function(f,w,M,R){var I=this.Qd;f=e.XYWHRect(f,w,M,R),o(f)&&I.addRect(f)},this.resetTransform=function(){this.Qd.transform(this.Sd);var f=e.Matrix.invert(this.Sd);this.Ld.concat(f),this.Sd=this.Ld.getTotalMatrix()},this.restore=function(){var f=this.lf.pop();if(f){var w=e.Matrix.multiply(this.Sd,e.Matrix.invert(f.Jf));this.Qd.transform(w),this.Od.delete(),this.Od=f.ag,this.ue=f.Zf,this.Ke=f.mg,this.ge=f.lg,this.ae=f.fs,this.we=f.jg,this.xe=f.kg,this.ve=f.sb,this.Je=f.ig,this.ie=f.ga,this.Nd=f.Qf,this.Ie=f.$f,this.Re=f.Pf,this.Ld.restore(),this.Sd=this.Ld.getTotalMatrix()}},this.rotate=function(f){if(isFinite(f)){var w=e.Matrix.rotated(-f);this.Qd.transform(w),this.Ld.rotate(f/Math.PI*180,0,0),this.Sd=this.Ld.getTotalMatrix()}},this.save=function(){if(this.ae.se){var f=this.ae.se();this.Be.push(f)}else f=this.ae;if(this.ge.se){var w=this.ge.se();this.Be.push(w)}else w=this.ge;this.lf.push({Jf:this.Sd.slice(),Zf:this.ue.slice(),mg:this.Ke,lg:w,fs:f,jg:this.we,kg:this.xe,sb:this.ve,ig:this.Je,ga:this.ie,$f:this.Ie,Qf:this.Nd,ag:this.Od.copy(),Pf:this.Re}),this.Ld.save()},this.scale=function(f,w){if(o(arguments)){var M=e.Matrix.scaled(1/f,1/w);this.Qd.transform(M),this.Ld.scale(f,w),this.Sd=this.Ld.getTotalMatrix()}},this.setLineDash=function(f){for(var w=0;w<f.length;w++)if(!isFinite(f[w])||0>f[w])return;f.length%2===1&&Array.prototype.push.apply(f,f),this.ue=f},this.setTransform=function(f,w,M,R,I,z){o(arguments)&&(this.resetTransform(),this.transform(f,w,M,R,I,z))},this.re=function(){var f=e.Matrix.invert(this.Sd);this.Ld.concat(f),this.Ld.concat(e.Matrix.translated(this.we,this.xe)),this.Ld.concat(this.Sd)},this.ye=function(f){var w=e.multiplyByAlpha(this.Je,this.ie);if(!e.getColorComponents(w)[3]||!(this.ve||this.xe||this.we))return null;f=f.copy(),f.setColor(w);var M=e.MaskFilter.MakeBlur(e.BlurStyle.Normal,this.ve/2,!1);return f.setMaskFilter(M),f.dispose=function(){M.delete(),this.delete()},f},this.cf=function(){var f=this.Od.copy();if(f.setStyle(e.PaintStyle.Stroke),l(this.ge)){var w=e.multiplyByAlpha(this.ge,this.ie);f.setColor(w)}else w=this.ge.te(this.Sd),f.setColor(e.Color(0,0,0,this.ie)),f.setShader(w);if(f.setStrokeWidth(this.Ke),this.ue.length){var M=e.PathEffect.MakeDash(this.ue,this.Ie);f.setPathEffect(M)}return f.dispose=function(){M&&M.delete(),this.delete()},f},this.stroke=function(f){f=f?f.Ud:this.Qd;var w=this.cf(),M=this.ye(w);M&&(this.Ld.save(),this.re(),this.Ld.drawPath(f,M),this.Ld.restore(),M.dispose()),this.Ld.drawPath(f,w),w.dispose()},this.strokeRect=function(f,w,M,R){var I=this.cf(),z=this.ye(I);z&&(this.Ld.save(),this.re(),this.Ld.drawRect(e.XYWHRect(f,w,M,R),z),this.Ld.restore(),z.dispose()),this.Ld.drawRect(e.XYWHRect(f,w,M,R),I),I.dispose()},this.strokeText=function(f,w,M){var R=this.cf();f=e.TextBlob.MakeFromText(f,this.me);var I=this.ye(R);I&&(this.Ld.save(),this.re(),this.Ld.drawTextBlob(f,w,M,I),this.Ld.restore(),I.dispose()),this.Ld.drawTextBlob(f,w,M,R),f.delete(),R.dispose()},this.translate=function(f,w){if(o(arguments)){var M=e.Matrix.translated(-f,-w);this.Qd.transform(M),this.Ld.translate(f,w),this.Sd=this.Ld.getTotalMatrix()}},this.transform=function(f,w,M,R,I,z){f=[f,M,I,w,R,z,0,0,1],w=e.Matrix.invert(f),this.Qd.transform(w),this.Ld.concat(f),this.Sd=this.Ld.getTotalMatrix()},this.addHitRegion=function(){},this.clearHitRegions=function(){},this.drawFocusIfNeeded=function(){},this.removeHitRegion=function(){},this.scrollPathIntoView=function(){},Object.defineProperty(this,"canvas",{value:null,writable:!1})}function E(L){this.df=L,this.Kd=new P(L.getCanvas()),this.Se=[],this.decodeImage=function(f){if(f=e.MakeImageFromEncoded(f),!f)throw"Invalid input";return this.Se.push(f),new N(f)},this.loadFont=function(f,w){if(f=e.Typeface.MakeFreeTypeFaceFromData(f),!f)return null;this.Se.push(f);var M=(w.style||"normal")+"|"+(w.variant||"normal")+"|"+(w.weight||"normal");w=w.family,Lt[w]||(Lt[w]={"*":f}),Lt[w][M]=f},this.makePath2D=function(f){return f=new st(f),this.Se.push(f.Ud),f},this.getContext=function(f){return f==="2d"?this.Kd:null},this.toDataURL=function(f,w){this.df.flush();var M=this.df.makeImageSnapshot();if(M){f=f||"image/png";var R=e.ImageFormat.PNG;if(f==="image/jpeg"&&(R=e.ImageFormat.JPEG),w=M.encodeToBytes(R,w||.92)){if(M.delete(),f="data:"+f+";base64,",typeof Buffer<"u")w=Buffer.from(w).toString("base64");else{M=0,R=w.length;for(var I="",z;M<R;)z=w.slice(M,Math.min(M+32768,R)),I+=String.fromCharCode.apply(null,z),M+=32768;w=btoa(I)}return f+w}}},this.dispose=function(){this.Kd.le(),this.Se.forEach(function(f){f.delete()}),this.df.dispose()}}function N(L){this.width=L.width(),this.height=L.height(),this.naturalWidth=this.width,this.naturalHeight=this.height,this.tf=function(){return L}}function W(L,f,w){if(!f||w===0)throw"invalid dimensions, width and height must be non-zero";if(L.length%4)throw"arr must be a multiple of 4";w=w||L.length/(4*f),Object.defineProperty(this,"data",{value:L,writable:!1}),Object.defineProperty(this,"height",{value:w,writable:!1}),Object.defineProperty(this,"width",{value:f,writable:!1})}function Q(L,f,w,M){this.Wd=null,this.ce=[],this.Zd=[],this.addColorStop=function(R,I){if(0>R||1<R||!isFinite(R))throw"offset must be between 0 and 1 inclusively";I=c(I);var z=this.Zd.indexOf(R);if(z!==-1)this.ce[z]=I;else{for(z=0;z<this.Zd.length&&!(this.Zd[z]>R);z++);this.Zd.splice(z,0,R),this.ce.splice(z,0,I)}},this.se=function(){var R=new Q(L,f,w,M);return R.ce=this.ce.slice(),R.Zd=this.Zd.slice(),R},this.le=function(){this.Wd&&(this.Wd.delete(),this.Wd=null)},this.te=function(R){var I=[L,f,w,M];e.Matrix.mapPoints(R,I),R=I[0];var z=I[1],K=I[2];return I=I[3],this.le(),this.Wd=e.Shader.MakeLinearGradient([R,z],[K,I],this.ce,this.Zd,e.TileMode.Clamp)}}function J(L,f,w,M,R,I){if(o([f,w,M,R,I])){if(0>I)throw"radii cannot be negative";L.isEmpty()&&L.moveTo(f,w),L.arcToTangent(f,w,M,R,I)}}function dt(L){if(!L.isEmpty()){var f=L.getBounds();(f[3]-f[1]||f[2]-f[0])&&L.close()}}function mt(L,f,w,M,R,I,z){z=(z-I)/Math.PI*180,I=I/Math.PI*180,f=e.LTRBRect(f-M,w-R,f+M,w+R),1e-5>Math.abs(Math.abs(z)-360)?(w=z/2,L.arcToOval(f,I,w,!1),L.arcToOval(f,I+w,w,!1)):L.arcToOval(f,I,z,!1)}function S(L,f,w,M,R,I,z,K,Pt){if(o([f,w,M,R,I,z,K])){if(0>M||0>R)throw"radii cannot be negative";var bt=2*Math.PI,he=z%bt;0>he&&(he+=bt);var ni=he-z;z=he,K+=ni,!Pt&&K-z>=bt?K=z+bt:Pt&&z-K>=bt?K=z-bt:!Pt&&z>K?K=z+(bt-(z-K)%bt):Pt&&z<K&&(K=z-(bt-(K-z)%bt)),I?(Pt=e.Matrix.rotated(I,f,w),I=e.Matrix.rotated(-I,f,w),L.transform(I),mt(L,f,w,M,R,z,K),L.transform(Pt)):mt(L,f,w,M,R,z,K)}}function k(L,f,w){o([f,w])&&(L.isEmpty()&&L.moveTo(f,w),L.lineTo(f,w))}function st(L){this.Ud=null,this.Ud=typeof L=="string"?e.Path.MakeFromSVGString(L):L&&L.af?L.Ud.copy():new e.Path,this.af=function(){return this.Ud},this.addPath=function(f,w){w||(w={a:1,c:0,e:0,b:0,d:1,f:0}),this.Ud.addPath(f.Ud,[w.a,w.c,w.e,w.b,w.d,w.f])},this.arc=function(f,w,M,R,I,z){S(this.Ud,f,w,M,M,0,R,I,z)},this.arcTo=function(f,w,M,R,I){J(this.Ud,f,w,M,R,I)},this.bezierCurveTo=function(f,w,M,R,I,z){var K=this.Ud;o([f,w,M,R,I,z])&&(K.isEmpty()&&K.moveTo(f,w),K.cubicTo(f,w,M,R,I,z))},this.closePath=function(){dt(this.Ud)},this.ellipse=function(f,w,M,R,I,z,K,Pt){S(this.Ud,f,w,M,R,I,z,K,Pt)},this.lineTo=function(f,w){k(this.Ud,f,w)},this.moveTo=function(f,w){var M=this.Ud;o([f,w])&&M.moveTo(f,w)},this.quadraticCurveTo=function(f,w,M,R){var I=this.Ud;o([f,w,M,R])&&(I.isEmpty()&&I.moveTo(f,w),I.quadTo(f,w,M,R))},this.rect=function(f,w,M,R){var I=this.Ud;f=e.XYWHRect(f,w,M,R),o(f)&&I.addRect(f)}}function vt(L,f){switch(this.Wd=null,L instanceof N&&(L=L.tf()),this.Ef=L,this._transform=e.Matrix.identity(),f===""&&(f="repeat"),f){case"repeat-x":this.ze=e.TileMode.Repeat,this.Ae=e.TileMode.Decal;break;case"repeat-y":this.ze=e.TileMode.Decal,this.Ae=e.TileMode.Repeat;break;case"repeat":this.Ae=this.ze=e.TileMode.Repeat;break;case"no-repeat":this.Ae=this.ze=e.TileMode.Decal;break;default:throw"invalid repetition mode "+f}this.setTransform=function(w){w=[w.a,w.c,w.e,w.b,w.d,w.f,0,0,1],o(w)&&(this._transform=w)},this.se=function(){var w=new vt;return w.ze=this.ze,w.Ae=this.Ae,w},this.le=function(){this.Wd&&(this.Wd.delete(),this.Wd=null)},this.te=function(){return this.le(),this.Wd=this.Ef.makeShaderCubic(this.ze,this.Ae,.3333333333333333,.3333333333333333,this._transform)}}function Tt(L,f,w,M,R,I){this.Wd=null,this.ce=[],this.Zd=[],this.addColorStop=function(z,K){if(0>z||1<z||!isFinite(z))throw"offset must be between 0 and 1 inclusively";K=c(K);var Pt=this.Zd.indexOf(z);if(Pt!==-1)this.ce[Pt]=K;else{for(Pt=0;Pt<this.Zd.length&&!(this.Zd[Pt]>z);Pt++);this.Zd.splice(Pt,0,z),this.ce.splice(Pt,0,K)}},this.se=function(){var z=new Tt(L,f,w,M,R,I);return z.ce=this.ce.slice(),z.Zd=this.Zd.slice(),z},this.le=function(){this.Wd&&(this.Wd.delete(),this.Wd=null)},this.te=function(z){var K=[L,f,M,R];e.Matrix.mapPoints(z,K);var Pt=K[0],bt=K[1],he=K[2];K=K[3];var ni=(Math.abs(z[0])+Math.abs(z[4]))/2;return z=w*ni,ni*=I,this.le(),this.Wd=e.Shader.MakeTwoPointConicalGradient([Pt,bt],z,[he,K],ni,this.ce,this.Zd,e.TileMode.Clamp)}}e._testing={};var Vt={aliceblue:Float32Array.of(.941,.973,1,1),antiquewhite:Float32Array.of(.98,.922,.843,1),aqua:Float32Array.of(0,1,1,1),aquamarine:Float32Array.of(.498,1,.831,1),azure:Float32Array.of(.941,1,1,1),beige:Float32Array.of(.961,.961,.863,1),bisque:Float32Array.of(1,.894,.769,1),black:Float32Array.of(0,0,0,1),blanchedalmond:Float32Array.of(1,.922,.804,1),blue:Float32Array.of(0,0,1,1),blueviolet:Float32Array.of(.541,.169,.886,1),brown:Float32Array.of(.647,.165,.165,1),burlywood:Float32Array.of(.871,.722,.529,1),cadetblue:Float32Array.of(.373,.62,.627,1),chartreuse:Float32Array.of(.498,1,0,1),chocolate:Float32Array.of(.824,.412,.118,1),coral:Float32Array.of(1,.498,.314,1),cornflowerblue:Float32Array.of(.392,.584,.929,1),cornsilk:Float32Array.of(1,.973,.863,1),crimson:Float32Array.of(.863,.078,.235,1),cyan:Float32Array.of(0,1,1,1),darkblue:Float32Array.of(0,0,.545,1),darkcyan:Float32Array.of(0,.545,.545,1),darkgoldenrod:Float32Array.of(.722,.525,.043,1),darkgray:Float32Array.of(.663,.663,.663,1),darkgreen:Float32Array.of(0,.392,0,1),darkgrey:Float32Array.of(.663,.663,.663,1),darkkhaki:Float32Array.of(.741,.718,.42,1),darkmagenta:Float32Array.of(.545,0,.545,1),darkolivegreen:Float32Array.of(.333,.42,.184,1),darkorange:Float32Array.of(1,.549,0,1),darkorchid:Float32Array.of(.6,.196,.8,1),darkred:Float32Array.of(.545,0,0,1),darksalmon:Float32Array.of(.914,.588,.478,1),darkseagreen:Float32Array.of(.561,.737,.561,1),darkslateblue:Float32Array.of(.282,.239,.545,1),darkslategray:Float32Array.of(.184,.31,.31,1),darkslategrey:Float32Array.of(.184,.31,.31,1),darkturquoise:Float32Array.of(0,.808,.82,1),darkviolet:Float32Array.of(.58,0,.827,1),deeppink:Float32Array.of(1,.078,.576,1),deepskyblue:Float32Array.of(0,.749,1,1),dimgray:Float32Array.of(.412,.412,.412,1),dimgrey:Float32Array.of(.412,.412,.412,1),dodgerblue:Float32Array.of(.118,.565,1,1),firebrick:Float32Array.of(.698,.133,.133,1),floralwhite:Float32Array.of(1,.98,.941,1),forestgreen:Float32Array.of(.133,.545,.133,1),fuchsia:Float32Array.of(1,0,1,1),gainsboro:Float32Array.of(.863,.863,.863,1),ghostwhite:Float32Array.of(.973,.973,1,1),gold:Float32Array.of(1,.843,0,1),goldenrod:Float32Array.of(.855,.647,.125,1),gray:Float32Array.of(.502,.502,.502,1),green:Float32Array.of(0,.502,0,1),greenyellow:Float32Array.of(.678,1,.184,1),grey:Float32Array.of(.502,.502,.502,1),honeydew:Float32Array.of(.941,1,.941,1),hotpink:Float32Array.of(1,.412,.706,1),indianred:Float32Array.of(.804,.361,.361,1),indigo:Float32Array.of(.294,0,.51,1),ivory:Float32Array.of(1,1,.941,1),khaki:Float32Array.of(.941,.902,.549,1),lavender:Float32Array.of(.902,.902,.98,1),lavenderblush:Float32Array.of(1,.941,.961,1),lawngreen:Float32Array.of(.486,.988,0,1),lemonchiffon:Float32Array.of(1,.98,.804,1),lightblue:Float32Array.of(.678,.847,.902,1),lightcoral:Float32Array.of(.941,.502,.502,1),lightcyan:Float32Array.of(.878,1,1,1),lightgoldenrodyellow:Float32Array.of(.98,.98,.824,1),lightgray:Float32Array.of(.827,.827,.827,1),lightgreen:Float32Array.of(.565,.933,.565,1),lightgrey:Float32Array.of(.827,.827,.827,1),lightpink:Float32Array.of(1,.714,.757,1),lightsalmon:Float32Array.of(1,.627,.478,1),lightseagreen:Float32Array.of(.125,.698,.667,1),lightskyblue:Float32Array.of(.529,.808,.98,1),lightslategray:Float32Array.of(.467,.533,.6,1),lightslategrey:Float32Array.of(.467,.533,.6,1),lightsteelblue:Float32Array.of(.69,.769,.871,1),lightyellow:Float32Array.of(1,1,.878,1),lime:Float32Array.of(0,1,0,1),limegreen:Float32Array.of(.196,.804,.196,1),linen:Float32Array.of(.98,.941,.902,1),magenta:Float32Array.of(1,0,1,1),maroon:Float32Array.of(.502,0,0,1),mediumaquamarine:Float32Array.of(.4,.804,.667,1),mediumblue:Float32Array.of(0,0,.804,1),mediumorchid:Float32Array.of(.729,.333,.827,1),mediumpurple:Float32Array.of(.576,.439,.859,1),mediumseagreen:Float32Array.of(.235,.702,.443,1),mediumslateblue:Float32Array.of(.482,.408,.933,1),mediumspringgreen:Float32Array.of(0,.98,.604,1),mediumturquoise:Float32Array.of(.282,.82,.8,1),mediumvioletred:Float32Array.of(.78,.082,.522,1),midnightblue:Float32Array.of(.098,.098,.439,1),mintcream:Float32Array.of(.961,1,.98,1),mistyrose:Float32Array.of(1,.894,.882,1),moccasin:Float32Array.of(1,.894,.71,1),navajowhite:Float32Array.of(1,.871,.678,1),navy:Float32Array.of(0,0,.502,1),oldlace:Float32Array.of(.992,.961,.902,1),olive:Float32Array.of(.502,.502,0,1),olivedrab:Float32Array.of(.42,.557,.137,1),orange:Float32Array.of(1,.647,0,1),orangered:Float32Array.of(1,.271,0,1),orchid:Float32Array.of(.855,.439,.839,1),palegoldenrod:Float32Array.of(.933,.91,.667,1),palegreen:Float32Array.of(.596,.984,.596,1),paleturquoise:Float32Array.of(.686,.933,.933,1),palevioletred:Float32Array.of(.859,.439,.576,1),papayawhip:Float32Array.of(1,.937,.835,1),peachpuff:Float32Array.of(1,.855,.725,1),peru:Float32Array.of(.804,.522,.247,1),pink:Float32Array.of(1,.753,.796,1),plum:Float32Array.of(.867,.627,.867,1),powderblue:Float32Array.of(.69,.878,.902,1),purple:Float32Array.of(.502,0,.502,1),rebeccapurple:Float32Array.of(.4,.2,.6,1),red:Float32Array.of(1,0,0,1),rosybrown:Float32Array.of(.737,.561,.561,1),royalblue:Float32Array.of(.255,.412,.882,1),saddlebrown:Float32Array.of(.545,.271,.075,1),salmon:Float32Array.of(.98,.502,.447,1),sandybrown:Float32Array.of(.957,.643,.376,1),seagreen:Float32Array.of(.18,.545,.341,1),seashell:Float32Array.of(1,.961,.933,1),sienna:Float32Array.of(.627,.322,.176,1),silver:Float32Array.of(.753,.753,.753,1),skyblue:Float32Array.of(.529,.808,.922,1),slateblue:Float32Array.of(.416,.353,.804,1),slategray:Float32Array.of(.439,.502,.565,1),slategrey:Float32Array.of(.439,.502,.565,1),snow:Float32Array.of(1,.98,.98,1),springgreen:Float32Array.of(0,1,.498,1),steelblue:Float32Array.of(.275,.51,.706,1),tan:Float32Array.of(.824,.706,.549,1),teal:Float32Array.of(0,.502,.502,1),thistle:Float32Array.of(.847,.749,.847,1),tomato:Float32Array.of(1,.388,.278,1),transparent:Float32Array.of(0,0,0,0),turquoise:Float32Array.of(.251,.878,.816,1),violet:Float32Array.of(.933,.51,.933,1),wheat:Float32Array.of(.961,.871,.702,1),white:Float32Array.of(1,1,1,1),whitesmoke:Float32Array.of(.961,.961,.961,1),yellow:Float32Array.of(1,1,0,1),yellowgreen:Float32Array.of(.604,.804,.196,1)};e._testing.parseColor=c,e._testing.colorToString=a;var Yt=RegExp("(italic|oblique|normal|)\\s*(small-caps|normal|)\\s*(bold|bolder|lighter|[1-9]00|normal|)\\s*([\\d\\.]+)(px|pt|pc|in|cm|mm|%|em|ex|ch|rem|q)(.+)"),Lt={"Noto Mono":{"*":null},monospace:{"*":null}};e._testing.parseFontString=p,e.MakeCanvas=function(L,f){return(L=e.MakeSurface(L,f))?new E(L):null},e.ImageData=function(){if(arguments.length===2){var L=arguments[0],f=arguments[1];return new W(new Uint8ClampedArray(4*L*f),L,f)}if(arguments.length===3){var w=arguments[0];if(w.prototype.constructor!==Uint8ClampedArray)throw"bytes must be given as a Uint8ClampedArray";if(L=arguments[1],f=arguments[2],w%4)throw"bytes must be given in a multiple of 4";if(w%L)throw"bytes must divide evenly by width";if(f&&f!==w/(4*L))throw"invalid height given";return new W(w,L,w/(4*L))}throw"invalid number of arguments - takes 2 or 3, saw "+arguments.length}}()}(h);var B=Object.assign({},h),U="./this.program",et=(e,r)=>{throw r},ct=typeof window=="object",ut=typeof importScripts=="function",At=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",yt="",ne,Se,Me;if(At){var We=ea,Ii=aa;yt=ut?Ii.dirname(yt)+"/":__dirname+"/",ne=(e,r)=>(e=e.startsWith("file://")?new URL(e):Ii.normalize(e),We.readFileSync(e,r?void 0:"utf8")),Me=e=>(e=ne(e,!0),e.buffer||(e=new Uint8Array(e)),e),Se=(e,r,s,l=!0)=>{e=e.startsWith("file://")?new URL(e):Ii.normalize(e),We.readFile(e,l?void 0:"utf8",(d,m)=>{d?s(d):r(l?m.buffer:m)})},!h.thisProgram&&1<process.argv.length&&(U=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),et=(e,r)=>{throw process.exitCode=e,r},h.inspect=()=>"[Emscripten Module object]"}else(ct||ut)&&(ut?yt=self.location.href:typeof document<"u"&&document.currentScript&&(yt=document.currentScript.src),n&&(yt=n),yt.indexOf("blob:")!==0?yt=yt.substr(0,yt.replace(/[?#].*/,"").lastIndexOf("/")+1):yt="",ne=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.send(null),r.responseText},ut&&(Me=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),Se=(e,r,s)=>{var l=new XMLHttpRequest;l.open("GET",e,!0),l.responseType="arraybuffer",l.onload=()=>{l.status==200||l.status==0&&l.response?r(l.response):s()},l.onerror=s,l.send(null)});var jn=h.print||console.log.bind(console),pe=h.printErr||console.error.bind(console);Object.assign(h,B),B=null,h.thisProgram&&(U=h.thisProgram),h.quit&&(et=h.quit);var $e;h.wasmBinary&&($e=h.wasmBinary);var Hn=h.noExitRuntime||!0;typeof WebAssembly!="object"&&Di("no native wasm support detected");var li,lt,Li=!1,se,ot,me,xe,$,wt,Z,mr;function gr(){var e=li.buffer;h.HEAP8=se=new Int8Array(e),h.HEAP16=me=new Int16Array(e),h.HEAP32=$=new Int32Array(e),h.HEAPU8=ot=new Uint8Array(e),h.HEAPU16=xe=new Uint16Array(e),h.HEAPU32=wt=new Uint32Array(e),h.HEAPF32=Z=new Float32Array(e),h.HEAPF64=mr=new Float64Array(e)}var Mt,vr=[],yr=[],wr=[];function Kn(){var e=h.preRun.shift();vr.unshift(e)}var Pe=0,Ge=null;function Di(e){throw h.onAbort&&h.onAbort(e),e="Aborted("+e+")",pe(e),Li=!0,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),F(e),e}function Sr(e){return e.startsWith("data:application/octet-stream;base64,")}var Re;if(Re="canvaskit.wasm",!Sr(Re)){var Pr=Re;Re=h.locateFile?h.locateFile(Pr,yt):yt+Pr}function br(e){if(e==Re&&$e)return new Uint8Array($e);if(Me)return Me(e);throw"both async and sync fetching of the wasm failed"}function Vn(e){if(!$e&&(ct||ut)){if(typeof fetch=="function"&&!e.startsWith("file://"))return fetch(e,{credentials:"same-origin"}).then(r=>{if(!r.ok)throw"failed to load wasm binary file at '"+e+"'";return r.arrayBuffer()}).catch(()=>br(e));if(Se)return new Promise((r,s)=>{Se(e,l=>r(new Uint8Array(l)),s)})}return Promise.resolve().then(()=>br(e))}function Ar(e,r,s){return Vn(e).then(l=>WebAssembly.instantiate(l,r)).then(l=>l).then(s,l=>{pe("failed to asynchronously prepare wasm: "+l),Di(l)})}function Yn(e,r){var s=Re;return $e||typeof WebAssembly.instantiateStreaming!="function"||Sr(s)||s.startsWith("file://")||At||typeof fetch!="function"?Ar(s,e,r):fetch(s,{credentials:"same-origin"}).then(l=>WebAssembly.instantiateStreaming(l,e).then(r,function(d){return pe("wasm streaming compile failed: "+d),pe("falling back to ArrayBuffer instantiation"),Ar(s,e,r)}))}function qn(e){this.name="ExitStatus",this.message=`Program terminated with exit(${e})`,this.status=e}var zi=e=>{for(;0<e.length;)e.shift()(h)},Cr=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,be=(e,r,s)=>{var l=r+s;for(s=r;e[s]&&!(s>=l);)++s;if(16<s-r&&e.buffer&&Cr)return Cr.decode(e.subarray(r,s));for(l="";r<s;){var d=e[r++];if(d&128){var m=e[r++]&63;if((d&224)==192)l+=String.fromCharCode((d&31)<<6|m);else{var b=e[r++]&63;d=(d&240)==224?(d&15)<<12|m<<6|b:(d&7)<<18|m<<12|b<<6|e[r++]&63,65536>d?l+=String.fromCharCode(d):(d-=65536,l+=String.fromCharCode(55296|d>>10,56320|d&1023))}}else l+=String.fromCharCode(d)}return l},hi={};function Bi(e){for(;e.length;){var r=e.pop();e.pop()(r)}}function je(e){return this.fromWireType($[e>>2])}var Ne={},Ae={},ci={},_r=void 0;function ui(e){throw new _r(e)}function Jt(e,r,s){function l(v){v=s(v),v.length!==e.length&&ui("Mismatched type converter count");for(var y=0;y<e.length;++y)ae(e[y],v[y])}e.forEach(function(v){ci[v]=r});var d=Array(r.length),m=[],b=0;r.forEach((v,y)=>{Ae.hasOwnProperty(v)?d[y]=Ae[v]:(m.push(v),Ne.hasOwnProperty(v)||(Ne[v]=[]),Ne[v].push(()=>{d[y]=Ae[v],++b,b===m.length&&l(d)}))}),m.length===0&&l(d)}function di(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError(`Unknown type size: ${e}`)}}var Er=void 0;function _t(e){for(var r="";ot[e];)r+=Er[ot[e++]];return r}var ke=void 0;function ft(e){throw new ke(e)}function Xn(e,r,s={}){var l=r.name;if(e||ft(`type "${l}" must have a positive integer typeid pointer`),Ae.hasOwnProperty(e)){if(s.Wf)return;ft(`Cannot register type '${l}' twice`)}Ae[e]=r,delete ci[e],Ne.hasOwnProperty(e)&&(r=Ne[e],delete Ne[e],r.forEach(d=>d()))}function ae(e,r,s={}){if(!("argPackAdvance"in r))throw new TypeError("registerType registeredInstance requires argPackAdvance");Xn(e,r,s)}function Ui(e){ft(e.Jd.Vd.Pd.name+" instance already deleted")}var Wi=!1;function Tr(){}function Fr(e){--e.count.value,e.count.value===0&&(e.Yd?e.ee.ke(e.Yd):e.Vd.Pd.ke(e.Rd))}function Mr(e,r,s){return r===s?e:s.$d===void 0?null:(e=Mr(e,r,s.$d),e===null?null:s.Mf(e))}var xr={},He=[];function $i(){for(;He.length;){var e=He.pop();e.Jd.Ee=!1,e.delete()}}var Ke=void 0,Ve={};function Jn(e,r){for(r===void 0&&ft("ptr should not be undefined");e.$d;)r=e.Oe(r),e=e.$d;return Ve[r]}function fi(e,r){return r.Vd&&r.Rd||ui("makeClassHandle requires ptr and ptrType"),!!r.ee!=!!r.Yd&&ui("Both smartPtrType and smartPtr must be specified"),r.count={value:1},Ye(Object.create(e,{Jd:{value:r}}))}function Ye(e){return typeof FinalizationRegistry>"u"?(Ye=r=>r,e):(Wi=new FinalizationRegistry(r=>{Fr(r.Jd)}),Ye=r=>{var s=r.Jd;return s.Yd&&Wi.register(r,{Jd:s},r),r},Tr=r=>{Wi.unregister(r)},Ye(e))}function ge(){}function Rr(e){if(e===void 0)return"_unknown";e=e.replace(/[^a-zA-Z0-9_]/g,"$");var r=e.charCodeAt(0);return 48<=r&&57>=r?`_${e}`:e}function Gi(e,r){return e=Rr(e),{[e]:function(){return r.apply(this,arguments)}}[e]}function ji(e,r,s){if(e[r].Xd===void 0){var l=e[r];e[r]=function(){return e[r].Xd.hasOwnProperty(arguments.length)||ft(`Function '${s}' called with an invalid number of arguments (${arguments.length}) - expects one of (${e[r].Xd})!`),e[r].Xd[arguments.length].apply(this,arguments)},e[r].Xd=[],e[r].Xd[l.Ce]=l}}function Hi(e,r,s){h.hasOwnProperty(e)?((s===void 0||h[e].Xd!==void 0&&h[e].Xd[s]!==void 0)&&ft(`Cannot register public name '${e}' twice`),ji(h,e,e),h.hasOwnProperty(s)&&ft(`Cannot register multiple overloads of a function with the same number of arguments (${s})!`),h[e].Xd[s]=r):(h[e]=r,s!==void 0&&(h[e].tg=s))}function Qn(e,r,s,l,d,m,b,v){this.name=e,this.constructor=r,this.Fe=s,this.ke=l,this.$d=d,this.Rf=m,this.Oe=b,this.Mf=v,this.cg=[]}function Ki(e,r,s){for(;r!==s;)r.Oe||ft(`Expected null or instance of ${s.name}, got an instance of ${r.name}`),e=r.Oe(e),r=r.$d;return e}function Zn(e,r){return r===null?(this.gf&&ft(`null is not a valid ${this.name}`),0):(r.Jd||ft(`Cannot pass "${Yi(r)}" as a ${this.name}`),r.Jd.Rd||ft(`Cannot pass deleted object as a pointer of type ${this.name}`),Ki(r.Jd.Rd,r.Jd.Vd.Pd,this.Pd))}function ts(e,r){if(r===null){if(this.gf&&ft(`null is not a valid ${this.name}`),this.Ve){var s=this.hf();return e!==null&&e.push(this.ke,s),s}return 0}if(r.Jd||ft(`Cannot pass "${Yi(r)}" as a ${this.name}`),r.Jd.Rd||ft(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.Ue&&r.Jd.Vd.Ue&&ft(`Cannot convert argument of type ${r.Jd.ee?r.Jd.ee.name:r.Jd.Vd.name} to parameter type ${this.name}`),s=Ki(r.Jd.Rd,r.Jd.Vd.Pd,this.Pd),this.Ve)switch(r.Jd.Yd===void 0&&ft("Passing raw pointer to smart pointer is illegal"),this.hg){case 0:r.Jd.ee===this?s=r.Jd.Yd:ft(`Cannot convert argument of type ${r.Jd.ee?r.Jd.ee.name:r.Jd.Vd.name} to parameter type ${this.name}`);break;case 1:s=r.Jd.Yd;break;case 2:if(r.Jd.ee===this)s=r.Jd.Yd;else{var l=r.clone();s=this.dg(s,Ht(function(){l.delete()})),e!==null&&e.push(this.ke,s)}break;default:ft("Unsupporting sharing policy")}return s}function es(e,r){return r===null?(this.gf&&ft(`null is not a valid ${this.name}`),0):(r.Jd||ft(`Cannot pass "${Yi(r)}" as a ${this.name}`),r.Jd.Rd||ft(`Cannot pass deleted object as a pointer of type ${this.name}`),r.Jd.Vd.Ue&&ft(`Cannot convert argument of type ${r.Jd.Vd.name} to parameter type ${this.name}`),Ki(r.Jd.Rd,r.Jd.Vd.Pd,this.Pd))}function oe(e,r,s,l,d,m,b,v,y,A,O){this.name=e,this.Pd=r,this.gf=s,this.Ue=l,this.Ve=d,this.bg=m,this.hg=b,this.vf=v,this.hf=y,this.dg=A,this.ke=O,d||r.$d!==void 0?this.toWireType=ts:(this.toWireType=l?Zn:es,this.de=null)}function Nr(e,r,s){h.hasOwnProperty(e)||ui("Replacing nonexistant public symbol"),h[e].Xd!==void 0&&s!==void 0?h[e].Xd[s]=r:(h[e]=r,h[e].Ce=s)}var is=(e,r)=>{var s=[];return function(){if(s.length=0,Object.assign(s,arguments),e.includes("j")){var l=h["dynCall_"+e];l=s&&s.length?l.apply(null,[r].concat(s)):l.call(null,r)}else l=Mt.get(r).apply(null,s);return l}};function Nt(e,r){e=_t(e);var s=e.includes("j")?is(e,r):Mt.get(r);return typeof s!="function"&&ft(`unknown function pointer with signature ${e}: ${r}`),s}var kr=void 0;function Or(e){e=en(e);var r=_t(e);return ue(e),r}function qe(e,r){function s(m){d[m]||Ae[m]||(ci[m]?ci[m].forEach(s):(l.push(m),d[m]=!0))}var l=[],d={};throw r.forEach(s),new kr(`${e}: `+l.map(Or).join([", "]))}function pi(e,r,s,l,d){var m=r.length;2>m&&ft("argTypes array size mismatch! Must at least get return value and 'this' types!");var b=r[1]!==null&&s!==null,v=!1;for(s=1;s<r.length;++s)if(r[s]!==null&&r[s].de===void 0){v=!0;break}var y=r[0].name!=="void",A=m-2,O=Array(A),D=[],H=[];return function(){if(arguments.length!==A&&ft(`function ${e} called with ${arguments.length} arguments, expected ${A} args!`),H.length=0,D.length=b?2:1,D[0]=d,b){var T=r[1].toWireType(H,this);D[1]=T}for(var Y=0;Y<A;++Y)O[Y]=r[Y+2].toWireType(H,arguments[Y]),D.push(O[Y]);if(Y=l.apply(null,D),v)Bi(H);else for(var nt=b?1:2;nt<r.length;nt++){var rt=nt===1?T:O[nt-2];r[nt].de!==null&&r[nt].de(rt)}return T=y?r[0].fromWireType(Y):void 0,T}}function mi(e,r){for(var s=[],l=0;l<e;l++)s.push(wt[r+4*l>>2]);return s}function Ir(){this.je=[void 0],this.sf=[]}var Gt=new Ir;function Vi(e){e>=Gt.Ge&&--Gt.get(e).wf===0&&Gt.Bf(e)}var jt=e=>(e||ft("Cannot use deleted val. handle = "+e),Gt.get(e).value),Ht=e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return Gt.Af({wf:1,value:e})}};function rs(e,r,s){switch(r){case 0:return function(l){return this.fromWireType((s?se:ot)[l])};case 1:return function(l){return this.fromWireType((s?me:xe)[l>>1])};case 2:return function(l){return this.fromWireType((s?$:wt)[l>>2])};default:throw new TypeError("Unknown integer type: "+e)}}function Xe(e,r){var s=Ae[e];return s===void 0&&ft(r+" has unknown type "+Or(e)),s}function Yi(e){if(e===null)return"null";var r=typeof e;return r==="object"||r==="array"||r==="function"?e.toString():""+e}function ns(e,r){switch(r){case 2:return function(s){return this.fromWireType(Z[s>>2])};case 3:return function(s){return this.fromWireType(mr[s>>3])};default:throw new TypeError("Unknown float type: "+e)}}function ss(e,r,s){switch(r){case 0:return s?function(l){return se[l]}:function(l){return ot[l]};case 1:return s?function(l){return me[l>>1]}:function(l){return xe[l>>1]};case 2:return s?function(l){return $[l>>2]}:function(l){return wt[l>>2]};default:throw new TypeError("Unknown integer type: "+e)}}var Qt=(e,r,s,l)=>{if(!(0<l))return 0;var d=s;l=s+l-1;for(var m=0;m<e.length;++m){var b=e.charCodeAt(m);if(55296<=b&&57343>=b){var v=e.charCodeAt(++m);b=65536+((b&1023)<<10)|v&1023}if(127>=b){if(s>=l)break;r[s++]=b}else{if(2047>=b){if(s+1>=l)break;r[s++]=192|b>>6}else{if(65535>=b){if(s+2>=l)break;r[s++]=224|b>>12}else{if(s+3>=l)break;r[s++]=240|b>>18,r[s++]=128|b>>12&63}r[s++]=128|b>>6&63}r[s++]=128|b&63}}return r[s]=0,s-d},Zt=e=>{for(var r=0,s=0;s<e.length;++s){var l=e.charCodeAt(s);127>=l?r++:2047>=l?r+=2:55296<=l&&57343>=l?(r+=4,++s):r+=3}return r},Lr=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,as=(e,r)=>{for(var s=e>>1,l=s+r/2;!(s>=l)&&xe[s];)++s;if(s<<=1,32<s-e&&Lr)return Lr.decode(ot.subarray(e,s));for(s="",l=0;!(l>=r/2);++l){var d=me[e+2*l>>1];if(d==0)break;s+=String.fromCharCode(d)}return s},os=(e,r,s)=>{if(s===void 0&&(s=2147483647),2>s)return 0;s-=2;var l=r;s=s<2*e.length?s/2:e.length;for(var d=0;d<s;++d)me[r>>1]=e.charCodeAt(d),r+=2;return me[r>>1]=0,r-l},ls=e=>2*e.length,hs=(e,r)=>{for(var s=0,l="";!(s>=r/4);){var d=$[e+4*s>>2];if(d==0)break;++s,65536<=d?(d-=65536,l+=String.fromCharCode(55296|d>>10,56320|d&1023)):l+=String.fromCharCode(d)}return l},cs=(e,r,s)=>{if(s===void 0&&(s=2147483647),4>s)return 0;var l=r;s=l+s-4;for(var d=0;d<e.length;++d){var m=e.charCodeAt(d);if(55296<=m&&57343>=m){var b=e.charCodeAt(++d);m=65536+((m&1023)<<10)|b&1023}if($[r>>2]=m,r+=4,r+4>s)break}return $[r>>2]=0,r-l},us=e=>{for(var r=0,s=0;s<e.length;++s){var l=e.charCodeAt(s);55296<=l&&57343>=l&&++s,r+=4}return r},ds={};function gi(e){var r=ds[e];return r===void 0?_t(e):r}var vi=[];function Dr(){function e(r){r.$$$embind_global$$$=r;var s=typeof $$$embind_global$$$=="object"&&r.$$$embind_global$$$==r;return s||delete r.$$$embind_global$$$,s}if(typeof globalThis=="object")return globalThis;if(typeof $$$embind_global$$$=="object"||(typeof lr=="object"&&e(lr)?$$$embind_global$$$=lr:typeof self=="object"&&e(self)&&($$$embind_global$$$=self),typeof $$$embind_global$$$=="object"))return $$$embind_global$$$;throw Error("unable to get global object.")}function fs(e){var r=vi.length;return vi.push(e),r}function ps(e,r){for(var s=Array(e),l=0;l<e;++l)s[l]=Xe(wt[r+4*l>>2],"parameter "+l);return s}var zr=[];function ms(e){var r=Array(e+1);return function(s,l,d){r[0]=s;for(var m=0;m<e;++m){var b=Xe(wt[l+4*m>>2],"parameter "+m);r[m+1]=b.readValueFromPointer(d),d+=b.argPackAdvance}return s=new(s.bind.apply(s,r)),Ht(s)}}var Br={};function gs(e){var r=e.getExtension("ANGLE_instanced_arrays");r&&(e.vertexAttribDivisor=function(s,l){r.vertexAttribDivisorANGLE(s,l)},e.drawArraysInstanced=function(s,l,d,m){r.drawArraysInstancedANGLE(s,l,d,m)},e.drawElementsInstanced=function(s,l,d,m,b){r.drawElementsInstancedANGLE(s,l,d,m,b)})}function vs(e){var r=e.getExtension("OES_vertex_array_object");r&&(e.createVertexArray=function(){return r.createVertexArrayOES()},e.deleteVertexArray=function(s){r.deleteVertexArrayOES(s)},e.bindVertexArray=function(s){r.bindVertexArrayOES(s)},e.isVertexArray=function(s){return r.isVertexArrayOES(s)})}function ys(e){var r=e.getExtension("WEBGL_draw_buffers");r&&(e.drawBuffers=function(s,l){r.drawBuffersWEBGL(s,l)})}var Ur=1,yi=[],te=[],wi=[],Je=[],Kt=[],ee=[],Si=[],le=[],Ce=[],_e=[],Wr={},$r={},Gr=4;function St(e){Pi||(Pi=e)}function Oe(e){for(var r=Ur++,s=e.length;s<r;s++)e[s]=null;return r}function ws(e,r){e.Ge||(e.Ge=e.getContext,e.getContext=function(l,d){return d=e.Ge(l,d),l=="webgl"==d instanceof WebGLRenderingContext?d:null});var s=1<r.majorVersion?e.getContext("webgl2",r):e.getContext("webgl",r);return s?Ss(s,r):0}function Ss(e,r){var s=Oe(le),l={handle:s,attributes:r,version:r.majorVersion,fe:e};return e.canvas&&(e.canvas.zf=l),le[s]=l,(typeof r.Nf>"u"||r.Nf)&&Ps(l),s}function jr(e){return it=le[e],h.rg=_=it&&it.fe,!(e&&!_)}function Ps(e){if(e||(e=it),!e.Xf){e.Xf=!0;var r=e.fe;gs(r),vs(r),ys(r),r.pf=r.getExtension("WEBGL_draw_instanced_base_vertex_base_instance"),r.uf=r.getExtension("WEBGL_multi_draw_instanced_base_vertex_base_instance"),2<=e.version&&(r.qf=r.getExtension("EXT_disjoint_timer_query_webgl2")),(2>e.version||!r.qf)&&(r.qf=r.getExtension("EXT_disjoint_timer_query")),r.sg=r.getExtension("WEBGL_multi_draw"),(r.getSupportedExtensions()||[]).forEach(function(s){s.includes("lose_context")||s.includes("debug")||r.getExtension(s)})}}var it,Pi,qi={},Hr=()=>{if(!Xi){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:U||"./this.program"},r;for(r in qi)qi[r]===void 0?delete e[r]:e[r]=qi[r];var s=[];for(r in e)s.push(`${r}=${e[r]}`);Xi=s}return Xi},Xi,bs=[null,[],[]];function Kr(e){_.bindVertexArray(Si[e])}function Vr(e,r){for(var s=0;s<e;s++){var l=$[r+4*s>>2];_.deleteVertexArray(Si[l]),Si[l]=null}}var bi=[];function Yr(e,r,s,l){_.drawElements(e,r,s,l)}function Ie(e,r,s,l){for(var d=0;d<e;d++){var m=_[s](),b=m&&Oe(l);m?(m.name=b,l[b]=m):St(1282),$[r+4*d>>2]=b}}function qr(e,r){Ie(e,r,"createVertexArray",Si)}function Xr(e,r,s){if(r){var l=void 0;switch(e){case 36346:l=1;break;case 36344:s!=0&&s!=1&&St(1280);return;case 34814:case 36345:l=0;break;case 34466:var d=_.getParameter(34467);l=d?d.length:0;break;case 33309:if(2>it.version){St(1282);return}l=2*(_.getSupportedExtensions()||[]).length;break;case 33307:case 33308:if(2>it.version){St(1280);return}l=e==33307?3:0}if(l===void 0)switch(d=_.getParameter(e),typeof d){case"number":l=d;break;case"boolean":l=d?1:0;break;case"string":St(1280);return;case"object":if(d===null)switch(e){case 34964:case 35725:case 34965:case 36006:case 36007:case 32873:case 34229:case 36662:case 36663:case 35053:case 35055:case 36010:case 35097:case 35869:case 32874:case 36389:case 35983:case 35368:case 34068:l=0;break;default:St(1280);return}else{if(d instanceof Float32Array||d instanceof Uint32Array||d instanceof Int32Array||d instanceof Array){for(e=0;e<d.length;++e)switch(s){case 0:$[r+4*e>>2]=d[e];break;case 2:Z[r+4*e>>2]=d[e];break;case 4:se[r+e>>0]=d[e]?1:0}return}try{l=d.name|0}catch(m){St(1280),pe("GL_INVALID_ENUM in glGet"+s+"v: Unknown object returned from WebGL getParameter("+e+")! (error: "+m+")");return}}break;default:St(1280),pe("GL_INVALID_ENUM in glGet"+s+"v: Native code calling glGet"+s+"v("+e+") and it returns "+d+" of type "+typeof d+"!");return}switch(s){case 1:s=l,wt[r>>2]=s,wt[r+4>>2]=(s-wt[r>>2])/4294967296;break;case 0:$[r>>2]=l;break;case 2:Z[r>>2]=l;break;case 4:se[r>>0]=l?1:0}}else St(1281)}var Qe=e=>{var r=Zt(e)+1,s=Ei(r);return s&&Qt(e,ot,s,r),s};function Jr(e){return e.slice(-1)=="]"&&e.lastIndexOf("[")}function Ai(e){return e-=5120,e==0?se:e==1?ot:e==2?me:e==4?$:e==6?Z:e==5||e==28922||e==28520||e==30779||e==30782?wt:xe}function Ji(e,r,s,l,d){e=Ai(e);var m=31-Math.clz32(e.BYTES_PER_ELEMENT),b=Gr;return e.subarray(d>>m,d+l*(s*({5:3,6:4,8:2,29502:3,29504:4,26917:2,26918:2,29846:3,29847:4}[r-6402]||1)*(1<<m)+b-1&-b)>>m)}function gt(e){var r=_.Kf;if(r){var s=r.Ne[e];return typeof s=="number"&&(r.Ne[e]=s=_.getUniformLocation(r,r.xf[e]+(0<s?"["+s+"]":""))),s}St(1282)}var ve=[],Ze=[],Ci=e=>e%4===0&&(e%100!==0||e%400===0),Qr=[31,29,31,30,31,30,31,31,30,31,30,31],Zr=[31,28,31,30,31,30,31,31,30,31,30,31];function As(e){var r=Array(Zt(e)+1);return Qt(e,r,0,r.length),r}var Cs=(e,r,s,l)=>{function d(T,Y,nt){for(T=typeof T=="number"?T.toString():T||"";T.length<Y;)T=nt[0]+T;return T}function m(T,Y){return d(T,Y,"0")}function b(T,Y){function nt(Bt){return 0>Bt?-1:0<Bt?1:0}var rt;return(rt=nt(T.getFullYear()-Y.getFullYear()))===0&&(rt=nt(T.getMonth()-Y.getMonth()))===0&&(rt=nt(T.getDate()-Y.getDate())),rt}function v(T){switch(T.getDay()){case 0:return new Date(T.getFullYear()-1,11,29);case 1:return T;case 2:return new Date(T.getFullYear(),0,3);case 3:return new Date(T.getFullYear(),0,2);case 4:return new Date(T.getFullYear(),0,1);case 5:return new Date(T.getFullYear()-1,11,31);case 6:return new Date(T.getFullYear()-1,11,30)}}function y(T){var Y=T.oe;for(T=new Date(new Date(T.pe+1900,0,1).getTime());0<Y;){var nt=T.getMonth(),rt=(Ci(T.getFullYear())?Qr:Zr)[nt];if(Y>rt-T.getDate())Y-=rt-T.getDate()+1,T.setDate(1),11>nt?T.setMonth(nt+1):(T.setMonth(0),T.setFullYear(T.getFullYear()+1));else{T.setDate(T.getDate()+Y);break}}return nt=new Date(T.getFullYear()+1,0,4),Y=v(new Date(T.getFullYear(),0,4)),nt=v(nt),0>=b(Y,T)?0>=b(nt,T)?T.getFullYear()+1:T.getFullYear():T.getFullYear()-1}var A=$[l+40>>2];l={pg:$[l>>2],og:$[l+4>>2],Ze:$[l+8>>2],jf:$[l+12>>2],$e:$[l+16>>2],pe:$[l+20>>2],he:$[l+24>>2],oe:$[l+28>>2],vg:$[l+32>>2],ng:$[l+36>>2],qg:A&&A?be(ot,A):""},s=s?be(ot,s):"",A={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var O in A)s=s.replace(new RegExp(O,"g"),A[O]);var D="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),H="January February March April May June July August September October November December".split(" ");A={"%a":T=>D[T.he].substring(0,3),"%A":T=>D[T.he],"%b":T=>H[T.$e].substring(0,3),"%B":T=>H[T.$e],"%C":T=>m((T.pe+1900)/100|0,2),"%d":T=>m(T.jf,2),"%e":T=>d(T.jf,2," "),"%g":T=>y(T).toString().substring(2),"%G":T=>y(T),"%H":T=>m(T.Ze,2),"%I":T=>(T=T.Ze,T==0?T=12:12<T&&(T-=12),m(T,2)),"%j":T=>{for(var Y=0,nt=0;nt<=T.$e-1;Y+=(Ci(T.pe+1900)?Qr:Zr)[nt++]);return m(T.jf+Y,3)},"%m":T=>m(T.$e+1,2),"%M":T=>m(T.og,2),"%n":()=>`
2
+ `,"%p":T=>0<=T.Ze&&12>T.Ze?"AM":"PM","%S":T=>m(T.pg,2),"%t":()=>" ","%u":T=>T.he||7,"%U":T=>m(Math.floor((T.oe+7-T.he)/7),2),"%V":T=>{var Y=Math.floor((T.oe+7-(T.he+6)%7)/7);if(2>=(T.he+371-T.oe-2)%7&&Y++,Y)Y==53&&(nt=(T.he+371-T.oe)%7,nt==4||nt==3&&Ci(T.pe)||(Y=1));else{Y=52;var nt=(T.he+7-T.oe-1)%7;(nt==4||nt==5&&Ci(T.pe%400-1))&&Y++}return m(Y,2)},"%w":T=>T.he,"%W":T=>m(Math.floor((T.oe+7-(T.he+6)%7)/7),2),"%y":T=>(T.pe+1900).toString().substring(2),"%Y":T=>T.pe+1900,"%z":T=>{T=T.ng;var Y=0<=T;return T=Math.abs(T)/60,(Y?"+":"-")+("0000"+(T/60*100+T%60)).slice(-4)},"%Z":T=>T.qg,"%%":()=>"%"},s=s.replace(/%%/g,"\0\0");for(O in A)s.includes(O)&&(s=s.replace(new RegExp(O,"g"),A[O](l)));return s=s.replace(/\0\0/g,"%"),O=As(s),O.length>r?0:(se.set(O,e),O.length-1)};_r=h.InternalError=class extends Error{constructor(e){super(e),this.name="InternalError"}};for(var tn=Array(256),_i=0;256>_i;++_i)tn[_i]=String.fromCharCode(_i);Er=tn,ke=h.BindingError=class extends Error{constructor(e){super(e),this.name="BindingError"}},ge.prototype.isAliasOf=function(e){if(!(this instanceof ge&&e instanceof ge))return!1;var r=this.Jd.Vd.Pd,s=this.Jd.Rd,l=e.Jd.Vd.Pd;for(e=e.Jd.Rd;r.$d;)s=r.Oe(s),r=r.$d;for(;l.$d;)e=l.Oe(e),l=l.$d;return r===l&&s===e},ge.prototype.clone=function(){if(this.Jd.Rd||Ui(this),this.Jd.Me)return this.Jd.count.value+=1,this;var e=Ye,r=Object,s=r.create,l=Object.getPrototypeOf(this),d=this.Jd;return e=e(s.call(r,l,{Jd:{value:{count:d.count,Ee:d.Ee,Me:d.Me,Rd:d.Rd,Vd:d.Vd,Yd:d.Yd,ee:d.ee}}})),e.Jd.count.value+=1,e.Jd.Ee=!1,e},ge.prototype.delete=function(){this.Jd.Rd||Ui(this),this.Jd.Ee&&!this.Jd.Me&&ft("Object already scheduled for deletion"),Tr(this),Fr(this.Jd),this.Jd.Me||(this.Jd.Yd=void 0,this.Jd.Rd=void 0)},ge.prototype.isDeleted=function(){return!this.Jd.Rd},ge.prototype.deleteLater=function(){return this.Jd.Rd||Ui(this),this.Jd.Ee&&!this.Jd.Me&&ft("Object already scheduled for deletion"),He.push(this),He.length===1&&Ke&&Ke($i),this.Jd.Ee=!0,this},h.getInheritedInstanceCount=function(){return Object.keys(Ve).length},h.getLiveInheritedInstances=function(){var e=[],r;for(r in Ve)Ve.hasOwnProperty(r)&&e.push(Ve[r]);return e},h.flushPendingDeletes=$i,h.setDelayFunction=function(e){Ke=e,He.length&&Ke&&Ke($i)},oe.prototype.Sf=function(e){return this.vf&&(e=this.vf(e)),e},oe.prototype.nf=function(e){this.ke&&this.ke(e)},oe.prototype.argPackAdvance=8,oe.prototype.readValueFromPointer=je,oe.prototype.deleteObject=function(e){e!==null&&e.delete()},oe.prototype.fromWireType=function(e){function r(){return this.Ve?fi(this.Pd.Fe,{Vd:this.bg,Rd:s,ee:this,Yd:e}):fi(this.Pd.Fe,{Vd:this,Rd:e})}var s=this.Sf(e);if(!s)return this.nf(e),null;var l=Jn(this.Pd,s);if(l!==void 0)return l.Jd.count.value===0?(l.Jd.Rd=s,l.Jd.Yd=e,l.clone()):(l=l.clone(),this.nf(e),l);if(l=this.Pd.Rf(s),l=xr[l],!l)return r.call(this);l=this.Ue?l.If:l.pointerType;var d=Mr(s,this.Pd,l.Pd);return d===null?r.call(this):this.Ve?fi(l.Pd.Fe,{Vd:l,Rd:d,ee:this,Yd:e}):fi(l.Pd.Fe,{Vd:l,Rd:d})},kr=h.UnboundTypeError=function(e,r){var s=Gi(r,function(l){this.name=r,this.message=l,l=Error(l).stack,l!==void 0&&(this.stack=this.toString()+`
3
+ `+l.replace(/^Error(:[^\n]*)?\n/,""))});return s.prototype=Object.create(e.prototype),s.prototype.constructor=s,s.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},s}(Error,"UnboundTypeError"),Object.assign(Ir.prototype,{get(e){return this.je[e]},has(e){return this.je[e]!==void 0},Af(e){var r=this.sf.pop()||this.je.length;return this.je[r]=e,r},Bf(e){this.je[e]=void 0,this.sf.push(e)}}),Gt.je.push({value:void 0},{value:null},{value:!0},{value:!1}),Gt.Ge=Gt.je.length,h.count_emval_handles=function(){for(var e=0,r=Gt.Ge;r<Gt.je.length;++r)Gt.je[r]!==void 0&&++e;return e};for(var _,$t=0;32>$t;++$t)bi.push(Array($t));var _s=new Float32Array(288);for($t=0;288>$t;++$t)ve[$t]=_s.subarray(0,$t+1);var Es=new Int32Array(288);for($t=0;288>$t;++$t)Ze[$t]=Es.subarray(0,$t+1);var Ts={T:function(){return 0},Bb:()=>{},Db:function(){return 0},yb:()=>{},zb:()=>{},U:function(){},Ab:()=>{},C:function(e){var r=hi[e];delete hi[e];var s=r.hf,l=r.ke,d=r.rf,m=d.map(b=>b.Vf).concat(d.map(b=>b.fg));Jt([e],m,b=>{var v={};return d.forEach((y,A)=>{var O=b[A],D=y.Tf,H=y.Uf,T=b[A+d.length],Y=y.eg,nt=y.gg;v[y.Of]={read:rt=>O.fromWireType(D(H,rt)),write:(rt,Bt)=>{var Rt=[];Y(nt,rt,T.toWireType(Rt,Bt)),Bi(Rt)}}}),[{name:r.name,fromWireType:function(y){var A={},O;for(O in v)A[O]=v[O].read(y);return l(y),A},toWireType:function(y,A){for(var O in v)if(!(O in A))throw new TypeError(`Missing field: "${O}"`);var D=s();for(O in v)v[O].write(D,A[O]);return y!==null&&y.push(l,D),D},argPackAdvance:8,readValueFromPointer:je,de:l}]})},qb:function(){},Hb:function(e,r,s,l,d){var m=di(s);r=_t(r),ae(e,{name:r,fromWireType:function(b){return!!b},toWireType:function(b,v){return v?l:d},argPackAdvance:8,readValueFromPointer:function(b){if(s===1)var v=se;else if(s===2)v=me;else if(s===4)v=$;else throw new TypeError("Unknown boolean type size: "+r);return this.fromWireType(v[b>>m])},de:null})},m:function(e,r,s,l,d,m,b,v,y,A,O,D,H){O=_t(O),m=Nt(d,m),v&&(v=Nt(b,v)),A&&(A=Nt(y,A)),H=Nt(D,H);var T=Rr(O);Hi(T,function(){qe(`Cannot construct ${O} due to unbound types`,[l])}),Jt([e,r,s],l?[l]:[],function(Y){if(Y=Y[0],l)var nt=Y.Pd,rt=nt.Fe;else rt=ge.prototype;Y=Gi(T,function(){if(Object.getPrototypeOf(this)!==Bt)throw new ke("Use 'new' to construct "+O);if(Rt.ne===void 0)throw new ke(O+" has no accessible constructor");var ei=Rt.ne[arguments.length];if(ei===void 0)throw new ke(`Tried to invoke ctor of ${O} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(Rt.ne).toString()}) parameters instead!`);return ei.apply(this,arguments)});var Bt=Object.create(rt,{constructor:{value:Y}});Y.prototype=Bt;var Rt=new Qn(O,Y,Bt,H,nt,m,v,A);Rt.$d&&(Rt.$d.Pe===void 0&&(Rt.$d.Pe=[]),Rt.$d.Pe.push(Rt)),nt=new oe(O,Rt,!0,!1,!1),rt=new oe(O+"*",Rt,!1,!1,!1);var ti=new oe(O+" const*",Rt,!1,!0,!1);return xr[e]={pointerType:rt,If:ti},Nr(T,Y),[nt,rt,ti]})},f:function(e,r,s,l,d,m,b){var v=mi(s,l);r=_t(r),m=Nt(d,m),Jt([],[e],function(y){function A(){qe(`Cannot call ${O} due to unbound types`,v)}y=y[0];var O=`${y.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]);var D=y.Pd.constructor;return D[r]===void 0?(A.Ce=s-1,D[r]=A):(ji(D,r,O),D[r].Xd[s-1]=A),Jt([],v,function(H){if(H=[H[0],null].concat(H.slice(1)),H=pi(O,H,null,m,b),D[r].Xd===void 0?(H.Ce=s-1,D[r]=H):D[r].Xd[s-1]=H,y.Pd.Pe)for(const T of y.Pd.Pe)T.constructor.hasOwnProperty(r)||(T.constructor[r]=H);return[]}),[]})},A:function(e,r,s,l,d,m){var b=mi(r,s);d=Nt(l,d),Jt([],[e],function(v){v=v[0];var y=`constructor ${v.name}`;if(v.Pd.ne===void 0&&(v.Pd.ne=[]),v.Pd.ne[r-1]!==void 0)throw new ke(`Cannot register multiple constructors with identical number of parameters (${r-1}) for class '${v.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return v.Pd.ne[r-1]=()=>{qe(`Cannot construct ${v.name} due to unbound types`,b)},Jt([],b,function(A){return A.splice(1,0,null),v.Pd.ne[r-1]=pi(y,A,null,d,m),[]}),[]})},b:function(e,r,s,l,d,m,b,v){var y=mi(s,l);r=_t(r),m=Nt(d,m),Jt([],[e],function(A){function O(){qe(`Cannot call ${D} due to unbound types`,y)}A=A[0];var D=`${A.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]),v&&A.Pd.cg.push(r);var H=A.Pd.Fe,T=H[r];return T===void 0||T.Xd===void 0&&T.className!==A.name&&T.Ce===s-2?(O.Ce=s-2,O.className=A.name,H[r]=O):(ji(H,r,D),H[r].Xd[s-2]=O),Jt([],y,function(Y){return Y=pi(D,Y,A,m,b),H[r].Xd===void 0?(Y.Ce=s-2,H[r]=Y):H[r].Xd[s-2]=Y,[]}),[]})},t:function(e,r,s){e=_t(e),Jt([],[r],function(l){return l=l[0],h[e]=l.fromWireType(s),[]})},Gb:function(e,r){r=_t(r),ae(e,{name:r,fromWireType:function(s){var l=jt(s);return Vi(s),l},toWireType:function(s,l){return Ht(l)},argPackAdvance:8,readValueFromPointer:je,de:null})},l:function(e,r,s,l){function d(){}s=di(s),r=_t(r),d.values={},ae(e,{name:r,constructor:d,fromWireType:function(m){return this.constructor.values[m]},toWireType:function(m,b){return b.value},argPackAdvance:8,readValueFromPointer:rs(r,s,l),de:null}),Hi(r,d)},c:function(e,r,s){var l=Xe(e,"enum");r=_t(r),e=l.constructor,l=Object.create(l.constructor.prototype,{value:{value:s},constructor:{value:Gi(`${l.name}_${r}`,function(){})}}),e.values[s]=l,e[r]=l},W:function(e,r,s){s=di(s),r=_t(r),ae(e,{name:r,fromWireType:function(l){return l},toWireType:function(l,d){return d},argPackAdvance:8,readValueFromPointer:ns(r,s),de:null})},y:function(e,r,s,l,d,m){var b=mi(r,s);e=_t(e),d=Nt(l,d),Hi(e,function(){qe(`Cannot call ${e} due to unbound types`,b)},r-1),Jt([],b,function(v){return v=[v[0],null].concat(v.slice(1)),Nr(e,pi(e,v,null,d,m),r-1),[]})},E:function(e,r,s,l,d){r=_t(r),d===-1&&(d=4294967295),d=di(s);var m=v=>v;if(l===0){var b=32-8*s;m=v=>v<<b>>>b}s=r.includes("unsigned")?function(v,y){return y>>>0}:function(v,y){return y},ae(e,{name:r,fromWireType:m,toWireType:s,argPackAdvance:8,readValueFromPointer:ss(r,d,l!==0),de:null})},s:function(e,r,s){function l(m){m>>=2;var b=wt;return new d(b.buffer,b[m+1],b[m])}var d=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][r];s=_t(s),ae(e,{name:s,fromWireType:l,argPackAdvance:8,readValueFromPointer:l},{Wf:!0})},q:function(e,r,s,l,d,m,b,v,y,A,O,D){s=_t(s),m=Nt(d,m),v=Nt(b,v),A=Nt(y,A),D=Nt(O,D),Jt([e],[r],function(H){return H=H[0],[new oe(s,H.Pd,!1,!1,!0,H,l,m,v,A,D)]})},V:function(e,r){r=_t(r);var s=r==="std::string";ae(e,{name:r,fromWireType:function(l){var d=wt[l>>2],m=l+4;if(s)for(var b=m,v=0;v<=d;++v){var y=m+v;if(v==d||ot[y]==0){if(b=b?be(ot,b,y-b):"",A===void 0)var A=b;else A+="\0",A+=b;b=y+1}}else{for(A=Array(d),v=0;v<d;++v)A[v]=String.fromCharCode(ot[m+v]);A=A.join("")}return ue(l),A},toWireType:function(l,d){d instanceof ArrayBuffer&&(d=new Uint8Array(d));var m=typeof d=="string";m||d instanceof Uint8Array||d instanceof Uint8ClampedArray||d instanceof Int8Array||ft("Cannot pass non-string to std::string");var b=s&&m?Zt(d):d.length,v=Ei(4+b+1),y=v+4;if(wt[v>>2]=b,s&&m)Qt(d,ot,y,b+1);else if(m)for(m=0;m<b;++m){var A=d.charCodeAt(m);255<A&&(ue(y),ft("String has UTF-16 code units that do not fit in 8 bits")),ot[y+m]=A}else for(m=0;m<b;++m)ot[y+m]=d[m];return l!==null&&l.push(ue,v),v},argPackAdvance:8,readValueFromPointer:je,de:function(l){ue(l)}})},N:function(e,r,s){if(s=_t(s),r===2)var l=as,d=os,m=ls,b=()=>xe,v=1;else r===4&&(l=hs,d=cs,m=us,b=()=>wt,v=2);ae(e,{name:s,fromWireType:function(y){for(var A=wt[y>>2],O=b(),D,H=y+4,T=0;T<=A;++T){var Y=y+4+T*r;(T==A||O[Y>>v]==0)&&(H=l(H,Y-H),D===void 0?D=H:(D+="\0",D+=H),H=Y+r)}return ue(y),D},toWireType:function(y,A){typeof A!="string"&&ft(`Cannot pass non-string to C++ string type ${s}`);var O=m(A),D=Ei(4+O+r);return wt[D>>2]=O>>v,d(A,D+4,O+r),y!==null&&y.push(ue,D),D},argPackAdvance:8,readValueFromPointer:je,de:function(y){ue(y)}})},D:function(e,r,s,l,d,m){hi[e]={name:_t(r),hf:Nt(s,l),ke:Nt(d,m),rf:[]}},e:function(e,r,s,l,d,m,b,v,y,A){hi[e].rf.push({Of:_t(r),Vf:s,Tf:Nt(l,d),Uf:m,fg:b,eg:Nt(v,y),gg:A})},Ib:function(e,r){r=_t(r),ae(e,{Yf:!0,name:r,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},Fb:()=>!0,ub:()=>{throw 1/0},F:function(e,r,s){e=jt(e),r=Xe(r,"emval::as");var l=[],d=Ht(l);return wt[s>>2]=d,r.toWireType(l,e)},Z:function(e,r,s,l,d){e=vi[e],r=jt(r),s=gi(s);var m=[];return wt[l>>2]=Ht(m),e(r,s,m,d)},w:function(e,r,s,l){e=vi[e],r=jt(r),s=gi(s),e(r,s,null,l)},d:Vi,K:function(e){return e===0?Ht(Dr()):(e=gi(e),Ht(Dr()[e]))},u:function(e,r){var s=ps(e,r),l=s[0];r=l.name+"_$"+s.slice(1).map(function(b){return b.name}).join("_")+"$";var d=zr[r];if(d!==void 0)return d;var m=Array(e-1);return d=fs((b,v,y,A)=>{for(var O=0,D=0;D<e-1;++D)m[D]=s[D+1].readValueFromPointer(A+O),O+=s[D+1].argPackAdvance;for(b=b[v].apply(b,m),D=0;D<e-1;++D)s[D+1].Lf&&s[D+1].Lf(m[D]);if(!l.Yf)return l.toWireType(y,b)}),zr[r]=d},z:function(e,r){return e=jt(e),r=jt(r),Ht(e[r])},p:function(e){4<e&&(Gt.get(e).wf+=1)},J:function(e,r,s,l){e=jt(e);var d=Br[r];return d||(d=ms(r),Br[r]=d),d(e,s,l)},H:function(){return Ht([])},g:function(e){return Ht(gi(e))},G:function(){return Ht({})},kb:function(e){return e=jt(e),!e},B:function(e){var r=jt(e);Bi(r),Vi(e)},i:function(e,r,s){e=jt(e),r=jt(r),s=jt(s),e[r]=s},h:function(e,r){return e=Xe(e,"_emval_take_value"),e=e.readValueFromPointer(r),Ht(e)},nb:function(){return-52},ob:function(){},a:()=>{Di("")},Eb:()=>performance.now(),vb:e=>{var r=ot.length;if(e>>>=0,2147483648<e)return!1;for(var s=1;4>=s;s*=2){var l=r*(1+.2/s);l=Math.min(l,e+100663296);var d=Math;l=Math.max(e,l);t:{d=d.min.call(d,2147483648,l+(65536-l%65536)%65536)-li.buffer.byteLength+65535>>>16;try{li.grow(d),gr();var m=1;break t}catch{}m=void 0}if(m)return!0}return!1},lb:function(){return it?it.handle:0},wb:(e,r)=>{var s=0;return Hr().forEach(function(l,d){var m=r+s;for(d=wt[e+4*d>>2]=m,m=0;m<l.length;++m)se[d++>>0]=l.charCodeAt(m);se[d>>0]=0,s+=l.length+1}),0},xb:(e,r)=>{var s=Hr();wt[e>>2]=s.length;var l=0;return s.forEach(function(d){l+=d.length+1}),wt[r>>2]=l,0},Jb:e=>{Hn||(h.onExit&&h.onExit(e),Li=!0),et(e,new qn(e))},M:()=>52,mb:function(){return 52},Cb:()=>52,pb:function(){return 70},S:(e,r,s,l)=>{for(var d=0,m=0;m<s;m++){var b=wt[r>>2],v=wt[r+4>>2];r+=8;for(var y=0;y<v;y++){var A=ot[b+y],O=bs[e];A===0||A===10?((e===1?jn:pe)(be(O,0)),O.length=0):O.push(A)}d+=v}return wt[l>>2]=d,0},aa:function(e){_.activeTexture(e)},ba:function(e,r){_.attachShader(te[e],ee[r])},ca:function(e,r,s){_.bindAttribLocation(te[e],r,s?be(ot,s):"")},da:function(e,r){e==35051?_.ef=r:e==35052&&(_.De=r),_.bindBuffer(e,yi[r])},$:function(e,r){_.bindFramebuffer(e,wi[r])},fc:function(e,r){_.bindRenderbuffer(e,Je[r])},Rb:function(e,r){_.bindSampler(e,Ce[r])},ea:function(e,r){_.bindTexture(e,Kt[r])},zc:Kr,Cc:Kr,fa:function(e,r,s,l){_.blendColor(e,r,s,l)},ga:function(e){_.blendEquation(e)},ha:function(e,r){_.blendFunc(e,r)},$b:function(e,r,s,l,d,m,b,v,y,A){_.blitFramebuffer(e,r,s,l,d,m,b,v,y,A)},ia:function(e,r,s,l){2<=it.version?s&&r?_.bufferData(e,ot,l,s,r):_.bufferData(e,r,l):_.bufferData(e,s?ot.subarray(s,s+r):r,l)},ja:function(e,r,s,l){2<=it.version?s&&_.bufferSubData(e,r,ot,l,s):_.bufferSubData(e,r,ot.subarray(l,l+s))},gc:function(e){return _.checkFramebufferStatus(e)},Q:function(e){_.clear(e)},_:function(e,r,s,l){_.clearColor(e,r,s,l)},R:function(e){_.clearStencil(e)},sb:function(e,r,s,l){return _.clientWaitSync(_e[e],r,(s>>>0)+4294967296*l)},ka:function(e,r,s,l){_.colorMask(!!e,!!r,!!s,!!l)},la:function(e){_.compileShader(ee[e])},ma:function(e,r,s,l,d,m,b,v){2<=it.version?_.De||!b?_.compressedTexImage2D(e,r,s,l,d,m,b,v):_.compressedTexImage2D(e,r,s,l,d,m,ot,v,b):_.compressedTexImage2D(e,r,s,l,d,m,v?ot.subarray(v,v+b):null)},na:function(e,r,s,l,d,m,b,v,y){2<=it.version?_.De||!v?_.compressedTexSubImage2D(e,r,s,l,d,m,b,v,y):_.compressedTexSubImage2D(e,r,s,l,d,m,b,ot,y,v):_.compressedTexSubImage2D(e,r,s,l,d,m,b,y?ot.subarray(y,y+v):null)},Zb:function(e,r,s,l,d){_.copyBufferSubData(e,r,s,l,d)},oa:function(e,r,s,l,d,m,b,v){_.copyTexSubImage2D(e,r,s,l,d,m,b,v)},pa:function(){var e=Oe(te),r=_.createProgram();return r.name=e,r.Ye=r.We=r.Xe=0,r.kf=1,te[e]=r,e},qa:function(e){var r=Oe(ee);return ee[r]=_.createShader(e),r},ra:function(e){_.cullFace(e)},sa:function(e,r){for(var s=0;s<e;s++){var l=$[r+4*s>>2],d=yi[l];d&&(_.deleteBuffer(d),d.name=0,yi[l]=null,l==_.ef&&(_.ef=0),l==_.De&&(_.De=0))}},hc:function(e,r){for(var s=0;s<e;++s){var l=$[r+4*s>>2],d=wi[l];d&&(_.deleteFramebuffer(d),d.name=0,wi[l]=null)}},ta:function(e){if(e){var r=te[e];r?(_.deleteProgram(r),r.name=0,te[e]=null):St(1281)}},ic:function(e,r){for(var s=0;s<e;s++){var l=$[r+4*s>>2],d=Je[l];d&&(_.deleteRenderbuffer(d),d.name=0,Je[l]=null)}},Sb:function(e,r){for(var s=0;s<e;s++){var l=$[r+4*s>>2],d=Ce[l];d&&(_.deleteSampler(d),d.name=0,Ce[l]=null)}},ua:function(e){if(e){var r=ee[e];r?(_.deleteShader(r),ee[e]=null):St(1281)}},_b:function(e){if(e){var r=_e[e];r?(_.deleteSync(r),r.name=0,_e[e]=null):St(1281)}},va:function(e,r){for(var s=0;s<e;s++){var l=$[r+4*s>>2],d=Kt[l];d&&(_.deleteTexture(d),d.name=0,Kt[l]=null)}},Ac:Vr,Dc:Vr,wa:function(e){_.depthMask(!!e)},xa:function(e){_.disable(e)},ya:function(e){_.disableVertexAttribArray(e)},za:function(e,r,s){_.drawArrays(e,r,s)},xc:function(e,r,s,l){_.drawArraysInstanced(e,r,s,l)},vc:function(e,r,s,l,d){_.pf.drawArraysInstancedBaseInstanceWEBGL(e,r,s,l,d)},tc:function(e,r){for(var s=bi[e],l=0;l<e;l++)s[l]=$[r+4*l>>2];_.drawBuffers(s)},Aa:Yr,yc:function(e,r,s,l,d){_.drawElementsInstanced(e,r,s,l,d)},wc:function(e,r,s,l,d,m,b){_.pf.drawElementsInstancedBaseVertexBaseInstanceWEBGL(e,r,s,l,d,m,b)},nc:function(e,r,s,l,d,m){Yr(e,l,d,m)},Ba:function(e){_.enable(e)},Ca:function(e){_.enableVertexAttribArray(e)},Xb:function(e,r){return(e=_.fenceSync(e,r))?(r=Oe(_e),e.name=r,_e[r]=e,r):0},Da:function(){_.finish()},Ea:function(){_.flush()},jc:function(e,r,s,l){_.framebufferRenderbuffer(e,r,s,Je[l])},kc:function(e,r,s,l,d){_.framebufferTexture2D(e,r,s,Kt[l],d)},Fa:function(e){_.frontFace(e)},Ga:function(e,r){Ie(e,r,"createBuffer",yi)},lc:function(e,r){Ie(e,r,"createFramebuffer",wi)},mc:function(e,r){Ie(e,r,"createRenderbuffer",Je)},Tb:function(e,r){Ie(e,r,"createSampler",Ce)},Ha:function(e,r){Ie(e,r,"createTexture",Kt)},Bc:qr,Ec:qr,bc:function(e){_.generateMipmap(e)},Ia:function(e,r,s){s?$[s>>2]=_.getBufferParameter(e,r):St(1281)},Ja:function(){var e=_.getError()||Pi;return Pi=0,e},Ka:function(e,r){Xr(e,r,2)},cc:function(e,r,s,l){e=_.getFramebufferAttachmentParameter(e,r,s),(e instanceof WebGLRenderbuffer||e instanceof WebGLTexture)&&(e=e.name|0),$[l>>2]=e},L:function(e,r){Xr(e,r,0)},La:function(e,r,s,l){e=_.getProgramInfoLog(te[e]),e===null&&(e="(unknown error)"),r=0<r&&l?Qt(e,ot,l,r):0,s&&($[s>>2]=r)},Ma:function(e,r,s){if(s)if(e>=Ur)St(1281);else if(e=te[e],r==35716)e=_.getProgramInfoLog(e),e===null&&(e="(unknown error)"),$[s>>2]=e.length+1;else if(r==35719){if(!e.Ye)for(r=0;r<_.getProgramParameter(e,35718);++r)e.Ye=Math.max(e.Ye,_.getActiveUniform(e,r).name.length+1);$[s>>2]=e.Ye}else if(r==35722){if(!e.We)for(r=0;r<_.getProgramParameter(e,35721);++r)e.We=Math.max(e.We,_.getActiveAttrib(e,r).name.length+1);$[s>>2]=e.We}else if(r==35381){if(!e.Xe)for(r=0;r<_.getProgramParameter(e,35382);++r)e.Xe=Math.max(e.Xe,_.getActiveUniformBlockName(e,r).length+1);$[s>>2]=e.Xe}else $[s>>2]=_.getProgramParameter(e,r);else St(1281)},dc:function(e,r,s){s?$[s>>2]=_.getRenderbufferParameter(e,r):St(1281)},Na:function(e,r,s,l){e=_.getShaderInfoLog(ee[e]),e===null&&(e="(unknown error)"),r=0<r&&l?Qt(e,ot,l,r):0,s&&($[s>>2]=r)},Ob:function(e,r,s,l){e=_.getShaderPrecisionFormat(e,r),$[s>>2]=e.rangeMin,$[s+4>>2]=e.rangeMax,$[l>>2]=e.precision},Oa:function(e,r,s){s?r==35716?(e=_.getShaderInfoLog(ee[e]),e===null&&(e="(unknown error)"),$[s>>2]=e?e.length+1:0):r==35720?(e=_.getShaderSource(ee[e]),$[s>>2]=e?e.length+1:0):$[s>>2]=_.getShaderParameter(ee[e],r):St(1281)},P:function(e){var r=Wr[e];if(!r){switch(e){case 7939:r=_.getSupportedExtensions()||[],r=r.concat(r.map(function(l){return"GL_"+l})),r=Qe(r.join(" "));break;case 7936:case 7937:case 37445:case 37446:(r=_.getParameter(e))||St(1280),r=r&&Qe(r);break;case 7938:r=_.getParameter(7938),r=2<=it.version?"OpenGL ES 3.0 ("+r+")":"OpenGL ES 2.0 ("+r+")",r=Qe(r);break;case 35724:r=_.getParameter(35724);var s=r.match(/^WebGL GLSL ES ([0-9]\.[0-9][0-9]?)(?:$| .*)/);s!==null&&(s[1].length==3&&(s[1]+="0"),r="OpenGL ES GLSL ES "+s[1]+" ("+r+")"),r=Qe(r);break;default:St(1280)}Wr[e]=r}return r},jb:function(e,r){if(2>it.version)return St(1282),0;var s=$r[e];if(s)return 0>r||r>=s.length?(St(1281),0):s[r];switch(e){case 7939:return s=_.getSupportedExtensions()||[],s=s.concat(s.map(function(l){return"GL_"+l})),s=s.map(function(l){return Qe(l)}),s=$r[e]=s,0>r||r>=s.length?(St(1281),0):s[r];default:return St(1280),0}},Pa:function(e,r){if(r=r?be(ot,r):"",e=te[e]){var s=e,l=s.Ne,d=s.yf,m;if(!l)for(s.Ne=l={},s.xf={},m=0;m<_.getProgramParameter(s,35718);++m){var b=_.getActiveUniform(s,m),v=b.name;b=b.size;var y=Jr(v);y=0<y?v.slice(0,y):v;var A=s.kf;for(s.kf+=b,d[y]=[b,A],v=0;v<b;++v)l[A]=v,s.xf[A++]=y}if(s=e.Ne,l=0,d=r,m=Jr(r),0<m&&(l=parseInt(r.slice(m+1))>>>0,d=r.slice(0,m)),(d=e.yf[d])&&l<d[0]&&(l+=d[1],s[l]=s[l]||_.getUniformLocation(e,r)))return l}else St(1281);return-1},Pb:function(e,r,s){for(var l=bi[r],d=0;d<r;d++)l[d]=$[s+4*d>>2];_.invalidateFramebuffer(e,l)},Qb:function(e,r,s,l,d,m,b){for(var v=bi[r],y=0;y<r;y++)v[y]=$[s+4*y>>2];_.invalidateSubFramebuffer(e,v,l,d,m,b)},Yb:function(e){return _.isSync(_e[e])},Qa:function(e){return(e=Kt[e])?_.isTexture(e):0},Ra:function(e){_.lineWidth(e)},Sa:function(e){e=te[e],_.linkProgram(e),e.Ne=0,e.yf={}},rc:function(e,r,s,l,d,m){_.uf.multiDrawArraysInstancedBaseInstanceWEBGL(e,$,r>>2,$,s>>2,$,l>>2,wt,d>>2,m)},sc:function(e,r,s,l,d,m,b,v){_.uf.multiDrawElementsInstancedBaseVertexBaseInstanceWEBGL(e,$,r>>2,s,$,l>>2,$,d>>2,$,m>>2,wt,b>>2,v)},Ta:function(e,r){e==3317&&(Gr=r),_.pixelStorei(e,r)},uc:function(e){_.readBuffer(e)},Ua:function(e,r,s,l,d,m,b){if(2<=it.version)if(_.ef)_.readPixels(e,r,s,l,d,m,b);else{var v=Ai(m);_.readPixels(e,r,s,l,d,m,v,b>>31-Math.clz32(v.BYTES_PER_ELEMENT))}else(b=Ji(m,d,s,l,b))?_.readPixels(e,r,s,l,d,m,b):St(1280)},ec:function(e,r,s,l){_.renderbufferStorage(e,r,s,l)},ac:function(e,r,s,l,d){_.renderbufferStorageMultisample(e,r,s,l,d)},Ub:function(e,r,s){_.samplerParameterf(Ce[e],r,s)},Vb:function(e,r,s){_.samplerParameteri(Ce[e],r,s)},Wb:function(e,r,s){_.samplerParameteri(Ce[e],r,$[s>>2])},Va:function(e,r,s,l){_.scissor(e,r,s,l)},Wa:function(e,r,s,l){for(var d="",m=0;m<r;++m){var b=l?$[l+4*m>>2]:-1,v=$[s+4*m>>2];b=v?be(ot,v,0>b?void 0:b):"",d+=b}_.shaderSource(ee[e],d)},Xa:function(e,r,s){_.stencilFunc(e,r,s)},Ya:function(e,r,s,l){_.stencilFuncSeparate(e,r,s,l)},Za:function(e){_.stencilMask(e)},_a:function(e,r){_.stencilMaskSeparate(e,r)},$a:function(e,r,s){_.stencilOp(e,r,s)},ab:function(e,r,s,l){_.stencilOpSeparate(e,r,s,l)},bb:function(e,r,s,l,d,m,b,v,y){if(2<=it.version)if(_.De)_.texImage2D(e,r,s,l,d,m,b,v,y);else if(y){var A=Ai(v);_.texImage2D(e,r,s,l,d,m,b,v,A,y>>31-Math.clz32(A.BYTES_PER_ELEMENT))}else _.texImage2D(e,r,s,l,d,m,b,v,null);else _.texImage2D(e,r,s,l,d,m,b,v,y?Ji(v,b,l,d,y):null)},cb:function(e,r,s){_.texParameterf(e,r,s)},db:function(e,r,s){_.texParameterf(e,r,Z[s>>2])},eb:function(e,r,s){_.texParameteri(e,r,s)},fb:function(e,r,s){_.texParameteri(e,r,$[s>>2])},oc:function(e,r,s,l,d){_.texStorage2D(e,r,s,l,d)},gb:function(e,r,s,l,d,m,b,v,y){if(2<=it.version)if(_.De)_.texSubImage2D(e,r,s,l,d,m,b,v,y);else if(y){var A=Ai(v);_.texSubImage2D(e,r,s,l,d,m,b,v,A,y>>31-Math.clz32(A.BYTES_PER_ELEMENT))}else _.texSubImage2D(e,r,s,l,d,m,b,v,null);else A=null,y&&(A=Ji(v,b,d,m,y)),_.texSubImage2D(e,r,s,l,d,m,b,v,A)},hb:function(e,r){_.uniform1f(gt(e),r)},ib:function(e,r,s){if(2<=it.version)r&&_.uniform1fv(gt(e),Z,s>>2,r);else{if(288>=r)for(var l=ve[r-1],d=0;d<r;++d)l[d]=Z[s+4*d>>2];else l=Z.subarray(s>>2,s+4*r>>2);_.uniform1fv(gt(e),l)}},Zc:function(e,r){_.uniform1i(gt(e),r)},_c:function(e,r,s){if(2<=it.version)r&&_.uniform1iv(gt(e),$,s>>2,r);else{if(288>=r)for(var l=Ze[r-1],d=0;d<r;++d)l[d]=$[s+4*d>>2];else l=$.subarray(s>>2,s+4*r>>2);_.uniform1iv(gt(e),l)}},$c:function(e,r,s){_.uniform2f(gt(e),r,s)},ad:function(e,r,s){if(2<=it.version)r&&_.uniform2fv(gt(e),Z,s>>2,2*r);else{if(144>=r)for(var l=ve[2*r-1],d=0;d<2*r;d+=2)l[d]=Z[s+4*d>>2],l[d+1]=Z[s+(4*d+4)>>2];else l=Z.subarray(s>>2,s+8*r>>2);_.uniform2fv(gt(e),l)}},Yc:function(e,r,s){_.uniform2i(gt(e),r,s)},Xc:function(e,r,s){if(2<=it.version)r&&_.uniform2iv(gt(e),$,s>>2,2*r);else{if(144>=r)for(var l=Ze[2*r-1],d=0;d<2*r;d+=2)l[d]=$[s+4*d>>2],l[d+1]=$[s+(4*d+4)>>2];else l=$.subarray(s>>2,s+8*r>>2);_.uniform2iv(gt(e),l)}},Wc:function(e,r,s,l){_.uniform3f(gt(e),r,s,l)},Vc:function(e,r,s){if(2<=it.version)r&&_.uniform3fv(gt(e),Z,s>>2,3*r);else{if(96>=r)for(var l=ve[3*r-1],d=0;d<3*r;d+=3)l[d]=Z[s+4*d>>2],l[d+1]=Z[s+(4*d+4)>>2],l[d+2]=Z[s+(4*d+8)>>2];else l=Z.subarray(s>>2,s+12*r>>2);_.uniform3fv(gt(e),l)}},Uc:function(e,r,s,l){_.uniform3i(gt(e),r,s,l)},Tc:function(e,r,s){if(2<=it.version)r&&_.uniform3iv(gt(e),$,s>>2,3*r);else{if(96>=r)for(var l=Ze[3*r-1],d=0;d<3*r;d+=3)l[d]=$[s+4*d>>2],l[d+1]=$[s+(4*d+4)>>2],l[d+2]=$[s+(4*d+8)>>2];else l=$.subarray(s>>2,s+12*r>>2);_.uniform3iv(gt(e),l)}},Sc:function(e,r,s,l,d){_.uniform4f(gt(e),r,s,l,d)},Rc:function(e,r,s){if(2<=it.version)r&&_.uniform4fv(gt(e),Z,s>>2,4*r);else{if(72>=r){var l=ve[4*r-1],d=Z;s>>=2;for(var m=0;m<4*r;m+=4){var b=s+m;l[m]=d[b],l[m+1]=d[b+1],l[m+2]=d[b+2],l[m+3]=d[b+3]}}else l=Z.subarray(s>>2,s+16*r>>2);_.uniform4fv(gt(e),l)}},Fc:function(e,r,s,l,d){_.uniform4i(gt(e),r,s,l,d)},Gc:function(e,r,s){if(2<=it.version)r&&_.uniform4iv(gt(e),$,s>>2,4*r);else{if(72>=r)for(var l=Ze[4*r-1],d=0;d<4*r;d+=4)l[d]=$[s+4*d>>2],l[d+1]=$[s+(4*d+4)>>2],l[d+2]=$[s+(4*d+8)>>2],l[d+3]=$[s+(4*d+12)>>2];else l=$.subarray(s>>2,s+16*r>>2);_.uniform4iv(gt(e),l)}},Hc:function(e,r,s,l){if(2<=it.version)r&&_.uniformMatrix2fv(gt(e),!!s,Z,l>>2,4*r);else{if(72>=r)for(var d=ve[4*r-1],m=0;m<4*r;m+=4)d[m]=Z[l+4*m>>2],d[m+1]=Z[l+(4*m+4)>>2],d[m+2]=Z[l+(4*m+8)>>2],d[m+3]=Z[l+(4*m+12)>>2];else d=Z.subarray(l>>2,l+16*r>>2);_.uniformMatrix2fv(gt(e),!!s,d)}},Ic:function(e,r,s,l){if(2<=it.version)r&&_.uniformMatrix3fv(gt(e),!!s,Z,l>>2,9*r);else{if(32>=r)for(var d=ve[9*r-1],m=0;m<9*r;m+=9)d[m]=Z[l+4*m>>2],d[m+1]=Z[l+(4*m+4)>>2],d[m+2]=Z[l+(4*m+8)>>2],d[m+3]=Z[l+(4*m+12)>>2],d[m+4]=Z[l+(4*m+16)>>2],d[m+5]=Z[l+(4*m+20)>>2],d[m+6]=Z[l+(4*m+24)>>2],d[m+7]=Z[l+(4*m+28)>>2],d[m+8]=Z[l+(4*m+32)>>2];else d=Z.subarray(l>>2,l+36*r>>2);_.uniformMatrix3fv(gt(e),!!s,d)}},Jc:function(e,r,s,l){if(2<=it.version)r&&_.uniformMatrix4fv(gt(e),!!s,Z,l>>2,16*r);else{if(18>=r){var d=ve[16*r-1],m=Z;l>>=2;for(var b=0;b<16*r;b+=16){var v=l+b;d[b]=m[v],d[b+1]=m[v+1],d[b+2]=m[v+2],d[b+3]=m[v+3],d[b+4]=m[v+4],d[b+5]=m[v+5],d[b+6]=m[v+6],d[b+7]=m[v+7],d[b+8]=m[v+8],d[b+9]=m[v+9],d[b+10]=m[v+10],d[b+11]=m[v+11],d[b+12]=m[v+12],d[b+13]=m[v+13],d[b+14]=m[v+14],d[b+15]=m[v+15]}}else d=Z.subarray(l>>2,l+64*r>>2);_.uniformMatrix4fv(gt(e),!!s,d)}},Kc:function(e){e=te[e],_.useProgram(e),_.Kf=e},Lc:function(e,r){_.vertexAttrib1f(e,r)},Mc:function(e,r){_.vertexAttrib2f(e,Z[r>>2],Z[r+4>>2])},Nc:function(e,r){_.vertexAttrib3f(e,Z[r>>2],Z[r+4>>2],Z[r+8>>2])},Oc:function(e,r){_.vertexAttrib4f(e,Z[r>>2],Z[r+4>>2],Z[r+8>>2],Z[r+12>>2])},pc:function(e,r){_.vertexAttribDivisor(e,r)},qc:function(e,r,s,l,d){_.vertexAttribIPointer(e,r,s,l,d)},Pc:function(e,r,s,l,d,m){_.vertexAttribPointer(e,r,s,!!l,d,m)},Qc:function(e,r,s,l){_.viewport(e,r,s,l)},rb:function(e,r,s,l){_.waitSync(_e[e],r,(s>>>0)+4294967296*l)},j:Ms,n:Ls,k:Fs,I:zs,Lb:Bs,Y:Us,X:$s,O:ks,o:Is,x:Ns,r:Rs,v:Os,Kb:Ws,Mb:Ds,Nb:xs,tb:(e,r,s,l)=>Cs(e,r,s,l)};(function(){function e(s){if(lt=s=s.exports,li=lt.bd,gr(),Mt=lt.dd,yr.unshift(lt.cd),Pe--,h.monitorRunDependencies&&h.monitorRunDependencies(Pe),Pe==0&&Ge){var l=Ge;Ge=null,l()}return s}var r={a:Ts};if(Pe++,h.monitorRunDependencies&&h.monitorRunDependencies(Pe),h.instantiateWasm)try{return h.instantiateWasm(r,e)}catch(s){pe("Module.instantiateWasm callback failed with error: "+s),F(s)}return Yn(r,function(s){e(s.instance)}).catch(F),{}})();var ue=h._free=e=>(ue=h._free=lt.ed)(e),Ei=h._malloc=e=>(Ei=h._malloc=lt.fd)(e),en=e=>(en=lt.gd)(e);h.__embind_initialize_bindings=()=>(h.__embind_initialize_bindings=lt.hd)();var kt=(e,r)=>(kt=lt.id)(e,r),Ot=()=>(Ot=lt.jd)(),It=e=>(It=lt.kd)(e);h.dynCall_viji=(e,r,s,l,d)=>(h.dynCall_viji=lt.ld)(e,r,s,l,d),h.dynCall_vijiii=(e,r,s,l,d,m,b)=>(h.dynCall_vijiii=lt.md)(e,r,s,l,d,m,b),h.dynCall_viiiiij=(e,r,s,l,d,m,b,v)=>(h.dynCall_viiiiij=lt.nd)(e,r,s,l,d,m,b,v),h.dynCall_jiiiijiiiii=(e,r,s,l,d,m,b,v,y,A,O,D)=>(h.dynCall_jiiiijiiiii=lt.od)(e,r,s,l,d,m,b,v,y,A,O,D),h.dynCall_viiij=(e,r,s,l,d,m)=>(h.dynCall_viiij=lt.pd)(e,r,s,l,d,m),h.dynCall_jii=(e,r,s)=>(h.dynCall_jii=lt.qd)(e,r,s),h.dynCall_vij=(e,r,s,l)=>(h.dynCall_vij=lt.rd)(e,r,s,l),h.dynCall_iiij=(e,r,s,l,d)=>(h.dynCall_iiij=lt.sd)(e,r,s,l,d),h.dynCall_iiiij=(e,r,s,l,d,m)=>(h.dynCall_iiiij=lt.td)(e,r,s,l,d,m),h.dynCall_viij=(e,r,s,l,d)=>(h.dynCall_viij=lt.ud)(e,r,s,l,d),h.dynCall_ji=(e,r)=>(h.dynCall_ji=lt.vd)(e,r),h.dynCall_iij=(e,r,s,l)=>(h.dynCall_iij=lt.wd)(e,r,s,l),h.dynCall_jiiiiii=(e,r,s,l,d,m,b)=>(h.dynCall_jiiiiii=lt.xd)(e,r,s,l,d,m,b),h.dynCall_jiiiiji=(e,r,s,l,d,m,b,v)=>(h.dynCall_jiiiiji=lt.yd)(e,r,s,l,d,m,b,v),h.dynCall_iijj=(e,r,s,l,d,m)=>(h.dynCall_iijj=lt.zd)(e,r,s,l,d,m),h.dynCall_iiiji=(e,r,s,l,d,m)=>(h.dynCall_iiiji=lt.Ad)(e,r,s,l,d,m),h.dynCall_iiji=(e,r,s,l,d)=>(h.dynCall_iiji=lt.Bd)(e,r,s,l,d),h.dynCall_iijjiii=(e,r,s,l,d,m,b,v,y)=>(h.dynCall_iijjiii=lt.Cd)(e,r,s,l,d,m,b,v,y),h.dynCall_vijjjii=(e,r,s,l,d,m,b,v,y,A)=>(h.dynCall_vijjjii=lt.Dd)(e,r,s,l,d,m,b,v,y,A),h.dynCall_jiji=(e,r,s,l,d)=>(h.dynCall_jiji=lt.Ed)(e,r,s,l,d),h.dynCall_viijii=(e,r,s,l,d,m,b)=>(h.dynCall_viijii=lt.Fd)(e,r,s,l,d,m,b),h.dynCall_iiiiij=(e,r,s,l,d,m,b)=>(h.dynCall_iiiiij=lt.Gd)(e,r,s,l,d,m,b),h.dynCall_iiiiijj=(e,r,s,l,d,m,b,v,y)=>(h.dynCall_iiiiijj=lt.Hd)(e,r,s,l,d,m,b,v,y),h.dynCall_iiiiiijj=(e,r,s,l,d,m,b,v,y,A)=>(h.dynCall_iiiiiijj=lt.Id)(e,r,s,l,d,m,b,v,y,A);function Fs(e,r,s,l){var d=Ot();try{return Mt.get(e)(r,s,l)}catch(m){if(It(d),m!==m+0)throw m;kt(1,0)}}function Ms(e,r){var s=Ot();try{return Mt.get(e)(r)}catch(l){if(It(s),l!==l+0)throw l;kt(1,0)}}function xs(e,r,s,l,d,m,b,v,y,A){var O=Ot();try{Mt.get(e)(r,s,l,d,m,b,v,y,A)}catch(D){if(It(O),D!==D+0)throw D;kt(1,0)}}function Rs(e,r,s,l){var d=Ot();try{Mt.get(e)(r,s,l)}catch(m){if(It(d),m!==m+0)throw m;kt(1,0)}}function Ns(e,r,s){var l=Ot();try{Mt.get(e)(r,s)}catch(d){if(It(l),d!==d+0)throw d;kt(1,0)}}function ks(e){var r=Ot();try{Mt.get(e)()}catch(s){if(It(r),s!==s+0)throw s;kt(1,0)}}function Os(e,r,s,l,d){var m=Ot();try{Mt.get(e)(r,s,l,d)}catch(b){if(It(m),b!==b+0)throw b;kt(1,0)}}function Is(e,r){var s=Ot();try{Mt.get(e)(r)}catch(l){if(It(s),l!==l+0)throw l;kt(1,0)}}function Ls(e,r,s){var l=Ot();try{return Mt.get(e)(r,s)}catch(d){if(It(l),d!==d+0)throw d;kt(1,0)}}function Ds(e,r,s,l,d,m,b){var v=Ot();try{Mt.get(e)(r,s,l,d,m,b)}catch(y){if(It(v),y!==y+0)throw y;kt(1,0)}}function zs(e,r,s,l,d){var m=Ot();try{return Mt.get(e)(r,s,l,d)}catch(b){if(It(m),b!==b+0)throw b;kt(1,0)}}function Bs(e,r,s,l,d,m){var b=Ot();try{return Mt.get(e)(r,s,l,d,m)}catch(v){if(It(b),v!==v+0)throw v;kt(1,0)}}function Us(e,r,s,l,d,m,b){var v=Ot();try{return Mt.get(e)(r,s,l,d,m,b)}catch(y){if(It(v),y!==y+0)throw y;kt(1,0)}}function Ws(e,r,s,l,d,m){var b=Ot();try{Mt.get(e)(r,s,l,d,m)}catch(v){if(It(b),v!==v+0)throw v;kt(1,0)}}function $s(e,r,s,l,d,m,b,v,y,A){var O=Ot();try{return Mt.get(e)(r,s,l,d,m,b,v,y,A)}catch(D){if(It(O),D!==D+0)throw D;kt(1,0)}}var Ti;Ge=function e(){Ti||rn(),Ti||(Ge=e)};function rn(){function e(){if(!Ti&&(Ti=!0,h.calledRun=!0,!Li)){if(zi(yr),C(h),h.onRuntimeInitialized&&h.onRuntimeInitialized(),h.postRun)for(typeof h.postRun=="function"&&(h.postRun=[h.postRun]);h.postRun.length;){var r=h.postRun.shift();wr.unshift(r)}zi(wr)}}if(!(0<Pe)){if(h.preRun)for(typeof h.preRun=="function"&&(h.preRun=[h.preRun]);h.preRun.length;)Kn();zi(vr),0<Pe||(h.setStatus?(h.setStatus("Running..."),setTimeout(function(){setTimeout(function(){h.setStatus("")},1),e()},1)):e())}}if(h.preInit)for(typeof h.preInit=="function"&&(h.preInit=[h.preInit]);0<h.preInit.length;)h.preInit.pop()();return rn(),u.ready}})();g.exports=i})(Tn);var oa=Tn.exports,la=Qs(oa);class Be{static slide(t){let i=Te.linear;return typeof t.easing=="string"?i=Te.fromTypeAsString(t.easing):t.easing!==void 0&&(i=t.easing),new Dn(t.direction,t.duration,i)}static none(){return new Ln}}class Ln extends Be{constructor(){super(),this.type=de.None,this.duration=NaN,this.easing=Te.none}}class Dn extends Be{constructor(t,i,n){super(),this.type=de.Slide,this.direction=t,this.duration=i,this.easing=n}}const de={Slide:"Slide",None:"None"},fe={Up:"Up",Down:"Down",Right:"Right",Left:"Left"};class zn{constructor(t,i){this.scene=t,this.transition=i}}const Bn={type:"object",description:"Information about the user's device.",properties:{userAgent:{type:"string",description:"The user agent string returned by navigator.userAgent."},devicePixelRatio:{type:"number",description:"Ratio of physical pixels to CSS pixels."},screen:{type:"object",description:"Screen information returned by window.screen.",properties:{availHeight:{type:"number",description:"Height of screen, in pixels, excluding UI features."},availWidth:{type:"number",description:"Width of screen, in pixels, excluding UI features."},colorDepth:{type:"number",description:"Color depth of screen."},height:{type:"number",description:"Height of screen, in pixels"},width:{type:"number",description:"Width of screen, in pixels."},orientation:{type:"object",description:"Information about the device's orientation.",properties:{type:{type:"string",description:"The orientation type (ScreenOrientation.type)."},angle:{type:"number",description:"The orientation angle (ScreenOrientation.angle)."}}},pixelDepth:{type:"number",description:"Pixel depth of screen."}}},webGlRenderer:{type:"string",description:"WebGL driver vendor and renderer. Taken from WEBGL_debug_renderer_info."}}};class fr{static getRendererString(){const t=document.createElement("canvas");t.id="webgl-renderer-info-canvas",t.height=0,t.width=0,t.hidden=!0,document.body.appendChild(t);const i=t.getContext("webgl");let n="no webgl context";if(!i)return n;const u=i.getExtension("WEBGL_debug_renderer_info");return u!=null?n=String(i.getParameter(u.UNMASKED_VENDOR_WEBGL))+", "+String(i.getParameter(u.UNMASKED_RENDERER_WEBGL)):n="no debug renderer info",t.remove(),n}static dispose(){const t=document.getElementById("webgl-renderer-info-canvas");t&&t.remove()}}class Un{constructor(t,i){this.sounds={},this.game=t,this.baseUrls=i}get audioContext(){if(!this._audioContext){if(!navigator.userActivation.hasBeenActive)throw new Error("AudioContext cannot be created until user has interacted with the page");this._audioContext=new AudioContext}return this._audioContext}initializeSounds(t){return t?this.loadSounds(t):Promise.resolve()}loadSounds(t){return t.length===0?Promise.resolve():(t.forEach(i=>{let n=i.url;q.urlHasScheme(i.url)||(n=q.getUrlFromManifest(this.game,`${this.baseUrls.assets}/${i.url}`));const u={soundName:i.soundName,data:void 0,audioBuffer:void 0,url:n,status:i.lazy?zt.Deferred:zt.WillFetch};this.sounds[i.soundName]&&console.warn(`A sound named ${i.soundName} has already been loaded. It will be replaced.`),this.sounds[i.soundName]=u}),this.fetchSounds())}async fetchSounds(){const t=Object.values(this.sounds).map(i=>i.status===zt.WillFetch?(i.status=zt.Fetching,fetch(i.url).then(n=>{if(!n.ok)throw i.status=zt.Error,new Error(`cannot fetch sound ${i.soundName} at url ${i.url}: ${n.statusText}`);return n.arrayBuffer().then(u=>{i.data=u,i.status=zt.Fetched,console.log(`\u26AA sound fetched. name: ${i.soundName}, bytes: ${u.byteLength}`)})})):Promise.resolve());await Promise.all(t)}fetchDeferredSound(t){return t.status=zt.WillFetch,this.fetchSounds()}hasSoundsToDecode(){return Object.values(this.sounds).filter(t=>t.status===zt.Fetched).length>0}decodeFetchedSounds(){const i=Object.values(this.sounds).filter(n=>n.status===zt.Fetched).map(n=>this.decodeSound(n));return Promise.all(i)}async decodeSound(t){if(!t.data)throw new Error(`data is undefined for sound ${t.soundName} (url ${t.url})`);try{t.status=zt.Decoding;const i=await this.audioContext.decodeAudioData(t.data);t.audioBuffer=i,t.status=zt.Ready,console.log(`\u26AA sound decoded. name: ${t.soundName}, duration (seconds): ${i.duration}`)}catch{throw t.status=zt.Error,new Error(`error decoding sound ${t.soundName} (url: ${t.url})`)}}getSound(t){const i=this.sounds[t];if(!i)throw new Error(`getSound(): sound ${t} not found`);return i}dispose(){}getSoundNames(){return Object.keys(this.sounds)}}class ha{constructor(t){this.game=t.game,this.nodeFactory=t.nodeFactory,this.freeNodesScene=t.freeNodesScene,this.configureI18n=t.configureI18n,this.eventMaterializers=new Map([[G.NodeNew,this.materializeNodeNewEvent.bind(this)],[G.Composite,this.materializeCompositeEvent.bind(this)],[G.ScenePresent,this.materializeScenePresentEvent.bind(this)],[G.NodePropertyChange,this.materializeNodePropertyChangeEvent.bind(this)],[G.NodeAddChild,this.materializeNodeAddChildEvent.bind(this)],[G.NodeRemoveChild,this.materializeNodeRemoveChildEvent.bind(this)],[G.DomPointerDown,this.materializeDomPointerDownEvent.bind(this)],[G.BrowserImageDataReady,this.materializeBrowserImageDataReadyEvent.bind(this)],[G.I18nDataReadyEvent,this.materializeI18nDataReadyEvent.bind(this)]])}materialize(t){t.length>0&&(console.log(`Replaying ${t.length} events`),t.forEach(i=>{const n=this.eventMaterializers.get(i.type);n?n(i):console.log(`EventMaterializer unhandled event: ${i.type}`)}))}materializeCompositeEvent(t){const i=this.game.materializedNodes.find(n=>n.uuid===t.target);if(!i)console.log(`EventMaterializer: composite node of type ${t.compositeType} with uuid ${t.target} not found when handling CompositeEvent ${t.compositeEventType}`);else if(console.log("calling handleCompositeEvent on composite node"),i.type===at.Composite)i.handleCompositeEvent(t);else throw new Error(`EventMaterializer: node was expected to be composite, but was of type ${i.type}`)}materializeNodeNewEvent(t){const i=this.nodeFactory.createNode(t.nodeType,t.compositeType,t.nodeOptions);i.type===at.Scene&&(i.name===X.FREE_NODES_SCENE_NAME?(this.freeNodesScene=i,this.freeNodesScene.game=this.game,this.freeNodesScene.needsInitialization=!0,this.game.freeNodesScene=this.freeNodesScene):this.game.addScene(i)),this.game.materializedNodes.push(i)}materializeNodePropertyChangeEvent(t){const i=this.game.materializedNodes.find(n=>n.uuid===t.uuid);if(!i)throw new Error(`EventMaterializer: node with uuid ${t.uuid} not found`);if(t.property in i)i[t.property]=t.value;else throw new Error(`EventMaterializer: on node ${i.name}, type ${i.type}, nodePropertyChangeEvent tried to set unknown property ${t.property} to value ${JSON.stringify(t.value)}`)}materializeNodeAddChildEvent(t){const i=this.game.materializedNodes.find(u=>u.uuid===t.uuid);if(!i)throw new Error(`EventMaterializer: parent node with uuid ${t.uuid} not found`);const n=this.game.materializedNodes.find(u=>u.uuid===t.childUuid);if(!n)throw new Error(`EventMaterializer: child node with uuid ${t.childUuid} not found`);i.addChild(n)}materializeNodeRemoveChildEvent(t){const i=this.game.materializedNodes.find(u=>u.uuid===t.uuid);if(!i)throw new Error(`EventMaterializer: parent node with uuid ${t.uuid} not found`);const n=this.game.materializedNodes.find(u=>u.uuid===t.childUuid);if(!n)throw new Error(`EventMaterializer: child node with uuid ${t.childUuid} not found`);i.removeChild(n)}materializeDomPointerDownEvent(t){this.game.currentScene?.run(V.custom({callback:()=>{const i=new ai({circleOfRadius:16,fillColor:x.LightGray,strokeColor:x.Black,lineWidth:2,alpha:.75,position:{x:t.x,y:t.y}});this.game.currentScene?.addChild(i),i.run(V.sequence([V.group([V.fadeAlpha({duration:750,alpha:0}),V.scale({duration:750,scale:0})]),V.custom({callback:()=>{this.game.currentScene?.removeChild(i)}})]))}}))}materializeBrowserImageDataReadyEvent(t){this.game.imageManager.loadImages([{imageName:t.imageName,width:t.width,height:t.height,dataUrl:t.dataUrl,svgString:t.svgString}])}materializeI18nDataReadyEvent(t){this.configureI18n(t.localizationOptions)}materializeScenePresentEvent(t){let i=Be.none();if(t.transitionType===de.Slide){if(t.direction===void 0)throw new Error("EventMaterializer: ScenePresentEvent direction is undefined for slide transition");if(t.duration===void 0)throw new Error("EventMaterializer: ScenePresentEvent duration is undefined for slide transition");if(t.easingType===void 0)throw new Error("EventMaterializer: ScenePresentEvent easingType is undefined for slide transition");const n=this.game.materializedNodes.find(u=>u.uuid===t.uuid);if(!n)throw new Error(`EventMaterializer: Scene with uuid ${t.uuid} not found`);switch(t.direction){case fe.Left:{n.position.x=n.size.width;break}case fe.Right:{n.position.x=-n.size.width;break}case fe.Up:{n.position.y=n.size.height;break}case fe.Down:{n.position.y=-n.size.height;break}}i=Be.slide({direction:t.direction,duration:t.duration,easing:Te.fromTypeAsString(t.easingType)})}this.game.presentScene(t.uuid,i)}}class ca{constructor(t){if(this.type=si.Game,this.sessionUuid="",this.uuid=De.generate(),this.publishUuid="",this.canvasKitWasmVersion="0.39.1",this.beginTimestamp=NaN,this.beginIso8601Timestamp="",this.eventListeners=new Array,this.gameMetrics=new Array,this.stepCount=0,this.steppingNow=0,this.warmupFunctionQueue=new Array,this.warmupFinished=!1,this.plugins=[],this.staticTrialSchema={},this.eventStore=new An,this.nodeFactory=new Cn,this.materializedNodes=new Array,this.data={trials:new Array},this.trialIndex=0,this.drawnFrames=0,this.lastFpsUpdate=0,this.nextFpsUpdate=0,this.fpsRate=0,this.animationFramesRequested=0,this.limitFps=!1,this.gameStopRequested=!1,this.webGlRendererInfo="",this.canvasCssWidth=0,this.canvasCssHeight=0,this.scenes=new Array,this.freeNodesScene=new Ue({name:X.FREE_NODES_SCENE_NAME,backgroundColor:[255,255,255,0]}),this.incomingSceneTransitions=new Array,this.replayEventsButtonEnabled=!0,this.automaticTrialSchema={study_id:{type:["string","null"],description:"The short human-readable text ID of the study (protocol, experiment, or other aggregate) that contains the administration of this activity."},study_uuid:{type:["string","null"],format:"uuid",description:"Unique identifier of the study (protocol, experiment, or other aggregate) that contains the administration of this activity."},document_uuid:{type:"string",format:"uuid",description:"Unique identifier for this data document."},session_uuid:{type:"string",format:"uuid",description:"Unique identifier for all activities in this administration of the session. This identifier changes each time a new session starts."},activity_uuid:{type:"string",format:"uuid",description:"Unique identifier for all trials in this administration of the activity. This identifier changes each time the activity starts."},activity_id:{type:"string",description:"Human-readable identifier of the activity."},activity_publish_uuid:{type:"string",format:"uuid",description:"Persistent unique identifier of the activity. This identifier never changes. It can be used to identify the activity across different studies and sessions."},activity_version:{type:"string",description:"Version of the activity."},device_timezone:{type:"string",description:"Timezone of the device. Calculated from Intl.DateTimeFormat().resolvedOptions().timeZone."},device_timezone_offset_minutes:{type:"integer",description:"Difference in minutes between UTC and device timezone. Calculated from Date.getTimezoneOffset()."},locale:{type:["string","null"],description:"Locale of the trial. null if the activity does not support localization."}},this.snapshots=new Array,!t.id||t.id.trim()==="")throw new Error("id is required in GameOptions");if(!De.isValid(t.publishUuid)){const i=t.publishUuid?`Provided publishUuid was ${t.publishUuid}. `:"";console.warn(`Missing or invalid publishUuid in GameOptions. ${i}To generate a valid UUID, visit a site such as https://www.uuidgenerator.net/version4`)}this.options=t,this.name=t.name,this.id=t.id,this.publishUuid=t.publishUuid,this.fpsMetricReportThreshold=t.fpsMetricReportThreshold??X.FPS_METRIC_REPORT_THRESHOLD,this.maximumRecordedActivityMetrics=t.maximumRecordedActivityMetrics??X.MAXIMUM_RECORDED_ACTIVITY_METRICS,this.addLocalizationParametersToGameParameters(),this.options.locale!==void 0&&this.setParameters({locale:this.options.locale}),this.options.fallbackLocale!==void 0&&this.setParameters({fallback_locale:this.options.fallbackLocale}),this.options.missingLocalizationColor&&this.setParameters({missing_localization_color:this.options.missingLocalizationColor}),this.options.translation&&this.setParameters({translation:this.options.translation}),this.options.additionalTranslation&&this.setParameters({translation:this.options.additionalTranslation}),this.options.trialSchema||(this.options.trialSchema={}),t.moduleMetadata?this.moduleMetadata=t.moduleMetadata:this.moduleMetadata={name:"",version:"",dependencies:{}}}createFreeNodesScene(){this.freeNodesScene.game=this,this.freeNodesScene.needsInitialization=!0;const t={name:X.FREE_NODES_SCENE_NAME,backgroundColor:[255,255,255,0],uuid:this.freeNodesScene.uuid},i={type:G.NodeNew,target:this.freeNodesScene,nodeType:at.Scene,...q.createFrameUpdateTimestamps(),nodeOptions:t,sequence:m2c2Globals.eventSequence};this.eventStore.addEvent(i)}getImportedModuleBaseUrl(t,i){const n=new RegExp(`^.*${t}[^\\/]*`),u=i.match(n);if(!u||u.length===0)throw new Error(`Could not calculate imported assessment package base URL. Package name: ${t}, module URL: ${i}`);return u[0]}addLocalizationParametersToGameParameters(){this.options.parameters={...this.options.parameters,...xi.makeLocalizationParameters()}}async init(){return this.initialize()}loadCanvasKit(t){return la({locateFile:()=>t})}async resolveGameBaseUrls(t){let i,n=!1,u=`assets/${t.id}`;if(t.moduleMetadata.name)try{i=await import.meta.resolve(t.moduleMetadata.name),u=t.getImportedModuleBaseUrl(t.moduleMetadata.name,i)+"/assets",n=!0}catch{}let h=`assets/${t.id}`;try{const C=await import.meta.resolve("@m2c2kit/core");h=t.getImportedModuleBaseUrl("@m2c2kit/core",C)+"/assets"}catch{if(n)throw new Error(`the package ${t.moduleMetadata.name} has been imported from a module URL (${i}), but the @m2c2kit/core package module URL could not be determined.`)}return{assets:u,canvasKitWasm:h}}async configureI18n(t){if(this.i18n=new xi(this,t),!this.i18n)throw new Error("I18n object is undefined");await this.i18n.initialize(),this.eventStore.addEvent({type:"I18nDataReadyEvent",target:this.i18n,localizationOptions:t,...q.createFrameUpdateTimestamps()})}async initialize(){this.options.recordEvents===!0&&(this.eventStore.mode=ce.Record),this.createFreeNodesScene();const t=await this.resolveGameBaseUrls(this);if(this.manifest===void 0&&(this.manifest=await this.loadManifest()),this._canvasKit===void 0){const i=q.getUrlFromManifest(this,t.canvasKitWasm+`/canvaskit-${this.canvasKitWasmVersion}.wasm`);try{this.canvasKit=await this.loadCanvasKit(i)}catch{throw new Error(`game ${this.id} could not load canvaskit wasm file from ${i}`)}}if(this.isLocalizationRequested()){const i=this.getLocalizationOptionsFromGameParameters();await this.configureI18n(i)}return this.fontManager=new _n(this,t),this.imageManager=new or(this,t),this.soundManager=new Un(this,t),this.eventMaterializer=new ha({game:this,nodeFactory:this.nodeFactory,freeNodesScene:this.freeNodesScene,configureI18n:this.configureI18n.bind(this)}),Promise.all([this.fontManager.initializeFonts(this.options.fonts),this.imageManager.initializeImages(this.options.images),this.soundManager.initializeSounds(this.options.sounds)])}async loadManifest(t="__NO_M2C2KIT_MANIFEST_JSON_URL__"){if(t.includes("NO_M2C2KIT_MANIFEST_JSON_URL"))return{};let i;try{if(i=await fetch(t),!i.ok)throw new Error(`Error ${i.status} on GET manifest.json from ${t}.`)}catch{throw new Error(`Network error on GET manifest.json from ${t}.`)}try{return await i.json()}catch{throw new Error(`Error parsing manifest.json from ${t}.`)}}get fontManager(){if(!this._fontManager)throw new Error("fontManager is undefined");return this._fontManager}set fontManager(t){this._fontManager=t}get imageManager(){if(!this._imageManager)throw new Error("imageManager is undefined");return this._imageManager}set imageManager(t){this._imageManager=t}get soundManager(){if(!this._soundManager)throw new Error("soundManager is undefined");return this._soundManager}set soundManager(t){this._soundManager=t}get eventMaterializer(){if(!this._eventMaterializer)throw new Error("eventMaterializer is undefined");return this._eventMaterializer}set eventMaterializer(t){this._eventMaterializer=t}addPrefixesToKey(t){let i="";if(this.studyId&&this.studyUuid)i=this.studyId.concat(":",this.studyUuid,":");else if(this.studyId||this.studyUuid)throw new Error(`study_id and study_uuid must both be set or unset. Values are study_id: ${this.studyId}, study_uuid: ${this.studyUuid}`);return i.concat(this.id.concat(this.id,":",this.publishUuid,":",t))}storeSetItem(t,i,n=!1){const u=n?t:this.addPrefixesToKey(t);return this.dataStores[0].setItem(u,i,n?"":this.publishUuid)}storeGetItem(t,i=!1){const n=i?t:this.addPrefixesToKey(t);return this.dataStores[0].getItem(n)}storeDeleteItem(t,i=!1){const n=i?t:this.addPrefixesToKey(t);return this.dataStores[0].deleteItem(n)}storeClearItems(){return this.dataStores[0].clearItemsByActivityPublishUuid(this.publishUuid)}storeItemsKeys(t=!1){return this.dataStores[0].itemsKeysByActivityPublishUuid(t?"":this.publishUuid)}storeItemExists(t,i=!1){const n=i?t:this.addPrefixesToKey(t);return this.dataStores[0].itemExists(n)}get dataStores(){if(!this._dataStores)throw new Error("dataStores is undefined");return this._dataStores}set dataStores(t){this._dataStores=t}hasDataStores(){return this._dataStores&&this._dataStores.length>0||!1}getLocalizationOptionsFromGameParameters(){const t=this.getParameter("locale"),i=this.getParameterOrFallback("fallback_locale",void 0),n=this.getParameterOrFallback("missing_localization_color",void 0),u=this.getParameterOrFallback("translation",void 0),h=this.options.translation;return{locale:t,fallbackLocale:i,missingLocalizationColor:n,additionalTranslation:u,translation:h}}isLocalizationRequested(){const t=this.getParameterOrFallback("locale",void 0);if(t==="")throw new Error("Empty string in locale. Leave locale undefined or null to prevent localization.");return t==null&&this.options.translation?(this.setParameters({locale:this.options.translation.baseLocale}),!0):!(t==null&&this.options.translation===void 0)}setParameters(t){const{parameters:i}=this.options;Object.keys(t).forEach(n=>{!i||!(n in i)?console.warn(`game ${this.options.name} does not have a parameter named ${n}. attempt to set parameter ${n} to value ${t[n]} will be ignored`):this.options.parameters&&this.options.parameters[n]&&(this.options.parameters[n].default=t[n])}),this.additionalParameters=t}get canvasKit(){if(!this._canvasKit)throw new Error("canvaskit is undefined");return this._canvasKit}set canvasKit(t){this._canvasKit=t}addFreeNode(t){this.freeNodesScene.addChild(t)}addFreeEntity(t){this.addFreeNode(t)}removeFreeNode(t){if(typeof t=="string"){const i=this.freeNodesScene.children.filter(n=>n.name===t).find(Boolean);if(!i)throw new Error(`cannot remove free node named "${t}" because it is not currently part of the game's free nodes. `);this.freeNodesScene.removeChild(i)}else this.freeNodesScene.removeChild(t)}removeFreeEntity(t){this.removeFreeNode(t)}removeAllFreeNodes(){for(;this.freeNodesScene.children.length;)this.freeNodesScene.children.pop()}removeAllFreeEntities(){this.removeAllFreeNodes()}get freeNodes(){return this.freeNodesScene.children}get freeEntities(){return this.freeNodes}addScene(t){t.game=this,t.needsInitialization=!0,this.scenes.push(t),this.addNodeEvents(t)}addNodeEvents(t){this.eventStore.addEvents(t.nodeEvents),t.nodeEvents.length=0;for(const i of t.children)this.addNodeEvents(i)}addScenes(t){t.forEach(i=>{this.addScene(i)})}removeScene(t){if(typeof t=="object")if(this.scenes.includes(t))this.scenes=this.scenes.filter(i=>i!==t);else throw new Error(`cannot remove scene ${t} from game because the scene is not currently added to the game`);else if(this.scenes.map(i=>i.name).includes(t))this.scenes=this.scenes.filter(i=>i.name!==t);else throw new Error(`cannot remove scene named "${t}" from game because the scene is not currently added to the game`)}presentScene(t,i){let n;if(typeof t=="string"){if(n=this.scenes.filter(F=>F.name===t).find(Boolean),n===void 0&&(n=this.scenes.filter(F=>F.uuid===t).find(Boolean)),n===void 0)throw new Error(`scene ${t} not found`)}else{if(!this.scenes.some(F=>F===t))throw new Error(`scene ${t} exists, but it has not been added to the game object`);n=t}n.initialize(),n.needsInitialization=!1;const u=new zn(n,i??Be.none());this.incomingSceneTransitions.push(u),n.game.bodyBackgroundColor!==void 0?document.body.style.backgroundColor=`rgb(${n.game.bodyBackgroundColor[0]},${n.game.bodyBackgroundColor[1]},${n.game.bodyBackgroundColor[2]},${n.game.bodyBackgroundColor[3]})`:document.body.style.backgroundColor=`rgb(${n.backgroundColor[0]},${n.backgroundColor[1]},${n.backgroundColor[2]},${n.backgroundColor[3]})`;let h;i?.type===de.Slide&&(h=i.direction);const C={type:"ScenePresent",target:n,uuid:n.uuid,...q.createFrameUpdateTimestamps(),transitionType:i?.type??de.None,duration:i?.duration,direction:h,easingType:i?.easing?Te.toTypeAsString(i.easing):void 0};this.eventStore.addEvent(C)}getParameter(t){if(this.options.parameters!==void 0&&Object.keys(this.options.parameters).includes(t))return this.options.parameters[t].default;throw new Error(`game parameter ${t} not found`)}getParameterOrFallback(t,i){return this.options.parameters!==void 0&&Object.keys(this.options.parameters).includes(t)?this.options.parameters[t].default:i}hasParameter(t){return!!(this.options.parameters!==void 0&&Object.keys(this.options.parameters).includes(t))}async start(t){const i=this.options;this.setupHtmlCanvases(i.canvasId,i.width,i.height,i.stretch),this.showFps=i.showFps??!1,this.bodyBackgroundColor=i.bodyBackgroundColor,this.initData(),this.setupCanvasKitSurface(),this.setupFpsFont(),this.setupCanvasDomEventHandlers(),this.beginTimestamp=Wt.now(),this.beginIso8601Timestamp=new Date().toISOString();let n;if(t!==void 0?typeof t=="object"?n=t:n=this.scenes.filter(C=>C.name===t).find(Boolean):this.entryScene!==void 0?typeof this.entryScene=="object"?n=this.entryScene:n=this.scenes.filter(C=>C.name===this.entryScene).find(Boolean):n=this.scenes.find(Boolean),n===void 0)throw new Error("cannot start game. entry scene has not been added to the game object.");if(this.presentScene(n),this.surface===void 0)throw new Error("CanvasKit surface is undefined");this.options.timeStepping?(this.addTimeSteppingControlsToDom(),this.updateTimeSteppingOutput()):this.removeTimeSteppingControlsFromDom(),this.options.showEventStoreControls&&this.addEventControlsToDom(),this.warmupFinished=!1;const u={target:this,type:G.GameWarmupStart,...q.createFrameUpdateTimestamps()};this.raiseActivityEventOnListeners(u),this.warmupFunctionQueue.push({warmupFunction:this.warmupShadersWithPrimitives}),this.warmupFunctionQueue.push({warmupFunction:this.warmupShadersWithPrimitives,positionOffset:.10012117}),this.warmupFunctionQueue.push({warmupFunction:this.warmupShadersWithScenes}),this.surface.requestAnimationFrame(this.loop.bind(this));const h={target:this,type:G.ActivityStart,...q.createFrameUpdateTimestamps()};this.raiseActivityEventOnListeners(h)}playEventsHandler(t){if(t?.target?.id==="replay-events"&&(this.eventStore.mode=ce.Disabled,this.scenes.forEach(i=>{this.removeScene(i)}),this.currentScene=void 0,this.eventListeners=new Array,this.freeNodesScene.removeAllChildren(),this.materializedNodes=[],this.eventStore.replay(),this.setReplayEventsButtonEnabled(!1),this.setStopReplayButtonEnabled(!0)),t?.target?.id==="stop-replay"&&(this.eventStore.clearEvents(),this.setReplayEventsButtonEnabled(!0),this.setStopReplayButtonEnabled(!1)),t?.target?.id==="log-events"){if(this.eventStore.mode===ce.Replay){console.log(this.eventStore.serializedEventsBeforeReplay),console.log(`Total events: ${JSON.parse(this.eventStore.serializedEventsBeforeReplay).length}`);return}console.log(JSON.stringify(this.eventStore.getEvents())),console.log(`Total events: ${this.eventStore.getEvents().length}`)}}setReplayEventsButtonEnabled(t){const i=document.getElementById("replay-events");if(i){if(t){i.removeAttribute("disabled"),this.replayEventsButtonEnabled=!0;return}i.setAttribute("disabled","true"),this.replayEventsButtonEnabled=!1}}setStopReplayButtonEnabled(t){const i=document.getElementById("stop-replay");if(i){if(t){i.removeAttribute("disabled");return}i.setAttribute("disabled","true")}}addEventControlsToDom(){const t=document.getElementById("m2c2kit-event-controls-div");t&&t.remove();const i=document.getElementsByTagName("body")[0];if(i){const n=document.createElement("div");n.id="m2c2kit-event-controls-div",n.style.position="fixed",n.style.top="4px",n.style.left="4px",i.prepend(n);const u=document.createElement("button");u.id="replay-events",u.title="replay event recording",u.innerText="\u25B6\uFE0F",u.style.marginRight="4px",n.appendChild(u),u.addEventListener("click",this.playEventsHandler.bind(this));const h=document.createElement("button");h.id="stop-replay",h.title="stop event replay",h.innerText="\u23F9\uFE0F",h.style.marginRight="4px",h.disabled=!0,n.appendChild(h),h.addEventListener("click",this.playEventsHandler.bind(this));const C=document.createElement("button");C.id="log-events",C.title="log events to console",C.innerText="\u{1F4C4}",C.style.marginRight="4px",n.appendChild(C),C.addEventListener("click",this.playEventsHandler.bind(this));const F=document.createElement("span");F.title="optional: replay events only through a given sequence number. Default is to replay all events.",F.innerText="Replay through sequence: ",n.appendChild(F);const B=document.createElement("input");B.id="sequence-number",B.title="optional: replay events only through a given sequence number. Default is to replay all events.",B.style.marginRight="4px",n.appendChild(B)}}addTimeSteppingControlsToDom(){if(document.getElementById("m2c2kit-time-stepping-div"))return;const i=document.getElementsByTagName("body")[0];if(i){const n=document.createElement("div");n.id="m2c2kit-time-stepping-div",i.prepend(n);const u=document.createElement("button");u.id="1-step-advance",u.title="advance 1 step (16.667 ms)",u.innerText=">",u.style.marginRight="4px",n.appendChild(u),u.addEventListener("click",this.advanceStepsHandler.bind(this));const h=document.createElement("button");h.id="55-step-advance",h.title="advance 55 steps (916.667 ms)",h.innerText=">>",h.style.marginRight="4px",n.appendChild(h),h.addEventListener("click",this.advanceStepsHandler.bind(this));const C=document.createElement("input");C.id="time-stepping-steps-input",C.title="steps",C.style.width="40px",C.style.marginRight="4px",C.setAttribute("readonly","true"),n.appendChild(C);const F=document.createElement("input");F.id="time-stepping-now-input",F.title="milliseconds",F.style.width="80px",F.style.marginRight="4px",F.setAttribute("readonly","true"),n.appendChild(F)}}updateTimeSteppingOutput(){const t=document.getElementById("time-stepping-steps-input");t&&(t.value=this.stepCount.toString());const i=document.getElementById("time-stepping-now-input");i&&(i.value=this.steppingNow.toFixed(2))}advanceStepsHandler(t){t?.target?.id==="1-step-advance"?(this.steppingNow=this.steppingNow+16.66666666666667,this.stepCount=this.stepCount+1):t?.target?.id==="55-step-advance"&&(this.steppingNow=this.steppingNow+16.66666666666667*55,this.stepCount=this.stepCount+55),this.updateTimeSteppingOutput()}removeTimeSteppingControlsFromDom(){const t=document.getElementById("m2c2kit-time-stepping-div");t&&t.remove()}warmupShadersWithPrimitives(t,i=0){if(t.save(),i==0?t.scale(1/m2c2Globals.canvasScale,1/m2c2Globals.canvasScale):t.scale(1/m2c2Globals.canvasScale*1.13,1/m2c2Globals.canvasScale*1.13),!this.surface)throw new Error("surface is undefined");const n=this.surface.width(),u=this.surface.height(),h=Math.round(n/2)+i,C=Math.round(u/2)+i,F=i,B=i,U=Ft.makePaint(this.canvasKit,x.White,this.canvasKit.PaintStyle.Fill,!0);t.drawRect([0,0,this.surface.width(),this.surface.height()],U);const et=Ft.makePaint(this.canvasKit,x.Black,this.canvasKit.PaintStyle.Fill,!1),ct=Ft.makePaint(this.canvasKit,x.Black,this.canvasKit.PaintStyle.Fill,!0),ut=Ft.makePaint(this.canvasKit,x.Black,this.canvasKit.PaintStyle.Stroke,!1);ut.setStrokeWidth(2);const At=Ft.makePaint(this.canvasKit,x.Black,this.canvasKit.PaintStyle.Stroke,!0);At.setStrokeWidth(2),t.drawCircle(h,C,32,et),t.drawCircle(h,C,32,ct),t.drawCircle(h,C,32,ut),t.drawCircle(h,C,32,At);const yt=this.fontManager,ne=this.fontManager.getFontNames();if(ne.length>0&&yt.fonts[ne[0]].status===Xt.Ready){const Me=yt.getTypeface(ne[0]),We=new this.canvasKit.Font(Me,16*m2c2Globals.canvasScale);t.drawText("abc",h,C,et,We),t.drawText("abc",h,C,ct,We)}const Se=this.takeCurrentSceneSnapshot();t.drawImage(Se,F,B),Se.delete(),t.drawRect([F,B,16,16],et),t.drawRect([F,B,16,16],ct),t.drawRect([F,B,16,16],ut),t.drawRect([F,B,16,16],At),t.restore()}warmupShadersWithScenes(t){[...this.scenes,this.freeNodesScene].forEach(h=>{h.warmup(t)});const i=this.nodes.filter(h=>h.type===at.Sprite).map(h=>h.imageName),n=this.imageManager.images;n&&Object.keys(n).filter(C=>C!=="__outgoingSceneSnapshot").forEach(C=>{if(!i.includes(C)&&n[C].status===qt.Ready){const F=n[C].canvaskitImage;if(!F)throw new Error(`image ${C} is undefined`);t.drawImage(F,0,0)}});const u=new this.canvasKit.Paint;if(u.setColor(this.canvasKit.Color(255,255,255,1)),!this.surface)throw new Error("surface is undefined");t.drawRect([0,0,this.surface.width(),this.surface.height()],u)}stop(){this.currentScene&&(this.currentScene._active=!1),this.gameStopRequested=!0,Wt.removeAll(),this.dispose()}dispose(){this.nodes.filter(t=>t.isDrawable).forEach(t=>t.dispose()),this.fontManager.dispose()}initData(){this.trialIndex=0,this.data={trials:new Array};const t=this.options.trialSchema??{},i=Object.entries(t);for(const[n,u]of i)if(u.type!==void 0&&!this.propertySchemaDataTypeIsValid(u.type))throw new Error(`invalid schema. variable ${n} is type ${u.type}. type must be number, string, boolean, object, or array`)}propertySchemaDataTypeIsValid(t){const i=["string","number","integer","object","array","boolean","null"];if(typeof t=="string")return i.includes(t);let n=!0;if(Array.isArray(t))t.forEach(u=>{i.includes(u)||(n=!1)});else throw new Error(`Invalid data type: ${t}`);return n}getDeviceMetadata(){const t=window.screen;return t.orientation?{userAgent:navigator.userAgent,devicePixelRatio:window.devicePixelRatio,screen:{availHeight:t.availHeight,availWidth:t.availWidth,colorDepth:t.colorDepth,height:t.height,orientation:{type:t.orientation.type,angle:t.orientation.angle},pixelDepth:t.pixelDepth,width:t.width},webGlRenderer:this.webGlRendererInfo}:{userAgent:navigator.userAgent,devicePixelRatio:window.devicePixelRatio,screen:{availHeight:t.availHeight,availWidth:t.availWidth,colorDepth:t.colorDepth,height:t.height,pixelDepth:t.pixelDepth,width:t.width},webGlRenderer:this.webGlRendererInfo}}addTrialData(t,i){if(!this.options.trialSchema)throw new Error("no trial schema were provided in GameOptions. cannot add trial data");if(this.data.trials.length<this.trialIndex+1){const h={},C=Object.entries(this.options.trialSchema);for(const[F]of C)h[F]=null;this.data.trials.push({document_uuid:De.generate(),study_id:this.studyId??null,study_uuid:this.studyUuid??null,session_uuid:this.sessionUuid,activity_uuid:this.uuid,activity_id:this.options.id,activity_publish_uuid:this.options.publishUuid,activity_version:this.options.version,device_timezone:Intl?.DateTimeFormat()?.resolvedOptions()?.timeZone??"",device_timezone_offset_minutes:new Date().getTimezoneOffset(),locale:this.i18n?.locale??null,...h,device_metadata:this.getDeviceMetadata()})}if(!(t in this.options.trialSchema))throw new Error(`trial variable ${t} not defined in schema`);let n;Array.isArray(this.options.trialSchema[t].type)?n=this.options.trialSchema[t].type:n=[this.options.trialSchema[t].type];let u=typeof i;if(u==="object"&&Object.prototype.toString.call(i)==="[object Array]"&&(u="array"),i==null&&(u="null"),!n.includes(u)&&!(u==="number"&&Number.isInteger(i)&&n.includes("integer")))throw new Error(`type for variable ${t} (value: ${i}) is "${u}". Based on schema for this variable, expected type was "${n}"`);this.data.trials[this.trialIndex][t]=i}addTrialSchema(t){Object.keys(t).forEach(n=>{if(!this.options.trialSchema)throw new Error("trial schema is undefined");this.options.trialSchema[n]=t[n]})}addStaticTrialData(t,i){if(!this.options.trialSchema)throw new Error("trial schema is undefined");if(this.options.trialSchema[t]===void 0)throw new Error(`trial variable ${t} not defined in schema`);this.staticTrialSchema[t]=i}trialComplete(){this.data.trials[this.trialIndex]?.locale&&(this.data.trials[this.trialIndex].locale=this.i18n?.locale??null),this.data.trials[this.trialIndex]?.device_metadata&&(this.data.trials[this.trialIndex].device_metadata=this.getDeviceMetadata()),Object.keys(this.staticTrialSchema).length>0&&(this.data.trials[this.trialIndex]={...this.data.trials[this.trialIndex],...this.staticTrialSchema}),this.trialIndex++;const t={type:G.ActivityData,...q.createFrameUpdateTimestamps(),target:this,newData:this.data.trials[this.trialIndex-1],newDataSchema:this.makeNewGameDataSchema(),data:this.data,dataSchema:this.makeGameDataSchema(),activityConfiguration:this.makeGameActivityConfiguration(this.options.parameters??{}),activityConfigurationSchema:this.makeGameActivityConfigurationSchema(this.options.parameters??{}),activityMetrics:this.gameMetrics};this.raiseActivityEventOnListeners(t)}makeNewGameDataSchema(){return{description:`A single trial and metadata from the assessment ${this.name}.`,$comment:`Activity identifier: ${this.options.id}, version: ${this.options.version}.`,$schema:"https://json-schema.org/draft/2019-09/schema",type:"object",properties:{...this.automaticTrialSchema,...this.options.trialSchema,device_metadata:Bn}}}makeGameDataSchema(){return{description:`All trials and metadata from the assessment ${this.name}.`,$comment:`Activity identifier: ${this.options.id}, version: ${this.options.version}.`,$schema:"https://json-schema.org/draft/2019-09/schema",type:"object",required:["trials"],properties:{trials:{type:"array",items:{$ref:"#/$defs/trial"},description:"All trials from the assessment."}},$defs:{trial:{type:"object",properties:{...this.automaticTrialSchema,...this.options.trialSchema,device_metadata:Bn}}}}}makeGameActivityConfiguration(t){const i=JSON.parse(JSON.stringify(t)),{locale:n,fallback_locale:u,missing_localization_color:h,translation:C,...F}=i;for(const B in F)for(const U in F[B])U=="default"&&(F[B]=F[B][U]);return F}makeGameActivityConfigurationSchema(t){const i=JSON.parse(JSON.stringify(t)),{locale:n,fallback_locale:u,missing_localization_color:h,translation:C,...F}=i;for(const B in F){if(!("type"in F[B])&&"value"in F[B]){const U=typeof F[B].default;U!=="bigint"&&U!=="function"&&U!=="symbol"&&U!=="undefined"&&(F[B].type=U)}for(const U in F[B])U=="default"&&delete F[B][U]}return{description:`activity configuration from the assessment ${this.name}`,type:"object",properties:F}}end(){const t={target:this,type:G.ActivityEnd,...q.createFrameUpdateTimestamps()},i={data:this.data,dataSchema:this.makeGameDataSchema(),activityConfiguration:this.makeGameActivityConfiguration(this.options.parameters??{}),activityConfigurationSchema:this.makeGameActivityConfigurationSchema(this.options.parameters??{}),activityMetrics:this.gameMetrics};this.raiseActivityEventOnListeners(t,i)}cancel(){const t={target:this,type:G.ActivityCancel,...q.createFrameUpdateTimestamps()},i={data:this.data,dataSchema:this.makeGameDataSchema(),activityConfiguration:this.makeGameActivityConfiguration(this.options.parameters??{}),activityConfigurationSchema:this.makeGameActivityConfigurationSchema(this.options.parameters??{}),activityMetrics:this.gameMetrics};this.raiseActivityEventOnListeners(t,i)}setupHtmlCanvases(t,i,n,u){m2c2Globals.canvasScale=Math.round(window.devicePixelRatio*100)/100;let h;if(t===void 0){const C=document.getElementsByTagName("canvas");let F=new Array;for(let U=0;U<C.length;U++)F.push(C[U]);if(F=F.filter(U=>!U.id.startsWith("m2c2kit-scratch-canvas")),F.length===0)throw new Error("no html canvas tag was found in the html");const B=F.filter(U=>U.id==="m2c2kit-canvas")[0];B?(h=B,F.length>1&&console.log("using canvas with id 'm2c2kit-canvas'")):(h=C[0],F.length>1&&console.log("using first canvas"))}else if(h=document.getElementById(t),h===void 0)throw new Error(`could not find canvas HTML element with id "${t}"`);if(u||window.innerWidth<i||window.innerHeight<n){const C=n/i;window.innerHeight/window.innerWidth<C?m2c2Globals.rootScale=window.innerHeight/n:m2c2Globals.rootScale=window.innerWidth/i}h.style.width=m2c2Globals.rootScale*i+"px",h.style.height=m2c2Globals.rootScale*n+"px",h.width=m2c2Globals.rootScale*i*m2c2Globals.canvasScale,h.height=m2c2Globals.rootScale*n*m2c2Globals.canvasScale,this.htmlCanvas=h,this.canvasCssWidth=i,this.canvasCssHeight=n,m2c2Globals.canvasCssWidth=i,m2c2Globals.canvasCssHeight=n}setupCanvasKitSurface(){if(this.htmlCanvas===void 0)throw new Error("main html canvas is undefined");window.logWebGl=this.options.logWebGl,this.interceptWebGlCalls();try{this.webGlRendererInfo=fr.getRendererString()}catch{this.webGlRendererInfo="err",fr.dispose()}const t=this.canvasKit.MakeWebGLCanvasSurface(this.htmlCanvas);if(t===null)throw new Error("could not make CanvasKit surface from canvas HTML element");this.surface=t,console.log(`\u26AA CanvasKit surface is backed by ${this.surface.reportBackendTypeIsGPU()?"GPU":"CPU"}`),this.surface.getCanvas().scale(m2c2Globals.canvasScale,m2c2Globals.canvasScale)}interceptWebGlCalls(){if(!this.htmlCanvas.__proto__.m2c2ModifiedGetContext){this.htmlCanvas.__proto__.m2c2ModifiedGetContext=!0;const t=this.htmlCanvas.__proto__.getContext;this.htmlCanvas.__proto__.getContext=function(...i){window.logWebGl&&console.log(`\u{1F53C} getContext(${i.map(u=>u.toString()).join(", ")})`);const n=t.apply(this,[...i]);if(n.__proto__.compileShader&&!n.__proto__.m2c2ModifiedCompileShader){n.__proto__.m2c2ModifiedCompileShader=!0;const u=n.__proto__.compileShader;n.__proto__.compileShader=function(...h){if(window.logWebGl){const C=h[0],F=n.getShaderSource(C);console.log("\u{1F53C} compileShader():"),console.log(F)}return u.apply(this,[...h])}}return n}}}setupFpsFont(){this.fpsTextFont=new this.canvasKit.Font(null,X.FPS_DISPLAY_TEXT_FONT_SIZE*m2c2Globals.canvasScale),this.fpsTextPaint=new this.canvasKit.Paint,this.fpsTextPaint.setColor(this.canvasKit.Color(X.FPS_DISPLAY_TEXT_COLOR[0],X.FPS_DISPLAY_TEXT_COLOR[1],X.FPS_DISPLAY_TEXT_COLOR[2],X.FPS_DISPLAY_TEXT_COLOR[3])),this.fpsTextPaint.setAntiAlias(!0)}setupCanvasDomEventHandlers(){if(this.htmlCanvas===void 0)throw new Error("main html canvas is undefined");this.htmlCanvas.addEventListener("pointerdown",this.htmlCanvasPointerDownHandler.bind(this)),this.htmlCanvas.addEventListener("pointerup",this.htmlCanvasPointerUpHandler.bind(this)),this.htmlCanvas.addEventListener("pointermove",this.htmlCanvasPointerMoveHandler.bind(this)),this.htmlCanvas.addEventListener("touchstart",t=>{t.preventDefault()}),this.htmlCanvas.addEventListener("pointerleave",this.htmlCanvasPointerLeaveHandler.bind(this))}loop(t){if(!this.surface)throw new Error("surface is undefined");if(this.warmupFunctionQueue.length>0){const i=this.warmupFunctionQueue.shift();i?.warmupFunction.call(this,t,i.positionOffset),this.surface.requestAnimationFrame(this.loop.bind(this));return}if(!this.warmupFinished){this.warmupFinished=!0;const i={target:this,type:G.GameWarmupEnd,...q.createFrameUpdateTimestamps()};this.raiseActivityEventOnListeners(i),this.surface.requestAnimationFrame(this.loop.bind(this));return}if(this.soundManager.hasSoundsToDecode()&&navigator.userActivation.hasBeenActive&&this.soundManager.decodeFetchedSounds(),this.gameStopRequested){this.surface.deleteLater();return}if(this.animationFramesRequested++,!this.limitFps||this.animationFramesRequested%Math.round(60/X.LIMITED_FPS_RATE)===0){if(this.currentScene===void 0&&this.incomingSceneTransitions.length===0&&this.eventStore.mode!==ce.Replay)throw new Error("Can not run game without a current or incoming scene");if(this.updateGameTime(),this.eventStore.mode===ce.Replay){const i=this.eventStore.dequeueEvents(Wt.now());this.eventMaterializer.materialize(i),this.eventStore.eventQueueLength===0&&!this.replayEventsButtonEnabled&&(this.setReplayEventsButtonEnabled(!0),this.setStopReplayButtonEnabled(!1))}for(this.handleIncomingSceneTransitions(this.incomingSceneTransitions),this.update(),this.draw(t);this.snapshots.length>0;)this.snapshots.shift()?.delete();this.snapshots.push(this.takeCurrentSceneSnapshot()),this.freeNodesScene.draw(t),this.pendingScreenshot&&(this.handlePendingScreenshot(this.pendingScreenshot),this.pendingScreenshot=void 0)}this.priorUpdateTime=m2c2Globals.now,this.surface.requestAnimationFrame(this.loop.bind(this))}updateGameTime(){this.options.timeStepping?m2c2Globals.now=this.steppingNow:m2c2Globals.now=performance.now(),this.priorUpdateTime?m2c2Globals.deltaTime=m2c2Globals.now-this.priorUpdateTime:m2c2Globals.deltaTime=0}handleIncomingSceneTransitions(t){if(t.length!==0&&(this.snapshots.length>0||t[0].transition.type===de.None)){const i=t.shift();if(i===void 0)throw new Error("no incoming scene transition");const n=i.scene,u=i.transition;if(u.type===de.None){this.currentScene&&(this.currentScene._active=!1),this.currentScene=n,this.currentScene._active=!0,this.raiseSceneEvent(n,"SceneSetup"),this.raiseSceneEvent(n,"SceneAppear");return}if(this.currentSceneSnapshot=this.snapshots.shift(),!this.currentSceneSnapshot)throw new Error("No snapshot available for outgoing scene");const h=this.createOutgoingScene(this.currentSceneSnapshot);h._active=!0,this.currentScene&&(this.currentScene._active=!1),this.currentScene=n,this.currentScene._active=!0,this.raiseSceneEvent(n,"SceneSetup"),this.animateSceneTransition(n,u,h)}}createOutgoingScene(t){const i=new Ue({name:X.OUTGOING_SCENE_NAME});i.size.width=this.canvasCssWidth,i.size.height=this.canvasCssHeight,this.addScene(i);const n={imageName:X.OUTGOING_SCENE_IMAGE_NAME,canvaskitImage:t,width:this.canvasCssWidth,height:this.canvasCssHeight,status:qt.Ready,localize:!1,isFallback:!1};this.imageManager.addImage(n);const u=new oi({name:X.OUTGOING_SCENE_SPRITE_NAME,imageName:X.OUTGOING_SCENE_IMAGE_NAME,position:{x:this.canvasCssWidth/m2c2Globals.rootScale/2,y:this.canvasCssHeight/m2c2Globals.rootScale/2}});return u.scale=1/m2c2Globals.rootScale,i.addChild(u),i}async registerPlugin(t){if(t.type!==si.Game)throw new Error(`registerPlugin(): plugin ${t.id} is not a game plugin. It is a ${t.type} plugin.`);if(this.plugins.includes(t)||this.plugins.map(i=>i.id).includes(t.id))throw new Error(`registerPlugin(): plugin ${t.id} already registered.`);this.plugins.push(t),t.initialize&&await t.initialize(this)}update(){this.executeBeforeUpdatePlugins(),this.updateScenes(),this.executeAfterUpdatePlugins()}updateScenes(){this.scenes.filter(t=>t._active).forEach(t=>t.update()),this.freeNodesScene.update()}executeBeforeUpdatePlugins(){this.plugins.filter(t=>typeof t.beforeUpdate=="function"&&t.disabled!==!0).forEach(t=>{t.beforeUpdate&&t.beforeUpdate(this,m2c2Globals.deltaTime)})}executeAfterUpdatePlugins(){this.plugins.filter(t=>typeof t.afterUpdate=="function"&&t.disabled!==!0).forEach(t=>{t.afterUpdate&&t.afterUpdate(this,m2c2Globals.deltaTime)})}draw(t){this.scenes.filter(i=>i._active).forEach(i=>i.draw(t)),this.drawnFrames++,this.calculateFps(),this.showFps&&this.drawFps(t)}calculateFps(){this.lastFpsUpdate===0?(this.lastFpsUpdate=m2c2Globals.now,this.nextFpsUpdate=m2c2Globals.now+X.FPS_DISPLAY_UPDATE_INTERVAL):m2c2Globals.now>=this.nextFpsUpdate&&(this.fpsRate=this.drawnFrames/((m2c2Globals.now-this.lastFpsUpdate)/1e3),this.drawnFrames=0,this.lastFpsUpdate=m2c2Globals.now,this.nextFpsUpdate=m2c2Globals.now+X.FPS_DISPLAY_UPDATE_INTERVAL,this.gameMetrics.length<this.maximumRecordedActivityMetrics&&this.fpsRate<this.fpsMetricReportThreshold&&this.gameMetrics.push({fps:Number.parseFloat(this.fpsRate.toFixed(2)),fps_interval_ms:X.FPS_DISPLAY_UPDATE_INTERVAL,fps_report_threshold:this.fpsMetricReportThreshold,activity_type:si.Game,activity_uuid:this.uuid,iso8601_timestamp:new Date().toISOString()}))}takeCurrentSceneSnapshot(){if(this.surface===void 0)throw new Error("CanvasKit surface is undefined");return this.surface.makeImageSnapshot()}handlePendingScreenshot(t){if(!this.surface)throw new Error("no surface");let i;if(t.rect.length==4){const u=t.rect[0]*m2c2Globals.canvasScale,h=t.rect[1]*m2c2Globals.canvasScale,C=t.rect[2]*m2c2Globals.canvasScale,F=t.rect[3]*m2c2Globals.canvasScale,B=[u,h,u+C,h+F];i=this.surface.makeImageSnapshot(B)}else i=this.surface.makeImageSnapshot();const n=i.encodeToBytes();t.promiseResolve(n)}takeScreenshot(t,i,n,u){if(!this.surface)throw new Error("no canvaskit surface. unable to take screenshot.");const h=[t,i,n,u].map(C=>C?0:1).reduce((C,F)=>C+F);return new Promise((C,F)=>{switch(h){case 0:{if(!t||!i||!n||!u){F("missing values in arguments for takeScreenshot()");return}this.pendingScreenshot={rect:[t,i,n,u],promiseResolve:C};break}case 4:{this.pendingScreenshot={rect:[],promiseResolve:C};break}default:F("Exactly 0 or 4 arguments must be supplied to takeScreenshot()")}})}animateSceneTransition(t,i,n){const u=i.duration;switch(t._transitioning=!0,n._transitioning=!0,i.type){case de.Slide:{switch(i.direction){case fe.Left:t.position.x=t.size.width,t.run(V.sequence([V.move({point:{x:0,y:0},duration:u,easing:i.easing,runDuringTransition:!0}),V.custom({callback:()=>{t._transitioning=!1,this.raiseSceneEvent(t,"SceneAppear"),this.removeScene(X.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),n.run(V.sequence([V.move({point:{x:-n.size.width,y:0},duration:u,easing:i.easing,runDuringTransition:!0}),V.custom({callback:()=>{n._active=!1,n._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;case fe.Right:t.position.x=-t.size.width,t.run(V.sequence([V.move({point:{x:0,y:0},duration:u,easing:i.easing,runDuringTransition:!0}),V.custom({callback:()=>{t._transitioning=!1,this.raiseSceneEvent(t,"SceneAppear"),this.removeScene(X.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),n.run(V.sequence([V.move({point:{x:n.size.width,y:0},duration:u,easing:i.easing,runDuringTransition:!0}),V.custom({callback:()=>{n._active=!1,n._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;case fe.Up:t.position.y=t.size.height,t.run(V.sequence([V.move({point:{x:0,y:0},duration:u,easing:i.easing,runDuringTransition:!0}),V.custom({callback:()=>{t._transitioning=!1,this.raiseSceneEvent(t,"SceneAppear"),this.removeScene(X.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),n.run(V.sequence([V.move({point:{x:0,y:-n.size.height},duration:u,easing:i.easing,runDuringTransition:!0}),V.custom({callback:()=>{n._active=!1,n._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;case fe.Down:t.position.y=-t.size.height,t.run(V.sequence([V.move({point:{x:0,y:0},duration:u,easing:i.easing,runDuringTransition:!0}),V.custom({callback:()=>{t._transitioning=!1,this.raiseSceneEvent(t,"SceneAppear"),this.removeScene(X.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),n.run(V.sequence([V.move({point:{x:0,y:n.size.height},duration:u,easing:i.easing,runDuringTransition:!0}),V.custom({callback:()=>{n._active=!1,n._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;default:throw new Error("unknown transition direction")}break}default:throw new Error("unknown transition type")}}drawFps(t){t.save();const i=m2c2Globals.canvasScale;if(t.scale(1/i,1/i),!this.fpsTextFont||!this.fpsTextPaint)throw new Error("fps font or paint is undefined");t.drawText("FPS: "+this.fpsRate.toFixed(2),0,0+X.FPS_DISPLAY_TEXT_FONT_SIZE*i,this.fpsTextPaint,this.fpsTextFont),t.restore()}createEventListener(t,i,n,u){const h=this.nodes.filter(F=>F.name===i);h.length>1&&console.warn(`warning: createEventListener() found more than one node with name ${i}. Event listener will be attached to first node found. All nodes that receive tap events should be uniquely named`);const C=h.filter(F=>F.name===i).find(Boolean);if(C===void 0)throw new Error(`could not create event listener. node with name ${i} could not be found in the game node tree`);if(!Object.values(G).includes(t))throw new Error(`game ${this.id}: could not create event listener. event type ${t} is not known`);C.addEventListener(t,n,u)}get nodes(){function t(n,u){u.push(n),n.children.forEach(h=>t(h,u))}const i=new Array;return[...this.scenes,this.freeNodesScene].forEach(n=>t(n,i)),i}get entities(){return this.nodes}htmlCanvasPointerDownHandler(t){t.preventDefault();const i=this.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;if(!this.htmlCanvas)throw new Error("main html canvas is undefined");const n={type:"DomPointerDown",target:this.htmlCanvas,x:t.offsetX/m2c2Globals.rootScale,y:t.offsetY/m2c2Globals.rootScale,...q.createTimestamps()};this.eventStore.addEvent(n);const u={target:i,type:G.PointerDown,handled:!1,...q.createTimestamps()};this.processDomPointerDown(i,u,t),this.processDomPointerDown(this.freeNodesScene,u,t)}htmlCanvasPointerUpHandler(t){t.preventDefault();const i=this.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;const n={target:i,type:G.PointerUp,handled:!1,...q.createTimestamps()};this.processDomPointerUp(i,n,t),this.processDomPointerUp(this.freeNodesScene,n,t)}htmlCanvasPointerMoveHandler(t){t.preventDefault();const i=this.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;const n={target:i,type:G.PointerMove,handled:!1,...q.createTimestamps()};this.processDomPointerMove(i,n,t),this.processDomPointerMove(this.freeNodesScene,n,t)}htmlCanvasPointerLeaveHandler(t){if(!this.currentScene)return;t.preventDefault();const i=this.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;const n={target:i,type:G.PointerLeave,handled:!1,...q.createTimestamps()};this.processDomPointerLeave(i,n,t),this.processDomPointerLeave(this.freeNodesScene,n,t)}processDomPointerDown(t,i,n){i.handled||(t.isUserInteractionEnabled&&this.IsCanvasPointWithinNodeBounds(t,n.offsetX,n.offsetY)&&(t.pressed=!0,t.pressedAndWithinHitArea=!0,t.pressedInitialPointerOffset={x:n.offsetX,y:n.offsetY},this.raiseM2PointerDownEvent(t,i,n),this.raiseTapDownEvent(t,i,n)),t.children&&t.children.filter(u=>!u.hidden).filter(u=>u.isDrawable).sort((u,h)=>h.zPosition-u.zPosition).forEach(u=>this.processDomPointerDown(u,i,n)))}processDomPointerUp(t,i,n){if(!i.handled){if(t.dragging){t.dragging=!1,t.pressed=!1,t.pressedAndWithinHitArea=!1,this.raiseM2DragEndEvent(t,i,n),i.handled=!0;return}t.isUserInteractionEnabled&&t.pressed&&t.pressedAndWithinHitArea?(t.pressed=!1,t.pressedAndWithinHitArea=!1,this.raiseTapUpEvent(t,i,n),this.raiseTapUpAny(t,i,n),this.raiseM2PointerUpEvent(t,i,n)):t.isUserInteractionEnabled&&t.pressed&&t.pressedAndWithinHitArea==!1?(t.pressed=!1,t.pressedAndWithinHitArea=!1,this.raiseTapUpAny(t,i,n)):t.isUserInteractionEnabled&&this.IsCanvasPointWithinNodeBounds(t,n.offsetX,n.offsetY)&&(t.pressed=!1,t.pressedAndWithinHitArea=!1,this.raiseM2PointerUpEvent(t,i,n)),t.children&&t.children.filter(u=>!u.hidden).filter(u=>u.isDrawable).sort((u,h)=>h.zPosition-u.zPosition).forEach(u=>this.processDomPointerUp(u,i,n))}}processDomPointerMove(t,i,n){if(!i.handled){if(t.isUserInteractionEnabled&&t.draggable&&t.pressed){let u=!1,h,C;t.dragging===!1?(t.dragging=!0,u=!0,h=n.offsetX-t.pressedInitialPointerOffset.x,C=n.offsetY-t.pressedInitialPointerOffset.y):(h=n.offsetX-t.draggingLastPointerOffset.x,C=n.offsetY-t.draggingLastPointerOffset.y),t.position.x+=h,t.position.y+=C,t.draggingLastPointerOffset={x:n.offsetX,y:n.offsetY},i.handled=!0,u?this.raiseM2DragStartEvent(t,i,n):this.raiseM2DragEvent(t,i,n);return}t.isUserInteractionEnabled&&t.pressed&&t.pressedAndWithinHitArea&&!this.IsCanvasPointWithinNodeBounds(t,n.offsetX,n.offsetY)&&(t.pressedAndWithinHitArea=!1,this.raiseTapLeaveEvent(t,i,n)),t.isUserInteractionEnabled&&this.IsCanvasPointWithinNodeBounds(t,n.offsetX,n.offsetY)&&(this.raiseM2PointerMoveEvent(t,i,n),t.withinHitArea=!0),t.isUserInteractionEnabled&&t.withinHitArea&&!this.IsCanvasPointWithinNodeBounds(t,n.offsetX,n.offsetY)&&(t.withinHitArea=!1,this.raiseM2PointerLeaveEvent(t,i,n)),t.children&&t.children.filter(u=>!u.hidden).filter(u=>u.isDrawable).sort((u,h)=>h.zPosition-u.zPosition).forEach(u=>this.processDomPointerMove(u,i,n))}}processDomPointerLeave(t,i,n){if(!i.handled){if(t.dragging){const u={target:t,type:G.DragEnd,handled:!1,...q.createTimestamps()};t.dragging=!1,t.pressed=!1,t.pressedAndWithinHitArea=!1,this.raiseM2DragEndEvent(t,u,n);return}t.isUserInteractionEnabled&&t.pressed&&t.pressedAndWithinHitArea&&!this.IsCanvasPointWithinNodeBounds(t,n.offsetX,n.offsetY)&&(t.pressedAndWithinHitArea=!1,this.raiseTapLeaveEvent(t,i,n)),t.isUserInteractionEnabled&&t.withinHitArea&&!this.IsCanvasPointWithinNodeBounds(t,n.offsetX,n.offsetY)&&(t.withinHitArea=!1,this.raiseM2PointerLeaveEvent(t,i,n)),t.children&&t.children.filter(u=>!u.hidden).filter(u=>u.isDrawable).sort((u,h)=>h.zPosition-u.zPosition).forEach(u=>this.processDomPointerLeave(u,i,n))}}raiseM2PointerDownEvent(t,i,n){i.target=t,i.type=G.PointerDown,this.raiseEventOnListeningNodes(t,i,n)}raiseTapDownEvent(t,i,n){i.target=t,i.type=G.TapDown,this.raiseEventOnListeningNodes(t,i,n)}raiseTapLeaveEvent(t,i,n){i.target=t,i.type=G.TapLeave,this.raiseEventOnListeningNodes(t,i,n)}raiseM2PointerUpEvent(t,i,n){i.target=t,i.type=G.PointerUp,this.raiseEventOnListeningNodes(t,i,n)}raiseTapUpEvent(t,i,n){i.target=t,i.type=G.TapUp,this.raiseEventOnListeningNodes(t,i,n)}raiseTapUpAny(t,i,n){i.target=t,i.type=G.TapUpAny,this.raiseEventOnListeningNodes(t,i,n)}raiseM2PointerMoveEvent(t,i,n){i.target=t,i.type=G.PointerMove,this.raiseEventOnListeningNodes(t,i,n)}raiseM2PointerLeaveEvent(t,i,n){i.target=t,i.type=G.PointerLeave,this.raiseEventOnListeningNodes(t,i,n)}raiseM2DragStartEvent(t,i,n){i.target=t,i.type=G.DragStart,this.raiseEventOnListeningNodes(t,i,n)}raiseM2DragEvent(t,i,n){i.target=t,i.type=G.Drag,this.raiseEventOnListeningNodes(t,i,n)}raiseM2DragEndEvent(t,i,n){i.target=t,i.type=G.DragEnd,this.raiseEventOnListeningNodes(t,i,n)}raiseSceneEvent(t,i){const n={target:t,type:i,...q.createFrameUpdateTimestamps()};t.eventListeners.filter(u=>u.type===i).forEach(u=>u.callback(n))}calculatePointWithinNodeFromDomPointerEvent(t,i){let n=t.size.width,u=t.size.height;if(t.type===at.Shape&&t.shapeType===Ut.Circle){const et=t.circleOfRadius;if(!et)throw"circleOfRadius is undefined";n=et*2,u=et*2}let h=i.offsetX,C=i.offsetY;const F=q.calculateNodeAbsoluteBoundingBox(t);q.nodeOrAncestorHasBeenRotated(t)&&q.calculateRotationTransforms(t).forEach(ct=>{const ut=q.rotatePoint({x:h,y:C},-ct.radians,ct.center);h=ut.x,C=ut.y});const B=(h-F.xMin)/(F.xMax-F.xMin)*n,U=(C-F.yMin)/(F.yMax-F.yMin)*u;return{x:B,y:U}}onStart(t,i){this.addEventListener(G.ActivityStart,t,i)}onCancel(t,i){this.addEventListener(G.ActivityCancel,t,i)}onEnd(t,i){this.addEventListener(G.ActivityEnd,t,i)}onData(t,i){this.addEventListener(G.ActivityData,t,i)}onWarmupStart(t,i){this.addEventListener(G.GameWarmupStart,t,i)}onWarmupEnd(t,i){this.addEventListener(G.GameWarmupEnd,t,i)}addEventListener(t,i,n){const u={type:t,activityUuid:this.uuid,callback:i};n?.replaceExisting&&(this.eventListeners=this.eventListeners.filter(h=>!(h.activityUuid===u.activityUuid&&h.type===u.type))),this.eventListeners.push(u)}raiseActivityEventOnListeners(t,i){i&&(t={...t,...i}),this.eventListeners.filter(n=>n.type===t.type).forEach(n=>{n.callback(t)})}raiseEventOnListeningNodes(t,i,n){t.eventListeners.filter(u=>u.type===i.type).forEach(u=>{if(u.nodeUuid===t.uuid){switch(i.target=t,i.type){case G.PointerDown:case G.PointerMove:case G.PointerUp:case G.PointerLeave:i.point=this.calculatePointWithinNodeFromDomPointerEvent(t,n),i.buttons=n.buttons,u.callback(i);break;case G.TapDown:case G.TapUp:case G.TapUpAny:case G.TapLeave:i.point=this.calculatePointWithinNodeFromDomPointerEvent(t,n),i.buttons=n.buttons,u.callback(i);break;case G.DragStart:case G.Drag:case G.DragEnd:i.position={x:t.position.x,y:t.position.y},i.buttons=n.buttons,u.callback(i);break}t.suppressEvents||this.eventStore.addEvent(i)}})}sceneCanReceiveUserInteraction(t){return!!(t._active&&t._transitioning===!1)}IsCanvasPointWithinNodeBounds(t,i,n){if(!t.isDrawable)throw"only drawable nodes can receive pointer events";if(t.type===at.Shape&&t.shapeType===Ut.Circle){const h=q.calculateNodeAbsoluteBoundingBox(t),C=t.circleOfRadius;if(!C)throw"circleOfRadius is undefined";const F={x:h.xMin+C*t.absoluteScale,y:h.yMin+C*t.absoluteScale};return Math.sqrt(Math.pow(i-F.x,2)+Math.pow(n-F.y,2))<=C*t.absoluteScale}if(t.size.width===0||t.size.height===0||t.type===at.TextLine&&isNaN(t.size.width))return!1;const u=q.calculateRotatedPoints(t);return t.isUserInteractionEnabled&&q.isPointInsideRectangle({x:i,y:n},u)}}function ua(){globalThis.m2c2Globals={now:performance.now(),iso8601Now:"",deltaTime:NaN,canvasScale:NaN,rootScale:1,canvasCssWidth:NaN,canvasCssHeight:NaN,m2NodeClassRegistry:{},__sequence:0,get eventSequence(){return m2c2Globals.__sequence++,m2c2Globals.__sequence-1}}}ua();const Wn=class Gn{constructor(t){this.startTime=NaN,this.stopTime=NaN,this.stopped=!0,this.cumulativeElapsed=NaN,this.name=t}static now(){return window.performance.now()}static start(t){let i=this._timers.filter(n=>n.name===t).find(Boolean);if(i===void 0)i=new Gn(t),i.cumulativeElapsed=0,this._timers.push(i);else if(i.stopped==!1)throw new Error(`can't start timer. timer with name ${t} is already started`);i.startTime=window.performance.now(),i.stopped=!1}static stop(t){const i=this._timers.filter(n=>n.name===t).find(Boolean);if(i===void 0)throw new Error(`can't stop timer. timer with name ${t} does not exist`);if(i.stopped===!0)throw new Error(`can't stop timer. timer with name ${t} is already stopped`);i.stopTime=window.performance.now(),i.cumulativeElapsed=i.cumulativeElapsed+i.stopTime-i.startTime,i.stopped=!0}static restart(t){const i=this._timers.filter(n=>n.name===t).find(Boolean);if(i===void 0)throw new Error(`can't restart timer. timer with name ${t} does not exist`);i.startTime=window.performance.now(),i.cumulativeElapsed=0,i.stopped=!1}static elapsed(t){const i=this._timers.filter(n=>n.name===t).find(Boolean);if(i===void 0)throw new Error(`can't get elapsed time. timer with name ${t} does not exist`);return i.stopped?i.cumulativeElapsed:i.cumulativeElapsed+window.performance.now()-i.startTime}static remove(t){if(this._timers.filter(n=>n.name===t).find(Boolean)===void 0)throw new Error(`can't remove timer. timer with name ${t} does not exist`);this._timers=this._timers.filter(n=>n.name!=t)}static removeAll(){this._timers=new Array}static exists(t){return this._timers.some(i=>i.name===t)}};Wn._timers=new Array;let da=Wn;class pr{static SingleFromRange(t,i){return Math.floor(Math.random()*(i-t+1))+t}static FromRangeWithoutReplacement(t,i,n){if(t>n-i+1)throw new Error(`number of requested draws (n = ${t}) is greater than number of integers in range [ ${i}, ${n}]`);const u=new Array;for(let h=0;h<t;h++){const C=pr.SingleFromRange(i,n);u.includes(C)?t++:u.push(C)}return u}static FromGridWithoutReplacement(t,i,n,u){const h=new Array,C=i*n-1,F=this.FromRangeWithoutReplacement(t,0,C);let B=0,U=NaN;for(;B<t;){const et=F[B]%n,ct=(F[B]-et)/n;if(u===void 0||u(ct,et))h.push({row:ct,column:et}),B++;else{do U=this.FromRangeWithoutReplacement(1,0,C)[0];while(F.includes(U));F[B]=U}}return h}}class fa extends re{constructor(t){super(t),this.type=at.SoundPlayer,this.isDrawable=!1,this.soundName=t.soundName}initialize(){}dispose(){}duplicate(t){throw new Error("Method not implemented.")}}class pa extends re{constructor(t){if(super(t),this.type=at.SoundRecorder,this.isDrawable=!1,this._isRecording=!1,this._isPaused=!1,this.audioChunks=[],this.timerUuid="",t?.mimeType){const i=this.getMediaRecorderSupportedAudioMimeTypes();if(i.includes(t.mimeType))this.mimeType=t.mimeType;else if(console.warn(`Unsupported MIME type in SoundRecorderOptions: ${t.mimeType}. Supported types are: ${i}.`),t.backupMimeTypes){const n=this.getSupportedBackupMimeType(t.backupMimeTypes);n&&(this.mimeType=n,console.log(`Using backup MIME type: ${n}.`))}}t?.audioTrackConstraints&&(this.audioTrackConstraints=t.audioTrackConstraints),t?.maximumDuration&&(this.maximumDuration=t.maximumDuration)}initialize(){}async start(){if(this.isRecording)throw new Error("cannot start SoundRecorder because it is already started.");const t=this.getMediaRecorderSupportedAudioMimeTypes();if(t.length===0)throw new Error("SoundRecorder found no supported MIME types for MediaRecorder.");this.mimeType||(this.mimeType=t[0],console.log(`Using MIME type: ${this.mimeType}.`));let i;try{i=await navigator.mediaDevices.getUserMedia({audio:this.audioTrackConstraints?this.audioTrackConstraints:!0})}catch{throw new Error("Error getting user media.")}if(!i)throw new Error("no stream.");const n=i.getAudioTracks();this.mediaTrackSettings=n?.map(u=>u.getSettings()),this.mediaRecorder=new MediaRecorder(i,{mimeType:this.mimeType}),this.mediaRecorder.ondataavailable=u=>{this.audioChunks.push(u.data)},this.mediaRecorder.onerror=u=>{throw new Error(`MediaRecorder error: ${u?.error?.message} ${u?.message}`)},this.mediaRecorder.start(),this.beginIso8601Timestamp=new Date().toISOString(),this.timerUuid=De.generate(),Wt.startNew(this.timerUuid),this._isRecording=!0,this._isPaused=!1}async stop(){if(!this.isRecording)throw new Error("cannot stop SoundRecorder because it has not started.");return new Promise(t=>{if(!this.mediaRecorder)throw new Error("no media recorder");this.mediaRecorder.onstop=async()=>{if(!this.mimeType)throw new Error("no mimeType");this._isRecording=!1,this._isPaused=!1;const i=new Blob(this.audioChunks,{type:this.getMimeTypeWithoutCodecs(this.mimeType)}),n=await this.blobToBase64(i);t({mimeType:this.mimeType,beginIso8601Timestamp:this.beginIso8601Timestamp??"",endIso8601Timestamp:this.endIso8601Timestamp??"",duration:Wt.elapsed(this.timerUuid),audioTrackSettings:this.mediaTrackSettings,audioBase64:n,audioBlob:i})},this.mediaRecorder.stop(),this.endIso8601Timestamp=new Date().toISOString(),this.isPaused||Wt.stop(this.timerUuid)})}pause(){if(!this.isRecording)throw new Error("cannot pause SoundRecorder because it is not started.");if(this.isPaused)throw new Error("cannot pause SoundRecorder because it is already paused.");this.mediaRecorder?.pause(),this._isPaused=!0,Wt.stop(this.timerUuid)}resume(){if(!this.isRecording)throw new Error("cannot resume SoundRecorder because it is not started.");if(!this.isPaused)throw new Error("cannot resume SoundRecorder because it is not paused.");this.mediaRecorder?.resume(),this._isPaused=!1,Wt.start(this.timerUuid)}get isRecording(){return this._isRecording}get isPaused(){return this._isPaused}update(){if(super.update(),this.isRecording&&!this.isPaused&&this.maximumDuration!==void 0&&Wt.elapsed(this.timerUuid)>this.maximumDuration){this.pause();return}}getMediaRecorderSupportedAudioMimeTypes(){const t=["audio"],i=["webm","ogg","mp3","mp4","x-matroska","3gpp","3gpp2","3gp2","quicktime","mpeg","aac","flac","x-flac","wave","wav","x-wav","x-pn-wav","not-supported"],n=["vp9","vp9.0","vp8","vp8.0","avc1","av1","h265","h.265","h264","h.264","opus","vorbis","pcm","aac","mpeg","mp4a","rtx","red","ulpfec","g722","pcmu","pcma","cn","telephone-event","not-supported"];return[...new Set(i.flatMap(u=>t.flatMap(h=>[`${h}/${u}`]))),...new Set(i.flatMap(u=>n.flatMap(h=>t.flatMap(C=>[`${C}/${u};codecs=${h}`])))),...new Set(i.flatMap(u=>n.flatMap(h=>n.flatMap(C=>t.flatMap(F=>[`${F}/${u};codecs="${h}, ${C}"`])))))].filter(u=>MediaRecorder.isTypeSupported(u))}blobToBase64(t){return new Promise((i,n)=>{const u=new FileReader;u.onloadend=()=>{const h=u.result?.toString().split(",").pop();if(h===void 0)throw new Error("base64WithoutPrefix is undefined.");i(h)},u.onerror=n,u.readAsDataURL(t)})}getMimeTypeWithoutCodecs(t){const i=t.match(/^[^;]+/);return i?i[0]:""}getSupportedBackupMimeType(t){const i=this.getMediaRecorderSupportedAudioMimeTypes();for(const n of t)if(i.includes(n))return n}dispose(){}duplicate(t){throw new Error(`Method not implemented. ${t}`)}}class ma{static create(t){return new Array}}console.log("\u26AA @m2c2kit/core version 0.3.19 (0679492d)");export{V as Action,si as ActivityType,Ft as CanvasKitHelpers,Vs as ColorfulMutablePath,Xs as Composite,X as Constants,Dt as ConstraintType,pn as CustomAction,bn as Dimensions,Te as Easings,j as Equal,Js as Equals,An as EventStore,ce as EventStoreMode,wn as FadeAlphaAction,_n as FontManager,ca as Game,dn as GroupAction,xi as I18n,or as ImageManager,ki as Label,ze as LabelHorizontalAlignmentMode,Pn as LayoutConstraint,da as LegacyTimer,G as M2EventType,qt as M2ImageStatus,re as M2Node,Cn as M2NodeFactory,at as M2NodeType,zt as M2SoundStatus,q as M2c2KitHelpers,vn as MoveAction,Ni as MutablePath,Ln as NoneTransition,mn as PlayAction,pr as RandomDraws,sr as RepeatAction,fn as RepeatForeverAction,Sn as RotateAction,yn as ScaleAction,Ue as Scene,zn as SceneTransition,un as SequenceAction,ai as Shape,Ut as ShapeType,Dn as SlideTransition,Un as SoundManager,fa as SoundPlayer,pa as SoundRecorder,oi as Sprite,ma as Story,Oi as TextLine,Wt as Timer,Be as Transition,fe as TransitionDirection,de as TransitionType,De as Uuid,gn as WaitAction,x as WebColors,fr as WebGlInfo,Fe as handleInterfaceOptions};