(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports", "../di/TypeKey"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.PropertyMap = void 0;
    const TypeKey_1 = require("../di/TypeKey");
    class PropertyMap {
        // tslint:disable-next-line:ban-types
        static from(o) {
            const c = Object.getPrototypeOf(o);
            const key = TypeKey_1.TypeKey.get(c);
            const map = PropertyMap.map;
            const m = map[key] || (map[key] = PropertyMap.createMap(o));
            return m;
        }
        static createMap(c) {
            const map = {};
            const nameList = [];
            while (c) {
                const names = Object.getOwnPropertyNames(c);
                for (const name of names) {
                    if (/hasOwnProperty|constructor|toString|isValid|errors/i.test(name)) {
                        continue;
                    }
                    // // map[name] = Object.getOwnPropertyDescriptor(c, name) ? true : false;
                    // const pd = Object.getOwnPropertyDescriptor(c, name);
                    // // tslint:disable-next-line:no-console
                    // console.log(`${name} = ${c.enumerable}`);
                    map[name] = true;
                    nameList.push(name);
                }
                c = Object.getPrototypeOf(c);
            }
            const m = new PropertyMap();
            m.map = map;
            m.names = nameList;
            return m;
        }
    }
    exports.PropertyMap = PropertyMap;
    PropertyMap.map = {};
});
//# sourceMappingURL=PropertyMap.js.map