var o=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var l=(n,t)=>{for(var e in t)o(n,e,{get:t[e],enumerable:!0})},c=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of m(t))!g.call(n,i)&&i!==e&&o(n,i,{get:()=>t[i],enumerable:!(r=p(t,i))||r.enumerable});return n};var x=n=>c(o({},"__esModule",{value:!0}),n);var b={};l(b,{ByteArray:()=>a,Decoder:()=>y,Encoder:()=>d});module.exports=x(b);var h=class n extends Uint8Array{static ensureByteArray(t){return t instanceof n?t:new n(t)}cmp(t,e){return e||(e=t,t=this),t.filter((r,i)=>r===e[i]).length===t.length}toInt(t=this.slice(this.off,4)){return t[0]&255|t[1]<<8&65535|t[2]<<16&16777215|t[3]<<24&4294967295}toBytes(t){return new n([t&255,t>>8&255,t>>16&255,t>>24&255])}nextInt(){return this.toInt(this.slice(this.off,this.off+=4))}nextIntBytes(){return n.ensureByteArray(this.slice(this.off,this.off+=4))}insertInt(t){this.insertBytes(this.toBytes(t))}insertBytes(t,e=t.length??4){this.set(t,this.off),this.off+=e}off=0},a=h;var f=new a([88,99,117,114]),s=new a([2,0,253,255]),w=new a([1,0,253,255]),U=typeof process<"u"&&process?.env?.NODE_ENV==="development"?console.log:()=>{};var I=class{data;constructor(t){if(this.data=a.ensureByteArray(t),!this.isCursor())throw new Error("No Xcur header found")}isCursor(){return f.cmp(this.data.nextIntBytes())}images(){return this.data.off=12,this.data.nextInt()}imageInfo(t){if(this.data.off=t*12+16,!!s.cmp(this.data.nextIntBytes())&&(this.data.nextInt(),this.data.off=this.data.nextInt(),!(this.data.nextInt()!==36||!s.cmp(this.data.nextIntBytes()))))return{type:this.data.nextInt(),subtype:this.data.nextInt(),width:this.data.nextInt(),height:this.data.nextInt(),xhot:this.data.nextInt(),yhot:this.data.nextInt(),delay:this.data.nextInt(),start:this.data.off}}getDataByNum(t){let e=this.imageInfo(t);if(!e)throw new Error("failed to get data");return this.getData(e)}getData(t){return this.data.slice(t.start,t.start+t.width*t.height*4)}imageTypes(){let t=[];for(let e=0;ee+48+r.width*r.height*4,16)}_imagePos(t,e){return 12*t.length+16+t.filter((r,i)=>ir+36+i.width*i.height*4,0)}pack(t){this.images=t||this.images;let e=new a(this._imagesSize(this.images));e.insertBytes(f),e.insertInt(16),e.insertInt(1),e.insertInt(this.images.length);for(let r=0;r