@meetelise/chat 1.20.4 → 1.20.5

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.4",
3
+ "version": "1.20.5",
4
4
  "description": "",
5
5
  "main": "public/dist/index.js",
6
6
  "type": "module",
@@ -323,7 +323,7 @@ var e={8005:function(e,t,n){var i,r=this&&this.__extends||(i=function(e,t){retur
323
323
  #noAvailabilityText.horizontal {
324
324
  margin-left: 0;
325
325
  }
326
- `,Ht([oe({attribute:!1})],Gt.prototype,"options",void 0),Ht([oe({type:Boolean})],Gt.prototype,"selectedDateExists",void 0),Ht([oe({type:Boolean})],Gt.prototype,"horizontal",void 0),Ht([ae()],Gt.prototype,"selected",void 0),Ht([oe({attribute:!1})],Gt.prototype,"selectedTime",null),Gt=Ht([ie("time-picker")],Gt);var $t=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 zt=class extends te{constructor(){super(),this.options=[],this.placeholder="Select",this.activeOption=null,this.isOpen=!1,this.toggleSelect=()=>{this.isOpen&&(this.activeOption=null),this.isOpen=!this.isOpen},this.setSelectedOption=(e,t=!0)=>{this.value=e.value,t&&(this.isOpen=!this.isOpen,this.activeOption=null),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))},this.handleKeydown=(e,t)=>n=>{("string"==typeof e&&n.key===e||"object"==typeof e&&e.includes(n.key))&&t()},document.addEventListener("click",(e=>{e.composedPath().includes(this.meSelect)||(this.isOpen=!1)}))}render(){var e;return D`
326
+ `,Ht([oe({attribute:!1})],Gt.prototype,"options",void 0),Ht([oe({type:Boolean})],Gt.prototype,"selectedDateExists",void 0),Ht([oe({type:Boolean})],Gt.prototype,"horizontal",void 0),Ht([ae()],Gt.prototype,"selected",void 0),Ht([oe({attribute:!1})],Gt.prototype,"selectedTime",null),Gt=Ht([ie("time-picker")],Gt);var $t=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 zt=class extends te{constructor(){super(),this.options=[],this.placeholder="Select",this.activeOption=null,this.isOpen=!1,this.toggleSelect=()=>{this.isOpen&&(this.activeOption=null),this.isOpen=!this.isOpen},this.setSelectedOption=(e,t=!0)=>{this.value!==e.value?this.value=e.value:this.value=void 0,t&&(this.isOpen=!this.isOpen,this.activeOption=null),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))},this.handleKeydown=(e,t)=>n=>{("string"==typeof e&&n.key===e||"object"==typeof e&&e.includes(n.key))&&t()},document.addEventListener("click",(e=>{e.composedPath().includes(this.meSelect)||(this.isOpen=!1)}))}render(){var e,t;return D`
327
327
  <div>
328
328
  <div
329
329
  id="select"
@@ -331,7 +331,9 @@ var e={8005:function(e,t,n){var i,r=this&&this.__extends||(i=function(e,t){retur
331
331
  @click=${()=>this.isOpen=!this.isOpen}
332
332
  @keydown="${e=>{switch(e.key){case"Enter":case" ":e.preventDefault(),this.isOpen&&this.activeOption?this.setSelectedOption(this.activeOption):this.toggleSelect();break;case"Escape":e.preventDefault(),this.isOpen=!1;break;case"Tab":this.isOpen&&e.preventDefault();break;case"ArrowUp":e.preventDefault(),this.isOpen&&this.activeOption&&(this.options.indexOf(this.activeOption)>0?this.activeOption=this.options[this.options.indexOf(this.activeOption)-1]:this.activeOption=null);break;case"ArrowDown":e.preventDefault(),this.isOpen&&(this.activeOption?this.activeOption&&this.options.indexOf(this.activeOption)<this.options.length-1&&(this.activeOption=this.options[this.options.indexOf(this.activeOption)+1]):this.activeOption=this.options[0])}}}"
333
333
  >
334
- <span id="selectText">${null!==(e=this.value)&&void 0!==e?e:this.placeholder}</span>
334
+ <span id="selectText"
335
+ >${null!==(t=null===(e=this.options.find((e=>e.value===this.value)))||void 0===e?void 0:e.label)&&void 0!==t?t:this.placeholder}</span
336
+ >
335
337
  <svg
336
338
  width="10"
337
339
  height="6"
@@ -441,7 +443,7 @@ var e={8005:function(e,t,n){var i,r=this&&this.__extends||(i=function(e,t){retur
441
443
  .option.active {
442
444
  background-color: var(--active-option-color);
443
445
  }
444
- `,$t([oe({attribute:!1})],zt.prototype,"options",void 0),$t([oe({type:String})],zt.prototype,"placeholder",void 0),$t([oe({type:String})],zt.prototype,"value",void 0),$t([ae()],zt.prototype,"activeOption",void 0),$t([ae()],zt.prototype,"isOpen",void 0),$t([se("#select",!0)],zt.prototype,"meSelect",void 0),zt=$t([ie("me-select")],zt);var Xt=n(9669),Zt=n.n(Xt),Qt=n(9991),Kt=n(7739),Yt=n.n(Kt);Math.pow(10,8);var en=36e5;function tn(e,t){Ee(1,arguments);var n=t||{},i=null==n.additionalDigits?2:Ve(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=sn(e);if(o.date){var a=un(o.date,i);r=ln(a.restDateString,a.year)}if(!r||isNaN(r.getTime()))return new Date(NaN);var s,u=r.getTime(),l=0;if(o.time&&(l=cn(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=fn(o.timezone),isNaN(s)?new Date(NaN):new Date(u+l+s)}var nn={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},rn=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,on=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,an=/^([+-])(\d{2})(?::?(\d{2}))?$/;function sn(e){var t,n={},i=e.split(nn.dateTimeDelimiter);if(i.length>2)return n;if(/:/.test(i[0])?t=i[0]:(n.date=i[0],t=i[1],nn.timeZoneDelimiter.test(n.date)&&(n.date=e.split(nn.timeZoneDelimiter)[0],t=e.substr(n.date.length,e.length))),t){var r=nn.timezone.exec(t);r?(n.time=t.replace(r[1],""),n.timezone=r[1]):n.time=t}return n}function un(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 ln(e,t){if(null===t)return new Date(NaN);var n=e.match(rn);if(!n)return new Date(NaN);var i=!!n[4],r=dn(n[1]),o=dn(n[2])-1,a=dn(n[3]),s=dn(n[4]),u=dn(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<=(hn[t]||(mn(e)?29:28))}(t,o,a)&&function(e,t){return t>=1&&t<=(mn(e)?366:365)}(t,r)?(l.setUTCFullYear(t,o,Math.max(r,a)),l):new Date(NaN)}function dn(e){return e?parseInt(e):1}function cn(e){var t=e.match(on);if(!t)return NaN;var n=pn(t[1]),i=pn(t[2]),r=pn(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*en+6e4*i+1e3*r:NaN}function pn(e){return e&&parseFloat(e.replace(",","."))||0}function fn(e){if("Z"===e)return 0;var t=e.match(an);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*en+6e4*r):NaN}var hn=[31,null,31,30,31,30,31,31,30,31,30,31];function mn(e){return e%400==0||e%4==0&&e%100!=0}const vn={buildingId:null,availabilities:{}},gn=async e=>{e&&(vn.buildingId=e);const t=vn.buildingId;if(!t)throw new Error("No buildingId was provided to getRawAvailabilities and there is no buildingId cached.");const n=vn.availabilities;if(n[t])return n[t];const i=function(e){Ee(1,arguments);var t=Fe(e);return t.setHours(0,0,0,0),t}(Date.now()),r=Vt(function(e){Ee(1,arguments);var t=Fe(e);return t.setHours(23,59,59,999),t}(function(e,t){Ee(2,arguments);var n=Fe(e),i=Ve(t);return isNaN(i)?new Date(NaN):i?(n.setDate(n.getDate()+i),n):n}(i,30))),o=`https://app.meetelise.com/api/pub/v1/buildings/${t}/tour/availabilities?startTime=${Vt(i)}&endTime=${r}`,a=await Zt().get(o);return vn.availabilities[t]=a.data,a.data},yn=async(e,t)=>{var n,i;const r=await gn(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},bn=async(e,t)=>{var n,i;const r=await yn(e,t);if(!r)return{};const o={availableTourStartTimes:null===(n=r.availableTourStartTimes?r.availableTourStartTimes.filter((e=>De(tn(e))&&!function(e){return Ee(1,arguments),Fe(e).getTime()<Date.now()}(tn(e)))):[])||void 0===n?void 0:n.map((e=>wn(e)))};return Yt()(null!==(i=o.availableTourStartTimes)&&void 0!==i?i:[],(e=>Pt(new Date(e.datetime),"yyyy-MM-dd")))},wn=e=>({datetime:e.slice(0,19),offset:e.slice(19)});n(7294);const Sn=()=>window.matchMedia("(max-width: 767px)").matches;var Tn=n(6486),xn=n(4184),On=n.n(xn),In=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 Rn=class extends te{constructor(){super(...arguments),this.layoutOptions=[],this.unitOptions=[],this.tourTypeOptions=[],this.buildingId=0,this.buildingSlug="",this.orgSlug="",this.tourType=Nn.Guided,this.shouldShowTourType={[Nn.Guided]:!0,[Nn.Self]:!0,[Nn.Virtual]:!0},this.email="",this.phoneNumber="",this.availabilitiesGroupedByDay={},this.waitingForAvailabilities=!0,this.mobilePageIndex=0,this.isSubmitting=!1,this.tourIsBooked=!1,this.firstUpdated=async()=>{this.availabilitiesGroupedByDay=await bn(An[this.tourType]),this.waitingForAvailabilities=!1;const e=await(async()=>{var e,t,n,i,r,o;return{[Nn.Guided]:!!(null===(t=null===(e=await yn(Qt.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.WithAgent))||void 0===e?void 0:e.availableTourStartTimes)||void 0===t?void 0:t.length),[Nn.Self]:!!(null===(i=null===(n=await yn(Qt.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.SelfGuided))||void 0===n?void 0:n.availableTourStartTimes)||void 0===i?void 0:i.length),[Nn.Virtual]:!!(null===(o=null===(r=await yn(Qt.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.VirtualShowing))||void 0===r?void 0:r.availableTourStartTimes)||void 0===o?void 0:o.length)}})();this.shouldShowTourType={[Nn.Guided]:this.tourTypeOptions.map((e=>e.value)).includes("WITH_AGENT")&&e[Nn.Guided],[Nn.Self]:this.tourTypeOptions.map((e=>e.value)).includes("SELF_GUIDED")&&e[Nn.Self],[Nn.Virtual]:this.tourTypeOptions.map((e=>e.value)).includes("VIRTUAL_SHOWING")&&e[Nn.Virtual]}},this.willUpdate=async e=>{e.has("tourType")&&(this.availabilitiesGroupedByDay=await bn(An[this.tourType]))},this.handlePhoneKeydown=e=>{var t;if(!(e instanceof KeyboardEvent&&e.target instanceof HTMLInputElement&&null!==e.target.selectionStart))return;const n=e.target.selectionStart;if(1!==e.key.length||Ne(e)){if("Backspace"===e.key){if(Ne(e))return;if(this.phoneInput.selectionEnd&&this.phoneInput.selectionStart&&this.phoneInput.selectionEnd-this.phoneInput.selectionStart>0)return;const t=this.phoneNumber.length,i=this.phoneNumber.slice(0,n).replace(/\D/g,""),r=this.phoneNumber.slice(n).replace(/\D/g,""),o=`${i.slice(0,-1)}${r}`;this.phoneNumber=Ie(o),this.phoneInput.value=this.phoneNumber;const a=n-(t-this.phoneNumber.length);return this.phoneInput.setSelectionRange(a,a),e.preventDefault(),void e.stopPropagation()}if(!["ArrowLeft","ArrowRight"].includes(e.key)||Ne(e)||e.shiftKey)return;if("ArrowLeft"===e.key){const e=((null===(t=this.phoneNumber.slice(0,n).split(/\d+/).at(-1))||void 0===t?void 0:t.length)||0)+1,i=n-e>-1?n-e:0;this.phoneInput.setSelectionRange(i,i)}if("ArrowRight"===e.key){const e=(this.phoneNumber.slice(n).split(/\d+/)[0].length||0)+1,t=n+e<this.phoneNumber.length?n+e:this.phoneNumber.length;this.phoneInput.setSelectionRange(t,t)}e.preventDefault(),e.stopPropagation()}else{e.preventDefault(),e.stopPropagation();const t=this.phoneNumber.slice(0,n)+e.key+this.phoneNumber.slice(n);this.phoneNumber=Ie(t.replace(/\D/g,"")),this.phoneInput.value=this.phoneNumber}},this.handlePhoneKeyup=e=>{var t;if(!e.key)return;if(e.key.includes("Arrow")||["Meta","Shift","Control","Alt"].includes(e.key))return;const n=this.phoneInput.selectionStart,i=n?this.phoneInput.value.slice(n).replace(/\D/g,""):"";this.phoneNumber=Ie(this.phoneInput.value);let r=0,o=i.length;for(;o;)(null===(t=this.phoneNumber.at(r))||void 0===t?void 0:t.match(/\d/))&&o--,r++;const a=this.phoneInput.value.length-r+1;this.phoneInput.setSelectionRange(a,a)},this.onChangeEmail=e=>{e.target&&(this.email=e.target.value)},this.validators={tourType:()=>!isNaN(this.tourType),dateAndTime:()=>!!this.selectedDate&&!!this.selectedTime,leadInfo:()=>{var e,t,n;return(!!(null===(e=this.firstNameInput)||void 0===e?void 0:e.value)||!!(null===(t=this.lastNameInput)||void 0===t?void 0:t.value))&&(null===(n=this.emailInput)||void 0===n?void 0:n.value.includes("@"))&&!!this.phoneNumber&&14===this.phoneNumber.length}},this.formIsValidForSubmission=()=>this.validators.tourType()&&this.validators.dateAndTime()&&this.validators.leadInfo(),this.timeStringToHoursAndMinutes=e=>{const[t,n]=e.split(/\D/g);return[parseInt(t)+(e.toLowerCase().includes("pm")?12:0),parseInt(n)]},this.submit=async()=>{var e;if(!this.selectedDate||!this.selectedTime)return;const t={email_address:this.email,phone_number:`+1${null===(e=this.phoneNumber.match(/\d/g))||void 0===e?void 0:e.join("")}`,building_id:this.buildingId,first_name:this.firstNameInput.value,last_name:this.lastNameInput.value,tour_type:Cn[this.tourType],tour_time:`${this.selectedTime.datetime}${this.selectedTime.offset}`,layouts:[this.layoutTypeSelect.value],unit_numbers:[this.unitTypeSelect.value]};this.isSubmitting=!0;try{await Zt().post("https://app.meetelise.com/platformApi/state/create/scheduleMe",t,{headers:{"building-slug":this.buildingSlug,"X-SecurityKey":"JRL8jV4VcSCwOSir5gWkpgNLfKghmhBG","org-slug":this.orgSlug}}),this.isSubmitting=!1,this.tourIsBooked=!0}catch(e){const t=e.response.data.detail||"Failed to book tour";alert(t),this.isSubmitting=!1,this.tourIsBooked=!1}},this.mobilePages=[{validate:this.validators.tourType,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>D`${this.tourTypeMenu()}`},{validate:this.validators.dateAndTime,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>D`${this.dateAndTimeMenu(!0)}`},{validate:()=>this.validators.leadInfo(),nextButtonText:null,renderNextButton:()=>D`<action-confirm-button
446
+ `,$t([oe({attribute:!1})],zt.prototype,"options",void 0),$t([oe({type:String})],zt.prototype,"placeholder",void 0),$t([oe({type:String})],zt.prototype,"value",void 0),$t([ae()],zt.prototype,"activeOption",void 0),$t([ae()],zt.prototype,"isOpen",void 0),$t([se("#select",!0)],zt.prototype,"meSelect",void 0),zt=$t([ie("me-select")],zt);var Xt=n(9669),Zt=n.n(Xt),Qt=n(9991),Kt=n(7739),Yt=n.n(Kt);Math.pow(10,8);var en=36e5;function tn(e,t){Ee(1,arguments);var n=t||{},i=null==n.additionalDigits?2:Ve(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=sn(e);if(o.date){var a=un(o.date,i);r=ln(a.restDateString,a.year)}if(!r||isNaN(r.getTime()))return new Date(NaN);var s,u=r.getTime(),l=0;if(o.time&&(l=cn(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=fn(o.timezone),isNaN(s)?new Date(NaN):new Date(u+l+s)}var nn={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},rn=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,on=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,an=/^([+-])(\d{2})(?::?(\d{2}))?$/;function sn(e){var t,n={},i=e.split(nn.dateTimeDelimiter);if(i.length>2)return n;if(/:/.test(i[0])?t=i[0]:(n.date=i[0],t=i[1],nn.timeZoneDelimiter.test(n.date)&&(n.date=e.split(nn.timeZoneDelimiter)[0],t=e.substr(n.date.length,e.length))),t){var r=nn.timezone.exec(t);r?(n.time=t.replace(r[1],""),n.timezone=r[1]):n.time=t}return n}function un(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 ln(e,t){if(null===t)return new Date(NaN);var n=e.match(rn);if(!n)return new Date(NaN);var i=!!n[4],r=dn(n[1]),o=dn(n[2])-1,a=dn(n[3]),s=dn(n[4]),u=dn(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<=(hn[t]||(mn(e)?29:28))}(t,o,a)&&function(e,t){return t>=1&&t<=(mn(e)?366:365)}(t,r)?(l.setUTCFullYear(t,o,Math.max(r,a)),l):new Date(NaN)}function dn(e){return e?parseInt(e):1}function cn(e){var t=e.match(on);if(!t)return NaN;var n=pn(t[1]),i=pn(t[2]),r=pn(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*en+6e4*i+1e3*r:NaN}function pn(e){return e&&parseFloat(e.replace(",","."))||0}function fn(e){if("Z"===e)return 0;var t=e.match(an);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*en+6e4*r):NaN}var hn=[31,null,31,30,31,30,31,31,30,31,30,31];function mn(e){return e%400==0||e%4==0&&e%100!=0}const vn={buildingId:null,availabilities:{}},gn=async e=>{e&&(vn.buildingId=e);const t=vn.buildingId;if(!t)throw new Error("No buildingId was provided to getRawAvailabilities and there is no buildingId cached.");const n=vn.availabilities;if(n[t])return n[t];const i=function(e){Ee(1,arguments);var t=Fe(e);return t.setHours(0,0,0,0),t}(Date.now()),r=Vt(function(e){Ee(1,arguments);var t=Fe(e);return t.setHours(23,59,59,999),t}(function(e,t){Ee(2,arguments);var n=Fe(e),i=Ve(t);return isNaN(i)?new Date(NaN):i?(n.setDate(n.getDate()+i),n):n}(i,30))),o=`https://app.meetelise.com/api/pub/v1/buildings/${t}/tour/availabilities?startTime=${Vt(i)}&endTime=${r}`,a=await Zt().get(o);return vn.availabilities[t]=a.data,a.data},yn=async(e,t)=>{var n,i;const r=await gn(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},bn=async(e,t)=>{var n,i;const r=await yn(e,t);if(!r)return{};const o={availableTourStartTimes:null===(n=r.availableTourStartTimes?r.availableTourStartTimes.filter((e=>De(tn(e))&&!function(e){return Ee(1,arguments),Fe(e).getTime()<Date.now()}(tn(e)))):[])||void 0===n?void 0:n.map((e=>wn(e)))};return Yt()(null!==(i=o.availableTourStartTimes)&&void 0!==i?i:[],(e=>Pt(new Date(e.datetime),"yyyy-MM-dd")))},wn=e=>({datetime:e.slice(0,19),offset:e.slice(19)});n(7294);const Sn=()=>window.matchMedia("(max-width: 767px)").matches;var Tn=n(6486),xn=n(4184),On=n.n(xn),In=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 Rn=class extends te{constructor(){super(...arguments),this.layoutOptions=[],this.unitOptions=[],this.tourTypeOptions=[],this.buildingId=0,this.buildingSlug="",this.orgSlug="",this.tourType=Nn.Guided,this.shouldShowTourType={[Nn.Guided]:!0,[Nn.Self]:!0,[Nn.Virtual]:!0},this.email="",this.phoneNumber="",this.availabilitiesGroupedByDay={},this.waitingForAvailabilities=!0,this.mobilePageIndex=0,this.isSubmitting=!1,this.tourIsBooked=!1,this.firstUpdated=async()=>{this.availabilitiesGroupedByDay=await bn(An[this.tourType]),this.waitingForAvailabilities=!1;const e=await(async()=>{var e,t,n,i,r,o;return{[Nn.Guided]:!!(null===(t=null===(e=await yn(Qt.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.WithAgent))||void 0===e?void 0:e.availableTourStartTimes)||void 0===t?void 0:t.length),[Nn.Self]:!!(null===(i=null===(n=await yn(Qt.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.SelfGuided))||void 0===n?void 0:n.availableTourStartTimes)||void 0===i?void 0:i.length),[Nn.Virtual]:!!(null===(o=null===(r=await yn(Qt.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.VirtualShowing))||void 0===r?void 0:r.availableTourStartTimes)||void 0===o?void 0:o.length)}})();this.shouldShowTourType={[Nn.Guided]:this.tourTypeOptions.map((e=>e.value)).includes("WITH_AGENT")&&e[Nn.Guided],[Nn.Self]:this.tourTypeOptions.map((e=>e.value)).includes("SELF_GUIDED")&&e[Nn.Self],[Nn.Virtual]:this.tourTypeOptions.map((e=>e.value)).includes("VIRTUAL_SHOWING")&&e[Nn.Virtual]}},this.willUpdate=async e=>{e.has("tourType")&&(this.availabilitiesGroupedByDay=await bn(An[this.tourType]))},this.handlePhoneKeydown=e=>{var t;if(!(e instanceof KeyboardEvent&&e.target instanceof HTMLInputElement&&null!==e.target.selectionStart))return;const n=e.target.selectionStart;if(1!==e.key.length||Ne(e)){if("Backspace"===e.key){if(Ne(e))return;if(this.phoneInput.selectionEnd&&this.phoneInput.selectionStart&&this.phoneInput.selectionEnd-this.phoneInput.selectionStart>0)return;const t=this.phoneNumber.length,i=this.phoneNumber.slice(0,n).replace(/\D/g,""),r=this.phoneNumber.slice(n).replace(/\D/g,""),o=`${i.slice(0,-1)}${r}`;this.phoneNumber=Ie(o),this.phoneInput.value=this.phoneNumber;const a=n-(t-this.phoneNumber.length);return this.phoneInput.setSelectionRange(a,a),e.preventDefault(),void e.stopPropagation()}if(!["ArrowLeft","ArrowRight"].includes(e.key)||Ne(e)||e.shiftKey)return;if("ArrowLeft"===e.key){const e=((null===(t=this.phoneNumber.slice(0,n).split(/\d+/).at(-1))||void 0===t?void 0:t.length)||0)+1,i=n-e>-1?n-e:0;this.phoneInput.setSelectionRange(i,i)}if("ArrowRight"===e.key){const e=(this.phoneNumber.slice(n).split(/\d+/)[0].length||0)+1,t=n+e<this.phoneNumber.length?n+e:this.phoneNumber.length;this.phoneInput.setSelectionRange(t,t)}e.preventDefault(),e.stopPropagation()}else{e.preventDefault(),e.stopPropagation();const t=this.phoneNumber.slice(0,n)+e.key+this.phoneNumber.slice(n);this.phoneNumber=Ie(t.replace(/\D/g,"")),this.phoneInput.value=this.phoneNumber}},this.handlePhoneKeyup=e=>{var t;if(!e.key)return;if(e.key.includes("Arrow")||["Meta","Shift","Control","Alt"].includes(e.key))return;const n=this.phoneInput.selectionStart,i=n?this.phoneInput.value.slice(n).replace(/\D/g,""):"";this.phoneNumber=Ie(this.phoneInput.value);let r=0,o=i.length;for(;o;)(null===(t=this.phoneNumber.at(r))||void 0===t?void 0:t.match(/\d/))&&o--,r++;const a=this.phoneInput.value.length-r+1;this.phoneInput.setSelectionRange(a,a)},this.onChangeEmail=e=>{e.target&&(this.email=e.target.value)},this.validators={tourType:()=>!isNaN(this.tourType),dateAndTime:()=>!!this.selectedDate&&!!this.selectedTime,leadInfo:()=>{var e,t,n;return(!!(null===(e=this.firstNameInput)||void 0===e?void 0:e.value)||!!(null===(t=this.lastNameInput)||void 0===t?void 0:t.value))&&(null===(n=this.emailInput)||void 0===n?void 0:n.value.includes("@"))&&!!this.phoneNumber&&14===this.phoneNumber.length}},this.formIsValidForSubmission=()=>this.validators.tourType()&&this.validators.dateAndTime()&&this.validators.leadInfo(),this.timeStringToHoursAndMinutes=e=>{const[t,n]=e.split(/\D/g);return[parseInt(t)+(e.toLowerCase().includes("pm")?12:0),parseInt(n)]},this.submit=async()=>{var e;if(!this.selectedDate||!this.selectedTime)return;const t={email_address:this.email,phone_number:`+1${null===(e=this.phoneNumber.match(/\d/g))||void 0===e?void 0:e.join("")}`,building_id:this.buildingId,first_name:this.firstNameInput.value,last_name:this.lastNameInput.value,tour_type:Cn[this.tourType],tour_time:`${this.selectedTime.datetime}${this.selectedTime.offset}`,layouts:this.layoutTypeSelect.value?[this.layoutTypeSelect.value]:null,unit_numbers:this.unitTypeSelect.value?[this.unitTypeSelect.value]:null};this.isSubmitting=!0;try{await Zt().post("https://app.meetelise.com/platformApi/state/create/scheduleMe",t,{headers:{"building-slug":this.buildingSlug,"X-SecurityKey":"JRL8jV4VcSCwOSir5gWkpgNLfKghmhBG","org-slug":this.orgSlug}}),this.isSubmitting=!1,this.tourIsBooked=!0}catch(e){const t=e.response.data.detail||"Failed to book tour";alert(t),this.isSubmitting=!1,this.tourIsBooked=!1}},this.mobilePages=[{validate:this.validators.tourType,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>D`${this.tourTypeMenu()}`},{validate:this.validators.dateAndTime,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>D`${this.dateAndTimeMenu(!0)}`},{validate:()=>this.validators.leadInfo(),nextButtonText:null,renderNextButton:()=>D`<action-confirm-button
445
447
  id="schedule"
446
448
  .onClick=${this.submit}
447
449
  .isLoading=${this.isSubmitting}
@@ -607,7 +609,7 @@ var e={8005:function(e,t,n){var i,r=this&&this.__extends||(i=function(e,t){retur
607
609
  <div class="unitLayoutOptions">
608
610
  <me-select
609
611
  id="layoutType"
610
- placeholder="Select type"
612
+ placeholder="Select layout"
611
613
  .options="${this.layoutOptions.map((e=>{return{label:(t=e,"studio"==t?"Studio":{"1br":"1 bedroom","2br":"2 bedrooms","3br":"3 bedrooms","4br":"4 bedrooms","5br":"5 bedrooms","6br":"6 bedrooms","7br":"7 bedrooms","8br":"8 bedrooms","9br":"9 bedrooms","10br":"10 bedroom"}[t]),value:e};var t}))}"
612
614
  defaultOption="Studio"
613
615
  @change=${()=>{this.requestUpdate()}}
@@ -615,11 +617,11 @@ var e={8005:function(e,t,n){var i,r=this&&this.__extends||(i=function(e,t){retur
615
617
  </me-select>
616
618
  </div>
617
619
  </div>`:""}
618
- ${this.unitOptions.length>0?D`<div class="unitLayoutChoice">
620
+ ${this.unitOptions.filter((e=>!this.layoutTypeSelect||e.layout===this.layoutTypeSelect.value)).length>0?D`<div class="unitLayoutChoice">
619
621
  <div class="unitLayoutOptions">
620
622
  <me-select
621
623
  id="unitType"
622
- placeholder="Select type"
624
+ placeholder="Select unit"
623
625
  .options="${this.unitOptions.filter((e=>!this.layoutTypeSelect||e.layout===this.layoutTypeSelect.value)).map((e=>({label:e.name,value:e.name})))}"
624
626
  defaultOption="Studio"
625
627
  @change=${()=>{this.requestUpdate()}}
@@ -35,7 +35,12 @@ export class MESelect extends LitElement {
35
35
  };
36
36
 
37
37
  setSelectedOption = (option: MeSelectOption, closeSelect = true): void => {
38
- this.value = option.value;
38
+ if (this.value !== option.value) {
39
+ this.value = option.value;
40
+ } else {
41
+ this.value = undefined;
42
+ }
43
+
39
44
  if (closeSelect) {
40
45
  this.isOpen = !this.isOpen;
41
46
  this.activeOption = null;
@@ -211,7 +216,10 @@ export class MESelect extends LitElement {
211
216
  }
212
217
  }}"
213
218
  >
214
- <span id="selectText">${this.value ?? this.placeholder}</span>
219
+ <span id="selectText"
220
+ >${this.options.find((o) => o.value === this.value)?.label ??
221
+ this.placeholder}</span
222
+ >
215
223
  <svg
216
224
  width="10"
217
225
  height="6"
@@ -332,8 +332,12 @@ export class TourScheduler extends LitElement {
332
332
  last_name: this.lastNameInput.value,
333
333
  tour_type: tourTypeForSubmission[this.tourType],
334
334
  tour_time: `${this.selectedTime.datetime}${this.selectedTime.offset}`, // e.g., "2022-06-27T09:00:00-07:00"
335
- layouts: [this.layoutTypeSelect.value],
336
- unit_numbers: [this.unitTypeSelect.value],
335
+ layouts: this.layoutTypeSelect.value
336
+ ? [this.layoutTypeSelect.value]
337
+ : null,
338
+ unit_numbers: this.unitTypeSelect.value
339
+ ? [this.unitTypeSelect.value]
340
+ : null,
337
341
  };
338
342
  const url = `https://app.meetelise.com/platformApi/state/create/scheduleMe`;
339
343
  this.isSubmitting = true;
@@ -1033,7 +1037,7 @@ export class TourScheduler extends LitElement {
1033
1037
  <div class="unitLayoutOptions">
1034
1038
  <me-select
1035
1039
  id="layoutType"
1036
- placeholder="Select type"
1040
+ placeholder="Select layout"
1037
1041
  .options="${this.layoutOptions.map((i) => ({
1038
1042
  label: getHumanReadableLayout(i),
1039
1043
  value: i,
@@ -1048,12 +1052,15 @@ export class TourScheduler extends LitElement {
1048
1052
  </div>
1049
1053
  </div>`
1050
1054
  : ""}
1051
- ${this.unitOptions.length > 0
1055
+ ${this.unitOptions.filter(
1056
+ (i) =>
1057
+ !this.layoutTypeSelect || i.layout === this.layoutTypeSelect.value
1058
+ ).length > 0
1052
1059
  ? html`<div class="unitLayoutChoice">
1053
1060
  <div class="unitLayoutOptions">
1054
1061
  <me-select
1055
1062
  id="unitType"
1056
- placeholder="Select type"
1063
+ placeholder="Select unit"
1057
1064
  .options="${this.unitOptions
1058
1065
  .filter(
1059
1066
  (i) =>