@meetelise/chat 1.22.0 → 1.22.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/public/demo/index.html +1 -10
- package/public/dist/index.js +3 -3
- package/src/MEChat.ts +5 -1
- package/src/WebComponent/me-chat.ts +16 -14
package/package.json
CHANGED
package/public/demo/index.html
CHANGED
|
@@ -151,22 +151,13 @@
|
|
|
151
151
|
console.log("Widget loaded");
|
|
152
152
|
};
|
|
153
153
|
|
|
154
|
-
/**
|
|
155
|
-
* Put a chat ID here to debug a specific state locally.
|
|
156
|
-
*
|
|
157
|
-
* Note: chat IDs expire after 24h of inactivity.
|
|
158
|
-
*
|
|
159
|
-
* Format: webchat_lead_<uuid>_<building_slug>
|
|
160
|
-
*/
|
|
161
|
-
window.eliseAiDebug = window.eliseAiDebug || {};
|
|
162
|
-
window.eliseAiDebug.chatIdOverride = "";
|
|
163
|
-
|
|
164
154
|
MEChat.start({
|
|
165
155
|
// organization: "avb",
|
|
166
156
|
// building: "ava-somerville-2",
|
|
167
157
|
|
|
168
158
|
organization: "elise-ai",
|
|
169
159
|
building: "the-cambridge-house-3",
|
|
160
|
+
// widgetType: "utilities",
|
|
170
161
|
|
|
171
162
|
// organization: "7e352741-1120-4ccf-9929-5dc99193a908",
|
|
172
163
|
// building: "870b418e-3301-11ef-87be-c3b83c8280bf",
|
package/public/dist/index.js
CHANGED
|
@@ -4250,7 +4250,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
|
|
|
4250
4250
|
I agree
|
|
4251
4251
|
</button>
|
|
4252
4252
|
</div>
|
|
4253
|
-
`;var wo=n(308),So=n.n(wo),To=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 xo=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=Xn.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.onWidgetLoaded=So(),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.setupWebchat=async()=>{if(!this.buildingSlug||!this.orgSlug)return;const e=await wi(this.orgSlug,this.buildingSlug);if(Math.random()<.2)try{(async(e,n)=>{const i=window.rentgrata;if(!i)return;const r=i.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!=n?n:""}})})(this.buildingSlug,this.orgSlug)}catch(e){console.warn("Error updating rentgrata token",e)}e.conversationMaintenanceMode?console.warn("MeetElise Chat is in maintenance mode. Chat icon will not appear."):1===e.active?(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)):console.warn("MeetElise has detected this building is NOT active. Chat icon will not appear.")},this.setBuildingDerivedInfo=async()=>{var e,n,i,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;const k=this.building;if(!k)return;k&&this.orgSlug&&Co(this.orgSlug,this.buildingSlug,null!==(n=null===(e=this.LeadSourceClient)||void 0===e?void 0:e.leadSource)&&void 0!==n?n:null);const[U,L,B,q,J,j]=await Promise.all([Ci(this.buildingSlug),Er(this.orgSlug,this.buildingSlug),Yn(this.buildingSlug),$n(this.buildingSlug),Ai(k.id),Zn(this.buildingSlug)]);this.building&&(this.building.phoneNumber=Ne(k.phoneNumber)),this.designConcept=null!==(i=null==U?void 0:U.abTestType)&&void 0!==i?i:"",this.leadSources=L,this.featureFlagShowDropdown=B;const H=k.textWithUsPhoneNumber?k.textWithUsPhoneNumber:await(async e=>{try{const n="https://app.meetelise.com",i=await t().get(`${n}/platformApi/webchat/${e}/phone-number`);if(i.data)return i.data}catch(t){return li({logType:si.error,buildingSlug:e,logTitle:"[ERROR_GETTING_PHONE_NUMBERS]",logData:{error:t}}),null}return null})(this.buildingSlug);var G,z;this.enabledChatWidgets={callDesktop:!(null===(r=null==J?void 0:J.config.shouldShowPhone)||void 0===r||!r)||null!==(o=null==J?void 0:J.config.shouldShowPhoneDesktop)&&void 0!==o&&o,callMobile:!(null===(a=null==J?void 0:J.config.shouldShowPhone)||void 0===a||!a)||null!==(s=null==J?void 0:J.config.shouldShowPhoneMobile)&&void 0!==s&&s,chatDesktop:!(null===(l=null==J?void 0:J.config.shouldShowChat)||void 0===l||!l)||null!==(u=null==J?void 0:J.config.shouldShowChatDesktop)&&void 0!==u&&u,chatMobile:!(null===(d=null==J?void 0:J.config.shouldShowChat)||void 0===d||!d)||null!==(c=null==J?void 0:J.config.shouldShowChatMobile)&&void 0!==c&&c,emailDesktop:!(null===(p=null==J?void 0:J.config.shouldShowEmail)||void 0===p||!p)||null!==(h=null==J?void 0:J.config.shouldShowEmailDesktop)&&void 0!==h&&h,emailMobile:!(null===(f=null==J?void 0:J.config.shouldShowEmail)||void 0===f||!f)||null!==(m=null==J?void 0:J.config.shouldShowEmailMobile)&&void 0!==m&&m,textDesktop:(!(null===(g=null==J?void 0:J.config.shouldShowText)||void 0===g||!g)||null!==(v=null==J?void 0:J.config.shouldShowTextDesktop)&&void 0!==v&&v)&&!!H,textMobile:(!(null===(y=null==J?void 0:J.config.shouldShowText)||void 0===y||!y)||null!==(b=null==J?void 0:J.config.shouldShowTextMobile)&&void 0!==b&&b)&&!!H,sstDesktop:!(null===(w=null==J?void 0:J.config.shouldShowSst)||void 0===w||!w)||null!==(S=null==J?void 0:J.config.shouldShowSstDesktop)&&void 0!==S&&S,sstMobile:!(null===(T=null==J?void 0:J.config.shouldShowSst)||void 0===T||!T)||null!==(x=null==J?void 0:J.config.shouldShowSstMobile)&&void 0!==x&&x},this.enabledChatWidgets.sstDesktop||this.enabledChatWidgets.sstMobile?(z=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(),z(e)}))})),((e,t,n)=>{if("be948f76-d8f9-11eb-b710-2bc5b16e7492"===t){const e=document.querySelector('a[href="/schedule-a-tour/"]');e&&e.addEventListener("click",(e=>{e.preventDefault(),n(e)}))}})(this.orgSlug,this.buildingSlug,this.handleTourClicked)):(null===(A=this.LeadSourceClient)||void 0===A?void 0:A.leadSource)&&(G=null!==(O=null===(C=this.LeadSourceClient)||void 0===C?void 0:C.leadSource)&&void 0!==O?O:null,document.querySelectorAll("a").forEach((function(e){const t=e.getAttribute("href");if(t&&t.startsWith("https://app.meetelise.com/")){const n=t.includes("?")?"&":"?";e.setAttribute("href",t+n+`eliseParsedLeadSource=${encodeURIComponent(G)}`)}}))),J&&J.config&&(this.brandColor=null!==(I=J.config.primaryColor)&&void 0!==I?I:null,this.backgroundColor=null!==(N=J.config.backgroundColor)&&void 0!==N?N:null,this.webchatConfigHasAutoOpenChat=J.config.autoOpenChat,this.requiresConsent=J.config.requiresConsent,this.hideMobileFeatures=J.config.hideMobileFeatures,this.privacyPolicyUrl=null!==(E=J.config.privacyPolicyUrl)&&void 0!==E?E:this.privacyPolicyUrl,J.config.displayStyle===Ti.MINIMIZED&&(this.isMinimized=!0),J.config.displayStyle===Ti.PILLS&&(this.designConcept=null),J.config.displayStyle===Ti.EMOJI&&(this.designConcept=Ti.EMOJI),this.onWidgetLoaded()),null===this.brandColor&&(this.brandColor=Me),null===this.backgroundColor&&(this.backgroundColor=Fe);const W=null!==(_=null===(R=this.building)||void 0===R?void 0:R.phoneNumber)&&void 0!==_?_:"";let V=null;q&&(V=await async function(e,n){try{const i=await t().get(`https://app.meetelise.com/platformApi/webchat/${e}/phone-number-by-source?source=${n}`);return i.data?{number:Ne(i.data.number),isMatch:i.data.match,isPropertyWebsiteCatchall:i.data.isPropertyWebsiteCatchall}:null}catch(e){return null}}(this.buildingSlug,null!==(M=null===(P=this.LeadSourceClient)||void 0===P?void 0:P.leadSource)&&void 0!==M?M:null),V&&!V.isMatch&&(V.number=W)),j&&(null==V?void 0:V.number)&&Xr(V.number,this.orgSlug,this.buildingSlug);const Q=localStorage.getItem("eliseai_phone_number_devtest");Q&&(console.info("Using dev test phone number: ",Q),Xr(Q,this.orgSlug,this.buildingSlug)),this.phoneNumberForSource=V||{number:W,isMatch:!1,isPropertyWebsiteCatchall:!0};const K=null!==(D=null===(F=this.LeadSourceClient)||void 0===F?void 0:F.leadSource)&&void 0!==D?D:null;K&&(this.leadSources.includes(K)||this.leadSources.push(K)),qn(k.id)},this.initializeChatVariables=async()=>{var e,n,i,r,o,a,s,l;if(!this.building)return;const u=Hr(this.buildingSlug),d=Gr(this.buildingSlug,u)?u:jr(this.buildingSlug,!1);if(!d.leadId)throw new Error("Lead ID is null");const c=null===(e=window.eliseAiDebug)||void 0===e?void 0:e.chatIdOverride,p=c?c.split("_").slice(1).join("_"):d.leadId;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,n)=>{const i=this.getLeadSourceBodyIfValid(e);if(i&&!pn(i.timestamp,24*this.localStorageTTLDays))return{...i,timestamp:Cn(i.timestamp)};const r=ui();this.leadSourceInput={websiteOrigin:window.location.origin,websiteSearch:window.location.search,queryParameters:r,referrer:document.referrer,parsedUtmSource:r?r.utm_source:null,campaignSources:Object.values(ai()).filter((e=>e))};const o={leadSource:t,leadId:n,buildingSlug:e,timestamp:yn(new Date),leadSourceInput:this.leadSourceInput};return localStorage.setItem("com.elise.webchat.leadsource.slug="+e,JSON.stringify(o)),{...o,timestamp:Cn(o.timestamp)}},this.getLeadSourceBodyIfValid=e=>{const t=localStorage.getItem("com.elise.webchat.leadsource.slug="+e);if(t)try{const n=JSON.parse(t);if(n.buildingSlug===e&&n.leadSource&&n.leadId&&n.timestamp&&!pn(Cn(n.timestamp),24*this.localStorageTTLDays)){try{this.leadSourceInput=n.leadSourceInput}catch(e){console.error("Error parsing leadSourceInput from localStorage")}return n}}catch(e){return null}return null}}async fetchCurrentParsedLeadSource({buildingSlug:e,queryParams:n,referrer:i,campaignSources:r}){try{return(await t().post(`${this.apiHost}/platformApi/webchat/current-parsed-lead-source`,{query_params:n,building_slug:e,referrer:i,campaign_sources:r})).data}catch(e){return null}}async checkAndHandleForLogLeadSource({webchatAction:e,stateId:n}){var i,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===(i=window.dataLayer.find((e=>{var t;return"gtagApiGet"==(null===(t=e.value)||void 0===t?void 0:t.event)})))||void 0===i?void 0:i.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:n,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:pi()(d)?null:d,extras:null!=c?c:null}),null}catch(e){return null}}async getCookieValue(e){try{const t=document.cookie.split(";");for(let n=0;n<t.length;n++){const i=t[n].trim();if(i.startsWith(e+"="))return i.substring((e+"=").length,-1===i.indexOf(";")?void 0:i.indexOf(";"))}return null}catch(e){console.error("error getting cookie value")}return null}async generateUserLeadSource({leadId:e,orgSlug:t,buildingSlug:n}){try{const i={queryParams:ui(),buildingSlug:n,referrer:document.referrer,campaignSources:ai()},r=n?this.getLeadSourceBodyIfValid(n):null;if(r)return this.leadSource=r.leadSource,this.leadSource;const o=await this.fetchCurrentParsedLeadSource(i);if(this.leadSource=o,this.buildingId=null,this.orgSlug=t,this.buildingSlug=n,n&&!o){const e=this.getLeadSourceBodyIfValid(n);if(e)return this.leadSource=e.leadSource,this.leadSource}return n&&o&&this.updateLeadSourceLocalStorage(n,o,e),o}catch(e){console.error(e)}return null}},this.myPubnub=new Kr(this.buildingSlug,this.building,this.orgSlug,null,p,this.LeadSourceClient),this.LeadSourceClient.chatId=this.myPubnub.channel,await(null===(n=this.LeadSourceClient)||void 0===n?void 0:n.generateUserLeadSource({leadId:null!==(r=null===(i=this.myPubnub)||void 0===i?void 0:i.leadUserId)&&void 0!==r?r:"",orgSlug:this.orgSlug,buildingSlug:this.buildingSlug})),"property-website"!==hi(this.orgSlug)?this.myPubnub.leadSource=null!==(a=null===(o=this.LeadSourceClient)||void 0===o?void 0:o.leadSource)&&void 0!==a?a:hi(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),c&&(u.initiatedChat=!0),await this.myPubnub.initializePubnub(u)},this.shouldAutoOpenChat=e=>{const t=sessionStorage.getItem("alreadyAutoOpenedTimestamp"),n=!t||!(t&&!xn(Cn(t)));return!!e&&!!n&&!cn()},this.updateAlreadyAutoOpenedTimestamp=()=>{sessionStorage.setItem("alreadyAutoOpenedTimestamp",yn(function(e,t){Le(2,arguments);var n=tt(t);return nt(e,6e4*n)}(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,n;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===(n=this.launcherRef.value)||void 0===n||n.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,n,i;const r=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("chatAdditionalActionsPubnub");if(!r)return;const o=null===(i=null===(n=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("pubnub-chat"))||void 0===n?void 0:n.shadowRoot)||void 0===i?void 0:i.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,n,i,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===(i=null===(n=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("pubnub-chat"))||void 0===n?void 0:n.shadowRoot)||void 0===i?void 0:i.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)=>U` <div
|
|
4253
|
+
`;var wo=n(308),So=n.n(wo),To=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 xo=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=Xn.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="default",this.onWidgetLoaded=So(),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.setupWebchat=async()=>{if("utilities"===this.widgetType)return void(Math.random()<.05&&li({logType:si.info,logTitle:"[UTILITY_WIDGET_TYPE_DETECTED]",logData:{widgetType:this.widgetType,url:window.location.href}}));if(!this.buildingSlug||!this.orgSlug)return;const e=await wi(this.orgSlug,this.buildingSlug);if(Math.random()<.2)try{(async(e,n)=>{const i=window.rentgrata;if(!i)return;const r=i.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!=n?n:""}})})(this.buildingSlug,this.orgSlug)}catch(e){console.warn("Error updating rentgrata token",e)}e.conversationMaintenanceMode?console.warn("MeetElise Chat is in maintenance mode. Chat icon will not appear."):1===e.active?(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)):console.warn("MeetElise has detected this building is NOT active. Chat icon will not appear.")},this.setBuildingDerivedInfo=async()=>{var e,n,i,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;const k=this.building;if(!k)return;k&&this.orgSlug&&Co(this.orgSlug,this.buildingSlug,null!==(n=null===(e=this.LeadSourceClient)||void 0===e?void 0:e.leadSource)&&void 0!==n?n:null);const[U,L,B,q,J,j]=await Promise.all([Ci(this.buildingSlug),Er(this.orgSlug,this.buildingSlug),Yn(this.buildingSlug),$n(this.buildingSlug),Ai(k.id),Zn(this.buildingSlug)]);this.building&&(this.building.phoneNumber=Ne(k.phoneNumber)),this.designConcept=null!==(i=null==U?void 0:U.abTestType)&&void 0!==i?i:"",this.leadSources=L,this.featureFlagShowDropdown=B;const H=k.textWithUsPhoneNumber?k.textWithUsPhoneNumber:await(async e=>{try{const n="https://app.meetelise.com",i=await t().get(`${n}/platformApi/webchat/${e}/phone-number`);if(i.data)return i.data}catch(t){return li({logType:si.error,buildingSlug:e,logTitle:"[ERROR_GETTING_PHONE_NUMBERS]",logData:{error:t}}),null}return null})(this.buildingSlug);var G,z;this.enabledChatWidgets={callDesktop:!(null===(r=null==J?void 0:J.config.shouldShowPhone)||void 0===r||!r)||null!==(o=null==J?void 0:J.config.shouldShowPhoneDesktop)&&void 0!==o&&o,callMobile:!(null===(a=null==J?void 0:J.config.shouldShowPhone)||void 0===a||!a)||null!==(s=null==J?void 0:J.config.shouldShowPhoneMobile)&&void 0!==s&&s,chatDesktop:!(null===(l=null==J?void 0:J.config.shouldShowChat)||void 0===l||!l)||null!==(u=null==J?void 0:J.config.shouldShowChatDesktop)&&void 0!==u&&u,chatMobile:!(null===(d=null==J?void 0:J.config.shouldShowChat)||void 0===d||!d)||null!==(c=null==J?void 0:J.config.shouldShowChatMobile)&&void 0!==c&&c,emailDesktop:!(null===(p=null==J?void 0:J.config.shouldShowEmail)||void 0===p||!p)||null!==(h=null==J?void 0:J.config.shouldShowEmailDesktop)&&void 0!==h&&h,emailMobile:!(null===(f=null==J?void 0:J.config.shouldShowEmail)||void 0===f||!f)||null!==(m=null==J?void 0:J.config.shouldShowEmailMobile)&&void 0!==m&&m,textDesktop:(!(null===(g=null==J?void 0:J.config.shouldShowText)||void 0===g||!g)||null!==(v=null==J?void 0:J.config.shouldShowTextDesktop)&&void 0!==v&&v)&&!!H,textMobile:(!(null===(y=null==J?void 0:J.config.shouldShowText)||void 0===y||!y)||null!==(b=null==J?void 0:J.config.shouldShowTextMobile)&&void 0!==b&&b)&&!!H,sstDesktop:!(null===(w=null==J?void 0:J.config.shouldShowSst)||void 0===w||!w)||null!==(S=null==J?void 0:J.config.shouldShowSstDesktop)&&void 0!==S&&S,sstMobile:!(null===(T=null==J?void 0:J.config.shouldShowSst)||void 0===T||!T)||null!==(x=null==J?void 0:J.config.shouldShowSstMobile)&&void 0!==x&&x},this.enabledChatWidgets.sstDesktop||this.enabledChatWidgets.sstMobile?(z=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(),z(e)}))})),((e,t,n)=>{if("be948f76-d8f9-11eb-b710-2bc5b16e7492"===t){const e=document.querySelector('a[href="/schedule-a-tour/"]');e&&e.addEventListener("click",(e=>{e.preventDefault(),n(e)}))}})(this.orgSlug,this.buildingSlug,this.handleTourClicked)):(null===(A=this.LeadSourceClient)||void 0===A?void 0:A.leadSource)&&(G=null!==(O=null===(C=this.LeadSourceClient)||void 0===C?void 0:C.leadSource)&&void 0!==O?O:null,document.querySelectorAll("a").forEach((function(e){const t=e.getAttribute("href");if(t&&t.startsWith("https://app.meetelise.com/")){const n=t.includes("?")?"&":"?";e.setAttribute("href",t+n+`eliseParsedLeadSource=${encodeURIComponent(G)}`)}}))),J&&J.config&&(this.brandColor=null!==(I=J.config.primaryColor)&&void 0!==I?I:null,this.backgroundColor=null!==(N=J.config.backgroundColor)&&void 0!==N?N:null,this.webchatConfigHasAutoOpenChat=J.config.autoOpenChat,this.requiresConsent=J.config.requiresConsent,this.hideMobileFeatures=J.config.hideMobileFeatures,this.privacyPolicyUrl=null!==(E=J.config.privacyPolicyUrl)&&void 0!==E?E:this.privacyPolicyUrl,J.config.displayStyle===Ti.MINIMIZED&&(this.isMinimized=!0),J.config.displayStyle===Ti.PILLS&&(this.designConcept=null),J.config.displayStyle===Ti.EMOJI&&(this.designConcept=Ti.EMOJI),this.onWidgetLoaded()),null===this.brandColor&&(this.brandColor=Me),null===this.backgroundColor&&(this.backgroundColor=Fe);const W=null!==(_=null===(R=this.building)||void 0===R?void 0:R.phoneNumber)&&void 0!==_?_:"";let V=null;q&&(V=await async function(e,n){try{const i=await t().get(`https://app.meetelise.com/platformApi/webchat/${e}/phone-number-by-source?source=${n}`);return i.data?{number:Ne(i.data.number),isMatch:i.data.match,isPropertyWebsiteCatchall:i.data.isPropertyWebsiteCatchall}:null}catch(e){return null}}(this.buildingSlug,null!==(M=null===(P=this.LeadSourceClient)||void 0===P?void 0:P.leadSource)&&void 0!==M?M:null),V&&!V.isMatch&&(V.number=W)),j&&(null==V?void 0:V.number)&&Xr(V.number,this.orgSlug,this.buildingSlug);const Q=localStorage.getItem("eliseai_phone_number_devtest");Q&&(console.info("Using dev test phone number: ",Q),Xr(Q,this.orgSlug,this.buildingSlug)),this.phoneNumberForSource=V||{number:W,isMatch:!1,isPropertyWebsiteCatchall:!0};const K=null!==(D=null===(F=this.LeadSourceClient)||void 0===F?void 0:F.leadSource)&&void 0!==D?D:null;K&&(this.leadSources.includes(K)||this.leadSources.push(K)),qn(k.id)},this.initializeChatVariables=async()=>{var e,n,i,r,o,a,s;if(!this.building)return;const l=Hr(this.buildingSlug),u=Gr(this.buildingSlug,l)?l:jr(this.buildingSlug,!1);if(!u.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,n)=>{const i=this.getLeadSourceBodyIfValid(e);if(i&&!pn(i.timestamp,24*this.localStorageTTLDays))return{...i,timestamp:Cn(i.timestamp)};const r=ui();this.leadSourceInput={websiteOrigin:window.location.origin,websiteSearch:window.location.search,queryParameters:r,referrer:document.referrer,parsedUtmSource:r?r.utm_source:null,campaignSources:Object.values(ai()).filter((e=>e))};const o={leadSource:t,leadId:n,buildingSlug:e,timestamp:yn(new Date),leadSourceInput:this.leadSourceInput};return localStorage.setItem("com.elise.webchat.leadsource.slug="+e,JSON.stringify(o)),{...o,timestamp:Cn(o.timestamp)}},this.getLeadSourceBodyIfValid=e=>{const t=localStorage.getItem("com.elise.webchat.leadsource.slug="+e);if(t)try{const n=JSON.parse(t);if(n.buildingSlug===e&&n.leadSource&&n.leadId&&n.timestamp&&!pn(Cn(n.timestamp),24*this.localStorageTTLDays)){try{this.leadSourceInput=n.leadSourceInput}catch(e){console.error("Error parsing leadSourceInput from localStorage")}return n}}catch(e){return null}return null}}async fetchCurrentParsedLeadSource({buildingSlug:e,queryParams:n,referrer:i,campaignSources:r}){try{return(await t().post(`${this.apiHost}/platformApi/webchat/current-parsed-lead-source`,{query_params:n,building_slug:e,referrer:i,campaign_sources:r})).data}catch(e){return null}}async checkAndHandleForLogLeadSource({webchatAction:e,stateId:n}){var i,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===(i=window.dataLayer.find((e=>{var t;return"gtagApiGet"==(null===(t=e.value)||void 0===t?void 0:t.event)})))||void 0===i?void 0:i.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:n,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:pi()(d)?null:d,extras:null!=c?c:null}),null}catch(e){return null}}async getCookieValue(e){try{const t=document.cookie.split(";");for(let n=0;n<t.length;n++){const i=t[n].trim();if(i.startsWith(e+"="))return i.substring((e+"=").length,-1===i.indexOf(";")?void 0:i.indexOf(";"))}return null}catch(e){console.error("error getting cookie value")}return null}async generateUserLeadSource({leadId:e,orgSlug:t,buildingSlug:n}){try{const i={queryParams:ui(),buildingSlug:n,referrer:document.referrer,campaignSources:ai()},r=n?this.getLeadSourceBodyIfValid(n):null;if(r)return this.leadSource=r.leadSource,this.leadSource;const o=await this.fetchCurrentParsedLeadSource(i);if(this.leadSource=o,this.buildingId=null,this.orgSlug=t,this.buildingSlug=n,n&&!o){const e=this.getLeadSourceBodyIfValid(n);if(e)return this.leadSource=e.leadSource,this.leadSource}return n&&o&&this.updateLeadSourceLocalStorage(n,o,e),o}catch(e){console.error(e)}return null}},this.myPubnub=new Kr(this.buildingSlug,this.building,this.orgSlug,null,u.leadId,this.LeadSourceClient),this.LeadSourceClient.chatId=this.myPubnub.channel,await(null===(e=this.LeadSourceClient)||void 0===e?void 0:e.generateUserLeadSource({leadId:null!==(i=null===(n=this.myPubnub)||void 0===n?void 0:n.leadUserId)&&void 0!==i?i:"",orgSlug:this.orgSlug,buildingSlug:this.buildingSlug})),"property-website"!==hi(this.orgSlug)?this.myPubnub.leadSource=null!==(o=null===(r=this.LeadSourceClient)||void 0===r?void 0:r.leadSource)&&void 0!==o?o:hi(this.orgSlug):this.myPubnub.leadSource=null!==(s=null===(a=this.LeadSourceClient)||void 0===a?void 0:a.leadSource)&&void 0!==s?s:null,u.initiatedChat&&await this.myPubnub.initializePubnub(l)},this.shouldAutoOpenChat=e=>{const t=sessionStorage.getItem("alreadyAutoOpenedTimestamp"),n=!t||!(t&&!xn(Cn(t)));return!!e&&!!n&&!cn()},this.updateAlreadyAutoOpenedTimestamp=()=>{sessionStorage.setItem("alreadyAutoOpenedTimestamp",yn(function(e,t){Le(2,arguments);var n=tt(t);return nt(e,6e4*n)}(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,n;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===(n=this.launcherRef.value)||void 0===n||n.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,n,i;const r=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("chatAdditionalActionsPubnub");if(!r)return;const o=null===(i=null===(n=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("pubnub-chat"))||void 0===n?void 0:n.shadowRoot)||void 0===i?void 0:i.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,n,i,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===(i=null===(n=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("pubnub-chat"))||void 0===n?void 0:n.shadowRoot)||void 0===i?void 0:i.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)=>U` <div
|
|
4254
4254
|
id=${e}
|
|
4255
4255
|
class=${fe({showTab:t,hideTab:!t})}
|
|
4256
4256
|
>
|
|
@@ -4409,7 +4409,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
|
|
|
4409
4409
|
position: fixed;
|
|
4410
4410
|
bottom: 0;
|
|
4411
4411
|
}
|
|
4412
|
-
`,To([le({type:String})],xo.prototype,"buildingSlug",void 0),To([le({type:String})],xo.prototype,"orgSlug",void 0),To([le({type:Object})],xo.prototype,"launcherStyles",void 0),To([le()],xo.prototype,"mobileStyles",void 0),To([le({type:Boolean})],xo.prototype,"isMinimized",void 0),To([le({type:String})],xo.prototype,"brandColor",void 0),To([le({type:String})],xo.prototype,"backgroundColor",void 0),To([ue()],xo.prototype,"chatId",void 0),To([ue()],xo.prototype,"analytics",void 0),To([ue()],xo.prototype,"launcher",void 0),To([ue()],xo.prototype,"building",void 0),To([ue()],xo.prototype,"designConcept",void 0),To([ue()],xo.prototype,"leadSources",void 0),To([ue()],xo.prototype,"currentLeadSource",void 0),To([ue()],xo.prototype,"featureFlagShowDropdown",void 0),To([ue()],xo.prototype,"phoneNumberForSource",void 0),To([ue()],xo.prototype,"hasMounted",void 0),To([ue()],xo.prototype,"hideLauncher",void 0),To([ue()],xo.prototype,"isLoading",void 0),To([ue()],xo.prototype,"showTourNextToChat",void 0),To([ue()],xo.prototype,"displayPubnubChat",void 0),To([ue()],xo.prototype,"myPubnub",void 0),To([ue()],xo.prototype,"LeadSourceClient",void 0),To([le({type:Number})],xo.prototype,"right",void 0),To([le({type:Number})],xo.prototype,"bottom",void 0),To([le({type:Number})],xo.prototype,"top",void 0),To([le({type:Number})],xo.prototype,"left",void 0),To([le({attribute:!0})],xo.prototype,"overrideRentgrata",void 0),To([le()],xo.prototype,"onWidgetLoaded",void 0),To([ue()],xo.prototype,"enabledChatWidgets",void 0),To([ue()],xo.prototype,"webchatConfigHasAutoOpenChat",void 0),To([ue()],xo.prototype,"requiresConsent",void 0),To([ue()],xo.prototype,"hideMobileFeatures",void 0),To([ue()],xo.prototype,"privacyPolicyUrl",void 0),xo=To([ae("me-chat")],xo);const Ao=e=>{for(const t of e){const e=document.getElementById(t);if(e)return e}return null},Co=async(e,n,i)=>{var r;if(!n||!e)return;const o=await async function(e){if(!e)return!1;try{return(await t().get(Kn(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(!o)return;const a=Ao(["myContactForm","contactus","fpa-myContactForm"]);let s;if(!(a&&a instanceof HTMLFormElement)){const t=document.querySelector("form");return void(window.location.pathname.toLowerCase().includes("contactus")&&Oo(n,e,"Could not find form",t?{id:t.id}:void 0))}try{if(a.parentElement&&"scheduleTourForm"===a.parentElement.id)return Oo(n,e,"Form is apart of schedule tour form!")}catch(e){console.error("error",e)}for(let e=0;e<a.elements.length;e++){const t=a.elements[e];if("button"===t.tagName.toLowerCase()&&"fakebutton"===t.getAttribute("data-selenium-id")){s=t;break}if("fpa-contact-submit"===t.getAttribute("id")){s=t;break}}if(!s)return Oo(n,e,"Could not find submit button");const l=()=>({firstName:Ao(["firstname","txtName","fpa-firstname"]),lastName:Ao(["lastname","txtName2","fpa-lastname"]),email:Ao(["email","txtEmail","fpa-email"]),phone:Ao(["phonenumber","txtPhone","fpa-phonenumber"]),message:Ao(["message","txtComments","fpa-email"])});if(Object.values(l()).some((e=>null===e))){const t=Object.entries(l()).filter((([,e])=>null===e)).map((([e])=>e));return Oo(n,e,"Missing the following form elements: "+t.join(", "))}const u=s.textContent,d=s.cloneNode(!0);null===(r=s.parentNode)||void 0===r||r.replaceChild(d,s),d.onclick=async function(t){if(Object.values(l()).forEach((e=>{"true"!==(null==e?void 0:e.getAttribute("aria-required"))||e.value||(e.className="form-control required is-invalid")})),!Object.values(l()).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(),d.textContent="Processing request...",d.disabled=!0;const r={};Object.entries(l()).forEach((([e,t])=>r[e]=null==t?void 0:t.value));const o=await wi(e,n);if(!o)return Oo(n,e,"Could not find building"),null;const s={email_address:r.email,first_name:r.firstName,last_name:r.lastName,phone_number:r.phone,first_message:r.message,building_id:o.id,is_external_form:!0,lead_sources:[...new Set(i?[i,hi(e)]:[hi(e)])]},c=JSON.stringify(s);fetch("https://app.meetelise.com/platformApi/state/create/contactMe",{method:"POST",headers:{"Content-Type":"application/json","building-slug":n,"org-slug":e},body:c}).then((e=>{if(!e.ok)throw new Error(`HTTP error ${e.status}`);return a&&a.reset(),Object.values(l()).forEach((e=>{e&&(e.disabled=!0)})),d.textContent="Submitted",d.disabled=!0,e.json()})).catch((()=>{d.textContent=u}))}},Oo=(e,t,n,i)=>{const r=JSON.stringify({orgSlug:t,buildingSlug:e,reason:n,url:window.location.href,formIdInfo:i});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})},Io=l`
|
|
4412
|
+
`,To([le({type:String})],xo.prototype,"buildingSlug",void 0),To([le({type:String})],xo.prototype,"orgSlug",void 0),To([le({type:Object})],xo.prototype,"launcherStyles",void 0),To([le()],xo.prototype,"mobileStyles",void 0),To([le({type:Boolean})],xo.prototype,"isMinimized",void 0),To([le({type:String})],xo.prototype,"brandColor",void 0),To([le({type:String})],xo.prototype,"backgroundColor",void 0),To([ue()],xo.prototype,"chatId",void 0),To([ue()],xo.prototype,"analytics",void 0),To([ue()],xo.prototype,"launcher",void 0),To([ue()],xo.prototype,"building",void 0),To([ue()],xo.prototype,"designConcept",void 0),To([ue()],xo.prototype,"leadSources",void 0),To([ue()],xo.prototype,"currentLeadSource",void 0),To([ue()],xo.prototype,"featureFlagShowDropdown",void 0),To([ue()],xo.prototype,"phoneNumberForSource",void 0),To([ue()],xo.prototype,"hasMounted",void 0),To([ue()],xo.prototype,"hideLauncher",void 0),To([ue()],xo.prototype,"isLoading",void 0),To([ue()],xo.prototype,"showTourNextToChat",void 0),To([ue()],xo.prototype,"displayPubnubChat",void 0),To([ue()],xo.prototype,"myPubnub",void 0),To([ue()],xo.prototype,"LeadSourceClient",void 0),To([le({type:Number})],xo.prototype,"right",void 0),To([le({type:Number})],xo.prototype,"bottom",void 0),To([le({type:Number})],xo.prototype,"top",void 0),To([le({type:Number})],xo.prototype,"left",void 0),To([le({attribute:!0})],xo.prototype,"overrideRentgrata",void 0),To([le({attribute:!0})],xo.prototype,"widgetType",void 0),To([le()],xo.prototype,"onWidgetLoaded",void 0),To([ue()],xo.prototype,"enabledChatWidgets",void 0),To([ue()],xo.prototype,"webchatConfigHasAutoOpenChat",void 0),To([ue()],xo.prototype,"requiresConsent",void 0),To([ue()],xo.prototype,"hideMobileFeatures",void 0),To([ue()],xo.prototype,"privacyPolicyUrl",void 0),xo=To([ae("me-chat")],xo);const Ao=e=>{for(const t of e){const e=document.getElementById(t);if(e)return e}return null},Co=async(e,n,i)=>{var r;if(!n||!e)return;const o=await async function(e){if(!e)return!1;try{return(await t().get(Kn(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(!o)return;const a=Ao(["myContactForm","contactus","fpa-myContactForm"]);let s;if(!(a&&a instanceof HTMLFormElement)){const t=document.querySelector("form");return void(window.location.pathname.toLowerCase().includes("contactus")&&Oo(n,e,"Could not find form",t?{id:t.id}:void 0))}try{if(a.parentElement&&"scheduleTourForm"===a.parentElement.id)return Oo(n,e,"Form is apart of schedule tour form!")}catch(e){console.error("error",e)}for(let e=0;e<a.elements.length;e++){const t=a.elements[e];if("button"===t.tagName.toLowerCase()&&"fakebutton"===t.getAttribute("data-selenium-id")){s=t;break}if("fpa-contact-submit"===t.getAttribute("id")){s=t;break}}if(!s)return Oo(n,e,"Could not find submit button");const l=()=>({firstName:Ao(["firstname","txtName","fpa-firstname"]),lastName:Ao(["lastname","txtName2","fpa-lastname"]),email:Ao(["email","txtEmail","fpa-email"]),phone:Ao(["phonenumber","txtPhone","fpa-phonenumber"]),message:Ao(["message","txtComments","fpa-email"])});if(Object.values(l()).some((e=>null===e))){const t=Object.entries(l()).filter((([,e])=>null===e)).map((([e])=>e));return Oo(n,e,"Missing the following form elements: "+t.join(", "))}const u=s.textContent,d=s.cloneNode(!0);null===(r=s.parentNode)||void 0===r||r.replaceChild(d,s),d.onclick=async function(t){if(Object.values(l()).forEach((e=>{"true"!==(null==e?void 0:e.getAttribute("aria-required"))||e.value||(e.className="form-control required is-invalid")})),!Object.values(l()).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(),d.textContent="Processing request...",d.disabled=!0;const r={};Object.entries(l()).forEach((([e,t])=>r[e]=null==t?void 0:t.value));const o=await wi(e,n);if(!o)return Oo(n,e,"Could not find building"),null;const s={email_address:r.email,first_name:r.firstName,last_name:r.lastName,phone_number:r.phone,first_message:r.message,building_id:o.id,is_external_form:!0,lead_sources:[...new Set(i?[i,hi(e)]:[hi(e)])]},c=JSON.stringify(s);fetch("https://app.meetelise.com/platformApi/state/create/contactMe",{method:"POST",headers:{"Content-Type":"application/json","building-slug":n,"org-slug":e},body:c}).then((e=>{if(!e.ok)throw new Error(`HTTP error ${e.status}`);return a&&a.reset(),Object.values(l()).forEach((e=>{e&&(e.disabled=!0)})),d.textContent="Submitted",d.disabled=!0,e.json()})).catch((()=>{d.textContent=u}))}},Oo=(e,t,n,i)=>{const r=JSON.stringify({orgSlug:t,buildingSlug:e,reason:n,url:window.location.href,formIdInfo:i});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})},Io=l`
|
|
4413
4413
|
.chat-launcher {
|
|
4414
4414
|
position: fixed;
|
|
4415
4415
|
}
|
|
@@ -4570,4 +4570,4 @@ otherwise there's some empty space at the bottom of the button, which interferes
|
|
|
4570
4570
|
line-height: 150%;
|
|
4571
4571
|
font-size: 16px;
|
|
4572
4572
|
}
|
|
4573
|
-
`,Ro([le({type:String})],_o.prototype,"healthcareId",void 0),Ro([le({type:Number})],_o.prototype,"right",void 0),Ro([le({type:Number})],_o.prototype,"bottom",void 0),Ro([le({type:Number})],_o.prototype,"top",void 0),Ro([le({type:Number})],_o.prototype,"left",void 0),Ro([ue()],_o.prototype,"launcher",void 0),Ro([ue()],_o.prototype,"currentLeadSource",void 0),Ro([ue()],_o.prototype,"displayPubnubChat",void 0),Ro([ue()],_o.prototype,"myPubnub",void 0),Ro([ue()],_o.prototype,"requiresConsent",void 0),Ro([ue()],_o.prototype,"privacyPolicyUrl",void 0),Ro([ue()],_o.prototype,"isLoading",void 0),_o=Ro([ae("health-chat")],_o);class Po{static healthcareStart(e,t=!0){var n,i,r,o;t&&(this.healthcareId=e.id,this.overridePlacement={right:e.right,bottom:e.bottom,top:e.top,left:e.left}),Mo();const a=document.createElement("health-chat");a.setAttribute("class","health-chat"),a.setAttribute("role","dialog"),a.setAttribute("aria-label","EliseAI Healthcare Widget"),a.setAttribute("aria-describedby","aria-describe-info"),a.setAttribute("aria-modal","true"),a.setAttribute("healthcareId",e.id),a.setAttribute("right",(null===(n=e.right)||void 0===n?void 0:n.toString())||"unset"),a.setAttribute("bottom",(null===(i=e.bottom)||void 0===i?void 0:i.toString())||"unset"),a.setAttribute("top",(null===(r=e.top)||void 0===r?void 0:r.toString())||"unset"),a.setAttribute("left",(null===(o=e.left)||void 0===o?void 0:o.toString())||"unset"),document.body.appendChild(a),Po.healthChat=a}static start(e,t=!0){var n,i,r,o,a,s,l,u;if(window.location.pathname.includes("residentservices")||window.location.pathname.includes("onlineleasing"))return;t&&(this.orgSlug="Pacific Urban Residential"===e.organization?"Pacific-Urban-Residential":e.organization,this.hasBuildingSlug=!!e.building,this.overridePlacement={right:null===(n=null==e?void 0:e.position)||void 0===n?void 0:n.right,bottom:null===(i=null==e?void 0:e.position)||void 0===i?void 0:i.bottom,top:null===(r=null==e?void 0:e.position)||void 0===r?void 0:r.top,left:null===(o=null==e?void 0:e.position)||void 0===o?void 0:o.left}),Mo();const d=document.createElement("me-chat");d.setAttribute("orgSlug","Pacific Urban Residential"===e.organization?"Pacific-Urban-Residential":e.organization),this.handleBuildingslug(d,e.building),d.setAttribute("class","meetelise-chat"),d.setAttribute("role","dialog"),d.setAttribute("aria-label","EliseAI Widget"),d.setAttribute("aria-describedby","aria-describe-info"),d.setAttribute("aria-modal","true"),e.launcherStyles&&(d.launcherStyles=e.launcherStyles),e.mobileStyles&&(d.mobileStyles=e.mobileStyles),e.brandColor&&(this.brandColor=e.brandColor,d.setAttribute("brandColor",((e,t)=>{const n=(r=e,{r:parseInt(r.substring(1,3),16),g:parseInt(r.substring(3,5),16),b:parseInt(r.substring(5,7),16)}),i={r:n.r+Math.round(.3*(0-n.r)),g:n.g+Math.round(.3*(0-n.g)),b:n.b+Math.round(.3*(0-n.b))};var r;return((e,t,n)=>"#"+[e,t,n].map((e=>{const t=e.toString(16);return 1===t.length?"0"+t:t})).join(""))(i.r,i.g,i.b)})(e.brandColor))),e.backgroundColor&&(this.backgroundColor=e.backgroundColor),e.onWidgetLoaded&&(d.onWidgetLoaded=e.onWidgetLoaded),e.position&&(d.setAttribute("right",(null===(a=e.position.right)||void 0===a?void 0:a.toString())||"unset"),d.setAttribute("bottom",(null===(s=e.position.bottom)||void 0===s?void 0:s.toString())||"unset"),d.setAttribute("top",(null===(l=e.position.top)||void 0===l?void 0:l.toString())||"unset"),d.setAttribute("left",(null===(u=e.position.left)||void 0===u?void 0:u.toString())||"unset")),e.overrideRentgrata&&(this.handleRentgrataOverride(),d.overrideRentgrata=!0),window.eliseAi={},document.body.appendChild(d),Po.meChat=d}static async restartConversation(){this.meChat&&await this.meChat.restartConversation()}static async remove(){this.meChat&&(await this.meChat.remove(),document.body.removeChild(this.meChat),Po.meChat=null)}static async handleBuildingslug(e,t){t?e.setAttribute("buildingSlug",t):this.mutationObserver||(this.handleSingleFamilyUrl(),this.previousUrl=window.location.href,document.body.addEventListener("click",(()=>{requestAnimationFrame((()=>{this.previousUrl===window.location.href||this.hasBuildingSlug||(this.previousUrl=window.location.href,this.handleSingleFamilyUrl())}))}),!0))}static async handleRentgrataOverride(){const e=await this.waitForElement("rg-widget-compact");e&&e.setAttribute("style","display: none")}static async waitForElement(e,t=5e3){return new Promise(((n,i)=>{const r=new MutationObserver(((t,i)=>{const r=document.getElementById(e);r&&(i.disconnect(),n(r))}));r.observe(document.body,{childList:!0,subtree:!0});const o=setTimeout((()=>{r.disconnect(),i(new Error(`Element ${e} did not appear within ${t}ms`))}),t),a=document.querySelector(e);a&&(clearTimeout(o),r.disconnect(),n(a))}))}static async handleSingleFamilyUrl(){if(this.hasBuildingSlug)return;this.remove();const e=window.location.href,n=`https://app.meetelise.com/platformApi/webchat/microsite_slug?uri=${encodeURIComponent(e)}`,i=await t().get(n,{headers:{"org-slug":this.orgSlug}});if(Math.random()<.2&&li({logType:i&&i.data?si.info:si.warn,logTitle:`[BUILDING_SLUG_CALCULATED_${i?"SUCCESS":"FAILURE"}]`,logData:{calculatedBuildingSlug:i.data,url:e,orgSlug:this.orgSlug,givenBuildingSlug:null,reason:i&&i.data?null:"No match found"}}),!i||!i.data)return;const r={organization:this.orgSlug,building:i.data,brandColor:this.brandColor,backgroundColor:this.backgroundColor};this.start(r,!1)}static async calculateBuildingSlugForLogging(e){const n=window.location.href,i=`https://app.meetelise.com/platformApi/webchat/microsite_slug?uri=${encodeURIComponent(n)}`,r=await t().get(i,{headers:{"org-slug":this.orgSlug}});Math.random()<.2&&li({logType:r&&r.data===e?si.info:si.warn,logTitle:`[BUILDING_SLUG_CALCULATED_${r&&r.data===e?"SUCCESS":"FAILURE"}]`,logData:{calculatedBuildingSlug:r.data,url:n,orgSlug:this.orgSlug,givenBuildingSlug:e,reason:r&&r.data===e?null:r&&!r.data?"No match found":r&&r.data!==e?"Mismatch":"No match found"}}),r&&r.data}}Po.meChat=null,Po.healthChat=null,Po.orgSlug="",Po.mutationObserver=null,Po.previousUrl="",Po.hasBuildingSlug=null,Po.brandColor="",Po.backgroundColor="",Po.healthcareId="",Po.overridePlacement={};const Mo=()=>{const e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("type","text/css"),document.head.appendChild(e)}})();var r=i.Z;export{r as default};
|
|
4573
|
+
`,Ro([le({type:String})],_o.prototype,"healthcareId",void 0),Ro([le({type:Number})],_o.prototype,"right",void 0),Ro([le({type:Number})],_o.prototype,"bottom",void 0),Ro([le({type:Number})],_o.prototype,"top",void 0),Ro([le({type:Number})],_o.prototype,"left",void 0),Ro([ue()],_o.prototype,"launcher",void 0),Ro([ue()],_o.prototype,"currentLeadSource",void 0),Ro([ue()],_o.prototype,"displayPubnubChat",void 0),Ro([ue()],_o.prototype,"myPubnub",void 0),Ro([ue()],_o.prototype,"requiresConsent",void 0),Ro([ue()],_o.prototype,"privacyPolicyUrl",void 0),Ro([ue()],_o.prototype,"isLoading",void 0),_o=Ro([ae("health-chat")],_o);class Po{static healthcareStart(e,t=!0){var n,i,r,o;t&&(this.healthcareId=e.id,this.overridePlacement={right:e.right,bottom:e.bottom,top:e.top,left:e.left}),Mo();const a=document.createElement("health-chat");a.setAttribute("class","health-chat"),a.setAttribute("role","dialog"),a.setAttribute("aria-label","EliseAI Healthcare Widget"),a.setAttribute("aria-describedby","aria-describe-info"),a.setAttribute("aria-modal","true"),a.setAttribute("healthcareId",e.id),a.setAttribute("right",(null===(n=e.right)||void 0===n?void 0:n.toString())||"unset"),a.setAttribute("bottom",(null===(i=e.bottom)||void 0===i?void 0:i.toString())||"unset"),a.setAttribute("top",(null===(r=e.top)||void 0===r?void 0:r.toString())||"unset"),a.setAttribute("left",(null===(o=e.left)||void 0===o?void 0:o.toString())||"unset"),document.body.appendChild(a),Po.healthChat=a}static start(e,t=!0){var n,i,r,o,a,s,l,u;if(window.location.pathname.includes("residentservices")||window.location.pathname.includes("onlineleasing"))return;t&&(this.orgSlug="Pacific Urban Residential"===e.organization?"Pacific-Urban-Residential":e.organization,this.hasBuildingSlug=!!e.building,this.overridePlacement={right:null===(n=null==e?void 0:e.position)||void 0===n?void 0:n.right,bottom:null===(i=null==e?void 0:e.position)||void 0===i?void 0:i.bottom,top:null===(r=null==e?void 0:e.position)||void 0===r?void 0:r.top,left:null===(o=null==e?void 0:e.position)||void 0===o?void 0:o.left}),Mo();const d=document.createElement("me-chat");d.setAttribute("orgSlug","Pacific Urban Residential"===e.organization?"Pacific-Urban-Residential":e.organization),d.setAttribute("widgetType",e.widgetType||"default"),"utilities"!==e.widgetType&&this.handleBuildingslug(d,e.building),d.setAttribute("class","meetelise-chat"),d.setAttribute("role","dialog"),d.setAttribute("aria-label","EliseAI Widget"),d.setAttribute("aria-describedby","aria-describe-info"),d.setAttribute("aria-modal","true"),e.launcherStyles&&(d.launcherStyles=e.launcherStyles),e.mobileStyles&&(d.mobileStyles=e.mobileStyles),e.brandColor&&(this.brandColor=e.brandColor,d.setAttribute("brandColor",((e,t)=>{const n=(r=e,{r:parseInt(r.substring(1,3),16),g:parseInt(r.substring(3,5),16),b:parseInt(r.substring(5,7),16)}),i={r:n.r+Math.round(.3*(0-n.r)),g:n.g+Math.round(.3*(0-n.g)),b:n.b+Math.round(.3*(0-n.b))};var r;return((e,t,n)=>"#"+[e,t,n].map((e=>{const t=e.toString(16);return 1===t.length?"0"+t:t})).join(""))(i.r,i.g,i.b)})(e.brandColor))),e.backgroundColor&&(this.backgroundColor=e.backgroundColor),e.onWidgetLoaded&&(d.onWidgetLoaded=e.onWidgetLoaded),e.position&&(d.setAttribute("right",(null===(a=e.position.right)||void 0===a?void 0:a.toString())||"unset"),d.setAttribute("bottom",(null===(s=e.position.bottom)||void 0===s?void 0:s.toString())||"unset"),d.setAttribute("top",(null===(l=e.position.top)||void 0===l?void 0:l.toString())||"unset"),d.setAttribute("left",(null===(u=e.position.left)||void 0===u?void 0:u.toString())||"unset")),e.overrideRentgrata&&(this.handleRentgrataOverride(),d.overrideRentgrata=!0),window.eliseAi={},document.body.appendChild(d),Po.meChat=d}static async restartConversation(){this.meChat&&await this.meChat.restartConversation()}static async remove(){this.meChat&&(await this.meChat.remove(),document.body.removeChild(this.meChat),Po.meChat=null)}static async handleBuildingslug(e,t){t?e.setAttribute("buildingSlug",t):this.mutationObserver||(this.handleSingleFamilyUrl(),this.previousUrl=window.location.href,document.body.addEventListener("click",(()=>{requestAnimationFrame((()=>{this.previousUrl===window.location.href||this.hasBuildingSlug||(this.previousUrl=window.location.href,this.handleSingleFamilyUrl())}))}),!0))}static async handleRentgrataOverride(){const e=await this.waitForElement("rg-widget-compact");e&&e.setAttribute("style","display: none")}static async waitForElement(e,t=5e3){return new Promise(((n,i)=>{const r=new MutationObserver(((t,i)=>{const r=document.getElementById(e);r&&(i.disconnect(),n(r))}));r.observe(document.body,{childList:!0,subtree:!0});const o=setTimeout((()=>{r.disconnect(),i(new Error(`Element ${e} did not appear within ${t}ms`))}),t),a=document.querySelector(e);a&&(clearTimeout(o),r.disconnect(),n(a))}))}static async handleSingleFamilyUrl(){if(this.hasBuildingSlug)return;this.remove();const e=window.location.href,n=`https://app.meetelise.com/platformApi/webchat/microsite_slug?uri=${encodeURIComponent(e)}`,i=await t().get(n,{headers:{"org-slug":this.orgSlug}});if(Math.random()<.2&&li({logType:i&&i.data?si.info:si.warn,logTitle:`[BUILDING_SLUG_CALCULATED_${i?"SUCCESS":"FAILURE"}]`,logData:{calculatedBuildingSlug:i.data,url:e,orgSlug:this.orgSlug,givenBuildingSlug:null,reason:i&&i.data?null:"No match found"}}),!i||!i.data)return;const r={organization:this.orgSlug,building:i.data,brandColor:this.brandColor,backgroundColor:this.backgroundColor};this.start(r,!1)}static async calculateBuildingSlugForLogging(e){const n=window.location.href,i=`https://app.meetelise.com/platformApi/webchat/microsite_slug?uri=${encodeURIComponent(n)}`,r=await t().get(i,{headers:{"org-slug":this.orgSlug}});Math.random()<.2&&li({logType:r&&r.data===e?si.info:si.warn,logTitle:`[BUILDING_SLUG_CALCULATED_${r&&r.data===e?"SUCCESS":"FAILURE"}]`,logData:{calculatedBuildingSlug:r.data,url:n,orgSlug:this.orgSlug,givenBuildingSlug:e,reason:r&&r.data===e?null:r&&!r.data?"No match found":r&&r.data!==e?"Mismatch":"No match found"}}),r&&r.data}}Po.meChat=null,Po.healthChat=null,Po.orgSlug="",Po.mutationObserver=null,Po.previousUrl="",Po.hasBuildingSlug=null,Po.brandColor="",Po.backgroundColor="",Po.healthcareId="",Po.overridePlacement={};const Mo=()=>{const e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("type","text/css"),document.head.appendChild(e)}})();var r=i.Z;export{r as default};
|
package/src/MEChat.ts
CHANGED
|
@@ -106,7 +106,10 @@ export default class MEChat {
|
|
|
106
106
|
? "Pacific-Urban-Residential"
|
|
107
107
|
: opts.organization
|
|
108
108
|
);
|
|
109
|
-
|
|
109
|
+
meChat.setAttribute("widgetType", opts.widgetType || "default");
|
|
110
|
+
if (opts.widgetType !== "utilities") {
|
|
111
|
+
this.handleBuildingslug(meChat, opts.building);
|
|
112
|
+
}
|
|
110
113
|
meChat.setAttribute("class", "meetelise-chat");
|
|
111
114
|
meChat.setAttribute("role", "dialog");
|
|
112
115
|
meChat.setAttribute("aria-label", "EliseAI Widget");
|
|
@@ -340,6 +343,7 @@ export interface Options {
|
|
|
340
343
|
position?: PositioningOptions;
|
|
341
344
|
onWidgetLoaded?: () => void;
|
|
342
345
|
overrideRentgrata?: boolean;
|
|
346
|
+
widgetType?: "default" | "healthcare" | "utilities";
|
|
343
347
|
}
|
|
344
348
|
|
|
345
349
|
/** You can't install a font from CSS in a shadow DOM, so we use JS to do it here in the regular DOM. */
|
|
@@ -183,6 +183,9 @@ export class MEChat extends LitElement {
|
|
|
183
183
|
@property({ attribute: true })
|
|
184
184
|
overrideRentgrata = false;
|
|
185
185
|
|
|
186
|
+
@property({ attribute: true })
|
|
187
|
+
widgetType: "default" | "healthcare" | "utilities" = "default";
|
|
188
|
+
|
|
186
189
|
@property()
|
|
187
190
|
onWidgetLoaded: () => void = noop;
|
|
188
191
|
|
|
@@ -228,6 +231,18 @@ export class MEChat extends LitElement {
|
|
|
228
231
|
firstUpdated = async (): Promise<void> => this.setupWebchat();
|
|
229
232
|
|
|
230
233
|
private setupWebchat = async (): Promise<void> => {
|
|
234
|
+
// TODO(erol) decide how we want to handle for this
|
|
235
|
+
if (this.widgetType === "utilities") {
|
|
236
|
+
if (Math.random() < 0.05) {
|
|
237
|
+
sendLoggingEvent({
|
|
238
|
+
logType: LogType.info,
|
|
239
|
+
logTitle: "[UTILITY_WIDGET_TYPE_DETECTED]",
|
|
240
|
+
logData: { widgetType: this.widgetType, url: window.location.href },
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
|
|
231
246
|
if (!this.buildingSlug || !this.orgSlug) return;
|
|
232
247
|
const building = await fetchBuildingInfo(this.orgSlug, this.buildingSlug);
|
|
233
248
|
if (Math.random() < 0.2) {
|
|
@@ -472,20 +487,13 @@ export class MEChat extends LitElement {
|
|
|
472
487
|
if (!updatedChatStorageKey.leadId) {
|
|
473
488
|
throw new Error("Lead ID is null");
|
|
474
489
|
}
|
|
475
|
-
|
|
476
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
477
|
-
const chatIdOverride = (window as any).eliseAiDebug?.chatIdOverride;
|
|
478
|
-
const leadId = chatIdOverride
|
|
479
|
-
? chatIdOverride.split("_").slice(1).join("_")
|
|
480
|
-
: updatedChatStorageKey.leadId;
|
|
481
|
-
|
|
482
490
|
this.LeadSourceClient = new LeadSourceClient();
|
|
483
491
|
this.myPubnub = new MyPubnub(
|
|
484
492
|
this.buildingSlug,
|
|
485
493
|
this.building,
|
|
486
494
|
this.orgSlug,
|
|
487
495
|
null, // initialize lead source as null initially
|
|
488
|
-
leadId,
|
|
496
|
+
updatedChatStorageKey.leadId,
|
|
489
497
|
this.LeadSourceClient
|
|
490
498
|
);
|
|
491
499
|
this.LeadSourceClient.chatId = this.myPubnub.channel;
|
|
@@ -505,12 +513,6 @@ export class MEChat extends LitElement {
|
|
|
505
513
|
if (updatedChatStorageKey.initiatedChat) {
|
|
506
514
|
await this.myPubnub.initializePubnub(currentChatStorageKey);
|
|
507
515
|
}
|
|
508
|
-
|
|
509
|
-
if (chatIdOverride) {
|
|
510
|
-
currentChatStorageKey.initiatedChat = true;
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
await this.myPubnub.initializePubnub(currentChatStorageKey);
|
|
514
516
|
};
|
|
515
517
|
|
|
516
518
|
private shouldAutoOpenChat = (buildingHasAutoOpen: boolean): boolean => {
|