@meetelise/chat 1.22.55 → 1.22.56

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.55",
3
+ "version": "1.22.56",
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 sn{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:ln(),incomingProcessedLeadSource:this.incomingProcessedLeadSource,webchatVersion:null!==(t="MISSING_ENV_VAR".npm_package_version)&&void 0!==t?t:"1.20.155"})})}}const ln=()=>{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 un;!function(e){e.error="error",e.info="info",e.warn="warn"}(un||(un={}));const dn=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:un.error,"log-title":r.toUpperCase().replace(/\s/g,"_")}})},cn=async({params:e,isSampled:i})=>{try{if(i&&Math.random()<=.05)return;await t().post("https://app.meetelise.com/platformApi/webchat/log/signal",{...e,website_origin:window.location.origin,website_search:window.location.search})}catch(e){console.warn(e)}};function pn(){return hn()?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 hn=()=>(window.location.search.match(/\?/g)||[]).length>1;var fn=i(8367),mn=i.n(fn);function gn(e){return"avb"===e?"AVB Company Website":"property-website"}const vn=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 yn=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 bn=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={[wn.Guided]:!0,[wn.Self]:!0,[wn.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([vn(this.buildingId,this.hasDynamicSchedulingEnabled),ji()]);this.shouldAllowScheduling=e,this.shouldAllowScheduleLoading=!1,dn({logTitle:"AVAILABILITIES_EXIST_FOR_TOUR_TYPE",logData:t,logType:un.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 dn({logTitle:"NO_AVAILABILITIES_EXIST",logData:null,logType:un.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});if(this.shouldShowTourType={[wn.Guided]:this.tourTypeOptions.map((e=>e.value)).includes("WITH_AGENT")&&(t[wn.Guided]||!!this.escortedToursLink),[wn.Self]:this.tourTypeOptions.map((e=>e.value)).includes("SELF_GUIDED")&&(t[wn.Self]||!!this.sgtUrl),[wn.Virtual]:this.tourTypeOptions.map((e=>e.value)).includes("VIRTUAL_SHOWING")&&(t[wn.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(Sn[this.tourType]),this.waitingForAvailabilities=!1}catch(e){this.errorGettingAvailabilities=!0,this.waitingForAvailabilities=!1,dn({logTitle:"ERROR_LOADING_AVAILABILITIES",logData:{error:e},logType:un.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this.willUpdate=async e=>{e.has("tourType")&&this.tourType&&(this.availabilitiesGroupedByDay=await Hi(Sn[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,tn("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:Tn[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:Tn[this.tourType],tour_time:`${this.selectedTime.datetime}${this.selectedTime.offset}`,cancel_existing_tours:this.promptForReschedule,lead_sources:[...new Set(v?[v,gn(this.orgSlug)]:[gn(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
948
+ `;class sn{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:ln(),incomingProcessedLeadSource:this.incomingProcessedLeadSource,webchatVersion:null!==(t="MISSING_ENV_VAR".npm_package_version)&&void 0!==t?t:"1.20.155"})})}}const ln=()=>{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 un;!function(e){e.error="error",e.info="info",e.warn="warn"}(un||(un={}));const dn=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:un.error,"log-title":r.toUpperCase().replace(/\s/g,"_")}})},cn=async({params:e,sampleRate:i})=>{try{if(Math.random()>=i)return;await t().post("https://app.meetelise.com/platformApi/webchat/log/signal",{...e,website_origin:window.location.origin,website_search:window.location.search})}catch(e){console.warn(e)}};function pn(){return hn()?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 hn=()=>(window.location.search.match(/\?/g)||[]).length>1;var fn=i(8367),mn=i.n(fn);function gn(e){return"avb"===e?"AVB Company Website":"property-website"}const vn=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 yn=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 bn=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={[wn.Guided]:!0,[wn.Self]:!0,[wn.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([vn(this.buildingId,this.hasDynamicSchedulingEnabled),ji()]);this.shouldAllowScheduling=e,this.shouldAllowScheduleLoading=!1,dn({logTitle:"AVAILABILITIES_EXIST_FOR_TOUR_TYPE",logData:t,logType:un.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 dn({logTitle:"NO_AVAILABILITIES_EXIST",logData:null,logType:un.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});if(this.shouldShowTourType={[wn.Guided]:this.tourTypeOptions.map((e=>e.value)).includes("WITH_AGENT")&&(t[wn.Guided]||!!this.escortedToursLink),[wn.Self]:this.tourTypeOptions.map((e=>e.value)).includes("SELF_GUIDED")&&(t[wn.Self]||!!this.sgtUrl),[wn.Virtual]:this.tourTypeOptions.map((e=>e.value)).includes("VIRTUAL_SHOWING")&&(t[wn.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(Sn[this.tourType]),this.waitingForAvailabilities=!1}catch(e){this.errorGettingAvailabilities=!0,this.waitingForAvailabilities=!1,dn({logTitle:"ERROR_LOADING_AVAILABILITIES",logData:{error:e},logType:un.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this.willUpdate=async e=>{e.has("tourType")&&this.tourType&&(this.availabilitiesGroupedByDay=await Hi(Sn[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,tn("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:Tn[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:Tn[this.tourType],tour_time:`${this.selectedTime.datetime}${this.selectedTime.offset}`,cancel_existing_tours:this.promptForReschedule,lead_sources:[...new Set(v?[v,gn(this.orgSlug)]:[gn(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}
@@ -4499,7 +4499,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
4499
4499
  I agree
4500
4500
  </button>
4501
4501
  </div>
4502
- `;var Ao=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 Co=class extends re{constructor(){super(...arguments),this.buildingSlug="",this.orgSlug="",this.launcherStyles={},this.mobileStyles={},this.isMinimized=!1,this.brandColor=null,this.backgroundColor=null,this.chatId="",this.analytics=null,this.launcher=null,this.building=null,this.designConcept=null,this.leadSources=null,this.currentLeadSource=null,this.featureFlagShowDropdown=Xi.always,this.phoneNumberForSource=null,this.hasMounted=!1,this.hideLauncher=!1,this.isLoading=!0,this.showTourNextToChat=!1,this.displayPubnubChat=!1,this.myPubnub=null,this.LeadSourceClient=null,this.right=void 0,this.bottom=void 0,this.top=void 0,this.left=void 0,this.overrideRentgrata=!1,this.widgetType=Lo.Default,this.onWidgetLoaded=hr(),this.onSstClose=hr(),this.enabledChatWidgets={callDesktop:!0,callMobile:!0,chatMobile:!0,chatDesktop:!0,emailDesktop:!0,emailMobile:!0,textDesktop:!0,textMobile:!0,sstDesktop:!0,sstMobile:!0},this.webchatConfigHasAutoOpenChat=!1,this.requiresConsent=!1,this.hideMobileFeatures=!1,this.privacyPolicyUrl="http://bit.ly/me_privacy_policy",this.launcherRef=xe(),this.firstUpdated=async()=>this.setupWebchat(),this.shouldShowWebchat=async(e,i)=>{if(!e)return console.warn("MeetElise Chat will NOT appear. Building does NOT exist."),cn({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!1,extra_data:{webchat_no_show_reason:"building_does_not_exist"}},isSampled:!0}),!1;if(!e.launchedDateTime)return console.warn("MeetElise Chat will NOT appear. Building is NOT launched (based on launched date time)."),cn({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!1,extra_data:{webchat_no_show_reason:"building_not_launched"}},isSampled:!0}),!1;if(!e.active)return console.warn("MeetElise Chat will NOT appear. Building is NOT active."),cn({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!1,extra_data:{webchat_no_show_reason:"building_not_active"}},isSampled:!0}),!1;if(!e.webchatScopeConfigured)return console.warn("MeetElise Chat will NOT appear. Building is NOT webchat scope configured."),cn({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!1,extra_data:{webchat_no_show_reason:"building_not_webchat_scope_configured"}},isSampled:!0}),!1;const n=await async function(e){if(!e)return!1;try{return(await t().get(Ki(e),{params:{building_slug:e,flag_type:"bool",feature_flag:"webchat-leasing-in-maintenance-mode",default_str:null,default_bool:!1}})).data}catch(e){return!1}}(i);return!n||(console.warn("MeetElise Chat will NOT appear. Chat is in maintenance mode."),cn({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!1,extra_data:{webchat_no_show_reason:"building_in_maintenance_mode"}},isSampled:!0}),!1)},this.setupWebchat=async()=>{if(!this.buildingSlug||!this.orgSlug)return;const e=await xn(this.orgSlug,this.buildingSlug);if(Math.random()<.2)try{(async(e,i)=>{const n=window.rentgrata;if(!n)return;const r=n.Widget;if(!r)return;const o=r.config;if(!o)return;const a=o.widgetKey;a&&await t().post(`https://app.meetelise.com/platformApi/webchat/rentgrata?token=${a}`,{},{headers:{"Content-Type":"application/json","building-slug":null!=e?e:"","org-slug":null!=i?i:""}})})(this.buildingSlug,this.orgSlug)}catch(e){console.warn("Error updating rentgrata token",e)}await this.shouldShowWebchat(e,this.buildingSlug)&&(cn({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!0},isSampled:!0}),this.building=e,await this.initializeChatVariables(),await this.handleChatInitializeAnalytics(),await this.setBuildingDerivedInfo(),this.attachOnClickToLauncher(),this.shouldAutoOpenChat(this.webchatConfigHasAutoOpenChat)&&(this.displayPubnubChat=!0,this.hideLauncher=!0,this.hasMounted=!0,this.updateAlreadyAutoOpenedTimestamp()),this.isLoading=!1,"true"===localStorage.getItem("isChatOpen")&&(this.hideLauncher=!0,this.displayPubnubChat=!0))},this.setBuildingDerivedInfo=async()=>{var e,i,n,r,o,a,s,l,u,d,c,p,h,f,m,g,v,y,b,w,S,T,x,A,C,O,I,N,E,R,_,P,M,F,D,k,U;const L=this.building;if(!L)return;L&&this.orgSlug&&Io(this.orgSlug,null!==(i=null===(e=this.LeadSourceClient)||void 0===e?void 0:e.chatId)&&void 0!==i?i:null,this.buildingSlug,null!==(r=null===(n=this.LeadSourceClient)||void 0===n?void 0:n.leadSource)&&void 0!==r?r:null);const[B,q,J,j,H,G,z]=await Promise.all([Nn(this.buildingSlug),Pr(this.orgSlug,this.buildingSlug),$i(this.buildingSlug),Yi(this.buildingSlug),In(L.id),Zi(this.buildingSlug),en(this.buildingSlug)]);this.building&&(this.building.phoneNumber=Ne(L.phoneNumber)),this.designConcept=null!==(o=null==B?void 0:B.abTestType)&&void 0!==o?o:"",this.leadSources=q,this.featureFlagShowDropdown=J;const W=L.textWithUsPhoneNumber?L.textWithUsPhoneNumber:await(async e=>{try{const i="https://app.meetelise.com",n=await t().get(`${i}/platformApi/webchat/${e}/phone-number`);if(n.data)return n.data}catch(t){return dn({logType:un.error,buildingSlug:e,logTitle:"[ERROR_GETTING_PHONE_NUMBERS]",logData:{error:t}}),null}return null})(this.buildingSlug);var V,Q;this.enabledChatWidgets={callDesktop:!(null===(a=null==H?void 0:H.config.shouldShowPhone)||void 0===a||!a)||null!==(s=null==H?void 0:H.config.shouldShowPhoneDesktop)&&void 0!==s&&s,callMobile:!(null===(l=null==H?void 0:H.config.shouldShowPhone)||void 0===l||!l)||null!==(u=null==H?void 0:H.config.shouldShowPhoneMobile)&&void 0!==u&&u,chatDesktop:!(null===(d=null==H?void 0:H.config.shouldShowChat)||void 0===d||!d)||null!==(c=null==H?void 0:H.config.shouldShowChatDesktop)&&void 0!==c&&c,chatMobile:!(null===(p=null==H?void 0:H.config.shouldShowChat)||void 0===p||!p)||null!==(h=null==H?void 0:H.config.shouldShowChatMobile)&&void 0!==h&&h,emailDesktop:!(null===(f=null==H?void 0:H.config.shouldShowEmail)||void 0===f||!f)||null!==(m=null==H?void 0:H.config.shouldShowEmailDesktop)&&void 0!==m&&m,emailMobile:!(null===(g=null==H?void 0:H.config.shouldShowEmail)||void 0===g||!g)||null!==(v=null==H?void 0:H.config.shouldShowEmailMobile)&&void 0!==v&&v,textDesktop:(!(null===(y=null==H?void 0:H.config.shouldShowText)||void 0===y||!y)||null!==(b=null==H?void 0:H.config.shouldShowTextDesktop)&&void 0!==b&&b)&&!!W,textMobile:(!(null===(w=null==H?void 0:H.config.shouldShowText)||void 0===w||!w)||null!==(S=null==H?void 0:H.config.shouldShowTextMobile)&&void 0!==S&&S)&&!!W,sstDesktop:!(null===(T=null==H?void 0:H.config.shouldShowSst)||void 0===T||!T)||null!==(x=null==H?void 0:H.config.shouldShowSstDesktop)&&void 0!==x&&x,sstMobile:!(null===(A=null==H?void 0:H.config.shouldShowSst)||void 0===A||!A)||null!==(C=null==H?void 0:H.config.shouldShowSstMobile)&&void 0!==C&&C},this.enabledChatWidgets.sstDesktop||this.enabledChatWidgets.sstMobile||"radco"===this.orgSlug?(Q=this.handleTourClicked,document.querySelectorAll("a").forEach((function(e){const t=e.getAttribute("href");t&&t.startsWith("https://app.meetelise.com/")&&e.addEventListener("click",(e=>{e.preventDefault(),Q(e)}))})),z&&(e=>{document.querySelectorAll('a[href$="schedule-a-tour"]').forEach((t=>{t&&t.addEventListener("click",(t=>{t.preventDefault(),e(t)}))}))})(this.handleTourClicked),"radco"===this.orgSlug&&(e=>{document.querySelectorAll('a[href^="#leaseleads-tour-open"]').forEach((t=>{var i;if(!t)return;const n=document.createElement("a");n.innerHTML=t.innerHTML,n.style.cursor="pointer",n.addEventListener("click",(t=>{t.preventDefault(),e(t)})),null===(i=t.parentNode)||void 0===i||i.replaceChild(n,t)}))})(this.handleTourClicked)):(null===(O=this.LeadSourceClient)||void 0===O?void 0:O.leadSource)&&(V=null!==(N=null===(I=this.LeadSourceClient)||void 0===I?void 0:I.leadSource)&&void 0!==N?N:null,document.querySelectorAll("a").forEach((function(e){const t=e.getAttribute("href");if(t&&t.startsWith("https://app.meetelise.com/")){const i=t.includes("?")?"&":"?";e.setAttribute("href",t+i+`eliseParsedLeadSource=${encodeURIComponent(V)}`)}}))),H&&H.config&&(this.brandColor=null!==(E=H.config.primaryColor)&&void 0!==E?E:null,this.backgroundColor=null!==(R=H.config.backgroundColor)&&void 0!==R?R:null,this.webchatConfigHasAutoOpenChat=H.config.autoOpenChat,this.requiresConsent=H.config.requiresConsent,this.hideMobileFeatures=H.config.hideMobileFeatures,this.privacyPolicyUrl=null!==(_=H.config.privacyPolicyUrl)&&void 0!==_?_:this.privacyPolicyUrl,H.config.displayStyle===Cn.MINIMIZED&&(this.isMinimized=!0),H.config.displayStyle===Cn.PILLS&&(this.designConcept=null),H.config.displayStyle===Cn.EMOJI&&(this.designConcept=Cn.EMOJI),this.onWidgetLoaded()),null===this.brandColor&&(this.brandColor=Me),null===this.backgroundColor&&(this.backgroundColor=Fe);const K=null!==(M=null===(P=this.building)||void 0===P?void 0:P.phoneNumber)&&void 0!==M?M:"";let X=null;if(j&&(X=await async function(e,i){try{const n=await t().get(`https://app.meetelise.com/platformApi/webchat/${e}/phone-number-by-source?source=${i}`);return n.data?{number:Ne(n.data.number),isMatch:n.data.match,isPropertyWebsiteCatchall:n.data.isPropertyWebsiteCatchall}:null}catch(e){return null}}(this.buildingSlug,null!==(D=null===(F=this.LeadSourceClient)||void 0===F?void 0:F.leadSource)&&void 0!==D?D:null),X&&!X.isMatch&&(X.number=K)),G&&(null==X?void 0:X.number)){const e=Zr(X.number,this.orgSlug,this.buildingSlug);e>0&&cn({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_dni_insert_override_success:!0,extra_data:{total_replacements:e}},isSampled:!0})}const $=localStorage.getItem("eliseai_phone_number_devtest");$&&(console.info("Using dev test phone number: ",$),Zr($,this.orgSlug,this.buildingSlug)),this.phoneNumberForSource=X||{number:K,isMatch:!1,isPropertyWebsiteCatchall:!0};const Y=null!==(U=null===(k=this.LeadSourceClient)||void 0===k?void 0:k.leadSource)&&void 0!==U?U:null;Y&&(this.leadSources.includes(Y)||this.leadSources.push(Y)),qi(L.id)},this.initializeChatVariables=async()=>{var e,i,n,r,o,a,s,l;if(!this.building)return;const u=Wr(this.buildingSlug),d=Vr(this.buildingSlug,u)?u:zr(this.buildingSlug,!1);if(!d.leadId)throw new Error("Lead ID is null");this.LeadSourceClient=new class{constructor(){this.chatId=null,this.apiHost="https://app.meetelise.com",this.leadSource=null,this.localStorageTTLDays=30,this.buildingId=null,this.orgSlug=null,this.buildingSlug=null,this.queryParameters=null,this.leadSourceInput=null,this.updateLeadSourceLocalStorage=(e,t,i,n,r)=>{const o=pn();if(this.leadSourceInput={websiteOrigin:window.location.origin,websiteSearch:window.location.search,queryParameters:o,referrer:document.referrer,parsedUtmSource:o?o.utm_source:null,campaignSources:Object.values(ln()).filter((e=>e))},n)return;if(!r){const t=this.getLeadSourceBodyIfValid(e);if(t&&!pi(t.timestamp,24*this.localStorageTTLDays))return{...t,timestamp:Ci(t.timestamp)}}const a={leadSource:t,leadId:i,buildingSlug:e,timestamp:yi(new Date),leadSourceInput:this.leadSourceInput};return localStorage.setItem("com.elise.webchat.leadsource.slug="+e,JSON.stringify(a)),{...a,timestamp:Ci(a.timestamp)}},this.getLeadSourceBodyIfValid=e=>{const t=localStorage.getItem("com.elise.webchat.leadsource.slug="+e);if(t)try{const i=JSON.parse(t);if(i.buildingSlug===e&&i.leadSource&&i.leadId&&i.timestamp&&!pi(Ci(i.timestamp),24*this.localStorageTTLDays)){try{this.leadSourceInput=i.leadSourceInput}catch(e){console.error("Error parsing leadSourceInput from localStorage")}return i}}catch(e){return null}return null}}async fetchCurrentParsedLeadSource({buildingSlug:e,queryParams:i,referrer:n,campaignSources:r}){try{return(await t().post(`${this.apiHost}/platformApi/webchat/current-parsed-lead-source`,{query_params:i,building_slug:e,referrer:n,campaign_sources:r})).data}catch(e){return null}}async checkAndHandleForLogLeadSource({webchatAction:e,stateId:i}){var n,r,o,a,s,l,u;try{if(!this.chatId)return console.error("chatId is not set"),null;if(!this.orgSlug)return console.error("orgId is not set"),null;let d=null,c=null;try{if("f1ba5a20-d207-4e5a-879e-65199e7d0a53"===this.orgSlug){const e=await this.getCookieValue("_ga");e&&(d=e),c=null===(n=window.dataLayer.find((e=>{var t;return"gtagApiGet"==(null===(t=e.value)||void 0===t?void 0:t.event)})))||void 0===n?void 0:n.value}}catch(e){console.error("error getting cookie")}return await t().post(`${this.apiHost}/platformApi/webchat/log/lead-source`,{chat_id:this.chatId,webchat_action:e,state_id:i,building_id:this.buildingId,org_slug:this.orgSlug,building_slug:this.buildingSlug,website_origin:null===(r=this.leadSourceInput)||void 0===r?void 0:r.websiteOrigin,website_search:null===(o=this.leadSourceInput)||void 0===o?void 0:o.websiteSearch,query_parameters:null===(a=this.leadSourceInput)||void 0===a?void 0:a.queryParameters,referrer:null===(s=this.leadSourceInput)||void 0===s?void 0:s.referrer,parsed_utm_source:null===(l=this.leadSourceInput)||void 0===l?void 0:l.parsedUtmSource,campaign_sources:null===(u=this.leadSourceInput)||void 0===u?void 0:u.campaignSources,lead_source_output:this.leadSource,google_analytics_client_id:mn()(d)?null:d,extras:null!=c?c:null}),null}catch(e){return null}}async getCookieValue(e){try{const t=document.cookie.split(";");for(let i=0;i<t.length;i++){const n=t[i].trim();if(n.startsWith(e+"="))return n.substring((e+"=").length,-1===n.indexOf(";")?void 0:n.indexOf(";"))}return null}catch(e){console.error("error getting cookie value")}return null}async generateUserLeadSource({leadId:e,orgSlug:t,buildingSlug:i}){try{const n={queryParams:pn(),buildingSlug:i,referrer:document.referrer,campaignSources:ln()};let r=!1;const o=i?this.getLeadSourceBodyIfValid(i):null;if(o){if(!["test-company","daf00bd2-1ecb-482c-b6f4-e1c5511a01be"].includes(t))return this.leadSource=o.leadSource,this.leadSource;{const e=await this.fetchCurrentParsedLeadSource(n);if(!e)return this.leadSource=o.leadSource,this.leadSource;this.leadSource=e,r=!0}}const a=await this.fetchCurrentParsedLeadSource(n);if(this.leadSource=a,this.buildingId=null,this.orgSlug=t,this.buildingSlug=i,i&&!a){const e=this.getLeadSourceBodyIfValid(i);if(e)return this.leadSource=e.leadSource,this.leadSource}if(i){const t=!!a&&a.length>0;this.updateLeadSourceLocalStorage(i,a,e,!t&&!r,r)}return a}catch(e){console.error(e)}return null}},this.myPubnub=new Yr(this.buildingSlug,this.building,this.orgSlug,null,d.leadId,this.LeadSourceClient,this.widgetType),this.LeadSourceClient.chatId=this.myPubnub.channel,await(null===(e=this.LeadSourceClient)||void 0===e?void 0:e.generateUserLeadSource({leadId:null!==(n=null===(i=this.myPubnub)||void 0===i?void 0:i.leadUserId)&&void 0!==n?n:"",orgSlug:this.orgSlug,buildingSlug:this.buildingSlug})),console.log("EliseAI Mapped Lead Source source: ",null===(r=this.LeadSourceClient)||void 0===r?void 0:r.leadSource),"property-website"!==gn(this.orgSlug)?this.myPubnub.leadSource=null!==(a=null===(o=this.LeadSourceClient)||void 0===o?void 0:o.leadSource)&&void 0!==a?a:gn(this.orgSlug):this.myPubnub.leadSource=null!==(l=null===(s=this.LeadSourceClient)||void 0===s?void 0:s.leadSource)&&void 0!==l?l:null,d.initiatedChat&&await this.myPubnub.initializePubnub(u)},this.shouldAutoOpenChat=e=>{const t=sessionStorage.getItem("alreadyAutoOpenedTimestamp"),i=!t||!(t&&!xi(Ci(t)));return!!e&&!!i&&!ci()},this.updateAlreadyAutoOpenedTimestamp=()=>{sessionStorage.setItem("alreadyAutoOpenedTimestamp",yi(function(e,t){Be(2,arguments);var i=it(t);return nt(e,6e4*i)}(new Date,15)))},this.handleContactClicked=e=>{var t;this.displayPubnubChat=!1,this.hideLauncher=!1,this.showTourNextToChat=!1,null===(t=this.launcherRef.value)||void 0===t||t.onClickEmailOption(e)},this.handleTourClicked=e=>{var t,i;this.showTourNextToChat?null===(t=this.launcherRef.value)||void 0===t||t.onClickSSTOption(e):(this.hideLauncher?this.showTourNextToChat=!0:this.displayPubnubChat=!1,this.hideLauncher=!1,null===(i=this.launcherRef.value)||void 0===i||i.onClickSSTOption(e))},this.handleContactTabClicked=e=>{var t;this.displayPubnubChat=!1,this.showTourNextToChat=!1,this.hideLauncher=!1,null===(t=this.launcherRef.value)||void 0===t||t.onClickPhoneOption(e)},this.adjustPositionChatAdditionalActions=()=>{var e,t,i,n;const r=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("chatAdditionalActionsPubnub");if(!r)return;const o=null===(n=null===(i=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("pubnub-chat"))||void 0===i?void 0:i.shadowRoot)||void 0===n?void 0:n.getElementById("pubnub-chat-container"),a=null==o?void 0:o.getBoundingClientRect();a&&(r.style.left=`${a.left}px`,r.style.top=`${a.bottom}px`)},this.handleKeydownTab=e=>{var t,i,n,r,o,a,s,l,u,d,c,p,h,f,m,g,v,y,b,w;if("Tab"===e.key){const S=this.displayPubnubChat?null===(n=null===(i=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("pubnub-chat"))||void 0===i?void 0:i.shadowRoot)||void 0===n?void 0:n.getElementById("pubnub-chat-container"):null!==(m=null!==(u=null===(l=null===(s=null===(a=null===(o=null===(r=this.shadowRoot)||void 0===r?void 0:r.getElementById("meetelise-launcher"))||void 0===o?void 0:o.shadowRoot)||void 0===a?void 0:a.getElementById("email-us-window"))||void 0===s?void 0:s.shadowRoot)||void 0===l?void 0:l.getElementById("email-us-form"))&&void 0!==u?u:null===(f=null===(h=null===(p=null===(c=null===(d=this.shadowRoot)||void 0===d?void 0:d.getElementById("meetelise-launcher"))||void 0===c?void 0:c.shadowRoot)||void 0===p?void 0:p.getElementById("tour-scheduler-window"))||void 0===h?void 0:h.shadowRoot)||void 0===f?void 0:f.getElementById("scheduler-container"))&&void 0!==m?m:null===(w=null===(b=null===(y=null===(v=null===(g=this.shadowRoot)||void 0===g?void 0:g.getElementById("meetelise-launcher"))||void 0===v?void 0:v.shadowRoot)||void 0===y?void 0:y.getElementById("call-us-window"))||void 0===b?void 0:b.shadowRoot)||void 0===w?void 0:w.getElementById("details-window");if(!S)return;e.preventDefault();const T=S.querySelectorAll("input, me-select, textarea, action-confirm-button, [tabindex]"),x=Array.from(T),A=x.findIndex((e=>e.matches(":focus")));x[(A+1)%x.length].focus()}},this.onClickMinimize=e=>{e.preventDefault(),e.stopPropagation(),this.isMinimized=!this.isMinimized,this.showTourNextToChat=!1},this.attachOnClickToLauncher=()=>{const e=this.launcherRef.value;e&&(e.onChatTapped=async()=>{this.displayPubnubChat=!0,this.hideLauncher=!0,this.hasMounted=!0,localStorage.setItem("isChatOpen","true")},e.onExitChat=this.onExitChat)},this.onExitChat=()=>{this.displayPubnubChat=!1,this.hideLauncher=!1,this.showTourNextToChat=!1,localStorage.setItem("isChatOpen","false")},this.renderChatAdditionalActions=(e,t)=>{const i=this.building&&ke(this.building.orgId,this.building.id)&&this.brandColor&&this.brandColor!==Me?De(this.brandColor,.6):"black";return U` <style>
4502
+ `;var Ao=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 Co=class extends re{constructor(){super(...arguments),this.buildingSlug="",this.orgSlug="",this.launcherStyles={},this.mobileStyles={},this.isMinimized=!1,this.brandColor=null,this.backgroundColor=null,this.chatId="",this.analytics=null,this.launcher=null,this.building=null,this.designConcept=null,this.leadSources=null,this.currentLeadSource=null,this.featureFlagShowDropdown=Xi.always,this.phoneNumberForSource=null,this.hasMounted=!1,this.hideLauncher=!1,this.isLoading=!0,this.showTourNextToChat=!1,this.displayPubnubChat=!1,this.myPubnub=null,this.LeadSourceClient=null,this.sampleRateToUse=.05,this.right=void 0,this.bottom=void 0,this.top=void 0,this.left=void 0,this.overrideRentgrata=!1,this.widgetType=Lo.Default,this.onWidgetLoaded=hr(),this.onSstClose=hr(),this.enabledChatWidgets={callDesktop:!0,callMobile:!0,chatMobile:!0,chatDesktop:!0,emailDesktop:!0,emailMobile:!0,textDesktop:!0,textMobile:!0,sstDesktop:!0,sstMobile:!0},this.webchatConfigHasAutoOpenChat=!1,this.requiresConsent=!1,this.hideMobileFeatures=!1,this.privacyPolicyUrl="http://bit.ly/me_privacy_policy",this.launcherRef=xe(),this.firstUpdated=async()=>this.setupWebchat(),this.shouldShowWebchat=async(e,i)=>{if(!e)return console.warn("MeetElise Chat will NOT appear. Building does NOT exist."),cn({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!1,extra_data:{webchat_no_show_reason:"building_does_not_exist"}},sampleRate:this.sampleRateToUse}),!1;if(!e.launchedDateTime)return console.warn("MeetElise Chat will NOT appear. Building is NOT launched (based on launched date time)."),cn({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!1,extra_data:{webchat_no_show_reason:"building_not_launched"}},sampleRate:this.sampleRateToUse}),!1;if(!e.active)return console.warn("MeetElise Chat will NOT appear. Building is NOT active."),cn({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!1,extra_data:{webchat_no_show_reason:"building_not_active"}},sampleRate:this.sampleRateToUse}),!1;if(!e.webchatScopeConfigured)return console.warn("MeetElise Chat will NOT appear. Building is NOT webchat scope configured."),cn({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!1,extra_data:{webchat_no_show_reason:"building_not_webchat_scope_configured"}},sampleRate:this.sampleRateToUse}),!1;const n=await async function(e){if(!e)return!1;try{return(await t().get(Ki(e),{params:{building_slug:e,flag_type:"bool",feature_flag:"webchat-leasing-in-maintenance-mode",default_str:null,default_bool:!1}})).data}catch(e){return!1}}(i);return!n||(console.warn("MeetElise Chat will NOT appear. Chat is in maintenance mode."),cn({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!1,extra_data:{webchat_no_show_reason:"building_in_maintenance_mode"}},sampleRate:this.sampleRateToUse}),!1)},this.setupWebchat=async()=>{if(!this.buildingSlug||!this.orgSlug)return;const e=await xn(this.orgSlug,this.buildingSlug);if(Math.random()<.2)try{(async(e,i)=>{const n=window.rentgrata;if(!n)return;const r=n.Widget;if(!r)return;const o=r.config;if(!o)return;const a=o.widgetKey;a&&await t().post(`https://app.meetelise.com/platformApi/webchat/rentgrata?token=${a}`,{},{headers:{"Content-Type":"application/json","building-slug":null!=e?e:"","org-slug":null!=i?i:""}})})(this.buildingSlug,this.orgSlug)}catch(e){console.warn("Error updating rentgrata token",e)}this.sampleRateToUse=(null==e?void 0:e.launchedDateTime)?.02:.05,await this.shouldShowWebchat(e,this.buildingSlug)&&(cn({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!0},sampleRate:this.sampleRateToUse}),this.building=e,await this.initializeChatVariables(),await this.handleChatInitializeAnalytics(),await this.setBuildingDerivedInfo(),this.attachOnClickToLauncher(),this.shouldAutoOpenChat(this.webchatConfigHasAutoOpenChat)&&(this.displayPubnubChat=!0,this.hideLauncher=!0,this.hasMounted=!0,this.updateAlreadyAutoOpenedTimestamp()),this.isLoading=!1,"true"===localStorage.getItem("isChatOpen")&&(this.hideLauncher=!0,this.displayPubnubChat=!0))},this.setBuildingDerivedInfo=async()=>{var e,i,n,r,o,a,s,l,u,d,c,p,h,f,m,g,v,y,b,w,S,T,x,A,C,O,I,N,E,R,_,P,M,F,D,k,U;const L=this.building;if(!L)return;L&&this.orgSlug&&Io(this.orgSlug,null!==(i=null===(e=this.LeadSourceClient)||void 0===e?void 0:e.chatId)&&void 0!==i?i:null,this.sampleRateToUse,this.buildingSlug,null!==(r=null===(n=this.LeadSourceClient)||void 0===n?void 0:n.leadSource)&&void 0!==r?r:null);const[B,q,J,j,H,G,z]=await Promise.all([Nn(this.buildingSlug),Pr(this.orgSlug,this.buildingSlug),$i(this.buildingSlug),Yi(this.buildingSlug),In(L.id),Zi(this.buildingSlug),en(this.buildingSlug)]);this.building&&(this.building.phoneNumber=Ne(L.phoneNumber)),this.designConcept=null!==(o=null==B?void 0:B.abTestType)&&void 0!==o?o:"",this.leadSources=q,this.featureFlagShowDropdown=J;const W=L.textWithUsPhoneNumber?L.textWithUsPhoneNumber:await(async e=>{try{const i="https://app.meetelise.com",n=await t().get(`${i}/platformApi/webchat/${e}/phone-number`);if(n.data)return n.data}catch(t){return dn({logType:un.error,buildingSlug:e,logTitle:"[ERROR_GETTING_PHONE_NUMBERS]",logData:{error:t}}),null}return null})(this.buildingSlug);var V,Q;this.enabledChatWidgets={callDesktop:!(null===(a=null==H?void 0:H.config.shouldShowPhone)||void 0===a||!a)||null!==(s=null==H?void 0:H.config.shouldShowPhoneDesktop)&&void 0!==s&&s,callMobile:!(null===(l=null==H?void 0:H.config.shouldShowPhone)||void 0===l||!l)||null!==(u=null==H?void 0:H.config.shouldShowPhoneMobile)&&void 0!==u&&u,chatDesktop:!(null===(d=null==H?void 0:H.config.shouldShowChat)||void 0===d||!d)||null!==(c=null==H?void 0:H.config.shouldShowChatDesktop)&&void 0!==c&&c,chatMobile:!(null===(p=null==H?void 0:H.config.shouldShowChat)||void 0===p||!p)||null!==(h=null==H?void 0:H.config.shouldShowChatMobile)&&void 0!==h&&h,emailDesktop:!(null===(f=null==H?void 0:H.config.shouldShowEmail)||void 0===f||!f)||null!==(m=null==H?void 0:H.config.shouldShowEmailDesktop)&&void 0!==m&&m,emailMobile:!(null===(g=null==H?void 0:H.config.shouldShowEmail)||void 0===g||!g)||null!==(v=null==H?void 0:H.config.shouldShowEmailMobile)&&void 0!==v&&v,textDesktop:(!(null===(y=null==H?void 0:H.config.shouldShowText)||void 0===y||!y)||null!==(b=null==H?void 0:H.config.shouldShowTextDesktop)&&void 0!==b&&b)&&!!W,textMobile:(!(null===(w=null==H?void 0:H.config.shouldShowText)||void 0===w||!w)||null!==(S=null==H?void 0:H.config.shouldShowTextMobile)&&void 0!==S&&S)&&!!W,sstDesktop:!(null===(T=null==H?void 0:H.config.shouldShowSst)||void 0===T||!T)||null!==(x=null==H?void 0:H.config.shouldShowSstDesktop)&&void 0!==x&&x,sstMobile:!(null===(A=null==H?void 0:H.config.shouldShowSst)||void 0===A||!A)||null!==(C=null==H?void 0:H.config.shouldShowSstMobile)&&void 0!==C&&C},this.enabledChatWidgets.sstDesktop||this.enabledChatWidgets.sstMobile||"radco"===this.orgSlug?(Q=this.handleTourClicked,document.querySelectorAll("a").forEach((function(e){const t=e.getAttribute("href");t&&t.startsWith("https://app.meetelise.com/")&&e.addEventListener("click",(e=>{e.preventDefault(),Q(e)}))})),z&&(e=>{document.querySelectorAll('a[href$="schedule-a-tour"]').forEach((t=>{t&&t.addEventListener("click",(t=>{t.preventDefault(),e(t)}))}))})(this.handleTourClicked),"radco"===this.orgSlug&&(e=>{document.querySelectorAll('a[href^="#leaseleads-tour-open"]').forEach((t=>{var i;if(!t)return;const n=document.createElement("a");n.innerHTML=t.innerHTML,n.style.cursor="pointer",n.addEventListener("click",(t=>{t.preventDefault(),e(t)})),null===(i=t.parentNode)||void 0===i||i.replaceChild(n,t)}))})(this.handleTourClicked)):(null===(O=this.LeadSourceClient)||void 0===O?void 0:O.leadSource)&&(V=null!==(N=null===(I=this.LeadSourceClient)||void 0===I?void 0:I.leadSource)&&void 0!==N?N:null,document.querySelectorAll("a").forEach((function(e){const t=e.getAttribute("href");if(t&&t.startsWith("https://app.meetelise.com/")){const i=t.includes("?")?"&":"?";e.setAttribute("href",t+i+`eliseParsedLeadSource=${encodeURIComponent(V)}`)}}))),H&&H.config&&(this.brandColor=null!==(E=H.config.primaryColor)&&void 0!==E?E:null,this.backgroundColor=null!==(R=H.config.backgroundColor)&&void 0!==R?R:null,this.webchatConfigHasAutoOpenChat=H.config.autoOpenChat,this.requiresConsent=H.config.requiresConsent,this.hideMobileFeatures=H.config.hideMobileFeatures,this.privacyPolicyUrl=null!==(_=H.config.privacyPolicyUrl)&&void 0!==_?_:this.privacyPolicyUrl,H.config.displayStyle===Cn.MINIMIZED&&(this.isMinimized=!0),H.config.displayStyle===Cn.PILLS&&(this.designConcept=null),H.config.displayStyle===Cn.EMOJI&&(this.designConcept=Cn.EMOJI),this.onWidgetLoaded()),null===this.brandColor&&(this.brandColor=Me),null===this.backgroundColor&&(this.backgroundColor=Fe);const K=null!==(M=null===(P=this.building)||void 0===P?void 0:P.phoneNumber)&&void 0!==M?M:"";let X=null;if(j&&(X=await async function(e,i){try{const n=await t().get(`https://app.meetelise.com/platformApi/webchat/${e}/phone-number-by-source?source=${i}`);return n.data?{number:Ne(n.data.number),isMatch:n.data.match,isPropertyWebsiteCatchall:n.data.isPropertyWebsiteCatchall}:null}catch(e){return null}}(this.buildingSlug,null!==(D=null===(F=this.LeadSourceClient)||void 0===F?void 0:F.leadSource)&&void 0!==D?D:null),X&&!X.isMatch&&(X.number=K)),G&&(null==X?void 0:X.number)){const e=Zr(X.number,this.orgSlug,this.buildingSlug);e>0&&cn({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_dni_insert_override_success:!0,extra_data:{total_replacements:e}},sampleRate:this.sampleRateToUse})}const $=localStorage.getItem("eliseai_phone_number_devtest");$&&(console.info("Using dev test phone number: ",$),Zr($,this.orgSlug,this.buildingSlug)),this.phoneNumberForSource=X||{number:K,isMatch:!1,isPropertyWebsiteCatchall:!0};const Y=null!==(U=null===(k=this.LeadSourceClient)||void 0===k?void 0:k.leadSource)&&void 0!==U?U:null;Y&&(this.leadSources.includes(Y)||this.leadSources.push(Y)),qi(L.id)},this.initializeChatVariables=async()=>{var e,i,n,r,o,a,s,l;if(!this.building)return;const u=Wr(this.buildingSlug),d=Vr(this.buildingSlug,u)?u:zr(this.buildingSlug,!1);if(!d.leadId)throw new Error("Lead ID is null");this.LeadSourceClient=new class{constructor(){this.chatId=null,this.apiHost="https://app.meetelise.com",this.leadSource=null,this.localStorageTTLDays=30,this.buildingId=null,this.orgSlug=null,this.buildingSlug=null,this.queryParameters=null,this.leadSourceInput=null,this.updateLeadSourceLocalStorage=(e,t,i,n,r)=>{const o=pn();if(this.leadSourceInput={websiteOrigin:window.location.origin,websiteSearch:window.location.search,queryParameters:o,referrer:document.referrer,parsedUtmSource:o?o.utm_source:null,campaignSources:Object.values(ln()).filter((e=>e))},n)return;if(!r){const t=this.getLeadSourceBodyIfValid(e);if(t&&!pi(t.timestamp,24*this.localStorageTTLDays))return{...t,timestamp:Ci(t.timestamp)}}const a={leadSource:t,leadId:i,buildingSlug:e,timestamp:yi(new Date),leadSourceInput:this.leadSourceInput};return localStorage.setItem("com.elise.webchat.leadsource.slug="+e,JSON.stringify(a)),{...a,timestamp:Ci(a.timestamp)}},this.getLeadSourceBodyIfValid=e=>{const t=localStorage.getItem("com.elise.webchat.leadsource.slug="+e);if(t)try{const i=JSON.parse(t);if(i.buildingSlug===e&&i.leadSource&&i.leadId&&i.timestamp&&!pi(Ci(i.timestamp),24*this.localStorageTTLDays)){try{this.leadSourceInput=i.leadSourceInput}catch(e){console.error("Error parsing leadSourceInput from localStorage")}return i}}catch(e){return null}return null}}async fetchCurrentParsedLeadSource({buildingSlug:e,queryParams:i,referrer:n,campaignSources:r}){try{return(await t().post(`${this.apiHost}/platformApi/webchat/current-parsed-lead-source`,{query_params:i,building_slug:e,referrer:n,campaign_sources:r})).data}catch(e){return null}}async checkAndHandleForLogLeadSource({webchatAction:e,stateId:i}){var n,r,o,a,s,l,u;try{if(!this.chatId)return console.error("chatId is not set"),null;if(!this.orgSlug)return console.error("orgId is not set"),null;let d=null,c=null;try{if("f1ba5a20-d207-4e5a-879e-65199e7d0a53"===this.orgSlug){const e=await this.getCookieValue("_ga");e&&(d=e),c=null===(n=window.dataLayer.find((e=>{var t;return"gtagApiGet"==(null===(t=e.value)||void 0===t?void 0:t.event)})))||void 0===n?void 0:n.value}}catch(e){console.error("error getting cookie")}return await t().post(`${this.apiHost}/platformApi/webchat/log/lead-source`,{chat_id:this.chatId,webchat_action:e,state_id:i,building_id:this.buildingId,org_slug:this.orgSlug,building_slug:this.buildingSlug,website_origin:null===(r=this.leadSourceInput)||void 0===r?void 0:r.websiteOrigin,website_search:null===(o=this.leadSourceInput)||void 0===o?void 0:o.websiteSearch,query_parameters:null===(a=this.leadSourceInput)||void 0===a?void 0:a.queryParameters,referrer:null===(s=this.leadSourceInput)||void 0===s?void 0:s.referrer,parsed_utm_source:null===(l=this.leadSourceInput)||void 0===l?void 0:l.parsedUtmSource,campaign_sources:null===(u=this.leadSourceInput)||void 0===u?void 0:u.campaignSources,lead_source_output:this.leadSource,google_analytics_client_id:mn()(d)?null:d,extras:null!=c?c:null}),null}catch(e){return null}}async getCookieValue(e){try{const t=document.cookie.split(";");for(let i=0;i<t.length;i++){const n=t[i].trim();if(n.startsWith(e+"="))return n.substring((e+"=").length,-1===n.indexOf(";")?void 0:n.indexOf(";"))}return null}catch(e){console.error("error getting cookie value")}return null}async generateUserLeadSource({leadId:e,orgSlug:t,buildingSlug:i}){try{const n={queryParams:pn(),buildingSlug:i,referrer:document.referrer,campaignSources:ln()};let r=!1;const o=i?this.getLeadSourceBodyIfValid(i):null;if(o){if(!["test-company","daf00bd2-1ecb-482c-b6f4-e1c5511a01be"].includes(t))return this.leadSource=o.leadSource,this.leadSource;{const e=await this.fetchCurrentParsedLeadSource(n);if(!e)return this.leadSource=o.leadSource,this.leadSource;this.leadSource=e,r=!0}}const a=await this.fetchCurrentParsedLeadSource(n);if(this.leadSource=a,this.buildingId=null,this.orgSlug=t,this.buildingSlug=i,i&&!a){const e=this.getLeadSourceBodyIfValid(i);if(e)return this.leadSource=e.leadSource,this.leadSource}if(i){const t=!!a&&a.length>0;this.updateLeadSourceLocalStorage(i,a,e,!t&&!r,r)}return a}catch(e){console.error(e)}return null}},this.myPubnub=new Yr(this.buildingSlug,this.building,this.orgSlug,null,d.leadId,this.LeadSourceClient,this.widgetType),this.LeadSourceClient.chatId=this.myPubnub.channel,await(null===(e=this.LeadSourceClient)||void 0===e?void 0:e.generateUserLeadSource({leadId:null!==(n=null===(i=this.myPubnub)||void 0===i?void 0:i.leadUserId)&&void 0!==n?n:"",orgSlug:this.orgSlug,buildingSlug:this.buildingSlug})),console.log("EliseAI Mapped Lead Source source: ",null===(r=this.LeadSourceClient)||void 0===r?void 0:r.leadSource),"property-website"!==gn(this.orgSlug)?this.myPubnub.leadSource=null!==(a=null===(o=this.LeadSourceClient)||void 0===o?void 0:o.leadSource)&&void 0!==a?a:gn(this.orgSlug):this.myPubnub.leadSource=null!==(l=null===(s=this.LeadSourceClient)||void 0===s?void 0:s.leadSource)&&void 0!==l?l:null,d.initiatedChat&&await this.myPubnub.initializePubnub(u)},this.shouldAutoOpenChat=e=>{const t=sessionStorage.getItem("alreadyAutoOpenedTimestamp"),i=!t||!(t&&!xi(Ci(t)));return!!e&&!!i&&!ci()},this.updateAlreadyAutoOpenedTimestamp=()=>{sessionStorage.setItem("alreadyAutoOpenedTimestamp",yi(function(e,t){Be(2,arguments);var i=it(t);return nt(e,6e4*i)}(new Date,15)))},this.handleContactClicked=e=>{var t;this.displayPubnubChat=!1,this.hideLauncher=!1,this.showTourNextToChat=!1,null===(t=this.launcherRef.value)||void 0===t||t.onClickEmailOption(e)},this.handleTourClicked=e=>{var t,i;this.showTourNextToChat?null===(t=this.launcherRef.value)||void 0===t||t.onClickSSTOption(e):(this.hideLauncher?this.showTourNextToChat=!0:this.displayPubnubChat=!1,this.hideLauncher=!1,null===(i=this.launcherRef.value)||void 0===i||i.onClickSSTOption(e))},this.handleContactTabClicked=e=>{var t;this.displayPubnubChat=!1,this.showTourNextToChat=!1,this.hideLauncher=!1,null===(t=this.launcherRef.value)||void 0===t||t.onClickPhoneOption(e)},this.adjustPositionChatAdditionalActions=()=>{var e,t,i,n;const r=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("chatAdditionalActionsPubnub");if(!r)return;const o=null===(n=null===(i=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("pubnub-chat"))||void 0===i?void 0:i.shadowRoot)||void 0===n?void 0:n.getElementById("pubnub-chat-container"),a=null==o?void 0:o.getBoundingClientRect();a&&(r.style.left=`${a.left}px`,r.style.top=`${a.bottom}px`)},this.handleKeydownTab=e=>{var t,i,n,r,o,a,s,l,u,d,c,p,h,f,m,g,v,y,b,w;if("Tab"===e.key){const S=this.displayPubnubChat?null===(n=null===(i=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("pubnub-chat"))||void 0===i?void 0:i.shadowRoot)||void 0===n?void 0:n.getElementById("pubnub-chat-container"):null!==(m=null!==(u=null===(l=null===(s=null===(a=null===(o=null===(r=this.shadowRoot)||void 0===r?void 0:r.getElementById("meetelise-launcher"))||void 0===o?void 0:o.shadowRoot)||void 0===a?void 0:a.getElementById("email-us-window"))||void 0===s?void 0:s.shadowRoot)||void 0===l?void 0:l.getElementById("email-us-form"))&&void 0!==u?u:null===(f=null===(h=null===(p=null===(c=null===(d=this.shadowRoot)||void 0===d?void 0:d.getElementById("meetelise-launcher"))||void 0===c?void 0:c.shadowRoot)||void 0===p?void 0:p.getElementById("tour-scheduler-window"))||void 0===h?void 0:h.shadowRoot)||void 0===f?void 0:f.getElementById("scheduler-container"))&&void 0!==m?m:null===(w=null===(b=null===(y=null===(v=null===(g=this.shadowRoot)||void 0===g?void 0:g.getElementById("meetelise-launcher"))||void 0===v?void 0:v.shadowRoot)||void 0===y?void 0:y.getElementById("call-us-window"))||void 0===b?void 0:b.shadowRoot)||void 0===w?void 0:w.getElementById("details-window");if(!S)return;e.preventDefault();const T=S.querySelectorAll("input, me-select, textarea, action-confirm-button, [tabindex]"),x=Array.from(T),A=x.findIndex((e=>e.matches(":focus")));x[(A+1)%x.length].focus()}},this.onClickMinimize=e=>{e.preventDefault(),e.stopPropagation(),this.isMinimized=!this.isMinimized,this.showTourNextToChat=!1},this.attachOnClickToLauncher=()=>{const e=this.launcherRef.value;e&&(e.onChatTapped=async()=>{this.displayPubnubChat=!0,this.hideLauncher=!0,this.hasMounted=!0,localStorage.setItem("isChatOpen","true")},e.onExitChat=this.onExitChat)},this.onExitChat=()=>{this.displayPubnubChat=!1,this.hideLauncher=!1,this.showTourNextToChat=!1,localStorage.setItem("isChatOpen","false")},this.renderChatAdditionalActions=(e,t)=>{const i=this.building&&ke(this.building.orgId,this.building.id)&&this.brandColor&&this.brandColor!==Me?De(this.brandColor,.6):"black";return U` <style>
4503
4503
  #{id}::after {
4504
4504
  border-right-color: ${i} !important;
4505
4505
  }
@@ -4667,7 +4667,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
4667
4667
  position: fixed;
4668
4668
  bottom: 0;
4669
4669
  }
4670
- `,Ao([le({type:String})],Co.prototype,"buildingSlug",void 0),Ao([le({type:String})],Co.prototype,"orgSlug",void 0),Ao([le({type:Object})],Co.prototype,"launcherStyles",void 0),Ao([le()],Co.prototype,"mobileStyles",void 0),Ao([le({type:Boolean})],Co.prototype,"isMinimized",void 0),Ao([le({type:String})],Co.prototype,"brandColor",void 0),Ao([le({type:String})],Co.prototype,"backgroundColor",void 0),Ao([ue()],Co.prototype,"chatId",void 0),Ao([ue()],Co.prototype,"analytics",void 0),Ao([ue()],Co.prototype,"launcher",void 0),Ao([ue()],Co.prototype,"building",void 0),Ao([ue()],Co.prototype,"designConcept",void 0),Ao([ue()],Co.prototype,"leadSources",void 0),Ao([ue()],Co.prototype,"currentLeadSource",void 0),Ao([ue()],Co.prototype,"featureFlagShowDropdown",void 0),Ao([ue()],Co.prototype,"phoneNumberForSource",void 0),Ao([ue()],Co.prototype,"hasMounted",void 0),Ao([ue()],Co.prototype,"hideLauncher",void 0),Ao([ue()],Co.prototype,"isLoading",void 0),Ao([ue()],Co.prototype,"showTourNextToChat",void 0),Ao([ue()],Co.prototype,"displayPubnubChat",void 0),Ao([ue()],Co.prototype,"myPubnub",void 0),Ao([ue()],Co.prototype,"LeadSourceClient",void 0),Ao([le({type:Number})],Co.prototype,"right",void 0),Ao([le({type:Number})],Co.prototype,"bottom",void 0),Ao([le({type:Number})],Co.prototype,"top",void 0),Ao([le({type:Number})],Co.prototype,"left",void 0),Ao([le({attribute:!0})],Co.prototype,"overrideRentgrata",void 0),Ao([le({attribute:!0})],Co.prototype,"widgetType",void 0),Ao([le()],Co.prototype,"onWidgetLoaded",void 0),Ao([le({attribute:!0})],Co.prototype,"onSstClose",void 0),Ao([ue()],Co.prototype,"enabledChatWidgets",void 0),Ao([ue()],Co.prototype,"webchatConfigHasAutoOpenChat",void 0),Ao([ue()],Co.prototype,"requiresConsent",void 0),Ao([ue()],Co.prototype,"hideMobileFeatures",void 0),Ao([ue()],Co.prototype,"privacyPolicyUrl",void 0),Co=Ao([ae("me-chat")],Co);const Oo=e=>{for(const t of e){const e=document.getElementById(t);if(e)return e}return null},Io=async(e,i,n,r)=>{var o;if(!n||!e)return;const a=await async function(e){if(!e)return!1;try{return(await t().get(Ki(e),{params:{building_slug:e,flag_type:"bool",feature_flag:"webchat-use-override-contact-us-form",default_str:null,default_bool:!1}})).data}catch(e){return!1}}(n);if(!a)return;const s=Oo(["myContactForm","contactus","fpa-myContactForm"]);let l;if(!(s&&s instanceof HTMLFormElement)){const t=document.querySelector("form");return void(window.location.pathname.toLowerCase().includes("contactus")&&No(n,e,"Could not find form",t?{id:t.id}:void 0))}try{if(s.parentElement&&"scheduleTourForm"===s.parentElement.id)return No(n,e,"Form is apart of schedule tour form!")}catch(e){console.error("error",e)}for(let e=0;e<s.elements.length;e++){const t=s.elements[e];if("button"===t.tagName.toLowerCase()&&"fakebutton"===t.getAttribute("data-selenium-id")){l=t;break}if("fpa-contact-submit"===t.getAttribute("id")){l=t;break}}if(!l)return No(n,e,"Could not find submit button");const u=()=>({firstName:Oo(["firstname","txtName","fpa-firstname","Form_FirstName"]),lastName:Oo(["lastname","txtName2","fpa-lastname","Form_LastName"]),email:Oo(["email","txtEmail","fpa-email","Form_Email"]),phone:Oo(["phonenumber","txtPhone","fpa-phonenumber","Form_Phone"]),message:Oo(["message","txtComments","fpa-email","Form_Message"])});if(Object.values(u()).some((e=>null===e))){const t=Object.entries(u()).filter((([,e])=>null===e)).map((([e])=>e));return No(n,e,"Missing the following form elements: "+t.join(", "))}const d=l.textContent,c=l.cloneNode(!0);null===(o=l.parentNode)||void 0===o||o.replaceChild(c,l),c&&cn({params:{chat_id:i,org_slug:e,building_slug:n,is_form_override_success:!0},isSampled:!0}),c.onclick=async function(t){if(Object.values(u()).forEach((e=>{"true"!==(null==e?void 0:e.getAttribute("aria-required"))||e.value||(e.className="form-control required is-invalid")})),!Object.values(u()).every((e=>null!==e&&!("true"===e.getAttribute("aria-required")&&!e.value)&&("email"!==e.id&&"phonenumber"!==e.id||"true"!==e.getAttribute("aria-invalid")))))return;t.preventDefault(),c.textContent="Processing request...",c.disabled=!0;const i={};Object.entries(u()).forEach((([e,t])=>i[e]=null==t?void 0:t.value));const o=await xn(e,n);if(!o)return No(n,e,"Could not find building"),null;const a={email_address:i.email,first_name:i.firstName,last_name:i.lastName,phone_number:i.phone,first_message:i.message,building_id:o.id,is_external_form:!0,lead_sources:[...new Set(r?[r,gn(e)]:[gn(e)])]},l=JSON.stringify(a);fetch("https://app.meetelise.com/platformApi/state/create/contactMe",{method:"POST",headers:{"Content-Type":"application/json","building-slug":n,"org-slug":e},body:l}).then((e=>{if(!e.ok)throw new Error(`HTTP error ${e.status}`);return s&&s.reset(),Object.values(u()).forEach((e=>{e&&(e.disabled=!0)})),c.textContent="Submitted",c.disabled=!0,e.json()})).catch((()=>{c.textContent=d}))}},No=(e,t,i,n)=>{const r=JSON.stringify({orgSlug:t,buildingSlug:e,reason:i,url:window.location.href,formIdInfo:n});fetch("https://app.meetelise.com/platformApi/webchat/form-override-error",{method:"POST",headers:{"Content-Type":"application/json","building-slug":e,"org-slug":t},body:r})},Eo=l`
4670
+ `,Ao([le({type:String})],Co.prototype,"buildingSlug",void 0),Ao([le({type:String})],Co.prototype,"orgSlug",void 0),Ao([le({type:Object})],Co.prototype,"launcherStyles",void 0),Ao([le()],Co.prototype,"mobileStyles",void 0),Ao([le({type:Boolean})],Co.prototype,"isMinimized",void 0),Ao([le({type:String})],Co.prototype,"brandColor",void 0),Ao([le({type:String})],Co.prototype,"backgroundColor",void 0),Ao([ue()],Co.prototype,"chatId",void 0),Ao([ue()],Co.prototype,"analytics",void 0),Ao([ue()],Co.prototype,"launcher",void 0),Ao([ue()],Co.prototype,"building",void 0),Ao([ue()],Co.prototype,"designConcept",void 0),Ao([ue()],Co.prototype,"leadSources",void 0),Ao([ue()],Co.prototype,"currentLeadSource",void 0),Ao([ue()],Co.prototype,"featureFlagShowDropdown",void 0),Ao([ue()],Co.prototype,"phoneNumberForSource",void 0),Ao([ue()],Co.prototype,"hasMounted",void 0),Ao([ue()],Co.prototype,"hideLauncher",void 0),Ao([ue()],Co.prototype,"isLoading",void 0),Ao([ue()],Co.prototype,"showTourNextToChat",void 0),Ao([ue()],Co.prototype,"displayPubnubChat",void 0),Ao([ue()],Co.prototype,"myPubnub",void 0),Ao([ue()],Co.prototype,"LeadSourceClient",void 0),Ao([ue()],Co.prototype,"sampleRateToUse",void 0),Ao([le({type:Number})],Co.prototype,"right",void 0),Ao([le({type:Number})],Co.prototype,"bottom",void 0),Ao([le({type:Number})],Co.prototype,"top",void 0),Ao([le({type:Number})],Co.prototype,"left",void 0),Ao([le({attribute:!0})],Co.prototype,"overrideRentgrata",void 0),Ao([le({attribute:!0})],Co.prototype,"widgetType",void 0),Ao([le()],Co.prototype,"onWidgetLoaded",void 0),Ao([le({attribute:!0})],Co.prototype,"onSstClose",void 0),Ao([ue()],Co.prototype,"enabledChatWidgets",void 0),Ao([ue()],Co.prototype,"webchatConfigHasAutoOpenChat",void 0),Ao([ue()],Co.prototype,"requiresConsent",void 0),Ao([ue()],Co.prototype,"hideMobileFeatures",void 0),Ao([ue()],Co.prototype,"privacyPolicyUrl",void 0),Co=Ao([ae("me-chat")],Co);const Oo=e=>{for(const t of e){const e=document.getElementById(t);if(e)return e}return null},Io=async(e,i,n,r,o)=>{var a;if(!r||!e)return;const s=await async function(e){if(!e)return!1;try{return(await t().get(Ki(e),{params:{building_slug:e,flag_type:"bool",feature_flag:"webchat-use-override-contact-us-form",default_str:null,default_bool:!1}})).data}catch(e){return!1}}(r);if(!s)return;const l=Oo(["myContactForm","contactus","fpa-myContactForm"]);let u;if(!(l&&l instanceof HTMLFormElement)){const t=document.querySelector("form");return void(window.location.pathname.toLowerCase().includes("contactus")&&No(r,e,"Could not find form",t?{id:t.id}:void 0))}try{if(l.parentElement&&"scheduleTourForm"===l.parentElement.id)return No(r,e,"Form is apart of schedule tour form!")}catch(e){console.error("error",e)}for(let e=0;e<l.elements.length;e++){const t=l.elements[e];if("button"===t.tagName.toLowerCase()&&"fakebutton"===t.getAttribute("data-selenium-id")){u=t;break}if("fpa-contact-submit"===t.getAttribute("id")){u=t;break}}if(!u)return No(r,e,"Could not find submit button");const d=()=>({firstName:Oo(["firstname","txtName","fpa-firstname","Form_FirstName"]),lastName:Oo(["lastname","txtName2","fpa-lastname","Form_LastName"]),email:Oo(["email","txtEmail","fpa-email","Form_Email"]),phone:Oo(["phonenumber","txtPhone","fpa-phonenumber","Form_Phone"]),message:Oo(["message","txtComments","fpa-email","Form_Message"])});if(Object.values(d()).some((e=>null===e))){const t=Object.entries(d()).filter((([,e])=>null===e)).map((([e])=>e));return No(r,e,"Missing the following form elements: "+t.join(", "))}const c=u.textContent,p=u.cloneNode(!0);null===(a=u.parentNode)||void 0===a||a.replaceChild(p,u),p&&cn({params:{chat_id:i,org_slug:e,building_slug:r,is_form_override_success:!0},sampleRate:n}),p.onclick=async function(t){if(Object.values(d()).forEach((e=>{"true"!==(null==e?void 0:e.getAttribute("aria-required"))||e.value||(e.className="form-control required is-invalid")})),!Object.values(d()).every((e=>null!==e&&!("true"===e.getAttribute("aria-required")&&!e.value)&&("email"!==e.id&&"phonenumber"!==e.id||"true"!==e.getAttribute("aria-invalid")))))return;t.preventDefault(),p.textContent="Processing request...",p.disabled=!0;const i={};Object.entries(d()).forEach((([e,t])=>i[e]=null==t?void 0:t.value));const n=await xn(e,r);if(!n)return No(r,e,"Could not find building"),null;const a={email_address:i.email,first_name:i.firstName,last_name:i.lastName,phone_number:i.phone,first_message:i.message,building_id:n.id,is_external_form:!0,lead_sources:[...new Set(o?[o,gn(e)]:[gn(e)])]},s=JSON.stringify(a);fetch("https://app.meetelise.com/platformApi/state/create/contactMe",{method:"POST",headers:{"Content-Type":"application/json","building-slug":r,"org-slug":e},body:s}).then((e=>{if(!e.ok)throw new Error(`HTTP error ${e.status}`);return l&&l.reset(),Object.values(d()).forEach((e=>{e&&(e.disabled=!0)})),p.textContent="Submitted",p.disabled=!0,e.json()})).catch((()=>{p.textContent=c}))}},No=(e,t,i,n)=>{const r=JSON.stringify({orgSlug:t,buildingSlug:e,reason:i,url:window.location.href,formIdInfo:n});fetch("https://app.meetelise.com/platformApi/webchat/form-override-error",{method:"POST",headers:{"Content-Type":"application/json","building-slug":e,"org-slug":t},body:r})},Eo=l`
4671
4671
  .chat-launcher {
4672
4672
  position: fixed;
4673
4673
  }
@@ -177,6 +177,9 @@ export class MEChat extends LitElement {
177
177
  @state()
178
178
  private LeadSourceClient: LeadSourceClient | null = null;
179
179
 
180
+ @state()
181
+ private sampleRateToUse = 0.05;
182
+
180
183
  @property({ type: Number })
181
184
  private right = undefined;
182
185
 
@@ -259,7 +262,7 @@ export class MEChat extends LitElement {
259
262
  webchat_no_show_reason: "building_does_not_exist",
260
263
  },
261
264
  },
262
- isSampled: true,
265
+ sampleRate: this.sampleRateToUse,
263
266
  });
264
267
  return false;
265
268
  }
@@ -278,7 +281,7 @@ export class MEChat extends LitElement {
278
281
  webchat_no_show_reason: "building_not_launched",
279
282
  },
280
283
  },
281
- isSampled: true,
284
+ sampleRate: this.sampleRateToUse,
282
285
  });
283
286
  return false;
284
287
  }
@@ -295,7 +298,7 @@ export class MEChat extends LitElement {
295
298
  webchat_no_show_reason: "building_not_active",
296
299
  },
297
300
  },
298
- isSampled: true,
301
+ sampleRate: this.sampleRateToUse,
299
302
  });
300
303
  return false;
301
304
  }
@@ -314,7 +317,7 @@ export class MEChat extends LitElement {
314
317
  webchat_no_show_reason: "building_not_webchat_scope_configured",
315
318
  },
316
319
  },
317
- isSampled: true,
320
+ sampleRate: this.sampleRateToUse,
318
321
  });
319
322
  return false;
320
323
  }
@@ -338,7 +341,7 @@ export class MEChat extends LitElement {
338
341
  webchat_no_show_reason: "building_in_maintenance_mode",
339
342
  },
340
343
  },
341
- isSampled: true,
344
+ sampleRate: this.sampleRateToUse,
342
345
  });
343
346
  return false;
344
347
  }
@@ -357,6 +360,9 @@ export class MEChat extends LitElement {
357
360
  }
358
361
  }
359
362
 
363
+ // We use a lower sample rate if not launched yet because likely still in onboarding process
364
+ this.sampleRateToUse = building?.launchedDateTime ? 0.02 : 0.05;
365
+
360
366
  const shouldShowWebchat = await this.shouldShowWebchat(
361
367
  building,
362
368
  this.buildingSlug
@@ -371,7 +377,7 @@ export class MEChat extends LitElement {
371
377
  is_pixel_on_site: true,
372
378
  is_any_webchat_showing: true,
373
379
  },
374
- isSampled: true,
380
+ sampleRate: this.sampleRateToUse,
375
381
  });
376
382
  }
377
383
 
@@ -405,6 +411,7 @@ export class MEChat extends LitElement {
405
411
  overrideContactUsForm(
406
412
  this.orgSlug,
407
413
  this.LeadSourceClient?.chatId ?? null,
414
+ this.sampleRateToUse,
408
415
  this.buildingSlug,
409
416
  this.LeadSourceClient?.leadSource ?? null
410
417
  );
@@ -564,7 +571,7 @@ export class MEChat extends LitElement {
564
571
  total_replacements: totalReplacements,
565
572
  },
566
573
  },
567
- isSampled: true,
574
+ sampleRate: this.sampleRateToUse,
568
575
  });
569
576
  }
570
577
  }
@@ -1076,6 +1083,7 @@ const findElementById = (priorityIds: string[]): HTMLElement | null => {
1076
1083
  const overrideContactUsForm = async (
1077
1084
  orgSlug: string,
1078
1085
  chatId: string | null,
1086
+ sampleRateToUse: number,
1079
1087
  buildingSlug?: string,
1080
1088
  leadSource?: string | null
1081
1089
  ): Promise<void> => {
@@ -1237,7 +1245,7 @@ const overrideContactUsForm = async (
1237
1245
  building_slug: buildingSlug,
1238
1246
  is_form_override_success: true,
1239
1247
  },
1240
- isSampled: true,
1248
+ sampleRate: sampleRateToUse,
1241
1249
  });
1242
1250
  }
1243
1251
 
package/src/analytics.ts CHANGED
@@ -192,14 +192,13 @@ interface SignalLoggerProps {
192
192
 
193
193
  export const logSignal = async ({
194
194
  params,
195
- isSampled,
195
+ sampleRate,
196
196
  }: {
197
197
  params: SignalLoggerProps;
198
- isSampled?: boolean;
198
+ sampleRate: number; // 0.05 is 5%
199
199
  }): Promise<void> => {
200
200
  try {
201
- // fire 5% of the time
202
- if (!!isSampled && Math.random() <= 0.05) {
201
+ if (Math.random() >= sampleRate) {
203
202
  return;
204
203
  }
205
204
  await axios.post(