@meetelise/chat 1.77.0 → 1.77.2
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.
- package/dist/src/WebComponent/SchedulerV2/tour-scheduler-v2.d.ts +1 -1
- package/dist/src/WebComponent/SchedulerV2/tourItineraryApi.d.ts +2 -0
- package/dist/src/utils.d.ts +4 -0
- package/package.json +1 -1
- package/public/dist/index.js +24 -15
- package/src/WebComponent/SchedulerV2/community-picker.ts +7 -3
- package/src/WebComponent/SchedulerV2/tour-scheduler-v2.ts +27 -10
- package/src/WebComponent/SchedulerV2/tourItineraryApi.ts +2 -0
- package/src/emailValidation.test.ts +51 -0
- package/src/tourSchedulerV2Booking.test.ts +37 -0
- package/src/utils.ts +5 -1
|
@@ -210,7 +210,7 @@ export declare class TourSchedulerV2 extends LitElement {
|
|
|
210
210
|
private renderAddStop;
|
|
211
211
|
private renderEditor;
|
|
212
212
|
private renderContactForm;
|
|
213
|
-
/** The consent text and the submit button, under the form or the itinerary. */
|
|
213
|
+
/** The consent text, any booking error and the submit button, under the form or the itinerary. */
|
|
214
214
|
private renderFooter;
|
|
215
215
|
private renderSchedule;
|
|
216
216
|
/** Today's reschedule prompt, with the server's reason. */
|
|
@@ -138,6 +138,8 @@ export interface BookingContact {
|
|
|
138
138
|
phone_e164: string;
|
|
139
139
|
bedrooms: number[];
|
|
140
140
|
move_in: string | null;
|
|
141
|
+
/** The budget filter the prospect set, saved as their max budget. */
|
|
142
|
+
max_budget: number | null;
|
|
141
143
|
notes: string;
|
|
142
144
|
}
|
|
143
145
|
/** The attribution /v2/scheduleMe takes today, under the same names. */
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -5,6 +5,10 @@ export declare const onMobileChange: (callback: (isMobile: boolean) => void) =>
|
|
|
5
5
|
export declare const isTimestampExpired: (timestamp: Date, ttlHours: number) => boolean;
|
|
6
6
|
export declare const getCookieValue: (name: string) => string | null;
|
|
7
7
|
export declare const isValidPhoneNumber: (phoneNumber: string) => boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Something@domain.tld, where the top-level domain is two or more letters
|
|
10
|
+
* (any script) or an IDN's punycode form, so a typo such as "x@y.c" is caught.
|
|
11
|
+
*/
|
|
8
12
|
export declare const isValidEmail: (email: string) => boolean;
|
|
9
13
|
export declare const isContainingEmail: (message: string) => boolean;
|
|
10
14
|
export declare const sentenceTitleCase: (str: string) => string;
|
package/package.json
CHANGED
package/public/dist/index.js
CHANGED
|
@@ -926,7 +926,7 @@ var e={2:(e,t,i)=>{var n=i(2199),r=i(4664),o=i(5950);e.exports=function(e){retur
|
|
|
926
926
|
:host([outlined]) #noAvailabilityText p {
|
|
927
927
|
margin: 0;
|
|
928
928
|
}
|
|
929
|
-
`,gr([pe({attribute:!1})],br.prototype,"options",void 0),gr([pe({type:Boolean})],br.prototype,"selectedDateExists",void 0),gr([pe({attribute:!0})],br.prototype,"timezone",void 0),gr([pe({attribute:!0})],br.prototype,"defaultSelectedTime",void 0),gr([pe({type:Boolean,reflect:!0})],br.prototype,"outlined",void 0),gr([fe()],br.prototype,"selected",void 0),gr([pe({attribute:!1})],br.prototype,"selectedTime",null),br=gr([ce("time-picker")],br);var yr=i(4058),vr=i.n(yr),wr=i(4124),xr=i.n(wr),Cr=i(6449),$r=i.n(Cr),Sr=i(3805),kr=i.n(Sr),Ar=i(9752),Tr=i.n(Ar);function Er(e,t){sn(2,arguments);var i=ln(e),n=ln(t);return i.getTime()<n.getTime()}const _r=(e,t)=>Tr()(e,(e,i,n,r)=>{e[(null==t?void 0:t.includes(n))||$r()(r)?n:vr()(String(n))]=kr()(i)?_r(i,t):i}),Or=(e,t)=>Tr()(e,(e,i,n,r)=>{e[(null==t?void 0:t.includes(n))||$r()(r)?n:xr()(String(n))]=kr()(i)?Or(i,t):i}),Pr="(max-width: 767px)",Ir="(max-height: 400px)",Nr=()=>window.matchMedia(Pr).matches||window.matchMedia(Ir).matches,Mr=e=>{const t=window.matchMedia(Pr),i=window.matchMedia(Ir),n=()=>e(t.matches||i.matches);return t.addEventListener("change",n),i.addEventListener("change",n),()=>{t.removeEventListener("change",n),i.removeEventListener("change",n)}},Dr=(e,t)=>Er(function(e,t){return sn(2,arguments),Sn(e,36e5*$n(t))}(e,t),Date.now()),Lr=e=>{try{const t=document.cookie.split("; ").map(e=>e.split("=")).find(([t])=>t===e);return t?decodeURIComponent(t[1]):null}catch(e){return null}},Rr=e=>/^[^\s@]+@[^\s@]+\.[
|
|
929
|
+
`,gr([pe({attribute:!1})],br.prototype,"options",void 0),gr([pe({type:Boolean})],br.prototype,"selectedDateExists",void 0),gr([pe({attribute:!0})],br.prototype,"timezone",void 0),gr([pe({attribute:!0})],br.prototype,"defaultSelectedTime",void 0),gr([pe({type:Boolean,reflect:!0})],br.prototype,"outlined",void 0),gr([fe()],br.prototype,"selected",void 0),gr([pe({attribute:!1})],br.prototype,"selectedTime",null),br=gr([ce("time-picker")],br);var yr=i(4058),vr=i.n(yr),wr=i(4124),xr=i.n(wr),Cr=i(6449),$r=i.n(Cr),Sr=i(3805),kr=i.n(Sr),Ar=i(9752),Tr=i.n(Ar);function Er(e,t){sn(2,arguments);var i=ln(e),n=ln(t);return i.getTime()<n.getTime()}const _r=(e,t)=>Tr()(e,(e,i,n,r)=>{e[(null==t?void 0:t.includes(n))||$r()(r)?n:vr()(String(n))]=kr()(i)?_r(i,t):i}),Or=(e,t)=>Tr()(e,(e,i,n,r)=>{e[(null==t?void 0:t.includes(n))||$r()(r)?n:xr()(String(n))]=kr()(i)?Or(i,t):i}),Pr="(max-width: 767px)",Ir="(max-height: 400px)",Nr=()=>window.matchMedia(Pr).matches||window.matchMedia(Ir).matches,Mr=e=>{const t=window.matchMedia(Pr),i=window.matchMedia(Ir),n=()=>e(t.matches||i.matches);return t.addEventListener("change",n),i.addEventListener("change",n),()=>{t.removeEventListener("change",n),i.removeEventListener("change",n)}},Dr=(e,t)=>Er(function(e,t){return sn(2,arguments),Sn(e,36e5*$n(t))}(e,t),Date.now()),Lr=e=>{try{const t=document.cookie.split("; ").map(e=>e.split("=")).find(([t])=>t===e);return t?decodeURIComponent(t[1]):null}catch(e){return null}},Rr=e=>/^[^\s@]+@[^\s@]+\.(?:\p{L}{2,}|xn--[a-z\d-]+)$/iu.test(e),Br=e=>{if(!e)return"";return(e.includes(" ")?e:e.replace(/([A-Z])/g," $1").trim()).split(" ").map(e=>e.length>1&&e===e.toUpperCase()?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" ")},Ur=(e,t=0)=>Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:t,maximumFractionDigits:t}).format(null!=e?e:0);var jr=function(e,t,i,n){var r,o=arguments.length,a=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,n);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,i,a):r(t,i))||a);return o>3&&a&&Object.defineProperty(t,i,a),a};let Fr=class extends de{constructor(){super(),this.options=[],this.placeholder="Select",this.outlined=!1,this.activeOption=null,this.isOpen=!1,this.activeOptionIndex=null,this.searchTerm="",this.focus=()=>{this.selectInput.focus()},this.closeSelect=()=>{this.isOpen=!1,this.searchTerm="",this.activeOption=null,this.activeOptionIndex=null},this.openSelect=()=>{this.isOpen=!0},this.toggleSelect=()=>{this.isOpen?this.closeSelect():(this.openSelect(),this.selectInput.focus())},this.setSelectedOption=(e,t=!0)=>{this.value!==e.value?this.value=e.value:this.value=void 0,t&&this.closeSelect(),this.value?this.meSelect.style.color="rgba(32, 32, 32, 1)":this.meSelect.style.color="rgba(32, 32, 32, 0.5)",this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))},this.handleKeydown=(e,t)=>i=>{("string"==typeof e&&i.key===e||"object"==typeof e&&e.includes(i.key))&&t()},this.handleSearchInput=e=>{this.searchTerm=e.target.value,this.activeOption=null,this.activeOptionIndex=null},this.firstUpdated=()=>{this.value&&this.meSelect&&(this.meSelect.style.color="rgba(32, 32, 32, 1)")},this.listboxId=`me-select-listbox-${Math.random().toString(36).slice(2,9)}`,this.optionId=e=>`${this.listboxId}-opt-${e}`,document.addEventListener("click",e=>{e.composedPath().includes(this)||this.closeSelect()})}get visibleOptions(){const e=this.searchTerm.trim().toLowerCase();return e?this.options.filter(t=>t.label.toLowerCase().includes(e)):this.options}adjustScrollToActiveOption(){if(null!=this.activeOptionIndex){const e=this.renderRoot.querySelectorAll(".option")[this.activeOptionIndex];e&&e.scrollIntoView({block:"nearest"})}}render(){var e,t;const i=this.activeOptionIndex,n=null!==(e=this.placeholder)&&void 0!==e?e:"Select",r=this.visibleOptions,o=null===(t=this.options.find(e=>e.value===this.value))||void 0===t?void 0:t.label,a=this.isOpen?this.searchTerm:o||this.value||"";return H`
|
|
930
930
|
<div id="outer-select-container">
|
|
931
931
|
<div
|
|
932
932
|
id="select"
|
|
@@ -5837,7 +5837,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
5837
5837
|
>
|
|
5838
5838
|
Clear all
|
|
5839
5839
|
</button>`:""}
|
|
5840
|
-
</div>`}renderCard(e){var t;const i=this.isSelected(e.building_id),n=e.next_available,r=!!n&&"extend"===this.variant,o=e.price_from?`${0===e.price_from.bedrooms?"Studio":`${e.price_from.bedrooms} BR`} from ${Ur(e.price_from.amount)}`:"";return H`<li>
|
|
5840
|
+
</div>`}renderCard(e){var t;const i=this.isSelected(e.building_id),n=e.next_available,r=!!n&&"extend"===this.variant,o="extend"===this.variant?e.distance_mi:null,a=e.price_from?`${0===e.price_from.bedrooms?"Studio":`${e.price_from.bedrooms} BR`} from ${Ur(e.price_from.amount)}`:"";return H`<li>
|
|
5841
5841
|
<button
|
|
5842
5842
|
class=${xe({"floorplan-image-card":!0,card:!0,selected:i,disabled:!e.tourable})}
|
|
5843
5843
|
aria-pressed=${String(i)}
|
|
@@ -5848,15 +5848,15 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
5848
5848
|
><img src=${e.image_url} alt=""
|
|
5849
5849
|
/></span>`:""}
|
|
5850
5850
|
<span class="card-body">
|
|
5851
|
-
${e.best_match||
|
|
5851
|
+
${e.best_match||a||null!==o?H`<span class="card-tags">
|
|
5852
5852
|
${e.best_match?H`<span class="tag"
|
|
5853
5853
|
>${((e=12)=>Jd(e,"M8.243 7.34l-6.38 .925l-.113 .023a1 1 0 0 0 -.44 1.684l4.622 4.499l-1.09 6.355l-.013 .11a1 1 0 0 0 1.464 .944l5.706 -3l5.693 3l.1 .046a1 1 0 0 0 1.352 -1.1l-1.091 -6.355l4.624 -4.5l.078 -.085a1 1 0 0 0 -.633 -1.62l-6.38 -.926l-2.852 -5.78a1 1 0 0 0 -1.794 0l-2.853 5.78z"))(12)} Best Match</span
|
|
5854
5854
|
>`:""}
|
|
5855
|
-
${
|
|
5856
|
-
>${((e=14)=>Jd(e,"M12.01 2.011a3.2 3.2 0 0 1 2.113 .797l.154 .145l.698 .698a1.2 1.2 0 0 0 .71 .341l.135 .008h1a3.2 3.2 0 0 1 3.195 3.018l.005 .182v1c0 .27 .092 .533 .258 .743l.09 .1l.697 .698a3.2 3.2 0 0 1 .147 4.382l-.145 .154l-.698 .698a1.2 1.2 0 0 0 -.341 .71l-.008 .135v1a3.2 3.2 0 0 1 -3.018 3.195l-.182 .005h-1a1.2 1.2 0 0 0 -.743 .258l-.1 .09l-.698 .697a3.2 3.2 0 0 1 -4.382 .147l-.154 -.145l-.698 -.698a1.2 1.2 0 0 0 -.71 -.341l-.135 -.008h-1a3.2 3.2 0 0 1 -3.195 -3.018l-.005 -.182v-1a1.2 1.2 0 0 0 -.258 -.743l-.09 -.1l-.697 -.698a3.2 3.2 0 0 1 -.147 -4.382l.145 -.154l.698 -.698a1.2 1.2 0 0 0 .341 -.71l.008 -.135v-1l.005 -.182a3.2 3.2 0 0 1 3.013 -3.013l.182 -.005h1a1.2 1.2 0 0 0 .743 -.258l.1 -.09l.698 -.697a3.2 3.2 0 0 1 2.269 -.944zm3.697 7.282a1 1 0 0 0 -1.414 0l-3.293 3.292l-1.293 -1.292l-.094 -.083a1 1 0 0 0 -1.32 1.497l2 2l.094 .083a1 1 0 0 0 1.32 -.083l4 -4l.083 -.094a1 1 0 0 0 -.083 -1.32z"))(14)} ${
|
|
5855
|
+
${a?H`<span class="tag"
|
|
5856
|
+
>${((e=14)=>Jd(e,"M12.01 2.011a3.2 3.2 0 0 1 2.113 .797l.154 .145l.698 .698a1.2 1.2 0 0 0 .71 .341l.135 .008h1a3.2 3.2 0 0 1 3.195 3.018l.005 .182v1c0 .27 .092 .533 .258 .743l.09 .1l.697 .698a3.2 3.2 0 0 1 .147 4.382l-.145 .154l-.698 .698a1.2 1.2 0 0 0 -.341 .71l-.008 .135v1a3.2 3.2 0 0 1 -3.018 3.195l-.182 .005h-1a1.2 1.2 0 0 0 -.743 .258l-.1 .09l-.698 .697a3.2 3.2 0 0 1 -4.382 .147l-.154 -.145l-.698 -.698a1.2 1.2 0 0 0 -.71 -.341l-.135 -.008h-1a3.2 3.2 0 0 1 -3.195 -3.018l-.005 -.182v-1a1.2 1.2 0 0 0 -.258 -.743l-.09 -.1l-.697 -.698a3.2 3.2 0 0 1 -.147 -4.382l.145 -.154l.698 -.698a1.2 1.2 0 0 0 .341 -.71l.008 -.135v-1l.005 -.182a3.2 3.2 0 0 1 3.013 -3.013l.182 -.005h1a1.2 1.2 0 0 0 .743 -.258l.1 -.09l.698 -.697a3.2 3.2 0 0 1 2.269 -.944zm3.697 7.282a1 1 0 0 0 -1.414 0l-3.293 3.292l-1.293 -1.292l-.094 -.083a1 1 0 0 0 -1.32 1.497l2 2l.094 .083a1 1 0 0 0 1.32 -.083l4 -4l.083 -.094a1 1 0 0 0 -.083 -1.32z"))(14)} ${a}</span
|
|
5857
5857
|
>`:""}
|
|
5858
|
-
${null!==
|
|
5859
|
-
>${
|
|
5858
|
+
${null!==o?H`<span class="distance"
|
|
5859
|
+
>${o.toFixed(1)} mi</span
|
|
5860
5860
|
>`:""}
|
|
5861
5861
|
</span>`:""}
|
|
5862
5862
|
<span class="card-name">
|
|
@@ -6922,7 +6922,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
6922
6922
|
transform: rotate(360deg);
|
|
6923
6923
|
}
|
|
6924
6924
|
}
|
|
6925
|
-
`,Fu([pe({type:Number})],Hu.prototype,"size",void 0),Fu([pe({type:Number})],Hu.prototype,"spinSpeed",void 0),Hu=Fu([ce("mega-loader")],Hu);const zu=e=>{const t=Object.fromEntries(e.buildingIds.slice(1).filter(t=>e.laterStarts[t]).map(t=>[String(t),e.laterStarts[t]])),i=Object.fromEntries(e.buildingIds.filter(t=>e.stopDates[t]&&e.stopDates[t]!==e.date).map(t=>[String(t),e.stopDates[t]])),n=e.existingEventIds[e.existingEventIds.length-1];return{building_ids:e.buildingIds,tour_type:e.tourType,date:e.date,start_time:e.firstStart,stop_starts:t,stop_dates:i,fixed_first:void 0===n?null:{calendar_event_id:n}}},Gu=({orgSlug:e,selectedLeadSource:t,currentLeadSource:i,touchpoints:n,search:r,referrer:o,googleReferral:a})=>{var s,l,d;const u=t||i||null,c=ca(e);return{lead_sources:[...new Set(u?[u,c]:[c])],lead_sources_with_timestamps:n.map(e=>Or({...e})),query_params:Object.fromEntries(new URLSearchParams(r).entries()),referrer:o,google_rwg_token:null!==(s=null==a?void 0:a.rwgToken)&&void 0!==s?s:null,google_referral_building_id:null!==(l=null==a?void 0:a.buildingId)&&void 0!==l?l:null,google_environment:null!==(d=null==a?void 0:a.environment)&&void 0!==d?d:null}},Wu=e=>0===e?0:Math.floor(e/10),qu=["Studio","One bedroom","Two bedroom","Three bedroom","Four bedroom","Five bedroom"],Vu=e=>{var t;return{value:10*e,label:null!==(t=qu[e])&&void 0!==t?t:`${e} bedroom`}};var Qu,Yu=function(e,t,i,n){var r,o=arguments.length,a=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,n);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,i,a):r(t,i))||a);return o>3&&a&&Object.defineProperty(t,i,a),a};const Ku={bedrooms:[],moveIn:null,maxBudget:null},Xu=e=>[...new Set(e.map(Wu))],Zu={"escorted-tour":"WITH_AGENT","self-guided-tour":"SELF_GUIDED","live-virtual-tour":"VIRTUAL_SHOWING"};let Ju=Qu=class extends de{constructor(){super(...arguments),this.orgSlug="",this.buildingSlug="",this.buildingId=0,this.orgId=0,this.buildingName="",this.sgtUrl="",this.selfGuidedToursTypeOffered="",this.escortedToursLink="",this.escortedToursTypeOffered="",this.virtualToursLink="",this.virtualToursTypeOffered="",this.tourTypeOptions=[],this.layoutOptions=[],this.currentLeadSource="",this.leadSources=[],this.featureFlagShowDropdown="",this.bedroomPreferenceRequired=!1,this.orgLegalName="",this.country=null,this.buildingState=null,this.primaryColor=Xi,this.foregroundColorOnPrimaryBackgroundColor="white",this.compactDesign=!1,this.leadSourceClient=null,this.leadSourceMultitouchClient=null,this.getSessionToken=()=>null,this.api=null,this.step="loading",this.loadError=null,this.mobile=Nr(),this.group=null,this.communities=new Map,this.selectedIds=[],this.picks=[],this.addingStop=!1,this.existingEventIds=[],this.tourType="escorted-tour",this.linkTourType=null,this.date=null,this.firstStart=null,this.laterStarts={},this.stopDates={},this.plan=null,this.planLoading=!1,this.planError=null,this.notice=null,this.contact=Ru,this.preferences=Ku,this.submitting=!1,this.bookingError=null,this.reschedulePrompt=null,this.confirmed=[],this.bookedTourType=null,this.bookedEventIds=[],this.extendInitial=null,this.extendFrom=null,this.extending=!1,this.rescheduled=!1,this.rescheduleCanceled=!1,this.planRequestId=0,this.idempotency=null,this.narrow=!1,this.modalResize=new ResizeObserver(([e])=>{this.narrow=e.contentRect.width<Qu.THREE_COLUMN_MIN_WIDTH}),this.observeModal=e=>{this.modalResize.disconnect(),e&&this.modalResize.observe(e)},this.onKeydown=e=>{hd(e,this),"Escape"!==e.key||e.defaultPrevented||e.isComposing||(e.stopPropagation(),this.close())},this.loadSelectCommunities=e=>this.client.getCommunities(e).then(this.rememberPage),this.loadExtendCommunities=e=>{const t=this.extendFrom;return t?this.client.getCommunities({...e,extend:t}).then(this.rememberPage):Promise.reject(new Error("No booking to extend"))},this.rememberPage=e=>(this.remember(e.communities),e),this.loadAddStopCommunities=e=>{const t=this.extendQueryFromPlan();return t?this.client.getCommunities({...e,extend:t}).then(this.rememberPage):Promise.reject(new Error("No stop to add after"))},this.onFiltersChange=e=>{this.preferences=e.detail.filters}}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"),this.cleanupMobileListener=Mr(e=>this.mobile=e),this.addEventListener("keydown",this.onKeydown)}disconnectedCallback(){var e;null===(e=this.cleanupMobileListener)||void 0===e||e.call(this),this.removeEventListener("keydown",this.onKeydown),super.disconnectedCallback()}close(){var e;null===(e=this.onCloseClicked)||void 0===e||e.call(this,new MouseEvent("click"))}get client(){return this.api||(this.api=lu({orgSlug:this.orgSlug,buildingSlug:this.buildingSlug,getSessionToken:()=>this.getSessionToken()})),this.api}willUpdate(e){if(e.has("primaryColor")||e.has("foregroundColorOnPrimaryBackgroundColor")){const e=this.primaryColor||Xi;this.style.setProperty("--primary-color",e),this.style.setProperty("--action-confirm-button-background",e),this.style.setProperty("--action-confirm-button-color",this.foregroundColorOnPrimaryBackgroundColor),this.style.setProperty("--on-primary-color",this.foregroundColorOnPrimaryBackgroundColor)}}firstUpdated(){this.start()}updated(e){var t;e.has("step")&&void 0===e.get("step")?ud(this):((e.has("step")||e.has("reschedulePrompt")||e.has("rescheduleCanceled"))&&(this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1"),this.focus({preventScroll:!0})),e.has("notice")&&this.notice&&(null===(t=this.renderRoot.querySelector(".notice"))||void 0===t||t.scrollIntoView({block:"nearest"})))}async start(){this.step="loading",this.loadError=null;try{const e=await this.client.getCommunities(Ku);if(this.group=e,this.remember(e.communities),e.anchor.is_general_building)return void this.goTo("pick");this.rememberOne({building_id:e.anchor.building_id,name:e.anchor.name,address:null,timezone:null}),this.startSchedule([e.anchor.building_id])}catch(e){if(e instanceof su&&"NOT_IN_GROUP"===e.code)return this.group=null,this.rememberOne({building_id:this.buildingId,name:this.buildingName,address:null,timezone:null}),void this.startSchedule([this.buildingId]);this.loadError=e.message,this.step="error",this.log("TOUR_SCHEDULER_V2_LOAD_ERROR",e)}}goTo(e){this.step=e,"pick"===e?this.picks=this.selectedIds.map(e=>this.communities.get(e)).filter(e=>!!e):"booked"===e&&(this.picks=[]),Ro("tourSchedulerStepViewed",{step:"schedule"===e&&this.extending?"extend-schedule":e,buildingId:this.buildingId})}remember(e){const t=new Map(this.communities);e.forEach(e=>t.set(e.building_id,ou(e))),this.communities=t}rememberOne(e){const t=this.communities.get(e.building_id);(null==t?void 0:t.address)||(this.communities=new Map(this.communities).set(e.building_id,e))}startSchedule(e){this.selectedIds=e,this.plan=null,this.firstStart=null,this.laterStarts={},this.stopDates={},this.linkTourType=null,this.notice=null,this.bookingError=null,this.reschedulePrompt=null,this.goTo("schedule"),this.runPlan()}choice(){var e;return{buildingIds:this.selectedIds,tourType:this.tourType,date:null!==(e=this.date)&&void 0!==e?e:Cu(new Date),firstStart:this.firstStart,laterStarts:this.laterStarts,stopDates:this.stopDates,existingEventIds:this.existingEventIds}}async runPlan(e=!1){if(this.addingStop=!1,0===this.selectedIds.length)return;const t=++this.planRequestId;this.planLoading=!0,this.planError=null,e||(this.notice=null);try{let e=this.choice(),i=await this.client.plan(zu(e));for(let n=0;n<2&&t===this.planRequestId;n++){if(i.tour_types.includes(e.tourType)){if(!(0===Object.keys(e.stopDates).length&&i.bookable_dates.length>0)||i.bookable_dates.includes(e.date))break;this.date=i.bookable_dates[0]}else{if(0===i.tour_types.length)break;this.tourType=i.tour_types[0],this.stopDates={}}this.firstStart=null,this.laterStarts={},e=this.choice(),i=await this.client.plan(zu(e))}if(t!==this.planRequestId)return;this.plan=i,i.bookable_dates.includes(e.date)&&(this.date=e.date),i.changed.length>0&&(this.notice=i.changed.map(e=>e.text).join(" "))}catch(e){if(t!==this.planRequestId)return;this.planError=e.message,this.log("TOUR_SCHEDULER_V2_PLAN_ERROR",e)}finally{t===this.planRequestId&&(this.planLoading=!1)}}tourLink(e){if(!this.tourTypeOptions.map(e=>e.value).includes(Zu[e]))return null;const[t,i]={"self-guided-tour":[this.sgtUrl,this.selfGuidedToursTypeOffered],"escorted-tour":[this.escortedToursLink,this.escortedToursTypeOffered],"live-virtual-tour":[this.virtualToursLink,this.virtualToursTypeOffered]}[e];return t&&wa(0,i)?t:null}get bookingOwnBuildingAlone(){return 0===this.existingEventIds.length&&1===this.selectedIds.length&&this.selectedIds[0]===this.buildingId}openTourLink(e){const t=this.tourLink(e);if(!t)return;const i="self-guided-tour"===e&&52===this.orgId?Io(t,Po()):t;window.open(i,"_blank")}tourTypeChoices(){var e,t;const i=null!==(t=null===(e=this.plan)||void 0===e?void 0:e.tour_types)&&void 0!==t?t:[];return Su.filter(e=>i.includes(e)||this.bookingOwnBuildingAlone&&!!this.tourLink(e)).map(e=>({id:e,opensLink:this.bookingOwnBuildingAlone&&!!this.tourLink(e)}))}get shownTourType(){var e;return this.linkTourType?this.linkTourType:(null===(e=this.plan)||void 0===e?void 0:e.tour_types.includes(this.tourType))?this.tourType:null}get activeLinkType(){const e=this.shownTourType;return e&&this.bookingOwnBuildingAlone&&this.tourLink(e)?e:null}onTourType(e){if(Ro("tourTypeSelected",{tourType:e,buildingId:this.buildingId}),this.bookingOwnBuildingAlone&&this.tourLink(e))return this.linkTourType=e,void this.openTourLink(e);this.linkTourType=null,e!==this.tourType&&(this.tourType=e,this.firstStart=null,this.laterStarts={},this.stopDates={},this.runPlan())}onDate(e){e!==this.date&&(Ro("tourDateSelected",{tourType:this.tourType,buildingId:this.buildingId}),this.date=e,this.firstStart=null,this.laterStarts={},this.stopDates={},this.runPlan())}stopDatesWithout(e){return Object.fromEntries(Object.entries(this.stopDates).filter(([t])=>Number(t)!==e))}onStopDate(e,t){const i=this.selectedIds.indexOf(e);if(i<0)return;Ro("tourStopDateSelected",{tourType:this.tourType,buildingId:this.buildingId,stopNumber:i+1});const n=this.stopDatesWithout(e);this.stopDates=t===this.date?n:{...n,[e]:t},0===i&&(this.firstStart=null),this.laterStarts=Object.fromEntries(this.selectedIds.slice(1,i).filter(e=>this.laterStarts[e]).map(e=>[e,this.laterStarts[e]])),this.runPlan()}onStopTime(e,t){const i=this.selectedIds.indexOf(e);if(i<0)return;Ro("tourTimeSelected",{tourType:this.tourType,buildingId:this.buildingId,stopNumber:i+1});const n=this.selectedIds.slice(1,i);0===i?(this.firstStart=uu(t),this.laterStarts={}):this.laterStarts={...Object.fromEntries(n.filter(e=>this.laterStarts[e]).map(e=>[e,this.laterStarts[e]])),[e]:t},this.runPlan()}onReorder(e){Ro("tourStopsReordered",{buildingId:this.buildingId,stopCount:e.length});const t=this.selectedIds.filter(t=>!e.includes(t));this.selectedIds=[...e,...t],this.firstStart=null,this.laterStarts={},this.runPlan()}onRemove(e){const t=this.selectedIds.filter(t=>t!==e);if(Ro("tourStopRemoved",{buildingId:this.buildingId,stopCount:t.length}),0===t.length)return this.selectedIds=[],this.plan=null,void this.goTo(this.extending?"booked":"pick");this.selectedIds[0]===e&&(this.firstStart=null),this.selectedIds=t,this.laterStarts={},this.stopDates=this.stopDatesWithout(e),this.runPlan()}onEditCommunities(){this.goTo("pick")}onCommunitiesSelected(e,t){var i;if(e.forEach(e=>this.rememberOne(e)),Ro("tourCommunitiesSelected",{buildingId:this.buildingId,count:e.length,mode:t}),this.extending="extend"===t,this.extending){this.existingEventIds=this.bookedEventIds,this.tourType=null!==(i=this.bookedTourType)&&void 0!==i?i:this.tourType;const e=this.confirmed.filter(e=>e.start).slice(-1)[0];this.date=(null==e?void 0:e.start)?du(e.start):this.date}else this.existingEventIds=[];this.startSchedule(e.map(e=>e.building_id))}async submit(e=!1){var t,i,n,r,o,a;const s=this.plan;if(!s||this.submitting)return;const l=this.choice(),d=this.formValues,u=this.showLeadSourceDropdown()?d.leadSource:null,c=(({choice:e,plan:t,contact:i,attribution:n,conversationTrackingId:r,cancelExistingTours:o})=>({tour_type:e.tourType,stops:[...e.existingEventIds.map(e=>({existing_calendar_event_id:e})),...t.stops.filter(e=>!e.fixed).map(e=>({building_id:e.building_id,start:e.start}))],...i?{contact:i}:{},lead_sources:n,conversation_tracking_id:r,cancel_existing_tours:o}))({choice:l,plan:s,contact:this.extending?null:{first_name:d.firstName.trim(),last_name:d.lastName.trim(),email:d.email.trim(),phone_e164:null!==(t=d.phoneE164)&&void 0!==t?t:"",bedrooms:Xu(d.layouts),move_in:d.moveIn||null,notes:d.notes.trim()},attribution:Gu({orgSlug:this.orgSlug,selectedLeadSource:u,currentLeadSource:this.currentLeadSource,touchpoints:null!==(n=null===(i=this.leadSourceMultitouchClient)||void 0===i?void 0:i.getSafeLeadSourceTouchpointsWithDefault({includedUserSelectedLeadSource:u||null}))&&void 0!==n?n:[],search:window.location.search,referrer:document.referrer,googleReferral:os()}),conversationTrackingId:null!==(o=null===(r=this.leadSourceClient)||void 0===r?void 0:r.chatId)&&void 0!==o?o:null,cancelExistingTours:e}),h=JSON.stringify({tour_type:c.tour_type,stops:c.stops,contact:c.contact,cancel_existing_tours:c.cancel_existing_tours});(null===(a=this.idempotency)||void 0===a?void 0:a.booking)!==h&&(this.idempotency={booking:h,key:bs()}),Ro("scheduleTourSubmitted",{tourType:l.tourType,stopCount:c.stops.length,buildingId:this.buildingId}),this.submitting=!0,this.bookingError=null;try{const t=await this.client.book(c,this.idempotency.key);this.idempotency=null,this.rescheduled=e,this.onBooked(t,l.tourType,s)}catch(e){this.onBookingError(e)}finally{this.submitting=!1}}onBooked(e,t,i){var n,r,o,a,s,l;if(this.reschedulePrompt=null,e.stops.every(e=>"failed"===e.status))return this.notice=null!==(o=null===(r=null===(n=e.stops.find(e=>e.error))||void 0===n?void 0:n.error)||void 0===r?void 0:r.message)&&void 0!==o?o:"We couldn't book your tour. Please pick another time.",this.log("TOUR_SCHEDULER_V2_BOOKING_ERROR",e.stops),void this.runPlan(!0);const d=new Map(i.stops.map(e=>[e.building_id,e]));this.confirmed=e.stops.map(e=>{var t,i,n,r,o,a,s,l,u,c;const h=null!==(t=this.communities.get(e.building_id))&&void 0!==t?t:{building_id:e.building_id,name:"",address:null,timezone:null},p=null!==(r=null!==(i=h.timezone)&&void 0!==i?i:null===(n=d.get(e.building_id))||void 0===n?void 0:n.timezone)&&void 0!==r?r:null;return{community:{...h,timezone:p},start:e.start,end:e.end,status:e.status,error:null!==(a=null===(o=e.error)||void 0===o?void 0:o.message)&&void 0!==a?a:null,distanceFromPrevMi:null!==(l=null===(s=d.get(e.building_id))||void 0===s?void 0:s.distance_from_prev_mi)&&void 0!==l?l:null,travelMinutesFromPrev:null!==(c=null===(u=d.get(e.building_id))||void 0===u?void 0:u.travel_minutes_from_prev)&&void 0!==c?c:null}});const u=e.stops.filter(e=>"failed"!==e.status&&null!==e.calendar_event_id);this.bookedEventIds=u.map(e=>e.calendar_event_id),this.bookedTourType=t,this.extending=!1,this.extendInitial=null,Ro("tourItineraryBooked",{buildingId:this.buildingId,stopCount:u.length,failedCount:e.stops.length-u.length}),u.length>0&&(null===(a=this.leadSourceClient)||void 0===a||a.checkAndHandleForLogLeadSource({webchatAction:"tour-scheduler",stateId:null}),null===(s=this.leadSourceClient)||void 0===s||s.resetLeadSource(),null===(l=this.leadSourceMultitouchClient)||void 0===l||l.resetLeadSourceTouchpoints()),this.goTo("booked"),this.loadExtension()}extendQueryFromBooking(){const e=this.confirmed.filter(e=>"failed"!==e.status),t=e[e.length-1];return(null==t?void 0:t.end)&&this.bookedTourType?{availableAfter:t.end,tourType:this.bookedTourType,nearBuildingId:t.community.building_id,excludeBuildingIds:e.map(e=>e.community.building_id)}:null}stopsRemaining(){return 3-this.bookedEventIds.length}get canAddStop(){var e,t;return!this.planLoading&&!this.planError&&this.stopsRemaining()>this.selectedIds.length&&(null!==(t=null===(e=this.plan)||void 0===e?void 0:e.stops.length)&&void 0!==t?t:0)>0}extendQueryFromPlan(){var e,t;const i=null!==(t=null===(e=this.plan)||void 0===e?void 0:e.stops)&&void 0!==t?t:[],n=i[i.length-1];return n&&this.extendFrom?{...this.extendFrom,availableAfter:n.end,nearBuildingId:n.building_id,excludeBuildingIds:[...this.extendFrom.excludeBuildingIds,...this.selectedIds]}:null}onStopAdded(e){const t=e[0];if(!t)return;this.rememberOne(t),Ro("tourCommunitiesSelected",{buildingId:this.buildingId,count:1,mode:"extend"});const i=this.stopDates[this.selectedIds[this.selectedIds.length-1]];i&&(this.stopDates={...this.stopDates,[t.building_id]:i}),this.selectedIds=[...this.selectedIds,t.building_id],this.runPlan()}async loadExtension(){const e=this.extendQueryFromBooking();this.extendFrom=e;const t=this.stopsRemaining();if(this.group&&e&&!(t<=0))try{const i=await this.client.getCommunities({...Ku,extend:e});this.remember(i.communities),i.communities.some(e=>e.tourable)&&(this.extendInitial=i,Ro("tourExtensionOffered",{buildingId:this.buildingId,stopsRemaining:t}))}catch(e){this.log("TOUR_SCHEDULER_V2_EXTEND_LOAD_ERROR",e)}}onBookingError(e){const t=e instanceof su?e:new su(0,null,"Something went wrong. Please try again.");if("EXISTING_TOUR"!==t.code){if(this.reschedulePrompt=null,"SLOT_TAKEN"===t.code)return this.notice=t.message,void this.runPlan(!0);this.bookingError=t.message,this.log("TOUR_SCHEDULER_V2_BOOKING_ERROR",e)}else this.reschedulePrompt=t.message}showLeadSourceDropdown(){return this.featureFlagShowDropdown===yo.always||this.featureFlagShowDropdown===yo.onAttributionFailure&&0===this.currentLeadSource.length}log(e,t){To({logTitle:e,logData:{error:t},logType:Ao.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,error:t})}backStep(){return this.rescheduleCanceled?null:"schedule"===this.step?this.extending?"booked":this.group?"pick":null:"pick"===this.step&&this.group&&!this.group.anchor.is_general_building&&this.plan&&this.selectedIds.length>0?"schedule":null}problems(){var e,t;return null!==(t=null===(e=this.plan)||void 0===e?void 0:e.unchainable)&&void 0!==t?t:[]}isMultiStop(){return this.selectedIds.length>1||this.existingEventIds.length>0}canSubmit(){const e=this.plan;return!!e&&!this.planLoading&&!this.planError&&e.stops.some(e=>!e.fixed)&&0===e.unchainable.length&&null===this.activeLinkType&&(this.extending||(t=this.formValues,i=this.bedroomsRequired,(!!t.firstName.trim()||!!t.lastName.trim())&&Rr(t.email.trim())&&!!t.phoneE164&&(!i||t.layouts.length>0)));var t,i}get bedroomOptions(){const e=new Set(this.selectedIds.flatMap(e=>{var t,i;return null!==(i=null===(t=this.communities.get(e))||void 0===t?void 0:t.bedrooms)&&void 0!==i?i:[]}));return e.size>0?[...e].sort((e,t)=>e-t).map(Vu):this.layoutOptions}get preferredLayouts(){return this.bedroomOptions.map(e=>e.value).filter(e=>this.preferences.bedrooms.includes(Wu(e)))}get formValues(){var e;return{...this.contact,layouts:this.preferredLayouts,moveIn:null!==(e=this.preferences.moveIn)&&void 0!==e?e:""}}onContactChange(e){this.contact=e;const t=this.formValues,i=Xu(t.layouts.filter(t=>!e.layouts.includes(t))),n=Xu(e.layouts.filter(e=>!t.layouts.includes(e)));(i.length>0||n.length>0)&&(this.preferences={...this.preferences,bedrooms:[...new Set([...this.preferences.bedrooms.filter(e=>!i.includes(e)),...n])].sort((e,t)=>e-t)}),e.moveIn!==t.moveIn&&(this.preferences={...this.preferences,moveIn:e.moveIn||null})}get bedroomsRequired(){return this.bedroomPreferenceRequired&&this.bedroomOptions.length>0}disclaimer(){return na({buildingName:this.buildingName,phoneNumberInput:this.contact.phone,emailInput:this.contact.email,orgLegalName:this.orgLegalName,orgSlug:this.orgSlug,country:this.country,buildingState:this.buildingState,clickingButtonText:"schedule tour"})}container(e){return H`<div
|
|
6925
|
+
`,Fu([pe({type:Number})],Hu.prototype,"size",void 0),Fu([pe({type:Number})],Hu.prototype,"spinSpeed",void 0),Hu=Fu([ce("mega-loader")],Hu);const zu=e=>{const t=Object.fromEntries(e.buildingIds.slice(1).filter(t=>e.laterStarts[t]).map(t=>[String(t),e.laterStarts[t]])),i=Object.fromEntries(e.buildingIds.filter(t=>e.stopDates[t]&&e.stopDates[t]!==e.date).map(t=>[String(t),e.stopDates[t]])),n=e.existingEventIds[e.existingEventIds.length-1];return{building_ids:e.buildingIds,tour_type:e.tourType,date:e.date,start_time:e.firstStart,stop_starts:t,stop_dates:i,fixed_first:void 0===n?null:{calendar_event_id:n}}},Gu=({orgSlug:e,selectedLeadSource:t,currentLeadSource:i,touchpoints:n,search:r,referrer:o,googleReferral:a})=>{var s,l,d;const u=t||i||null,c=ca(e);return{lead_sources:[...new Set(u?[u,c]:[c])],lead_sources_with_timestamps:n.map(e=>Or({...e})),query_params:Object.fromEntries(new URLSearchParams(r).entries()),referrer:o,google_rwg_token:null!==(s=null==a?void 0:a.rwgToken)&&void 0!==s?s:null,google_referral_building_id:null!==(l=null==a?void 0:a.buildingId)&&void 0!==l?l:null,google_environment:null!==(d=null==a?void 0:a.environment)&&void 0!==d?d:null}},Wu=e=>0===e?0:Math.floor(e/10),qu=["Studio","One bedroom","Two bedroom","Three bedroom","Four bedroom","Five bedroom"],Vu=e=>{var t;return{value:10*e,label:null!==(t=qu[e])&&void 0!==t?t:`${e} bedroom`}};var Qu,Yu=function(e,t,i,n){var r,o=arguments.length,a=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,n);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,i,a):r(t,i))||a);return o>3&&a&&Object.defineProperty(t,i,a),a};const Ku={bedrooms:[],moveIn:null,maxBudget:null},Xu=e=>[...new Set(e.map(Wu))],Zu={"escorted-tour":"WITH_AGENT","self-guided-tour":"SELF_GUIDED","live-virtual-tour":"VIRTUAL_SHOWING"};let Ju=Qu=class extends de{constructor(){super(...arguments),this.orgSlug="",this.buildingSlug="",this.buildingId=0,this.orgId=0,this.buildingName="",this.sgtUrl="",this.selfGuidedToursTypeOffered="",this.escortedToursLink="",this.escortedToursTypeOffered="",this.virtualToursLink="",this.virtualToursTypeOffered="",this.tourTypeOptions=[],this.layoutOptions=[],this.currentLeadSource="",this.leadSources=[],this.featureFlagShowDropdown="",this.bedroomPreferenceRequired=!1,this.orgLegalName="",this.country=null,this.buildingState=null,this.primaryColor=Xi,this.foregroundColorOnPrimaryBackgroundColor="white",this.compactDesign=!1,this.leadSourceClient=null,this.leadSourceMultitouchClient=null,this.getSessionToken=()=>null,this.api=null,this.step="loading",this.loadError=null,this.mobile=Nr(),this.group=null,this.communities=new Map,this.selectedIds=[],this.picks=[],this.addingStop=!1,this.existingEventIds=[],this.tourType="escorted-tour",this.linkTourType=null,this.date=null,this.firstStart=null,this.laterStarts={},this.stopDates={},this.plan=null,this.planLoading=!1,this.planError=null,this.notice=null,this.contact=Ru,this.preferences=Ku,this.submitting=!1,this.bookingError=null,this.reschedulePrompt=null,this.confirmed=[],this.bookedTourType=null,this.bookedEventIds=[],this.extendInitial=null,this.extendFrom=null,this.extending=!1,this.rescheduled=!1,this.rescheduleCanceled=!1,this.planRequestId=0,this.idempotency=null,this.narrow=!1,this.modalResize=new ResizeObserver(([e])=>{this.narrow=e.contentRect.width<Qu.THREE_COLUMN_MIN_WIDTH}),this.observeModal=e=>{this.modalResize.disconnect(),e&&this.modalResize.observe(e)},this.onKeydown=e=>{hd(e,this),"Escape"!==e.key||e.defaultPrevented||e.isComposing||(e.stopPropagation(),this.close())},this.loadSelectCommunities=e=>this.client.getCommunities(e).then(this.rememberPage),this.loadExtendCommunities=e=>{const t=this.extendFrom;return t?this.client.getCommunities({...e,extend:t}).then(this.rememberPage):Promise.reject(new Error("No booking to extend"))},this.rememberPage=e=>(this.remember(e.communities),e),this.loadAddStopCommunities=e=>{const t=this.extendQueryFromPlan();return t?this.client.getCommunities({...e,extend:t}).then(this.rememberPage):Promise.reject(new Error("No stop to add after"))},this.onFiltersChange=e=>{this.preferences=e.detail.filters}}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"),this.cleanupMobileListener=Mr(e=>this.mobile=e),this.addEventListener("keydown",this.onKeydown)}disconnectedCallback(){var e;null===(e=this.cleanupMobileListener)||void 0===e||e.call(this),this.removeEventListener("keydown",this.onKeydown),super.disconnectedCallback()}close(){var e;null===(e=this.onCloseClicked)||void 0===e||e.call(this,new MouseEvent("click"))}get client(){return this.api||(this.api=lu({orgSlug:this.orgSlug,buildingSlug:this.buildingSlug,getSessionToken:()=>this.getSessionToken()})),this.api}willUpdate(e){if(e.has("primaryColor")||e.has("foregroundColorOnPrimaryBackgroundColor")){const e=this.primaryColor||Xi;this.style.setProperty("--primary-color",e),this.style.setProperty("--action-confirm-button-background",e),this.style.setProperty("--action-confirm-button-color",this.foregroundColorOnPrimaryBackgroundColor),this.style.setProperty("--on-primary-color",this.foregroundColorOnPrimaryBackgroundColor)}}firstUpdated(){this.start()}updated(e){var t;e.has("step")&&void 0===e.get("step")?ud(this):((e.has("step")||e.has("reschedulePrompt")||e.has("rescheduleCanceled"))&&(this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1"),this.focus({preventScroll:!0})),e.has("notice")&&this.notice&&(null===(t=this.renderRoot.querySelector(".notice"))||void 0===t||t.scrollIntoView({block:"nearest"})))}async start(){this.step="loading",this.loadError=null;try{const e=await this.client.getCommunities(Ku);if(this.group=e,this.remember(e.communities),e.anchor.is_general_building)return void this.goTo("pick");this.rememberOne({building_id:e.anchor.building_id,name:e.anchor.name,address:null,timezone:null}),this.startSchedule([e.anchor.building_id])}catch(e){if(e instanceof su&&"NOT_IN_GROUP"===e.code)return this.group=null,this.rememberOne({building_id:this.buildingId,name:this.buildingName,address:null,timezone:null}),void this.startSchedule([this.buildingId]);this.loadError=e.message,this.step="error",this.log("TOUR_SCHEDULER_V2_LOAD_ERROR",e)}}goTo(e){this.step=e,"pick"===e?this.picks=this.selectedIds.map(e=>this.communities.get(e)).filter(e=>!!e):"booked"===e&&(this.picks=[]),Ro("tourSchedulerStepViewed",{step:"schedule"===e&&this.extending?"extend-schedule":e,buildingId:this.buildingId})}remember(e){const t=new Map(this.communities);e.forEach(e=>t.set(e.building_id,ou(e))),this.communities=t}rememberOne(e){const t=this.communities.get(e.building_id);(null==t?void 0:t.address)||(this.communities=new Map(this.communities).set(e.building_id,e))}startSchedule(e){this.selectedIds=e,this.plan=null,this.firstStart=null,this.laterStarts={},this.stopDates={},this.linkTourType=null,this.notice=null,this.bookingError=null,this.reschedulePrompt=null,this.goTo("schedule"),this.runPlan()}choice(){var e;return{buildingIds:this.selectedIds,tourType:this.tourType,date:null!==(e=this.date)&&void 0!==e?e:Cu(new Date),firstStart:this.firstStart,laterStarts:this.laterStarts,stopDates:this.stopDates,existingEventIds:this.existingEventIds}}async runPlan(e=!1){if(this.addingStop=!1,0===this.selectedIds.length)return;const t=++this.planRequestId;this.planLoading=!0,this.planError=null,e||(this.notice=null);try{let e=this.choice(),i=await this.client.plan(zu(e));for(let n=0;n<2&&t===this.planRequestId;n++){if(i.tour_types.includes(e.tourType)){if(!(0===Object.keys(e.stopDates).length&&i.bookable_dates.length>0)||i.bookable_dates.includes(e.date))break;this.date=i.bookable_dates[0]}else{if(0===i.tour_types.length)break;this.tourType=i.tour_types[0],this.stopDates={}}this.firstStart=null,this.laterStarts={},e=this.choice(),i=await this.client.plan(zu(e))}if(t!==this.planRequestId)return;this.plan=i,i.bookable_dates.includes(e.date)&&(this.date=e.date),i.changed.length>0&&(this.notice=i.changed.map(e=>e.text).join(" "))}catch(e){if(t!==this.planRequestId)return;this.planError=e.message,this.log("TOUR_SCHEDULER_V2_PLAN_ERROR",e)}finally{t===this.planRequestId&&(this.planLoading=!1)}}tourLink(e){if(!this.tourTypeOptions.map(e=>e.value).includes(Zu[e]))return null;const[t,i]={"self-guided-tour":[this.sgtUrl,this.selfGuidedToursTypeOffered],"escorted-tour":[this.escortedToursLink,this.escortedToursTypeOffered],"live-virtual-tour":[this.virtualToursLink,this.virtualToursTypeOffered]}[e];return t&&wa(0,i)?t:null}get bookingOwnBuildingAlone(){return 0===this.existingEventIds.length&&1===this.selectedIds.length&&this.selectedIds[0]===this.buildingId}openTourLink(e){const t=this.tourLink(e);if(!t)return;const i="self-guided-tour"===e&&52===this.orgId?Io(t,Po()):t;window.open(i,"_blank")}tourTypeChoices(){var e,t;const i=null!==(t=null===(e=this.plan)||void 0===e?void 0:e.tour_types)&&void 0!==t?t:[];return Su.filter(e=>i.includes(e)||this.bookingOwnBuildingAlone&&!!this.tourLink(e)).map(e=>({id:e,opensLink:this.bookingOwnBuildingAlone&&!!this.tourLink(e)}))}get shownTourType(){var e;return this.linkTourType?this.linkTourType:(null===(e=this.plan)||void 0===e?void 0:e.tour_types.includes(this.tourType))?this.tourType:null}get activeLinkType(){const e=this.shownTourType;return e&&this.bookingOwnBuildingAlone&&this.tourLink(e)?e:null}onTourType(e){if(Ro("tourTypeSelected",{tourType:e,buildingId:this.buildingId}),this.bookingOwnBuildingAlone&&this.tourLink(e))return this.linkTourType=e,void this.openTourLink(e);this.linkTourType=null,e!==this.tourType&&(this.tourType=e,this.firstStart=null,this.laterStarts={},this.stopDates={},this.runPlan())}onDate(e){e!==this.date&&(Ro("tourDateSelected",{tourType:this.tourType,buildingId:this.buildingId}),this.date=e,this.firstStart=null,this.laterStarts={},this.stopDates={},this.runPlan())}stopDatesWithout(e){return Object.fromEntries(Object.entries(this.stopDates).filter(([t])=>Number(t)!==e))}onStopDate(e,t){const i=this.selectedIds.indexOf(e);if(i<0)return;Ro("tourStopDateSelected",{tourType:this.tourType,buildingId:this.buildingId,stopNumber:i+1});const n=this.stopDatesWithout(e);this.stopDates=t===this.date?n:{...n,[e]:t},0===i&&(this.firstStart=null),this.laterStarts=Object.fromEntries(this.selectedIds.slice(1,i).filter(e=>this.laterStarts[e]).map(e=>[e,this.laterStarts[e]])),this.runPlan()}onStopTime(e,t){const i=this.selectedIds.indexOf(e);if(i<0)return;Ro("tourTimeSelected",{tourType:this.tourType,buildingId:this.buildingId,stopNumber:i+1});const n=this.selectedIds.slice(1,i);0===i?(this.firstStart=uu(t),this.laterStarts={}):this.laterStarts={...Object.fromEntries(n.filter(e=>this.laterStarts[e]).map(e=>[e,this.laterStarts[e]])),[e]:t},this.runPlan()}onReorder(e){Ro("tourStopsReordered",{buildingId:this.buildingId,stopCount:e.length});const t=this.selectedIds.filter(t=>!e.includes(t));this.selectedIds=[...e,...t],this.firstStart=null,this.laterStarts={},this.runPlan()}onRemove(e){const t=this.selectedIds.filter(t=>t!==e);if(Ro("tourStopRemoved",{buildingId:this.buildingId,stopCount:t.length}),0===t.length)return this.selectedIds=[],this.plan=null,void this.goTo(this.extending?"booked":"pick");this.selectedIds[0]===e&&(this.firstStart=null),this.selectedIds=t,this.laterStarts={},this.stopDates=this.stopDatesWithout(e),this.runPlan()}onEditCommunities(){this.goTo("pick")}onCommunitiesSelected(e,t){var i;if(e.forEach(e=>this.rememberOne(e)),Ro("tourCommunitiesSelected",{buildingId:this.buildingId,count:e.length,mode:t}),this.extending="extend"===t,this.extending){this.existingEventIds=this.bookedEventIds,this.tourType=null!==(i=this.bookedTourType)&&void 0!==i?i:this.tourType;const e=this.confirmed.filter(e=>e.start).slice(-1)[0];this.date=(null==e?void 0:e.start)?du(e.start):this.date}else this.existingEventIds=[];this.startSchedule(e.map(e=>e.building_id))}async submit(e=!1){var t,i,n,r,o,a;const s=this.plan;if(!s||this.submitting)return;const l=this.choice(),d=this.formValues,u=this.showLeadSourceDropdown()?d.leadSource:null,c=(({choice:e,plan:t,contact:i,attribution:n,conversationTrackingId:r,cancelExistingTours:o})=>({tour_type:e.tourType,stops:[...e.existingEventIds.map(e=>({existing_calendar_event_id:e})),...t.stops.filter(e=>!e.fixed).map(e=>({building_id:e.building_id,start:e.start}))],...i?{contact:i}:{},lead_sources:n,conversation_tracking_id:r,cancel_existing_tours:o}))({choice:l,plan:s,contact:this.extending?null:{first_name:d.firstName.trim(),last_name:d.lastName.trim(),email:d.email.trim(),phone_e164:null!==(t=d.phoneE164)&&void 0!==t?t:"",bedrooms:Xu(d.layouts),move_in:d.moveIn||null,max_budget:this.preferences.maxBudget,notes:d.notes.trim()},attribution:Gu({orgSlug:this.orgSlug,selectedLeadSource:u,currentLeadSource:this.currentLeadSource,touchpoints:null!==(n=null===(i=this.leadSourceMultitouchClient)||void 0===i?void 0:i.getSafeLeadSourceTouchpointsWithDefault({includedUserSelectedLeadSource:u||null}))&&void 0!==n?n:[],search:window.location.search,referrer:document.referrer,googleReferral:os()}),conversationTrackingId:null!==(o=null===(r=this.leadSourceClient)||void 0===r?void 0:r.chatId)&&void 0!==o?o:null,cancelExistingTours:e}),h=JSON.stringify({tour_type:c.tour_type,stops:c.stops,contact:c.contact,cancel_existing_tours:c.cancel_existing_tours});(null===(a=this.idempotency)||void 0===a?void 0:a.booking)!==h&&(this.idempotency={booking:h,key:bs()}),Ro("scheduleTourSubmitted",{tourType:l.tourType,stopCount:c.stops.length,buildingId:this.buildingId}),this.submitting=!0,this.bookingError=null;try{const t=await this.client.book(c,this.idempotency.key);this.idempotency=null,this.rescheduled=e,this.onBooked(t,l.tourType,s)}catch(e){this.onBookingError(e)}finally{this.submitting=!1}}onBooked(e,t,i){var n,r,o,a,s,l;if(this.reschedulePrompt=null,e.stops.every(e=>"failed"===e.status))return this.notice=null!==(o=null===(r=null===(n=e.stops.find(e=>e.error))||void 0===n?void 0:n.error)||void 0===r?void 0:r.message)&&void 0!==o?o:"We couldn't book your tour. Please pick another time.",this.log("TOUR_SCHEDULER_V2_BOOKING_ERROR",e.stops),void this.runPlan(!0);const d=new Map(i.stops.map(e=>[e.building_id,e]));this.confirmed=e.stops.map(e=>{var t,i,n,r,o,a,s,l,u,c;const h=null!==(t=this.communities.get(e.building_id))&&void 0!==t?t:{building_id:e.building_id,name:"",address:null,timezone:null},p=null!==(r=null!==(i=h.timezone)&&void 0!==i?i:null===(n=d.get(e.building_id))||void 0===n?void 0:n.timezone)&&void 0!==r?r:null;return{community:{...h,timezone:p},start:e.start,end:e.end,status:e.status,error:null!==(a=null===(o=e.error)||void 0===o?void 0:o.message)&&void 0!==a?a:null,distanceFromPrevMi:null!==(l=null===(s=d.get(e.building_id))||void 0===s?void 0:s.distance_from_prev_mi)&&void 0!==l?l:null,travelMinutesFromPrev:null!==(c=null===(u=d.get(e.building_id))||void 0===u?void 0:u.travel_minutes_from_prev)&&void 0!==c?c:null}});const u=e.stops.filter(e=>"failed"!==e.status&&null!==e.calendar_event_id);this.bookedEventIds=u.map(e=>e.calendar_event_id),this.bookedTourType=t,this.extending=!1,this.extendInitial=null,Ro("tourItineraryBooked",{buildingId:this.buildingId,stopCount:u.length,failedCount:e.stops.length-u.length}),u.length>0&&(null===(a=this.leadSourceClient)||void 0===a||a.checkAndHandleForLogLeadSource({webchatAction:"tour-scheduler",stateId:null}),null===(s=this.leadSourceClient)||void 0===s||s.resetLeadSource(),null===(l=this.leadSourceMultitouchClient)||void 0===l||l.resetLeadSourceTouchpoints()),this.goTo("booked"),this.loadExtension()}extendQueryFromBooking(){const e=this.confirmed.filter(e=>"failed"!==e.status),t=e[e.length-1];return(null==t?void 0:t.end)&&this.bookedTourType?{availableAfter:t.end,tourType:this.bookedTourType,nearBuildingId:t.community.building_id,excludeBuildingIds:e.map(e=>e.community.building_id)}:null}stopsRemaining(){return 3-this.bookedEventIds.length}get canAddStop(){var e,t;return!this.planLoading&&!this.planError&&this.stopsRemaining()>this.selectedIds.length&&(null!==(t=null===(e=this.plan)||void 0===e?void 0:e.stops.length)&&void 0!==t?t:0)>0}extendQueryFromPlan(){var e,t;const i=null!==(t=null===(e=this.plan)||void 0===e?void 0:e.stops)&&void 0!==t?t:[],n=i[i.length-1];return n&&this.extendFrom?{...this.extendFrom,availableAfter:n.end,nearBuildingId:n.building_id,excludeBuildingIds:[...this.extendFrom.excludeBuildingIds,...this.selectedIds]}:null}onStopAdded(e){const t=e[0];if(!t)return;this.rememberOne(t),Ro("tourCommunitiesSelected",{buildingId:this.buildingId,count:1,mode:"extend"});const i=this.stopDates[this.selectedIds[this.selectedIds.length-1]];i&&(this.stopDates={...this.stopDates,[t.building_id]:i}),this.selectedIds=[...this.selectedIds,t.building_id],this.runPlan()}async loadExtension(){const e=this.extendQueryFromBooking();this.extendFrom=e;const t=this.stopsRemaining();if(this.group&&e&&!(t<=0))try{const i=await this.client.getCommunities({...Ku,extend:e});this.remember(i.communities),i.communities.some(e=>e.tourable)&&(this.extendInitial=i,Ro("tourExtensionOffered",{buildingId:this.buildingId,stopsRemaining:t}))}catch(e){this.log("TOUR_SCHEDULER_V2_EXTEND_LOAD_ERROR",e)}}onBookingError(e){const t=e instanceof su?e:new su(0,null,"Something went wrong. Please try again.");if("EXISTING_TOUR"!==t.code){if(this.reschedulePrompt=null,"SLOT_TAKEN"===t.code)return this.notice=t.message,void this.runPlan(!0);this.bookingError=t.message,this.log("TOUR_SCHEDULER_V2_BOOKING_ERROR",e)}else this.reschedulePrompt=t.message}showLeadSourceDropdown(){return this.featureFlagShowDropdown===yo.always||this.featureFlagShowDropdown===yo.onAttributionFailure&&0===this.currentLeadSource.length}log(e,t){To({logTitle:e,logData:{error:t},logType:Ao.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,error:t})}backStep(){return this.rescheduleCanceled?null:"schedule"===this.step?this.extending?"booked":this.group?"pick":null:"pick"===this.step&&this.group&&!this.group.anchor.is_general_building&&this.plan&&this.selectedIds.length>0?"schedule":null}problems(){var e,t;return null!==(t=null===(e=this.plan)||void 0===e?void 0:e.unchainable)&&void 0!==t?t:[]}isMultiStop(){return this.selectedIds.length>1||this.existingEventIds.length>0}canSubmit(){const e=this.plan;return!!e&&!this.planLoading&&!this.planError&&e.stops.some(e=>!e.fixed)&&0===e.unchainable.length&&null===this.activeLinkType&&(this.extending||(t=this.formValues,i=this.bedroomsRequired,(!!t.firstName.trim()||!!t.lastName.trim())&&Rr(t.email.trim())&&!!t.phoneE164&&(!i||t.layouts.length>0)));var t,i}get bedroomOptions(){const e=new Set(this.selectedIds.flatMap(e=>{var t,i;return null!==(i=null===(t=this.communities.get(e))||void 0===t?void 0:t.bedrooms)&&void 0!==i?i:[]}));return e.size>0?[...e].sort((e,t)=>e-t).map(Vu):this.layoutOptions}get preferredLayouts(){return this.bedroomOptions.map(e=>e.value).filter(e=>this.preferences.bedrooms.includes(Wu(e)))}get formValues(){var e;return{...this.contact,layouts:this.preferredLayouts,moveIn:null!==(e=this.preferences.moveIn)&&void 0!==e?e:""}}onContactChange(e){this.contact=e;const t=this.formValues,i=Xu(t.layouts.filter(t=>!e.layouts.includes(t))),n=Xu(e.layouts.filter(e=>!t.layouts.includes(e)));(i.length>0||n.length>0)&&(this.preferences={...this.preferences,bedrooms:[...new Set([...this.preferences.bedrooms.filter(e=>!i.includes(e)),...n])].sort((e,t)=>e-t)}),e.moveIn!==t.moveIn&&(this.preferences={...this.preferences,moveIn:e.moveIn||null})}get bedroomsRequired(){return this.bedroomPreferenceRequired&&this.bedroomOptions.length>0}disclaimer(){return na({buildingName:this.buildingName,phoneNumberInput:this.contact.phone,emailInput:this.contact.email,orgLegalName:this.orgLegalName,orgSlug:this.orgSlug,country:this.country,buildingState:this.buildingState,clickingButtonText:"schedule tour"})}container(e){return H`<div
|
|
6926
6926
|
id=${this.mobile?"mobile-body-container":"scheduler-container"}
|
|
6927
6927
|
>
|
|
6928
6928
|
${e}
|
|
@@ -6998,12 +6998,12 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
6998
6998
|
id="tour-scheduler-footer"
|
|
6999
6999
|
class=${xe({itinerary:this.extending})}
|
|
7000
7000
|
>
|
|
7001
|
-
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
</
|
|
7001
|
+
${this.extending?"":H`<div class="explanation consent">
|
|
7002
|
+
We'll send a confirmation and any follow-ups to your email address,
|
|
7003
|
+
please reply to the email to make any appointment changes.
|
|
7004
|
+
${this.disclaimer()}
|
|
7005
|
+
</div>`}
|
|
7006
|
+
${this.bookingError?H`<p class="error-message" role="alert">${this.bookingError}</p>`:""}
|
|
7007
7007
|
<action-confirm-button
|
|
7008
7008
|
id="schedule-bttn"
|
|
7009
7009
|
.onClick=${()=>this.submit()}
|
|
@@ -7045,7 +7045,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
7045
7045
|
</p>
|
|
7046
7046
|
</div>`)}
|
|
7047
7047
|
<div id="tour-scheduler-footer" class="itinerary">
|
|
7048
|
-
|
|
7048
|
+
${this.extending?"":H`<div class="explanation consent">${this.disclaimer()}</div>`}
|
|
7049
7049
|
<div class="reschedule-buttons-wrapper">
|
|
7050
7050
|
<action-confirm-button
|
|
7051
7051
|
id="cancel-reschedule-bttn"
|
|
@@ -7306,6 +7306,15 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
7306
7306
|
text-align: center;
|
|
7307
7307
|
}
|
|
7308
7308
|
|
|
7309
|
+
/* The footer's gap spaces it. */
|
|
7310
|
+
#tour-scheduler-footer > .error-message {
|
|
7311
|
+
margin: 0;
|
|
7312
|
+
}
|
|
7313
|
+
|
|
7314
|
+
#tour-scheduler-footer.itinerary > .error-message {
|
|
7315
|
+
text-align: center;
|
|
7316
|
+
}
|
|
7317
|
+
|
|
7309
7318
|
.consent {
|
|
7310
7319
|
font-size: 10px;
|
|
7311
7320
|
line-height: 14px;
|
|
@@ -323,6 +323,10 @@ export class CommunityPicker extends LitElement {
|
|
|
323
323
|
const next = c.next_available;
|
|
324
324
|
// Extension times are all on the day already booked.
|
|
325
325
|
const sameDay = !!next && this.variant === "extend";
|
|
326
|
+
// Only the extend variant measures from a booked stop. The select page
|
|
327
|
+
// measures from the community the widget opened on, which for a group is
|
|
328
|
+
// a placeholder, so its distances mean nothing to the prospect.
|
|
329
|
+
const distance = this.variant === "extend" ? c.distance_mi : null;
|
|
326
330
|
const price = c.price_from
|
|
327
331
|
? `${
|
|
328
332
|
c.price_from.bedrooms === 0 ? "Studio" : `${c.price_from.bedrooms} BR`
|
|
@@ -346,7 +350,7 @@ export class CommunityPicker extends LitElement {
|
|
|
346
350
|
/></span>`
|
|
347
351
|
: ""}
|
|
348
352
|
<span class="card-body">
|
|
349
|
-
${c.best_match || price ||
|
|
353
|
+
${c.best_match || price || distance !== null
|
|
350
354
|
? html`<span class="card-tags">
|
|
351
355
|
${c.best_match
|
|
352
356
|
? html`<span class="tag"
|
|
@@ -358,9 +362,9 @@ export class CommunityPicker extends LitElement {
|
|
|
358
362
|
>${BadgeCheckFilledIcon(14)} ${price}</span
|
|
359
363
|
>`
|
|
360
364
|
: ""}
|
|
361
|
-
${
|
|
365
|
+
${distance !== null
|
|
362
366
|
? html`<span class="distance"
|
|
363
|
-
>${
|
|
367
|
+
>${distance.toFixed(1)} mi</span
|
|
364
368
|
>`
|
|
365
369
|
: ""}
|
|
366
370
|
</span>`
|
|
@@ -722,6 +722,7 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
722
722
|
phone_e164: values.phoneE164 ?? "",
|
|
723
723
|
bedrooms: bedroomsOf(values.layouts),
|
|
724
724
|
move_in: values.moveIn || null,
|
|
725
|
+
max_budget: this.preferences.maxBudget,
|
|
725
726
|
notes: values.notes.trim(),
|
|
726
727
|
},
|
|
727
728
|
attribution: buildAttribution({
|
|
@@ -1235,20 +1236,25 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
1235
1236
|
></contact-form>`;
|
|
1236
1237
|
}
|
|
1237
1238
|
|
|
1238
|
-
/** The consent text and the submit button, under the form or the itinerary. */
|
|
1239
|
+
/** The consent text, any booking error and the submit button, under the form or the itinerary. */
|
|
1239
1240
|
private renderFooter(): TemplateResult {
|
|
1240
1241
|
return html`<div
|
|
1241
1242
|
id="tour-scheduler-footer"
|
|
1242
1243
|
class=${classMap({ itinerary: this.extending })}
|
|
1243
1244
|
>
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1245
|
+
${this.extending
|
|
1246
|
+
? // Adding stops sends no contact details: it books into the first
|
|
1247
|
+
// booking's conversation, whose form showed the consent. So, as in
|
|
1248
|
+
// the design, the itinerary has only its button.
|
|
1249
|
+
""
|
|
1250
|
+
: html`<div class="explanation consent">
|
|
1251
|
+
We'll send a confirmation and any follow-ups to your email address,
|
|
1252
|
+
please reply to the email to make any appointment changes.
|
|
1253
|
+
${this.disclaimer()}
|
|
1254
|
+
</div>`}
|
|
1255
|
+
${this.bookingError
|
|
1256
|
+
? html`<p class="error-message" role="alert">${this.bookingError}</p>`
|
|
1257
|
+
: ""}
|
|
1252
1258
|
<action-confirm-button
|
|
1253
1259
|
id="schedule-bttn"
|
|
1254
1260
|
.onClick=${() => this.submit()}
|
|
@@ -1317,7 +1323,9 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
1317
1323
|
</p>
|
|
1318
1324
|
</div>`)}
|
|
1319
1325
|
<div id="tour-scheduler-footer" class="itinerary">
|
|
1320
|
-
|
|
1326
|
+
${this.extending
|
|
1327
|
+
? ""
|
|
1328
|
+
: html`<div class="explanation consent">${this.disclaimer()}</div>`}
|
|
1321
1329
|
<div class="reschedule-buttons-wrapper">
|
|
1322
1330
|
<action-confirm-button
|
|
1323
1331
|
id="cancel-reschedule-bttn"
|
|
@@ -1628,6 +1636,15 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
1628
1636
|
text-align: center;
|
|
1629
1637
|
}
|
|
1630
1638
|
|
|
1639
|
+
/* The footer's gap spaces it. */
|
|
1640
|
+
#tour-scheduler-footer > .error-message {
|
|
1641
|
+
margin: 0;
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
#tour-scheduler-footer.itinerary > .error-message {
|
|
1645
|
+
text-align: center;
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1631
1648
|
.consent {
|
|
1632
1649
|
font-size: 10px;
|
|
1633
1650
|
line-height: 14px;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { expect } from "@esm-bundle/chai";
|
|
2
|
+
import "../public/dist/index";
|
|
3
|
+
import type { ContactForm } from "./WebComponent/SchedulerV2/contact-form";
|
|
4
|
+
|
|
5
|
+
declare const it: (name: string, callback: () => Promise<void>) => void;
|
|
6
|
+
|
|
7
|
+
// isValidEmail, through the v2 scheduler's contact form, one of its callers:
|
|
8
|
+
// the form flags an email it rejects.
|
|
9
|
+
const flagged = async (email: string): Promise<boolean> => {
|
|
10
|
+
const form = document.createElement("contact-form") as ContactForm;
|
|
11
|
+
form.values = { ...form.values, email };
|
|
12
|
+
document.body.appendChild(form);
|
|
13
|
+
await form.updateComplete;
|
|
14
|
+
const shown = !!form.shadowRoot?.querySelector(".error-message");
|
|
15
|
+
form.remove();
|
|
16
|
+
return shown;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
it("accepts emails whose top-level domain is two or more letters", async () => {
|
|
20
|
+
for (const email of [
|
|
21
|
+
"jane@example.com",
|
|
22
|
+
"jane@example.co",
|
|
23
|
+
"brittney.ciesa+tc17@onmicrosoft.com",
|
|
24
|
+
"first.last@mail.sub.example.co.uk",
|
|
25
|
+
"jane@example.museum",
|
|
26
|
+
"jane@example.photography",
|
|
27
|
+
"o'brien_99@example-mail.io",
|
|
28
|
+
"jane@例え.テスト",
|
|
29
|
+
"jane@xn--80ak6aa92e.xn--p1ai",
|
|
30
|
+
"JANE@EXAMPLE.COM",
|
|
31
|
+
]) {
|
|
32
|
+
expect(await flagged(email), email).to.equal(false);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("rejects a one-letter or non-letter top-level domain, and what it rejected before", async () => {
|
|
37
|
+
for (const email of [
|
|
38
|
+
"brittney.ciesa+tc17@onmicrosoft.c",
|
|
39
|
+
"jane@example.c",
|
|
40
|
+
"jane@example.1",
|
|
41
|
+
"jane@example.c0m",
|
|
42
|
+
"jane@example.com.",
|
|
43
|
+
"jane@example",
|
|
44
|
+
"jane.example.com",
|
|
45
|
+
"jane@@example.com",
|
|
46
|
+
"jane doe@example.com",
|
|
47
|
+
"@example.com",
|
|
48
|
+
]) {
|
|
49
|
+
expect(await flagged(email), email).to.equal(true);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
@@ -418,6 +418,7 @@ it("books a tour with the prospect's details, attribution and conversation, and
|
|
|
418
418
|
phone_e164: "+13125550142",
|
|
419
419
|
bedrooms: [1],
|
|
420
420
|
move_in: null,
|
|
421
|
+
max_budget: null,
|
|
421
422
|
notes: "",
|
|
422
423
|
});
|
|
423
424
|
expect(booking.conversation_tracking_id).to.equal("webchat_lead_test");
|
|
@@ -453,9 +454,15 @@ it("books a tour with the prospect's details, attribution and conversation, and
|
|
|
453
454
|
it("extends a booking without asking for contact details again, sending the booked tour as an existing stop and only the new community as a new one", async () => {
|
|
454
455
|
const { bookings, communityQueries } = fakeBackend();
|
|
455
456
|
const scheduler = mount();
|
|
457
|
+
const footerText = () =>
|
|
458
|
+
inScheduler(scheduler, "#tour-scheduler-footer")?.textContent ?? "";
|
|
456
459
|
|
|
460
|
+
await waitFor(() => inScheduler(scheduler, "contact-form"));
|
|
461
|
+
expect(footerText()).to.include("you consent to");
|
|
457
462
|
await bookAndAddLinden(scheduler);
|
|
458
463
|
expect(inScheduler(scheduler, "contact-form")).to.equal(null);
|
|
464
|
+
// The first booking's form showed the consent; adding a stop asks for nothing new.
|
|
465
|
+
expect(footerText()).not.to.include("consent");
|
|
459
466
|
await submitWhenReady(scheduler);
|
|
460
467
|
await waitFor(() => bookings.length === 2);
|
|
461
468
|
|
|
@@ -982,6 +989,7 @@ it("carries bedrooms, move-in and budget between the picker's filters, the form
|
|
|
982
989
|
await waitFor(() => bookings.length === 1);
|
|
983
990
|
expect(bookings[0].contact?.bedrooms).to.deep.equal([1]);
|
|
984
991
|
expect(bookings[0].contact?.move_in).to.equal("2027-01-15");
|
|
992
|
+
expect(bookings[0].contact?.max_budget).to.equal(2500);
|
|
985
993
|
|
|
986
994
|
const extendQuery = await waitFor(() =>
|
|
987
995
|
communityQueries.find((q) => q.has("available_after") && q.has("bedrooms"))
|
|
@@ -1184,3 +1192,32 @@ it("closes the date calendar when the prospect picks the day already chosen", as
|
|
|
1184
1192
|
await editor.updateComplete;
|
|
1185
1193
|
expect(popover.open).to.equal(false);
|
|
1186
1194
|
});
|
|
1195
|
+
|
|
1196
|
+
it("shows distances only on communities near a booked stop, not on the first page", async () => {
|
|
1197
|
+
const distances = async (variant: "select" | "extend") => {
|
|
1198
|
+
const picker = document.createElement(
|
|
1199
|
+
"community-picker"
|
|
1200
|
+
) as CommunityPicker;
|
|
1201
|
+
Object.assign(picker, {
|
|
1202
|
+
variant,
|
|
1203
|
+
initial: {
|
|
1204
|
+
anchor: {
|
|
1205
|
+
building_id: ANCHOR,
|
|
1206
|
+
name: "Parkside",
|
|
1207
|
+
is_general_building: true,
|
|
1208
|
+
},
|
|
1209
|
+
communities: [community(LINDEN, "The Linden")],
|
|
1210
|
+
},
|
|
1211
|
+
});
|
|
1212
|
+
document.body.appendChild(picker);
|
|
1213
|
+
await picker.updateComplete;
|
|
1214
|
+
const shown = Array.from(
|
|
1215
|
+
picker.shadowRoot?.querySelectorAll(".distance") ?? []
|
|
1216
|
+
).map((d) => d.textContent?.trim());
|
|
1217
|
+
picker.remove();
|
|
1218
|
+
return shown;
|
|
1219
|
+
};
|
|
1220
|
+
|
|
1221
|
+
expect(await distances("select")).to.deep.equal([]);
|
|
1222
|
+
expect(await distances("extend")).to.deep.equal(["1.8 mi"]);
|
|
1223
|
+
});
|
package/src/utils.ts
CHANGED
|
@@ -95,8 +95,12 @@ export const isValidPhoneNumber = (phoneNumber: string): boolean => {
|
|
|
95
95
|
return phoneNumberRegex.test(phoneNumber);
|
|
96
96
|
};
|
|
97
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Something@domain.tld, where the top-level domain is two or more letters
|
|
100
|
+
* (any script) or an IDN's punycode form, so a typo such as "x@y.c" is caught.
|
|
101
|
+
*/
|
|
98
102
|
export const isValidEmail = (email: string): boolean => {
|
|
99
|
-
const emailRegex = /^[^\s@]+@[^\s@]+\.[
|
|
103
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.(?:\p{L}{2,}|xn--[a-z\d-]+)$/iu;
|
|
100
104
|
return emailRegex.test(email);
|
|
101
105
|
};
|
|
102
106
|
|