"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.wrapImage = wrapImage;
const _1 = require("../Class/$");
const CodePathNotImplemented_1 = require("../exception/CodePathNotImplemented");
const ObjectPathTooDeep_1 = require("../exception/ObjectPathTooDeep");
const ObjectReadOnly_1 = require("../exception/ObjectReadOnly");
const KNOWN_IMAGE_PROPERTIES = ['naturalWidth', 'naturalHeight'];
function wrapImage(image, system) {
    const stream = new (class Image extends _1.$ {
        constructor() {
            super(...arguments);
            this.__ = ['IM', 'J'];
        }
        get(name) {
            if (KNOWN_IMAGE_PROPERTIES.includes(name)) {
                // @ts-ignore
                return image[name];
            }
            return false;
        }
        set(name, data) {
            throw new ObjectReadOnly_1.ReadOnlyError('image');
        }
        delete(name) {
            throw new ObjectReadOnly_1.ReadOnlyError('image');
        }
        hasKey(name) {
            if (KNOWN_IMAGE_PROPERTIES.includes(name)) {
                return true;
            }
            return false;
        }
        keys() {
            throw KNOWN_IMAGE_PROPERTIES;
        }
        deepGet(path) {
            if (path.length > 1) {
                throw new ObjectPathTooDeep_1.ObjectPathTooDeepError();
            }
            return this.get(path[0]);
        }
        deepSet(path, data) {
            throw new ObjectReadOnly_1.ReadOnlyError('image');
        }
        deepDelete(path) {
            throw new ObjectReadOnly_1.ReadOnlyError('image');
        }
        deepHas(path) {
            try {
                this.deepGet(path);
                return true;
            }
            catch (err) {
                return false;
            }
        }
        subscribe(path, key, listener) {
            throw new CodePathNotImplemented_1.CodePathNotImplementedError();
        }
        image() {
            return image;
        }
        raw() {
            return image;
        }
    })(system);
    return stream;
}
//# sourceMappingURL=Image.js.map