@meetelise/chat 1.45.0 → 1.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -67,6 +67,9 @@ export declare class TourScheduler extends LitElement {
67
67
  private units;
68
68
  private allowOccupiedUnitTours;
69
69
  errorGettingAvailabilities: boolean;
70
+ private centralConvoBuildings;
71
+ selectedBuildingEl?: MESelect;
72
+ private statusMessage;
70
73
  _setAvailabilities: () => Promise<void>;
71
74
  _setDefaultSelectedDateAndTimes: (tourType?: TourAvailabilityResponseRankOrderedSupportedTourTypesEnum, date?: Date) => Promise<void>;
72
75
  _getHighestRankedTourType: (availabilities: TourAvailabilityResponse) => TourAvailabilityResponseRankOrderedSupportedTourTypesEnum | null;
@@ -77,6 +80,10 @@ export declare class TourScheduler extends LitElement {
77
80
  }[];
78
81
  _fetchUnits: () => Promise<void>;
79
82
  firstUpdated: () => Promise<void>;
83
+ private _loadForCurrentBuilding;
84
+ private _fetchCentralConvoBuildings;
85
+ private _onBuildingChange;
86
+ buildingSelector(): TemplateResult | string;
80
87
  protected willUpdate: (_changedProperties: PropertyValueMap<{
81
88
  tourType: TourType;
82
89
  }> | Map<PropertyKey, unknown>) => Promise<void>;
@@ -114,6 +121,7 @@ export declare class TourScheduler extends LitElement {
114
121
  confirmationMessage(): TemplateResult;
115
122
  loadingIcon(size?: number): TemplateResult;
116
123
  render(): TemplateResult;
124
+ private renderBody;
117
125
  }
118
126
  export declare enum TourType {
119
127
  Guided = "guided",
@@ -0,0 +1,14 @@
1
+ export interface CentralConvoBuilding {
2
+ building_id: number;
3
+ name: string;
4
+ slug: string;
5
+ }
6
+ /**
7
+ * Fetch the buildings that belong to the same central conversation group as the
8
+ * current building. Returns an empty array when the building is not part of a
9
+ * central conversation group (in which case no building selector is shown).
10
+ *
11
+ * @param orgSlug - The org slug, e.g. "big-prop-co"
12
+ * @param buildingSlug - The current building's slug, e.g. "gravity-falls"
13
+ */
14
+ export default function fetchCentralConvoBuildings(orgSlug: string, buildingSlug: string): Promise<CentralConvoBuilding[]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meetelise/chat",
3
- "version": "1.45.0",
3
+ "version": "1.46.0",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/MeetElise/chat-ui#readme",
@@ -947,6 +947,17 @@ var e={2:(e,t,n)=>{var i=n(2199),r=n(4664),o=n(5950);e.exports=function(e){retur
947
947
  font-size: 14px;
948
948
  font-weight: 600;
949
949
  }
950
+ .sr-only {
951
+ position: absolute;
952
+ width: 1px;
953
+ height: 1px;
954
+ padding: 0;
955
+ margin: -1px;
956
+ overflow: hidden;
957
+ clip: rect(0, 0, 0, 0);
958
+ white-space: nowrap;
959
+ border: 0;
960
+ }
950
961
  #close-button {
951
962
  background: none;
952
963
  border: none;
@@ -974,6 +985,11 @@ var e={2:(e,t,n)=>{var i=n(2199),r=n(4664),o=n(5950);e.exports=function(e){retur
974
985
  padding-bottom: 12px;
975
986
  }
976
987
 
988
+ me-select#building {
989
+ display: block;
990
+ margin-bottom: 20px;
991
+ }
992
+
977
993
  #tour-type-menu-outer-container {
978
994
  width: 220px;
979
995
  }
@@ -1270,7 +1286,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
1270
1286
  gap: 12px;
1271
1287
  align-items: center;
1272
1288
  }
1273
- `;class wi{constructor(e,t,n,i){this.org=e,this.building=t,this.chatId=n,this.incomingProcessedLeadSource=i,this.featureFlags={}}setFeatureFlags(e){this.featureFlags={...this.featureFlags,...e}}ping(e){var t;fetch("https://app.meetelise.com/platformApi/connectors/talk_js/analytics",{method:"POST",credentials:"omit",keepalive:!0,headers:{"content-type":"application/json; charset=UTF-8"},body:JSON.stringify({eventType:e,chatId:this.chatId,url:location.href,org:this.org,building:this.building,referrer:document.referrer,featureFlags:this.featureFlags,campaignSources:Ci(),incomingProcessedLeadSource:this.incomingProcessedLeadSource,webchatVersion:null!==(t="MISSING_ENV_VAR".npm_package_version)&&void 0!==t?t:"1.20.155"})})}}const Ci=()=>{var e,t,n,i,r,o;try{const i=new URL(window.location.href).searchParams,r=null!==(n=null===(t=null===(e=window.RCTPCampaign)||void 0===e?void 0:e.CampaignDetails)||void 0===t?void 0:t.Source)&&void 0!==n?n:null,o=i.get("switch_cls[id]"),a=i.get("ilm"),s=i.get("utm_source");return{entrataCampaignSource:o,realpageCampaignSource:a,utmCampaignSource:s,yardiCampaignSource:r,bozzutoAdSource:Cn("bozzuto_ad_source")}}catch(e){const t=document.createElement("iframe");if(t.style.display="none",document.body.appendChild(t),!t.contentWindow)return{entrataCampaignSource:null,realpageCampaignSource:null,utmCampaignSource:null,yardiCampaignSource:null,bozzutoAdSource:null};const n=t.contentWindow.URL;if(!n)return{entrataCampaignSource:null,realpageCampaignSource:null,utmCampaignSource:null,yardiCampaignSource:null,bozzutoAdSource:null};const a=new n(window.location.href).searchParams,s=null!==(o=null===(r=null===(i=window.RCTPCampaign)||void 0===i?void 0:i.CampaignDetails)||void 0===r?void 0:r.Source)&&void 0!==o?o:null;return{entrataCampaignSource:a.get("switch_cls[id]"),realpageCampaignSource:a.get("ilm"),utmCampaignSource:a.get("utm_source"),yardiCampaignSource:s,bozzutoAdSource:Cn("bozzuto_ad_source")}}};var xi;!function(e){e.error="error",e.info="info",e.warn="warn"}(xi||(xi={}));const Ai=async({logType:e,buildingSlug:t,orgSlug:n,logTitle:i,logData:o})=>{await r().post("https://app.meetelise.com/platformApi/webchat/logging",{...o},{headers:{"Content-Type":"application/json","building-slug":null!=t?t:"","org-slug":null!=n?n:"","log-type":null!=e?e:xi.error,"log-title":i.toUpperCase().replace(/\s/g,"_")}})},Si=async({params:e,sampleRate:t})=>{try{if(Math.random()>=t)return;await r().post("https://app.meetelise.com/platformApi/webchat/log/signal",{...e,website_origin:window.location.origin,website_search:window.location.search})}catch(e){}};function Ei(){return ki()?function(){const e=window.location.search,t={},n=e.split("?").slice(1).join("&");return n.split("&").forEach(e=>{const[n,i]=e.split("=");n&&i&&(t[decodeURIComponent(n)]=decodeURIComponent(i))}),t}():function(){const e=new URLSearchParams(window.location.search),t=e.has("utm_content"),n=e.has("utm_source");if(t&&!n){const t=e.get("utm_content");e.delete("utm_content"),e.set("utm_source",t)}return Object.fromEntries(e)}()}const ki=()=>(window.location.search.match(/\?/g)||[]).length>1;var Ti=n(2193),_i=n.n(Ti);function Oi(e){return"avb"===e?"AVB Company Website":"windsor"===e?"Windsorcommunities.com":"property-website"}const Pi=class{constructor(){this.chatId=null,this.apiHost="https://app.meetelise.com",this.leadSource=null,this.localStorageTTLDays=30,this.buildingId=null,this.orgSlug=null,this.buildingSlug=null,this.queryParameters=null,this.leadSourceInput=null,this.updateLeadSourceLocalStorage=(e,t,n,i,r)=>{const o=Ei();if(this.leadSourceInput={websiteOrigin:window.location.origin,websiteSearch:window.location.search,queryParameters:o,referrer:document.referrer,parsedUtmSource:o?o.utm_source:null,campaignSources:Object.values(Ci()).filter(e=>e)},i)return;if(!r){const t=this.getLeadSourceBodyIfValid(e);if(t){if(!wn(t.timestamp,24*this.localStorageTTLDays))return{...t,timestamp:Rn(t.timestamp)}}}const a={leadSource:t,leadId:n,buildingSlug:e,timestamp:On(new Date),leadSourceInput:this.leadSourceInput};return localStorage.setItem("com.elise.webchat.leadsource.slug="+e,JSON.stringify(a)),{...a,timestamp:Rn(a.timestamp)}},this.getLeadSourceBodyIfValid=e=>{const t=localStorage.getItem("com.elise.webchat.leadsource.slug="+e);if(t)try{const n=JSON.parse(t);if(n.buildingSlug===e&&n.leadSource&&n.leadId&&n.timestamp&&!wn(Rn(n.timestamp),24*this.localStorageTTLDays)){try{this.leadSourceInput=n.leadSourceInput}catch(e){}return n}}catch(e){return null}return null},this.resetLeadSource=()=>{if(!this.buildingSlug)return!1;const e="com.elise.webchat.leadsource.slug="+this.buildingSlug;return localStorage.removeItem(e),!0}}async fetchCurrentParsedLeadSource({buildingSlug:e,queryParams:t,referrer:n,campaignSources:i}){try{return(await r().post(`${this.apiHost}/platformApi/webchat/current-parsed-lead-source`,{query_params:t,building_slug:e,referrer:n,campaign_sources:i})).data}catch(e){return null}}async checkAndHandleForLogLeadSource({webchatAction:e,stateId:t}){var n,i,o,a,s,l,u;try{if(!this.chatId)return null;if(!this.orgSlug)return null;let c=null,d=null;try{if("f1ba5a20-d207-4e5a-879e-65199e7d0a53"===this.orgSlug){const e=await this.getCookieValue("_ga");e&&(c=e),d=null===(n=window.dataLayer.find(e=>{var t;return"gtagApiGet"==(null===(t=e.value)||void 0===t?void 0:t.event)}))||void 0===n?void 0:n.value}}catch(e){}return await r().post(`${this.apiHost}/platformApi/webchat/log/lead-source`,{chat_id:this.chatId,webchat_action:e,state_id:t,building_id:this.buildingId,org_slug:this.orgSlug,building_slug:this.buildingSlug,website_origin:null===(i=this.leadSourceInput)||void 0===i?void 0:i.websiteOrigin,website_search:null===(o=this.leadSourceInput)||void 0===o?void 0:o.websiteSearch,query_parameters:null===(a=this.leadSourceInput)||void 0===a?void 0:a.queryParameters,referrer:null===(s=this.leadSourceInput)||void 0===s?void 0:s.referrer,parsed_utm_source:null===(l=this.leadSourceInput)||void 0===l?void 0:l.parsedUtmSource,campaign_sources:null===(u=this.leadSourceInput)||void 0===u?void 0:u.campaignSources,lead_source_output:this.leadSource,google_analytics_client_id:_i()(c)?null:c,extras:null!=d?d:null}),null}catch(e){return null}}async getCookieValue(e){try{const t=document.cookie.split(";");for(let n=0;n<t.length;n++){const i=t[n].trim();if(i.startsWith(e+"=")){return i.substring((e+"=").length,-1===i.indexOf(";")?void 0:i.indexOf(";"))}}return null}catch(e){}return null}async generateUserLeadSource({leadId:e,orgSlug:t,buildingSlug:n}){try{const i={queryParams:Ei(),buildingSlug:n,referrer:document.referrer,campaignSources:Ci()};let r=!1;const o=n?this.getLeadSourceBodyIfValid(n):null;if(o){if(!["test-company","daf00bd2-1ecb-482c-b6f4-e1c5511a01be"].includes(t))return this.leadSource=o.leadSource,this.leadSource;{const e=await this.fetchCurrentParsedLeadSource(i);if(!e)return this.leadSource=o.leadSource,this.leadSource;this.leadSource=e,r=!0}}const a=await this.fetchCurrentParsedLeadSource(i);if(this.leadSource=a,this.buildingId=null,this.orgSlug=t,this.buildingSlug=n,n&&!a){const e=this.getLeadSourceBodyIfValid(n);if(e)return this.leadSource=e.leadSource,this.leadSource}if(n){const t=!!a&&a.length>0;this.updateLeadSourceLocalStorage(n,a,e,!t&&!r,r)}return a}catch(e){}return null}},Ii=async(e,t=!1)=>{const n=`https://app.meetelise.com/eliseCrmApi/building/${e}/scheduling_status?observe_dynamic_scheduling=${t}`;try{return(await r().get(n)).data.is_enabled}catch(e){return!1}};var Mi,Ni,Di;!function(e){e.EMOJI="emoji",e.PILLS="pills",e.MINIMIZED="minimized"}(Mi||(Mi={})),function(e){e.UNKNOWN="UNKNOWN",e.SELF_GUIDED="SELF_GUIDED",e.VIRTUAL_SHOWING="VIRTUAL_SHOWING",e.WITH_AGENT="WITH_AGENT",e.MEDIA_TOUR="MEDIA_TOUR",e.OPEN_HOUSE_STUDIO="OPEN_HOUSE_STUDIO",e.OPEN_HOUSE_1BR="OPEN_HOUSE_1BR",e.OPEN_HOUSE_2BR="OPEN_HOUSE_2BR",e.OPEN_HOUSE_3BR="OPEN_HOUSE_3BR",e.OPEN_HOUSE_4BR="OPEN_HOUSE_4BR",e.OPEN_HOUSE_5BR="OPEN_HOUSE_5BR"}(Ni||(Ni={})),function(e){e.LINK="link",e.CLIENT_SCHEDULED="client_scheduled",e.SCHEDULED_BY_ME_MANAGED_BY_ME="scheduled_by_ME_managed_by_ME",e.SCHEDULED_BY_ME_MANAGED_BY_CLIENT="scheduled_by_ME_managed_by_client",e.SCHEDULED_BY_ME_MANAGED_BY_CONCIERGE="scheduled_by_ME_managed_by_concierge"}(Di||(Di={}));const Li=(e,t)=>"link"===(null==t?void 0:t.toLowerCase());async function Ui(e,t){var n;const i=`https://app.meetelise.com/api/pub/v1/organization/${e}/building/${t}/v2`,o=(await r().get(i)).data;try{o.welcomeMessage=Ri(null!==(n=o.welcomeMessage)&&void 0!==n?n:"",o.userFirstName)}catch(e){}return o}const Ri=(e,t)=>e.replace(/elise/gi,t);var Bi=n(7035),ji=n(6353);function Fi(e,t,n){var i=function(e,t,n){if(n&&!n.code)throw new Error("date-fns-tz error: Please set a language code on the locale object imported from date-fns, e.g. `locale.code = 'en-US'`");return new Intl.DateTimeFormat(n?[n.code,"en-US"]:void 0,{timeZone:t,timeZoneName:e})}(e,n.timeZone,n.locale);return i.formatToParts?function(e,t){for(var n=e.formatToParts(t),i=n.length-1;i>=0;--i)if("timeZoneName"===n[i].type)return n[i].value}(i,t):function(e,t){var n=e.format(t).replace(/\u200E/g,""),i=/ [\w-+ ]+$/.exec(n);return i?i[0].substr(1):""}(i,t)}function Hi(e,t){var n=function(e){if(!zi[e]){var t=new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:"America/New_York",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date("2014-06-25T04:00:00.123Z")),n="06/25/2014, 00:00:00"===t||"‎06‎/‎25‎/‎2014‎ ‎00‎:‎00‎:‎00"===t;zi[e]=n?new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}return zi[e]}(t);return n.formatToParts?function(e,t){try{for(var n=e.formatToParts(t),i=[],r=0;r<n.length;r++){var o=$i[n[r].type];o>=0&&(i[o]=parseInt(n[r].value,10))}return i}catch(e){if(e instanceof RangeError)return[NaN];throw e}}(n,e):function(e,t){var n=e.format(t),i=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(n);return[i[3],i[1],i[2],i[4],i[5],i[6]]}(n,e)}var $i={year:0,month:1,day:2,hour:3,minute:4,second:5};var zi={};function Gi(e,t,n,i,r,o,a){var s=new Date(0);return s.setUTCFullYear(e,t,n),s.setUTCHours(i,r,o,a),s}var Qi=36e5,Wi={timezone:/([Z+-].*)$/,timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-])(\d{2}):?(\d{2})$/};function qi(e,t,n){var i,r,o;if(!e)return 0;if(i=Wi.timezoneZ.exec(e))return 0;if(i=Wi.timezoneHH.exec(e))return Yi(o=parseInt(i[1],10))?-o*Qi:NaN;if(i=Wi.timezoneHHMM.exec(e)){o=parseInt(i[2],10);var a=parseInt(i[3],10);return Yi(o,a)?(r=Math.abs(o)*Qi+6e4*a,"+"===i[1]?-r:r):NaN}if(function(e){if(Ki[e])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),Ki[e]=!0,!0}catch(e){return!1}}(e)){t=new Date(t||Date.now());var s=n?t:function(e){return Gi(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}(t),l=Vi(s,e),u=n?l:function(e,t,n){var i=e.getTime(),r=i-t,o=Vi(new Date(r),n);if(t===o)return t;r-=o-t;var a=Vi(new Date(r),n);if(o===a)return o;return Math.max(o,a)}(t,l,e);return-u}return NaN}function Vi(e,t){var n=Hi(e,t),i=Gi(n[0],n[1]-1,n[2],n[3]%24,n[4],n[5],0).getTime(),r=e.getTime(),o=r%1e3;return i-(r-=o>=0?o:1e3+o)}function Yi(e,t){return-23<=e&&e<=23&&(null==t||0<=t&&t<=59)}var Ki={};var Xi={X:function(e,t,n,i){var r=Zi(i.timeZone,e);if(0===r)return"Z";switch(t){case"X":return tr(r);case"XXXX":case"XX":return er(r);default:return er(r,":")}},x:function(e,t,n,i){var r=Zi(i.timeZone,e);switch(t){case"x":return tr(r);case"xxxx":case"xx":return er(r);default:return er(r,":")}},O:function(e,t,n,i){var r=Zi(i.timeZone,e);switch(t){case"O":case"OO":case"OOO":return"GMT"+function(e,t){var n=e>0?"-":"+",i=Math.abs(e),r=Math.floor(i/60),o=i%60;if(0===o)return n+String(r);var a=t||"";return n+String(r)+a+Ji(o,2)}(r,":");default:return"GMT"+er(r,":")}},z:function(e,t,n,i){switch(t){case"z":case"zz":case"zzz":return Fi("short",e,i);default:return Fi("long",e,i)}}};function Zi(e,t){var n=e?qi(e,t,!0)/6e4:t.getTimezoneOffset();if(Number.isNaN(n))throw new RangeError("Invalid time zone specified: "+e);return n}function Ji(e,t){for(var n=e<0?"-":"",i=Math.abs(e).toString();i.length<t;)i="0"+i;return n+i}function er(e,t){var n=t||"",i=e>0?"-":"+",r=Math.abs(e);return i+Ji(Math.floor(r/60),2)+n+Ji(Math.floor(r%60),2)}function tr(e,t){return e%60==0?(e>0?"-":"+")+Ji(Math.abs(e)/60,2):er(e,t)}const nr=Xi;var ir=n(9784),rr=n(9720);var or=36e5,ar=6e4,sr={dateTimePattern:/^([0-9W+-]+)(T| )(.*)/,datePattern:/^([0-9W+-]+)(.*)/,plainTime:/:/,YY:/^(\d{2})$/,YYY:[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],YYYY:/^(\d{4})/,YYYYY:[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],MM:/^-(\d{2})$/,DDD:/^-?(\d{3})$/,MMDD:/^-?(\d{2})-?(\d{2})$/,Www:/^-?W(\d{2})$/,WwwD:/^-?W(\d{2})-?(\d{1})$/,HH:/^(\d{2}([.,]\d*)?)$/,HHMM:/^(\d{2}):?(\d{2}([.,]\d*)?)$/,HHMMSS:/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,timeZone:/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/};function lr(e,t){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(null===e)return new Date(NaN);var n=t||{},i=null==n.additionalDigits?2:ir(n.additionalDigits);if(2!==i&&1!==i&&0!==i)throw new RangeError("additionalDigits must be 0, 1 or 2");if(e instanceof Date||"object"==typeof e&&"[object Date]"===Object.prototype.toString.call(e))return new Date(e.getTime());if("number"==typeof e||"[object Number]"===Object.prototype.toString.call(e))return new Date(e);if("string"!=typeof e&&"[object String]"!==Object.prototype.toString.call(e))return new Date(NaN);var r=function(e){var t,n={},i=sr.dateTimePattern.exec(e);i?(n.date=i[1],t=i[3]):(i=sr.datePattern.exec(e))?(n.date=i[1],t=i[2]):(n.date=null,t=e);if(t){var r=sr.timeZone.exec(t);r?(n.time=t.replace(r[1],""),n.timeZone=r[1].trim()):n.time=t}return n}(e),o=function(e,t){var n,i=sr.YYY[t],r=sr.YYYYY[t];if(n=sr.YYYY.exec(e)||r.exec(e)){var o=n[1];return{year:parseInt(o,10),restDateString:e.slice(o.length)}}if(n=sr.YY.exec(e)||i.exec(e)){var a=n[1];return{year:100*parseInt(a,10),restDateString:e.slice(a.length)}}return{year:null}}(r.date,i),a=o.year,s=function(e,t){if(null===t)return null;var n,i,r,o;if(0===e.length)return(i=new Date(0)).setUTCFullYear(t),i;if(n=sr.MM.exec(e))return i=new Date(0),pr(t,r=parseInt(n[1],10)-1)?(i.setUTCFullYear(t,r),i):new Date(NaN);if(n=sr.DDD.exec(e)){i=new Date(0);var a=parseInt(n[1],10);return function(e,t){if(t<1)return!1;var n=hr(e);if(n&&t>366)return!1;if(!n&&t>365)return!1;return!0}(t,a)?(i.setUTCFullYear(t,0,a),i):new Date(NaN)}if(n=sr.MMDD.exec(e)){i=new Date(0),r=parseInt(n[1],10)-1;var s=parseInt(n[2],10);return pr(t,r,s)?(i.setUTCFullYear(t,r,s),i):new Date(NaN)}if(n=sr.Www.exec(e))return fr(t,o=parseInt(n[1],10)-1)?ur(t,o):new Date(NaN);if(n=sr.WwwD.exec(e)){o=parseInt(n[1],10)-1;var l=parseInt(n[2],10)-1;return fr(t,o,l)?ur(t,o,l):new Date(NaN)}return null}(o.restDateString,a);if(isNaN(s))return new Date(NaN);if(s){var l,u=s.getTime(),c=0;if(r.time&&(c=function(e){var t,n,i;if(t=sr.HH.exec(e))return gr(n=parseFloat(t[1].replace(",",".")))?n%24*or:NaN;if(t=sr.HHMM.exec(e))return gr(n=parseInt(t[1],10),i=parseFloat(t[2].replace(",",".")))?n%24*or+i*ar:NaN;if(t=sr.HHMMSS.exec(e)){n=parseInt(t[1],10),i=parseInt(t[2],10);var r=parseFloat(t[3].replace(",","."));return gr(n,i,r)?n%24*or+i*ar+1e3*r:NaN}return null}(r.time),isNaN(c)))return new Date(NaN);if(r.timeZone||n.timeZone){if(l=qi(r.timeZone||n.timeZone,new Date(u+c)),isNaN(l))return new Date(NaN)}else l=rr(new Date(u+c)),l=rr(new Date(u+c+l));return new Date(u+c+l)}return new Date(NaN)}function ur(e,t,n){t=t||0,n=n||0;var i=new Date(0);i.setUTCFullYear(e,0,4);var r=7*t+n+1-(i.getUTCDay()||7);return i.setUTCDate(i.getUTCDate()+r),i}var cr=[31,28,31,30,31,30,31,31,30,31,30,31],dr=[31,29,31,30,31,30,31,31,30,31,30,31];function hr(e){return e%400==0||e%4==0&&e%100!=0}function pr(e,t,n){if(t<0||t>11)return!1;if(null!=n){if(n<1)return!1;var i=hr(e);if(i&&n>dr[t])return!1;if(!i&&n>cr[t])return!1}return!0}function fr(e,t,n){return!(t<0||t>52)&&(null==n||!(n<0||n>6))}function gr(e,t,n){return(null==e||!(e<0||e>=25))&&((null==t||!(t<0||t>=60))&&(null==n||!(n<0||n>=60)))}var mr=/([xXOz]+)|''|'(''|[^'])+('|$)/g;function yr(e,t,n,i){var r=Bi(i);return r.timeZone=t,r.originalDate=e,function(e,t,n){var i=String(t),r=n||{},o=i.match(mr);if(o){var a=lr(r.originalDate||e,r);i=o.reduce(function(e,t){if("'"===t[0])return e;var n=e.indexOf(t),i="'"===e[n-1],o=e.replace(t,"'"+nr[t[0]](a,t,null,r)+"'");return i?o.substring(0,n-1)+o.substring(n+1):o},i)}return ji(e,i,r)}(function(e,t,n){var i=lr(e,n),r=qi(t,i,!0),o=new Date(i.getTime()-r),a=new Date(0);return a.setFullYear(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate()),a.setHours(o.getUTCHours(),o.getUTCMinutes(),o.getUTCSeconds(),o.getUTCMilliseconds()),a}(e,t),n,r)}const br=async({buildingSlug:e})=>{try{const t=await r().get(`${hn}/platformApi/webchat/${e}/units/summary`);if(t.data)return fn(t.data)}catch(t){Ai({logType:xi.error,buildingSlug:e,logTitle:"[ERROR_GETTING_UNITS_SUMMARY]",logData:{error:t}})}return[]};var vr=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a};let wr=class extends oe{constructor(){super(...arguments),this.tourTypeOptions=[],this.layoutOptions=[],this.chatId="",this.buildingId=0,this.buildingSlug="",this.sgtUrl="",this.selfGuidedToursTypeOffered="",this.selfGuidedTourEnabled=!1,this.escortedToursLink="",this.escortedToursTypeOffered="",this.virtualToursLink="",this.virtualToursTypeOffered="",this.orgSlug="",this.hasDynamicSchedulingEnabled=!1,this.leadSourceClient=null,this.leadSourceMultitouchClient=null,this.buildingName="",this.tourType=null,this.shouldShowTourType={[Cr.Guided]:!0,[Cr.Self]:!0,[Cr.Virtual]:!0},this.email="",this.phoneNumber="",this.availabilitiesGroupedByDay={},this.calendarTimeZone=Intl.DateTimeFormat().resolvedOptions().timeZone,this.waitingForAvailabilities=!0,this.mobilePageIndex=0,this.isSubmitting=!1,this.tourIsBooked=!1,this.shouldAllowScheduling=!1,this.shouldAllowScheduleLoading=!0,this.promptForReschedule=!1,this.canceledReschedule=!1,this.leadSources=[],this.orgLegalName="",this.currentLeadSource="",this.featureFlagShowDropdown="",this.compactDesign=!1,this.primaryColor=Ue,this.backgroundColor=Re,this.foregroundColorOnPrimaryBackgroundColor="white",this.foregroundColorOnSecondaryBackgroundColor="black",this.firstNameInputValue="",this.lastNameInputValue="",this.leadSourceInputValue="",this.selectedLayoutValue="",this.selectedUnitValue="",this.units=[],this.allowOccupiedUnitTours=!1,this.errorGettingAvailabilities=!1,this._setAvailabilities=async()=>{try{const[e,t]=await Promise.all([Ii(this.buildingId,this.hasDynamicSchedulingEnabled),Kn()]);this.shouldAllowScheduling=e,this.shouldAllowScheduleLoading=!1,this.calendarTimeZone=await(async e=>{var t;return null!==(t=(await Vn(e)).calendarTimeZone)&&void 0!==t?t:Intl.DateTimeFormat().resolvedOptions().timeZone})(this.buildingId),Ai({logTitle:"AVAILABILITIES_EXIST_FOR_TOUR_TYPE",logData:t,logType:xi.info,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});const n=Object.values(t).every(e=>!1===e),i=!this.sgtUrl&&!this.escortedToursLink&&!this.virtualToursLink;if(n&&i)return this.errorGettingAvailabilities=!0,this.waitingForAvailabilities=!1,void Ai({logTitle:"NO_AVAILABILITIES_EXIST",logData:null,logType:xi.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});this.shouldShowTourType={[Cr.Guided]:this.tourTypeOptions.map(e=>e.value).includes("WITH_AGENT")&&(t[Cr.Guided]||!!this.escortedToursLink),[Cr.Self]:this.tourTypeOptions.map(e=>e.value).includes("SELF_GUIDED")&&(t[Cr.Self]||!!this.sgtUrl),[Cr.Virtual]:this.tourTypeOptions.map(e=>e.value).includes("VIRTUAL_SHOWING")&&(t[Cr.Virtual]||!!this.virtualToursLink)};const r=1===Object.values(this.shouldShowTourType).reduce((e,t)=>!0===t?e+1:e,0);if(this._setDefaultSelectedDateAndTimes(),r&&(this.tourType=Object.keys(this.shouldShowTourType).find(e=>this.shouldShowTourType[e])),null===this.tourType)return void(this.waitingForAvailabilities=!1);this.availabilitiesGroupedByDay=await Xn(xr[this.tourType]),this.waitingForAvailabilities=!1}catch(e){this.errorGettingAvailabilities=!0,this.waitingForAvailabilities=!1,Ai({logTitle:"ERROR_LOADING_AVAILABILITIES",logData:{error:e},logType:xi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this._setDefaultSelectedDateAndTimes=async(e,t)=>{var n,i,r;const o=await Vn(this.buildingId),a=null!=e?e:this._getHighestRankedTourType(o),s=a?null===(r=null===(i=null===(n=o.availability)||void 0===n?void 0:n[a])||void 0===i?void 0:i.availableTourStartTimes)||void 0===r?void 0:r.filter(e=>{if(!t)return!0;return Wt("string"==typeof e?Rn(e):e,t)}):[],l=null==s?void 0:s[0];a&&l&&a!==In.Unknown&&a!==In.MediaTour&&(this.selectedDate=Qt("string"==typeof l?Rn(l):l),this.tourType=Ar[a],this.selectedTime="string"==typeof l?Zn(l):(e=>({datetime:Ft(e,"yyyy-MM-dd'T'HH:mm:ss"),offset:Ft(e,"xxx")}))(l))},this._getHighestRankedTourType=e=>{var t;const n=(null!==(t=e.rankOrderedSupportedTourTypes)&&void 0!==t?t:[]).map(t=>{var n,i;return{tourType:t,availabilities:null===(i=null===(n=e.availability)||void 0===n?void 0:n[t])||void 0===i?void 0:i.availableTourStartTimes}}).filter(e=>{if(e.tourType===In.Unknown||e.tourType===In.MediaTour)return!1;const t=Ar[e.tourType],n=this._getTourTypeOffered(t);return!!n&&(!Li(0,n)&&e.availabilities&&e.availabilities.length>0)}),i=n[0];return i?i.tourType:null},this._getTourTypeOffered=e=>e===Cr.Guided?this.escortedToursTypeOffered:e===Cr.Self?this.selfGuidedToursTypeOffered:e===Cr.Virtual?this.virtualToursTypeOffered:null,this._getUnitOptions=()=>{const e=this.selectedLayoutValue?this.units.filter(e=>Er(10*e.numberOfBedrooms)===this.selectedLayoutValue):this.units,t=e.map(e=>({label:e.unitNumber,value:e.unitNumber}));return t},this._fetchUnits=async()=>{if(this.buildingSlug)try{this.units=await br({buildingSlug:this.buildingSlug})}catch(e){this.units=[],Ai({logTitle:"ERROR_LOADING_UNITS_FOR_TOUR_SCHEDULER",logData:{error:e},logType:xi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this.firstUpdated=async()=>{await Promise.all([this._setAvailabilities().then(async()=>{try{const e=await Vn(this.buildingId);this.allowOccupiedUnitTours=!!e.allowOccupiedUnitTours}catch(e){this.allowOccupiedUnitTours=!1}}),this._fetchUnits()])},this.willUpdate=async e=>{e.has("tourType")&&this.tourType&&(this.availabilitiesGroupedByDay=await Xn(xr[this.tourType]))},this.handlePhoneKeydown=e=>{var t;if(!(e instanceof KeyboardEvent&&e.target instanceof HTMLInputElement&&null!==e.target.selectionStart))return;const n=e.target.selectionStart;if(1!==e.key.length||Ne(e)){if("Backspace"===e.key){if(Ne(e))return;if(this.phoneInput.selectionEnd&&this.phoneInput.selectionStart&&this.phoneInput.selectionEnd-this.phoneInput.selectionStart>0)return;const t=this.phoneNumber.length,i=this.phoneNumber.slice(0,n).replace(/\D/g,""),r=this.phoneNumber.slice(n).replace(/\D/g,""),o=`${i.slice(0,-1)}${r}`;this.phoneNumber=Pe(o),this.phoneInput.value=this.phoneNumber;const a=n-(t-this.phoneNumber.length);return this.phoneInput.setSelectionRange(a,a),e.preventDefault(),void e.stopPropagation()}if(!["ArrowLeft","ArrowRight"].includes(e.key)||Ne(e)||e.shiftKey)return;if("ArrowLeft"===e.key){const e=((null===(t=this.phoneNumber.slice(0,n).split(/\d+/).at(-1))||void 0===t?void 0:t.length)||0)+1,i=n-e>-1?n-e:0;this.phoneInput.setSelectionRange(i,i)}if("ArrowRight"===e.key){const e=(this.phoneNumber.slice(n).split(/\d+/)[0].length||0)+1,t=n+e<this.phoneNumber.length?n+e:this.phoneNumber.length;this.phoneInput.setSelectionRange(t,t)}e.preventDefault(),e.stopPropagation()}else{e.preventDefault(),e.stopPropagation();const t=this.phoneNumber.slice(0,n)+e.key+this.phoneNumber.slice(n);this.phoneNumber=Pe(t.replace(/\D/g,"")),this.phoneInput.value=this.phoneNumber}},this.handlePhoneKeyup=e=>{var t;if(!e.key)return;if(e.key.includes("Arrow")||["Meta","Shift","Control","Alt"].includes(e.key))return;const n=this.phoneInput.selectionStart,i=n?this.phoneInput.value.slice(n).replace(/\D/g,""):"";this.phoneNumber=Pe(this.phoneInput.value);let r=0,o=i.length;for(;o;)(null===(t=this.phoneNumber.at(r))||void 0===t?void 0:t.match(/\d/))&&o--,r++;const a=this.phoneInput.value.length-r+1;this.phoneInput.setSelectionRange(a,a)},this.onChangeEmail=e=>{e.target&&(this.email=e.target.value)},this.validators={tourType:()=>null!==this.tourType,dateAndTime:()=>!!this.selectedDate&&!!this.selectedTime,leadInfo:()=>{var e,t,n,i;return(!!(null===(e=this.firstNameInput)||void 0===e?void 0:e.value)||!!(null===(t=this.lastNameInput)||void 0===t?void 0:t.value))&&An(null!==(i=null===(n=this.emailInput)||void 0===n?void 0:n.value)&&void 0!==i?i:"")&&!!this.phoneNumber&&14===this.phoneNumber.length&&xn(this.phoneNumber)}},this.formIsValidForSubmission=()=>this.validators.tourType()&&this.validators.dateAndTime()&&this.validators.leadInfo(),this.timeStringToHoursAndMinutes=e=>{const[t,n]=e.split(/\D/g);return[parseInt(t)+(e.toLowerCase().includes("pm")?12:0),parseInt(n)]},this.submit=async()=>{var e,t,n,i,o,a,s,l,u,c,d,h,p,f,g,m,y,b,v,w,C,x,A;if(!this.selectedDate||!this.selectedTime||null===this.tourType)return;const S=new URLSearchParams(window.location.search);let E=null;E=this.selectedLeadSource&&this.selectedLeadSource.value&&this.selectedLeadSource.value.length>0?this.selectedLeadSource.value:this.leadSourceInputValue&&this.leadSourceInputValue.length>0?this.leadSourceInputValue:this.currentLeadSource;const k=[...new Set(E?[E,"property-website"]:["property-website"])];this.firstNameInput&&(this.firstNameInputValue=this.firstNameInput.value),this.lastNameInput&&(this.lastNameInputValue=this.lastNameInput.value),this.leadSourceInputValue=E;const T=(null===(e=this.selectedLayoutEl)||void 0===e?void 0:e.value)||this.selectedLayoutValue||null,_=(null===(t=this.selectedUnitEl)||void 0===t?void 0:t.value)||this.selectedUnitValue||null;ai("scheduleTourSubmitted",{email:this.email,phone:`+1${null===(n=this.phoneNumber.match(/\d/g))||void 0===n?void 0:n.join("")}`,firstName:null!==(o=null===(i=this.firstNameInput)||void 0===i?void 0:i.value)&&void 0!==o?o:this.firstNameInputValue,lastName:null!==(s=null===(a=this.lastNameInput)||void 0===a?void 0:a.value)&&void 0!==s?s:this.lastNameInputValue,tourType:Sr[this.tourType],tourTime:`${this.selectedTime.datetime}${this.selectedTime.offset}`,originatingSource:k.find(e=>"property-website"!==e)||null,layout:T,unit:_});const O={referrer:document.referrer,email_address:this.email,phone_number:`+1${null===(l=this.phoneNumber.match(/\d/g))||void 0===l?void 0:l.join("")}`,building_id:this.buildingId,first_name:null!==(c=null===(u=this.firstNameInput)||void 0===u?void 0:u.value)&&void 0!==c?c:this.firstNameInputValue,last_name:null!==(h=null===(d=this.lastNameInput)||void 0===d?void 0:d.value)&&void 0!==h?h:this.lastNameInputValue,tour_type:Sr[this.tourType],tour_time:`${this.selectedTime.datetime}${this.selectedTime.offset}`,cancel_existing_tours:this.promptForReschedule,lead_sources:[...new Set(E?[E,Oi(this.orgSlug)]:[Oi(this.orgSlug)])],query_params:Object.fromEntries(S.entries()),conversation_tracking_id:null===(p=this.leadSourceClient)||void 0===p?void 0:p.chatId,layouts:T?[T]:void 0,unit_numbers:_?[_]:void 0,lead_sources_with_timestamps:(null!==(m=null===(f=this.leadSourceMultitouchClient)||void 0===f?void 0:f.getSafeLeadSourceTouchpointsWithDefault({includedUserSelectedLeadSource:(null===(g=this.selectedLeadSource)||void 0===g?void 0:g.value)&&this.selectedLeadSource.value.length>0?this.selectedLeadSource.value:null}))&&void 0!==m?m:[]).map(e=>gn({...e}))};this.isSubmitting=!0;try{await r().post("https://app.meetelise.com/platformApi/state/create/v2/scheduleMe",O,{headers:{"building-slug":this.buildingSlug,"X-SecurityKey":"webchatkey-wkjcWAKZjqhLStvP8L6SN8y4FbYmPhdE","org-slug":this.orgSlug}}),null===(y=this.leadSourceClient)||void 0===y||y.checkAndHandleForLogLeadSource({webchatAction:"tour-scheduler",stateId:null}),null===(b=this.leadSourceClient)||void 0===b||b.resetLeadSource(),null===(v=this.leadSourceMultitouchClient)||void 0===v||v.resetLeadSourceTouchpoints(),this.isSubmitting=!1,this.tourIsBooked=!0}catch(e){const t=e,n=(null===(C=null===(w=t.response)||void 0===w?void 0:w.data)||void 0===C?void 0:C.detail)||"Failed to book tour";if(t.response&&t.response.headers&&t.response.headers["funnel-prospect-conflicting-appointment-error"]){if(this.selectedDate&&this.selectedTime){const e=this.availabilitiesGroupedByDay[Ft(this.selectedDate,"yyyy-MM-dd")];e&&(this.availabilitiesGroupedByDay[Ft(this.selectedDate,"yyyy-MM-dd")]=e.filter(e=>e!==this.selectedTime))}}else{if(409===(null===(x=t.response)||void 0===x?void 0:x.status)&&!this.promptForReschedule&&"User already has a tour scheduled for this building"===n)return this.promptForReschedule=!0,this.isSubmitting=!1,void(this.tourIsBooked=!1);if(409===(null===(A=t.response)||void 0===A?void 0:A.status)&&!this.promptForReschedule)return this.isSubmitting=!1,this.tourIsBooked=!1,qn(),this.availabilitiesGroupedByDay=await Xn(xr[this.tourType],this.buildingId),void alert("This timeslot is no longer available. Please select a different time.")}alert(n),this.isSubmitting=!1,this.tourIsBooked=!1}},this.mobilePages=[{validate:this.validators.tourType,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>B`${this.tourTypeMenu()}`},{validate:this.validators.dateAndTime,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>B`${this.dateAndTimeMenu()}`},{validate:()=>this.validators.leadInfo(),nextButtonText:null,renderNextButton:()=>B` <action-confirm-button
1289
+ `;class wi{constructor(e,t,n,i){this.org=e,this.building=t,this.chatId=n,this.incomingProcessedLeadSource=i,this.featureFlags={}}setFeatureFlags(e){this.featureFlags={...this.featureFlags,...e}}ping(e){var t;fetch("https://app.meetelise.com/platformApi/connectors/talk_js/analytics",{method:"POST",credentials:"omit",keepalive:!0,headers:{"content-type":"application/json; charset=UTF-8"},body:JSON.stringify({eventType:e,chatId:this.chatId,url:location.href,org:this.org,building:this.building,referrer:document.referrer,featureFlags:this.featureFlags,campaignSources:Ci(),incomingProcessedLeadSource:this.incomingProcessedLeadSource,webchatVersion:null!==(t="MISSING_ENV_VAR".npm_package_version)&&void 0!==t?t:"1.20.155"})})}}const Ci=()=>{var e,t,n,i,r,o;try{const i=new URL(window.location.href).searchParams,r=null!==(n=null===(t=null===(e=window.RCTPCampaign)||void 0===e?void 0:e.CampaignDetails)||void 0===t?void 0:t.Source)&&void 0!==n?n:null,o=i.get("switch_cls[id]"),a=i.get("ilm"),s=i.get("utm_source");return{entrataCampaignSource:o,realpageCampaignSource:a,utmCampaignSource:s,yardiCampaignSource:r,bozzutoAdSource:Cn("bozzuto_ad_source")}}catch(e){const t=document.createElement("iframe");if(t.style.display="none",document.body.appendChild(t),!t.contentWindow)return{entrataCampaignSource:null,realpageCampaignSource:null,utmCampaignSource:null,yardiCampaignSource:null,bozzutoAdSource:null};const n=t.contentWindow.URL;if(!n)return{entrataCampaignSource:null,realpageCampaignSource:null,utmCampaignSource:null,yardiCampaignSource:null,bozzutoAdSource:null};const a=new n(window.location.href).searchParams,s=null!==(o=null===(r=null===(i=window.RCTPCampaign)||void 0===i?void 0:i.CampaignDetails)||void 0===r?void 0:r.Source)&&void 0!==o?o:null;return{entrataCampaignSource:a.get("switch_cls[id]"),realpageCampaignSource:a.get("ilm"),utmCampaignSource:a.get("utm_source"),yardiCampaignSource:s,bozzutoAdSource:Cn("bozzuto_ad_source")}}};var xi;!function(e){e.error="error",e.info="info",e.warn="warn"}(xi||(xi={}));const Ai=async({logType:e,buildingSlug:t,orgSlug:n,logTitle:i,logData:o})=>{await r().post("https://app.meetelise.com/platformApi/webchat/logging",{...o},{headers:{"Content-Type":"application/json","building-slug":null!=t?t:"","org-slug":null!=n?n:"","log-type":null!=e?e:xi.error,"log-title":i.toUpperCase().replace(/\s/g,"_")}})},Si=async({params:e,sampleRate:t})=>{try{if(Math.random()>=t)return;await r().post("https://app.meetelise.com/platformApi/webchat/log/signal",{...e,website_origin:window.location.origin,website_search:window.location.search})}catch(e){}};function Ei(){return ki()?function(){const e=window.location.search,t={},n=e.split("?").slice(1).join("&");return n.split("&").forEach(e=>{const[n,i]=e.split("=");n&&i&&(t[decodeURIComponent(n)]=decodeURIComponent(i))}),t}():function(){const e=new URLSearchParams(window.location.search),t=e.has("utm_content"),n=e.has("utm_source");if(t&&!n){const t=e.get("utm_content");e.delete("utm_content"),e.set("utm_source",t)}return Object.fromEntries(e)}()}const ki=()=>(window.location.search.match(/\?/g)||[]).length>1;var Ti=n(2193),_i=n.n(Ti);function Oi(e){return"avb"===e?"AVB Company Website":"windsor"===e?"Windsorcommunities.com":"property-website"}const Pi=class{constructor(){this.chatId=null,this.apiHost="https://app.meetelise.com",this.leadSource=null,this.localStorageTTLDays=30,this.buildingId=null,this.orgSlug=null,this.buildingSlug=null,this.queryParameters=null,this.leadSourceInput=null,this.updateLeadSourceLocalStorage=(e,t,n,i,r)=>{const o=Ei();if(this.leadSourceInput={websiteOrigin:window.location.origin,websiteSearch:window.location.search,queryParameters:o,referrer:document.referrer,parsedUtmSource:o?o.utm_source:null,campaignSources:Object.values(Ci()).filter(e=>e)},i)return;if(!r){const t=this.getLeadSourceBodyIfValid(e);if(t){if(!wn(t.timestamp,24*this.localStorageTTLDays))return{...t,timestamp:Rn(t.timestamp)}}}const a={leadSource:t,leadId:n,buildingSlug:e,timestamp:On(new Date),leadSourceInput:this.leadSourceInput};return localStorage.setItem("com.elise.webchat.leadsource.slug="+e,JSON.stringify(a)),{...a,timestamp:Rn(a.timestamp)}},this.getLeadSourceBodyIfValid=e=>{const t=localStorage.getItem("com.elise.webchat.leadsource.slug="+e);if(t)try{const n=JSON.parse(t);if(n.buildingSlug===e&&n.leadSource&&n.leadId&&n.timestamp&&!wn(Rn(n.timestamp),24*this.localStorageTTLDays)){try{this.leadSourceInput=n.leadSourceInput}catch(e){}return n}}catch(e){return null}return null},this.resetLeadSource=()=>{if(!this.buildingSlug)return!1;const e="com.elise.webchat.leadsource.slug="+this.buildingSlug;return localStorage.removeItem(e),!0}}async fetchCurrentParsedLeadSource({buildingSlug:e,queryParams:t,referrer:n,campaignSources:i}){try{return(await r().post(`${this.apiHost}/platformApi/webchat/current-parsed-lead-source`,{query_params:t,building_slug:e,referrer:n,campaign_sources:i})).data}catch(e){return null}}async checkAndHandleForLogLeadSource({webchatAction:e,stateId:t}){var n,i,o,a,s,l,u;try{if(!this.chatId)return null;if(!this.orgSlug)return null;let c=null,d=null;try{if("f1ba5a20-d207-4e5a-879e-65199e7d0a53"===this.orgSlug){const e=await this.getCookieValue("_ga");e&&(c=e),d=null===(n=window.dataLayer.find(e=>{var t;return"gtagApiGet"==(null===(t=e.value)||void 0===t?void 0:t.event)}))||void 0===n?void 0:n.value}}catch(e){}return await r().post(`${this.apiHost}/platformApi/webchat/log/lead-source`,{chat_id:this.chatId,webchat_action:e,state_id:t,building_id:this.buildingId,org_slug:this.orgSlug,building_slug:this.buildingSlug,website_origin:null===(i=this.leadSourceInput)||void 0===i?void 0:i.websiteOrigin,website_search:null===(o=this.leadSourceInput)||void 0===o?void 0:o.websiteSearch,query_parameters:null===(a=this.leadSourceInput)||void 0===a?void 0:a.queryParameters,referrer:null===(s=this.leadSourceInput)||void 0===s?void 0:s.referrer,parsed_utm_source:null===(l=this.leadSourceInput)||void 0===l?void 0:l.parsedUtmSource,campaign_sources:null===(u=this.leadSourceInput)||void 0===u?void 0:u.campaignSources,lead_source_output:this.leadSource,google_analytics_client_id:_i()(c)?null:c,extras:null!=d?d:null}),null}catch(e){return null}}async getCookieValue(e){try{const t=document.cookie.split(";");for(let n=0;n<t.length;n++){const i=t[n].trim();if(i.startsWith(e+"=")){return i.substring((e+"=").length,-1===i.indexOf(";")?void 0:i.indexOf(";"))}}return null}catch(e){}return null}async generateUserLeadSource({leadId:e,orgSlug:t,buildingSlug:n}){try{const i={queryParams:Ei(),buildingSlug:n,referrer:document.referrer,campaignSources:Ci()};let r=!1;const o=n?this.getLeadSourceBodyIfValid(n):null;if(o){if(!["test-company","daf00bd2-1ecb-482c-b6f4-e1c5511a01be"].includes(t))return this.leadSource=o.leadSource,this.leadSource;{const e=await this.fetchCurrentParsedLeadSource(i);if(!e)return this.leadSource=o.leadSource,this.leadSource;this.leadSource=e,r=!0}}const a=await this.fetchCurrentParsedLeadSource(i);if(this.leadSource=a,this.buildingId=null,this.orgSlug=t,this.buildingSlug=n,n&&!a){const e=this.getLeadSourceBodyIfValid(n);if(e)return this.leadSource=e.leadSource,this.leadSource}if(n){const t=!!a&&a.length>0;this.updateLeadSourceLocalStorage(n,a,e,!t&&!r,r)}return a}catch(e){}return null}},Ii=async(e,t=!1)=>{const n=`https://app.meetelise.com/eliseCrmApi/building/${e}/scheduling_status?observe_dynamic_scheduling=${t}`;try{return(await r().get(n)).data.is_enabled}catch(e){return!1}};var Mi,Ni,Di;!function(e){e.EMOJI="emoji",e.PILLS="pills",e.MINIMIZED="minimized"}(Mi||(Mi={})),function(e){e.UNKNOWN="UNKNOWN",e.SELF_GUIDED="SELF_GUIDED",e.VIRTUAL_SHOWING="VIRTUAL_SHOWING",e.WITH_AGENT="WITH_AGENT",e.MEDIA_TOUR="MEDIA_TOUR",e.OPEN_HOUSE_STUDIO="OPEN_HOUSE_STUDIO",e.OPEN_HOUSE_1BR="OPEN_HOUSE_1BR",e.OPEN_HOUSE_2BR="OPEN_HOUSE_2BR",e.OPEN_HOUSE_3BR="OPEN_HOUSE_3BR",e.OPEN_HOUSE_4BR="OPEN_HOUSE_4BR",e.OPEN_HOUSE_5BR="OPEN_HOUSE_5BR"}(Ni||(Ni={})),function(e){e.LINK="link",e.CLIENT_SCHEDULED="client_scheduled",e.SCHEDULED_BY_ME_MANAGED_BY_ME="scheduled_by_ME_managed_by_ME",e.SCHEDULED_BY_ME_MANAGED_BY_CLIENT="scheduled_by_ME_managed_by_client",e.SCHEDULED_BY_ME_MANAGED_BY_CONCIERGE="scheduled_by_ME_managed_by_concierge"}(Di||(Di={}));const Li=(e,t)=>"link"===(null==t?void 0:t.toLowerCase());async function Ui(e,t){var n;const i=`https://app.meetelise.com/api/pub/v1/organization/${e}/building/${t}/v2`,o=(await r().get(i)).data;try{o.welcomeMessage=Ri(null!==(n=o.welcomeMessage)&&void 0!==n?n:"",o.userFirstName)}catch(e){}return o}const Ri=(e,t)=>e.replace(/elise/gi,t);var Bi=n(7035),ji=n(6353);function Fi(e,t,n){var i=function(e,t,n){if(n&&!n.code)throw new Error("date-fns-tz error: Please set a language code on the locale object imported from date-fns, e.g. `locale.code = 'en-US'`");return new Intl.DateTimeFormat(n?[n.code,"en-US"]:void 0,{timeZone:t,timeZoneName:e})}(e,n.timeZone,n.locale);return i.formatToParts?function(e,t){for(var n=e.formatToParts(t),i=n.length-1;i>=0;--i)if("timeZoneName"===n[i].type)return n[i].value}(i,t):function(e,t){var n=e.format(t).replace(/\u200E/g,""),i=/ [\w-+ ]+$/.exec(n);return i?i[0].substr(1):""}(i,t)}function Hi(e,t){var n=function(e){if(!zi[e]){var t=new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:"America/New_York",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date("2014-06-25T04:00:00.123Z")),n="06/25/2014, 00:00:00"===t||"‎06‎/‎25‎/‎2014‎ ‎00‎:‎00‎:‎00"===t;zi[e]=n?new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}return zi[e]}(t);return n.formatToParts?function(e,t){try{for(var n=e.formatToParts(t),i=[],r=0;r<n.length;r++){var o=$i[n[r].type];o>=0&&(i[o]=parseInt(n[r].value,10))}return i}catch(e){if(e instanceof RangeError)return[NaN];throw e}}(n,e):function(e,t){var n=e.format(t),i=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(n);return[i[3],i[1],i[2],i[4],i[5],i[6]]}(n,e)}var $i={year:0,month:1,day:2,hour:3,minute:4,second:5};var zi={};function Gi(e,t,n,i,r,o,a){var s=new Date(0);return s.setUTCFullYear(e,t,n),s.setUTCHours(i,r,o,a),s}var Qi=36e5,Wi={timezone:/([Z+-].*)$/,timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-])(\d{2}):?(\d{2})$/};function qi(e,t,n){var i,r,o;if(!e)return 0;if(i=Wi.timezoneZ.exec(e))return 0;if(i=Wi.timezoneHH.exec(e))return Yi(o=parseInt(i[1],10))?-o*Qi:NaN;if(i=Wi.timezoneHHMM.exec(e)){o=parseInt(i[2],10);var a=parseInt(i[3],10);return Yi(o,a)?(r=Math.abs(o)*Qi+6e4*a,"+"===i[1]?-r:r):NaN}if(function(e){if(Ki[e])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),Ki[e]=!0,!0}catch(e){return!1}}(e)){t=new Date(t||Date.now());var s=n?t:function(e){return Gi(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}(t),l=Vi(s,e),u=n?l:function(e,t,n){var i=e.getTime(),r=i-t,o=Vi(new Date(r),n);if(t===o)return t;r-=o-t;var a=Vi(new Date(r),n);if(o===a)return o;return Math.max(o,a)}(t,l,e);return-u}return NaN}function Vi(e,t){var n=Hi(e,t),i=Gi(n[0],n[1]-1,n[2],n[3]%24,n[4],n[5],0).getTime(),r=e.getTime(),o=r%1e3;return i-(r-=o>=0?o:1e3+o)}function Yi(e,t){return-23<=e&&e<=23&&(null==t||0<=t&&t<=59)}var Ki={};var Xi={X:function(e,t,n,i){var r=Zi(i.timeZone,e);if(0===r)return"Z";switch(t){case"X":return tr(r);case"XXXX":case"XX":return er(r);default:return er(r,":")}},x:function(e,t,n,i){var r=Zi(i.timeZone,e);switch(t){case"x":return tr(r);case"xxxx":case"xx":return er(r);default:return er(r,":")}},O:function(e,t,n,i){var r=Zi(i.timeZone,e);switch(t){case"O":case"OO":case"OOO":return"GMT"+function(e,t){var n=e>0?"-":"+",i=Math.abs(e),r=Math.floor(i/60),o=i%60;if(0===o)return n+String(r);var a=t||"";return n+String(r)+a+Ji(o,2)}(r,":");default:return"GMT"+er(r,":")}},z:function(e,t,n,i){switch(t){case"z":case"zz":case"zzz":return Fi("short",e,i);default:return Fi("long",e,i)}}};function Zi(e,t){var n=e?qi(e,t,!0)/6e4:t.getTimezoneOffset();if(Number.isNaN(n))throw new RangeError("Invalid time zone specified: "+e);return n}function Ji(e,t){for(var n=e<0?"-":"",i=Math.abs(e).toString();i.length<t;)i="0"+i;return n+i}function er(e,t){var n=t||"",i=e>0?"-":"+",r=Math.abs(e);return i+Ji(Math.floor(r/60),2)+n+Ji(Math.floor(r%60),2)}function tr(e,t){return e%60==0?(e>0?"-":"+")+Ji(Math.abs(e)/60,2):er(e,t)}const nr=Xi;var ir=n(9784),rr=n(9720);var or=36e5,ar=6e4,sr={dateTimePattern:/^([0-9W+-]+)(T| )(.*)/,datePattern:/^([0-9W+-]+)(.*)/,plainTime:/:/,YY:/^(\d{2})$/,YYY:[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],YYYY:/^(\d{4})/,YYYYY:[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],MM:/^-(\d{2})$/,DDD:/^-?(\d{3})$/,MMDD:/^-?(\d{2})-?(\d{2})$/,Www:/^-?W(\d{2})$/,WwwD:/^-?W(\d{2})-?(\d{1})$/,HH:/^(\d{2}([.,]\d*)?)$/,HHMM:/^(\d{2}):?(\d{2}([.,]\d*)?)$/,HHMMSS:/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,timeZone:/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/};function lr(e,t){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(null===e)return new Date(NaN);var n=t||{},i=null==n.additionalDigits?2:ir(n.additionalDigits);if(2!==i&&1!==i&&0!==i)throw new RangeError("additionalDigits must be 0, 1 or 2");if(e instanceof Date||"object"==typeof e&&"[object Date]"===Object.prototype.toString.call(e))return new Date(e.getTime());if("number"==typeof e||"[object Number]"===Object.prototype.toString.call(e))return new Date(e);if("string"!=typeof e&&"[object String]"!==Object.prototype.toString.call(e))return new Date(NaN);var r=function(e){var t,n={},i=sr.dateTimePattern.exec(e);i?(n.date=i[1],t=i[3]):(i=sr.datePattern.exec(e))?(n.date=i[1],t=i[2]):(n.date=null,t=e);if(t){var r=sr.timeZone.exec(t);r?(n.time=t.replace(r[1],""),n.timeZone=r[1].trim()):n.time=t}return n}(e),o=function(e,t){var n,i=sr.YYY[t],r=sr.YYYYY[t];if(n=sr.YYYY.exec(e)||r.exec(e)){var o=n[1];return{year:parseInt(o,10),restDateString:e.slice(o.length)}}if(n=sr.YY.exec(e)||i.exec(e)){var a=n[1];return{year:100*parseInt(a,10),restDateString:e.slice(a.length)}}return{year:null}}(r.date,i),a=o.year,s=function(e,t){if(null===t)return null;var n,i,r,o;if(0===e.length)return(i=new Date(0)).setUTCFullYear(t),i;if(n=sr.MM.exec(e))return i=new Date(0),pr(t,r=parseInt(n[1],10)-1)?(i.setUTCFullYear(t,r),i):new Date(NaN);if(n=sr.DDD.exec(e)){i=new Date(0);var a=parseInt(n[1],10);return function(e,t){if(t<1)return!1;var n=hr(e);if(n&&t>366)return!1;if(!n&&t>365)return!1;return!0}(t,a)?(i.setUTCFullYear(t,0,a),i):new Date(NaN)}if(n=sr.MMDD.exec(e)){i=new Date(0),r=parseInt(n[1],10)-1;var s=parseInt(n[2],10);return pr(t,r,s)?(i.setUTCFullYear(t,r,s),i):new Date(NaN)}if(n=sr.Www.exec(e))return fr(t,o=parseInt(n[1],10)-1)?ur(t,o):new Date(NaN);if(n=sr.WwwD.exec(e)){o=parseInt(n[1],10)-1;var l=parseInt(n[2],10)-1;return fr(t,o,l)?ur(t,o,l):new Date(NaN)}return null}(o.restDateString,a);if(isNaN(s))return new Date(NaN);if(s){var l,u=s.getTime(),c=0;if(r.time&&(c=function(e){var t,n,i;if(t=sr.HH.exec(e))return gr(n=parseFloat(t[1].replace(",",".")))?n%24*or:NaN;if(t=sr.HHMM.exec(e))return gr(n=parseInt(t[1],10),i=parseFloat(t[2].replace(",",".")))?n%24*or+i*ar:NaN;if(t=sr.HHMMSS.exec(e)){n=parseInt(t[1],10),i=parseInt(t[2],10);var r=parseFloat(t[3].replace(",","."));return gr(n,i,r)?n%24*or+i*ar+1e3*r:NaN}return null}(r.time),isNaN(c)))return new Date(NaN);if(r.timeZone||n.timeZone){if(l=qi(r.timeZone||n.timeZone,new Date(u+c)),isNaN(l))return new Date(NaN)}else l=rr(new Date(u+c)),l=rr(new Date(u+c+l));return new Date(u+c+l)}return new Date(NaN)}function ur(e,t,n){t=t||0,n=n||0;var i=new Date(0);i.setUTCFullYear(e,0,4);var r=7*t+n+1-(i.getUTCDay()||7);return i.setUTCDate(i.getUTCDate()+r),i}var cr=[31,28,31,30,31,30,31,31,30,31,30,31],dr=[31,29,31,30,31,30,31,31,30,31,30,31];function hr(e){return e%400==0||e%4==0&&e%100!=0}function pr(e,t,n){if(t<0||t>11)return!1;if(null!=n){if(n<1)return!1;var i=hr(e);if(i&&n>dr[t])return!1;if(!i&&n>cr[t])return!1}return!0}function fr(e,t,n){return!(t<0||t>52)&&(null==n||!(n<0||n>6))}function gr(e,t,n){return(null==e||!(e<0||e>=25))&&((null==t||!(t<0||t>=60))&&(null==n||!(n<0||n>=60)))}var mr=/([xXOz]+)|''|'(''|[^'])+('|$)/g;function yr(e,t,n,i){var r=Bi(i);return r.timeZone=t,r.originalDate=e,function(e,t,n){var i=String(t),r=n||{},o=i.match(mr);if(o){var a=lr(r.originalDate||e,r);i=o.reduce(function(e,t){if("'"===t[0])return e;var n=e.indexOf(t),i="'"===e[n-1],o=e.replace(t,"'"+nr[t[0]](a,t,null,r)+"'");return i?o.substring(0,n-1)+o.substring(n+1):o},i)}return ji(e,i,r)}(function(e,t,n){var i=lr(e,n),r=qi(t,i,!0),o=new Date(i.getTime()-r),a=new Date(0);return a.setFullYear(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate()),a.setHours(o.getUTCHours(),o.getUTCMinutes(),o.getUTCSeconds(),o.getUTCMilliseconds()),a}(e,t),n,r)}const br=async({buildingSlug:e})=>{try{const t=await r().get(`${hn}/platformApi/webchat/${e}/units/summary`);if(t.data)return fn(t.data)}catch(t){Ai({logType:xi.error,buildingSlug:e,logTitle:"[ERROR_GETTING_UNITS_SUMMARY]",logData:{error:t}})}return[]};var vr=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a};let wr=class extends oe{constructor(){super(...arguments),this.tourTypeOptions=[],this.layoutOptions=[],this.chatId="",this.buildingId=0,this.buildingSlug="",this.sgtUrl="",this.selfGuidedToursTypeOffered="",this.selfGuidedTourEnabled=!1,this.escortedToursLink="",this.escortedToursTypeOffered="",this.virtualToursLink="",this.virtualToursTypeOffered="",this.orgSlug="",this.hasDynamicSchedulingEnabled=!1,this.leadSourceClient=null,this.leadSourceMultitouchClient=null,this.buildingName="",this.tourType=null,this.shouldShowTourType={[Cr.Guided]:!0,[Cr.Self]:!0,[Cr.Virtual]:!0},this.email="",this.phoneNumber="",this.availabilitiesGroupedByDay={},this.calendarTimeZone=Intl.DateTimeFormat().resolvedOptions().timeZone,this.waitingForAvailabilities=!0,this.mobilePageIndex=0,this.isSubmitting=!1,this.tourIsBooked=!1,this.shouldAllowScheduling=!1,this.shouldAllowScheduleLoading=!0,this.promptForReschedule=!1,this.canceledReschedule=!1,this.leadSources=[],this.orgLegalName="",this.currentLeadSource="",this.featureFlagShowDropdown="",this.compactDesign=!1,this.primaryColor=Ue,this.backgroundColor=Re,this.foregroundColorOnPrimaryBackgroundColor="white",this.foregroundColorOnSecondaryBackgroundColor="black",this.firstNameInputValue="",this.lastNameInputValue="",this.leadSourceInputValue="",this.selectedLayoutValue="",this.selectedUnitValue="",this.units=[],this.allowOccupiedUnitTours=!1,this.errorGettingAvailabilities=!1,this.centralConvoBuildings=[],this.statusMessage="",this._setAvailabilities=async()=>{try{const[e,t]=await Promise.all([Ii(this.buildingId,this.hasDynamicSchedulingEnabled),Kn()]);this.shouldAllowScheduling=e,this.shouldAllowScheduleLoading=!1,this.calendarTimeZone=await(async e=>{var t;return null!==(t=(await Vn(e)).calendarTimeZone)&&void 0!==t?t:Intl.DateTimeFormat().resolvedOptions().timeZone})(this.buildingId),Ai({logTitle:"AVAILABILITIES_EXIST_FOR_TOUR_TYPE",logData:t,logType:xi.info,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});const n=Object.values(t).every(e=>!1===e),i=!this.sgtUrl&&!this.escortedToursLink&&!this.virtualToursLink;if(n&&i)return this.errorGettingAvailabilities=!0,this.waitingForAvailabilities=!1,void Ai({logTitle:"NO_AVAILABILITIES_EXIST",logData:null,logType:xi.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});this.shouldShowTourType={[Cr.Guided]:this.tourTypeOptions.map(e=>e.value).includes("WITH_AGENT")&&(t[Cr.Guided]||!!this.escortedToursLink),[Cr.Self]:this.tourTypeOptions.map(e=>e.value).includes("SELF_GUIDED")&&(t[Cr.Self]||!!this.sgtUrl),[Cr.Virtual]:this.tourTypeOptions.map(e=>e.value).includes("VIRTUAL_SHOWING")&&(t[Cr.Virtual]||!!this.virtualToursLink)};const r=1===Object.values(this.shouldShowTourType).reduce((e,t)=>!0===t?e+1:e,0);if(this._setDefaultSelectedDateAndTimes(),r&&(this.tourType=Object.keys(this.shouldShowTourType).find(e=>this.shouldShowTourType[e])),null===this.tourType)return void(this.waitingForAvailabilities=!1);this.availabilitiesGroupedByDay=await Xn(xr[this.tourType]),this.waitingForAvailabilities=!1}catch(e){this.errorGettingAvailabilities=!0,this.waitingForAvailabilities=!1,Ai({logTitle:"ERROR_LOADING_AVAILABILITIES",logData:{error:e},logType:xi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this._setDefaultSelectedDateAndTimes=async(e,t)=>{var n,i,r;const o=await Vn(this.buildingId),a=null!=e?e:this._getHighestRankedTourType(o),s=a?null===(r=null===(i=null===(n=o.availability)||void 0===n?void 0:n[a])||void 0===i?void 0:i.availableTourStartTimes)||void 0===r?void 0:r.filter(e=>{if(!t)return!0;return Wt("string"==typeof e?Rn(e):e,t)}):[],l=null==s?void 0:s[0];a&&l&&a!==In.Unknown&&a!==In.MediaTour&&(this.selectedDate=Qt("string"==typeof l?Rn(l):l),this.tourType=Ar[a],this.selectedTime="string"==typeof l?Zn(l):(e=>({datetime:Ft(e,"yyyy-MM-dd'T'HH:mm:ss"),offset:Ft(e,"xxx")}))(l))},this._getHighestRankedTourType=e=>{var t;const n=(null!==(t=e.rankOrderedSupportedTourTypes)&&void 0!==t?t:[]).map(t=>{var n,i;return{tourType:t,availabilities:null===(i=null===(n=e.availability)||void 0===n?void 0:n[t])||void 0===i?void 0:i.availableTourStartTimes}}).filter(e=>{if(e.tourType===In.Unknown||e.tourType===In.MediaTour)return!1;const t=Ar[e.tourType],n=this._getTourTypeOffered(t);return!!n&&(!Li(0,n)&&e.availabilities&&e.availabilities.length>0)}),i=n[0];return i?i.tourType:null},this._getTourTypeOffered=e=>e===Cr.Guided?this.escortedToursTypeOffered:e===Cr.Self?this.selfGuidedToursTypeOffered:e===Cr.Virtual?this.virtualToursTypeOffered:null,this._getUnitOptions=()=>{const e=this.selectedLayoutValue?this.units.filter(e=>Er(10*e.numberOfBedrooms)===this.selectedLayoutValue):this.units,t=e.map(e=>({label:e.unitNumber,value:e.unitNumber}));return t},this._fetchUnits=async()=>{if(this.buildingSlug)try{this.units=await br({buildingSlug:this.buildingSlug})}catch(e){this.units=[],Ai({logTitle:"ERROR_LOADING_UNITS_FOR_TOUR_SCHEDULER",logData:{error:e},logType:xi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this.firstUpdated=async()=>{this._fetchCentralConvoBuildings(),await this._loadForCurrentBuilding()},this._loadForCurrentBuilding=async()=>{try{await Vn(this.buildingId)}catch(e){}await Promise.all([this._setAvailabilities().then(async()=>{try{const e=await Vn(this.buildingId);this.allowOccupiedUnitTours=!!e.allowOccupiedUnitTours}catch(e){this.allowOccupiedUnitTours=!1}}),this._fetchUnits()])},this._fetchCentralConvoBuildings=async()=>{if(this.orgSlug&&this.buildingSlug)try{this.centralConvoBuildings=await async function(e,t){var n;return null!==(n=(await r().get("https://app.meetelise.com/platformApi/webchat/central-convo-buildings",{headers:{"building-slug":t,"org-slug":e}})).data)&&void 0!==n?n:[]}(this.orgSlug,this.buildingSlug)}catch(e){this.centralConvoBuildings=[]}},this._onBuildingChange=async()=>{var e;const t=null===(e=this.selectedBuildingEl)||void 0===e?void 0:e.value;if(!t||t===this.buildingSlug)return;const n=this.centralConvoBuildings.find(e=>e.slug===t);if(n){this.waitingForAvailabilities=!0,this.errorGettingAvailabilities=!1,this.tourType=null,this.selectedDate=void 0,this.selectedTime=void 0,this.availabilitiesGroupedByDay={},this.mobilePageIndex=0,this.units=[],this.selectedLayoutValue="",this.selectedUnitValue="",this.buildingId=n.building_id,this.buildingSlug=n.slug,this.buildingName=n.name,this.statusMessage=`Loading tours for ${n.name}…`,ai("tourBuildingSelected",{buildingId:n.building_id});try{const e=await Ui(this.orgSlug,n.slug);this.sgtUrl=e.sgtUrl,this.selfGuidedToursTypeOffered=e.selfGuidedToursTypeOffered,this.selfGuidedTourEnabled=e.isSelfGuidedTourEnabled,this.escortedToursLink=e.escortedToursLink,this.escortedToursTypeOffered=e.escortedToursTypeOffered,this.virtualToursLink=e.virtualToursLink,this.virtualToursTypeOffered=e.virtualToursTypeOffered,this.tourTypeOptions=e.tourTypeOptions.map(e=>({label:e.label,value:e.value})),this.hasDynamicSchedulingEnabled=e.usesDynamicScheduling}catch(e){}if(await this._loadForCurrentBuilding(),!this.shouldAllowScheduling||this.errorGettingAvailabilities)this.statusMessage=`No tour availabilities for ${n.name}.`;else{const e=Object.values(this.shouldShowTourType).filter(Boolean).length;this.statusMessage=`Showing tours for ${n.name}. ${e} tour type${1===e?"":"s"} available.`}}},this.willUpdate=async e=>{e.has("tourType")&&this.tourType&&(this.availabilitiesGroupedByDay=await Xn(xr[this.tourType]))},this.handlePhoneKeydown=e=>{var t;if(!(e instanceof KeyboardEvent&&e.target instanceof HTMLInputElement&&null!==e.target.selectionStart))return;const n=e.target.selectionStart;if(1!==e.key.length||Ne(e)){if("Backspace"===e.key){if(Ne(e))return;if(this.phoneInput.selectionEnd&&this.phoneInput.selectionStart&&this.phoneInput.selectionEnd-this.phoneInput.selectionStart>0)return;const t=this.phoneNumber.length,i=this.phoneNumber.slice(0,n).replace(/\D/g,""),r=this.phoneNumber.slice(n).replace(/\D/g,""),o=`${i.slice(0,-1)}${r}`;this.phoneNumber=Pe(o),this.phoneInput.value=this.phoneNumber;const a=n-(t-this.phoneNumber.length);return this.phoneInput.setSelectionRange(a,a),e.preventDefault(),void e.stopPropagation()}if(!["ArrowLeft","ArrowRight"].includes(e.key)||Ne(e)||e.shiftKey)return;if("ArrowLeft"===e.key){const e=((null===(t=this.phoneNumber.slice(0,n).split(/\d+/).at(-1))||void 0===t?void 0:t.length)||0)+1,i=n-e>-1?n-e:0;this.phoneInput.setSelectionRange(i,i)}if("ArrowRight"===e.key){const e=(this.phoneNumber.slice(n).split(/\d+/)[0].length||0)+1,t=n+e<this.phoneNumber.length?n+e:this.phoneNumber.length;this.phoneInput.setSelectionRange(t,t)}e.preventDefault(),e.stopPropagation()}else{e.preventDefault(),e.stopPropagation();const t=this.phoneNumber.slice(0,n)+e.key+this.phoneNumber.slice(n);this.phoneNumber=Pe(t.replace(/\D/g,"")),this.phoneInput.value=this.phoneNumber}},this.handlePhoneKeyup=e=>{var t;if(!e.key)return;if(e.key.includes("Arrow")||["Meta","Shift","Control","Alt"].includes(e.key))return;const n=this.phoneInput.selectionStart,i=n?this.phoneInput.value.slice(n).replace(/\D/g,""):"";this.phoneNumber=Pe(this.phoneInput.value);let r=0,o=i.length;for(;o;)(null===(t=this.phoneNumber.at(r))||void 0===t?void 0:t.match(/\d/))&&o--,r++;const a=this.phoneInput.value.length-r+1;this.phoneInput.setSelectionRange(a,a)},this.onChangeEmail=e=>{e.target&&(this.email=e.target.value)},this.validators={tourType:()=>null!==this.tourType,dateAndTime:()=>!!this.selectedDate&&!!this.selectedTime,leadInfo:()=>{var e,t,n,i;return(!!(null===(e=this.firstNameInput)||void 0===e?void 0:e.value)||!!(null===(t=this.lastNameInput)||void 0===t?void 0:t.value))&&An(null!==(i=null===(n=this.emailInput)||void 0===n?void 0:n.value)&&void 0!==i?i:"")&&!!this.phoneNumber&&14===this.phoneNumber.length&&xn(this.phoneNumber)}},this.formIsValidForSubmission=()=>this.validators.tourType()&&this.validators.dateAndTime()&&this.validators.leadInfo(),this.timeStringToHoursAndMinutes=e=>{const[t,n]=e.split(/\D/g);return[parseInt(t)+(e.toLowerCase().includes("pm")?12:0),parseInt(n)]},this.submit=async()=>{var e,t,n,i,o,a,s,l,u,c,d,h,p,f,g,m,y,b,v,w,C,x,A;if(!this.selectedDate||!this.selectedTime||null===this.tourType)return;const S=new URLSearchParams(window.location.search);let E=null;E=this.selectedLeadSource&&this.selectedLeadSource.value&&this.selectedLeadSource.value.length>0?this.selectedLeadSource.value:this.leadSourceInputValue&&this.leadSourceInputValue.length>0?this.leadSourceInputValue:this.currentLeadSource;const k=[...new Set(E?[E,"property-website"]:["property-website"])];this.firstNameInput&&(this.firstNameInputValue=this.firstNameInput.value),this.lastNameInput&&(this.lastNameInputValue=this.lastNameInput.value),this.leadSourceInputValue=E;const T=(null===(e=this.selectedLayoutEl)||void 0===e?void 0:e.value)||this.selectedLayoutValue||null,_=(null===(t=this.selectedUnitEl)||void 0===t?void 0:t.value)||this.selectedUnitValue||null;ai("scheduleTourSubmitted",{email:this.email,phone:`+1${null===(n=this.phoneNumber.match(/\d/g))||void 0===n?void 0:n.join("")}`,firstName:null!==(o=null===(i=this.firstNameInput)||void 0===i?void 0:i.value)&&void 0!==o?o:this.firstNameInputValue,lastName:null!==(s=null===(a=this.lastNameInput)||void 0===a?void 0:a.value)&&void 0!==s?s:this.lastNameInputValue,tourType:Sr[this.tourType],tourTime:`${this.selectedTime.datetime}${this.selectedTime.offset}`,originatingSource:k.find(e=>"property-website"!==e)||null,layout:T,unit:_});const O={referrer:document.referrer,email_address:this.email,phone_number:`+1${null===(l=this.phoneNumber.match(/\d/g))||void 0===l?void 0:l.join("")}`,building_id:this.buildingId,first_name:null!==(c=null===(u=this.firstNameInput)||void 0===u?void 0:u.value)&&void 0!==c?c:this.firstNameInputValue,last_name:null!==(h=null===(d=this.lastNameInput)||void 0===d?void 0:d.value)&&void 0!==h?h:this.lastNameInputValue,tour_type:Sr[this.tourType],tour_time:`${this.selectedTime.datetime}${this.selectedTime.offset}`,cancel_existing_tours:this.promptForReschedule,lead_sources:[...new Set(E?[E,Oi(this.orgSlug)]:[Oi(this.orgSlug)])],query_params:Object.fromEntries(S.entries()),conversation_tracking_id:null===(p=this.leadSourceClient)||void 0===p?void 0:p.chatId,layouts:T?[T]:void 0,unit_numbers:_?[_]:void 0,lead_sources_with_timestamps:(null!==(m=null===(f=this.leadSourceMultitouchClient)||void 0===f?void 0:f.getSafeLeadSourceTouchpointsWithDefault({includedUserSelectedLeadSource:(null===(g=this.selectedLeadSource)||void 0===g?void 0:g.value)&&this.selectedLeadSource.value.length>0?this.selectedLeadSource.value:null}))&&void 0!==m?m:[]).map(e=>gn({...e}))};this.isSubmitting=!0;try{await r().post("https://app.meetelise.com/platformApi/state/create/v2/scheduleMe",O,{headers:{"building-slug":this.buildingSlug,"X-SecurityKey":"webchatkey-wkjcWAKZjqhLStvP8L6SN8y4FbYmPhdE","org-slug":this.orgSlug}}),null===(y=this.leadSourceClient)||void 0===y||y.checkAndHandleForLogLeadSource({webchatAction:"tour-scheduler",stateId:null}),null===(b=this.leadSourceClient)||void 0===b||b.resetLeadSource(),null===(v=this.leadSourceMultitouchClient)||void 0===v||v.resetLeadSourceTouchpoints(),this.isSubmitting=!1,this.tourIsBooked=!0}catch(e){const t=e,n=(null===(C=null===(w=t.response)||void 0===w?void 0:w.data)||void 0===C?void 0:C.detail)||"Failed to book tour";if(t.response&&t.response.headers&&t.response.headers["funnel-prospect-conflicting-appointment-error"]){if(this.selectedDate&&this.selectedTime){const e=this.availabilitiesGroupedByDay[Ft(this.selectedDate,"yyyy-MM-dd")];e&&(this.availabilitiesGroupedByDay[Ft(this.selectedDate,"yyyy-MM-dd")]=e.filter(e=>e!==this.selectedTime))}}else{if(409===(null===(x=t.response)||void 0===x?void 0:x.status)&&!this.promptForReschedule&&"User already has a tour scheduled for this building"===n)return this.promptForReschedule=!0,this.isSubmitting=!1,void(this.tourIsBooked=!1);if(409===(null===(A=t.response)||void 0===A?void 0:A.status)&&!this.promptForReschedule)return this.isSubmitting=!1,this.tourIsBooked=!1,qn(),this.availabilitiesGroupedByDay=await Xn(xr[this.tourType],this.buildingId),void alert("This timeslot is no longer available. Please select a different time.")}alert(n),this.isSubmitting=!1,this.tourIsBooked=!1}},this.mobilePages=[{validate:this.validators.tourType,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>B`${this.tourTypeMenu()}`},{validate:this.validators.dateAndTime,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>B`${this.dateAndTimeMenu()}`},{validate:()=>this.validators.leadInfo(),nextButtonText:null,renderNextButton:()=>B` <action-confirm-button
1274
1290
  id="schedule-bttn"
1275
1291
  .onClick=${this.submit}
1276
1292
  .isLoading=${this.isSubmitting}
@@ -1278,7 +1294,16 @@ otherwise there's some empty space at the bottom of the button, which interferes
1278
1294
  width="145px"
1279
1295
  text="Schedule tour"
1280
1296
  ?disabled=${!this.formIsValidForSubmission()}
1281
- ></action-confirm-button>`,nextButtonAction:null,render:()=>B`${this.userInfoAndLayoutMenu()}`}]}connectedCallback(){super.connectedCallback(),this.hasAttribute("role")||this.setAttribute("role","dialog"),this.hasAttribute("aria-modal")||this.setAttribute("aria-modal","true"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Schedule a Tour")}tourTypeMenu(){return B`<h2 id="tour-type-heading" class="journey-header">Tour Type</h2>
1297
+ ></action-confirm-button>`,nextButtonAction:null,render:()=>B`${this.userInfoAndLayoutMenu()}`}]}connectedCallback(){super.connectedCallback(),this.hasAttribute("role")||this.setAttribute("role","dialog"),this.hasAttribute("aria-modal")||this.setAttribute("aria-modal","true"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Schedule a Tour")}buildingSelector(){return this.centralConvoBuildings.length<=1?"":B`<h2 class="journey-header">Building</h2>
1298
+ <me-select
1299
+ id="building"
1300
+ placeholder="Select a property"
1301
+ .value=${this.buildingSlug}
1302
+ .options="${this.centralConvoBuildings.map(e=>({label:e.name,value:e.slug}))}"
1303
+ @change=${this._onBuildingChange}
1304
+ >
1305
+ </me-select>`}tourTypeMenu(){return B`${this.buildingSelector()}
1306
+ <h2 id="tour-type-heading" class="journey-header">Tour Type</h2>
1282
1307
  <div
1283
1308
  id="tour-type-menu"
1284
1309
  role="radiogroup"
@@ -1541,7 +1566,12 @@ xmlns="http://www.w3.org/2000/svg"
1541
1566
  d="M17.835 13.1045C18.4839 11.5628 18.6332 9.85647 18.2621 8.22548C17.8909 6.5945 17.018 5.12084 15.7659 4.0117C14.5139 2.90256 12.9457 2.21372 11.2818 2.04201C9.618 1.87031 7.94218 2.22438 6.49 3.05445L5.498 1.31745C7.01563 0.450066 8.73419 -0.00418222 10.4822 2.90165e-05C12.2302 0.00424025 13.9466 0.466764 15.46 1.34145C19.95 3.93345 21.67 9.48345 19.577 14.1115L20.919 14.8855L16.754 17.0995L16.589 12.3855L17.835 13.1045ZM3.085 6.89845C2.43614 8.44015 2.28678 10.1464 2.65792 11.7774C3.02905 13.4084 3.90201 14.8821 5.15407 15.9912C6.40613 17.1003 7.97432 17.7892 9.63816 17.9609C11.302 18.1326 12.9778 17.7785 14.43 16.9485L15.422 18.6855C13.9044 19.5528 12.1858 20.0071 10.4378 20.0029C8.68979 19.9987 6.97344 19.5361 5.46 18.6615C0.97 16.0695 -0.75 10.5195 1.343 5.89145L0 5.11845L4.165 2.90445L4.33 7.61845L3.084 6.89945L3.085 6.89845Z"
1542
1567
  fill="#1E1E1E"
1543
1568
  />
1544
- </svg>`}render(){var e,t,n,i,r,o;const a=this.waitingForAvailabilities||this.shouldAllowScheduleLoading;if(!this.shouldAllowScheduling&&!a)return B` <div
1569
+ </svg>`}render(){return B`
1570
+ <div class="sr-only" role="status" aria-live="polite">
1571
+ ${this.statusMessage}
1572
+ </div>
1573
+ ${this.renderBody()}
1574
+ `}renderBody(){var e,t,n,i,r,o;const a=this.waitingForAvailabilities||this.shouldAllowScheduleLoading;if(!this.shouldAllowScheduling&&!a)return B` <div
1545
1575
  id="tour-scheduler-inner-form"
1546
1576
  class="${ni()({"tour-scheduler-full":!this.compactDesign&&!bn(),"tour-scheduler-compact":this.compactDesign&&!bn(),"tour-scheduler-mobile":bn()})}"
1547
1577
  >
@@ -1762,7 +1792,7 @@ xmlns="http://www.w3.org/2000/svg"
1762
1792
  </div>
1763
1793
  `}
1764
1794
  </div>
1765
- `}};var Cr;wr.styles=[vi,kn],vr([ue({attribute:!1})],wr.prototype,"tourTypeOptions",void 0),vr([ue({attribute:!1})],wr.prototype,"layoutOptions",void 0),vr([ue({attribute:!0})],wr.prototype,"chatId",void 0),vr([ue({type:Number})],wr.prototype,"buildingId",void 0),vr([ue({attribute:!0})],wr.prototype,"buildingSlug",void 0),vr([ue({attribute:!0})],wr.prototype,"sgtUrl",void 0),vr([ue({attribute:!0})],wr.prototype,"selfGuidedToursTypeOffered",void 0),vr([ue({attribute:!0})],wr.prototype,"selfGuidedTourEnabled",void 0),vr([ue({attribute:!0})],wr.prototype,"escortedToursLink",void 0),vr([ue({attribute:!0})],wr.prototype,"escortedToursTypeOffered",void 0),vr([ue({attribute:!0})],wr.prototype,"virtualToursLink",void 0),vr([ue({attribute:!0})],wr.prototype,"virtualToursTypeOffered",void 0),vr([ue({attribute:!0})],wr.prototype,"orgSlug",void 0),vr([ue({attribute:!0})],wr.prototype,"hasDynamicSchedulingEnabled",void 0),vr([ue({attribute:!0})],wr.prototype,"leadSourceClient",void 0),vr([ue({attribute:!0})],wr.prototype,"leadSourceMultitouchClient",void 0),vr([ue({attribute:!0})],wr.prototype,"buildingName",void 0),vr([ce()],wr.prototype,"tourType",void 0),vr([ce()],wr.prototype,"shouldShowTourType",void 0),vr([ce()],wr.prototype,"email",void 0),vr([ce()],wr.prototype,"phoneNumber",void 0),vr([ce()],wr.prototype,"availabilitiesGroupedByDay",void 0),vr([ce()],wr.prototype,"calendarTimeZone",void 0),vr([ce()],wr.prototype,"waitingForAvailabilities",void 0),vr([ce()],wr.prototype,"selectedDate",void 0),vr([ce()],wr.prototype,"selectedTime",void 0),vr([ce()],wr.prototype,"mobilePageIndex",void 0),vr([ce()],wr.prototype,"isSubmitting",void 0),vr([ce()],wr.prototype,"tourIsBooked",void 0),vr([ce()],wr.prototype,"shouldAllowScheduling",void 0),vr([ce()],wr.prototype,"shouldAllowScheduleLoading",void 0),vr([ce()],wr.prototype,"promptForReschedule",void 0),vr([ce()],wr.prototype,"canceledReschedule",void 0),vr([ue({attribute:!1})],wr.prototype,"leadSources",void 0),vr([ue({attribute:!0})],wr.prototype,"orgLegalName",void 0),vr([ue({attribute:!0})],wr.prototype,"currentLeadSource",void 0),vr([ue({attribute:!0})],wr.prototype,"featureFlagShowDropdown",void 0),vr([ue({attribute:!0})],wr.prototype,"compactDesign",void 0),vr([ue({attribute:!0})],wr.prototype,"primaryColor",void 0),vr([ue({attribute:!0})],wr.prototype,"backgroundColor",void 0),vr([ue({attribute:!0})],wr.prototype,"foregroundColorOnPrimaryBackgroundColor",void 0),vr([ue({attribute:!0})],wr.prototype,"foregroundColorOnSecondaryBackgroundColor",void 0),vr([de(".nameContainer#firstName input")],wr.prototype,"firstNameInput",void 0),vr([de(".nameContainer#lastName input")],wr.prototype,"lastNameInput",void 0),vr([de(".inputContainer#email input")],wr.prototype,"emailInput",void 0),vr([de(".inputContainer#phone input")],wr.prototype,"phoneInput",void 0),vr([de("me-select#leadSource")],wr.prototype,"selectedLeadSource",void 0),vr([de("me-select#layout")],wr.prototype,"selectedLayoutEl",void 0),vr([de("me-select#unit")],wr.prototype,"selectedUnitEl",void 0),vr([ce()],wr.prototype,"firstNameInputValue",void 0),vr([ce()],wr.prototype,"lastNameInputValue",void 0),vr([ce()],wr.prototype,"leadSourceInputValue",void 0),vr([ce()],wr.prototype,"selectedLayoutValue",void 0),vr([ce()],wr.prototype,"selectedUnitValue",void 0),vr([ce()],wr.prototype,"units",void 0),vr([ce()],wr.prototype,"allowOccupiedUnitTours",void 0),vr([ce()],wr.prototype,"errorGettingAvailabilities",void 0),wr=vr([se("tour-scheduler")],wr),function(e){e.Guided="guided",e.Self="self",e.Virtual="virtual"}(Cr||(Cr={}));const xr={[Cr.Guided]:In.WithAgent,[Cr.Self]:In.SelfGuided,[Cr.Virtual]:In.VirtualShowing},Ar={[In.WithAgent]:Cr.Guided,[In.SelfGuided]:Cr.Self,[In.VirtualShowing]:Cr.Virtual},Sr={[Cr.Guided]:"escorted-tour",[Cr.Self]:"self-guided-tour",[Cr.Virtual]:"live-virtual-tour"};function Er(e){const t=Math.round(e/10);return 0===t?"studio":`${t}br`}const kr=(e,t,n=!0,i=!1,r,o=.01)=>Si({params:{org_slug:e,building_slug:t,is_pixel_on_site:n,is_any_webchat_showing:i,extra_data:{webchat_no_show_reason:r}},sampleRate:o}),Tr=async(e,t,n)=>{const i=.01;if(!e)return kr(n,t,!0,!1,"building_does_not_exist",i),!1;if(!e.launchedDateTime)return kr(n,t,!0,!1,"building_not_launched",i),!1;if(!e.active)return kr(n,t,!0,!1,"building_not_active",i),!1;if(!e.webchatScopeConfigured)return kr(n,t,!0,!1,"building_not_webchat_scope_configured",i),!1;const o=await async function(e){if(!e)return!1;try{return(await r().get(ii(e),{params:{building_slug:e,flag_type:"bool",feature_flag:"webchat-leasing-in-maintenance-mode",default_str:null,default_bool:!1}})).data}catch(e){return!1}}(t);return!o||(kr(n,t,!0,!1,"building_in_maintenance_mode",i),!1)},_r=u`
1795
+ `}};var Cr;wr.styles=[vi,kn],vr([ue({attribute:!1})],wr.prototype,"tourTypeOptions",void 0),vr([ue({attribute:!1})],wr.prototype,"layoutOptions",void 0),vr([ue({attribute:!0})],wr.prototype,"chatId",void 0),vr([ue({type:Number})],wr.prototype,"buildingId",void 0),vr([ue({attribute:!0})],wr.prototype,"buildingSlug",void 0),vr([ue({attribute:!0})],wr.prototype,"sgtUrl",void 0),vr([ue({attribute:!0})],wr.prototype,"selfGuidedToursTypeOffered",void 0),vr([ue({attribute:!0})],wr.prototype,"selfGuidedTourEnabled",void 0),vr([ue({attribute:!0})],wr.prototype,"escortedToursLink",void 0),vr([ue({attribute:!0})],wr.prototype,"escortedToursTypeOffered",void 0),vr([ue({attribute:!0})],wr.prototype,"virtualToursLink",void 0),vr([ue({attribute:!0})],wr.prototype,"virtualToursTypeOffered",void 0),vr([ue({attribute:!0})],wr.prototype,"orgSlug",void 0),vr([ue({attribute:!0})],wr.prototype,"hasDynamicSchedulingEnabled",void 0),vr([ue({attribute:!0})],wr.prototype,"leadSourceClient",void 0),vr([ue({attribute:!0})],wr.prototype,"leadSourceMultitouchClient",void 0),vr([ue({attribute:!0})],wr.prototype,"buildingName",void 0),vr([ce()],wr.prototype,"tourType",void 0),vr([ce()],wr.prototype,"shouldShowTourType",void 0),vr([ce()],wr.prototype,"email",void 0),vr([ce()],wr.prototype,"phoneNumber",void 0),vr([ce()],wr.prototype,"availabilitiesGroupedByDay",void 0),vr([ce()],wr.prototype,"calendarTimeZone",void 0),vr([ce()],wr.prototype,"waitingForAvailabilities",void 0),vr([ce()],wr.prototype,"selectedDate",void 0),vr([ce()],wr.prototype,"selectedTime",void 0),vr([ce()],wr.prototype,"mobilePageIndex",void 0),vr([ce()],wr.prototype,"isSubmitting",void 0),vr([ce()],wr.prototype,"tourIsBooked",void 0),vr([ce()],wr.prototype,"shouldAllowScheduling",void 0),vr([ce()],wr.prototype,"shouldAllowScheduleLoading",void 0),vr([ce()],wr.prototype,"promptForReschedule",void 0),vr([ce()],wr.prototype,"canceledReschedule",void 0),vr([ue({attribute:!1})],wr.prototype,"leadSources",void 0),vr([ue({attribute:!0})],wr.prototype,"orgLegalName",void 0),vr([ue({attribute:!0})],wr.prototype,"currentLeadSource",void 0),vr([ue({attribute:!0})],wr.prototype,"featureFlagShowDropdown",void 0),vr([ue({attribute:!0})],wr.prototype,"compactDesign",void 0),vr([ue({attribute:!0})],wr.prototype,"primaryColor",void 0),vr([ue({attribute:!0})],wr.prototype,"backgroundColor",void 0),vr([ue({attribute:!0})],wr.prototype,"foregroundColorOnPrimaryBackgroundColor",void 0),vr([ue({attribute:!0})],wr.prototype,"foregroundColorOnSecondaryBackgroundColor",void 0),vr([de(".nameContainer#firstName input")],wr.prototype,"firstNameInput",void 0),vr([de(".nameContainer#lastName input")],wr.prototype,"lastNameInput",void 0),vr([de(".inputContainer#email input")],wr.prototype,"emailInput",void 0),vr([de(".inputContainer#phone input")],wr.prototype,"phoneInput",void 0),vr([de("me-select#leadSource")],wr.prototype,"selectedLeadSource",void 0),vr([de("me-select#layout")],wr.prototype,"selectedLayoutEl",void 0),vr([de("me-select#unit")],wr.prototype,"selectedUnitEl",void 0),vr([ce()],wr.prototype,"firstNameInputValue",void 0),vr([ce()],wr.prototype,"lastNameInputValue",void 0),vr([ce()],wr.prototype,"leadSourceInputValue",void 0),vr([ce()],wr.prototype,"selectedLayoutValue",void 0),vr([ce()],wr.prototype,"selectedUnitValue",void 0),vr([ce()],wr.prototype,"units",void 0),vr([ce()],wr.prototype,"allowOccupiedUnitTours",void 0),vr([ce()],wr.prototype,"errorGettingAvailabilities",void 0),vr([ce()],wr.prototype,"centralConvoBuildings",void 0),vr([de("me-select#building")],wr.prototype,"selectedBuildingEl",void 0),vr([ce()],wr.prototype,"statusMessage",void 0),wr=vr([se("tour-scheduler")],wr),function(e){e.Guided="guided",e.Self="self",e.Virtual="virtual"}(Cr||(Cr={}));const xr={[Cr.Guided]:In.WithAgent,[Cr.Self]:In.SelfGuided,[Cr.Virtual]:In.VirtualShowing},Ar={[In.WithAgent]:Cr.Guided,[In.SelfGuided]:Cr.Self,[In.VirtualShowing]:Cr.Virtual},Sr={[Cr.Guided]:"escorted-tour",[Cr.Self]:"self-guided-tour",[Cr.Virtual]:"live-virtual-tour"};function Er(e){const t=Math.round(e/10);return 0===t?"studio":`${t}br`}const kr=(e,t,n=!0,i=!1,r,o=.01)=>Si({params:{org_slug:e,building_slug:t,is_pixel_on_site:n,is_any_webchat_showing:i,extra_data:{webchat_no_show_reason:r}},sampleRate:o}),Tr=async(e,t,n)=>{const i=.01;if(!e)return kr(n,t,!0,!1,"building_does_not_exist",i),!1;if(!e.launchedDateTime)return kr(n,t,!0,!1,"building_not_launched",i),!1;if(!e.active)return kr(n,t,!0,!1,"building_not_active",i),!1;if(!e.webchatScopeConfigured)return kr(n,t,!0,!1,"building_not_webchat_scope_configured",i),!1;const o=await async function(e){if(!e)return!1;try{return(await r().get(ii(e),{params:{building_slug:e,flag_type:"bool",feature_flag:"webchat-leasing-in-maintenance-mode",default_str:null,default_bool:!1}})).data}catch(e){return!1}}(t);return!o||(kr(n,t,!0,!1,"building_in_maintenance_mode",i),!1)},_r=u`
1766
1796
  * {
1767
1797
  font-family: "Helvetica Neue", Arial;
1768
1798
  font-size: 14px;
@@ -57,6 +57,10 @@ import { TourVirtuallyIcon } from "../icons/TourVirtuallyIcon";
57
57
  import { TourSelfGuidedIcon } from "../icons/TourSelfGuidedIcon";
58
58
  import { TourWithAgentIcon } from "../icons/TourWithAgentIcon";
59
59
  import { shouldOpenTourLink } from "../../fetchBuildingWebchatView";
60
+ import fetchBuildingWebchatView from "../../fetchBuildingWebchatView";
61
+ import fetchCentralConvoBuildings, {
62
+ CentralConvoBuilding,
63
+ } from "../../fetchCentralConvoBuildings";
60
64
  import formatInTimeZone from "date-fns-tz/formatInTimeZone";
61
65
  import { getTimezoneAbbreviation } from "../../getTimezoneString";
62
66
  import startOfDay from "date-fns/startOfDay";
@@ -220,6 +224,13 @@ export class TourScheduler extends LitElement {
220
224
  @state()
221
225
  errorGettingAvailabilities = false;
222
226
 
227
+ @state()
228
+ private centralConvoBuildings: CentralConvoBuilding[] = [];
229
+ @query("me-select#building")
230
+ selectedBuildingEl?: MESelect;
231
+ @state()
232
+ private statusMessage = "";
233
+
223
234
  _setAvailabilities = async (): Promise<void> => {
224
235
  try {
225
236
  const [allowScheduling, availabilitiesExistForTourType] =
@@ -455,11 +466,22 @@ export class TourScheduler extends LitElement {
455
466
  };
456
467
 
457
468
  firstUpdated = async (): Promise<void> => {
469
+ this._fetchCentralConvoBuildings();
470
+ await this._loadForCurrentBuilding();
471
+ };
472
+
473
+ private _loadForCurrentBuilding = async (): Promise<void> => {
474
+ try {
475
+ await getRawAvailabilities(this.buildingId);
476
+ } catch (e) {
477
+ // noop
478
+ }
458
479
  await Promise.all([
459
480
  this._setAvailabilities().then(async () => {
460
481
  try {
461
482
  const rawAvailabilities = await getRawAvailabilities(this.buildingId);
462
- this.allowOccupiedUnitTours = !!rawAvailabilities.allowOccupiedUnitTours;
483
+ this.allowOccupiedUnitTours =
484
+ !!rawAvailabilities.allowOccupiedUnitTours;
463
485
  } catch (e) {
464
486
  this.allowOccupiedUnitTours = false;
465
487
  }
@@ -468,6 +490,93 @@ export class TourScheduler extends LitElement {
468
490
  ]);
469
491
  };
470
492
 
493
+ private _fetchCentralConvoBuildings = async (): Promise<void> => {
494
+ if (!this.orgSlug || !this.buildingSlug) return;
495
+ try {
496
+ this.centralConvoBuildings = await fetchCentralConvoBuildings(
497
+ this.orgSlug,
498
+ this.buildingSlug
499
+ );
500
+ } catch (e) {
501
+ this.centralConvoBuildings = [];
502
+ }
503
+ };
504
+
505
+ private _onBuildingChange = async (): Promise<void> => {
506
+ const slug = this.selectedBuildingEl?.value;
507
+ if (!slug || slug === this.buildingSlug) return;
508
+ const building = this.centralConvoBuildings.find((b) => b.slug === slug);
509
+ if (!building) return;
510
+
511
+ this.waitingForAvailabilities = true;
512
+ this.errorGettingAvailabilities = false;
513
+ this.tourType = null;
514
+ this.selectedDate = undefined;
515
+ this.selectedTime = undefined;
516
+ this.availabilitiesGroupedByDay = {};
517
+ this.mobilePageIndex = 0;
518
+ this.units = [];
519
+ this.selectedLayoutValue = "";
520
+ this.selectedUnitValue = "";
521
+
522
+ this.buildingId = building.building_id;
523
+ this.buildingSlug = building.slug;
524
+ this.buildingName = building.name;
525
+ this.statusMessage = `Loading tours for ${building.name}…`;
526
+
527
+ pushGtmEvent("tourBuildingSelected", {
528
+ buildingId: building.building_id,
529
+ });
530
+
531
+ try {
532
+ const view = await fetchBuildingWebchatView(this.orgSlug, building.slug);
533
+ this.sgtUrl = view.sgtUrl;
534
+ this.selfGuidedToursTypeOffered = view.selfGuidedToursTypeOffered;
535
+ this.selfGuidedTourEnabled = view.isSelfGuidedTourEnabled;
536
+ this.escortedToursLink = view.escortedToursLink;
537
+ this.escortedToursTypeOffered = view.escortedToursTypeOffered;
538
+ this.virtualToursLink = view.virtualToursLink;
539
+ this.virtualToursTypeOffered = view.virtualToursTypeOffered;
540
+ this.tourTypeOptions = view.tourTypeOptions.map((o) => ({
541
+ label: o.label,
542
+ value: o.value,
543
+ }));
544
+ this.hasDynamicSchedulingEnabled = view.usesDynamicScheduling;
545
+ } catch (e) {
546
+ // eslint-disable-next-line no-console
547
+ console.error("Failed to load building config for selection", e);
548
+ }
549
+
550
+ await this._loadForCurrentBuilding();
551
+
552
+ if (!this.shouldAllowScheduling || this.errorGettingAvailabilities) {
553
+ this.statusMessage = `No tour availabilities for ${building.name}.`;
554
+ } else {
555
+ const count = Object.values(this.shouldShowTourType).filter(
556
+ Boolean
557
+ ).length;
558
+ this.statusMessage = `Showing tours for ${
559
+ building.name
560
+ }. ${count} tour type${count === 1 ? "" : "s"} available.`;
561
+ }
562
+ };
563
+
564
+ buildingSelector(): TemplateResult | string {
565
+ if (this.centralConvoBuildings.length <= 1) return "";
566
+ return html`<h2 class="journey-header">Building</h2>
567
+ <me-select
568
+ id="building"
569
+ placeholder="Select a property"
570
+ .value=${this.buildingSlug}
571
+ .options="${this.centralConvoBuildings.map((b) => ({
572
+ label: b.name,
573
+ value: b.slug,
574
+ }))}"
575
+ @change=${this._onBuildingChange}
576
+ >
577
+ </me-select>`;
578
+ }
579
+
471
580
  protected willUpdate = async (
472
581
  _changedProperties:
473
582
  | PropertyValueMap<{ tourType: TourType }>
@@ -831,7 +940,8 @@ export class TourScheduler extends LitElement {
831
940
  static styles = [tourSchedulerStyles, InputStyles];
832
941
 
833
942
  tourTypeMenu(): TemplateResult {
834
- return html`<h2 id="tour-type-heading" class="journey-header">Tour Type</h2>
943
+ return html`${this.buildingSelector()}
944
+ <h2 id="tour-type-heading" class="journey-header">Tour Type</h2>
835
945
  <div
836
946
  id="tour-type-menu"
837
947
  role="radiogroup"
@@ -1460,6 +1570,15 @@ export class TourScheduler extends LitElement {
1460
1570
  }
1461
1571
 
1462
1572
  render(): TemplateResult {
1573
+ return html`
1574
+ <div class="sr-only" role="status" aria-live="polite">
1575
+ ${this.statusMessage}
1576
+ </div>
1577
+ ${this.renderBody()}
1578
+ `;
1579
+ }
1580
+
1581
+ private renderBody(): TemplateResult {
1463
1582
  const isLoading =
1464
1583
  this.waitingForAvailabilities || this.shouldAllowScheduleLoading;
1465
1584
  if (!this.shouldAllowScheduling && !isLoading) {
@@ -111,6 +111,17 @@ export const tourSchedulerStyles = css`
111
111
  font-size: 14px;
