@stratusjs/idx
Version:
AngularJS idx/property Service and Components bundle to be used as an add on to StratusJS
1 lines • 308 kB
JavaScript
System.register(["lodash","@stratusjs/runtime/stratus","angular","@stratusjs/angularjs/services/model","@stratusjs/angularjs/services/collection","@stratusjs/core/misc","@stratusjs/core/environment","@stratusjs/idx/listTrac","@stratusjs/core/dom","moment","@stratusjs/angularjs-extras/filters/numeral","@stratusjs/angular","angular-material","angular-sanitize","@stratusjs/angularjs-extras","@stratusjs/swiper"],function(){"use strict";var uniqueId,clone,isString,isPlainObject,isArray,isEmpty,isEqual,isNumber,isObject,get,extend,isDate,isUndefined,isNil,cloneDeep,forEach,trim,camelCase,compact,union,_,includes,intersection,map,throttle,Stratus,element,Model,Collection,getHashBangParam,setHashBangParam,isJSON,safeUniqueId,hydrate,cookie,DOMComplete,moment,numeralFormat;return{setters:[function(module){uniqueId=module.uniqueId,clone=module.clone,isString=module.isString,isPlainObject=module.isPlainObject,isArray=module.isArray,isEmpty=module.isEmpty,isEqual=module.isEqual,isNumber=module.isNumber,isObject=module.isObject,get=module.get,extend=module.extend,isDate=module.isDate,isUndefined=module.isUndefined,isNil=module.isNil,cloneDeep=module.cloneDeep,forEach=module.forEach,trim=module.trim,camelCase=module.camelCase,compact=module.compact,union=module.union,_=module.default,includes=module.includes,intersection=module.intersection,map=module.map,throttle=module.throttle},function(module){Stratus=module.Stratus},function(module){element=module.element},function(module){Model=module.Model},function(module){Collection=module.Collection},function(module){getHashBangParam=module.getHashBangParam,setHashBangParam=module.setHashBangParam,isJSON=module.isJSON,safeUniqueId=module.safeUniqueId,hydrate=module.hydrate},function(module){cookie=module.cookie},null,function(module){DOMComplete=module.DOMComplete},function(module){moment=module.default},function(module){numeralFormat=module.numeralFormat},null,null,null,null,null],execute:function(){var __awaiter$b=function(thisArg,_arguments,P,generator){return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator.throw(value))}catch(e){reject(e)}}function step(result){var value;result.done?resolve(result.value):(value=result.value,value instanceof P?value:new P(function(resolve){resolve(value)})).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})};const angularJsService=($http,$mdToast,$q,$rootScope,$window,ListTrac,orderByFilter)=>{const sharedValues={contactUrl:null,contactCommentVariable:null,contact:null,integrations:{analytics:{},maps:{}}},defaultWhereOptions={City:[],eCity:[],UnparsedAddress:[],StreetAddress:[],eStreetAddress:[],Location:"",eLocation:"",Status:[],ListingId:[],ListingType:[],CountyOrParish:[],eCountyOrParish:[],MLSAreaMajor:[],eMLSAreaMajor:[],MLSAreaMinor:[],eMLSAreaMinor:[],SubdivisionName:[],eSubdivisionName:[],Neighborhood:[],eNeighborhood:[],PostalCode:[],CityRegion:[],eCityRegion:[],AgentLicense:[],OfficeNumber:[],OfficeName:[]};let refreshLoginTimer,defaultPageTitle,idxServicesEnabled=[],tokenRefreshURL="/ajax/request?class=property.token_auth&method=getToken",sessionInitialized=!1;const instance={disclaimer:{},map:{},member:{details:{},list:{},search:{}},office:{details:{},list:{},search:{}},property:{details:{},list:{},search:{}}},instanceLink={Disclaimer:{},List:{},Map:{},Search:{}},instanceOnEmitters={},session={services:[],lastCreated:new Date,lastTtl:0,contacts:[]},urlOptions={Listing:{},Search:{}},lastQueries={whereFilter:{},pages:[],perPage:0,time:null};function emitManual(emitterName,uid,$scope,var1,var2,var3){var _a,_b,_c;Object.prototype.hasOwnProperty.call(instanceOnEmitters,uid)&&Object.prototype.hasOwnProperty.call(instanceOnEmitters[uid],emitterName)&&Object.values(instanceOnEmitters[uid][emitterName]).forEach(emitter=>{try{emitter($scope,var1,var2,var3)}catch(e){console.error(e,"issue sending back emitter on",uid,emitterName,emitter)}}),"init"===emitterName&&(null!==(_a=instanceOnEmitters[uid])&&void 0!==_a||(instanceOnEmitters[uid]={}),null!==(_b=(_c=instanceOnEmitters[uid])[emitterName])&&void 0!==_b||(_c[emitterName]={}))}function getIdxServices(){return idxServicesEnabled}function setIdxServices(services){idxServicesEnabled=services}function tokenKeepAuth(keepAlive=!1){return $q((resolve,reject)=>__awaiter$b(this,void 0,void 0,function*(){try{Object.keys(session.services).length<1||session.expires<new Date(Date.now()+5e3)?(yield tokenRefresh(keepAlive,!0),resolve()):resolve()}catch(err){console.error("tokenKeepAuth Error:",err),reject(err)}}))}function tokenRefresh(keepAlive=!1,cacheReset=!1){return $q((resolve,reject)=>{let additionalQueries="&apiVersion=3.13.0";0!==idxServicesEnabled.length&&idxServicesEnabled.forEach(service=>{additionalQueries+=`&service[]=${service}`}),cacheReset&&(additionalQueries+="&cacheReset=true"),$http({method:"GET",url:tokenRefreshURL+additionalQueries}).then(response=>{"object"==typeof response&&Object.prototype.hasOwnProperty.call(response,"data")&&Object.prototype.hasOwnProperty.call(response.data,"services")&&Object.prototype.hasOwnProperty.call(response.data.services,"length")?(!function(response,keepAlive=!1){session.services={},response.data.services.forEach(service=>{Object.prototype.hasOwnProperty.call(service,"id")&&(Object.prototype.hasOwnProperty.call(service,"fetchTime")||(service.fetchTime={Property:null,Media:null,Member:null,Office:null,OpenHouse:null}),Object.prototype.hasOwnProperty.call(service,"analyticsEnabled")&&null!==service.analyticsEnabled||(service.analyticsEnabled=[]),Object.prototype.hasOwnProperty.call(service,"logo")&&null!==service.logo||(service.logo={default:null}),Object.prototype.hasOwnProperty.call(service,"mandatoryLogo")&&null!==service.mandatoryLogo||(service.mandatoryLogo=[]),session.services[service.id]=service,session.lastCreated=new Date(service.created),session.lastTtl=service.ttl,session.expires=new Date(session.lastCreated.getTime()+1e3*(session.lastTtl-15)))}),Object.prototype.hasOwnProperty.call(response.data,"contactUrl")&&""!==response.data.contactUrl&&(sharedValues.contactUrl=response.data.contactUrl);Object.prototype.hasOwnProperty.call(response.data,"contactCommentVariable")&&""!==response.data.contactCommentVariable&&(sharedValues.contactCommentVariable=response.data.contactCommentVariable);Object.prototype.hasOwnProperty.call(response.data,"contact")&&(sharedValues.contact={name:"",emails:{},locations:{},phones:{},socialUrls:{},urls:{}},Object.prototype.hasOwnProperty.call(response.data,"site")&&isString(response.data.site)&&""!==response.data.site&&(sharedValues.contact.name=response.data.site),Object.prototype.hasOwnProperty.call(response.data,"contactName")&&isString(response.data.contactName)&&""!==response.data.site&&(sharedValues.contact.name=response.data.contactName),Object.prototype.hasOwnProperty.call(response.data,"contact")&&isPlainObject(response.data.contact)&&(Object.prototype.hasOwnProperty.call(response.data.contact,"emails")&&isPlainObject(response.data.contact.emails)&&(sharedValues.contact.emails=response.data.contact.emails),Object.prototype.hasOwnProperty.call(response.data.contact,"locations")&&isPlainObject(response.data.contact.locations)&&(sharedValues.contact.locations=response.data.contact.locations),Object.prototype.hasOwnProperty.call(response.data.contact,"phones")&&isPlainObject(response.data.contact.phones)&&(sharedValues.contact.phones=response.data.contact.phones),Object.prototype.hasOwnProperty.call(response.data.contact,"socialUrls")&&isPlainObject(response.data.contact.socialUrls)&&(sharedValues.contact.socialUrls=response.data.contact.socialUrls),Object.prototype.hasOwnProperty.call(response.data.contact,"urls")&&isPlainObject(response.data.contact.urls)&&(sharedValues.contact.urls=response.data.contact.urls)));Object.prototype.hasOwnProperty.call(response.data,"integrations")&&(Object.prototype.hasOwnProperty.call(response.data.integrations,"analytics")&&(Object.prototype.hasOwnProperty.call(response.data.integrations.analytics,"googleAnalytics")&&Object.prototype.hasOwnProperty.call(response.data.integrations.analytics.googleAnalytics,"accountId")&&isString(response.data.integrations.analytics.googleAnalytics.accountId)&&""!==response.data.integrations.analytics.googleAnalytics.accountId&&(sharedValues.integrations.analytics.googleAnalytics={accountId:response.data.integrations.analytics.googleAnalytics.accountId}),Object.prototype.hasOwnProperty.call(response.data.integrations.analytics,"listTrac")&&Object.prototype.hasOwnProperty.call(response.data.integrations.analytics.listTrac,"accountId")&&isString(response.data.integrations.analytics.listTrac.accountId)&&""!==response.data.integrations.analytics.listTrac.accountId&&(sharedValues.integrations.analytics.listTrac={accountId:response.data.integrations.analytics.listTrac.accountId},ListTrac.setAccountId(sharedValues.integrations.analytics.listTrac.accountId))),Object.prototype.hasOwnProperty.call(response.data.integrations,"maps")&&Object.prototype.hasOwnProperty.call(response.data.integrations.maps,"googleMaps")&&Object.prototype.hasOwnProperty.call(response.data.integrations.maps.googleMaps,"publicKey")&&isString(response.data.integrations.maps.googleMaps.publicKey)&&""!==response.data.integrations.maps.googleMaps.publicKey&&(sharedValues.integrations.maps.googleMaps={publicKey:response.data.integrations.maps.googleMaps.publicKey}));sessionInitialized||emitManual("sessionInit","Idx",null);emitManual("sessionRefresh","Idx",null),sessionInitialized=!0,keepAlive&&function(){clearTimeout(refreshLoginTimer),refreshLoginTimer=setTimeout(()=>__awaiter$b(this,void 0,void 0,function*(){yield tokenRefresh()}),1e3*(session.lastTtl-15))}()}(response,keepAlive),resolve()):reject(tokenHandleBadResponse(response))},response=>{reject(tokenHandleBadResponse(response))})})}function tokenHandleBadResponse(response){let errorMessage="Token supplied is invalid or blank";return"object"==typeof response&&Object.prototype.hasOwnProperty.call(response,"data")&&Object.prototype.hasOwnProperty.call(response.data,"errors")&&Object.prototype.hasOwnProperty.call(response.data.errors,"length")&&(errorMessage=response.data.errors),$mdToast.show($mdToast.simple().textContent("Unable to authorize Idx feed!").toastClass("errorMessage").position("top right").hideDelay(5e3)),errorMessage}function updateFetchTime(apiFetch,modelName,serviceId){const fetchTime=apiFetch.header.get("x-fetch-time");if(fetchTime){const oldTime=session.services[serviceId].fetchTime[modelName];session.services[serviceId].fetchTime[modelName]=new Date(fetchTime),isDate(oldTime)&&isDate(session.services[serviceId].fetchTime[modelName])&&oldTime.getTime()===session.services[serviceId].fetchTime[modelName].getTime()||emitManual("fetchTimeUpdate","Idx",null,serviceId,modelName,session.services[serviceId].fetchTime[modelName])}}function modelInjectProperty(modelDatas,properties){return $q.all(modelDatas.map(modelData=>{extend(modelData,properties)}))}function compileGenericWhereFilter(where,searchPossibilities){const whereQuery={},andStatement=[],searchFunctions={valueEquals:(searchObject,value)=>{whereQuery[searchObject.apiField]=value},stringLike:(searchObject,value)=>{isEmpty(value)||(whereQuery[searchObject.apiField]={like:value,options:"i"})},stringLikeArray:(searchObject,value)=>{if((value="string"==typeof value?[value]:value).length>1){const stringLikeArrayOrStatement=[];value.forEach(requestedValue=>{isEmpty(requestedValue)||stringLikeArrayOrStatement.push({[searchObject.apiField]:{like:requestedValue,options:"i"}})}),isEmpty(stringLikeArrayOrStatement)||andStatement.push({or:stringLikeArrayOrStatement})}else 1===value.length&&(isEmpty(value[0])||(whereQuery[searchObject.apiField]={like:value[0],options:"i"}))},stringIncludesArray:(searchObject,value)=>{(value="string"==typeof value?[value]:value).length>1?whereQuery[searchObject.apiField]={inq:value}:1===value.length&&(whereQuery[searchObject.apiField]=value[0])},stringIncludesArrayAlternative:(searchObject,value)=>{(value="string"==typeof value?[value]:value).length>1?whereQuery[searchObject.apiField]={in:value}:1===value.length&&(whereQuery[searchObject.apiField]=value[0])},numberEqualGreater:(searchObject,value)=>{value&&0!==value&&(Object.prototype.hasOwnProperty.call(whereQuery,searchObject.apiField)&&Object.prototype.hasOwnProperty.call(whereQuery[searchObject.apiField],"lte")?whereQuery[searchObject.apiField]={between:[parseInt(value,10),parseInt(get(whereQuery[searchObject.apiField],"lte"),10)]}:whereQuery[searchObject.apiField]={gte:parseInt(value,10)})},numberEqualLess:(searchObject,value)=>{value&&0!==value&&(Object.prototype.hasOwnProperty.call(whereQuery,searchObject.apiField)&&Object.prototype.hasOwnProperty.call(whereQuery[searchObject.apiField],"gte")?whereQuery[searchObject.apiField]={between:[parseInt(get(whereQuery[searchObject.apiField],"gte"),10),parseInt(value,10)]}:whereQuery[searchObject.apiField]={lte:parseInt(value,10)})},andOr:(searchObject,value)=>{if(Object.prototype.hasOwnProperty.call(searchObject,"andOr")){const andOrOrStatement=[];searchObject.andOr.forEach(orObject=>{"valueEquals"===orObject.type?andOrOrStatement.push({[orObject.apiField]:value}):"stringLike"===orObject.type?isEmpty(value)||andOrOrStatement.push({[orObject.apiField]:{like:value,options:"i"}}):"stringLikeArray"===orObject.type?(value="string"==typeof value?[value]:value).length>1?value.forEach(requestedValue=>{isEmpty(requestedValue)||andOrOrStatement.push({[orObject.apiField]:{like:requestedValue,options:"i"}})}):1===value.length&&(isEmpty(value[0])||andOrOrStatement.push({[orObject.apiField]:{like:value[0],options:"i"}})):"stringIncludesArray"===orObject.type&&((value="string"==typeof value?[value]:value).length>1?andOrOrStatement.push({[orObject.apiField]:{inq:value}}):1===value.length&&andOrOrStatement.push({[orObject.apiField]:value[0]}))}),isEmpty(andOrOrStatement)||(andOrOrStatement.length>1?andStatement.push({or:andOrOrStatement}):1===andOrOrStatement.length&&andStatement.push(andOrOrStatement[0]))}}};for(const[widgetField,searchObject]of Object.entries(searchPossibilities))Object.prototype.hasOwnProperty.call(searchObject,"apiField")||(searchObject.apiField=widgetField),Object.prototype.hasOwnProperty.call(searchFunctions,searchObject.type)&&Object.prototype.hasOwnProperty.call(where,widgetField)&&""!==where[widgetField]&&searchFunctions[searchObject.type](searchObject,where[widgetField]);return isEmpty(andStatement)||(whereQuery.and=andStatement),whereQuery}function compilePropertyWhereFilter(where){return compileGenericWhereFilter(where,{ListingKey:{type:"valueEquals"},ListingId:{type:"stringIncludesArray"},ListingType:{type:"stringIncludesArray"},Status:{type:"stringIncludesArray"},ListPriceMin:{type:"numberEqualGreater",apiField:"_BestPrice"},ListPriceMax:{type:"numberEqualLess",apiField:"_BestPrice"},Bathrooms:{type:"numberEqualGreater"},Bedrooms:{type:"numberEqualGreater",apiField:"BedroomsTotal"},AgentLicense:{type:"stringIncludesArray"},OfficeNumber:{type:"stringIncludesArray"},OfficeName:{type:"stringIncludesArray"},OpenHouseOnly:{type:"valueEquals"},UnparsedAddress:{type:"stringLikeArray"},StreetAddress:{apiField:"_StreetAddress",type:"stringLikeArray"},eStreetAddress:{apiField:"_StreetAddress",type:"stringIncludesArray"},City:{type:"stringLikeArray"},eCity:{apiField:"City",type:"stringIncludesArray"},PostalCode:{type:"stringIncludesArray"},CountyOrParish:{type:"stringLikeArray"},eCountyOrParish:{apiField:"CountyOrParish",type:"stringIncludesArray"},SubdivisionName:{type:"stringLikeArray"},eSubdivisionName:{apiField:"SubdivisionName",type:"stringIncludesArray"},MLSAreaMajor:{type:"stringLikeArray"},eMLSAreaMajor:{apiField:"MLSAreaMajor",type:"stringIncludesArray"},MLSAreaMinor:{type:"stringLikeArray"},eMLSAreaMinor:{apiField:"MLSAreaMinor",type:"stringIncludesArray"},CityRegion:{type:"stringLikeArray"},eCityRegion:{apiField:"CityRegion",type:"stringIncludesArray"},Location:{type:"andOr",andOr:[{apiField:"City",type:"stringLikeArray"},{apiField:"CityRegion",type:"stringLikeArray"},{apiField:"CountyOrParish",type:"stringLikeArray"},{apiField:"SubdivisionName",type:"stringLikeArray"},{apiField:"MLSAreaMajor",type:"stringLikeArray"},{apiField:"MLSAreaMinor",type:"stringLikeArray"},{apiField:"PostalCode",type:"stringLikeArray"},{apiField:"UnparsedAddress",type:"stringLikeArray"},{apiField:"ListingId",type:"stringIncludesArray"}]},eLocation:{type:"andOr",andOr:[{apiField:"City",type:"stringIncludesArray"},{apiField:"CityRegion",type:"stringIncludesArray"},{apiField:"CountyOrParish",type:"stringIncludesArray"},{apiField:"SubdivisionName",type:"stringIncludesArray"},{apiField:"MLSAreaMajor",type:"stringIncludesArray"},{apiField:"MLSAreaMinor",type:"stringIncludesArray"},{apiField:"PostalCode",type:"stringIncludesArray"},{apiField:"ListingId",type:"stringIncludesArray"}]},Neighborhood:{type:"andOr",andOr:[{apiField:"CityRegion",type:"stringLikeArray"},{apiField:"SubdivisionName",type:"stringLikeArray"},{apiField:"MLSAreaMajor",type:"stringLikeArray"},{apiField:"MLSAreaMinor",type:"stringLikeArray"}]},eNeighborhood:{type:"andOr",andOr:[{apiField:"CityRegion",type:"stringIncludesArray"},{apiField:"SubdivisionName",type:"stringIncludesArray"},{apiField:"MLSAreaMajor",type:"stringIncludesArray"},{apiField:"MLSAreaMinor",type:"stringIncludesArray"}]}})}function compileMemberWhereFilter(where){return compileGenericWhereFilter(where,{MemberKey:{type:"valueEquals"},MemberStateLicense:{type:"valueEquals"},MemberNationalAssociationId:{type:"valueEquals"},MemberStatus:{type:"valueEquals"},MemberFullName:{type:"stringLike"}})}function compileOfficeWhereFilter(where){return compileGenericWhereFilter(where,{OfficeKey:{type:"valueEquals"},OfficeNationalAssociationId:{type:"valueEquals"},OfficeStatus:{type:"valueEquals"},OfficeNumber:{type:"stringIncludesArray"},OfficeName:{type:"stringLikeArray"}})}function compileGenericFilter(options,filterFunction){options.perPage||(options.perPage=20);let activeServices=0;"number"!=typeof options.service&&"string"!=typeof options.service||(options.service=[options.service]),options.service.forEach(serviceId=>{Object.prototype.hasOwnProperty.call(session.services,serviceId)&&activeServices++}),activeServices=activeServices>=1?activeServices:1;let skip=0;options.page&&(skip=(options.page-1)*options.perPage/activeServices);const filterQuery={where:filterFunction(options.where),limit:options.perPage,skip};options.fields&&(filterQuery.fields=options.fields),options.order&&options.order.length>0&&(filterQuery.order=function(orderUnparsed){"string"==typeof orderUnparsed&&(orderUnparsed=orderUnparsed.split(","));const orderQuery=[];return orderUnparsed.forEach(orderName=>{let direction="ASC";"-"===orderName.charAt(0)&&(orderName=orderName.substring(1,orderName.length),direction="DESC"),orderQuery.push(orderName+" "+direction)}),orderQuery}(options.order));const includes=[];return Object.entries({images:{relation:"Images",scope:{order:"Order",fields:["MediaURL"]}},openhouses:{relation:"OpenHouses",scope:{order:"OpenHouseStartTime",fields:["OpenHouseStartTime","OpenHouseEndTime"]}},office:{relation:"Office",scope:{fields:["OfficeName","OfficeKey"]}},managingBroker:{relation:"Member",scope:{fields:["MemberFullName","MemberStateLicense","MemberKey"]}},members:{relation:"Member",scope:{fields:["MemberFullName","MemberStateLicense","MemberKey"]}}}).forEach(([optionName,includeItem])=>{if(Object.prototype.hasOwnProperty.call(options,optionName)){const option=options[optionName];"object"==typeof option&&(Object.prototype.hasOwnProperty.call(option,"fields")?"*"===option.fields?delete includeItem.scope.fields:includeItem.scope.fields=option.fields:Object.prototype.hasOwnProperty.call(option,"limit")&&isNumber(option.limit)&&(includeItem.scope.limit=option.limit)),!1!==option&&includes.push(includeItem)}}),1===includes.length?filterQuery.include=includes[0]:includes.length>1&&(filterQuery.include=includes),filterQuery.fields.length<=0&&delete filterQuery.fields,filterQuery}function compilePropertyFilter(options){return compileGenericFilter(options,compilePropertyWhereFilter)}function compileMemberFilter(options){return compileGenericFilter(options,compileMemberWhereFilter)}function compileOfficeFilter(options){return compileGenericFilter(options,compileOfficeWhereFilter)}function getUrlOptionsPath(defaultOptions){null!=defaultOptions||(defaultOptions={});let path="";const searchOptionNames=Object.keys(urlOptions.Search);if(searchOptionNames.length>0){let searchPath="";searchOptionNames.forEach(searchOptionName=>{if(Object.prototype.hasOwnProperty.call(urlOptions.Search,searchOptionName)&&null!==urlOptions.Search[searchOptionName]){let defaultValue=defaultOptions[searchOptionName];const compareValue=urlOptions.Search[searchOptionName];!isArray(defaultValue)&&isArray(compareValue)&&(defaultValue=[defaultValue]),isEqual(defaultValue,compareValue)||(searchPath+=searchOptionName+"/"+compareValue+"/")}}),""!==searchPath&&(path+="Search/"+searchPath)}return Object.prototype.hasOwnProperty.call(urlOptions.Listing,"service")&&Object.prototype.hasOwnProperty.call(urlOptions.Listing,"ListingKey")&&!isNaN(urlOptions.Listing.service)&&urlOptions.Listing.ListingKey&&(path+="Listing/"+urlOptions.Listing.service+"/"+urlOptions.Listing.ListingKey+"/",Object.prototype.hasOwnProperty.call(urlOptions.Listing,"address")&&urlOptions.Listing.address&&"string"==typeof urlOptions.Listing.address&&(path+=urlOptions.Listing.address.replace(/ /g,"-")+"/")),path.length&&(path="/"+path),path}function getSingularApiModelName(name){let apiModelSingular="Property";switch(name){case"Properties":apiModelSingular="Property";break;case"Members":apiModelSingular="Member";break;case"Offices":apiModelSingular="Office";break;case"OpenHouses":apiModelSingular="OpenHouse"}return apiModelSingular}function genericSearchCollection(uid,collectionVarName,options={},refresh=!1,moduleName,apiModel,compileFilterFunction){var _a,_b,_c,_d,_e,_f;return __awaiter$b(this,void 0,void 0,function*(){null!==(_a=options.service)&&void 0!==_a||(options.service=[]),null!==(_b=options.where)&&void 0!==_b||(options.where={}),null!==(_c=options.order)&&void 0!==_c||(options.order=[]),null!==(_d=options.page)&&void 0!==_d||(options.page=1),null!==(_e=options.perPage)&&void 0!==_e||(options.perPage=10),options.images||(options.images=!1),null!==(_f=options.fields)&&void 0!==_f||(options.fields=["_id"]),"string"==typeof options.order&&(options.order=options.order.split(",")),"number"==typeof options.service&&(options.service=[options.service]),0===options.service.length&&(options.service=[0]);const apiModelSingular=getSingularApiModelName(apiModel),collection=function(uid,moduleName,scopedCollectionVarName){let collection;return Object.keys(instance[moduleName].list).forEach(listName=>{!collection&&listName===uid&&Object.prototype.hasOwnProperty.call(instance[moduleName].list,listName)&&Object.prototype.hasOwnProperty.call(instance[moduleName].list[listName],scopedCollectionVarName)&&instance[moduleName].list[listName][scopedCollectionVarName]instanceof Collection&&(collection=instance[moduleName].list[listName][scopedCollectionVarName])}),collection||(collection=new Collection),Object.keys(instance[moduleName].list).forEach(listName=>{listName!==uid||Object.prototype.hasOwnProperty.call(instance[moduleName].list[listName],scopedCollectionVarName)&&instance[moduleName].list[listName][scopedCollectionVarName]===collection||(instance[moduleName].list[listName][scopedCollectionVarName]=collection)},this),collection}(uid,moduleName,collectionVarName),filterQuery=compileFilterFunction(options),collections=[];if(!isEqual(lastQueries.whereFilter,filterQuery.where)||lastQueries.order!==options.order||lastQueries.perPage!==options.perPage||refresh?(collection.models.splice(0,collection.models.length),refresh=!0,lastQueries.pages=[],filterQuery.count=!0):refresh=!1,collection.models.length<options.page*options.perPage){if(collection.pending=!0,Object.keys(instance[moduleName].list).forEach(listName=>{instance[moduleName].list[listName].$applyAsync()}),options.page>1&&!lastQueries.pages.includes(options.page-1,options.page-2)){filterQuery.limit=options.perPage*options.page,filterQuery.skip=0;for(let addPage=1;addPage<options.page;addPage++)lastQueries.pages.push(addPage)}if(0!==options.service.length?setIdxServices(options.service):options.service=getIdxServices(),yield tokenKeepAuth(),0===options.service.length&&(options.service=Object.keys(session.services)),options.service.forEach(serviceId=>{var _a;if(Object.prototype.hasOwnProperty.call(session.services,serviceId)){const filterQueryCustom=clone(filterQuery);refresh||(filterQueryCustom.skip=null!==(_a=get(collection.meta,`data.recordCounts[${serviceId}]`))&&void 0!==_a?_a:0);const request={serviceId,urlRoot:session.services[serviceId].host,target:apiModel+"/search",api:{filter:filterQueryCustom,meta:{action:"search",format:"reso"},route:{controller:apiModelSingular}}};collections.push(function(request){request.direct=!0,request.api&&(request.api.apiVersion="3.13.0");const collection=new Collection(request);return request.api&&collection.meta.set("api",isJSON(request.api)?JSON.parse(request.api):request.api),collection}(request))}}),yield function(originalCollection,collections,modelName,append=!1){return __awaiter$b(this,void 0,void 0,function*(){originalCollection.pending=!0,originalCollection.completed=!1;let maxCount=0,totalCount=0;const fetchPromises=[];return collections.forEach(collection=>{const options={};null!==session.services[collection.serviceId].token&&(options.headers={Authorization:session.services[collection.serviceId].token}),fetchPromises.push($q(resolve=>__awaiter$b(this,void 0,void 0,function*(){yield collection.fetch("POST",null,options),yield modelInjectProperty(collection.models,{_ServiceId:collection.serviceId}),updateFetchTime(collection,modelName,collection.serviceId);const maxRecords=collection.header.get("x-max-count"),countRecords=collection.header.get("x-total-count");maxRecords&&(maxCount+=parseInt(maxRecords,10)),countRecords&&(totalCount+=parseInt(countRecords,10),maxRecords||(maxCount+=parseInt(countRecords,10))),resolve(collection.models)})))}),append||originalCollection.models.splice(0,originalCollection.models.length),$q.all(fetchPromises).then(fetchedData=>__awaiter$b(this,void 0,void 0,function*(){return yield $q.all(fetchedData.map(models=>{isArray(models)&&originalCollection.models.push(...models)})),originalCollection})).then(()=>(originalCollection.header.set("x-max-count",maxCount),originalCollection.header.set("x-total-count",totalCount),originalCollection.meta.set("fetchDate",new Date),originalCollection.pending=!1,originalCollection.completed=!0,originalCollection.filtering=!1,originalCollection.paginate=!1,originalCollection))})}(collection,collections,apiModelSingular,!refresh),refresh){const maxRecords=collection.header.get("x-max-count")||0,totalRecords=collection.header.get("x-total-count")||0;collection.meta.set("maxRecords",maxRecords),collection.meta.set("totalRecords",totalRecords),collection.meta.set("totalPages",Math.ceil((maxRecords||totalRecords)/options.perPage))}!function(collection,propertyNames,reverse=!1){if(propertyNames){const orderPropertyNames=isArray(propertyNames)?clone(propertyNames):[clone(propertyNames)];orderPropertyNames.forEach((item,index)=>{"BestPrice"===item?orderPropertyNames[index]="_BestPrice":"-BestPrice"===item&&(orderPropertyNames[index]="-_BestPrice"),"Status"===item?orderPropertyNames[index]="_Status":"-Status"===item&&(orderPropertyNames[index]="-_Status")}),collection.models=orderByFilter(collection.models,orderPropertyNames,reverse)}}(collection,options.order),collection.models.length>options.page*options.perPage&&collection.models.splice(options.page*options.perPage,collection.models.length);const recordCounts={};yield $q.all(collection.models.map(model=>{var _a,_b;null!==(_a=recordCounts[_b=model._ServiceId])&&void 0!==_a||(recordCounts[_b]=0),recordCounts[model._ServiceId]++})),collection.meta.set("recordCounts",recordCounts),Object.keys(instance[moduleName].list).forEach(listName=>{instance[moduleName].list[listName].$applyAsync()})}return lastQueries.whereFilter=clone(filterQuery.where),lastQueries.order=options.order,lastQueries.perPage=options.perPage,lastQueries.pages.push(options.page),lastQueries.time=new Date,collection})}function genericSearchModel($scope,modelVarName,options={},apiModel,compileFilterFunction){var _a,_b,_c;return __awaiter$b(this,void 0,void 0,function*(){yield tokenKeepAuth(),null!==(_a=options.service)&&void 0!==_a||(options.service=0),null!==(_b=options.where)&&void 0!==_b||(options.where={}),options.images||(options.images=!1),null!==(_c=options.fields)&&void 0!==_c||(options.fields=[]),options.perPage=1,isArray(options.service)&&(options.service=options.service[0]);const apiModelSingular=getSingularApiModelName(apiModel);let model;if(Object.prototype.hasOwnProperty.call($scope,modelVarName)&&(model=$scope[modelVarName]),model||(model=new Model),Object.prototype.hasOwnProperty.call($scope,modelVarName)&&$scope[modelVarName]===model||($scope[modelVarName]=model),Object.prototype.hasOwnProperty.call(session.services,options.service)){const tempModel=function(request){request.api&&!isString(request.api)&&(request.api.apiVersion="3.13.0");const model=new Model(request);return Object.prototype.hasOwnProperty.call(request,"api")&&request.api&&model.meta.set("api",isJSON(request.api)?JSON.parse(request.api):request.api),Object.prototype.hasOwnProperty.call(request,"serviceId")&&(model.serviceId=request.serviceId),model}({serviceId:options.service,urlRoot:session.services[options.service].host,target:apiModel+"/search",api:{filter:compileFilterFunction(options),meta:{action:"search",format:"reso"},route:{controller:apiModelSingular}}});(function(originalModel,newModel,modelName){return __awaiter$b(this,void 0,void 0,function*(){originalModel.pending=!0,originalModel.completed=!1;const fetchPromises=[],options={};null!==session.services[newModel.serviceId].token&&(options.headers={Authorization:session.services[newModel.serviceId].token}),fetchPromises.push($q(resolve=>__awaiter$b(this,void 0,void 0,function*(){yield newModel.fetch("POST",null,options),yield modelInjectProperty([newModel.data],{_ServiceId:newModel.serviceId}),updateFetchTime(newModel,modelName,newModel.serviceId),resolve(newModel.data)})));const fetchedData=yield $q.all(fetchPromises);return yield $q.all(fetchedData.map(data=>{originalModel.data=data})),originalModel.meta.set("fetchDate",new Date),originalModel.pending=!1,originalModel.completed=!0,originalModel})})(model,tempModel,apiModelSingular).then(()=>{$scope.$applyAsync()})}return lastQueries.time=new Date,$scope[modelVarName]})}function getFriendlyStatus(property,preferredStatus="Closed"){let statusName="";if(Object.prototype.hasOwnProperty.call(property,"MlsStatus")&&""!==property.MlsStatus?statusName=property.MlsStatus:Object.prototype.hasOwnProperty.call(property,"StandardStatus")&&""!==property.StandardStatus&&(statusName=property.StandardStatus),""!==statusName)switch(statusName){case"Act Cont Release":case"Act Cont Show":case"Contingent - Release":case"Contingent - Show":case"Contingent-Release":case"Contingent-Show":statusName="Contingent";break;default:statusName=getFriendlyClosedStatus(property,statusName,preferredStatus)}return statusName}function getFriendlyClosedStatus(property,statusName,preferredStatus="Closed"){if(""!==statusName)if("Closed"===preferredStatus)switch(statusName){case"Sold":case"Leased/Option":case"Leased/Rented":statusName="Closed"}else switch(statusName){case"Closed":case"Sold":statusName="Sold",Object.prototype.hasOwnProperty.call(property,"_IsRental")&&property._IsRental&&(statusName=preferredStatus);break;case"Leased/Option":case"Leased/Rented":statusName=preferredStatus}return statusName}function getStreetAddress(property){if(Object.prototype.hasOwnProperty.call(property,"StreetName")&&""!==property.StreetName||!Object.prototype.hasOwnProperty.call(property,"UnparsedAddress")||""===property.UnparsedAddress){const addressParts=[];return Object.prototype.hasOwnProperty.call(property,"StreetNumberNumeric")&&isNumber(property.StreetNumberNumeric)&&property.StreetNumberNumeric>0?addressParts.push(property.StreetNumberNumeric.toString()):Object.prototype.hasOwnProperty.call(property,"StreetNumber")&&""!==property.StreetNumber&&addressParts.push(property.StreetNumber),["StreetDirPrefix","StreetName","StreetSuffix","StreetSuffixModifier","StreetDirSuffix","UnitNumber"].forEach(addressPart=>{Object.prototype.hasOwnProperty.call(property,addressPart)&&("StreetSuffix"===addressPart&&"None"===property[addressPart]&&(property[addressPart]=""),"UnitNumber"===addressPart&&addressParts.push("Unit"),isEmpty(property[addressPart])||addressParts.push(property[addressPart]))}),addressParts.join(" ")}return property.UnparsedAddress||""}function getNestedPathValue(currentNest,pathPieces){const currentPiece=pathPieces.shift();return pathPieces[0]?getNestedPathValue(currentNest[currentPiece],pathPieces):Object.prototype.hasOwnProperty.call(currentNest,currentPiece)?currentNest[currentPiece]:null}function updateNestedPathValue(currentNest,pathPieces,value){return __awaiter$b(this,void 0,void 0,function*(){const currentPiece=pathPieces.shift();return currentPiece?pathPieces[0]?updateNestedPathValue(currentNest[currentPiece],pathPieces,value):Object.prototype.hasOwnProperty.call(currentNest,currentPiece)&&!isArray(currentNest[currentPiece])&&isArray(value)?void console.warn("updateNestedPathValue couldn't connect",currentPiece," as value given is array, but value stored is not: ",clone(currentNest),"It may need to be initialized first (as an array)"):(!isArray(currentNest[currentPiece])||isArray(value)||isJSON(value)||(value=""===value?[]:value.split(",")),isArray(value)||!isObject(currentNest[currentPiece])&&!isJSON(value)?currentNest[currentPiece]=clone(value):currentNest[currentPiece]=JSON.parse(value),value):(console.warn("updateNestedPathValue couldn't find",currentPiece,"in",clone(currentNest),"It may need to be initialized first"),null)})}return{apiVersion:"3.13.0",fetchMembers:function(uid,collectionVarName,options={},refresh=!1){var _a,_b,_c,_d,_e,_f;return __awaiter$b(this,void 0,void 0,function*(){return null!==(_a=options.service)&&void 0!==_a||(options.service=[]),null!==(_b=options.where)&&void 0!==_b||(options.where={}),null!==(_c=options.order)&&void 0!==_c||(options.order=[]),null!==(_d=options.page)&&void 0!==_d||(options.page=1),null!==(_e=options.perPage)&&void 0!==_e||(options.perPage=10),options.images||(options.images=!1),options.office||(options.office=!1),null!==(_f=options.fields)&&void 0!==_f||(options.fields=["_id","MemberKey","MemberStateLicense","MemberNationalAssociationId","MemberFirstName","MemberLastName","MemberFullName","MemberStatus","MemberMlsAccessYN","MemberType","MemberAOR","OfficeKey","OfficeMlsId","OfficeName","OriginatingSystemName","SourceSystemName"]),genericSearchCollection(uid,collectionVarName,options,refresh,"member","Members",compileMemberFilter)})},fetchOffices:function(uid,collectionVarName,options={},refresh=!1){var _a,_b,_c,_d,_e,_f;return __awaiter$b(this,void 0,void 0,function*(){return null!==(_a=options.service)&&void 0!==_a||(options.service=[]),null!==(_b=options.where)&&void 0!==_b||(options.where={}),null!==(_c=options.order)&&void 0!==_c||(options.order=[]),null!==(_d=options.page)&&void 0!==_d||(options.page=1),null!==(_e=options.perPage)&&void 0!==_e||(options.perPage=10),options.images||(options.images=!1),options.managingBroker||(options.managingBroker=!1),options.members||(options.members=!1),null!==(_f=options.fields)&&void 0!==_f||(options.fields=["_id","OfficeKey","OfficeMlsId","OfficeName","OfficeNationalAssociationId","OfficeStatus","OfficePhone","OfficeAddress1","OfficeCity","OfficePostalCode","OfficeBrokerKey"]),refresh||(refresh=!1),genericSearchCollection(uid,collectionVarName,options,refresh,"office","Offices",compileOfficeFilter)})},fetchProperties:function(uid,collectionVarName,options={},refresh=!1){var _a,_b,_c,_d,_e,_f;return __awaiter$b(this,void 0,void 0,function*(){if(null!==(_a=options.service)&&void 0!==_a||(options.service=[]),!options.where&&!isEmpty(urlOptions.Search)){const whereReAssign=urlOptions.Search;delete urlOptions.Search.Page,delete urlOptions.Search.Order,options.where=whereReAssign}return null!==(_b=options.where)&&void 0!==_b||(options.where={}),null!==(_c=options.order)&&void 0!==_c||(options.order=urlOptions.Search.Order||[]),null!==(_d=options.page)&&void 0!==_d||(options.page=urlOptions.Search.Page||1),null!==(_e=options.perPage)&&void 0!==_e||(options.perPage=10),options.images||(options.images=!1),null!==(_f=options.fields)&&void 0!==_f||(options.fields=["_id","_Class","MlsStatus","PropertyType","PropertySubType","UnparsedAddress","StreetNumber","StreetNumberNumeric","StreetName","StreetSuffix","UnitNumber","City","CityRegion","MLSAreaMajor","MLSAreaMinor","CountyOrParish","StateOrProvince","Latitude","Longitude","ListPrice","ClosePrice","ListingId","ListingKey","BathroomsTotalInteger","BathroomsFull","BathroomsHalf","BathroomsOneQuarter","BathroomsThreeQuarter","BathroomsPartial","BedroomsTotal"]),Object.prototype.hasOwnProperty.call(options.where,"OpenHouseOnly")&&isString(options.where.OpenHouseOnly)&&(options.where.OpenHouseOnly="true"===options.where.OpenHouseOnly),Object.prototype.hasOwnProperty.call(options.where,"OpenHouseOnly")&&options.where.OpenHouseOnly&&(options.openhouses=!0),isEmpty(options.where.Neighborhood)&&isEmpty(options.where.eNeighborhood)&&isEmpty(options.where.Location)&&isEmpty(options.where.eLocation)&&isEmpty(options.where.AgentLicense)&&isEmpty(options.where.OfficeNumber)&&isEmpty(options.where.City)&&isEmpty(options.where.eCity)&&isEmpty(options.where.CityRegion)&&isEmpty(options.where.eCityRegion)&&isEmpty(options.where.CountyOrParish)&&isEmpty(options.where.eCountyOrParish)&&isEmpty(options.where.MLSAreaMajor)&&isEmpty(options.where.eMLSAreaMajor)&&isEmpty(options.where.MLSAreaMinor)&&isEmpty(options.where.eMLSAreaMinor)&&isEmpty(options.where.PostalCode)&&isEmpty(options.where.UnparsedAddress)&&(options.openhouses=!1,delete options.where.OpenHouseOnly),genericSearchCollection(uid,collectionVarName,options,refresh,"property","Properties",compilePropertyFilter)})},fetchProperty:function($scope,modelVarName,options={}){var _a,_b,_c;return __awaiter$b(this,void 0,void 0,function*(){return null!==(_a=options.service)&&void 0!==_a||(options.service=null),null!==(_b=options.where)&&void 0!==_b||(options.where={}),options.images||(options.images=!1),options.openhouses||(options.openhouses=!1),null!==(_c=options.fields)&&void 0!==_c||(options.fields=[]),genericSearchModel($scope,modelVarName,options,"Properties",compilePropertyFilter)})},clearFieldInput:function(ev){ev&&ev.hasOwnProperty("target")&&ev.target&&ev.target.hasOwnProperty("value")&&(ev.target.value=null)},countArraysNotEmpty:function(arrayList){return arrayList.filter(e=>e.length).length},devLog:function(...items){cookie("env")&&console.log(...items)},emit:function(emitterName,$scope,var1,var2,var3){emitManual(emitterName,$scope.elementId,$scope,var1,var2,var3)},emitManual,ensureItemsAreArrays:function(itemParent,itemNames){itemNames.forEach(itemName=>{itemParent.hasOwnProperty(itemName)&&!isArray(itemParent[itemName])&&(itemParent[itemName]=isEmpty(itemParent[itemName])?[]:[itemParent[itemName]])})},getContactVariables:function(){return session.contacts},getDefaultWhereOptions:function(){return clone(defaultWhereOptions)},getDisclaimerInstance:function(disclaimerUid){return disclaimerUid?Object.prototype.hasOwnProperty.call(instance.disclaimer,disclaimerUid)?{[instance.disclaimer[disclaimerUid].elementId]:instance.disclaimer[disclaimerUid]}:null:instance.disclaimer},getFriendlyPriceLabel:function(property){let priceLabel="List";if(property.hasOwnProperty("ClosePrice")){switch(getFriendlyStatus(property)){case"Closed":default:priceLabel="Sale";break;case"Leased":priceLabel="Lease";break;case"Rented":priceLabel="Rent"}}return priceLabel+=" Price",priceLabel},getFriendlyStatus,getFullAddress:function(property,encode){const address=getStreetAddress(property)+", "+property.City+" "+property.StateOrProvince;return encode?encodeURIComponent(address):address},getFullStatus:function(property,preferredStatus="Closed"){let statusName="";return Object.prototype.hasOwnProperty.call(property,"MlsStatus")&&""!==property.MlsStatus?statusName=property.MlsStatus:Object.prototype.hasOwnProperty.call(property,"StandardStatus")&&""!==property.StandardStatus&&(statusName=property.StandardStatus),""!==statusName&&(statusName=getFriendlyClosedStatus(property,statusName,preferredStatus)),statusName},getGoogleMapsKey:function(){let googleMapsKey=null;return sharedValues.integrations&&Object.prototype.hasOwnProperty.call(sharedValues.integrations,"maps")&&Object.prototype.hasOwnProperty.call(sharedValues.integrations.maps,"googleMaps")&&Object.prototype.hasOwnProperty.call(sharedValues.integrations.maps.googleMaps,"publicKey")&&""!==sharedValues.integrations.maps.googleMaps.publicKey&&(googleMapsKey=sharedValues.integrations.maps.googleMaps.publicKey),googleMapsKey},getIdxServices,getInput:function(elementId){return element(document.getElementById(elementId))},getScopeValuePath:function(scope,scopeVarPath){return getNestedPathValue(scope,scopeVarPath.split("."))},getLastQueryTime:function(){return lastQueries.time},getLastSessionTime:function(){return session.lastCreated},getListInstance:function(listUid,moduleName="property"){return Object.prototype.hasOwnProperty.call(instanceLink.List,listUid)?instance[moduleName].list[listUid]:null},getListInstanceLinks:function(listUid,moduleName="property"){const linkedSearches=[];return Object.prototype.hasOwnProperty.call(instanceLink.List,listUid)&&instanceLink.List[listUid].forEach(searchUid=>{Object.prototype.hasOwnProperty.call(instance[moduleName].list,searchUid)&&linkedSearches.push(instance[moduleName].list[searchUid])}),linkedSearches},getMLSVariables:function(serviceIds){const serviceList=[];return serviceIds&&isArray(serviceIds)?serviceIds.forEach(serviceId=>{Object.prototype.hasOwnProperty.call(session.services,serviceId)&&serviceList.push({id:session.services[serviceId].id,name:session.services[serviceId].name,disclaimer:session.services[serviceId].disclaimer,fetchTime:session.services[serviceId].fetchTime,analyticsEnabled:session.services[serviceId].analyticsEnabled,logo:session.services[serviceId].logo,mandatoryLogo:session.services[serviceId].mandatoryLogo})}):Object.values(session.services).forEach(service=>{isEmpty(service)||serviceList.push({id:service.id,name:service.name,disclaimer:service.disclaimer,fetchTime:service.fetchTime,analyticsEnabled:service.analyticsEnabled,logo:service.logo,mandatoryLogo:service.mandatoryLogo})}),serviceList},getNestedPathValue,getOptionsFromUrl:function(){let hash=getHashBangParam("#!");return hash=function(path){const regex=/\/Listing\/(\d{1,3})\/([^/\s]+)(\/?[\w\-_]*\/?)?/,matches=regex.exec(path);path=path.replace(regex,""),null!==matches&&matches[1]&&matches[2]&&(urlOptions.Listing.service=matches[1],urlOptions.Listing.ListingKey=matches[2]);return path}(hash),function(path){let regex=/\/Search\/(.*)?\/?/,matches=regex.exec(path);if(path=path.replace(regex,""),null!==matches&&matches[1]){const rawSearchOptions=matches[1];regex=/([^/]+)\/([^/]*)/g;const whileLoopAssignmentBypass=(regexp,value)=>(matches=regexp.exec(value),matches);for(;null!=whileLoopAssignmentBypass(regex,rawSearchOptions);)matches[1]&&(matches[2]&&matches[2].includes(",")?urlOptions.Search[matches[1]]=matches[2].split(","):urlOptions.Search[matches[1]]=matches[2])}Object.prototype.hasOwnProperty.call(urlOptions.Search,"Page")&&isString(urlOptions.Search.Page)&&(urlOptions.Search.Page=parseInt(urlOptions.Search.Page,10))}(hash),urlOptions},getSearchInstanceLinks:function(searchUid,moduleName="property"){const linkedLists=[];return Object.prototype.hasOwnProperty.call(instanceLink.Search,searchUid)&&instanceLink.Search[searchUid].forEach(listUid=>{Object.prototype.hasOwnProperty.call(instance[moduleName].list,listUid)&&linkedLists.push(instance[moduleName].list[listUid])}),linkedLists},getStreetAddress,getUrlOptions:function(listingOrSearch){return urlOptions[listingOrSearch]},getUrlOptionsPath,getWebsiteMainContact:function(){const contact={name:null,email:null,phone:null};return isPlainObject(sharedValues.contact)&&(contact.name=clone(sharedValues.contact.name),sharedValues.contact.emails.hasOwnProperty("Main")&&(contact.email=clone(sharedValues.contact.emails.Main)),sharedValues.contact.phones.hasOwnProperty("Main")&&(contact.phone=clone(sharedValues.contact.phones.Main))),isString(contact.name)&&""!==contact.name?contact:null},on:function(uid,emitterName,callback){if("init"===emitterName&&Object.prototype.hasOwnProperty.call(instanceOnEmitters,uid)&&Object.prototype.hasOwnProperty.call(instanceOnEmitters[uid],emitterName)&&Object.prototype.hasOwnProperty.call(Stratus.Instances,uid))return void callback(Stratus.Instances[uid]);if("Idx"===uid&&"sessionInit"===emitterName&&sessionInitialized)return void callback(null);Object.prototype.hasOwnProperty.call(instanceOnEmitters,uid)||(instanceOnEmitters[uid]={}),Object.prototype.hasOwnProperty.call(instanceOnEmitters[uid],emitterName)||(instanceOnEmitters[uid][emitterName]={});const onId=uniqueId();return instanceOnEmitters[uid][emitterName][onId]=callback,()=>{!function(emitterName,emitterId,onId){Object.prototype.hasOwnProperty.call(instanceOnEmitters,emitterId)&&Object.prototype.hasOwnProperty.call(instanceOnEmitters[emitterId],emitterName)&&Object.prototype.hasOwnProperty.call(instanceOnEmitters[emitterId][emitterName],onId)&&delete instanceOnEmitters[emitterId][emitterName][onId]}(uid,emitterName,onId)}},registerDetailsInstance:function(uid,moduleName,$scope){instance[moduleName].details[uid]=$scope},registerDisclaimerInstance:function(uid,$scope){Object.prototype.hasOwnProperty.call(instance,"disclaimer")||(instance.disclaimer={}),instance.disclaimer[uid]=$scope,Object.prototype.hasOwnProperty.call(instanceLink.Disclaimer,uid)||(instanceLink.Disclaimer[uid]=[])},registerListInstance:function(uid,moduleName,$scope){Object.prototype.hasOwnProperty.call(instance,moduleName)||(instance[moduleName].list={}),instance[moduleName].list[uid]=$scope,Object.prototype.hasOwnProperty.call(instanceLink.List,uid)||(instanceLink.List[uid]=[])},registerMapInstance:function(uid,$scope){Object.prototype.hasOwnProperty.call(instance,"map")||(instance.map={}),instance.map[uid]=$scope,Object.prototype.hasOwnProperty.call(instanceLink.Map,uid)||(instanceLink.Map[uid]=[])},registerSearchInstance:function(uid,moduleName,$scope,listUid){instance[moduleName].search[uid]=$scope,Object.prototype.hasOwnProperty.call(instanceLink.Search,uid)||(instanceLink.Search[uid]=[]),listUid&&(instanceLink.Search[uid].push(listUid),Object.prototype.hasOwnProperty.call(instanceLink.List,listUid)||(instanceLink.List[listUid]=[]),instanceLink.List[listUid].push(uid))},setIdxServices,setPageTitle:function(title){defaultPageTitle||(defaultPageTitle=JSON.parse(JSON.stringify($window.document.title))),$window.document.title=title||defaultPageTitle},setTokenURL:function(url){tokenRefreshURL=url},setUrlOptions:function(listingOrSearch,options){urlOptions[listingOrSearch]=options||{}},sharedValues,tokenKeepAuth,refreshUrlOptions:function(defaultOptions){var path;path=getUrlOptionsPath(defaultOptions),$rootScope.$applyAsync(()=>{setHashBangParam(path,"#!")})},updateNestedPathValue,updateScopeValuePath:function(scope,scopeVarPath,value){return __awaiter$b(this,void 0,void 0,function*(){if(null==value||"null"===value||""===value)return!1;const scopePieces=scopeVarPath.split(".");return updateNestedPathValue(scope,scopePieces,value)})},unregisterDetailsInstance:function(uid,moduleName){if(Object.prototype.hasOwnProperty.call(instance[moduleName].details,uid)){const detailUid=instance[moduleName].details[uid].elementId;delete instance[moduleName].details[uid],Stratus.Instances.Clean(detailUid)}}}};Stratus.Services.Idx=["$provide",$provide=>{$provide.factory("Idx",angularJsService)}],System.register(["lodash","@stratusjs/runtime/stratus","angular","@stratusjs/angularjs/services/model","@stratusjs/angularjs/services/collection","@stratusjs/core/misc","@stratusjs/core/environment","@stratusjs/idx/listTrac"],function(exports_1,context_1){var lodash_1,stratus_1,angular_1,model_1,collection_1,misc_1,environment_1,angularJsService;return context_1&&context_1.id,{setters:[function(lodash_1_1){lodash_1=lodash_1_1},function(stratus_1_1){stratus_1=stratus_1_1},function(angular_1_1){angular_1=angular_1_1},function(model_1_1){model_1=model_1_1},function(collection_1_1){collection_1=collection_1_1},function(misc_1_1){misc_1=misc_1_1},function(environment_1_1){environment_1=environment_1_1},function(_1){}],execute:function(){angularJsService=($http,$mdToast,$q,$rootScope,$window,ListTrac,orderByFilter)=>{const sharedValues={contactUrl:null,contactCommentVariable:null,contact:null,integrations:{analytics:{},maps:{}}},defaultWhereOptions={City:[],eCity:[],UnparsedAddress:"",Location:"",eLocation:"",Status:[],ListingId:[],ListingType:[],CountyOrParish:[],eCountyOrParish:[],MLSAreaMajor:[],eMLSAreaMajor:[],MLSAreaMinor:[],eMLSAreaMinor:[],SubdivisionName:[],eSubdivisionName:[],Neighborhood:[],eNeighborhood:[],PostalCode:[],CityRegion:[],eCityRegion:[],AgentLicense:[],OfficeNumber:[],OfficeName:[]};let refreshLoginTimer,defaultPageTitle,idxServicesEnabled=[],tokenRefreshURL="/ajax/request?class=property.token_auth&method=getToken",sessionInitialized=!1;const instance={disclaimer:{},