UNPKG

@pebula/metap

Version:
2 lines 26 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@pebula/utils")):"function"==typeof define&&define.amd?define("@pebula/metap/internal",["exports","@pebula/utils"],e):e(((t=t||self).pebula=t.pebula||{},t.pebula.metap=t.pebula.metap||{},t.pebula.metap.internal={}),t.pebula.utils)}(this,function(t,e){"use strict";var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function n(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function a(t,e,r,n){var a,o=arguments.length,i=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(a=t[s])&&(i=(o<3?a(i):o>3?a(e,r,i):a(e,r))||i);return o>3&&i&&Object.defineProperty(e,r,i),i}function o(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function i(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}}function s(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,a,o=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(t){a={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(a)throw a.error}}return i}function c(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(s(arguments[e]));return t}var u,f=Symbol("Throw"),p=function(){function t(){t.create(this)}return Object.defineProperty(t.prototype,"throw",{get:function(){var t;return Object.assign(Object.create(this),((t={})[f]="throw",t))},enumerable:!0,configurable:!0}),t.prototype.decorator=function(t,r,n){var a=e.isFunction(t)?t:t.constructor;if(n){var o=a===t?"#":".";return this.ERROR("Invalid decorator @ "+e.stringify(t)+o+e.stringify(n)+": "+r)}return this.ERROR("Invalid decorator @ "+e.stringify(a)+"}: "+r)},t.prototype.model=function(t,r){return this.ERROR("Model Error ["+e.stringify(t)+"]: "+r)},t.prototype.modelSingleCol=function(t,r){return this.ERROR("Expected a COLLECTION but got an OBJECT [Target: "+e.stringify(t)+"]")},t.prototype.ERROR=function(t,e){var r=new Error(t);if(e&&Object.assign(r,e),"throw"===this[f])throw r;return r},t.create=function(e){return e||Object.create(t.prototype)},t}(),l=p.create(),g=((u={next:function(){return{value:null,done:!0}}})[Symbol.iterator]=function(){return g},u),y=function(){function t(){this.map=new Map,this[Symbol.toStringTag]="Map"}return t.prototype.has=function(t,e){if(void 0===e)return this.map.has(t);var r=this.map.get(t);return!!r&&r.has(e)},t.prototype.get=function(t,e){var r=this.map.get(t);return void 0===e?r:r&&r.get(e)},t.prototype.delete=function(t,e){if(void 0===e)return this.map.delete(t);var r=this.map.get(t);return!(r&&r.delete(e))},t.prototype.set=function(t,e,r){if(e instanceof Map)2===arguments.length&&this.map.set(t,e);else{var n=this.map.get(t)||new Map;n.set(e,r),this.map.set(t,n)}},t.prototype.clear=function(t){void 0===t&&this.map.clear();var e=this.map.get(t);e&&e.clear()},t.prototype.forEach=function(t,e,r){if(!0===t)this.map.forEach(e,r);else{var n=this.map.get(e);n&&n.forEach(t,r)}},t.prototype.entries=function(t){if(void 0===t)return this.map.entries();var e=this.map.get(t);return e?e.entries():this.makeEmptyIterator()},t.prototype.keys=function(t){if(void 0===t)return this.map.keys();var e=this.map.get(t);return e?e.keys():this.makeEmptyIterator()},t.prototype.values=function(t){if(void 0===t)return this.map.values();var e=this.map.get(t);return e?e.values():this.makeEmptyIterator()},Object.defineProperty(t.prototype,"size",{get:function(){return this.map.size},enumerable:!0,configurable:!0}),t.prototype.sizeOf=function(t){var e=this.map.get(t);return e?e.size:0},t.prototype.makeEmptyIterator=function(){return g},t.prototype[Symbol.iterator]=function(){return this.map[Symbol.iterator]()},t}();var h=function(){function t(){this.map=new Map}return t.prototype.has=function(t,e){if(1===arguments.length)return this.map.has(t);var r=this.map.get(t);return!!r&&r.has(e)},t.prototype.get=function(t,e){if(1===arguments.length)return this.map.get(t);var r=this.map.get(t);return r?d.index(r,e):void 0},t.prototype.set=function(t,e){return e||(e=new Set),this.map.set(t,e),e},t.prototype.add=function(t,e){var r=this.map.get(t)||new Set;return r.add(e),this.map.set(t,r),this},t.prototype.clear=function(t){if(t){var e=this.map.get(t);e&&e.clear()}else this.map.clear()},t.prototype.delete=function(t,e){if(1===arguments.length)return this.delete(t);var r=this.map.get(t);return!!r&&r.delete(e)},t.prototype.forEach=function(t,e,r){var n=this.map.get(t);n&&n.forEach(e,r)},Object.defineProperty(t.prototype,"size",{get:function(){return this.map.size},enumerable:!0,configurable:!0}),t.prototype.sizeOf=function(t){var e=this.map.get(t);return e?e.size:0},t}();var d=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.first=function(){return e.first(this)},e.prototype.index=function(t){return e.index(this,t)},e.prototype.asArray=function(){return e.asArray(this)},e.prototype.isSuperset=function(t){return e.isSuperset(this,t)},e.prototype.combine=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];e.combine.apply(e,c([this],t))},e.prototype.deduct=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];e.deduct.apply(e,c([this],t))},e.prototype.union=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return e.union.apply(e,c([e,this],t))},e.prototype.intersection=function(t){return e.intersection(this,t,!0)},e.prototype.difference=function(t){return e.difference(this,t,!0)},e.prototype.negative=function(t){return e.negative(this,t,!0)},e.first=function(t){return t.values().next().value},e.index=function(t,e){for(var r=t.values(),n=0;n<e;n++)if(r.next().done)return;return r.next().value},e.asArray=function(t){return Array.from(t)},e.isSuperset=function(t,r){return!e.asArray(r).some(function(e){return!t.has(e)})},e.combine=function(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];for(var a=0,o=r.length;a<o;a++)for(var i=Array.isArray(r[a])?r[a]:e.asArray(r[a]),s=0,c=i.length;s<c;s++)t.has(i[s])||t.add(i[s]);return t},e.deduct=function(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];for(var a=0,o=r.length;a<o;a++)for(var i=e.asArray(r[a]),s=0,c=i.length;s<c;s++)t.delete(i[s]);return t},e.union=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n="function"==typeof t[0]?new(t.shift()):new Set;return e.combine.apply(e,c([n],t)),n},e.intersection=function(t,r,n){for(var a=n?new e:new Set,o=e.asArray(r),i=0,s=o.length;i<s;i++)t.has(o[i])&&a.add(o[i]);return a},e.difference=function(t,r,n){for(var a=n?new e(t):new Set(t),o=e.asArray(r),i=0,s=o.length;i<s;i++)a.delete(o[i]);return a},e.negative=function(t,r,n){for(var a=n?new e(t):new Set(t),o=e.asArray(r),i=0,s=o.length;i<s;i++)a.has(o[i])?a.delete(o[i]):a.add(o[i]);return a},e}(Set),m=function(){function t(){}return t.mergeInto=function(e,r,n){for(var a=t.asKeyArray(r),o=0,i=a.length;o<i;o++)n&&e.has(a[o])||e.set(a[o],r.get(a[o]));return e},t.fromArray=function(t,e,r,n){r instanceof Map||(r=new Map,n=!1);for(var a=0,o=t.length;a<o;a++){var i=e(t[a]);n&&r.has(i)||r.set(i,t[a])}return r},t.asKeyValArray=function(t){return Array.from(t.entries())},t.asKeyArray=function(t){return Array.from(t.keys())},t.asValArray=function(t){return Array.from(t.values())},t.asObjectLiteral=function(e){return t.asKeyArray(e).reduce(function(t,r){return t[r.toString()]=e.get(r),t},{})},t}(),v={designType:function(t,e){return Reflect.getMetadata("design:type",t,e)},paramTypes:function(t,e){return Reflect.getMetadata("design:paramtypes",t,e)}};function b(t){return function(e,r,n){if(n)throw new Error("LazyInit can only decorate properties");Object.defineProperty(e,r,{configurable:!0,get:function(){var e=t.call(this);return Object.defineProperty(this,r,{value:e}),e}})}}var M={findRemove:function(t,e,r){var n=t.findIndex(e,r);if(n>-1)return t.splice(n,1)[0]}};var O=function(t){this.decoratorInfo=t,this.name=t.name};var w=function(t){function e(e,r){var n=t.call(this,e)||this;return n.paramType=v.paramTypes(r.prototype,n.name)[e.paramIndex],n}return n(e,t),Object.defineProperty(e.prototype,"paramIndex",{get:function(){return this.decoratorInfo.paramIndex},enumerable:!0,configurable:!0}),e}(O);var x=new h,S=new h,j=function(){function t(){t.create(this)}return t.prototype.metaInit=function(t){return{run:function(e){S.add(t,e)}}},t.prototype.createMetadata=function(t){e.isFunction(t)&&x.add("createMetadata",t)},t.prototype.beforeProcessType=function(t){e.isFunction(t)&&x.add("beforeProcessType",t)},t.prototype.processType=function(t){e.isFunction(t)&&x.add("processType",t)},t.create=function(e){var r=e||Object.create(t.prototype);return r.FIRE=A,r},t}();var A={metaInit:function(t,e,r,n){var a=S.get(t);a&&Array.from(a.values()).forEach(function(t){return t(e,r,n)})},createMetadata:function(t){return E("createMetadata",t)},beforeProcessType:function(t){return E("beforeProcessType",t)},processType:function(t){return E("processType",t)}},T=j.create();function E(t,e){var r=x.get(t);r&&Array.from(r.values()).forEach(function(t){return t(e)})}var P=Symbol("lazyRef"),F=function(){return e.stringify(this())};function R(t){return t[P]=R,t.toString=F,t}!function(t){t.resolve=function(r){return e.isFunction(r)&&r[P]===t?r():r}}(R||(R={}));var C={},I={};var K=new Map,z=function(){},_=function(){function t(t,r){if(this.target=t,this.metaArgs=r,this.proxyTo=[],this.metaArgs){if(r.inherit&&(this.metaArgs=r=Object.assign({},V.get(r.inherit).metaArgs,r)),r.factory&&(this.factory=r.factory),r.register&&(e.isString(r.register)?this.register=C[r.register]:e.isFunction(r.register)&&(this.register=r.register)),r.proxy){var n=r.proxy;n.metaClass=this,V.get(r.proxy.host).proxyTo.push(n)}if(r.extend){if(!0===r.single)throw new Error("Extending a single class is done using extendSingle");e.isString(r.extend)?this.extend=I[r.extend]:e.isFunction(r.extend)&&(this.extend=r.extend)}if(e.isFunction(r.extendSingle)){if(!0!==r.single)throw new Error("Extending a non-single class is done using extend");this.extendSingle=r.extendSingle}e.isFunction(r.onCreated)&&r.onCreated(this)}else this.metaArgs={}}return t.prototype.create=function(t,e,r,n){return this.createCurry(t,e,r,n)()},t.prototype.createCurry=function(t,r,n,a){var o=this,i=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];if(e.isFunction(t[0])&&!t[1])return{type:"class"};var n=3===t.length&&e.isNumber(t[2])?"param":"member",a={type:n,name:t[1],isStatic:e.isStaticDecorator(t[0]),hasDescriptor:3===t.length&&"member"===n};return"param"===n&&(a.paramIndex=t[2]),a}(r,n,a),s=this.metaArgs.allowOn;if(s&&s.length>0)if("class"===i.type){if(-1===s.indexOf("class"))throw new Error("Metadata class "+e.stringify(this.target)+" can not decorate a class ("+e.stringify(r)+")")}else if(i.isStatic){if(-1===s.indexOf("staticMember"))throw new Error("Metadata class "+e.stringify(this.target)+" can not decorate a static member ("+e.stringify(r)+"#"+n.toString()+")")}else if("param"===i.type){if(-1===s.indexOf("param"))throw new Error("Metadata class "+e.stringify(this.target)+" can not decorate a param ("+e.stringify(r)+"#"+n.toString()+")")}else if(-1===s.indexOf("member"))throw new Error("Metadata class "+e.stringify(this.target)+" can not decorate an instance member ("+e.stringify(r.constructor)+"."+n.toString()+")");var c=this.factory(t,r,i,n,a),u=function(e){if(e||(e=c),e){o.register(e);var i=o.singleChain(e);return i&&i.forEach(function(t){return o.register(t)}),T.FIRE.metaInit(e.metaClassKey,e.target,e.metaValue,t),o.findProxies(t).forEach(function(t){if(t)for(var e=0,o=t.args.length;e<o;e++)t.meta.create(t.args[e],r,n,a)}),c&&c.metaValue}};return u.meta=c,u},t.prototype.createDecorator=function(){for(var t=this,r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return function(r){return function(n,a,o){var s,c,u,f,p=t.metaArgs,l=p.decorateBefore,g=p.decorateAfter,y=e.isFunction(l)?l(r):[],h=e.isFunction(g)?g(r):[];try{for(var d=i(h),m=d.next();!m.done;m=d.next()){(0,m.value)(n,a,o)}}catch(t){s={error:t}}finally{try{m&&!m.done&&(c=d.return)&&c.call(d)}finally{if(s)throw s.error}}t.create(r,n,a,o);try{for(var v=i(y),b=v.next();!b.done;b=v.next()){(0,b.value)(n,a,o)}}catch(t){u={error:t}}finally{try{b&&!b.done&&(f=v.return)&&f.call(v)}finally{if(u)throw u.error}}}}},t.prototype.factory=function(t,r,n,a,o){var i=e.ensureTargetIsType(r);return{info:n,target:i,metaClassKey:this.target,metaPropKey:!0===this.metaArgs.single?z:n.name,metaValue:new this.target(t,n,i)}},t.prototype.singleChain=function(t){if(!0===this.metaArgs.single&&this.metaArgs.inherit){var e=Object.create(t);e.metaClassKey=this.metaArgs.inherit;var r=k(this.metaArgs.inherit).singleChain(t);return r?c([e],r):[e]}},t.prototype.findProxies=function(t){var r=[];if(t){this.metaArgs.inherit&&r.splice.apply(r,c([0,0],V.get(this.metaArgs.inherit).findProxies(t)));var n=this.proxyTo.map(function(r){if(t.hasOwnProperty(r.containerKey)){var n=e.isFunction(r.before)?r.before(t[r.containerKey]):t[r.containerKey];return delete t[r.containerKey],!0===r.forEach&&Array.isArray(n)?{meta:r.metaClass,args:n}:{meta:r.metaClass,args:[n]}}});r.splice.apply(r,c([r.length,0],n))}return r},t.create=function(e,r){return new t(e,r)},t}();function k(t){return K.get(t)}function V(t){return function(e){K.set(e,_.create(e,t))}}(function(t){t.create=function(t,e,r,n,a){return K.get(t).create(e,r,n,a)},t.decorator=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return K.get(t).createDecorator()},t.defaultRegistrator=function(t){_.prototype.register=t}})(V||(V={})),V.get=k;var D=Symbol("ModelClassCollection instance mark"),N=["constructor"],B=new Map;function L(t){var e=Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t)).filter(function(t){return-1===N.indexOf(t)});B.set(t,e)}function G(t,e){var r=B.get(t)||[];e[D]=!0;for(var n=0,a=r.length;n<a;n++){var o=r[n],i=Object.getOwnPropertyDescriptor(t,o);i?Object.defineProperty(e,o,i):e[o]=t[o]}}var U=function(t){function r(){var e=t.call(this)||this;return G(r.prototype,e),e}return n(r,t),r.extend=function(t){e.Mixin(r,t),L(r.prototype)},r.instanceOf=function(t){return!0===t[D]},r.create=function(t,e){return e?t.getTargetMeta(e).createCollection():new r},r.factory=function(t){var a=function(t){function o(){var e=t.call(this)||this;return G(a.prototype,e),e}return n(o,t),o.extend=function(t){e.Mixin(r,t),L(a.prototype)},o}(r);return Object.defineProperty(a,Symbol.hasInstance,{value:a.instanceOf}),Object.assign(a.prototype,t),L(a.prototype),a},r}(Array);Object.defineProperty(U,Symbol.hasInstance,{value:U.instanceOf}),L(U.prototype);var q=Symbol("ModelClass instance mark");var H=function(){function t(){}return t.prototype.toString=function(){return this.constructor.name},t.instanceOf=function(t){return!0===t[q]},t.factory=function(r){var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(r);Object.defineProperty(a,"name",{configurable:!0,value:r.name}),Object.defineProperty(a,Symbol.hasInstance,{value:t.instanceOf}),e.MixinFree(a,t,"proto");var o=Reflect.getOwnMetadata("design:paramtypes",r);return Reflect.defineMetadata("design:paramtypes",o,a),a},t}();Object.defineProperty(H.prototype,q,{value:!0});var J=function(){function t(t,e,r){this.targetStore=t,this.target=e,this.config=r}return t.prototype.getValues=function(t){var e=this.config.get(t);return e?Array.from(e.values()):[]},t.prototype.getMetaFor=function(t,r){if(e.isString(r)){if(n=this.config.get(t))return n.get(r)}else{if(!0!==r)return this.config.get(t);var n;if(n=this.config.get(z))return n.get(t)}},t.prototype.setMetaFor=function(t,r,n){e.isString(r)?this.targetStore.setMetaFor(this.target,t,r,n):this.targetStore.setMetaFor(this.target,t,!0,r)},t.prototype.createCollection=function(){return new U},t}();var Q=function(){function t(){t.create(this)}return Object.defineProperty(t.prototype,"on",{get:function(){return T},enumerable:!0,configurable:!0}),t.prototype.local=function(t,e){void 0===e&&(e=0);var r=this.locals.get(t);if(r)return d.index(r,e)},t.prototype.hasTarget=function(t){return this.targets.has(t)},t.prototype.getAllModels=function(){return Array.from(this.builtTargets.values()).filter(function(t){return t.hasModel})},t.prototype.findTarget=function(t){return this.namedTargets.get(t)},t.prototype.getTargetsFor=function(t){var e,r,n=[];try{for(var a=i(Array.from(this.targets.entries())),o=a.next();!o.done;o=a.next()){var c=s(o.value,2),u=c[0];c[1].has(t)&&n.push(u)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}return n},t.prototype.getTargetMeta=function(t){var e=this.builtTargets.get(t);if(!e){var r=this.targets.get(t);if(!r)return this.registerTarget(t),this.getTargetMeta(t);e=new J(this,t,r),this.builtTargets.set(t,e),T.FIRE.createMetadata(t)}return e},t.prototype.getMetaFor=function(t,e,r,n){var a=this.targets.get(t);if(a){if(!0===r){var o=a.get(z,e);return o&&n?o[n]:o}return r?a.get(e,r):a.get(e)}},t.prototype.setMetaFormFactory=function(t){t&&(t.metaPropKey===z?this.set(t.target,z,t.metaClassKey,t.metaValue):this.setMetaFor(t.target,t.metaClassKey,t.metaPropKey,t.metaValue))},t.prototype.setMetaFor=function(t,e,r,n){!0===r?this.set(t,z,e,n):this.set(t,e,r,n)},t.prototype.registerTarget=function(t){this.hasTarget(t)||this.targets.set(t,new y)},t.prototype.extend=function(t,r){if(!this.hasTarget(t)||!this.hasTarget(r))throw new Error("Target not registered.");var n=this.targets.get(t),a=this.targets.get(r);Array.from(n.keys()).forEach(function(o){if(o===z){var i=n.get(o),c=a.get(o)||new Map;m.asKeyValArray(i).forEach(function(n){var a=s(n,2),o=a[0],i=a[1],u=V.get(o);if(u.extendSingle){var f=c.get(o),p=u.extendSingle(i,f,{from:t,to:r});e.isUndefined(p)||c.set(o,p)}}),c.size>0&&a.set(o,c)}else{var u=V.get(o);if(u.extend){var f=u.extend(n.get(o),a.get(o),{from:t,to:r});e.isUndefined(f)||a.set(o,f)}}})},t.prototype.set=function(t,e,r,n){var a=this.targets.get(t);return a||this.targets.set(t,a=new y),a.set(e,r,n),n},t.create=function(e){var r=e||Object.create(t.prototype);return r.locals=new h,r.namedTargets=new Map,r.targets=new Map,r.builtTargets=new Map,r},t}();var W,X=(W=Q.create(),V.defaultRegistrator(function(t){return X.setMetaFormFactory(t)}),function(t){C.array=function(e){var r=!0===this.metaArgs.single||e.metaPropKey,n=t.getMetaFor(e.target,e.metaClassKey,r);n||t.setMetaFor(e.target,e.metaClassKey,r,n=[]),n.push(e.metaValue)},I.mergeMap=function(t,e){return e?m.mergeInto(e,t):new Map(t.entries())},I.mergeMapArray=function(t,e){return e||(e=new Map),m.asKeyValArray(t).forEach(function(t){var r,n,a=s(t,2),o=a[0],c=a[1];if(e.has(o)){var u=c,f=e.get(o),p=function(t){f.some(function(e){return e.name===t.name})||f.push(t)};try{for(var l=i(u),g=l.next();!g.done;g=l.next())p(g.value)}catch(t){r={error:t}}finally{try{g&&!g.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}}else e.set(o,c.slice())}),e}}(W),W);var Y=[Array,Map,Set];var Z,$=function(t){function r(r,n,a){var o,i=t.call(this,n)||this,s=a?v.designType(a.prototype,i.name):Object,c=function(t){return Y.indexOf(t)>-1}(s)?s:void 0;return e.isFunction(r)?o={ref:r,forwardRef:!0,container:c}:r?(r.isArray&&!r.container&&(r.container=Array),o=r,c&&!o.hasOwnProperty("container")&&(o.container=c),o.ref||(o.ref=!0===o.forwardRef?function(){return Object}:Object)):o={ref:s===Array?Object:s,container:c},i.container=o.container,!0===o.forwardRef?(Object.defineProperty(i,"ref",{configurable:!0,get:o.ref}),i.isGetter=!0):i.ref=o.ref,i}return n(r,t),r=a([V({allowOn:["member"],extend:"mergeMap"}),o("design:paramtypes",[Object,Object,Object])],r)}(O);var tt=function(){return X.getMetaFor(this.target,$,this.name)||new $(this.typeArgs,this.decoratorInfo,this.target)},et=function(t){function r(r,n,a){var o,i,s,c,u=t.call(this,n)||this;return u.target=a,r||(r={}),u.alias=(o=r.alias,i=n.name,o?e.isString(o)?s=c=o:(s=o.incoming||i,c=o.outgoing||i):s=c=i,{incoming:s,outgoing:c}),r.transform&&(u.transform=function(t){var r,n;return e.isFunction(t)?r=n=t:t&&(e.isFunction(t.incoming)&&(r=t.incoming),e.isFunction(t.outgoing)&&(n=t.outgoing)),{incoming:r,outgoing:n}}(r.transform)),r.type&&(u.typeArgs=r.type),u}var i;return n(r,t),i=r,r.getCreateProp=function(t,r){var n=e.isString(r)?r:r.name,a=t.getMetaFor(i,n);return a||(Z||(Z=V.decorator(i,!0)()),Z(t.target.prototype,n),t.getMetaFor(i,n))},a([b(tt),o("design:type",$)],r.prototype,"type",void 0),r=i=a([V({allowOn:["member"],extend:"mergeMap"}),o("design:paramtypes",[Object,Object,Object])],r)}(O);var rt=function(t){X.on.processType(function(e){var r,n,a=X.getTargetMeta(e),o=t.target;try{for(var s=i(a.getValues(o)),c=s.next();!c.done;c=s.next()){var u=c.value,f=et.getCreateProp(a,u.decoratorInfo);RelationMetadata_1.setRelationship(f,u),u.name!==u.foreignKey&&(et.getCreateProp(a,u.foreignKey).foreignKeyOf=f)}}catch(t){r={error:t}}finally{try{c&&!c.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}})},nt=function(t){function e(e,r){var n=t.call(this,r)||this;return n.foreignKey=e&&e.foreignKey||r.name,n}return n(e,t),e,e.setRelationship=function(t,e){if(!(t.type.isGetter||t.type.ref&&t.type.ref!==Object&&t.type.ref!==Array))throw new Error("Property "+t.decoratorInfo.name.toString()+" with relation but without a type, please set a type.");t.relation=e},e=a([V({allowOn:["member"],extend:"mergeMap",onCreated:rt}),o("design:paramtypes",[Object,Object])],e)}(O);function at(t,e,r){if("class"!==r.type)return{info:r,target:e.constructor,metaClassKey:ot,metaPropKey:r.name,metaValue:new ot(t,r)};X.getTargetMeta(e).model().transformStrategy="exclusive"}var ot=function(t){function e(e,r){var n=t.call(this,r)||this;return e&&(n.from=e.from),n}return n(e,t),e=a([V({allowOn:["class","member"],extend:"mergeMap",proxy:{host:et,containerKey:"exclude"},factory:at}),o("design:paramtypes",[Object,Object])],e)}(O);var it=Symbol("ModelMetadata placeholder");function st(t){!function(t){Object.defineProperty(J.prototype,"model",{value:function(){return this[it]||(this[it]={})}}),Object.defineProperty(J.prototype,"hasModel",{get:function(){return this[it]instanceof t}}),J.prototype.getIdentityKey=function(t){return X.getIdentityKey(this.target,t)}}(t),function(t){X.on.processType(function(t){var e=X.getTargetMeta(t).model();e&&X.namedTargets.set(e.resName,t)}),Q.prototype.getTargetName=function(e){return X.getMetaFor(e,t,!0,"resName")},Q.prototype.getIdentityKey=function(t,r){var n=this.getTargetMeta(t),a=n.model(),o=a.identity;if(o){if(!r)return o;var i=n.getMetaFor(et,o);if(i.name===i.alias[r]){var s=a.transformNameStrategy;if(s&&e.isFunction(s[r]))return"exclusive"===a.transformStrategy&&(r="outgoing"),s[r](i.name)}return"outgoing"===r?i.alias.outgoing:i.alias.incoming}}}(t)}function ct(t,e,r){if(!e)return X.getTargetMeta(r.to)[it]=t.clone(r.to);Object.keys(t).forEach(function(r){r in e||(e[r]=t[r])})}var ut=function(t){return st(t.target)},ft=function(t){function r(r,n,a){for(var o=t.call(this,n)||this,i=X.getTargetMeta(a),s=e.getProtoChain(a),c=s.length-1;c>0;c--){var u=X.hasTarget(s[c])&&X.getTargetMeta(s[c]);if(u)if(u[it]&&!u.hasModel)Object.assign(o,u[it]);else if(u.hasModel)break}var f=i.hasOwnProperty(it)?i[it]:{};return Object.assign(o,f,r||{},{target:a,tMeta:i}),o.resName||(o.resName=e.stringify(a)),i[it]=o,o}return n(r,t),r,Object.defineProperty(r.prototype,"built",{get:function(){return this._built},enumerable:!0,configurable:!0}),r.prototype.clone=function(t){return new(0,this.constructor)(this,this.decoratorInfo,t)},r.prototype.factory=function(t){return t?this.tMeta.createCollection():new this.target},r.prototype.build=function(t){if(this.built){if(!0===t)return!1;throw new Error('"'+e.stringify(this.target)+'" already built.')}return this._built=!0,T.FIRE.beforeProcessType(this.target),T.FIRE.processType(this.target),!0},r=a([V({allowOn:["class"],single:!0,extendSingle:ct,onCreated:ut}),o("design:paramtypes",[Object,Object,Object])],r)}(O);var pt=["boolean","string","number","symbol"],lt=function(){function t(){}return t.prototype.deserialize=function(t){return this._deserialize(t)},t.prototype.serialize=function(t){return this._serialize(t,new Map)},t.prototype._deserialize=function(t){return t},t.prototype._serialize=function(t,e){if(null==t)return null;if(pt.indexOf(typeof t)>-1)return t;var r=e.get(t);if(r)return r;if(Array.isArray(t)){e.set(t,r=[]);for(var n=0,a=t.length;n<a;n++)r.push(this._serialize(t[n],e))}else if(t instanceof Date)e.set(t,r=t.toISOString());else if(t instanceof RegExp)e.set(t,r=t.toString());else if("object"==typeof t||"function"==typeof t){e.set(t,r={});var o=Object.keys(t);for(n=0,a=o.length;n<a;n++)r[o[n]]=this._serialize(t[o[n]],e)}else e.set(t,r=t.toString());return r},t}();var gt=function(t,e){this.source=t,this.plainMapper=e||new lt};var yt=function(t,e,r){this.source=t,this.sourceType=e,this.plainMapper=r||new lt};t.BaseDeserializer=yt,t.BaseMetadata=O,t.BaseParamMetadata=w,t.BaseSerializer=gt,t.DualKeyMap=y,t.Errors=p,t.ExcludeMetadata=ot,t.KeySet=h,t.LazyInit=b,t.MapExt=m,t.MetaClass=V,t.MetaClassMetadata=_,t.ModelClassBase=H,t.ModelClassCollection=U,t.ModelMetadata=ft,t.PlainObjectMapper=lt,t.PropMetadata=et,t.RelationMetadata=nt,t.SetExt=d,t.TargetEvents=j,t.TargetMetadata=J,t.TargetStore=Q,t.TypeMetadata=$,t.array=M,t.errors=l,t.lazyRef=R,t.reflection=v,t.setMetaHelper=function(t,e,r){switch(t){case"extend":I[e]=r;break;case"register":C[e]=r}},t.targetStore=X,t.ɵa=at,t.ɵc=O,t.ɵd=V,t.ɵf=b,t.ɵg=y,Object.defineProperty(t,"__esModule",{value:!0})}); //# sourceMappingURL=pebula-metap-internal.umd.min.js.map