@meetelise/chat 1.20.121 → 1.20.122

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meetelise/chat",
3
- "version": "1.20.121",
3
+ "version": "1.20.122",
4
4
  "description": "",
5
5
  "main": "public/dist/index.js",
6
6
  "type": "module",
@@ -122,8 +122,8 @@
122
122
  // organization: "test-company",
123
123
  // building: "3fc93384-91f5-11ed-98a3-43f5a2f42588",
124
124
 
125
- organization: "TT",
126
- building: "ffc97070-5c73-11ed-8507-77860136d3bf",
125
+ // organization: "TT",
126
+ // building: "ffc97070-5c73-11ed-8507-77860136d3bf",
127
127
 
128
128
  // AMLI
129
129
  // organization: "amli",
@@ -133,8 +133,8 @@
133
133
  // building: "25fead9e-c76f-11ed-83b2-7b1e7b442e9f",
134
134
 
135
135
  // Taylor Street Apartments
136
- // organization: "test-company",
137
- // building: "e2e-test-yardi-building",
136
+ organization: "test-company",
137
+ building: "e2e-test-yardi-building",
138
138
 
139
139
  // organization: "Pacific Urban Residential",
140
140
  // building: "1ac49f90-6150-11ed-b327-1b3f05e7b9db",
@@ -3230,26 +3230,32 @@ otherwise there's some empty space at the bottom of the button, which interferes
3230
3230
  .hidden {
3231
3231
  display: none !important;
3232
3232
  }
