"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const image_js_1 = require("image-js");
const Database_1 = require("../Database");
class FileTexture {
    _filePath;
    _width;
    _height;
    _pixelData;
    get width() {
        return this._width;
    }
    get height() {
        return this._height;
    }
    get path() {
        return this._filePath;
    }
    constructor(_filePath, _width, _height, _pixelData) {
        this._filePath = _filePath;
        this._width = _width;
        this._height = _height;
        this._pixelData = _pixelData;
    }
    static async readTextureFromProjectFile(file) {
        await file.loadContent();
        if (typeof file.content === "string" || !file.content?.buffer) {
            return Promise.resolve(undefined);
        }
        const data = await image_js_1.Image.load(file.content);
        return new FileTexture(file.storageRelativePath, data.width, data.height, data);
    }
    static async readTextureFromLocalPath(filePath) {
        const content = await Database_1.default.getContentFolderContent(filePath);
        if (!content || !(content instanceof Uint8Array)) {
            return undefined;
        }
        const image = await image_js_1.Image.load(content);
        return new FileTexture(filePath, image.width, image.height, image);
    }
    isHighResolution() {
        return this._width === 128;
    }
    getPixel(x, y) {
        const [r, g, b, a = 255] = this._pixelData.getPixelXY(x, y);
        return { r, g, b, a };
    }
}
exports.default = FileTexture;

//# sourceMappingURL=../../maps/minecraft/textures/FileTexture.js.map
