"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.wrapImageData = wrapImageData;
const _1 = require("../Class/$");
const InvalidKeyPathError_1 = require("../exception/InvalidKeyPathError");
const ObjectReadOnly_1 = require("../exception/ObjectReadOnly");
const Array_1 = require("./Array");
function wrapImageData(imageData, system) {
    const image = new (class ImageData_ extends _1.$ {
        constructor() {
            super(...arguments);
            this.__ = ['J', 'ID'];
        }
        imageData() {
            return imageData;
        }
        get(name) {
            if (imageData[name] !== undefined) {
                if (name === 'data') {
                    return (0, Array_1.wrapUint8Array)(imageData.data, system);
                }
                return imageData[name];
            }
        }
        set(name, data) {
            throw new ObjectReadOnly_1.ReadOnlyError('image data');
        }
        delete(name) {
            throw new ObjectReadOnly_1.ReadOnlyError('image data');
        }
        hasKey(name) {
            if (imageData[name] !== undefined) {
                return true;
            }
            return false;
        }
        keys() {
            return ['width', 'height', 'data', 'colorSpace'];
        }
        deepGet(path) {
            if (path.length === 1) {
                return this.get(path[0]);
            }
            throw new InvalidKeyPathError_1.InvalidKeyPathError();
        }
        deepSet(path, data) {
            throw new ObjectReadOnly_1.ReadOnlyError('image data');
        }
        deepDelete(path) {
            throw new ObjectReadOnly_1.ReadOnlyError('image data');
        }
        deepHas(path) {
            try {
                this.deepGet(path);
                return true;
            }
            catch (err) {
                return false;
            }
        }
        subscribe(path, key, listener) {
            throw new ObjectReadOnly_1.ReadOnlyError('image data');
        }
        raw() {
            return imageData;
        }
    })(system);
    return image;
}
//# sourceMappingURL=ImageData.js.map