@meetelise/chat 1.20.239 → 1.20.240

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.239",
3
+ "version": "1.20.240",
4
4
  "description": "",
5
5
  "main": "public/dist/index.js",
6
6
  "type": "module",
@@ -3621,19 +3621,19 @@ otherwise there's some empty space at the bottom of the button, which interferes
3621
3621
  transform: rotate(360deg);
3622
3622
  }
3623
3623
  }
3624
- `,Vr=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}([ae("mini-loader")],Vr);var Qr=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 Kr=class extends re{constructor(){super(...arguments),this.onMount=()=>({}),this.loadingPreviews=!0,this.websitePreviewInfo=[],this.imagesToDisplay=[],this.imageUrlError=[],this.isLeadMessage=!1}isMessageStillStreamingChunks(){if(!this.message)return!1;const e=this.message.chunks.find((e=>e.isDone));return!e||this.message.chunks.length===e.order}updated(e){if(this.onMount(),!e.has("message"))return;if(!this.message)return;try{!this.isLeadMessage&&this.invalidMarkdownText(this.message.message)&&si({logType:ai.error,logTitle:"IMPROPER_MARKDOWN",logData:{message:this.message.message}})}catch(e){console.error("Error parsing markdown:",e)}const{hyperlinks:t,markedText:n}=this.mapAndMarkHyperLinks(this.message.message),i=/(https?:\/\/[^\s]+)/g,r=[],o=[];this.parsedMessage=U`${n.trim().split("\n").map((e=>{const n=this.sanitizeMarkdownText(e),a=this.preserveHTMLTags(n);return a?U`${a.map((e=>{if(t.find((t=>t.id===e))){const n=t.find((t=>t.id===e));if(!n)return;return o.push({redirectTo:null==n?void 0:n.link,source:null==n?void 0:n.link}),U`<a
3624
+ `,Vr=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}([ae("mini-loader")],Vr);var Qr=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 Kr=class extends re{constructor(){super(...arguments),this.onMount=()=>({}),this.loadingPreviews=!0,this.websitePreviewInfo=[],this.imagesToDisplay=[],this.imageUrlError=[],this.isLeadMessage=!1}isMessageStillStreamingChunks(){if(!this.message)return!1;const e=this.message.chunks.find((e=>e.isDone));return!e||this.message.chunks.length===e.order}updated(e){var t;if(this.onMount(),!e.has("message"))return;if(!this.message)return;try{!this.isLeadMessage&&this.invalidMarkdownText(this.message.message)&&si({logType:ai.error,logTitle:"IMPROPER_MARKDOWN",logData:{message:this.message.message,chatId:null===(t=this.myPubnub)||void 0===t?void 0:t.channel},buildingSlug:this.buildingSlug})}catch(e){console.error("Error parsing markdown:",e)}const{hyperlinks:n,markedText:i}=this.mapAndMarkHyperLinks(this.message.message),r=/(https?:\/\/[^\s]+)/g,o=[],a=[];this.parsedMessage=U`${i.trim().split("\n").map((e=>{const t=this.sanitizeMarkdownText(e),i=this.preserveHTMLTags(t);return i?U`${i.map((e=>{if(n.find((t=>t.id===e))){const t=n.find((t=>t.id===e));if(!t)return;return a.push({redirectTo:null==t?void 0:t.link,source:null==t?void 0:t.link}),U`<a
3625
3625
  class="redirect-link"
3626
- href="${null==n?void 0:n.link}"
3626
+ href="${null==t?void 0:t.link}"
3627
3627
  target="_blank"
3628
3628
  rel="noopener noreferrer"
3629
- >${null==n?void 0:n.hyperlink}
3630
- </a>`}if(i.test(e)){const t=this.removeTrailingPunctuation(e);return r.push(this.getLinkData(t)),U`<a
3629
+ >${null==t?void 0:t.hyperlink}
3630
+ </a>`}if(r.test(e)){const t=this.removeTrailingPunctuation(e);return o.push(this.getLinkData(t)),U`<a
3631
3631
  class="redirect-link"
3632
3632
  href="${t}"
3633
3633
  target="_blank"
3634
3634
  rel="noopener noreferrer"
3635
3635
  >${t}
3636
- </a>`}return U`${Wr(Gr().sanitize(e))} `}))}<br />`:U``}))}`,this.imagesToDisplay=o,Promise.all(r).then((e=>{this.websitePreviewInfo=e}))}invalidMarkdownText(e){try{return[/\*\*[^*]*$/,/__[^_]*$/,/`[^`]*$/,/\[[^\]]*$/,/\[[^\]]*\]\([^)]*$/,/^(#+)\s*$/,/(^|[^!])\[[^\]]*\]\(([^)]+)\s*$/,/(?:^|\s)[*_]{1,2}(?:\s|$)/].some((t=>t.test(e)))}catch(e){return!1}}preserveHTMLTags(e){var t;const n=e.match(/(<\/?[a-z][^>]*>[^<]*<\/?[a-z]*>|[^\s]+[.,?!]?|\S)/gi);return null!==(t=null==n?void 0:n.filter((e=>""!==e.trim())))&&void 0!==t?t:[]}sanitizeMarkdownText(e){return e.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*?)\*\*/gim,"<b>$1</b>").replace(/\*(.*?)\*/gim,"<i>$1</i>").trim()}removeTrailingPunctuation(e){return[".",",","!","?",":",";"].includes(e[e.length-1])?this.removeTrailingPunctuation(e.slice(0,-1)):e}mapAndMarkHyperLinks(e){const t=Array.from(e.matchAll(/<https?:\/\/[^|]+\|[^>]+>|<a href="[^"]+"(?: target="[^"]*")?>[^<]+<\/a>|\[.*?\]\([^)]*\.[^)]*\)/g)),n=[],i=t.map((t=>{const n=t[0];if(void 0===t.index)return;const i=e[t.index-1],r=e[t.index+n.length];if(n.startsWith("<https")||n.startsWith("<http"))return{matchedLink:n,link:n.split("|")[0].replace("<",""),hyperlink:n.split("|")[1].replace(">",""),addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)};if(n.startsWith("<a href=")){const e=n.match(/href="([^"]+)"/),t=n.match(/>[^<]+</);return{matchedLink:n,link:e?e[1]:"",hyperlink:t?t[0].slice(1,-1):"",addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)}}{const[e,t]=n.split("](");return{matchedLink:n,link:t?t.slice(0,-1):"",hyperlink:e?e.slice(1):"",addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)}}}));return i.forEach((t=>{if(t&&t.link&&t.hyperlink){const i=Ir().replace(/-/g,"");n.push({link:this.removeTrailingPunctuation(t.link),hyperlink:this.removeTrailingPunctuation(t.hyperlink),mark:t.matchedLink,id:i}),e=e.replace(t.matchedLink,`${t.addSpaceBefore?" ":""}${i}${t.addSpaceAfter?" ":""}`)}})),{hyperlinks:n,markedText:e}}async getLinkData(e){var n,i,r,o;try{const a=(await t().get(e)).data,s=(new DOMParser).parseFromString(a,"text/html");return s?{title:null!==(i=null===(n=s.querySelector("title"))||void 0===n?void 0:n.textContent)&&void 0!==i?i:null,description:(null===(r=s.querySelector('meta[name="description"]'))||void 0===r?void 0:r.getAttribute("content"))||null,image:(null===(o=s.querySelector('meta[property="og:image"]'))||void 0===o?void 0:o.getAttribute("content"))||null,favicon:null,link:e}:{title:null,description:null,image:null,favicon:null,link:e}}catch(t){return console.error("Error fetching website details:",t),{title:null,description:null,image:null,favicon:null,link:e}}}render(){return this.message?U`<div class="message-inner-body">
3636
+ </a>`}return U`${Wr(Gr().sanitize(e))} `}))}<br />`:U``}))}`,this.imagesToDisplay=a,Promise.all(o).then((e=>{this.websitePreviewInfo=e}))}invalidMarkdownText(e){try{return[/\*\*[^*]*$/,/__[^_]*$/,/`[^`]*$/,/\[[^\]]*$/,/\[[^\]]*\]\([^)]*$/,/^(#+)\s*$/,/(^|[^!])\[[^\]]*\]\(([^)]+)\s*$/,/(?:^|\s)[*_]{1,2}(?:\s|$)/].some((t=>t.test(e)))}catch(e){return!1}}preserveHTMLTags(e){var t;const n=e.match(/(<\/?[a-z][^>]*>[^<]*<\/?[a-z]*>|[^\s]+[.,?!]?|\S)/gi);return null!==(t=null==n?void 0:n.filter((e=>""!==e.trim())))&&void 0!==t?t:[]}sanitizeMarkdownText(e){return e.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*?)\*\*/gim,"<b>$1</b>").replace(/\*(.*?)\*/gim,"<i>$1</i>").trim()}removeTrailingPunctuation(e){return[".",",","!","?",":",";"].includes(e[e.length-1])?this.removeTrailingPunctuation(e.slice(0,-1)):e}mapAndMarkHyperLinks(e){const t=Array.from(e.matchAll(/<https?:\/\/[^|]+\|[^>]+>|<a href="[^"]+"(?: target="[^"]*")?>[^<]+<\/a>|\[.*?\]\([^)]*\.[^)]*\)/g)),n=[],i=t.map((t=>{const n=t[0];if(void 0===t.index)return;const i=e[t.index-1],r=e[t.index+n.length];if(n.startsWith("<https")||n.startsWith("<http"))return{matchedLink:n,link:n.split("|")[0].replace("<",""),hyperlink:n.split("|")[1].replace(">",""),addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)};if(n.startsWith("<a href=")){const e=n.match(/href="([^"]+)"/),t=n.match(/>[^<]+</);return{matchedLink:n,link:e?e[1]:"",hyperlink:t?t[0].slice(1,-1):"",addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)}}{const[e,t]=n.split("](");return{matchedLink:n,link:t?t.slice(0,-1):"",hyperlink:e?e.slice(1):"",addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)}}}));return i.forEach((t=>{if(t&&t.link&&t.hyperlink){const i=Ir().replace(/-/g,"");n.push({link:this.removeTrailingPunctuation(t.link),hyperlink:this.removeTrailingPunctuation(t.hyperlink),mark:t.matchedLink,id:i}),e=e.replace(t.matchedLink,`${t.addSpaceBefore?" ":""}${i}${t.addSpaceAfter?" ":""}`)}})),{hyperlinks:n,markedText:e}}async getLinkData(e){var n,i,r,o;try{const a=(await t().get(e)).data,s=(new DOMParser).parseFromString(a,"text/html");return s?{title:null!==(i=null===(n=s.querySelector("title"))||void 0===n?void 0:n.textContent)&&void 0!==i?i:null,description:(null===(r=s.querySelector('meta[name="description"]'))||void 0===r?void 0:r.getAttribute("content"))||null,image:(null===(o=s.querySelector('meta[property="og:image"]'))||void 0===o?void 0:o.getAttribute("content"))||null,favicon:null,link:e}:{title:null,description:null,image:null,favicon:null,link:e}}catch(t){return console.error("Error fetching website details:",t),{title:null,description:null,image:null,favicon:null,link:e}}}render(){return this.message?U`<div class="message-inner-body">
3637
3637
  ${this.isMessageStillStreamingChunks()?U`<div class="message-loader"><mini-loader></mini-loader></div>`:""}
3638
3638
  <p
3639
3639
  class=${fe({"message-text":!0,"webchat-font__desktop":!dn(),"webchat-font__mobile":dn()})}
@@ -3685,7 +3685,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
3685
3685
  bottom: -2px;
3686
3686
  right: -2px;
3687
3687
  }
3688
- `],Qr([ue({attribute:!0})],Kr.prototype,"message",void 0),Qr([ue({attribute:!0})],Kr.prototype,"myPubnub",void 0),Qr([ue({attribute:!0})],Kr.prototype,"onMount",void 0),Qr([le()],Kr.prototype,"loadingPreviews",void 0),Qr([le()],Kr.prototype,"parsedMessage",void 0),Qr([le()],Kr.prototype,"websitePreviewInfo",void 0),Qr([le()],Kr.prototype,"imagesToDisplay",void 0),Qr([le()],Kr.prototype,"imageUrlError",void 0),Qr([ue({type:Boolean})],Kr.prototype,"isLeadMessage",void 0),Kr=Qr([ae("pubnub-message")],Kr);var Xr=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 Yr=class extends re{constructor(){super(...arguments),this.onMount=()=>({}),this.showMediaAsCarousel=!0,this.activeIndex=0}updated(e){this.onMount(),e.has("message")}prevImage(){this.message&&(0===this.activeIndex?this.activeIndex=this.message.media.length-1:this.activeIndex-=1)}nextImage(){this.message&&(this.activeIndex===this.message.media.length-1?this.activeIndex=0:this.activeIndex+=1)}render(){return this.message?this.showMediaAsCarousel?U`<div class="message-inner-body">
3688
+ `],Qr([ue({attribute:!0})],Kr.prototype,"buildingSlug",void 0),Qr([ue({attribute:!0})],Kr.prototype,"message",void 0),Qr([ue({attribute:!0})],Kr.prototype,"myPubnub",void 0),Qr([ue({attribute:!0})],Kr.prototype,"onMount",void 0),Qr([le()],Kr.prototype,"loadingPreviews",void 0),Qr([le()],Kr.prototype,"parsedMessage",void 0),Qr([le()],Kr.prototype,"websitePreviewInfo",void 0),Qr([le()],Kr.prototype,"imagesToDisplay",void 0),Qr([le()],Kr.prototype,"imageUrlError",void 0),Qr([ue({type:Boolean})],Kr.prototype,"isLeadMessage",void 0),Kr=Qr([ae("pubnub-message")],Kr);var Xr=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 Yr=class extends re{constructor(){super(...arguments),this.onMount=()=>({}),this.showMediaAsCarousel=!0,this.activeIndex=0}updated(e){this.onMount(),e.has("message")}prevImage(){this.message&&(0===this.activeIndex?this.activeIndex=this.message.media.length-1:this.activeIndex-=1)}nextImage(){this.message&&(this.activeIndex===this.message.media.length-1?this.activeIndex=0:this.activeIndex+=1)}render(){return this.message?this.showMediaAsCarousel?U`<div class="message-inner-body">
3689
3689
  <div class="carousel">
3690
3690
  <div
3691
3691
  class="image-container"
@@ -3888,6 +3888,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
3888
3888
  .myPubnub=${this.myPubnub}
3889
3889
  .onMount=${()=>this.scrollToChatBottom()}
3890
3890
  .isLeadMessage=${e.isLeadMessage}
3891
+ .buildingSlug=${this.buildingSlug}
3891
3892
  >
3892
3893
  </pubnub-message>`:""}
3893
3894
  </li>
@@ -3984,6 +3985,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
3984
3985
  .myPubnub=${this.myPubnub}
3985
3986
  .onMount=${()=>this.scrollToChatBottom()}
3986
3987
  .isLeadMessage=${e.isLeadMessage}
3988
+ .buildingSlug=${this.buildingSlug}
3987
3989
  >
3988
3990
  </pubnub-message>`:""}
