"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isImageFile = exports.uniqueId = void 0;
exports.getImageDimensions = getImageDimensions;
exports.loadImage = loadImage;
exports.getTransferFiles = getTransferFiles;
const utils_1 = require("../../../utils/index.js");
var lodash_1 = require("../../../lodash.js");
Object.defineProperty(exports, "uniqueId", { enumerable: true, get: function () { return lodash_1.uniqueId; } });
var clipboard_1 = require("../../../utils/clipboard.js");
Object.defineProperty(exports, "isImageFile", { enumerable: true, get: function () { return clipboard_1.isImageFile; } });
async function getImageDimensions(imgFile) {
    const img = await loadImage(imgFile);
    return { width: img.naturalWidth, height: img.naturalHeight };
}
async function loadImage(imgFile) {
    return new Promise((resolve, reject) => {
        const img = document.createElement('img');
        img.src = URL.createObjectURL(imgFile);
        img.onload = () => {
            URL.revokeObjectURL(img.src);
            resolve(img);
        };
        img.onerror = (_e, _s, _l, _c, error) => reject(error);
    });
}
function getTransferFiles(data) {
    if (!data)
        return null;
    if (!(0, utils_1.isFilesOnly)(data) && !(0, utils_1.isFilesFromHtml)(data))
        return null;
    return Array.from(data.files);
}
//# sourceMappingURL=utils.js.map
