@meetelise/chat 1.22.0 → 1.22.1
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 +0 -10
- package/public/dist/index.js +1 -1
- package/src/WebComponent/me-chat.ts +1 -14
package/package.json
CHANGED
package/public/demo/index.html
CHANGED
|
@@ -151,16 +151,6 @@
|
|
|
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",
|
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.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;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
|
>
|
|
@@ -472,20 +472,13 @@ export class MEChat extends LitElement {
|
|
|
472
472
|
if (!updatedChatStorageKey.leadId) {
|
|
473
473
|
throw new Error("Lead ID is null");
|
|
474
474
|
}
|
|
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
475
|
this.LeadSourceClient = new LeadSourceClient();
|
|
483
476
|
this.myPubnub = new MyPubnub(
|
|
484
477
|
this.buildingSlug,
|
|
485
478
|
this.building,
|
|
486
479
|
this.orgSlug,
|
|
487
480
|
null, // initialize lead source as null initially
|
|
488
|
-
leadId,
|
|
481
|
+
updatedChatStorageKey.leadId,
|
|
489
482
|
this.LeadSourceClient
|
|
490
483
|
);
|
|
491
484
|
this.LeadSourceClient.chatId = this.myPubnub.channel;
|
|
@@ -505,12 +498,6 @@ export class MEChat extends LitElement {
|
|
|
505
498
|
if (updatedChatStorageKey.initiatedChat) {
|
|
506
499
|
await this.myPubnub.initializePubnub(currentChatStorageKey);
|
|
507
500
|
}
|
|
508
|
-
|
|
509
|
-
if (chatIdOverride) {
|
|
510
|
-
currentChatStorageKey.initiatedChat = true;
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
await this.myPubnub.initializePubnub(currentChatStorageKey);
|
|
514
501
|
};
|
|
515
502
|
|
|
516
503
|
private shouldAutoOpenChat = (buildingHasAutoOpen: boolean): boolean => {
|