@meetelise/chat 1.20.131 → 1.20.133
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
package/public/demo/index.html
CHANGED
|
@@ -122,6 +122,9 @@
|
|
|
122
122
|
organization: "test-company",
|
|
123
123
|
building: "3fc93384-91f5-11ed-98a3-43f5a2f42588",
|
|
124
124
|
|
|
125
|
+
// organization: "d1a1060d-3844-48d4-a454-1ba26292bc69",
|
|
126
|
+
// building: "25feb690-c76f-11ed-83b9-a7aa9698a486",
|
|
127
|
+
|
|
125
128
|
// organization: "TT",
|
|
126
129
|
// building: "ffc97070-5c73-11ed-8507-77860136d3bf",
|
|
127
130
|
|
|
@@ -157,7 +160,7 @@
|
|
|
157
160
|
// building: "1ac49f90-6150-11ed-b327-1b3f05e7b9db",
|
|
158
161
|
|
|
159
162
|
// organization: "sparrow",
|
|
160
|
-
// building: "
|
|
163
|
+
// building: "8e87ae6e-eae8-11ed-aae8-fb82f4692a79",
|
|
161
164
|
});
|
|
162
165
|
</script>
|
|
163
166
|
<main>
|
package/public/dist/index.js
CHANGED
|
@@ -473,7 +473,7 @@ var e={8005:function(e,t,n){var i,r=this&&this.__extends||(i=function(e,t){retur
|
|
|
473
473
|
.option.active {
|
|
474
474
|
background-color: var(--active-option-color);
|
|
475
475
|
}
|
|
476
|
-
`,Zt],$t([ue({attribute:!1})],en.prototype,"options",void 0),$t([ue({type:String})],en.prototype,"placeholder",void 0),$t([ue({type:String})],en.prototype,"value",void 0),$t([le()],en.prototype,"activeOption",void 0),$t([le()],en.prototype,"isOpen",void 0),$t([de("#select",!0)],en.prototype,"meSelect",void 0),en=$t([ae("me-select")],en);var nn=n(9991),rn=n(7739),on=n.n(rn);function an(e){return ke(1,arguments),qe(e).getTime()<Date.now()}Math.pow(10,8);var sn=36e5;function un(e,t){ke(1,arguments);var n=t||{},i=null==n.additionalDigits?2:et(n.additionalDigits);if(2!==i&&1!==i&&0!==i)throw new RangeError("additionalDigits must be 0, 1 or 2");if("string"!=typeof e&&"[object String]"!==Object.prototype.toString.call(e))return new Date(NaN);var r,o=hn(e);if(o.date){var a=fn(o.date,i);r=mn(a.restDateString,a.year)}if(!r||isNaN(r.getTime()))return new Date(NaN);var s,u=r.getTime(),l=0;if(o.time&&(l=vn(o.time),isNaN(l)))return new Date(NaN);if(!o.timezone){var d=new Date(u+l),c=new Date(0);return c.setFullYear(d.getUTCFullYear(),d.getUTCMonth(),d.getUTCDate()),c.setHours(d.getUTCHours(),d.getUTCMinutes(),d.getUTCSeconds(),d.getUTCMilliseconds()),c}return s=bn(o.timezone),isNaN(s)?new Date(NaN):new Date(u+l+s)}var ln={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},dn=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,cn=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,pn=/^([+-])(\d{2})(?::?(\d{2}))?$/;function hn(e){var t,n={},i=e.split(ln.dateTimeDelimiter);if(i.length>2)return n;if(/:/.test(i[0])?t=i[0]:(n.date=i[0],t=i[1],ln.timeZoneDelimiter.test(n.date)&&(n.date=e.split(ln.timeZoneDelimiter)[0],t=e.substr(n.date.length,e.length))),t){var r=ln.timezone.exec(t);r?(n.time=t.replace(r[1],""),n.timezone=r[1]):n.time=t}return n}function fn(e,t){var n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),i=e.match(n);if(!i)return{year:NaN,restDateString:""};var r=i[1]?parseInt(i[1]):null,o=i[2]?parseInt(i[2]):null;return{year:null===o?r:100*o,restDateString:e.slice((i[1]||i[2]).length)}}function mn(e,t){if(null===t)return new Date(NaN);var n=e.match(dn);if(!n)return new Date(NaN);var i=!!n[4],r=gn(n[1]),o=gn(n[2])-1,a=gn(n[3]),s=gn(n[4]),u=gn(n[5])-1;if(i)return function(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}(0,s,u)?function(e,t,n){var i=new Date(0);i.setUTCFullYear(e,0,4);var r=7*(t-1)+n+1-(i.getUTCDay()||7);return i.setUTCDate(i.getUTCDate()+r),i}(t,s,u):new Date(NaN);var l=new Date(0);return function(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(wn[t]||(Sn(e)?29:28))}(t,o,a)&&function(e,t){return t>=1&&t<=(Sn(e)?366:365)}(t,r)?(l.setUTCFullYear(t,o,Math.max(r,a)),l):new Date(NaN)}function gn(e){return e?parseInt(e):1}function vn(e){var t=e.match(cn);if(!t)return NaN;var n=yn(t[1]),i=yn(t[2]),r=yn(t[3]);return function(e,t,n){return 24===e?0===t&&0===n:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}(n,i,r)?n*sn+6e4*i+1e3*r:NaN}function yn(e){return e&&parseFloat(e.replace(",","."))||0}function bn(e){if("Z"===e)return 0;var t=e.match(pn);if(!t)return 0;var n="+"===t[1]?-1:1,i=parseInt(t[2]),r=t[3]&&parseInt(t[3])||0;return function(e,t){return t>=0&&t<=59}(0,r)?n*(i*sn+6e4*r):NaN}var wn=[31,null,31,30,31,30,31,31,30,31,30,31];function Sn(e){return e%400==0||e%4==0&&e%100!=0}const Tn={buildingId:null,availabilities:{}},An=async e=>{e&&(Tn.buildingId=e);const n=Tn.buildingId;if(!n)throw new Error("No buildingId was provided to getRawAvailabilities and there is no buildingId cached.");const i=Tn.availabilities;if(i[n])return i[n];const r=function(e){ke(1,arguments);var t=qe(e);return t.setHours(0,0,0,0),t}(Date.now()),o=tn(function(e){ke(1,arguments);var t=qe(e);return t.setHours(23,59,59,999),t}(function(e,t){ke(2,arguments);var n=qe(e),i=et(t);return isNaN(i)?new Date(NaN):i?(n.setDate(n.getDate()+i),n):n}(r,30))),a=`https://app.meetelise.com/api/pub/v1/buildings/${n}/tour/availabilities?startTime=${tn(r)}&endTime=${o}`,s=await t().get(a);return Tn.availabilities[n]=s.data,s.data},xn=async(e,t)=>{var n,i;const r=await An(t),o=(null===(n=r.availability)||void 0===n?void 0:n[e])?null===(i=r.availability)||void 0===i?void 0:i[e].availableTourStartTimes:[];return r.availability?{...r.availability[e],availableTourStartTimes:o}:null},On=async(e,t)=>{var n,i;const r=await xn(e,t);if(!r)return{};const o={availableTourStartTimes:null===(n=r.availableTourStartTimes?r.availableTourStartTimes.filter((e=>Je(un(e))&&!an(un(e)))):[])||void 0===n?void 0:n.map((e=>Cn(e)))};return on()(null!==(i=o.availableTourStartTimes)&&void 0!==i?i:[],(e=>Lt(new Date(e.datetime),"yyyy-MM-dd")))},Cn=e=>({datetime:e.slice(0,19),offset:e.slice(19)});n(7294);var In=n(8929),Nn=n.n(In),En=n(1469),Rn=n.n(En),Pn=n(3218),_n=n.n(Pn),Fn=n(8718),Mn=n.n(Fn);const Dn=(e,t)=>Mn()(e,((e,n,i,r)=>{e[(null==t?void 0:t.includes(i))||Rn()(r)?i:Nn()(String(i))]=_n()(n)?Dn(n,t):n})),Un=()=>window.matchMedia("(max-width: 767px)").matches;var kn=n(1763),qn=n.n(kn),Bn=n(6604),Ln=n.n(Bn),Jn=n(7037),jn=n.n(Jn),Hn=n(4184),Gn=n.n(Hn);async function zn({chatId:e,website:n,referrer:i,buildingSlug:r,selectedLeadSource:o}){try{return(await t().post("https://app.meetelise.com/platformApi/webchat/lead-sourced",{chat_id:e,website:n,referrer:i,query_params:Qn(),building_slug:r,timestamp:new Date,selected_lead_source:o})).data}catch(e){return null}}function Qn(){return Object.fromEntries(new URLSearchParams(window.location.search))}const Wn=e=>`https://app.meetelise.com/platformApi/webchat/${e}/chat-ui-feature-flag`;var Vn;async function Kn(e){if(!e)return Vn.always;try{const n=await t().get(Wn(e),{params:{building_slug:e,flag_type:"string",feature_flag:"webchat-marketing-source-dropdown-configuration",default_str:"always",default_bool:!0}});return"on-attribution-failure"===n.data?Vn.onAttributionFailure:"never"===n.data?Vn.never:Vn.always}catch(e){return Vn.always}}async function Xn(e){if(!e)return!1;try{return(await t().get(Wn(e),{params:{building_slug:e,flag_type:"bool",feature_flag:"webchat-use-dni-phone-number-by-source",default_str:null,default_bool:!1}})).data}catch(e){return!1}}async function Yn(e){if(!e)return!1;try{return(await t().get(Wn(e),{params:{building_slug:e,flag_type:"bool",feature_flag:"webchat-insert-dni-into-website",default_str:null,default_bool:!1}})).data}catch(e){return!1}}!function(e){e.onAttributionFailure="on-attribution-failure",e.never="never",e.always="always"}(Vn||(Vn={}));const Zn=(e,t={})=>{window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:e,...t})},$n={fontSize:"10px",paddingTop:"4px"},ei={color:"#4287f5"},ti=({buildingName:e,phoneNumberInput:t,emailInput:n})=>t?k` <div style=${_e($n)}>
|
|
476
|
+
`,Zt],$t([ue({attribute:!1})],en.prototype,"options",void 0),$t([ue({type:String})],en.prototype,"placeholder",void 0),$t([ue({type:String})],en.prototype,"value",void 0),$t([le()],en.prototype,"activeOption",void 0),$t([le()],en.prototype,"isOpen",void 0),$t([de("#select",!0)],en.prototype,"meSelect",void 0),en=$t([ae("me-select")],en);var nn=n(9991),rn=n(7739),on=n.n(rn);function an(e){return ke(1,arguments),qe(e).getTime()<Date.now()}Math.pow(10,8);var sn=36e5;function un(e,t){ke(1,arguments);var n=t||{},i=null==n.additionalDigits?2:et(n.additionalDigits);if(2!==i&&1!==i&&0!==i)throw new RangeError("additionalDigits must be 0, 1 or 2");if("string"!=typeof e&&"[object String]"!==Object.prototype.toString.call(e))return new Date(NaN);var r,o=hn(e);if(o.date){var a=fn(o.date,i);r=mn(a.restDateString,a.year)}if(!r||isNaN(r.getTime()))return new Date(NaN);var s,u=r.getTime(),l=0;if(o.time&&(l=vn(o.time),isNaN(l)))return new Date(NaN);if(!o.timezone){var d=new Date(u+l),c=new Date(0);return c.setFullYear(d.getUTCFullYear(),d.getUTCMonth(),d.getUTCDate()),c.setHours(d.getUTCHours(),d.getUTCMinutes(),d.getUTCSeconds(),d.getUTCMilliseconds()),c}return s=bn(o.timezone),isNaN(s)?new Date(NaN):new Date(u+l+s)}var ln={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},dn=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,cn=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,pn=/^([+-])(\d{2})(?::?(\d{2}))?$/;function hn(e){var t,n={},i=e.split(ln.dateTimeDelimiter);if(i.length>2)return n;if(/:/.test(i[0])?t=i[0]:(n.date=i[0],t=i[1],ln.timeZoneDelimiter.test(n.date)&&(n.date=e.split(ln.timeZoneDelimiter)[0],t=e.substr(n.date.length,e.length))),t){var r=ln.timezone.exec(t);r?(n.time=t.replace(r[1],""),n.timezone=r[1]):n.time=t}return n}function fn(e,t){var n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),i=e.match(n);if(!i)return{year:NaN,restDateString:""};var r=i[1]?parseInt(i[1]):null,o=i[2]?parseInt(i[2]):null;return{year:null===o?r:100*o,restDateString:e.slice((i[1]||i[2]).length)}}function mn(e,t){if(null===t)return new Date(NaN);var n=e.match(dn);if(!n)return new Date(NaN);var i=!!n[4],r=gn(n[1]),o=gn(n[2])-1,a=gn(n[3]),s=gn(n[4]),u=gn(n[5])-1;if(i)return function(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}(0,s,u)?function(e,t,n){var i=new Date(0);i.setUTCFullYear(e,0,4);var r=7*(t-1)+n+1-(i.getUTCDay()||7);return i.setUTCDate(i.getUTCDate()+r),i}(t,s,u):new Date(NaN);var l=new Date(0);return function(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(wn[t]||(Sn(e)?29:28))}(t,o,a)&&function(e,t){return t>=1&&t<=(Sn(e)?366:365)}(t,r)?(l.setUTCFullYear(t,o,Math.max(r,a)),l):new Date(NaN)}function gn(e){return e?parseInt(e):1}function vn(e){var t=e.match(cn);if(!t)return NaN;var n=yn(t[1]),i=yn(t[2]),r=yn(t[3]);return function(e,t,n){return 24===e?0===t&&0===n:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}(n,i,r)?n*sn+6e4*i+1e3*r:NaN}function yn(e){return e&&parseFloat(e.replace(",","."))||0}function bn(e){if("Z"===e)return 0;var t=e.match(pn);if(!t)return 0;var n="+"===t[1]?-1:1,i=parseInt(t[2]),r=t[3]&&parseInt(t[3])||0;return function(e,t){return t>=0&&t<=59}(0,r)?n*(i*sn+6e4*r):NaN}var wn=[31,null,31,30,31,30,31,31,30,31,30,31];function Sn(e){return e%400==0||e%4==0&&e%100!=0}const Tn={buildingId:null,availabilities:{}},An=async e=>{e&&(Tn.buildingId=e);const n=Tn.buildingId;if(!n)throw new Error("No buildingId was provided to getRawAvailabilities and there is no buildingId cached.");const i=Tn.availabilities;if(i[n])return i[n];const r=function(e){ke(1,arguments);var t=qe(e);return t.setHours(0,0,0,0),t}(Date.now()),o=tn(function(e){ke(1,arguments);var t=qe(e);return t.setHours(23,59,59,999),t}(function(e,t){ke(2,arguments);var n=qe(e),i=et(t);return isNaN(i)?new Date(NaN):i?(n.setDate(n.getDate()+i),n):n}(r,30))),a=`https://app.meetelise.com/api/pub/v1/buildings/${n}/tour/availabilities?startTime=${encodeURIComponent(tn(r))}&endTime=${encodeURIComponent(o)}`,s=await t().get(a);return Tn.availabilities[n]=s.data,s.data},xn=async(e,t)=>{var n,i;const r=await An(t),o=(null===(n=r.availability)||void 0===n?void 0:n[e])?null===(i=r.availability)||void 0===i?void 0:i[e].availableTourStartTimes:[];return r.availability?{...r.availability[e],availableTourStartTimes:o}:null},On=async(e,t)=>{var n,i;const r=await xn(e,t);if(!r)return{};const o={availableTourStartTimes:null===(n=r.availableTourStartTimes?r.availableTourStartTimes.filter((e=>Je(un(e))&&!an(un(e)))):[])||void 0===n?void 0:n.map((e=>Cn(e)))};return on()(null!==(i=o.availableTourStartTimes)&&void 0!==i?i:[],(e=>Lt(new Date(e.datetime),"yyyy-MM-dd")))},Cn=e=>({datetime:e.slice(0,19),offset:e.slice(19)});n(7294);var In=n(8929),Nn=n.n(In),En=n(1469),Rn=n.n(En),Pn=n(3218),_n=n.n(Pn),Fn=n(8718),Mn=n.n(Fn);const Dn=(e,t)=>Mn()(e,((e,n,i,r)=>{e[(null==t?void 0:t.includes(i))||Rn()(r)?i:Nn()(String(i))]=_n()(n)?Dn(n,t):n})),Un=()=>window.matchMedia("(max-width: 767px)").matches;var kn=n(1763),qn=n.n(kn),Bn=n(6604),Ln=n.n(Bn),Jn=n(7037),jn=n.n(Jn),Hn=n(4184),Gn=n.n(Hn);async function zn({chatId:e,website:n,referrer:i,buildingSlug:r,selectedLeadSource:o}){try{return(await t().post("https://app.meetelise.com/platformApi/webchat/lead-sourced",{chat_id:e,website:n,referrer:i,query_params:Qn(),building_slug:r,timestamp:new Date,selected_lead_source:o})).data}catch(e){return null}}function Qn(){return Object.fromEntries(new URLSearchParams(window.location.search))}const Wn=e=>`https://app.meetelise.com/platformApi/webchat/${e}/chat-ui-feature-flag`;var Vn;async function Kn(e){if(!e)return Vn.always;try{const n=await t().get(Wn(e),{params:{building_slug:e,flag_type:"string",feature_flag:"webchat-marketing-source-dropdown-configuration",default_str:"always",default_bool:!0}});return"on-attribution-failure"===n.data?Vn.onAttributionFailure:"never"===n.data?Vn.never:Vn.always}catch(e){return Vn.always}}async function Xn(e){if(!e)return!1;try{return(await t().get(Wn(e),{params:{building_slug:e,flag_type:"bool",feature_flag:"webchat-use-dni-phone-number-by-source",default_str:null,default_bool:!1}})).data}catch(e){return!1}}async function Yn(e){if(!e)return!1;try{return(await t().get(Wn(e),{params:{building_slug:e,flag_type:"bool",feature_flag:"webchat-insert-dni-into-website",default_str:null,default_bool:!1}})).data}catch(e){return!1}}!function(e){e.onAttributionFailure="on-attribution-failure",e.never="never",e.always="always"}(Vn||(Vn={}));const Zn=(e,t={})=>{window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:e,...t})},$n={fontSize:"10px",paddingTop:"4px"},ei={color:"#4287f5"},ti=({buildingName:e,phoneNumberInput:t,emailInput:n})=>t?k` <div style=${_e($n)}>
|
|
477
477
|
By providing your number and clicking submit, you consent to recurring
|
|
478
478
|
marketing text messages from or for
|
|
479
479
|
${e.length>0?e:"this building"} at this
|
|
@@ -3159,7 +3159,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
|
|
|
3159
3159
|
display: none;
|
|
3160
3160
|
}
|
|
3161
3161
|
.redirect-link {
|
|
3162
|
-
color:
|
|
3162
|
+
color: inherit;
|
|
3163
3163
|
}
|
|
3164
3164
|
|
|
3165
3165
|
#loading-message {
|
|
@@ -3277,7 +3277,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
|
|
|
3277
3277
|
-webkit-line-clamp: 2;
|
|
3278
3278
|
overflow: hidden;
|
|
3279
3279
|
text-overflow: ellipsis;
|
|
3280
|
-
height: 24px;
|
|
3280
|
+
max-height: 24px;
|
|
3281
3281
|
}
|
|
3282
3282
|
.website-preview-description {
|
|
3283
3283
|
font-size: 10px;
|
|
@@ -3333,19 +3333,19 @@ otherwise there's some empty space at the bottom of the button, which interferes
|
|
|
3333
3333
|
cursor: pointer;
|
|
3334
3334
|
width: fit-content;
|
|
3335
3335
|
}
|
|
3336
|
-
`;var Er=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 Rr=class extends re{constructor(){super(...arguments),this.onMount=()=>({}),this.loadingPreviews=!0,this.websitePreviewInfo=[],this.imagesToDisplay=[],this.imageUrlError=[]
|
|
3336
|
+
`;var Er=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 Rr=class extends re{constructor(){super(...arguments),this.onMount=()=>({}),this.loadingPreviews=!0,this.websitePreviewInfo=[],this.imagesToDisplay=[],this.imageUrlError=[]}firstUpdated(){if(!this.message)return;const{hyperlinks:e,markedText:t}=this.mapAndMarkHyperLinks(this.message.message.text),n=/(https?:\/\/[^\s]+)/g,i=[],r=[];this.parsedMessage=k`${t.split("\n").map((t=>{const o=t.split(" ");return o?k`${o.map((t=>{if(e.find((e=>e.id===t))){const n=e.find((e=>e.id===t));if(!n)return;return r.push({redirectTo:null==n?void 0:n.link,source:null==n?void 0:n.link}),k`<a
|
|
3337
3337
|
class="redirect-link"
|
|
3338
3338
|
href="${null==n?void 0:n.link}"
|
|
3339
3339
|
target="_blank"
|
|
3340
3340
|
rel="noopener noreferrer"
|
|
3341
3341
|
>${null==n?void 0:n.hyperlink}
|
|
3342
|
-
</a>`}
|
|
3342
|
+
</a>`}if(n.test(t)){const e=this.removeTrailingPunctuation(t);return i.push(this.getLinkData(e)),k`<a
|
|
3343
3343
|
class="redirect-link"
|
|
3344
|
-
href="${
|
|
3344
|
+
href="${e}"
|
|
3345
3345
|
target="_blank"
|
|
3346
3346
|
rel="noopener noreferrer"
|
|
3347
|
-
>${
|
|
3348
|
-
</a>`
|
|
3347
|
+
>${e}
|
|
3348
|
+
</a>`}return k`${t} `}))}<br />`:k``}))}`,this.imagesToDisplay=r,Promise.all(i).then((e=>{this.websitePreviewInfo=e}))}removeTrailingPunctuation(e){return[".",",","!","?",":",";"].includes(e[e.length-1])?this.removeTrailingPunctuation(e.slice(0,-1)):e}mapAndMarkHyperLinks(e){const t=Array.from(e.matchAll(/<https?:\/\/[^|]+\|[^>]+>/g)),n=[];return t.forEach((t=>{try{const i=t[0].split("|")[0].replace("<",""),r=t[0].split("|")[1].replace(">","");if(i&&r){const o=Sr().replace(/-/g,"");n.push({link:this.removeTrailingPunctuation(i),hyperlink:this.removeTrailingPunctuation(r),mark:t[0],id:o}),e=e.replace(t[0],o)}}catch(e){}})),{hyperlinks:n,markedText:e}}async getLinkData(e){var n,i,r,o,a,s;try{const u=(await t().get(e)).data,l=(new DOMParser).parseFromString(u,"text/html");return l?{title:null!==(i=null===(n=l.querySelector("title"))||void 0===n?void 0:n.textContent)&&void 0!==i?i:null,description:(null===(r=l.querySelector('meta[name="description"]'))||void 0===r?void 0:r.getAttribute("content"))||null,image:(null===(o=l.querySelector('meta[property="og:image"]'))||void 0===o?void 0:o.getAttribute("content"))||null,favicon:(null===(a=l.querySelector('link[rel="shortcut icon"]'))||void 0===a?void 0:a.getAttribute("href"))||(null===(s=l.querySelector('link[rel="icon"]'))||void 0===s?void 0:s.getAttribute("href"))||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}}}updated(){this.onMount()}render(){return this.message?k`<div class="message-inner-body">
|
|
3349
3349
|
<p class="message-text">${this.parsedMessage}</p>
|
|
3350
3350
|
${this.websitePreviewInfo.length>0&&this.websitePreviewInfo.some((e=>e.title&&(e.image||e.favicon)))?k`<br />`:""}
|
|
3351
3351
|
${this.imagesToDisplay.map((e=>k`<a
|
|
@@ -3375,9 +3375,9 @@ otherwise there's some empty space at the bottom of the button, which interferes
|
|
|
3375
3375
|
|
|
3376
3376
|
<div class="website-preview-body">
|
|
3377
3377
|
<p class="message-text website-preview-title">${e.title}</p>
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3378
|
+
${e.description?k`<p class="message-text website-preview-description">
|
|
3379
|
+
${e.description}
|
|
3380
|
+
</p>`:""}
|
|
3381
3381
|
</div>
|
|
3382
3382
|
</div>
|
|
3383
3383
|
</a></div> `}))}
|
|
@@ -133,7 +133,7 @@ export const pubnubChatStyles = css`
|
|
|
133
133
|
display: none;
|
|
134
134
|
}
|
|
135
135
|
.redirect-link {
|
|
136
|
-
color:
|
|
136
|
+
color: inherit;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
#loading-message {
|
|
@@ -251,7 +251,7 @@ export const pubnubChatStyles = css`
|
|
|
251
251
|
-webkit-line-clamp: 2;
|
|
252
252
|
overflow: hidden;
|
|
253
253
|
text-overflow: ellipsis;
|
|
254
|
-
height: 24px;
|
|
254
|
+
max-height: 24px;
|
|
255
255
|
}
|
|
256
256
|
.website-preview-description {
|
|
257
257
|
font-size: 10px;
|
|
@@ -53,12 +53,11 @@ export class PubnubMessage extends LitElement {
|
|
|
53
53
|
const urlRegex = /(https?:\/\/[^\s]+)/g; // Regular expression to match URLs
|
|
54
54
|
const loadingWebsitePreviews: Promise<WebsitePreview>[] = [];
|
|
55
55
|
const imagesToDisplay: ImageToDisplay[] = [];
|
|
56
|
+
|
|
56
57
|
this.parsedMessage = html`${markedText.split("\n").map((line) => {
|
|
57
|
-
const allWords = line.
|
|
58
|
-
/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|])|(\b[\w':]+\b)|([.,;!?])/gi
|
|
59
|
-
);
|
|
58
|
+
const allWords = line.split(" ");
|
|
60
59
|
if (!allWords) return html``;
|
|
61
|
-
return html`${allWords.map((word
|
|
60
|
+
return html`${allWords.map((word) => {
|
|
62
61
|
if (hyperlinks.find((obj) => obj.id === word)) {
|
|
63
62
|
// EliseAI made hyperlink
|
|
64
63
|
const link = hyperlinks.find((obj) => obj.id === word);
|
|
@@ -77,21 +76,16 @@ export class PubnubMessage extends LitElement {
|
|
|
77
76
|
}
|
|
78
77
|
if (urlRegex.test(word)) {
|
|
79
78
|
// general url
|
|
80
|
-
|
|
79
|
+
const link = this.removeTrailingPunctuation(word);
|
|
80
|
+
loadingWebsitePreviews.push(this.getLinkData(link));
|
|
81
81
|
return html`<a
|
|
82
82
|
class="redirect-link"
|
|
83
|
-
href="${
|
|
83
|
+
href="${link}"
|
|
84
84
|
target="_blank"
|
|
85
85
|
rel="noopener noreferrer"
|
|
86
|
-
>${
|
|
86
|
+
>${link}
|
|
87
87
|
</a>`;
|
|
88
88
|
} else {
|
|
89
|
-
if (
|
|
90
|
-
// add a space only if the next word is not a punctuation
|
|
91
|
-
index + 1 < allWords.length &&
|
|
92
|
-
this.isPunctuation(allWords[index + 1])
|
|
93
|
-
)
|
|
94
|
-
return html`${word}`;
|
|
95
89
|
return html`${word} `;
|
|
96
90
|
}
|
|
97
91
|
})}<br />`;
|
|
@@ -101,10 +95,14 @@ export class PubnubMessage extends LitElement {
|
|
|
101
95
|
this.websitePreviewInfo = results;
|
|
102
96
|
});
|
|
103
97
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
98
|
+
|
|
99
|
+
private removeTrailingPunctuation(text: string): string {
|
|
100
|
+
const punctuation = [".", ",", "!", "?", ":", ";"];
|
|
101
|
+
if (punctuation.includes(text[text.length - 1])) {
|
|
102
|
+
return this.removeTrailingPunctuation(text.slice(0, -1));
|
|
103
|
+
}
|
|
104
|
+
return text;
|
|
105
|
+
}
|
|
108
106
|
|
|
109
107
|
private mapAndMarkHyperLinks(text: string): {
|
|
110
108
|
hyperlinks: {
|
|
@@ -129,8 +127,8 @@ export class PubnubMessage extends LitElement {
|
|
|
129
127
|
if (link && hyperlink) {
|
|
130
128
|
const uniqueKeyMark = uuid().replace(/-/g, "");
|
|
131
129
|
listHyperlinks.push({
|
|
132
|
-
link,
|
|
133
|
-
hyperlink,
|
|
130
|
+
link: this.removeTrailingPunctuation(link),
|
|
131
|
+
hyperlink: this.removeTrailingPunctuation(hyperlink),
|
|
134
132
|
mark: match[0],
|
|
135
133
|
id: uniqueKeyMark,
|
|
136
134
|
});
|
|
@@ -246,9 +244,13 @@ export class PubnubMessage extends LitElement {
|
|
|
246
244
|
|
|
247
245
|
<div class="website-preview-body">
|
|
248
246
|
<p class="message-text website-preview-title">${preview.title}</p>
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
247
|
+
${
|
|
248
|
+
preview.description
|
|
249
|
+
? html`<p class="message-text website-preview-description">
|
|
250
|
+
${preview.description}
|
|
251
|
+
</p>`
|
|
252
|
+
: ""
|
|
253
|
+
}
|
|
252
254
|
</div>
|
|
253
255
|
</div>
|
|
254
256
|
</a></div> `;
|
package/src/getAvailabilities.ts
CHANGED
|
@@ -44,9 +44,13 @@ export const getRawAvailabilities = async (
|
|
|
44
44
|
}
|
|
45
45
|
const startTime = startOfToday();
|
|
46
46
|
const endTime = formatISO(endOfDay(addDays(startTime, 30)));
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
|
|
48
|
+
// We MUST encode the URI components because a positive timezone offset counts as a space in urls!
|
|
49
|
+
const timeParams = `startTime=${encodeURIComponent(
|
|
50
|
+
formatISO(startTime)
|
|
51
|
+
)}&endTime=${encodeURIComponent(endTime)}`;
|
|
52
|
+
const url = `https://app.meetelise.com/api/pub/v1/buildings/${buildingIdToUse}/tour/availabilities?${timeParams}`;
|
|
53
|
+
|
|
50
54
|
const result = await axios.get<TourAvailabilityResponse>(url);
|
|
51
55
|
availabilitiesCache.availabilities[buildingIdToUse] = result.data;
|
|
52
56
|
// The endpoint INCORRECTLY states that these are returned as dates. They are, in fact, strings.
|