1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2402],{52937:function(e,t,i){i.d(t,{N:function(){return s}});var n=i(39986);class o{constructor(e,t,i=!0,o){this.automaticComponentRegistration=!0,this.registeredComponents={},this.propStateRegistrations=new Map,this.eventListenerRegistrations=new Map,this.host=e,this.stores=t,this.automaticComponentRegistration=i,this.eventOverrides=o,(0,n.b)(`[${this.hostTagName}] Initializing (abstract) provider.`,{eventOverrides:o}),this.registerComponent=this.registerComponent.bind(this),this.getStore=this.getStore.bind(this),Object.keys(this.stores).forEach(e=>{this.propStateRegistrations.set(e,new Map)})}async componentWillLoad(e){(0,n.b)(`[${this.hostTagName}] Will load`),this.setupStoreListeners(),this.nylasConnector=e;let t=Array.from(this.host.querySelectorAll("*")).filter(e=>e.tagName.toLowerCase().startsWith("nylas-"));(0,n.b)(`[${this.hostTagName}] Found ${t.length} child component(s).`,{childComponents:t});let i=t.map(async e=>{if(!e){(0,n.b)(`[~${this.hostTagName}] (componentWillLoad) Component ${e.tagName} does not have a name. Skipping.`);return}if(!e.registerNylasComponent){(0,n.b)(`[~${this.hostTagName}] (componentWillLoad) Component ${e.tagName} is not a component that can be registered. Skipping.`,{component:e});return}let t={element:e,name:e.tagName.toLowerCase(),getStoresToProp:e.getStoresToProp,storeToProps:e.storeToProps,stateToProps:e.stateToProps,authToProp:e.authToProp,eventToProps:e.eventToProps,connectorToProp:e.connectorToProp,localPropsToProp:e.localPropsToProp};await this.registerComponent(t)});await Promise.all(i)}async componentDidLoad(){(0,n.b)(`[~${this.hostTagName}] (componentDidLoad) Did load`)}async componentDisconnected(){Object.values(this.stores).forEach(e=>{e.dispose()})}async registerComponentHandler(e){if(e.stopPropagation(),!this.automaticComponentRegistration){(0,n.b)(`~[${this.hostTagName}] (registerComponentHandler) Automatic component registration disabled. Skipping registration of ${e.detail.name}.`);return}await this.registerComponent(e.detail)}async unregisterComponentHandler(e){if(e.stopPropagation(),!this.automaticComponentRegistration){(0,n.b)(`~[${this.hostTagName}] (unregisterComponentHandler) Automatic component registration disabled. Skipping unregistration of ${e.detail.name}.`);return}this.unregisterComponent(e.detail)}async registerComponent(e){(0,n.b)(`~[${this.hostTagName}] (registerComponent) Registering component ${e.name}.`);let t=e.element.dataset.nylasId;t&&this.registeredComponents[t]?((0,n.b)(`[${this.hostTagName}] (registerComponent) Component ${e.name} already registered. Updating registration.`),this.cleanupComponentRegistration(t,!1)):e.element.dataset.nylasId=t||(0,n.n)();let i=e.element.dataset.nylasId;i&&(this.registeredComponents[i]=e),(0,n.b)(`[${this.hostTagName}] (registerComponent) Waiting for "${e.element.localName}" component to be defined`,{component:e});try{await customElements.whenDefined(e.element.tagName.toLowerCase()),(0,n.b)(`[${this.hostTagName}] (registerComponent) Component "${e.element.localName}" is now defined`)}catch(t){(0,n.b)(`[${this.hostTagName}] (registerComponent) Error waiting for component "${e.element.localName}" to be defined:`,t)}let o=this.eventOverrides,{stateToProps:s,getStoresToProp:r,eventToProps:a,storeToProps:l,connectorToProp:d,localPropsToProp:c,element:h}=e;null==a||a.forEach((t,i)=>{var s;let r=this.nylasConnector,a=async s=>{(0,n.b)(`[${this.hostTagName}] (registerComponent) Handling "${e.name}" prop "${String(i)}" event.`,{event:s}),i in o&&((0,n.b)(`[${this.hostTagName}] (registerComponent) Found event override for "${String(i)}" event. Calling override.`),await o[i](s,r)),s.defaultPrevented||await t(s,r)},l=e.element.dataset.nylasId;l&&!this.eventListenerRegistrations.has(l)&&this.eventListenerRegistrations.set(l,[]),l&&(null==(s=this.eventListenerRegistrations.get(l))||s.push([h,i,a])),(0,n.b)(`[${this.hostTagName}] (registerComponent) Setting "${e.name}" event "${String(i)}" to automcially call NylasConnector method.`);let d=(0,n.o)(i.toString());(0,n.b)(`[${this.hostTagName}] (registerComponent) Adding event listener for "${d}" on "${h.tagName}"`),h.addEventListener(d,a)}
1),null==s||s.forEach((t,i)=>{var o,s,r,a;let[l,d]=i.split("."),c=this.getStore(l).state[d];if(!h.dataset.nylasId){(0,n.b)(`[${this.hostTagName}] (registerComponent) Component "${e.name}" not registered. Skipping.`,{component:e});return}this.propStateRegistrations.has(l)||this.propStateRegistrations.set(l,new Map),null!=(o=this.propStateRegistrations.get(l))&&o.has(d)?null==(a=null==(r=this.propStateRegistrations.get(l))?void 0:r.get(d))||a.push({elementId:h.dataset.nylasId,propKey:t}):null==(s=this.propStateRegistrations.get(l))||s.set(d,[{elementId:h.dataset.nylasId,propKey:t}]),h[t.toString()]=c,(0,n.b)(`[${this.hostTagName}] Setting "${e.name}" prop "${t.toString()}" to "${i}" value.`,{stateValue:c})}),null==c||c.forEach((t,i)=>{let o=this.host[i];h[t.toString()]=o,(0,n.b)(`[${this.hostTagName}] Setting "${e.name}" prop "${t.toString()}" to the value of "${i}" value.`,{value:i,mappedPropValue:o})}),r&&(h[null==r?void 0:r.toString()]=this.getStore,(0,n.b)(`[${this.hostTagName}] Setting "${e.name}" prop "${r.toString()}" to "getStore" method.`)),null==l||l.forEach((t,i)=>{let o=this.getStore(i);h[t.toString()]=o,(0,n.b)(`[${this.hostTagName}] Setting "${e.name}" prop "${t.toString()}" to "${i}" store.`,{store:o})}),d&&(h[null==d?void 0:d.toString()]=this.nylasConnector,(0,n.b)(`[${this.hostTagName}] Setting "${e.name}" prop "${d.toString()}" to "nylasConnector" value.`,{connectorToProp:d})),"function"==typeof h.registerCallback&&((0,n.b)(`[${this.hostTagName}] (registerComponent) Calling registerCallback method for "${e.name}".`),await h.registerCallback()),(0,n.b)(`[${this.hostTagName}] (registerComponent) Component ${e.name} registered.`)}cleanupComponentRegistration(e,t=!0){let i=this.eventListenerRegistrations.get(e);i&&(i.forEach(([e,t,i])=>{let o=(0,n.o)(t.toString());(0,n.b)(`[${this.hostTagName}] (cleanupComponentRegistration) Removing event listener for "${o}" on "${e.tagName}"`),e.removeEventListener(o,i)}),this.eventListenerRegistrations.delete(e)),this.propStateRegistrations.forEach((t,i)=>{t.forEach((t,n)=>{var o;let s=t.filter(t=>t.elementId!==e);s.length!==t.length&&(null==(o=this.propStateRegistrations.get(i))||o.set(n,s))})}),t&&delete this.registeredComponents[e]}unregisterComponent(e){(0,n.b)(`[${this.hostTagName}] Unregistering component ${e.name}.`);let t=e.element.dataset.nylasId;if(!t){(0,n.b)(`[${this.hostTagName}] (unregisterComponent) Unregistering component ${e.name}.`);return}if(this.registeredComponents[t]){(0,n.b)(`[${this.hostTagName}] (unregisterComponent) Component ${e.name} not registered. Skipping.`);return}this.propStateRegistrations.forEach((e,i)=>{e.forEach((e,n)=>{var o,s;let r=null==(o=this.propStateRegistrations.get(i))?void 0:o.get(n),a=null==r?void 0:r.filter(e=>e.elementId!==t);a&&(null==(s=this.propStateRegistrations.get(i))||s.set(n,a))})});let i=this.eventListenerRegistrations.get(t);null==i||i.forEach(([e,t,i])=>{let o=(0,n.o)(t.toString());(0,n.b)(`[${this.hostTagName}] (unregisterComponent) Removing event listener for "${o}" on "${e.tagName}"`),e.removeEventListener(o,i)}),delete this.registeredComponents[t]}getStore(e){let t=this.stores[e];if(!t)throw Error(`[${this.hostTagName}] Store "${e.toString()}" not found.`);return t}async setupStoreListeners(){let e=this;Object.entries(this.stores).forEach(([t,i])=>{(0,n.b)(`[${e.hostTagName}] (setupStoreListeners) Listening for changes in "${t}" store.`),i.use({set(i,o,s){var r;if((0,n.b)(`[${e.hostTagName}] (setupStoreListeners) Store "${t}" state "${i.toString()}" changed`,{newValue:o,oldValue:s}),o===s){(0,n.b)(`[${e.hostTagName}] (setupStoreListeners) Store "${t}" state "${i.toString()}" unchanged. Skipping.`);return}let a=e.registeredComponents;if(!a){(0,n.b)(`[${e.hostTagName}] (setupStoreListeners) No registered components found. Skipping.`);return}let l=(null==(r=e.propStateRegistrations.get(t))?void 0:r.get(i.toString()))||[];(0,n.b)(`[${e.hostTagName}] (setupStoreListeners) Found ${l.length} prop(s) registered for "${i.toString()}" store.`,{props:l,propStateRegistrations:e.propStateRegistrations}),l.forEach(({elementId:o,propKey:s})=>{let r=a[o];if(!r){(0,n.b)(`[${e.hostTagName}] (setupStoreListeners) Component "${o}" not found. Skipping.`,{component:r});return}let l=e.getStore(t).state[i];r.element[s.toString()]=l,(0,n.b)(`[${e.hostTagName}] (setupStoreListeners) Setting "${r.name}" prop "${s.toString()}" to "${i.toString()}" value.`,{stateValue:l})})}})})}get hostTagName(){var e,t;return(null==(t=null==(e=this.host)?void 0:e.tagName)?void 0:t.toLowerCase())??"nylas-provider"}}class s extends o{}},2402:function(e,t,i){i.r(t),i.d(t,{nylas_scheduling:function(){return p}});var n=i(39986),o=i(52937),s=i(63003),r=i(99091),a=i(38182);i(67294),i(85893),i(73935);class l{constructor(){this.component=e=>{let t=s.E.Component,i=`${e} Error`;return{endtime_not_in_future:(e='"endtime" can not be in the future')=>({title:i,message:e,category:t}),no_booking_info:(e="No booking info provided")=>({title:i,message:e,category:t}),no_timeslot_selected:(e="No timeslot selected")=>({title:i,message:e,category:t}),no_timezone_selected:(e="No timezone selected")=>({title:i,message:e,category:t}),no_booking_id:(e="No booking id provided")=>({title:i,message:e,category:t}),no_salt:(e="No salt provided")=>({title:i,message:e,category:t}),invalid_start_time:(e="Invalid start time")=>({title:i,message:e,category:t}),invalid_end_time:(e="Invalid end time")=>({title:i,message:e,category:t}),invalid_timezone:(e="Invalid timezone")=>({title:i,message:e,category:t}),no_config_id:(e="No configuration id provided")=>({title:i,message:e,category:t})}},this.api=e=>{let t=s.E.Api,i=`${e} Error`;
1return{invalid_session:e=>({title:i,message:e,category:t}),general_error:e=>({title:i,message:e,category:t}),internal_error:e=>({title:i,message:e,category:t}),invalid_request_error:e=>({title:i,message:e,category:t}),timeslot_not_available:e=>({title:i,message:e,category:t}),provider_error:e=>({title:i,message:e,category:t}),not_found_error:e=>({title:i,message:e,category:t})}}}}class d{constructor({schedulerAPIURL:e,schedulerStore:t,sessionId:i,configId:n,slug:o,clientId:s}){this.errors=new l,this.schedulerStore=t,this.schedulerAPIURL=e,this.sessionId=i,this.configId=n,this.slug=o,this.clientId=s}getHeaders(){return this.sessionId?{Authorization:`Bearer ${this.sessionId}`}:{}}async makeAPIRequest(e,t,i,n={}){try{let o=new URL(this.schedulerAPIURL);return o.pathname=e,await (await fetch(decodeURIComponent(o.toString()),{method:t,headers:{"Content-Type":"application/json",Origin:window.location.origin,"X-Source":"nylas-scheduling","X-Nylas-Web-Elements-Version":"2.0.2",...n},body:i})).json()}catch(e){return{error:{message:e.message,title:"API request failed",type:"api"}}}}getErrorMessage(e){var t,i,n,o;let s=(null==e?void 0:e.message)||(null==e?void 0:e.title)||"Something went wrong";return(null==e?void 0:e.type)==="provider_error"&&(s=(null==(i=null==(t=null==e?void 0:e.provider_error)?void 0:t.error)?void 0:i.message)||(null==(o=null==(n=null==e?void 0:e.provider_error)?void 0:n.error)?void 0:o.title)||"Something went wrong"),s}setConfigId(e){this.configId=e}selectDate(e){this.schedulerStore.set("selectedDate",e),this.schedulerStore.set("selectedTimeslot",null)}selectTime(e){this.schedulerStore.set("selectedTimeslot",e)}selectTimezone(e){this.schedulerStore.set("selectedTimezone",e)}selectLanguage(e){this.schedulerStore.set("selectedLanguage",e),n.i.changeLanguage(e)}async toggleAdditionalData(e){e||await this.refetchAvailability(),this.schedulerStore.set("showBookingForm",e)}setParticipantName(e){let{bookingInfo:t}=this.schedulerStore.state;this.schedulerStore.set("bookingInfo",{...t,primaryParticipant:{...null==t?void 0:t.primaryParticipant,name:e}})}setParticipantEmail(e){let{bookingInfo:t}=this.schedulerStore.state;this.schedulerStore.set("bookingInfo",{...t,primaryParticipant:{...null==t?void 0:t.primaryParticipant,email:e}})}async refetchAvailability(){let e=new Date,t=new Date(e.getFullYear(),e.getMonth(),1).getTime()/1e3,i=t<e.getTime()/1e3?Math.floor(e.getTime()/1e3):t,n=new Date(e.getFullYear(),e.getMonth()+1,1).getTime()/1e3;return await this.getAvailability(i,n)}async resetStoreStateAndFetchAvailability(){let e=new Date,t=await this.refetchAvailability(),i=this.schedulerStore.get("availability").find(e=>new Date(e.start_time)>new Date),n=e;return i&&(n=i.start_time),this.schedulerStore.set("selectedDate",n),this.schedulerStore.set("eventInfo",null),this.schedulerStore.set("showBookingForm",!1),this.schedulerStore.set("selectedTimeslot",null),t}async setReschedule(e){this.schedulerStore.set("isLoading",!0);let t=this.schedulerStore.state.eventInfo;return t&&this.schedulerStore.set("reschedulingEventInfo",t),this.schedulerStore.set("rescheduleBookingId",e),await this.getUISettings(),await this.resetStoreStateAndFetchAvailability().finally(()=>{this.schedulerStore.set("isLoading",!1)})}async setCancel(e){this.schedulerStore.set("cancelBookingId",e)}async setReject(e){this.schedulerStore.set("rejectBookingId",e)}async resetCancel(){let e=await this.resetStoreStateAndFetchAvailability();return this.schedulerStore.set("cancelBookingId",""),this.schedulerStore.set("rejectBookingId",""),this.schedulerStore.set("cancelledEventInfo",null),e}async goBack(){this.schedulerStore.set("cancelBookingId","")}async resetConfirm(){let e=await this.resetStoreStateAndFetchAvailability();return this.schedulerStore.set("organizerConfirmationBookingId",""),this.schedulerStore.set("confirmedEventInfo",void 0),e}async bookTimeslot(e){var t,i,o;this.schedulerStore.set("isLoading",!0);let{selectedTimeslot:s,selectedTimezone:r,bookingInfo:a,selectedLanguage:l}=this.schedulerStore.state;if(!e&&!a)return{error:this.errors.component(n.i.t("createBookingErrorTitle")).no_booking_info()};let d=(null==e?void 0:e.timeslot)||s;if(!d)return{error:this.errors.component(n.i.t("createBookingErrorTitle")).no_timeslot_selected()};let c=e&&null!=e&&e.timezone?null==e?void 0:e.timezone:r,h=l||"en-US";if(!c)return{error:this.errors.component(n.i.t("createBookingErrorTitle")).no_timezone_selected()};let g=[...this.schedulerStore.get("availabilityOrderEmails")],u="",p=(null==d?void 0:d.emails)||[],m={};Object.entries((null==a?void 0:a.additionalFields)||{}
1).forEach(([e,t])=>{m[e]=t.value});let f=e?null==e?void 0:e.primaryParticipant:null==a?void 0:a.primaryParticipant,v=e?(null==e?void 0:e.guests)||[]:(null==a?void 0:a.guests)||[],b=e?null==e?void 0:e.additionalFields:m,y=this.getHeaders(),_=`/v3/scheduling/bookings${!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:""}`;if(0===g.length){let e=await this.makeAPIRequest(decodeURIComponent(_),"POST",JSON.stringify({additional_fields:b,additional_guests:v,guest:{...f},start_time:d.start_time.getTime()/1e3,end_time:d.end_time.getTime()/1e3,timezone:c,event_id:(null==d?void 0:d.event_id)||void 0,master_id:(null==d?void 0:d.master_id)||void 0,calendar_id:(null==d?void 0:d.calendar_id)||void 0,email_language:this.getTwoLetterLanguageCode(h)}),y);return this.schedulerStore.set("isLoading",!1),"data"in e?(this.schedulerStore.set("eventInfo",e.data),e):{error:e.error}}for(;g.length>0;){if(u=g.shift(),!p.includes(u))continue;let e=await this.makeAPIRequest(decodeURIComponent(_),"POST",JSON.stringify({participants:u?[{email:u}]:void 0,additional_fields:b,additional_guests:v,guest:{...f},start_time:d.start_time.getTime()/1e3,end_time:d.end_time.getTime()/1e3,timezone:c,email_language:this.getTwoLetterLanguageCode(h)}),y);if("data"in e)return this.schedulerStore.set("isLoading",!1),this.schedulerStore.set("eventInfo",null==e?void 0:e.data),e;if(!(null!=(i=null==(t=e.error)?void 0:t.message)&&i.startsWith("The selected timeslot is unavailable"))){this.schedulerStore.set("isLoading",!1);let t=null==(o=e.error)?void 0:o.type,i=e.error;if(t&&t in this.errors.api(n.i.t("createBookingErrorTitle"))){let e=this.getErrorMessage(i);i=this.errors.api(n.i.t("createBookingErrorTitle"))[t](e)}return{error:i}}}return this.schedulerStore.set("isLoading",!1),{error:this.errors.api(n.i.t("createBookingErrorTitle")).timeslot_not_available("The selected timeslot is unavailable")}}async getUISettings(){var e;this.schedulerStore.set("isLoading",!0);let t=this.schedulerStore.get("rescheduleBookingId"),i=this.getHeaders(),o=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"";t&&o?o+=`&booking_id=${t}`:t&&(o+=`?booking_id=${t}`);let s=`/v3/scheduling/ui-settings${o}`,r=await this.makeAPIRequest(s,"GET",void 0,i);if("error"in r){this.schedulerStore.set("isLoading",!1);let t=null==(e=r.error)?void 0:e.type,i=r.error;return t&&t in this.errors.api(n.i.t("getUISettingErrorTitle"))&&(i=this.errors.api(n.i.t("getUISettingErrorTitle"))[t]((null==i?void 0:i.message)||(null==i?void 0:i.title)||"Something went wrong")),{error:i}}return"data"in r&&this.schedulerStore.set("configSettings",r.data),this.schedulerStore.set("isLoading",!1),r}getTwoLetterLanguageCode(e){return e.split("-")[0]}getStartTimeWithMinBookingNotice(e){var t;let i=null==(t=this.schedulerStore.get("configSettings"))?void 0:t.scheduler,n=null==i?void 0:i.min_booking_notice;if(!n)return e;let o=new Date().getTime();return e<(o+6e4*n)/1e3?Math.floor((o+6e4*n)/1e3):e}getEndTimeForAvailableDaysInFuture(e){var t,i;let o=new Date,s=null==(i=null==(t=this.schedulerStore.get("configSettings"))?void 0:t.scheduler)?void 0:i.available_days_in_future;return Math.min(Math.floor((0,n.l)(o,s).getTime()/1e3),e)}async getAvailability(e=0,t=0){var i,o,s,r;this.schedulerStore.set("isLoading",!0);let a=new URLSearchParams,l=new Date,d=l.getTime();if(t&&t<d/1e3)return this.schedulerStore.set("isLoading",!1),{error:this.errors.component(n.i.t("getAvailabilityErrorTitle")).endtime_not_in_future()};e||(e=Math.floor(new Date(l.getFullYear(),l.getMonth(),1).getTime()/1e3)),t||(t=Math.floor(new Date(l.getFullYear(),l.getMonth()+1,0).getTime()/1e3)),t=this.getEndTimeForAvailableDaysInFuture(t);let c=this.getStartTimeWithMinBookingNotice(e);e=c,t=c>t?c+1:t,a.append("start_time",encodeURIComponent(e.toString())),a.append("end_time",encodeURIComponent(t.toString())),this.configId&&!this.sessionId?a.append("configuration_id",encodeURIComponent(this.configId)):this.slug&&this.clientId&&!this.sessionId&&(a.append("slug",encodeURIComponent(this.slug)),a.append("client_id",encodeURIComponent(this.clientId)));let h=this.schedulerStore.get("rescheduleBookingId");h&&a.append("booking_id",encodeURIComponent(h));let g=a.toString(),u=`/v3/scheduling/availability${g?`?${g}`:""}`,p=this.getHeaders(),m=await this.makeAPIRequest(decodeURIComponent(u),"GET",void 0,p);if("error"in m){this.schedulerStore.set("availability",[]),this.schedulerStore.set("isLoading",!1);let e=null==(i=m.error)?void 0:i.type,t=m.error;if(e&&e in this.errors.api(n.i.t("getAvailabilityErrorTitle"))){let i=this.getErrorMessage(t);t=this.errors.api(n.i.t("getAvailabilityErrorTitle"))[e](i)}return{error:t}}if("data"in m){let e=((null==(s=null==(o=m.data)?void 0:o.time_slots)?void 0:s.map(e=>({...e,start_time:new Date(1e3*e.start_time),end_time:new Date(1e3*e.end_time)})))||[]).filter(e=>e.start_time.getTime()>d).sort((e,t)=>
1e.start_time.getTime()-t.start_time.getTime());this.schedulerStore.set("availability",e);let t=(null==(r=m.data)?void 0:r.order)||[];this.schedulerStore.set("availabilityOrderEmails",t)}return this.schedulerStore.set("isLoading",!1),m}async cancelBooking(e,t){var i;if(this.schedulerStore.set("isLoading",!0),!e)return{error:this.errors.component(n.i.t("cancelBookingErrorTitle")).no_booking_id()};let o=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"",s=`/v3/scheduling/bookings/${e}${o}`,r=this.getHeaders(),a=await this.makeAPIRequest(decodeURIComponent(s),"DELETE",JSON.stringify({action:"cancel",cancellation_reason:t}),r);if("error"in a){this.schedulerStore.set("isLoading",!1);let e=null==(i=a.error)?void 0:i.type,t=a.error;if(e&&e in this.errors.api(n.i.t("cancelBookingErrorTitle"))){let i=this.getErrorMessage(t);t=this.errors.api(n.i.t("cancelBookingErrorTitle"))[e](i)}return{error:t}}return this.schedulerStore.set("cancelledEventInfo",{booking_id:e}),this.schedulerStore.set("rescheduleBookingId",""),this.schedulerStore.set("isLoading",!1),a}async rescheduleBooking(e,t){var i;if(this.schedulerStore.set("isLoading",!0),!e)return{error:this.errors.component(n.i.t("rescheduleBookingErrorTitle")).no_booking_id()};let o=this.errors.api(n.i.t("rescheduleBookingErrorTitle")),s=this.errors.component(n.i.t("rescheduleBookingErrorTitle")),{bookingInfo:r,selectedTimeslot:a,selectedTimezone:l,selectedLanguage:d}=this.schedulerStore.state,{startTime:c,endTime:h,timezone:g}=t,u=c||(null==a?void 0:a.start_time);if(!u)return{error:s.invalid_start_time('Please pass "startTime" in data or set "selectedTimeslot" in the defaultSchedulerState.')};let p=h||(null==a?void 0:a.end_time);if(!p)return{error:s.invalid_end_time('Please pass "endTime" in data or set "selectedTimeslot" in the defaultSchedulerState.')};let m=this.schedulerStore.get("availabilityOrderEmails"),f="";if(m.length>0){let e=(null==a?void 0:a.emails)||[];for(let t=0;t<m.length;t++)if(e.includes(m[t])){f=m[t];break}}let v=g||l;if(!v)return{error:s.invalid_timezone('Please pass "timezone" in data or set "selectedTimezone" in the defaultSchedulerState.')};let b=(null==a?void 0:a.event_id)||void 0,y=(null==a?void 0:a.master_id)||void 0,_=(null==a?void 0:a.calendar_id)||void 0,S={};Object.entries((null==r?void 0:r.additionalFields)||{}).forEach(([e,t])=>{S[e]=t.value});let k=t?null==t?void 0:t.primaryParticipant:null==r?void 0:r.primaryParticipant,w=t?(null==t?void 0:t.guests)||[]:(null==r?void 0:r.guests)||[],I=t?null==t?void 0:t.additionalFields:S,C=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"",T=`/v3/scheduling/bookings/${e}${C}`,E=this.getHeaders(),L=await this.makeAPIRequest(decodeURIComponent(T),"PATCH",JSON.stringify({start_time:u.getTime()/1e3,end_time:p.getTime()/1e3,timezone:v,additional_fields:I,guest:{...k},additional_guests:w,participants:f?[{email:f}]:void 0,email_language:this.getTwoLetterLanguageCode(d),event_id:b,master_id:y,calendar_id:_}),E);if("error"in L){this.schedulerStore.set("isLoading",!1);let e=null==(i=L.error)?void 0:i.type,t=L.error;if(e&&e in o){let i=this.getErrorMessage(t);t=o[e](i)}return{error:t}}let $=this.schedulerStore.get("reschedulingEventInfo");return"data"in L?this.schedulerStore.set("eventInfo",null==L?void 0:L.data):$?this.schedulerStore.set("eventInfo",$):this.schedulerStore.set("eventInfo",{booking_id:e}),this.schedulerStore.set("isLoading",!1),L}async updateBooking(e){var t;this.schedulerStore.set("isLoading",!0);let{bookingId:i,status:o,reason:s}=e,r=this.schedulerStore.get("organizerConfirmationSalt"),a="confirmed"===o?n.i.t("confirmBookingErrorTitle"):n.i.t("rejectBookingErrorTitle");if(!i)return{error:this.errors.component(a).no_booking_id()};if(!r)return{error:this.errors.component(a).no_salt()};let l=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"",d=`/v3/scheduling/bookings/${i}${l}`,c=this.getHeaders(),h=await this.makeAPIRequest(decodeURIComponent(d),"PUT",JSON.stringify({status:o,cancellation_reason:s,salt:r}),c);if("error"in h){this.schedulerStore.set("isLoading",!1);let e=null==(t=h.error)?void 0:t.type,i=h.error;if(e&&e in this.errors.api(a)){let t=this.getErrorMessage(i);i=this.errors.api(a)[e](t)}return{error:i}}return"data"in h&&"confirmed"===o?this.schedulerStore.set("confirmedEventInfo",null==h?void 0:h.data):"request_id"in h&&"cancelled"===o&&this.schedulerStore.set("cancelledEventInfo",{booking_id:i}),this.schedulerStore.set("organizerConfirmationBookingId",""),this.schedulerStore.set("isLoading",!1),h}async validateGroupEventTimeslot(e){var t,i;this.schedulerStore.set("isLoading",!0);let o=null==(t=this.schedulerStore.get("configSettings"))?void 0:t.configuration_id;if(!o)return{error:this.errors.component(n.i.t("validateTimeslotErrorTitle")).no_config_id()};let s=this.getHeaders(),r=`/v3/scheduling/configurations/${o}/group-events/validate-timeslot`,a=await this.makeAPIRequest(decodeURIComponent(r),"POST",JSON.stringify({...e,start_time:e.start_time.getTime()/1e3,end_time:e.end_time.getTime()/1e3}),s);if("error"in a){this.schedulerStore.set("isLoading",!1);let e=null==(i=a.error)?void 0:i.type,t=a.error;if(e&&e in this.errors.api(n.i.t("validateTimeslotErrorTitle"))){let i=this.getErrorMessage(t);t=this.errors.api(n.i.t("validateTimeslotErrorTitle"))[e](i)}return this.refetchAvailability(),{error:t}}return this.schedulerStore.set("selectedTimeslot",e),this.schedulerStore.set("showBookingForm",!0),this.schedulerStore.set("isLoading",!1),a}}class c{constructor({schedulerAPIURL:e,nylasSchedulerStore:t,sessionId:i,configId:n,slug:o,clientId:s}){if(!e)throw Error("schedulerAPIURL is required");if(!t)throw Error("nylasSchedulerStore is required");if(!i&&!n&&!(o||s))throw Error("sessionId is required for private configs. If using public config either pass a configurationId or a combination of slug and clientId.");"/"===e&&(e=new URL(window.location.href).origin),this.configId=n,this.sessionId=i,this.schedulerAPIURL=e,this.nylasSchedulerStore=t,this.slug=o,this.clientId=s}init(){(0,n.b)("NylasConnector init")}get schedulerStore(){return this.nylasSchedulerStore}get scheduler(){return this._schedulerAPIConnector||(this._schedulerAPIConnector=new d({schedulerAPIURL:this.schedulerAPIURL,schedulerStore:this.schedulerStore,sessionId:this.sessionId,configId:this.configId,slug:this.slug,clientId:this.clientId})),this._schedulerAPIConnector}resetStores(){this.nylasSchedulerStore.reset()}}let h=(e,t)=>{let i=e.isLoading,o=e.showNotification,s=e.nylasBranding,r=e.version;return(0,n.h)(n.F,null,o&&(0,n.h)("nylas-notification",null),i&&(0,n.h)("div",{class:"loading"},(0,n.h)("div",{class:"left"},(0,n.h)("div",{class:"skeleton"})),(0,n.h)("div",{class:"right"},(0,n.h)("div",{class:"skeleton"}),(0,n.h)("div",{class:"skeleton"}),(0,n.h)("div",{class:"skeleton"}),(0,n.h)("div",{class:"skeleton"}),(0,n.h)("div",{class:"skeleton"}))),!i&&t,(0,n.h)("div",{class:"footer"},s&&(0,n.h)("a",{href:"https://scheduler.nylas.com?utm_source=powered-by-nylas-logoutm_medium=link&utm_campaign=get-scheduler&utm_id=get-scheduler",class:"powered-by-nylas",target:"_blank",rel:"noreferrer noopener"},"Powered by\xa0",(0,n.h)("span",{class:"sr-only"},"Nylas"),(0,n.h)("nylas-logo",{"aria-hidden":!0})),(0,n.h)("tooltip-component",null,(0,n.h)("info-icon",{slot:"tooltip-icon"}),(0,n.h)("span",{slot:"tooltip-content"},r))))},g=(e,t)=>(0,n.h)("div",{class:"message-banner"},t),u={title:n.i.t("genericErrorTitle"),type:r.n.Error,category:s.E.Component},p=class{constructor(e){(0,n.r)(this,e),this.init=(0,n.a)(this,"init",7),this.schedulerWillLoad=(0,n.a)(this,"schedulerWillLoad",7),this.schedulerDidLoad=(0,n.a)(this,"schedulerDidLoad",7),this.nylasSchedulerError=(0,n.a)(this,"nylasSchedulerError",7),this.nylasSchedulerInfo=(0,n.a)(this,"nylasSchedulerInfo",7),this.configSettingsLoaded=(0,n.a)(this,"configSettingsLoaded",7),this.bookingRefExtracted=(0,n.a)(this,"bookingRefExtracted",7),this.bookedEventInfo=(0,n.a)(this,"bookedEventInfo",7),this.mode="app",this.defaultSchedulerState=void 0,this.sessionId=void 0,this.schedulerApiUrl="https://api.us.nylas.com",this.bookingInfo=void 0,this.rescheduleBookingRef=void 0,this.cancelBookingRef=void 0,this.organizerConfirmationBookingRef=void 0,this.configurationId=void 0,this.slug=void 0,this.clientId=void 0,this.nylasBranding=!0,this.eventOverrides={},this.isLoading=void 0,this.themeConfig=void 0,this.localization=void 0,this.defaultLanguage=void 0,this.showNotification=!0,this.enableUserFeedback=!0,this.hour12=void 0,this.automaticComponentRegistration=!0,this.selectedDateLabel=new Date().toLocaleDateString(navigator.language,{dateStyle:"full"})||`${n.i.t("noDateSelected")}`,this.refConfigId=void 0,this.language=navigator.language,this.show
1FeedbackModal=!1,this.bookingInfoConfirmed=null,this.version="2.0.2"}connectedCallback(){(0,n.b)("[nylas-scheduler] connectedCallback")}async componentWillLoad(){var e,t,i;let r;(0,n.b)("[nylas-scheduler] Component will load"),this.version="2.0.2",this.enableUserFeedback&&!(0,s.i)()&&(0,s.a)({dsn:"https://[email protected]/4507889638178816",release:this.version,integrations:e=>[...e.filter(e=>!1),(0,s.f)({colorScheme:"system",autoInject:!1})],autoSessionTracking:!1,beforeSend:()=>null});let l=this.schedulerWillLoad.emit(this.host);if("schedulerWillLoad"in this.eventOverrides&&(await this.eventOverrides.schedulerWillLoad(l,this.nylasSchedulerConnector),l.defaultPrevented))return;let d=new URLSearchParams(window.location.search).get("lang"),h=d&&Object.values(a.L).includes(d)?d:null;if(this.stores={scheduler:function(e={}){let t={selectedDate:null,selectedLanguage:navigator.language,selectedTimezone:Intl.DateTimeFormat().resolvedOptions().timeZone,selectedTimeslot:null,showBookingForm:!1,availabilityOrderEmails:[],selectableDates:null,availability:[],eventDuration:0,state:"ready",eventInfo:null,cancelledEventInfo:null,isLoading:!1,nylasBranding:!0,...e};(0,n.b)("[defaultNylasStoreState]: ",t);let i=(0,n.e)(t);return i.onChange("availability",e=>{(0,n.b)("[availability]: ",e);let t=e.map(e=>e.start_time);(0,n.b)("[selectableDates]: ",t),i.set("selectableDates",t);let o=e[0];if(!o)return;let s=Math.floor((o.end_time.getTime()-o.start_time.getTime())/6e4);(0,n.b)("[durationMinutes]: ",s),i.set("eventDuration",s)}),i.reset=()=>{for(let e in t){let n=t[e];i.set(e,n)}},i}({bookingInfo:this.bookingInfo,nylasBranding:this.nylasBranding,themeConfig:this.themeConfig,hour12:this.hour12,selectedLanguage:h||this.defaultLanguage||(null==(e=this.bookingInfo)?void 0:e.language)||a.L.en,...this.defaultSchedulerState})},this.baseProvider=new o.N(this.host,this.stores,this.automaticComponentRegistration,this.eventOverrides),this.refConfigId=this.configurationId,this.rescheduleBookingRef){let[e,t,i]=(0,n.k)(this.rescheduleBookingRef);this.refConfigId=e,this.stores.scheduler.set("rescheduleBookingId",t),r=this.bookingRefExtracted.emit({configurationId:e,bookingId:t})}else if(this.cancelBookingRef){let[e,t,i]=(0,n.k)(this.cancelBookingRef);this.refConfigId=e,this.stores.scheduler.set("cancelBookingId",t),r=this.bookingRefExtracted.emit({configurationId:e,bookingId:t})}else if(this.organizerConfirmationBookingRef){let[e,t,i]=(0,n.k)(this.organizerConfirmationBookingRef);this.refConfigId=e,this.stores.scheduler.set("organizerConfirmationBookingId",t),this.stores.scheduler.set("organizerConfirmationSalt",i),r=this.bookingRefExtracted.emit({configurationId:e,bookingId:t,salt:i})}if("bookingRefExtracted"in this.eventOverrides&&(await this.eventOverrides.bookingRefExtracted(r,this.nylasSchedulerConnector),r.defaultPrevented)||!this.checkIfSessionIdOrConfigIdExists())return;let g=null==(t=this.baseProvider)?void 0:t.getStore("scheduler");this.nylasSchedulerConnector=new c({schedulerAPIURL:this.schedulerApiUrl,sessionId:this.sessionId,configId:this.refConfigId,slug:this.slug,clientId:this.clientId,nylasSchedulerStore:g});let u=this.init.emit(this.host);"init"in this.eventOverrides&&(await this.eventOverrides.init(u,this.nylasSchedulerConnector),u.defaultPrevented)||(null==(i=this.baseProvider)||i.componentWillLoad(this.nylasSchedulerConnector),this.applyThemeConfig(this.themeConfig))}async componentDidLoad(){var e,t,i,n,o,s,r,a;let l;null==(e=this.baseProvider)||e.componentDidLoad();let d=this.schedulerDidLoad.emit(this.host);if("schedulerDidLoad"in this.eventOverrides&&(await this.eventOverrides.schedulerDidLoad(d,this.nylasSchedulerConnector),d.defaultPrevented)||!this.checkIfSessionIdOrConfigIdExists())return;this.localizationChanged(this.localization);let c=await (null==(t=this.nylasSchedulerConnector)?void 0:t.scheduler.getUISettings());if(!c||"error"in c){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(null==c?void 0:c.error)},host:this.host});return}{"data"in c&&null!=(i=c.data)&&i.appearance&&console.info("Appearance settings have been returned from the configuration used byt his scheduling page; please remember to grab them from the configSettingsLoaded event and apply them as desired.");let e=this.configSettingsLoaded.emit({settings:c});if("configSettingsLoaded"in this.eventOverrides&&(await this.eventOverrides.configSettingsLoaded(e,this.nylasSchedulerConnector),e.defaultPrevented))return}let h=null==(n=this.baseProvider)?void 0:n.getStore("scheduler"),g=null==(s=null==(o=null==h?void 0:h.get("configSettings"))?void 0:o.scheduler)?void 0:s.available_days_in_future,u=null==h?void 0:h.get("selectedTimeslot");if(u&&null!=u&&u.start_time){if(!this.isTimeslotValid(u))return;if(null!=h&&h.get("showBookingForm")){null==h||h.set("selectedDate",u.start_time);return}}let p=null==h?void 0:h.get("selectedDate"),m=null==h?void 0:h.get("availability");if(!(m&&m.length>0)){if(p){let{startTime:e,endTime:t,endTimeForAvailableDaysInFuture:i}=this.validateAvailableDaysInFuture(p,g||30);p.getTime()<1e3*i&&(l=await (null==(a=this.nylasSchedulerConnector)?void 0:a.scheduler.getAvailability(e,t)))}else{let e=new Date,{startTime:t,endTime:i,endTimeForAvailableDaysInFuture:n}=this.validateAvailableDaysInFuture(e,g||30);e.getTime()<1e3*n&&(l=await (null==(r=this.nylasSchedulerConnector)?void 0:r.scheduler.getAvailability(t,i)))}
1if((!l||"error"in l)&&this.nylasSchedulerError.emit({notification:{...this.getErrorObject(null==l?void 0:l.error)},host:this.host}),!p){let e=new Date,t=null==h?void 0:h.get("availability").find(e=>new Date(e.start_time)>new Date);t&&(e=t.start_time),null==h||h.set("selectedDate",e)}}}componentDisconnected(){var e;null==(e=this.baseProvider)||e.componentDisconnected()}bookingInfoChanged(e){var t,i;null==(t=this.stores)||t.scheduler.set("bookingInfo",e),null!=e&&e.language&&!this.defaultLanguage&&(null==(i=this.stores)||i.scheduler.set("selectedLanguage",e.language))}rescheduleBookingRefChanged(e){var t,i;if(e){let[o,s]=(0,n.k)(e);null==(t=this.stores)||t.scheduler.set("rescheduleBookingId",s),this.refConfigId=o,null==(i=this.nylasSchedulerConnector)||i.scheduler.setConfigId(o)}}cancelBookingRefChanged(e){var t,i;if(e){let[o,s]=(0,n.k)(e);null==(t=this.stores)||t.scheduler.set("cancelBookingId",s),this.refConfigId=o,null==(i=this.nylasSchedulerConnector)||i.scheduler.setConfigId(o)}}organizerConfirmationBookingRefChanged(e){var t,i;if(e){let[o,s]=(0,n.k)(e);null==(t=this.stores)||t.scheduler.set("organizerConfirmationBookingId",s),this.refConfigId=o,null==(i=this.nylasSchedulerConnector)||i.scheduler.setConfigId(o)}}localizationChanged(e){e&&Object.keys(e).forEach(t=>{t in a.L&&n.i.addResourceBundle(t,"translation",e[t],!1,!0)})}defaultLanguageChanged(e){var t;e&&(null==(t=this.stores)||t.scheduler.set("selectedLanguage",e),n.i.changeLanguage(e))}themeConfigChanged(e){var t,i;null==(i=null==(t=this.baseProvider)?void 0:t.getStore("scheduler"))||i.set("themeConfig",e),this.applyThemeConfig(e)}languageChanged(e){let t=e.detail;this.language=t,n.i.changeLanguage(t)}async registerComponentHandler(e){var t;null==(t=this.baseProvider)||t.registerComponent(e.detail)}async unregisterComponentHandler(e){var t;null==(t=this.baseProvider)||t.unregisterComponent(e.detail)}async monthChangedHandler(e){var t,i,n,o,s,r,a;let l=e.detail,d=null==(o=null==(n=null==(i=null==(t=this.nylasSchedulerConnector)?void 0:t.schedulerStore)?void 0:i.get("configSettings"))?void 0:n.scheduler)?void 0:o.available_days_in_future,{startTime:c,endTime:h,endTimeForAvailableDaysInFuture:g}=this.validateAvailableDaysInFuture(l,d||30);if(!e.defaultPrevented&&c<g&&l.getTime()<1e3*g){let e=await (null==(s=this.nylasSchedulerConnector)?void 0:s.scheduler.getAvailability(c,h));(!e||"error"in e)&&this.nylasSchedulerError.emit({notification:{...this.getErrorObject(null==e?void 0:e.error)},host:this.host});let t=null==(r=this.stores)?void 0:r.scheduler.get("selectableDates");t&&t.length>0&&(null==(a=this.stores)||a.scheduler.set("selectedDate",t[0]))}}mapToBookingData(e){var t,i,n;let o=null==(t=this.stores)?void 0:t.scheduler.get("selectedTimeslot"),s=null==(i=this.stores)?void 0:i.scheduler.get("selectedLanguage"),r=null==(n=this.stores)?void 0:n.scheduler.get("selectedTimezone"),a=null!=o&&o.start_time?new Date(null==o?void 0:o.start_time).getTime()/1e3:"",l=null!=o&&o.end_time?new Date(null==o?void 0:o.end_time).getTime()/1e3:"";return{additional_guests:e.guests,guest:{...e.primaryParticipant},additional_fields:{...e.additionalFields},start_time:a,end_time:l,email_language:s,timezone:r}}async bookButtonClickedHandler(e){var t,i,n,o;if(e.defaultPrevented)return;let s=e.detail,r=this.mapToBookingData(s);this.bookingInfoConfirmed=s;let a=null==(i=null==(t=this.nylasSchedulerConnector)?void 0:t.schedulerStore)?void 0:i.get("rescheduleBookingId");if(a){let e=await (null==(n=this.nylasSchedulerConnector)?void 0:n.scheduler.rescheduleBooking(a,s));(!e||"error"in e)&&this.nylasSchedulerError.emit({notification:{...this.getErrorObject(null==e?void 0:e.error)},host:this.host});let t=null==e?void 0:e.data,i=this.bookedEventInfo.emit({...e,data:{...t,...r}});this.bookingInfoConfirmed={...this.bookingInfoConfirmed,...t},"bookedEventInfo"in this.eventOverrides&&await this.eventOverrides.bookedEventInfo(i,this.nylasSchedulerConnector);return}let l=await (null==(o=this.nylasSchedulerConnector)?void 0:o.scheduler.bookTimeslot(s));
1(!l||"error"in l)&&this.nylasSchedulerError.emit({notification:{...this.getErrorObject(null==l?void 0:l.error)},host:this.host});let d=null==l?void 0:l.data,c=this.bookedEventInfo.emit({...l,data:{...d,...r}});this.bookingInfoConfirmed={...this.bookingInfoConfirmed,...d},"bookedEventInfo"in this.eventOverrides&&await this.eventOverrides.bookedEventInfo(c,this.nylasSchedulerConnector)}dateSelectedHandler(e){let t=e.detail;this.selectedDateLabel=t?t.toLocaleDateString(this.language,{dateStyle:"full"}):`${n.i.t("noDateSelected")}`}cancelBookedEventErrorHandler(e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e.detail.error)},host:this.host})}cancelBookedEventValidationErrorHandler(e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e.detail.error)},host:this.host})}rescheduleBookedEventErrorHandler(e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e.detail.error)},host:this.host})}confirmBookingErrorHandler(e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e.detail.error)},host:this.host})}feedbackModalClosedHandler(){this.showFeedbackModal=!1}eventIsFullHandler(e){let t=e.detail.error;"error"===e.detail.type?this.nylasSchedulerError.emit({notification:{...this.getErrorObject({message:t})},host:this.host}):this.nylasSchedulerInfo.emit({notification:{title:"Event is full",category:s.E.Component,type:r.n.Info,description:"The event you selected is full. Please try a different time.",id:new Date().getTime().toString(),ttl:3e3},host:this.host})}feedbackSubmittedHandler(e){let t={eventId:(0,s.c)("Scheduling Page User Feedback",{extra:{configId:this.configurationId,slug:this.slug}}),message:e.detail.feedback};(0,s.b)(t,{includeReplay:!0,captureContext:{tags:{"nylas-web-element":"nylas-scheduling","nylas-web-element-version":this.version,"nylas-config-id":this.configurationId,"nylas-slug":this.slug,"host-url":window.location.href},extra:{configId:this.configurationId,slug:this.slug,version:this.version}}}),this.showFeedbackModal=!1}async getNylasSchedulerStore(){var e;return null==(e=this.baseProvider)?void 0:e.getStore("scheduler")}async getNylasSchedulerConnector(){return this.nylasSchedulerConnector}async getRef(){return this.host}getErrorObject(e){return{title:(null==e?void 0:e.title)||u.title,category:(null==e?void 0:e.category)||u.category,type:r.n.Error,description:(null==e?void 0:e.message)||"",id:new Date().getTime().toString(),ttl:"none"}}checkIfSessionIdOrConfigIdExists(){if(!this.sessionId&&!this.refConfigId&&!(this.slug&&this.clientId)){let e="";return this.sessionId||(e+=n.i.t("sessionIdRequiredErrorMessage")),this.sessionId||this.refConfigId||this.slug&&this.clientId||(e=n.i.t("sessionIdRequiredErrorMessage")+" "+n.i.t("publicConfigErrorMessage")),this.nylasSchedulerError.emit({notification:{title:n.i.t("schedulingComponentErrorTitle"),category:s.E.Component,type:r.n.Error,description:e,id:new Date().getTime().toString(),ttl:"none"},host:this.host}),!1}return!0}isTimeslotValid(e){return!(new Date(e.start_time)<new Date)||(this.nylasSchedulerError.emit({notification:{title:n.i.t("invalidTimeslotErrorTitle"),category:s.E.Component,type:r.n.Error,description:n.i.t("invalidTimeslotErrorMessage"),id:new Date().getTime().toString(),ttl:"none"},host:this.host}),!1)}validateAvailableDaysInFuture(e,t){let i=new Date,o=new Date(e.getFullYear(),e.getMonth(),1).getTime()/1e3,s=new Date(e.getFullYear(),e.getMonth()+1,1).getTime()/1e3,r=Math.floor((0,n.l)(i,t).getTime()/1e3);return{startTime:o<i.getTime()/1e3?Math.floor(i.getTime()/1e3):o,endTime:Math.min(r,s),endTimeForAvailableDaysInFuture:r}}
1applyThemeConfig(e){if(e)for(let[t,i]of Object.entries(e))this.host.style.setProperty(`${t}`,i)}onFeedbackClick(e){e.preventDefault(),this.showFeedbackModal=!0}redirectToCustomUrl(e){window.location.assign(e)}nylasFormDropdownChangedHandler(e){var t,i;let{name:o,value:s}=e.detail;if("language"===o){let e=a.L[s];n.i.changeLanguage(e),null==(i=null==(t=this.stores)?void 0:t.scheduler)||i.set("selectedLanguage",e)}}render(){var e,t,i,o,s,r,l,d,c,u,p,m;let f="app"===this.mode,v=null==(e=this.baseProvider)?void 0:e.getStore("scheduler"),b=null==v?void 0:v.get("eventInfo"),y=null==v?void 0:v.get("showBookingForm"),_=null==v?void 0:v.get("cancelledEventInfo"),S=null==v?void 0:v.get("cancelBookingId"),k=null==v?void 0:v.get("selectedTimeslot"),w=null==v?void 0:v.get("rescheduleBookingId"),I=null==v?void 0:v.get("organizerConfirmationBookingId"),C=null==v?void 0:v.get("rejectBookingId"),T=null==v?void 0:v.get("confirmedEventInfo"),E=(null==v?void 0:v.get("nylasBranding"))||this.nylasBranding,L=null==v?void 0:v.get("selectedDate"),$=null==(i=null==(t=null==v?void 0:v.get("configSettings"))?void 0:t.scheduler)?void 0:i.confirmation_redirect_url;this.selectedDateLabel=L&&this.language?(0,n.m)(L.toLocaleDateString(this.language,{dateStyle:"full"})):`${n.i.t("noDateSelected")}`;let x=Object.keys(a.a).map(e=>({label:a.a[e],value:e})),R=(null==v?void 0:v.get("selectedLanguage"))||this.defaultLanguage||navigator.language||a.L.en;if(f&&(S||C)&&!_)return(0,n.h)(n.H,null,(0,n.h)(h,{version:this.version,nylasBranding:E,isLoading:this.isLoading,showNotification:this.showNotification},(0,n.h)("div",{class:"cancel-flow-page",part:"cancel-flow-page"},(0,n.h)("nylas-cancel-booking-form",{selectedTimeslot:k,cancelBookingId:S,rejectBookingId:C,exportparts:"ncbf, ncbf__icon, ncbf__title, ncbf__description, ncbf__reason-textarea, ncbf__button-cta, ncbf__button-outline, ncbf__card"}))),(0,n.h)("div",{class:"language-feedback-container"},this.enableUserFeedback&&(0,n.h)("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},(0,n.h)("feedback-icon",null)),(0,n.h)("select-dropdown",{name:"language",searchPlaceholder:n.i.t("search"),options:x,withChevron:!1,defaultSelectedOption:x.find(e=>e.value==R),exportparts:"sd_dropdown: nse__language-dropdown, sd_dropdown-button: nse__language-drop-button, sd_dropdown-content: nse__language-drop-content, sd_dropdown_label: nse__language-drop-label"},(0,n.h)("span",{slot:"select-icon"},(0,n.h)("translate-icon",{width:"20",height:"20"})))),this.showFeedbackModal&&(0,n.h)("nylas-feedback-form",null));if(f&&I)return(0,n.h)(n.H,null,(0,n.h)(h,null,(0,n.h)("div",{class:"manual-confirmation-page",part:"manual-confirmation-page"},(0,n.h)("nylas-organizer-confirmation-card",{organizerConfirmationBookingId:I,exportparts:"nmcc, nmcc__title, nmcc__description, nmcc__button-cta, nmcc__button-outline"}))),(0,n.h)("div",{class:"language-feedback-container"},this.enableUserFeedback&&(0,n.h)("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},(0,n.h)("feedback-icon",null)),(0,n.h)("select-dropdown",{name:"language",searchPlaceholder:n.i.t("search"),options:x,withChevron:!1,defaultSelectedOption:x.find(e=>e.value==R),exportparts:"sd_dropdown: nse__language-dropdown, sd_dropdown-button: nse__language-drop-button, sd_dropdown-content: nse__language-drop-content, sd_dropdown_label: nse__language-drop-label"},(0,n.h)("span",{slot:"select-icon"},(0,n.h)("translate-icon",{width:"20",height:"20"})))),this.showFeedbackModal&&(0,n.h)("nylas-feedback-form",null));if(f&&_)return(0,n.h)(n.H,null,(0,n.h)(h,{version:this.version,nylasBranding:E,isLoading:this.isLoading,showNotification:this.showNotification},(0,n.h)("div",{class:"cancelled-event-page",part:"cancelled-event-page"},(0,n.h)("nylas-cancelled-event-card",{cancelledEventInfo:_,exportparts:"ncec, ncec__icon, ncec__title, ncec__description, ncec__button-outline, ncec__card"}))),(0,n.h)("div",{class:"language-feedback-container"},this.enableUserFeedback&&(0,n.h)("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},(0,n.h)("feedback-icon",null)),(0,n.h)("select-dropdown",{name:"language",searchPlaceholder:n.i.t("search"),options:x,withChevron:!1,defaultSelectedOption:x.find(e=>e.value==R),exportparts:"sd_dropdown: nse__language-dropdown, sd_dropdown-button: nse__language-drop-button, sd_dropdown-content: nse__language-drop-content, sd_dropdown_label: nse__language-drop-label"},(0,n.h)("span",{slot:"select-icon"},(0,n.h)("translate-icon",{width:"20",height:"20"}
1)))),this.showFeedbackModal&&(0,n.h)("nylas-feedback-form",null));if(f&&T)return(0,n.h)(n.H,null,(0,n.h)(h,{version:this.version,nylasBranding:E,isLoading:this.isLoading,showNotification:this.showNotification},(0,n.h)("div",{class:"cancelled-event-page",part:"confirmed-event-page"},(0,n.h)("nylas-confirmed-event-card",{confirmedEventInfo:T,exportparts:"ncec, ncec__icon, ncec__title, ncec__description, ncec__button-outline, ncec__card"}))),(0,n.h)("div",{class:"language-feedback-container"},this.enableUserFeedback&&(0,n.h)("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},(0,n.h)("feedback-icon",null)),(0,n.h)("select-dropdown",{name:"language",searchPlaceholder:n.i.t("search"),options:x,withChevron:!1,defaultSelectedOption:x.find(e=>e.value==R),exportparts:"sd_dropdown: nse__language-dropdown, sd_dropdown-button: nse__language-drop-button, sd_dropdown-content: nse__language-drop-content, sd_dropdown_label: nse__language-drop-label"},(0,n.h)("span",{slot:"select-icon"},(0,n.h)("translate-icon",{width:"20",height:"20"})))),this.showFeedbackModal&&(0,n.h)("nylas-feedback-form",null));if(f&&b&&$){let e=null==(o=this.bookingInfoConfirmed)?void 0:o.primaryParticipant,t=null==(s=this.bookingInfoConfirmed)?void 0:s.location,i=null==(r=this.bookingInfoConfirmed)?void 0:r.booking_ref,n=(null==(l=this.bookingInfoConfirmed)?void 0:l.additionalFields)||{};if(this.bookingInfo&&"u">typeof(null==(d=this.bookingInfo)?void 0:d.additionalFields)){let e=this.bookingInfo.additionalFields;Object.keys(e).forEach(t=>{!n[t]&&null!=e&&e[t]&&(n[t]=e[t].value)})}let a=null==(c=this.stores)?void 0:c.scheduler.get("selectedTimeslot"),h=null==(u=this.stores)?void 0:u.scheduler.get("selectedTimezone"),g=null==(p=this.stores)?void 0:p.scheduler.get("selectedLanguage"),f=null==(m=this.stores)?void 0:m.scheduler.get("configSettings"),v=this.configurationId?this.configurationId:null==f?void 0:f.configuration_id,y=new URLSearchParams(window.location.search);y.set("booking_id",b.booking_id),null!=e&&e.name&&y.set("name",e.name),null!=e&&e.email&&y.set("email",e.email),null!=a&&a.start_time&&y.set("start_time",(new Date(a.start_time).getTime()/1e3).toString()),null!=a&&a.end_time&&y.set("end_time",(new Date(a.end_time).getTime()/1e3).toString()),h&&y.set("tz",h),g&&y.set("language",g),n&&y.set("additional_values",JSON.stringify(n)),this.slug&&y.set("page_slug",this.slug),v&&y.set("config_id",v),t&&y.set("location",t),i&&y.set("booking_ref",i),this.redirectToCustomUrl(`${$}?${y.toString()}`);return}if(f&&b)return(0,n.h)(n.H,null,(0,n.h)(h,{version:this.version,nylasBranding:E,isLoading:this.isLoading,showNotification:this.showNotification},(0,n.h)("div",{class:"booked-event-page",part:"booked-event-page ns_booked-event-page"},(0,n.h)("nylas-booked-event-card",{selectedTimeslot:k,eventInfo:b,exportparts:"nbec, nbec__title, nbec__card, nbec__description, nbec__button-outline, nbec__cancel-cta, nbec__reschedule-cta"}))),(0,n.h)("div",{class:"language-feedback-container"},this.enableUserFeedback&&(0,n.h)("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},(0,n.h)("feedback-icon",null)),(0,n.h)("select-dropdown",{name:"language",searchPlaceholder:n.i.t("search"),options:x,withChevron:!1,defaultSelectedOption:x.find(e=>e.value==R),exportparts:"sd_dropdown: nse__language-dropdown, sd_dropdown-button: nse__language-drop-button, sd_dropdown-content: nse__language-drop-content, sd_dropdown_label: nse__language-drop-label"},(0,n.h)("span",{slot:"select-icon"},(0,n.h)("translate-icon",{width:"20",height:"20"})))),this.showFeedbackModal&&(0,n.h)("nylas-feedback-form",null));if(f&&(!b||w)&&!y){let e=this.host.querySelector('[slot="timeslot-picker-cta-label"]');return(0,n.h)(n.H,null,(0,n.h)(h,{version:this.version,nylasBranding:E,isLoading:this.isLoading,showNotification:this.showNotification},w&&(0,n.h)(g,null,`${n.i.t("rescheduleTitle")}`),(0,n.h)("div",{class:"select-date-page",part:"select-date-page ns_select-date-page"},(0,n.h)("div",{class:"left-panel",part:"ns_left-panel"},(0,n.h)("nylas-date-picker",{exportparts:"ndp, ndp__title, ndp__month-header, ndp__month-button, ndp__day, ndp__date, ndp__date--disabled, ndp__date--selected, ndp__date--current-day, ndp__date--current-month"}),(0,n.h)("nylas-locale-switch",{exportparts:"nls, nls__timezone, nls__timezone-dropdown, nls__timezone-drop-button, nls__timezone-drop-button-selected-label, nls__timezone-drop-content, nls__timezone-drop-label, nls__language, nls__language-dropdown, nls__language-drop-button, nls__language-drop-content, nls__language-drop-label"})),(0,n.h)("div",{class:`right-panel ${w?"reschedule":""}`,part:`ns_right-panel ${w?"ns_reschedule":""}`},(0,n.h)("h2",{part:"ns_right-panel__title"},(0,n.h)("calendar-icon",{part:"ns_right-panel__calendar-icon"}),(0,n.h)("span",{id:"selectedDate",part:"ns_right-panel__selected-date"},this.selectedDateLabel)),(0,n.h)("nylas-timeslot-picker",{exportparts:"ntp, ntp__time-picker-wrapper, ntp__timeslots, ntp__timeslot, ntp__timeslot--selected, ntp__button-primary"},e&&(0,n.h)("span",{slot:"timeslot-picker-cta-label"},(0,n.h)("slot",{name:"timeslot-picker-cta-label"})))))),this.enableUserFeedback&&(0,n.h)("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)}
1,(0,n.h)("feedback-icon",null)),this.showFeedbackModal&&(0,n.h)("nylas-feedback-form",null))}return f&&!b&&y?(0,n.h)(n.H,null,(0,n.h)(h,{version:this.version,nylasBranding:E,isLoading:this.isLoading,showNotification:this.showNotification},w&&(0,n.h)(g,null,`${n.i.t("rescheduleTitle")}`),(0,n.h)("div",{class:"additional-data-page",part:"additional-data-page ns_additional-data-page"},(0,n.h)("div",{class:"left-panel ns_left-panel",part:"ns_left-panel"},(0,n.h)("div",{class:"wrapper",part:"ns_left-panel__wrapper"},(0,n.h)("nylas-selected-event-card",{exportparts:"nsec, nsec__card, nsec__icon, nsec__date, nsec__time, nsec__timezone"}))),(0,n.h)("div",{class:`right-panel ${w?"reschedule":""}`,part:`ns_right-panel ${w?"ns_reschedule":""}`},(0,n.h)("nylas-booking-form",{exportparts:"nbf, nbf__input-textfield, nbf__button-ghost, nbf__button-outline, nbf__button-primary, nbf__input-wrapper, nbf__checkbox-component, nbf__radio-button-group, nbf__textarea-component, nbf__dropdown, nbf__dropdown-button, nbf__dropdown-content"})))),(0,n.h)("div",{class:"language-feedback-container"},this.enableUserFeedback&&(0,n.h)("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},(0,n.h)("feedback-icon",null)),(0,n.h)("select-dropdown",{name:"language",searchPlaceholder:n.i.t("search"),options:x,withChevron:!1,defaultSelectedOption:x.find(e=>e.value==R),exportparts:"sd_dropdown: nse__language-dropdown, sd_dropdown-button: nse__language-drop-button, sd_dropdown-content: nse__language-drop-content, sd_dropdown_label: nse__language-drop-label"},(0,n.h)("span",{slot:"select-icon"},(0,n.h)("translate-icon",{width:"20",height:"20"})))),this.showFeedbackModal&&(0,n.h)("nylas-feedback-form",null)):(0,n.h)(n.H,null,(0,n.h)("slot",null))}get host(){return(0,n.g)(this)}static get watchers(){return{bookingInfo:["bookingInfoChanged"],rescheduleBookingRef:["rescheduleBookingRefChanged"],cancelBookingRef:["cancelBookingRefChanged"],organizerConfirmationBookingRef:["organizerConfirmationBookingRefChanged"],localization:["localizationChanged"],defaultLanguage:["defaultLanguageChanged"],themeConfig:["themeConfigChanged"]}}};p.style=':host{display:flex;flex-direction:column;overflow:visible;border-radius:var(--nylas-border-radius-2x);width:fit-content;background:var(--nylas-base-0);position:relative;box-shadow:0px 4px 8px 2px rgba(0, 0, 0, 0.05), 0px 8px 16px -2px rgba(0, 0, 0, 0.1);--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-color-blue-100:#e0e6f9;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif;--nylas-color-black:#000000;--nylas-color-grey-900:#2c2c2c;--nylas-color-grey-800:#4b4b4b;--nylas-color-grey-700:#6e6e6e;--nylas-color-grey-600:#8e8e8e;--nylas-color-grey-500:#b3b3b3;--nylas-color-grey-400:#cacaca;--nylas-color-grey-300:#e1e1e1;--nylas-color-grey-200:#eaeaea;--nylas-color-grey-100:#f5f5f5;--nylas-color-grey-50:#fbfcfe;--nylas-color-white:#ffffff;--nylas-color-red-900:#992222;--nylas-color-red-700:#cc4841;--nylas-color-red-500:#ff786a;--nylas-color-red-300:#ffa79e;--nylas-color-red-100:#ffc5bf;--nylas-color-red-50:#ffeae8;--nylas-color-blue-900:#213571;--nylas-color-blue-700:#314fa9;--nylas-color-blue-500:#4169e1;--nylas-color-blue-300:#bdccf9;--nylas-color-blue-100:#e0e6f9;--nylas-color-blue-50:#f6f8fd;--nylas-color-yellow-900:#7c6506;--nylas-color-yellow-700:#c29f09;--nylas-color-yellow-500:#f7c90b;--nylas-color-yellow-300:#f9de70;--nylas-color-yellow-100:#fceba9;--nylas-color-yellow-50:#fdf4ce;--nylas-color-green-900:#0e6b60;--nylas-color-green-700:#16a392;--nylas-color-green-500:#17c3b2;--nylas-color-green-300:#74dbd1;--nylas-color-green-100:#a2e7e0;--nylas-color-green-50:#d1f3f0;--nylas-color-purple-900:#643554;--nylas-color-purple-700:#954f7d;--nylas-color-purple-500:#c769a7;--nylas-color-purple-300:#dda5ca;--nylas-color-purple-100:#e0bdd6;--nylas-color-purple-50:#e9dde5;--nylas-color-sky-900:#20698f;--nylas-color-sky-700:#2b8fc2;--nylas-color-sky-500:#6dceff;--nylas-color-sky-300:#8fdaff;--nylas-color-sky-100:#b8e7ff;--nylas-color-sky-50:#d9f2ff;font-family:var(--nylas-font-family);font-optical-sizing:auto;font-style:normal;font-variation-settings:"slnt" 0}@media screen and (max-width: 768px){:host{width:auto;min-width:325px}}:root{font-family:inherit}.error{padding:8rem 12rem;color:var(--nylas-base-0);background-color:var(--nylas-error);margin:1.5rem;border-radius:var(--nylas-border-radius-2x)}.message-banner{text-align:right;color:var(--nylas-base-800);padding:1rem;border-bottom:1px solid var(--nylas-color-primary-200);margin:0}.loading{margin:1.5rem;display:flex;gap:1rem}.loading .skeleton{border-radius:var(--nylas-border-radius-2x);animation:pulsate 1.5s infinite}.loading .skeleton:nth-child(2){animation-delay:-100ms}.loading .skeleton:nth-child(3){animation-delay:-200ms}.loading .skeleton:nth-child(4){animation-delay:-300ms}
1.loading .skeleton:nth-child(5){animation-delay:-400ms}.loading .left .skeleton{height:100%;width:400px}.loading .right .skeleton{height:5rem;width:300px;margin-bottom:1rem}.loading .right .skeleton:last-child{margin-bottom:0}@keyframes pulsate{0%{background-color:var(--nylas-base-50)}50%{background-color:var(--nylas-base-100)}100%{background-color:var(--nylas-base-50)}}.select-date-page,.additional-data-page,.booked-event-page,.manual-confirmation-page,.cancelled-event-page,.cancel-flow-page{border-top-left-radius:var(--nylas-border-radius-2x);border-top-right-radius:var(--nylas-border-radius-2x)}.select-date-page,.additional-data-page{display:flex}@media screen and (max-width: 768px){.select-date-page,.additional-data-page{flex-direction:column}}.booked-event-page,.manual-confirmation-page{background-color:var(--nylas-base-50)}.cancelled-event-page,.manual-confirmation-page,.cancel-flow-page{padding:1rem;height:496px;display:flex;justify-content:center;align-items:center}.booked-event-page,.manual-confirmation-page,.cancelled-event-page,.cancel-flow-page{min-width:784px;background:var(--nylas-base-50)}@media screen and (max-width: 768px){.booked-event-page,.manual-confirmation-page,.cancelled-event-page,.cancel-flow-page{min-width:90%}}.left-panel{display:flex;flex-direction:column;min-width:424px;border-top-left-radius:inherit;background:var(--nylas-base-0);position:relative;padding:1rem 0 0 0;height:624px}@media screen and (max-width: 768px){.left-panel{border-top-right-radius:inherit;min-width:unset;height:auto}}@media screen and (max-width: 768px){.select-date-page .left-panel{height:624px}}.border{margin-left:-20px;margin-right:-20px;border-top-width:1px;height:0.5px;background-color:var(--nylas-base-200)}@media screen and (max-width: 768px){.border{display:none}}.right-panel{min-width:360px;width:360px;background-color:var(--nylas-base-50);height:624px;padding-top:16px;border-left:1px solid var(--nylas-base-200);border-top-right-radius:inherit}.right-panel.reschedule{border-top-right-radius:0px}@media screen and (max-width: 768px){.right-panel{border-top-right-radius:0px;width:inherit;min-width:unset;height:auto;border-left:none}}.right-panel h2{display:flex;margin:0;height:48px;gap:0.5rem;justify-content:center;align-items:center;width:auto;font-size:1.125rem;line-height:1.5rem;font-weight:500;text-align:center;color:var(--nylas-base-800)}.additional-data-page .left-panel{background-color:var(--nylas-base-50)}.additional-data-page .right-panel{background-color:var(--nylas-base-0)}nylas-selected-event-card{height:604px;padding:0 1rem}@media screen and (max-width: 768px){nylas-selected-event-card{height:250px}}.footer{display:flex;justify-content:flex-end;align-items:center;gap:8px;padding:16px;font-size:14px;font-weight:300;color:var(--nylas-base-500);border-top:1px solid var(--nylas-base-200);min-height:24px}.footer .powered-by-nylas{display:flex;align-items:center;text-decoration:none;color:var(--nylas-base-500)}.footer .powered-by-nylas:hover{color:var(--nylas-base-800)}.footer svg{fill:var(--nylas-base-500)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0}.footer svg{margin-top:1px}nylas-selected-event-card::part(nsec__timezone){position:absolute;bottom:0}nylas-notification{margin:1.5rem;width:-webkit-fill-available;width:-moz-available;position:absolute}nylas-locale-switch{position:absolute;padding:18px 20px;bottom:0;width:-webkit-fill-available;width:-moz-available;border-top:1px solid var(--nylas-base-200)}@media screen and (max-width: 768px){nylas-locale-switch{height:auto}}nylas-date-picker{padding:0 20px}button-component#report-issue{width:auto;position:absolute;bottom:4px;left:16px}.language-feedback-container{width:auto;position:absolute;bottom:4px;left:16px;display:flex;gap:8px;align-items:center}.language-feedback-container button-component#report-issue{position:initial}nylas-feedback-form{position:absolute;top:0;height:100%;width:100%;display:flex;flex-direction:column;justify-content:center;align-items:center;background:rgba(0, 0, 0, 0.6);z-index:2;border-radius:inherit}'}}]); 2//# sourceMappingURL=2402.12e9c9450c19a67b.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.