@meetelise/chat 1.43.13 → 1.43.15
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 +2 -2
package/package.json
CHANGED
package/public/dist/index.js
CHANGED
|
@@ -5533,7 +5533,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
5533
5533
|
${Cr}
|
|
5534
5534
|
${xr}
|
|
5535
5535
|
${Ar}
|
|
5536
|
-
`,ba([ue({attribute:!0})],va.prototype,"isMinimized",void 0),ba([ue()],va.prototype,"mobileStyles",void 0),ba([ue({type:Boolean})],va.prototype,"isFirstMount",void 0),ba([ue({attribute:!1})],va.prototype,"autoOpenChatWidget",void 0),ba([ue()],va.prototype,"phoneNumber",void 0),ba([ue({attribute:!0})],va.prototype,"buildingName",void 0),ba([ue({attribute:!0})],va.prototype,"chatId",void 0),ba([ue({attribute:!0})],va.prototype,"orgLegalName",void 0),ba([ue({attribute:!0})],va.prototype,"chatCallUsHeader",void 0),ba([ue({attribute:!1})],va.prototype,"buildingId",void 0),ba([ue({attribute:!0})],va.prototype,"buildingSlug",void 0),ba([ue({attribute:!0})],va.prototype,"orgSlug",void 0),ba([ue({attribute:!0})],va.prototype,"sgtUrl",void 0),ba([ue({attribute:!0})],va.prototype,"selfGuidedTourEnabled",void 0),ba([ue({attribute:!0})],va.prototype,"selfGuidedToursTypeOffered",void 0),ba([ue({attribute:!0})],va.prototype,"designConcept",void 0),ba([ue({attribute:!0})],va.prototype,"featureFlagShowDropdown",void 0),ba([ue({attribute:!1})],va.prototype,"leadSources",void 0),ba([ue({attribute:!0})],va.prototype,"currentLeadSource",void 0),ba([ue({attribute:!0})],va.prototype,"escortedToursLink",void 0),ba([ue({attribute:!0})],va.prototype,"escortedToursTypeOffered",void 0),ba([ue({attribute:!0})],va.prototype,"virtualToursLink",void 0),ba([ue({attribute:!0})],va.prototype,"virtualToursTypeOffered",void 0),ba([ue({type:Boolean})],va.prototype,"hasChatEnabledDesktop",void 0),ba([ue({type:Boolean})],va.prototype,"hasChatEnabledMobile",void 0),ba([ue({type:Boolean})],va.prototype,"hasEmailEnabledDesktop",void 0),ba([ue({type:Boolean})],va.prototype,"hasEmailEnabledMobile",void 0),ba([ue({attribute:!0})],va.prototype,"hasApplyNowEnabledDesktop",void 0),ba([ue({attribute:!0})],va.prototype,"hasApplyNowEnabledMobile",void 0),ba([ue({attribute:!0})],va.prototype,"applicationLink",void 0),ba([ue({type:Boolean})],va.prototype,"hasCallUsEnabledDesktop",void 0),ba([ue({type:Boolean})],va.prototype,"hasCallUsEnabledMobile",void 0),ba([ue({type:Boolean})],va.prototype,"hasTextUsEnabledDesktop",void 0),ba([ue({type:Boolean})],va.prototype,"hasTextUsEnabledMobile",void 0),ba([ue({type:Boolean})],va.prototype,"hasSSTEnabledDesktop",void 0),ba([ue({type:Boolean})],va.prototype,"hasSSTEnabledMobile",void 0),ba([ue({attribute:!1})],va.prototype,"tourTypeOptions",void 0),ba([ue({attribute:!0})],va.prototype,"hasDynamicSchedulingEnabled",void 0),ba([ue({attribute:!0})],va.prototype,"hasPricingCalculatorEnabledDesktop",void 0),ba([ue({attribute:!0})],va.prototype,"hasPricingCalculatorEnabledMobile",void 0),ba([ue({attribute:!1})],va.prototype,"hasHideMobileFeatures",void 0),ba([ue({type:Number})],va.prototype,"right",void 0),ba([ue({type:Number})],va.prototype,"bottom",void 0),ba([ue({type:Number})],va.prototype,"top",void 0),ba([ue({type:Number})],va.prototype,"left",void 0),ba([ue({attribute:!0})],va.prototype,"showTourNextToChat",void 0),ba([ue({attribute:!1})],va.prototype,"onChatTapped",void 0),ba([ue({attribute:!0})],va.prototype,"onClickMinimize",void 0),ba([ue({attribute:!0})],va.prototype,"onSstClose",void 0),ba([ue({attribute:!0})],va.prototype,"overrideRentgrata",void 0),ba([ue({attribute:!1})],va.prototype,"launcherStyles",void 0),ba([ue({attribute:!0})],va.prototype,"primaryColor",void 0),ba([ue({attribute:!0})],va.prototype,"backgroundColor",void 0),ba([ue({attribute:!0})],va.prototype,"foregroundColorOnPrimaryBackgroundColor",void 0),ba([ue({attribute:!0})],va.prototype,"foregroundColorOnSecondaryBackgroundColor",void 0),ba([ue({attribute:!0})],va.prototype,"leadSourceClient",void 0),ba([ce()],va.prototype,"leadSourceMultitouchClient",void 0),ba([ce()],va.prototype,"isEmailWindowOpen",void 0),ba([ce()],va.prototype,"isCallUsWindowOpen",void 0),ba([ce()],va.prototype,"isSSTWindowOpen",void 0),ba([ce()],va.prototype,"isTextUsWindowOpen",void 0),ba([ce()],va.prototype,"isCalculatorWindowOpen",void 0),ba([ce()],va.prototype,"isMobileFeaturesExpanded",void 0),va=ba([se("meetelise-launcher")],va);const wa=()=>{window.customElements.get("meetelise-launcher")||window.customElements.define("meetelise-launcher",va)},Ca=["app.meetelise.com","staging.eliseai.com","localhost"],xa={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"}},Aa=e=>{const t=window.location.hostname;if(!Ca.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 xa&&(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=xa[e];n&&(i[n.desktop]=t,i[n.mobile]=t)}),i};var Sa=n(5072),Ea=n.n(Sa),ka=n(7825),Ta=n.n(ka),_a=n(7659),Oa=n.n(_a),Pa=n(5056),Ia=n.n(Pa),Na=n(540),Ma=n.n(Na),Da=n(1113),Ua=n.n(Da),La=n(5541),Ra={};Ra.styleTagTransform=Ua(),Ra.setAttributes=Ia(),Ra.insert=Oa().bind(null,"head"),Ra.domAPI=Ta(),Ra.insertStyleElement=Ma();Ea()(La.A,Ra);La.A&&La.A.locals&&La.A.locals;async function Ba(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 ja(n.data,t)}return[]}catch(e){return[]}}const ja=(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 Fa,Ha=n(8805),$a=n.n(Ha),za=new Uint8Array(16);function Ga(){if(!Fa&&!(Fa="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 Fa(za)}const Qa=/^(?:[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 qa=function(e){return"string"==typeof e&&Qa.test(e)};for(var Wa=[],Va=0;Va<256;++Va)Wa.push((Va+256).toString(16).substr(1));const Ya=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(Wa[e[t+0]]+Wa[e[t+1]]+Wa[e[t+2]]+Wa[e[t+3]]+"-"+Wa[e[t+4]]+Wa[e[t+5]]+"-"+Wa[e[t+6]]+Wa[e[t+7]]+"-"+Wa[e[t+8]]+Wa[e[t+9]]+"-"+Wa[e[t+10]]+Wa[e[t+11]]+Wa[e[t+12]]+Wa[e[t+13]]+Wa[e[t+14]]+Wa[e[t+15]]).toLowerCase();if(!qa(n))throw TypeError("Stringified UUID is invalid");return n};const Ka=function(e,t,n){var i=(e=e||{}).random||(e.rng||Ga)();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 Ya(i)},Xa=e=>localStorage.removeItem("com.elise.webchat.slug="+e),Za=(e,t,n)=>{const i=En(new Date),r=n||`lead_${Ka()}`;return localStorage.setItem("com.elise.webchat.slug="+e,JSON.stringify({buildingSlug:e,leadId:r,timestamp:i,initiatedChat:t})),{leadId:r,timestamp:Mn(i),buildingSlug:e,initiatedChat:t}},Ja=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(es(e,i))return i}catch(e){}return{leadId:null,timestamp:null,buildingSlug:null,initiatedChat:!1}},es=(e,t)=>{try{if(t.timestamp&&t.initiatedChat){const e=new Date("2024-06-06T21:30:00Z");if(dn(t.timestamp,e))return!1}}catch(e){}return!(t.buildingSlug!==e||!t.leadId||!t.timestamp)&&!yn(t.timestamp,24)};var ts;!function(e){e.noReply="no-reply",e.text="text",e.media="media"}(ts||(ts={}));const ns=e=>e.type===rs.text,is=e=>e.type===rs.media;var rs;!function(e){e.text="text",e.media="media"}(rs||(rs={}));const os=class{constructor(e,t,n,i=null,r,o,a=null,s=Wl.Default){this.apiHost="https://app.meetelise.com",this.leadSourceClient=null,this.leadSourceMultitouchClient=null,this.buildingWebchatView=null,this.eliseResponseTimeout=null,this.isWaitingForStreamingMessages=!1,this.widgetType=Wl.Default,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;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!==ts.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===rs.text&&e.message.includes("confirmed for your tour"))&&ni("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(!ns(e))return!1;const t=e.chunks.find(e=>e.isDone);return!t||e.chunks.length===t.order});t&&(this.streamingMessageTimeout=setTimeout(()=>{bi({logTitle:"PUBNUB_WARN_DELAYED_STREAMING_MESSAGES",logData:{channel:this.channel},logType:yi.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;ni("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)===ts.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&&bi({logTitle:"PUBNUB_ERROR_ADDING_LISTENER",logData:{error:e,channel:this.channel,leadUserId:this.leadUserId,website:location.href},logType:yi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},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=Za(this.buildingSlug,!0,this.leadUserId);if(!await this.initializePubnub(e))return}await this.withAuthToken(async()=>{var t,n,i,r,o,a,s,l;this.pubnub&&this.channel&&(this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.eliseResponseTimeout=setTimeout(()=>{this.buildingWebchatView&&bi({logTitle:"PUBNUB_ERROR_ELISEAI_MESSAGE_TIMEOUT",logData:{channel:this.channel,leadUserId:this.leadUserId,message:e},logType:yi.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===Wl.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=>gn({...e}))}}),null===(a=this.leadSourceMultitouchClient)||void 0===a||a.resetLeadSourceTouchpoints()),this.isFirstChatMessageSent||(ni("firstChatMessageSent",{message:e,buildingId:null===(s=this.buildingWebchatView)||void 0===s?void 0:s.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel}),this.isFirstChatMessageSent=!0),ni("chatMessageSent",{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}))}),!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)?(bi({logTitle:"PUBNUB_WARN_DUPLICATE_MESSAGE",logData:{message:e,channel:this.channel},logType:yi.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:rs.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:rs.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:rs.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}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($a())({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{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&&bi({logTitle:"PUBNUB_ERROR_FETCHING_TOKEN",logData:{error:e},logType:yi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}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&&bi({logTitle:"PUBNUB_ERROR_FETCHING_CHANNEL_EXISTS",logData:{error:e},logType:yi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}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&&bi({logTitle:"PUBNUB_ERROR_REFETCHING_TOKEN",logData:{retryError:e},logType:yi.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})}),this.markEveryPreviousNoReplyMessageDone(t),n=n.concat(t.filter(e=>e.message.messageType!==ts.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&&bi({logTitle:"PUBNUB_WARN_FETCHING_HISTORY",logData:{error:e},logType:yi.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}shouldCreateAsDevState(){return location.href.startsWith("https://app.meetelise.com/settings/widgets")||location.href.includes("demo/utilities")}},as=(e,t,n)=>{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}-)\d{3}-\d{4}/g,c=/(tel|sms):(?:\+1\s)?(?:(?:\(\d{3}\)\s|\d{3}-)\d{3}-\d{4}|\d{10,11})/g,d=/whatsapp:\/\/send\?phone=\d+/g,h=/(facetime|facetime-audio):\d+/g,p=document.body.getElementsByTagName("*");let f=!1;const g=i.replace(/(\d{3})(\d{3})(\d{4})/,"($1) $2-$3");let m=!1,y=!1,b=0;for(let e=0;e<p.length;e++)if(p[e].nodeType===Node.ELEMENT_NODE){if(1===p[e].childNodes.length&&p[e].childNodes[0].nodeType==Node.TEXT_NODE){const t=p[e].textContent;if(!t)continue;const n=t.replace(u,e=>e.startsWith("+1 ")?`+1 ${g}`:g);t!==n&&(b++,p[e].textContent=n),f=!0,m||(m=!0)}if(p[e].hasAttribute("href")){const t=p[e].getAttribute("href");if(!t)continue;let n="",i=c;t.startsWith("sms:")?n=o:t.startsWith("whatsapp:")?(n=a,i=d):t.startsWith("facetime:")?(n=s,i=h):t.startsWith("facetime-audio:")?(n=l,i=h):n=r;const u=t.replace(i,n);if(p[e].setAttribute("href",u),(t.startsWith("tel:")||t.startsWith("sms:"))&&u===t&&u!==n){t.replace(/\D/g,"").length>=7&&p[e].setAttribute("href",t.startsWith("tel:")?r:o)}y||(y=!0)}}return m&&bi({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"text-insertion",newPhoneNumber:g,website:window.location.href},logType:yi.info,buildingSlug:n,orgSlug:t}),y&&bi({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"href-insertion",newPhoneNumber:g,website:window.location.href},logType:yi.info,buildingSlug:n,orgSlug:t}),f||bi({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"no-phone-number-found",website:window.location.href},logType:yi.warn,buildingSlug:n,orgSlug:t}),b};var ss=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 ls=class extends oe{constructor(){super(...arguments),this.onClick=()=>{},this.primaryColor=Le,this.toExpand=!1}render(){return B`
|
|
5536
|
+
`,ba([ue({attribute:!0})],va.prototype,"isMinimized",void 0),ba([ue()],va.prototype,"mobileStyles",void 0),ba([ue({type:Boolean})],va.prototype,"isFirstMount",void 0),ba([ue({attribute:!1})],va.prototype,"autoOpenChatWidget",void 0),ba([ue()],va.prototype,"phoneNumber",void 0),ba([ue({attribute:!0})],va.prototype,"buildingName",void 0),ba([ue({attribute:!0})],va.prototype,"chatId",void 0),ba([ue({attribute:!0})],va.prototype,"orgLegalName",void 0),ba([ue({attribute:!0})],va.prototype,"chatCallUsHeader",void 0),ba([ue({attribute:!1})],va.prototype,"buildingId",void 0),ba([ue({attribute:!0})],va.prototype,"buildingSlug",void 0),ba([ue({attribute:!0})],va.prototype,"orgSlug",void 0),ba([ue({attribute:!0})],va.prototype,"sgtUrl",void 0),ba([ue({attribute:!0})],va.prototype,"selfGuidedTourEnabled",void 0),ba([ue({attribute:!0})],va.prototype,"selfGuidedToursTypeOffered",void 0),ba([ue({attribute:!0})],va.prototype,"designConcept",void 0),ba([ue({attribute:!0})],va.prototype,"featureFlagShowDropdown",void 0),ba([ue({attribute:!1})],va.prototype,"leadSources",void 0),ba([ue({attribute:!0})],va.prototype,"currentLeadSource",void 0),ba([ue({attribute:!0})],va.prototype,"escortedToursLink",void 0),ba([ue({attribute:!0})],va.prototype,"escortedToursTypeOffered",void 0),ba([ue({attribute:!0})],va.prototype,"virtualToursLink",void 0),ba([ue({attribute:!0})],va.prototype,"virtualToursTypeOffered",void 0),ba([ue({type:Boolean})],va.prototype,"hasChatEnabledDesktop",void 0),ba([ue({type:Boolean})],va.prototype,"hasChatEnabledMobile",void 0),ba([ue({type:Boolean})],va.prototype,"hasEmailEnabledDesktop",void 0),ba([ue({type:Boolean})],va.prototype,"hasEmailEnabledMobile",void 0),ba([ue({attribute:!0})],va.prototype,"hasApplyNowEnabledDesktop",void 0),ba([ue({attribute:!0})],va.prototype,"hasApplyNowEnabledMobile",void 0),ba([ue({attribute:!0})],va.prototype,"applicationLink",void 0),ba([ue({type:Boolean})],va.prototype,"hasCallUsEnabledDesktop",void 0),ba([ue({type:Boolean})],va.prototype,"hasCallUsEnabledMobile",void 0),ba([ue({type:Boolean})],va.prototype,"hasTextUsEnabledDesktop",void 0),ba([ue({type:Boolean})],va.prototype,"hasTextUsEnabledMobile",void 0),ba([ue({type:Boolean})],va.prototype,"hasSSTEnabledDesktop",void 0),ba([ue({type:Boolean})],va.prototype,"hasSSTEnabledMobile",void 0),ba([ue({attribute:!1})],va.prototype,"tourTypeOptions",void 0),ba([ue({attribute:!0})],va.prototype,"hasDynamicSchedulingEnabled",void 0),ba([ue({attribute:!0})],va.prototype,"hasPricingCalculatorEnabledDesktop",void 0),ba([ue({attribute:!0})],va.prototype,"hasPricingCalculatorEnabledMobile",void 0),ba([ue({attribute:!1})],va.prototype,"hasHideMobileFeatures",void 0),ba([ue({type:Number})],va.prototype,"right",void 0),ba([ue({type:Number})],va.prototype,"bottom",void 0),ba([ue({type:Number})],va.prototype,"top",void 0),ba([ue({type:Number})],va.prototype,"left",void 0),ba([ue({attribute:!0})],va.prototype,"showTourNextToChat",void 0),ba([ue({attribute:!1})],va.prototype,"onChatTapped",void 0),ba([ue({attribute:!0})],va.prototype,"onClickMinimize",void 0),ba([ue({attribute:!0})],va.prototype,"onSstClose",void 0),ba([ue({attribute:!0})],va.prototype,"overrideRentgrata",void 0),ba([ue({attribute:!1})],va.prototype,"launcherStyles",void 0),ba([ue({attribute:!0})],va.prototype,"primaryColor",void 0),ba([ue({attribute:!0})],va.prototype,"backgroundColor",void 0),ba([ue({attribute:!0})],va.prototype,"foregroundColorOnPrimaryBackgroundColor",void 0),ba([ue({attribute:!0})],va.prototype,"foregroundColorOnSecondaryBackgroundColor",void 0),ba([ue({attribute:!0})],va.prototype,"leadSourceClient",void 0),ba([ce()],va.prototype,"leadSourceMultitouchClient",void 0),ba([ce()],va.prototype,"isEmailWindowOpen",void 0),ba([ce()],va.prototype,"isCallUsWindowOpen",void 0),ba([ce()],va.prototype,"isSSTWindowOpen",void 0),ba([ce()],va.prototype,"isTextUsWindowOpen",void 0),ba([ce()],va.prototype,"isCalculatorWindowOpen",void 0),ba([ce()],va.prototype,"isMobileFeaturesExpanded",void 0),va=ba([se("meetelise-launcher")],va);const wa=()=>{window.customElements.get("meetelise-launcher")||window.customElements.define("meetelise-launcher",va)},Ca=["app.meetelise.com","staging.eliseai.com","localhost"],xa={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"}},Aa=e=>{const t=window.location.hostname;if(!Ca.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 xa&&(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=xa[e];n&&(i[n.desktop]=t,i[n.mobile]=t)}),i};var Sa=n(5072),Ea=n.n(Sa),ka=n(7825),Ta=n.n(ka),_a=n(7659),Oa=n.n(_a),Pa=n(5056),Ia=n.n(Pa),Na=n(540),Ma=n.n(Na),Da=n(1113),Ua=n.n(Da),La=n(5541),Ra={};Ra.styleTagTransform=Ua(),Ra.setAttributes=Ia(),Ra.insert=Oa().bind(null,"head"),Ra.domAPI=Ta(),Ra.insertStyleElement=Ma();Ea()(La.A,Ra);La.A&&La.A.locals&&La.A.locals;async function Ba(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 ja(n.data,t)}return[]}catch(e){return[]}}const ja=(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 Fa,Ha=n(8805),$a=n.n(Ha),za=new Uint8Array(16);function Ga(){if(!Fa&&!(Fa="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 Fa(za)}const Qa=/^(?:[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 qa=function(e){return"string"==typeof e&&Qa.test(e)};for(var Wa=[],Va=0;Va<256;++Va)Wa.push((Va+256).toString(16).substr(1));const Ya=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(Wa[e[t+0]]+Wa[e[t+1]]+Wa[e[t+2]]+Wa[e[t+3]]+"-"+Wa[e[t+4]]+Wa[e[t+5]]+"-"+Wa[e[t+6]]+Wa[e[t+7]]+"-"+Wa[e[t+8]]+Wa[e[t+9]]+"-"+Wa[e[t+10]]+Wa[e[t+11]]+Wa[e[t+12]]+Wa[e[t+13]]+Wa[e[t+14]]+Wa[e[t+15]]).toLowerCase();if(!qa(n))throw TypeError("Stringified UUID is invalid");return n};const Ka=function(e,t,n){var i=(e=e||{}).random||(e.rng||Ga)();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 Ya(i)},Xa=e=>localStorage.removeItem("com.elise.webchat.slug="+e),Za=(e,t,n)=>{const i=En(new Date),r=n||`lead_${Ka()}`;return localStorage.setItem("com.elise.webchat.slug="+e,JSON.stringify({buildingSlug:e,leadId:r,timestamp:i,initiatedChat:t})),{leadId:r,timestamp:Mn(i),buildingSlug:e,initiatedChat:t}},Ja=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(es(e,i))return i}catch(e){}return{leadId:null,timestamp:null,buildingSlug:null,initiatedChat:!1}},es=(e,t)=>{try{if(t.timestamp&&t.initiatedChat){const e=new Date("2024-06-06T21:30:00Z");if(dn(t.timestamp,e))return!1}}catch(e){}return!(t.buildingSlug!==e||!t.leadId||!t.timestamp)&&!yn(t.timestamp,24)};var ts;!function(e){e.noReply="no-reply",e.text="text",e.media="media"}(ts||(ts={}));const ns=e=>e.type===rs.text,is=e=>e.type===rs.media;var rs;!function(e){e.text="text",e.media="media"}(rs||(rs={}));const os=class{constructor(e,t,n,i=null,r,o,a=null,s=Wl.Default){this.apiHost="https://app.meetelise.com",this.leadSourceClient=null,this.leadSourceMultitouchClient=null,this.buildingWebchatView=null,this.eliseResponseTimeout=null,this.isWaitingForStreamingMessages=!1,this.widgetType=Wl.Default,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;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!==ts.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===rs.text&&e.message.includes("confirmed for your"))&&ni("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(!ns(e))return!1;const t=e.chunks.find(e=>e.isDone);return!t||e.chunks.length===t.order});t&&(this.streamingMessageTimeout=setTimeout(()=>{bi({logTitle:"PUBNUB_WARN_DELAYED_STREAMING_MESSAGES",logData:{channel:this.channel},logType:yi.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;ni("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)===ts.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&&bi({logTitle:"PUBNUB_ERROR_ADDING_LISTENER",logData:{error:e,channel:this.channel,leadUserId:this.leadUserId,website:location.href},logType:yi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},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=Za(this.buildingSlug,!0,this.leadUserId);if(!await this.initializePubnub(e))return}await this.withAuthToken(async()=>{var t,n,i,r,o,a,s,l;this.pubnub&&this.channel&&(this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.eliseResponseTimeout=setTimeout(()=>{this.buildingWebchatView&&bi({logTitle:"PUBNUB_ERROR_ELISEAI_MESSAGE_TIMEOUT",logData:{channel:this.channel,leadUserId:this.leadUserId,message:e},logType:yi.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===Wl.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=>gn({...e}))}}),null===(a=this.leadSourceMultitouchClient)||void 0===a||a.resetLeadSourceTouchpoints()),this.isFirstChatMessageSent||(ni("firstChatMessageSent",{message:e,buildingId:null===(s=this.buildingWebchatView)||void 0===s?void 0:s.id,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug,leadUserId:this.leadUserId,channel:this.channel}),this.isFirstChatMessageSent=!0),ni("chatMessageSent",{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}))}),!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)?(bi({logTitle:"PUBNUB_WARN_DUPLICATE_MESSAGE",logData:{message:e,channel:this.channel},logType:yi.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:rs.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:rs.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:rs.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}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($a())({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{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&&bi({logTitle:"PUBNUB_ERROR_FETCHING_TOKEN",logData:{error:e},logType:yi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}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&&bi({logTitle:"PUBNUB_ERROR_FETCHING_CHANNEL_EXISTS",logData:{error:e},logType:yi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}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&&bi({logTitle:"PUBNUB_ERROR_REFETCHING_TOKEN",logData:{retryError:e},logType:yi.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})}),this.markEveryPreviousNoReplyMessageDone(t),n=n.concat(t.filter(e=>e.message.messageType!==ts.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&&bi({logTitle:"PUBNUB_WARN_FETCHING_HISTORY",logData:{error:e},logType:yi.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}shouldCreateAsDevState(){return location.href.startsWith("https://app.meetelise.com/settings/widgets")||location.href.includes("demo/utilities")}},as=(e,t,n)=>{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}-)\d{3}-\d{4}/g,c=/(tel|sms):(?:\+1\s)?(?:(?:\(\d{3}\)\s|\d{3}-)\d{3}-\d{4}|\d{10,11})/g,d=/whatsapp:\/\/send\?phone=\d+/g,h=/(facetime|facetime-audio):\d+/g,p=document.body.getElementsByTagName("*");let f=!1;const g=i.replace(/(\d{3})(\d{3})(\d{4})/,"($1) $2-$3");let m=!1,y=!1,b=0;for(let e=0;e<p.length;e++)if(p[e].nodeType===Node.ELEMENT_NODE){if(1===p[e].childNodes.length&&p[e].childNodes[0].nodeType==Node.TEXT_NODE){const t=p[e].textContent;if(!t)continue;const n=t.replace(u,e=>e.startsWith("+1 ")?`+1 ${g}`:g);t!==n&&(b++,p[e].textContent=n),f=!0,m||(m=!0)}if(p[e].hasAttribute("href")){const t=p[e].getAttribute("href");if(!t)continue;let n="",i=c;t.startsWith("sms:")?n=o:t.startsWith("whatsapp:")?(n=a,i=d):t.startsWith("facetime:")?(n=s,i=h):t.startsWith("facetime-audio:")?(n=l,i=h):n=r;const u=t.replace(i,n);if(p[e].setAttribute("href",u),(t.startsWith("tel:")||t.startsWith("sms:"))&&u===t&&u!==n){t.replace(/\D/g,"").length>=7&&p[e].setAttribute("href",t.startsWith("tel:")?r:o)}y||(y=!0)}}return m&&bi({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"text-insertion",newPhoneNumber:g,website:window.location.href},logType:yi.info,buildingSlug:n,orgSlug:t}),y&&bi({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"href-insertion",newPhoneNumber:g,website:window.location.href},logType:yi.info,buildingSlug:n,orgSlug:t}),f||bi({logTitle:"DNI_WEBSITE_INSERTION",logData:{type:"no-phone-number-found",website:window.location.href},logType:yi.warn,buildingSlug:n,orgSlug:t}),b};var ss=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 ls=class extends oe{constructor(){super(...arguments),this.onClick=()=>{},this.primaryColor=Le,this.toExpand=!1}render(){return B`
|
|
5537
5537
|
<div
|
|
5538
5538
|
class=${this.toExpand?"button-container mini":"button-container"}
|
|
5539
5539
|
@click=${this.onClick}
|
package/src/MyPubnub.ts
CHANGED
|
@@ -161,7 +161,7 @@ class MyPubnub {
|
|
|
161
161
|
(message) => {
|
|
162
162
|
return (
|
|
163
163
|
message.type === SimpleMessageTypes.text &&
|
|
164
|
-
message.message.includes("confirmed for your
|
|
164
|
+
message.message.includes("confirmed for your")
|
|
165
165
|
);
|
|
166
166
|
}
|
|
167
167
|
);
|
|
@@ -581,7 +581,7 @@ class MyPubnub {
|
|
|
581
581
|
orgSlug: this.orgSlug,
|
|
582
582
|
});
|
|
583
583
|
}
|
|
584
|
-
}, 90000); // if after 90 seconds, no message - we
|
|
584
|
+
}, 90000); // if after 90 seconds, no message - we erro
|
|
585
585
|
|
|
586
586
|
if (this.simpleChatMessages.length === 0) {
|
|
587
587
|
this.leadSourceClient?.checkAndHandleForLogLeadSource({
|