UNPKG

ns2-front-module-common

Version:
2 lines 97.9 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/http"),require("rxjs/Observable"),require("@angular/core"),require("angular2-uuid"),require("ngx-cookie-service"),require("rxjs/operator/map"),require("rxmq"),require("@angular/common/http"),require("ts-md5/dist/md5"),require("rxjs")):"function"==typeof define&&define.amd?define(["exports","@angular/http","rxjs/Observable","@angular/core","angular2-uuid","ngx-cookie-service","rxjs/operator/map","rxmq","@angular/common/http","ts-md5/dist/md5","rxjs"],e):e((t.ng=t.ng||{},t.ng.common=t.ng.common||{}),t.ng.http,t.Rx,t.ng.core,t.angular2Uuid,t.ngxCookieService,null,t.Rxmq,t._angular_common_http,t.tsMd5_dist_md5,t.rxjs)}(this,function(t,e,n,r,o,i,c,u,a,s,p){"use strict";function f(t,e,n){return new P(t,e,n)}u="default"in u?u.default:u;var h=function(){function t(){}return t}(),_=function(){function t(){}return Object.defineProperty(t,"gw",{get:function(){return t._gw},set:function(e){t._gw=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"storage",{get:function(){return t._storage},set:function(e){t._storage=e},enumerable:!0,configurable:!0}),t}();_._gw="",_._storage="";var l=function(){function t(){}return Object.defineProperty(t,"endPoint",{get:function(){return _.gw},enumerable:!0,configurable:!0}),t}(),y=(!0).__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),v=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return y(e,t),Object.defineProperty(e,"self",{get:function(){return e.endPoint+"/self"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"moderation",{get:function(){return e.self+"/moderate"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"logout",{get:function(){return e.endPoint+"/self/logout"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"geoSessionCity",{get:function(){return e.endPoint+"/self/geo"},enumerable:!0,configurable:!0}),e}(l),d="token",m=function(){function t(e,n,r,o){this.injector=e,this.persistStorage=n,this.tempStorage=r,this.cookiesService=o,this.token="",this.usersEndPoint="",this.temporaryDeviceUUID="",this.ESBChannel=u.channel(t.ESB_CHANNEL_NAME)}return t.prototype.getSocials=function(){var t=this;return new Promise(function(e,n){var r=t.usersEndPoint+"self/socials";t.injector.get(P).get(r).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(function(t){e(t)},function(t){n(t)})})},t.prototype.load=function(){var t=this;return new Promise(function(e,n){t.restoreToken().then(function(r){var o=function(){e(r)};t.loadInfoRemote().then(o).catch(function(t){401==t.statusCode?o():n(t)})}).catch(e)})},t.prototype.setUsersEndPoint=function(t){this.usersEndPoint=t},t.prototype.isAuth=function(){return!!this.getToken()},t.prototype.login=function(t,e,n){var r=this;return new Promise(function(o,i){var c=r.usersEndPoint+"users/login",u={email:t,password:e};r.injector.get(P).post(c,u).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(function(t){r.storeToken(t,n).then(function(t){r.token=t,r.loadInfoRemote().then(function(){o()}).catch(function(t){i(t)})}).catch(function(){r.token="",i()})},function(t){i(t)})})},t.prototype.register=function(t,e,n,r,o,i,c){var u=this;return new Promise(function(a,s){var p=u.usersEndPoint+"users/register",f={email:t,password:e,password_repeat:n,firstname:r,lastname:o,geo_guid:i,phone:c};u.injector.get(P).post(p,f).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(function(t){a(t)},function(t){s(t)})})},t.prototype.registerCheckEmail=function(t){var n=this;return new Promise(function(r,o){var i=n.usersEndPoint+"users/register-check-email",c=new e.URLSearchParams;c.set("email",t),n.injector.get(P).get(i,{search:c}).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(function(t){r(t)},function(t){o(t)})})},t.prototype.registerChangePhone=function(t,e){var n=this;return new Promise(function(r,o){var i=n.usersEndPoint+"users/register-change-phone",c={user_guid:t,phone:e};n.injector.get(P).put(i,c).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(function(t){r(t)},function(t){o(t)})})},t.prototype.confirm=function(t,e){var n=this;return new Promise(function(r,o){var i=n.usersEndPoint+"users/confirm",c={user_guid:t,code:e};n.injector.get(P).post(i,c).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(function(t){r(t)},function(t){o(t)})})},t.prototype.loadInfoRemote=function(){var e=this;return new Promise(function(n,r){var o=v.self;e.injector.get(P).get(o).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(function(r){e.info=r,e.ESBChannel.subject(t.ESB_USER_LOGIN).next(r),n(r)},function(t){r(t)})})},t.prototype.reminderPassword=function(t){var e=this;return new Promise(function(n,r){var o=e.usersEndPoint+"users/reminder-password",i={email:t};e.injector.get(P).post(o,i).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(function(t){n(t)},function(t){r(t)})})},t.prototype.restorePasswordCheck=function(t){var n=this;return new Promise(function(r,o){var i=n.usersEndPoint+"users/restore-password-check",c=new e.URLSearchParams;c.set("token",t),n.injector.get(P).get(i,{search:c}).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(function(t){r(t)},function(t){o(t)})})},t.prototype.restorePassword=function(t,e,n){var r=this;return new Promise(function(o,i){var c=r.usersEndPoint+"users/restore-password",u={token:t,password:e,password_repeat:n};r.injector.get(P).put(c,u).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(function(t){o(t)},function(t){i(t)})})},t.prototype.setGeo=function(e){var n=this;return new Promise(function(r,o){var i=n.usersEndPoint+"self/geo",c={geo_guid:e};n.injector.get(P).put(i,c).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(function(e){n.info.session.geo_guid=e.geo_guid,n.ESBChannel.subject(t.ESB_SESSION_CHANGE_CITY).next({oldGeoGuid:n.info.session.geo_guid,newGeoGuid:e.geo_guid}),r(e)},function(t){o(t)})})},t.prototype.onGeoChange=function(e){return this.ESBChannel.observe(t.ESB_SESSION_CHANGE_CITY).subscribe(e)},t.prototype.onLogin=function(e){return this.ESBChannel.observe(t.ESB_USER_LOGIN).subscribe(e)},t.prototype.onLogout=function(e){return this.ESBChannel.observe(t.ESB_USER_LOGOUT).subscribe(e)},t.prototype.logout=function(){var e=this;return new Promise(function(n,r){var o=e.usersEndPoint+"self/logout",i=function(){e.ESBChannel.subject(t.ESB_USER_LOGOUT).next(),e.localLogout().then(n).catch(r)};e.injector.get(P).delete(o).subscribe(i,i)})},t.prototype.localLogout=function(){return this.token="",this.cookiesService.delete(t.USER_TOKEN_NAME),Promise.race([this.persistStorage.remove(d),this.persistStorage.removeByTag(d),this.tempStorage.remove(d),this.tempStorage.removeByTag(d)])},t.prototype.saveProfile=function(t){var e=this;return new n.Observable(function(n){e.injector.get(P).post(v.self,t).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(function(t){e.info=t,n.next(t),n.complete()},function(t){n.error(t),n.complete()})})},t.prototype.sendOnModeration=function(t){var e=this;return new n.Observable(function(n){e.injector.get(P).post(v.moderation,t).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(function(t){e.info=t,n.next(t),n.complete()},function(t){n.error(t),n.complete()})})},t.prototype.storeToken=function(t,e){return e?this.persistStorage.set(d,t):this.tempStorage.set(d,t)},t.prototype.restoreToken=function(){var e=this;return new Promise(function(n,r){var o=e.cookiesService.get(t.USER_TOKEN_NAME);o?(e.token=o,e.storeToken(e.token,!0).then(function(){n(o),e.cookiesService.delete(t.USER_TOKEN_NAME)})):e.persistStorage.get(d).then(function(t){e.token=t,n(t)}).catch(function(){e.tempStorage.get(d).then(function(t){e.token=t,n(t)}).catch(function(){r()})})})},t.prototype.setRejectionReason=function(t){this.info.reject_reason=t},t.prototype.getToken=function(){return this.token},t.prototype.setToken=function(t){this.token=t},t.prototype.getInfo=function(){return this.info},t.prototype.invite=function(t){var e=this;return new Promise(function(n,r){var o=e.usersEndPoint+"self/invite";e.injector.get(P).post(o,{email:t}).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(function(){n()},function(t){r(t)})})},t.prototype.getPartners=function(){var t=this;return new Promise(function(e,n){var r=t.usersEndPoint+"self/partners";t.injector.get(P).get(r).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(e,n)})},t.prototype.addPartners=function(t){var e=this;return new Promise(function(n,r){var o=e.usersEndPoint+"self/partners";e.injector.get(P).put(o,t).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(n,r)})},t.prototype.setPartners=function(t){var e=this;return new Promise(function(n,r){var o=e.usersEndPoint+"self/partners";e.injector.get(P).post(o,t).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(n,r)})},t.prototype.deletePartner=function(t){var e=this;return new Promise(function(n,r){var o=e.usersEndPoint+"self/partner/"+t;e.injector.get(P).delete(o).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(n,r)})},t.prototype.getTemporaryDeviceUUID=function(){return this.temporaryDeviceUUID||(this.temporaryDeviceUUID=o.UUID.UUID()),this.temporaryDeviceUUID},Object.defineProperty(t.prototype,"isCandidate",{get:function(){return"candidate"===this.info.rank},enumerable:!0,configurable:!0}),t}();m.ESB_CHANNEL_NAME="current-user",m.ESB_SESSION_CHANGE_CITY="session.change-city",m.ESB_INFO_UPDATE="info.update",m.ESB_USER_LOGIN="user.login",m.ESB_USER_LOGOUT="user.logout",m.USER_TOKEN_NAME="X-User-Token",m.decorators=[{type:r.Injectable}],m.ctorParameters=function(){return[{type:r.Injector},{type:void 0,decorators:[{type:r.Inject,args:["StorageInterface"]}]},{type:void 0,decorators:[{type:r.Inject,args:["StorageInterface"]}]},{type:i.CookieService}]};var b=function(){function t(){this._handler=new r.EventEmitter}return Object.defineProperty(t.prototype,"handler",{get:function(){return this._handler},enumerable:!0,configurable:!0}),t}();b.decorators=[{type:r.Injectable}],b.ctorParameters=function(){return[]};var g=(!0).__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),P=function(t){function o(e,n,r){var o=t.call(this,n,r)||this;return o.injector=e,o}return g(o,t),o.prototype.getDefaultHttpClient=function(){if(!this.defaultHttpClient){var t=r.ReflectiveInjector.resolveAndCreate([a.HttpClient,{provide:a.HttpHandler,useClass:a.HttpXhrBackend},{provide:a.XhrFactory,useClass:e.BrowserXhr}]);this.defaultHttpClient=t.get(a.HttpClient)}return this.defaultHttpClient},o.prototype.request=function(r,o){var i=this,c=this.injector.get(m),u=c.getToken();if("string"==typeof r){var a=new e.Headers;a.append(m.USER_TOKEN_NAME,u),o instanceof e.RequestOptions||(o=new e.RequestOptions),o.headers=a}else r instanceof e.Request&&(void 0===r.headers&&(r.headers=new e.Headers),r.headers.append(m.USER_TOKEN_NAME,u));return n.Observable.fromPromise(new Promise(function(e,n){t.prototype.request.call(i,r,o).subscribe(function(t){return e(t)},function(t){n(i.handleHttpError(t))})}))},o.prototype.handleHttpError=function(t){var e,n;try{var r=t.json();e=r.hasOwnProperty("error")?r.error:t.statusText,n=r.hasOwnProperty("errno")?r.errno:0}catch(o){e=t.statusText,n=0}var o={message:e,statusCode:t.status,errNo:n,errorResponse:t};return this.injector.get(b).handler.emit(o),o},o}(e.Http);P.decorators=[{type:r.Injectable}],P.ctorParameters=function(){return[{type:r.Injector},{type:e.ConnectionBackend},{type:e.RequestOptions}]};var O=function(){function t(t,e){this.httpService=t,this.cache=e}return t.prototype.setRefsEndPoint=function(t){this.refsEndPoint=t},t.prototype.getOne=function(t){var e=this;return new Promise(function(n,r){var o=e.cache.getCacheKey(e.refName,t);e.cache.get(o).then(n).catch(function(){var i=e.refsEndPoint+"data/"+e.refName+"/"+t;e.httpService.get(i).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(function(t){var r=function(){n(t)};e.cache.set(o,t,0,[t.guid,e.refName]).then(r).catch(r)},function(t){r(t)})})})},t.prototype.treeUp=function(t,e){var n=this;return new Promise(function(r,o){var i=n.cache.getCacheKey("tree",n.refName,t,JSON.stringify(e));n.cache.get(i).then(r).catch(function(){var c=n.refsEndPoint+"tree/"+n.refName+"/up/"+t,u=e||{};n.httpService.get(c,{search:u}).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(function(t){var e=function(){r(t)};n.cache.set(i,t,0,[t.guid,n.refName]).then(e).catch(e)},function(t){o(t)})})})},t.prototype.treeDown=function(t,e){var n=this;return new Promise(function(r,o){var i=n.cache.getCacheKey("tree",n.refName,t,JSON.stringify(e));n.cache.get(i).then(r).catch(function(){var c=n.refsEndPoint+"tree/"+n.refName+"/down/"+t,u=e||{};n.httpService.get(c,{search:u}).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(function(t){var e=function(){r(t)};n.cache.set(i,t,0,[t.guid,n.refName]).then(e).catch(e)},function(t){o(t)})})})},t.prototype.getList=function(t){var n=this;return new Promise(function(r,o){for(var i=n.refsEndPoint+"data/"+n.refName,c=Object.keys(t),u=new e.URLSearchParams,a=0;a<c.length;a++){var s=c[a];u.set(s,t[s])}var p=n.cache.getCacheKey(n.refName,u.toString());n.cache.get(p).then(r).catch(function(){n.httpService.get(i,{search:u}).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(function(t){var e=function(){r(t)},o=[n.refName];(t?t.items||[]:[]).map(function(t){t&&t.guid&&o.push(t.guid)}),n.cache.set(p,t,0,o).then(e).catch(e)},function(t){o(t)})})})},t.prototype.getListAll=function(n,r){var o=this;return void 0===r&&(r=""),new Promise(function(i,c){for(var u=o.refsEndPoint+"data/"+o.refName+"/full",a=Object.keys(n),s=new e.URLSearchParams,p=0;p<a.length;p++){var f=a[p];s.set(f,n[f])}""!=r&&s.set(t.SORT_FIELD,r);var h=o.cache.getCacheKey(o.refName,s.toString());o.cache.get(h).then(i).catch(function(){o.httpService.get(u,{search:s}).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(function(t){var e=function(){i(t)},n=[o.refName];t.map(function(t){t&&t.guid&&n.push(t.guid)}),o.cache.set(h,t,0,n).then(e).catch(e)},function(t){c(t)})})})},t}();O.MAX_ITEMS=1e3,O.PER_PAGE_FIELD="per-page",O.PAGE_FIELD="page",O.SORT_FIELD="sort",O.decorators=[{type:r.Injectable}],O.ctorParameters=function(){return[{type:P},{type:void 0,decorators:[{type:r.Inject,args:["StorageInterface"]}]}]};var E=function(){function t(){this.channel=u.channel(t.CHANNEL_NAME),this.reconnectTimeout=1e3,this.isConnected=!1}return t.prototype.setEndPoint=function(t){this.endPoint=t},t.prototype.setReconnectTimeout=function(t){this.reconnectTimeout=t},t.prototype.send=function(t){this.ws.send(JSON.stringify(t))},t.prototype.onOpen=function(e){return this.channel.observe(t.SOCKET_OPEN_TOPIC_NAME).subscribe(e)},t.prototype.onMessage=function(e){return this.channel.observe(t.SOCKET_MESSAGE_TOPIC_NAME).subscribe(e)},t.prototype.onClose=function(e){return this.channel.observe(t.SOCKET_CLOSE_TOPIC_NAME).subscribe(e)},t.prototype.onError=function(e){return this.channel.observe(t.SOCKET_ERROR_TOPIC_NAME).subscribe(e)},t.prototype.connect=function(t){this.isConnected||(this.openConnection(t),this.isConnected=!0)},t.prototype.disconnect=function(){this.isConnected&&(this.ws.close(t.SOCKET_CLOSE_NORMAL),this.isConnected=!1)},t.prototype.openConnection=function(e){var n=this,r=this.endPoint,o=[];for(var i in e)e.hasOwnProperty(i)&&o.push(i+"="+e[i]);o.length>0&&(r+="?"+o.join("&")),this.ws=new WebSocket(r),this.ws.onopen=function(e){n.channel.subject(t.SOCKET_OPEN_TOPIC_NAME).next(e)},this.ws.onmessage=function(e){var r=JSON.parse(e.data)||{};n.channel.subject(t.SOCKET_MESSAGE_TOPIC_NAME).next(r)},this.ws.onerror=function(e){n.channel.subject(t.SOCKET_ERROR_TOPIC_NAME).next(e),n.ws.close(t.SOCKET_CLOSE_ABNORMAL)},this.ws.onclose=function(r){n.channel.subject(t.SOCKET_CLOSE_TOPIC_NAME).next(r),r.code!==t.SOCKET_CLOSE_NORMAL&&setTimeout(function(){n.openConnection(e)},n.reconnectTimeout)}},t}();E.CHANNEL_NAME="ws",E.SOCKET_OPEN_TOPIC_NAME="socket_open",E.SOCKET_MESSAGE_TOPIC_NAME="socket_message",E.SOCKET_CLOSE_TOPIC_NAME="socket_close",E.SOCKET_ERROR_TOPIC_NAME="socket_error",E.SOCKET_CLOSE_NORMAL=1e3,E.SOCKET_CLOSE_ABNORMAL=3e3,E.decorators=[{type:r.Injectable}],E.ctorParameters=function(){return[]};var S=function(){function t(t){this.currentUser=t}return t.prototype.declOfNum=function(t,e){var n=[2,0,1,1,1,2];return e[t%100>4&&t%100<20?2:n[t%10<5?t%10:5]]},t.prototype.getSelectedText=function(){var t="";return window.getSelection&&(t=window.getSelection().toString()),t},t.prototype.maskPhone=function(t,e){return t+" "+e.substr(0,3)+" "+e.substr(3,3)+"-"+e.substr(6,2)+"-"+e.substr(8,2)},t.prototype.getPublishedRealty=function(t){var e=this.getRealtyInfo(t);return e.hasOwnProperty("published")?Number(e.published):0},t.prototype.getExclusiveRealty=function(t){var e=this.getRealtyInfo(t);return e.hasOwnProperty("exclusive")?Number(e.exclusive):0},t.prototype.getRealtyInfo=function(t){var e=this.currentUser.getInfo(),n=e?e.session:null,r=n?n.geo_guid:"";return t.realty_count&&t.realty_count.hasOwnProperty(r)?t.realty_count[r]:{}},t}();S.decorators=[{type:r.Injectable}],S.ctorParameters=function(){return[{type:m}]};var w=function(){function t(){}return t}();w.decorators=[{type:r.NgModule,args:[{declarations:[],imports:[e.HttpModule],providers:[E,b,S,i.CookieService,{provide:P,useFactory:f,deps:[r.Injector,e.XHRBackend,e.RequestOptions]}]}]}],w.ctorParameters=function(){return[]};var j=function(){function t(){this.guid="",this.firstname="",this.lastname="",this.email="",this.experience=0,this.avatar_guid="",this.geo_guid="",this.description="",this.is_online=!1,this.phones=[],this.specializations=[],this.districts=[],this.is_agency=!1,this.agency_position="",this.agency_title="",this.can_work_other_city=!1,this.birthday=0,this.site_url="",this.socials=[],this.rank="",this.rank_title="",this.customer_info="",this.on_moderate=!1}return t}(),A=(!0).__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),R=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return A(e,t),e}(j),I=(!0).__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),C=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return I(e,t),e}(O),T=function(){function t(t,e){this.httpService=t,this.cache=e,this.services={}}return t.prototype.setRefsEndPoint=function(t){this.refsEndPoint=t},t.prototype.getInstance=function(t){if(!this.services.hasOwnProperty(t)){var e=new C(this.httpService,this.cache);e.refName=t,e.setRefsEndPoint(this.refsEndPoint),this.services[t]=e}return this.services[t]},t}();T.decorators=[{type:r.Injectable}],T.ctorParameters=function(){return[{type:P},{type:void 0,decorators:[{type:r.Inject,args:["StorageInterface"]}]}]};var M=function(){function t(){this.loadedScripts=[],this.loadedStyles=[],this.loadedImages=[]}return t.prototype.loadStyles=function(t){var e=this;return Promise.all(t.map(function(t){return e.loadStyle(t.href,t.optionalAttributes||{})}))},t.prototype.loadScripts=function(t){var e=this;return Promise.all(t.map(function(t){return e.loadScript(t.src,t.optionalAttributes||{})}))},t.prototype.loadImages=function(t){var e=this;return Promise.all(t.map(function(t){return e.loadImage(t.src,t.optionalAttributes||{})}))},t.prototype.loadStyle=function(e,n){var r=this;return new Promise(function(o,i){if(-1!==r.loadedStyles.indexOf(e))o();else{var c=document.createElement("link"),u=Object.assign(t.defaultStyleAttributes,n||{});for(var a in u)c.setAttribute(a,u[a]);c.href=e,c.onload=function(){r.loadedStyles.push(e),o()},c.onerror=i,document.head.appendChild(c)}})},t.prototype.loadScript=function(e,n){var r=this;return new Promise(function(o,i){if(-1!==r.loadedScripts.indexOf(e))o();else{var c=document.createElement("script"),u=Object.assign(t.defaultScriptAttributes,n||{});for(var a in u)c.setAttribute(a,u[a]);c.src=e,c.onload=function(){r.loadedScripts.push(e),o()},c.onerror=i,document.body.appendChild(c)}})},t.prototype.loadImage=function(t,e){var n=this;return new Promise(function(r,o){if(-1!==n.loadedImages.indexOf(t))r();else{var i=new Image,c=e||{};for(var u in c)i.setAttribute(u,c[u]);i.onload=function(){n.loadedImages.push(t),r()},i.onerror=o,i.src=t}})},t}();M.defaultStyleAttributes={type:"text/css",rel:"stylesheet"},M.defaultScriptAttributes={type:"text/javascript"},M.decorators=[{type:r.Injectable}],M.ctorParameters=function(){return[]};var L=(!0).__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),N=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return L(e,t),e}(h),x=(!0).__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),U=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return x(e,t),e}(N),D=(!0).__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),G=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.refName="geo",e}return D(e,t),e.prototype.getAllCountries=function(){return this.getListAll({level:1},"sorder,title")},e.prototype.getAllCities=function(t){return this.getListAll({level:2,pid:t},"sorder,title")},e.prototype.getAllDistricts=function(t){return this.getListAll({level:3,pid:t},"sorder,title")},e.prototype.getCountries=function(t){return t=t||{},t.level=1,t[e.SORT_FIELD]="sorder,title",this.getList(t)},e.prototype.getCities=function(t,n){return n=n||{},n.level=2,n.pid=t,n[e.SORT_FIELD]="sorder,title",this.getList(n)},e.prototype.getDistricts=function(t,n){return n=n||{},n.level=3,n.pid=t,n[e.SORT_FIELD]="sorder,title",this.getList(n)},e.prototype.getCity=function(t){return this.getOne(t)},e.prototype.getTreeUp=function(t,e){return this.treeUp(t,e)},e.prototype.getTreeDown=function(t,e){return this.treeDown(t,e)},e.prototype.getCountry=function(t){return this.getOne(t)},e.prototype.getListAll=function(e,n){return void 0===n&&(n=""),e=e||{},e.visible=!0,t.prototype.getListAll.call(this,e,n)},e.prototype.getList=function(e){return e=e||{},e.visible=!0,t.prototype.getList.call(this,e)},e.prototype.treeUp=function(e,n){return n=n||{},n.visible=!0,t.prototype.treeUp.call(this,e,n)},e.prototype.treeDown=function(e,n){return n=n||{},n.visible=!0,t.prototype.treeDown.call(this,e,n)},e}(O);G.decorators=[{type:r.Injectable}],G.ctorParameters=function(){return[]};var k=function(){function t(t,e,n){this._expiredAt=0,this._tags=[],this._value=null,this._hits=0,this.expiredAt=t?Math.floor((new Date).getTime())+t:0,this.tags=e||[],this.value=n||null,this.hits=0}return Object.defineProperty(t.prototype,"expiredAt",{get:function(){return this._expiredAt},set:function(t){this._expiredAt=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hits",{get:function(){return this._hits},set:function(t){this._hits=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"tags",{get:function(){return this._tags},set:function(t){this._tags=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"value",{get:function(){return this._value},set:function(t){this._value=t},enumerable:!0,configurable:!0}),t.prototype.serialize=function(){var t={expiredAt:this.expiredAt,tags:this.tags,value:this.value,hits:this.hits};return JSON.stringify(t)},t.prototype.isExpired=function(){return this.expiredAt>0&&this.expiredAt>Math.floor((new Date).getTime())},t.unserialize=function(e){var n=JSON.parse(e),r=n.expiredAt||0,o=n.tags||[],i=n.value||null,c=new t(r,o,i);return c.hits=n.hits||0,c},t}(),H=function(){function t(){this.maintenanceProcessing=!1,this.maintenanceExceptKeys=[d]}return t.prototype.set=function(t,e,n,r){var o=this,i=new k(n,r,e);return new Promise(function(n,r){var c=function(){n(e)};o.setInternal(t,i).then(c).catch(function(){o.maintenance().then(function(){o.setInternal(t,i).then(c).catch(r)}).catch(r)})})},t.prototype.get=function(t){var e=this;return new Promise(function(n,r){e._get(e.prepareKey(t)).then(function(o){try{var i=k.unserialize(o);i.isExpired()?e.removeInternal(t,i.tags).then(r).catch(r):(i.hits=i.hits+1,e.setInternal(t,i).then(function(){n(i.value||null)}).catch(function(){n(i.value||null)}))}catch(t){r(t)}}).catch(r)})},t.prototype.removeByTag=function(t){var e=this;return new Promise(function(n,r){var o=[],i=e.prepareTag(t);e._get(i).then(function(t){var r=JSON.parse(t);o=r.map(function(t){return new Promise(function(n,r){var o=e.prepareKey(t);e._get(o).then(function(o){var i=k.unserialize(o);e.removeInternal(t,i.tags).then(n).catch(r)}).catch(r)})});var c=function(){Promise.all(o).then(n).catch(n)};e._remove(i).then(c).catch(c)}).catch(r)})},t.prototype.remove=function(t){var e=this;return new Promise(function(n,r){var o=e.prepareKey(t);e._get(o).then(function(o){var i=k.unserialize(o);e.removeInternal(t,i.tags).then(n).catch(r)}).catch(r)})},t.prototype.clear=function(){return this._clear()},t.prototype.maintenance=function(){var e=this;return new Promise(function(n,r){e.maintenanceProcessing?n():e._getStorageInstance().then(function(r){e.maintenanceProcessing=!0;for(var o=Object.keys(r),i=Math.floor(o.length*t.CLEAN_RECORDS_PERCENT/100),c={},u=0,a="",s=0,p=!0,f=0;f<o.length;f++){var h=o[f];if(0===h.indexOf(t.DATA_PREFIX)){var _=h.substring(t.DATA_PREFIX.length),l=e.maintenanceExceptKeys.indexOf(_)>-1,y=r.getItem(h);if(null!==y&&!l){var v=k.unserialize(y);if(u<i)c[h]=v.hits,u++,(""==a||s>v.hits)&&(a=h,s=v.hits),v.hits>0&&(p=!1);else{if(p&&u>=i)break;v.hits<s&&(delete c[a],c[h]=v.hits,v.hits>0&&(p=!1))}}}}var d=[];for(var m in c)if(c.hasOwnProperty(m)){var b=m.substring(t.DATA_PREFIX.length);d.push(e.remove(b))}Promise.all(d).then(function(){e.maintenanceProcessing=!1,n()}).catch(function(){e.maintenanceProcessing=!1,n()})}).catch(r)})},t.prototype.getCacheKey=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=JSON.stringify(t);return String(s.Md5.hashStr(n))},t.prototype.setInternal=function(t,e){var n=this;return new Promise(function(r,o){var i=e.tags.map(function(e){return new Promise(function(r,o){var i=n.prepareTag(e);n._get(i).then(function(e){var c=JSON.parse(e);-1===c.indexOf(t)?(c.push(t),n._set(i,JSON.stringify(c)).then(r).catch(o)):r()}).catch(function(){n._set(i,JSON.stringify([t])).then(r).catch(o)})})});i.push(n._set(n.prepareKey(t),e.serialize())),Promise.all(i).then(r).catch(o)})},t.prototype.removeInternal=function(t,e){var n=this;return new Promise(function(r,o){var i=e.map(function(e){return new Promise(function(r,o){e=n.prepareTag(e),n._get(e).then(function(i){var c=JSON.parse(i),u=c.indexOf(t);u>-1?(c.splice(u,1),c.length>0?n._set(e,JSON.stringify(c)).then(r).catch(o):n._remove(e).then(r).catch(o)):o()}).catch(o)})});i.push(n._remove(n.prepareKey(t))),Promise.all(i).then(r).catch(o)})},t.prototype.prepareTag=function(e){return t.TAGS_PREFIX+e.trim().toLowerCase()},t.prototype.prepareKey=function(e){return t.DATA_PREFIX+e.trim().toLowerCase()},t}();H.CLEAN_RECORDS_PERCENT=30,H.TAGS_PREFIX="T_",H.DATA_PREFIX="D_",H.decorators=[{type:r.Injectable}],H.ctorParameters=function(){return[]};var F=(!0).__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),B=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return F(e,t),e.prototype._set=function(t,e){var n=this;return new Promise(function(r,o){try{n._getStorageInstance().then(function(n){n.setItem(t,e),r()}).catch(o)}catch(t){o(t)}})},e.prototype._get=function(t){var e=this;return new Promise(function(n,r){try{e._getStorageInstance().then(function(e){var o=e.getItem(t);null===o?r():n(o)}).catch(r)}catch(t){r(t)}})},e.prototype._remove=function(t){var e=this;return new Promise(function(n,r){try{e._getStorageInstance().then(function(e){e.removeItem(t),n()}).catch(r)}catch(t){r(t)}})},e.prototype._clear=function(){var t=this;return new Promise(function(e,n){try{t._getStorageInstance().then(function(t){t.clear(),e()}).catch(n)}catch(t){n(t)}})},e.prototype._getStorageInstance=function(){return new Promise(function(t,e){try{t(localStorage)}catch(t){e(t)}})},e}(H);B.decorators=[{type:r.Injectable}],B.ctorParameters=function(){return[]};var K=function(){function t(){this.is_primary=!1}return t}(),Y=function(){function t(){}return t}(),q=function(){function t(){}return t}(),z=(!0).__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),J=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return z(e,t),Object.defineProperty(e,"baseUrl",{get:function(){return e.endPoint+"/realtors"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"list",{get:function(){return""+e.baseUrl},enumerable:!0,configurable:!0}),Object.defineProperty(e,"search",{get:function(){return e.baseUrl+"/search"},enumerable:!0,configurable:!0}),e}(l),X=function(){function t(t){this.httpService=t}return t.prototype.search=function(t,n){var r=this;return new Promise(function(o,i){var c={search:new e.URLSearchParams};Object.keys(n).forEach(function(t){c.search.set(t,n[t])}),c.search.set("query",t),r.httpService.get(J.search,c).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(o,i)})},t.prototype.getPartners=function(t){var e=this;return new Promise(function(n,r){var o=e.usersEndPoint+"users/"+t+"/partners";e.httpService.get(o).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(n,r)})},t.prototype.addPartners=function(t,e){var n=this;return new Promise(function(r,o){var i=n.usersEndPoint+"users/"+t+"/partners";n.httpService.put(i,e).map(function(t){ return t.json()}).map(function(t){return t.data}).subscribe(r,o)})},t.prototype.setPartners=function(t,e){var n=this;return new Promise(function(r,o){var i=n.usersEndPoint+"users/"+t+"/partners";n.httpService.post(i,e).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(r,o)})},t.prototype.deletePartner=function(t,e){var n=this;return new Promise(function(r,o){var i=n.usersEndPoint+"users/"+t+"/partner/"+e;n.httpService.delete(i).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(r,o)})},t.prototype.filter=function(t,n){var r=this;return new Promise(function(o,i){var c=new e.URLSearchParams;if(n)for(var u=Object.keys(n),a=0;a<u.length;a++){var s=u[a];c.set(s,n[s])}r.httpService.post(J.list,t,{search:c}).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(o,i)})},t.prototype.filterMembers=function(t,n){var r=this;return new Promise(function(o,i){var c=r.usersEndPoint+"users/filter-members",u=new e.URLSearchParams;if(n)for(var a=Object.keys(n),s=0;s<a.length;s++){var p=a[s];u.set(p,n[p])}r.httpService.post(c,t,{search:u}).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(o,i)})},t.prototype.load=function(t){var e=this;return new Promise(function(n,r){var o=e.usersEndPoint+"users/"+t;e.httpService.get(o).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(n,r)})},t.prototype.getUsersByGuids=function(t){var e=this;return new Promise(function(n,r){var o=e.usersEndPoint+"users/get-by-guids";e.httpService.post(o,t).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(n,r)})},t.prototype.setUsersEndPoint=function(t){this.usersEndPoint=t},t}();X.ESB_REALTORS_CHANNEL_NAME="realtors",X.ESB_REALTORS_SHOW_INFO="info.show",X.decorators=[{type:r.Injectable}],X.ctorParameters=function(){return[{type:P}]};var V=(!0).__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),W=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return V(e,t),Object.defineProperty(e,"baseUrl",{get:function(){return e.endPoint+"/realty"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"filter",{get:function(){return e.baseUrl+"/filter"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"favorites",{get:function(){return e.baseUrl+"/favorites"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"myList",{get:function(){return e.baseUrl+"/get-my-realty"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"getFiltersFullMeta",{get:function(){return e.endPoint+"/realty-filter/full-meta-info"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"metaFull",{get:function(){return e.endPoint+"/realty-form/full"},enumerable:!0,configurable:!0}),e.create=function(t,n){return e.baseUrl+"/"+t+"/"+n},e.update=function(t,n,r){return e.baseUrl+"/"+t+"/"+n+"/"+r},e.publish=function(t,n,r){return e.baseUrl+"/"+t+"/"+n+"/"+r+"/publish"},e.remove=function(t,n,r){return e.baseUrl+"/"+t+"/"+n+"/"+r},e.favorite=function(t){return e.baseUrl+"/"+t+"/favorites"},e.about=function(t){return e.baseUrl+"/"+t},Object.defineProperty(e,"getFormLastModified",{get:function(){return e.endPoint+"/realty-form/last-modified"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"getByGuids",{get:function(){return e.endPoint+"/get-by-guids"},enumerable:!0,configurable:!0}),e.salePublish=function(t,n,r){return e.baseUrl+"/"+t+"/"+n+"/"+r+"/sale-publish"},e.saleUnPublish=function(t,n,r){return e.baseUrl+"/"+t+"/"+n+"/"+r+"/sale-unpublish"},e}(l),$=function(){function t(e,n,r){var o=this;this.httpService=e,this.currentUser=n,this.cache=r,this.realtyChannel=u.channel(t.ESB_REALTY_CHANNEL_NAME),this.currentUser.onGeoChange(function(t){t=t||{},o.cache.removeByTag(t.oldGeoGuid||"")})}return t.prototype.getAllFormMetadata=function(){var e=this;return new Promise(function(n,r){var o=e.cache.getCacheKey(t.FULL_FORM_METADATA_KEY);e.cache.get(o).then(function(t){n(t)}).catch(function(){var t=W.metaFull;e.httpService.get(t).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(function(t){for(var i,c,u,a={},s=[],p=0;p<t.length;p++){i=t[p],c=[i.action_guid,i.entity_guid,i.action_guid+"_"+i.entity_guid,e.currentUser.getInfo().session.geo_guid],u=e.cache.getCacheKey(i.action_guid,i.entity_guid);for(var f=0;f<c.length;f++)a.hasOwnProperty(c[f])||(a[c[f]]=!0);s.push(e.cache.set(u,i.meta,0,c))}var h=Object.keys(a);h.push(e.currentUser.getInfo().session.geo_guid),s.push(e.cache.set(o,t,0,h)),Promise.all(s).then(function(){n(t)}).catch(function(t){r(t)})},r)})})},t.prototype.getFilterMetaData=function(t){var e=this,n={currentUserSessionGeoGuid:t},r=W.getFiltersFullMeta;return new Promise(function(t,o){e.httpService.post(r,n).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(function(e){t(e)},o)})},t.prototype.create=function(t,e,n){var r=this;return new Promise(function(o,i){var c=W.create(t,e);r.httpService.post(c,n).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(o,i)})},t.prototype.update=function(t,e,n,r){var o=this;return new Promise(function(i,c){var u=W.update(t,e,n);o.httpService.post(u,r).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(i,c)})},t.prototype.filter=function(t,e){return this.loadList(W.filter,t,e)},t.prototype.getMyRealty=function(t,e){return this.loadList(W.myList,t,e)},t.prototype.getFavoritesRealty=function(t,e){return this.loadList(W.favorites,t,e)},t.prototype.publish=function(e,n,r){var o=this;return new Promise(function(i,c){var u=W.publish(e,n,r);o.httpService.put(u,{}).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(function(c){o.realtyChannel.subject(t.ESB_REALTY_PUBLISHED_CHANGE).next({actionGuid:e,entityGuid:n,guid:r,state:!0}),i(c)},c)})},t.prototype.unPublish=function(e,n,r){var o=this;return new Promise(function(i,c){var u=W.publish(e,n,r);o.httpService.delete(u).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(function(c){o.realtyChannel.subject(t.ESB_REALTY_PUBLISHED_CHANGE).next({actionGuid:e,entityGuid:n,guid:r,state:!1}),i(c)},c)})},t.prototype.onPublishedChange=function(e){return this.realtyChannel.observe(t.ESB_REALTY_PUBLISHED_CHANGE).subscribe(e)},t.prototype.onSalePublishedChange=function(e){return this.realtyChannel.observe(t.ESB_REALTY_SALE_PUBLISHED_CHANGE).subscribe(e)},t.prototype.remove=function(e,n,r){var o=this;return new Promise(function(i,c){var u=W.remove(e,n,r);o.httpService.delete(u).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(function(c){o.realtyChannel.subject(t.ESB_REALTY_REMOVE).next({actionGuid:e,entityGuid:n,guid:r}),i(c)},c)})},t.prototype.onRemove=function(e){return this.realtyChannel.observe(t.ESB_REALTY_REMOVE).subscribe(e)},t.prototype.addRealtyToFavorite=function(e){var n=this;return new Promise(function(r,o){var i=W.favorite(e);n.httpService.post(i,null).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(function(o){n.realtyChannel.subject(t.ESB_REALTY_FAVORITES_CHANGE).next({guid:e,state:!0}),r(o)},o)})},t.prototype.removeRealtyFromFavorite=function(e){var n=this;return new Promise(function(r,o){var i=W.favorite(e);n.httpService.delete(i).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(function(o){n.realtyChannel.subject(t.ESB_REALTY_FAVORITES_CHANGE).next({guid:e,state:!1}),r(o)},o)})},t.prototype.onFavoriteChange=function(e){return this.realtyChannel.observe(t.ESB_REALTY_FAVORITES_CHANGE).subscribe(e)},t.prototype.load=function(t){var e=this;return new Promise(function(n,r){var o=W.about(t);e.httpService.get(o).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(n,r)})},t.prototype.synchronizeFormMetaInfo=function(){var e=this;return new Promise(function(n){var r=W.getFormLastModified;e.httpService.get(r).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(function(r){var o=function(t){e.processFormMetaInfo(t,r).then(n).catch(n)};e.cache.get(t.LAST_MODIFIED_INFO_KEY).then(function(t){o(t)}).catch(function(){o({})})},function(){n()})})},t.prototype.getRealtyByGuids=function(t){var e=this;return new Promise(function(n,r){var o=W.getByGuids;e.httpService.post(o,t).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(n,r)})},t.prototype.loadList=function(t,n,r){var o=this;return new Promise(function(i,c){var u=new e.URLSearchParams;if(r)for(var a=Object.keys(r),s=0;s<a.length;s++){var p=a[s];u.set(p,r[p])}o.httpService.post(t,n,{params:u}).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(i,c)})},t.prototype.processFormMetaInfo=function(e,n){var r=[],o={},i=!1;e=e||{};for(var c=0,u=n;c<u.length;c++){var a=u[c];a=a||{};var s=a.updated||0,p=a.action_guid||"",f=a.entity_guid||"",h=p+"_"+f;e.hasOwnProperty(h)?e.hasOwnProperty(h)&&(e[h]<s||0==s)&&(r.push(this.cache.removeByTag(h)),i=!0):i=!0,o[h]=s}for(var _=Object.keys(e),l=0;l<_.length;l++){var h=_[l];o.hasOwnProperty(h)||(r.push(this.cache.removeByTag(h)),i=!0)}return i&&r.push(this.cache.set(t.LAST_MODIFIED_INFO_KEY,o)),Promise.all(r)},t.prototype.salePublish=function(e,n,r){var o=this;return new Promise(function(i,c){var u=W.salePublish(e,n,r);o.httpService.put(u,null).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(function(c){o.realtyChannel.subject(t.ESB_REALTY_SALE_PUBLISHED_CHANGE).next({actionGuid:e,entityGuid:n,guid:r,state:!0}),i(c)},c)})},t.prototype.saleUnPublish=function(e,n,r){var o=this;return new Promise(function(i,c){var u=W.saleUnPublish(e,n,r);o.httpService.delete(u).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(function(c){o.realtyChannel.subject(t.ESB_REALTY_SALE_PUBLISHED_CHANGE).next({actionGuid:e,entityGuid:n,guid:r,state:!1}),i(c)},c)})},t}();$.LAST_MODIFIED_INFO_KEY="realty_forms_last_modified_info",$.FULL_FORM_METADATA_KEY="full_form_metadata_info",$.ESB_REALTY_CHANNEL_NAME="realty",$.ESB_REALTY_FAVORITES_CHANGE="favorite.change",$.ESB_REALTY_PUBLISHED_CHANGE="published.change",$.ESB_REALTY_SALE_PUBLISHED_CHANGE="sale_published.change",$.ESB_REALTY_REMOVE="remove",$.decorators=[{type:r.Injectable}],$.ctorParameters=function(){return[{type:P},{type:m},{type:void 0,decorators:[{type:r.Inject,args:["StorageInterface"]}]}]};var Q=function(){function t(t,e){this.httpService=t,this.cache=e}return t.prototype.setRefsEndPoint=function(t){this.refsEndPoint=t},t.prototype.synchronize=function(){var e=this;return new Promise(function(n){var r=e.refsEndPoint+"refs/last-modified";e.httpService.get(r).map(function(t){return t.json()}).map(function(t){return t.data}).subscribe(function(r){var o=function(t){e.processLastModified(t,r).then(n).catch(n)};e.cache.get(t.REFS_LAST_MODIFIED_INFO_KEY).then(function(t){o(t)}).catch(function(){o({})})},function(){n()})})},t.prototype.processLastModified=function(e,n){var r=[],o={},i=!1;e=e||{};for(var c=0,u=n;c<u.length;c++){var a=u[c];a=a||{};var s=a.updated||0,p=a.class_name||null;e.hasOwnProperty(p)?e.hasOwnProperty(p)&&e[p]<s&&(r.push(this.cache.removeByTag(p)),i=!0):i=!0,o[p]=s}for(var f=Object.keys(e),h=0;h<f.length;h++){var _=f[h];o.hasOwnProperty(_)||(r.push(this.cache.removeByTag(_)),i=!0)}return i&&r.push(this.cache.set(t.REFS_LAST_MODIFIED_INFO_KEY,o)),Promise.all(r)},t}();Q.REFS_LAST_MODIFIED_INFO_KEY="refs_last_modified_info",Q.decorators=[{type:r.Injectable}],Q.ctorParameters=function(){return[{type:P},{type:void 0,decorators:[{type:r.Inject,args:["StorageInterface"]}]}]};var Z=function(){function t(){}return t}(),tt=(!0).__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),et=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return tt(e,t),e}(h),nt=(!0).__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),rt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.refName="realty_deal",e}return nt(e,t),e.prototype.getAllDeals=function(t,e){return this.getListAll(t||{},e||"sorder,title")},e}(O);rt.decorators=[{type:r.Injectable}],rt.ctorParameters=function(){return[]};var ot=(!0).__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),it=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return ot(e,t),e.prototype._set=function(t,e){var n=this;return new Promise(function(r,o){try{n._getStorageInstance().then(function(n){n.setItem(t,e),r()}).catch(o)}catch(t){o(t)}})},e.prototype._get=function(t){var e=this;return new Promise(function(n,r){try{e._getStorageInstance().then(function(e){var o=e.getItem(t);null===o?r():n(o)}).catch(r)}catch(t){r(t)}})},e.prototype._remove=function(t){var e=this;return new Promise(function(n,r){try{e._getStorageInstance().then(function(e){e.removeItem(t),n()}).catch(r)}catch(t){r(t)}})},e.prototype._clear=function(){var t=this;return new Promise(function(e,n){try{t._getStorageInstance().then(function(t){t.clear(),e()}).catch(n)}catch(t){n(t)}})},e.prototype._getStorageInstance=function(){return new Promise(function(t,e){try{t(sessionStorage)}catch(t){e(t)}})},e}(H);it.decorators=[{type:r.Injectable}],it.ctorParameters=function(){return[]};var ct=function(){function t(t,e){this.userService=t,this.http=e}return t.prototype.setStorageEndPoint=function(t){this.storageEndPoint=t},t.prototype.deleteFile=function(t){var e=this;return new Promise(function(n,r){var o=e.storageEndPoint+"files/"+t;e.http.delete(o).subscribe(function(t){n()},function(t){r(t)})})},t.prototype.postFile=function(t){var e=this;return new Promise(function(n,r){var o=e.storageEndPoint+"files",i=new FormData,c=new XMLHttpRequest;i.append("data",t,t.name),c.onreadystatechange=function(){if(4===c.readyState)try{if(200===c.status)n(JSON.parse(c.response));else{var t=JSON.parse(c.response);r(t&&t.data?t.data:t)}}catch(t){r(t)}},c.open("POST",o,!0),c.send(i)})},t.prototype.changeAttachment=function(t,e){var n=this;return new Promise(function(r,o){var i=n.storageEndPoint+"files/"+t+"/change",c=new FormData,u=new XMLHttpRequest;c.append("data",e,e.name),u.onreadystatechange=function(){if(4===u.readyState)try{if(200===u.status)r(JSON.parse(u.response));else{var t=JSON.parse(u.response);o(t&&t.data?t.data:t)}}catch(t){o(t)}},u.open("POST",i,!0),u.setRequestHeader(m.USER_TOKEN_NAME,n.userService.getToken()),u.send(c)})},t.prototype.getScaledImageUrl=function(t,e,n,r,o){void 0===r&&(r="outbound"),void 0===o&&(o=95);var i=this.storageEndPoint+"images/scale/"+t+"/"+e+"/"+n;return i+=r?"/"+r:"",i+=o?"/"+o:""},t.prototype.getImageUrl=function(t){return this.storageEndPoint+"files/"+t},t}();ct.decorators=[{type:r.Injectable}],ct.ctorParameters=function(){return[{type:m},{type:P}]};var ut=(!0).__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),at=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return ut(e,t),e}(h),st=(!0).__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),pt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.refName="spec",e}return st(e,t),e.prototype.getSpecializations=function(){return this.getListAll({},"sorder,title")},e}(O);pt.decorators=[{type:r.Injectable}],pt.ctorParameters=function(){return[]};var ft=function(){function t(){}return t.prototype.email=function(t){return/^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i.test(t)},t}();ft.decorators=[{type:r.Injectable}],ft.ctorParameters=function(){return[]};var ht=function(){function t(t,e,n){this.operation=t,this.field=e,this.value=n}return t.prototype.getRequest=function(){return{operation:this.operation,field:this.field,value:this.value}},t}(),_t=function(){function t(t,e){this.operation=t,this.value=e}return t.prototype.getRequest=function(){var t={};if(Array.isArray(this.value)){for(var e=[],n=0;n<this.value.length;n++)e[n]=this.value[n].getRequest();t[this.operation]=e}else t[this.operation]=this.value.getRequest();return t},t}(),lt=function(){function t(){}return t.prototype.or=function(t){return new _t("or",t)},t.prototype.and=function(t){return new _t("and",t)},t.prototype.eq=function(t,e){return new ht("eq",t,e)},t.prototype.ne=function(t,e){return new ht("ne",t,e)},t.prototype.gt=function(t,e){return new ht("gt",t,e)},t.prototype.gte=function(t,e){return new ht("gte",t,e)},t.prototype.lt=function(t,e){return new ht("lt",t,e)},t.prototype.lte=function(t,e){return new ht("lte",t,e)},t.prototype.in=function(t,e){return new ht("in",t,e)},t.prototype.nin=f