//#region ../../node_modules/geotiff/dist-module/predictor.js
function e(e, t) {
	let n = e.length - t, r = 0;
	do {
		for (let n = t; n > 0; n--) e[r + t] += e[r], r++;
		n -= t;
	} while (n > 0);
}
function t(e, t, n) {
	let r = 0, i = e.length, a = i / n;
	for (; i > t;) {
		for (let n = t; n > 0; --n) e[r + t] += e[r], ++r;
		i -= t;
	}
	let o = e.slice();
	for (let t = 0; t < a; ++t) for (let r = 0; r < n; ++r) e[n * t + r] = o[(n - r - 1) * a + t];
}
function n(n, r, i, a, o, s) {
	if (!r || r === 1) return n;
	for (let e = 0; e < o.length; ++e) {
		if (o[e] % 8 != 0) throw Error("When decoding with predictor, only multiple of 8 bits are supported.");
		if (o[e] !== o[0]) throw Error("When decoding with predictor, all samples must have the same size.");
	}
	let c = o[0] / 8, l = s === 2 ? 1 : o.length;
	for (let s = 0; s < a && !(s * l * i * c >= n.byteLength); ++s) {
		let a;
		if (r === 2) {
			switch (o[0]) {
				case 8:
					a = new Uint8Array(n, s * l * i * c, l * i * c);
					break;
				case 16:
					a = new Uint16Array(n, s * l * i * c, l * i * c / 2);
					break;
				case 32:
					a = new Uint32Array(n, s * l * i * c, l * i * c / 4);
					break;
				default: throw Error(`Predictor 2 not allowed with ${o[0]} bits per sample.`);
			}
			e(a, l);
		} else r === 3 && (a = new Uint8Array(n, s * l * i * c, l * i * c), t(a, l, c));
	}
	return n;
}
//#endregion
//#region ../../node_modules/geotiff/dist-module/compression/basedecoder.js
var r = class {
	constructor(e) {
		this.parameters = e;
	}
	decodeBlock(e) {
		throw Error("decodeBlock not implemented");
	}
	async decode(e) {
		let t = await this.decodeBlock(e), { tileWidth: r, tileHeight: i, predictor: a, bitsPerSample: o, planarConfiguration: s } = this.parameters;
		return a === 1 ? t : n(t, a, r, i, Array.isArray(o) || ArrayBuffer.isView(o) ? Array.from(o) : [o], s);
	}
};
//#endregion
export { r as t };
