UNPKG

ng2-completer

Version:

angular autocomplete/typeahead component

5 lines 65.5 kB
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("@angular/core"),require("rxjs/operators"),require("@angular/common/http"),require("@angular/forms"),require("@angular/common")):"function"==typeof define&&define.amd?define(["exports","@angular/core","rxjs/operators","@angular/common/http","@angular/forms","@angular/common"],factory):factory(((global=global||self).ng2=global.ng2||{},global.ng2.completer={}),global.ng.core,global.Rx.Observable.prototype,global.ng.common.http,global.ng.forms,global.ng.common)}(this,function(exports,core,operators,http,forms,common){"use strict";var extendStatics=function(d,b){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])})(d,b)};function __extends(d,b){function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}function __decorate(decorators,target,key,desc){var d,c=arguments.length,r=c<3?target:null===desc?desc=Object.getOwnPropertyDescriptor(target,key):desc;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;0<=i;i--)(d=decorators[i])&&(r=(c<3?d(r):3<c?d(target,key,r):d(target,key))||r);return 3<c&&r&&Object.defineProperty(target,key,r),r}function __param(paramIndex,decorator){return function(target,key){decorator(target,key,paramIndex)}}function __metadata(metadataKey,metadataValue){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(metadataKey,metadataValue)}function isFunction(x){return"function"==typeof x}var _enable_super_gross_mode_that_will_cause_bad_things=!1,config={Promise:void 0,set useDeprecatedSynchronousErrorHandling(value){value&&(new Error).stack;_enable_super_gross_mode_that_will_cause_bad_things=value},get useDeprecatedSynchronousErrorHandling(){return _enable_super_gross_mode_that_will_cause_bad_things}};function hostReportError(err){setTimeout(function(){throw err},0)}var empty={closed:!0,next:function(value){},error:function(err){if(config.useDeprecatedSynchronousErrorHandling)throw err;hostReportError(err)},complete:function(){}},isArray=function(){return Array.isArray||function(x){return x&&"number"==typeof x.length}}();var UnsubscriptionError=function(){function UnsubscriptionErrorImpl(errors){return Error.call(this),this.message=errors?errors.length+" errors occurred during unsubscription:\n"+errors.map(function(err,i){return i+1+") "+err.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=errors,this}return UnsubscriptionErrorImpl.prototype=Object.create(Error.prototype),UnsubscriptionErrorImpl}(),Subscription=function(){function Subscription(unsubscribe){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,unsubscribe&&(this._unsubscribe=unsubscribe)}var empty;return Subscription.prototype.unsubscribe=function(){var errors;if(!this.closed){var x,_parentOrParents=this._parentOrParents,_unsubscribe=this._unsubscribe,_subscriptions=this._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,_parentOrParents instanceof Subscription)_parentOrParents.remove(this);else if(null!==_parentOrParents)for(var index=0;index<_parentOrParents.length;++index){_parentOrParents[index].remove(this)}if(isFunction(_unsubscribe))try{_unsubscribe.call(this)}catch(e){errors=e instanceof UnsubscriptionError?flattenUnsubscriptionErrors(e.errors):[e]}if(isArray(_subscriptions)){index=-1;for(var len=_subscriptions.length;++index<len;){var sub=_subscriptions[index];if(null!==(x=sub)&&"object"==typeof x)try{sub.unsubscribe()}catch(e){errors=errors||[],e instanceof UnsubscriptionError?errors=errors.concat(flattenUnsubscriptionErrors(e.errors)):errors.push(e)}}}if(errors)throw new UnsubscriptionError(errors)}},Subscription.prototype.add=function(teardown){var subscription=teardown;if(!teardown)return Subscription.EMPTY;switch(typeof teardown){case"function":subscription=new Subscription(teardown);case"object":if(subscription===this||subscription.closed||"function"!=typeof subscription.unsubscribe)return subscription;if(this.closed)return subscription.unsubscribe(),subscription;if(!(subscription instanceof Subscription)){var tmp=subscription;(subscription=new Subscription)._subscriptions=[tmp]}break;default:throw new Error("unrecognized teardown "+teardown+" added to Subscription.")}var _parentOrParents=subscription._parentOrParents;if(null===_parentOrParents)subscription._parentOrParents=this;else if(_parentOrParents instanceof Subscription){if(_parentOrParents===this)return subscription;subscription._parentOrParents=[_parentOrParents,this]}else{if(-1!==_parentOrParents.indexOf(this))return subscription;_parentOrParents.push(this)}var subscriptions=this._subscriptions;return null===subscriptions?this._subscriptions=[subscription]:subscriptions.push(subscription),subscription},Subscription.prototype.remove=function(subscription){var subscriptions=this._subscriptions;if(subscriptions){var subscriptionIndex=subscriptions.indexOf(subscription);-1!==subscriptionIndex&&subscriptions.splice(subscriptionIndex,1)}},Subscription.EMPTY=((empty=new Subscription).closed=!0,empty),Subscription}();function flattenUnsubscriptionErrors(errors){return errors.reduce(function(errs,err){return errs.concat(err instanceof UnsubscriptionError?err.errors:err)},[])}var rxSubscriber=function(){return"function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random()}(),Subscriber=function(_super){function Subscriber(destinationOrNext,error,complete){var _this=_super.call(this)||this;switch(_this.syncErrorValue=null,_this.syncErrorThrown=!1,_this.syncErrorThrowable=!1,_this.isStopped=!1,arguments.length){case 0:_this.destination=empty;break;case 1:if(!destinationOrNext){_this.destination=empty;break}if("object"==typeof destinationOrNext){destinationOrNext instanceof Subscriber?(_this.syncErrorThrowable=destinationOrNext.syncErrorThrowable,(_this.destination=destinationOrNext).add(_this)):(_this.syncErrorThrowable=!0,_this.destination=new SafeSubscriber(_this,destinationOrNext));break}default:_this.syncErrorThrowable=!0,_this.destination=new SafeSubscriber(_this,destinationOrNext,error,complete)}return _this}return __extends(Subscriber,_super),Subscriber.prototype[rxSubscriber]=function(){return this},Subscriber.create=function(next,error,complete){var subscriber=new Subscriber(next,error,complete);return subscriber.syncErrorThrowable=!1,subscriber},Subscriber.prototype.next=function(value){this.isStopped||this._next(value)},Subscriber.prototype.error=function(err){this.isStopped||(this.isStopped=!0,this._error(err))},Subscriber.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},Subscriber.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,_super.prototype.unsubscribe.call(this))},Subscriber.prototype._next=function(value){this.destination.next(value)},Subscriber.prototype._error=function(err){this.destination.error(err),this.unsubscribe()},Subscriber.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},Subscriber.prototype._unsubscribeAndRecycle=function(){var _parentOrParents=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=_parentOrParents,this},Subscriber}(Subscription),SafeSubscriber=function(_super){function SafeSubscriber(_parentSubscriber,observerOrNext,error,complete){var next,_this=_super.call(this)||this;_this._parentSubscriber=_parentSubscriber;var context=_this;return isFunction(observerOrNext)?next=observerOrNext:observerOrNext&&(next=observerOrNext.next,error=observerOrNext.error,complete=observerOrNext.complete,observerOrNext!==empty&&(isFunction((context=Object.create(observerOrNext)).unsubscribe)&&_this.add(context.unsubscribe.bind(context)),context.unsubscribe=_this.unsubscribe.bind(_this))),_this._context=context,_this._next=next,_this._error=error,_this._complete=complete,_this}return __extends(SafeSubscriber,_super),SafeSubscriber.prototype.next=function(value){if(!this.isStopped&&this._next){var _parentSubscriber=this._parentSubscriber;config.useDeprecatedSynchronousErrorHandling&&_parentSubscriber.syncErrorThrowable?this.__tryOrSetError(_parentSubscriber,this._next,value)&&this.unsubscribe():this.__tryOrUnsub(this._next,value)}},SafeSubscriber.prototype.error=function(err){if(!this.isStopped){var _parentSubscriber=this._parentSubscriber,useDeprecatedSynchronousErrorHandling=config.useDeprecatedSynchronousErrorHandling;if(this._error)useDeprecatedSynchronousErrorHandling&&_parentSubscriber.syncErrorThrowable?this.__tryOrSetError(_parentSubscriber,this._error,err):this.__tryOrUnsub(this._error,err),this.unsubscribe();else if(_parentSubscriber.syncErrorThrowable)useDeprecatedSynchronousErrorHandling?(_parentSubscriber.syncErrorValue=err,_parentSubscriber.syncErrorThrown=!0):hostReportError(err),this.unsubscribe();else{if(this.unsubscribe(),useDeprecatedSynchronousErrorHandling)throw err;hostReportError(err)}}},SafeSubscriber.prototype.complete=function(){var _this=this;if(!this.isStopped){var _parentSubscriber=this._parentSubscriber;if(this._complete){var wrappedComplete=function(){return _this._complete.call(_this._context)};config.useDeprecatedSynchronousErrorHandling&&_parentSubscriber.syncErrorThrowable?this.__tryOrSetError(_parentSubscriber,wrappedComplete):this.__tryOrUnsub(wrappedComplete),this.unsubscribe()}else this.unsubscribe()}},SafeSubscriber.prototype.__tryOrUnsub=function(fn,value){try{fn.call(this._context,value)}catch(err){if(this.unsubscribe(),config.useDeprecatedSynchronousErrorHandling)throw err;hostReportError(err)}},SafeSubscriber.prototype.__tryOrSetError=function(parent,fn,value){if(!config.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{fn.call(this._context,value)}catch(err){return config.useDeprecatedSynchronousErrorHandling?(parent.syncErrorValue=err,parent.syncErrorThrown=!0):(hostReportError(err),!0)}return!1},SafeSubscriber.prototype._unsubscribe=function(){var _parentSubscriber=this._parentSubscriber;this._context=null,this._parentSubscriber=null,_parentSubscriber.unsubscribe()},SafeSubscriber}(Subscriber);var observable=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}();function identity(x){return x}var Observable=function(){function Observable(subscribe){this._isScalar=!1,subscribe&&(this._subscribe=subscribe)}return Observable.prototype.lift=function(operator){var observable=new Observable;return observable.source=this,observable.operator=operator,observable},Observable.prototype.subscribe=function(observerOrNext,error,complete){var operator=this.operator,sink=function(nextOrObserver,error,complete){if(nextOrObserver){if(nextOrObserver instanceof Subscriber)return nextOrObserver;if(nextOrObserver[rxSubscriber])return nextOrObserver[rxSubscriber]()}return nextOrObserver||error||complete?new Subscriber(nextOrObserver,error,complete):new Subscriber(empty)}(observerOrNext,error,complete);if(operator?sink.add(operator.call(sink,this.source)):sink.add(this.source||config.useDeprecatedSynchronousErrorHandling&&!sink.syncErrorThrowable?this._subscribe(sink):this._trySubscribe(sink)),config.useDeprecatedSynchronousErrorHandling&&sink.syncErrorThrowable&&(sink.syncErrorThrowable=!1,sink.syncErrorThrown))throw sink.syncErrorValue;return sink},Observable.prototype._trySubscribe=function(sink){try{return this._subscribe(sink)}catch(err){config.useDeprecatedSynchronousErrorHandling&&(sink.syncErrorThrown=!0,sink.syncErrorValue=err),!function(observer){for(;observer;){var closed_1=observer.closed,destination=observer.destination,isStopped=observer.isStopped;if(closed_1||isStopped)return;observer=destination&&destination instanceof Subscriber?destination:null}return 1}(sink)?console.warn(err):sink.error(err)}},Observable.prototype.forEach=function(next,promiseCtor){var _this=this;return new(promiseCtor=getPromiseCtor(promiseCtor))(function(resolve,reject){var subscription;subscription=_this.subscribe(function(value){try{next(value)}catch(err){reject(err),subscription&&subscription.unsubscribe()}},reject,resolve)})},Observable.prototype._subscribe=function(subscriber){var source=this.source;return source&&source.subscribe(subscriber)},Observable.prototype[observable]=function(){return this},Observable.prototype.pipe=function(){for(var fns,operations=[],_i=0;_i<arguments.length;_i++)operations[_i]=arguments[_i];return 0===operations.length?this:(0===(fns=operations).length?identity:1===fns.length?fns[0]:function(input){return fns.reduce(function(prev,fn){return fn(prev)},input)})(this)},Observable.prototype.toPromise=function(promiseCtor){var _this=this;return new(promiseCtor=getPromiseCtor(promiseCtor))(function(resolve,reject){var value;_this.subscribe(function(x){return value=x},function(err){return reject(err)},function(){return resolve(value)})})},Observable.create=function(subscribe){return new Observable(subscribe)},Observable}();function getPromiseCtor(promiseCtor){if(!(promiseCtor=promiseCtor||Promise))throw new Error("no Promise impl found");return promiseCtor}var ObjectUnsubscribedError=function(){function ObjectUnsubscribedErrorImpl(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return ObjectUnsubscribedErrorImpl.prototype=Object.create(Error.prototype),ObjectUnsubscribedErrorImpl}(),SubjectSubscription=function(_super){function SubjectSubscription(subject,subscriber){var _this=_super.call(this)||this;return _this.subject=subject,_this.subscriber=subscriber,_this.closed=!1,_this}return __extends(SubjectSubscription,_super),SubjectSubscription.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var subject=this.subject,observers=subject.observers;if(this.subject=null,observers&&0!==observers.length&&!subject.isStopped&&!subject.closed){var subscriberIndex=observers.indexOf(this.subscriber);-1!==subscriberIndex&&observers.splice(subscriberIndex,1)}}},SubjectSubscription}(Subscription),SubjectSubscriber=function(_super){function SubjectSubscriber(destination){var _this=_super.call(this,destination)||this;return _this.destination=destination,_this}return __extends(SubjectSubscriber,_super),SubjectSubscriber}(Subscriber),Subject=function(_super){function Subject(){var _this=_super.call(this)||this;return _this.observers=[],_this.closed=!1,_this.isStopped=!1,_this.hasError=!1,_this.thrownError=null,_this}return __extends(Subject,_super),Subject.prototype[rxSubscriber]=function(){return new SubjectSubscriber(this)},Subject.prototype.lift=function(operator){var subject=new AnonymousSubject(this,this);return subject.operator=operator,subject},Subject.prototype.next=function(value){if(this.closed)throw new ObjectUnsubscribedError;if(!this.isStopped)for(var observers=this.observers,len=observers.length,copy=observers.slice(),i=0;i<len;i++)copy[i].next(value)},Subject.prototype.error=function(err){if(this.closed)throw new ObjectUnsubscribedError;this.hasError=!0,this.thrownError=err,this.isStopped=!0;for(var observers=this.observers,len=observers.length,copy=observers.slice(),i=0;i<len;i++)copy[i].error(err);this.observers.length=0},Subject.prototype.complete=function(){if(this.closed)throw new ObjectUnsubscribedError;this.isStopped=!0;for(var observers=this.observers,len=observers.length,copy=observers.slice(),i=0;i<len;i++)copy[i].complete();this.observers.length=0},Subject.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},Subject.prototype._trySubscribe=function(subscriber){if(this.closed)throw new ObjectUnsubscribedError;return _super.prototype._trySubscribe.call(this,subscriber)},Subject.prototype._subscribe=function(subscriber){if(this.closed)throw new ObjectUnsubscribedError;return this.hasError?(subscriber.error(this.thrownError),Subscription.EMPTY):this.isStopped?(subscriber.complete(),Subscription.EMPTY):(this.observers.push(subscriber),new SubjectSubscription(this,subscriber))},Subject.prototype.asObservable=function(){var observable=new Observable;return observable.source=this,observable},Subject.create=function(destination,source){return new AnonymousSubject(destination,source)},Subject}(Observable),AnonymousSubject=function(_super){function AnonymousSubject(destination,source){var _this=_super.call(this)||this;return _this.destination=destination,_this.source=source,_this}return __extends(AnonymousSubject,_super),AnonymousSubject.prototype.next=function(value){var destination=this.destination;destination&&destination.next&&destination.next(value)},AnonymousSubject.prototype.error=function(err){var destination=this.destination;destination&&destination.error&&this.destination.error(err)},AnonymousSubject.prototype.complete=function(){var destination=this.destination;destination&&destination.complete&&this.destination.complete()},AnonymousSubject.prototype._subscribe=function(subscriber){return this.source?this.source.subscribe(subscriber):Subscription.EMPTY},AnonymousSubject}(Subject),AsyncAction=function(_super){function AsyncAction(scheduler,work){var _this=_super.call(this,scheduler,work)||this;return _this.scheduler=scheduler,_this.work=work,_this.pending=!1,_this}return __extends(AsyncAction,_super),AsyncAction.prototype.schedule=function(state,delay){if(void 0===delay&&(delay=0),this.closed)return this;this.state=state;var id=this.id,scheduler=this.scheduler;return null!=id&&(this.id=this.recycleAsyncId(scheduler,id,delay)),this.pending=!0,this.delay=delay,this.id=this.id||this.requestAsyncId(scheduler,this.id,delay),this},AsyncAction.prototype.requestAsyncId=function(scheduler,id,delay){return void 0===delay&&(delay=0),setInterval(scheduler.flush.bind(scheduler,this),delay)},AsyncAction.prototype.recycleAsyncId=function(scheduler,id,delay){if(void 0===delay&&(delay=0),null!==delay&&this.delay===delay&&!1===this.pending)return id;clearInterval(id)},AsyncAction.prototype.execute=function(state,delay){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var error=this._execute(state,delay);if(error)return error;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},AsyncAction.prototype._execute=function(state,delay){var errored=!1,errorValue=void 0;try{this.work(state)}catch(e){errored=!0,errorValue=!!e&&e||new Error(e)}if(errored)return this.unsubscribe(),errorValue},AsyncAction.prototype._unsubscribe=function(){var id=this.id,scheduler=this.scheduler,actions=scheduler.actions,index=actions.indexOf(this);this.work=null,this.state=null,this.pending=!1,this.scheduler=null,-1!==index&&actions.splice(index,1),null!=id&&(this.id=this.recycleAsyncId(scheduler,id,null)),this.delay=null},AsyncAction}(function(_super){function Action(scheduler,work){return _super.call(this)||this}return __extends(Action,_super),Action.prototype.schedule=function(state,delay){return this},Action}(Subscription)),Scheduler=function(){function Scheduler(SchedulerAction,now){void 0===now&&(now=Scheduler.now),this.SchedulerAction=SchedulerAction,this.now=now}return Scheduler.prototype.schedule=function(work,delay,state){return void 0===delay&&(delay=0),new this.SchedulerAction(this,work).schedule(state,delay)},Scheduler.now=function(){return Date.now()},Scheduler}();function isScheduler(value){return value&&"function"==typeof value.schedule}var async=new(function(_super){function AsyncScheduler(SchedulerAction,now){void 0===now&&(now=Scheduler.now);var _this=_super.call(this,SchedulerAction,function(){return AsyncScheduler.delegate&&AsyncScheduler.delegate!==_this?AsyncScheduler.delegate.now():now()})||this;return _this.actions=[],_this.active=!1,_this.scheduled=void 0,_this}return __extends(AsyncScheduler,_super),AsyncScheduler.prototype.schedule=function(work,delay,state){return void 0===delay&&(delay=0),AsyncScheduler.delegate&&AsyncScheduler.delegate!==this?AsyncScheduler.delegate.schedule(work,delay,state):_super.prototype.schedule.call(this,work,delay,state)},AsyncScheduler.prototype.flush=function(action){var actions=this.actions;if(this.active)actions.push(action);else{var error;this.active=!0;do{if(error=action.execute(action.state,action.delay))break}while(action=actions.shift());if(this.active=!1,error){for(;action=actions.shift();)action.unsubscribe();throw error}}},AsyncScheduler}(Scheduler))(AsyncAction);function isNumeric(val){return!isArray(val)&&0<=val-parseFloat(val)+1}function timer(dueTime,periodOrScheduler,scheduler){void 0===dueTime&&(dueTime=0);var period=-1;return isNumeric(periodOrScheduler)?period=Number(periodOrScheduler)<1?1:Number(periodOrScheduler):isScheduler(periodOrScheduler)&&(scheduler=periodOrScheduler),isScheduler(scheduler)||(scheduler=async),new Observable(function(subscriber){var due=isNumeric(dueTime)?dueTime:dueTime-scheduler.now();return scheduler.schedule(dispatch,due,{index:0,period:period,subscriber:subscriber})})}function dispatch(state){var index=state.index,period=state.period,subscriber=state.subscriber;if(subscriber.next(index),!subscriber.closed){if(-1===period)return subscriber.complete();state.index=index+1,this.schedule(state,period)}} /** * @license ng2-completer * MIT license */function isNil(value){return null==value}function noop(){}var CompleterBaseData=function(_super){function CompleterBaseData(){var _this=_super.call(this)||this;return _this._searchFields=null,_this._titleField=null,_this._descriptionField=void 0,_this._imageField=void 0,_this}return __extends(CompleterBaseData,_super),CompleterBaseData.prototype.cancel=function(){},CompleterBaseData.prototype.searchFields=function(searchFields){return this._searchFields=searchFields,this},CompleterBaseData.prototype.titleField=function(titleField){return this._titleField=titleField,this},CompleterBaseData.prototype.descriptionField=function(descriptionField){return this._descriptionField=descriptionField,this},CompleterBaseData.prototype.imageField=function(imageField){return this._imageField=imageField,this},CompleterBaseData.prototype.convertToItem=function(data){var formattedText,image=null,formattedDesc=null;return"string"!=typeof(formattedText=this._titleField?this.extractTitle(data):data)&&(formattedText=JSON.stringify(formattedText)),this._descriptionField&&(formattedDesc=this.extractValue(data,this._descriptionField)),this._imageField&&(image=this.extractValue(data,this._imageField)),isNil(formattedText)?null:{description:formattedDesc,image:image,originalObject:data,title:formattedText}},CompleterBaseData.prototype.extractMatches=function(data,term){var _this=this,searchFields=this._searchFields?this._searchFields.split(","):null;return null!==this._searchFields&&void 0!==this._searchFields&&""!==term?data.filter(function(item){return(searchFields?_this.extractBySearchFields(searchFields,item):[item]).some(function(value){return 0<=value.toString().toLowerCase().indexOf(term.toString().toLowerCase())})}):data},CompleterBaseData.prototype.extractTitle=function(item){var _this=this;return this._titleField?this._titleField.split(",").map(function(field){return _this.extractValue(item,field)}).reduce(function(acc,titlePart){return acc?acc+" "+titlePart:titlePart}):""},CompleterBaseData.prototype.extractValue=function(obj,key){var result;if(key){result=obj;for(var _i=0,keys_1=key.split(".");_i<keys_1.length;_i++)key=keys_1[_i],result=result&&result[key]}else result=obj;return result},CompleterBaseData.prototype.processResults=function(matches){var i,results=[];if(matches&&0<matches.length)for(i=0;i<matches.length;i++){var item=this.convertToItem(matches[i]);item&&results.push(item)}return results},CompleterBaseData.prototype.extractBySearchFields=function(searchFields,item){var _this=this;return searchFields.map(function(searchField){return _this.extractValue(item,searchField)}).filter(function(value){return!!value})},CompleterBaseData}(Subject),LocalData=function(_super){function LocalData(){var _this=_super.call(this)||this;return _this.dataSourceChange=new core.EventEmitter,_this._data=[],_this.savedTerm=null,_this}return __extends(LocalData,_super),LocalData.prototype.data=function(data){var _this=this;data instanceof Observable?data.pipe(operators.catchError(function(){return[]})).subscribe(function(res){_this._data=res,_this.savedTerm&&_this.search(_this.savedTerm),_this.dataSourceChange.emit()}):this._data=data;return this.dataSourceChange.emit(),this},LocalData.prototype.search=function(term){if(this._data){this.savedTerm=null;var matches=this.extractMatches(this._data,term);this.next(this.processResults(matches))}else this.savedTerm=term},LocalData.prototype.convertToItem=function(data){return _super.prototype.convertToItem.call(this,data)},LocalData}(CompleterBaseData),RemoteData=function(_super){function RemoteData(http){var _this=_super.call(this)||this;return _this.http=http,_this.dataSourceChange=new core.EventEmitter,_this._remoteUrl=null,_this.remoteSearch=null,_this._urlFormater=null,_this._dataField=null,_this}return __extends(RemoteData,_super),RemoteData.prototype.remoteUrl=function(remoteUrl){return this._remoteUrl=remoteUrl,this.dataSourceChange.emit(),this},RemoteData.prototype.urlFormater=function(urlFormater){this._urlFormater=urlFormater},RemoteData.prototype.dataField=function(dataField){this._dataField=dataField},RemoteData.prototype.requestOptions=function(requestOptions){this._requestOptions=requestOptions},RemoteData.prototype.search=function(term){var _this=this;this.cancel();var url="";url=this._urlFormater?this._urlFormater(term):this._remoteUrl+encodeURIComponent(term),this.remoteSearch=this.http.get(url,Object.assign({},this._requestOptions)).pipe(operators.map(function(data){var matches=_this.extractValue(data,_this._dataField);return _this.extractMatches(matches,term)}),operators.catchError(function(){return[]})).subscribe(function(matches){var results=_this.processResults(matches);_this.next(results)})},RemoteData.prototype.cancel=function(){this.remoteSearch&&this.remoteSearch.unsubscribe()},RemoteData.prototype.convertToItem=function(data){return _super.prototype.convertToItem.call(this,data)},RemoteData}(CompleterBaseData),LocalDataFactory=function(){function LocalDataFactory(){}return LocalDataFactory.prototype.create=function(){return new LocalData},LocalDataFactory=__decorate([core.Injectable()],LocalDataFactory)}(),RemoteDataFactory=function(){function RemoteDataFactory(http){this.http=http}return RemoteDataFactory.prototype.create=function(){return new RemoteData(this.http)},RemoteDataFactory=__decorate([core.Injectable(),__metadata("design:paramtypes",[http.HttpClient])],RemoteDataFactory)}(),CompleterService=function(){function CompleterService(localDataFactory,remoteDataFactory){this.localDataFactory=localDataFactory,this.remoteDataFactory=remoteDataFactory}return CompleterService.prototype.local=function(data,searchFields,titleField){return void 0===searchFields&&(searchFields=""),void 0===titleField&&(titleField=""),this.localDataFactory.create().data(data).searchFields(searchFields).titleField(titleField)},CompleterService.prototype.remote=function(url,searchFields,titleField){return void 0===searchFields&&(searchFields=""),void 0===titleField&&(titleField=""),this.remoteDataFactory.create().remoteUrl(url).searchFields(searchFields).titleField(titleField)},CompleterService=__decorate([core.Injectable(),__metadata("design:paramtypes",[LocalDataFactory,RemoteDataFactory])],CompleterService)}(),CtrCompleter=function(){function CtrCompleter(){this.selected=new core.EventEmitter,this.highlighted=new core.EventEmitter,this.opened=new core.EventEmitter,this.dataSourceChange=new core.EventEmitter,this.list=null,this.dropdown=null,this._hasHighlighted=!1,this._hasSelected=!1,this._cancelBlur=!1,this._isOpen=!1,this._autoHighlightIndex=null}return CtrCompleter.prototype.registerList=function(list){this.list=list},CtrCompleter.prototype.registerDropdown=function(dropdown){this.dropdown=dropdown},CtrCompleter.prototype.onHighlighted=function(item){this.highlighted.emit(item),this._hasHighlighted=!!item},CtrCompleter.prototype.onSelected=function(item,clearList){void 0===clearList&&(clearList=!0),this.selected.emit(item),item&&(this._hasSelected=!0),clearList&&this.clear()},CtrCompleter.prototype.onDataSourceChange=function(){this.hasSelected&&(this.selected.emit(null),this._hasSelected=!1),this.dataSourceChange.emit()},CtrCompleter.prototype.search=function(term){this._hasSelected&&(this.selected.emit(null),this._hasSelected=!1),this.list&&this.list.search(term)},CtrCompleter.prototype.clear=function(){this._hasHighlighted=!1,this.isOpen=!1,this.dropdown&&this.dropdown.clear(),this.list&&this.list.clear()},CtrCompleter.prototype.selectCurrent=function(){this.dropdown&&this.dropdown.selectCurrent()},CtrCompleter.prototype.nextRow=function(){this.dropdown&&this.dropdown.nextRow()},CtrCompleter.prototype.prevRow=function(){this.dropdown&&this.dropdown.prevRow()},CtrCompleter.prototype.hasHighlighted=function(){return this._hasHighlighted},CtrCompleter.prototype.cancelBlur=function(cancel){this._cancelBlur=cancel},CtrCompleter.prototype.isCancelBlur=function(){return this._cancelBlur},CtrCompleter.prototype.open=function(){!this._isOpen&&this.list&&(this.isOpen=!0,this.list.open())},Object.defineProperty(CtrCompleter.prototype,"isOpen",{get:function(){return this._isOpen},set:function(open){this._isOpen=open,this.opened.emit(this._isOpen),this.list&&this.list.isOpen(open)},enumerable:!0,configurable:!0}),Object.defineProperty(CtrCompleter.prototype,"autoHighlightIndex",{get:function(){return this._autoHighlightIndex},set:function(index){this._autoHighlightIndex=index,this.dropdown&&this.dropdown.highlightRow(this._autoHighlightIndex)},enumerable:!0,configurable:!0}),Object.defineProperty(CtrCompleter.prototype,"hasSelected",{get:function(){return this._hasSelected},enumerable:!0,configurable:!0}),__decorate([core.Output(),__metadata("design:type",Object)],CtrCompleter.prototype,"selected",void 0),__decorate([core.Output(),__metadata("design:type",Object)],CtrCompleter.prototype,"highlighted",void 0),__decorate([core.Output(),__metadata("design:type",Object)],CtrCompleter.prototype,"opened",void 0),__decorate([core.Output(),__metadata("design:type",Object)],CtrCompleter.prototype,"dataSourceChange",void 0),CtrCompleter=__decorate([core.Directive({selector:"[ctrCompleter]"})],CtrCompleter)}(),CtrRowItem=function(row,index){this.row=row,this.index=index},CtrDropdown=function(){function CtrDropdown(completer,el,zone){this.completer=completer,this.el=el,this.zone=zone,this.rows=[],this.isScrollOn=!1,this._rowMouseDown=!1,this.completer.registerDropdown(this)}return CtrDropdown.prototype.ngOnDestroy=function(){this.completer.registerDropdown(null)},CtrDropdown.prototype.ngAfterViewInit=function(){var _this=this,css=getComputedStyle(this.el.nativeElement),autoHighlightIndex=this.completer.autoHighlightIndex;this.isScrollOn=!!css.maxHeight&&"auto"===css.overflowY,autoHighlightIndex&&this.zone.run(function(){_this.highlightRow(autoHighlightIndex)})},CtrDropdown.prototype.onMouseDown=function(event){var _this=this;this._rowMouseDown?this._rowMouseDown=!1:(this.completer.cancelBlur(!0),this.zone.run(function(){_this.completer.cancelBlur(!1)}))},CtrDropdown.prototype.registerRow=function(row){var arrIndex=this.rows.findIndex(function(_row){return _row.index===row.index});0<=arrIndex?this.rows[arrIndex]=row:this.rows.push(row)},CtrDropdown.prototype.unregisterRow=function(rowIndex){var arrIndex=this.rows.findIndex(function(_row){return _row.index===rowIndex});this.rows.splice(arrIndex,1),this.currHighlighted&&rowIndex===this.currHighlighted.index&&this.highlightRow(null)},CtrDropdown.prototype.highlightRow=function(index){var highlighted=this.rows.find(function(row){return row.index===index});if(isNil(index)||index<0)return this.currHighlighted&&this.currHighlighted.row.setHighlighted(!1),this.currHighlighted=void 0,void this.completer.onHighlighted(null);if(highlighted&&(this.currHighlighted&&this.currHighlighted.row.setHighlighted(!1),this.currHighlighted=highlighted,this.currHighlighted.row.setHighlighted(!0),this.completer.onHighlighted(this.currHighlighted.row.getDataItem()),this.isScrollOn&&this.currHighlighted)){var rowTop=this.dropdownRowTop();if(!rowTop)return;if(rowTop<0)this.dropdownScrollTopTo(rowTop-1);else{var row=this.currHighlighted.row.getNativeElement();this.dropdownHeight()<row.getBoundingClientRect().bottom&&(this.dropdownScrollTopTo(this.dropdownRowOffsetHeight(row)),this.el.nativeElement.getBoundingClientRect().bottom-this.dropdownRowOffsetHeight(row)<row.getBoundingClientRect().top&&this.dropdownScrollTopTo(row.getBoundingClientRect().top-(this.el.nativeElement.getBoundingClientRect().top+parseInt(getComputedStyle(this.el.nativeElement).paddingTop,10))))}}},CtrDropdown.prototype.clear=function(){this.rows=[]},CtrDropdown.prototype.onSelected=function(item){this.completer.onSelected(item)},CtrDropdown.prototype.rowMouseDown=function(){this._rowMouseDown=!0},CtrDropdown.prototype.selectCurrent=function(){this.currHighlighted&&this.currHighlighted.row?this.onSelected(this.currHighlighted.row.getDataItem()):0<this.rows.length&&this.onSelected(this.rows[0].row.getDataItem())},CtrDropdown.prototype.nextRow=function(){var nextRowIndex=0;this.currHighlighted&&(nextRowIndex=this.currHighlighted.index+1),this.highlightRow(nextRowIndex)},CtrDropdown.prototype.prevRow=function(){var nextRowIndex=-1;this.currHighlighted&&(nextRowIndex=this.currHighlighted.index-1),this.highlightRow(nextRowIndex)},CtrDropdown.prototype.dropdownScrollTopTo=function(offset){this.el.nativeElement.scrollTop=this.el.nativeElement.scrollTop+offset},CtrDropdown.prototype.dropdownRowTop=function(){if(this.currHighlighted)return this.currHighlighted.row.getNativeElement().getBoundingClientRect().top-(this.el.nativeElement.getBoundingClientRect().top+parseInt(getComputedStyle(this.el.nativeElement).paddingTop,10))},CtrDropdown.prototype.dropdownHeight=function(){return this.el.nativeElement.getBoundingClientRect().top+parseInt(getComputedStyle(this.el.nativeElement).maxHeight,10)},CtrDropdown.prototype.dropdownRowOffsetHeight=function(row){var css=getComputedStyle(row.parentElement);return row.parentElement.offsetHeight+parseInt(css.marginTop,10)+parseInt(css.marginBottom,10)},__decorate([core.HostListener("mousedown",["$event"]),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",void 0)],CtrDropdown.prototype,"onMouseDown",null),CtrDropdown=__decorate([core.Directive({selector:"[ctrDropdown]"}),__param(0,core.Host()),__metadata("design:paramtypes",[CtrCompleter,core.ElementRef,core.NgZone])],CtrDropdown)}(),CtrInput=function(){function CtrInput(completer,ngModel,el){var _this=this;this.completer=completer,this.ngModel=ngModel,this.el=el,this.clearSelected=!1,this.clearUnselected=!1,this.overrideSuggested=!1,this.fillHighlighted=!0,this.openOnFocus=!1,this.openOnClick=!1,this.selectOnClick=!1,this.selectOnFocus=!1,this.ngModelChange=new core.EventEmitter,this._searchStr="",this._displayStr="",this.blurTimer=null,this.completer.selected.subscribe(function(item){item&&(_this.clearSelected?_this.searchStr="":_this.searchStr=item.title,_this.ngModelChange.emit(_this.searchStr))}),this.completer.highlighted.subscribe(function(item){_this.fillHighlighted&&(item?(_this._displayStr=item.title,_this.ngModelChange.emit(item.title)):(_this._displayStr=_this.searchStr,_this.ngModelChange.emit(_this.searchStr)))}),this.completer.dataSourceChange.subscribe(function(){_this.completer.search(_this.searchStr)}),this.ngModel.valueChanges&&this.ngModel.valueChanges.subscribe(function(value){isNil(value)||_this._displayStr===value||(_this.searchStr!==value&&_this.completer.search(value),_this.searchStr=value)})}return CtrInput.prototype.keyupHandler=function(event){37!==event.keyCode&&39!==event.keyCode&&9!==event.keyCode&&(38===event.keyCode||13===event.keyCode?event.preventDefault():40===event.keyCode?(event.preventDefault(),this.completer.search(this.searchStr)):27===event.keyCode&&this.completer.isOpen&&(this.restoreSearchValue(),this.completer.clear(),event.stopPropagation(),event.preventDefault()))},CtrInput.prototype.pasteHandler=function(event){this.completer.open()},CtrInput.prototype.keydownHandler=function(event){var keyCode=event.keyCode||event.which;13===keyCode?(this.completer.hasHighlighted()&&event.preventDefault(),this.handleSelection()):40===keyCode?(event.preventDefault(),this.completer.open(),this.completer.nextRow()):38===keyCode?(event.preventDefault(),this.completer.prevRow()):9===keyCode?this.handleSelection():8===keyCode?this.completer.open():27===keyCode?(event.preventDefault(),this.completer.isOpen&&event.stopPropagation()):0===keyCode||16===keyCode||20===keyCode||!(keyCode<=112||123<=keyCode)||event.ctrlKey||event.metaKey||event.altKey||this.completer.open()},CtrInput.prototype.onBlur=function(event){var _this=this;this.completer.isCancelBlur()?setTimeout(function(){_this.el.nativeElement.focus()},0):this.completer.isOpen&&(this.blurTimer=timer(200).pipe(operators.take(1)).subscribe(function(){return _this.doBlur()}))},CtrInput.prototype.onfocus=function(){this.blurTimer&&(this.blurTimer.unsubscribe(),this.blurTimer=null),this.selectOnFocus&&this.el.nativeElement.select(),this.openOnFocus&&this.completer.open()},CtrInput.prototype.onClick=function(event){this.selectOnClick&&this.el.nativeElement.select(),this.openOnClick&&(this.completer.isOpen?this.completer.clear():this.completer.open())},Object.defineProperty(CtrInput.prototype,"searchStr",{get:function(){return this._searchStr},set:function(term){this._searchStr=term,this._displayStr=term},enumerable:!0,configurable:!0}),CtrInput.prototype.handleSelection=function(){this.completer.hasHighlighted()?(this._searchStr="",this.completer.selectCurrent()):this.overrideSuggested?this.completer.onSelected({title:this.searchStr,originalObject:null}):(this.clearUnselected&&!this.completer.hasSelected&&(this.searchStr="",this.ngModelChange.emit(this.searchStr)),this.completer.clear())},CtrInput.prototype.restoreSearchValue=function(){this.fillHighlighted&&this._displayStr!==this.searchStr&&(this._displayStr=this.searchStr,this.ngModelChange.emit(this.searchStr))},CtrInput.prototype.doBlur=function(){this.blurTimer&&(this.blurTimer.unsubscribe(),this.blurTimer=null),this.overrideSuggested?this.completer.onSelected({title:this.searchStr,originalObject:null}):this.clearUnselected&&!this.completer.hasSelected?(this.searchStr="",this.ngModelChange.emit(this.searchStr)):this.restoreSearchValue(),this.completer.clear()},__decorate([core.Input("clearSelected"),__metadata("design:type",Object)],CtrInput.prototype,"clearSelected",void 0),__decorate([core.Input("clearUnselected"),__metadata("design:type",Object)],CtrInput.prototype,"clearUnselected",void 0),__decorate([core.Input("overrideSuggested"),__metadata("design:type",Object)],CtrInput.prototype,"overrideSuggested",void 0),__decorate([core.Input("fillHighlighted"),__metadata("design:type",Object)],CtrInput.prototype,"fillHighlighted",void 0),__decorate([core.Input("openOnFocus"),__metadata("design:type",Object)],CtrInput.prototype,"openOnFocus",void 0),__decorate([core.Input("openOnClick"),__metadata("design:type",Object)],CtrInput.prototype,"openOnClick",void 0),__decorate([core.Input("selectOnClick"),__metadata("design:type",Object)],CtrInput.prototype,"selectOnClick",void 0),__decorate([core.Input("selectOnFocus"),__metadata("design:type",Object)],CtrInput.prototype,"selectOnFocus",void 0),__decorate([core.Output(),__metadata("design:type",core.EventEmitter)],CtrInput.prototype,"ngModelChange",void 0),__decorate([core.HostListener("keyup",["$event"]),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",void 0)],CtrInput.prototype,"keyupHandler",null),__decorate([core.HostListener("paste",["$event"]),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",void 0)],CtrInput.prototype,"pasteHandler",null),__decorate([core.HostListener("keydown",["$event"]),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",void 0)],CtrInput.prototype,"keydownHandler",null),__decorate([core.HostListener("blur",["$event"]),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",void 0)],CtrInput.prototype,"onBlur",null),__decorate([core.HostListener("focus",[]),__metadata("design:type",Function),__metadata("design:paramtypes",[]),__metadata("design:returntype",void 0)],CtrInput.prototype,"onfocus",null),__decorate([core.HostListener("click",["$event"]),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",void 0)],CtrInput.prototype,"onClick",null),CtrInput=__decorate([core.Directive({selector:"[ctrInput]"}),__param(0,core.Host()),__metadata("design:paramtypes",[CtrCompleter,forms.NgModel,core.ElementRef])],CtrInput)}(),CtrListContext=function(results,searching,searchInitialized,isOpen){this.results=results,this.searching=searching,this.searchInitialized=searchInitialized,this.isOpen=isOpen},CtrList=function(){function CtrList(completer,templateRef,viewContainer,cd,zone){this.completer=completer,this.templateRef=templateRef,this.viewContainer=viewContainer,this.cd=cd,this.zone=zone,this.ctrListMinSearchLength=3,this.ctrListPause=10,this.ctrListAutoMatch=!1,this.ctrListAutoHighlight=!1,this.ctrListDisplaySearching=!0,this._dataService=null,this.term=null,this.searchTimer=null,this.clearTimer=null,this.ctx=new CtrListContext([],!1,!1,!1),this._initialValue=null,this.viewRef=null}return CtrList.prototype.ngOnInit=function(){this.completer.registerList(this),this.viewRef=this.viewContainer.createEmbeddedView(this.templateRef,new CtrListContext([],!1,!1,!1))},Object.defineProperty(CtrList.prototype,"dataService",{set:function(newService){this._dataService=newService,this.dataServiceSubscribe()},enumerable:!0,configurable:!0}),Object.defineProperty(CtrList.prototype,"initialValue",{set:function(value){var _this=this;this._dataService&&"function"==typeof this._dataService.convertToItem?this.zone.run(function(){var initialItem=_this._dataService&&_this._dataService.convertToItem(value);initialItem&&_this.completer.onSelected(initialItem,!1)}):this._dataService||(this._initialValue=value)},enumerable:!0,configurable:!0}),CtrList.prototype.search=function(term){var _this=this;!isNil(term)&&term.length>=this.ctrListMinSearchLength&&this.term!==term?(this.searchTimer&&(this.searchTimer.unsubscribe(),this.searchTimer=null),this.ctx.searching||(this.ctrListDisplaySearching&&(this.ctx.results=[]),this.ctx.searching=!0,this.ctx.searchInitialized=!0,this.refreshTemplate()),this.clearTimer&&this.clearTimer.unsubscribe(),this.searchTimer=timer(this.ctrListPause).pipe(operators.take(1)).subscribe(function(){_this.searchTimerComplete(term)})):!isNil(term)&&term.length<this.ctrListMinSearchLength&&(this.clear(),this.term="")},CtrList.prototype.clear=function(){var _this=this;this.searchTimer&&this.searchTimer.unsubscribe(),this.clearTimer=timer(50).pipe(operators.take(1)).subscribe(function(){_this._clear()})},CtrList.prototype.open=function(){this.ctx.searchInitialized||this.search(""),this.refreshTemplate()},CtrList.prototype.isOpen=function(open){this.ctx.isOpen=open},CtrList.prototype._clear=function(){this.searchTimer&&(this.searchTimer.unsubscribe(),this.searchTimer=null),this.dataService&&this.dataService.cancel(),this.viewContainer.clear(),this.viewRef=null},CtrList.prototype.searchTimerComplete=function(term){isNil(term)||term.length<this.ctrListMinSearchLength?this.ctx.searching=!1:(this.term=term,this._dataService&&this._dataService.search(term))},CtrList.prototype.refreshTemplate=function(){this.viewRef?this.viewRef.destroyed||(this.viewRef.context.isOpen=this.ctx.isOpen,this.viewRef.context.results=this.ctx.results,this.viewRef.context.searching=this.ctx.searching,this.viewRef.context.searchInitialized=this.ctx.searchInitialized,this.viewRef.detectChanges()):this.viewRef=this.viewContainer.createEmbeddedView(this.templateRef,this.ctx),this.cd.markForCheck()},CtrList.prototype.getBestMatchIndex=function(){var _this=this;if(!this.ctx.results||!this.term)return null;var bestMatch=this.ctx.results.findIndex(function(item){return item.title.toLowerCase()===_this.term.toLocaleLowerCase()});return bestMatch<0&&(bestMatch=this.ctx.results.findIndex(function(item){return item.title.toLowerCase().startsWith(_this.term.toLocaleLowerCase())})),bestMatch<0&&(bestMatch=this.ctx.results.findIndex(function(item){return item.title.toLowerCase().includes(_this.term.toLocaleLowerCase())})),bestMatch<0?null:bestMatch},CtrList.prototype.dataServiceSubscribe=function(){var _this=this;this._dataService&&(this._dataService.subscribe(function(results){_this.ctx.searchInitialized=!0,_this.ctx.searching=!1,_this.ctx.results=results,_this.ctrListAutoMatch&&results&&1===results.length&&results[0].title&&!isNil(_this.term)&&results[0].title.toLocaleLowerCase()===_this.term.toLocaleLowerCase()?_this.completer.onSelected(results[0]):(_this.refreshTemplate(),_this.ctrListAutoHighlight&&(_this.completer.autoHighlightIndex=_this.getBestMatchIndex()))},function(error){return console.error(error),console.error("Unexpected error in dataService: errors should be handled by the dataService Observable"),[]}),this._dataService.dataSourceChange&&this._dataService.dataSourceChange.subscribe(function(){_this.term=null,_this.ctx.searchInitialized=!1,_this.ctx.searching=!1,_this.ctx.results=[],_this.refreshTemplate(),_this.completer.onDataSourceChange()}))},__decorate([core.Input(),__metadata("design:type",Object)],CtrList.prototype,"ctrListMinSearchLength",void 0),__decorate([core.Input(),__metadata("design:type",Object)],CtrList.prototype,"ctrListPause",void 0),__decorate([core.Input(),__metadata("design:type",Object)],CtrList.prototype,"ctrListAutoMatch",void 0),__decorate([core.Input(),__metadata("design:type",Object)],CtrList.prototype,"ctrListAutoHighlight",void 0),__decorate([core.Input(),__metadata("design:type",Object)],CtrList.prototype,"ctrListDisplaySearching",void 0),__decorate([core.Input("ctrList"),__metadata("design:type",Object),__metadata("design:paramtypes",[Object])],CtrList.prototype,"dataService",null),__decorate([core.Input("ctrListInitialValue"),__metadata("design:type",Object),__metadata("design:paramtypes",[Object])],CtrList.prototype,"initialValue",null),CtrList=__decorate([core.Directive({selector:"[ctrList]"}),__param(0,core.Host()),__metadata("design:paramtypes",[CtrCompleter,core.TemplateRef,core.ViewContainerRef,core.ChangeDetectorRef,core.NgZone])],CtrList)}(),CtrRow=function(){function CtrRow(el,renderer,dropdown){this.el=el,this.renderer=renderer,this.dropdown=dropdown,this.selected=!1,this._rowIndex=0,this._item=null}return CtrRow.prototype.ngOnDestroy=function(){this._rowIndex&&this.dropdown.unregisterRow(this._rowIndex)},Object.defineProperty(CtrRow.prototype,"ctrRow",{set:function(index){this._rowIndex=index,this.dropdown.registerRow(new CtrRowItem(this,this._rowIndex))},enumerable:!0,configurable:!0}),Object.defineProperty(CtrRow.prototype,"dataItem",{set:function(item){this._item=item},enumerable:!0,configurable:!0}),CtrRow.prototype.onClick=function(event){this.dropdown.onSelected(this._item)},CtrRow.prototype.onMouseEnter=function(event){this.dropdown.highlightRow(this._rowIndex)},CtrRow.prototype.onMouseDown=function(event){this.dropdown.rowMouseDown()},CtrRow.prototype.setHighlighted=function(selected){this.selected=selected,this.selected?this.renderer.addClass(this.el.nativeElement,"completer-selected-row"):this.renderer.removeClass(this.el.nativeElement,"completer-selected-row")},CtrRow.prototype.getNativeElement=function(){return this.el.nativeElement},CtrRow.prototype.getDataItem=function(){return this._item},__decorate([core.Input(),__metadata("design:type",Number),__metadata("design:paramtypes",[Number])],CtrRow.prototype,"ctrRow",null),__decorate([core.Input(),__metadata("design:type",Object),__metadata("design:paramtypes",[Object])],CtrRow.prototype,"dataItem",null),__decorate([core.HostListener("click",["$event"]),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",void 0)],CtrRow.prototype,"onClick",null),__decorate([core.HostListener("mouseenter",["$event"]),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",void 0)],CtrRow.prototype,"onMouseEnter",null),__decorate([core.HostListener("mousedown",["$event"]),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",void 0)],CtrRow.prototype,"onMouseDown",null),CtrRow=__decorate([core.Directive({selector:"[ctrRow]"}),__param(2,core.Host()),__metadata("design:paramtypes",[core.ElementRef,core.Renderer2,CtrDropdown])],CtrRow)}(),CompleterListItemCmp=function(){function CompleterListItemCmp(){this.text="",this.searchStr="",this.matchClass="",this.type="",this.parts=[]}return CompleterListItemCmp.prototype.ngOnInit=function(){if(this.searchStr){for(var matchStr=this.text.toLowerCase(),matchPos=matchStr.indexOf(this.searchStr.toLowerCase()),startIndex=0;0<=matchPos;){var matchText=this.text.slice(matchPos,matchPos+this.searchStr.length);if(0===matchPos)this.parts.push({isMatch:!0,text:matchText}),startIndex+=this.searchStr.length;else if(0<matchPos){var matchPart=this.text.slice(startIndex,matchPos);this.parts.push({isMatch:!1,text:matchPart}),this.parts.push({isMatch:!0,text:matchText}),startIndex+=this.searchStr.length+matchPart.length}matchPos=matchStr.index