/*!
 * GeoMoose Licensing
 * ==================
 *
 * The MIT License (MIT)
 * ---------------------
 *
 * Copyright (c) 2016-2026 Dan "Ducky" Little & GeoMoose.org
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *
 *
 */
"use strict";
/*
 * ATTENTION: An "eval-source-map" devtool has been used.
 * This devtool is neither made for production nor for readable output files.
 * It uses "eval()" calls to create a separate source file with attached SourceMaps in the browser devtools.
 * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
 * or disable the default devtool with "devtool: false".
 * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
 */
(self["webpackChunkgm3"] = self["webpackChunkgm3"] || []).push([["node_modules_geotiff_dist-module_compression_webimage_js"],{

/***/ "./node_modules/geotiff/dist-module/compression/webimage.js":
/*!******************************************************************!*\
  !*** ./node_modules/geotiff/dist-module/compression/webimage.js ***!
  \******************************************************************/
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {

eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"default\": function() { return /* binding */ WebImageDecoder; }\n/* harmony export */ });\n/* harmony import */ var _basedecoder_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./basedecoder.js */ \"./node_modules/geotiff/dist-module/compression/basedecoder.js\");\n\n/**\n * class WebImageDecoder\n *\n * This decoder uses the browsers image decoding facilities to read image\n * formats like WebP when supported.\n */\nclass WebImageDecoder extends _basedecoder_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"] {\n    /**\n     * @param {import('./basedecoder.js').BaseDecoderParameters} parameters\n     */\n    constructor(parameters) {\n        super(parameters);\n        if (typeof createImageBitmap === 'undefined') {\n            throw new Error('Cannot decode WebImage as `createImageBitmap` is not available');\n        }\n        else if (typeof document === 'undefined' && typeof OffscreenCanvas === 'undefined') {\n            throw new Error('Cannot decode WebImage as neither `document` nor `OffscreenCanvas` is not available');\n        }\n    }\n    /** @param {ArrayBuffer} buffer */\n    async decodeBlock(buffer) {\n        const blob = new Blob([buffer]);\n        const imageBitmap = await createImageBitmap(blob);\n        let canvas;\n        if (typeof document !== 'undefined') {\n            canvas = document.createElement('canvas');\n            canvas.width = imageBitmap.width;\n            canvas.height = imageBitmap.height;\n        }\n        else {\n            canvas = new OffscreenCanvas(imageBitmap.width, imageBitmap.height);\n        }\n        // Draw the image onto the canvas to extract the pixel data.\n        // Note: createImageBitmap always returns RGBA data.\n        const ctx = /** @type {CanvasRenderingContext2D} */ (canvas.getContext('2d'));\n        ctx.drawImage(imageBitmap, 0, 0);\n        const imageData = ctx.getImageData(0, 0, imageBitmap.width, imageBitmap.height).data;\n        // Return the correct channels to the caller\n        const samplesPerPixel = this.parameters.samplesPerPixel || 4;\n        if (samplesPerPixel === 4) {\n            // RGBA, return as is\n            return imageData.buffer;\n        }\n        else if (samplesPerPixel === 3) {\n            // RGB, remove alpha channel before returning\n            const rgb = new Uint8ClampedArray(imageBitmap.width * imageBitmap.height * 3);\n            for (let i = 0, j = 0; i < rgb.length; i += 3, j += 4) {\n                rgb[i] = imageData[j];\n                rgb[i + 1] = imageData[j + 1];\n                rgb[i + 2] = imageData[j + 2];\n            }\n            return rgb.buffer;\n        }\n        else {\n            throw new Error(`Unsupported SamplesPerPixel value: ${samplesPerPixel}`);\n        }\n    }\n}\n//# sourceMappingURL=webimage.js.map//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64, \n//# sourceURL=webpack-internal:///./node_modules/geotiff/dist-module/compression/webimage.js\n\n}");

/***/ })

}]);