UNPKG

octopus-svga

Version:

高性能SVGA动效播放器,支持Web/微信小程序/支付宝小程序/抖音小程序,设计目标是 解析速度更快、体积更小、性能更高、兼容性更高、功能更丰富。

1 lines 50.9 kB
import{createPlatform as t,pluginSelector as e,pluginCanvas as s,pluginOfsCanvas as r,pluginCodec as n,pluginDownload as i,pluginFsm as a,pluginImage as o,pluginNow as l,pluginPath as c,pluginRAF as h}from"octopus-platform";const u=t([e,s,r,n,i,a,o,l,c,h],"2.0.1");class f{painter;static isBitmap(t){return"h5"===u.globals.env&&t instanceof ImageBitmap}static releaseOne(t){f.isBitmap(t)?t.close():""!==t.src&&(u.path.is(t.src)&&u.local.remove(t.src),u.image.release(t))}caches=[];dynamicMaterials=new Map;materials=new Map;point=0;constructor(t){this.painter=t}createImage(){let t=null;return this.point>0&&(this.point--,t=this.caches.shift()),t||(t=u.image.create(this.painter.F)),this.caches.push(t),t}inertBitmapIntoCaches(t){f.isBitmap(t)&&this.caches.push(t)}loadExtImage(t,e){return u.image.load((()=>this.createImage()),t,u.path.resolve(e,"ext")).then((t=>(this.inertBitmapIntoCaches(t),t)))}async loadImagesWithRecord(t,e,s="normal"){const r=[],n=`${e.replace(/\.svga$/g,"")}.png`;Object.entries(t).forEach((([t,e])=>{if(e instanceof Uint8Array&&e.byteLength<70)return;const i=u.image.load((()=>this.createImage()),e,u.path.resolve(n,"dynamic"===s?`dyn_${t}`:t)).then((e=>{this.inertBitmapIntoCaches(e),"dynamic"===s?this.dynamicMaterials.set(t,e):this.materials.set(t,e)}));r.push(i)})),await Promise.all(r)}release(){for(const t of this.caches)f.releaseOne(t);this.materials.clear(),this.dynamicMaterials.clear(),"alipay"===u.globals.env?this.cleanup():this.tidyUp()}tidyUp(){this.caches=Array.from(new Set(this.caches)),this.point=this.caches.length}cleanup(){this.caches.length=0,this.point=0}}const d=function(){const t=Array(4).fill(0).map((()=>new DataView(new ArrayBuffer(8))));let e=0;return function(s,r){if(r<0||r+4>s.length)throw new RangeError("Index out of range");const n=t[e];e=(e+1)%4;const i=new Uint8Array(n.buffer);return i[0]=s[r],i[1]=s[r+1],i[2]=s[r+2],i[3]=s[r+3],n.getFloat32(0,!0)}}();class p{caches=new Map;count=0;get size(){return this.caches.size}get hitCount(){return this.count}calculate(t,e){const{pos:s,buf:r}=t,n=Math.min(e,t.len);return function(t,e,s,r){let n=0;for(let i=e;i<s;i+=r)n=(n<<5)-n+t[i],n|=0;return n=(n<<5)-n+s-e,n|=0,n.toString(36)}(r,s,n,Math.max(1,Math.floor((n-s)/100)))}has(t){const e=this.caches.has(t);return e&&this.count++,e}get(t){return this.caches.get(t)}set(t,e){this.caches.set(t,e)}clear(){this.count=0,this.caches.clear()}}class m{static EMPTY_UINT8ARRAY=new Uint8Array(0);buf;len;pos;preflight=new p;constructor(t){this.buf=t,this.pos=0,this.len=t.length}indexOutOfRange(t,e){return new RangeError("index out of range: "+t.pos+" + "+(e||1)+" > "+t.len)}readVarint32Slow(){let t=this.buf[this.pos++],e=127&t,s=7;do{if(this.pos>=this.len)throw this.indexOutOfRange(this);t=this.buf[this.pos++],e|=(127&t)<<s,s+=7}while(t>=128&&s<32);return e>>>0}end(t){return void 0===t?this.len:this.pos+t}uint32(){const t=this.buf[this.pos];return t<128?(this.pos++,t):this.readVarint32Slow()}int32(){return 0|this.uint32()}float(){const t=this.pos+4;if(t>this.len)throw this.indexOutOfRange(this,4);const e=d(this.buf,this.pos);return this.pos=t,e}getBytesRange(){const t=this.uint32(),e=this.pos,s=e+t;if(s>this.len)throw this.indexOutOfRange(this,t);return[e,s,t]}bytes(){const[t,e,s]=this.getBytesRange();return this.pos+=s,0===s?m.EMPTY_UINT8ARRAY:this.buf.subarray(t,e)}string(){const[t,e]=this.getBytesRange(),s=u.codec.utf8(this.buf,t,e);return this.pos=e,s}skip(t){if("number"==typeof t){if(this.pos+t>this.len)throw this.indexOutOfRange(this,t);return this.pos+=t,this}const{buf:e,len:s}=this;let r=this.pos;for(;r<s;){if(!(128&e[r++]))return this.pos=r,this;if(r<s&&128&e[r]&&(r++,r<s&&128&e[r]&&(r++,r<s&&128&e[r]))){for(r++;r<s&&128&e[r];)if(r++,r-this.pos>=10)throw Error("invalid varint encoding");if(r<s)return this.pos=r+1,this}}throw this.indexOutOfRange(this)}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(t=7&this.uint32());)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+t+" at offset "+this.pos)}return this}}class g{static decode(t,e){const{preflight:s}=t,r=t.end(e),n=s.calculate(t,r);if(s.has(n))return t.pos=r,s.get(n);const i=new g;let a;for(;t.pos<r;)switch(a=t.uint32(),a>>>3){case 1:i.x=t.float();break;case 2:i.y=t.float();break;case 3:i.width=t.float();break;case 4:i.height=t.float();break;default:t.skipType(7&a)}return s.set(n,g.format(i)),s.get(n)}static format(t){const{x:e=0,y:s=0,width:r=0,height:n=0}=t;return{x:e,y:s,width:r,height:n}}x=0;y=0;width=0;height=0}class y{static decode(t,e){const s=t.end(e),r=new y;let n;for(;t.pos<s;)switch(n=t.uint32(),n>>>3){case 1:r.a=t.float();break;case 2:r.b=t.float();break;case 3:r.c=t.float();break;case 4:r.d=t.float();break;case 5:r.tx=t.float();break;case 6:r.ty=t.float();break;default:t.skipType(7&n)}return r}a=0;b=0;c=0;d=0;tx=0;ty=0}class w{static decode(t,e){const{preflight:s}=t,r=t.end(e),n=s.calculate(t,r);if(s.has(n))return t.pos=r,s.get(n);const i=new w;let a;for(;t.pos<r;)if(a=t.uint32(),a>>>3==1)i.d=t.string();else t.skipType(7&a);return s.set(n,i),s.get(n)}d=""}class b{static decode(t,e){const{preflight:s}=t,r=t.end(e),n=s.calculate(t,r);if(s.has(n))return t.pos=r,s.get(n);const i=new b;let a;for(;t.pos<r;)switch(a=t.uint32(),a>>>3){case 1:i.x=t.float();break;case 2:i.y=t.float();break;case 3:i.width=t.float();break;case 4:i.height=t.float();break;case 5:i.cornerRadius=t.float();break;default:t.skipType(7&a)}return s.set(n,i),s.get(n)}x=0;y=0;width=0;height=0;cornerRadius=0}class k{static decode(t,e){const{preflight:s}=t,r=t.end(e),n=s.calculate(t,r);if(s.has(n))return t.pos=r,s.get(n);const i=new k;let a;for(;t.pos<r;)switch(a=t.uint32(),a>>>3){case 1:i.x=t.float();break;case 2:i.y=t.float();break;case 3:i.radiusX=t.float();break;case 4:i.radiusY=t.float();break;default:t.skipType(7&a)}return s.set(n,i),s.get(n)}x=0;y=0;radiusX=0;radiusY=0}class x{static decode(t,e){const{preflight:s}=t,r=t.end(e),n=s.calculate(t,r);if(s.has(n))return t.pos=r,s.get(n);const i=new x;let a;for(;t.pos<r;)switch(a=t.uint32(),a>>>3){case 1:i.r=t.float();break;case 2:i.g=t.float();break;case 3:i.b=t.float();break;case 4:i.a=t.float();break;default:t.skipType(7&a)}return s.set(n,x.format(i)),s.get(n)}static format(t){const{r:e,g:s,b:r,a:n}=t;return`rgba(${255*e|0}, ${255*s|0}, ${255*r|0}, ${1*n|0})`}r=0;g=0;b=0;a=0}class T{static decode(t,e){const{preflight:s}=t,r=t.end(e),n=s.calculate(t,r);if(s.has(n))return t.pos=r,s.get(n);const i=new T;let a;for(;t.pos<r;)switch(a=t.uint32(),a>>>3){case 1:i.fill=x.decode(t,t.uint32());break;case 2:i.stroke=x.decode(t,t.uint32());break;case 3:i.strokeWidth=t.float();break;case 4:i.lineCap=t.int32();break;case 5:i.lineJoin=t.int32();break;case 6:i.miterLimit=t.float();break;case 7:i.lineDashI=t.float();break;case 8:i.lineDashII=t.float();break;case 9:i.lineDashIII=t.float();break;default:t.skipType(7&a)}return s.set(n,T.format(i)),s.get(n)}static format(t){const{fill:e,stroke:s,strokeWidth:r,miterLimit:n,lineDashI:i,lineDashII:a,lineDashIII:o}=t,l=[];let c,h;switch(i>0&&l.push(i),a>0&&(l.length<1&&l.push(0),l.push(a)),o>0&&(l.length<2&&l.push(0,0),l.push(o)),t.lineCap){case 0:c="butt";break;case 1:c="round";break;case 2:c="square"}switch(t.lineJoin){case 0:h="miter";break;case 1:h="round";break;case 2:h="bevel"}return{lineDash:l,fill:e||null,stroke:s||null,lineCap:c,lineJoin:h,strokeWidth:r,miterLimit:n}}fill=null;stroke=null;strokeWidth=0;lineCap=0;lineJoin=0;miterLimit=0;lineDashI=0;lineDashII=0;lineDashIII=0}class C{static decode(t,e){const s=t.end(e),r=new C;let n;for(;t.pos<s;)switch(n=t.uint32(),n>>>3){case 1:r.type=t.int32();break;case 2:r.shape=w.decode(t,t.uint32());break;case 3:r.rect=b.decode(t,t.uint32());break;case 4:r.ellipse=k.decode(t,t.uint32());break;case 10:r.styles=T.decode(t,t.uint32());break;case 11:r.transform=y.decode(t,t.uint32());break;default:t.skipType(7&n)}return C.format(r)}static format(t){const{type:e,shape:s,rect:r,ellipse:n,styles:i,transform:a}=t;switch(e){case 0:return{type:"shape",path:s,styles:i,transform:a};case 1:return{type:"rect",path:r,styles:i,transform:a};case 2:return{type:"ellipse",path:n,styles:i,transform:a}}return null}type=0;shape=null;rect=null;ellipse=null;styles=null;transform=null}class M{static HIDDEN_FRAME={alpha:0};static decode(t,e){const s=t.end(e),r=new M;let n;for(;t.pos<s;)switch(n=t.uint32(),n>>>3){case 1:r.alpha=t.float();break;case 2:r.layout=g.decode(t,t.uint32());break;case 3:r.transform=y.decode(t,t.uint32());break;case 4:r.clipPath=t.string();break;case 5:{const e=C.decode(t,t.uint32());null!==e&&r.shapes.push(e);break}default:t.skipType(7&n)}return 0===r.shapes.length?r.shapes=t.preflight.get("latest_shapes"):t.preflight.set("latest_shapes",r.shapes),M.format(r)}static format(t){if(t.alpha<.05)return M.HIDDEN_FRAME;const{alpha:e,layout:s,transform:r,shapes:n}=t;return{alpha:e,layout:s,transform:r,shapes:n}}shapes=[];alpha=0;layout=null;transform=null;clipPath=""}class E{static decode(t,e){const s=t.end(e),r=new E;let n;for(t.preflight.set("latest_shapes",[]);t.pos<s;)switch(n=t.uint32(),n>>>3){case 1:r.imageKey=t.string();break;case 2:r.frames&&r.frames.length||(r.frames=[]),r.frames.push(M.decode(t,t.uint32()));break;case 3:r.matteKey=t.string();break;default:t.skipType(7&n)}return E.format(r)}static format(t){return{imageKey:t.imageKey,frames:t.frames}}frames=[];imageKey="";matteKey=""}class A{static decode(t,e){const s=t.end(e),r=new A;let n;for(;t.pos<s;)switch(n=t.uint32(),n>>>3){case 1:r.viewBoxWidth=t.float();break;case 2:r.viewBoxHeight=t.float();break;case 3:r.fps=t.int32();break;case 4:r.frames=t.int32();break;default:t.skipType(7&n)}return r}viewBoxWidth=0;viewBoxHeight=0;fps=0;frames=0}class v{static EMPTY_U8=new Uint8Array(0);static decode(t,e){const s=t.end(e),r=new v;let n,i,a,o,l;for(;t.pos<s;)switch(o=t.uint32(),o>>>3){case 1:r.version=t.string();break;case 2:r.params=A.decode(t,t.uint32());break;case 3:for(a=t.uint32()+t.pos,n="",i=v.EMPTY_U8;t.pos<a;)switch(l=t.uint32(),l>>>3){case 1:n=t.string();break;case 2:i=t.bytes();break;default:t.skipType(7&l)}r.images[n]=i;break;case 4:r.sprites.push(E.decode(t,t.uint32()));break;default:t.skipType(7&o)}return v.format(r)}static format(t){const{version:e,images:s,sprites:r}=t,{fps:n,frames:i,viewBoxWidth:a,viewBoxHeight:o}=t.params;return{version:e,filename:"",locked:!1,dynamicElements:{},size:{width:a,height:o},fps:n,frames:i,images:s,sprites:r}}version="";params=null;images={};sprites=[]}class R{pool=[];acquire(){const{pool:t}=this;return t.length>0?t.pop():{x:0,y:0,x1:0,y1:0,x2:0,y2:0}}release(t){t.x=t.y=t.x1=t.y1=t.x2=t.y2=0,this.pool.push(t)}}class P{context;static SVG_PATH=new Set(["M","L","H","V","Z","C","S","Q","m","l","h","v","z","c","s","q"]);static SVG_LETTER_REGEXP=/[a-zA-Z]/;static parseSVGPath(t){const{SVG_LETTER_REGEXP:e}=P,s=[];let r=0,n=0,i="",a="";for(;r<t.length;){const o=t[r];switch(n){case 0:e.test(o)&&(i=o,n=1);break;case 1:e.test(o)?(s.push({command:i,args:a.trim()}),i=o,a=""):a+=o}r++}return i&&1===n&&s.push({command:i,args:a.trim()}),s}static fillOrStroke(t,e){e&&(e.fill&&t.fill(),e.stroke&&t.stroke())}static resetShapeStyles(t,e){e&&(t.strokeStyle=e.stroke||"transparent",e.strokeWidth>0&&(t.lineWidth=e.strokeWidth),e.miterLimit>0&&(t.miterLimit=e.miterLimit),e.lineCap&&(t.lineCap=e.lineCap),e.lineJoin&&(t.lineJoin=e.lineJoin),t.fillStyle=e.fill||"transparent",e.lineDash&&t.setLineDash(e.lineDash))}static calculateScale(t,e,s){const r=e.width/e.height,n=s.width/s.height,i="aspect-fit"===t,a=(t,e,s)=>({scaleX:t,scaleY:t,translateX:e,translateY:s});if(r>=n&&i||r<=n&&!i){const t=s.width/e.width;return a(t,0,(s.height-e.height*t)/2)}const o=s.height/e.height;return a(o,(s.width-e.width*o)/2,0)}pointPool=new R;currentPoint;lastResizeKey="";globalTransform=void 0;constructor(t){this.context=t,this.currentPoint=this.pointPool.acquire()}setTransform(t){t&&this.context&&this.context.transform(t.a,t.b,t.c,t.d,t.tx,t.ty)}drawBezier(t,e,s){const{context:r,pointPool:n}=this;if(this.currentPoint=n.acquire(),r.save(),P.resetShapeStyles(r,s),this.setTransform(e),r.beginPath(),t){const e=P.parseSVGPath(t);for(const{command:t,args:s}of e)P.SVG_PATH.has(t)&&this.drawBezierElement(this.currentPoint,t,s.split(/[\s,]+/).filter(Boolean))}P.fillOrStroke(r,s),n.release(this.currentPoint),r.restore()}drawBezierElement(t,e,s){const{context:r}=this;switch(e){case"M":t.x=+s[0],t.y=+s[1],r.moveTo(t.x,t.y);break;case"m":t.x+=+s[0],t.y+=+s[1],r.moveTo(t.x,t.y);break;case"L":t.x=+s[0],t.y=+s[1],r.lineTo(t.x,t.y);break;case"l":t.x+=+s[0],t.y+=+s[1],r.lineTo(t.x,t.y);break;case"H":t.x=+s[0],r.lineTo(t.x,t.y);break;case"h":t.x+=+s[0],r.lineTo(t.x,t.y);break;case"V":t.y=+s[0],r.lineTo(t.x,t.y);break;case"v":t.y+=+s[0],r.lineTo(t.x,t.y);break;case"C":t.x1=+s[0],t.y1=+s[1],t.x2=+s[2],t.y2=+s[3],t.x=+s[4],t.y=+s[5],r.bezierCurveTo(t.x1,t.y1,t.x2,t.y2,t.x,t.y);break;case"c":t.x1=t.x+ +s[0],t.y1=t.y+ +s[1],t.x2=t.x+ +s[2],t.y2=t.y+ +s[3],t.x+=+s[4],t.y+=+s[5],r.bezierCurveTo(t.x1,t.y1,t.x2,t.y2,t.x,t.y);break;case"S":void 0!==t.x1&&void 0!==t.y1&&void 0!==t.x2&&void 0!==t.y2?(t.x1=t.x-t.x2+t.x,t.y1=t.y-t.y2+t.y,t.x2=+s[0],t.y2=+s[1],t.x=+s[2],t.y=+s[3],r.bezierCurveTo(t.x1,t.y1,t.x2,t.y2,t.x,t.y)):(t.x1=+s[0],t.y1=+s[1],t.x=+s[2],t.y=+s[3],r.quadraticCurveTo(t.x1,t.y1,t.x,t.y));break;case"s":void 0!==t.x1&&void 0!==t.y1&&void 0!==t.x2&&void 0!==t.y2?(t.x1=t.x-t.x2+t.x,t.y1=t.y-t.y2+t.y,t.x2=t.x+ +s[0],t.y2=t.y+ +s[1],t.x+=+s[2],t.y+=+s[3],r.bezierCurveTo(t.x1,t.y1,t.x2,t.y2,t.x,t.y)):(t.x1=t.x+ +s[0],t.y1=t.y+ +s[1],t.x+=+s[2],t.y+=+s[3],r.quadraticCurveTo(t.x1,t.y1,t.x,t.y));break;case"Q":t.x1=+s[0],t.y1=+s[1],t.x=+s[2],t.y=+s[3],r.quadraticCurveTo(t.x1,t.y1,t.x,t.y);break;case"q":t.x1=t.x+ +s[0],t.y1=t.y+ +s[1],t.x+=+s[2],t.y+=+s[3],r.quadraticCurveTo(t.x1,t.y1,t.x,t.y);break;case"Z":case"z":r.closePath()}}drawEllipse(t,e,s,r,n,i){const{context:a}=this;a.save(),P.resetShapeStyles(a,i),this.setTransform(n);const o=2*s,l=2*r,c=.5522848,h=o/2*c,u=l/2*c,f=(t-=s)+o,d=(e-=r)+l,p=t+o/2,m=e+l/2;a.beginPath(),a.moveTo(t,m),a.bezierCurveTo(t,m-u,p-h,e,p,e),a.bezierCurveTo(p+h,e,f,m-u,f,m),a.bezierCurveTo(f,m+u,p+h,d,p,d),a.bezierCurveTo(p-h,d,t,m+u,t,m),P.fillOrStroke(a,i),a.restore()}drawRect(t,e,s,r,n,i,a){const{context:o}=this;o.save(),P.resetShapeStyles(o,a),this.setTransform(i);let l=n;s<2*l&&(l=s/2),r<2*l&&(l=r/2),o.beginPath(),o.moveTo(t+l,e),o.arcTo(t+s,e,t+s,e+r,l),o.arcTo(t+s,e+r,t,e+r,l),o.arcTo(t,e+r,t,e,l),o.arcTo(t,e,t+s,e,l),o.closePath(),P.fillOrStroke(o,a),o.restore()}drawShape(t){const{type:e,path:s,transform:r,styles:n}=t;switch(e){case"shape":this.drawBezier(s.d,r,n);break;case"ellipse":this.drawEllipse(s.x??0,s.y??0,s.radiusX??0,s.radiusY??0,r,n);break;case"rect":this.drawRect(s.x??0,s.y??0,s.width??0,s.height??0,s.cornerRadius??0,r,n)}}drawSprite(t,e,s){if(0===t.alpha)return;const{context:r}=this,{alpha:n,transform:i,layout:a,shapes:o}=t,{a:l=1,b:c=0,c:h=0,d:u=1,tx:f=0,ty:d=0}=i??{};r.save(),this.setTransform(this.globalTransform),r.globalAlpha=n,r.transform(l,c,h,u,f,d),e&&r.drawImage(e,0,0,a.width,a.height),s&&r.drawImage(s,(a.width-s.width)/2,(a.height-s.height)/2);for(let t=0;t<o.length;t++)this.drawShape(o[t]);r.restore()}resize(t,e,s){const{width:r,height:n}=s,{width:i,height:a}=e,o=`${t}-${i}-${a}-${r}-${n}`,l=this.globalTransform;if(this.lastResizeKey===o&&l)return;let c={scaleX:1,scaleY:1,translateX:0,translateY:0};"fill"===t?(c.scaleX=r/i,c.scaleY=n/a):c=P.calculateScale(t,e,s),this.lastResizeKey=o,this.globalTransform={a:c.scaleX,b:0,c:0,d:c.scaleY,tx:c.translateX,ty:c.translateY}}render(t,e,s,r,n,i){let a,o,l,c;for(let h=n;h<i;h++)a=t.sprites[h],o=a.imageKey,l=e.get(o),c=s.get(o),this.drawSprite(a.frames[r],l,c)}destroy(){this.globalTransform=void 0,this.lastResizeKey="",this.context=null}}const I=(t,e)=>()=>t.drawImage(e,0,0),S=(t,e,s,r,n)=>"CL"===t?()=>{e.clearRect(0,0,r,n)}:()=>{s.width=r,s.height=n};class D{isRunning=!1;startTime=0;duration=0;loopStart=0;pauseTime=0;loopDuration=0;onAnimate=u.noop;onStart=u.noop;onUpdate=u.noop;onEnd=u.noop;setConfig(t,e,s,r){this.duration=t,this.loopStart=e,this.loopDuration=t*s+r-e}start(){this.isRunning=!0,this.startTime=u.now(),this.pauseTime=0,this.onStart(),this.doFrame()}resume(){return 0!==this.startTime&&(this.isRunning=!0,this.doFrame(),!0)}pause(){return 0!==this.startTime&&(this.isRunning=!1,this.pauseTime=(u.now()-this.startTime)%this.duration,!0)}stop(){this.isRunning=!1,this.startTime=0}doFrame(){this.isRunning&&(this.doDeltaTime(u.now()-this.startTime),this.isRunning&&this.onAnimate((()=>this.doFrame())))}doDeltaTime(t){const{duration:e,loopStart:s,pauseTime:r,loopDuration:n}=this;let i,a=!1;t>=n?(i=1,a=!0,this.stop()):i=(t+s+r)%e/e,this.onUpdate(i),!this.isRunning&&a&&this.onEnd()}}const B=Uint8Array,F=Uint16Array,U=Int32Array,O=new B([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),N=new B([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),z=new B([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),L=(t,e)=>{const s=new F(31);for(let r=0;r<31;++r)s[r]=e+=1<<t[r-1];const r=new U(s[30]);for(let t=1;t<30;++t)for(let e=s[t];e<s[t+1];++e)r[e]=e-s[t]<<5|t;return{b:s,r:r}},{b:_,r:H}=L(O,2);_[28]=258,H[258]=28;const{b:V,r:$}=L(N,0),W=new F(32768);for(let t=0;t<32768;++t){let e=(43690&t)>>1|(21845&t)<<1;e=(52428&e)>>2|(13107&e)<<2,e=(61680&e)>>4|(3855&e)<<4,W[t]=((65280&e)>>8|(255&e)<<8)>>1}const Y=(t,e,s)=>{const r=t.length;let n=0;const i=new F(e);for(;n<r;++n)t[n]&&++i[t[n]-1];const a=new F(e);for(n=1;n<e;++n)a[n]=a[n-1]+i[n-1]<<1;let o;if(s){o=new F(1<<e);const s=15-e;for(n=0;n<r;++n)if(t[n]){const r=n<<4|t[n],i=e-t[n];let l=a[t[n]-1]++<<i;for(const t=l|(1<<i)-1;l<=t;++l)o[W[l]>>s]=r}}else for(o=new F(r),n=0;n<r;++n)t[n]&&(o[n]=W[a[t[n]-1]++]>>15-t[n]);return o},K=new B(288);for(let t=0;t<144;++t)K[t]=8;for(let t=144;t<256;++t)K[t]=9;for(let t=256;t<280;++t)K[t]=7;for(let t=280;t<288;++t)K[t]=8;const X=new B(32);for(let t=0;t<32;++t)X[t]=5;const q=Y(K,9,0),J=Y(K,9,1),j=Y(X,5,0),G=Y(X,5,1),Q=t=>{let e=t[0];for(let s=1;s<t.length;++s)t[s]>e&&(e=t[s]);return e},Z=(t,e,s)=>{const r=e/8|0;return(t[r]|t[r+1]<<8)>>(7&e)&s},tt=(t,e)=>{const s=e/8|0;return(t[s]|t[s+1]<<8|t[s+2]<<16)>>(7&e)},et=t=>(t+7)/8|0,st=(t,e,s)=>((null==s||s>t.length)&&(s=t.length),new B(t.subarray(e,s))),rt=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],nt=(t,e,s)=>{const r=new Error(e||rt[t]);if(r.code=t,Error.captureStackTrace&&Error.captureStackTrace(r,nt),!s)throw r;return r},it=(t,e,s)=>{s<<=7&e;const r=e/8|0;t[r]|=s,t[r+1]|=s>>8},at=(t,e,s)=>{s<<=7&e;const r=e/8|0;t[r]|=s,t[r+1]|=s>>8,t[r+2]|=s>>16},ot=(t,e)=>{const s=[];for(let e=0;e<t.length;++e)t[e]&&s.push({s:e,f:t[e]});const r=s.length,n=s.slice();if(!r)return{t:pt,l:0};if(1==r){const t=new B(s[0].s+1);return t[s[0].s]=1,{t:t,l:1}}s.sort(((t,e)=>t.f-e.f)),s.push({s:-1,f:25001});let i=s[0],a=s[1],o=0,l=1,c=2;for(s[0]={s:-1,f:i.f+a.f,l:i,r:a};l!=r-1;)i=s[s[o].f<s[c].f?o++:c++],a=s[o!=l&&s[o].f<s[c].f?o++:c++],s[l++]={s:-1,f:i.f+a.f,l:i,r:a};let h=n[0].s;for(let t=1;t<r;++t)n[t].s>h&&(h=n[t].s);const u=new F(h+1);let f=lt(s[l-1],u,0);if(f>e){let t=0,s=0;const i=f-e,a=1<<i;for(n.sort(((t,e)=>u[e.s]-u[t.s]||t.f-e.f));t<r;++t){const r=n[t].s;if(!(u[r]>e))break;s+=a-(1<<f-u[r]),u[r]=e}for(s>>=i;s>0;){const r=n[t].s;u[r]<e?s-=1<<e-u[r]++-1:++t}for(;t>=0&&s;--t){const r=n[t].s;u[r]==e&&(--u[r],++s)}f=e}return{t:new B(u),l:f}},lt=(t,e,s)=>-1==t.s?Math.max(lt(t.l,e,s+1),lt(t.r,e,s+1)):e[t.s]=s,ct=t=>{let e=t.length;for(;e&&!t[--e];);const s=new F(++e);let r=0,n=t[0],i=1;const a=t=>{s[r++]=t};for(let s=1;s<=e;++s)if(t[s]==n&&s!=e)++i;else{if(!n&&i>2){for(;i>138;i-=138)a(32754);i>2&&(a(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(a(n),--i;i>6;i-=6)a(8304);i>2&&(a(i-3<<5|8208),i=0)}for(;i--;)a(n);i=1,n=t[s]}return{c:s.subarray(0,r),n:e}},ht=(t,e)=>{let s=0;for(let r=0;r<e.length;++r)s+=t[r]*e[r];return s},ut=(t,e,s)=>{const r=s.length,n=et(e+2);t[n]=255&r,t[n+1]=r>>8,t[n+2]=255^t[n],t[n+3]=255^t[n+1];for(let e=0;e<r;++e)t[n+e+4]=s[e];return 8*(n+4+r)},ft=(t,e,s,r,n,i,a,o,l,c,h)=>{it(e,h++,s),++n[256];const{t:u,l:f}=ot(n,15),{t:d,l:p}=ot(i,15),{c:m,n:g}=ct(u),{c:y,n:w}=ct(d),b=new F(19);for(let t=0;t<m.length;++t)++b[31&m[t]];for(let t=0;t<y.length;++t)++b[31&y[t]];const{t:k,l:x}=ot(b,7);let T=19;for(;T>4&&!k[z[T-1]];--T);const C=c+5<<3,M=ht(n,K)+ht(i,X)+a,E=ht(n,u)+ht(i,d)+a+14+3*T+ht(b,k)+2*b[16]+3*b[17]+7*b[18];if(l>=0&&C<=M&&C<=E)return ut(e,h,t.subarray(l,l+c));let A,v,R,P;if(it(e,h,1+(E<M)),h+=2,E<M){A=Y(u,f,0),v=u,R=Y(d,p,0),P=d;const t=Y(k,x,0);it(e,h,g-257),it(e,h+5,w-1),it(e,h+10,T-4),h+=14;for(let t=0;t<T;++t)it(e,h+3*t,k[z[t]]);h+=3*T;const s=[m,y];for(let r=0;r<2;++r){const n=s[r];for(let s=0;s<n.length;++s){const r=31&n[s];it(e,h,t[r]),h+=k[r],r>15&&(it(e,h,n[s]>>5&127),h+=n[s]>>12)}}}else A=q,v=K,R=j,P=X;for(let t=0;t<o;++t){const s=r[t];if(s>255){const t=s>>18&31;at(e,h,A[t+257]),h+=v[t+257],t>7&&(it(e,h,s>>23&31),h+=O[t]);const r=31&s;at(e,h,R[r]),h+=P[r],r>3&&(at(e,h,s>>5&8191),h+=N[r])}else at(e,h,A[s]),h+=v[s]}return at(e,h,A[256]),h+v[256]},dt=new U([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),pt=new B(0),mt=()=>{let t=1,e=0;return{p(s){let r=t,n=e;const i=0|s.length;for(let t=0;t!=i;){const e=Math.min(t+2655,i);for(;t<e;++t)n+=r+=s[t];r=(65535&r)+15*(r>>16),n=(65535&n)+15*(n>>16)}t=r,e=n},d:()=>(t%=65521,e%=65521,(255&t)<<24|(65280&t)<<8|(255&e)<<8|e>>8)}},gt=(t,e,s,r,n)=>{if(!n&&(n={l:1},e.dictionary)){const s=e.dictionary.subarray(-32768),r=new B(s.length+t.length);r.set(s),r.set(t,s.length),t=r,n.w=s.length}return((t,e,s,r,n,i)=>{const a=i.z||t.length,o=new B(r+a+5*(1+Math.ceil(a/7e3))+n),l=o.subarray(r,o.length-n),c=i.l;let h=7&(i.r||0);if(e){h&&(l[0]=i.r>>3);const r=dt[e-1],n=r>>13,o=8191&r,u=(1<<s)-1,f=i.p||new F(32768),d=i.h||new F(u+1),p=Math.ceil(s/3),m=2*p,g=e=>(t[e]^t[e+1]<<p^t[e+2]<<m)&u,y=new U(25e3),w=new F(288),b=new F(32);let k=0,x=0,T=i.i||0,C=0,M=i.w||0,E=0;for(;T+2<a;++T){const e=g(T);let s=32767&T,r=d[e];if(f[s]=r,d[e]=s,M<=T){const i=a-T;if((k>7e3||C>24576)&&(i>423||!c)){h=ft(t,l,0,y,w,b,x,C,E,T-E,h),C=k=x=0,E=T;for(let t=0;t<286;++t)w[t]=0;for(let t=0;t<30;++t)b[t]=0}let u=2,d=0,p=o,m=s-r&32767;if(i>2&&e==g(T-m)){const e=Math.min(n,i)-1,a=Math.min(32767,T),o=Math.min(258,i);for(;m<=a&&--p&&s!=r;){if(t[T+u]==t[T+u-m]){let s=0;for(;s<o&&t[T+s]==t[T+s-m];++s);if(s>u){if(u=s,d=m,s>e)break;const t=Math.min(m,s-2);let n=0;for(let e=0;e<t;++e){const t=T-m+e&32767,s=t-f[t]&32767;s>n&&(n=s,r=t)}}}s=r,r=f[s],m+=s-r&32767}}if(d){y[C++]=268435456|H[u]<<18|$[d];const t=31&H[u],e=31&$[d];x+=O[t]+N[e],++w[257+t],++b[e],M=T+u,++k}else y[C++]=t[T],++w[t[T]]}}for(T=Math.max(T,M);T<a;++T)y[C++]=t[T],++w[t[T]];h=ft(t,l,c,y,w,b,x,C,E,T-E,h),c||(i.r=7&h|l[h/8|0]<<3,h-=7,i.h=d,i.p=f,i.i=T,i.w=M)}else{for(let e=i.w||0;e<a+c;e+=65535){let s=e+65535;s>=a&&(l[h/8|0]=c,s=a),h=ut(l,h+1,t.subarray(e,s))}i.i=a}return st(o,0,r+et(h)+n)})(t,null==e.level?6:e.level,null==e.mem?n.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):20:12+e.mem,s,r,n)},yt=(t,e,s)=>{for(;s;++e)t[e]=s,s>>>=8};function wt(t,e={}){const s=mt();s.p(t);const r=gt(t,e,e.dictionary?6:2,4);return((t,e)=>{const s=e.level??0,r=0==s?0:s<6?1:9==s?3:2;if(t[0]=120,t[1]=r<<6|((e.dictionary??0)&&32),t[1]|=31-(t[0]<<8|t[1])%31,e.dictionary){const s=mt();s.p(e.dictionary),yt(t,2,s.d())}})(r,e),yt(r,r.length-4,s.d()),r}function bt(t,e={}){return((t,e,s,r)=>{const n=t.length,i=r?r.length:0;if(!n||e.f&&!e.l)return s||new B(0);const a=!s,o=a||2!=e.i,l=e.i;a&&(s=new B(3*n));const c=t=>{let e=s.length;if(t>e){const r=new B(Math.max(2*e,t));r.set(s),s=r}};let h=e.f||0,u=e.p||0,f=e.b||0,d=e.l,p=e.d,m=e.m,g=e.n;const y=8*n;do{if(!d){h=Z(t,u,1);const r=Z(t,u+1,3);if(u+=3,!r){const r=et(u)+4,i=t[r-4]|t[r-3]<<8,a=r+i;if(a>n){l&&nt(0);break}o&&c(f+i),s.set(t.subarray(r,a),f),e.b=f+=i,e.p=u=8*a,e.f=h;continue}if(1==r)d=J,p=G,m=9,g=5;else if(2==r){const e=Z(t,u,31)+257,s=Z(t,u+10,15)+4,r=e+Z(t,u+5,31)+1;u+=14;const n=new B(r),i=new B(19);for(let e=0;e<s;++e)i[z[e]]=Z(t,u+3*e,7);u+=3*s;const a=Q(i),o=(1<<a)-1,l=Y(i,a,1);for(let e=0;e<r;){const s=l[Z(t,u,o)];u+=15&s;const r=s>>4;if(r<16)n[e++]=r;else{let s=0,i=0;for(16==r?(i=3+Z(t,u,3),u+=2,s=n[e-1]):17==r?(i=3+Z(t,u,7),u+=3):18==r&&(i=11+Z(t,u,127),u+=7);i--;)n[e++]=s}}const c=n.subarray(0,e),h=n.subarray(e);m=Q(c),g=Q(h),d=Y(c,m,1),p=Y(h,g,1)}else nt(1);if(u>y){l&&nt(0);break}}o&&c(f+131072);const a=(1<<m)-1,w=(1<<g)-1;let b=u;for(;;b=u){const e=d[tt(t,u)&a],n=e>>4;if(u+=15&e,u>y){l&&nt(0);break}if(e||nt(2),n<256)s[f++]=n;else{if(256==n){b=u,d=void 0;break}{let e=n-254;if(n>264){const s=n-257,r=O[s];e=Z(t,u,(1<<r)-1)+_[s],u+=r}const a=p[tt(t,u)&w],h=a>>4;a||nt(3),u+=15&a;let d=V[h];if(h>3){const e=N[h];d+=tt(t,u)&(1<<e)-1,u+=e}if(u>y){l&&nt(0);break}o&&c(f+131072);const m=f+e;if(f<d){const t=i-d,e=Math.min(d,m);for(t+f<0&&nt(3);f<e;++f)s[f]=r[t+f]}for(;f<m;++f)s[f]=s[f-d]}}}e.l=d,e.p=b,e.b=f,e.f=h,d&&(h=1,e.m=m,e.d=p,e.n=g)}while(!h);return f!=s.length&&a?st(s,0,f):s.subarray(0,f)})(t.subarray((s=t,r=e.dictionary,(8!=(15&s[0])||s[0]>>4>7||(s[0]<<8|s[1])%31)&&nt(6,"invalid zlib data"),(s[1]>>5&1)==+!r&&nt(6,"invalid zlib data: "+(32&s[1]?"need":"unexpected")+" dictionary"),2+(s[1]>>3&4)),-4),{i:2},e&&e.out,e&&e.dictionary);var s,r}class kt{static table=Uint32Array.from(Array(256),((t,e)=>{let s=e;for(let t=0;t<8;t++)s=1&s?3988292384^s>>>1:s>>>1;return s>>>0}));static WHITE_COLOR=4294967295;caches=new Map;calculate(t){if(!(t instanceof Uint8Array))throw new TypeError("Input must be a Uint8Array");const{caches:e}=this,s=u.codec.bytesToString(t);if(e.has(s))return e.get(s);let r=kt.WHITE_COLOR;for(let e=0;e<t.length;e++)r=r>>>8^kt.table[255&(r^t[e])];return e.set(s,(r^kt.WHITE_COLOR)>>>0),e.get(s)}clear(){this.caches.clear()}}class xt{width;height;view;crc32=new kt;constructor(t,e){this.width=t,this.height=e,this.view=new DataView(new ArrayBuffer(4*t*e))}createChunk(t,e){const s=new Uint8Array(4);new DataView(s.buffer).setUint32(0,e.length,!1);const r=Uint8Array.from(t,(t=>t.charCodeAt(0))),n=new Uint8Array(r.length+e.length);n.set(r),n.set(e,r.length);const i=new Uint8Array(4);new DataView(i.buffer).setUint32(0,this.crc32.calculate(n)>>>0,!1);const a=new Uint8Array(s.length+n.length+i.length);return a.set(s),a.set(n,s.length),a.set(i,s.length+n.length),a}createIHDRChunk(){const t=new Uint8Array(13),e=new DataView(t.buffer);return e.setUint32(0,this.width,!1),e.setUint32(4,this.height,!1),e.setUint8(8,8),e.setUint8(9,6),e.setUint8(10,0),e.setUint8(11,0),e.setUint8(12,0),this.createChunk("IHDR",t)}createIDATChunk(){const{width:t,height:e}=this,s=4*t,r=s+1,n=new Uint8Array(r*e),i=new Uint8Array(this.view.buffer);let a,o;for(let t=0;t<e;t++)a=t*r,n[a]=0,o=t*s,n.set(i.subarray(o,o+s),a+1);return this.createChunk("IDAT",wt(n))}setPixel(t,e,s){this.view.setUint32(4*(e*this.width+t),s,!1)}write(t){const{width:e,height:s}=this;let r,n,i,a,o,l;for(let c=0;c<s;c++)for(let s=0;s<e;s++)r=4*(c*e+s),n=t[r],i=t[r+1],a=t[r+2],o=t[r+3],l=(n<<24|i<<16|a<<8|o)>>>0,this.setPixel(s,c,l);return this}flush(){const t=this.createIHDRChunk(),e=this.createIDATChunk(),s=this.createChunk("IEND",new Uint8Array(0)),r=new Uint8Array(8+t.length+e.length+s.length);let n=0;return r.set(new Uint8Array([137,80,78,71,13,10,26,10]),n),n+=8,r.set(t,n),n+=t.length,r.set(e,n),n+=e.length,r.set(s,n),this.crc32.clear(),r}}class Tt{buffer=[];lengthInBits=0;getAt(t){const e=~~(t/8);return 1==(this.buffer[e]>>>7-t%8&1)}put(t,e){for(let s=0;s<e;s++)this.putBit(1==(t>>>e-s-1&1))}putBit(t){const{lengthInBits:e,buffer:s}=this,r=~~(e/8);s.length<=r&&s.push(0),t&&(s[r]|=128>>>e%8),this.lengthInBits+=1}}const Ct={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},Mt={L:1,M:0,Q:3,H:2},Et={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};class At{bytes;constructor(t){let e=[];for(let s=0;s<t.length;s++){const r=[],n=t.charCodeAt(s);n>65536?(r[0]=240|(1835008&n)>>>18,r[1]=128|(258048&n)>>>12,r[2]=128|(4032&n)>>>6,r[3]=128|63&n):n>2048?(r[0]=224|(61440&n)>>>12,r[1]=128|(4032&n)>>>6,r[2]=128|63&n):n>128?(r[0]=192|(1984&n)>>>6,r[1]=128|63&n):r[0]=n,e.push(r)}this.bytes=e.flat(1);const{bytes:s}=this;s.length!==t.length&&(s.unshift(191),s.unshift(187),s.unshift(239))}get mode(){return Ct.MODE_8BIT_BYTE}get length(){return this.bytes.length}write(t){const{bytes:e}=this;for(let s=0;s<e.length;s++)t.put(e[s],8)}}const vt=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]];class Rt{getRSBlockTable(t,e){const{L:s,M:r,Q:n,H:i}=Mt,a=4*(t-1);switch(e){case s:return vt[a+0];case r:return vt[a+1];case n:return vt[a+2];case i:return vt[a+3];default:throw new Error(`bad rs block @ typeNumber:${t}/errorCorrectLevel: ${e}`)}}getRSBlocks(t,e){const s=this.getRSBlockTable(t,e),r=s.length/3,n=[];for(let t=0;t<r;t++){const e=s[3*t],r=s[3*t+1],i=s[3*t+2];for(let t=0;t<e;t++)n.push({totalCount:r,dataCount:i})}return n}}const Pt=new Array(256),It=new Array(256);for(let t=0;t<8;t++)Pt[t]=1<<t;for(let t=8;t<256;t++)Pt[t]=Pt[t-4]^Pt[t-5]^Pt[t-6]^Pt[t-8];for(let t=0;t<255;t++)It[Pt[t]]=t;const St={glog(t){if(t<1)throw new Error(`glog(${t})`);return It[t]},gexp:t=>(t<0?t=255+t%255:t>255&&(t%=255),Pt[t])};class Dt{num;constructor(t,e){const{length:s}=t;if(void 0===s)throw new Error(`${s}/${e}`);let r=0;for(;r<s&&0===t[r];)r++;const n=s-r;this.num=new Array(n+e);for(let e=0;e<n;e++)this.num[e]=t[e+r]}get length(){return this.num.length}getAt(t){return this.num[t]}multiply(t){const{glog:e,gexp:s}=St,r=[];for(let n=0;n<this.length;n++)for(let i=0;i<t.length;i++)r[n+i]^=s(e(this.getAt(n))+e(t.getAt(i)));return new Dt(r,0)}mod(t){if(this.length-t.length<0)return this;const{glog:e,gexp:s}=St,r=e(this.getAt(0))-e(t.getAt(0)),n=[];for(var i=0;i<this.length;i++){const a=this.getAt(i);n[i]=i<t.length?a^s(e(t.getAt(i))+r):a}return new Dt(n,0).mod(t)}}const Bt=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],Ft=t=>0===t?0:Math.log2(t),Ut=Ft(1335),Ot=Ft(7973),Nt={getBCHTypeInfo(t){let e=t<<10;for(;Ft(e)-Ut>=0;)e^=1335<<Ft(e)-Ut;return 21522^(t<<10|e)},getBCHTypeNumber(t){let e=t<<12;for(;Ft(e)-Ot>=0;)e^=7973<<Ft(e)-Ot;return t<<12|e},getPatternPosition:t=>Bt[t-1],getMaskFunction(t){const{PATTERN000:e,PATTERN001:s,PATTERN010:r,PATTERN011:n,PATTERN100:i,PATTERN101:a,PATTERN110:o,PATTERN111:l}=Et;switch(t){case e:return(t,e)=>(t+e)%2==0;case s:return t=>t%2==0;case r:return(t,e)=>e%3==0;case n:return(t,e)=>(t+e)%3==0;case i:return(t,e)=>(~~(t/2)+~~(e/3))%2==0;case a:return(t,e)=>t*e%2+t*e%3==0;case o:return(t,e)=>(t*e%2+t*e%3)%2==0;case l:return(t,e)=>(t*e%3+(t+e)%2)%2==0;default:throw new Error(`bad maskPattern: ${t}`)}},getErrorCorrectPolynomial(t){let e=new Dt([1],0);for(let s=0;s<t;s++)e=e.multiply(new Dt([1,St.gexp(s)],0));return e},getLengthInBits(t,e){const{MODE_NUMBER:s,MODE_ALPHA_NUM:r,MODE_8BIT_BYTE:n,MODE_KANJI:i}=Ct;if(e<1||e>40)throw new Error(`type: ${e}`);if(e>=1&&e<10)switch(t){case s:return 10;case r:return 9;case n:case i:return 8}if(e<27)switch(t){case s:return 12;case r:return 11;case n:return 16;case i:return 10}if(e<=40)switch(t){case s:return 14;case r:return 13;case n:return 16;case i:return 12}throw new Error(`mode: ${t}`)},getLostPoint(t){const e=t.getModuleCount();let s=0;for(let r=0;r<e;r++)for(let n=0;n<e;n++){const i=t.isDark(r,n);let a=0;for(let s=-1;s<=1;s++){const o=r+s;if(!(o<0||e<=o))for(let r=-1;r<=1;r++){const l=n+r;l<0||e<=l||(0===s&&0===r||i===t.isDark(o,l)&&a++)}}a>5&&(s+=a+3-5)}for(let r=0;r<e-1;r++)for(let n=0;n<e-1;n++){let e=0;t.isDark(r,n)&&e++,t.isDark(r+1,n)&&e++,t.isDark(r,n+1)&&e++,t.isDark(r+1,n+1)&&e++,0!==e&&4!==e||(s+=3)}for(let r=0;r<e;r++)for(let n=0;n<e-6;n++)t.isDark(r,n)&&!t.isDark(r,n+1)&&t.isDark(r,n+2)&&t.isDark(r,n+3)&&t.isDark(r,n+4)&&!t.isDark(r,n+5)&&t.isDark(r,n+6)&&(s+=40);for(let r=0;r<e;r++)for(let n=0;n<e-6;n++)t.isDark(n,r)&&!t.isDark(n+1,r)&&t.isDark(n+2,r)&&t.isDark(n+3,r)&&t.isDark(n+4,r)&&!t.isDark(n+5,r)&&t.isDark(n+6,r)&&(s+=40);let r=0;for(let s=0;s<e;s++)for(let n=0;n<e;n++)t.isDark(n,s)&&r++;return s+10*(Math.abs(100*r/Math.pow(e,2)-50)/5)}};class zt{typeNumber;errorCorrectLevel;modules=[];moduleCount=0;dataCache=null;dataList=[];constructor(t,e){this.typeNumber=t,this.errorCorrectLevel=Mt[e]}makeImpl(t,e){this.moduleCount=4*this.typeNumber+17,this.modules=(t=>{const e=[];for(let s=0;s<t;s++){e[s]=[];for(let r=0;r<t;r++)e[s][r]=null}return e})(this.moduleCount);const s=this.moduleCount-7;this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(s,0),this.setupPositionProbePattern(0,s),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(t,e),this.typeNumber>=7&&this.setupTypeNumber(t),null===this.dataCache&&(this.dataCache=this.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,e)}setupPositionProbePattern(t,e){const{modules:s,moduleCount:r}=this;for(let n=-1;n<=7;n++){const i=t+n;if(!(i<=-1||r<=i))for(let t=-1;t<=7;t++){const a=e+t;a<=-1||r<=a||(s[i][a]=n>=0&&n<=6&&(0===t||6===t)||t>=0&&t<=6&&(0===n||6===n)||n>=2&&n<=4&&t>=2&&t<=4)}}}setupPositionAdjustPattern(){const{typeNumber:t,modules:e}=this,s=Nt.getPatternPosition(t),{length:r}=s;for(let t=0;t<r;t++)for(let n=0;n<r;n++){const r=s[t],i=s[n];if(null==e[r][i])for(let t=-2;t<=2;t++)for(let s=-2;s<=2;s++)e[r+t][i+s]=-2===t||2===t||-2===s||2===s||0===t&&0===s}}setupTimingPattern(){const{moduleCount:t,modules:e}=this,s=t-8;for(let t=8;t<s;t++)null==e[t][6]&&(e[t][6]=t%2==0);for(let t=8;t<s;t++)null==e[6][t]&&(e[6][t]=t%2==0)}setupTypeInfo(t,e){const{errorCorrectLevel:s,modules:r,moduleCount:n}=this,i=s<<3|e,a=Nt.getBCHTypeInfo(i);for(let e=0;e<15;e++){const s=!t&&1==(a>>e&1);e<6?r[e][8]=s:e<8?r[e+1][8]=s:r[n-15+e][8]=s}for(let e=0;e<15;e++){const s=!t&&1==(a>>e&1);e<8?r[8][n-e-1]=s:e<9?r[8][15-e]=s:r[8][15-e-1]=s}r[n-8][8]=!t}getBestMaskPattern(){let t=0,e=0;for(let s=0;s<8;s++){this.makeImpl(!0,s);const r=Nt.getLostPoint(this);(0===s||t>r)&&(t=r,e=s)}return e}setupTypeNumber(t){const{typeNumber:e,modules:s,moduleCount:r}=this,n=Nt.getBCHTypeNumber(e);for(let e=0;e<18;e++){const i=!t&&1==(n>>e&1);s[~~(e/3)][e%3+r-8-3]=i,s[e%3+r-8-3][~~(e/3)]=i}}createData(t,e,s){const r=(new Rt).getRSBlocks(t,e),n=new Tt;for(let e=0;e<s.length;e++){const r=s[e];n.put(r.mode,4),n.put(r.length,Nt.getLengthInBits(r.mode,t)),r.write(n)}let i=0;for(let t=0;t<r.length;t++)i+=r[t].dataCount;const a=8*i;if(n.lengthInBits>a)throw new Error(`code length overflow. (${n.lengthInBits} > ${a})`);for(n.lengthInBits+4<=a&&n.put(0,4);n.lengthInBits%8!=0;)n.putBit(!1);for(;!(n.lengthInBits>=a||(n.put(236,8),n.lengthInBits>=a));)n.put(17,8);return this.createBytes(n,r)}mapData(t,e){const{modules:s,moduleCount:r}=this,n=Nt.getMaskFunction(e);let i=-1,a=r-1,o=7,l=0;for(let e=a;e>0;e-=2)for(6===e&&(e-=1);;){for(let r=0;r<2;r++)if(null==s[a][e-r]){let i=!1;l<t.length&&(i=1==(t[l]>>>o&1)),n(a,e-r)&&(i=!i),s[a][e-r]=i,o--,-1===o&&(l++,o=7)}if(a+=i,a<0||r<=a){a-=i,i=-i;break}}}createBytes(t,e){const s=[],r=[];let n=0,i=0,a=0;for(let o=0;o<e.length;o++){const l=e[o].dataCount,c=e[o].totalCount-l;i=Math.max(i,l),a=Math.max(a,c),s[o]=[];for(let e=0;e<l;e++)s[o][e]=255&t.buffer[e+n];n+=l;const h=Nt.getErrorCorrectPolynomial(c),u=new Dt(s[o],h.length-1).mod(h);r[o]=new Array(h.length-1);for(let t=0;t<r[o].length;t++){const e=t+u.length-r[o].length;r[o][t]=e>=0?u.getAt(e):0}}let o=0;for(let t=0;t<e.length;t++)o+=e[t].totalCount;const l=new Array(o);let c=0;for(let t=0;t<i;t++)for(let r=0;r<e.length;r++)t<s[r].length&&(l[c++]=s[r][t]);for(let t=0;t<a;t++)for(let s=0;s<e.length;s++)t<r[s].length&&(l[c++]=r[s][t]);return l}isDark(t,e){const{moduleCount:s}=this;if(t<0||s<=t||e<0||s<=e)throw new Error(`${t}, ${e}`);return this.modules[t][e]}addData(t){this.dataList.push(new At(t)),this.dataCache=null}getModuleCount(){return this.moduleCount}make(){this.makeImpl(!1,this.getBestMaskPattern())}}class Lt{static cached=new Map;static decompress(t){return bt(new Uint8Array(t)).buffer}static parseVideo(t,e,s=!0){return function(t,e){if(t instanceof Uint8Array){const s=new m(t),r=v.decode(s);return r.filename=e,s.preflight.clear(),r}throw new Error("Invalid data type")}(new Uint8Array(s?this.decompress(t):t),u.path.filename(e))}static async download(t){Lt.cached.has(t)||Lt.cached.set(t,u.remote.fetch(t));const e=await Lt.cached.get(t);return Lt.cached.delete(t),e}static async load(t){return Lt.parseVideo(await Lt.download(t),t)}}const{noop:_t}=u;class Ht{mode;F=null;FC=null;B=null;BC=null;W;H;model={};renderer=null;constructor(t="dual",e=0,s=0){this.mode=t;const{dpr:r}=u.globals;this.W=e*r,this.H=s*r}setActionModel(t){const{model:e}=this,{env:s}=u.globals;e.type=t,e.clear="O"===t&&"tt"===s||"alipay"===s?"CL":"RE"}async register(t,e,s){const{model:r,mode:n}=this,{getCanvas:i,getOfsCanvas:a}=u,{env:o}=u.globals;if("single"!==n||"h5"===o&&!("OffscreenCanvas"in globalThis)){const{canvas:e,context:r}=await i(t,{type:"2d",component:s});this.F=e,this.FC=r,this.setActionModel("C"),"single"===n?(e.width=this.W,e.height=this.H):(this.W=e.width,this.H=e.height)}else{const{W:t,H:e}=this,{canvas:s,context:r}=a({type:"2d",width:t,height:e});this.F=s,this.FC=r,this.setActionModel("O")}const{FC:l,F:c,W:h,H:f}=this,d=r.clear;if(this.clearContainer=S(d,l,c,h,f),"single"===n)this.B=c,this.BC=l,this.clearSecondary=this.clearContainer,this.stick=_t;else{let t;"string"==typeof e&&""!==e?(t=await i(e,{type:"2d",component:s}),t.canvas.width=h,t.canvas.height=f,this.setActionModel("C")):(t=a({type:"2d",width:h,height:f}),this.setActionModel("O")),this.B=t.canvas,this.BC=t.context;const{BC:r,B:n}=this;this.clearSecondary=S(d,r,n,h,f),this.stick=I(l,n)}const{B:p,BC:m}=this,g=this.renderer=new P(m);this.resize=(t,e)=>g.resize(t,e,p),this.draw=(t,e,s,r,n,i)=>g.render(t,e,s,r,n,i)}clearContainer=_t;clearSecondary=_t;resize=_t;draw=_t;stick=_t;destroy(){this.clearContainer(),this.clearSecondary(),this.F=this.FC=this.B=this.BC=null,this.clearContainer=this.clearSecondary=this.stick=_t,this.renderer?.destroy()}}class Vt{fillMode="backwards";playMode="forwards";contentMode="fill";startFrame=0;endFrame=0;loopStartFrame=0;loop=0;register(t){"number"==typeof t.loop&&t.loop>=0&&(this.loop=t.loop),t.fillMode&&["forwards","backwards","none"].includes(t.fillMode)&&(this.fillMode=t.fillMode),t.playMode&&["forwards","fallbacks"].includes(t.playMode)&&(this.playMode=t.playMode),"number"==typeof t.startFrame&&(this.startFrame=t.startFrame),"number"==typeof t.endFrame&&(this.endFrame=t.endFrame),"number"==typeof t.loopStartFrame&&(this.loopStartFrame=t.loopStartFrame),"string"==typeof t.contentMode&&(this.contentMode=t.contentMode)}setItem(t,e){this.register({[t]:e})}getConfig(t){const{playMode:e,loopStartFrame:s,startFrame:r,endFrame:n,fillMode:i,loop:a}=this,{fps:o,sprites:l}=t,{frames:c}=t,h=l.length,u=Math.min(c-1,Math.max(r,0)),f=n>0?Math.min(c,n):c,d=1e3/o;if(u>=f)throw new Error("endFrame should greater than startFrame");const p=f-u,m=f-1,g=Math.floor(p*d*10**6)/10**6;let y,w,b=0;return"forwards"===e?(y=Math.min(m,Math.max(s,u)),"forwards"===i&&(b=1),w=(y-u)*d):(y=Math.min(m,m-Math.max(s,u)),"backwards"===i&&(b=1),w=(m-y)*d),{currFrame:y,startFrame:u,endFrame:f,totalFrame:p,spriteCount:h,aniConfig:{duration:g,loopStart:w,loop:0===a?1/0:a,fillValue:b*d}}}}class $t{entity;config=new Vt;resource=null;painter=new Ht;animator=new D;async setConfig(t,e){const s="string"==typeof t?{container:t}:t,{container:r,secondary:n}=s;this.config.register(s),await this.painter.register(r,n,e),this.resource=new f(this.painter),this.animator.onAnimate=u.rAF.bind(null,this.painter.F)}setItem(t,e){this.config.setItem(t,e)}async mount(t){if(!t)throw new Error("videoEntity undefined");const{images:e,filename:s}=t;this.animator.stop(),this.resource.release(),this.entity=t,await this.resource.loadImagesWithRecord(e,s)}onStart;onResume;onPause;onStop;onProcess;onEnd;start(){this.startAnimation(),this.onStart?.()}resume(){this.animator.resume()&&this.onResume?.()}pause(){this.animator.pause()&&this.onPause?.()}stop(){this.animator.stop(),this.painter.clearContainer(),this.painter.clearSecondary(),this.onStop?.()}destroy(){this.animator.stop(),this.painter.destroy(),this.resource?.release(),this.resource?.cleanup(),this.entity=void 0}stepToFrame(t,e=!1){!this.entity||t<0||t>=this.entity.frames||(this.pause(),this.config.loopStartFrame=t,e&&this.start())}stepToPercentage(t,e=!1){if(!this.entity)return;const{frames:s}=this.entity;let r=t<0?0:Math.round(t*s);r>=s&&(r=s-1),this.stepToFrame(r,e)}startAnimation(){const{entity:t,config:e,animator:s,painter:r,resource:n}=this,{materials:i,dynamicMaterials:a}=n,{fillMode:o,playMode:l,contentMode:c}=e,{currFrame:h,startFrame:f,endFrame:d,totalFrame:p,spriteCount:m,aniConfig:g}=e.getConfig(t),{duration:y,loopStart:w,loop:b,fillValue:k}=g,x="fallbacks"===l;let T,C,M,E,A,v,R=h,P=0,I=!0;s.setConfig(y,w,b,k),r.resize(c,t.size);const S=(e,s)=>r.draw(t,i,a,R,e,s);let D,B,F,U=4;s.onUpdate=t=>{I&&(r.clearSecondary(),I=!1),(t=>{for(D=u.now(),t();P<m;)if(B=Math.min(U,m-P),T=P+B|0,S(P,T),P=T,F=u.now()-D,F<3)U=Math.min(2*U,34);else if(F>8){U=Math.max(U/2,1);break}})((()=>{A=x?1-t:t,E=A*p,x?(M=(0===t?d:Math.ceil(E))-1,A=R/p):M=1===t?f:Math.floor(E),v=R===M})),v||(P<m&&S(P,m),r.clearContainer(),r.stick(),I=!0,C=R,R=M,P=0,this.onProcess?.(~~(100*A)/100,C))},s.onStart=()=>{t.locked=!0},s.onEnd=()=>{t.locked=!1,"none"===o&&r.clearContainer(),this.onEnd?.()},s.start()}}class Wt{entity;config={container:"",contentMode:"fill",frame:0};isConfigured=!1;painter;resource=null;constructor(t,e){this.painter=new Ht("single",t,e)}async register(t="",e){await this.painter.register(t,"",e),this.resource=new f(this.painter)}async setConfig(t={},e){"string"==typeof t?this.config.container=t:Object.assign(this.config,t),this.isConfigured=!0,await this.register(this.config.container,e)}setContentMode(t){this.config.contentMode=t}setFrame(t){this.config.frame=t}async mount(t){if(!t)throw new Error("videoEntity undefined");this.isConfigured||(await this.register(),this.isConfigured=!0);const{images:e,filename:s}=t;this.painter.clearContainer(),this.resource.release(),this.entity=t,await this.resource.loadImagesWithRecord(e,s)}draw(){if(!this.entity)return;const{painter:t,resource:e,entity:s,config:r}=this;t.resize(r.contentMode,s.size),t.draw(s,e.materials,e.dynamicMaterials,r.frame,0,s.sprites.length)}toImageData(){const{FC:t,W:e,H:s}=this.painter;return t.getImageData(0,0,e,s)}destroy(){this.painter.destroy(),this.resource?.release(),this.resource?.cleanup(),this.entity=void 0}}function Yt(t){const{code:e,typeNumber:s,correctLevel:r,size:n,codeColor:i,backgroundColor:a}=function(t){const e=t.typeNumber??4,s=t.correctLevel??"H",r=t.codeColor??"#000000",n=t.backgroundColor??"#FFFFFF";return{code:t.code,size:t.size,typeNumber:e,correctLevel:s,codeColor:r,backgroundColor:n}}(t);let o;try{o=new zt(s,r),o.addData(e),o.make()}catch(t){if(s>=40)throw new Error("Text too long to encode");return Yt({code:e,size:n,correctLevel:r,typeNumber:s+1,codeColor:i,backgroundColor:a})}const l=o.getModuleCount(),{padding:c,cellSize:h}=((t,e)=>{const s=~~(e/t);return{padding:~~((e-t*s)/2),cellSize:s||2}})(l,n),u=l*h+c,f=+`${i.replace("#","0x")}FF`,d=+`${a.replace("#","0x")}FF`,p=new xt(n,n);for(let t=0;t<n;t++)for(let e=0;e<n;e++)if(c<=e&&e<u&&c<=t&&t<u){const s=~~((e-c)/h),r=~~((t-c)/h);p.setPixel(e,t,o.isDark(r,s)?f:d)}else p.setPixel(e,t,d);return p.flush()}function Kt(t){return Yt(t)}function Xt(t){const e=Kt(t);return u.codec.toDataURL(e)}function qt(t){const{width:e,height:s,data:r}=t;return new xt(e,s).write(r).flush()}function Jt(t){return u.codec.toDataURL(qt(t))}function jt(t){if(t.length<6)return!1;const e=t[0],s=t[1];if(8!=(15&e))return!1;if((256*e+s)%31!=0)return!1;if(!!(32&s))return!1;const r=t.slice(-4);if(4!==r.length)return!1;const n=r[0]<<24|r[1]<<16|r[2]<<8|r[3];return!(t.length>2&&0===n)}class Gt{point=0;maxRemain=3;remainStart=0;remainEnd=0;loadMode="fast";buckets=[];options={preprocess:t=>Lt.download(t.origin),postprocess:(t,e)=>Lt.parseVideo(e,t.origin,!0),cleanup:t=>{const{local:e,path:s}=u;t.forEach((t=>{s.is(t.local)&&e.remove(t.local)}))}};get size(){return this.buckets.length}constructor(t,e){"string"==typeof t&&(this.loadMode=t),Object.assign(this.options,e)}updateRemainRange(t,e,s){this.point=t<0?0:t>=s?s-1:t,"whole"===this.loadMode?(this.remainStart=0,this.remainEnd=s):(this.maxRemain=e<1?1:e>s?s:e,this.remainStart=this.point-Math.floor(this.maxRemain/2),this.remainStart<0&&(this.remainStart=s+this.remainStart),this.remainEnd=this.remainStart+this.maxRemain,this.remainEnd>s&&(this.remainEnd=this.remainEnd%s))}includeRemainRange(t){return this.remainStart<this.remainEnd?t>=this.remainStart&&t<this.remainEnd:!(this.remainStart>this.remainEnd)||(t>=this.remainStart||t<this.remainEnd)}async downloadAndParseVideo(t,e=!1){const{options:s}=this,r=await s.preprocess(t);return e?s.postprocess(t,r):r}async createBucket(t,e,s){const{path:r}=u,n={origin:t,local:r.resolve(r.filename(t)),entity:null,promise:null};return this.buckets[e]=n,s?n.entity=await this.downloadAndParseVideo(n,!0):this.includeRemainRange(e)&&(n.promise=this.downloadAndParseVideo(n)),n}async prepare(t,e=0,s=3){this.updateRemainRange(e,s,t.length);const{loadMode:r,point:n}=this,i="whole"===r,a=await this.createBucket(t[n],n,i);await Promise.all(t.map(((t,e)=>e===n?a:this.createBucket(t,e,i))))}async get(){const t=this.buckets[this.point];return t.entity||(t.promise||(t.promise=this.downloadAndParseVideo(t)),t.entity=await t.promise.then((e=>this.options.postprocess(t,e))),t.promise=null),t}getPoint(){return this.point}async go(t){const{size:e,buckets:s,loadMode:r}=this;return t<0||t>=e?s[this.point]:(this.updateRemainRange(t,this.maxRemain,s.length),"fast"===r&&this.maxRemain!==s.length&&s.forEach(((t,e)=>{this.includeRemainRange(e)?null===t.entity&&null===t.promise&&(t.promise=this.downloadAndParseVideo(t)):(t.entity=null,t.promise=null)})),this.get())}async clear(t=!0){const{buckets:e}=this;this.point=0,this.remainStart=0,this.remainEnd=0,this.maxRemain=3,this.buckets=[],t&&await this.options.cleanup(e)}}class Qt{painter;resource;entity;constructor(t,e,s){this.painter=t,this.resource=e,this.entity=s}async set(t,e,s="R"){const{entity:r,resource:n}=this;"A"===s?await n.loadImagesWithRecord({[t]:e},r.filename,"dynamic"):r.images[t]=e}getContext(){return this.painter.BC}hasValidKey(t){const{images:e}=this.entit