@m2c2kit/core 0.3.15 → 0.3.17
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/assets/{canvaskit.wasm → canvaskit-0.39.1.wasm} +0 -0
- package/dist/index.d.ts +1574 -1226
- package/dist/index.js +4864 -5319
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +3 -0
- package/package.json +16 -12
- package/assets/css/bootstrap-datepicker.standalone.css +0 -539
- package/assets/css/bootstrap-slider.css +0 -328
- package/assets/css/defaultV2.css +0 -3655
- package/assets/css/m2c2kit.css +0 -72
- package/assets/css/modern.css +0 -2564
- package/assets/css/nouislider.css +0 -309
- package/assets/css/select2.css +0 -712
- package/assets/css/survey.css +0 -1006
- package/index.html +0 -31
|
@@ -0,0 +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};
|