@m2c2kit/core 0.3.30 → 0.3.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1,4 +1,4 @@
1
- var dt=(m=>(m.Node="Node",m.Scene="Scene",m.Sprite="Sprite",m.Label="Label",m.TextLine="TextLine",m.Shape="Shape",m.Composite="Composite",m.SoundPlayer="SoundPlayer",m.SoundRecorder="SoundRecorder",m))(dt||{});const jt={Deferred:"Deferred",WillFetch:"WillFetch",Fetching:"Fetching",Fetched:"Fetched",Decoding:"Decoding",Ready:"Ready",Error:"Error"};var mt=(m=>(m.Sequence="Sequence",m.Group="Group",m.Wait="Wait",m.Custom="Custom",m.Move="Move",m.Scale="Scale",m.FadeAlpha="FadeAlpha",m.Rotate="Rotate",m.Play="Play",m.Repeat="Repeat",m.RepeatForever="RepeatForever",m))(mt||{});class C extends Error{constructor(...t){super(...t),this.name="M2Error",Object.setPrototypeOf(this,C.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,C)}}const xt=class nt{static toTypeAsString(t){switch(t){case nt.none:return"None";case nt.linear:return"Linear";case nt.quadraticIn:return"QuadraticIn";case nt.quadraticOut:return"QuadraticOut";case nt.quadraticInOut:return"QuadraticInOut";case nt.cubicIn:return"CubicIn";case nt.cubicOut:return"CubicOut";case nt.cubicInOut:return"CubicInOut";case nt.quarticIn:return"QuarticIn";case nt.quarticOut:return"QuarticOut";case nt.quarticInOut:return"QuarticInOut";case nt.quinticIn:return"QuinticIn";case nt.quinticOut:return"QuinticOut";case nt.quinticInOut:return"QuinticInOut";case nt.sinusoidalIn:return"SinusoidalIn";case nt.sinusoidalOut:return"SinusoidalOut";case nt.sinusoidalInOut:return"SinusoidalInOut";case nt.exponentialIn:return"ExponentialIn";case nt.exponentialOut:return"ExponentialOut";case nt.exponentialInOut:return"ExponentialInOut";case nt.circularIn:return"CircularIn";case nt.circularOut:return"CircularOut";case nt.circularInOut:return"CircularInOut";default:throw new C("Easings.toTypeAsString(): Unknown easing function")}}static fromTypeAsString(t){switch(t){case"None":return nt.none;case"Linear":return nt.linear;case"QuadraticIn":return nt.quadraticIn;case"QuadraticOut":return nt.quadraticOut;case"QuadraticInOut":return nt.quadraticInOut;case"CubicIn":return nt.cubicIn;case"CubicOut":return nt.cubicOut;case"CubicInOut":return nt.cubicInOut;case"QuarticIn":return nt.quarticIn;case"QuarticOut":return nt.quarticOut;case"QuarticInOut":return nt.quarticInOut;case"QuinticIn":return nt.quinticIn;case"QuinticOut":return nt.quinticOut;case"QuinticInOut":return nt.quinticInOut;case"SinusoidalIn":return nt.sinusoidalIn;case"SinusoidalOut":return nt.sinusoidalOut;case"SinusoidalInOut":return nt.sinusoidalInOut;case"ExponentialIn":return nt.exponentialIn;case"ExponentialOut":return nt.exponentialOut;case"ExponentialInOut":return nt.exponentialInOut;case"CircularIn":return nt.circularIn;case"CircularOut":return nt.circularOut;case"CircularInOut":return nt.circularInOut;default:throw new C(`Easings.fromTypeAsString(): Unknown easing function type ${t}`)}}};xt.none=(m,t,i,r)=>i+t,xt.linear=(m,t,i,r)=>i*m/r+t,xt.quadraticIn=(m,t,i,r)=>(m/=r,i*m*m+t),xt.quadraticOut=(m,t,i,r)=>(m/=r,-i*m*(m-2)+t),xt.quadraticInOut=(m,t,i,r)=>(m/=r/2,m<1?i/2*m*m+t:(m--,-i/2*(m*(m-2)-1)+t)),xt.cubicIn=(m,t,i,r)=>(m/=r,i*m*m*m+t),xt.cubicOut=(m,t,i,r)=>(m/=r,m--,i*(m*m*m+1)+t),xt.cubicInOut=(m,t,i,r)=>(m/=r/2,m<1?i/2*m*m*m+t:(m-=2,i/2*(m*m*m+2)+t)),xt.quarticIn=(m,t,i,r)=>(m/=r,i*m*m*m*m+t),xt.quarticOut=(m,t,i,r)=>(m/=r,m--,-i*(m*m*m*m-1)+t),xt.quarticInOut=(m,t,i,r)=>(m/=r/2,m<1?i/2*m*m*m*m+t:(m-=2,-i/2*(m*m*m*m-2)+t)),xt.quinticIn=(m,t,i,r)=>(m/=r,i*m*m*m*m*m+t),xt.quinticOut=(m,t,i,r)=>(m/=r,m--,i*(m*m*m*m*m+1)+t),xt.quinticInOut=(m,t,i,r)=>(m/=r/2,m<1?i/2*m*m*m*m*m+t:(m-=2,i/2*(m*m*m*m*m+2)+t)),xt.sinusoidalIn=(m,t,i,r)=>-i*Math.cos(m/r*(Math.PI/2))+i+t,xt.sinusoidalOut=(m,t,i,r)=>i*Math.sin(m/r*(Math.PI/2))+t,xt.sinusoidalInOut=(m,t,i,r)=>-i/2*(Math.cos(Math.PI*m/r)-1)+t,xt.exponentialIn=(m,t,i,r)=>i*Math.pow(2,10*(m/r-1))+t,xt.exponentialOut=(m,t,i,r)=>i*(-Math.pow(2,-10*m/r)+1)+t,xt.exponentialInOut=(m,t,i,r)=>(m/=r/2,m<1?i/2*Math.pow(2,10*(m-1))+t:(m--,i/2*(-Math.pow(2,-10*m)+2)+t)),xt.circularIn=(m,t,i,r)=>(m/=r,-i*(Math.sqrt(1-m*m)-1)+t),xt.circularOut=(m,t,i,r)=>(m/=r,m--,i*Math.sqrt(1-m*m)+t),xt.circularInOut=(m,t,i,r)=>(m/=r/2,m<1?-i/2*(Math.sqrt(1-m*m)-1)+t:(m-=2,i/2*(Math.sqrt(1-m*m)+1)+t));let De=xt;var Kt=(m=>(m.Undefined="Undefined",m.Rectangle="Rectangle",m.Circle="Circle",m.Path="Path",m))(Kt||{});const xr=class ss{constructor(t){this.startTime=NaN,this.stopTime=NaN,this.stopped=!0,this.cumulativeElapsed=NaN,this.name=t}static now(){return window.performance.now()}static new(t){this._timers=this._timers.filter(r=>r.name!==t);const i=new ss(t);i.cumulativeElapsed=0,this._timers.push(i)}static startNew(t){this.new(t),this.start(t)}static start(t){const i=this._timers.filter(r=>r.name===t).find(Boolean);if(i===void 0)throw new C(`can't start timer. timer with name ${t} does not exist.`);if(i.stopped===!1)throw new C(`can't start timer. timer with name ${t} is already started.`);i.startTime=window.performance.now(),i.stopped=!1}static stop(t){const i=this._timers.filter(r=>r.name===t).find(Boolean);if(i===void 0)throw new C(`can't stop timer. timer with name ${t} does not exist.`);if(i.stopped===!0)throw new C(`can't stop timer. timer with name ${t} is already stopped.`);i.stopTime=window.performance.now(),i.cumulativeElapsed=i.cumulativeElapsed+i.stopTime-i.startTime,i.stopped=!0}static elapsed(t){const i=this._timers.filter(r=>r.name===t).find(Boolean);if(i===void 0)throw new C(`can't get elapsed time. timer with name ${t} does not exist.`);return i.stopped?i.cumulativeElapsed:i.cumulativeElapsed+window.performance.now()-i.startTime}static remove(t){if(this._timers.filter(r=>r.name===t).find(Boolean)===void 0)throw new C(`can't remove timer. timer with name ${t} does not exist.`);this._timers=this._timers.filter(r=>r.name!=t)}static removeAll(){this._timers=new Array}static exists(t){return this._timers.some(i=>i.name===t)}};xr._timers=new Array;let Vt=xr;class R{}R.Transparent=[0,0,0,0],R.MediumVioletRed=[199,21,133,1],R.DeepPink=[255,20,147,1],R.PaleVioletRed=[219,112,147,1],R.HotPink=[255,105,180,1],R.LightPink=[255,182,193,1],R.Pink=[255,192,203,1],R.DarkRed=[139,0,0,1],R.Red=[255,0,0,1],R.Firebrick=[178,34,34,1],R.Crimson=[220,20,60,1],R.IndianRed=[205,92,92,1],R.LightCoral=[240,128,128,1],R.Salmon=[250,128,114,1],R.DarkSalmon=[233,150,122,1],R.LightSalmon=[255,160,122,1],R.OrangeRed=[255,69,0,1],R.Tomato=[255,99,71,1],R.DarkOrange=[255,140,0,1],R.Coral=[255,127,80,1],R.Orange=[255,165,0,1],R.DarkKhaki=[189,183,107,1],R.Gold=[255,215,0,1],R.Khaki=[240,230,140,1],R.PeachPuff=[255,218,185,1],R.Yellow=[255,255,0,1],R.PaleGoldenrod=[238,232,170,1],R.Moccasin=[255,228,181,1],R.PapayaWhip=[255,239,213,1],R.LightGoldenrodYellow=[250,250,210,1],R.LemonChiffon=[255,250,205,1],R.LightYellow=[255,255,224,1],R.Maroon=[128,0,0,1],R.Brown=[165,42,42,1],R.SaddleBrown=[139,69,19,1],R.Sienna=[160,82,45,1],R.Chocolate=[210,105,30,1],R.DarkGoldenrod=[184,134,11,1],R.Peru=[205,133,63,1],R.RosyBrown=[188,143,143,1],R.Goldenrod=[218,165,32,1],R.SandyBrown=[244,164,96,1],R.Tan=[210,180,140,1],R.Burlywood=[222,184,135,1],R.Wheat=[245,222,179,1],R.NavajoWhite=[255,222,173,1],R.Bisque=[255,228,196,1],R.BlanchedAlmond=[255,235,205,1],R.Cornsilk=[255,248,220,1],R.DarkGreen=[0,100,0,1],R.Green=[0,128,0,1],R.DarkOliveGreen=[85,107,47,1],R.ForestGreen=[34,139,34,1],R.SeaGreen=[46,139,87,1],R.Olive=[128,128,0,1],R.OliveDrab=[107,142,35,1],R.MediumSeaGreen=[60,179,113,1],R.LimeGreen=[50,205,50,1],R.Lime=[0,255,0,1],R.SpringGreen=[0,255,127,1],R.MediumSpringGreen=[0,250,154,1],R.DarkSeaGreen=[143,188,143,1],R.MediumAquamarine=[102,205,170,1],R.YellowGreen=[154,205,50,1],R.LawnGreen=[124,252,0,1],R.Chartreuse=[127,255,0,1],R.LightGreen=[144,238,144,1],R.GreenYellow=[173,255,47,1],R.PaleGreen=[152,251,152,1],R.Teal=[0,128,128,1],R.DarkCyan=[0,139,139,1],R.LightSeaGreen=[32,178,170,1],R.CadetBlue=[95,158,160,1],R.DarkTurquoise=[0,206,209,1],R.MediumTurquoise=[72,209,204,1],R.Turquoise=[64,224,208,1],R.Aqua=[0,255,255,1],R.Cyan=[0,255,255,1],R.Aquamarine=[127,255,212,1],R.PaleTurquoise=[175,238,238,1],R.LightCyan=[224,255,255,1],R.Navy=[0,0,128,1],R.DarkBlue=[0,0,139,1],R.MediumBlue=[0,0,205,1],R.Blue=[0,0,255,1],R.MidnightBlue=[25,25,112,1],R.RoyalBlue=[65,105,225,1],R.SteelBlue=[70,130,180,1],R.DodgerBlue=[30,144,255,1],R.DeepSkyBlue=[0,191,255,1],R.CornflowerBlue=[100,149,237,1],R.SkyBlue=[135,206,235,1],R.LightSkyBlue=[135,206,250,1],R.LightSteelBlue=[176,196,222,1],R.LightBlue=[173,216,230,1],R.PowderBlue=[176,224,230,1],R.Indigo=[75,0,130,1],R.Purple=[128,0,128,1],R.DarkMagenta=[139,0,139,1],R.DarkViolet=[148,0,211,1],R.DarkSlateBlue=[72,61,139,1],R.BlueViolet=[138,43,226,1],R.DarkOrchid=[153,50,204,1],R.Fuchsia=[255,0,255,1],R.Magenta=[255,0,255,1],R.SlateBlue=[106,90,205,1],R.MediumSlateBlue=[123,104,238,1],R.MediumOrchid=[186,85,211,1],R.MediumPurple=[147,112,219,1],R.Orchid=[218,112,214,1],R.Violet=[238,130,238,1],R.Plum=[221,160,221,1],R.Thistle=[216,191,216,1],R.Lavender=[230,230,250,1],R.MistyRose=[255,228,225,1],R.AntiqueWhite=[250,235,215,1],R.Linen=[250,240,230,1],R.Beige=[245,245,220,1],R.WhiteSmoke=[245,245,245,1],R.LavenderBlush=[255,240,245,1],R.OldLace=[253,245,230,1],R.AliceBlue=[240,248,255,1],R.Seashell=[255,245,238,1],R.GhostWhite=[248,248,255,1],R.Honeydew=[240,255,240,1],R.FloralWhite=[255,250,240,1],R.Azure=[240,255,255,1],R.MintCream=[245,255,250,1],R.Snow=[255,250,250,1],R.Ivory=[255,255,240,1],R.White=[255,255,255,1],R.Black=[0,0,0,1],R.DarkSlateGray=[47,79,79,1],R.DimGray=[105,105,105,1],R.SlateGray=[112,128,144,1],R.Gray=[128,128,128,1],R.LightSlateGray=[119,136,153,1],R.DarkGray=[169,169,169,1],R.Silver=[192,192,192,1],R.LightGray=[211,211,211,1],R.Gainsboro=[220,220,220,1],R.RebeccaPurple=[102,51,153,1];class Q{}Q.FPS_DISPLAY_TEXT_FONT_SIZE=12,Q.FPS_DISPLAY_TEXT_COLOR=[0,0,0,.5],Q.FPS_DISPLAY_UPDATE_INTERVAL=1e3,Q.MAXIMUM_RECORDED_ACTIVITY_METRICS=32,Q.FPS_METRIC_REPORT_THRESHOLD=59,Q.DEFAULT_SCENE_BACKGROUND_COLOR=R.White,Q.DEFAULT_SHAPE_FILL_COLOR=R.Red,Q.DEFAULT_PATH_STROKE_COLOR=R.Red,Q.DEFAULT_PATH_LINE_WIDTH=2,Q.DEFAULT_FONT_COLOR=R.Black,Q.DEFAULT_FONT_SIZE=16,Q.LIMITED_FPS_RATE=5,Q.FREE_NODES_SCENE_NAME="__freeNodesScene",Q.OUTGOING_SCENE_NAME="__outgoingScene",Q.OUTGOING_SCENE_SPRITE_NAME="__outgoingSceneSprite",Q.OUTGOING_SCENE_IMAGE_NAME="__outgoingSceneSnapshot",Q.SESSION_INITIALIZATION_POLLING_INTERVAL_MS=50,Q.MODULE_METADATA_PLACEHOLDER={name:"",version:"",dependencies:{}},Q.DEFAULT_ROOT_ELEMENT_ID="m2c2kit",Q.ERUDA_URL="https://cdn.jsdelivr.net/npm/eruda@3.4.1/eruda.js",Q.ERUDA_SRI="sha384-daS5bEfWdSq146t9c4BureB/fQWO3lHohseXBelPqKvbOUx2D6PE3TxcQ9jrKZDM";class V{static getUrlFromManifest(t,i){const r=t.manifest;return r&&r[i]?r[i]:i}static urlHasScheme(t){return/^[a-z]+:\/\//i.test(t)}static convertValueToType(t,i){function r(U){return typeof U=="string"||typeof U=="object"||!Number.isNaN(parseFloat(U))||typeof U=="boolean"}function h(U){if(typeof U=="string")return U;if(typeof U=="object")return console.warn(`convertValueToType() converted an object to a string. This may not be the desired behavior. The object was: ${JSON.stringify(U)}`),JSON.stringify(U);if(!Number.isNaN(parseFloat(U)))return U;if(typeof U=="boolean")return U.toString();throw new C(`Error parsing "${U}" as a string.`)}function c(U){if(typeof U=="number")return!0;if(typeof U!="string")return!1;const ut=parseFloat(U);return!Number.isNaN(ut)}function S(U){if(typeof U=="number")return U;if(typeof U!="string")throw new C(`Error parsing "${U}" as a number.`);const ut=parseFloat(U);if(Number.isNaN(ut))throw new C(`Error parsing "${U}" as a number.`);return ut}function x(U){if(typeof U=="number")return!0;if(typeof U!="string")return!1;const ut=parseInt(U);return!Number.isNaN(ut)}function z(U){if(typeof U=="number")return U;if(typeof U!="string")throw new C(`Error parsing "${U}" as an integer.`);const ut=parseInt(U);if(Number.isNaN(ut))throw new C(`Error parsing "${U}" as an integer.`);return ut}function G(U){return typeof U=="boolean"?!0:!(U!=="true"&&U!=="false")}function q(U){if(typeof U=="boolean")return U;if(U!=="true"&&U!=="false")throw new C(`Error parsing "${U}" as a boolean.`);return U==="true"}function st(U){if(Array.isArray(U))return!0;if(typeof U!="string")return!1;try{const ut=JSON.parse(U);if(Array.isArray(ut))return!0}catch{const ut=JSON.parse(decodeURIComponent(U));if(Array.isArray(ut))return!0}return!1}function lt(U){if(Array.isArray(U))return U;if(typeof U!="string")throw new C(`Error parsing "${U}" as an array.`);try{const ut=JSON.parse(U);if(Array.isArray(ut))return ut}catch{const ut=JSON.parse(decodeURIComponent(U));if(Array.isArray(ut))return ut}throw new C(`Error parsing "${U}" as an array.`)}function yt(U){if(typeof U=="object"&&!Array.isArray(U)&&U!==null)return!0;if(typeof U!="string")return!1;try{const ut=JSON.parse(U);if(typeof ut=="object"&&!Array.isArray(ut)&&ut!==null)return!0}catch{const ut=JSON.parse(decodeURIComponent(U));if(typeof ut=="object"&&!Array.isArray(ut)&&ut!==null)return!0}return!1}function rt(U){if(typeof U=="object"&&!Array.isArray(U)&&U!==null)return U;if(typeof U!="string")throw new C(`Error parsing "${U}" as an object.`);try{const ut=JSON.parse(U);if(typeof ut=="object"&&!Array.isArray(ut)&&ut!==null)return ut}catch{const ut=JSON.parse(decodeURIComponent(U));if(typeof ut=="object"&&!Array.isArray(ut)&&ut!==null)return ut}throw new C(`Error parsing "${U}" as an object.`)}function Et(U){return U===null||U==="null"}function Wt(U){if(U!=="null"&&U!==null)throw new C(`Error parsing "${U}" as null.`);return null}const Bt={string:r,number:c,integer:x,boolean:G,array:st,object:yt,null:Et},se={string:h,number:S,integer:z,boolean:q,array:lt,object:rt,null:Wt};if(i===void 0)throw new C(`Error with "${t}" as a target type.`);if(!Array.isArray(i)){if(Bt[i](t))return se[i](t);throw new C(`Error parsing "${t}" as a ${i}.`)}for(const U of i)if(Bt[U](t))return se[U](t);throw new C(`Error parsing "${t}" as one of ${i}.`)}static loadScriptUrls(t){if(!Array.isArray(t)||!t.every(i=>typeof i=="string")){console.warn('Error parsing "scripts" parameter. "scripts" must be an array of URL strings, and it is recommended to be URI encoded.');return}t.forEach(i=>{if(!m2c2Globals.addedScriptUrls.includes(i)){const r=document.createElement("script");r.src=i,r.async=!0,document.head.appendChild(r),console.log(`\u26AA added script: ${i}`),m2c2Globals.addedScriptUrls.push(i)}})}static loadEruda(t=100,i=50){if(m2c2Globals.erudaRequested===!0)return;console.log(`\u26AA added eruda script: ${Q.ERUDA_URL}`);const r=document.createElement("script");r.src=Q.ERUDA_URL,r.integrity=Q.ERUDA_SRI,r.crossOrigin="anonymous",r.async=!0,document.head.appendChild(r),m2c2Globals.erudaRequested=!0;let h=0;const c=()=>{const S=window?.eruda;typeof S<"u"?(console.log("\u26AA eruda ready"),S.init(),m2c2Globals.erudaInitialized=!0):h<i?(h++,setTimeout(c,t)):console.log(`eruda was requested, but could not be loaded after ${t*i} milliseconds.`)};c()}static registerM2NodeClass(...t){m2c2Globals.m2NodeClassRegistry||(m2c2Globals.m2NodeClassRegistry={}),t.forEach(i=>{m2c2Globals.m2NodeClassRegistry={...m2c2Globals.m2NodeClassRegistry,[i.name]:i}})}static createFrameUpdateTimestamps(){return{timestamp:Number.isNaN(m2c2Globals?.now)||m2c2Globals?.now===void 0?Vt.now():m2c2Globals.now,iso8601Timestamp:m2c2Globals.iso8601Now?m2c2Globals.iso8601Now:new Date().toISOString()}}static createTimestamps(){return{timestamp:Vt.now(),iso8601Timestamp:new Date().toISOString()}}static calculateRotatedPoints(t){const i=t.ancestors;i.reverse(),i.push(t);const r=i.map(h=>{const c=V.calculateNodeAbsoluteBoundingBox(h);return V.boundingBoxToPoints(c)});for(let h=0;h<r.length;h++){if(!cn(i[h]))continue;const c=r[h],S=i[h].zRotation,x=V.findCentroid(c);for(let z=h;z<i.length;z++)r[z]=ha(r[z],S,x)}return r[r.length-1]}static rotateCanvasForDrawableNode(t,i){const r=V.calculateRotationTransforms(i);if(r.length===0)return;const h=m2c2Globals.canvasScale/i.absoluteScale;la(r,h,t)}static calculateNodeAbsoluteBoundingBox(t){const i=t.anchorPoint,r=t.absoluteScale;let h=t.size.width,c=t.size.height;if(t.type===dt.Shape&&t.shapeType===Kt.Circle){const q=t.circleOfRadius;if(!q)throw"circleOfRadius is undefined";h=q*2,c=q*2}const S=t.absolutePosition.x-h*i.x*r,x=t.absolutePosition.x+h*(1-i.x)*r,z=t.absolutePosition.y-c*i.y*r,G=t.absolutePosition.y+c*(1-i.y)*r;return{xMin:S,xMax:x,yMin:z,yMax:G}}static radiansToDegrees(t){return-V.normalizeAngleRadians(t)*(180/Math.PI)}static normalizeAngleRadians(t){const i=Math.floor(t/(2*Math.PI));let r=t-i*(2*Math.PI);return r<0&&(r+=2*Math.PI),r}static arePointsOnSameSideOfLine(t,i,r,h){const c=(h.x-r.x)*(t.y-r.y)-(h.y-r.y)*(t.x-r.x),S=(h.x-r.x)*(i.y-r.y)-(h.y-r.y)*(i.x-r.x);return c*S>=0}static isPointInsideRectangle(t,i){if(i.length!==4)throw new C("Invalid input: expected an array of four points");return V.arePointsOnSameSideOfLine(t,i[2],i[0],i[1])&&V.arePointsOnSameSideOfLine(t,i[3],i[1],i[2])&&V.arePointsOnSameSideOfLine(t,i[0],i[2],i[3])&&V.arePointsOnSameSideOfLine(t,i[1],i[3],i[0])}static nodeOrAncestorHasBeenRotated(t){const i=t.ancestors;return i.push(t),i.some(r=>cn(r))}static boundingBoxToPoints(t){const{xMin:i,xMax:r,yMin:h,yMax:c}=t;return[{x:i,y:h},{x:r,y:h},{x:r,y:c},{x:i,y:c}]}static findCentroid(t){if(t.length!==4)throw new C("Invalid input: expected an array of four points");let i=0,r=0;for(const S of t)i+=S.x,r+=S.y;const h=i/4,c=r/4;return{x:h,y:c}}static rotatePoint(t,i,r){const h=t.x-r.x,c=t.y-r.y,S=h*Math.cos(-i)-c*Math.sin(-i),x=h*Math.sin(-i)+c*Math.cos(-i);return{x:S+r.x,y:x+r.y}}static calculateRotationTransforms(t){const i=[],r=t.ancestors;return r.reverse(),r.push(t),r.forEach(h=>{if(cn(h)){const c=h;if(c.type===dt.Scene){const G={x:c.absolutePosition.x+c.size.width*.5,y:c.absolutePosition.y+c.size.height*.5};i.push({radians:c.zRotation,center:G});return}const S=V.calculateNodeAbsoluteBoundingBox(c),x=V.boundingBoxToPoints(S),z=V.findCentroid(x);i.push({radians:c.zRotation,center:z})}}),i}}function la(m,t,i){m.forEach(r=>{i.rotate(V.radiansToDegrees(r.radians),r.center.x*t,r.center.y*t)})}function cn(m){return V.normalizeAngleRadians(m.zRotation)!==0&&m.isDrawable}function ha(m,t,i){if(m.length!==4)throw new C("Invalid input: expected an array of four points");const r=[];for(const h of m)r.push(V.rotatePoint(h,t,i));return r}class zt{constructor(t){if(this.expression=new Array,this.WARNING_EXPRESSION_LENGTH=32,typeof t=="number"){this.pushToExpression(t);return}if(t===void 0){this.pushToExpression(1/0);return}this.pushToExpression(t)}pushToExpression(t){if(t===this)throw new C("Cannot add, subtract, or assign a Futurable with itself.");this.expression.push(t),this.expression.length===this.WARNING_EXPRESSION_LENGTH&&console.warn(`Expression length is ${this.WARNING_EXPRESSION_LENGTH} elements. Something may be wrong.`)}assign(t){for(;this.expression.length>0;)this.expression.pop();this.pushToExpression(t)}add(...t){return this.appendOperation(Di.Add,...t),this}subtract(...t){return this.appendOperation(Di.Subtract,...t),this}appendOperation(t,...i){i.forEach(r=>{this.pushToExpression(t),this.pushToExpression(r)})}get value(){let t=0;const i=this.expression.flat(1/0);let r=1;for(let h=0;h<i.length;h++){if(typeof i[h]=="number"){t=t+r*i[h];continue}if(i[h]instanceof zt){t=t+r*i[h].value;continue}if(i[h]===Di.Add){r=1;continue}if(i[h]===Di.Subtract){r=-1;continue}}return t}}const Di={Add:"Add",Subtract:"Subtract"};class X{constructor(t=!1){this.startOffset=new zt(0),this.started=!1,this.running=!1,this._completed=!1,this.runStartTime=-1,this.duration=new zt,this.runDuringTransition=t}initialize(t){const i=this.clone();return this.assignParents(i,i,t),this.propagateRunDuringTransition(i),this.assignDurations(i),this.assignStartOffsets(i),i}assignParents(t,i,r){if(r!==void 0&&(t.key=r),this.isParent(t)){const h=t.children;h.forEach(c=>{c.parent=t}),h.filter(c=>this.isParent(c)).forEach(c=>this.assignParents(c,i,r))}}propagateRunDuringTransition(t){this.isParent(t)&&(t.descendants.some(i=>i.runDuringTransition)&&(t.runDuringTransition=!0),t.children.forEach(i=>this.propagateRunDuringTransition(i)))}assignDurations(t){t.duration=this.calculateDuration(t),this.isParent(t)&&t.children.forEach(i=>this.assignDurations(i))}calculateDuration(t){if(t.type===mt.Group){const r=t.children.map(h=>this.calculateDuration(h)).reduce((h,c)=>Math.max(h,c.value),0);return new zt(r)}if(t.type===mt.Sequence){const r=t.children.map(h=>this.calculateDuration(h)).reduce((h,c)=>h+c.value,0);return new zt(r)}return this.isRepeating(t)?new zt:t.duration}assignStartOffsets(t){t.startOffset=this.calculateStartOffset(t),this.isParent(t)&&t.children.forEach(i=>this.assignStartOffsets(i))}calculateStartOffset(t){if(t.parent===void 0)return new zt(0);if(t.parent.type!==mt.Sequence)return t.parent.startOffset;const i=new zt(0);i.add(t.parent.startOffset);for(const r of t.parent.children){if(r===t)break;i.add(r.duration)}return i}static evaluateAction(t,i,r,h){if(i.involvedInSceneTransition()&&!t.runDuringTransition||(t.runStartTime===-1&&t.assignRunStartTimes(t,r),r<t.runStartTime+t.startOffset.value))return;if(t.shouldBeRunning(r)&&(t.running=!0),t.isParent(t)){if(t.children.forEach(S=>{X.evaluateAction(S,i,r,h)}),!t.isRepeating(t)){t.started||(t.started=!0),t.running&&t.completed&&(t.running=!1);return}X.evaluateRepeatingActions(t,r);return}if(t.shouldBeRunning(r)||(t.running=!1),t.running===!1&&t.completed===!0)return;const c=r-(t.runStartTime+t.startOffset.value);switch(t.type){case mt.Custom:X.evaluateCustomAction(t);break;case mt.Play:X.evaluatePlayAction(i,t);break;case mt.Wait:X.evaluateWaitAction(t,r);break;case mt.Move:X.evaluateMoveAction(t,i,c);break;case mt.Scale:X.evaluateScaleAction(t,i,c,h);break;case mt.FadeAlpha:X.evaluateFadeAlphaAction(t,i,c,h);break;case mt.Rotate:X.evaluateRotateAction(t,i,c,h);break;default:throw new C(`Action type not recognized: ${t.type}`)}}static evaluateRepeatingActions(t,i){if(t.started||(t.started=!0),t.repetitionHasCompleted){t.completedRepetitions++;const r=t.children[0].duration.value;if(t.cumulativeDuration=t.cumulativeDuration+r,!isFinite(r))throw"repetitionDuration is not finite";if(!t.completed)t.restartAction(t,i);else{if(t.type===mt.RepeatForever)throw new C("RepeatForever action should never complete");t.duration.assign(t.cumulativeDuration),t.running=!1}}}static evaluateRotateAction(t,i,r,h){const c=t;c.started||(c.byAngle!==void 0&&(c.delta=c.byAngle),c.toAngle!==void 0&&(c.toAngle=V.normalizeAngleRadians(c.toAngle),i.zRotation=V.normalizeAngleRadians(i.zRotation),c.delta=c.toAngle-i.zRotation,c.shortestUnitArc===!0&&Math.abs(c.delta)>Math.PI&&(c.delta=2*Math.PI-Math.abs(c.delta))),c.started=!0,c.finalValue=i.zRotation+c.delta),r<c.duration.value?(i.zRotation=i.zRotation+c.delta*(h/c.duration.value),c.delta<=0&&i.zRotation<c.finalValue&&(i.zRotation=c.finalValue),c.delta>0&&i.zRotation>c.finalValue&&(i.zRotation=c.finalValue)):(i.zRotation=c.finalValue,c.running=!1,c.completed=!0)}static evaluateFadeAlphaAction(t,i,r,h){const c=t;c.started||(c.delta=c.alpha-i.alpha,c.started=!0),r<c.duration.value?i.alpha=i.alpha+c.delta*(h/c.duration.value):(i.alpha=c.alpha,c.running=!1,c.completed=!0)}static evaluateScaleAction(t,i,r,h){const c=t;c.started||(c.delta=c.scale-i.scale,c.started=!0),r<c.duration.value?i.scale=i.scale+c.delta*(h/c.duration.value):(i.scale=c.scale,c.running=!1,c.completed=!0)}static evaluateMoveAction(t,i,r){const h=t;h.started||(h.dx=h.point.x-i.position.x,h.dy=h.point.y-i.position.y,h.startPoint.x=i.position.x,h.startPoint.y=i.position.y,h.started=!0),r<h.duration.value?(i.position.x=h.easing(r,h.startPoint.x,h.dx,h.duration.value),i.position.y=h.easing(r,h.startPoint.y,h.dy,h.duration.value)):(i.position.x=h.point.x,i.position.y=h.point.y,h.running=!1,h.completed=!0)}static evaluateWaitAction(t,i){const r=t;i>t.runStartTime+t.startOffset.value+t.duration.value&&(r.running=!1,r.completed=!0)}static evaluatePlayAction(t,i){if(t.type!==dt.SoundPlayer)throw new C("Play action can only be used with a SoundPlayer");const r=i,h=t,c=h.game.soundManager;if(!r.started){const S=c.getSound(h.soundName);if(S.audioBuffer)S.audioBufferSource=c.audioContext.createBufferSource(),S.audioBufferSource.buffer=S.audioBuffer,S.audioBufferSource.onended=()=>{r.running=!1,r.completed=!0;const x=performance.now()-(i.runStartTime+i.startOffset.value);i.duration.assign(x)},S.audioBufferSource.connect(c.audioContext.destination),S.audioBufferSource.start(),r.started=!0;else{if(S.status===jt.Error)throw new C(`error loading sound ${S.soundName} (url ${S.url})`);console.warn(`Play action: audio buffer not ready for sound ${h.soundName} (url: ${S.url}); will try next frame`),S.status===jt.Deferred&&c.fetchDeferredSound(S)}}}static evaluateCustomAction(t){const i=t;i.callback(),i.running=!1,i.completed=!0}assignRunStartTimes(t,i){t.runStartTime=i,t.isParent(t)&&t.children.forEach(r=>{t.assignRunStartTimes(r,i)})}restartAction(t,i){if(t.runStartTime=i,t.running=!0,t.started=!0,t.type===mt.Play&&(t.duration=new zt),t.isParent(t)){t.children.forEach(r=>{t.restartAction(r,i)});return}t.completed=!1}shouldBeRunning(t){return t>=this.runStartTime+this.startOffset.value&&t<=this.runStartTime+this.startOffset.value+this.duration.value}static move(t){return new Or(t.point,new zt(t.duration),t.easing??De.linear,t.runDuringTransition??!1)}static wait(t){return new Ir(new zt(t.duration),t.runDuringTransition??!1)}static custom(t){return new kr(t.callback,t.runDuringTransition??!1)}static play(t){return new Nr(t?.runDuringTransition??!1)}static scale(t){return new Dr(t.scale,new zt(t.duration),t.runDuringTransition)}static fadeAlpha(t){return new zr(t.alpha,new zt(t.duration),t.runDuringTransition)}static rotate(t){if(t.byAngle!==void 0&&t.toAngle!==void 0)throw new C("rotate Action: cannot specify both byAngle and toAngle");if(t.byAngle===void 0&&t.toAngle===void 0)throw new C("rotate Action: must specify either byAngle or toAngle");if(t.toAngle===void 0&&t.shortestUnitArc!==void 0)throw new C("rotate Action: shortestUnitArc can only be specified when toAngle is provided");return t.toAngle!==void 0&&t.shortestUnitArc===void 0&&(t.shortestUnitArc=!0),new Lr(t.byAngle,t.toAngle,t.shortestUnitArc,new zt(t.duration),t.runDuringTransition)}static sequence(t){const i=new Fr(t);return i.children=t,i}static group(t){const i=new Mr(t);return i.children=t,i}static repeat(t){return new un(t.action,t.count,t.runDuringTransition)}static repeatForever(t){return new Rr(t.action,t.runDuringTransition)}isParent(t){return t.type===mt.Group||t.type===mt.Sequence||t.type===mt.Repeat||t.type===mt.RepeatForever}isRepeating(t){return t.type===mt.Repeat||t.type===mt.RepeatForever}get completed(){return this._completed}set completed(t){this._completed=t}}class Fr extends X{constructor(t){super(),this.type=mt.Sequence,this.children=t}clone(){const t=this.children.map(r=>r.clone()),i=X.sequence(t);return i.children.forEach(r=>r.key=this.key),i.key=this.key,i}get completed(){return this.children.every(t=>t.completed)}get descendants(){return dn(this)}}class Mr extends X{constructor(t){super(),this.type=mt.Group,this.children=new Array,this.children=t}clone(){const t=this.children.map(r=>r.clone()),i=X.group(t);return i.children.forEach(r=>r.key=this.key),i.key=this.key,i}get completed(){return this.children.every(t=>t.completed)}get descendants(){return dn(this)}}class un extends X{constructor(t,i,r=!1){super(r),this.type=mt.Repeat,this.completedRepetitions=0,this.cumulativeDuration=0,this.children=[t],this.count=i,this.duration=new zt}clone(){if(this.children.length!==1)throw new C("Repeat action must have exactly one child");const t=X.repeat({action:this.children[0].clone(),count:this.count,runDuringTransition:this.runDuringTransition});return t.children[0].key=this.key,t.key=this.key,t}get completed(){return this.children.every(t=>t.completed)&&this.completedRepetitions===this.count}get descendantsAreCompleted(){return this.children.every(t=>t.completed)}get repetitionHasCompleted(){return this.running&&this.descendantsAreCompleted&&!this.completed}get descendants(){return dn(this)}}class Rr extends un{constructor(t,i=!1){super(t,1/0,i),this.type=mt.RepeatForever,this.count=1/0}clone(){if(this.children.length!==1)throw new C("RepeatForever action must have exactly one child");const t=X.repeatForever({action:this.children[0].clone(),runDuringTransition:this.runDuringTransition});return t.children[0].key=this.key,t.key=this.key,t}}function dn(m){const t=[];function i(r){if(r.isParent(r))for(const h of r.children)t.push(h),i(h)}return i(m),t}class kr extends X{constructor(t,i=!1){super(i),this.type=mt.Custom,this.callback=t,this.duration=new zt(0)}clone(){const t=X.custom({callback:this.callback,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class Nr extends X{constructor(t=!1){super(t),this.type=mt.Play,this.duration=new zt}clone(){const t=X.play({runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class Ir extends X{constructor(t,i){super(i),this.type=mt.Wait,this.duration=t}clone(){const t=X.wait({duration:this.duration.value,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class Or extends X{constructor(t,i,r,h){super(h),this.type=mt.Move,this.startPoint={x:NaN,y:NaN},this.dx=0,this.dy=0,this.duration=i,this.point=t,this.easing=r}clone(){const t=X.move({point:this.point,duration:this.duration.value,easing:this.easing,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class Dr extends X{constructor(t,i,r=!1){super(r),this.type=mt.Scale,this.delta=0,this.duration=i,this.scale=t}clone(){const t=X.scale({scale:this.scale,duration:this.duration.value,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class zr extends X{constructor(t,i,r=!1){super(r),this.type=mt.FadeAlpha,this.delta=0,this.duration=i,this.alpha=t}clone(){const t=X.fadeAlpha({alpha:this.alpha,duration:this.duration.value,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class Lr extends X{constructor(t,i,r,h,c=!1){super(c),this.type=mt.Rotate,this.delta=0,this.finalValue=NaN,this.duration=h,this.byAngle=t,this.toAngle=i,this.shortestUnitArc=r}clone(){const t=X.rotate({byAngle:this.byAngle,toAngle:this.toAngle,shortestUnitArc:this.shortestUnitArc,duration:this.duration.value,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}var ui=(m=>(m.Game="Game",m.Survey="Survey",m))(ui||{});class Nt{static Dispose(t){t.filter(i=>!i?.isDeleted()).forEach(i=>i?.delete())}static makePaint(t,i,r,h){const c=new t.Paint;return c.setColor(t.Color(i[0],i[1],i[2],i[3])),c.setStyle(r),c.setAntiAlias(h),c}}class Bi{constructor(){this._subpaths=new Array,this.currentPath=new Array}get subpaths(){return this.currentPath.length>0?[...this._subpaths,this.currentPath]:this._subpaths}move(t){this.currentPath.length>0&&this._subpaths.push(this.currentPath),this.currentPath=new Array,this.currentPath.push(t)}addLine(t){this.currentPath.push(t)}clear(){this._subpaths=new Array,this.currentPath=new Array}duplicate(){const t=new Bi;return t._subpaths=JSON.parse(JSON.stringify(this._subpaths)),t.currentPath=JSON.parse(JSON.stringify(this.currentPath)),t}}class ca extends Bi{constructor(){super(...arguments),this.strokeColor=Q.DEFAULT_PATH_STROKE_COLOR,this.lineWidth=Q.DEFAULT_PATH_LINE_WIDTH,this.linePresentations=[]}addLine(t){this.isNewLinePresentation()&&this.linePresentations.push({strokeColor:this.strokeColor,lineWidth:this.lineWidth,subpathIndex:this._subpaths.length,pointIndex:this.currentPath.length-1}),this.currentPath.push(t)}isNewLinePresentation(){if(this.linePresentations.length===0)return!0;const t=this.linePresentations[this.linePresentations.length-1];return t.strokeColor!==this.strokeColor||t.lineWidth!==this.lineWidth}clear(){super.clear(),this.linePresentations=[],this.strokeColor=Q.DEFAULT_PATH_STROKE_COLOR,this.lineWidth=Q.DEFAULT_PATH_LINE_WIDTH}duplicate(){const t=super.duplicate();return t.strokeColor=JSON.parse(JSON.stringify(this.strokeColor)),t.lineWidth=this.lineWidth,t.linePresentations=JSON.parse(JSON.stringify(this.linePresentations)),t}}var Gt=(m=>(m.topToTopOf="topToTopOf",m.topToBottomOf="topToBottomOf",m.bottomToTopOf="bottomToTopOf",m.bottomToBottomOf="bottomToBottomOf",m.startToStartOf="startToStartOf",m.startToEndOf="startToEndOf",m.endToEndOf="endToEndOf",m.endToStartOf="endToStartOf",m))(Gt||{});class Br{constructor(t,i){this.verticalConstraint=!1,this.focalNodeMinimum=!1,this.alterNodeMinimum=!1,this.verticalTypes=[Gt.topToTopOf,Gt.topToBottomOf,Gt.bottomToTopOf,Gt.bottomToBottomOf],this.focalNodeMinimumTypes=[Gt.topToTopOf,Gt.topToBottomOf,Gt.startToStartOf,Gt.startToEndOf],this.alterNodeMinimumTypes=[Gt.topToTopOf,Gt.bottomToTopOf,Gt.startToStartOf,Gt.endToStartOf],this.type=t,this.alterNode=i,this.verticalTypes.includes(t)?(this.verticalConstraint=!0,this.focalNodeMinimumTypes.includes(t)?this.focalNodeMinimum=!0:this.focalNodeMinimum=!1,this.alterNodeMinimumTypes.includes(t)?this.alterNodeMinimum=!0:this.alterNodeMinimum=!1):(this.verticalConstraint=!1,this.focalNodeMinimumTypes.includes(t)?this.focalNodeMinimum=!0:this.focalNodeMinimum=!1,this.alterNodeMinimumTypes.includes(t)?this.alterNodeMinimum=!0:this.alterNodeMinimum=!1)}}class ze{static generate(){try{return crypto.randomUUID()}catch{let t;try{t=()=>crypto.getRandomValues(new Uint8Array(1))[0]}catch{t=()=>Math.floor(Math.random()*256)}return("10000000-1000-4000-8000"+-1e11).replace(/[018]/g,i=>(Number(i)^t()&15>>Number(i)/4).toString(16))}}static isValid(t){return t?t==="00000000-0000-0000-0000-000000000000"?!0:/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t):!1}}const H={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",KeyDown:"KeyDown",KeyUp:"KeyUp",Drag:"Drag",DragStart:"DragStart",DragEnd:"DragEnd",Composite:"Composite",FrameDidSimulatePhysics:"FrameDidSimulatePhysics",SceneSetup:"SceneSetup",SceneAppear:"SceneAppear",ScenePresent:"ScenePresent",NodeNew:"NodeNew",NodeAddChild:"NodeAddChild",NodeRemoveChild:"NodeRemoveChild",NodePropertyChange:"NodePropertyChange",DomPointerDown:"DomPointerDown",BrowserImageDataReady:"BrowserImageDataReady",I18nDataReadyEvent:"I18nDataReadyEvent"};class K{static rgbaColor(t,i){return!t||!i?!1:t[0]===i[0]&&t[1]===i[1]&&t[2]===i[2]&&t[3]===i[3]}static value(t,i){return typeof t!=typeof i?!1:t&&typeof t=="object"&&i&&typeof i=="object"?K.objectsDeepEqual(t,i):t===i}static objectsDeepEqual(t,i){if(t===i)return!0;if(Array.isArray(t)&&Array.isArray(i)){if(t.length!==i.length)return!1;for(let r=0;r<t.length;r++)if(!K.objectsDeepEqual(t[r],i[r]))return!1;return!0}if(typeof t=="object"&&!Array.isArray(t)&&t!==null&&typeof i=="object"&&!Array.isArray(i)&&i!==null){const r=Object.keys(t),h=Object.keys(i);if(r.length!==h.length)return!1;for(const c of r)if(!(c in i)||!K.objectsDeepEqual(t[c],i[c]))return!1;return!0}return!1}}function ua(m,t){t.anchorPoint&&(m.anchorPoint=t.anchorPoint),t.zPosition!==void 0&&(m.zPosition=t.zPosition)}function da(m,t){t.text!==void 0&&(m.text=t.text),t.fontName!==void 0&&(m.fontName=t.fontName),t.fontColor&&(m.fontColor=t.fontColor),t.fontSize!==void 0&&(m.fontSize=t.fontSize),t.interpolation&&(m.interpolation=t.interpolation),t.localize!==void 0&&(m.localize=t.localize)}function Le(m,t){m.isDrawable&&ua(m,t),m.isText&&da(m,t)}class fe{constructor(t={}){this.type=dt.Node,this.isDrawable=!1,this.isShape=!1,this.isText=!1,this._suppressEvents=!1,this._position={x:0,y:0},this._scale=1,this._alpha=1,this._zRotation=0,this._isUserInteractionEnabled=!1,this._draggable=!1,this._hidden=!1,this.layout={},this.children=new Array,this.absolutePosition={x:0,y:0},this._size={width:0,height:0},this.absoluteScale=1,this.absoluteAlpha=1,this.absoluteAlphaChange=0,this.actions=new Array,this.eventListeners=new Array,this.uuid=ze.generate(),this.needsInitialization=!0,this.userData={},this.loopMessages=new Set,this.nodeEvents=new Array,this.pressed=!1,this.withinHitArea=!1,this.pressedAndWithinHitArea=!1,this.pressedInitialPointerOffset={x:NaN,y:NaN},this.draggingLastPointerOffset={x:NaN,y:NaN},this.dragging=!1,this.toString=()=>{let i=this.type.toString();return this.type==dt.Composite&&(i=this.compositeType),this.name!==this.uuid?`${this.name} (${i}, ${this.uuid})`:`${i} (${this.uuid})`},t.suppressEvents!==void 0&&(this.suppressEvents=t.suppressEvents),this.constructionTimeStamp=Number.isNaN(m2c2Globals?.now)||m2c2Globals?.now===void 0?Vt.now():m2c2Globals.now,this.constructionIso8601TimeStamp=new Date().toISOString(),this.constructionSequence=m2c2Globals.eventSequence,this.options=t,t.uuid!==void 0&&(this.uuid=t.uuid),t.name===void 0?this.name=this.uuid:this.name=t.name,t.position!==void 0&&(this.position=t.position),t.scale!==void 0&&(this.scale=t.scale),t.alpha!==void 0&&(this.alpha=t.alpha),t.zRotation!==void 0&&(this.zRotation=t.zRotation),t.isUserInteractionEnabled!==void 0&&(this.isUserInteractionEnabled=t.isUserInteractionEnabled),t.draggable!==void 0&&(this.draggable=t.draggable),t.hidden!==void 0&&(this.hidden=t.hidden),t.layout!==void 0&&(this.layout=t.layout)}initialize(){throw new C("initialize() called in abstract base class Node.")}get completeNodeOptions(){throw new C("get completeNodeOptions() called in abstract base class Node.")}saveNodeNewEvent(){if(this.suppressEvents)return;const t={type:H.NodeNew,target:this,nodeType:this.type,compositeType:this.type===dt.Composite?this.compositeType:void 0,timestamp:this.constructionTimeStamp,iso8601Timestamp:this.constructionIso8601TimeStamp,nodeOptions:this.completeNodeOptions,sequence:this.constructionSequence};this.saveEvent(t)}savePropertyChangeEvent(t,i){if(this.suppressEvents)return;const r={type:H.NodePropertyChange,target:this,uuid:this.uuid,property:t,value:i,...V.createFrameUpdateTimestamps()};this.saveEvent(r)}saveEvent(t){t.sequence===void 0&&(t.sequence=m2c2Globals.eventSequence);try{this.game.eventStore.addEvent(t)}catch{this.nodeEvents.push(t)}}get game(){const t=i=>{if(i.parent)return i.parent.type===dt.Scene?i.parent:t(i.parent);throw new C(`Node ${this} has not been added to a scene.`)};return t(this).game}isPartOfGame(){if(this.type===dt.Scene&&this._game===void 0)return!1;if(this.type===dt.Scene&&this._game!==void 0)return!0;const t=i=>{if(i.parent)return i.parent.type===dt.Scene?i.parent:t(i.parent)};return t(this)?._game!==void 0}addChild(t){const i=this.suppressEvents||t.suppressEvents;if(t===this)throw new C(`Cannot add node ${t.toString()} as a child to itself.`);if(t.type==dt.Scene)throw new C(`Cannot add scene ${t.toString()} as a child to node ${this.toString()}. A scene cannot be the child of a node. A scene can only be added to a game object.`);if(this.children.filter(c=>c!==t).map(c=>c.name).includes(t.name))throw new C(`Cannot add child node ${t.toString()} to parent node ${this.toString()}. A child with name "${t.name}" already exists on this parent.`);let r=new Array;if(this.isPartOfGame())r=this.game.nodes.filter(c=>c.children.includes(t));else{const c=this.descendants;c.includes(t)&&(r=c.filter(S=>S.children.includes(t)).map(S=>S.parent??void 0))}if(r.length===0){t.parent=this,this.children.push(t);const c={type:"NodeAddChild",target:this,uuid:this.uuid,childUuid:t.uuid,...V.createFrameUpdateTimestamps()};i||this.saveEvent(c),this.saveChildEvents(t);return}const h=r.find(Boolean);throw h===this?new C(`Cannot add child node ${t.toString()} to parent node ${this.toString()}. This child already exists on this parent. The child cannot be added again.`):new C(`Cannot add child node ${t.toString()} to parent node ${this.toString()}. This child already exists on other parent node: ${h?.toString()}}. Remove the child from the other parent first.`)}saveChildEvents(t){t.nodeEvents.forEach(i=>{this.saveEvent(i)}),t.nodeEvents.length=0;for(const i of t.children)this.saveChildEvents(i)}removeAllChildren(){this.children.forEach(t=>this.removeChild(t))}removeChild(t){const i=this.suppressEvents||t.suppressEvents;if(this.children.includes(t))t.parent=void 0,this.children=this.children.filter(h=>h!==t);else throw new C(`cannot remove node ${t} from parent ${this} because the node is not currently a child of the parent`);const r={type:"NodeRemoveChild",target:this,uuid:this.uuid,childUuid:t.uuid,...V.createFrameUpdateTimestamps()};i||this.saveEvent(r)}removeChildren(t){t.forEach(i=>{if(!this.children.includes(i))throw new C(`cannot remove node ${i} from parent ${this} because the node is not currently a child of the parent`);this.removeChild(i)})}descendant(t){const i=this.descendants.filter(r=>r.name===t).find(Boolean);if(i===void 0)throw new C(`descendant with name ${t} not found on parent ${this.toString()}`);return i}get descendants(){function t(r,h){h.push(r),r.children.forEach(c=>t(c,h))}const i=new Array;return this.children.forEach(r=>t(r,i)),i}get ancestors(){function t(r,h){return r.type==dt.Scene||!r.parent?h:(h.push(r.parent),t(r.parent,h))}const i=new Array;return t(this,i)}involvedInActionAffectingAppearance(){return this.ancestors.concat(this).flatMap(r=>r.actions).some(r=>r.running&&(r.type===mt.Move||r.type===mt.Scale))}involvedInSceneTransition(){let t;return this.type===dt.Scene?t=this:t=this.parentSceneAsNode,t._transitioning}onTapDown(t,i){this.addEventListener(H.TapDown,t,i)}onTapUp(t,i){this.addEventListener(H.TapUp,t,i)}onTapUpAny(t,i){this.addEventListener(H.TapUpAny,t,i)}onTapLeave(t,i){this.addEventListener(H.TapLeave,t,i)}onPointerDown(t,i){this.addEventListener(H.PointerDown,t,i)}onPointerUp(t,i){this.addEventListener(H.PointerUp,t,i)}onPointerMove(t,i){this.addEventListener(H.PointerMove,t,i)}onPointerLeave(t,i){this.addEventListener(H.PointerLeave,t,i)}onDragStart(t,i){this.addEventListener(H.DragStart,t,i)}onDrag(t,i){this.addEventListener(H.Drag,t,i)}onDragEnd(t,i){this.addEventListener(H.DragEnd,t,i)}addEventListener(t,i,r){const h={type:t,nodeUuid:this.uuid,callback:i};r?.replaceExisting&&(this.eventListeners=this.eventListeners.filter(c=>!(c.nodeUuid===h.nodeUuid&&c.type===h.type))),this.eventListeners.push(h)}parseLayoutConstraints(t,i){const r=new Array;return Object.values(Gt).forEach(c=>{if(t[c]!==void 0){let S,x="";if(typeof t[c]=="object")S=t[c];else{const G=t[c];S=i.filter(q=>q.name===G||q.uuid===G).find(Boolean),S||(S=this.game.materializedNodes.filter(q=>q.name===G||q.uuid===G).find(Boolean)),x=`. sibling node named "${G}" has not been added to the game object`}if(S===void 0)throw new C("could not find sibling node for constraint"+x);const z=new Br(c,S);r.push(z)}}),r}calculateYFromConstraint(t,i,r,h){let c=t.alterNode.absolutePosition.y;return t.alterNodeMinimum?t.alterNode.type!==dt.Scene&&(c=c-t.alterNode.size.height*.5*h):t.alterNode.type!==dt.Scene?c=c+t.alterNode.size.height*.5*h:c=c+t.alterNode.size.height*h,t.focalNodeMinimum?(c=c+this.size.height*.5*h,c=c+i*h):(c=c-this.size.height*.5*h,c=c-r*h),c}calculateXFromConstraint(t,i,r,h){let c=t.alterNode.absolutePosition.x;return t.alterNodeMinimum?t.alterNode.type!==dt.Scene&&(c=c-t.alterNode.size.width*.5*h):t.alterNode.type!==dt.Scene?c=c+t.alterNode.size.width*.5*h:c=c+t.alterNode.size.width*h,t.focalNodeMinimum?(c=c+this.size.width*.5*h,c=c+i*h):(c=c-this.size.width*.5*h,c=c-r*h),c}calculateAbsoluteAlpha(t,i){const r=i.reduce((h,c)=>h*c.alpha,1);return t*r}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 h=this.layout?.constraints?.horizontalBias??.5,c=this.layout?.constraints?.verticalBias??.5,S=this.layout?.marginTop??0,x=this.layout?.marginBottom??0,z=this.layout?.marginStart??0,G=this.layout?.marginEnd??0,q=this.parseLayoutConstraints(this.layout?.constraints,this.parentSceneAsNode.descendants),st=this.parent.absoluteScale,lt=q.filter(rt=>rt.verticalConstraint).map(rt=>this.calculateYFromConstraint(rt,S,x,st));lt.length===0||(lt.length===1?this.absolutePosition.y=lt[0]:lt.length===2&&(this.absolutePosition.y=Math.min(lt[0],lt[1])+c*Math.abs(lt[0]-lt[1])));const yt=q.filter(rt=>!rt.verticalConstraint).map(rt=>this.calculateXFromConstraint(rt,z,G,st));yt.length===0||(yt.length===1?this.absolutePosition.x=yt[0]:yt.length===2&&(this.absolutePosition.x=Math.min(yt[0],yt[1])+h*Math.abs(yt[0]-yt[1])))}this.actions.forEach(h=>X.evaluateAction(h,this,m2c2Globals.now,m2c2Globals.deltaTime));function t(h,c){const S=new Array;return c===void 0||Object.values(Gt).forEach(z=>{if(c[z]!==void 0){let G,q="";if(typeof c[z]=="object")G=c[z];else{const st=c[z];let lt;h.type===dt.Scene?lt=h.descendants:lt=h.parentSceneAsNode.descendants,G=lt.filter(yt=>yt.name===st||yt.uuid===st).find(Boolean),G===void 0&&(G=h.game.materializedNodes.filter(yt=>yt.name===st||yt.uuid===st).find(Boolean)),G===void 0&&(q=`. sibling node named "${st}" has not been added to the game object`)}if(G===void 0)throw new C("error getting uuid of sibling constraint"+q);G!==h&&S.push(G.uuid)}}),S}const i=new Map;this.children.forEach(h=>{i.set(h.uuid,t(this,h.layout?.constraints))});const r=this.findTopologicalSort(i);if(r.length>0){const h=r.reverse(),c=new Array;h.forEach(S=>{const x=this.children.filter(z=>z.uuid===S).find(Boolean);if(x===void 0)throw new C("error in dag topological sort");c.push(x)}),c.forEach(S=>S.update())}else this.children.forEach(h=>h.update())}drawChildren(t){this.children.filter(i=>!i.hidden&&i.isDrawable).map(i=>i).sort((i,r)=>i.zPosition-r.zPosition).forEach(i=>i.draw(t))}run(t,i){this.actions.push(t.initialize(i))}removeAction(t){this.actions=this.actions.filter(i=>i.key!==t)}removeAllActions(){for(;this.actions.length;)this.actions.pop()}getNodeOptions(){return{name:this.name,position:this.position,scale:this.scale,alpha:this.alpha,zRotation:this.zRotation,isUserInteractionEnabled:this.isUserInteractionEnabled,draggable:this.draggable,hidden:this.hidden,layout:this.layout,uuid:this.uuid}}getDrawableOptions(){if(!this.isDrawable)throw new C("getDrawableOptions() called object that is not IDrawable");return{anchorPoint:this.anchorPoint,zPosition:this.zPosition}}getTextOptions(){if(!this.isText)throw new C("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===dt.Scene)throw new C(`Node ${this} is a scene and cannot have a parent scene`);if(this.parent&&this.parent.type===dt.Scene)return this.parent;if(this.parent)return this.parent.parentSceneAsNode;throw new C(`Node ${this} has not been added to a scene`)}get size(){const t=this;return{get height(){return t._size.height},set height(i){K.value(t._size.height,i)||(t._size.height=i,t.savePropertyChangeEvent("size",t.size))},get width(){return t._size.width},set width(i){K.value(t._size.width,i)||(t._size.width=i,t.savePropertyChangeEvent("size",t.size))}}}set size(t){K.value(this._size.width,t.width)||(this._size=t,this.savePropertyChangeEvent("size",this.size))}get position(){const t=this;return{get x(){return t._position.x},set x(i){K.value(t._position.x,i)||(t._position.x=i,t.savePropertyChangeEvent("position",t.position))},get y(){return t._position.y},set y(i){K.value(t._position.y,i)||(t._position.y=i,t.savePropertyChangeEvent("position",t.position))}}}set position(t){K.value(this._position,t)||(this._position=t,this.savePropertyChangeEvent("position",this.position))}get zRotation(){return this._zRotation}set zRotation(t){K.value(this._zRotation,t)||(this._zRotation=t,this.savePropertyChangeEvent("zRotation",t))}get scale(){return this._scale}set scale(t){K.value(this._scale,t)||(this._scale=t,this.savePropertyChangeEvent("scale",t))}get alpha(){return this._alpha}set alpha(t){K.value(this._alpha,t)||(this._alpha=t,this.savePropertyChangeEvent("alpha",t))}get isUserInteractionEnabled(){return this._isUserInteractionEnabled}set isUserInteractionEnabled(t){K.value(this._isUserInteractionEnabled,t)||(this._isUserInteractionEnabled=t,this.savePropertyChangeEvent("isUserInteractionEnabled",t))}get hidden(){return this._hidden}set hidden(t){K.value(this._hidden,t)||(this._hidden=t,this.savePropertyChangeEvent("hidden",t))}get draggable(){return this._draggable}set draggable(t){K.value(this._draggable,t)||(this._draggable=t,this.savePropertyChangeEvent("draggable",t))}get suppressEvents(){return this._suppressEvents}set suppressEvents(t){this._suppressEvents=t}findTopologicalSort(t){const i=[],r=new Map;t.forEach((c,S)=>{r.has(S)||r.set(S,0),c.forEach(x=>{if(r.has(x)){const z=r.get(x);if(z===void 0)throw new C(`Could not find inDegree for edge ${x}`);r.set(x,z+1)}else r.set(x,1)})});const h=[];for(r.forEach((c,S)=>{c==0&&h.push(S)});h.length>0;){const c=h.shift();if(c===void 0)throw"current vertex is undefined";i.push(c),t.has(c)&&t.get(c)?.forEach(S=>{const x=r.get(S);if(x===void 0)throw new C(`Could not find inDegree for edge ${S}`);if(r.has(S)&&x>0){const z=x-1;r.set(S,z),z==0&&h.push(S)}})}return i}}class fa extends fe{constructor(t={}){super(t),this.type=dt.Composite,this.compositeType="<compositeType>",this.isDrawable=!0,this._anchorPoint={x:.5,y:.5},this._zPosition=0,Le(this,t)}initialize(){}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){K.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){K.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){K.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){K.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}dispose(){}update(){super.update()}draw(t){super.drawChildren(t)}handleCompositeEvent(t){}}var Ur=(m=>(m[m.MatchConstraint=0]="MatchConstraint",m))(Ur||{});const ne={Deferred:"Deferred",Loading:"Loading",Ready:"Ready",Error:"Error"};class fn{constructor(t,i){this.images={},this.game=t,this.baseUrls=i,this.canvasKit=t.canvasKit}initializeImages(t){return this.loadImages(t??[])}async loadImages(t){if(t.length===0)return;this.checkImageNamesForDuplicates(t);const i=t.map(r=>{let h=r.url;r.url&&!V.urlHasScheme(r.url)&&(h=V.getUrlFromManifest(this.game,`${this.baseUrls.assets}/${r.url}`)),r.dataUrl&&(h=r.dataUrl);const c={imageName:r.imageName,url:h,originalUrl:h,isFallback:!1,localize:r.localize??!1,svgString:r.svgString,canvaskitImage:void 0,width:r.width,height:r.height,status:r.lazy?ne.Deferred:ne.Loading};return c.localize&&this.configureImageLocalization(c),this.images[r.imageName]=c,c.status===ne.Loading?this.renderM2Image(c):Promise.resolve()});await Promise.all(i)}configureImageLocalization(t){t.fallbackLocalizationUrls=new Array,t.originalUrl&&this.game.i18n?.locale&&(t.status="Deferred",this.game.i18n?.fallbackLocale&&this.game.i18n?.fallbackLocale!==this.game.i18n?.baseLocale&&t.fallbackLocalizationUrls.push(this.localizeImageUrl(t.originalUrl,this.game.i18n.fallbackLocale)),this.game.i18n?.locale===this.game.i18n?.baseLocale?t.url=t.originalUrl:t.url=this.localizeImageUrl(t.originalUrl,this.game.i18n.locale),t.url!==t.originalUrl&&t.fallbackLocalizationUrls.push(t.originalUrl),this.game.i18n.missingLocalizationColor&&!this.missingLocalizationImagePaint&&(this.missingLocalizationImagePaint=Nt.makePaint(this.canvasKit,this.game.i18n.missingLocalizationColor,this.canvasKit.PaintStyle.Stroke,!0),this.missingLocalizationImagePaint.setStrokeWidth(4)))}localizeImageUrl(t,i){const r=t.lastIndexOf(".");if(r===-1)throw new C("URL does not have an extension");return t.slice(0,r)+`.${i}`+t.slice(r)}reinitializeLocalizedImages(){Object.keys(this.game.imageManager.images).forEach(i=>{const r=this.game.imageManager.images[i];r.localize&&this.game.imageManager.configureImageLocalization(r)}),this.game.nodes.filter(i=>i.type===dt.Sprite).forEach(i=>{i.needsInitialization=!0})}checkImageNamesForDuplicates(t){const r=(h=>h.filter((c,S)=>h.indexOf(c)!=S))(t.map(h=>h.imageName));if(r.length>0)throw new C(`image names must be unique. these image names are duplicated within a game ${this.game.id}: `+r.join(", "))}prepareDeferredImage(t){return t.status=ne.Loading,t.isFallback=!1,this.renderM2Image(t).catch(async()=>{for(t.isFallback=!0;t.fallbackLocalizationUrls?.length;){t.url=t.fallbackLocalizationUrls.shift();try{await this.renderM2Image(t)}catch(i){if(t.fallbackLocalizationUrls.length===0)throw i instanceof Error?i:new C(`prepareDeferredImage(): unable to render image named ${t.imageName}. image source was ${t.svgString?"svgString":`url: ${t.url}`}`)}}})}renderM2Image(t){const i=document.createElement("img"),r=h=>{if(!this.scratchCanvas||!this.ctx||!this.scale)throw new C("image manager not set up");this.scratchCanvas.width=t.width*this.scale,this.scratchCanvas.height=t.height*this.scale,this.ctx.scale(this.scale,this.scale),this.ctx.clearRect(0,0,t.width,t.height),this.ctx.drawImage(i,0,0,t.width,t.height),this.scratchCanvas.toBlob(c=>{if(!c)throw new C(`renderM2Image(): blob is undefined for ${t.imageName}`);c.arrayBuffer().then(S=>{const x=this.canvasKit.MakeImageFromEncoded(S);if(!x)throw new C(`could not create image with name "${t.imageName}."`);console.log(`image loaded. name: ${t.imageName}, w: ${t.width}, h: ${t.height}`),this.images[t.imageName].canvaskitImage=x,this.images[t.imageName].status=ne.Ready,this.game.nodes.filter(G=>G.type==="Sprite").forEach(G=>{G.imageName===t.imageName&&(G.needsInitialization=!0)}),h()})})};return new Promise((h,c)=>{if(i.width=t.width,i.height=t.height,i.crossOrigin="Anonymous",i.onerror=()=>{c(new Error(`unable to render image named ${t.imageName}. image source was ${t.svgString?"svgString":`url: ${t.url}`}`))},i.onload=()=>{r(h)},!t.svgString&&!t.url)throw new C(`no svgString or url provided for image named ${t.imageName}`);if(t.svgString&&t.url)throw new C(`provide svgString or url. both were provided for image named ${t.imageName}`);if(t.svgString){i.src="data:image/svg+xml,"+encodeURIComponent(t.svgString);const S={type:H.BrowserImageDataReady,target:this,imageName:t.imageName,width:t.width,height:t.height,svgString:t.svgString,...V.createFrameUpdateTimestamps()};this.game.eventStore.addEvent(S)}else t.url&&fetch(t.url).then(S=>S.arrayBuffer()).then(S=>{this.arrayBufferToBase64Async(S).then(x=>{const z=this.inferImageSubtypeFromUrl(t.url);i.src="data:image/"+z+";base64,"+x;const G={type:H.BrowserImageDataReady,target:this,imageName:t.imageName,width:t.width,height:t.height,dataUrl:i.src,...V.createFrameUpdateTimestamps()};this.game.eventStore.addEvent(G)})})})}arrayBufferToBase64Async(t){return new Promise((i,r)=>{const h=new FileReader;h.onload=()=>{i(h.result?.toString().split(",")[1]??"")},h.onerror=r,h.readAsDataURL(new Blob([t]))})}inferImageSubtypeFromUrl(t){if(t?.startsWith("data:image/"))return t.split(";")[0].split("/")[1];let i="jpeg";return t?.includes(".")&&(i=t.split(".").pop()?.toLowerCase()??"jpeg",i===""&&(i="jpeg")),i==="svg"&&(i="svg+xml"),i}getImage(t){return this.images[t]}addImage(t){this.images[t.imageName]=t}get scratchCanvas(){if(!this._scratchCanvas){this._scratchCanvas=document.createElement("canvas"),this._scratchCanvas.id=`m2c2kit-scratch-canvas-${this.game.id}-${Math.floor(Math.random()*1e6)}`,this._scratchCanvas.hidden=!0,document.body.appendChild(this._scratchCanvas);const t=this._scratchCanvas.getContext("2d");if(t===null)throw new C("could not get 2d canvas context from scratch canvas");this.ctx=t,this.scale=window.devicePixelRatio}return this._scratchCanvas}removeScratchCanvas(){this.ctx=void 0,this._scratchCanvas?.remove()}}const di="{{}}",pn="[[]]";class zi{constructor(t,i){this.locale="",this.fallbackLocale="en-US",this.baseLocale="en-US",this.game=t,this._translation=this.mergeAdditionalTranslation(i.translation,i.additionalTranslation)??{},this.translation.configuration?.baseLocale&&(this.baseLocale=this.translation.configuration.baseLocale),i.missingLocalizationColor&&(this.missingLocalizationColor=i.missingLocalizationColor),i.locale&&(this.locale=i.locale),i.fallbackLocale&&(this.fallbackLocale=i.fallbackLocale)}async initialize(){await this.configureInitialLocale()}async configureInitialLocale(){if(this.game.hasDataStores()){const t=await this.game.storeGetItem("locale"),i=await this.game.storeGetItem("fallbackLocale");if(typeof t=="string"&&typeof i=="string"){this.locale=t,this.fallbackLocale=i;return}}if(this.locale?.toLowerCase()==="auto"){const t=this.getEnvironmentLocale();t?this.localeTranslationAvailable(t)?(this.locale=t,this.localeTranslationAvailable(this.fallbackLocale)||(this.fallbackLocale=this.baseLocale)):this.fallbackLocale&&this.localeTranslationAvailable(this.fallbackLocale)?(console.warn(`auto locale requested, but detected locale ${t} does not have translation. Setting locale to fallback locale ${this.fallbackLocale}`),this.locale=this.fallbackLocale,this.fallbackLocale=this.baseLocale):(console.warn(`auto locale requested, but detected locale ${t} does not have translation, and fallback locale does not have translation or was not specified (fallback locale is ${this.fallbackLocale}). Setting locale to base locale ${this.baseLocale}.`),this.locale=this.baseLocale,this.fallbackLocale=this.baseLocale):this.fallbackLocale&&this.localeTranslationAvailable(this.fallbackLocale)?(console.warn(`auto locale requested, but environment cannot detect locale. Setting locale to fallback locale ${this.fallbackLocale}`),this.locale=this.fallbackLocale,this.fallbackLocale=this.baseLocale):(console.warn(`auto locale requested, but environment cannot detect locale, and fallback locale does not have translation or was not specified (fallback locale is ${this.fallbackLocale}). Setting locale to base locale ${this.baseLocale}.`),this.locale=this.baseLocale,this.fallbackLocale=this.baseLocale)}else this.locale=this.locale??"",this.fallbackLocale||(this.fallbackLocale=this.baseLocale)}localeTranslationAvailable(t){return this.translation[t]!==void 0||t===this.baseLocale}switchToLocale(t){this.locale=t,this.game.nodes.filter(i=>i.isText).forEach(i=>i.needsInitialization=!0),this.game.imageManager.reinitializeLocalizedImages(),this.game&&this.game.hasDataStores()&&(this.game.storeSetItem("locale",this.locale),this.game.storeSetItem("fallbackLocale",this.fallbackLocale))}getTextLocalization(t,i){const r=this.attemptTranslation(t,i);if(r.isFallbackOrMissingTranslation){const h=this.handleTranslationPlaceholders(t,r,i);if(h)return i!==void 0&&(h.text=this.insertInterpolations(di,h.text,i)),h}return r}attemptTranslation(t,i){let r=this.tf(t,i),h=!1;return r?.text===void 0&&(r=this.tf(t,{useFallbackLocale:!0,...i}),h=!0),{text:r?.text??t,fontSize:r?.fontSize,fontName:r?.fontName,fontNames:r?.fontNames,isFallbackOrMissingTranslation:h}}handleTranslationPlaceholders(t,i,r){const h=this.getTranslationPlaceholders(t);if(h.length===0)return null;const c={size:new Set,name:new Set,names:new Set},S={};let x=!1;h.forEach(lt=>{const yt=this.translatePlaceholder(lt,c,r);S[lt]=yt.text,x=x||yt.isFallback}),this.warnConflictingFontProperties(t,c);const z=this.insertInterpolations(pn,t,S),G=i.fontSize||(c.size.size>0?[...c.size][0]:void 0),q=i.fontName||(c.name.size>0?[...c.name][0]:void 0),st=i.fontNames||(c.names.size>0?[...c.names][0].split(","):void 0);return{text:z,fontSize:G,fontName:q,fontNames:st,isFallbackOrMissingTranslation:x}}translatePlaceholder(t,i,r){let h=this.tf(t,r),c=!1;return h?.text===void 0&&(h=this.tf(t,{useFallbackLocale:!0,...r}),c=!0),h?.fontSize!==void 0&&i.size.add(h.fontSize),h?.fontName!==void 0&&i.name.add(h.fontName),h?.fontNames!==void 0&&i.names.add(h.fontNames.sort().join(",")),{text:h?.text??t,isFallback:c}}getTranslationPlaceholders(t){const[i,r]=[pn.slice(0,2),pn.slice(2)],h=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),S=new RegExp(`${h}(.*?)${c}`,"g"),x=t.match(S);return x?x.map(z=>z.slice(i.length,-r.length).trim()):[]}warnConflictingFontProperties(t,i){i.size.size>1&&console.warn(`i18n: placeholders set multiple different font sizes in string to be localized. Only one will be used. String: ${t}`),i.name.size>1&&console.warn(`i18n: placeholders set multiple different font names within string to be localized. Only one will be used. String: ${t}`),i.names.size>1&&console.warn(`i18n: placeholders set multiple different font names arrays within string to be localized. Only one will be used. String: ${t}`)}t(t,i){const{useFallbackLocale:r,...h}=i??{};if(r!==!0){const S=this.translation[this.locale]?.[t];return this.isStringOrTextWithFontCustomization(S)?this.insertInterpolations(di,this.getKeyText(S),h):void 0}const c=this.translation[this.fallbackLocale]?.[t];if(this.isStringOrTextWithFontCustomization(c))return this.insertInterpolations(di,this.getKeyText(c),h)}tf(t,i){const{useFallbackLocale:r,...h}=i??{};if(r!==!0){const S=this.translation[this.locale]?.[t];if(this.isStringOrTextWithFontCustomization(S)){const x=this.getKeyTextAndFont(S,this.locale);return x.text&&(x.text=this.insertInterpolations(di,x.text,h)),x}return}const c=this.translation[this.fallbackLocale]?.[t];if(this.isStringOrTextWithFontCustomization(c)){const S=this.getKeyTextAndFont(c,this.fallbackLocale);return S.text&&(S.text=this.insertInterpolations(di,S.text,h)),S}}getKeyText(t){return this.isTextWithFontCustomization(t)?t.text:t}getKeyTextAndFont(t,i){let r,h=new Array;this.isString(this.translation[i]?.fontName)?h.push(this.translation[i].fontName):this.isStringArray(this.translation[i]?.fontName)?h.push(...this.translation[i].fontName):h.push("default");let c;switch(this.isTextWithFontCustomization(t)?(c=t.text,r=t.fontSize,this.isString(t.additionalFontName)&&h.push(t.additionalFontName),this.isStringArray(t.additionalFontName)&&h.push(...t.additionalFontName),t.overrideFontName&&(h.length=0,this.isString(t.overrideFontName)&&h.push(t.overrideFontName),this.isStringArray(t.overrideFontName)&&h.push(...t.overrideFontName))):c=t,h=h.filter(S=>S!=="default"),h.length){case 0:return{text:c,fontSize:r};case 1:return{text:c,fontSize:r,fontName:h[0]};default:return{text:c,fontSize:r,fontNames:h}}}insertInterpolations(t,i,r){if(!r)return i;const[h,c]=[t.slice(0,2),t.slice(2)],S=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),x=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),z=new RegExp(`${S}(.*?)${x}`,"g");return i.replace(z,(G,q)=>{if(Object.prototype.hasOwnProperty.call(r,q))return r[q];throw new C(`insertInterpolations(): placeholder "${q}" not found. Text was ${i}, provided interpolation was ${JSON.stringify(r)}`)})}get translation(){return this._translation}set translation(t){this._translation=t}getEnvironmentLocale(){return(navigator.languages&&navigator.languages.length?navigator.languages[0]:navigator.language)??""}mergeAdditionalTranslation(t,i){if(!t&&!i)return;if(!i)return t;if(!t)return i;const r={},h=new Array;for(const c in t)h.push(c),r[c]={...t[c],...i[c]};for(const c in i)h.includes(c)||(r[c]=i[c]);return r}static makeLocalizationParameters(){return JSON.parse(JSON.stringify({locale:{type:["string","null"],default:null,description:'Locale to use for localization, or "auto" to request from the environment.'},fallback_locale:{type:["string","null"],default:null,description:'Locale to use if requested locale translation is not available, or if "auto" locale was requested and environment cannot provide a locale.'},missing_localization_color:{type:["array","null"],default:null,description:"Font color for strings that are missing translation and outline color for images that are missing localization, [r,g,b,a].",items:{type:"number"}},translation:{type:["object","null"],default:null,description:"Additional translation for localization."}}))}isTextWithFontCustomization(t){return t?.text!==void 0}isStringOrTextWithFontCustomization(t){return typeof t=="string"||this.isTextWithFontCustomization(t)}isStringArray(t){return Array.isArray(t)&&t.every(i=>typeof i=="string")}isString(t){return typeof t=="string"}}const ve={Disabled:"Disabled",Record:"Record",Replay:"Replay"};class $r{constructor(){this.events=new Array,this.replayBeginTimestamp=NaN,this.firstTimestamp=NaN,this.replayThoughSequence=Number.MAX_VALUE,this.serializedEventsBeforeReplay="",this.mode=ve.Disabled}serializeEvent(t){const i=t.target;if(t.type===H.NodeNew&&t.nodeOptions?.layout?.constraints!==void 0){const h=t.nodeOptions?.layout?.constraints,c={};for(const x in h){if(x==="horizontalBias"||x==="verticalBias"){c[x]=h[x];continue}const z=h[x];z instanceof fe&&(c[x]=z.uuid)}t.target=i.uuid,t.nodeOptions.layout.constraints=c;const S=JSON.stringify(t);return t.target=i,t.nodeOptions.layout.constraints=h,S}if(i instanceof fe){t.target=i.uuid;const h=JSON.stringify(t);return t.target=i,h}if(i instanceof Element){t.target=i.nodeName;const h=JSON.stringify(t);return t.target=i,h}if(i instanceof fn){t.target="ImageManager";const h=JSON.stringify(t);return t.target=i,h}if(i instanceof zi){t.target="I18n";const h=JSON.stringify(t);return t.target=i,h}t.target="object";const r=JSON.stringify(t);return t.target=i,r}addEvent(t){if(this.mode===ve.Record){t.sequence===void 0&&(t.sequence=m2c2Globals.eventSequence);const i=this.serializeEvent(t);this.events.push(JSON.parse(i))}}addEvents(t){t.forEach(i=>{this.addEvent(i)})}clearEvents(){this.events=[]}record(){this.mode=ve.Record}replay(t){if(t&&(this.events=t),this.events.length===0)if(this.serializedEventsBeforeReplay!=="")this.events=JSON.parse(this.serializedEventsBeforeReplay);else{console.log("Event store has no events to replay.");return}this.mode=ve.Replay,this.replayBeginTimestamp=Vt.now(),this.sortEventStore(this.events),this.serializedEventsBeforeReplay===""&&(this.serializedEventsBeforeReplay=JSON.stringify(this.events)),this.firstTimestamp=this.events[0].timestamp,console.log(`Event store has ${this.events.length} events. Replay beginning.`);const i=document.getElementById("sequence-number");i&&(this.replayThoughSequence=parseInt(i.value))}getEvents(){return this.sortEventStore(this.events),this.events}dequeueEvents(t){const i=new Array,r=t-this.replayBeginTimestamp+this.firstTimestamp;for(;this.events.length>0&&this.events[0].timestamp<=r;){const h=this.events.shift();if(!h)throw new C("EventStore.dequeueEvents(): undefined event");h.sequence!==void 0&&h.sequence>this.replayThoughSequence||i.push(h)}return i}get eventQueueLength(){return this.events.length}sortEventStore(t){t.sort((i,r)=>{if(i.sequence===void 0||r.sequence===void 0)throw new C("EventStore.sortEventStore(): undefined sequence");return i.sequence!==r.sequence?i.sequence-r.sequence:0})}}var He=(m=>(m[m.Center=0]="Center",m[m.Left=1]="Left",m[m.Right=2]="Right",m))(He||{});const re={Deferred:"Deferred",Loading:"Loading",Ready:"Ready"},Jt={UNDERLINE:"u",ITALIC:"i",BOLD:"b",STRIKETHROUGH:"s",OVERLINE:"o"};class Ui extends fe{constructor(t={}){super(t),this.type=dt.Label,this.isDrawable=!0,this.isText=!0,this._anchorPoint={x:.5,y:.5},this._zPosition=0,this._text="",this._fontColor=Q.DEFAULT_FONT_COLOR,this._fontSize=Q.DEFAULT_FONT_SIZE,this._interpolation={},this._horizontalAlignmentMode=He.Center,this._localize=!0,this.localizedFontNames=[],this.textAfterLocalization="",this.plainText="",this.styleSegments=[],Le(this,t),t.horizontalAlignmentMode&&(this.horizontalAlignmentMode=t.horizontalAlignmentMode),t.preferredMaxLayoutWidth!==void 0&&(this.preferredMaxLayoutWidth=t.preferredMaxLayoutWidth),t.backgroundColor&&(this.backgroundColor=t.backgroundColor),t.fontNames&&(this.fontNames=t.fontNames),this.saveNodeNewEvent()}get completeNodeOptions(){return{...this.options,...this.getNodeOptions(),...this.getDrawableOptions(),...this.getTextOptions(),horizontalAlignmentMode:this.horizontalAlignmentMode,preferredMaxLayoutWidth:this.preferredMaxLayoutWidth,backgroundColor:this.backgroundColor,fontNames:this.fontNames}}initialize(){let t=this.canvasKit.TextAlign.Center;switch(this.horizontalAlignmentMode){case He.Center:t=this.canvasKit.TextAlign.Center;break;case He.Left:t=this.canvasKit.TextAlign.Left;break;case He.Right:t=this.canvasKit.TextAlign.Right;break;default:throw new C("unknown horizontalAlignmentMode")}this.text||(this.text="");let i=this.canvasKit.Color(this.fontColor[0],this.fontColor[1],this.fontColor[2],this.fontColor[3]);const r=this.game.i18n;if(r&&this.localize!==!1){const q=r.getTextLocalization(this.text,this.interpolation);this.textAfterLocalization=q.text,this.localizedFontSize=q.fontSize,this.localizedFontName=q.fontName,this.localizedFontNames=q.fontNames??[],q.isFallbackOrMissingTranslation&&r.missingLocalizationColor&&(i=this.canvasKit.Color(r.missingLocalizationColor[0],r.missingLocalizationColor[1],r.missingLocalizationColor[2],r.missingLocalizationColor[3]))}else this.textAfterLocalization=this.text;const h=this.parseFormattedText(this.textAfterLocalization);if(this.plainText=h.plainText,this.styleSegments=h.styleSegments,this.fontName&&this.fontNames)throw new C("cannot specify both fontName and fontNames");const c=this.game.fontManager,S=this.getRequiredLabelFonts(c);if(S.forEach(q=>{if(q.status===re.Deferred){c.prepareDeferredFont(q);return}}),!S.every(q=>q.status===re.Ready))return;this.paraStyle=new this.canvasKit.ParagraphStyle({textStyle:{},textAlign:t}),this.builder&&this.builder.delete(),this.builder=this.canvasKit.ParagraphBuilder.MakeFromFontProvider(this.paraStyle,c.provider),this._backgroundPaint||(this._backgroundPaint=new this.canvasKit.Paint),this._fontPaint||(this._fontPaint=new this.canvasKit.Paint),this.fontPaint.setColor(i),this.fontPaint.setAlphaf(this.absoluteAlpha),this.backgroundColor?(this.backgroundPaint.setColor(this.backgroundColor),this.backgroundPaint.setAlphaf(this.absoluteAlpha)):this.backgroundPaint.setColor(this.canvasKit.Color(0,0,0,0));const x={fontFamilies:S.map(q=>q.fontName),fontSize:(this.localizedFontSize??this.fontSize)*m2c2Globals.canvasScale,fontStyle:{weight:this.canvasKit.FontWeight.Normal,width:this.canvasKit.FontWidth.Normal,slant:this.canvasKit.FontSlant.Upright},decoration:0,decorationThickness:1,decorationStyle:this.canvasKit.DecorationStyle.Solid,heightMultiplier:-1,halfLeading:!1,letterSpacing:0,wordSpacing:0};this.builder.pushPaintStyle(x,this.fontPaint,this.backgroundPaint),this.addStyleSegmentsToParagraphBuilder(this.builder,this.styleSegments,x),this.paragraph&&this.paragraph.delete(),this.paragraph=this.builder.build();const z=this.preferredMaxLayoutWidth??m2c2Globals.canvasCssWidth;let G=z;if(z===0||this.layout.width===0){if(this.parent===void 0)throw new C("width is set to match parent, but node has no parent");const q=this.layout.marginStart??0,st=this.layout.marginEnd??0;G=this.parent.size.width-(q+st)}this.paragraph.layout(G*m2c2Globals.canvasScale),z===0||this.layout.width===0?this.size.width=G:(this.paragraph.layout(Math.ceil(this.paragraph.getLongestLine())),this.size.width=this.paragraph.getMaxWidth()/m2c2Globals.canvasScale),this.size.height=this.paragraph.getHeight()/m2c2Globals.canvasScale,this.needsInitialization=!1}parseFormattedText(t){let i="";const r=[],h=[],c=new Set([Jt.UNDERLINE,Jt.BOLD,Jt.ITALIC,Jt.STRIKETHROUGH,Jt.OVERLINE]),S=/<\/?([^>]+)>/g;let x=0,z=0,G=null;const q=rt=>{let Et=1,Wt=1;for(let Bt=0;Bt<rt;Bt++)t[Bt]===`
2
- `?(Et++,Wt=1):Wt++;return`line ${Et}, column ${Wt}`};for(;(G=S.exec(t))!==null;){const rt=G[0],Et=G[1],Wt=rt.charAt(1)==="/",Bt=q(G.index);if(!c.has(Et)){const U=t.substring(x,G.index);i+=U,z+=U.length,i+=rt,z+=rt.length,x=G.index+rt.length;continue}const se=t.substring(x,G.index);if(i+=se,z+=se.length,Wt){if(h.length===0)throw new C(`Label has closing tag </${Et}> at ${Bt} without matching opening tag. Text is: ${t}`);const U=h.pop();if(U!==Et)throw new C(`Label has improperly nested tags at ${Bt}. Expected </${U}> but found </${Et}>. Tags must be properly nested. Text is: ${t}`);r.push({position:z,style:Et,isStart:!1})}else h.push(Et),r.push({position:z,style:Et,isStart:!0});x=G.index+rt.length}if(i+=t.substring(x),h.length>0)throw new C(`Label has unclosed format tags: <${h.join(">, <")}>. All tags must be closed. Text is: ${t}`);const st=new Set,lt=[];let yt=0;r.sort((rt,Et)=>rt.position-Et.position);for(const rt of r)rt.position>yt&&st.size>0&&lt.push({start:yt,end:rt.position,styles:new Set(st)}),rt.isStart?st.add(rt.style):st.delete(rt.style),yt=rt.position;return{plainText:i,styleSegments:lt}}addStyleSegmentsToParagraphBuilder(t,i,r){if(i.length===0)t.addText(this.plainText);else{let h=0;for(const c of i){c.start>h&&this.addTextWithStyle(t,this.plainText.substring(h,c.start),r);const S={};if(c.styles.has(Jt.BOLD)&&(S.fontStyle={...S.fontStyle||r.fontStyle,weight:this.canvasKit.FontWeight.Black}),c.styles.has(Jt.ITALIC)&&(S.fontStyle={...S.fontStyle||r.fontStyle,slant:this.canvasKit.FontSlant.Italic}),c.styles.has(Jt.UNDERLINE)&&(S.decoration=this.canvasKit.UnderlineDecoration,S.decorationThickness=1,S.decorationStyle=this.canvasKit.DecorationStyle.Solid,S.decorationColor=this.fontColor),c.styles.has(Jt.STRIKETHROUGH)&&(S.decoration=this.canvasKit.LineThroughDecoration,S.decorationThickness=1,S.decorationStyle=this.canvasKit.DecorationStyle.Solid,S.decorationColor=this.fontColor),c.styles.has(Jt.OVERLINE)&&(S.decoration=this.canvasKit.OverlineDecoration,S.decorationThickness=1,S.decorationStyle=this.canvasKit.DecorationStyle.Solid,S.decorationColor=this.fontColor),[Jt.UNDERLINE,Jt.STRIKETHROUGH,Jt.OVERLINE].filter(z=>c.styles.has(z)).length>1)throw new C(`Label does not support multiple text decorations (underline, overline, or strikethrough) on a single text segment. Text is: ${this.textAfterLocalization}`);this.addTextWithStyle(t,this.plainText.substring(c.start,c.end),r,S),h=c.end}h<this.plainText.length&&this.addTextWithStyle(t,this.plainText.substring(h),r)}}addTextWithStyle(t,i,r,h={}){if(!i)return;const c={...r,...h};t.pushPaintStyle(c,this.fontPaint,this.backgroundPaint),t.addText(i),t.pop()}getRequiredLabelFonts(t){let i;if(this.game.i18n&&this.localize!==!1){if(this.localizedFontName)return i=[t.fonts[this.localizedFontName]],i;if(this.localizedFontNames.length>0)return i=this.localizedFontNames.map(r=>t.fonts[r]),i}if(this.fontName===void 0&&this.fontNames===void 0)i=[t.getDefaultFont()];else if(this.fontName!==void 0)i=[t.fonts[this.fontName]];else if(this.fontNames!==void 0&&this.fontNames.length>0)i=this.fontNames.map(r=>t.fonts[r]);else throw new C("cannot determine required fonts");return i}dispose(){Nt.Dispose([this.paragraph,this.builder,this._fontPaint,this._backgroundPaint])}get text(){return this._text}set text(t){K.value(this._text,t)||(this._text=t,this.needsInitialization=!0,this.savePropertyChangeEvent("text",t))}get interpolation(){return this._interpolation}set interpolation(t){K.value(this._interpolation,t)||(this._interpolation=t,Object.freeze(this._interpolation),this.needsInitialization=!0,this.savePropertyChangeEvent("interpolation",t))}get fontName(){return this._fontName}set fontName(t){K.value(this._fontName,t)||(this._fontName=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontName",t))}get fontNames(){return this._fontNames}set fontNames(t){K.value(this._fontNames,t)||(this._fontNames=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontNames",t))}get fontColor(){return this._fontColor}set fontColor(t){K.value(this._fontColor,t)||(this._fontColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontColor",t))}get fontSize(){return this._fontSize}set fontSize(t){K.value(this._fontSize,t)||(this._fontSize=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontSize",t))}get horizontalAlignmentMode(){return this._horizontalAlignmentMode}set horizontalAlignmentMode(t){K.value(this._horizontalAlignmentMode,t)||(this._horizontalAlignmentMode=t,this.needsInitialization=!0,this.savePropertyChangeEvent("horizontalAlignmentMode",t))}get preferredMaxLayoutWidth(){return this._preferredMaxLayoutWidth}set preferredMaxLayoutWidth(t){K.value(this._preferredMaxLayoutWidth,t)||(this._preferredMaxLayoutWidth=t,this.needsInitialization=!0,this.savePropertyChangeEvent("preferredMaxLayoutWidth",t))}get backgroundColor(){return this._backgroundColor}set backgroundColor(t){K.value(this._backgroundColor,t)||(this._backgroundColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("backgroundColor",t))}get localize(){return this._localize}set localize(t){K.value(this._localize,t)||(this._localize=t,this.needsInitialization=!0,this.savePropertyChangeEvent("localize",t))}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){K.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){K.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){K.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){K.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}get backgroundPaint(){if(!this._backgroundPaint)throw new C("backgroundPaint cannot be undefined");return this._backgroundPaint}set backgroundPaint(t){this._backgroundPaint=t}get fontPaint(){if(!this._fontPaint)throw new C("fontPaint cannot be undefined");return this._fontPaint}set fontPaint(t){this._fontPaint=t}duplicate(t){const i=new Ui({...this.getNodeOptions(),...this.getDrawableOptions(),...this.getTextOptions(),horizontalAlignmentMode:this.horizontalAlignmentMode,preferredMaxLayoutWidth:this.preferredMaxLayoutWidth,backgroundColor:this.backgroundColor,name:t});return this.children.length>0&&(i.children=this.children.map(r=>{const h=r.duplicate();return h.parent=i,h})),i}update(){super.update(),this.absoluteAlphaChange!==0&&this.initialize()}draw(t){if(this.parent&&this.text!==""&&!this.needsInitialization){t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;t.scale(1/i,1/i),V.rotateCanvasForDrawableNode(t,this);const r=(this.absolutePosition.x-this.size.width*this.anchorPoint.x*this.absoluteScale)*i,h=(this.absolutePosition.y-this.size.height*this.anchorPoint.y*this.absoluteScale)*i;if(this.paragraph===void 0)throw new C("no paragraph");t.drawParagraph(this.paragraph,r,h),t.restore()}super.drawChildren(t)}warmup(t){const i=this.game.i18n;if(i&&this.localize!==!1){const h=i.getTextLocalization(this.text,this.interpolation);this.localizedFontName=h.fontName,this.localizedFontNames=h.fontNames??[]}if(!this.getRequiredLabelFonts(this.game.fontManager).some(h=>h.status===re.Deferred)&&Object.keys(this.layout).length===0){if(this.initialize(),!this.paragraph)throw new C(`warmup Label node ${this.toString()}: paragraph is undefined`);t.drawParagraph(this.paragraph,0,0)}}}class Ve extends fe{constructor(t={}){super(t),this.type=dt.Scene,this.isDrawable=!0,this._anchorPoint={x:0,y:0},this._zPosition=0,this._backgroundColor=Q.DEFAULT_SCENE_BACKGROUND_COLOR,this._active=!1,this._transitioning=!1,Le(this,t),t.backgroundColor&&(this.backgroundColor=t.backgroundColor),this.saveNodeNewEvent()}get completeNodeOptions(){return{...this.options,...this.getNodeOptions(),...this.getDrawableOptions(),backgroundColor:this.backgroundColor}}initialize(){this.scale=m2c2Globals.rootScale,this.size.width=this.game.canvasCssWidth,this.size.height=this.game.canvasCssHeight,this.backgroundPaint&&this.backgroundPaint.delete(),this.backgroundPaint=Nt.makePaint(this.canvasKit,this.backgroundColor,this.canvasKit.PaintStyle.Fill,!1),this.needsInitialization=!1}dispose(){Nt.Dispose([this.backgroundPaint])}set game(t){this._game=t}get game(){if(this._game===void 0)throw new C(`Scene ${this} has not been added to a game.`);return this._game}get backgroundColor(){return this._backgroundColor}set backgroundColor(t){K.value(this._backgroundColor,t)||(this._backgroundColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("backgroundColor",t))}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){K.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){K.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){K.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){K.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}duplicate(t){const i=new Ve({...this.getNodeOptions(),...this.getDrawableOptions(),backgroundColor:this.backgroundColor,name:t});return i.game=this.game,this.children.length>0&&(i.children=this.children.map(r=>{const h=r.duplicate();return h.parent=i,h})),i}onSetup(t,i){this.addEventListener("SceneSetup",t,i)}onAppear(t,i){this.addEventListener("SceneAppear",t,i)}onKeyDown(t,i){this.addEventListener(H.KeyDown,t,i)}onKeyUp(t,i){this.addEventListener(H.KeyUp,t,i)}update(){super.update()}draw(t){t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;if(t.scale(1/i,1/i),V.rotateCanvasForDrawableNode(t,this),!this.backgroundPaint)throw new C(`in Scene ${this}, background paint is undefined.`);this.absoluteAlphaChange!==0&&this.backgroundPaint.setAlphaf(this.absoluteAlpha),t.drawRect([this.position.x*i*m2c2Globals.rootScale,this.position.y*i*m2c2Globals.rootScale,(this.position.x+this.size.width)*i*m2c2Globals.rootScale,(this.position.y+this.size.height)*i*m2c2Globals.rootScale],this.backgroundPaint),t.restore(),super.drawChildren(t)}warmup(t){this.initialize(),t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;if(t.scale(1/i,1/i),!this.backgroundPaint)throw new C(`in Scene ${this}, background paint is undefined.`);t.drawRect([this.position.x*i*m2c2Globals.rootScale,this.position.y*i*m2c2Globals.rootScale,(this.position.x+this.size.width)*i*m2c2Globals.rootScale,(this.position.y+this.size.height)*i*m2c2Globals.rootScale],this.backgroundPaint),t.restore(),this.children.forEach(r=>{r.isDrawable&&r.warmup(t)})}}class fi extends fe{constructor(t={}){if(super(t),this.type=dt.Shape,this.isDrawable=!0,this.isShape=!0,this._anchorPoint={x:.5,y:.5},this._zPosition=0,this.shapeType=Kt.Undefined,this.ckPath=null,this._cornerRadius=0,this._fillColor=Q.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,Le(this,t),t.path!==void 0){if(this.path=t.path,this.shapeType=Kt.Path,this.shapeIsM2Path()&&t.size!==void 0&&(this.size=t.size),this.shapeIsSvgStringPath()&&t.size!==void 0)throw new C("Size cannot be specified when path is SVG string path");if(this.svgPathRequestedWidth=t.path.width,this.svgPathRequestedHeight=t.path.height,this.svgPathRequestedHeight!==void 0&&this.svgPathRequestedWidth!==void 0)throw new C("Cannot specify both width and height for SVG string path.");if(this.strokeColor||(this.strokeColor=Q.DEFAULT_PATH_STROKE_COLOR),this.lineWidth===void 0&&(this.lineWidth=Q.DEFAULT_PATH_LINE_WIDTH),t.circleOfRadius||t.rect)throw new C("Shape must specify only one of: path, circleOfRadius, or rect")}if(t.circleOfRadius!==void 0){if(this.circleOfRadius=t.circleOfRadius,this.shapeType=Kt.Circle,t.size!==void 0)throw new C("Size cannot be specified for circle shape");if(t.path||t.rect)throw new C("Shape must specify only one of: path, circleOfRadius, or rect");this.size.width=this.circleOfRadius*2,this.size.height=this.circleOfRadius*2}if(t.rect&&(this.rect=t.rect,t.rect.size?(this.size.width=t.rect.size.width,this.size.height=t.rect.size.height):t.rect.width!==void 0&&t.rect.height!==void 0&&(this.size.width=t.rect.width,this.size.height=t.rect.height),t.rect.origin?this.position=t.rect.origin:t.rect.x!==void 0&&t.rect.y!==void 0&&(this.position={x:t.rect.x,y:t.rect.y}),this.shapeType=Kt.Rectangle,t.size!==void 0))throw new C("Size cannot be specified for rectangle shape");t.cornerRadius!==void 0&&(this.cornerRadius=t.cornerRadius),t.fillColor&&(this.fillColor=t.fillColor),t.strokeColor&&(this.strokeColor=t.strokeColor),t.lineWidth!==void 0&&(this.lineWidth=t.lineWidth),t.isAntialiased!==void 0&&(this.isAntialiased=t.isAntialiased),t.strokeColor&&!t.lineWidth&&console.warn(`warning: for node ${this}, strokeColor = ${t.strokeColor} but lineWidth is non-zero. In normal usage, both would be set or both would be undefined.`),t.strokeColor===void 0&&t.lineWidth&&console.warn(`warning: for node ${this}, lineWidth = ${t.lineWidth} but strokeColor is undefined. In normal usage, both would be set or both would be undefined.`),this.saveNodeNewEvent()}get completeNodeOptions(){let t;return this.shapeIsM2Path()&&(t=this.size),{...this.options,...this.getNodeOptions(),...this.getDrawableOptions(),circleOfRadius:this.circleOfRadius,rect:this.rect,cornerRadius:this.cornerRadius,fillColor:this.fillColor,strokeColor:this.strokeColor,lineWidth:this.lineWidth,path:this.path,size:t,isAntialiased:this.isAntialiased}}initialize(){if(this.shapeType===Kt.Path&&this.shapeIsSvgStringPath()){const t=this.path.pathString??this.path.svgPathString;if(!t)throw new C("SVG Path string is null/undefined");if(this.path.svgPathString!==void 0&&console.warn("warning: svgPathString is deprecated. Use pathString instead."),this.ckPath=this.canvasKit.Path.MakeFromSVGString(t),!this.ckPath)throw new C("could not make CanvasKit Path from SVG string");const i=this.ckPath.getBounds();this.svgPathWidth=i[2]+(i[0]<0?Math.abs(i[0]):0),this.svgPathHeight=i[3]+(i[1]<0?Math.abs(i[1]):0),this.svgPathRequestedHeight!==void 0?this.svgPathScaleForResizing=this.svgPathRequestedHeight/this.svgPathHeight:this.svgPathRequestedWidth!==void 0&&(this.svgPathScaleForResizing=this.svgPathRequestedWidth/this.svgPathWidth),this.size.width=this.svgPathWidth*this.svgPathScaleForResizing,this.size.height=this.svgPathHeight*this.svgPathScaleForResizing,this.svgPreviousAbsoluteX=0,this.svgPreviousAbsoluteY=0}if(this.shapeIsM2Path()&&(this.size.width===0||this.size.height===0||this.size.width===void 0||this.size.height===void 0))throw new C("Size of shape must have non-zero height and width when path is M2Path");this.fillColor&&(this.fillColorPaintAntialiased=Nt.makePaint(this.canvasKit,this.fillColor,this.canvasKit.PaintStyle.Fill,!0),this.fillColorPaintNotAntialiased=Nt.makePaint(this.canvasKit,this.fillColor,this.canvasKit.PaintStyle.Fill,!1)),this.strokeColor&&(this.strokeColorPaintAntialiased=Nt.makePaint(this.canvasKit,this.strokeColor,this.canvasKit.PaintStyle.Stroke,!0),this.strokeColorPaintNotAntialiased=Nt.makePaint(this.canvasKit,this.strokeColor,this.canvasKit.PaintStyle.Stroke,!1)),this.svgFirstPathDraw=!0,this.needsInitialization=!1}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){K.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){K.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){K.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){K.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}dispose(){Nt.Dispose([this._strokeColorPaintAntialiased,this._strokeColorPaintNotAntialiased,this._fillColorPaintAntialiased,this._fillColorPaintNotAntialiased,this.ckPath,...Array.from(this.colorfulPathPaints.values())])}duplicate(t){const i=new fi({...this.getNodeOptions(),...this.getDrawableOptions(),shapeType:this.shapeType,circleOfRadius:this.circleOfRadius,rect:this.rect,cornerRadius:this.cornerRadius,fillColor:this.fillColor,strokeColor:this.strokeColor,lineWidth:this.lineWidth,name:t});return this.children.length>0&&(i.children=this.children.map(r=>{const h=r.duplicate();return h.parent=i,h})),i}update(){super.update()}draw(t){t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;t.scale(1/i,1/i),V.rotateCanvasForDrawableNode(t,this),this.absoluteAlphaChange!==0&&this.applyAlphaToPaints(this.absoluteAlpha,[this._fillColorPaintAntialiased,this._fillColorPaintNotAntialiased,this._strokeColorPaintAntialiased,this._strokeColorPaintNotAntialiased]),this.shapeIsM2Path()&&this.drawPathFromM2Path(t),this.shapeIsSvgStringPath()&&this.drawPathFromSvgString(t),this.shapeType===Kt.Circle&&this.drawCircle(t),this.shapeType===Kt.Rectangle&&this.drawRectangle(t),t.restore(),super.drawChildren(t)}applyAlphaToPaints(t,i){i.forEach(r=>{r&&r.setAlphaf(t)})}drawPathFromM2Path(t){const i=m2c2Globals.canvasScale/this.absoluteScale,r=(this.absolutePosition.x-this.anchorPoint.x*this.size.width*this.absoluteScale)*i,h=(this.absolutePosition.y-this.anchorPoint.y*this.size.height*this.absoluteScale)*i;if(this.pathIsM2ColorfulPath(this.path)){const c=this.path.linePresentations;let S=0;const x=this.path.subpaths;let z;for(let G=0;G<x.length;G++){const st=x[G].flat();for(let lt=0;lt<st.length-1;lt++){if(c[S].subpathIndex===G&&c[S].pointIndex===lt){const yt=c[S].strokeColor,rt=c[S].lineWidth,Et=[...yt,rt].toString();z=this.colorfulPathPaints.get(Et),z===void 0&&(z=Nt.makePaint(this.canvasKit,yt,this.canvasKit.PaintStyle.Stroke,!0),z.setStrokeWidth(rt*m2c2Globals.canvasScale),this.colorfulPathPaints.set(Et,z)),S<c.length-1&&S++}if(z===void 0)throw new C("paint is undefined");t.drawLine(r+st[lt].x*m2c2Globals.canvasScale,h+st[lt].y*m2c2Globals.canvasScale,r+st[lt+1].x*m2c2Globals.canvasScale,h+st[lt+1].y*m2c2Globals.canvasScale,z)}}return}if(this.strokeColor&&this.strokeColorPaintAntialiased&&this.lineWidth){this.strokeColorPaintAntialiased.setStrokeWidth(this.lineWidth*m2c2Globals.canvasScale);const c=this.path.subpaths;for(const S of c){const x=S.flat();for(let z=0;z<x.length-1;z++)t.drawLine(r+x[z].x*m2c2Globals.canvasScale,h+x[z].y*m2c2Globals.canvasScale,r+x[z+1].x*m2c2Globals.canvasScale,h+x[z+1].y*m2c2Globals.canvasScale,this.strokeColorPaintAntialiased)}}}drawPathFromSvgString(t){if(!this.ckPath)return;const i=this.calculateSvgPathX(),r=this.calculateSvgPathY();if(this.pathNeedsTransform(i,r)){const c=m2c2Globals.canvasScale/this.absoluteScale*this.svgPathScaleForResizing*m2c2Globals.rootScale,S=this.calculateTransformationMatrix(c,i,r);this.ckPath=this.ckPath.transform(S),this.saveSvgPathAbsolutePosition(i,r)}if(this.fillColor){const h=this.getFillPaint();t.drawPath(this.ckPath,h)}if(this.strokeColor&&this.lineWidth){const h=this.getStrokePaint(this.lineWidth);t.drawPath(this.ckPath,h)}}calculateSvgPathY(){const t=m2c2Globals.canvasScale/this.absoluteScale;return(this.absolutePosition.y-this.size.height*this.absoluteScale/2)*t}calculateSvgPathX(){const t=m2c2Globals.canvasScale/this.absoluteScale;return(this.absolutePosition.x-this.size.width*this.absoluteScale/2)*t}saveSvgPathAbsolutePosition(t,i){this.svgPreviousAbsoluteX=t,this.svgPreviousAbsoluteY=i}calculateTransformationMatrix(t,i,r){let h;this.svgFirstPathDraw?(h=t,this.svgFirstPathDraw=!1):h=1;const c=i-this.svgPreviousAbsoluteX,S=r-this.svgPreviousAbsoluteY;return[h,0,c,0,h,S,0,0,1]}pathNeedsTransform(t,i){return this.svgFirstPathDraw===!0||t!==this.svgPreviousAbsoluteX||i!==this.svgPreviousAbsoluteY}shapeIsSvgStringPath(){return this.path?.pathString!==void 0||this.path?.svgPathString!==void 0}shapeIsM2Path(){return this.path?.subpaths!==void 0}pathIsM2ColorfulPath(t){return t!==void 0&&"linePresentations"in t}drawCircle(t){if(this.circleOfRadius){if(this.fillColor){const i=this.getFillPaint();this.drawCircleWithCanvasKit(t,i)}if(this.strokeColor&&this.lineWidth){const i=this.getStrokePaint(this.lineWidth);this.drawCircleWithCanvasKit(t,i)}}}drawRectangle(t){if(this.fillColor){const i=this.getFillPaint();this.drawRectangleWithCanvasKit(t,i)}if(this.strokeColor&&this.lineWidth){const i=this.getStrokePaint(this.lineWidth);this.drawRectangleWithCanvasKit(t,i)}}drawCircleWithCanvasKit(t,i){if(!this.circleOfRadius)return;const r=m2c2Globals.canvasScale/this.absoluteScale,h=this.absolutePosition.x*r,c=this.absolutePosition.y*r,S=this.circleOfRadius*this.absoluteScale*r;t.drawCircle(h,c,S,i)}drawRectangleWithCanvasKit(t,i){const r=this.calculateCKRoundedRectangle();t.drawRRect(r,i)}calculateCKRoundedRectangle(){const t=m2c2Globals.canvasScale/this.absoluteScale;return this.canvasKit.RRectXY(this.canvasKit.LTRBRect((this.absolutePosition.x-this.anchorPoint.x*this.size.width*this.absoluteScale)*t,(this.absolutePosition.y-this.anchorPoint.y*this.size.height*this.absoluteScale)*t,(this.absolutePosition.x+this.size.width*this.absoluteScale-this.anchorPoint.x*this.size.width*this.absoluteScale)*t,(this.absolutePosition.y+this.size.height*this.absoluteScale-this.anchorPoint.y*this.size.height*this.absoluteScale)*t),this.cornerRadius*t,this.cornerRadius*t)}getFillPaint(){return this.involvedInActionAffectingAppearance()?this.fillColorPaintNotAntialiased:this.isAntialiased?this.fillColorPaintAntialiased:this.fillColorPaintNotAntialiased}getStrokePaint(t){let i;this.involvedInActionAffectingAppearance()?i=this.strokeColorPaintNotAntialiased:i=this.isAntialiased?this.strokeColorPaintAntialiased:this.strokeColorPaintNotAntialiased;const r=m2c2Globals.canvasScale/this.absoluteScale;return i.setStrokeWidth(t*r),i}warmup(t){this.initialize(),t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;t.scale(1/i,1/i),this.shapeType===Kt.Circle&&(this.fillColor&&this.warmupFilledCircle(t),this.strokeColor&&this.lineWidth&&this.warmupStrokedCircle(t)),this.shapeType===Kt.Rectangle&&(this.fillColor&&this.warmupFilledRectangle(t),this.strokeColor&&this.lineWidth&&this.warmupStrokedRectangle(t)),t.restore(),this.children.forEach(r=>{r.isDrawable&&r.warmup(t)})}warmupFilledCircle(t){this.circleOfRadius&&(this.drawCircleWithCanvasKit(t,this.fillColorPaintAntialiased),this.drawCircleWithCanvasKit(t,this.fillColorPaintNotAntialiased))}warmupStrokedCircle(t){if(!this.lineWidth||!this.circleOfRadius)return;const i=m2c2Globals.canvasScale/this.absoluteScale;this.strokeColorPaintAntialiased.setStrokeWidth(this.lineWidth*i),this.drawCircleWithCanvasKit(t,this.strokeColorPaintAntialiased),this.strokeColorPaintNotAntialiased.setStrokeWidth(this.lineWidth*i),this.drawCircleWithCanvasKit(t,this.strokeColorPaintNotAntialiased)}warmupFilledRectangle(t){this.drawRectangleWithCanvasKit(t,this.fillColorPaintAntialiased),this.drawRectangleWithCanvasKit(t,this.fillColorPaintNotAntialiased)}warmupStrokedRectangle(t){if(!this.lineWidth||!this.circleOfRadius)return;const i=m2c2Globals.canvasScale/this.absoluteScale;this.strokeColorPaintAntialiased.setStrokeWidth(this.lineWidth*i),this.drawRectangleWithCanvasKit(t,this.strokeColorPaintAntialiased),this.strokeColorPaintNotAntialiased.setStrokeWidth(this.lineWidth*i),this.drawRectangleWithCanvasKit(t,this.strokeColorPaintNotAntialiased)}get circleOfRadius(){return this._circleOfRadius}set circleOfRadius(t){K.value(t,this._circleOfRadius)||(this._circleOfRadius=t,this.needsInitialization=!0,this.savePropertyChangeEvent("circleOfRadius",t))}get rect(){return this._rect}set rect(t){K.value(t,this._rect)||(this._rect=t,this.needsInitialization=!0,this.savePropertyChangeEvent("rect",t))}get cornerRadius(){return this._cornerRadius}set cornerRadius(t){K.value(t,this._cornerRadius)||(this._cornerRadius=t??0,this.needsInitialization=!0,this.savePropertyChangeEvent("cornerRadius",t??0))}get lineWidth(){return this._lineWidth}set lineWidth(t){K.value(t,this._lineWidth)||(this._lineWidth=t,this.needsInitialization=!0,this.savePropertyChangeEvent("lineWidth",t))}get path(){return this._path}set path(t){K.value(t,this._path)||(this._path=t,this.needsInitialization=!0,this.savePropertyChangeEvent("path",t))}get fillColor(){return this._fillColor}set fillColor(t){K.value(t,this._fillColor)||(this._fillColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fillColor",t))}get strokeColor(){return this._strokeColor}set strokeColor(t){K.value(t,this._strokeColor)||(this._strokeColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("strokeColor",t))}get isAntialiased(){return this._isAntialiased}set isAntialiased(t){K.value(t,this._isAntialiased)||(this._isAntialiased=t,this.needsInitialization=!0,this.savePropertyChangeEvent("isAntialiased",t))}get fillColorPaintAntialiased(){if(!this._fillColorPaintAntialiased)throw new C("fillColorPaintAntiAliased is undefined");return this._fillColorPaintAntialiased}set fillColorPaintAntialiased(t){this._fillColorPaintAntialiased=t}get strokeColorPaintAntialiased(){if(!this._strokeColorPaintAntialiased)throw new C("strokeColorPaintAntiAliased is undefined");return this._strokeColorPaintAntialiased}set strokeColorPaintAntialiased(t){this._strokeColorPaintAntialiased=t}get fillColorPaintNotAntialiased(){if(!this._fillColorPaintNotAntialiased)throw new C("fillColorPaintNotAntiAliased is undefined");return this._fillColorPaintNotAntialiased}set fillColorPaintNotAntialiased(t){this._fillColorPaintNotAntialiased=t}get strokeColorPaintNotAntialiased(){if(!this._strokeColorPaintNotAntialiased)throw new C("strokeColorPaintNotAntiAliased is undefined");return this._strokeColorPaintNotAntialiased}set strokeColorPaintNotAntialiased(t){this._strokeColorPaintNotAntialiased=t}}class $i extends fe{constructor(t={}){super(t),this.type=dt.TextLine,this.isDrawable=!0,this.isText=!0,this._zPosition=0,this._anchorPoint={x:0,y:.5},this._text="",this._fontColor=Q.DEFAULT_FONT_COLOR,this._fontSize=Q.DEFAULT_FONT_SIZE,this._interpolation={},this._localize=!0,this.typeface=null,this.tryMissingTranslationPaint=!1,this.textForDraw="",this.localizedFontNames=[],Le(this,t),this.size.height=this.localizedFontSize??this.fontSize,this.size.width=t.width??NaN,this.saveNodeNewEvent()}get completeNodeOptions(){return{...this.options,...this.getNodeOptions(),...this.getDrawableOptions(),...this.getTextOptions(),width:this.size.width}}initialize(){const t=this.game.i18n;if(this.tryMissingTranslationPaint=!1,t&&this.localize!==!1){const r=t.getTextLocalization(this.text,this.interpolation);this.textForDraw=r.text,this.localizedFontSize=r.fontSize,this.localizedFontName=r.fontName,this.localizedFontNames=r.fontNames??[],r.isFallbackOrMissingTranslation&&(this.tryMissingTranslationPaint=!0)}else this.textForDraw=this.text;const i=this.game.fontManager;if(this.fontForDraw=this.getRequiredTextLineFont(i),this.fontForDraw.status===re.Deferred){i.prepareDeferredFont(this.fontForDraw);return}this.fontForDraw.status!==re.Loading&&(this.createFontPaint(t),this.createFont(i),this.needsInitialization=!1)}getRequiredTextLineFont(t){if(this.game.i18n){if(this.localizedFontName!==void 0&&this.localizedFontNames.length!==0||this.localizedFontNames.length>1)throw new C("TextLine supports only one font, but multiple fonts are specified in translation.");if(this.localizedFontName!==void 0)return t.fonts[this.localizedFontName];if(this.localizedFontNames.length==1)return t.fonts[this.localizedFontNames[0]]}return this.fontName===void 0?t.getDefaultFont():t.getFont(this.fontName)}createFontPaint(t){this.paint&&this.paint.delete(),this.paint=new this.canvasKit.Paint,this.tryMissingTranslationPaint&&this.localize!==!1?t?.missingLocalizationColor&&this.paint.setColor(this.canvasKit.Color(t.missingLocalizationColor[0],t.missingLocalizationColor[1],t.missingLocalizationColor[2],t.missingLocalizationColor[3])):this.paint.setColor(this.canvasKit.Color(this.fontColor[0],this.fontColor[1],this.fontColor[2],this.fontColor[3])),this.paint.setStyle(this.canvasKit.PaintStyle.Fill),this.paint.setAntiAlias(!0)}createFont(t){if(this.fontForDraw)this.typeface=t.getTypeface(this.fontForDraw.fontName);else{const i=t.getFontNames();i.length>0&&(this.typeface=t.getTypeface(i[0]))}this.font&&this.font.delete(),this.font=new this.canvasKit.Font(this.typeface,(this.localizedFontSize??this.fontSize)*m2c2Globals.canvasScale)}get text(){return this._text}set text(t){K.value(this._text,t)||(this._text=t,this.needsInitialization=!0,this.savePropertyChangeEvent("text",t))}get fontName(){return this._fontName}set fontName(t){K.value(this._fontName,t)||(this._fontName=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontName",t))}get fontColor(){return this._fontColor}set fontColor(t){K.value(this._fontColor,t)||(this._fontColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontColor",t))}get fontSize(){return this._fontSize}set fontSize(t){K.value(this._fontSize,t)||(this._fontSize=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontSize",t))}get interpolation(){return this._interpolation}set interpolation(t){K.value(this._interpolation,t)||(this._interpolation=t,Object.freeze(this._interpolation),this.needsInitialization=!0,this.savePropertyChangeEvent("interpolation",t))}get localize(){return this._localize}set localize(t){K.value(this._localize,t)||(this._localize=t,this.needsInitialization=!0,this.savePropertyChangeEvent("localize",t))}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){K.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){K.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){K.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){K.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}dispose(){Nt.Dispose([this.font,this.typeface,this.paint])}duplicate(t){const i=new $i({...this.getNodeOptions(),...this.getDrawableOptions(),...this.getTextOptions(),width:this.size.width,name:t});return this.children.length>0&&(i.children=this.children.map(r=>{const h=r.duplicate();return h.parent=i,h})),i}update(){super.update()}draw(t){if(this.parent&&this.text&&!this.needsInitialization){t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;t.scale(1/i,1/i),V.rotateCanvasForDrawableNode(t,this);const r=this.absolutePosition.x*i,h=(this.absolutePosition.y+this.size.height*this.anchorPoint.y*this.absoluteScale)*i;if(this.paint===void 0||this.font===void 0)throw new C(`in TextLine node ${this}, Paint or Font is undefined.`);this.absoluteAlphaChange!==0&&this.paint.setAlphaf(this.absoluteAlpha),t.drawText(this.textForDraw,r,h,this.paint,this.font),t.restore()}super.drawChildren(t)}warmup(t){const i=this.game.i18n;if(i&&this.localize!==!1){const h=i.getTextLocalization(this.text,this.interpolation);this.localizedFontName=h.fontName,this.localizedFontNames=h.fontNames??[]}if(this.getRequiredTextLineFont(this.game.fontManager).status!==re.Deferred){if(this.initialize(),this.paint===void 0||this.font===void 0)throw new C(`warmup TextLine node ${this.toString()}: Paint or Font is undefined.`);t.drawText(this.text,0,0,this.paint,this.font)}}}class pi extends fe{constructor(t={}){super(t),this.type=dt.Sprite,this.isDrawable=!0,this._anchorPoint={x:.5,y:.5},this._zPosition=0,this._imageName="",Le(this,t),t.imageName!==void 0&&(this.imageName=t.imageName),this.saveNodeNewEvent()}get completeNodeOptions(){return{...this.options,...this.getNodeOptions(),...this.getDrawableOptions(),imageName:this.imageName}}initialize(){if(this.m2Image=this.game.imageManager.getImage(this._imageName),!this.m2Image)throw new C(`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(){Nt.Dispose([this.m2Image?.canvaskitImage,this._paint])}get imageName(){return this._imageName}set imageName(t){K.value(this._imageName,t)||(this._imageName=t,this.needsInitialization=!0)}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){K.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){K.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){K.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){K.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}set paint(t){this._paint=t}get paint(){if(!this._paint)throw new C(`in paint getter: Sprite node ${this.toString()} paint is undefined.`);return this._paint}duplicate(t){const i=new pi({...this.getNodeOptions(),...this.getDrawableOptions(),imageName:this.imageName,name:t});return this.children.length>0&&(i.children=this.children.map(r=>{const h=r.duplicate();return h.parent=i,h})),i}update(){super.update()}draw(t){if(!this.hidden){if(this.m2Image){t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;t.scale(1/i,1/i),V.rotateCanvasForDrawableNode(t,this);const r=(this.absolutePosition.x-this.size.width*this.anchorPoint.x*this.absoluteScale)*i,h=(this.absolutePosition.y-this.size.height*this.anchorPoint.y*this.absoluteScale)*i;if(this.absoluteAlphaChange!==0&&this.paint.setAlphaf(this.absoluteAlpha),this.m2Image.status===ne.Ready&&this.m2Image.canvaskitImage)this.m2Image.isFallback&&this.drawFallbackImageBorder(t),t.drawImage(this.m2Image.canvaskitImage,r,h,this.paint);else if(this.m2Image.status===ne.Deferred&&(console.log(`begin loading lazy image ${this.m2Image.imageName} for Sprite node ${this.toString()}`),this.game.imageManager.prepareDeferredImage(this.m2Image)),this.m2Image.status===ne.Error)throw new C(`error status on image ${this.m2Image.imageName} for Sprite node ${this.toString()}`);t.restore()}super.drawChildren(t)}}warmup(t){if(this.m2Image?.status===ne.Ready){if(this.initialize(),!this.m2Image)throw new C(`in Sprite.warmup(): Sprite node ${this.toString()}: image not loaded.`);if(!this.m2Image.canvaskitImage)throw new C(`in Sprite.warmup(): Sprite node ${this.toString()} image ${this.m2Image.imageName} is undefined.`);t.drawImage(this.m2Image.canvaskitImage,0,0)}this.children.forEach(i=>{i.isDrawable&&i.warmup(t)})}drawFallbackImageBorder(t){const i=this.game.imageManager.missingLocalizationImagePaint;if(!i)return;const r=m2c2Globals.canvasScale/this.absoluteScale,h=this.canvasKit.RRectXY(this.canvasKit.LTRBRect((this.absolutePosition.x-this.anchorPoint.x*this.size.width*this.absoluteScale)*r,(this.absolutePosition.y-this.anchorPoint.y*this.size.height*this.absoluteScale)*r,(this.absolutePosition.x+this.size.width*this.absoluteScale-this.anchorPoint.x*this.size.width*this.absoluteScale)*r,(this.absolutePosition.y+this.size.height*this.absoluteScale-this.anchorPoint.y*this.size.height*this.absoluteScale)*r),0,0);t.drawRRect(h,i)}}class Gr{constructor(){V.registerM2NodeClass(Ui,fi,pi,Ve,$i)}createNode(t,i,r){const h=i||t;if(!this.hasClassRegistration(h))throw new C(`Unknown node type: ${h}`);if(!m2c2Globals.m2NodeClassRegistry)throw new C("Node class registry is not initialized.");const c=m2c2Globals.m2NodeClassRegistry[h];return new c(r)}hasClassRegistration(t){return Object.keys(m2c2Globals.m2NodeClassRegistry??{}).includes(t)}}class pa{static rgbaColor(t,i){return!t||!i?!1:t[0]===i[0]&&t[1]===i[1]&&t[2]===i[2]&&t[3]===i[3]}}class Wr{constructor(t,i){this.fonts={},this.game=t,this.baseUrls=i,this.canvasKit=t.canvasKit,this.provider=this.canvasKit.TypefaceFontProvider.Make()}initializeFonts(t){return this.loadFonts(t??[])}async loadFonts(t){if(t.length===0)return;const i=t.map((r,h)=>{let c=r.url;V.urlHasScheme(r.url)||(c=V.getUrlFromManifest(this.game,`${this.baseUrls.assets}/${r.url}`));const S={fontName:r.fontName,typeface:void 0,data:r.sharedFont?.data,default:h===0,url:r.sharedFont?.url??c,status:r.lazy?re.Deferred:re.Loading};if(this.fonts[r.fontName]=S,S.status===re.Loading)return this.prepareFont(S)});await Promise.all(i)}async prepareFont(t){const i=t.data??await this.fetchFontAsArrayBuffer(t);this.registerFont(i,t),console.log(`\u26AA font ${t.fontName}${t.default?" (default)":""} loaded for game ${this.game.id} from ${t.url}`)}async prepareDeferredFont(t){return t.status=re.Loading,this.prepareFont(t)}async fetchFontAsArrayBuffer(t){const i=await fetch(t.url);if(!i.ok)throw new C(`cannot fetch font ${t.fontName} at url ${t.url}: ${i.statusText}`);return await i.arrayBuffer()}registerFont(t,i){this.provider.registerFont(t,i.fontName);const r=this.canvasKit.Typeface.MakeFreeTypeFaceFromData(t);if(!r)throw new C(`cannot make typeface for font ${i.fontName} at url ${i.url}`);i.typeface=r,i.status=re.Ready}getFont(t){return this.fonts[t]}getDefaultFont(){const t=Object.values(this.fonts).find(i=>i.default);if(!t)throw new C("no default font found; please make sure at least one font is loaded");return t}dispose(){const t=Object.entries(this.fonts).map(([,i])=>i.typeface);Nt.Dispose([...t,this.provider])}getTypeface(t){const i=this.fonts[t]?.typeface;if(!i)throw new C(`font ${t} not found`);return i}getFontNames(){return Object.keys(this.fonts)}}var gn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ga(m){return m&&m.__esModule&&Object.prototype.hasOwnProperty.call(m,"default")?m.default:m}function jr(m){if(Object.prototype.hasOwnProperty.call(m,"__esModule"))return m;var t=m.default;if(typeof t=="function"){var i=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};i.prototype=t.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(m).forEach(function(r){var h=Object.getOwnPropertyDescriptor(m,r);Object.defineProperty(i,r,h.get?h:{enumerable:!0,get:function(){return m[r]}})}),i}var mn={exports:{}},ma={},ya=Object.freeze({__proto__:null,default:ma}),va=jr(ya);function Hr(m,t){for(var i=0,r=m.length-1;r>=0;r--){var h=m[r];h==="."?m.splice(r,1):h===".."?(m.splice(r,1),i++):i&&(m.splice(r,1),i--)}if(t)for(;i--;i)m.unshift("..");return m}var wa=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,yn=function(m){return wa.exec(m).slice(1)};function Li(){for(var m="",t=!1,i=arguments.length-1;i>=-1&&!t;i--){var r=i>=0?arguments[i]:"/";if(typeof r!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!r)continue;m=r+"/"+m,t=r.charAt(0)==="/"}return m=Hr(Sn(m.split("/"),function(h){return!!h}),!t).join("/"),(t?"/":"")+m||"."}function vn(m){var t=wn(m),i=ba(m,-1)==="/";return m=Hr(Sn(m.split("/"),function(r){return!!r}),!t).join("/"),!m&&!t&&(m="."),m&&i&&(m+="/"),(t?"/":"")+m}function wn(m){return m.charAt(0)==="/"}function Kr(){var m=Array.prototype.slice.call(arguments,0);return vn(Sn(m,function(t,i){if(typeof t!="string")throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))}function Vr(m,t){m=Li(m).substr(1),t=Li(t).substr(1);function i(G){for(var q=0;q<G.length&&G[q]==="";q++);for(var st=G.length-1;st>=0&&G[st]==="";st--);return q>st?[]:G.slice(q,st-q+1)}for(var r=i(m.split("/")),h=i(t.split("/")),c=Math.min(r.length,h.length),S=c,x=0;x<c;x++)if(r[x]!==h[x]){S=x;break}for(var z=[],x=S;x<r.length;x++)z.push("..");return z=z.concat(h.slice(S)),z.join("/")}var qr="/",Yr=":";function Xr(m){var t=yn(m),i=t[0],r=t[1];return!i&&!r?".":(r&&(r=r.substr(0,r.length-1)),i+r)}function Jr(m,t){var i=yn(m)[2];return t&&i.substr(-1*t.length)===t&&(i=i.substr(0,i.length-t.length)),i}function Qr(m){return yn(m)[3]}var Sa={extname:Qr,basename:Jr,dirname:Xr,sep:qr,delimiter:Yr,relative:Vr,join:Kr,isAbsolute:wn,normalize:vn,resolve:Li};function Sn(m,t){if(m.filter)return m.filter(t);for(var i=[],r=0;r<m.length;r++)t(m[r],r,m)&&i.push(m[r]);return i}var ba="ab".substr(-1)==="b"?function(m,t,i){return m.substr(t,i)}:function(m,t,i){return t<0&&(t=m.length+t),m.substr(t,i)},Pa=Object.freeze({__proto__:null,basename:Jr,default:Sa,delimiter:Yr,dirname:Xr,extname:Qr,isAbsolute:wn,join:Kr,normalize:vn,relative:Vr,resolve:Li,sep:qr}),Aa=jr(Pa),Zr;function Ca(){return Zr||(Zr=1,function(m,t){var i=(()=>{var r=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<"u"&&(r=r||__filename),function(h={}){var c=h,S,x;c.ready=new Promise((e,n)=>{S=e,x=n}),function(e){e.ke=e.ke||[],e.ke.push(function(){e.MakeSWCanvasSurface=function(n){var s=n,l=typeof OffscreenCanvas<"u"&&s instanceof OffscreenCanvas;if(!(typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||l||(s=document.getElementById(n),s)))throw"Canvas with id "+n+" was not found";return(n=e.MakeSurface(s.width,s.height))&&(n.ce=s),n},e.MakeCanvasSurface||(e.MakeCanvasSurface=e.MakeSWCanvasSurface),e.MakeSurface=function(n,s){var l={width:n,height:s,colorType:e.ColorType.RGBA_8888,alphaType:e.AlphaType.Unpremul,colorSpace:e.ColorSpace.SRGB},d=n*s*4,g=e._malloc(d);return(l=e.Surface._makeRasterDirect(l,g,4*n))&&(l.ce=null,l.Xf=n,l.Tf=s,l.Vf=d,l.wf=g,l.getCanvas().clear(e.TRANSPARENT)),l},e.MakeRasterDirectSurface=function(n,s,l){return e.Surface._makeRasterDirect(n,s.byteOffset,l)},e.Surface.prototype.flush=function(n){if(e.de(this.be),this._flush(),this.ce){var s=new Uint8ClampedArray(e.HEAPU8.buffer,this.wf,this.Vf);s=new ImageData(s,this.Xf,this.Tf),n?this.ce.getContext("2d").putImageData(s,0,0,n[0],n[1],n[2]-n[0],n[3]-n[1]):this.ce.getContext("2d").putImageData(s,0,0)}},e.Surface.prototype.dispose=function(){this.wf&&e._free(this.wf),this.delete()},e.de=e.de||function(){},e.mf=e.mf||function(){return null}})}(c),function(e){e.ke=e.ke||[],e.ke.push(function(){function n(y,v,T){return y&&y.hasOwnProperty(v)?y[v]:T}function s(y){var v=Ne(ee);return ee[v]=y,v}function l(y){return y.naturalHeight||y.videoHeight||y.displayHeight||y.height}function d(y){return y.naturalWidth||y.videoWidth||y.displayWidth||y.width}function g(y,v,T,O){return y.bindTexture(y.TEXTURE_2D,v),O||T.alphaType!==e.AlphaType.Premul||y.pixelStorei(y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),v}function A(y,v,T){T||v.alphaType!==e.AlphaType.Premul||y.pixelStorei(y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),y.bindTexture(y.TEXTURE_2D,null)}e.GetWebGLContext=function(y,v){if(!y)throw"null canvas passed into makeWebGLContext";var T={alpha:n(v,"alpha",1),depth:n(v,"depth",1),stencil:n(v,"stencil",8),antialias:n(v,"antialias",0),premultipliedAlpha:n(v,"premultipliedAlpha",1),preserveDrawingBuffer:n(v,"preserveDrawingBuffer",0),preferLowPowerToHighPerformance:n(v,"preferLowPowerToHighPerformance",0),failIfMajorPerformanceCaveat:n(v,"failIfMajorPerformanceCaveat",0),enableExtensionsByDefault:n(v,"enableExtensionsByDefault",1),explicitSwapControl:n(v,"explicitSwapControl",0),renderViaOffscreenBackBuffer:n(v,"renderViaOffscreenBackBuffer",0)};if(T.majorVersion=v&&v.majorVersion?v.majorVersion:typeof WebGL2RenderingContext<"u"?2:1,T.explicitSwapControl)throw"explicitSwapControl is not supported";return y=Is(y,T),y?(tr(y),at.xe.getExtension("WEBGL_debug_renderer_info"),y):0},e.deleteContext=function(y){at===ye[y]&&(at=null),typeof JSEvents=="object"&&JSEvents.Mg(ye[y].xe.canvas),ye[y]&&ye[y].xe.canvas&&(ye[y].xe.canvas.Rf=void 0),ye[y]=null},e._setTextureCleanup({deleteTexture:function(y,v){var T=ee[v];T&&ye[y].xe.deleteTexture(T),ee[v]=null}}),e.MakeWebGLContext=function(y){if(!this.de(y))return null;var v=this._MakeGrContext();if(!v)return null;v.be=y;var T=v.delete.bind(v);return v.delete=function(){e.de(this.be),T()}.bind(v),at.Af=v},e.MakeGrContext=e.MakeWebGLContext,e.GrDirectContext.prototype.getResourceCacheLimitBytes=function(){e.de(this.be),this._getResourceCacheLimitBytes()},e.GrDirectContext.prototype.getResourceCacheUsageBytes=function(){e.de(this.be),this._getResourceCacheUsageBytes()},e.GrDirectContext.prototype.releaseResourcesAndAbandonContext=function(){e.de(this.be),this._releaseResourcesAndAbandonContext()},e.GrDirectContext.prototype.setResourceCacheLimitBytes=function(y){e.de(this.be),this._setResourceCacheLimitBytes(y)},e.MakeOnScreenGLSurface=function(y,v,T,O,L,Y){return!this.de(y.be)||(v=L===void 0||Y===void 0?this._MakeOnScreenGLSurface(y,v,T,O):this._MakeOnScreenGLSurface(y,v,T,O,L,Y),!v)?null:(v.be=y.be,v)},e.MakeRenderTarget=function(){var y=arguments[0];if(!this.de(y.be))return null;if(arguments.length===3){var v=this._MakeRenderTargetWH(y,arguments[1],arguments[2]);if(!v)return null}else if(arguments.length===2){if(v=this._MakeRenderTargetII(y,arguments[1]),!v)return null}else return null;return v.be=y.be,v},e.MakeWebGLCanvasSurface=function(y,v,T){v=v||null;var O=y,L=typeof OffscreenCanvas<"u"&&O instanceof OffscreenCanvas;if(!(typeof HTMLCanvasElement<"u"&&O instanceof HTMLCanvasElement||L||(O=document.getElementById(y),O)))throw"Canvas with id "+y+" was not found";if(y=this.GetWebGLContext(O,T),!y||0>y)throw"failed to create webgl context: err "+y;return y=this.MakeWebGLContext(y),v=this.MakeOnScreenGLSurface(y,O.width,O.height,v),v||(v=O.cloneNode(!0),O.parentNode.replaceChild(v,O),v.classList.add("ck-replaced"),e.MakeSWCanvasSurface(v))},e.MakeCanvasSurface=e.MakeWebGLCanvasSurface,e.Surface.prototype.makeImageFromTexture=function(y,v){return e.de(this.be),y=s(y),(v=this._makeImageFromTexture(this.be,y,v))&&(v.cf=y),v},e.Surface.prototype.makeImageFromTextureSource=function(y,v,T){v||(v={height:l(y),width:d(y),colorType:e.ColorType.RGBA_8888,alphaType:T?e.AlphaType.Premul:e.AlphaType.Unpremul}),v.colorSpace||(v.colorSpace=e.ColorSpace.SRGB),e.de(this.be);var O=at.xe;return T=g(O,O.createTexture(),v,T),at.version===2?O.texImage2D(O.TEXTURE_2D,0,O.RGBA,v.width,v.height,0,O.RGBA,O.UNSIGNED_BYTE,y):O.texImage2D(O.TEXTURE_2D,0,O.RGBA,O.RGBA,O.UNSIGNED_BYTE,y),A(O,v),this._resetContext(),this.makeImageFromTexture(T,v)},e.Surface.prototype.updateTextureFromSource=function(y,v,T){if(y.cf){e.de(this.be);var O=y.getImageInfo(),L=at.xe,Y=g(L,ee[y.cf],O,T);at.version===2?L.texImage2D(L.TEXTURE_2D,0,L.RGBA,d(v),l(v),0,L.RGBA,L.UNSIGNED_BYTE,v):L.texImage2D(L.TEXTURE_2D,0,L.RGBA,L.RGBA,L.UNSIGNED_BYTE,v),A(L,O,T),this._resetContext(),ee[y.cf]=null,y.cf=s(Y),O.colorSpace=y.getColorSpace(),v=this._makeImageFromTexture(this.be,y.cf,O),T=y.ae.ie,L=y.ae.pe,y.ae.ie=v.ae.ie,y.ae.pe=v.ae.pe,v.ae.ie=T,v.ae.pe=L,v.delete(),O.colorSpace.delete()}},e.MakeLazyImageFromTextureSource=function(y,v,T){v||(v={height:l(y),width:d(y),colorType:e.ColorType.RGBA_8888,alphaType:T?e.AlphaType.Premul:e.AlphaType.Unpremul}),v.colorSpace||(v.colorSpace=e.ColorSpace.SRGB);var O={makeTexture:function(){var L=at,Y=L.xe,F=g(Y,Y.createTexture(),v,T);return L.version===2?Y.texImage2D(Y.TEXTURE_2D,0,Y.RGBA,v.width,v.height,0,Y.RGBA,Y.UNSIGNED_BYTE,y):Y.texImage2D(Y.TEXTURE_2D,0,Y.RGBA,Y.RGBA,Y.UNSIGNED_BYTE,y),A(Y,v,T),s(F)},freeSrc:function(){}};return y.constructor.name==="VideoFrame"&&(O.freeSrc=function(){y.close()}),e.Image._makeFromGenerator(v,O)},e.de=function(y){return y?tr(y):!1},e.mf=function(){return at&&at.Af&&!at.Af.isDeleted()?at.Af:null}})}(c),function(e){function n(o,a,u,p,P){for(var E=0;E<o.length;E++)a[E*u+(E*P+p+u)%u]=o[E];return a}function s(o){for(var a=o*o,u=Array(a);a--;)u[a]=a%(o+1)===0?1:0;return u}function l(o){return o?o.constructor===Float32Array&&o.length===4:!1}function d(o){return(y(255*o[3])<<24|y(255*o[0])<<16|y(255*o[1])<<8|y(255*o[2])<<0)>>>0}function g(o){if(o&&o._ck)return o;if(o instanceof Float32Array){for(var a=Math.floor(o.length/4),u=new Uint32Array(a),p=0;p<a;p++)u[p]=d(o.slice(4*p,4*(p+1)));return u}if(o instanceof Uint32Array)return o;if(o instanceof Array&&o[0]instanceof Float32Array)return o.map(d)}function A(o){if(o===void 0)return 1;var a=parseFloat(o);return o&&o.indexOf("%")!==-1?a/100:a}function y(o){return Math.round(Math.max(0,Math.min(o||0,255)))}function v(o,a){a&&a._ck||e._free(o)}function T(o,a,u){if(!o||!o.length)return gt;if(o&&o._ck)return o.byteOffset;var p=e[a].BYTES_PER_ELEMENT;return u||(u=e._malloc(o.length*p)),e[a].set(o,u/p),u}function O(o){var a={te:gt,count:o.length,colorType:e.ColorType.RGBA_F32};if(o instanceof Float32Array)a.te=T(o,"HEAPF32"),a.count=o.length/4;else if(o instanceof Uint32Array)a.te=T(o,"HEAPU32"),a.colorType=e.ColorType.RGBA_8888;else if(o instanceof Array){if(o&&o.length){for(var u=e._malloc(16*o.length),p=0,P=u/4,E=0;E<o.length;E++)for(var N=0;4>N;N++)e.HEAPF32[P+p]=o[E][N],p++;o=u}else o=gt;a.te=o}else throw"Invalid argument to copyFlexibleColorArray, Not a color array "+typeof o;return a}function L(o){if(!o)return gt;var a=rn.toTypedArray();if(o.length){if(o.length===6||o.length===9)return T(o,"HEAPF32",_e),o.length===6&&e.HEAPF32.set(aa,6+_e/4),_e;if(o.length===16)return a[0]=o[0],a[1]=o[1],a[2]=o[3],a[3]=o[4],a[4]=o[5],a[5]=o[7],a[6]=o[12],a[7]=o[13],a[8]=o[15],_e;throw"invalid matrix size"}if(o.m11===void 0)throw"invalid matrix argument";return a[0]=o.m11,a[1]=o.m21,a[2]=o.m41,a[3]=o.m12,a[4]=o.m22,a[5]=o.m42,a[6]=o.m14,a[7]=o.m24,a[8]=o.m44,_e}function Y(o){if(!o)return gt;var a=sn.toTypedArray();if(o.length){if(o.length!==16&&o.length!==6&&o.length!==9)throw"invalid matrix size";return o.length===16?T(o,"HEAPF32",We):(a.fill(0),a[0]=o[0],a[1]=o[1],a[3]=o[2],a[4]=o[3],a[5]=o[4],a[7]=o[5],a[10]=1,a[12]=o[6],a[13]=o[7],a[15]=o[8],o.length===6&&(a[12]=0,a[13]=0,a[15]=1),We)}if(o.m11===void 0)throw"invalid matrix argument";return a[0]=o.m11,a[1]=o.m21,a[2]=o.m31,a[3]=o.m41,a[4]=o.m12,a[5]=o.m22,a[6]=o.m32,a[7]=o.m42,a[8]=o.m13,a[9]=o.m23,a[10]=o.m33,a[11]=o.m43,a[12]=o.m14,a[13]=o.m24,a[14]=o.m34,a[15]=o.m44,We}function F(o,a){return T(o,"HEAPF32",a||Oe)}function J(o,a,u,p){var P=an.toTypedArray();return P[0]=o,P[1]=a,P[2]=u,P[3]=p,Oe}function ht(o){for(var a=new Float32Array(4),u=0;4>u;u++)a[u]=e.HEAPF32[o/4+u];return a}function ot(o,a){return T(o,"HEAPF32",a||Rt)}function Ht(o,a){return T(o,"HEAPF32",a||hn)}function Lt(){for(var o=0,a=0;a<arguments.length-1;a+=2)o+=arguments[a]*arguments[a+1];return o}function ai(o,a,u){for(var p=Array(o.length),P=0;P<u;P++)for(var E=0;E<u;E++){for(var N=0,j=0;j<u;j++)N+=o[u*P+j]*a[u*j+E];p[P*u+E]=N}return p}function oi(o,a){for(var u=ai(a[0],a[1],o),p=2;p<a.length;)u=ai(u,a[p],o),p++;return u}e.Color=function(o,a,u,p){return p===void 0&&(p=1),e.Color4f(y(o)/255,y(a)/255,y(u)/255,p)},e.ColorAsInt=function(o,a,u,p){return p===void 0&&(p=255),(y(p)<<24|y(o)<<16|y(a)<<8|y(u)<<0&268435455)>>>0},e.Color4f=function(o,a,u,p){return p===void 0&&(p=1),Float32Array.of(o,a,u,p)},Object.defineProperty(e,"TRANSPARENT",{get:function(){return e.Color4f(0,0,0,0)}}),Object.defineProperty(e,"BLACK",{get:function(){return e.Color4f(0,0,0,1)}}),Object.defineProperty(e,"WHITE",{get:function(){return e.Color4f(1,1,1,1)}}),Object.defineProperty(e,"RED",{get:function(){return e.Color4f(1,0,0,1)}}),Object.defineProperty(e,"GREEN",{get:function(){return e.Color4f(0,1,0,1)}}),Object.defineProperty(e,"BLUE",{get:function(){return e.Color4f(0,0,1,1)}}),Object.defineProperty(e,"YELLOW",{get:function(){return e.Color4f(1,1,0,1)}}),Object.defineProperty(e,"CYAN",{get:function(){return e.Color4f(0,1,1,1)}}),Object.defineProperty(e,"MAGENTA",{get:function(){return e.Color4f(1,0,1,1)}}),e.getColorComponents=function(o){return[Math.floor(255*o[0]),Math.floor(255*o[1]),Math.floor(255*o[2]),o[3]]},e.parseColorString=function(o,a){if(o=o.toLowerCase(),o.startsWith("#")){switch(a=255,o.length){case 9:a=parseInt(o.slice(7,9),16);case 7:var u=parseInt(o.slice(1,3),16),p=parseInt(o.slice(3,5),16),P=parseInt(o.slice(5,7),16);break;case 5:a=17*parseInt(o.slice(4,5),16);case 4:u=17*parseInt(o.slice(1,2),16),p=17*parseInt(o.slice(2,3),16),P=17*parseInt(o.slice(3,4),16)}return e.Color(u,p,P,a/255)}return o.startsWith("rgba")?(o=o.slice(5,-1),o=o.split(","),e.Color(+o[0],+o[1],+o[2],A(o[3]))):o.startsWith("rgb")?(o=o.slice(4,-1),o=o.split(","),e.Color(+o[0],+o[1],+o[2],A(o[3]))):o.startsWith("gray(")||o.startsWith("hsl")||!a||(o=a[o],o===void 0)?e.BLACK:o},e.multiplyByAlpha=function(o,a){return o=o.slice(),o[3]=Math.max(0,Math.min(o[3]*a,1)),o},e.Malloc=function(o,a){var u=e._malloc(a*o.BYTES_PER_ELEMENT);return{_ck:!0,length:a,byteOffset:u,Je:null,subarray:function(p,P){return p=this.toTypedArray().subarray(p,P),p._ck=!0,p},toTypedArray:function(){return this.Je&&this.Je.length?this.Je:(this.Je=new o(e.HEAPU8.buffer,u,a),this.Je._ck=!0,this.Je)}}},e.Free=function(o){e._free(o.byteOffset),o.byteOffset=gt,o.toTypedArray=null,o.Je=null};var _e=gt,rn,We=gt,sn,Oe=gt,an,ue,Rt=gt,Pr,Ee=gt,Ar,on=gt,Cr,ln=gt,Oi,li=gt,Tr,hn=gt,_r,Er=gt,aa=Float32Array.of(0,0,1),gt=0;e.onRuntimeInitialized=function(){function o(a,u,p,P,E,N,j){N||(N=4*P.width,P.colorType===e.ColorType.RGBA_F16?N*=2:P.colorType===e.ColorType.RGBA_F32&&(N*=4));var tt=N*P.height,et=E?E.byteOffset:e._malloc(tt);if(j?!a._readPixels(P,et,N,u,p,j):!a._readPixels(P,et,N,u,p))return E||e._free(et),null;if(E)return E.toTypedArray();switch(P.colorType){case e.ColorType.RGBA_8888:case e.ColorType.RGBA_F16:a=new Uint8Array(e.HEAPU8.buffer,et,tt).slice();break;case e.ColorType.RGBA_F32:a=new Float32Array(e.HEAPU8.buffer,et,tt).slice();break;default:return null}return e._free(et),a}an=e.Malloc(Float32Array,4),Oe=an.byteOffset,sn=e.Malloc(Float32Array,16),We=sn.byteOffset,rn=e.Malloc(Float32Array,9),_e=rn.byteOffset,Tr=e.Malloc(Float32Array,12),hn=Tr.byteOffset,_r=e.Malloc(Float32Array,12),Er=_r.byteOffset,ue=e.Malloc(Float32Array,4),Rt=ue.byteOffset,Pr=e.Malloc(Float32Array,4),Ee=Pr.byteOffset,Ar=e.Malloc(Float32Array,3),on=Ar.byteOffset,Cr=e.Malloc(Float32Array,3),ln=Cr.byteOffset,Oi=e.Malloc(Int32Array,4),li=Oi.byteOffset,e.ColorSpace.SRGB=e.ColorSpace._MakeSRGB(),e.ColorSpace.DISPLAY_P3=e.ColorSpace._MakeDisplayP3(),e.ColorSpace.ADOBE_RGB=e.ColorSpace._MakeAdobeRGB(),e.GlyphRunFlags={IsWhiteSpace:e._GlyphRunFlags_isWhiteSpace},e.Path.MakeFromCmds=function(a){var u=T(a,"HEAPF32"),p=e.Path._MakeFromCmds(u,a.length);return v(u,a),p},e.Path.MakeFromVerbsPointsWeights=function(a,u,p){var P=T(a,"HEAPU8"),E=T(u,"HEAPF32"),N=T(p,"HEAPF32"),j=e.Path._MakeFromVerbsPointsWeights(P,a.length,E,u.length,N,p&&p.length||0);return v(P,a),v(E,u),v(N,p),j},e.Path.prototype.addArc=function(a,u,p){return a=ot(a),this._addArc(a,u,p),this},e.Path.prototype.addCircle=function(a,u,p,P){return this._addCircle(a,u,p,!!P),this},e.Path.prototype.addOval=function(a,u,p){return p===void 0&&(p=1),a=ot(a),this._addOval(a,!!u,p),this},e.Path.prototype.addPath=function(){var a=Array.prototype.slice.call(arguments),u=a[0],p=!1;if(typeof a[a.length-1]=="boolean"&&(p=a.pop()),a.length===1)this._addPath(u,1,0,0,0,1,0,0,0,1,p);else if(a.length===2)a=a[1],this._addPath(u,a[0],a[1],a[2],a[3],a[4],a[5],a[6]||0,a[7]||0,a[8]||1,p);else if(a.length===7||a.length===10)this._addPath(u,a[1],a[2],a[3],a[4],a[5],a[6],a[7]||0,a[8]||0,a[9]||1,p);else return null;return this},e.Path.prototype.addPoly=function(a,u){var p=T(a,"HEAPF32");return this._addPoly(p,a.length/2,u),v(p,a),this},e.Path.prototype.addRect=function(a,u){return a=ot(a),this._addRect(a,!!u),this},e.Path.prototype.addRRect=function(a,u){return a=Ht(a),this._addRRect(a,!!u),this},e.Path.prototype.addVerbsPointsWeights=function(a,u,p){var P=T(a,"HEAPU8"),E=T(u,"HEAPF32"),N=T(p,"HEAPF32");this._addVerbsPointsWeights(P,a.length,E,u.length,N,p&&p.length||0),v(P,a),v(E,u),v(N,p)},e.Path.prototype.arc=function(a,u,p,P,E,N){return a=e.LTRBRect(a-p,u-p,a+p,u+p),E=(E-P)/Math.PI*180-360*!!N,N=new e.Path,N.addArc(a,P/Math.PI*180,E),this.addPath(N,!0),N.delete(),this},e.Path.prototype.arcToOval=function(a,u,p,P){return a=ot(a),this._arcToOval(a,u,p,P),this},e.Path.prototype.arcToRotated=function(a,u,p,P,E,N,j){return this._arcToRotated(a,u,p,!!P,!!E,N,j),this},e.Path.prototype.arcToTangent=function(a,u,p,P,E){return this._arcToTangent(a,u,p,P,E),this},e.Path.prototype.close=function(){return this._close(),this},e.Path.prototype.conicTo=function(a,u,p,P,E){return this._conicTo(a,u,p,P,E),this},e.Path.prototype.computeTightBounds=function(a){this._computeTightBounds(Rt);var u=ue.toTypedArray();return a?(a.set(u),a):u.slice()},e.Path.prototype.cubicTo=function(a,u,p,P,E,N){return this._cubicTo(a,u,p,P,E,N),this},e.Path.prototype.dash=function(a,u,p){return this._dash(a,u,p)?this:null},e.Path.prototype.getBounds=function(a){this._getBounds(Rt);var u=ue.toTypedArray();return a?(a.set(u),a):u.slice()},e.Path.prototype.lineTo=function(a,u){return this._lineTo(a,u),this},e.Path.prototype.moveTo=function(a,u){return this._moveTo(a,u),this},e.Path.prototype.offset=function(a,u){return this._transform(1,0,a,0,1,u,0,0,1),this},e.Path.prototype.quadTo=function(a,u,p,P){return this._quadTo(a,u,p,P),this},e.Path.prototype.rArcTo=function(a,u,p,P,E,N,j){return this._rArcTo(a,u,p,P,E,N,j),this},e.Path.prototype.rConicTo=function(a,u,p,P,E){return this._rConicTo(a,u,p,P,E),this},e.Path.prototype.rCubicTo=function(a,u,p,P,E,N){return this._rCubicTo(a,u,p,P,E,N),this},e.Path.prototype.rLineTo=function(a,u){return this._rLineTo(a,u),this},e.Path.prototype.rMoveTo=function(a,u){return this._rMoveTo(a,u),this},e.Path.prototype.rQuadTo=function(a,u,p,P){return this._rQuadTo(a,u,p,P),this},e.Path.prototype.stroke=function(a){return a=a||{},a.width=a.width||1,a.miter_limit=a.miter_limit||4,a.cap=a.cap||e.StrokeCap.Butt,a.join=a.join||e.StrokeJoin.Miter,a.precision=a.precision||1,this._stroke(a)?this:null},e.Path.prototype.transform=function(){if(arguments.length===1){var a=arguments[0];this._transform(a[0],a[1],a[2],a[3],a[4],a[5],a[6]||0,a[7]||0,a[8]||1)}else if(arguments.length===6||arguments.length===9)a=arguments,this._transform(a[0],a[1],a[2],a[3],a[4],a[5],a[6]||0,a[7]||0,a[8]||1);else throw"transform expected to take 1 or 9 arguments. Got "+arguments.length;return this},e.Path.prototype.trim=function(a,u,p){return this._trim(a,u,!!p)?this:null},e.Image.prototype.encodeToBytes=function(a,u){var p=e.mf();return a=a||e.ImageFormat.PNG,u=u||100,p?this._encodeToBytes(a,u,p):this._encodeToBytes(a,u)},e.Image.prototype.makeShaderCubic=function(a,u,p,P,E){return E=L(E),this._makeShaderCubic(a,u,p,P,E)},e.Image.prototype.makeShaderOptions=function(a,u,p,P,E){return E=L(E),this._makeShaderOptions(a,u,p,P,E)},e.Image.prototype.readPixels=function(a,u,p,P,E){var N=e.mf();return o(this,a,u,p,P,E,N)},e.Canvas.prototype.clear=function(a){e.de(this.be),a=F(a),this._clear(a)},e.Canvas.prototype.clipRRect=function(a,u,p){e.de(this.be),a=Ht(a),this._clipRRect(a,u,p)},e.Canvas.prototype.clipRect=function(a,u,p){e.de(this.be),a=ot(a),this._clipRect(a,u,p)},e.Canvas.prototype.concat=function(a){e.de(this.be),a=Y(a),this._concat(a)},e.Canvas.prototype.drawArc=function(a,u,p,P,E){e.de(this.be),a=ot(a),this._drawArc(a,u,p,P,E)},e.Canvas.prototype.drawAtlas=function(a,u,p,P,E,N,j){if(a&&P&&u&&p&&u.length===p.length){e.de(this.be),E||(E=e.BlendMode.SrcOver);var tt=T(u,"HEAPF32"),et=T(p,"HEAPF32"),vt=p.length/4,bt=T(g(N),"HEAPU32");if(j&&"B"in j&&"C"in j)this._drawAtlasCubic(a,et,tt,bt,vt,E,j.B,j.C,P);else{let b=e.FilterMode.Linear,I=e.MipmapMode.None;j&&(b=j.filter,"mipmap"in j&&(I=j.mipmap)),this._drawAtlasOptions(a,et,tt,bt,vt,E,b,I,P)}v(tt,u),v(et,p),v(bt,N)}},e.Canvas.prototype.drawCircle=function(a,u,p,P){e.de(this.be),this._drawCircle(a,u,p,P)},e.Canvas.prototype.drawColor=function(a,u){e.de(this.be),a=F(a),u!==void 0?this._drawColor(a,u):this._drawColor(a)},e.Canvas.prototype.drawColorInt=function(a,u){e.de(this.be),this._drawColorInt(a,u||e.BlendMode.SrcOver)},e.Canvas.prototype.drawColorComponents=function(a,u,p,P,E){e.de(this.be),a=J(a,u,p,P),E!==void 0?this._drawColor(a,E):this._drawColor(a)},e.Canvas.prototype.drawDRRect=function(a,u,p){e.de(this.be),a=Ht(a,hn),u=Ht(u,Er),this._drawDRRect(a,u,p)},e.Canvas.prototype.drawImage=function(a,u,p,P){e.de(this.be),this._drawImage(a,u,p,P||null)},e.Canvas.prototype.drawImageCubic=function(a,u,p,P,E,N){e.de(this.be),this._drawImageCubic(a,u,p,P,E,N||null)},e.Canvas.prototype.drawImageOptions=function(a,u,p,P,E,N){e.de(this.be),this._drawImageOptions(a,u,p,P,E,N||null)},e.Canvas.prototype.drawImageNine=function(a,u,p,P,E){e.de(this.be),u=T(u,"HEAP32",li),p=ot(p),this._drawImageNine(a,u,p,P,E||null)},e.Canvas.prototype.drawImageRect=function(a,u,p,P,E){e.de(this.be),ot(u,Rt),ot(p,Ee),this._drawImageRect(a,Rt,Ee,P,!!E)},e.Canvas.prototype.drawImageRectCubic=function(a,u,p,P,E,N){e.de(this.be),ot(u,Rt),ot(p,Ee),this._drawImageRectCubic(a,Rt,Ee,P,E,N||null)},e.Canvas.prototype.drawImageRectOptions=function(a,u,p,P,E,N){e.de(this.be),ot(u,Rt),ot(p,Ee),this._drawImageRectOptions(a,Rt,Ee,P,E,N||null)},e.Canvas.prototype.drawLine=function(a,u,p,P,E){e.de(this.be),this._drawLine(a,u,p,P,E)},e.Canvas.prototype.drawOval=function(a,u){e.de(this.be),a=ot(a),this._drawOval(a,u)},e.Canvas.prototype.drawPaint=function(a){e.de(this.be),this._drawPaint(a)},e.Canvas.prototype.drawParagraph=function(a,u,p){e.de(this.be),this._drawParagraph(a,u,p)},e.Canvas.prototype.drawPatch=function(a,u,p,P,E){if(24>a.length)throw"Need 12 cubic points";if(u&&4>u.length)throw"Need 4 colors";if(p&&8>p.length)throw"Need 4 shader coordinates";e.de(this.be);const N=T(a,"HEAPF32"),j=u?T(g(u),"HEAPU32"):gt,tt=p?T(p,"HEAPF32"):gt;P||(P=e.BlendMode.Modulate),this._drawPatch(N,j,tt,P,E),v(tt,p),v(j,u),v(N,a)},e.Canvas.prototype.drawPath=function(a,u){e.de(this.be),this._drawPath(a,u)},e.Canvas.prototype.drawPicture=function(a){e.de(this.be),this._drawPicture(a)},e.Canvas.prototype.drawPoints=function(a,u,p){e.de(this.be);var P=T(u,"HEAPF32");this._drawPoints(a,P,u.length/2,p),v(P,u)},e.Canvas.prototype.drawRRect=function(a,u){e.de(this.be),a=Ht(a),this._drawRRect(a,u)},e.Canvas.prototype.drawRect=function(a,u){e.de(this.be),a=ot(a),this._drawRect(a,u)},e.Canvas.prototype.drawRect4f=function(a,u,p,P,E){e.de(this.be),this._drawRect4f(a,u,p,P,E)},e.Canvas.prototype.drawShadow=function(a,u,p,P,E,N,j){e.de(this.be);var tt=T(E,"HEAPF32"),et=T(N,"HEAPF32");u=T(u,"HEAPF32",on),p=T(p,"HEAPF32",ln),this._drawShadow(a,u,p,P,tt,et,j),v(tt,E),v(et,N)},e.getShadowLocalBounds=function(a,u,p,P,E,N,j){return a=L(a),p=T(p,"HEAPF32",on),P=T(P,"HEAPF32",ln),this._getShadowLocalBounds(a,u,p,P,E,N,Rt)?(u=ue.toTypedArray(),j?(j.set(u),j):u.slice()):null},e.Canvas.prototype.drawTextBlob=function(a,u,p,P){e.de(this.be),this._drawTextBlob(a,u,p,P)},e.Canvas.prototype.drawVertices=function(a,u,p){e.de(this.be),this._drawVertices(a,u,p)},e.Canvas.prototype.getDeviceClipBounds=function(a){this._getDeviceClipBounds(li);var u=Oi.toTypedArray();return a?a.set(u):a=u.slice(),a},e.Canvas.prototype.quickReject=function(a){return a=ot(a),this._quickReject(a)},e.Canvas.prototype.getLocalToDevice=function(){this._getLocalToDevice(We);for(var a=We,u=Array(16),p=0;16>p;p++)u[p]=e.HEAPF32[a/4+p];return u},e.Canvas.prototype.getTotalMatrix=function(){this._getTotalMatrix(_e);for(var a=Array(9),u=0;9>u;u++)a[u]=e.HEAPF32[_e/4+u];return a},e.Canvas.prototype.makeSurface=function(a){return a=this._makeSurface(a),a.be=this.be,a},e.Canvas.prototype.readPixels=function(a,u,p,P,E){return e.de(this.be),o(this,a,u,p,P,E)},e.Canvas.prototype.saveLayer=function(a,u,p,P,E){return u=ot(u),this._saveLayer(a||null,u,p||null,P||0,E||e.TileMode.Clamp)},e.Canvas.prototype.writePixels=function(a,u,p,P,E,N,j,tt){if(a.byteLength%(u*p))throw"pixels length must be a multiple of the srcWidth * srcHeight";e.de(this.be);var et=a.byteLength/(u*p);N=N||e.AlphaType.Unpremul,j=j||e.ColorType.RGBA_8888,tt=tt||e.ColorSpace.SRGB;var vt=et*u;return et=T(a,"HEAPU8"),u=this._writePixels({width:u,height:p,colorType:j,alphaType:N,colorSpace:tt},et,vt,P,E),v(et,a),u},e.ColorFilter.MakeBlend=function(a,u,p){return a=F(a),p=p||e.ColorSpace.SRGB,e.ColorFilter._MakeBlend(a,u,p)},e.ColorFilter.MakeMatrix=function(a){if(!a||a.length!==20)throw"invalid color matrix";var u=T(a,"HEAPF32"),p=e.ColorFilter._makeMatrix(u);return v(u,a),p},e.ContourMeasure.prototype.getPosTan=function(a,u){return this._getPosTan(a,Rt),a=ue.toTypedArray(),u?(u.set(a),u):a.slice()},e.ImageFilter.prototype.getOutputBounds=function(a,u,p){return a=ot(a,Rt),u=L(u),this._getOutputBounds(a,u,li),u=Oi.toTypedArray(),p?(p.set(u),p):u.slice()},e.ImageFilter.MakeDropShadow=function(a,u,p,P,E,N){return E=F(E,Oe),e.ImageFilter._MakeDropShadow(a,u,p,P,E,N)},e.ImageFilter.MakeDropShadowOnly=function(a,u,p,P,E,N){return E=F(E,Oe),e.ImageFilter._MakeDropShadowOnly(a,u,p,P,E,N)},e.ImageFilter.MakeImage=function(a,u,p,P){if(p=ot(p,Rt),P=ot(P,Ee),"B"in u&&"C"in u)return e.ImageFilter._MakeImageCubic(a,u.B,u.C,p,P);const E=u.filter;let N=e.MipmapMode.None;return"mipmap"in u&&(N=u.mipmap),e.ImageFilter._MakeImageOptions(a,E,N,p,P)},e.ImageFilter.MakeMatrixTransform=function(a,u,p){if(a=L(a),"B"in u&&"C"in u)return e.ImageFilter._MakeMatrixTransformCubic(a,u.B,u.C,p);const P=u.filter;let E=e.MipmapMode.None;return"mipmap"in u&&(E=u.mipmap),e.ImageFilter._MakeMatrixTransformOptions(a,P,E,p)},e.Paint.prototype.getColor=function(){return this._getColor(Oe),ht(Oe)},e.Paint.prototype.setColor=function(a,u){u=u||null,a=F(a),this._setColor(a,u)},e.Paint.prototype.setColorComponents=function(a,u,p,P,E){E=E||null,a=J(a,u,p,P),this._setColor(a,E)},e.Path.prototype.getPoint=function(a,u){return this._getPoint(a,Rt),a=ue.toTypedArray(),u?(u[0]=a[0],u[1]=a[1],u):a.slice(0,2)},e.Picture.prototype.makeShader=function(a,u,p,P,E){return P=L(P),E=ot(E),this._makeShader(a,u,p,P,E)},e.Picture.prototype.cullRect=function(a){this._cullRect(Rt);var u=ue.toTypedArray();return a?(a.set(u),a):u.slice()},e.PictureRecorder.prototype.beginRecording=function(a,u){return a=ot(a),this._beginRecording(a,!!u)},e.Surface.prototype.getCanvas=function(){var a=this._getCanvas();return a.be=this.be,a},e.Surface.prototype.makeImageSnapshot=function(a){return e.de(this.be),a=T(a,"HEAP32",li),this._makeImageSnapshot(a)},e.Surface.prototype.makeSurface=function(a){return e.de(this.be),a=this._makeSurface(a),a.be=this.be,a},e.Surface.prototype.Wf=function(a,u){return this.Ze||(this.Ze=this.getCanvas()),requestAnimationFrame(function(){e.de(this.be),a(this.Ze),this.flush(u)}.bind(this))},e.Surface.prototype.requestAnimationFrame||(e.Surface.prototype.requestAnimationFrame=e.Surface.prototype.Wf),e.Surface.prototype.Sf=function(a,u){this.Ze||(this.Ze=this.getCanvas()),requestAnimationFrame(function(){e.de(this.be),a(this.Ze),this.flush(u),this.dispose()}.bind(this))},e.Surface.prototype.drawOnce||(e.Surface.prototype.drawOnce=e.Surface.prototype.Sf),e.PathEffect.MakeDash=function(a,u){if(u||(u=0),!a.length||a.length%2===1)throw"Intervals array must have even length";var p=T(a,"HEAPF32");return u=e.PathEffect._MakeDash(p,a.length,u),v(p,a),u},e.PathEffect.MakeLine2D=function(a,u){return u=L(u),e.PathEffect._MakeLine2D(a,u)},e.PathEffect.MakePath2D=function(a,u){return a=L(a),e.PathEffect._MakePath2D(a,u)},e.Shader.MakeColor=function(a,u){return u=u||null,a=F(a),e.Shader._MakeColor(a,u)},e.Shader.Blend=e.Shader.MakeBlend,e.Shader.Color=e.Shader.MakeColor,e.Shader.MakeLinearGradient=function(a,u,p,P,E,N,j,tt){tt=tt||null;var et=O(p),vt=T(P,"HEAPF32");j=j||0,N=L(N);var bt=ue.toTypedArray();return bt.set(a),bt.set(u,2),a=e.Shader._MakeLinearGradient(Rt,et.te,et.colorType,vt,et.count,E,j,N,tt),v(et.te,p),P&&v(vt,P),a},e.Shader.MakeRadialGradient=function(a,u,p,P,E,N,j,tt){tt=tt||null;var et=O(p),vt=T(P,"HEAPF32");return j=j||0,N=L(N),a=e.Shader._MakeRadialGradient(a[0],a[1],u,et.te,et.colorType,vt,et.count,E,j,N,tt),v(et.te,p),P&&v(vt,P),a},e.Shader.MakeSweepGradient=function(a,u,p,P,E,N,j,tt,et,vt){vt=vt||null;var bt=O(p),b=T(P,"HEAPF32");return j=j||0,tt=tt||0,et=et||360,N=L(N),a=e.Shader._MakeSweepGradient(a,u,bt.te,bt.colorType,b,bt.count,E,tt,et,j,N,vt),v(bt.te,p),P&&v(b,P),a},e.Shader.MakeTwoPointConicalGradient=function(a,u,p,P,E,N,j,tt,et,vt){vt=vt||null;var bt=O(E),b=T(N,"HEAPF32");et=et||0,tt=L(tt);var I=ue.toTypedArray();return I.set(a),I.set(p,2),a=e.Shader._MakeTwoPointConicalGradient(Rt,u,P,bt.te,bt.colorType,b,bt.count,j,et,tt,vt),v(bt.te,E),N&&v(b,N),a},e.Vertices.prototype.bounds=function(a){this._bounds(Rt);var u=ue.toTypedArray();return a?(a.set(u),a):u.slice()},e.ke&&e.ke.forEach(function(a){a()})},e.computeTonalColors=function(o){var a=T(o.ambient,"HEAPF32"),u=T(o.spot,"HEAPF32");this._computeTonalColors(a,u);var p={ambient:ht(a),spot:ht(u)};return v(a,o.ambient),v(u,o.spot),p},e.LTRBRect=function(o,a,u,p){return Float32Array.of(o,a,u,p)},e.XYWHRect=function(o,a,u,p){return Float32Array.of(o,a,o+u,a+p)},e.LTRBiRect=function(o,a,u,p){return Int32Array.of(o,a,u,p)},e.XYWHiRect=function(o,a,u,p){return Int32Array.of(o,a,o+u,a+p)},e.RRectXY=function(o,a,u){return Float32Array.of(o[0],o[1],o[2],o[3],a,u,a,u,a,u,a,u)},e.MakeAnimatedImageFromEncoded=function(o){o=new Uint8Array(o);var a=e._malloc(o.byteLength);return e.HEAPU8.set(o,a),(o=e._decodeAnimatedImage(a,o.byteLength))?o:null},e.MakeImageFromEncoded=function(o){o=new Uint8Array(o);var a=e._malloc(o.byteLength);return e.HEAPU8.set(o,a),(o=e._decodeImage(a,o.byteLength))?o:null};var hi=null;e.MakeImageFromCanvasImageSource=function(o){var a=o.width,u=o.height;hi||(hi=document.createElement("canvas")),hi.width=a,hi.height=u;var p=hi.getContext("2d",{willReadFrequently:!0});return p.drawImage(o,0,0),o=p.getImageData(0,0,a,u),e.MakeImage({width:a,height:u,alphaType:e.AlphaType.Unpremul,colorType:e.ColorType.RGBA_8888,colorSpace:e.ColorSpace.SRGB},o.data,4*a)},e.MakeImage=function(o,a,u){var p=e._malloc(a.length);return e.HEAPU8.set(a,p),e._MakeImage(o,p,a.length,u)},e.MakeVertices=function(o,a,u,p,P,E){var N=P&&P.length||0,j=0;return u&&u.length&&(j|=1),p&&p.length&&(j|=2),E===void 0||E||(j|=4),o=new e._VerticesBuilder(o,a.length/2,N,j),T(a,"HEAPF32",o.positions()),o.texCoords()&&T(u,"HEAPF32",o.texCoords()),o.colors()&&T(g(p),"HEAPU32",o.colors()),o.indices()&&T(P,"HEAPU16",o.indices()),o.detach()},e.Matrix={},e.Matrix.identity=function(){return s(3)},e.Matrix.invert=function(o){var a=o[0]*o[4]*o[8]+o[1]*o[5]*o[6]+o[2]*o[3]*o[7]-o[2]*o[4]*o[6]-o[1]*o[3]*o[8]-o[0]*o[5]*o[7];return a?[(o[4]*o[8]-o[5]*o[7])/a,(o[2]*o[7]-o[1]*o[8])/a,(o[1]*o[5]-o[2]*o[4])/a,(o[5]*o[6]-o[3]*o[8])/a,(o[0]*o[8]-o[2]*o[6])/a,(o[2]*o[3]-o[0]*o[5])/a,(o[3]*o[7]-o[4]*o[6])/a,(o[1]*o[6]-o[0]*o[7])/a,(o[0]*o[4]-o[1]*o[3])/a]:null},e.Matrix.mapPoints=function(o,a){for(var u=0;u<a.length;u+=2){var p=a[u],P=a[u+1],E=o[6]*p+o[7]*P+o[8],N=o[3]*p+o[4]*P+o[5];a[u]=(o[0]*p+o[1]*P+o[2])/E,a[u+1]=N/E}return a},e.Matrix.multiply=function(){return oi(3,arguments)},e.Matrix.rotated=function(o,a,u){a=a||0,u=u||0;var p=Math.sin(o);return o=Math.cos(o),[o,-p,Lt(p,u,1-o,a),p,o,Lt(-p,a,1-o,u),0,0,1]},e.Matrix.scaled=function(o,a,u,p){u=u||0,p=p||0;var P=n([o,a],s(3),3,0,1);return n([u-o*u,p-a*p],P,3,2,0)},e.Matrix.skewed=function(o,a,u,p){u=u||0,p=p||0;var P=n([o,a],s(3),3,1,-1);return n([-o*u,-a*p],P,3,2,0)},e.Matrix.translated=function(o,a){return n(arguments,s(3),3,2,0)},e.Vector={},e.Vector.dot=function(o,a){return o.map(function(u,p){return u*a[p]}).reduce(function(u,p){return u+p})},e.Vector.lengthSquared=function(o){return e.Vector.dot(o,o)},e.Vector.length=function(o){return Math.sqrt(e.Vector.lengthSquared(o))},e.Vector.mulScalar=function(o,a){return o.map(function(u){return u*a})},e.Vector.add=function(o,a){return o.map(function(u,p){return u+a[p]})},e.Vector.sub=function(o,a){return o.map(function(u,p){return u-a[p]})},e.Vector.dist=function(o,a){return e.Vector.length(e.Vector.sub(o,a))},e.Vector.normalize=function(o){return e.Vector.mulScalar(o,1/e.Vector.length(o))},e.Vector.cross=function(o,a){return[o[1]*a[2]-o[2]*a[1],o[2]*a[0]-o[0]*a[2],o[0]*a[1]-o[1]*a[0]]},e.M44={},e.M44.identity=function(){return s(4)},e.M44.translated=function(o){return n(o,s(4),4,3,0)},e.M44.scaled=function(o){return n(o,s(4),4,0,1)},e.M44.rotated=function(o,a){return e.M44.rotatedUnitSinCos(e.Vector.normalize(o),Math.sin(a),Math.cos(a))},e.M44.rotatedUnitSinCos=function(o,a,u){var p=o[0],P=o[1];o=o[2];var E=1-u;return[E*p*p+u,E*p*P-a*o,E*p*o+a*P,0,E*p*P+a*o,E*P*P+u,E*P*o-a*p,0,E*p*o-a*P,E*P*o+a*p,E*o*o+u,0,0,0,0,1]},e.M44.lookat=function(o,a,u){a=e.Vector.normalize(e.Vector.sub(a,o)),u=e.Vector.normalize(u),u=e.Vector.normalize(e.Vector.cross(a,u));var p=e.M44.identity();return n(u,p,4,0,0),n(e.Vector.cross(u,a),p,4,1,0),n(e.Vector.mulScalar(a,-1),p,4,2,0),n(o,p,4,3,0),o=e.M44.invert(p),o===null?e.M44.identity():o},e.M44.perspective=function(o,a,u){var p=1/(a-o);return u/=2,u=Math.cos(u)/Math.sin(u),[u,0,0,0,0,u,0,0,0,0,(a+o)*p,2*a*o*p,0,0,-1,1]},e.M44.rc=function(o,a,u){return o[4*a+u]},e.M44.multiply=function(){return oi(4,arguments)},e.M44.invert=function(o){var a=o[0],u=o[4],p=o[8],P=o[12],E=o[1],N=o[5],j=o[9],tt=o[13],et=o[2],vt=o[6],bt=o[10],b=o[14],I=o[3],ct=o[7],Ct=o[11];o=o[15];var kt=a*N-u*E,Xt=a*j-p*E,ie=a*tt-P*E,de=u*j-p*N,Tt=u*tt-P*N,$=p*tt-P*j,f=et*ct-vt*I,w=et*Ct-bt*I,M=et*o-b*I,k=vt*Ct-bt*ct,D=vt*o-b*ct,B=bt*o-b*Ct,Z=kt*B-Xt*D+ie*k+de*M-Tt*w+$*f,pt=1/Z;return Z===0||pt===1/0?null:(kt*=pt,Xt*=pt,ie*=pt,de*=pt,Tt*=pt,$*=pt,f*=pt,w*=pt,M*=pt,k*=pt,D*=pt,B*=pt,a=[N*B-j*D+tt*k,j*M-E*B-tt*w,E*D-N*M+tt*f,N*w-E*k-j*f,p*D-u*B-P*k,a*B-p*M+P*w,u*M-a*D-P*f,a*k-u*w+p*f,ct*$-Ct*Tt+o*de,Ct*ie-I*$-o*Xt,I*Tt-ct*ie+o*kt,ct*Xt-I*de-Ct*kt,bt*Tt-vt*$-b*de,et*$-bt*ie+b*Xt,vt*ie-et*Tt-b*kt,et*de-vt*Xt+bt*kt],a.every(function($t){return!isNaN($t)&&$t!==1/0&&$t!==-1/0})?a:null)},e.M44.transpose=function(o){return[o[0],o[4],o[8],o[12],o[1],o[5],o[9],o[13],o[2],o[6],o[10],o[14],o[3],o[7],o[11],o[15]]},e.M44.mustInvert=function(o){if(o=e.M44.invert(o),o===null)throw"Matrix not invertible";return o},e.M44.setupCamera=function(o,a,u){var p=e.M44.lookat(u.eye,u.coa,u.up);return u=e.M44.perspective(u.near,u.far,u.angle),a=[(o[2]-o[0])/2,(o[3]-o[1])/2,a],o=e.M44.multiply(e.M44.translated([(o[0]+o[2])/2,(o[1]+o[3])/2,0]),e.M44.scaled(a)),e.M44.multiply(o,u,p,e.M44.mustInvert(o))},e.ColorMatrix={},e.ColorMatrix.identity=function(){var o=new Float32Array(20);return o[0]=1,o[6]=1,o[12]=1,o[18]=1,o},e.ColorMatrix.scaled=function(o,a,u,p){var P=new Float32Array(20);return P[0]=o,P[6]=a,P[12]=u,P[18]=p,P};var oa=[[6,7,11,12],[0,10,2,12],[0,1,5,6]];e.ColorMatrix.rotated=function(o,a,u){var p=e.ColorMatrix.identity();return o=oa[o],p[o[0]]=u,p[o[1]]=a,p[o[2]]=-a,p[o[3]]=u,p},e.ColorMatrix.postTranslate=function(o,a,u,p,P){return o[4]+=a,o[9]+=u,o[14]+=p,o[19]+=P,o},e.ColorMatrix.concat=function(o,a){for(var u=new Float32Array(20),p=0,P=0;20>P;P+=5){for(var E=0;4>E;E++)u[p++]=o[P]*a[E]+o[P+1]*a[E+5]+o[P+2]*a[E+10]+o[P+3]*a[E+15];u[p++]=o[P]*a[4]+o[P+1]*a[9]+o[P+2]*a[14]+o[P+3]*a[19]+o[P+4]}return u},function(o){o.ke=o.ke||[],o.ke.push(function(){function a(b){return b&&(b.dir=b.dir===0?o.TextDirection.RTL:o.TextDirection.LTR),b}function u(b){if(!b||!b.length)return[];for(var I=[],ct=0;ct<b.length;ct+=5){var Ct=o.LTRBRect(b[ct],b[ct+1],b[ct+2],b[ct+3]),kt=o.TextDirection.LTR;b[ct+4]===0&&(kt=o.TextDirection.RTL),I.push({rect:Ct,dir:kt})}return o._free(b.byteOffset),I}function p(b){return b=b||{},b.weight===void 0&&(b.weight=o.FontWeight.Normal),b.width=b.width||o.FontWidth.Normal,b.slant=b.slant||o.FontSlant.Upright,b}function P(b){if(!b||!b.length)return gt;for(var I=[],ct=0;ct<b.length;ct++){var Ct=E(b[ct]);I.push(Ct)}return T(I,"HEAPU32")}function E(b){if(tt[b])return tt[b];var I=le(b)+1,ct=o._malloc(I);return oe(b,ft,ct,I),tt[b]=ct}function N(b){if(b._colorPtr=F(b.color),b._foregroundColorPtr=gt,b._backgroundColorPtr=gt,b._decorationColorPtr=gt,b.foregroundColor&&(b._foregroundColorPtr=F(b.foregroundColor,et)),b.backgroundColor&&(b._backgroundColorPtr=F(b.backgroundColor,vt)),b.decorationColor&&(b._decorationColorPtr=F(b.decorationColor,bt)),Array.isArray(b.fontFamilies)&&b.fontFamilies.length?(b._fontFamiliesPtr=P(b.fontFamilies),b._fontFamiliesLen=b.fontFamilies.length):(b._fontFamiliesPtr=gt,b._fontFamiliesLen=0),b.locale){var I=b.locale;b._localePtr=E(I),b._localeLen=le(I)}else b._localePtr=gt,b._localeLen=0;if(Array.isArray(b.shadows)&&b.shadows.length){I=b.shadows;var ct=I.map(function(Tt){return Tt.color||o.BLACK}),Ct=I.map(function(Tt){return Tt.blurRadius||0});b._shadowLen=I.length;for(var kt=o._malloc(8*I.length),Xt=kt/4,ie=0;ie<I.length;ie++){var de=I[ie].offset||[0,0];o.HEAPF32[Xt]=de[0],o.HEAPF32[Xt+1]=de[1],Xt+=2}b._shadowColorsPtr=O(ct).te,b._shadowOffsetsPtr=kt,b._shadowBlurRadiiPtr=T(Ct,"HEAPF32")}else b._shadowLen=0,b._shadowColorsPtr=gt,b._shadowOffsetsPtr=gt,b._shadowBlurRadiiPtr=gt;Array.isArray(b.fontFeatures)&&b.fontFeatures.length?(I=b.fontFeatures,ct=I.map(function(Tt){return Tt.name}),Ct=I.map(function(Tt){return Tt.value}),b._fontFeatureLen=I.length,b._fontFeatureNamesPtr=P(ct),b._fontFeatureValuesPtr=T(Ct,"HEAPU32")):(b._fontFeatureLen=0,b._fontFeatureNamesPtr=gt,b._fontFeatureValuesPtr=gt),Array.isArray(b.fontVariations)&&b.fontVariations.length?(I=b.fontVariations,ct=I.map(function(Tt){return Tt.axis}),Ct=I.map(function(Tt){return Tt.value}),b._fontVariationLen=I.length,b._fontVariationAxesPtr=P(ct),b._fontVariationValuesPtr=T(Ct,"HEAPF32")):(b._fontVariationLen=0,b._fontVariationAxesPtr=gt,b._fontVariationValuesPtr=gt)}function j(b){o._free(b._fontFamiliesPtr),o._free(b._shadowColorsPtr),o._free(b._shadowOffsetsPtr),o._free(b._shadowBlurRadiiPtr),o._free(b._fontFeatureNamesPtr),o._free(b._fontFeatureValuesPtr),o._free(b._fontVariationAxesPtr),o._free(b._fontVariationValuesPtr)}o.Paragraph.prototype.getRectsForRange=function(b,I,ct,Ct){return b=this._getRectsForRange(b,I,ct,Ct),u(b)},o.Paragraph.prototype.getRectsForPlaceholders=function(){var b=this._getRectsForPlaceholders();return u(b)},o.Paragraph.prototype.getGlyphInfoAt=function(b){return a(this._getGlyphInfoAt(b))},o.Paragraph.prototype.getClosestGlyphInfoAtCoordinate=function(b,I){return a(this._getClosestGlyphInfoAtCoordinate(b,I))},o.TypefaceFontProvider.prototype.registerFont=function(b,I){if(b=o.Typeface.MakeTypefaceFromData(b),!b)return null;I=E(I),this._registerFont(b,I),b.delete()},o.ParagraphStyle=function(b){if(b.disableHinting=b.disableHinting||!1,b.ellipsis){var I=b.ellipsis;b._ellipsisPtr=E(I),b._ellipsisLen=le(I)}else b._ellipsisPtr=gt,b._ellipsisLen=0;return b.heightMultiplier==null&&(b.heightMultiplier=-1),b.maxLines=b.maxLines||0,b.replaceTabCharacters=b.replaceTabCharacters||!1,I=(I=b.strutStyle)||{},I.strutEnabled=I.strutEnabled||!1,I.strutEnabled&&Array.isArray(I.fontFamilies)&&I.fontFamilies.length?(I._fontFamiliesPtr=P(I.fontFamilies),I._fontFamiliesLen=I.fontFamilies.length):(I._fontFamiliesPtr=gt,I._fontFamiliesLen=0),I.fontStyle=p(I.fontStyle),I.fontSize==null&&(I.fontSize=-1),I.heightMultiplier==null&&(I.heightMultiplier=-1),I.halfLeading=I.halfLeading||!1,I.leading=I.leading||0,I.forceStrutHeight=I.forceStrutHeight||!1,b.strutStyle=I,b.textAlign=b.textAlign||o.TextAlign.Start,b.textDirection=b.textDirection||o.TextDirection.LTR,b.textHeightBehavior=b.textHeightBehavior||o.TextHeightBehavior.All,b.textStyle=o.TextStyle(b.textStyle),b.applyRoundingHack=b.applyRoundingHack!==!1,b},o.TextStyle=function(b){return b.color||(b.color=o.BLACK),b.decoration=b.decoration||0,b.decorationThickness=b.decorationThickness||0,b.decorationStyle=b.decorationStyle||o.DecorationStyle.Solid,b.textBaseline=b.textBaseline||o.TextBaseline.Alphabetic,b.fontSize==null&&(b.fontSize=-1),b.letterSpacing=b.letterSpacing||0,b.wordSpacing=b.wordSpacing||0,b.heightMultiplier==null&&(b.heightMultiplier=-1),b.halfLeading=b.halfLeading||!1,b.fontStyle=p(b.fontStyle),b};var tt={},et=o._malloc(16),vt=o._malloc(16),bt=o._malloc(16);o.ParagraphBuilder.Make=function(b,I){return N(b.textStyle),I=o.ParagraphBuilder._Make(b,I),j(b.textStyle),I},o.ParagraphBuilder.MakeFromFontProvider=function(b,I){return N(b.textStyle),I=o.ParagraphBuilder._MakeFromFontProvider(b,I),j(b.textStyle),I},o.ParagraphBuilder.MakeFromFontCollection=function(b,I){return N(b.textStyle),I=o.ParagraphBuilder._MakeFromFontCollection(b,I),j(b.textStyle),I},o.ParagraphBuilder.ShapeText=function(b,I,ct){let Ct=0;for(const kt of I)Ct+=kt.length;if(Ct!==b.length)throw"Accumulated block lengths must equal text.length";return o.ParagraphBuilder._ShapeText(b,I,ct)},o.ParagraphBuilder.prototype.pushStyle=function(b){N(b),this._pushStyle(b),j(b)},o.ParagraphBuilder.prototype.pushPaintStyle=function(b,I,ct){N(b),this._pushPaintStyle(b,I,ct),j(b)},o.ParagraphBuilder.prototype.addPlaceholder=function(b,I,ct,Ct,kt){ct=ct||o.PlaceholderAlignment.Baseline,Ct=Ct||o.TextBaseline.Alphabetic,this._addPlaceholder(b||0,I||0,ct,Ct,kt||0)},o.ParagraphBuilder.prototype.setWordsUtf8=function(b){var I=T(b,"HEAPU32");this._setWordsUtf8(I,b&&b.length||0),v(I,b)},o.ParagraphBuilder.prototype.setWordsUtf16=function(b){var I=T(b,"HEAPU32");this._setWordsUtf16(I,b&&b.length||0),v(I,b)},o.ParagraphBuilder.prototype.setGraphemeBreaksUtf8=function(b){var I=T(b,"HEAPU32");this._setGraphemeBreaksUtf8(I,b&&b.length||0),v(I,b)},o.ParagraphBuilder.prototype.setGraphemeBreaksUtf16=function(b){var I=T(b,"HEAPU32");this._setGraphemeBreaksUtf16(I,b&&b.length||0),v(I,b)},o.ParagraphBuilder.prototype.setLineBreaksUtf8=function(b){var I=T(b,"HEAPU32");this._setLineBreaksUtf8(I,b&&b.length||0),v(I,b)},o.ParagraphBuilder.prototype.setLineBreaksUtf16=function(b){var I=T(b,"HEAPU32");this._setLineBreaksUtf16(I,b&&b.length||0),v(I,b)}})}(c),e.ke=e.ke||[],e.ke.push(function(){e.Path.prototype.op=function(o,a){return this._op(o,a)?this:null},e.Path.prototype.simplify=function(){return this._simplify()?this:null}}),e.ke=e.ke||[],e.ke.push(function(){e.Canvas.prototype.drawText=function(o,a,u,p,P){var E=le(o),N=e._malloc(E+1);oe(o,ft,N,E+1),this._drawSimpleText(N,E,a,u,P,p),e._free(N)},e.Canvas.prototype.drawGlyphs=function(o,a,u,p,P,E){if(!(2*o.length<=a.length))throw"Not enough positions for the array of gyphs";e.de(this.be);const N=T(o,"HEAPU16"),j=T(a,"HEAPF32");this._drawGlyphs(o.length,N,j,u,p,P,E),v(j,a),v(N,o)},e.Font.prototype.getGlyphBounds=function(o,a,u){var p=T(o,"HEAPU16"),P=e._malloc(16*o.length);return this._getGlyphWidthBounds(p,o.length,gt,P,a||null),a=new Float32Array(e.HEAPU8.buffer,P,4*o.length),v(p,o),u?(u.set(a),e._free(P),u):(o=Float32Array.from(a),e._free(P),o)},e.Font.prototype.getGlyphIDs=function(o,a,u){a||(a=o.length);var p=le(o)+1,P=e._malloc(p);return oe(o,ft,P,p),o=e._malloc(2*a),a=this._getGlyphIDs(P,p-1,a,o),e._free(P),0>a?(e._free(o),null):(P=new Uint16Array(e.HEAPU8.buffer,o,a),u?(u.set(P),e._free(o),u):(u=Uint16Array.from(P),e._free(o),u))},e.Font.prototype.getGlyphIntercepts=function(o,a,u,p){var P=T(o,"HEAPU16"),E=T(a,"HEAPF32");return this._getGlyphIntercepts(P,o.length,!(o&&o._ck),E,a.length,!(a&&a._ck),u,p)},e.Font.prototype.getGlyphWidths=function(o,a,u){var p=T(o,"HEAPU16"),P=e._malloc(4*o.length);return this._getGlyphWidthBounds(p,o.length,P,gt,a||null),a=new Float32Array(e.HEAPU8.buffer,P,o.length),v(p,o),u?(u.set(a),e._free(P),u):(o=Float32Array.from(a),e._free(P),o)},e.FontMgr.FromData=function(){if(!arguments.length)return null;var o=arguments;if(o.length===1&&Array.isArray(o[0])&&(o=arguments[0]),!o.length)return null;for(var a=[],u=[],p=0;p<o.length;p++){var P=new Uint8Array(o[p]),E=T(P,"HEAPU8");a.push(E),u.push(P.byteLength)}return a=T(a,"HEAPU32"),u=T(u,"HEAPU32"),o=e.FontMgr._fromData(a,u,o.length),e._free(a),e._free(u),o},e.Typeface.MakeTypefaceFromData=function(o){o=new Uint8Array(o);var a=T(o,"HEAPU8");return(o=e.Typeface._MakeTypefaceFromData(a,o.byteLength))?o:null},e.Typeface.MakeFreeTypeFaceFromData=e.Typeface.MakeTypefaceFromData,e.Typeface.prototype.getGlyphIDs=function(o,a,u){a||(a=o.length);var p=le(o)+1,P=e._malloc(p);return oe(o,ft,P,p),o=e._malloc(2*a),a=this._getGlyphIDs(P,p-1,a,o),e._free(P),0>a?(e._free(o),null):(P=new Uint16Array(e.HEAPU8.buffer,o,a),u?(u.set(P),e._free(o),u):(u=Uint16Array.from(P),e._free(o),u))},e.TextBlob.MakeOnPath=function(o,a,u,p){if(o&&o.length&&a&&a.countPoints()){if(a.countPoints()===1)return this.MakeFromText(o,u);p||(p=0);var P=u.getGlyphIDs(o);P=u.getGlyphWidths(P);var E=[];a=new e.ContourMeasureIter(a,!1,1);for(var N=a.next(),j=new Float32Array(4),tt=0;tt<o.length&&N;tt++){var et=P[tt];if(p+=et/2,p>N.length()){if(N.delete(),N=a.next(),!N){o=o.substring(0,tt);break}p=et/2}N.getPosTan(p,j);var vt=j[2],bt=j[3];E.push(vt,bt,j[0]-et/2*vt,j[1]-et/2*bt),p+=et/2}return o=this.MakeFromRSXform(o,E,u),N&&N.delete(),a.delete(),o}},e.TextBlob.MakeFromRSXform=function(o,a,u){var p=le(o)+1,P=e._malloc(p);return oe(o,ft,P,p),o=T(a,"HEAPF32"),u=e.TextBlob._MakeFromRSXform(P,p-1,o,u),e._free(P),u||null},e.TextBlob.MakeFromRSXformGlyphs=function(o,a,u){var p=T(o,"HEAPU16");return a=T(a,"HEAPF32"),u=e.TextBlob._MakeFromRSXformGlyphs(p,2*o.length,a,u),v(p,o),u||null},e.TextBlob.MakeFromGlyphs=function(o,a){var u=T(o,"HEAPU16");return a=e.TextBlob._MakeFromGlyphs(u,2*o.length,a),v(u,o),a||null},e.TextBlob.MakeFromText=function(o,a){var u=le(o)+1,p=e._malloc(u);return oe(o,ft,p,u),o=e.TextBlob._MakeFromText(p,u-1,a),e._free(p),o||null},e.MallocGlyphIDs=function(o){return e.Malloc(Uint16Array,o)}}),e.ke=e.ke||[],e.ke.push(function(){e.MakePicture=function(o){o=new Uint8Array(o);var a=e._malloc(o.byteLength);return e.HEAPU8.set(o,a),(o=e._MakePicture(a,o.byteLength))?o:null}}),e.ke=e.ke||[],e.ke.push(function(){e.RuntimeEffect.Make=function(o,a){return e.RuntimeEffect._Make(o,{onError:a||function(u){console.log("RuntimeEffect error",u)}})},e.RuntimeEffect.MakeForBlender=function(o,a){return e.RuntimeEffect._MakeForBlender(o,{onError:a||function(u){console.log("RuntimeEffect error",u)}})},e.RuntimeEffect.prototype.makeShader=function(o,a){var u=!o._ck,p=T(o,"HEAPF32");return a=L(a),this._makeShader(p,4*o.length,u,a)},e.RuntimeEffect.prototype.makeShaderWithChildren=function(o,a,u){var p=!o._ck,P=T(o,"HEAPF32");u=L(u);for(var E=[],N=0;N<a.length;N++)E.push(a[N].ae.ie);return a=T(E,"HEAPU32"),this._makeShaderWithChildren(P,4*o.length,p,a,E.length,u)},e.RuntimeEffect.prototype.makeBlender=function(o){var a=!o._ck,u=T(o,"HEAPF32");return this._makeBlender(u,4*o.length,a)}}),function(){function o($){for(var f=0;f<$.length;f++)if($[f]!==void 0&&!Number.isFinite($[f]))return!1;return!0}function a($){var f=e.getColorComponents($);$=f[0];var w=f[1],M=f[2];return f=f[3],f===1?($=$.toString(16).toLowerCase(),w=w.toString(16).toLowerCase(),M=M.toString(16).toLowerCase(),$=$.length===1?"0"+$:$,w=w.length===1?"0"+w:w,M=M.length===1?"0"+M:M,"#"+$+w+M):(f=f===0||f===1?f:f.toFixed(8),"rgba("+$+", "+w+", "+M+", "+f+")")}function u($){return e.parseColorString($,ie)}function p($){if($=de.exec($),!$)return null;var f=parseFloat($[4]),w=16;switch($[5]){case"em":case"rem":w=16*f;break;case"pt":w=4*f/3;break;case"px":w=f;break;case"pc":w=16*f;break;case"in":w=96*f;break;case"cm":w=96*f/2.54;break;case"mm":w=3.7795275590551185*f;break;case"q":w=.9448818897637796*f;break;case"%":w=.21333333333333335*f}return{style:$[1],variant:$[2],weight:$[3],sizePx:w,family:$[6].trim()}}function P(){Tt||(Tt={"Noto Mono":{"*":e.Typeface.GetDefault()},monospace:{"*":e.Typeface.GetDefault()}})}function E($){this.ce=$,this.fe=new e.Paint,this.fe.setAntiAlias(!0),this.fe.setStrokeMiter(10),this.fe.setStrokeCap(e.StrokeCap.Butt),this.fe.setStrokeJoin(e.StrokeJoin.Miter),this.kf="10px monospace",this.Fe=new e.Font(e.Typeface.GetDefault(),10),this.Fe.setSubpixel(!0),this.se=this.ye=e.BLACK,this.Oe=0,this.af=e.TRANSPARENT,this.Qe=this.Pe=0,this.bf=this.Be=1,this.$e=0,this.Ne=[],this.ee=e.BlendMode.SrcOver,this.fe.setStrokeWidth(this.bf),this.fe.setBlendMode(this.ee),this.he=new e.Path,this.je=e.Matrix.identity(),this.Ff=[],this.Ue=[],this.Ee=function(){this.he.delete(),this.fe.delete(),this.Fe.delete(),this.Ue.forEach(function(f){f.Ee()})},Object.defineProperty(this,"currentTransform",{enumerable:!0,get:function(){return{a:this.je[0],c:this.je[1],e:this.je[2],b:this.je[3],d:this.je[4],f:this.je[5]}},set:function(f){f.a&&this.setTransform(f.a,f.b,f.c,f.d,f.e,f.f)}}),Object.defineProperty(this,"fillStyle",{enumerable:!0,get:function(){return l(this.se)?a(this.se):this.se},set:function(f){typeof f=="string"?this.se=u(f):f.Me&&(this.se=f)}}),Object.defineProperty(this,"font",{enumerable:!0,get:function(){return this.kf},set:function(f){var w=p(f),M=(w.style||"normal")+"|"+(w.variant||"normal")+"|"+(w.weight||"normal"),k=w.family;P(),M=Tt[k]?Tt[k][M]||Tt[k]["*"]:e.Typeface.GetDefault(),w.typeface=M,w&&(this.Fe.setSize(w.sizePx),this.Fe.setTypeface(w.typeface),this.kf=f)}}),Object.defineProperty(this,"globalAlpha",{enumerable:!0,get:function(){return this.Be},set:function(f){!isFinite(f)||0>f||1<f||(this.Be=f)}}),Object.defineProperty(this,"globalCompositeOperation",{enumerable:!0,get:function(){switch(this.ee){case e.BlendMode.SrcOver:return"source-over";case e.BlendMode.DstOver:return"destination-over";case e.BlendMode.Src:return"copy";case e.BlendMode.Dst:return"destination";case e.BlendMode.Clear:return"clear";case e.BlendMode.SrcIn:return"source-in";case e.BlendMode.DstIn:return"destination-in";case e.BlendMode.SrcOut:return"source-out";case e.BlendMode.DstOut:return"destination-out";case e.BlendMode.SrcATop:return"source-atop";case e.BlendMode.DstATop:return"destination-atop";case e.BlendMode.Xor:return"xor";case e.BlendMode.Plus:return"lighter";case e.BlendMode.Multiply:return"multiply";case e.BlendMode.Screen:return"screen";case e.BlendMode.Overlay:return"overlay";case e.BlendMode.Darken:return"darken";case e.BlendMode.Lighten:return"lighten";case e.BlendMode.ColorDodge:return"color-dodge";case e.BlendMode.ColorBurn:return"color-burn";case e.BlendMode.HardLight:return"hard-light";case e.BlendMode.SoftLight:return"soft-light";case e.BlendMode.Difference:return"difference";case e.BlendMode.Exclusion:return"exclusion";case e.BlendMode.Hue:return"hue";case e.BlendMode.Saturation:return"saturation";case e.BlendMode.Color:return"color";case e.BlendMode.Luminosity:return"luminosity"}},set:function(f){switch(f){case"source-over":this.ee=e.BlendMode.SrcOver;break;case"destination-over":this.ee=e.BlendMode.DstOver;break;case"copy":this.ee=e.BlendMode.Src;break;case"destination":this.ee=e.BlendMode.Dst;break;case"clear":this.ee=e.BlendMode.Clear;break;case"source-in":this.ee=e.BlendMode.SrcIn;break;case"destination-in":this.ee=e.BlendMode.DstIn;break;case"source-out":this.ee=e.BlendMode.SrcOut;break;case"destination-out":this.ee=e.BlendMode.DstOut;break;case"source-atop":this.ee=e.BlendMode.SrcATop;break;case"destination-atop":this.ee=e.BlendMode.DstATop;break;case"xor":this.ee=e.BlendMode.Xor;break;case"lighter":this.ee=e.BlendMode.Plus;break;case"plus-lighter":this.ee=e.BlendMode.Plus;break;case"plus-darker":throw"plus-darker is not supported";case"multiply":this.ee=e.BlendMode.Multiply;break;case"screen":this.ee=e.BlendMode.Screen;break;case"overlay":this.ee=e.BlendMode.Overlay;break;case"darken":this.ee=e.BlendMode.Darken;break;case"lighten":this.ee=e.BlendMode.Lighten;break;case"color-dodge":this.ee=e.BlendMode.ColorDodge;break;case"color-burn":this.ee=e.BlendMode.ColorBurn;break;case"hard-light":this.ee=e.BlendMode.HardLight;break;case"soft-light":this.ee=e.BlendMode.SoftLight;break;case"difference":this.ee=e.BlendMode.Difference;break;case"exclusion":this.ee=e.BlendMode.Exclusion;break;case"hue":this.ee=e.BlendMode.Hue;break;case"saturation":this.ee=e.BlendMode.Saturation;break;case"color":this.ee=e.BlendMode.Color;break;case"luminosity":this.ee=e.BlendMode.Luminosity;break;default:return}this.fe.setBlendMode(this.ee)}}),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.fe.getStrokeCap()){case e.StrokeCap.Butt:return"butt";case e.StrokeCap.Round:return"round";case e.StrokeCap.Square:return"square"}},set:function(f){switch(f){case"butt":this.fe.setStrokeCap(e.StrokeCap.Butt);break;case"round":this.fe.setStrokeCap(e.StrokeCap.Round);break;case"square":this.fe.setStrokeCap(e.StrokeCap.Square)}}}),Object.defineProperty(this,"lineDashOffset",{enumerable:!0,get:function(){return this.$e},set:function(f){isFinite(f)&&(this.$e=f)}}),Object.defineProperty(this,"lineJoin",{enumerable:!0,get:function(){switch(this.fe.getStrokeJoin()){case e.StrokeJoin.Miter:return"miter";case e.StrokeJoin.Round:return"round";case e.StrokeJoin.Bevel:return"bevel"}},set:function(f){switch(f){case"miter":this.fe.setStrokeJoin(e.StrokeJoin.Miter);break;case"round":this.fe.setStrokeJoin(e.StrokeJoin.Round);break;case"bevel":this.fe.setStrokeJoin(e.StrokeJoin.Bevel)}}}),Object.defineProperty(this,"lineWidth",{enumerable:!0,get:function(){return this.fe.getStrokeWidth()},set:function(f){0>=f||!f||(this.bf=f,this.fe.setStrokeWidth(f))}}),Object.defineProperty(this,"miterLimit",{enumerable:!0,get:function(){return this.fe.getStrokeMiter()},set:function(f){0>=f||!f||this.fe.setStrokeMiter(f)}}),Object.defineProperty(this,"shadowBlur",{enumerable:!0,get:function(){return this.Oe},set:function(f){0>f||!isFinite(f)||(this.Oe=f)}}),Object.defineProperty(this,"shadowColor",{enumerable:!0,get:function(){return a(this.af)},set:function(f){this.af=u(f)}}),Object.defineProperty(this,"shadowOffsetX",{enumerable:!0,get:function(){return this.Pe},set:function(f){isFinite(f)&&(this.Pe=f)}}),Object.defineProperty(this,"shadowOffsetY",{enumerable:!0,get:function(){return this.Qe},set:function(f){isFinite(f)&&(this.Qe=f)}}),Object.defineProperty(this,"strokeStyle",{enumerable:!0,get:function(){return a(this.ye)},set:function(f){typeof f=="string"?this.ye=u(f):f.Me&&(this.ye=f)}}),this.arc=function(f,w,M,k,D,B){I(this.he,f,w,M,M,0,k,D,B)},this.arcTo=function(f,w,M,k,D){vt(this.he,f,w,M,k,D)},this.beginPath=function(){this.he.delete(),this.he=new e.Path},this.bezierCurveTo=function(f,w,M,k,D,B){var Z=this.he;o([f,w,M,k,D,B])&&(Z.isEmpty()&&Z.moveTo(f,w),Z.cubicTo(f,w,M,k,D,B))},this.clearRect=function(f,w,M,k){this.fe.setStyle(e.PaintStyle.Fill),this.fe.setBlendMode(e.BlendMode.Clear),this.ce.drawRect(e.XYWHRect(f,w,M,k),this.fe),this.fe.setBlendMode(this.ee)},this.clip=function(f,w){typeof f=="string"?(w=f,f=this.he):f&&f.vf&&(f=f.le),f||(f=this.he),f=f.copy(),w&&w.toLowerCase()==="evenodd"?f.setFillType(e.FillType.EvenOdd):f.setFillType(e.FillType.Winding),this.ce.clipPath(f,e.ClipOp.Intersect,!0),f.delete()},this.closePath=function(){bt(this.he)},this.createImageData=function(){if(arguments.length===1){var f=arguments[0];return new tt(new Uint8ClampedArray(4*f.width*f.height),f.width,f.height)}if(arguments.length===2){f=arguments[0];var w=arguments[1];return new tt(new Uint8ClampedArray(4*f*w),f,w)}throw"createImageData expects 1 or 2 arguments, got "+arguments.length},this.createLinearGradient=function(f,w,M,k){if(o(arguments)){var D=new et(f,w,M,k);return this.Ue.push(D),D}},this.createPattern=function(f,w){return f=new kt(f,w),this.Ue.push(f),f},this.createRadialGradient=function(f,w,M,k,D,B){if(o(arguments)){var Z=new Xt(f,w,M,k,D,B);return this.Ue.push(Z),Z}},this.drawImage=function(f){f instanceof j&&(f=f.Lf());var w=this.jf();if(arguments.length===3||arguments.length===5)var M=e.XYWHRect(arguments[1],arguments[2],arguments[3]||f.width(),arguments[4]||f.height()),k=e.XYWHRect(0,0,f.width(),f.height());else if(arguments.length===9)M=e.XYWHRect(arguments[5],arguments[6],arguments[7],arguments[8]),k=e.XYWHRect(arguments[1],arguments[2],arguments[3],arguments[4]);else throw"invalid number of args for drawImage, need 3, 5, or 9; got "+arguments.length;this.ce.drawImageRect(f,k,M,w,!1),w.dispose()},this.ellipse=function(f,w,M,k,D,B,Z,pt){I(this.he,f,w,M,k,D,B,Z,pt)},this.jf=function(){var f=this.fe.copy();if(f.setStyle(e.PaintStyle.Fill),l(this.se)){var w=e.multiplyByAlpha(this.se,this.Be);f.setColor(w)}else w=this.se.Me(this.je),f.setColor(e.Color(0,0,0,this.Be)),f.setShader(w);return f.dispose=function(){this.delete()},f},this.fill=function(f,w){if(typeof f=="string"?(w=f,f=this.he):f&&f.vf&&(f=f.le),w==="evenodd")this.he.setFillType(e.FillType.EvenOdd);else{if(w!=="nonzero"&&w)throw"invalid fill rule";this.he.setFillType(e.FillType.Winding)}f||(f=this.he),w=this.jf();var M=this.Re(w);M&&(this.ce.save(),this.Ke(),this.ce.drawPath(f,M),this.ce.restore(),M.dispose()),this.ce.drawPath(f,w),w.dispose()},this.fillRect=function(f,w,M,k){var D=this.jf(),B=this.Re(D);B&&(this.ce.save(),this.Ke(),this.ce.drawRect(e.XYWHRect(f,w,M,k),B),this.ce.restore(),B.dispose()),this.ce.drawRect(e.XYWHRect(f,w,M,k),D),D.dispose()},this.fillText=function(f,w,M){var k=this.jf();f=e.TextBlob.MakeFromText(f,this.Fe);var D=this.Re(k);D&&(this.ce.save(),this.Ke(),this.ce.drawTextBlob(f,w,M,D),this.ce.restore(),D.dispose()),this.ce.drawTextBlob(f,w,M,k),f.delete(),k.dispose()},this.getImageData=function(f,w,M,k){return(f=this.ce.readPixels(f,w,{width:M,height:k,colorType:e.ColorType.RGBA_8888,alphaType:e.AlphaType.Unpremul,colorSpace:e.ColorSpace.SRGB}))?new tt(new Uint8ClampedArray(f.buffer),M,k):null},this.getLineDash=function(){return this.Ne.slice()},this.Gf=function(f){var w=e.Matrix.invert(this.je);return e.Matrix.mapPoints(w,f),f},this.isPointInPath=function(f,w,M){var k=arguments;if(k.length===3)var D=this.he;else if(k.length===4)D=k[0],f=k[1],w=k[2],M=k[3];else throw"invalid arg count, need 3 or 4, got "+k.length;return!isFinite(f)||!isFinite(w)||(M=M||"nonzero",M!=="nonzero"&&M!=="evenodd")?!1:(k=this.Gf([f,w]),f=k[0],w=k[1],D.setFillType(M==="nonzero"?e.FillType.Winding:e.FillType.EvenOdd),D.contains(f,w))},this.isPointInStroke=function(f,w){var M=arguments;if(M.length===2)var k=this.he;else if(M.length===3)k=M[0],f=M[1],w=M[2];else throw"invalid arg count, need 2 or 3, got "+M.length;return!isFinite(f)||!isFinite(w)?!1:(M=this.Gf([f,w]),f=M[0],w=M[1],k=k.copy(),k.setFillType(e.FillType.Winding),k.stroke({width:this.lineWidth,miter_limit:this.miterLimit,cap:this.fe.getStrokeCap(),join:this.fe.getStrokeJoin(),precision:.3}),M=k.contains(f,w),k.delete(),M)},this.lineTo=function(f,w){ct(this.he,f,w)},this.measureText=function(f){f=this.Fe.getGlyphIDs(f),f=this.Fe.getGlyphWidths(f);let w=0;for(const M of f)w+=M;return{width:w}},this.moveTo=function(f,w){var M=this.he;o([f,w])&&M.moveTo(f,w)},this.putImageData=function(f,w,M,k,D,B,Z){if(o([w,M,k,D,B,Z])){if(k===void 0)this.ce.writePixels(f.data,f.width,f.height,w,M);else if(k=k||0,D=D||0,B=B||f.width,Z=Z||f.height,0>B&&(k+=B,B=Math.abs(B)),0>Z&&(D+=Z,Z=Math.abs(Z)),0>k&&(B+=k,k=0),0>D&&(Z+=D,D=0),!(0>=B||0>=Z)){f=e.MakeImage({width:f.width,height:f.height,alphaType:e.AlphaType.Unpremul,colorType:e.ColorType.RGBA_8888,colorSpace:e.ColorSpace.SRGB},f.data,4*f.width);var pt=e.XYWHRect(k,D,B,Z);w=e.XYWHRect(w+k,M+D,B,Z),M=e.Matrix.invert(this.je),this.ce.save(),this.ce.concat(M),this.ce.drawImageRect(f,pt,w,null,!1),this.ce.restore(),f.delete()}}},this.quadraticCurveTo=function(f,w,M,k){var D=this.he;o([f,w,M,k])&&(D.isEmpty()&&D.moveTo(f,w),D.quadTo(f,w,M,k))},this.rect=function(f,w,M,k){var D=this.he;f=e.XYWHRect(f,w,M,k),o(f)&&D.addRect(f)},this.resetTransform=function(){this.he.transform(this.je);var f=e.Matrix.invert(this.je);this.ce.concat(f),this.je=this.ce.getTotalMatrix()},this.restore=function(){var f=this.Ff.pop();if(f){var w=e.Matrix.multiply(this.je,e.Matrix.invert(f.ag));this.he.transform(w),this.fe.delete(),this.fe=f.sg,this.Ne=f.qg,this.bf=f.Eg,this.ye=f.Dg,this.se=f.fs,this.Pe=f.Bg,this.Qe=f.Cg,this.Oe=f.sb,this.af=f.Ag,this.Be=f.ga,this.ee=f.hg,this.$e=f.rg,this.kf=f.gg,this.ce.restore(),this.je=this.ce.getTotalMatrix()}},this.rotate=function(f){if(isFinite(f)){var w=e.Matrix.rotated(-f);this.he.transform(w),this.ce.rotate(f/Math.PI*180,0,0),this.je=this.ce.getTotalMatrix()}},this.save=function(){if(this.se.Le){var f=this.se.Le();this.Ue.push(f)}else f=this.se;if(this.ye.Le){var w=this.ye.Le();this.Ue.push(w)}else w=this.ye;this.Ff.push({ag:this.je.slice(),qg:this.Ne.slice(),Eg:this.bf,Dg:w,fs:f,Bg:this.Pe,Cg:this.Qe,sb:this.Oe,Ag:this.af,ga:this.Be,rg:this.$e,hg:this.ee,sg:this.fe.copy(),gg:this.kf}),this.ce.save()},this.scale=function(f,w){if(o(arguments)){var M=e.Matrix.scaled(1/f,1/w);this.he.transform(M),this.ce.scale(f,w),this.je=this.ce.getTotalMatrix()}},this.setLineDash=function(f){for(var w=0;w<f.length;w++)if(!isFinite(f[w])||0>f[w])return;f.length%2===1&&Array.prototype.push.apply(f,f),this.Ne=f},this.setTransform=function(f,w,M,k,D,B){o(arguments)&&(this.resetTransform(),this.transform(f,w,M,k,D,B))},this.Ke=function(){var f=e.Matrix.invert(this.je);this.ce.concat(f),this.ce.concat(e.Matrix.translated(this.Pe,this.Qe)),this.ce.concat(this.je)},this.Re=function(f){var w=e.multiplyByAlpha(this.af,this.Be);if(!e.getColorComponents(w)[3]||!(this.Oe||this.Qe||this.Pe))return null;f=f.copy(),f.setColor(w);var M=e.MaskFilter.MakeBlur(e.BlurStyle.Normal,this.Oe/2,!1);return f.setMaskFilter(M),f.dispose=function(){M.delete(),this.delete()},f},this.xf=function(){var f=this.fe.copy();if(f.setStyle(e.PaintStyle.Stroke),l(this.ye)){var w=e.multiplyByAlpha(this.ye,this.Be);f.setColor(w)}else w=this.ye.Me(this.je),f.setColor(e.Color(0,0,0,this.Be)),f.setShader(w);if(f.setStrokeWidth(this.bf),this.Ne.length){var M=e.PathEffect.MakeDash(this.Ne,this.$e);f.setPathEffect(M)}return f.dispose=function(){M&&M.delete(),this.delete()},f},this.stroke=function(f){f=f?f.le:this.he;var w=this.xf(),M=this.Re(w);M&&(this.ce.save(),this.Ke(),this.ce.drawPath(f,M),this.ce.restore(),M.dispose()),this.ce.drawPath(f,w),w.dispose()},this.strokeRect=function(f,w,M,k){var D=this.xf(),B=this.Re(D);B&&(this.ce.save(),this.Ke(),this.ce.drawRect(e.XYWHRect(f,w,M,k),B),this.ce.restore(),B.dispose()),this.ce.drawRect(e.XYWHRect(f,w,M,k),D),D.dispose()},this.strokeText=function(f,w,M){var k=this.xf();f=e.TextBlob.MakeFromText(f,this.Fe);var D=this.Re(k);D&&(this.ce.save(),this.Ke(),this.ce.drawTextBlob(f,w,M,D),this.ce.restore(),D.dispose()),this.ce.drawTextBlob(f,w,M,k),f.delete(),k.dispose()},this.translate=function(f,w){if(o(arguments)){var M=e.Matrix.translated(-f,-w);this.he.transform(M),this.ce.translate(f,w),this.je=this.ce.getTotalMatrix()}},this.transform=function(f,w,M,k,D,B){f=[f,M,D,w,k,B,0,0,1],w=e.Matrix.invert(f),this.he.transform(w),this.ce.concat(f),this.je=this.ce.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 N($){this.yf=$,this.be=new E($.getCanvas()),this.lf=[],this.decodeImage=function(f){if(f=e.MakeImageFromEncoded(f),!f)throw"Invalid input";return this.lf.push(f),new j(f)},this.loadFont=function(f,w){if(f=e.Typeface.MakeTypefaceFromData(f),!f)return null;this.lf.push(f);var M=(w.style||"normal")+"|"+(w.variant||"normal")+"|"+(w.weight||"normal");w=w.family,P(),Tt[w]||(Tt[w]={"*":f}),Tt[w][M]=f},this.makePath2D=function(f){return f=new Ct(f),this.lf.push(f.le),f},this.getContext=function(f){return f==="2d"?this.be:null},this.toDataURL=function(f,w){this.yf.flush();var M=this.yf.makeImageSnapshot();if(M){f=f||"image/png";var k=e.ImageFormat.PNG;if(f==="image/jpeg"&&(k=e.ImageFormat.JPEG),w=M.encodeToBytes(k,w||.92)){if(M.delete(),f="data:"+f+";base64,",typeof Buffer<"u")w=Buffer.from(w).toString("base64");else{M=0,k=w.length;for(var D="",B;M<k;)B=w.slice(M,Math.min(M+32768,k)),D+=String.fromCharCode.apply(null,B),M+=32768;w=btoa(D)}return f+w}}},this.dispose=function(){this.be.Ee(),this.lf.forEach(function(f){f.delete()}),this.yf.dispose()}}function j($){this.width=$.width(),this.height=$.height(),this.naturalWidth=this.width,this.naturalHeight=this.height,this.Lf=function(){return $}}function tt($,f,w){if(!f||w===0)throw new TypeError("invalid dimensions, width and height must be non-zero");if($.length%4)throw new TypeError("arr must be a multiple of 4");w=w||$.length/(4*f),Object.defineProperty(this,"data",{value:$,writable:!1}),Object.defineProperty(this,"height",{value:w,writable:!1}),Object.defineProperty(this,"width",{value:f,writable:!1})}function et($,f,w,M){this.ne=null,this.ue=[],this.qe=[],this.addColorStop=function(k,D){if(0>k||1<k||!isFinite(k))throw"offset must be between 0 and 1 inclusively";D=u(D);var B=this.qe.indexOf(k);if(B!==-1)this.ue[B]=D;else{for(B=0;B<this.qe.length&&!(this.qe[B]>k);B++);this.qe.splice(B,0,k),this.ue.splice(B,0,D)}},this.Le=function(){var k=new et($,f,w,M);return k.ue=this.ue.slice(),k.qe=this.qe.slice(),k},this.Ee=function(){this.ne&&(this.ne.delete(),this.ne=null)},this.Me=function(k){var D=[$,f,w,M];e.Matrix.mapPoints(k,D),k=D[0];var B=D[1],Z=D[2];return D=D[3],this.Ee(),this.ne=e.Shader.MakeLinearGradient([k,B],[Z,D],this.ue,this.qe,e.TileMode.Clamp)}}function vt($,f,w,M,k,D){if(o([f,w,M,k,D])){if(0>D)throw"radii cannot be negative";$.isEmpty()&&$.moveTo(f,w),$.arcToTangent(f,w,M,k,D)}}function bt($){if(!$.isEmpty()){var f=$.getBounds();(f[3]-f[1]||f[2]-f[0])&&$.close()}}function b($,f,w,M,k,D,B){B=(B-D)/Math.PI*180,D=D/Math.PI*180,f=e.LTRBRect(f-M,w-k,f+M,w+k),1e-5>Math.abs(Math.abs(B)-360)?(w=B/2,$.arcToOval(f,D,w,!1),$.arcToOval(f,D+w,w,!1)):$.arcToOval(f,D,B,!1)}function I($,f,w,M,k,D,B,Z,pt){if(o([f,w,M,k,D,B,Z])){if(0>M||0>k)throw"radii cannot be negative";var $t=2*Math.PI,je=B%$t;0>je&&(je+=$t);var ci=je-B;B=je,Z+=ci,!pt&&Z-B>=$t?Z=B+$t:pt&&B-Z>=$t?Z=B-$t:!pt&&B>Z?Z=B+($t-(B-Z)%$t):pt&&B<Z&&(Z=B-($t-(Z-B)%$t)),D?(pt=e.Matrix.rotated(D,f,w),D=e.Matrix.rotated(-D,f,w),$.transform(D),b($,f,w,M,k,B,Z),$.transform(pt)):b($,f,w,M,k,B,Z)}}function ct($,f,w){o([f,w])&&($.isEmpty()&&$.moveTo(f,w),$.lineTo(f,w))}function Ct($){this.le=null,this.le=typeof $=="string"?e.Path.MakeFromSVGString($):$&&$.vf?$.le.copy():new e.Path,this.vf=function(){return this.le},this.addPath=function(f,w){w||(w={a:1,c:0,e:0,b:0,d:1,f:0}),this.le.addPath(f.le,[w.a,w.c,w.e,w.b,w.d,w.f])},this.arc=function(f,w,M,k,D,B){I(this.le,f,w,M,M,0,k,D,B)},this.arcTo=function(f,w,M,k,D){vt(this.le,f,w,M,k,D)},this.bezierCurveTo=function(f,w,M,k,D,B){var Z=this.le;o([f,w,M,k,D,B])&&(Z.isEmpty()&&Z.moveTo(f,w),Z.cubicTo(f,w,M,k,D,B))},this.closePath=function(){bt(this.le)},this.ellipse=function(f,w,M,k,D,B,Z,pt){I(this.le,f,w,M,k,D,B,Z,pt)},this.lineTo=function(f,w){ct(this.le,f,w)},this.moveTo=function(f,w){var M=this.le;o([f,w])&&M.moveTo(f,w)},this.quadraticCurveTo=function(f,w,M,k){var D=this.le;o([f,w,M,k])&&(D.isEmpty()&&D.moveTo(f,w),D.quadTo(f,w,M,k))},this.rect=function(f,w,M,k){var D=this.le;f=e.XYWHRect(f,w,M,k),o(f)&&D.addRect(f)}}function kt($,f){switch(this.ne=null,$ instanceof j&&($=$.Lf()),this.Uf=$,this._transform=e.Matrix.identity(),f===""&&(f="repeat"),f){case"repeat-x":this.Se=e.TileMode.Repeat,this.Te=e.TileMode.Decal;break;case"repeat-y":this.Se=e.TileMode.Decal,this.Te=e.TileMode.Repeat;break;case"repeat":this.Te=this.Se=e.TileMode.Repeat;break;case"no-repeat":this.Te=this.Se=e.TileMode.Decal;break;default:throw"invalid repetition mode "+f}this.setTransform=function(w){w=[w.a,w.c,w.e,w.b,w.d,w.f,0,0,1],o(w)&&(this._transform=w)},this.Le=function(){var w=new kt;return w.Se=this.Se,w.Te=this.Te,w},this.Ee=function(){this.ne&&(this.ne.delete(),this.ne=null)},this.Me=function(){return this.Ee(),this.ne=this.Uf.makeShaderCubic(this.Se,this.Te,.3333333333333333,.3333333333333333,this._transform)}}function Xt($,f,w,M,k,D){this.ne=null,this.ue=[],this.qe=[],this.addColorStop=function(B,Z){if(0>B||1<B||!isFinite(B))throw"offset must be between 0 and 1 inclusively";Z=u(Z);var pt=this.qe.indexOf(B);if(pt!==-1)this.ue[pt]=Z;else{for(pt=0;pt<this.qe.length&&!(this.qe[pt]>B);pt++);this.qe.splice(pt,0,B),this.ue.splice(pt,0,Z)}},this.Le=function(){var B=new Xt($,f,w,M,k,D);return B.ue=this.ue.slice(),B.qe=this.qe.slice(),B},this.Ee=function(){this.ne&&(this.ne.delete(),this.ne=null)},this.Me=function(B){var Z=[$,f,M,k];e.Matrix.mapPoints(B,Z);var pt=Z[0],$t=Z[1],je=Z[2];Z=Z[3];var ci=(Math.abs(B[0])+Math.abs(B[4]))/2;return B=w*ci,ci*=D,this.Ee(),this.ne=e.Shader.MakeTwoPointConicalGradient([pt,$t],B,[je,Z],ci,this.ue,this.qe,e.TileMode.Clamp)}}e._testing={};var ie={aliceblue:Float32Array.of(.941,.973,1,1),antiquewhite:Float32Array.of(.98,.922,.843,1),aqua:Float32Array.of(0,1,1,1),aquamarine:Float32Array.of(.498,1,.831,1),azure:Float32Array.of(.941,1,1,1),beige:Float32Array.of(.961,.961,.863,1),bisque:Float32Array.of(1,.894,.769,1),black:Float32Array.of(0,0,0,1),blanchedalmond:Float32Array.of(1,.922,.804,1),blue:Float32Array.of(0,0,1,1),blueviolet:Float32Array.of(.541,.169,.886,1),brown:Float32Array.of(.647,.165,.165,1),burlywood:Float32Array.of(.871,.722,.529,1),cadetblue:Float32Array.of(.373,.62,.627,1),chartreuse:Float32Array.of(.498,1,0,1),chocolate:Float32Array.of(.824,.412,.118,1),coral:Float32Array.of(1,.498,.314,1),cornflowerblue:Float32Array.of(.392,.584,.929,1),cornsilk:Float32Array.of(1,.973,.863,1),crimson:Float32Array.of(.863,.078,.235,1),cyan:Float32Array.of(0,1,1,1),darkblue:Float32Array.of(0,0,.545,1),darkcyan:Float32Array.of(0,.545,.545,1),darkgoldenrod:Float32Array.of(.722,.525,.043,1),darkgray:Float32Array.of(.663,.663,.663,1),darkgreen:Float32Array.of(0,.392,0,1),darkgrey:Float32Array.of(.663,.663,.663,1),darkkhaki:Float32Array.of(.741,.718,.42,1),darkmagenta:Float32Array.of(.545,0,.545,1),darkolivegreen:Float32Array.of(.333,.42,.184,1),darkorange:Float32Array.of(1,.549,0,1),darkorchid:Float32Array.of(.6,.196,.8,1),darkred:Float32Array.of(.545,0,0,1),darksalmon:Float32Array.of(.914,.588,.478,1),darkseagreen:Float32Array.of(.561,.737,.561,1),darkslateblue:Float32Array.of(.282,.239,.545,1),darkslategray:Float32Array.of(.184,.31,.31,1),darkslategrey:Float32Array.of(.184,.31,.31,1),darkturquoise:Float32Array.of(0,.808,.82,1),darkviolet:Float32Array.of(.58,0,.827,1),deeppink:Float32Array.of(1,.078,.576,1),deepskyblue:Float32Array.of(0,.749,1,1),dimgray:Float32Array.of(.412,.412,.412,1),dimgrey:Float32Array.of(.412,.412,.412,1),dodgerblue:Float32Array.of(.118,.565,1,1),firebrick:Float32Array.of(.698,.133,.133,1),floralwhite:Float32Array.of(1,.98,.941,1),forestgreen:Float32Array.of(.133,.545,.133,1),fuchsia:Float32Array.of(1,0,1,1),gainsboro:Float32Array.of(.863,.863,.863,1),ghostwhite:Float32Array.of(.973,.973,1,1),gold:Float32Array.of(1,.843,0,1),goldenrod:Float32Array.of(.855,.647,.125,1),gray:Float32Array.of(.502,.502,.502,1),green:Float32Array.of(0,.502,0,1),greenyellow:Float32Array.of(.678,1,.184,1),grey:Float32Array.of(.502,.502,.502,1),honeydew:Float32Array.of(.941,1,.941,1),hotpink:Float32Array.of(1,.412,.706,1),indianred:Float32Array.of(.804,.361,.361,1),indigo:Float32Array.of(.294,0,.51,1),ivory:Float32Array.of(1,1,.941,1),khaki:Float32Array.of(.941,.902,.549,1),lavender:Float32Array.of(.902,.902,.98,1),lavenderblush:Float32Array.of(1,.941,.961,1),lawngreen:Float32Array.of(.486,.988,0,1),lemonchiffon:Float32Array.of(1,.98,.804,1),lightblue:Float32Array.of(.678,.847,.902,1),lightcoral:Float32Array.of(.941,.502,.502,1),lightcyan:Float32Array.of(.878,1,1,1),lightgoldenrodyellow:Float32Array.of(.98,.98,.824,1),lightgray:Float32Array.of(.827,.827,.827,1),lightgreen:Float32Array.of(.565,.933,.565,1),lightgrey:Float32Array.of(.827,.827,.827,1),lightpink:Float32Array.of(1,.714,.757,1),lightsalmon:Float32Array.of(1,.627,.478,1),lightseagreen:Float32Array.of(.125,.698,.667,1),lightskyblue:Float32Array.of(.529,.808,.98,1),lightslategray:Float32Array.of(.467,.533,.6,1),lightslategrey:Float32Array.of(.467,.533,.6,1),lightsteelblue:Float32Array.of(.69,.769,.871,1),lightyellow:Float32Array.of(1,1,.878,1),lime:Float32Array.of(0,1,0,1),limegreen:Float32Array.of(.196,.804,.196,1),linen:Float32Array.of(.98,.941,.902,1),magenta:Float32Array.of(1,0,1,1),maroon:Float32Array.of(.502,0,0,1),mediumaquamarine:Float32Array.of(.4,.804,.667,1),mediumblue:Float32Array.of(0,0,.804,1),mediumorchid:Float32Array.of(.729,.333,.827,1),mediumpurple:Float32Array.of(.576,.439,.859,1),mediumseagreen:Float32Array.of(.235,.702,.443,1),mediumslateblue:Float32Array.of(.482,.408,.933,1),mediumspringgreen:Float32Array.of(0,.98,.604,1),mediumturquoise:Float32Array.of(.282,.82,.8,1),mediumvioletred:Float32Array.of(.78,.082,.522,1),midnightblue:Float32Array.of(.098,.098,.439,1),mintcream:Float32Array.of(.961,1,.98,1),mistyrose:Float32Array.of(1,.894,.882,1),moccasin:Float32Array.of(1,.894,.71,1),navajowhite:Float32Array.of(1,.871,.678,1),navy:Float32Array.of(0,0,.502,1),oldlace:Float32Array.of(.992,.961,.902,1),olive:Float32Array.of(.502,.502,0,1),olivedrab:Float32Array.of(.42,.557,.137,1),orange:Float32Array.of(1,.647,0,1),orangered:Float32Array.of(1,.271,0,1),orchid:Float32Array.of(.855,.439,.839,1),palegoldenrod:Float32Array.of(.933,.91,.667,1),palegreen:Float32Array.of(.596,.984,.596,1),paleturquoise:Float32Array.of(.686,.933,.933,1),palevioletred:Float32Array.of(.859,.439,.576,1),papayawhip:Float32Array.of(1,.937,.835,1),peachpuff:Float32Array.of(1,.855,.725,1),peru:Float32Array.of(.804,.522,.247,1),pink:Float32Array.of(1,.753,.796,1),plum:Float32Array.of(.867,.627,.867,1),powderblue:Float32Array.of(.69,.878,.902,1),purple:Float32Array.of(.502,0,.502,1),rebeccapurple:Float32Array.of(.4,.2,.6,1),red:Float32Array.of(1,0,0,1),rosybrown:Float32Array.of(.737,.561,.561,1),royalblue:Float32Array.of(.255,.412,.882,1),saddlebrown:Float32Array.of(.545,.271,.075,1),salmon:Float32Array.of(.98,.502,.447,1),sandybrown:Float32Array.of(.957,.643,.376,1),seagreen:Float32Array.of(.18,.545,.341,1),seashell:Float32Array.of(1,.961,.933,1),sienna:Float32Array.of(.627,.322,.176,1),silver:Float32Array.of(.753,.753,.753,1),skyblue:Float32Array.of(.529,.808,.922,1),slateblue:Float32Array.of(.416,.353,.804,1),slategray:Float32Array.of(.439,.502,.565,1),slategrey:Float32Array.of(.439,.502,.565,1),snow:Float32Array.of(1,.98,.98,1),springgreen:Float32Array.of(0,1,.498,1),steelblue:Float32Array.of(.275,.51,.706,1),tan:Float32Array.of(.824,.706,.549,1),teal:Float32Array.of(0,.502,.502,1),thistle:Float32Array.of(.847,.749,.847,1),tomato:Float32Array.of(1,.388,.278,1),transparent:Float32Array.of(0,0,0,0),turquoise:Float32Array.of(.251,.878,.816,1),violet:Float32Array.of(.933,.51,.933,1),wheat:Float32Array.of(.961,.871,.702,1),white:Float32Array.of(1,1,1,1),whitesmoke:Float32Array.of(.961,.961,.961,1),yellow:Float32Array.of(1,1,0,1),yellowgreen:Float32Array.of(.604,.804,.196,1)};e._testing.parseColor=u,e._testing.colorToString=a;var de=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)(.+)"),Tt;e._testing.parseFontString=p,e.MakeCanvas=function($,f){return($=e.MakeSurface($,f))?new N($):null},e.ImageData=function(){if(arguments.length===2){var $=arguments[0],f=arguments[1];return new tt(new Uint8ClampedArray(4*$*f),$,f)}if(arguments.length===3){var w=arguments[0];if(w.prototype.constructor!==Uint8ClampedArray)throw new TypeError("bytes must be given as a Uint8ClampedArray");if($=arguments[1],f=arguments[2],w%4)throw new TypeError("bytes must be given in a multiple of 4");if(w%$)throw new TypeError("bytes must divide evenly by width");if(f&&f!==w/(4*$))throw new TypeError("invalid height given");return new tt(w,$,w/(4*$))}throw new TypeError("invalid number of arguments - takes 2 or 3, saw "+arguments.length)}}()}(c);var z=Object.assign({},c),G="./this.program",q=(e,n)=>{throw n},st=typeof window=="object",lt=typeof importScripts=="function",yt=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",rt="",Et,Wt,Bt;if(yt){var se=va,U=Aa;rt=lt?U.dirname(rt)+"/":__dirname+"/",Et=(e,n)=>(e=e.startsWith("file://")?new URL(e):U.normalize(e),se.readFileSync(e,n?void 0:"utf8")),Bt=e=>(e=Et(e,!0),e.buffer||(e=new Uint8Array(e)),e),Wt=(e,n,s,l=!0)=>{e=e.startsWith("file://")?new URL(e):U.normalize(e),se.readFile(e,l?void 0:"utf8",(d,g)=>{d?s(d):n(l?g.buffer:g)})},!c.thisProgram&&1<process.argv.length&&(G=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),q=(e,n)=>{throw process.exitCode=e,n},c.inspect=()=>"[Emscripten Module object]"}else(st||lt)&&(lt?rt=self.location.href:typeof document<"u"&&document.currentScript&&(rt=document.currentScript.src),r&&(rt=r),rt.indexOf("blob:")!==0?rt=rt.substr(0,rt.replace(/[?#].*/,"").lastIndexOf("/")+1):rt="",Et=e=>{var n=new XMLHttpRequest;return n.open("GET",e,!1),n.send(null),n.responseText},lt&&(Bt=e=>{var n=new XMLHttpRequest;return n.open("GET",e,!1),n.responseType="arraybuffer",n.send(null),new Uint8Array(n.response)}),Wt=(e,n,s)=>{var l=new XMLHttpRequest;l.open("GET",e,!0),l.responseType="arraybuffer",l.onload=()=>{l.status==200||l.status==0&&l.response?n(l.response):s()},l.onerror=s,l.send(null)});var ut=c.print||console.log.bind(console),Pe=c.printErr||console.error.bind(console);Object.assign(c,z),z=null,c.thisProgram&&(G=c.thisProgram),c.quit&&(q=c.quit);var qe;c.wasmBinary&&(qe=c.wasmBinary),c.noExitRuntime,typeof WebAssembly!="object"&&Gi("no native wasm support detected");var gi,Pt,Cn=!1,pe,ft,Ae,Be,W,_t,it,Tn;function _n(){var e=gi.buffer;c.HEAP8=pe=new Int8Array(e),c.HEAP16=Ae=new Int16Array(e),c.HEAP32=W=new Int32Array(e),c.HEAPU8=ft=new Uint8Array(e),c.HEAPU16=Be=new Uint16Array(e),c.HEAPU32=_t=new Uint32Array(e),c.HEAPF32=it=new Float32Array(e),c.HEAPF64=Tn=new Float64Array(e)}var Mt,En=[],xn=[],Fn=[];function os(){var e=c.preRun.shift();En.unshift(e)}var xe=0,Ye=null;function Gi(e){throw c.onAbort&&c.onAbort(e),e="Aborted("+e+")",Pe(e),Cn=!0,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),x(e),e}function Mn(e){return e.startsWith("data:application/octet-stream;base64,")}var Ue;if(Ue="canvaskit.wasm",!Mn(Ue)){var Rn=Ue;Ue=c.locateFile?c.locateFile(Rn,rt):rt+Rn}function kn(e){if(e==Ue&&qe)return new Uint8Array(qe);if(Bt)return Bt(e);throw"both async and sync fetching of the wasm failed"}function ls(e){if(!qe&&(st||lt)){if(typeof fetch=="function"&&!e.startsWith("file://"))return fetch(e,{credentials:"same-origin"}).then(n=>{if(!n.ok)throw"failed to load wasm binary file at '"+e+"'";return n.arrayBuffer()}).catch(()=>kn(e));if(Wt)return new Promise((n,s)=>{Wt(e,l=>n(new Uint8Array(l)),s)})}return Promise.resolve().then(()=>kn(e))}function Nn(e,n,s){return ls(e).then(l=>WebAssembly.instantiate(l,n)).then(l=>l).then(s,l=>{Pe("failed to asynchronously prepare wasm: "+l),Gi(l)})}function hs(e,n){var s=Ue;return qe||typeof WebAssembly.instantiateStreaming!="function"||Mn(s)||s.startsWith("file://")||yt||typeof fetch!="function"?Nn(s,e,n):fetch(s,{credentials:"same-origin"}).then(l=>WebAssembly.instantiateStreaming(l,e).then(n,function(d){return Pe("wasm streaming compile failed: "+d),Pe("falling back to ArrayBuffer instantiation"),Nn(s,e,n)}))}function cs(e){this.name="ExitStatus",this.message=`Program terminated with exit(${e})`,this.status=e}var Wi=e=>{for(;0<e.length;)e.shift()(c)},In=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Fe=(e,n,s)=>{var l=n+s;for(s=n;e[s]&&!(s>=l);)++s;if(16<s-n&&e.buffer&&In)return In.decode(e.subarray(n,s));for(l="";n<s;){var d=e[n++];if(d&128){var g=e[n++]&63;if((d&224)==192)l+=String.fromCharCode((d&31)<<6|g);else{var A=e[n++]&63;d=(d&240)==224?(d&15)<<12|g<<6|A:(d&7)<<18|g<<12|A<<6|e[n++]&63,65536>d?l+=String.fromCharCode(d):(d-=65536,l+=String.fromCharCode(55296|d>>10,56320|d&1023))}}else l+=String.fromCharCode(d)}return l},mi={};function ji(e){for(;e.length;){var n=e.pop();e.pop()(n)}}function Xe(e){return this.fromWireType(W[e>>2])}var $e={},Me={},yi={},On=void 0;function vi(e){throw new On(e)}function ae(e,n,s){function l(y){y=s(y),y.length!==e.length&&vi("Mismatched type converter count");for(var v=0;v<e.length;++v)ge(e[v],y[v])}e.forEach(function(y){yi[y]=n});var d=Array(n.length),g=[],A=0;n.forEach((y,v)=>{Me.hasOwnProperty(y)?d[v]=Me[y]:(g.push(y),$e.hasOwnProperty(y)||($e[y]=[]),$e[y].push(()=>{d[v]=Me[y],++A,A===g.length&&l(d)}))}),g.length===0&&l(d)}function wi(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError(`Unknown type size: ${e}`)}}var Dn=void 0;function Ft(e){for(var n="";ft[e];)n+=Dn[ft[e++]];return n}var Ge=void 0;function wt(e){throw new Ge(e)}function us(e,n,s={}){var l=n.name;if(e||wt(`type "${l}" must have a positive integer typeid pointer`),Me.hasOwnProperty(e)){if(s.ng)return;wt(`Cannot register type '${l}' twice`)}Me[e]=n,delete yi[e],$e.hasOwnProperty(e)&&(n=$e[e],delete $e[e],n.forEach(d=>d()))}function ge(e,n,s={}){if(!("argPackAdvance"in n))throw new TypeError("registerType registeredInstance requires argPackAdvance");us(e,n,s)}function Hi(e){wt(e.ae.me.ge.name+" instance already deleted")}var Ki=!1;function zn(){}function Ln(e){--e.count.value,e.count.value===0&&(e.pe?e.we.De(e.pe):e.me.ge.De(e.ie))}function Bn(e,n,s){return n===s?e:s.re===void 0?null:(e=Bn(e,n,s.re),e===null?null:s.dg(e))}var Un={},Je=[];function Vi(){for(;Je.length;){var e=Je.pop();e.ae.Xe=!1,e.delete()}}var Qe=void 0,Ze={};function ds(e,n){for(n===void 0&&wt("ptr should not be undefined");e.re;)n=e.gf(n),e=e.re;return Ze[n]}function Si(e,n){return n.me&&n.ie||vi("makeClassHandle requires ptr and ptrType"),!!n.we!=!!n.pe&&vi("Both smartPtrType and smartPtr must be specified"),n.count={value:1},ti(Object.create(e,{ae:{value:n}}))}function ti(e){return typeof FinalizationRegistry>"u"?(ti=n=>n,e):(Ki=new FinalizationRegistry(n=>{Ln(n.ae)}),ti=n=>{var s=n.ae;return s.pe&&Ki.register(n,{ae:s},n),n},zn=n=>{Ki.unregister(n)},ti(e))}function Ce(){}function $n(e){if(e===void 0)return"_unknown";e=e.replace(/[^a-zA-Z0-9_]/g,"$");var n=e.charCodeAt(0);return 48<=n&&57>=n?`_${e}`:e}function qi(e,n){return e=$n(e),{[e]:function(){return n.apply(this,arguments)}}[e]}function Yi(e,n,s){if(e[n].oe===void 0){var l=e[n];e[n]=function(){return e[n].oe.hasOwnProperty(arguments.length)||wt(`Function '${s}' called with an invalid number of arguments (${arguments.length}) - expects one of (${e[n].oe})!`),e[n].oe[arguments.length].apply(this,arguments)},e[n].oe=[],e[n].oe[l.Ve]=l}}function Xi(e,n,s){c.hasOwnProperty(e)?((s===void 0||c[e].oe!==void 0&&c[e].oe[s]!==void 0)&&wt(`Cannot register public name '${e}' twice`),Yi(c,e,e),c.hasOwnProperty(s)&&wt(`Cannot register multiple overloads of a function with the same number of arguments (${s})!`),c[e].oe[s]=n):(c[e]=n,s!==void 0&&(c[e].Lg=s))}function fs(e,n,s,l,d,g,A,y){this.name=e,this.constructor=n,this.Ye=s,this.De=l,this.re=d,this.ig=g,this.gf=A,this.dg=y,this.ug=[]}function Ji(e,n,s){for(;n!==s;)n.gf||wt(`Expected null or instance of ${s.name}, got an instance of ${n.name}`),e=n.gf(e),n=n.re;return e}function ps(e,n){return n===null?(this.Bf&&wt(`null is not a valid ${this.name}`),0):(n.ae||wt(`Cannot pass "${Zi(n)}" as a ${this.name}`),n.ae.ie||wt(`Cannot pass deleted object as a pointer of type ${this.name}`),Ji(n.ae.ie,n.ae.me.ge,this.ge))}function gs(e,n){if(n===null){if(this.Bf&&wt(`null is not a valid ${this.name}`),this.pf){var s=this.Cf();return e!==null&&e.push(this.De,s),s}return 0}if(n.ae||wt(`Cannot pass "${Zi(n)}" as a ${this.name}`),n.ae.ie||wt(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.nf&&n.ae.me.nf&&wt(`Cannot convert argument of type ${n.ae.we?n.ae.we.name:n.ae.me.name} to parameter type ${this.name}`),s=Ji(n.ae.ie,n.ae.me.ge,this.ge),this.pf)switch(n.ae.pe===void 0&&wt("Passing raw pointer to smart pointer is illegal"),this.zg){case 0:n.ae.we===this?s=n.ae.pe:wt(`Cannot convert argument of type ${n.ae.we?n.ae.we.name:n.ae.me.name} to parameter type ${this.name}`);break;case 1:s=n.ae.pe;break;case 2:if(n.ae.we===this)s=n.ae.pe;else{var l=n.clone();s=this.vg(s,te(function(){l.delete()})),e!==null&&e.push(this.De,s)}break;default:wt("Unsupporting sharing policy")}return s}function ms(e,n){return n===null?(this.Bf&&wt(`null is not a valid ${this.name}`),0):(n.ae||wt(`Cannot pass "${Zi(n)}" as a ${this.name}`),n.ae.ie||wt(`Cannot pass deleted object as a pointer of type ${this.name}`),n.ae.me.nf&&wt(`Cannot convert argument of type ${n.ae.me.name} to parameter type ${this.name}`),Ji(n.ae.ie,n.ae.me.ge,this.ge))}function me(e,n,s,l,d,g,A,y,v,T,O){this.name=e,this.ge=n,this.Bf=s,this.nf=l,this.pf=d,this.tg=g,this.zg=A,this.Nf=y,this.Cf=v,this.vg=T,this.De=O,d||n.re!==void 0?this.toWireType=gs:(this.toWireType=l?ps:ms,this.ve=null)}function Gn(e,n,s){c.hasOwnProperty(e)||vi("Replacing nonexistant public symbol"),c[e].oe!==void 0&&s!==void 0?c[e].oe[s]=n:(c[e]=n,c[e].Ve=s)}var ys=(e,n)=>{var s=[];return function(){if(s.length=0,Object.assign(s,arguments),e.includes("j")){var l=c["dynCall_"+e];l=s&&s.length?l.apply(null,[n].concat(s)):l.call(null,n)}else l=Mt.get(n).apply(null,s);return l}};function Ut(e,n){e=Ft(e);var s=e.includes("j")?ys(e,n):Mt.get(n);return typeof s!="function"&&wt(`unknown function pointer with signature ${e}: ${n}`),s}var Wn=void 0;function jn(e){e=Sr(e);var n=Ft(e);return we(e),n}function ei(e,n){function s(g){d[g]||Me[g]||(yi[g]?yi[g].forEach(s):(l.push(g),d[g]=!0))}var l=[],d={};throw n.forEach(s),new Wn(`${e}: `+l.map(jn).join([", "]))}function bi(e,n,s,l,d){var g=n.length;2>g&&wt("argTypes array size mismatch! Must at least get return value and 'this' types!");var A=n[1]!==null&&s!==null,y=!1;for(s=1;s<n.length;++s)if(n[s]!==null&&n[s].ve===void 0){y=!0;break}var v=n[0].name!=="void",T=g-2,O=Array(T),L=[],Y=[];return function(){if(arguments.length!==T&&wt(`function ${e} called with ${arguments.length} arguments, expected ${T} args!`),Y.length=0,L.length=A?2:1,L[0]=d,A){var F=n[1].toWireType(Y,this);L[1]=F}for(var J=0;J<T;++J)O[J]=n[J+2].toWireType(Y,arguments[J]),L.push(O[J]);if(J=l.apply(null,L),y)ji(Y);else for(var ht=A?1:2;ht<n.length;ht++){var ot=ht===1?F:O[ht-2];n[ht].ve!==null&&n[ht].ve(ot)}return F=v?n[0].fromWireType(J):void 0,F}}function Pi(e,n){for(var s=[],l=0;l<e;l++)s.push(_t[n+4*l>>2]);return s}function Hn(){this.Ce=[void 0],this.Kf=[]}var Qt=new Hn;function Qi(e){e>=Qt.df&&--Qt.get(e).Of===0&&Qt.Zf(e)}var Zt=e=>(e||wt("Cannot use deleted val. handle = "+e),Qt.get(e).value),te=e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return Qt.Yf({Of:1,value:e})}};function vs(e,n,s){switch(n){case 0:return function(l){return this.fromWireType((s?pe:ft)[l])};case 1:return function(l){return this.fromWireType((s?Ae:Be)[l>>1])};case 2:return function(l){return this.fromWireType((s?W:_t)[l>>2])};default:throw new TypeError("Unknown integer type: "+e)}}function ii(e,n){var s=Me[e];return s===void 0&&wt(n+" has unknown type "+jn(e)),s}function Zi(e){if(e===null)return"null";var n=typeof e;return n==="object"||n==="array"||n==="function"?e.toString():""+e}function ws(e,n){switch(n){case 2:return function(s){return this.fromWireType(it[s>>2])};case 3:return function(s){return this.fromWireType(Tn[s>>3])};default:throw new TypeError("Unknown float type: "+e)}}function Ss(e,n,s){switch(n){case 0:return s?function(l){return pe[l]}:function(l){return ft[l]};case 1:return s?function(l){return Ae[l>>1]}:function(l){return Be[l>>1]};case 2:return s?function(l){return W[l>>2]}:function(l){return _t[l>>2]};default:throw new TypeError("Unknown integer type: "+e)}}var oe=(e,n,s,l)=>{if(!(0<l))return 0;var d=s;l=s+l-1;for(var g=0;g<e.length;++g){var A=e.charCodeAt(g);if(55296<=A&&57343>=A){var y=e.charCodeAt(++g);A=65536+((A&1023)<<10)|y&1023}if(127>=A){if(s>=l)break;n[s++]=A}else{if(2047>=A){if(s+1>=l)break;n[s++]=192|A>>6}else{if(65535>=A){if(s+2>=l)break;n[s++]=224|A>>12}else{if(s+3>=l)break;n[s++]=240|A>>18,n[s++]=128|A>>12&63}n[s++]=128|A>>6&63}n[s++]=128|A&63}}return n[s]=0,s-d},le=e=>{for(var n=0,s=0;s<e.length;++s){var l=e.charCodeAt(s);127>=l?n++:2047>=l?n+=2:55296<=l&&57343>=l?(n+=4,++s):n+=3}return n},Kn=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,bs=(e,n)=>{for(var s=e>>1,l=s+n/2;!(s>=l)&&Be[s];)++s;if(s<<=1,32<s-e&&Kn)return Kn.decode(ft.subarray(e,s));for(s="",l=0;!(l>=n/2);++l){var d=Ae[e+2*l>>1];if(d==0)break;s+=String.fromCharCode(d)}return s},Ps=(e,n,s)=>{if(s===void 0&&(s=2147483647),2>s)return 0;s-=2;var l=n;s=s<2*e.length?s/2:e.length;for(var d=0;d<s;++d)Ae[n>>1]=e.charCodeAt(d),n+=2;return Ae[n>>1]=0,n-l},As=e=>2*e.length,Cs=(e,n)=>{for(var s=0,l="";!(s>=n/4);){var d=W[e+4*s>>2];if(d==0)break;++s,65536<=d?(d-=65536,l+=String.fromCharCode(55296|d>>10,56320|d&1023)):l+=String.fromCharCode(d)}return l},Ts=(e,n,s)=>{if(s===void 0&&(s=2147483647),4>s)return 0;var l=n;s=l+s-4;for(var d=0;d<e.length;++d){var g=e.charCodeAt(d);if(55296<=g&&57343>=g){var A=e.charCodeAt(++d);g=65536+((g&1023)<<10)|A&1023}if(W[n>>2]=g,n+=4,n+4>s)break}return W[n>>2]=0,n-l},_s=e=>{for(var n=0,s=0;s<e.length;++s){var l=e.charCodeAt(s);55296<=l&&57343>=l&&++s,n+=4}return n},Es={};function Ai(e){var n=Es[e];return n===void 0?Ft(e):n}var Ci=[];function Vn(){function e(n){n.$$$embind_global$$$=n;var s=typeof $$$embind_global$$$=="object"&&n.$$$embind_global$$$==n;return s||delete n.$$$embind_global$$$,s}if(typeof globalThis=="object")return globalThis;if(typeof $$$embind_global$$$=="object"||(typeof gn=="object"&&e(gn)?$$$embind_global$$$=gn:typeof self=="object"&&e(self)&&($$$embind_global$$$=self),typeof $$$embind_global$$$=="object"))return $$$embind_global$$$;throw Error("unable to get global object.")}function xs(e){var n=Ci.length;return Ci.push(e),n}function Fs(e,n){for(var s=Array(e),l=0;l<e;++l)s[l]=ii(_t[n+4*l>>2],"parameter "+l);return s}var qn=[];function Ms(e){var n=Array(e+1);return function(s,l,d){n[0]=s;for(var g=0;g<e;++g){var A=ii(_t[l+4*g>>2],"parameter "+g);n[g+1]=A.readValueFromPointer(d),d+=A.argPackAdvance}return s=new(s.bind.apply(s,n)),te(s)}}var Yn={};function Rs(e){var n=e.getExtension("ANGLE_instanced_arrays");n&&(e.vertexAttribDivisor=function(s,l){n.vertexAttribDivisorANGLE(s,l)},e.drawArraysInstanced=function(s,l,d,g){n.drawArraysInstancedANGLE(s,l,d,g)},e.drawElementsInstanced=function(s,l,d,g,A){n.drawElementsInstancedANGLE(s,l,d,g,A)})}function ks(e){var n=e.getExtension("OES_vertex_array_object");n&&(e.createVertexArray=function(){return n.createVertexArrayOES()},e.deleteVertexArray=function(s){n.deleteVertexArrayOES(s)},e.bindVertexArray=function(s){n.bindVertexArrayOES(s)},e.isVertexArray=function(s){return n.isVertexArrayOES(s)})}function Ns(e){var n=e.getExtension("WEBGL_draw_buffers");n&&(e.drawBuffers=function(s,l){n.drawBuffersWEBGL(s,l)})}var Xn=1,Ti=[],he=[],_i=[],ni=[],ee=[],ce=[],Ei=[],ye=[],qt=[],Re=[],ke=[],Jn={},Qn={},Zn=4;function St(e){xi||(xi=e)}function Ne(e){for(var n=Xn++,s=e.length;s<n;s++)e[s]=null;return n}function Is(e,n){e.df||(e.df=e.getContext,e.getContext=function(l,d){return d=e.df(l,d),l=="webgl"==d instanceof WebGLRenderingContext?d:null});var s=1<n.majorVersion?e.getContext("webgl2",n):e.getContext("webgl",n);return s?Os(s,n):0}function Os(e,n){var s=Ne(ye),l={handle:s,attributes:n,version:n.majorVersion,xe:e};return e.canvas&&(e.canvas.Rf=l),ye[s]=l,(typeof n.eg>"u"||n.eg)&&Ds(l),s}function tr(e){return at=ye[e],c.Jg=_=at&&at.xe,!(e&&!_)}function Ds(e){if(e||(e=at),!e.og){e.og=!0;var n=e.xe;Rs(n),ks(n),Ns(n),n.If=n.getExtension("WEBGL_draw_instanced_base_vertex_base_instance"),n.Mf=n.getExtension("WEBGL_multi_draw_instanced_base_vertex_base_instance"),2<=e.version&&(n.ze=n.getExtension("EXT_disjoint_timer_query_webgl2")),(2>e.version||!n.ze)&&(n.ze=n.getExtension("EXT_disjoint_timer_query")),n.Kg=n.getExtension("WEBGL_multi_draw"),(n.getSupportedExtensions()||[]).forEach(function(s){s.includes("lose_context")||s.includes("debug")||n.getExtension(s)})}}var at,xi;function er(e,n){_.bindFramebuffer(e,_i[n])}function ir(e){_.bindVertexArray(Ei[e])}function nr(e){_.clear(e)}function rr(e,n,s,l){_.clearColor(e,n,s,l)}function sr(e){_.clearStencil(e)}function ar(e,n){for(var s=0;s<e;s++){var l=W[n+4*s>>2];_.deleteVertexArray(Ei[l]),Ei[l]=null}}var Fi=[];function or(e,n,s,l){_.drawElements(e,n,s,l)}function Ie(e,n,s,l){for(var d=0;d<e;d++){var g=_[s](),A=g&&Ne(l);g?(g.name=A,l[A]=g):St(1282),W[n+4*d>>2]=A}}function lr(e,n){Ie(e,n,"createVertexArray",Ei)}function hr(e,n){_t[e>>2]=n,_t[e+4>>2]=(n-_t[e>>2])/4294967296}function cr(e,n,s){if(n){var l=void 0;switch(e){case 36346:l=1;break;case 36344:s!=0&&s!=1&&St(1280);return;case 34814:case 36345:l=0;break;case 34466:var d=_.getParameter(34467);l=d?d.length:0;break;case 33309:if(2>at.version){St(1282);return}l=2*(_.getSupportedExtensions()||[]).length;break;case 33307:case 33308:if(2>at.version){St(1280);return}l=e==33307?3:0}if(l===void 0)switch(d=_.getParameter(e),typeof d){case"number":l=d;break;case"boolean":l=d?1:0;break;case"string":St(1280);return;case"object":if(d===null)switch(e){case 34964:case 35725:case 34965:case 36006:case 36007:case 32873:case 34229:case 36662:case 36663:case 35053:case 35055:case 36010:case 35097:case 35869:case 32874:case 36389:case 35983:case 35368:case 34068:l=0;break;default:St(1280);return}else{if(d instanceof Float32Array||d instanceof Uint32Array||d instanceof Int32Array||d instanceof Array){for(e=0;e<d.length;++e)switch(s){case 0:W[n+4*e>>2]=d[e];break;case 2:it[n+4*e>>2]=d[e];break;case 4:pe[n+e>>0]=d[e]?1:0}return}try{l=d.name|0}catch(g){St(1280),Pe("GL_INVALID_ENUM in glGet"+s+"v: Unknown object returned from WebGL getParameter("+e+")! (error: "+g+")");return}}break;default:St(1280),Pe("GL_INVALID_ENUM in glGet"+s+"v: Native code calling glGet"+s+"v("+e+") and it returns "+d+" of type "+typeof d+"!");return}switch(s){case 1:hr(n,l);break;case 0:W[n>>2]=l;break;case 2:it[n>>2]=l;break;case 4:pe[n>>0]=l?1:0}}else St(1281)}function ur(e,n){cr(e,n,0)}function dr(e,n,s){if(s){e=qt[e],n=2>at.version?_.ze.getQueryObjectEXT(e,n):_.getQueryParameter(e,n);var l;typeof n=="boolean"?l=n?1:0:l=n,hr(s,l)}else St(1281)}var ri=e=>{var n=le(e)+1,s=Ni(n);return s&&oe(e,ft,s,n),s};function fr(e){var n=Jn[e];if(!n){switch(e){case 7939:n=_.getSupportedExtensions()||[],n=n.concat(n.map(function(l){return"GL_"+l})),n=ri(n.join(" "));break;case 7936:case 7937:case 37445:case 37446:(n=_.getParameter(e))||St(1280),n=n&&ri(n);break;case 7938:n=_.getParameter(7938),n=2<=at.version?"OpenGL ES 3.0 ("+n+")":"OpenGL ES 2.0 ("+n+")",n=ri(n);break;case 35724:n=_.getParameter(35724);var s=n.match(/^WebGL GLSL ES ([0-9]\.[0-9][0-9]?)(?:$| .*)/);s!==null&&(s[1].length==3&&(s[1]+="0"),n="OpenGL ES GLSL ES "+s[1]+" ("+n+")"),n=ri(n);break;default:St(1280)}Jn[e]=n}return n}function pr(e,n){if(2>at.version)return St(1282),0;var s=Qn[e];if(s)return 0>n||n>=s.length?(St(1281),0):s[n];switch(e){case 7939:return s=_.getSupportedExtensions()||[],s=s.concat(s.map(function(l){return"GL_"+l})),s=s.map(function(l){return ri(l)}),s=Qn[e]=s,0>n||n>=s.length?(St(1281),0):s[n];default:return St(1280),0}}function gr(e){return e.slice(-1)=="]"&&e.lastIndexOf("[")}function Mi(e){return e-=5120,e==0?pe:e==1?ft:e==2?Ae:e==4?W:e==6?it:e==5||e==28922||e==28520||e==30779||e==30782?_t:Be}function tn(e,n,s,l,d){e=Mi(e);var g=31-Math.clz32(e.BYTES_PER_ELEMENT),A=Zn;return e.subarray(d>>g,d+l*(s*({5:3,6:4,8:2,29502:3,29504:4,26917:2,26918:2,29846:3,29847:4}[n-6402]||1)*(1<<g)+A-1&-A)>>g)}function At(e){var n=_.bg;if(n){var s=n.ff[e];return typeof s=="number"&&(n.ff[e]=s=_.getUniformLocation(n,n.Pf[e]+(0<s?"["+s+"]":""))),s}St(1282)}var Te=[],si=[],en={},mr=()=>{if(!nn){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:G||"./this.program"},n;for(n in en)en[n]===void 0?delete e[n]:e[n]=en[n];var s=[];for(n in e)s.push(`${n}=${e[n]}`);nn=s}return nn},nn,zs=[null,[],[]],Ri=e=>e%4===0&&(e%100!==0||e%400===0),yr=[31,29,31,30,31,30,31,31,30,31,30,31],vr=[31,28,31,30,31,30,31,31,30,31,30,31];function Ls(e){var n=Array(le(e)+1);return oe(e,n,0,n.length),n}var Bs=(e,n,s,l)=>{function d(F,J,ht){for(F=typeof F=="number"?F.toString():F||"";F.length<J;)F=ht[0]+F;return F}function g(F,J){return d(F,J,"0")}function A(F,J){function ht(Ht){return 0>Ht?-1:0<Ht?1:0}var ot;return(ot=ht(F.getFullYear()-J.getFullYear()))===0&&(ot=ht(F.getMonth()-J.getMonth()))===0&&(ot=ht(F.getDate()-J.getDate())),ot}function y(F){switch(F.getDay()){case 0:return new Date(F.getFullYear()-1,11,29);case 1:return F;case 2:return new Date(F.getFullYear(),0,3);case 3:return new Date(F.getFullYear(),0,2);case 4:return new Date(F.getFullYear(),0,1);case 5:return new Date(F.getFullYear()-1,11,31);case 6:return new Date(F.getFullYear()-1,11,30)}}function v(F){var J=F.He;for(F=new Date(new Date(F.Ie+1900,0,1).getTime());0<J;){var ht=F.getMonth(),ot=(Ri(F.getFullYear())?yr:vr)[ht];if(J>ot-F.getDate())J-=ot-F.getDate()+1,F.setDate(1),11>ht?F.setMonth(ht+1):(F.setMonth(0),F.setFullYear(F.getFullYear()+1));else{F.setDate(F.getDate()+J);break}}return ht=new Date(F.getFullYear()+1,0,4),J=y(new Date(F.getFullYear(),0,4)),ht=y(ht),0>=A(J,F)?0>=A(ht,F)?F.getFullYear()+1:F.getFullYear():F.getFullYear()-1}var T=W[l+40>>2];l={Hg:W[l>>2],Gg:W[l+4>>2],tf:W[l+8>>2],Df:W[l+12>>2],uf:W[l+16>>2],Ie:W[l+20>>2],Ae:W[l+24>>2],He:W[l+28>>2],Ng:W[l+32>>2],Fg:W[l+36>>2],Ig:T&&T?Fe(ft,T):""},s=s?Fe(ft,s):"",T={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var O in T)s=s.replace(new RegExp(O,"g"),T[O]);var L="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),Y="January February March April May June July August September October November December".split(" ");T={"%a":F=>L[F.Ae].substring(0,3),"%A":F=>L[F.Ae],"%b":F=>Y[F.uf].substring(0,3),"%B":F=>Y[F.uf],"%C":F=>g((F.Ie+1900)/100|0,2),"%d":F=>g(F.Df,2),"%e":F=>d(F.Df,2," "),"%g":F=>v(F).toString().substring(2),"%G":F=>v(F),"%H":F=>g(F.tf,2),"%I":F=>(F=F.tf,F==0?F=12:12<F&&(F-=12),g(F,2)),"%j":F=>{for(var J=0,ht=0;ht<=F.uf-1;J+=(Ri(F.Ie+1900)?yr:vr)[ht++]);return g(F.Df+J,3)},"%m":F=>g(F.uf+1,2),"%M":F=>g(F.Gg,2),"%n":()=>`
3
- `,"%p":F=>0<=F.tf&&12>F.tf?"AM":"PM","%S":F=>g(F.Hg,2),"%t":()=>" ","%u":F=>F.Ae||7,"%U":F=>g(Math.floor((F.He+7-F.Ae)/7),2),"%V":F=>{var J=Math.floor((F.He+7-(F.Ae+6)%7)/7);if(2>=(F.Ae+371-F.He-2)%7&&J++,J)J==53&&(ht=(F.Ae+371-F.He)%7,ht==4||ht==3&&Ri(F.Ie)||(J=1));else{J=52;var ht=(F.Ae+7-F.He-1)%7;(ht==4||ht==5&&Ri(F.Ie%400-1))&&J++}return g(J,2)},"%w":F=>F.Ae,"%W":F=>g(Math.floor((F.He+7-(F.Ae+6)%7)/7),2),"%y":F=>(F.Ie+1900).toString().substring(2),"%Y":F=>F.Ie+1900,"%z":F=>{F=F.Fg;var J=0<=F;return F=Math.abs(F)/60,(J?"+":"-")+("0000"+(F/60*100+F%60)).slice(-4)},"%Z":F=>F.Ig,"%%":()=>"%"},s=s.replace(/%%/g,"\0\0");for(O in T)s.includes(O)&&(s=s.replace(new RegExp(O,"g"),T[O](l)));return s=s.replace(/\0\0/g,"%"),O=Ls(s),O.length>n?0:(pe.set(O,e),O.length-1)};On=c.InternalError=class extends Error{constructor(e){super(e),this.name="InternalError"}};for(var wr=Array(256),ki=0;256>ki;++ki)wr[ki]=String.fromCharCode(ki);Dn=wr,Ge=c.BindingError=class extends Error{constructor(e){super(e),this.name="BindingError"}},Ce.prototype.isAliasOf=function(e){if(!(this instanceof Ce&&e instanceof Ce))return!1;var n=this.ae.me.ge,s=this.ae.ie,l=e.ae.me.ge;for(e=e.ae.ie;n.re;)s=n.gf(s),n=n.re;for(;l.re;)e=l.gf(e),l=l.re;return n===l&&s===e},Ce.prototype.clone=function(){if(this.ae.ie||Hi(this),this.ae.ef)return this.ae.count.value+=1,this;var e=ti,n=Object,s=n.create,l=Object.getPrototypeOf(this),d=this.ae;return e=e(s.call(n,l,{ae:{value:{count:d.count,Xe:d.Xe,ef:d.ef,ie:d.ie,me:d.me,pe:d.pe,we:d.we}}})),e.ae.count.value+=1,e.ae.Xe=!1,e},Ce.prototype.delete=function(){this.ae.ie||Hi(this),this.ae.Xe&&!this.ae.ef&&wt("Object already scheduled for deletion"),zn(this),Ln(this.ae),this.ae.ef||(this.ae.pe=void 0,this.ae.ie=void 0)},Ce.prototype.isDeleted=function(){return!this.ae.ie},Ce.prototype.deleteLater=function(){return this.ae.ie||Hi(this),this.ae.Xe&&!this.ae.ef&&wt("Object already scheduled for deletion"),Je.push(this),Je.length===1&&Qe&&Qe(Vi),this.ae.Xe=!0,this},c.getInheritedInstanceCount=function(){return Object.keys(Ze).length},c.getLiveInheritedInstances=function(){var e=[],n;for(n in Ze)Ze.hasOwnProperty(n)&&e.push(Ze[n]);return e},c.flushPendingDeletes=Vi,c.setDelayFunction=function(e){Qe=e,Je.length&&Qe&&Qe(Vi)},me.prototype.jg=function(e){return this.Nf&&(e=this.Nf(e)),e},me.prototype.Hf=function(e){this.De&&this.De(e)},me.prototype.argPackAdvance=8,me.prototype.readValueFromPointer=Xe,me.prototype.deleteObject=function(e){e!==null&&e.delete()},me.prototype.fromWireType=function(e){function n(){return this.pf?Si(this.ge.Ye,{me:this.tg,ie:s,we:this,pe:e}):Si(this.ge.Ye,{me:this,ie:e})}var s=this.jg(e);if(!s)return this.Hf(e),null;var l=ds(this.ge,s);if(l!==void 0)return l.ae.count.value===0?(l.ae.ie=s,l.ae.pe=e,l.clone()):(l=l.clone(),this.Hf(e),l);if(l=this.ge.ig(s),l=Un[l],!l)return n.call(this);l=this.nf?l.$f:l.pointerType;var d=Bn(s,this.ge,l.ge);return d===null?n.call(this):this.pf?Si(l.ge.Ye,{me:l,ie:d,we:this,pe:e}):Si(l.ge.Ye,{me:l,ie:d})},Wn=c.UnboundTypeError=function(e,n){var s=qi(n,function(l){this.name=n,this.message=l,l=Error(l).stack,l!==void 0&&(this.stack=this.toString()+`
4
- `+l.replace(/^Error(:[^\n]*)?\n/,""))});return s.prototype=Object.create(e.prototype),s.prototype.constructor=s,s.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},s}(Error,"UnboundTypeError"),Object.assign(Hn.prototype,{get(e){return this.Ce[e]},has(e){return this.Ce[e]!==void 0},Yf(e){var n=this.Kf.pop()||this.Ce.length;return this.Ce[n]=e,n},Zf(e){this.Ce[e]=void 0,this.Kf.push(e)}}),Qt.Ce.push({value:void 0},{value:null},{value:!0},{value:!1}),Qt.df=Qt.Ce.length,c.count_emval_handles=function(){for(var e=0,n=Qt.df;n<Qt.Ce.length;++n)Qt.Ce[n]!==void 0&&++e;return e};for(var _,Yt=0;32>Yt;++Yt)Fi.push(Array(Yt));var Us=new Float32Array(288);for(Yt=0;288>Yt;++Yt)Te[Yt]=Us.subarray(0,Yt+1);var $s=new Int32Array(288);for(Yt=0;288>Yt;++Yt)si[Yt]=$s.subarray(0,Yt+1);var Gs={R:function(){return 0},wb:()=>{},yb:function(){return 0},tb:()=>{},ub:()=>{},S:function(){},vb:()=>{},B:function(e){var n=mi[e];delete mi[e];var s=n.Cf,l=n.De,d=n.Jf,g=d.map(A=>A.mg).concat(d.map(A=>A.xg));ae([e],g,A=>{var y={};return d.forEach((v,T)=>{var O=A[T],L=v.kg,Y=v.lg,F=A[T+d.length],J=v.wg,ht=v.yg;y[v.fg]={read:ot=>O.fromWireType(L(Y,ot)),write:(ot,Ht)=>{var Lt=[];J(ht,ot,F.toWireType(Lt,Ht)),ji(Lt)}}}),[{name:n.name,fromWireType:function(v){var T={},O;for(O in y)T[O]=y[O].read(v);return l(v),T},toWireType:function(v,T){for(var O in y)if(!(O in T))throw new TypeError(`Missing field: "${O}"`);var L=s();for(O in y)y[O].write(L,T[O]);return v!==null&&v.push(l,L),L},argPackAdvance:8,readValueFromPointer:Xe,ve:l}]})},nb:function(){},Cb:function(e,n,s,l,d){var g=wi(s);n=Ft(n),ge(e,{name:n,fromWireType:function(A){return!!A},toWireType:function(A,y){return y?l:d},argPackAdvance:8,readValueFromPointer:function(A){if(s===1)var y=pe;else if(s===2)y=Ae;else if(s===4)y=W;else throw new TypeError("Unknown boolean type size: "+n);return this.fromWireType(y[A>>g])},ve:null})},n:function(e,n,s,l,d,g,A,y,v,T,O,L,Y){O=Ft(O),g=Ut(d,g),y&&(y=Ut(A,y)),T&&(T=Ut(v,T)),Y=Ut(L,Y);var F=$n(O);Xi(F,function(){ei(`Cannot construct ${O} due to unbound types`,[l])}),ae([e,n,s],l?[l]:[],function(J){if(J=J[0],l)var ht=J.ge,ot=ht.Ye;else ot=Ce.prototype;J=qi(F,function(){if(Object.getPrototypeOf(this)!==Ht)throw new Ge("Use 'new' to construct "+O);if(Lt.Ge===void 0)throw new Ge(O+" has no accessible constructor");var oi=Lt.Ge[arguments.length];if(oi===void 0)throw new Ge(`Tried to invoke ctor of ${O} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(Lt.Ge).toString()}) parameters instead!`);return oi.apply(this,arguments)});var Ht=Object.create(ot,{constructor:{value:J}});J.prototype=Ht;var Lt=new fs(O,J,Ht,Y,ht,g,y,T);Lt.re&&(Lt.re.hf===void 0&&(Lt.re.hf=[]),Lt.re.hf.push(Lt)),ht=new me(O,Lt,!0,!1,!1),ot=new me(O+"*",Lt,!1,!1,!1);var ai=new me(O+" const*",Lt,!1,!0,!1);return Un[e]={pointerType:ot,$f:ai},Gn(F,J),[ht,ot,ai]})},f:function(e,n,s,l,d,g,A){var y=Pi(s,l);n=Ft(n),g=Ut(d,g),ae([],[e],function(v){function T(){ei(`Cannot call ${O} due to unbound types`,y)}v=v[0];var O=`${v.name}.${n}`;n.startsWith("@@")&&(n=Symbol[n.substring(2)]);var L=v.ge.constructor;return L[n]===void 0?(T.Ve=s-1,L[n]=T):(Yi(L,n,O),L[n].oe[s-1]=T),ae([],y,function(Y){if(Y=[Y[0],null].concat(Y.slice(1)),Y=bi(O,Y,null,g,A),L[n].oe===void 0?(Y.Ve=s-1,L[n]=Y):L[n].oe[s-1]=Y,v.ge.hf)for(const F of v.ge.hf)F.constructor.hasOwnProperty(n)||(F.constructor[n]=Y);return[]}),[]})},A:function(e,n,s,l,d,g){var A=Pi(n,s);d=Ut(l,d),ae([],[e],function(y){y=y[0];var v=`constructor ${y.name}`;if(y.ge.Ge===void 0&&(y.ge.Ge=[]),y.ge.Ge[n-1]!==void 0)throw new Ge(`Cannot register multiple constructors with identical number of parameters (${n-1}) for class '${y.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return y.ge.Ge[n-1]=()=>{ei(`Cannot construct ${y.name} due to unbound types`,A)},ae([],A,function(T){return T.splice(1,0,null),y.ge.Ge[n-1]=bi(v,T,null,d,g),[]}),[]})},b:function(e,n,s,l,d,g,A,y){var v=Pi(s,l);n=Ft(n),g=Ut(d,g),ae([],[e],function(T){function O(){ei(`Cannot call ${L} due to unbound types`,v)}T=T[0];var L=`${T.name}.${n}`;n.startsWith("@@")&&(n=Symbol[n.substring(2)]),y&&T.ge.ug.push(n);var Y=T.ge.Ye,F=Y[n];return F===void 0||F.oe===void 0&&F.className!==T.name&&F.Ve===s-2?(O.Ve=s-2,O.className=T.name,Y[n]=O):(Yi(Y,n,L),Y[n].oe[s-2]=O),ae([],v,function(J){return J=bi(L,J,T,g,A),Y[n].oe===void 0?(J.Ve=s-2,Y[n]=J):Y[n].oe[s-2]=J,[]}),[]})},t:function(e,n,s){e=Ft(e),ae([],[n],function(l){return l=l[0],c[e]=l.fromWireType(s),[]})},Bb:function(e,n){n=Ft(n),ge(e,{name:n,fromWireType:function(s){var l=Zt(s);return Qi(s),l},toWireType:function(s,l){return te(l)},argPackAdvance:8,readValueFromPointer:Xe,ve:null})},m:function(e,n,s,l){function d(){}s=wi(s),n=Ft(n),d.values={},ge(e,{name:n,constructor:d,fromWireType:function(g){return this.constructor.values[g]},toWireType:function(g,A){return A.value},argPackAdvance:8,readValueFromPointer:vs(n,s,l),ve:null}),Xi(n,d)},c:function(e,n,s){var l=ii(e,"enum");n=Ft(n),e=l.constructor,l=Object.create(l.constructor.prototype,{value:{value:s},constructor:{value:qi(`${l.name}_${n}`,function(){})}}),e.values[s]=l,e[n]=l},U:function(e,n,s){s=wi(s),n=Ft(n),ge(e,{name:n,fromWireType:function(l){return l},toWireType:function(l,d){return d},argPackAdvance:8,readValueFromPointer:ws(n,s),ve:null})},y:function(e,n,s,l,d,g){var A=Pi(n,s);e=Ft(e),d=Ut(l,d),Xi(e,function(){ei(`Cannot call ${e} due to unbound types`,A)},n-1),ae([],A,function(y){return y=[y[0],null].concat(y.slice(1)),Gn(e,bi(e,y,null,d,g),n-1),[]})},E:function(e,n,s,l,d){n=Ft(n),d===-1&&(d=4294967295),d=wi(s);var g=y=>y;if(l===0){var A=32-8*s;g=y=>y<<A>>>A}s=n.includes("unsigned")?function(y,v){return v>>>0}:function(y,v){return v},ge(e,{name:n,fromWireType:g,toWireType:s,argPackAdvance:8,readValueFromPointer:Ss(n,d,l!==0),ve:null})},r:function(e,n,s){function l(g){g>>=2;var A=_t;return new d(A.buffer,A[g+1],A[g])}var d=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][n];s=Ft(s),ge(e,{name:s,fromWireType:l,argPackAdvance:8,readValueFromPointer:l},{ng:!0})},q:function(e,n,s,l,d,g,A,y,v,T,O,L){s=Ft(s),g=Ut(d,g),y=Ut(A,y),T=Ut(v,T),L=Ut(O,L),ae([e],[n],function(Y){return Y=Y[0],[new me(s,Y.ge,!1,!1,!0,Y,l,g,y,T,L)]})},T:function(e,n){n=Ft(n);var s=n==="std::string";ge(e,{name:n,fromWireType:function(l){var d=_t[l>>2],g=l+4;if(s)for(var A=g,y=0;y<=d;++y){var v=g+y;if(y==d||ft[v]==0){if(A=A?Fe(ft,A,v-A):"",T===void 0)var T=A;else T+="\0",T+=A;A=v+1}}else{for(T=Array(d),y=0;y<d;++y)T[y]=String.fromCharCode(ft[g+y]);T=T.join("")}return we(l),T},toWireType:function(l,d){d instanceof ArrayBuffer&&(d=new Uint8Array(d));var g=typeof d=="string";g||d instanceof Uint8Array||d instanceof Uint8ClampedArray||d instanceof Int8Array||wt("Cannot pass non-string to std::string");var A=s&&g?le(d):d.length,y=Ni(4+A+1),v=y+4;if(_t[y>>2]=A,s&&g)oe(d,ft,v,A+1);else if(g)for(g=0;g<A;++g){var T=d.charCodeAt(g);255<T&&(we(v),wt("String has UTF-16 code units that do not fit in 8 bits")),ft[v+g]=T}else for(g=0;g<A;++g)ft[v+g]=d[g];return l!==null&&l.push(we,y),y},argPackAdvance:8,readValueFromPointer:Xe,ve:function(l){we(l)}})},N:function(e,n,s){if(s=Ft(s),n===2)var l=bs,d=Ps,g=As,A=()=>Be,y=1;else n===4&&(l=Cs,d=Ts,g=_s,A=()=>_t,y=2);ge(e,{name:s,fromWireType:function(v){for(var T=_t[v>>2],O=A(),L,Y=v+4,F=0;F<=T;++F){var J=v+4+F*n;(F==T||O[J>>y]==0)&&(Y=l(Y,J-Y),L===void 0?L=Y:(L+="\0",L+=Y),Y=J+n)}return we(v),L},toWireType:function(v,T){typeof T!="string"&&wt(`Cannot pass non-string to C++ string type ${s}`);var O=g(T),L=Ni(4+O+n);return _t[L>>2]=O>>y,d(T,L+4,O+n),v!==null&&v.push(we,L),L},argPackAdvance:8,readValueFromPointer:Xe,ve:function(v){we(v)}})},C:function(e,n,s,l,d,g){mi[e]={name:Ft(n),Cf:Ut(s,l),De:Ut(d,g),Jf:[]}},e:function(e,n,s,l,d,g,A,y,v,T){mi[e].Jf.push({fg:Ft(n),mg:s,kg:Ut(l,d),lg:g,xg:A,wg:Ut(y,v),yg:T})},Db:function(e,n){n=Ft(n),ge(e,{pg:!0,name:n,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},Ab:()=>!0,pb:()=>{throw 1/0},F:function(e,n,s){e=Zt(e),n=ii(n,"emval::as");var l=[],d=te(l);return _t[s>>2]=d,n.toWireType(l,e)},X:function(e,n,s,l,d){e=Ci[e],n=Zt(n),s=Ai(s);var g=[];return _t[l>>2]=te(g),e(n,s,g,d)},x:function(e,n,s,l){e=Ci[e],n=Zt(n),s=Ai(s),e(n,s,null,l)},d:Qi,K:function(e){return e===0?te(Vn()):(e=Ai(e),te(Vn()[e]))},u:function(e,n){var s=Fs(e,n),l=s[0];n=l.name+"_$"+s.slice(1).map(function(A){return A.name}).join("_")+"$";var d=qn[n];if(d!==void 0)return d;var g=Array(e-1);return d=xs((A,y,v,T)=>{for(var O=0,L=0;L<e-1;++L)g[L]=s[L+1].readValueFromPointer(T+O),O+=s[L+1].argPackAdvance;for(A=A[y].apply(A,g),L=0;L<e-1;++L)s[L+1].cg&&s[L+1].cg(g[L]);if(!l.pg)return l.toWireType(v,A)}),qn[n]=d},z:function(e,n){return e=Zt(e),n=Zt(n),te(e[n])},p:function(e){4<e&&(Qt.get(e).Of+=1)},J:function(e,n,s,l){e=Zt(e);var d=Yn[n];return d||(d=Ms(n),Yn[n]=d),d(e,s,l)},H:function(){return te([])},g:function(e){return te(Ai(e))},G:function(){return te({})},gb:function(e){return e=Zt(e),!e},D:function(e){var n=Zt(e);ji(n),Qi(e)},l:function(e,n,s){e=Zt(e),n=Zt(n),s=Zt(s),e[n]=s},h:function(e,n){return e=ii(e,"_emval_take_value"),e=e.readValueFromPointer(n),te(e)},kb:function(){return-52},lb:function(){},a:()=>{Gi("")},zb:()=>performance.now(),sd:function(e){_.activeTexture(e)},td:function(e,n){_.attachShader(he[e],ce[n])},Yb:function(e,n){_.beginQuery(e,qt[n])},Sb:function(e,n){_.ze.beginQueryEXT(e,qt[n])},ud:function(e,n,s){_.bindAttribLocation(he[e],n,s?Fe(ft,s):"")},vd:function(e,n){e==35051?_.zf=n:e==35052&&(_.We=n),_.bindBuffer(e,Ti[n])},uc:er,vc:function(e,n){_.bindRenderbuffer(e,ni[n])},cc:function(e,n){_.bindSampler(e,Re[n])},wd:function(e,n){_.bindTexture(e,ee[n])},Pc:ir,Tc:ir,Y:function(e,n,s,l){_.blendColor(e,n,s,l)},Z:function(e){_.blendEquation(e)},_:function(e,n){_.blendFunc(e,n)},oc:function(e,n,s,l,d,g,A,y,v,T){_.blitFramebuffer(e,n,s,l,d,g,A,y,v,T)},$:function(e,n,s,l){2<=at.version?s&&n?_.bufferData(e,ft,l,s,n):_.bufferData(e,n,l):_.bufferData(e,s?ft.subarray(s,s+n):n,l)},aa:function(e,n,s,l){2<=at.version?s&&_.bufferSubData(e,n,ft,l,s):_.bufferSubData(e,n,ft.subarray(l,l+s))},wc:function(e){return _.checkFramebufferStatus(e)},ba:nr,ca:rr,da:sr,lc:function(e,n,s,l){return _.clientWaitSync(ke[e],n,(s>>>0)+4294967296*l)},ea:function(e,n,s,l){_.colorMask(!!e,!!n,!!s,!!l)},fa:function(e){_.compileShader(ce[e])},ga:function(e,n,s,l,d,g,A,y){2<=at.version?_.We||!A?_.compressedTexImage2D(e,n,s,l,d,g,A,y):_.compressedTexImage2D(e,n,s,l,d,g,ft,y,A):_.compressedTexImage2D(e,n,s,l,d,g,y?ft.subarray(y,y+A):null)},ha:function(e,n,s,l,d,g,A,y,v){2<=at.version?_.We||!y?_.compressedTexSubImage2D(e,n,s,l,d,g,A,y,v):_.compressedTexSubImage2D(e,n,s,l,d,g,A,ft,v,y):_.compressedTexSubImage2D(e,n,s,l,d,g,A,v?ft.subarray(v,v+y):null)},nc:function(e,n,s,l,d){_.copyBufferSubData(e,n,s,l,d)},ia:function(e,n,s,l,d,g,A,y){_.copyTexSubImage2D(e,n,s,l,d,g,A,y)},ja:function(){var e=Ne(he),n=_.createProgram();return n.name=e,n.sf=n.qf=n.rf=0,n.Ef=1,he[e]=n,e},ka:function(e){var n=Ne(ce);return ce[n]=_.createShader(e),n},la:function(e){_.cullFace(e)},ma:function(e,n){for(var s=0;s<e;s++){var l=W[n+4*s>>2],d=Ti[l];d&&(_.deleteBuffer(d),d.name=0,Ti[l]=null,l==_.zf&&(_.zf=0),l==_.We&&(_.We=0))}},xc:function(e,n){for(var s=0;s<e;++s){var l=W[n+4*s>>2],d=_i[l];d&&(_.deleteFramebuffer(d),d.name=0,_i[l]=null)}},na:function(e){if(e){var n=he[e];n?(_.deleteProgram(n),n.name=0,he[e]=null):St(1281)}},Zb:function(e,n){for(var s=0;s<e;s++){var l=W[n+4*s>>2],d=qt[l];d&&(_.deleteQuery(d),qt[l]=null)}},Tb:function(e,n){for(var s=0;s<e;s++){var l=W[n+4*s>>2],d=qt[l];d&&(_.ze.deleteQueryEXT(d),qt[l]=null)}},yc:function(e,n){for(var s=0;s<e;s++){var l=W[n+4*s>>2],d=ni[l];d&&(_.deleteRenderbuffer(d),d.name=0,ni[l]=null)}},dc:function(e,n){for(var s=0;s<e;s++){var l=W[n+4*s>>2],d=Re[l];d&&(_.deleteSampler(d),d.name=0,Re[l]=null)}},oa:function(e){if(e){var n=ce[e];n?(_.deleteShader(n),ce[e]=null):St(1281)}},mc:function(e){if(e){var n=ke[e];n?(_.deleteSync(n),n.name=0,ke[e]=null):St(1281)}},pa:function(e,n){for(var s=0;s<e;s++){var l=W[n+4*s>>2],d=ee[l];d&&(_.deleteTexture(d),d.name=0,ee[l]=null)}},Qc:ar,Uc:ar,qa:function(e){_.depthMask(!!e)},ra:function(e){_.disable(e)},sa:function(e){_.disableVertexAttribArray(e)},ta:function(e,n,s){_.drawArrays(e,n,s)},Nc:function(e,n,s,l){_.drawArraysInstanced(e,n,s,l)},Lc:function(e,n,s,l,d){_.If.drawArraysInstancedBaseInstanceWEBGL(e,n,s,l,d)},Jc:function(e,n){for(var s=Fi[e],l=0;l<e;l++)s[l]=W[n+4*l>>2];_.drawBuffers(s)},ua:or,Oc:function(e,n,s,l,d){_.drawElementsInstanced(e,n,s,l,d)},Mc:function(e,n,s,l,d,g,A){_.If.drawElementsInstancedBaseVertexBaseInstanceWEBGL(e,n,s,l,d,g,A)},Dc:function(e,n,s,l,d,g){or(e,l,d,g)},va:function(e){_.enable(e)},wa:function(e){_.enableVertexAttribArray(e)},_b:function(e){_.endQuery(e)},Ub:function(e){_.ze.endQueryEXT(e)},ic:function(e,n){return(e=_.fenceSync(e,n))?(n=Ne(ke),e.name=n,ke[n]=e,n):0},xa:function(){_.finish()},ya:function(){_.flush()},zc:function(e,n,s,l){_.framebufferRenderbuffer(e,n,s,ni[l])},Ac:function(e,n,s,l,d){_.framebufferTexture2D(e,n,s,ee[l],d)},za:function(e){_.frontFace(e)},Aa:function(e,n){Ie(e,n,"createBuffer",Ti)},Bc:function(e,n){Ie(e,n,"createFramebuffer",_i)},$b:function(e,n){Ie(e,n,"createQuery",qt)},Vb:function(e,n){for(var s=0;s<e;s++){var l=_.ze.createQueryEXT();if(!l){for(St(1282);s<e;)W[n+4*s++>>2]=0;break}var d=Ne(qt);l.name=d,qt[d]=l,W[n+4*s>>2]=d}},Cc:function(e,n){Ie(e,n,"createRenderbuffer",ni)},ec:function(e,n){Ie(e,n,"createSampler",Re)},Ba:function(e,n){Ie(e,n,"createTexture",ee)},Rc:lr,Vc:lr,qc:function(e){_.generateMipmap(e)},Ca:function(e,n,s){s?W[s>>2]=_.getBufferParameter(e,n):St(1281)},Da:function(){var e=_.getError()||xi;return xi=0,e},Ea:function(e,n){cr(e,n,2)},rc:function(e,n,s,l){e=_.getFramebufferAttachmentParameter(e,n,s),(e instanceof WebGLRenderbuffer||e instanceof WebGLTexture)&&(e=e.name|0),W[l>>2]=e},Fa:ur,Ga:function(e,n,s,l){e=_.getProgramInfoLog(he[e]),e===null&&(e="(unknown error)"),n=0<n&&l?oe(e,ft,l,n):0,s&&(W[s>>2]=n)},Ha:function(e,n,s){if(s)if(e>=Xn)St(1281);else if(e=he[e],n==35716)e=_.getProgramInfoLog(e),e===null&&(e="(unknown error)"),W[s>>2]=e.length+1;else if(n==35719){if(!e.sf)for(n=0;n<_.getProgramParameter(e,35718);++n)e.sf=Math.max(e.sf,_.getActiveUniform(e,n).name.length+1);W[s>>2]=e.sf}else if(n==35722){if(!e.qf)for(n=0;n<_.getProgramParameter(e,35721);++n)e.qf=Math.max(e.qf,_.getActiveAttrib(e,n).name.length+1);W[s>>2]=e.qf}else if(n==35381){if(!e.rf)for(n=0;n<_.getProgramParameter(e,35382);++n)e.rf=Math.max(e.rf,_.getActiveUniformBlockName(e,n).length+1);W[s>>2]=e.rf}else W[s>>2]=_.getProgramParameter(e,n);else St(1281)},Pb:dr,Qb:dr,ac:function(e,n,s){if(s){e=_.getQueryParameter(qt[e],n);var l;typeof e=="boolean"?l=e?1:0:l=e,W[s>>2]=l}else St(1281)},Wb:function(e,n,s){if(s){e=_.ze.getQueryObjectEXT(qt[e],n);var l;typeof e=="boolean"?l=e?1:0:l=e,W[s>>2]=l}else St(1281)},bc:function(e,n,s){s?W[s>>2]=_.getQuery(e,n):St(1281)},Xb:function(e,n,s){s?W[s>>2]=_.ze.getQueryEXT(e,n):St(1281)},sc:function(e,n,s){s?W[s>>2]=_.getRenderbufferParameter(e,n):St(1281)},Ia:function(e,n,s,l){e=_.getShaderInfoLog(ce[e]),e===null&&(e="(unknown error)"),n=0<n&&l?oe(e,ft,l,n):0,s&&(W[s>>2]=n)},Mb:function(e,n,s,l){e=_.getShaderPrecisionFormat(e,n),W[s>>2]=e.rangeMin,W[s+4>>2]=e.rangeMax,W[l>>2]=e.precision},Ja:function(e,n,s){s?n==35716?(e=_.getShaderInfoLog(ce[e]),e===null&&(e="(unknown error)"),W[s>>2]=e?e.length+1:0):n==35720?(e=_.getShaderSource(ce[e]),W[s>>2]=e?e.length+1:0):W[s>>2]=_.getShaderParameter(ce[e],n):St(1281)},Ka:fr,Sc:pr,La:function(e,n){if(n=n?Fe(ft,n):"",e=he[e]){var s=e,l=s.ff,d=s.Qf,g;if(!l)for(s.ff=l={},s.Pf={},g=0;g<_.getProgramParameter(s,35718);++g){var A=_.getActiveUniform(s,g),y=A.name;A=A.size;var v=gr(y);v=0<v?y.slice(0,v):y;var T=s.Ef;for(s.Ef+=A,d[v]=[A,T],y=0;y<A;++y)l[T]=y,s.Pf[T++]=v}if(s=e.ff,l=0,d=n,g=gr(n),0<g&&(l=parseInt(n.slice(g+1))>>>0,d=n.slice(0,g)),(d=e.Qf[d])&&l<d[0]&&(l+=d[1],s[l]=s[l]||_.getUniformLocation(e,n)))return l}else St(1281);return-1},Nb:function(e,n,s){for(var l=Fi[n],d=0;d<n;d++)l[d]=W[s+4*d>>2];_.invalidateFramebuffer(e,l)},Ob:function(e,n,s,l,d,g,A){for(var y=Fi[n],v=0;v<n;v++)y[v]=W[s+4*v>>2];_.invalidateSubFramebuffer(e,y,l,d,g,A)},jc:function(e){return _.isSync(ke[e])},Ma:function(e){return(e=ee[e])?_.isTexture(e):0},Na:function(e){_.lineWidth(e)},Oa:function(e){e=he[e],_.linkProgram(e),e.ff=0,e.Qf={}},Hc:function(e,n,s,l,d,g){_.Mf.multiDrawArraysInstancedBaseInstanceWEBGL(e,W,n>>2,W,s>>2,W,l>>2,_t,d>>2,g)},Ic:function(e,n,s,l,d,g,A,y){_.Mf.multiDrawElementsInstancedBaseVertexBaseInstanceWEBGL(e,W,n>>2,s,W,l>>2,W,d>>2,W,g>>2,_t,A>>2,y)},Pa:function(e,n){e==3317&&(Zn=n),_.pixelStorei(e,n)},Rb:function(e,n){_.ze.queryCounterEXT(qt[e],n)},Kc:function(e){_.readBuffer(e)},Qa:function(e,n,s,l,d,g,A){if(2<=at.version)if(_.zf)_.readPixels(e,n,s,l,d,g,A);else{var y=Mi(g);_.readPixels(e,n,s,l,d,g,y,A>>31-Math.clz32(y.BYTES_PER_ELEMENT))}else(A=tn(g,d,s,l,A))?_.readPixels(e,n,s,l,d,g,A):St(1280)},tc:function(e,n,s,l){_.renderbufferStorage(e,n,s,l)},pc:function(e,n,s,l,d){_.renderbufferStorageMultisample(e,n,s,l,d)},fc:function(e,n,s){_.samplerParameterf(Re[e],n,s)},gc:function(e,n,s){_.samplerParameteri(Re[e],n,s)},hc:function(e,n,s){_.samplerParameteri(Re[e],n,W[s>>2])},Ra:function(e,n,s,l){_.scissor(e,n,s,l)},Sa:function(e,n,s,l){for(var d="",g=0;g<n;++g){var A=l?W[l+4*g>>2]:-1,y=W[s+4*g>>2];A=y?Fe(ft,y,0>A?void 0:A):"",d+=A}_.shaderSource(ce[e],d)},Ta:function(e,n,s){_.stencilFunc(e,n,s)},Ua:function(e,n,s,l){_.stencilFuncSeparate(e,n,s,l)},Va:function(e){_.stencilMask(e)},Wa:function(e,n){_.stencilMaskSeparate(e,n)},Xa:function(e,n,s){_.stencilOp(e,n,s)},Ya:function(e,n,s,l){_.stencilOpSeparate(e,n,s,l)},Za:function(e,n,s,l,d,g,A,y,v){if(2<=at.version)if(_.We)_.texImage2D(e,n,s,l,d,g,A,y,v);else if(v){var T=Mi(y);_.texImage2D(e,n,s,l,d,g,A,y,T,v>>31-Math.clz32(T.BYTES_PER_ELEMENT))}else _.texImage2D(e,n,s,l,d,g,A,y,null);else _.texImage2D(e,n,s,l,d,g,A,y,v?tn(y,A,l,d,v):null)},_a:function(e,n,s){_.texParameterf(e,n,s)},$a:function(e,n,s){_.texParameterf(e,n,it[s>>2])},ab:function(e,n,s){_.texParameteri(e,n,s)},bb:function(e,n,s){_.texParameteri(e,n,W[s>>2])},Ec:function(e,n,s,l,d){_.texStorage2D(e,n,s,l,d)},cb:function(e,n,s,l,d,g,A,y,v){if(2<=at.version)if(_.We)_.texSubImage2D(e,n,s,l,d,g,A,y,v);else if(v){var T=Mi(y);_.texSubImage2D(e,n,s,l,d,g,A,y,T,v>>31-Math.clz32(T.BYTES_PER_ELEMENT))}else _.texSubImage2D(e,n,s,l,d,g,A,y,null);else T=null,v&&(T=tn(y,A,d,g,v)),_.texSubImage2D(e,n,s,l,d,g,A,y,T)},db:function(e,n){_.uniform1f(At(e),n)},eb:function(e,n,s){if(2<=at.version)n&&_.uniform1fv(At(e),it,s>>2,n);else{if(288>=n)for(var l=Te[n-1],d=0;d<n;++d)l[d]=it[s+4*d>>2];else l=it.subarray(s>>2,s+4*n>>2);_.uniform1fv(At(e),l)}},od:function(e,n){_.uniform1i(At(e),n)},pd:function(e,n,s){if(2<=at.version)n&&_.uniform1iv(At(e),W,s>>2,n);else{if(288>=n)for(var l=si[n-1],d=0;d<n;++d)l[d]=W[s+4*d>>2];else l=W.subarray(s>>2,s+4*n>>2);_.uniform1iv(At(e),l)}},qd:function(e,n,s){_.uniform2f(At(e),n,s)},rd:function(e,n,s){if(2<=at.version)n&&_.uniform2fv(At(e),it,s>>2,2*n);else{if(144>=n)for(var l=Te[2*n-1],d=0;d<2*n;d+=2)l[d]=it[s+4*d>>2],l[d+1]=it[s+(4*d+4)>>2];else l=it.subarray(s>>2,s+8*n>>2);_.uniform2fv(At(e),l)}},nd:function(e,n,s){_.uniform2i(At(e),n,s)},md:function(e,n,s){if(2<=at.version)n&&_.uniform2iv(At(e),W,s>>2,2*n);else{if(144>=n)for(var l=si[2*n-1],d=0;d<2*n;d+=2)l[d]=W[s+4*d>>2],l[d+1]=W[s+(4*d+4)>>2];else l=W.subarray(s>>2,s+8*n>>2);_.uniform2iv(At(e),l)}},ld:function(e,n,s,l){_.uniform3f(At(e),n,s,l)},kd:function(e,n,s){if(2<=at.version)n&&_.uniform3fv(At(e),it,s>>2,3*n);else{if(96>=n)for(var l=Te[3*n-1],d=0;d<3*n;d+=3)l[d]=it[s+4*d>>2],l[d+1]=it[s+(4*d+4)>>2],l[d+2]=it[s+(4*d+8)>>2];else l=it.subarray(s>>2,s+12*n>>2);_.uniform3fv(At(e),l)}},jd:function(e,n,s,l){_.uniform3i(At(e),n,s,l)},id:function(e,n,s){if(2<=at.version)n&&_.uniform3iv(At(e),W,s>>2,3*n);else{if(96>=n)for(var l=si[3*n-1],d=0;d<3*n;d+=3)l[d]=W[s+4*d>>2],l[d+1]=W[s+(4*d+4)>>2],l[d+2]=W[s+(4*d+8)>>2];else l=W.subarray(s>>2,s+12*n>>2);_.uniform3iv(At(e),l)}},hd:function(e,n,s,l,d){_.uniform4f(At(e),n,s,l,d)},gd:function(e,n,s){if(2<=at.version)n&&_.uniform4fv(At(e),it,s>>2,4*n);else{if(72>=n){var l=Te[4*n-1],d=it;s>>=2;for(var g=0;g<4*n;g+=4){var A=s+g;l[g]=d[A],l[g+1]=d[A+1],l[g+2]=d[A+2],l[g+3]=d[A+3]}}else l=it.subarray(s>>2,s+16*n>>2);_.uniform4fv(At(e),l)}},Wc:function(e,n,s,l,d){_.uniform4i(At(e),n,s,l,d)},Xc:function(e,n,s){if(2<=at.version)n&&_.uniform4iv(At(e),W,s>>2,4*n);else{if(72>=n)for(var l=si[4*n-1],d=0;d<4*n;d+=4)l[d]=W[s+4*d>>2],l[d+1]=W[s+(4*d+4)>>2],l[d+2]=W[s+(4*d+8)>>2],l[d+3]=W[s+(4*d+12)>>2];else l=W.subarray(s>>2,s+16*n>>2);_.uniform4iv(At(e),l)}},Yc:function(e,n,s,l){if(2<=at.version)n&&_.uniformMatrix2fv(At(e),!!s,it,l>>2,4*n);else{if(72>=n)for(var d=Te[4*n-1],g=0;g<4*n;g+=4)d[g]=it[l+4*g>>2],d[g+1]=it[l+(4*g+4)>>2],d[g+2]=it[l+(4*g+8)>>2],d[g+3]=it[l+(4*g+12)>>2];else d=it.subarray(l>>2,l+16*n>>2);_.uniformMatrix2fv(At(e),!!s,d)}},Zc:function(e,n,s,l){if(2<=at.version)n&&_.uniformMatrix3fv(At(e),!!s,it,l>>2,9*n);else{if(32>=n)for(var d=Te[9*n-1],g=0;g<9*n;g+=9)d[g]=it[l+4*g>>2],d[g+1]=it[l+(4*g+4)>>2],d[g+2]=it[l+(4*g+8)>>2],d[g+3]=it[l+(4*g+12)>>2],d[g+4]=it[l+(4*g+16)>>2],d[g+5]=it[l+(4*g+20)>>2],d[g+6]=it[l+(4*g+24)>>2],d[g+7]=it[l+(4*g+28)>>2],d[g+8]=it[l+(4*g+32)>>2];else d=it.subarray(l>>2,l+36*n>>2);_.uniformMatrix3fv(At(e),!!s,d)}},_c:function(e,n,s,l){if(2<=at.version)n&&_.uniformMatrix4fv(At(e),!!s,it,l>>2,16*n);else{if(18>=n){var d=Te[16*n-1],g=it;l>>=2;for(var A=0;A<16*n;A+=16){var y=l+A;d[A]=g[y],d[A+1]=g[y+1],d[A+2]=g[y+2],d[A+3]=g[y+3],d[A+4]=g[y+4],d[A+5]=g[y+5],d[A+6]=g[y+6],d[A+7]=g[y+7],d[A+8]=g[y+8],d[A+9]=g[y+9],d[A+10]=g[y+10],d[A+11]=g[y+11],d[A+12]=g[y+12],d[A+13]=g[y+13],d[A+14]=g[y+14],d[A+15]=g[y+15]}}else d=it.subarray(l>>2,l+64*n>>2);_.uniformMatrix4fv(At(e),!!s,d)}},$c:function(e){e=he[e],_.useProgram(e),_.bg=e},ad:function(e,n){_.vertexAttrib1f(e,n)},bd:function(e,n){_.vertexAttrib2f(e,it[n>>2],it[n+4>>2])},cd:function(e,n){_.vertexAttrib3f(e,it[n>>2],it[n+4>>2],it[n+8>>2])},dd:function(e,n){_.vertexAttrib4f(e,it[n>>2],it[n+4>>2],it[n+8>>2],it[n+12>>2])},Fc:function(e,n){_.vertexAttribDivisor(e,n)},Gc:function(e,n,s,l,d){_.vertexAttribIPointer(e,n,s,l,d)},ed:function(e,n,s,l,d,g){_.vertexAttribPointer(e,n,s,!!l,d,g)},fd:function(e,n,s,l){_.viewport(e,n,s,l)},kc:function(e,n,s,l){_.waitSync(ke[e],n,(s>>>0)+4294967296*l)},qb:e=>{var n=ft.length;if(e>>>=0,2147483648<e)return!1;for(var s=1;4>=s;s*=2){var l=n*(1+.2/s);l=Math.min(l,e+100663296);var d=Math;l=Math.max(e,l);t:{d=d.min.call(d,2147483648,l+(65536-l%65536)%65536)-gi.buffer.byteLength+65535>>>16;try{gi.grow(d),_n();var g=1;break t}catch{}g=void 0}if(g)return!0}return!1},hb:function(){return at?at.handle:0},rb:(e,n)=>{var s=0;return mr().forEach(function(l,d){var g=n+s;for(d=_t[e+4*d>>2]=g,g=0;g<l.length;++g)pe[d++>>0]=l.charCodeAt(g);pe[d>>0]=0,s+=l.length+1}),0},sb:(e,n)=>{var s=mr();_t[e>>2]=s.length;var l=0;return s.forEach(function(d){l+=d.length+1}),_t[n>>2]=l,0},Eb:e=>{q(e,new cs(e))},M:()=>52,jb:function(){return 52},xb:()=>52,mb:function(){return 70},Q:(e,n,s,l)=>{for(var d=0,g=0;g<s;g++){var A=_t[n>>2],y=_t[n+4>>2];n+=8;for(var v=0;v<y;v++){var T=ft[A+v],O=zs[e];T===0||T===10?((e===1?ut:Pe)(Fe(O,0)),O.length=0):O.push(T)}d+=y}return _t[l>>2]=d,0},yd:er,ib:nr,xd:rr,Kb:sr,L:ur,P:fr,fb:pr,Ib:Zs,j:qs,o:Js,k:Ws,I:na,Hb:ta,Fb:sa,W:ea,V:ra,O:Vs,i:Xs,w:Ks,v:Hs,s:Ys,Gb:ia,Jb:Qs,Lb:js,ob:(e,n,s,l)=>Bs(e,n,s,l)};(function(){function e(s){if(Pt=s=s.exports,gi=Pt.zd,_n(),Mt=Pt.Cd,xn.unshift(Pt.Ad),xe--,c.monitorRunDependencies&&c.monitorRunDependencies(xe),xe==0&&Ye){var l=Ye;Ye=null,l()}return s}var n={a:Gs};if(xe++,c.monitorRunDependencies&&c.monitorRunDependencies(xe),c.instantiateWasm)try{return c.instantiateWasm(n,e)}catch(s){Pe("Module.instantiateWasm callback failed with error: "+s),x(s)}return hs(n,function(s){e(s.instance)}).catch(x),{}})();var Ni=c._malloc=e=>(Ni=c._malloc=Pt.Bd)(e),we=c._free=e=>(we=c._free=Pt.Dd)(e),Sr=e=>(Sr=Pt.Ed)(e);c.__embind_initialize_bindings=()=>(c.__embind_initialize_bindings=Pt.Fd)();var It=(e,n)=>(It=Pt.Gd)(e,n),Ot=()=>(Ot=Pt.Hd)(),Dt=e=>(Dt=Pt.Id)(e);c.dynCall_viji=(e,n,s,l,d)=>(c.dynCall_viji=Pt.Jd)(e,n,s,l,d),c.dynCall_vijiii=(e,n,s,l,d,g,A)=>(c.dynCall_vijiii=Pt.Kd)(e,n,s,l,d,g,A),c.dynCall_viiiiij=(e,n,s,l,d,g,A,y)=>(c.dynCall_viiiiij=Pt.Ld)(e,n,s,l,d,g,A,y),c.dynCall_jii=(e,n,s)=>(c.dynCall_jii=Pt.Md)(e,n,s),c.dynCall_vij=(e,n,s,l)=>(c.dynCall_vij=Pt.Nd)(e,n,s,l),c.dynCall_jiiiiii=(e,n,s,l,d,g,A)=>(c.dynCall_jiiiiii=Pt.Od)(e,n,s,l,d,g,A),c.dynCall_jiiiiji=(e,n,s,l,d,g,A,y)=>(c.dynCall_jiiiiji=Pt.Pd)(e,n,s,l,d,g,A,y),c.dynCall_ji=(e,n)=>(c.dynCall_ji=Pt.Qd)(e,n),c.dynCall_iijj=(e,n,s,l,d,g)=>(c.dynCall_iijj=Pt.Rd)(e,n,s,l,d,g),c.dynCall_iiiji=(e,n,s,l,d,g)=>(c.dynCall_iiiji=Pt.Sd)(e,n,s,l,d,g),c.dynCall_iiji=(e,n,s,l,d)=>(c.dynCall_iiji=Pt.Td)(e,n,s,l,d),c.dynCall_iijjiii=(e,n,s,l,d,g,A,y,v)=>(c.dynCall_iijjiii=Pt.Ud)(e,n,s,l,d,g,A,y,v),c.dynCall_iij=(e,n,s,l)=>(c.dynCall_iij=Pt.Vd)(e,n,s,l),c.dynCall_vijjjii=(e,n,s,l,d,g,A,y,v,T)=>(c.dynCall_vijjjii=Pt.Wd)(e,n,s,l,d,g,A,y,v,T),c.dynCall_jiji=(e,n,s,l,d)=>(c.dynCall_jiji=Pt.Xd)(e,n,s,l,d),c.dynCall_viijii=(e,n,s,l,d,g,A)=>(c.dynCall_viijii=Pt.Yd)(e,n,s,l,d,g,A),c.dynCall_iiiiij=(e,n,s,l,d,g,A)=>(c.dynCall_iiiiij=Pt.Zd)(e,n,s,l,d,g,A),c.dynCall_iiiiijj=(e,n,s,l,d,g,A,y,v)=>(c.dynCall_iiiiijj=Pt._d)(e,n,s,l,d,g,A,y,v),c.dynCall_iiiiiijj=(e,n,s,l,d,g,A,y,v,T)=>(c.dynCall_iiiiiijj=Pt.$d)(e,n,s,l,d,g,A,y,v,T);function Ws(e,n,s,l){var d=Ot();try{return Mt.get(e)(n,s,l)}catch(g){if(Dt(d),g!==g+0)throw g;It(1,0)}}function js(e,n,s,l,d,g,A,y,v,T){var O=Ot();try{Mt.get(e)(n,s,l,d,g,A,y,v,T)}catch(L){if(Dt(O),L!==L+0)throw L;It(1,0)}}function Hs(e,n,s,l){var d=Ot();try{Mt.get(e)(n,s,l)}catch(g){if(Dt(d),g!==g+0)throw g;It(1,0)}}function Ks(e,n,s){var l=Ot();try{Mt.get(e)(n,s)}catch(d){if(Dt(l),d!==d+0)throw d;It(1,0)}}function Vs(e){var n=Ot();try{Mt.get(e)()}catch(s){if(Dt(n),s!==s+0)throw s;It(1,0)}}function qs(e,n){var s=Ot();try{return Mt.get(e)(n)}catch(l){if(Dt(s),l!==l+0)throw l;It(1,0)}}function Ys(e,n,s,l,d){var g=Ot();try{Mt.get(e)(n,s,l,d)}catch(A){if(Dt(g),A!==A+0)throw A;It(1,0)}}function Xs(e,n){var s=Ot();try{Mt.get(e)(n)}catch(l){if(Dt(s),l!==l+0)throw l;It(1,0)}}function Js(e,n,s){var l=Ot();try{return Mt.get(e)(n,s)}catch(d){if(Dt(l),d!==d+0)throw d;It(1,0)}}function Qs(e,n,s,l,d,g,A){var y=Ot();try{Mt.get(e)(n,s,l,d,g,A)}catch(v){if(Dt(y),v!==v+0)throw v;It(1,0)}}function Zs(e){var n=Ot();try{return Mt.get(e)()}catch(s){if(Dt(n),s!==s+0)throw s;It(1,0)}}function ta(e,n,s,l,d,g){var A=Ot();try{return Mt.get(e)(n,s,l,d,g)}catch(y){if(Dt(A),y!==y+0)throw y;It(1,0)}}function ea(e,n,s,l,d,g,A,y){var v=Ot();try{return Mt.get(e)(n,s,l,d,g,A,y)}catch(T){if(Dt(v),T!==T+0)throw T;It(1,0)}}function ia(e,n,s,l,d,g){var A=Ot();try{Mt.get(e)(n,s,l,d,g)}catch(y){if(Dt(A),y!==y+0)throw y;It(1,0)}}function na(e,n,s,l,d){var g=Ot();try{return Mt.get(e)(n,s,l,d)}catch(A){if(Dt(g),A!==A+0)throw A;It(1,0)}}function ra(e,n,s,l,d,g,A,y,v,T){var O=Ot();try{return Mt.get(e)(n,s,l,d,g,A,y,v,T)}catch(L){if(Dt(O),L!==L+0)throw L;It(1,0)}}function sa(e,n,s,l,d,g,A){var y=Ot();try{return Mt.get(e)(n,s,l,d,g,A)}catch(v){if(Dt(y),v!==v+0)throw v;It(1,0)}}var Ii;Ye=function e(){Ii||br(),Ii||(Ye=e)};function br(){function e(){if(!Ii&&(Ii=!0,c.calledRun=!0,!Cn)){if(Wi(xn),S(c),c.onRuntimeInitialized&&c.onRuntimeInitialized(),c.postRun)for(typeof c.postRun=="function"&&(c.postRun=[c.postRun]);c.postRun.length;){var n=c.postRun.shift();Fn.unshift(n)}Wi(Fn)}}if(!(0<xe)){if(c.preRun)for(typeof c.preRun=="function"&&(c.preRun=[c.preRun]);c.preRun.length;)os();Wi(En),0<xe||(c.setStatus?(c.setStatus("Running..."),setTimeout(function(){setTimeout(function(){c.setStatus("")},1),e()},1)):e())}}if(c.preInit)for(typeof c.preInit=="function"&&(c.preInit=[c.preInit]);0<c.preInit.length;)c.preInit.pop()();return br(),h.ready}})();m.exports=i}(mn)),mn.exports}var Ta=Ca(),_a=ga(Ta);class Ke{static slide(t){let i=De.linear;return typeof t.easing=="string"?i=De.fromTypeAsString(t.easing):t.easing!==void 0&&(i=t.easing),new es(t.direction,t.duration,i)}static none(){return new ts}}class ts extends Ke{constructor(){super(),this.type=Se.None,this.duration=NaN,this.easing=De.none}}class es extends Ke{constructor(t,i,r){super(),this.type=Se.Slide,this.direction=t,this.duration=i,this.easing=r}}const Se={Slide:"Slide",None:"None"},be={Up:"Up",Down:"Down",Right:"Right",Left:"Left"};class is{constructor(t,i){this.scene=t,this.transition=i}}const bn={type:"object",description:"Information about the user's device.",properties:{userAgent:{type:"string",description:"The user agent string returned by navigator.userAgent."},devicePixelRatio:{type:"number",description:"Ratio of physical pixels to CSS pixels."},screen:{type:"object",description:"Screen information returned by window.screen.",properties:{availHeight:{type:"number",description:"Height of screen, in pixels, excluding UI features."},availWidth:{type:"number",description:"Width of screen, in pixels, excluding UI features."},colorDepth:{type:"number",description:"Color depth of screen."},height:{type:"number",description:"Height of screen, in pixels"},width:{type:"number",description:"Width of screen, in pixels."},orientation:{type:"object",description:"Information about the device's orientation.",properties:{type:{type:"string",description:"The orientation type (ScreenOrientation.type)."},angle:{type:"number",description:"The orientation angle (ScreenOrientation.angle)."}}},pixelDepth:{type:"number",description:"Pixel depth of screen."}}},webGlRenderer:{type:"string",description:"WebGL driver vendor and renderer. Taken from WEBGL_debug_renderer_info."}}};class Pn{static getRendererString(){const t=document.createElement("canvas");t.id="webgl-renderer-info-canvas",t.height=0,t.width=0,t.hidden=!0,document.body.appendChild(t);const i=t.getContext("webgl");let r="no webgl context";if(!i)return r;const h=i.getExtension("WEBGL_debug_renderer_info");return h!=null?r=String(i.getParameter(h.UNMASKED_VENDOR_WEBGL))+", "+String(i.getParameter(h.UNMASKED_RENDERER_WEBGL)):r="no debug renderer info",t.remove(),r}static dispose(){const t=document.getElementById("webgl-renderer-info-canvas");t&&t.remove()}}class ns{constructor(t,i){this.sounds={},this.game=t,this.baseUrls=i}get audioContext(){if(!this._audioContext){if(!navigator.userActivation.hasBeenActive)throw new C("AudioContext cannot be created until user has interacted with the page");this._audioContext=new AudioContext}return this._audioContext}initializeSounds(t){return t?this.loadSounds(t):Promise.resolve()}loadSounds(t){return t.length===0?Promise.resolve():(t.forEach(i=>{let r=i.url;V.urlHasScheme(i.url)||(r=V.getUrlFromManifest(this.game,`${this.baseUrls.assets}/${i.url}`));const h={soundName:i.soundName,data:void 0,audioBuffer:void 0,audioBufferSource:void 0,url:r,status:i.lazy?jt.Deferred:jt.WillFetch};this.sounds[i.soundName]&&console.warn(`A sound named ${i.soundName} has already been loaded. It will be replaced.`),this.sounds[i.soundName]=h}),this.fetchSounds())}async fetchSounds(){const t=Object.values(this.sounds).map(i=>i.status===jt.WillFetch?(i.status=jt.Fetching,fetch(i.url).then(r=>{if(!r.ok)throw i.status=jt.Error,new C(`cannot fetch sound ${i.soundName} at url ${i.url}: ${r.statusText}`);return r.arrayBuffer().then(h=>{i.data=h,i.status=jt.Fetched,console.log(`\u26AA sound fetched. name: ${i.soundName}, bytes: ${h.byteLength}`)})})):Promise.resolve());await Promise.all(t)}fetchDeferredSound(t){return t.status=jt.WillFetch,this.fetchSounds()}hasSoundsToDecode(){return Object.values(this.sounds).filter(t=>t.status===jt.Fetched).length>0}decodeFetchedSounds(){const i=Object.values(this.sounds).filter(r=>r.status===jt.Fetched).map(r=>this.decodeSound(r));return Promise.all(i)}async decodeSound(t){if(!t.data)throw new C(`data is undefined for sound ${t.soundName} (url ${t.url})`);try{t.status=jt.Decoding;const i=await this.audioContext.decodeAudioData(t.data);t.audioBuffer=i,t.status=jt.Ready,console.log(`\u26AA sound decoded. name: ${t.soundName}, duration (seconds): ${i.duration}`)}catch{throw t.status=jt.Error,new C(`error decoding sound ${t.soundName} (url: ${t.url})`)}}getSound(t){const i=this.sounds[t];if(!i)throw new C(`getSound(): sound ${t} not found`);return i}dispose(){}getSoundNames(){return Object.keys(this.sounds)}}class Ea{constructor(t){this.game=t.game,this.nodeFactory=t.nodeFactory,this.freeNodesScene=t.freeNodesScene,this.configureI18n=t.configureI18n,this.eventMaterializers=new Map([[H.NodeNew,this.materializeNodeNewEvent.bind(this)],[H.Composite,this.materializeCompositeEvent.bind(this)],[H.ScenePresent,this.materializeScenePresentEvent.bind(this)],[H.NodePropertyChange,this.materializeNodePropertyChangeEvent.bind(this)],[H.NodeAddChild,this.materializeNodeAddChildEvent.bind(this)],[H.NodeRemoveChild,this.materializeNodeRemoveChildEvent.bind(this)],[H.DomPointerDown,this.materializeDomPointerDownEvent.bind(this)],[H.BrowserImageDataReady,this.materializeBrowserImageDataReadyEvent.bind(this)],[H.I18nDataReadyEvent,this.materializeI18nDataReadyEvent.bind(this)]])}materialize(t){t.length>0&&(console.log(`Replaying ${t.length} events`),t.forEach(i=>{const r=this.eventMaterializers.get(i.type);r?r(i):console.log(`EventMaterializer unhandled event: ${i.type}`)}))}materializeCompositeEvent(t){const i=this.game.materializedNodes.find(r=>r.uuid===t.target);if(!i)console.log(`EventMaterializer: composite node of type ${t.compositeType} with uuid ${t.target} not found when handling CompositeEvent ${t.compositeEventType}`);else if(i.type===dt.Composite)i.handleCompositeEvent(t);else throw new C(`EventMaterializer: node was expected to be composite, but was of type ${i.type}`)}materializeNodeNewEvent(t){const i=this.nodeFactory.createNode(t.nodeType,t.compositeType,t.nodeOptions);i.type===dt.Scene&&(i.name===Q.FREE_NODES_SCENE_NAME?(this.freeNodesScene=i,this.freeNodesScene.game=this.game,this.freeNodesScene.needsInitialization=!0,this.game.freeNodesScene=this.freeNodesScene):this.game.addScene(i)),this.game.materializedNodes.push(i)}materializeNodePropertyChangeEvent(t){const i=this.game.materializedNodes.find(r=>r.uuid===t.uuid);if(!i)throw new C(`EventMaterializer: node with uuid ${t.uuid} not found`);if(t.property in i)i[t.property]=t.value;else throw new C(`EventMaterializer: on node ${i.name}, type ${i.type}, nodePropertyChangeEvent tried to set unknown property ${t.property} to value ${JSON.stringify(t.value)}`)}materializeNodeAddChildEvent(t){const i=this.game.materializedNodes.find(h=>h.uuid===t.uuid);if(!i)throw new C(`EventMaterializer: parent node with uuid ${t.uuid} not found`);const r=this.game.materializedNodes.find(h=>h.uuid===t.childUuid);if(!r)throw new C(`EventMaterializer: child node with uuid ${t.childUuid} not found`);i.addChild(r)}materializeNodeRemoveChildEvent(t){const i=this.game.materializedNodes.find(h=>h.uuid===t.uuid);if(!i)throw new C(`EventMaterializer: parent node with uuid ${t.uuid} not found`);const r=this.game.materializedNodes.find(h=>h.uuid===t.childUuid);if(!r)throw new C(`EventMaterializer: child node with uuid ${t.childUuid} not found`);i.removeChild(r)}materializeDomPointerDownEvent(t){this.game.currentScene?.run(X.custom({callback:()=>{const i=new fi({circleOfRadius:16,fillColor:R.LightGray,strokeColor:R.Black,lineWidth:2,alpha:.75,position:{x:t.x,y:t.y}});this.game.currentScene?.addChild(i),i.run(X.sequence([X.group([X.fadeAlpha({duration:750,alpha:0}),X.scale({duration:750,scale:0})]),X.custom({callback:()=>{this.game.currentScene?.removeChild(i)}})]))}}))}materializeBrowserImageDataReadyEvent(t){this.game.imageManager.loadImages([{imageName:t.imageName,width:t.width,height:t.height,dataUrl:t.dataUrl,svgString:t.svgString}])}materializeI18nDataReadyEvent(t){this.configureI18n(t.localizationOptions)}materializeScenePresentEvent(t){let i=Ke.none();if(t.transitionType===Se.Slide){if(t.direction===void 0)throw new C("EventMaterializer: ScenePresentEvent direction is undefined for slide transition");if(t.duration===void 0)throw new C("EventMaterializer: ScenePresentEvent duration is undefined for slide transition");if(t.easingType===void 0)throw new C("EventMaterializer: ScenePresentEvent easingType is undefined for slide transition");const r=this.game.materializedNodes.find(h=>h.uuid===t.uuid);if(!r)throw new C(`EventMaterializer: Scene with uuid ${t.uuid} not found`);switch(t.direction){case be.Left:{r.position.x=r.size.width;break}case be.Right:{r.position.x=-r.size.width;break}case be.Up:{r.position.y=r.size.height;break}case be.Down:{r.position.y=-r.size.height;break}}i=Ke.slide({direction:t.direction,duration:t.duration,easing:De.fromTypeAsString(t.easingType)})}this.game.presentScene(t.uuid,i)}}class xa{constructor(t){if(this.type=ui.Game,this.sessionUuid="",this.uuid=ze.generate(),this.publishUuid="",this.canvasKitWasmVersion="0.40.0",this.beginTimestamp=NaN,this.beginIso8601Timestamp="",this.eventListeners=new Array,this.gameMetrics=new Array,this.stepCount=0,this.steppingNow=0,this.warmupFunctionQueue=new Array,this.warmupFinished=!1,this.plugins=[],this.staticTrialSchema={},this.eventStore=new $r,this.nodeFactory=new Gr,this.materializedNodes=new Array,this.data={trials:new Array,scoring:{}},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 Ve({name:Q.FREE_NODES_SCENE_NAME,backgroundColor:[255,255,255,0]}),this.incomingSceneTransitions=new Array,this.replayEventsButtonEnabled=!0,this.automaticScoringSchema={data_type:{type:"string",description:"Type of data."},study_id:{type:["string","null"],description:"The short human-readable text ID of the study (protocol, experiment, or other aggregate) that contains the administration of this activity."},study_uuid:{type:["string","null"],format:"uuid",description:"Unique identifier of the study (protocol, experiment, or other aggregate) that contains the administration of this activity."},document_uuid:{type:"string",format:"uuid",description:"Unique identifier for this data document."},session_uuid:{type:"string",format:"uuid",description:"Unique identifier for all activities in this administration of the session. This identifier changes each time a new session starts."},activity_uuid:{type:"string",format:"uuid",description:"Unique identifier for all trials in this administration of the activity. This identifier changes each time the activity starts."},activity_id:{type:"string",description:"Human-readable identifier of the activity."},activity_publish_uuid:{type:"string",format:"uuid",description:"Persistent unique identifier of the activity. This identifier never changes. It can be used to identify the activity across different studies and sessions."},activity_version:{type:"string",description:"Version of the activity."},device_timezone:{type:"string",description:"Timezone of the device. Calculated from Intl.DateTimeFormat().resolvedOptions().timeZone."},device_timezone_offset_minutes:{type:"integer",description:"Difference in minutes between UTC and device timezone. Calculated from Date.getTimezoneOffset()."},locale:{type:["string","null"],description:"Locale of the trial. null if the activity does not support localization."}},this.automaticTrialSchema={data_type:{type:"string",description:"Type of data."},study_id:{type:["string","null"],description:"The short human-readable text ID of the study (protocol, experiment, or other aggregate) that contains the administration of this activity."},study_uuid:{type:["string","null"],format:"uuid",description:"Unique identifier of the study (protocol, experiment, or other aggregate) that contains the administration of this activity."},document_uuid:{type:"string",format:"uuid",description:"Unique identifier for this data document."},session_uuid:{type:"string",format:"uuid",description:"Unique identifier for all activities in this administration of the session. This identifier changes each time a new session starts."},activity_uuid:{type:"string",format:"uuid",description:"Unique identifier for all trials in this administration of the activity. This identifier changes each time the activity starts."},activity_id:{type:"string",description:"Human-readable identifier of the activity."},activity_publish_uuid:{type:"string",format:"uuid",description:"Persistent unique identifier of the activity. This identifier never changes. It can be used to identify the activity across different studies and sessions."},activity_version:{type:"string",description:"Version of the activity."},device_timezone:{type:"string",description:"Timezone of the device. Calculated from Intl.DateTimeFormat().resolvedOptions().timeZone."},device_timezone_offset_minutes:{type:"integer",description:"Difference in minutes between UTC and device timezone. Calculated from Date.getTimezoneOffset()."},locale:{type:["string","null"],description:"Locale of the trial. null if the activity does not support localization."}},this.snapshots=new Array,!t.id||t.id.trim()==="")throw new C("id is required in GameOptions");if(!ze.isValid(t.publishUuid)){const i=t.publishUuid?`Provided publishUuid was ${t.publishUuid}. `:"";console.warn(`Missing or invalid publishUuid in GameOptions. ${i}To generate a valid UUID, visit a site such as https://www.uuidgenerator.net/version4`)}this.options=t,this.name=t.name,this.id=t.id,this.publishUuid=t.publishUuid,this.fpsMetricReportThreshold=t.fpsMetricReportThreshold??Q.FPS_METRIC_REPORT_THRESHOLD,this.maximumRecordedActivityMetrics=t.maximumRecordedActivityMetrics??Q.MAXIMUM_RECORDED_ACTIVITY_METRICS,this.addLocalizationParametersToGameParameters(),this.options.locale!==void 0&&this.setParameters({locale:this.options.locale}),this.options.fallbackLocale!==void 0&&this.setParameters({fallback_locale:this.options.fallbackLocale}),this.options.missingLocalizationColor&&this.setParameters({missing_localization_color:this.options.missingLocalizationColor}),this.options.translation&&this.setParameters({translation:this.options.translation}),this.options.additionalTranslation&&this.setParameters({translation:this.options.additionalTranslation}),this.options.trialSchema||(this.options.trialSchema={}),this.options.scoringSchema||(this.options.scoringSchema={}),t.moduleMetadata?this.moduleMetadata=t.moduleMetadata:this.moduleMetadata={name:"",version:"",dependencies:{}},t.moduleMetadata?.name&&t.version&&console.log(`\u26AA ${t.moduleMetadata.name} version ${t.version}`)}createFreeNodesScene(){this.freeNodesScene.game=this,this.freeNodesScene.needsInitialization=!0;const t={name:Q.FREE_NODES_SCENE_NAME,backgroundColor:[255,255,255,0],uuid:this.freeNodesScene.uuid},i={type:H.NodeNew,target:this.freeNodesScene,nodeType:dt.Scene,...V.createFrameUpdateTimestamps(),nodeOptions:t,sequence:m2c2Globals.eventSequence};this.eventStore.addEvent(i)}getImportedModuleBaseUrl(t,i){const r=new RegExp(`^.*${t}[^\\/]*`),h=i.match(r);if(!h||h.length===0)throw new C(`Could not calculate imported assessment package base URL. Package name: ${t}, module URL: ${i}`);return h[0]}addLocalizationParametersToGameParameters(){this.options.parameters={...this.options.parameters,...zi.makeLocalizationParameters()}}async init(){return this.initialize()}loadCanvasKit(t){return _a({locateFile:()=>t})}async resolveGameBaseUrls(t){let i,r=!1,h=`assets/${t.id}`;if(t.moduleMetadata.name)try{i=await import.meta.resolve(t.moduleMetadata.name),h=t.getImportedModuleBaseUrl(t.moduleMetadata.name,i)+"/assets",r=!0}catch{}let c=`assets/${t.id}`;try{const S=await import.meta.resolve("@m2c2kit/core");c=t.getImportedModuleBaseUrl("@m2c2kit/core",S)+"/assets"}catch{if(r)throw new C(`the package ${t.moduleMetadata.name} has been imported from a module URL (${i}), but the @m2c2kit/core package module URL could not be determined.`)}return{assets:h,canvasKitWasm:c}}async configureI18n(t){if(this.i18n=new zi(this,t),!this.i18n)throw new C("I18n object is undefined");await this.i18n.initialize(),this.eventStore.addEvent({type:"I18nDataReadyEvent",target:this.i18n,localizationOptions:t,...V.createFrameUpdateTimestamps()})}async waitForErudaInitialization(t=5e3){await new Promise(i=>{let r=0;const h=setInterval(()=>{m2c2Globals.erudaInitialized===!0&&(clearInterval(h),i(void 0)),r=r+100,r>t&&(console.warn(`Could not initialize eruda within ${t} milliseconds.`),clearInterval(h),i(void 0))},100)})}async initialize(){m2c2Globals.erudaRequested===!0&&await this.waitForErudaInitialization(),this.options.recordEvents===!0&&(this.eventStore.mode=ve.Record),this.createFreeNodesScene();const t=await this.resolveGameBaseUrls(this);if(this.manifest===void 0&&(this.manifest=await this.loadManifest()),this._canvasKit===void 0){const i=V.getUrlFromManifest(this,t.canvasKitWasm+`/canvaskit-${this.canvasKitWasmVersion}.wasm`);try{this.canvasKit=await this.loadCanvasKit(i)}catch{throw new C(`game ${this.id} could not load canvaskit wasm file from ${i}`)}}if(this.isLocalizationRequested()){const i=this.getLocalizationOptionsFromGameParameters();await this.configureI18n(i)}return this.fontManager=new Wr(this,t),this.imageManager=new fn(this,t),this.soundManager=new ns(this,t),this.eventMaterializer=new Ea({game:this,nodeFactory:this.nodeFactory,freeNodesScene:this.freeNodesScene,configureI18n:this.configureI18n.bind(this)}),Promise.all([this.fontManager.initializeFonts(this.options.fonts),this.imageManager.initializeImages(this.options.images),this.soundManager.initializeSounds(this.options.sounds)])}async loadManifest(t="__NO_M2C2KIT_MANIFEST_JSON_URL__"){if(t.includes("NO_M2C2KIT_MANIFEST_JSON_URL"))return{};let i;try{if(i=await fetch(t),!i.ok)throw new C(`Error ${i.status} on GET manifest.json from ${t}.`)}catch{throw new C(`Network error on GET manifest.json from ${t}.`)}try{return await i.json()}catch{throw new C(`Error parsing manifest.json from ${t}.`)}}get fontManager(){if(!this._fontManager)throw new C("fontManager is undefined");return this._fontManager}set fontManager(t){this._fontManager=t}get imageManager(){if(!this._imageManager)throw new C("imageManager is undefined");return this._imageManager}set imageManager(t){this._imageManager=t}get soundManager(){if(!this._soundManager)throw new C("soundManager is undefined");return this._soundManager}set soundManager(t){this._soundManager=t}get eventMaterializer(){if(!this._eventMaterializer)throw new C("eventMaterializer is undefined");return this._eventMaterializer}set eventMaterializer(t){this._eventMaterializer=t}addPrefixesToKey(t){let i="";if(this.studyId&&this.studyUuid)i=this.studyId.concat(":",this.studyUuid,":");else if(this.studyId||this.studyUuid)throw new C(`study_id and study_uuid must both be set or unset. Values are study_id: ${this.studyId}, study_uuid: ${this.studyUuid}`);return i.concat(this.id.concat(this.id,":",this.publishUuid,":",t))}storeSetItem(t,i,r=!1){const h=r?t:this.addPrefixesToKey(t);return this.dataStores[0].setItem(h,i,r?"":this.publishUuid)}storeGetItem(t,i=!1){const r=i?t:this.addPrefixesToKey(t);return this.dataStores[0].getItem(r)}storeDeleteItem(t,i=!1){const r=i?t:this.addPrefixesToKey(t);return this.dataStores[0].deleteItem(r)}storeClearItems(){return this.dataStores[0].clearItemsByActivityPublishUuid(this.publishUuid)}storeItemsKeys(t=!1){return this.dataStores[0].itemsKeysByActivityPublishUuid(t?"":this.publishUuid)}storeItemExists(t,i=!1){const r=i?t:this.addPrefixesToKey(t);return this.dataStores[0].itemExists(r)}get dataStores(){if(!this._dataStores)throw new C("dataStores is undefined");return this._dataStores}set dataStores(t){this._dataStores=t}hasDataStores(){return this._dataStores&&this._dataStores.length>0||!1}getLocalizationOptionsFromGameParameters(){const t=this.getParameter("locale"),i=this.getParameterOrFallback("fallback_locale",void 0),r=this.getParameterOrFallback("missing_localization_color",void 0),h=this.getParameterOrFallback("translation",void 0),c=this.options.translation;return{locale:t,fallbackLocale:i,missingLocalizationColor:r,additionalTranslation:h,translation:c}}isLocalizationRequested(){const t=this.getParameterOrFallback("locale",void 0);if(t==="")throw new C("Empty string in locale. Leave locale undefined or null to prevent localization.");return t==null&&this.options.translation?(this.setParameters({locale:this.options.translation.baseLocale}),!0):!(t==null&&this.options.translation===void 0)}setParameters(t){const{parameters:i}=this.options;Object.keys(t).forEach(r=>{if(r!=="diagnostics"){if(r==="eruda"){t[r]===!0&&V.loadEruda();return}if(r==="scripts"){const h=t[r];h&&V.loadScriptUrls(h);return}if(!i||!(r in i))console.warn(`game ${this.options.name} does not have a parameter named ${r}. attempt to set parameter ${r} to value ${t[r]} will be ignored`);else if(this.options.parameters&&this.options.parameters[r]){const h=t[r];let c;if(this.options.parameters[r].type!==void 0&&h!==void 0)try{c=V.convertValueToType(h,this.options.parameters[r].type)}catch(S){throw new C("Error setting parameter "+r+": "+S.message)}else c=h;this.options.parameters[r].default=c}this.additionalParameters===void 0&&(this.additionalParameters={}),this.additionalParameters[r]=t[r]}})}get canvasKit(){if(!this._canvasKit)throw new C("canvaskit is undefined");return this._canvasKit}set canvasKit(t){this._canvasKit=t}addFreeNode(t){this.freeNodesScene.addChild(t)}addFreeEntity(t){this.addFreeNode(t)}removeFreeNode(t){if(typeof t=="string"){const i=this.freeNodesScene.children.filter(r=>r.name===t).find(Boolean);if(!i)throw new C(`cannot remove free node named "${t}" because it is not currently part of the game's free nodes. `);this.freeNodesScene.removeChild(i)}else this.freeNodesScene.removeChild(t)}removeFreeEntity(t){this.removeFreeNode(t)}removeAllFreeNodes(){for(;this.freeNodesScene.children.length;)this.freeNodesScene.children.pop()}removeAllFreeEntities(){this.removeAllFreeNodes()}get freeNodes(){return this.freeNodesScene.children}get freeEntities(){return this.freeNodes}addScene(t){this.scenes.includes(t)&&console.warn(`Game.addScene(): scene ${t.toString()} has already been added to the game. This will cause unpredictable behavior. This warning will become an error in a future release.`),t.game=this,t.needsInitialization=!0,this.scenes.push(t),this.addNodeEvents(t)}addNodeEvents(t){this.eventStore.addEvents(t.nodeEvents),t.nodeEvents.length=0;for(const i of t.children)this.addNodeEvents(i)}addScenes(t){t.forEach(i=>{this.addScene(i)})}removeScene(t){if(typeof t=="object")if(this.scenes.includes(t))this.scenes=this.scenes.filter(i=>i!==t);else throw new C(`cannot remove scene ${t} from game because the scene is not currently added to the game`);else if(this.scenes.map(i=>i.name).includes(t))this.scenes=this.scenes.filter(i=>i.name!==t);else throw new C(`cannot remove scene named "${t}" from game because the scene is not currently added to the game`)}presentScene(t,i){let r;if(typeof t=="string"){if(r=this.scenes.filter(x=>x.name===t).find(Boolean),r===void 0&&(r=this.scenes.filter(x=>x.uuid===t).find(Boolean)),r===void 0)throw new C(`scene ${t} not found`)}else{if(!this.scenes.some(x=>x===t))throw new C(`scene ${t} exists, but it has not been added to the game object`);r=t}r.initialize(),r.needsInitialization=!1;const h=new is(r,i??Ke.none());this.incomingSceneTransitions.push(h),r.game.bodyBackgroundColor!==void 0?document.body.style.backgroundColor=`rgb(${r.game.bodyBackgroundColor[0]},${r.game.bodyBackgroundColor[1]},${r.game.bodyBackgroundColor[2]},${r.game.bodyBackgroundColor[3]})`:document.body.style.backgroundColor=`rgb(${r.backgroundColor[0]},${r.backgroundColor[1]},${r.backgroundColor[2]},${r.backgroundColor[3]})`;let c;i?.type===Se.Slide&&(c=i.direction);const S={type:"ScenePresent",target:r,uuid:r.uuid,...V.createFrameUpdateTimestamps(),transitionType:i?.type??Se.None,duration:i?.duration,direction:c,easingType:i?.easing?De.toTypeAsString(i.easing):void 0};this.eventStore.addEvent(S)}getParameter(t){if(this.options.parameters!==void 0&&Object.keys(this.options.parameters).includes(t))return this.options.parameters[t].default;throw new C(`game parameter ${t} not found`)}getParameterOrFallback(t,i){return this.options.parameters!==void 0&&Object.keys(this.options.parameters).includes(t)?this.options.parameters[t].default:i}hasParameter(t){return!!(this.options.parameters!==void 0&&Object.keys(this.options.parameters).includes(t))}async start(t){const i=this.options;this.setupHtmlCanvases(i.canvasId,i.width,i.height,i.stretch),this.showFps=i.showFps??!1,this.bodyBackgroundColor=i.bodyBackgroundColor,this.initData(),this.setupCanvasKitSurface(),this.setupFpsFont(),this.setupCanvasDomEventHandlers(),this.beginTimestamp=Vt.now(),this.beginIso8601Timestamp=new Date().toISOString();let r;if(t!==void 0?typeof t=="object"?r=t:r=this.scenes.filter(S=>S.name===t).find(Boolean):this.entryScene!==void 0?typeof this.entryScene=="object"?r=this.entryScene:r=this.scenes.filter(S=>S.name===this.entryScene).find(Boolean):r=this.scenes.find(Boolean),r===void 0)throw new C("cannot start game. entry scene has not been added to the game object.");if(this.presentScene(r),this.surface===void 0)throw new C("CanvasKit surface is undefined");this.options.timeStepping?(this.addTimeSteppingControlsToDom(),this.updateTimeSteppingOutput()):this.removeTimeSteppingControlsFromDom(),this.options.showEventStoreControls&&this.addEventControlsToDom(),this.warmupFinished=!1;const h={target:this,type:H.GameWarmupStart,...V.createFrameUpdateTimestamps()};this.raiseActivityEventOnListeners(h),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 c={target:this,type:H.ActivityStart,...V.createFrameUpdateTimestamps()};this.raiseActivityEventOnListeners(c)}playEventsHandler(t){if(t?.target?.id==="replay-events"&&(this.eventStore.mode=ve.Disabled,this.scenes.forEach(i=>{this.removeScene(i)}),this.currentScene=void 0,this.eventListeners=new Array,this.freeNodesScene.removeAllChildren(),this.materializedNodes=[],this.eventStore.replay(),this.setReplayEventsButtonEnabled(!1),this.setStopReplayButtonEnabled(!0)),t?.target?.id==="stop-replay"&&(this.eventStore.clearEvents(),this.setReplayEventsButtonEnabled(!0),this.setStopReplayButtonEnabled(!1)),t?.target?.id==="log-events"){if(this.eventStore.mode===ve.Replay){console.log(this.eventStore.serializedEventsBeforeReplay),console.log(`Total events: ${JSON.parse(this.eventStore.serializedEventsBeforeReplay).length}`);return}console.log(JSON.stringify(this.eventStore.getEvents())),console.log(`Total events: ${this.eventStore.getEvents().length}`)}}setReplayEventsButtonEnabled(t){const i=document.getElementById("replay-events");if(i){if(t){i.removeAttribute("disabled"),this.replayEventsButtonEnabled=!0;return}i.setAttribute("disabled","true"),this.replayEventsButtonEnabled=!1}}setStopReplayButtonEnabled(t){const i=document.getElementById("stop-replay");if(i){if(t){i.removeAttribute("disabled");return}i.setAttribute("disabled","true")}}addEventControlsToDom(){const t=document.getElementById("m2c2kit-event-controls-div");t&&t.remove();const i=document.getElementsByTagName("body")[0];if(i){const r=document.createElement("div");r.id="m2c2kit-event-controls-div",r.style.position="fixed",r.style.top="4px",r.style.left="4px",i.prepend(r);const h=document.createElement("button");h.id="replay-events",h.title="replay event recording",h.innerText="\u25B6\uFE0F",h.style.marginRight="4px",r.appendChild(h),h.addEventListener("click",this.playEventsHandler.bind(this));const c=document.createElement("button");c.id="stop-replay",c.title="stop event replay",c.innerText="\u23F9\uFE0F",c.style.marginRight="4px",c.disabled=!0,r.appendChild(c),c.addEventListener("click",this.playEventsHandler.bind(this));const S=document.createElement("button");S.id="log-events",S.title="log events to console",S.innerText="\u{1F4C4}",S.style.marginRight="4px",r.appendChild(S),S.addEventListener("click",this.playEventsHandler.bind(this));const x=document.createElement("span");x.title="optional: replay events only through a given sequence number. Default is to replay all events.",x.innerText="Replay through sequence: ",r.appendChild(x);const z=document.createElement("input");z.id="sequence-number",z.title="optional: replay events only through a given sequence number. Default is to replay all events.",z.style.marginRight="4px",r.appendChild(z)}}addTimeSteppingControlsToDom(){if(document.getElementById("m2c2kit-time-stepping-div"))return;const i=document.getElementsByTagName("body")[0];if(i){const r=document.createElement("div");r.id="m2c2kit-time-stepping-div",i.prepend(r);const h=document.createElement("button");h.id="1-step-advance",h.title="advance 1 step (16.667 ms)",h.innerText=">",h.style.marginRight="4px",r.appendChild(h),h.addEventListener("click",this.advanceStepsHandler.bind(this));const c=document.createElement("button");c.id="55-step-advance",c.title="advance 55 steps (916.667 ms)",c.innerText=">>",c.style.marginRight="4px",r.appendChild(c),c.addEventListener("click",this.advanceStepsHandler.bind(this));const S=document.createElement("input");S.id="time-stepping-steps-input",S.title="steps",S.style.width="40px",S.style.marginRight="4px",S.setAttribute("readonly","true"),r.appendChild(S);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"),r.appendChild(x)}}updateTimeSteppingOutput(){const t=document.getElementById("time-stepping-steps-input");t&&(t.value=this.stepCount.toString());const i=document.getElementById("time-stepping-now-input");i&&(i.value=this.steppingNow.toFixed(2))}advanceStepsHandler(t){t?.target?.id==="1-step-advance"?(this.steppingNow=this.steppingNow+16.66666666666667,this.stepCount=this.stepCount+1):t?.target?.id==="55-step-advance"&&(this.steppingNow=this.steppingNow+16.66666666666667*55,this.stepCount=this.stepCount+55),this.updateTimeSteppingOutput()}removeTimeSteppingControlsFromDom(){const t=document.getElementById("m2c2kit-time-stepping-div");t&&t.remove()}warmupShadersWithPrimitives(t,i=0){if(t.save(),i==0?t.scale(1/m2c2Globals.canvasScale,1/m2c2Globals.canvasScale):t.scale(1/m2c2Globals.canvasScale*1.13,1/m2c2Globals.canvasScale*1.13),!this.surface)throw new C("surface is undefined");const r=this.surface.width(),h=this.surface.height(),c=Math.round(r/2)+i,S=Math.round(h/2)+i,x=i,z=i,G=Nt.makePaint(this.canvasKit,R.White,this.canvasKit.PaintStyle.Fill,!0);t.drawRect([0,0,this.surface.width(),this.surface.height()],G);const q=Nt.makePaint(this.canvasKit,R.Black,this.canvasKit.PaintStyle.Fill,!1),st=Nt.makePaint(this.canvasKit,R.Black,this.canvasKit.PaintStyle.Fill,!0),lt=Nt.makePaint(this.canvasKit,R.Black,this.canvasKit.PaintStyle.Stroke,!1);lt.setStrokeWidth(2);const yt=Nt.makePaint(this.canvasKit,R.Black,this.canvasKit.PaintStyle.Stroke,!0);yt.setStrokeWidth(2),t.drawCircle(c,S,32,q),t.drawCircle(c,S,32,st),t.drawCircle(c,S,32,lt),t.drawCircle(c,S,32,yt);const rt=this.fontManager,Et=this.fontManager.getFontNames();if(Et.length>0&&rt.fonts[Et[0]].status===re.Ready){const Bt=rt.getTypeface(Et[0]),se=new this.canvasKit.Font(Bt,16*m2c2Globals.canvasScale);t.drawText("abc",c,S,q,se),t.drawText("abc",c,S,st,se)}const Wt=this.takeCurrentSceneSnapshot();t.drawImage(Wt,x,z),Wt.delete(),t.drawRect([x,z,16,16],q),t.drawRect([x,z,16,16],st),t.drawRect([x,z,16,16],lt),t.drawRect([x,z,16,16],yt),t.restore()}warmupShadersWithScenes(t){[...this.scenes,this.freeNodesScene].forEach(c=>{c.warmup(t)});const i=this.nodes.filter(c=>c.type===dt.Sprite).map(c=>c.imageName),r=this.imageManager.images;r&&Object.keys(r).filter(S=>S!=="__outgoingSceneSnapshot").forEach(S=>{if(!i.includes(S)&&r[S].status===ne.Ready){const x=r[S].canvaskitImage;if(!x)throw new C(`image ${S} is undefined`);t.drawImage(x,0,0)}});const h=new this.canvasKit.Paint;if(h.setColor(this.canvasKit.Color(255,255,255,1)),!this.surface)throw new C("surface is undefined");t.drawRect([0,0,this.surface.width(),this.surface.height()],h)}stop(){this.currentScene&&(this.currentScene._active=!1),this.gameStopRequested=!0,Vt.removeAll(),this.dispose()}dispose(){this.nodes.filter(t=>t.isDrawable).forEach(t=>t.dispose()),this.fontManager.dispose()}initData(){this.trialIndex=0,this.data={trials:new Array,scoring:{}};const t=this.options.trialSchema??{},i=this.options.scoringSchema??{};this.validateSchema(t),this.validateSchema(i)}validateSchema(t){const i=Object.entries(t);for(const[r,h]of i)if(h.type!==void 0&&!this.propertySchemaDataTypeIsValid(h.type))throw new C(`invalid schema. variable ${r} is type ${h.type}. type must be number, string, boolean, object, or array`)}propertySchemaDataTypeIsValid(t){const i=["string","number","integer","object","array","boolean","null"];if(typeof t=="string")return i.includes(t);let r=!0;if(Array.isArray(t))t.forEach(h=>{i.includes(h)||(r=!1)});else throw new C(`Invalid data type: ${t}`);return r}getDeviceMetadata(){const t=window.screen;return t.orientation?{userAgent:navigator.userAgent,devicePixelRatio:window.devicePixelRatio,screen:{availHeight:t.availHeight,availWidth:t.availWidth,colorDepth:t.colorDepth,height:t.height,orientation:{type:t.orientation.type,angle:t.orientation.angle},pixelDepth:t.pixelDepth,width:t.width},webGlRenderer:this.webGlRendererInfo}:{userAgent:navigator.userAgent,devicePixelRatio:window.devicePixelRatio,screen:{availHeight:t.availHeight,availWidth:t.availWidth,colorDepth:t.colorDepth,height:t.height,pixelDepth:t.pixelDepth,width:t.width},webGlRenderer:this.webGlRendererInfo}}addTrialData(t,i){if(!this.options.trialSchema)throw new C("no trial schema were provided in GameOptions. cannot add trial data");if(this.data.trials.length<this.trialIndex+1){const c={},S=Object.entries(this.options.trialSchema);for(const[x]of S)c[x]=null;this.data.trials.push({data_type:"trial",document_uuid:ze.generate(),study_id:this.studyId??null,study_uuid:this.studyUuid??null,session_uuid:this.sessionUuid,activity_uuid:this.uuid,activity_id:this.options.id,activity_publish_uuid:this.options.publishUuid,activity_version:this.options.version,device_timezone:Intl?.DateTimeFormat()?.resolvedOptions()?.timeZone??"",device_timezone_offset_minutes:new Date().getTimezoneOffset(),locale:this.i18n?.locale??null,...c,device_metadata:this.getDeviceMetadata()})}if(!(t in this.options.trialSchema))throw new C(`trial variable ${t} not defined in schema`);let r;Array.isArray(this.options.trialSchema[t].type)?r=this.options.trialSchema[t].type:r=[this.options.trialSchema[t].type];let h=typeof i;if(h==="object"&&Object.prototype.toString.call(i)==="[object Array]"&&(h="array"),i==null&&(h="null"),!r.includes(h)&&!(h==="number"&&Number.isInteger(i)&&r.includes("integer")))throw new C(`type for variable ${t} (value: ${i}) is "${h}". Based on schema for this variable, expected type was "${r}"`);this.data.trials[this.trialIndex][t]=i}addScoringData(t,i){if(!this.options.scoringSchema)throw new C("no scoring schema were provided in GameOptions. cannot add scoring data");if(Object.keys(this.data.scoring).length===0){const h={data_type:"scoring",document_uuid:ze.generate(),study_id:this.studyId??null,study_uuid:this.studyUuid??null,session_uuid:this.sessionUuid,activity_uuid:this.uuid,activity_id:this.options.id,activity_publish_uuid:this.options.publishUuid,activity_version:this.options.version,device_timezone:Intl?.DateTimeFormat()?.resolvedOptions()?.timeZone??"",device_timezone_offset_minutes:new Date().getTimezoneOffset(),locale:this.i18n?.locale??null,device_metadata:this.getDeviceMetadata()},c=Object.entries(this.options.scoringSchema);for(const[S]of c)h[S]=null;this.data.scoring=h}if(typeof t=="object"){let h;Array.isArray(t)?(t.length!==1&&console.warn(`Array of objects passed to addScoringData() is length ${t.length}. This is likely an error in the assessment's code for calculateScores().`),h=t[0]):h=t;for(const[c,S]of Object.entries(h))this.validateAndSetScoringVariable(c,S);return}const r=t;if(i===void 0)throw new C("Value must be provided when adding a single scoring variable");this.validateAndSetScoringVariable(r,i)}validateAndSetScoringVariable(t,i){if(!this.options.scoringSchema)throw new C("no scoring schema were provided in GameOptions. cannot add scoring data");if(!(t in this.options.scoringSchema))throw new C(`scoring variable ${t} not defined in schema`);let r;Array.isArray(this.options.scoringSchema[t].type)?r=this.options.scoringSchema[t].type:r=[this.options.scoringSchema[t].type];let h=typeof i;if(h==="object"&&Object.prototype.toString.call(i)==="[object Array]"&&(h="array"),i==null&&(h="null"),!r.includes(h)&&!(h==="number"&&Number.isInteger(i)&&r.includes("integer")))throw new C(`type for variable ${t} (value: ${i}) is "${h}". Based on schema for this variable, expected type was "${r}"`);this.data.scoring[t]=i}addTrialSchema(t){Object.keys(t).forEach(r=>{if(!this.options.trialSchema)throw new C("trial schema is undefined");this.options.trialSchema[r]=t[r]})}addStaticTrialData(t,i){if(!this.options.trialSchema)throw new C("trial schema is undefined");if(this.options.trialSchema[t]===void 0)throw new C(`trial variable ${t} not defined in schema`);this.staticTrialSchema[t]=i}trialComplete(){this.data.trials[this.trialIndex]?.locale&&(this.data.trials[this.trialIndex].locale=this.i18n?.locale??null),this.data.trials[this.trialIndex]?.device_metadata&&(this.data.trials[this.trialIndex].device_metadata=this.getDeviceMetadata()),Object.keys(this.staticTrialSchema).length>0&&(this.data.trials[this.trialIndex]={...this.data.trials[this.trialIndex],...this.staticTrialSchema}),this.trialIndex++;const t={type:H.ActivityData,...V.createFrameUpdateTimestamps(),target:this,newData:this.data.trials[this.trialIndex-1],newDataSchema:this.makeNewGameDataSchema(),data:this.data,dataSchema:this.makeGameDataSchema(),dataType:"Trial",activityConfiguration:this.makeGameActivityConfiguration(this.options.parameters??{}),activityConfigurationSchema:this.makeGameActivityConfigurationSchema(this.options.parameters??{}),activityMetrics:this.gameMetrics};this.raiseActivityEventOnListeners(t)}scoringComplete(){const t={type:H.ActivityData,...V.createFrameUpdateTimestamps(),target:this,newData:this.data.scoring,newDataSchema:this.makeScoringDataSchema(),data:this.data.scoring,dataSchema:this.makeScoringDataSchema(),dataType:"Scoring",activityConfiguration:this.makeGameActivityConfiguration(this.options.parameters??{}),activityConfigurationSchema:this.makeGameActivityConfigurationSchema(this.options.parameters??{}),activityMetrics:this.gameMetrics};this.raiseActivityEventOnListeners(t)}makeNewGameDataSchema(){return{description:`A single trial and metadata from the assessment ${this.name}.`,$comment:`Activity identifier: ${this.options.id}, version: ${this.options.version}.`,$schema:"https://json-schema.org/draft/2019-09/schema",type:"object",properties:{...this.automaticTrialSchema,...this.options.trialSchema,device_metadata:bn}}}makeGameDataSchema(){return{description:`All trials and metadata from the assessment ${this.name}.`,$comment:`Activity identifier: ${this.options.id}, version: ${this.options.version}.`,$schema:"https://json-schema.org/draft/2019-09/schema",type:"object",required:["trials"],properties:{trials:{type:"array",items:{$ref:"#/$defs/trial"},description:"All trials from the assessment."}},$defs:{trial:{type:"object",properties:{...this.automaticTrialSchema,...this.options.trialSchema,device_metadata:bn}}}}}makeGameActivityConfiguration(t){const i=JSON.parse(JSON.stringify(t)),{locale:r,fallback_locale:h,missing_localization_color:c,translation:S,...x}=i;for(const z in x)for(const G in x[z])G=="default"&&(x[z]=x[z][G]);return x}makeGameActivityConfigurationSchema(t){const i=JSON.parse(JSON.stringify(t)),{locale:r,fallback_locale:h,missing_localization_color:c,translation:S,...x}=i;for(const z in x){if(!("type"in x[z])&&"value"in x[z]){const G=typeof x[z].default;G!=="bigint"&&G!=="function"&&G!=="symbol"&&G!=="undefined"&&(x[z].type=G)}for(const G in x[z])G=="default"&&delete x[z][G]}return{description:`activity configuration from the assessment ${this.name}`,type:"object",properties:x}}makeScoringDataSchema(){return{description:`Scoring data 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.automaticScoringSchema,...this.options.scoringSchema,device_metadata:bn}}}end(){const t={target:this,type:H.ActivityEnd,...V.createFrameUpdateTimestamps()},i={data:this.data,dataSchema:this.makeGameDataSchema(),dataType:"Trial",activityConfiguration:this.makeGameActivityConfiguration(this.options.parameters??{}),activityConfigurationSchema:this.makeGameActivityConfigurationSchema(this.options.parameters??{}),activityMetrics:this.gameMetrics};this.raiseActivityEventOnListeners(t,i)}cancel(){const t={target:this,type:H.ActivityCancel,...V.createFrameUpdateTimestamps()},i={data:this.data,dataSchema:this.makeGameDataSchema(),dataType:"Trial",activityConfiguration:this.makeGameActivityConfiguration(this.options.parameters??{}),activityConfigurationSchema:this.makeGameActivityConfigurationSchema(this.options.parameters??{}),activityMetrics:this.gameMetrics};this.raiseActivityEventOnListeners(t,i)}setupHtmlCanvases(t,i,r,h){m2c2Globals.canvasScale=Math.round(window.devicePixelRatio*100)/100;let c;if(t===void 0){const S=document.getElementsByTagName("canvas");let x=new Array;for(let G=0;G<S.length;G++)x.push(S[G]);if(x=x.filter(G=>!G.id.startsWith("m2c2kit-scratch-canvas")),x.length===0)throw new C("no html canvas tag was found in the html");const z=x.filter(G=>G.id==="m2c2kit-canvas")[0];z?(c=z,x.length>1&&console.log("using canvas with id 'm2c2kit-canvas'")):(c=S[0],x.length>1&&console.log("using first canvas"))}else if(c=document.getElementById(t),c===void 0)throw new C(`could not find canvas HTML element with id "${t}"`);if(h||window.innerWidth<i||window.innerHeight<r){const S=r/i;window.innerHeight/window.innerWidth<S?m2c2Globals.rootScale=window.innerHeight/r:m2c2Globals.rootScale=window.innerWidth/i}c.style.width=m2c2Globals.rootScale*i+"px",c.style.height=m2c2Globals.rootScale*r+"px",c.width=m2c2Globals.rootScale*i*m2c2Globals.canvasScale,c.height=m2c2Globals.rootScale*r*m2c2Globals.canvasScale,this.htmlCanvas=c,this.canvasCssWidth=i,this.canvasCssHeight=r,m2c2Globals.canvasCssWidth=i,m2c2Globals.canvasCssHeight=r}setupCanvasKitSurface(){if(this.htmlCanvas===void 0)throw new C("main html canvas is undefined");window.logWebGl=this.options.logWebGl,this.interceptWebGlCalls();try{this.webGlRendererInfo=Pn.getRendererString()}catch{this.webGlRendererInfo="err",Pn.dispose()}const t=this.canvasKit.MakeWebGLCanvasSurface(this.htmlCanvas);if(t===null)throw new C("could not make CanvasKit surface from canvas HTML element");this.surface=t,console.log(`\u26AA CanvasKit surface is backed by ${this.surface.reportBackendTypeIsGPU()?"GPU":"CPU"}`),this.surface.getCanvas().scale(m2c2Globals.canvasScale,m2c2Globals.canvasScale)}interceptWebGlCalls(){if(!this.htmlCanvas.__proto__.m2c2ModifiedGetContext){this.htmlCanvas.__proto__.m2c2ModifiedGetContext=!0;const t=this.htmlCanvas.__proto__.getContext;this.htmlCanvas.__proto__.getContext=function(...i){window.logWebGl&&console.log(`\u{1F53C} getContext(${i.map(h=>h.toString()).join(", ")})`);const r=t.apply(this,[...i]);if(r.__proto__.compileShader&&!r.__proto__.m2c2ModifiedCompileShader){r.__proto__.m2c2ModifiedCompileShader=!0;const h=r.__proto__.compileShader;r.__proto__.compileShader=function(...c){if(window.logWebGl){const S=c[0],x=r.getShaderSource(S);console.log("\u{1F53C} compileShader():"),console.log(x)}return h.apply(this,[...c])}}return r}}}setupFpsFont(){this.fpsTextFont=new this.canvasKit.Font(null,Q.FPS_DISPLAY_TEXT_FONT_SIZE*m2c2Globals.canvasScale),this.fpsTextPaint=new this.canvasKit.Paint,this.fpsTextPaint.setColor(this.canvasKit.Color(Q.FPS_DISPLAY_TEXT_COLOR[0],Q.FPS_DISPLAY_TEXT_COLOR[1],Q.FPS_DISPLAY_TEXT_COLOR[2],Q.FPS_DISPLAY_TEXT_COLOR[3])),this.fpsTextPaint.setAntiAlias(!0)}setupCanvasDomEventHandlers(){if(this.htmlCanvas===void 0)throw new C("main html canvas is undefined");this.htmlCanvas.addEventListener("pointerdown",this.htmlCanvasPointerDownHandler.bind(this)),this.htmlCanvas.addEventListener("pointerup",this.htmlCanvasPointerUpHandler.bind(this)),this.htmlCanvas.addEventListener("pointermove",this.htmlCanvasPointerMoveHandler.bind(this)),this.htmlCanvas.addEventListener("touchstart",t=>{t.preventDefault()}),this.htmlCanvas.addEventListener("pointerleave",this.htmlCanvasPointerLeaveHandler.bind(this)),document.addEventListener("keydown",this.documentKeyDownHandler.bind(this)),document.addEventListener("keyup",this.documentKeyUpHandler.bind(this))}loop(t){if(!this.surface)throw new C("surface is undefined");if(this.warmupFunctionQueue.length>0){const i=this.warmupFunctionQueue.shift();i?.warmupFunction.call(this,t,i.positionOffset),this.surface.requestAnimationFrame(this.loop.bind(this));return}if(!this.warmupFinished){this.warmupFinished=!0;const i={target:this,type:H.GameWarmupEnd,...V.createFrameUpdateTimestamps()};this.raiseActivityEventOnListeners(i),this.surface.requestAnimationFrame(this.loop.bind(this));return}if(this.soundManager.hasSoundsToDecode()&&navigator.userActivation.hasBeenActive&&this.soundManager.decodeFetchedSounds(),this.gameStopRequested){this.surface.deleteLater();return}if(this.animationFramesRequested++,!this.limitFps||this.animationFramesRequested%Math.round(60/Q.LIMITED_FPS_RATE)===0){if(this.currentScene===void 0&&this.incomingSceneTransitions.length===0&&this.eventStore.mode!==ve.Replay)throw new C("Can not run game without a current or incoming scene");if(this.updateGameTime(),this.eventStore.mode===ve.Replay){const i=this.eventStore.dequeueEvents(Vt.now());this.eventMaterializer.materialize(i),this.eventStore.eventQueueLength===0&&!this.replayEventsButtonEnabled&&(this.setReplayEventsButtonEnabled(!0),this.setStopReplayButtonEnabled(!1))}for(this.handleIncomingSceneTransitions(this.incomingSceneTransitions),this.update(),this.draw(t);this.snapshots.length>0;)this.snapshots.shift()?.delete();this.snapshots.push(this.takeCurrentSceneSnapshot()),this.freeNodesScene.draw(t),this.pendingScreenshot&&(this.handlePendingScreenshot(this.pendingScreenshot),this.pendingScreenshot=void 0)}this.priorUpdateTime=m2c2Globals.now,this.surface.requestAnimationFrame(this.loop.bind(this))}updateGameTime(){this.options.timeStepping?m2c2Globals.now=this.steppingNow:m2c2Globals.now=performance.now(),this.priorUpdateTime?m2c2Globals.deltaTime=m2c2Globals.now-this.priorUpdateTime:m2c2Globals.deltaTime=0}handleIncomingSceneTransitions(t){if(t.length!==0&&(this.snapshots.length>0||t[0].transition.type===Se.None)){const i=t.shift();if(i===void 0)throw new C("no incoming scene transition");const r=i.scene,h=i.transition;if(h.type===Se.None){this.currentScene&&(this.currentScene._active=!1),this.currentScene=r,this.currentScene._active=!0,this.raiseSceneEvent(r,"SceneSetup"),this.raiseSceneEvent(r,"SceneAppear");return}if(this.currentSceneSnapshot=this.snapshots.shift(),!this.currentSceneSnapshot)throw new C("No snapshot available for outgoing scene");const c=this.createOutgoingScene(this.currentSceneSnapshot);c._active=!0,this.currentScene&&(this.currentScene._active=!1),this.currentScene=r,this.currentScene._active=!0,this.raiseSceneEvent(r,"SceneSetup"),this.animateSceneTransition(r,h,c)}}createOutgoingScene(t){const i=new Ve({name:Q.OUTGOING_SCENE_NAME});i.size.width=this.canvasCssWidth,i.size.height=this.canvasCssHeight,this.addScene(i);const r={imageName:Q.OUTGOING_SCENE_IMAGE_NAME,canvaskitImage:t,width:this.canvasCssWidth,height:this.canvasCssHeight,status:ne.Ready,localize:!1,isFallback:!1};this.imageManager.addImage(r);const h=new pi({name:Q.OUTGOING_SCENE_SPRITE_NAME,imageName:Q.OUTGOING_SCENE_IMAGE_NAME,position:{x:this.canvasCssWidth/m2c2Globals.rootScale/2,y:this.canvasCssHeight/m2c2Globals.rootScale/2}});return h.scale=1/m2c2Globals.rootScale,i.addChild(h),i}async registerPlugin(t){if(t.type!==ui.Game)throw new C(`registerPlugin(): plugin ${t.id} is not a game plugin. It is a ${t.type} plugin.`);if(this.plugins.includes(t)||this.plugins.map(i=>i.id).includes(t.id))throw new C(`registerPlugin(): plugin ${t.id} already registered.`);this.plugins.push(t),t.initialize&&await t.initialize(this)}update(){this.executeBeforeUpdatePlugins(),this.updateScenes(),this.executeAfterUpdatePlugins()}updateScenes(){this.scenes.filter(t=>t._active).forEach(t=>t.update()),this.freeNodesScene.update()}executeBeforeUpdatePlugins(){this.plugins.filter(t=>typeof t.beforeUpdate=="function"&&t.disabled!==!0).forEach(t=>{t.beforeUpdate&&t.beforeUpdate(this,m2c2Globals.deltaTime)})}executeAfterUpdatePlugins(){this.plugins.filter(t=>typeof t.afterUpdate=="function"&&t.disabled!==!0).forEach(t=>{t.afterUpdate&&t.afterUpdate(this,m2c2Globals.deltaTime)})}draw(t){this.scenes.filter(i=>i._active).forEach(i=>i.draw(t)),this.drawnFrames++,this.calculateFps(),this.showFps&&this.drawFps(t)}calculateFps(){this.lastFpsUpdate===0?(this.lastFpsUpdate=m2c2Globals.now,this.nextFpsUpdate=m2c2Globals.now+Q.FPS_DISPLAY_UPDATE_INTERVAL):m2c2Globals.now>=this.nextFpsUpdate&&(this.fpsRate=this.drawnFrames/((m2c2Globals.now-this.lastFpsUpdate)/1e3),this.drawnFrames=0,this.lastFpsUpdate=m2c2Globals.now,this.nextFpsUpdate=m2c2Globals.now+Q.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:Q.FPS_DISPLAY_UPDATE_INTERVAL,fps_report_threshold:this.fpsMetricReportThreshold,activity_type:ui.Game,activity_uuid:this.uuid,iso8601_timestamp:new Date().toISOString()}))}takeCurrentSceneSnapshot(){if(this.surface===void 0)throw new C("CanvasKit surface is undefined");return this.surface.makeImageSnapshot()}handlePendingScreenshot(t){if(!this.surface)throw new C("no surface");let i;if(t.rect.length==4){const h=t.rect[0]*m2c2Globals.canvasScale,c=t.rect[1]*m2c2Globals.canvasScale,S=t.rect[2]*m2c2Globals.canvasScale,x=t.rect[3]*m2c2Globals.canvasScale,z=[h,c,h+S,c+x];i=this.surface.makeImageSnapshot(z)}else i=this.surface.makeImageSnapshot();const r=i.encodeToBytes();t.promiseResolve(r)}takeScreenshot(t,i,r,h){if(!this.surface)throw new C("no canvaskit surface. unable to take screenshot.");const c=[t,i,r,h].map(S=>S?0:1).reduce((S,x)=>S+x);return new Promise((S,x)=>{switch(c){case 0:{if(!t||!i||!r||!h){x("missing values in arguments for takeScreenshot()");return}this.pendingScreenshot={rect:[t,i,r,h],promiseResolve:S};break}case 4:{this.pendingScreenshot={rect:[],promiseResolve:S};break}default:x("Exactly 0 or 4 arguments must be supplied to takeScreenshot()")}})}animateSceneTransition(t,i,r){const h=i.duration;switch(t._transitioning=!0,r._transitioning=!0,i.type){case Se.Slide:{switch(i.direction){case be.Left:t.position.x=t.size.width,t.run(X.sequence([X.move({point:{x:0,y:0},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{t._transitioning=!1,this.raiseSceneEvent(t,"SceneAppear"),this.removeScene(Q.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),r.run(X.sequence([X.move({point:{x:-r.size.width,y:0},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{r._active=!1,r._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;case be.Right:t.position.x=-t.size.width,t.run(X.sequence([X.move({point:{x:0,y:0},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{t._transitioning=!1,this.raiseSceneEvent(t,"SceneAppear"),this.removeScene(Q.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),r.run(X.sequence([X.move({point:{x:r.size.width,y:0},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{r._active=!1,r._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;case be.Up:t.position.y=t.size.height,t.run(X.sequence([X.move({point:{x:0,y:0},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{t._transitioning=!1,this.raiseSceneEvent(t,"SceneAppear"),this.removeScene(Q.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),r.run(X.sequence([X.move({point:{x:0,y:-r.size.height},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{r._active=!1,r._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;case be.Down:t.position.y=-t.size.height,t.run(X.sequence([X.move({point:{x:0,y:0},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{t._transitioning=!1,this.raiseSceneEvent(t,"SceneAppear"),this.removeScene(Q.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),r.run(X.sequence([X.move({point:{x:0,y:r.size.height},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{r._active=!1,r._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;default:throw new C("unknown transition direction")}break}default:throw new C("unknown transition type")}}drawFps(t){t.save();const i=m2c2Globals.canvasScale;if(t.scale(1/i,1/i),!this.fpsTextFont||!this.fpsTextPaint)throw new C("fps font or paint is undefined");t.drawText("FPS: "+this.fpsRate.toFixed(2),0,0+Q.FPS_DISPLAY_TEXT_FONT_SIZE*i,this.fpsTextPaint,this.fpsTextFont),t.restore()}createEventListener(t,i,r,h){const c=this.nodes.filter(x=>x.name===i);c.length>1&&console.warn(`warning: createEventListener() found more than one node with name ${i}. Event listener will be attached to first node found. All nodes that receive tap events should be uniquely named`);const S=c.filter(x=>x.name===i).find(Boolean);if(S===void 0)throw new C(`could not create event listener. node with name ${i} could not be found in the game node tree`);if(!Object.values(H).includes(t))throw new C(`game ${this.id}: could not create event listener. event type ${t} is not known`);S.addEventListener(t,r,h)}get nodes(){function t(r,h){h.push(r),r.children.forEach(c=>t(c,h))}const i=new Array;return[...this.scenes,this.freeNodesScene].forEach(r=>t(r,i)),i}get entities(){return this.nodes}htmlCanvasPointerDownHandler(t){t.preventDefault();const i=this.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;if(!this.htmlCanvas)throw new C("main html canvas is undefined");const r={type:"DomPointerDown",target:this.htmlCanvas,x:t.offsetX/m2c2Globals.rootScale,y:t.offsetY/m2c2Globals.rootScale,...V.createTimestamps()};this.eventStore.addEvent(r);const h={target:i,type:H.PointerDown,handled:!1,...V.createTimestamps()};this.processDomPointerDown(this.freeNodesScene,h,t),this.processDomPointerDown(i,h,t)}htmlCanvasPointerUpHandler(t){t.preventDefault();const i=this.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;const r={target:i,type:H.PointerUp,handled:!1,...V.createTimestamps()};this.processDomPointerUp(this.freeNodesScene,r,t),this.processDomPointerUp(i,r,t)}htmlCanvasPointerMoveHandler(t){t.preventDefault();const i=this.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;const r={target:i,type:H.PointerMove,handled:!1,...V.createTimestamps()};this.processDomPointerMove(this.freeNodesScene,r,t),this.processDomPointerMove(i,r,t)}htmlCanvasPointerLeaveHandler(t){if(!this.currentScene)return;t.preventDefault();const i=this.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;const r={target:i,type:H.PointerLeave,handled:!1,...V.createTimestamps()};this.processDomPointerLeave(this.freeNodesScene,r,t),this.processDomPointerLeave(i,r,t)}documentKeyDownHandler(t){const i=this.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;const r={target:i,type:H.KeyDown,handled:!1,...V.createTimestamps()};this.raiseEventOnListeningNodes(this.freeNodesScene,r,t),this.raiseEventOnListeningNodes(i,r,t)}documentKeyUpHandler(t){const i=this.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;const r={target:i,type:H.KeyUp,handled:!1,...V.createTimestamps()};this.raiseEventOnListeningNodes(this.freeNodesScene,r,t),this.raiseEventOnListeningNodes(i,r,t)}processDomPointerDown(t,i,r){i.handled||(t.isUserInteractionEnabled&&this.IsCanvasPointWithinNodeBounds(t,r.offsetX,r.offsetY)&&(t.pressed=!0,t.pressedAndWithinHitArea=!0,t.pressedInitialPointerOffset={x:r.offsetX,y:r.offsetY},this.raiseM2PointerDownEvent(t,i,r),this.raiseTapDownEvent(t,i,r)),t.children&&t.children.filter(h=>!h.hidden).filter(h=>h.isDrawable).sort((h,c)=>{const S=c.zPosition-h.zPosition;return S!==0?S:t.children.indexOf(c)-t.children.indexOf(h)}).forEach(h=>this.processDomPointerDown(h,i,r)))}processDomPointerUp(t,i,r){if(!i.handled){if(t.dragging){t.dragging=!1,t.pressed=!1,t.pressedAndWithinHitArea=!1,this.raiseM2DragEndEvent(t,i,r);return}t.isUserInteractionEnabled&&t.pressed&&t.pressedAndWithinHitArea?(t.pressed=!1,t.pressedAndWithinHitArea=!1,this.raiseTapUpEvent(t,i,r),this.raiseTapUpAny(t,i,r),this.raiseM2PointerUpEvent(t,i,r)):t.isUserInteractionEnabled&&t.pressed&&t.pressedAndWithinHitArea==!1?(t.pressed=!1,t.pressedAndWithinHitArea=!1,this.raiseTapUpAny(t,i,r)):t.isUserInteractionEnabled&&this.IsCanvasPointWithinNodeBounds(t,r.offsetX,r.offsetY)&&(t.pressed=!1,t.pressedAndWithinHitArea=!1,this.raiseM2PointerUpEvent(t,i,r)),t.children&&t.children.filter(h=>!h.hidden).filter(h=>h.isDrawable).sort((h,c)=>{const S=c.zPosition-h.zPosition;return S!==0?S:t.children.indexOf(c)-t.children.indexOf(h)}).forEach(h=>this.processDomPointerUp(h,i,r))}}processDomPointerMove(t,i,r){if(!i.handled){if(t.isUserInteractionEnabled&&t.draggable&&t.pressed){let h=!1,c,S;t.dragging===!1?(t.dragging=!0,h=!0,c=r.offsetX-t.pressedInitialPointerOffset.x,S=r.offsetY-t.pressedInitialPointerOffset.y):(c=r.offsetX-t.draggingLastPointerOffset.x,S=r.offsetY-t.draggingLastPointerOffset.y),t.position.x+=c,t.position.y+=S,t.draggingLastPointerOffset={x:r.offsetX,y:r.offsetY},h?this.raiseM2DragStartEvent(t,i,r):this.raiseM2DragEvent(t,i,r);return}t.isUserInteractionEnabled&&t.pressed&&t.pressedAndWithinHitArea&&!this.IsCanvasPointWithinNodeBounds(t,r.offsetX,r.offsetY)&&(t.pressedAndWithinHitArea=!1,this.raiseTapLeaveEvent(t,i,r)),t.isUserInteractionEnabled&&this.IsCanvasPointWithinNodeBounds(t,r.offsetX,r.offsetY)&&(this.raiseM2PointerMoveEvent(t,i,r),t.withinHitArea=!0),t.isUserInteractionEnabled&&t.withinHitArea&&!this.IsCanvasPointWithinNodeBounds(t,r.offsetX,r.offsetY)&&(t.withinHitArea=!1,this.raiseM2PointerLeaveEvent(t,i,r)),t.children&&t.children.filter(h=>!h.hidden).filter(h=>h.isDrawable).sort((h,c)=>{const S=c.zPosition-h.zPosition;return S!==0?S:t.children.indexOf(c)-t.children.indexOf(h)}).forEach(h=>this.processDomPointerMove(h,i,r))}}processDomPointerLeave(t,i,r){if(!i.handled){if(t.dragging){const h={target:t,type:H.DragEnd,handled:!1,...V.createTimestamps()};t.dragging=!1,t.pressed=!1,t.pressedAndWithinHitArea=!1,this.raiseM2DragEndEvent(t,h,r);return}t.isUserInteractionEnabled&&t.pressed&&t.pressedAndWithinHitArea&&!this.IsCanvasPointWithinNodeBounds(t,r.offsetX,r.offsetY)&&(t.pressedAndWithinHitArea=!1,this.raiseTapLeaveEvent(t,i,r)),t.isUserInteractionEnabled&&t.withinHitArea&&!this.IsCanvasPointWithinNodeBounds(t,r.offsetX,r.offsetY)&&(t.withinHitArea=!1,this.raiseM2PointerLeaveEvent(t,i,r)),t.children&&t.children.filter(h=>!h.hidden).filter(h=>h.isDrawable).sort((h,c)=>{const S=c.zPosition-h.zPosition;return S!==0?S:t.children.indexOf(c)-t.children.indexOf(h)}).forEach(h=>this.processDomPointerLeave(h,i,r))}}raiseM2PointerDownEvent(t,i,r){i.target=t,i.type=H.PointerDown,this.raiseEventOnListeningNodes(t,i,r)}raiseTapDownEvent(t,i,r){i.target=t,i.type=H.TapDown,this.raiseEventOnListeningNodes(t,i,r)}raiseTapLeaveEvent(t,i,r){i.target=t,i.type=H.TapLeave,this.raiseEventOnListeningNodes(t,i,r)}raiseM2PointerUpEvent(t,i,r){i.target=t,i.type=H.PointerUp,this.raiseEventOnListeningNodes(t,i,r)}raiseTapUpEvent(t,i,r){i.target=t,i.type=H.TapUp,this.raiseEventOnListeningNodes(t,i,r)}raiseTapUpAny(t,i,r){i.target=t,i.type=H.TapUpAny,this.raiseEventOnListeningNodes(t,i,r)}raiseM2PointerMoveEvent(t,i,r){i.target=t,i.type=H.PointerMove,this.raiseEventOnListeningNodes(t,i,r)}raiseM2PointerLeaveEvent(t,i,r){i.target=t,i.type=H.PointerLeave,this.raiseEventOnListeningNodes(t,i,r)}raiseM2DragStartEvent(t,i,r){i.target=t,i.type=H.DragStart,this.raiseEventOnListeningNodes(t,i,r)}raiseM2DragEvent(t,i,r){i.target=t,i.type=H.Drag,this.raiseEventOnListeningNodes(t,i,r)}raiseM2DragEndEvent(t,i,r){i.target=t,i.type=H.DragEnd,this.raiseEventOnListeningNodes(t,i,r)}raiseSceneEvent(t,i){const r={target:t,type:i,...V.createFrameUpdateTimestamps()};t.eventListeners.filter(h=>h.type===i).forEach(h=>h.callback(r))}calculatePointWithinNodeFromDomPointerEvent(t,i){let r=t.size.width,h=t.size.height;if(t.type===dt.Shape&&t.shapeType===Kt.Circle){const q=t.circleOfRadius;if(!q)throw"circleOfRadius is undefined";r=q*2,h=q*2}let c=i.offsetX,S=i.offsetY;const x=V.calculateNodeAbsoluteBoundingBox(t);V.nodeOrAncestorHasBeenRotated(t)&&V.calculateRotationTransforms(t).forEach(st=>{const lt=V.rotatePoint({x:c,y:S},-st.radians,st.center);c=lt.x,S=lt.y});const z=(c-x.xMin)/(x.xMax-x.xMin)*r,G=(S-x.yMin)/(x.yMax-x.yMin)*h;return{x:z,y:G}}onStart(t,i){this.addEventListener(H.ActivityStart,t,i)}onCancel(t,i){this.addEventListener(H.ActivityCancel,t,i)}onEnd(t,i){this.addEventListener(H.ActivityEnd,t,i)}onData(t,i){this.addEventListener(H.ActivityData,t,i)}onWarmupStart(t,i){this.addEventListener(H.GameWarmupStart,t,i)}onWarmupEnd(t,i){this.addEventListener(H.GameWarmupEnd,t,i)}addEventListener(t,i,r){const h={type:t,activityUuid:this.uuid,callback:i};r?.replaceExisting&&(this.eventListeners=this.eventListeners.filter(c=>!(c.activityUuid===h.activityUuid&&c.type===h.type))),this.eventListeners.push(h)}raiseActivityEventOnListeners(t,i){i&&(t={...t,...i}),this.eventListeners.filter(r=>r.type===t.type).forEach(r=>{r.callback(t)})}raiseEventOnListeningNodes(t,i,r){t.eventListeners.filter(h=>h.type===i.type).forEach(h=>{if(h.nodeUuid===t.uuid){switch(i.target=t,i.type){case H.PointerDown:case H.PointerMove:case H.PointerUp:case H.PointerLeave:i.point=this.calculatePointWithinNodeFromDomPointerEvent(t,r),i.buttons=r.buttons,h.callback(i);break;case H.KeyDown:case H.KeyUp:i.key=r.key,i.code=r.code,i.shiftKey=r.shiftKey,i.ctrlKey=r.ctrlKey,i.metaKey=r.metaKey,i.altKey=r.altKey,i.repeat=r.repeat,h.callback(i);break;case H.TapDown:case H.TapUp:case H.TapUpAny:case H.TapLeave:i.point=this.calculatePointWithinNodeFromDomPointerEvent(t,r),i.buttons=r.buttons,h.callback(i);break;case H.DragStart:case H.Drag:case H.DragEnd:i.position={x:t.position.x,y:t.position.y},i.buttons=r.buttons,h.callback(i);break}t.suppressEvents||this.eventStore.addEvent(i)}})}sceneCanReceiveUserInteraction(t){return!!(t._active&&t._transitioning===!1)}IsCanvasPointWithinNodeBounds(t,i,r){if(!t.isDrawable)throw"only drawable nodes can receive pointer events";if(t.type===dt.Shape&&t.shapeType===Kt.Circle){const c=V.calculateNodeAbsoluteBoundingBox(t),S=t.circleOfRadius;if(!S)throw"circleOfRadius is undefined";const x={x:c.xMin+S*t.absoluteScale,y:c.yMin+S*t.absoluteScale};return Math.sqrt(Math.pow(i-x.x,2)+Math.pow(r-x.y,2))<=S*t.absoluteScale}if(t.size.width===0||t.size.height===0||t.type===dt.TextLine&&isNaN(t.size.width))return!1;const h=V.calculateRotatedPoints(t);return t.isUserInteractionEnabled&&V.isPointInsideRectangle({x:i,y:r},h)}}function Fa(){globalThis.m2c2Globals={now:performance.now(),iso8601Now:"",deltaTime:NaN,canvasScale:NaN,rootScale:1,canvasCssWidth:NaN,canvasCssHeight:NaN,m2NodeClassRegistry:{},__sequence:0,get eventSequence(){return m2c2Globals.__sequence++,m2c2Globals.__sequence-1},addedScriptUrls:[]}}Fa();const rs=class as{constructor(t){this.startTime=NaN,this.stopTime=NaN,this.stopped=!0,this.cumulativeElapsed=NaN,this.name=t}static now(){return window.performance.now()}static start(t){let i=this._timers.filter(r=>r.name===t).find(Boolean);if(i===void 0)i=new as(t),i.cumulativeElapsed=0,this._timers.push(i);else if(i.stopped==!1)throw new C(`can't start timer. timer with name ${t} is already started`);i.startTime=window.performance.now(),i.stopped=!1}static stop(t){const i=this._timers.filter(r=>r.name===t).find(Boolean);if(i===void 0)throw new C(`can't stop timer. timer with name ${t} does not exist`);if(i.stopped===!0)throw new C(`can't stop timer. timer with name ${t} is already stopped`);i.stopTime=window.performance.now(),i.cumulativeElapsed=i.cumulativeElapsed+i.stopTime-i.startTime,i.stopped=!0}static restart(t){const i=this._timers.filter(r=>r.name===t).find(Boolean);if(i===void 0)throw new C(`can't restart timer. timer with name ${t} does not exist`);i.startTime=window.performance.now(),i.cumulativeElapsed=0,i.stopped=!1}static elapsed(t){const i=this._timers.filter(r=>r.name===t).find(Boolean);if(i===void 0)throw new C(`can't get elapsed time. timer with name ${t} does not exist`);return i.stopped?i.cumulativeElapsed:i.cumulativeElapsed+window.performance.now()-i.startTime}static remove(t){if(this._timers.filter(r=>r.name===t).find(Boolean)===void 0)throw new C(`can't remove timer. timer with name ${t} does not exist`);this._timers=this._timers.filter(r=>r.name!=t)}static removeAll(){this._timers=new Array}static exists(t){return this._timers.some(i=>i.name===t)}};rs._timers=new Array;let Ma=rs;class An{static SingleFromRange(t,i){return Math.floor(Math.random()*(i-t+1))+t}static FromRangeWithoutReplacement(t,i,r){if(t>r-i+1)throw new C(`number of requested draws (n = ${t}) is greater than number of integers in range [ ${i}, ${r}]`);const h=new Array;for(let c=0;c<t;c++){const S=An.SingleFromRange(i,r);h.includes(S)?t++:h.push(S)}return h}static FromGridWithoutReplacement(t,i,r,h){const c=new Array,S=i*r-1,x=this.FromRangeWithoutReplacement(t,0,S);let z=0,G=NaN;for(;z<t;){const q=x[z]%r,st=(x[z]-q)/r;if(h===void 0||h(st,q))c.push({row:st,column:q}),z++;else{do G=this.FromRangeWithoutReplacement(1,0,S)[0];while(x.includes(G));x[z]=G}}return c}}class Ra extends fe{constructor(t){super(t),this.type=dt.SoundPlayer,this.isDrawable=!1,this.soundName=t.soundName}initialize(){}removeAction(t){const i=this.actions.find(r=>r.key===t);i?.type===mt.Play&&this.stopSoundActionAudio(i),this.actions=this.actions.filter(r=>r.key!==t)}removeAllActions(){for(;this.actions.length;){const t=this.actions.pop();t?.type===mt.Play&&this.stopSoundActionAudio(t)}}stopSoundActionAudio(t){if(t.running){const i=this.game.soundManager.getSound(this.soundName);i.audioBufferSource?.stop(),i.audioBufferSource?.disconnect()}}dispose(){}duplicate(t){throw new C("Method not implemented.")}}class ka extends fe{constructor(t){if(super(t),this.type=dt.SoundRecorder,this.isDrawable=!1,this._isRecording=!1,this._isPaused=!1,this.audioChunks=[],this.timerUuid="",t?.mimeType){const i=this.getMediaRecorderSupportedAudioMimeTypes();if(i.includes(t.mimeType))this.mimeType=t.mimeType;else if(console.warn(`Unsupported MIME type in SoundRecorderOptions: ${t.mimeType}. Supported types are: ${i}.`),t.backupMimeTypes){const r=this.getSupportedBackupMimeType(t.backupMimeTypes);r&&(this.mimeType=r,console.log(`Using backup MIME type: ${r}.`))}}t?.audioTrackConstraints&&(this.audioTrackConstraints=t.audioTrackConstraints),t?.maximumDuration&&(this.maximumDuration=t.maximumDuration)}initialize(){}async start(){if(this.isRecording)throw new C("cannot start SoundRecorder because it is already started.");this.audioChunks=[],this.endIso8601Timestamp=void 0;const t=this.getMediaRecorderSupportedAudioMimeTypes();if(t.length===0)throw new C("SoundRecorder found no supported MIME types for MediaRecorder.");this.mimeType||(this.mimeType=t[0],console.log(`Using MIME type: ${this.mimeType}.`));let i;try{i=await navigator.mediaDevices.getUserMedia({audio:this.audioTrackConstraints?this.audioTrackConstraints:!0})}catch(h){throw new C(`Error getting user media: ${h}.`)}if(!i)throw new C("no stream.");const r=i.getAudioTracks();this.mediaTrackSettings=r?.map(h=>h.getSettings()),this.mediaRecorder=new MediaRecorder(i,{mimeType:this.mimeType}),this.mediaRecorder.ondataavailable=h=>{this.audioChunks.push(h.data)},this.mediaRecorder.onerror=h=>{throw new C(`MediaRecorder error: ${h?.error?.message} ${h?.message}`)},this.mediaRecorder.start(),this.beginIso8601Timestamp=new Date().toISOString(),this.timerUuid=ze.generate(),Vt.startNew(this.timerUuid),this._isRecording=!0,this._isPaused=!1}async stop(){if(!this.isRecording)throw new C("cannot stop SoundRecorder because it has not started.");return new Promise(t=>{if(!this.mediaRecorder)throw new C("no media recorder");this.mediaRecorder.onstop=async()=>{if(!this.mimeType)throw new C("no mimeType");this._isRecording=!1,this._isPaused=!1;const i=new Blob(this.audioChunks,{type:this.getMimeTypeWithoutCodecs(this.mimeType)}),r=await this.blobToBase64(i);t({mimeType:this.mimeType,beginIso8601Timestamp:this.beginIso8601Timestamp??"",endIso8601Timestamp:this.endIso8601Timestamp??"",duration:Vt.elapsed(this.timerUuid),audioTrackSettings:this.mediaTrackSettings,audioBase64:r,audioBlob:i})},this.mediaRecorder.stop(),this.endIso8601Timestamp=new Date().toISOString(),this.isPaused||Vt.stop(this.timerUuid)})}pause(){if(!this.isRecording)throw new C("cannot pause SoundRecorder because it is not started.");if(this.isPaused)throw new C("cannot pause SoundRecorder because it is already paused.");this.mediaRecorder?.pause(),this._isPaused=!0,Vt.stop(this.timerUuid)}resume(){if(!this.isRecording)throw new C("cannot resume SoundRecorder because it is not started.");if(!this.isPaused)throw new C("cannot resume SoundRecorder because it is not paused.");this.mediaRecorder?.resume(),this._isPaused=!1,Vt.start(this.timerUuid)}async queryPermission(){try{return(await navigator.permissions.query({name:"microphone"})).state}catch(t){console.warn(`Error calling navigator.permissions.query({ name: "microphone" }): ${t}.`);return}}async requestPermission(){try{return(await navigator.mediaDevices.getUserMedia({audio:this.audioTrackConstraints?this.audioTrackConstraints:!0})).getTracks().forEach(i=>i.stop()),!0}catch(t){return console.warn(`Microphone access denied: ${t}`),!1}}get isRecording(){return this._isRecording}get isPaused(){return this._isPaused}update(){if(super.update(),this.isRecording&&!this.isPaused&&this.maximumDuration!==void 0&&Vt.elapsed(this.timerUuid)>this.maximumDuration){this.pause();return}}getMediaRecorderSupportedAudioMimeTypes(){const t=["audio"],i=["webm","ogg","mp3","mp4","x-matroska","3gpp","3gpp2","3gp2","quicktime","mpeg","aac","flac","x-flac","wave","wav","x-wav","x-pn-wav","not-supported"],r=["vp9","vp9.0","vp8","vp8.0","avc1","av1","h265","h.265","h264","h.264","opus","vorbis","pcm","aac","mpeg","mp4a","rtx","red","ulpfec","g722","pcmu","pcma","cn","telephone-event","not-supported"];return[...new Set(i.flatMap(h=>t.flatMap(c=>[`${c}/${h}`]))),...new Set(i.flatMap(h=>r.flatMap(c=>t.flatMap(S=>[`${S}/${h};codecs=${c}`])))),...new Set(i.flatMap(h=>r.flatMap(c=>r.flatMap(S=>t.flatMap(x=>[`${x}/${h};codecs="${c}, ${S}"`])))))].filter(h=>MediaRecorder.isTypeSupported(h))}blobToBase64(t){return new Promise((i,r)=>{const h=new FileReader;h.onloadend=()=>{const c=h.result?.toString().split(",").pop();if(c===void 0)throw new C("base64WithoutPrefix is undefined.");i(c)},h.onerror=r,h.readAsDataURL(t)})}getMimeTypeWithoutCodecs(t){const i=t.match(/^[^;]+/);return i?i[0]:""}getSupportedBackupMimeType(t){const i=this.getMediaRecorderSupportedAudioMimeTypes();for(const r of t)if(i.includes(r))return r}dispose(){}duplicate(t){throw new C(`Method not implemented. ${t}`)}}class Na{static create(t){return new Array}}console.log("\u26AA @m2c2kit/core version 0.3.30 (9f27c146)");export{X as Action,ui as ActivityType,Nt as CanvasKitHelpers,ca as ColorfulMutablePath,fa as Composite,Q as Constants,Gt as ConstraintType,kr as CustomAction,Ur as Dimensions,De as Easings,K as Equal,pa as Equals,$r as EventStore,ve as EventStoreMode,zr as FadeAlphaAction,Wr as FontManager,xa as Game,Mr as GroupAction,zi as I18n,fn as ImageManager,Ui as Label,He as LabelHorizontalAlignmentMode,Br as LayoutConstraint,Ma as LegacyTimer,C as M2Error,H as M2EventType,ne as M2ImageStatus,fe as M2Node,Gr as M2NodeFactory,dt as M2NodeType,jt as M2SoundStatus,V as M2c2KitHelpers,Or as MoveAction,Bi as MutablePath,ts as NoneTransition,Nr as PlayAction,An as RandomDraws,un as RepeatAction,Rr as RepeatForeverAction,Lr as RotateAction,Dr as ScaleAction,Ve as Scene,is as SceneTransition,Fr as SequenceAction,fi as Shape,Kt as ShapeType,es as SlideTransition,ns as SoundManager,Ra as SoundPlayer,ka as SoundRecorder,pi as Sprite,Na as Story,$i as TextLine,Vt as Timer,Ke as Transition,be as TransitionDirection,Se as TransitionType,ze as Uuid,Ir as WaitAction,R as WebColors,Pn as WebGlInfo,Le as handleInterfaceOptions};
1
+ var dt=(m=>(m.Node="Node",m.Scene="Scene",m.Sprite="Sprite",m.Label="Label",m.TextLine="TextLine",m.Shape="Shape",m.Composite="Composite",m.SoundPlayer="SoundPlayer",m.SoundRecorder="SoundRecorder",m))(dt||{});const jt={Deferred:"Deferred",WillFetch:"WillFetch",Fetching:"Fetching",Fetched:"Fetched",Decoding:"Decoding",Ready:"Ready",Error:"Error"};var mt=(m=>(m.Sequence="Sequence",m.Group="Group",m.Wait="Wait",m.Custom="Custom",m.Move="Move",m.Scale="Scale",m.FadeAlpha="FadeAlpha",m.Rotate="Rotate",m.Play="Play",m.Repeat="Repeat",m.RepeatForever="RepeatForever",m))(mt||{});class C extends Error{constructor(...t){super(...t),this.name="M2Error",Object.setPrototypeOf(this,C.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,C)}}const xt=class rt{static toTypeAsString(t){switch(t){case rt.none:return"None";case rt.linear:return"Linear";case rt.quadraticIn:return"QuadraticIn";case rt.quadraticOut:return"QuadraticOut";case rt.quadraticInOut:return"QuadraticInOut";case rt.cubicIn:return"CubicIn";case rt.cubicOut:return"CubicOut";case rt.cubicInOut:return"CubicInOut";case rt.quarticIn:return"QuarticIn";case rt.quarticOut:return"QuarticOut";case rt.quarticInOut:return"QuarticInOut";case rt.quinticIn:return"QuinticIn";case rt.quinticOut:return"QuinticOut";case rt.quinticInOut:return"QuinticInOut";case rt.sinusoidalIn:return"SinusoidalIn";case rt.sinusoidalOut:return"SinusoidalOut";case rt.sinusoidalInOut:return"SinusoidalInOut";case rt.exponentialIn:return"ExponentialIn";case rt.exponentialOut:return"ExponentialOut";case rt.exponentialInOut:return"ExponentialInOut";case rt.circularIn:return"CircularIn";case rt.circularOut:return"CircularOut";case rt.circularInOut:return"CircularInOut";default:throw new C("Easings.toTypeAsString(): Unknown easing function")}}static fromTypeAsString(t){switch(t){case"None":return rt.none;case"Linear":return rt.linear;case"QuadraticIn":return rt.quadraticIn;case"QuadraticOut":return rt.quadraticOut;case"QuadraticInOut":return rt.quadraticInOut;case"CubicIn":return rt.cubicIn;case"CubicOut":return rt.cubicOut;case"CubicInOut":return rt.cubicInOut;case"QuarticIn":return rt.quarticIn;case"QuarticOut":return rt.quarticOut;case"QuarticInOut":return rt.quarticInOut;case"QuinticIn":return rt.quinticIn;case"QuinticOut":return rt.quinticOut;case"QuinticInOut":return rt.quinticInOut;case"SinusoidalIn":return rt.sinusoidalIn;case"SinusoidalOut":return rt.sinusoidalOut;case"SinusoidalInOut":return rt.sinusoidalInOut;case"ExponentialIn":return rt.exponentialIn;case"ExponentialOut":return rt.exponentialOut;case"ExponentialInOut":return rt.exponentialInOut;case"CircularIn":return rt.circularIn;case"CircularOut":return rt.circularOut;case"CircularInOut":return rt.circularInOut;default:throw new C(`Easings.fromTypeAsString(): Unknown easing function type ${t}`)}}};xt.none=(m,t,i,r)=>i+t,xt.linear=(m,t,i,r)=>i*m/r+t,xt.quadraticIn=(m,t,i,r)=>(m/=r,i*m*m+t),xt.quadraticOut=(m,t,i,r)=>(m/=r,-i*m*(m-2)+t),xt.quadraticInOut=(m,t,i,r)=>(m/=r/2,m<1?i/2*m*m+t:(m--,-i/2*(m*(m-2)-1)+t)),xt.cubicIn=(m,t,i,r)=>(m/=r,i*m*m*m+t),xt.cubicOut=(m,t,i,r)=>(m/=r,m--,i*(m*m*m+1)+t),xt.cubicInOut=(m,t,i,r)=>(m/=r/2,m<1?i/2*m*m*m+t:(m-=2,i/2*(m*m*m+2)+t)),xt.quarticIn=(m,t,i,r)=>(m/=r,i*m*m*m*m+t),xt.quarticOut=(m,t,i,r)=>(m/=r,m--,-i*(m*m*m*m-1)+t),xt.quarticInOut=(m,t,i,r)=>(m/=r/2,m<1?i/2*m*m*m*m+t:(m-=2,-i/2*(m*m*m*m-2)+t)),xt.quinticIn=(m,t,i,r)=>(m/=r,i*m*m*m*m*m+t),xt.quinticOut=(m,t,i,r)=>(m/=r,m--,i*(m*m*m*m*m+1)+t),xt.quinticInOut=(m,t,i,r)=>(m/=r/2,m<1?i/2*m*m*m*m*m+t:(m-=2,i/2*(m*m*m*m*m+2)+t)),xt.sinusoidalIn=(m,t,i,r)=>-i*Math.cos(m/r*(Math.PI/2))+i+t,xt.sinusoidalOut=(m,t,i,r)=>i*Math.sin(m/r*(Math.PI/2))+t,xt.sinusoidalInOut=(m,t,i,r)=>-i/2*(Math.cos(Math.PI*m/r)-1)+t,xt.exponentialIn=(m,t,i,r)=>i*Math.pow(2,10*(m/r-1))+t,xt.exponentialOut=(m,t,i,r)=>i*(-Math.pow(2,-10*m/r)+1)+t,xt.exponentialInOut=(m,t,i,r)=>(m/=r/2,m<1?i/2*Math.pow(2,10*(m-1))+t:(m--,i/2*(-Math.pow(2,-10*m)+2)+t)),xt.circularIn=(m,t,i,r)=>(m/=r,-i*(Math.sqrt(1-m*m)-1)+t),xt.circularOut=(m,t,i,r)=>(m/=r,m--,i*Math.sqrt(1-m*m)+t),xt.circularInOut=(m,t,i,r)=>(m/=r/2,m<1?-i/2*(Math.sqrt(1-m*m)-1)+t:(m-=2,i/2*(Math.sqrt(1-m*m)+1)+t));let De=xt;var Kt=(m=>(m.Undefined="Undefined",m.Rectangle="Rectangle",m.Circle="Circle",m.Path="Path",m))(Kt||{});const xr=class ss{constructor(t){this.startTime=NaN,this.stopTime=NaN,this.stopped=!0,this.cumulativeElapsed=NaN,this.name=t}static now(){return window.performance.now()}static new(t){this._timers=this._timers.filter(r=>r.name!==t);const i=new ss(t);i.cumulativeElapsed=0,this._timers.push(i)}static startNew(t){this.new(t),this.start(t)}static start(t){const i=this._timers.filter(r=>r.name===t).find(Boolean);if(i===void 0)throw new C(`can't start timer. timer with name ${t} does not exist.`);if(i.stopped===!1)throw new C(`can't start timer. timer with name ${t} is already started.`);i.startTime=window.performance.now(),i.stopped=!1}static stop(t){const i=this._timers.filter(r=>r.name===t).find(Boolean);if(i===void 0)throw new C(`can't stop timer. timer with name ${t} does not exist.`);if(i.stopped===!0)throw new C(`can't stop timer. timer with name ${t} is already stopped.`);i.stopTime=window.performance.now(),i.cumulativeElapsed=i.cumulativeElapsed+i.stopTime-i.startTime,i.stopped=!0}static elapsed(t){const i=this._timers.filter(r=>r.name===t).find(Boolean);if(i===void 0)throw new C(`can't get elapsed time. timer with name ${t} does not exist.`);return i.stopped?i.cumulativeElapsed:i.cumulativeElapsed+window.performance.now()-i.startTime}static remove(t){if(this._timers.filter(r=>r.name===t).find(Boolean)===void 0)throw new C(`can't remove timer. timer with name ${t} does not exist.`);this._timers=this._timers.filter(r=>r.name!=t)}static removeAll(){this._timers=new Array}static exists(t){return this._timers.some(i=>i.name===t)}};xr._timers=new Array;let Vt=xr;class R{}R.Transparent=[0,0,0,0],R.MediumVioletRed=[199,21,133,1],R.DeepPink=[255,20,147,1],R.PaleVioletRed=[219,112,147,1],R.HotPink=[255,105,180,1],R.LightPink=[255,182,193,1],R.Pink=[255,192,203,1],R.DarkRed=[139,0,0,1],R.Red=[255,0,0,1],R.Firebrick=[178,34,34,1],R.Crimson=[220,20,60,1],R.IndianRed=[205,92,92,1],R.LightCoral=[240,128,128,1],R.Salmon=[250,128,114,1],R.DarkSalmon=[233,150,122,1],R.LightSalmon=[255,160,122,1],R.OrangeRed=[255,69,0,1],R.Tomato=[255,99,71,1],R.DarkOrange=[255,140,0,1],R.Coral=[255,127,80,1],R.Orange=[255,165,0,1],R.DarkKhaki=[189,183,107,1],R.Gold=[255,215,0,1],R.Khaki=[240,230,140,1],R.PeachPuff=[255,218,185,1],R.Yellow=[255,255,0,1],R.PaleGoldenrod=[238,232,170,1],R.Moccasin=[255,228,181,1],R.PapayaWhip=[255,239,213,1],R.LightGoldenrodYellow=[250,250,210,1],R.LemonChiffon=[255,250,205,1],R.LightYellow=[255,255,224,1],R.Maroon=[128,0,0,1],R.Brown=[165,42,42,1],R.SaddleBrown=[139,69,19,1],R.Sienna=[160,82,45,1],R.Chocolate=[210,105,30,1],R.DarkGoldenrod=[184,134,11,1],R.Peru=[205,133,63,1],R.RosyBrown=[188,143,143,1],R.Goldenrod=[218,165,32,1],R.SandyBrown=[244,164,96,1],R.Tan=[210,180,140,1],R.Burlywood=[222,184,135,1],R.Wheat=[245,222,179,1],R.NavajoWhite=[255,222,173,1],R.Bisque=[255,228,196,1],R.BlanchedAlmond=[255,235,205,1],R.Cornsilk=[255,248,220,1],R.DarkGreen=[0,100,0,1],R.Green=[0,128,0,1],R.DarkOliveGreen=[85,107,47,1],R.ForestGreen=[34,139,34,1],R.SeaGreen=[46,139,87,1],R.Olive=[128,128,0,1],R.OliveDrab=[107,142,35,1],R.MediumSeaGreen=[60,179,113,1],R.LimeGreen=[50,205,50,1],R.Lime=[0,255,0,1],R.SpringGreen=[0,255,127,1],R.MediumSpringGreen=[0,250,154,1],R.DarkSeaGreen=[143,188,143,1],R.MediumAquamarine=[102,205,170,1],R.YellowGreen=[154,205,50,1],R.LawnGreen=[124,252,0,1],R.Chartreuse=[127,255,0,1],R.LightGreen=[144,238,144,1],R.GreenYellow=[173,255,47,1],R.PaleGreen=[152,251,152,1],R.Teal=[0,128,128,1],R.DarkCyan=[0,139,139,1],R.LightSeaGreen=[32,178,170,1],R.CadetBlue=[95,158,160,1],R.DarkTurquoise=[0,206,209,1],R.MediumTurquoise=[72,209,204,1],R.Turquoise=[64,224,208,1],R.Aqua=[0,255,255,1],R.Cyan=[0,255,255,1],R.Aquamarine=[127,255,212,1],R.PaleTurquoise=[175,238,238,1],R.LightCyan=[224,255,255,1],R.Navy=[0,0,128,1],R.DarkBlue=[0,0,139,1],R.MediumBlue=[0,0,205,1],R.Blue=[0,0,255,1],R.MidnightBlue=[25,25,112,1],R.RoyalBlue=[65,105,225,1],R.SteelBlue=[70,130,180,1],R.DodgerBlue=[30,144,255,1],R.DeepSkyBlue=[0,191,255,1],R.CornflowerBlue=[100,149,237,1],R.SkyBlue=[135,206,235,1],R.LightSkyBlue=[135,206,250,1],R.LightSteelBlue=[176,196,222,1],R.LightBlue=[173,216,230,1],R.PowderBlue=[176,224,230,1],R.Indigo=[75,0,130,1],R.Purple=[128,0,128,1],R.DarkMagenta=[139,0,139,1],R.DarkViolet=[148,0,211,1],R.DarkSlateBlue=[72,61,139,1],R.BlueViolet=[138,43,226,1],R.DarkOrchid=[153,50,204,1],R.Fuchsia=[255,0,255,1],R.Magenta=[255,0,255,1],R.SlateBlue=[106,90,205,1],R.MediumSlateBlue=[123,104,238,1],R.MediumOrchid=[186,85,211,1],R.MediumPurple=[147,112,219,1],R.Orchid=[218,112,214,1],R.Violet=[238,130,238,1],R.Plum=[221,160,221,1],R.Thistle=[216,191,216,1],R.Lavender=[230,230,250,1],R.MistyRose=[255,228,225,1],R.AntiqueWhite=[250,235,215,1],R.Linen=[250,240,230,1],R.Beige=[245,245,220,1],R.WhiteSmoke=[245,245,245,1],R.LavenderBlush=[255,240,245,1],R.OldLace=[253,245,230,1],R.AliceBlue=[240,248,255,1],R.Seashell=[255,245,238,1],R.GhostWhite=[248,248,255,1],R.Honeydew=[240,255,240,1],R.FloralWhite=[255,250,240,1],R.Azure=[240,255,255,1],R.MintCream=[245,255,250,1],R.Snow=[255,250,250,1],R.Ivory=[255,255,240,1],R.White=[255,255,255,1],R.Black=[0,0,0,1],R.DarkSlateGray=[47,79,79,1],R.DimGray=[105,105,105,1],R.SlateGray=[112,128,144,1],R.Gray=[128,128,128,1],R.LightSlateGray=[119,136,153,1],R.DarkGray=[169,169,169,1],R.Silver=[192,192,192,1],R.LightGray=[211,211,211,1],R.Gainsboro=[220,220,220,1],R.RebeccaPurple=[102,51,153,1];class Q{}Q.FPS_DISPLAY_TEXT_FONT_SIZE=12,Q.FPS_DISPLAY_TEXT_COLOR=[0,0,0,.5],Q.FPS_DISPLAY_UPDATE_INTERVAL=1e3,Q.MAXIMUM_RECORDED_ACTIVITY_METRICS=32,Q.FPS_METRIC_REPORT_THRESHOLD=59,Q.DEFAULT_SCENE_BACKGROUND_COLOR=R.White,Q.DEFAULT_SHAPE_FILL_COLOR=R.Red,Q.DEFAULT_PATH_STROKE_COLOR=R.Red,Q.DEFAULT_PATH_LINE_WIDTH=2,Q.DEFAULT_FONT_COLOR=R.Black,Q.DEFAULT_FONT_SIZE=16,Q.LIMITED_FPS_RATE=5,Q.FREE_NODES_SCENE_NAME="__freeNodesScene",Q.OUTGOING_SCENE_NAME="__outgoingScene",Q.OUTGOING_SCENE_SPRITE_NAME="__outgoingSceneSprite",Q.OUTGOING_SCENE_IMAGE_NAME="__outgoingSceneSnapshot",Q.SESSION_INITIALIZATION_POLLING_INTERVAL_MS=50,Q.MODULE_METADATA_PLACEHOLDER={name:"",version:"",dependencies:{}},Q.DEFAULT_ROOT_ELEMENT_ID="m2c2kit",Q.ERUDA_URL="https://cdn.jsdelivr.net/npm/eruda@3.4.1/eruda.js",Q.ERUDA_SRI="sha384-daS5bEfWdSq146t9c4BureB/fQWO3lHohseXBelPqKvbOUx2D6PE3TxcQ9jrKZDM";class q{static getUrlFromManifest(t,i){const r=t.manifest;return r&&r[i]?r[i]:i}static urlHasScheme(t){return/^[a-z]+:\/\//i.test(t)}static convertValueToType(t,i){function r(U){return typeof U=="string"||typeof U=="object"||!Number.isNaN(parseFloat(U))||typeof U=="boolean"}function h(U){if(typeof U=="string")return U;if(typeof U=="object")return console.warn(`convertValueToType() converted an object to a string. This may not be the desired behavior. The object was: ${JSON.stringify(U)}`),JSON.stringify(U);if(!Number.isNaN(parseFloat(U)))return U;if(typeof U=="boolean")return U.toString();throw new C(`Error parsing "${U}" as a string.`)}function c(U){if(typeof U=="number")return!0;if(typeof U!="string")return!1;const ut=parseFloat(U);return!Number.isNaN(ut)}function S(U){if(typeof U=="number")return U;if(typeof U!="string")throw new C(`Error parsing "${U}" as a number.`);const ut=parseFloat(U);if(Number.isNaN(ut))throw new C(`Error parsing "${U}" as a number.`);return ut}function E(U){if(typeof U=="number")return!0;if(typeof U!="string")return!1;const ut=parseInt(U);return!Number.isNaN(ut)}function O(U){if(typeof U=="number")return U;if(typeof U!="string")throw new C(`Error parsing "${U}" as an integer.`);const ut=parseInt(U);if(Number.isNaN(ut))throw new C(`Error parsing "${U}" as an integer.`);return ut}function G(U){return typeof U=="boolean"?!0:!(U!=="true"&&U!=="false")}function K(U){if(typeof U=="boolean")return U;if(U!=="true"&&U!=="false")throw new C(`Error parsing "${U}" as a boolean.`);return U==="true"}function it(U){if(Array.isArray(U))return!0;if(typeof U!="string")return!1;try{const ut=JSON.parse(U);if(Array.isArray(ut))return!0}catch{const ut=JSON.parse(decodeURIComponent(U));if(Array.isArray(ut))return!0}return!1}function lt(U){if(Array.isArray(U))return U;if(typeof U!="string")throw new C(`Error parsing "${U}" as an array.`);try{const ut=JSON.parse(U);if(Array.isArray(ut))return ut}catch{const ut=JSON.parse(decodeURIComponent(U));if(Array.isArray(ut))return ut}throw new C(`Error parsing "${U}" as an array.`)}function yt(U){if(typeof U=="object"&&!Array.isArray(U)&&U!==null)return!0;if(typeof U!="string")return!1;try{const ut=JSON.parse(U);if(typeof ut=="object"&&!Array.isArray(ut)&&ut!==null)return!0}catch{const ut=JSON.parse(decodeURIComponent(U));if(typeof ut=="object"&&!Array.isArray(ut)&&ut!==null)return!0}return!1}function st(U){if(typeof U=="object"&&!Array.isArray(U)&&U!==null)return U;if(typeof U!="string")throw new C(`Error parsing "${U}" as an object.`);try{const ut=JSON.parse(U);if(typeof ut=="object"&&!Array.isArray(ut)&&ut!==null)return ut}catch{const ut=JSON.parse(decodeURIComponent(U));if(typeof ut=="object"&&!Array.isArray(ut)&&ut!==null)return ut}throw new C(`Error parsing "${U}" as an object.`)}function Et(U){return U===null||U==="null"}function Wt(U){if(U!=="null"&&U!==null)throw new C(`Error parsing "${U}" as null.`);return null}const Bt={string:r,number:c,integer:E,boolean:G,array:it,object:yt,null:Et},se={string:h,number:S,integer:O,boolean:K,array:lt,object:st,null:Wt};if(i===void 0)throw new C(`Error with "${t}" as a target type.`);if(!Array.isArray(i)){if(Bt[i](t))return se[i](t);throw new C(`Error parsing "${t}" as a ${i}.`)}for(const U of i)if(Bt[U](t))return se[U](t);throw new C(`Error parsing "${t}" as one of ${i}.`)}static loadScriptUrls(t){if(!Array.isArray(t)||!t.every(i=>typeof i=="string")){console.warn('Error parsing "scripts" parameter. "scripts" must be an array of URL strings, and it is recommended to be URI encoded.');return}t.forEach(i=>{if(!m2c2Globals.addedScriptUrls.includes(i)){const r=document.createElement("script");r.src=i,r.async=!0,document.head.appendChild(r),console.log(`\u26AA added script: ${i}`),m2c2Globals.addedScriptUrls.push(i)}})}static loadEruda(t=100,i=50){if(m2c2Globals.erudaRequested===!0)return;console.log(`\u26AA added eruda script: ${Q.ERUDA_URL}`);const r=document.createElement("script");r.src=Q.ERUDA_URL,r.integrity=Q.ERUDA_SRI,r.crossOrigin="anonymous",r.async=!0,document.head.appendChild(r),m2c2Globals.erudaRequested=!0;let h=0;const c=()=>{const S=window?.eruda;typeof S<"u"?(console.log("\u26AA eruda ready"),S.init(),m2c2Globals.erudaInitialized=!0):h<i?(h++,setTimeout(c,t)):console.log(`eruda was requested, but could not be loaded after ${t*i} milliseconds.`)};c()}static registerM2NodeClass(...t){m2c2Globals.m2NodeClassRegistry||(m2c2Globals.m2NodeClassRegistry={}),t.forEach(i=>{m2c2Globals.m2NodeClassRegistry={...m2c2Globals.m2NodeClassRegistry,[i.name]:i}})}static createFrameUpdateTimestamps(){return{timestamp:Number.isNaN(m2c2Globals?.now)||m2c2Globals?.now===void 0?Vt.now():m2c2Globals.now,iso8601Timestamp:m2c2Globals.iso8601Now?m2c2Globals.iso8601Now:new Date().toISOString()}}static createTimestamps(){return{timestamp:Vt.now(),iso8601Timestamp:new Date().toISOString()}}static calculateRotatedPoints(t){const i=t.ancestors;i.reverse(),i.push(t);const r=i.map(h=>{const c=q.calculateNodeAbsoluteBoundingBox(h);return q.boundingBoxToPoints(c)});for(let h=0;h<r.length;h++){if(!cn(i[h]))continue;const c=r[h],S=i[h].zRotation,E=q.findCentroid(c);for(let O=h;O<i.length;O++)r[O]=ha(r[O],S,E)}return r[r.length-1]}static rotateCanvasForDrawableNode(t,i){const r=q.calculateRotationTransforms(i);if(r.length===0)return;const h=m2c2Globals.canvasScale/i.absoluteScale;la(r,h,t)}static calculateNodeAbsoluteBoundingBox(t){const i=t.anchorPoint,r=t.absoluteScale;let h=t.size.width,c=t.size.height;if(t.type===dt.Shape&&t.shapeType===Kt.Circle){const K=t.circleOfRadius;if(!K)throw"circleOfRadius is undefined";h=K*2,c=K*2}const S=t.absolutePosition.x-h*i.x*r,E=t.absolutePosition.x+h*(1-i.x)*r,O=t.absolutePosition.y-c*i.y*r,G=t.absolutePosition.y+c*(1-i.y)*r;return{xMin:S,xMax:E,yMin:O,yMax:G}}static radiansToDegrees(t){return-q.normalizeAngleRadians(t)*(180/Math.PI)}static normalizeAngleRadians(t){const i=Math.floor(t/(2*Math.PI));let r=t-i*(2*Math.PI);return r<0&&(r+=2*Math.PI),r}static arePointsOnSameSideOfLine(t,i,r,h){const c=(h.x-r.x)*(t.y-r.y)-(h.y-r.y)*(t.x-r.x),S=(h.x-r.x)*(i.y-r.y)-(h.y-r.y)*(i.x-r.x);return c*S>=0}static isPointInsideRectangle(t,i){if(i.length!==4)throw new C("Invalid input: expected an array of four points");return q.arePointsOnSameSideOfLine(t,i[2],i[0],i[1])&&q.arePointsOnSameSideOfLine(t,i[3],i[1],i[2])&&q.arePointsOnSameSideOfLine(t,i[0],i[2],i[3])&&q.arePointsOnSameSideOfLine(t,i[1],i[3],i[0])}static nodeOrAncestorHasBeenRotated(t){const i=t.ancestors;return i.push(t),i.some(r=>cn(r))}static boundingBoxToPoints(t){const{xMin:i,xMax:r,yMin:h,yMax:c}=t;return[{x:i,y:h},{x:r,y:h},{x:r,y:c},{x:i,y:c}]}static findCentroid(t){if(t.length!==4)throw new C("Invalid input: expected an array of four points");let i=0,r=0;for(const S of t)i+=S.x,r+=S.y;const h=i/4,c=r/4;return{x:h,y:c}}static rotatePoint(t,i,r){const h=t.x-r.x,c=t.y-r.y,S=h*Math.cos(-i)-c*Math.sin(-i),E=h*Math.sin(-i)+c*Math.cos(-i);return{x:S+r.x,y:E+r.y}}static calculateRotationTransforms(t){const i=[],r=t.ancestors;return r.reverse(),r.push(t),r.forEach(h=>{if(cn(h)){const c=h;if(c.type===dt.Scene){const G={x:c.absolutePosition.x+c.size.width*.5,y:c.absolutePosition.y+c.size.height*.5};i.push({radians:c.zRotation,center:G});return}const S=q.calculateNodeAbsoluteBoundingBox(c),E=q.boundingBoxToPoints(S),O=q.findCentroid(E);i.push({radians:c.zRotation,center:O})}}),i}}function la(m,t,i){m.forEach(r=>{i.rotate(q.radiansToDegrees(r.radians),r.center.x*t,r.center.y*t)})}function cn(m){return q.normalizeAngleRadians(m.zRotation)!==0&&m.isDrawable}function ha(m,t,i){if(m.length!==4)throw new C("Invalid input: expected an array of four points");const r=[];for(const h of m)r.push(q.rotatePoint(h,t,i));return r}class zt{constructor(t){if(this.expression=new Array,this.WARNING_EXPRESSION_LENGTH=32,typeof t=="number"){this.pushToExpression(t);return}if(t===void 0){this.pushToExpression(1/0);return}this.pushToExpression(t)}pushToExpression(t){if(t===this)throw new C("Cannot add, subtract, or assign a Futurable with itself.");this.expression.push(t),this.expression.length===this.WARNING_EXPRESSION_LENGTH&&console.warn(`Expression length is ${this.WARNING_EXPRESSION_LENGTH} elements. Something may be wrong.`)}assign(t){for(;this.expression.length>0;)this.expression.pop();this.pushToExpression(t)}add(...t){return this.appendOperation(Di.Add,...t),this}subtract(...t){return this.appendOperation(Di.Subtract,...t),this}appendOperation(t,...i){i.forEach(r=>{this.pushToExpression(t),this.pushToExpression(r)})}get value(){let t=0;const i=this.expression.flat(1/0);let r=1;for(let h=0;h<i.length;h++){if(typeof i[h]=="number"){t=t+r*i[h];continue}if(i[h]instanceof zt){t=t+r*i[h].value;continue}if(i[h]===Di.Add){r=1;continue}if(i[h]===Di.Subtract){r=-1;continue}}return t}}const Di={Add:"Add",Subtract:"Subtract"};class X{constructor(t=!1){this.startOffset=new zt(0),this.started=!1,this.running=!1,this._completed=!1,this.runStartTime=-1,this.duration=new zt,this.runDuringTransition=t}initialize(t){const i=this.clone();return this.assignParents(i,i,t),this.propagateRunDuringTransition(i),this.assignDurations(i),this.assignStartOffsets(i),i}assignParents(t,i,r){if(r!==void 0&&(t.key=r),this.isParent(t)){const h=t.children;h.forEach(c=>{c.parent=t}),h.filter(c=>this.isParent(c)).forEach(c=>this.assignParents(c,i,r))}}propagateRunDuringTransition(t){this.isParent(t)&&(t.descendants.some(i=>i.runDuringTransition)&&(t.runDuringTransition=!0),t.children.forEach(i=>this.propagateRunDuringTransition(i)))}assignDurations(t){t.duration=this.calculateDuration(t),this.isParent(t)&&t.children.forEach(i=>this.assignDurations(i))}calculateDuration(t){if(t.type===mt.Group){const r=t.children.map(h=>this.calculateDuration(h)).reduce((h,c)=>Math.max(h,c.value),0);return new zt(r)}if(t.type===mt.Sequence){const r=t.children.map(h=>this.calculateDuration(h)).reduce((h,c)=>h+c.value,0);return new zt(r)}return this.isRepeating(t)?new zt:t.duration}assignStartOffsets(t){t.startOffset=this.calculateStartOffset(t),this.isParent(t)&&t.children.forEach(i=>this.assignStartOffsets(i))}calculateStartOffset(t){if(t.parent===void 0)return new zt(0);if(t.parent.type!==mt.Sequence)return t.parent.startOffset;const i=new zt(0);i.add(t.parent.startOffset);for(const r of t.parent.children){if(r===t)break;i.add(r.duration)}return i}static evaluateAction(t,i,r,h){if(i.involvedInSceneTransition()&&!t.runDuringTransition||(t.runStartTime===-1&&t.assignRunStartTimes(t,r),r<t.runStartTime+t.startOffset.value))return;if(t.shouldBeRunning(r)&&(t.running=!0),t.isParent(t)){if(t.children.forEach(S=>{X.evaluateAction(S,i,r,h)}),!t.isRepeating(t)){t.started||(t.started=!0),t.running&&t.completed&&(t.running=!1);return}X.evaluateRepeatingActions(t,r);return}if(t.shouldBeRunning(r)||(t.running=!1),t.running===!1&&t.completed===!0)return;const c=r-(t.runStartTime+t.startOffset.value);switch(t.type){case mt.Custom:X.evaluateCustomAction(t);break;case mt.Play:X.evaluatePlayAction(i,t);break;case mt.Wait:X.evaluateWaitAction(t,r);break;case mt.Move:X.evaluateMoveAction(t,i,c);break;case mt.Scale:X.evaluateScaleAction(t,i,c,h);break;case mt.FadeAlpha:X.evaluateFadeAlphaAction(t,i,c,h);break;case mt.Rotate:X.evaluateRotateAction(t,i,c,h);break;default:throw new C(`Action type not recognized: ${t.type}`)}}static evaluateRepeatingActions(t,i){if(t.started||(t.started=!0),t.repetitionHasCompleted){t.completedRepetitions++;const r=t.children[0].duration.value;if(t.cumulativeDuration=t.cumulativeDuration+r,!isFinite(r))throw"repetitionDuration is not finite";if(!t.completed)t.restartAction(t,i);else{if(t.type===mt.RepeatForever)throw new C("RepeatForever action should never complete");t.duration.assign(t.cumulativeDuration),t.running=!1}}}static evaluateRotateAction(t,i,r,h){const c=t;c.started||(c.byAngle!==void 0&&(c.delta=c.byAngle),c.toAngle!==void 0&&(c.toAngle=q.normalizeAngleRadians(c.toAngle),i.zRotation=q.normalizeAngleRadians(i.zRotation),c.delta=c.toAngle-i.zRotation,c.shortestUnitArc===!0&&Math.abs(c.delta)>Math.PI&&(c.delta=2*Math.PI-Math.abs(c.delta))),c.started=!0,c.finalValue=i.zRotation+c.delta),r<c.duration.value?(i.zRotation=i.zRotation+c.delta*(h/c.duration.value),c.delta<=0&&i.zRotation<c.finalValue&&(i.zRotation=c.finalValue),c.delta>0&&i.zRotation>c.finalValue&&(i.zRotation=c.finalValue)):(i.zRotation=c.finalValue,c.running=!1,c.completed=!0)}static evaluateFadeAlphaAction(t,i,r,h){const c=t;c.started||(c.delta=c.alpha-i.alpha,c.started=!0),r<c.duration.value?i.alpha=i.alpha+c.delta*(h/c.duration.value):(i.alpha=c.alpha,c.running=!1,c.completed=!0)}static evaluateScaleAction(t,i,r,h){const c=t;c.started||(c.delta=c.scale-i.scale,c.started=!0),r<c.duration.value?i.scale=i.scale+c.delta*(h/c.duration.value):(i.scale=c.scale,c.running=!1,c.completed=!0)}static evaluateMoveAction(t,i,r){const h=t;h.started||(h.dx=h.point.x-i.position.x,h.dy=h.point.y-i.position.y,h.startPoint.x=i.position.x,h.startPoint.y=i.position.y,h.started=!0),r<h.duration.value?(i.position.x=h.easing(r,h.startPoint.x,h.dx,h.duration.value),i.position.y=h.easing(r,h.startPoint.y,h.dy,h.duration.value)):(i.position.x=h.point.x,i.position.y=h.point.y,h.running=!1,h.completed=!0)}static evaluateWaitAction(t,i){const r=t;i>t.runStartTime+t.startOffset.value+t.duration.value&&(r.running=!1,r.completed=!0)}static evaluatePlayAction(t,i){if(t.type!==dt.SoundPlayer)throw new C("Play action can only be used with a SoundPlayer");const r=i,h=t,c=h.game.soundManager;if(!r.started){const S=c.getSound(h.soundName);if(S.audioBuffer)S.audioBufferSource=c.audioContext.createBufferSource(),S.audioBufferSource.buffer=S.audioBuffer,S.audioBufferSource.onended=()=>{r.running=!1,r.completed=!0;const E=performance.now()-(i.runStartTime+i.startOffset.value);i.duration.assign(E)},S.audioBufferSource.connect(c.audioContext.destination),S.audioBufferSource.start(),r.started=!0;else{if(S.status===jt.Error)throw new C(`error loading sound ${S.soundName} (url ${S.url})`);console.warn(`Play action: audio buffer not ready for sound ${h.soundName} (url: ${S.url}); will try next frame`),S.status===jt.Deferred&&c.fetchDeferredSound(S)}}}static evaluateCustomAction(t){const i=t;i.callback(),i.running=!1,i.completed=!0}assignRunStartTimes(t,i){t.runStartTime=i,t.isParent(t)&&t.children.forEach(r=>{t.assignRunStartTimes(r,i)})}restartAction(t,i){if(t.runStartTime=i,t.running=!0,t.started=!0,t.type===mt.Play&&(t.duration=new zt),t.isParent(t)){t.children.forEach(r=>{t.restartAction(r,i)});return}t.completed=!1}shouldBeRunning(t){return t>=this.runStartTime+this.startOffset.value&&t<=this.runStartTime+this.startOffset.value+this.duration.value}static move(t){return new Or(t.point,new zt(t.duration),t.easing??De.linear,t.runDuringTransition??!1)}static wait(t){return new Ir(new zt(t.duration),t.runDuringTransition??!1)}static custom(t){return new kr(t.callback,t.runDuringTransition??!1)}static play(t){return new Nr(t?.runDuringTransition??!1)}static scale(t){return new Dr(t.scale,new zt(t.duration),t.runDuringTransition)}static fadeAlpha(t){return new zr(t.alpha,new zt(t.duration),t.runDuringTransition)}static rotate(t){if(t.byAngle!==void 0&&t.toAngle!==void 0)throw new C("rotate Action: cannot specify both byAngle and toAngle");if(t.byAngle===void 0&&t.toAngle===void 0)throw new C("rotate Action: must specify either byAngle or toAngle");if(t.toAngle===void 0&&t.shortestUnitArc!==void 0)throw new C("rotate Action: shortestUnitArc can only be specified when toAngle is provided");return t.toAngle!==void 0&&t.shortestUnitArc===void 0&&(t.shortestUnitArc=!0),new Lr(t.byAngle,t.toAngle,t.shortestUnitArc,new zt(t.duration),t.runDuringTransition)}static sequence(t){const i=new Fr(t);return i.children=t,i}static group(t){const i=new Mr(t);return i.children=t,i}static repeat(t){return new un(t.action,t.count,t.runDuringTransition)}static repeatForever(t){return new Rr(t.action,t.runDuringTransition)}isParent(t){return t.type===mt.Group||t.type===mt.Sequence||t.type===mt.Repeat||t.type===mt.RepeatForever}isRepeating(t){return t.type===mt.Repeat||t.type===mt.RepeatForever}get completed(){return this._completed}set completed(t){this._completed=t}}class Fr extends X{constructor(t){super(),this.type=mt.Sequence,this.children=t}clone(){const t=this.children.map(r=>r.clone()),i=X.sequence(t);return i.children.forEach(r=>r.key=this.key),i.key=this.key,i}get completed(){return this.children.every(t=>t.completed)}get descendants(){return dn(this)}}class Mr extends X{constructor(t){super(),this.type=mt.Group,this.children=new Array,this.children=t}clone(){const t=this.children.map(r=>r.clone()),i=X.group(t);return i.children.forEach(r=>r.key=this.key),i.key=this.key,i}get completed(){return this.children.every(t=>t.completed)}get descendants(){return dn(this)}}class un extends X{constructor(t,i,r=!1){super(r),this.type=mt.Repeat,this.completedRepetitions=0,this.cumulativeDuration=0,this.children=[t],this.count=i,this.duration=new zt}clone(){if(this.children.length!==1)throw new C("Repeat action must have exactly one child");const t=X.repeat({action:this.children[0].clone(),count:this.count,runDuringTransition:this.runDuringTransition});return t.children[0].key=this.key,t.key=this.key,t}get completed(){return this.children.every(t=>t.completed)&&this.completedRepetitions===this.count}get descendantsAreCompleted(){return this.children.every(t=>t.completed)}get repetitionHasCompleted(){return this.running&&this.descendantsAreCompleted&&!this.completed}get descendants(){return dn(this)}}class Rr extends un{constructor(t,i=!1){super(t,1/0,i),this.type=mt.RepeatForever,this.count=1/0}clone(){if(this.children.length!==1)throw new C("RepeatForever action must have exactly one child");const t=X.repeatForever({action:this.children[0].clone(),runDuringTransition:this.runDuringTransition});return t.children[0].key=this.key,t.key=this.key,t}}function dn(m){const t=[];function i(r){if(r.isParent(r))for(const h of r.children)t.push(h),i(h)}return i(m),t}class kr extends X{constructor(t,i=!1){super(i),this.type=mt.Custom,this.callback=t,this.duration=new zt(0)}clone(){const t=X.custom({callback:this.callback,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class Nr extends X{constructor(t=!1){super(t),this.type=mt.Play,this.duration=new zt}clone(){const t=X.play({runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class Ir extends X{constructor(t,i){super(i),this.type=mt.Wait,this.duration=t}clone(){const t=X.wait({duration:this.duration.value,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class Or extends X{constructor(t,i,r,h){super(h),this.type=mt.Move,this.startPoint={x:NaN,y:NaN},this.dx=0,this.dy=0,this.duration=i,this.point=t,this.easing=r}clone(){const t=X.move({point:this.point,duration:this.duration.value,easing:this.easing,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class Dr extends X{constructor(t,i,r=!1){super(r),this.type=mt.Scale,this.delta=0,this.duration=i,this.scale=t}clone(){const t=X.scale({scale:this.scale,duration:this.duration.value,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class zr extends X{constructor(t,i,r=!1){super(r),this.type=mt.FadeAlpha,this.delta=0,this.duration=i,this.alpha=t}clone(){const t=X.fadeAlpha({alpha:this.alpha,duration:this.duration.value,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class Lr extends X{constructor(t,i,r,h,c=!1){super(c),this.type=mt.Rotate,this.delta=0,this.finalValue=NaN,this.duration=h,this.byAngle=t,this.toAngle=i,this.shortestUnitArc=r}clone(){const t=X.rotate({byAngle:this.byAngle,toAngle:this.toAngle,shortestUnitArc:this.shortestUnitArc,duration:this.duration.value,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}var ui=(m=>(m.Game="Game",m.Survey="Survey",m))(ui||{});class Nt{static Dispose(t){t.filter(i=>!i?.isDeleted()).forEach(i=>i?.delete())}static makePaint(t,i,r,h){const c=new t.Paint;return c.setColor(t.Color(i[0],i[1],i[2],i[3])),c.setStyle(r),c.setAntiAlias(h),c}}class Bi{constructor(){this._subpaths=new Array,this.currentPath=new Array}get subpaths(){return this.currentPath.length>0?[...this._subpaths,this.currentPath]:this._subpaths}move(t){this.currentPath.length>0&&this._subpaths.push(this.currentPath),this.currentPath=new Array,this.currentPath.push(t)}addLine(t){this.currentPath.push(t)}clear(){this._subpaths=new Array,this.currentPath=new Array}duplicate(){const t=new Bi;return t._subpaths=JSON.parse(JSON.stringify(this._subpaths)),t.currentPath=JSON.parse(JSON.stringify(this.currentPath)),t}}class ca extends Bi{constructor(){super(...arguments),this.strokeColor=Q.DEFAULT_PATH_STROKE_COLOR,this.lineWidth=Q.DEFAULT_PATH_LINE_WIDTH,this.linePresentations=[]}addLine(t){this.isNewLinePresentation()&&this.linePresentations.push({strokeColor:this.strokeColor,lineWidth:this.lineWidth,subpathIndex:this._subpaths.length,pointIndex:this.currentPath.length-1}),this.currentPath.push(t)}isNewLinePresentation(){if(this.linePresentations.length===0)return!0;const t=this.linePresentations[this.linePresentations.length-1];return t.strokeColor!==this.strokeColor||t.lineWidth!==this.lineWidth}clear(){super.clear(),this.linePresentations=[],this.strokeColor=Q.DEFAULT_PATH_STROKE_COLOR,this.lineWidth=Q.DEFAULT_PATH_LINE_WIDTH}duplicate(){const t=super.duplicate();return t.strokeColor=JSON.parse(JSON.stringify(this.strokeColor)),t.lineWidth=this.lineWidth,t.linePresentations=JSON.parse(JSON.stringify(this.linePresentations)),t}}var Gt=(m=>(m.topToTopOf="topToTopOf",m.topToBottomOf="topToBottomOf",m.bottomToTopOf="bottomToTopOf",m.bottomToBottomOf="bottomToBottomOf",m.startToStartOf="startToStartOf",m.startToEndOf="startToEndOf",m.endToEndOf="endToEndOf",m.endToStartOf="endToStartOf",m))(Gt||{});class Br{constructor(t,i){this.verticalConstraint=!1,this.focalNodeMinimum=!1,this.alterNodeMinimum=!1,this.verticalTypes=[Gt.topToTopOf,Gt.topToBottomOf,Gt.bottomToTopOf,Gt.bottomToBottomOf],this.focalNodeMinimumTypes=[Gt.topToTopOf,Gt.topToBottomOf,Gt.startToStartOf,Gt.startToEndOf],this.alterNodeMinimumTypes=[Gt.topToTopOf,Gt.bottomToTopOf,Gt.startToStartOf,Gt.endToStartOf],this.type=t,this.alterNode=i,this.verticalTypes.includes(t)?(this.verticalConstraint=!0,this.focalNodeMinimumTypes.includes(t)?this.focalNodeMinimum=!0:this.focalNodeMinimum=!1,this.alterNodeMinimumTypes.includes(t)?this.alterNodeMinimum=!0:this.alterNodeMinimum=!1):(this.verticalConstraint=!1,this.focalNodeMinimumTypes.includes(t)?this.focalNodeMinimum=!0:this.focalNodeMinimum=!1,this.alterNodeMinimumTypes.includes(t)?this.alterNodeMinimum=!0:this.alterNodeMinimum=!1)}}class ze{static generate(){try{return crypto.randomUUID()}catch{let t;try{t=()=>crypto.getRandomValues(new Uint8Array(1))[0]}catch{t=()=>Math.floor(Math.random()*256)}return("10000000-1000-4000-8000"+-1e11).replace(/[018]/g,i=>(Number(i)^t()&15>>Number(i)/4).toString(16))}}static isValid(t){return t?t==="00000000-0000-0000-0000-000000000000"?!0:/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t):!1}}const H={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",KeyDown:"KeyDown",KeyUp:"KeyUp",Drag:"Drag",DragStart:"DragStart",DragEnd:"DragEnd",Composite:"Composite",FrameDidSimulatePhysics:"FrameDidSimulatePhysics",SceneSetup:"SceneSetup",SceneAppear:"SceneAppear",ScenePresent:"ScenePresent",NodeNew:"NodeNew",NodeAddChild:"NodeAddChild",NodeRemoveChild:"NodeRemoveChild",NodePropertyChange:"NodePropertyChange",DomPointerDown:"DomPointerDown",BrowserImageDataReady:"BrowserImageDataReady",I18nDataReadyEvent:"I18nDataReadyEvent"};class V{static rgbaColor(t,i){return!t||!i?!1:t[0]===i[0]&&t[1]===i[1]&&t[2]===i[2]&&t[3]===i[3]}static value(t,i){return typeof t!=typeof i?!1:t&&typeof t=="object"&&i&&typeof i=="object"?V.objectsDeepEqual(t,i):t===i}static objectsDeepEqual(t,i){if(t===i)return!0;if(Array.isArray(t)&&Array.isArray(i)){if(t.length!==i.length)return!1;for(let r=0;r<t.length;r++)if(!V.objectsDeepEqual(t[r],i[r]))return!1;return!0}if(typeof t=="object"&&!Array.isArray(t)&&t!==null&&typeof i=="object"&&!Array.isArray(i)&&i!==null){const r=Object.keys(t),h=Object.keys(i);if(r.length!==h.length)return!1;for(const c of r)if(!(c in i)||!V.objectsDeepEqual(t[c],i[c]))return!1;return!0}return!1}}function ua(m,t){t.anchorPoint&&(m.anchorPoint=t.anchorPoint),t.zPosition!==void 0&&(m.zPosition=t.zPosition)}function da(m,t){t.text!==void 0&&(m.text=t.text),t.fontName!==void 0&&(m.fontName=t.fontName),t.fontColor&&(m.fontColor=t.fontColor),t.fontSize!==void 0&&(m.fontSize=t.fontSize),t.interpolation&&(m.interpolation=t.interpolation),t.localize!==void 0&&(m.localize=t.localize)}function Le(m,t){m.isDrawable&&ua(m,t),m.isText&&da(m,t)}class fe{constructor(t={}){this.type=dt.Node,this.isDrawable=!1,this.isShape=!1,this.isText=!1,this._suppressEvents=!1,this._position={x:0,y:0},this._scale=1,this._alpha=1,this._zRotation=0,this._isUserInteractionEnabled=!1,this._draggable=!1,this._hidden=!1,this.layout={},this.children=new Array,this.absolutePosition={x:0,y:0},this._size={width:0,height:0},this.absoluteScale=1,this.absoluteAlpha=1,this.absoluteAlphaChange=0,this.actions=new Array,this.eventListeners=new Array,this.uuid=ze.generate(),this.needsInitialization=!0,this.userData={},this.loopMessages=new Set,this.nodeEvents=new Array,this.pressed=!1,this.withinHitArea=!1,this.pressedAndWithinHitArea=!1,this.pressedInitialPointerOffset={x:NaN,y:NaN},this.draggingLastPointerOffset={x:NaN,y:NaN},this.dragging=!1,this.toString=()=>{let i=this.type.toString();return this.type==dt.Composite&&(i=this.compositeType),this.name!==this.uuid?`${this.name} (${i}, ${this.uuid})`:`${i} (${this.uuid})`},t.suppressEvents!==void 0&&(this.suppressEvents=t.suppressEvents),this.constructionTimeStamp=Number.isNaN(m2c2Globals?.now)||m2c2Globals?.now===void 0?Vt.now():m2c2Globals.now,this.constructionIso8601TimeStamp=new Date().toISOString(),this.constructionSequence=m2c2Globals.eventSequence,this.options=t,t.uuid!==void 0&&(this.uuid=t.uuid),t.name===void 0?this.name=this.uuid:this.name=t.name,t.position!==void 0&&(this.position=t.position),t.scale!==void 0&&(this.scale=t.scale),t.alpha!==void 0&&(this.alpha=t.alpha),t.zRotation!==void 0&&(this.zRotation=t.zRotation),t.isUserInteractionEnabled!==void 0&&(this.isUserInteractionEnabled=t.isUserInteractionEnabled),t.draggable!==void 0&&(this.draggable=t.draggable),t.hidden!==void 0&&(this.hidden=t.hidden),t.layout!==void 0&&(this.layout=t.layout)}initialize(){throw new C("initialize() called in abstract base class Node.")}get completeNodeOptions(){throw new C("get completeNodeOptions() called in abstract base class Node.")}saveNodeNewEvent(){if(this.suppressEvents)return;const t={type:H.NodeNew,target:this,nodeType:this.type,compositeType:this.type===dt.Composite?this.compositeType:void 0,timestamp:this.constructionTimeStamp,iso8601Timestamp:this.constructionIso8601TimeStamp,nodeOptions:this.completeNodeOptions,sequence:this.constructionSequence};this.saveEvent(t)}savePropertyChangeEvent(t,i){if(this.suppressEvents)return;const r={type:H.NodePropertyChange,target:this,uuid:this.uuid,property:t,value:i,...q.createFrameUpdateTimestamps()};this.saveEvent(r)}saveEvent(t){t.sequence===void 0&&(t.sequence=m2c2Globals.eventSequence);try{this.game.eventStore.addEvent(t)}catch{this.nodeEvents.push(t)}}get game(){const t=i=>{if(i.parent)return i.parent.type===dt.Scene?i.parent:t(i.parent);throw new C(`Node ${this} has not been added to a scene.`)};return t(this).game}isPartOfGame(){if(this.type===dt.Scene&&this._game===void 0)return!1;if(this.type===dt.Scene&&this._game!==void 0)return!0;const t=i=>{if(i.parent)return i.parent.type===dt.Scene?i.parent:t(i.parent)};return t(this)?._game!==void 0}addChild(t){const i=this.suppressEvents||t.suppressEvents;if(t===this)throw new C(`Cannot add node ${t.toString()} as a child to itself.`);if(t.type==dt.Scene)throw new C(`Cannot add scene ${t.toString()} as a child to node ${this.toString()}. A scene cannot be the child of a node. A scene can only be added to a game object.`);if(this.children.filter(c=>c!==t).map(c=>c.name).includes(t.name))throw new C(`Cannot add child node ${t.toString()} to parent node ${this.toString()}. A child with name "${t.name}" already exists on this parent.`);let r=new Array;if(this.isPartOfGame())r=this.game.nodes.filter(c=>c.children.includes(t));else{const c=this.descendants;c.includes(t)&&(r=c.filter(S=>S.children.includes(t)).map(S=>S.parent??void 0))}if(r.length===0){t.parent=this,this.children.push(t);const c={type:"NodeAddChild",target:this,uuid:this.uuid,childUuid:t.uuid,...q.createFrameUpdateTimestamps()};i||this.saveEvent(c),this.saveChildEvents(t);return}const h=r.find(Boolean);throw h===this?new C(`Cannot add child node ${t.toString()} to parent node ${this.toString()}. This child already exists on this parent. The child cannot be added again.`):new C(`Cannot add child node ${t.toString()} to parent node ${this.toString()}. This child already exists on other parent node: ${h?.toString()}}. Remove the child from the other parent first.`)}saveChildEvents(t){t.nodeEvents.forEach(i=>{this.saveEvent(i)}),t.nodeEvents.length=0;for(const i of t.children)this.saveChildEvents(i)}removeAllChildren(){this.children.forEach(t=>this.removeChild(t))}removeChild(t){const i=this.suppressEvents||t.suppressEvents;if(this.children.includes(t))t.parent=void 0,this.children=this.children.filter(h=>h!==t);else throw new C(`cannot remove node ${t} from parent ${this} because the node is not currently a child of the parent`);const r={type:"NodeRemoveChild",target:this,uuid:this.uuid,childUuid:t.uuid,...q.createFrameUpdateTimestamps()};i||this.saveEvent(r)}removeChildren(t){t.forEach(i=>{if(!this.children.includes(i))throw new C(`cannot remove node ${i} from parent ${this} because the node is not currently a child of the parent`);this.removeChild(i)})}descendant(t){const i=this.descendants.filter(r=>r.name===t).find(Boolean);if(i===void 0)throw new C(`descendant with name ${t} not found on parent ${this.toString()}`);return i}get descendants(){function t(r,h){h.push(r),r.children.forEach(c=>t(c,h))}const i=new Array;return this.children.forEach(r=>t(r,i)),i}get ancestors(){function t(r,h){return r.type==dt.Scene||!r.parent?h:(h.push(r.parent),t(r.parent,h))}const i=new Array;return t(this,i)}involvedInActionAffectingAppearance(){return this.ancestors.concat(this).flatMap(r=>r.actions).some(r=>r.running&&(r.type===mt.Move||r.type===mt.Scale))}involvedInSceneTransition(){let t;return this.type===dt.Scene?t=this:t=this.parentSceneAsNode,t._transitioning}onTapDown(t,i){this.addEventListener(H.TapDown,t,i)}onTapUp(t,i){this.addEventListener(H.TapUp,t,i)}onTapUpAny(t,i){this.addEventListener(H.TapUpAny,t,i)}onTapLeave(t,i){this.addEventListener(H.TapLeave,t,i)}onPointerDown(t,i){this.addEventListener(H.PointerDown,t,i)}onPointerUp(t,i){this.addEventListener(H.PointerUp,t,i)}onPointerMove(t,i){this.addEventListener(H.PointerMove,t,i)}onPointerLeave(t,i){this.addEventListener(H.PointerLeave,t,i)}onDragStart(t,i){this.addEventListener(H.DragStart,t,i)}onDrag(t,i){this.addEventListener(H.Drag,t,i)}onDragEnd(t,i){this.addEventListener(H.DragEnd,t,i)}addEventListener(t,i,r){const h={type:t,nodeUuid:this.uuid,callback:i};r?.replaceExisting&&(this.eventListeners=this.eventListeners.filter(c=>!(c.nodeUuid===h.nodeUuid&&c.type===h.type))),this.eventListeners.push(h)}parseLayoutConstraints(t,i){const r=new Array;return Object.values(Gt).forEach(c=>{if(t[c]!==void 0){let S,E="";if(typeof t[c]=="object")S=t[c];else{const G=t[c];S=i.filter(K=>K.name===G||K.uuid===G).find(Boolean),S||(S=this.game.materializedNodes.filter(K=>K.name===G||K.uuid===G).find(Boolean)),E=`. sibling node named "${G}" has not been added to the game object`}if(S===void 0)throw new C("could not find sibling node for constraint"+E);const O=new Br(c,S);r.push(O)}}),r}calculateYFromConstraint(t,i,r,h){let c=t.alterNode.absolutePosition.y;return t.alterNodeMinimum?t.alterNode.type!==dt.Scene&&(c=c-t.alterNode.size.height*.5*h):t.alterNode.type!==dt.Scene?c=c+t.alterNode.size.height*.5*h:c=c+t.alterNode.size.height*h,t.focalNodeMinimum?(c=c+this.size.height*.5*h,c=c+i*h):(c=c-this.size.height*.5*h,c=c-r*h),c}calculateXFromConstraint(t,i,r,h){let c=t.alterNode.absolutePosition.x;return t.alterNodeMinimum?t.alterNode.type!==dt.Scene&&(c=c-t.alterNode.size.width*.5*h):t.alterNode.type!==dt.Scene?c=c+t.alterNode.size.width*.5*h:c=c+t.alterNode.size.width*h,t.focalNodeMinimum?(c=c+this.size.width*.5*h,c=c+i*h):(c=c-this.size.width*.5*h,c=c-r*h),c}calculateAbsoluteAlpha(t,i){const r=i.reduce((h,c)=>h*c.alpha,1);return t*r}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 h=this.layout?.constraints?.horizontalBias??.5,c=this.layout?.constraints?.verticalBias??.5,S=this.layout?.marginTop??0,E=this.layout?.marginBottom??0,O=this.layout?.marginStart??0,G=this.layout?.marginEnd??0,K=this.parseLayoutConstraints(this.layout?.constraints,this.parentSceneAsNode.descendants),it=this.parent.absoluteScale,lt=K.filter(st=>st.verticalConstraint).map(st=>this.calculateYFromConstraint(st,S,E,it));lt.length===0||(lt.length===1?this.absolutePosition.y=lt[0]:lt.length===2&&(this.absolutePosition.y=Math.min(lt[0],lt[1])+c*Math.abs(lt[0]-lt[1])));const yt=K.filter(st=>!st.verticalConstraint).map(st=>this.calculateXFromConstraint(st,O,G,it));yt.length===0||(yt.length===1?this.absolutePosition.x=yt[0]:yt.length===2&&(this.absolutePosition.x=Math.min(yt[0],yt[1])+h*Math.abs(yt[0]-yt[1])))}this.actions.forEach(h=>X.evaluateAction(h,this,m2c2Globals.now,m2c2Globals.deltaTime));function t(h,c){const S=new Array;return c===void 0||Object.values(Gt).forEach(O=>{if(c[O]!==void 0){let G,K="";if(typeof c[O]=="object")G=c[O];else{const it=c[O];let lt;h.type===dt.Scene?lt=h.descendants:lt=h.parentSceneAsNode.descendants,G=lt.filter(yt=>yt.name===it||yt.uuid===it).find(Boolean),G===void 0&&(G=h.game.materializedNodes.filter(yt=>yt.name===it||yt.uuid===it).find(Boolean)),G===void 0&&(K=`. sibling node named "${it}" has not been added to the game object`)}if(G===void 0)throw new C("error getting uuid of sibling constraint"+K);G!==h&&S.push(G.uuid)}}),S}const i=new Map;this.children.forEach(h=>{i.set(h.uuid,t(this,h.layout?.constraints))});const r=this.findTopologicalSort(i);if(r.length>0){const h=r.reverse(),c=new Array;h.forEach(S=>{const E=this.children.filter(O=>O.uuid===S).find(Boolean);if(E===void 0)throw new C("error in dag topological sort");c.push(E)}),c.forEach(S=>S.update())}else this.children.forEach(h=>h.update())}drawChildren(t){this.children.filter(i=>!i.hidden&&i.isDrawable).map(i=>i).sort((i,r)=>i.zPosition-r.zPosition).forEach(i=>i.draw(t))}run(t,i){this.actions.push(t.initialize(i))}removeAction(t){this.actions=this.actions.filter(i=>i.key!==t)}removeAllActions(){for(;this.actions.length;)this.actions.pop()}getNodeOptions(){return{name:this.name,position:this.position,scale:this.scale,alpha:this.alpha,zRotation:this.zRotation,isUserInteractionEnabled:this.isUserInteractionEnabled,draggable:this.draggable,hidden:this.hidden,layout:this.layout,uuid:this.uuid}}getDrawableOptions(){if(!this.isDrawable)throw new C("getDrawableOptions() called object that is not IDrawable");return{anchorPoint:this.anchorPoint,zPosition:this.zPosition}}getTextOptions(){if(!this.isText)throw new C("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===dt.Scene)throw new C(`Node ${this} is a scene and cannot have a parent scene`);if(this.parent&&this.parent.type===dt.Scene)return this.parent;if(this.parent)return this.parent.parentSceneAsNode;throw new C(`Node ${this} has not been added to a scene`)}get size(){const t=this;return{get height(){return t._size.height},set height(i){V.value(t._size.height,i)||(t._size.height=i,t.savePropertyChangeEvent("size",t.size))},get width(){return t._size.width},set width(i){V.value(t._size.width,i)||(t._size.width=i,t.savePropertyChangeEvent("size",t.size))}}}set size(t){V.value(this._size.width,t.width)||(this._size=t,this.savePropertyChangeEvent("size",this.size))}get position(){const t=this;return{get x(){return t._position.x},set x(i){V.value(t._position.x,i)||(t._position.x=i,t.savePropertyChangeEvent("position",t.position))},get y(){return t._position.y},set y(i){V.value(t._position.y,i)||(t._position.y=i,t.savePropertyChangeEvent("position",t.position))}}}set position(t){V.value(this._position,t)||(this._position=t,this.savePropertyChangeEvent("position",this.position))}get zRotation(){return this._zRotation}set zRotation(t){V.value(this._zRotation,t)||(this._zRotation=t,this.savePropertyChangeEvent("zRotation",t))}get scale(){return this._scale}set scale(t){V.value(this._scale,t)||(this._scale=t,this.savePropertyChangeEvent("scale",t))}get alpha(){return this._alpha}set alpha(t){V.value(this._alpha,t)||(this._alpha=t,this.savePropertyChangeEvent("alpha",t))}get isUserInteractionEnabled(){return this._isUserInteractionEnabled}set isUserInteractionEnabled(t){V.value(this._isUserInteractionEnabled,t)||(this._isUserInteractionEnabled=t,this.savePropertyChangeEvent("isUserInteractionEnabled",t))}get hidden(){return this._hidden}set hidden(t){V.value(this._hidden,t)||(this._hidden=t,this.savePropertyChangeEvent("hidden",t))}get draggable(){return this._draggable}set draggable(t){V.value(this._draggable,t)||(this._draggable=t,this.savePropertyChangeEvent("draggable",t))}get suppressEvents(){return this._suppressEvents}set suppressEvents(t){this._suppressEvents=t}findTopologicalSort(t){const i=[],r=new Map;t.forEach((c,S)=>{r.has(S)||r.set(S,0),c.forEach(E=>{if(r.has(E)){const O=r.get(E);if(O===void 0)throw new C(`Could not find inDegree for edge ${E}`);r.set(E,O+1)}else r.set(E,1)})});const h=[];for(r.forEach((c,S)=>{c==0&&h.push(S)});h.length>0;){const c=h.shift();if(c===void 0)throw"current vertex is undefined";i.push(c),t.has(c)&&t.get(c)?.forEach(S=>{const E=r.get(S);if(E===void 0)throw new C(`Could not find inDegree for edge ${S}`);if(r.has(S)&&E>0){const O=E-1;r.set(S,O),O==0&&h.push(S)}})}return i}}class fa extends fe{constructor(t={}){super(t),this.type=dt.Composite,this.compositeType="<compositeType>",this.isDrawable=!0,this._anchorPoint={x:.5,y:.5},this._zPosition=0,Le(this,t)}initialize(){}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){V.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){V.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){V.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){V.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}dispose(){}update(){super.update()}draw(t){super.drawChildren(t)}handleCompositeEvent(t){}}var Ur=(m=>(m[m.MatchConstraint=0]="MatchConstraint",m))(Ur||{});const ne={Deferred:"Deferred",Loading:"Loading",Ready:"Ready",Error:"Error"};class fn{constructor(t,i){this.images={},this.game=t,this.baseUrls=i,this.canvasKit=t.canvasKit}initializeImages(t){return this.loadImages(t??[])}async loadImages(t){if(t.length===0)return;this.checkImageNamesForDuplicates(t);const i=t.map(r=>{let h=r.url;r.url&&!q.urlHasScheme(r.url)&&(h=q.getUrlFromManifest(this.game,`${this.baseUrls.assets}/${r.url}`)),r.dataUrl&&(h=r.dataUrl);const c={imageName:r.imageName,url:h,originalUrl:h,isFallback:!1,localize:r.localize??!1,svgString:r.svgString,canvaskitImage:void 0,width:r.width,height:r.height,status:r.lazy?ne.Deferred:ne.Loading};return c.localize&&this.configureImageLocalization(c),this.images[r.imageName]=c,c.status===ne.Loading?this.renderM2Image(c):Promise.resolve()});await Promise.all(i)}configureImageLocalization(t){t.fallbackLocalizationUrls=new Array,t.originalUrl&&this.game.i18n?.locale&&(t.status="Deferred",this.game.i18n?.fallbackLocale&&this.game.i18n?.fallbackLocale!==this.game.i18n?.baseLocale&&t.fallbackLocalizationUrls.push(this.localizeImageUrl(t.originalUrl,this.game.i18n.fallbackLocale)),this.game.i18n?.locale===this.game.i18n?.baseLocale?t.url=t.originalUrl:t.url=this.localizeImageUrl(t.originalUrl,this.game.i18n.locale),t.url!==t.originalUrl&&t.fallbackLocalizationUrls.push(t.originalUrl),this.game.i18n.missingLocalizationColor&&!this.missingLocalizationImagePaint&&(this.missingLocalizationImagePaint=Nt.makePaint(this.canvasKit,this.game.i18n.missingLocalizationColor,this.canvasKit.PaintStyle.Stroke,!0),this.missingLocalizationImagePaint.setStrokeWidth(4)))}localizeImageUrl(t,i){const r=t.lastIndexOf(".");if(r===-1)throw new C("URL does not have an extension");return t.slice(0,r)+`.${i}`+t.slice(r)}reinitializeLocalizedImages(){Object.keys(this.game.imageManager.images).forEach(i=>{const r=this.game.imageManager.images[i];r.localize&&this.game.imageManager.configureImageLocalization(r)}),this.game.nodes.filter(i=>i.type===dt.Sprite).forEach(i=>{i.needsInitialization=!0})}checkImageNamesForDuplicates(t){const r=(h=>h.filter((c,S)=>h.indexOf(c)!=S))(t.map(h=>h.imageName));if(r.length>0)throw new C(`image names must be unique. these image names are duplicated within a game ${this.game.id}: `+r.join(", "))}prepareDeferredImage(t){return t.status=ne.Loading,t.isFallback=!1,this.renderM2Image(t).catch(async()=>{for(t.isFallback=!0;t.fallbackLocalizationUrls?.length;){t.url=t.fallbackLocalizationUrls.shift();try{await this.renderM2Image(t)}catch(i){if(t.fallbackLocalizationUrls.length===0)throw i instanceof Error?i:new C(`prepareDeferredImage(): unable to render image named ${t.imageName}. image source was ${t.svgString?"svgString":`url: ${t.url}`}`)}}})}renderM2Image(t){const i=document.createElement("img"),r=h=>{if(!this.scratchCanvas||!this.ctx||!this.scale)throw new C("image manager not set up");this.scratchCanvas.width=t.width*this.scale,this.scratchCanvas.height=t.height*this.scale,this.ctx.scale(this.scale,this.scale),this.ctx.clearRect(0,0,t.width,t.height),this.ctx.drawImage(i,0,0,t.width,t.height),this.scratchCanvas.toBlob(c=>{if(!c)throw new C(`renderM2Image(): blob is undefined for ${t.imageName}`);c.arrayBuffer().then(S=>{const E=this.canvasKit.MakeImageFromEncoded(S);if(!E)throw new C(`could not create image with name "${t.imageName}."`);console.log(`image loaded. name: ${t.imageName}, w: ${t.width}, h: ${t.height}`),this.images[t.imageName].canvaskitImage=E,this.images[t.imageName].status=ne.Ready,this.game.nodes.filter(G=>G.type==="Sprite").forEach(G=>{G.imageName===t.imageName&&(G.needsInitialization=!0)}),h()})})};return new Promise((h,c)=>{if(i.width=t.width,i.height=t.height,i.crossOrigin="Anonymous",i.onerror=()=>{c(new Error(`unable to render image named ${t.imageName}. image source was ${t.svgString?"svgString":`url: ${t.url}`}`))},i.onload=()=>{r(h)},!t.svgString&&!t.url)throw new C(`no svgString or url provided for image named ${t.imageName}`);if(t.svgString&&t.url)throw new C(`provide svgString or url. both were provided for image named ${t.imageName}`);if(t.svgString){i.src="data:image/svg+xml,"+encodeURIComponent(t.svgString);const S={type:H.BrowserImageDataReady,target:this,imageName:t.imageName,width:t.width,height:t.height,svgString:t.svgString,...q.createFrameUpdateTimestamps()};this.game.eventStore.addEvent(S)}else t.url&&fetch(t.url).then(S=>S.arrayBuffer()).then(S=>{this.arrayBufferToBase64Async(S).then(E=>{const O=this.inferImageSubtypeFromUrl(t.url);i.src="data:image/"+O+";base64,"+E;const G={type:H.BrowserImageDataReady,target:this,imageName:t.imageName,width:t.width,height:t.height,dataUrl:i.src,...q.createFrameUpdateTimestamps()};this.game.eventStore.addEvent(G)})})})}arrayBufferToBase64Async(t){return new Promise((i,r)=>{const h=new FileReader;h.onload=()=>{i(h.result?.toString().split(",")[1]??"")},h.onerror=r,h.readAsDataURL(new Blob([t]))})}inferImageSubtypeFromUrl(t){if(t?.startsWith("data:image/"))return t.split(";")[0].split("/")[1];let i="jpeg";return t?.includes(".")&&(i=t.split(".").pop()?.toLowerCase()??"jpeg",i===""&&(i="jpeg")),i==="svg"&&(i="svg+xml"),i}getImage(t){return this.images[t]}addImage(t){this.images[t.imageName]=t}get scratchCanvas(){if(!this._scratchCanvas){this._scratchCanvas=document.createElement("canvas"),this._scratchCanvas.id=`m2c2kit-scratch-canvas-${this.game.id}-${Math.floor(Math.random()*1e6)}`,this._scratchCanvas.hidden=!0,document.body.appendChild(this._scratchCanvas);const t=this._scratchCanvas.getContext("2d");if(t===null)throw new C("could not get 2d canvas context from scratch canvas");this.ctx=t,this.scale=window.devicePixelRatio}return this._scratchCanvas}removeScratchCanvas(){this.ctx=void 0,this._scratchCanvas?.remove()}}const di="{{}}",pn="[[]]";class zi{constructor(t,i){this.locale="",this.fallbackLocale="en-US",this.baseLocale="en-US",this.game=t,this._translation=this.mergeAdditionalTranslation(i.translation,i.additionalTranslation)??{},this.translation.configuration?.baseLocale&&(this.baseLocale=this.translation.configuration.baseLocale),i.missingLocalizationColor&&(this.missingLocalizationColor=i.missingLocalizationColor),i.locale&&(this.locale=i.locale),i.fallbackLocale&&(this.fallbackLocale=i.fallbackLocale)}async initialize(){await this.configureInitialLocale()}async configureInitialLocale(){if(this.game.hasDataStores()){const t=await this.game.storeGetItem("locale"),i=await this.game.storeGetItem("fallbackLocale");if(typeof t=="string"&&typeof i=="string"){this.locale=t,this.fallbackLocale=i;return}}if(this.locale?.toLowerCase()==="auto"){const t=this.getEnvironmentLocale();t?this.localeTranslationAvailable(t)?(this.locale=t,this.localeTranslationAvailable(this.fallbackLocale)||(this.fallbackLocale=this.baseLocale)):this.fallbackLocale&&this.localeTranslationAvailable(this.fallbackLocale)?(console.warn(`auto locale requested, but detected locale ${t} does not have translation. Setting locale to fallback locale ${this.fallbackLocale}`),this.locale=this.fallbackLocale,this.fallbackLocale=this.baseLocale):(console.warn(`auto locale requested, but detected locale ${t} does not have translation, and fallback locale does not have translation or was not specified (fallback locale is ${this.fallbackLocale}). Setting locale to base locale ${this.baseLocale}.`),this.locale=this.baseLocale,this.fallbackLocale=this.baseLocale):this.fallbackLocale&&this.localeTranslationAvailable(this.fallbackLocale)?(console.warn(`auto locale requested, but environment cannot detect locale. Setting locale to fallback locale ${this.fallbackLocale}`),this.locale=this.fallbackLocale,this.fallbackLocale=this.baseLocale):(console.warn(`auto locale requested, but environment cannot detect locale, and fallback locale does not have translation or was not specified (fallback locale is ${this.fallbackLocale}). Setting locale to base locale ${this.baseLocale}.`),this.locale=this.baseLocale,this.fallbackLocale=this.baseLocale)}else this.locale=this.locale??"",this.fallbackLocale||(this.fallbackLocale=this.baseLocale)}localeTranslationAvailable(t){return this.translation[t]!==void 0||t===this.baseLocale}switchToLocale(t){this.locale=t,this.game.nodes.filter(i=>i.isText).forEach(i=>i.needsInitialization=!0),this.game.imageManager.reinitializeLocalizedImages(),this.game&&this.game.hasDataStores()&&(this.game.storeSetItem("locale",this.locale),this.game.storeSetItem("fallbackLocale",this.fallbackLocale))}getTextLocalization(t,i){const r=this.attemptTranslation(t,i);if(r.isFallbackOrMissingTranslation){const h=this.handleTranslationPlaceholders(t,r,i);if(h)return i!==void 0&&(h.text=this.insertInterpolations(di,h.text,i)),h}return r}attemptTranslation(t,i){let r=this.tf(t,i),h=!1;return r?.text===void 0&&(r=this.tf(t,{useFallbackLocale:!0,...i}),h=!0),{text:r?.text??t,fontSize:r?.fontSize,fontName:r?.fontName,fontNames:r?.fontNames,isFallbackOrMissingTranslation:h}}handleTranslationPlaceholders(t,i,r){const h=this.getTranslationPlaceholders(t);if(h.length===0)return null;const c={size:new Set,name:new Set,names:new Set},S={};let E=!1;h.forEach(lt=>{const yt=this.translatePlaceholder(lt,c,r);S[lt]=yt.text,E=E||yt.isFallback}),this.warnConflictingFontProperties(t,c);const O=this.insertInterpolations(pn,t,S),G=i.fontSize||(c.size.size>0?[...c.size][0]:void 0),K=i.fontName||(c.name.size>0?[...c.name][0]:void 0),it=i.fontNames||(c.names.size>0?[...c.names][0].split(","):void 0);return{text:O,fontSize:G,fontName:K,fontNames:it,isFallbackOrMissingTranslation:E}}translatePlaceholder(t,i,r){let h=this.tf(t,r),c=!1;return h?.text===void 0&&(h=this.tf(t,{useFallbackLocale:!0,...r}),c=!0),h?.fontSize!==void 0&&i.size.add(h.fontSize),h?.fontName!==void 0&&i.name.add(h.fontName),h?.fontNames!==void 0&&i.names.add(h.fontNames.sort().join(",")),{text:h?.text??t,isFallback:c}}getTranslationPlaceholders(t){const[i,r]=[pn.slice(0,2),pn.slice(2)],h=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),S=new RegExp(`${h}(.*?)${c}`,"g"),E=t.match(S);return E?E.map(O=>O.slice(i.length,-r.length).trim()):[]}warnConflictingFontProperties(t,i){i.size.size>1&&console.warn(`i18n: placeholders set multiple different font sizes in string to be localized. Only one will be used. String: ${t}`),i.name.size>1&&console.warn(`i18n: placeholders set multiple different font names within string to be localized. Only one will be used. String: ${t}`),i.names.size>1&&console.warn(`i18n: placeholders set multiple different font names arrays within string to be localized. Only one will be used. String: ${t}`)}t(t,i){const{useFallbackLocale:r,...h}=i??{};if(r!==!0){const S=this.translation[this.locale]?.[t];return this.isStringOrTextWithFontCustomization(S)?this.insertInterpolations(di,this.getKeyText(S),h):void 0}const c=this.translation[this.fallbackLocale]?.[t];if(this.isStringOrTextWithFontCustomization(c))return this.insertInterpolations(di,this.getKeyText(c),h)}tf(t,i){const{useFallbackLocale:r,...h}=i??{};if(r!==!0){const S=this.translation[this.locale]?.[t];if(this.isStringOrTextWithFontCustomization(S)){const E=this.getKeyTextAndFont(S,this.locale);return E.text&&(E.text=this.insertInterpolations(di,E.text,h)),E}return}const c=this.translation[this.fallbackLocale]?.[t];if(this.isStringOrTextWithFontCustomization(c)){const S=this.getKeyTextAndFont(c,this.fallbackLocale);return S.text&&(S.text=this.insertInterpolations(di,S.text,h)),S}}getKeyText(t){return this.isTextWithFontCustomization(t)?t.text:t}getKeyTextAndFont(t,i){let r,h=new Array;this.isString(this.translation[i]?.fontName)?h.push(this.translation[i].fontName):this.isStringArray(this.translation[i]?.fontName)?h.push(...this.translation[i].fontName):h.push("default");let c;switch(this.isTextWithFontCustomization(t)?(c=t.text,r=t.fontSize,this.isString(t.additionalFontName)&&h.push(t.additionalFontName),this.isStringArray(t.additionalFontName)&&h.push(...t.additionalFontName),t.overrideFontName&&(h.length=0,this.isString(t.overrideFontName)&&h.push(t.overrideFontName),this.isStringArray(t.overrideFontName)&&h.push(...t.overrideFontName))):c=t,h=h.filter(S=>S!=="default"),h.length){case 0:return{text:c,fontSize:r};case 1:return{text:c,fontSize:r,fontName:h[0]};default:return{text:c,fontSize:r,fontNames:h}}}insertInterpolations(t,i,r){if(!r)return i;const[h,c]=[t.slice(0,2),t.slice(2)],S=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),E=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),O=new RegExp(`${S}(.*?)${E}`,"g");return i.replace(O,(G,K)=>{if(Object.prototype.hasOwnProperty.call(r,K))return r[K];throw new C(`insertInterpolations(): placeholder "${K}" not found. Text was ${i}, provided interpolation was ${JSON.stringify(r)}`)})}get translation(){return this._translation}set translation(t){this._translation=t}getEnvironmentLocale(){return(navigator.languages&&navigator.languages.length?navigator.languages[0]:navigator.language)??""}mergeAdditionalTranslation(t,i){if(!t&&!i)return;if(!i)return t;if(!t)return i;const r={},h=new Array;for(const c in t)h.push(c),r[c]={...t[c],...i[c]};for(const c in i)h.includes(c)||(r[c]=i[c]);return r}static makeLocalizationParameters(){return JSON.parse(JSON.stringify({locale:{type:["string","null"],default:null,description:'Locale to use for localization, or "auto" to request from the environment.'},fallback_locale:{type:["string","null"],default:null,description:'Locale to use if requested locale translation is not available, or if "auto" locale was requested and environment cannot provide a locale.'},missing_localization_color:{type:["array","null"],default:null,description:"Font color for strings that are missing translation and outline color for images that are missing localization, [r,g,b,a].",items:{type:"number"}},translation:{type:["object","null"],default:null,description:"Additional translation for localization."}}))}isTextWithFontCustomization(t){return t?.text!==void 0}isStringOrTextWithFontCustomization(t){return typeof t=="string"||this.isTextWithFontCustomization(t)}isStringArray(t){return Array.isArray(t)&&t.every(i=>typeof i=="string")}isString(t){return typeof t=="string"}}const ve={Disabled:"Disabled",Record:"Record",Replay:"Replay"};class $r{constructor(){this.events=new Array,this.replayBeginTimestamp=NaN,this.firstTimestamp=NaN,this.replayThoughSequence=Number.MAX_VALUE,this.serializedEventsBeforeReplay="",this.mode=ve.Disabled}serializeEvent(t){const i=t.target;if(t.type===H.NodeNew&&t.nodeOptions?.layout?.constraints!==void 0){const h=t.nodeOptions?.layout?.constraints,c={};for(const E in h){if(E==="horizontalBias"||E==="verticalBias"){c[E]=h[E];continue}const O=h[E];O instanceof fe&&(c[E]=O.uuid)}t.target=i.uuid,t.nodeOptions.layout.constraints=c;const S=JSON.stringify(t);return t.target=i,t.nodeOptions.layout.constraints=h,S}if(i instanceof fe){t.target=i.uuid;const h=JSON.stringify(t);return t.target=i,h}if(i instanceof Element){t.target=i.nodeName;const h=JSON.stringify(t);return t.target=i,h}if(i instanceof fn){t.target="ImageManager";const h=JSON.stringify(t);return t.target=i,h}if(i instanceof zi){t.target="I18n";const h=JSON.stringify(t);return t.target=i,h}t.target="object";const r=JSON.stringify(t);return t.target=i,r}addEvent(t){if(this.mode===ve.Record){t.sequence===void 0&&(t.sequence=m2c2Globals.eventSequence);const i=this.serializeEvent(t);this.events.push(JSON.parse(i))}}addEvents(t){t.forEach(i=>{this.addEvent(i)})}clearEvents(){this.events=[]}record(){this.mode=ve.Record}replay(t){if(t&&(this.events=t),this.events.length===0)if(this.serializedEventsBeforeReplay!=="")this.events=JSON.parse(this.serializedEventsBeforeReplay);else{console.log("Event store has no events to replay.");return}this.mode=ve.Replay,this.replayBeginTimestamp=Vt.now(),this.sortEventStore(this.events),this.serializedEventsBeforeReplay===""&&(this.serializedEventsBeforeReplay=JSON.stringify(this.events)),this.firstTimestamp=this.events[0].timestamp,console.log(`Event store has ${this.events.length} events. Replay beginning.`);const i=document.getElementById("sequence-number");i&&(this.replayThoughSequence=parseInt(i.value))}getEvents(){return this.sortEventStore(this.events),this.events}dequeueEvents(t){const i=new Array,r=t-this.replayBeginTimestamp+this.firstTimestamp;for(;this.events.length>0&&this.events[0].timestamp<=r;){const h=this.events.shift();if(!h)throw new C("EventStore.dequeueEvents(): undefined event");h.sequence!==void 0&&h.sequence>this.replayThoughSequence||i.push(h)}return i}get eventQueueLength(){return this.events.length}sortEventStore(t){t.sort((i,r)=>{if(i.sequence===void 0||r.sequence===void 0)throw new C("EventStore.sortEventStore(): undefined sequence");return i.sequence!==r.sequence?i.sequence-r.sequence:0})}}var He=(m=>(m[m.Center=0]="Center",m[m.Left=1]="Left",m[m.Right=2]="Right",m))(He||{});const re={Deferred:"Deferred",Loading:"Loading",Ready:"Ready"},Jt={UNDERLINE:"u",ITALIC:"i",BOLD:"b",STRIKETHROUGH:"s",OVERLINE:"o"};class Ui extends fe{constructor(t={}){super(t),this.type=dt.Label,this.isDrawable=!0,this.isText=!0,this._anchorPoint={x:.5,y:.5},this._zPosition=0,this._text="",this._fontColor=Q.DEFAULT_FONT_COLOR,this._fontSize=Q.DEFAULT_FONT_SIZE,this._interpolation={},this._horizontalAlignmentMode=He.Center,this._localize=!0,this.localizedFontNames=[],this.textAfterLocalization="",this.plainText="",this.styleSegments=[],Le(this,t),t.horizontalAlignmentMode&&(this.horizontalAlignmentMode=t.horizontalAlignmentMode),t.preferredMaxLayoutWidth!==void 0&&(this.preferredMaxLayoutWidth=t.preferredMaxLayoutWidth),t.backgroundColor&&(this.backgroundColor=t.backgroundColor),t.fontNames&&(this.fontNames=t.fontNames),this.saveNodeNewEvent()}get completeNodeOptions(){return{...this.options,...this.getNodeOptions(),...this.getDrawableOptions(),...this.getTextOptions(),horizontalAlignmentMode:this.horizontalAlignmentMode,preferredMaxLayoutWidth:this.preferredMaxLayoutWidth,backgroundColor:this.backgroundColor,fontNames:this.fontNames}}initialize(){let t=this.canvasKit.TextAlign.Center;switch(this.horizontalAlignmentMode){case He.Center:t=this.canvasKit.TextAlign.Center;break;case He.Left:t=this.canvasKit.TextAlign.Left;break;case He.Right:t=this.canvasKit.TextAlign.Right;break;default:throw new C("unknown horizontalAlignmentMode")}this.text||(this.text="");let i=this.canvasKit.Color(this.fontColor[0],this.fontColor[1],this.fontColor[2],this.fontColor[3]);const r=this.game.i18n;if(r&&this.localize!==!1){const K=r.getTextLocalization(this.text,this.interpolation);this.textAfterLocalization=K.text,this.localizedFontSize=K.fontSize,this.localizedFontName=K.fontName,this.localizedFontNames=K.fontNames??[],K.isFallbackOrMissingTranslation&&r.missingLocalizationColor&&(i=this.canvasKit.Color(r.missingLocalizationColor[0],r.missingLocalizationColor[1],r.missingLocalizationColor[2],r.missingLocalizationColor[3]))}else this.textAfterLocalization=this.text;const h=this.parseFormattedText(this.textAfterLocalization);if(this.plainText=h.plainText,this.styleSegments=h.styleSegments,this.fontName&&this.fontNames)throw new C("cannot specify both fontName and fontNames");const c=this.game.fontManager,S=this.getRequiredLabelFonts(c);if(S.forEach(K=>{if(K.status===re.Deferred){c.prepareDeferredFont(K);return}}),!S.every(K=>K.status===re.Ready))return;this.paraStyle=new this.canvasKit.ParagraphStyle({textStyle:{},textAlign:t}),this.builder&&this.builder.delete(),this.builder=this.canvasKit.ParagraphBuilder.MakeFromFontProvider(this.paraStyle,c.provider),this._backgroundPaint||(this._backgroundPaint=new this.canvasKit.Paint),this._fontPaint||(this._fontPaint=new this.canvasKit.Paint),this.fontPaint.setColor(i),this.fontPaint.setAlphaf(this.absoluteAlpha),this.backgroundColor?(this.backgroundPaint.setColor(this.backgroundColor),this.backgroundPaint.setAlphaf(this.absoluteAlpha)):this.backgroundPaint.setColor(this.canvasKit.Color(0,0,0,0));const E={fontFamilies:S.map(K=>K.fontName),fontSize:(this.localizedFontSize??this.fontSize)*m2c2Globals.canvasScale,fontStyle:{weight:this.canvasKit.FontWeight.Normal,width:this.canvasKit.FontWidth.Normal,slant:this.canvasKit.FontSlant.Upright},decoration:0,decorationThickness:1,decorationStyle:this.canvasKit.DecorationStyle.Solid,heightMultiplier:-1,halfLeading:!1,letterSpacing:0,wordSpacing:0};this.builder.pushPaintStyle(E,this.fontPaint,this.backgroundPaint),this.addStyleSegmentsToParagraphBuilder(this.builder,this.styleSegments,E),this.paragraph&&this.paragraph.delete(),this.paragraph=this.builder.build();const O=this.preferredMaxLayoutWidth??m2c2Globals.canvasCssWidth;let G=O;if(O===0||this.layout.width===0){if(this.parent===void 0)throw new C("width is set to match parent, but node has no parent");const K=this.layout.marginStart??0,it=this.layout.marginEnd??0;G=this.parent.size.width-(K+it)}this.paragraph.layout(G*m2c2Globals.canvasScale),O===0||this.layout.width===0?this.size.width=G:(this.paragraph.layout(Math.ceil(this.paragraph.getLongestLine())),this.size.width=this.paragraph.getMaxWidth()/m2c2Globals.canvasScale),this.size.height=this.paragraph.getHeight()/m2c2Globals.canvasScale,this.needsInitialization=!1}parseFormattedText(t){let i="";const r=[],h=[],c=new Set([Jt.UNDERLINE,Jt.BOLD,Jt.ITALIC,Jt.STRIKETHROUGH,Jt.OVERLINE]),S=/<\/?([^>]+)>/g;let E=0,O=0,G=null;const K=st=>{let Et=1,Wt=1;for(let Bt=0;Bt<st;Bt++)t[Bt]===`
2
+ `?(Et++,Wt=1):Wt++;return`line ${Et}, column ${Wt}`};for(;(G=S.exec(t))!==null;){const st=G[0],Et=G[1],Wt=st.charAt(1)==="/",Bt=K(G.index);if(!c.has(Et)){const U=t.substring(E,G.index);i+=U,O+=U.length,i+=st,O+=st.length,E=G.index+st.length;continue}const se=t.substring(E,G.index);if(i+=se,O+=se.length,Wt){if(h.length===0)throw new C(`Label has closing tag </${Et}> at ${Bt} without matching opening tag. Text is: ${t}`);const U=h.pop();if(U!==Et)throw new C(`Label has improperly nested tags at ${Bt}. Expected </${U}> but found </${Et}>. Tags must be properly nested. Text is: ${t}`);r.push({position:O,style:Et,isStart:!1})}else h.push(Et),r.push({position:O,style:Et,isStart:!0});E=G.index+st.length}if(i+=t.substring(E),h.length>0)throw new C(`Label has unclosed format tags: <${h.join(">, <")}>. All tags must be closed. Text is: ${t}`);const it=new Set,lt=[];let yt=0;r.sort((st,Et)=>st.position-Et.position);for(const st of r)st.position>yt&&it.size>0&&lt.push({start:yt,end:st.position,styles:new Set(it)}),st.isStart?it.add(st.style):it.delete(st.style),yt=st.position;return{plainText:i,styleSegments:lt}}addStyleSegmentsToParagraphBuilder(t,i,r){if(i.length===0)t.addText(this.plainText);else{let h=0;for(const c of i){c.start>h&&this.addTextWithStyle(t,this.plainText.substring(h,c.start),r);const S={};if(c.styles.has(Jt.BOLD)&&(S.fontStyle={...S.fontStyle||r.fontStyle,weight:this.canvasKit.FontWeight.Black}),c.styles.has(Jt.ITALIC)&&(S.fontStyle={...S.fontStyle||r.fontStyle,slant:this.canvasKit.FontSlant.Italic}),c.styles.has(Jt.UNDERLINE)&&(S.decoration=this.canvasKit.UnderlineDecoration,S.decorationThickness=1,S.decorationStyle=this.canvasKit.DecorationStyle.Solid,S.decorationColor=this.fontColor),c.styles.has(Jt.STRIKETHROUGH)&&(S.decoration=this.canvasKit.LineThroughDecoration,S.decorationThickness=1,S.decorationStyle=this.canvasKit.DecorationStyle.Solid,S.decorationColor=this.fontColor),c.styles.has(Jt.OVERLINE)&&(S.decoration=this.canvasKit.OverlineDecoration,S.decorationThickness=1,S.decorationStyle=this.canvasKit.DecorationStyle.Solid,S.decorationColor=this.fontColor),[Jt.UNDERLINE,Jt.STRIKETHROUGH,Jt.OVERLINE].filter(O=>c.styles.has(O)).length>1)throw new C(`Label does not support multiple text decorations (underline, overline, or strikethrough) on a single text segment. Text is: ${this.textAfterLocalization}`);this.addTextWithStyle(t,this.plainText.substring(c.start,c.end),r,S),h=c.end}h<this.plainText.length&&this.addTextWithStyle(t,this.plainText.substring(h),r)}}addTextWithStyle(t,i,r,h={}){if(!i)return;const c={...r,...h};t.pushPaintStyle(c,this.fontPaint,this.backgroundPaint),t.addText(i),t.pop()}getRequiredLabelFonts(t){let i;if(this.game.i18n&&this.localize!==!1){if(this.localizedFontName)return i=[t.fonts[this.localizedFontName]],i;if(this.localizedFontNames.length>0)return i=this.localizedFontNames.map(r=>t.fonts[r]),i}if(this.fontName===void 0&&this.fontNames===void 0)i=[t.getDefaultFont()];else if(this.fontName!==void 0)i=[t.fonts[this.fontName]];else if(this.fontNames!==void 0&&this.fontNames.length>0)i=this.fontNames.map(r=>t.fonts[r]);else throw new C("cannot determine required fonts");return i}dispose(){Nt.Dispose([this.paragraph,this.builder,this._fontPaint,this._backgroundPaint])}get text(){return this._text}set text(t){V.value(this._text,t)||(this._text=t,this.needsInitialization=!0,this.savePropertyChangeEvent("text",t))}get interpolation(){return this._interpolation}set interpolation(t){V.value(this._interpolation,t)||(this._interpolation=t,Object.freeze(this._interpolation),this.needsInitialization=!0,this.savePropertyChangeEvent("interpolation",t))}get fontName(){return this._fontName}set fontName(t){V.value(this._fontName,t)||(this._fontName=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontName",t))}get fontNames(){return this._fontNames}set fontNames(t){V.value(this._fontNames,t)||(this._fontNames=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontNames",t))}get fontColor(){return this._fontColor}set fontColor(t){V.value(this._fontColor,t)||(this._fontColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontColor",t))}get fontSize(){return this._fontSize}set fontSize(t){V.value(this._fontSize,t)||(this._fontSize=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontSize",t))}get horizontalAlignmentMode(){return this._horizontalAlignmentMode}set horizontalAlignmentMode(t){V.value(this._horizontalAlignmentMode,t)||(this._horizontalAlignmentMode=t,this.needsInitialization=!0,this.savePropertyChangeEvent("horizontalAlignmentMode",t))}get preferredMaxLayoutWidth(){return this._preferredMaxLayoutWidth}set preferredMaxLayoutWidth(t){V.value(this._preferredMaxLayoutWidth,t)||(this._preferredMaxLayoutWidth=t,this.needsInitialization=!0,this.savePropertyChangeEvent("preferredMaxLayoutWidth",t))}get backgroundColor(){return this._backgroundColor}set backgroundColor(t){V.value(this._backgroundColor,t)||(this._backgroundColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("backgroundColor",t))}get localize(){return this._localize}set localize(t){V.value(this._localize,t)||(this._localize=t,this.needsInitialization=!0,this.savePropertyChangeEvent("localize",t))}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){V.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){V.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){V.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){V.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}get backgroundPaint(){if(!this._backgroundPaint)throw new C("backgroundPaint cannot be undefined");return this._backgroundPaint}set backgroundPaint(t){this._backgroundPaint=t}get fontPaint(){if(!this._fontPaint)throw new C("fontPaint cannot be undefined");return this._fontPaint}set fontPaint(t){this._fontPaint=t}duplicate(t){const i=new Ui({...this.getNodeOptions(),...this.getDrawableOptions(),...this.getTextOptions(),horizontalAlignmentMode:this.horizontalAlignmentMode,preferredMaxLayoutWidth:this.preferredMaxLayoutWidth,backgroundColor:this.backgroundColor,name:t});return this.children.length>0&&(i.children=this.children.map(r=>{const h=r.duplicate();return h.parent=i,h})),i}update(){super.update(),this.absoluteAlphaChange!==0&&this.initialize()}draw(t){if(this.parent&&this.text!==""&&!this.needsInitialization){t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;t.scale(1/i,1/i),q.rotateCanvasForDrawableNode(t,this);const r=(this.absolutePosition.x-this.size.width*this.anchorPoint.x*this.absoluteScale)*i,h=(this.absolutePosition.y-this.size.height*this.anchorPoint.y*this.absoluteScale)*i;if(this.paragraph===void 0)throw new C("no paragraph");t.drawParagraph(this.paragraph,r,h),t.restore()}super.drawChildren(t)}warmup(t){const i=this.game.i18n;if(i&&this.localize!==!1){const h=i.getTextLocalization(this.text,this.interpolation);this.localizedFontName=h.fontName,this.localizedFontNames=h.fontNames??[]}if(!this.getRequiredLabelFonts(this.game.fontManager).some(h=>h.status===re.Deferred)&&Object.keys(this.layout).length===0){if(this.initialize(),!this.paragraph)throw new C(`warmup Label node ${this.toString()}: paragraph is undefined`);t.drawParagraph(this.paragraph,0,0)}}}class Ve extends fe{constructor(t={}){super(t),this.type=dt.Scene,this.isDrawable=!0,this._anchorPoint={x:0,y:0},this._zPosition=0,this._backgroundColor=Q.DEFAULT_SCENE_BACKGROUND_COLOR,this._active=!1,this._transitioning=!1,Le(this,t),t.backgroundColor&&(this.backgroundColor=t.backgroundColor),this.saveNodeNewEvent()}get completeNodeOptions(){return{...this.options,...this.getNodeOptions(),...this.getDrawableOptions(),backgroundColor:this.backgroundColor}}initialize(){this.scale=m2c2Globals.rootScale,this.size.width=this.game.canvasCssWidth,this.size.height=this.game.canvasCssHeight,this.backgroundPaint&&this.backgroundPaint.delete(),this.backgroundPaint=Nt.makePaint(this.canvasKit,this.backgroundColor,this.canvasKit.PaintStyle.Fill,!1),this.needsInitialization=!1}dispose(){Nt.Dispose([this.backgroundPaint])}set game(t){this._game=t}get game(){if(this._game===void 0)throw new C(`Scene ${this} has not been added to a game.`);return this._game}get backgroundColor(){return this._backgroundColor}set backgroundColor(t){V.value(this._backgroundColor,t)||(this._backgroundColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("backgroundColor",t))}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){V.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){V.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){V.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){V.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}duplicate(t){const i=new Ve({...this.getNodeOptions(),...this.getDrawableOptions(),backgroundColor:this.backgroundColor,name:t});return i.game=this.game,this.children.length>0&&(i.children=this.children.map(r=>{const h=r.duplicate();return h.parent=i,h})),i}onSetup(t,i){this.addEventListener("SceneSetup",t,i)}onAppear(t,i){this.addEventListener("SceneAppear",t,i)}onKeyDown(t,i){this.addEventListener(H.KeyDown,t,i)}onKeyUp(t,i){this.addEventListener(H.KeyUp,t,i)}update(){super.update()}draw(t){t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;if(t.scale(1/i,1/i),q.rotateCanvasForDrawableNode(t,this),!this.backgroundPaint)throw new C(`in Scene ${this}, background paint is undefined.`);this.absoluteAlphaChange!==0&&this.backgroundPaint.setAlphaf(this.absoluteAlpha),t.drawRect([this.position.x*i*m2c2Globals.rootScale,this.position.y*i*m2c2Globals.rootScale,(this.position.x+this.size.width)*i*m2c2Globals.rootScale,(this.position.y+this.size.height)*i*m2c2Globals.rootScale],this.backgroundPaint),t.restore(),super.drawChildren(t)}warmup(t){this.initialize(),t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;if(t.scale(1/i,1/i),!this.backgroundPaint)throw new C(`in Scene ${this}, background paint is undefined.`);t.drawRect([this.position.x*i*m2c2Globals.rootScale,this.position.y*i*m2c2Globals.rootScale,(this.position.x+this.size.width)*i*m2c2Globals.rootScale,(this.position.y+this.size.height)*i*m2c2Globals.rootScale],this.backgroundPaint),t.restore(),this.children.forEach(r=>{r.isDrawable&&r.warmup(t)})}}class fi extends fe{constructor(t={}){if(super(t),this.type=dt.Shape,this.isDrawable=!0,this.isShape=!0,this._anchorPoint={x:.5,y:.5},this._zPosition=0,this.shapeType=Kt.Undefined,this.ckPath=null,this._cornerRadius=0,this._fillColor=Q.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,Le(this,t),t.path!==void 0){if(this.path=t.path,this.shapeType=Kt.Path,this.shapeIsM2Path()&&t.size!==void 0&&(this.size=t.size),this.shapeIsSvgStringPath()&&t.size!==void 0)throw new C("Size cannot be specified when path is SVG string path");if(this.svgPathRequestedWidth=t.path.width,this.svgPathRequestedHeight=t.path.height,this.svgPathRequestedHeight!==void 0&&this.svgPathRequestedWidth!==void 0)throw new C("Cannot specify both width and height for SVG string path.");if(this.strokeColor||(this.strokeColor=Q.DEFAULT_PATH_STROKE_COLOR),this.lineWidth===void 0&&(this.lineWidth=Q.DEFAULT_PATH_LINE_WIDTH),t.circleOfRadius||t.rect)throw new C("Shape must specify only one of: path, circleOfRadius, or rect")}if(t.circleOfRadius!==void 0){if(this.circleOfRadius=t.circleOfRadius,this.shapeType=Kt.Circle,t.size!==void 0)throw new C("Size cannot be specified for circle shape");if(t.path||t.rect)throw new C("Shape must specify only one of: path, circleOfRadius, or rect");this.size.width=this.circleOfRadius*2,this.size.height=this.circleOfRadius*2}if(t.rect&&(this.rect=t.rect,t.rect.size?(this.size.width=t.rect.size.width,this.size.height=t.rect.size.height):t.rect.width!==void 0&&t.rect.height!==void 0&&(this.size.width=t.rect.width,this.size.height=t.rect.height),t.rect.origin?this.position=t.rect.origin:t.rect.x!==void 0&&t.rect.y!==void 0&&(this.position={x:t.rect.x,y:t.rect.y}),this.shapeType=Kt.Rectangle,t.size!==void 0))throw new C("Size cannot be specified for rectangle shape");t.cornerRadius!==void 0&&(this.cornerRadius=t.cornerRadius),t.fillColor&&(this.fillColor=t.fillColor),t.strokeColor&&(this.strokeColor=t.strokeColor),t.lineWidth!==void 0&&(this.lineWidth=t.lineWidth),t.isAntialiased!==void 0&&(this.isAntialiased=t.isAntialiased),t.strokeColor&&!t.lineWidth&&console.warn(`warning: for node ${this}, strokeColor = ${t.strokeColor} but lineWidth is non-zero. In normal usage, both would be set or both would be undefined.`),t.strokeColor===void 0&&t.lineWidth&&console.warn(`warning: for node ${this}, lineWidth = ${t.lineWidth} but strokeColor is undefined. In normal usage, both would be set or both would be undefined.`),this.saveNodeNewEvent()}get completeNodeOptions(){let t;return this.shapeIsM2Path()&&(t=this.size),{...this.options,...this.getNodeOptions(),...this.getDrawableOptions(),circleOfRadius:this.circleOfRadius,rect:this.rect,cornerRadius:this.cornerRadius,fillColor:this.fillColor,strokeColor:this.strokeColor,lineWidth:this.lineWidth,path:this.path,size:t,isAntialiased:this.isAntialiased}}initialize(){if(this.shapeType===Kt.Path&&this.shapeIsSvgStringPath()){const t=this.path.pathString??this.path.svgPathString;if(!t)throw new C("SVG Path string is null/undefined");if(this.path.svgPathString!==void 0&&console.warn("warning: svgPathString is deprecated. Use pathString instead."),this.ckPath=this.canvasKit.Path.MakeFromSVGString(t),!this.ckPath)throw new C("could not make CanvasKit Path from SVG string");const i=this.ckPath.getBounds();this.svgPathWidth=i[2]+(i[0]<0?Math.abs(i[0]):0),this.svgPathHeight=i[3]+(i[1]<0?Math.abs(i[1]):0),this.svgPathRequestedHeight!==void 0?this.svgPathScaleForResizing=this.svgPathRequestedHeight/this.svgPathHeight:this.svgPathRequestedWidth!==void 0&&(this.svgPathScaleForResizing=this.svgPathRequestedWidth/this.svgPathWidth),this.size.width=this.svgPathWidth*this.svgPathScaleForResizing,this.size.height=this.svgPathHeight*this.svgPathScaleForResizing,this.svgPreviousAbsoluteX=0,this.svgPreviousAbsoluteY=0}if(this.shapeIsM2Path()&&(this.size.width===0||this.size.height===0||this.size.width===void 0||this.size.height===void 0))throw new C("Size of shape must have non-zero height and width when path is M2Path");this.fillColor&&(this.fillColorPaintAntialiased=Nt.makePaint(this.canvasKit,this.fillColor,this.canvasKit.PaintStyle.Fill,!0),this.fillColorPaintNotAntialiased=Nt.makePaint(this.canvasKit,this.fillColor,this.canvasKit.PaintStyle.Fill,!1)),this.strokeColor&&(this.strokeColorPaintAntialiased=Nt.makePaint(this.canvasKit,this.strokeColor,this.canvasKit.PaintStyle.Stroke,!0),this.strokeColorPaintNotAntialiased=Nt.makePaint(this.canvasKit,this.strokeColor,this.canvasKit.PaintStyle.Stroke,!1)),this.svgFirstPathDraw=!0,this.needsInitialization=!1}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){V.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){V.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){V.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){V.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}dispose(){Nt.Dispose([this._strokeColorPaintAntialiased,this._strokeColorPaintNotAntialiased,this._fillColorPaintAntialiased,this._fillColorPaintNotAntialiased,this.ckPath,...Array.from(this.colorfulPathPaints.values())])}duplicate(t){const i=new fi({...this.getNodeOptions(),...this.getDrawableOptions(),shapeType:this.shapeType,circleOfRadius:this.circleOfRadius,rect:this.rect,cornerRadius:this.cornerRadius,fillColor:this.fillColor,strokeColor:this.strokeColor,lineWidth:this.lineWidth,name:t});return this.children.length>0&&(i.children=this.children.map(r=>{const h=r.duplicate();return h.parent=i,h})),i}update(){super.update()}draw(t){t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;t.scale(1/i,1/i),q.rotateCanvasForDrawableNode(t,this),this.absoluteAlphaChange!==0&&this.applyAlphaToPaints(this.absoluteAlpha,[this._fillColorPaintAntialiased,this._fillColorPaintNotAntialiased,this._strokeColorPaintAntialiased,this._strokeColorPaintNotAntialiased]),this.shapeIsM2Path()&&this.drawPathFromM2Path(t),this.shapeIsSvgStringPath()&&this.drawPathFromSvgString(t),this.shapeType===Kt.Circle&&this.drawCircle(t),this.shapeType===Kt.Rectangle&&this.drawRectangle(t),t.restore(),super.drawChildren(t)}applyAlphaToPaints(t,i){i.forEach(r=>{r&&r.setAlphaf(t)})}drawPathFromM2Path(t){const i=m2c2Globals.canvasScale/this.absoluteScale,r=(this.absolutePosition.x-this.anchorPoint.x*this.size.width*this.absoluteScale)*i,h=(this.absolutePosition.y-this.anchorPoint.y*this.size.height*this.absoluteScale)*i;if(this.pathIsM2ColorfulPath(this.path)){const c=this.path.linePresentations;let S=0;const E=this.path.subpaths;let O;for(let G=0;G<E.length;G++){const it=E[G].flat();for(let lt=0;lt<it.length-1;lt++){if(c[S].subpathIndex===G&&c[S].pointIndex===lt){const yt=c[S].strokeColor,st=c[S].lineWidth,Et=[...yt,st].toString();O=this.colorfulPathPaints.get(Et),O===void 0&&(O=Nt.makePaint(this.canvasKit,yt,this.canvasKit.PaintStyle.Stroke,!0),O.setStrokeWidth(st*m2c2Globals.canvasScale),this.colorfulPathPaints.set(Et,O)),S<c.length-1&&S++}if(O===void 0)throw new C("paint is undefined");t.drawLine(r+it[lt].x*m2c2Globals.canvasScale,h+it[lt].y*m2c2Globals.canvasScale,r+it[lt+1].x*m2c2Globals.canvasScale,h+it[lt+1].y*m2c2Globals.canvasScale,O)}}return}if(this.strokeColor&&this.strokeColorPaintAntialiased&&this.lineWidth){this.strokeColorPaintAntialiased.setStrokeWidth(this.lineWidth*m2c2Globals.canvasScale);const c=this.path.subpaths;for(const S of c){const E=S.flat();for(let O=0;O<E.length-1;O++)t.drawLine(r+E[O].x*m2c2Globals.canvasScale,h+E[O].y*m2c2Globals.canvasScale,r+E[O+1].x*m2c2Globals.canvasScale,h+E[O+1].y*m2c2Globals.canvasScale,this.strokeColorPaintAntialiased)}}}drawPathFromSvgString(t){if(!this.ckPath)return;const i=this.calculateSvgPathX(),r=this.calculateSvgPathY();if(this.pathNeedsTransform(i,r)){const c=m2c2Globals.canvasScale/this.absoluteScale*this.svgPathScaleForResizing*m2c2Globals.rootScale,S=this.calculateTransformationMatrix(c,i,r);this.ckPath=this.ckPath.transform(S),this.saveSvgPathAbsolutePosition(i,r)}if(this.fillColor){const h=this.getFillPaint();t.drawPath(this.ckPath,h)}if(this.strokeColor&&this.lineWidth){const h=this.getStrokePaint(this.lineWidth);t.drawPath(this.ckPath,h)}}calculateSvgPathY(){const t=m2c2Globals.canvasScale/this.absoluteScale;return(this.absolutePosition.y-this.size.height*this.absoluteScale/2)*t}calculateSvgPathX(){const t=m2c2Globals.canvasScale/this.absoluteScale;return(this.absolutePosition.x-this.size.width*this.absoluteScale/2)*t}saveSvgPathAbsolutePosition(t,i){this.svgPreviousAbsoluteX=t,this.svgPreviousAbsoluteY=i}calculateTransformationMatrix(t,i,r){let h;this.svgFirstPathDraw?(h=t,this.svgFirstPathDraw=!1):h=1;const c=i-this.svgPreviousAbsoluteX,S=r-this.svgPreviousAbsoluteY;return[h,0,c,0,h,S,0,0,1]}pathNeedsTransform(t,i){return this.svgFirstPathDraw===!0||t!==this.svgPreviousAbsoluteX||i!==this.svgPreviousAbsoluteY}shapeIsSvgStringPath(){return this.path?.pathString!==void 0||this.path?.svgPathString!==void 0}shapeIsM2Path(){return this.path?.subpaths!==void 0}pathIsM2ColorfulPath(t){return t!==void 0&&"linePresentations"in t}drawCircle(t){if(this.circleOfRadius){if(this.fillColor){const i=this.getFillPaint();this.drawCircleWithCanvasKit(t,i)}if(this.strokeColor&&this.lineWidth){const i=this.getStrokePaint(this.lineWidth);this.drawCircleWithCanvasKit(t,i)}}}drawRectangle(t){if(this.fillColor){const i=this.getFillPaint();this.drawRectangleWithCanvasKit(t,i)}if(this.strokeColor&&this.lineWidth){const i=this.getStrokePaint(this.lineWidth);this.drawRectangleWithCanvasKit(t,i)}}drawCircleWithCanvasKit(t,i){if(!this.circleOfRadius)return;const r=m2c2Globals.canvasScale/this.absoluteScale,h=this.absolutePosition.x*r,c=this.absolutePosition.y*r,S=this.circleOfRadius*this.absoluteScale*r;t.drawCircle(h,c,S,i)}drawRectangleWithCanvasKit(t,i){const r=this.calculateCKRoundedRectangle();t.drawRRect(r,i)}calculateCKRoundedRectangle(){const t=m2c2Globals.canvasScale/this.absoluteScale;return this.canvasKit.RRectXY(this.canvasKit.LTRBRect((this.absolutePosition.x-this.anchorPoint.x*this.size.width*this.absoluteScale)*t,(this.absolutePosition.y-this.anchorPoint.y*this.size.height*this.absoluteScale)*t,(this.absolutePosition.x+this.size.width*this.absoluteScale-this.anchorPoint.x*this.size.width*this.absoluteScale)*t,(this.absolutePosition.y+this.size.height*this.absoluteScale-this.anchorPoint.y*this.size.height*this.absoluteScale)*t),this.cornerRadius*t,this.cornerRadius*t)}getFillPaint(){return this.involvedInActionAffectingAppearance()?this.fillColorPaintNotAntialiased:this.isAntialiased?this.fillColorPaintAntialiased:this.fillColorPaintNotAntialiased}getStrokePaint(t){let i;this.involvedInActionAffectingAppearance()?i=this.strokeColorPaintNotAntialiased:i=this.isAntialiased?this.strokeColorPaintAntialiased:this.strokeColorPaintNotAntialiased;const r=m2c2Globals.canvasScale/this.absoluteScale;return i.setStrokeWidth(t*r),i}warmup(t){this.initialize(),t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;t.scale(1/i,1/i),this.shapeType===Kt.Circle&&(this.fillColor&&this.warmupFilledCircle(t),this.strokeColor&&this.lineWidth&&this.warmupStrokedCircle(t)),this.shapeType===Kt.Rectangle&&(this.fillColor&&this.warmupFilledRectangle(t),this.strokeColor&&this.lineWidth&&this.warmupStrokedRectangle(t)),t.restore(),this.children.forEach(r=>{r.isDrawable&&r.warmup(t)})}warmupFilledCircle(t){this.circleOfRadius&&(this.drawCircleWithCanvasKit(t,this.fillColorPaintAntialiased),this.drawCircleWithCanvasKit(t,this.fillColorPaintNotAntialiased))}warmupStrokedCircle(t){if(!this.lineWidth||!this.circleOfRadius)return;const i=m2c2Globals.canvasScale/this.absoluteScale;this.strokeColorPaintAntialiased.setStrokeWidth(this.lineWidth*i),this.drawCircleWithCanvasKit(t,this.strokeColorPaintAntialiased),this.strokeColorPaintNotAntialiased.setStrokeWidth(this.lineWidth*i),this.drawCircleWithCanvasKit(t,this.strokeColorPaintNotAntialiased)}warmupFilledRectangle(t){this.drawRectangleWithCanvasKit(t,this.fillColorPaintAntialiased),this.drawRectangleWithCanvasKit(t,this.fillColorPaintNotAntialiased)}warmupStrokedRectangle(t){if(!this.lineWidth||!this.circleOfRadius)return;const i=m2c2Globals.canvasScale/this.absoluteScale;this.strokeColorPaintAntialiased.setStrokeWidth(this.lineWidth*i),this.drawRectangleWithCanvasKit(t,this.strokeColorPaintAntialiased),this.strokeColorPaintNotAntialiased.setStrokeWidth(this.lineWidth*i),this.drawRectangleWithCanvasKit(t,this.strokeColorPaintNotAntialiased)}get circleOfRadius(){return this._circleOfRadius}set circleOfRadius(t){V.value(t,this._circleOfRadius)||(this._circleOfRadius=t,this.needsInitialization=!0,this.savePropertyChangeEvent("circleOfRadius",t))}get rect(){return this._rect}set rect(t){V.value(t,this._rect)||(this._rect=t,this.needsInitialization=!0,this.savePropertyChangeEvent("rect",t))}get cornerRadius(){return this._cornerRadius}set cornerRadius(t){V.value(t,this._cornerRadius)||(this._cornerRadius=t??0,this.needsInitialization=!0,this.savePropertyChangeEvent("cornerRadius",t??0))}get lineWidth(){return this._lineWidth}set lineWidth(t){V.value(t,this._lineWidth)||(this._lineWidth=t,this.needsInitialization=!0,this.savePropertyChangeEvent("lineWidth",t))}get path(){return this._path}set path(t){V.value(t,this._path)||(this._path=t,this.needsInitialization=!0,this.savePropertyChangeEvent("path",t))}get fillColor(){return this._fillColor}set fillColor(t){V.value(t,this._fillColor)||(this._fillColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fillColor",t))}get strokeColor(){return this._strokeColor}set strokeColor(t){V.value(t,this._strokeColor)||(this._strokeColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("strokeColor",t))}get isAntialiased(){return this._isAntialiased}set isAntialiased(t){V.value(t,this._isAntialiased)||(this._isAntialiased=t,this.needsInitialization=!0,this.savePropertyChangeEvent("isAntialiased",t))}get fillColorPaintAntialiased(){if(!this._fillColorPaintAntialiased)throw new C("fillColorPaintAntiAliased is undefined");return this._fillColorPaintAntialiased}set fillColorPaintAntialiased(t){this._fillColorPaintAntialiased=t}get strokeColorPaintAntialiased(){if(!this._strokeColorPaintAntialiased)throw new C("strokeColorPaintAntiAliased is undefined");return this._strokeColorPaintAntialiased}set strokeColorPaintAntialiased(t){this._strokeColorPaintAntialiased=t}get fillColorPaintNotAntialiased(){if(!this._fillColorPaintNotAntialiased)throw new C("fillColorPaintNotAntiAliased is undefined");return this._fillColorPaintNotAntialiased}set fillColorPaintNotAntialiased(t){this._fillColorPaintNotAntialiased=t}get strokeColorPaintNotAntialiased(){if(!this._strokeColorPaintNotAntialiased)throw new C("strokeColorPaintNotAntiAliased is undefined");return this._strokeColorPaintNotAntialiased}set strokeColorPaintNotAntialiased(t){this._strokeColorPaintNotAntialiased=t}}class $i extends fe{constructor(t={}){super(t),this.type=dt.TextLine,this.isDrawable=!0,this.isText=!0,this._zPosition=0,this._anchorPoint={x:0,y:.5},this._text="",this._fontColor=Q.DEFAULT_FONT_COLOR,this._fontSize=Q.DEFAULT_FONT_SIZE,this._interpolation={},this._localize=!0,this.typeface=null,this.tryMissingTranslationPaint=!1,this.textForDraw="",this.localizedFontNames=[],Le(this,t),this.size.height=this.localizedFontSize??this.fontSize,this.size.width=t.width??NaN,this.saveNodeNewEvent()}get completeNodeOptions(){return{...this.options,...this.getNodeOptions(),...this.getDrawableOptions(),...this.getTextOptions(),width:this.size.width}}initialize(){const t=this.game.i18n;if(this.tryMissingTranslationPaint=!1,t&&this.localize!==!1){const r=t.getTextLocalization(this.text,this.interpolation);this.textForDraw=r.text,this.localizedFontSize=r.fontSize,this.localizedFontName=r.fontName,this.localizedFontNames=r.fontNames??[],r.isFallbackOrMissingTranslation&&(this.tryMissingTranslationPaint=!0)}else this.textForDraw=this.text;const i=this.game.fontManager;if(this.fontForDraw=this.getRequiredTextLineFont(i),this.fontForDraw.status===re.Deferred){i.prepareDeferredFont(this.fontForDraw);return}this.fontForDraw.status!==re.Loading&&(this.createFontPaint(t),this.createFont(i),this.needsInitialization=!1)}getRequiredTextLineFont(t){if(this.game.i18n){if(this.localizedFontName!==void 0&&this.localizedFontNames.length!==0||this.localizedFontNames.length>1)throw new C("TextLine supports only one font, but multiple fonts are specified in translation.");if(this.localizedFontName!==void 0)return t.fonts[this.localizedFontName];if(this.localizedFontNames.length==1)return t.fonts[this.localizedFontNames[0]]}return this.fontName===void 0?t.getDefaultFont():t.getFont(this.fontName)}createFontPaint(t){this.paint&&this.paint.delete(),this.paint=new this.canvasKit.Paint,this.tryMissingTranslationPaint&&this.localize!==!1?t?.missingLocalizationColor&&this.paint.setColor(this.canvasKit.Color(t.missingLocalizationColor[0],t.missingLocalizationColor[1],t.missingLocalizationColor[2],t.missingLocalizationColor[3])):this.paint.setColor(this.canvasKit.Color(this.fontColor[0],this.fontColor[1],this.fontColor[2],this.fontColor[3])),this.paint.setStyle(this.canvasKit.PaintStyle.Fill),this.paint.setAntiAlias(!0)}createFont(t){if(this.fontForDraw)this.typeface=t.getTypeface(this.fontForDraw.fontName);else{const i=t.getFontNames();i.length>0&&(this.typeface=t.getTypeface(i[0]))}this.font&&this.font.delete(),this.font=new this.canvasKit.Font(this.typeface,(this.localizedFontSize??this.fontSize)*m2c2Globals.canvasScale)}get text(){return this._text}set text(t){V.value(this._text,t)||(this._text=t,this.needsInitialization=!0,this.savePropertyChangeEvent("text",t))}get fontName(){return this._fontName}set fontName(t){V.value(this._fontName,t)||(this._fontName=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontName",t))}get fontColor(){return this._fontColor}set fontColor(t){V.value(this._fontColor,t)||(this._fontColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontColor",t))}get fontSize(){return this._fontSize}set fontSize(t){V.value(this._fontSize,t)||(this._fontSize=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontSize",t))}get interpolation(){return this._interpolation}set interpolation(t){V.value(this._interpolation,t)||(this._interpolation=t,Object.freeze(this._interpolation),this.needsInitialization=!0,this.savePropertyChangeEvent("interpolation",t))}get localize(){return this._localize}set localize(t){V.value(this._localize,t)||(this._localize=t,this.needsInitialization=!0,this.savePropertyChangeEvent("localize",t))}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){V.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){V.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){V.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){V.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}dispose(){Nt.Dispose([this.font,this.typeface,this.paint])}duplicate(t){const i=new $i({...this.getNodeOptions(),...this.getDrawableOptions(),...this.getTextOptions(),width:this.size.width,name:t});return this.children.length>0&&(i.children=this.children.map(r=>{const h=r.duplicate();return h.parent=i,h})),i}update(){super.update()}draw(t){if(this.parent&&this.text&&!this.needsInitialization){t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;t.scale(1/i,1/i),q.rotateCanvasForDrawableNode(t,this);const r=this.absolutePosition.x*i,h=(this.absolutePosition.y+this.size.height*this.anchorPoint.y*this.absoluteScale)*i;if(this.paint===void 0||this.font===void 0)throw new C(`in TextLine node ${this}, Paint or Font is undefined.`);this.absoluteAlphaChange!==0&&this.paint.setAlphaf(this.absoluteAlpha),t.drawText(this.textForDraw,r,h,this.paint,this.font),t.restore()}super.drawChildren(t)}warmup(t){const i=this.game.i18n;if(i&&this.localize!==!1){const h=i.getTextLocalization(this.text,this.interpolation);this.localizedFontName=h.fontName,this.localizedFontNames=h.fontNames??[]}if(this.getRequiredTextLineFont(this.game.fontManager).status!==re.Deferred){if(this.initialize(),this.paint===void 0||this.font===void 0)throw new C(`warmup TextLine node ${this.toString()}: Paint or Font is undefined.`);t.drawText(this.text,0,0,this.paint,this.font)}}}class pi extends fe{constructor(t={}){super(t),this.type=dt.Sprite,this.isDrawable=!0,this._anchorPoint={x:.5,y:.5},this._zPosition=0,this._imageName="",Le(this,t),t.imageName!==void 0&&(this.imageName=t.imageName),this.saveNodeNewEvent()}get completeNodeOptions(){return{...this.options,...this.getNodeOptions(),...this.getDrawableOptions(),imageName:this.imageName}}initialize(){if(this.m2Image=this.game.imageManager.getImage(this._imageName),!this.m2Image)throw new C(`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(){Nt.Dispose([this.m2Image?.canvaskitImage,this._paint])}get imageName(){return this._imageName}set imageName(t){V.value(this._imageName,t)||(this._imageName=t,this.needsInitialization=!0)}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){V.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){V.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){V.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){V.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}set paint(t){this._paint=t}get paint(){if(!this._paint)throw new C(`in paint getter: Sprite node ${this.toString()} paint is undefined.`);return this._paint}duplicate(t){const i=new pi({...this.getNodeOptions(),...this.getDrawableOptions(),imageName:this.imageName,name:t});return this.children.length>0&&(i.children=this.children.map(r=>{const h=r.duplicate();return h.parent=i,h})),i}update(){super.update()}draw(t){if(!this.hidden){if(this.m2Image){t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;t.scale(1/i,1/i),q.rotateCanvasForDrawableNode(t,this);const r=(this.absolutePosition.x-this.size.width*this.anchorPoint.x*this.absoluteScale)*i,h=(this.absolutePosition.y-this.size.height*this.anchorPoint.y*this.absoluteScale)*i;if(this.absoluteAlphaChange!==0&&this.paint.setAlphaf(this.absoluteAlpha),this.m2Image.status===ne.Ready&&this.m2Image.canvaskitImage)this.m2Image.isFallback&&this.drawFallbackImageBorder(t),t.drawImage(this.m2Image.canvaskitImage,r,h,this.paint);else if(this.m2Image.status===ne.Deferred&&(console.log(`begin loading lazy image ${this.m2Image.imageName} for Sprite node ${this.toString()}`),this.game.imageManager.prepareDeferredImage(this.m2Image)),this.m2Image.status===ne.Error)throw new C(`error status on image ${this.m2Image.imageName} for Sprite node ${this.toString()}`);t.restore()}super.drawChildren(t)}}warmup(t){if(this.m2Image?.status===ne.Ready){if(this.initialize(),!this.m2Image)throw new C(`in Sprite.warmup(): Sprite node ${this.toString()}: image not loaded.`);if(!this.m2Image.canvaskitImage)throw new C(`in Sprite.warmup(): Sprite node ${this.toString()} image ${this.m2Image.imageName} is undefined.`);t.drawImage(this.m2Image.canvaskitImage,0,0)}this.children.forEach(i=>{i.isDrawable&&i.warmup(t)})}drawFallbackImageBorder(t){const i=this.game.imageManager.missingLocalizationImagePaint;if(!i)return;const r=m2c2Globals.canvasScale/this.absoluteScale,h=this.canvasKit.RRectXY(this.canvasKit.LTRBRect((this.absolutePosition.x-this.anchorPoint.x*this.size.width*this.absoluteScale)*r,(this.absolutePosition.y-this.anchorPoint.y*this.size.height*this.absoluteScale)*r,(this.absolutePosition.x+this.size.width*this.absoluteScale-this.anchorPoint.x*this.size.width*this.absoluteScale)*r,(this.absolutePosition.y+this.size.height*this.absoluteScale-this.anchorPoint.y*this.size.height*this.absoluteScale)*r),0,0);t.drawRRect(h,i)}}class Gr{constructor(){q.registerM2NodeClass(Ui,fi,pi,Ve,$i)}createNode(t,i,r){const h=i||t;if(!this.hasClassRegistration(h))throw new C(`Unknown node type: ${h}`);if(!m2c2Globals.m2NodeClassRegistry)throw new C("Node class registry is not initialized.");const c=m2c2Globals.m2NodeClassRegistry[h];return new c(r)}hasClassRegistration(t){return Object.keys(m2c2Globals.m2NodeClassRegistry??{}).includes(t)}}class pa{static rgbaColor(t,i){return!t||!i?!1:t[0]===i[0]&&t[1]===i[1]&&t[2]===i[2]&&t[3]===i[3]}}class Wr{constructor(t,i){this.fonts={},this.game=t,this.baseUrls=i,this.canvasKit=t.canvasKit,this.provider=this.canvasKit.TypefaceFontProvider.Make()}initializeFonts(t){return this.loadFonts(t??[])}async loadFonts(t){if(t.length===0)return;const i=t.map((r,h)=>{let c=r.url;q.urlHasScheme(r.url)||(c=q.getUrlFromManifest(this.game,`${this.baseUrls.assets}/${r.url}`));const S={fontName:r.fontName,typeface:void 0,data:r.sharedFont?.data,default:h===0,url:r.sharedFont?.url??c,status:r.lazy?re.Deferred:re.Loading};if(this.fonts[r.fontName]=S,S.status===re.Loading)return this.prepareFont(S)});await Promise.all(i)}async prepareFont(t){const i=t.data??await this.fetchFontAsArrayBuffer(t);this.registerFont(i,t),console.log(`\u26AA font ${t.fontName}${t.default?" (default)":""} loaded for game ${this.game.id} from ${t.url}`)}async prepareDeferredFont(t){return t.status=re.Loading,this.prepareFont(t)}async fetchFontAsArrayBuffer(t){const i=await fetch(t.url);if(!i.ok)throw new C(`cannot fetch font ${t.fontName} at url ${t.url}: ${i.statusText}`);return await i.arrayBuffer()}registerFont(t,i){this.provider.registerFont(t,i.fontName);const r=this.canvasKit.Typeface.MakeFreeTypeFaceFromData(t);if(!r)throw new C(`cannot make typeface for font ${i.fontName} at url ${i.url}`);i.typeface=r,i.status=re.Ready}getFont(t){return this.fonts[t]}getDefaultFont(){const t=Object.values(this.fonts).find(i=>i.default);if(!t)throw new C("no default font found; please make sure at least one font is loaded");return t}dispose(){const t=Object.entries(this.fonts).map(([,i])=>i.typeface);Nt.Dispose([...t,this.provider])}getTypeface(t){const i=this.fonts[t]?.typeface;if(!i)throw new C(`font ${t} not found`);return i}getFontNames(){return Object.keys(this.fonts)}}var gn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ga(m){return m&&m.__esModule&&Object.prototype.hasOwnProperty.call(m,"default")?m.default:m}function jr(m){if(Object.prototype.hasOwnProperty.call(m,"__esModule"))return m;var t=m.default;if(typeof t=="function"){var i=function r(){var h=!1;try{h=this instanceof r}catch{}return h?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};i.prototype=t.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(m).forEach(function(r){var h=Object.getOwnPropertyDescriptor(m,r);Object.defineProperty(i,r,h.get?h:{enumerable:!0,get:function(){return m[r]}})}),i}var mn={exports:{}},ma={},ya=Object.freeze({__proto__:null,default:ma}),va=jr(ya);function Hr(m,t){for(var i=0,r=m.length-1;r>=0;r--){var h=m[r];h==="."?m.splice(r,1):h===".."?(m.splice(r,1),i++):i&&(m.splice(r,1),i--)}if(t)for(;i--;i)m.unshift("..");return m}var wa=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,yn=function(m){return wa.exec(m).slice(1)};function Li(){for(var m="",t=!1,i=arguments.length-1;i>=-1&&!t;i--){var r=i>=0?arguments[i]:"/";if(typeof r!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!r)continue;m=r+"/"+m,t=r.charAt(0)==="/"}return m=Hr(Sn(m.split("/"),function(h){return!!h}),!t).join("/"),(t?"/":"")+m||"."}function vn(m){var t=wn(m),i=ba(m,-1)==="/";return m=Hr(Sn(m.split("/"),function(r){return!!r}),!t).join("/"),!m&&!t&&(m="."),m&&i&&(m+="/"),(t?"/":"")+m}function wn(m){return m.charAt(0)==="/"}function Kr(){var m=Array.prototype.slice.call(arguments,0);return vn(Sn(m,function(t,i){if(typeof t!="string")throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))}function Vr(m,t){m=Li(m).substr(1),t=Li(t).substr(1);function i(G){for(var K=0;K<G.length&&G[K]==="";K++);for(var it=G.length-1;it>=0&&G[it]==="";it--);return K>it?[]:G.slice(K,it-K+1)}for(var r=i(m.split("/")),h=i(t.split("/")),c=Math.min(r.length,h.length),S=c,E=0;E<c;E++)if(r[E]!==h[E]){S=E;break}for(var O=[],E=S;E<r.length;E++)O.push("..");return O=O.concat(h.slice(S)),O.join("/")}var qr="/",Yr=":";function Xr(m){var t=yn(m),i=t[0],r=t[1];return!i&&!r?".":(r&&(r=r.substr(0,r.length-1)),i+r)}function Jr(m,t){var i=yn(m)[2];return t&&i.substr(-1*t.length)===t&&(i=i.substr(0,i.length-t.length)),i}function Qr(m){return yn(m)[3]}var Sa={extname:Qr,basename:Jr,dirname:Xr,sep:qr,delimiter:Yr,relative:Vr,join:Kr,isAbsolute:wn,normalize:vn,resolve:Li};function Sn(m,t){if(m.filter)return m.filter(t);for(var i=[],r=0;r<m.length;r++)t(m[r],r,m)&&i.push(m[r]);return i}var ba="ab".substr(-1)==="b"?function(m,t,i){return m.substr(t,i)}:function(m,t,i){return t<0&&(t=m.length+t),m.substr(t,i)},Pa=Object.freeze({__proto__:null,basename:Jr,default:Sa,delimiter:Yr,dirname:Xr,extname:Qr,isAbsolute:wn,join:Kr,normalize:vn,relative:Vr,resolve:Li,sep:qr}),Aa=jr(Pa),Zr;function Ca(){return Zr||(Zr=1,function(m,t){var i=(()=>{var r=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<"u"&&(r=r||__filename),function(h={}){var c=h,S,E;c.ready=new Promise((e,n)=>{S=e,E=n}),function(e){e.ke=e.ke||[],e.ke.push(function(){e.MakeSWCanvasSurface=function(n){var s=n,l=typeof OffscreenCanvas<"u"&&s instanceof OffscreenCanvas;if(!(typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||l||(s=document.getElementById(n),s)))throw"Canvas with id "+n+" was not found";return(n=e.MakeSurface(s.width,s.height))&&(n.ce=s),n},e.MakeCanvasSurface||(e.MakeCanvasSurface=e.MakeSWCanvasSurface),e.MakeSurface=function(n,s){var l={width:n,height:s,colorType:e.ColorType.RGBA_8888,alphaType:e.AlphaType.Unpremul,colorSpace:e.ColorSpace.SRGB},d=n*s*4,g=e._malloc(d);return(l=e.Surface._makeRasterDirect(l,g,4*n))&&(l.ce=null,l.Xf=n,l.Tf=s,l.Vf=d,l.wf=g,l.getCanvas().clear(e.TRANSPARENT)),l},e.MakeRasterDirectSurface=function(n,s,l){return e.Surface._makeRasterDirect(n,s.byteOffset,l)},e.Surface.prototype.flush=function(n){if(e.de(this.be),this._flush(),this.ce){var s=new Uint8ClampedArray(e.HEAPU8.buffer,this.wf,this.Vf);s=new ImageData(s,this.Xf,this.Tf),n?this.ce.getContext("2d").putImageData(s,0,0,n[0],n[1],n[2]-n[0],n[3]-n[1]):this.ce.getContext("2d").putImageData(s,0,0)}},e.Surface.prototype.dispose=function(){this.wf&&e._free(this.wf),this.delete()},e.de=e.de||function(){},e.mf=e.mf||function(){return null}})}(c),function(e){e.ke=e.ke||[],e.ke.push(function(){function n(y,v,T){return y&&y.hasOwnProperty(v)?y[v]:T}function s(y){var v=Ne(ee);return ee[v]=y,v}function l(y){return y.naturalHeight||y.videoHeight||y.displayHeight||y.height}function d(y){return y.naturalWidth||y.videoWidth||y.displayWidth||y.width}function g(y,v,T,D){return y.bindTexture(y.TEXTURE_2D,v),D||T.alphaType!==e.AlphaType.Premul||y.pixelStorei(y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),v}function A(y,v,T){T||v.alphaType!==e.AlphaType.Premul||y.pixelStorei(y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),y.bindTexture(y.TEXTURE_2D,null)}e.GetWebGLContext=function(y,v){if(!y)throw"null canvas passed into makeWebGLContext";var T={alpha:n(v,"alpha",1),depth:n(v,"depth",1),stencil:n(v,"stencil",8),antialias:n(v,"antialias",0),premultipliedAlpha:n(v,"premultipliedAlpha",1),preserveDrawingBuffer:n(v,"preserveDrawingBuffer",0),preferLowPowerToHighPerformance:n(v,"preferLowPowerToHighPerformance",0),failIfMajorPerformanceCaveat:n(v,"failIfMajorPerformanceCaveat",0),enableExtensionsByDefault:n(v,"enableExtensionsByDefault",1),explicitSwapControl:n(v,"explicitSwapControl",0),renderViaOffscreenBackBuffer:n(v,"renderViaOffscreenBackBuffer",0)};if(T.majorVersion=v&&v.majorVersion?v.majorVersion:typeof WebGL2RenderingContext<"u"?2:1,T.explicitSwapControl)throw"explicitSwapControl is not supported";return y=Is(y,T),y?(tr(y),at.xe.getExtension("WEBGL_debug_renderer_info"),y):0},e.deleteContext=function(y){at===ye[y]&&(at=null),typeof JSEvents=="object"&&JSEvents.Mg(ye[y].xe.canvas),ye[y]&&ye[y].xe.canvas&&(ye[y].xe.canvas.Rf=void 0),ye[y]=null},e._setTextureCleanup({deleteTexture:function(y,v){var T=ee[v];T&&ye[y].xe.deleteTexture(T),ee[v]=null}}),e.MakeWebGLContext=function(y){if(!this.de(y))return null;var v=this._MakeGrContext();if(!v)return null;v.be=y;var T=v.delete.bind(v);return v.delete=function(){e.de(this.be),T()}.bind(v),at.Af=v},e.MakeGrContext=e.MakeWebGLContext,e.GrDirectContext.prototype.getResourceCacheLimitBytes=function(){e.de(this.be),this._getResourceCacheLimitBytes()},e.GrDirectContext.prototype.getResourceCacheUsageBytes=function(){e.de(this.be),this._getResourceCacheUsageBytes()},e.GrDirectContext.prototype.releaseResourcesAndAbandonContext=function(){e.de(this.be),this._releaseResourcesAndAbandonContext()},e.GrDirectContext.prototype.setResourceCacheLimitBytes=function(y){e.de(this.be),this._setResourceCacheLimitBytes(y)},e.MakeOnScreenGLSurface=function(y,v,T,D,L,Y){return!this.de(y.be)||(v=L===void 0||Y===void 0?this._MakeOnScreenGLSurface(y,v,T,D):this._MakeOnScreenGLSurface(y,v,T,D,L,Y),!v)?null:(v.be=y.be,v)},e.MakeRenderTarget=function(){var y=arguments[0];if(!this.de(y.be))return null;if(arguments.length===3){var v=this._MakeRenderTargetWH(y,arguments[1],arguments[2]);if(!v)return null}else if(arguments.length===2){if(v=this._MakeRenderTargetII(y,arguments[1]),!v)return null}else return null;return v.be=y.be,v},e.MakeWebGLCanvasSurface=function(y,v,T){v=v||null;var D=y,L=typeof OffscreenCanvas<"u"&&D instanceof OffscreenCanvas;if(!(typeof HTMLCanvasElement<"u"&&D instanceof HTMLCanvasElement||L||(D=document.getElementById(y),D)))throw"Canvas with id "+y+" was not found";if(y=this.GetWebGLContext(D,T),!y||0>y)throw"failed to create webgl context: err "+y;return y=this.MakeWebGLContext(y),v=this.MakeOnScreenGLSurface(y,D.width,D.height,v),v||(v=D.cloneNode(!0),D.parentNode.replaceChild(v,D),v.classList.add("ck-replaced"),e.MakeSWCanvasSurface(v))},e.MakeCanvasSurface=e.MakeWebGLCanvasSurface,e.Surface.prototype.makeImageFromTexture=function(y,v){return e.de(this.be),y=s(y),(v=this._makeImageFromTexture(this.be,y,v))&&(v.cf=y),v},e.Surface.prototype.makeImageFromTextureSource=function(y,v,T){v||(v={height:l(y),width:d(y),colorType:e.ColorType.RGBA_8888,alphaType:T?e.AlphaType.Premul:e.AlphaType.Unpremul}),v.colorSpace||(v.colorSpace=e.ColorSpace.SRGB),e.de(this.be);var D=at.xe;return T=g(D,D.createTexture(),v,T),at.version===2?D.texImage2D(D.TEXTURE_2D,0,D.RGBA,v.width,v.height,0,D.RGBA,D.UNSIGNED_BYTE,y):D.texImage2D(D.TEXTURE_2D,0,D.RGBA,D.RGBA,D.UNSIGNED_BYTE,y),A(D,v),this._resetContext(),this.makeImageFromTexture(T,v)},e.Surface.prototype.updateTextureFromSource=function(y,v,T){if(y.cf){e.de(this.be);var D=y.getImageInfo(),L=at.xe,Y=g(L,ee[y.cf],D,T);at.version===2?L.texImage2D(L.TEXTURE_2D,0,L.RGBA,d(v),l(v),0,L.RGBA,L.UNSIGNED_BYTE,v):L.texImage2D(L.TEXTURE_2D,0,L.RGBA,L.RGBA,L.UNSIGNED_BYTE,v),A(L,D,T),this._resetContext(),ee[y.cf]=null,y.cf=s(Y),D.colorSpace=y.getColorSpace(),v=this._makeImageFromTexture(this.be,y.cf,D),T=y.ae.ie,L=y.ae.pe,y.ae.ie=v.ae.ie,y.ae.pe=v.ae.pe,v.ae.ie=T,v.ae.pe=L,v.delete(),D.colorSpace.delete()}},e.MakeLazyImageFromTextureSource=function(y,v,T){v||(v={height:l(y),width:d(y),colorType:e.ColorType.RGBA_8888,alphaType:T?e.AlphaType.Premul:e.AlphaType.Unpremul}),v.colorSpace||(v.colorSpace=e.ColorSpace.SRGB);var D={makeTexture:function(){var L=at,Y=L.xe,F=g(Y,Y.createTexture(),v,T);return L.version===2?Y.texImage2D(Y.TEXTURE_2D,0,Y.RGBA,v.width,v.height,0,Y.RGBA,Y.UNSIGNED_BYTE,y):Y.texImage2D(Y.TEXTURE_2D,0,Y.RGBA,Y.RGBA,Y.UNSIGNED_BYTE,y),A(Y,v,T),s(F)},freeSrc:function(){}};return y.constructor.name==="VideoFrame"&&(D.freeSrc=function(){y.close()}),e.Image._makeFromGenerator(v,D)},e.de=function(y){return y?tr(y):!1},e.mf=function(){return at&&at.Af&&!at.Af.isDeleted()?at.Af:null}})}(c),function(e){function n(o,a,u,p,P){for(var x=0;x<o.length;x++)a[x*u+(x*P+p+u)%u]=o[x];return a}function s(o){for(var a=o*o,u=Array(a);a--;)u[a]=a%(o+1)===0?1:0;return u}function l(o){return o?o.constructor===Float32Array&&o.length===4:!1}function d(o){return(y(255*o[3])<<24|y(255*o[0])<<16|y(255*o[1])<<8|y(255*o[2])<<0)>>>0}function g(o){if(o&&o._ck)return o;if(o instanceof Float32Array){for(var a=Math.floor(o.length/4),u=new Uint32Array(a),p=0;p<a;p++)u[p]=d(o.slice(4*p,4*(p+1)));return u}if(o instanceof Uint32Array)return o;if(o instanceof Array&&o[0]instanceof Float32Array)return o.map(d)}function A(o){if(o===void 0)return 1;var a=parseFloat(o);return o&&o.indexOf("%")!==-1?a/100:a}function y(o){return Math.round(Math.max(0,Math.min(o||0,255)))}function v(o,a){a&&a._ck||e._free(o)}function T(o,a,u){if(!o||!o.length)return gt;if(o&&o._ck)return o.byteOffset;var p=e[a].BYTES_PER_ELEMENT;return u||(u=e._malloc(o.length*p)),e[a].set(o,u/p),u}function D(o){var a={te:gt,count:o.length,colorType:e.ColorType.RGBA_F32};if(o instanceof Float32Array)a.te=T(o,"HEAPF32"),a.count=o.length/4;else if(o instanceof Uint32Array)a.te=T(o,"HEAPU32"),a.colorType=e.ColorType.RGBA_8888;else if(o instanceof Array){if(o&&o.length){for(var u=e._malloc(16*o.length),p=0,P=u/4,x=0;x<o.length;x++)for(var N=0;4>N;N++)e.HEAPF32[P+p]=o[x][N],p++;o=u}else o=gt;a.te=o}else throw"Invalid argument to copyFlexibleColorArray, Not a color array "+typeof o;return a}function L(o){if(!o)return gt;var a=rn.toTypedArray();if(o.length){if(o.length===6||o.length===9)return T(o,"HEAPF32",_e),o.length===6&&e.HEAPF32.set(aa,6+_e/4),_e;if(o.length===16)return a[0]=o[0],a[1]=o[1],a[2]=o[3],a[3]=o[4],a[4]=o[5],a[5]=o[7],a[6]=o[12],a[7]=o[13],a[8]=o[15],_e;throw"invalid matrix size"}if(o.m11===void 0)throw"invalid matrix argument";return a[0]=o.m11,a[1]=o.m21,a[2]=o.m41,a[3]=o.m12,a[4]=o.m22,a[5]=o.m42,a[6]=o.m14,a[7]=o.m24,a[8]=o.m44,_e}function Y(o){if(!o)return gt;var a=sn.toTypedArray();if(o.length){if(o.length!==16&&o.length!==6&&o.length!==9)throw"invalid matrix size";return o.length===16?T(o,"HEAPF32",We):(a.fill(0),a[0]=o[0],a[1]=o[1],a[3]=o[2],a[4]=o[3],a[5]=o[4],a[7]=o[5],a[10]=1,a[12]=o[6],a[13]=o[7],a[15]=o[8],o.length===6&&(a[12]=0,a[13]=0,a[15]=1),We)}if(o.m11===void 0)throw"invalid matrix argument";return a[0]=o.m11,a[1]=o.m21,a[2]=o.m31,a[3]=o.m41,a[4]=o.m12,a[5]=o.m22,a[6]=o.m32,a[7]=o.m42,a[8]=o.m13,a[9]=o.m23,a[10]=o.m33,a[11]=o.m43,a[12]=o.m14,a[13]=o.m24,a[14]=o.m34,a[15]=o.m44,We}function F(o,a){return T(o,"HEAPF32",a||Oe)}function J(o,a,u,p){var P=an.toTypedArray();return P[0]=o,P[1]=a,P[2]=u,P[3]=p,Oe}function ht(o){for(var a=new Float32Array(4),u=0;4>u;u++)a[u]=e.HEAPF32[o/4+u];return a}function ot(o,a){return T(o,"HEAPF32",a||Rt)}function Ht(o,a){return T(o,"HEAPF32",a||hn)}function Lt(){for(var o=0,a=0;a<arguments.length-1;a+=2)o+=arguments[a]*arguments[a+1];return o}function ai(o,a,u){for(var p=Array(o.length),P=0;P<u;P++)for(var x=0;x<u;x++){for(var N=0,j=0;j<u;j++)N+=o[u*P+j]*a[u*j+x];p[P*u+x]=N}return p}function oi(o,a){for(var u=ai(a[0],a[1],o),p=2;p<a.length;)u=ai(u,a[p],o),p++;return u}e.Color=function(o,a,u,p){return p===void 0&&(p=1),e.Color4f(y(o)/255,y(a)/255,y(u)/255,p)},e.ColorAsInt=function(o,a,u,p){return p===void 0&&(p=255),(y(p)<<24|y(o)<<16|y(a)<<8|y(u)<<0&268435455)>>>0},e.Color4f=function(o,a,u,p){return p===void 0&&(p=1),Float32Array.of(o,a,u,p)},Object.defineProperty(e,"TRANSPARENT",{get:function(){return e.Color4f(0,0,0,0)}}),Object.defineProperty(e,"BLACK",{get:function(){return e.Color4f(0,0,0,1)}}),Object.defineProperty(e,"WHITE",{get:function(){return e.Color4f(1,1,1,1)}}),Object.defineProperty(e,"RED",{get:function(){return e.Color4f(1,0,0,1)}}),Object.defineProperty(e,"GREEN",{get:function(){return e.Color4f(0,1,0,1)}}),Object.defineProperty(e,"BLUE",{get:function(){return e.Color4f(0,0,1,1)}}),Object.defineProperty(e,"YELLOW",{get:function(){return e.Color4f(1,1,0,1)}}),Object.defineProperty(e,"CYAN",{get:function(){return e.Color4f(0,1,1,1)}}),Object.defineProperty(e,"MAGENTA",{get:function(){return e.Color4f(1,0,1,1)}}),e.getColorComponents=function(o){return[Math.floor(255*o[0]),Math.floor(255*o[1]),Math.floor(255*o[2]),o[3]]},e.parseColorString=function(o,a){if(o=o.toLowerCase(),o.startsWith("#")){switch(a=255,o.length){case 9:a=parseInt(o.slice(7,9),16);case 7:var u=parseInt(o.slice(1,3),16),p=parseInt(o.slice(3,5),16),P=parseInt(o.slice(5,7),16);break;case 5:a=17*parseInt(o.slice(4,5),16);case 4:u=17*parseInt(o.slice(1,2),16),p=17*parseInt(o.slice(2,3),16),P=17*parseInt(o.slice(3,4),16)}return e.Color(u,p,P,a/255)}return o.startsWith("rgba")?(o=o.slice(5,-1),o=o.split(","),e.Color(+o[0],+o[1],+o[2],A(o[3]))):o.startsWith("rgb")?(o=o.slice(4,-1),o=o.split(","),e.Color(+o[0],+o[1],+o[2],A(o[3]))):o.startsWith("gray(")||o.startsWith("hsl")||!a||(o=a[o],o===void 0)?e.BLACK:o},e.multiplyByAlpha=function(o,a){return o=o.slice(),o[3]=Math.max(0,Math.min(o[3]*a,1)),o},e.Malloc=function(o,a){var u=e._malloc(a*o.BYTES_PER_ELEMENT);return{_ck:!0,length:a,byteOffset:u,Je:null,subarray:function(p,P){return p=this.toTypedArray().subarray(p,P),p._ck=!0,p},toTypedArray:function(){return this.Je&&this.Je.length?this.Je:(this.Je=new o(e.HEAPU8.buffer,u,a),this.Je._ck=!0,this.Je)}}},e.Free=function(o){e._free(o.byteOffset),o.byteOffset=gt,o.toTypedArray=null,o.Je=null};var _e=gt,rn,We=gt,sn,Oe=gt,an,ue,Rt=gt,Pr,Ee=gt,Ar,on=gt,Cr,ln=gt,Oi,li=gt,Tr,hn=gt,_r,Er=gt,aa=Float32Array.of(0,0,1),gt=0;e.onRuntimeInitialized=function(){function o(a,u,p,P,x,N,j){N||(N=4*P.width,P.colorType===e.ColorType.RGBA_F16?N*=2:P.colorType===e.ColorType.RGBA_F32&&(N*=4));var tt=N*P.height,et=x?x.byteOffset:e._malloc(tt);if(j?!a._readPixels(P,et,N,u,p,j):!a._readPixels(P,et,N,u,p))return x||e._free(et),null;if(x)return x.toTypedArray();switch(P.colorType){case e.ColorType.RGBA_8888:case e.ColorType.RGBA_F16:a=new Uint8Array(e.HEAPU8.buffer,et,tt).slice();break;case e.ColorType.RGBA_F32:a=new Float32Array(e.HEAPU8.buffer,et,tt).slice();break;default:return null}return e._free(et),a}an=e.Malloc(Float32Array,4),Oe=an.byteOffset,sn=e.Malloc(Float32Array,16),We=sn.byteOffset,rn=e.Malloc(Float32Array,9),_e=rn.byteOffset,Tr=e.Malloc(Float32Array,12),hn=Tr.byteOffset,_r=e.Malloc(Float32Array,12),Er=_r.byteOffset,ue=e.Malloc(Float32Array,4),Rt=ue.byteOffset,Pr=e.Malloc(Float32Array,4),Ee=Pr.byteOffset,Ar=e.Malloc(Float32Array,3),on=Ar.byteOffset,Cr=e.Malloc(Float32Array,3),ln=Cr.byteOffset,Oi=e.Malloc(Int32Array,4),li=Oi.byteOffset,e.ColorSpace.SRGB=e.ColorSpace._MakeSRGB(),e.ColorSpace.DISPLAY_P3=e.ColorSpace._MakeDisplayP3(),e.ColorSpace.ADOBE_RGB=e.ColorSpace._MakeAdobeRGB(),e.GlyphRunFlags={IsWhiteSpace:e._GlyphRunFlags_isWhiteSpace},e.Path.MakeFromCmds=function(a){var u=T(a,"HEAPF32"),p=e.Path._MakeFromCmds(u,a.length);return v(u,a),p},e.Path.MakeFromVerbsPointsWeights=function(a,u,p){var P=T(a,"HEAPU8"),x=T(u,"HEAPF32"),N=T(p,"HEAPF32"),j=e.Path._MakeFromVerbsPointsWeights(P,a.length,x,u.length,N,p&&p.length||0);return v(P,a),v(x,u),v(N,p),j},e.Path.prototype.addArc=function(a,u,p){return a=ot(a),this._addArc(a,u,p),this},e.Path.prototype.addCircle=function(a,u,p,P){return this._addCircle(a,u,p,!!P),this},e.Path.prototype.addOval=function(a,u,p){return p===void 0&&(p=1),a=ot(a),this._addOval(a,!!u,p),this},e.Path.prototype.addPath=function(){var a=Array.prototype.slice.call(arguments),u=a[0],p=!1;if(typeof a[a.length-1]=="boolean"&&(p=a.pop()),a.length===1)this._addPath(u,1,0,0,0,1,0,0,0,1,p);else if(a.length===2)a=a[1],this._addPath(u,a[0],a[1],a[2],a[3],a[4],a[5],a[6]||0,a[7]||0,a[8]||1,p);else if(a.length===7||a.length===10)this._addPath(u,a[1],a[2],a[3],a[4],a[5],a[6],a[7]||0,a[8]||0,a[9]||1,p);else return null;return this},e.Path.prototype.addPoly=function(a,u){var p=T(a,"HEAPF32");return this._addPoly(p,a.length/2,u),v(p,a),this},e.Path.prototype.addRect=function(a,u){return a=ot(a),this._addRect(a,!!u),this},e.Path.prototype.addRRect=function(a,u){return a=Ht(a),this._addRRect(a,!!u),this},e.Path.prototype.addVerbsPointsWeights=function(a,u,p){var P=T(a,"HEAPU8"),x=T(u,"HEAPF32"),N=T(p,"HEAPF32");this._addVerbsPointsWeights(P,a.length,x,u.length,N,p&&p.length||0),v(P,a),v(x,u),v(N,p)},e.Path.prototype.arc=function(a,u,p,P,x,N){return a=e.LTRBRect(a-p,u-p,a+p,u+p),x=(x-P)/Math.PI*180-360*!!N,N=new e.Path,N.addArc(a,P/Math.PI*180,x),this.addPath(N,!0),N.delete(),this},e.Path.prototype.arcToOval=function(a,u,p,P){return a=ot(a),this._arcToOval(a,u,p,P),this},e.Path.prototype.arcToRotated=function(a,u,p,P,x,N,j){return this._arcToRotated(a,u,p,!!P,!!x,N,j),this},e.Path.prototype.arcToTangent=function(a,u,p,P,x){return this._arcToTangent(a,u,p,P,x),this},e.Path.prototype.close=function(){return this._close(),this},e.Path.prototype.conicTo=function(a,u,p,P,x){return this._conicTo(a,u,p,P,x),this},e.Path.prototype.computeTightBounds=function(a){this._computeTightBounds(Rt);var u=ue.toTypedArray();return a?(a.set(u),a):u.slice()},e.Path.prototype.cubicTo=function(a,u,p,P,x,N){return this._cubicTo(a,u,p,P,x,N),this},e.Path.prototype.dash=function(a,u,p){return this._dash(a,u,p)?this:null},e.Path.prototype.getBounds=function(a){this._getBounds(Rt);var u=ue.toTypedArray();return a?(a.set(u),a):u.slice()},e.Path.prototype.lineTo=function(a,u){return this._lineTo(a,u),this},e.Path.prototype.moveTo=function(a,u){return this._moveTo(a,u),this},e.Path.prototype.offset=function(a,u){return this._transform(1,0,a,0,1,u,0,0,1),this},e.Path.prototype.quadTo=function(a,u,p,P){return this._quadTo(a,u,p,P),this},e.Path.prototype.rArcTo=function(a,u,p,P,x,N,j){return this._rArcTo(a,u,p,P,x,N,j),this},e.Path.prototype.rConicTo=function(a,u,p,P,x){return this._rConicTo(a,u,p,P,x),this},e.Path.prototype.rCubicTo=function(a,u,p,P,x,N){return this._rCubicTo(a,u,p,P,x,N),this},e.Path.prototype.rLineTo=function(a,u){return this._rLineTo(a,u),this},e.Path.prototype.rMoveTo=function(a,u){return this._rMoveTo(a,u),this},e.Path.prototype.rQuadTo=function(a,u,p,P){return this._rQuadTo(a,u,p,P),this},e.Path.prototype.stroke=function(a){return a=a||{},a.width=a.width||1,a.miter_limit=a.miter_limit||4,a.cap=a.cap||e.StrokeCap.Butt,a.join=a.join||e.StrokeJoin.Miter,a.precision=a.precision||1,this._stroke(a)?this:null},e.Path.prototype.transform=function(){if(arguments.length===1){var a=arguments[0];this._transform(a[0],a[1],a[2],a[3],a[4],a[5],a[6]||0,a[7]||0,a[8]||1)}else if(arguments.length===6||arguments.length===9)a=arguments,this._transform(a[0],a[1],a[2],a[3],a[4],a[5],a[6]||0,a[7]||0,a[8]||1);else throw"transform expected to take 1 or 9 arguments. Got "+arguments.length;return this},e.Path.prototype.trim=function(a,u,p){return this._trim(a,u,!!p)?this:null},e.Image.prototype.encodeToBytes=function(a,u){var p=e.mf();return a=a||e.ImageFormat.PNG,u=u||100,p?this._encodeToBytes(a,u,p):this._encodeToBytes(a,u)},e.Image.prototype.makeShaderCubic=function(a,u,p,P,x){return x=L(x),this._makeShaderCubic(a,u,p,P,x)},e.Image.prototype.makeShaderOptions=function(a,u,p,P,x){return x=L(x),this._makeShaderOptions(a,u,p,P,x)},e.Image.prototype.readPixels=function(a,u,p,P,x){var N=e.mf();return o(this,a,u,p,P,x,N)},e.Canvas.prototype.clear=function(a){e.de(this.be),a=F(a),this._clear(a)},e.Canvas.prototype.clipRRect=function(a,u,p){e.de(this.be),a=Ht(a),this._clipRRect(a,u,p)},e.Canvas.prototype.clipRect=function(a,u,p){e.de(this.be),a=ot(a),this._clipRect(a,u,p)},e.Canvas.prototype.concat=function(a){e.de(this.be),a=Y(a),this._concat(a)},e.Canvas.prototype.drawArc=function(a,u,p,P,x){e.de(this.be),a=ot(a),this._drawArc(a,u,p,P,x)},e.Canvas.prototype.drawAtlas=function(a,u,p,P,x,N,j){if(a&&P&&u&&p&&u.length===p.length){e.de(this.be),x||(x=e.BlendMode.SrcOver);var tt=T(u,"HEAPF32"),et=T(p,"HEAPF32"),vt=p.length/4,bt=T(g(N),"HEAPU32");if(j&&"B"in j&&"C"in j)this._drawAtlasCubic(a,et,tt,bt,vt,x,j.B,j.C,P);else{let b=e.FilterMode.Linear,I=e.MipmapMode.None;j&&(b=j.filter,"mipmap"in j&&(I=j.mipmap)),this._drawAtlasOptions(a,et,tt,bt,vt,x,b,I,P)}v(tt,u),v(et,p),v(bt,N)}},e.Canvas.prototype.drawCircle=function(a,u,p,P){e.de(this.be),this._drawCircle(a,u,p,P)},e.Canvas.prototype.drawColor=function(a,u){e.de(this.be),a=F(a),u!==void 0?this._drawColor(a,u):this._drawColor(a)},e.Canvas.prototype.drawColorInt=function(a,u){e.de(this.be),this._drawColorInt(a,u||e.BlendMode.SrcOver)},e.Canvas.prototype.drawColorComponents=function(a,u,p,P,x){e.de(this.be),a=J(a,u,p,P),x!==void 0?this._drawColor(a,x):this._drawColor(a)},e.Canvas.prototype.drawDRRect=function(a,u,p){e.de(this.be),a=Ht(a,hn),u=Ht(u,Er),this._drawDRRect(a,u,p)},e.Canvas.prototype.drawImage=function(a,u,p,P){e.de(this.be),this._drawImage(a,u,p,P||null)},e.Canvas.prototype.drawImageCubic=function(a,u,p,P,x,N){e.de(this.be),this._drawImageCubic(a,u,p,P,x,N||null)},e.Canvas.prototype.drawImageOptions=function(a,u,p,P,x,N){e.de(this.be),this._drawImageOptions(a,u,p,P,x,N||null)},e.Canvas.prototype.drawImageNine=function(a,u,p,P,x){e.de(this.be),u=T(u,"HEAP32",li),p=ot(p),this._drawImageNine(a,u,p,P,x||null)},e.Canvas.prototype.drawImageRect=function(a,u,p,P,x){e.de(this.be),ot(u,Rt),ot(p,Ee),this._drawImageRect(a,Rt,Ee,P,!!x)},e.Canvas.prototype.drawImageRectCubic=function(a,u,p,P,x,N){e.de(this.be),ot(u,Rt),ot(p,Ee),this._drawImageRectCubic(a,Rt,Ee,P,x,N||null)},e.Canvas.prototype.drawImageRectOptions=function(a,u,p,P,x,N){e.de(this.be),ot(u,Rt),ot(p,Ee),this._drawImageRectOptions(a,Rt,Ee,P,x,N||null)},e.Canvas.prototype.drawLine=function(a,u,p,P,x){e.de(this.be),this._drawLine(a,u,p,P,x)},e.Canvas.prototype.drawOval=function(a,u){e.de(this.be),a=ot(a),this._drawOval(a,u)},e.Canvas.prototype.drawPaint=function(a){e.de(this.be),this._drawPaint(a)},e.Canvas.prototype.drawParagraph=function(a,u,p){e.de(this.be),this._drawParagraph(a,u,p)},e.Canvas.prototype.drawPatch=function(a,u,p,P,x){if(24>a.length)throw"Need 12 cubic points";if(u&&4>u.length)throw"Need 4 colors";if(p&&8>p.length)throw"Need 4 shader coordinates";e.de(this.be);const N=T(a,"HEAPF32"),j=u?T(g(u),"HEAPU32"):gt,tt=p?T(p,"HEAPF32"):gt;P||(P=e.BlendMode.Modulate),this._drawPatch(N,j,tt,P,x),v(tt,p),v(j,u),v(N,a)},e.Canvas.prototype.drawPath=function(a,u){e.de(this.be),this._drawPath(a,u)},e.Canvas.prototype.drawPicture=function(a){e.de(this.be),this._drawPicture(a)},e.Canvas.prototype.drawPoints=function(a,u,p){e.de(this.be);var P=T(u,"HEAPF32");this._drawPoints(a,P,u.length/2,p),v(P,u)},e.Canvas.prototype.drawRRect=function(a,u){e.de(this.be),a=Ht(a),this._drawRRect(a,u)},e.Canvas.prototype.drawRect=function(a,u){e.de(this.be),a=ot(a),this._drawRect(a,u)},e.Canvas.prototype.drawRect4f=function(a,u,p,P,x){e.de(this.be),this._drawRect4f(a,u,p,P,x)},e.Canvas.prototype.drawShadow=function(a,u,p,P,x,N,j){e.de(this.be);var tt=T(x,"HEAPF32"),et=T(N,"HEAPF32");u=T(u,"HEAPF32",on),p=T(p,"HEAPF32",ln),this._drawShadow(a,u,p,P,tt,et,j),v(tt,x),v(et,N)},e.getShadowLocalBounds=function(a,u,p,P,x,N,j){return a=L(a),p=T(p,"HEAPF32",on),P=T(P,"HEAPF32",ln),this._getShadowLocalBounds(a,u,p,P,x,N,Rt)?(u=ue.toTypedArray(),j?(j.set(u),j):u.slice()):null},e.Canvas.prototype.drawTextBlob=function(a,u,p,P){e.de(this.be),this._drawTextBlob(a,u,p,P)},e.Canvas.prototype.drawVertices=function(a,u,p){e.de(this.be),this._drawVertices(a,u,p)},e.Canvas.prototype.getDeviceClipBounds=function(a){this._getDeviceClipBounds(li);var u=Oi.toTypedArray();return a?a.set(u):a=u.slice(),a},e.Canvas.prototype.quickReject=function(a){return a=ot(a),this._quickReject(a)},e.Canvas.prototype.getLocalToDevice=function(){this._getLocalToDevice(We);for(var a=We,u=Array(16),p=0;16>p;p++)u[p]=e.HEAPF32[a/4+p];return u},e.Canvas.prototype.getTotalMatrix=function(){this._getTotalMatrix(_e);for(var a=Array(9),u=0;9>u;u++)a[u]=e.HEAPF32[_e/4+u];return a},e.Canvas.prototype.makeSurface=function(a){return a=this._makeSurface(a),a.be=this.be,a},e.Canvas.prototype.readPixels=function(a,u,p,P,x){return e.de(this.be),o(this,a,u,p,P,x)},e.Canvas.prototype.saveLayer=function(a,u,p,P,x){return u=ot(u),this._saveLayer(a||null,u,p||null,P||0,x||e.TileMode.Clamp)},e.Canvas.prototype.writePixels=function(a,u,p,P,x,N,j,tt){if(a.byteLength%(u*p))throw"pixels length must be a multiple of the srcWidth * srcHeight";e.de(this.be);var et=a.byteLength/(u*p);N=N||e.AlphaType.Unpremul,j=j||e.ColorType.RGBA_8888,tt=tt||e.ColorSpace.SRGB;var vt=et*u;return et=T(a,"HEAPU8"),u=this._writePixels({width:u,height:p,colorType:j,alphaType:N,colorSpace:tt},et,vt,P,x),v(et,a),u},e.ColorFilter.MakeBlend=function(a,u,p){return a=F(a),p=p||e.ColorSpace.SRGB,e.ColorFilter._MakeBlend(a,u,p)},e.ColorFilter.MakeMatrix=function(a){if(!a||a.length!==20)throw"invalid color matrix";var u=T(a,"HEAPF32"),p=e.ColorFilter._makeMatrix(u);return v(u,a),p},e.ContourMeasure.prototype.getPosTan=function(a,u){return this._getPosTan(a,Rt),a=ue.toTypedArray(),u?(u.set(a),u):a.slice()},e.ImageFilter.prototype.getOutputBounds=function(a,u,p){return a=ot(a,Rt),u=L(u),this._getOutputBounds(a,u,li),u=Oi.toTypedArray(),p?(p.set(u),p):u.slice()},e.ImageFilter.MakeDropShadow=function(a,u,p,P,x,N){return x=F(x,Oe),e.ImageFilter._MakeDropShadow(a,u,p,P,x,N)},e.ImageFilter.MakeDropShadowOnly=function(a,u,p,P,x,N){return x=F(x,Oe),e.ImageFilter._MakeDropShadowOnly(a,u,p,P,x,N)},e.ImageFilter.MakeImage=function(a,u,p,P){if(p=ot(p,Rt),P=ot(P,Ee),"B"in u&&"C"in u)return e.ImageFilter._MakeImageCubic(a,u.B,u.C,p,P);const x=u.filter;let N=e.MipmapMode.None;return"mipmap"in u&&(N=u.mipmap),e.ImageFilter._MakeImageOptions(a,x,N,p,P)},e.ImageFilter.MakeMatrixTransform=function(a,u,p){if(a=L(a),"B"in u&&"C"in u)return e.ImageFilter._MakeMatrixTransformCubic(a,u.B,u.C,p);const P=u.filter;let x=e.MipmapMode.None;return"mipmap"in u&&(x=u.mipmap),e.ImageFilter._MakeMatrixTransformOptions(a,P,x,p)},e.Paint.prototype.getColor=function(){return this._getColor(Oe),ht(Oe)},e.Paint.prototype.setColor=function(a,u){u=u||null,a=F(a),this._setColor(a,u)},e.Paint.prototype.setColorComponents=function(a,u,p,P,x){x=x||null,a=J(a,u,p,P),this._setColor(a,x)},e.Path.prototype.getPoint=function(a,u){return this._getPoint(a,Rt),a=ue.toTypedArray(),u?(u[0]=a[0],u[1]=a[1],u):a.slice(0,2)},e.Picture.prototype.makeShader=function(a,u,p,P,x){return P=L(P),x=ot(x),this._makeShader(a,u,p,P,x)},e.Picture.prototype.cullRect=function(a){this._cullRect(Rt);var u=ue.toTypedArray();return a?(a.set(u),a):u.slice()},e.PictureRecorder.prototype.beginRecording=function(a,u){return a=ot(a),this._beginRecording(a,!!u)},e.Surface.prototype.getCanvas=function(){var a=this._getCanvas();return a.be=this.be,a},e.Surface.prototype.makeImageSnapshot=function(a){return e.de(this.be),a=T(a,"HEAP32",li),this._makeImageSnapshot(a)},e.Surface.prototype.makeSurface=function(a){return e.de(this.be),a=this._makeSurface(a),a.be=this.be,a},e.Surface.prototype.Wf=function(a,u){return this.Ze||(this.Ze=this.getCanvas()),requestAnimationFrame(function(){e.de(this.be),a(this.Ze),this.flush(u)}.bind(this))},e.Surface.prototype.requestAnimationFrame||(e.Surface.prototype.requestAnimationFrame=e.Surface.prototype.Wf),e.Surface.prototype.Sf=function(a,u){this.Ze||(this.Ze=this.getCanvas()),requestAnimationFrame(function(){e.de(this.be),a(this.Ze),this.flush(u),this.dispose()}.bind(this))},e.Surface.prototype.drawOnce||(e.Surface.prototype.drawOnce=e.Surface.prototype.Sf),e.PathEffect.MakeDash=function(a,u){if(u||(u=0),!a.length||a.length%2===1)throw"Intervals array must have even length";var p=T(a,"HEAPF32");return u=e.PathEffect._MakeDash(p,a.length,u),v(p,a),u},e.PathEffect.MakeLine2D=function(a,u){return u=L(u),e.PathEffect._MakeLine2D(a,u)},e.PathEffect.MakePath2D=function(a,u){return a=L(a),e.PathEffect._MakePath2D(a,u)},e.Shader.MakeColor=function(a,u){return u=u||null,a=F(a),e.Shader._MakeColor(a,u)},e.Shader.Blend=e.Shader.MakeBlend,e.Shader.Color=e.Shader.MakeColor,e.Shader.MakeLinearGradient=function(a,u,p,P,x,N,j,tt){tt=tt||null;var et=D(p),vt=T(P,"HEAPF32");j=j||0,N=L(N);var bt=ue.toTypedArray();return bt.set(a),bt.set(u,2),a=e.Shader._MakeLinearGradient(Rt,et.te,et.colorType,vt,et.count,x,j,N,tt),v(et.te,p),P&&v(vt,P),a},e.Shader.MakeRadialGradient=function(a,u,p,P,x,N,j,tt){tt=tt||null;var et=D(p),vt=T(P,"HEAPF32");return j=j||0,N=L(N),a=e.Shader._MakeRadialGradient(a[0],a[1],u,et.te,et.colorType,vt,et.count,x,j,N,tt),v(et.te,p),P&&v(vt,P),a},e.Shader.MakeSweepGradient=function(a,u,p,P,x,N,j,tt,et,vt){vt=vt||null;var bt=D(p),b=T(P,"HEAPF32");return j=j||0,tt=tt||0,et=et||360,N=L(N),a=e.Shader._MakeSweepGradient(a,u,bt.te,bt.colorType,b,bt.count,x,tt,et,j,N,vt),v(bt.te,p),P&&v(b,P),a},e.Shader.MakeTwoPointConicalGradient=function(a,u,p,P,x,N,j,tt,et,vt){vt=vt||null;var bt=D(x),b=T(N,"HEAPF32");et=et||0,tt=L(tt);var I=ue.toTypedArray();return I.set(a),I.set(p,2),a=e.Shader._MakeTwoPointConicalGradient(Rt,u,P,bt.te,bt.colorType,b,bt.count,j,et,tt,vt),v(bt.te,x),N&&v(b,N),a},e.Vertices.prototype.bounds=function(a){this._bounds(Rt);var u=ue.toTypedArray();return a?(a.set(u),a):u.slice()},e.ke&&e.ke.forEach(function(a){a()})},e.computeTonalColors=function(o){var a=T(o.ambient,"HEAPF32"),u=T(o.spot,"HEAPF32");this._computeTonalColors(a,u);var p={ambient:ht(a),spot:ht(u)};return v(a,o.ambient),v(u,o.spot),p},e.LTRBRect=function(o,a,u,p){return Float32Array.of(o,a,u,p)},e.XYWHRect=function(o,a,u,p){return Float32Array.of(o,a,o+u,a+p)},e.LTRBiRect=function(o,a,u,p){return Int32Array.of(o,a,u,p)},e.XYWHiRect=function(o,a,u,p){return Int32Array.of(o,a,o+u,a+p)},e.RRectXY=function(o,a,u){return Float32Array.of(o[0],o[1],o[2],o[3],a,u,a,u,a,u,a,u)},e.MakeAnimatedImageFromEncoded=function(o){o=new Uint8Array(o);var a=e._malloc(o.byteLength);return e.HEAPU8.set(o,a),(o=e._decodeAnimatedImage(a,o.byteLength))?o:null},e.MakeImageFromEncoded=function(o){o=new Uint8Array(o);var a=e._malloc(o.byteLength);return e.HEAPU8.set(o,a),(o=e._decodeImage(a,o.byteLength))?o:null};var hi=null;e.MakeImageFromCanvasImageSource=function(o){var a=o.width,u=o.height;hi||(hi=document.createElement("canvas")),hi.width=a,hi.height=u;var p=hi.getContext("2d",{willReadFrequently:!0});return p.drawImage(o,0,0),o=p.getImageData(0,0,a,u),e.MakeImage({width:a,height:u,alphaType:e.AlphaType.Unpremul,colorType:e.ColorType.RGBA_8888,colorSpace:e.ColorSpace.SRGB},o.data,4*a)},e.MakeImage=function(o,a,u){var p=e._malloc(a.length);return e.HEAPU8.set(a,p),e._MakeImage(o,p,a.length,u)},e.MakeVertices=function(o,a,u,p,P,x){var N=P&&P.length||0,j=0;return u&&u.length&&(j|=1),p&&p.length&&(j|=2),x===void 0||x||(j|=4),o=new e._VerticesBuilder(o,a.length/2,N,j),T(a,"HEAPF32",o.positions()),o.texCoords()&&T(u,"HEAPF32",o.texCoords()),o.colors()&&T(g(p),"HEAPU32",o.colors()),o.indices()&&T(P,"HEAPU16",o.indices()),o.detach()},e.Matrix={},e.Matrix.identity=function(){return s(3)},e.Matrix.invert=function(o){var a=o[0]*o[4]*o[8]+o[1]*o[5]*o[6]+o[2]*o[3]*o[7]-o[2]*o[4]*o[6]-o[1]*o[3]*o[8]-o[0]*o[5]*o[7];return a?[(o[4]*o[8]-o[5]*o[7])/a,(o[2]*o[7]-o[1]*o[8])/a,(o[1]*o[5]-o[2]*o[4])/a,(o[5]*o[6]-o[3]*o[8])/a,(o[0]*o[8]-o[2]*o[6])/a,(o[2]*o[3]-o[0]*o[5])/a,(o[3]*o[7]-o[4]*o[6])/a,(o[1]*o[6]-o[0]*o[7])/a,(o[0]*o[4]-o[1]*o[3])/a]:null},e.Matrix.mapPoints=function(o,a){for(var u=0;u<a.length;u+=2){var p=a[u],P=a[u+1],x=o[6]*p+o[7]*P+o[8],N=o[3]*p+o[4]*P+o[5];a[u]=(o[0]*p+o[1]*P+o[2])/x,a[u+1]=N/x}return a},e.Matrix.multiply=function(){return oi(3,arguments)},e.Matrix.rotated=function(o,a,u){a=a||0,u=u||0;var p=Math.sin(o);return o=Math.cos(o),[o,-p,Lt(p,u,1-o,a),p,o,Lt(-p,a,1-o,u),0,0,1]},e.Matrix.scaled=function(o,a,u,p){u=u||0,p=p||0;var P=n([o,a],s(3),3,0,1);return n([u-o*u,p-a*p],P,3,2,0)},e.Matrix.skewed=function(o,a,u,p){u=u||0,p=p||0;var P=n([o,a],s(3),3,1,-1);return n([-o*u,-a*p],P,3,2,0)},e.Matrix.translated=function(o,a){return n(arguments,s(3),3,2,0)},e.Vector={},e.Vector.dot=function(o,a){return o.map(function(u,p){return u*a[p]}).reduce(function(u,p){return u+p})},e.Vector.lengthSquared=function(o){return e.Vector.dot(o,o)},e.Vector.length=function(o){return Math.sqrt(e.Vector.lengthSquared(o))},e.Vector.mulScalar=function(o,a){return o.map(function(u){return u*a})},e.Vector.add=function(o,a){return o.map(function(u,p){return u+a[p]})},e.Vector.sub=function(o,a){return o.map(function(u,p){return u-a[p]})},e.Vector.dist=function(o,a){return e.Vector.length(e.Vector.sub(o,a))},e.Vector.normalize=function(o){return e.Vector.mulScalar(o,1/e.Vector.length(o))},e.Vector.cross=function(o,a){return[o[1]*a[2]-o[2]*a[1],o[2]*a[0]-o[0]*a[2],o[0]*a[1]-o[1]*a[0]]},e.M44={},e.M44.identity=function(){return s(4)},e.M44.translated=function(o){return n(o,s(4),4,3,0)},e.M44.scaled=function(o){return n(o,s(4),4,0,1)},e.M44.rotated=function(o,a){return e.M44.rotatedUnitSinCos(e.Vector.normalize(o),Math.sin(a),Math.cos(a))},e.M44.rotatedUnitSinCos=function(o,a,u){var p=o[0],P=o[1];o=o[2];var x=1-u;return[x*p*p+u,x*p*P-a*o,x*p*o+a*P,0,x*p*P+a*o,x*P*P+u,x*P*o-a*p,0,x*p*o-a*P,x*P*o+a*p,x*o*o+u,0,0,0,0,1]},e.M44.lookat=function(o,a,u){a=e.Vector.normalize(e.Vector.sub(a,o)),u=e.Vector.normalize(u),u=e.Vector.normalize(e.Vector.cross(a,u));var p=e.M44.identity();return n(u,p,4,0,0),n(e.Vector.cross(u,a),p,4,1,0),n(e.Vector.mulScalar(a,-1),p,4,2,0),n(o,p,4,3,0),o=e.M44.invert(p),o===null?e.M44.identity():o},e.M44.perspective=function(o,a,u){var p=1/(a-o);return u/=2,u=Math.cos(u)/Math.sin(u),[u,0,0,0,0,u,0,0,0,0,(a+o)*p,2*a*o*p,0,0,-1,1]},e.M44.rc=function(o,a,u){return o[4*a+u]},e.M44.multiply=function(){return oi(4,arguments)},e.M44.invert=function(o){var a=o[0],u=o[4],p=o[8],P=o[12],x=o[1],N=o[5],j=o[9],tt=o[13],et=o[2],vt=o[6],bt=o[10],b=o[14],I=o[3],ct=o[7],Ct=o[11];o=o[15];var kt=a*N-u*x,Xt=a*j-p*x,ie=a*tt-P*x,de=u*j-p*N,Tt=u*tt-P*N,$=p*tt-P*j,f=et*ct-vt*I,w=et*Ct-bt*I,M=et*o-b*I,k=vt*Ct-bt*ct,z=vt*o-b*ct,B=bt*o-b*Ct,Z=kt*B-Xt*z+ie*k+de*M-Tt*w+$*f,pt=1/Z;return Z===0||pt===1/0?null:(kt*=pt,Xt*=pt,ie*=pt,de*=pt,Tt*=pt,$*=pt,f*=pt,w*=pt,M*=pt,k*=pt,z*=pt,B*=pt,a=[N*B-j*z+tt*k,j*M-x*B-tt*w,x*z-N*M+tt*f,N*w-x*k-j*f,p*z-u*B-P*k,a*B-p*M+P*w,u*M-a*z-P*f,a*k-u*w+p*f,ct*$-Ct*Tt+o*de,Ct*ie-I*$-o*Xt,I*Tt-ct*ie+o*kt,ct*Xt-I*de-Ct*kt,bt*Tt-vt*$-b*de,et*$-bt*ie+b*Xt,vt*ie-et*Tt-b*kt,et*de-vt*Xt+bt*kt],a.every(function($t){return!isNaN($t)&&$t!==1/0&&$t!==-1/0})?a:null)},e.M44.transpose=function(o){return[o[0],o[4],o[8],o[12],o[1],o[5],o[9],o[13],o[2],o[6],o[10],o[14],o[3],o[7],o[11],o[15]]},e.M44.mustInvert=function(o){if(o=e.M44.invert(o),o===null)throw"Matrix not invertible";return o},e.M44.setupCamera=function(o,a,u){var p=e.M44.lookat(u.eye,u.coa,u.up);return u=e.M44.perspective(u.near,u.far,u.angle),a=[(o[2]-o[0])/2,(o[3]-o[1])/2,a],o=e.M44.multiply(e.M44.translated([(o[0]+o[2])/2,(o[1]+o[3])/2,0]),e.M44.scaled(a)),e.M44.multiply(o,u,p,e.M44.mustInvert(o))},e.ColorMatrix={},e.ColorMatrix.identity=function(){var o=new Float32Array(20);return o[0]=1,o[6]=1,o[12]=1,o[18]=1,o},e.ColorMatrix.scaled=function(o,a,u,p){var P=new Float32Array(20);return P[0]=o,P[6]=a,P[12]=u,P[18]=p,P};var oa=[[6,7,11,12],[0,10,2,12],[0,1,5,6]];e.ColorMatrix.rotated=function(o,a,u){var p=e.ColorMatrix.identity();return o=oa[o],p[o[0]]=u,p[o[1]]=a,p[o[2]]=-a,p[o[3]]=u,p},e.ColorMatrix.postTranslate=function(o,a,u,p,P){return o[4]+=a,o[9]+=u,o[14]+=p,o[19]+=P,o},e.ColorMatrix.concat=function(o,a){for(var u=new Float32Array(20),p=0,P=0;20>P;P+=5){for(var x=0;4>x;x++)u[p++]=o[P]*a[x]+o[P+1]*a[x+5]+o[P+2]*a[x+10]+o[P+3]*a[x+15];u[p++]=o[P]*a[4]+o[P+1]*a[9]+o[P+2]*a[14]+o[P+3]*a[19]+o[P+4]}return u},function(o){o.ke=o.ke||[],o.ke.push(function(){function a(b){return b&&(b.dir=b.dir===0?o.TextDirection.RTL:o.TextDirection.LTR),b}function u(b){if(!b||!b.length)return[];for(var I=[],ct=0;ct<b.length;ct+=5){var Ct=o.LTRBRect(b[ct],b[ct+1],b[ct+2],b[ct+3]),kt=o.TextDirection.LTR;b[ct+4]===0&&(kt=o.TextDirection.RTL),I.push({rect:Ct,dir:kt})}return o._free(b.byteOffset),I}function p(b){return b=b||{},b.weight===void 0&&(b.weight=o.FontWeight.Normal),b.width=b.width||o.FontWidth.Normal,b.slant=b.slant||o.FontSlant.Upright,b}function P(b){if(!b||!b.length)return gt;for(var I=[],ct=0;ct<b.length;ct++){var Ct=x(b[ct]);I.push(Ct)}return T(I,"HEAPU32")}function x(b){if(tt[b])return tt[b];var I=le(b)+1,ct=o._malloc(I);return oe(b,ft,ct,I),tt[b]=ct}function N(b){if(b._colorPtr=F(b.color),b._foregroundColorPtr=gt,b._backgroundColorPtr=gt,b._decorationColorPtr=gt,b.foregroundColor&&(b._foregroundColorPtr=F(b.foregroundColor,et)),b.backgroundColor&&(b._backgroundColorPtr=F(b.backgroundColor,vt)),b.decorationColor&&(b._decorationColorPtr=F(b.decorationColor,bt)),Array.isArray(b.fontFamilies)&&b.fontFamilies.length?(b._fontFamiliesPtr=P(b.fontFamilies),b._fontFamiliesLen=b.fontFamilies.length):(b._fontFamiliesPtr=gt,b._fontFamiliesLen=0),b.locale){var I=b.locale;b._localePtr=x(I),b._localeLen=le(I)}else b._localePtr=gt,b._localeLen=0;if(Array.isArray(b.shadows)&&b.shadows.length){I=b.shadows;var ct=I.map(function(Tt){return Tt.color||o.BLACK}),Ct=I.map(function(Tt){return Tt.blurRadius||0});b._shadowLen=I.length;for(var kt=o._malloc(8*I.length),Xt=kt/4,ie=0;ie<I.length;ie++){var de=I[ie].offset||[0,0];o.HEAPF32[Xt]=de[0],o.HEAPF32[Xt+1]=de[1],Xt+=2}b._shadowColorsPtr=D(ct).te,b._shadowOffsetsPtr=kt,b._shadowBlurRadiiPtr=T(Ct,"HEAPF32")}else b._shadowLen=0,b._shadowColorsPtr=gt,b._shadowOffsetsPtr=gt,b._shadowBlurRadiiPtr=gt;Array.isArray(b.fontFeatures)&&b.fontFeatures.length?(I=b.fontFeatures,ct=I.map(function(Tt){return Tt.name}),Ct=I.map(function(Tt){return Tt.value}),b._fontFeatureLen=I.length,b._fontFeatureNamesPtr=P(ct),b._fontFeatureValuesPtr=T(Ct,"HEAPU32")):(b._fontFeatureLen=0,b._fontFeatureNamesPtr=gt,b._fontFeatureValuesPtr=gt),Array.isArray(b.fontVariations)&&b.fontVariations.length?(I=b.fontVariations,ct=I.map(function(Tt){return Tt.axis}),Ct=I.map(function(Tt){return Tt.value}),b._fontVariationLen=I.length,b._fontVariationAxesPtr=P(ct),b._fontVariationValuesPtr=T(Ct,"HEAPF32")):(b._fontVariationLen=0,b._fontVariationAxesPtr=gt,b._fontVariationValuesPtr=gt)}function j(b){o._free(b._fontFamiliesPtr),o._free(b._shadowColorsPtr),o._free(b._shadowOffsetsPtr),o._free(b._shadowBlurRadiiPtr),o._free(b._fontFeatureNamesPtr),o._free(b._fontFeatureValuesPtr),o._free(b._fontVariationAxesPtr),o._free(b._fontVariationValuesPtr)}o.Paragraph.prototype.getRectsForRange=function(b,I,ct,Ct){return b=this._getRectsForRange(b,I,ct,Ct),u(b)},o.Paragraph.prototype.getRectsForPlaceholders=function(){var b=this._getRectsForPlaceholders();return u(b)},o.Paragraph.prototype.getGlyphInfoAt=function(b){return a(this._getGlyphInfoAt(b))},o.Paragraph.prototype.getClosestGlyphInfoAtCoordinate=function(b,I){return a(this._getClosestGlyphInfoAtCoordinate(b,I))},o.TypefaceFontProvider.prototype.registerFont=function(b,I){if(b=o.Typeface.MakeTypefaceFromData(b),!b)return null;I=x(I),this._registerFont(b,I),b.delete()},o.ParagraphStyle=function(b){if(b.disableHinting=b.disableHinting||!1,b.ellipsis){var I=b.ellipsis;b._ellipsisPtr=x(I),b._ellipsisLen=le(I)}else b._ellipsisPtr=gt,b._ellipsisLen=0;return b.heightMultiplier==null&&(b.heightMultiplier=-1),b.maxLines=b.maxLines||0,b.replaceTabCharacters=b.replaceTabCharacters||!1,I=(I=b.strutStyle)||{},I.strutEnabled=I.strutEnabled||!1,I.strutEnabled&&Array.isArray(I.fontFamilies)&&I.fontFamilies.length?(I._fontFamiliesPtr=P(I.fontFamilies),I._fontFamiliesLen=I.fontFamilies.length):(I._fontFamiliesPtr=gt,I._fontFamiliesLen=0),I.fontStyle=p(I.fontStyle),I.fontSize==null&&(I.fontSize=-1),I.heightMultiplier==null&&(I.heightMultiplier=-1),I.halfLeading=I.halfLeading||!1,I.leading=I.leading||0,I.forceStrutHeight=I.forceStrutHeight||!1,b.strutStyle=I,b.textAlign=b.textAlign||o.TextAlign.Start,b.textDirection=b.textDirection||o.TextDirection.LTR,b.textHeightBehavior=b.textHeightBehavior||o.TextHeightBehavior.All,b.textStyle=o.TextStyle(b.textStyle),b.applyRoundingHack=b.applyRoundingHack!==!1,b},o.TextStyle=function(b){return b.color||(b.color=o.BLACK),b.decoration=b.decoration||0,b.decorationThickness=b.decorationThickness||0,b.decorationStyle=b.decorationStyle||o.DecorationStyle.Solid,b.textBaseline=b.textBaseline||o.TextBaseline.Alphabetic,b.fontSize==null&&(b.fontSize=-1),b.letterSpacing=b.letterSpacing||0,b.wordSpacing=b.wordSpacing||0,b.heightMultiplier==null&&(b.heightMultiplier=-1),b.halfLeading=b.halfLeading||!1,b.fontStyle=p(b.fontStyle),b};var tt={},et=o._malloc(16),vt=o._malloc(16),bt=o._malloc(16);o.ParagraphBuilder.Make=function(b,I){return N(b.textStyle),I=o.ParagraphBuilder._Make(b,I),j(b.textStyle),I},o.ParagraphBuilder.MakeFromFontProvider=function(b,I){return N(b.textStyle),I=o.ParagraphBuilder._MakeFromFontProvider(b,I),j(b.textStyle),I},o.ParagraphBuilder.MakeFromFontCollection=function(b,I){return N(b.textStyle),I=o.ParagraphBuilder._MakeFromFontCollection(b,I),j(b.textStyle),I},o.ParagraphBuilder.ShapeText=function(b,I,ct){let Ct=0;for(const kt of I)Ct+=kt.length;if(Ct!==b.length)throw"Accumulated block lengths must equal text.length";return o.ParagraphBuilder._ShapeText(b,I,ct)},o.ParagraphBuilder.prototype.pushStyle=function(b){N(b),this._pushStyle(b),j(b)},o.ParagraphBuilder.prototype.pushPaintStyle=function(b,I,ct){N(b),this._pushPaintStyle(b,I,ct),j(b)},o.ParagraphBuilder.prototype.addPlaceholder=function(b,I,ct,Ct,kt){ct=ct||o.PlaceholderAlignment.Baseline,Ct=Ct||o.TextBaseline.Alphabetic,this._addPlaceholder(b||0,I||0,ct,Ct,kt||0)},o.ParagraphBuilder.prototype.setWordsUtf8=function(b){var I=T(b,"HEAPU32");this._setWordsUtf8(I,b&&b.length||0),v(I,b)},o.ParagraphBuilder.prototype.setWordsUtf16=function(b){var I=T(b,"HEAPU32");this._setWordsUtf16(I,b&&b.length||0),v(I,b)},o.ParagraphBuilder.prototype.setGraphemeBreaksUtf8=function(b){var I=T(b,"HEAPU32");this._setGraphemeBreaksUtf8(I,b&&b.length||0),v(I,b)},o.ParagraphBuilder.prototype.setGraphemeBreaksUtf16=function(b){var I=T(b,"HEAPU32");this._setGraphemeBreaksUtf16(I,b&&b.length||0),v(I,b)},o.ParagraphBuilder.prototype.setLineBreaksUtf8=function(b){var I=T(b,"HEAPU32");this._setLineBreaksUtf8(I,b&&b.length||0),v(I,b)},o.ParagraphBuilder.prototype.setLineBreaksUtf16=function(b){var I=T(b,"HEAPU32");this._setLineBreaksUtf16(I,b&&b.length||0),v(I,b)}})}(c),e.ke=e.ke||[],e.ke.push(function(){e.Path.prototype.op=function(o,a){return this._op(o,a)?this:null},e.Path.prototype.simplify=function(){return this._simplify()?this:null}}),e.ke=e.ke||[],e.ke.push(function(){e.Canvas.prototype.drawText=function(o,a,u,p,P){var x=le(o),N=e._malloc(x+1);oe(o,ft,N,x+1),this._drawSimpleText(N,x,a,u,P,p),e._free(N)},e.Canvas.prototype.drawGlyphs=function(o,a,u,p,P,x){if(!(2*o.length<=a.length))throw"Not enough positions for the array of gyphs";e.de(this.be);const N=T(o,"HEAPU16"),j=T(a,"HEAPF32");this._drawGlyphs(o.length,N,j,u,p,P,x),v(j,a),v(N,o)},e.Font.prototype.getGlyphBounds=function(o,a,u){var p=T(o,"HEAPU16"),P=e._malloc(16*o.length);return this._getGlyphWidthBounds(p,o.length,gt,P,a||null),a=new Float32Array(e.HEAPU8.buffer,P,4*o.length),v(p,o),u?(u.set(a),e._free(P),u):(o=Float32Array.from(a),e._free(P),o)},e.Font.prototype.getGlyphIDs=function(o,a,u){a||(a=o.length);var p=le(o)+1,P=e._malloc(p);return oe(o,ft,P,p),o=e._malloc(2*a),a=this._getGlyphIDs(P,p-1,a,o),e._free(P),0>a?(e._free(o),null):(P=new Uint16Array(e.HEAPU8.buffer,o,a),u?(u.set(P),e._free(o),u):(u=Uint16Array.from(P),e._free(o),u))},e.Font.prototype.getGlyphIntercepts=function(o,a,u,p){var P=T(o,"HEAPU16"),x=T(a,"HEAPF32");return this._getGlyphIntercepts(P,o.length,!(o&&o._ck),x,a.length,!(a&&a._ck),u,p)},e.Font.prototype.getGlyphWidths=function(o,a,u){var p=T(o,"HEAPU16"),P=e._malloc(4*o.length);return this._getGlyphWidthBounds(p,o.length,P,gt,a||null),a=new Float32Array(e.HEAPU8.buffer,P,o.length),v(p,o),u?(u.set(a),e._free(P),u):(o=Float32Array.from(a),e._free(P),o)},e.FontMgr.FromData=function(){if(!arguments.length)return null;var o=arguments;if(o.length===1&&Array.isArray(o[0])&&(o=arguments[0]),!o.length)return null;for(var a=[],u=[],p=0;p<o.length;p++){var P=new Uint8Array(o[p]),x=T(P,"HEAPU8");a.push(x),u.push(P.byteLength)}return a=T(a,"HEAPU32"),u=T(u,"HEAPU32"),o=e.FontMgr._fromData(a,u,o.length),e._free(a),e._free(u),o},e.Typeface.MakeTypefaceFromData=function(o){o=new Uint8Array(o);var a=T(o,"HEAPU8");return(o=e.Typeface._MakeTypefaceFromData(a,o.byteLength))?o:null},e.Typeface.MakeFreeTypeFaceFromData=e.Typeface.MakeTypefaceFromData,e.Typeface.prototype.getGlyphIDs=function(o,a,u){a||(a=o.length);var p=le(o)+1,P=e._malloc(p);return oe(o,ft,P,p),o=e._malloc(2*a),a=this._getGlyphIDs(P,p-1,a,o),e._free(P),0>a?(e._free(o),null):(P=new Uint16Array(e.HEAPU8.buffer,o,a),u?(u.set(P),e._free(o),u):(u=Uint16Array.from(P),e._free(o),u))},e.TextBlob.MakeOnPath=function(o,a,u,p){if(o&&o.length&&a&&a.countPoints()){if(a.countPoints()===1)return this.MakeFromText(o,u);p||(p=0);var P=u.getGlyphIDs(o);P=u.getGlyphWidths(P);var x=[];a=new e.ContourMeasureIter(a,!1,1);for(var N=a.next(),j=new Float32Array(4),tt=0;tt<o.length&&N;tt++){var et=P[tt];if(p+=et/2,p>N.length()){if(N.delete(),N=a.next(),!N){o=o.substring(0,tt);break}p=et/2}N.getPosTan(p,j);var vt=j[2],bt=j[3];x.push(vt,bt,j[0]-et/2*vt,j[1]-et/2*bt),p+=et/2}return o=this.MakeFromRSXform(o,x,u),N&&N.delete(),a.delete(),o}},e.TextBlob.MakeFromRSXform=function(o,a,u){var p=le(o)+1,P=e._malloc(p);return oe(o,ft,P,p),o=T(a,"HEAPF32"),u=e.TextBlob._MakeFromRSXform(P,p-1,o,u),e._free(P),u||null},e.TextBlob.MakeFromRSXformGlyphs=function(o,a,u){var p=T(o,"HEAPU16");return a=T(a,"HEAPF32"),u=e.TextBlob._MakeFromRSXformGlyphs(p,2*o.length,a,u),v(p,o),u||null},e.TextBlob.MakeFromGlyphs=function(o,a){var u=T(o,"HEAPU16");return a=e.TextBlob._MakeFromGlyphs(u,2*o.length,a),v(u,o),a||null},e.TextBlob.MakeFromText=function(o,a){var u=le(o)+1,p=e._malloc(u);return oe(o,ft,p,u),o=e.TextBlob._MakeFromText(p,u-1,a),e._free(p),o||null},e.MallocGlyphIDs=function(o){return e.Malloc(Uint16Array,o)}}),e.ke=e.ke||[],e.ke.push(function(){e.MakePicture=function(o){o=new Uint8Array(o);var a=e._malloc(o.byteLength);return e.HEAPU8.set(o,a),(o=e._MakePicture(a,o.byteLength))?o:null}}),e.ke=e.ke||[],e.ke.push(function(){e.RuntimeEffect.Make=function(o,a){return e.RuntimeEffect._Make(o,{onError:a||function(u){console.log("RuntimeEffect error",u)}})},e.RuntimeEffect.MakeForBlender=function(o,a){return e.RuntimeEffect._MakeForBlender(o,{onError:a||function(u){console.log("RuntimeEffect error",u)}})},e.RuntimeEffect.prototype.makeShader=function(o,a){var u=!o._ck,p=T(o,"HEAPF32");return a=L(a),this._makeShader(p,4*o.length,u,a)},e.RuntimeEffect.prototype.makeShaderWithChildren=function(o,a,u){var p=!o._ck,P=T(o,"HEAPF32");u=L(u);for(var x=[],N=0;N<a.length;N++)x.push(a[N].ae.ie);return a=T(x,"HEAPU32"),this._makeShaderWithChildren(P,4*o.length,p,a,x.length,u)},e.RuntimeEffect.prototype.makeBlender=function(o){var a=!o._ck,u=T(o,"HEAPF32");return this._makeBlender(u,4*o.length,a)}}),function(){function o($){for(var f=0;f<$.length;f++)if($[f]!==void 0&&!Number.isFinite($[f]))return!1;return!0}function a($){var f=e.getColorComponents($);$=f[0];var w=f[1],M=f[2];return f=f[3],f===1?($=$.toString(16).toLowerCase(),w=w.toString(16).toLowerCase(),M=M.toString(16).toLowerCase(),$=$.length===1?"0"+$:$,w=w.length===1?"0"+w:w,M=M.length===1?"0"+M:M,"#"+$+w+M):(f=f===0||f===1?f:f.toFixed(8),"rgba("+$+", "+w+", "+M+", "+f+")")}function u($){return e.parseColorString($,ie)}function p($){if($=de.exec($),!$)return null;var f=parseFloat($[4]),w=16;switch($[5]){case"em":case"rem":w=16*f;break;case"pt":w=4*f/3;break;case"px":w=f;break;case"pc":w=16*f;break;case"in":w=96*f;break;case"cm":w=96*f/2.54;break;case"mm":w=3.7795275590551185*f;break;case"q":w=.9448818897637796*f;break;case"%":w=.21333333333333335*f}return{style:$[1],variant:$[2],weight:$[3],sizePx:w,family:$[6].trim()}}function P(){Tt||(Tt={"Noto Mono":{"*":e.Typeface.GetDefault()},monospace:{"*":e.Typeface.GetDefault()}})}function x($){this.ce=$,this.fe=new e.Paint,this.fe.setAntiAlias(!0),this.fe.setStrokeMiter(10),this.fe.setStrokeCap(e.StrokeCap.Butt),this.fe.setStrokeJoin(e.StrokeJoin.Miter),this.kf="10px monospace",this.Fe=new e.Font(e.Typeface.GetDefault(),10),this.Fe.setSubpixel(!0),this.se=this.ye=e.BLACK,this.Oe=0,this.af=e.TRANSPARENT,this.Qe=this.Pe=0,this.bf=this.Be=1,this.$e=0,this.Ne=[],this.ee=e.BlendMode.SrcOver,this.fe.setStrokeWidth(this.bf),this.fe.setBlendMode(this.ee),this.he=new e.Path,this.je=e.Matrix.identity(),this.Ff=[],this.Ue=[],this.Ee=function(){this.he.delete(),this.fe.delete(),this.Fe.delete(),this.Ue.forEach(function(f){f.Ee()})},Object.defineProperty(this,"currentTransform",{enumerable:!0,get:function(){return{a:this.je[0],c:this.je[1],e:this.je[2],b:this.je[3],d:this.je[4],f:this.je[5]}},set:function(f){f.a&&this.setTransform(f.a,f.b,f.c,f.d,f.e,f.f)}}),Object.defineProperty(this,"fillStyle",{enumerable:!0,get:function(){return l(this.se)?a(this.se):this.se},set:function(f){typeof f=="string"?this.se=u(f):f.Me&&(this.se=f)}}),Object.defineProperty(this,"font",{enumerable:!0,get:function(){return this.kf},set:function(f){var w=p(f),M=(w.style||"normal")+"|"+(w.variant||"normal")+"|"+(w.weight||"normal"),k=w.family;P(),M=Tt[k]?Tt[k][M]||Tt[k]["*"]:e.Typeface.GetDefault(),w.typeface=M,w&&(this.Fe.setSize(w.sizePx),this.Fe.setTypeface(w.typeface),this.kf=f)}}),Object.defineProperty(this,"globalAlpha",{enumerable:!0,get:function(){return this.Be},set:function(f){!isFinite(f)||0>f||1<f||(this.Be=f)}}),Object.defineProperty(this,"globalCompositeOperation",{enumerable:!0,get:function(){switch(this.ee){case e.BlendMode.SrcOver:return"source-over";case e.BlendMode.DstOver:return"destination-over";case e.BlendMode.Src:return"copy";case e.BlendMode.Dst:return"destination";case e.BlendMode.Clear:return"clear";case e.BlendMode.SrcIn:return"source-in";case e.BlendMode.DstIn:return"destination-in";case e.BlendMode.SrcOut:return"source-out";case e.BlendMode.DstOut:return"destination-out";case e.BlendMode.SrcATop:return"source-atop";case e.BlendMode.DstATop:return"destination-atop";case e.BlendMode.Xor:return"xor";case e.BlendMode.Plus:return"lighter";case e.BlendMode.Multiply:return"multiply";case e.BlendMode.Screen:return"screen";case e.BlendMode.Overlay:return"overlay";case e.BlendMode.Darken:return"darken";case e.BlendMode.Lighten:return"lighten";case e.BlendMode.ColorDodge:return"color-dodge";case e.BlendMode.ColorBurn:return"color-burn";case e.BlendMode.HardLight:return"hard-light";case e.BlendMode.SoftLight:return"soft-light";case e.BlendMode.Difference:return"difference";case e.BlendMode.Exclusion:return"exclusion";case e.BlendMode.Hue:return"hue";case e.BlendMode.Saturation:return"saturation";case e.BlendMode.Color:return"color";case e.BlendMode.Luminosity:return"luminosity"}},set:function(f){switch(f){case"source-over":this.ee=e.BlendMode.SrcOver;break;case"destination-over":this.ee=e.BlendMode.DstOver;break;case"copy":this.ee=e.BlendMode.Src;break;case"destination":this.ee=e.BlendMode.Dst;break;case"clear":this.ee=e.BlendMode.Clear;break;case"source-in":this.ee=e.BlendMode.SrcIn;break;case"destination-in":this.ee=e.BlendMode.DstIn;break;case"source-out":this.ee=e.BlendMode.SrcOut;break;case"destination-out":this.ee=e.BlendMode.DstOut;break;case"source-atop":this.ee=e.BlendMode.SrcATop;break;case"destination-atop":this.ee=e.BlendMode.DstATop;break;case"xor":this.ee=e.BlendMode.Xor;break;case"lighter":this.ee=e.BlendMode.Plus;break;case"plus-lighter":this.ee=e.BlendMode.Plus;break;case"plus-darker":throw"plus-darker is not supported";case"multiply":this.ee=e.BlendMode.Multiply;break;case"screen":this.ee=e.BlendMode.Screen;break;case"overlay":this.ee=e.BlendMode.Overlay;break;case"darken":this.ee=e.BlendMode.Darken;break;case"lighten":this.ee=e.BlendMode.Lighten;break;case"color-dodge":this.ee=e.BlendMode.ColorDodge;break;case"color-burn":this.ee=e.BlendMode.ColorBurn;break;case"hard-light":this.ee=e.BlendMode.HardLight;break;case"soft-light":this.ee=e.BlendMode.SoftLight;break;case"difference":this.ee=e.BlendMode.Difference;break;case"exclusion":this.ee=e.BlendMode.Exclusion;break;case"hue":this.ee=e.BlendMode.Hue;break;case"saturation":this.ee=e.BlendMode.Saturation;break;case"color":this.ee=e.BlendMode.Color;break;case"luminosity":this.ee=e.BlendMode.Luminosity;break;default:return}this.fe.setBlendMode(this.ee)}}),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.fe.getStrokeCap()){case e.StrokeCap.Butt:return"butt";case e.StrokeCap.Round:return"round";case e.StrokeCap.Square:return"square"}},set:function(f){switch(f){case"butt":this.fe.setStrokeCap(e.StrokeCap.Butt);break;case"round":this.fe.setStrokeCap(e.StrokeCap.Round);break;case"square":this.fe.setStrokeCap(e.StrokeCap.Square)}}}),Object.defineProperty(this,"lineDashOffset",{enumerable:!0,get:function(){return this.$e},set:function(f){isFinite(f)&&(this.$e=f)}}),Object.defineProperty(this,"lineJoin",{enumerable:!0,get:function(){switch(this.fe.getStrokeJoin()){case e.StrokeJoin.Miter:return"miter";case e.StrokeJoin.Round:return"round";case e.StrokeJoin.Bevel:return"bevel"}},set:function(f){switch(f){case"miter":this.fe.setStrokeJoin(e.StrokeJoin.Miter);break;case"round":this.fe.setStrokeJoin(e.StrokeJoin.Round);break;case"bevel":this.fe.setStrokeJoin(e.StrokeJoin.Bevel)}}}),Object.defineProperty(this,"lineWidth",{enumerable:!0,get:function(){return this.fe.getStrokeWidth()},set:function(f){0>=f||!f||(this.bf=f,this.fe.setStrokeWidth(f))}}),Object.defineProperty(this,"miterLimit",{enumerable:!0,get:function(){return this.fe.getStrokeMiter()},set:function(f){0>=f||!f||this.fe.setStrokeMiter(f)}}),Object.defineProperty(this,"shadowBlur",{enumerable:!0,get:function(){return this.Oe},set:function(f){0>f||!isFinite(f)||(this.Oe=f)}}),Object.defineProperty(this,"shadowColor",{enumerable:!0,get:function(){return a(this.af)},set:function(f){this.af=u(f)}}),Object.defineProperty(this,"shadowOffsetX",{enumerable:!0,get:function(){return this.Pe},set:function(f){isFinite(f)&&(this.Pe=f)}}),Object.defineProperty(this,"shadowOffsetY",{enumerable:!0,get:function(){return this.Qe},set:function(f){isFinite(f)&&(this.Qe=f)}}),Object.defineProperty(this,"strokeStyle",{enumerable:!0,get:function(){return a(this.ye)},set:function(f){typeof f=="string"?this.ye=u(f):f.Me&&(this.ye=f)}}),this.arc=function(f,w,M,k,z,B){I(this.he,f,w,M,M,0,k,z,B)},this.arcTo=function(f,w,M,k,z){vt(this.he,f,w,M,k,z)},this.beginPath=function(){this.he.delete(),this.he=new e.Path},this.bezierCurveTo=function(f,w,M,k,z,B){var Z=this.he;o([f,w,M,k,z,B])&&(Z.isEmpty()&&Z.moveTo(f,w),Z.cubicTo(f,w,M,k,z,B))},this.clearRect=function(f,w,M,k){this.fe.setStyle(e.PaintStyle.Fill),this.fe.setBlendMode(e.BlendMode.Clear),this.ce.drawRect(e.XYWHRect(f,w,M,k),this.fe),this.fe.setBlendMode(this.ee)},this.clip=function(f,w){typeof f=="string"?(w=f,f=this.he):f&&f.vf&&(f=f.le),f||(f=this.he),f=f.copy(),w&&w.toLowerCase()==="evenodd"?f.setFillType(e.FillType.EvenOdd):f.setFillType(e.FillType.Winding),this.ce.clipPath(f,e.ClipOp.Intersect,!0),f.delete()},this.closePath=function(){bt(this.he)},this.createImageData=function(){if(arguments.length===1){var f=arguments[0];return new tt(new Uint8ClampedArray(4*f.width*f.height),f.width,f.height)}if(arguments.length===2){f=arguments[0];var w=arguments[1];return new tt(new Uint8ClampedArray(4*f*w),f,w)}throw"createImageData expects 1 or 2 arguments, got "+arguments.length},this.createLinearGradient=function(f,w,M,k){if(o(arguments)){var z=new et(f,w,M,k);return this.Ue.push(z),z}},this.createPattern=function(f,w){return f=new kt(f,w),this.Ue.push(f),f},this.createRadialGradient=function(f,w,M,k,z,B){if(o(arguments)){var Z=new Xt(f,w,M,k,z,B);return this.Ue.push(Z),Z}},this.drawImage=function(f){f instanceof j&&(f=f.Lf());var w=this.jf();if(arguments.length===3||arguments.length===5)var M=e.XYWHRect(arguments[1],arguments[2],arguments[3]||f.width(),arguments[4]||f.height()),k=e.XYWHRect(0,0,f.width(),f.height());else if(arguments.length===9)M=e.XYWHRect(arguments[5],arguments[6],arguments[7],arguments[8]),k=e.XYWHRect(arguments[1],arguments[2],arguments[3],arguments[4]);else throw"invalid number of args for drawImage, need 3, 5, or 9; got "+arguments.length;this.ce.drawImageRect(f,k,M,w,!1),w.dispose()},this.ellipse=function(f,w,M,k,z,B,Z,pt){I(this.he,f,w,M,k,z,B,Z,pt)},this.jf=function(){var f=this.fe.copy();if(f.setStyle(e.PaintStyle.Fill),l(this.se)){var w=e.multiplyByAlpha(this.se,this.Be);f.setColor(w)}else w=this.se.Me(this.je),f.setColor(e.Color(0,0,0,this.Be)),f.setShader(w);return f.dispose=function(){this.delete()},f},this.fill=function(f,w){if(typeof f=="string"?(w=f,f=this.he):f&&f.vf&&(f=f.le),w==="evenodd")this.he.setFillType(e.FillType.EvenOdd);else{if(w!=="nonzero"&&w)throw"invalid fill rule";this.he.setFillType(e.FillType.Winding)}f||(f=this.he),w=this.jf();var M=this.Re(w);M&&(this.ce.save(),this.Ke(),this.ce.drawPath(f,M),this.ce.restore(),M.dispose()),this.ce.drawPath(f,w),w.dispose()},this.fillRect=function(f,w,M,k){var z=this.jf(),B=this.Re(z);B&&(this.ce.save(),this.Ke(),this.ce.drawRect(e.XYWHRect(f,w,M,k),B),this.ce.restore(),B.dispose()),this.ce.drawRect(e.XYWHRect(f,w,M,k),z),z.dispose()},this.fillText=function(f,w,M){var k=this.jf();f=e.TextBlob.MakeFromText(f,this.Fe);var z=this.Re(k);z&&(this.ce.save(),this.Ke(),this.ce.drawTextBlob(f,w,M,z),this.ce.restore(),z.dispose()),this.ce.drawTextBlob(f,w,M,k),f.delete(),k.dispose()},this.getImageData=function(f,w,M,k){return(f=this.ce.readPixels(f,w,{width:M,height:k,colorType:e.ColorType.RGBA_8888,alphaType:e.AlphaType.Unpremul,colorSpace:e.ColorSpace.SRGB}))?new tt(new Uint8ClampedArray(f.buffer),M,k):null},this.getLineDash=function(){return this.Ne.slice()},this.Gf=function(f){var w=e.Matrix.invert(this.je);return e.Matrix.mapPoints(w,f),f},this.isPointInPath=function(f,w,M){var k=arguments;if(k.length===3)var z=this.he;else if(k.length===4)z=k[0],f=k[1],w=k[2],M=k[3];else throw"invalid arg count, need 3 or 4, got "+k.length;return!isFinite(f)||!isFinite(w)||(M=M||"nonzero",M!=="nonzero"&&M!=="evenodd")?!1:(k=this.Gf([f,w]),f=k[0],w=k[1],z.setFillType(M==="nonzero"?e.FillType.Winding:e.FillType.EvenOdd),z.contains(f,w))},this.isPointInStroke=function(f,w){var M=arguments;if(M.length===2)var k=this.he;else if(M.length===3)k=M[0],f=M[1],w=M[2];else throw"invalid arg count, need 2 or 3, got "+M.length;return!isFinite(f)||!isFinite(w)?!1:(M=this.Gf([f,w]),f=M[0],w=M[1],k=k.copy(),k.setFillType(e.FillType.Winding),k.stroke({width:this.lineWidth,miter_limit:this.miterLimit,cap:this.fe.getStrokeCap(),join:this.fe.getStrokeJoin(),precision:.3}),M=k.contains(f,w),k.delete(),M)},this.lineTo=function(f,w){ct(this.he,f,w)},this.measureText=function(f){f=this.Fe.getGlyphIDs(f),f=this.Fe.getGlyphWidths(f);let w=0;for(const M of f)w+=M;return{width:w}},this.moveTo=function(f,w){var M=this.he;o([f,w])&&M.moveTo(f,w)},this.putImageData=function(f,w,M,k,z,B,Z){if(o([w,M,k,z,B,Z])){if(k===void 0)this.ce.writePixels(f.data,f.width,f.height,w,M);else if(k=k||0,z=z||0,B=B||f.width,Z=Z||f.height,0>B&&(k+=B,B=Math.abs(B)),0>Z&&(z+=Z,Z=Math.abs(Z)),0>k&&(B+=k,k=0),0>z&&(Z+=z,z=0),!(0>=B||0>=Z)){f=e.MakeImage({width:f.width,height:f.height,alphaType:e.AlphaType.Unpremul,colorType:e.ColorType.RGBA_8888,colorSpace:e.ColorSpace.SRGB},f.data,4*f.width);var pt=e.XYWHRect(k,z,B,Z);w=e.XYWHRect(w+k,M+z,B,Z),M=e.Matrix.invert(this.je),this.ce.save(),this.ce.concat(M),this.ce.drawImageRect(f,pt,w,null,!1),this.ce.restore(),f.delete()}}},this.quadraticCurveTo=function(f,w,M,k){var z=this.he;o([f,w,M,k])&&(z.isEmpty()&&z.moveTo(f,w),z.quadTo(f,w,M,k))},this.rect=function(f,w,M,k){var z=this.he;f=e.XYWHRect(f,w,M,k),o(f)&&z.addRect(f)},this.resetTransform=function(){this.he.transform(this.je);var f=e.Matrix.invert(this.je);this.ce.concat(f),this.je=this.ce.getTotalMatrix()},this.restore=function(){var f=this.Ff.pop();if(f){var w=e.Matrix.multiply(this.je,e.Matrix.invert(f.ag));this.he.transform(w),this.fe.delete(),this.fe=f.sg,this.Ne=f.qg,this.bf=f.Eg,this.ye=f.Dg,this.se=f.fs,this.Pe=f.Bg,this.Qe=f.Cg,this.Oe=f.sb,this.af=f.Ag,this.Be=f.ga,this.ee=f.hg,this.$e=f.rg,this.kf=f.gg,this.ce.restore(),this.je=this.ce.getTotalMatrix()}},this.rotate=function(f){if(isFinite(f)){var w=e.Matrix.rotated(-f);this.he.transform(w),this.ce.rotate(f/Math.PI*180,0,0),this.je=this.ce.getTotalMatrix()}},this.save=function(){if(this.se.Le){var f=this.se.Le();this.Ue.push(f)}else f=this.se;if(this.ye.Le){var w=this.ye.Le();this.Ue.push(w)}else w=this.ye;this.Ff.push({ag:this.je.slice(),qg:this.Ne.slice(),Eg:this.bf,Dg:w,fs:f,Bg:this.Pe,Cg:this.Qe,sb:this.Oe,Ag:this.af,ga:this.Be,rg:this.$e,hg:this.ee,sg:this.fe.copy(),gg:this.kf}),this.ce.save()},this.scale=function(f,w){if(o(arguments)){var M=e.Matrix.scaled(1/f,1/w);this.he.transform(M),this.ce.scale(f,w),this.je=this.ce.getTotalMatrix()}},this.setLineDash=function(f){for(var w=0;w<f.length;w++)if(!isFinite(f[w])||0>f[w])return;f.length%2===1&&Array.prototype.push.apply(f,f),this.Ne=f},this.setTransform=function(f,w,M,k,z,B){o(arguments)&&(this.resetTransform(),this.transform(f,w,M,k,z,B))},this.Ke=function(){var f=e.Matrix.invert(this.je);this.ce.concat(f),this.ce.concat(e.Matrix.translated(this.Pe,this.Qe)),this.ce.concat(this.je)},this.Re=function(f){var w=e.multiplyByAlpha(this.af,this.Be);if(!e.getColorComponents(w)[3]||!(this.Oe||this.Qe||this.Pe))return null;f=f.copy(),f.setColor(w);var M=e.MaskFilter.MakeBlur(e.BlurStyle.Normal,this.Oe/2,!1);return f.setMaskFilter(M),f.dispose=function(){M.delete(),this.delete()},f},this.xf=function(){var f=this.fe.copy();if(f.setStyle(e.PaintStyle.Stroke),l(this.ye)){var w=e.multiplyByAlpha(this.ye,this.Be);f.setColor(w)}else w=this.ye.Me(this.je),f.setColor(e.Color(0,0,0,this.Be)),f.setShader(w);if(f.setStrokeWidth(this.bf),this.Ne.length){var M=e.PathEffect.MakeDash(this.Ne,this.$e);f.setPathEffect(M)}return f.dispose=function(){M&&M.delete(),this.delete()},f},this.stroke=function(f){f=f?f.le:this.he;var w=this.xf(),M=this.Re(w);M&&(this.ce.save(),this.Ke(),this.ce.drawPath(f,M),this.ce.restore(),M.dispose()),this.ce.drawPath(f,w),w.dispose()},this.strokeRect=function(f,w,M,k){var z=this.xf(),B=this.Re(z);B&&(this.ce.save(),this.Ke(),this.ce.drawRect(e.XYWHRect(f,w,M,k),B),this.ce.restore(),B.dispose()),this.ce.drawRect(e.XYWHRect(f,w,M,k),z),z.dispose()},this.strokeText=function(f,w,M){var k=this.xf();f=e.TextBlob.MakeFromText(f,this.Fe);var z=this.Re(k);z&&(this.ce.save(),this.Ke(),this.ce.drawTextBlob(f,w,M,z),this.ce.restore(),z.dispose()),this.ce.drawTextBlob(f,w,M,k),f.delete(),k.dispose()},this.translate=function(f,w){if(o(arguments)){var M=e.Matrix.translated(-f,-w);this.he.transform(M),this.ce.translate(f,w),this.je=this.ce.getTotalMatrix()}},this.transform=function(f,w,M,k,z,B){f=[f,M,z,w,k,B,0,0,1],w=e.Matrix.invert(f),this.he.transform(w),this.ce.concat(f),this.je=this.ce.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 N($){this.yf=$,this.be=new x($.getCanvas()),this.lf=[],this.decodeImage=function(f){if(f=e.MakeImageFromEncoded(f),!f)throw"Invalid input";return this.lf.push(f),new j(f)},this.loadFont=function(f,w){if(f=e.Typeface.MakeTypefaceFromData(f),!f)return null;this.lf.push(f);var M=(w.style||"normal")+"|"+(w.variant||"normal")+"|"+(w.weight||"normal");w=w.family,P(),Tt[w]||(Tt[w]={"*":f}),Tt[w][M]=f},this.makePath2D=function(f){return f=new Ct(f),this.lf.push(f.le),f},this.getContext=function(f){return f==="2d"?this.be:null},this.toDataURL=function(f,w){this.yf.flush();var M=this.yf.makeImageSnapshot();if(M){f=f||"image/png";var k=e.ImageFormat.PNG;if(f==="image/jpeg"&&(k=e.ImageFormat.JPEG),w=M.encodeToBytes(k,w||.92)){if(M.delete(),f="data:"+f+";base64,",typeof Buffer<"u")w=Buffer.from(w).toString("base64");else{M=0,k=w.length;for(var z="",B;M<k;)B=w.slice(M,Math.min(M+32768,k)),z+=String.fromCharCode.apply(null,B),M+=32768;w=btoa(z)}return f+w}}},this.dispose=function(){this.be.Ee(),this.lf.forEach(function(f){f.delete()}),this.yf.dispose()}}function j($){this.width=$.width(),this.height=$.height(),this.naturalWidth=this.width,this.naturalHeight=this.height,this.Lf=function(){return $}}function tt($,f,w){if(!f||w===0)throw new TypeError("invalid dimensions, width and height must be non-zero");if($.length%4)throw new TypeError("arr must be a multiple of 4");w=w||$.length/(4*f),Object.defineProperty(this,"data",{value:$,writable:!1}),Object.defineProperty(this,"height",{value:w,writable:!1}),Object.defineProperty(this,"width",{value:f,writable:!1})}function et($,f,w,M){this.ne=null,this.ue=[],this.qe=[],this.addColorStop=function(k,z){if(0>k||1<k||!isFinite(k))throw"offset must be between 0 and 1 inclusively";z=u(z);var B=this.qe.indexOf(k);if(B!==-1)this.ue[B]=z;else{for(B=0;B<this.qe.length&&!(this.qe[B]>k);B++);this.qe.splice(B,0,k),this.ue.splice(B,0,z)}},this.Le=function(){var k=new et($,f,w,M);return k.ue=this.ue.slice(),k.qe=this.qe.slice(),k},this.Ee=function(){this.ne&&(this.ne.delete(),this.ne=null)},this.Me=function(k){var z=[$,f,w,M];e.Matrix.mapPoints(k,z),k=z[0];var B=z[1],Z=z[2];return z=z[3],this.Ee(),this.ne=e.Shader.MakeLinearGradient([k,B],[Z,z],this.ue,this.qe,e.TileMode.Clamp)}}function vt($,f,w,M,k,z){if(o([f,w,M,k,z])){if(0>z)throw"radii cannot be negative";$.isEmpty()&&$.moveTo(f,w),$.arcToTangent(f,w,M,k,z)}}function bt($){if(!$.isEmpty()){var f=$.getBounds();(f[3]-f[1]||f[2]-f[0])&&$.close()}}function b($,f,w,M,k,z,B){B=(B-z)/Math.PI*180,z=z/Math.PI*180,f=e.LTRBRect(f-M,w-k,f+M,w+k),1e-5>Math.abs(Math.abs(B)-360)?(w=B/2,$.arcToOval(f,z,w,!1),$.arcToOval(f,z+w,w,!1)):$.arcToOval(f,z,B,!1)}function I($,f,w,M,k,z,B,Z,pt){if(o([f,w,M,k,z,B,Z])){if(0>M||0>k)throw"radii cannot be negative";var $t=2*Math.PI,je=B%$t;0>je&&(je+=$t);var ci=je-B;B=je,Z+=ci,!pt&&Z-B>=$t?Z=B+$t:pt&&B-Z>=$t?Z=B-$t:!pt&&B>Z?Z=B+($t-(B-Z)%$t):pt&&B<Z&&(Z=B-($t-(Z-B)%$t)),z?(pt=e.Matrix.rotated(z,f,w),z=e.Matrix.rotated(-z,f,w),$.transform(z),b($,f,w,M,k,B,Z),$.transform(pt)):b($,f,w,M,k,B,Z)}}function ct($,f,w){o([f,w])&&($.isEmpty()&&$.moveTo(f,w),$.lineTo(f,w))}function Ct($){this.le=null,this.le=typeof $=="string"?e.Path.MakeFromSVGString($):$&&$.vf?$.le.copy():new e.Path,this.vf=function(){return this.le},this.addPath=function(f,w){w||(w={a:1,c:0,e:0,b:0,d:1,f:0}),this.le.addPath(f.le,[w.a,w.c,w.e,w.b,w.d,w.f])},this.arc=function(f,w,M,k,z,B){I(this.le,f,w,M,M,0,k,z,B)},this.arcTo=function(f,w,M,k,z){vt(this.le,f,w,M,k,z)},this.bezierCurveTo=function(f,w,M,k,z,B){var Z=this.le;o([f,w,M,k,z,B])&&(Z.isEmpty()&&Z.moveTo(f,w),Z.cubicTo(f,w,M,k,z,B))},this.closePath=function(){bt(this.le)},this.ellipse=function(f,w,M,k,z,B,Z,pt){I(this.le,f,w,M,k,z,B,Z,pt)},this.lineTo=function(f,w){ct(this.le,f,w)},this.moveTo=function(f,w){var M=this.le;o([f,w])&&M.moveTo(f,w)},this.quadraticCurveTo=function(f,w,M,k){var z=this.le;o([f,w,M,k])&&(z.isEmpty()&&z.moveTo(f,w),z.quadTo(f,w,M,k))},this.rect=function(f,w,M,k){var z=this.le;f=e.XYWHRect(f,w,M,k),o(f)&&z.addRect(f)}}function kt($,f){switch(this.ne=null,$ instanceof j&&($=$.Lf()),this.Uf=$,this._transform=e.Matrix.identity(),f===""&&(f="repeat"),f){case"repeat-x":this.Se=e.TileMode.Repeat,this.Te=e.TileMode.Decal;break;case"repeat-y":this.Se=e.TileMode.Decal,this.Te=e.TileMode.Repeat;break;case"repeat":this.Te=this.Se=e.TileMode.Repeat;break;case"no-repeat":this.Te=this.Se=e.TileMode.Decal;break;default:throw"invalid repetition mode "+f}this.setTransform=function(w){w=[w.a,w.c,w.e,w.b,w.d,w.f,0,0,1],o(w)&&(this._transform=w)},this.Le=function(){var w=new kt;return w.Se=this.Se,w.Te=this.Te,w},this.Ee=function(){this.ne&&(this.ne.delete(),this.ne=null)},this.Me=function(){return this.Ee(),this.ne=this.Uf.makeShaderCubic(this.Se,this.Te,.3333333333333333,.3333333333333333,this._transform)}}function Xt($,f,w,M,k,z){this.ne=null,this.ue=[],this.qe=[],this.addColorStop=function(B,Z){if(0>B||1<B||!isFinite(B))throw"offset must be between 0 and 1 inclusively";Z=u(Z);var pt=this.qe.indexOf(B);if(pt!==-1)this.ue[pt]=Z;else{for(pt=0;pt<this.qe.length&&!(this.qe[pt]>B);pt++);this.qe.splice(pt,0,B),this.ue.splice(pt,0,Z)}},this.Le=function(){var B=new Xt($,f,w,M,k,z);return B.ue=this.ue.slice(),B.qe=this.qe.slice(),B},this.Ee=function(){this.ne&&(this.ne.delete(),this.ne=null)},this.Me=function(B){var Z=[$,f,M,k];e.Matrix.mapPoints(B,Z);var pt=Z[0],$t=Z[1],je=Z[2];Z=Z[3];var ci=(Math.abs(B[0])+Math.abs(B[4]))/2;return B=w*ci,ci*=z,this.Ee(),this.ne=e.Shader.MakeTwoPointConicalGradient([pt,$t],B,[je,Z],ci,this.ue,this.qe,e.TileMode.Clamp)}}e._testing={};var ie={aliceblue:Float32Array.of(.941,.973,1,1),antiquewhite:Float32Array.of(.98,.922,.843,1),aqua:Float32Array.of(0,1,1,1),aquamarine:Float32Array.of(.498,1,.831,1),azure:Float32Array.of(.941,1,1,1),beige:Float32Array.of(.961,.961,.863,1),bisque:Float32Array.of(1,.894,.769,1),black:Float32Array.of(0,0,0,1),blanchedalmond:Float32Array.of(1,.922,.804,1),blue:Float32Array.of(0,0,1,1),blueviolet:Float32Array.of(.541,.169,.886,1),brown:Float32Array.of(.647,.165,.165,1),burlywood:Float32Array.of(.871,.722,.529,1),cadetblue:Float32Array.of(.373,.62,.627,1),chartreuse:Float32Array.of(.498,1,0,1),chocolate:Float32Array.of(.824,.412,.118,1),coral:Float32Array.of(1,.498,.314,1),cornflowerblue:Float32Array.of(.392,.584,.929,1),cornsilk:Float32Array.of(1,.973,.863,1),crimson:Float32Array.of(.863,.078,.235,1),cyan:Float32Array.of(0,1,1,1),darkblue:Float32Array.of(0,0,.545,1),darkcyan:Float32Array.of(0,.545,.545,1),darkgoldenrod:Float32Array.of(.722,.525,.043,1),darkgray:Float32Array.of(.663,.663,.663,1),darkgreen:Float32Array.of(0,.392,0,1),darkgrey:Float32Array.of(.663,.663,.663,1),darkkhaki:Float32Array.of(.741,.718,.42,1),darkmagenta:Float32Array.of(.545,0,.545,1),darkolivegreen:Float32Array.of(.333,.42,.184,1),darkorange:Float32Array.of(1,.549,0,1),darkorchid:Float32Array.of(.6,.196,.8,1),darkred:Float32Array.of(.545,0,0,1),darksalmon:Float32Array.of(.914,.588,.478,1),darkseagreen:Float32Array.of(.561,.737,.561,1),darkslateblue:Float32Array.of(.282,.239,.545,1),darkslategray:Float32Array.of(.184,.31,.31,1),darkslategrey:Float32Array.of(.184,.31,.31,1),darkturquoise:Float32Array.of(0,.808,.82,1),darkviolet:Float32Array.of(.58,0,.827,1),deeppink:Float32Array.of(1,.078,.576,1),deepskyblue:Float32Array.of(0,.749,1,1),dimgray:Float32Array.of(.412,.412,.412,1),dimgrey:Float32Array.of(.412,.412,.412,1),dodgerblue:Float32Array.of(.118,.565,1,1),firebrick:Float32Array.of(.698,.133,.133,1),floralwhite:Float32Array.of(1,.98,.941,1),forestgreen:Float32Array.of(.133,.545,.133,1),fuchsia:Float32Array.of(1,0,1,1),gainsboro:Float32Array.of(.863,.863,.863,1),ghostwhite:Float32Array.of(.973,.973,1,1),gold:Float32Array.of(1,.843,0,1),goldenrod:Float32Array.of(.855,.647,.125,1),gray:Float32Array.of(.502,.502,.502,1),green:Float32Array.of(0,.502,0,1),greenyellow:Float32Array.of(.678,1,.184,1),grey:Float32Array.of(.502,.502,.502,1),honeydew:Float32Array.of(.941,1,.941,1),hotpink:Float32Array.of(1,.412,.706,1),indianred:Float32Array.of(.804,.361,.361,1),indigo:Float32Array.of(.294,0,.51,1),ivory:Float32Array.of(1,1,.941,1),khaki:Float32Array.of(.941,.902,.549,1),lavender:Float32Array.of(.902,.902,.98,1),lavenderblush:Float32Array.of(1,.941,.961,1),lawngreen:Float32Array.of(.486,.988,0,1),lemonchiffon:Float32Array.of(1,.98,.804,1),lightblue:Float32Array.of(.678,.847,.902,1),lightcoral:Float32Array.of(.941,.502,.502,1),lightcyan:Float32Array.of(.878,1,1,1),lightgoldenrodyellow:Float32Array.of(.98,.98,.824,1),lightgray:Float32Array.of(.827,.827,.827,1),lightgreen:Float32Array.of(.565,.933,.565,1),lightgrey:Float32Array.of(.827,.827,.827,1),lightpink:Float32Array.of(1,.714,.757,1),lightsalmon:Float32Array.of(1,.627,.478,1),lightseagreen:Float32Array.of(.125,.698,.667,1),lightskyblue:Float32Array.of(.529,.808,.98,1),lightslategray:Float32Array.of(.467,.533,.6,1),lightslategrey:Float32Array.of(.467,.533,.6,1),lightsteelblue:Float32Array.of(.69,.769,.871,1),lightyellow:Float32Array.of(1,1,.878,1),lime:Float32Array.of(0,1,0,1),limegreen:Float32Array.of(.196,.804,.196,1),linen:Float32Array.of(.98,.941,.902,1),magenta:Float32Array.of(1,0,1,1),maroon:Float32Array.of(.502,0,0,1),mediumaquamarine:Float32Array.of(.4,.804,.667,1),mediumblue:Float32Array.of(0,0,.804,1),mediumorchid:Float32Array.of(.729,.333,.827,1),mediumpurple:Float32Array.of(.576,.439,.859,1),mediumseagreen:Float32Array.of(.235,.702,.443,1),mediumslateblue:Float32Array.of(.482,.408,.933,1),mediumspringgreen:Float32Array.of(0,.98,.604,1),mediumturquoise:Float32Array.of(.282,.82,.8,1),mediumvioletred:Float32Array.of(.78,.082,.522,1),midnightblue:Float32Array.of(.098,.098,.439,1),mintcream:Float32Array.of(.961,1,.98,1),mistyrose:Float32Array.of(1,.894,.882,1),moccasin:Float32Array.of(1,.894,.71,1),navajowhite:Float32Array.of(1,.871,.678,1),navy:Float32Array.of(0,0,.502,1),oldlace:Float32Array.of(.992,.961,.902,1),olive:Float32Array.of(.502,.502,0,1),olivedrab:Float32Array.of(.42,.557,.137,1),orange:Float32Array.of(1,.647,0,1),orangered:Float32Array.of(1,.271,0,1),orchid:Float32Array.of(.855,.439,.839,1),palegoldenrod:Float32Array.of(.933,.91,.667,1),palegreen:Float32Array.of(.596,.984,.596,1),paleturquoise:Float32Array.of(.686,.933,.933,1),palevioletred:Float32Array.of(.859,.439,.576,1),papayawhip:Float32Array.of(1,.937,.835,1),peachpuff:Float32Array.of(1,.855,.725,1),peru:Float32Array.of(.804,.522,.247,1),pink:Float32Array.of(1,.753,.796,1),plum:Float32Array.of(.867,.627,.867,1),powderblue:Float32Array.of(.69,.878,.902,1),purple:Float32Array.of(.502,0,.502,1),rebeccapurple:Float32Array.of(.4,.2,.6,1),red:Float32Array.of(1,0,0,1),rosybrown:Float32Array.of(.737,.561,.561,1),royalblue:Float32Array.of(.255,.412,.882,1),saddlebrown:Float32Array.of(.545,.271,.075,1),salmon:Float32Array.of(.98,.502,.447,1),sandybrown:Float32Array.of(.957,.643,.376,1),seagreen:Float32Array.of(.18,.545,.341,1),seashell:Float32Array.of(1,.961,.933,1),sienna:Float32Array.of(.627,.322,.176,1),silver:Float32Array.of(.753,.753,.753,1),skyblue:Float32Array.of(.529,.808,.922,1),slateblue:Float32Array.of(.416,.353,.804,1),slategray:Float32Array.of(.439,.502,.565,1),slategrey:Float32Array.of(.439,.502,.565,1),snow:Float32Array.of(1,.98,.98,1),springgreen:Float32Array.of(0,1,.498,1),steelblue:Float32Array.of(.275,.51,.706,1),tan:Float32Array.of(.824,.706,.549,1),teal:Float32Array.of(0,.502,.502,1),thistle:Float32Array.of(.847,.749,.847,1),tomato:Float32Array.of(1,.388,.278,1),transparent:Float32Array.of(0,0,0,0),turquoise:Float32Array.of(.251,.878,.816,1),violet:Float32Array.of(.933,.51,.933,1),wheat:Float32Array.of(.961,.871,.702,1),white:Float32Array.of(1,1,1,1),whitesmoke:Float32Array.of(.961,.961,.961,1),yellow:Float32Array.of(1,1,0,1),yellowgreen:Float32Array.of(.604,.804,.196,1)};e._testing.parseColor=u,e._testing.colorToString=a;var de=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)(.+)"),Tt;e._testing.parseFontString=p,e.MakeCanvas=function($,f){return($=e.MakeSurface($,f))?new N($):null},e.ImageData=function(){if(arguments.length===2){var $=arguments[0],f=arguments[1];return new tt(new Uint8ClampedArray(4*$*f),$,f)}if(arguments.length===3){var w=arguments[0];if(w.prototype.constructor!==Uint8ClampedArray)throw new TypeError("bytes must be given as a Uint8ClampedArray");if($=arguments[1],f=arguments[2],w%4)throw new TypeError("bytes must be given in a multiple of 4");if(w%$)throw new TypeError("bytes must divide evenly by width");if(f&&f!==w/(4*$))throw new TypeError("invalid height given");return new tt(w,$,w/(4*$))}throw new TypeError("invalid number of arguments - takes 2 or 3, saw "+arguments.length)}}()}(c);var O=Object.assign({},c),G="./this.program",K=(e,n)=>{throw n},it=typeof window=="object",lt=typeof importScripts=="function",yt=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",st="",Et,Wt,Bt;if(yt){var se=va,U=Aa;st=lt?U.dirname(st)+"/":__dirname+"/",Et=(e,n)=>(e=e.startsWith("file://")?new URL(e):U.normalize(e),se.readFileSync(e,n?void 0:"utf8")),Bt=e=>(e=Et(e,!0),e.buffer||(e=new Uint8Array(e)),e),Wt=(e,n,s,l=!0)=>{e=e.startsWith("file://")?new URL(e):U.normalize(e),se.readFile(e,l?void 0:"utf8",(d,g)=>{d?s(d):n(l?g.buffer:g)})},!c.thisProgram&&1<process.argv.length&&(G=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),K=(e,n)=>{throw process.exitCode=e,n},c.inspect=()=>"[Emscripten Module object]"}else(it||lt)&&(lt?st=self.location.href:typeof document<"u"&&document.currentScript&&(st=document.currentScript.src),r&&(st=r),st.indexOf("blob:")!==0?st=st.substr(0,st.replace(/[?#].*/,"").lastIndexOf("/")+1):st="",Et=e=>{var n=new XMLHttpRequest;return n.open("GET",e,!1),n.send(null),n.responseText},lt&&(Bt=e=>{var n=new XMLHttpRequest;return n.open("GET",e,!1),n.responseType="arraybuffer",n.send(null),new Uint8Array(n.response)}),Wt=(e,n,s)=>{var l=new XMLHttpRequest;l.open("GET",e,!0),l.responseType="arraybuffer",l.onload=()=>{l.status==200||l.status==0&&l.response?n(l.response):s()},l.onerror=s,l.send(null)});var ut=c.print||console.log.bind(console),Pe=c.printErr||console.error.bind(console);Object.assign(c,O),O=null,c.thisProgram&&(G=c.thisProgram),c.quit&&(K=c.quit);var qe;c.wasmBinary&&(qe=c.wasmBinary),c.noExitRuntime,typeof WebAssembly!="object"&&Gi("no native wasm support detected");var gi,Pt,Cn=!1,pe,ft,Ae,Be,W,_t,nt,Tn;function _n(){var e=gi.buffer;c.HEAP8=pe=new Int8Array(e),c.HEAP16=Ae=new Int16Array(e),c.HEAP32=W=new Int32Array(e),c.HEAPU8=ft=new Uint8Array(e),c.HEAPU16=Be=new Uint16Array(e),c.HEAPU32=_t=new Uint32Array(e),c.HEAPF32=nt=new Float32Array(e),c.HEAPF64=Tn=new Float64Array(e)}var Mt,En=[],xn=[],Fn=[];function os(){var e=c.preRun.shift();En.unshift(e)}var xe=0,Ye=null;function Gi(e){throw c.onAbort&&c.onAbort(e),e="Aborted("+e+")",Pe(e),Cn=!0,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),E(e),e}function Mn(e){return e.startsWith("data:application/octet-stream;base64,")}var Ue;if(Ue="canvaskit.wasm",!Mn(Ue)){var Rn=Ue;Ue=c.locateFile?c.locateFile(Rn,st):st+Rn}function kn(e){if(e==Ue&&qe)return new Uint8Array(qe);if(Bt)return Bt(e);throw"both async and sync fetching of the wasm failed"}function ls(e){if(!qe&&(it||lt)){if(typeof fetch=="function"&&!e.startsWith("file://"))return fetch(e,{credentials:"same-origin"}).then(n=>{if(!n.ok)throw"failed to load wasm binary file at '"+e+"'";return n.arrayBuffer()}).catch(()=>kn(e));if(Wt)return new Promise((n,s)=>{Wt(e,l=>n(new Uint8Array(l)),s)})}return Promise.resolve().then(()=>kn(e))}function Nn(e,n,s){return ls(e).then(l=>WebAssembly.instantiate(l,n)).then(l=>l).then(s,l=>{Pe("failed to asynchronously prepare wasm: "+l),Gi(l)})}function hs(e,n){var s=Ue;return qe||typeof WebAssembly.instantiateStreaming!="function"||Mn(s)||s.startsWith("file://")||yt||typeof fetch!="function"?Nn(s,e,n):fetch(s,{credentials:"same-origin"}).then(l=>WebAssembly.instantiateStreaming(l,e).then(n,function(d){return Pe("wasm streaming compile failed: "+d),Pe("falling back to ArrayBuffer instantiation"),Nn(s,e,n)}))}function cs(e){this.name="ExitStatus",this.message=`Program terminated with exit(${e})`,this.status=e}var Wi=e=>{for(;0<e.length;)e.shift()(c)},In=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Fe=(e,n,s)=>{var l=n+s;for(s=n;e[s]&&!(s>=l);)++s;if(16<s-n&&e.buffer&&In)return In.decode(e.subarray(n,s));for(l="";n<s;){var d=e[n++];if(d&128){var g=e[n++]&63;if((d&224)==192)l+=String.fromCharCode((d&31)<<6|g);else{var A=e[n++]&63;d=(d&240)==224?(d&15)<<12|g<<6|A:(d&7)<<18|g<<12|A<<6|e[n++]&63,65536>d?l+=String.fromCharCode(d):(d-=65536,l+=String.fromCharCode(55296|d>>10,56320|d&1023))}}else l+=String.fromCharCode(d)}return l},mi={};function ji(e){for(;e.length;){var n=e.pop();e.pop()(n)}}function Xe(e){return this.fromWireType(W[e>>2])}var $e={},Me={},yi={},On=void 0;function vi(e){throw new On(e)}function ae(e,n,s){function l(y){y=s(y),y.length!==e.length&&vi("Mismatched type converter count");for(var v=0;v<e.length;++v)ge(e[v],y[v])}e.forEach(function(y){yi[y]=n});var d=Array(n.length),g=[],A=0;n.forEach((y,v)=>{Me.hasOwnProperty(y)?d[v]=Me[y]:(g.push(y),$e.hasOwnProperty(y)||($e[y]=[]),$e[y].push(()=>{d[v]=Me[y],++A,A===g.length&&l(d)}))}),g.length===0&&l(d)}function wi(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError(`Unknown type size: ${e}`)}}var Dn=void 0;function Ft(e){for(var n="";ft[e];)n+=Dn[ft[e++]];return n}var Ge=void 0;function wt(e){throw new Ge(e)}function us(e,n,s={}){var l=n.name;if(e||wt(`type "${l}" must have a positive integer typeid pointer`),Me.hasOwnProperty(e)){if(s.ng)return;wt(`Cannot register type '${l}' twice`)}Me[e]=n,delete yi[e],$e.hasOwnProperty(e)&&(n=$e[e],delete $e[e],n.forEach(d=>d()))}function ge(e,n,s={}){if(!("argPackAdvance"in n))throw new TypeError("registerType registeredInstance requires argPackAdvance");us(e,n,s)}function Hi(e){wt(e.ae.me.ge.name+" instance already deleted")}var Ki=!1;function zn(){}function Ln(e){--e.count.value,e.count.value===0&&(e.pe?e.we.De(e.pe):e.me.ge.De(e.ie))}function Bn(e,n,s){return n===s?e:s.re===void 0?null:(e=Bn(e,n,s.re),e===null?null:s.dg(e))}var Un={},Je=[];function Vi(){for(;Je.length;){var e=Je.pop();e.ae.Xe=!1,e.delete()}}var Qe=void 0,Ze={};function ds(e,n){for(n===void 0&&wt("ptr should not be undefined");e.re;)n=e.gf(n),e=e.re;return Ze[n]}function Si(e,n){return n.me&&n.ie||vi("makeClassHandle requires ptr and ptrType"),!!n.we!=!!n.pe&&vi("Both smartPtrType and smartPtr must be specified"),n.count={value:1},ti(Object.create(e,{ae:{value:n}}))}function ti(e){return typeof FinalizationRegistry>"u"?(ti=n=>n,e):(Ki=new FinalizationRegistry(n=>{Ln(n.ae)}),ti=n=>{var s=n.ae;return s.pe&&Ki.register(n,{ae:s},n),n},zn=n=>{Ki.unregister(n)},ti(e))}function Ce(){}function $n(e){if(e===void 0)return"_unknown";e=e.replace(/[^a-zA-Z0-9_]/g,"$");var n=e.charCodeAt(0);return 48<=n&&57>=n?`_${e}`:e}function qi(e,n){return e=$n(e),{[e]:function(){return n.apply(this,arguments)}}[e]}function Yi(e,n,s){if(e[n].oe===void 0){var l=e[n];e[n]=function(){return e[n].oe.hasOwnProperty(arguments.length)||wt(`Function '${s}' called with an invalid number of arguments (${arguments.length}) - expects one of (${e[n].oe})!`),e[n].oe[arguments.length].apply(this,arguments)},e[n].oe=[],e[n].oe[l.Ve]=l}}function Xi(e,n,s){c.hasOwnProperty(e)?((s===void 0||c[e].oe!==void 0&&c[e].oe[s]!==void 0)&&wt(`Cannot register public name '${e}' twice`),Yi(c,e,e),c.hasOwnProperty(s)&&wt(`Cannot register multiple overloads of a function with the same number of arguments (${s})!`),c[e].oe[s]=n):(c[e]=n,s!==void 0&&(c[e].Lg=s))}function fs(e,n,s,l,d,g,A,y){this.name=e,this.constructor=n,this.Ye=s,this.De=l,this.re=d,this.ig=g,this.gf=A,this.dg=y,this.ug=[]}function Ji(e,n,s){for(;n!==s;)n.gf||wt(`Expected null or instance of ${s.name}, got an instance of ${n.name}`),e=n.gf(e),n=n.re;return e}function ps(e,n){return n===null?(this.Bf&&wt(`null is not a valid ${this.name}`),0):(n.ae||wt(`Cannot pass "${Zi(n)}" as a ${this.name}`),n.ae.ie||wt(`Cannot pass deleted object as a pointer of type ${this.name}`),Ji(n.ae.ie,n.ae.me.ge,this.ge))}function gs(e,n){if(n===null){if(this.Bf&&wt(`null is not a valid ${this.name}`),this.pf){var s=this.Cf();return e!==null&&e.push(this.De,s),s}return 0}if(n.ae||wt(`Cannot pass "${Zi(n)}" as a ${this.name}`),n.ae.ie||wt(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.nf&&n.ae.me.nf&&wt(`Cannot convert argument of type ${n.ae.we?n.ae.we.name:n.ae.me.name} to parameter type ${this.name}`),s=Ji(n.ae.ie,n.ae.me.ge,this.ge),this.pf)switch(n.ae.pe===void 0&&wt("Passing raw pointer to smart pointer is illegal"),this.zg){case 0:n.ae.we===this?s=n.ae.pe:wt(`Cannot convert argument of type ${n.ae.we?n.ae.we.name:n.ae.me.name} to parameter type ${this.name}`);break;case 1:s=n.ae.pe;break;case 2:if(n.ae.we===this)s=n.ae.pe;else{var l=n.clone();s=this.vg(s,te(function(){l.delete()})),e!==null&&e.push(this.De,s)}break;default:wt("Unsupporting sharing policy")}return s}function ms(e,n){return n===null?(this.Bf&&wt(`null is not a valid ${this.name}`),0):(n.ae||wt(`Cannot pass "${Zi(n)}" as a ${this.name}`),n.ae.ie||wt(`Cannot pass deleted object as a pointer of type ${this.name}`),n.ae.me.nf&&wt(`Cannot convert argument of type ${n.ae.me.name} to parameter type ${this.name}`),Ji(n.ae.ie,n.ae.me.ge,this.ge))}function me(e,n,s,l,d,g,A,y,v,T,D){this.name=e,this.ge=n,this.Bf=s,this.nf=l,this.pf=d,this.tg=g,this.zg=A,this.Nf=y,this.Cf=v,this.vg=T,this.De=D,d||n.re!==void 0?this.toWireType=gs:(this.toWireType=l?ps:ms,this.ve=null)}function Gn(e,n,s){c.hasOwnProperty(e)||vi("Replacing nonexistant public symbol"),c[e].oe!==void 0&&s!==void 0?c[e].oe[s]=n:(c[e]=n,c[e].Ve=s)}var ys=(e,n)=>{var s=[];return function(){if(s.length=0,Object.assign(s,arguments),e.includes("j")){var l=c["dynCall_"+e];l=s&&s.length?l.apply(null,[n].concat(s)):l.call(null,n)}else l=Mt.get(n).apply(null,s);return l}};function Ut(e,n){e=Ft(e);var s=e.includes("j")?ys(e,n):Mt.get(n);return typeof s!="function"&&wt(`unknown function pointer with signature ${e}: ${n}`),s}var Wn=void 0;function jn(e){e=Sr(e);var n=Ft(e);return we(e),n}function ei(e,n){function s(g){d[g]||Me[g]||(yi[g]?yi[g].forEach(s):(l.push(g),d[g]=!0))}var l=[],d={};throw n.forEach(s),new Wn(`${e}: `+l.map(jn).join([", "]))}function bi(e,n,s,l,d){var g=n.length;2>g&&wt("argTypes array size mismatch! Must at least get return value and 'this' types!");var A=n[1]!==null&&s!==null,y=!1;for(s=1;s<n.length;++s)if(n[s]!==null&&n[s].ve===void 0){y=!0;break}var v=n[0].name!=="void",T=g-2,D=Array(T),L=[],Y=[];return function(){if(arguments.length!==T&&wt(`function ${e} called with ${arguments.length} arguments, expected ${T} args!`),Y.length=0,L.length=A?2:1,L[0]=d,A){var F=n[1].toWireType(Y,this);L[1]=F}for(var J=0;J<T;++J)D[J]=n[J+2].toWireType(Y,arguments[J]),L.push(D[J]);if(J=l.apply(null,L),y)ji(Y);else for(var ht=A?1:2;ht<n.length;ht++){var ot=ht===1?F:D[ht-2];n[ht].ve!==null&&n[ht].ve(ot)}return F=v?n[0].fromWireType(J):void 0,F}}function Pi(e,n){for(var s=[],l=0;l<e;l++)s.push(_t[n+4*l>>2]);return s}function Hn(){this.Ce=[void 0],this.Kf=[]}var Qt=new Hn;function Qi(e){e>=Qt.df&&--Qt.get(e).Of===0&&Qt.Zf(e)}var Zt=e=>(e||wt("Cannot use deleted val. handle = "+e),Qt.get(e).value),te=e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return Qt.Yf({Of:1,value:e})}};function vs(e,n,s){switch(n){case 0:return function(l){return this.fromWireType((s?pe:ft)[l])};case 1:return function(l){return this.fromWireType((s?Ae:Be)[l>>1])};case 2:return function(l){return this.fromWireType((s?W:_t)[l>>2])};default:throw new TypeError("Unknown integer type: "+e)}}function ii(e,n){var s=Me[e];return s===void 0&&wt(n+" has unknown type "+jn(e)),s}function Zi(e){if(e===null)return"null";var n=typeof e;return n==="object"||n==="array"||n==="function"?e.toString():""+e}function ws(e,n){switch(n){case 2:return function(s){return this.fromWireType(nt[s>>2])};case 3:return function(s){return this.fromWireType(Tn[s>>3])};default:throw new TypeError("Unknown float type: "+e)}}function Ss(e,n,s){switch(n){case 0:return s?function(l){return pe[l]}:function(l){return ft[l]};case 1:return s?function(l){return Ae[l>>1]}:function(l){return Be[l>>1]};case 2:return s?function(l){return W[l>>2]}:function(l){return _t[l>>2]};default:throw new TypeError("Unknown integer type: "+e)}}var oe=(e,n,s,l)=>{if(!(0<l))return 0;var d=s;l=s+l-1;for(var g=0;g<e.length;++g){var A=e.charCodeAt(g);if(55296<=A&&57343>=A){var y=e.charCodeAt(++g);A=65536+((A&1023)<<10)|y&1023}if(127>=A){if(s>=l)break;n[s++]=A}else{if(2047>=A){if(s+1>=l)break;n[s++]=192|A>>6}else{if(65535>=A){if(s+2>=l)break;n[s++]=224|A>>12}else{if(s+3>=l)break;n[s++]=240|A>>18,n[s++]=128|A>>12&63}n[s++]=128|A>>6&63}n[s++]=128|A&63}}return n[s]=0,s-d},le=e=>{for(var n=0,s=0;s<e.length;++s){var l=e.charCodeAt(s);127>=l?n++:2047>=l?n+=2:55296<=l&&57343>=l?(n+=4,++s):n+=3}return n},Kn=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,bs=(e,n)=>{for(var s=e>>1,l=s+n/2;!(s>=l)&&Be[s];)++s;if(s<<=1,32<s-e&&Kn)return Kn.decode(ft.subarray(e,s));for(s="",l=0;!(l>=n/2);++l){var d=Ae[e+2*l>>1];if(d==0)break;s+=String.fromCharCode(d)}return s},Ps=(e,n,s)=>{if(s===void 0&&(s=2147483647),2>s)return 0;s-=2;var l=n;s=s<2*e.length?s/2:e.length;for(var d=0;d<s;++d)Ae[n>>1]=e.charCodeAt(d),n+=2;return Ae[n>>1]=0,n-l},As=e=>2*e.length,Cs=(e,n)=>{for(var s=0,l="";!(s>=n/4);){var d=W[e+4*s>>2];if(d==0)break;++s,65536<=d?(d-=65536,l+=String.fromCharCode(55296|d>>10,56320|d&1023)):l+=String.fromCharCode(d)}return l},Ts=(e,n,s)=>{if(s===void 0&&(s=2147483647),4>s)return 0;var l=n;s=l+s-4;for(var d=0;d<e.length;++d){var g=e.charCodeAt(d);if(55296<=g&&57343>=g){var A=e.charCodeAt(++d);g=65536+((g&1023)<<10)|A&1023}if(W[n>>2]=g,n+=4,n+4>s)break}return W[n>>2]=0,n-l},_s=e=>{for(var n=0,s=0;s<e.length;++s){var l=e.charCodeAt(s);55296<=l&&57343>=l&&++s,n+=4}return n},Es={};function Ai(e){var n=Es[e];return n===void 0?Ft(e):n}var Ci=[];function Vn(){function e(n){n.$$$embind_global$$$=n;var s=typeof $$$embind_global$$$=="object"&&n.$$$embind_global$$$==n;return s||delete n.$$$embind_global$$$,s}if(typeof globalThis=="object")return globalThis;if(typeof $$$embind_global$$$=="object"||(typeof gn=="object"&&e(gn)?$$$embind_global$$$=gn:typeof self=="object"&&e(self)&&($$$embind_global$$$=self),typeof $$$embind_global$$$=="object"))return $$$embind_global$$$;throw Error("unable to get global object.")}function xs(e){var n=Ci.length;return Ci.push(e),n}function Fs(e,n){for(var s=Array(e),l=0;l<e;++l)s[l]=ii(_t[n+4*l>>2],"parameter "+l);return s}var qn=[];function Ms(e){var n=Array(e+1);return function(s,l,d){n[0]=s;for(var g=0;g<e;++g){var A=ii(_t[l+4*g>>2],"parameter "+g);n[g+1]=A.readValueFromPointer(d),d+=A.argPackAdvance}return s=new(s.bind.apply(s,n)),te(s)}}var Yn={};function Rs(e){var n=e.getExtension("ANGLE_instanced_arrays");n&&(e.vertexAttribDivisor=function(s,l){n.vertexAttribDivisorANGLE(s,l)},e.drawArraysInstanced=function(s,l,d,g){n.drawArraysInstancedANGLE(s,l,d,g)},e.drawElementsInstanced=function(s,l,d,g,A){n.drawElementsInstancedANGLE(s,l,d,g,A)})}function ks(e){var n=e.getExtension("OES_vertex_array_object");n&&(e.createVertexArray=function(){return n.createVertexArrayOES()},e.deleteVertexArray=function(s){n.deleteVertexArrayOES(s)},e.bindVertexArray=function(s){n.bindVertexArrayOES(s)},e.isVertexArray=function(s){return n.isVertexArrayOES(s)})}function Ns(e){var n=e.getExtension("WEBGL_draw_buffers");n&&(e.drawBuffers=function(s,l){n.drawBuffersWEBGL(s,l)})}var Xn=1,Ti=[],he=[],_i=[],ni=[],ee=[],ce=[],Ei=[],ye=[],qt=[],Re=[],ke=[],Jn={},Qn={},Zn=4;function St(e){xi||(xi=e)}function Ne(e){for(var n=Xn++,s=e.length;s<n;s++)e[s]=null;return n}function Is(e,n){e.df||(e.df=e.getContext,e.getContext=function(l,d){return d=e.df(l,d),l=="webgl"==d instanceof WebGLRenderingContext?d:null});var s=1<n.majorVersion?e.getContext("webgl2",n):e.getContext("webgl",n);return s?Os(s,n):0}function Os(e,n){var s=Ne(ye),l={handle:s,attributes:n,version:n.majorVersion,xe:e};return e.canvas&&(e.canvas.Rf=l),ye[s]=l,(typeof n.eg>"u"||n.eg)&&Ds(l),s}function tr(e){return at=ye[e],c.Jg=_=at&&at.xe,!(e&&!_)}function Ds(e){if(e||(e=at),!e.og){e.og=!0;var n=e.xe;Rs(n),ks(n),Ns(n),n.If=n.getExtension("WEBGL_draw_instanced_base_vertex_base_instance"),n.Mf=n.getExtension("WEBGL_multi_draw_instanced_base_vertex_base_instance"),2<=e.version&&(n.ze=n.getExtension("EXT_disjoint_timer_query_webgl2")),(2>e.version||!n.ze)&&(n.ze=n.getExtension("EXT_disjoint_timer_query")),n.Kg=n.getExtension("WEBGL_multi_draw"),(n.getSupportedExtensions()||[]).forEach(function(s){s.includes("lose_context")||s.includes("debug")||n.getExtension(s)})}}var at,xi;function er(e,n){_.bindFramebuffer(e,_i[n])}function ir(e){_.bindVertexArray(Ei[e])}function nr(e){_.clear(e)}function rr(e,n,s,l){_.clearColor(e,n,s,l)}function sr(e){_.clearStencil(e)}function ar(e,n){for(var s=0;s<e;s++){var l=W[n+4*s>>2];_.deleteVertexArray(Ei[l]),Ei[l]=null}}var Fi=[];function or(e,n,s,l){_.drawElements(e,n,s,l)}function Ie(e,n,s,l){for(var d=0;d<e;d++){var g=_[s](),A=g&&Ne(l);g?(g.name=A,l[A]=g):St(1282),W[n+4*d>>2]=A}}function lr(e,n){Ie(e,n,"createVertexArray",Ei)}function hr(e,n){_t[e>>2]=n,_t[e+4>>2]=(n-_t[e>>2])/4294967296}function cr(e,n,s){if(n){var l=void 0;switch(e){case 36346:l=1;break;case 36344:s!=0&&s!=1&&St(1280);return;case 34814:case 36345:l=0;break;case 34466:var d=_.getParameter(34467);l=d?d.length:0;break;case 33309:if(2>at.version){St(1282);return}l=2*(_.getSupportedExtensions()||[]).length;break;case 33307:case 33308:if(2>at.version){St(1280);return}l=e==33307?3:0}if(l===void 0)switch(d=_.getParameter(e),typeof d){case"number":l=d;break;case"boolean":l=d?1:0;break;case"string":St(1280);return;case"object":if(d===null)switch(e){case 34964:case 35725:case 34965:case 36006:case 36007:case 32873:case 34229:case 36662:case 36663:case 35053:case 35055:case 36010:case 35097:case 35869:case 32874:case 36389:case 35983:case 35368:case 34068:l=0;break;default:St(1280);return}else{if(d instanceof Float32Array||d instanceof Uint32Array||d instanceof Int32Array||d instanceof Array){for(e=0;e<d.length;++e)switch(s){case 0:W[n+4*e>>2]=d[e];break;case 2:nt[n+4*e>>2]=d[e];break;case 4:pe[n+e>>0]=d[e]?1:0}return}try{l=d.name|0}catch(g){St(1280),Pe("GL_INVALID_ENUM in glGet"+s+"v: Unknown object returned from WebGL getParameter("+e+")! (error: "+g+")");return}}break;default:St(1280),Pe("GL_INVALID_ENUM in glGet"+s+"v: Native code calling glGet"+s+"v("+e+") and it returns "+d+" of type "+typeof d+"!");return}switch(s){case 1:hr(n,l);break;case 0:W[n>>2]=l;break;case 2:nt[n>>2]=l;break;case 4:pe[n>>0]=l?1:0}}else St(1281)}function ur(e,n){cr(e,n,0)}function dr(e,n,s){if(s){e=qt[e],n=2>at.version?_.ze.getQueryObjectEXT(e,n):_.getQueryParameter(e,n);var l;typeof n=="boolean"?l=n?1:0:l=n,hr(s,l)}else St(1281)}var ri=e=>{var n=le(e)+1,s=Ni(n);return s&&oe(e,ft,s,n),s};function fr(e){var n=Jn[e];if(!n){switch(e){case 7939:n=_.getSupportedExtensions()||[],n=n.concat(n.map(function(l){return"GL_"+l})),n=ri(n.join(" "));break;case 7936:case 7937:case 37445:case 37446:(n=_.getParameter(e))||St(1280),n=n&&ri(n);break;case 7938:n=_.getParameter(7938),n=2<=at.version?"OpenGL ES 3.0 ("+n+")":"OpenGL ES 2.0 ("+n+")",n=ri(n);break;case 35724:n=_.getParameter(35724);var s=n.match(/^WebGL GLSL ES ([0-9]\.[0-9][0-9]?)(?:$| .*)/);s!==null&&(s[1].length==3&&(s[1]+="0"),n="OpenGL ES GLSL ES "+s[1]+" ("+n+")"),n=ri(n);break;default:St(1280)}Jn[e]=n}return n}function pr(e,n){if(2>at.version)return St(1282),0;var s=Qn[e];if(s)return 0>n||n>=s.length?(St(1281),0):s[n];switch(e){case 7939:return s=_.getSupportedExtensions()||[],s=s.concat(s.map(function(l){return"GL_"+l})),s=s.map(function(l){return ri(l)}),s=Qn[e]=s,0>n||n>=s.length?(St(1281),0):s[n];default:return St(1280),0}}function gr(e){return e.slice(-1)=="]"&&e.lastIndexOf("[")}function Mi(e){return e-=5120,e==0?pe:e==1?ft:e==2?Ae:e==4?W:e==6?nt:e==5||e==28922||e==28520||e==30779||e==30782?_t:Be}function tn(e,n,s,l,d){e=Mi(e);var g=31-Math.clz32(e.BYTES_PER_ELEMENT),A=Zn;return e.subarray(d>>g,d+l*(s*({5:3,6:4,8:2,29502:3,29504:4,26917:2,26918:2,29846:3,29847:4}[n-6402]||1)*(1<<g)+A-1&-A)>>g)}function At(e){var n=_.bg;if(n){var s=n.ff[e];return typeof s=="number"&&(n.ff[e]=s=_.getUniformLocation(n,n.Pf[e]+(0<s?"["+s+"]":""))),s}St(1282)}var Te=[],si=[],en={},mr=()=>{if(!nn){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:G||"./this.program"},n;for(n in en)en[n]===void 0?delete e[n]:e[n]=en[n];var s=[];for(n in e)s.push(`${n}=${e[n]}`);nn=s}return nn},nn,zs=[null,[],[]],Ri=e=>e%4===0&&(e%100!==0||e%400===0),yr=[31,29,31,30,31,30,31,31,30,31,30,31],vr=[31,28,31,30,31,30,31,31,30,31,30,31];function Ls(e){var n=Array(le(e)+1);return oe(e,n,0,n.length),n}var Bs=(e,n,s,l)=>{function d(F,J,ht){for(F=typeof F=="number"?F.toString():F||"";F.length<J;)F=ht[0]+F;return F}function g(F,J){return d(F,J,"0")}function A(F,J){function ht(Ht){return 0>Ht?-1:0<Ht?1:0}var ot;return(ot=ht(F.getFullYear()-J.getFullYear()))===0&&(ot=ht(F.getMonth()-J.getMonth()))===0&&(ot=ht(F.getDate()-J.getDate())),ot}function y(F){switch(F.getDay()){case 0:return new Date(F.getFullYear()-1,11,29);case 1:return F;case 2:return new Date(F.getFullYear(),0,3);case 3:return new Date(F.getFullYear(),0,2);case 4:return new Date(F.getFullYear(),0,1);case 5:return new Date(F.getFullYear()-1,11,31);case 6:return new Date(F.getFullYear()-1,11,30)}}function v(F){var J=F.He;for(F=new Date(new Date(F.Ie+1900,0,1).getTime());0<J;){var ht=F.getMonth(),ot=(Ri(F.getFullYear())?yr:vr)[ht];if(J>ot-F.getDate())J-=ot-F.getDate()+1,F.setDate(1),11>ht?F.setMonth(ht+1):(F.setMonth(0),F.setFullYear(F.getFullYear()+1));else{F.setDate(F.getDate()+J);break}}return ht=new Date(F.getFullYear()+1,0,4),J=y(new Date(F.getFullYear(),0,4)),ht=y(ht),0>=A(J,F)?0>=A(ht,F)?F.getFullYear()+1:F.getFullYear():F.getFullYear()-1}var T=W[l+40>>2];l={Hg:W[l>>2],Gg:W[l+4>>2],tf:W[l+8>>2],Df:W[l+12>>2],uf:W[l+16>>2],Ie:W[l+20>>2],Ae:W[l+24>>2],He:W[l+28>>2],Ng:W[l+32>>2],Fg:W[l+36>>2],Ig:T&&T?Fe(ft,T):""},s=s?Fe(ft,s):"",T={"%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 D in T)s=s.replace(new RegExp(D,"g"),T[D]);var L="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),Y="January February March April May June July August September October November December".split(" ");T={"%a":F=>L[F.Ae].substring(0,3),"%A":F=>L[F.Ae],"%b":F=>Y[F.uf].substring(0,3),"%B":F=>Y[F.uf],"%C":F=>g((F.Ie+1900)/100|0,2),"%d":F=>g(F.Df,2),"%e":F=>d(F.Df,2," "),"%g":F=>v(F).toString().substring(2),"%G":F=>v(F),"%H":F=>g(F.tf,2),"%I":F=>(F=F.tf,F==0?F=12:12<F&&(F-=12),g(F,2)),"%j":F=>{for(var J=0,ht=0;ht<=F.uf-1;J+=(Ri(F.Ie+1900)?yr:vr)[ht++]);return g(F.Df+J,3)},"%m":F=>g(F.uf+1,2),"%M":F=>g(F.Gg,2),"%n":()=>`
3
+ `,"%p":F=>0<=F.tf&&12>F.tf?"AM":"PM","%S":F=>g(F.Hg,2),"%t":()=>" ","%u":F=>F.Ae||7,"%U":F=>g(Math.floor((F.He+7-F.Ae)/7),2),"%V":F=>{var J=Math.floor((F.He+7-(F.Ae+6)%7)/7);if(2>=(F.Ae+371-F.He-2)%7&&J++,J)J==53&&(ht=(F.Ae+371-F.He)%7,ht==4||ht==3&&Ri(F.Ie)||(J=1));else{J=52;var ht=(F.Ae+7-F.He-1)%7;(ht==4||ht==5&&Ri(F.Ie%400-1))&&J++}return g(J,2)},"%w":F=>F.Ae,"%W":F=>g(Math.floor((F.He+7-(F.Ae+6)%7)/7),2),"%y":F=>(F.Ie+1900).toString().substring(2),"%Y":F=>F.Ie+1900,"%z":F=>{F=F.Fg;var J=0<=F;return F=Math.abs(F)/60,(J?"+":"-")+("0000"+(F/60*100+F%60)).slice(-4)},"%Z":F=>F.Ig,"%%":()=>"%"},s=s.replace(/%%/g,"\0\0");for(D in T)s.includes(D)&&(s=s.replace(new RegExp(D,"g"),T[D](l)));return s=s.replace(/\0\0/g,"%"),D=Ls(s),D.length>n?0:(pe.set(D,e),D.length-1)};On=c.InternalError=class extends Error{constructor(e){super(e),this.name="InternalError"}};for(var wr=Array(256),ki=0;256>ki;++ki)wr[ki]=String.fromCharCode(ki);Dn=wr,Ge=c.BindingError=class extends Error{constructor(e){super(e),this.name="BindingError"}},Ce.prototype.isAliasOf=function(e){if(!(this instanceof Ce&&e instanceof Ce))return!1;var n=this.ae.me.ge,s=this.ae.ie,l=e.ae.me.ge;for(e=e.ae.ie;n.re;)s=n.gf(s),n=n.re;for(;l.re;)e=l.gf(e),l=l.re;return n===l&&s===e},Ce.prototype.clone=function(){if(this.ae.ie||Hi(this),this.ae.ef)return this.ae.count.value+=1,this;var e=ti,n=Object,s=n.create,l=Object.getPrototypeOf(this),d=this.ae;return e=e(s.call(n,l,{ae:{value:{count:d.count,Xe:d.Xe,ef:d.ef,ie:d.ie,me:d.me,pe:d.pe,we:d.we}}})),e.ae.count.value+=1,e.ae.Xe=!1,e},Ce.prototype.delete=function(){this.ae.ie||Hi(this),this.ae.Xe&&!this.ae.ef&&wt("Object already scheduled for deletion"),zn(this),Ln(this.ae),this.ae.ef||(this.ae.pe=void 0,this.ae.ie=void 0)},Ce.prototype.isDeleted=function(){return!this.ae.ie},Ce.prototype.deleteLater=function(){return this.ae.ie||Hi(this),this.ae.Xe&&!this.ae.ef&&wt("Object already scheduled for deletion"),Je.push(this),Je.length===1&&Qe&&Qe(Vi),this.ae.Xe=!0,this},c.getInheritedInstanceCount=function(){return Object.keys(Ze).length},c.getLiveInheritedInstances=function(){var e=[],n;for(n in Ze)Ze.hasOwnProperty(n)&&e.push(Ze[n]);return e},c.flushPendingDeletes=Vi,c.setDelayFunction=function(e){Qe=e,Je.length&&Qe&&Qe(Vi)},me.prototype.jg=function(e){return this.Nf&&(e=this.Nf(e)),e},me.prototype.Hf=function(e){this.De&&this.De(e)},me.prototype.argPackAdvance=8,me.prototype.readValueFromPointer=Xe,me.prototype.deleteObject=function(e){e!==null&&e.delete()},me.prototype.fromWireType=function(e){function n(){return this.pf?Si(this.ge.Ye,{me:this.tg,ie:s,we:this,pe:e}):Si(this.ge.Ye,{me:this,ie:e})}var s=this.jg(e);if(!s)return this.Hf(e),null;var l=ds(this.ge,s);if(l!==void 0)return l.ae.count.value===0?(l.ae.ie=s,l.ae.pe=e,l.clone()):(l=l.clone(),this.Hf(e),l);if(l=this.ge.ig(s),l=Un[l],!l)return n.call(this);l=this.nf?l.$f:l.pointerType;var d=Bn(s,this.ge,l.ge);return d===null?n.call(this):this.pf?Si(l.ge.Ye,{me:l,ie:d,we:this,pe:e}):Si(l.ge.Ye,{me:l,ie:d})},Wn=c.UnboundTypeError=function(e,n){var s=qi(n,function(l){this.name=n,this.message=l,l=Error(l).stack,l!==void 0&&(this.stack=this.toString()+`
4
+ `+l.replace(/^Error(:[^\n]*)?\n/,""))});return s.prototype=Object.create(e.prototype),s.prototype.constructor=s,s.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},s}(Error,"UnboundTypeError"),Object.assign(Hn.prototype,{get(e){return this.Ce[e]},has(e){return this.Ce[e]!==void 0},Yf(e){var n=this.Kf.pop()||this.Ce.length;return this.Ce[n]=e,n},Zf(e){this.Ce[e]=void 0,this.Kf.push(e)}}),Qt.Ce.push({value:void 0},{value:null},{value:!0},{value:!1}),Qt.df=Qt.Ce.length,c.count_emval_handles=function(){for(var e=0,n=Qt.df;n<Qt.Ce.length;++n)Qt.Ce[n]!==void 0&&++e;return e};for(var _,Yt=0;32>Yt;++Yt)Fi.push(Array(Yt));var Us=new Float32Array(288);for(Yt=0;288>Yt;++Yt)Te[Yt]=Us.subarray(0,Yt+1);var $s=new Int32Array(288);for(Yt=0;288>Yt;++Yt)si[Yt]=$s.subarray(0,Yt+1);var Gs={R:function(){return 0},wb:()=>{},yb:function(){return 0},tb:()=>{},ub:()=>{},S:function(){},vb:()=>{},B:function(e){var n=mi[e];delete mi[e];var s=n.Cf,l=n.De,d=n.Jf,g=d.map(A=>A.mg).concat(d.map(A=>A.xg));ae([e],g,A=>{var y={};return d.forEach((v,T)=>{var D=A[T],L=v.kg,Y=v.lg,F=A[T+d.length],J=v.wg,ht=v.yg;y[v.fg]={read:ot=>D.fromWireType(L(Y,ot)),write:(ot,Ht)=>{var Lt=[];J(ht,ot,F.toWireType(Lt,Ht)),ji(Lt)}}}),[{name:n.name,fromWireType:function(v){var T={},D;for(D in y)T[D]=y[D].read(v);return l(v),T},toWireType:function(v,T){for(var D in y)if(!(D in T))throw new TypeError(`Missing field: "${D}"`);var L=s();for(D in y)y[D].write(L,T[D]);return v!==null&&v.push(l,L),L},argPackAdvance:8,readValueFromPointer:Xe,ve:l}]})},nb:function(){},Cb:function(e,n,s,l,d){var g=wi(s);n=Ft(n),ge(e,{name:n,fromWireType:function(A){return!!A},toWireType:function(A,y){return y?l:d},argPackAdvance:8,readValueFromPointer:function(A){if(s===1)var y=pe;else if(s===2)y=Ae;else if(s===4)y=W;else throw new TypeError("Unknown boolean type size: "+n);return this.fromWireType(y[A>>g])},ve:null})},n:function(e,n,s,l,d,g,A,y,v,T,D,L,Y){D=Ft(D),g=Ut(d,g),y&&(y=Ut(A,y)),T&&(T=Ut(v,T)),Y=Ut(L,Y);var F=$n(D);Xi(F,function(){ei(`Cannot construct ${D} due to unbound types`,[l])}),ae([e,n,s],l?[l]:[],function(J){if(J=J[0],l)var ht=J.ge,ot=ht.Ye;else ot=Ce.prototype;J=qi(F,function(){if(Object.getPrototypeOf(this)!==Ht)throw new Ge("Use 'new' to construct "+D);if(Lt.Ge===void 0)throw new Ge(D+" has no accessible constructor");var oi=Lt.Ge[arguments.length];if(oi===void 0)throw new Ge(`Tried to invoke ctor of ${D} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(Lt.Ge).toString()}) parameters instead!`);return oi.apply(this,arguments)});var Ht=Object.create(ot,{constructor:{value:J}});J.prototype=Ht;var Lt=new fs(D,J,Ht,Y,ht,g,y,T);Lt.re&&(Lt.re.hf===void 0&&(Lt.re.hf=[]),Lt.re.hf.push(Lt)),ht=new me(D,Lt,!0,!1,!1),ot=new me(D+"*",Lt,!1,!1,!1);var ai=new me(D+" const*",Lt,!1,!0,!1);return Un[e]={pointerType:ot,$f:ai},Gn(F,J),[ht,ot,ai]})},f:function(e,n,s,l,d,g,A){var y=Pi(s,l);n=Ft(n),g=Ut(d,g),ae([],[e],function(v){function T(){ei(`Cannot call ${D} due to unbound types`,y)}v=v[0];var D=`${v.name}.${n}`;n.startsWith("@@")&&(n=Symbol[n.substring(2)]);var L=v.ge.constructor;return L[n]===void 0?(T.Ve=s-1,L[n]=T):(Yi(L,n,D),L[n].oe[s-1]=T),ae([],y,function(Y){if(Y=[Y[0],null].concat(Y.slice(1)),Y=bi(D,Y,null,g,A),L[n].oe===void 0?(Y.Ve=s-1,L[n]=Y):L[n].oe[s-1]=Y,v.ge.hf)for(const F of v.ge.hf)F.constructor.hasOwnProperty(n)||(F.constructor[n]=Y);return[]}),[]})},A:function(e,n,s,l,d,g){var A=Pi(n,s);d=Ut(l,d),ae([],[e],function(y){y=y[0];var v=`constructor ${y.name}`;if(y.ge.Ge===void 0&&(y.ge.Ge=[]),y.ge.Ge[n-1]!==void 0)throw new Ge(`Cannot register multiple constructors with identical number of parameters (${n-1}) for class '${y.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return y.ge.Ge[n-1]=()=>{ei(`Cannot construct ${y.name} due to unbound types`,A)},ae([],A,function(T){return T.splice(1,0,null),y.ge.Ge[n-1]=bi(v,T,null,d,g),[]}),[]})},b:function(e,n,s,l,d,g,A,y){var v=Pi(s,l);n=Ft(n),g=Ut(d,g),ae([],[e],function(T){function D(){ei(`Cannot call ${L} due to unbound types`,v)}T=T[0];var L=`${T.name}.${n}`;n.startsWith("@@")&&(n=Symbol[n.substring(2)]),y&&T.ge.ug.push(n);var Y=T.ge.Ye,F=Y[n];return F===void 0||F.oe===void 0&&F.className!==T.name&&F.Ve===s-2?(D.Ve=s-2,D.className=T.name,Y[n]=D):(Yi(Y,n,L),Y[n].oe[s-2]=D),ae([],v,function(J){return J=bi(L,J,T,g,A),Y[n].oe===void 0?(J.Ve=s-2,Y[n]=J):Y[n].oe[s-2]=J,[]}),[]})},t:function(e,n,s){e=Ft(e),ae([],[n],function(l){return l=l[0],c[e]=l.fromWireType(s),[]})},Bb:function(e,n){n=Ft(n),ge(e,{name:n,fromWireType:function(s){var l=Zt(s);return Qi(s),l},toWireType:function(s,l){return te(l)},argPackAdvance:8,readValueFromPointer:Xe,ve:null})},m:function(e,n,s,l){function d(){}s=wi(s),n=Ft(n),d.values={},ge(e,{name:n,constructor:d,fromWireType:function(g){return this.constructor.values[g]},toWireType:function(g,A){return A.value},argPackAdvance:8,readValueFromPointer:vs(n,s,l),ve:null}),Xi(n,d)},c:function(e,n,s){var l=ii(e,"enum");n=Ft(n),e=l.constructor,l=Object.create(l.constructor.prototype,{value:{value:s},constructor:{value:qi(`${l.name}_${n}`,function(){})}}),e.values[s]=l,e[n]=l},U:function(e,n,s){s=wi(s),n=Ft(n),ge(e,{name:n,fromWireType:function(l){return l},toWireType:function(l,d){return d},argPackAdvance:8,readValueFromPointer:ws(n,s),ve:null})},y:function(e,n,s,l,d,g){var A=Pi(n,s);e=Ft(e),d=Ut(l,d),Xi(e,function(){ei(`Cannot call ${e} due to unbound types`,A)},n-1),ae([],A,function(y){return y=[y[0],null].concat(y.slice(1)),Gn(e,bi(e,y,null,d,g),n-1),[]})},E:function(e,n,s,l,d){n=Ft(n),d===-1&&(d=4294967295),d=wi(s);var g=y=>y;if(l===0){var A=32-8*s;g=y=>y<<A>>>A}s=n.includes("unsigned")?function(y,v){return v>>>0}:function(y,v){return v},ge(e,{name:n,fromWireType:g,toWireType:s,argPackAdvance:8,readValueFromPointer:Ss(n,d,l!==0),ve:null})},r:function(e,n,s){function l(g){g>>=2;var A=_t;return new d(A.buffer,A[g+1],A[g])}var d=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][n];s=Ft(s),ge(e,{name:s,fromWireType:l,argPackAdvance:8,readValueFromPointer:l},{ng:!0})},q:function(e,n,s,l,d,g,A,y,v,T,D,L){s=Ft(s),g=Ut(d,g),y=Ut(A,y),T=Ut(v,T),L=Ut(D,L),ae([e],[n],function(Y){return Y=Y[0],[new me(s,Y.ge,!1,!1,!0,Y,l,g,y,T,L)]})},T:function(e,n){n=Ft(n);var s=n==="std::string";ge(e,{name:n,fromWireType:function(l){var d=_t[l>>2],g=l+4;if(s)for(var A=g,y=0;y<=d;++y){var v=g+y;if(y==d||ft[v]==0){if(A=A?Fe(ft,A,v-A):"",T===void 0)var T=A;else T+="\0",T+=A;A=v+1}}else{for(T=Array(d),y=0;y<d;++y)T[y]=String.fromCharCode(ft[g+y]);T=T.join("")}return we(l),T},toWireType:function(l,d){d instanceof ArrayBuffer&&(d=new Uint8Array(d));var g=typeof d=="string";g||d instanceof Uint8Array||d instanceof Uint8ClampedArray||d instanceof Int8Array||wt("Cannot pass non-string to std::string");var A=s&&g?le(d):d.length,y=Ni(4+A+1),v=y+4;if(_t[y>>2]=A,s&&g)oe(d,ft,v,A+1);else if(g)for(g=0;g<A;++g){var T=d.charCodeAt(g);255<T&&(we(v),wt("String has UTF-16 code units that do not fit in 8 bits")),ft[v+g]=T}else for(g=0;g<A;++g)ft[v+g]=d[g];return l!==null&&l.push(we,y),y},argPackAdvance:8,readValueFromPointer:Xe,ve:function(l){we(l)}})},N:function(e,n,s){if(s=Ft(s),n===2)var l=bs,d=Ps,g=As,A=()=>Be,y=1;else n===4&&(l=Cs,d=Ts,g=_s,A=()=>_t,y=2);ge(e,{name:s,fromWireType:function(v){for(var T=_t[v>>2],D=A(),L,Y=v+4,F=0;F<=T;++F){var J=v+4+F*n;(F==T||D[J>>y]==0)&&(Y=l(Y,J-Y),L===void 0?L=Y:(L+="\0",L+=Y),Y=J+n)}return we(v),L},toWireType:function(v,T){typeof T!="string"&&wt(`Cannot pass non-string to C++ string type ${s}`);var D=g(T),L=Ni(4+D+n);return _t[L>>2]=D>>y,d(T,L+4,D+n),v!==null&&v.push(we,L),L},argPackAdvance:8,readValueFromPointer:Xe,ve:function(v){we(v)}})},C:function(e,n,s,l,d,g){mi[e]={name:Ft(n),Cf:Ut(s,l),De:Ut(d,g),Jf:[]}},e:function(e,n,s,l,d,g,A,y,v,T){mi[e].Jf.push({fg:Ft(n),mg:s,kg:Ut(l,d),lg:g,xg:A,wg:Ut(y,v),yg:T})},Db:function(e,n){n=Ft(n),ge(e,{pg:!0,name:n,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},Ab:()=>!0,pb:()=>{throw 1/0},F:function(e,n,s){e=Zt(e),n=ii(n,"emval::as");var l=[],d=te(l);return _t[s>>2]=d,n.toWireType(l,e)},X:function(e,n,s,l,d){e=Ci[e],n=Zt(n),s=Ai(s);var g=[];return _t[l>>2]=te(g),e(n,s,g,d)},x:function(e,n,s,l){e=Ci[e],n=Zt(n),s=Ai(s),e(n,s,null,l)},d:Qi,K:function(e){return e===0?te(Vn()):(e=Ai(e),te(Vn()[e]))},u:function(e,n){var s=Fs(e,n),l=s[0];n=l.name+"_$"+s.slice(1).map(function(A){return A.name}).join("_")+"$";var d=qn[n];if(d!==void 0)return d;var g=Array(e-1);return d=xs((A,y,v,T)=>{for(var D=0,L=0;L<e-1;++L)g[L]=s[L+1].readValueFromPointer(T+D),D+=s[L+1].argPackAdvance;for(A=A[y].apply(A,g),L=0;L<e-1;++L)s[L+1].cg&&s[L+1].cg(g[L]);if(!l.pg)return l.toWireType(v,A)}),qn[n]=d},z:function(e,n){return e=Zt(e),n=Zt(n),te(e[n])},p:function(e){4<e&&(Qt.get(e).Of+=1)},J:function(e,n,s,l){e=Zt(e);var d=Yn[n];return d||(d=Ms(n),Yn[n]=d),d(e,s,l)},H:function(){return te([])},g:function(e){return te(Ai(e))},G:function(){return te({})},gb:function(e){return e=Zt(e),!e},D:function(e){var n=Zt(e);ji(n),Qi(e)},l:function(e,n,s){e=Zt(e),n=Zt(n),s=Zt(s),e[n]=s},h:function(e,n){return e=ii(e,"_emval_take_value"),e=e.readValueFromPointer(n),te(e)},kb:function(){return-52},lb:function(){},a:()=>{Gi("")},zb:()=>performance.now(),sd:function(e){_.activeTexture(e)},td:function(e,n){_.attachShader(he[e],ce[n])},Yb:function(e,n){_.beginQuery(e,qt[n])},Sb:function(e,n){_.ze.beginQueryEXT(e,qt[n])},ud:function(e,n,s){_.bindAttribLocation(he[e],n,s?Fe(ft,s):"")},vd:function(e,n){e==35051?_.zf=n:e==35052&&(_.We=n),_.bindBuffer(e,Ti[n])},uc:er,vc:function(e,n){_.bindRenderbuffer(e,ni[n])},cc:function(e,n){_.bindSampler(e,Re[n])},wd:function(e,n){_.bindTexture(e,ee[n])},Pc:ir,Tc:ir,Y:function(e,n,s,l){_.blendColor(e,n,s,l)},Z:function(e){_.blendEquation(e)},_:function(e,n){_.blendFunc(e,n)},oc:function(e,n,s,l,d,g,A,y,v,T){_.blitFramebuffer(e,n,s,l,d,g,A,y,v,T)},$:function(e,n,s,l){2<=at.version?s&&n?_.bufferData(e,ft,l,s,n):_.bufferData(e,n,l):_.bufferData(e,s?ft.subarray(s,s+n):n,l)},aa:function(e,n,s,l){2<=at.version?s&&_.bufferSubData(e,n,ft,l,s):_.bufferSubData(e,n,ft.subarray(l,l+s))},wc:function(e){return _.checkFramebufferStatus(e)},ba:nr,ca:rr,da:sr,lc:function(e,n,s,l){return _.clientWaitSync(ke[e],n,(s>>>0)+4294967296*l)},ea:function(e,n,s,l){_.colorMask(!!e,!!n,!!s,!!l)},fa:function(e){_.compileShader(ce[e])},ga:function(e,n,s,l,d,g,A,y){2<=at.version?_.We||!A?_.compressedTexImage2D(e,n,s,l,d,g,A,y):_.compressedTexImage2D(e,n,s,l,d,g,ft,y,A):_.compressedTexImage2D(e,n,s,l,d,g,y?ft.subarray(y,y+A):null)},ha:function(e,n,s,l,d,g,A,y,v){2<=at.version?_.We||!y?_.compressedTexSubImage2D(e,n,s,l,d,g,A,y,v):_.compressedTexSubImage2D(e,n,s,l,d,g,A,ft,v,y):_.compressedTexSubImage2D(e,n,s,l,d,g,A,v?ft.subarray(v,v+y):null)},nc:function(e,n,s,l,d){_.copyBufferSubData(e,n,s,l,d)},ia:function(e,n,s,l,d,g,A,y){_.copyTexSubImage2D(e,n,s,l,d,g,A,y)},ja:function(){var e=Ne(he),n=_.createProgram();return n.name=e,n.sf=n.qf=n.rf=0,n.Ef=1,he[e]=n,e},ka:function(e){var n=Ne(ce);return ce[n]=_.createShader(e),n},la:function(e){_.cullFace(e)},ma:function(e,n){for(var s=0;s<e;s++){var l=W[n+4*s>>2],d=Ti[l];d&&(_.deleteBuffer(d),d.name=0,Ti[l]=null,l==_.zf&&(_.zf=0),l==_.We&&(_.We=0))}},xc:function(e,n){for(var s=0;s<e;++s){var l=W[n+4*s>>2],d=_i[l];d&&(_.deleteFramebuffer(d),d.name=0,_i[l]=null)}},na:function(e){if(e){var n=he[e];n?(_.deleteProgram(n),n.name=0,he[e]=null):St(1281)}},Zb:function(e,n){for(var s=0;s<e;s++){var l=W[n+4*s>>2],d=qt[l];d&&(_.deleteQuery(d),qt[l]=null)}},Tb:function(e,n){for(var s=0;s<e;s++){var l=W[n+4*s>>2],d=qt[l];d&&(_.ze.deleteQueryEXT(d),qt[l]=null)}},yc:function(e,n){for(var s=0;s<e;s++){var l=W[n+4*s>>2],d=ni[l];d&&(_.deleteRenderbuffer(d),d.name=0,ni[l]=null)}},dc:function(e,n){for(var s=0;s<e;s++){var l=W[n+4*s>>2],d=Re[l];d&&(_.deleteSampler(d),d.name=0,Re[l]=null)}},oa:function(e){if(e){var n=ce[e];n?(_.deleteShader(n),ce[e]=null):St(1281)}},mc:function(e){if(e){var n=ke[e];n?(_.deleteSync(n),n.name=0,ke[e]=null):St(1281)}},pa:function(e,n){for(var s=0;s<e;s++){var l=W[n+4*s>>2],d=ee[l];d&&(_.deleteTexture(d),d.name=0,ee[l]=null)}},Qc:ar,Uc:ar,qa:function(e){_.depthMask(!!e)},ra:function(e){_.disable(e)},sa:function(e){_.disableVertexAttribArray(e)},ta:function(e,n,s){_.drawArrays(e,n,s)},Nc:function(e,n,s,l){_.drawArraysInstanced(e,n,s,l)},Lc:function(e,n,s,l,d){_.If.drawArraysInstancedBaseInstanceWEBGL(e,n,s,l,d)},Jc:function(e,n){for(var s=Fi[e],l=0;l<e;l++)s[l]=W[n+4*l>>2];_.drawBuffers(s)},ua:or,Oc:function(e,n,s,l,d){_.drawElementsInstanced(e,n,s,l,d)},Mc:function(e,n,s,l,d,g,A){_.If.drawElementsInstancedBaseVertexBaseInstanceWEBGL(e,n,s,l,d,g,A)},Dc:function(e,n,s,l,d,g){or(e,l,d,g)},va:function(e){_.enable(e)},wa:function(e){_.enableVertexAttribArray(e)},_b:function(e){_.endQuery(e)},Ub:function(e){_.ze.endQueryEXT(e)},ic:function(e,n){return(e=_.fenceSync(e,n))?(n=Ne(ke),e.name=n,ke[n]=e,n):0},xa:function(){_.finish()},ya:function(){_.flush()},zc:function(e,n,s,l){_.framebufferRenderbuffer(e,n,s,ni[l])},Ac:function(e,n,s,l,d){_.framebufferTexture2D(e,n,s,ee[l],d)},za:function(e){_.frontFace(e)},Aa:function(e,n){Ie(e,n,"createBuffer",Ti)},Bc:function(e,n){Ie(e,n,"createFramebuffer",_i)},$b:function(e,n){Ie(e,n,"createQuery",qt)},Vb:function(e,n){for(var s=0;s<e;s++){var l=_.ze.createQueryEXT();if(!l){for(St(1282);s<e;)W[n+4*s++>>2]=0;break}var d=Ne(qt);l.name=d,qt[d]=l,W[n+4*s>>2]=d}},Cc:function(e,n){Ie(e,n,"createRenderbuffer",ni)},ec:function(e,n){Ie(e,n,"createSampler",Re)},Ba:function(e,n){Ie(e,n,"createTexture",ee)},Rc:lr,Vc:lr,qc:function(e){_.generateMipmap(e)},Ca:function(e,n,s){s?W[s>>2]=_.getBufferParameter(e,n):St(1281)},Da:function(){var e=_.getError()||xi;return xi=0,e},Ea:function(e,n){cr(e,n,2)},rc:function(e,n,s,l){e=_.getFramebufferAttachmentParameter(e,n,s),(e instanceof WebGLRenderbuffer||e instanceof WebGLTexture)&&(e=e.name|0),W[l>>2]=e},Fa:ur,Ga:function(e,n,s,l){e=_.getProgramInfoLog(he[e]),e===null&&(e="(unknown error)"),n=0<n&&l?oe(e,ft,l,n):0,s&&(W[s>>2]=n)},Ha:function(e,n,s){if(s)if(e>=Xn)St(1281);else if(e=he[e],n==35716)e=_.getProgramInfoLog(e),e===null&&(e="(unknown error)"),W[s>>2]=e.length+1;else if(n==35719){if(!e.sf)for(n=0;n<_.getProgramParameter(e,35718);++n)e.sf=Math.max(e.sf,_.getActiveUniform(e,n).name.length+1);W[s>>2]=e.sf}else if(n==35722){if(!e.qf)for(n=0;n<_.getProgramParameter(e,35721);++n)e.qf=Math.max(e.qf,_.getActiveAttrib(e,n).name.length+1);W[s>>2]=e.qf}else if(n==35381){if(!e.rf)for(n=0;n<_.getProgramParameter(e,35382);++n)e.rf=Math.max(e.rf,_.getActiveUniformBlockName(e,n).length+1);W[s>>2]=e.rf}else W[s>>2]=_.getProgramParameter(e,n);else St(1281)},Pb:dr,Qb:dr,ac:function(e,n,s){if(s){e=_.getQueryParameter(qt[e],n);var l;typeof e=="boolean"?l=e?1:0:l=e,W[s>>2]=l}else St(1281)},Wb:function(e,n,s){if(s){e=_.ze.getQueryObjectEXT(qt[e],n);var l;typeof e=="boolean"?l=e?1:0:l=e,W[s>>2]=l}else St(1281)},bc:function(e,n,s){s?W[s>>2]=_.getQuery(e,n):St(1281)},Xb:function(e,n,s){s?W[s>>2]=_.ze.getQueryEXT(e,n):St(1281)},sc:function(e,n,s){s?W[s>>2]=_.getRenderbufferParameter(e,n):St(1281)},Ia:function(e,n,s,l){e=_.getShaderInfoLog(ce[e]),e===null&&(e="(unknown error)"),n=0<n&&l?oe(e,ft,l,n):0,s&&(W[s>>2]=n)},Mb:function(e,n,s,l){e=_.getShaderPrecisionFormat(e,n),W[s>>2]=e.rangeMin,W[s+4>>2]=e.rangeMax,W[l>>2]=e.precision},Ja:function(e,n,s){s?n==35716?(e=_.getShaderInfoLog(ce[e]),e===null&&(e="(unknown error)"),W[s>>2]=e?e.length+1:0):n==35720?(e=_.getShaderSource(ce[e]),W[s>>2]=e?e.length+1:0):W[s>>2]=_.getShaderParameter(ce[e],n):St(1281)},Ka:fr,Sc:pr,La:function(e,n){if(n=n?Fe(ft,n):"",e=he[e]){var s=e,l=s.ff,d=s.Qf,g;if(!l)for(s.ff=l={},s.Pf={},g=0;g<_.getProgramParameter(s,35718);++g){var A=_.getActiveUniform(s,g),y=A.name;A=A.size;var v=gr(y);v=0<v?y.slice(0,v):y;var T=s.Ef;for(s.Ef+=A,d[v]=[A,T],y=0;y<A;++y)l[T]=y,s.Pf[T++]=v}if(s=e.ff,l=0,d=n,g=gr(n),0<g&&(l=parseInt(n.slice(g+1))>>>0,d=n.slice(0,g)),(d=e.Qf[d])&&l<d[0]&&(l+=d[1],s[l]=s[l]||_.getUniformLocation(e,n)))return l}else St(1281);return-1},Nb:function(e,n,s){for(var l=Fi[n],d=0;d<n;d++)l[d]=W[s+4*d>>2];_.invalidateFramebuffer(e,l)},Ob:function(e,n,s,l,d,g,A){for(var y=Fi[n],v=0;v<n;v++)y[v]=W[s+4*v>>2];_.invalidateSubFramebuffer(e,y,l,d,g,A)},jc:function(e){return _.isSync(ke[e])},Ma:function(e){return(e=ee[e])?_.isTexture(e):0},Na:function(e){_.lineWidth(e)},Oa:function(e){e=he[e],_.linkProgram(e),e.ff=0,e.Qf={}},Hc:function(e,n,s,l,d,g){_.Mf.multiDrawArraysInstancedBaseInstanceWEBGL(e,W,n>>2,W,s>>2,W,l>>2,_t,d>>2,g)},Ic:function(e,n,s,l,d,g,A,y){_.Mf.multiDrawElementsInstancedBaseVertexBaseInstanceWEBGL(e,W,n>>2,s,W,l>>2,W,d>>2,W,g>>2,_t,A>>2,y)},Pa:function(e,n){e==3317&&(Zn=n),_.pixelStorei(e,n)},Rb:function(e,n){_.ze.queryCounterEXT(qt[e],n)},Kc:function(e){_.readBuffer(e)},Qa:function(e,n,s,l,d,g,A){if(2<=at.version)if(_.zf)_.readPixels(e,n,s,l,d,g,A);else{var y=Mi(g);_.readPixels(e,n,s,l,d,g,y,A>>31-Math.clz32(y.BYTES_PER_ELEMENT))}else(A=tn(g,d,s,l,A))?_.readPixels(e,n,s,l,d,g,A):St(1280)},tc:function(e,n,s,l){_.renderbufferStorage(e,n,s,l)},pc:function(e,n,s,l,d){_.renderbufferStorageMultisample(e,n,s,l,d)},fc:function(e,n,s){_.samplerParameterf(Re[e],n,s)},gc:function(e,n,s){_.samplerParameteri(Re[e],n,s)},hc:function(e,n,s){_.samplerParameteri(Re[e],n,W[s>>2])},Ra:function(e,n,s,l){_.scissor(e,n,s,l)},Sa:function(e,n,s,l){for(var d="",g=0;g<n;++g){var A=l?W[l+4*g>>2]:-1,y=W[s+4*g>>2];A=y?Fe(ft,y,0>A?void 0:A):"",d+=A}_.shaderSource(ce[e],d)},Ta:function(e,n,s){_.stencilFunc(e,n,s)},Ua:function(e,n,s,l){_.stencilFuncSeparate(e,n,s,l)},Va:function(e){_.stencilMask(e)},Wa:function(e,n){_.stencilMaskSeparate(e,n)},Xa:function(e,n,s){_.stencilOp(e,n,s)},Ya:function(e,n,s,l){_.stencilOpSeparate(e,n,s,l)},Za:function(e,n,s,l,d,g,A,y,v){if(2<=at.version)if(_.We)_.texImage2D(e,n,s,l,d,g,A,y,v);else if(v){var T=Mi(y);_.texImage2D(e,n,s,l,d,g,A,y,T,v>>31-Math.clz32(T.BYTES_PER_ELEMENT))}else _.texImage2D(e,n,s,l,d,g,A,y,null);else _.texImage2D(e,n,s,l,d,g,A,y,v?tn(y,A,l,d,v):null)},_a:function(e,n,s){_.texParameterf(e,n,s)},$a:function(e,n,s){_.texParameterf(e,n,nt[s>>2])},ab:function(e,n,s){_.texParameteri(e,n,s)},bb:function(e,n,s){_.texParameteri(e,n,W[s>>2])},Ec:function(e,n,s,l,d){_.texStorage2D(e,n,s,l,d)},cb:function(e,n,s,l,d,g,A,y,v){if(2<=at.version)if(_.We)_.texSubImage2D(e,n,s,l,d,g,A,y,v);else if(v){var T=Mi(y);_.texSubImage2D(e,n,s,l,d,g,A,y,T,v>>31-Math.clz32(T.BYTES_PER_ELEMENT))}else _.texSubImage2D(e,n,s,l,d,g,A,y,null);else T=null,v&&(T=tn(y,A,d,g,v)),_.texSubImage2D(e,n,s,l,d,g,A,y,T)},db:function(e,n){_.uniform1f(At(e),n)},eb:function(e,n,s){if(2<=at.version)n&&_.uniform1fv(At(e),nt,s>>2,n);else{if(288>=n)for(var l=Te[n-1],d=0;d<n;++d)l[d]=nt[s+4*d>>2];else l=nt.subarray(s>>2,s+4*n>>2);_.uniform1fv(At(e),l)}},od:function(e,n){_.uniform1i(At(e),n)},pd:function(e,n,s){if(2<=at.version)n&&_.uniform1iv(At(e),W,s>>2,n);else{if(288>=n)for(var l=si[n-1],d=0;d<n;++d)l[d]=W[s+4*d>>2];else l=W.subarray(s>>2,s+4*n>>2);_.uniform1iv(At(e),l)}},qd:function(e,n,s){_.uniform2f(At(e),n,s)},rd:function(e,n,s){if(2<=at.version)n&&_.uniform2fv(At(e),nt,s>>2,2*n);else{if(144>=n)for(var l=Te[2*n-1],d=0;d<2*n;d+=2)l[d]=nt[s+4*d>>2],l[d+1]=nt[s+(4*d+4)>>2];else l=nt.subarray(s>>2,s+8*n>>2);_.uniform2fv(At(e),l)}},nd:function(e,n,s){_.uniform2i(At(e),n,s)},md:function(e,n,s){if(2<=at.version)n&&_.uniform2iv(At(e),W,s>>2,2*n);else{if(144>=n)for(var l=si[2*n-1],d=0;d<2*n;d+=2)l[d]=W[s+4*d>>2],l[d+1]=W[s+(4*d+4)>>2];else l=W.subarray(s>>2,s+8*n>>2);_.uniform2iv(At(e),l)}},ld:function(e,n,s,l){_.uniform3f(At(e),n,s,l)},kd:function(e,n,s){if(2<=at.version)n&&_.uniform3fv(At(e),nt,s>>2,3*n);else{if(96>=n)for(var l=Te[3*n-1],d=0;d<3*n;d+=3)l[d]=nt[s+4*d>>2],l[d+1]=nt[s+(4*d+4)>>2],l[d+2]=nt[s+(4*d+8)>>2];else l=nt.subarray(s>>2,s+12*n>>2);_.uniform3fv(At(e),l)}},jd:function(e,n,s,l){_.uniform3i(At(e),n,s,l)},id:function(e,n,s){if(2<=at.version)n&&_.uniform3iv(At(e),W,s>>2,3*n);else{if(96>=n)for(var l=si[3*n-1],d=0;d<3*n;d+=3)l[d]=W[s+4*d>>2],l[d+1]=W[s+(4*d+4)>>2],l[d+2]=W[s+(4*d+8)>>2];else l=W.subarray(s>>2,s+12*n>>2);_.uniform3iv(At(e),l)}},hd:function(e,n,s,l,d){_.uniform4f(At(e),n,s,l,d)},gd:function(e,n,s){if(2<=at.version)n&&_.uniform4fv(At(e),nt,s>>2,4*n);else{if(72>=n){var l=Te[4*n-1],d=nt;s>>=2;for(var g=0;g<4*n;g+=4){var A=s+g;l[g]=d[A],l[g+1]=d[A+1],l[g+2]=d[A+2],l[g+3]=d[A+3]}}else l=nt.subarray(s>>2,s+16*n>>2);_.uniform4fv(At(e),l)}},Wc:function(e,n,s,l,d){_.uniform4i(At(e),n,s,l,d)},Xc:function(e,n,s){if(2<=at.version)n&&_.uniform4iv(At(e),W,s>>2,4*n);else{if(72>=n)for(var l=si[4*n-1],d=0;d<4*n;d+=4)l[d]=W[s+4*d>>2],l[d+1]=W[s+(4*d+4)>>2],l[d+2]=W[s+(4*d+8)>>2],l[d+3]=W[s+(4*d+12)>>2];else l=W.subarray(s>>2,s+16*n>>2);_.uniform4iv(At(e),l)}},Yc:function(e,n,s,l){if(2<=at.version)n&&_.uniformMatrix2fv(At(e),!!s,nt,l>>2,4*n);else{if(72>=n)for(var d=Te[4*n-1],g=0;g<4*n;g+=4)d[g]=nt[l+4*g>>2],d[g+1]=nt[l+(4*g+4)>>2],d[g+2]=nt[l+(4*g+8)>>2],d[g+3]=nt[l+(4*g+12)>>2];else d=nt.subarray(l>>2,l+16*n>>2);_.uniformMatrix2fv(At(e),!!s,d)}},Zc:function(e,n,s,l){if(2<=at.version)n&&_.uniformMatrix3fv(At(e),!!s,nt,l>>2,9*n);else{if(32>=n)for(var d=Te[9*n-1],g=0;g<9*n;g+=9)d[g]=nt[l+4*g>>2],d[g+1]=nt[l+(4*g+4)>>2],d[g+2]=nt[l+(4*g+8)>>2],d[g+3]=nt[l+(4*g+12)>>2],d[g+4]=nt[l+(4*g+16)>>2],d[g+5]=nt[l+(4*g+20)>>2],d[g+6]=nt[l+(4*g+24)>>2],d[g+7]=nt[l+(4*g+28)>>2],d[g+8]=nt[l+(4*g+32)>>2];else d=nt.subarray(l>>2,l+36*n>>2);_.uniformMatrix3fv(At(e),!!s,d)}},_c:function(e,n,s,l){if(2<=at.version)n&&_.uniformMatrix4fv(At(e),!!s,nt,l>>2,16*n);else{if(18>=n){var d=Te[16*n-1],g=nt;l>>=2;for(var A=0;A<16*n;A+=16){var y=l+A;d[A]=g[y],d[A+1]=g[y+1],d[A+2]=g[y+2],d[A+3]=g[y+3],d[A+4]=g[y+4],d[A+5]=g[y+5],d[A+6]=g[y+6],d[A+7]=g[y+7],d[A+8]=g[y+8],d[A+9]=g[y+9],d[A+10]=g[y+10],d[A+11]=g[y+11],d[A+12]=g[y+12],d[A+13]=g[y+13],d[A+14]=g[y+14],d[A+15]=g[y+15]}}else d=nt.subarray(l>>2,l+64*n>>2);_.uniformMatrix4fv(At(e),!!s,d)}},$c:function(e){e=he[e],_.useProgram(e),_.bg=e},ad:function(e,n){_.vertexAttrib1f(e,n)},bd:function(e,n){_.vertexAttrib2f(e,nt[n>>2],nt[n+4>>2])},cd:function(e,n){_.vertexAttrib3f(e,nt[n>>2],nt[n+4>>2],nt[n+8>>2])},dd:function(e,n){_.vertexAttrib4f(e,nt[n>>2],nt[n+4>>2],nt[n+8>>2],nt[n+12>>2])},Fc:function(e,n){_.vertexAttribDivisor(e,n)},Gc:function(e,n,s,l,d){_.vertexAttribIPointer(e,n,s,l,d)},ed:function(e,n,s,l,d,g){_.vertexAttribPointer(e,n,s,!!l,d,g)},fd:function(e,n,s,l){_.viewport(e,n,s,l)},kc:function(e,n,s,l){_.waitSync(ke[e],n,(s>>>0)+4294967296*l)},qb:e=>{var n=ft.length;if(e>>>=0,2147483648<e)return!1;for(var s=1;4>=s;s*=2){var l=n*(1+.2/s);l=Math.min(l,e+100663296);var d=Math;l=Math.max(e,l);t:{d=d.min.call(d,2147483648,l+(65536-l%65536)%65536)-gi.buffer.byteLength+65535>>>16;try{gi.grow(d),_n();var g=1;break t}catch{}g=void 0}if(g)return!0}return!1},hb:function(){return at?at.handle:0},rb:(e,n)=>{var s=0;return mr().forEach(function(l,d){var g=n+s;for(d=_t[e+4*d>>2]=g,g=0;g<l.length;++g)pe[d++>>0]=l.charCodeAt(g);pe[d>>0]=0,s+=l.length+1}),0},sb:(e,n)=>{var s=mr();_t[e>>2]=s.length;var l=0;return s.forEach(function(d){l+=d.length+1}),_t[n>>2]=l,0},Eb:e=>{K(e,new cs(e))},M:()=>52,jb:function(){return 52},xb:()=>52,mb:function(){return 70},Q:(e,n,s,l)=>{for(var d=0,g=0;g<s;g++){var A=_t[n>>2],y=_t[n+4>>2];n+=8;for(var v=0;v<y;v++){var T=ft[A+v],D=zs[e];T===0||T===10?((e===1?ut:Pe)(Fe(D,0)),D.length=0):D.push(T)}d+=y}return _t[l>>2]=d,0},yd:er,ib:nr,xd:rr,Kb:sr,L:ur,P:fr,fb:pr,Ib:Zs,j:qs,o:Js,k:Ws,I:na,Hb:ta,Fb:sa,W:ea,V:ra,O:Vs,i:Xs,w:Ks,v:Hs,s:Ys,Gb:ia,Jb:Qs,Lb:js,ob:(e,n,s,l)=>Bs(e,n,s,l)};(function(){function e(s){if(Pt=s=s.exports,gi=Pt.zd,_n(),Mt=Pt.Cd,xn.unshift(Pt.Ad),xe--,c.monitorRunDependencies&&c.monitorRunDependencies(xe),xe==0&&Ye){var l=Ye;Ye=null,l()}return s}var n={a:Gs};if(xe++,c.monitorRunDependencies&&c.monitorRunDependencies(xe),c.instantiateWasm)try{return c.instantiateWasm(n,e)}catch(s){Pe("Module.instantiateWasm callback failed with error: "+s),E(s)}return hs(n,function(s){e(s.instance)}).catch(E),{}})();var Ni=c._malloc=e=>(Ni=c._malloc=Pt.Bd)(e),we=c._free=e=>(we=c._free=Pt.Dd)(e),Sr=e=>(Sr=Pt.Ed)(e);c.__embind_initialize_bindings=()=>(c.__embind_initialize_bindings=Pt.Fd)();var It=(e,n)=>(It=Pt.Gd)(e,n),Ot=()=>(Ot=Pt.Hd)(),Dt=e=>(Dt=Pt.Id)(e);c.dynCall_viji=(e,n,s,l,d)=>(c.dynCall_viji=Pt.Jd)(e,n,s,l,d),c.dynCall_vijiii=(e,n,s,l,d,g,A)=>(c.dynCall_vijiii=Pt.Kd)(e,n,s,l,d,g,A),c.dynCall_viiiiij=(e,n,s,l,d,g,A,y)=>(c.dynCall_viiiiij=Pt.Ld)(e,n,s,l,d,g,A,y),c.dynCall_jii=(e,n,s)=>(c.dynCall_jii=Pt.Md)(e,n,s),c.dynCall_vij=(e,n,s,l)=>(c.dynCall_vij=Pt.Nd)(e,n,s,l),c.dynCall_jiiiiii=(e,n,s,l,d,g,A)=>(c.dynCall_jiiiiii=Pt.Od)(e,n,s,l,d,g,A),c.dynCall_jiiiiji=(e,n,s,l,d,g,A,y)=>(c.dynCall_jiiiiji=Pt.Pd)(e,n,s,l,d,g,A,y),c.dynCall_ji=(e,n)=>(c.dynCall_ji=Pt.Qd)(e,n),c.dynCall_iijj=(e,n,s,l,d,g)=>(c.dynCall_iijj=Pt.Rd)(e,n,s,l,d,g),c.dynCall_iiiji=(e,n,s,l,d,g)=>(c.dynCall_iiiji=Pt.Sd)(e,n,s,l,d,g),c.dynCall_iiji=(e,n,s,l,d)=>(c.dynCall_iiji=Pt.Td)(e,n,s,l,d),c.dynCall_iijjiii=(e,n,s,l,d,g,A,y,v)=>(c.dynCall_iijjiii=Pt.Ud)(e,n,s,l,d,g,A,y,v),c.dynCall_iij=(e,n,s,l)=>(c.dynCall_iij=Pt.Vd)(e,n,s,l),c.dynCall_vijjjii=(e,n,s,l,d,g,A,y,v,T)=>(c.dynCall_vijjjii=Pt.Wd)(e,n,s,l,d,g,A,y,v,T),c.dynCall_jiji=(e,n,s,l,d)=>(c.dynCall_jiji=Pt.Xd)(e,n,s,l,d),c.dynCall_viijii=(e,n,s,l,d,g,A)=>(c.dynCall_viijii=Pt.Yd)(e,n,s,l,d,g,A),c.dynCall_iiiiij=(e,n,s,l,d,g,A)=>(c.dynCall_iiiiij=Pt.Zd)(e,n,s,l,d,g,A),c.dynCall_iiiiijj=(e,n,s,l,d,g,A,y,v)=>(c.dynCall_iiiiijj=Pt._d)(e,n,s,l,d,g,A,y,v),c.dynCall_iiiiiijj=(e,n,s,l,d,g,A,y,v,T)=>(c.dynCall_iiiiiijj=Pt.$d)(e,n,s,l,d,g,A,y,v,T);function Ws(e,n,s,l){var d=Ot();try{return Mt.get(e)(n,s,l)}catch(g){if(Dt(d),g!==g+0)throw g;It(1,0)}}function js(e,n,s,l,d,g,A,y,v,T){var D=Ot();try{Mt.get(e)(n,s,l,d,g,A,y,v,T)}catch(L){if(Dt(D),L!==L+0)throw L;It(1,0)}}function Hs(e,n,s,l){var d=Ot();try{Mt.get(e)(n,s,l)}catch(g){if(Dt(d),g!==g+0)throw g;It(1,0)}}function Ks(e,n,s){var l=Ot();try{Mt.get(e)(n,s)}catch(d){if(Dt(l),d!==d+0)throw d;It(1,0)}}function Vs(e){var n=Ot();try{Mt.get(e)()}catch(s){if(Dt(n),s!==s+0)throw s;It(1,0)}}function qs(e,n){var s=Ot();try{return Mt.get(e)(n)}catch(l){if(Dt(s),l!==l+0)throw l;It(1,0)}}function Ys(e,n,s,l,d){var g=Ot();try{Mt.get(e)(n,s,l,d)}catch(A){if(Dt(g),A!==A+0)throw A;It(1,0)}}function Xs(e,n){var s=Ot();try{Mt.get(e)(n)}catch(l){if(Dt(s),l!==l+0)throw l;It(1,0)}}function Js(e,n,s){var l=Ot();try{return Mt.get(e)(n,s)}catch(d){if(Dt(l),d!==d+0)throw d;It(1,0)}}function Qs(e,n,s,l,d,g,A){var y=Ot();try{Mt.get(e)(n,s,l,d,g,A)}catch(v){if(Dt(y),v!==v+0)throw v;It(1,0)}}function Zs(e){var n=Ot();try{return Mt.get(e)()}catch(s){if(Dt(n),s!==s+0)throw s;It(1,0)}}function ta(e,n,s,l,d,g){var A=Ot();try{return Mt.get(e)(n,s,l,d,g)}catch(y){if(Dt(A),y!==y+0)throw y;It(1,0)}}function ea(e,n,s,l,d,g,A,y){var v=Ot();try{return Mt.get(e)(n,s,l,d,g,A,y)}catch(T){if(Dt(v),T!==T+0)throw T;It(1,0)}}function ia(e,n,s,l,d,g){var A=Ot();try{Mt.get(e)(n,s,l,d,g)}catch(y){if(Dt(A),y!==y+0)throw y;It(1,0)}}function na(e,n,s,l,d){var g=Ot();try{return Mt.get(e)(n,s,l,d)}catch(A){if(Dt(g),A!==A+0)throw A;It(1,0)}}function ra(e,n,s,l,d,g,A,y,v,T){var D=Ot();try{return Mt.get(e)(n,s,l,d,g,A,y,v,T)}catch(L){if(Dt(D),L!==L+0)throw L;It(1,0)}}function sa(e,n,s,l,d,g,A){var y=Ot();try{return Mt.get(e)(n,s,l,d,g,A)}catch(v){if(Dt(y),v!==v+0)throw v;It(1,0)}}var Ii;Ye=function e(){Ii||br(),Ii||(Ye=e)};function br(){function e(){if(!Ii&&(Ii=!0,c.calledRun=!0,!Cn)){if(Wi(xn),S(c),c.onRuntimeInitialized&&c.onRuntimeInitialized(),c.postRun)for(typeof c.postRun=="function"&&(c.postRun=[c.postRun]);c.postRun.length;){var n=c.postRun.shift();Fn.unshift(n)}Wi(Fn)}}if(!(0<xe)){if(c.preRun)for(typeof c.preRun=="function"&&(c.preRun=[c.preRun]);c.preRun.length;)os();Wi(En),0<xe||(c.setStatus?(c.setStatus("Running..."),setTimeout(function(){setTimeout(function(){c.setStatus("")},1),e()},1)):e())}}if(c.preInit)for(typeof c.preInit=="function"&&(c.preInit=[c.preInit]);0<c.preInit.length;)c.preInit.pop()();return br(),h.ready}})();m.exports=i}(mn)),mn.exports}var Ta=Ca(),_a=ga(Ta);class Ke{static slide(t){let i=De.linear;return typeof t.easing=="string"?i=De.fromTypeAsString(t.easing):t.easing!==void 0&&(i=t.easing),new es(t.direction,t.duration,i)}static none(){return new ts}}class ts extends Ke{constructor(){super(),this.type=Se.None,this.duration=NaN,this.easing=De.none}}class es extends Ke{constructor(t,i,r){super(),this.type=Se.Slide,this.direction=t,this.duration=i,this.easing=r}}const Se={Slide:"Slide",None:"None"},be={Up:"Up",Down:"Down",Right:"Right",Left:"Left"};class is{constructor(t,i){this.scene=t,this.transition=i}}const bn={type:"object",description:"Information about the user's device.",properties:{userAgent:{type:"string",description:"The user agent string returned by navigator.userAgent."},devicePixelRatio:{type:"number",description:"Ratio of physical pixels to CSS pixels."},screen:{type:"object",description:"Screen information returned by window.screen.",properties:{availHeight:{type:"number",description:"Height of screen, in pixels, excluding UI features."},availWidth:{type:"number",description:"Width of screen, in pixels, excluding UI features."},colorDepth:{type:"number",description:"Color depth of screen."},height:{type:"number",description:"Height of screen, in pixels"},width:{type:"number",description:"Width of screen, in pixels."},orientation:{type:"object",description:"Information about the device's orientation.",properties:{type:{type:"string",description:"The orientation type (ScreenOrientation.type)."},angle:{type:"number",description:"The orientation angle (ScreenOrientation.angle)."}}},pixelDepth:{type:"number",description:"Pixel depth of screen."}}},webGlRenderer:{type:"string",description:"WebGL driver vendor and renderer. Taken from WEBGL_debug_renderer_info."}}};class Pn{static getRendererString(){const t=document.createElement("canvas");t.id="webgl-renderer-info-canvas",t.height=0,t.width=0,t.hidden=!0,document.body.appendChild(t);const i=t.getContext("webgl");let r="no webgl context";if(!i)return r;const h=i.getExtension("WEBGL_debug_renderer_info");return h!=null?r=String(i.getParameter(h.UNMASKED_VENDOR_WEBGL))+", "+String(i.getParameter(h.UNMASKED_RENDERER_WEBGL)):r="no debug renderer info",t.remove(),r}static dispose(){const t=document.getElementById("webgl-renderer-info-canvas");t&&t.remove()}}class ns{constructor(t,i){this.sounds={},this.game=t,this.baseUrls=i}get audioContext(){if(!this._audioContext){if(!navigator.userActivation.hasBeenActive)throw new C("AudioContext cannot be created until user has interacted with the page");this._audioContext=new AudioContext}return this._audioContext}initializeSounds(t){return t?this.loadSounds(t):Promise.resolve()}loadSounds(t){return t.length===0?Promise.resolve():(t.forEach(i=>{let r=i.url;q.urlHasScheme(i.url)||(r=q.getUrlFromManifest(this.game,`${this.baseUrls.assets}/${i.url}`));const h={soundName:i.soundName,data:void 0,audioBuffer:void 0,audioBufferSource:void 0,url:r,status:i.lazy?jt.Deferred:jt.WillFetch};this.sounds[i.soundName]&&console.warn(`A sound named ${i.soundName} has already been loaded. It will be replaced.`),this.sounds[i.soundName]=h}),this.fetchSounds())}async fetchSounds(){const t=Object.values(this.sounds).map(i=>i.status===jt.WillFetch?(i.status=jt.Fetching,fetch(i.url).then(r=>{if(!r.ok)throw i.status=jt.Error,new C(`cannot fetch sound ${i.soundName} at url ${i.url}: ${r.statusText}`);return r.arrayBuffer().then(h=>{i.data=h,i.status=jt.Fetched,console.log(`\u26AA sound fetched. name: ${i.soundName}, bytes: ${h.byteLength}`)})})):Promise.resolve());await Promise.all(t)}fetchDeferredSound(t){return t.status=jt.WillFetch,this.fetchSounds()}hasSoundsToDecode(){return Object.values(this.sounds).filter(t=>t.status===jt.Fetched).length>0}decodeFetchedSounds(){const i=Object.values(this.sounds).filter(r=>r.status===jt.Fetched).map(r=>this.decodeSound(r));return Promise.all(i)}async decodeSound(t){if(!t.data)throw new C(`data is undefined for sound ${t.soundName} (url ${t.url})`);try{t.status=jt.Decoding;const i=await this.audioContext.decodeAudioData(t.data);t.audioBuffer=i,t.status=jt.Ready,console.log(`\u26AA sound decoded. name: ${t.soundName}, duration (seconds): ${i.duration}`)}catch{throw t.status=jt.Error,new C(`error decoding sound ${t.soundName} (url: ${t.url})`)}}getSound(t){const i=this.sounds[t];if(!i)throw new C(`getSound(): sound ${t} not found`);return i}dispose(){}getSoundNames(){return Object.keys(this.sounds)}}class Ea{constructor(t){this.game=t.game,this.nodeFactory=t.nodeFactory,this.freeNodesScene=t.freeNodesScene,this.configureI18n=t.configureI18n,this.eventMaterializers=new Map([[H.NodeNew,this.materializeNodeNewEvent.bind(this)],[H.Composite,this.materializeCompositeEvent.bind(this)],[H.ScenePresent,this.materializeScenePresentEvent.bind(this)],[H.NodePropertyChange,this.materializeNodePropertyChangeEvent.bind(this)],[H.NodeAddChild,this.materializeNodeAddChildEvent.bind(this)],[H.NodeRemoveChild,this.materializeNodeRemoveChildEvent.bind(this)],[H.DomPointerDown,this.materializeDomPointerDownEvent.bind(this)],[H.BrowserImageDataReady,this.materializeBrowserImageDataReadyEvent.bind(this)],[H.I18nDataReadyEvent,this.materializeI18nDataReadyEvent.bind(this)]])}materialize(t){t.length>0&&(console.log(`Replaying ${t.length} events`),t.forEach(i=>{const r=this.eventMaterializers.get(i.type);r?r(i):console.log(`EventMaterializer unhandled event: ${i.type}`)}))}materializeCompositeEvent(t){const i=this.game.materializedNodes.find(r=>r.uuid===t.target);if(!i)console.log(`EventMaterializer: composite node of type ${t.compositeType} with uuid ${t.target} not found when handling CompositeEvent ${t.compositeEventType}`);else if(i.type===dt.Composite)i.handleCompositeEvent(t);else throw new C(`EventMaterializer: node was expected to be composite, but was of type ${i.type}`)}materializeNodeNewEvent(t){const i=this.nodeFactory.createNode(t.nodeType,t.compositeType,t.nodeOptions);i.type===dt.Scene&&(i.name===Q.FREE_NODES_SCENE_NAME?(this.freeNodesScene=i,this.freeNodesScene.game=this.game,this.freeNodesScene.needsInitialization=!0,this.game.freeNodesScene=this.freeNodesScene):this.game.addScene(i)),this.game.materializedNodes.push(i)}materializeNodePropertyChangeEvent(t){const i=this.game.materializedNodes.find(r=>r.uuid===t.uuid);if(!i)throw new C(`EventMaterializer: node with uuid ${t.uuid} not found`);if(t.property in i)i[t.property]=t.value;else throw new C(`EventMaterializer: on node ${i.name}, type ${i.type}, nodePropertyChangeEvent tried to set unknown property ${t.property} to value ${JSON.stringify(t.value)}`)}materializeNodeAddChildEvent(t){const i=this.game.materializedNodes.find(h=>h.uuid===t.uuid);if(!i)throw new C(`EventMaterializer: parent node with uuid ${t.uuid} not found`);const r=this.game.materializedNodes.find(h=>h.uuid===t.childUuid);if(!r)throw new C(`EventMaterializer: child node with uuid ${t.childUuid} not found`);i.addChild(r)}materializeNodeRemoveChildEvent(t){const i=this.game.materializedNodes.find(h=>h.uuid===t.uuid);if(!i)throw new C(`EventMaterializer: parent node with uuid ${t.uuid} not found`);const r=this.game.materializedNodes.find(h=>h.uuid===t.childUuid);if(!r)throw new C(`EventMaterializer: child node with uuid ${t.childUuid} not found`);i.removeChild(r)}materializeDomPointerDownEvent(t){this.game.currentScene?.run(X.custom({callback:()=>{const i=new fi({circleOfRadius:16,fillColor:R.LightGray,strokeColor:R.Black,lineWidth:2,alpha:.75,position:{x:t.x,y:t.y}});this.game.currentScene?.addChild(i),i.run(X.sequence([X.group([X.fadeAlpha({duration:750,alpha:0}),X.scale({duration:750,scale:0})]),X.custom({callback:()=>{this.game.currentScene?.removeChild(i)}})]))}}))}materializeBrowserImageDataReadyEvent(t){this.game.imageManager.loadImages([{imageName:t.imageName,width:t.width,height:t.height,dataUrl:t.dataUrl,svgString:t.svgString}])}materializeI18nDataReadyEvent(t){this.configureI18n(t.localizationOptions)}materializeScenePresentEvent(t){let i=Ke.none();if(t.transitionType===Se.Slide){if(t.direction===void 0)throw new C("EventMaterializer: ScenePresentEvent direction is undefined for slide transition");if(t.duration===void 0)throw new C("EventMaterializer: ScenePresentEvent duration is undefined for slide transition");if(t.easingType===void 0)throw new C("EventMaterializer: ScenePresentEvent easingType is undefined for slide transition");const r=this.game.materializedNodes.find(h=>h.uuid===t.uuid);if(!r)throw new C(`EventMaterializer: Scene with uuid ${t.uuid} not found`);switch(t.direction){case be.Left:{r.position.x=r.size.width;break}case be.Right:{r.position.x=-r.size.width;break}case be.Up:{r.position.y=r.size.height;break}case be.Down:{r.position.y=-r.size.height;break}}i=Ke.slide({direction:t.direction,duration:t.duration,easing:De.fromTypeAsString(t.easingType)})}this.game.presentScene(t.uuid,i)}}class xa{constructor(t){if(this.type=ui.Game,this.sessionUuid="",this.uuid=ze.generate(),this.publishUuid="",this.canvasKitWasmVersion="0.40.0",this.beginTimestamp=NaN,this.beginIso8601Timestamp="",this.eventListeners=new Array,this.gameMetrics=new Array,this.stepCount=0,this.steppingNow=0,this.warmupFunctionQueue=new Array,this.warmupFinished=!1,this.plugins=[],this.staticTrialSchema={},this.eventStore=new $r,this.nodeFactory=new Gr,this.materializedNodes=new Array,this.data={trials:new Array,scoring:{}},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 Ve({name:Q.FREE_NODES_SCENE_NAME,backgroundColor:[255,255,255,0]}),this.incomingSceneTransitions=new Array,this.replayEventsButtonEnabled=!0,this.automaticScoringSchema={data_type:{type:"string",description:"Type of data."},study_id:{type:["string","null"],description:"The short human-readable text ID of the study (protocol, experiment, or other aggregate) that contains the administration of this activity."},study_uuid:{type:["string","null"],format:"uuid",description:"Unique identifier of the study (protocol, experiment, or other aggregate) that contains the administration of this activity."},document_uuid:{type:"string",format:"uuid",description:"Unique identifier for this data document."},session_uuid:{type:"string",format:"uuid",description:"Unique identifier for all activities in this administration of the session. This identifier changes each time a new session starts."},activity_uuid:{type:"string",format:"uuid",description:"Unique identifier for all trials in this administration of the activity. This identifier changes each time the activity starts."},activity_id:{type:"string",description:"Human-readable identifier of the activity."},activity_publish_uuid:{type:"string",format:"uuid",description:"Persistent unique identifier of the activity. This identifier never changes. It can be used to identify the activity across different studies and sessions."},activity_version:{type:"string",description:"Version of the activity."},device_timezone:{type:"string",description:"Timezone of the device. Calculated from Intl.DateTimeFormat().resolvedOptions().timeZone."},device_timezone_offset_minutes:{type:"integer",description:"Difference in minutes between UTC and device timezone. Calculated from Date.getTimezoneOffset()."},locale:{type:["string","null"],description:"Locale of the trial. null if the activity does not support localization."}},this.automaticTrialSchema={data_type:{type:"string",description:"Type of data."},study_id:{type:["string","null"],description:"The short human-readable text ID of the study (protocol, experiment, or other aggregate) that contains the administration of this activity."},study_uuid:{type:["string","null"],format:"uuid",description:"Unique identifier of the study (protocol, experiment, or other aggregate) that contains the administration of this activity."},document_uuid:{type:"string",format:"uuid",description:"Unique identifier for this data document."},session_uuid:{type:"string",format:"uuid",description:"Unique identifier for all activities in this administration of the session. This identifier changes each time a new session starts."},activity_uuid:{type:"string",format:"uuid",description:"Unique identifier for all trials in this administration of the activity. This identifier changes each time the activity starts."},activity_id:{type:"string",description:"Human-readable identifier of the activity."},activity_publish_uuid:{type:"string",format:"uuid",description:"Persistent unique identifier of the activity. This identifier never changes. It can be used to identify the activity across different studies and sessions."},activity_version:{type:"string",description:"Version of the activity."},device_timezone:{type:"string",description:"Timezone of the device. Calculated from Intl.DateTimeFormat().resolvedOptions().timeZone."},device_timezone_offset_minutes:{type:"integer",description:"Difference in minutes between UTC and device timezone. Calculated from Date.getTimezoneOffset()."},locale:{type:["string","null"],description:"Locale of the trial. null if the activity does not support localization."}},this.snapshots=new Array,!t.id||t.id.trim()==="")throw new C("id is required in GameOptions");if(!ze.isValid(t.publishUuid)){const i=t.publishUuid?`Provided publishUuid was ${t.publishUuid}. `:"";console.warn(`Missing or invalid publishUuid in GameOptions. ${i}To generate a valid UUID, visit a site such as https://www.uuidgenerator.net/version4`)}this.options=t,this.name=t.name,this.id=t.id,this.publishUuid=t.publishUuid,this.fpsMetricReportThreshold=t.fpsMetricReportThreshold??Q.FPS_METRIC_REPORT_THRESHOLD,this.maximumRecordedActivityMetrics=t.maximumRecordedActivityMetrics??Q.MAXIMUM_RECORDED_ACTIVITY_METRICS,this.addLocalizationParametersToGameParameters(),this.options.locale!==void 0&&this.setParameters({locale:this.options.locale}),this.options.fallbackLocale!==void 0&&this.setParameters({fallback_locale:this.options.fallbackLocale}),this.options.missingLocalizationColor&&this.setParameters({missing_localization_color:this.options.missingLocalizationColor}),this.options.translation&&this.setParameters({translation:this.options.translation}),this.options.additionalTranslation&&this.setParameters({translation:this.options.additionalTranslation}),this.options.trialSchema||(this.options.trialSchema={}),this.options.scoringSchema||(this.options.scoringSchema={}),t.moduleMetadata?this.moduleMetadata=t.moduleMetadata:this.moduleMetadata={name:"",version:"",dependencies:{}},t.moduleMetadata?.name&&t.version&&console.log(`\u26AA ${t.moduleMetadata.name} version ${t.version}`)}createFreeNodesScene(){this.freeNodesScene.game=this,this.freeNodesScene.needsInitialization=!0;const t={name:Q.FREE_NODES_SCENE_NAME,backgroundColor:[255,255,255,0],uuid:this.freeNodesScene.uuid},i={type:H.NodeNew,target:this.freeNodesScene,nodeType:dt.Scene,...q.createFrameUpdateTimestamps(),nodeOptions:t,sequence:m2c2Globals.eventSequence};this.eventStore.addEvent(i)}getImportedModuleBaseUrl(t,i){const r=new URL(i),h=r.pathname.split("/").filter(Boolean);let c=-1;for(let E=0;E<h.length-1;E++)if(t.startsWith("@")){const O=t.split("/");if(O.length===2){const G=O[0],K=O[1];for(let it=0;it<h.length-1;it++)h[it]===G&&(h[it+1]===K||h[it+1].startsWith(`${K}@`))&&(c=it+1)}}else(h[E]===t||h[E].startsWith(`${t}@`))&&(c=E);if(c===-1)throw new Error(`Could not locate base URL for package "${t}" in "${i}"`);const S=h.slice(0,c+1).join("/");return`${r.origin}/${S}`.replace(/\/*$/,"")}addLocalizationParametersToGameParameters(){this.options.parameters={...this.options.parameters,...zi.makeLocalizationParameters()}}async init(){return this.initialize()}loadCanvasKit(t){return _a({locateFile:()=>t})}async resolveGameBaseUrls(t){let i,r=!1,h=`assets/${t.id}`;if(t.moduleMetadata.name)try{i=await import.meta.resolve(t.moduleMetadata.name),h=t.getImportedModuleBaseUrl(t.moduleMetadata.name,i)+"/assets",r=!0}catch{}let c=`assets/${t.id}`;try{const S=await import.meta.resolve("@m2c2kit/core");c=t.getImportedModuleBaseUrl("@m2c2kit/core",S)+"/assets"}catch{if(r)throw new C(`the package ${t.moduleMetadata.name} has been imported from a module URL (${i}), but the @m2c2kit/core package module URL could not be determined.`)}return{assets:h,canvasKitWasm:c}}async configureI18n(t){if(this.i18n=new zi(this,t),!this.i18n)throw new C("I18n object is undefined");await this.i18n.initialize(),this.eventStore.addEvent({type:"I18nDataReadyEvent",target:this.i18n,localizationOptions:t,...q.createFrameUpdateTimestamps()})}async waitForErudaInitialization(t=5e3){await new Promise(i=>{let r=0;const h=setInterval(()=>{m2c2Globals.erudaInitialized===!0&&(clearInterval(h),i(void 0)),r=r+100,r>t&&(console.warn(`Could not initialize eruda within ${t} milliseconds.`),clearInterval(h),i(void 0))},100)})}async initialize(){m2c2Globals.erudaRequested===!0&&await this.waitForErudaInitialization(),this.options.recordEvents===!0&&(this.eventStore.mode=ve.Record),this.createFreeNodesScene();const t=await this.resolveGameBaseUrls(this);if(this.manifest===void 0&&(this.manifest=await this.loadManifest()),this._canvasKit===void 0){const i=q.getUrlFromManifest(this,t.canvasKitWasm+`/canvaskit-${this.canvasKitWasmVersion}.wasm`);try{this.canvasKit=await this.loadCanvasKit(i)}catch{throw new C(`game ${this.id} could not load canvaskit wasm file from ${i}`)}}if(this.isLocalizationRequested()){const i=this.getLocalizationOptionsFromGameParameters();await this.configureI18n(i)}return this.fontManager=new Wr(this,t),this.imageManager=new fn(this,t),this.soundManager=new ns(this,t),this.eventMaterializer=new Ea({game:this,nodeFactory:this.nodeFactory,freeNodesScene:this.freeNodesScene,configureI18n:this.configureI18n.bind(this)}),Promise.all([this.fontManager.initializeFonts(this.options.fonts),this.imageManager.initializeImages(this.options.images),this.soundManager.initializeSounds(this.options.sounds)])}async loadManifest(t="__NO_M2C2KIT_MANIFEST_JSON_URL__"){if(t.includes("NO_M2C2KIT_MANIFEST_JSON_URL"))return{};let i;try{if(i=await fetch(t),!i.ok)throw new C(`Error ${i.status} on GET manifest.json from ${t}.`)}catch{throw new C(`Network error on GET manifest.json from ${t}.`)}try{return await i.json()}catch{throw new C(`Error parsing manifest.json from ${t}.`)}}get fontManager(){if(!this._fontManager)throw new C("fontManager is undefined");return this._fontManager}set fontManager(t){this._fontManager=t}get imageManager(){if(!this._imageManager)throw new C("imageManager is undefined");return this._imageManager}set imageManager(t){this._imageManager=t}get soundManager(){if(!this._soundManager)throw new C("soundManager is undefined");return this._soundManager}set soundManager(t){this._soundManager=t}get eventMaterializer(){if(!this._eventMaterializer)throw new C("eventMaterializer is undefined");return this._eventMaterializer}set eventMaterializer(t){this._eventMaterializer=t}addPrefixesToKey(t){let i="";if(this.studyId&&this.studyUuid)i=this.studyId.concat(":",this.studyUuid,":");else if(this.studyId||this.studyUuid)throw new C(`study_id and study_uuid must both be set or unset. Values are study_id: ${this.studyId}, study_uuid: ${this.studyUuid}`);return i.concat(this.id.concat(this.id,":",this.publishUuid,":",t))}storeSetItem(t,i,r=!1){const h=r?t:this.addPrefixesToKey(t);return this.dataStores[0].setItem(h,i,r?"":this.publishUuid)}storeGetItem(t,i=!1){const r=i?t:this.addPrefixesToKey(t);return this.dataStores[0].getItem(r)}storeDeleteItem(t,i=!1){const r=i?t:this.addPrefixesToKey(t);return this.dataStores[0].deleteItem(r)}storeClearItems(){return this.dataStores[0].clearItemsByActivityPublishUuid(this.publishUuid)}storeItemsKeys(t=!1){return this.dataStores[0].itemsKeysByActivityPublishUuid(t?"":this.publishUuid)}storeItemExists(t,i=!1){const r=i?t:this.addPrefixesToKey(t);return this.dataStores[0].itemExists(r)}get dataStores(){if(!this._dataStores)throw new C("dataStores is undefined");return this._dataStores}set dataStores(t){this._dataStores=t}hasDataStores(){return this._dataStores&&this._dataStores.length>0||!1}getLocalizationOptionsFromGameParameters(){const t=this.getParameter("locale"),i=this.getParameterOrFallback("fallback_locale",void 0),r=this.getParameterOrFallback("missing_localization_color",void 0),h=this.getParameterOrFallback("translation",void 0),c=this.options.translation;return{locale:t,fallbackLocale:i,missingLocalizationColor:r,additionalTranslation:h,translation:c}}isLocalizationRequested(){const t=this.getParameterOrFallback("locale",void 0);if(t==="")throw new C("Empty string in locale. Leave locale undefined or null to prevent localization.");return t==null&&this.options.translation?(this.setParameters({locale:this.options.translation.baseLocale}),!0):!(t==null&&this.options.translation===void 0)}setParameters(t){const{parameters:i}=this.options;Object.keys(t).forEach(r=>{if(r!=="diagnostics"){if(r==="eruda"){t[r]===!0&&q.loadEruda();return}if(r==="scripts"){const h=t[r];h&&q.loadScriptUrls(h);return}if(!i||!(r in i))console.warn(`game ${this.options.name} does not have a parameter named ${r}. attempt to set parameter ${r} to value ${t[r]} will be ignored`);else if(this.options.parameters&&this.options.parameters[r]){const h=t[r];let c;if(this.options.parameters[r].type!==void 0&&h!==void 0)try{c=q.convertValueToType(h,this.options.parameters[r].type)}catch(S){throw new C("Error setting parameter "+r+": "+S.message)}else c=h;this.options.parameters[r].default=c}this.additionalParameters===void 0&&(this.additionalParameters={}),this.additionalParameters[r]=t[r]}})}get canvasKit(){if(!this._canvasKit)throw new C("canvaskit is undefined");return this._canvasKit}set canvasKit(t){this._canvasKit=t}addFreeNode(t){this.freeNodesScene.addChild(t)}addFreeEntity(t){this.addFreeNode(t)}removeFreeNode(t){if(typeof t=="string"){const i=this.freeNodesScene.children.filter(r=>r.name===t).find(Boolean);if(!i)throw new C(`cannot remove free node named "${t}" because it is not currently part of the game's free nodes. `);this.freeNodesScene.removeChild(i)}else this.freeNodesScene.removeChild(t)}removeFreeEntity(t){this.removeFreeNode(t)}removeAllFreeNodes(){for(;this.freeNodesScene.children.length;)this.freeNodesScene.children.pop()}removeAllFreeEntities(){this.removeAllFreeNodes()}get freeNodes(){return this.freeNodesScene.children}get freeEntities(){return this.freeNodes}addScene(t){this.scenes.includes(t)&&console.warn(`Game.addScene(): scene ${t.toString()} has already been added to the game. This will cause unpredictable behavior. This warning will become an error in a future release.`),t.game=this,t.needsInitialization=!0,this.scenes.push(t),this.addNodeEvents(t)}addNodeEvents(t){this.eventStore.addEvents(t.nodeEvents),t.nodeEvents.length=0;for(const i of t.children)this.addNodeEvents(i)}addScenes(t){t.forEach(i=>{this.addScene(i)})}removeScene(t){if(typeof t=="object")if(this.scenes.includes(t))this.scenes=this.scenes.filter(i=>i!==t);else throw new C(`cannot remove scene ${t} from game because the scene is not currently added to the game`);else if(this.scenes.map(i=>i.name).includes(t))this.scenes=this.scenes.filter(i=>i.name!==t);else throw new C(`cannot remove scene named "${t}" from game because the scene is not currently added to the game`)}presentScene(t,i){let r;if(typeof t=="string"){if(r=this.scenes.filter(E=>E.name===t).find(Boolean),r===void 0&&(r=this.scenes.filter(E=>E.uuid===t).find(Boolean)),r===void 0)throw new C(`scene ${t} not found`)}else{if(!this.scenes.some(E=>E===t))throw new C(`scene ${t} exists, but it has not been added to the game object`);r=t}r.initialize(),r.needsInitialization=!1;const h=new is(r,i??Ke.none());this.incomingSceneTransitions.push(h),r.game.bodyBackgroundColor!==void 0?document.body.style.backgroundColor=`rgb(${r.game.bodyBackgroundColor[0]},${r.game.bodyBackgroundColor[1]},${r.game.bodyBackgroundColor[2]},${r.game.bodyBackgroundColor[3]})`:document.body.style.backgroundColor=`rgb(${r.backgroundColor[0]},${r.backgroundColor[1]},${r.backgroundColor[2]},${r.backgroundColor[3]})`;let c;i?.type===Se.Slide&&(c=i.direction);const S={type:"ScenePresent",target:r,uuid:r.uuid,...q.createFrameUpdateTimestamps(),transitionType:i?.type??Se.None,duration:i?.duration,direction:c,easingType:i?.easing?De.toTypeAsString(i.easing):void 0};this.eventStore.addEvent(S)}getParameter(t){if(this.options.parameters!==void 0&&Object.keys(this.options.parameters).includes(t))return this.options.parameters[t].default;throw new C(`game parameter ${t} not found`)}getParameterOrFallback(t,i){return this.options.parameters!==void 0&&Object.keys(this.options.parameters).includes(t)?this.options.parameters[t].default:i}hasParameter(t){return!!(this.options.parameters!==void 0&&Object.keys(this.options.parameters).includes(t))}async start(t){const i=this.options;this.setupHtmlCanvases(i.canvasId,i.width,i.height,i.stretch),this.showFps=i.showFps??!1,this.bodyBackgroundColor=i.bodyBackgroundColor,this.initData(),this.setupCanvasKitSurface(),this.setupFpsFont(),this.setupCanvasDomEventHandlers(),this.beginTimestamp=Vt.now(),this.beginIso8601Timestamp=new Date().toISOString();let r;if(t!==void 0?typeof t=="object"?r=t:r=this.scenes.filter(S=>S.name===t).find(Boolean):this.entryScene!==void 0?typeof this.entryScene=="object"?r=this.entryScene:r=this.scenes.filter(S=>S.name===this.entryScene).find(Boolean):r=this.scenes.find(Boolean),r===void 0)throw new C("cannot start game. entry scene has not been added to the game object.");if(this.presentScene(r),this.surface===void 0)throw new C("CanvasKit surface is undefined");this.options.timeStepping?(this.addTimeSteppingControlsToDom(),this.updateTimeSteppingOutput()):this.removeTimeSteppingControlsFromDom(),this.options.showEventStoreControls&&this.addEventControlsToDom(),this.warmupFinished=!1;const h={target:this,type:H.GameWarmupStart,...q.createFrameUpdateTimestamps()};this.raiseActivityEventOnListeners(h),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 c={target:this,type:H.ActivityStart,...q.createFrameUpdateTimestamps()};this.raiseActivityEventOnListeners(c)}playEventsHandler(t){if(t?.target?.id==="replay-events"&&(this.eventStore.mode=ve.Disabled,this.scenes.forEach(i=>{this.removeScene(i)}),this.currentScene=void 0,this.eventListeners=new Array,this.freeNodesScene.removeAllChildren(),this.materializedNodes=[],this.eventStore.replay(),this.setReplayEventsButtonEnabled(!1),this.setStopReplayButtonEnabled(!0)),t?.target?.id==="stop-replay"&&(this.eventStore.clearEvents(),this.setReplayEventsButtonEnabled(!0),this.setStopReplayButtonEnabled(!1)),t?.target?.id==="log-events"){if(this.eventStore.mode===ve.Replay){console.log(this.eventStore.serializedEventsBeforeReplay),console.log(`Total events: ${JSON.parse(this.eventStore.serializedEventsBeforeReplay).length}`);return}console.log(JSON.stringify(this.eventStore.getEvents())),console.log(`Total events: ${this.eventStore.getEvents().length}`)}}setReplayEventsButtonEnabled(t){const i=document.getElementById("replay-events");if(i){if(t){i.removeAttribute("disabled"),this.replayEventsButtonEnabled=!0;return}i.setAttribute("disabled","true"),this.replayEventsButtonEnabled=!1}}setStopReplayButtonEnabled(t){const i=document.getElementById("stop-replay");if(i){if(t){i.removeAttribute("disabled");return}i.setAttribute("disabled","true")}}addEventControlsToDom(){const t=document.getElementById("m2c2kit-event-controls-div");t&&t.remove();const i=document.getElementsByTagName("body")[0];if(i){const r=document.createElement("div");r.id="m2c2kit-event-controls-div",r.style.position="fixed",r.style.top="4px",r.style.left="4px",i.prepend(r);const h=document.createElement("button");h.id="replay-events",h.title="replay event recording",h.innerText="\u25B6\uFE0F",h.style.marginRight="4px",r.appendChild(h),h.addEventListener("click",this.playEventsHandler.bind(this));const c=document.createElement("button");c.id="stop-replay",c.title="stop event replay",c.innerText="\u23F9\uFE0F",c.style.marginRight="4px",c.disabled=!0,r.appendChild(c),c.addEventListener("click",this.playEventsHandler.bind(this));const S=document.createElement("button");S.id="log-events",S.title="log events to console",S.innerText="\u{1F4C4}",S.style.marginRight="4px",r.appendChild(S),S.addEventListener("click",this.playEventsHandler.bind(this));const E=document.createElement("span");E.title="optional: replay events only through a given sequence number. Default is to replay all events.",E.innerText="Replay through sequence: ",r.appendChild(E);const O=document.createElement("input");O.id="sequence-number",O.title="optional: replay events only through a given sequence number. Default is to replay all events.",O.style.marginRight="4px",r.appendChild(O)}}addTimeSteppingControlsToDom(){if(document.getElementById("m2c2kit-time-stepping-div"))return;const i=document.getElementsByTagName("body")[0];if(i){const r=document.createElement("div");r.id="m2c2kit-time-stepping-div",i.prepend(r);const h=document.createElement("button");h.id="1-step-advance",h.title="advance 1 step (16.667 ms)",h.innerText=">",h.style.marginRight="4px",r.appendChild(h),h.addEventListener("click",this.advanceStepsHandler.bind(this));const c=document.createElement("button");c.id="55-step-advance",c.title="advance 55 steps (916.667 ms)",c.innerText=">>",c.style.marginRight="4px",r.appendChild(c),c.addEventListener("click",this.advanceStepsHandler.bind(this));const S=document.createElement("input");S.id="time-stepping-steps-input",S.title="steps",S.style.width="40px",S.style.marginRight="4px",S.setAttribute("readonly","true"),r.appendChild(S);const E=document.createElement("input");E.id="time-stepping-now-input",E.title="milliseconds",E.style.width="80px",E.style.marginRight="4px",E.setAttribute("readonly","true"),r.appendChild(E)}}updateTimeSteppingOutput(){const t=document.getElementById("time-stepping-steps-input");t&&(t.value=this.stepCount.toString());const i=document.getElementById("time-stepping-now-input");i&&(i.value=this.steppingNow.toFixed(2))}advanceStepsHandler(t){t?.target?.id==="1-step-advance"?(this.steppingNow=this.steppingNow+16.66666666666667,this.stepCount=this.stepCount+1):t?.target?.id==="55-step-advance"&&(this.steppingNow=this.steppingNow+16.66666666666667*55,this.stepCount=this.stepCount+55),this.updateTimeSteppingOutput()}removeTimeSteppingControlsFromDom(){const t=document.getElementById("m2c2kit-time-stepping-div");t&&t.remove()}warmupShadersWithPrimitives(t,i=0){if(t.save(),i==0?t.scale(1/m2c2Globals.canvasScale,1/m2c2Globals.canvasScale):t.scale(1/m2c2Globals.canvasScale*1.13,1/m2c2Globals.canvasScale*1.13),!this.surface)throw new C("surface is undefined");const r=this.surface.width(),h=this.surface.height(),c=Math.round(r/2)+i,S=Math.round(h/2)+i,E=i,O=i,G=Nt.makePaint(this.canvasKit,R.White,this.canvasKit.PaintStyle.Fill,!0);t.drawRect([0,0,this.surface.width(),this.surface.height()],G);const K=Nt.makePaint(this.canvasKit,R.Black,this.canvasKit.PaintStyle.Fill,!1),it=Nt.makePaint(this.canvasKit,R.Black,this.canvasKit.PaintStyle.Fill,!0),lt=Nt.makePaint(this.canvasKit,R.Black,this.canvasKit.PaintStyle.Stroke,!1);lt.setStrokeWidth(2);const yt=Nt.makePaint(this.canvasKit,R.Black,this.canvasKit.PaintStyle.Stroke,!0);yt.setStrokeWidth(2),t.drawCircle(c,S,32,K),t.drawCircle(c,S,32,it),t.drawCircle(c,S,32,lt),t.drawCircle(c,S,32,yt);const st=this.fontManager,Et=this.fontManager.getFontNames();if(Et.length>0&&st.fonts[Et[0]].status===re.Ready){const Bt=st.getTypeface(Et[0]),se=new this.canvasKit.Font(Bt,16*m2c2Globals.canvasScale);t.drawText("abc",c,S,K,se),t.drawText("abc",c,S,it,se)}const Wt=this.takeCurrentSceneSnapshot();t.drawImage(Wt,E,O),Wt.delete(),t.drawRect([E,O,16,16],K),t.drawRect([E,O,16,16],it),t.drawRect([E,O,16,16],lt),t.drawRect([E,O,16,16],yt),t.restore()}warmupShadersWithScenes(t){[...this.scenes,this.freeNodesScene].forEach(c=>{c.warmup(t)});const i=this.nodes.filter(c=>c.type===dt.Sprite).map(c=>c.imageName),r=this.imageManager.images;r&&Object.keys(r).filter(S=>S!=="__outgoingSceneSnapshot").forEach(S=>{if(!i.includes(S)&&r[S].status===ne.Ready){const E=r[S].canvaskitImage;if(!E)throw new C(`image ${S} is undefined`);t.drawImage(E,0,0)}});const h=new this.canvasKit.Paint;if(h.setColor(this.canvasKit.Color(255,255,255,1)),!this.surface)throw new C("surface is undefined");t.drawRect([0,0,this.surface.width(),this.surface.height()],h)}stop(){this.currentScene&&(this.currentScene._active=!1),this.gameStopRequested=!0,Vt.removeAll(),this.dispose()}dispose(){this.nodes.filter(t=>t.isDrawable).forEach(t=>t.dispose()),this.fontManager.dispose()}initData(){this.trialIndex=0,this.data={trials:new Array,scoring:{}};const t=this.options.trialSchema??{},i=this.options.scoringSchema??{};this.validateSchema(t),this.validateSchema(i)}validateSchema(t){const i=Object.entries(t);for(const[r,h]of i)if(h.type!==void 0&&!this.propertySchemaDataTypeIsValid(h.type))throw new C(`invalid schema. variable ${r} is type ${h.type}. type must be number, string, boolean, object, or array`)}propertySchemaDataTypeIsValid(t){const i=["string","number","integer","object","array","boolean","null"];if(typeof t=="string")return i.includes(t);let r=!0;if(Array.isArray(t))t.forEach(h=>{i.includes(h)||(r=!1)});else throw new C(`Invalid data type: ${t}`);return r}getDeviceMetadata(){const t=window.screen;return t.orientation?{userAgent:navigator.userAgent,devicePixelRatio:window.devicePixelRatio,screen:{availHeight:t.availHeight,availWidth:t.availWidth,colorDepth:t.colorDepth,height:t.height,orientation:{type:t.orientation.type,angle:t.orientation.angle},pixelDepth:t.pixelDepth,width:t.width},webGlRenderer:this.webGlRendererInfo}:{userAgent:navigator.userAgent,devicePixelRatio:window.devicePixelRatio,screen:{availHeight:t.availHeight,availWidth:t.availWidth,colorDepth:t.colorDepth,height:t.height,pixelDepth:t.pixelDepth,width:t.width},webGlRenderer:this.webGlRendererInfo}}addTrialData(t,i){if(!this.options.trialSchema)throw new C("no trial schema were provided in GameOptions. cannot add trial data");if(this.data.trials.length<this.trialIndex+1){const c={},S=Object.entries(this.options.trialSchema);for(const[E]of S)c[E]=null;this.data.trials.push({data_type:"trial",document_uuid:ze.generate(),study_id:this.studyId??null,study_uuid:this.studyUuid??null,session_uuid:this.sessionUuid,activity_uuid:this.uuid,activity_id:this.options.id,activity_publish_uuid:this.options.publishUuid,activity_version:this.options.version,device_timezone:Intl?.DateTimeFormat()?.resolvedOptions()?.timeZone??"",device_timezone_offset_minutes:new Date().getTimezoneOffset(),locale:this.i18n?.locale??null,...c,device_metadata:this.getDeviceMetadata()})}if(!(t in this.options.trialSchema))throw new C(`trial variable ${t} not defined in schema`);let r;Array.isArray(this.options.trialSchema[t].type)?r=this.options.trialSchema[t].type:r=[this.options.trialSchema[t].type];let h=typeof i;if(h==="object"&&Object.prototype.toString.call(i)==="[object Array]"&&(h="array"),i==null&&(h="null"),!r.includes(h)&&!(h==="number"&&Number.isInteger(i)&&r.includes("integer")))throw new C(`type for variable ${t} (value: ${i}) is "${h}". Based on schema for this variable, expected type was "${r}"`);this.data.trials[this.trialIndex][t]=i}addScoringData(t,i){if(!this.options.scoringSchema)throw new C("no scoring schema were provided in GameOptions. cannot add scoring data");if(Object.keys(this.data.scoring).length===0){const h={data_type:"scoring",document_uuid:ze.generate(),study_id:this.studyId??null,study_uuid:this.studyUuid??null,session_uuid:this.sessionUuid,activity_uuid:this.uuid,activity_id:this.options.id,activity_publish_uuid:this.options.publishUuid,activity_version:this.options.version,device_timezone:Intl?.DateTimeFormat()?.resolvedOptions()?.timeZone??"",device_timezone_offset_minutes:new Date().getTimezoneOffset(),locale:this.i18n?.locale??null,device_metadata:this.getDeviceMetadata()},c=Object.entries(this.options.scoringSchema);for(const[S]of c)h[S]=null;this.data.scoring=h}if(typeof t=="object"){let h;Array.isArray(t)?(t.length!==1&&console.warn(`Array of objects passed to addScoringData() is length ${t.length}. This is likely an error in the assessment's code for calculateScores().`),h=t[0]):h=t;for(const[c,S]of Object.entries(h))this.validateAndSetScoringVariable(c,S);return}const r=t;if(i===void 0)throw new C("Value must be provided when adding a single scoring variable");this.validateAndSetScoringVariable(r,i)}validateAndSetScoringVariable(t,i){if(!this.options.scoringSchema)throw new C("no scoring schema were provided in GameOptions. cannot add scoring data");if(!(t in this.options.scoringSchema))throw new C(`scoring variable ${t} not defined in schema`);let r;Array.isArray(this.options.scoringSchema[t].type)?r=this.options.scoringSchema[t].type:r=[this.options.scoringSchema[t].type];let h=typeof i;if(h==="object"&&Object.prototype.toString.call(i)==="[object Array]"&&(h="array"),i==null&&(h="null"),!r.includes(h)&&!(h==="number"&&Number.isInteger(i)&&r.includes("integer")))throw new C(`type for variable ${t} (value: ${i}) is "${h}". Based on schema for this variable, expected type was "${r}"`);this.data.scoring[t]=i}addTrialSchema(t){Object.keys(t).forEach(r=>{if(!this.options.trialSchema)throw new C("trial schema is undefined");this.options.trialSchema[r]=t[r]})}addStaticTrialData(t,i){if(!this.options.trialSchema)throw new C("trial schema is undefined");if(this.options.trialSchema[t]===void 0)throw new C(`trial variable ${t} not defined in schema`);this.staticTrialSchema[t]=i}trialComplete(){this.data.trials[this.trialIndex]?.locale&&(this.data.trials[this.trialIndex].locale=this.i18n?.locale??null),this.data.trials[this.trialIndex]?.device_metadata&&(this.data.trials[this.trialIndex].device_metadata=this.getDeviceMetadata()),Object.keys(this.staticTrialSchema).length>0&&(this.data.trials[this.trialIndex]={...this.data.trials[this.trialIndex],...this.staticTrialSchema}),this.trialIndex++;const t={type:H.ActivityData,...q.createFrameUpdateTimestamps(),target:this,newData:this.data.trials[this.trialIndex-1],newDataSchema:this.makeNewGameDataSchema(),data:this.data,dataSchema:this.makeGameDataSchema(),dataType:"Trial",activityConfiguration:this.makeGameActivityConfiguration(this.options.parameters??{}),activityConfigurationSchema:this.makeGameActivityConfigurationSchema(this.options.parameters??{}),activityMetrics:this.gameMetrics};this.raiseActivityEventOnListeners(t)}scoringComplete(){const t={type:H.ActivityData,...q.createFrameUpdateTimestamps(),target:this,newData:this.data.scoring,newDataSchema:this.makeScoringDataSchema(),data:this.data.scoring,dataSchema:this.makeScoringDataSchema(),dataType:"Scoring",activityConfiguration:this.makeGameActivityConfiguration(this.options.parameters??{}),activityConfigurationSchema:this.makeGameActivityConfigurationSchema(this.options.parameters??{}),activityMetrics:this.gameMetrics};this.raiseActivityEventOnListeners(t)}makeNewGameDataSchema(){return{description:`A single trial and metadata from the assessment ${this.name}.`,$comment:`Activity identifier: ${this.options.id}, version: ${this.options.version}.`,$schema:"https://json-schema.org/draft/2019-09/schema",type:"object",properties:{...this.automaticTrialSchema,...this.options.trialSchema,device_metadata:bn}}}makeGameDataSchema(){return{description:`All trials and metadata from the assessment ${this.name}.`,$comment:`Activity identifier: ${this.options.id}, version: ${this.options.version}.`,$schema:"https://json-schema.org/draft/2019-09/schema",type:"object",required:["trials"],properties:{trials:{type:"array",items:{$ref:"#/$defs/trial"},description:"All trials from the assessment."}},$defs:{trial:{type:"object",properties:{...this.automaticTrialSchema,...this.options.trialSchema,device_metadata:bn}}}}}makeGameActivityConfiguration(t){const i=JSON.parse(JSON.stringify(t)),{locale:r,fallback_locale:h,missing_localization_color:c,translation:S,...E}=i;for(const O in E)for(const G in E[O])G=="default"&&(E[O]=E[O][G]);return E}makeGameActivityConfigurationSchema(t){const i=JSON.parse(JSON.stringify(t)),{locale:r,fallback_locale:h,missing_localization_color:c,translation:S,...E}=i;for(const O in E){if(!("type"in E[O])&&"value"in E[O]){const G=typeof E[O].default;G!=="bigint"&&G!=="function"&&G!=="symbol"&&G!=="undefined"&&(E[O].type=G)}for(const G in E[O])G=="default"&&delete E[O][G]}return{description:`activity configuration from the assessment ${this.name}`,type:"object",properties:E}}makeScoringDataSchema(){return{description:`Scoring data 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.automaticScoringSchema,...this.options.scoringSchema,device_metadata:bn}}}end(){const t={target:this,type:H.ActivityEnd,...q.createFrameUpdateTimestamps()},i={data:this.data,dataSchema:this.makeGameDataSchema(),dataType:"Trial",activityConfiguration:this.makeGameActivityConfiguration(this.options.parameters??{}),activityConfigurationSchema:this.makeGameActivityConfigurationSchema(this.options.parameters??{}),activityMetrics:this.gameMetrics};this.raiseActivityEventOnListeners(t,i)}cancel(){const t={target:this,type:H.ActivityCancel,...q.createFrameUpdateTimestamps()},i={data:this.data,dataSchema:this.makeGameDataSchema(),dataType:"Trial",activityConfiguration:this.makeGameActivityConfiguration(this.options.parameters??{}),activityConfigurationSchema:this.makeGameActivityConfigurationSchema(this.options.parameters??{}),activityMetrics:this.gameMetrics};this.raiseActivityEventOnListeners(t,i)}setupHtmlCanvases(t,i,r,h){m2c2Globals.canvasScale=Math.round(window.devicePixelRatio*100)/100;let c;if(t===void 0){const S=document.getElementsByTagName("canvas");let E=new Array;for(let G=0;G<S.length;G++)E.push(S[G]);if(E=E.filter(G=>!G.id.startsWith("m2c2kit-scratch-canvas")),E.length===0)throw new C("no html canvas tag was found in the html");const O=E.filter(G=>G.id==="m2c2kit-canvas")[0];O?(c=O,E.length>1&&console.log("using canvas with id 'm2c2kit-canvas'")):(c=S[0],E.length>1&&console.log("using first canvas"))}else if(c=document.getElementById(t),c===void 0)throw new C(`could not find canvas HTML element with id "${t}"`);if(h||window.innerWidth<i||window.innerHeight<r){const S=r/i;window.innerHeight/window.innerWidth<S?m2c2Globals.rootScale=window.innerHeight/r:m2c2Globals.rootScale=window.innerWidth/i}c.style.width=m2c2Globals.rootScale*i+"px",c.style.height=m2c2Globals.rootScale*r+"px",c.width=m2c2Globals.rootScale*i*m2c2Globals.canvasScale,c.height=m2c2Globals.rootScale*r*m2c2Globals.canvasScale,this.htmlCanvas=c,this.canvasCssWidth=i,this.canvasCssHeight=r,m2c2Globals.canvasCssWidth=i,m2c2Globals.canvasCssHeight=r}setupCanvasKitSurface(){if(this.htmlCanvas===void 0)throw new C("main html canvas is undefined");window.logWebGl=this.options.logWebGl,this.interceptWebGlCalls();try{this.webGlRendererInfo=Pn.getRendererString()}catch{this.webGlRendererInfo="err",Pn.dispose()}const t=this.canvasKit.MakeWebGLCanvasSurface(this.htmlCanvas);if(t===null)throw new C("could not make CanvasKit surface from canvas HTML element");this.surface=t,console.log(`\u26AA CanvasKit surface is backed by ${this.surface.reportBackendTypeIsGPU()?"GPU":"CPU"}`),this.surface.getCanvas().scale(m2c2Globals.canvasScale,m2c2Globals.canvasScale)}interceptWebGlCalls(){if(!this.htmlCanvas.__proto__.m2c2ModifiedGetContext){this.htmlCanvas.__proto__.m2c2ModifiedGetContext=!0;const t=this.htmlCanvas.__proto__.getContext;this.htmlCanvas.__proto__.getContext=function(...i){window.logWebGl&&console.log(`\u{1F53C} getContext(${i.map(h=>h.toString()).join(", ")})`);const r=t.apply(this,[...i]);if(r.__proto__.compileShader&&!r.__proto__.m2c2ModifiedCompileShader){r.__proto__.m2c2ModifiedCompileShader=!0;const h=r.__proto__.compileShader;r.__proto__.compileShader=function(...c){if(window.logWebGl){const S=c[0],E=r.getShaderSource(S);console.log("\u{1F53C} compileShader():"),console.log(E)}return h.apply(this,[...c])}}return r}}}setupFpsFont(){this.fpsTextFont=new this.canvasKit.Font(null,Q.FPS_DISPLAY_TEXT_FONT_SIZE*m2c2Globals.canvasScale),this.fpsTextPaint=new this.canvasKit.Paint,this.fpsTextPaint.setColor(this.canvasKit.Color(Q.FPS_DISPLAY_TEXT_COLOR[0],Q.FPS_DISPLAY_TEXT_COLOR[1],Q.FPS_DISPLAY_TEXT_COLOR[2],Q.FPS_DISPLAY_TEXT_COLOR[3])),this.fpsTextPaint.setAntiAlias(!0)}setupCanvasDomEventHandlers(){if(this.htmlCanvas===void 0)throw new C("main html canvas is undefined");this.htmlCanvas.addEventListener("pointerdown",this.htmlCanvasPointerDownHandler.bind(this)),this.htmlCanvas.addEventListener("pointerup",this.htmlCanvasPointerUpHandler.bind(this)),this.htmlCanvas.addEventListener("pointermove",this.htmlCanvasPointerMoveHandler.bind(this)),this.htmlCanvas.addEventListener("touchstart",t=>{t.preventDefault()}),this.htmlCanvas.addEventListener("pointerleave",this.htmlCanvasPointerLeaveHandler.bind(this)),document.addEventListener("keydown",this.documentKeyDownHandler.bind(this)),document.addEventListener("keyup",this.documentKeyUpHandler.bind(this))}loop(t){if(!this.surface)throw new C("surface is undefined");if(this.warmupFunctionQueue.length>0){const i=this.warmupFunctionQueue.shift();i?.warmupFunction.call(this,t,i.positionOffset),this.surface.requestAnimationFrame(this.loop.bind(this));return}if(!this.warmupFinished){this.warmupFinished=!0;const i={target:this,type:H.GameWarmupEnd,...q.createFrameUpdateTimestamps()};this.raiseActivityEventOnListeners(i),this.surface.requestAnimationFrame(this.loop.bind(this));return}if(this.soundManager.hasSoundsToDecode()&&navigator.userActivation.hasBeenActive&&this.soundManager.decodeFetchedSounds(),this.gameStopRequested){this.surface.deleteLater();return}if(this.animationFramesRequested++,!this.limitFps||this.animationFramesRequested%Math.round(60/Q.LIMITED_FPS_RATE)===0){if(this.currentScene===void 0&&this.incomingSceneTransitions.length===0&&this.eventStore.mode!==ve.Replay)throw new C("Can not run game without a current or incoming scene");if(this.updateGameTime(),this.eventStore.mode===ve.Replay){const i=this.eventStore.dequeueEvents(Vt.now());this.eventMaterializer.materialize(i),this.eventStore.eventQueueLength===0&&!this.replayEventsButtonEnabled&&(this.setReplayEventsButtonEnabled(!0),this.setStopReplayButtonEnabled(!1))}for(this.handleIncomingSceneTransitions(this.incomingSceneTransitions),this.update(),this.draw(t);this.snapshots.length>0;)this.snapshots.shift()?.delete();this.snapshots.push(this.takeCurrentSceneSnapshot()),this.freeNodesScene.draw(t),this.pendingScreenshot&&(this.handlePendingScreenshot(this.pendingScreenshot),this.pendingScreenshot=void 0)}this.priorUpdateTime=m2c2Globals.now,this.surface.requestAnimationFrame(this.loop.bind(this))}updateGameTime(){this.options.timeStepping?m2c2Globals.now=this.steppingNow:m2c2Globals.now=performance.now(),this.priorUpdateTime?m2c2Globals.deltaTime=m2c2Globals.now-this.priorUpdateTime:m2c2Globals.deltaTime=0}handleIncomingSceneTransitions(t){if(t.length!==0&&(this.snapshots.length>0||t[0].transition.type===Se.None)){const i=t.shift();if(i===void 0)throw new C("no incoming scene transition");const r=i.scene,h=i.transition;if(h.type===Se.None){this.currentScene&&(this.currentScene._active=!1),this.currentScene=r,this.currentScene._active=!0,this.raiseSceneEvent(r,"SceneSetup"),this.raiseSceneEvent(r,"SceneAppear");return}if(this.currentSceneSnapshot=this.snapshots.shift(),!this.currentSceneSnapshot)throw new C("No snapshot available for outgoing scene");const c=this.createOutgoingScene(this.currentSceneSnapshot);c._active=!0,this.currentScene&&(this.currentScene._active=!1),this.currentScene=r,this.currentScene._active=!0,this.raiseSceneEvent(r,"SceneSetup"),this.animateSceneTransition(r,h,c)}}createOutgoingScene(t){const i=new Ve({name:Q.OUTGOING_SCENE_NAME});i.size.width=this.canvasCssWidth,i.size.height=this.canvasCssHeight,this.addScene(i);const r={imageName:Q.OUTGOING_SCENE_IMAGE_NAME,canvaskitImage:t,width:this.canvasCssWidth,height:this.canvasCssHeight,status:ne.Ready,localize:!1,isFallback:!1};this.imageManager.addImage(r);const h=new pi({name:Q.OUTGOING_SCENE_SPRITE_NAME,imageName:Q.OUTGOING_SCENE_IMAGE_NAME,position:{x:this.canvasCssWidth/m2c2Globals.rootScale/2,y:this.canvasCssHeight/m2c2Globals.rootScale/2}});return h.scale=1/m2c2Globals.rootScale,i.addChild(h),i}async registerPlugin(t){if(t.type!==ui.Game)throw new C(`registerPlugin(): plugin ${t.id} is not a game plugin. It is a ${t.type} plugin.`);if(this.plugins.includes(t)||this.plugins.map(i=>i.id).includes(t.id))throw new C(`registerPlugin(): plugin ${t.id} already registered.`);this.plugins.push(t),t.initialize&&await t.initialize(this)}update(){this.executeBeforeUpdatePlugins(),this.updateScenes(),this.executeAfterUpdatePlugins()}updateScenes(){this.scenes.filter(t=>t._active).forEach(t=>t.update()),this.freeNodesScene.update()}executeBeforeUpdatePlugins(){this.plugins.filter(t=>typeof t.beforeUpdate=="function"&&t.disabled!==!0).forEach(t=>{t.beforeUpdate&&t.beforeUpdate(this,m2c2Globals.deltaTime)})}executeAfterUpdatePlugins(){this.plugins.filter(t=>typeof t.afterUpdate=="function"&&t.disabled!==!0).forEach(t=>{t.afterUpdate&&t.afterUpdate(this,m2c2Globals.deltaTime)})}draw(t){this.scenes.filter(i=>i._active).forEach(i=>i.draw(t)),this.drawnFrames++,this.calculateFps(),this.showFps&&this.drawFps(t)}calculateFps(){this.lastFpsUpdate===0?(this.lastFpsUpdate=m2c2Globals.now,this.nextFpsUpdate=m2c2Globals.now+Q.FPS_DISPLAY_UPDATE_INTERVAL):m2c2Globals.now>=this.nextFpsUpdate&&(this.fpsRate=this.drawnFrames/((m2c2Globals.now-this.lastFpsUpdate)/1e3),this.drawnFrames=0,this.lastFpsUpdate=m2c2Globals.now,this.nextFpsUpdate=m2c2Globals.now+Q.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:Q.FPS_DISPLAY_UPDATE_INTERVAL,fps_report_threshold:this.fpsMetricReportThreshold,activity_type:ui.Game,activity_uuid:this.uuid,iso8601_timestamp:new Date().toISOString()}))}takeCurrentSceneSnapshot(){if(this.surface===void 0)throw new C("CanvasKit surface is undefined");return this.surface.makeImageSnapshot()}handlePendingScreenshot(t){if(!this.surface)throw new C("no surface");let i;if(t.rect.length==4){const h=t.rect[0]*m2c2Globals.canvasScale,c=t.rect[1]*m2c2Globals.canvasScale,S=t.rect[2]*m2c2Globals.canvasScale,E=t.rect[3]*m2c2Globals.canvasScale,O=[h,c,h+S,c+E];i=this.surface.makeImageSnapshot(O)}else i=this.surface.makeImageSnapshot();const r=i.encodeToBytes();t.promiseResolve(r)}takeScreenshot(t,i,r,h){if(!this.surface)throw new C("no canvaskit surface. unable to take screenshot.");const c=[t,i,r,h].map(S=>S===void 0?1:0).reduce((S,E)=>S+E);return new Promise((S,E)=>{switch(c){case 0:{if(t===void 0||i===void 0||r===void 0||h===void 0){E("missing values in arguments for takeScreenshot()");return}this.pendingScreenshot={rect:[t,i,r,h],promiseResolve:S};break}case 4:{this.pendingScreenshot={rect:[],promiseResolve:S};break}default:E("Exactly 0 or 4 arguments must be supplied to takeScreenshot()")}})}animateSceneTransition(t,i,r){const h=i.duration;switch(t._transitioning=!0,r._transitioning=!0,i.type){case Se.Slide:{switch(i.direction){case be.Left:t.position.x=t.size.width,t.run(X.sequence([X.move({point:{x:0,y:0},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{t._transitioning=!1,this.raiseSceneEvent(t,"SceneAppear"),this.removeScene(Q.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),r.run(X.sequence([X.move({point:{x:-r.size.width,y:0},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{r._active=!1,r._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;case be.Right:t.position.x=-t.size.width,t.run(X.sequence([X.move({point:{x:0,y:0},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{t._transitioning=!1,this.raiseSceneEvent(t,"SceneAppear"),this.removeScene(Q.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),r.run(X.sequence([X.move({point:{x:r.size.width,y:0},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{r._active=!1,r._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;case be.Up:t.position.y=t.size.height,t.run(X.sequence([X.move({point:{x:0,y:0},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{t._transitioning=!1,this.raiseSceneEvent(t,"SceneAppear"),this.removeScene(Q.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),r.run(X.sequence([X.move({point:{x:0,y:-r.size.height},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{r._active=!1,r._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;case be.Down:t.position.y=-t.size.height,t.run(X.sequence([X.move({point:{x:0,y:0},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{t._transitioning=!1,this.raiseSceneEvent(t,"SceneAppear"),this.removeScene(Q.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),r.run(X.sequence([X.move({point:{x:0,y:r.size.height},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{r._active=!1,r._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;default:throw new C("unknown transition direction")}break}default:throw new C("unknown transition type")}}drawFps(t){t.save();const i=m2c2Globals.canvasScale;if(t.scale(1/i,1/i),!this.fpsTextFont||!this.fpsTextPaint)throw new C("fps font or paint is undefined");t.drawText("FPS: "+this.fpsRate.toFixed(2),0,0+Q.FPS_DISPLAY_TEXT_FONT_SIZE*i,this.fpsTextPaint,this.fpsTextFont),t.restore()}createEventListener(t,i,r,h){const c=this.nodes.filter(E=>E.name===i);c.length>1&&console.warn(`warning: createEventListener() found more than one node with name ${i}. Event listener will be attached to first node found. All nodes that receive tap events should be uniquely named`);const S=c.filter(E=>E.name===i).find(Boolean);if(S===void 0)throw new C(`could not create event listener. node with name ${i} could not be found in the game node tree`);if(!Object.values(H).includes(t))throw new C(`game ${this.id}: could not create event listener. event type ${t} is not known`);S.addEventListener(t,r,h)}get nodes(){function t(r,h){h.push(r),r.children.forEach(c=>t(c,h))}const i=new Array;return[...this.scenes,this.freeNodesScene].forEach(r=>t(r,i)),i}get entities(){return this.nodes}htmlCanvasPointerDownHandler(t){t.preventDefault();const i=this.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;if(!this.htmlCanvas)throw new C("main html canvas is undefined");const r={type:"DomPointerDown",target:this.htmlCanvas,x:t.offsetX/m2c2Globals.rootScale,y:t.offsetY/m2c2Globals.rootScale,...q.createTimestamps()};this.eventStore.addEvent(r);const h={target:i,type:H.PointerDown,handled:!1,...q.createTimestamps()};this.processDomPointerDown(this.freeNodesScene,h,t),this.processDomPointerDown(i,h,t)}htmlCanvasPointerUpHandler(t){t.preventDefault();const i=this.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;const r={target:i,type:H.PointerUp,handled:!1,...q.createTimestamps()};this.processDomPointerUp(this.freeNodesScene,r,t),this.processDomPointerUp(i,r,t)}htmlCanvasPointerMoveHandler(t){t.preventDefault();const i=this.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;const r={target:i,type:H.PointerMove,handled:!1,...q.createTimestamps()};this.processDomPointerMove(this.freeNodesScene,r,t),this.processDomPointerMove(i,r,t)}htmlCanvasPointerLeaveHandler(t){if(!this.currentScene)return;t.preventDefault();const i=this.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;const r={target:i,type:H.PointerLeave,handled:!1,...q.createTimestamps()};this.processDomPointerLeave(this.freeNodesScene,r,t),this.processDomPointerLeave(i,r,t)}documentKeyDownHandler(t){const i=this.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;const r={target:i,type:H.KeyDown,handled:!1,...q.createTimestamps()};this.raiseEventOnListeningNodes(this.freeNodesScene,r,t),this.raiseEventOnListeningNodes(i,r,t)}documentKeyUpHandler(t){const i=this.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;const r={target:i,type:H.KeyUp,handled:!1,...q.createTimestamps()};this.raiseEventOnListeningNodes(this.freeNodesScene,r,t),this.raiseEventOnListeningNodes(i,r,t)}processDomPointerDown(t,i,r){i.handled||(t.isUserInteractionEnabled&&this.IsCanvasPointWithinNodeBounds(t,r.offsetX,r.offsetY)&&(t.pressed=!0,t.pressedAndWithinHitArea=!0,t.pressedInitialPointerOffset={x:r.offsetX,y:r.offsetY},this.raiseM2PointerDownEvent(t,i,r),this.raiseTapDownEvent(t,i,r)),t.children&&t.children.filter(h=>!h.hidden).filter(h=>h.isDrawable).sort((h,c)=>{const S=c.zPosition-h.zPosition;return S!==0?S:t.children.indexOf(c)-t.children.indexOf(h)}).forEach(h=>this.processDomPointerDown(h,i,r)))}processDomPointerUp(t,i,r){if(!i.handled){if(t.dragging){t.dragging=!1,t.pressed=!1,t.pressedAndWithinHitArea=!1,this.raiseM2DragEndEvent(t,i,r);return}t.isUserInteractionEnabled&&t.pressed&&t.pressedAndWithinHitArea?(t.pressed=!1,t.pressedAndWithinHitArea=!1,this.raiseTapUpEvent(t,i,r),this.raiseTapUpAny(t,i,r),this.raiseM2PointerUpEvent(t,i,r)):t.isUserInteractionEnabled&&t.pressed&&t.pressedAndWithinHitArea==!1?(t.pressed=!1,t.pressedAndWithinHitArea=!1,this.raiseTapUpAny(t,i,r)):t.isUserInteractionEnabled&&this.IsCanvasPointWithinNodeBounds(t,r.offsetX,r.offsetY)&&(t.pressed=!1,t.pressedAndWithinHitArea=!1,this.raiseM2PointerUpEvent(t,i,r)),t.children&&t.children.filter(h=>!h.hidden).filter(h=>h.isDrawable).sort((h,c)=>{const S=c.zPosition-h.zPosition;return S!==0?S:t.children.indexOf(c)-t.children.indexOf(h)}).forEach(h=>this.processDomPointerUp(h,i,r))}}processDomPointerMove(t,i,r){if(!i.handled){if(t.isUserInteractionEnabled&&t.draggable&&t.pressed){let h=!1,c,S;t.dragging===!1?(t.dragging=!0,h=!0,c=r.offsetX-t.pressedInitialPointerOffset.x,S=r.offsetY-t.pressedInitialPointerOffset.y):(c=r.offsetX-t.draggingLastPointerOffset.x,S=r.offsetY-t.draggingLastPointerOffset.y),t.position.x+=c,t.position.y+=S,t.draggingLastPointerOffset={x:r.offsetX,y:r.offsetY},h?this.raiseM2DragStartEvent(t,i,r):this.raiseM2DragEvent(t,i,r);return}t.isUserInteractionEnabled&&t.pressed&&t.pressedAndWithinHitArea&&!this.IsCanvasPointWithinNodeBounds(t,r.offsetX,r.offsetY)&&(t.pressedAndWithinHitArea=!1,this.raiseTapLeaveEvent(t,i,r)),t.isUserInteractionEnabled&&this.IsCanvasPointWithinNodeBounds(t,r.offsetX,r.offsetY)&&(this.raiseM2PointerMoveEvent(t,i,r),t.withinHitArea=!0),t.isUserInteractionEnabled&&t.withinHitArea&&!this.IsCanvasPointWithinNodeBounds(t,r.offsetX,r.offsetY)&&(t.withinHitArea=!1,this.raiseM2PointerLeaveEvent(t,i,r)),t.children&&t.children.filter(h=>!h.hidden).filter(h=>h.isDrawable).sort((h,c)=>{const S=c.zPosition-h.zPosition;return S!==0?S:t.children.indexOf(c)-t.children.indexOf(h)}).forEach(h=>this.processDomPointerMove(h,i,r))}}processDomPointerLeave(t,i,r){if(!i.handled){if(t.dragging){const h={target:t,type:H.DragEnd,handled:!1,...q.createTimestamps()};t.dragging=!1,t.pressed=!1,t.pressedAndWithinHitArea=!1,this.raiseM2DragEndEvent(t,h,r);return}t.isUserInteractionEnabled&&t.pressed&&t.pressedAndWithinHitArea&&!this.IsCanvasPointWithinNodeBounds(t,r.offsetX,r.offsetY)&&(t.pressedAndWithinHitArea=!1,this.raiseTapLeaveEvent(t,i,r)),t.isUserInteractionEnabled&&t.withinHitArea&&!this.IsCanvasPointWithinNodeBounds(t,r.offsetX,r.offsetY)&&(t.withinHitArea=!1,this.raiseM2PointerLeaveEvent(t,i,r)),t.children&&t.children.filter(h=>!h.hidden).filter(h=>h.isDrawable).sort((h,c)=>{const S=c.zPosition-h.zPosition;return S!==0?S:t.children.indexOf(c)-t.children.indexOf(h)}).forEach(h=>this.processDomPointerLeave(h,i,r))}}raiseM2PointerDownEvent(t,i,r){i.target=t,i.type=H.PointerDown,this.raiseEventOnListeningNodes(t,i,r)}raiseTapDownEvent(t,i,r){i.target=t,i.type=H.TapDown,this.raiseEventOnListeningNodes(t,i,r)}raiseTapLeaveEvent(t,i,r){i.target=t,i.type=H.TapLeave,this.raiseEventOnListeningNodes(t,i,r)}raiseM2PointerUpEvent(t,i,r){i.target=t,i.type=H.PointerUp,this.raiseEventOnListeningNodes(t,i,r)}raiseTapUpEvent(t,i,r){i.target=t,i.type=H.TapUp,this.raiseEventOnListeningNodes(t,i,r)}raiseTapUpAny(t,i,r){i.target=t,i.type=H.TapUpAny,this.raiseEventOnListeningNodes(t,i,r)}raiseM2PointerMoveEvent(t,i,r){i.target=t,i.type=H.PointerMove,this.raiseEventOnListeningNodes(t,i,r)}raiseM2PointerLeaveEvent(t,i,r){i.target=t,i.type=H.PointerLeave,this.raiseEventOnListeningNodes(t,i,r)}raiseM2DragStartEvent(t,i,r){i.target=t,i.type=H.DragStart,this.raiseEventOnListeningNodes(t,i,r)}raiseM2DragEvent(t,i,r){i.target=t,i.type=H.Drag,this.raiseEventOnListeningNodes(t,i,r)}raiseM2DragEndEvent(t,i,r){i.target=t,i.type=H.DragEnd,this.raiseEventOnListeningNodes(t,i,r)}raiseSceneEvent(t,i){const r={target:t,type:i,...q.createFrameUpdateTimestamps()};t.eventListeners.filter(h=>h.type===i).forEach(h=>h.callback(r))}calculatePointWithinNodeFromDomPointerEvent(t,i){let r=t.size.width,h=t.size.height;if(t.type===dt.Shape&&t.shapeType===Kt.Circle){const K=t.circleOfRadius;if(!K)throw"circleOfRadius is undefined";r=K*2,h=K*2}let c=i.offsetX,S=i.offsetY;const E=q.calculateNodeAbsoluteBoundingBox(t);q.nodeOrAncestorHasBeenRotated(t)&&q.calculateRotationTransforms(t).forEach(it=>{const lt=q.rotatePoint({x:c,y:S},-it.radians,it.center);c=lt.x,S=lt.y});const O=(c-E.xMin)/(E.xMax-E.xMin)*r,G=(S-E.yMin)/(E.yMax-E.yMin)*h;return{x:O,y:G}}onStart(t,i){this.addEventListener(H.ActivityStart,t,i)}onCancel(t,i){this.addEventListener(H.ActivityCancel,t,i)}onEnd(t,i){this.addEventListener(H.ActivityEnd,t,i)}onData(t,i){this.addEventListener(H.ActivityData,t,i)}onWarmupStart(t,i){this.addEventListener(H.GameWarmupStart,t,i)}onWarmupEnd(t,i){this.addEventListener(H.GameWarmupEnd,t,i)}addEventListener(t,i,r){const h={type:t,activityUuid:this.uuid,callback:i};r?.replaceExisting&&(this.eventListeners=this.eventListeners.filter(c=>!(c.activityUuid===h.activityUuid&&c.type===h.type))),this.eventListeners.push(h)}raiseActivityEventOnListeners(t,i){i&&(t={...t,...i}),this.eventListeners.filter(r=>r.type===t.type).forEach(r=>{r.callback(t)})}raiseEventOnListeningNodes(t,i,r){t.eventListeners.filter(h=>h.type===i.type).forEach(h=>{if(h.nodeUuid===t.uuid){switch(i.target=t,i.type){case H.PointerDown:case H.PointerMove:case H.PointerUp:case H.PointerLeave:i.point=this.calculatePointWithinNodeFromDomPointerEvent(t,r),i.buttons=r.buttons,h.callback(i);break;case H.KeyDown:case H.KeyUp:i.key=r.key,i.code=r.code,i.shiftKey=r.shiftKey,i.ctrlKey=r.ctrlKey,i.metaKey=r.metaKey,i.altKey=r.altKey,i.repeat=r.repeat,h.callback(i);break;case H.TapDown:case H.TapUp:case H.TapUpAny:case H.TapLeave:i.point=this.calculatePointWithinNodeFromDomPointerEvent(t,r),i.buttons=r.buttons,h.callback(i);break;case H.DragStart:case H.Drag:case H.DragEnd:i.position={x:t.position.x,y:t.position.y},i.buttons=r.buttons,h.callback(i);break}t.suppressEvents||this.eventStore.addEvent(i)}})}sceneCanReceiveUserInteraction(t){return!!(t._active&&t._transitioning===!1)}IsCanvasPointWithinNodeBounds(t,i,r){if(!t.isDrawable)throw"only drawable nodes can receive pointer events";if(t.type===dt.Shape&&t.shapeType===Kt.Circle){const c=q.calculateNodeAbsoluteBoundingBox(t),S=t.circleOfRadius;if(!S)throw"circleOfRadius is undefined";const E={x:c.xMin+S*t.absoluteScale,y:c.yMin+S*t.absoluteScale};return Math.sqrt(Math.pow(i-E.x,2)+Math.pow(r-E.y,2))<=S*t.absoluteScale}if(t.size.width===0||t.size.height===0||t.type===dt.TextLine&&isNaN(t.size.width))return!1;const h=q.calculateRotatedPoints(t);return t.isUserInteractionEnabled&&q.isPointInsideRectangle({x:i,y:r},h)}}function Fa(){globalThis.m2c2Globals={now:performance.now(),iso8601Now:"",deltaTime:NaN,canvasScale:NaN,rootScale:1,canvasCssWidth:NaN,canvasCssHeight:NaN,m2NodeClassRegistry:{},__sequence:0,get eventSequence(){return m2c2Globals.__sequence++,m2c2Globals.__sequence-1},addedScriptUrls:[]}}Fa();const rs=class as{constructor(t){this.startTime=NaN,this.stopTime=NaN,this.stopped=!0,this.cumulativeElapsed=NaN,this.name=t}static now(){return window.performance.now()}static start(t){let i=this._timers.filter(r=>r.name===t).find(Boolean);if(i===void 0)i=new as(t),i.cumulativeElapsed=0,this._timers.push(i);else if(i.stopped==!1)throw new C(`can't start timer. timer with name ${t} is already started`);i.startTime=window.performance.now(),i.stopped=!1}static stop(t){const i=this._timers.filter(r=>r.name===t).find(Boolean);if(i===void 0)throw new C(`can't stop timer. timer with name ${t} does not exist`);if(i.stopped===!0)throw new C(`can't stop timer. timer with name ${t} is already stopped`);i.stopTime=window.performance.now(),i.cumulativeElapsed=i.cumulativeElapsed+i.stopTime-i.startTime,i.stopped=!0}static restart(t){const i=this._timers.filter(r=>r.name===t).find(Boolean);if(i===void 0)throw new C(`can't restart timer. timer with name ${t} does not exist`);i.startTime=window.performance.now(),i.cumulativeElapsed=0,i.stopped=!1}static elapsed(t){const i=this._timers.filter(r=>r.name===t).find(Boolean);if(i===void 0)throw new C(`can't get elapsed time. timer with name ${t} does not exist`);return i.stopped?i.cumulativeElapsed:i.cumulativeElapsed+window.performance.now()-i.startTime}static remove(t){if(this._timers.filter(r=>r.name===t).find(Boolean)===void 0)throw new C(`can't remove timer. timer with name ${t} does not exist`);this._timers=this._timers.filter(r=>r.name!=t)}static removeAll(){this._timers=new Array}static exists(t){return this._timers.some(i=>i.name===t)}};rs._timers=new Array;let Ma=rs;class An{static SingleFromRange(t,i){return Math.floor(Math.random()*(i-t+1))+t}static FromRangeWithoutReplacement(t,i,r){if(t>r-i+1)throw new C(`number of requested draws (n = ${t}) is greater than number of integers in range [ ${i}, ${r}]`);const h=new Array;for(let c=0;c<t;c++){const S=An.SingleFromRange(i,r);h.includes(S)?t++:h.push(S)}return h}static FromGridWithoutReplacement(t,i,r,h){const c=new Array,S=i*r-1,E=this.FromRangeWithoutReplacement(t,0,S);let O=0,G=NaN;for(;O<t;){const K=E[O]%r,it=(E[O]-K)/r;if(h===void 0||h(it,K))c.push({row:it,column:K}),O++;else{do G=this.FromRangeWithoutReplacement(1,0,S)[0];while(E.includes(G));E[O]=G}}return c}}class Ra extends fe{constructor(t){super(t),this.type=dt.SoundPlayer,this.isDrawable=!1,this.soundName=t.soundName}initialize(){}removeAction(t){const i=this.actions.find(r=>r.key===t);i?.type===mt.Play&&this.stopSoundActionAudio(i),this.actions=this.actions.filter(r=>r.key!==t)}removeAllActions(){for(;this.actions.length;){const t=this.actions.pop();t?.type===mt.Play&&this.stopSoundActionAudio(t)}}stopSoundActionAudio(t){if(t.running){const i=this.game.soundManager.getSound(this.soundName);i.audioBufferSource?.stop(),i.audioBufferSource?.disconnect()}}dispose(){}duplicate(t){throw new C("Method not implemented.")}}class ka extends fe{constructor(t){if(super(t),this.type=dt.SoundRecorder,this.isDrawable=!1,this._isRecording=!1,this._isPaused=!1,this.audioChunks=[],this.timerUuid="",t?.mimeType){const i=this.getMediaRecorderSupportedAudioMimeTypes();if(i.includes(t.mimeType))this.mimeType=t.mimeType;else if(console.warn(`Unsupported MIME type in SoundRecorderOptions: ${t.mimeType}. Supported types are: ${i}.`),t.backupMimeTypes){const r=this.getSupportedBackupMimeType(t.backupMimeTypes);r&&(this.mimeType=r,console.log(`Using backup MIME type: ${r}.`))}}t?.audioTrackConstraints&&(this.audioTrackConstraints=t.audioTrackConstraints),t?.maximumDuration&&(this.maximumDuration=t.maximumDuration)}initialize(){}async start(){if(this.isRecording)throw new C("cannot start SoundRecorder because it is already started.");this.audioChunks=[],this.endIso8601Timestamp=void 0;const t=this.getMediaRecorderSupportedAudioMimeTypes();if(t.length===0)throw new C("SoundRecorder found no supported MIME types for MediaRecorder.");this.mimeType||(this.mimeType=t[0],console.log(`Using MIME type: ${this.mimeType}.`));let i;try{i=await navigator.mediaDevices.getUserMedia({audio:this.audioTrackConstraints?this.audioTrackConstraints:!0})}catch(h){throw new C(`Error getting user media: ${h}.`)}if(!i)throw new C("no stream.");const r=i.getAudioTracks();this.mediaTrackSettings=r?.map(h=>h.getSettings()),this.mediaRecorder=new MediaRecorder(i,{mimeType:this.mimeType}),this.mediaRecorder.ondataavailable=h=>{this.audioChunks.push(h.data)},this.mediaRecorder.onerror=h=>{throw new C(`MediaRecorder error: ${h?.error?.message} ${h?.message}`)},this.mediaRecorder.start(),this.beginIso8601Timestamp=new Date().toISOString(),this.timerUuid=ze.generate(),Vt.startNew(this.timerUuid),this._isRecording=!0,this._isPaused=!1}async stop(){if(!this.isRecording)throw new C("cannot stop SoundRecorder because it has not started.");return new Promise(t=>{if(!this.mediaRecorder)throw new C("no media recorder");this.mediaRecorder.onstop=async()=>{if(!this.mimeType)throw new C("no mimeType");this._isRecording=!1,this._isPaused=!1;const i=new Blob(this.audioChunks,{type:this.getMimeTypeWithoutCodecs(this.mimeType)}),r=await this.blobToBase64(i);t({mimeType:this.mimeType,beginIso8601Timestamp:this.beginIso8601Timestamp??"",endIso8601Timestamp:this.endIso8601Timestamp??"",duration:Vt.elapsed(this.timerUuid),audioTrackSettings:this.mediaTrackSettings,audioBase64:r,audioBlob:i})},this.mediaRecorder.stop(),this.endIso8601Timestamp=new Date().toISOString(),this.isPaused||Vt.stop(this.timerUuid)})}pause(){if(!this.isRecording)throw new C("cannot pause SoundRecorder because it is not started.");if(this.isPaused)throw new C("cannot pause SoundRecorder because it is already paused.");this.mediaRecorder?.pause(),this._isPaused=!0,Vt.stop(this.timerUuid)}resume(){if(!this.isRecording)throw new C("cannot resume SoundRecorder because it is not started.");if(!this.isPaused)throw new C("cannot resume SoundRecorder because it is not paused.");this.mediaRecorder?.resume(),this._isPaused=!1,Vt.start(this.timerUuid)}async queryPermission(){try{return(await navigator.permissions.query({name:"microphone"})).state}catch(t){console.warn(`Error calling navigator.permissions.query({ name: "microphone" }): ${t}.`);return}}async requestPermission(){try{return(await navigator.mediaDevices.getUserMedia({audio:this.audioTrackConstraints?this.audioTrackConstraints:!0})).getTracks().forEach(i=>i.stop()),!0}catch(t){return console.warn(`Microphone access denied: ${t}`),!1}}get isRecording(){return this._isRecording}get isPaused(){return this._isPaused}update(){if(super.update(),this.isRecording&&!this.isPaused&&this.maximumDuration!==void 0&&Vt.elapsed(this.timerUuid)>this.maximumDuration){this.pause();return}}getMediaRecorderSupportedAudioMimeTypes(){const t=["audio"],i=["webm","ogg","mp3","mp4","x-matroska","3gpp","3gpp2","3gp2","quicktime","mpeg","aac","flac","x-flac","wave","wav","x-wav","x-pn-wav","not-supported"],r=["vp9","vp9.0","vp8","vp8.0","avc1","av1","h265","h.265","h264","h.264","opus","vorbis","pcm","aac","mpeg","mp4a","rtx","red","ulpfec","g722","pcmu","pcma","cn","telephone-event","not-supported"];return[...new Set(i.flatMap(h=>t.flatMap(c=>[`${c}/${h}`]))),...new Set(i.flatMap(h=>r.flatMap(c=>t.flatMap(S=>[`${S}/${h};codecs=${c}`])))),...new Set(i.flatMap(h=>r.flatMap(c=>r.flatMap(S=>t.flatMap(E=>[`${E}/${h};codecs="${c}, ${S}"`])))))].filter(h=>MediaRecorder.isTypeSupported(h))}blobToBase64(t){return new Promise((i,r)=>{const h=new FileReader;h.onloadend=()=>{const c=h.result?.toString().split(",").pop();if(c===void 0)throw new C("base64WithoutPrefix is undefined.");i(c)},h.onerror=r,h.readAsDataURL(t)})}getMimeTypeWithoutCodecs(t){const i=t.match(/^[^;]+/);return i?i[0]:""}getSupportedBackupMimeType(t){const i=this.getMediaRecorderSupportedAudioMimeTypes();for(const r of t)if(i.includes(r))return r}dispose(){}duplicate(t){throw new C(`Method not implemented. ${t}`)}}class Na{static create(t){return new Array}}console.log("\u26AA @m2c2kit/core version 0.3.31 (62ccf312)");export{X as Action,ui as ActivityType,Nt as CanvasKitHelpers,ca as ColorfulMutablePath,fa as Composite,Q as Constants,Gt as ConstraintType,kr as CustomAction,Ur as Dimensions,De as Easings,V as Equal,pa as Equals,$r as EventStore,ve as EventStoreMode,zr as FadeAlphaAction,Wr as FontManager,xa as Game,Mr as GroupAction,zi as I18n,fn as ImageManager,Ui as Label,He as LabelHorizontalAlignmentMode,Br as LayoutConstraint,Ma as LegacyTimer,C as M2Error,H as M2EventType,ne as M2ImageStatus,fe as M2Node,Gr as M2NodeFactory,dt as M2NodeType,jt as M2SoundStatus,q as M2c2KitHelpers,Or as MoveAction,Bi as MutablePath,ts as NoneTransition,Nr as PlayAction,An as RandomDraws,un as RepeatAction,Rr as RepeatForeverAction,Lr as RotateAction,Dr as ScaleAction,Ve as Scene,is as SceneTransition,Fr as SequenceAction,fi as Shape,Kt as ShapeType,es as SlideTransition,ns as SoundManager,Ra as SoundPlayer,ka as SoundRecorder,pi as Sprite,Na as Story,$i as TextLine,Vt as Timer,Ke as Transition,be as TransitionDirection,Se as TransitionType,ze as Uuid,Ir as WaitAction,R as WebColors,Pn as WebGlInfo,Le as handleInterfaceOptions};