import { a9 as Ce, aa as Z, ad as Oe, D as G, i as M, ae as De, g as ue, v as ye, z as E, A as N, F as Ie, G as Pe, H as F, I as k, J as Ae, K as Ve, L as $, M as j, N as Y, O as J, P as K, Q as I, e as A, R as xe, ac as He, ab as Ne, f as ce, h as W, j as je, p as _e, u as Le, l as de, n as V, r as Me, d as x, s as Fe, o as Ue, q as Be, t as Ge, w as We, S as ze, U as qe, a as z, W as X, X as Ze, a3 as ke, a4 as $e, a5 as Ye, a6 as Je, a7 as Q, a8 as Ke, V as fe, m as Xe, T as Qe, c as et, k as _, x as tt, y as nt, E as rt, B as H, Y as st, C as it, b as at, Z as pe, _ as U, $ as lt, a0 as he, a1 as ot, a2 as ut } from "./internal-common.mjs";
import { ag as Vn } from "./internal-common.mjs";
import { render as ee, createElement as m, createRef as te, Fragment as ct } from "../../preact/dist/preact.module.mjs";
import "../../preact/compat/dist/compat.module.mjs";
const dt = [], ge = {
  code: "en",
  week: {
    dow: 0,
    doy: 4
    // 4 days need to be within the year to be considered the first week
  },
  direction: "ltr",
  buttonText: {
    prev: "prev",
    next: "next",
    prevYear: "prev year",
    nextYear: "next year",
    year: "year",
    today: "today",
    month: "month",
    week: "week",
    day: "day",
    list: "list"
  },
  weekText: "W",
  weekTextLong: "Week",
  closeHint: "Close",
  timeHint: "Time",
  eventHint: "Event",
  allDayText: "all-day",
  moreLinkText: "more",
  noEventsText: "No events to display"
}, me = Object.assign(Object.assign({}, ge), {
  // Includes things we don't want other locales to inherit,
  // things that derive from other translatable strings.
  buttonHints: {
    prev: "Previous $0",
    next: "Next $0",
    today(t, e) {
      return e === "day" ? "Today" : `This ${t}`;
    }
  },
  viewHint: "$0 view",
  navLinkHint: "Go to $0",
  moreLinkHint(t) {
    return `Show ${t} more event${t === 1 ? "" : "s"}`;
  }
});
function ft(t) {
  let e = t.length > 0 ? t[0].code : "en", n = dt.concat(t), r = {
    en: me
  };
  for (let s of n)
    r[s.code] = s;
  return {
    map: r,
    defaultCode: e
  };
}
function ve(t, e) {
  return typeof t == "object" && !Array.isArray(t) ? be(t.code, [t.code], t) : pt(t, e);
}
function pt(t, e) {
  let n = [].concat(t || []), r = ht(n, e) || me;
  return be(t, n, r);
}
function ht(t, e) {
  for (let n = 0; n < t.length; n += 1) {
    let r = t[n].toLocaleLowerCase().split("-");
    for (let s = r.length; s > 0; s -= 1) {
      let a = r.slice(0, s).join("-");
      if (e[a])
        return e[a];
    }
  }
  return null;
}
function be(t, e, n) {
  let r = Xe([ge, n], ["buttonText"]);
  delete r.code;
  let { week: s } = r;
  return delete r.week, {
    codeArg: t,
    codes: e,
    week: s,
    simpleNumberFormat: new Intl.NumberFormat(t),
    options: r
  };
}
function P(t) {
  return {
    id: ue(),
    name: t.name,
    premiumReleaseDate: t.premiumReleaseDate ? new Date(t.premiumReleaseDate) : void 0,
    deps: t.deps || [],
    reducers: t.reducers || [],
    isLoadingFuncs: t.isLoadingFuncs || [],
    contextInit: [].concat(t.contextInit || []),
    eventRefiners: t.eventRefiners || {},
    eventDefMemberAdders: t.eventDefMemberAdders || [],
    eventSourceRefiners: t.eventSourceRefiners || {},
    isDraggableTransformers: t.isDraggableTransformers || [],
    eventDragMutationMassagers: t.eventDragMutationMassagers || [],
    eventDefMutationAppliers: t.eventDefMutationAppliers || [],
    dateSelectionTransformers: t.dateSelectionTransformers || [],
    datePointTransforms: t.datePointTransforms || [],
    dateSpanTransforms: t.dateSpanTransforms || [],
    views: t.views || {},
    viewPropsTransformers: t.viewPropsTransformers || [],
    isPropsValid: t.isPropsValid || null,
    externalDefTransforms: t.externalDefTransforms || [],
    viewContainerAppends: t.viewContainerAppends || [],
    eventDropTransformers: t.eventDropTransformers || [],
    componentInteractions: t.componentInteractions || [],
    calendarInteractions: t.calendarInteractions || [],
    themeClasses: t.themeClasses || {},
    eventSourceDefs: t.eventSourceDefs || [],
    cmdFormatter: t.cmdFormatter,
    recurringTypes: t.recurringTypes || [],
    namedTimeZonedImpl: t.namedTimeZonedImpl,
    initialView: t.initialView || "",
    elementDraggingImpl: t.elementDraggingImpl,
    optionChangeHandlers: t.optionChangeHandlers || {},
    scrollGridImpl: t.scrollGridImpl || null,
    listenerRefiners: t.listenerRefiners || {},
    optionRefiners: t.optionRefiners || {},
    propSetHandlers: t.propSetHandlers || {}
  };
}
function gt(t, e) {
  let n = {}, r = {
    premiumReleaseDate: void 0,
    reducers: [],
    isLoadingFuncs: [],
    contextInit: [],
    eventRefiners: {},
    eventDefMemberAdders: [],
    eventSourceRefiners: {},
    isDraggableTransformers: [],
    eventDragMutationMassagers: [],
    eventDefMutationAppliers: [],
    dateSelectionTransformers: [],
    datePointTransforms: [],
    dateSpanTransforms: [],
    views: {},
    viewPropsTransformers: [],
    isPropsValid: null,
    externalDefTransforms: [],
    viewContainerAppends: [],
    eventDropTransformers: [],
    componentInteractions: [],
    calendarInteractions: [],
    themeClasses: {},
    eventSourceDefs: [],
    cmdFormatter: null,
    recurringTypes: [],
    namedTimeZonedImpl: null,
    initialView: "",
    elementDraggingImpl: null,
    optionChangeHandlers: {},
    scrollGridImpl: null,
    listenerRefiners: {},
    optionRefiners: {},
    propSetHandlers: {}
  };
  function s(a) {
    for (let i of a) {
      const l = i.name, o = n[l];
      o === void 0 ? (n[l] = i.id, s(i.deps), r = vt(r, i)) : o !== i.id && console.warn(`Duplicate plugin '${l}'`);
    }
  }
  return t && s(t), s(e), r;
}
function mt() {
  let t = [], e = [], n;
  return (r, s) => ((!n || !M(r, t) || !M(s, e)) && (n = gt(r, s)), t = r, e = s, n);
}
function vt(t, e) {
  return {
    premiumReleaseDate: bt(t.premiumReleaseDate, e.premiumReleaseDate),
    reducers: t.reducers.concat(e.reducers),
    isLoadingFuncs: t.isLoadingFuncs.concat(e.isLoadingFuncs),
    contextInit: t.contextInit.concat(e.contextInit),
    eventRefiners: Object.assign(Object.assign({}, t.eventRefiners), e.eventRefiners),
    eventDefMemberAdders: t.eventDefMemberAdders.concat(e.eventDefMemberAdders),
    eventSourceRefiners: Object.assign(Object.assign({}, t.eventSourceRefiners), e.eventSourceRefiners),
    isDraggableTransformers: t.isDraggableTransformers.concat(e.isDraggableTransformers),
    eventDragMutationMassagers: t.eventDragMutationMassagers.concat(e.eventDragMutationMassagers),
    eventDefMutationAppliers: t.eventDefMutationAppliers.concat(e.eventDefMutationAppliers),
    dateSelectionTransformers: t.dateSelectionTransformers.concat(e.dateSelectionTransformers),
    datePointTransforms: t.datePointTransforms.concat(e.datePointTransforms),
    dateSpanTransforms: t.dateSpanTransforms.concat(e.dateSpanTransforms),
    views: Object.assign(Object.assign({}, t.views), e.views),
    viewPropsTransformers: t.viewPropsTransformers.concat(e.viewPropsTransformers),
    isPropsValid: e.isPropsValid || t.isPropsValid,
    externalDefTransforms: t.externalDefTransforms.concat(e.externalDefTransforms),
    viewContainerAppends: t.viewContainerAppends.concat(e.viewContainerAppends),
    eventDropTransformers: t.eventDropTransformers.concat(e.eventDropTransformers),
    calendarInteractions: t.calendarInteractions.concat(e.calendarInteractions),
    componentInteractions: t.componentInteractions.concat(e.componentInteractions),
    themeClasses: Object.assign(Object.assign({}, t.themeClasses), e.themeClasses),
    eventSourceDefs: t.eventSourceDefs.concat(e.eventSourceDefs),
    cmdFormatter: e.cmdFormatter || t.cmdFormatter,
    recurringTypes: t.recurringTypes.concat(e.recurringTypes),
    namedTimeZonedImpl: e.namedTimeZonedImpl || t.namedTimeZonedImpl,
    initialView: t.initialView || e.initialView,
    elementDraggingImpl: t.elementDraggingImpl || e.elementDraggingImpl,
    optionChangeHandlers: Object.assign(Object.assign({}, t.optionChangeHandlers), e.optionChangeHandlers),
    scrollGridImpl: e.scrollGridImpl || t.scrollGridImpl,
    listenerRefiners: Object.assign(Object.assign({}, t.listenerRefiners), e.listenerRefiners),
    optionRefiners: Object.assign(Object.assign({}, t.optionRefiners), e.optionRefiners),
    propSetHandlers: Object.assign(Object.assign({}, t.propSetHandlers), e.propSetHandlers)
  };
}
function bt(t, e) {
  return t === void 0 ? e : e === void 0 ? t : new Date(Math.max(t.valueOf(), e.valueOf()));
}
class O extends Qe {
}
O.prototype.classes = {
  root: "fc-theme-standard",
  tableCellShaded: "fc-cell-shaded",
  buttonGroup: "fc-button-group",
  button: "fc-button fc-button-primary",
  buttonActive: "fc-button-active"
};
O.prototype.baseIconClass = "fc-icon";
O.prototype.iconClasses = {
  close: "fc-icon-x",
  prev: "fc-icon-chevron-left",
  next: "fc-icon-chevron-right",
  prevYear: "fc-icon-chevrons-left",
  nextYear: "fc-icon-chevrons-right"
};
O.prototype.rtlIconClasses = {
  prev: "fc-icon-chevron-right",
  next: "fc-icon-chevron-left",
  prevYear: "fc-icon-chevrons-right",
  nextYear: "fc-icon-chevrons-left"
};
O.prototype.iconOverrideOption = "buttonIcons";
O.prototype.iconOverrideCustomButtonOption = "icon";
O.prototype.iconOverridePrefix = "fc-icon-";
function Et(t, e) {
  let n = {}, r;
  for (r in t)
    B(r, n, t, e);
  for (r in e)
    B(r, n, t, e);
  return n;
}
function B(t, e, n, r) {
  if (e[t])
    return e[t];
  let s = Rt(t, e, n, r);
  return s && (e[t] = s), s;
}
function Rt(t, e, n, r) {
  let s = n[t], a = r[t], i = (d) => s && s[d] !== null ? s[d] : a && a[d] !== null ? a[d] : null, l = i("component"), o = i("superType"), u = null;
  if (o) {
    if (o === t)
      throw new Error("Can't have a custom view type that references itself");
    u = B(o, e, n, r);
  }
  return !l && u && (l = u.component), l ? {
    type: t,
    component: l,
    defaults: Object.assign(Object.assign({}, u ? u.defaults : {}), s ? s.rawOptions : {}),
    overrides: Object.assign(Object.assign({}, u ? u.overrides : {}), a ? a.rawOptions : {})
  } : null;
}
function ne(t) {
  return z(t, Tt);
}
function Tt(t) {
  let e = typeof t == "function" ? { component: t } : t, { component: n } = e;
  return e.content ? n = re(e) : n && !(n.prototype instanceof H) && (n = re(Object.assign(Object.assign({}, e), { content: n }))), {
    superType: e.type,
    component: n,
    rawOptions: e
    // includes type and component too :(
  };
}
function re(t) {
  return (e) => m(fe.Consumer, null, (n) => m(it, { elTag: "div", elClasses: at(n.viewSpec), renderProps: Object.assign(Object.assign({}, e), { nextDayThreshold: n.options.nextDayThreshold }), generatorName: void 0, customGenerator: t.content, classNameGenerator: t.classNames, didMount: t.didMount, willUnmount: t.willUnmount }));
}
function wt(t, e, n, r) {
  let s = ne(t), a = ne(e.views), i = Et(s, a);
  return z(i, (l) => St(l, a, e, n, r));
}
function St(t, e, n, r, s) {
  let a = t.overrides.duration || t.defaults.duration || r.duration || n.duration, i = null, l = "", o = "", u = {};
  if (a && (i = Ct(a), i)) {
    let p = et(i);
    l = p.unit, p.value === 1 && (o = l, u = e[l] ? e[l].rawOptions : {});
  }
  let d = (p) => {
    let c = p.buttonText || {}, v = t.defaults.buttonTextKey;
    return v != null && c[v] != null ? c[v] : c[t.type] != null ? c[t.type] : c[o] != null ? c[o] : null;
  }, f = (p) => {
    let c = p.buttonHints || {}, v = t.defaults.buttonTextKey;
    return v != null && c[v] != null ? c[v] : c[t.type] != null ? c[t.type] : c[o] != null ? c[o] : null;
  };
  return {
    type: t.type,
    component: t.component,
    duration: i,
    durationUnit: l,
    singleUnit: o,
    optionDefaults: t.defaults,
    optionOverrides: Object.assign(Object.assign({}, u), t.overrides),
    buttonTextOverride: d(r) || d(n) || // constructor-specified buttonText lookup hash takes precedence
    t.overrides.buttonText,
    buttonTextDefault: d(s) || t.defaults.buttonText || d(A) || t.type,
    // not DRY
    buttonTitleOverride: f(r) || f(n) || t.overrides.buttonHint,
    buttonTitleDefault: f(s) || t.defaults.buttonHint || f(A)
    // will eventually fall back to buttonText
  };
}
let se = {};
function Ct(t) {
  let e = JSON.stringify(t), n = se[e];
  return n === void 0 && (n = x(t), se[e] = n), n;
}
function Ot(t, e) {
  switch (e.type) {
    case "CHANGE_VIEW_TYPE":
      t = e.viewType;
  }
  return t;
}
function Dt(t, e) {
  switch (e.type) {
    case "SET_OPTION":
      return Object.assign(Object.assign({}, t), { [e.optionName]: e.rawOptionValue });
    default:
      return t;
  }
}
function yt(t, e, n, r) {
  let s;
  switch (e.type) {
    case "CHANGE_VIEW_TYPE":
      return r.build(e.dateMarker || n);
    case "CHANGE_DATE":
      return r.build(e.dateMarker);
    case "PREV":
      if (s = r.buildPrev(t, n), s.isValid)
        return s;
      break;
    case "NEXT":
      if (s = r.buildNext(t, n), s.isValid)
        return s;
      break;
  }
  return t;
}
function It(t, e, n) {
  let r = e ? e.activeRange : null;
  return Re({}, jt(t, n), r, n);
}
function Pt(t, e, n, r) {
  let s = n ? n.activeRange : null;
  switch (e.type) {
    case "ADD_EVENT_SOURCES":
      return Re(t, e.sources, s, r);
    case "REMOVE_EVENT_SOURCE":
      return Vt(t, e.sourceId);
    case "PREV":
    case "NEXT":
    case "CHANGE_DATE":
    case "CHANGE_VIEW_TYPE":
      return n ? Te(t, s, r) : t;
    case "FETCH_EVENT_SOURCES":
      return q(t, e.sourceIds ? (
        // why no type?
        ce(e.sourceIds)
      ) : we(t, r), s, e.isRefetch || !1, r);
    case "RECEIVE_EVENTS":
    case "RECEIVE_EVENT_ERROR":
      return Nt(t, e.sourceId, e.fetchId, e.fetchRange);
    case "REMOVE_ALL_EVENT_SOURCES":
      return {};
    default:
      return t;
  }
}
function At(t, e, n) {
  let r = e ? e.activeRange : null;
  return q(t, we(t, n), r, !0, n);
}
function Ee(t) {
  for (let e in t)
    if (t[e].isFetching)
      return !0;
  return !1;
}
function Re(t, e, n, r) {
  let s = {};
  for (let a of e)
    s[a.sourceId] = a;
  return n && (s = Te(s, n, r)), Object.assign(Object.assign({}, t), s);
}
function Vt(t, e) {
  return W(t, (n) => n.sourceId !== e);
}
function Te(t, e, n) {
  return q(t, W(t, (r) => xt(r, e, n)), e, !1, n);
}
function xt(t, e, n) {
  return Se(t, n) ? !n.options.lazyFetching || !t.fetchRange || t.isFetching || // always cancel outdated in-progress fetches
  e.start < t.fetchRange.start || e.end > t.fetchRange.end : !t.latestFetchId;
}
function q(t, e, n, r, s) {
  let a = {};
  for (let i in t) {
    let l = t[i];
    e[i] ? a[i] = Ht(l, n, r, s) : a[i] = l;
  }
  return a;
}
function Ht(t, e, n, r) {
  let { options: s, calendarApi: a } = r, i = r.pluginHooks.eventSourceDefs[t.sourceDefId], l = ue();
  return i.fetch({
    eventSource: t,
    range: e,
    isRefetch: n,
    context: r
  }, (o) => {
    let { rawEvents: u } = o;
    s.eventSourceSuccess && (u = s.eventSourceSuccess.call(a, u, o.response) || u), t.success && (u = t.success.call(a, u, o.response) || u), r.dispatch({
      type: "RECEIVE_EVENTS",
      sourceId: t.sourceId,
      fetchId: l,
      fetchRange: e,
      rawEvents: u
    });
  }, (o) => {
    let u = !1;
    s.eventSourceFailure && (s.eventSourceFailure.call(a, o), u = !0), t.failure && (t.failure(o), u = !0), u || console.warn(o.message, o), r.dispatch({
      type: "RECEIVE_EVENT_ERROR",
      sourceId: t.sourceId,
      fetchId: l,
      fetchRange: e,
      error: o
    });
  }), Object.assign(Object.assign({}, t), { isFetching: !0, latestFetchId: l });
}
function Nt(t, e, n, r) {
  let s = t[e];
  return s && // not already removed
  n === s.latestFetchId ? Object.assign(Object.assign({}, t), { [e]: Object.assign(Object.assign({}, s), { isFetching: !1, fetchRange: r }) }) : t;
}
function we(t, e) {
  return W(t, (n) => Se(n, e));
}
function jt(t, e) {
  let n = je(e), r = [].concat(t.eventSources || []), s = [];
  t.initialEvents && r.unshift(t.initialEvents), t.events && r.unshift(t.events);
  for (let a of r) {
    let i = _e(a, e, n);
    i && s.push(i);
  }
  return s;
}
function Se(t, e) {
  return !e.pluginHooks.eventSourceDefs[t.sourceDefId].ignoreRange;
}
function _t(t, e) {
  switch (e.type) {
    case "UNSELECT_DATES":
      return null;
    case "SELECT_DATES":
      return e.selection;
    default:
      return t;
  }
}
function Lt(t, e) {
  switch (e.type) {
    case "UNSELECT_EVENT":
      return "";
    case "SELECT_EVENT":
      return e.eventInstanceId;
    default:
      return t;
  }
}
function Mt(t, e) {
  let n;
  switch (e.type) {
    case "UNSET_EVENT_DRAG":
      return null;
    case "SET_EVENT_DRAG":
      return n = e.state, {
        affectedEvents: n.affectedEvents,
        mutatedEvents: n.mutatedEvents,
        isEvent: n.isEvent
      };
    default:
      return t;
  }
}
function Ft(t, e) {
  let n;
  switch (e.type) {
    case "UNSET_EVENT_RESIZE":
      return null;
    case "SET_EVENT_RESIZE":
      return n = e.state, {
        affectedEvents: n.affectedEvents,
        mutatedEvents: n.mutatedEvents,
        isEvent: n.isEvent
      };
    default:
      return t;
  }
}
function Ut(t, e, n, r, s) {
  let a = t.headerToolbar ? ie(t.headerToolbar, t, e, n, r, s) : null, i = t.footerToolbar ? ie(t.footerToolbar, t, e, n, r, s) : null;
  return { header: a, footer: i };
}
function ie(t, e, n, r, s, a) {
  let i = {}, l = [], o = !1;
  for (let u in t) {
    let d = t[u], f = Bt(d, e, n, r, s, a);
    i[u] = f.widgets, l.push(...f.viewsWithButtons), o = o || f.hasTitle;
  }
  return { sectionWidgets: i, viewsWithButtons: l, hasTitle: o };
}
function Bt(t, e, n, r, s, a) {
  let i = e.direction === "rtl", l = e.customButtons || {}, o = n.buttonText || {}, u = e.buttonText || {}, d = n.buttonHints || {}, f = e.buttonHints || {}, p = t ? t.split(" ") : [], c = [], v = !1;
  return { widgets: p.map((g) => g.split(",").map((h) => {
    if (h === "title")
      return v = !0, { buttonName: h };
    let R, T, w, D, S, C;
    if (R = l[h])
      w = (b) => {
        R.click && R.click.call(b.target, b, b.target);
      }, (D = r.getCustomButtonIconClass(R)) || (D = r.getIconClass(h, i)) || (S = R.text), C = R.hint || R.text;
    else if (T = s[h]) {
      c.push(h), w = () => {
        a.changeView(h);
      }, (S = T.buttonTextOverride) || (D = r.getIconClass(h, i)) || (S = T.buttonTextDefault);
      let b = T.buttonTextOverride || T.buttonTextDefault;
      C = _(
        T.buttonTitleOverride || T.buttonTitleDefault || e.viewHint,
        [b, h],
        // view-name = buttonName
        b
      );
    } else if (a[h])
      if (w = () => {
        a[h]();
      }, (S = o[h]) || (D = r.getIconClass(h, i)) || (S = u[h]), h === "prevYear" || h === "nextYear") {
        let b = h === "prevYear" ? "prev" : "next";
        C = _(d[b] || f[b], [
          u.year || "year",
          "year"
        ], u[h]);
      } else
        C = (b) => _(d[h] || f[h], [
          u[b] || b,
          b
        ], u[h]);
    return { buttonName: h, buttonClick: w, buttonIcon: D, buttonText: S, buttonHint: C };
  })), viewsWithButtons: c, hasTitle: v };
}
class Gt {
  constructor(e, n, r) {
    this.type = e, this.getCurrentData = n, this.dateEnv = r;
  }
  get calendar() {
    return this.getCurrentData().calendarApi;
  }
  get title() {
    return this.getCurrentData().viewTitle;
  }
  get activeStart() {
    return this.dateEnv.toDate(this.getCurrentData().dateProfile.activeRange.start);
  }
  get activeEnd() {
    return this.dateEnv.toDate(this.getCurrentData().dateProfile.activeRange.end);
  }
  get currentStart() {
    return this.dateEnv.toDate(this.getCurrentData().dateProfile.currentRange.start);
  }
  get currentEnd() {
    return this.dateEnv.toDate(this.getCurrentData().dateProfile.currentRange.end);
  }
  getOption(e) {
    return this.getCurrentData().options[e];
  }
}
let Wt = {
  ignoreRange: !0,
  parseMeta(t) {
    return Array.isArray(t.events) ? t.events : null;
  },
  fetch(t, e) {
    e({
      rawEvents: t.eventSource.meta
    });
  }
};
const zt = P({
  name: "array-event-source",
  eventSourceDefs: [Wt]
});
let qt = {
  parseMeta(t) {
    return typeof t.events == "function" ? t.events : null;
  },
  fetch(t, e, n) {
    const { dateEnv: r } = t.context, s = t.eventSource.meta;
    Le(s.bind(null, de(t.range, r)), (a) => e({ rawEvents: a }), n);
  }
};
const Zt = P({
  name: "func-event-source",
  eventSourceDefs: [qt]
}), kt = {
  method: String,
  extraParams: V,
  startParam: String,
  endParam: String,
  timeZoneParam: String
};
let $t = {
  parseMeta(t) {
    return t.url && (t.format === "json" || !t.format) ? {
      url: t.url,
      format: "json",
      method: (t.method || "GET").toUpperCase(),
      extraParams: t.extraParams,
      startParam: t.startParam,
      endParam: t.endParam,
      timeZoneParam: t.timeZoneParam
    } : null;
  },
  fetch(t, e, n) {
    const { meta: r } = t.eventSource, s = Jt(r, t.range, t.context);
    Me(r.method, r.url, s).then(([a, i]) => {
      e({ rawEvents: a, response: i });
    }, n);
  }
};
const Yt = P({
  name: "json-event-source",
  eventSourceRefiners: kt,
  eventSourceDefs: [$t]
});
function Jt(t, e, n) {
  let { dateEnv: r, options: s } = n, a, i, l, o, u = {};
  return a = t.startParam, a == null && (a = s.startParam), i = t.endParam, i == null && (i = s.endParam), l = t.timeZoneParam, l == null && (l = s.timeZoneParam), typeof t.extraParams == "function" ? o = t.extraParams() : o = t.extraParams || {}, Object.assign(u, o), u[a] = r.formatIso(e.start), u[i] = r.formatIso(e.end), r.timeZone !== "local" && (u[l] = r.timeZone), u;
}
const Kt = {
  daysOfWeek: V,
  startTime: x,
  endTime: x,
  duration: x,
  startRecur: V,
  endRecur: V
};
let Xt = {
  parse(t, e) {
    if (t.daysOfWeek || t.startTime || t.endTime || t.startRecur || t.endRecur) {
      let n = {
        daysOfWeek: t.daysOfWeek || null,
        startTime: t.startTime || null,
        endTime: t.endTime || null,
        startRecur: t.startRecur ? e.createMarker(t.startRecur) : null,
        endRecur: t.endRecur ? e.createMarker(t.endRecur) : null
      }, r;
      return t.duration && (r = t.duration), !r && t.startTime && t.endTime && (r = Fe(t.endTime, t.startTime)), {
        allDayGuess: !t.startTime && !t.endTime,
        duration: r,
        typeData: n
        // doesn't need endTime anymore but oh well
      };
    }
    return null;
  },
  expand(t, e, n) {
    let r = Ue(e, { start: t.startRecur, end: t.endRecur });
    return r ? en(t.daysOfWeek, t.startTime, r, n) : [];
  }
};
const Qt = P({
  name: "simple-recurring-event",
  recurringTypes: [Xt],
  eventRefiners: Kt
});
function en(t, e, n, r) {
  let s = t ? ce(t) : null, a = Be(n.start), i = n.end, l = [];
  for (; a < i; ) {
    let o;
    (!s || s[a.getUTCDay()]) && (e ? o = r.add(a, e) : o = a, l.push(o)), a = Ge(a, 1);
  }
  return l;
}
const tn = P({
  name: "change-handler",
  optionChangeHandlers: {
    events(t, e) {
      ae([t], e);
    },
    eventSources: ae
  }
});
function ae(t, e) {
  let n = ye(e.getCurrentData().eventSources);
  if (n.length === 1 && t.length === 1 && Array.isArray(n[0]._raw) && Array.isArray(t[0])) {
    e.dispatch({
      type: "RESET_RAW_EVENTS",
      sourceId: n[0].sourceId,
      rawEvents: t[0]
    });
    return;
  }
  let r = [];
  for (let s of t) {
    let a = !1;
    for (let i = 0; i < n.length; i += 1)
      if (n[i]._raw === s) {
        n.splice(i, 1), a = !0;
        break;
      }
    a || r.push(s);
  }
  for (let s of n)
    e.dispatch({
      type: "REMOVE_EVENT_SOURCE",
      sourceId: s.sourceId
    });
  for (let s of r)
    e.calendarApi.addEventSource(s);
}
function nn(t, e) {
  e.emitter.trigger("datesSet", Object.assign(Object.assign({}, de(t.activeRange, e.dateEnv)), { view: e.viewApi }));
}
function rn(t, e) {
  let { emitter: n } = e;
  n.hasHandlers("eventsSet") && n.trigger("eventsSet", We(t, e));
}
const sn = [
  zt,
  Zt,
  Yt,
  Qt,
  tn,
  P({
    name: "misc",
    isLoadingFuncs: [
      (t) => Ee(t.eventSources)
    ],
    propSetHandlers: {
      dateProfile: nn,
      eventStore: rn
    }
  })
];
class an {
  constructor(e, n) {
    this.runTaskOption = e, this.drainedOption = n, this.queue = [], this.delayedRunner = new G(this.drain.bind(this));
  }
  request(e, n) {
    this.queue.push(e), this.delayedRunner.request(n);
  }
  pause(e) {
    this.delayedRunner.pause(e);
  }
  resume(e, n) {
    this.delayedRunner.resume(e, n);
  }
  drain() {
    let { queue: e } = this;
    for (; e.length; ) {
      let n = [], r;
      for (; r = e.shift(); )
        this.runTask(r), n.push(r);
      this.drained(n);
    }
  }
  runTask(e) {
    this.runTaskOption && this.runTaskOption(e);
  }
  drained(e) {
    this.drainedOption && this.drainedOption(e);
  }
}
function ln(t, e, n) {
  let r;
  return /^(year|month)$/.test(t.currentRangeUnit) ? r = t.currentRange : r = t.activeRange, n.formatRange(r.start, r.end, tt(e.titleFormat || on(t)), {
    isEndExclusive: t.isRangeAllDay,
    defaultSeparator: e.titleRangeSeparator
  });
}
function on(t) {
  let { currentRangeUnit: e } = t;
  if (e === "year")
    return { year: "numeric" };
  if (e === "month")
    return { year: "numeric", month: "long" };
  let n = nt(t.currentRange.start, t.currentRange.end);
  return n !== null && n > 1 ? { year: "numeric", month: "short", day: "numeric" } : { year: "numeric", month: "long", day: "numeric" };
}
class un {
  constructor(e) {
    this.computeCurrentViewData = E(this._computeCurrentViewData), this.organizeRawLocales = E(ft), this.buildLocale = E(ve), this.buildPluginHooks = mt(), this.buildDateEnv = E(cn), this.buildTheme = E(dn), this.parseToolbars = E(Ut), this.buildViewSpecs = E(wt), this.buildDateProfileGenerator = N(fn), this.buildViewApi = E(pn), this.buildViewUiProps = N(mn), this.buildEventUiBySource = E(hn, rt), this.buildEventUiBases = E(gn), this.parseContextBusinessHours = N(vn), this.buildTitle = E(ln), this.emitter = new Ie(), this.actionRunner = new an(this._handleAction.bind(this), this.updateData.bind(this)), this.currentCalendarOptionsInput = {}, this.currentCalendarOptionsRefined = {}, this.currentViewOptionsInput = {}, this.currentViewOptionsRefined = {}, this.currentCalendarOptionsRefiners = {}, this.optionsForRefining = [], this.optionsForHandling = [], this.getCurrentData = () => this.data, this.dispatch = (p) => {
      this.actionRunner.request(p);
    }, this.props = e, this.actionRunner.pause();
    let n = {}, r = this.computeOptionsData(e.optionOverrides, n, e.calendarApi), s = r.calendarOptions.initialView || r.pluginHooks.initialView, a = this.computeCurrentViewData(s, r, e.optionOverrides, n);
    e.calendarApi.currentDataManager = this, this.emitter.setThisContext(e.calendarApi), this.emitter.setOptions(a.options);
    let i = Pe(r.calendarOptions, r.dateEnv), l = a.dateProfileGenerator.build(i);
    F(l.activeRange, i) || (i = l.currentRange.start);
    let o = {
      dateEnv: r.dateEnv,
      options: r.calendarOptions,
      pluginHooks: r.pluginHooks,
      calendarApi: e.calendarApi,
      dispatch: this.dispatch,
      emitter: this.emitter,
      getCurrentData: this.getCurrentData
    };
    for (let p of r.pluginHooks.contextInit)
      p(o);
    let u = It(r.calendarOptions, l, o), d = {
      dynamicOptionOverrides: n,
      currentViewType: s,
      currentDate: i,
      dateProfile: l,
      businessHours: this.parseContextBusinessHours(o),
      eventSources: u,
      eventUiBases: {},
      eventStore: k(),
      renderableEventStore: k(),
      dateSelection: null,
      eventSelection: "",
      eventDrag: null,
      eventResize: null,
      selectionConfig: this.buildViewUiProps(o).selectionConfig
    }, f = Object.assign(Object.assign({}, o), d);
    for (let p of r.pluginHooks.reducers)
      Object.assign(d, p(null, null, f));
    L(d, o) && this.emitter.trigger("loading", !0), this.state = d, this.updateData(), this.actionRunner.resume();
  }
  resetOptions(e, n) {
    let { props: r } = this;
    n === void 0 ? r.optionOverrides = e : (r.optionOverrides = Object.assign(Object.assign({}, r.optionOverrides || {}), e), this.optionsForRefining.push(...n)), (n === void 0 || n.length) && this.actionRunner.request({
      type: "NOTHING"
    });
  }
  _handleAction(e) {
    let { props: n, state: r, emitter: s } = this, a = Dt(r.dynamicOptionOverrides, e), i = this.computeOptionsData(n.optionOverrides, a, n.calendarApi), l = Ot(r.currentViewType, e), o = this.computeCurrentViewData(l, i, n.optionOverrides, a);
    n.calendarApi.currentDataManager = this, s.setThisContext(n.calendarApi), s.setOptions(o.options);
    let u = {
      dateEnv: i.dateEnv,
      options: i.calendarOptions,
      pluginHooks: i.pluginHooks,
      calendarApi: n.calendarApi,
      dispatch: this.dispatch,
      emitter: s,
      getCurrentData: this.getCurrentData
    }, { currentDate: d, dateProfile: f } = r;
    this.data && this.data.dateProfileGenerator !== o.dateProfileGenerator && (f = o.dateProfileGenerator.build(d)), d = Ae(d, e), f = yt(f, e, d, o.dateProfileGenerator), (e.type === "PREV" || // TODO: move this logic into DateProfileGenerator
    e.type === "NEXT" || // "
    !F(f.currentRange, d)) && (d = f.currentRange.start);
    let p = Pt(r.eventSources, e, f, u), c = Ve(r.eventStore, e, p, f, u), y = Ee(p) && !o.options.progressiveEventRendering && r.renderableEventStore || c, { eventUiSingleBase: g, selectionConfig: h } = this.buildViewUiProps(u), R = this.buildEventUiBySource(p), T = this.buildEventUiBases(y.defs, g, R), w = {
      dynamicOptionOverrides: a,
      currentViewType: l,
      currentDate: d,
      dateProfile: f,
      eventSources: p,
      eventStore: c,
      renderableEventStore: y,
      selectionConfig: h,
      eventUiBases: T,
      businessHours: this.parseContextBusinessHours(u),
      dateSelection: _t(r.dateSelection, e),
      eventSelection: Lt(r.eventSelection, e),
      eventDrag: Mt(r.eventDrag, e),
      eventResize: Ft(r.eventResize, e)
    }, D = Object.assign(Object.assign({}, u), w);
    for (let b of i.pluginHooks.reducers)
      Object.assign(w, b(r, e, D));
    let S = L(r, u), C = L(w, u);
    !S && C ? s.trigger("loading", !0) : S && !C && s.trigger("loading", !1), this.state = w, n.onAction && n.onAction(e);
  }
  updateData() {
    let { props: e, state: n } = this, r = this.data, s = this.computeOptionsData(e.optionOverrides, n.dynamicOptionOverrides, e.calendarApi), a = this.computeCurrentViewData(n.currentViewType, s, e.optionOverrides, n.dynamicOptionOverrides), i = this.data = Object.assign(Object.assign(Object.assign({ viewTitle: this.buildTitle(n.dateProfile, a.options, s.dateEnv), calendarApi: e.calendarApi, dispatch: this.dispatch, emitter: this.emitter, getCurrentData: this.getCurrentData }, s), a), n), l = s.pluginHooks.optionChangeHandlers, o = r && r.calendarOptions, u = s.calendarOptions;
    if (o && o !== u) {
      o.timeZone !== u.timeZone && (n.eventSources = i.eventSources = At(i.eventSources, n.dateProfile, i), n.eventStore = i.eventStore = $(i.eventStore, r.dateEnv, i.dateEnv), n.renderableEventStore = i.renderableEventStore = $(i.renderableEventStore, r.dateEnv, i.dateEnv));
      for (let d in l)
        (this.optionsForHandling.indexOf(d) !== -1 || o[d] !== u[d]) && l[d](u[d], i);
    }
    this.optionsForHandling = [], e.onData && e.onData(i);
  }
  computeOptionsData(e, n, r) {
    if (!this.optionsForRefining.length && e === this.stableOptionOverrides && n === this.stableDynamicOptionOverrides)
      return this.stableCalendarOptionsData;
    let { refinedOptions: s, pluginHooks: a, localeDefaults: i, availableLocaleData: l, extra: o } = this.processRawCalendarOptions(e, n);
    le(o);
    let u = this.buildDateEnv(s.timeZone, s.locale, s.weekNumberCalculation, s.firstDay, s.weekText, a, l, s.defaultRangeSeparator), d = this.buildViewSpecs(a.views, this.stableOptionOverrides, this.stableDynamicOptionOverrides, i), f = this.buildTheme(s, a), p = this.parseToolbars(s, this.stableOptionOverrides, f, d, r);
    return this.stableCalendarOptionsData = {
      calendarOptions: s,
      pluginHooks: a,
      dateEnv: u,
      viewSpecs: d,
      theme: f,
      toolbarConfig: p,
      localeDefaults: i,
      availableRawLocales: l.map
    };
  }
  // always called from behind a memoizer
  processRawCalendarOptions(e, n) {
    let { locales: r, locale: s } = j([
      A,
      e,
      n
    ]), a = this.organizeRawLocales(r), i = a.map, l = this.buildLocale(s || a.defaultCode, i).options, o = this.buildPluginHooks(e.plugins || [], sn), u = this.currentCalendarOptionsRefiners = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, Y), J), K), o.listenerRefiners), o.optionRefiners), d = {}, f = j([
      A,
      l,
      e,
      n
    ]), p = {}, c = this.currentCalendarOptionsInput, v = this.currentCalendarOptionsRefined, y = !1;
    for (let g in f)
      this.optionsForRefining.indexOf(g) === -1 && (f[g] === c[g] || I[g] && g in c && I[g](c[g], f[g])) ? p[g] = v[g] : u[g] ? (p[g] = u[g](f[g]), y = !0) : d[g] = c[g];
    return y && (this.currentCalendarOptionsInput = f, this.currentCalendarOptionsRefined = p, this.stableOptionOverrides = e, this.stableDynamicOptionOverrides = n), this.optionsForHandling.push(...this.optionsForRefining), this.optionsForRefining = [], {
      rawOptions: this.currentCalendarOptionsInput,
      refinedOptions: this.currentCalendarOptionsRefined,
      pluginHooks: o,
      availableLocaleData: a,
      localeDefaults: l,
      extra: d
    };
  }
  _computeCurrentViewData(e, n, r, s) {
    let a = n.viewSpecs[e];
    if (!a)
      throw new Error(`viewType "${e}" is not available. Please make sure you've loaded all neccessary plugins`);
    let { refinedOptions: i, extra: l } = this.processRawViewOptions(a, n.pluginHooks, n.localeDefaults, r, s);
    le(l);
    let o = this.buildDateProfileGenerator({
      dateProfileGeneratorClass: a.optionDefaults.dateProfileGeneratorClass,
      duration: a.duration,
      durationUnit: a.durationUnit,
      usesMinMaxTime: a.optionDefaults.usesMinMaxTime,
      dateEnv: n.dateEnv,
      calendarApi: this.props.calendarApi,
      slotMinTime: i.slotMinTime,
      slotMaxTime: i.slotMaxTime,
      showNonCurrentDates: i.showNonCurrentDates,
      dayCount: i.dayCount,
      dateAlignment: i.dateAlignment,
      dateIncrement: i.dateIncrement,
      hiddenDays: i.hiddenDays,
      weekends: i.weekends,
      nowInput: i.now,
      validRangeInput: i.validRange,
      visibleRangeInput: i.visibleRange,
      fixedWeekCount: i.fixedWeekCount
    }), u = this.buildViewApi(e, this.getCurrentData, n.dateEnv);
    return { viewSpec: a, options: i, dateProfileGenerator: o, viewApi: u };
  }
  processRawViewOptions(e, n, r, s, a) {
    let i = j([
      A,
      e.optionDefaults,
      r,
      s,
      e.optionOverrides,
      a
    ]), l = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, Y), J), K), xe), n.listenerRefiners), n.optionRefiners), o = {}, u = this.currentViewOptionsInput, d = this.currentViewOptionsRefined, f = !1, p = {};
    for (let c in i)
      i[c] === u[c] || I[c] && I[c](i[c], u[c]) ? o[c] = d[c] : (i[c] === this.currentCalendarOptionsInput[c] || I[c] && I[c](i[c], this.currentCalendarOptionsInput[c]) ? c in this.currentCalendarOptionsRefined && (o[c] = this.currentCalendarOptionsRefined[c]) : l[c] ? o[c] = l[c](i[c]) : p[c] = i[c], f = !0);
    return f && (this.currentViewOptionsInput = i, this.currentViewOptionsRefined = o), {
      rawOptions: this.currentViewOptionsInput,
      refinedOptions: this.currentViewOptionsRefined,
      extra: p
    };
  }
}
function cn(t, e, n, r, s, a, i, l) {
  let o = ve(e || i.defaultCode, i.map);
  return new ze({
    calendarSystem: "gregory",
    timeZone: t,
    namedTimeZoneImpl: a.namedTimeZonedImpl,
    locale: o,
    weekNumberCalculation: n,
    firstDay: r,
    weekText: s,
    cmdFormatter: a.cmdFormatter,
    defaultSeparator: l
  });
}
function dn(t, e) {
  let n = e.themeClasses[t.themeSystem] || O;
  return new n(t);
}
function fn(t) {
  let e = t.dateProfileGeneratorClass || qe;
  return new e(t);
}
function pn(t, e, n) {
  return new Gt(t, e, n);
}
function hn(t) {
  return z(t, (e) => e.ui);
}
function gn(t, e, n) {
  let r = { "": e };
  for (let s in t) {
    let a = t[s];
    a.sourceId && n[a.sourceId] && (r[s] = n[a.sourceId]);
  }
  return r;
}
function mn(t) {
  let { options: e } = t;
  return {
    eventUiSingleBase: X({
      display: e.eventDisplay,
      editable: e.editable,
      startEditable: e.eventStartEditable,
      durationEditable: e.eventDurationEditable,
      constraint: e.eventConstraint,
      overlap: typeof e.eventOverlap == "boolean" ? e.eventOverlap : void 0,
      allow: e.eventAllow,
      backgroundColor: e.eventBackgroundColor,
      borderColor: e.eventBorderColor,
      textColor: e.eventTextColor,
      color: e.eventColor
      // classNames: options.eventClassNames // render hook will handle this
    }, t),
    selectionConfig: X({
      constraint: e.selectConstraint,
      overlap: typeof e.selectOverlap == "boolean" ? e.selectOverlap : void 0,
      allow: e.selectAllow
    }, t)
  };
}
function L(t, e) {
  for (let n of e.pluginHooks.isLoadingFuncs)
    if (n(t))
      return !0;
  return !1;
}
function vn(t) {
  return Ze(t.options.businessHours, t);
}
function le(t, e) {
  for (let n in t)
    console.warn(`Unknown option '${n}'` + (e ? ` for view '${e}'` : ""));
}
class bn extends H {
  render() {
    let e = this.props.widgetGroups.map((n) => this.renderWidgetGroup(n));
    return m("div", { className: "fc-toolbar-chunk" }, ...e);
  }
  renderWidgetGroup(e) {
    let { props: n } = this, { theme: r } = this.context, s = [], a = !0;
    for (let i of e) {
      let { buttonName: l, buttonClick: o, buttonText: u, buttonIcon: d, buttonHint: f } = i;
      if (l === "title")
        a = !1, s.push(m("h2", { className: "fc-toolbar-title", id: n.titleId }, n.title));
      else {
        let p = l === n.activeButton, c = !n.isTodayEnabled && l === "today" || !n.isPrevEnabled && l === "prev" || !n.isNextEnabled && l === "next", v = [`fc-${l}-button`, r.getClass("button")];
        p && v.push(r.getClass("buttonActive")), s.push(m("button", { type: "button", title: typeof f == "function" ? f(n.navUnit) : f, disabled: c, "aria-pressed": p, className: v.join(" "), onClick: o }, u || (d ? m("span", { className: d, role: "img" }) : "")));
      }
    }
    if (s.length > 1) {
      let i = a && r.getClass("buttonGroup") || "";
      return m("div", { className: i }, ...s);
    }
    return s[0];
  }
}
class oe extends H {
  render() {
    let { model: e, extraClassName: n } = this.props, r = !1, s, a, i = e.sectionWidgets, l = i.center;
    return i.left ? (r = !0, s = i.left) : s = i.start, i.right ? (r = !0, a = i.right) : a = i.end, m(
      "div",
      { className: [
        n || "",
        "fc-toolbar",
        r ? "fc-toolbar-ltr" : ""
      ].join(" ") },
      this.renderSection("start", s || []),
      this.renderSection("center", l || []),
      this.renderSection("end", a || [])
    );
  }
  renderSection(e, n) {
    let { props: r } = this;
    return m(bn, { key: e, widgetGroups: n, title: r.title, navUnit: r.navUnit, activeButton: r.activeButton, isTodayEnabled: r.isTodayEnabled, isPrevEnabled: r.isPrevEnabled, isNextEnabled: r.isNextEnabled, titleId: r.titleId });
  }
}
class En extends H {
  constructor() {
    super(...arguments), this.state = {
      availableWidth: null
    }, this.handleEl = (e) => {
      this.el = e, st(this.props.elRef, e), this.updateAvailableWidth();
    }, this.handleResize = () => {
      this.updateAvailableWidth();
    };
  }
  render() {
    let { props: e, state: n } = this, { aspectRatio: r } = e, s = [
      "fc-view-harness",
      r || e.liquid || e.height ? "fc-view-harness-active" : "fc-view-harness-passive"
      // let the view do the height
    ], a = "", i = "";
    return r ? n.availableWidth !== null ? a = n.availableWidth / r : i = `${1 / r * 100}%` : a = e.height || "", m("div", { "aria-labelledby": e.labeledById, ref: this.handleEl, className: s.join(" "), style: { height: a, paddingBottom: i } }, e.children);
  }
  componentDidMount() {
    this.context.addResizeHandler(this.handleResize);
  }
  componentWillUnmount() {
    this.context.removeResizeHandler(this.handleResize);
  }
  updateAvailableWidth() {
    this.el && // needed. but why?
    this.props.aspectRatio && this.setState({ availableWidth: this.el.offsetWidth });
  }
}
class Rn extends pe {
  constructor(e) {
    super(e), this.handleSegClick = (n, r) => {
      let { component: s } = this, { context: a } = s, i = U(r);
      if (i && // might be the <div> surrounding the more link
      s.isValidSegDownEl(n.target)) {
        let l = lt(n.target, ".fc-event-forced-url"), o = l ? l.querySelector("a[href]").href : "";
        a.emitter.trigger("eventClick", {
          el: r,
          event: new he(s.context, i.eventRange.def, i.eventRange.instance),
          jsEvent: n,
          view: a.viewApi
        }), o && !n.defaultPrevented && (window.location.href = o);
      }
    }, this.destroy = ot(
      e.el,
      "click",
      ".fc-event",
      // on both fg and bg events
      this.handleSegClick
    );
  }
}
class Tn extends pe {
  constructor(e) {
    super(e), this.handleEventElRemove = (n) => {
      n === this.currentSegEl && this.handleSegLeave(null, this.currentSegEl);
    }, this.handleSegEnter = (n, r) => {
      U(r) && (this.currentSegEl = r, this.triggerEvent("eventMouseEnter", n, r));
    }, this.handleSegLeave = (n, r) => {
      this.currentSegEl && (this.currentSegEl = null, this.triggerEvent("eventMouseLeave", n, r));
    }, this.removeHoverListeners = ut(
      e.el,
      ".fc-event",
      // on both fg and bg events
      this.handleSegEnter,
      this.handleSegLeave
    );
  }
  destroy() {
    this.removeHoverListeners();
  }
  triggerEvent(e, n, r) {
    let { component: s } = this, { context: a } = s, i = U(r);
    (!n || s.isValidSegDownEl(n.target)) && a.emitter.trigger(e, {
      el: r,
      event: new he(a, i.eventRange.def, i.eventRange.instance),
      jsEvent: n,
      view: a.viewApi
    });
  }
}
class wn extends ke {
  constructor() {
    super(...arguments), this.buildViewContext = E($e), this.buildViewPropTransformers = E(Cn), this.buildToolbarProps = E(Sn), this.headerRef = te(), this.footerRef = te(), this.interactionsStore = {}, this.state = {
      viewLabelId: Ye()
    }, this.registerInteractiveComponent = (e, n) => {
      let r = Je(e, n), i = [
        Rn,
        Tn
      ].concat(this.props.pluginHooks.componentInteractions).map((l) => new l(r));
      this.interactionsStore[e.uid] = i, Q[e.uid] = r;
    }, this.unregisterInteractiveComponent = (e) => {
      let n = this.interactionsStore[e.uid];
      if (n) {
        for (let r of n)
          r.destroy();
        delete this.interactionsStore[e.uid];
      }
      delete Q[e.uid];
    }, this.resizeRunner = new G(() => {
      this.props.emitter.trigger("_resize", !0), this.props.emitter.trigger("windowResize", { view: this.props.viewApi });
    }), this.handleWindowResize = (e) => {
      let { options: n } = this.props;
      n.handleWindowResize && e.target === window && this.resizeRunner.request(n.windowResizeDelay);
    };
  }
  /*
  renders INSIDE of an outer div
  */
  render() {
    let { props: e } = this, { toolbarConfig: n, options: r } = e, s = this.buildToolbarProps(
      e.viewSpec,
      e.dateProfile,
      e.dateProfileGenerator,
      e.currentDate,
      Ke(e.options.now, e.dateEnv),
      // TODO: use NowTimer????
      e.viewTitle
    ), a = !1, i = "", l;
    e.isHeightAuto || e.forPrint ? i = "" : r.height != null ? a = !0 : r.contentHeight != null ? i = r.contentHeight : l = Math.max(r.aspectRatio, 0.5);
    let o = this.buildViewContext(e.viewSpec, e.viewApi, e.options, e.dateProfileGenerator, e.dateEnv, e.theme, e.pluginHooks, e.dispatch, e.getCurrentData, e.emitter, e.calendarApi, this.registerInteractiveComponent, this.unregisterInteractiveComponent), u = n.header && n.header.hasTitle ? this.state.viewLabelId : "";
    return m(
      fe.Provider,
      { value: o },
      n.header && m(oe, Object.assign({ ref: this.headerRef, extraClassName: "fc-header-toolbar", model: n.header, titleId: u }, s)),
      m(
        En,
        { liquid: a, height: i, aspectRatio: l, labeledById: u },
        this.renderView(e),
        this.buildAppendContent()
      ),
      n.footer && m(oe, Object.assign({ ref: this.footerRef, extraClassName: "fc-footer-toolbar", model: n.footer, titleId: "" }, s))
    );
  }
  componentDidMount() {
    let { props: e } = this;
    this.calendarInteractions = e.pluginHooks.calendarInteractions.map((r) => new r(e)), window.addEventListener("resize", this.handleWindowResize);
    let { propSetHandlers: n } = e.pluginHooks;
    for (let r in n)
      n[r](e[r], e);
  }
  componentDidUpdate(e) {
    let { props: n } = this, { propSetHandlers: r } = n.pluginHooks;
    for (let s in r)
      n[s] !== e[s] && r[s](n[s], n);
  }
  componentWillUnmount() {
    window.removeEventListener("resize", this.handleWindowResize), this.resizeRunner.clear();
    for (let e of this.calendarInteractions)
      e.destroy();
    this.props.emitter.trigger("_unmount");
  }
  buildAppendContent() {
    let { props: e } = this, n = e.pluginHooks.viewContainerAppends.map((r) => r(e));
    return m(ct, {}, ...n);
  }
  renderView(e) {
    let { pluginHooks: n } = e, { viewSpec: r } = e, s = {
      dateProfile: e.dateProfile,
      businessHours: e.businessHours,
      eventStore: e.renderableEventStore,
      eventUiBases: e.eventUiBases,
      dateSelection: e.dateSelection,
      eventSelection: e.eventSelection,
      eventDrag: e.eventDrag,
      eventResize: e.eventResize,
      isHeightAuto: e.isHeightAuto,
      forPrint: e.forPrint
    }, a = this.buildViewPropTransformers(n.viewPropsTransformers);
    for (let l of a)
      Object.assign(s, l.transform(s, e));
    let i = r.component;
    return m(i, Object.assign({}, s));
  }
}
function Sn(t, e, n, r, s, a) {
  let i = n.build(s, void 0, !1), l = n.buildPrev(e, r, !1), o = n.buildNext(e, r, !1);
  return {
    title: a,
    activeButton: t.type,
    navUnit: t.singleUnit,
    isTodayEnabled: i.isValid && !F(e.currentRange, s),
    isPrevEnabled: l.isValid,
    isNextEnabled: o.isValid
  };
}
function Cn(t) {
  return t.map((e) => new e());
}
class In extends Ce {
  constructor(e, n = {}) {
    super(), this.isRendering = !1, this.isRendered = !1, this.currentClassNames = [], this.customContentRenderId = 0, this.handleAction = (r) => {
      switch (r.type) {
        case "SET_EVENT_DRAG":
        case "SET_EVENT_RESIZE":
          this.renderRunner.tryDrain();
      }
    }, this.handleData = (r) => {
      this.currentData = r, this.renderRunner.request(r.calendarOptions.rerenderDelay);
    }, this.handleRenderRequest = () => {
      if (this.isRendering) {
        this.isRendered = !0;
        let { currentData: r } = this;
        Z(() => {
          ee(m(Ne, { options: r.calendarOptions, theme: r.theme, emitter: r.emitter }, (s, a, i, l) => (this.setClassNames(s), this.setHeight(a), m(
            He.Provider,
            { value: this.customContentRenderId },
            m(wn, Object.assign({ isHeightAuto: i, forPrint: l }, r))
          ))), this.el);
        });
      } else
        this.isRendered && (this.isRendered = !1, ee(null, this.el), this.setClassNames([]), this.setHeight(""));
    }, Oe(e), this.el = e, this.renderRunner = new G(this.handleRenderRequest), new un({
      optionOverrides: n,
      calendarApi: this,
      onAction: this.handleAction,
      onData: this.handleData
    });
  }
  render() {
    let e = this.isRendering;
    e ? this.customContentRenderId += 1 : this.isRendering = !0, this.renderRunner.request(), e && this.updateSize();
  }
  destroy() {
    this.isRendering && (this.isRendering = !1, this.renderRunner.request());
  }
  updateSize() {
    Z(() => {
      super.updateSize();
    });
  }
  batchRendering(e) {
    this.renderRunner.pause("batchRendering"), e(), this.renderRunner.resume("batchRendering");
  }
  pauseRendering() {
    this.renderRunner.pause("pauseRendering");
  }
  resumeRendering() {
    this.renderRunner.resume("pauseRendering", !0);
  }
  resetOptions(e, n) {
    this.currentDataManager.resetOptions(e, n);
  }
  setClassNames(e) {
    if (!M(e, this.currentClassNames)) {
      let { classList: n } = this.el;
      for (let r of this.currentClassNames)
        n.remove(r);
      for (let r of e)
        n.add(r);
      this.currentClassNames = e;
    }
  }
  setHeight(e) {
    De(this.el, "height", e);
  }
}
export {
  In as Calendar,
  Vn as JsonRequestError,
  P as createPlugin,
  dt as globalLocales,
  sn as globalPlugins
};
