import { t as e } from "./basedecoder-BFm2CpEb.js";
//#region ../../node_modules/geotiff/dist-module/compression/webimage.js
var t = class extends e {
	constructor(e) {
		if (super(e), typeof createImageBitmap > "u") throw Error("Cannot decode WebImage as `createImageBitmap` is not available");
		if (typeof document > "u" && typeof OffscreenCanvas > "u") throw Error("Cannot decode WebImage as neither `document` nor `OffscreenCanvas` is not available");
	}
	async decodeBlock(e) {
		let t = new Blob([e]), n = await createImageBitmap(t), r;
		typeof document < "u" ? (r = document.createElement("canvas"), r.width = n.width, r.height = n.height) : r = new OffscreenCanvas(n.width, n.height);
		let i = r.getContext("2d");
		i.drawImage(n, 0, 0);
		let a = i.getImageData(0, 0, n.width, n.height).data, o = this.parameters.samplesPerPixel || 4;
		if (o === 4) return a.buffer;
		if (o === 3) {
			let e = new Uint8ClampedArray(n.width * n.height * 3);
			for (let t = 0, n = 0; t < e.length; t += 3, n += 4) e[t] = a[n], e[t + 1] = a[n + 1], e[t + 2] = a[n + 2];
			return e.buffer;
		} else throw Error(`Unsupported SamplesPerPixel value: ${o}`);
	}
};
//#endregion
export { t as default };
