UNPKG

canvaskit-wasm

Version:

A WASM version of Skia's Canvas API

109 lines (106 loc) 128 kB
var CanvasKitInit = (() => { var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined; if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename; return ( function(CanvasKitInit) { CanvasKitInit = CanvasKitInit || {}; null;var v;v||(v=typeof CanvasKitInit !== 'undefined' ? CanvasKitInit : {});var da,ha;v.ready=new Promise(function(a,b){da=a;ha=b}); (function(a){a.Sd=a.Sd||[];a.Sd.push(function(){a.MakeSWCanvasSurface=function(b){var d=b;if("CANVAS"!==d.tagName&&(d=document.getElementById(b),!d))throw"Canvas with id "+b+" was not found";if(b=a.MakeSurface(d.width,d.height))b.Od=d;return b};a.MakeCanvasSurface||(a.MakeCanvasSurface=a.MakeSWCanvasSurface);a.MakeSurface=function(b,d){var f={width:b,height:d,colorType:a.ColorType.RGBA_8888,alphaType:a.AlphaType.Unpremul,colorSpace:a.ColorSpace.SRGB},h=b*d*4,m=a._malloc(h);if(f=a.Surface._makeRasterDirect(f, m,4*b))f.Od=null,f.Ff=b,f.Bf=d,f.Df=h,f.af=m,f.getCanvas().clear(a.TRANSPARENT);return f};a.MakeRasterDirectSurface=function(b,d,f){return a.Surface._makeRasterDirect(b,d.byteOffset,f)};a.Surface.prototype.flush=function(b){a.Pd(this.Nd);this._flush();if(this.Od){var d=new Uint8ClampedArray(a.HEAPU8.buffer,this.af,this.Df);d=new ImageData(d,this.Ff,this.Bf);b?this.Od.getContext("2d").putImageData(d,0,0,b[0],b[1],b[2]-b[0],b[3]-b[1]):this.Od.getContext("2d").putImageData(d,0,0)}};a.Surface.prototype.dispose= function(){this.af&&a._free(this.af);this.delete()};a.Pd=a.Pd||function(){}})})(v); (function(a){a.Sd=a.Sd||[];a.Sd.push(function(){function b(n,q,x){return n&&n.hasOwnProperty(q)?n[q]:x}function d(n){var q=ia(ka);ka[q]=n;return q}function f(n){return n.naturalHeight||n.videoHeight||n.displayHeight||n.height}function h(n){return n.naturalWidth||n.videoWidth||n.displayWidth||n.width}function m(n,q,x,D){n.bindTexture(n.TEXTURE_2D,q);D||x.alphaType!==a.AlphaType.Premul||n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0);return q}function t(n,q,x){x||q.alphaType!==a.AlphaType.Premul|| n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1);n.bindTexture(n.TEXTURE_2D,null)}a.GetWebGLContext=function(n,q){if(!n)throw"null canvas passed into makeWebGLContext";var x={alpha:b(q,"alpha",1),depth:b(q,"depth",1),stencil:b(q,"stencil",8),antialias:b(q,"antialias",0),premultipliedAlpha:b(q,"premultipliedAlpha",1),preserveDrawingBuffer:b(q,"preserveDrawingBuffer",0),preferLowPowerToHighPerformance:b(q,"preferLowPowerToHighPerformance",0),failIfMajorPerformanceCaveat:b(q,"failIfMajorPerformanceCaveat", 0),enableExtensionsByDefault:b(q,"enableExtensionsByDefault",1),explicitSwapControl:b(q,"explicitSwapControl",0),renderViaOffscreenBackBuffer:b(q,"renderViaOffscreenBackBuffer",0)};x.majorVersion=q&&q.majorVersion?q.majorVersion:"undefined"!==typeof WebGL2RenderingContext?2:1;if(x.explicitSwapControl)throw"explicitSwapControl is not supported";n=la(n,x);if(!n)return 0;ma(n);return n};a.deleteContext=function(n){w===na[n]&&(w=null);"object"==typeof JSEvents&&JSEvents.Ag(na[n].ke.canvas);na[n]&&na[n].ke.canvas&& (na[n].ke.canvas.yf=void 0);na[n]=null};a._setTextureCleanup({deleteTexture:function(n,q){var x=ka[q];x&&na[n].ke.deleteTexture(x);ka[q]=null}});a.zf=function(n){if(!this.Pd(n))return null;var q=this._MakeGrContext();if(!q)return null;q.Nd=n;return q};a.MakeGrContext=a.zf;a.MakeOnScreenGLSurface=function(n,q,x,D){if(!this.Pd(n.Nd))return null;q=this._MakeOnScreenGLSurface(n,q,x,D);if(!q)return null;q.Nd=n.Nd;return q};a.MakeRenderTarget=function(){var n=arguments[0];if(!this.Pd(n.Nd))return null; if(3===arguments.length){var q=this._MakeRenderTargetWH(n,arguments[1],arguments[2]);if(!q)return null}else if(2===arguments.length){if(q=this._MakeRenderTargetII(n,arguments[1]),!q)return null}else return null;q.Nd=n.Nd;return q};a.MakeWebGLCanvasSurface=function(n,q,x){q=q||null;var D=n,H="undefined"!==typeof OffscreenCanvas&&D instanceof OffscreenCanvas;if(!("undefined"!==typeof HTMLCanvasElement&&D instanceof HTMLCanvasElement||H||(D=document.getElementById(n),D)))throw"Canvas with id "+n+" was not found"; n=this.GetWebGLContext(D,x);if(!n||0>n)throw"failed to create webgl context: err "+n;n=this.MakeGrContext(n);q=this.MakeOnScreenGLSurface(n,D.width,D.height,q);return q?q:(q=D.cloneNode(!0),D.parentNode.replaceChild(q,D),q.classList.add("ck-replaced"),a.MakeSWCanvasSurface(q))};a.MakeCanvasSurface=a.MakeWebGLCanvasSurface;a.Surface.prototype.makeImageFromTexture=function(n,q){a.Pd(this.Nd);n=d(n);if(q=this._makeImageFromTexture(this.Nd,n,q))q.Me=n;return q};a.Surface.prototype.makeImageFromTextureSource= function(n,q,x){q||(q={height:f(n),width:h(n),colorType:a.ColorType.RGBA_8888,alphaType:x?a.AlphaType.Premul:a.AlphaType.Unpremul});q.colorSpace||(q.colorSpace=a.ColorSpace.SRGB);a.Pd(this.Nd);var D=w.ke;x=m(D,D.createTexture(),q,x);2===w.version?D.texImage2D(D.TEXTURE_2D,0,D.RGBA,q.width,q.height,0,D.RGBA,D.UNSIGNED_BYTE,n):D.texImage2D(D.TEXTURE_2D,0,D.RGBA,D.RGBA,D.UNSIGNED_BYTE,n);t(D,q);return this.makeImageFromTexture(x,q)};a.Surface.prototype.updateTextureFromSource=function(n,q,x){if(n.Me){a.Pd(this.Nd); var D=n.getImageInfo(),H=w.ke,N=m(H,ka[n.Me],D,x);2===w.version?H.texImage2D(H.TEXTURE_2D,0,H.RGBA,h(q),f(q),0,H.RGBA,H.UNSIGNED_BYTE,q):H.texImage2D(H.TEXTURE_2D,0,H.RGBA,H.RGBA,H.UNSIGNED_BYTE,q);t(H,D,x);this._resetContext();ka[n.Me]=null;n.Me=d(N);D.colorSpace=n.getColorSpace();q=this._makeImageFromTexture(this.Nd,n.Me,D);x=n.Md.Vd;H=n.Md.ae;n.Md.Vd=q.Md.Vd;n.Md.ae=q.Md.ae;q.Md.Vd=x;q.Md.ae=H;q.delete();D.colorSpace.delete()}};a.MakeLazyImageFromTextureSource=function(n,q,x){q||(q={height:f(n), width:h(n),colorType:a.ColorType.RGBA_8888,alphaType:x?a.AlphaType.Premul:a.AlphaType.Unpremul});q.colorSpace||(q.colorSpace=a.ColorSpace.SRGB);var D={makeTexture:function(){var H=w,N=H.ke,z=m(N,N.createTexture(),q,x);2===H.version?N.texImage2D(N.TEXTURE_2D,0,N.RGBA,q.width,q.height,0,N.RGBA,N.UNSIGNED_BYTE,n):N.texImage2D(N.TEXTURE_2D,0,N.RGBA,N.RGBA,N.UNSIGNED_BYTE,n);t(N,q,x);return d(z)},freeSrc:function(){}};"VideoFrame"===n.constructor.name&&(D.freeSrc=function(){n.close()});return a.Image._makeFromGenerator(q, D)};a.Pd=function(n){return n?ma(n):!1}})})(v); (function(a){function b(e,c,g,l,r){for(var y=0;y<e.length;y++)c[y*g+(y*r+l+g)%g]=e[y];return c}function d(e){for(var c=e*e,g=Array(c);c--;)g[c]=0===c%(e+1)?1:0;return g}function f(e){return e?e.constructor===Float32Array&&4===e.length:!1}function h(e){return(n(255*e[3])<<24|n(255*e[0])<<16|n(255*e[1])<<8|n(255*e[2])<<0)>>>0}function m(e){if(e&&e._ck)return e;if(e instanceof Float32Array){for(var c=Math.floor(e.length/4),g=new Uint32Array(c),l=0;l<c;l++)g[l]=h(e.slice(4*l,4*(l+1)));return g}if(e instanceof Uint32Array)return e;if(e instanceof Array&&e[0]instanceof Float32Array)return e.map(h)}function t(e){if(void 0===e)return 1;var c=parseFloat(e);return e&&-1!==e.indexOf("%")?c/100:c}function n(e){return Math.round(Math.max(0,Math.min(e||0,255)))}function q(e,c){c&&c._ck||a._free(e)}function x(e,c,g){if(!e||!e.length)return U;if(e&&e._ck)return e.byteOffset;var l=a[c].BYTES_PER_ELEMENT;g||(g=a._malloc(e.length*l));a[c].set(e,g/l);return g}function D(e){var c={de:U,count:e.length,colorType:a.ColorType.RGBA_F32}; if(e instanceof Float32Array)c.de=x(e,"HEAPF32"),c.count=e.length/4;else if(e instanceof Uint32Array)c.de=x(e,"HEAPU32"),c.colorType=a.ColorType.RGBA_8888;else if(e instanceof Array){if(e&&e.length){for(var g=a._malloc(16*e.length),l=0,r=g/4,y=0;y<e.length;y++)for(var C=0;4>C;C++)a.HEAPF32[r+l]=e[y][C],l++;e=g}else e=U;c.de=e}else throw"Invalid argument to copyFlexibleColorArray, Not a color array "+typeof e;return c}function H(e){if(!e)return U;var c=Vb.toTypedArray();if(e.length){if(6===e.length|| 9===e.length)return x(e,"HEAPF32",Oa),6===e.length&&a.HEAPF32.set(zd,6+Oa/4),Oa;if(16===e.length)return c[0]=e[0],c[1]=e[1],c[2]=e[3],c[3]=e[4],c[4]=e[5],c[5]=e[7],c[6]=e[12],c[7]=e[13],c[8]=e[15],Oa;throw"invalid matrix size";}if(void 0===e.m11)throw"invalid matrix argument";c[0]=e.m11;c[1]=e.m21;c[2]=e.m41;c[3]=e.m12;c[4]=e.m22;c[5]=e.m42;c[6]=e.m14;c[7]=e.m24;c[8]=e.m44;return Oa}function N(e){if(!e)return U;var c=Wb.toTypedArray();if(e.length){if(16!==e.length&&6!==e.length&&9!==e.length)throw"invalid matrix size"; if(16===e.length)return x(e,"HEAPF32",$a);c.fill(0);c[0]=e[0];c[1]=e[1];c[3]=e[2];c[4]=e[3];c[5]=e[4];c[7]=e[5];c[10]=1;c[12]=e[6];c[13]=e[7];c[15]=e[8];6===e.length&&(c[12]=0,c[13]=0,c[15]=1);return $a}if(void 0===e.m11)throw"invalid matrix argument";c[0]=e.m11;c[1]=e.m21;c[2]=e.m31;c[3]=e.m41;c[4]=e.m12;c[5]=e.m22;c[6]=e.m32;c[7]=e.m42;c[8]=e.m13;c[9]=e.m23;c[10]=e.m33;c[11]=e.m43;c[12]=e.m14;c[13]=e.m24;c[14]=e.m34;c[15]=e.m44;return $a}function z(e,c){return x(e,"HEAPF32",c||fb)}function O(e, c,g,l){var r=Xb.toTypedArray();r[0]=e;r[1]=c;r[2]=g;r[3]=l;return fb}function S(e){for(var c=new Float32Array(4),g=0;4>g;g++)c[g]=a.HEAPF32[e/4+g];return c}function T(e,c){return x(e,"HEAPF32",c||ea)}function pa(e,c){return x(e,"HEAPF32",c||Yb)}function wa(){for(var e=0,c=0;c<arguments.length-1;c+=2)e+=arguments[c]*arguments[c+1];return e}function gb(e,c,g){for(var l=Array(e.length),r=0;r<g;r++)for(var y=0;y<g;y++){for(var C=0,J=0;J<g;J++)C+=e[g*r+J]*c[g*J+y];l[r*g+y]=C}return l}function hb(e,c){for(var g= gb(c[0],c[1],e),l=2;l<c.length;)g=gb(g,c[l],e),l++;return g}a.Color=function(e,c,g,l){void 0===l&&(l=1);return a.Color4f(n(e)/255,n(c)/255,n(g)/255,l)};a.ColorAsInt=function(e,c,g,l){void 0===l&&(l=255);return(n(l)<<24|n(e)<<16|n(c)<<8|n(g)<<0&268435455)>>>0};a.Color4f=function(e,c,g,l){void 0===l&&(l=1);return Float32Array.of(e,c,g,l)};Object.defineProperty(a,"TRANSPARENT",{get:function(){return a.Color4f(0,0,0,0)}});Object.defineProperty(a,"BLACK",{get:function(){return a.Color4f(0,0,0,1)}});Object.defineProperty(a, "WHITE",{get:function(){return a.Color4f(1,1,1,1)}});Object.defineProperty(a,"RED",{get:function(){return a.Color4f(1,0,0,1)}});Object.defineProperty(a,"GREEN",{get:function(){return a.Color4f(0,1,0,1)}});Object.defineProperty(a,"BLUE",{get:function(){return a.Color4f(0,0,1,1)}});Object.defineProperty(a,"YELLOW",{get:function(){return a.Color4f(1,1,0,1)}});Object.defineProperty(a,"CYAN",{get:function(){return a.Color4f(0,1,1,1)}});Object.defineProperty(a,"MAGENTA",{get:function(){return a.Color4f(1, 0,1,1)}});a.getColorComponents=function(e){return[Math.floor(255*e[0]),Math.floor(255*e[1]),Math.floor(255*e[2]),e[3]]};a.parseColorString=function(e,c){e=e.toLowerCase();if(e.startsWith("#")){c=255;switch(e.length){case 9:c=parseInt(e.slice(7,9),16);case 7:var g=parseInt(e.slice(1,3),16);var l=parseInt(e.slice(3,5),16);var r=parseInt(e.slice(5,7),16);break;case 5:c=17*parseInt(e.slice(4,5),16);case 4:g=17*parseInt(e.slice(1,2),16),l=17*parseInt(e.slice(2,3),16),r=17*parseInt(e.slice(3,4),16)}return a.Color(g, l,r,c/255)}return e.startsWith("rgba")?(e=e.slice(5,-1),e=e.split(","),a.Color(+e[0],+e[1],+e[2],t(e[3]))):e.startsWith("rgb")?(e=e.slice(4,-1),e=e.split(","),a.Color(+e[0],+e[1],+e[2],t(e[3]))):e.startsWith("gray(")||e.startsWith("hsl")||!c||(e=c[e],void 0===e)?a.BLACK:e};a.multiplyByAlpha=function(e,c){e=e.slice();e[3]=Math.max(0,Math.min(e[3]*c,1));return e};a.Malloc=function(e,c){var g=a._malloc(c*e.BYTES_PER_ELEMENT);return{_ck:!0,length:c,byteOffset:g,se:null,subarray:function(l,r){l=this.toTypedArray().subarray(l, r);l._ck=!0;return l},toTypedArray:function(){if(this.se&&this.se.length)return this.se;this.se=new e(a.HEAPU8.buffer,g,c);this.se._ck=!0;return this.se}}};a.Free=function(e){a._free(e.byteOffset);e.byteOffset=U;e.toTypedArray=null;e.se=null};var Oa=U,Vb,$a=U,Wb,fb=U,Xb,qa,ea=U,Cc,Ta=U,Dc,Zb=U,Ec,$b=U,ac,xb=U,Fc,Yb=U,Gc,Hc=U,zd=Float32Array.of(0,0,1),U=0;a.onRuntimeInitialized=function(){function e(c,g,l,r,y,C){C||(C=4*r.width,r.colorType===a.ColorType.RGBA_F16?C*=2:r.colorType===a.ColorType.RGBA_F32&& (C*=4));var J=C*r.height;var L=y?y.byteOffset:a._malloc(J);if(!c._readPixels(r,L,C,g,l))return y||a._free(L),null;if(y)return y.toTypedArray();switch(r.colorType){case a.ColorType.RGBA_8888:case a.ColorType.RGBA_F16:c=(new Uint8Array(a.HEAPU8.buffer,L,J)).slice();break;case a.ColorType.RGBA_F32:c=(new Float32Array(a.HEAPU8.buffer,L,J)).slice();break;default:return null}a._free(L);return c}Xb=a.Malloc(Float32Array,4);fb=Xb.byteOffset;Wb=a.Malloc(Float32Array,16);$a=Wb.byteOffset;Vb=a.Malloc(Float32Array, 9);Oa=Vb.byteOffset;Fc=a.Malloc(Float32Array,12);Yb=Fc.byteOffset;Gc=a.Malloc(Float32Array,12);Hc=Gc.byteOffset;qa=a.Malloc(Float32Array,4);ea=qa.byteOffset;Cc=a.Malloc(Float32Array,4);Ta=Cc.byteOffset;Dc=a.Malloc(Float32Array,3);Zb=Dc.byteOffset;Ec=a.Malloc(Float32Array,3);$b=Ec.byteOffset;ac=a.Malloc(Int32Array,4);xb=ac.byteOffset;a.ColorSpace.SRGB=a.ColorSpace._MakeSRGB();a.ColorSpace.DISPLAY_P3=a.ColorSpace._MakeDisplayP3();a.ColorSpace.ADOBE_RGB=a.ColorSpace._MakeAdobeRGB();a.GlyphRunFlags={IsWhiteSpace:a._GlyphRunFlags_isWhiteSpace}; a.Path.MakeFromCmds=function(c){var g=x(c,"HEAPF32"),l=a.Path._MakeFromCmds(g,c.length);q(g,c);return l};a.Path.MakeFromVerbsPointsWeights=function(c,g,l){var r=x(c,"HEAPU8"),y=x(g,"HEAPF32"),C=x(l,"HEAPF32"),J=a.Path._MakeFromVerbsPointsWeights(r,c.length,y,g.length,C,l&&l.length||0);q(r,c);q(y,g);q(C,l);return J};a.Path.prototype.addArc=function(c,g,l){c=T(c);this._addArc(c,g,l);return this};a.Path.prototype.addOval=function(c,g,l){void 0===l&&(l=1);c=T(c);this._addOval(c,!!g,l);return this};a.Path.prototype.addPath= function(){var c=Array.prototype.slice.call(arguments),g=c[0],l=!1;"boolean"===typeof c[c.length-1]&&(l=c.pop());if(1===c.length)this._addPath(g,1,0,0,0,1,0,0,0,1,l);else if(2===c.length)c=c[1],this._addPath(g,c[0],c[1],c[2],c[3],c[4],c[5],c[6]||0,c[7]||0,c[8]||1,l);else if(7===c.length||10===c.length)this._addPath(g,c[1],c[2],c[3],c[4],c[5],c[6],c[7]||0,c[8]||0,c[9]||1,l);else return null;return this};a.Path.prototype.addPoly=function(c,g){var l=x(c,"HEAPF32");this._addPoly(l,c.length/2,g);q(l,c); return this};a.Path.prototype.addRect=function(c,g){c=T(c);this._addRect(c,!!g);return this};a.Path.prototype.addRRect=function(c,g){c=pa(c);this._addRRect(c,!!g);return this};a.Path.prototype.addVerbsPointsWeights=function(c,g,l){var r=x(c,"HEAPU8"),y=x(g,"HEAPF32"),C=x(l,"HEAPF32");this._addVerbsPointsWeights(r,c.length,y,g.length,C,l&&l.length||0);q(r,c);q(y,g);q(C,l)};a.Path.prototype.arc=function(c,g,l,r,y,C){c=a.LTRBRect(c-l,g-l,c+l,g+l);y=(y-r)/Math.PI*180-360*!!C;C=new a.Path;C.addArc(c,r/ Math.PI*180,y);this.addPath(C,!0);C.delete();return this};a.Path.prototype.arcToOval=function(c,g,l,r){c=T(c);this._arcToOval(c,g,l,r);return this};a.Path.prototype.arcToRotated=function(c,g,l,r,y,C,J){this._arcToRotated(c,g,l,!!r,!!y,C,J);return this};a.Path.prototype.arcToTangent=function(c,g,l,r,y){this._arcToTangent(c,g,l,r,y);return this};a.Path.prototype.close=function(){this._close();return this};a.Path.prototype.conicTo=function(c,g,l,r,y){this._conicTo(c,g,l,r,y);return this};a.Path.prototype.computeTightBounds= function(c){this._computeTightBounds(ea);var g=qa.toTypedArray();return c?(c.set(g),c):g.slice()};a.Path.prototype.cubicTo=function(c,g,l,r,y,C){this._cubicTo(c,g,l,r,y,C);return this};a.Path.prototype.dash=function(c,g,l){return this._dash(c,g,l)?this:null};a.Path.prototype.getBounds=function(c){this._getBounds(ea);var g=qa.toTypedArray();return c?(c.set(g),c):g.slice()};a.Path.prototype.lineTo=function(c,g){this._lineTo(c,g);return this};a.Path.prototype.moveTo=function(c,g){this._moveTo(c,g);return this}; a.Path.prototype.offset=function(c,g){this._transform(1,0,c,0,1,g,0,0,1);return this};a.Path.prototype.quadTo=function(c,g,l,r){this._quadTo(c,g,l,r);return this};a.Path.prototype.rArcTo=function(c,g,l,r,y,C,J){this._rArcTo(c,g,l,r,y,C,J);return this};a.Path.prototype.rConicTo=function(c,g,l,r,y){this._rConicTo(c,g,l,r,y);return this};a.Path.prototype.rCubicTo=function(c,g,l,r,y,C){this._rCubicTo(c,g,l,r,y,C);return this};a.Path.prototype.rLineTo=function(c,g){this._rLineTo(c,g);return this};a.Path.prototype.rMoveTo= function(c,g){this._rMoveTo(c,g);return this};a.Path.prototype.rQuadTo=function(c,g,l,r){this._rQuadTo(c,g,l,r);return this};a.Path.prototype.stroke=function(c){c=c||{};c.width=c.width||1;c.miter_limit=c.miter_limit||4;c.cap=c.cap||a.StrokeCap.Butt;c.join=c.join||a.StrokeJoin.Miter;c.precision=c.precision||1;return this._stroke(c)?this:null};a.Path.prototype.transform=function(){if(1===arguments.length){var c=arguments[0];this._transform(c[0],c[1],c[2],c[3],c[4],c[5],c[6]||0,c[7]||0,c[8]||1)}else if(6=== arguments.length||9===arguments.length)c=arguments,this._transform(c[0],c[1],c[2],c[3],c[4],c[5],c[6]||0,c[7]||0,c[8]||1);else throw"transform expected to take 1 or 9 arguments. Got "+arguments.length;return this};a.Path.prototype.trim=function(c,g,l){return this._trim(c,g,!!l)?this:null};a.Image.prototype.makeShaderCubic=function(c,g,l,r,y){y=H(y);return this._makeShaderCubic(c,g,l,r,y)};a.Image.prototype.makeShaderOptions=function(c,g,l,r,y){y=H(y);return this._makeShaderOptions(c,g,l,r,y)};a.Image.prototype.readPixels= function(c,g,l,r,y){return e(this,c,g,l,r,y)};a.Canvas.prototype.clear=function(c){a.Pd(this.Nd);c=z(c);this._clear(c)};a.Canvas.prototype.clipRRect=function(c,g,l){a.Pd(this.Nd);c=pa(c);this._clipRRect(c,g,l)};a.Canvas.prototype.clipRect=function(c,g,l){a.Pd(this.Nd);c=T(c);this._clipRect(c,g,l)};a.Canvas.prototype.concat=function(c){a.Pd(this.Nd);c=N(c);this._concat(c)};a.Canvas.prototype.drawArc=function(c,g,l,r,y){a.Pd(this.Nd);c=T(c);this._drawArc(c,g,l,r,y)};a.Canvas.prototype.drawAtlas=function(c, g,l,r,y,C,J){if(c&&r&&g&&l&&g.length===l.length){a.Pd(this.Nd);y||(y=a.BlendMode.SrcOver);var L=x(g,"HEAPF32"),P=x(l,"HEAPF32"),V=l.length/4,u=x(m(C),"HEAPU32");if(J&&"B"in J&&"C"in J)this._drawAtlasCubic(c,P,L,u,V,y,J.B,J.C,r);else{let G=a.FilterMode.Linear,R=a.MipmapMode.None;J&&(G=J.filter,"mipmap"in J&&(R=J.mipmap));this._drawAtlasOptions(c,P,L,u,V,y,G,R,r)}q(L,g);q(P,l);q(u,C)}};a.Canvas.prototype.drawCircle=function(c,g,l,r){a.Pd(this.Nd);this._drawCircle(c,g,l,r)};a.Canvas.prototype.drawColor= function(c,g){a.Pd(this.Nd);c=z(c);void 0!==g?this._drawColor(c,g):this._drawColor(c)};a.Canvas.prototype.drawColorInt=function(c,g){a.Pd(this.Nd);this._drawColorInt(c,g||a.BlendMode.SrcOver)};a.Canvas.prototype.drawColorComponents=function(c,g,l,r,y){a.Pd(this.Nd);c=O(c,g,l,r);void 0!==y?this._drawColor(c,y):this._drawColor(c)};a.Canvas.prototype.drawDRRect=function(c,g,l){a.Pd(this.Nd);c=pa(c,Yb);g=pa(g,Hc);this._drawDRRect(c,g,l)};a.Canvas.prototype.drawImage=function(c,g,l,r){a.Pd(this.Nd);this._drawImage(c, g,l,r||null)};a.Canvas.prototype.drawImageCubic=function(c,g,l,r,y,C){a.Pd(this.Nd);this._drawImageCubic(c,g,l,r,y,C||null)};a.Canvas.prototype.drawImageOptions=function(c,g,l,r,y,C){a.Pd(this.Nd);this._drawImageOptions(c,g,l,r,y,C||null)};a.Canvas.prototype.drawImageNine=function(c,g,l,r,y){a.Pd(this.Nd);g=x(g,"HEAP32",xb);l=T(l);this._drawImageNine(c,g,l,r,y||null)};a.Canvas.prototype.drawImageRect=function(c,g,l,r,y){a.Pd(this.Nd);T(g,ea);T(l,Ta);this._drawImageRect(c,ea,Ta,r,!!y)};a.Canvas.prototype.drawImageRectCubic= function(c,g,l,r,y,C){a.Pd(this.Nd);T(g,ea);T(l,Ta);this._drawImageRectCubic(c,ea,Ta,r,y,C||null)};a.Canvas.prototype.drawImageRectOptions=function(c,g,l,r,y,C){a.Pd(this.Nd);T(g,ea);T(l,Ta);this._drawImageRectOptions(c,ea,Ta,r,y,C||null)};a.Canvas.prototype.drawLine=function(c,g,l,r,y){a.Pd(this.Nd);this._drawLine(c,g,l,r,y)};a.Canvas.prototype.drawOval=function(c,g){a.Pd(this.Nd);c=T(c);this._drawOval(c,g)};a.Canvas.prototype.drawPaint=function(c){a.Pd(this.Nd);this._drawPaint(c)};a.Canvas.prototype.drawParagraph= function(c,g,l){a.Pd(this.Nd);this._drawParagraph(c,g,l)};a.Canvas.prototype.drawPatch=function(c,g,l,r,y){if(24>c.length)throw"Need 12 cubic points";if(g&&4>g.length)throw"Need 4 colors";if(l&&8>l.length)throw"Need 4 shader coordinates";a.Pd(this.Nd);const C=x(c,"HEAPF32"),J=g?x(m(g),"HEAPU32"):U,L=l?x(l,"HEAPF32"):U;r||(r=a.BlendMode.Modulate);this._drawPatch(C,J,L,r,y);q(L,l);q(J,g);q(C,c)};a.Canvas.prototype.drawPath=function(c,g){a.Pd(this.Nd);this._drawPath(c,g)};a.Canvas.prototype.drawPicture= function(c){a.Pd(this.Nd);this._drawPicture(c)};a.Canvas.prototype.drawPoints=function(c,g,l){a.Pd(this.Nd);var r=x(g,"HEAPF32");this._drawPoints(c,r,g.length/2,l);q(r,g)};a.Canvas.prototype.drawRRect=function(c,g){a.Pd(this.Nd);c=pa(c);this._drawRRect(c,g)};a.Canvas.prototype.drawRect=function(c,g){a.Pd(this.Nd);c=T(c);this._drawRect(c,g)};a.Canvas.prototype.drawRect4f=function(c,g,l,r,y){a.Pd(this.Nd);this._drawRect4f(c,g,l,r,y)};a.Canvas.prototype.drawShadow=function(c,g,l,r,y,C,J){a.Pd(this.Nd); var L=x(y,"HEAPF32"),P=x(C,"HEAPF32");g=x(g,"HEAPF32",Zb);l=x(l,"HEAPF32",$b);this._drawShadow(c,g,l,r,L,P,J);q(L,y);q(P,C)};a.getShadowLocalBounds=function(c,g,l,r,y,C,J){c=H(c);l=x(l,"HEAPF32",Zb);r=x(r,"HEAPF32",$b);if(!this._getShadowLocalBounds(c,g,l,r,y,C,ea))return null;g=qa.toTypedArray();return J?(J.set(g),J):g.slice()};a.Canvas.prototype.drawTextBlob=function(c,g,l,r){a.Pd(this.Nd);this._drawTextBlob(c,g,l,r)};a.Canvas.prototype.drawVertices=function(c,g,l){a.Pd(this.Nd);this._drawVertices(c, g,l)};a.Canvas.prototype.getDeviceClipBounds=function(c){this._getDeviceClipBounds(xb);var g=ac.toTypedArray();c?c.set(g):c=g.slice();return c};a.Canvas.prototype.getLocalToDevice=function(){this._getLocalToDevice($a);for(var c=$a,g=Array(16),l=0;16>l;l++)g[l]=a.HEAPF32[c/4+l];return g};a.Canvas.prototype.getTotalMatrix=function(){this._getTotalMatrix(Oa);for(var c=Array(9),g=0;9>g;g++)c[g]=a.HEAPF32[Oa/4+g];return c};a.Canvas.prototype.makeSurface=function(c){c=this._makeSurface(c);c.Nd=this.Nd; return c};a.Canvas.prototype.readPixels=function(c,g,l,r,y){a.Pd(this.Nd);return e(this,c,g,l,r,y)};a.Canvas.prototype.saveLayer=function(c,g,l,r){g=T(g);return this._saveLayer(c||null,g,l||null,r||0)};a.Canvas.prototype.writePixels=function(c,g,l,r,y,C,J,L){if(c.byteLength%(g*l))throw"pixels length must be a multiple of the srcWidth * srcHeight";a.Pd(this.Nd);var P=c.byteLength/(g*l);C=C||a.AlphaType.Unpremul;J=J||a.ColorType.RGBA_8888;L=L||a.ColorSpace.SRGB;var V=P*g;P=x(c,"HEAPU8");g=this._writePixels({width:g, height:l,colorType:J,alphaType:C,colorSpace:L},P,V,r,y);q(P,c);return g};a.ColorFilter.MakeBlend=function(c,g){c=z(c);return a.ColorFilter._MakeBlend(c,g)};a.ColorFilter.MakeMatrix=function(c){if(!c||20!==c.length)throw"invalid color matrix";var g=x(c,"HEAPF32"),l=a.ColorFilter._makeMatrix(g);q(g,c);return l};a.ContourMeasure.prototype.getPosTan=function(c,g){this._getPosTan(c,ea);c=qa.toTypedArray();return g?(g.set(c),g):c.slice()};a.ImageFilter.MakeMatrixTransform=function(c,g,l){c=H(c);if("B"in g&&"C"in g)return a.ImageFilter._MakeMatrixTransformCubic(c,g.ug,g.vg,l);const r=g.filter;let y=a.MipmapMode.None;"mipmap"in g&&(y=g.mipmap);return a.ImageFilter._MakeMatrixTransformOptions(c,r,y,l)};a.Paint.prototype.getColor=function(){this._getColor(fb);return S(fb)};a.Paint.prototype.setColor=function(c,g){g=g||null;c=z(c);this._setColor(c,g)};a.Paint.prototype.setColorComponents=function(c,g,l,r,y){y=y||null;c=O(c,g,l,r);this._setColor(c,y)};a.Path.prototype.getPoint=function(c,g){this._getPoint(c, ea);c=qa.toTypedArray();return g?(g[0]=c[0],g[1]=c[1],g):c.slice(0,2)};a.Picture.prototype.makeShader=function(c,g,l,r,y){r=H(r);y=T(y);return this._makeShader(c,g,l,r,y)};a.PictureRecorder.prototype.beginRecording=function(c){c=T(c);return this._beginRecording(c)};a.Surface.prototype.getCanvas=function(){var c=this._getCanvas();c.Nd=this.Nd;return c};a.Surface.prototype.makeImageSnapshot=function(c){a.Pd(this.Nd);c=x(c,"HEAP32",xb);return this._makeImageSnapshot(c)};a.Surface.prototype.makeSurface= function(c){a.Pd(this.Nd);c=this._makeSurface(c);c.Nd=this.Nd;return c};a.Surface.prototype.Ef=function(c,g){this.Ie||(this.Ie=this.getCanvas());requestAnimationFrame(function(){a.Pd(this.Nd);c(this.Ie);this.flush(g)}.bind(this))};a.Surface.prototype.requestAnimationFrame||(a.Surface.prototype.requestAnimationFrame=a.Surface.prototype.Ef);a.Surface.prototype.Af=function(c,g){this.Ie||(this.Ie=this.getCanvas());requestAnimationFrame(function(){a.Pd(this.Nd);c(this.Ie);this.flush(g);this.dispose()}.bind(this))}; a.Surface.prototype.drawOnce||(a.Surface.prototype.drawOnce=a.Surface.prototype.Af);a.PathEffect.MakeDash=function(c,g){g||(g=0);if(!c.length||1===c.length%2)throw"Intervals array must have even length";var l=x(c,"HEAPF32");g=a.PathEffect._MakeDash(l,c.length,g);q(l,c);return g};a.PathEffect.MakeLine2D=function(c,g){g=H(g);return a.PathEffect._MakeLine2D(c,g)};a.PathEffect.MakePath2D=function(c,g){c=H(c);return a.PathEffect._MakePath2D(c,g)};a.Shader.MakeColor=function(c,g){g=g||null;c=z(c);return a.Shader._MakeColor(c, g)};a.Shader.Blend=a.Shader.MakeBlend;a.Shader.Color=a.Shader.MakeColor;a.Shader.MakeLinearGradient=function(c,g,l,r,y,C,J,L){L=L||null;var P=D(l),V=x(r,"HEAPF32");J=J||0;C=H(C);var u=qa.toTypedArray();u.set(c);u.set(g,2);c=a.Shader._MakeLinearGradient(ea,P.de,P.colorType,V,P.count,y,J,C,L);q(P.de,l);r&&q(V,r);return c};a.Shader.MakeRadialGradient=function(c,g,l,r,y,C,J,L){L=L||null;var P=D(l),V=x(r,"HEAPF32");J=J||0;C=H(C);c=a.Shader._MakeRadialGradient(c[0],c[1],g,P.de,P.colorType,V,P.count,y,J, C,L);q(P.de,l);r&&q(V,r);return c};a.Shader.MakeSweepGradient=function(c,g,l,r,y,C,J,L,P,V){V=V||null;var u=D(l),G=x(r,"HEAPF32");J=J||0;L=L||0;P=P||360;C=H(C);c=a.Shader._MakeSweepGradient(c,g,u.de,u.colorType,G,u.count,y,L,P,J,C,V);q(u.de,l);r&&q(G,r);return c};a.Shader.MakeTwoPointConicalGradient=function(c,g,l,r,y,C,J,L,P,V){V=V||null;var u=D(y),G=x(C,"HEAPF32");P=P||0;L=H(L);var R=qa.toTypedArray();R.set(c);R.set(l,2);c=a.Shader._MakeTwoPointConicalGradient(ea,g,r,u.de,u.colorType,G,u.count, J,P,L,V);q(u.de,y);C&&q(G,C);return c};a.Vertices.prototype.bounds=function(c){this._bounds(ea);var g=qa.toTypedArray();return c?(c.set(g),c):g.slice()};a.Sd&&a.Sd.forEach(function(c){c()})};a.computeTonalColors=function(e){var c=x(e.ambient,"HEAPF32"),g=x(e.spot,"HEAPF32");this._computeTonalColors(c,g);var l={ambient:S(c),spot:S(g)};q(c,e.ambient);q(g,e.spot);return l};a.LTRBRect=function(e,c,g,l){return Float32Array.of(e,c,g,l)};a.XYWHRect=function(e,c,g,l){return Float32Array.of(e,c,e+g,c+l)}; a.LTRBiRect=function(e,c,g,l){return Int32Array.of(e,c,g,l)};a.XYWHiRect=function(e,c,g,l){return Int32Array.of(e,c,e+g,c+l)};a.RRectXY=function(e,c,g){return Float32Array.of(e[0],e[1],e[2],e[3],c,g,c,g,c,g,c,g)};a.MakeAnimatedImageFromEncoded=function(e){e=new Uint8Array(e);var c=a._malloc(e.byteLength);a.HEAPU8.set(e,c);return(e=a._decodeAnimatedImage(c,e.byteLength))?e:null};a.MakeImageFromEncoded=function(e){e=new Uint8Array(e);var c=a._malloc(e.byteLength);a.HEAPU8.set(e,c);return(e=a._decodeImage(c, e.byteLength))?e:null};var ib=null;a.MakeImageFromCanvasImageSource=function(e){var c=e.width,g=e.height;ib||(ib=document.createElement("canvas"));ib.width=c;ib.height=g;var l=ib.getContext("2d",{Cg:!0});l.drawImage(e,0,0);e=l.getImageData(0,0,c,g);return a.MakeImage({width:c,height:g,alphaType:a.AlphaType.Unpremul,colorType:a.ColorType.RGBA_8888,colorSpace:a.ColorSpace.SRGB},e.data,4*c)};a.MakeImage=function(e,c,g){var l=a._malloc(c.length);a.HEAPU8.set(c,l);return a._MakeImage(e,l,c.length,g)}; a.MakeVertices=function(e,c,g,l,r,y){var C=r&&r.length||0,J=0;g&&g.length&&(J|=1);l&&l.length&&(J|=2);void 0===y||y||(J|=4);e=new a._VerticesBuilder(e,c.length/2,C,J);x(c,"HEAPF32",e.positions());e.texCoords()&&x(g,"HEAPF32",e.texCoords());e.colors()&&x(m(l),"HEAPU32",e.colors());e.indices()&&x(r,"HEAPU16",e.indices());return e.detach()};a.Matrix={};a.Matrix.identity=function(){return d(3)};a.Matrix.invert=function(e){var c=e[0]*e[4]*e[8]+e[1]*e[5]*e[6]+e[2]*e[3]*e[7]-e[2]*e[4]*e[6]-e[1]*e[3]*e[8]- e[0]*e[5]*e[7];return c?[(e[4]*e[8]-e[5]*e[7])/c,(e[2]*e[7]-e[1]*e[8])/c,(e[1]*e[5]-e[2]*e[4])/c,(e[5]*e[6]-e[3]*e[8])/c,(e[0]*e[8]-e[2]*e[6])/c,(e[2]*e[3]-e[0]*e[5])/c,(e[3]*e[7]-e[4]*e[6])/c,(e[1]*e[6]-e[0]*e[7])/c,(e[0]*e[4]-e[1]*e[3])/c]:null};a.Matrix.mapPoints=function(e,c){for(var g=0;g<c.length;g+=2){var l=c[g],r=c[g+1],y=e[6]*l+e[7]*r+e[8],C=e[3]*l+e[4]*r+e[5];c[g]=(e[0]*l+e[1]*r+e[2])/y;c[g+1]=C/y}return c};a.Matrix.multiply=function(){return hb(3,arguments)};a.Matrix.rotated=function(e, c,g){c=c||0;g=g||0;var l=Math.sin(e);e=Math.cos(e);return[e,-l,wa(l,g,1-e,c),l,e,wa(-l,c,1-e,g),0,0,1]};a.Matrix.scaled=function(e,c,g,l){g=g||0;l=l||0;var r=b([e,c],d(3),3,0,1);return b([g-e*g,l-c*l],r,3,2,0)};a.Matrix.skewed=function(e,c,g,l){g=g||0;l=l||0;var r=b([e,c],d(3),3,1,-1);return b([-e*g,-c*l],r,3,2,0)};a.Matrix.translated=function(e,c){return b(arguments,d(3),3,2,0)};a.Vector={};a.Vector.dot=function(e,c){return e.map(function(g,l){return g*c[l]}).reduce(function(g,l){return g+l})};a.Vector.lengthSquared= function(e){return a.Vector.dot(e,e)};a.Vector.length=function(e){return Math.sqrt(a.Vector.lengthSquared(e))};a.Vector.mulScalar=function(e,c){return e.map(function(g){return g*c})};a.Vector.add=function(e,c){return e.map(function(g,l){return g+c[l]})};a.Vector.sub=function(e,c){return e.map(function(g,l){return g-c[l]})};a.Vector.dist=function(e,c){return a.Vector.length(a.Vector.sub(e,c))};a.Vector.normalize=function(e){return a.Vector.mulScalar(e,1/a.Vector.length(e))};a.Vector.cross=function(e, c){return[e[1]*c[2]-e[2]*c[1],e[2]*c[0]-e[0]*c[2],e[0]*c[1]-e[1]*c[0]]};a.M44={};a.M44.identity=function(){return d(4)};a.M44.translated=function(e){return b(e,d(4),4,3,0)};a.M44.scaled=function(e){return b(e,d(4),4,0,1)};a.M44.rotated=function(e,c){return a.M44.rotatedUnitSinCos(a.Vector.normalize(e),Math.sin(c),Math.cos(c))};a.M44.rotatedUnitSinCos=function(e,c,g){var l=e[0],r=e[1];e=e[2];var y=1-g;return[y*l*l+g,y*l*r-c*e,y*l*e+c*r,0,y*l*r+c*e,y*r*r+g,y*r*e-c*l,0,y*l*e-c*r,y*r*e+c*l,y*e*e+g,0, 0,0,0,1]};a.M44.lookat=function(e,c,g){c=a.Vector.normalize(a.Vector.sub(c,e));g=a.Vector.normalize(g);g=a.Vector.normalize(a.Vector.cross(c,g));var l=a.M44.identity();b(g,l,4,0,0);b(a.Vector.cross(g,c),l,4,1,0);b(a.Vector.mulScalar(c,-1),l,4,2,0);b(e,l,4,3,0);e=a.M44.invert(l);return null===e?a.M44.identity():e};a.M44.perspective=function(e,c,g){var l=1/(c-e);g/=2;g=Math.cos(g)/Math.sin(g);return[g,0,0,0,0,g,0,0,0,0,(c+e)*l,2*c*e*l,0,0,-1,1]};a.M44.rc=function(e,c,g){return e[4*c+g]};a.M44.multiply= function(){return hb(4,arguments)};a.M44.invert=function(e){var c=e[0],g=e[4],l=e[8],r=e[12],y=e[1],C=e[5],J=e[9],L=e[13],P=e[2],V=e[6],u=e[10],G=e[14],R=e[3],aa=e[7],ja=e[11];e=e[15];var ra=c*C-g*y,xa=c*J-l*y,Da=c*L-r*y,fa=g*J-l*C,I=g*L-r*C,k=l*L-r*J,p=P*aa-V*R,A=P*ja-u*R,B=P*e-G*R,E=V*ja-u*aa,F=V*e-G*aa,M=u*e-G*ja,ba=ra*M-xa*F+Da*E+fa*B-I*A+k*p,ca=1/ba;if(0===ba||Infinity===ca)return null;ra*=ca;xa*=ca;Da*=ca;fa*=ca;I*=ca;k*=ca;p*=ca;A*=ca;B*=ca;E*=ca;F*=ca;M*=ca;c=[C*M-J*F+L*E,J*B-y*M-L*A,y*F- C*B+L*p,C*A-y*E-J*p,l*F-g*M-r*E,c*M-l*B+r*A,g*B-c*F-r*p,c*E-g*A+l*p,aa*k-ja*I+e*fa,ja*Da-R*k-e*xa,R*I-aa*Da+e*ra,aa*xa-R*fa-ja*ra,u*I-V*k-G*fa,P*k-u*Da+G*xa,V*Da-P*I-G*ra,P*fa-V*xa+u*ra];return c.every(function(Ia){return!isNaN(Ia)&&Infinity!==Ia&&-Infinity!==Ia})?c:null};a.M44.transpose=function(e){return[e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13],e[2],e[6],e[10],e[14],e[3],e[7],e[11],e[15]]};a.M44.mustInvert=function(e){e=a.M44.invert(e);if(null===e)throw"Matrix not invertible";return e};a.M44.setupCamera= function(e,c,g){var l=a.M44.lookat(g.eye,g.coa,g.up);g=a.M44.perspective(g.near,g.far,g.angle);c=[(e[2]-e[0])/2,(e[3]-e[1])/2,c];e=a.M44.multiply(a.M44.translated([(e[0]+e[2])/2,(e[1]+e[3])/2,0]),a.M44.scaled(c));return a.M44.multiply(e,g,l,a.M44.mustInvert(e))};a.ColorMatrix={};a.ColorMatrix.identity=function(){var e=new Float32Array(20);e[0]=1;e[6]=1;e[12]=1;e[18]=1;return e};a.ColorMatrix.scaled=function(e,c,g,l){var r=new Float32Array(20);r[0]=e;r[6]=c;r[12]=g;r[18]=l;return r};var Ad=[[6,7,11, 12],[0,10,2,12],[0,1,5,6]];a.ColorMatrix.rotated=function(e,c,g){var l=a.ColorMatrix.identity();e=Ad[e];l[e[0]]=g;l[e[1]]=c;l[e[2]]=-c;l[e[3]]=g;return l};a.ColorMatrix.postTranslate=function(e,c,g,l,r){e[4]+=c;e[9]+=g;e[14]+=l;e[19]+=r;return e};a.ColorMatrix.concat=function(e,c){for(var g=new Float32Array(20),l=0,r=0;20>r;r+=5){for(var y=0;4>y;y++)g[l++]=e[r]*c[y]+e[r+1]*c[y+5]+e[r+2]*c[y+10]+e[r+3]*c[y+15];g[l++]=e[r]*c[4]+e[r+1]*c[9]+e[r+2]*c[14]+e[r+3]*c[19]+e[r+4]}return g};(function(e){e.Sd= e.Sd||[];e.Sd.push(function(){function c(u){if(!u||!u.length)return[];for(var G=[],R=0;R<u.length;R+=5){var aa=e.LTRBRect(u[R],u[R+1],u[R+2],u[R+3]);aa.direction=0===u[R+4]?e.TextDirection.RTL:e.TextDirection.LTR;G.push(aa)}e._free(u.byteOffset);return G}function g(u){u=u||{};void 0===u.weight&&(u.weight=e.FontWeight.Normal);u.width=u.width||e.FontWidth.Normal;u.slant=u.slant||e.FontSlant.Upright;return u}function l(u){if(!u||!u.length)return U;for(var G=[],R=0;R<u.length;R++){var aa=r(u[R]);G.push(aa)}return x(G, "HEAPU32")}function r(u){if(J[u])return J[u];var G=oa(u)+1,R=e._malloc(G);sa(u,K,R,G);return J[u]=R}function y(u){u._colorPtr=z(u.color);u._foregroundColorPtr=U;u._backgroundColorPtr=U;u._decorationColorPtr=U;u.foregroundColor&&(u._foregroundColorPtr=z(u.foregroundColor,L));u.backgroundColor&&(u._backgroundColorPtr=z(u.backgroundColor,P));u.decorationColor&&(u._decorationColorPtr=z(u.decorationColor,V));Array.isArray(u.fontFamilies)&&u.fontFamilies.length?(u._fontFamiliesPtr=l(u.fontFamilies),u._fontFamiliesLen= u.fontFamilies.length):(u._fontFamiliesPtr=U,u._fontFamiliesLen=0);if(u.locale){var G=u.locale;u._localePtr=r(G);u._localeLen=oa(G)+1}else u._localePtr=U,u._localeLen=0;if(Array.isArray(u.shadows)&&u.shadows.length){G=u.shadows;var R=G.map(function(fa){return fa.color||e.BLACK}),aa=G.map(function(fa){return fa.blurRadius||0});u._shadowLen=G.length;for(var ja=e._malloc(8*G.length),ra=ja/4,xa=0;xa<G.length;xa++){var Da=G[xa].offset||[0,0];e.HEAPF32[ra]=Da[0];e.HEAPF32[ra+1]=Da[1];ra+=2}u._shadowColorsPtr= D(R).de;u._shadowOffsetsPtr=ja;u._shadowBlurRadiiPtr=x(aa,"HEAPF32")}else u._shadowLen=0,u._shadowColorsPtr=U,u._shadowOffsetsPtr=U,u._shadowBlurRadiiPtr=U;Array.isArray(u.fontFeatures)&&u.fontFeatures.length?(G=u.fontFeatures,R=G.map(function(fa){return fa.name}),aa=G.map(function(fa){return fa.value}),u._fontFeatureLen=G.length,u._fontFeatureNamesPtr=l(R),u._fontFeatureValuesPtr=x(aa,"HEAPU32")):(u._fontFeatureLen=0,u._fontFeatureNamesPtr=U,u._fontFeatureValuesPtr=U)}function C(u){e._free(u._fontFamiliesPtr); e._free(u._shadowColorsPtr);e._free(u._shadowOffsetsPtr);e._free(u._shadowBlurRadiiPtr);e._free(u._fontFeatureNamesPtr);e._free(u._fontFeatureValuesPtr)}e.Paragraph.prototype.getRectsForRange=function(u,G,R,aa){u=this._getRectsForRange(u,G,R,aa);return c(u)};e.Paragraph.prototype.getRectsForPlaceholders=function(){var u=this._getRectsForPlaceholders();return c(u)};e.TypefaceFontProvider.prototype.registerFont=function(u,G){u=e.Typeface.MakeFreeTypeFaceFromData(u);if(!u)return null;G=r(G);this._registerFont(u, G)};e.ParagraphStyle=function(u){u.disableHinting=u.disableHinting||!1;if(u.ellipsis){var G=u.ellipsis;u._ellipsisPtr=r(G);u._ellipsisLen=oa(G)+1}else u._ellipsisPtr=U,u._ellipsisLen=0;u.heightMultiplier=u.heightMultiplier||0;u.maxLines=u.maxLines||0;G=(G=u.strutStyle)||{};G.strutEnabled=G.strutEnabled||!1;G.strutEnabled&&Array.isArray(G.fontFamilies)&&G.fontFamilies.length?(G._fontFamiliesPtr=l(G.fontFamilies),G._fontFamiliesLen=G.fontFamilies.length):(G._fontFamiliesPtr=U,G._fontFamiliesLen=0); G.fontStyle=g(G.fontStyle);G.fontSize=G.fontSize||0;G.heightMultiplier=G.heightMultiplier||0;G.halfLeading=G.halfLeading||!1;G.leading=G.leading||0;G.forceStrutHeight=G.forceStrutHeight||!1;u.strutStyle=G;u.textAlign=u.textAlign||e.TextAlign.Start;u.textDirection=u.textDirection||e.TextDirection.LTR;u.textHeightBehavior=u.textHeightBehavior||e.TextHeightBehavior.All;u.textStyle=e.TextStyle(u.textStyle);return u};e.TextStyle=function(u){u.color||(u.color=e.BLACK);u.decoration=u.decoration||0;u.decorationThickness= u.decorationThickness||0;u.decorationStyle=u.decorationStyle||e.DecorationStyle.Solid;u.textBaseline=u.textBaseline||e.TextBaseline.Alphabetic;u.fontSize=u.fontSize||0;u.letterSpacing=u.letterSpacing||0;u.wordSpacing=u.wordSpacing||0;u.heightMultiplier=u.heightMultiplier||0;u.halfLeading=u.halfLeading||!1;u.fontStyle=g(u.fontStyle);return u};var J={},L=e._malloc(16),P=e._malloc(16),V=e._malloc(16);e.ParagraphBuilder.Make=function(u,G){y(u.textStyle);G=e.ParagraphBuilder._Make(u,G);C(u.textStyle); return G};e.ParagraphBuilder.MakeFromFontProvider=function(u,G){y(u.textStyle);G=e.ParagraphBuilder._MakeFromFontProvider(u,G);C(u.textStyle);return G};e.ParagraphBuilder.ShapeText=function(u,G,R){let aa=0;for(const ja of G)aa+=ja.length;if(aa!==u.length)throw"Accumulated block lengths must equal text.length";return e.ParagraphBuilder._ShapeText(u,G,R)};e.ParagraphBuilder.prototype.pushStyle=function(u){y(u);this._pushStyle(u);C(u)};e.ParagraphBuilder.prototype.pushPaintStyle=function(u,G,R){y(u); this._pushPaintStyle(u,G,R);C(u)};e.ParagraphBuilder.prototype.addPlaceholder=function(u,G,R,aa,ja){R=R||e.PlaceholderAlignment.Baseline;aa=aa||e.TextBaseline.Alphabetic;this._addPlaceholder(u||0,G||0,R,aa,ja||0)}})})(v);a.MakeManagedAnimation=function(e,c,g,l,r){if(!a._MakeManagedAnimation)throw"Not compiled with MakeManagedAnimation";g||(g="");if(!c)return a._MakeManagedAnimation(e,0,U,U,U,g,l,r);for(var y=[],C=[],J=[],L=Object.keys(c||{}),P=0;P<L.length;P++){var V=L[P],u=new Uint8Array(c[V]),G= a._malloc(u.byteLength);a.HEAPU8.set(u,G);C.push(G);J.push(u.byteLength);u=oa(V)+1;G=a._malloc(u);sa(V,K,G,u);y.push(G)}c=x(y,"HEAPU32");C=x(C,"HEAPU32");J=x(J,"HEAPU32");e=a._MakeManagedAnimation(e,L.length,c,C,J,g,l,r);a._free(c);a._free(C);a._free(J);return e};(function(e){e.Sd=e.Sd||[];e.Sd.push(function(){e.Animation.prototype.render=function(c,g){T(g,ea);this._render(c,ea)};e.Animation.prototype.size=function(c){this._size(ea);var g=qa.toTypedArray();return c?(c[0]=g[0],c[1]=g[1],c):g.slice(0, 2)};e.ManagedAnimation&&(e.ManagedAnimation.prototype.render=function(c,g){T(g,ea);this._render(c,ea)},e.ManagedAnimation.prototype.seek=function(c,g){this._seek(c,ea);c=qa.toTypedArray();return g?(g.set(c),g):c.slice()},e.ManagedAnimation.prototype.seekFrame=function(c,g){this._seekFrame(c,ea);c=qa.toTypedArray();return g?(g.set(c),g):c.slice()},e.ManagedAnimation.prototype.setColor=function(c,g){g=z(g);return this._setColor(c,g)},e.ManagedAnimation.prototype.size=function(c){this._size(ea);var g= qa.toTypedArray();return c?(c[0]=g[0],c[1]=g[1],c):g.slice(0,2)})})})(v);a.MakeParticles=function(e,c){if(!a._MakeParticles)throw"Not compiled with MakeParticles";if(!c)return a._MakeParticles(e,0,U,U,U);for(var g=[],l=[],r=[],y=Object.keys(c||{}),C=0;C<y.length;C++){var J=y[C],L=new Uint8Array(c[J]),P=a._malloc(L.byteLength);a.HEAPU8.set(L,P);l.push(P);r.push(L.byteLength);L=oa(J)+1;P=a._malloc(L);sa(J,K,P,L);g.push(P)}c=x(g,"HEAPU32");l=x(l,"HEAPU32");r=x(r,"HEAPU32");e=a._MakeParticles(e,y.length, c,l,r);a._free(c);a._free(l);a._free(r);return e};a.Sd=a.Sd||[];a.Sd.push(function(){a.ParticleEffect.prototype.uniforms=function(){var e=this._uniformPtr(),c=this.getUniformFloatCount();return!e||0>=c?new Float32Array:new Float32Array(a.HEAPU8.buffer,e,c)};a.ParticleEffect.prototype.setPosition=function(e){this._setPosition(e[0],e[1])}});a.Sd=a.Sd||[];a.Sd.push(function(){a.Path.prototype.op=function(e,c){return this._op(e,c)?this:null};a.Path.prototype.simplify=function(){return this._simplify()? this:null}});a.Sd=a.Sd||[];a.Sd.push(function(){a.Canvas.prototype.drawText=function(e,c,g,l,r){var y=oa(e),C=a._malloc(y+1);sa(e,K,C,y+1);this._drawSimpleText(C,y,c,g,r,l);a._free(C)};a.Canvas.prototype.drawGlyphs=function(e,c,g,l,r,y){if(!(2*e.length<=c.length))throw"Not enough positions for the array of gyphs";a.Pd(this.Nd);const C=x(e,"HEAPU16"),J=x(c,"HEAPF32");this._drawGlyphs(e.length,C,J,g,l,r,y);q(J,c);q(C,e)};a.Font.prototype.getGlyphBounds=function(e,c,g){var l=x(e,"HEAPU16"),r=a._malloc(16* e.length);this._getGlyphWidthBounds(l,e.length,U,r,c||null);c=new Float32Array(a.HEAPU8.buffer,r,4*e.length);q(l,e);if(g)return g.set(c),a._free(r),g;e=Float32Array.from(c);a._free(r);return e};a.Font.prototype.getGlyphIDs=function(e,c,g){c||(c=e.length);var l=oa(e)+1,r=a._malloc(l);sa(e,K,r,l);e=a._malloc(2*c);c=this._getGlyphIDs(r,l-1,c,e);a._free(r);if(0>c)return a._free(e),null;r=new Uint16Array(a.HEAPU8.buffer,e,c);if(g)return g.set(r),a._free(e),g;g=Uint16Array.from(r);a._free(e);return g}; a.Font.prototype.getGlyphIntercepts=function(e,c,g,l){var r=x(e,"HEAPU16"),y=x(c,"HEAPF32");return this._getGlyphIntercepts(r,e.length,!(e&&e._ck),y,c.length,!(c&&c._ck),g,l)};a.Font.prototype.getGlyphWidths=function(e,c,g){var l=x(e,"HEAPU16"),r=a._malloc(4*e.length);this._getGlyphWidthBounds(l,e.length,r,U,c||null);c=new Float32Array(a.HEAPU8.buffer,r,e.length);q(l,e);if(g)return g.set(c),a._free(r),g;e=Float32Array.from(c);a._free(r);return e};a.FontMgr.FromData=function(){if(!arguments.length)return null; var e=arguments;1===e.length&&Array.isArray(e[0])&&(e=arguments[0]);if(!e.length)return null;for(var c=[],g=[],l=0;l<e.length;l++){var r=new Uint8Array(e[l]),y=x(r,"HEAPU8");c.push(y);g.push(r.byteLength)}c=x(c,"HEAPU32");g=x(g,"HEAPU32");e=a.FontMgr._fromData(c,g,e.length);a._free(c);a._free(g);return e};a.Typeface.MakeFreeTypeFaceFromData=function(e){e=new Uint8Array(e);var c=x(e,"HEAPU8");return(e=a.Typeface._MakeFreeTypeFaceFromData(c,e.byteLength))?e:null};a.Typeface.prototype.getGlyphIDs=function(e, c,g){c||(c=e.length);var l=oa(e)+1,r=a._malloc(l);sa(e,K,r,l);e=a._malloc(2*c);c=this._getGlyphIDs(r,l-1,c,e);a._free(r);if(0>c)return a._free(e),null;r=new Uint16Array(a.HEAPU8.buffer,e,c);if(g)return g.set(r),a._free(e),g;g=Uint16Array.from(r);a._free(e);return g};a.TextBlob.MakeOnPath=function(e,c,g,l){if(e&&e.length&&c&&c.countPoints()){if(1===c.countPoints())return this.MakeFromText(e,g);l||(l=0);var r=g.getGlyphIDs(e);r=g.getGlyphWidths(r);var y=[];c=new a.ContourMeasureIter(c,!1,1);for(var C= c.next(),J=new Float32Array(4),L=0;L<e.length&&C;L++){var P=r[L];l+=P/2;if(l>C.length()){C.delete();C=c.next();if(!C){e=e.substring(0,L);break}l=P/2}C.getPosTan(l,J);var V=J[2],u=J[3];y.push(V,u,J[0]-P/2*V,J[1]-P/2*u);l+=P/2}e=this.MakeFromRSXform(e,y,g);C&&C.delete();c.delete();return e}};a.TextBlob.MakeFromRSXform=function(e,c,g){var l=oa(e)+1,r=a._malloc(l);sa(e,K,r,l);e=x(c,"HEAPF32");g=a.TextBlob._MakeFromRSXform(r,l-1,e,g);a._free(r);return g?g:null};a.TextBlob.MakeFromRSXformGlyphs=function(e, c,g){var l=x(e,"HEAPU16");c=x(c,"HEAPF32");g=a.TextBlob._MakeFromRSXformGlyphs(l,2*e.length,c,g);q(l,e);return g?g:null};a.TextBlob.MakeFromGlyphs=function(e,c){var g=x(e,"HEAPU16");c=a.TextBlob._MakeFromGlyphs(g,2*e.length,c);q(g,e);return c?c:null};a.TextBlob.MakeFromText=function(e,c){var g=oa(e)+1,l=a._malloc(g);sa(e,K,l,g);e=a.TextBlob._MakeFromText(l,g-1,c);a._free(l);return e?e:null};a.MallocGlyphIDs=function(e){return a.Malloc(Uint16Array,e)}});a.Sd=a.Sd||[];a.Sd.push(function(){a.MakePicture= function(e){e=new Uint8Array(e);var c=a._malloc(e.byteLength);a.HEAPU8.set(e,c);return(e=a._MakePicture(c,e.byteLength))?e:null}});a.Sd=a.Sd||[];a.Sd.push(function(){a.RuntimeEffect.Make=function(e,c){return a.RuntimeEffect._Make(e,{onError:c||function(g){console.log("RuntimeEffect error",g)}})};a.RuntimeEffect.prototype.makeShader=function(e,c){var g=!e._ck,l=x(e,"HEAPF32");c=H(c);return this._makeShader(l,4*e.length,g,c)};a.RuntimeEffect.prototype.makeShaderWithChildren=function(e,c,g){var l=!e._ck, r=x(e,"HEAPF32");g=H(g);for(var y=[],C=0;C<c.length;C++)y.push(c[C].Md.Vd);c=x(y,"HEAPU32");return this._makeShaderWithChildren(r,4*e.length,l,c,y.length,g)}});(function(){function e(I){for(var k=0;k<I.length;k++)if(void 0!==I[k]&&!Number.isFinite(I[k]))return!1;return!0}function c(I){var k=a.getColorComponents(I);I=k[0];var p=k[1],A=k[2];k=k[3];if(1===k)return I=I.toString(16).toLowerCase(),p=p.toString(16).toLowerCase(),A=A.toString(16).toLowerCase(),I=1===I.length?"0"+I:I,p=1===p.length?"0"+p: p,A=1===A.length?"0"+A:A,"#"+I+p+A;k=0===k||1===k?k:k.toFixed(8);return"rgba("+I+", "+p+", "+A+", "+k+")"}function g(I){return a.parseColorString(I,xa)}function l(I){I=Da.exec(I);if(!I)return null;var k=parseFloat(I[4]),p=16;switch(I[5]){case "em":case "rem":p=16*k;break;case "pt":p=4*k/3;break;case "px":p=k;break;case "pc":p=16*k;break;case "in":p=96*k;break;case "cm":p=96*k/2.54;break;case "mm":p=96/25.4*k;break;case "q":p=96/25.4/4*k;break;case "%":p=16/75*k}return{style:I[1],variant:I[2],weight:I[3], sizePx:p,family:I[6].trim()}}function r(I){this.Od=I;this.Rd=new a.Paint;this.Rd.setAntiAlias(!0);this.Rd.setStrokeMiter(10);this.Rd.setStrokeCap(a.StrokeCap.Butt);this.Rd.setStrokeJoin(a.StrokeJoin.Miter);this.Re="10px monospace";this.oe=new a.Font(null,10);this.oe.setSubpixel(!0);this.ce=this.he=a.BLACK;this.xe=0;this.Ke=a.TRANSPARENT;this.ze=this.ye=0;this.Le=this.le=1;this.Je=0;this.we=[];this.Qd=a.BlendMode.SrcOver;this.Rd.setStrokeWidth(this.Le);this.Rd.setBlendMode(this.Qd);this.Ud=new a.Path; this.Wd=a.Matrix.identity();this.mf=[];this.De=[];this.ne=function(){this.Ud.delete();this.Rd.delete();this.oe.delete();this.De.forEach(function(k){k.ne()})};Object.defineProperty(this,"currentTransform",{enumerable:!0,get:function(){return{a:this.Wd[0],c:this.Wd[1],e:this.Wd[2],b:this.Wd[3],d:this.Wd[4],f:this.Wd[5]}},set:function(k){k.a&&this.setTransform(k.a,k.b,k.c,k.d,k.e,k.f)}});Object.defineProperty(this,"fillStyle",{enumerable:!0,get:function(){return f(this.ce)?c(this.ce):this.ce},set:function(k){"string"=== typeof k?this.ce=g(k):k.ve&&(this.ce=k)}});Object.defineProperty(this,"font",{enumerable:!0,get:function(){return this.Re},set:function(k){var p=l(k),A=p.family;p.typeface=fa[A]?fa[A][(p.style||"normal")+"|"+(p.variant||"normal")+"|"+(p.weight||"normal")]||fa[A]["*"]:null;p&&(this.oe.setSize(p.sizePx),this.oe.setTypeface(p.typeface),this.Re=k)}});Object.defineProperty(this,"globalAlpha",{enumerable:!0,get:function(){return this.le},set:function(k){!isFinite(k)||0>k||1<k||(this.le=k)}});Object.defineProperty(this, "globalCompositeOperation",{enumerable:!0,get:function(){switch(this.Qd){case a.BlendMode.SrcOver:return"source-over";case a.BlendMode.DstOver:return"destination-over";case a.BlendMode.Src:return"copy";case a.BlendMode.Dst:return"destination";case a.BlendMode.Clear:return"clear";case a.BlendMode.SrcIn:return"source-in";case a.BlendMode.DstIn:return"destination-in";case a.BlendMode.SrcOut:return"source-out";case a.BlendMode.DstOut:return"destination-out";case a.BlendMode.SrcATop:return"source-atop"; case a.BlendMode.DstATop:return"destination-atop";case a.BlendMode.Xor:return"xor";case a.BlendMode.Plus:return"lighter";case a.BlendMode.Multiply:return"multiply";case a.BlendMode.Screen:return"screen";case a.BlendMode.Overlay:return"overlay";case a.BlendMode.Darken:return"darken";case a.BlendMode.Lighten:return"lighten";case a.BlendMode.ColorDodge:return"color-dodge";case a.BlendMode.ColorBurn:return"color-burn";case a.BlendMode.HardLight:return"hard-light";case a.BlendMode.SoftLight:return"soft-light"; case a.BlendMode.Difference:return"difference";case a.BlendMode.Exclusion:return"exclusion";case a.BlendMode.Hue:return"hue";case a.BlendMode.Saturation:return"saturation";case a.BlendMode.Color:return"color";case a.BlendMode.Luminosity:return"luminosity"}},set:function(k){switch(k){case "source-over":this.Qd=a.BlendMode.SrcOver;break;case "destination-over":this.Qd=a.BlendMode.DstOver;break;case "copy":this.Qd=a.BlendMode.Src;break;case "destination":this.Qd=a.BlendMode.Dst;break;case "clear":this.Qd= a.BlendMode.Clear;break;case "source-in":this.Qd=a.BlendMode.SrcIn;break;case "destination-in":this.Qd=a.BlendMode.DstIn;break;case "source-out":this.Qd=a.BlendMode.SrcOut;break;case "destination-out":this.Qd=a.BlendMode.DstOut;break;case "source-atop":this.Qd=a.BlendMode.SrcATop;break;case "destination-atop":this.Qd=a.BlendMode.DstATop;break;case "xor":this.Qd=a.BlendMode.Xor;break;case "lighter":this.Qd=a.BlendMode.Plus;break;case "plus-lighter":this.Qd=a.BlendMode.Plus;break;case "plus-darker":throw"plus-darker is not supported"; case "multiply":this.Qd=a.BlendMode.Multiply;break;case "screen":this.Qd=a.BlendMode.Screen;break;case "overlay":this.Qd=a.BlendMode.Overlay;break;case "darken":this.Qd=a.BlendMode.Darken;break;case "lighten":this.Qd=a.BlendMode.Lighten;break;case "color-dodge":this.Qd=a.BlendMode.ColorDodge;break;case "color-burn":this.Qd=a.BlendMode.ColorBurn;break;case "hard-light":this.Qd=a.BlendMode.HardLight;break;case "soft-light":this.Qd=a.BlendMode.SoftLight;break;case "difference":this.Qd=a.BlendMode.Difference; break;case "exclusion":this.Qd=a.BlendMode.Exclusion;break;case "hue":this.Qd=a.BlendMode.Hue;break;case "saturation":this.Qd=a.BlendMode.Saturation;break;case "color":this.Qd=a.BlendMode.Color;break;case "luminosity":this.Qd=a.BlendMode.Luminosity;break;default:return}this.Rd.setBlendMode(this.Qd)}});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.Rd.getStrokeCap()){case a.StrokeCap.Butt:return"butt";case a.StrokeCap.Round:return"round";case a.StrokeCap.Square:return"square"}},set:function(k){switch(k){case "butt":this.Rd.setStrokeCap(a.StrokeCap.Butt);break;case "round":this.Rd.setStrokeCap(a.StrokeCap.Round);break;case "square":this.Rd.setStrokeCap(a.StrokeCap.Square)}}});Object.defineProperty(this,"lineDashOffset",{enumerable:!0,get:function(){return this.Je}, set:function(k){isFinite(k)&&(this.Je=k)}});Object.defineProperty(this,"lineJoin",{enumerable:!0,get:function(){switch(this.Rd.getStrokeJoin()){case a.StrokeJoin.Miter:return"miter";case a.StrokeJoin.Round:return"round";case a.StrokeJoin.Bevel:return"bevel"}},set:function(k){switch(k){case "miter":this.Rd.setStrokeJoin(a.StrokeJoi