@meetelise/chat 1.51.5 → 1.51.6
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.
|
@@ -5,6 +5,7 @@ import "./pubnub-media";
|
|
|
5
5
|
import { WidgetType } from "../main/MEChat";
|
|
6
6
|
import { BuildingWebchatView } from "../fetchBuildingWebchatView";
|
|
7
7
|
export declare class PubnubChat extends LitElement {
|
|
8
|
+
private static readonly AUTO_SCROLL_THRESHOLD_PX;
|
|
8
9
|
static styles: import("lit").CSSResult[];
|
|
9
10
|
private right;
|
|
10
11
|
private bottom;
|
|
@@ -26,6 +27,7 @@ export declare class PubnubChat extends LitElement {
|
|
|
26
27
|
messageBody: HTMLDivElement;
|
|
27
28
|
_isMobile: boolean;
|
|
28
29
|
private _cleanupMobileListener?;
|
|
30
|
+
private shouldAutoScroll;
|
|
29
31
|
messages: SimpleChatMessage[];
|
|
30
32
|
isLoadingMessages: boolean;
|
|
31
33
|
hasReceivedConsent: boolean;
|
|
@@ -45,6 +47,7 @@ export declare class PubnubChat extends LitElement {
|
|
|
45
47
|
sendMessage: (message: string) => Promise<void>;
|
|
46
48
|
firstUpdated(): void;
|
|
47
49
|
scrollToChatBottom: () => void;
|
|
50
|
+
private handleConversationScroll;
|
|
48
51
|
updated(): Promise<void>;
|
|
49
52
|
autoResizeMessageInput: () => void;
|
|
50
53
|
needsConsent: () => boolean;
|
package/package.json
CHANGED
package/public/dist/index.js
CHANGED
|
@@ -6032,7 +6032,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
6032
6032
|
${Qa}
|
|
6033
6033
|
${Wa}
|
|
6034
6034
|
${Va}
|
|
6035
|
-
`,Fl([ue({attribute:!0})],Hl.prototype,"isMinimized",void 0),Fl([ue()],Hl.prototype,"mobileStyles",void 0),Fl([ue({type:Boolean})],Hl.prototype,"isFirstMount",void 0),Fl([ue({attribute:!1})],Hl.prototype,"autoOpenChatWidget",void 0),Fl([ue()],Hl.prototype,"phoneNumber",void 0),Fl([ue({attribute:!0})],Hl.prototype,"buildingName",void 0),Fl([ue({attribute:!0})],Hl.prototype,"chatId",void 0),Fl([ue({attribute:!0})],Hl.prototype,"orgLegalName",void 0),Fl([ue({attribute:!1})],Hl.prototype,"country",void 0),Fl([ue({attribute:!0})],Hl.prototype,"chatCallUsHeader",void 0),Fl([ue({attribute:!1})],Hl.prototype,"buildingId",void 0),Fl([ue({type:Number})],Hl.prototype,"orgId",void 0),Fl([ue({attribute:!1})],Hl.prototype,"leadSourceParams",void 0),Fl([ue({attribute:!0})],Hl.prototype,"buildingSlug",void 0),Fl([ue({attribute:!0})],Hl.prototype,"orgSlug",void 0),Fl([ue({attribute:!0})],Hl.prototype,"sgtUrl",void 0),Fl([ue({attribute:!0})],Hl.prototype,"selfGuidedTourEnabled",void 0),Fl([ue({attribute:!0})],Hl.prototype,"selfGuidedToursTypeOffered",void 0),Fl([ue({attribute:!0})],Hl.prototype,"designConcept",void 0),Fl([ue({attribute:!0})],Hl.prototype,"featureFlagShowDropdown",void 0),Fl([ue({attribute:!1})],Hl.prototype,"leadSources",void 0),Fl([ue({attribute:!0})],Hl.prototype,"currentLeadSource",void 0),Fl([ue({attribute:!0})],Hl.prototype,"escortedToursLink",void 0),Fl([ue({attribute:!0})],Hl.prototype,"escortedToursTypeOffered",void 0),Fl([ue({attribute:!0})],Hl.prototype,"virtualToursLink",void 0),Fl([ue({attribute:!0})],Hl.prototype,"virtualToursTypeOffered",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasChatEnabledDesktop",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasChatEnabledMobile",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasEmailEnabledDesktop",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasEmailEnabledMobile",void 0),Fl([ue({attribute:!0})],Hl.prototype,"hasApplyNowEnabledDesktop",void 0),Fl([ue({attribute:!0})],Hl.prototype,"hasApplyNowEnabledMobile",void 0),Fl([ue({attribute:!0})],Hl.prototype,"applicationLink",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasCallUsEnabledDesktop",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasCallUsEnabledMobile",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasTextUsEnabledDesktop",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasTextUsEnabledMobile",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasSSTEnabledDesktop",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasSSTEnabledMobile",void 0),Fl([ue({attribute:!1})],Hl.prototype,"tourTypeOptions",void 0),Fl([ue({attribute:!1})],Hl.prototype,"layoutOptions",void 0),Fl([ue({attribute:!0})],Hl.prototype,"bedroomPreferenceRequired",void 0),Fl([ue({attribute:!0})],Hl.prototype,"hasDynamicSchedulingEnabled",void 0),Fl([ue({attribute:!0})],Hl.prototype,"hasPricingCalculatorEnabledDesktop",void 0),Fl([ue({attribute:!0})],Hl.prototype,"hasPricingCalculatorEnabledMobile",void 0),Fl([ue({attribute:!1})],Hl.prototype,"hasHideMobileFeatures",void 0),Fl([ue({type:Number})],Hl.prototype,"right",void 0),Fl([ue({type:Number})],Hl.prototype,"bottom",void 0),Fl([ue({type:Number})],Hl.prototype,"top",void 0),Fl([ue({type:Number})],Hl.prototype,"left",void 0),Fl([ue({attribute:!0})],Hl.prototype,"showTourNextToChat",void 0),Fl([ue({attribute:!1})],Hl.prototype,"onChatTapped",void 0),Fl([ue({attribute:!0})],Hl.prototype,"onClickMinimize",void 0),Fl([ue({attribute:!0})],Hl.prototype,"onSstClose",void 0),Fl([ue({attribute:!0})],Hl.prototype,"overrideRentgrata",void 0),Fl([ue({attribute:!1})],Hl.prototype,"launcherStyles",void 0),Fl([ue({attribute:!0})],Hl.prototype,"primaryColor",void 0),Fl([ue({attribute:!0})],Hl.prototype,"backgroundColor",void 0),Fl([ue({attribute:!0})],Hl.prototype,"foregroundColorOnPrimaryBackgroundColor",void 0),Fl([ue({attribute:!0})],Hl.prototype,"foregroundColorOnSecondaryBackgroundColor",void 0),Fl([ue({attribute:!0})],Hl.prototype,"leadSourceClient",void 0),Fl([de()],Hl.prototype,"leadSourceMultitouchClient",void 0),Fl([de()],Hl.prototype,"_isMobile",void 0),Fl([de()],Hl.prototype,"isEmailWindowOpen",void 0),Fl([de()],Hl.prototype,"isCallUsWindowOpen",void 0),Fl([de()],Hl.prototype,"isSSTWindowOpen",void 0),Fl([de()],Hl.prototype,"isTextUsWindowOpen",void 0),Fl([de()],Hl.prototype,"isCalculatorWindowOpen",void 0),Fl([de()],Hl.prototype,"isMobileFeaturesExpanded",void 0),Hl=Fl([se("meetelise-launcher")],Hl);const Gl=()=>{window.customElements.get("meetelise-launcher")||window.customElements.define("meetelise-launcher",Hl)},zl=["app.meetelise.com","staging.eliseai.com","localhost"],Ql={calculator:{desktop:"calcDesktop",mobile:"calcMobile"},email:{desktop:"emailDesktop",mobile:"emailMobile"},call:{desktop:"callDesktop",mobile:"callMobile"},text:{desktop:"textDesktop",mobile:"textMobile"},sst:{desktop:"sstDesktop",mobile:"sstMobile"}},Wl=e=>{const t=window.location.hostname;if(!zl.includes(t))return e;const n=(e=>{if(!e)return{};try{return e.split(",").reduce((e,t)=>{const[n,i]=t.split(":");return n&&i&&n in Ql&&(e[n]="true"===i.toLowerCase()),e},{})}catch(e){return{}}})(new URLSearchParams(window.location.search).get("widgets"));if(0===Object.keys(n).length)return e;const i={...e};return Object.entries(n).forEach(([e,t])=>{const n=Ql[e];n&&(i[n.desktop]=t,i[n.mobile]=t)}),i};var Vl=n(5072),ql=n.n(Vl),Yl=n(7825),Kl=n.n(Yl),Xl=n(7659),Zl=n.n(Xl),Jl=n(5056),eu=n.n(Jl),tu=n(540),nu=n.n(tu),iu=n(1113),ru=n.n(iu),ou=n(5541),au={};au.styleTagTransform=ru(),au.setAttributes=eu(),au.insert=Zl().bind(null,"head"),au.domAPI=Kl(),au.insertStyleElement=nu();ql()(ou.A,au);ou.A&&ou.A.locals&&ou.A.locals;async function su(e,t){try{const n=await r().get(`https://app.meetelise.com/platformApi/webchat/${t}/lead-sources`);if(n.data){if("7e352741-1120-4ccf-9929-5dc99193a908"===e){const e=["Zillow","Apartments.com","Google PPC","Google Maps","Apple Maps","Social Media","Print Marketing"];return n.data.filter(t=>e.includes(t))}return lu(n.data,t)}return[]}catch(e){return[]}}const lu=(e,t)=>{let n=[];switch(t){case"d41619ec-0f79-11ee-8439-93855926ad58":n=["Forthea - PPC","HotPads","Forthea","Locator","Website-apartmentguide.com","Forthea - organic search","Tdc employee","University newspaper","Nashville apartment locators","Forthea - paid social","Apartment list","Off campus partners","Waze ads","Athletic event","Website-apartment guide"];break;case"d4160560-0f79-11ee-8438-fba837bf3a46":n=["Forthea - PPC","Rentgrata","Website-ApartmentFinder.com","Word of Mouth","Texas A&M A-Frame on Campus","Rent.com","Website-craigslist","Apartment List","Website-apartments.com","Forthea - paid social","Forthea - organic search","Website-apartmentguide.com","Forthea","Uhomes","Phone book","Property - website"];break;default:n=[]}return e.sort(),e.filter(e=>{const t=e.toLowerCase();return!n.map(e=>e.toLowerCase()).includes(t)})};async function uu(e){var t,n;if(!e)return!1;try{return null!==(n=null===(t=(await r().get(`https://app.meetelise.com/platformApi/webchat/${e}/aip`)).data)||void 0===t?void 0:t.is_aip)&&void 0!==n&&n}catch(e){return!1}}var du,cu=n(8805),hu=n.n(cu),pu=new Uint8Array(16);function fu(){if(!du&&!(du="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return du(pu)}const gu=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;const mu=function(e){return"string"==typeof e&&gu.test(e)};for(var yu=[],bu=0;bu<256;++bu)yu.push((bu+256).toString(16).substr(1));const vu=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(yu[e[t+0]]+yu[e[t+1]]+yu[e[t+2]]+yu[e[t+3]]+"-"+yu[e[t+4]]+yu[e[t+5]]+"-"+yu[e[t+6]]+yu[e[t+7]]+"-"+yu[e[t+8]]+yu[e[t+9]]+"-"+yu[e[t+10]]+yu[e[t+11]]+yu[e[t+12]]+yu[e[t+13]]+yu[e[t+14]]+yu[e[t+15]]).toLowerCase();if(!mu(n))throw TypeError("Stringified UUID is invalid");return n};const wu=function(e,t,n){var i=(e=e||{}).random||(e.rng||fu)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){n=n||0;for(var r=0;r<16;++r)t[n+r]=i[r];return t}return vu(i)},Cu=e=>localStorage.removeItem("com.elise.webchat.slug="+e),xu=(e,t,n)=>{const i=Rr(new Date),r=n||`lead_${wu()}`;return localStorage.setItem("com.elise.webchat.slug="+e,JSON.stringify({buildingSlug:e,leadId:r,timestamp:i,initiatedChat:t})),{leadId:r,timestamp:Wr(i),buildingSlug:e,initiatedChat:t}},$u=e=>{const t=localStorage.getItem("com.elise.webchat.slug="+e);if(t)try{const n=JSON.parse(t),i={leadId:n.leadId,timestamp:new Date(n.timestamp),buildingSlug:n.buildingSlug,initiatedChat:n.initiatedChat};if(Su(e,i))return i}catch(e){}return{leadId:null,timestamp:null,buildingSlug:null,initiatedChat:!1}},Su=(e,t)=>{try{if(t.timestamp&&t.initiatedChat){const e=new Date("2024-06-06T21:30:00Z");if(xr(t.timestamp,e))return!1}}catch(e){}return!(t.buildingSlug!==e||!t.leadId||!t.timestamp)&&!Pr(t.timestamp,24)};var Au;!function(e){e.noReply="no-reply",e.text="text",e.media="media"}(Au||(Au={}));const Eu=e=>e.type===ku.text,Tu=e=>e.type===ku.media;var ku;!function(e){e.text="text",e.media="media"}(ku||(ku={}));const _u=class{constructor(e,t,n,i=null,r,o,a=null,s=Oc.Default){this.apiHost="https://app.meetelise.com",this.leadSourceClient=null,this.leadSourceMultitouchClient=null,this.buildingWebchatView=null,this.eliseResponseTimeout=null,this.isWaitingForStreamingMessages=!1,this.widgetType=Oc.Default,this.pubnub=null,this.leadUserId="",this.channel="",this.leadSource=null,this.sessionToken=null,this.isCurrentlyStreamingMessage=!1,this.chatListener=null,this.rawPubnubMessages=[],this.simpleChatMessages=[],this.listenerParams={message:e=>{var t,n;const i={channel:e.channel,message:e.message,publisher:e.publisher,subscription:e.subscription,timetoken:+e.timetoken};this.rawPubnubMessages=[...this.rawPubnubMessages,i],this.markEveryPreviousNoReplyMessageDone(this.rawPubnubMessages),this.rawPubnubMessages=this.rawPubnubMessages.filter(e=>e.message.messageType!==Au.noReply),this.simpleChatMessages=this.translatePubnubMessagesIntoSimpleChatMessages(this.rawPubnubMessages),this.checkAndHandleDelayStreamingMessages();const r="eliseai"!==e.publisher&&"elise_health_ai"!==e.publisher;if(null===(t=this.chatListener)||void 0===t||t.call(this,{messages:this.simpleChatMessages,isLoading:r}),!r&&this.eliseResponseTimeout&&clearTimeout(this.eliseResponseTimeout),this.isLoadingMessages=r,"ai_message"===e.message.customType){this.simpleChatMessages.some(e=>e.type===ku.text&&e.message.includes("confirmed for your"))&&xo("scheduledTourEvent",{tourDetails:e.message,buildingId:null===(n=this.buildingWebchatView)||void 0===n?void 0:n.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel})}this.checkAndHandleGTMForLeadEmail(e)}},this.isLoadingMessages=!1,this.isFirstChatMessageSent=!1,this.streamingMessageTimeout=null,this.checkAndHandleDelayStreamingMessages=({delayToFetchHistoryInMs:e=1e4}={})=>{this.streamingMessageTimeout&&(clearTimeout(this.streamingMessageTimeout),this.streamingMessageTimeout=null);const t=this.simpleChatMessages.some(e=>{if(!Eu(e))return!1;const t=e.chunks.find(e=>e.isDone);return!t||e.chunks.length===t.order});t&&(this.streamingMessageTimeout=setTimeout(()=>{Fo({logTitle:"PUBNUB_WARN_DELAYED_STREAMING_MESSAGES",logData:{channel:this.channel},logType:jo.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug}),this.getChannelHistory()},e))},this.checkAndHandleGTMForLeadEmail=e=>{var t;try{if("lead_message"!==e.message.customType)return;if(!(e=>{try{return/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b/.test(e)}catch(e){return!1}})(e.message.text))return;xo("leadProvidedEmail",{buildingId:null===(t=this.buildingWebchatView)||void 0===t?void 0:t.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel})}catch(e){return}},this.markEveryPreviousNoReplyMessageDone=e=>{var t,n;for(let i=e.length-1;i>=0;i--){const r=null===(t=e[i])||void 0===t?void 0:t.message,o=i>0&&(null===(n=e[i-1])||void 0===n?void 0:n.message);(null==r?void 0:r.messageType)===Au.noReply&&o&&(o.is_done=!0)}},this.checkMessageChunkValid=e=>{try{return!!e.message&&!!e.message.text&&e.message.text.length>0&&!!e.message.customType}catch(e){return!1}},this.handleChatListeners=()=>{if(this.pubnub&&this.channel)try{this.pubnub.subscribe({channels:[this.channel]}),this.pubnub.addListener(this.listenerParams)}catch(e){this.buildingWebchatView&&Fo({logTitle:"PUBNUB_ERROR_ADDING_LISTENER",logData:{error:e,channel:this.channel,leadUserId:this.leadUserId,website:location.href},logType:jo.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,error:e})}},this.handleDisconnect=()=>{this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.streamingMessageTimeout&&(clearTimeout(this.streamingMessageTimeout),this.streamingMessageTimeout=null),this.removeChatListeners()},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){const e=xu(this.buildingSlug,!0,this.leadUserId);if(!await this.initializePubnub(e))return}await this.withAuthToken(async()=>{var t,n,i,r,o,a,s,l,u;this.pubnub&&this.channel&&(this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.eliseResponseTimeout=setTimeout(()=>{this.buildingWebchatView&&Fo({logTitle:"PUBNUB_ERROR_ELISEAI_MESSAGE_TIMEOUT",logData:{channel:this.channel,leadUserId:this.leadUserId,message:e},logType:jo.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})},9e4),0===this.simpleChatMessages.length&&(null===(t=this.leadSourceClient)||void 0===t||t.checkAndHandleForLogLeadSource({webchatAction:"chat",stateId:null})),this.widgetType===Oc.Utilities?await this.pubnub.publish({channel:this.channel,message:{text:e,customType:"lead_message",widgetType:this.widgetType,isDevState:this.shouldCreateAsDevState(),orgSlug:this.orgSlug}}):(await this.pubnub.publish({channel:this.channel,message:{text:e,customType:"lead_message",buildingId:null===(n=this.buildingWebchatView)||void 0===n?void 0:n.id,buildingSlug:this.buildingSlug,userId:null===(i=this.buildingWebchatView)||void 0===i?void 0:i.userId,leadSource:this.leadSource,widgetType:this.widgetType,isDevState:this.shouldCreateAsDevState(),lead_sources_with_timestamps:(null!==(o=null===(r=this.leadSourceMultitouchClient)||void 0===r?void 0:r.getSafeLeadSourceTouchpointsWithDefault({includedUserSelectedLeadSource:null}))&&void 0!==o?o:[]).map(e=>Er({...e}))}}),null===(a=this.leadSourceClient)||void 0===a||a.resetLeadSource(),null===(s=this.leadSourceMultitouchClient)||void 0===s||s.resetLeadSourceTouchpoints()),this.isFirstChatMessageSent||(xo("firstChatMessageSent",{message:e,buildingId:null===(l=this.buildingWebchatView)||void 0===l?void 0:l.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel}),this.isFirstChatMessageSent=!0),xo("chatMessageSent",{message:e,buildingId:null===(u=this.buildingWebchatView)||void 0===u?void 0:u.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel}))}),!1===this.isLoadingMessages&&(this.isLoadingMessages=!0)}},this.isLeadMessage=e=>e.publisher.includes("lead_")&&"lead_message"===e.message.customType,this.removeDuplicatedRawPubnubMessages=e=>{const t=new Set;return e.filter(e=>{if("lead_message"===e.message.customType||!e.message.stream_id||!e.message.order)return!0;const n=`${e.message.stream_id}-${e.message.order}-${e.message.messageType}`;return t.has(n)?(Fo({logTitle:"PUBNUB_WARN_DUPLICATE_MESSAGE",logData:{message:e,channel:this.channel},logType:jo.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug}),!1):(t.add(n),!0)})},this.translatePubnubMessagesIntoSimpleChatMessages=e=>{const t=[],n={};return this.removeDuplicatedRawPubnubMessages(e).forEach(e=>{var i;"media"===e.message.messageType?t.push({timestamp:e.timetoken,media:null!==(i=e.message.media)&&void 0!==i?i:[],isLeadMessage:this.isLeadMessage(e),type:ku.media}):!e.message.stream_id||e.message.is_done&&0===e.message.order?t.push({timestamp:e.timetoken,message:e.message.text,isLeadMessage:this.isLeadMessage(e),chunks:[{text:e.message.text,order:0,isDone:!0}],type:ku.text}):n[e.message.stream_id]?n[e.message.stream_id].push(e):n[e.message.stream_id]=[e]}),Object.keys(n).forEach(e=>{const i=n[e],r=this.getConsecutiveChunks(i.sort((e,t)=>{var n,i;return(null!==(n=e.message.order)&&void 0!==n?n:0)-(null!==(i=t.message.order)&&void 0!==i?i:0)})),o=r.map(e=>e.message.text).join(""),a=r[0],s={timestamp:a.timetoken,message:o,isLeadMessage:this.isLeadMessage(a),chunks:r.map(e=>{var t,n;return{text:e.message.text,order:null!==(t=e.message.order)&&void 0!==t?t:0,isDone:null!==(n=e.message.is_done)&&void 0!==n&&n}}),type:ku.text};this.isCurrentlyStreamingMessage=this.isMessageStillStreamingChunks(r),t.push(s)}),t.sort((e,t)=>e.timestamp-t.timestamp),t},this.getConsecutiveChunks=e=>{var t,n;const i=e.sort((e,t)=>{var n,i;return(null!==(n=e.message.order)&&void 0!==n?n:0)-(null!==(i=t.message.order)&&void 0!==i?i:0)}),r=[];let o=null!==(t=i[0].message.order)&&void 0!==t?t:0;for(const e of i){if((null!==(n=e.message.order)&&void 0!==n?n:-1)!==o)break;r.push(e),o++}return r},this.isMessageStillStreamingChunks=e=>{const t=e.find(e=>e.message.is_done);return!t||e.length===t.message.order},this.buildingSlug=e,this.buildingWebchatView=t,this.orgSlug=n,this.leadSource=i,this.leadUserId=r,this.channel=`webchat_${r}`,this.leadSourceClient=a,this.leadSourceMultitouchClient=o,this.widgetType=s}async initSession(e,t,n){try{const i={building_slug:e,org_slug:t};n&&(i.lead_id=n);const o=await r().post(`${this.apiHost}/platformApi/webchat/init`,i);return this.sessionToken=o.data.session_token,this.leadUserId=o.data.lead_id,this.channel=o.data.channel,o.data}catch(e){return this.buildingWebchatView&&Fo({logTitle:"WEBCHAT_INIT_SESSION_ERROR",logData:{error:e},logType:jo.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,error:e}),null}}addChatListener(e){this.chatListener=e}async initializePubnub(e){if(!e.leadId)return;this.leadUserId=e.leadId;const t=await this.fetchToken(this.leadUserId,this.channel);return t?(this.pubnub=new(hu())({publishKey:t.keys.publish_key,subscribeKey:t.keys.subscribe_key,userId:this.leadUserId,authKey:t.auth.result.token,origin:"meetelise.pubnubapi.com"}),this.withAuthToken(()=>new Promise(()=>this.handleChatListeners())),await this.withAuthToken(()=>this.getChannelHistory()),this.pubnub):void 0}async fetchToken(e,t){try{if(this.sessionToken){const e="healthcare"===this.widgetType?"?industry=health_care":"";return(await r().get(`${this.apiHost}/platformApi/webchat/pn/v2/request-token${e}`,{headers:{"X-Session-Token":this.sessionToken}})).data}return(await r().get(`${this.apiHost}/platformApi/webchat/pn/request-token?user_id=${e}&channel=${t}&${"healthcare"===this.widgetType?"industry=health_care":""}`)).data}catch(e){this.buildingWebchatView&&Fo({logTitle:"PUBNUB_ERROR_FETCHING_TOKEN",logData:{error:e},logType:jo.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,error:e})}return null}async fetchChannelExists(e){try{return(await r().get(`${this.apiHost}/platformApi/webchat/check-channel-exists?channel_name=${e}`)).data}catch(e){this.buildingWebchatView&&Fo({logTitle:"PUBNUB_ERROR_FETCHING_CHANNEL_EXISTS",logData:{error:e},logType:jo.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,error:e})}return!1}async withAuthToken(e){try{await e()}catch(t){if(t instanceof i.AxiosError&&t&&t.response&&403===t.response.status)try{if(!this.pubnub||!this.leadUserId||!this.channel)return;const t=await this.fetchToken(this.leadUserId,this.channel);if(!t)return;this.pubnub.setAuthKey(t.auth.result.token),await e()}catch(e){this.buildingWebchatView&&Fo({logTitle:"PUBNUB_ERROR_REFETCHING_TOKEN",logData:{retryError:e},logType:jo.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,error:e})}}}async getChannelHistory(e=1500){var t;try{let n=[],i=null;const r=100;for(let t=0;t<e;t+=r){const o=await new Promise((n,o)=>{if(!this.pubnub||!this.channel)return[];const a=Math.min(r,e-t);this.pubnub.fetchMessages({channels:[this.channel],count:a,start:null!=i?i:void 0},(e,t)=>{e.error?o(e):n(t)})}),a=o.channels[this.channel];if(!a)break;if(a.sort((e,t)=>+e.timetoken-+t.timetoken),!a||0===a.length)break;if(this.channel&&0!==Object.keys(o.channels).length){const e=o.channels[this.channel],t=[];e.forEach(e=>{e.uuid&&t.push({channel:e.channel,message:e.message,publisher:e.uuid,subscription:e.channel,timetoken:+e.timetoken})}),this.markEveryPreviousNoReplyMessageDone(t),n=n.concat(t.filter(e=>e.message.messageType!==Au.noReply))}if(i=a[0].timetoken,n.length>=e||a.length<r)break}this.rawPubnubMessages=n.slice(0,e),this.simpleChatMessages=this.translatePubnubMessagesIntoSimpleChatMessages(this.rawPubnubMessages),null===(t=this.chatListener)||void 0===t||t.call(this,{messages:this.simpleChatMessages,isLoading:!1})}catch(e){this.buildingWebchatView&&Fo({logTitle:"PUBNUB_WARN_FETCHING_HISTORY",logData:{error:e},logType:jo.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,error:e})}}shouldCreateAsDevState(){return location.href.startsWith("https://app.meetelise.com/settings/widgets")||location.href.includes("demo/utilities")}},Ou=new Set(["8009855990","8338526262","8002221222","8006624357","8002738255","8007997233","8007874889","8006564673","8004224453","8883737888","8006213362","8009506264","8558272736","8008435678","8007862929","8008523836","8007849433","8007729100","8006699777","8006858470","8004322209","8003473735","8008778339","8009552232","8002255342","8009272891","8003049320","8007937724","8002382333","8003353863","8776858878","8003329227","8776554371","8772944357","8772944356","6092925760","6092926735","8007928339","8008329173","8882853036","6092921210","8007929773","8003561561","8003826717","8005727233","8009291040","8888958179","8006879512","8004262537","8773475463","8774149251","8005103102","8889372835","8007010710","8007010720","8774288844","8007929745","8003283838","6092927060","6092928319","8008527899","8662401347","8009923678","8776522873","8776527624","8003313937","8008435437","8776536783","8778392339","8003676274","8006896411"]),Pu=e=>{const t=e.replace(/\D/g,"").replace(/^1(\d{10})$/,"$1");return Ou.has(t)},Iu=(e,t,n)=>{try{const i=e.replace(/\D/g,"").replace(/^1(\d{10})$/,"$1"),r=`tel:${i}`,o=`sms:${i}`,a=`whatsapp://send?phone=${i}`,s=`facetime:${i}`,l=`facetime-audio:${i}`,u=/(?:\+1[\s.-]?)?(?:\(\d{3}\)[\s.-]?|\d{3}[\s.-])\d{3}[\s.-]?\d{4}/g,d=/(tel|sms):(?:\+1\s)?(?:(?:\(\d{3}\)\s|\d{3}-)\d{3}-\d{4}|\d{10,11})/g,c=/whatsapp:\/\/send\?phone=\d+/g,h=/(facetime|facetime-audio):\d+/g,p=/emergency|emergencia/i,f=300,g=e=>!(!e||e.length>f)&&p.test(e),m=e=>{var t,n,i,r;if(g(e.textContent))return!0;if(g(null===(t=e.previousElementSibling)||void 0===t?void 0:t.textContent)||g(null===(n=e.nextElementSibling)||void 0===n?void 0:n.textContent))return!0;const o=e.parentElement;return!(!o||!g(null===(i=o.previousElementSibling)||void 0===i?void 0:i.textContent)&&!g(null===(r=o.nextElementSibling)||void 0===r?void 0:r.textContent))},y=document.body.getElementsByTagName("*");let b=!1;const v=i.replace(/(\d{3})(\d{3})(\d{4})/,"($1) $2-$3");let w=!1,C=!1,x=0;for(let e=0;e<y.length;e++)if(y[e].nodeType===Node.ELEMENT_NODE&&!m(y[e])){if(1===y[e].childNodes.length&&y[e].childNodes[0].nodeType==Node.TEXT_NODE){const t=y[e].textContent;if(!t)continue;const n=t.replace(u,e=>{if(Pu(e))return e;return e.startsWith("+1 ")?`+1 ${v}`:v});t!==n&&(x++,y[e].textContent=n),b=!0,w||(w=!0)}if(y[e].hasAttribute("href")){const t=y[e].getAttribute("href");if(!t)continue;let n="",i=d;if(t.startsWith("sms:")?n=o:t.startsWith("whatsapp:")?(n=a,i=c):t.startsWith("facetime:")?(n=s,i=h):t.startsWith("facetime-audio:")?(n=l,i=h):n=r,Pu(t))continue;const u=t.replace(i,n);if(y[e].setAttribute("href",u),(t.startsWith("tel:")||t.startsWith("sms:"))&&u===t&&u!==n){t.replace(/\D/g,"").length>=7&&y[e].setAttribute("href",t.startsWith("tel:")?r:o)}C||(C=!0)}}return w&&Fo({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"text-insertion",newPhoneNumber:v,website:window.location.href},logType:jo.info,buildingSlug:n,orgSlug:t}),C&&Fo({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"href-insertion",newPhoneNumber:v,website:window.location.href},logType:jo.info,buildingSlug:n,orgSlug:t}),b||Fo({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"no-phone-number-found",website:window.location.href},logType:jo.warn,buildingSlug:n,orgSlug:t}),x}catch(e){return Fo({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"insertion-error",error:e instanceof Error?e.message:String(e),website:window.location.href},logType:jo.error,buildingSlug:n,orgSlug:t,error:e}),0}};var Nu=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 Mu=class extends oe{constructor(){super(...arguments),this.onClick=()=>{},this.primaryColor=qn,this.toExpand=!1}render(){return R`
|
|
6035
|
+
`,Fl([ue({attribute:!0})],Hl.prototype,"isMinimized",void 0),Fl([ue()],Hl.prototype,"mobileStyles",void 0),Fl([ue({type:Boolean})],Hl.prototype,"isFirstMount",void 0),Fl([ue({attribute:!1})],Hl.prototype,"autoOpenChatWidget",void 0),Fl([ue()],Hl.prototype,"phoneNumber",void 0),Fl([ue({attribute:!0})],Hl.prototype,"buildingName",void 0),Fl([ue({attribute:!0})],Hl.prototype,"chatId",void 0),Fl([ue({attribute:!0})],Hl.prototype,"orgLegalName",void 0),Fl([ue({attribute:!1})],Hl.prototype,"country",void 0),Fl([ue({attribute:!0})],Hl.prototype,"chatCallUsHeader",void 0),Fl([ue({attribute:!1})],Hl.prototype,"buildingId",void 0),Fl([ue({type:Number})],Hl.prototype,"orgId",void 0),Fl([ue({attribute:!1})],Hl.prototype,"leadSourceParams",void 0),Fl([ue({attribute:!0})],Hl.prototype,"buildingSlug",void 0),Fl([ue({attribute:!0})],Hl.prototype,"orgSlug",void 0),Fl([ue({attribute:!0})],Hl.prototype,"sgtUrl",void 0),Fl([ue({attribute:!0})],Hl.prototype,"selfGuidedTourEnabled",void 0),Fl([ue({attribute:!0})],Hl.prototype,"selfGuidedToursTypeOffered",void 0),Fl([ue({attribute:!0})],Hl.prototype,"designConcept",void 0),Fl([ue({attribute:!0})],Hl.prototype,"featureFlagShowDropdown",void 0),Fl([ue({attribute:!1})],Hl.prototype,"leadSources",void 0),Fl([ue({attribute:!0})],Hl.prototype,"currentLeadSource",void 0),Fl([ue({attribute:!0})],Hl.prototype,"escortedToursLink",void 0),Fl([ue({attribute:!0})],Hl.prototype,"escortedToursTypeOffered",void 0),Fl([ue({attribute:!0})],Hl.prototype,"virtualToursLink",void 0),Fl([ue({attribute:!0})],Hl.prototype,"virtualToursTypeOffered",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasChatEnabledDesktop",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasChatEnabledMobile",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasEmailEnabledDesktop",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasEmailEnabledMobile",void 0),Fl([ue({attribute:!0})],Hl.prototype,"hasApplyNowEnabledDesktop",void 0),Fl([ue({attribute:!0})],Hl.prototype,"hasApplyNowEnabledMobile",void 0),Fl([ue({attribute:!0})],Hl.prototype,"applicationLink",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasCallUsEnabledDesktop",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasCallUsEnabledMobile",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasTextUsEnabledDesktop",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasTextUsEnabledMobile",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasSSTEnabledDesktop",void 0),Fl([ue({type:Boolean})],Hl.prototype,"hasSSTEnabledMobile",void 0),Fl([ue({attribute:!1})],Hl.prototype,"tourTypeOptions",void 0),Fl([ue({attribute:!1})],Hl.prototype,"layoutOptions",void 0),Fl([ue({attribute:!0})],Hl.prototype,"bedroomPreferenceRequired",void 0),Fl([ue({attribute:!0})],Hl.prototype,"hasDynamicSchedulingEnabled",void 0),Fl([ue({attribute:!0})],Hl.prototype,"hasPricingCalculatorEnabledDesktop",void 0),Fl([ue({attribute:!0})],Hl.prototype,"hasPricingCalculatorEnabledMobile",void 0),Fl([ue({attribute:!1})],Hl.prototype,"hasHideMobileFeatures",void 0),Fl([ue({type:Number})],Hl.prototype,"right",void 0),Fl([ue({type:Number})],Hl.prototype,"bottom",void 0),Fl([ue({type:Number})],Hl.prototype,"top",void 0),Fl([ue({type:Number})],Hl.prototype,"left",void 0),Fl([ue({attribute:!0})],Hl.prototype,"showTourNextToChat",void 0),Fl([ue({attribute:!1})],Hl.prototype,"onChatTapped",void 0),Fl([ue({attribute:!0})],Hl.prototype,"onClickMinimize",void 0),Fl([ue({attribute:!0})],Hl.prototype,"onSstClose",void 0),Fl([ue({attribute:!0})],Hl.prototype,"overrideRentgrata",void 0),Fl([ue({attribute:!1})],Hl.prototype,"launcherStyles",void 0),Fl([ue({attribute:!0})],Hl.prototype,"primaryColor",void 0),Fl([ue({attribute:!0})],Hl.prototype,"backgroundColor",void 0),Fl([ue({attribute:!0})],Hl.prototype,"foregroundColorOnPrimaryBackgroundColor",void 0),Fl([ue({attribute:!0})],Hl.prototype,"foregroundColorOnSecondaryBackgroundColor",void 0),Fl([ue({attribute:!0})],Hl.prototype,"leadSourceClient",void 0),Fl([de()],Hl.prototype,"leadSourceMultitouchClient",void 0),Fl([de()],Hl.prototype,"_isMobile",void 0),Fl([de()],Hl.prototype,"isEmailWindowOpen",void 0),Fl([de()],Hl.prototype,"isCallUsWindowOpen",void 0),Fl([de()],Hl.prototype,"isSSTWindowOpen",void 0),Fl([de()],Hl.prototype,"isTextUsWindowOpen",void 0),Fl([de()],Hl.prototype,"isCalculatorWindowOpen",void 0),Fl([de()],Hl.prototype,"isMobileFeaturesExpanded",void 0),Hl=Fl([se("meetelise-launcher")],Hl);const Gl=()=>{window.customElements.get("meetelise-launcher")||window.customElements.define("meetelise-launcher",Hl)},zl=["app.meetelise.com","staging.eliseai.com","localhost"],Ql={calculator:{desktop:"calcDesktop",mobile:"calcMobile"},email:{desktop:"emailDesktop",mobile:"emailMobile"},call:{desktop:"callDesktop",mobile:"callMobile"},text:{desktop:"textDesktop",mobile:"textMobile"},sst:{desktop:"sstDesktop",mobile:"sstMobile"}},Wl=e=>{const t=window.location.hostname;if(!zl.includes(t))return e;const n=(e=>{if(!e)return{};try{return e.split(",").reduce((e,t)=>{const[n,i]=t.split(":");return n&&i&&n in Ql&&(e[n]="true"===i.toLowerCase()),e},{})}catch(e){return{}}})(new URLSearchParams(window.location.search).get("widgets"));if(0===Object.keys(n).length)return e;const i={...e};return Object.entries(n).forEach(([e,t])=>{const n=Ql[e];n&&(i[n.desktop]=t,i[n.mobile]=t)}),i};var Vl=n(5072),ql=n.n(Vl),Yl=n(7825),Kl=n.n(Yl),Xl=n(7659),Zl=n.n(Xl),Jl=n(5056),eu=n.n(Jl),tu=n(540),nu=n.n(tu),iu=n(1113),ru=n.n(iu),ou=n(5541),au={};au.styleTagTransform=ru(),au.setAttributes=eu(),au.insert=Zl().bind(null,"head"),au.domAPI=Kl(),au.insertStyleElement=nu();ql()(ou.A,au);ou.A&&ou.A.locals&&ou.A.locals;async function su(e,t){try{const n=await r().get(`https://app.meetelise.com/platformApi/webchat/${t}/lead-sources`);if(n.data){if("7e352741-1120-4ccf-9929-5dc99193a908"===e){const e=["Zillow","Apartments.com","Google PPC","Google Maps","Apple Maps","Social Media","Print Marketing"];return n.data.filter(t=>e.includes(t))}return lu(n.data,t)}return[]}catch(e){return[]}}const lu=(e,t)=>{let n=[];switch(t){case"d41619ec-0f79-11ee-8439-93855926ad58":n=["Forthea - PPC","HotPads","Forthea","Locator","Website-apartmentguide.com","Forthea - organic search","Tdc employee","University newspaper","Nashville apartment locators","Forthea - paid social","Apartment list","Off campus partners","Waze ads","Athletic event","Website-apartment guide"];break;case"d4160560-0f79-11ee-8438-fba837bf3a46":n=["Forthea - PPC","Rentgrata","Website-ApartmentFinder.com","Word of Mouth","Texas A&M A-Frame on Campus","Rent.com","Website-craigslist","Apartment List","Website-apartments.com","Forthea - paid social","Forthea - organic search","Website-apartmentguide.com","Forthea","Uhomes","Phone book","Property - website"];break;default:n=[]}return e.sort(),e.filter(e=>{const t=e.toLowerCase();return!n.map(e=>e.toLowerCase()).includes(t)})};async function uu(e){var t,n;if(!e)return!1;try{return null!==(n=null===(t=(await r().get(`https://app.meetelise.com/platformApi/webchat/${e}/aip`)).data)||void 0===t?void 0:t.is_aip)&&void 0!==n&&n}catch(e){return!1}}var du,cu=n(8805),hu=n.n(cu),pu=new Uint8Array(16);function fu(){if(!du&&!(du="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return du(pu)}const gu=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;const mu=function(e){return"string"==typeof e&&gu.test(e)};for(var yu=[],bu=0;bu<256;++bu)yu.push((bu+256).toString(16).substr(1));const vu=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(yu[e[t+0]]+yu[e[t+1]]+yu[e[t+2]]+yu[e[t+3]]+"-"+yu[e[t+4]]+yu[e[t+5]]+"-"+yu[e[t+6]]+yu[e[t+7]]+"-"+yu[e[t+8]]+yu[e[t+9]]+"-"+yu[e[t+10]]+yu[e[t+11]]+yu[e[t+12]]+yu[e[t+13]]+yu[e[t+14]]+yu[e[t+15]]).toLowerCase();if(!mu(n))throw TypeError("Stringified UUID is invalid");return n};const wu=function(e,t,n){var i=(e=e||{}).random||(e.rng||fu)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){n=n||0;for(var r=0;r<16;++r)t[n+r]=i[r];return t}return vu(i)},Cu=e=>localStorage.removeItem("com.elise.webchat.slug="+e),xu=(e,t,n)=>{const i=Rr(new Date),r=n||`lead_${wu()}`;return localStorage.setItem("com.elise.webchat.slug="+e,JSON.stringify({buildingSlug:e,leadId:r,timestamp:i,initiatedChat:t})),{leadId:r,timestamp:Wr(i),buildingSlug:e,initiatedChat:t}},$u=e=>{const t=localStorage.getItem("com.elise.webchat.slug="+e);if(t)try{const n=JSON.parse(t),i={leadId:n.leadId,timestamp:new Date(n.timestamp),buildingSlug:n.buildingSlug,initiatedChat:n.initiatedChat};if(Su(e,i))return i}catch(e){}return{leadId:null,timestamp:null,buildingSlug:null,initiatedChat:!1}},Su=(e,t)=>{try{if(t.timestamp&&t.initiatedChat){const e=new Date("2024-06-06T21:30:00Z");if(xr(t.timestamp,e))return!1}}catch(e){}return!(t.buildingSlug!==e||!t.leadId||!t.timestamp)&&!Pr(t.timestamp,24)};var Au;!function(e){e.noReply="no-reply",e.text="text",e.media="media"}(Au||(Au={}));const Eu=e=>e.type===ku.text,Tu=e=>e.type===ku.media;var ku;!function(e){e.text="text",e.media="media"}(ku||(ku={}));const _u=class{constructor(e,t,n,i=null,r,o,a=null,s=Pc.Default){this.apiHost="https://app.meetelise.com",this.leadSourceClient=null,this.leadSourceMultitouchClient=null,this.buildingWebchatView=null,this.eliseResponseTimeout=null,this.isWaitingForStreamingMessages=!1,this.widgetType=Pc.Default,this.pubnub=null,this.leadUserId="",this.channel="",this.leadSource=null,this.sessionToken=null,this.isCurrentlyStreamingMessage=!1,this.chatListener=null,this.rawPubnubMessages=[],this.simpleChatMessages=[],this.listenerParams={message:e=>{var t,n;const i={channel:e.channel,message:e.message,publisher:e.publisher,subscription:e.subscription,timetoken:+e.timetoken};this.rawPubnubMessages=[...this.rawPubnubMessages,i],this.markEveryPreviousNoReplyMessageDone(this.rawPubnubMessages),this.rawPubnubMessages=this.rawPubnubMessages.filter(e=>e.message.messageType!==Au.noReply),this.simpleChatMessages=this.translatePubnubMessagesIntoSimpleChatMessages(this.rawPubnubMessages),this.checkAndHandleDelayStreamingMessages();const r="eliseai"!==e.publisher&&"elise_health_ai"!==e.publisher;if(null===(t=this.chatListener)||void 0===t||t.call(this,{messages:this.simpleChatMessages,isLoading:r}),!r&&this.eliseResponseTimeout&&clearTimeout(this.eliseResponseTimeout),this.isLoadingMessages=r,"ai_message"===e.message.customType){this.simpleChatMessages.some(e=>e.type===ku.text&&e.message.includes("confirmed for your"))&&xo("scheduledTourEvent",{tourDetails:e.message,buildingId:null===(n=this.buildingWebchatView)||void 0===n?void 0:n.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel})}this.checkAndHandleGTMForLeadEmail(e)}},this.isLoadingMessages=!1,this.isFirstChatMessageSent=!1,this.streamingMessageTimeout=null,this.checkAndHandleDelayStreamingMessages=({delayToFetchHistoryInMs:e=1e4}={})=>{this.streamingMessageTimeout&&(clearTimeout(this.streamingMessageTimeout),this.streamingMessageTimeout=null);const t=this.simpleChatMessages.some(e=>{if(!Eu(e))return!1;const t=e.chunks.find(e=>e.isDone);return!t||e.chunks.length===t.order});t&&(this.streamingMessageTimeout=setTimeout(()=>{Fo({logTitle:"PUBNUB_WARN_DELAYED_STREAMING_MESSAGES",logData:{channel:this.channel},logType:jo.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug}),this.getChannelHistory()},e))},this.checkAndHandleGTMForLeadEmail=e=>{var t;try{if("lead_message"!==e.message.customType)return;if(!(e=>{try{return/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b/.test(e)}catch(e){return!1}})(e.message.text))return;xo("leadProvidedEmail",{buildingId:null===(t=this.buildingWebchatView)||void 0===t?void 0:t.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel})}catch(e){return}},this.markEveryPreviousNoReplyMessageDone=e=>{var t,n;for(let i=e.length-1;i>=0;i--){const r=null===(t=e[i])||void 0===t?void 0:t.message,o=i>0&&(null===(n=e[i-1])||void 0===n?void 0:n.message);(null==r?void 0:r.messageType)===Au.noReply&&o&&(o.is_done=!0)}},this.checkMessageChunkValid=e=>{try{return!!e.message&&!!e.message.text&&e.message.text.length>0&&!!e.message.customType}catch(e){return!1}},this.handleChatListeners=()=>{if(this.pubnub&&this.channel)try{this.pubnub.subscribe({channels:[this.channel]}),this.pubnub.addListener(this.listenerParams)}catch(e){this.buildingWebchatView&&Fo({logTitle:"PUBNUB_ERROR_ADDING_LISTENER",logData:{error:e,channel:this.channel,leadUserId:this.leadUserId,website:location.href},logType:jo.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,error:e})}},this.handleDisconnect=()=>{this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.streamingMessageTimeout&&(clearTimeout(this.streamingMessageTimeout),this.streamingMessageTimeout=null),this.removeChatListeners()},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){const e=xu(this.buildingSlug,!0,this.leadUserId);if(!await this.initializePubnub(e))return}await this.withAuthToken(async()=>{var t,n,i,r,o,a,s,l,u;this.pubnub&&this.channel&&(this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.eliseResponseTimeout=setTimeout(()=>{this.buildingWebchatView&&Fo({logTitle:"PUBNUB_ERROR_ELISEAI_MESSAGE_TIMEOUT",logData:{channel:this.channel,leadUserId:this.leadUserId,message:e},logType:jo.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})},9e4),0===this.simpleChatMessages.length&&(null===(t=this.leadSourceClient)||void 0===t||t.checkAndHandleForLogLeadSource({webchatAction:"chat",stateId:null})),this.widgetType===Pc.Utilities?await this.pubnub.publish({channel:this.channel,message:{text:e,customType:"lead_message",widgetType:this.widgetType,isDevState:this.shouldCreateAsDevState(),orgSlug:this.orgSlug}}):(await this.pubnub.publish({channel:this.channel,message:{text:e,customType:"lead_message",buildingId:null===(n=this.buildingWebchatView)||void 0===n?void 0:n.id,buildingSlug:this.buildingSlug,userId:null===(i=this.buildingWebchatView)||void 0===i?void 0:i.userId,leadSource:this.leadSource,widgetType:this.widgetType,isDevState:this.shouldCreateAsDevState(),lead_sources_with_timestamps:(null!==(o=null===(r=this.leadSourceMultitouchClient)||void 0===r?void 0:r.getSafeLeadSourceTouchpointsWithDefault({includedUserSelectedLeadSource:null}))&&void 0!==o?o:[]).map(e=>Er({...e}))}}),null===(a=this.leadSourceClient)||void 0===a||a.resetLeadSource(),null===(s=this.leadSourceMultitouchClient)||void 0===s||s.resetLeadSourceTouchpoints()),this.isFirstChatMessageSent||(xo("firstChatMessageSent",{message:e,buildingId:null===(l=this.buildingWebchatView)||void 0===l?void 0:l.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel}),this.isFirstChatMessageSent=!0),xo("chatMessageSent",{message:e,buildingId:null===(u=this.buildingWebchatView)||void 0===u?void 0:u.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel}))}),!1===this.isLoadingMessages&&(this.isLoadingMessages=!0)}},this.isLeadMessage=e=>e.publisher.includes("lead_")&&"lead_message"===e.message.customType,this.removeDuplicatedRawPubnubMessages=e=>{const t=new Set;return e.filter(e=>{if("lead_message"===e.message.customType||!e.message.stream_id||!e.message.order)return!0;const n=`${e.message.stream_id}-${e.message.order}-${e.message.messageType}`;return t.has(n)?(Fo({logTitle:"PUBNUB_WARN_DUPLICATE_MESSAGE",logData:{message:e,channel:this.channel},logType:jo.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug}),!1):(t.add(n),!0)})},this.translatePubnubMessagesIntoSimpleChatMessages=e=>{const t=[],n={};return this.removeDuplicatedRawPubnubMessages(e).forEach(e=>{var i;"media"===e.message.messageType?t.push({timestamp:e.timetoken,media:null!==(i=e.message.media)&&void 0!==i?i:[],isLeadMessage:this.isLeadMessage(e),type:ku.media}):!e.message.stream_id||e.message.is_done&&0===e.message.order?t.push({timestamp:e.timetoken,message:e.message.text,isLeadMessage:this.isLeadMessage(e),chunks:[{text:e.message.text,order:0,isDone:!0}],type:ku.text}):n[e.message.stream_id]?n[e.message.stream_id].push(e):n[e.message.stream_id]=[e]}),Object.keys(n).forEach(e=>{const i=n[e],r=this.getConsecutiveChunks(i.sort((e,t)=>{var n,i;return(null!==(n=e.message.order)&&void 0!==n?n:0)-(null!==(i=t.message.order)&&void 0!==i?i:0)})),o=r.map(e=>e.message.text).join(""),a=r[0],s={timestamp:a.timetoken,message:o,isLeadMessage:this.isLeadMessage(a),chunks:r.map(e=>{var t,n;return{text:e.message.text,order:null!==(t=e.message.order)&&void 0!==t?t:0,isDone:null!==(n=e.message.is_done)&&void 0!==n&&n}}),type:ku.text};this.isCurrentlyStreamingMessage=this.isMessageStillStreamingChunks(r),t.push(s)}),t.sort((e,t)=>e.timestamp-t.timestamp),t},this.getConsecutiveChunks=e=>{var t,n;const i=e.sort((e,t)=>{var n,i;return(null!==(n=e.message.order)&&void 0!==n?n:0)-(null!==(i=t.message.order)&&void 0!==i?i:0)}),r=[];let o=null!==(t=i[0].message.order)&&void 0!==t?t:0;for(const e of i){if((null!==(n=e.message.order)&&void 0!==n?n:-1)!==o)break;r.push(e),o++}return r},this.isMessageStillStreamingChunks=e=>{const t=e.find(e=>e.message.is_done);return!t||e.length===t.message.order},this.buildingSlug=e,this.buildingWebchatView=t,this.orgSlug=n,this.leadSource=i,this.leadUserId=r,this.channel=`webchat_${r}`,this.leadSourceClient=a,this.leadSourceMultitouchClient=o,this.widgetType=s}async initSession(e,t,n){try{const i={building_slug:e,org_slug:t};n&&(i.lead_id=n);const o=await r().post(`${this.apiHost}/platformApi/webchat/init`,i);return this.sessionToken=o.data.session_token,this.leadUserId=o.data.lead_id,this.channel=o.data.channel,o.data}catch(e){return this.buildingWebchatView&&Fo({logTitle:"WEBCHAT_INIT_SESSION_ERROR",logData:{error:e},logType:jo.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,error:e}),null}}addChatListener(e){this.chatListener=e}async initializePubnub(e){if(!e.leadId)return;this.leadUserId=e.leadId;const t=await this.fetchToken(this.leadUserId,this.channel);return t?(this.pubnub=new(hu())({publishKey:t.keys.publish_key,subscribeKey:t.keys.subscribe_key,userId:this.leadUserId,authKey:t.auth.result.token,origin:"meetelise.pubnubapi.com"}),this.withAuthToken(()=>new Promise(()=>this.handleChatListeners())),await this.withAuthToken(()=>this.getChannelHistory()),this.pubnub):void 0}async fetchToken(e,t){try{if(this.sessionToken){const e="healthcare"===this.widgetType?"?industry=health_care":"";return(await r().get(`${this.apiHost}/platformApi/webchat/pn/v2/request-token${e}`,{headers:{"X-Session-Token":this.sessionToken}})).data}return(await r().get(`${this.apiHost}/platformApi/webchat/pn/request-token?user_id=${e}&channel=${t}&${"healthcare"===this.widgetType?"industry=health_care":""}`)).data}catch(e){this.buildingWebchatView&&Fo({logTitle:"PUBNUB_ERROR_FETCHING_TOKEN",logData:{error:e},logType:jo.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,error:e})}return null}async fetchChannelExists(e){try{return(await r().get(`${this.apiHost}/platformApi/webchat/check-channel-exists?channel_name=${e}`)).data}catch(e){this.buildingWebchatView&&Fo({logTitle:"PUBNUB_ERROR_FETCHING_CHANNEL_EXISTS",logData:{error:e},logType:jo.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,error:e})}return!1}async withAuthToken(e){try{await e()}catch(t){if(t instanceof i.AxiosError&&t&&t.response&&403===t.response.status)try{if(!this.pubnub||!this.leadUserId||!this.channel)return;const t=await this.fetchToken(this.leadUserId,this.channel);if(!t)return;this.pubnub.setAuthKey(t.auth.result.token),await e()}catch(e){this.buildingWebchatView&&Fo({logTitle:"PUBNUB_ERROR_REFETCHING_TOKEN",logData:{retryError:e},logType:jo.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,error:e})}}}async getChannelHistory(e=1500){var t;try{let n=[],i=null;const r=100;for(let t=0;t<e;t+=r){const o=await new Promise((n,o)=>{if(!this.pubnub||!this.channel)return[];const a=Math.min(r,e-t);this.pubnub.fetchMessages({channels:[this.channel],count:a,start:null!=i?i:void 0},(e,t)=>{e.error?o(e):n(t)})}),a=o.channels[this.channel];if(!a)break;if(a.sort((e,t)=>+e.timetoken-+t.timetoken),!a||0===a.length)break;if(this.channel&&0!==Object.keys(o.channels).length){const e=o.channels[this.channel],t=[];e.forEach(e=>{e.uuid&&t.push({channel:e.channel,message:e.message,publisher:e.uuid,subscription:e.channel,timetoken:+e.timetoken})}),this.markEveryPreviousNoReplyMessageDone(t),n=n.concat(t.filter(e=>e.message.messageType!==Au.noReply))}if(i=a[0].timetoken,n.length>=e||a.length<r)break}this.rawPubnubMessages=n.slice(0,e),this.simpleChatMessages=this.translatePubnubMessagesIntoSimpleChatMessages(this.rawPubnubMessages),null===(t=this.chatListener)||void 0===t||t.call(this,{messages:this.simpleChatMessages,isLoading:!1})}catch(e){this.buildingWebchatView&&Fo({logTitle:"PUBNUB_WARN_FETCHING_HISTORY",logData:{error:e},logType:jo.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,error:e})}}shouldCreateAsDevState(){return location.href.startsWith("https://app.meetelise.com/settings/widgets")||location.href.includes("demo/utilities")}},Ou=new Set(["8009855990","8338526262","8002221222","8006624357","8002738255","8007997233","8007874889","8006564673","8004224453","8883737888","8006213362","8009506264","8558272736","8008435678","8007862929","8008523836","8007849433","8007729100","8006699777","8006858470","8004322209","8003473735","8008778339","8009552232","8002255342","8009272891","8003049320","8007937724","8002382333","8003353863","8776858878","8003329227","8776554371","8772944357","8772944356","6092925760","6092926735","8007928339","8008329173","8882853036","6092921210","8007929773","8003561561","8003826717","8005727233","8009291040","8888958179","8006879512","8004262537","8773475463","8774149251","8005103102","8889372835","8007010710","8007010720","8774288844","8007929745","8003283838","6092927060","6092928319","8008527899","8662401347","8009923678","8776522873","8776527624","8003313937","8008435437","8776536783","8778392339","8003676274","8006896411"]),Pu=e=>{const t=e.replace(/\D/g,"").replace(/^1(\d{10})$/,"$1");return Ou.has(t)},Iu=(e,t,n)=>{try{const i=e.replace(/\D/g,"").replace(/^1(\d{10})$/,"$1"),r=`tel:${i}`,o=`sms:${i}`,a=`whatsapp://send?phone=${i}`,s=`facetime:${i}`,l=`facetime-audio:${i}`,u=/(?:\+1[\s.-]?)?(?:\(\d{3}\)[\s.-]?|\d{3}[\s.-])\d{3}[\s.-]?\d{4}/g,d=/(tel|sms):(?:\+1\s)?(?:(?:\(\d{3}\)\s|\d{3}-)\d{3}-\d{4}|\d{10,11})/g,c=/whatsapp:\/\/send\?phone=\d+/g,h=/(facetime|facetime-audio):\d+/g,p=/emergency|emergencia/i,f=300,g=e=>!(!e||e.length>f)&&p.test(e),m=e=>{var t,n,i,r;if(g(e.textContent))return!0;if(g(null===(t=e.previousElementSibling)||void 0===t?void 0:t.textContent)||g(null===(n=e.nextElementSibling)||void 0===n?void 0:n.textContent))return!0;const o=e.parentElement;return!(!o||!g(null===(i=o.previousElementSibling)||void 0===i?void 0:i.textContent)&&!g(null===(r=o.nextElementSibling)||void 0===r?void 0:r.textContent))},y=document.body.getElementsByTagName("*");let b=!1;const v=i.replace(/(\d{3})(\d{3})(\d{4})/,"($1) $2-$3");let w=!1,C=!1,x=0;for(let e=0;e<y.length;e++)if(y[e].nodeType===Node.ELEMENT_NODE&&!m(y[e])){if(1===y[e].childNodes.length&&y[e].childNodes[0].nodeType==Node.TEXT_NODE){const t=y[e].textContent;if(!t)continue;const n=t.replace(u,e=>{if(Pu(e))return e;return e.startsWith("+1 ")?`+1 ${v}`:v});t!==n&&(x++,y[e].textContent=n),b=!0,w||(w=!0)}if(y[e].hasAttribute("href")){const t=y[e].getAttribute("href");if(!t)continue;let n="",i=d;if(t.startsWith("sms:")?n=o:t.startsWith("whatsapp:")?(n=a,i=c):t.startsWith("facetime:")?(n=s,i=h):t.startsWith("facetime-audio:")?(n=l,i=h):n=r,Pu(t))continue;const u=t.replace(i,n);if(y[e].setAttribute("href",u),(t.startsWith("tel:")||t.startsWith("sms:"))&&u===t&&u!==n){t.replace(/\D/g,"").length>=7&&y[e].setAttribute("href",t.startsWith("tel:")?r:o)}C||(C=!0)}}return w&&Fo({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"text-insertion",newPhoneNumber:v,website:window.location.href},logType:jo.info,buildingSlug:n,orgSlug:t}),C&&Fo({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"href-insertion",newPhoneNumber:v,website:window.location.href},logType:jo.info,buildingSlug:n,orgSlug:t}),b||Fo({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"no-phone-number-found",website:window.location.href},logType:jo.warn,buildingSlug:n,orgSlug:t}),x}catch(e){return Fo({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"insertion-error",error:e instanceof Error?e.message:String(e),website:window.location.href},logType:jo.error,buildingSlug:n,orgSlug:t,error:e}),0}};var Nu=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 Mu=class extends oe{constructor(){super(...arguments),this.onClick=()=>{},this.primaryColor=qn,this.toExpand=!1}render(){return R`
|
|
6036
6036
|
<button
|
|
6037
6037
|
class=${this.toExpand?"button-container mini":"button-container"}
|
|
6038
6038
|
@click=${this.onClick}
|
|
@@ -6552,7 +6552,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
6552
6552
|
transform: rotate(360deg);
|
|
6553
6553
|
}
|
|
6554
6554
|
}
|
|
6555
|
-
`,Gd([ue({type:Number})],zd.prototype,"spinSpeed",void 0),zd=Gd([se("mini-loader")],zd);var Qd=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 Wd=class extends oe{constructor(){super(...arguments),this.onMount=()=>({}),this.loadingPreviews=!0,this.websitePreviewInfo=[],this.imagesToDisplay=[],this.imageUrlError=[],this.isLeadMessage=!1,this.widgetType=
|
|
6555
|
+
`,Gd([ue({type:Number})],zd.prototype,"spinSpeed",void 0),zd=Gd([se("mini-loader")],zd);var Qd=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 Wd=class extends oe{constructor(){super(...arguments),this.onMount=()=>({}),this.loadingPreviews=!0,this.websitePreviewInfo=[],this.imagesToDisplay=[],this.imageUrlError=[],this.isLeadMessage=!1,this.widgetType=Pc.Default}isMessageStillStreamingChunks(){if(!this.message)return!1;const e=this.message.chunks.find(e=>e.isDone);return!e||this.message.chunks.length===e.order}updated(e){if(this.onMount(),!e.has("message"))return;if(!this.message)return;const{hyperlinks:t,markedText:n}=this.mapAndMarkHyperLinks(this.message.message),i=/(https?:\/\/[^\s]+)/g,r=[],o=[];this.parsedMessage=R`${n.trim().split("\n").map(e=>{const n=this.sanitizeMarkdownText(e),a=this.preserveHTMLTags(n);return a?R`${a.map(e=>{if(t.find(t=>t.id===e)){const n=t.find(t=>t.id===e);if(!n)return;return o.push({redirectTo:null==n?void 0:n.link,source:null==n?void 0:n.link}),R`<a
|
|
6556
6556
|
class="redirect-link"
|
|
6557
6557
|
href="${null==n?void 0:n.link}"
|
|
6558
6558
|
target="_blank"
|
|
@@ -6567,7 +6567,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
6567
6567
|
</a>`}return R`${So(Hd.sanitize(e))} `})}<br />`:R``})}`,this.imagesToDisplay=o,Promise.all(r).then(e=>{this.websitePreviewInfo=e})}preserveHTMLTags(e){var t;const n=e.match(/(<\/?[a-z][^>]*>[^<]*<\/?[a-z]*>|[^\s]+[.,?!]?|\S)/gi);return null!==(t=null==n?void 0:n.filter(e=>""!==e.trim()))&&void 0!==t?t:[]}sanitizeMarkdownText(e){return e.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*?)\*\*/gim,"<b>$1</b>").replace(/\*(.*?)\*/gim,"<i>$1</i>").trim()}removeTrailingPunctuation(e){return[".",",","!","?",":",";"].includes(e[e.length-1])?this.removeTrailingPunctuation(e.slice(0,-1)):e}mapAndMarkHyperLinks(e){const t=Array.from(e.matchAll(/<https?:\/\/[^|]+\|[^>]+>|<a href="[^"]+"(?: target="[^"]*")?>[^<]+<\/a>|\[.*?\]\([^)]*\.[^)]*\)/g)),n=[],i=t.map(t=>{const n=t[0];if(void 0===t.index)return;const i=e[t.index-1],r=e[t.index+n.length];if(n.startsWith("<https")||n.startsWith("<http"))return{matchedLink:n,link:n.split("|")[0].replace("<",""),hyperlink:n.split("|")[1].replace(">",""),addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)};if(n.startsWith("<a href=")){const e=n.match(/href="([^"]+)"/),t=n.match(/>[^<]+</);return{matchedLink:n,link:e?e[1]:"",hyperlink:t?t[0].slice(1,-1):"",addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)}}{const[e,t]=n.split("](");return{matchedLink:n,link:t?t.slice(0,-1):"",hyperlink:e?e.slice(1):"",addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)}}});return i.forEach(t=>{if(t&&t.link&&t.hyperlink){const i=wu().replace(/-/g,"");n.push({link:this.removeTrailingPunctuation(t.link),hyperlink:this.removeTrailingPunctuation(t.hyperlink),mark:t.matchedLink,id:i}),e=e.replace(t.matchedLink,`${t.addSpaceBefore?" ":""}${i}${t.addSpaceAfter?" ":""}`)}}),{hyperlinks:n,markedText:e}}async getLinkData(e){var t,n,i,o;try{const a=(await r().get(e)).data,s=(new DOMParser).parseFromString(a,"text/html");return s?{title:null!==(n=null===(t=s.querySelector("title"))||void 0===t?void 0:t.textContent)&&void 0!==n?n:null,description:(null===(i=s.querySelector('meta[name="description"]'))||void 0===i?void 0:i.getAttribute("content"))||null,image:(null===(o=s.querySelector('meta[property="og:image"]'))||void 0===o?void 0:o.getAttribute("content"))||null,favicon:null,link:e}:{title:null,description:null,image:null,favicon:null,link:e}}catch(t){return{title:null,description:null,image:null,favicon:null,link:e}}}render(){return this.message?R`<div class="message-inner-body">
|
|
6568
6568
|
${this.isMessageStillStreamingChunks()?R`<div class="message-loader"><mini-loader></mini-loader></div>`:""}
|
|
6569
6569
|
<p
|
|
6570
|
-
class=${ye({"message-text":this.widgetType!==
|
|
6570
|
+
class=${ye({"message-text":this.widgetType!==Pc.Utilities,"message-text-large":this.widgetType===Pc.Utilities,"webchat-font__desktop":!_r(),"webchat-font__mobile":_r()})}
|
|
6571
6571
|
>
|
|
6572
6572
|
${this.parsedMessage}
|
|
6573
6573
|
</p>
|
|
@@ -6598,9 +6598,9 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
6598
6598
|
/>`:""}
|
|
6599
6599
|
|
|
6600
6600
|
<div class="website-preview-body">
|
|
6601
|
-
<p class=${ye({"message-text":this.widgetType!==
|
|
6601
|
+
<p class=${ye({"message-text":this.widgetType!==Pc.Utilities,"message-text-large":this.widgetType===Pc.Utilities,"website-preview-title":!0,"webchat-font__desktop":!_r(),"webchat-font__mobile":_r()})}>${e.title}</p>
|
|
6602
6602
|
${e.description?R`<p
|
|
6603
|
-
class=${ye({"message-text":this.widgetType!==
|
|
6603
|
+
class=${ye({"message-text":this.widgetType!==Pc.Utilities,"message-text-large":this.widgetType===Pc.Utilities,"website-preview-description":!0,"webchat-font__desktop":!_r(),"webchat-font__mobile":_r()})}
|
|
6604
6604
|
>
|
|
6605
6605
|
${e.description}
|
|
6606
6606
|
</p>`:""}
|
|
@@ -6868,7 +6868,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
6868
6868
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M15 0C17.7614 0 20 2.23858 20 5V15C20 17.7614 17.7614 20 15 20H5C2.23858 20 0 17.7614 0 15V5C0 2.23858 2.23858 0 5 0H15ZM18 5C18 3.34315 16.6569 2 15 2H5C3.34315 2 2 3.34315 2 5V15C2 16.6569 3.34315 18 5 18H15C16.6569 18 18 16.6569 18 15V5Z" fill="${e}"/>
|
|
6869
6869
|
<path d="M12.1893 9.25L10.4697 7.53033C10.1768 7.23744 10.1768 6.76256 10.4697 6.46967C10.7626 6.17678 11.2374 6.17678 11.5303 6.46967L13.8232 8.76256C14.5066 9.44598 14.5066 10.554 13.8232 11.2374L11.5303 13.5303C11.2374 13.8232 10.7626 13.8232 10.4697 13.5303C10.1768 13.2374 10.1768 12.7626 10.4697 12.4697L12.1893 10.75L6 10.75C5.58579 10.75 5.25 10.4142 5.25 10C5.25 9.58579 5.58579 9.25 6 9.25L12.1893 9.25Z" fill="${e}"/>
|
|
6870
6870
|
</svg>
|
|
6871
|
-
`;var ec=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
|
|
6871
|
+
`;var ec,tc=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 nc=ec=class extends oe{constructor(){super(...arguments),this.right=void 0,this.bottom=void 0,this.top=void 0,this.left=void 0,this.onMount=()=>({}),this.isHealthChat=!1,this.widgetType=Pc.Default,this.primaryColor=qn,this.backgroundColor=Yn,this.onClickExit=()=>{localStorage.setItem("isChatOpen","false")},this.requiresConsent=!1,this._isMobile=_r(),this.shouldAutoScroll=!0,this.messages=[],this.isLoadingMessages=!1,this.hasReceivedConsent=!1,this.privacyPolicyUrl="http://bit.ly/me_privacy_policy",this.websitePreviewMapping={},this.sendMessage=async e=>{var t;0!==e.length&&(this.shouldAutoScroll=!0,this.messageInput.value="",this.autoResizeMessageInput(),0===this.messages.length&&(this.messages=[{timestamp:0,message:e,isLeadMessage:!0,chunks:[{text:e,order:0,isDone:!0}],type:ku.text}]),await(null===(t=this.myPubnub)||void 0===t?void 0:t.sendMessage(e)))},this.scrollToChatBottom=()=>{this.shouldAutoScroll&&this.messageBody.scrollTo({top:this.messageBody.scrollHeight-this.messageBody.clientHeight,behavior:"auto"})},this.handleConversationScroll=e=>{const t=e.currentTarget,n=t.scrollHeight-t.clientHeight-t.scrollTop;this.shouldAutoScroll=n<=ec.AUTO_SCROLL_THRESHOLD_PX},this.autoResizeMessageInput=()=>{this.messageInput.style.height="auto",this.messageInput.style.height=this.messageInput.scrollHeight+"px"},this.needsConsent=()=>this.requiresConsent&&!this.hasReceivedConsent}get consentKey(){return`${this.orgSlug}Consent`}connectedCallback(){super.connectedCallback(),this._cleanupMobileListener=Or(e=>{this._isMobile=e})}disconnectedCallback(){var e;null===(e=this._cleanupMobileListener)||void 0===e||e.call(this),super.disconnectedCallback()}firstUpdated(){var e,t;this.messages=(null===(e=this.myPubnub)||void 0===e?void 0:e.simpleChatMessages)||[],null===(t=this.myPubnub)||void 0===t||t.addChatListener(e=>{this.messages=e.messages,this.isLoadingMessages=e.isLoading}),this.onMount();const n=localStorage.getItem(this.consentKey);if(!n)return void(this.hasReceivedConsent=!1);const i=JSON.parse(n),{timestamp:r,consentId:o}=i;Kd(new Date,new Date(r))<7&&o===Io?this.hasReceivedConsent=!0:(this.hasReceivedConsent=!1,localStorage.removeItem(this.consentKey))}async updated(){this.scrollToChatBottom();try{const e=document.getElementById("#healthchat-container");if(!e)return;e.focus()}catch(e){}}render(){var e,t,n,i,r,o,a,s,l,u,d,c,h,p,f,g,m,y,b,v,w,C,x;if(!this.buildingSlug)return R``;const $=null===(e=this.building)||void 0===e?void 0:e.id;let S={};if(S=this._isMobile?{top:void 0,bottom:0,left:void 0,right:0}:{top:void 0===this.top||isNaN(this.top)?void 0:`${this.top}px`,bottom:void 0===this.bottom||isNaN(this.bottom)?"130px":`${this.bottom}px`,left:void 0===this.left||isNaN(this.left)?void 0:`${this.left}px`,right:void 0===this.right||isNaN(this.right)?"18px":`${this.right}px`},22320===$&&(S={...S,fontFamily:'"Helvetica Neue", Arial'}),this.widgetType===Pc.Utilities)return R`
|
|
6872
6872
|
<div
|
|
6873
6873
|
id="utilities-container"
|
|
6874
6874
|
class=${ye({"pubnub-container__mobile":this._isMobile,"utilities-container__desktop":!this._isMobile})}
|
|
@@ -6893,6 +6893,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
6893
6893
|
</div>
|
|
6894
6894
|
<div
|
|
6895
6895
|
id="conversation-body"
|
|
6896
|
+
@scroll=${this.handleConversationScroll}
|
|
6896
6897
|
class=${ye({hidden:this.needsConsent(),"utilities-conversation-body-backdrop":!0})}
|
|
6897
6898
|
>
|
|
6898
6899
|
<ul
|
|
@@ -6978,7 +6979,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
6978
6979
|
</div>
|
|
6979
6980
|
</div>
|
|
6980
6981
|
</div>
|
|
6981
|
-
`;if(this.widgetType===
|
|
6982
|
+
`;if(this.widgetType===Pc.Healthcare)return R`
|
|
6982
6983
|
<div
|
|
6983
6984
|
id="healthchat-container"
|
|
6984
6985
|
class=${ye({"pubnub-container__mobile":this._isMobile,"healthchat-container__desktop":!this._isMobile})}
|
|
@@ -7007,6 +7008,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
7007
7008
|
</div>
|
|
7008
7009
|
<div
|
|
7009
7010
|
id="conversation-body"
|
|
7011
|
+
@scroll=${this.handleConversationScroll}
|
|
7010
7012
|
class=${ye({hidden:this.needsConsent(),"healthcare-conversation-body-backdrop":!0})}
|
|
7011
7013
|
>
|
|
7012
7014
|
<ul
|
|
@@ -7121,6 +7123,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
7121
7123
|
</div>
|
|
7122
7124
|
<div
|
|
7123
7125
|
id="conversation-body"
|
|
7126
|
+
@scroll=${this.handleConversationScroll}
|
|
7124
7127
|
style=${Vn({background:444===this.building.orgId?"rgba(229, 229, 229, 1);":void 0})}
|
|
7125
7128
|
class=${ye({hidden:this.needsConsent(),"leasing-conversation-body-backdrop":!0})}
|
|
7126
7129
|
>
|
|
@@ -7204,7 +7207,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
7204
7207
|
</button>
|
|
7205
7208
|
</div>
|
|
7206
7209
|
</div>
|
|
7207
|
-
`}};tc.styles=[Oe,Uu,Lu,Du,Xd],ec([ue({type:Number})],tc.prototype,"right",void 0),ec([ue({type:Number})],tc.prototype,"bottom",void 0),ec([ue({type:Number})],tc.prototype,"top",void 0),ec([ue({type:Number})],tc.prototype,"left",void 0),ec([ue({attribute:!0})],tc.prototype,"onMount",void 0),ec([ue({attribute:!0})],tc.prototype,"channel",void 0),ec([ue({attribute:!0})],tc.prototype,"isHealthChat",void 0),ec([ue({attribute:!0})],tc.prototype,"myPubnub",void 0),ec([ue({attribute:!0})],tc.prototype,"orgSlug",void 0),ec([ue({attribute:!0})],tc.prototype,"buildingSlug",void 0),ec([ue({attribute:!0})],tc.prototype,"widgetType",void 0),ec([ue({attribute:!0})],tc.prototype,"building",void 0),ec([ue({attribute:!0})],tc.prototype,"primaryColor",void 0),ec([ue({attribute:!0})],tc.prototype,"backgroundColor",void 0),ec([ue({attribute:!0})],tc.prototype,"onClickExit",void 0),ec([ue({attribute:!0})],tc.prototype,"requiresConsent",void 0),ec([ce("#message-input",!0)],tc.prototype,"messageInput",void 0),ec([ce("#conversation-body",!0)],tc.prototype,"messageBody",void 0),ec([de()],tc.prototype,"_isMobile",void 0),ec([de()],tc.prototype,"messages",void 0),ec([de()],tc.prototype,"isLoadingMessages",void 0),ec([de()],tc.prototype,"hasReceivedConsent",void 0),ec([de()],tc.prototype,"privacyPolicyUrl",void 0),ec([de()],tc.prototype,"websitePreviewMapping",void 0),tc=ec([se("pubnub-chat")],tc);const nc="cdn.skypack.dev/@meetelise/chat",ic="cdn.eliseai.com/@meetelise/chat",rc=async(e,t)=>{try{if(Math.random()>=.15)return;const n=(()=>{try{const e=document.getElementsByTagName("script");for(const t of e){const e=t.src||"",n=t.textContent||"";if(e.includes(nc)||n.includes(nc))return"skypack";if(e.includes(ic)||n.includes(ic))return"eliseai"}return"unknown"}catch(e){return"unknown"}})();await r().post("https://app.meetelise.com/platformApi/webchat/cdn-version",{cdn_version:n},{params:{cdn_version:n},headers:{"Content-Type":"application/json","building-slug":t,"org-slug":e}})}catch(e){}},oc=(e,t)=>["floor plan","floorplan","floor plans","floorplans","apply here"].some(t=>e.toLowerCase().includes(t))?t.endsWith("/units")?t:`${t}/units`:t,ac={"95ae958e-95db-11ed-9862-6f4db5533d3f":"8008db60-45b7-11f1-88ac-635f686365da","95ae96b0-95db-11ed-9863-a7aa664fd985":"72ed27c4-45b7-11f1-82d9-37b7db547687"},sc="https://applications.eliseai.com",lc=["Check Availability","Apply Now"],uc=(e,t,n,i)=>{if(!(e=>{var t;if(!e.classList.contains("floorplan-button"))return!1;const n=e.getElementsByTagName("span");if(1!==n.length)return!1;const i=null===(t=n[0].textContent)||void 0===t?void 0:t.trim();return null!=i&&lc.includes(i)})(e))return!1;if(e.getAttribute("href")===t)return!1;const r=e.getAttribute("href");return e.setAttribute("href",t),e.setAttribute("target","_blank"),Fo({logTitle:"CHECK_AVAIL_OVERWRITE",logData:{oldHref:r,newHref:t,website:window.location.href},logType:jo.info,buildingSlug:i,orgSlug:n}),!0},dc=(e,t,n,i)=>{for(let r=0;r<e.length;r++){const o=e[r];if(o.nodeType!==Node.ELEMENT_NODE)continue;const a=o;"A"===a.tagName&&uc(a,t,n,i);const s=a.getElementsByTagName("a");for(let e=0;e<s.length;e++)uc(s[e],t,n,i)}},cc=(e,t,n)=>{((e,t,n)=>{const i=document.body.getElementsByTagName("a");for(let r=0;r<i.length;r++)uc(i[r],e,t,n)})(n,e,t);new MutationObserver(i=>{for(const r of i)dc(r.addedNodes,n,e,t)}).observe(document.body,{childList:!0,subtree:!0})};class hc{constructor(e,t){this.persistLeadSourceTTLDays=30,this.maxSourcesNonPropertyWebsiteCount=3,this._generateLeadSourceLocalStorageKey=()=>`com.eliseai.webchat.leadsources.v2.buildingslug=${this.buildingSlug}`,this._generateNewExpirationTimestamp=()=>Rr(Br(new Date,this.persistLeadSourceTTLDays)),this._generateLeadSourceParameters=()=>{const e=yo();return{websiteOrigin:window.location.origin,websiteSearch:window.location.search,queryParameters:e,referrer:document.referrer,parsedUtmSource:e?e.utm_source:null,campaignSources:Object.values(Bo()).filter(e=>e)}},this.addSafeLeadSourceTouchpoint=e=>{const t=this.getLocalStorageMultitouchValue(),n=this._generateLeadSourceLocalStorageKey();if(!t||this.isExpiredTimestamp(t.timestampExpires)){const t={timestampExpires:this._generateNewExpirationTimestamp(),leadSources:[{parameters:this._generateLeadSourceParameters(),leadSourceValue:e,timestampInitiallyLogged:Rr(new Date),type:"touchpoint"}]};localStorage.setItem(n,JSON.stringify(t))}else{if(t.leadSources.find(t=>t.leadSourceValue===e))return;if(t.leadSources.length<this.maxSourcesNonPropertyWebsiteCount)return t.leadSources.push({parameters:this._generateLeadSourceParameters(),leadSourceValue:e,timestampInitiallyLogged:Rr(new Date),type:"touchpoint"}),t.timestampExpires=this._generateNewExpirationTimestamp(),void localStorage.setItem(n,JSON.stringify(t));Fo({logType:jo.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,logTitle:"TOO_MANY_LEAD_SOURCES",logData:{buildingSlug:this.buildingSlug}})}},this.getSafeLeadSourceTouchpointsWithDefault=({includedUserSelectedLeadSource:e})=>{const t=this.getLocalStorageMultitouchValue(),n=Qo(this.orgSlug);if(!t){const t=[{leadSourceValue:n,timestampInitiallyLogged:Rr(new Date),type:"default"}];return e&&t.push({leadSourceValue:e,timestampInitiallyLogged:Rr(new Date),type:"user-selected"}),t}const i=t.leadSources.length>0?t.leadSources.sort((e,t)=>Wr(e.timestampInitiallyLogged).getTime()-Wr(t.timestampInitiallyLogged).getTime())[0].timestampInitiallyLogged:Rr(new Date),r=[{timestampInitiallyLogged:i,leadSourceValue:n,type:"default"},...t.leadSources.map(e=>({timestampInitiallyLogged:e.timestampInitiallyLogged,leadSourceValue:e.leadSourceValue,type:e.type}))];return e&&r.push({leadSourceValue:e,timestampInitiallyLogged:Rr(new Date),type:"user-selected"}),r},this.getLocalStorageMultitouchValue=()=>{const e=this._generateLeadSourceLocalStorageKey(),t=localStorage.getItem(e);if(!t)return null;return JSON.parse(t)},this.isExpiredTimestamp=e=>Wr(e)<new Date,this.resetLeadSourceTouchpoints=()=>{const e=this._generateLeadSourceLocalStorageKey();return localStorage.removeItem(e),!0},this.orgSlug=e,this.buildingSlug=t}}var pc,fc=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 gc=pc=class extends oe{constructor(){super(...arguments),this.buildingSlug="",this.orgSlug="",this.centralConvo=!1,this.launcherStyles={},this.mobileStyles={},this.isMinimized=!1,this.primaryColor=null,this.backgroundColor=null,this.foregroundColorOnPrimaryBackgroundColor=null,this.foregroundColorOnSecondaryBackgroundColor=null,this._isMobile=_r(),this.chatId="",this.analytics=null,this.launcher=null,this.buildingWebchatView=null,this.designConcept=null,this.leadSources=null,this.currentLeadSource=null,this.featureFlagShowDropdown=fo.always,this.bedroomPreferenceRequired=!1,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.LeadSourceMultitouchClient=null,this.sampleRateToUse=.05,this.right=void 0,this.bottom=void 0,this.top=void 0,this.left=void 0,this.overrideRentgrata=!1,this.widgetType=Oc.Default,this.onWidgetLoaded=Bl(),this.onSstClose=Bl(),this.enabledChatWidgets={callDesktop:!1,callMobile:!1,chatMobile:!1,chatDesktop:!1,emailDesktop:!1,emailMobile:!1,textDesktop:!1,textMobile:!1,sstDesktop:!1,sstMobile:!1,calcDesktop:!1,calcMobile:!1},this.webchatConfigHasAutoOpenChat=!1,this.requiresConsent=!1,this.hideMobileFeatures=!1,this.privacyPolicyUrl="http://bit.ly/me_privacy_policy",this.launcherRef=Ee(),this.firstUpdated=async()=>this.setupWebchat(),this.setupWebchat=async()=>{if(!this.orgSlug)return;if(!this.centralConvo&&!this.buildingSlug)return;const e=this.centralConvo?await async function(e){const t=`https://app.meetelise.com/api/pub/v1/organization/${e}/webchat/v2`,n=await r().get(t);return Jo(n.data)}(this.orgSlug):await Zo(this.orgSlug,this.buildingSlug);if(Math.random()<.2)try{(async(e,t)=>{const n=window.rentgrata;if(!n)return;const i=n.Widget;if(!i)return;const o=i.config;if(!o)return;const a=o.widgetKey;a&&await r().post(`https://app.meetelise.com/platformApi/webchat/rentgrata?token=${a}`,{},{headers:{"Content-Type":"application/json","building-slug":null!=e?e:"","org-slug":null!=t?t:""}})})(this.buildingSlug,this.orgSlug)}catch(e){}try{rc(this.orgSlug,this.buildingSlug)}catch(e){}await za(e,this.buildingSlug,this.orgSlug)&&(Ho({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!0},sampleRate:(null==e?void 0:e.launchedDateTime)?.01:.05}),this.buildingWebchatView=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))},this.setBuildingDerivedInfo=async()=>{var e,t,n,i,o,a,s,l,u,d,c,h,p,f,g,m,y,b,v,w,C,x,$,S,A,E,T,k,_,O,P,I,N,M,D,L,U,R,B,j,F,H,G,z,Q,W,V,q,Y;const K=this.buildingWebchatView;if(!K)return;K&&this.orgSlug&&yc(this.orgSlug,null!==(t=null===(e=this.LeadSourceClient)||void 0===e?void 0:e.chatId)&&void 0!==t?t:null,this.sampleRateToUse,this.buildingSlug,null!==(i=null===(n=this.LeadSourceClient)||void 0===n?void 0:n.leadSource)&&void 0!==i?i:null);const X=K.featureFlagWebchatMarketingSourceDropdownConfiguration,Z=K.featureFlagWebchatUseDniPhoneNumberBySource,J=K.featureFlagInsertDniIntoWebsite,ee=K.featureFlagWebchatReplaceAnyScheduleTourCtaWebsite;var te;te=vo.includes(K.orgId),Co=te;const[ne,ie,re,oe]=await Promise.all([su(this.orgSlug,this.buildingSlug),go(this.buildingSlug),uu(this.buildingSlug),mo(this.buildingSlug)]);this.buildingWebchatView&&(this.buildingWebchatView.phoneNumber=Gn(K.phoneNumber),this.buildingWebchatView.isAip=re),this.leadSources=ne,this.featureFlagShowDropdown=X,this.bedroomPreferenceRequired=oe;const ae=K.textWithUsPhoneNumber?K.textWithUsPhoneNumber:await(async e=>{try{const t="https://app.meetelise.com",n=await r().get(`${t}/platformApi/webchat/${e}/phone-number`);if(n.data)return n.data}catch(t){return Fo({logType:jo.error,buildingSlug:e,logTitle:"[ERROR_GETTING_PHONE_NUMBERS]",logData:{error:t},error:t}),null}return null})(this.buildingSlug),se=null!==(a=null===(o=this.buildingWebchatView)||void 0===o?void 0:o.shouldShowPricingCalculatorDesktop)&&void 0!==a&&a,le=null!==(l=null===(s=this.buildingWebchatView)||void 0===s?void 0:s.shouldShowPricingCalculatorMobile)&&void 0!==l&&l,ue={callDesktop:null!==(d=null===(u=this.buildingWebchatView)||void 0===u?void 0:u.shouldShowPhoneDesktop)&&void 0!==d&&d,callMobile:null!==(h=null===(c=this.buildingWebchatView)||void 0===c?void 0:c.shouldShowPhoneMobile)&&void 0!==h&&h,chatDesktop:null!==(f=null===(p=this.buildingWebchatView)||void 0===p?void 0:p.shouldShowChatDesktop)&&void 0!==f&&f,chatMobile:null!==(m=null===(g=this.buildingWebchatView)||void 0===g?void 0:g.shouldShowChatMobile)&&void 0!==m&&m,emailDesktop:null!==(b=null===(y=this.buildingWebchatView)||void 0===y?void 0:y.shouldShowEmailDesktop)&&void 0!==b&&b,emailMobile:null!==(w=null===(v=this.buildingWebchatView)||void 0===v?void 0:v.shouldShowEmailMobile)&&void 0!==w&&w,textDesktop:null!==(x=(null===(C=this.buildingWebchatView)||void 0===C?void 0:C.shouldShowTextDesktop)&&!!ae)&&void 0!==x&&x,textMobile:null!==(S=(null===($=this.buildingWebchatView)||void 0===$?void 0:$.shouldShowTextMobile)&&!!ae)&&void 0!==S&&S,sstDesktop:null!==(E=null===(A=this.buildingWebchatView)||void 0===A?void 0:A.shouldShowSstDesktop)&&void 0!==E&&E,sstMobile:null!==(k=null===(T=this.buildingWebchatView)||void 0===T?void 0:T.shouldShowSstMobile)&&void 0!==k&&k,calcDesktop:se,calcMobile:le};var de,ce;this.enabledChatWidgets=Wl(ue),this.enabledChatWidgets.sstDesktop||this.enabledChatWidgets.sstMobile||"radco"===this.orgSlug?(ce=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(),ce(e)})}),ee&&(e=>{document.querySelectorAll('a[href$="schedule-a-tour"]').forEach(t=>{t&&t.addEventListener("click",t=>{t.preventDefault(),e(t)})})})(this.handleTourClicked),"radco"===this.orgSlug&&(e=>{document.querySelectorAll('a[href^="#leaseleads-tour-open"]').forEach(t=>{var n;if(!t)return;const i=document.createElement("a");i.textContent=t.textContent,i.style.cursor="pointer",i.addEventListener("click",t=>{t.preventDefault(),e(t)}),null===(n=t.parentNode)||void 0===n||n.replaceChild(i,t)})})(this.handleTourClicked)):(null===(_=this.LeadSourceClient)||void 0===_?void 0:_.leadSource)&&(de=null!==(P=null===(O=this.LeadSourceClient)||void 0===O?void 0:O.leadSource)&&void 0!==P?P: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(de)}`)}})),this.buildingWebchatView&&(this.primaryColor=null!==(I=this.buildingWebchatView.primaryColor)&&void 0!==I?I:null,this.backgroundColor=null!==(N=this.buildingWebchatView.secondaryColor)&&void 0!==N?N:null,this.foregroundColorOnPrimaryBackgroundColor=null!==(M=this.buildingWebchatView.foregroundColorOnPrimaryBackgroundColor)&&void 0!==M?M:null,this.foregroundColorOnSecondaryBackgroundColor=null!==(D=this.buildingWebchatView.foregroundColorOnSecondaryBackgroundColor)&&void 0!==D?D:null,this.webchatConfigHasAutoOpenChat=null!==(L=this.buildingWebchatView.autoOpenChat)&&void 0!==L&&L,this.requiresConsent=null!==(U=this.buildingWebchatView.requiresConsentForChat)&&void 0!==U&&U,this.hideMobileFeatures=null!==(R=this.buildingWebchatView.collapseMobileFeatures)&&void 0!==R&&R,this.privacyPolicyUrl=null!==(B=this.buildingWebchatView.privacyPolicyUrlForChat)&&void 0!==B?B:this.privacyPolicyUrl,this.buildingWebchatView.displayStyle===qo.MINIMIZED&&(this.isMinimized=!0),this.buildingWebchatView.displayStyle===qo.PILLS&&(this.designConcept=null),this.buildingWebchatView.displayStyle===qo.EMOJI&&(this.designConcept=qo.EMOJI),this.onWidgetLoaded()),null===this.primaryColor&&(this.primaryColor=qn),null===this.backgroundColor&&(this.backgroundColor=Yn);const he=null!==(F=null===(j=this.buildingWebchatView)||void 0===j?void 0:j.phoneNumber)&&void 0!==F?F:"";let pe=null;if(Z&&(pe=await async function(e,t){try{const n=await r().get(`https://app.meetelise.com/platformApi/webchat/${e}/phone-number-by-source`,{params:{source:t}});return n.data?{number:Gn(n.data.number),isMatch:n.data.match,isPropertyWebsiteCatchall:n.data.isPropertyWebsiteCatchall}:null}catch(e){return null}}(this.buildingSlug,null!==(G=null===(H=this.LeadSourceClient)||void 0===H?void 0:H.leadSource)&&void 0!==G?G:null),pe&&!pe.isMatch&&(pe.number=he)),J&&(null==pe?void 0:pe.number)){const e=Iu(pe.number,this.orgSlug,this.buildingSlug);e>0&&Ho({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_dni_insert_override_success:!0,extra_data:{total_replacements:e}},sampleRate:this.sampleRateToUse})}const fe=localStorage.getItem("eliseai_phone_number_devtest");fe&&Iu(fe,this.orgSlug,this.buildingSlug),this.phoneNumberForSource=pe||{number:he,isMatch:!1,isPropertyWebsiteCatchall:!0};const ge=null!==(Q=null===(z=this.LeadSourceClient)||void 0===z?void 0:z.leadSource)&&void 0!==Q?Q:null;ge&&(this.leadSources.includes(ge)||this.leadSources.push(ge)),io(K.id);if((ie||(null===(W=this.buildingWebchatView)||void 0===W?void 0:W.isAip))&&(null===(V=this.buildingWebchatView)||void 0===V?void 0:V.isLiveOnApplications)&&this.buildingSlug){const e=((e,t,n)=>{var i;const r=[/thehavenatgreenhill\.securecafe\.com\/onlineleasing\/the-haven-at-greenhill\/oleapplication\.aspx(\?.*)?$/,/securecafe\.com\/onlineleasing.*\/oleapplication\.aspx(\?.*)?$/,/\/onlineleasing.*\/oleapplication\.aspx(\?.*)?$/,/\/content\/apply/,/\/apply-now/,/\/apply/,/vsc\.myresman\.com\/Portal\/Applicants\/Availability(\?.*)?$/,/vsc\.myresman\.com\/Portal\/Applicants\/New\/.*(\?.*)?$/,/busboomgroup\.myresman\.com\/Portal\/Applicants\/Availability(\?.*)?$/],o=document.body.getElementsByTagName("a");let a=0;for(let s=0;s<o.length;s++){const l=o[s];if(l.nodeType===Node.ELEMENT_NODE&&r.some(e=>e.test(l.href))){const r=l.getAttribute("href"),o=(null===(i=l.textContent)||void 0===i?void 0:i.toLowerCase())||"",s=oc(o,e);l.setAttribute("href",s),a++,Fo({logTitle:"SELECT_BUTTON_LINK_REPLACEMENT",logData:{type:"link-replacement",oldHref:r,newHref:s,website:window.location.href},logType:jo.info,buildingSlug:n,orgSlug:t})}}return 0===a&&Fo({logTitle:"SELECT_BUTTON_LINK_REPLACEMENT",logData:{type:"no-select-buttons-found",website:window.location.href},logType:jo.warn,buildingSlug:n,orgSlug:t}),a})(`https://applications.eliseai.com/building/${this.buildingSlug}/units`,this.orgSlug,this.buildingSlug);e>0&&Ho({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_application_link_replacement_success:!0,extra_data:{total_replacements:e}},sampleRate:this.sampleRateToUse})}if(this.buildingSlug&&this.orgSlug)try{(e=>{const t=ac[e];if(!t)return 0;const n=`${sc}/building/${t}/units`,i=`${sc}/building/${e}/units`,r=new RegExp(`https://applications\\.eliseai\\.com/building/${t}/units`,"g");let o=0;const a=document.body.getElementsByTagName("a");for(let e=0;e<a.length;e++){const t=a[e],s=t.getAttribute("href");if(!s||!s.includes(n))continue;const l=s.replace(r,i);l!==s&&(t.setAttribute("href",l),o++)}document.body.querySelectorAll("[onclick]").forEach(e=>{const t=e.getAttribute("onclick");if(!t||!t.includes(n))return;const a=t.replace(r,i);a!==t&&(e.setAttribute("onclick",a),o++)})})(this.buildingSlug)}catch{}this.buildingSlug&&(null===(q=this.buildingWebchatView)||void 0===q?void 0:q.isLiveOnApplications)&&(null===(Y=this.buildingWebchatView)||void 0===Y?void 0:Y.applicationLink)&&"c954426c-12ab-4f8e-8384-8218e79eaf72"===this.orgSlug&&cc(this.orgSlug,this.buildingSlug,this.buildingWebchatView.applicationLink)},this.initializeChatVariables=async()=>{var e,t,n,i,r,o,a,s,l,u;if(!this.buildingWebchatView)return;const d=$u(this.buildingSlug),c=Su(this.buildingSlug,d),h=c?d:xu(this.buildingSlug,!1);if(!h.leadId)throw new Error("Lead ID is null");this.LeadSourceClient=new Wo,this.LeadSourceClient.orgId=null!==(t=null===(e=this.buildingWebchatView)||void 0===e?void 0:e.orgId)&&void 0!==t?t:0,this.LeadSourceMultitouchClient=new hc(this.orgSlug,this.buildingSlug),this.myPubnub=new _u(this.buildingSlug,this.buildingWebchatView,this.orgSlug,null,h.leadId,this.LeadSourceMultitouchClient,this.LeadSourceClient,this.widgetType);const p=await this.myPubnub.initSession(this.buildingSlug,this.orgSlug,c&&null!==(n=h.leadId)&&void 0!==n?n:void 0);p&&xu(this.buildingSlug,h.initiatedChat,p.lead_id),this.LeadSourceClient.chatId=this.myPubnub.channel;const f=await(null===(i=this.LeadSourceClient)||void 0===i?void 0:i.generateUserLeadSource({leadId:null!==(o=null===(r=this.myPubnub)||void 0===r?void 0:r.leadUserId)&&void 0!==o?o:"",orgSlug:this.orgSlug,buildingSlug:this.buildingSlug}));f&&this.LeadSourceMultitouchClient.addSafeLeadSourceTouchpoint(f),"property-website"!==Qo(this.orgSlug)?this.myPubnub.leadSource=null!==(s=null===(a=this.LeadSourceClient)||void 0===a?void 0:a.leadSource)&&void 0!==s?s:Qo(this.orgSlug):this.myPubnub.leadSource=null!==(u=null===(l=this.LeadSourceClient)||void 0===l?void 0:l.leadSource)&&void 0!==u?u:null;const g=$u(this.buildingSlug);g.initiatedChat&&await this.myPubnub.initializePubnub(g)},this.shouldAutoOpenChat=e=>{const t=sessionStorage.getItem("alreadyAutoOpenedTimestamp"),n=!t||!(t&&!Gr(Wr(t)));return!!e&&!!n&&!_r()},this.updateAlreadyAutoOpenedTimestamp=()=>{sessionStorage.setItem("alreadyAutoOpenedTimestamp",Rr(function(e,t){return ni(2,arguments),vi(e,6e4*bi(t))}(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;if("Tab"!==e.key)return;const u=null===(n=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("meetelise-launcher"))||void 0===n?void 0:n.shadowRoot;let d=[];if(this.displayPubnubChat){const e=null===(o=null===(r=null===(i=this.shadowRoot)||void 0===i?void 0:i.getElementById("pubnub-chat"))||void 0===r?void 0:r.shadowRoot)||void 0===o?void 0:o.getElementById("pubnub-chat-container"),t=null===(a=this.shadowRoot)||void 0===a?void 0:a.getElementById("chatAdditionalActionsPubnub");e&&d.push(...this.collectFocusableElements(e)),t&&d.push(...this.collectFocusableElements(t))}else{const e=null!==(l=null!==(s=null==u?void 0:u.getElementById("email-us-window"))&&void 0!==s?s:null==u?void 0:u.getElementById("tour-scheduler-window"))&&void 0!==l?l:null==u?void 0:u.getElementById("call-us-window");e&&(d=this.collectFocusableElements(e))}if(0===d.length)return;e.preventDefault();const c=this.getDeepActiveElement(),h=d.findIndex(e=>e===c);d[e.shiftKey?(h-1+d.length)%d.length:(h+1)%d.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")}}async handleChatInitializeAnalytics(){var e,t,n,i;this.analytics=new Ro(this.orgSlug,this.buildingSlug,null!==(t=null===(e=this.myPubnub)||void 0===e?void 0:e.channel)&&void 0!==t?t:"",null!==(i=null===(n=this.LeadSourceClient)||void 0===n?void 0:n.leadSource)&&void 0!==i?i:null),Math.random()<.05&&this.analytics.ping("webchat_heartbeat")}async restartConversation(){var e;null===(e=this.myPubnub)||void 0===e||e.handleDisconnect(),Cu(this.buildingSlug),this.myPubnub=null,this.displayPubnubChat=!1,await this.setupWebchat(),this.hideLauncher=!1}show(){this.launcher&&(this.launcher.style.display="")}hide(){this.launcher&&(this.launcher.style.display="none")}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.adjustPositionChatAdditionalActions),window.addEventListener("keydown",this.handleKeydownTab),this._cleanupMobileListener=Or(e=>{this._isMobile=e})}static isFocusable(e){return!("disabled"in e)||!e.disabled}collectFocusableElements(e){const t=[];e instanceof Element&&e.shadowRoot&&t.push(...this.collectFocusableElements(e.shadowRoot));const n=e.querySelectorAll("*");for(const e of Array.from(n))e.matches(pc.FOCUSABLE_SELECTOR)&&pc.isFocusable(e)&&t.push(e),e.shadowRoot&&t.push(...this.collectFocusableElements(e.shadowRoot));return t}getDeepActiveElement(){let e=document.activeElement,t=0;for(;(null==e?void 0:e.shadowRoot)&&(null==e?void 0:e.shadowRoot.activeElement);)if(t+=1,e=null==e?void 0:e.shadowRoot.activeElement,t>100){Fo({logType:jo.error,buildingSlug:this.buildingSlug,logTitle:"[ERROR_GETTING_DEEP_ELEMENT]",logData:{message:"error getting deep active element"}});break}return e}updated(){this.adjustPositionChatAdditionalActions()}disconnectedCallback(){var e,t;null===(e=this.myPubnub)||void 0===e||e.handleDisconnect(),window.removeEventListener("resize",this.adjustPositionChatAdditionalActions),window.removeEventListener("keydown",this.handleKeydownTab),null===(t=this._cleanupMobileListener)||void 0===t||t.call(this),super.disconnectedCallback()}render(){var e,t,n,i,r,o,a,s,l,u,d,c,h,p,f,g,m,y,b,v,w,C,x,$,S,A,E,T,k,_,O,P,I,N,M,D,L,U,B,j,F,H,G,z,Q;Gl();const W=this.hideLauncher&&!this.isLoading&&!this._isMobile;return R`
|
|
7210
|
+
`}};nc.AUTO_SCROLL_THRESHOLD_PX=32,nc.styles=[Oe,Uu,Lu,Du,Xd],tc([ue({type:Number})],nc.prototype,"right",void 0),tc([ue({type:Number})],nc.prototype,"bottom",void 0),tc([ue({type:Number})],nc.prototype,"top",void 0),tc([ue({type:Number})],nc.prototype,"left",void 0),tc([ue({attribute:!0})],nc.prototype,"onMount",void 0),tc([ue({attribute:!0})],nc.prototype,"channel",void 0),tc([ue({attribute:!0})],nc.prototype,"isHealthChat",void 0),tc([ue({attribute:!0})],nc.prototype,"myPubnub",void 0),tc([ue({attribute:!0})],nc.prototype,"orgSlug",void 0),tc([ue({attribute:!0})],nc.prototype,"buildingSlug",void 0),tc([ue({attribute:!0})],nc.prototype,"widgetType",void 0),tc([ue({attribute:!0})],nc.prototype,"building",void 0),tc([ue({attribute:!0})],nc.prototype,"primaryColor",void 0),tc([ue({attribute:!0})],nc.prototype,"backgroundColor",void 0),tc([ue({attribute:!0})],nc.prototype,"onClickExit",void 0),tc([ue({attribute:!0})],nc.prototype,"requiresConsent",void 0),tc([ce("#message-input",!0)],nc.prototype,"messageInput",void 0),tc([ce("#conversation-body",!0)],nc.prototype,"messageBody",void 0),tc([de()],nc.prototype,"_isMobile",void 0),tc([de()],nc.prototype,"messages",void 0),tc([de()],nc.prototype,"isLoadingMessages",void 0),tc([de()],nc.prototype,"hasReceivedConsent",void 0),tc([de()],nc.prototype,"privacyPolicyUrl",void 0),tc([de()],nc.prototype,"websitePreviewMapping",void 0),nc=ec=tc([se("pubnub-chat")],nc);const ic="cdn.skypack.dev/@meetelise/chat",rc="cdn.eliseai.com/@meetelise/chat",oc=async(e,t)=>{try{if(Math.random()>=.15)return;const n=(()=>{try{const e=document.getElementsByTagName("script");for(const t of e){const e=t.src||"",n=t.textContent||"";if(e.includes(ic)||n.includes(ic))return"skypack";if(e.includes(rc)||n.includes(rc))return"eliseai"}return"unknown"}catch(e){return"unknown"}})();await r().post("https://app.meetelise.com/platformApi/webchat/cdn-version",{cdn_version:n},{params:{cdn_version:n},headers:{"Content-Type":"application/json","building-slug":t,"org-slug":e}})}catch(e){}},ac=(e,t)=>["floor plan","floorplan","floor plans","floorplans","apply here"].some(t=>e.toLowerCase().includes(t))?t.endsWith("/units")?t:`${t}/units`:t,sc={"95ae958e-95db-11ed-9862-6f4db5533d3f":"8008db60-45b7-11f1-88ac-635f686365da","95ae96b0-95db-11ed-9863-a7aa664fd985":"72ed27c4-45b7-11f1-82d9-37b7db547687"},lc="https://applications.eliseai.com",uc=["Check Availability","Apply Now"],dc=(e,t,n,i)=>{if(!(e=>{var t;if(!e.classList.contains("floorplan-button"))return!1;const n=e.getElementsByTagName("span");if(1!==n.length)return!1;const i=null===(t=n[0].textContent)||void 0===t?void 0:t.trim();return null!=i&&uc.includes(i)})(e))return!1;if(e.getAttribute("href")===t)return!1;const r=e.getAttribute("href");return e.setAttribute("href",t),e.setAttribute("target","_blank"),Fo({logTitle:"CHECK_AVAIL_OVERWRITE",logData:{oldHref:r,newHref:t,website:window.location.href},logType:jo.info,buildingSlug:i,orgSlug:n}),!0},cc=(e,t,n,i)=>{for(let r=0;r<e.length;r++){const o=e[r];if(o.nodeType!==Node.ELEMENT_NODE)continue;const a=o;"A"===a.tagName&&dc(a,t,n,i);const s=a.getElementsByTagName("a");for(let e=0;e<s.length;e++)dc(s[e],t,n,i)}},hc=(e,t,n)=>{((e,t,n)=>{const i=document.body.getElementsByTagName("a");for(let r=0;r<i.length;r++)dc(i[r],e,t,n)})(n,e,t);new MutationObserver(i=>{for(const r of i)cc(r.addedNodes,n,e,t)}).observe(document.body,{childList:!0,subtree:!0})};class pc{constructor(e,t){this.persistLeadSourceTTLDays=30,this.maxSourcesNonPropertyWebsiteCount=3,this._generateLeadSourceLocalStorageKey=()=>`com.eliseai.webchat.leadsources.v2.buildingslug=${this.buildingSlug}`,this._generateNewExpirationTimestamp=()=>Rr(Br(new Date,this.persistLeadSourceTTLDays)),this._generateLeadSourceParameters=()=>{const e=yo();return{websiteOrigin:window.location.origin,websiteSearch:window.location.search,queryParameters:e,referrer:document.referrer,parsedUtmSource:e?e.utm_source:null,campaignSources:Object.values(Bo()).filter(e=>e)}},this.addSafeLeadSourceTouchpoint=e=>{const t=this.getLocalStorageMultitouchValue(),n=this._generateLeadSourceLocalStorageKey();if(!t||this.isExpiredTimestamp(t.timestampExpires)){const t={timestampExpires:this._generateNewExpirationTimestamp(),leadSources:[{parameters:this._generateLeadSourceParameters(),leadSourceValue:e,timestampInitiallyLogged:Rr(new Date),type:"touchpoint"}]};localStorage.setItem(n,JSON.stringify(t))}else{if(t.leadSources.find(t=>t.leadSourceValue===e))return;if(t.leadSources.length<this.maxSourcesNonPropertyWebsiteCount)return t.leadSources.push({parameters:this._generateLeadSourceParameters(),leadSourceValue:e,timestampInitiallyLogged:Rr(new Date),type:"touchpoint"}),t.timestampExpires=this._generateNewExpirationTimestamp(),void localStorage.setItem(n,JSON.stringify(t));Fo({logType:jo.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,logTitle:"TOO_MANY_LEAD_SOURCES",logData:{buildingSlug:this.buildingSlug}})}},this.getSafeLeadSourceTouchpointsWithDefault=({includedUserSelectedLeadSource:e})=>{const t=this.getLocalStorageMultitouchValue(),n=Qo(this.orgSlug);if(!t){const t=[{leadSourceValue:n,timestampInitiallyLogged:Rr(new Date),type:"default"}];return e&&t.push({leadSourceValue:e,timestampInitiallyLogged:Rr(new Date),type:"user-selected"}),t}const i=t.leadSources.length>0?t.leadSources.sort((e,t)=>Wr(e.timestampInitiallyLogged).getTime()-Wr(t.timestampInitiallyLogged).getTime())[0].timestampInitiallyLogged:Rr(new Date),r=[{timestampInitiallyLogged:i,leadSourceValue:n,type:"default"},...t.leadSources.map(e=>({timestampInitiallyLogged:e.timestampInitiallyLogged,leadSourceValue:e.leadSourceValue,type:e.type}))];return e&&r.push({leadSourceValue:e,timestampInitiallyLogged:Rr(new Date),type:"user-selected"}),r},this.getLocalStorageMultitouchValue=()=>{const e=this._generateLeadSourceLocalStorageKey(),t=localStorage.getItem(e);if(!t)return null;return JSON.parse(t)},this.isExpiredTimestamp=e=>Wr(e)<new Date,this.resetLeadSourceTouchpoints=()=>{const e=this._generateLeadSourceLocalStorageKey();return localStorage.removeItem(e),!0},this.orgSlug=e,this.buildingSlug=t}}var fc,gc=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 mc=fc=class extends oe{constructor(){super(...arguments),this.buildingSlug="",this.orgSlug="",this.centralConvo=!1,this.launcherStyles={},this.mobileStyles={},this.isMinimized=!1,this.primaryColor=null,this.backgroundColor=null,this.foregroundColorOnPrimaryBackgroundColor=null,this.foregroundColorOnSecondaryBackgroundColor=null,this._isMobile=_r(),this.chatId="",this.analytics=null,this.launcher=null,this.buildingWebchatView=null,this.designConcept=null,this.leadSources=null,this.currentLeadSource=null,this.featureFlagShowDropdown=fo.always,this.bedroomPreferenceRequired=!1,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.LeadSourceMultitouchClient=null,this.sampleRateToUse=.05,this.right=void 0,this.bottom=void 0,this.top=void 0,this.left=void 0,this.overrideRentgrata=!1,this.widgetType=Pc.Default,this.onWidgetLoaded=Bl(),this.onSstClose=Bl(),this.enabledChatWidgets={callDesktop:!1,callMobile:!1,chatMobile:!1,chatDesktop:!1,emailDesktop:!1,emailMobile:!1,textDesktop:!1,textMobile:!1,sstDesktop:!1,sstMobile:!1,calcDesktop:!1,calcMobile:!1},this.webchatConfigHasAutoOpenChat=!1,this.requiresConsent=!1,this.hideMobileFeatures=!1,this.privacyPolicyUrl="http://bit.ly/me_privacy_policy",this.launcherRef=Ee(),this.firstUpdated=async()=>this.setupWebchat(),this.setupWebchat=async()=>{if(!this.orgSlug)return;if(!this.centralConvo&&!this.buildingSlug)return;const e=this.centralConvo?await async function(e){const t=`https://app.meetelise.com/api/pub/v1/organization/${e}/webchat/v2`,n=await r().get(t);return Jo(n.data)}(this.orgSlug):await Zo(this.orgSlug,this.buildingSlug);if(Math.random()<.2)try{(async(e,t)=>{const n=window.rentgrata;if(!n)return;const i=n.Widget;if(!i)return;const o=i.config;if(!o)return;const a=o.widgetKey;a&&await r().post(`https://app.meetelise.com/platformApi/webchat/rentgrata?token=${a}`,{},{headers:{"Content-Type":"application/json","building-slug":null!=e?e:"","org-slug":null!=t?t:""}})})(this.buildingSlug,this.orgSlug)}catch(e){}try{oc(this.orgSlug,this.buildingSlug)}catch(e){}await za(e,this.buildingSlug,this.orgSlug)&&(Ho({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_pixel_on_site:!0,is_any_webchat_showing:!0},sampleRate:(null==e?void 0:e.launchedDateTime)?.01:.05}),this.buildingWebchatView=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))},this.setBuildingDerivedInfo=async()=>{var e,t,n,i,o,a,s,l,u,d,c,h,p,f,g,m,y,b,v,w,C,x,$,S,A,E,T,k,_,O,P,I,N,M,D,L,U,R,B,j,F,H,G,z,Q,W,V,q,Y;const K=this.buildingWebchatView;if(!K)return;K&&this.orgSlug&&bc(this.orgSlug,null!==(t=null===(e=this.LeadSourceClient)||void 0===e?void 0:e.chatId)&&void 0!==t?t:null,this.sampleRateToUse,this.buildingSlug,null!==(i=null===(n=this.LeadSourceClient)||void 0===n?void 0:n.leadSource)&&void 0!==i?i:null);const X=K.featureFlagWebchatMarketingSourceDropdownConfiguration,Z=K.featureFlagWebchatUseDniPhoneNumberBySource,J=K.featureFlagInsertDniIntoWebsite,ee=K.featureFlagWebchatReplaceAnyScheduleTourCtaWebsite;var te;te=vo.includes(K.orgId),Co=te;const[ne,ie,re,oe]=await Promise.all([su(this.orgSlug,this.buildingSlug),go(this.buildingSlug),uu(this.buildingSlug),mo(this.buildingSlug)]);this.buildingWebchatView&&(this.buildingWebchatView.phoneNumber=Gn(K.phoneNumber),this.buildingWebchatView.isAip=re),this.leadSources=ne,this.featureFlagShowDropdown=X,this.bedroomPreferenceRequired=oe;const ae=K.textWithUsPhoneNumber?K.textWithUsPhoneNumber:await(async e=>{try{const t="https://app.meetelise.com",n=await r().get(`${t}/platformApi/webchat/${e}/phone-number`);if(n.data)return n.data}catch(t){return Fo({logType:jo.error,buildingSlug:e,logTitle:"[ERROR_GETTING_PHONE_NUMBERS]",logData:{error:t},error:t}),null}return null})(this.buildingSlug),se=null!==(a=null===(o=this.buildingWebchatView)||void 0===o?void 0:o.shouldShowPricingCalculatorDesktop)&&void 0!==a&&a,le=null!==(l=null===(s=this.buildingWebchatView)||void 0===s?void 0:s.shouldShowPricingCalculatorMobile)&&void 0!==l&&l,ue={callDesktop:null!==(d=null===(u=this.buildingWebchatView)||void 0===u?void 0:u.shouldShowPhoneDesktop)&&void 0!==d&&d,callMobile:null!==(h=null===(c=this.buildingWebchatView)||void 0===c?void 0:c.shouldShowPhoneMobile)&&void 0!==h&&h,chatDesktop:null!==(f=null===(p=this.buildingWebchatView)||void 0===p?void 0:p.shouldShowChatDesktop)&&void 0!==f&&f,chatMobile:null!==(m=null===(g=this.buildingWebchatView)||void 0===g?void 0:g.shouldShowChatMobile)&&void 0!==m&&m,emailDesktop:null!==(b=null===(y=this.buildingWebchatView)||void 0===y?void 0:y.shouldShowEmailDesktop)&&void 0!==b&&b,emailMobile:null!==(w=null===(v=this.buildingWebchatView)||void 0===v?void 0:v.shouldShowEmailMobile)&&void 0!==w&&w,textDesktop:null!==(x=(null===(C=this.buildingWebchatView)||void 0===C?void 0:C.shouldShowTextDesktop)&&!!ae)&&void 0!==x&&x,textMobile:null!==(S=(null===($=this.buildingWebchatView)||void 0===$?void 0:$.shouldShowTextMobile)&&!!ae)&&void 0!==S&&S,sstDesktop:null!==(E=null===(A=this.buildingWebchatView)||void 0===A?void 0:A.shouldShowSstDesktop)&&void 0!==E&&E,sstMobile:null!==(k=null===(T=this.buildingWebchatView)||void 0===T?void 0:T.shouldShowSstMobile)&&void 0!==k&&k,calcDesktop:se,calcMobile:le};var de,ce;this.enabledChatWidgets=Wl(ue),this.enabledChatWidgets.sstDesktop||this.enabledChatWidgets.sstMobile||"radco"===this.orgSlug?(ce=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(),ce(e)})}),ee&&(e=>{document.querySelectorAll('a[href$="schedule-a-tour"]').forEach(t=>{t&&t.addEventListener("click",t=>{t.preventDefault(),e(t)})})})(this.handleTourClicked),"radco"===this.orgSlug&&(e=>{document.querySelectorAll('a[href^="#leaseleads-tour-open"]').forEach(t=>{var n;if(!t)return;const i=document.createElement("a");i.textContent=t.textContent,i.style.cursor="pointer",i.addEventListener("click",t=>{t.preventDefault(),e(t)}),null===(n=t.parentNode)||void 0===n||n.replaceChild(i,t)})})(this.handleTourClicked)):(null===(_=this.LeadSourceClient)||void 0===_?void 0:_.leadSource)&&(de=null!==(P=null===(O=this.LeadSourceClient)||void 0===O?void 0:O.leadSource)&&void 0!==P?P: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(de)}`)}})),this.buildingWebchatView&&(this.primaryColor=null!==(I=this.buildingWebchatView.primaryColor)&&void 0!==I?I:null,this.backgroundColor=null!==(N=this.buildingWebchatView.secondaryColor)&&void 0!==N?N:null,this.foregroundColorOnPrimaryBackgroundColor=null!==(M=this.buildingWebchatView.foregroundColorOnPrimaryBackgroundColor)&&void 0!==M?M:null,this.foregroundColorOnSecondaryBackgroundColor=null!==(D=this.buildingWebchatView.foregroundColorOnSecondaryBackgroundColor)&&void 0!==D?D:null,this.webchatConfigHasAutoOpenChat=null!==(L=this.buildingWebchatView.autoOpenChat)&&void 0!==L&&L,this.requiresConsent=null!==(U=this.buildingWebchatView.requiresConsentForChat)&&void 0!==U&&U,this.hideMobileFeatures=null!==(R=this.buildingWebchatView.collapseMobileFeatures)&&void 0!==R&&R,this.privacyPolicyUrl=null!==(B=this.buildingWebchatView.privacyPolicyUrlForChat)&&void 0!==B?B:this.privacyPolicyUrl,this.buildingWebchatView.displayStyle===qo.MINIMIZED&&(this.isMinimized=!0),this.buildingWebchatView.displayStyle===qo.PILLS&&(this.designConcept=null),this.buildingWebchatView.displayStyle===qo.EMOJI&&(this.designConcept=qo.EMOJI),this.onWidgetLoaded()),null===this.primaryColor&&(this.primaryColor=qn),null===this.backgroundColor&&(this.backgroundColor=Yn);const he=null!==(F=null===(j=this.buildingWebchatView)||void 0===j?void 0:j.phoneNumber)&&void 0!==F?F:"";let pe=null;if(Z&&(pe=await async function(e,t){try{const n=await r().get(`https://app.meetelise.com/platformApi/webchat/${e}/phone-number-by-source`,{params:{source:t}});return n.data?{number:Gn(n.data.number),isMatch:n.data.match,isPropertyWebsiteCatchall:n.data.isPropertyWebsiteCatchall}:null}catch(e){return null}}(this.buildingSlug,null!==(G=null===(H=this.LeadSourceClient)||void 0===H?void 0:H.leadSource)&&void 0!==G?G:null),pe&&!pe.isMatch&&(pe.number=he)),J&&(null==pe?void 0:pe.number)){const e=Iu(pe.number,this.orgSlug,this.buildingSlug);e>0&&Ho({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_dni_insert_override_success:!0,extra_data:{total_replacements:e}},sampleRate:this.sampleRateToUse})}const fe=localStorage.getItem("eliseai_phone_number_devtest");fe&&Iu(fe,this.orgSlug,this.buildingSlug),this.phoneNumberForSource=pe||{number:he,isMatch:!1,isPropertyWebsiteCatchall:!0};const ge=null!==(Q=null===(z=this.LeadSourceClient)||void 0===z?void 0:z.leadSource)&&void 0!==Q?Q:null;ge&&(this.leadSources.includes(ge)||this.leadSources.push(ge)),io(K.id);if((ie||(null===(W=this.buildingWebchatView)||void 0===W?void 0:W.isAip))&&(null===(V=this.buildingWebchatView)||void 0===V?void 0:V.isLiveOnApplications)&&this.buildingSlug){const e=((e,t,n)=>{var i;const r=[/thehavenatgreenhill\.securecafe\.com\/onlineleasing\/the-haven-at-greenhill\/oleapplication\.aspx(\?.*)?$/,/securecafe\.com\/onlineleasing.*\/oleapplication\.aspx(\?.*)?$/,/\/onlineleasing.*\/oleapplication\.aspx(\?.*)?$/,/\/content\/apply/,/\/apply-now/,/\/apply/,/vsc\.myresman\.com\/Portal\/Applicants\/Availability(\?.*)?$/,/vsc\.myresman\.com\/Portal\/Applicants\/New\/.*(\?.*)?$/,/busboomgroup\.myresman\.com\/Portal\/Applicants\/Availability(\?.*)?$/],o=document.body.getElementsByTagName("a");let a=0;for(let s=0;s<o.length;s++){const l=o[s];if(l.nodeType===Node.ELEMENT_NODE&&r.some(e=>e.test(l.href))){const r=l.getAttribute("href"),o=(null===(i=l.textContent)||void 0===i?void 0:i.toLowerCase())||"",s=ac(o,e);l.setAttribute("href",s),a++,Fo({logTitle:"SELECT_BUTTON_LINK_REPLACEMENT",logData:{type:"link-replacement",oldHref:r,newHref:s,website:window.location.href},logType:jo.info,buildingSlug:n,orgSlug:t})}}return 0===a&&Fo({logTitle:"SELECT_BUTTON_LINK_REPLACEMENT",logData:{type:"no-select-buttons-found",website:window.location.href},logType:jo.warn,buildingSlug:n,orgSlug:t}),a})(`https://applications.eliseai.com/building/${this.buildingSlug}/units`,this.orgSlug,this.buildingSlug);e>0&&Ho({params:{org_slug:this.orgSlug,building_slug:this.buildingSlug,is_application_link_replacement_success:!0,extra_data:{total_replacements:e}},sampleRate:this.sampleRateToUse})}if(this.buildingSlug&&this.orgSlug)try{(e=>{const t=sc[e];if(!t)return 0;const n=`${lc}/building/${t}/units`,i=`${lc}/building/${e}/units`,r=new RegExp(`https://applications\\.eliseai\\.com/building/${t}/units`,"g");let o=0;const a=document.body.getElementsByTagName("a");for(let e=0;e<a.length;e++){const t=a[e],s=t.getAttribute("href");if(!s||!s.includes(n))continue;const l=s.replace(r,i);l!==s&&(t.setAttribute("href",l),o++)}document.body.querySelectorAll("[onclick]").forEach(e=>{const t=e.getAttribute("onclick");if(!t||!t.includes(n))return;const a=t.replace(r,i);a!==t&&(e.setAttribute("onclick",a),o++)})})(this.buildingSlug)}catch{}this.buildingSlug&&(null===(q=this.buildingWebchatView)||void 0===q?void 0:q.isLiveOnApplications)&&(null===(Y=this.buildingWebchatView)||void 0===Y?void 0:Y.applicationLink)&&"c954426c-12ab-4f8e-8384-8218e79eaf72"===this.orgSlug&&hc(this.orgSlug,this.buildingSlug,this.buildingWebchatView.applicationLink)},this.initializeChatVariables=async()=>{var e,t,n,i,r,o,a,s,l,u;if(!this.buildingWebchatView)return;const d=$u(this.buildingSlug),c=Su(this.buildingSlug,d),h=c?d:xu(this.buildingSlug,!1);if(!h.leadId)throw new Error("Lead ID is null");this.LeadSourceClient=new Wo,this.LeadSourceClient.orgId=null!==(t=null===(e=this.buildingWebchatView)||void 0===e?void 0:e.orgId)&&void 0!==t?t:0,this.LeadSourceMultitouchClient=new pc(this.orgSlug,this.buildingSlug),this.myPubnub=new _u(this.buildingSlug,this.buildingWebchatView,this.orgSlug,null,h.leadId,this.LeadSourceMultitouchClient,this.LeadSourceClient,this.widgetType);const p=await this.myPubnub.initSession(this.buildingSlug,this.orgSlug,c&&null!==(n=h.leadId)&&void 0!==n?n:void 0);p&&xu(this.buildingSlug,h.initiatedChat,p.lead_id),this.LeadSourceClient.chatId=this.myPubnub.channel;const f=await(null===(i=this.LeadSourceClient)||void 0===i?void 0:i.generateUserLeadSource({leadId:null!==(o=null===(r=this.myPubnub)||void 0===r?void 0:r.leadUserId)&&void 0!==o?o:"",orgSlug:this.orgSlug,buildingSlug:this.buildingSlug}));f&&this.LeadSourceMultitouchClient.addSafeLeadSourceTouchpoint(f),"property-website"!==Qo(this.orgSlug)?this.myPubnub.leadSource=null!==(s=null===(a=this.LeadSourceClient)||void 0===a?void 0:a.leadSource)&&void 0!==s?s:Qo(this.orgSlug):this.myPubnub.leadSource=null!==(u=null===(l=this.LeadSourceClient)||void 0===l?void 0:l.leadSource)&&void 0!==u?u:null;const g=$u(this.buildingSlug);g.initiatedChat&&await this.myPubnub.initializePubnub(g)},this.shouldAutoOpenChat=e=>{const t=sessionStorage.getItem("alreadyAutoOpenedTimestamp"),n=!t||!(t&&!Gr(Wr(t)));return!!e&&!!n&&!_r()},this.updateAlreadyAutoOpenedTimestamp=()=>{sessionStorage.setItem("alreadyAutoOpenedTimestamp",Rr(function(e,t){return ni(2,arguments),vi(e,6e4*bi(t))}(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;if("Tab"!==e.key)return;const u=null===(n=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("meetelise-launcher"))||void 0===n?void 0:n.shadowRoot;let d=[];if(this.displayPubnubChat){const e=null===(o=null===(r=null===(i=this.shadowRoot)||void 0===i?void 0:i.getElementById("pubnub-chat"))||void 0===r?void 0:r.shadowRoot)||void 0===o?void 0:o.getElementById("pubnub-chat-container"),t=null===(a=this.shadowRoot)||void 0===a?void 0:a.getElementById("chatAdditionalActionsPubnub");e&&d.push(...this.collectFocusableElements(e)),t&&d.push(...this.collectFocusableElements(t))}else{const e=null!==(l=null!==(s=null==u?void 0:u.getElementById("email-us-window"))&&void 0!==s?s:null==u?void 0:u.getElementById("tour-scheduler-window"))&&void 0!==l?l:null==u?void 0:u.getElementById("call-us-window");e&&(d=this.collectFocusableElements(e))}if(0===d.length)return;e.preventDefault();const c=this.getDeepActiveElement(),h=d.findIndex(e=>e===c);d[e.shiftKey?(h-1+d.length)%d.length:(h+1)%d.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")}}async handleChatInitializeAnalytics(){var e,t,n,i;this.analytics=new Ro(this.orgSlug,this.buildingSlug,null!==(t=null===(e=this.myPubnub)||void 0===e?void 0:e.channel)&&void 0!==t?t:"",null!==(i=null===(n=this.LeadSourceClient)||void 0===n?void 0:n.leadSource)&&void 0!==i?i:null),Math.random()<.05&&this.analytics.ping("webchat_heartbeat")}async restartConversation(){var e;null===(e=this.myPubnub)||void 0===e||e.handleDisconnect(),Cu(this.buildingSlug),this.myPubnub=null,this.displayPubnubChat=!1,await this.setupWebchat(),this.hideLauncher=!1}show(){this.launcher&&(this.launcher.style.display="")}hide(){this.launcher&&(this.launcher.style.display="none")}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.adjustPositionChatAdditionalActions),window.addEventListener("keydown",this.handleKeydownTab),this._cleanupMobileListener=Or(e=>{this._isMobile=e})}static isFocusable(e){return!("disabled"in e)||!e.disabled}collectFocusableElements(e){const t=[];e instanceof Element&&e.shadowRoot&&t.push(...this.collectFocusableElements(e.shadowRoot));const n=e.querySelectorAll("*");for(const e of Array.from(n))e.matches(fc.FOCUSABLE_SELECTOR)&&fc.isFocusable(e)&&t.push(e),e.shadowRoot&&t.push(...this.collectFocusableElements(e.shadowRoot));return t}getDeepActiveElement(){let e=document.activeElement,t=0;for(;(null==e?void 0:e.shadowRoot)&&(null==e?void 0:e.shadowRoot.activeElement);)if(t+=1,e=null==e?void 0:e.shadowRoot.activeElement,t>100){Fo({logType:jo.error,buildingSlug:this.buildingSlug,logTitle:"[ERROR_GETTING_DEEP_ELEMENT]",logData:{message:"error getting deep active element"}});break}return e}updated(){this.adjustPositionChatAdditionalActions()}disconnectedCallback(){var e,t;null===(e=this.myPubnub)||void 0===e||e.handleDisconnect(),window.removeEventListener("resize",this.adjustPositionChatAdditionalActions),window.removeEventListener("keydown",this.handleKeydownTab),null===(t=this._cleanupMobileListener)||void 0===t||t.call(this),super.disconnectedCallback()}render(){var e,t,n,i,r,o,a,s,l,u,d,c,h,p,f,g,m,y,b,v,w,C,x,$,S,A,E,T,k,_,O,P,I,N,M,D,L,U,B,j,F,H,G,z,Q;Gl();const W=this.hideLauncher&&!this.isLoading&&!this._isMobile;return R`
|
|
7208
7211
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
7209
7212
|
${this.displayPubnubChat?R`
|
|
7210
7213
|
<pubnub-chat
|
|
@@ -7213,7 +7216,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
7213
7216
|
.myPubnub=${this.myPubnub}
|
|
7214
7217
|
.orgSlug=${this.orgSlug}
|
|
7215
7218
|
.buildingSlug=${this.buildingSlug}
|
|
7216
|
-
.widgetType=${
|
|
7219
|
+
.widgetType=${Pc.Default}
|
|
7217
7220
|
.building=${this.buildingWebchatView}
|
|
7218
7221
|
.primaryColor=${this.primaryColor}
|
|
7219
7222
|
.backgroundColor=${this.backgroundColor}
|
|
@@ -7318,7 +7321,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
7318
7321
|
</meetelise-launcher>`:""}
|
|
7319
7322
|
</div>
|
|
7320
7323
|
</meta>
|
|
7321
|
-
`}};
|
|
7324
|
+
`}};mc.styles=u`
|
|
7322
7325
|
:host {
|
|
7323
7326
|
all: initial;
|
|
7324
7327
|
}
|
|
@@ -7367,7 +7370,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
7367
7370
|
position: fixed;
|
|
7368
7371
|
bottom: 0;
|
|
7369
7372
|
}
|
|
7370
|
-
`,
|
|
7373
|
+
`,mc.FOCUSABLE_SELECTOR="a[href]:not([tabindex='-1']), input:not([disabled]), button:not([disabled]), textarea, [tabindex]:not([tabindex='-1'])",gc([ue({type:String})],mc.prototype,"buildingSlug",void 0),gc([ue({type:String})],mc.prototype,"orgSlug",void 0),gc([ue({type:Boolean})],mc.prototype,"centralConvo",void 0),gc([ue({type:Object})],mc.prototype,"launcherStyles",void 0),gc([ue()],mc.prototype,"mobileStyles",void 0),gc([ue({type:Boolean})],mc.prototype,"isMinimized",void 0),gc([ue({type:String})],mc.prototype,"primaryColor",void 0),gc([ue({type:String})],mc.prototype,"backgroundColor",void 0),gc([ue({type:String})],mc.prototype,"foregroundColorOnPrimaryBackgroundColor",void 0),gc([ue({type:String})],mc.prototype,"foregroundColorOnSecondaryBackgroundColor",void 0),gc([de()],mc.prototype,"_isMobile",void 0),gc([de()],mc.prototype,"chatId",void 0),gc([de()],mc.prototype,"analytics",void 0),gc([de()],mc.prototype,"launcher",void 0),gc([de()],mc.prototype,"buildingWebchatView",void 0),gc([de()],mc.prototype,"designConcept",void 0),gc([de()],mc.prototype,"leadSources",void 0),gc([de()],mc.prototype,"currentLeadSource",void 0),gc([de()],mc.prototype,"featureFlagShowDropdown",void 0),gc([de()],mc.prototype,"bedroomPreferenceRequired",void 0),gc([de()],mc.prototype,"phoneNumberForSource",void 0),gc([de()],mc.prototype,"hasMounted",void 0),gc([de()],mc.prototype,"hideLauncher",void 0),gc([de()],mc.prototype,"isLoading",void 0),gc([de()],mc.prototype,"showTourNextToChat",void 0),gc([de()],mc.prototype,"displayPubnubChat",void 0),gc([de()],mc.prototype,"myPubnub",void 0),gc([de()],mc.prototype,"LeadSourceClient",void 0),gc([de()],mc.prototype,"LeadSourceMultitouchClient",void 0),gc([de()],mc.prototype,"sampleRateToUse",void 0),gc([ue({type:Number})],mc.prototype,"right",void 0),gc([ue({type:Number})],mc.prototype,"bottom",void 0),gc([ue({type:Number})],mc.prototype,"top",void 0),gc([ue({type:Number})],mc.prototype,"left",void 0),gc([ue({attribute:!0})],mc.prototype,"overrideRentgrata",void 0),gc([ue({attribute:!0})],mc.prototype,"widgetType",void 0),gc([ue()],mc.prototype,"onWidgetLoaded",void 0),gc([ue({attribute:!0})],mc.prototype,"onSstClose",void 0),gc([de()],mc.prototype,"enabledChatWidgets",void 0),gc([de()],mc.prototype,"webchatConfigHasAutoOpenChat",void 0),gc([de()],mc.prototype,"requiresConsent",void 0),gc([de()],mc.prototype,"hideMobileFeatures",void 0),gc([de()],mc.prototype,"privacyPolicyUrl",void 0),mc=fc=gc([se("me-chat")],mc);const yc=e=>{for(const t of e){const e=document.getElementById(t);if(e)return e}return null},bc=async(e,t,n,i,o)=>{var a;if(!i||!e)return;const s=await async function(e){if(!e)return!1;try{return(await r().get(po(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}}(i);if(!s)return;const l=yc(["myContactForm","contactus","fpa-myContactForm"]);let u;if(!(l&&l instanceof HTMLFormElement)){const t=document.querySelector("form");return void(window.location.pathname.toLowerCase().includes("contactus")&&vc(i,e,"Could not find form",t?{id:t.id}:void 0))}try{if(l.parentElement&&"scheduleTourForm"===l.parentElement.id)return vc(i,e,"Form is apart of schedule tour form!")}catch(e){}for(let e=0;e<l.elements.length;e++){const t=l.elements[e];if("button"===t.tagName.toLowerCase()&&"fakebutton"===t.getAttribute("data-selenium-id")){u=t;break}if("fpa-contact-submit"===t.getAttribute("id")){u=t;break}}if(!u)return vc(i,e,"Could not find submit button");const d=()=>({firstName:yc(["firstname","txtName","fpa-firstname","Form_FirstName"]),lastName:yc(["lastname","txtName2","fpa-lastname","Form_LastName"]),email:yc(["email","txtEmail","fpa-email","Form_Email"]),phone:yc(["phonenumber","txtPhone","fpa-phonenumber","Form_Phone"]),message:yc(["message","txtComments","fpa-email","Form_Message"])});if(Object.values(d()).some(e=>null===e)){const t=Object.entries(d()).filter(([,e])=>null===e).map(([e])=>e);return vc(i,e,"Missing the following form elements: "+t.join(", "))}const c=u.textContent,h=u.cloneNode(!0);null===(a=u.parentNode)||void 0===a||a.replaceChild(h,u),h&&Ho({params:{chat_id:t,org_slug:e,building_slug:i,is_form_override_success:!0},sampleRate:n}),h.onclick=async function(t){if(Object.values(d()).forEach(e=>{"true"!==(null==e?void 0:e.getAttribute("aria-required"))||e.value||(e.className="form-control required is-invalid")}),!Object.values(d()).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(),h.textContent="Processing request...",h.disabled=!0;const n={};Object.entries(d()).forEach(([e,t])=>n[e]=null==t?void 0:t.value);const r=await Zo(e,i);if(!r)return vc(i,e,"Could not find building"),null;const a={email_address:n.email,first_name:n.firstName,last_name:n.lastName,phone_number:n.phone,first_message:n.message,building_id:r.id,is_external_form:!0,lead_sources:[...new Set(o?[o,Qo(e)]:[Qo(e)])]},s=JSON.stringify(a);fetch("https://app.meetelise.com/platformApi/state/create/contactMe",{method:"POST",headers:{"Content-Type":"application/json","building-slug":i,"org-slug":e},body:s}).then(e=>{if(!e.ok)throw new Error(`HTTP error ${e.status}`);return l&&l.reset(),Object.values(d()).forEach(e=>{e&&(e.disabled=!0)}),h.textContent="Submitted",h.disabled=!0,e.json()}).catch(()=>{h.textContent=c})}},vc=(e,t,n,i)=>{const r=JSON.stringify({orgSlug:t,buildingSlug:e,reason:n,url:window.location.href,formIdInfo:i});fetch("https://app.meetelise.com/platformApi/webchat/form-override-error",{method:"POST",headers:{"Content-Type":"application/json","building-slug":e,"org-slug":t},body:r})},wc=u`
|
|
7371
7374
|
.chat-launcher {
|
|
7372
7375
|
position: fixed;
|
|
7373
7376
|
}
|
|
@@ -7398,7 +7401,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
7398
7401
|
filter: brightness(1.1);
|
|
7399
7402
|
}
|
|
7400
7403
|
}
|
|
7401
|
-
`;var
|
|
7404
|
+
`;var Cc=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 xc=class extends oe{constructor(){super(...arguments),this.right=0,this.bottom=0,this.top=0,this.left=0,this.isChatOpen=!1,this.onClickCloseChat=()=>({}),this.onClickOpenChat=()=>({})}render(){return this.isChatOpen?R`
|
|
7402
7405
|
<div
|
|
7403
7406
|
class="chat-launcher"
|
|
7404
7407
|
style=${Vn({top:_r()||isNaN(this.top)?void 0:`${this.top+432}px`,bottom:_r()||isNaN(this.bottom)?"72px":this.bottom-60+"px",left:_r()||isNaN(this.left)?void 0:`${this.left}px`,right:_r()||isNaN(this.right)?"18px":`${this.right}px`})}
|
|
@@ -7452,12 +7455,12 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
7452
7455
|
/>
|
|
7453
7456
|
</svg>
|
|
7454
7457
|
</button>
|
|
7455
|
-
</div>`}};
|
|
7458
|
+
</div>`}};xc.styles=[wc],Cc([ue({type:Number})],xc.prototype,"right",void 0),Cc([ue({type:Number})],xc.prototype,"bottom",void 0),Cc([ue({type:Number})],xc.prototype,"top",void 0),Cc([ue({type:Number})],xc.prototype,"left",void 0),Cc([ue({attribute:!0})],xc.prototype,"isChatOpen",void 0),Cc([ue({attribute:!0})],xc.prototype,"onClickCloseChat",void 0),Cc([ue({attribute:!0})],xc.prototype,"onClickOpenChat",void 0),xc=Cc([se("simple-launcher")],xc);var $c=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 Sc=class extends oe{constructor(){super(...arguments),this.healthcareId="",this.right=0,this.bottom=0,this.top=0,this.left=0,this.launcher=null,this.currentLeadSource=null,this.displayPubnubChat=!1,this.myPubnub=null,this.requiresConsent=!1,this.privacyPolicyUrl="http://bit.ly/me_privacy_policy",this.isLoading=!0,this.launcherRef=Ee(),this.firstUpdated=async()=>{await this.initializeChatVariables()},this.initializeChatVariables=async()=>{this.isLoading=!0;const e=$u(this.healthcareId),t=Su(this.healthcareId,e)?e:xu(this.healthcareId,!1);if(!t.leadId)throw new Error("Lead ID is null");this.myPubnub=new _u(this.healthcareId,null,"",this.currentLeadSource,t.leadId,null,null,Pc.Healthcare),t.initiatedChat&&await this.myPubnub.initializePubnub(e),_r()||(this.displayPubnubChat=!0),this.attachOnClickToLauncher(),this.isLoading=!1},this.attachOnClickToLauncher=()=>{const e=this.launcherRef.value;e&&(e.onChatTapped=async()=>{this.displayPubnubChat=!0})}}async restartConversation(){var e;null===(e=this.myPubnub)||void 0===e||e.handleDisconnect(),Cu(this.healthcareId),this.myPubnub=null,this.displayPubnubChat=!1,await this.initializeChatVariables()}show(){this.launcher&&(this.launcher.style.display="")}hide(){this.launcher&&(this.launcher.style.display="none")}disconnectedCallback(){var e;null===(e=this.myPubnub)||void 0===e||e.handleDisconnect(),super.disconnectedCallback()}render(){var e;return Gl(),this.isLoading?R``:R`
|
|
7456
7459
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
|
7457
7460
|
${this.displayPubnubChat?R`
|
|
7458
7461
|
<pubnub-chat
|
|
7459
7462
|
id="pubnub-chat"
|
|
7460
|
-
.widgetType=${
|
|
7463
|
+
.widgetType=${Pc.Healthcare}
|
|
7461
7464
|
.channel=${null===(e=this.myPubnub)||void 0===e?void 0:e.channel}
|
|
7462
7465
|
.myPubnub=${this.myPubnub}
|
|
7463
7466
|
.buildingSlug=${this.healthcareId}
|
|
@@ -7483,7 +7486,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
7483
7486
|
></simple-launcher>
|
|
7484
7487
|
|
|
7485
7488
|
</meta>
|
|
7486
|
-
`}}
|
|
7489
|
+
`}};Sc.styles=u`
|
|
7487
7490
|
:host {
|
|
7488
7491
|
all: initial;
|
|
7489
7492
|
}
|
|
@@ -7536,13 +7539,13 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
7536
7539
|
line-height: 150%;
|
|
7537
7540
|
font-size: 16px;
|
|
7538
7541
|
}
|
|
7539
|
-
|
|
7542
|
+
`,$c([ue({type:String})],Sc.prototype,"healthcareId",void 0),$c([ue({type:Number})],Sc.prototype,"right",void 0),$c([ue({type:Number})],Sc.prototype,"bottom",void 0),$c([ue({type:Number})],Sc.prototype,"top",void 0),$c([ue({type:Number})],Sc.prototype,"left",void 0),$c([de()],Sc.prototype,"launcher",void 0),$c([de()],Sc.prototype,"currentLeadSource",void 0),$c([de()],Sc.prototype,"displayPubnubChat",void 0),$c([de()],Sc.prototype,"myPubnub",void 0),$c([de()],Sc.prototype,"requiresConsent",void 0),$c([de()],Sc.prototype,"privacyPolicyUrl",void 0),$c([de()],Sc.prototype,"isLoading",void 0),Sc=$c([se("health-chat")],Sc);var Ac=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 Ec=class extends oe{constructor(){super(...arguments),this.orgSlug="",this.right=void 0,this.bottom=void 0,this.top=void 0,this.left=void 0,this.launcher=null,this.currentLeadSource=null,this.displayPubnubChat=!1,this.myPubnub=null,this.requiresConsent=!1,this.privacyPolicyUrl="http://bit.ly/me_privacy_policy",this.isLoading=!0,this.launcherRef=Ee(),this.firstUpdated=async()=>{(await async function(e){if(!e)return!1;const t="e2e-test-yardi-building";try{return(await r().get(po(t),{params:{building_slug:t,flag_type:"bool",feature_flag:"enable-show-utilities-webchat",default_str:null,default_bool:!1}})).data}catch(e){return!1}}(this.orgSlug)||location.href.includes("demo/utilities"))&&await this.initializeChatVariables()},this.initializeChatVariables=async()=>{this.isLoading=!0;const e=$u(this.orgSlug),t=Su(this.orgSlug,e)?e:xu(this.orgSlug,!1);if(!t.leadId)throw new Error("Lead ID is null");this.myPubnub=new _u(this.orgSlug,null,this.orgSlug,this.currentLeadSource,t.leadId,null,null,Pc.Utilities),t.initiatedChat&&await this.myPubnub.initializePubnub(e),_r()||(this.displayPubnubChat=!0),this.attachOnClickToLauncher(),this.isLoading=!1},this.attachOnClickToLauncher=()=>{const e=this.launcherRef.value;e&&(e.onChatTapped=async()=>{this.displayPubnubChat=!0})}}async restartConversation(){var e;null===(e=this.myPubnub)||void 0===e||e.handleDisconnect(),Cu(this.orgSlug),this.myPubnub=null,this.displayPubnubChat=!1,await this.initializeChatVariables()}show(){this.launcher&&(this.launcher.style.display="")}hide(){this.launcher&&(this.launcher.style.display="none")}disconnectedCallback(){var e;null===(e=this.myPubnub)||void 0===e||e.handleDisconnect(),super.disconnectedCallback()}render(){var e;return Gl(),this.isLoading?R``:R`
|
|
7540
7543
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
|
7541
7544
|
${this.displayPubnubChat?R`
|
|
7542
7545
|
<pubnub-chat
|
|
7543
7546
|
id="pubnub-chat"
|
|
7544
7547
|
.channel=${null===(e=this.myPubnub)||void 0===e?void 0:e.channel}
|
|
7545
|
-
.widgetType=${
|
|
7548
|
+
.widgetType=${Pc.Utilities}
|
|
7546
7549
|
.myPubnub=${this.myPubnub}
|
|
7547
7550
|
.buildingSlug=${this.orgSlug}
|
|
7548
7551
|
.onClickExit=${()=>{this.displayPubnubChat=!1}}
|
|
@@ -7566,7 +7569,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
7566
7569
|
|
|
7567
7570
|
></simple-launcher>
|
|
7568
7571
|
</meta>
|
|
7569
|
-
`}};
|
|
7572
|
+
`}};Ec.styles=u`
|
|
7570
7573
|
:host {
|
|
7571
7574
|
all: initial;
|
|
7572
7575
|
}
|
|
@@ -7619,4 +7622,4 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
7619
7622
|
line-height: 150%;
|
|
7620
7623
|
font-size: 16px;
|
|
7621
7624
|
}
|
|
7622
|
-
`,
|
|
7625
|
+
`,Ac([ue({type:String})],Ec.prototype,"orgSlug",void 0),Ac([ue({type:Number})],Ec.prototype,"right",void 0),Ac([ue({type:Number})],Ec.prototype,"bottom",void 0),Ac([ue({type:Number})],Ec.prototype,"top",void 0),Ac([ue({type:Number})],Ec.prototype,"left",void 0),Ac([de()],Ec.prototype,"launcher",void 0),Ac([de()],Ec.prototype,"currentLeadSource",void 0),Ac([de()],Ec.prototype,"displayPubnubChat",void 0),Ac([de()],Ec.prototype,"myPubnub",void 0),Ac([de()],Ec.prototype,"requiresConsent",void 0),Ac([de()],Ec.prototype,"privacyPolicyUrl",void 0),Ac([de()],Ec.prototype,"isLoading",void 0),Ec=Ac([se("utilities-chat")],Ec);const Tc=async e=>{const t=window.location.href,n=`https://app.meetelise.com/platformApi/webchat/microsite_slug?uri=${encodeURIComponent(t)}`,i=await r().get(n,{headers:{"org-slug":e}});return Math.random()<.2&&Fo({logType:i&&i.data?jo.info:jo.warn,logTitle:`[BUILDING_SLUG_CALCULATED_${i?"SUCCESS":"FAILURE"}]`,logData:{calculatedBuildingSlug:i.data,url:t,orgSlug:e,givenBuildingSlug:null,reason:i&&i.data?null:"No match found"}}),i.data},kc=async(e,t=5e3)=>new Promise((n,i)=>{const r=new MutationObserver((t,i)=>{const r=document.getElementById(e);r&&(i.disconnect(),n(r))});r.observe(document.body,{childList:!0,subtree:!0});const o=setTimeout(()=>{r.disconnect(),i(new Error(`Element ${e} did not appear within ${t}ms`))},t),a=document.querySelector(e);a&&(clearTimeout(o),r.disconnect(),n(a))});class _c{static healthcareStart(e,t=!0){var n,i,r,o;t&&(this.healthcareId=e.id,this.overridePlacement={right:e.right,bottom:e.bottom,top:e.top,left:e.left}),Ic();const a=document.createElement("health-chat");a.setAttribute("class","health-chat"),a.setAttribute("role","region"),a.setAttribute("aria-label","EliseAI Healthcare Widget"),a.setAttribute("healthcareId",e.id),a.setAttribute("right",(null===(n=e.right)||void 0===n?void 0:n.toString())||"unset"),a.setAttribute("bottom",(null===(i=e.bottom)||void 0===i?void 0:i.toString())||"unset"),a.setAttribute("top",(null===(r=e.top)||void 0===r?void 0:r.toString())||"unset"),a.setAttribute("left",(null===(o=e.left)||void 0===o?void 0:o.toString())||"unset"),document.body.appendChild(a),_c.healthChat=a}static start(e,t=!0){var n,i,r,o,a,s,l,u;if(window.location.pathname.includes("residentservices")||window.location.pathname.includes("onlineleasing"))return;if(t&&(this.orgSlug="Pacific Urban Residential"===e.organization?"cbc11aba-21c4-4571-bc43-ff9d86a029e3":e.organization||"",this.hasBuildingSlug=!!e.building,this.overridePlacement={right:null===(n=null==e?void 0:e.position)||void 0===n?void 0:n.right,bottom:null===(i=null==e?void 0:e.position)||void 0===i?void 0:i.bottom,top:null===(r=null==e?void 0:e.position)||void 0===r?void 0:r.top,left:null===(o=null==e?void 0:e.position)||void 0===o?void 0:o.left}),Ic(),e.studio&&!e.building)return void this.handleStudioContext(e);let d=null;switch(e.widgetType){case Pc.Healthcare:throw new Error("Healthcare widget is not supported yet, please use the healthcareStart method instead.");case Pc.Default:d=document.createElement("me-chat");break;case Pc.Utilities:d=document.createElement("utilities-chat");break;default:d=document.createElement("me-chat")}if(!d)throw new Error("Invalid widget type");d.setAttribute("orgSlug","Pacific Urban Residential"===e.organization?"cbc11aba-21c4-4571-bc43-ff9d86a029e3":e.organization||""),d.setAttribute("widgetType",e.widgetType||Pc.Default),d.setAttribute("class","meetelise-chat"),d.setAttribute("role","region"),d.setAttribute("aria-label","EliseAI Widget"),e.brandColor&&(this.brandColor=e.brandColor,d.setAttribute("primaryColor",((e,t)=>{const n=Kn(e),i=0,r=0,o=0,a={r:n.r+Math.round((i-n.r)*t),g:n.g+Math.round((r-n.g)*t),b:n.b+Math.round((o-n.b)*t)};return Xn(a.r,a.g,a.b)})(e.brandColor,.3))),e.backgroundColor&&(this.backgroundColor=e.backgroundColor),d instanceof mc&&(e.centralConvo?d.setAttribute("centralConvo","true"):this.handleBuildingslug(d,e.organization,e.building,e),e.launcherStyles&&(d.launcherStyles=e.launcherStyles),e.mobileStyles&&(d.mobileStyles=e.mobileStyles),e.onWidgetLoaded&&(d.onWidgetLoaded=e.onWidgetLoaded),e.overrideRentgrata&&((async()=>{const e=await kc("rg-widget-compact");e&&e.setAttribute("style","display: none")})(),d.overrideRentgrata=!0),e.onSstClose&&(d.onSstClose=e.onSstClose)),e.position&&(d.setAttribute("right",(null===(a=e.position.right)||void 0===a?void 0:a.toString())||"unset"),d.setAttribute("bottom",(null===(s=e.position.bottom)||void 0===s?void 0:s.toString())||"unset"),d.setAttribute("top",(null===(l=e.position.top)||void 0===l?void 0:l.toString())||"unset"),d.setAttribute("left",(null===(u=e.position.left)||void 0===u?void 0:u.toString())||"unset")),window.eliseAi={},document.body.appendChild(d),d instanceof mc&&(_c.meChat=d),d instanceof Ec&&(_c.utilitiesChat=d)}static async restartConversation(){this.meChat&&await this.meChat.restartConversation()}static async remove(){this.studioUpdateToken+=1,await this.removeWidget(),this.activeStudioOrgSlug="",this.activeStudioBuildingSlug="",this.activeStudioSessionScopeKey="",this.activeStudioOptions=null}static async removeWidget(){var e;if(!this.meChat)return;const t=this.meChat;await t.remove(),null===(e=t.parentNode)||void 0===e||e.removeChild(t),_c.meChat=null}static handleStudioContext(e){e.studio&&(this.activeStudioOptions=e)}static updateStudioContext(e){const t=this.activeStudioOptions;if(!(null==t?void 0:t.studio))return;const n=++this.studioUpdateToken;if(e.siteId&&e.siteId!==t.studio.siteId)return void Fo({logType:jo.warn,logTitle:"[STUDIO_WEBCHAT_CONTEXT_SITE_MISMATCH]",logData:{activeSiteId:t.studio.siteId,contextSiteId:e.siteId,url:window.location.href}});const i=Oc(e.organization),r=Oc(e.building);if(!i||!r)return void this.clearStudioContext({source:"elise_studio",reason:"missing_context",preserveCache:!0});const o=function(e,t){if(!(null==e?void 0:e.key))return`building:${t}`;return e.key}(e.sessionScope,r),a=function(e){return"Pacific Urban Residential"===e?"cbc11aba-21c4-4571-bc43-ff9d86a029e3":e}(i);this.activeStudioOrgSlug===a&&this.activeStudioBuildingSlug===r&&this.activeStudioSessionScopeKey===o||this.removeWidget().then(()=>{n===this.studioUpdateToken&&(this.activeStudioOrgSlug=a,this.activeStudioBuildingSlug=r,this.activeStudioSessionScopeKey=o,this.orgSlug=a,this.start({...t,organization:i,building:r},!1))})}static clearStudioContext(e){this.studioUpdateToken+=1,this.activeStudioOrgSlug="",this.activeStudioBuildingSlug="",this.activeStudioSessionScopeKey="",this.removeWidget()}static async handleBuildingslug(e,t,n,i){if(n)return void e.setAttribute("buildingSlug",n);if(this.mutationObserver)return;if(!t)return;const r=await Tc(t);if(r){const e={...i,organization:t,building:r};this.start(e,!1)}this.previousUrl=window.location.href,document.body.addEventListener("click",()=>{requestAnimationFrame(()=>{this.previousUrl===window.location.href||this.hasBuildingSlug||(this.previousUrl=window.location.href,Tc(t).then(e=>{if(!e)return;const n={...i,organization:t,building:e};this.start(n,!1)}))})},!0)}static async handleSingleFamilyUrl(){if(this.hasBuildingSlug)return;this.remove();const e=window.location.href,t=`https://app.meetelise.com/platformApi/webchat/microsite_slug?uri=${encodeURIComponent(e)}`,n=await r().get(t,{headers:{"org-slug":this.orgSlug}});if(Math.random()<.2&&Fo({logType:n&&n.data?jo.info:jo.warn,logTitle:`[BUILDING_SLUG_CALCULATED_${n?"SUCCESS":"FAILURE"}]`,logData:{calculatedBuildingSlug:n.data,url:e,orgSlug:this.orgSlug,givenBuildingSlug:null,reason:n&&n.data?null:"No match found"}}),!n||!n.data)return;const i={organization:this.orgSlug,building:n.data,brandColor:this.brandColor,backgroundColor:this.backgroundColor};this.start(i,!1)}static async calculateBuildingSlugForLogging(e){const t=window.location.href,n=`https://app.meetelise.com/platformApi/webchat/microsite_slug?uri=${encodeURIComponent(t)}`,i=await r().get(n,{headers:{"org-slug":this.orgSlug}});Math.random()<.2&&Fo({logType:i&&i.data===e?jo.info:jo.warn,logTitle:`[BUILDING_SLUG_CALCULATED_${i&&i.data===e?"SUCCESS":"FAILURE"}]`,logData:{calculatedBuildingSlug:i.data,url:t,orgSlug:this.orgSlug,givenBuildingSlug:e,reason:i&&i.data===e?null:i&&!i.data?"No match found":i&&i.data!==e?"Mismatch":"No match found"}}),i&&i.data}}function Oc(e){return"string"!=typeof e?"":e.trim()}var Pc;_c.meChat=null,_c.healthChat=null,_c.utilitiesChat=null,_c.orgSlug="",_c.mutationObserver=null,_c.previousUrl="",_c.hasBuildingSlug=null,_c.brandColor="",_c.backgroundColor="",_c.healthcareId="",_c.activeStudioOrgSlug="",_c.activeStudioBuildingSlug="",_c.activeStudioSessionScopeKey="",_c.activeStudioOptions=null,_c.studioUpdateToken=0,_c.overridePlacement={},function(e){e.Default="default",e.Healthcare="healthcare",e.Utilities="utilities"}(Pc||(Pc={}));const Ic=()=>{const e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("type","text/css"),document.head.appendChild(e)};export{Pc as WidgetType,_c as default};
|
|
@@ -39,6 +39,8 @@ import { BuildingWebchatView } from "../fetchBuildingWebchatView";
|
|
|
39
39
|
|
|
40
40
|
@customElement("pubnub-chat")
|
|
41
41
|
export class PubnubChat extends LitElement {
|
|
42
|
+
private static readonly AUTO_SCROLL_THRESHOLD_PX = 32;
|
|
43
|
+
|
|
42
44
|
static styles = [
|
|
43
45
|
InputStyles,
|
|
44
46
|
pubnubChatStyles,
|
|
@@ -108,6 +110,8 @@ export class PubnubChat extends LitElement {
|
|
|
108
110
|
|
|
109
111
|
private _cleanupMobileListener?: () => void;
|
|
110
112
|
|
|
113
|
+
private shouldAutoScroll = true;
|
|
114
|
+
|
|
111
115
|
@state()
|
|
112
116
|
messages: SimpleChatMessage[] = [];
|
|
113
117
|
|
|
@@ -151,6 +155,7 @@ export class PubnubChat extends LitElement {
|
|
|
151
155
|
if (message.length === 0) {
|
|
152
156
|
return;
|
|
153
157
|
}
|
|
158
|
+
this.shouldAutoScroll = true;
|
|
154
159
|
this.messageInput.value = "";
|
|
155
160
|
this.autoResizeMessageInput();
|
|
156
161
|
|
|
@@ -199,12 +204,23 @@ export class PubnubChat extends LitElement {
|
|
|
199
204
|
}
|
|
200
205
|
|
|
201
206
|
scrollToChatBottom = (): void => {
|
|
207
|
+
if (!this.shouldAutoScroll) return;
|
|
202
208
|
this.messageBody.scrollTo({
|
|
203
209
|
top: this.messageBody.scrollHeight - this.messageBody.clientHeight,
|
|
204
|
-
behavior: "
|
|
210
|
+
behavior: "auto",
|
|
205
211
|
});
|
|
206
212
|
};
|
|
207
213
|
|
|
214
|
+
private handleConversationScroll = (event: Event): void => {
|
|
215
|
+
const messageBody = event.currentTarget as HTMLDivElement;
|
|
216
|
+
const distanceFromBottom =
|
|
217
|
+
messageBody.scrollHeight -
|
|
218
|
+
messageBody.clientHeight -
|
|
219
|
+
messageBody.scrollTop;
|
|
220
|
+
this.shouldAutoScroll =
|
|
221
|
+
distanceFromBottom <= PubnubChat.AUTO_SCROLL_THRESHOLD_PX;
|
|
222
|
+
};
|
|
223
|
+
|
|
208
224
|
async updated(): Promise<void> {
|
|
209
225
|
this.scrollToChatBottom();
|
|
210
226
|
try {
|
|
@@ -312,6 +328,7 @@ export class PubnubChat extends LitElement {
|
|
|
312
328
|
</div>
|
|
313
329
|
<div
|
|
314
330
|
id="conversation-body"
|
|
331
|
+
@scroll=${this.handleConversationScroll}
|
|
315
332
|
class=${classMap({
|
|
316
333
|
["hidden"]: this.needsConsent(),
|
|
317
334
|
["utilities-conversation-body-backdrop"]: true,
|
|
@@ -485,6 +502,7 @@ export class PubnubChat extends LitElement {
|
|
|
485
502
|
</div>
|
|
486
503
|
<div
|
|
487
504
|
id="conversation-body"
|
|
505
|
+
@scroll=${this.handleConversationScroll}
|
|
488
506
|
class=${classMap({
|
|
489
507
|
["hidden"]: this.needsConsent(),
|
|
490
508
|
["healthcare-conversation-body-backdrop"]: true,
|
|
@@ -667,6 +685,7 @@ export class PubnubChat extends LitElement {
|
|
|
667
685
|
</div>
|
|
668
686
|
<div
|
|
669
687
|
id="conversation-body"
|
|
688
|
+
@scroll=${this.handleConversationScroll}
|
|
670
689
|
style=${styleMap({
|
|
671
690
|
background:
|
|
672
691
|
this.building.orgId === 444
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { expect } from "@esm-bundle/chai";
|
|
2
|
+
import "../public/dist/index";
|
|
3
|
+
import { BuildingWebchatView } from "./fetchBuildingWebchatView";
|
|
4
|
+
import type { SimpleTextChatMessage } from "./MyPubnub";
|
|
5
|
+
import type { PubnubChat } from "./WebComponent/pubnub-chat";
|
|
6
|
+
|
|
7
|
+
declare const afterEach: (callback: () => void) => void;
|
|
8
|
+
declare const it: (name: string, callback: () => void | Promise<void>) => void;
|
|
9
|
+
|
|
10
|
+
interface ScrollMetrics {
|
|
11
|
+
clientHeight: number;
|
|
12
|
+
scrollHeight: number;
|
|
13
|
+
scrollTop: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const waitForRender = async (chat: PubnubChat): Promise<void> => {
|
|
17
|
+
await chat.updateComplete;
|
|
18
|
+
const messageUpdates = Array.from(
|
|
19
|
+
chat.shadowRoot?.querySelectorAll("pubnub-message") ?? []
|
|
20
|
+
).map(
|
|
21
|
+
(message) =>
|
|
22
|
+
(message as HTMLElement & { updateComplete: Promise<boolean> })
|
|
23
|
+
.updateComplete
|
|
24
|
+
);
|
|
25
|
+
await Promise.all(messageUpdates);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const streamingMessage = (chunks: string[]): SimpleTextChatMessage => ({
|
|
29
|
+
timestamp: 100,
|
|
30
|
+
message: chunks.join(""),
|
|
31
|
+
isLeadMessage: false,
|
|
32
|
+
chunks: chunks.map((text, order) => ({ text, order, isDone: false })),
|
|
33
|
+
type: "text" as SimpleTextChatMessage["type"],
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const completedMessage = (message: string): SimpleTextChatMessage => ({
|
|
37
|
+
timestamp: 100,
|
|
38
|
+
message,
|
|
39
|
+
isLeadMessage: false,
|
|
40
|
+
chunks: [{ text: message, order: 0, isDone: true }],
|
|
41
|
+
type: "text" as SimpleTextChatMessage["type"],
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const createScrollableChat = async (
|
|
45
|
+
initialMetrics: Partial<ScrollMetrics> = {}
|
|
46
|
+
): Promise<{
|
|
47
|
+
chat: PubnubChat;
|
|
48
|
+
messageBody: HTMLElement;
|
|
49
|
+
scrollCalls: ScrollToOptions[];
|
|
50
|
+
setMetrics: (metrics: Partial<ScrollMetrics>) => void;
|
|
51
|
+
}> => {
|
|
52
|
+
const chat = document.createElement("pubnub-chat") as PubnubChat;
|
|
53
|
+
chat.buildingSlug = "test-building";
|
|
54
|
+
chat.orgSlug = "test-org";
|
|
55
|
+
chat.building = {
|
|
56
|
+
id: 1,
|
|
57
|
+
orgId: 1,
|
|
58
|
+
name: "Test Building",
|
|
59
|
+
welcomeMessage: null,
|
|
60
|
+
state: "NY",
|
|
61
|
+
country: "US",
|
|
62
|
+
customAdditionalDisclaimer: null,
|
|
63
|
+
} as BuildingWebchatView;
|
|
64
|
+
document.body.appendChild(chat);
|
|
65
|
+
await waitForRender(chat);
|
|
66
|
+
|
|
67
|
+
const messageBody =
|
|
68
|
+
chat.shadowRoot?.querySelector<HTMLElement>("#conversation-body");
|
|
69
|
+
if (!messageBody) throw new Error("Expected the conversation body to render");
|
|
70
|
+
|
|
71
|
+
const metrics: ScrollMetrics = {
|
|
72
|
+
clientHeight: 400,
|
|
73
|
+
scrollHeight: 1_000,
|
|
74
|
+
scrollTop: 200,
|
|
75
|
+
...initialMetrics,
|
|
76
|
+
};
|
|
77
|
+
Object.defineProperties(messageBody, {
|
|
78
|
+
clientHeight: { configurable: true, get: () => metrics.clientHeight },
|
|
79
|
+
scrollHeight: { configurable: true, get: () => metrics.scrollHeight },
|
|
80
|
+
scrollTop: { configurable: true, get: () => metrics.scrollTop },
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const scrollCalls: ScrollToOptions[] = [];
|
|
84
|
+
messageBody.scrollTo = ((options: ScrollToOptions) => {
|
|
85
|
+
scrollCalls.push(options);
|
|
86
|
+
}) as typeof messageBody.scrollTo;
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
chat,
|
|
90
|
+
messageBody,
|
|
91
|
+
scrollCalls,
|
|
92
|
+
setMetrics: (nextMetrics) => Object.assign(metrics, nextMetrics),
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const expectOnlyAutoScrollsTo = (
|
|
97
|
+
scrollCalls: ScrollToOptions[],
|
|
98
|
+
top: number
|
|
99
|
+
): void => {
|
|
100
|
+
expect(scrollCalls).not.to.be.empty;
|
|
101
|
+
expect(
|
|
102
|
+
scrollCalls.every(
|
|
103
|
+
(options) => options.top === top && options.behavior === "auto"
|
|
104
|
+
)
|
|
105
|
+
).to.equal(true);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
afterEach(() => {
|
|
109
|
+
document.querySelectorAll("pubnub-chat").forEach((chat) => chat.remove());
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("test_bug_preserves_scroll_position_during_streamed_updates", async () => {
|
|
113
|
+
const { chat, messageBody, scrollCalls } = await createScrollableChat();
|
|
114
|
+
|
|
115
|
+
messageBody.dispatchEvent(new Event("scroll"));
|
|
116
|
+
chat.messages = [streamingMessage(["First streamed chunk. "])];
|
|
117
|
+
await waitForRender(chat);
|
|
118
|
+
chat.messages = [
|
|
119
|
+
streamingMessage(["First streamed chunk. ", "Second streamed chunk."]),
|
|
120
|
+
];
|
|
121
|
+
await waitForRender(chat);
|
|
122
|
+
|
|
123
|
+
expect(scrollCalls).to.deep.equal([]);
|
|
124
|
+
expect(messageBody.scrollTop).to.equal(200);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it("preserves scroll position when a completed message re-renders", async () => {
|
|
128
|
+
const { chat, messageBody, scrollCalls } = await createScrollableChat();
|
|
129
|
+
|
|
130
|
+
chat.messages = [
|
|
131
|
+
completedMessage(
|
|
132
|
+
"A completed response with enough content to exceed the visible pane."
|
|
133
|
+
),
|
|
134
|
+
];
|
|
135
|
+
await waitForRender(chat);
|
|
136
|
+
scrollCalls.length = 0;
|
|
137
|
+
|
|
138
|
+
messageBody.dispatchEvent(new Event("scroll"));
|
|
139
|
+
const renderedMessage = chat.shadowRoot?.querySelector("pubnub-message") as
|
|
140
|
+
| (HTMLElement & { updateComplete: Promise<boolean> })
|
|
141
|
+
| null;
|
|
142
|
+
if (!renderedMessage) throw new Error("Expected a rendered chat message");
|
|
143
|
+
|
|
144
|
+
// Completed messages can update later as links, previews, or media settle.
|
|
145
|
+
renderedMessage.requestUpdate();
|
|
146
|
+
await renderedMessage.updateComplete;
|
|
147
|
+
|
|
148
|
+
expect(scrollCalls).to.deep.equal([]);
|
|
149
|
+
expect(messageBody.scrollTop).to.equal(200);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it("continues following streamed updates while already at the bottom", async () => {
|
|
153
|
+
const { chat, messageBody, scrollCalls, setMetrics } =
|
|
154
|
+
await createScrollableChat({ scrollTop: 600 });
|
|
155
|
+
|
|
156
|
+
messageBody.dispatchEvent(new Event("scroll"));
|
|
157
|
+
setMetrics({ scrollHeight: 1_200 });
|
|
158
|
+
chat.messages = [streamingMessage(["A newly streamed response."])];
|
|
159
|
+
await waitForRender(chat);
|
|
160
|
+
|
|
161
|
+
expectOnlyAutoScrollsTo(scrollCalls, 800);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it("resumes following after the reader returns near the bottom", async () => {
|
|
165
|
+
const { chat, messageBody, scrollCalls, setMetrics } =
|
|
166
|
+
await createScrollableChat();
|
|
167
|
+
|
|
168
|
+
messageBody.dispatchEvent(new Event("scroll"));
|
|
169
|
+
chat.messages = [streamingMessage(["First streamed chunk. "])];
|
|
170
|
+
await waitForRender(chat);
|
|
171
|
+
expect(scrollCalls).to.deep.equal([]);
|
|
172
|
+
|
|
173
|
+
setMetrics({ scrollTop: 575 });
|
|
174
|
+
messageBody.dispatchEvent(new Event("scroll"));
|
|
175
|
+
setMetrics({ scrollHeight: 1_200 });
|
|
176
|
+
chat.messages = [
|
|
177
|
+
streamingMessage(["First streamed chunk. ", "Second streamed chunk."]),
|
|
178
|
+
];
|
|
179
|
+
await waitForRender(chat);
|
|
180
|
+
|
|
181
|
+
expectOnlyAutoScrollsTo(scrollCalls, 800);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it("follows the conversation again when the reader sends a message", async () => {
|
|
185
|
+
const { chat, messageBody, scrollCalls } = await createScrollableChat();
|
|
186
|
+
|
|
187
|
+
messageBody.dispatchEvent(new Event("scroll"));
|
|
188
|
+
await chat.sendMessage("Show me another apartment");
|
|
189
|
+
await waitForRender(chat);
|
|
190
|
+
|
|
191
|
+
expectOnlyAutoScrollsTo(scrollCalls, 600);
|
|
192
|
+
});
|