UNPKG

canvaskit-wasm

Version:

A WASM version of Skia's Canvas API

108 lines (105 loc) 159 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 g;g||(g=typeof CanvasKitInit !== 'undefined' ? CanvasKitInit : {});var aa;g.ready=new Promise(function(a){aa=a}); (function(a){a.zk=a.zk||[];a.zk.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.kk=c;return b};a.MakeCanvasSurface||(a.MakeCanvasSurface=a.MakeSWCanvasSurface);a.MakeSurface=function(b,c){var d={width:b,height:c,colorType:a.ColorType.RGBA_8888,alphaType:a.AlphaType.Unpremul,colorSpace:a.SkColorSpace.SRGB},e=b*c*4,h=a._malloc(e);if(d=this._getRasterDirectSurface(d, h,4*b))d.kk=null,d.jm=b,d.fm=c,d.im=e,d.Jl=h,d.getCanvas().clear(a.TRANSPARENT);return d};a.SkSurface.prototype.flush=function(b){this._flush();if(this.kk){var c=new Uint8ClampedArray(a.HEAPU8.buffer,this.Jl,this.im);c=new ImageData(c,this.jm,this.fm);b?this.kk.getContext("2d").putImageData(c,0,0,b.fLeft,b.fTop,b.fRight-b.fLeft,b.fBottom-b.fTop):this.kk.getContext("2d").putImageData(c,0,0)}};a.SkSurface.prototype.dispose=function(){this.Jl&&a._free(this.Jl);this.delete()};a.currentContext=a.currentContext|| function(){};a.setCurrentContext=a.setCurrentContext||function(){}})})(g); (function(a){a.zk=a.zk||[];a.zk.push(function(){function b(c,d,e){return c&&c.hasOwnProperty(d)?c[d]:e}a.Gm=function(c,d){if(!c)throw"null canvas passed into makeWebGLContext";var e={alpha:b(d,"alpha",1),depth:b(d,"depth",1),stencil:b(d,"stencil",8),antialias:b(d,"antialias",0),premultipliedAlpha:b(d,"premultipliedAlpha",1),preserveDrawingBuffer:b(d,"preserveDrawingBuffer",0),preferLowPowerToHighPerformance:b(d,"preferLowPowerToHighPerformance",0),failIfMajorPerformanceCaveat:b(d,"failIfMajorPerformanceCaveat", 0),enableExtensionsByDefault:b(d,"enableExtensionsByDefault",1),explicitSwapControl:b(d,"explicitSwapControl",0),renderViaOffscreenBackBuffer:b(d,"renderViaOffscreenBackBuffer",0)};d&&d.majorVersion&&(e.majorVersion=d.majorVersion);if(e.explicitSwapControl)throw"explicitSwapControl is not supported";this.createContext(c,!0,!0,e)};a.GetWebGLContext=function(c,d){this.Gm(c,d);return a.currentContext()||0};a.MakeWebGLCanvasSurface=function(c,d,e){d=d||null;var h=c;if("CANVAS"!==h.tagName&&(h=document.getElementById(c), !h))throw"Canvas with id "+c+" was not found";c=this.GetWebGLContext(h,e);e=h.dm.version;if(!c||0>c)throw"failed to create webgl context: err "+c;var n=this.MakeGrContext(c);d=this.MakeOnScreenGLSurface(n,h.width,h.height,d);if(!d)return d=h.cloneNode(!0),h.parentNode.replaceChild(d,h),d.classList.add("ck-replaced"),a.MakeSWCanvasSurface(d);d.Qk=c;d.grContext=n;d.openGLversion=e;return d};a.MakeCanvasSurface=a.MakeWebGLCanvasSurface})})(g); (function(a){function b(m){return Math.round(Math.max(0,Math.min(m||0,255)))}function c(m){return m?m.constructor===Float32Array&&4===m.length:!1}function d(m){return(b(255*m[3])<<24|b(255*m[0])<<16|b(255*m[1])<<8|b(255*m[2])<<0)>>>0}function e(m){if(m instanceof Float32Array){for(var w=Math.floor(m.length/4),F=new Uint32Array(w),J=0;J<w;J++)F[J]=d(m.slice(4*J,4*(J+1)));return F}if(m instanceof Uint32Array)return m;if(m instanceof Array&&m[0]instanceof Float32Array)return m.map(d)}function h(m){if(void 0=== m)return 1;var w=parseFloat(m);return m&&-1!==m.indexOf("%")?w/100:w}function n(m,w,F){if(!m||!m.length)return 0;if(m._ck)return m.byteOffset;var J=a[w].BYTES_PER_ELEMENT;F||(F=a._malloc(m.length*J));a[w].set(m,F/J);return F}function q(m,w,F){if(!m||!m.length)return 0;var J=a[w].BYTES_PER_ELEMENT;F||(F=a._malloc(m.length*m[0].length*J));w=a[w];var X=0;J=F/J;for(var ca=0;ca<m.length;ca++)for(var f=0;f<m[0].length;f++)w[J+X]=m[ca][f],X++;return F}function u(m){var w={Fk:0,count:m.length,sl:a.ColorType.RGBA_F32}; if(m instanceof Float32Array)w.Fk=n(m,"HEAPF32"),w.count=m.length/4;else if(m instanceof Uint32Array)w.Fk=n(m,"HEAPU32"),w.sl=a.ColorType.RGBA_8888;else if(m instanceof Array&&m[0]instanceof Float32Array)w.Fk=q(m,"HEAPF32");else throw"Invalid argument to copyFlexibleColorArray, Not a color array "+typeof m;return w}function A(m){if(!m)return 0;if(m.length){if(6!==m.length&&9!==m.length)throw"invalid matrix size";var w=n(m,"HEAPF32",ka);6===m.length&&a.HEAPF32.set(Ba,6+w/4);return w}w=gb.toTypedArray(); w[0]=m.m11;w[1]=m.m21;w[2]=m.m41;w[3]=m.m12;w[4]=m.m22;w[5]=m.m42;w[6]=m.m14;w[7]=m.m24;w[8]=m.m44;return ka}function G(m){if(!m)return 0;var w=Fc.toTypedArray();if(m.length){if(16!==m.length&&6!==m.length&&9!==m.length)throw"invalid matrix size";if(16===m.length)return n(m,"HEAPF32",Ea);w.fill(0);w[0]=m[0];w[1]=m[1];w[3]=m[2];w[4]=m[3];w[5]=m[4];w[7]=m[5];w[12]=m[6];w[13]=m[7];w[15]=m[8];6===m.length&&(w[12]=0,w[13]=0,w[15]=1);return Ea}w[0]=m.m11;w[1]=m.m21;w[2]=m.m31;w[3]=m.m41;w[4]=m.m12;w[5]= m.m22;w[6]=m.m32;w[7]=m.m42;w[8]=m.m13;w[9]=m.m23;w[10]=m.m33;w[11]=m.m43;w[12]=m.m14;w[13]=m.m24;w[14]=m.m34;w[15]=m.m44;return Ea}function M(m){for(var w=Array(16),F=0;16>F;F++)w[F]=a.HEAPF32[m/4+F];return w}function P(m,w){return n(m,"HEAPF32",w||Bb)}function z(m,w,F,J){var X=Gc.toTypedArray();X[0]=m;X[1]=w;X[2]=F;X[3]=J;return Bb}function Q(m){for(var w=new Float32Array(4),F=0;4>F;F++)w[F]=a.HEAPF32[m/4+F];return w}function R(m,w){w&&!w._ck&&a._free(m)}a.Color=function(m,w,F,J){void 0===J&&(J= 1);return a.Color4f(b(m)/255,b(w)/255,b(F)/255,J)};a.ColorAsInt=function(m,w,F,J){void 0===J&&(J=255);return(b(J)<<24|b(m)<<16|b(w)<<8|b(F)<<0&268435455)>>>0};a.Color4f=function(m,w,F,J){void 0===J&&(J=1);return Float32Array.of(m,w,F,J)};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(m){return[Math.floor(255*m[0]),Math.floor(255* m[1]),Math.floor(255*m[2]),m[3]]};a.parseColorString=function(m,w){m=m.toLowerCase();if(m.startsWith("#")){w=255;switch(m.length){case 9:w=parseInt(m.slice(7,9),16);case 7:var F=parseInt(m.slice(1,3),16);var J=parseInt(m.slice(3,5),16);var X=parseInt(m.slice(5,7),16);break;case 5:w=17*parseInt(m.slice(4,5),16);case 4:F=17*parseInt(m.slice(1,2),16),J=17*parseInt(m.slice(2,3),16),X=17*parseInt(m.slice(3,4),16)}return a.Color(F,J,X,w/255)}return m.startsWith("rgba")?(m=m.slice(5,-1),m=m.split(","),a.Color(+m[0], +m[1],+m[2],h(m[3]))):m.startsWith("rgb")?(m=m.slice(4,-1),m=m.split(","),a.Color(+m[0],+m[1],+m[2],h(m[3]))):m.startsWith("gray(")||m.startsWith("hsl")||!w||(m=w[m],void 0===m)?a.BLACK:m};a.multiplyByAlpha=function(m,w){m=m.slice();m[3]=Math.max(0,Math.min(m[3]*w,1));return m};var fa=!(new Function("try {return this===window;}catch(e){ return false;}"))(),Ba=Float32Array.of(0,0,1),ka=0,gb,Ea=0,Fc,Bb=0,Gc,Hc={};a.Wk=function(){this.Pk=[];this.sk=null;Object.defineProperty(this,"length",{enumerable:!0, get:function(){return this.Pk.length/4}})};a.Wk.prototype.push=function(m,w,F,J){this.sk||this.Pk.push(m,w,F,J)};a.Wk.prototype.set=function(m,w,F,J,X){0>m||m>=this.Pk.length/4||(m*=4,this.sk?(m=this.sk/4+m,a.HEAPF32[m]=w,a.HEAPF32[m+1]=F,a.HEAPF32[m+2]=J,a.HEAPF32[m+3]=X):(this.Pk[m]=w,this.Pk[m+1]=F,this.Pk[m+2]=J,this.Pk[m+3]=X))};a.Wk.prototype.build=function(){return this.sk?this.sk:this.sk=n(this.Pk,"HEAPF32")};a.Wk.prototype.delete=function(){this.sk&&(a._free(this.sk),this.sk=null)};a.ll= function(){this.rl=[];this.sk=null;Object.defineProperty(this,"length",{enumerable:!0,get:function(){return this.rl.length}})};a.ll.prototype.push=function(m){this.sk||this.rl.push(m)};a.ll.prototype.set=function(m,w){0>m||m>=this.rl.length||(m*=4,this.sk?a.HEAPU32[this.sk/4+m]=w:this.rl[m]=w)};a.ll.prototype.build=function(){return this.sk?this.sk:this.sk=n(this.rl,"HEAPU32")};a.ll.prototype.delete=function(){this.sk&&(a._free(this.sk),this.sk=null)};a.SkRectBuilder=a.Wk;a.RSXFormBuilder=a.Wk;a.SkColorBuilder= a.ll;a.Malloc=function(m,w){var F=a._malloc(w*m.BYTES_PER_ELEMENT);return{_ck:!0,length:w,byteOffset:F,Vk:null,subarray:function(J,X){J=this.toTypedArray().subarray(J,X);J._ck=!0;return J},toTypedArray:function(){if(this.Vk&&this.Vk.length)return this.Vk;this.Vk=new m(a.HEAPU8.buffer,F,w);this.Vk._ck=!0;return this.Vk}}};a.Free=function(m){a._free(m.byteOffset);m.byteOffset=0;m.toTypedArray=null;m.Vk=null};a.onRuntimeInitialized=function(){function m(f,p,t,x,C){for(var H=0;H<f.length;H++)p[H*t+(H* C+x+t)%t]=f[H];return p}function w(f){for(var p=f*f,t=Array(p);p--;)t[p]=0==p%(f+1)?1:0;return t}function F(){for(var f=0,p=0;p<arguments.length-1;p+=2)f+=arguments[p]*arguments[p+1];return f}function J(f,p,t){for(var x=Array(f.length),C=0;C<t;C++)for(var H=0;H<t;H++){for(var S=0,U=0;U<t;U++)S+=f[t*C+U]*p[t*U+H];x[C*t+H]=S}return x}function X(f,p){for(var t=J(p[0],p[1],f),x=2;x<p.length;)t=J(t,p[x],f),x++;return t}Gc=a.Malloc(Float32Array,4);Bb=Gc.byteOffset;Fc=a.Malloc(Float32Array,16);Ea=Fc.byteOffset; gb=a.Malloc(Float32Array,9);ka=gb.byteOffset;a.SkColorSpace.SRGB=a.SkColorSpace._MakeSRGB();a.SkColorSpace.DISPLAY_P3=a.SkColorSpace._MakeDisplayP3();a.SkColorSpace.ADOBE_RGB=a.SkColorSpace._MakeAdobeRGB();a.SkMatrix={};a.SkMatrix.identity=function(){return w(3)};a.SkMatrix.invert=function(f){var p=f[0]*f[4]*f[8]+f[1]*f[5]*f[6]+f[2]*f[3]*f[7]-f[2]*f[4]*f[6]-f[1]*f[3]*f[8]-f[0]*f[5]*f[7];return p?[(f[4]*f[8]-f[5]*f[7])/p,(f[2]*f[7]-f[1]*f[8])/p,(f[1]*f[5]-f[2]*f[4])/p,(f[5]*f[6]-f[3]*f[8])/p,(f[0]* f[8]-f[2]*f[6])/p,(f[2]*f[3]-f[0]*f[5])/p,(f[3]*f[7]-f[4]*f[6])/p,(f[1]*f[6]-f[0]*f[7])/p,(f[0]*f[4]-f[1]*f[3])/p]:null};a.SkMatrix.mapPoints=function(f,p){for(var t=0;t<p.length;t+=2){var x=p[t],C=p[t+1],H=f[6]*x+f[7]*C+f[8],S=f[3]*x+f[4]*C+f[5];p[t]=(f[0]*x+f[1]*C+f[2])/H;p[t+1]=S/H}return p};a.SkMatrix.multiply=function(){return X(3,arguments)};a.SkMatrix.rotated=function(f,p,t){p=p||0;t=t||0;var x=Math.sin(f);f=Math.cos(f);return[f,-x,F(x,t,1-f,p),x,f,F(-x,p,1-f,t),0,0,1]};a.SkMatrix.scaled=function(f, p,t,x){t=t||0;x=x||0;var C=m([f,p],w(3),3,0,1);return m([t-f*t,x-p*x],C,3,2,0)};a.SkMatrix.skewed=function(f,p,t,x){t=t||0;x=x||0;var C=m([f,p],w(3),3,1,-1);return m([-f*t,-p*x],C,3,2,0)};a.SkMatrix.translated=function(f,p){return m(arguments,w(3),3,2,0)};a.SkVector={};a.SkVector.dot=function(f,p){return f.map(function(t,x){return t*p[x]}).reduce(function(t,x){return t+x})};a.SkVector.lengthSquared=function(f){return a.SkVector.dot(f,f)};a.SkVector.length=function(f){return Math.sqrt(a.SkVector.lengthSquared(f))}; a.SkVector.mulScalar=function(f,p){return f.map(function(t){return t*p})};a.SkVector.add=function(f,p){return f.map(function(t,x){return t+p[x]})};a.SkVector.sub=function(f,p){return f.map(function(t,x){return t-p[x]})};a.SkVector.dist=function(f,p){return a.SkVector.length(a.SkVector.sub(f,p))};a.SkVector.normalize=function(f){return a.SkVector.mulScalar(f,1/a.SkVector.length(f))};a.SkVector.cross=function(f,p){return[f[1]*p[2]-f[2]*p[1],f[2]*p[0]-f[0]*p[2],f[0]*p[1]-f[1]*p[0]]};a.SkM44={};a.SkM44.identity= function(){return w(4)};a.SkM44.translated=function(f){return m(f,w(4),4,3,0)};a.SkM44.scaled=function(f){return m(f,w(4),4,0,1)};a.SkM44.rotated=function(f,p){return a.SkM44.rotatedUnitSinCos(a.SkVector.normalize(f),Math.sin(p),Math.cos(p))};a.SkM44.rotatedUnitSinCos=function(f,p,t){var x=f[0],C=f[1];f=f[2];var H=1-t;return[H*x*x+t,H*x*C-p*f,H*x*f+p*C,0,H*x*C+p*f,H*C*C+t,H*C*f-p*x,0,H*x*f-p*C,H*C*f+p*x,H*f*f+t,0,0,0,0,1]};a.SkM44.lookat=function(f,p,t){p=a.SkVector.normalize(a.SkVector.sub(p,f)); t=a.SkVector.normalize(t);t=a.SkVector.normalize(a.SkVector.cross(p,t));var x=a.SkM44.identity();m(t,x,4,0,0);m(a.SkVector.cross(t,p),x,4,1,0);m(a.SkVector.mulScalar(p,-1),x,4,2,0);m(f,x,4,3,0);f=a.SkM44.invert(x);return null===f?a.SkM44.identity():f};a.SkM44.perspective=function(f,p,t){var x=1/(p-f);t/=2;t=Math.cos(t)/Math.sin(t);return[t,0,0,0,0,t,0,0,0,0,(p+f)*x,2*p*f*x,0,0,-1,1]};a.SkM44.rc=function(f,p,t){return f[4*p+t]};a.SkM44.multiply=function(){return X(4,arguments)};a.SkM44.invert=function(f){var p= f[0],t=f[4],x=f[8],C=f[12],H=f[1],S=f[5],U=f[9],V=f[13],Y=f[2],la=f[6],ra=f[10],sa=f[14],K=f[3],l=f[7],r=f[11];f=f[15];var y=p*S-t*H,B=p*U-x*H,D=p*V-C*H,I=t*U-x*S,O=t*V-C*S,ba=x*V-C*U,ja=Y*l-la*K,ta=Y*r-ra*K,ua=Y*f-sa*K,hb=la*r-ra*l,ib=la*f-sa*l,jb=ra*f-sa*r,nd=y*jb-B*ib+D*hb+I*ua-O*ta+ba*ja,va=1/nd;if(0===nd||Infinity===va)return null;y*=va;B*=va;D*=va;I*=va;O*=va;ba*=va;ja*=va;ta*=va;ua*=va;hb*=va;ib*=va;jb*=va;p=[S*jb-U*ib+V*hb,U*ua-H*jb-V*ta,H*ib-S*ua+V*ja,S*ta-H*hb-U*ja,x*ib-t*jb-C*hb,p*jb-x* ua+C*ta,t*ua-p*ib-C*ja,p*hb-t*ta+x*ja,l*ba-r*O+f*I,r*D-K*ba-f*B,K*O-l*D+f*y,l*B-K*I-r*y,ra*O-la*ba-sa*I,Y*ba-ra*D+sa*B,la*D-Y*O-sa*y,Y*I-la*B+ra*y];return p.every(function(od){return Infinity!==od&&-Infinity!==od})?p:null};a.SkM44.transpose=function(f){return[f[0],f[4],f[8],f[12],f[1],f[5],f[9],f[13],f[2],f[6],f[10],f[14],f[3],f[7],f[11],f[15]]};a.SkM44.mustInvert=function(f){f=a.SkM44.invert(f);if(null===f)throw"Matrix not invertible";return f};a.SkM44.setupCamera=function(f,p,t){var x=a.SkM44.lookat(t.eye, t.coa,t.up);t=a.SkM44.perspective(t.near,t.far,t.angle);p=[(f.fRight-f.fLeft)/2,(f.fBottom-f.fTop)/2,p];f=a.SkM44.multiply(a.SkM44.translated([(f.fLeft+f.fRight)/2,(f.fTop+f.fBottom)/2,0]),a.SkM44.scaled(p));return a.SkM44.multiply(f,t,x,a.SkM44.mustInvert(f))};a.SkColorMatrix={};a.SkColorMatrix.identity=function(){var f=new Float32Array(20);f[0]=1;f[6]=1;f[12]=1;f[18]=1;return f};a.SkColorMatrix.scaled=function(f,p,t,x){var C=new Float32Array(20);C[0]=f;C[6]=p;C[12]=t;C[18]=x;return C};var ca=[[6, 7,11,12],[0,10,2,12],[0,1,5,6]];a.SkColorMatrix.rotated=function(f,p,t){var x=a.SkColorMatrix.identity();f=ca[f];x[f[0]]=t;x[f[1]]=p;x[f[2]]=-p;x[f[3]]=t;return x};a.SkColorMatrix.postTranslate=function(f,p,t,x,C){f[4]+=p;f[9]+=t;f[14]+=x;f[19]+=C;return f};a.SkColorMatrix.concat=function(f,p){for(var t=new Float32Array(20),x=0,C=0;20>C;C+=5){for(var H=0;4>H;H++)t[x++]=f[C]*p[H]+f[C+1]*p[H+5]+f[C+2]*p[H+10]+f[C+3]*p[H+15];t[x++]=f[C]*p[4]+f[C+1]*p[9]+f[C+2]*p[14]+f[C+3]*p[19]+f[C+4]}return t};a.SkPath.MakeFromCmds= function(f){for(var p=0,t=0;t<f.length;t++)p+=f[t].length;if(Hc[p])var x=Hc[p];else x=new Float32Array(p),Hc[p]=x;var C=0;for(t=0;t<f.length;t++)for(var H=0;H<f[t].length;H++)x[C]=f[t][H],C++;f=[n(x,"HEAPF32"),p];p=a.SkPath._MakeFromCmds(f[0],f[1]);a._free(f[0]);return p};a.MakePathFromCmds=a.SkPath.MakeFromCmds;a.SkPath.MakeFromVerbsPointsWeights=function(f,p,t){var x=n(f,"HEAPU8"),C=n(p,"HEAPF32"),H=n(t,"HEAPF32"),S=a.SkPath._MakeFromVerbsPointsWeights(x,f.length,C,p.length,H,t&&t.length||0);R(x, f);R(C,p);R(H,t);return S};a.SkPath.prototype.addArc=function(f,p,t){this._addArc(f,p,t);return this};a.SkPath.prototype.addOval=function(f,p,t){void 0===t&&(t=1);this._addOval(f,!!p,t);return this};a.SkPath.prototype.addPath=function(){var f=Array.prototype.slice.call(arguments),p=f[0],t=!1;"boolean"===typeof f[f.length-1]&&(t=f.pop());if(1===f.length)this._addPath(p,1,0,0,0,1,0,0,0,1,t);else if(2===f.length)f=f[1],this._addPath(p,f[0],f[1],f[2],f[3],f[4],f[5],f[6]||0,f[7]||0,f[8]||1,t);else if(7=== f.length||10===f.length)this._addPath(p,f[1],f[2],f[3],f[4],f[5],f[6],f[7]||0,f[8]||0,f[9]||1,t);else return null;return this};a.SkPath.prototype.addPoly=function(f,p){if(f._ck){var t=f.byteOffset;var x=f.length/2}else t=q(f,"HEAPF32"),x=f.length;this._addPoly(t,x,p);R(t,f);return this};a.SkPath.prototype.addRect=function(){if(1===arguments.length||2===arguments.length){var f=arguments[0];this._addRect(f.fLeft,f.fTop,f.fRight,f.fBottom,arguments[1]||!1)}else if(4===arguments.length||5===arguments.length)f= arguments,this._addRect(f[0],f[1],f[2],f[3],f[4]||!1);else return null;return this};a.SkPath.prototype.addRoundRect=function(){var f=arguments;if(3===f.length||6===f.length)var p=f[f.length-2];else if(4===f.length||7===f.length){p=f[f.length-3];var t=f[f.length-2];p=[p,t,p,t,p,t,p,t]}else return null;if(8!==p.length)return null;t=n(p,"HEAPF32");if(3===f.length||4===f.length){var x=f[0],C=f[f.length-1];this._addRoundRect(x.fLeft,x.fTop,x.fRight,x.fBottom,t,C)}else 6!==f.length&&7!==f.length||this._addRoundRect(f[0], f[1],f[2],f[3],t,C);R(t,p);return this};a.SkPath.prototype.addVerbsPointsWeights=function(f,p,t){var x=n(f,"HEAPU8"),C=n(p,"HEAPF32"),H=n(t,"HEAPF32");this._addVerbsPointsWeights(x,f.length,C,p.length,H,t&&t.length||0);R(x,f);R(C,p);R(H,t)};a.SkPath.prototype.arc=function(f,p,t,x,C,H){f=a.LTRBRect(f-t,p-t,f+t,p+t);C=(C-x)/Math.PI*180-360*!!H;H=new a.SkPath;H.addArc(f,x/Math.PI*180,C);this.addPath(H,!0);H.delete();return this};a.SkPath.prototype.arcTo=function(){var f=arguments;if(5===f.length)this._arcToTangent(f[0], f[1],f[2],f[3],f[4]);else if(4===f.length)this._arcToOval(f[0],f[1],f[2],f[3]);else if(7===f.length)this._arcToRotated(f[0],f[1],f[2],!!f[3],!!f[4],f[5],f[6]);else throw"Invalid args for arcTo. Expected 4, 5, or 7, got "+f.length;return this};a.SkPath.prototype.arcToOval=function(f,p,t,x){this._arcToOval(f,p,t,x);return this};a.SkPath.prototype.arcToRotated=function(f,p,t,x,C,H,S){this._arcToRotated(f,p,t,!!x,!!C,H,S);return this};a.SkPath.prototype.arcToTangent=function(f,p,t,x,C){this._arcToTangent(f, p,t,x,C);return this};a.SkPath.prototype.close=function(){this._close();return this};a.SkPath.prototype.conicTo=function(f,p,t,x,C){this._conicTo(f,p,t,x,C);return this};a.SkPath.prototype.cubicTo=function(f,p,t,x,C,H){this._cubicTo(f,p,t,x,C,H);return this};a.SkPath.prototype.dash=function(f,p,t){return this._dash(f,p,t)?this:null};a.SkPath.prototype.lineTo=function(f,p){this._lineTo(f,p);return this};a.SkPath.prototype.moveTo=function(f,p){this._moveTo(f,p);return this};a.SkPath.prototype.offset= function(f,p){this._transform(1,0,f,0,1,p,0,0,1);return this};a.SkPath.prototype.quadTo=function(f,p,t,x){this._quadTo(f,p,t,x);return this};a.SkPath.prototype.rArcTo=function(f,p,t,x,C,H,S){this._rArcTo(f,p,t,x,C,H,S);return this};a.SkPath.prototype.rConicTo=function(f,p,t,x,C){this._rConicTo(f,p,t,x,C);return this};a.SkPath.prototype.rCubicTo=function(f,p,t,x,C,H){this._rCubicTo(f,p,t,x,C,H);return this};a.SkPath.prototype.rLineTo=function(f,p){this._rLineTo(f,p);return this};a.SkPath.prototype.rMoveTo= function(f,p){this._rMoveTo(f,p);return this};a.SkPath.prototype.rQuadTo=function(f,p,t,x){this._rQuadTo(f,p,t,x);return this};a.SkPath.prototype.stroke=function(f){f=f||{};f.width=f.width||1;f.miter_limit=f.miter_limit||4;f.cap=f.cap||a.StrokeCap.Butt;f.join=f.join||a.StrokeJoin.Miter;f.precision=f.precision||1;return this._stroke(f)?this:null};a.SkPath.prototype.transform=function(){if(1===arguments.length){var f=arguments[0];this._transform(f[0],f[1],f[2],f[3],f[4],f[5],f[6]||0,f[7]||0,f[8]||1)}else if(6=== arguments.length||9===arguments.length)f=arguments,this._transform(f[0],f[1],f[2],f[3],f[4],f[5],f[6]||0,f[7]||0,f[8]||1);else throw"transform expected to take 1 or 9 arguments. Got "+arguments.length;return this};a.SkPath.prototype.trim=function(f,p,t){return this._trim(f,p,!!t)?this:null};a.SkImage.prototype.encodeToData=function(){if(!arguments.length)return this._encodeToData();if(2===arguments.length){var f=arguments;return this._encodeToDataWithFormat(f[0],f[1])}throw"encodeToData expected to take 0 or 2 arguments. Got "+ arguments.length;};a.SkImage.prototype.makeShader=function(f,p,t){t=A(t);return this._makeShader(f,p,t)};a.SkImage.prototype.readPixels=function(f,p,t){switch(f.colorType){case a.ColorType.RGBA_8888:var x=4*f.width;break;case a.ColorType.RGBA_F32:x=16*f.width;break;default:return}var C=x*f.height,H=a._malloc(C);if(!this._readPixels(f,H,x,p,t))return null;p=null;switch(f.colorType){case a.ColorType.RGBA_8888:p=(new Uint8Array(a.HEAPU8.buffer,H,C)).slice();break;case a.ColorType.RGBA_F32:p=(new Float32Array(a.HEAPU8.buffer, H,C)).slice()}a._free(H);return p};a.SkCanvas.prototype.clear=function(f){f=P(f);this._clear(f)};a.SkCanvas.prototype.concat=function(f){f=G(f);this._concat(f)};a.SkCanvas.prototype.concat44=a.SkCanvas.prototype.concat;a.SkCanvas.prototype.drawAtlas=function(f,p,t,x,C,H){if(f&&x&&p&&t&&p.length===t.length){C||(C=a.BlendMode.SrcOver);var S;p.build?S=p.build():S=n(p,"HEAPF32");if(t.build){var U=t.build();var V=t.length}else U=n(t,"HEAPF32"),V=t.length/4;var Y=0;H&&(H.build?Y=H.build():Y=n(e(H),"HEAPU32")); this._drawAtlas(f,U,S,Y,V,C,x);S&&!p.build&&R(S,p);U&&!t.build&&R(U,t);Y&&!H.build&&R(Y,H)}};a.SkCanvas.prototype.drawColor=function(f,p){f=P(f);void 0!==p?this._drawColor(f,p):this._drawColor(f)};a.SkCanvas.prototype.drawColorComponents=function(f,p,t,x,C){f=z(f,p,t,x);void 0!==C?this._drawColor(f,C):this._drawColor(f)};a.SkCanvas.prototype.drawPoints=function(f,p,t){if(p._ck){var x=p.byteOffset;var C=p.length/2}else x=q(p,"HEAPF32"),C=p.length;this._drawPoints(f,x,C,t);R(x,p)};a.SkCanvas.prototype.drawShadow= function(f,p,t,x,C,H,S){var U=n(C,"HEAPF32"),V=n(H,"HEAPF32");this._drawShadow(f,p,t,x,U,V,S);R(U,C);R(V,H)};a.SkCanvas.prototype.getLocalToDevice=function(){this._getLocalToDevice(Ea);return M(Ea)};a.SkCanvas.prototype.findMarkedCTM=function(f){return this._findMarkedCTM(f,Ea)?M(Ea):null};a.SkCanvas.prototype.getTotalMatrix=function(){this._getTotalMatrix(ka);for(var f=Array(9),p=0;9>p;p++)f[p]=a.HEAPF32[ka/4+p];return f};a.SkCanvas.prototype.readPixels=function(f,p,t,x,C,H,S,U){C=C||a.AlphaType.Unpremul; H=H||a.ColorType.RGBA_8888;S=S||a.SkColorSpace.SRGB;var V=4;H===a.ColorType.RGBA_F16&&(V=8);U=U||V*t;var Y=x*U;V=a._malloc(Y);if(!this._readPixels({width:t,height:x,colorType:H,alphaType:C,colorSpace:S},V,U,f,p))return a._free(V),null;f=(new Uint8Array(a.HEAPU8.buffer,V,Y)).slice();a._free(V);return f};a.SkCanvas.prototype.writePixels=function(f,p,t,x,C,H,S,U){if(f.byteLength%(p*t))throw"pixels length must be a multiple of the srcWidth * srcHeight";var V=f.byteLength/(p*t);H=H||a.AlphaType.Unpremul; S=S||a.ColorType.RGBA_8888;U=U||a.SkColorSpace.SRGB;var Y=V*p;V=n(f,"HEAPU8");p=this._writePixels({width:p,height:t,colorType:S,alphaType:H,colorSpace:U},V,Y,x,C);R(V,f);return p};a.SkColorFilter.MakeBlend=function(f,p){f=P(f);return a.SkColorFilter._MakeBlend(f,p)};a.SkColorFilter.MakeMatrix=function(f){if(!f||20!==f.length)throw"invalid color matrix";var p=n(f,"HEAPF32"),t=a.SkColorFilter._makeMatrix(p);R(p,f);return t};a.SkImageFilter.MakeMatrixTransform=function(f,p,t){f=A(f);return a.SkImageFilter._MakeMatrixTransform(f, p,t)};a.SkPaint.prototype.getColor=function(){this._getColor(Bb);return Q(Bb)};a.SkPaint.prototype.setColor=function(f,p){p=p||null;f=P(f);this._setColor(f,p)};a.SkPaint.prototype.setColorComponents=function(f,p,t,x,C){C=C||null;f=z(f,p,t,x);this._setColor(f,C)};a.SkSurface.prototype.captureFrameAsSkPicture=function(f){var p=new a.SkPictureRecorder,t=p.beginRecording(a.LTRBRect(0,0,this.width(),this.height()));f(t);f=p.finishRecordingAsPicture();p.delete();return f};a.SkSurface.prototype.requestAnimationFrame= function(f,p){this.ml||(this.ml=this.getCanvas());window.requestAnimationFrame(function(){void 0!==this.Qk&&a.setCurrentContext(this.Qk);f(this.ml);this.flush(p)}.bind(this))};a.SkSurface.prototype.drawOnce=function(f,p){this.ml||(this.ml=this.getCanvas());window.requestAnimationFrame(function(){void 0!==this.Qk&&a.setCurrentContext(this.Qk);f(this.ml);this.flush(p);this.dispose()}.bind(this))};a.SkPathEffect.MakeDash=function(f,p){p||(p=0);if(!f.length||1===f.length%2)throw"Intervals array must have even length"; var t=n(f,"HEAPF32");p=a.SkPathEffect._MakeDash(t,f.length,p);R(t,f);return p};a.SkShader.Color=function(f,p){p=p||null;f=P(f);return a.SkShader._Color(f,p)};a.SkShader.MakeLinearGradient=function(f,p,t,x,C,H,S,U){U=U||null;var V=u(t),Y=n(x,"HEAPF32");S=S||0;H=A(H);f=a._MakeLinearGradientShader(f,p,V.Fk,V.sl,Y,V.count,C,S,H,U);R(V.Fk,t);x&&R(Y,x);return f};a.SkShader.MakeRadialGradient=function(f,p,t,x,C,H,S,U){U=U||null;var V=u(t),Y=n(x,"HEAPF32");S=S||0;H=A(H);f=a._MakeRadialGradientShader(f,p, V.Fk,V.sl,Y,V.count,C,S,H,U);R(V.Fk,t);x&&R(Y,x);return f};a.SkShader.MakeSweepGradient=function(f,p,t,x,C,H,S,U,V,Y){Y=Y||null;var la=u(t),ra=n(x,"HEAPF32");S=S||0;U=U||0;V=V||360;H=A(H);f=a._MakeSweepGradientShader(f,p,la.Fk,la.sl,ra,la.count,C,U,V,S,H,Y);R(la.Fk,t);x&&R(ra,x);return f};a.SkShader.MakeTwoPointConicalGradient=function(f,p,t,x,C,H,S,U,V,Y){Y=Y||null;var la=u(C),ra=n(H,"HEAPF32");V=V||0;U=A(U);f=a._MakeTwoPointConicalGradientShader(f,p,t,x,la.Fk,la.sl,ra,la.count,S,V,U,Y);R(la.Fk, C);H&&R(ra,H);return f};a.an=a.SkPathEffect.MakeDash;a.Zm=a.SkShader.MakeLinearGradient;a.$m=a.SkShader.MakeRadialGradient;a.bn=a.SkShader.MakeTwoPointConicalGradient;a.zk&&a.zk.forEach(function(f){f()})};a.computeTonalColors=function(m){var w=n(m.ambient,"HEAPF32"),F=n(m.spot,"HEAPF32");this._computeTonalColors(w,F);var J={ambient:Q(w),spot:Q(F)};R(w,m.ambient);R(F,m.spot);return J};a.LTRBRect=function(m,w,F,J){return{fLeft:m,fTop:w,fRight:F,fBottom:J}};a.XYWHRect=function(m,w,F,J){return{fLeft:m, fTop:w,fRight:m+F,fBottom:w+J}};a.RRectXY=function(m,w,F){return{rect:m,rx1:w,ry1:F,rx2:w,ry2:F,rx3:w,ry3:F,rx4:w,ry4:F}};a.MakeAnimatedImageFromEncoded=function(m){m=new Uint8Array(m);var w=a._malloc(m.byteLength);a.HEAPU8.set(m,w);return(m=a._decodeAnimatedImage(w,m.byteLength))?m:null};a.MakeImageFromEncoded=function(m){m=new Uint8Array(m);var w=a._malloc(m.byteLength);a.HEAPU8.set(m,w);return(m=a._decodeImage(w,m.byteLength))?m:null};var Cb=null;a.MakeImageFromCanvasImageSource=function(m){var w= m.width,F=m.height;Cb||(Cb=document.createElement("canvas"));Cb.width=w;Cb.height=F;var J=Cb.getContext("2d");J.drawImage(m,0,0);m=J.getImageData(0,0,w,F);return a.MakeImage(m.data,w,F,a.AlphaType.Unpremul,a.ColorType.RGBA_8888,a.SkColorSpace.SRGB)};a.MakeImage=function(m,w,F,J,X,ca){var f=m.length/(w*F);F={width:w,height:F,alphaType:J,colorType:X,colorSpace:ca};J=n(m,"HEAPU8");return a._MakeImage(F,J,m.length,w*f)};a.MakeSkVertices=function(m,w,F,J,X,ca){var f=X&&X.length||0,p=0;F&&F.length&&(p|= 1);J&&J.length&&(p|=2);void 0===ca||ca||(p|=4);m=new a._SkVerticesBuilder(m,w.length,f,p);q(w,"HEAPF32",m.positions());m.texCoords()&&q(F,"HEAPF32",m.texCoords());if(m.colors()){if(J.build)throw"Color builder not accepted by MakeSkVertices, use array of ints";n(e(J),"HEAPU32",m.colors())}m.indices()&&n(X,"HEAPU16",m.indices());return m.detach()};(function(m){m.zk=m.zk||[];m.zk.push(function(){function w(f){if(J[f])return J[f];var p=da(f)+1,t=m._malloc(p);ea(f,t,p);return J[f]=t}function F(f){f._colorPtr= P(f.color);f._foregroundColorPtr=0;f._backgroundColorPtr=0;f.foregroundColor&&(f._foregroundColorPtr=P(f.foregroundColor,X));f.backgroundColor&&(f._backgroundColorPtr=P(f.backgroundColor,ca));if(Array.isArray(f.fontFamilies)&&f.fontFamilies.length){var p;if((p=f.fontFamilies)&&p.length){for(var t=[],x=0;x<p.length;x++){var C=w(p[x]);t.push(C)}p=n(t,"HEAPU32")}else p=0;f._fontFamiliesPtr=p;f._fontFamiliesLen=f.fontFamilies.length}else f._fontFamiliesPtr=0,f._fontFamiliesLen=0}m.Paragraph.prototype.getRectsForRange= function(f,p,t,x){f=this._getRectsForRange(f,p,t,x);if(!f||!f.length)return[];p=[];for(t=0;t<f.length;t+=5)x=m.LTRBRect(f[t],f[t+1],f[t+2],f[t+3]),x.direction=0===f[t+4]?m.TextDirection.RTL:m.TextDirection.LTR,p.push(x);m._free(f.byteOffset);return p};m.ParagraphStyle=function(f){f.disableHinting=f.disableHinting||!1;if(f.ellipsis){var p=f.ellipsis;f._ellipsisPtr=w(p);f._ellipsisLen=da(p)+1}else f._ellipsisPtr=0,f._ellipsisLen=0;f.heightMultiplier=f.heightMultiplier||0;f.maxLines=f.maxLines||0;f.textAlign= f.textAlign||m.TextAlign.Start;f.textDirection=f.textDirection||m.TextDirection.LTR;f.textStyle=m.TextStyle(f.textStyle);return f};m.TextStyle=function(f){f.color||(f.color=m.BLACK);f.decoration=f.decoration||0;f.decorationThickness=f.decorationThickness||0;f.fontSize=f.fontSize||0;var p=f.fontStyle;p=p||{};void 0===p.weight&&(p.weight=m.FontWeight.Normal);p.width=p.width||m.FontWidth.Normal;p.slant=p.slant||m.FontSlant.Upright;f.fontStyle=p;return f};var J={},X=m._malloc(16),ca=m._malloc(16);m.ParagraphBuilder.Make= function(f,p){F(f.textStyle);p=m.ParagraphBuilder._Make(f,p);m._free(f.textStyle._fontFamiliesPtr);return p};m.ParagraphBuilder.prototype.pushStyle=function(f){F(f);this._pushStyle(f);m._free(f._fontFamiliesPtr)}})})(g);a.zk=a.zk||[];a.zk.push(function(){a.SkCanvas.prototype.drawText=function(m,w,F,J,X){if("string"===typeof m){var ca=da(m),f=a._malloc(ca+1);ea(m,f,ca+1);this._drawSimpleText(f,ca,w,F,X,J)}else this._drawShapedText(m,w,F,J)};a.SkFont.prototype.getWidths=function(m){var w=m.length+1, F=da(m)+1,J=a._malloc(F);ea(m,J,F);m=a._malloc(4*w);if(!this._getWidths(J,F,w,m))return a._free(J),a._free(m),null;w=new Float32Array(a.HEAPU8.buffer,m,w);w=Array.from(w);a._free(J);a._free(m);return w};a.SkFontMgr.FromData=function(){if(!arguments.length)return null;var m=arguments;1===m.length&&Array.isArray(m[0])&&(m=arguments[0]);if(!m.length)return null;for(var w=[],F=[],J=0;J<m.length;J++){var X=new Uint8Array(m[J]),ca=n(X,"HEAPU8");w.push(ca);F.push(X.byteLength)}w=n(w,"HEAPU32");F=n(F,"HEAPU32"); m=a.SkFontMgr._fromData(w,F,m.length);a._free(w);a._free(F);return m};a.SkFontMgr.prototype.MakeTypefaceFromData=function(m){m=new Uint8Array(m);var w=n(m,"HEAPU8");return(m=this._makeTypefaceFromData(w,m.byteLength))?m:null};a.SkTextBlob.MakeOnPath=function(m,w,F,J){if(m&&m.length&&w&&w.countPoints()){if(1===w.countPoints())return this.MakeFromText(m,F);J||(J=0);var X=F.getWidths(m),ca=new a.RSXFormBuilder;w=new a.SkPathMeasure(w,!1,1);for(var f=0;f<m.length;f++){var p=X[f];J+=p/2;if(J>w.getLength()){if(!w.nextContour()){m= m.substring(0,f);break}J=p/2}var t=w.getPosTan(J),x=t[2],C=t[3];ca.push(x,C,t[0]-p/2*x,t[1]-p/2*C);J+=p/2}m=this.MakeFromRSXform(m,ca,F);ca.delete();w.delete();return m}};a.SkTextBlob.MakeFromRSXform=function(m,w,F){var J=da(m)+1,X=a._malloc(J);ea(m,X,J);m=w.build();F=a.SkTextBlob._MakeFromRSXform(X,J-1,m,F);if(!F)return null;var ca=F.delete.bind(F);F.delete=function(){a._free(X);ca()};return F};a.SkTextBlob.MakeFromText=function(m,w){var F=da(m)+1,J=a._malloc(F);ea(m,J,F);m=a.SkTextBlob._MakeFromText(J, F-1,w);if(!m)return null;var X=m.delete.bind(m);m.delete=function(){a._free(J);X()};return m}});(function(){function m(K){for(var l=0;l<K.length;l++)if(void 0!==K[l]&&!Number.isFinite(K[l]))return!1;return!0}function w(K){var l=a.getColorComponents(K);K=l[0];var r=l[1],y=l[2];l=l[3];if(1===l)return K=K.toString(16).toLowerCase(),r=r.toString(16).toLowerCase(),y=y.toString(16).toLowerCase(),K=1===K.length?"0"+K:K,r=1===r.length?"0"+r:r,y=1===y.length?"0"+y:y,"#"+K+r+y;l=0===l||1===l?l:l.toFixed(8); return"rgba("+K+", "+r+", "+y+", "+l+")"}function F(K){return a.parseColorString(K,la)}function J(K){K=ra.exec(K);if(!K)return null;var l=parseFloat(K[4]),r=16;switch(K[5]){case "em":case "rem":r=16*l;break;case "pt":r=4*l/3;break;case "px":r=l;break;case "pc":r=16*l;break;case "in":r=96*l;break;case "cm":r=96*l/2.54;break;case "mm":r=96/25.4*l;break;case "q":r=96/25.4/4*l;break;case "%":r=16/75*l}return{style:K[1],variant:K[2],weight:K[3],sizePx:r,family:K[6].trim()}}function X(K){this.kk=K;this.mk= new a.SkPaint;this.mk.setAntiAlias(!0);this.mk.setStrokeMiter(10);this.mk.setStrokeCap(a.StrokeCap.Butt);this.mk.setStrokeJoin(a.StrokeJoin.Miter);this.yl="10px monospace";this.Rk=new a.SkFont(null,10);this.Rk.setSubpixel(!0);this.Bk=this.Jk=a.BLACK;this.al=0;this.pl=a.TRANSPARENT;this.cl=this.bl=0;this.ql=this.Nk=1;this.ol=0;this.$k=[];this.lk=a.BlendMode.SrcOver;this.Sk=a.FilterQuality.Low;this.nl=!0;this.mk.setStrokeWidth(this.ql);this.mk.setBlendMode(this.lk);this.pk=new a.SkPath;this.rk=a.SkMatrix.identity(); this.Wl=[];this.gl=[];this.Ok=function(){this.pk.delete();this.mk.delete();this.Rk.delete();this.gl.forEach(function(l){l.Ok()})};Object.defineProperty(this,"currentTransform",{enumerable:!0,get:function(){return{a:this.rk[0],c:this.rk[1],e:this.rk[2],b:this.rk[3],d:this.rk[4],f:this.rk[5]}},set:function(l){l.a&&this.setTransform(l.a,l.b,l.c,l.d,l.e,l.f)}});Object.defineProperty(this,"fillStyle",{enumerable:!0,get:function(){return c(this.Bk)?w(this.Bk):this.Bk},set:function(l){"string"===typeof l? this.Bk=F(l):l.Zk&&(this.Bk=l)}});Object.defineProperty(this,"font",{enumerable:!0,get:function(){return this.yl},set:function(l){var r=J(l),y=r.family;r.typeface=sa[y]?sa[y][(r.style||"normal")+"|"+(r.variant||"normal")+"|"+(r.weight||"normal")]||sa[y]["*"]:null;r&&(this.Rk.setSize(r.sizePx),this.Rk.setTypeface(r.typeface),this.yl=l)}});Object.defineProperty(this,"globalAlpha",{enumerable:!0,get:function(){return this.Nk},set:function(l){!isFinite(l)||0>l||1<l||(this.Nk=l)}});Object.defineProperty(this, "globalCompositeOperation",{enumerable:!0,get:function(){switch(this.lk){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(l){switch(l){case "source-over":this.lk=a.BlendMode.SrcOver;break;case "destination-over":this.lk=a.BlendMode.DstOver;break;case "copy":this.lk=a.BlendMode.Src;break;case "destination":this.lk=a.BlendMode.Dst;break;case "clear":this.lk= a.BlendMode.Clear;break;case "source-in":this.lk=a.BlendMode.SrcIn;break;case "destination-in":this.lk=a.BlendMode.DstIn;break;case "source-out":this.lk=a.BlendMode.SrcOut;break;case "destination-out":this.lk=a.BlendMode.DstOut;break;case "source-atop":this.lk=a.BlendMode.SrcATop;break;case "destination-atop":this.lk=a.BlendMode.DstATop;break;case "xor":this.lk=a.BlendMode.Xor;break;case "lighter":this.lk=a.BlendMode.Plus;break;case "plus-lighter":this.lk=a.BlendMode.Plus;break;case "plus-darker":throw"plus-darker is not supported"; case "multiply":this.lk=a.BlendMode.Multiply;break;case "screen":this.lk=a.BlendMode.Screen;break;case "overlay":this.lk=a.BlendMode.Overlay;break;case "darken":this.lk=a.BlendMode.Darken;break;case "lighten":this.lk=a.BlendMode.Lighten;break;case "color-dodge":this.lk=a.BlendMode.ColorDodge;break;case "color-burn":this.lk=a.BlendMode.ColorBurn;break;case "hard-light":this.lk=a.BlendMode.HardLight;break;case "soft-light":this.lk=a.BlendMode.SoftLight;break;case "difference":this.lk=a.BlendMode.Difference; break;case "exclusion":this.lk=a.BlendMode.Exclusion;break;case "hue":this.lk=a.BlendMode.Hue;break;case "saturation":this.lk=a.BlendMode.Saturation;break;case "color":this.lk=a.BlendMode.Color;break;case "luminosity":this.lk=a.BlendMode.Luminosity;break;default:return}this.mk.setBlendMode(this.lk)}});Object.defineProperty(this,"imageSmoothingEnabled",{enumerable:!0,get:function(){return this.nl},set:function(l){this.nl=!!l}});Object.defineProperty(this,"imageSmoothingQuality",{enumerable:!0,get:function(){switch(this.Sk){case a.FilterQuality.Low:return"low"; case a.FilterQuality.Medium:return"medium";case a.FilterQuality.High:return"high"}},set:function(l){switch(l){case "low":this.Sk=a.FilterQuality.Low;break;case "medium":this.Sk=a.FilterQuality.Medium;break;case "high":this.Sk=a.FilterQuality.High}}});Object.defineProperty(this,"lineCap",{enumerable:!0,get:function(){switch(this.mk.getStrokeCap()){case a.StrokeCap.Butt:return"butt";case a.StrokeCap.Round:return"round";case a.StrokeCap.Square:return"square"}},set:function(l){switch(l){case "butt":this.mk.setStrokeCap(a.StrokeCap.Butt); break;case "round":this.mk.setStrokeCap(a.StrokeCap.Round);break;case "square":this.mk.setStrokeCap(a.StrokeCap.Square)}}});Object.defineProperty(this,"lineDashOffset",{enumerable:!0,get:function(){return this.ol},set:function(l){isFinite(l)&&(this.ol=l)}});Object.defineProperty(this,"lineJoin",{enumerable:!0,get:function(){switch(this.mk.getStrokeJoin()){case a.StrokeJoin.Miter:return"miter";case a.StrokeJoin.Round:return"round";case a.StrokeJoin.Bevel:return"bevel"}},set:function(l){switch(l){case "miter":this.mk.setStrokeJoin(a.StrokeJoin.Miter); break;case "round":this.mk.setStrokeJoin(a.StrokeJoin.Round);break;case "bevel":this.mk.setStrokeJoin(a.StrokeJoin.Bevel)}}});Object.defineProperty(this,"lineWidth",{enumerable:!0,get:function(){return this.mk.getStrokeWidth()},set:function(l){0>=l||!l||(this.ql=l,this.mk.setStrokeWidth(l))}});Object.defineProperty(this,"miterLimit",{enumerable:!0,get:function(){return this.mk.getStrokeMiter()},set:function(l){0>=l||!l||this.mk.setStrokeMiter(l)}});Object.defineProperty(this,"shadowBlur",{enumerable:!0, get:function(){return this.al},set:function(l){0>l||!isFinite(l)||(this.al=l)}});Object.defineProperty(this,"shadowColor",{enumerable:!0,get:function(){return w(this.pl)},set:function(l){this.pl=F(l)}});Object.defineProperty(this,"shadowOffsetX",{enumerable:!0,get:function(){return this.bl},set:function(l){isFinite(l)&&(this.bl=l)}});Object.defineProperty(this,"shadowOffsetY",{enumerable:!0,get:function(){return this.cl},set:function(l){isFinite(l)&&(this.cl=l)}});Object.defineProperty(this,"strokeStyle", {enumerable:!0,get:function(){return w(this.Jk)},set:function(l){"string"===typeof l?this.Jk=F(l):l.Zk&&(this.Jk=l)}});this.arc=function(l,r,y,B,D,I){H(this.pk,l,r,y,y,0,B,D,I)};this.arcTo=function(l,r,y,B,D){t(this.pk,l,r,y,B,D)};this.beginPath=function(){this.pk.delete();this.pk=new a.SkPath};this.bezierCurveTo=function(l,r,y,B,D,I){var O=this.pk;m([l,r,y,B,D,I])&&(O.isEmpty()&&O.moveTo(l,r),O.cubicTo(l,r,y,B,D,I))};this.clearRect=function(l,r,y,B){this.mk.setStyle(a.PaintStyle.Fill);this.mk.setBlendMode(a.BlendMode.Clear); this.kk.drawRect(a.XYWHRect(l,r,y,B),this.mk);this.mk.setBlendMode(this.lk)};this.clip=function(l,r){"string"===typeof l?(r=l,l=this.pk):l&&l.Il&&(l=l.tk);l||(l=this.pk);l=l.copy();r&&"evenodd"===r.toLowerCase()?l.setFillType(a.FillType.EvenOdd):l.setFillType(a.FillType.Winding);this.kk.clipPath(l,a.ClipOp.Intersect,!0);l.delete()};this.closePath=function(){x(this.pk)};this.createImageData=function(){if(1===arguments.length){var l=arguments[0];return new f(new Uint8ClampedArray(4*l.width*l.height), l.width,l.height)}if(2===arguments.length){l=arguments[0];var r=arguments[1];return new f(new Uint8ClampedArray(4*l*r),l,r)}throw"createImageData expects 1 or 2 arguments, got "+arguments.length;};this.createLinearGradient=function(l,r,y,B){if(m(arguments)){var D=new p(l,r,y,B);this.gl.push(D);return D}};this.createPattern=function(l,r){l=new V(l,r);this.gl.push(l);return l};this.createRadialGradient=function(l,r,y,B,D,I){if(m(arguments)){var O=new Y(l,r,y,B,D,I);this.gl.push(O);return O}};this.hm= function(){var l=this.xl();this.nl?l.setFilterQuality(this.Sk):l.setFilterQuality(a.FilterQuality.None);return l};this.drawImage=function(l){var r=this.hm();if(3===arguments.length||5===arguments.length)var y=a.XYWHRect(arguments[1],arguments[2],arguments[3]||l.width(),arguments[4]||l.height()),B=a.XYWHRect(0,0,l.width(),l.height());else if(9===arguments.length)y=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.kk.drawImageRect(l,B,y,r,!1);r.dispose()};this.ellipse=function(l,r,y,B,D,I,O,ba){H(this.pk,l,r,y,B,D,I,O,ba)};this.xl=function(){var l=this.mk.copy();l.setStyle(a.PaintStyle.Fill);if(c(this.Bk)){var r=a.multiplyByAlpha(this.Bk,this.Nk);l.setColor(r)}else r=this.Bk.Zk(this.rk),l.setColor(a.Color(0,0,0,this.Nk)),l.setShader(r);l.dispose=function(){this.delete()};return l};this.fill=function(l,r){"string"===typeof l?(r=l,l=this.pk):l&&l.Il&&(l=l.tk);if("evenodd"===r)this.pk.setFillType(a.FillType.EvenOdd); else{if("nonzero"!==r&&r)throw"invalid fill rule";this.pk.setFillType(a.FillType.Winding)}l||(l=this.pk);r=this.xl();var y=this.dl(r);y&&(this.kk.save(),this.Xk(),this.kk.drawPath(l,y),this.kk.restore(),y.dispose());this.kk.drawPath(l,r);r.dispose()};this.fillRect=function(l,r,y,B){var D=this.xl(),I=this.dl(D);I&&(this.kk.save(),this.Xk(),this.kk.drawRect(a.XYWHRect(l,r,y,B),I),this.kk.restore(),I.dispose());this.kk.drawRect(a.XYWHRect(l,r,y,B),D);D.dispose()};this.fillText=function(l,r,y){var B= this.xl();l=a.SkTextBlob.MakeFromText(l,this.Rk);var D=this.dl(B);D&&(this.kk.save(),this.Xk(),this.kk.drawTextBlob(l,r,y,D),this.kk.restore(),D.dispose());this.kk.drawTextBlob(l,r,y,B);l.delete();B.dispose()};this.getImageData=function(l,r,y,B){return(l=this.kk.readPixels(l,r,y,B))?new f(new Uint8ClampedArray(l.buffer),y,B):null};this.getLineDash=function(){return this.$k.slice()};this.Xl=function(l){var r=a.SkMatrix.invert(this.rk);a.SkMatrix.mapPoints(r,l);return l};this.isPointInPath=function(l, r,y){var B=arguments;if(3===B.length)var D=this.pk;else if(4===B.length)D=B[0],l=B[1],r=B[2],y=B[3];else throw"invalid arg count, need 3 or 4, got "+B.length;if(!isFinite(l)||!isFinite(r))return!1;y=y||"nonzero";if("nonzero"!==y&&"evenodd"!==y)return!1;B=this.Xl([l,r]);l=B[0];r=B[1];D.setFillType("nonzero"===y?a.FillType.Winding:a.FillType.EvenOdd);return D.contains(l,r)};this.isPointInStroke=function(l,r){var y=arguments;if(2===y.length)var B=this.pk;else if(3===y.length)B=y[0],l=y[1],r=y[2];else throw"invalid arg count, need 2 or 3, got "+ y.length;if(!isFinite(l)||!isFinite(r))return!1;y=this.Xl([l,r]);l=y[0];r=y[1];B=B.copy();B.setFillType(a.FillType.Winding);B.stroke({width:this.lineWidth,miter_limit:this.miterLimit,cap:this.mk.getStrokeCap(),join:this.mk.getStrokeJoin(),precision:.3});y=B.contains(l,r);B.delete();return y};this.lineTo=function(l,r){S(this.pk,l,r)};this.measureText=function(l){return{width:this.Rk.measureText(l)}};this.moveTo=function(l,r){var y=this.pk;m([l,r])&&y.moveTo(l,r)};this.putImageData=function(l,r,y,B, D,I,O){if(m([r,y,B,D,I,O]))if(void 0===B)this.kk.writePixels(l.data,l.width,l.height,r,y);else if(B=B||0,D=D||0,I=I||l.width,O=O||l.height,0>I&&(B+=I,I=Math.abs(I)),0>O&&(D+=O,O=Math.abs(O)),0>B&&(I+=B,B=0),0>D&&(O+=D,D=0),!(0>=I||0>=O)){l=a.MakeImage(l.data,l.width,l.height,a.AlphaType.Unpremul,a.ColorType.RGBA_8888,a.SkColorSpace.SRGB);var ba=a.XYWHRect(B,D,I,O);r=a.XYWHRect(r+B,y+D,I,O);y=a.SkMatrix.invert(this.rk);this.kk.save();this.kk.concat(y);this.kk.drawImageRect(l,ba,r,null,!1);this.kk.restore(); l.delete()}};this.quadraticCurveTo=function(l,r,y,B){var D=this.pk;m([l,r,y,B])&&(D.isEmpty()&&D.moveTo(l,r),D.quadTo(l,r,y,B))};this.rect=function(l,r,y,B){var D=this.pk;m([l,r,y,B])&&D.addRect(l,r,l+y,r+B)};this.resetTransform=function(){this.pk.transform(this.rk);var l=a.SkMatrix.invert(this.rk);this.kk.concat(l);this.rk=this.kk.getTotalMatrix()};this.restore=function(){var l=this.Wl.pop();if(l){var r=a.SkMatrix.multiply(this.rk,a.SkMatrix.invert(l.mm));this.pk.transform(r);this.mk.delete();this.mk= l.Im;this.$k=l.Dm;this.ql=l.Tm;this.Jk=l.Sm;this.Bk=l.fs;this.bl=l.Qm;this.cl=l.Rm;this.al=l.Nm;this.pl=l.Pm;this.Nk=l.rm;this.lk=l.sm;this.ol=l.Em;this.nl=l.Bm;this.Sk=l.Cm;this.yl=l.qm;this.kk.restore();this.rk=this.kk.getTotalMatrix()}};this.rotate=function(l){if(isFinite(l)){var r=a.SkMatrix.rotated(-l);this.pk.transform(r);this.kk.rotate(l/Math.PI*180,0,0);this.rk=this.kk.getTotalMatrix()}};this.save=function(){if(this.Bk.Yk){var l=this.Bk.Yk();this.gl.push(l)}else l=this.Bk;if(this.Jk.Yk){var r= this.Jk.Yk();this.gl.push(r)}else r=this.Jk;this.Wl.push({mm:this.rk.slice(),Dm:this.$k.slice(),Tm:this.ql,Sm:r,fs:l,Qm:this.bl,Rm:this.cl,Nm:this.al,Pm:this.pl,rm:this.Nk,Em:this.ol,sm:this.lk,Bm:this.nl,Cm:this.Sk,Im:this.mk.copy(),qm:this.yl});this.kk.save()};this.scale=function(l,r){if(m(arguments)){var y=a.SkMatrix.scaled(1/l,1/r);this.pk.transform(y);this.kk.scale(l,r);this.rk=this.kk.getTotalMatrix()}};this.setLineDash=function(l){for(var r=0;r<l.length;r++)if(!isFinite(l[r])||0>l[r])return; 1===l.length%2&&Array.prototype.push.apply(l,l);this.$k=l};this.setTransform=function(l,r,y,B,D,I){m(arguments)&&(this.resetTransform(),this.transform(l,r,y,B,D,I))};this.Xk=function(){var l=a.SkMatrix.invert(this.rk);this.kk.concat(l);this.kk.concat(a.SkMatrix.translated(this.bl,this.cl));this.kk.concat(this.rk)};this.dl=function(l){var r=a.multiplyByAlpha(this.pl,this.Nk);if(!a.getColorComponents(r)[3]||!(this.al||this.cl||this.bl))return null;l=l.copy();l.setColor(r);var y=a.SkMaskFilter.MakeBlur(a.BlurStyle.Normal, this.al/2,!1);l.setMaskFilter(y);l.dispose=function(){y.delete();this.delete()};return l};this.Kl=function(){var l=this.mk.copy();l.setStyle(a.PaintStyle.Stroke);if(c(this.Jk)){var r=a.multiplyByAlpha(this.Jk,this.Nk);l.setColor(r)}else r=this.Jk.Zk(this.rk),l.setColor(a.Color(0,0,0,this.Nk)),l.setShader(r);l.setStrokeWidth(this.ql);if(this.$k.length){var y=a.SkPathEffect.MakeDash(this.$k,this.ol);l.setPathEffect(y)}l.dispose=function(){y&&y.delete();this.delete()};return l};this.stroke=function(l){l= l?l.tk:this.pk;var r=this.Kl(),y=this.dl(r);y&&(this.kk.save(),this.Xk(),this.kk.drawPath(l,y),this.kk.restore(),y.dispose());this.kk.drawPath(l,r);r.dispose()};this.strokeRect=function(l,r,y,B){var D=this.Kl(),I=this.dl(D);I&&(this.kk.save(),this.Xk(),this.kk.drawRect(a.XYWHRect(l,r,y,B),I),this.kk.restore(),I.dispose());this.kk.drawRect(a.XYWHRect(l,r,y,B),D);D.dispose()};this.strokeText=function(l,r,y){var B=this.Kl();l=a.SkTextBlob.MakeFromText(l,this.Rk);var D=this.dl(B);D&&(this.kk.save(),this.Xk(), this.kk.drawTextBlob(l,r,y,D),this.kk.restore(),D.dispose());this.kk.drawTextBlob(l,r,y,B);l.delete();B.dispose()};this.translate=function(l,r){if(m(arguments)){var y=a.SkMatrix.translated(-l,-r);this.pk.transform(y);this.kk.translate(l,r);this.rk=this.kk.getTotalMatrix()}};this.transform=function(l,r,y,B,D,I){l=[l,y,D,r,B,I,0,0,1];r=a.SkMatrix.invert(l);this.pk.transform(r);this.kk.concat(l);this.rk=this.kk.getTotalMatrix()};this.addHitRegion=function(){};this.clearHitRegions=function(){};this.drawFocusIfNeeded= function(){};this.removeHitRegion=function(){};this.scrollPathIntoView=function(){};Object.defineProperty(this,"canvas",{value:null,writable:!1})}function ca(K){this.Ll=K;this.Qk=new X(K.getCanvas());this.zl=[];this.em=a.SkFontMgr.RefDefault();this.decodeImage=function(l){l=a.MakeImageFromEncoded(l);if(!l)throw"Invalid input";this.zl.push(l);return l};this.loadFont=function(l,r){l=this.em.MakeTypefaceFromData(l);if(!l)return null;this.zl.push(l);var y=(r.style||"normal")+"|"+(r.variant||"normal")+ "|"+(r.weight||"normal");r=r.family;sa[r]||(sa[r]={"*":l});sa[r][y]=l};this.makePath2D=function(l){l=new U(l);this.zl.push(l.tk);return l};this.getContext=function(l){return"2d"===l?this.Qk:null};this.toDataURL=function(l,r){this.Ll.flush();var y=this.Ll.makeImageSnapshot();if(y){l=l||"image/png";var B=a.ImageFormat.PNG;"image/jpeg"===l&&(B=a.ImageFormat.JPEG);if(r=y.encodeToData(B,r||.92)){r=a.getSkDataBytes(r);l="data:"+l+";base64,";if(fa)r=Buffer.from(r).toString("base64");else{y=0;B=r.length; for(var D="",I;y<B;)I=r.slice(y,Math.min(y+32768,B)),D+=String.fromCharCode.apply(null,I),y+=32768;r=btoa(D)}return l+r}}};this.dispose=function(){this.Qk.Ok();this.zl.forEach(function(l){l.delete()});this.Ll.dispose()}}function f(K,l,r){if(!l||0===r)throw"invalid dimensions, width and height must be non-zero";if(K.length%4)throw"arr must be a multiple of 4";r=r||K.length/(4*l);Object.defineProperty(this,"data",{value:K,writable:!1});Object.defineProperty(this,"height",{value:r,writable:!1});Object.defineProperty(this, "width",{value:l,writable:!1})}function p(K,l,r,y){this.vk=null;this.Ek=[];this.yk=[];this.addColorStop=function(B,D){if(0>B||1<B||!isFinite(B))throw"offset must be between 0 and 1 inclusively";D=F(D);var I=this.yk.indexOf(B);if(-1!==I)this.Ek[I]=D;else{for(I=0;I<this.yk.length&&!(this.yk[I]>B);I++);this.yk.splice(I,0,B);this.Ek.splice(I,0,D)}};this.Yk=function(){var B=new p(K,l,r,y);B.Ek=this.Ek.slice();B.yk=this.yk.slice();return B};this.Ok=function(){this.vk&&(this.vk.delete(),this.vk=null)};this.Zk= function(B){var D=[K,l,r,y];a.SkMatrix.mapPoints(B,D);B=D[0];var I=D[1],O=D[2];D=D[3];this.Ok();return this.vk=a.SkShader.MakeLinearGradient([B,I],[O,D],this.Ek,this.yk,a.TileMode.Clamp)}}function t(K,l,r,y,B,D){if(m([l,r,y,B,D])){if(0>D)throw"radii cannot be negative";K.isEmpty()&&K.moveTo(l,r);K.arcToTangent(l,r,y,B,D)}}function x(K){if(!K.isEmpty()){var l=K.getBounds();(l.fBottom-l.fTop||l.fRight-l.fLeft)&&K.close()}}function C(K,l,r,y,B,D,I){I=(I-D)/Math.PI*180;D=D/Math.PI*180;l=a.LTRBRect(l- y,r-B,l+y,r+B);1E-5>Math.abs(Math.abs(I)-360)?(r=I/2,K.arcToOval(l,D,r,!1),K.arcToOval(l,D+r,r,!1)):K.arcToOval(l,D,I,!1)}function H(K,l,r,y,B,D,I,O,ba){if(m([l,r,y,B,D,I,O])){if(0>y||0>B)throw"radii cannot b