UNPKG

dhtmlx-scheduler

Version:

JavaScript event calendar. Allows to manage events and appointments in different views

1,236 lines (1,232 loc) 674 kB
/** @license dhtmlxScheduler v.7.2.11 Standard To use dhtmlxScheduler in non-GPL projects (and get Pro version of the product), please obtain Commercial/Enterprise or Ultimate license on our site https://dhtmlx.com/docs/products/dhtmlxScheduler/#licensing or contact us at sales@dhtmlx.com (c) XB Software Ltd. */ const le = typeof window < "u" ? window : global; function Mt(e) { let i = [], t = !1, n = null, s = null; function a() { return e.config.drag_highlight && e.markTimespan; } function o(d) { const l = e.getView(d); return l ? l.layout : d; } function _(d) { const { event: l, layout: h, viewName: p, sectionId: m, eventNode: v } = d; (function(f, y) { switch (y) { case "month": f.style.top = "", f.style.left = ""; break; case "timeline": f.style.left = "", f.style.marginLeft = "1px"; break; default: f.style.top = ""; } })(v, h); const c = {}; let u = { start_date: l.start_date, end_date: l.end_date, css: "dhx_scheduler_dnd_marker", html: v }; if (h == "timeline") { const f = e.getView(p); if (f.round_position) { const y = e._get_date_index(f, l.start_date), w = f._trace_x[y]; u.start_date = w; } } return h != "timeline" && h != "month" || (u = { ...u, end_date: e.date.add(l.start_date, 1, "minute") }), m && (c[p] = m, u.sections = c), u; } function r(d) { const { layout: l } = d; let h; switch (l) { case "month": h = function(p) { let m = []; const { event: v, layout: c, viewName: u, sectionId: f } = p, y = []; let w = new Date(v.start_date); for (; w.valueOf() < v.end_date.valueOf(); ) { let M = { start_date: w }; y.push(M), w = e.date.week_start(e.date.add(w, 1, "week")); } let D = e.$container.querySelectorAll(`[${e.config.event_attribute}='${v.id}']`); for (let M = 0; M < D.length; M++) { const k = { event: y[M], layout: c, viewName: u, sectionId: f, eventNode: D[M].cloneNode(!0) }; m.push(_(k)); } return m; }(d); break; case "timeline": case "units": h = function(p) { let m = []; const { event: v, layout: c, viewName: u, eventNode: f } = p; let y = function(w) { const D = e.getView(w); return D.y_property ? D.y_property : D.map_to ? D.map_to : void 0; }(u); if (y) { const w = String(v[y]).split(e.config.section_delimiter).map((M) => String(M)), D = []; for (let M = 0; M < w.length; M++) { D[M] = f.cloneNode(!0); const k = { event: v, layout: c, viewName: u, sectionId: w[M], eventNode: D[M] }; m.push(_(k)); } } return m; }(d); break; default: h = function(p) { const { event: m, layout: v, viewName: c, sectionId: u } = p; let f = [], y = e.$container.querySelectorAll(`[${e.config.event_attribute}='${m.id}']:not(.dhx_cal_select_menu):not(.dhx_drag_marker)`); if (y) for (let w = 0; w < y.length; w++) { let D = y[w].cloneNode(!0); const M = { event: { start_date: /* @__PURE__ */ new Date(+D.getAttribute("data-bar-start")), end_date: /* @__PURE__ */ new Date(+D.getAttribute("data-bar-end")) }, layout: v, viewName: c, sectionId: u, eventNode: D }; f.push(_(M)); } return f; }(d); } h.forEach((p) => { i.push(e.markTimespan(p)); }); } e.attachEvent("onBeforeDrag", function(d, l, h) { return a() && (t = !0, s = e.getEvent(d), n = h.target.closest(`[${e.config.event_attribute}]`), o(e.getState().mode) == "units" && e.config.cascade_event_display && (e.unselect(d), n = h.target.closest(`[${e.config.event_attribute}]`))), !0; }), e.attachEvent("onEventDrag", function(d, l, h) { if (t && a()) { t = !1; const p = e.getState().mode, m = o(p), v = e.getActionData(h).section; s && r({ event: s, layout: m, viewName: p, sectionId: v, eventNode: n }); } }), e.attachEvent("onDragEnd", function(d, l, h) { for (let p = 0; p < i.length; p++) e.unmarkTimespan(i[p]); i = [], n = null, s = null; }); } function Nt(e) { e.config.mark_now = !0, e.config.display_marked_timespans = !0, e.config.overwrite_marked_timespans = !0; var i = "dhx_time_block", t = "default", n = function(a, o, _) { var r = typeof a == "object" ? a : { days: a }; return r.type = i, r.css = "", o && (_ && (r.sections = _), r = function(d, l, h) { return l instanceof Date && h instanceof Date ? (d.start_date = l, d.end_date = h) : (d.days = l, d.zones = h), d; }(r, a, o)), r; }; function s(a, o, _, r, d) { var l = e, h = [], p = { _props: "map_to", matrix: "y_property" }; for (var m in p) { var v = p[m]; if (l[m]) for (var c in l[m]) { var u = l[m][c][v]; a[u] && (h = l._add_timespan_zones(h, e._get_blocked_zones(o[c], a[u], _, r, d))); } } return h = l._add_timespan_zones(h, e._get_blocked_zones(o, "global", _, r, d)); } e.blockTime = function(a, o, _) { var r = n(a, o, _); return e.addMarkedTimespan(r); }, e.unblockTime = function(a, o, _) { var r = n(a, o = o || "fullday", _); return e.deleteMarkedTimespan(r); }, e.checkInMarkedTimespan = function(a, o, _) { o = o || t; for (var r = !0, d = new Date(a.start_date.valueOf()), l = e.date.add(d, 1, "day"), h = e._marked_timespans; d < a.end_date; d = e.date.date_part(l), l = e.date.add(d, 1, "day")) { var p = +e.date.date_part(new Date(d)), m = s(a, h, d.getDay(), p, o); if (m) for (var v = 0; v < m.length; v += 2) { var c = e._get_zone_minutes(d), u = a.end_date > l || a.end_date.getDate() != d.getDate() ? 1440 : e._get_zone_minutes(a.end_date), f = m[v], y = m[v + 1]; if (f < u && y > c && !(r = typeof _ == "function" && _(a, c, u, f, y))) break; } } return !r; }, e.checkLimitViolation = function(a) { if (!a || !e.config.check_limits) return !0; var o = e, _ = o.config, r = []; if (a.rec_type && a._end_date || a.rrule) { const m = a._end_date || a.end_date; return !_.limit_start || !_.limit_end || m.valueOf() >= _.limit_start.valueOf() && a.start_date.valueOf() <= _.limit_end.valueOf(); } r = [a]; for (var d = !0, l = 0; l < r.length; l++) { var h = !0, p = r[l]; p._timed = e.isOneDayEvent(p), (h = !_.limit_start || !_.limit_end || p.start_date.valueOf() >= _.limit_start.valueOf() && p.end_date.valueOf() <= _.limit_end.valueOf()) && (h = !e.checkInMarkedTimespan(p, i, function(m, v, c, u, f) { var y = !0; return v <= f && v >= u && ((f == 1440 || c <= f) && (y = !1), m._timed && o._drag_id && o._drag_mode == "new-size" ? (m.start_date.setHours(0), m.start_date.setMinutes(f)) : y = !1), (c >= u && c <= f || v < u && c > f) && (m._timed && o._drag_id && o._drag_mode == "new-size" ? (m.end_date.setHours(0), m.end_date.setMinutes(u)) : y = !1), y; })), h || (h = o.checkEvent("onLimitViolation") ? o.callEvent("onLimitViolation", [p.id, p]) : h), d = d && h; } return d || (o._drag_id = null, o._drag_mode = null), d; }, e._get_blocked_zones = function(a, o, _, r, d) { var l = []; if (a && a[o]) for (var h = a[o], p = this._get_relevant_blocked_zones(_, r, h, d), m = 0; m < p.length; m++) l = this._add_timespan_zones(l, p[m].zones); return l; }, e._get_relevant_blocked_zones = function(a, o, _, r) { var d; return e.config.overwrite_marked_timespans ? d = _[o] && _[o][r] ? _[o][r] : _[a] && _[a][r] ? _[a][r] : [] : (d = [], _[o] && _[o][r] && (d = d.concat(_[o][r])), _[a] && _[a][r] && (d = d.concat(_[a][r]))), d; }, e._mark_now = function(a) { var o = "dhx_now_time"; this._els[o] || (this._els[o] = []); var _ = e._currentDate(), r = this.config; if (e._remove_mark_now(), !a && r.mark_now && _ < this._max_date && _ > this._min_date && _.getHours() >= r.first_hour && _.getHours() < r.last_hour) { var d = this.locate_holder_day(_); this._els[o] = e._append_mark_now(d, _); } }, e._append_mark_now = function(a, o) { var _ = "dhx_now_time", r = e._get_zone_minutes(o), d = { zones: [r, r + 1], css: _, type: _ }; if (!this._table_view) { if (this._props && this._props[this._mode]) { var l, h, p = this._props[this._mode], m = p.size || p.options.length; p.days > 1 ? (p.size && p.options.length && (a = (p.position + a) / p.options.length * p.size), l = a, h = a + m) : h = (l = 0) + m; for (var v = [], c = l; c < h; c++) { var u = c; d.days = u; var f = e._render_marked_timespan(d, null, u)[0]; v.push(f); } return v; } return d.days = a, e._render_marked_timespan(d, null, a); } if (this._mode == "month") return d.days = +e.date.date_part(o), e._render_marked_timespan(d, null, null); }, e._remove_mark_now = function() { for (var a = "dhx_now_time", o = this._els[a], _ = 0; _ < o.length; _++) { var r = o[_], d = r.parentNode; d && d.removeChild(r); } this._els[a] = []; }, e._marked_timespans = { global: {} }, e._get_zone_minutes = function(a) { return 60 * a.getHours() + a.getMinutes(); }, e._prepare_timespan_options = function(a) { var o = [], _ = []; if (a.days == "fullweek" && (a.days = [0, 1, 2, 3, 4, 5, 6]), a.days instanceof Array) { for (var r = a.days.slice(), d = 0; d < r.length; d++) { var l = e._lame_clone(a); l.days = r[d], o.push.apply(o, e._prepare_timespan_options(l)); } return o; } if (!a || !(a.start_date && a.end_date && a.end_date > a.start_date || a.days !== void 0 && a.zones) && !a.type) return o; a.zones == "fullday" && (a.zones = [0, 1440]), a.zones && a.invert_zones && (a.zones = e.invertZones(a.zones)), a.id = e.uid(), a.css = a.css || "", a.type = a.type || t; var h = a.sections; if (h) { for (var p in h) if (h.hasOwnProperty(p)) { var m = h[p]; for (m instanceof Array || (m = [m]), d = 0; d < m.length; d++) (D = e._lame_copy({}, a)).sections = {}, D.sections[p] = m[d], _.push(D); } } else _.push(a); for (var v = 0; v < _.length; v++) { var c = _[v], u = c.start_date, f = c.end_date; if (u && f) for (var y = e.date.date_part(new Date(u)), w = e.date.add(y, 1, "day"); y < f; ) { var D; delete (D = e._lame_copy({}, c)).start_date, delete D.end_date, D.days = y.valueOf(); var M = u > y ? e._get_zone_minutes(u) : 0, k = f > w || f.getDate() != y.getDate() ? 1440 : e._get_zone_minutes(f); D.zones = [M, k], o.push(D), y = w, w = e.date.add(w, 1, "day"); } else c.days instanceof Date && (c.days = e.date.date_part(c.days).valueOf()), c.zones = a.zones.slice(), o.push(c); } return o; }, e._get_dates_by_index = function(a, o, _) { var r = []; o = e.date.date_part(new Date(o || e._min_date)), _ = new Date(_ || e._max_date); for (var d = o.getDay(), l = a - d >= 0 ? a - d : 7 - o.getDay() + a, h = e.date.add(o, l, "day"); h < _; h = e.date.add(h, 1, "week")) r.push(h); return r; }, e._get_css_classes_by_config = function(a) { var o = []; return a.type == i && (o.push(i), a.css && o.push(i + "_reset")), o.push("dhx_marked_timespan", a.css), o.join(" "); }, e._get_block_by_config = function(a) { var o = document.createElement("div"); if (a.html) { let _ = a.html; typeof _ == "function" && (_ = _(a)), typeof _ == "string" ? o.innerHTML = a.html : e.config.external_render && e.config.external_render.isElement(_) ? e.config.external_render.renderElement(_, o) : o.appendChild(_); } return o; }, e._render_marked_timespan = function(a, o, _) { var r = [], d = e.config, l = this._min_date, h = this._max_date, p = !1; if (!d.display_marked_timespans) return r; if (!_ && _ !== 0) { if (a.days < 7) _ = a.days; else { var m = new Date(a.days); if (p = +m, !(+h > +m && +l <= +m)) return r; _ = m.getDay(); } var v = l.getDay(); v > _ ? _ = 7 - (v - _) : _ -= v; } var c = a.zones, u = e._get_css_classes_by_config(a); if (e._table_view && e._mode == "month") { var f = [], y = []; if (o) f.push(o), y.push(_); else { y = p ? [p] : e._get_dates_by_index(_); for (var w = 0; w < y.length; w++) f.push(this._scales[y[w]]); } for (w = 0; w < f.length; w++) { o = f[w], _ = y[w]; var D = this.locate_holder_day(_, !1) % this._cols.length; if (!this._ignores[D]) { var M = e._get_block_by_config(a); M.className = u, M.style.top = "0px", M.style.height = "100%"; for (var k = 0; k < c.length; k += 2) { var N = c[w]; if ((E = c[w + 1]) <= N) return []; (S = M.cloneNode(!0)).style.left = "0px", S.style.width = "100%", o.appendChild(S), r.push(S); } } } } else { var g = _; if (this._ignores[this.locate_holder_day(_, !1)]) return r; if (this._props && this._props[this._mode] && a.sections && a.sections[this._mode]) { var x = this._props[this._mode]; g = x.order[a.sections[this._mode]]; var b = x.order[a.sections[this._mode]]; x.days > 1 ? g = g * (x.size || x.options.length) + b : (g = b, x.size && g > x.position + x.size && (g = 0)); } for (o = o || e.locate_holder(g), w = 0; w < c.length; w += 2) { var E, S; if (N = Math.max(c[w], 60 * d.first_hour), (E = Math.min(c[w + 1], 60 * d.last_hour)) <= N) { if (w + 2 < c.length) continue; return []; } (S = e._get_block_by_config(a)).className = u; var T = 24 * this.config.hour_size_px + 1, A = 36e5; S.style.top = Math.round((60 * N * 1e3 - this.config.first_hour * A) * this.config.hour_size_px / A) % T + "px", S.style.height = Math.max(Math.round(60 * (E - N) * 1e3 * this.config.hour_size_px / A) % T, 1) + "px", o.appendChild(S), r.push(S); } } return r; }, e._mark_timespans = function() { var a = this._els.dhx_cal_data[0], o = []; if (e._table_view && e._mode == "month") for (var _ in this._scales) { var r = /* @__PURE__ */ new Date(+_); o.push.apply(o, e._on_scale_add_marker(this._scales[_], r)); } else { r = new Date(e._min_date); for (var d = 0, l = a.childNodes.length; d < l; d++) { var h = a.childNodes[d]; h.firstChild && e._getClassName(h.firstChild).indexOf("dhx_scale_hour") > -1 || (o.push.apply(o, e._on_scale_add_marker(h, r)), r = e.date.add(r, 1, "day")); } } return o; }, e.markTimespan = function(a) { if (!this._els) throw new Error("`scheduler.markTimespan` can't be used before scheduler initialization. Place `scheduler.markTimespan` call after `scheduler.init`."); var o = !1; this._els.dhx_cal_data || (e.get_elements(), o = !0); var _ = e._marked_timespans_ids, r = e._marked_timespans_types, d = e._marked_timespans; e.deleteMarkedTimespan(), e.addMarkedTimespan(a); var l = e._mark_timespans(); return o && (e._els = []), e._marked_timespans_ids = _, e._marked_timespans_types = r, e._marked_timespans = d, l; }, e.unmarkTimespan = function(a) { if (a) for (var o = 0; o < a.length; o++) { var _ = a[o]; _.parentNode && _.parentNode.removeChild(_); } }, e._addMarkerTimespanConfig = function(a) { var o = "global", _ = e._marked_timespans, r = a.id, d = e._marked_timespans_ids; d[r] || (d[r] = []); var l = a.days, h = a.sections, p = a.type; if (a.id = r, h) { for (var m in h) if (h.hasOwnProperty(m)) { _[m] || (_[m] = {}); var v = h[m], c = _[m]; c[v] || (c[v] = {}), c[v][l] || (c[v][l] = {}), c[v][l][p] || (c[v][l][p] = [], e._marked_timespans_types || (e._marked_timespans_types = {}), e._marked_timespans_types[p] || (e._marked_timespans_types[p] = !0)); var u = c[v][l][p]; a._array = u, u.push(a), d[r].push(a); } } else _[o][l] || (_[o][l] = {}), _[o][l][p] || (_[o][l][p] = []), e._marked_timespans_types || (e._marked_timespans_types = {}), e._marked_timespans_types[p] || (e._marked_timespans_types[p] = !0), u = _[o][l][p], a._array = u, u.push(a), d[r].push(a); }, e._marked_timespans_ids = {}, e.addMarkedTimespan = function(a) { var o = e._prepare_timespan_options(a); if (o.length) { for (var _ = o[0].id, r = 0; r < o.length; r++) e._addMarkerTimespanConfig(o[r]); return _; } }, e._add_timespan_zones = function(a, o) { var _ = a.slice(); if (o = o.slice(), !_.length) return o; for (var r = 0; r < _.length; r += 2) for (var d = _[r], l = _[r + 1], h = r + 2 == _.length, p = 0; p < o.length; p += 2) { var m = o[p], v = o[p + 1]; if (v > l && m <= l || m < d && v >= d) _[r] = Math.min(d, m), _[r + 1] = Math.max(l, v), r -= 2; else { if (!h) continue; var c = d > m ? 0 : 2; _.splice(r + c, 0, m, v); } o.splice(p--, 2); break; } return _; }, e._subtract_timespan_zones = function(a, o) { for (var _ = a.slice(), r = 0; r < _.length; r += 2) for (var d = _[r], l = _[r + 1], h = 0; h < o.length; h += 2) { var p = o[h], m = o[h + 1]; if (m > d && p < l) { var v = !1; d >= p && l <= m && _.splice(r, 2), d < p && (_.splice(r, 2, d, p), v = !0), l > m && _.splice(v ? r + 2 : r, v ? 0 : 2, m, l), r -= 2; break; } } return _; }, e.invertZones = function(a) { return e._subtract_timespan_zones([0, 1440], a.slice()); }, e._delete_marked_timespan_by_id = function(a) { var o = e._marked_timespans_ids[a]; if (o) { for (var _ = 0; _ < o.length; _++) for (var r = o[_], d = r._array, l = 0; l < d.length; l++) if (d[l] == r) { d.splice(l, 1); break; } } }, e._delete_marked_timespan_by_config = function(a) { var o, _ = e._marked_timespans, r = a.sections, d = a.days, l = a.type || t; if (r) { for (var h in r) if (r.hasOwnProperty(h) && _[h]) { var p = r[h]; _[h][p] && (o = _[h][p]); } } else o = _.global; if (o) { if (d !== void 0) o[d] && o[d][l] && (e._addMarkerTimespanConfig(a), e._delete_marked_timespans_list(o[d][l], a)); else for (var m in o) if (o[m][l]) { var v = e._lame_clone(a); a.days = m, e._addMarkerTimespanConfig(v), e._delete_marked_timespans_list(o[m][l], a); } } }, e._delete_marked_timespans_list = function(a, o) { for (var _ = 0; _ < a.length; _++) { var r = a[_], d = e._subtract_timespan_zones(r.zones, o.zones); if (d.length) r.zones = d; else { a.splice(_, 1), _--; for (var l = e._marked_timespans_ids[r.id], h = 0; h < l.length; h++) if (l[h] == r) { l.splice(h, 1); break; } } } }, e.deleteMarkedTimespan = function(a) { if (arguments.length || (e._marked_timespans = { global: {} }, e._marked_timespans_ids = {}, e._marked_timespans_types = {}), typeof a != "object") e._delete_marked_timespan_by_id(a); else { a.start_date && a.end_date || (a.days !== void 0 || a.type || (a.days = "fullweek"), a.zones || (a.zones = "fullday")); var o = []; if (a.type) o.push(a.type); else for (var _ in e._marked_timespans_types) o.push(_); for (var r = e._prepare_timespan_options(a), d = 0; d < r.length; d++) for (var l = r[d], h = 0; h < o.length; h++) { var p = e._lame_clone(l); p.type = o[h], e._delete_marked_timespan_by_config(p); } } }, e._get_types_to_render = function(a, o) { var _ = a ? e._lame_copy({}, a) : {}; for (var r in o || {}) o.hasOwnProperty(r) && (_[r] = o[r]); return _; }, e._get_configs_to_render = function(a) { var o = []; for (var _ in a) a.hasOwnProperty(_) && o.push.apply(o, a[_]); return o; }, e._on_scale_add_marker = function(a, o) { if (!e._table_view || e._mode == "month") { var _ = o.getDay(), r = o.valueOf(), d = this._mode, l = e._marked_timespans, h = [], p = []; if (this._props && this._props[d]) { var m = this._props[d], v = m.options, c = v[e._get_unit_index(m, o)]; if (m.days > 1) { var u = Math.round((o - e._min_date) / 864e5), f = m.size || v.length; o = e.date.add(e._min_date, Math.floor(u / f), "day"), o = e.date.date_part(o); } else o = e.date.date_part(new Date(this._date)); if (_ = o.getDay(), r = o.valueOf(), l[d] && l[d][c.key]) { var y = l[d][c.key], w = e._get_types_to_render(y[_], y[r]); h.push.apply(h, e._get_configs_to_render(w)); } } var D = l.global; if (e.config.overwrite_marked_timespans) { var M = D[r] || D[_]; h.push.apply(h, e._get_configs_to_render(M)); } else D[r] && h.push.apply(h, e._get_configs_to_render(D[r])), D[_] && h.push.apply(h, e._get_configs_to_render(D[_])); for (var k = 0; k < h.length; k++) p.push.apply(p, e._render_marked_timespan(h[k], a, o)); return p; } }, e.attachEvent("onScaleAdd", function() { e._on_scale_add_marker.apply(e, arguments); }), e.dblclick_dhx_marked_timespan = function(a, o) { e.callEvent("onScaleDblClick", [e.getActionData(a).date, o, a]), e.config.dblclick_create && e.addEventNow(e.getActionData(a).date, null, a); }; } function Tt(e) { var i = {}, t = !1; function n(r, d) { d = typeof d == "function" ? d : function() { }, i[r] || (i[r] = this[r], this[r] = d); } function s(r) { i[r] && (this[r] = i[r], i[r] = null); } function a(r) { for (var d in r) n.call(this, d, r[d]); } function o() { for (var r in i) s.call(this, r); } function _(r) { try { r(); } catch (d) { window.console.error(d); } } return e.$stateProvider.registerProvider("batchUpdate", function() { return { batch_update: t }; }, !1), function(r, d) { if (t) return void _(r); var l, h = this._dp && this._dp.updateMode != "off"; h && (l = this._dp.updateMode, this._dp.setUpdateMode("off")); const p = { setModeDate: { date: null, mode: null }, needRender: !1, needUpdateView: !1, repaintEvents: {} }, m = (c, u) => { c && (p.setModeDate.date = c), u && (p.setModeDate.mode = u); }; var v = { render: (c, u) => { p.needRender = !0, m(c, u); }, setCurrentView: (c, u) => { p.needRender = !0, m(c, u); }, updateView: (c, u) => { p.needUpdateView = !0, m(c, u); }, render_data: () => p.needRender = !0, render_view_data: (c) => { c && c.length ? c.forEach((u) => p.repaintEvents[u.id] = !0) : p.needRender = !0; } }; if (a.call(this, v), t = !0, this.callEvent("onBeforeBatchUpdate", []), _(r), this.callEvent("onAfterBatchUpdate", []), o.call(this), t = !1, !d) if (p.needRender) e.render(p.setModeDate.date, p.setModeDate.mode); else if (p.needUpdateView) e.updateView(p.setModeDate.date, p.setModeDate.mode); else for (const c in p.repaintEvents) e.updateEvent(c); h && (this._dp.setUpdateMode(l), this._dp.sendData()); }; } class At { constructor(i) { const { url: t, token: n } = i; this._url = t, this._token = n, this._mode = 1, this._seed = 1, this._queue = [], this.data = {}, this.api = {}, this._events = {}; } headers() { return { Accept: "application/json", "Content-Type": "application/json", "Remote-Token": this._token }; } fetch(i, t) { const n = { credentials: "include", headers: this.headers() }; return t && (n.method = "POST", n.body = t), fetch(i, n).then((s) => s.json()); } load(i) { return i && (this._url = i), this.fetch(this._url).then((t) => this.parse(t)); } parse(i) { const { key: t, websocket: n } = i; t && (this._token = i.key); for (const s in i.data) this.data[s] = i.data[s]; for (const s in i.api) { const a = this.api[s] = {}, o = i.api[s]; for (const _ in o) a[_] = this._wrapper(s + "." + _); } return n && this.connect(), this; } connect() { const i = this._socket; i && (this._socket = null, i.onclose = function() { }, i.close()), this._mode = 2, this._socket = function(t, n, s, a) { let o = n; o[0] === "/" && (o = document.location.protocol + "//" + document.location.host + n), o = o.replace(/^http(s|):/, "ws$1:"); const _ = o.indexOf("?") != -1 ? "&" : "?"; o = `${o}${_}token=${s}&ws=1`; const r = new WebSocket(o); return r.onclose = () => setTimeout(() => t.connect(), 2e3), r.onmessage = (d) => { const l = JSON.parse(d.data); switch (l.action) { case "result": t.result(l.body, []); break; case "event": t.fire(l.body.name, l.body.value); break; case "start": a(); break; default: t.onError(l.data); } }, r; }(this, this._url, this._token, () => (this._mode = 3, this._send(), this._resubscribe(), this)); } _wrapper(i) { return (function() { const t = [].slice.call(arguments); let n = null; const s = new Promise((a, o) => { n = { data: { id: this._uid(), name: i, args: t }, status: 1, resolve: a, reject: o }, this._queue.push(n); }); return this.onCall(n, s), this._mode === 3 ? this._send(n) : setTimeout(() => this._send(), 1), s; }).bind(this); } _uid() { return (this._seed++).toString(); } _send(i) { if (this._mode == 2) return void setTimeout(() => this._send(), 100); const t = i ? [i] : this._queue.filter((s) => s.status === 1); if (!t.length) return; const n = t.map((s) => (s.status = 2, s.data)); this._mode !== 3 ? this.fetch(this._url, JSON.stringify(n)).catch((s) => this.onError(s)).then((s) => this.result(s, n)) : this._socket.send(JSON.stringify({ action: "call", body: n })); } result(i, t) { const n = {}; if (i) for (let s = 0; s < i.length; s++) n[i[s].id] = i[s]; else for (let s = 0; s < t.length; s++) n[t[s].id] = { id: t[s].id, error: "Network Error", data: null }; for (let s = this._queue.length - 1; s >= 0; s--) { const a = this._queue[s], o = n[a.data.id]; o && (this.onResponse(a, o), o.error ? a.reject(o.error) : a.resolve(o.data), this._queue.splice(s, 1)); } } on(i, t) { const n = this._uid(); let s = this._events[i]; const a = !!s; return a || (s = this._events[i] = []), s.push({ id: n, handler: t }), a || this._mode != 3 || this._socket.send(JSON.stringify({ action: "subscribe", name: i })), { name: i, id: n }; } _resubscribe() { if (this._mode == 3) for (const i in this._events) this._socket.send(JSON.stringify({ action: "subscribe", name: i })); } detach(i) { if (!i) { if (this._mode == 3) for (const a in this._events) this._socket.send(JSON.stringify({ action: "unsubscribe", key: a })); return void (this._events = {}); } const { id: t, name: n } = i, s = this._events[n]; if (s) { const a = s.filter((o) => o.id != t); a.length ? this._events[n] = a : (delete this._events[n], this._mode == 3 && this._socket.send(JSON.stringify({ action: "unsubscribe", name: n }))); } } fire(i, t) { const n = this._events[i]; if (n) for (let s = 0; s < n.length; s++) n[s].handler(t); } onError(i) { return null; } onCall(i, t) { } onResponse(i, t) { } } class Ct { constructor(i, t) { const n = new At({ url: i, token: t }); n.fetch = function(s, a) { const o = { headers: this.headers() }; return a && (o.method = "POST", o.body = a), fetch(s, o).then((_) => _.json()); }, this._ready = n.load().then((s) => this._remote = s); } ready() { return this._ready; } on(i, t) { this.ready().then((n) => { if (typeof i == "string") n.on(i, t); else for (const s in i) n.on(s, i[s]); }); } } function Ot(e) { function i(n, s) { switch (n) { case "add-event": (function(a) { if (e.getEvent(a.id)) return void console.warn(`Event with ID ${a.id} already exists. Skipping add.`); a.start_date = e.templates.parse_date(a.start_date), a.end_date = e.templates.parse_date(a.end_date), a.original_start && (a.original_start = e.templates.parse_date(a.original_start)), t(() => { e.addEvent(a); }); })(s); break; case "update-event": (function(a) { const o = a.id; if (!e.getEvent(o)) return void console.warn(`Event with ID ${o} does not exist. Skipping update.`); const _ = e.getEvent(o); t(() => { for (let r in a) r !== "start_date" && r !== "end_date" && (_[r] = a[r]); _.start_date = e.templates.parse_date(a.start_date), _.end_date = e.templates.parse_date(a.end_date), a.original_start && (a.original_start = e.templates.parse_date(a.original_start)), e.callEvent("onEventChanged", [o, _]), e.updateEvent(o), o !== a.id && e.changeEventId(o, a.id); }); })(s); break; case "delete-event": (function(a) { const o = a.id; if (!e.getEvent(o)) return void ((a.event_pid || a.recurring_event_id) && t(() => { e.addEvent(a); })); t(() => { const _ = e.getEvent(o); if (_) { if (_.rec_type || _.rrule) { e._roll_back_dates(_); const r = e._get_rec_markers(o); for (const d in r) e.getEvent(d) && e.deleteEvent(d, !0); } if (e.getState().lightbox_id == o && (this._new_event = this._lightbox_id, a.id = this._lightbox_id, this._events[this._lightbox_id] = a, e.callEvent("onLiveUpdateCollision", [o, null, "delete", a]) === !1)) return void e.endLightbox(!1, e._lightbox); e.deleteEvent(o, !0); } }); })(s); } } function t(n) { e._dp ? e._dp.ignore(n) : n(); } return { events: function(n) { if (!n || !n.event || !n.event.id) return void console.error("Invalid message format:", n); const { type: s, event: a } = n; if (!e._dp || !e._dp._in_progress[a.id]) { if (s === "add-event") { for (const o in e._dp._in_progress) if (e._dp.getState(o) === "inserted") return void e._dp.attachEvent("onFullSync", function() { e.getEvent(a.id) || i(s, a); }, { once: !0 }); } i(s, a); } } }; } function Lt(e) { (function(i) { const t = {}; i.attachEvent("onConfirmedBeforeEventDelete", function(n) { return t[n] = !0, !0; }), i.attachEvent("onEventDeleted", function(n, s) { if (!t[n]) return; delete t[n]; let a = i.copy(s); i.config.undo_deleted && !i.getState().new_event && i.message({ text: `<div class="dhx_info_message"> <span class="undo_popup_text">Event deleted</span> <button class="undo_button" data-deleted-event-id="${s.id}">Undo</button> </div>`, expire: 1e4, type: "popup_after_delete", callback: function(o) { o.target.closest(`[data-deleted-event-id="${s.id}"]`) && (a.rrule && a.duration && (a.end_date = new Date(a.start_date.valueOf() + 1e3 * a.duration), i.addEvent(a)), i.addEvent(a), i.render()); } }); }); })(e), Mt(e), Nt(e), function(i) { i.batchUpdate = Tt(i); }(e), function(i) { i.ext || (i.ext = {}), i.ext.liveUpdates = { RemoteEvents: Ct, remoteUpdates: Ot(i) }; }(e); } var $t = Date.now(); function Te(e) { return !(!e || typeof e != "object") && !!(e.getFullYear && e.getMonth && e.getDate); } const re = { uid: function() { return $t++; }, mixin: function(e, i, t) { for (var n in i) (e[n] === void 0 || t) && (e[n] = i[n]); return e; }, copy: function e(i) { var t, n, s; if (i && typeof i == "object") switch (!0) { case Te(i): n = new Date(i); break; case (s = i, Array.isArray ? Array.isArray(s) : s && s.length !== void 0 && s.pop && s.push): for (n = new Array(i.length), t = 0; t < i.length; t++) n[t] = e(i[t]); break; case function(a) { return a && typeof a == "object" && Function.prototype.toString.call(a.constructor) === "function String() { [native code] }"; }(i): n = new String(i); break; case function(a) { return a && typeof a == "object" && Function.prototype.toString.call(a.constructor) === "function Number() { [native code] }"; }(i): n = new Number(i); break; case function(a) { return a && typeof a == "object" && Function.prototype.toString.call(a.constructor) === "function Boolean() { [native code] }"; }(i): n = new Boolean(i); break; default: for (t in n = {}, i) { const a = typeof i[t]; a === "string" || a === "number" || a === "boolean" ? n[t] = i[t] : Te(i[t]) ? n[t] = new Date(i[t]) : Object.prototype.hasOwnProperty.apply(i, [t]) && (n[t] = e(i[t])); } } return n || i; }, defined: function(e) { return e !== void 0; }, isDate: Te, delay: function(e, i) { var t, n = function() { n.$cancelTimeout(), n.$pending = !0; var s = Array.prototype.slice.call(arguments); t = setTimeout(function() { e.apply(this, s), n.$pending = !1; }, i); }; return n.$pending = !1, n.$cancelTimeout = function() { clearTimeout(t), n.$pending = !1; }, n.$execute = function() { var s = Array.prototype.slice.call(arguments); e.apply(this, s), n.$cancelTimeout(); }, n; } }; function Ht(e) { function i(v) { var c = document.createElement("div"); return (v || "").split(" ").forEach(function(u) { c.classList.add(u); }), c; } var t = function() { return i("dhx_cal_navbar_rows_container"); }, n = function() { return i("dhx_cal_navbar_row"); }, s = function(v) { var c = i("dhx_cal_tab"); return c.setAttribute("name", v.view + "_tab"), c.setAttribute("data-tab", v.view), e.config.fix_tab_position && (v.$firstTab ? c.classList.add("dhx_cal_tab_first") : v.$lastTab ? c.classList.add("dhx_cal_tab_last") : v.view !== "week" && c.classList.add("dhx_cal_tab_standalone"), v.$segmentedTab && c.classList.add("dhx_cal_tab_segmented")), c; }, a = function() { return i("dhx_cal_date"); }, o = function(v) { return i("dhx_cal_nav_button dhx_cal_nav_button_custom dhx_cal_tab"); }, _ = function(v) { return i("dhx_cal_" + v.view + "_button dhx_cal_nav_button"); }, r = function() { return i("dhx_cal_line_spacer"); }, d = function(v) { var c = i("dhx_minical_icon"); return v.click || c.$_eventAttached || e.event(c, "click", function() { e.isCalendarVisible() ? e.destroyCalendar() : e.renderCalendar({ position: this, date: e.getState().date, navigation: !0, handler: function(u, f) { e.setCurrentView(u), e.destroyCalendar(); } }); }), c; }; function l(v) { var c = function(y) { var w; if (y.view) switch (y.view) { case "today": case "next": case "prev": w = _; break; case "date": w = a; break; case "spacer": w = r; break; case "button": w = o; break; case "minicalendar": w = d; break; default: w = s; } else y.rows ? w = t : y.cols && (w = n); return w; }(v); if (c) { var u = c(v); if (v.css && u.classList.add(v.css), v.width && ((f = v.width) === 1 * f && (f += "px"), u.style.width = f), v.height && ((f = v.height) === 1 * f && (f += "px"), u.style.height = f), v.click && e.event(u, "click", v.click), v.html && (u.innerHTML = v.html), v.align) { var f = ""; v.align == "right" ? f = "flex-end" : v.align == "left" && (f = "flex-start"), u.style.justifyContent = f; } return u; } } function h(v) { return typeof v == "string" && (v = { view: v }), v.view || v.rows || v.cols || (v.view = "button"), v; } function p(v) { var c, u = document.createDocumentFragment(); c = Array.isArray(v) ? v : [v]; for (var f = 0; f < c.length; f++) { var y, w = h(c[f]); w.view === "day" && c[f + 1] && ((y = h(c[f + 1])).view !== "week" && y.view !== "month" || (w.$firstTab = !0, w.$segmentedTab = !0)), w.view === "week" && c[f - 1] && ((y = h(c[f + 1])).view !== "week" && y.view !== "month" || (w.$segmentedTab = !0)), w.view === "month" && c[f - 1] && ((y = h(c[f - 1])).view !== "week" && y.view !== "day" || (w.$lastTab = !0, w.$segmentedTab = !0)); var D = l(w); u.appendChild(D), (w.cols || w.rows) && D.appendChild(p(w.cols || w.rows)); } return u; } e._init_nav_bar = function(v) { var c = this.$container.querySelector(".dhx_cal_navline"); return c || ((c = document.createElement("div")).className = "dhx_cal_navline dhx_cal_navline_flex", e._update_nav_bar(v, c), c); }; var m = null; e._update_nav_bar = function(v, c) { if (v) { var u = !1, f = v.height || e.xy.nav_height; m !== null && m === f || (u = !0), u && (e.xy.nav_height = f), c.innerHTML = "", c.appendChild(p(v)), e.unset_actions(), e._els = [], e.get_elements(), e.set_actions(), c.style.display = f === 0 ? "none" : "", m = f; } }; } function zt(e) { function i(a) { return a.isConnected !== void 0 ? a.isConnected : document.body.contains(a); } function t(a) { return { w: a.innerWidth || document.documentElement.clientWidth, h: a.innerHeight || document.documentElement.clientHeight }; } function n(a, o) { var _, r = t(o); a.event(o, "resize", function() { clearTimeout(_), _ = setTimeout(function() { if (i(a.$container) && !a.$destroyed) { var d, l, h = t(o); l = h, ((d = r).w != l.w || d.h != l.h) && (r = h, s(a)); } }, 150); }); } function s(a) { a.$initialized && !a.$destroyed && a.$root && i(a.$root) && a.callEvent("onSchedulerResize", []) && (a.updateView(), a.callEvent("onAfterSchedulerResize", [])); } (function(a) { var o = a.$container; if (window.getComputedStyle(o).getPropertyValue("position") == "static" && (o.style.position = "relative"), window.ResizeObserver) { let r = !0; const d = new ResizeObserver(function(l) { r ? r = !1 : s(a); }); d.observe(o), a.attachEvent("onDestroy", function() { d.unobserve(o); }); } else { var _ = document.createElement("iframe"); _.className = "scheduler_container_resize_watcher", _.tabIndex = -1, a.config.wai_aria_attributes && (_.setAttribute("role", "none"), _.setAttribute("aria-hidden", !0)), window.Sfdc || window.$A || window.Aura ? function(r) { var d = r.$root.offsetHeight, l = r.$root.offsetWidth; (function h() { r.$destroyed || (r.$root && (r.$root.offsetHeight == d && r.$root.offsetWidth == l || s(r), d = r.$root.offsetHeight, l = r.$root.offsetWidth), setTimeout(h, 200)); })(); }(a) : (o.appendChild(_), _.contentWindow ? n(a, _.contentWindow) : (o.removeChild(_), n(a, window))); } })(e); } class qt { constructor() { this._silent_mode = !1, this.listeners = {}; } _silentStart() { this._silent_mode = !0; } _silentEnd() { this._silent_mode = !1; } } function Ue(e) { const i = new qt(); e.attachEvent = function(t, n, s) { t = "ev_" + t.toLowerCase(), i.listeners[t] || (i.listeners[t] = function(o) { let _ = {}, r = 0; const d = function() { let l = !0; for (const h in _) { const p = _[h].apply(o, arguments); l = l && p; } return l; }; return d.addEvent = function(l, h) { if (typeof l == "function") { let p; if (h && h.id ? p = h.id : (p = r, r++), h && h.once) { const m = l; l = function() { m(), d.removeEvent(p); }; } return _[p] = l, p; } return !1; }, d.removeEvent = function(l) { delete _[l]; }, d.clear = function() { _ = {}; }, d; }(this)), s && s.thisObject && (n = n.bind(s.thisObject)); let a = t + ":" + i.listeners[t].addEvent(n, s); return s && s.id && (a = s.id), a; }, e.attachAll = function(t) { this.attachEvent("listen_all", t); }, e.callEvent = function(t, n) { if (i._silent_mode) return !0; const s = "ev_" + t.toLowerCase(), a = i.listeners; return a.ev_listen_all && a.ev_listen_all.apply(this, [t].concat(n)), !a[s] || a[s].apply(this, n); }, e.checkEvent = function(t) { return !!i.listeners["ev_" + t.toLowerCase()]; }, e.detachEvent = function(t) { if (t) { let n = i.listeners; for (const a in n) n[a].removeEvent(t); const s = t.split(":"); if (n = i.listeners, s.length === 2) { const a = s[0], o = s[1]; n[a] && n[a].removeEvent(o); } } }, e.detachAllEvents = function() { for (const t in i.listeners) i.listeners[t].clear(); }; } const We = { event: function(e, i, t) { e.addEventListener ? e.addEventListener(i, t, !1) : e.attachEvent && e.attachEvent("on" + i, t); }, eventRemove: function(e, i, t) { e.removeEventListener ? e.removeEventListener(i, t, !1) : e.detachEvent && e.detachEvent("on" + i, t); } }; function jt(e) { var i = function() { var t = function(n, s) { n = n || We.event, s = s || We.eventRemove; var a = [], o = { attach: function(_, r, d, l) { a.push({ element: _, event: r, callback: d, capture: l }), n(_, r, d, l); }, detach: function(_, r, d, l) { s(_, r, d, l); for (var h = 0; h < a.length; h++) { var p = a[h]; p.element === _ && p.event === r && p.callback === d && p.capture === l && (a.splice(h, 1), h--); } }, detachAll: function() { for (var _ = a.slice(), r = 0; r < _.length; r++) { var d = _[r]; o.detach(d.element, d.event, d.callback, d.capture), o.detach(d.element, d.event, d.callback, void 0), o.detach(d.element, d.event, d.callback, !1), o.detach(d.element, d.event, d.callback, !0); } a.splice(0, a.length); }, extend: function() { return t(this.event, this.eventRemove); } }; return o; }; return t(); }(); e.event = i.attach, e.eventRemove = i.detach, e._eventRemoveAll = i.detachAll, e._createDomEventScope = i.extend, e._trim = function(t) { return (String.prototype.trim || function() { return this.replace(/^\s+|\s+$/g, ""); }).apply(t); }, e._isDate = function(t) { return !(!t || typeof t != "object") && !!(t.getFullYear && t.getMonth && t.getDate); }, e._isObject = function(t) { return t && typeof t == "object"; }; } function ft(e) { if (!e) return ""; var i = e.className || ""; return i.baseVal && (i = i.baseVal), i.indexOf || (i = ""), i || ""; } function pt(e, i, t) { t === void 0 && (t = !0); for (var n = e.target || e.srcElement, s = ""; n; ) { if (s = ft(n)) { var a = s.indexOf(i); if (a >= 0) { if (!t) return n; var o = a === 0 || !(s.charAt(a - 1) || "").trim(), _ = a + i.length >= s.length || !s.charAt(a + i.length).trim(); if (o && _) return n; } } n = n.parentNode; } return null; } function It(e) { var i = !1, t = !1; if (window.getComputedStyle) { var n = window.getComputedStyle(e, null); i = n.display, t = n.visibility; } else e.currentStyle && (i = e.currentStyle.display, t = e.currentStyle.visibility); var s = !1, a = pt({ target: e }, "dhx_form_repeat", !1); return a && (s = a.style.height == "0px"), s = s || !e.offsetHeight, i != "none" && t != "hidden" && !s; } function Rt(e) { return !isNaN(e.getAttribute("tabindex")) && 1 * e.getAttribute("tabindex") >= 0; } function Pt(e) { return !{ a: !0, area: !0 }[e.nodeName.loLowerCase()] || !!e.getAttribute("href"); } function Yt(e) { return !{ input: !0, select: !0, textarea: !0, button: !0, object: !0 }[e.nodeName.toLowerCase()] || !e.hasAttribute("disabled"); } function vt() { return document.head.createShadowRoot || document.head.attachShadow; } function Ke(e, i) { if (e.closest) return e.closest(i); if (e.matches || e.msMatchesSelector || e.webkitMatchesSelector) { var t = e; if (!document.documentElement.contains(t)) return null; do { if ((t.matches || t.msMatchesSelector || t.webkitMatchesSelector).call(t, i)) return t; t = t.parentElement || t.parentNode; } while (t !== null && t.nodeType === 1); return null; } return console.error("Your browser is not supported"), null; } function Ge(e) { if (!e || !vt()) return document.body; for (; e.parentNode && (e = e.parentNode); ) if (e instanceof ShadowRoot) return e.host; return document.body; } const ue = { getAbsoluteLeft: function(e) { return this.getOffset(e).left + (parseInt(window.getComputedStyle(e).paddingLeft, 10) || 0); }, getAbsoluteTop: function(e) { return this.getOffset(e).top + (parseInt(window.getComputedStyle(e).paddingTop, 10) || 0); }, getOffsetSum: function(e) { for (var i = 0, t = 0; e; ) i += parseInt(e.offsetTop), t += parseInt(e.offsetLeft), e = e.offsetParent; return { top: i, left: t }; }, getOffsetRect: function(e) { var i = e.getBoundingClientRect(), t = 0, n = 0; if (/Mobi/.test(navigator.userAgent)) { var s = document.createElement("div"); s.style.position = "absolute", s.style.left = "0px", s.style.top = "0px", s.style.width = "1px", s.style.height = "1px", document.body.appendChild(s); var a = s.getBoundingClientRect(); t = i.top - a.top, n = i.left - a.left, s.parentNode.removeChild(s); } else { var o = document.body, _ = document.documentElement, r = window.pageYOffset || _.scrollTop || o.scrollTop, d = window.pageXOffset || _.scrollLeft || o.scrollLeft, l = _.clientTop || o.clientTop || 0, h = _.clientLeft || o.clientLeft || 0; t = i.top + r - l, n = i.left + d - h; } return { top: Math.round(t), left: Math.round(n) }; }, getOffset: function(e) { return e.getBoundingClientRect ? this.getOffsetRect(e) : this.getOffsetSum(e); }, closest: function(e, i) { return e && i ? Ke(e, i) : null; }, insertAfter: function(e, i) { i.nextSibling ? i.parentNode.insertBefore(e, i.nextSibling) : i.parentNode.appendChild(e); }, remove: function(e) { e && e.parentNode && e.parentNode.removeChild(e); }, isChildOf: function(e, i) { return i.contains(e); }, getFocusableNodes: function(e) { for (var i = e.querySelectorAll(["a[href]", "area[href]", "input", "select", "textarea", "button", "iframe", "object", "embed", "[tabindex]", "[contenteditable]"].join(", ")), t = Array.prototype.slice.call(i, 0), n = 0; n < t.length; n++) t[n].$position = n; for (t.sort(function(a, o) { return a.tabIndex === 0 && o.tabIndex !== 0 ? 1 : a.tabIndex !== 0 && o.tabIndex === 0 ? -1 : a.tabIndex === o.tabIndex ? a.$position - o.$position : a.tabIndex < o.tabIndex ? -1 : 1; }), n = 0; n < t.length; n++) { var s = t[n]; (Rt(s) || Yt(s) || Pt(s)) && It(s) || (t.splice(n, 1), n--); } return t; }, getClassName: ft, locateCss: pt, getRootNode: Ge, hasShadowParent: function(e) { return !!Ge(e); }, isShadowDomSupported: vt, getActiveElement: function() { var e = document.activeElement; return e.shadowRoot && (e = e.shadowRoot.activeElement), e === document.body && document.getSelection && (e = document.getSelection().focusNode || document.body), e; }, getRelativeEventPosition: function(e, i) { var t = document.documentElement, n = function(s) { var a = 0, o = 0, _ = 0, r = 0; if (s.getBoundingClientRect) { var d = s.getBoundingClientRect(), l = document.body, h = document.documentElement || document.body.parentNode || document.body, p = window.pageYOffset || h.scrollTop || l.scrollTop, m = window.pageXOffset || h.scrollLeft || l.scrollLeft, v = h.clientTop || l.clientTop || 0, c = h.clientLeft || l.clientLeft || 0; a = d.top + p - v, o = d.left + m - c, _ = document.body.offsetWidth - d.right, r = document.body.offsetHeight - d.bottom; } else { for (; s; ) a += parseInt(s.offsetTop, 10), o += parseInt(s.offsetLeft, 10), s = s.offsetParent; _ = document.body.offsetWidth - s.offsetWidth - o, r