@meetelise/chat 1.20.199 → 1.20.201

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.20.199",
3
+ "version": "1.20.201",
4
4
  "description": "",
5
5
  "main": "public/dist/index.js",
6
6
  "type": "module",
@@ -117,68 +117,9 @@
117
117
  <!-- Webpack dev server will serve the bundle, index.js, at the path '/' -->
118
118
  <script type="module" async>
119
119
  import MEChat from "/index.js";
120
- MEChat.healthcareStart({
121
- id: "6a9e65e5-9699-4c96-af75-1741d0df79aa",
122
- // MEChat.start({
123
- // 123 Main Street
124
- // organization: "test-company",
125
- // building: "e2e-test-yardi-building",
126
-
127
- // organization: "edward-rose",
128
- // building: "rivers-edge-apartments",
129
- // // mobileStyles: {
130
- // // bottom: "100px",
131
- // // },
132
-
133
- // // organization: "mill-creek",
134
- // // building: "5ec32c42-2548-11ec-b813-e361780537f5",
135
-
136
- // // organization: "d1a1060d-3844-48d4-a454-1ba26292bc69",
137
- // // building: "25feb690-c76f-11ed-83b9-a7aa9698a486",
138
-
139
- // // organization: "TT",
140
- // // building: "ffc97070-5c73-11ed-8507-77860136d3bf",
141
-
142
- // // AMLI
143
- // organization: "amli",
144
- // building: "6e43581c-c4a4-11ec-a62b-9311f60f23f8",
145
-
146
- // organization: "d1a1060d-3844-48d4-a454-1ba26292bc69",
147
- // building: "25fead9e-c76f-11ed-83b2-7b1e7b442e9f",
148
-
149
- // // Taylor Street Apartments
150
- // organization: "test-company",
151
- // building: "e2e-test-yardi-building",
152
- // position: {
153
- // bottom: 100,
154
- // left: 0,
155
- // },
156
-
157
- // // The Qual People
158
- // // organization: "Pacific Urban Residential",
159
- // // building: "1ac49f90-6150-11ed-b327-1b3f05e7b9db",
160
-
161
- // // organization: "Pacific Urban Residential",
162
- // // building: "1ac49f90-6150-11ed-b327-1b3f05e7b9db",
163
-
164
- // // Cambridge House
165
- // organization: "elise-ai",
166
- // building: "the-cambridge-house-3",
167
-
168
- // // Artistry on 10th
169
- // // organization: "lindy",
170
- // // building: "c4cfc3ec-c4da-11ec-bda4-43aed00ca1b2",
171
-
172
- // // brandColor: "#a44ef5",
173
-
174
- // // organization: "Pacific Urban Residential",
175
- // // building: "1ac49f90-6150-11ed-b327-1b3f05e7b9db",
176
-
177
- // // organization: "sparrow",
178
- // // building: "8e87ae6e-eae8-11ed-aae8-fb82f4692a79",
179
- // });
180
- // MEChat.healthcareStart({
181
- // id: "6a9e65e5-9699-4c96-af75-1741d0df79aa",
120
+ MEChat.start({
121
+ organization: "ab6383d4-6281-45b4-ac47-3476edb26e6f",
122
+ building: "618c0172-9906-11ee-b546-e3efad391a18",
182
123
  });
183
124
  </script>
184
125
  <main>
@@ -187,6 +128,7 @@
187
128
  This is an example page for serving the chat widget locally. Source of
188
129
  truth
189
130
  </p>
131
+
190
132
  <button id="reset" type="button">Restart conversation</button>
191
133
  <button id="navigate" type="button">navigate</button>
192
134
  <button id="unnavigate" type="button">unnavigate</button>
@@ -922,7 +922,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
922
922
  .loading-entire-tour-icon {
923
923
  padding: 24px;
924
924
  }
925
- `;class ii{constructor(e,t,n,i){this.org=e,this.building=t,this.chatId=n,this.incomingProcessedLeadSource=i,this.featureFlags={}}setFeatureFlags(e){this.featureFlags={...this.featureFlags,...e}}ping(e){var t;fetch("https://app.meetelise.com/platformApi/connectors/talk_js/analytics",{method:"POST",credentials:"omit",keepalive:!0,headers:{"content-type":"application/json; charset=UTF-8"},body:JSON.stringify({eventType:e,chatId:this.chatId,url:location.href,org:this.org,building:this.building,referrer:document.referrer,featureFlags:this.featureFlags,campaignSources:ri(),incomingProcessedLeadSource:this.incomingProcessedLeadSource,webchatVersion:null!==(t="MISSING_ENV_VAR".npm_package_version)&&void 0!==t?t:"1.20.155"})})}}const ri=()=>{var e,t,n;const i=new URL(window.location.href).searchParams,r=null!==(n=null===(t=null===(e=window.RCTPCampaign)||void 0===e?void 0:e.CampaignDetails)||void 0===t?void 0:t.Source)&&void 0!==n?n:null;return{entrataCampaignSource:i.get("switch_cls[id]"),realpageCampaignSource:i.get("ilm"),utmCampaignSource:i.get("utm_source"),yardiCampaignSource:r}};var oi;!function(e){e.error="error",e.info="info",e.warn="warn"}(oi||(oi={}));const ai=async({logType:e,buildingSlug:n,orgSlug:i,logTitle:r,logData:o})=>{await t().post("https://app.meetelise.com/platformApi/webchat/logging",{...o},{headers:{"Content-Type":"application/json","building-slug":null!=n?n:"","org-slug":null!=i?i:"","log-type":null!=e?e:oi.error,"log-title":r.toUpperCase().replace(/\s/g,"_")}})};var si=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a};let ui=class extends re{constructor(){super(...arguments),this.layoutOptions=[],this.unitOptions=[],this.tourTypeOptions=[],this.chatId="",this.buildingId=0,this.buildingSlug="",this.sgtUrl="",this.escortedToursLink="",this.virtualToursLink="",this.orgSlug="",this.hasDynamicSchedulingEnabled=!1,this.buildingName="",this.tourType=null,this.shouldShowTourType={[li.Guided]:!0,[li.Self]:!0,[li.Virtual]:!0},this.email="",this.phoneNumber="",this.availabilitiesGroupedByDay={},this.waitingForAvailabilities=!0,this.mobilePageIndex=0,this.isSubmitting=!1,this.tourIsBooked=!1,this.leadSources=[],this.currentLeadSource="",this.featureFlagShowDropdown="",this.compactDesign=!1,this.brandColor=Fe,this.errorGettingAvailabilities=!1,this.firstUpdated=async()=>{try{const e=await(async()=>{var e,t,n,i,r,o;return{[li.Guided]:!!(null===(t=null===(e=await Un(gn.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.WithAgent))||void 0===e?void 0:e.availableTourStartTimes)||void 0===t?void 0:t.length),[li.Self]:!!(null===(i=null===(n=await Un(gn.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.SelfGuided))||void 0===n?void 0:n.availableTourStartTimes)||void 0===i?void 0:i.length),[li.Virtual]:!!(null===(o=null===(r=await Un(gn.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.VirtualShowing))||void 0===r?void 0:r.availableTourStartTimes)||void 0===o?void 0:o.length)}})();ai({logTitle:"AVAILABILITIES_EXIST_FOR_TOUR_TYPE",logData:e,logType:oi.info,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});const t=Object.values(e).every((e=>!1===e));if(t)return this.errorGettingAvailabilities=!0,this.waitingForAvailabilities=!1,void ai({logTitle:"NO_AVAILABILITIES_EXIST",logData:null,logType:oi.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});if(this.shouldShowTourType={[li.Guided]:this.tourTypeOptions.map((e=>e.value)).includes("WITH_AGENT")&&e[li.Guided],[li.Self]:this.tourTypeOptions.map((e=>e.value)).includes("SELF_GUIDED")&&e[li.Self],[li.Virtual]:this.tourTypeOptions.map((e=>e.value)).includes("VIRTUAL_SHOWING")&&e[li.Virtual]},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 qn(di[this.tourType]),this.waitingForAvailabilities=!1}catch(e){this.errorGettingAvailabilities=!0,this.waitingForAvailabilities=!1,ai({logTitle:"ERROR_LOADING_AVAILABILITIES",logData:{error:e},logType:oi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this.willUpdate=async e=>{e.has("tourType")&&this.tourType&&(this.availabilitiesGroupedByDay=await qn(di[this.tourType]))},this.handlePhoneKeydown=e=>{var t;if(!(e instanceof KeyboardEvent&&e.target instanceof HTMLInputElement&&null!==e.target.selectionStart))return;const n=e.target.selectionStart;if(1!==e.key.length||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,i=this.phoneNumber.slice(0,n).replace(/\D/g,""),r=this.phoneNumber.slice(n).replace(/\D/g,""),o=`${i.slice(0,-1)}${r}`;this.phoneNumber=Ie(o),this.phoneInput.value=this.phoneNumber;const a=n-(t-this.phoneNumber.length);return this.phoneInput.setSelectionRange(a,a),e.preventDefault(),void e.stopPropagation()}if(!["ArrowLeft","ArrowRight"].includes(e.key)||Re(e)||e.shiftKey)return;if("ArrowLeft"===e.key){const e=((null===(t=this.phoneNumber.slice(0,n).split(/\d+/).at(-1))||void 0===t?void 0:t.length)||0)+1,i=n-e>-1?n-e:0;this.phoneInput.setSelectionRange(i,i)}if("ArrowRight"===e.key){const e=(this.phoneNumber.slice(n).split(/\d+/)[0].length||0)+1,t=n+e<this.phoneNumber.length?n+e:this.phoneNumber.length;this.phoneInput.setSelectionRange(t,t)}e.preventDefault(),e.stopPropagation()}else{e.preventDefault(),e.stopPropagation();const t=this.phoneNumber.slice(0,n)+e.key+this.phoneNumber.slice(n);this.phoneNumber=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 n=this.phoneInput.selectionStart,i=n?this.phoneInput.value.slice(n).replace(/\D/g,""):"";this.phoneNumber=Ie(this.phoneInput.value);let r=0,o=i.length;for(;o;)(null===(t=this.phoneNumber.at(r))||void 0===t?void 0:t.match(/\d/))&&o--,r++;const a=this.phoneInput.value.length-r+1;this.phoneInput.setSelectionRange(a,a)},this.onChangeEmail=e=>{e.target&&(this.email=e.target.value)},this.validators={tourType:()=>null!==this.tourType,dateAndTime:()=>!!this.selectedDate&&!!this.selectedTime,leadInfo:()=>{var e,t,n;return(!!(null===(e=this.firstNameInput)||void 0===e?void 0:e.value)||!!(null===(t=this.lastNameInput)||void 0===t?void 0:t.value))&&(null===(n=this.emailInput)||void 0===n?void 0:n.value.includes("@"))&&!!this.phoneNumber&&14===this.phoneNumber.length}},this.formIsValidForSubmission=()=>this.validators.tourType()&&this.validators.dateAndTime()&&this.validators.leadInfo(),this.timeStringToHoursAndMinutes=e=>{const[t,n]=e.split(/\D/g);return[parseInt(t)+(e.toLowerCase().includes("pm")?12:0),parseInt(n)]},this.submit=async()=>{var e,n;if(!this.selectedDate||!this.selectedTime||null===this.tourType)return;const i=new URLSearchParams(window.location.search),r=this.selectedLeadSource&&this.selectedLeadSource.value?this.selectedLeadSource.value:this.currentLeadSource,o=[...new Set(r?[r,"property-website"]:["property-website"])];Zn("scheduleTourSubmitted",{email:this.email,phone:`+1${null===(e=this.phoneNumber.match(/\d/g))||void 0===e?void 0:e.join("")}`,firstName:this.firstNameInput.value,lastName:this.lastNameInput.value,tourType:ci[this.tourType],tourTime:`${this.selectedTime.datetime}${this.selectedTime.offset}`,originatingSource:o.find((e=>"property-website"!==e))||null});const a={referrer:document.referrer,email_address:this.email,phone_number:`+1${null===(n=this.phoneNumber.match(/\d/g))||void 0===n?void 0:n.join("")}`,building_id:this.buildingId,first_name:this.firstNameInput.value,last_name:this.lastNameInput.value,tour_type:ci[this.tourType],tour_time:`${this.selectedTime.datetime}${this.selectedTime.offset}`,lead_sources:[...new Set(r?[r,"property-website"]:["property-website"])],query_params:Object.fromEntries(i.entries())};this.isSubmitting=!0;try{await t().post("https://app.meetelise.com/platformApi/state/create/v2/scheduleMe",a,{headers:{"building-slug":this.buildingSlug,"X-SecurityKey":"JRL8jV4VcSCwOSir5gWkpgNLfKghmhBG","org-slug":this.orgSlug}}),await Gn({chatId:this.chatId,website:window.location.origin,referrer:document.referrer,buildingSlug:this.buildingSlug,selectedLeadSource:null!=r?r:""}),this.isSubmitting=!1,this.tourIsBooked=!0}catch(e){const t=e.response.data.detail||"Failed to book tour";alert(t),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
925
+ `;class ii{constructor(e,t,n,i){this.org=e,this.building=t,this.chatId=n,this.incomingProcessedLeadSource=i,this.featureFlags={}}setFeatureFlags(e){this.featureFlags={...this.featureFlags,...e}}ping(e){var t;fetch("https://app.meetelise.com/platformApi/connectors/talk_js/analytics",{method:"POST",credentials:"omit",keepalive:!0,headers:{"content-type":"application/json; charset=UTF-8"},body:JSON.stringify({eventType:e,chatId:this.chatId,url:location.href,org:this.org,building:this.building,referrer:document.referrer,featureFlags:this.featureFlags,campaignSources:ri(),incomingProcessedLeadSource:this.incomingProcessedLeadSource,webchatVersion:null!==(t="MISSING_ENV_VAR".npm_package_version)&&void 0!==t?t:"1.20.155"})})}}const ri=()=>{var e,t,n,i,r,o;try{const i=new URL(window.location.href).searchParams,r=null!==(n=null===(t=null===(e=window.RCTPCampaign)||void 0===e?void 0:e.CampaignDetails)||void 0===t?void 0:t.Source)&&void 0!==n?n:null,o=i.get("switch_cls[id]");return{entrataCampaignSource:o,realpageCampaignSource:i.get("ilm"),utmCampaignSource:i.get("utm_source"),yardiCampaignSource:r}}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};const n=t.contentWindow.URL;if(!n)return{entrataCampaignSource:null,realpageCampaignSource:null,utmCampaignSource:null,yardiCampaignSource:null};const a=new n(window.location.href).searchParams,s=null!==(o=null===(r=null===(i=window.RCTPCampaign)||void 0===i?void 0:i.CampaignDetails)||void 0===r?void 0:r.Source)&&void 0!==o?o:null;return{entrataCampaignSource:a.get("switch_cls[id]"),realpageCampaignSource:a.get("ilm"),utmCampaignSource:a.get("utm_source"),yardiCampaignSource:s}}};var oi;!function(e){e.error="error",e.info="info",e.warn="warn"}(oi||(oi={}));const ai=async({logType:e,buildingSlug:n,orgSlug:i,logTitle:r,logData:o})=>{await t().post("https://app.meetelise.com/platformApi/webchat/logging",{...o},{headers:{"Content-Type":"application/json","building-slug":null!=n?n:"","org-slug":null!=i?i:"","log-type":null!=e?e:oi.error,"log-title":r.toUpperCase().replace(/\s/g,"_")}})};var si=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a};let ui=class extends re{constructor(){super(...arguments),this.layoutOptions=[],this.unitOptions=[],this.tourTypeOptions=[],this.chatId="",this.buildingId=0,this.buildingSlug="",this.sgtUrl="",this.escortedToursLink="",this.virtualToursLink="",this.orgSlug="",this.hasDynamicSchedulingEnabled=!1,this.buildingName="",this.tourType=null,this.shouldShowTourType={[li.Guided]:!0,[li.Self]:!0,[li.Virtual]:!0},this.email="",this.phoneNumber="",this.availabilitiesGroupedByDay={},this.waitingForAvailabilities=!0,this.mobilePageIndex=0,this.isSubmitting=!1,this.tourIsBooked=!1,this.leadSources=[],this.currentLeadSource="",this.featureFlagShowDropdown="",this.compactDesign=!1,this.brandColor=Fe,this.errorGettingAvailabilities=!1,this.firstUpdated=async()=>{try{const e=await(async()=>{var e,t,n,i,r,o;return{[li.Guided]:!!(null===(t=null===(e=await Un(gn.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.WithAgent))||void 0===e?void 0:e.availableTourStartTimes)||void 0===t?void 0:t.length),[li.Self]:!!(null===(i=null===(n=await Un(gn.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.SelfGuided))||void 0===n?void 0:n.availableTourStartTimes)||void 0===i?void 0:i.length),[li.Virtual]:!!(null===(o=null===(r=await Un(gn.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.VirtualShowing))||void 0===r?void 0:r.availableTourStartTimes)||void 0===o?void 0:o.length)}})();ai({logTitle:"AVAILABILITIES_EXIST_FOR_TOUR_TYPE",logData:e,logType:oi.info,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});const t=Object.values(e).every((e=>!1===e));if(t)return this.errorGettingAvailabilities=!0,this.waitingForAvailabilities=!1,void ai({logTitle:"NO_AVAILABILITIES_EXIST",logData:null,logType:oi.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});if(this.shouldShowTourType={[li.Guided]:this.tourTypeOptions.map((e=>e.value)).includes("WITH_AGENT")&&e[li.Guided],[li.Self]:this.tourTypeOptions.map((e=>e.value)).includes("SELF_GUIDED")&&e[li.Self],[li.Virtual]:this.tourTypeOptions.map((e=>e.value)).includes("VIRTUAL_SHOWING")&&e[li.Virtual]},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 qn(di[this.tourType]),this.waitingForAvailabilities=!1}catch(e){this.errorGettingAvailabilities=!0,this.waitingForAvailabilities=!1,ai({logTitle:"ERROR_LOADING_AVAILABILITIES",logData:{error:e},logType:oi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this.willUpdate=async e=>{e.has("tourType")&&this.tourType&&(this.availabilitiesGroupedByDay=await qn(di[this.tourType]))},this.handlePhoneKeydown=e=>{var t;if(!(e instanceof KeyboardEvent&&e.target instanceof HTMLInputElement&&null!==e.target.selectionStart))return;const n=e.target.selectionStart;if(1!==e.key.length||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,i=this.phoneNumber.slice(0,n).replace(/\D/g,""),r=this.phoneNumber.slice(n).replace(/\D/g,""),o=`${i.slice(0,-1)}${r}`;this.phoneNumber=Ie(o),this.phoneInput.value=this.phoneNumber;const a=n-(t-this.phoneNumber.length);return this.phoneInput.setSelectionRange(a,a),e.preventDefault(),void e.stopPropagation()}if(!["ArrowLeft","ArrowRight"].includes(e.key)||Re(e)||e.shiftKey)return;if("ArrowLeft"===e.key){const e=((null===(t=this.phoneNumber.slice(0,n).split(/\d+/).at(-1))||void 0===t?void 0:t.length)||0)+1,i=n-e>-1?n-e:0;this.phoneInput.setSelectionRange(i,i)}if("ArrowRight"===e.key){const e=(this.phoneNumber.slice(n).split(/\d+/)[0].length||0)+1,t=n+e<this.phoneNumber.length?n+e:this.phoneNumber.length;this.phoneInput.setSelectionRange(t,t)}e.preventDefault(),e.stopPropagation()}else{e.preventDefault(),e.stopPropagation();const t=this.phoneNumber.slice(0,n)+e.key+this.phoneNumber.slice(n);this.phoneNumber=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 n=this.phoneInput.selectionStart,i=n?this.phoneInput.value.slice(n).replace(/\D/g,""):"";this.phoneNumber=Ie(this.phoneInput.value);let r=0,o=i.length;for(;o;)(null===(t=this.phoneNumber.at(r))||void 0===t?void 0:t.match(/\d/))&&o--,r++;const a=this.phoneInput.value.length-r+1;this.phoneInput.setSelectionRange(a,a)},this.onChangeEmail=e=>{e.target&&(this.email=e.target.value)},this.validators={tourType:()=>null!==this.tourType,dateAndTime:()=>!!this.selectedDate&&!!this.selectedTime,leadInfo:()=>{var e,t,n;return(!!(null===(e=this.firstNameInput)||void 0===e?void 0:e.value)||!!(null===(t=this.lastNameInput)||void 0===t?void 0:t.value))&&(null===(n=this.emailInput)||void 0===n?void 0:n.value.includes("@"))&&!!this.phoneNumber&&14===this.phoneNumber.length}},this.formIsValidForSubmission=()=>this.validators.tourType()&&this.validators.dateAndTime()&&this.validators.leadInfo(),this.timeStringToHoursAndMinutes=e=>{const[t,n]=e.split(/\D/g);return[parseInt(t)+(e.toLowerCase().includes("pm")?12:0),parseInt(n)]},this.submit=async()=>{var e,n;if(!this.selectedDate||!this.selectedTime||null===this.tourType)return;const i=new URLSearchParams(window.location.search),r=this.selectedLeadSource&&this.selectedLeadSource.value?this.selectedLeadSource.value:this.currentLeadSource,o=[...new Set(r?[r,"property-website"]:["property-website"])];Zn("scheduleTourSubmitted",{email:this.email,phone:`+1${null===(e=this.phoneNumber.match(/\d/g))||void 0===e?void 0:e.join("")}`,firstName:this.firstNameInput.value,lastName:this.lastNameInput.value,tourType:ci[this.tourType],tourTime:`${this.selectedTime.datetime}${this.selectedTime.offset}`,originatingSource:o.find((e=>"property-website"!==e))||null});const a={referrer:document.referrer,email_address:this.email,phone_number:`+1${null===(n=this.phoneNumber.match(/\d/g))||void 0===n?void 0:n.join("")}`,building_id:this.buildingId,first_name:this.firstNameInput.value,last_name:this.lastNameInput.value,tour_type:ci[this.tourType],tour_time:`${this.selectedTime.datetime}${this.selectedTime.offset}`,lead_sources:[...new Set(r?[r,"property-website"]:["property-website"])],query_params:Object.fromEntries(i.entries())};this.isSubmitting=!0;try{await t().post("https://app.meetelise.com/platformApi/state/create/v2/scheduleMe",a,{headers:{"building-slug":this.buildingSlug,"X-SecurityKey":"JRL8jV4VcSCwOSir5gWkpgNLfKghmhBG","org-slug":this.orgSlug}}),await Gn({chatId:this.chatId,website:window.location.origin,referrer:document.referrer,buildingSlug:this.buildingSlug,selectedLeadSource:null!=r?r:""}),this.isSubmitting=!1,this.tourIsBooked=!0}catch(e){const t=e.response.data.detail||"Failed to book tour";alert(t),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
926
926
  id="schedule-bttn"
927
927
  .onClick=${this.submit}
928
928
  .isLoading=${this.isSubmitting}
@@ -3485,7 +3485,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
3485
3485
  target="_blank"
3486
3486
  rel="noopener noreferrer"
3487
3487
  >${e}
3488
- </a>`}return U`${t} `}))}<br />`:U``}))}`,this.imagesToDisplay=r,Promise.all(i).then((e=>{this.websitePreviewInfo=e}))}removeTrailingPunctuation(e){return[".",",","!","?",":",";"].includes(e[e.length-1])?this.removeTrailingPunctuation(e.slice(0,-1)):e}mapAndMarkHyperLinks(e){const t=Array.from(e.matchAll(/<https?:\/\/[^|]+\|[^>]+>|<a href="https?:\/\/[^"]+">[^<]+<\/a>/g)),n=[],i=t.map((t=>{const n=t[0];if(void 0===t.index)return;const i=e[t.index-1],r=e[t.index+n.length];if(n.startsWith("<https")||n.startsWith("<http"))return{matchedLink:n,link:n.split("|")[0].replace("<",""),hyperlink:n.split("|")[1].replace(">",""),addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)};{const e=n.match(/href="([^"]+)"/),t=n.match(/>[^<]+</);return{matchedLink:n,link:e?e[1]:"",hyperlink:t?t[0].slice(1,-1):"",addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)}}}));return i.forEach((t=>{if(t&&t.link&&t.hyperlink){const i=Or().replace(/-/g,"");n.push({link:this.removeTrailingPunctuation(t.link),hyperlink:this.removeTrailingPunctuation(t.hyperlink),mark:t.matchedLink,id:i}),e=e.replace(t.matchedLink,`${t.addSpaceBefore?" ":""}${i}${t.addSpaceAfter?" ":""}`)}})),{hyperlinks:n,markedText:e}}async getLinkData(e){var n,i,r,o;try{const a=(await t().get(e)).data,s=(new DOMParser).parseFromString(a,"text/html");return s?{title:null!==(i=null===(n=s.querySelector("title"))||void 0===n?void 0:n.textContent)&&void 0!==i?i:null,description:(null===(r=s.querySelector('meta[name="description"]'))||void 0===r?void 0:r.getAttribute("content"))||null,image:(null===(o=s.querySelector('meta[property="og:image"]'))||void 0===o?void 0:o.getAttribute("content"))||null,favicon:null,link:e}:{title:null,description:null,image:null,favicon:null,link:e}}catch(t){return console.error("Error fetching website details:",t),{title:null,description:null,image:null,favicon:null,link:e}}}updated(){this.onMount()}render(){return this.message?U`<div class="message-inner-body">
3488
+ </a>`}return U`${t} `}))}<br />`:U``}))}`,this.imagesToDisplay=r,Promise.all(i).then((e=>{this.websitePreviewInfo=e}))}removeTrailingPunctuation(e){return[".",",","!","?",":",";"].includes(e[e.length-1])?this.removeTrailingPunctuation(e.slice(0,-1)):e}mapAndMarkHyperLinks(e){const t=Array.from(e.matchAll(/<https?:\/\/[^|]+\|[^>]+>|<a href="https?:\/\/[^"]+"(?: target="[^"]*")?>[^<]+<\/a>/g)),n=[],i=t.map((t=>{const n=t[0];if(void 0===t.index)return;const i=e[t.index-1],r=e[t.index+n.length];if(n.startsWith("<https")||n.startsWith("<http"))return{matchedLink:n,link:n.split("|")[0].replace("<",""),hyperlink:n.split("|")[1].replace(">",""),addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)};{const e=n.match(/href="([^"]+)"/),t=n.match(/>[^<]+</);return{matchedLink:n,link:e?e[1]:"",hyperlink:t?t[0].slice(1,-1):"",addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)}}}));return i.forEach((t=>{if(t&&t.link&&t.hyperlink){const i=Or().replace(/-/g,"");n.push({link:this.removeTrailingPunctuation(t.link),hyperlink:this.removeTrailingPunctuation(t.hyperlink),mark:t.matchedLink,id:i}),e=e.replace(t.matchedLink,`${t.addSpaceBefore?" ":""}${i}${t.addSpaceAfter?" ":""}`)}})),{hyperlinks:n,markedText:e}}async getLinkData(e){var n,i,r,o;try{const a=(await t().get(e)).data,s=(new DOMParser).parseFromString(a,"text/html");return s?{title:null!==(i=null===(n=s.querySelector("title"))||void 0===n?void 0:n.textContent)&&void 0!==i?i:null,description:(null===(r=s.querySelector('meta[name="description"]'))||void 0===r?void 0:r.getAttribute("content"))||null,image:(null===(o=s.querySelector('meta[property="og:image"]'))||void 0===o?void 0:o.getAttribute("content"))||null,favicon:null,link:e}:{title:null,description:null,image:null,favicon:null,link:e}}catch(t){return console.error("Error fetching website details:",t),{title:null,description:null,image:null,favicon:null,link:e}}}updated(){this.onMount()}render(){return this.message?U`<div class="message-inner-body">
3489
3489
  <p
3490
3490
  class=${fe({"message-text":!0,"webchat-font__desktop":!ln(),"webchat-font__mobile":ln()})}
3491
3491
  >
@@ -117,7 +117,7 @@ export class PubnubMessage extends LitElement {
117
117
  } {
118
118
  // Updated regex to match both formats (EliseAI and embedded links)
119
119
  const regex =
120
- /<https?:\/\/[^|]+\|[^>]+>|<a href="https?:\/\/[^"]+">[^<]+<\/a>/g;
120
+ /<https?:\/\/[^|]+\|[^>]+>|<a href="https?:\/\/[^"]+"(?: target="[^"]*")?>[^<]+<\/a>/g;
121
121
 