3233
- .legalConfirmationContainer {
3233
+ .legal-confirmation-container {
3234
3234
  display: flex;
3235
3235
  flex-direction: column;
3236
3236
  gap: 16px;
3237
- justify-content: center;
3238
3237
  font-size: 14px;
3239
3238
  line-height: 22px;
3240
3239
  flex: 1;
3241
3240
  width: 100%;
3242
3241
  height: 100%;
3243
- background: rgba(193, 193, 193);
3242
+ background: #f5f5f5;
3244
3243
  overflow-y: scroll;
3245
3244
  border-top: 1px solid rgba(0, 0, 0, 0.1);
3246
3245
  border-bottom: 6px solid black;
3246
+
3247
+ padding: 12px;
3248
+ box-sizing: border-box;
3247
3249
  }
3248
3250
 
3249
- .legalConfirmationInnerContainer {
3251
+ .legal-confirmation-inner-container {
3250
3252
  margin: 0 16px;
3251
3253
  }
3252
3254
 
3255
+ .privacy-policy-link {
3256
+ color: blue;
3257
+ }
3258
+
3253
3259
  .agreeButton {
3254
3260
  background: #000;
3255
3261
  border-radius: 20px;
@@ -3307,7 +3313,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
3307
3313
  </div>
3308
3314
  </div>
3309
3315
  </a></div> `}))}
3310
- </div>`:k``}};Pr.styles=[Er],Rr([ue({attribute:!0})],Pr.prototype,"message",void 0),Rr([ue({attribute:!0})],Pr.prototype,"myPubnub",void 0),Rr([ue({attribute:!0})],Pr.prototype,"onMount",void 0),Rr([le()],Pr.prototype,"loadingPreviews",void 0),Rr([le()],Pr.prototype,"parsedMessage",void 0),Rr([le()],Pr.prototype,"websitePreviewInfo",void 0),Rr([le()],Pr.prototype,"imagesToDisplay",void 0),Rr([le()],Pr.prototype,"imageUrlError",void 0),Pr=Rr([ae("pubnub-message")],Pr);var _r=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 Fr=class extends re{constructor(){super(...arguments),this.onMount=()=>({}),this.brandColor=Fe,this.onClickExit=()=>({}),this.requiresConsent=!1,this.messages=[],this.isMobile=!1,this.isLoadingMessages=!1,this.hasReceivedConsent=!1,this.websitePreviewMapping={},this.sendMessage=async e=>{var t;this.messageInput.value="",this.autoResizeMessageInput(),await(null===(t=this.myPubnub)||void 0===t?void 0:t.sendMessage(e))},this.scrollToChatBottom=()=>{this.messageBody.scrollTo({top:this.messageBody.scrollHeight-this.messageBody.clientHeight,behavior:"smooth"})},this.autoResizeMessageInput=()=>{this.messageInput.style.height="auto",this.messageInput.style.height=this.messageInput.scrollHeight+"px"},this.needsConsent=()=>!!this.requiresConsent&&!!this.requiresConsent&&!this.hasReceivedConsent}firstUpdated(){var e,t;this.messages=(null===(e=this.myPubnub)||void 0===e?void 0:e.messages)||[],null===(t=this.myPubnub)||void 0===t||t.addChatListener((e=>{this.messages=e.messages,this.isLoadingMessages=e.isLoading})),this.onMount()}async updated(){this.scrollToChatBottom()}render(){return this.buildingSlug&&this.building?k`
3316
+ </div>`:k``}};Pr.styles=[Er],Rr([ue({attribute:!0})],Pr.prototype,"message",void 0),Rr([ue({attribute:!0})],Pr.prototype,"myPubnub",void 0),Rr([ue({attribute:!0})],Pr.prototype,"onMount",void 0),Rr([le()],Pr.prototype,"loadingPreviews",void 0),Rr([le()],Pr.prototype,"parsedMessage",void 0),Rr([le()],Pr.prototype,"websitePreviewInfo",void 0),Rr([le()],Pr.prototype,"imagesToDisplay",void 0),Rr([le()],Pr.prototype,"imageUrlError",void 0),Pr=Rr([ae("pubnub-message")],Pr);var _r=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 Fr=class extends re{constructor(){super(...arguments),this.onMount=()=>({}),this.brandColor=Fe,this.onClickExit=()=>({}),this.requiresConsent=!1,this.messages=[],this.isMobile=!1,this.isLoadingMessages=!1,this.hasReceivedConsent=!1,this.privacyPolicyUrl="http://bit.ly/me_privacy_policy",this.websitePreviewMapping={},this.sendMessage=async e=>{var t;this.messageInput.value="",this.autoResizeMessageInput(),await(null===(t=this.myPubnub)||void 0===t?void 0:t.sendMessage(e))},this.scrollToChatBottom=()=>{this.messageBody.scrollTo({top:this.messageBody.scrollHeight-this.messageBody.clientHeight,behavior:"smooth"})},this.autoResizeMessageInput=()=>{this.messageInput.style.height="auto",this.messageInput.style.height=this.messageInput.scrollHeight+"px"},this.needsConsent=()=>!!this.requiresConsent&&!!this.requiresConsent&&!this.hasReceivedConsent}firstUpdated(){var e,t;this.messages=(null===(e=this.myPubnub)||void 0===e?void 0:e.messages)||[],null===(t=this.myPubnub)||void 0===t||t.addChatListener((e=>{this.messages=e.messages,this.isLoadingMessages=e.isLoading})),this.onMount()}async updated(){this.scrollToChatBottom()}render(){return this.buildingSlug&&this.building?k`
3311
3317
  <div
3312
3318
  id="pubnub-chat-container"
3313
3319
  class=${fe({"pubnub-container__mobile":this.isMobile,"pubnub-container__desktop":!this.isMobile})}
@@ -3322,9 +3328,9 @@ otherwise there's some empty space at the bottom of the button, which interferes
3322
3328
  </button>
3323
3329
  </div>
3324
3330
  <div
3325
- class=${fe({hidden:!this.needsConsent(),legalConfirmationContainer:!0})}
3331
+ class=${fe({hidden:!this.needsConsent(),"legal-confirmation-container":!0})}
3326
3332
  >
3327
- <div class="legalConfirmationInnerContainer">
3333
+ <div class="legal-confirmation-inner-container">
3328
3334
  <div>${Li}</div>
3329
3335
  <div>
3330
3336
  <span style="font-weight: 600">Confirm to continue</span>
@@ -3334,9 +3340,10 @@ otherwise there's some empty space at the bottom of the button, which interferes
3334
3340
  collect our conversation and other information you provide,
3335
3341
  consistent with our
3336
3342
  <a
3337
- href="http://bit.ly/me_privacy_policy"
3343
+ href=${this.privacyPolicyUrl}
3338
3344
  target="_blank"
3339
3345
  rel="noopener noreferrer"
3346
+ class="privacy-policy-link"
3340
3347
  >
3341
3348
  privacy policy</a
3342
3349
  >.
@@ -3417,7 +3424,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
3417
3424
  </button>
3418
3425
  </div>
3419
3426
  </div>
3420
- `:k``}};Fr.styles=[Er],_r([ue({attribute:!0})],Fr.prototype,"onMount",void 0),_r([ue({attribute:!0})],Fr.prototype,"channel",void 0),_r([ue({attribute:!0})],Fr.prototype,"myPubnub",void 0),_r([ue({attribute:!0})],Fr.prototype,"buildingSlug",void 0),_r([ue({attribute:!0})],Fr.prototype,"building",void 0),_r([ue({attribute:!0})],Fr.prototype,"brandColor",void 0),_r([ue({attribute:!0})],Fr.prototype,"onClickExit",void 0),_r([ue({attribute:!0})],Fr.prototype,"requiresConsent",void 0),_r([de("#message-input",!0)],Fr.prototype,"messageInput",void 0),_r([de("#conversation-body",!0)],Fr.prototype,"messageBody",void 0),_r([le()],Fr.prototype,"messages",void 0),_r([le()],Fr.prototype,"isMobile",void 0),_r([le()],Fr.prototype,"isLoadingMessages",void 0),_r([le()],Fr.prototype,"hasReceivedConsent",void 0),_r([le()],Fr.prototype,"websitePreviewMapping",void 0),Fr=_r([ae("pubnub-chat")],Fr);const Mr={};var Dr=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 Ur=class extends re{constructor(){super(...arguments),this.buildingSlug="",this.orgSlug="",this.launcherStyles={},this.isMinimized=!1,this.brandColor=null,this.chatId="",this.analytics=null,this.isMobile=Un(),this.launcher=null,this.building=null,this.designConcept=null,this.leadSources=null,this.currentLeadSource=null,this.featureFlagShowDropdown=Vn.always,this.phoneNumberForSource=null,this.hasMounted=!1,this.hideLauncher=!1,this.isLoading=!0,this.showTourNextToChat=!1,this.displayPubnubChat=!1,this.myPubnub=null,this.enabledChatWidgets={call:!0,chat:!0,email:!0,text:!0,sst:!0},this.webchatConfigHasAutoOpenChat=!1,this.requiresConsent=!1,this.launcherRef=Ae(),this.firstUpdated=async()=>{await this.setBuildingDerivedInfo(),await this.initializeChatVariables(),this.handleChatInitializeAnalytics()},this.setBuildingDerivedInfo=async()=>{var e,n,i,r,o,a,s,u,l,d,c,p,h,f,m,g,v;if(!this.buildingSlug||!this.orgSlug)return;const y=await hi(this.orgSlug,this.buildingSlug);if(1!==y.active)return;const[b,w,S,T,A,x,O]=await Promise.all([vi(this.buildingSlug),cr(this.buildingSlug),yi(this.buildingSlug,document.referrer),Kn(this.buildingSlug),Xn(this.buildingSlug),gi(y.id),Yn(this.buildingSlug)]);y.phoneNumber=Ne(y.phoneNumber),this.building=y,this.designConcept=null!==(e=null==b?void 0:b.abTestType)&&void 0!==e?e:"",this.leadSources=w,this.currentLeadSource=S,this.featureFlagShowDropdown=T;const C=await(async e=>{if(Mr[e])return Mr[e];const n=`https://app.meetelise.com/sms_management_numbers/webchat/building/${e}/numbers`,i=await t().get(n);return Mr[e]=i.data,i.data})(y.id);this.enabledChatWidgets={call:x&&!x.isGlobalDefault?x.config.shouldShowPhone:null===(r=null===(i=null===(n=this.building)||void 0===n?void 0:n.chatWidgets)||void 0===i?void 0:i.includes("CALL"))||void 0===r||r,chat:x&&!x.isGlobalDefault?x.config.shouldShowChat:null===(s=null===(a=null===(o=this.building)||void 0===o?void 0:o.chatWidgets)||void 0===a?void 0:a.includes("CHAT"))||void 0===s||s,email:x&&!x.isGlobalDefault?x.config.shouldShowEmail:null===(d=null===(l=null===(u=this.building)||void 0===u?void 0:u.chatWidgets)||void 0===l?void 0:l.includes("EMAIL"))||void 0===d||d,text:(x&&!x.isGlobalDefault?x.config.shouldShowText:null===(h=null===(p=null===(c=this.building)||void 0===c?void 0:c.chatWidgets)||void 0===p?void 0:p.includes("SMS"))||void 0===h||h)&&C.length>0,sst:x&&!x.isGlobalDefault?x.config.shouldShowSst:null===(g=null===(m=null===(f=this.building)||void 0===f?void 0:f.chatWidgets)||void 0===m?void 0:m.includes("SST"))||void 0===g||g},x&&x.config&&(this.brandColor=null!==(v=x.config.primaryColor)&&void 0!==v?v:null,this.webchatConfigHasAutoOpenChat=x.config.autoOpenChat,this.requiresConsent=x.config.requiresConsent,x.config.displayStyle===fi.MINIMIZED&&(this.isMinimized=!0),x.config.displayStyle===fi.PILLS&&(this.designConcept=null),x.config.displayStyle===fi.EMOJI&&(this.designConcept=fi.EMOJI)),null===this.brandColor&&(this.brandColor=Fe);let I=null;var N;A&&(I=await async function(e,n){try{const i=await t().get(`https://app.meetelise.com/platformApi/webchat/${e}/phone-number-by-source?source=${n}`);return i.data?{number:Ne(i.data.number),isMatch:i.data.isMatch,isPropertyWebsiteCatchall:i.data.isPropertyWebsiteCatchall}:null}catch(e){return null}}(this.buildingSlug,this.currentLeadSource)),O&&(null==I?void 0:I.number)&&((e=>{const t=document.querySelectorAll('a[data-selenium-id="click_to_call"]');t&&t.forEach((t=>{"A"===t.tagName&&(t.href=`tel:${Cr(e)}`);const n=t.querySelector(".click-to-call");n&&Or(n)&&(n.textContent=e)}))})(N=I.number),(e=>{const t=document.querySelectorAll(".dvPhone");t&&t.forEach((t=>{var n;"A"===t.tagName&&(t.href=`tel:${Cr(e)}`),Or(t)&&(t.textContent=e);const i=t.nextElementSibling;if("BR"!==(null==i?void 0:i.tagName)||"A"!==(null===(n=null==i?void 0:i.nextElementSibling)||void 0===n?void 0:n.tagName))return;const r=null==i?void 0:i.nextElementSibling;r.href=`sms:${Cr(e)}`,Or(r)&&(r.textContent=`Text: ${e}`)}))})(N),(e=>{const t=document.querySelectorAll(".click_to_call_href");t&&2===t.length&&t.forEach((t=>{"A"===t.tagName&&(t.href=`tel:${Cr(e)}`);const n=t.querySelector(".click_to_call")||t.querySelector(".click_to_call_foot");n&&Or(n)&&(n.textContent=e)}))})(N)),this.phoneNumberForSource=I||{number:this.building.phoneNumber,isMatch:!1,isPropertyWebsiteCatchall:!0},this.currentLeadSource&&(this.leadSources.includes(this.currentLeadSource)||this.leadSources.push(this.currentLeadSource)),An(this.building.id)},this.initializeChatVariables=async()=>{var n;this.building&&(this.building.conversationMaintenanceMode?console.warn("MeetElise Chat is in maintenance mode. Chat icon will not appear."):(this.myPubnub=new class{constructor(e,t,n){this.apiHost="https://app.meetelise.com",this.building=null,this.ttlHours=24,this.eliseResponseTimeout=null,this.pubnub=null,this.leadUserId="",this.channel="",this.chatListener=null,this.messages=[],this.listenerParams={message:e=>{var t;e.message.messageType!==Tr.noReply&&(this.messages=[...this.messages,{channel:e.channel,message:e.message,publisher:e.publisher,subscription:e.subscription,timetoken:+e.timetoken}]);const n="eliseai"!==e.publisher;null===(t=this.chatListener)||void 0===t||t.call(this,{messages:this.messages,isLoading:n}),!n&&this.eliseResponseTimeout&&clearTimeout(this.eliseResponseTimeout),this.isLoadingMessages=n}},this.isLoadingMessages=!1,this.handleChatListeners=()=>{if(this.pubnub&&this.channel)try{this.pubnub.subscribe({channels:[this.channel]}),this.pubnub.addListener(this.listenerParams)}catch(e){pi({logTitle:"PUBNUB_ERROR_ADDING_LISTENER",logData:{error:e,channel:this.channel,leadUserId:this.leadUserId,website:location.href},logType:ci.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&&!await this.initializePubnub())return;await this.withAuthToken((async()=>{var t,n;this.pubnub&&this.channel&&(this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.eliseResponseTimeout=setTimeout((()=>{console.error("Elise AI did not respond in time..."),pi({logTitle:"PUBNUB_ERROR_ELISEAI_MESSAGE_TIMEOUT",logData:{channel:this.channel,leadUserId:this.leadUserId,message:e},logType:ci.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}),6e4),await this.pubnub.publish({channel:this.channel,message:{text:e,customType:"lead_message",buildingId:null===(t=this.building)||void 0===t?void 0:t.id,buildingSlug:this.buildingSlug,userId:null===(n=this.building)||void 0===n?void 0:n.userId}}))})),!1===this.isLoadingMessages&&(this.isLoadingMessages=!0)}},this.isLeadMessage=e=>e.publisher.includes("lead_")&&"lead_message"===e.message.customType,this.clearChatStorageKey=()=>localStorage.removeItem("com.eliseai.webchat.slug="+this.buildingSlug),this.createChatStorageKey=e=>{const t=tn(new Date),n=null!=e?e:`lead_${Sr()}_${this.buildingSlug}`;return localStorage.setItem("com.eliseai.webchat.slug="+this.buildingSlug,JSON.stringify({buildingSlug:this.buildingSlug,leadId:n,timestamp:t})),{leadId:n,timestamp:un(t),buildingSlug:this.buildingSlug}},this.getChatStorageKey=(e=!0)=>{const t=localStorage.getItem("com.eliseai.webchat.slug="+this.buildingSlug);if(t)try{const e=JSON.parse(t),n=e.buildingSlug,i=e.leadId,r=new Date(e.timestamp);if(this.isChatKeyValid({leadId:i,timestamp:r,buildingSlug:n}))return{leadId:i,timestamp:r,buildingSlug:n}}catch(e){console.warn("Error getting chat storage key")}return e?this.createChatStorageKey():{leadId:null,timestamp:null,buildingSlug:null}},this.isChatKeyValid=e=>!(e.buildingSlug!==this.buildingSlug||!e.leadId||!e.timestamp||function(e,t){ke(2,arguments);var n=qe(e),i=qe(t);return n.getTime()<i.getTime()}(xr(e.timestamp,this.ttlHours),Date.now())),this.buildingSlug=e,this.building=t,this.orgSlug=n}addChatListener(e){this.chatListener=e}async initializePubnub(){const e=this.getChatStorageKey();if(!e.leadId)return void pi({logTitle:"PUBNUB_ERROR_FETCHING_STORAGE_KEY",logData:{channel:this.channel,eliseaiLocalStorageValue:e,leadUserId:this.leadUserId},logType:ci.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});this.leadUserId=e.leadId,this.channel=`webchat_${this.leadUserId}`,e.timestamp&&function(e,t){ke(2,arguments);var n=qe(e),i=qe(t);return n.getTime()>i.getTime()}(e.timestamp,xr(new Date,this.ttlHours))&&this.createChatStorageKey(this.leadUserId);const t=await this.fetchToken(this.leadUserId,this.channel);return t?(this.pubnub=new(fr())({publishKey:t.keys.publish_key,subscribeKey:t.keys.subscribe_key,userId:this.leadUserId,authKey:t.auth.result.token}),this.withAuthToken((()=>new Promise((()=>this.handleChatListeners())))),await this.withAuthToken((()=>this.getChannelHistory())),this.pubnub):void 0}async fetchToken(e,n){try{return(await t().get(`${this.apiHost}/platformApi/webchat/pn/request-token?user_id=${e}&channel=${n}`)).data}catch(e){pi({logTitle:"PUBNUB_ERROR_FETCHING_TOKEN",logData:{error:e},logType:ci.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){pi({logTitle:"PUBNUB_ERROR_FETCHING_CHANNEL_EXISTS",logData:{error:e},logType:ci.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){pi({logTitle:"PUBNUB_ERROR_REFETCHING_TOKEN",logData:{retryError:e},logType:ci.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}}async getChannelHistory(){var e;try{const t=await new Promise(((e,t)=>{this.pubnub&&this.channel&&this.pubnub.fetchMessages({channels:[this.channel],count:100},((n,i)=>{n.error?(pi({logTitle:"PUBNUB_WARN_FETCHING_HISTORY",logData:{channel:this.channel,status:n,response:i},logType:ci.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug}),t(n)):e(i)}))}));if(this.channel&&0!==Object.keys(t.channels).length){const n=t.channels[this.channel],i=[];n.forEach((e=>{e.uuid&&i.push({channel:e.channel,message:e.message,publisher:e.uuid,subscription:e.channel,timetoken:+e.timetoken})})),this.messages=i.filter((e=>e.message.messageType!==Tr.noReply)),null===(e=this.chatListener)||void 0===e||e.call(this,{messages:this.messages,isLoading:!1})}}catch(e){pi({logTitle:"PUBNUB_WARN_FETCHING_HISTORY",logData:{error:e},logType:ci.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}}(this.buildingSlug,this.building,this.orgSlug),this.myPubnub.isChatKeyValid(this.myPubnub.getChatStorageKey(!1))&&await this.myPubnub.initializePubnub(),this.attachOnClickToLauncher(),this.shouldAutoOpenChat(null!==(n=this.building.autoOpenChatWidget)&&void 0!==n?n:this.webchatConfigHasAutoOpenChat)&&(this.displayPubnubChat=!0,this.hideLauncher=!0,this.hasMounted=!0,this.updateAlreadyAutoOpenedTimestamp()),this.isLoading=!1))},this.shouldAutoOpenChat=e=>{const t=sessionStorage.getItem("alreadyAutoOpenedTimestamp"),n=!t||!(t&&!an(un(t)));return!!e&&!!n&&!Un()},this.updateAlreadyAutoOpenedTimestamp=()=>{sessionStorage.setItem("alreadyAutoOpenedTimestamp",tn(function(e,t){ke(2,arguments);var n=et(t);return tt(e,6e4*n)}(new Date,15)))},this.handleContactClicked=e=>{var t;this.displayPubnubChat=!1,this.hideLauncher=!1,this.showTourNextToChat=!1,null===(t=this.launcherRef.value)||void 0===t||t.onClickEmailOption(e)},this.handleTourClicked=e=>{var t,n;this.showTourNextToChat?null===(t=this.launcherRef.value)||void 0===t||t.onClickSSTOption(e):(this.hideLauncher?this.showTourNextToChat=!0:this.displayPubnubChat=!1,this.hideLauncher=!1,null===(n=this.launcherRef.value)||void 0===n||n.onClickSSTOption(e))},this.handleContactTabClicked=e=>{var t;this.displayPubnubChat=!1,this.showTourNextToChat=!1,this.hideLauncher=!1,null===(t=this.launcherRef.value)||void 0===t||t.onClickPhoneOption(e)},this.adjustPositionChatAdditionalActions=()=>{var e,t,n,i;const r=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("chatAdditionalActionsPubnub");if(!r)return;const o=null===(i=null===(n=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("pubnub-chat"))||void 0===n?void 0:n.shadowRoot)||void 0===i?void 0:i.getElementById("pubnub-chat-container"),a=null==o?void 0:o.getBoundingClientRect();a&&(r.style.left=`${a.left}px`,r.style.top=`${a.bottom}px`)},this.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})},this.renderChatAdditionalActions=(e,t)=>k` <div
3427
+ `:k``}};Fr.styles=[Er],_r([ue({attribute:!0})],Fr.prototype,"onMount",void 0),_r([ue({attribute:!0})],Fr.prototype,"channel",void 0),_r([ue({attribute:!0})],Fr.prototype,"myPubnub",void 0),_r([ue({attribute:!0})],Fr.prototype,"buildingSlug",void 0),_r([ue({attribute:!0})],Fr.prototype,"building",void 0),_r([ue({attribute:!0})],Fr.prototype,"brandColor",void 0),_r([ue({attribute:!0})],Fr.prototype,"onClickExit",void 0),_r([ue({attribute:!0})],Fr.prototype,"requiresConsent",void 0),_r([de("#message-input",!0)],Fr.prototype,"messageInput",void 0),_r([de("#conversation-body",!0)],Fr.prototype,"messageBody",void 0),_r([le()],Fr.prototype,"messages",void 0),_r([le()],Fr.prototype,"isMobile",void 0),_r([le()],Fr.prototype,"isLoadingMessages",void 0),_r([le()],Fr.prototype,"hasReceivedConsent",void 0),_r([le()],Fr.prototype,"privacyPolicyUrl",void 0),_r([le()],Fr.prototype,"websitePreviewMapping",void 0),Fr=_r([ae("pubnub-chat")],Fr);const Mr={};var Dr=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 Ur=class extends re{constructor(){super(...arguments),this.buildingSlug="",this.orgSlug="",this.launcherStyles={},this.isMinimized=!1,this.brandColor=null,this.chatId="",this.analytics=null,this.isMobile=Un(),this.launcher=null,this.building=null,this.designConcept=null,this.leadSources=null,this.currentLeadSource=null,this.featureFlagShowDropdown=Vn.always,this.phoneNumberForSource=null,this.hasMounted=!1,this.hideLauncher=!1,this.isLoading=!0,this.showTourNextToChat=!1,this.displayPubnubChat=!1,this.myPubnub=null,this.enabledChatWidgets={call:!0,chat:!0,email:!0,text:!0,sst:!0},this.webchatConfigHasAutoOpenChat=!1,this.requiresConsent=!1,this.privacyPolicyUrl="http://bit.ly/me_privacy_policy",this.launcherRef=Ae(),this.firstUpdated=async()=>{await this.setBuildingDerivedInfo(),await this.initializeChatVariables(),this.handleChatInitializeAnalytics()},this.setBuildingDerivedInfo=async()=>{var e,n,i,r,o,a,s,u,l,d,c,p,h,f,m,g,v,y;if(!this.buildingSlug||!this.orgSlug)return;const b=await hi(this.orgSlug,this.buildingSlug);if(1!==b.active)return;const[w,S,T,A,x,O,C]=await Promise.all([vi(this.buildingSlug),cr(this.buildingSlug),yi(this.buildingSlug,document.referrer),Kn(this.buildingSlug),Xn(this.buildingSlug),gi(b.id),Yn(this.buildingSlug)]);b.phoneNumber=Ne(b.phoneNumber),this.building=b,this.designConcept=null!==(e=null==w?void 0:w.abTestType)&&void 0!==e?e:"",this.leadSources=S,this.currentLeadSource=T,this.featureFlagShowDropdown=A;const I=await(async e=>{if(Mr[e])return Mr[e];const n=`https://app.meetelise.com/sms_management_numbers/webchat/building/${e}/numbers`,i=await t().get(n);return Mr[e]=i.data,i.data})(b.id);this.enabledChatWidgets={call:O&&!O.isGlobalDefault?O.config.shouldShowPhone:null===(r=null===(i=null===(n=this.building)||void 0===n?void 0:n.chatWidgets)||void 0===i?void 0:i.includes("CALL"))||void 0===r||r,chat:O&&!O.isGlobalDefault?O.config.shouldShowChat:null===(s=null===(a=null===(o=this.building)||void 0===o?void 0:o.chatWidgets)||void 0===a?void 0:a.includes("CHAT"))||void 0===s||s,email:O&&!O.isGlobalDefault?O.config.shouldShowEmail:null===(d=null===(l=null===(u=this.building)||void 0===u?void 0:u.chatWidgets)||void 0===l?void 0:l.includes("EMAIL"))||void 0===d||d,text:(O&&!O.isGlobalDefault?O.config.shouldShowText:null===(h=null===(p=null===(c=this.building)||void 0===c?void 0:c.chatWidgets)||void 0===p?void 0:p.includes("SMS"))||void 0===h||h)&&I.length>0,sst:O&&!O.isGlobalDefault?O.config.shouldShowSst:null===(g=null===(m=null===(f=this.building)||void 0===f?void 0:f.chatWidgets)||void 0===m?void 0:m.includes("SST"))||void 0===g||g},O&&O.config&&(this.brandColor=null!==(v=O.config.primaryColor)&&void 0!==v?v:null,this.webchatConfigHasAutoOpenChat=O.config.autoOpenChat,this.requiresConsent=O.config.requiresConsent,this.privacyPolicyUrl=null!==(y=O.config.privacyPolicyUrl)&&void 0!==y?y:this.privacyPolicyUrl,O.config.displayStyle===fi.MINIMIZED&&(this.isMinimized=!0),O.config.displayStyle===fi.PILLS&&(this.designConcept=null),O.config.displayStyle===fi.EMOJI&&(this.designConcept=fi.EMOJI)),null===this.brandColor&&(this.brandColor=Fe);let N=null;var E;x&&(N=await async function(e,n){try{const i=await t().get(`https://app.meetelise.com/platformApi/webchat/${e}/phone-number-by-source?source=${n}`);return i.data?{number:Ne(i.data.number),isMatch:i.data.isMatch,isPropertyWebsiteCatchall:i.data.isPropertyWebsiteCatchall}:null}catch(e){return null}}(this.buildingSlug,this.currentLeadSource)),C&&(null==N?void 0:N.number)&&((e=>{const t=document.querySelectorAll('a[data-selenium-id="click_to_call"]');t&&t.forEach((t=>{"A"===t.tagName&&(t.href=`tel:${Cr(e)}`);const n=t.querySelector(".click-to-call");n&&Or(n)&&(n.textContent=e)}))})(E=N.number),(e=>{const t=document.querySelectorAll(".dvPhone");t&&t.forEach((t=>{var n;"A"===t.tagName&&(t.href=`tel:${Cr(e)}`),Or(t)&&(t.textContent=e);const i=t.nextElementSibling;if("BR"!==(null==i?void 0:i.tagName)||"A"!==(null===(n=null==i?void 0:i.nextElementSibling)||void 0===n?void 0:n.tagName))return;const r=null==i?void 0:i.nextElementSibling;r.href=`sms:${Cr(e)}`,Or(r)&&(r.textContent=`Text: ${e}`)}))})(E),(e=>{const t=document.querySelectorAll(".click_to_call_href");t&&2===t.length&&t.forEach((t=>{"A"===t.tagName&&(t.href=`tel:${Cr(e)}`);const n=t.querySelector(".click_to_call")||t.querySelector(".click_to_call_foot");n&&Or(n)&&(n.textContent=e)}))})(E)),this.phoneNumberForSource=N||{number:this.building.phoneNumber,isMatch:!1,isPropertyWebsiteCatchall:!0},this.currentLeadSource&&(this.leadSources.includes(this.currentLeadSource)||this.leadSources.push(this.currentLeadSource)),An(this.building.id)},this.initializeChatVariables=async()=>{var n;this.building&&(this.building.conversationMaintenanceMode?console.warn("MeetElise Chat is in maintenance mode. Chat icon will not appear."):(this.myPubnub=new class{constructor(e,t,n){this.apiHost="https://app.meetelise.com",this.building=null,this.ttlHours=24,this.eliseResponseTimeout=null,this.pubnub=null,this.leadUserId="",this.channel="",this.chatListener=null,this.messages=[],this.listenerParams={message:e=>{var t;e.message.messageType!==Tr.noReply&&(this.messages=[...this.messages,{channel:e.channel,message:e.message,publisher:e.publisher,subscription:e.subscription,timetoken:+e.timetoken}]);const n="eliseai"!==e.publisher;null===(t=this.chatListener)||void 0===t||t.call(this,{messages:this.messages,isLoading:n}),!n&&this.eliseResponseTimeout&&clearTimeout(this.eliseResponseTimeout),this.isLoadingMessages=n}},this.isLoadingMessages=!1,this.handleChatListeners=()=>{if(this.pubnub&&this.channel)try{this.pubnub.subscribe({channels:[this.channel]}),this.pubnub.addListener(this.listenerParams)}catch(e){pi({logTitle:"PUBNUB_ERROR_ADDING_LISTENER",logData:{error:e,channel:this.channel,leadUserId:this.leadUserId,website:location.href},logType:ci.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&&!await this.initializePubnub())return;await this.withAuthToken((async()=>{var t,n;this.pubnub&&this.channel&&(this.eliseResponseTimeout&&(clearTimeout(this.eliseResponseTimeout),this.eliseResponseTimeout=null),this.eliseResponseTimeout=setTimeout((()=>{console.error("Elise AI did not respond in time..."),pi({logTitle:"PUBNUB_ERROR_ELISEAI_MESSAGE_TIMEOUT",logData:{channel:this.channel,leadUserId:this.leadUserId,message:e},logType:ci.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}),6e4),await this.pubnub.publish({channel:this.channel,message:{text:e,customType:"lead_message",buildingId:null===(t=this.building)||void 0===t?void 0:t.id,buildingSlug:this.buildingSlug,userId:null===(n=this.building)||void 0===n?void 0:n.userId}}))})),!1===this.isLoadingMessages&&(this.isLoadingMessages=!0)}},this.isLeadMessage=e=>e.publisher.includes("lead_")&&"lead_message"===e.message.customType,this.clearChatStorageKey=()=>localStorage.removeItem("com.eliseai.webchat.slug="+this.buildingSlug),this.createChatStorageKey=e=>{const t=tn(new Date),n=null!=e?e:`lead_${Sr()}_${this.buildingSlug}`;return localStorage.setItem("com.eliseai.webchat.slug="+this.buildingSlug,JSON.stringify({buildingSlug:this.buildingSlug,leadId:n,timestamp:t})),{leadId:n,timestamp:un(t),buildingSlug:this.buildingSlug}},this.getChatStorageKey=(e=!0)=>{const t=localStorage.getItem("com.eliseai.webchat.slug="+this.buildingSlug);if(t)try{const e=JSON.parse(t),n=e.buildingSlug,i=e.leadId,r=new Date(e.timestamp);if(this.isChatKeyValid({leadId:i,timestamp:r,buildingSlug:n}))return{leadId:i,timestamp:r,buildingSlug:n}}catch(e){console.warn("Error getting chat storage key")}return e?this.createChatStorageKey():{leadId:null,timestamp:null,buildingSlug:null}},this.isChatKeyValid=e=>!(e.buildingSlug!==this.buildingSlug||!e.leadId||!e.timestamp||function(e,t){ke(2,arguments);var n=qe(e),i=qe(t);return n.getTime()<i.getTime()}(xr(e.timestamp,this.ttlHours),Date.now())),this.buildingSlug=e,this.building=t,this.orgSlug=n}addChatListener(e){this.chatListener=e}async initializePubnub(){const e=this.getChatStorageKey();if(!e.leadId)return void pi({logTitle:"PUBNUB_ERROR_FETCHING_STORAGE_KEY",logData:{channel:this.channel,eliseaiLocalStorageValue:e,leadUserId:this.leadUserId},logType:ci.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});this.leadUserId=e.leadId,this.channel=`webchat_${this.leadUserId}`,e.timestamp&&function(e,t){ke(2,arguments);var n=qe(e),i=qe(t);return n.getTime()>i.getTime()}(e.timestamp,xr(new Date,this.ttlHours))&&this.createChatStorageKey(this.leadUserId);const t=await this.fetchToken(this.leadUserId,this.channel);return t?(this.pubnub=new(fr())({publishKey:t.keys.publish_key,subscribeKey:t.keys.subscribe_key,userId:this.leadUserId,authKey:t.auth.result.token}),this.withAuthToken((()=>new Promise((()=>this.handleChatListeners())))),await this.withAuthToken((()=>this.getChannelHistory())),this.pubnub):void 0}async fetchToken(e,n){try{return(await t().get(`${this.apiHost}/platformApi/webchat/pn/request-token?user_id=${e}&channel=${n}`)).data}catch(e){pi({logTitle:"PUBNUB_ERROR_FETCHING_TOKEN",logData:{error:e},logType:ci.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){pi({logTitle:"PUBNUB_ERROR_FETCHING_CHANNEL_EXISTS",logData:{error:e},logType:ci.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){pi({logTitle:"PUBNUB_ERROR_REFETCHING_TOKEN",logData:{retryError:e},logType:ci.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}}async getChannelHistory(){var e;try{const t=await new Promise(((e,t)=>{this.pubnub&&this.channel&&this.pubnub.fetchMessages({channels:[this.channel],count:100},((n,i)=>{n.error?(pi({logTitle:"PUBNUB_WARN_FETCHING_HISTORY",logData:{channel:this.channel,status:n,response:i},logType:ci.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug}),t(n)):e(i)}))}));if(this.channel&&0!==Object.keys(t.channels).length){const n=t.channels[this.channel],i=[];n.forEach((e=>{e.uuid&&i.push({channel:e.channel,message:e.message,publisher:e.uuid,subscription:e.channel,timetoken:+e.timetoken})})),this.messages=i.filter((e=>e.message.messageType!==Tr.noReply)),null===(e=this.chatListener)||void 0===e||e.call(this,{messages:this.messages,isLoading:!1})}}catch(e){pi({logTitle:"PUBNUB_WARN_FETCHING_HISTORY",logData:{error:e},logType:ci.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}}}(this.buildingSlug,this.building,this.orgSlug),this.myPubnub.isChatKeyValid(this.myPubnub.getChatStorageKey(!1))&&await this.myPubnub.initializePubnub(),this.attachOnClickToLauncher(),this.shouldAutoOpenChat(null!==(n=this.building.autoOpenChatWidget)&&void 0!==n?n:this.webchatConfigHasAutoOpenChat)&&(this.displayPubnubChat=!0,this.hideLauncher=!0,this.hasMounted=!0,this.updateAlreadyAutoOpenedTimestamp()),this.isLoading=!1))},this.shouldAutoOpenChat=e=>{const t=sessionStorage.getItem("alreadyAutoOpenedTimestamp"),n=!t||!(t&&!an(un(t)));return!!e&&!!n&&!Un()},this.updateAlreadyAutoOpenedTimestamp=()=>{sessionStorage.setItem("alreadyAutoOpenedTimestamp",tn(function(e,t){ke(2,arguments);var n=et(t);return tt(e,6e4*n)}(new Date,15)))},this.handleContactClicked=e=>{var t;this.displayPubnubChat=!1,this.hideLauncher=!1,this.showTourNextToChat=!1,null===(t=this.launcherRef.value)||void 0===t||t.onClickEmailOption(e)},this.handleTourClicked=e=>{var t,n;this.showTourNextToChat?null===(t=this.launcherRef.value)||void 0===t||t.onClickSSTOption(e):(this.hideLauncher?this.showTourNextToChat=!0:this.displayPubnubChat=!1,this.hideLauncher=!1,null===(n=this.launcherRef.value)||void 0===n||n.onClickSSTOption(e))},this.handleContactTabClicked=e=>{var t;this.displayPubnubChat=!1,this.showTourNextToChat=!1,this.hideLauncher=!1,null===(t=this.launcherRef.value)||void 0===t||t.onClickPhoneOption(e)},this.adjustPositionChatAdditionalActions=()=>{var e,t,n,i;const r=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("chatAdditionalActionsPubnub");if(!r)return;const o=null===(i=null===(n=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("pubnub-chat"))||void 0===n?void 0:n.shadowRoot)||void 0===i?void 0:i.getElementById("pubnub-chat-container"),a=null==o?void 0:o.getBoundingClientRect();a&&(r.style.left=`${a.left}px`,r.style.top=`${a.bottom}px`)},this.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})},this.renderChatAdditionalActions=(e,t)=>k` <div
3421
3428
  id=${e}
3422
3429
  class=${fe({showTab:t,hideTab:!t})}
3423
3430
  >
@@ -3458,6 +3465,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
3458
3465
  .onMount=${()=>{this.adjustPositionChatAdditionalActions()}}
3459
3466
  .isMobile=${this.isMobile}
3460
3467
  .requiresConsent=${this.requiresConsent}
3468
+ .privacyPolicyUrl=${this.privacyPolicyUrl}
3461
3469
  ></pubnub-chat>
3462
3470
  ${this.renderChatAdditionalActions("chatAdditionalActionsPubnub",N||this.showTourNextToChat)}
3463
3471
  `:""}
@@ -3554,4 +3562,4 @@ otherwise there's some empty space at the bottom of the button, which interferes
3554
3562
  position: fixed;
3555
3563
  bottom: 0;
3556
3564
  }
3557
- `,Dr([ue({type:String})],Ur.prototype,"buildingSlug",void 0),Dr([ue({type:String})],Ur.prototype,"orgSlug",void 0),Dr([ue({type:Object})],Ur.prototype,"launcherStyles",void 0),Dr([ue({type:Boolean})],Ur.prototype,"isMinimized",void 0),Dr([ue({type:String})],Ur.prototype,"brandColor",void 0),Dr([le()],Ur.prototype,"chatId",void 0),Dr([le()],Ur.prototype,"analytics",void 0),Dr([le()],Ur.prototype,"isMobile",void 0),Dr([le()],Ur.prototype,"launcher",void 0),Dr([le()],Ur.prototype,"building",void 0),Dr([le()],Ur.prototype,"designConcept",void 0),Dr([le()],Ur.prototype,"leadSources",void 0),Dr([le()],Ur.prototype,"currentLeadSource",void 0),Dr([le()],Ur.prototype,"featureFlagShowDropdown",void 0),Dr([le()],Ur.prototype,"phoneNumberForSource",void 0),Dr([le()],Ur.prototype,"hasMounted",void 0),Dr([le()],Ur.prototype,"hideLauncher",void 0),Dr([le()],Ur.prototype,"isLoading",void 0),Dr([le()],Ur.prototype,"showTourNextToChat",void 0),Dr([le()],Ur.prototype,"displayPubnubChat",void 0),Dr([le()],Ur.prototype,"myPubnub",void 0),Dr([le()],Ur.prototype,"enabledChatWidgets",void 0),Dr([le()],Ur.prototype,"webchatConfigHasAutoOpenChat",void 0),Dr([le()],Ur.prototype,"requiresConsent",void 0),Ur=Dr([ae("me-chat")],Ur);class kr{static start(e,t=!0){if(window.location.pathname.includes("residentservices")||window.location.pathname.includes("onlineleasing"))return;t&&(this.orgSlug=e.organization,this.hasBuildingSlug=!!e.building),qr();const n=document.createElement("me-chat");n.setAttribute("orgSlug",e.organization),this.handleBuildingslug(n,e.building),n.setAttribute("class","meetelise-chat"),n.setAttribute("role","dialog"),n.setAttribute("aria-label","EliseAI Widget"),n.setAttribute("aria-describedby","aria-describe-info"),n.setAttribute("aria-modal","true"),e.launcherStyles&&(n.launcherStyles=e.launcherStyles),e.brandColor&&(this.brandColor=e.brandColor,n.setAttribute("brandColor",((e,t)=>{const n=(r=e,{r:parseInt(r.substring(1,3),16),g:parseInt(r.substring(3,5),16),b:parseInt(r.substring(5,7),16)}),i={r:n.r+Math.round(.3*(0-n.r)),g:n.g+Math.round(.3*(0-n.g)),b:n.b+Math.round(.3*(0-n.b))};var r;return((e,t,n)=>"#"+[e,t,n].map((e=>{const t=e.toString(16);return 1===t.length?"0"+t:t})).join(""))(i.r,i.g,i.b)})(e.brandColor))),document.body.appendChild(n),kr.meChat=n,e.building&&e.organization&&Lr(e.organization,e.building)}static async restartConversation(){this.meChat&&await this.meChat.restartConversation()}static async remove(){this.meChat&&(await this.meChat.remove(),document.body.removeChild(this.meChat),kr.meChat=null)}static async handleBuildingslug(e,t){t?e.setAttribute("buildingSlug",t):this.mutationObserver||(this.handleSingleFamilyUrl(),this.previousUrl=window.location.href,document.body.addEventListener("click",(()=>{requestAnimationFrame((()=>{this.previousUrl===window.location.href||this.hasBuildingSlug||(this.previousUrl=window.location.href,this.handleSingleFamilyUrl())}))}),!0))}static async handleSingleFamilyUrl(){if(this.hasBuildingSlug)return;this.remove();const e=window.location.href,n=`https://app.meetelise.com/platformApi/webchat/microsite_slug?uri=${encodeURIComponent(e)}`,i=await t().get(n,{headers:{"org-slug":this.orgSlug}});if(!i||!i.data)return;const r={organization:this.orgSlug,building:i.data,brandColor:this.brandColor};this.start(r,!1)}}kr.meChat=null,kr.orgSlug="",kr.mutationObserver=null,kr.previousUrl="",kr.hasBuildingSlug=null,kr.brandColor="";const qr=()=>{const e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("type","text/css"),document.head.appendChild(e)},Br=e=>{for(const t of e){const e=document.getElementById(t);if(e)return e}return null},Lr=async(e,n)=>{var i;if(!n||!e)return;const r=await async function(e){if(!e)return!1;try{return(await t().get(Wn(e),{params:{building_slug:e,flag_type:"bool",feature_flag:"webchat-use-override-contact-us-form",default_str:null,default_bool:!1}})).data}catch(e){return!1}}(n);if(!r)return;const o=Br(["myContactForm","contactus"]);let a;if(!(o&&o instanceof HTMLFormElement)){const t=document.querySelector("form");return void(window.location.pathname.toLowerCase().includes("contactus")&&Jr(n,e,"Could not find form",t?{id:t.id}:void 0))}for(let e=0;e<o.elements.length;e++){const t=o.elements[e];if("button"===t.tagName.toLowerCase()&&"fakebutton"===t.getAttribute("data-selenium-id")){a=t;break}}if(!a)return Jr(n,e,"Could not find submit button");const s=()=>({firstName:Br(["firstname","txtName"]),lastName:Br(["lastname","txtName2"]),email:Br(["email","txtEmail"]),phone:Br(["phonenumber","txtPhone"]),message:Br(["message","txtComments"])});if(Object.values(s()).some((e=>null===e))){const t=Object.entries(s()).filter((([,e])=>null===e)).map((([e])=>e));return Jr(n,e,"Missing the following form elements: "+t.join(", "))}const u=a.textContent,l=a.cloneNode(!0);null===(i=a.parentNode)||void 0===i||i.replaceChild(l,a),l.onclick=async function(t){if(Object.values(s()).forEach((e=>{"true"!==(null==e?void 0:e.getAttribute("aria-required"))||e.value||(e.className="form-control required is-invalid")})),!Object.values(s()).every((e=>null!==e&&!("true"===e.getAttribute("aria-required")&&!e.value)&&("email"!==e.id&&"phonenumber"!==e.id||"true"!==e.getAttribute("aria-invalid")))))return;t.preventDefault(),l.textContent="Processing request...",l.disabled=!0;const i={};Object.entries(s()).forEach((([e,t])=>i[e]=null==t?void 0:t.value));const r=await hi(e,n),a=await yi(n,document.referrer);if(!r)return Jr(n,e,"Could not find building"),null;const d={email_address:i.email,first_name:i.firstName,last_name:i.lastName,phone_number:i.phone,first_message:i.message,building_id:r.id,is_external_form:!0,lead_sources:[...new Set(a?[a,"property-website"]:["property-website"])]},c=JSON.stringify(d);fetch("https://app.meetelise.com/platformApi/state/create/contactMe",{method:"POST",headers:{"Content-Type":"application/json","building-slug":n,"org-slug":e},body:c}).then((e=>{if(!e.ok)throw new Error(`HTTP error ${e.status}`);return o&&o.reset(),Object.values(s()).forEach((e=>{e&&(e.disabled=!0)})),l.textContent="Submitted",l.disabled=!0,e.json()})).catch((()=>{l.textContent=u}))}},Jr=(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})}})();var r=i.Z;export{r as default};
3565
+ `,Dr([ue({type:String})],Ur.prototype,"buildingSlug",void 0),Dr([ue({type:String})],Ur.prototype,"orgSlug",void 0),Dr([ue({type:Object})],Ur.prototype,"launcherStyles",void 0),Dr([ue({type:Boolean})],Ur.prototype,"isMinimized",void 0),Dr([ue({type:String})],Ur.prototype,"brandColor",void 0),Dr([le()],Ur.prototype,"chatId",void 0),Dr([le()],Ur.prototype,"analytics",void 0),Dr([le()],Ur.prototype,"isMobile",void 0),Dr([le()],Ur.prototype,"launcher",void 0),Dr([le()],Ur.prototype,"building",void 0),Dr([le()],Ur.prototype,"designConcept",void 0),Dr([le()],Ur.prototype,"leadSources",void 0),Dr([le()],Ur.prototype,"currentLeadSource",void 0),Dr([le()],Ur.prototype,"featureFlagShowDropdown",void 0),Dr([le()],Ur.prototype,"phoneNumberForSource",void 0),Dr([le()],Ur.prototype,"hasMounted",void 0),Dr([le()],Ur.prototype,"hideLauncher",void 0),Dr([le()],Ur.prototype,"isLoading",void 0),Dr([le()],Ur.prototype,"showTourNextToChat",void 0),Dr([le()],Ur.prototype,"displayPubnubChat",void 0),Dr([le()],Ur.prototype,"myPubnub",void 0),Dr([le()],Ur.prototype,"enabledChatWidgets",void 0),Dr([le()],Ur.prototype,"webchatConfigHasAutoOpenChat",void 0),Dr([le()],Ur.prototype,"requiresConsent",void 0),Dr([le()],Ur.prototype,"privacyPolicyUrl",void 0),Ur=Dr([ae("me-chat")],Ur);class kr{static start(e,t=!0){if(window.location.pathname.includes("residentservices")||window.location.pathname.includes("onlineleasing"))return;t&&(this.orgSlug=e.organization,this.hasBuildingSlug=!!e.building),qr();const n=document.createElement("me-chat");n.setAttribute("orgSlug",e.organization),this.handleBuildingslug(n,e.building),n.setAttribute("class","meetelise-chat"),n.setAttribute("role","dialog"),n.setAttribute("aria-label","EliseAI Widget"),n.setAttribute("aria-describedby","aria-describe-info"),n.setAttribute("aria-modal","true"),e.launcherStyles&&(n.launcherStyles=e.launcherStyles),e.brandColor&&(this.brandColor=e.brandColor,n.setAttribute("brandColor",((e,t)=>{const n=(r=e,{r:parseInt(r.substring(1,3),16),g:parseInt(r.substring(3,5),16),b:parseInt(r.substring(5,7),16)}),i={r:n.r+Math.round(.3*(0-n.r)),g:n.g+Math.round(.3*(0-n.g)),b:n.b+Math.round(.3*(0-n.b))};var r;return((e,t,n)=>"#"+[e,t,n].map((e=>{const t=e.toString(16);return 1===t.length?"0"+t:t})).join(""))(i.r,i.g,i.b)})(e.brandColor))),document.body.appendChild(n),kr.meChat=n,e.building&&e.organization&&Lr(e.organization,e.building)}static async restartConversation(){this.meChat&&await this.meChat.restartConversation()}static async remove(){this.meChat&&(await this.meChat.remove(),document.body.removeChild(this.meChat),kr.meChat=null)}static async handleBuildingslug(e,t){t?e.setAttribute("buildingSlug",t):this.mutationObserver||(this.handleSingleFamilyUrl(),this.previousUrl=window.location.href,document.body.addEventListener("click",(()=>{requestAnimationFrame((()=>{this.previousUrl===window.location.href||this.hasBuildingSlug||(this.previousUrl=window.location.href,this.handleSingleFamilyUrl())}))}),!0))}static async handleSingleFamilyUrl(){if(this.hasBuildingSlug)return;this.remove();const e=window.location.href,n=`https://app.meetelise.com/platformApi/webchat/microsite_slug?uri=${encodeURIComponent(e)}`,i=await t().get(n,{headers:{"org-slug":this.orgSlug}});if(!i||!i.data)return;const r={organization:this.orgSlug,building:i.data,brandColor:this.brandColor};this.start(r,!1)}}kr.meChat=null,kr.orgSlug="",kr.mutationObserver=null,kr.previousUrl="",kr.hasBuildingSlug=null,kr.brandColor="";const qr=()=>{const e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("type","text/css"),document.head.appendChild(e)},Br=e=>{for(const t of e){const e=document.getElementById(t);if(e)return e}return null},Lr=async(e,n)=>{var i;if(!n||!e)return;const r=await async function(e){if(!e)return!1;try{return(await t().get(Wn(e),{params:{building_slug:e,flag_type:"bool",feature_flag:"webchat-use-override-contact-us-form",default_str:null,default_bool:!1}})).data}catch(e){return!1}}(n);if(!r)return;const o=Br(["myContactForm","contactus"]);let a;if(!(o&&o instanceof HTMLFormElement)){const t=document.querySelector("form");return void(window.location.pathname.toLowerCase().includes("contactus")&&Jr(n,e,"Could not find form",t?{id:t.id}:void 0))}for(let e=0;e<o.elements.length;e++){const t=o.elements[e];if("button"===t.tagName.toLowerCase()&&"fakebutton"===t.getAttribute("data-selenium-id")){a=t;break}}if(!a)return Jr(n,e,"Could not find submit button");const s=()=>({firstName:Br(["firstname","txtName"]),lastName:Br(["lastname","txtName2"]),email:Br(["email","txtEmail"]),phone:Br(["phonenumber","txtPhone"]),message:Br(["message","txtComments"])});if(Object.values(s()).some((e=>null===e))){const t=Object.entries(s()).filter((([,e])=>null===e)).map((([e])=>e));return Jr(n,e,"Missing the following form elements: "+t.join(", "))}const u=a.textContent,l=a.cloneNode(!0);null===(i=a.parentNode)||void 0===i||i.replaceChild(l,a),l.onclick=async function(t){if(Object.values(s()).forEach((e=>{"true"!==(null==e?void 0:e.getAttribute("aria-required"))||e.value||(e.className="form-control required is-invalid")})),!Object.values(s()).every((e=>null!==e&&!("true"===e.getAttribute("aria-required")&&!e.value)&&("email"!==e.id&&"phonenumber"!==e.id||"true"!==e.getAttribute("aria-invalid")))))return;t.preventDefault(),l.textContent="Processing request...",l.disabled=!0;const i={};Object.entries(s()).forEach((([e,t])=>i[e]=null==t?void 0:t.value));const r=await hi(e,n),a=await yi(n,document.referrer);if(!r)return Jr(n,e,"Could not find building"),null;const d={email_address:i.email,first_name:i.firstName,last_name:i.lastName,phone_number:i.phone,first_message:i.message,building_id:r.id,is_external_form:!0,lead_sources:[...new Set(a?[a,"property-website"]:["property-website"])]},c=JSON.stringify(d);fetch("https://app.meetelise.com/platformApi/state/create/contactMe",{method:"POST",headers:{"Content-Type":"application/json","building-slug":n,"org-slug":e},body:c}).then((e=>{if(!e.ok)throw new Error(`HTTP error ${e.status}`);return o&&o.reset(),Object.values(s()).forEach((e=>{e&&(e.disabled=!0)})),l.textContent="Submitted",l.disabled=!0,e.json()})).catch((()=>{l.textContent=u}))}},Jr=(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})}})();var r=i.Z;export{r as default};
@@ -166,6 +166,9 @@ export class MEChat extends LitElement {
166
166
  @state()
167
167
  private requiresConsent = false;
168
168
 
169
+ @state()
170
+ private privacyPolicyUrl = "http://bit.ly/me_privacy_policy";
171
+
169
172
  launcherRef: Ref<Launcher> = createRef();
170
173
 
171
174
  firstUpdated = async (): Promise<void> => {
@@ -239,6 +242,8 @@ export class MEChat extends LitElement {
239
242
  this.brandColor = webchatSettings.config.primaryColor ?? null;
240
243
  this.webchatConfigHasAutoOpenChat = webchatSettings.config.autoOpenChat;
241
244
  this.requiresConsent = webchatSettings.config.requiresConsent;
245
+ this.privacyPolicyUrl =
246
+ webchatSettings.config.privacyPolicyUrl ?? this.privacyPolicyUrl;
242
247
 
243
248
  if (webchatSettings.config.displayStyle === DesignConcepts.MINIMIZED) {
244
249
  // this.designConcept = DesignConcepts.MINIMIZED; // uncomment this if we want to remove the minimize/expand option
@@ -489,6 +494,7 @@ export class MEChat extends LitElement {
489
494
  }}
490
495
  .isMobile=${this.isMobile}
491
496
  .requiresConsent=${this.requiresConsent}
497
+ .privacyPolicyUrl=${this.privacyPolicyUrl}
492
498
  ></pubnub-chat>
493
499
  ${this.renderChatAdditionalActions(
494
500
  "chatAdditionalActionsPubnub",
@@ -265,26 +265,32 @@ export const pubnubChatStyles = css`
265
265
  .hidden {
266
266
  display: none !important;
267
267
  }
268
- .legalConfirmationContainer {
268
+ .legal-confirmation-container {
269
269
  display: flex;
270
270
  flex-direction: column;
271
271
  gap: 16px;
272
- justify-content: center;
273
272
  font-size: 14px;
274
273
  line-height: 22px;
275
274
  flex: 1;
276
275
  width: 100%;
277
276
  height: 100%;
278
- background: rgba(193, 193, 193);
277
+ background: #f5f5f5;
279
278
  overflow-y: scroll;
280
279
  border-top: 1px solid rgba(0, 0, 0, 0.1);
281
280
  border-bottom: 6px solid black;
281
+
282
+ padding: 12px;
283
+ box-sizing: border-box;
282
284
  }
283
285
 
284
- .legalConfirmationInnerContainer {
286
+ .legal-confirmation-inner-container {
285
287
  margin: 0 16px;
286
288
  }
287
289
 
290
+ .privacy-policy-link {
291
+ color: blue;
292
+ }
293
+
288
294
  .agreeButton {
289
295
  background: #000;
290
296
  border-radius: 20px;
@@ -59,6 +59,9 @@ export class PubnubChat extends LitElement {
59
59
  @state()
60
60
  hasReceivedConsent = false;
61
61
 
62
+ @state()
63
+ privacyPolicyUrl = "http://bit.ly/me_privacy_policy";
64
+
62
65
  @state()
63
66
  websitePreviewMapping: {
64
67
  [messageId: string]: {
@@ -142,10 +145,10 @@ export class PubnubChat extends LitElement {
142
145
  <div
143
146
  class=${classMap({
144
147
  ["hidden"]: !this.needsConsent(),
145
- ["legalConfirmationContainer"]: true,
148
+ ["legal-confirmation-container"]: true,
146
149
  })}
147
150
  >
148
- <div class="legalConfirmationInnerContainer">
151
+ <div class="legal-confirmation-inner-container">
149
152
  <div>${HeyThereEmoji}</div>
150
153
  <div>
151
154
  <span style="font-weight: 600">Confirm to continue</span>
@@ -155,9 +158,10 @@ export class PubnubChat extends LitElement {
155
158
  collect our conversation and other information you provide,
156
159
  consistent with our
157
160
  <a
158
- href="http://bit.ly/me_privacy_policy"
161
+ href=${this.privacyPolicyUrl}
159
162
  target="_blank"
160
163
  rel="noopener noreferrer"
164
+ class="privacy-policy-link"
161
165
  >
162
166
  privacy policy</a
163
167
  >.
@@ -16,6 +16,7 @@ export interface WebchatConfigurationPreferences {
16
16
  displayStyle: DesignConcepts;
17
17
  primaryColor: string;
18
18
  requiresConsent: boolean;
19
+ privacyPolicyUrl: string;
19
20
  }
20
21
 
21
22
  export enum DesignConcepts {