UNPKG

canvaskit-wasm

Version:

A WASM version of Skia's Canvas API

108 lines (105 loc) 123 kB
var CanvasKitInit = (function() { 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 r;r||(r=typeof CanvasKitInit !== 'undefined' ? CanvasKitInit : {});var ca,ea;r.ready=new Promise(function(a,b){ca=a;ea=b}); (function(a){a.Ud=a.Ud||[];a.Ud.push(function(){a.MakeSWCanvasSurface=function(b){var c=b;if("CANVAS"!==c.tagName&&(c=document.getElementById(b),!c))throw"Canvas with id "+b+" was not found";if(b=a.MakeSurface(c.width,c.height))b.Ld=c;return b};a.MakeCanvasSurface||(a.MakeCanvasSurface=a.MakeSWCanvasSurface);a.MakeSurface=function(b,c){var f={width:b,height:c,colorType:a.ColorType.RGBA_8888,alphaType:a.AlphaType.Unpremul,colorSpace:a.ColorSpace.SRGB},g=b*c*4,m=a._malloc(g);if(f=a.Surface._makeRasterDirect(f, m,4*b))f.Ld=null,f.yf=b,f.vf=c,f.xf=g,f.bf=m,f.getCanvas().clear(a.TRANSPARENT);return f};a.MakeRasterDirectSurface=function(b,c,f){return a.Surface._makeRasterDirect(b,c.byteOffset,f)};a.Surface.prototype.flush=function(b){this._flush();if(this.Ld){var c=new Uint8ClampedArray(a.HEAPU8.buffer,this.bf,this.xf);c=new ImageData(c,this.yf,this.vf);b?this.Ld.getContext("2d").putImageData(c,0,0,b[0],b[1],b[2]-b[0],b[3]-b[1]):this.Ld.getContext("2d").putImageData(c,0,0)}};a.Surface.prototype.dispose=function(){this.bf&& a._free(this.bf);this.delete()};a.currentContext=a.currentContext||function(){};a.setCurrentContext=a.setCurrentContext||function(){}})})(r); (function(a){a.Ud=a.Ud||[];a.Ud.push(function(){function b(c,f,g){return c&&c.hasOwnProperty(f)?c[f]:g}a.GetWebGLContext=function(c,f){if(!c)throw"null canvas passed into makeWebGLContext";var g={alpha:b(f,"alpha",1),depth:b(f,"depth",1),stencil:b(f,"stencil",8),antialias:b(f,"antialias",0),premultipliedAlpha:b(f,"premultipliedAlpha",1),preserveDrawingBuffer:b(f,"preserveDrawingBuffer",0),preferLowPowerToHighPerformance:b(f,"preferLowPowerToHighPerformance",0),failIfMajorPerformanceCaveat:b(f,"failIfMajorPerformanceCaveat", 0),enableExtensionsByDefault:b(f,"enableExtensionsByDefault",1),explicitSwapControl:b(f,"explicitSwapControl",0),renderViaOffscreenBackBuffer:b(f,"renderViaOffscreenBackBuffer",0)};g.majorVersion=f&&f.majorVersion?f.majorVersion:"undefined"!==typeof WebGL2RenderingContext?2:1;if(g.explicitSwapControl)throw"explicitSwapControl is not supported";if(c=1<g.majorVersion?c.getContext("webgl2",g):c.getContext("webgl",g)){f=ha(ja);var m={Qf:f,attributes:g,version:g.majorVersion,Ge:c};c.canvas&&(c.canvas.lf= m);ja[f]=m;("undefined"===typeof g.Ef||g.Ef)&&la(m);g=f}else g=0;if(!g)return 0;ma(g);return g};a.deleteContext=function(c){u===ja[c]&&(u=null);"object"===typeof JSEvents&&JSEvents.Ag(ja[c].Ge.canvas);ja[c]&&ja[c].Ge.canvas&&(ja[c].Ge.canvas.lf=void 0);ja[c]=null};a.MakeWebGLCanvasSurface=function(c,f,g){f=f||null;var m=c,p="undefined"!==typeof OffscreenCanvas&&m instanceof OffscreenCanvas;if(!("undefined"!==typeof HTMLCanvasElement&&m instanceof HTMLCanvasElement||p||(m=document.getElementById(c), m)))throw"Canvas with id "+c+" was not found";c=this.GetWebGLContext(m,g);if(!c||0>c)throw"failed to create webgl context: err "+c;g=this.MakeGrContext(c);f=this.MakeOnScreenGLSurface(g,m.width,m.height,f);if(!f)return f=m.cloneNode(!0),m.parentNode.replaceChild(f,m),f.classList.add("ck-replaced"),a.MakeSWCanvasSurface(f);f.le=c;f.grContext=g;f.openGLversion=m.lf.version;return f};a.MakeCanvasSurface=a.MakeWebGLCanvasSurface})})(r); (function(a){function b(d,e,h,l,q){for(var z=0;z<d.length;z++)e[z*h+(z*q+l+h)%h]=d[z];return e}function c(d){for(var e=d*d,h=Array(e);e--;)h[e]=0===e%(d+1)?1:0;return h}function f(d){return d?d.constructor===Float32Array&&4===d.length:!1}function g(d){return(t(255*d[3])<<24|t(255*d[0])<<16|t(255*d[1])<<8|t(255*d[2])<<0)>>>0}function m(d){if(d instanceof Float32Array){for(var e=Math.floor(d.length/4),h=new Uint32Array(e),l=0;l<e;l++)h[l]=g(d.slice(4*l,4*(l+1)));return h}if(d instanceof Uint32Array)return d; if(d instanceof Array&&d[0]instanceof Float32Array)return d.map(g)}function p(d){if(void 0===d)return 1;var e=parseFloat(d);return d&&-1!==d.indexOf("%")?e/100:e}function t(d){return Math.round(Math.max(0,Math.min(d||0,255)))}function y(d,e){e&&!e._ck&&a._free(d)}function w(d,e,h){if(!d||!d.length)return T;if(d._ck)return d.byteOffset;var l=a[e].BYTES_PER_ELEMENT;h||(h=a._malloc(d.length*l));a[e].set(d,h/l);return h}function H(d){var e={ae:T,count:d.length,Ne:a.ColorType.RGBA_F32};if(d instanceof Float32Array)e.ae=w(d,"HEAPF32"),e.count=d.length/4;else if(d instanceof Uint32Array)e.ae=w(d,"HEAPU32"),e.Ne=a.ColorType.RGBA_8888;else if(d instanceof Array){if(d&&d.length){for(var h=a._malloc(16*d.length),l=0,q=h/4,z=0;z<d.length;z++)for(var D=0;4>D;D++)a.HEAPF32[q+l]=d[z][D],l++;d=h}else d=T;e.ae=d}else throw"Invalid argument to copyFlexibleColorArray, Not a color array "+typeof d;return e}function L(d){if(!d)return T;if(d.length){if(6===d.length||9===d.length)return w(d,"HEAPF32",Ja),6===d.length&& a.HEAPF32.set(Id,6+Ja/4),Ja;if(16===d.length){var e=Bb.toTypedArray();e[0]=d[0];e[1]=d[1];e[2]=d[3];e[3]=d[4];e[4]=d[5];e[5]=d[7];e[6]=d[12];e[7]=d[13];e[8]=d[15];return Ja}throw"invalid matrix size";}e=Bb.toTypedArray();e[0]=d.m11;e[1]=d.m21;e[2]=d.m41;e[3]=d.m12;e[4]=d.m22;e[5]=d.m42;e[6]=d.m14;e[7]=d.m24;e[8]=d.m44;return Ja}function P(d){if(!d)return T;var e=ec.toTypedArray();if(d.length){if(16!==d.length&&6!==d.length&&9!==d.length)throw"invalid matrix size";if(16===d.length)return w(d,"HEAPF32", Ka);e.fill(0);e[0]=d[0];e[1]=d[1];e[3]=d[2];e[4]=d[3];e[5]=d[4];e[7]=d[5];e[12]=d[6];e[13]=d[7];e[15]=d[8];6===d.length&&(e[12]=0,e[13]=0,e[15]=1);return Ka}e[0]=d.m11;e[1]=d.m21;e[2]=d.m31;e[3]=d.m41;e[4]=d.m12;e[5]=d.m22;e[6]=d.m32;e[7]=d.m42;e[8]=d.m13;e[9]=d.m23;e[10]=d.m33;e[11]=d.m43;e[12]=d.m14;e[13]=d.m24;e[14]=d.m34;e[15]=d.m44;return Ka}function A(d){for(var e=Array(16),h=0;16>h;h++)e[h]=a.HEAPF32[d/4+h];return e}function M(d,e){return w(d,"HEAPF32",e||hb)}function Y(d,e,h,l){var q=fc.toTypedArray(); q[0]=d;q[1]=e;q[2]=h;q[3]=l;return hb}function da(d){for(var e=new Float32Array(4),h=0;4>h;h++)e[h]=a.HEAPF32[d/4+h];return e}function aa(d,e){return w(d,"HEAPF32",e||ia)}function oa(d,e){return w(d,"HEAPF32",e||hc)}function Cb(d,e){if(Oc)require("fs").writeFile(e,new Buffer(d),function(l){if(l)throw l;});else{url=window.URL.createObjectURL(new Blob([d],{type:"application/octet-stream"}));var h=document.createElement("a");document.body.appendChild(h);h.href=url;h.download=e;h.click();setTimeout(function(){URL.revokeObjectURL(url); h.remove()},50)}}function ib(){for(var d=0,e=0;e<arguments.length-1;e+=2)d+=arguments[e]*arguments[e+1];return d}function Pc(d,e,h){for(var l=Array(d.length),q=0;q<h;q++)for(var z=0;z<h;z++){for(var D=0,J=0;J<h;J++)D+=d[h*q+J]*e[h*J+z];l[q*h+z]=D}return l}function Qc(d,e){for(var h=Pc(e[0],e[1],d),l=2;l<e.length;)h=Pc(h,e[l],d),l++;return h}a.Color=function(d,e,h,l){void 0===l&&(l=1);return a.Color4f(t(d)/255,t(e)/255,t(h)/255,l)};a.ColorAsInt=function(d,e,h,l){void 0===l&&(l=255);return(t(l)<<24| t(d)<<16|t(e)<<8|t(h)<<0&268435455)>>>0};a.Color4f=function(d,e,h,l){void 0===l&&(l=1);return Float32Array.of(d,e,h,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(d){return[Math.floor(255*d[0]),Math.floor(255*d[1]),Math.floor(255*d[2]),d[3]]};a.parseColorString=function(d,e){d=d.toLowerCase();if(d.startsWith("#")){e= 255;switch(d.length){case 9:e=parseInt(d.slice(7,9),16);case 7:var h=parseInt(d.slice(1,3),16);var l=parseInt(d.slice(3,5),16);var q=parseInt(d.slice(5,7),16);break;case 5:e=17*parseInt(d.slice(4,5),16);case 4:h=17*parseInt(d.slice(1,2),16),l=17*parseInt(d.slice(2,3),16),q=17*parseInt(d.slice(3,4),16)}return a.Color(h,l,q,e/255)}return d.startsWith("rgba")?(d=d.slice(5,-1),d=d.split(","),a.Color(+d[0],+d[1],+d[2],p(d[3]))):d.startsWith("rgb")?(d=d.slice(4,-1),d=d.split(","),a.Color(+d[0],+d[1],+d[2], p(d[3]))):d.startsWith("gray(")||d.startsWith("hsl")||!e||(d=e[d],void 0===d)?a.BLACK:d};a.multiplyByAlpha=function(d,e){d=d.slice();d[3]=Math.max(0,Math.min(d[3]*e,1));return d};a.Malloc=function(d,e){var h=a._malloc(e*d.BYTES_PER_ELEMENT);return{_ck:!0,length:e,byteOffset:h,ne:null,subarray:function(l,q){l=this.toTypedArray().subarray(l,q);l._ck=!0;return l},toTypedArray:function(){if(this.ne&&this.ne.length)return this.ne;this.ne=new d(a.HEAPU8.buffer,h,e);this.ne._ck=!0;return this.ne}}};a.Free= function(d){a._free(d.byteOffset);d.byteOffset=T;d.toTypedArray=null;d.ne=null};var Ja=T,Bb,Ka=T,ec,hb=T,fc,ya,ia=T,Rc,Sa=T,Sc,ic=T,Tc,jc=T,Uc,kc=T,Vc,hc=T,Wc,Xc=T,Id=Float32Array.of(0,0,1),lc={};a.oe=function(){this.ke=[];this.Sd=null;Object.defineProperty(this,"length",{enumerable:!0,get:function(){return this.ke.length/4}})};a.oe.prototype.push=function(d,e,h,l){this.Sd||this.ke.push(d,e,h,l)};a.oe.prototype.set=function(d,e,h,l,q){0>d||d>=this.ke.length/4||(d*=4,this.Sd?(d=this.Sd/4+d,a.HEAPF32[d]= e,a.HEAPF32[d+1]=h,a.HEAPF32[d+2]=l,a.HEAPF32[d+3]=q):(this.ke[d]=e,this.ke[d+1]=h,this.ke[d+2]=l,this.ke[d+3]=q))};a.oe.prototype.build=function(){return this.Sd?this.Sd:this.Sd=w(this.ke,"HEAPF32")};a.oe.prototype.delete=function(){this.Sd&&(a._free(this.Sd),this.Sd=null)};a.He=function(){this.Me=[];this.Sd=null;Object.defineProperty(this,"length",{enumerable:!0,get:function(){return this.Me.length}})};a.He.prototype.push=function(d){this.Sd||this.Me.push(d)};a.He.prototype.set=function(d,e){0> d||d>=this.Me.length||(d*=4,this.Sd?a.HEAPU32[this.Sd/4+d]=e:this.Me[d]=e)};a.He.prototype.build=function(){return this.Sd?this.Sd:this.Sd=w(this.Me,"HEAPU32")};a.He.prototype.delete=function(){this.Sd&&(a._free(this.Sd),this.Sd=null)};a.RectBuilder=a.oe;a.RSXFormBuilder=a.oe;a.ColorBuilder=a.He;var T=0,Oc=!(new Function("try {return this===window;}catch(e){ return false;}"))();a.onRuntimeInitialized=function(){function d(e,h,l,q,z,D){D||(D=4*q.width,q.colorType===a.ColorType.RGBA_F16?D*=2:q.colorType=== a.ColorType.RGBA_F32&&(D*=4));var J=D*q.height;var N=z?z.byteOffset:a._malloc(J);if(!e._readPixels(q,N,D,h,l))return z||a._free(N),null;if(z)return z.toTypedArray();switch(q.colorType){case a.ColorType.RGBA_8888:case a.ColorType.RGBA_F16:e=(new Uint8Array(a.HEAPU8.buffer,N,J)).slice();break;case a.ColorType.RGBA_F32:e=(new Float32Array(a.HEAPU8.buffer,N,J)).slice();break;default:return null}a._free(N);return e}fc=a.Malloc(Float32Array,4);hb=fc.byteOffset;ec=a.Malloc(Float32Array,16);Ka=ec.byteOffset; Bb=a.Malloc(Float32Array,9);Ja=Bb.byteOffset;Vc=a.Malloc(Float32Array,12);hc=Vc.byteOffset;Wc=a.Malloc(Float32Array,12);Xc=Wc.byteOffset;ya=a.Malloc(Float32Array,4);ia=ya.byteOffset;Rc=a.Malloc(Float32Array,4);Sa=Rc.byteOffset;Sc=a.Malloc(Float32Array,3);ic=Sc.byteOffset;Tc=a.Malloc(Float32Array,3);jc=Tc.byteOffset;Uc=a.Malloc(Int32Array,4);kc=Uc.byteOffset;a.ColorSpace.SRGB=a.ColorSpace._MakeSRGB();a.ColorSpace.DISPLAY_P3=a.ColorSpace._MakeDisplayP3();a.ColorSpace.ADOBE_RGB=a.ColorSpace._MakeAdobeRGB(); a.Path.MakeFromCmds=function(e){for(var h=0,l=0;l<e.length;l++)h+=e[l].length;if(lc[h])var q=lc[h];else q=new Float32Array(h),lc[h]=q;var z=0;for(l=0;l<e.length;l++)for(var D=0;D<e[l].length;D++)q[z]=e[l][D],z++;e=[w(q,"HEAPF32"),h];h=a.Path._MakeFromCmds(e[0],e[1]);a._free(e[0]);return h};a.Path.MakeFromVerbsPointsWeights=function(e,h,l){var q=w(e,"HEAPU8"),z=w(h,"HEAPF32"),D=w(l,"HEAPF32"),J=a.Path._MakeFromVerbsPointsWeights(q,e.length,z,h.length,D,l&&l.length||0);y(q,e);y(z,h);y(D,l);return J}; a.Path.prototype.addArc=function(e,h,l){e=aa(e);this._addArc(e,h,l);return this};a.Path.prototype.addOval=function(e,h,l){void 0===l&&(l=1);e=aa(e);this._addOval(e,!!h,l);return this};a.Path.prototype.addPath=function(){var e=Array.prototype.slice.call(arguments),h=e[0],l=!1;"boolean"===typeof e[e.length-1]&&(l=e.pop());if(1===e.length)this._addPath(h,1,0,0,0,1,0,0,0,1,l);else if(2===e.length)e=e[1],this._addPath(h,e[0],e[1],e[2],e[3],e[4],e[5],e[6]||0,e[7]||0,e[8]||1,l);else if(7===e.length||10=== e.length)this._addPath(h,e[1],e[2],e[3],e[4],e[5],e[6],e[7]||0,e[8]||0,e[9]||1,l);else return null;return this};a.Path.prototype.addPoly=function(e,h){var l=w(e,"HEAPF32");this._addPoly(l,e.length/2,h);y(l,e);return this};a.Path.prototype.addRect=function(e,h){e=aa(e);this._addRect(e,!!h);return this};a.Path.prototype.addRRect=function(e,h){e=oa(e);this._addRRect(e,!!h);return this};a.Path.prototype.addVerbsPointsWeights=function(e,h,l){var q=w(e,"HEAPU8"),z=w(h,"HEAPF32"),D=w(l,"HEAPF32");this._addVerbsPointsWeights(q, e.length,z,h.length,D,l&&l.length||0);y(q,e);y(z,h);y(D,l)};a.Path.prototype.arc=function(e,h,l,q,z,D){e=a.LTRBRect(e-l,h-l,e+l,h+l);z=(z-q)/Math.PI*180-360*!!D;D=new a.Path;D.addArc(e,q/Math.PI*180,z);this.addPath(D,!0);D.delete();return this};a.Path.prototype.arcToOval=function(e,h,l,q){e=aa(e);this._arcToOval(e,h,l,q);return this};a.Path.prototype.arcToRotated=function(e,h,l,q,z,D,J){this._arcToRotated(e,h,l,!!q,!!z,D,J);return this};a.Path.prototype.arcToTangent=function(e,h,l,q,z){this._arcToTangent(e, h,l,q,z);return this};a.Path.prototype.close=function(){this._close();return this};a.Path.prototype.conicTo=function(e,h,l,q,z){this._conicTo(e,h,l,q,z);return this};a.Path.prototype.computeTightBounds=function(e){this._computeTightBounds(ia);var h=ya.toTypedArray();return e?(e.set(h),e):h.slice()};a.Path.prototype.cubicTo=function(e,h,l,q,z,D){this._cubicTo(e,h,l,q,z,D);return this};a.Path.prototype.dash=function(e,h,l){return this._dash(e,h,l)?this:null};a.Path.prototype.getBounds=function(e){this._getBounds(ia); var h=ya.toTypedArray();return e?(e.set(h),e):h.slice()};a.Path.prototype.lineTo=function(e,h){this._lineTo(e,h);return this};a.Path.prototype.moveTo=function(e,h){this._moveTo(e,h);return this};a.Path.prototype.offset=function(e,h){this._transform(1,0,e,0,1,h,0,0,1);return this};a.Path.prototype.quadTo=function(e,h,l,q){this._quadTo(e,h,l,q);return this};a.Path.prototype.rArcTo=function(e,h,l,q,z,D,J){this._rArcTo(e,h,l,q,z,D,J);return this};a.Path.prototype.rConicTo=function(e,h,l,q,z){this._rConicTo(e, h,l,q,z);return this};a.Path.prototype.rCubicTo=function(e,h,l,q,z,D){this._rCubicTo(e,h,l,q,z,D);return this};a.Path.prototype.rLineTo=function(e,h){this._rLineTo(e,h);return this};a.Path.prototype.rMoveTo=function(e,h){this._rMoveTo(e,h);return this};a.Path.prototype.rQuadTo=function(e,h,l,q){this._rQuadTo(e,h,l,q);return this};a.Path.prototype.stroke=function(e){e=e||{};e.width=e.width||1;e.miter_limit=e.miter_limit||4;e.cap=e.cap||a.StrokeCap.Butt;e.join=e.join||a.StrokeJoin.Miter;e.precision= e.precision||1;return this._stroke(e)?this:null};a.Path.prototype.transform=function(){if(1===arguments.length){var e=arguments[0];this._transform(e[0],e[1],e[2],e[3],e[4],e[5],e[6]||0,e[7]||0,e[8]||1)}else if(6===arguments.length||9===arguments.length)e=arguments,this._transform(e[0],e[1],e[2],e[3],e[4],e[5],e[6]||0,e[7]||0,e[8]||1);else throw"transform expected to take 1 or 9 arguments. Got "+arguments.length;return this};a.Path.prototype.trim=function(e,h,l){return this._trim(e,h,!!l)?this:null}; a.Image.prototype.makeShaderCubic=function(e,h,l,q,z){z=L(z);return this._makeShaderCubic(e,h,l,q,z)};a.Image.prototype.makeShaderOptions=function(e,h,l,q,z){z=L(z);return this._makeShaderOptions(e,h,l,q,z)};a.Image.prototype.readPixels=function(e,h,l,q,z){return d(this,e,h,l,q,z)};a.Canvas.prototype.clear=function(e){e=M(e);this._clear(e)};a.Canvas.prototype.clipRRect=function(e,h,l){e=oa(e);this._clipRRect(e,h,l)};a.Canvas.prototype.clipRect=function(e,h,l){e=aa(e);this._clipRect(e,h,l)};a.Canvas.prototype.concat= function(e){e=P(e);this._concat(e)};a.Canvas.prototype.drawArc=function(e,h,l,q,z){e=aa(e);this._drawArc(e,h,l,q,z)};a.Canvas.prototype.drawAtlas=function(e,h,l,q,z,D){if(e&&q&&h&&l&&h.length===l.length){z||(z=a.BlendMode.SrcOver);var J;h.build?J=h.build():J=w(h,"HEAPF32");if(l.build){var N=l.build();var Q=l.length}else N=w(l,"HEAPF32"),Q=l.length/4;var S=T;D&&(D.build?S=D.build():S=w(m(D),"HEAPU32"));this._drawAtlas(e,N,J,S,Q,z,q);J&&!h.build&&y(J,h);N&&!l.build&&y(N,l);S&&!D.build&&y(S,D)}};a.Canvas.prototype.drawColor= function(e,h){e=M(e);void 0!==h?this._drawColor(e,h):this._drawColor(e)};a.Canvas.prototype.drawColorComponents=function(e,h,l,q,z){e=Y(e,h,l,q);void 0!==z?this._drawColor(e,z):this._drawColor(e)};a.Canvas.prototype.drawDRRect=function(e,h,l){e=oa(e,hc);h=oa(h,Xc);this._drawDRRect(e,h,l)};a.Canvas.prototype.drawImageNine=function(e,h,l,q,z){h=w(h,"HEAP32",kc);l=aa(l);this._drawImageNine(e,h,l,q,z||null)};a.Canvas.prototype.drawImageRect=function(e,h,l,q,z){aa(h,ia);aa(l,Sa);this._drawImageRect(e, ia,Sa,q,!!z)};a.Canvas.prototype.drawImageRectCubic=function(e,h,l,q,z,D){aa(h,ia);aa(l,Sa);this._drawImageRectCubic(e,ia,Sa,q,z,D||null)};a.Canvas.prototype.drawImageRectOptions=function(e,h,l,q,z,D){aa(h,ia);aa(l,Sa);this._drawImageRectOptions(e,ia,Sa,q,z,D||null)};a.Canvas.prototype.drawOval=function(e,h){e=aa(e);this._drawOval(e,h)};a.Canvas.prototype.drawPoints=function(e,h,l){var q=w(h,"HEAPF32");this._drawPoints(e,q,h.length/2,l);y(q,h)};a.Canvas.prototype.drawRRect=function(e,h){e=oa(e);this._drawRRect(e, h)};a.Canvas.prototype.drawRect=function(e,h){e=aa(e);this._drawRect(e,h)};a.Canvas.prototype.drawShadow=function(e,h,l,q,z,D,J){var N=w(z,"HEAPF32"),Q=w(D,"HEAPF32");h=w(h,"HEAPF32",ic);l=w(l,"HEAPF32",jc);this._drawShadow(e,h,l,q,N,Q,J);y(N,z);y(Q,D)};a.getShadowLocalBounds=function(e,h,l,q,z,D,J){e=L(e);l=w(l,"HEAPF32",ic);q=w(q,"HEAPF32",jc);if(!this._getShadowLocalBounds(e,h,l,q,z,D,ia))return null;h=ya.toTypedArray();return J?(J.set(h),J):h.slice()};a.Canvas.prototype.getLocalToDevice=function(){this._getLocalToDevice(Ka); return A(Ka)};a.Canvas.prototype.findMarkedCTM=function(e){return this._findMarkedCTM(e,Ka)?A(Ka):null};a.Canvas.prototype.getTotalMatrix=function(){this._getTotalMatrix(Ja);for(var e=Array(9),h=0;9>h;h++)e[h]=a.HEAPF32[Ja/4+h];return e};a.Canvas.prototype.readPixels=function(e,h,l,q,z){return d(this,e,h,l,q,z)};a.Canvas.prototype.saveLayer=function(e,h,l,q){h=aa(h);return this._saveLayer(e||null,h,l||null,q||0)};a.Canvas.prototype.writePixels=function(e,h,l,q,z,D,J,N){if(e.byteLength%(h*l))throw"pixels length must be a multiple of the srcWidth * srcHeight"; var Q=e.byteLength/(h*l);D=D||a.AlphaType.Unpremul;J=J||a.ColorType.RGBA_8888;N=N||a.ColorSpace.SRGB;var S=Q*h;Q=w(e,"HEAPU8");h=this._writePixels({width:h,height:l,colorType:J,alphaType:D,colorSpace:N},Q,S,q,z);y(Q,e);return h};a.ColorFilter.MakeBlend=function(e,h){e=M(e);return a.ColorFilter._MakeBlend(e,h)};a.ColorFilter.MakeMatrix=function(e){if(!e||20!==e.length)throw"invalid color matrix";var h=w(e,"HEAPF32"),l=a.ColorFilter._makeMatrix(h);y(h,e);return l};a.ContourMeasure.prototype.getPosTan= function(e,h){this._getPosTan(e,ia);e=ya.toTypedArray();return h?(h.set(e),h):e.slice()};a.ImageFilter.MakeMatrixTransform=function(e,h,l){e=L(e);return a.ImageFilter._MakeMatrixTransform(e,h,l)};a.Paint.prototype.getColor=function(){this._getColor(hb);return da(hb)};a.Paint.prototype.setColor=function(e,h){h=h||null;e=M(e);this._setColor(e,h)};a.Paint.prototype.setColorComponents=function(e,h,l,q,z){z=z||null;e=Y(e,h,l,q);this._setColor(e,z)};a.Path.prototype.getPoint=function(e,h){this._getPoint(e, ia);e=ya.toTypedArray();return h?(h[0]=e[0],h[1]=e[1],h):e.slice(0,2)};a.PictureRecorder.prototype.beginRecording=function(e){e=aa(e);return this._beginRecording(e)};a.Surface.prototype.makeImageSnapshot=function(e){e=w(e,"HEAP32",kc);return this._makeImageSnapshot(e)};a.Surface.prototype.requestAnimationFrame=function(e,h){this.Ie||(this.Ie=this.getCanvas());requestAnimationFrame(function(){void 0!==this.le&&a.setCurrentContext(this.le);e(this.Ie);this.flush(h)}.bind(this))};a.Surface.prototype.drawOnce= function(e,h){this.Ie||(this.Ie=this.getCanvas());requestAnimationFrame(function(){void 0!==this.le&&a.setCurrentContext(this.le);e(this.Ie);this.flush(h);this.dispose()}.bind(this))};a.PathEffect.MakeDash=function(e,h){h||(h=0);if(!e.length||1===e.length%2)throw"Intervals array must have even length";var l=w(e,"HEAPF32");h=a.PathEffect._MakeDash(l,e.length,h);y(l,e);return h};a.Shader.MakeColor=function(e,h){h=h||null;e=M(e);return a.Shader._MakeColor(e,h)};a.Shader.Blend=a.Shader.MakeBlend;a.Shader.Color= a.Shader.MakeColor;a.Shader.Lerp=a.Shader.MakeLerp;a.Shader.MakeLinearGradient=function(e,h,l,q,z,D,J,N){N=N||null;var Q=H(l),S=w(q,"HEAPF32");J=J||0;D=L(D);var v=ya.toTypedArray();v.set(e);v.set(h,2);e=a.Shader._MakeLinearGradient(ia,Q.ae,Q.Ne,S,Q.count,z,J,D,N);y(Q.ae,l);q&&y(S,q);return e};a.Shader.MakeRadialGradient=function(e,h,l,q,z,D,J,N){N=N||null;var Q=H(l),S=w(q,"HEAPF32");J=J||0;D=L(D);e=a.Shader._MakeRadialGradient(e[0],e[1],h,Q.ae,Q.Ne,S,Q.count,z,J,D,N);y(Q.ae,l);q&&y(S,q);return e}; a.Shader.MakeSweepGradient=function(e,h,l,q,z,D,J,N,Q,S){S=S||null;var v=H(l),I=w(q,"HEAPF32");J=J||0;N=N||0;Q=Q||360;D=L(D);e=a.Shader._MakeSweepGradient(e,h,v.ae,v.Ne,I,v.count,z,N,Q,J,D,S);y(v.ae,l);q&&y(I,q);return e};a.Shader.MakeTwoPointConicalGradient=function(e,h,l,q,z,D,J,N,Q,S){S=S||null;var v=H(z),I=w(D,"HEAPF32");Q=Q||0;N=L(N);var R=ya.toTypedArray();R.set(e);R.set(l,2);e=a.Shader._MakeTwoPointConicalGradient(ia,h,q,v.ae,v.Ne,I,v.count,J,Q,N,S);y(v.ae,z);D&&y(I,D);return e};a.Vertices.prototype.bounds= function(e){this._bounds(ia);var h=ya.toTypedArray();return e?(e.set(h),e):h.slice()};a.Ud&&a.Ud.forEach(function(e){e()})};a.computeTonalColors=function(d){var e=w(d.ambient,"HEAPF32"),h=w(d.spot,"HEAPF32");this._computeTonalColors(e,h);var l={ambient:da(e),spot:da(h)};y(e,d.ambient);y(h,d.spot);return l};a.LTRBRect=function(d,e,h,l){return Float32Array.of(d,e,h,l)};a.XYWHRect=function(d,e,h,l){return Float32Array.of(d,e,d+h,e+l)};a.LTRBiRect=function(d,e,h,l){return Int32Array.of(d,e,h,l)};a.XYWHiRect= function(d,e,h,l){return Int32Array.of(d,e,d+h,e+l)};a.RRectXY=function(d,e,h){return Float32Array.of(d[0],d[1],d[2],d[3],e,h,e,h,e,h,e,h)};a.MakeAnimatedImageFromEncoded=function(d){d=new Uint8Array(d);var e=a._malloc(d.byteLength);a.HEAPU8.set(d,e);return(d=a._decodeAnimatedImage(e,d.byteLength))?d:null};a.MakeImageFromEncoded=function(d){d=new Uint8Array(d);var e=a._malloc(d.byteLength);a.HEAPU8.set(d,e);return(d=a._decodeImage(e,d.byteLength))?d:null};var jb=null;a.MakeImageFromCanvasImageSource= function(d){var e=d.width,h=d.height;jb||(jb=document.createElement("canvas"));jb.width=e;jb.height=h;var l=jb.getContext("2d");l.drawImage(d,0,0);d=l.getImageData(0,0,e,h);return a.MakeImage({width:e,height:h,alphaType:a.AlphaType.Unpremul,colorType:a.ColorType.RGBA_8888,colorSpace:a.ColorSpace.SRGB},d.data,4*e)};a.MakeImage=function(d,e,h){var l=a._malloc(e.length);a.HEAPU8.set(e,l);return a._MakeImage(d,l,e.length,h)};a.MakeVertices=function(d,e,h,l,q,z){var D=q&&q.length||0,J=0;h&&h.length&&(J|= 1);l&&l.length&&(J|=2);void 0===z||z||(J|=4);d=new a._VerticesBuilder(d,e.length/2,D,J);w(e,"HEAPF32",d.positions());d.texCoords()&&w(h,"HEAPF32",d.texCoords());if(d.colors()){if(l.build)throw"Color builder not accepted by MakeVertices, use array of ints";w(m(l),"HEAPU32",d.colors())}d.indices()&&w(q,"HEAPU16",d.indices());return d.detach()};a.Matrix={};a.Matrix.identity=function(){return c(3)};a.Matrix.invert=function(d){var e=d[0]*d[4]*d[8]+d[1]*d[5]*d[6]+d[2]*d[3]*d[7]-d[2]*d[4]*d[6]-d[1]*d[3]* d[8]-d[0]*d[5]*d[7];return e?[(d[4]*d[8]-d[5]*d[7])/e,(d[2]*d[7]-d[1]*d[8])/e,(d[1]*d[5]-d[2]*d[4])/e,(d[5]*d[6]-d[3]*d[8])/e,(d[0]*d[8]-d[2]*d[6])/e,(d[2]*d[3]-d[0]*d[5])/e,(d[3]*d[7]-d[4]*d[6])/e,(d[1]*d[6]-d[0]*d[7])/e,(d[0]*d[4]-d[1]*d[3])/e]:null};a.Matrix.mapPoints=function(d,e){for(var h=0;h<e.length;h+=2){var l=e[h],q=e[h+1],z=d[6]*l+d[7]*q+d[8],D=d[3]*l+d[4]*q+d[5];e[h]=(d[0]*l+d[1]*q+d[2])/z;e[h+1]=D/z}return e};a.Matrix.multiply=function(){return Qc(3,arguments)};a.Matrix.rotated=function(d, e,h){e=e||0;h=h||0;var l=Math.sin(d);d=Math.cos(d);return[d,-l,ib(l,h,1-d,e),l,d,ib(-l,e,1-d,h),0,0,1]};a.Matrix.scaled=function(d,e,h,l){h=h||0;l=l||0;var q=b([d,e],c(3),3,0,1);return b([h-d*h,l-e*l],q,3,2,0)};a.Matrix.skewed=function(d,e,h,l){h=h||0;l=l||0;var q=b([d,e],c(3),3,1,-1);return b([-d*h,-e*l],q,3,2,0)};a.Matrix.translated=function(d,e){return b(arguments,c(3),3,2,0)};a.Vector={};a.Vector.dot=function(d,e){return d.map(function(h,l){return h*e[l]}).reduce(function(h,l){return h+l})};a.Vector.lengthSquared= function(d){return a.Vector.dot(d,d)};a.Vector.length=function(d){return Math.sqrt(a.Vector.lengthSquared(d))};a.Vector.mulScalar=function(d,e){return d.map(function(h){return h*e})};a.Vector.add=function(d,e){return d.map(function(h,l){return h+e[l]})};a.Vector.sub=function(d,e){return d.map(function(h,l){return h-e[l]})};a.Vector.dist=function(d,e){return a.Vector.length(a.Vector.sub(d,e))};a.Vector.normalize=function(d){return a.Vector.mulScalar(d,1/a.Vector.length(d))};a.Vector.cross=function(d, e){return[d[1]*e[2]-d[2]*e[1],d[2]*e[0]-d[0]*e[2],d[0]*e[1]-d[1]*e[0]]};a.M44={};a.M44.identity=function(){return c(4)};a.M44.translated=function(d){return b(d,c(4),4,3,0)};a.M44.scaled=function(d){return b(d,c(4),4,0,1)};a.M44.rotated=function(d,e){return a.M44.rotatedUnitSinCos(a.Vector.normalize(d),Math.sin(e),Math.cos(e))};a.M44.rotatedUnitSinCos=function(d,e,h){var l=d[0],q=d[1];d=d[2];var z=1-h;return[z*l*l+h,z*l*q-e*d,z*l*d+e*q,0,z*l*q+e*d,z*q*q+h,z*q*d-e*l,0,z*l*d-e*q,z*q*d+e*l,z*d*d+h,0, 0,0,0,1]};a.M44.lookat=function(d,e,h){e=a.Vector.normalize(a.Vector.sub(e,d));h=a.Vector.normalize(h);h=a.Vector.normalize(a.Vector.cross(e,h));var l=a.M44.identity();b(h,l,4,0,0);b(a.Vector.cross(h,e),l,4,1,0);b(a.Vector.mulScalar(e,-1),l,4,2,0);b(d,l,4,3,0);d=a.M44.invert(l);return null===d?a.M44.identity():d};a.M44.perspective=function(d,e,h){var l=1/(e-d);h/=2;h=Math.cos(h)/Math.sin(h);return[h,0,0,0,0,h,0,0,0,0,(e+d)*l,2*e*d*l,0,0,-1,1]};a.M44.rc=function(d,e,h){return d[4*e+h]};a.M44.multiply= function(){return Qc(4,arguments)};a.M44.invert=function(d){var e=d[0],h=d[4],l=d[8],q=d[12],z=d[1],D=d[5],J=d[9],N=d[13],Q=d[2],S=d[6],v=d[10],I=d[14],R=d[3],ba=d[7],qa=d[11];d=d[15];var va=e*D-h*z,wa=e*J-l*z,ka=e*N-q*z,F=h*J-l*D,k=h*N-q*D,n=l*N-q*J,x=Q*ba-S*R,B=Q*qa-v*R,C=Q*d-I*R,E=S*qa-v*ba,K=S*d-I*ba,Z=v*d-I*qa,pa=va*Z-wa*K+ka*E+F*C-k*B+n*x,fa=1/pa;if(0===pa||Infinity===fa)return null;va*=fa;wa*=fa;ka*=fa;F*=fa;k*=fa;n*=fa;x*=fa;B*=fa;C*=fa;E*=fa;K*=fa;Z*=fa;e=[D*Z-J*K+N*E,J*C-z*Z-N*B,z*K-D*C+ N*x,D*B-z*E-J*x,l*K-h*Z-q*E,e*Z-l*C+q*B,h*C-e*K-q*x,e*E-h*B+l*x,ba*n-qa*k+d*F,qa*ka-R*n-d*wa,R*k-ba*ka+d*va,ba*wa-R*F-qa*va,v*k-S*n-I*F,Q*n-v*ka+I*wa,S*ka-Q*k-I*va,Q*F-S*wa+v*va];return e.every(function(Ea){return!isNaN(Ea)&&Infinity!==Ea&&-Infinity!==Ea})?e:null};a.M44.transpose=function(d){return[d[0],d[4],d[8],d[12],d[1],d[5],d[9],d[13],d[2],d[6],d[10],d[14],d[3],d[7],d[11],d[15]]};a.M44.mustInvert=function(d){d=a.M44.invert(d);if(null===d)throw"Matrix not invertible";return d};a.M44.setupCamera= function(d,e,h){var l=a.M44.lookat(h.eye,h.coa,h.up);h=a.M44.perspective(h.near,h.far,h.angle);e=[(d[2]-d[0])/2,(d[3]-d[1])/2,e];d=a.M44.multiply(a.M44.translated([(d[0]+d[2])/2,(d[1]+d[3])/2,0]),a.M44.scaled(e));return a.M44.multiply(d,h,l,a.M44.mustInvert(d))};a.ColorMatrix={};a.ColorMatrix.identity=function(){var d=new Float32Array(20);d[0]=1;d[6]=1;d[12]=1;d[18]=1;return d};a.ColorMatrix.scaled=function(d,e,h,l){var q=new Float32Array(20);q[0]=d;q[6]=e;q[12]=h;q[18]=l;return q};var Jd=[[6,7,11, 12],[0,10,2,12],[0,1,5,6]];a.ColorMatrix.rotated=function(d,e,h){var l=a.ColorMatrix.identity();d=Jd[d];l[d[0]]=h;l[d[1]]=e;l[d[2]]=-e;l[d[3]]=h;return l};a.ColorMatrix.postTranslate=function(d,e,h,l,q){d[4]+=e;d[9]+=h;d[14]+=l;d[19]+=q;return d};a.ColorMatrix.concat=function(d,e){for(var h=new Float32Array(20),l=0,q=0;20>q;q+=5){for(var z=0;4>z;z++)h[l++]=d[q]*e[z]+d[q+1]*e[z+5]+d[q+2]*e[z+10]+d[q+3]*e[z+15];h[l++]=d[q]*e[4]+d[q+1]*e[9]+d[q+2]*e[14]+d[q+3]*e[19]+d[q+4]}return h};(function(d){d.Ud= d.Ud||[];d.Ud.push(function(){function e(v){if(!v||!v.length)return[];for(var I=[],R=0;R<v.length;R+=5){var ba=d.LTRBRect(v[R],v[R+1],v[R+2],v[R+3]);ba.direction=0===v[R+4]?d.TextDirection.RTL:d.TextDirection.LTR;I.push(ba)}d._free(v.byteOffset);return I}function h(v){v=v||{};void 0===v.weight&&(v.weight=d.FontWeight.Normal);v.width=v.width||d.FontWidth.Normal;v.slant=v.slant||d.FontSlant.Upright;return v}function l(v){if(!v||!v.length)return T;for(var I=[],R=0;R<v.length;R++){var ba=q(v[R]);I.push(ba)}return w(I, "HEAPU32")}function q(v){if(J[v])return J[v];var I=na(v)+1,R=d._malloc(I);ra(v,G,R,I);return J[v]=R}function z(v){v._colorPtr=M(v.color);v._foregroundColorPtr=T;v._backgroundColorPtr=T;v._decorationColorPtr=T;v.foregroundColor&&(v._foregroundColorPtr=M(v.foregroundColor,N));v.backgroundColor&&(v._backgroundColorPtr=M(v.backgroundColor,Q));v.decorationColor&&(v._decorationColorPtr=M(v.decorationColor,S));Array.isArray(v.fontFamilies)&&v.fontFamilies.length?(v._fontFamiliesPtr=l(v.fontFamilies),v._fontFamiliesLen= v.fontFamilies.length):(v._fontFamiliesPtr=T,v._fontFamiliesLen=0)}function D(v){d._free(v._fontFamiliesPtr)}d.Paragraph.prototype.getRectsForRange=function(v,I,R,ba){v=this._getRectsForRange(v,I,R,ba);return e(v)};d.Paragraph.prototype.getRectsForPlaceholders=function(){var v=this._getRectsForPlaceholders();return e(v)};d.TypefaceFontProvider.prototype.registerFont=function(v,I){v=d.FontMgr.RefDefault().MakeTypefaceFromData(v);if(!v)return null;I=q(I);this._registerFont(v,I)};d.ParagraphStyle=function(v){v.disableHinting= v.disableHinting||!1;if(v.ellipsis){var I=v.ellipsis;v._ellipsisPtr=q(I);v._ellipsisLen=na(I)+1}else v._ellipsisPtr=T,v._ellipsisLen=0;v.heightMultiplier=v.heightMultiplier||0;v.maxLines=v.maxLines||0;v.textAlign=v.textAlign||d.TextAlign.Start;v.textDirection=v.textDirection||d.TextDirection.LTR;v.textStyle=d.TextStyle(v.textStyle);I=(I=v.strutStyle)||{};I.strutEnabled=I.strutEnabled||!1;I.strutEnabled&&Array.isArray(I.fontFamilies)&&I.fontFamilies.length?(I._fontFamiliesPtr=l(I.fontFamilies),I._fontFamiliesLen= I.fontFamilies.length):(I._fontFamiliesPtr=T,I._fontFamiliesLen=0);I.fontStyle=h(I.fontStyle);I.fontSize=I.fontSize||0;I.heightMultiplier=I.heightMultiplier||0;I.leading=I.leading||0;I.forceStrutHeight=I.forceStrutHeight||!1;v.strutStyle=I;return v};d.TextStyle=function(v){v.color||(v.color=d.BLACK);v.decoration=v.decoration||0;v.decorationThickness=v.decorationThickness||0;v.decorationStyle=v.decorationStyle||d.DecorationStyle.Solid;v.textBaseline=v.textBaseline||d.TextBaseline.Alphabetic;v.fontSize= v.fontSize||0;v.letterSpacing=v.letterSpacing||0;v.wordSpacing=v.wordSpacing||0;v.heightMultiplier=v.heightMultiplier||0;if(v.locale){var I=v.locale;v._localePtr=q(I);v._localeLen=na(I)+1}else v._localePtr=T,v._localeLen=0;v.fontStyle=h(v.fontStyle);if(v.shadows){I=v.shadows;var R=I.map(function(F){return F.color||d.BLACK}),ba=I.map(function(F){return F.blurRadius||0});v._shadowLen=I.length;for(var qa=d._malloc(2*I.length,"HEAPF32"),va=qa/4,wa=0;wa<I.length;wa++){var ka=I[wa].offset||[0,0];d.HEAPF32[va]= ka[0];d.HEAPF32[va+1]=ka[1];va+=2}v._shadowColorsPtr=H(R).ae;v._shadowOffsetsPtr=qa;v._shadowBlurRadiiPtr=w(ba,"HEAPF32")}else v._shadowLen=0,v._shadowColorsPtr=T,v._shadowOffsetsPtr=T,v._shadowBlurRadiiPtr=T;v.fontFeatures?(I=v.fontFeatures,R=I.map(function(F){return F.name}),ba=I.map(function(F){return F.value}),v._fontFeatureLen=I.length,v._fontFeatureNamesPtr=l(R),v._fontFeatureValuesPtr=w(ba,"HEAPU32")):(v._fontFeatureLen=0,v._fontFeatureNamesPtr=T,v._fontFeatureValuesPtr=T);return v};var J= {},N=d._malloc(16),Q=d._malloc(16),S=d._malloc(16);d.ParagraphBuilder.Make=function(v,I){z(v.textStyle);I=d.ParagraphBuilder._Make(v,I);D(v.textStyle);return I};d.ParagraphBuilder.MakeFromFontProvider=function(v,I){z(v.textStyle);I=d.ParagraphBuilder._MakeFromFontProvider(v,I);D(v.textStyle);return I};d.ParagraphBuilder.prototype.pushStyle=function(v){z(v);this._pushStyle(v);D(v)};d.ParagraphBuilder.prototype.pushPaintStyle=function(v,I,R){z(v);this._pushPaintStyle(v,I,R);D(v)};d.ParagraphBuilder.prototype.addPlaceholder= function(v,I,R,ba,qa){R=R||d.PlaceholderAlignment.Baseline;ba=ba||d.TextBaseline.Alphabetic;this._addPlaceholder(v||0,I||0,R,ba,qa||0)}})})(r);a.Ud=a.Ud||[];a.Ud.push(function(){a.Path.prototype.op=function(d,e){return this._op(d,e)?this:null};a.Path.prototype.simplify=function(){return this._simplify()?this:null}});a.Ud=a.Ud||[];a.Ud.push(function(){a.Canvas.prototype.drawText=function(d,e,h,l,q){if("string"===typeof d){var z=na(d),D=a._malloc(z+1);ra(d,G,D,z+1);this._drawSimpleText(D,z,e,h,q,l); a._free(D)}else this._drawShapedText(d,e,h,l)};a.Font.prototype.getGlyphBounds=function(d,e,h){var l=w(d,"HEAPU16"),q=a._malloc(16*d.length);this._getGlyphWidthBounds(l,d.length,T,q,e||null);e=new Float32Array(a.HEAPU8.buffer,q,4*d.length);y(l,d);if(h)return h.set(e),a._free(q),h;d=Float32Array.from(e);a._free(q);return d};a.Font.prototype.getGlyphIDs=function(d,e,h){e||(e=d.length);var l=na(d)+1,q=a._malloc(l);ra(d,G,q,l);d=a._malloc(2*e);e=this._getGlyphIDs(q,l-1,e,d);a._free(q);if(0>e)return a._free(d), null;q=new Uint16Array(a.HEAPU8.buffer,d,e);if(h)return h.set(q),a._free(d),h;h=Uint32Array.from(q);a._free(d);return h};a.Font.prototype.getGlyphWidths=function(d,e,h){var l=w(d,"HEAPU16"),q=a._malloc(4*d.length);this._getGlyphWidthBounds(l,d.length,q,T,e||null);e=new Float32Array(a.HEAPU8.buffer,q,d.length);y(l,d);if(h)return h.set(e),a._free(q),h;d=Float32Array.from(e);a._free(q);return d};a.Font.prototype.getWidths=function(d){var e=d.length+1,h=na(d)+1,l=a._malloc(h);ra(d,G,l,h);d=a._malloc(4* e);if(!this._getWidths(l,h,e,d))return a._free(l),a._free(d),null;e=new Float32Array(a.HEAPU8.buffer,d,e);e=Array.from(e);a._free(l);a._free(d);return e};a.FontMgr.FromData=function(){if(!arguments.length)return null;var d=arguments;1===d.length&&Array.isArray(d[0])&&(d=arguments[0]);if(!d.length)return null;for(var e=[],h=[],l=0;l<d.length;l++){var q=new Uint8Array(d[l]),z=w(q,"HEAPU8");e.push(z);h.push(q.byteLength)}e=w(e,"HEAPU32");h=w(h,"HEAPU32");d=a.FontMgr._fromData(e,h,d.length);a._free(e); a._free(h);return d};a.FontMgr.prototype.MakeTypefaceFromData=function(d){d=new Uint8Array(d);var e=w(d,"HEAPU8");return(d=this._makeTypefaceFromData(e,d.byteLength))?d:null};a.ShapedText.prototype.getBounds=function(d){this._getBounds(ia);var e=ya.toTypedArray();return d?(d.set(e),d):e.slice()};a.TextBlob.MakeOnPath=function(d,e,h,l){if(d&&d.length&&e&&e.countPoints()){if(1===e.countPoints())return this.MakeFromText(d,h);l||(l=0);var q=h.getWidths(d),z=new a.RSXFormBuilder;e=new a.ContourMeasureIter(e, !1,1);for(var D=e.next(),J=new Float32Array(4),N=0;N<d.length&&D;N++){var Q=q[N];l+=Q/2;if(l>D.length()){D.delete();D=e.next();if(!D){d=d.substring(0,N);break}l=Q/2}D.getPosTan(l,J);var S=J[2],v=J[3];z.push(S,v,J[0]-Q/2*S,J[1]-Q/2*v);l+=Q/2}d=this.MakeFromRSXform(d,z,h);z.delete();D&&D.delete();e.delete();return d}};a.TextBlob.MakeFromRSXform=function(d,e,h){var l=na(d)+1,q=a._malloc(l);ra(d,G,q,l);d=T;e.build?d=e.build():d=w(e,"HEAPF32");e=a.TextBlob._MakeFromRSXform(q,l-1,d,h);a._free(q);return e? e:null};a.TextBlob.MakeFromRSXformGlyphs=function(d,e,h){var l=w(d,"HEAPU16"),q=T;e.build?q=e.build():q=w(e,"HEAPF32");e=a.TextBlob._MakeFromRSXformGlyphs(l,2*d.length,q,h);y(l,d);return e?e:null};a.TextBlob.MakeFromGlyphs=function(d,e){var h=w(d,"HEAPU16");e=a.TextBlob._MakeFromGlyphs(h,2*d.length,e);y(h,d);return e?e:null};a.TextBlob.MakeFromText=function(d,e){var h=na(d)+1,l=a._malloc(h);ra(d,G,l,h);d=a.TextBlob._MakeFromText(l,h-1,e);a._free(l);return d?d:null};a.MallocGlyphIDs=function(d){return a.Malloc(Uint16Array, d)}});a.Ud=a.Ud||[];a.Ud.push(function(){a.MakePicture=function(d){d=new Uint8Array(d);var e=a._malloc(d.byteLength);a.HEAPU8.set(d,e);return(d=a._MakePicture(e,d.byteLength))?d:null};a.Picture.prototype.saveAsFile=function(d){var e=this.serialize();e&&Cb(e,d)}});(function(){function d(F){for(var k=0;k<F.length;k++)if(void 0!==F[k]&&!Number.isFinite(F[k]))return!1;return!0}function e(F){var k=a.getColorComponents(F);F=k[0];var n=k[1],x=k[2];k=k[3];if(1===k)return F=F.toString(16).toLowerCase(),n= n.toString(16).toLowerCase(),x=x.toString(16).toLowerCase(),F=1===F.length?"0"+F:F,n=1===n.length?"0"+n:n,x=1===x.length?"0"+x:x,"#"+F+n+x;k=0===k||1===k?k:k.toFixed(8);return"rgba("+F+", "+n+", "+x+", "+k+")"}function h(F){return a.parseColorString(F,va)}function l(F){F=wa.exec(F);if(!F)return null;var k=parseFloat(F[4]),n=16;switch(F[5]){case "em":case "rem":n=16*k;break;case "pt":n=4*k/3;break;case "px":n=k;break;case "pc":n=16*k;break;case "in":n=96*k;break;case "cm":n=96*k/2.54;break;case "mm":n= 96/25.4*k;break;case "q":n=96/25.4/4*k;break;case "%":n=16/75*k}return{style:F[1],variant:F[2],weight:F[3],sizePx:n,family:F[6].trim()}}function q(F){this.Ld=F;this.Nd=new a.Paint;this.Nd.setAntiAlias(!0);this.Nd.setStrokeMiter(10);this.Nd.setStrokeCap(a.StrokeCap.Butt);this.Nd.setStrokeJoin(a.StrokeJoin.Miter);this.Ue="10px monospace";this.re=new a.Font(null,10);this.re.setSubpixel(!0);this.$d=this.fe=a.BLACK;this.ue=0;this.Ke=a.TRANSPARENT;this.we=this.ve=0;this.Le=this.he=1;this.Je=0;this.te=[]; this.Md=a.BlendMode.SrcOver;this.Nd.setStrokeWidth(this.Le);this.Nd.setBlendMode(this.Md);this.Qd=new a.Path;this.Rd=a.Matrix.identity();this.mf=[];this.Ae=[];this.je=function(){this.Qd.delete();this.Nd.delete();this.re.delete();this.Ae.forEach(function(k){k.je()})};Object.defineProperty(this,"currentTransform",{enumerable:!0,get:function(){return{a:this.Rd[0],c:this.Rd[1],e:this.Rd[2],b:this.Rd[3],d:this.Rd[4],f:this.Rd[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.$d)?e(this.$d):this.$d},set:function(k){"string"===typeof k?this.$d=h(k):k.se&&(this.$d=k)}});Object.defineProperty(this,"font",{enumerable:!0,get:function(){return this.Ue},set:function(k){var n=l(k),x=n.family;n.typeface=ka[x]?ka[x][(n.style||"normal")+"|"+(n.variant||"normal")+"|"+(n.weight||"normal")]||ka[x]["*"]:null;n&&(this.re.setSize(n.sizePx),this.re.setTypeface(n.typeface),this.Ue=k)}});Object.defineProperty(this,"globalAlpha",{enumerable:!0, get:function(){return this.he},set:function(k){!isFinite(k)||0>k||1<k||(this.he=k)}});Object.defineProperty(this,"globalCompositeOperation",{enumerable:!0,get:function(){switch(this.Md){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.Md=a.BlendMode.SrcOver;break;case "destination-over":this.Md=a.BlendMode.DstOver;break;case "copy":this.Md= a.BlendMode.Src;break;case "destination":this.Md=a.BlendMode.Dst;break;case "clear":this.Md=a.BlendMode.Clear;break;case "source-in":this.Md=a.BlendMode.SrcIn;break;case "destination-in":this.Md=a.BlendMode.DstIn;break;case "source-out":this.Md=a.BlendMode.SrcOut;break;case "destination-out":this.Md=a.BlendMode.DstOut;break;case "source-atop":this.Md=a.BlendMode.SrcATop;break;case "destination-atop":this.Md=a.BlendMode.DstATop;break;case "xor":this.Md=a.BlendMode.Xor;break;case "lighter":this.Md= a.BlendMode.Plus;break;case "plus-lighter":this.Md=a.BlendMode.Plus;break;case "plus-darker":throw"plus-darker is not supported";case "multiply":this.Md=a.BlendMode.Multiply;break;case "screen":this.Md=a.BlendMode.Screen;break;case "overlay":this.Md=a.BlendMode.Overlay;break;case "darken":this.Md=a.BlendMode.Darken;break;case "lighten":this.Md=a.BlendMode.Lighten;break;case "color-dodge":this.Md=a.BlendMode.ColorDodge;break;case "color-burn":this.Md=a.BlendMode.ColorBurn;break;case "hard-light":this.Md= a.BlendMode.HardLight;break;case "soft-light":this.Md=a.BlendMode.SoftLight;break;case "difference":this.Md=a.BlendMode.Difference;break;case "exclusion":this.Md=a.BlendMode.Exclusion;break;case "hue":this.Md=a.BlendMode.Hue;break;case "saturation":this.Md=a.BlendMode.Saturation;break;case "color":this.Md=a.BlendMode.Color;break;case "luminosity":this.Md=a.BlendMode.Luminosity;break;default:return}this.Nd.setBlendMode(this.Md)}});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.Nd.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.Nd.setStrokeCap(a.StrokeCap.Butt);break;case "round":this.Nd.setStrokeCap(a.StrokeCap.Round);break;case "square":this.Nd.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.Nd.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.Nd.setStrokeJoin(a.StrokeJoin.Miter);break;case "round":this.Nd.setStrokeJoin(a.StrokeJoin.Round);break;case "bevel":this.Nd.setStrokeJoin(a.StrokeJoin.Bevel)}}}); Object.defineProperty(this,"lineWidth",{enumerable:!0,get:function(){return this.Nd.getStrokeWidth()},set:function(k){0>=k||!k||(this.Le=k,this.Nd.setStrokeWidth(k))}});Object.defineProperty(this,"miterLimit",{enumerable:!0,get:function(){return this.Nd.getStrokeMiter()},set:function(k){0>=k||!k||this.Nd.setStrokeMiter(k)}});Object.defineProperty(this,"shadowBlur",{enumerable:!0,get:function(){return this.ue},set:function(k){0>k||!isFinite(k)||(this.ue=k)}});Object.defineProperty(this,"shadowColor", {enumerable:!0,get:function(){return e(this.Ke)},set:function(k){this.Ke=h(k)}});Object.defineProperty(this,"shadowOffsetX",{enumerable:!0,get:function(){return this.ve},set:function(k){isFinite(k)&&(this.ve=k)}});Object.defineProperty(this,"shadowOffsetY",{enumerable:!0,get:function(){return this.we},set:function(k){isFinite(k)&&(this.we=k)}});Object.defineProperty(this,"strokeStyle",{enumerable:!0,get:function(){return e(this.fe)},set:function(k){"string"===typeof k?this.fe=h(k):k.se&&(this.fe= k)}});this.arc=function(k,n,x,B,C,E){v(this.Qd,k,n,x,x,0,B,C,E)};this.arcTo=function(k,n,x,B,C){N(this.Qd,k,n,x,B,C)};this.beginPath=function(){this.Qd.delete();this.Qd=new a.Path};this.bezierCurveTo=function(k,n,x,B,C,E){var K=this.Qd;d([k,n,x,B,C,E])&&(K.isEmpty()&&K.moveTo(k,n),K.cubicTo(k,n,x,B,C,E))};this.clearRect=function(k,n,x,B){this.Nd.setStyle(a.PaintStyle.Fill);this.Nd.setBlendMode(a.BlendMode.Clear);this.Ld.drawRect(a.XYWHRect(k,n,x,B),this.Nd);this.Nd.setBlendMode(this.Md)};this.clip= function(k,n){"string"===typeof k?(n=k,k=this.Qd):k&&k.af&&(k=k.Td);k||(k=this.Qd);k=k.copy();n&&"evenodd"===n.toLowerCase()?k.setFillType(a.FillType.EvenOdd):k.setFillType(a.FillType.Winding);this.Ld.clipPath(k,a.ClipOp.Intersect,!0);k.delete()};this.closePath=function(){Q(this.Qd)};this.createImageData=function(){if(1===arguments.length){var k=arguments[0];return new D(new Uint8ClampedArray(4*k.width*k.height),k.width,k.height)}if(2===arguments.length){k=arguments[0];var n=arguments[1];return new D(new Uint8ClampedArray(4* k*n),k,n)}throw"createImageData expects 1 or 2 arguments, got "+arguments.length;};this.createLinearGradient=function(k,n,x,B){if(d(arguments)){var C=new J(k,n,x,B);this.Ae.push(C);return C}};this.createPattern=function(k,n){k=new ba(k,n);this.Ae.push(k);return k};this.createRadialGradient=function(k,n,x,B,C,E){if(d(arguments)){var K=new qa(k,n,x,B,C,E);this.Ae.push(K);return K}};this.drawImage=function(k){var n=this.Te();if(3===arguments.length||5===arguments.length)var x=a.XYWHRect(arguments[1], arguments[2],arguments[3]||k.width(),arguments[4]||k.height()),B=a.XYWHRect(0,0,k.width(),k.height());else if(9===arguments.length)x=a.XYWHRect(arguments[5],arguments[6],arguments[7],arguments[8]),B=a.XYWHRect(arguments[1],arguments[2],arguments[3],arguments[4]);else throw"invalid number of args for drawImage, need 3, 5, or 9; got "+arguments.length;this.Ld.drawImageRect(k,B,x,n,!1);n.dispose()};this.ellipse=function(k,n,x,B,C,E,K,Z){v(this.Qd,k,n,x,B,C,E,K,Z)};this.Te=function(){var k=this.Nd.copy(); k.setStyle(a.PaintStyle.Fill);if(f(this.$d)){var n=a.multiplyByAlpha(this.$d,this.he);k.setColor(n)}else n=this.$d.se(this.Rd),k.setColor(a.Color(0,0,0,this.he)),k.setShader(n);k.dispose=function(){this.delete()};return k};this.fill=function(k,n){"string"===typeof k?(n=k,k=this.Qd):k&&k.af&&(k=k.Td);if("evenodd"===n)this.Qd.setFillType(a.FillType.EvenOdd);else{if("nonzero"!==n&&n)throw"invalid fill rule";this.Qd.setFillType(a.FillType.Winding)}k||(k=this.Qd);n=this.Te();var x=this.xe(n);x&&(this.Ld.save(), this.pe(),this.Ld.drawPath(k,x),this.Ld.restore(),x.dispose());this.Ld.drawPath(k,n);n.dispose()};this.fillRect=function(k,n,x,B){var C=this.Te(),E=this.xe(C);E&&(this.Ld.save(),this.pe(),this.Ld.drawRect(a.XYWHRect(k,n,x,B),E),this.Ld.restore(),E.dispose());this.Ld.drawRect(a.XYWHRect(k,n,x,B),C);C.dispose()};this.fillText=function(k,n,x){var B=this.Te();k=a.TextBlob.MakeFromText(k,this.re);var C=this.xe(B);C&&(this.Ld.save(),this.pe(),this.Ld.drawTextBlob(k,n,x,C),this.Ld.restore(),C.dispose()); this.Ld.drawTextBlob(k,n,x,B);k.delete();B.dispose()};this.getImageData=function(k,n,x,B){return(k=this.Ld.readPixels(k,n,{width:x,height:B,colorType:a.ColorType.RGBA_8888,alphaType:a.AlphaType.Unpremul,colorSpace:a.ColorSpace.SRGB}))?new D(new Uint8ClampedArray(k.buffer),x,B):null};this.getLineDash=function(){return this.te.slice()};this.nf=function(k){var n=a.Matrix.invert(this.Rd);a.Matrix.mapPoints(n,k);return k};this.isPointInPath=function(k,n,x){var B=arguments;if(3===B.length)var C=this.Qd; else if(4===B.length)C=B[0],k=B[1],n=B[2],x=B[3];else throw"invalid arg count, need 3 or 4, got "+B.length;if(!isFinite(k)||!isFinite(n))return!1;x=x||"nonzero";if("nonzero"!==x&&"evenodd"!==x)return!1;B=this.nf([k,n]);k=B[0];n=B[1];C.setFillType("nonzero"===x?a.FillType.Winding:a.FillType.EvenOdd);return C.contains(k,n)};this.isPointInStroke=function(k,n){var x=arguments;if(2===x.length)var B=this.Qd;else if(3===x.length)B=x[0],k=x[1],n=x[2];else throw"invalid arg count, need 2 or 3, got "+x.length; if(!isFinite(k)||!isFinite(n))return!1;x=this.nf([k,n]);k=x[0];n=x[1];B=B.copy();B.setFillType(a.FillType.Winding);B.stroke({width:this.lineWidth,miter_limit:this.miterLimit,cap:this.Nd.getStrokeCap(),join:this.Nd.getStrokeJoin(),precision:.3});x=B.contains(k,n);B.delete();return x};this.lineTo=function(k,n){I(this.Qd,k,n)};this.measureText=function(){throw Error("Clients wishing to properly measure text should use the Paragraph API");};this.moveTo=function(k,n){var x=this.Qd;d([k,n])&&x.moveTo(k, n)};this.putImageData=function(k,n,x,B,C,E,K){if(d([n,x,B,C,E,K]))if(void 0===B)this.Ld.writePixels(k.data,k.width,k.height,n,x);else if(B=B||0,C=C||0,E=E||k.width,K=K||k.height,0>E&&(B+=E,E=Math.abs(E)),0>K&&(C+=K,K=Math.abs(K)),0>B&&(E+=B,B=0),0>C&&(K+=C,C=0),!(0>=E||0>=K)){k=a.MakeImage({width:k.width,height:k.height,alphaType:a.AlphaType.Unpremul,colorType:a.ColorType.RGBA_8888,colorSpace:a.ColorSpace.SRGB},k.data,4*k.width);var Z=a.XYWHRect(B,C,E,K);n=a.XYWHRect(n+B,x+C,E,K);x=a.Matrix.invert(this.Rd); this.Ld.save();this.Ld.concat(x);this.Ld.drawImageRect(k,Z,n,null,!1);this.Ld.restore();k.delete()}};this.quadraticCurveTo=function(k,n,x,B){var C=this.Qd;d([k,n,x,B])&&(C.isEmpty()&&C.moveTo(k,n),C.quadTo(k,n,x,B))};this.rect=function(k,n,x,B){var C=this.Qd;k=a.XYWHRect(k,n,x,B);d(k)&&C.addRect(k)};this.resetTransform=function(){this.Qd.transform(this.Rd);var k=a.Matrix.invert(this.Rd);this.Ld.concat(k);this.Rd=this.Ld.getTotalMatrix()};this.restore=function(){var k=this.mf.pop();if(k){var n=a.Matrix.multiply(this.Rd, a.Matrix.invert(k.Bf));this.Qd.transform(n);this.Nd.delete();this.Nd=k.Zf;this.te=k.Vf;this.Le=k.qg;this.fe=k.pg;this.$d=k.fs;this.ve=k.ng;this.we=k.og;this.ue=k.cg;this.Ke=k.mg;this.he=k.If;this.Md=k.Jf;this.Je=k.Wf;this.Ue=k.Gf;this.Ld.restore();this.Rd=this.Ld.getTotalMatrix()}};this.rotate=function(k){if(isFi