122
122
  const matches = Array.from(text.matchAll(regex));
123
123
  const listHyperlinks: {
package/src/analytics.ts CHANGED
@@ -75,19 +75,63 @@ export default class Analytics {
75
75
  }
76
76
 
77
77
  export const getCampaignSources = (): CampaignSources => {
78
- const queryParams = new URL(window.location.href).searchParams;
79
- const yardiCampaignSource =
80
- window.RCTPCampaign?.CampaignDetails?.Source ?? null;
81
- const entrataCampaignSource = queryParams.get("switch_cls[id]");
82
- const realpageCampaignSource = queryParams.get("ilm");
83
- const utmCampaignSource = queryParams.get("utm_source");
78
+ try {
79
+ const queryParams = new URL(window.location.href).searchParams;
80
+ const yardiCampaignSource =
81
+ window.RCTPCampaign?.CampaignDetails?.Source ?? null;
82
+ const entrataCampaignSource = queryParams.get("switch_cls[id]");
83
+ const realpageCampaignSource = queryParams.get("ilm");
84
+ const utmCampaignSource = queryParams.get("utm_source");
84
85
 
85
- return {
86
- entrataCampaignSource,
87
- realpageCampaignSource,
88
- utmCampaignSource,
89
- yardiCampaignSource,
90
- };
86
+ return {
87
+ entrataCampaignSource,
88
+ realpageCampaignSource,
89
+ utmCampaignSource,
90
+ yardiCampaignSource,
91
+ };
92
+ } catch (e) {
93
+ /**
94
+ * Some clients have pages that overwrite the `URL` class and turn it into a string. This is a workaround for that.
95
+ * Example site: https://ther3.com
96
+ */
97
+ // eslint-disable-next-line no-console
98
+ console.warn(`Couldnt get campaign sources from url, error: ${e}`);
99
+ const iframe = document.createElement("iframe");
100
+ iframe.style.display = "none";
101
+ document.body.appendChild(iframe);
102
+ if (!iframe.contentWindow) {
103
+ return {
104
+ entrataCampaignSource: null,
105
+ realpageCampaignSource: null,
106
+ utmCampaignSource: null,
107
+ yardiCampaignSource: null,
108
+ };
109
+ }
110
+
111
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
112
+ const OriginalURL = (iframe.contentWindow as any).URL;
113
+ if (!OriginalURL) {
114
+ return {
115
+ entrataCampaignSource: null,
116
+ realpageCampaignSource: null,
117
+ utmCampaignSource: null,
118
+ yardiCampaignSource: null,
119
+ };
120
+ }
121
+ const queryParams = new OriginalURL(window.location.href).searchParams;
122
+ const yardiCampaignSource =
123
+ window.RCTPCampaign?.CampaignDetails?.Source ?? null;
124
+ const entrataCampaignSource = queryParams.get("switch_cls[id]");
125
+ const realpageCampaignSource = queryParams.get("ilm");
126
+ const utmCampaignSource = queryParams.get("utm_source");
127
+
128
+ return {
129
+ entrataCampaignSource,
130
+ realpageCampaignSource,
131
+ utmCampaignSource,
132
+ yardiCampaignSource,
133
+ };
134
+ }
91
135
  };
92
136
 
93
137
  export enum LogType {