/*
    *
    * Wijmo Library 5.20182.500
    * http://wijmo.com/
    *
    * Copyright(c) GrapeCity, Inc.  All rights reserved.
    *
    * Licensed under the GrapeCity Commercial License.
    * sales@wijmo.com
    * wijmo.com/products/wijmo-5/license/
    *
    */
define(["require","exports","wijmo/wijmo","@angular/core"],function(e,t,n,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){}return e.asyncBindings=!0,e}();t.WjOptions=r;var o=function(){function e(e){this.changeEventMap=[],this.allImplEvents=[],this.resolveChangeEventMap(e)}return e.prototype.resolveChangeEventMap=function(e){var t=this.changeEventMap,n=e.outputs,i=e.changeEvents||{};if(t.splice(0,t.length),this.allImplEvents=[],n&&n.length){var r=n.map(function(e){return e.split(":")}).map(function(e){return{implName:e[0].trim(),exposeName:e[1]&&e[1].trim()}});this.allImplEvents=r.map(function(e){return e.implName});for(var o=0,s=r.filter(function(e){return e.implName&&e.exposeName});o<s.length;o++){var p=s[o];if(a.getWjEventName(p.implName)){var h={eventImpl:p.implName,event:p.exposeName},l=i[p.exposeName];l&&l.length&&(h.props=l.map(function(e){return{prop:e,evExposed:a.getChangeEventNameExposed(e),evImpl:a.getChangeEventNameImplemented(e)}})),t.push(h)}}for(var u in i)if(u.indexOf(".")>-1){h={eventImpl:null,event:u,props:i[u].map(function(e){return{prop:e,evExposed:a.getChangeEventNameExposed(e),evImpl:a.getChangeEventNameImplemented(e)}})};t.push(h)}}},e}();t.WjComponentResolvedMetadata=o;var s=function(){function e(t,n,i,r){this._pendingEvents=[],this.isInitialized=!1,this.isDestroyed=!1,this.directive=t,this.elementRef=n,this.injector=i,this.injectedParent=r;var s=this.typeData=t.constructor[e.directiveTypeDataProp];null==s.siblingId&&(s.siblingId=++e.siblingDirId+"");var a=t.constructor[e.directiveResolvedTypeDataProp];a?this.resolvedTypeData=a:t.constructor[e.directiveResolvedTypeDataProp]=a=this.resolvedTypeData=new o(s),t[e.BehaviourRefProp]=this,i[e.BehaviourRefProp]=this,t[e.isInitializedPropAttr]=!1,this._createEvents(),this._setupAsChild(),this._isHostElement()&&n.nativeElement.setAttribute(e.siblingDirIdAttr,s.siblingId),this.subscribeToEvents(!1)}return e.getHostElement=function(t,n){return e.ngZone||(e.ngZone=n.get(i.NgZone)),t.nativeElement},e.attach=function(t,n,i,r){return new e(t,n,i,r)},e.prototype.ngOnInit=function(){this.isInitialized=!0,this._initParent(),this.subscribeToEvents(!0)},e.prototype.ngAfterViewInit=function(){var t=this;this.directive[e.isInitializedPropAttr]=!0,setTimeout(function(){t.isDestroyed||t.directive[e.initializedEventAttr].emit(void 0)})},e.prototype.ngOnDestroy=function(){if(!this.isDestroyed){this.isDestroyed=!0;var t=this.directive;if(this._siblingInsertedEH&&this.elementRef.nativeElement.removeEventListener("DOMNodeInserted",this._siblingInsertedEH),this._isChild()&&this.parentBehavior){var i=this.parentBehavior.directive,r=this._getParentProp();if(!this.parentBehavior.isDestroyed&&i&&r&&t){var o=i[r];if(n.isArray(o)&&o){var s=o.indexOf(t);s>=0&&o.splice(s,1)}}}if(t instanceof n.Control&&t.hostElement){var a=this.elementRef.nativeElement,p=a&&a.parentNode,h=p?Array.prototype.indexOf.call(p.childNodes,a):-1;t.dispose(),h>-1&&Array.prototype.indexOf.call(p.childNodes,a)<0&&(a.textContent="",h<p.childNodes.length&&p.replaceChild(a,p.childNodes[h]))}this.injector[e.BehaviourRefProp]=null}},e.instantiateTemplate=function(e,t,n,i,r,o){void 0===r&&(r=!1),void 0===o&&(o={});var s,a=t.createEmbeddedView(n,o,t.length),p=a.rootNodes;if(r&&1===p.length)s=p[0];else{s=document.createElement("div");for(var h=0,l=p;h<l.length;h++){var u=l[h];s.appendChild(u)}}return e&&e.appendChild(s),{viewRef:a,rootElement:s}},e.prototype.getPropChangeEvent=function(e){var t=this.typeData.changeEvents;if(t)for(var n in t)if(t[n].indexOf(e)>-1)return n;return null},e.prototype._createEvents=function(){for(var e=0,t=this.resolvedTypeData.allImplEvents;e<t.length;e++){var n=t[e];this.directive[n]=new i.EventEmitter(!1)}},e.prototype.subscribeToEvents=function(e){var t=this.resolvedTypeData.changeEventMap;e=!!e;for(var n=0,i=t;n<i.length;n++)e!==(s=i[n]).event.indexOf(".")<0&&this.addHandlers(s);if(e)for(var r=0,o=t;r<o.length;r++){var s=o[r];this.triggerPropChangeEvents(s,!0)}},e.prototype.addHandlers=function(t){var n=this,i=this.directive;e.evaluatePath(i,t.event).addHandler(function(e,r){n._runInsideNgZone(function(){n.isInitialized&&n.triggerPropChangeEvents(t),t.eventImpl&&n._triggerEvent(i[t.eventImpl],r,t.props&&t.props.length>0)})})},e.prototype.triggerPropChangeEvents=function(e,t){void 0===t&&(t=!0);var n=this.directive;if(e.props&&e.props.length)for(var i=0,r=e.props;i<r.length;i++){var o=r[i];this._triggerEvent(n[o.evImpl],n[o.prop],t)}},e.prototype._setupAsChild=function(){this._isChild()&&(this._isHostElement()&&(this.elementRef.nativeElement.style.display="none"),this.parentBehavior=e.getBehavior(this.injectedParent))},e.prototype._isAsyncBinding=function(){var t=this.directive[e.asyncBindingUpdatePropAttr];return null==t?r.asyncBindings:t},e.prototype._isChild=function(){return this._isParentInitializer()||this._isParentReferencer()},e.prototype._isParentInitializer=function(){return null!=this.directive[e.parPropAttr]},e.prototype._isParentReferencer=function(){return!!this.typeData.parentRefProperty},e.prototype._getParentProp=function(){return this.directive[e.parPropAttr]},e.prototype._getParentReferenceProperty=function(){return this.typeData.parentRefProperty},e.prototype._useParentObj=function(){return!1},e.prototype._parentInCtor=function(){return this._isParentReferencer()&&""==this._getParentReferenceProperty()},e.prototype._initParent=function(){if(this.parentBehavior&&!this._useParentObj()){var e=this.parentBehavior.directive,t=this._getParentProp(),i=this.directive;if(this._isParentInitializer()){this._getParentProp();var r=e[t];if(n.isArray(r)){var o=this._isHostElement(),s=o?this._getSiblingIndex():-1;(s<0||s>=r.length)&&(s=r.length),r.splice(s,0,i),o&&(this._siblingInsertedEH=this._siblingInserted.bind(this),this.elementRef.nativeElement.addEventListener("DOMNodeInserted",this._siblingInsertedEH))}else e[t]=i}this._isParentReferencer()&&!this._parentInCtor()&&(i[this._getParentReferenceProperty()]=e)}},e.prototype._getSiblingIndex=function(){var t=this.elementRef.nativeElement,n=t.parentElement;if(!n)return-1;for(var i=n.childNodes,r=-1,o=this.typeData.siblingId,s=0;s<i.length;s++){var a=i[s];if(1==a.nodeType&&a.getAttribute(e.siblingDirIdAttr)==o&&(++r,a===t))return r}return-1},e.prototype._siblingInserted=function(e){if(e.target===this.elementRef.nativeElement){var t=this._getSiblingIndex(),n=this.parentBehavior.directive[this._getParentProp()],i=this.directive,r=n.indexOf(i);t>=0&&r>=0&&t!==r&&(n.splice(r,1),t=Math.min(t,n.length),n.splice(t,0,i))}},e.prototype._isHostElement=function(){return this.elementRef.nativeElement.nodeType===Node.ELEMENT_NODE},e.prototype._runInsideNgZone=function(t){var n=e;return n.ngZone&&!n._ngZoneRun&&(n._ngZoneRun=n.ngZone.run.bind(n.ngZone)),(n._ngZoneRun||function(e){return e()})(t)},e.prototype._triggerEvent=function(e,t,n){var i=this;if(n&&this._isAsyncBinding()){var r={event:e,args:t};this._pendingEvents.push(r),null==this._pendingEventsTO&&(this._pendingEventsTO=setTimeout(function(){i._triggerPendingEvents(!1)},0))}else e.emit(t)},e.prototype._triggerPendingEvents=function(e){if(null!=this._pendingEventsTO&&(clearTimeout(this._pendingEventsTO),this._pendingEventsTO=null),!this.isDestroyed){var t=[].concat(this._pendingEvents);this._pendingEvents.splice(0,this._pendingEvents.length);for(var n=0,i=t;n<i.length;n++){var r=i[n];r.event.emit(r.args)}e&&this._pendingEvents.length&&this._triggerPendingEvents(!0)}},e.prototype.flushPendingEvents=function(){this._triggerPendingEvents(!0)},e.evaluatePath=function(e,t){return this._pathBinding.path=t,this._pathBinding.getValue(e)},e.getBehavior=function(t){return t?t[e.BehaviourRefProp]:null},e.directiveTypeDataProp="meta",e.directiveResolvedTypeDataProp="_wjResolvedMeta",e.BehaviourRefProp="_wjBehaviour",e.parPropAttr="wjProperty",e.wjModelPropAttr="wjModelProperty",e.initializedEventAttr="initialized",e.isInitializedPropAttr="isInitialized",e.siblingDirIdAttr="wj-directive-id",e.asyncBindingUpdatePropAttr="asyncBindings",e.siblingDirId=0,e.wijmoComponentProviderId="WjComponent",e.outsideZoneEvents={pointermove:!0,pointerover:!0,mousemove:!0,wheel:!0,touchmove:!0,pointerenter:!0,pointerleave:!0,pointerout:!0,mouseover:!0,mouseenter:!0,mouseleave:!0,mouseout:!0},e._pathBinding=new n.Binding(""),e}();t.WjDirectiveBehavior=s;var a=function(){function e(){}return e.initEvents=function(e,t){for(var n=[],i=0,r=t;i<r.length;i++){var o=r[i],s=o.props;if(o.event&&o.eventImpl&&n.push(o.eventImpl+":"+o.event),s&&s.length)for(var a=0,p=s;a<p.length;a++){var h=p[a];n.push(h.evImpl+":"+h.evExposed)}}return n},e.getChangeEventNameImplemented=function(t){return e.getChangeEventNameExposed(t)+e.changeEventImplementSuffix},e.getChangeEventNameExposed=function(e){return e+"Change"},e.getWjEventNameImplemented=function(t){return t+e.wjEventImplementSuffix},e.getWjEventName=function(t){if(t){var n=e.wjEventImplementSuffix,i=t.length-n.length;if(i>0&&t.substr(i)===n)return t.substr(0,i)}return null},e.getBaseType=function(e){var t;return e&&(t=Object.getPrototypeOf(e.prototype))&&t.constructor},e.getAnnotations=function(e){return Reflect.getMetadata("annotations",e)},e.getAnnotation=function(e,t){if(t&&e)for(var n=0,i=e;n<i.length;n++){var r=i[n];if(r instanceof t)return r}return null},e.getTypeAnnotation=function(t,n,i){for(var r=t;r;r=i?null:e.getBaseType(r)){var o=e.getAnnotation(e.getAnnotations(r),n);if(o)return o}return null},e.equals=function(e,t){return e!=e&&t!=t||n.DateTime.equals(e,t)||e===t},e._copy=function(e,t,i,r,o){if(e&&t)for(var s in t)if(r||"_"!==s[0]){var a=t[s];if(!o||o(s,a)){var p=e[s];n.isArray(a)?e[s]=(!n.isArray(p)||i?[]:p).concat(a):void 0!==a&&(e[s]=a)}}},e.changeEventImplementSuffix="PC",e.wjEventImplementSuffix="Ng",e}();t.Ng2Utils=a;var p=function(){function e(e){this._writeQnt=0,this._isSubscribed=!1,this._onChange=function(e){},this._onTouched=function(){},this._directive=e,this._behavior=s.getBehavior(e)}return e.prototype.writeValue=function(e){var t=this;if(this._modelValue=e,++this._writeQnt,this._directive.isInitialized)this._ensureInitEhUnsubscribed(),this._updateDirective();else if(!this._dirInitEh){var n=this._directive.initialized;this._dirInitEh=n.subscribe(function(){t._updateDirective(),t._ensureInitEhUnsubscribed()})}},e.prototype.registerOnChange=function(e){this._onChange=e},e.prototype.registerOnTouched=function(e){this._onTouched=e},e.prototype.setDisabledState=function(e){var t=this._directive;t instanceof n.Control&&(t.isDisabled=e)},e.prototype._updateDirective=function(){if(!this._isFirstChange()||null!=this._modelValue){if(this._ensureNgModelProp(),this._directive&&this._ngModelProp){var e=this._modelValue;""===e&&(e=null),this._directive[this._ngModelProp]=e}this._ensureSubscribed()}},e.prototype._ensureSubscribed=function(){if(!this._isSubscribed){var e=this._directive;if(e){this._ensureNgModelProp();var t=this._ngModelProp=e[s.wjModelPropAttr];if(t){var i=this._behavior.getPropChangeEvent(t);i&&e[i].addHandler(this._dirValChgEh,this)}e instanceof n.Control&&e.lostFocus.addHandler(this._dirLostFocusEh,this),this._isSubscribed=!0}}},e.prototype._ensureNgModelProp=function(){!this._ngModelProp&&this._directive&&(this._ngModelProp=this._directive[s.wjModelPropAttr])},e.prototype._ensureInitEhUnsubscribed=function(){this._dirInitEh&&(this._dirInitEh.unsubscribe(),this._dirInitEh=null)},e.prototype._isFirstChange=function(){return this._writeQnt<2},e.prototype._dirValChgEh=function(e,t){if(this._onChange&&this._directive&&this._ngModelProp){var n=this._directive[this._ngModelProp];a.equals(this._modelValue,n)||(this._modelValue=n,this._onChange(n))}},e.prototype._dirLostFocusEh=function(e,t){this._onTouched&&this._onTouched()},e}();t.WjValueAccessor=p,t.WjValueAccessorFactory=function(e){return new p(e)};var h=function(){function e(){}return e.decorators=[{type:i.NgModule,args:[{}]}],e.ctorParameters=function(){return[]},e}();t.WjDirectiveBaseModule=h});