@meetelise/chat 1.22.20 → 1.22.22

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meetelise/chat",
3
- "version": "1.22.20",
3
+ "version": "1.22.22",
4
4
  "description": "",
5
5
  "main": "public/dist/index.js",
6
6
  "type": "module",
@@ -945,7 +945,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
945
945
  gap: 12px;
946
946
  align-items: center;
947
947
  }
948
- `;class an{constructor(e,t,i,n){this.org=e,this.building=t,this.chatId=i,this.incomingProcessedLeadSource=n,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:sn(),incomingProcessedLeadSource:this.incomingProcessedLeadSource,webchatVersion:null!==(t="MISSING_ENV_VAR".npm_package_version)&&void 0!==t?t:"1.20.155"})})}}const sn=()=>{var e,t,i,n,r,o;try{const n=new URL(window.location.href).searchParams,r=null!==(i=null===(t=null===(e=window.RCTPCampaign)||void 0===e?void 0:e.CampaignDetails)||void 0===t?void 0:t.Source)&&void 0!==i?i:null,o=n.get("switch_cls[id]"),a=n.get("ilm");return{entrataCampaignSource:o,realpageCampaignSource:a,utmCampaignSource:n.get("utm_source"),yardiCampaignSource:r,bozzutoAdSource:hi("bozzuto_ad_source")}}catch(e){console.warn(`Couldnt get campaign sources from url, error: ${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 i=t.contentWindow.URL;if(!i)return{entrataCampaignSource:null,realpageCampaignSource:null,utmCampaignSource:null,yardiCampaignSource:null,bozzutoAdSource:null};const a=new i(window.location.href).searchParams,s=null!==(o=null===(r=null===(n=window.RCTPCampaign)||void 0===n?void 0:n.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:hi("bozzuto_ad_source")}}};var ln;!function(e){e.error="error",e.info="info",e.warn="warn"}(ln||(ln={}));const un=async({logType:e,buildingSlug:i,orgSlug:n,logTitle:r,logData:o})=>{await t().post("https://app.meetelise.com/platformApi/webchat/logging",{...o},{headers:{"Content-Type":"application/json","building-slug":null!=i?i:"","org-slug":null!=n?n:"","log-type":null!=e?e:ln.error,"log-title":r.toUpperCase().replace(/\s/g,"_")}})};function dn(){return cn()?function(){const e=window.location.search,t={};return e.split("?").slice(1).join("&").split("&").forEach((e=>{const[i,n]=e.split("=");i&&n&&(t[decodeURIComponent(i)]=decodeURIComponent(n))})),t}():function(){const e=new URLSearchParams(window.location.search),t=e.has("utm_content"),i=e.has("utm_source");if(t&&!i){const t=e.get("utm_content");e.delete("utm_content"),e.set("utm_source",t)}return Object.fromEntries(e)}()}const cn=()=>(window.location.search.match(/\?/g)||[]).length>1;var pn=i(8367),hn=i.n(pn);function fn(e){return"avb"===e?"AVB Company Website":"property-website"}const mn=async(e,i=!1)=>{const n=`https://app.meetelise.com/eliseCrmApi/building/${e}/scheduling_status?observe_dynamic_scheduling=${i}`;try{return(await t().get(n)).data.is_enabled}catch(e){return!1}};var gn=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 vn=class extends re{constructor(){super(...arguments),this.tourTypeOptions=[],this.chatId="",this.buildingId=0,this.buildingSlug="",this.sgtUrl="",this.escortedToursLink="",this.virtualToursLink="",this.orgSlug="",this.hasDynamicSchedulingEnabled=!1,this.leadSourceClient=null,this.buildingName="",this.tourType=null,this.shouldShowTourType={[yn.Guided]:!0,[yn.Self]:!0,[yn.Virtual]:!0},this.email="",this.phoneNumber="",this.availabilitiesGroupedByDay={},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.brandColor=Me,this.backgroundColor=Fe,this.firstNameInputValue="",this.lastNameInputValue="",this.leadSourceInputValue="",this.errorGettingAvailabilities=!1,this.firstUpdated=async()=>{try{const[e,t]=await Promise.all([mn(this.buildingId,this.hasDynamicSchedulingEnabled),ji()]);this.shouldAllowScheduling=e,this.shouldAllowScheduleLoading=!1,un({logTitle:"AVAILABILITIES_EXIST_FOR_TOUR_TYPE",logData:t,logType:ln.info,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});const i=Object.values(t).every((e=>!1===e)),n=!this.sgtUrl&&!this.escortedToursLink&&!this.virtualToursLink;if(i&&n)return this.errorGettingAvailabilities=!0,this.waitingForAvailabilities=!1,void un({logTitle:"NO_AVAILABILITIES_EXIST",logData:null,logType:ln.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});if(this.shouldShowTourType={[yn.Guided]:this.tourTypeOptions.map((e=>e.value)).includes("WITH_AGENT")&&(t[yn.Guided]||!!this.escortedToursLink),[yn.Self]:this.tourTypeOptions.map((e=>e.value)).includes("SELF_GUIDED")&&(t[yn.Self]||!!this.sgtUrl),[yn.Virtual]:this.tourTypeOptions.map((e=>e.value)).includes("VIRTUAL_SHOWING")&&(t[yn.Virtual]||!!this.virtualToursLink)},1===Object.values(this.shouldShowTourType).reduce(((e,t)=>!0===t?e+1:e),0)&&(this.tourType=Object.keys(this.shouldShowTourType).find((e=>this.shouldShowTourType[e]))),null===this.tourType)return void(this.waitingForAvailabilities=!1);this.availabilitiesGroupedByDay=await Hi(bn[this.tourType]),this.waitingForAvailabilities=!1}catch(e){this.errorGettingAvailabilities=!0,this.waitingForAvailabilities=!1,un({logTitle:"ERROR_LOADING_AVAILABILITIES",logData:{error:e},logType:ln.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this.willUpdate=async e=>{e.has("tourType")&&this.tourType&&(this.availabilitiesGroupedByDay=await Hi(bn[this.tourType]))},this.handlePhoneKeydown=e=>{var t;if(!(e instanceof KeyboardEvent&&e.target instanceof HTMLInputElement&&null!==e.target.selectionStart))return;const i=e.target.selectionStart;if(1!==e.key.length||Re(e)){if("Backspace"===e.key){if(Re(e))return;if(this.phoneInput.selectionEnd&&this.phoneInput.selectionStart&&this.phoneInput.selectionEnd-this.phoneInput.selectionStart>0)return;const t=this.phoneNumber.length,n=this.phoneNumber.slice(0,i).replace(/\D/g,""),r=this.phoneNumber.slice(i).replace(/\D/g,""),o=`${n.slice(0,-1)}${r}`;this.phoneNumber=Ie(o),this.phoneInput.value=this.phoneNumber;const a=i-(t-this.phoneNumber.length);return this.phoneInput.setSelectionRange(a,a),e.preventDefault(),void e.stopPropagation()}if(!["ArrowLeft","ArrowRight"].includes(e.key)||Re(e)||e.shiftKey)return;if("ArrowLeft"===e.key){const e=((null===(t=this.phoneNumber.slice(0,i).split(/\d+/).at(-1))||void 0===t?void 0:t.length)||0)+1,n=i-e>-1?i-e:0;this.phoneInput.setSelectionRange(n,n)}if("ArrowRight"===e.key){const e=(this.phoneNumber.slice(i).split(/\d+/)[0].length||0)+1,t=i+e<this.phoneNumber.length?i+e:this.phoneNumber.length;this.phoneInput.setSelectionRange(t,t)}e.preventDefault(),e.stopPropagation()}else{e.preventDefault(),e.stopPropagation();const t=this.phoneNumber.slice(0,i)+e.key+this.phoneNumber.slice(i);this.phoneNumber=Ie(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 i=this.phoneInput.selectionStart,n=i?this.phoneInput.value.slice(i).replace(/\D/g,""):"";this.phoneNumber=Ie(this.phoneInput.value);let r=0,o=n.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,i;return(!!(null===(e=this.firstNameInput)||void 0===e?void 0:e.value)||!!(null===(t=this.lastNameInput)||void 0===t?void 0:t.value))&&(null===(i=this.emailInput)||void 0===i?void 0:i.value.includes("@"))&&!!this.phoneNumber&&14===this.phoneNumber.length&&fi(this.phoneNumber)}},this.formIsValidForSubmission=()=>this.validators.tourType()&&this.validators.dateAndTime()&&this.validators.leadInfo(),this.timeStringToHoursAndMinutes=e=>{const[t,i]=e.split(/\D/g);return[parseInt(t)+(e.toLowerCase().includes("pm")?12:0),parseInt(i)]},this.submit=async()=>{var e,i,n,r,o,a,s,l,u,d,c,p,h,f,m,g;if(!this.selectedDate||!this.selectedTime||null===this.tourType)return;const v=new URLSearchParams(window.location.search),y=this.selectedLeadSource&&this.selectedLeadSource.value?this.selectedLeadSource.value:null!==(e=this.leadSourceInputValue)&&void 0!==e?e:this.currentLeadSource,b=[...new Set(y?[y,"property-website"]:["property-website"])];this.firstNameInput&&(this.firstNameInputValue=this.firstNameInput.value),this.lastNameInput&&(this.lastNameInputValue=this.lastNameInput.value),this.leadSourceInputValue=y,en("scheduleTourSubmitted",{email:this.email,phone:`+1${null===(i=this.phoneNumber.match(/\d/g))||void 0===i?void 0:i.join("")}`,firstName:null!==(r=null===(n=this.firstNameInput)||void 0===n?void 0:n.value)&&void 0!==r?r:this.firstNameInputValue,lastName:null!==(a=null===(o=this.lastNameInput)||void 0===o?void 0:o.value)&&void 0!==a?a:this.lastNameInputValue,tourType:wn[this.tourType],tourTime:`${this.selectedTime.datetime}${this.selectedTime.offset}`,originatingSource:b.find((e=>"property-website"!==e))||null});const w={referrer:document.referrer,email_address:this.email,phone_number:`+1${null===(s=this.phoneNumber.match(/\d/g))||void 0===s?void 0:s.join("")}`,building_id:this.buildingId,first_name:null!==(u=null===(l=this.firstNameInput)||void 0===l?void 0:l.value)&&void 0!==u?u:this.firstNameInputValue,last_name:null!==(c=null===(d=this.lastNameInput)||void 0===d?void 0:d.value)&&void 0!==c?c:this.lastNameInputValue,tour_type:wn[this.tourType],tour_time:`${this.selectedTime.datetime}${this.selectedTime.offset}`,cancel_existing_tours:this.promptForReschedule,lead_sources:[...new Set(y?[y,fn(this.orgSlug)]:[fn(this.orgSlug)])],query_params:Object.fromEntries(v.entries()),conversation_tracking_id:null===(p=this.leadSourceClient)||void 0===p?void 0:p.chatId};this.isSubmitting=!0;try{await t().post("https://app.meetelise.com/platformApi/state/create/v2/scheduleMe",w,{headers:{"building-slug":this.buildingSlug,"X-SecurityKey":"JRL8jV4VcSCwOSir5gWkpgNLfKghmhBG","org-slug":this.orgSlug}}),null===(h=this.leadSourceClient)||void 0===h||h.checkAndHandleForLogLeadSource({webchatAction:"tour-scheduler",stateId:null}),this.isSubmitting=!1,this.tourIsBooked=!0}catch(e){const t=e,i=(null===(m=null===(f=t.response)||void 0===f?void 0:f.data)||void 0===m?void 0:m.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[jt(this.selectedDate,"yyyy-MM-dd")];e&&(this.availabilitiesGroupedByDay[jt(this.selectedDate,"yyyy-MM-dd")]=e.filter((e=>e!==this.selectedTime)))}}else if(409===(null===(g=t.response)||void 0===g?void 0:g.status)&&!this.promptForReschedule)return this.promptForReschedule=!0,this.isSubmitting=!1,void(this.tourIsBooked=!1);alert(i),this.isSubmitting=!1,this.tourIsBooked=!1}},this.mobilePages=[{validate:this.validators.tourType,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>U`${this.tourTypeMenu()}`},{validate:this.validators.dateAndTime,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>U`${this.dateAndTimeMenu()}`},{validate:()=>this.validators.leadInfo(),nextButtonText:null,renderNextButton:()=>U` <action-confirm-button
948
+ `;class an{constructor(e,t,i,n){this.org=e,this.building=t,this.chatId=i,this.incomingProcessedLeadSource=n,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:sn(),incomingProcessedLeadSource:this.incomingProcessedLeadSource,webchatVersion:null!==(t="MISSING_ENV_VAR".npm_package_version)&&void 0!==t?t:"1.20.155"})})}}const sn=()=>{var e,t,i,n,r,o;try{const n=new URL(window.location.href).searchParams,r=null!==(i=null===(t=null===(e=window.RCTPCampaign)||void 0===e?void 0:e.CampaignDetails)||void 0===t?void 0:t.Source)&&void 0!==i?i:null,o=n.get("switch_cls[id]"),a=n.get("ilm");return{entrataCampaignSource:o,realpageCampaignSource:a,utmCampaignSource:n.get("utm_source"),yardiCampaignSource:r,bozzutoAdSource:hi("bozzuto_ad_source")}}catch(e){console.warn(`Couldnt get campaign sources from url, error: ${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 i=t.contentWindow.URL;if(!i)return{entrataCampaignSource:null,realpageCampaignSource:null,utmCampaignSource:null,yardiCampaignSource:null,bozzutoAdSource:null};const a=new i(window.location.href).searchParams,s=null!==(o=null===(r=null===(n=window.RCTPCampaign)||void 0===n?void 0:n.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:hi("bozzuto_ad_source")}}};var ln;!function(e){e.error="error",e.info="info",e.warn="warn"}(ln||(ln={}));const un=async({logType:e,buildingSlug:i,orgSlug:n,logTitle:r,logData:o})=>{await t().post("https://app.meetelise.com/platformApi/webchat/logging",{...o},{headers:{"Content-Type":"application/json","building-slug":null!=i?i:"","org-slug":null!=n?n:"","log-type":null!=e?e:ln.error,"log-title":r.toUpperCase().replace(/\s/g,"_")}})};function dn(){return cn()?function(){const e=window.location.search,t={};return e.split("?").slice(1).join("&").split("&").forEach((e=>{const[i,n]=e.split("=");i&&n&&(t[decodeURIComponent(i)]=decodeURIComponent(n))})),t}():function(){const e=new URLSearchParams(window.location.search),t=e.has("utm_content"),i=e.has("utm_source");if(t&&!i){const t=e.get("utm_content");e.delete("utm_content"),e.set("utm_source",t)}return Object.fromEntries(e)}()}const cn=()=>(window.location.search.match(/\?/g)||[]).length>1;var pn=i(8367),hn=i.n(pn);function fn(e){return"avb"===e?"AVB Company Website":"property-website"}const mn=async(e,i=!1)=>{const n=`https://app.meetelise.com/eliseCrmApi/building/${e}/scheduling_status?observe_dynamic_scheduling=${i}`;try{return(await t().get(n)).data.is_enabled}catch(e){return!1}};var gn=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 vn=class extends re{constructor(){super(...arguments),this.tourTypeOptions=[],this.chatId="",this.buildingId=0,this.buildingSlug="",this.sgtUrl="",this.escortedToursLink="",this.virtualToursLink="",this.orgSlug="",this.hasDynamicSchedulingEnabled=!1,this.leadSourceClient=null,this.buildingName="",this.tourType=null,this.shouldShowTourType={[yn.Guided]:!0,[yn.Self]:!0,[yn.Virtual]:!0},this.email="",this.phoneNumber="",this.availabilitiesGroupedByDay={},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.brandColor=Me,this.backgroundColor=Fe,this.firstNameInputValue="",this.lastNameInputValue="",this.leadSourceInputValue="",this.errorGettingAvailabilities=!1,this.firstUpdated=async()=>{try{const[e,t]=await Promise.all([mn(this.buildingId,this.hasDynamicSchedulingEnabled),ji()]);this.shouldAllowScheduling=e,this.shouldAllowScheduleLoading=!1,un({logTitle:"AVAILABILITIES_EXIST_FOR_TOUR_TYPE",logData:t,logType:ln.info,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});const i=Object.values(t).every((e=>!1===e)),n=!this.sgtUrl&&!this.escortedToursLink&&!this.virtualToursLink;if(i&&n)return this.errorGettingAvailabilities=!0,this.waitingForAvailabilities=!1,void un({logTitle:"NO_AVAILABILITIES_EXIST",logData:null,logType:ln.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});if(this.shouldShowTourType={[yn.Guided]:this.tourTypeOptions.map((e=>e.value)).includes("WITH_AGENT")&&(t[yn.Guided]||!!this.escortedToursLink),[yn.Self]:this.tourTypeOptions.map((e=>e.value)).includes("SELF_GUIDED")&&(t[yn.Self]||!!this.sgtUrl),[yn.Virtual]:this.tourTypeOptions.map((e=>e.value)).includes("VIRTUAL_SHOWING")&&(t[yn.Virtual]||!!this.virtualToursLink)},1===Object.values(this.shouldShowTourType).reduce(((e,t)=>!0===t?e+1:e),0)&&(this.tourType=Object.keys(this.shouldShowTourType).find((e=>this.shouldShowTourType[e]))),null===this.tourType)return void(this.waitingForAvailabilities=!1);this.availabilitiesGroupedByDay=await Hi(bn[this.tourType]),this.waitingForAvailabilities=!1}catch(e){this.errorGettingAvailabilities=!0,this.waitingForAvailabilities=!1,un({logTitle:"ERROR_LOADING_AVAILABILITIES",logData:{error:e},logType:ln.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this.willUpdate=async e=>{e.has("tourType")&&this.tourType&&(this.availabilitiesGroupedByDay=await Hi(bn[this.tourType]))},this.handlePhoneKeydown=e=>{var t;if(!(e instanceof KeyboardEvent&&e.target instanceof HTMLInputElement&&null!==e.target.selectionStart))return;const i=e.target.selectionStart;if(1!==e.key.length||Re(e)){if("Backspace"===e.key){if(Re(e))return;if(this.phoneInput.selectionEnd&&this.phoneInput.selectionStart&&this.phoneInput.selectionEnd-this.phoneInput.selectionStart>0)return;const t=this.phoneNumber.length,n=this.phoneNumber.slice(0,i).replace(/\D/g,""),r=this.phoneNumber.slice(i).replace(/\D/g,""),o=`${n.slice(0,-1)}${r}`;this.phoneNumber=Ie(o),this.phoneInput.value=this.phoneNumber;const a=i-(t-this.phoneNumber.length);return this.phoneInput.setSelectionRange(a,a),e.preventDefault(),void e.stopPropagation()}if(!["ArrowLeft","ArrowRight"].includes(e.key)||Re(e)||e.shiftKey)return;if("ArrowLeft"===e.key){const e=((null===(t=this.phoneNumber.slice(0,i).split(/\d+/).at(-1))||void 0===t?void 0:t.length)||0)+1,n=i-e>-1?i-e:0;this.phoneInput.setSelectionRange(n,n)}if("ArrowRight"===e.key){const e=(this.phoneNumber.slice(i).split(/\d+/)[0].length||0)+1,t=i+e<this.phoneNumber.length?i+e:this.phoneNumber.length;this.phoneInput.setSelectionRange(t,t)}e.preventDefault(),e.stopPropagation()}else{e.preventDefault(),e.stopPropagation();const t=this.phoneNumber.slice(0,i)+e.key+this.phoneNumber.slice(i);this.phoneNumber=Ie(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 i=this.phoneInput.selectionStart,n=i?this.phoneInput.value.slice(i).replace(/\D/g,""):"";this.phoneNumber=Ie(this.phoneInput.value);let r=0,o=n.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,i;return(!!(null===(e=this.firstNameInput)||void 0===e?void 0:e.value)||!!(null===(t=this.lastNameInput)||void 0===t?void 0:t.value))&&(null===(i=this.emailInput)||void 0===i?void 0:i.value.includes("@"))&&!!this.phoneNumber&&14===this.phoneNumber.length&&fi(this.phoneNumber)}},this.formIsValidForSubmission=()=>this.validators.tourType()&&this.validators.dateAndTime()&&this.validators.leadInfo(),this.timeStringToHoursAndMinutes=e=>{const[t,i]=e.split(/\D/g);return[parseInt(t)+(e.toLowerCase().includes("pm")?12:0),parseInt(i)]},this.submit=async()=>{var e,i,n,r,o,a,s,l,u,d,c,p,h,f,m;if(!this.selectedDate||!this.selectedTime||null===this.tourType)return;const g=new URLSearchParams(window.location.search);let v=null;v=this.selectedLeadSource&&this.selectedLeadSource.value&&this.selectedLeadSource.value.length>0?this.selectedLeadSource.value:this.leadSourceInputValue&&this.leadSourceInputValue.length>0?this.leadSourceInputValue:this.currentLeadSource;const y=[...new Set(v?[v,"property-website"]:["property-website"])];this.firstNameInput&&(this.firstNameInputValue=this.firstNameInput.value),this.lastNameInput&&(this.lastNameInputValue=this.lastNameInput.value),this.leadSourceInputValue=v,en("scheduleTourSubmitted",{email:this.email,phone:`+1${null===(e=this.phoneNumber.match(/\d/g))||void 0===e?void 0:e.join("")}`,firstName:null!==(n=null===(i=this.firstNameInput)||void 0===i?void 0:i.value)&&void 0!==n?n:this.firstNameInputValue,lastName:null!==(o=null===(r=this.lastNameInput)||void 0===r?void 0:r.value)&&void 0!==o?o:this.lastNameInputValue,tourType:wn[this.tourType],tourTime:`${this.selectedTime.datetime}${this.selectedTime.offset}`,originatingSource:y.find((e=>"property-website"!==e))||null});const b={referrer:document.referrer,email_address:this.email,phone_number:`+1${null===(a=this.phoneNumber.match(/\d/g))||void 0===a?void 0:a.join("")}`,building_id:this.buildingId,first_name:null!==(l=null===(s=this.firstNameInput)||void 0===s?void 0:s.value)&&void 0!==l?l:this.firstNameInputValue,last_name:null!==(d=null===(u=this.lastNameInput)||void 0===u?void 0:u.value)&&void 0!==d?d:this.lastNameInputValue,tour_type:wn[this.tourType],tour_time:`${this.selectedTime.datetime}${this.selectedTime.offset}`,cancel_existing_tours:this.promptForReschedule,lead_sources:[...new Set(v?[v,fn(this.orgSlug)]:[fn(this.orgSlug)])],query_params:Object.fromEntries(g.entries()),conversation_tracking_id:null===(c=this.leadSourceClient)||void 0===c?void 0:c.chatId};this.isSubmitting=!0;try{await t().post("https://app.meetelise.com/platformApi/state/create/v2/scheduleMe",b,{headers:{"building-slug":this.buildingSlug,"X-SecurityKey":"JRL8jV4VcSCwOSir5gWkpgNLfKghmhBG","org-slug":this.orgSlug}}),null===(p=this.leadSourceClient)||void 0===p||p.checkAndHandleForLogLeadSource({webchatAction:"tour-scheduler",stateId:null}),this.isSubmitting=!1,this.tourIsBooked=!0}catch(e){const t=e,i=(null===(f=null===(h=t.response)||void 0===h?void 0:h.data)||void 0===f?void 0:f.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[jt(this.selectedDate,"yyyy-MM-dd")];e&&(this.availabilitiesGroupedByDay[jt(this.selectedDate,"yyyy-MM-dd")]=e.filter((e=>e!==this.selectedTime)))}}else if(409===(null===(m=t.response)||void 0===m?void 0:m.status)&&!this.promptForReschedule)return this.promptForReschedule=!0,this.isSubmitting=!1,void(this.tourIsBooked=!1);alert(i),this.isSubmitting=!1,this.tourIsBooked=!1}},this.mobilePages=[{validate:this.validators.tourType,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>U`${this.tourTypeMenu()}`},{validate:this.validators.dateAndTime,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>U`${this.dateAndTimeMenu()}`},{validate:()=>this.validators.leadInfo(),nextButtonText:null,renderNextButton:()=>U` <action-confirm-button
949
949
  id="schedule-bttn"
950
950
  .onClick=${this.submit}
951
951
  .isLoading=${this.isSubmitting}
@@ -3167,7 +3167,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
3167
3167
  <div class="chevron-right">${Qn}</div>
3168
3168
  </div>
3169
3169
  `:""}
3170
- </div>`}render(){return window.customElements.get("email-us-window")||window.customElements.define("email-us-window",Dn),window.customElements.get("call-us-window")||window.customElements.define("call-us-window",nr),(this.hasSSTEnabledDesktop||this.hasSSTEnabledMobile)&&(window.eliseAi.onOpenSST=e=>{this.isSSTWindowOpen=!0,this.isCallUsWindowOpen=!1,this.isEmailWindowOpen=!1,this.onExitChat(),e&&e()}),(this.hasChatEnabledDesktop||this.hasChatEnabledMobile)&&(window.eliseAi.onOpenChat=e=>{this.onChatTapped(),this.isSSTWindowOpen=!1,this.isCallUsWindowOpen=!1,this.isEmailWindowOpen=!1,e&&e()}),(this.hasCallUsEnabledDesktop||this.hasCallUsEnabledMobile)&&(window.eliseAi.onOpenCallUsWindow=e=>{this.isCallUsWindowOpen=!0,this.isSSTWindowOpen=!1,this.isEmailWindowOpen=!1,this.onExitChat(),e&&e()}),(this.hasEmailEnabledDesktop||this.hasEmailEnabledMobile)&&(window.eliseAi.onOpenEmailUsWindow=e=>{this.isEmailWindowOpen=!0,this.isSSTWindowOpen=!1,this.isCallUsWindowOpen=!1,this.onExitChat(),e&&e()}),U`
3170
+ </div>`}render(){return window.customElements.get("email-us-window")||window.customElements.define("email-us-window",Dn),window.customElements.get("call-us-window")||window.customElements.define("call-us-window",nr),window.eliseAi.onOpenSST=e=>{this.isSSTWindowOpen=!0,this.isCallUsWindowOpen=!1,this.isEmailWindowOpen=!1,this.onExitChat(),e&&e()},(this.hasChatEnabledDesktop||this.hasChatEnabledMobile)&&(window.eliseAi.onOpenChat=e=>{this.onChatTapped(),this.isSSTWindowOpen=!1,this.isCallUsWindowOpen=!1,this.isEmailWindowOpen=!1,e&&e()}),(this.hasCallUsEnabledDesktop||this.hasCallUsEnabledMobile)&&(window.eliseAi.onOpenCallUsWindow=e=>{this.isCallUsWindowOpen=!0,this.isSSTWindowOpen=!1,this.isEmailWindowOpen=!1,this.onExitChat(),e&&e()}),(this.hasEmailEnabledDesktop||this.hasEmailEnabledMobile)&&(window.eliseAi.onOpenEmailUsWindow=e=>{this.isEmailWindowOpen=!0,this.isSSTWindowOpen=!1,this.isCallUsWindowOpen=!1,this.onExitChat(),e&&e()}),U`
3171
3171
  <div
3172
3172
  class=${Qi()({"launcher__mobile-launcher-wrapper":ci()||this.isMinimized,"launcher__mini-launcher-wrapper":!ci()&&!this.isMinimized,"launcher__mini-elevated":"livcor"===this.orgSlug.toLowerCase()&&(ci()||this.isMinimized)})}
3173
3173
  style=${Pe({...this.launcherStyles,...this.mobileStyles,top:ci()||void 0===this.top||isNaN(this.top)?void 0!==this.mobileStyles.top?`${this.mobileStyles.top}px`:void 0:this.top-700+"px",bottom:ci()||void 0===this.bottom||isNaN(this.bottom)?void 0!==this.mobileStyles.bottom?`${this.mobileStyles.bottom}px`:"72px":`${this.bottom}px`,left:ci()||void 0===this.left||isNaN(this.left)?void 0!==this.mobileStyles.left?`${this.mobileStyles.left}px`:void 0:`${this.left}px`,right:ci()||void 0===this.right||isNaN(this.right)?void 0!==this.mobileStyles.right?`${this.mobileStyles.right}px`:"18px":`${this.right}px`})}
@@ -454,10 +454,21 @@ export class TourScheduler extends LitElement {
454
454
  }
455
455
  const queryParams = new URLSearchParams(window.location.search);
456
456
 
457
- const parsedLeadSource =
458
- this.selectedLeadSource && this.selectedLeadSource.value
459
- ? this.selectedLeadSource.value
460
- : this.leadSourceInputValue ?? this.currentLeadSource;
457
+ let parsedLeadSource = null;
458
+ if (
459
+ this.selectedLeadSource &&
460
+ this.selectedLeadSource.value &&
461
+ this.selectedLeadSource.value.length > 0
462
+ ) {
463
+ parsedLeadSource = this.selectedLeadSource.value;
464
+ } else if (
465
+ this.leadSourceInputValue &&
466
+ this.leadSourceInputValue.length > 0
467
+ ) {
468
+ parsedLeadSource = this.leadSourceInputValue;
469
+ } else {
470
+ parsedLeadSource = this.currentLeadSource;
471
+ }
461
472
 
462
473
  const leadSources = [
463
474
  ...new Set(
@@ -503,6 +514,7 @@ export class TourScheduler extends LitElement {
503
514
  query_params: Object.fromEntries(queryParams.entries()),
504
515
  conversation_tracking_id: this.leadSourceClient?.chatId,
505
516
  };
517
+
506
518
  const url = `https://app.meetelise.com/platformApi/state/create/v2/scheduleMe`;
507
519
  this.isSubmitting = true;
508
520
  try {
@@ -775,18 +775,17 @@ export class Launcher extends LitElement {
775
775
  installEmailUsWindow();
776
776
  installCallUsWindow();
777
777
 
778
- if (this.hasSSTEnabledDesktop || this.hasSSTEnabledMobile) {
779
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
780
- (window as any).eliseAi.onOpenSST = (callBack?: () => void) => {
781
- this.isSSTWindowOpen = true;
782
- this.isCallUsWindowOpen = false;
783
- this.isEmailWindowOpen = false;
784
- this.onExitChat();
785
- if (callBack) {
786
- callBack();
787
- }
788
- };
789
- }
778
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
779
+ (window as any).eliseAi.onOpenSST = (callBack?: () => void) => {
780
+ this.isSSTWindowOpen = true;
781
+ this.isCallUsWindowOpen = false;
782
+ this.isEmailWindowOpen = false;
783
+ this.onExitChat();
784
+ if (callBack) {
785
+ callBack();
786
+ }
787
+ };
788
+
790
789
  if (this.hasChatEnabledDesktop || this.hasChatEnabledMobile) {
791
790
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
792
791
  (window as any).eliseAi.onOpenChat = (callBack?: () => void) => {