@rive-app/canvas-lite 2.41.0 → 2.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/rive.js CHANGED
@@ -349,98 +349,103 @@ __webpack_require__.r(__webpack_exports__);
349
349
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
350
350
  /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
351
351
  /* harmony export */ });
352
- var Rive=(()=>{var _scriptName=globalThis.document?.currentScript?.src;return async function(moduleArg={}){var moduleRtn;var k=moduleArg,aa=!!globalThis.window,ba=!!globalThis.WorkerGlobalScope;
353
- function fa(){function b(h){const g=d;c=a=0;d=new Map;g.forEach(m=>{try{m(h)}catch(n){console.error(n)}});this.ab();e&&e.xb()}let a=0,c=0,d=new Map,e=null,f=null;this.requestAnimationFrame=function(h){a||=requestAnimationFrame(b.bind(this));const g=++c;d.set(g,h);return g};this.cancelAnimationFrame=function(h){d.delete(h);a&&0==d.size&&(cancelAnimationFrame(a),a=0)};this.vb=function(h){f&&(document.body.remove(f),f=null);h||(f=document.createElement("div"),f.style.backgroundColor="black",f.style.position=
354
- "fixed",f.style.right=0,f.style.top=0,f.style.color="white",f.style.padding="4px",f.innerHTML="RIVE FPS",h=function(g){f.innerHTML="RIVE FPS "+g.toFixed(1)},document.body.appendChild(f));e=new function(){let g=0,m=0;this.xb=function(){var n=performance.now();m?(++g,n-=m,1E3<n&&(h(1E3*g/n),g=m=0)):(m=n,g=0)}}};this.sb=function(){f&&(document.body.remove(f),f=null);e=null};this.ab=function(){}}
355
- function ja(b){console.assert(!0);const a=new Map;let c=-Infinity;this.push=function(d){d=d+((1<<b)-1)>>b;a.has(d)&&clearTimeout(a.get(d));a.set(d,setTimeout(function(){a.delete(d);0==a.length?c=-Infinity:d==c&&(c=Math.max(...a.keys()),console.assert(c<d))},1E3));c=Math.max(d,c);return c<<b}}const ka=k.onRuntimeInitialized;
356
- k.onRuntimeInitialized=function(){ka&&ka();let b=k.decodeAudio;k.decodeAudio=function(f,h){f=b(f);h(f)};let a=k.decodeFont;k.decodeFont=function(f,h){f=a(f);h(f)};let c=k.setFallbackFontCb;k.setFallbackFontCallback="function"===typeof c?function(f){c(f)}:function(){console.warn("Module.setFallbackFontCallback called, but text support is not enabled in this build.")};const d=k.FileAssetLoader;k.ptrToAsset=f=>{let h=k.ptrToFileAsset(f);return h.isImage?k.ptrToImageAsset(f):h.isFont?k.ptrToFontAsset(f):
357
- h.isAudio?k.ptrToAudioAsset(f):h};k.CustomFileAssetLoader=d.extend("CustomFileAssetLoader",{__construct:function({loadContents:f}){this.__parent.__construct.call(this);this.mb=f},loadContents:function(f,h){f=k.ptrToAsset(f);return this.mb(f,h)}});k.CDNFileAssetLoader=d.extend("CDNFileAssetLoader",{__construct:function(){this.__parent.__construct.call(this)},loadContents:function(f){let h=k.ptrToAsset(f);f=h.cdnUuid;if(""===f)return!1;(function(g,m){var n=new XMLHttpRequest;n.responseType="arraybuffer";
358
- n.onreadystatechange=function(){4==n.readyState&&200==n.status&&m(n)};n.open("GET",g,!0);n.send(null)})(h.cdnBaseUrl+"/"+f,g=>{h.decode(new Uint8Array(g.response))});return!0}});k.FallbackFileAssetLoader=d.extend("FallbackFileAssetLoader",{__construct:function(){this.__parent.__construct.call(this);this.$a=[]},addLoader:function(f){this.$a.push(f)},loadContents:function(f,h){for(let g of this.$a)if(g.loadContents(f,h))return!0;return!1}});let e=k.computeAlignment;k.computeAlignment=function(f,h,g,
359
- m,n=1){return e.call(this,f,h,g,m,n)}};
360
- const la="createConicGradient createImageData createLinearGradient createPattern createRadialGradient getContextAttributes getImageData getLineDash getTransform isContextLost isPointInPath isPointInStroke measureText".split(" "),ma=new function(){function b(){if(!a){var t=document.createElement("canvas"),v={alpha:1,depth:0,stencil:0,antialias:0,premultipliedAlpha:1,preserveDrawingBuffer:0,powerPreference:"high-performance",failIfMajorPerformanceCaveat:0,enableExtensionsByDefault:1,explicitSwapControl:1,
361
- renderViaOffscreenBackBuffer:1};let p;if(/iPhone|iPad|iPod/i.test(navigator.userAgent)){if(p=t.getContext("webgl",v),c=1,!p)return console.log("No WebGL support. Image mesh will not be drawn."),!1}else if(p=t.getContext("webgl2",v))c=2;else if(p=t.getContext("webgl",v))c=1;else return console.log("No WebGL support. Image mesh will not be drawn."),!1;p=new Proxy(p,{get(F,r){if(F.isContextLost()){if(m||(console.error("Cannot render the mesh because the GL Context was lost. Tried to invoke ",r),m=!0),
362
- "function"===typeof F[r])return function(){}}else return"function"===typeof F[r]?function(...G){return F[r].apply(F,G)}:F[r]},set(F,r,G){if(F.isContextLost())m||(console.error("Cannot render the mesh because the GL Context was lost. Tried to set property "+r),m=!0);else return F[r]=G,!0}});d=Math.min(p.getParameter(p.MAX_RENDERBUFFER_SIZE),p.getParameter(p.MAX_TEXTURE_SIZE));function I(F,r,G){r=p.createShader(r);p.shaderSource(r,G);p.compileShader(r);G=p.getShaderInfoLog(r);if(0<(G||"").length)throw G;
363
- p.attachShader(F,r)}t=p.createProgram();I(t,p.VERTEX_SHADER,"attribute vec2 vertex;\n attribute vec2 uv;\n uniform vec4 mat;\n uniform vec2 translate;\n varying vec2 st;\n void main() {\n st = uv;\n gl_Position = vec4(mat2(mat) * vertex + translate, 0, 1);\n }");I(t,p.FRAGMENT_SHADER,"precision highp float;\n uniform sampler2D image;\n varying vec2 st;\n void main() {\n gl_FragColor = texture2D(image, st);\n }");
364
- p.bindAttribLocation(t,0,"vertex");p.bindAttribLocation(t,1,"uv");p.linkProgram(t);v=p.getProgramInfoLog(t);if(0<(v||"").trim().length)throw v;e=p.getUniformLocation(t,"mat");f=p.getUniformLocation(t,"translate");p.useProgram(t);p.bindBuffer(p.ARRAY_BUFFER,p.createBuffer());p.enableVertexAttribArray(0);p.enableVertexAttribArray(1);p.bindBuffer(p.ELEMENT_ARRAY_BUFFER,p.createBuffer());p.uniform1i(p.getUniformLocation(t,"image"),0);p.pixelStorei(p.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0);a=p}return!0}let a=
365
- null,c=0,d=0,e=null,f=null,h=0,g=0,m=!1;b();this.Gb=function(){b();return d};this.rb=function(t){a.deleteTexture&&a.deleteTexture(t)};this.qb=function(t){if(!b())return null;const v=a.createTexture();if(!v)return null;a.bindTexture(a.TEXTURE_2D,v);a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,t);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR);2==c?(a.texParameteri(a.TEXTURE_2D,
366
- a.TEXTURE_MIN_FILTER,a.LINEAR_MIPMAP_LINEAR),a.generateMipmap(a.TEXTURE_2D)):a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR);return v};const n=new ja(8),u=new ja(8),x=new ja(10),w=new ja(10);this.ub=function(t,v,p,I,F){if(b()){var r=n.push(t),G=u.push(v);if(a.canvas){if(a.canvas.width!=r||a.canvas.height!=G)a.canvas.width=r,a.canvas.height=G;a.viewport(0,G-v,t,v);a.disable(a.SCISSOR_TEST);a.clearColor(0,0,0,0);a.clear(a.COLOR_BUFFER_BIT);a.enable(a.SCISSOR_TEST);p.sort((E,U)=>U.fb-E.fb);
367
- r=x.push(I);h!=r&&(a.bufferData(a.ARRAY_BUFFER,8*r,a.DYNAMIC_DRAW),h=r);r=0;for(var L of p)a.bufferSubData(a.ARRAY_BUFFER,r,L.Oa),r+=4*L.Oa.length;console.assert(r==4*I);for(var O of p)a.bufferSubData(a.ARRAY_BUFFER,r,O.ib),r+=4*O.ib.length;console.assert(r==8*I);r=w.push(F);g!=r&&(a.bufferData(a.ELEMENT_ARRAY_BUFFER,2*r,a.DYNAMIC_DRAW),g=r);L=0;for(var ca of p)a.bufferSubData(a.ELEMENT_ARRAY_BUFFER,L,ca.indices),L+=2*ca.indices.length;console.assert(L==2*F);ca=0;O=!0;r=L=0;for(const E of p){E.image.Ja!=
368
- ca&&(a.bindTexture(a.TEXTURE_2D,E.image.Ia||null),ca=E.image.Ja);E.Jb?(a.scissor(E.Ta,G-E.Ua-E.Za,E.Qb,E.Za),O=!0):O&&(a.scissor(0,G-v,t,v),O=!1);p=2/t;const U=-2/v;a.uniform4f(e,E.ua[0]*p*E.Ea,E.ua[1]*U*E.Fa,E.ua[2]*p*E.Ea,E.ua[3]*U*E.Fa);a.uniform2f(f,E.ua[4]*p*E.Ea+p*(E.Ta-E.Hb*E.Ea)-1,E.ua[5]*U*E.Fa+U*(E.Ua-E.Ib*E.Fa)+1);a.vertexAttribPointer(0,2,a.FLOAT,!1,0,r);a.vertexAttribPointer(1,2,a.FLOAT,!1,0,r+4*I);a.drawElements(a.TRIANGLES,E.indices.length,a.UNSIGNED_SHORT,L);r+=4*E.Oa.length;L+=2*
369
- E.indices.length}console.assert(r==4*I);console.assert(L==2*F)}}};this.canvas=function(){return b()&&a.canvas}},na=k.onRuntimeInitialized;
370
- k.onRuntimeInitialized=function(){function b(l){switch(l){case n.srcOver:return"source-over";case n.screen:return"screen";case n.overlay:return"overlay";case n.darken:return"darken";case n.lighten:return"lighten";case n.colorDodge:return"color-dodge";case n.colorBurn:return"color-burn";case n.hardLight:return"hard-light";case n.softLight:return"soft-light";case n.difference:return"difference";case n.exclusion:return"exclusion";case n.multiply:return"multiply";case n.hue:return"hue";case n.saturation:return"saturation";
371
- case n.color:return"color";case n.luminosity:return"luminosity"}}function a(l){return"rgba("+((16711680&l)>>>16)+","+((65280&l)>>>8)+","+((255&l)>>>0)+","+((4278190080&l)>>>24)/255+")"}function c(){0<G.length&&(ma.ub(r.drawWidth(),r.drawHeight(),G,L,O),G=[],O=L=0,r.reset(512,512));for(const l of F){for(const q of l.ma)q();l.ma=[]}F.clear()}na&&na();var d=k.RenderPaintStyle;const e=k.RenderPath,f=k.RenderPaint,h=k.Renderer,g=k.StrokeCap,m=k.StrokeJoin,n=k.BlendMode,u=d.fill,x=d.stroke,w=k.FillRule.evenOdd;
372
- let t=1;var v=k.RenderImage.extend("CanvasRenderImage",{__construct:function({ya:l,Da:q}={}){this.__parent.__construct.call(this);this.Ja=t;t=t+1&2147483647||1;this.ya=l;this.Da=q},__destruct:function(){this.Ia&&(ma.rb(this.Ia),URL.revokeObjectURL(this.Ra));this.__parent.__destruct.call(this)},decode:function(l){var q=this;q.Da&&q.Da(q);var D=new Image;q.Ra=URL.createObjectURL(new Blob([l],{type:"image/png"}));D.onload=function(){q.lb=D;q.Ia=ma.qb(D);q.size(D.width,D.height);q.ya&&q.ya(q)};D.src=
373
- q.Ra}}),p=e.extend("CanvasRenderPath",{__construct:function(){this.__parent.__construct.call(this);this.ra=new Path2D},rewind:function(){this.ra=new Path2D},addPath:function(l,q,D,B,y,C,A){var H=this.ra,ha=H.addPath;l=l.ra;const N=new DOMMatrix;N.a=q;N.b=D;N.c=B;N.d=y;N.e=C;N.f=A;ha.call(H,l,N)},fillRule:function(l){this.Qa=l},moveTo:function(l,q){this.ra.moveTo(l,q)},lineTo:function(l,q){this.ra.lineTo(l,q)},cubicTo:function(l,q,D,B,y,C){this.ra.bezierCurveTo(l,q,D,B,y,C)},close:function(){this.ra.closePath()}}),
374
- I=f.extend("CanvasRenderPaint",{color:function(l){this.Sa=a(l)},thickness:function(l){this.ob=l},join:function(l){switch(l){case m.miter:this.Ha="miter";break;case m.round:this.Ha="round";break;case m.bevel:this.Ha="bevel"}},cap:function(l){switch(l){case g.butt:this.Ga="butt";break;case g.round:this.Ga="round";break;case g.square:this.Ga="square"}},style:function(l){this.nb=l},blendMode:function(l){this.kb=b(l)},clearGradient:function(){this.wa=null},linearGradient:function(l,q,D,B){this.wa={gb:l,
375
- hb:q,Wa:D,Xa:B,Na:[]}},radialGradient:function(l,q,D,B){this.wa={gb:l,hb:q,Wa:D,Xa:B,Na:[],Eb:!0}},addStop:function(l,q){this.wa.Na.push({color:l,stop:q})},completeGradient:function(){},draw:function(l,q,D,B){let y=this.nb;var C=this.Sa,A=this.wa;const H=l.globalCompositeOperation,ha=l.globalAlpha;l.globalCompositeOperation=this.kb;l.globalAlpha=B;if(null!=A){C=A.gb;const R=A.hb,X=A.Wa;var N=A.Xa;B=A.Na;A.Eb?(A=X-C,N-=R,C=l.createRadialGradient(C,R,0,C,R,Math.sqrt(A*A+N*N))):C=l.createLinearGradient(C,
376
- R,X,N);for(let S=0,V=B.length;S<V;S++)A=B[S],C.addColorStop(A.stop,a(A.color));this.Sa=C;this.wa=null}switch(y){case x:l.strokeStyle=C;l.lineWidth=this.ob;l.lineCap=this.Ga;l.lineJoin=this.Ha;l.stroke(q);break;case u:l.fillStyle=C,l.fill(q,D)}l.globalCompositeOperation=H;l.globalAlpha=ha}});const F=new Set;let r=null,G=[],L=0,O=0;var ca=k.CanvasRenderer=h.extend("Renderer",{__construct:function(l){this.__parent.__construct.call(this);this.qa=[1,0,0,1,0,0];this.ja=[1];this.ga=l.getContext("2d");this.Pa=
377
- l;this.ma=[]},save:function(){this.qa.push(...this.qa.slice(this.qa.length-6));this.ja.push(this.ja[this.ja.length-1]);this.ma.push(this.ga.save.bind(this.ga))},restore:function(){const l=this.qa.length-6;if(6>l)throw"restore() called without matching save().";this.qa.splice(l);this.ja.pop();this.ma.push(this.ga.restore.bind(this.ga))},transform:function(l,q,D,B,y,C){const A=this.qa,H=A.length-6;A.splice(H,6,A[H]*l+A[H+2]*q,A[H+1]*l+A[H+3]*q,A[H]*D+A[H+2]*B,A[H+1]*D+A[H+3]*B,A[H]*y+A[H+2]*C+A[H+4],
378
- A[H+1]*y+A[H+3]*C+A[H+5]);this.ma.push(this.ga.transform.bind(this.ga,l,q,D,B,y,C))},rotate:function(l){const q=Math.sin(l);l=Math.cos(l);this.transform(l,q,-q,l,0,0)},modulateOpacity:function(l){this.ja[this.ja.length-1]*=l},_drawPath:function(l,q){this.ma.push(q.draw.bind(q,this.ga,l.ra,l.Qa===w?"evenodd":"nonzero",Math.max(0,this.ja[this.ja.length-1])))},_drawRiveImage:function(l,q,D,B){var y=l.lb;if(y){var C=this.ga,A=b(D),H=Math.max(0,B*this.ja[this.ja.length-1]);this.ma.push(function(){C.globalCompositeOperation=
379
- A;C.globalAlpha=H;C.drawImage(y,0,0);C.globalAlpha=1})}},_getMatrix:function(l){const q=this.qa,D=q.length-6;for(let B=0;6>B;++B)l[B]=q[D+B]},_drawImageMesh:function(l,q,D,B,y,C,A,H,ha,N,R,X,S,V){let nb,ob,pb;try{nb=k.HEAPF32.slice(y>>2,(y>>2)+C),ob=k.HEAPF32.slice(A>>2,(A>>2)+H),pb=k.HEAPU16.slice(ha>>1,(ha>>1)+N)}catch(Ra){console.error("[Rive] _drawImageMesh: failed to read mesh data from WASM heap. Mesh skipped for this frame.");return}q=this.ga.canvas.width;y=this.ga.canvas.height;A=S-R;H=V-
380
- X;R=Math.max(R,0);X=Math.max(X,0);S=Math.min(S,q);V=Math.min(V,y);const qa=S-R,ra=V-X;console.assert(qa<=Math.min(A,q));console.assert(ra<=Math.min(H,y));if(!(0>=qa||0>=ra)){S=qa<A||ra<H;q=V=1;var da=Math.ceil(qa*V),ea=Math.ceil(ra*q);y=ma.Gb();da>y&&(V*=y/da,da=y);ea>y&&(q*=y/ea,ea=y);r||(r=new k.DynamicRectanizer(y),r.reset(512,512));y=r.addRect(da,ea);0>y&&(c(),F.add(this),y=r.addRect(da,ea),console.assert(0<=y));var qb=y&65535,rb=y>>16;G.push({ua:this.qa.slice(this.qa.length-6),image:l,Ta:qb,
381
- Ua:rb,Hb:R,Ib:X,Qb:da,Za:ea,Ea:V,Fa:q,Oa:nb,ib:ob,indices:pb,Jb:S,fb:l.Ja<<1|(S?1:0)});L+=C;O+=N;var ia=this.ga,cc=b(D),dc=Math.max(0,B*this.ja[this.ja.length-1]);this.ma.push(function(){ia.save();ia.resetTransform();ia.globalCompositeOperation=cc;ia.globalAlpha=dc;const Ra=ma.canvas();Ra&&ia.drawImage(Ra,qb,rb,da,ea,R,X,qa,ra);ia.restore()})}},_clipPath:function(l){this.ma.push(this.ga.clip.bind(this.ga,l.ra,l.Qa===w?"evenodd":"nonzero"))},clear:function(){F.add(this);this.ma.push(this.ga.clearRect.bind(this.ga,
382
- 0,0,this.Pa.width,this.Pa.height))},flush:function(){},translate:function(l,q){this.transform(1,0,0,1,l,q)}});k.makeRenderer=function(l){const q=new ca(l),D=q.ga;return new Proxy(q,{get(B,y){if("function"===typeof B[y])return function(...C){return B[y].apply(B,C)};if("function"===typeof D[y]){if(-1<la.indexOf(y))throw Error("RiveException: Method call to '"+y+"()' is not allowed, as the renderer cannot immediately pass through the return values of any canvas 2d context methods.");
383
- return function(...C){q.ma.push(D[y].bind(D,...C))}}return B[y]},set(B,y,C){if(y in D)return q.ma.push(()=>{D[y]=C}),!0}})};k.decodeImage=function(l,q){(new v({ya:q})).decode(l)};k.renderFactory={makeRenderPaint:function(){return new I},makeRenderPath:function(){return new p},makeRenderImage:function(){let l=U;return new v({Da:()=>{l.total++},ya:()=>{l.loaded++;if(l.loaded===l.total){const q=l.ready;q&&(q(),l.ready=null)}}})}};let E=k.load,U=null;k.load=function(l,q,D=!0){const B=new k.FallbackFileAssetLoader;
384
- void 0!==q&&B.addLoader(q);D&&(q=new k.CDNFileAssetLoader,B.addLoader(q));return new Promise(function(y){let C=null;U={total:0,loaded:0,ready:function(){y(C)}};C=E(l,B);0==U.total&&y(C)})};let ec=k.RendererWrapper.prototype.align;k.RendererWrapper.prototype.align=function(l,q,D,B,y=1){ec.call(this,l,q,D,B,y)};d=new fa;k.requestAnimationFrame=d.requestAnimationFrame.bind(d);k.cancelAnimationFrame=d.cancelAnimationFrame.bind(d);k.enableFPSCounter=d.vb.bind(d);k.disableFPSCounter=d.sb;d.ab=c;k.resolveAnimationFrame=
385
- c;k.cleanup=function(){r&&r.delete()}};var oa="./this.program";ba&&(_scriptName=self.location.href);var pa="",sa,ta;
386
- if(aa||ba){try{pa=(new URL(".",_scriptName)).href}catch{}ba&&(ta=b=>{var a=new XMLHttpRequest;a.open("GET",b,!1);a.responseType="arraybuffer";a.send(null);return new Uint8Array(a.response)});sa=async b=>{if(ua(b))return new Promise((c,d)=>{var e=new XMLHttpRequest;e.open("GET",b,!0);e.responseType="arraybuffer";e.onload=()=>{200==e.status||0==e.status&&e.response?c(e.response):d(e.status)};e.onerror=d;e.send(null)});var a=await fetch(b,{credentials:"same-origin"});if(a.ok)return a.arrayBuffer();throw Error(a.status+
387
- " : "+a.url);}}var va=console.log.bind(console),wa=console.error.bind(console),xa,ya=!1,za,ua=b=>b.startsWith("file://"),Aa,Ba,Ca,z,Da,Ea,Fa,J,Ga,Ha,Ia,Ja,Ka=!1;function La(){var b=Ma.buffer;k.HEAP8=Ca=new Int8Array(b);Da=new Int16Array(b);k.HEAPU8=z=new Uint8Array(b);k.HEAPU16=Ea=new Uint16Array(b);k.HEAP32=Fa=new Int32Array(b);k.HEAPU32=J=new Uint32Array(b);k.HEAPF32=Ga=new Float32Array(b);Ha=new Float64Array(b);Ia=new BigInt64Array(b);Ja=new BigUint64Array(b)}
388
- function Na(b){k.onAbort?.(b);b="Aborted("+b+")";wa(b);ya=!0;b=new WebAssembly.RuntimeError(b+". Build with -sASSERTIONS for more info.");Ba?.(b);throw b;}var Oa;async function Pa(b){if(!xa)try{var a=await sa(b);return new Uint8Array(a)}catch{}if(b==Oa&&xa)b=new Uint8Array(xa);else if(ta)b=ta(b);else throw"both async and sync fetching of the wasm failed";return b}
389
- async function Qa(b,a){try{var c=await Pa(b);return await WebAssembly.instantiate(c,a)}catch(d){wa(`failed to asynchronously prepare wasm: ${d}`),Na(d)}}async function Sa(b){var a=Oa;if(!xa&&!ua(a))try{var c=fetch(a,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(c,b)}catch(d){wa(`wasm streaming compile failed: ${d}`),wa("falling back to ArrayBuffer instantiation")}return Qa(a,b)}
390
- class Ta{name="ExitStatus";constructor(b){this.message=`Program terminated with exit(${b})`;this.status=b}}
391
- var Ua=b=>{for(;0<b.length;)b.shift()(k)},Va=[],Wa=[],Xa=()=>{var b=k.preRun.shift();Wa.push(b)},Ya=!0,Za=(b,a)=>Object.defineProperty(a,"name",{value:b}),$a=[],ab=[0,1,,1,null,1,!0,1,!1,1],K=class extends Error{constructor(b){super(b);this.name="BindingError"}},M=b=>{if(!b)throw new K(`Cannot use deleted val. handle = ${b}`);return ab[b]},P=b=>{switch(b){case void 0:return 2;case null:return 4;case !0:return 6;case !1:return 8;default:const a=$a.pop()||ab.length;ab[a]=b;ab[a+1]=1;return a}};
392
- class bb extends Error{}
393
- var Q=b=>{for(var a="";;){var c=z[b++];if(!c)return a;a+=String.fromCharCode(c)}},cb={},db=(b,a)=>{if(void 0===a)throw new K("ptr should not be undefined");for(;b.ha;)a=b.za(a),b=b.ha;return a},eb={},hb=b=>{b=fb(b);var a=Q(b);gb(b);return a},ib=(b,a)=>{var c=eb[b];if(void 0===c)throw b=`${a} has unknown type ${hb(b)}`,new K(b);return c},jb=()=>{},kb=!1,lb=b=>{if(!globalThis.FinalizationRegistry)return lb=a=>a,b;kb=new FinalizationRegistry(a=>{a=a.$;--a.count.value;0===a.count.value&&(a.ia?a.na.pa(a.ia):
394
- a.da.aa.pa(a.ca))});lb=a=>{var c=a.$;c.ia&&kb.register(a,{$:c},a);return a};jb=a=>{kb.unregister(a)};return lb(b)},mb={},sb=b=>{for(;b.length;){var a=b.pop();b.pop()(a)}};function tb(b){return this.ba(J[b>>2])}
395
- var ub={},vb={},wb=class extends Error{constructor(b){super(b);this.name="InternalError"}},W=(b,a,c)=>{function d(g){g=c(g);if(g.length!==b.length)throw new wb("Mismatched type converter count");for(var m=0;m<b.length;++m)T(b[m],g[m])}b.forEach(g=>vb[g]=a);var e=Array(a.length),f=[],h=0;for(let [g,m]of a.entries())eb.hasOwnProperty(m)?e[g]=eb[m]:(f.push(m),ub.hasOwnProperty(m)||(ub[m]=[]),ub[m].push(()=>{e[g]=eb[m];++h;h===f.length&&d(e)}));0===f.length&&d(e)};
396
- function xb(b,a,c={}){var d=a.name;if(!b)throw new K(`type "${d}" must have a positive integer typeid pointer`);if(eb.hasOwnProperty(b)){if(c.Db)return;throw new K(`Cannot register type '${d}' twice`);}eb[b]=a;delete vb[b];ub.hasOwnProperty(b)&&(a=ub[b],delete ub[b],a.forEach(e=>e()))}function T(b,a,c={}){return xb(b,a,c)}
397
- var yb=(b,a,c)=>{switch(a){case 1:return c?d=>Ca[d]:d=>z[d];case 2:return c?d=>Da[d>>1]:d=>Ea[d>>1];case 4:return c?d=>Fa[d>>2]:d=>J[d>>2];case 8:return c?d=>Ia[d>>3]:d=>Ja[d>>3];default:throw new TypeError(`invalid integer width (${a}): ${b}`);}},zb=b=>{throw new K(b.$.da.aa.name+" instance already deleted");},Ab=[];function Bb(){}
398
- var Cb={},Db=(b,a,c)=>{if(void 0===b[a].fa){var d=b[a];b[a]=function(...e){if(!b[a].fa.hasOwnProperty(e.length))throw new K(`Function '${c}' called with an invalid number of arguments (${e.length}) - expects one of (${b[a].fa})!`);return b[a].fa[e.length].apply(this,e)};b[a].fa=[];b[a].fa[d.sa]=d}},Eb=(b,a,c)=>{if(k.hasOwnProperty(b)){if(void 0===c||void 0!==k[b].fa&&void 0!==k[b].fa[c])throw new K(`Cannot register public name '${b}' twice`);Db(k,b,b);if(k[b].fa.hasOwnProperty(c))throw new K(`Cannot register multiple overloads of a function with the same number of arguments (${c})!`);
399
- k[b].fa[c]=a}else k[b]=a,k[b].sa=c},Fb=b=>{b=b.replace(/[^a-zA-Z0-9_]/g,"$");var a=b.charCodeAt(0);return 48<=a&&57>=a?`_${b}`:b};function Gb(b,a,c,d,e,f,h,g){this.name=b;this.constructor=a;this.oa=c;this.pa=d;this.ha=e;this.yb=f;this.za=h;this.tb=g;this.bb=[]}
400
- var Hb=(b,a,c)=>{for(;a!==c;){if(!a.za)throw new K(`Expected null or instance of ${c.name}, got an instance of ${a.name}`);b=a.za(b);a=a.ha}return b},Ib=b=>{if(null===b)return"null";var a=typeof b;return"object"===a||"array"===a||"function"===a?b.toString():""+b};
401
- function Jb(b,a){if(null===a){if(this.Ka)throw new K(`null is not a valid ${this.name}`);return 0}if(!a.$)throw new K(`Cannot pass "${Ib(a)}" as a ${this.name}`);if(!a.$.ca)throw new K(`Cannot pass deleted object as a pointer of type ${this.name}`);return Hb(a.$.ca,a.$.da.aa,this.aa)}
402
- function Kb(b,a){if(null===a){if(this.Ka)throw new K(`null is not a valid ${this.name}`);if(this.Ca){var c=this.Ma();null!==b&&b.push(this.pa,c);return c}return 0}if(!a||!a.$)throw new K(`Cannot pass "${Ib(a)}" as a ${this.name}`);if(!a.$.ca)throw new K(`Cannot pass deleted object as a pointer of type ${this.name}`);if(!this.Ba&&a.$.da.Ba)throw new K(`Cannot convert argument of type ${a.$.na?a.$.na.name:a.$.da.name} to parameter type ${this.name}`);c=Hb(a.$.ca,a.$.da.aa,this.aa);if(this.Ca){if(void 0===
403
- a.$.ia)throw new K("Passing raw pointer to smart pointer is illegal");switch(this.Pb){case 0:if(a.$.na===this)c=a.$.ia;else throw new K(`Cannot convert argument of type ${a.$.na?a.$.na.name:a.$.da.name} to parameter type ${this.name}`);break;case 1:c=a.$.ia;break;case 2:if(a.$.na===this)c=a.$.ia;else{var d=a.clone();c=this.Lb(c,P(()=>d["delete"]()));null!==b&&b.push(this.pa,c)}break;default:throw new K("Unsupported sharing policy");}}return c}
404
- function Lb(b,a){if(null===a){if(this.Ka)throw new K(`null is not a valid ${this.name}`);return 0}if(!a.$)throw new K(`Cannot pass "${Ib(a)}" as a ${this.name}`);if(!a.$.ca)throw new K(`Cannot pass deleted object as a pointer of type ${this.name}`);if(a.$.da.Ba)throw new K(`Cannot convert argument of type ${a.$.da.name} to parameter type ${this.name}`);return Hb(a.$.ca,a.$.da.aa,this.aa)}
405
- var Mb=(b,a,c)=>{if(a===c)return b;if(void 0===c.ha)return null;b=Mb(b,a,c.ha);return null===b?null:c.tb(b)},Nb=(b,a)=>{a=db(b,a);return cb[a]},Ob=(b,a)=>{if(!a.da||!a.ca)throw new wb("makeClassHandle requires ptr and ptrType");if(!!a.na!==!!a.ia)throw new wb("Both smartPtrType and smartPtr must be specified");a.count={value:1};return lb(Object.create(b,{$:{value:a,writable:!0}}))};
406
- function Pb(b,a,c,d,e,f,h,g,m,n,u){this.name=b;this.aa=a;this.Ka=c;this.Ba=d;this.Ca=e;this.Kb=f;this.Pb=h;this.cb=g;this.Ma=m;this.Lb=n;this.pa=u;e||void 0!==a.ha?this.ea=Kb:(this.ea=d?Jb:Lb,this.ka=null)}var Qb=(b,a,c)=>{if(!k.hasOwnProperty(b))throw new wb("Replacing nonexistent public symbol");void 0!==k[b].fa&&void 0!==c?k[b].fa[c]=a:(k[b]=a,k[b].sa=c)},Y=(b,a)=>{b=Q(b);var c=Rb.get(a);if("function"!=typeof c)throw new K(`unknown function pointer with signature ${b}: ${a}`);return c};
407
- class Sb extends Error{}var Z=(b,a)=>{function c(f){e[f]||eb[f]||(vb[f]?vb[f].forEach(c):(d.push(f),e[f]=!0))}var d=[],e={};a.forEach(c);throw new Sb(`${b}: `+d.map(hb).join([", "]));};function Tb(b){for(var a=1;a<b.length;++a)if(null!==b[a]&&void 0===b[a].ka)return!0;return!1}
408
- function Ub(b,a,c,d,e){var f=a.length;if(2>f)throw new K("argTypes array size mismatch! Must at least get return value and 'this' types!");var h=null!==a[1]&&null!==c,g=Tb(a),m=!a[0].Fb,n=f-2,u=Array(n),x=[],w=[];return Za(b,function(...t){w.length=0;x.length=h?2:1;x[0]=e;if(h){var v=a[1].ea(w,this);x[1]=v}for(var p=0;p<n;++p)u[p]=a[p+2].ea(w,t[p]),x.push(u[p]);t=d(...x);if(g)sb(w);else for(p=h?1:2;p<a.length;p++){var I=1===p?v:u[p-2];null!==a[p].ka&&a[p].ka(I)}v=m?a[0].ba(t):void 0;return v})}
409
- var Vb=(b,a)=>{for(var c=[],d=0;d<b;d++)c.push(J[a+4*d>>2]);return c},Wb=b=>{b=b.trim();const a=b.indexOf("(");return-1===a?b:b.slice(0,a)},Xb=(b,a,c)=>{if(!(b instanceof Object))throw new K(`${c} with invalid "this": ${b}`);if(!(b instanceof a.aa.constructor))throw new K(`${c} incompatible with "this" of type ${b.constructor.name}`);if(!b.$.ca)throw new K(`cannot call emscripten binding method ${c} on deleted object`);return Hb(b.$.ca,b.$.da.aa,a.aa)},Yb=b=>{9<b&&0===--ab[b+1]&&(ab[b]=void 0,$a.push(b))},
410
- Zb={name:"emscripten::val",ba:b=>{var a=M(b);Yb(b);return a},ea:(b,a)=>P(a),la:tb,ka:null},$b=(b,a,c)=>{switch(a){case 1:return c?function(d){return this.ba(Ca[d])}:function(d){return this.ba(z[d])};case 2:return c?function(d){return this.ba(Da[d>>1])}:function(d){return this.ba(Ea[d>>1])};case 4:return c?function(d){return this.ba(Fa[d>>2])}:function(d){return this.ba(J[d>>2])};default:throw new TypeError(`invalid integer width (${a}): ${b}`);}},ac=(b,a)=>{switch(a){case 4:return function(c){return this.ba(Ga[c>>
411
- 2])};case 8:return function(c){return this.ba(Ha[c>>3])};default:throw new TypeError(`invalid float width (${a}): ${b}`);}},bc=(b,a,c)=>{var d=z;if(!(0<c))return 0;var e=a;c=a+c-1;for(var f=0;f<b.length;++f){var h=b.codePointAt(f);if(127>=h){if(a>=c)break;d[a++]=h}else if(2047>=h){if(a+1>=c)break;d[a++]=192|h>>6;d[a++]=128|h&63}else if(65535>=h){if(a+2>=c)break;d[a++]=224|h>>12;d[a++]=128|h>>6&63;d[a++]=128|h&63}else{if(a+3>=c)break;d[a++]=240|h>>18;d[a++]=128|h>>12&63;d[a++]=128|h>>6&63;d[a++]=128|
412
- h&63;f++}}d[a]=0;return a-e},fc=b=>{for(var a=0,c=0;c<b.length;++c){var d=b.charCodeAt(c);127>=d?a++:2047>=d?a+=2:55296<=d&&57343>=d?(a+=4,++c):a+=3}return a},gc=globalThis.TextDecoder&&new TextDecoder,hc=(b,a,c,d)=>{c=a+c;if(d)return c;for(;b[a]&&!(a>=c);)++a;return a},ic=(b,a=0,c,d)=>{c=hc(b,a,c,d);if(16<c-a&&b.buffer&&gc)return gc.decode(b.subarray(a,c));for(d="";a<c;){var e=b[a++];if(e&128){var f=b[a++]&63;if(192==(e&224))d+=String.fromCharCode((e&31)<<6|f);else{var h=b[a++]&63;e=224==(e&240)?
413
- (e&15)<<12|f<<6|h:(e&7)<<18|f<<12|h<<6|b[a++]&63;65536>e?d+=String.fromCharCode(e):(e-=65536,d+=String.fromCharCode(55296|e>>10,56320|e&1023))}}else d+=String.fromCharCode(e)}return d},jc=globalThis.TextDecoder?new TextDecoder("utf-16le"):void 0,kc=(b,a,c)=>{b>>=1;a=hc(Ea,b,a/2,c);if(16<a-b&&jc)return jc.decode(Ea.subarray(b,a));for(c="";b<a;++b)c+=String.fromCharCode(Ea[b]);return c},lc=(b,a,c)=>{c??=2147483647;if(2>c)return 0;c-=2;var d=a;c=c<2*b.length?c/2:b.length;for(var e=0;e<c;++e)Da[a>>1]=
414
- b.charCodeAt(e),a+=2;Da[a>>1]=0;return a-d},mc=b=>2*b.length,nc=(b,a,c)=>{var d="";b>>=2;for(var e=0;!(e>=a/4);e++){var f=J[b+e];if(!f&&!c)break;d+=String.fromCodePoint(f)}return d},oc=(b,a,c)=>{c??=2147483647;if(4>c)return 0;var d=a;c=d+c-4;for(var e=0;e<b.length;++e){var f=b.codePointAt(e);65535<f&&e++;Fa[a>>2]=f;a+=4;if(a+4>c)break}Fa[a>>2]=0;return a-d},pc=b=>{for(var a=0,c=0;c<b.length;++c)65535<b.codePointAt(c)&&c++,a+=4;return a},qc=0,rc=[],sc=b=>{var a=rc.length;rc.push(b);return a},tc=(b,
415
- a)=>{for(var c=Array(b),d=0;d<b;++d)c[d]=ib(J[a+4*d>>2],`parameter ${d}`);return c},uc={},vc=b=>{var a=uc[b];return void 0===a?Q(b):a},wc={},xc=b=>{if(!(b instanceof Ta||"unwind"==b))throw b;},yc=b=>{za=b;Ya||0<qc||(k.onExit?.(b),ya=!0);throw new Ta(b);},zc=b=>{if(!ya)try{if(b(),!(Ya||0<qc))try{za=b=za,yc(b)}catch(a){xc(a)}}catch(a){xc(a)}},Ac={},Cc=()=>{if(!Bc){var b={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-",
416
- "_")+".UTF-8",_:oa||"./this.program"},a;for(a in Ac)void 0===Ac[a]?delete b[a]:b[a]=Ac[a];var c=[];for(a in b)c.push(`${a}=${b[a]}`);Bc=c}return Bc},Bc,Dc=[null,[],[]];
417
- (()=>{let b=Bb.prototype;Object.assign(b,{isAliasOf:function(c){if(!(this instanceof Bb&&c instanceof Bb))return!1;var d=this.$.da.aa,e=this.$.ca;c.$=c.$;var f=c.$.da.aa;for(c=c.$.ca;d.ha;)e=d.za(e),d=d.ha;for(;f.ha;)c=f.za(c),f=f.ha;return d===f&&e===c},clone:function(){this.$.ca||zb(this);if(this.$.va)return this.$.count.value+=1,this;var c=lb,d=Object,e=d.create,f=Object.getPrototypeOf(this),h=this.$;c=c(e.call(d,f,{$:{value:{count:h.count,xa:h.xa,va:h.va,ca:h.ca,da:h.da,ia:h.ia,na:h.na}}}));c.$.count.value+=
418
- 1;c.$.xa=!1;return c},["delete"](){this.$.ca||zb(this);if(this.$.xa&&!this.$.va)throw new K("Object already scheduled for deletion");jb(this);var c=this.$;--c.count.value;0===c.count.value&&(c.ia?c.na.pa(c.ia):c.da.aa.pa(c.ca));this.$.va||(this.$.ia=void 0,this.$.ca=void 0)},isDeleted:function(){return!this.$.ca},deleteLater:function(){this.$.ca||zb(this);if(this.$.xa&&!this.$.va)throw new K("Object already scheduled for deletion");Ab.push(this);this.$.xa=!0;return this}});const a=Symbol.dispose;
352
+ var Rive=(()=>{var _scriptName=globalThis.document?.currentScript?.src;return async function(moduleArg={}){var moduleRtn;var h=moduleArg,ba=!!globalThis.window,ca=!!globalThis.WorkerGlobalScope;
353
+ function fa(){function b(g){const f=d;c=a=0;d=new Map;f.forEach(m=>{try{m(g)}catch(n){console.error(n)}});this.rb();e&&e.Qb()}let a=0,c=0,d=new Map,e=null,k=null;this.requestAnimationFrame=function(g){a||=requestAnimationFrame(b.bind(this));const f=++c;d.set(f,g);return f};this.cancelAnimationFrame=function(g){d.delete(g);a&&0==d.size&&(cancelAnimationFrame(a),a=0)};this.Ob=function(g){k&&(document.body.remove(k),k=null);g||(k=document.createElement("div"),k.style.backgroundColor="black",k.style.position=
354
+ "fixed",k.style.right=0,k.style.top=0,k.style.color="white",k.style.padding="4px",k.innerHTML="RIVE FPS",g=function(f){k.innerHTML="RIVE FPS "+f.toFixed(1)},document.body.appendChild(k));e=new function(){let f=0,m=0;this.Qb=function(){var n=performance.now();m?(++f,n-=m,1E3<n&&(g(1E3*f/n),f=m=0)):(m=n,f=0)}}};this.Lb=function(){k&&(document.body.remove(k),k=null);e=null};this.rb=function(){}}
355
+ function ia(b){console.assert(!0);const a=new Map;let c=-Infinity;this.push=function(d){d=d+((1<<b)-1)>>b;a.has(d)&&clearTimeout(a.get(d));a.set(d,setTimeout(function(){a.delete(d);0==a.length?c=-Infinity:d==c&&(c=Math.max(...a.keys()),console.assert(c<d))},1E3));c=Math.max(d,c);return c<<b}}const ja=h.onRuntimeInitialized;
356
+ h.onRuntimeInitialized=function(){ja&&ja();let b=h.decodeAudio;h.decodeAudio=function(g,f,m=null){g=b(g,m??null);f(g)};let a=h.decodeFont;h.decodeFont=function(g,f,m=null){g=a(g,m??null);f(g)};const c=h.FileAsset.prototype.decode;h.FileAsset.prototype.decode=function(g,f){return c.call(this,g,f??null)};let d=h.setFallbackFontCb;h.setFallbackFontCallback="function"===typeof d?function(g){d(g)}:function(){console.warn("Module.setFallbackFontCallback called, but text support is not enabled in this build.")};
357
+ const e=h.FileAssetLoader;h.ptrToAsset=g=>{let f=h.ptrToFileAsset(g);return f.isImage?h.ptrToImageAsset(g):f.isFont?h.ptrToFontAsset(g):f.isAudio?h.ptrToAudioAsset(g):f};h.CustomFileAssetLoader=e.extend("CustomFileAssetLoader",{__construct:function({loadContents:g}){this.__parent.__construct.call(this);this.Fb=g},loadContents:function(g,f){g=h.ptrToAsset(g);return this.Fb(g,f)}});h.CDNFileAssetLoader=e.extend("CDNFileAssetLoader",{__construct:function(g){this.__parent.__construct.call(this);this.Gb=
358
+ g??null},loadContents:function(g){let f=h.ptrToAsset(g);g=f.cdnUuid;if(""===g)return!1;const m=this.Gb??null;(function(n,r){var w=new XMLHttpRequest;w.responseType="arraybuffer";w.onreadystatechange=function(){4==w.readyState&&200==w.status&&r(w)};w.open("GET",n,!0);w.send(null)})(f.cdnBaseUrl+"/"+g,n=>{f.decode(new Uint8Array(n.response),m)});return!0}});h.FallbackFileAssetLoader=e.extend("FallbackFileAssetLoader",{__construct:function(){this.__parent.__construct.call(this);this.qb=[]},addLoader:function(g){this.qb.push(g)},
359
+ loadContents:function(g,f){for(let m of this.qb)if(m.loadContents(g,f))return!0;return!1}});let k=h.computeAlignment;h.computeAlignment=function(g,f,m,n,r=1){return k.call(this,g,f,m,n,r)}};
360
+ const ka="createConicGradient createImageData createLinearGradient createPattern createRadialGradient getContextAttributes getImageData getLineDash getTransform isContextLost isPointInPath isPointInStroke measureText".split(" "),la=new function(){function b(){if(!a){var v=document.createElement("canvas"),x={alpha:1,depth:0,stencil:0,antialias:0,premultipliedAlpha:1,preserveDrawingBuffer:0,powerPreference:"high-performance",failIfMajorPerformanceCaveat:0,enableExtensionsByDefault:1,explicitSwapControl:1,
361
+ renderViaOffscreenBackBuffer:1};let q;if(/iPhone|iPad|iPod/i.test(navigator.userAgent)){if(q=v.getContext("webgl",x),c=1,!q)return console.log("No WebGL support. Image mesh will not be drawn."),!1}else if(q=v.getContext("webgl2",x))c=2;else if(q=v.getContext("webgl",x))c=1;else return console.log("No WebGL support. Image mesh will not be drawn."),!1;q=new Proxy(q,{get(I,u){if(I.isContextLost()){if(m||(console.error("Cannot render the mesh because the GL Context was lost. Tried to invoke ",u),m=!0),
362
+ "function"===typeof I[u])return function(){}}else return"function"===typeof I[u]?function(...J){return I[u].apply(I,J)}:I[u]},set(I,u,J){if(I.isContextLost())m||(console.error("Cannot render the mesh because the GL Context was lost. Tried to set property "+u),m=!0);else return I[u]=J,!0}});d=Math.min(q.getParameter(q.MAX_RENDERBUFFER_SIZE),q.getParameter(q.MAX_TEXTURE_SIZE));function L(I,u,J){u=q.createShader(u);q.shaderSource(u,J);q.compileShader(u);J=q.getShaderInfoLog(u);if(0<(J||"").length)throw J;
363
+ q.attachShader(I,u)}v=q.createProgram();L(v,q.VERTEX_SHADER,"attribute vec2 vertex;\n attribute vec2 uv;\n uniform vec4 mat;\n uniform vec2 translate;\n varying vec2 st;\n void main() {\n st = uv;\n gl_Position = vec4(mat2(mat) * vertex + translate, 0, 1);\n }");L(v,q.FRAGMENT_SHADER,"precision highp float;\n uniform sampler2D image;\n varying vec2 st;\n void main() {\n gl_FragColor = texture2D(image, st);\n }");
364
+ q.bindAttribLocation(v,0,"vertex");q.bindAttribLocation(v,1,"uv");q.linkProgram(v);x=q.getProgramInfoLog(v);if(0<(x||"").trim().length)throw x;e=q.getUniformLocation(v,"mat");k=q.getUniformLocation(v,"translate");q.useProgram(v);q.bindBuffer(q.ARRAY_BUFFER,q.createBuffer());q.enableVertexAttribArray(0);q.enableVertexAttribArray(1);q.bindBuffer(q.ELEMENT_ARRAY_BUFFER,q.createBuffer());q.uniform1i(q.getUniformLocation(v,"image"),0);q.pixelStorei(q.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0);a=q}return!0}let a=
365
+ null,c=0,d=0,e=null,k=null,g=0,f=0,m=!1;b();this.Zb=function(){b();return d};this.Kb=function(v){a&&a.deleteTexture&&a.deleteTexture(v)};this.Jb=function(v){if(!b())return null;const x=a.createTexture();if(!x)return null;a.bindTexture(a.TEXTURE_2D,x);a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,v);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR);2==
366
+ c?(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR_MIPMAP_LINEAR),a.generateMipmap(a.TEXTURE_2D)):a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR);return x};const n=new ia(8),r=new ia(8),w=new ia(10),z=new ia(10);this.Nb=function(v,x,q,L,I){if(b()){var u=n.push(v),J=r.push(x);if(a.canvas){if(a.canvas.width!=u||a.canvas.height!=J)a.canvas.width=u,a.canvas.height=J;a.viewport(0,J-x,v,x);a.disable(a.SCISSOR_TEST);a.clearColor(0,0,0,0);a.clear(a.COLOR_BUFFER_BIT);a.enable(a.SCISSOR_TEST);
367
+ q.sort((E,aa)=>aa.vb-E.vb);u=w.push(L);g!=u&&(a.bufferData(a.ARRAY_BUFFER,8*u,a.DYNAMIC_DRAW),g=u);u=0;for(var K of q)a.bufferSubData(a.ARRAY_BUFFER,u,K.ab),u+=4*K.ab.length;console.assert(u==4*L);for(var R of q)a.bufferSubData(a.ARRAY_BUFFER,u,R.yb),u+=4*R.yb.length;console.assert(u==8*L);u=z.push(I);f!=u&&(a.bufferData(a.ELEMENT_ARRAY_BUFFER,2*u,a.DYNAMIC_DRAW),f=u);K=0;for(var X of q)a.bufferSubData(a.ELEMENT_ARRAY_BUFFER,K,X.indices),K+=2*X.indices.length;console.assert(K==2*I);X=0;R=!0;u=K=0;
368
+ for(const E of q){E.image.Va!=X&&(a.bindTexture(a.TEXTURE_2D,E.image.Ta||null),X=E.image.Va);E.bc?(a.scissor(E.ib,J-E.jb-E.pb,E.jc,E.pb),R=!0):R&&(a.scissor(0,J-x,v,x),R=!1);q=2/v;const aa=-2/x;a.uniform4f(e,E.wa[0]*q*E.La,E.wa[1]*aa*E.Ma,E.wa[2]*q*E.La,E.wa[3]*aa*E.Ma);a.uniform2f(k,E.wa[4]*q*E.La+q*(E.ib-E.$b*E.La)-1,E.wa[5]*aa*E.Ma+aa*(E.jb-E.ac*E.Ma)+1);a.vertexAttribPointer(0,2,a.FLOAT,!1,0,u);a.vertexAttribPointer(1,2,a.FLOAT,!1,0,u+4*L);a.drawElements(a.TRIANGLES,E.indices.length,a.UNSIGNED_SHORT,
369
+ K);u+=4*E.ab.length;K+=2*E.indices.length}console.assert(u==4*L);console.assert(K==2*I)}}};this.canvas=function(){return b()&&a.canvas}},ma=h.onRuntimeInitialized;
370
+ h.onRuntimeInitialized=function(){function b(l){switch(l){case n.srcOver:return"source-over";case n.screen:return"screen";case n.overlay:return"overlay";case n.darken:return"darken";case n.lighten:return"lighten";case n.colorDodge:return"color-dodge";case n.colorBurn:return"color-burn";case n.hardLight:return"hard-light";case n.softLight:return"soft-light";case n.difference:return"difference";case n.exclusion:return"exclusion";case n.multiply:return"multiply";case n.hue:return"hue";case n.saturation:return"saturation";
371
+ case n.color:return"color";case n.luminosity:return"luminosity"}}function a(l){return"rgba("+((16711680&l)>>>16)+","+((65280&l)>>>8)+","+((255&l)>>>0)+","+((4278190080&l)>>>24)/255+")"}function c(){0<R.length&&(la.Nb(K.drawWidth(),K.drawHeight(),R,X,E),R=[],E=X=0,K.reset(512,512));for(const l of u){for(const p of l.na)p();l.na=[]}u.clear()}ma&&ma();var d=h.RenderPaintStyle;const e=h.RenderPath,k=h.RenderPaint,g=h.Renderer,f=h.StrokeCap,m=h.StrokeJoin,n=h.BlendMode,r=d.fill,w=d.stroke,z=h.FillRule.evenOdd;
372
+ let v=1;var x=h.RenderImage.extend("CanvasRenderImage",{__construct:function({Ba:l,Ka:p}={}){this.__parent.__construct.call(this);this.Va=v;v=v+1&2147483647||1;this.Ba=l;this.Ka=p},__destruct:function(){this.Ta&&(la.Kb(this.Ta),URL.revokeObjectURL(this.gb));this.__parent.__destruct.call(this)},decode:function(l){var p=this;p.Ka&&p.Ka(p);var A=new Image;p.gb=URL.createObjectURL(new Blob([l],{type:"image/png"}));A.onload=function(){p.Eb=A;p.Ta=la.Jb(A);p.size(A.width,A.height);p.Ba&&p.Ba(p)};A.src=
373
+ p.gb}});class q{constructor(){this.Da=this.Ha=0;this.sa=new Path2D}clear(){this.Da=this.Ha=0;this.sa=new Path2D}Hb(l){for(0<this.Ha&&this.Da<l.length&&this.clear();this.Da<l.length;)l[this.Da++](this.sa);this.Ha++;return this.sa}release(l){l===this.sa&&this.Ha--}}var L=e.extend("CanvasRenderPath",{__construct:function(){this.__parent.__construct.call(this);this.Ra=[];this.sa=new q;this.Qa=!1;this.za=null},rewind:function(){this.Ra.length=0;this.sa.clear();this.Qa=!1;this.za=null},addPath:function(l,
374
+ p,A,t,G,B,C){const y=l.Ab();this.ya(F=>{const H=new DOMMatrix;H.a=p;H.b=A;H.c=t;H.d=G;H.e=B;H.f=C;F.addPath(y,H)})},fillRule:function(l){this.fb=l},moveTo:function(l,p){this.Qa=!0;const A={kb:!0};this.za=A;this.ya(t=>{t.moveTo(l,p);A.kb&&t.lineTo(l,p)})},lineTo:function(l,p){this.eb();this.Oa();this.ya(A=>{A.lineTo(l,p)})},cubicTo:function(l,p,A,t,G,B){this.eb();this.Oa();this.ya(C=>{C.bezierCurveTo(l,p,A,t,G,B)})},close:function(){this.Oa();this.ya(l=>{l.closePath()})},eb:function(){this.Qa||this.moveTo(0,
375
+ 0)},Oa:function(){null!==this.za&&(this.za.kb=!1,this.za=null)},ya:function(l){this.Ra.push(l)},Na:function(){return this.sa.Hb(this.Ra)},hb:function(l){this.sa.release(l)},Ab:function(){const l=this.Na();this.sa.clear();return l}}),I=k.extend("CanvasRenderPaint",{__construct:function(){this.__parent.__construct.call(this);this.la=[];this.Pa=0;this.Sa=r;this.Wa=a(4278190080);this.Ua=1;this.Ga="miter";this.Fa="butt";this.bb=b(n.srcOver);this.va=null},color:function(l){this.la.push(()=>{this.Wa=a(l)})},
376
+ thickness:function(l){this.la.push(()=>{this.Ua=Math.abs(l)})},join:function(l){this.la.push(()=>{switch(l){case m.miter:this.Ga="miter";break;case m.round:this.Ga="round";break;case m.bevel:this.Ga="bevel"}})},cap:function(l){this.la.push(()=>{switch(l){case f.butt:this.Fa="butt";break;case f.round:this.Fa="round";break;case f.square:this.Fa="square"}})},style:function(l){this.la.push(()=>{this.Sa=l})},blendMode:function(l){this.la.push(()=>{this.bb=b(l)})},clearGradient:function(){this.la.push(()=>
377
+ {this.va=null})},linearGradient:function(l,p,A,t){this.la.push(()=>{this.va={wb:l,xb:p,mb:A,nb:t,$a:[]}})},radialGradient:function(l,p,A,t){this.la.push(()=>{this.va={wb:l,xb:p,mb:A,nb:t,$a:[],Xb:!0}})},addStop:function(l,p){this.la.push(()=>{this.va.$a.push({color:l,stop:p})})},completeGradient:function(){},Bb:function(l,p,A,t){if(this.Sa!==w||0<this.Ua){var G=this.Sa,B=this.Wa,C=this.va,y=l.globalCompositeOperation,F=l.globalAlpha;l.globalCompositeOperation=this.bb;l.globalAlpha=t;if(null!=C){B=
378
+ C.wb;const O=C.xb,Q=C.mb;var H=C.nb;t=C.$a;C.Xb?(C=Q-B,H-=O,B=l.createRadialGradient(B,O,0,B,O,Math.sqrt(C*C+H*H))):B=l.createLinearGradient(B,O,Q,H);for(let S=0,Aa=t.length;S<Aa;S++)C=t[S],B.addColorStop(C.stop,a(C.color));this.Wa=B;this.va=null}switch(G){case w:l.strokeStyle=B;l.lineWidth=this.Ua;l.lineCap=this.Fa;l.lineJoin=this.Ga;l.stroke(p);break;case r:l.fillStyle=B,l.fill(p,A)}l.globalCompositeOperation=y;l.globalAlpha=F}},Db:function(){return this.Pa+this.la.length},Cb:function(l){const p=
379
+ l-this.Pa;for(let A=0;A<p;A++)this.la[A]();this.la.splice(0,p);this.Pa=l}});const u=new Set,J=Object.prototype.hasOwnProperty;let K=null,R=[],X=0,E=0;var aa=h.CanvasRenderer=g.extend("Renderer",{__construct:function(l){this.__parent.__construct.call(this);this.ra=[1,0,0,1,0,0];this.ja=[1];this.ha=l.getContext("2d");this.cb=l;this.na=[]},save:function(){this.ra.push(...this.ra.slice(this.ra.length-6));this.ja.push(this.ja[this.ja.length-1]);this.na.push(this.ha.save.bind(this.ha))},restore:function(){const l=
380
+ this.ra.length-6;if(6>l)throw"restore() called without matching save().";this.ra.splice(l);this.ja.pop();this.na.push(this.ha.restore.bind(this.ha))},transform:function(l,p,A,t,G,B){const C=this.ra,y=C.length-6;C.splice(y,6,C[y]*l+C[y+2]*p,C[y+1]*l+C[y+3]*p,C[y]*A+C[y+2]*t,C[y+1]*A+C[y+3]*t,C[y]*G+C[y+2]*B+C[y+4],C[y+1]*G+C[y+3]*B+C[y+5]);this.na.push(this.ha.transform.bind(this.ha,l,p,A,t,G,B))},rotate:function(l){const p=Math.sin(l);l=Math.cos(l);this.transform(l,p,-p,l,0,0)},modulateOpacity:function(l){this.ja[this.ja.length-
381
+ 1]*=l},_drawPath:function(l,p){const A=l.fb===z?"evenodd":"nonzero",t=Math.max(0,this.ja[this.ja.length-1]),G=l.Na(),B=p.Db();this.na.push(()=>{p.Cb(B);p.Bb(this.ha,G,A,t);l.hb(G)})},_drawRiveImage:function(l,p,A){var t=l.Eb;if(t){var G=this.ha,B=b(p),C=Math.max(0,A*this.ja[this.ja.length-1]);this.na.push(function(){G.globalCompositeOperation=B;G.globalAlpha=C;G.drawImage(t,0,0);G.globalAlpha=1})}},_getMatrix:function(l){const p=this.ra,A=p.length-6;for(let t=0;6>t;++t)l[t]=p[A+t]},_drawImageMesh:function(l,
382
+ p,A,t,G,B,C,y,F,H,O,Q,S){let Aa,ob,pb;try{Aa=h.HEAPF32.slice(t>>2,(t>>2)+G),ob=h.HEAPF32.slice(B>>2,(B>>2)+C),pb=h.HEAPU16.slice(y>>1,(y>>1)+F)}catch(Ra){console.error("[Rive] _drawImageMesh: failed to read mesh data from WASM heap. Mesh skipped for this frame.");return}t=this.ha.canvas.width;B=this.ha.canvas.height;C=Q-H;y=S-O;H=Math.max(H,0);O=Math.max(O,0);Q=Math.min(Q,t);S=Math.min(S,B);const pa=Q-H,qa=S-O;console.assert(pa<=Math.min(C,t));console.assert(qa<=Math.min(y,B));if(!(0>=pa||0>=qa)){Q=
383
+ pa<C||qa<y;t=S=1;var da=Math.ceil(pa*S),ea=Math.ceil(qa*t);B=la.Zb();da>B&&(S*=B/da,da=B);ea>B&&(t*=B/ea,ea=B);K||(K=new h.DynamicRectanizer(B),K.reset(512,512));B=K.addRect(da,ea);0>B&&(c(),u.add(this),B=K.addRect(da,ea),console.assert(0<=B));var qb=B&65535,rb=B>>16;R.push({wa:this.ra.slice(this.ra.length-6),image:l,ib:qb,jb:rb,$b:H,ac:O,jc:da,pb:ea,La:S,Ma:t,ab:Aa,yb:ob,indices:pb,bc:Q,vb:l.Va<<1|(Q?1:0)});X+=G;E+=F;var ha=this.ha,cc=b(p),dc=Math.max(0,A*this.ja[this.ja.length-1]);this.na.push(function(){ha.save();
384
+ ha.resetTransform();ha.globalCompositeOperation=cc;ha.globalAlpha=dc;const Ra=la.canvas();Ra&&ha.drawImage(Ra,qb,rb,da,ea,H,O,pa,qa);ha.restore()})}},_clipPath:function(l){const p=l.fb===z?"evenodd":"nonzero",A=l.Na();this.na.push(()=>{this.ha.clip(A,p);l.hb(A)})},beginFrame:function(l=!0){u.add(this);l&&this.na.push(this.ha.clearRect.bind(this.ha,0,0,this.cb.width,this.cb.height))},clear:function(){this.beginFrame(!0)},flush:function(){},translate:function(l,p){this.transform(1,0,0,1,l,p)}});h.makeRenderer=
385
+ function(l){const p=new aa(l),A=p.ha;let t=null,G=null;const B={attachSession:function(y){if(y&&t===y)return!0;if(!y||t||"function"!==typeof h.c2dDeferredClaim||"function"!==typeof h.c2dDeferredRenderer||!h.c2dDeferredClaim(y))return!1;const F=h.c2dDeferredRenderer(y);if(!F)return!1;t=y;G=F;return!0},detachSession:function(){t&&h.c2dDeferredDetach(t);G=t=null},deferredActive:function(){return null!==G}},C={save:function(){h.c2dDeferredSave(t)},restore:function(){h.c2dDeferredRestore(t)},transform:function(y,
386
+ F,H,O,Q,S){h.c2dDeferredTransform(t,y,F,H,O,Q,S)},translate:function(y,F){h.c2dDeferredTransform(t,1,0,0,1,y,F)},rotate:function(y){const F=Math.sin(y);y=Math.cos(y);h.c2dDeferredTransform(t,y,F,-F,y,0,0)},align:function(y,F,H,O,Q){h.c2dDeferredAlign(t,y,F,H.minX,H.minY,H.maxX,H.maxY,O.minX,O.minY,O.maxX,O.maxY,void 0===Q?1:Q)},beginFrame:function(y=!0){p.beginFrame(y);h.c2dDeferredBeginFrame(t)},clear:function(){p.beginFrame(!0);h.c2dDeferredBeginFrame(t)},flush:function(){h.c2dDeferredReplay(t,
387
+ p)}};return new Proxy(p,{get(y,F){if(J.call(B,F))return B[F];if("_deferredRecorder"===F)return G;if(null!==G&&J.call(C,F))return C[F];if("function"===typeof y[F])return function(...H){return y[F].apply(y,H)};if("function"===typeof A[F]){if(-1<ka.indexOf(F))throw Error("RiveException: Method call to '"+F+"()' is not allowed, as the renderer cannot immediately pass through the return values of any canvas 2d context methods.");return function(...H){p.na.push(A[F].bind(A,...H))}}return y[F]},
388
+ set(y,F,H){if(F in A)return p.na.push(()=>{A[F]=H}),!0}})};h.decodeImage=function(l,p){(new x({Ba:p})).decode(l)};h.renderFactory={makeRenderPaint:function(){return new I},makeRenderPath:function(){return new L},makeRenderImage:function(){let l=Sa;return new x({Ka:()=>{l.total++},Ba:()=>{l.loaded++;if(l.loaded===l.total){const p=l.ready;p&&(p(),l.ready=null)}}})}};let ec=h.load,Sa=null;h.load=function(l,p,A=!0,t=null){const G=new h.FallbackFileAssetLoader;void 0!==p&&G.addLoader(p);A&&(p=new h.CDNFileAssetLoader(t),
389
+ G.addLoader(p));return new Promise(function(B){let C=null;Sa={total:0,loaded:0,ready:function(){B(C)}};C=ec(l,G,t??null);0==Sa.total&&B(C)})};const fc=h.Artboard.prototype.draw;h.Artboard.prototype.draw=function(l){fc.call(this,l._deferredRecorder||l)};let gc=h.RendererWrapper.prototype.align;h.RendererWrapper.prototype.align=function(l,p,A,t,G=1){gc.call(this,l,p,A,t,G)};d=new fa;h.requestAnimationFrame=d.requestAnimationFrame.bind(d);h.cancelAnimationFrame=d.cancelAnimationFrame.bind(d);h.enableFPSCounter=
390
+ d.Ob.bind(d);h.disableFPSCounter=d.Lb;d.rb=c;h.resolveAnimationFrame=c;h.cleanup=function(){K&&K.delete()}};var na="./this.program";ca&&(_scriptName=self.location.href);var oa="",ra,sa;
391
+ if(ba||ca){try{oa=(new URL(".",_scriptName)).href}catch{}ca&&(sa=b=>{var a=new XMLHttpRequest;a.open("GET",b,!1);a.responseType="arraybuffer";a.send(null);return new Uint8Array(a.response)});ra=async b=>{if(ta(b))return new Promise((c,d)=>{var e=new XMLHttpRequest;e.open("GET",b,!0);e.responseType="arraybuffer";e.onload=()=>{200==e.status||0==e.status&&e.response?c(e.response):d(e.status)};e.onerror=d;e.send(null)});var a=await fetch(b,{credentials:"same-origin"});if(a.ok)return a.arrayBuffer();throw Error(a.status+
392
+ " : "+a.url);}}var ua=console.log.bind(console),va=console.error.bind(console),wa,xa=!1,ya,ta=b=>b.startsWith("file://"),za,Ba,Ca,D,Da,Ea,Fa,M,Ga,Ha,Ia,Ja,Ka=!1;function La(){var b=Ma.buffer;h.HEAP8=Ca=new Int8Array(b);Da=new Int16Array(b);h.HEAPU8=D=new Uint8Array(b);h.HEAPU16=Ea=new Uint16Array(b);h.HEAP32=Fa=new Int32Array(b);h.HEAPU32=M=new Uint32Array(b);h.HEAPF32=Ga=new Float32Array(b);Ha=new Float64Array(b);Ia=new BigInt64Array(b);Ja=new BigUint64Array(b)}
393
+ function Na(b){h.onAbort?.(b);b="Aborted("+b+")";va(b);xa=!0;b=new WebAssembly.RuntimeError(b+". Build with -sASSERTIONS for more info.");Ba?.(b);throw b;}var Oa;async function Pa(b){if(!wa)try{var a=await ra(b);return new Uint8Array(a)}catch{}if(b==Oa&&wa)b=new Uint8Array(wa);else if(sa)b=sa(b);else throw"both async and sync fetching of the wasm failed";return b}
394
+ async function Qa(b,a){try{var c=await Pa(b);return await WebAssembly.instantiate(c,a)}catch(d){va(`failed to asynchronously prepare wasm: ${d}`),Na(d)}}async function Ta(b){var a=Oa;if(!wa&&!ta(a))try{var c=fetch(a,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(c,b)}catch(d){va(`wasm streaming compile failed: ${d}`),va("falling back to ArrayBuffer instantiation")}return Qa(a,b)}
395
+ class Ua{name="ExitStatus";constructor(b){this.message=`Program terminated with exit(${b})`;this.status=b}}
396
+ var Va=b=>{for(;0<b.length;)b.shift()(h)},Wa=[],Xa=[],Ya=()=>{var b=h.preRun.shift();Xa.push(b)},Za=!0,$a=(b,a)=>Object.defineProperty(a,"name",{value:b}),ab=[],bb=[0,1,,1,null,1,!0,1,!1,1],N=class extends Error{constructor(b){super(b);this.name="BindingError"}},P=b=>{if(!b)throw new N(`Cannot use deleted val. handle = ${b}`);return bb[b]},T=b=>{switch(b){case void 0:return 2;case null:return 4;case !0:return 6;case !1:return 8;default:const a=ab.pop()||bb.length;bb[a]=b;bb[a+1]=1;return a}};
397
+ class cb extends Error{}
398
+ var U=b=>{for(var a="";;){var c=D[b++];if(!c)return a;a+=String.fromCharCode(c)}},db={},eb=(b,a)=>{if(void 0===a)throw new N("ptr should not be undefined");for(;b.ga;)a=b.Ca(a),b=b.ga;return a},fb={},ib=b=>{b=gb(b);var a=U(b);hb(b);return a},jb=(b,a)=>{var c=fb[b];if(void 0===c)throw b=`${a} has unknown type ${ib(b)}`,new N(b);return c},kb=()=>{},lb=!1,mb=b=>{if(!globalThis.FinalizationRegistry)return mb=a=>a,b;lb=new FinalizationRegistry(a=>{a=a.$;--a.count.value;0===a.count.value&&(a.ia?a.oa.qa(a.ia):
399
+ a.da.aa.qa(a.ca))});mb=a=>{var c=a.$;c.ia&&lb.register(a,{$:c},a);return a};kb=a=>{lb.unregister(a)};return mb(b)},nb={},sb=b=>{for(;b.length;){var a=b.pop();b.pop()(a)}};function tb(b){return this.ba(M[b>>2])}
400
+ var ub={},vb={},wb=class extends Error{constructor(b){super(b);this.name="InternalError"}},W=(b,a,c)=>{function d(f){f=c(f);if(f.length!==b.length)throw new wb("Mismatched type converter count");for(var m=0;m<b.length;++m)V(b[m],f[m])}b.forEach(f=>vb[f]=a);var e=Array(a.length),k=[],g=0;for(let [f,m]of a.entries())fb.hasOwnProperty(m)?e[f]=fb[m]:(k.push(m),ub.hasOwnProperty(m)||(ub[m]=[]),ub[m].push(()=>{e[f]=fb[m];++g;g===k.length&&d(e)}));0===k.length&&d(e)};
401
+ function xb(b,a,c={}){var d=a.name;if(!b)throw new N(`type "${d}" must have a positive integer typeid pointer`);if(fb.hasOwnProperty(b)){if(c.Wb)return;throw new N(`Cannot register type '${d}' twice`);}fb[b]=a;delete vb[b];ub.hasOwnProperty(b)&&(a=ub[b],delete ub[b],a.forEach(e=>e()))}function V(b,a,c={}){return xb(b,a,c)}
402
+ var yb=(b,a,c)=>{switch(a){case 1:return c?d=>Ca[d]:d=>D[d];case 2:return c?d=>Da[d>>1]:d=>Ea[d>>1];case 4:return c?d=>Fa[d>>2]:d=>M[d>>2];case 8:return c?d=>Ia[d>>3]:d=>Ja[d>>3];default:throw new TypeError(`invalid integer width (${a}): ${b}`);}},zb=b=>{throw new N(b.$.da.aa.name+" instance already deleted");},Ab=[];function Bb(){}
403
+ var Cb={},Db=(b,a,c)=>{if(void 0===b[a].fa){var d=b[a];b[a]=function(...e){if(!b[a].fa.hasOwnProperty(e.length))throw new N(`Function '${c}' called with an invalid number of arguments (${e.length}) - expects one of (${b[a].fa})!`);return b[a].fa[e.length].apply(this,e)};b[a].fa=[];b[a].fa[d.ta]=d}},Eb=(b,a,c)=>{if(h.hasOwnProperty(b)){if(void 0===c||void 0!==h[b].fa&&void 0!==h[b].fa[c])throw new N(`Cannot register public name '${b}' twice`);Db(h,b,b);if(h[b].fa.hasOwnProperty(c))throw new N(`Cannot register multiple overloads of a function with the same number of arguments (${c})!`);
404
+ h[b].fa[c]=a}else h[b]=a,h[b].ta=c},Fb=b=>{b=b.replace(/[^a-zA-Z0-9_]/g,"$");var a=b.charCodeAt(0);return 48<=a&&57>=a?`_${b}`:b};function Gb(b,a,c,d,e,k,g,f){this.name=b;this.constructor=a;this.pa=c;this.qa=d;this.ga=e;this.Rb=k;this.Ca=g;this.Mb=f;this.sb=[]}
405
+ var Hb=(b,a,c)=>{for(;a!==c;){if(!a.Ca)throw new N(`Expected null or instance of ${c.name}, got an instance of ${a.name}`);b=a.Ca(b);a=a.ga}return b},Ib=b=>{if(null===b)return"null";var a=typeof b;return"object"===a||"array"===a||"function"===a?b.toString():""+b};
406
+ function Jb(b,a){if(null===a){if(this.Xa)throw new N(`null is not a valid ${this.name}`);return 0}if(!a.$)throw new N(`Cannot pass "${Ib(a)}" as a ${this.name}`);if(!a.$.ca)throw new N(`Cannot pass deleted object as a pointer of type ${this.name}`);return Hb(a.$.ca,a.$.da.aa,this.aa)}
407
+ function Kb(b,a){if(null===a){if(this.Xa)throw new N(`null is not a valid ${this.name}`);if(this.Ja){var c=this.Za();null!==b&&b.push(this.qa,c);return c}return 0}if(!a||!a.$)throw new N(`Cannot pass "${Ib(a)}" as a ${this.name}`);if(!a.$.ca)throw new N(`Cannot pass deleted object as a pointer of type ${this.name}`);if(!this.Ia&&a.$.da.Ia)throw new N(`Cannot convert argument of type ${a.$.oa?a.$.oa.name:a.$.da.name} to parameter type ${this.name}`);c=Hb(a.$.ca,a.$.da.aa,this.aa);if(this.Ja){if(void 0===
408
+ a.$.ia)throw new N("Passing raw pointer to smart pointer is illegal");switch(this.ic){case 0:if(a.$.oa===this)c=a.$.ia;else throw new N(`Cannot convert argument of type ${a.$.oa?a.$.oa.name:a.$.da.name} to parameter type ${this.name}`);break;case 1:c=a.$.ia;break;case 2:if(a.$.oa===this)c=a.$.ia;else{var d=a.clone();c=this.dc(c,T(()=>d["delete"]()));null!==b&&b.push(this.qa,c)}break;default:throw new N("Unsupported sharing policy");}}return c}
409
+ function Lb(b,a){if(null===a){if(this.Xa)throw new N(`null is not a valid ${this.name}`);return 0}if(!a.$)throw new N(`Cannot pass "${Ib(a)}" as a ${this.name}`);if(!a.$.ca)throw new N(`Cannot pass deleted object as a pointer of type ${this.name}`);if(a.$.da.Ia)throw new N(`Cannot convert argument of type ${a.$.da.name} to parameter type ${this.name}`);return Hb(a.$.ca,a.$.da.aa,this.aa)}
410
+ var Mb=(b,a,c)=>{if(a===c)return b;if(void 0===c.ga)return null;b=Mb(b,a,c.ga);return null===b?null:c.Mb(b)},Nb=(b,a)=>{a=eb(b,a);return db[a]},Ob=(b,a)=>{if(!a.da||!a.ca)throw new wb("makeClassHandle requires ptr and ptrType");if(!!a.oa!==!!a.ia)throw new wb("Both smartPtrType and smartPtr must be specified");a.count={value:1};return mb(Object.create(b,{$:{value:a,writable:!0}}))};
411
+ function Pb(b,a,c,d,e,k,g,f,m,n,r){this.name=b;this.aa=a;this.Xa=c;this.Ia=d;this.Ja=e;this.cc=k;this.ic=g;this.tb=f;this.Za=m;this.dc=n;this.qa=r;e||void 0!==a.ga?this.ea=Kb:(this.ea=d?Jb:Lb,this.ka=null)}var Qb=(b,a,c)=>{if(!h.hasOwnProperty(b))throw new wb("Replacing nonexistent public symbol");void 0!==h[b].fa&&void 0!==c?h[b].fa[c]=a:(h[b]=a,h[b].ta=c)},Y=(b,a)=>{b=U(b);var c=Rb.get(a);if("function"!=typeof c)throw new N(`unknown function pointer with signature ${b}: ${a}`);return c};
412
+ class Sb extends Error{}var Z=(b,a)=>{function c(k){e[k]||fb[k]||(vb[k]?vb[k].forEach(c):(d.push(k),e[k]=!0))}var d=[],e={};a.forEach(c);throw new Sb(`${b}: `+d.map(ib).join([", "]));};function Tb(b){for(var a=1;a<b.length;++a)if(null!==b[a]&&void 0===b[a].ka)return!0;return!1}
413
+ function Ub(b,a,c,d,e){var k=a.length;if(2>k)throw new N("argTypes array size mismatch! Must at least get return value and 'this' types!");var g=null!==a[1]&&null!==c,f=Tb(a),m=!a[0].Yb,n=k-2,r=Array(n),w=[],z=[];return $a(b,function(...v){z.length=0;w.length=g?2:1;w[0]=e;if(g){var x=a[1].ea(z,this);w[1]=x}for(var q=0;q<n;++q)r[q]=a[q+2].ea(z,v[q]),w.push(r[q]);v=d(...w);if(f)sb(z);else for(q=g?1:2;q<a.length;q++){var L=1===q?x:r[q-2];null!==a[q].ka&&a[q].ka(L)}x=m?a[0].ba(v):void 0;return x})}
414
+ var Vb=(b,a)=>{for(var c=[],d=0;d<b;d++)c.push(M[a+4*d>>2]);return c},Wb=b=>{b=b.trim();const a=b.indexOf("(");return-1===a?b:b.slice(0,a)},Xb=(b,a,c)=>{if(!(b instanceof Object))throw new N(`${c} with invalid "this": ${b}`);if(!(b instanceof a.aa.constructor))throw new N(`${c} incompatible with "this" of type ${b.constructor.name}`);if(!b.$.ca)throw new N(`cannot call emscripten binding method ${c} on deleted object`);return Hb(b.$.ca,b.$.da.aa,a.aa)},Yb=b=>{9<b&&0===--bb[b+1]&&(bb[b]=void 0,ab.push(b))},
415
+ Zb={name:"emscripten::val",ba:b=>{var a=P(b);Yb(b);return a},ea:(b,a)=>T(a),ma:tb,ka:null},$b=(b,a,c)=>{switch(a){case 1:return c?function(d){return this.ba(Ca[d])}:function(d){return this.ba(D[d])};case 2:return c?function(d){return this.ba(Da[d>>1])}:function(d){return this.ba(Ea[d>>1])};case 4:return c?function(d){return this.ba(Fa[d>>2])}:function(d){return this.ba(M[d>>2])};default:throw new TypeError(`invalid integer width (${a}): ${b}`);}},ac=(b,a)=>{switch(a){case 4:return function(c){return this.ba(Ga[c>>
416
+ 2])};case 8:return function(c){return this.ba(Ha[c>>3])};default:throw new TypeError(`invalid float width (${a}): ${b}`);}},bc=(b,a,c)=>{var d=D;if(!(0<c))return 0;var e=a;c=a+c-1;for(var k=0;k<b.length;++k){var g=b.codePointAt(k);if(127>=g){if(a>=c)break;d[a++]=g}else if(2047>=g){if(a+1>=c)break;d[a++]=192|g>>6;d[a++]=128|g&63}else if(65535>=g){if(a+2>=c)break;d[a++]=224|g>>12;d[a++]=128|g>>6&63;d[a++]=128|g&63}else{if(a+3>=c)break;d[a++]=240|g>>18;d[a++]=128|g>>12&63;d[a++]=128|g>>6&63;d[a++]=128|
417
+ g&63;k++}}d[a]=0;return a-e},hc=b=>{for(var a=0,c=0;c<b.length;++c){var d=b.charCodeAt(c);127>=d?a++:2047>=d?a+=2:55296<=d&&57343>=d?(a+=4,++c):a+=3}return a},ic=globalThis.TextDecoder&&new TextDecoder,jc=(b,a,c,d)=>{c=a+c;if(d)return c;for(;b[a]&&!(a>=c);)++a;return a},kc=(b,a=0,c,d)=>{c=jc(b,a,c,d);if(16<c-a&&b.buffer&&ic)return ic.decode(b.subarray(a,c));for(d="";a<c;){var e=b[a++];if(e&128){var k=b[a++]&63;if(192==(e&224))d+=String.fromCharCode((e&31)<<6|k);else{var g=b[a++]&63;e=224==(e&240)?
418
+ (e&15)<<12|k<<6|g:(e&7)<<18|k<<12|g<<6|b[a++]&63;65536>e?d+=String.fromCharCode(e):(e-=65536,d+=String.fromCharCode(55296|e>>10,56320|e&1023))}}else d+=String.fromCharCode(e)}return d},lc=globalThis.TextDecoder?new TextDecoder("utf-16le"):void 0,mc=(b,a,c)=>{b>>=1;a=jc(Ea,b,a/2,c);if(16<a-b&&lc)return lc.decode(Ea.subarray(b,a));for(c="";b<a;++b)c+=String.fromCharCode(Ea[b]);return c},nc=(b,a,c)=>{c??=2147483647;if(2>c)return 0;c-=2;var d=a;c=c<2*b.length?c/2:b.length;for(var e=0;e<c;++e)Da[a>>1]=
419
+ b.charCodeAt(e),a+=2;Da[a>>1]=0;return a-d},oc=b=>2*b.length,pc=(b,a,c)=>{var d="";b>>=2;for(var e=0;!(e>=a/4);e++){var k=M[b+e];if(!k&&!c)break;d+=String.fromCodePoint(k)}return d},qc=(b,a,c)=>{c??=2147483647;if(4>c)return 0;var d=a;c=d+c-4;for(var e=0;e<b.length;++e){var k=b.codePointAt(e);65535<k&&e++;Fa[a>>2]=k;a+=4;if(a+4>c)break}Fa[a>>2]=0;return a-d},rc=b=>{for(var a=0,c=0;c<b.length;++c)65535<b.codePointAt(c)&&c++,a+=4;return a},sc=0,tc=[],uc=b=>{var a=tc.length;tc.push(b);return a},vc=(b,
420
+ a)=>{for(var c=Array(b),d=0;d<b;++d)c[d]=jb(M[a+4*d>>2],`parameter ${d}`);return c},wc={},xc=b=>{var a=wc[b];return void 0===a?U(b):a},yc={},zc=b=>{if(!(b instanceof Ua||"unwind"==b))throw b;},Ac=b=>{ya=b;Za||0<sc||(h.onExit?.(b),xa=!0);throw new Ua(b);},Bc=b=>{if(!xa)try{if(b(),!(Za||0<sc))try{ya=b=ya,Ac(b)}catch(a){zc(a)}}catch(a){zc(a)}},Cc={},Ec=()=>{if(!Dc){var b={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-",
421
+ "_")+".UTF-8",_:na||"./this.program"},a;for(a in Cc)void 0===Cc[a]?delete b[a]:b[a]=Cc[a];var c=[];for(a in b)c.push(`${a}=${b[a]}`);Dc=c}return Dc},Dc,Fc=[null,[],[]];
422
+ (()=>{let b=Bb.prototype;Object.assign(b,{isAliasOf:function(c){if(!(this instanceof Bb&&c instanceof Bb))return!1;var d=this.$.da.aa,e=this.$.ca;c.$=c.$;var k=c.$.da.aa;for(c=c.$.ca;d.ga;)e=d.Ca(e),d=d.ga;for(;k.ga;)c=k.Ca(c),k=k.ga;return d===k&&e===c},clone:function(){this.$.ca||zb(this);if(this.$.xa)return this.$.count.value+=1,this;var c=mb,d=Object,e=d.create,k=Object.getPrototypeOf(this),g=this.$;c=c(e.call(d,k,{$:{value:{count:g.count,Aa:g.Aa,xa:g.xa,ca:g.ca,da:g.da,ia:g.ia,oa:g.oa}}}));c.$.count.value+=
423
+ 1;c.$.Aa=!1;return c},["delete"](){this.$.ca||zb(this);if(this.$.Aa&&!this.$.xa)throw new N("Object already scheduled for deletion");kb(this);var c=this.$;--c.count.value;0===c.count.value&&(c.ia?c.oa.qa(c.ia):c.da.aa.qa(c.ca));this.$.xa||(this.$.ia=void 0,this.$.ca=void 0)},isDeleted:function(){return!this.$.ca},deleteLater:function(){this.$.ca||zb(this);if(this.$.Aa&&!this.$.xa)throw new N("Object already scheduled for deletion");Ab.push(this);this.$.Aa=!0;return this}});const a=Symbol.dispose;
419
424
  a&&(b[a]=b["delete"])})();
420
- Object.assign(Pb.prototype,{zb(b){this.cb&&(b=this.cb(b));return b},Va(b){this.pa?.(b)},la:tb,ba:function(b){function a(){return this.Ca?Ob(this.aa.oa,{da:this.Kb,ca:c,na:this,ia:b}):Ob(this.aa.oa,{da:this,ca:b})}var c=this.zb(b);if(!c)return this.Va(b),null;var d=Nb(this.aa,c);if(void 0!==d){if(0===d.$.count.value)return d.$.ca=c,d.$.ia=b,d.clone();d=d.clone();this.Va(b);return d}d=this.aa.yb(c);d=Cb[d];if(!d)return a.call(this);d=this.Ba?d.pb:d.pointerType;var e=Mb(c,this.aa,d.aa);return null===
421
- e?a.call(this):this.Ca?Ob(d.aa.oa,{da:d,ca:e,na:this,ia:b}):Ob(d.aa.oa,{da:d,ca:e})}});k.noExitRuntime&&(Ya=k.noExitRuntime);k.print&&(va=k.print);k.printErr&&(wa=k.printErr);k.wasmBinary&&(xa=k.wasmBinary);k.thisProgram&&(oa=k.thisProgram);if(k.preInit)for("function"==typeof k.preInit&&(k.preInit=[k.preInit]);0<k.preInit.length;)k.preInit.shift()();
422
- var gb,Ec,fb,Fc,Ma,Rb,Gc={E:()=>Na(""),n:(b,a,c)=>{b=Q(b);a=ib(a,"wrapper");c=M(c);var d=a.aa,e=d.oa,f=d.ha.oa,h=d.ha.constructor;b=Za(b,function(...g){for(var m of d.ha.bb)if(this[m]===f[m])throw new bb(`Pure virtual function ${m} must be implemented in JavaScript`);Object.defineProperty(this,"__parent",{value:e});this.__construct(...g)});e.__construct=function(...g){if(this===e)throw new K("Pass correct 'this' to __construct");g=h.implement(this,...g);jb(g);var m=g.$;g.notifyOnDestruction();m.va=
423
- !0;Object.defineProperties(this,{$:{value:m}});lb(this);g=m.ca;g=db(d,g);if(cb.hasOwnProperty(g))throw new K(`Tried to register registered instance: ${g}`);cb[g]=this};e.__destruct=function(){if(this===e)throw new K("Pass correct 'this' to __destruct");jb(this);var g=this.$.ca;g=db(d,g);if(cb.hasOwnProperty(g))delete cb[g];else throw new K(`Tried to unregister unregistered instance: ${g}`);};b.prototype=Object.create(e);Object.assign(b.prototype,c);return P(b)},N:b=>{var a=mb[b];delete mb[b];var c=
424
- a.Ma,d=a.pa,e=a.Ya,f=e.map(h=>h.Cb).concat(e.map(h=>h.Nb));W([b],f,h=>{var g={},m,n;for([m,n]of e.entries()){const u=h[m],x=n.Ab,w=n.Bb,t=h[m+e.length],v=n.Mb,p=n.Ob;g[n.wb]={read:I=>u.ba(x(w,I)),write:(I,F)=>{var r=[];v(p,I,t.ea(r,F));sb(r)},optional:u.optional}}return[{name:a.name,ba:u=>{var x={},w;for(w in g)x[w]=g[w].read(u);d(u);return x},ea:(u,x)=>{for(var w in g)if(!(w in x||g[w].optional))throw new TypeError(`Missing field: "${w}"`);var t=c();for(w in g)g[w].write(t,x[w]);null!==u&&u.push(d,
425
- t);return t},la:tb,ka:d}]})},r:(b,a,c,d,e)=>{a=Q(a);d=0n===d;let f=h=>h;if(d){const h=8*c;f=g=>BigInt.asUintN(h,g);e=f(e)}T(b,{name:a,ba:f,ea:(h,g)=>{"number"==typeof g&&(g=BigInt(g));return g},la:yb(a,c,!d),ka:null})},H:(b,a,c,d)=>{a=Q(a);T(b,{name:a,ba:function(e){return!!e},ea:function(e,f){return f?c:d},la:function(e){return this.ba(z[e])},ka:null})},c:(b,a,c,d,e,f,h,g,m,n,u,x,w)=>{u=Q(u);f=Y(e,f);g&&=Y(h,g);n&&=Y(m,n);w=Y(x,w);var t=Fb(u);Eb(t,function(){Z(`Cannot construct ${u} due to unbound types`,
426
- [d])});W([b,a,c],d?[d]:[],v=>{v=v[0];if(d){var p=v.aa;var I=p.oa}else I=Bb.prototype;v=Za(u,function(...L){if(Object.getPrototypeOf(this)!==F)throw new K(`Use 'new' to construct ${u}`);if(void 0===r.ta)throw new K(`${u} has no accessible constructor`);var O=r.ta[L.length];if(void 0===O)throw new K(`Tried to invoke ctor of ${u} with invalid number of parameters (${L.length}) - expected (${Object.keys(r.ta).toString()}) parameters instead!`);return O.apply(this,L)});var F=Object.create(I,{constructor:{value:v}});
427
- v.prototype=F;var r=new Gb(u,v,F,w,p,f,g,n);if(r.ha){var G;(G=r.ha).Aa??(G.Aa=[]);r.ha.Aa.push(r)}p=new Pb(u,r,!0,!1,!1);G=new Pb(u+"*",r,!1,!1,!1);I=new Pb(u+" const*",r,!1,!0,!1);Cb[b]={pointerType:G,pb:I};Qb(t,v);return[p,G,I]})},j:(b,a,c,d,e,f,h)=>{var g=Vb(c,d);a=Q(a);a=Wb(a);f=Y(e,f);W([],[b],m=>{function n(){Z(`Cannot call ${u} due to unbound types`,g)}m=m[0];var u=`${m.name}.${a}`;a.startsWith("@@")&&(a=Symbol[a.substring(2)]);var x=m.aa.constructor;void 0===x[a]?(n.sa=c-1,x[a]=n):(Db(x,a,
428
- u),x[a].fa[c-1]=n);W([],g,w=>{w=Ub(u,[w[0],null].concat(w.slice(1)),null,f,h);void 0===x[a].fa?(w.sa=c-1,x[a]=w):x[a].fa[c-1]=w;if(m.aa.Aa)for(const t of m.aa.Aa)t.constructor.hasOwnProperty(a)||(t.constructor[a]=w);return[]});return[]})},p:(b,a,c,d,e,f,h,g)=>{a=Q(a);f=Y(e,f);W([],[b],m=>{m=m[0];var n=`${m.name}.${a}`,u={get(){Z(`Cannot access ${n} due to unbound types`,[c])},enumerable:!0,configurable:!0};u.set=g?()=>{Z(`Cannot access ${n} due to unbound types`,[c])}:()=>{throw new K(`${n} is a read-only property`);
429
- };Object.defineProperty(m.aa.constructor,a,u);W([],[c],x=>{x=x[0];var w={get(){return x.ba(f(d))},enumerable:!0};g&&(g=Y(h,g),w.set=t=>{var v=[];g(d,x.ea(v,t));sb(v)});Object.defineProperty(m.aa.constructor,a,w);return[]});return[]})},m:(b,a,c,d,e,f)=>{var h=Vb(a,c);e=Y(d,e);W([],[b],g=>{g=g[0];var m=`constructor ${g.name}`;void 0===g.aa.ta&&(g.aa.ta=[]);if(void 0!==g.aa.ta[a-1])throw new K(`Cannot register multiple constructors with identical number of parameters (${a-1}) for class '${g.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);
430
- g.aa.ta[a-1]=()=>{Z(`Cannot construct ${g.name} due to unbound types`,h)};W([],h,n=>{n.splice(1,0,null);g.aa.ta[a-1]=Ub(m,n,null,e,f);return[]});return[]})},a:(b,a,c,d,e,f,h,g)=>{var m=Vb(c,d);a=Q(a);a=Wb(a);f=Y(e,f);W([],[b],n=>{function u(){Z(`Cannot call ${x} due to unbound types`,m)}n=n[0];var x=`${n.name}.${a}`;a.startsWith("@@")&&(a=Symbol[a.substring(2)]);g&&n.aa.bb.push(a);var w=n.aa.oa,t=w[a];void 0===t||void 0===t.fa&&t.className!==n.name&&t.sa===c-2?(u.sa=c-2,u.className=n.name,w[a]=u):
431
- (Db(w,a,x),w[a].fa[c-2]=u);W([],m,v=>{v=Ub(x,v,n,f,h);void 0===w[a].fa?(v.sa=c-2,w[a]=v):w[a].fa[c-2]=v;return[]});return[]})},b:(b,a,c,d,e,f,h,g,m,n)=>{a=Q(a);e=Y(d,e);W([],[b],u=>{u=u[0];var x=`${u.name}.${a}`,w={get(){Z(`Cannot access ${x} due to unbound types`,[c,h])},enumerable:!0,configurable:!0};w.set=m?()=>Z(`Cannot access ${x} due to unbound types`,[c,h]):()=>{throw new K(x+" is a read-only property");};Object.defineProperty(u.aa.oa,a,w);W([],m?[c,h]:[c],t=>{var v=t[0],p={get(){var F=Xb(this,
432
- u,x+" getter");return v.ba(e(f,F))},enumerable:!0};if(m){m=Y(g,m);var I=t[1];p.set=function(F){var r=Xb(this,u,x+" setter"),G=[];m(n,r,I.ea(G,F));sb(G)}}Object.defineProperty(u.aa.oa,a,p);return[]});return[]})},F:b=>T(b,Zb),l:(b,a,c,d,e)=>{a=Q(a);e=0===e?"object":1===e?"number":"string";switch(e){case "object":function h(){}h.values={};T(b,{name:a,constructor:h,valueType:e,ba:function(g){return this.constructor.values[g]},ea:(g,m)=>m.value,la:$b(a,c,d),ka:null});Eb(a,h);break;case "number":var f=
433
- {};T(b,{name:a,La:f,valueType:e,ba:g=>g,ea:(g,m)=>m,la:$b(a,c,d),ka:null});Eb(a,f);delete k[a].sa;break;case "string":f={},T(b,{name:a,jb:{},eb:{},La:f,valueType:e,ba:function(g){return this.eb[g]},ea:function(g,m){return this.jb[m]},la:$b(a,c,d),ka:null}),Eb(a,f),delete k[a].sa}},d:(b,a,c)=>{var d=ib(b,"enum");a=Q(a);switch(d.valueType){case "object":b=d.constructor;d=Object.create(d.constructor.prototype,{value:{value:c},constructor:{value:Za(`${d.name}_${a}`,function(){})}});b.values[c]=d;b[a]=
434
- d;break;case "number":d.La[a]=c;break;case "string":d.jb[a]=c,d.eb[c]=a,d.La[a]=a}},q:(b,a,c)=>{a=Q(a);T(b,{name:a,ba:d=>d,ea:(d,e)=>e,la:ac(a,c),ka:null})},i:(b,a,c,d,e,f)=>{var h=Vb(a,c);b=Q(b);b=Wb(b);e=Y(d,e);Eb(b,function(){Z(`Cannot call ${b} due to unbound types`,h)},a-1);W([],h,g=>{Qb(b,Ub(b,[g[0],null].concat(g.slice(1)),null,e,f),a-1);return[]})},k:(b,a,c,d,e)=>{a=Q(a);let f=g=>g;if(0===d){var h=32-8*c;f=g=>g<<h>>>h;e=f(e)}T(b,{name:a,ba:f,ea:(g,m)=>m,la:yb(a,c,0!==d),ka:null})},h:(b,a,
435
- c)=>{function d(f){return new e(Ca.buffer,J[f+4>>2],J[f>>2])}var e=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array][a];c=Q(c);T(b,{name:c,ba:d,la:d},{Db:!0})},G:(b,a)=>{a=Q(a);T(b,{name:a,ba(c){var d=(d=c+4)?ic(z,d,J[c>>2],!0):"";gb(c);return d},ea(c,d){d instanceof ArrayBuffer&&(d=new Uint8Array(d));var e="string"==typeof d;if(!(e||ArrayBuffer.isView(d)&&1==d.BYTES_PER_ELEMENT))throw new K("Cannot pass non-string to std::string");
436
- var f=e?fc(d):d.length;var h=Ec(4+f+1),g=h+4;J[h>>2]=f;e?bc(d,g,f+1):z.set(d,g);null!==c&&c.push(gb,h);return h},la:tb,ka(c){gb(c)}})},o:(b,a,c)=>{c=Q(c);if(2===a){var d=kc;var e=lc;var f=mc}else d=nc,e=oc,f=pc;T(b,{name:c,ba:h=>{var g=d(h+4,J[h>>2]*a,!0);gb(h);return g},ea:(h,g)=>{if("string"!=typeof g)throw new K(`Cannot pass non-string to C++ string type ${c}`);var m=f(g),n=Ec(4+m+a);J[n>>2]=m/a;e(g,n+4,m+a);null!==h&&h.push(gb,n);return n},la:tb,ka(h){gb(h)}})},P:(b,a,c,d,e,f)=>{mb[b]={name:Q(a),
437
- Ma:Y(c,d),pa:Y(e,f),Ya:[]}},O:(b,a,c,d,e,f,h,g,m,n)=>{mb[b].Ya.push({wb:Q(a),Cb:c,Ab:Y(d,e),Bb:f,Nb:h,Mb:Y(g,m),Ob:n})},I:(b,a)=>{a=Q(a);T(b,{Fb:!0,name:a,ba:()=>{},ea:()=>{}})},u:()=>{Ya=!1;qc=0},f:(b,a,c)=>{var [d,...e]=tc(b,a),f=d.ea.bind(d),h=e.map(m=>m.la.bind(m));b--;var g=Array(b);a=`methodCaller<(${e.map(m=>m.name)}) => ${d.name}>`;return sc(Za(a,(m,n,u,x)=>{for(var w=0,t=0;t<b;++t)g[t]=h[t](x+w),w+=8;switch(c){case 0:var v=M(m).apply(null,g);break;case 2:v=Reflect.construct(M(m),g);break;
438
- case 3:v=g[0];break;case 1:v=M(m)[vc(n)](...g)}m=[];v=f(m,v);m.length&&(J[u>>2]=P(m));return v}))},R:Yb,J:b=>{b=vc(b);return P(k[b])},K:(b,a)=>{b=M(b);a=M(a);return P(b[a])},L:b=>{9<b&&(ab[b+1]+=1)},e:(b,a,c,d,e)=>rc[b](a,c,d,e),M:()=>P([]),s:b=>P(vc(b)),S:()=>P({}),Q:b=>{var a=M(b);sb(a);Yb(b)},g:(b,a,c)=>{b=M(b);a=M(a);c=M(c);b[a]=c},v:(b,a)=>{wc[b]&&(clearTimeout(wc[b].id),delete wc[b]);if(!a)return 0;var c=setTimeout(()=>{delete wc[b];zc(()=>Fc(b,performance.now()))},a);wc[b]={id:c,Rb:a};return 0},
439
- w:(b,a,c,d)=>{var e=(new Date).getFullYear(),f=(new Date(e,0,1)).getTimezoneOffset();e=(new Date(e,6,1)).getTimezoneOffset();J[b>>2]=60*Math.max(f,e);Fa[a>>2]=Number(f!=e);a=h=>{var g=Math.abs(h);return`UTC${0<=h?"-":"+"}${String(Math.floor(g/60)).padStart(2,"0")}${String(g%60).padStart(2,"0")}`};b=a(f);a=a(e);e<f?(bc(b,c,17),bc(a,d,17)):(bc(b,d,17),bc(a,c,17))},z:function(b,a,c){if(!(0<=b&&3>=b))return 28;Ia[c>>3]=BigInt(Math.round(1E6*(0===b?Date.now():performance.now())));return 0},A:b=>{var a=
440
- z.length;b>>>=0;if(2147483648<b)return!1;for(var c=1;4>=c;c*=2){var d=a*(1+.2/c);d=Math.min(d,b+100663296);a:{d=(Math.min(2147483648,65536*Math.ceil(Math.max(b,d)/65536))-Ma.buffer.byteLength+65535)/65536|0;try{Ma.grow(d);La();var e=1;break a}catch(f){}e=void 0}if(e)return!0}return!1},x:(b,a)=>{var c=0,d=0,e;for(e of Cc()){var f=a+c;J[b+d>>2]=f;c+=bc(e,f,Infinity)+1;d+=4}return 0},y:(b,a)=>{var c=Cc();J[b>>2]=c.length;b=0;for(var d of c)b+=fc(d)+1;J[a>>2]=b;return 0},D:()=>52,B:function(){return 70},
441
- C:(b,a,c,d)=>{for(var e=0,f=0;f<c;f++){var h=J[a>>2],g=J[a+4>>2];a+=8;for(var m=0;m<g;m++){var n=b,u=z[h+m],x=Dc[n];0===u||10===u?((1===n?va:wa)(ic(x)),x.length=0):x.push(u)}e+=g}J[d>>2]=e;return 0},t:yc},Hc;
442
- Hc=await (async function(){function b(c){c=Hc=c.exports;gb=c.V;Ec=c.W;fb=c.X;Fc=c.Z;Ma=c.T;Rb=c.Y;La();return Hc}var a={a:Gc};if(k.instantiateWasm)return new Promise(c=>{k.instantiateWasm(a,(d,e)=>{c(b(d,e))})});Oa??=k.locateFile?k.locateFile("canvas_advanced.wasm",pa):pa+"canvas_advanced.wasm";return b((await Sa(a)).instance)}());
443
- (function(){function b(){k.calledRun=!0;if(!ya){Ka=!0;Hc.U();Aa?.(k);k.onRuntimeInitialized?.();if(k.postRun)for("function"==typeof k.postRun&&(k.postRun=[k.postRun]);k.postRun.length;){var a=k.postRun.shift();Va.push(a)}Ua(Va)}}if(k.preRun)for("function"==typeof k.preRun&&(k.preRun=[k.preRun]);k.preRun.length;)Xa();Ua(Wa);k.setStatus?(k.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>k.setStatus(""),1);b()},1)):b()})();Ka?moduleRtn=k:moduleRtn=new Promise((b,a)=>{Aa=b;Ba=a});
425
+ Object.assign(Pb.prototype,{Sb(b){this.tb&&(b=this.tb(b));return b},lb(b){this.qa?.(b)},ma:tb,ba:function(b){function a(){return this.Ja?Ob(this.aa.pa,{da:this.cc,ca:c,oa:this,ia:b}):Ob(this.aa.pa,{da:this,ca:b})}var c=this.Sb(b);if(!c)return this.lb(b),null;var d=Nb(this.aa,c);if(void 0!==d){if(0===d.$.count.value)return d.$.ca=c,d.$.ia=b,d.clone();d=d.clone();this.lb(b);return d}d=this.aa.Rb(c);d=Cb[d];if(!d)return a.call(this);d=this.Ia?d.Ib:d.pointerType;var e=Mb(c,this.aa,d.aa);return null===
426
+ e?a.call(this):this.Ja?Ob(d.aa.pa,{da:d,ca:e,oa:this,ia:b}):Ob(d.aa.pa,{da:d,ca:e})}});h.noExitRuntime&&(Za=h.noExitRuntime);h.print&&(ua=h.print);h.printErr&&(va=h.printErr);h.wasmBinary&&(wa=h.wasmBinary);h.thisProgram&&(na=h.thisProgram);if(h.preInit)for("function"==typeof h.preInit&&(h.preInit=[h.preInit]);0<h.preInit.length;)h.preInit.shift()();
427
+ var hb,Gc,gb,Hc,Ma,Rb,Ic={E:()=>Na(""),n:(b,a,c)=>{b=U(b);a=jb(a,"wrapper");c=P(c);var d=a.aa,e=d.pa,k=d.ga.pa,g=d.ga.constructor;b=$a(b,function(...f){for(var m of d.ga.sb)if(this[m]===k[m])throw new cb(`Pure virtual function ${m} must be implemented in JavaScript`);Object.defineProperty(this,"__parent",{value:e});this.__construct(...f)});e.__construct=function(...f){if(this===e)throw new N("Pass correct 'this' to __construct");f=g.implement(this,...f);kb(f);var m=f.$;f.notifyOnDestruction();m.xa=
428
+ !0;Object.defineProperties(this,{$:{value:m}});mb(this);f=m.ca;f=eb(d,f);if(db.hasOwnProperty(f))throw new N(`Tried to register registered instance: ${f}`);db[f]=this};e.__destruct=function(){if(this===e)throw new N("Pass correct 'this' to __destruct");kb(this);var f=this.$.ca;f=eb(d,f);if(db.hasOwnProperty(f))delete db[f];else throw new N(`Tried to unregister unregistered instance: ${f}`);};b.prototype=Object.create(e);Object.assign(b.prototype,c);return T(b)},N:b=>{var a=nb[b];delete nb[b];var c=
429
+ a.Za,d=a.qa,e=a.ob,k=e.map(g=>g.Vb).concat(e.map(g=>g.fc));W([b],k,g=>{var f={},m,n;for([m,n]of e.entries()){const r=g[m],w=n.Tb,z=n.Ub,v=g[m+e.length],x=n.ec,q=n.hc;f[n.Pb]={read:L=>r.ba(w(z,L)),write:(L,I)=>{var u=[];x(q,L,v.ea(u,I));sb(u)},optional:r.optional}}return[{name:a.name,ba:r=>{var w={},z;for(z in f)w[z]=f[z].read(r);d(r);return w},ea:(r,w)=>{for(var z in f)if(!(z in w||f[z].optional))throw new TypeError(`Missing field: "${z}"`);var v=c();for(z in f)f[z].write(v,w[z]);null!==r&&r.push(d,
430
+ v);return v},ma:tb,ka:d}]})},r:(b,a,c,d,e)=>{a=U(a);d=0n===d;let k=g=>g;if(d){const g=8*c;k=f=>BigInt.asUintN(g,f);e=k(e)}V(b,{name:a,ba:k,ea:(g,f)=>{"number"==typeof f&&(f=BigInt(f));return f},ma:yb(a,c,!d),ka:null})},H:(b,a,c,d)=>{a=U(a);V(b,{name:a,ba:function(e){return!!e},ea:function(e,k){return k?c:d},ma:function(e){return this.ba(D[e])},ka:null})},c:(b,a,c,d,e,k,g,f,m,n,r,w,z)=>{r=U(r);k=Y(e,k);f&&=Y(g,f);n&&=Y(m,n);z=Y(w,z);var v=Fb(r);Eb(v,function(){Z(`Cannot construct ${r} due to unbound types`,
431
+ [d])});W([b,a,c],d?[d]:[],x=>{x=x[0];if(d){var q=x.aa;var L=q.pa}else L=Bb.prototype;x=$a(r,function(...K){if(Object.getPrototypeOf(this)!==I)throw new N(`Use 'new' to construct ${r}`);if(void 0===u.ua)throw new N(`${r} has no accessible constructor`);var R=u.ua[K.length];if(void 0===R)throw new N(`Tried to invoke ctor of ${r} with invalid number of parameters (${K.length}) - expected (${Object.keys(u.ua).toString()}) parameters instead!`);return R.apply(this,K)});var I=Object.create(L,{constructor:{value:x}});
432
+ x.prototype=I;var u=new Gb(r,x,I,z,q,k,f,n);if(u.ga){var J;(J=u.ga).Ea??(J.Ea=[]);u.ga.Ea.push(u)}q=new Pb(r,u,!0,!1,!1);J=new Pb(r+"*",u,!1,!1,!1);L=new Pb(r+" const*",u,!1,!0,!1);Cb[b]={pointerType:J,Ib:L};Qb(v,x);return[q,J,L]})},j:(b,a,c,d,e,k,g)=>{var f=Vb(c,d);a=U(a);a=Wb(a);k=Y(e,k);W([],[b],m=>{function n(){Z(`Cannot call ${r} due to unbound types`,f)}m=m[0];var r=`${m.name}.${a}`;a.startsWith("@@")&&(a=Symbol[a.substring(2)]);var w=m.aa.constructor;void 0===w[a]?(n.ta=c-1,w[a]=n):(Db(w,a,
433
+ r),w[a].fa[c-1]=n);W([],f,z=>{z=Ub(r,[z[0],null].concat(z.slice(1)),null,k,g);void 0===w[a].fa?(z.ta=c-1,w[a]=z):w[a].fa[c-1]=z;if(m.aa.Ea)for(const v of m.aa.Ea)v.constructor.hasOwnProperty(a)||(v.constructor[a]=z);return[]});return[]})},p:(b,a,c,d,e,k,g,f)=>{a=U(a);k=Y(e,k);W([],[b],m=>{m=m[0];var n=`${m.name}.${a}`,r={get(){Z(`Cannot access ${n} due to unbound types`,[c])},enumerable:!0,configurable:!0};r.set=f?()=>{Z(`Cannot access ${n} due to unbound types`,[c])}:()=>{throw new N(`${n} is a read-only property`);
434
+ };Object.defineProperty(m.aa.constructor,a,r);W([],[c],w=>{w=w[0];var z={get(){return w.ba(k(d))},enumerable:!0};f&&(f=Y(g,f),z.set=v=>{var x=[];f(d,w.ea(x,v));sb(x)});Object.defineProperty(m.aa.constructor,a,z);return[]});return[]})},m:(b,a,c,d,e,k)=>{var g=Vb(a,c);e=Y(d,e);W([],[b],f=>{f=f[0];var m=`constructor ${f.name}`;void 0===f.aa.ua&&(f.aa.ua=[]);if(void 0!==f.aa.ua[a-1])throw new N(`Cannot register multiple constructors with identical number of parameters (${a-1}) for class '${f.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);
435
+ f.aa.ua[a-1]=()=>{Z(`Cannot construct ${f.name} due to unbound types`,g)};W([],g,n=>{n.splice(1,0,null);f.aa.ua[a-1]=Ub(m,n,null,e,k);return[]});return[]})},a:(b,a,c,d,e,k,g,f)=>{var m=Vb(c,d);a=U(a);a=Wb(a);k=Y(e,k);W([],[b],n=>{function r(){Z(`Cannot call ${w} due to unbound types`,m)}n=n[0];var w=`${n.name}.${a}`;a.startsWith("@@")&&(a=Symbol[a.substring(2)]);f&&n.aa.sb.push(a);var z=n.aa.pa,v=z[a];void 0===v||void 0===v.fa&&v.className!==n.name&&v.ta===c-2?(r.ta=c-2,r.className=n.name,z[a]=r):
436
+ (Db(z,a,w),z[a].fa[c-2]=r);W([],m,x=>{x=Ub(w,x,n,k,g);void 0===z[a].fa?(x.ta=c-2,z[a]=x):z[a].fa[c-2]=x;return[]});return[]})},b:(b,a,c,d,e,k,g,f,m,n)=>{a=U(a);e=Y(d,e);W([],[b],r=>{r=r[0];var w=`${r.name}.${a}`,z={get(){Z(`Cannot access ${w} due to unbound types`,[c,g])},enumerable:!0,configurable:!0};z.set=m?()=>Z(`Cannot access ${w} due to unbound types`,[c,g]):()=>{throw new N(w+" is a read-only property");};Object.defineProperty(r.aa.pa,a,z);W([],m?[c,g]:[c],v=>{var x=v[0],q={get(){var I=Xb(this,
437
+ r,w+" getter");return x.ba(e(k,I))},enumerable:!0};if(m){m=Y(f,m);var L=v[1];q.set=function(I){var u=Xb(this,r,w+" setter"),J=[];m(n,u,L.ea(J,I));sb(J)}}Object.defineProperty(r.aa.pa,a,q);return[]});return[]})},F:b=>V(b,Zb),l:(b,a,c,d,e)=>{a=U(a);e=0===e?"object":1===e?"number":"string";switch(e){case "object":function g(){}g.values={};V(b,{name:a,constructor:g,valueType:e,ba:function(f){return this.constructor.values[f]},ea:(f,m)=>m.value,ma:$b(a,c,d),ka:null});Eb(a,g);break;case "number":var k=
438
+ {};V(b,{name:a,Ya:k,valueType:e,ba:f=>f,ea:(f,m)=>m,ma:$b(a,c,d),ka:null});Eb(a,k);delete h[a].ta;break;case "string":k={},V(b,{name:a,zb:{},ub:{},Ya:k,valueType:e,ba:function(f){return this.ub[f]},ea:function(f,m){return this.zb[m]},ma:$b(a,c,d),ka:null}),Eb(a,k),delete h[a].ta}},d:(b,a,c)=>{var d=jb(b,"enum");a=U(a);switch(d.valueType){case "object":b=d.constructor;d=Object.create(d.constructor.prototype,{value:{value:c},constructor:{value:$a(`${d.name}_${a}`,function(){})}});b.values[c]=d;b[a]=
439
+ d;break;case "number":d.Ya[a]=c;break;case "string":d.zb[a]=c,d.ub[c]=a,d.Ya[a]=a}},q:(b,a,c)=>{a=U(a);V(b,{name:a,ba:d=>d,ea:(d,e)=>e,ma:ac(a,c),ka:null})},h:(b,a,c,d,e,k)=>{var g=Vb(a,c);b=U(b);b=Wb(b);e=Y(d,e);Eb(b,function(){Z(`Cannot call ${b} due to unbound types`,g)},a-1);W([],g,f=>{Qb(b,Ub(b,[f[0],null].concat(f.slice(1)),null,e,k),a-1);return[]})},k:(b,a,c,d,e)=>{a=U(a);let k=f=>f;if(0===d){var g=32-8*c;k=f=>f<<g>>>g;e=k(e)}V(b,{name:a,ba:k,ea:(f,m)=>m,ma:yb(a,c,0!==d),ka:null})},i:(b,a,
440
+ c)=>{function d(k){return new e(Ca.buffer,M[k+4>>2],M[k>>2])}var e=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array][a];c=U(c);V(b,{name:c,ba:d,ma:d},{Wb:!0})},G:(b,a)=>{a=U(a);V(b,{name:a,ba(c){var d=(d=c+4)?kc(D,d,M[c>>2],!0):"";hb(c);return d},ea(c,d){d instanceof ArrayBuffer&&(d=new Uint8Array(d));var e="string"==typeof d;if(!(e||ArrayBuffer.isView(d)&&1==d.BYTES_PER_ELEMENT))throw new N("Cannot pass non-string to std::string");
441
+ var k=e?hc(d):d.length;var g=Gc(4+k+1),f=g+4;M[g>>2]=k;e?bc(d,f,k+1):D.set(d,f);null!==c&&c.push(hb,g);return g},ma:tb,ka(c){hb(c)}})},o:(b,a,c)=>{c=U(c);if(2===a){var d=mc;var e=nc;var k=oc}else d=pc,e=qc,k=rc;V(b,{name:c,ba:g=>{var f=d(g+4,M[g>>2]*a,!0);hb(g);return f},ea:(g,f)=>{if("string"!=typeof f)throw new N(`Cannot pass non-string to C++ string type ${c}`);var m=k(f),n=Gc(4+m+a);M[n>>2]=m/a;e(f,n+4,m+a);null!==g&&g.push(hb,n);return n},ma:tb,ka(g){hb(g)}})},P:(b,a,c,d,e,k)=>{nb[b]={name:U(a),
442
+ Za:Y(c,d),qa:Y(e,k),ob:[]}},O:(b,a,c,d,e,k,g,f,m,n)=>{nb[b].ob.push({Pb:U(a),Vb:c,Tb:Y(d,e),Ub:k,fc:g,ec:Y(f,m),hc:n})},I:(b,a)=>{a=U(a);V(b,{Yb:!0,name:a,ba:()=>{},ea:()=>{}})},u:()=>{Za=!1;sc=0},f:(b,a,c)=>{var [d,...e]=vc(b,a),k=d.ea.bind(d),g=e.map(m=>m.ma.bind(m));b--;var f=Array(b);a=`methodCaller<(${e.map(m=>m.name)}) => ${d.name}>`;return uc($a(a,(m,n,r,w)=>{for(var z=0,v=0;v<b;++v)f[v]=g[v](w+z),z+=8;switch(c){case 0:var x=P(m).apply(null,f);break;case 2:x=Reflect.construct(P(m),f);break;
443
+ case 3:x=f[0];break;case 1:x=P(m)[xc(n)](...f)}m=[];x=k(m,x);m.length&&(M[r>>2]=T(m));return x}))},R:Yb,J:b=>{b=xc(b);return T(h[b])},K:(b,a)=>{b=P(b);a=P(a);return T(b[a])},L:b=>{9<b&&(bb[b+1]+=1)},e:(b,a,c,d,e)=>tc[b](a,c,d,e),M:()=>T([]),s:b=>T(xc(b)),S:()=>T({}),Q:b=>{var a=P(b);sb(a);Yb(b)},g:(b,a,c)=>{b=P(b);a=P(a);c=P(c);b[a]=c},v:(b,a)=>{yc[b]&&(clearTimeout(yc[b].id),delete yc[b]);if(!a)return 0;var c=setTimeout(()=>{delete yc[b];Bc(()=>Hc(b,performance.now()))},a);yc[b]={id:c,kc:a};return 0},
444
+ w:(b,a,c,d)=>{var e=(new Date).getFullYear(),k=(new Date(e,0,1)).getTimezoneOffset();e=(new Date(e,6,1)).getTimezoneOffset();M[b>>2]=60*Math.max(k,e);Fa[a>>2]=Number(k!=e);a=g=>{var f=Math.abs(g);return`UTC${0<=g?"-":"+"}${String(Math.floor(f/60)).padStart(2,"0")}${String(f%60).padStart(2,"0")}`};b=a(k);a=a(e);e<k?(bc(b,c,17),bc(a,d,17)):(bc(b,d,17),bc(a,c,17))},x:function(b,a,c){if(!(0<=b&&3>=b))return 28;Ia[c>>3]=BigInt(Math.round(1E6*(0===b?Date.now():performance.now())));return 0},y:b=>{var a=
445
+ D.length;b>>>=0;if(2147483648<b)return!1;for(var c=1;4>=c;c*=2){var d=a*(1+.2/c);d=Math.min(d,b+100663296);a:{d=(Math.min(2147483648,65536*Math.ceil(Math.max(b,d)/65536))-Ma.buffer.byteLength+65535)/65536|0;try{Ma.grow(d);La();var e=1;break a}catch(k){}e=void 0}if(e)return!0}return!1},C:(b,a)=>{var c=0,d=0,e;for(e of Ec()){var k=a+c;M[b+d>>2]=k;c+=bc(e,k,Infinity)+1;d+=4}return 0},D:(b,a)=>{var c=Ec();M[b>>2]=c.length;b=0;for(var d of c)b+=hc(d)+1;M[a>>2]=b;return 0},B:()=>52,z:function(){return 70},
446
+ A:(b,a,c,d)=>{for(var e=0,k=0;k<c;k++){var g=M[a>>2],f=M[a+4>>2];a+=8;for(var m=0;m<f;m++){var n=b,r=D[g+m],w=Fc[n];0===r||10===r?((1===n?ua:va)(kc(w)),w.length=0):w.push(r)}e+=f}M[d>>2]=e;return 0},t:Ac},Jc;
447
+ Jc=await (async function(){function b(c){c=Jc=c.exports;hb=c.V;Gc=c.W;gb=c.X;Hc=c.Z;Ma=c.T;Rb=c.Y;La();return Jc}var a={a:Ic};if(h.instantiateWasm)return new Promise(c=>{h.instantiateWasm(a,(d,e)=>{c(b(d,e))})});Oa??=h.locateFile?h.locateFile("canvas_advanced.wasm",oa):oa+"canvas_advanced.wasm";return b((await Ta(a)).instance)}());
448
+ (function(){function b(){h.calledRun=!0;if(!xa){Ka=!0;Jc.U();za?.(h);h.onRuntimeInitialized?.();if(h.postRun)for("function"==typeof h.postRun&&(h.postRun=[h.postRun]);h.postRun.length;){var a=h.postRun.shift();Wa.push(a)}Va(Wa)}}if(h.preRun)for("function"==typeof h.preRun&&(h.preRun=[h.preRun]);h.preRun.length;)Ya();Va(Xa);h.setStatus?(h.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>h.setStatus(""),1);b()},1)):b()})();Ka?moduleRtn=h:moduleRtn=new Promise((b,a)=>{za=b;Ba=a});
444
449
  ;return moduleRtn}})();
