import{TransformationType as t}from"./enums/transformation-type.enum.js";var e=function(){function e(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return e.prototype.addTypeMetadata=function(t){this._typeMetadatas.has(t.target)||this._typeMetadatas.set(t.target,new Map),this._typeMetadatas.get(t.target).set(t.propertyName,t)},e.prototype.addTransformMetadata=function(t){this._transformMetadatas.has(t.target)||this._transformMetadatas.set(t.target,new Map),this._transformMetadatas.get(t.target).has(t.propertyName)||this._transformMetadatas.get(t.target).set(t.propertyName,[]),this._transformMetadatas.get(t.target).get(t.propertyName).push(t)},e.prototype.addExposeMetadata=function(t){this._exposeMetadatas.has(t.target)||this._exposeMetadatas.set(t.target,new Map),this._exposeMetadatas.get(t.target).set(t.propertyName,t)},e.prototype.addExcludeMetadata=function(t){this._excludeMetadatas.has(t.target)||this._excludeMetadatas.set(t.target,new Map),this._excludeMetadatas.get(t.target).set(t.propertyName,t)},e.prototype.findTransformMetadatas=function(e,a,o){return this.findMetadatas(this._transformMetadatas,e,a).filter((function(e){return!e.options||(!0===e.options.toClassOnly&&!0===e.options.toPlainOnly||(!0===e.options.toClassOnly?o===t.CLASS_TO_CLASS||o===t.PLAIN_TO_CLASS:!0!==e.options.toPlainOnly||o===t.CLASS_TO_PLAIN))}))},e.prototype.findExcludeMetadata=function(t,e){return this.findMetadata(this._excludeMetadatas,t,e)},e.prototype.findExposeMetadata=function(t,e){return this.findMetadata(this._exposeMetadatas,t,e)},e.prototype.findExposeMetadataByCustomName=function(t,e){return this.getExposedMetadatas(t).find((function(t){return t.options&&t.options.name===e}))},e.prototype.findTypeMetadata=function(t,e){return this.findMetadata(this._typeMetadatas,t,e)},e.prototype.getStrategy=function(t){var e=this._excludeMetadatas.get(t),a=e&&e.get(void 0),o=this._exposeMetadatas.get(t),s=o&&o.get(void 0);return a&&s||!a&&!s?"none":a?"excludeAll":"exposeAll"},e.prototype.getExposedMetadatas=function(t){return this.getMetadata(this._exposeMetadatas,t)},e.prototype.getExcludedMetadatas=function(t){return this.getMetadata(this._excludeMetadatas,t)},e.prototype.getExposedProperties=function(e,a){return this.getExposedMetadatas(e).filter((function(e){return!e.options||(!0===e.options.toClassOnly&&!0===e.options.toPlainOnly||(!0===e.options.toClassOnly?a===t.CLASS_TO_CLASS||a===t.PLAIN_TO_CLASS:!0!==e.options.toPlainOnly||a===t.CLASS_TO_PLAIN))})).map((function(t){return t.propertyName}))},e.prototype.getExcludedProperties=function(e,a){return this.getExcludedMetadatas(e).filter((function(e){return!e.options||(!0===e.options.toClassOnly&&!0===e.options.toPlainOnly||(!0===e.options.toClassOnly?a===t.CLASS_TO_CLASS||a===t.PLAIN_TO_CLASS:!0!==e.options.toPlainOnly||a===t.CLASS_TO_PLAIN))})).map((function(t){return t.propertyName}))},e.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},e.prototype.getMetadata=function(t,e){var a,o=t.get(e);o&&(a=Array.from(o.values()).filter((function(t){return void 0!==t.propertyName})));for(var s=[],r=0,n=this.getAncestors(e);r<n.length;r++){var p=n[r],i=t.get(p);if(i){var d=Array.from(i.values()).filter((function(t){return void 0!==t.propertyName}));s.push.apply(s,d)}}return s.concat(a||[])},e.prototype.findMetadata=function(t,e,a){var o=t.get(e);if(o){var s=o.get(a);if(s)return s}for(var r=0,n=this.getAncestors(e);r<n.length;r++){var p=n[r],i=t.get(p);if(i){var d=i.get(a);if(d)return d}}},e.prototype.findMetadatas=function(t,e,a){var o,s=t.get(e);s&&(o=s.get(a));for(var r=[],n=0,p=this.getAncestors(e);n<p.length;n++){var i=p[n],d=t.get(i);d&&d.has(a)&&r.push.apply(r,d.get(a))}return r.slice().reverse().concat((o||[]).slice().reverse())},e.prototype.getAncestors=function(t){if(!t)return[];if(!this._ancestorsMap.has(t)){for(var e=[],a=Object.getPrototypeOf(t.prototype.constructor);void 0!==a.prototype;a=Object.getPrototypeOf(a.prototype.constructor))e.push(a);this._ancestorsMap.set(t,e)}return this._ancestorsMap.get(t)},e}();export{e as MetadataStorage};
//# sourceMappingURL=MetadataStorage.js.map
