{"version":3,"file":"app-b4b1fd3e.9729664bca28a8e6916d.bundle.js","mappings":";;;;;;;;;;;;;;;AAAA;AACA;AAEA;AAIA;AAAA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AAGA;AACA;AACA;AAtBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AAiBA;AAAA;AAdA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAIA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAGA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAxIA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC5BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AA+DA;AAAA;AA7DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AACA;AACA;AAEA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAOA;AACA;AAEA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AAAA;AAAA;AAAA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AA3WA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AChBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAcA;AAAA;AACA;AAAA;AAEA;AAAA;AACA;AAAA;AACA;AAAA;AACA;AAAA;AAaA;AAAA;AA/BA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAIA;AAAA;AAAA;AAAA;AAAA;AAMA;AAEA;AACA;AAEA;AACA;AAEA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAMA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA5VA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;;;;;;;;;;;;;AClBA;AACA;AAEA;AASA;AAAA;AAPA;AACA;AAEA;AACA;AAIA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AArCA;;;;;;;;;;;;;;;;;;;;;;;;;ACHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAOA;AAAA;AALA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AAIA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;AC9EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAaA;AAAA;AAXA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAIA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AAxEA;;;;;;;;;;;;;;;;;;;ACTA;AACA;AACA;AACA;AACA;AAEA;AAGA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AACA;AAGA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AA/DA;;;;;;;;;;;;;;;ACNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;ACPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;ACPA;AACA;AACA;AACA;;;;;;;;;;;ACHA;AACA;AACA;AACA;;;;;;;;;;;ACHA;AACA;AACA;AACA;;;;;;;;;;;ACHA;AACA;AACA;AACA;;;;;;;;;;;ACHA;AACA;AACA;AACA;;;;;;;;;;;ACHA;AACA;AACA;AACA;;;;;;;;;;;ACHA;AACA;AACA;AACA;;;;;;;;;;;ACHA;AACA;AACA;AACA","sources":["webpack://www.zeusteam.com/./src/members/integrations/_index.js","webpack://www.zeusteam.com/./src/members/integrations/calendar.js","webpack://www.zeusteam.com/./src/members/integrations/dialog/booking-calendar-editor.js","webpack://www.zeusteam.com/./src/members/integrations/dialog/your-calendar-online-editor.js","webpack://www.zeusteam.com/./src/members/integrations/nylas-callback.js","webpack://www.zeusteam.com/./src/members/leaderboards/dialogs/leaderboard-entry-editor.js","webpack://www.zeusteam.com/./src/members/leaderboards/entries.js","webpack://www.zeusteam.com/./src/members/leads/_index.js","webpack://www.zeusteam.com/./src/members/integrations/dialog/booking-calendar-editor.scss","webpack://www.zeusteam.com/./src/members/integrations/dialog/your-calendar-online-editor.scss","webpack://www.zeusteam.com/./src/members/integrations/_index.html","webpack://www.zeusteam.com/./src/members/integrations/calendar.html","webpack://www.zeusteam.com/./src/members/integrations/dialog/booking-calendar-editor.html","webpack://www.zeusteam.com/./src/members/integrations/dialog/your-calendar-online-editor.html","webpack://www.zeusteam.com/./src/members/integrations/nylas-callback.html","webpack://www.zeusteam.com/./src/members/leaderboards/dialogs/leaderboard-entry-editor.html","webpack://www.zeusteam.com/./src/members/leaderboards/entries.html","webpack://www.zeusteam.com/./src/members/leads/_index.html"],"sourcesContent":["import { PLATFORM } from 'aurelia-pal';\r\nimport { I18n } from 'common/i18n';\r\n\r\nexport class Index {\r\n static inject = [I18n];\r\n _i18n;\r\n\r\n constructor(i18n) {\r\n this._i18n = i18n;\r\n }\r\n\r\n configureRouter(config, router){\r\n config.map([\r\n {\r\n route: ['nylas', 'nylas/:from'],\r\n moduleId: PLATFORM.moduleName('members/integrations/nylas-callback'),\r\n nav: false,\r\n membersOnly: true,\r\n adminOnly: false,\r\n settings: { canAddToMobileMenu: false },\r\n },\r\n ]);\r\n\r\n this.router = router;\r\n }\r\n}\r\n","import { PLATFORM } from 'aurelia-pal';\r\nimport { bindable, observable, computedFrom } from 'aurelia-framework';\r\nimport { Security } from 'common/security';\r\nimport { Nylas } from 'services/nylas';\r\nimport { Calendar as CalendarSvc } from 'services/calendar';\r\nimport { Members } from 'services/members';\r\nimport { Notifier } from 'common/ui';\r\nimport { DialogService } from 'aurelia-dialog';\r\nimport { NewInstance } from 'aurelia-dependency-injection';\r\nimport { ValidationRules, ValidationController } from 'aurelia-validation';\r\nimport { BootstrapFormValidationRenderer } from 'validation/bootstrap-form-validation-renderer';\r\nimport { YourCalendarOnlineEditor } from './dialog/your-calendar-online-editor';\r\nimport copy from 'copy-to-clipboard';\r\nPLATFORM.moduleName('./dialog/your-calendar-online-editor');\r\n\r\n\r\nexport class Calendar {\r\n static inject = [Security, Nylas, CalendarSvc, Members, Notifier, DialogService, NewInstance.of(ValidationController)];\r\n\r\n _security;\r\n _nylas;\r\n _calendar;\r\n _members;\r\n _notifier;\r\n _dialogService;\r\n _validationController;\r\n\r\n @bindable memberId;\r\n @observable email;\r\n nylasAuthUrl;\r\n downlineUsesBookingCalendars = false;\r\n forMemberId;\r\n\r\n constructor(security, nylas, calendar, members, notifier, dialogService, validationController) {\r\n this._security = security;\r\n this._nylas = nylas;\r\n this._calendar = calendar;\r\n this._members = members;\r\n this._notifier = notifier;\r\n this._dialogService = dialogService;\r\n\t\tthis._validationController = validationController;\r\n\t\tthis._validationController.addRenderer(new BootstrapFormValidationRenderer());\r\n\r\n\t\tValidationRules\r\n .ensure('email').required().email()\r\n .on(this);\r\n }\r\n\r\n async attached() {\r\n this._isAttached = true;\r\n await this._initialize();\r\n }\r\n\r\n memberIdChanged() {\r\n if (!this._isAttached) return;\r\n this._initialize();\r\n }\r\n\r\n emailChanged() {\r\n if (!this._initialized) return;\r\n if (!this.email) {\r\n this.nylasAuthUrl = undefined;\r\n return;\r\n }\r\n this._loadNylasAuthUrl();\r\n }\r\n\r\n async _initialize() {\r\n if (!this.memberId) return;\r\n try {\r\n if (!this._security.isAuthenticatedMember(this.memberId)) {\r\n // Need to load up the agent and load all calendar details for the agent\r\n const agent = await this._members.getMember(this.memberId);\r\n this.forMemberId = this.memberId;\r\n this.email = agent.email;\r\n this.canSetSchedulingPages = agent.isAgency;\r\n } else {\r\n this.email = this._security.agent.email;\r\n this.canSetSchedulingPages = this._security.isAgency();\r\n }\r\n this.mustReauth = await this._nylas.mustReauth(this.forMemberId);\r\n await this._load();\r\n this.nylasAuthenticated = await this._nylas.isAuthenticated(this.forMemberId);\r\n } catch (err) {\r\n console.log(err);\r\n } finally {\r\n this._initialized = true;\r\n }\r\n }\r\n\r\n async _load() {\r\n try {\r\n this.loading = true;\r\n await Promise.all[this._loadNylasAuthUrl(), this._loadYourCalendarOnline(), this._loadActions()];\r\n } catch (err) {\r\n console.log(err);\r\n } finally {\r\n this.loading = false;\r\n }\r\n }\r\n\r\n async _loadYourCalendarOnline() {\r\n try {\r\n this.yco = await this._calendar.yourCalendarOnline(this.forMemberId);\r\n console.log('YCO', this.yco);\r\n this.ycoPreviewQs = this.yco.isActive ? '' : '?preview=true';\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n async _loadNylasAuthUrl() {\r\n try {\r\n const v = await this._validationController.validate();\r\n if (!v.valid) return;\r\n this.authorizedEmail = await this._nylas.authorizedEmail(this.forMemberId);\r\n const email = await this._nylas.email(this.email, this.forMemberId);\r\n this.nylasAuthUrl = await this._nylas.redirectToAuthUrl(email, undefined, this.forMemberId);\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n async _loadActions() {\r\n try {\r\n if (!this.canSetSchedulingPages) return; // only agencies get this option\r\n this.downlineUsesBookingCalendars = this._calendar.downlineUsesBookingCalendars();\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n async reauthNylas() {\r\n try {\r\n await this._nylas.resetAuth(this.forMemberId);\r\n this.mustReauth = await this._nylas.mustReauth(this.forMemberId);\r\n this._loadNylasAuthUrl();\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n copyToClipboard(bookingCalendarId) {\r\n let url = this.yco.url;\r\n if (bookingCalendarId) url += `/booking/${encodeURIComponent(bookingCalendarId)}`;\r\n\t copy(url);\r\n this._notifier.success('your-calendar-online-url-copy-success');\r\n }\r\n\r\n async openEdit() {\r\n this._dialogService.open({ viewModel: YourCalendarOnlineEditor, model: { memberId: this.memberId, yourCalendarOnline: this.yco }, ignoreTransitions: true }).whenClosed(response => {\r\n this._initialize();\r\n });\r\n return false;\r\n }\r\n\r\n async setDownlineUseBookingCalendars(checked) {\r\n try {\r\n await this._calendar.setDownlineUseBookingCalendars(checked, this.forMemberId);\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n}","import { Security } from 'common/security';\r\nimport { DialogController } from 'aurelia-dialog';\r\nimport { NewInstance } from 'aurelia-dependency-injection';\r\nimport { ValidationRules, ValidationController } from 'aurelia-validation';\r\nimport { BootstrapFormValidationRenderer } from 'validation/bootstrap-form-validation-renderer';\r\nimport { Calendar } from 'services/calendar';\r\nimport { Nylas } from 'services/nylas';\r\nimport { Notifier } from 'common/ui';\r\nimport { c } from 'common/common';\r\nimport { LpfnUtil } from 'common/utils';\r\nimport { Pipelines } from 'services/pipelines';\r\nimport { I18n } from 'common/i18n';\r\nimport { PERSON_TYPE } from 'common/constants';\r\nimport { Config } from 'services/config';\r\nimport { Content } from 'services/content';\r\n\r\nexport class BookingCalendarEditor {\r\n static inject = [Security, DialogController, NewInstance.of(ValidationController), Calendar, Nylas, Notifier, Pipelines, I18n, Config, Content];\r\n _security;\r\n dialogController;\r\n _calendar;\r\n _nylas;\r\n _notifier;\r\n _pipelines;\r\n _i18n;\r\n _config;\r\n _content;\r\n\r\n tab;\r\n tabs = [\r\n { code: 'event', title: 'booking-calendar-event', icon: 'fa-duotone fa-solid fa-calendar-clock' },\r\n { code: 'availability', title: 'booking-calendar-availability', icon: 'fa-duotone fa-solid fa-calendar-range' },\r\n { code: 'booking-options', title: 'booking-calendar-booking-options', icon: 'fa-duotone fa-solid fa-arrow-progress' },\r\n { code: 'fields', title: 'booking-calendar-fields', icon: 'fa-duotone fa-solid fa-square-list' },\r\n { code: 'emails', title: 'booking-calendar-emails', icon: 'fa-duotone fa-solid fa-envelope-circle-check' },\r\n { code: 'reminders', title: 'booking-calendar-reminders', icon: 'fa-duotone fa-solid fa-alarm-clock' },\r\n { code: 'guest', title: 'booking-calendar-guest', icon: 'fa-duotone fa-solid fa-user-clock' },\r\n { code: 'advanced', title: 'booking-calendar-advanced', icon: 'fa-duotone fa-solid fa-gear-complex' },\r\n ];\r\n availableRules = [];\r\n\r\n personTypes = [];\r\n locationOptions = ['phone', 'online', 'other'];\r\n timezoneOptions = ['America/New_York', 'America/Chicago', 'America/Denver', 'America/Phoenix', 'America/Los_Angeles', 'America/Anchorage', 'Pacific/Honolulu', 'America/Adak'];\r\n durationMinuteOptions = ['15', '30', '45', '60', '90'];\r\n bookDaysInFuture = ['3', '7', '14', '21', '30'];\r\n intervalMinuteOptions = ['0', '15', '30'];\r\n bookingNoticeMinuteOptions = ['15', '30', '60', '90', '120'];\r\n cancellationNoticeMinuteOptions = ['15', '30', '60', '90', '120'];\r\n startEndMinuteOptions = ['00', '15', '30', '45'];\r\n dayOptions = [\r\n { code: 'sunday', selected: false },\r\n { code: 'monday', selected: false },\r\n { code: 'tuesday', selected: false },\r\n { code: 'wednesday', selected: false },\r\n { code: 'thursday', selected: false },\r\n { code: 'friday', selected: false },\r\n { code: 'saturday', selected: false }\r\n ];\r\n reminderRecipients = ['all', 'host', 'guest'];\r\n questions = [];\r\n questionDataTypes = [\r\n { dataType: 'general', type: 'text' },\r\n { dataType: 'general-multi-line', type: 'multi_line_text' },\r\n { dataType: 'email', type: 'email' },\r\n { dataType: 'phone', type: 'phone_number' },\r\n { dataType: 'general-select-dropdown', type: 'dropdown' },\r\n { dataType: 'general-date', type: 'date' },\r\n { dataType: 'general-checkbox', type: 'checkbox' },\r\n { dataType: 'general-select-radio', type: 'radio_button' },\r\n { dataType: 'street-address', type: 'text' },\r\n { dataType: 'city', type: 'text' },\r\n { dataType: 'state', type: 'text' },\r\n { dataType: 'zip', type: 'text' },\r\n { dataType: 'date-of-birth', type: 'date' },\r\n ];\r\n\r\n deleteText = 'delete';\r\n\r\n constructor(security, dialogController, validationController, calendar, nylas, notifier, pipelines, i18n, config, content) {\r\n this._security = security;\r\n this.dialogController = dialogController;\r\n this.dialogController.settings.centerHorizontalOnly = true;\r\n this.validationController = validationController;\r\n this.validationController.addRenderer(new BootstrapFormValidationRenderer());\r\n this._calendar = calendar;\r\n this._nylas = nylas;\r\n this._notifier = notifier;\r\n this._pipelines = pipelines;\r\n this._i18n = i18n;\r\n this._config = config;\r\n this._content = content;\r\n }\r\n\r\n async activate(model) {\r\n this.displayTab(this.tabs[0]);\r\n model.bookingCalendar = model.bookingCalendar ?? {};\r\n this.forMemberId = model.forMemberId;\r\n this.bookingCalendar = JSON.parse(JSON.stringify(model.bookingCalendar));\r\n this.calendars = model.calendars ?? [];\r\n if (!this.bookingCalendar.id) {\r\n this.bookingCalendar.slug = `${this._security.agent.agentID}-${c.Helpers.uniqueId(7)}`;\r\n this.bookingCalendar.durationMinutes = '30';\r\n this.bookingCalendar.bookDaysInFuture = '7';\r\n this.bookingCalendar.minutesBetweenBookings = '15';\r\n this.bookingCalendar.minimumMinutesBeforeBooking = '60';\r\n this.bookingCalendar.minimumMinutesBeforeCancellation = '60';\r\n this.availableRules.push(this._defaultAvailableRule());\r\n this.questions = [];\r\n const defaultReminders = await this._config.get('NylasDefaultBookingCalendarReminders');\r\n this.reminders = defaultReminders ? JSON.parse(defaultReminders) : [];\r\n } else {\r\n // set up the form with the current booking calendar model\r\n // Make the Numbers strings so the default is selected\r\n this.bookingCalendar.durationMinutes += '';\r\n this.bookingCalendar.bookDaysInFuture += '';\r\n this.bookingCalendar.minutesBetweenBookings += '';\r\n this.bookingCalendar.minimumMinutesBeforeBooking += '';\r\n this.bookingCalendar.minimumMinutesBeforeCancellation += '';\r\n this.availableRules = [];\r\n this.bookingCalendar.daysAvailable.forEach(da => {\r\n const ar = this._defaultAvailableRule(false);\r\n da.days.forEach(day => {\r\n const doIndex = ar.dayOptions.findIndex(x => x.code === day);\r\n if (doIndex >= 0) ar.dayOptions[doIndex].selected = true;\r\n });\r\n ar.startAvailableHour = `${da.startHour}`;\r\n ar.startAvailableMinute = `${da.startMinute}`;\r\n ar.endAvailableHour = `${da.endHour}`;\r\n ar.endAvailableMinute = `${da.endMinute}`;\r\n this.availableRules.push(ar);\r\n });\r\n this.questions = [];\r\n this.bookingCalendar.additionalFields.forEach(af => {\r\n this.questions.push({\r\n question: af.name,\r\n type: af.type,\r\n dataType: af.dataType,\r\n isRequired: af.required,\r\n answerOptions: af.options ?? [],\r\n });\r\n });\r\n this.reminders = [];\r\n this.bookingCalendar.reminders.forEach(r => {\r\n this.reminders.push(JSON.parse(JSON.stringify(r)));\r\n });\r\n }\r\n\r\n this._setupValidation();\r\n this._load();\r\n }\r\n\r\n attached() {\r\n this._scrollToTop();\r\n }\r\n\r\n displayTab(tab) {\r\n this.tab = tab;\r\n }\r\n\r\n async _load() {\r\n try {\r\n this.pipelines = [];\r\n const pipelines = await this._pipelines.all(this.forMemberId);\r\n pipelines.forEach(p => {\r\n p.option = `${p.name} (${this._i18n.tr(p.personType)})`;\r\n });\r\n pipelines.unshift({ id: null, option: '' });\r\n this.pipelines = pipelines;\r\n const personTypes = PERSON_TYPE.visible();\r\n personTypes.unshift('');\r\n this.personTypes = personTypes;\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n _scrollToTop() {\r\n try {\r\n LpfnUtil.scrollToElm(this.containerEl, this.topEl, 600);\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n _setupValidation() {\r\n ValidationRules\r\n .ensure('title').required()\r\n .ensure('location').required()\r\n .ensure('duration').required()\r\n .ensure('calendarId').required()\r\n .on(this.bookingCalendar);\r\n\r\n this.validationController.reset();\r\n }\r\n\r\n _defaultAvailableRule(defaultSelected = true) {\r\n const ar = {\r\n dayOptions: JSON.parse(JSON.stringify(this.dayOptions)),\r\n startAvailableHour: '8',\r\n startAvailableMinute: '0',\r\n endAvailableHour: '20',\r\n endAvailableMinute: '0',\r\n };\r\n ar.dayOptions[1].selected = defaultSelected;\r\n ar.dayOptions[2].selected = defaultSelected;\r\n ar.dayOptions[3].selected = defaultSelected;\r\n ar.dayOptions[4].selected = defaultSelected;\r\n ar.dayOptions[5].selected = defaultSelected;\r\n return ar;\r\n }\r\n\r\n addAvailabilityRule() {\r\n this.availableRules.push(this._defaultAvailableRule());\r\n }\r\n\r\n removeAvailabilityRule(index) {\r\n this.availableRules.splice(index, 1);\r\n }\r\n\r\n selectDay(day) {\r\n day.selected = !day.selected;\r\n }\r\n\r\n onAddToPipelineChanged(bc) {\r\n try {\r\n if (!bc.addToPipelineId || bc.addToPipelineId === 'null') {\r\n bc.addPersonType = '';\r\n return;\r\n }\r\n const pipeline = this.pipelines.find(x => x.id === bc.addToPipelineId);\r\n bc.addPersonType = pipeline.personType;\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n }\r\n\r\n async save() {\r\n if (this.saving) return;\r\n try {\r\n const v = await this.validationController.validate();\r\n if (!v.valid) return;\r\n this.saving = true;\r\n\r\n if (this.bookingCalendar.location === 'phone') this.bookingCalendar.locationDetail = '';\r\n\r\n this.bookingCalendar.daysAvailable = [];\r\n this.availableRules.forEach(ar => {\r\n const da = {\r\n days: ar.dayOptions.filter(x => x.selected).map(x => x.code),\r\n startHour: Number(ar.startAvailableHour),\r\n startMinute: Number(ar.startAvailableMinute),\r\n endHour: Number(ar.endAvailableHour),\r\n endMinute: Number(ar.endAvailableMinute),\r\n }\r\n this.bookingCalendar.daysAvailable.push(da);\r\n });\r\n this.bookingCalendar.additionalFields = [];\r\n this.questions.forEach(q => {\r\n this.bookingCalendar.additionalFields.push({\r\n name: q.question,\r\n type: q.type,\r\n dataType: q.dataType,\r\n required: q.isRequired,\r\n options: q.answerOptions,\r\n });\r\n });\r\n this.bookingCalendar.reminders = this.reminders;\r\n\r\n await this._calendar.saveBookingCalendar(this.bookingCalendar, this.forMemberId);\r\n this.dialogController.ok();\r\n } catch (err) {\r\n console.log(err);\r\n this._notifier.generalError(err);\r\n } finally {\r\n this.saving = false;\r\n }\r\n }\r\n\r\n addReminder() {\r\n this.reminders.push({\r\n type: 'email',\r\n minutesBeforeEvent: '15',\r\n recipient: this.reminderRecipients[0],\r\n subject: '',\r\n });\r\n }\r\n\r\n removeReminder(index) {\r\n this.reminders.splice(index, 1);\r\n }\r\n\r\n checkReminderForError(reminder) {\r\n reminder.hasError = !reminder.minutesBeforeEvent ? true : false;\r\n }\r\n\r\n addQuestion(addDataType = undefined) {\r\n const dataType = addDataType\r\n ? this.questionDataTypes.find(x => x.dataType === addDataType) ?? this.questionDataTypes[0]\r\n : this.questionDataTypes[0];\r\n this.questions.push({\r\n question: '',\r\n type: dataType.type,\r\n dataType: dataType.dataType,\r\n isRequired: false,\r\n referenceKey: '',\r\n answerOptions: [],\r\n });\r\n }\r\n\r\n questionDataTypeSelected(q) {\r\n const questionDataType = this.questionDataTypes.find(x => x.dataType === q.dataType);\r\n q.type = questionDataType?.type ?? 'text';\r\n console.log(q.type);\r\n }\r\n\r\n removeQuestion(index) {\r\n this.questions.splice(index, 1);\r\n }\r\n\r\n checkQuestionForError(question) {\r\n question.hasError = !question.question ? true : false;\r\n }\r\n\r\n addAnswerOption(question) {\r\n if (!question.addOption) question.addOption = '';\r\n if (!question.answerOptions.includes(question.addOption)) {\r\n question.answerOptions.push(question.addOption);\r\n }\r\n question.addOption = '';\r\n question.focusAddOption = true;\r\n }\r\n\r\n removeAnswerOption(question, index) {\r\n question.answerOptions.splice(index, 1);\r\n }\r\n\r\n async showEmail(key, bookingCalendarProperty) {\r\n try {\r\n const variables = [];\r\n variables.push({ key: 'booking.customMessage', value: this.bookingCalendar[bookingCalendarProperty] ?? '' });\r\n variables.push({ key: 'additionalHtml', value: '
${bc.durationMinutes}
\\r\\n${bc.location}
\\r\\n${bc.calendarId}
\\r\\n