@meetelise/chat 1.20.225 → 1.20.227

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meetelise/chat",
3
- "version": "1.20.225",
3
+ "version": "1.20.227",
4
4
  "description": "",
5
5
  "main": "public/dist/index.js",
6
6
  "type": "module",
@@ -4022,7 +4022,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
4022
4022
  I agree
4023
4023
  </button>
4024
4024
  </div>
4025
- `;function oo(){return ao()?function(){const e=window.location.search,t={};return e.split("?").slice(1).join("&").split("&").forEach((e=>{const[n,i]=e.split("=");n&&i&&(t[decodeURIComponent(n)]=decodeURIComponent(i))})),t}():function(){const e=new URLSearchParams(window.location.search),t=e.has("utm_content"),n=e.has("utm_source");if(t&&!n){const t=e.get("utm_content");e.delete("utm_content"),e.set("utm_source",t)}return Object.fromEntries(e)}()}const ao=()=>(window.location.search.match(/\?/g)||[]).length>1;var so=n(8367),uo=n.n(so);var lo=n(308),co=n.n(lo),po=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 ho=class extends re{constructor(){super(...arguments),this.buildingSlug="",this.orgSlug="",this.launcherStyles={},this.mobileStyles={},this.isMinimized=!1,this.brandColor=null,this.chatId="",this.analytics=null,this.launcher=null,this.building=null,this.designConcept=null,this.leadSources=null,this.currentLeadSource=null,this.featureFlagShowDropdown=Vn.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.onWidgetLoaded=co(),this.enabledChatWidgets={call:!0,chat:!0,email:!0,text:!0,sst:!0},this.webchatConfigHasAutoOpenChat=!1,this.requiresConsent=!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 hi(this.orgSlug,this.buildingSlug);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,u,l,d,c,p,h,f,m,g,v,y,b,w,S,T,x,A,O,C,I,N,E;const R=this.building;if(!R)return;R&&this.orgSlug&&mo(this.orgSlug,this.buildingSlug,null!==(n=null===(e=this.LeadSourceClient)||void 0===e?void 0:e.leadSource)&&void 0!==n?n:null);const[_,P,M,F,D,k]=await Promise.all([yi(this.buildingSlug),mr(this.buildingSlug),Kn(this.buildingSlug),Xn(this.buildingSlug),vi(R.id),Yn(this.buildingSlug)]);this.building&&(this.building.phoneNumber=Ne(R.phoneNumber)),this.designConcept=null!==(i=null==_?void 0:_.abTestType)&&void 0!==i?i:"",this.leadSources=P,this.featureFlagShowDropdown=M;const U=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 ai({logType:oi.error,buildingSlug:e,logTitle:"[ERROR_GETTING_PHONE_NUMBERS]",logData:{error:t}}),null}return null})(this.buildingSlug);var q,B;this.enabledChatWidgets={call:D&&!D.isGlobalDefault?D.config.shouldShowPhone:null===(a=null===(o=null===(r=this.building)||void 0===r?void 0:r.chatWidgets)||void 0===o?void 0:o.includes("CALL"))||void 0===a||a,chat:D&&!D.isGlobalDefault?D.config.shouldShowChat:null===(l=null===(u=null===(s=this.building)||void 0===s?void 0:s.chatWidgets)||void 0===u?void 0:u.includes("CHAT"))||void 0===l||l,email:D&&!D.isGlobalDefault?D.config.shouldShowEmail:null===(p=null===(c=null===(d=this.building)||void 0===d?void 0:d.chatWidgets)||void 0===c?void 0:c.includes("EMAIL"))||void 0===p||p,text:(D&&!D.isGlobalDefault?D.config.shouldShowText:null===(m=null===(f=null===(h=this.building)||void 0===h?void 0:h.chatWidgets)||void 0===f?void 0:f.includes("SMS"))||void 0===m||m)&&!!U,sst:D&&!D.isGlobalDefault?D.config.shouldShowSst:null===(y=null===(v=null===(g=this.building)||void 0===g?void 0:g.chatWidgets)||void 0===v?void 0:v.includes("SST"))||void 0===y||y},this.enabledChatWidgets.sst?(B=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(),B(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===(b=this.LeadSourceClient)||void 0===b?void 0:b.leadSource)&&(q=null!==(S=null===(w=this.LeadSourceClient)||void 0===w?void 0:w.leadSource)&&void 0!==S?S: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(q)}`)}}))),D&&D.config&&(this.brandColor=null!==(T=D.config.primaryColor)&&void 0!==T?T:null,this.webchatConfigHasAutoOpenChat=D.config.autoOpenChat,this.requiresConsent=D.config.requiresConsent,this.privacyPolicyUrl=null!==(x=D.config.privacyPolicyUrl)&&void 0!==x?x:this.privacyPolicyUrl,D.config.displayStyle===mi.MINIMIZED&&(this.isMinimized=!0),D.config.displayStyle===mi.PILLS&&(this.designConcept=null),D.config.displayStyle===mi.EMOJI&&(this.designConcept=mi.EMOJI),this.onWidgetLoaded()),null===this.brandColor&&(this.brandColor=Me);const L=null!==(O=null===(A=this.building)||void 0===A?void 0:A.phoneNumber)&&void 0!==O?O:"";let J=null;F&&(J=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!==(I=null===(C=this.LeadSourceClient)||void 0===C?void 0:C.leadSource)&&void 0!==I?I:null),J&&!J.isMatch&&(J.number=L)),k&&(null==J?void 0:J.number)&&kr(J.number,this.orgSlug,this.buildingSlug);const j=localStorage.getItem("eliseai_phone_number_devtest");j&&(console.info("Using dev test phone number: ",j),kr(j,this.orgSlug,this.buildingSlug)),this.phoneNumberForSource=J||{number:L,isMatch:!1,isPropertyWebsiteCatchall:!0};const H=null!==(E=null===(N=this.LeadSourceClient)||void 0===N?void 0:N.leadSource)&&void 0!==E?E:null;H&&(this.leadSources.includes(H)||this.leadSources.push(H)),qn(R.id)},this.initializeChatVariables=async()=>{var e,n,i,r,o;if(!this.building)return;const a=Er(this.buildingSlug),s=Rr(this.buildingSlug,a)?a:Nr(this.buildingSlug,!1);if(!s.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.localStorageTTLHours=4,this.buildingId=null,this.orgSlug=null,this.buildingSlug=null,this.queryParameters=null,this.leadSourceInput=null,this.updateLeadSourceLocalStorage=(e,t,n)=>{const i=oo();this.leadSourceInput={websiteOrigin:window.location.origin,websiteSearch:window.location.search,queryParameters:i,referrer:document.referrer,parsedUtmSource:i?i.utm_source:null,campaignSources:Object.values(ri()).filter((e=>e))};const r={leadSource:t,leadId:n,buildingSlug:e,timestamp:gn(new Date),leadSourceInput:this.leadSourceInput};return localStorage.setItem("com.elise.webchat.leadsource.slug="+e,JSON.stringify(r)),{...r,timestamp:xn(r.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&&!dn(xn(n.timestamp),this.localStorageTTLHours)){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,u,l;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=this.getCookieValue("_ga",`.${new URL(window.location.href).hostname}`);e&&(d=e),c=null===(i=window.dataLayer.find((e=>e.gtagApiGet)))||void 0===i?void 0:i.gtagApiGet}}catch(e){console.error("error getting cookie is not set")}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===(u=this.leadSourceInput)||void 0===u?void 0:u.parsedUtmSource,campaign_sources:null===(l=this.leadSourceInput)||void 0===l?void 0:l.campaignSources,lead_source_output:this.leadSource,google_analytics_client_id:uo()(d)?null:d,extras:null!=c?c:null}),null}catch(e){return null}}async getCookieValue(e,t){try{{const n=document.cookie.split(";");for(let i=0;i<n.length;i++){const r=n[i].trim();if(r.startsWith(e+"=")&&r.includes(`domain=${t}`))return r.substring((e+"=").length,r.indexOf("; domain="))}return null}}catch(e){console.error("error getting cookie is not set")}return null}async generateUserLeadSource({leadId:e,orgSlug:t,buildingSlug:n}){try{const i={queryParams:oo(),buildingSlug:n,referrer:document.referrer,campaignSources:ri()},r=await this.fetchCurrentParsedLeadSource(i);if(this.leadSource=r,this.buildingId=null,this.orgSlug=t,this.buildingSlug=n,n&&!r){const e=this.getLeadSourceBodyIfValid(n);if(e)return this.leadSource=e.leadSource,this.leadSource}return n&&r&&this.updateLeadSourceLocalStorage(n,r,e),r}catch(e){console.error(e)}return null}},this.myPubnub=new Dr(this.buildingSlug,this.building,this.orgSlug,null,s.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})),this.myPubnub.leadSource=null!==(o=null===(r=this.LeadSourceClient)||void 0===r?void 0:r.leadSource)&&void 0!==o?o:null,s.initiatedChat&&await this.myPubnub.initializePubnub(a)},this.shouldAutoOpenChat=e=>{const t=sessionStorage.getItem("alreadyAutoOpenedTimestamp"),n=!t||!(t&&!Sn(xn(t)));return!!e&&!!n&&!ln()},this.updateAlreadyAutoOpenedTimestamp=()=>{sessionStorage.setItem("alreadyAutoOpenedTimestamp",gn(function(e,t){Ue(2,arguments);var n=et(t);return tt(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,u,l,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!==(l=null===(u=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===u?void 0:u.getElementById("email-us-form"))&&void 0!==l?l: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
4025
+ `;function oo(){return ao()?function(){const e=window.location.search,t={};return e.split("?").slice(1).join("&").split("&").forEach((e=>{const[n,i]=e.split("=");n&&i&&(t[decodeURIComponent(n)]=decodeURIComponent(i))})),t}():function(){const e=new URLSearchParams(window.location.search),t=e.has("utm_content"),n=e.has("utm_source");if(t&&!n){const t=e.get("utm_content");e.delete("utm_content"),e.set("utm_source",t)}return Object.fromEntries(e)}()}const ao=()=>(window.location.search.match(/\?/g)||[]).length>1;var so=n(8367),uo=n.n(so);var lo=n(308),co=n.n(lo),po=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 ho=class extends re{constructor(){super(...arguments),this.buildingSlug="",this.orgSlug="",this.launcherStyles={},this.mobileStyles={},this.isMinimized=!1,this.brandColor=null,this.chatId="",this.analytics=null,this.launcher=null,this.building=null,this.designConcept=null,this.leadSources=null,this.currentLeadSource=null,this.featureFlagShowDropdown=Vn.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.onWidgetLoaded=co(),this.enabledChatWidgets={call:!0,chat:!0,email:!0,text:!0,sst:!0},this.webchatConfigHasAutoOpenChat=!1,this.requiresConsent=!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 hi(this.orgSlug,this.buildingSlug);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,u,l,d,c,p,h,f,m,g,v,y,b,w,S,T,x,A,O,C,I,N,E;const R=this.building;if(!R)return;R&&this.orgSlug&&mo(this.orgSlug,this.buildingSlug,null!==(n=null===(e=this.LeadSourceClient)||void 0===e?void 0:e.leadSource)&&void 0!==n?n:null);const[_,P,M,F,D,k]=await Promise.all([yi(this.buildingSlug),mr(this.buildingSlug),Kn(this.buildingSlug),Xn(this.buildingSlug),vi(R.id),Yn(this.buildingSlug)]);this.building&&(this.building.phoneNumber=Ne(R.phoneNumber)),this.designConcept=null!==(i=null==_?void 0:_.abTestType)&&void 0!==i?i:"",this.leadSources=P,this.featureFlagShowDropdown=M;const U=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 ai({logType:oi.error,buildingSlug:e,logTitle:"[ERROR_GETTING_PHONE_NUMBERS]",logData:{error:t}}),null}return null})(this.buildingSlug);var q,B;this.enabledChatWidgets={call:D&&!D.isGlobalDefault?D.config.shouldShowPhone:null===(a=null===(o=null===(r=this.building)||void 0===r?void 0:r.chatWidgets)||void 0===o?void 0:o.includes("CALL"))||void 0===a||a,chat:D&&!D.isGlobalDefault?D.config.shouldShowChat:null===(l=null===(u=null===(s=this.building)||void 0===s?void 0:s.chatWidgets)||void 0===u?void 0:u.includes("CHAT"))||void 0===l||l,email:D&&!D.isGlobalDefault?D.config.shouldShowEmail:null===(p=null===(c=null===(d=this.building)||void 0===d?void 0:d.chatWidgets)||void 0===c?void 0:c.includes("EMAIL"))||void 0===p||p,text:(D&&!D.isGlobalDefault?D.config.shouldShowText:null===(m=null===(f=null===(h=this.building)||void 0===h?void 0:h.chatWidgets)||void 0===f?void 0:f.includes("SMS"))||void 0===m||m)&&!!U,sst:D&&!D.isGlobalDefault?D.config.shouldShowSst:null===(y=null===(v=null===(g=this.building)||void 0===g?void 0:g.chatWidgets)||void 0===v?void 0:v.includes("SST"))||void 0===y||y},this.enabledChatWidgets.sst?(B=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(),B(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===(b=this.LeadSourceClient)||void 0===b?void 0:b.leadSource)&&(q=null!==(S=null===(w=this.LeadSourceClient)||void 0===w?void 0:w.leadSource)&&void 0!==S?S: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(q)}`)}}))),D&&D.config&&(this.brandColor=null!==(T=D.config.primaryColor)&&void 0!==T?T:null,this.webchatConfigHasAutoOpenChat=D.config.autoOpenChat,this.requiresConsent=D.config.requiresConsent,this.privacyPolicyUrl=null!==(x=D.config.privacyPolicyUrl)&&void 0!==x?x:this.privacyPolicyUrl,D.config.displayStyle===mi.MINIMIZED&&(this.isMinimized=!0),D.config.displayStyle===mi.PILLS&&(this.designConcept=null),D.config.displayStyle===mi.EMOJI&&(this.designConcept=mi.EMOJI),this.onWidgetLoaded()),null===this.brandColor&&(this.brandColor=Me);const L=null!==(O=null===(A=this.building)||void 0===A?void 0:A.phoneNumber)&&void 0!==O?O:"";let J=null;F&&(J=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!==(I=null===(C=this.LeadSourceClient)||void 0===C?void 0:C.leadSource)&&void 0!==I?I:null),J&&!J.isMatch&&(J.number=L)),k&&(null==J?void 0:J.number)&&kr(J.number,this.orgSlug,this.buildingSlug);const j=localStorage.getItem("eliseai_phone_number_devtest");j&&(console.info("Using dev test phone number: ",j),kr(j,this.orgSlug,this.buildingSlug)),this.phoneNumberForSource=J||{number:L,isMatch:!1,isPropertyWebsiteCatchall:!0};const H=null!==(E=null===(N=this.LeadSourceClient)||void 0===N?void 0:N.leadSource)&&void 0!==E?E:null;H&&(this.leadSources.includes(H)||this.leadSources.push(H)),qn(R.id)},this.initializeChatVariables=async()=>{var e,n,i,r,o;if(!this.building)return;const a=Er(this.buildingSlug),s=Rr(this.buildingSlug,a)?a:Nr(this.buildingSlug,!1);if(!s.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.localStorageTTLHours=4,this.buildingId=null,this.orgSlug=null,this.buildingSlug=null,this.queryParameters=null,this.leadSourceInput=null,this.updateLeadSourceLocalStorage=(e,t,n)=>{const i=oo();this.leadSourceInput={websiteOrigin:window.location.origin,websiteSearch:window.location.search,queryParameters:i,referrer:document.referrer,parsedUtmSource:i?i.utm_source:null,campaignSources:Object.values(ri()).filter((e=>e))};const r={leadSource:t,leadId:n,buildingSlug:e,timestamp:gn(new Date),leadSourceInput:this.leadSourceInput};return localStorage.setItem("com.elise.webchat.leadsource.slug="+e,JSON.stringify(r)),{...r,timestamp:xn(r.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&&!dn(xn(n.timestamp),this.localStorageTTLHours)){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,u,l;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",`.${new URL(window.location.href).hostname}`);e&&(d=e),c=null===(i=window.dataLayer.find((e=>e.gtagApiGet)))||void 0===i?void 0:i.gtagApiGet}}catch(e){console.error("error getting cookie is not set")}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===(u=this.leadSourceInput)||void 0===u?void 0:u.parsedUtmSource,campaign_sources:null===(l=this.leadSourceInput)||void 0===l?void 0:l.campaignSources,lead_source_output:this.leadSource,google_analytics_client_id:uo()(d)?null:d,extras:null!=c?c:null}),null}catch(e){return null}}async getCookieValue(e,t){try{const n=document.cookie.split(";");for(let i=0;i<n.length;i++){const r=n[i].trim();if(r.startsWith(e+"=")){if(!t)return r.substring((e+"=").length,-1===r.indexOf(";")?void 0:r.indexOf(";"));if(r.includes(`domain=${t}`))return r.substring((e+"=").length,r.indexOf("; domain="))}}return null}catch(e){console.error("error getting cookie value")}return null}async generateUserLeadSource({leadId:e,orgSlug:t,buildingSlug:n}){try{const i={queryParams:oo(),buildingSlug:n,referrer:document.referrer,campaignSources:ri()},r=await this.fetchCurrentParsedLeadSource(i);if(this.leadSource=r,this.buildingId=null,this.orgSlug=t,this.buildingSlug=n,n&&!r){const e=this.getLeadSourceBodyIfValid(n);if(e)return this.leadSource=e.leadSource,this.leadSource}return n&&this.updateLeadSourceLocalStorage(n,r,e),r}catch(e){console.error(e)}return null}},this.myPubnub=new Dr(this.buildingSlug,this.building,this.orgSlug,null,s.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})),this.myPubnub.leadSource=null!==(o=null===(r=this.LeadSourceClient)||void 0===r?void 0:r.leadSource)&&void 0!==o?o:null,s.initiatedChat&&await this.myPubnub.initializePubnub(a)},this.shouldAutoOpenChat=e=>{const t=sessionStorage.getItem("alreadyAutoOpenedTimestamp"),n=!t||!(t&&!Sn(xn(t)));return!!e&&!!n&&!ln()},this.updateAlreadyAutoOpenedTimestamp=()=>{sessionStorage.setItem("alreadyAutoOpenedTimestamp",gn(function(e,t){Ue(2,arguments);var n=et(t);return tt(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,u,l,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!==(l=null===(u=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===u?void 0:u.getElementById("email-us-form"))&&void 0!==l?l: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
4026
4026
  id=${e}
4027
4027
  class=${fe({showTab:t,hideTab:!t})}
4028
4028
  >
@@ -148,7 +148,7 @@ class LeadSourceClient {
148
148
  try {
149
149
  if (this.orgSlug === "f1ba5a20-d207-4e5a-879e-65199e7d0a53") {
150
150
  // SCION only
151
- const gaCookie = this.getCookieValue(
151
+ const gaCookie = await this.getCookieValue(
152
152
  "_ga",
153
153
  `.${new URL(window.location.href).hostname}`
154
154
  );
@@ -188,29 +188,33 @@ class LeadSourceClient {
188
188
  }
189
189
  }
190
190
 
191
- private async getCookieValue(key: string, domain: string) {
191
+ async getCookieValue(key: string, domain?: string): Promise<string | null> {
192
192
  try {
193
- {
194
- const cookies = document.cookie.split(";");
195
- for (let i = 0; i < cookies.length; i++) {
196
- const cookie = cookies[i].trim();
197
- if (
198
- cookie.startsWith(key + "=") &&
199
- cookie.includes(`domain=${domain}`)
200
- ) {
193
+ const cookies = document.cookie.split(";");
194
+ for (let i = 0; i < cookies.length; i++) {
195
+ const cookie = cookies[i].trim();
196
+ if (cookie.startsWith(key + "=")) {
197
+ if (domain) {
198
+ if (cookie.includes(`domain=${domain}`)) {
199
+ const value = cookie.substring(
200
+ (key + "=").length,
201
+ cookie.indexOf("; domain=")
202
+ );
203
+ return value;
204
+ }
205
+ } else {
201
206
  const value = cookie.substring(
202
207
  (key + "=").length,
203
- cookie.indexOf("; domain=")
208
+ cookie.indexOf(";") === -1 ? undefined : cookie.indexOf(";")
204
209
  );
205
210
  return value;
206
211
  }
207
212
  }
208
- return null;
209
213
  }
210
214
  return null;
211
215
  } catch (error) {
212
216
  // eslint-disable-next-line no-console
213
- console.error("error getting cookie is not set");
217
+ console.error("error getting cookie value");
214
218
  }
215
219
  return null;
216
220
  }
@@ -235,6 +239,7 @@ class LeadSourceClient {
235
239
  referrer: document.referrer,
236
240
  campaignSources: getCampaignSources(),
237
241
  };
242
+
238
243
  const currentParsedLeadSource = await this.fetchCurrentParsedLeadSource(
239
244
  leadSourceInput
240
245
  );
@@ -255,7 +260,7 @@ class LeadSourceClient {
255
260
  }
256
261
 
257
262
  // If we detect a lead source from the current session, we store it in local storage
258
- if (buildingSlug && currentParsedLeadSource) {
263
+ if (buildingSlug) {
259
264
  this.updateLeadSourceLocalStorage(
260
265
  buildingSlug,
261
266
  currentParsedLeadSource,