ng2-completer
Version:
ng2 autocomplete/typeahead component
1 lines • 59.4 kB
JavaScript
!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.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 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})}var empty={closed:!0,next:function(value){},error:function(err){if(config.useDeprecatedSynchronousErrorHandling)throw err;hostReportError(err)},complete:function(){}},isArray=Array.isArray||function(x){return x&&"number"==typeof x.length};function isObject(x){return null!=x&&"object"==typeof x}var tryCatchTarget,errorObject={e:{}};function tryCatcher(){try{return tryCatchTarget.apply(this,arguments)}catch(e){return errorObject.e=e,errorObject}}function tryCatch(fn){return tryCatchTarget=fn,tryCatcher}var UnsubscriptionError=function(_super){function UnsubscriptionError(errors){var _this=_super.call(this,errors?errors.length+" errors occurred during unsubscription:\n "+errors.map(function(err,i){return i+1+") "+err.toString()}).join("\n "):"")||this;return _this.errors=errors,_this.name="UnsubscriptionError",Object.setPrototypeOf(_this,UnsubscriptionError.prototype),_this}return __extends(UnsubscriptionError,_super),UnsubscriptionError}(Error),Subscription=function(){function Subscription(unsubscribe){this.closed=!1,this._parent=null,this._parents=null,this._subscriptions=null,unsubscribe&&(this._unsubscribe=unsubscribe)}var empty;return Subscription.prototype.unsubscribe=function(){var errors,hasErrors=!1;if(!this.closed){var _parent=this._parent,_parents=this._parents,_unsubscribe=this._unsubscribe,_subscriptions=this._subscriptions;this.closed=!0,this._parent=null,this._parents=null,this._subscriptions=null;for(var index=-1,len=_parents?_parents.length:0;_parent;)_parent.remove(this),_parent=++index<len&&_parents[index]||null;if(isFunction(_unsubscribe))tryCatch(_unsubscribe).call(this)===errorObject&&(hasErrors=!0,errors=errors||(errorObject.e instanceof UnsubscriptionError?flattenUnsubscriptionErrors(errorObject.e.errors):[errorObject.e]));if(isArray(_subscriptions))for(index=-1,len=_subscriptions.length;++index<len;){var sub=_subscriptions[index];if(isObject(sub))if(tryCatch(sub.unsubscribe).call(sub)===errorObject){hasErrors=!0,errors=errors||[];var err=errorObject.e;err instanceof UnsubscriptionError?errors=errors.concat(flattenUnsubscriptionErrors(err.errors)):errors.push(err)}}if(hasErrors)throw new UnsubscriptionError(errors)}},Subscription.prototype.add=function(teardown){if(!teardown||teardown===Subscription.EMPTY)return Subscription.EMPTY;if(teardown===this)return this;var subscription=teardown;switch(typeof teardown){case"function":subscription=new Subscription(teardown);case"object":if(subscription.closed||"function"!=typeof subscription.unsubscribe)return subscription;if(this.closed)return subscription.unsubscribe(),subscription;if("function"!=typeof subscription._addParent){var tmp=subscription;(subscription=new Subscription)._subscriptions=[tmp]}break;default:throw new Error("unrecognized teardown "+teardown+" added to Subscription.")}return(this._subscriptions||(this._subscriptions=[])).push(subscription),subscription._addParent(this),subscription},Subscription.prototype.remove=function(subscription){var subscriptions=this._subscriptions;if(subscriptions){var subscriptionIndex=subscriptions.indexOf(subscription);-1!==subscriptionIndex&&subscriptions.splice(subscriptionIndex,1)}},Subscription.prototype._addParent=function(parent){var _parent=this._parent,_parents=this._parents;_parent&&_parent!==parent?_parents?-1===_parents.indexOf(parent)&&_parents.push(parent):this._parents=[parent]:this._parent=parent},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"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("rxSubscriber"):"@@rxSubscriber",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){if(isTrustedSubscriber(destinationOrNext)){var trustedSubscriber=destinationOrNext[rxSubscriber]();_this.syncErrorThrowable=trustedSubscriber.syncErrorThrowable,(_this.destination=trustedSubscriber).add(_this)}else _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 _parent=this._parent,_parents=this._parents;return this._parent=null,this._parents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parent=_parent,this._parents=_parents,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);function isTrustedSubscriber(obj){return obj instanceof Subscriber||"syncErrorThrowable"in obj&&obj[rxSubscriber]}var observable="function"==typeof Symbol&&Symbol.observable||"@@observable";function noop(){}var Observable=function(){function Observable(subscribe){this._isScalar=!1,subscribe&&(this._subscribe=subscribe)}return Observable.prototype.lift=function(operator){var observable$$1=new Observable;return observable$$1.source=this,observable$$1.operator=operator,observable$$1},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?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),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 operations=[],_i=0;_i<arguments.length;_i++)operations[_i]=arguments[_i];return 0===operations.length?this:function(fns){return fns?1===fns.length?fns[0]:function(input){return fns.reduce(function(prev,fn){return fn(prev)},input)}:noop}(operations)(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||(config.Promise||Promise)))throw new Error("no Promise impl found");return promiseCtor}var ObjectUnsubscribedError=function(_super){function ObjectUnsubscribedError(){var _this=_super.call(this,"object unsubscribed")||this;return _this.name="ObjectUnsubscribedError",Object.setPrototypeOf(_this,ObjectUnsubscribedError.prototype),_this}return __extends(ObjectUnsubscribedError,_super),ObjectUnsubscribedError}(Error),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);var 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 void 0===delay&&(delay=0),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}(),AsyncScheduler=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);function isScheduler(value){return value&&"function"==typeof value.schedule}var async=new AsyncScheduler(AsyncAction);Error,Error,Error;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$7,due,{index:0,period:period,subscriber:subscriber})})}function dispatch$7(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)}}function isNil(value){return null==value}function noop$1(){}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$$1){var _this=_super.call(this)||this;return _this.http=http$$1,_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.decorators=[{type:core.Injectable}],LocalDataFactory}(),RemoteDataFactory=function(){function RemoteDataFactory(http$$1){this.http=http$$1}return RemoteDataFactory.prototype.create=function(){return new RemoteData(this.http)},RemoteDataFactory.decorators=[{type:core.Injectable}],RemoteDataFactory.ctorParameters=function(){return[{type: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.decorators=[{type:core.Injectable}],CompleterService.ctorParameters=function(){return[{type:LocalDataFactory},{type: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}),CtrCompleter.decorators=[{type:core.Directive,args:[{selector:"[ctrCompleter]"}]}],CtrCompleter.propDecorators={selected:[{type:core.Output}],highlighted:[{type:core.Output}],opened:[{type:core.Output}],dataSourceChange:[{type:core.Output}]},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)},CtrDropdown.decorators=[{type:core.Directive,args:[{selector:"[ctrDropdown]"}]}],CtrDropdown.ctorParameters=function(){return[{type:CtrCompleter,decorators:[{type:core.Host}]},{type:core.ElementRef},{type:core.NgZone}]},CtrDropdown.propDecorators={onMouseDown:[{type:core.HostListener,args:["mousedown",["$event"]]}]},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()},CtrInput.decorators=[{type:core.Directive,args:[{selector:"[ctrInput]"}]}],CtrInput.ctorParameters=function(){return[{type:CtrCompleter,decorators:[{type:core.Host}]},{type:forms.NgModel},{type:core.ElementRef}]},CtrInput.propDecorators={clearSelected:[{type:core.Input,args:["clearSelected"]}],clearUnselected:[{type:core.Input,args:["clearUnselected"]}],overrideSuggested:[{type:core.Input,args:["overrideSuggested"]}],fillHighlighted:[{type:core.Input,args:["fillHighlighted"]}],openOnFocus:[{type:core.Input,args:["openOnFocus"]}],openOnClick:[{type:core.Input,args:["openOnClick"]}],selectOnClick:[{type:core.Input,args:["selectOnClick"]}],selectOnFocus:[{type:core.Input,args:["selectOnFocus"]}],ngModelChange:[{type:core.Output}],keyupHandler:[{type:core.HostListener,args:["keyup",["$event"]]}],pasteHandler:[{type:core.HostListener,args:["paste",["$event"]]}],keydownHandler:[{type:core.HostListener,args:["keydown",["$event"]]}],onBlur:[{type:core.HostListener,args:["blur",["$event"]]}],onfocus:[{type:core.HostListener,args:["focus",[]]}],onClick:[{type:core.HostListener,args:["click",["$event"]]}]},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()}))},CtrList.decorators=[{type:core.Directive,args:[{selector:"[ctrList]"}]}],CtrList.ctorParameters=function(){return[{type:CtrCompleter,decorators:[{type:core.Host}]},{type:core.TemplateRef},{type:core.ViewContainerRef},{type:core.ChangeDetectorRef},{type:core.NgZone}]},CtrList.propDecorators={ctrListMinSearchLength:[{type:core.Input}],ctrListPause:[{type:core.Input}],ctrListAutoMatch:[{type:core.Input}],ctrListAutoHighlight:[{type:core.Input}],ctrListDisplaySearching:[{type:core.Input}],dataService:[{type:core.Input,args:["ctrList"]}],initialValue:[{type:core.Input,args:["ctrListInitialValue"]}]},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.renderer.setElementClass(this.el.nativeElement,"completer-selected-row",this.selected)},CtrRow.prototype.getNativeElement=function(){return this.el.nativeElement},CtrRow.prototype.getDataItem=function(){return this._item},CtrRow.decorators=[{type:core.Directive,args:[{selector:"[ctrRow]"}]}],CtrRow.ctorParameters=function(){return[{type:core.ElementRef},{type:core.Renderer},{type:CtrDropdown,decorators:[{type:core.Host}]}]},CtrRow.propDecorators={ctrRow:[{type:core.Input}],dataItem:[{type:core.Input}],onClick:[{type:core.HostListener,args:["click",["$event"]]}],onMouseEnter:[{type:core.HostListener,args:["mouseenter",["$event"]]}],onMouseDown:[{type:core.HostListener,args:["mousedown",["$event"]]}]},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.indexOf(this.searchStr.toLowerCase(),startIndex)}startIndex<this.text.length&&this.parts.push({isMatch:!1,text:this.text.slice(startIndex,this.text.length)})}else this.parts.push({isMatch:!1,text:this.text})},CompleterListItemCmp.decorators=[{type:core.Component,args:[{selector:"completer-list-item",template:'<span class="completer-list-item-holder" [ngClass]= "{\'completer-title\': type === \'title\', \'completer-description\': type === \'description\'}" >\n <span class="completer-list-item" *ngFor="let part of parts" [ngClass]= "part.isMatch ? matchClass : null">{{part.text}}</span>\n </span>'}]}],CompleterListItemCmp.propDecorators={text:[{type:core.Input}],searchStr:[{type:core.Input}],matchClass:[{type:core.Input}],type:[{type:core.Input}]},CompleterListItemCmp}(),COMPLETER_CONTROL_VALUE_ACCESSOR={multi:!0,provide:forms.NG_VALUE_ACCESSOR,useExisting:core.forwardRef(function(){return CompleterCmp})},CompleterCmp=function(){function CompleterCmp(completerService,cdr){this.completerService=completerService,this.cdr=cdr,this.inputName="",this.inputId="",this.pause=10,this.minSearchLength=3,this.maxChars=524288,this.overrideSuggested=!1,this.clearSelected=!1,this.clearUnselected=!1,this.fillHighlighted=!0,this.placeholder="",this.autoMatch=!1,this.disableInput=!1,this.autofocus=!1,this.openOnFocus=!1,this.openOnClick=!1,this.selectOnClick=!1,this.selectOnFocus=!1,this.autoHighlight=!1,this.selected=new core.EventEmitter,this.highlighted=new core.EventEmitter,this.blurEvent=new core.EventEmitter,this.click=new core.EventEmitter,this.focusEvent=new core.EventEmitter,this.opened=new core.EventEmitter,this.keyup=new core.EventEmitter,this.keydown=new core.EventEmitter,this.control=new forms.FormControl(""),this.displaySearching=!0,this.displayNoResults=!0,this._textNoResults="No results found",this._textSearching="Searching...",this._onTouchedCallback=noop$1,this._onChangeCallback=noop$1,this._focus=!1,this._open=!1,this._searchStr=""}return Object.defineProperty(CompleterCmp.prototype,"value",{get:function(){return this.searchStr},set:function(v){v!==this.searchStr&&(this.searchStr=v),this._onChangeCallback(v)},enumerable:!0,configurable:!0}),Object.defineProperty(CompleterCmp.prototype,"searchStr",{get:function(){return this._searchStr},set:function(value){"string"==typeof value||isNil(value)?this._searchStr=value:this._searchStr=JSON.stringify(value)},enumerable:!0,configurable:!0}),CompleterCmp.prototype.ngAfterViewInit=function(){this.autofocus&&(this._focus=!0)},CompleterCmp.prototype.ngAfterViewChecked=function(){var _this=this;this._focus&&setTimeout(function(){_this.ctrInput&&(_this.ctrInput.nativeElement.focus(),_this._focus=!1)},0)},CompleterCmp.prototype.onTouched=function(){this._onTouchedCallback()},CompleterCmp.prototype.writeValue=function(value){this.searchStr=value},CompleterCmp.prototype.registerOnChange=function(fn){this._onChangeCallback=fn},CompleterCmp.prototype.registerOnTouched=function(fn){this._onTouchedCallback=fn},CompleterCmp.prototype.setDisabledState=function(isDisabled){this.disableInput=isDisab