3989
3991
  </li>
@@ -324,6 +324,7 @@ export class PubnubChat extends LitElement {
324
324
  .myPubnub=${this.myPubnub}
325
325
  .onMount=${() => this.scrollToChatBottom()}
326
326
  .isLeadMessage=${message.isLeadMessage}
327
+ .buildingSlug=${this.buildingSlug}
327
328
  >
328
329
  </pubnub-message>`
329
330
  : ""}
@@ -490,6 +491,7 @@ export class PubnubChat extends LitElement {
490
491
  .myPubnub=${this.myPubnub}
491
492
  .onMount=${() => this.scrollToChatBottom()}
492
493
  .isLeadMessage=${message.isLeadMessage}
494
+ .buildingSlug=${this.buildingSlug}
493
495
  >
494
496
  </pubnub-message>`
495
497
  : ""}
@@ -41,6 +41,9 @@ export class PubnubMessage extends LitElement {
41
41
  `,
42
42
  ];
43
43
 
44
+ @property({ attribute: true })
45
+ buildingSlug: string | undefined;
46
+
44
47
  @property({
45
48
  attribute: true,
46
49
  })
@@ -94,9 +97,12 @@ export class PubnubMessage extends LitElement {
94
97
  sendLoggingEvent({
95
98
  logType: LogType.error,
96
99
  logTitle: "IMPROPER_MARKDOWN",
97
- logData: { message: this.message.message },
100
+ logData: {
101
+ message: this.message.message,
102
+ chatId: this.myPubnub?.channel,
103
+ },
104
+ buildingSlug: this.buildingSlug,
98
105
  });
99
- //return html``;
100
106
  }
101
107
  } catch (error) {
102
108
  // eslint-disable-next-line no-console