445
450
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Rive);
446
451
 
@@ -449,7 +454,7 @@ Hc=await (async function(){function b(c){c=Hc=c.exports;gb=c.V;Ec=c.W;fb=c.X;Fc=
449
454
  /* 5 */
450
455
  /***/ ((module) => {
451
456
 
452
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.41.0","description":"A lite version of Rive\'s canvas based web api.","main":"rive.js","homepage":"https://rive.app","repository":{"type":"git","url":"https://github.com/rive-app/rive-wasm/tree/master/js"},"keywords":["rive","animation"],"author":"Rive","contributors":["Luigi Rosso <luigi@rive.app> (https://rive.app)","Maxwell Talbot <max@rive.app> (https://rive.app)","Arthur Vivian <arthur@rive.app> (https://rive.app)","Umberto Sonnino <umberto@rive.app> (https://rive.app)","Matthew Sullivan <matt.j.sullivan@gmail.com> (mailto:matt.j.sullivan@gmail.com)"],"license":"MIT","files":["rive.js","rive.js.map","rive.wasm","rive_fallback.wasm","rive.d.ts","rive_advanced.mjs.d.ts","runtimeLoader.d.ts","utils","semantics"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
457
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.42.0","description":"A lite version of Rive\'s canvas based web api.","main":"rive.js","homepage":"https://rive.app","repository":{"type":"git","url":"https://github.com/rive-app/rive-wasm/tree/master/js"},"keywords":["rive","animation"],"author":"Rive","contributors":["Luigi Rosso <luigi@rive.app> (https://rive.app)","Maxwell Talbot <max@rive.app> (https://rive.app)","Arthur Vivian <arthur@rive.app> (https://rive.app)","Umberto Sonnino <umberto@rive.app> (https://rive.app)","Matthew Sullivan <matt.j.sullivan@gmail.com> (mailto:matt.j.sullivan@gmail.com)"],"license":"MIT","files":["rive.js","rive.js.map","rive.wasm","rive_fallback.wasm","rive.d.ts","rive_advanced.mjs.d.ts","runtimeLoader.d.ts","utils","semantics"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
453
458
 
454
459
  /***/ }),
455
460
  /* 6 */
@@ -458,12 +463,16 @@ module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas-lite","versi
458
463
  __webpack_require__.r(__webpack_exports__);
459
464
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
460
465
  /* harmony export */ AccessibilityOverlay: () => (/* reexport safe */ _accessibilityOverlay__WEBPACK_IMPORTED_MODULE_1__.AccessibilityOverlay),
466
+ /* harmony export */ CHECK_STATE_MASK: () => (/* reexport safe */ _types__WEBPACK_IMPORTED_MODULE_2__.CHECK_STATE_MASK),
467
+ /* harmony export */ CHECK_STATE_OFFSET: () => (/* reexport safe */ _types__WEBPACK_IMPORTED_MODULE_2__.CHECK_STATE_OFFSET),
461
468
  /* harmony export */ SemanticActionType: () => (/* reexport safe */ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticActionType),
469
+ /* harmony export */ SemanticCheckState: () => (/* reexport safe */ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticCheckState),
462
470
  /* harmony export */ SemanticMode: () => (/* reexport safe */ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticMode),
463
471
  /* harmony export */ SemanticRole: () => (/* reexport safe */ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole),
464
472
  /* harmony export */ SemanticState: () => (/* reexport safe */ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState),
465
473
  /* harmony export */ SemanticTrait: () => (/* reexport safe */ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait),
466
474
  /* harmony export */ SemanticTreeModel: () => (/* reexport safe */ _semanticTreeModel__WEBPACK_IMPORTED_MODULE_0__.SemanticTreeModel),
475
+ /* harmony export */ checkStateOf: () => (/* reexport safe */ _types__WEBPACK_IMPORTED_MODULE_2__.checkStateOf),
467
476
  /* harmony export */ hasState: () => (/* reexport safe */ _types__WEBPACK_IMPORTED_MODULE_2__.hasState),
468
477
  /* harmony export */ hasTrait: () => (/* reexport safe */ _types__WEBPACK_IMPORTED_MODULE_2__.hasTrait),
469
478
  /* harmony export */ roleName: () => (/* reexport safe */ _types__WEBPACK_IMPORTED_MODULE_2__.roleName),
@@ -928,11 +937,15 @@ function applyGeometry(target, src) {
928
937
 
929
938
  __webpack_require__.r(__webpack_exports__);
930
939
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
940
+ /* harmony export */ CHECK_STATE_MASK: () => (/* binding */ CHECK_STATE_MASK),
941
+ /* harmony export */ CHECK_STATE_OFFSET: () => (/* binding */ CHECK_STATE_OFFSET),
931
942
  /* harmony export */ SemanticActionType: () => (/* binding */ SemanticActionType),
943
+ /* harmony export */ SemanticCheckState: () => (/* binding */ SemanticCheckState),
932
944
  /* harmony export */ SemanticMode: () => (/* binding */ SemanticMode),
933
945
  /* harmony export */ SemanticRole: () => (/* binding */ SemanticRole),
934
946
  /* harmony export */ SemanticState: () => (/* binding */ SemanticState),
935
947
  /* harmony export */ SemanticTrait: () => (/* binding */ SemanticTrait),
948
+ /* harmony export */ checkStateOf: () => (/* binding */ checkStateOf),
936
949
  /* harmony export */ hasState: () => (/* binding */ hasState),
937
950
  /* harmony export */ hasTrait: () => (/* binding */ hasTrait),
938
951
  /* harmony export */ roleName: () => (/* binding */ roleName),
@@ -967,14 +980,17 @@ var SemanticRole = {
967
980
  //
968
981
  // Bits 0-7 are trait-gated (only meaningful when the corresponding
969
982
  // SemanticTrait is set). Bits 8-13 are non-trait states.
983
+ //
984
+ // Check state is the exception: it is a two-bit *field* at bits 2-3 rather
985
+ // than a flag, because a checkbox is tri-state. It is not a member of this
986
+ // table — read it with checkStateOf().
970
987
  // ---------------------------------------------------------------------------
971
988
  var SemanticState = {
972
989
  None: 0,
973
990
  // Trait-gated
974
991
  Expanded: 1 << 0, // requires Expandable
975
992
  Selected: 1 << 1, // requires Selectable
976
- Checked: 1 << 2, // requires Checkable
977
- Mixed: 1 << 3, // requires Checkable; wins over Checked
993
+ // Bits 2-3 are the check state field, not independent flags -- see SemanticCheckState.
978
994
  Toggled: 1 << 4, // requires Toggleable
979
995
  Required: 1 << 5, // requires Requirable
980
996
  Disabled: 1 << 6, // requires Enablable
@@ -990,6 +1006,30 @@ var SemanticState = {
990
1006
  function hasState(flags, state) {
991
1007
  return (flags & state) !== 0;
992
1008
  }
1009
+ // SemanticCheckState — mirrors rive::SemanticCheckState
1010
+ //
1011
+ // The tri-state of a checkable node. Occupies two bits of stateFlags at
1012
+ // CHECK_STATE_OFFSET, so it is read as a value rather than tested as a flag.
1013
+ // Only meaningful when the Checkable trait is set.
1014
+ var SemanticCheckState = {
1015
+ Unchecked: 0,
1016
+ Checked: 1,
1017
+ Mixed: 2,
1018
+ };
1019
+ /** Bit offset of the check field within stateFlags. */
1020
+ var CHECK_STATE_OFFSET = 2;
1021
+ /** Mask of the check field within stateFlags. */
1022
+ var CHECK_STATE_MASK = 3 << CHECK_STATE_OFFSET;
1023
+ /**
1024
+ * Decodes the check field out of `flags`. The field is two bits. Returns 0, 1, or 2
1025
+ * per the mapping in SemanticCheckState.
1026
+ */
1027
+ function checkStateOf(flags) {
1028
+ var value = (flags & CHECK_STATE_MASK) >> CHECK_STATE_OFFSET;
1029
+ return value >= SemanticCheckState.Mixed
1030
+ ? SemanticCheckState.Mixed
1031
+ : value;
1032
+ }
993
1033
  /**
994
1034
  * Controls when the instance builds semantic trees and accessibility overlays.
995
1035
  *
@@ -1056,6 +1096,14 @@ function stateNames(flags) {
1056
1096
  if (flags & bit)
1057
1097
  active.push(name_2);
1058
1098
  }
1099
+ switch (checkStateOf(flags)) {
1100
+ case SemanticCheckState.Checked:
1101
+ active.push("Checked");
1102
+ break;
1103
+ case SemanticCheckState.Mixed:
1104
+ active.push("Mixed");
1105
+ break;
1106
+ }
1059
1107
  return active.join(", ") || "none";
1060
1108
  }
1061
1109
  function traitNames(flags) {
@@ -1824,13 +1872,15 @@ var AccessibilityOverlay = /** @class */ (function () {
1824
1872
  removeAttr(el, "aria-selected");
1825
1873
  }
1826
1874
  if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Checkable) && ARIA_CHECKED_ROLES.has(role)) {
1827
- // Mixed wins over Checked per the C++ precedence contract, but
1828
- // role="switch" only accepts true/false — "mixed" is invalid per ARIA.
1829
- if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Mixed) && role !== _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.switchControl) {
1875
+ // Check state is a tri-state field, but not every checkable role
1876
+ // accepts all three values — see ARIA_MIXED_ROLES.
1877
+ var checkState = (0,_types__WEBPACK_IMPORTED_MODULE_0__.checkStateOf)(flags);
1878
+ if (checkState === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticCheckState.Mixed &&
1879
+ ARIA_MIXED_ROLES.has(role)) {
1830
1880
  setAttr(el, "aria-checked", "mixed");
1831
1881
  }
1832
1882
  else {
1833
- setBoolAttr(el, "aria-checked", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Checked));
1883
+ setBoolAttr(el, "aria-checked", checkState === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticCheckState.Checked);
1834
1884
  }
1835
1885
  }
1836
1886
  else {
@@ -2090,6 +2140,15 @@ var ARIA_CHECKED_ROLES = new Set([
2090
2140
  _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.radioButton,
2091
2141
  _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.switchControl,
2092
2142
  ]);
2143
+ /**
2144
+ * aria-checked="mixed": checkbox only. ARIA defines checkbox as three-valued
2145
+ * (true/false/mixed) but radio and switch as two-valued (true/false), so an
2146
+ * indeterminate check state degrades to false for those roles rather than
2147
+ * emitting a value they do not support.
2148
+ */
2149
+ var ARIA_MIXED_ROLES = new Set([
2150
+ _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.checkbox,
2151
+ ]);
2093
2152
  /**
2094
2153
  * aria-pressed: button only. switch is a button subclass in ARIA but uses
2095
2154
  * aria-checked (not aria-pressed) for its on/off state — it is intentionally
@@ -2938,14 +2997,26 @@ var __extends = (undefined && undefined.__extends) || (function () {
2938
2997
  };
2939
2998
  })();
2940
2999
  var FileFinalizer = /** @class */ (function () {
2941
- function FileFinalizer(file) {
3000
+ function FileFinalizer(file, session) {
3001
+ if (session === void 0) { session = null; }
2942
3002
  this.selfUnref = false;
2943
3003
  this._file = file;
3004
+ this._session = session;
2944
3005
  }
2945
3006
  FileFinalizer.prototype.unref = function () {
2946
3007
  if (this._file) {
2947
3008
  this._file.unref();
2948
3009
  }
3010
+ // After the file, never before: the file's resources belong to the session.
3011
+ if (this._session) {
3012
+ this._session.delete();
3013
+ this._session = null;
3014
+ }
3015
+ };
3016
+ // Disarms the GC path for a file cleanup() already released.
3017
+ FileFinalizer.prototype.release = function () {
3018
+ this._file = null;
3019
+ this._session = null;
2949
3020
  };
2950
3021
  return FileFinalizer;
2951
3022
  }());
@@ -3029,8 +3100,10 @@ var FontWrapper = /** @class */ (function (_super) {
3029
3100
  return FontWrapper;
3030
3101
  }(AssetWrapper));
3031
3102
  var CustomFileAssetLoaderWrapper = /** @class */ (function () {
3032
- function CustomFileAssetLoaderWrapper(runtime, loaderCallback) {
3103
+ function CustomFileAssetLoaderWrapper(runtime, loaderCallback, session) {
3104
+ if (session === void 0) { session = null; }
3033
3105
  this._assetLoaderCallback = loaderCallback;
3106
+ this._session = session;
3034
3107
  this.assetLoader = new runtime.CustomFileAssetLoader({
3035
3108
  loadContents: this.loadContents.bind(this),
3036
3109
  });
@@ -3038,13 +3111,13 @@ var CustomFileAssetLoaderWrapper = /** @class */ (function () {
3038
3111
  CustomFileAssetLoaderWrapper.prototype.loadContents = function (asset, bytes) {
3039
3112
  var assetWrapper;
3040
3113
  if (asset.isImage) {
3041
- assetWrapper = new ImageAssetWrapper(asset);
3114
+ assetWrapper = new ImageAssetWrapper(asset, this._session);
3042
3115
  }
3043
3116
  else if (asset.isAudio) {
3044
- assetWrapper = new AudioAssetWrapper(asset);
3117
+ assetWrapper = new AudioAssetWrapper(asset, this._session);
3045
3118
  }
3046
3119
  else if (asset.isFont) {
3047
- assetWrapper = new FontAssetWrapper(asset);
3120
+ assetWrapper = new FontAssetWrapper(asset, this._session);
3048
3121
  }
3049
3122
  else {
3050
3123
  return false;
@@ -3058,11 +3131,15 @@ var CustomFileAssetLoaderWrapper = /** @class */ (function () {
3058
3131
  * an asset associated wtih the Rive File
3059
3132
  */
3060
3133
  var FileAssetWrapper = /** @class */ (function () {
3061
- function FileAssetWrapper(nativeAsset) {
3134
+ function FileAssetWrapper(nativeAsset, session) {
3135
+ if (session === void 0) { session = null; }
3062
3136
  this._nativeFileAsset = nativeAsset;
3137
+ this._session = session;
3063
3138
  }
3064
3139
  FileAssetWrapper.prototype.decode = function (bytes) {
3065
- this._nativeFileAsset.decode(bytes);
3140
+ // The session travels with the asset so a deferred file's assets are
3141
+ // session-typed without the caller needing to know the file's rendering mode.
3142
+ this._nativeFileAsset.decode(bytes, this._session);
3066
3143
  };
3067
3144
  Object.defineProperty(FileAssetWrapper.prototype, "name", {
3068
3145
  get: function () {
@@ -4698,8 +4775,23 @@ var RiveFile = /** @class */ (function () {
4698
4775
  this.destroyed = false;
4699
4776
  this.selfUnref = false;
4700
4777
  this.bindableArtboards = [];
4778
+ // Deferred rendering was requested; the session may still be null if this
4779
+ // build has no deferred support.
4780
+ this.deferred = false;
4781
+ // The session this file imported through, null when immediate. Owned here:
4782
+ // it has to outlive the file, so it is deleted after the file is released.
4783
+ this.session = null;
4784
+ // Attaching is once per session: a detached session can never replay again,
4785
+ // so a claimed file re-imports for the next instance implicitly. Mirrors the native
4786
+ // latch (WebGL2DeferredSession::everBound, C2DDeferredSession::claim).
4787
+ this._sessionClaimed = false;
4788
+ // Releasing this file has to be deterministic once a session owns its
4789
+ // resources, so the finalizer is disarmed rather than left to GC.
4790
+ this.fileFinalizer = null;
4791
+ this.boundElsewhereWarned = false;
4701
4792
  this.src = params.src;
4702
4793
  this.buffer = params.buffer;
4794
+ this.deferred = !!params.enableGPUCanvas;
4703
4795
  if (params.assetLoader)
4704
4796
  this.assetLoader = params.assetLoader;
4705
4797
  this.enableRiveAssetCDN =
@@ -4717,12 +4809,24 @@ var RiveFile = /** @class */ (function () {
4717
4809
  this.on(EventType.LoadError, params.onLoadError);
4718
4810
  }
4719
4811
  RiveFile.prototype.releaseFile = function () {
4720
- var _a;
4721
- if (this.selfUnref) {
4722
- (_a = this.file) === null || _a === void 0 ? void 0 : _a.unref();
4723
- }
4812
+ var _a, _b;
4813
+ // Release here rather than leaving it to the finalization registry. The
4814
+ // native file frees GL-backed resources when its last reference goes, and
4815
+ // callers reach this with the renderer's context current; a finalizer runs
4816
+ // with none, so those deletes would silently do nothing.
4817
+ (_a = this.fileFinalizer) === null || _a === void 0 ? void 0 : _a.release();
4818
+ (_b = this.file) === null || _b === void 0 ? void 0 : _b.unref();
4819
+ this.fileFinalizer = null;
4724
4820
  this.file = null;
4725
4821
  };
4822
+ RiveFile.prototype.releaseSession = function () {
4823
+ var _a;
4824
+ // Known limitation: cleanup() on a file an instance is still drawing
4825
+ // deletes the session under it. A RiveFile's creator holds no reference of
4826
+ // its own, so their cleanup() can take the count to zero.
4827
+ (_a = this.session) === null || _a === void 0 ? void 0 : _a.delete();
4828
+ this.session = null;
4829
+ };
4726
4830
  RiveFile.prototype.releaseBindableArtboards = function () {
4727
4831
  this.bindableArtboards.forEach(function (bindableArtboard) {
4728
4832
  return bindableArtboard.destroy();
@@ -4730,7 +4834,7 @@ var RiveFile = /** @class */ (function () {
4730
4834
  };
4731
4835
  RiveFile.prototype.initData = function () {
4732
4836
  return __awaiter(this, void 0, void 0, function () {
4733
- var _a, error_1, loader, loaderWrapper, _b, fileFinalizer;
4837
+ var _a, error_1, loader, loaderWrapper, _b, error_2, fileFinalizer;
4734
4838
  return __generator(this, function (_c) {
4735
4839
  switch (_c.label) {
4736
4840
  case 0:
@@ -4753,36 +4857,55 @@ var RiveFile = /** @class */ (function () {
4753
4857
  if (this.destroyed) {
4754
4858
  return [2 /*return*/];
4755
4859
  }
4860
+ if (this.deferred && this.session === null) {
4861
+ this.session = RiveFile.makeDeferredSession(this.runtime);
4862
+ }
4756
4863
  if (this.assetLoader) {
4757
- loaderWrapper = new _utils__WEBPACK_IMPORTED_MODULE_3__.CustomFileAssetLoaderWrapper(this.runtime, this.assetLoader);
4864
+ loaderWrapper = new _utils__WEBPACK_IMPORTED_MODULE_3__.CustomFileAssetLoaderWrapper(this.runtime, this.assetLoader, this.session);
4758
4865
  loader = loaderWrapper.assetLoader;
4759
4866
  }
4760
4867
  // Load the Rive file
4761
4868
  if (this.enablePerfMarks)
4762
4869
  performance.mark('rive:file-load:start');
4763
- _b = this;
4764
- return [4 /*yield*/, this.runtime.load(new Uint8Array(this.buffer), loader, this.enableRiveAssetCDN)];
4870
+ _c.label = 5;
4765
4871
  case 5:
4872
+ _c.trys.push([5, 7, , 8]);
4873
+ _b = this;
4874
+ return [4 /*yield*/, this.runtime.load(new Uint8Array(this.buffer), loader, this.enableRiveAssetCDN, this.session)];
4875
+ case 6:
4766
4876
  _b.file = _c.sent();
4877
+ return [3 /*break*/, 8];
4878
+ case 7:
4879
+ error_2 = _c.sent();
4880
+ // The finalizer that would reclaim the session is only registered once
4881
+ // the import succeeds, so a failed load has to release it here.
4882
+ this.releaseSession();
4883
+ throw error_2;
4884
+ case 8:
4767
4885
  if (this.enablePerfMarks) {
4768
4886
  performance.mark('rive:file-load:end');
4769
4887
  performance.measure('rive:file-load', 'rive:file-load:start', 'rive:file-load:end');
4770
4888
  }
4771
- fileFinalizer = new _utils__WEBPACK_IMPORTED_MODULE_3__.FileFinalizer(this.file);
4772
- _utils__WEBPACK_IMPORTED_MODULE_3__.finalizationRegistry.register(this, fileFinalizer);
4773
4889
  if (this.destroyed) {
4774
4890
  this.releaseFile();
4891
+ this.releaseSession();
4775
4892
  return [2 /*return*/];
4776
4893
  }
4777
- if (this.file !== null) {
4778
- this.eventManager.fire({
4779
- type: EventType.Load,
4780
- data: this,
4781
- });
4782
- }
4783
- else {
4894
+ if (this.file === null) {
4895
+ // A malformed file resolves to null rather than rejecting. Release the
4896
+ // session now: a finalizer for a file that does not exist would keep it
4897
+ // alive until GC, or for as long as the caller holds the failed RiveFile.
4898
+ this.releaseSession();
4784
4899
  this.fireLoadError(RiveFile.fileLoadErrorMessage);
4900
+ return [2 /*return*/];
4785
4901
  }
4902
+ fileFinalizer = new _utils__WEBPACK_IMPORTED_MODULE_3__.FileFinalizer(this.file, this.session);
4903
+ this.fileFinalizer = fileFinalizer;
4904
+ _utils__WEBPACK_IMPORTED_MODULE_3__.finalizationRegistry.register(this, fileFinalizer);
4905
+ this.eventManager.fire({
4906
+ type: EventType.Load,
4907
+ data: this,
4908
+ });
4786
4909
  return [2 /*return*/];
4787
4910
  }
4788
4911
  });
@@ -4826,7 +4949,7 @@ var RiveFile = /** @class */ (function () {
4826
4949
  };
4827
4950
  RiveFile.prototype.init = function () {
4828
4951
  return __awaiter(this, void 0, void 0, function () {
4829
- var _a, bufferResolved, runtimeResolved, error_2;
4952
+ var _a, bufferResolved, runtimeResolved, error_3;
4830
4953
  return __generator(this, function (_b) {
4831
4954
  switch (_b.label) {
4832
4955
  case 0:
@@ -4858,8 +4981,8 @@ var RiveFile = /** @class */ (function () {
4858
4981
  }
4859
4982
  return [3 /*break*/, 5];
4860
4983
  case 4:
4861
- error_2 = _b.sent();
4862
- this.fireLoadError(error_2 instanceof Error ? error_2.message : RiveFile.fileLoadErrorMessage);
4984
+ error_3 = _b.sent();
4985
+ this.fireLoadError(error_3 instanceof Error ? error_3.message : RiveFile.fileLoadErrorMessage);
4863
4986
  return [3 /*break*/, 5];
4864
4987
  case 5: return [2 /*return*/];
4865
4988
  }
@@ -4901,9 +5024,99 @@ var RiveFile = /** @class */ (function () {
4901
5024
  this.removeAllRiveEventListeners();
4902
5025
  this.releaseFile();
4903
5026
  this.releaseBindableArtboards();
5027
+ // Everything imported through the session is gone; the session can go.
5028
+ this.releaseSession();
4904
5029
  this.destroyed = true;
4905
5030
  }
4906
5031
  };
5032
+ // Deferred is only compiled into some runtime builds, so feature detect it
5033
+ // and degrade to an immediate import rather than failing the load.
5034
+ RiveFile.makeDeferredSession = function (runtime) {
5035
+ var _a, _b;
5036
+ var session = (_b = (_a = runtime.makeDeferredSession) === null || _a === void 0 ? void 0 : _a.call(runtime)) !== null && _b !== void 0 ? _b : null;
5037
+ if (session === null && !RiveFile.deferredUnsupportedWarned) {
5038
+ RiveFile.deferredUnsupportedWarned = true;
5039
+ console.warn("Rive: `enableGPUCanvas: true` was ignored because this runtime build has no GPU Canvas support; importing in immediate mode. Use a @rive-app/webgl2 or @rive-app/canvas build with deferred rendering compiled in.");
5040
+ }
5041
+ return session;
5042
+ };
5043
+ Object.defineProperty(RiveFile.prototype, "deferredSession", {
5044
+ /**
5045
+ * @internal The deferred session this file imported through, or null if it
5046
+ * was imported in immediate mode.
5047
+ */
5048
+ get: function () {
5049
+ return this.session;
5050
+ },
5051
+ enumerable: false,
5052
+ configurable: true
5053
+ });
5054
+ Object.defineProperty(RiveFile.prototype, "deferredRequested", {
5055
+ /**
5056
+ * @internal Whether deferred was asked for, even when this build could not
5057
+ * honor it and imported immediate.
5058
+ */
5059
+ get: function () {
5060
+ return this.deferred;
5061
+ },
5062
+ enumerable: false,
5063
+ configurable: true
5064
+ });
5065
+ Object.defineProperty(RiveFile.prototype, "sessionClaimed", {
5066
+ /**
5067
+ * @internal Whether this file's session has ever been attached to a renderer.
5068
+ * Attaching is once per session, so a claimed file re-imports for the next
5069
+ * instance even after the renderer it was bound to is gone.
5070
+ */
5071
+ get: function () {
5072
+ return this._sessionClaimed;
5073
+ },
5074
+ enumerable: false,
5075
+ configurable: true
5076
+ });
5077
+ /**
5078
+ * @internal Marks this file's session as spent. There is no matching release:
5079
+ * a session that has been attached can never replay for another renderer.
5080
+ */
5081
+ RiveFile.prototype.claimSession = function () {
5082
+ this._sessionClaimed = true;
5083
+ };
5084
+ /**
5085
+ * @internal One warning per file however many instances collide on it.
5086
+ */
5087
+ RiveFile.prototype.warnBoundElsewhereOnce = function () {
5088
+ if (this.boundElsewhereWarned) {
5089
+ return;
5090
+ }
5091
+ this.boundElsewhereWarned = true;
5092
+ console.warn("Rive: this deferred RiveFile is already bound to another Rive instance's canvas, and a deferred session cannot span canvases. Re-importing the file for this instance (an extra parse of the retained buffer, no extra network request).");
5093
+ };
5094
+ /**
5095
+ * @internal Re-imports this file from its retained buffer into a mode of its
5096
+ * own. The copy is owned by whoever asked for it and never joins this file's
5097
+ * reference count.
5098
+ */
5099
+ RiveFile.prototype.reimport = function (deferred) {
5100
+ return __awaiter(this, void 0, void 0, function () {
5101
+ var copy;
5102
+ return __generator(this, function (_a) {
5103
+ switch (_a.label) {
5104
+ case 0:
5105
+ copy = new RiveFile({
5106
+ buffer: this.buffer,
5107
+ assetLoader: this.assetLoader,
5108
+ enableRiveAssetCDN: this.enableRiveAssetCDN,
5109
+ enablePerfMarks: this.enablePerfMarks,
5110
+ enableGPUCanvas: deferred,
5111
+ });
5112
+ return [4 /*yield*/, copy.init()];
5113
+ case 1:
5114
+ _a.sent();
5115
+ return [2 /*return*/, copy];
5116
+ }
5117
+ });
5118
+ });
5119
+ };
4907
5120
  /**
4908
5121
  * Unsubscribes all Rive listeners from an event type, or everything if no type is
4909
5122
  * given
@@ -4974,6 +5187,8 @@ var RiveFile = /** @class */ (function () {
4974
5187
  RiveFile.missingErrorMessage = "Rive source file or data buffer required";
4975
5188
  // Error message for file load error
4976
5189
  RiveFile.fileLoadErrorMessage = "The file failed to load";
5190
+ // Deferred support is per build, so the warning is per page, not per file.
5191
+ RiveFile.deferredUnsupportedWarned = false;
4977
5192
  return RiveFile;
4978
5193
  }());
4979
5194
 
@@ -4995,6 +5210,13 @@ var Rive = /** @class */ (function () {
4995
5210
  * and start.
4996
5211
  */
4997
5212
  this.readyForPlaying = false;
5213
+ // Deferred rendering was requested for this instance. The file it renders
5214
+ // has the final say, since a file's mode is fixed at import.
5215
+ this.deferredRenderer = false;
5216
+ // Whether this instance imported the file in `riveFile` (true) or the caller
5217
+ // supplied it (false). Only a file we imported may be released without a
5218
+ // matching getInstance(): a caller's file is theirs however this init ends.
5219
+ this.ownsRiveFile = false;
4998
5220
  // Runtime artboard
4999
5221
  this.artboard = null;
5000
5222
  // place to clear up pointer/touch event listeners
@@ -5129,6 +5351,7 @@ var Rive = /** @class */ (function () {
5129
5351
  _runtimeLoader__WEBPACK_IMPORTED_MODULE_1__.RuntimeLoader.enablePerfMarks = true;
5130
5352
  this._focusOptions = (_c = params.focusOptions) !== null && _c !== void 0 ? _c : this._focusOptions;
5131
5353
  this._tabIndex = (_d = params.tabIndex) !== null && _d !== void 0 ? _d : null;
5354
+ this.deferredRenderer = !!params.enableGPUCanvas;
5132
5355
  // New event management system
5133
5356
  this.eventManager = new EventManager();
5134
5357
  if (params.onLoad)
@@ -5185,6 +5408,7 @@ var Rive = /** @class */ (function () {
5185
5408
  tabIndex: params.tabIndex,
5186
5409
  semanticsMode: params.semanticsMode,
5187
5410
  semanticsOptions: params.semanticsOptions,
5411
+ enableGPUCanvas: this.deferredRenderer,
5188
5412
  });
5189
5413
  }
5190
5414
  Object.defineProperty(Rive.prototype, "viewModelCount", {
@@ -5244,26 +5468,52 @@ var Rive = /** @class */ (function () {
5244
5468
  // Initializes the Rive object either from constructor or load()
5245
5469
  Rive.prototype.init = function (_a) {
5246
5470
  var _this = this;
5247
- var src = _a.src, buffer = _a.buffer, riveFile = _a.riveFile, stateMachine = _a.stateMachine, animations = _a.animations, stateMachines = _a.stateMachines, artboard = _a.artboard, _b = _a.autoplay, autoplay = _b === void 0 ? false : _b, _c = _a.useOffscreenRenderer, useOffscreenRenderer = _c === void 0 ? false : _c, _d = _a.autoBind, autoBind = _d === void 0 ? false : _d, tabIndex = _a.tabIndex, semanticsMode = _a.semanticsMode, semanticsOptions = _a.semanticsOptions;
5471
+ var _b, _c, _d, _e, _f;
5472
+ var src = _a.src, buffer = _a.buffer, riveFile = _a.riveFile, stateMachine = _a.stateMachine, animations = _a.animations, stateMachines = _a.stateMachines, artboard = _a.artboard, _g = _a.autoplay, autoplay = _g === void 0 ? false : _g, _h = _a.useOffscreenRenderer, useOffscreenRenderer = _h === void 0 ? false : _h, _j = _a.autoBind, autoBind = _j === void 0 ? false : _j, tabIndex = _a.tabIndex, semanticsMode = _a.semanticsMode, semanticsOptions = _a.semanticsOptions, enableGPUCanvas = _a.enableGPUCanvas;
5248
5473
  if (this.destroyed) {
5249
5474
  return;
5250
5475
  }
5476
+ // Validated before any state changes, so a call with no source leaves a
5477
+ // running instance untouched.
5478
+ if (!src && !buffer && !riveFile) {
5479
+ throw new RiveError(Rive.missingErrorMessage);
5480
+ }
5481
+ // Reload releases the outgoing file in the same order cleanup() uses:
5482
+ // artboard, then the renderer's session, then the file. The artboard goes
5483
+ // first because it holds an rcp<File> and its resources came from the
5484
+ // session about to be released. stop() has already deleted the animation
5485
+ // and state machine instances; reload deliberately skips cleanupInstances(),
5486
+ // which would also drop the event listeners load() keeps in place.
5487
+ if (this.artboard) {
5488
+ // Free GPU-backed resources with their own context current. No-op on
5489
+ // the canvas2d build.
5490
+ (_c = (_b = this.renderer) === null || _b === void 0 ? void 0 : _b.bindContext) === null || _c === void 0 ? void 0 : _c.call(_b);
5491
+ (_d = this.animator) === null || _d === void 0 ? void 0 : _d.stop();
5492
+ this.artboard.delete();
5493
+ this.artboard = null;
5494
+ }
5495
+ // Detach before the session is deleted: the handle dies with it.
5496
+ if (this.renderer) {
5497
+ (_f = (_e = this.renderer).detachSession) === null || _f === void 0 ? void 0 : _f.call(_e);
5498
+ }
5499
+ this.releaseCurrentRiveFile(/* isTeardown */ false);
5251
5500
  this.src = src;
5252
5501
  this.buffer = buffer;
5253
5502
  this.riveFile = riveFile;
5503
+ // initData flips this if it ends up importing the file itself.
5504
+ this.ownsRiveFile = false;
5505
+ // Sticky across reloads so a constructor-set flag survives; an explicit
5506
+ // `false` still turns it off.
5507
+ this.deferredRenderer = enableGPUCanvas !== null && enableGPUCanvas !== void 0 ? enableGPUCanvas : this.deferredRenderer;
5254
5508
  this._tabIndex = tabIndex !== null && tabIndex !== void 0 ? tabIndex : null;
5255
5509
  this.semanticsMode = semanticsMode !== null && semanticsMode !== void 0 ? semanticsMode : _semantics__WEBPACK_IMPORTED_MODULE_2__.SemanticMode.Disabled;
5256
5510
  this.semanticsOptions = semanticsOptions !== null && semanticsOptions !== void 0 ? semanticsOptions : this.semanticsOptions;
5257
- // If no source file url specified, it's a bust
5258
- if (!this.src && !this.buffer && !this.riveFile) {
5259
- throw new RiveError(Rive.missingErrorMessage);
5260
- }
5261
5511
  // Names of the animations and state machines that should be initialized
5262
- var _e = resolveStartingPlayback({
5512
+ var _k = resolveStartingPlayback({
5263
5513
  stateMachine: stateMachine,
5264
5514
  animations: animations,
5265
5515
  stateMachines: stateMachines,
5266
- }), startingAnimationNames = _e.startingAnimationNames, startingStateMachineNames = _e.startingStateMachineNames;
5516
+ }), startingAnimationNames = _k.startingAnimationNames, startingStateMachineNames = _k.startingStateMachineNames;
5267
5517
  // Ensure loaded is marked as false if loading new file
5268
5518
  this.loaded = false;
5269
5519
  this.readyForPlaying = false;
@@ -5283,6 +5533,8 @@ var Rive = /** @class */ (function () {
5283
5533
  if (_this.enablePerfMarks)
5284
5534
  performance.mark('rive:make-renderer:start');
5285
5535
  try {
5536
+ // Always immediate at creation; a deferred file attaches its session
5537
+ // to this renderer once the file has loaded.
5286
5538
  _this.renderer = _this.runtime.makeRenderer(_this.canvas, useOffscreenRenderer);
5287
5539
  if (!_this.renderer) {
5288
5540
  throw new Error("Renderer is null, cannot render Rive on the canvas.");
@@ -5435,32 +5687,52 @@ var Rive = /** @class */ (function () {
5435
5687
  // Returns true for successful initialization.
5436
5688
  Rive.prototype.initData = function (artboardName, animationNames, stateMachineNames, autoplay, autoBind) {
5437
5689
  return __awaiter(this, void 0, void 0, function () {
5438
- var riveFile, error_3, msg;
5439
- var _a;
5440
- return __generator(this, function (_b) {
5441
- switch (_b.label) {
5690
+ var riveFile, error_4, msg;
5691
+ var _a, _b;
5692
+ return __generator(this, function (_c) {
5693
+ switch (_c.label) {
5442
5694
  case 0:
5443
- _b.trys.push([0, 3, , 4]);
5444
- if (!(this.riveFile == null)) return [3 /*break*/, 2];
5695
+ _c.trys.push([0, 5, , 6]);
5696
+ // A caller-supplied riveFile is theirs to release; one we import here is
5697
+ // ours, which matters if a deferred fallback replaces it below.
5698
+ this.ownsRiveFile = this.riveFile == null;
5699
+ if (!this.ownsRiveFile) return [3 /*break*/, 2];
5445
5700
  riveFile = new RiveFile({
5446
5701
  src: this.src,
5447
5702
  buffer: this.buffer,
5448
5703
  enableRiveAssetCDN: this.enableRiveAssetCDN,
5449
5704
  assetLoader: this.assetLoader,
5450
5705
  enablePerfMarks: this.enablePerfMarks,
5706
+ // The instance owns this file, so its flag is the file's flag.
5707
+ enableGPUCanvas: this.deferredRenderer,
5451
5708
  });
5452
5709
  this.riveFile = riveFile;
5453
5710
  return [4 /*yield*/, riveFile.init()];
5454
5711
  case 1:
5455
- _b.sent();
5712
+ _c.sent();
5456
5713
  if (this.destroyed) {
5457
5714
  // In the very unlikely scenario where the rive file created by this Rive is shared by
5458
5715
  // another rive file, we only want to destroy it if this file is the only owner.
5459
5716
  riveFile.destroyIfUnused();
5460
5717
  return [2 /*return*/, false];
5461
5718
  }
5462
- _b.label = 2;
5719
+ _c.label = 2;
5463
5720
  case 2:
5721
+ if (!(this.riveFile.deferredSession !== null || this.deferredRenderer)) return [3 /*break*/, 4];
5722
+ return [4 /*yield*/, this.resolveDeferredRendering()];
5723
+ case 3:
5724
+ _c.sent();
5725
+ if (this.destroyed) {
5726
+ // cleanup() ran during a re-import. Taking a reference now would
5727
+ // resurrect a file this instance is never going to draw. Only ours
5728
+ // to release — a caller-supplied file stays theirs.
5729
+ if (this.ownsRiveFile) {
5730
+ (_a = this.riveFile) === null || _a === void 0 ? void 0 : _a.destroyIfUnused();
5731
+ }
5732
+ return [2 /*return*/, false];
5733
+ }
5734
+ _c.label = 4;
5735
+ case 4:
5464
5736
  this.file = this.riveFile.getInstance();
5465
5737
  // Initialize and draw frame
5466
5738
  this.initArtboard(artboardName, animationNames, stateMachineNames, autoplay, autoBind);
@@ -5479,7 +5751,7 @@ var Rive = /** @class */ (function () {
5479
5751
  this.loaded = true;
5480
5752
  this.eventManager.fire({
5481
5753
  type: EventType.Load,
5482
- data: (_a = this.src) !== null && _a !== void 0 ? _a : "buffer",
5754
+ data: (_b = this.src) !== null && _b !== void 0 ? _b : "buffer",
5483
5755
  });
5484
5756
  }
5485
5757
  catch (e) {
@@ -5497,12 +5769,114 @@ var Rive = /** @class */ (function () {
5497
5769
  this.taskQueue.process();
5498
5770
  this.drawFrame();
5499
5771
  return [2 /*return*/, true];
5500
- case 3:
5501
- error_3 = _b.sent();
5502
- msg = resolveErrorMessage(error_3);
5772
+ case 5:
5773
+ error_4 = _c.sent();
5774
+ msg = resolveErrorMessage(error_4);
5503
5775
  this.eventManager.fire({ type: EventType.LoadError, data: msg });
5504
5776
  return [2 /*return*/, Promise.reject(msg)];
5505
- case 4: return [2 /*return*/];
5777
+ case 6: return [2 /*return*/];
5778
+ }
5779
+ });
5780
+ });
5781
+ };
5782
+ /**
5783
+ * Settles which rendering mode this Rive instance runs in. The file dictates: its rendering mode
5784
+ * is fixed at import, and an immediate renderer silently drops a deferred
5785
+ * file's resources. Every mismatch warns and degrades to something that
5786
+ * renders, so users shouldn't have a blank canvas. A fallback self-reimport replaces `this.riveFile`;
5787
+ * only a file this instance imported is released when that happens.
5788
+ */
5789
+ Rive.prototype.resolveDeferredRendering = function () {
5790
+ return __awaiter(this, void 0, void 0, function () {
5791
+ var file, ownsFile, renderer, session, attachSession, immediate, copy, copySession, fallback;
5792
+ var _a;
5793
+ return __generator(this, function (_b) {
5794
+ switch (_b.label) {
5795
+ case 0:
5796
+ file = this.riveFile;
5797
+ ownsFile = this.ownsRiveFile;
5798
+ renderer = this.renderer;
5799
+ session = file.deferredSession;
5800
+ if (session === null) {
5801
+ // No second warning when the file asked for deferred and the build
5802
+ // could not honor it; the unsupported-build warning already fired, and
5803
+ // telling the user to set a flag they set would mislead.
5804
+ if (this.deferredRenderer && !file.deferredRequested) {
5805
+ console.warn("Rive: `enableGPUCanvas: true` was ignored because this RiveFile was imported without it. The mode is fixed at import: construct the RiveFile with `enableGPUCanvas: true` to opt in.");
5806
+ }
5807
+ return [2 /*return*/];
5808
+ }
5809
+ if (!this.deferredRenderer) {
5810
+ console.warn("Rive: this RiveFile was imported with `enableGPUCanvas: true`, so this instance renders deferred even though `enableGPUCanvas` is false on the instance. An immediate renderer would drop the file's deferred resources and draw nothing.");
5811
+ }
5812
+ attachSession = renderer === null || renderer === void 0 ? void 0 : renderer.attachSession;
5813
+ if (!(typeof attachSession !== "function")) return [3 /*break*/, 2];
5814
+ // Offscreen renderers share one context across canvases, which a session
5815
+ // cannot record for. An immediate copy of the file still renders.
5816
+ console.warn("Rive: this renderer cannot replay a deferred session (`useOffscreenRenderer` is not supported with deferred rendering). Re-importing the file in immediate mode for this instance.");
5817
+ return [4 /*yield*/, file.reimport(false)];
5818
+ case 1:
5819
+ immediate = _b.sent();
5820
+ if (this.destroyed) {
5821
+ // cleanup() ran while we were importing; nothing will use this copy.
5822
+ immediate.destroyIfUnused();
5823
+ return [2 /*return*/];
5824
+ }
5825
+ this.riveFile = immediate;
5826
+ this.ownsRiveFile = true;
5827
+ if (ownsFile) {
5828
+ // Nothing else can reach the deferred import we just walked away from.
5829
+ file.destroyIfUnused();
5830
+ }
5831
+ return [2 /*return*/];
5832
+ case 2:
5833
+ // Never re-offered once claimed, even if that renderer is gone: the
5834
+ // resources the session's stream refers to died with it.
5835
+ if (!file.sessionClaimed && attachSession.call(renderer, session)) {
5836
+ file.claimSession();
5837
+ return [2 /*return*/];
5838
+ }
5839
+ // Bound to another instance. Re-import from the retained buffer into a
5840
+ // session of our own.
5841
+ file.warnBoundElsewhereOnce();
5842
+ return [4 /*yield*/, file.reimport(true)];
5843
+ case 3:
5844
+ copy = _b.sent();
5845
+ if (this.destroyed) {
5846
+ // The renderer was deleted while we imported; attaching to it would hand
5847
+ // embind a deleted object.
5848
+ copy.destroyIfUnused();
5849
+ return [2 /*return*/];
5850
+ }
5851
+ this.riveFile = copy;
5852
+ this.ownsRiveFile = true;
5853
+ copySession = copy.deferredSession;
5854
+ if (copySession !== null && attachSession.call(renderer, copySession)) {
5855
+ copy.claimSession();
5856
+ return [2 /*return*/];
5857
+ }
5858
+ // The copy's session could not take this canvas either (this renderer
5859
+ // already holds one). An immediate re-import still renders; a deferred file
5860
+ // on an immediate renderer would drop its resources and draw nothing.
5861
+ console.warn("Rive: could not attach the re-imported file's deferred session to this canvas; falling back to immediate rendering for this instance.");
5862
+ // If a leftover session is why the attach failed, it would keep routing
5863
+ // the immediate file's draws into its recorder, which drops them.
5864
+ (_a = renderer.detachSession) === null || _a === void 0 ? void 0 : _a.call(renderer);
5865
+ return [4 /*yield*/, file.reimport(false)];
5866
+ case 4:
5867
+ fallback = _b.sent();
5868
+ // The deferred copy was only ever ours, so it always goes.
5869
+ copy.destroyIfUnused();
5870
+ if (this.destroyed) {
5871
+ fallback.destroyIfUnused();
5872
+ return [2 /*return*/];
5873
+ }
5874
+ this.riveFile = fallback;
5875
+ this.ownsRiveFile = true;
5876
+ if (ownsFile) {
5877
+ file.destroyIfUnused();
5878
+ }
5879
+ return [2 /*return*/];
5506
5880
  }
5507
5881
  });
5508
5882
  });
@@ -5597,6 +5971,13 @@ var Rive = /** @class */ (function () {
5597
5971
  }
5598
5972
  return changed;
5599
5973
  };
5974
+ // Content the artboard's change flag cannot see: ore and GPU canvas commands
5975
+ // scripts record straight into the session. Must be read before the renderer
5976
+ // clears — clearing marks the stream, so a later read is true every frame.
5977
+ Rive.prototype._deferredWorkPending = function () {
5978
+ var _a, _b, _c;
5979
+ return (_c = (_b = (_a = this.riveFile) === null || _a === void 0 ? void 0 : _a.deferredSession) === null || _b === void 0 ? void 0 : _b.recordedThisFrame()) !== null && _c !== void 0 ? _c : false;
5980
+ };
5600
5981
  /**
5601
5982
  * Poll focus state each frame to see if we should focus/blur the canvas in case
5602
5983
  * Rive internally updated focus outside of user interaction (e.g., via listener action)
@@ -5806,6 +6187,11 @@ var Rive = /** @class */ (function () {
5806
6187
  Rive.prototype.draw = function (time, onSecond) {
5807
6188
  // Clear the frameRequestId, as we're now rendering a fresh frame
5808
6189
  this.frameRequestId = null;
6190
+ // load() tears the artboard down and re-inits asynchronously; a frame
6191
+ // queued before that lands here with nothing to draw.
6192
+ if (!this.artboard) {
6193
+ return;
6194
+ }
5809
6195
  var before = performance.now();
5810
6196
  // Instrument the first 3 frames so the Performance timeline shows precise
5811
6197
  // per-call latency for advance, draw, and flush without polluting the trace.
@@ -5827,9 +6213,13 @@ var Rive = /** @class */ (function () {
5827
6213
  var renderer = this.renderer;
5828
6214
  // Do not draw on 0 canvas size
5829
6215
  if (!this._hasZeroSize) {
5830
- // If there was no dirt on this frame, do not clear and draw
6216
+ // If there was no dirt on this frame, do not clear and draw. The deferred
6217
+ // term has to be read here, before `clear()` below: clearing opens the
6218
+ // session's recording window and marks its stream, so a read taken after
6219
+ // it reports every frame as dirty and nothing is ever skipped.
5831
6220
  if (this.drawOptimization == DrawOptimizationOptions.AlwaysDraw ||
5832
6221
  this.artboard.didChange() ||
6222
+ this._deferredWorkPending() ||
5833
6223
  this._needsRedraw ||
5834
6224
  this._canvasSizeChanged()) {
5835
6225
  // Canvas must be wiped to prevent artifacts
@@ -5927,7 +6317,7 @@ var Rive = /** @class */ (function () {
5927
6317
  * Rive class
5928
6318
  */
5929
6319
  Rive.prototype.cleanup = function () {
5930
- var _a, _b, _c, _d;
6320
+ var _a, _b, _c, _d, _e;
5931
6321
  this.destroyed = true;
5932
6322
  // Stop the renderer if it hasn't already been stopped.
5933
6323
  this.stopRendering();
@@ -5943,10 +6333,14 @@ var Rive = /** @class */ (function () {
5943
6333
  observers.remove(this._observed);
5944
6334
  }
5945
6335
  this.removeRiveListeners();
5946
- if (this.file) {
5947
- (_c = this.riveFile) === null || _c === void 0 ? void 0 : _c.cleanup();
5948
- this.file = null;
5949
- }
6336
+ // The file and its session go before the renderer: the session's replay
6337
+ // state lives in the renderer's context. But the renderer must let go of
6338
+ // the session first — its detach handle dies with session.delete(), and a
6339
+ // later detach would pass embind a deleted object.
6340
+ if (this.renderer) {
6341
+ (_d = (_c = this.renderer).detachSession) === null || _d === void 0 ? void 0 : _d.call(_c);
6342
+ }
6343
+ this.releaseCurrentRiveFile(/* isTeardown */ true);
5950
6344
  this.riveFile = null;
5951
6345
  this.deleteRiveRenderer();
5952
6346
  if (this._audioEventListener !== null) {
@@ -5957,21 +6351,65 @@ var Rive = /** @class */ (function () {
5957
6351
  document.removeEventListener('visibilitychange', this._pageVisibilityHandler);
5958
6352
  this._pageVisibilityHandler = null;
5959
6353
  }
5960
- (_d = this._viewModelInstance) === null || _d === void 0 ? void 0 : _d.cleanup();
6354
+ (_e = this._viewModelInstance) === null || _e === void 0 ? void 0 : _e.cleanup();
5961
6355
  this._viewModelInstance = null;
5962
6356
  this._globalViewModelInstances.forEach(function (instance) { return instance.cleanup(); });
5963
6357
  this._globalViewModelInstances.clear();
5964
6358
  this._dataEnums = null;
5965
6359
  };
6360
+ /**
6361
+ * Drops this instance's hold on `this.riveFile`. A reference taken through
6362
+ * getInstance() is given back; a file we imported but never referenced is
6363
+ * released outright so its session goes with it. A caller-supplied file we
6364
+ * never referenced is left alone.
6365
+ *
6366
+ * `isTeardown` distinguishes cleanup() from a reload. Teardown always hands
6367
+ * the reference back, as it always has. A reload must not do that for a
6368
+ * caller-supplied file: a RiveFile carries no reference for its creator, so
6369
+ * releasing here would take the last one and destroy a file the caller still
6370
+ * holds.
6371
+ */
6372
+ Rive.prototype.releaseCurrentRiveFile = function (isTeardown) {
6373
+ var _a, _b;
6374
+ if (this.file) {
6375
+ if (isTeardown || this.ownsRiveFile) {
6376
+ (_a = this.riveFile) === null || _a === void 0 ? void 0 : _a.cleanup();
6377
+ }
6378
+ this.file = null;
6379
+ }
6380
+ else if (this.ownsRiveFile) {
6381
+ (_b = this.riveFile) === null || _b === void 0 ? void 0 : _b.destroyIfUnused();
6382
+ }
6383
+ };
5966
6384
  /**
5967
6385
  * Cleans up the Renderer object. Only call this API if you no longer
5968
6386
  * need to render Rive content in your session.
5969
6387
  */
5970
6388
  Rive.prototype.deleteRiveRenderer = function () {
5971
- var _a;
5972
- (_a = this.renderer) === null || _a === void 0 ? void 0 : _a.delete();
6389
+ var _a, _b;
6390
+ if (this.renderer) {
6391
+ // A session outliving this renderer has to stop pointing at it, and its
6392
+ // replay state has to drop while this context is still alive. No-op when
6393
+ // nothing was ever attached.
6394
+ (_b = (_a = this.renderer).detachSession) === null || _b === void 0 ? void 0 : _b.call(_a);
6395
+ this.renderer.delete();
6396
+ }
5973
6397
  this.renderer = null;
5974
6398
  };
6399
+ Object.defineProperty(Rive.prototype, "deferredRendererActive", {
6400
+ /**
6401
+ * @experimental This API is early and may encounter breaking behavior change without a major version bump
6402
+ *
6403
+ * Whether this instance is rendering through a deferred session. False whenever
6404
+ * a fallback ran, whatever was requested.
6405
+ */
6406
+ get: function () {
6407
+ var _a, _b, _c;
6408
+ return (_c = (_b = (_a = this.renderer) === null || _a === void 0 ? void 0 : _a.deferredActive) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : false;
6409
+ },
6410
+ enumerable: false,
6411
+ configurable: true
6412
+ });
5975
6413
  /**
5976
6414
  * Cleans up any Wasm-generated objects that need to be manually destroyed:
5977
6415
  * artboard instances, animation instances, state machine instances.
@@ -6203,7 +6641,10 @@ var Rive = /** @class */ (function () {
6203
6641
  };
6204
6642
  // Loads a new Rive file, keeping listeners in place
6205
6643
  Rive.prototype.load = function (params) {
6206
- this.file = null;
6644
+ // Before stop(), so a call with no source leaves playback running.
6645
+ if (!params.src && !params.buffer && !params.riveFile) {
6646
+ throw new RiveError(Rive.missingErrorMessage);
6647
+ }
6207
6648
  // Stop all animations
6208
6649
  this.stop();
6209
6650
  // Reinitialize
@@ -8067,7 +8508,7 @@ var decodeAudio = function (bytes) { return __awaiter(void 0, void 0, void 0, fu
8067
8508
  case 0:
8068
8509
  decodedPromise = new Promise(function (resolve) {
8069
8510
  return _runtimeLoader__WEBPACK_IMPORTED_MODULE_1__.RuntimeLoader.getInstance(function (rive) {
8070
- rive.decodeAudio(bytes, resolve);
8511
+ rive.decodeAudio(bytes, resolve, null);
8071
8512
  });
8072
8513
  });
8073
8514
  return [4 /*yield*/, decodedPromise];
@@ -8092,7 +8533,7 @@ var decodeImage = function (bytes) { return __awaiter(void 0, void 0, void 0, fu
8092
8533
  case 0:
8093
8534
  decodedPromise = new Promise(function (resolve) {
8094
8535
  return _runtimeLoader__WEBPACK_IMPORTED_MODULE_1__.RuntimeLoader.getInstance(function (rive) {
8095
- rive.decodeImage(bytes, resolve);
8536
+ rive.decodeImage(bytes, resolve, null);
8096
8537
  });
8097
8538
  });
8098
8539
  return [4 /*yield*/, decodedPromise];
@@ -8117,7 +8558,7 @@ var decodeFont = function (bytes) { return __awaiter(void 0, void 0, void 0, fun
8117
8558
  case 0:
8118
8559
  decodedPromise = new Promise(function (resolve) {
8119
8560
  return _runtimeLoader__WEBPACK_IMPORTED_MODULE_1__.RuntimeLoader.getInstance(function (rive) {
8120
- rive.decodeFont(bytes, resolve);
8561
+ rive.decodeFont(bytes, resolve, null);
8121
8562
  });
8122
8563
  });
8123
8564
  return [4 /*yield*/, decodedPromise];