112
112
  font-weight: 600;
113
113
  }
114
+ .sr-only {
115
+ position: absolute;
116
+ width: 1px;
117
+ height: 1px;
118
+ padding: 0;
119
+ margin: -1px;
120
+ overflow: hidden;
121
+ clip: rect(0, 0, 0, 0);
122
+ white-space: nowrap;
123
+ border: 0;
124
+ }
114
125
  #close-button {
115
126
  background: none;
116
127
  border: none;
@@ -138,6 +149,11 @@ export const tourSchedulerStyles = css`
138
149
  padding-bottom: 12px;
139
150
  }
140
151
 
152
+ me-select#building {
153
+ display: block;
154
+ margin-bottom: 20px;
155
+ }
156
+
141
157
  #tour-type-menu-outer-container {
142
158
  width: 220px;
143
159
  }
@@ -0,0 +1,32 @@
1
+ import axios from "axios";
2
+
3
+ export interface CentralConvoBuilding {
4
+ building_id: number;
5
+ name: string;
6
+ slug: string;
7
+ }
8
+
9
+ /**
10
+ * Fetch the buildings that belong to the same central conversation group as the
11
+ * current building. Returns an empty array when the building is not part of a
12
+ * central conversation group (in which case no building selector is shown).
13
+ *
14
+ * @param orgSlug - The org slug, e.g. "big-prop-co"
15
+ * @param buildingSlug - The current building's slug, e.g. "gravity-falls"
16
+ */
17
+ export default async function fetchCentralConvoBuildings(
18
+ orgSlug: string,
19
+ buildingSlug: string
20
+ ): Promise<CentralConvoBuilding[]> {
21
+ const host = "https://app.meetelise.com";
22
+ const url = `${host}/platformApi/webchat/central-convo-buildings`;
23
+
24
+ const response = await axios.get<CentralConvoBuilding[]>(url, {
25
+ headers: {
26
+ ["building-slug"]: buildingSlug,
27
+ ["org-slug"]: orgSlug,
28
+ },
29
+ });
30
+
31
+ return response.data ?? [];
32
+ }