UNPKG

octopus-svga

Version:

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

1 lines 51.5 kB
import{OctopusPlatform as t,pluginSelector as e,pluginCanvas as s,pluginOfsCanvas as r,pluginDecode as n,pluginDownload as i,pluginFsm as a,pluginImage as o,pluginNow as l,pluginPath as c,pluginRAF as h,installPlugin as u}from"octopus-platform";class f extends t{now;path;remote;local;decode;image;rAF;getSelector;getCanvas;getOfsCanvas;constructor(){super([e,s,r,n,i,a,o,l,c,h],"1.2.2"),this.init()}installPlugin(t){u(this,t)}}const d=new f;class p{painter;static isBitmap(t){return"h5"===d.globals.env&&t instanceof ImageBitmap}static releaseOne(t){p.isBitmap(t)?t.close():""!==t.src&&("weapp"===d.globals.env&&t.src.includes(d.path.USER_DATA_PATH)&&d.local.remove(t.src),d.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=d.image.create(this.painter.F)),this.caches.push(t),t}inertBitmapIntoCaches(t){p.isBitmap(t)&&this.caches.push(t)}loadExtImage(t,e){return d.image.load((()=>this.createImage()),t,d.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=d.image.load((()=>this.createImage()),e,d.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)p.releaseOne(t);this.materials.clear(),this.dynamicMaterials.clear(),"alipay"===d.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 m=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 g{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 y{static EMPTY_UINT8ARRAY=new Uint8Array(0);buf;len;pos;preflight=new g;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=m(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?y.EMPTY_UINT8ARRAY:this.buf.subarray(t,e)}string(){const[t,e]=this.getBytesRange(),s=d.decode.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 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;)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,w.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 b{static decode(t,e){const s=t.end(e),r=new b;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 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;)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 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.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 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.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 C{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 C;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,C.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 A{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 A;let a;for(;t.pos<r;)switch(a=t.uint32(),a>>>3){case 1:i.fill=C.decode(t,t.uint32());break;case 2:i.stroke=C.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,A.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 v{static decode(t,e){const s=t.end(e),r=new v;let n;for(;t.pos<s;)switch(n=t.uint32(),n>>>3){case 1:r.type=t.int32();break;case 2:r.shape=k.decode(t,t.uint32());break;case 3:r.rect=x.decode(t,t.uint32());break;case 4:r.ellipse=T.decode(t,t.uint32());break;case 10:r.styles=A.decode(t,t.uint32());break;case 11:r.transform=b.decode(t,t.uint32());break;default:t.skipType(7&n)}return v.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 E{static HIDDEN_FRAME={alpha:0};static decode(t,e){const s=t.end(e),r=new E;let n;for(;t.pos<s;)switch(n=t.uint32(),n>>>3){case 1:r.alpha=t.float();break;case 2:r.layout=w.decode(t,t.uint32());break;case 3:r.transform=b.decode(t,t.uint32());break;case 4:r.clipPath=t.string();break;case 5:{const e=v.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),E.format(r)}static format(t){if(t.alpha<.05)return E.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 M{static decode(t,e){const s=t.end(e),r=new M;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(E.decode(t,t.uint32()));break;case 3:r.matteKey=t.string();break;default:t.skipType(7&n)}return M.format(r)}static format(t){return{imageKey:t.imageKey,frames:t.frames}}frames=[];imageKey="";matteKey=""}class R{static decode(t,e){const s=t.end(e),r=new R;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 P{static EMPTY_U8=new Uint8Array(0);static decode(t,e){const s=t.end(e),r=new P;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=R.decode(t,t.uint32());break;case 3:for(a=t.uint32()+t.pos,n="",i=P.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(M.decode(t,t.uint32()));break;default:t.skipType(7&o)}return P.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 S{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 I{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}=I,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 S;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(),I.resetShapeStyles(r,s),this.setTransform(e),r.beginPath(),t){const e=I.parseSVGPath(t);for(const{command:t,args:s}of e)I.SVG_PATH.has(t)&&this.drawBezierElement(this.currentPoint,t,s.split(/[\s,]+/).filter(Boolean))}I.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(),I.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),I.fillOrStroke(a,i),a.restore()}drawRect(t,e,s,r,n,i,a){const{context:o}=this;o.save(),I.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(),I.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=I.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 D=(t,e)=>()=>t.drawImage(e,0,0),B=(t,e,s,r,n)=>"CL"===t?()=>{e.clearRect(0,0,r,n)}:()=>{s.width=r,s.height=n};class F{isRunning=!1;startTime=0;duration=0;loopStart=0;pauseTime=0;loopDuration=0;onAnimate=d.noop;onStart=d.noop;onUpdate=d.noop;onEnd=d.noop;setConfig(t,e,s,r){this.duration=t,this.loopStart=e,this.loopDuration=t*s+r-e}start(){this.isRunning=!0,this.startTime=d.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=(d.now()-this.startTime)%this.duration,!0)}stop(){this.isRunning=!1,this.startTime=0}doFrame(){this.isRunning&&(this.doDeltaTime(d.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 U=Uint8Array,O=Uint16Array,N=Int32Array,z=new U([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]),L=new U([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]),H=new U([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),_=(t,e)=>{const s=new O(31);for(let r=0;r<31;++r)s[r]=e+=1<<t[r-1];const r=new N(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:W,r:V}=_(z,2);W[28]=258,V[258]=28;const{b:$,r:Y}=_(L,0),K=new O(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,K[t]=((65280&e)>>8|(255&e)<<8)>>1}const X=(t,e,s)=>{const r=t.length;let n=0;const i=new O(e);for(;n<r;++n)t[n]&&++i[t[n]-1];const a=new O(e);for(n=1;n<e;++n)a[n]=a[n-1]+i[n-1]<<1;let o;if(s){o=new O(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[K[l]>>s]=r}}else for(o=new O(r),n=0;n<r;++n)t[n]&&(o[n]=K[a[t[n]-1]++]>>15-t[n]);return o},q=new U(288);for(let t=0;t<144;++t)q[t]=8;for(let t=144;t<256;++t)q[t]=9;for(let t=256;t<280;++t)q[t]=7;for(let t=280;t<288;++t)q[t]=8;const J=new U(32);for(let t=0;t<32;++t)J[t]=5;const j=X(q,9,0),G=X(q,9,1),Q=X(J,5,0),Z=X(J,5,1),tt=t=>{let e=t[0];for(let s=1;s<t.length;++s)t[s]>e&&(e=t[s]);return e},et=(t,e,s)=>{const r=e/8|0;return(t[r]|t[r+1]<<8)>>(7&e)&s},st=(t,e)=>{const s=e/8|0;return(t[s]|t[s+1]<<8|t[s+2]<<16)>>(7&e)},rt=t=>(t+7)/8|0,nt=(t,e,s)=>((null==s||s>t.length)&&(s=t.length),new U(t.subarray(e,s))),it=["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"],at=(t,e,s)=>{const r=new Error(e||it[t]);if(r.code=t,Error.captureStackTrace&&Error.captureStackTrace(r,at),!s)throw r;return r},ot=(t,e,s)=>{s<<=7&e;const r=e/8|0;t[r]|=s,t[r+1]|=s>>8},lt=(t,e,s)=>{s<<=7&e;const r=e/8|0;t[r]|=s,t[r+1]|=s>>8,t[r+2]|=s>>16},ct=(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:gt,l:0};if(1==r){const t=new U(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 O(h+1);let f=ht(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 U(u),l:f}},ht=(t,e,s)=>-1==t.s?Math.max(ht(t.l,e,s+1),ht(t.r,e,s+1)):e[t.s]=s,ut=t=>{let e=t.length;for(;e&&!t[--e];);const s=new O(++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}},ft=(t,e)=>{let s=0;for(let r=0;r<e.length;++r)s+=t[r]*e[r];return s},dt=(t,e,s)=>{const r=s.length,n=rt(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)},pt=(t,e,s,r,n,i,a,o,l,c,h)=>{ot(e,h++,s),++n[256];const{t:u,l:f}=ct(n,15),{t:d,l:p}=ct(i,15),{c:m,n:g}=ut(u),{c:y,n:w}=ut(d),b=new O(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}=ct(b,7);let T=19;for(;T>4&&!k[H[T-1]];--T);const C=c+5<<3,A=ft(n,q)+ft(i,J)+a,v=ft(n,u)+ft(i,d)+a+14+3*T+ft(b,k)+2*b[16]+3*b[17]+7*b[18];if(l>=0&&C<=A&&C<=v)return dt(e,h,t.subarray(l,l+c));let E,M,R,P;if(ot(e,h,1+(v<A)),h+=2,v<A){E=X(u,f,0),M=u,R=X(d,p,0),P=d;const t=X(k,x,0);ot(e,h,g-257),ot(e,h+5,w-1),ot(e,h+10,T-4),h+=14;for(let t=0;t<T;++t)ot(e,h+3*t,k[H[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];ot(e,h,t[r]),h+=k[r],r>15&&(ot(e,h,n[s]>>5&127),h+=n[s]>>12)}}}else E=j,M=q,R=Q,P=J;for(let t=0;t<o;++t){const s=r[t];if(s>255){const t=s>>18&31;lt(e,h,E[t+257]),h+=M[t+257],t>7&&(ot(e,h,s>>23&31),h+=z[t]);const r=31&s;lt(e,h,R[r]),h+=P[r],r>3&&(lt(e,h,s>>5&8191),h+=L[r])}else lt(e,h,E[s]),h+=M[s]}return lt(e,h,E[256]),h+M[256]},mt=new N([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),gt=new U(0),yt=()=>{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)}},wt=(t,e,s,r,n)=>{if(!n&&(n={l:1},e.dictionary)){const s=e.dictionary.subarray(-32768),r=new U(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 U(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=mt[e-1],n=r>>13,o=8191&r,u=(1<<s)-1,f=i.p||new O(32768),d=i.h||new O(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 N(25e3),w=new O(288),b=new O(32);let k=0,x=0,T=i.i||0,C=0,A=i.w||0,v=0;for(;T+2<a;++T){const e=g(T);let s=32767&T,r=d[e];if(f[s]=r,d[e]=s,A<=T){const i=a-T;if((k>7e3||C>24576)&&(i>423||!c)){h=pt(t,l,0,y,w,b,x,C,v,T-v,h),C=k=x=0,v=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|V[u]<<18|Y[d];const t=31&V[u],e=31&Y[d];x+=z[t]+L[e],++w[257+t],++b[e],A=T+u,++k}else y[C++]=t[T],++w[t[T]]}}for(T=Math.max(T,A);T<a;++T)y[C++]=t[T],++w[t[T]];h=pt(t,l,c,y,w,b,x,C,v,T-v,h),c||(i.r=7&h|l[h/8|0]<<3,h-=7,i.h=d,i.p=f,i.i=T,i.w=A)}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=dt(l,h+1,t.subarray(e,s))}i.i=a}return nt(o,0,r+rt(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)},bt=(t,e,s)=>{for(;s;++e)t[e]=s,s>>>=8};function kt(t,e={}){const s=yt();s.p(t);const r=wt(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=yt();s.p(e.dictionary),bt(t,2,s.d())}})(r,e),bt(r,r.length-4,s.d()),r}function xt(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 U(0);const a=!s,o=a||2!=e.i,l=e.i;a&&(s=new U(3*n));const c=t=>{let e=s.length;if(t>e){const r=new U(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=et(t,u,1);const r=et(t,u+1,3);if(u+=3,!r){const r=rt(u)+4,i=t[r-4]|t[r-3]<<8,a=r+i;if(a>n){l&&at(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=G,p=Z,m=9,g=5;else if(2==r){const e=et(t,u,31)+257,s=et(t,u+10,15)+4,r=e+et(t,u+5,31)+1;u+=14;const n=new U(r),i=new U(19);for(let e=0;e<s;++e)i[H[e]]=et(t,u+3*e,7);u+=3*s;const a=tt(i),o=(1<<a)-1,l=X(i,a,1);for(let e=0;e<r;){const s=l[et(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+et(t,u,3),u+=2,s=n[e-1]):17==r?(i=3+et(t,u,7),u+=3):18==r&&(i=11+et(t,u,127),u+=7);i--;)n[e++]=s}}const c=n.subarray(0,e),h=n.subarray(e);m=tt(c),g=tt(h),d=X(c,m,1),p=X(h,g,1)}else at(1);if(u>y){l&&at(0);break}}o&&c(f+131072);const a=(1<<m)-1,w=(1<<g)-1;let b=u;for(;;b=u){const e=d[st(t,u)&a],n=e>>4;if(u+=15&e,u>y){l&&at(0);break}if(e||at(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=z[s];e=et(t,u,(1<<r)-1)+W[s],u+=r}const a=p[st(t,u)&w],h=a>>4;a||at(3),u+=15&a;let d=$[h];if(h>3){const e=L[h];d+=st(t,u)&(1<<e)-1,u+=e}if(u>y){l&&at(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&&at(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?nt(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)&&at(6,"invalid zlib data"),(s[1]>>5&1)==+!r&&at(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 Tt{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=d.decode.bytesToString(t);if(e.has(s))return e.get(s);let r=Tt.WHITE_COLOR;for(let e=0;e<t.length;e++)r=r>>>8^Tt.table[255&(r^t[e])];return e.set(s,(r^Tt.WHITE_COLOR)>>>0),e.get(s)}clear(){this.caches.clear()}}class Ct{width;height;view;crc32=new Tt;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",kt(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 At{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 vt={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},Et={L:1,M:0,Q:3,H:2},Mt={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};class Rt{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 vt.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 Pt=[[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 St{getRSBlockTable(t,e){const{L:s,M:r,Q:n,H:i}=Et,a=4*(t-1);switch(e){case s:return Pt[a+0];case r:return Pt[a+1];case n:return Pt[a+2];case i:return Pt[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 It=new Array(256),Dt=new Array(256);for(let t=0;t<8;t++)It[t]=1<<t;for(let t=8;t<256;t++)It[t]=It[t-4]^It[t-5]^It[t-6]^It[t-8];for(let t=0;t<255;t++)Dt[It[t]]=t;const Bt={glog(t){if(t<1)throw new Error(`glog(${t})`);return Dt[t]},gexp:t=>(t<0?t=255+t%255:t>255&&(t%=255),It[t])};class Ft{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}=Bt,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 Ft(r,0)}mod(t){if(this.length-t.length<0)return this;const{glog:e,gexp:s}=Bt,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 Ft(n,0).mod(t)}}const Ut=[[],[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]],Ot=t=>0===t?0:Math.log2(t),Nt=Ot(1335),zt=Ot(7973),Lt={getBCHTypeInfo(t){let e=t<<10;for(;Ot(e)-Nt>=0;)e^=1335<<Ot(e)-Nt;return 21522^(t<<10|e)},getBCHTypeNumber(t){let e=t<<12;for(;Ot(e)-zt>=0;)e^=7973<<Ot(e)-zt;return t<<12|e},getPatternPosition:t=>Ut[t-1],getMaskFunction(t){const{PATTERN000:e,PATTERN001:s,PATTERN010:r,PATTERN011:n,PATTERN100:i,PATTERN101:a,PATTERN110:o,PATTERN111:l}=Mt;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 Ft([1],0);for(let s=0;s<t;s++)e=e.multiply(new Ft([1,Bt.gexp(s)],0));return e},getLengthInBits(t,e){const{MODE_NUMBER:s,MODE_ALPHA_NUM:r,MODE_8BIT_BYTE:n,MODE_KANJI:i}=vt;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 Ht{typeNumber;errorCorrectLevel;modules=[];moduleCount=0;dataCache=null;dataList=[];constructor(t,e){this.typeNumber=t,this.errorCorrectLevel=Et[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=Lt.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=Lt.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=Lt.getLostPoint(this);(0===s||t>r)&&(t=r,e=s)}return e}setupTypeNumber(t){const{typeNumber:e,modules:s,moduleCount:r}=this,n=Lt.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 St).getRSBlocks(t,e),n=new At;for(let e=0;e<s.length;e++){const r=s[e];n.put(r.mode,4),n.put(r.length,Lt.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=Lt.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=Lt.getErrorCorrectPolynomial(c),u=new Ft(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 Rt(t)),this.dataCache=null}getModuleCount(){return this.moduleCount}make(){this.makeImpl(!1,this.getBestMaskPattern())}}class _t{static decompress(t){return xt(new Uint8Array(t)).buffer}static parseVideo(t,e,s=!0){return function(t,e){if(t instanceof Uint8Array){const s=new y(t),r=P.decode(s);return r.filename=e,s.preflight.clear(),r}throw new Error("Invalid data type")}(new Uint8Array(s?this.decompress(t):t),d.path.filename(e))}static async download(t){const{globals:e,remote:s,path:r,local:n}=d,{env:i}=e,a="h5"!==i&&"tt"!==i,o=r.is(t)?t:r.resolve(r.filename(t));if(a&&await n.exists(o))return n.read(o);const l=await s.fetch(t);if(a)try{await n.write(l,o)}catch(t){console.error(t)}return l}static async load(t){return _t.parseVideo(await _t.download(t),t)}}const{noop:Wt}=d;class Vt{mode;F=null;FC=null;B=null;BC=null;W;H;model={};renderer=null;constructor(t="animation",e=0,s=0){this.mode=t;const{dpr:r}=d.globals;this.W=e*r,this.H=s*r}setActionModel(t){const{model:e}=this,{env:s}=d.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}=d,{env:o}=d.globals;if("poster"!==n||"h5"===o&&!("OffscreenCanvas"in globalThis)){const{canvas:e,context:r}=await i(t,s),{width:a,height:o}=e;this.F=e,this.FC=r,this.setActionModel("C"),"poster"===n?(e.width=this.W,e.height=this.H):(this.W=a,this.H=o)}else{const{W:t,H:e}=this,{canvas:s,context:r}=a({width:t,height:e});this.F=s,this.FC=r,this.setActionModel("O")}if(this.clearContainer=B(r.clear,this.FC,this.F,this.W,this.H),"poster"===n)this.B=this.F,this.BC=this.FC,this.clearSecondary=this.clearContainer,this.stick=Wt;else{const{W:t,H:n}=this;let o;"string"==typeof e&&""!==e?(o=await i(e,s),o.canvas.width=t,o.canvas.height=n,this.setActionModel("C")):(o=a({width:t,height:n}),this.setActionModel("O")),this.B=o.canvas,this.BC=o.context,this.clearSecondary=B(r.clear,this.BC,this.B,this.W,this.H),this.stick=D(this.FC,this.B)}const{B:l,BC:c}=this,h=this.renderer=new I(c);this.resize=(t,e)=>h.resize(t,e,l),this.draw=(t,e,s,r,n,i)=>h.render(t,e,s,r,n,i)}clearContainer=Wt;clearSecondary=Wt;resize=Wt;draw=Wt;stick=Wt;destroy(){this.clearContainer(),this.clearSecondary(),this.F=this.FC=this.B=this.BC=null,this.clearContainer=this.clearSecondary=this.stick=Wt,this.renderer?.destroy()}}class $t{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&&t.startFrame>=0&&(this.startFrame=t.startFrame),"number"==typeof t.endFrame&&t.endFrame>=0&&(this.endFrame=t.endFrame),"number"==typeof t.loopStartFrame&&t.loopStartFrame>=0&&(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;let{frames:c}=t;const h=l.length,u=r>0?r:0,f=n>0&&n<c?n:c,d=1e3/o;if(u>f)throw new Error("StartFrame should greater than EndFrame");f<c?c=f-u:u>0&&(c-=u);const p=Math.floor(c*d*10**6)/10**6;let m,g=0,y=0;return"forwards"===e?(g=Math.max(s,r),"forwards"===i&&(y=1),m=s>u?(s-u)*d:0):(g=Math.min(s,f-1),"backwards"===i&&(y=1),m=s<f?(f-s)*d:0),{currFrame:g,startFrame:u,endFrame:f,totalFrame:c,spriteCount:h,aniConfig:{duration:p,loopStart:m,loop:0===a?1/0:a,fillValue:y*d}}}}class Yt{entity;config=new $t;resource=null;painter=new Vt;animator=new F;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 p(this.painter),this.animator.onAnimate=d.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.painter.clearSecondary(),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,{W:i,H:a}=r,{materials:o,dynamicMaterials:l}=n,{fillMode:c,playMode:h,contentMode:u}=e,{currFrame:f,startFrame:p,endFrame:m,totalFrame:g,spriteCount:y,aniConfig:w}=e.getConfig(t),{duration:b,loopStart:k,loop:x,fillValue:T}=w,C="fallbacks"===h;let A,v,E,M,R,P,S=f,I=0;s.setConfig(b,k,x,T),r.resize(u,t.size);const D=(e,s)=>r.draw(t,o,l,S,e,s);let B,F,U,O=4;s.onUpdate=t=>{(t=>{for(B=d.now(),t();I<y;)if(F=Math.min(O,y-I),A=I+F|0,D(I,A),I=A,U=d.now()-B,U<3)O=Math.min(2*O,34);else if(U>8){O=Math.max(O/2,1);break}})((()=>{R=C?1-t:t,M=R*g,C?(E=(0===t?m:Math.ceil(M))-1,R=S/g):E=1===t?p:Math.floor(M),P=S===E})),P||(I<y&&D(I,y),r.clearContainer(),r.stick(),r.clearSecondary(),v=S,S=E,I=0,this.onProcess?.(~~(100*R)/100,v))},s.onStart=()=>{t.locked=!0},s.onEnd=()=>{t.locked=!1,"none"===c&&r.clearContainer(),this.onEnd?.()},s.start()}}class Kt{entity;config={container:"",contentMode:"fill",frame:0};isConfigured=!1;painter;resource=null;constructor(t,e){this.painter=new Vt("poster",t,e)}async register(t="",e){await this.painter.register(t,"",e),this.resource=new p(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 Xt(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 Ht(s,r),o.addData(e),o.make()}catch(t){if(s>=40)throw new Error("Text too long to encode");return arguments.callee({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 Ct(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 qt(t){const e=Xt(t);return d.decode.toDataURL(e)}function Jt(t){const{width:e,height:s,data:r}=t;return new Ct(e,s).write(r).flush()}const jt=Jt;function Gt(t){const e=Jt(t);return d.decode.toDataURL(e)}const Qt=Gt;function Zt(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 te{point=0;maxRemain=3;remainStart=0;remainEnd=0;loadMode="fast";buckets=[];options={preprocess:t=>_t.download(t.origin),postprocess:(t,e)=>_t.parseVideo(e,t.origin,!0),cleanup:t=>{const{globals:e,local:s,path:r}=d;t.forEach((t=>{r.is(t.local)&&s.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}=d,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=await this.createBucket(t[n],n,!0);await Promise.all(t.map(((t,e)=>e===n?i:this.createBucket(t,e,"whole"===r))))}async get(){const t=this.buckets[this.point];return t.promise?(t.entity=await t.promise.then((e=>this.options.postprocess(t,e))),t.promise=null):t.entity||(t.entity=await this.downloadAndParseVideo(t,!0)),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;t