@meetelise/chat 1.20.255 → 1.20.256
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/public/dist/index.js +1 -1
- package/src/MyPubnub.ts +0 -16
package/package.json
CHANGED
package/public/dist/index.js
CHANGED
|
@@ -3161,7 +3161,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
|
|
|
3161
3161
|
${Oi}
|
|
3162
3162
|
${Ii}
|
|
3163
3163
|
${Ni}
|
|
3164
|
-
`,or([le({attribute:!0})],ar.prototype,"isMinimized",void 0),or([le()],ar.prototype,"mobileStyles",void 0),or([le({type:Boolean})],ar.prototype,"isFirstMount",void 0),or([le({attribute:!1})],ar.prototype,"autoOpenChatWidget",void 0),or([le()],ar.prototype,"phoneNumber",void 0),or([le({attribute:!0})],ar.prototype,"buildingName",void 0),or([le({attribute:!0})],ar.prototype,"chatId",void 0),or([le({attribute:!0})],ar.prototype,"chatCallUsHeader",void 0),or([le({attribute:!1})],ar.prototype,"buildingId",void 0),or([le({attribute:!0})],ar.prototype,"buildingSlug",void 0),or([le({attribute:!0})],ar.prototype,"orgSlug",void 0),or([le({attribute:!0})],ar.prototype,"sgtUrl",void 0),or([le({attribute:!0})],ar.prototype,"designConcept",void 0),or([le({attribute:!0})],ar.prototype,"featureFlagShowDropdown",void 0),or([le({attribute:!1})],ar.prototype,"leadSources",void 0),or([le({attribute:!0})],ar.prototype,"currentLeadSource",void 0),or([le({attribute:!0})],ar.prototype,"escortedToursLink",void 0),or([le({attribute:!0})],ar.prototype,"virtualToursLink",void 0),or([le({type:Boolean})],ar.prototype,"hasChatEnabledDesktop",void 0),or([le({type:Boolean})],ar.prototype,"hasChatEnabledMobile",void 0),or([le({type:Boolean})],ar.prototype,"hasEmailEnabledDesktop",void 0),or([le({type:Boolean})],ar.prototype,"hasEmailEnabledMobile",void 0),or([le({type:Boolean})],ar.prototype,"hasCallUsEnabledDesktop",void 0),or([le({type:Boolean})],ar.prototype,"hasCallUsEnabledMobile",void 0),or([le({type:Boolean})],ar.prototype,"hasTextUsEnabledDesktop",void 0),or([le({type:Boolean})],ar.prototype,"hasTextUsEnabledMobile",void 0),or([le({type:Boolean})],ar.prototype,"hasSSTEnabledDesktop",void 0),or([le({type:Boolean})],ar.prototype,"hasSSTEnabledMobile",void 0),or([le({attribute:!1})],ar.prototype,"layoutOptions",void 0),or([le({attribute:!1})],ar.prototype,"unitOptions",void 0),or([le({attribute:!1})],ar.prototype,"tourTypeOptions",void 0),or([le({attribute:!0})],ar.prototype,"hasDynamicSchedulingEnabled",void 0),or([le({attribute:!0})],ar.prototype,"onExitChat",void 0),or([le({type:Number})],ar.prototype,"right",void 0),or([le({type:Number})],ar.prototype,"bottom",void 0),or([le({type:Number})],ar.prototype,"top",void 0),or([le({type:Number})],ar.prototype,"left",void 0),or([le({attribute:!0})],ar.prototype,"showTourNextToChat",void 0),or([le({attribute:!1})],ar.prototype,"onChatTapped",void 0),or([le({attribute:!0})],ar.prototype,"onClickMinimize",void 0),or([le({attribute:!1})],ar.prototype,"launcherStyles",void 0),or([le({attribute:!0})],ar.prototype,"brandColor",void 0),or([le({attribute:!0})],ar.prototype,"backgroundColor",void 0),or([le({attribute:!0})],ar.prototype,"leadSourceClient",void 0),or([ue()],ar.prototype,"isEmailWindowOpen",void 0),or([ue()],ar.prototype,"isCallUsWindowOpen",void 0),or([ue()],ar.prototype,"isSSTWindowOpen",void 0),or([ue()],ar.prototype,"isTextUsWindowOpen",void 0),ar=or([ae("meetelise-launcher")],ar);const sr=()=>{window.customElements.get("meetelise-launcher")||window.customElements.define("meetelise-launcher",ar)};var lr=n(3379),ur=n.n(lr),dr=n(7795),cr=n.n(dr),pr=n(569),hr=n.n(pr),fr=n(3565),mr=n.n(fr),gr=n(9216),vr=n.n(gr),yr=n(4589),br=n.n(yr),wr=n(3631),Sr={};async function Tr(e){try{const n=await t().get(`https://app.meetelise.com/platformApi/webchat/${e}/lead-sources`);return n.data?xr(n.data,e):[]}catch(e){return[]}}Sr.styleTagTransform=br(),Sr.setAttributes=mr(),Sr.insert=hr().bind(null,"head"),Sr.domAPI=cr(),Sr.insertStyleElement=vr(),ur()(wr.Z,Sr),wr.Z&&wr.Z.locals&&wr.Z.locals;const xr=(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)}))};var Ar,Cr=n(9594),Or=n.n(Cr),Ir=new Uint8Array(16);function Nr(){if(!Ar&&!(Ar="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 Ar(Ir)}const Er=/^(?:[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,Rr=function(e){return"string"==typeof e&&Er.test(e)};for(var _r=[],Pr=0;Pr<256;++Pr)_r.push((Pr+256).toString(16).substr(1));const Mr=function(e,t,n){var i=(e=e||{}).random||(e.rng||Nr)();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 function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(_r[e[t+0]]+_r[e[t+1]]+_r[e[t+2]]+_r[e[t+3]]+"-"+_r[e[t+4]]+_r[e[t+5]]+"-"+_r[e[t+6]]+_r[e[t+7]]+"-"+_r[e[t+8]]+_r[e[t+9]]+"-"+_r[e[t+10]]+_r[e[t+11]]+_r[e[t+12]]+_r[e[t+13]]+_r[e[t+14]]+_r[e[t+15]]).toLowerCase();if(!Rr(n))throw TypeError("Stringified UUID is invalid");return n}(i)},Fr=e=>localStorage.removeItem("com.elise.webchat.slug="+e),Dr=(e,t,n)=>{const i=yn(new Date),r=n||`lead_${Mr()}_${e}`;return localStorage.setItem("com.elise.webchat.slug="+e,JSON.stringify({buildingSlug:e,leadId:r,timestamp:i,initiatedChat:t})),{leadId:r,timestamp:Cn(i),buildingSlug:e,initiatedChat:t}},kr=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(Ur(e,i))return i}catch(e){console.warn("Error getting chat storage key")}return{leadId:null,timestamp:null,buildingSlug:null,initiatedChat:!1}},Ur=(e,t)=>{try{if(t.timestamp&&t.initiatedChat){const e=new Date("2024-06-06T21:30:00Z");if(un(t.timestamp,e))return!1}}catch(e){console.warn("Error checking chat storage key validity")}return!(t.buildingSlug!==e||!t.leadId||!t.timestamp||pn(t.timestamp,24))};var Lr;!function(e){e.noReply="no-reply",e.text="text",e.media="media"}(Lr||(Lr={}));const qr=e=>e.type===Jr.text,Br=e=>e.type===Jr.media;var Jr;!function(e){e.text="text",e.media="media"}(Jr||(Jr={}));const jr=class{constructor(e,t,n,i=null,r,o=null){this.apiHost="https://app.meetelise.com",this.leadSourceClient=null,this.building=null,this.eliseResponseTimeout=null,this.pubnub=null,this.leadUserId="",this.channel="",this.leadSource=null,this.isCurrentlyStreamingMessage=!1,this.chatListener=null,this.rawPubnubMessages=[],this.simpleChatMessages=[],this.listenerParams={message:e=>{var t,n;e.message.messageType!==Lr.noReply&&(this.rawPubnubMessages=[...this.rawPubnubMessages,{channel:e.channel,message:e.message,publisher:e.publisher,subscription:e.subscription,timetoken:+e.timetoken}],this.simpleChatMessages=this.translatePubnubMessagesIntoSimpleChatMessages(this.rawPubnubMessages));const i="eliseai"!==e.publisher&&"elise_health_ai"!==e.publisher;null===(t=this.chatListener)||void 0===t||t.call(this,{messages:this.simpleChatMessages,isLoading:i}),!i&&this.eliseResponseTimeout&&clearTimeout(this.eliseResponseTimeout),this.isLoadingMessages=i,("eliseai"===e.publisher||"elise_health_ai"===e.publisher&&"ai_message"===e.message.customType&&e.message.text.includes("confirmed tour"))&&ei("scheduledTourEvent",{tourDetails:e.message.text,buildingId:null===(n=this.building)||void 0===n?void 0:n.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel})}},this.isLoadingMessages=!1,this.isFirstChatMessageSent=!1,this.handleChatListeners=()=>{if(this.pubnub&&this.channel)try{this.pubnub.subscribe({channels:[this.channel]}),this.pubnub.addListener(this.listenerParams)}catch(e){this.building&&li({logTitle:"PUBNUB_ERROR_ADDING_LISTENER",logData:{error:e,channel:this.channel,leadUserId:this.leadUserId,website:location.href},logType:si.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this.handleDisconnect=()=>{this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=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=Dr(this.buildingSlug,!0,this.leadUserId);if(!await this.initializePubnub(e))return}await this.withAuthToken((async()=>{var t,n,i,r,o;this.pubnub&&this.channel&&(this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.eliseResponseTimeout=setTimeout((()=>{console.error("Elise AI did not respond in time..."),this.building&&li({logTitle:"PUBNUB_ERROR_ELISEAI_MESSAGE_TIMEOUT",logData:{channel:this.channel,leadUserId:this.leadUserId,message:e},logType:si.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})),await this.pubnub.publish({channel:this.channel,message:{text:e,customType:"lead_message",buildingId:null===(n=this.building)||void 0===n?void 0:n.id,buildingSlug:this.buildingSlug,userId:null===(i=this.building)||void 0===i?void 0:i.userId,leadSource:this.leadSource,isDevState:this.shouldCreateAsDevState()}}),this.isFirstChatMessageSent||(ei("firstChatMessageSent",{message:e,buildingId:null===(r=this.building)||void 0===r?void 0:r.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel}),this.isFirstChatMessageSent=!0),ei("chatMessageSent",{message:e,buildingId:null===(o=this.building)||void 0===o?void 0:o.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.translatePubnubMessagesIntoSimpleChatMessages=e=>{const t=[],n={};return 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:Jr.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:Jr.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:Jr.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.building=t,this.orgSlug=n,this.leadSource=i,this.leadUserId=r,this.channel=`webchat_${r}`,this.leadSourceClient=o}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(Or())({publishKey:t.keys.publish_key,subscribeKey:t.keys.subscribe_key,userId:this.leadUserId,authKey:t.auth.result.token}),this.withAuthToken((()=>new Promise((()=>this.handleChatListeners())))),await this.withAuthToken((()=>this.getChannelHistory())),this.pubnub):void 0}async fetchToken(e,n){try{return(await t().get(`${this.apiHost}/platformApi/webchat/pn/request-token?user_id=${e}&channel=${n}&${this.building?"":"industry=health_care"}`)).data}catch(e){this.building&&li({logTitle:"PUBNUB_ERROR_FETCHING_TOKEN",logData:{error:e},logType:si.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}return null}async fetchChannelExists(e){try{return(await t().get(`${this.apiHost}/platformApi/webchat/check-channel-exists?channel_name=${e}`)).data}catch(e){this.building&&li({logTitle:"PUBNUB_ERROR_FETCHING_CHANNEL_EXISTS",logData:{error:e},logType:si.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}return!1}async withAuthToken(t){try{await t()}catch(n){if(n instanceof e.AxiosError&&n&&n.response&&403===n.response.status)try{if(!this.pubnub||!this.leadUserId||!this.channel)return;const e=await this.fetchToken(this.leadUserId,this.channel);if(!e)return;this.pubnub.setAuthKey(e.auth.result.token),await t()}catch(e){this.building&&li({logTitle:"PUBNUB_ERROR_REFETCHING_TOKEN",logData:{retryError:e},logType:si.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}}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})})),n=n.concat(t.filter((e=>e.message.messageType!==Lr.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.building&&li({logTitle:"PUBNUB_WARN_FETCHING_HISTORY",logData:{error:e},logType:si.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}shouldCreateAsDevState(){return location.href.startsWith("https://app.meetelise.com/settings/widgets")}},Hr=(e,t,n)=>{const i=`tel:${e}`,r=`sms:${e}`,o=`whatsapp://send?phone=${e}}`,a=`facetime:${e}`,s=`facetime-audio:${e}`,l=/\(\d{3}\)\s\d{3}-\d{4}/g,u=/(tel|sms):\(\d{3}\)\s\d{3}-\d{4}/g,d=/whatsapp:\/\/send\?phone=\d+/g,c=/(facetime|facetime-audio):\d+/g,p=document.body.getElementsByTagName("*");let h=!1;const f=e.replace(/(\d{3})(\d{3})(\d{4})/,"($1) $2-$3");let m=!1,g=!1;for(let e=0;e<p.length;e++)if(p[e].nodeType===Node.ELEMENT_NODE&&(1===p[e].childNodes.length&&p[e].childNodes[0].nodeType==Node.TEXT_NODE&&(p[e].innerHTML=p[e].innerHTML.replace(l,f),h=!0,m||(m=!0)),p[e].hasAttribute("href"))){const t=p[e].getAttribute("href");if(!t)continue;let n="",l=u;t.startsWith("sms:")?n=r:t.startsWith("whatsapp:")?(n=o,l=d):t.startsWith("facetime:")?(n=a,l=c):t.startsWith("facetime-audio:")?(n=s,l=c):n=i;const h=t.replace(l,n);p[e].setAttribute("href",h),g||(g=!0)}m&&li({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"text-insertion",newPhoneNumber:f,website:window.location.href},logType:si.info,buildingSlug:n,orgSlug:t}),g&&li({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"href-insertion",newPhoneNumber:f,website:window.location.href},logType:si.info,buildingSlug:n,orgSlug:t}),h||li({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"no-phone-number-found",website:window.location.href},logType:si.warn,buildingSlug:n,orgSlug:t})};var Gr=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 zr=class extends re{constructor(){super(...arguments),this.onClick=()=>{},this.brandColor=Me,this.toExpand=!1}render(){return U`
|
|
3164
|
+
`,or([le({attribute:!0})],ar.prototype,"isMinimized",void 0),or([le()],ar.prototype,"mobileStyles",void 0),or([le({type:Boolean})],ar.prototype,"isFirstMount",void 0),or([le({attribute:!1})],ar.prototype,"autoOpenChatWidget",void 0),or([le()],ar.prototype,"phoneNumber",void 0),or([le({attribute:!0})],ar.prototype,"buildingName",void 0),or([le({attribute:!0})],ar.prototype,"chatId",void 0),or([le({attribute:!0})],ar.prototype,"chatCallUsHeader",void 0),or([le({attribute:!1})],ar.prototype,"buildingId",void 0),or([le({attribute:!0})],ar.prototype,"buildingSlug",void 0),or([le({attribute:!0})],ar.prototype,"orgSlug",void 0),or([le({attribute:!0})],ar.prototype,"sgtUrl",void 0),or([le({attribute:!0})],ar.prototype,"designConcept",void 0),or([le({attribute:!0})],ar.prototype,"featureFlagShowDropdown",void 0),or([le({attribute:!1})],ar.prototype,"leadSources",void 0),or([le({attribute:!0})],ar.prototype,"currentLeadSource",void 0),or([le({attribute:!0})],ar.prototype,"escortedToursLink",void 0),or([le({attribute:!0})],ar.prototype,"virtualToursLink",void 0),or([le({type:Boolean})],ar.prototype,"hasChatEnabledDesktop",void 0),or([le({type:Boolean})],ar.prototype,"hasChatEnabledMobile",void 0),or([le({type:Boolean})],ar.prototype,"hasEmailEnabledDesktop",void 0),or([le({type:Boolean})],ar.prototype,"hasEmailEnabledMobile",void 0),or([le({type:Boolean})],ar.prototype,"hasCallUsEnabledDesktop",void 0),or([le({type:Boolean})],ar.prototype,"hasCallUsEnabledMobile",void 0),or([le({type:Boolean})],ar.prototype,"hasTextUsEnabledDesktop",void 0),or([le({type:Boolean})],ar.prototype,"hasTextUsEnabledMobile",void 0),or([le({type:Boolean})],ar.prototype,"hasSSTEnabledDesktop",void 0),or([le({type:Boolean})],ar.prototype,"hasSSTEnabledMobile",void 0),or([le({attribute:!1})],ar.prototype,"layoutOptions",void 0),or([le({attribute:!1})],ar.prototype,"unitOptions",void 0),or([le({attribute:!1})],ar.prototype,"tourTypeOptions",void 0),or([le({attribute:!0})],ar.prototype,"hasDynamicSchedulingEnabled",void 0),or([le({attribute:!0})],ar.prototype,"onExitChat",void 0),or([le({type:Number})],ar.prototype,"right",void 0),or([le({type:Number})],ar.prototype,"bottom",void 0),or([le({type:Number})],ar.prototype,"top",void 0),or([le({type:Number})],ar.prototype,"left",void 0),or([le({attribute:!0})],ar.prototype,"showTourNextToChat",void 0),or([le({attribute:!1})],ar.prototype,"onChatTapped",void 0),or([le({attribute:!0})],ar.prototype,"onClickMinimize",void 0),or([le({attribute:!1})],ar.prototype,"launcherStyles",void 0),or([le({attribute:!0})],ar.prototype,"brandColor",void 0),or([le({attribute:!0})],ar.prototype,"backgroundColor",void 0),or([le({attribute:!0})],ar.prototype,"leadSourceClient",void 0),or([ue()],ar.prototype,"isEmailWindowOpen",void 0),or([ue()],ar.prototype,"isCallUsWindowOpen",void 0),or([ue()],ar.prototype,"isSSTWindowOpen",void 0),or([ue()],ar.prototype,"isTextUsWindowOpen",void 0),ar=or([ae("meetelise-launcher")],ar);const sr=()=>{window.customElements.get("meetelise-launcher")||window.customElements.define("meetelise-launcher",ar)};var lr=n(3379),ur=n.n(lr),dr=n(7795),cr=n.n(dr),pr=n(569),hr=n.n(pr),fr=n(3565),mr=n.n(fr),gr=n(9216),vr=n.n(gr),yr=n(4589),br=n.n(yr),wr=n(3631),Sr={};async function Tr(e){try{const n=await t().get(`https://app.meetelise.com/platformApi/webchat/${e}/lead-sources`);return n.data?xr(n.data,e):[]}catch(e){return[]}}Sr.styleTagTransform=br(),Sr.setAttributes=mr(),Sr.insert=hr().bind(null,"head"),Sr.domAPI=cr(),Sr.insertStyleElement=vr(),ur()(wr.Z,Sr),wr.Z&&wr.Z.locals&&wr.Z.locals;const xr=(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)}))};var Ar,Cr=n(9594),Or=n.n(Cr),Ir=new Uint8Array(16);function Nr(){if(!Ar&&!(Ar="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 Ar(Ir)}const Er=/^(?:[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,Rr=function(e){return"string"==typeof e&&Er.test(e)};for(var _r=[],Pr=0;Pr<256;++Pr)_r.push((Pr+256).toString(16).substr(1));const Mr=function(e,t,n){var i=(e=e||{}).random||(e.rng||Nr)();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 function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(_r[e[t+0]]+_r[e[t+1]]+_r[e[t+2]]+_r[e[t+3]]+"-"+_r[e[t+4]]+_r[e[t+5]]+"-"+_r[e[t+6]]+_r[e[t+7]]+"-"+_r[e[t+8]]+_r[e[t+9]]+"-"+_r[e[t+10]]+_r[e[t+11]]+_r[e[t+12]]+_r[e[t+13]]+_r[e[t+14]]+_r[e[t+15]]).toLowerCase();if(!Rr(n))throw TypeError("Stringified UUID is invalid");return n}(i)},Fr=e=>localStorage.removeItem("com.elise.webchat.slug="+e),Dr=(e,t,n)=>{const i=yn(new Date),r=n||`lead_${Mr()}_${e}`;return localStorage.setItem("com.elise.webchat.slug="+e,JSON.stringify({buildingSlug:e,leadId:r,timestamp:i,initiatedChat:t})),{leadId:r,timestamp:Cn(i),buildingSlug:e,initiatedChat:t}},kr=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(Ur(e,i))return i}catch(e){console.warn("Error getting chat storage key")}return{leadId:null,timestamp:null,buildingSlug:null,initiatedChat:!1}},Ur=(e,t)=>{try{if(t.timestamp&&t.initiatedChat){const e=new Date("2024-06-06T21:30:00Z");if(un(t.timestamp,e))return!1}}catch(e){console.warn("Error checking chat storage key validity")}return!(t.buildingSlug!==e||!t.leadId||!t.timestamp||pn(t.timestamp,24))};var Lr;!function(e){e.noReply="no-reply",e.text="text",e.media="media"}(Lr||(Lr={}));const qr=e=>e.type===Jr.text,Br=e=>e.type===Jr.media;var Jr;!function(e){e.text="text",e.media="media"}(Jr||(Jr={}));const jr=class{constructor(e,t,n,i=null,r,o=null){this.apiHost="https://app.meetelise.com",this.leadSourceClient=null,this.building=null,this.eliseResponseTimeout=null,this.pubnub=null,this.leadUserId="",this.channel="",this.leadSource=null,this.isCurrentlyStreamingMessage=!1,this.chatListener=null,this.rawPubnubMessages=[],this.simpleChatMessages=[],this.listenerParams={message:e=>{var t;e.message.messageType!==Lr.noReply&&(this.rawPubnubMessages=[...this.rawPubnubMessages,{channel:e.channel,message:e.message,publisher:e.publisher,subscription:e.subscription,timetoken:+e.timetoken}],this.simpleChatMessages=this.translatePubnubMessagesIntoSimpleChatMessages(this.rawPubnubMessages));const n="eliseai"!==e.publisher&&"elise_health_ai"!==e.publisher;null===(t=this.chatListener)||void 0===t||t.call(this,{messages:this.simpleChatMessages,isLoading:n}),!n&&this.eliseResponseTimeout&&clearTimeout(this.eliseResponseTimeout),this.isLoadingMessages=n}},this.isLoadingMessages=!1,this.isFirstChatMessageSent=!1,this.handleChatListeners=()=>{if(this.pubnub&&this.channel)try{this.pubnub.subscribe({channels:[this.channel]}),this.pubnub.addListener(this.listenerParams)}catch(e){this.building&&li({logTitle:"PUBNUB_ERROR_ADDING_LISTENER",logData:{error:e,channel:this.channel,leadUserId:this.leadUserId,website:location.href},logType:si.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this.handleDisconnect=()=>{this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=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=Dr(this.buildingSlug,!0,this.leadUserId);if(!await this.initializePubnub(e))return}await this.withAuthToken((async()=>{var t,n,i,r,o;this.pubnub&&this.channel&&(this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.eliseResponseTimeout=setTimeout((()=>{console.error("Elise AI did not respond in time..."),this.building&&li({logTitle:"PUBNUB_ERROR_ELISEAI_MESSAGE_TIMEOUT",logData:{channel:this.channel,leadUserId:this.leadUserId,message:e},logType:si.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})),await this.pubnub.publish({channel:this.channel,message:{text:e,customType:"lead_message",buildingId:null===(n=this.building)||void 0===n?void 0:n.id,buildingSlug:this.buildingSlug,userId:null===(i=this.building)||void 0===i?void 0:i.userId,leadSource:this.leadSource,isDevState:this.shouldCreateAsDevState()}}),this.isFirstChatMessageSent||(ei("firstChatMessageSent",{message:e,buildingId:null===(r=this.building)||void 0===r?void 0:r.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel}),this.isFirstChatMessageSent=!0),ei("chatMessageSent",{message:e,buildingId:null===(o=this.building)||void 0===o?void 0:o.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.translatePubnubMessagesIntoSimpleChatMessages=e=>{const t=[],n={};return 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:Jr.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:Jr.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:Jr.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.building=t,this.orgSlug=n,this.leadSource=i,this.leadUserId=r,this.channel=`webchat_${r}`,this.leadSourceClient=o}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(Or())({publishKey:t.keys.publish_key,subscribeKey:t.keys.subscribe_key,userId:this.leadUserId,authKey:t.auth.result.token}),this.withAuthToken((()=>new Promise((()=>this.handleChatListeners())))),await this.withAuthToken((()=>this.getChannelHistory())),this.pubnub):void 0}async fetchToken(e,n){try{return(await t().get(`${this.apiHost}/platformApi/webchat/pn/request-token?user_id=${e}&channel=${n}&${this.building?"":"industry=health_care"}`)).data}catch(e){this.building&&li({logTitle:"PUBNUB_ERROR_FETCHING_TOKEN",logData:{error:e},logType:si.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}return null}async fetchChannelExists(e){try{return(await t().get(`${this.apiHost}/platformApi/webchat/check-channel-exists?channel_name=${e}`)).data}catch(e){this.building&&li({logTitle:"PUBNUB_ERROR_FETCHING_CHANNEL_EXISTS",logData:{error:e},logType:si.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}return!1}async withAuthToken(t){try{await t()}catch(n){if(n instanceof e.AxiosError&&n&&n.response&&403===n.response.status)try{if(!this.pubnub||!this.leadUserId||!this.channel)return;const e=await this.fetchToken(this.leadUserId,this.channel);if(!e)return;this.pubnub.setAuthKey(e.auth.result.token),await t()}catch(e){this.building&&li({logTitle:"PUBNUB_ERROR_REFETCHING_TOKEN",logData:{retryError:e},logType:si.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}}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})})),n=n.concat(t.filter((e=>e.message.messageType!==Lr.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.building&&li({logTitle:"PUBNUB_WARN_FETCHING_HISTORY",logData:{error:e},logType:si.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}shouldCreateAsDevState(){return location.href.startsWith("https://app.meetelise.com/settings/widgets")}},Hr=(e,t,n)=>{const i=`tel:${e}`,r=`sms:${e}`,o=`whatsapp://send?phone=${e}}`,a=`facetime:${e}`,s=`facetime-audio:${e}`,l=/\(\d{3}\)\s\d{3}-\d{4}/g,u=/(tel|sms):\(\d{3}\)\s\d{3}-\d{4}/g,d=/whatsapp:\/\/send\?phone=\d+/g,c=/(facetime|facetime-audio):\d+/g,p=document.body.getElementsByTagName("*");let h=!1;const f=e.replace(/(\d{3})(\d{3})(\d{4})/,"($1) $2-$3");let m=!1,g=!1;for(let e=0;e<p.length;e++)if(p[e].nodeType===Node.ELEMENT_NODE&&(1===p[e].childNodes.length&&p[e].childNodes[0].nodeType==Node.TEXT_NODE&&(p[e].innerHTML=p[e].innerHTML.replace(l,f),h=!0,m||(m=!0)),p[e].hasAttribute("href"))){const t=p[e].getAttribute("href");if(!t)continue;let n="",l=u;t.startsWith("sms:")?n=r:t.startsWith("whatsapp:")?(n=o,l=d):t.startsWith("facetime:")?(n=a,l=c):t.startsWith("facetime-audio:")?(n=s,l=c):n=i;const h=t.replace(l,n);p[e].setAttribute("href",h),g||(g=!0)}m&&li({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"text-insertion",newPhoneNumber:f,website:window.location.href},logType:si.info,buildingSlug:n,orgSlug:t}),g&&li({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"href-insertion",newPhoneNumber:f,website:window.location.href},logType:si.info,buildingSlug:n,orgSlug:t}),h||li({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"no-phone-number-found",website:window.location.href},logType:si.warn,buildingSlug:n,orgSlug:t})};var Gr=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 zr=class extends re{constructor(){super(...arguments),this.onClick=()=>{},this.brandColor=Me,this.toExpand=!1}render(){return U`
|
|
3165
3165
|
<div
|
|
3166
3166
|
class=${this.toExpand?"button-container mini":"button-container"}
|
|
3167
3167
|
@click=${this.onClick}
|
package/src/MyPubnub.ts
CHANGED
|
@@ -143,22 +143,6 @@ class MyPubnub {
|
|
|
143
143
|
clearTimeout(this.eliseResponseTimeout);
|
|
144
144
|
}
|
|
145
145
|
this.isLoadingMessages = isWaitingForEliseResponse;
|
|
146
|
-
|
|
147
|
-
if (
|
|
148
|
-
messageEvent.publisher === "eliseai" ||
|
|
149
|
-
(messageEvent.publisher === "elise_health_ai" &&
|
|
150
|
-
messageEvent.message.customType === "ai_message" &&
|
|
151
|
-
messageEvent.message.text.includes("confirmed tour"))
|
|
152
|
-
) {
|
|
153
|
-
pushGtmEvent("scheduledTourEvent", {
|
|
154
|
-
tourDetails: messageEvent.message.text,
|
|
155
|
-
buildingId: this.building?.id,
|
|
156
|
-
buildingSlug: this.buildingSlug,
|
|
157
|
-
orgSlug: this.orgSlug,
|
|
158
|
-
leadUserId: this.leadUserId,
|
|
159
|
-
channel: this.channel,
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
146
|
},
|
|
163
147
|
};
|
|
164
148
|
isLoadingMessages = false;
|