@meetelise/chat 1.20.212 → 1.20.213

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.212",
3
+ "version": "1.20.213",
4
4
  "description": "",
5
5
  "main": "public/dist/index.js",
6
6
  "type": "module",
@@ -132,8 +132,8 @@
132
132
 
133
133
  MEChat.start({
134
134
  organization: "test-company",
135
- building: "test-yardi-building",
136
- // building: "3fc93384-91f5-11ed-98a3-43f5a2f42588",
135
+ //building: "test-yardi-building",
136
+ building: "3fc93384-91f5-11ed-98a3-43f5a2f42588",
137
137
  onWidgetLoaded: onWidgetLoaded,
138
138
  // organization: "00f18938-9632-40b9-8d7f-f30e219c94fc",
139
139
  // building: "19e21cda-d05b-11ee-b3bd-cf9cc1ace7e5",
@@ -3530,7 +3530,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
3530
3530
  </div>
3531
3531
  </div>
3532
3532
  </a></div> `}))}
3533
- </div>`:U``}};Lr.styles=[pn,qr],Br([ue({attribute:!0})],Lr.prototype,"message",void 0),Br([ue({attribute:!0})],Lr.prototype,"myPubnub",void 0),Br([ue({attribute:!0})],Lr.prototype,"onMount",void 0),Br([le()],Lr.prototype,"loadingPreviews",void 0),Br([le()],Lr.prototype,"parsedMessage",void 0),Br([le()],Lr.prototype,"websitePreviewInfo",void 0),Br([le()],Lr.prototype,"imagesToDisplay",void 0),Br([le()],Lr.prototype,"imageUrlError",void 0),Lr=Br([ae("pubnub-message")],Lr);var Jr=864e5;function jr(e,t){Ue(2,arguments);var n=gn(e),i=gn(t),r=n.getTime()-Et(n),o=i.getTime()-Et(i);return Math.round((r-o)/Jr)}function Hr(e,t){var n=e.getFullYear()-t.getFullYear()||e.getMonth()-t.getMonth()||e.getDate()-t.getDate()||e.getHours()-t.getHours()||e.getMinutes()-t.getMinutes()||e.getSeconds()-t.getSeconds()||e.getMilliseconds()-t.getMilliseconds();return n<0?-1:n>0?1:n}var Gr=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a};let zr=class extends re{constructor(){super(...arguments),this.right=void 0,this.bottom=void 0,this.top=void 0,this.left=void 0,this.onMount=()=>({}),this.isHealthChat=!1,this.brandColor=Fe,this.onClickExit=()=>{localStorage.setItem("isChatOpen","false")},this.requiresConsent=!1,this.messages=[],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.hasReceivedConsent}get consentKey(){return`${this.orgSlug}Consent`}firstUpdated(){var e,t;this.messages=(null===(e=this.myPubnub)||void 0===e?void 0:e.simpleChatMessages)||[],null===(t=this.myPubnub)||void 0===t||t.addChatListener((e=>{this.messages=e.messages,this.isLoadingMessages=e.isLoading})),this.onMount();const n=localStorage.getItem(this.consentKey);if(!n)return void(this.hasReceivedConsent=!1);const i=JSON.parse(n),{timestamp:r,consentId:o}=i,a=function(e,t){Ue(2,arguments);var n=qe(e),i=qe(t),r=Hr(n,i),o=Math.abs(jr(n,i));n.setDate(n.getDate()-r*o);var a=Number(Hr(n,i)===-r),s=r*(o-a);return 0===s?0:s}(new Date,new Date(r));a<7&&o===Wr?this.hasReceivedConsent=!0:(this.hasReceivedConsent=!1,localStorage.removeItem(this.consentKey))}async updated(){this.scrollToChatBottom();try{const e=document.getElementById("#healthchat-container");if(!e)return;e.focus()}catch(e){console.error(e)}}render(){var e,t,n,i;if(!this.buildingSlug)return U``;let r={};if(r=ln()?{top:void 0,bottom:0,left:void 0,right:0}:{top:void 0===this.top||isNaN(this.top)?void 0:`${this.top}px`,bottom:void 0===this.bottom||isNaN(this.bottom)?"130px":`${this.bottom}px`,left:void 0===this.left||isNaN(this.left)?void 0:`${this.left}px`,right:void 0===this.right||isNaN(this.right)?"18px":`${this.right}px`},this.isHealthChat)return U`
3533
+ </div>`:U``}};Lr.styles=[pn,qr],Br([ue({attribute:!0})],Lr.prototype,"message",void 0),Br([ue({attribute:!0})],Lr.prototype,"myPubnub",void 0),Br([ue({attribute:!0})],Lr.prototype,"onMount",void 0),Br([le()],Lr.prototype,"loadingPreviews",void 0),Br([le()],Lr.prototype,"parsedMessage",void 0),Br([le()],Lr.prototype,"websitePreviewInfo",void 0),Br([le()],Lr.prototype,"imagesToDisplay",void 0),Br([le()],Lr.prototype,"imageUrlError",void 0),Lr=Br([ae("pubnub-message")],Lr);var Jr=864e5;function jr(e,t){Ue(2,arguments);var n=gn(e),i=gn(t),r=n.getTime()-Et(n),o=i.getTime()-Et(i);return Math.round((r-o)/Jr)}function Hr(e,t){var n=e.getFullYear()-t.getFullYear()||e.getMonth()-t.getMonth()||e.getDate()-t.getDate()||e.getHours()-t.getHours()||e.getMinutes()-t.getMinutes()||e.getSeconds()-t.getSeconds()||e.getMilliseconds()-t.getMilliseconds();return n<0?-1:n>0?1:n}var Gr=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a};let zr=class extends re{constructor(){super(...arguments),this.right=void 0,this.bottom=void 0,this.top=void 0,this.left=void 0,this.onMount=()=>({}),this.isHealthChat=!1,this.brandColor=Fe,this.onClickExit=()=>{localStorage.setItem("isChatOpen","false")},this.requiresConsent=!1,this.messages=[],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(),0===this.messages.length&&(this.messages=[{timestamp:0,message:e,isLeadMessage:!0,chunks:[{text:e,order:0,isDone:!0}]}]),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.hasReceivedConsent}get consentKey(){return`${this.orgSlug}Consent`}firstUpdated(){var e,t;this.messages=(null===(e=this.myPubnub)||void 0===e?void 0:e.simpleChatMessages)||[],null===(t=this.myPubnub)||void 0===t||t.addChatListener((e=>{this.messages=e.messages,this.isLoadingMessages=e.isLoading})),this.onMount();const n=localStorage.getItem(this.consentKey);if(!n)return void(this.hasReceivedConsent=!1);const i=JSON.parse(n),{timestamp:r,consentId:o}=i,a=function(e,t){Ue(2,arguments);var n=qe(e),i=qe(t),r=Hr(n,i),o=Math.abs(jr(n,i));n.setDate(n.getDate()-r*o);var a=Number(Hr(n,i)===-r),s=r*(o-a);return 0===s?0:s}(new Date,new Date(r));a<7&&o===Wr?this.hasReceivedConsent=!0:(this.hasReceivedConsent=!1,localStorage.removeItem(this.consentKey))}async updated(){this.scrollToChatBottom();try{const e=document.getElementById("#healthchat-container");if(!e)return;e.focus()}catch(e){console.error(e)}}render(){var e,t,n,i;if(!this.buildingSlug)return U``;let r={};if(r=ln()?{top:void 0,bottom:0,left:void 0,right:0}:{top:void 0===this.top||isNaN(this.top)?void 0:`${this.top}px`,bottom:void 0===this.bottom||isNaN(this.bottom)?"130px":`${this.bottom}px`,left:void 0===this.left||isNaN(this.left)?void 0:`${this.left}px`,right:void 0===this.right||isNaN(this.right)?"18px":`${this.right}px`},this.isHealthChat)return U`
3534
3534
  <div
3535
3535
  id="healthchat-container"
3536
3536
  class=${fe({"pubnub-container__mobile":ln(),"healthchat-container__desktop":!ln()})}
@@ -111,6 +111,19 @@ export class PubnubChat extends LitElement {
111
111
  sendMessage = async (message: string): Promise<void> => {
112
112
  this.messageInput.value = "";
113
113
  this.autoResizeMessageInput();
114
+
115
+ // The first message triggers a channel creation which can take a few seconds,
116
+ // so we immediately add the message to the UI to avoid a delay.
117
+ if (this.messages.length === 0) {
118
+ this.messages = [
119
+ {
120
+ timestamp: 0,
121
+ message,
122
+ isLeadMessage: true,
123
+ chunks: [{ text: message, order: 0, isDone: true }],
124
+ },
125
+ ];
126
+ }
114
127
  await this.myPubnub?.sendMessage(message);
115
128
  };
116
129
  firstUpdated(): void {