@meetelise/chat 1.20.93 → 1.20.95
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
package/public/dist/index.js
CHANGED
|
@@ -3249,7 +3249,7 @@ var e={8005:function(e,t,n){var i,r=this&&this.__extends||(i=function(e,t){retur
|
|
|
3249
3249
|
</button>
|
|
3250
3250
|
</div>
|
|
3251
3251
|
</div>
|
|
3252
|
-
`:B``}};Ur.styles=[Fr],kr([de({attribute:!0})],Ur.prototype,"channel",void 0),kr([de({attribute:!0})],Ur.prototype,"myPubnub",void 0),kr([de({attribute:!0})],Ur.prototype,"buildingSlug",void 0),kr([de({attribute:!0})],Ur.prototype,"building",void 0),kr([de({attribute:!0})],Ur.prototype,"brandColor",void 0),kr([de({attribute:!0})],Ur.prototype,"onClickExit",void 0),kr([de({attribute:!0})],Ur.prototype,"onMount",void 0),kr([pe("#message-input",!0)],Ur.prototype,"messageInput",void 0),kr([pe("#conversation-body",!0)],Ur.prototype,"messageBody",void 0),kr([ce()],Ur.prototype,"messages",void 0),kr([ce()],Ur.prototype,"isMobile",void 0),kr([ce()],Ur.prototype,"isLoadingMessages",void 0),kr([ce()],Ur.prototype,"websitePreviewMapping",void 0),Ur=kr([ue("pubnub-chat")],Ur);var qr,Br,Lr=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};!function(e){e.TALKJS="talkjs",e.PUBNUB="pubnub"}(Br||(Br={}));let Jr=qr=class extends ae{constructor(){super(...arguments),this.buildingSlug="",this.orgSlug="",this.themeId="Glass",this.useMiniWidget=!0,this.launcherStyles={},this.isMinimized=!1,this.brandColor=null,this.popup=null,this.theme=Si({themeId:this.themeId,brandColor:this.brandColor}),this.chatId="",this.analytics=null,this.isMobile=r(),this.launcher=null,this.building=null,this.buildingABTestType=null,this.leadSources=null,this.currentLeadSource=null,this.featureFlagShowDropdown=qn.always,this.phoneNumberForSource=null,this.hasMounted=!1,this.hideLauncher=!1,this.isLoading=!0,this.talkjsPopupElement=null,this.chatProvider=Br.TALKJS,this.displayPubnubChat=!1,this.myPubnub=null,this.yardiDNIScriptInterval=null,this.launcherRef=Oe(),this.initializeInstanceVariables=async()=>{qr.session=Ee.ready.then((()=>{const e=new Ee.User({id:"anonymous-"+di(this.orgSlug,this.buildingSlug),name:"Me",email:null,role:"Default"});return new Ee.Session({appId:"ogKIvCor",me:e})})),await this.setBuildingDerivedInfo(),await this.initializeLaunchJS()&&(this.attachOnClickToLauncher(),this.isLoading=!1)},this.setBuildingDerivedInfo=async()=>{var e,n,i;if(!this.buildingSlug||!this.orgSlug)return;const[r,o,a,s,u,l,d]=await Promise.all([Ai(this.orgSlug,this.buildingSlug),Ii(this.buildingSlug),Cr(this.buildingSlug),Ni(this.buildingSlug,document.referrer),Bn(this.buildingSlug),Ln(this.buildingSlug),Ci(this.buildingSlug)]);r.phoneNumber=Pe(r.phoneNumber),this.building=r,this.buildingABTestType=null!==(e=null==o?void 0:o.abTestType)&&void 0!==e?e:"",this.leadSources=a,this.currentLeadSource=s,this.featureFlagShowDropdown=u,d&&(null===this.brandColor&&(this.brandColor=null!==(n=d.primaryColor)&&void 0!==n?n:null),this.isMinimized=!!d.autoMinimize,d.designConcept&&(d.designConcept===xi.MINIMIZED&&(this.isMobile=!0),d.designConcept===xi.PILLS&&(this.buildingABTestType=null),d.designConcept===xi.EMOJI&&(this.buildingABTestType=Oi.ConceptEmoji))),null===this.brandColor&&(this.brandColor=vi);let c=null;l&&(c=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:Pe(i.data.number),isMatch:i.data.isMatch,isPropertyWebsiteCatchall:i.data.isPropertyWebsiteCatchall}:null}catch(e){return null}}(this.buildingSlug,this.currentLeadSource)),this.phoneNumberForSource=c||{number:this.building.phoneNumber,isMatch:!1,isPropertyWebsiteCatchall:!0},this.currentLeadSource&&(this.leadSources.includes(this.currentLeadSource)||this.leadSources.push(this.currentLeadSource)),An(this.building.id),this.chatId=di(this.orgSlug,this.buildingSlug),this.avatarSrc=this.avatarSrc||this.building.avatarSrc,this.theme=Si({themeId:null!==(i=this.themeId)&&void 0!==i?i:this.building.themeId,brandColor:this.brandColor}),this.analytics=new Zn(this.orgSlug,this.buildingSlug,this.chatId,this.currentLeadSource),this.analytics.ping("webchat_heartbeat")},this.initializeLaunchJS=async()=>{var e;if(!this.building||!this.theme)return;if(this.popup&&this.launcher)return;const[t,n,i,r]=await Promise.all([this.building,this.theme,this.avatarSrc,qr.session]);return t.conversationMaintenanceMode?(console.warn("MeetElise Chat is in maintenance mode. Chat icon will not appear."),!1):r?(await this.configureTalkJSPopup(t,n,r,i),this.configureLauncherElement(),null===(e=this.analytics)||void 0===e||e.ping("load"),this.yardiDNIScriptInterval=setInterval((()=>this.pollForYardiCampaignSource()),1e3),setTimeout(clearInterval,15e3,this.yardiDNIScriptInterval),!0):void 0},this.configureLauncherElement=()=>{this.popup&&this.launcherRef.value&&(this.launcher=this.launcherRef.value)},this.configureTalkJSPopup=async(e,t,n,i)=>{var r;const o=n.createPopup(Ti(n,e,t,i||e.avatarSrc,this.chatId,this.isMobile),{launcher:"never",showCloseInHeader:!0,messageField:{placeholder:"Ask a question..."}});await o.mount({show:!1}),o.on("close",(()=>{this.hideLauncher=!1}));const a=document.querySelector(".__talkjs_popup");if(this.talkjsPopupElement=a,!a)throw new Error("Failed to find chat window");a.classList.add("meetelise-chat","pane"),this.isMobile||a.classList.add("launcher__desktop"),a.style.zIndex="99999999999",this.popup=o,this.shouldAutoOpenChat(e.autoOpenChatWidget)&&(this.popup.show(),this.hideLauncher=!0,this.hasMounted=!0,this.updateAlreadyAutoOpenedTimestamp(),null===(r=this.analytics)||void 0===r||r.ping("autoOpen"))},this.shouldAutoOpenChat=e=>{const t=sessionStorage.getItem("alreadyAutoOpenedTimestamp"),n=!t||!(t&&!an(un(t)));return!!e&&!!n&&!r()},this.updateAlreadyAutoOpenedTimestamp=()=>{sessionStorage.setItem("alreadyAutoOpenedTimestamp",tn(function(e,t){Ue(2,arguments);var n=et(t);return tt(e,6e4*n)}(new Date,15)))},this.firstUpdated=async()=>{await async function(e){try{return(await t().get(Un(e),{params:{building_slug:e,flag_type:"bool",feature_flag:"use-pubnub-chat-provider",default_str:null,default_bool:!1}})).data}catch(e){return!1}}(this.buildingSlug)?(this.chatProvider=Br.PUBNUB,this.initializePubnubVariables()):this.initializeInstanceVariables()},this.initializePubnubVariables=async()=>{await this.setBuildingDerivedInfo(),this.building&&(this.building.conversationMaintenanceMode?console.warn("MeetElise Chat is in maintenance mode. Chat icon will not appear."):(this.myPubnub=new class{constructor(e,t,n){this.apiHost="https://app.meetelise.com",this.building=null,this.ttlHours=24,this.eliseResponseTimeout=null,this.pubnub=null,this.leadUserId="",this.channel="",this.chatListener=null,this.messages=[],this.listenerParams={message:e=>{var t;this.messages=[...this.messages,{channel:e.channel,message:e.message,publisher:e.publisher,subscription:e.subscription,timetoken:+e.timetoken}];const n="eliseai"!==e.publisher;null===(t=this.chatListener)||void 0===t||t.call(this,{messages:this.messages,isLoading:n}),!n&&this.eliseResponseTimeout&&clearTimeout(this.eliseResponseTimeout),this.isLoadingMessages=n}},this.isLoadingMessages=!1,this.handleChatListeners=()=>{if(this.pubnub&&this.channel)try{this.pubnub.subscribe({channels:[this.channel]}),this.pubnub.addListener(this.listenerParams)}catch(e){ti({logTitle:"PUBNUB_ERROR_ADDING_LISTENER",logData:{error:e,channel:this.channel,leadUserId:this.leadUserId,website:location.href},logType:ei.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this.removeChatListeners=()=>{this.pubnub&&this.channel&&(this.pubnub.unsubscribe({channels:[this.channel]}),this.pubnub.removeListener(this.listenerParams))},this.sendMessage=async e=>{if(e){if(!this.pubnub&&!await this.initializePubnub())return;await this.withAuthToken((async()=>{var t,n;this.pubnub&&this.channel&&(this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.eliseResponseTimeout=setTimeout((()=>{console.error("Elise AI did not respond in time..."),ti({logTitle:"PUBNUB_ERROR_ELISEAI_MESSAGE_TIMEOUT",logData:{channel:this.channel,leadUserId:this.leadUserId,message:e},logType:ei.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}),45e3),await this.pubnub.publish({channel:this.channel,message:{text:e,customType:"lead_message",buildingId:null===(t=this.building)||void 0===t?void 0:t.id,buildingSlug:this.buildingSlug,userId:null===(n=this.building)||void 0===n?void 0:n.userId}}))})),!1===this.isLoadingMessages&&(this.isLoadingMessages=!0)}},this.isLeadMessage=e=>e.publisher.includes("lead_")&&"lead_message"===e.message.customType,this.createChatStorageKey=e=>{const t=tn(new Date),n=null!=e?e:`lead_${li()}_${this.buildingSlug}`;return localStorage.setItem("com.eliseai.webchat.slug="+this.buildingSlug,JSON.stringify({buildingSlug:this.buildingSlug,leadId:n,timestamp:t})),{leadId:n,timestamp:un(t),buildingSlug:this.buildingSlug}},this.getChatStorageKey=(e=!0)=>{const t=localStorage.getItem("com.eliseai.webchat.slug="+this.buildingSlug);if(t)try{const e=JSON.parse(t),n=e.buildingSlug,i=e.leadId,r=new Date(e.timestamp);if(this.isChatKeyValid({leadId:i,timestamp:r,buildingSlug:n}))return{leadId:i,timestamp:r,buildingSlug:n}}catch(e){console.warn("Error getting chat storage key")}return e?this.createChatStorageKey():{leadId:null,timestamp:null,buildingSlug:null}},this.isChatKeyValid=e=>{if(e.buildingSlug!==this.buildingSlug||!e.leadId||!e.timestamp)return!1;const t=Rr(new Date,this.ttlHours);return function(e,t){Ue(2,arguments);var n=qe(e),i=qe(t);return n.getTime()<i.getTime()}(e.timestamp,t)},this.buildingSlug=e,this.building=t,this.orgSlug=n}addChatListener(e){this.chatListener=e}async initializePubnub(){const e=this.getChatStorageKey();if(!e.leadId)return void ti({logTitle:"PUBNUB_ERROR_FETCHING_STORAGE_KEY",logData:{channel:this.channel,eliseaiLocalStorageValue:e,leadUserId:this.leadUserId},logType:ei.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});this.leadUserId=e.leadId,this.channel=`webchat_${this.leadUserId}`,e.timestamp&&function(e,t){Ue(2,arguments);var n=qe(e),i=qe(t);return n.getTime()>i.getTime()}(e.timestamp,Rr(new Date,this.ttlHours))&&this.createChatStorageKey(this.leadUserId);const t=await this.fetchToken(this.leadUserId,this.channel);return t?(this.pubnub=new(Nr())({publishKey:t.keys.publish_key,subscribeKey:t.keys.subscribe_key,userId:this.leadUserId,authKey:t.auth.result.token}),this.withAuthToken((()=>new Promise((()=>this.handleChatListeners())))),await this.withAuthToken((()=>this.getChannelHistory())),this.pubnub):void 0}async fetchToken(e,n){try{return(await t().get(`${this.apiHost}/platformApi/webchat/pn/request-token?user_id=${e}&channel=${n}`)).data}catch(e){ti({logTitle:"PUBNUB_ERROR_FETCHING_TOKEN",logData:{error:e},logType:ei.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}return null}async fetchChannelExists(e){try{return(await t().get(`${this.apiHost}/platformApi/webchat/check-channel-exists?channel_name=${e}`)).data}catch(e){ti({logTitle:"PUBNUB_ERROR_FETCHING_CHANNEL_EXISTS",logData:{error:e},logType:ei.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}return!1}async withAuthToken(t){try{await t()}catch(n){if(n instanceof e.AxiosError&&n&&n.response&&403===n.response.status)try{if(!this.pubnub||!this.leadUserId||!this.channel)return;const e=await this.fetchToken(this.leadUserId,this.channel);if(!e)return;this.pubnub.setAuthKey(e.auth.result.token),await t()}catch(e){ti({logTitle:"PUBNUB_ERROR_REFETCHING_TOKEN",logData:{retryError:e},logType:ei.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}}async getChannelHistory(){var e;try{const t=await new Promise(((e,t)=>{this.pubnub&&this.channel&&this.pubnub.fetchMessages({channels:[this.channel],count:100},((n,i)=>{n.error?(ti({logTitle:"PUBNUB_ERROR_FETCHING_HISTORY",logData:{channel:this.channel,status:n,response:i},logType:ei.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug}),t(n)):e(i)}))}));if(this.channel&&0!==Object.keys(t.channels).length){const n=t.channels[this.channel],i=[];n.forEach((e=>{e.uuid&&i.push({channel:e.channel,message:e.message,publisher:e.uuid,subscription:e.channel,timetoken:+e.timetoken})})),this.messages=i,null===(e=this.chatListener)||void 0===e||e.call(this,{messages:this.messages,isLoading:!1})}}catch(e){ti({logTitle:"PUBNUB_ERROR_FETCHING_HISTORY",logData:{error:e},logType:ei.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}}(this.buildingSlug,this.building,this.orgSlug),this.myPubnub.isChatKeyValid(this.myPubnub.getChatStorageKey(!1))&&await this.myPubnub.initializePubnub(),this.attachOnClickToLauncher(),this.shouldAutoOpenChat(this.building.autoOpenChatWidget)&&(this.displayPubnubChat=!0,this.hideLauncher=!0,this.hasMounted=!0,this.updateAlreadyAutoOpenedTimestamp()),this.isLoading=!1))},this.handleContactClicked=e=>{var t,n;this.chatProvider===Br.TALKJS?null===(t=this.popup)||void 0===t||t.hide():this.chatProvider===Br.PUBNUB&&(this.displayPubnubChat=!1),this.hideLauncher=!1,null===(n=this.launcherRef.value)||void 0===n||n.onClickEmailOption(e)},this.handleTourClicked=e=>{var t,n;this.chatProvider===Br.TALKJS?null===(t=this.popup)||void 0===t||t.hide():this.chatProvider===Br.PUBNUB&&(this.displayPubnubChat=!1),this.hideLauncher=!1,null===(n=this.launcherRef.value)||void 0===n||n.onClickSSTOption(e)},this.handleContactTabClicked=e=>{var t,n;this.chatProvider===Br.TALKJS?null===(t=this.popup)||void 0===t||t.hide():this.chatProvider===Br.PUBNUB&&(this.displayPubnubChat=!1),this.hideLauncher=!1,null===(n=this.launcherRef.value)||void 0===n||n.onClickPhoneOption(e)},this.adjustTopHeaderContactCoords=()=>{var e,t,n,i;const r=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById(this.chatProvider===Br.TALKJS?"chatAdditionalActionsTalkjs":"chatAdditionalActionsPubnub");if(r)if(this.chatProvider===Br.TALKJS&&this.talkjsPopupElement){const e=this.talkjsPopupElement.getBoundingClientRect();r.style.left=`${e.left+20}px`,r.style.top=e.bottom-24+"px"}else if(this.chatProvider===Br.PUBNUB){const e=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"),o=null==e?void 0:e.getBoundingClientRect();if(!o)return;r.style.left=`${o.left}px`,r.style.top=`${o.bottom}px`}},this.onClickMinimize=e=>{e.preventDefault(),e.stopPropagation(),this.isMinimized=!this.isMinimized},this.renderChatAdditionalActions=(e,t)=>{var n,i,r,o,a,s,u,l;return B` <div
|
|
3252
|
+
`:B``}};Ur.styles=[Fr],kr([de({attribute:!0})],Ur.prototype,"channel",void 0),kr([de({attribute:!0})],Ur.prototype,"myPubnub",void 0),kr([de({attribute:!0})],Ur.prototype,"buildingSlug",void 0),kr([de({attribute:!0})],Ur.prototype,"building",void 0),kr([de({attribute:!0})],Ur.prototype,"brandColor",void 0),kr([de({attribute:!0})],Ur.prototype,"onClickExit",void 0),kr([de({attribute:!0})],Ur.prototype,"onMount",void 0),kr([pe("#message-input",!0)],Ur.prototype,"messageInput",void 0),kr([pe("#conversation-body",!0)],Ur.prototype,"messageBody",void 0),kr([ce()],Ur.prototype,"messages",void 0),kr([ce()],Ur.prototype,"isMobile",void 0),kr([ce()],Ur.prototype,"isLoadingMessages",void 0),kr([ce()],Ur.prototype,"websitePreviewMapping",void 0),Ur=kr([ue("pubnub-chat")],Ur);var qr,Br,Lr=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};!function(e){e.TALKJS="talkjs",e.PUBNUB="pubnub"}(Br||(Br={}));let Jr=qr=class extends ae{constructor(){super(...arguments),this.buildingSlug="",this.orgSlug="",this.themeId="Glass",this.useMiniWidget=!0,this.launcherStyles={},this.isMinimized=!1,this.brandColor=null,this.popup=null,this.theme=Si({themeId:this.themeId,brandColor:this.brandColor}),this.chatId="",this.analytics=null,this.isMobile=r(),this.launcher=null,this.building=null,this.buildingABTestType=null,this.leadSources=null,this.currentLeadSource=null,this.featureFlagShowDropdown=qn.always,this.phoneNumberForSource=null,this.hasMounted=!1,this.hideLauncher=!1,this.isLoading=!0,this.talkjsPopupElement=null,this.chatProvider=Br.TALKJS,this.displayPubnubChat=!1,this.myPubnub=null,this.yardiDNIScriptInterval=null,this.launcherRef=Oe(),this.initializeInstanceVariables=async()=>{qr.session=Ee.ready.then((()=>{const e=new Ee.User({id:"anonymous-"+di(this.orgSlug,this.buildingSlug),name:"Me",email:null,role:"Default"});return new Ee.Session({appId:"ogKIvCor",me:e})})),await this.setBuildingDerivedInfo(),await this.initializeLaunchJS()&&(this.attachOnClickToLauncher(),this.isLoading=!1)},this.setBuildingDerivedInfo=async()=>{var e,n,i;if(!this.buildingSlug||!this.orgSlug)return;const r=await Ai(this.orgSlug,this.buildingSlug);if(1!==r.active)return;const[o,a,s,u,l,d]=await Promise.all([Ii(this.buildingSlug),Cr(this.buildingSlug),Ni(this.buildingSlug,document.referrer),Bn(this.buildingSlug),Ln(this.buildingSlug),Ci(this.buildingSlug)]);r.phoneNumber=Pe(r.phoneNumber),this.building=r,this.buildingABTestType=null!==(e=null==o?void 0:o.abTestType)&&void 0!==e?e:"",this.leadSources=a,this.currentLeadSource=s,this.featureFlagShowDropdown=u,d&&(null===this.brandColor&&(this.brandColor=null!==(n=d.primaryColor)&&void 0!==n?n:null),this.isMinimized=!!d.autoMinimize,d.designConcept&&(d.designConcept===xi.MINIMIZED&&(this.isMobile=!0),d.designConcept===xi.PILLS&&(this.buildingABTestType=null),d.designConcept===xi.EMOJI&&(this.buildingABTestType=Oi.ConceptEmoji))),null===this.brandColor&&(this.brandColor=vi);let c=null;l&&(c=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:Pe(i.data.number),isMatch:i.data.isMatch,isPropertyWebsiteCatchall:i.data.isPropertyWebsiteCatchall}:null}catch(e){return null}}(this.buildingSlug,this.currentLeadSource)),this.phoneNumberForSource=c||{number:this.building.phoneNumber,isMatch:!1,isPropertyWebsiteCatchall:!0},this.currentLeadSource&&(this.leadSources.includes(this.currentLeadSource)||this.leadSources.push(this.currentLeadSource)),An(this.building.id),this.chatId=di(this.orgSlug,this.buildingSlug),this.avatarSrc=this.avatarSrc||this.building.avatarSrc,this.theme=Si({themeId:null!==(i=this.themeId)&&void 0!==i?i:this.building.themeId,brandColor:this.brandColor}),this.analytics=new Zn(this.orgSlug,this.buildingSlug,this.chatId,this.currentLeadSource),this.analytics.ping("webchat_heartbeat")},this.initializeLaunchJS=async()=>{var e;if(!this.building||!this.theme)return;if(this.popup&&this.launcher)return;const[t,n,i,r]=await Promise.all([this.building,this.theme,this.avatarSrc,qr.session]);return t.conversationMaintenanceMode?(console.warn("MeetElise Chat is in maintenance mode. Chat icon will not appear."),!1):r?(await this.configureTalkJSPopup(t,n,r,i),this.configureLauncherElement(),null===(e=this.analytics)||void 0===e||e.ping("load"),this.yardiDNIScriptInterval=setInterval((()=>this.pollForYardiCampaignSource()),1e3),setTimeout(clearInterval,15e3,this.yardiDNIScriptInterval),!0):void 0},this.configureLauncherElement=()=>{this.popup&&this.launcherRef.value&&(this.launcher=this.launcherRef.value)},this.configureTalkJSPopup=async(e,t,n,i)=>{var r;const o=n.createPopup(Ti(n,e,t,i||e.avatarSrc,this.chatId,this.isMobile),{launcher:"never",showCloseInHeader:!0,messageField:{placeholder:"Ask a question..."}});await o.mount({show:!1}),o.on("close",(()=>{this.hideLauncher=!1}));const a=document.querySelector(".__talkjs_popup");if(this.talkjsPopupElement=a,!a)throw new Error("Failed to find chat window");a.classList.add("meetelise-chat","pane"),this.isMobile||a.classList.add("launcher__desktop"),a.style.zIndex="99999999999",this.popup=o,this.shouldAutoOpenChat(e.autoOpenChatWidget)&&(this.popup.show(),this.hideLauncher=!0,this.hasMounted=!0,this.updateAlreadyAutoOpenedTimestamp(),null===(r=this.analytics)||void 0===r||r.ping("autoOpen"))},this.shouldAutoOpenChat=e=>{const t=sessionStorage.getItem("alreadyAutoOpenedTimestamp"),n=!t||!(t&&!an(un(t)));return!!e&&!!n&&!r()},this.updateAlreadyAutoOpenedTimestamp=()=>{sessionStorage.setItem("alreadyAutoOpenedTimestamp",tn(function(e,t){Ue(2,arguments);var n=et(t);return tt(e,6e4*n)}(new Date,15)))},this.firstUpdated=async()=>{await async function(e){try{return(await t().get(Un(e),{params:{building_slug:e,flag_type:"bool",feature_flag:"use-pubnub-chat-provider",default_str:null,default_bool:!1}})).data}catch(e){return!1}}(this.buildingSlug)?(this.chatProvider=Br.PUBNUB,this.initializePubnubVariables()):this.initializeInstanceVariables()},this.initializePubnubVariables=async()=>{await this.setBuildingDerivedInfo(),this.building&&(this.building.conversationMaintenanceMode?console.warn("MeetElise Chat is in maintenance mode. Chat icon will not appear."):(this.myPubnub=new class{constructor(e,t,n){this.apiHost="https://app.meetelise.com",this.building=null,this.ttlHours=24,this.eliseResponseTimeout=null,this.pubnub=null,this.leadUserId="",this.channel="",this.chatListener=null,this.messages=[],this.listenerParams={message:e=>{var t;this.messages=[...this.messages,{channel:e.channel,message:e.message,publisher:e.publisher,subscription:e.subscription,timetoken:+e.timetoken}];const n="eliseai"!==e.publisher;null===(t=this.chatListener)||void 0===t||t.call(this,{messages:this.messages,isLoading:n}),!n&&this.eliseResponseTimeout&&clearTimeout(this.eliseResponseTimeout),this.isLoadingMessages=n}},this.isLoadingMessages=!1,this.handleChatListeners=()=>{if(this.pubnub&&this.channel)try{this.pubnub.subscribe({channels:[this.channel]}),this.pubnub.addListener(this.listenerParams)}catch(e){ti({logTitle:"PUBNUB_ERROR_ADDING_LISTENER",logData:{error:e,channel:this.channel,leadUserId:this.leadUserId,website:location.href},logType:ei.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this.removeChatListeners=()=>{this.pubnub&&this.channel&&(this.pubnub.unsubscribe({channels:[this.channel]}),this.pubnub.removeListener(this.listenerParams))},this.sendMessage=async e=>{if(e){if(!this.pubnub&&!await this.initializePubnub())return;await this.withAuthToken((async()=>{var t,n;this.pubnub&&this.channel&&(this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.eliseResponseTimeout=setTimeout((()=>{console.error("Elise AI did not respond in time..."),ti({logTitle:"PUBNUB_ERROR_ELISEAI_MESSAGE_TIMEOUT",logData:{channel:this.channel,leadUserId:this.leadUserId,message:e},logType:ei.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}),45e3),await this.pubnub.publish({channel:this.channel,message:{text:e,customType:"lead_message",buildingId:null===(t=this.building)||void 0===t?void 0:t.id,buildingSlug:this.buildingSlug,userId:null===(n=this.building)||void 0===n?void 0:n.userId}}))})),!1===this.isLoadingMessages&&(this.isLoadingMessages=!0)}},this.isLeadMessage=e=>e.publisher.includes("lead_")&&"lead_message"===e.message.customType,this.createChatStorageKey=e=>{const t=tn(new Date),n=null!=e?e:`lead_${li()}_${this.buildingSlug}`;return localStorage.setItem("com.eliseai.webchat.slug="+this.buildingSlug,JSON.stringify({buildingSlug:this.buildingSlug,leadId:n,timestamp:t})),{leadId:n,timestamp:un(t),buildingSlug:this.buildingSlug}},this.getChatStorageKey=(e=!0)=>{const t=localStorage.getItem("com.eliseai.webchat.slug="+this.buildingSlug);if(t)try{const e=JSON.parse(t),n=e.buildingSlug,i=e.leadId,r=new Date(e.timestamp);if(this.isChatKeyValid({leadId:i,timestamp:r,buildingSlug:n}))return{leadId:i,timestamp:r,buildingSlug:n}}catch(e){console.warn("Error getting chat storage key")}return e?this.createChatStorageKey():{leadId:null,timestamp:null,buildingSlug:null}},this.isChatKeyValid=e=>{if(e.buildingSlug!==this.buildingSlug||!e.leadId||!e.timestamp)return!1;const t=Rr(new Date,this.ttlHours);return function(e,t){Ue(2,arguments);var n=qe(e),i=qe(t);return n.getTime()<i.getTime()}(e.timestamp,t)},this.buildingSlug=e,this.building=t,this.orgSlug=n}addChatListener(e){this.chatListener=e}async initializePubnub(){const e=this.getChatStorageKey();if(!e.leadId)return void ti({logTitle:"PUBNUB_ERROR_FETCHING_STORAGE_KEY",logData:{channel:this.channel,eliseaiLocalStorageValue:e,leadUserId:this.leadUserId},logType:ei.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});this.leadUserId=e.leadId,this.channel=`webchat_${this.leadUserId}`,e.timestamp&&function(e,t){Ue(2,arguments);var n=qe(e),i=qe(t);return n.getTime()>i.getTime()}(e.timestamp,Rr(new Date,this.ttlHours))&&this.createChatStorageKey(this.leadUserId);const t=await this.fetchToken(this.leadUserId,this.channel);return t?(this.pubnub=new(Nr())({publishKey:t.keys.publish_key,subscribeKey:t.keys.subscribe_key,userId:this.leadUserId,authKey:t.auth.result.token}),this.withAuthToken((()=>new Promise((()=>this.handleChatListeners())))),await this.withAuthToken((()=>this.getChannelHistory())),this.pubnub):void 0}async fetchToken(e,n){try{return(await t().get(`${this.apiHost}/platformApi/webchat/pn/request-token?user_id=${e}&channel=${n}`)).data}catch(e){ti({logTitle:"PUBNUB_ERROR_FETCHING_TOKEN",logData:{error:e},logType:ei.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}return null}async fetchChannelExists(e){try{return(await t().get(`${this.apiHost}/platformApi/webchat/check-channel-exists?channel_name=${e}`)).data}catch(e){ti({logTitle:"PUBNUB_ERROR_FETCHING_CHANNEL_EXISTS",logData:{error:e},logType:ei.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}return!1}async withAuthToken(t){try{await t()}catch(n){if(n instanceof e.AxiosError&&n&&n.response&&403===n.response.status)try{if(!this.pubnub||!this.leadUserId||!this.channel)return;const e=await this.fetchToken(this.leadUserId,this.channel);if(!e)return;this.pubnub.setAuthKey(e.auth.result.token),await t()}catch(e){ti({logTitle:"PUBNUB_ERROR_REFETCHING_TOKEN",logData:{retryError:e},logType:ei.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}}async getChannelHistory(){var e;try{const t=await new Promise(((e,t)=>{this.pubnub&&this.channel&&this.pubnub.fetchMessages({channels:[this.channel],count:100},((n,i)=>{n.error?(ti({logTitle:"PUBNUB_ERROR_FETCHING_HISTORY",logData:{channel:this.channel,status:n,response:i},logType:ei.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug}),t(n)):e(i)}))}));if(this.channel&&0!==Object.keys(t.channels).length){const n=t.channels[this.channel],i=[];n.forEach((e=>{e.uuid&&i.push({channel:e.channel,message:e.message,publisher:e.uuid,subscription:e.channel,timetoken:+e.timetoken})})),this.messages=i,null===(e=this.chatListener)||void 0===e||e.call(this,{messages:this.messages,isLoading:!1})}}catch(e){ti({logTitle:"PUBNUB_ERROR_FETCHING_HISTORY",logData:{error:e},logType:ei.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}}(this.buildingSlug,this.building,this.orgSlug),this.myPubnub.isChatKeyValid(this.myPubnub.getChatStorageKey(!1))&&await this.myPubnub.initializePubnub(),this.attachOnClickToLauncher(),this.shouldAutoOpenChat(this.building.autoOpenChatWidget)&&(this.displayPubnubChat=!0,this.hideLauncher=!0,this.hasMounted=!0,this.updateAlreadyAutoOpenedTimestamp()),this.isLoading=!1))},this.handleContactClicked=e=>{var t,n;this.chatProvider===Br.TALKJS?null===(t=this.popup)||void 0===t||t.hide():this.chatProvider===Br.PUBNUB&&(this.displayPubnubChat=!1),this.hideLauncher=!1,null===(n=this.launcherRef.value)||void 0===n||n.onClickEmailOption(e)},this.handleTourClicked=e=>{var t,n;this.chatProvider===Br.TALKJS?null===(t=this.popup)||void 0===t||t.hide():this.chatProvider===Br.PUBNUB&&(this.displayPubnubChat=!1),this.hideLauncher=!1,null===(n=this.launcherRef.value)||void 0===n||n.onClickSSTOption(e)},this.handleContactTabClicked=e=>{var t,n;this.chatProvider===Br.TALKJS?null===(t=this.popup)||void 0===t||t.hide():this.chatProvider===Br.PUBNUB&&(this.displayPubnubChat=!1),this.hideLauncher=!1,null===(n=this.launcherRef.value)||void 0===n||n.onClickPhoneOption(e)},this.adjustTopHeaderContactCoords=()=>{var e,t,n,i;const r=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById(this.chatProvider===Br.TALKJS?"chatAdditionalActionsTalkjs":"chatAdditionalActionsPubnub");if(r)if(this.chatProvider===Br.TALKJS&&this.talkjsPopupElement){const e=this.talkjsPopupElement.getBoundingClientRect();r.style.left=`${e.left+20}px`,r.style.top=e.bottom-24+"px"}else if(this.chatProvider===Br.PUBNUB){const e=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"),o=null==e?void 0:e.getBoundingClientRect();if(!o)return;r.style.left=`${o.left}px`,r.style.top=`${o.bottom}px`}},this.onClickMinimize=e=>{e.preventDefault(),e.stopPropagation(),this.isMinimized=!this.isMinimized},this.renderChatAdditionalActions=(e,t)=>{var n,i,r,o,a,s,u,l;return B` <div
|
|
3253
3253
|
id=${e}
|
|
3254
3254
|
class=${ge({showTab:t,hideTab:!t})}
|
|
3255
3255
|
>
|
|
@@ -3387,4 +3387,4 @@ var e={8005:function(e,t,n){var i,r=this&&this.__extends||(i=function(e,t){retur
|
|
|
3387
3387
|
position: fixed;
|
|
3388
3388
|
bottom: 0;
|
|
3389
3389
|
}
|
|
3390
|
-
`,Jr.session=null,Lr([de({type:String})],Jr.prototype,"buildingSlug",void 0),Lr([de({type:String})],Jr.prototype,"orgSlug",void 0),Lr([de({type:String})],Jr.prototype,"themeId",void 0),Lr([de({attribute:!1})],Jr.prototype,"avatarSrc",void 0),Lr([de({type:Boolean})],Jr.prototype,"useMiniWidget",void 0),Lr([de({type:Object})],Jr.prototype,"launcherStyles",void 0),Lr([de({type:Boolean})],Jr.prototype,"isMinimized",void 0),Lr([de({type:String})],Jr.prototype,"brandColor",void 0),Lr([ce()],Jr.prototype,"popup",void 0),Lr([ce()],Jr.prototype,"theme",void 0),Lr([ce()],Jr.prototype,"chatId",void 0),Lr([ce()],Jr.prototype,"analytics",void 0),Lr([ce()],Jr.prototype,"isMobile",void 0),Lr([ce()],Jr.prototype,"launcher",void 0),Lr([ce()],Jr.prototype,"building",void 0),Lr([ce()],Jr.prototype,"buildingABTestType",void 0),Lr([ce()],Jr.prototype,"leadSources",void 0),Lr([ce()],Jr.prototype,"currentLeadSource",void 0),Lr([ce()],Jr.prototype,"featureFlagShowDropdown",void 0),Lr([ce()],Jr.prototype,"phoneNumberForSource",void 0),Lr([ce()],Jr.prototype,"hasMounted",void 0),Lr([ce()],Jr.prototype,"hideLauncher",void 0),Lr([ce()],Jr.prototype,"isLoading",void 0),Lr([ce()],Jr.prototype,"talkjsPopupElement",void 0),Lr([ce()],Jr.prototype,"chatProvider",void 0),Lr([ce()],Jr.prototype,"displayPubnubChat",void 0),Lr([ce()],Jr.prototype,"myPubnub",void 0),Jr=qr=Lr([ue("me-chat")],Jr);class jr{static start(e,t=!0){if(window.location.pathname.includes("residentservices")||window.location.pathname.includes("onlineleasing"))return;t&&(this.orgSlug=e.organization,this.hasBuildingSlug=!!e.building),Hr(),Gr();const n=document.createElement("me-chat");n.setAttribute("orgSlug",e.organization),this.handleBuildingslug(n,e.building),n.setAttribute("class","meetelise-chat"),n.setAttribute("role","dialog"),n.setAttribute("aria-label","EliseAI Widget"),n.setAttribute("aria-describedby","aria-describe-info"),n.setAttribute("aria-modal","true"),e.themeId&&n.setAttribute("themeId",e.themeId),e.avatarSrc&&n.setAttribute("avatarSrc",e.avatarSrc),void 0!==e.mini&&(n.useMiniWidget=e.mini),e.launcherStyles&&(n.launcherStyles=e.launcherStyles),e.brandColor&&(this.brandColor=e.brandColor,n.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))),document.body.appendChild(n),jr.meChat=n,e.building&&e.organization&&zr(e.organization,e.building)}static async restartConversation(){this.meChat&&await this.meChat.restartConversation()}static async remove(){this.meChat&&(await this.meChat.remove(),document.body.removeChild(this.meChat),jr.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 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(!i||!i.data)return;const r={organization:this.orgSlug,building:i.data,brandColor:this.brandColor};this.start(r,!1)}}jr.meChat=null,jr.orgSlug="",jr.mutationObserver=null,jr.previousUrl="",jr.hasBuildingSlug=null,jr.brandColor="";const Hr=()=>{const e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("type","text/css"),document.head.appendChild(e)},Gr=()=>{const e=document.createElement("meta");e.setAttribute("name","viewport"),e.setAttribute("content","width=device-width, initial-scale=1, maximum-scale=2"),document.head.appendChild(e)},zr=async(e,n)=>{var i;const r=await async function(e){try{return(await t().get(Un(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(!r)return;const o=document.getElementById("myContactForm");let a;if(!(o&&o instanceof HTMLFormElement))return void(window.location.pathname.toLowerCase().includes("contactus")&&Qr(n,e,"Could not find form"));for(let e=0;e<o.elements.length;e++){const t=o.elements[e];if("button"===t.tagName.toLowerCase()&&"fakebutton"===t.getAttribute("data-selenium-id")){a=t;break}}if(!a)return Qr(n,e,"Could not find submit button");const s=()=>({firstName:document.getElementById("firstname"),lastName:document.getElementById("lastname"),email:document.getElementById("email"),phone:document.getElementById("phonenumber"),message:document.getElementById("message")});if(Object.values(s()).some((e=>null===e))){const t=Object.entries(s()).filter((([,e])=>null===e)).map((([e])=>e));return Qr(n,e,"Missing the following form elements: "+t.join(", "))}const u=a.textContent,l=a.cloneNode(!0);null===(i=a.parentNode)||void 0===i||i.replaceChild(l,a),l.onclick=async function(t){if(Object.values(s()).forEach((e=>{"true"!==(null==e?void 0:e.getAttribute("aria-required"))||e.value||(e.className="form-control required is-invalid")})),!Object.values(s()).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(),l.textContent="Processing request...",l.disabled=!0;const i={};Object.entries(s()).forEach((([e,t])=>i[e]=null==t?void 0:t.value));const r=await Ai(e,n),a=await Ni(n,document.referrer);if(!r)return Qr(n,e,"Could not find building"),null;const d={email_address:i.email,first_name:i.firstName,last_name:i.lastName,phone_number:i.phone,first_message:i.message,building_id:r.id,is_external_form:!0,lead_sources:[...new Set(a?[a,"property-website"]:["property-website"])]},c=JSON.stringify(d);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 o.reset(),Object.values(s()).forEach((e=>{e&&(e.disabled=!0)})),l.textContent="Submitted",l.disabled=!0,e.json()})).catch((()=>{l.textContent=u}))}},Qr=(e,t,n)=>{const i=JSON.stringify({orgSlug:t,buildingSlug:e,reason:n});fetch("https://app.meetelise.com/platformApi/webchat/form-override-error",{method:"POST",headers:{"Content-Type":"application/json","building-slug":e,"org-slug":t},body:i})}})();var r=i.Z;export{r as default};
|
|
3390
|
+
`,Jr.session=null,Lr([de({type:String})],Jr.prototype,"buildingSlug",void 0),Lr([de({type:String})],Jr.prototype,"orgSlug",void 0),Lr([de({type:String})],Jr.prototype,"themeId",void 0),Lr([de({attribute:!1})],Jr.prototype,"avatarSrc",void 0),Lr([de({type:Boolean})],Jr.prototype,"useMiniWidget",void 0),Lr([de({type:Object})],Jr.prototype,"launcherStyles",void 0),Lr([de({type:Boolean})],Jr.prototype,"isMinimized",void 0),Lr([de({type:String})],Jr.prototype,"brandColor",void 0),Lr([ce()],Jr.prototype,"popup",void 0),Lr([ce()],Jr.prototype,"theme",void 0),Lr([ce()],Jr.prototype,"chatId",void 0),Lr([ce()],Jr.prototype,"analytics",void 0),Lr([ce()],Jr.prototype,"isMobile",void 0),Lr([ce()],Jr.prototype,"launcher",void 0),Lr([ce()],Jr.prototype,"building",void 0),Lr([ce()],Jr.prototype,"buildingABTestType",void 0),Lr([ce()],Jr.prototype,"leadSources",void 0),Lr([ce()],Jr.prototype,"currentLeadSource",void 0),Lr([ce()],Jr.prototype,"featureFlagShowDropdown",void 0),Lr([ce()],Jr.prototype,"phoneNumberForSource",void 0),Lr([ce()],Jr.prototype,"hasMounted",void 0),Lr([ce()],Jr.prototype,"hideLauncher",void 0),Lr([ce()],Jr.prototype,"isLoading",void 0),Lr([ce()],Jr.prototype,"talkjsPopupElement",void 0),Lr([ce()],Jr.prototype,"chatProvider",void 0),Lr([ce()],Jr.prototype,"displayPubnubChat",void 0),Lr([ce()],Jr.prototype,"myPubnub",void 0),Jr=qr=Lr([ue("me-chat")],Jr);class jr{static start(e,t=!0){if(window.location.pathname.includes("residentservices")||window.location.pathname.includes("onlineleasing"))return;t&&(this.orgSlug=e.organization,this.hasBuildingSlug=!!e.building),Hr(),Gr();const n=document.createElement("me-chat");n.setAttribute("orgSlug",e.organization),this.handleBuildingslug(n,e.building),n.setAttribute("class","meetelise-chat"),n.setAttribute("role","dialog"),n.setAttribute("aria-label","EliseAI Widget"),n.setAttribute("aria-describedby","aria-describe-info"),n.setAttribute("aria-modal","true"),e.themeId&&n.setAttribute("themeId",e.themeId),e.avatarSrc&&n.setAttribute("avatarSrc",e.avatarSrc),void 0!==e.mini&&(n.useMiniWidget=e.mini),e.launcherStyles&&(n.launcherStyles=e.launcherStyles),e.brandColor&&(this.brandColor=e.brandColor,n.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))),document.body.appendChild(n),jr.meChat=n,e.building&&e.organization&&zr(e.organization,e.building)}static async restartConversation(){this.meChat&&await this.meChat.restartConversation()}static async remove(){this.meChat&&(await this.meChat.remove(),document.body.removeChild(this.meChat),jr.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 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(!i||!i.data)return;const r={organization:this.orgSlug,building:i.data,brandColor:this.brandColor};this.start(r,!1)}}jr.meChat=null,jr.orgSlug="",jr.mutationObserver=null,jr.previousUrl="",jr.hasBuildingSlug=null,jr.brandColor="";const Hr=()=>{const e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("type","text/css"),document.head.appendChild(e)},Gr=()=>{const e=document.createElement("meta");e.setAttribute("name","viewport"),e.setAttribute("content","width=device-width, initial-scale=1, maximum-scale=2"),document.head.appendChild(e)},zr=async(e,n)=>{var i;const r=await async function(e){if(!e)return!1;try{return(await t().get(Un(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(!r)return;const o=document.getElementById("myContactForm");let a;if(!(o&&o instanceof HTMLFormElement))return void(window.location.pathname.toLowerCase().includes("contactus")&&Qr(n,e,"Could not find form"));for(let e=0;e<o.elements.length;e++){const t=o.elements[e];if("button"===t.tagName.toLowerCase()&&"fakebutton"===t.getAttribute("data-selenium-id")){a=t;break}}if(!a)return Qr(n,e,"Could not find submit button");const s=()=>({firstName:document.getElementById("firstname"),lastName:document.getElementById("lastname"),email:document.getElementById("email"),phone:document.getElementById("phonenumber"),message:document.getElementById("message")});if(Object.values(s()).some((e=>null===e))){const t=Object.entries(s()).filter((([,e])=>null===e)).map((([e])=>e));return Qr(n,e,"Missing the following form elements: "+t.join(", "))}const u=a.textContent,l=a.cloneNode(!0);null===(i=a.parentNode)||void 0===i||i.replaceChild(l,a),l.onclick=async function(t){if(Object.values(s()).forEach((e=>{"true"!==(null==e?void 0:e.getAttribute("aria-required"))||e.value||(e.className="form-control required is-invalid")})),!Object.values(s()).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(),l.textContent="Processing request...",l.disabled=!0;const i={};Object.entries(s()).forEach((([e,t])=>i[e]=null==t?void 0:t.value));const r=await Ai(e,n),a=await Ni(n,document.referrer);if(!r)return Qr(n,e,"Could not find building"),null;const d={email_address:i.email,first_name:i.firstName,last_name:i.lastName,phone_number:i.phone,first_message:i.message,building_id:r.id,is_external_form:!0,lead_sources:[...new Set(a?[a,"property-website"]:["property-website"])]},c=JSON.stringify(d);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 o.reset(),Object.values(s()).forEach((e=>{e&&(e.disabled=!0)})),l.textContent="Submitted",l.disabled=!0,e.json()})).catch((()=>{l.textContent=u}))}},Qr=(e,t,n)=>{const i=JSON.stringify({orgSlug:t,buildingSlug:e,reason:n});fetch("https://app.meetelise.com/platformApi/webchat/form-override-error",{method:"POST",headers:{"Content-Type":"application/json","building-slug":e,"org-slug":t},body:i})}})();var r=i.Z;export{r as default};
|
|
@@ -199,8 +199,12 @@ export class MEChat extends LitElement {
|
|
|
199
199
|
if (!this.buildingSlug || !this.orgSlug) {
|
|
200
200
|
return;
|
|
201
201
|
}
|
|
202
|
+
const building = await fetchBuildingInfo(this.orgSlug, this.buildingSlug);
|
|
203
|
+
if (building.active !== 1) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
|
|
202
207
|
const [
|
|
203
|
-
building,
|
|
204
208
|
buildingABTest,
|
|
205
209
|
leadSources,
|
|
206
210
|
currentLeadSource,
|
|
@@ -208,7 +212,6 @@ export class MEChat extends LitElement {
|
|
|
208
212
|
featureFlagUseDNI,
|
|
209
213
|
webchatPreferences,
|
|
210
214
|
] = await Promise.all([
|
|
211
|
-
fetchBuildingInfo(this.orgSlug, this.buildingSlug),
|
|
212
215
|
fetchBuildingABTestType(this.buildingSlug),
|
|
213
216
|
fetchLeadSources(this.buildingSlug),
|
|
214
217
|
fetchCurrentParsedLeadSource(this.buildingSlug, document.referrer),
|
package/src/fetchBuildingInfo.ts
CHANGED
package/src/fetchFeatureFlag.ts
CHANGED
|
@@ -64,6 +64,9 @@ export async function fetchFeatureFlagUsePhoneNumberBySource(
|
|
|
64
64
|
export async function fetchFeatureFlagUseOverrideContactUsForm(
|
|
65
65
|
buildingSlug: string
|
|
66
66
|
): Promise<boolean> {
|
|
67
|
+
if (!buildingSlug) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
67
70
|
try {
|
|
68
71
|
const featureFlagResponse = await axios.get(
|
|
69
72
|
featureFlagEndpoint(buildingSlug),
|