UNPKG

drizzle-cube

Version:

Drizzle ORM-first semantic layer with Cube.js compatibility. Type-safe analytics and dashboards with SQL injection protection.

10,620 lines 358 kB
import * as te from "react";
import ie, { useContext as Rt, createContext as yn, useMemo as q, useState as J, useEffect as Ae, useCallback as Ve, useSyncExternalStore as Ts, useRef as be, useLayoutEffect as xn } from "react";
import { jsx as o, jsxs as N, Fragment as gn } from "react/jsx-runtime";
import { ResponsiveContainer as tt, Tooltip as lt, ComposedChart as Cr, CartesianGrid as Et, XAxis as Lt, YAxis as He, Legend as Qe, Bar as Ms, Cell as It, Line as ze, LineChart as Cs, Area as _s, PieChart as Ds, Pie as $s, ScatterChart as Os, Scatter as Rn, RadarChart as Rs, PolarGrid as Es, PolarAngleAxis as Ls, PolarRadiusAxis as Is, Radar as Ps, RadialBarChart as zs, RadialBar as js, Treemap as Vs, FunnelChart as Hs, Funnel as Us, LabelList as En, Sankey as Ys, SunburstChart as Bs } from "recharts";
import { d as Yt, a as Qs, b as Ln, c as In, e as qs, f as Ks, g as Ws, h as Pn, i as zn, j as Gs, k as bn, l as Xs, m as Zs, n as Js, o as ei, p as ti, q as ni, r as ri, s as si, t as ii, u as ai, v as oi, w as li, x as ci, y as ui, z as di, A as fi, B as hi, C as mi, D as pi, E as yi, F as xi, G as gi, H as bi, I as vi, J as wi, K as Ni, L as Si, M as Ai, N as ki, O as Fi, P as Ti, Q as Mi, R as Ci, S as _i, T as Di, U as $i, V as Oi, W as Ri, X as Ei, Y as Li, Z as Ii, _ as Pi, $ as zi, a0 as ji, a1 as Vi, a2 as Hi, a3 as Ui, a4 as Yi, a5 as Bi, a6 as Qi, a7 as qi, a8 as Ki, a9 as Wi, aa as Gi, ab as Xi, ac as Zi, ad as Ji, ae as bt } from "./icons-BiNaQlri.js";
var qe = class {
  constructor() {
    this.listeners = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this);
  }
  subscribe(e) {
    return this.listeners.add(e), this.onSubscribe(), () => {
      this.listeners.delete(e), this.onUnsubscribe();
    };
  }
  hasListeners() {
    return this.listeners.size > 0;
  }
  onSubscribe() {
  }
  onUnsubscribe() {
  }
}, ea = {
  // We need the wrapper function syntax below instead of direct references to
  // global setTimeout etc.
  //
  // BAD: `setTimeout: setTimeout`
  // GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`
  //
  // If we use direct references here, then anything that wants to spy on or
  // replace the global setTimeout (like tests) won't work since we'll already
  // have a hard reference to the original implementation at the time when this
  // file was imported.
  setTimeout: (e, t) => setTimeout(e, t),
  clearTimeout: (e) => clearTimeout(e),
  setInterval: (e, t) => setInterval(e, t),
  clearInterval: (e) => clearInterval(e)
}, ta = class {
  // We cannot have TimeoutManager<T> as we must instantiate it with a concrete
  // type at app boot; and if we leave that type, then any new timer provider
  // would need to support ReturnType<typeof setTimeout>, which is infeasible.
  //
  // We settle for type safety for the TimeoutProvider type, and accept that
  // this class is unsafe internally to allow for extension.
  #t = ea;
  #e = !1;
  setTimeoutProvider(e) {
    process.env.NODE_ENV !== "production" && this.#e && e !== this.#t && console.error(
      "[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",
      { previous: this.#t, provider: e }
    ), this.#t = e, process.env.NODE_ENV !== "production" && (this.#e = !1);
  }
  setTimeout(e, t) {
    return process.env.NODE_ENV !== "production" && (this.#e = !0), this.#t.setTimeout(e, t);
  }
  clearTimeout(e) {
    this.#t.clearTimeout(e);
  }
  setInterval(e, t) {
    return process.env.NODE_ENV !== "production" && (this.#e = !0), this.#t.setInterval(e, t);
  }
  clearInterval(e) {
    this.#t.clearInterval(e);
  }
}, Le = new ta();
function na(e) {
  setTimeout(e, 0);
}
var Ue = typeof window > "u" || "Deno" in globalThis;
function fe() {
}
function ra(e, t) {
  return typeof e == "function" ? e(t) : e;
}
function Jt(e) {
  return typeof e == "number" && e >= 0 && e !== 1 / 0;
}
function _r(e, t) {
  return Math.max(e + (t || 0) - Date.now(), 0);
}
function Oe(e, t) {
  return typeof e == "function" ? e(t) : e;
}
function we(e, t) {
  return typeof e == "function" ? e(t) : e;
}
function jn(e, t) {
  const {
    type: n = "all",
    exact: r,
    fetchStatus: s,
    predicate: i,
    queryKey: a,
    stale: l
  } = e;
  if (a) {
    if (r) {
      if (t.queryHash !== vn(a, t.options))
        return !1;
    } else if (!nt(t.queryKey, a))
      return !1;
  }
  if (n !== "all") {
    const u = t.isActive();
    if (n === "active" && !u || n === "inactive" && u)
      return !1;
  }
  return !(typeof l == "boolean" && t.isStale() !== l || s && s !== t.state.fetchStatus || i && !i(t));
}
function Vn(e, t) {
  const { exact: n, status: r, predicate: s, mutationKey: i } = e;
  if (i) {
    if (!t.options.mutationKey)
      return !1;
    if (n) {
      if (Ye(t.options.mutationKey) !== Ye(i))
        return !1;
    } else if (!nt(t.options.mutationKey, i))
      return !1;
  }
  return !(r && t.state.status !== r || s && !s(t));
}
function vn(e, t) {
  return (t?.queryKeyHashFn || Ye)(e);
}
function Ye(e) {
  return JSON.stringify(
    e,
    (t, n) => en(n) ? Object.keys(n).sort().reduce((r, s) => (r[s] = n[s], r), {}) : n
  );
}
function nt(e, t) {
  return e === t ? !0 : typeof e != typeof t ? !1 : e && t && typeof e == "object" && typeof t == "object" ? Object.keys(t).every((n) => nt(e[n], t[n])) : !1;
}
var sa = Object.prototype.hasOwnProperty;
function vt(e, t) {
  if (e === t)
    return e;
  const n = Hn(e) && Hn(t);
  if (!n && !(en(e) && en(t))) return t;
  const s = (n ? e : Object.keys(e)).length, i = n ? t : Object.keys(t), a = i.length, l = n ? new Array(a) : {};
  let u = 0;
  for (let c = 0; c < a; c++) {
    const d = n ? c : i[c], h = e[d], p = t[d];
    if (h === p) {
      l[d] = h, (n ? c < s : sa.call(e, d)) && u++;
      continue;
    }
    if (h === null || p === null || typeof h != "object" || typeof p != "object") {
      l[d] = p;
      continue;
    }
    const f = vt(h, p);
    l[d] = f, f === h && u++;
  }
  return s === a && u === s ? e : l;
}
function rt(e, t) {
  if (!t || Object.keys(e).length !== Object.keys(t).length)
    return !1;
  for (const n in e)
    if (e[n] !== t[n])
      return !1;
  return !0;
}
function Hn(e) {
  return Array.isArray(e) && e.length === Object.keys(e).length;
}
function en(e) {
  if (!Un(e))
    return !1;
  const t = e.constructor;
  if (t === void 0)
    return !0;
  const n = t.prototype;
  return !(!Un(n) || !n.hasOwnProperty("isPrototypeOf") || Object.getPrototypeOf(e) !== Object.prototype);
}
function Un(e) {
  return Object.prototype.toString.call(e) === "[object Object]";
}
function ia(e) {
  return new Promise((t) => {
    Le.setTimeout(t, e);
  });
}
function tn(e, t, n) {
  if (typeof n.structuralSharing == "function")
    return n.structuralSharing(e, t);
  if (n.structuralSharing !== !1) {
    if (process.env.NODE_ENV !== "production")
      try {
        return vt(e, t);
      } catch (r) {
        throw console.error(
          `Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${n.queryHash}]: ${r}`
        ), r;
      }
    return vt(e, t);
  }
  return t;
}
function aa(e, t, n = 0) {
  const r = [...e, t];
  return n && r.length > n ? r.slice(1) : r;
}
function oa(e, t, n = 0) {
  const r = [t, ...e];
  return n && r.length > n ? r.slice(0, -1) : r;
}
var wt = /* @__PURE__ */ Symbol();
function Dr(e, t) {
  return process.env.NODE_ENV !== "production" && e.queryFn === wt && console.error(
    `Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`
  ), !e.queryFn && t?.initialPromise ? () => t.initialPromise : !e.queryFn || e.queryFn === wt ? () => Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)) : e.queryFn;
}
function wn(e, t) {
  return typeof e == "function" ? e(...t) : !!e;
}
function la(e, t, n) {
  let r = !1, s;
  return Object.defineProperty(e, "signal", {
    enumerable: !0,
    get: () => (s ??= t(), r || (r = !0, s.aborted ? n() : s.addEventListener("abort", n, { once: !0 })), s)
  }), e;
}
var ca = class extends qe {
  #t;
  #e;
  #n;
  constructor() {
    super(), this.#n = (e) => {
      if (!Ue && window.addEventListener) {
        const t = () => e();
        return window.addEventListener("visibilitychange", t, !1), () => {
          window.removeEventListener("visibilitychange", t);
        };
      }
    };
  }
  onSubscribe() {
    this.#e || this.setEventListener(this.#n);
  }
  onUnsubscribe() {
    this.hasListeners() || (this.#e?.(), this.#e = void 0);
  }
  setEventListener(e) {
    this.#n = e, this.#e?.(), this.#e = e((t) => {
      typeof t == "boolean" ? this.setFocused(t) : this.onFocus();
    });
  }
  setFocused(e) {
    this.#t !== e && (this.#t = e, this.onFocus());
  }
  onFocus() {
    const e = this.isFocused();
    this.listeners.forEach((t) => {
      t(e);
    });
  }
  isFocused() {
    return typeof this.#t == "boolean" ? this.#t : globalThis.document?.visibilityState !== "hidden";
  }
}, Nn = new ca();
function nn() {
  let e, t;
  const n = new Promise((s, i) => {
    e = s, t = i;
  });
  n.status = "pending", n.catch(() => {
  });
  function r(s) {
    Object.assign(n, s), delete n.resolve, delete n.reject;
  }
  return n.resolve = (s) => {
    r({
      status: "fulfilled",
      value: s
    }), e(s);
  }, n.reject = (s) => {
    r({
      status: "rejected",
      reason: s
    }), t(s);
  }, n;
}
var ua = na;
function da() {
  let e = [], t = 0, n = (l) => {
    l();
  }, r = (l) => {
    l();
  }, s = ua;
  const i = (l) => {
    t ? e.push(l) : s(() => {
      n(l);
    });
  }, a = () => {
    const l = e;
    e = [], l.length && s(() => {
      r(() => {
        l.forEach((u) => {
          n(u);
        });
      });
    });
  };
  return {
    batch: (l) => {
      let u;
      t++;
      try {
        u = l();
      } finally {
        t--, t || a();
      }
      return u;
    },
    /**
     * All calls to the wrapped function will be batched.
     */
    batchCalls: (l) => (...u) => {
      i(() => {
        l(...u);
      });
    },
    schedule: i,
    /**
     * Use this method to set a custom notify function.
     * This can be used to for example wrap notifications with `React.act` while running tests.
     */
    setNotifyFunction: (l) => {
      n = l;
    },
    /**
     * Use this method to set a custom function to batch notifications together into a single tick.
     * By default React Query will use the batch function provided by ReactDOM or React Native.
     */
    setBatchNotifyFunction: (l) => {
      r = l;
    },
    setScheduler: (l) => {
      s = l;
    }
  };
}
var ee = da(), fa = class extends qe {
  #t = !0;
  #e;
  #n;
  constructor() {
    super(), this.#n = (e) => {
      if (!Ue && window.addEventListener) {
        const t = () => e(!0), n = () => e(!1);
        return window.addEventListener("online", t, !1), window.addEventListener("offline", n, !1), () => {
          window.removeEventListener("online", t), window.removeEventListener("offline", n);
        };
      }
    };
  }
  onSubscribe() {
    this.#e || this.setEventListener(this.#n);
  }
  onUnsubscribe() {
    this.hasListeners() || (this.#e?.(), this.#e = void 0);
  }
  setEventListener(e) {
    this.#n = e, this.#e?.(), this.#e = e(this.setOnline.bind(this));
  }
  setOnline(e) {
    this.#t !== e && (this.#t = e, this.listeners.forEach((n) => {
      n(e);
    }));
  }
  isOnline() {
    return this.#t;
  }
}, Nt = new fa();
function ha(e) {
  return Math.min(1e3 * 2 ** e, 3e4);
}
function $r(e) {
  return (e ?? "online") === "online" ? Nt.isOnline() : !0;
}
var rn = class extends Error {
  constructor(e) {
    super("CancelledError"), this.revert = e?.revert, this.silent = e?.silent;
  }
};
function Or(e) {
  let t = !1, n = 0, r;
  const s = nn(), i = () => s.status !== "pending", a = (m) => {
    if (!i()) {
      const x = new rn(m);
      p(x), e.onCancel?.(x);
    }
  }, l = () => {
    t = !0;
  }, u = () => {
    t = !1;
  }, c = () => Nn.isFocused() && (e.networkMode === "always" || Nt.isOnline()) && e.canRun(), d = () => $r(e.networkMode) && e.canRun(), h = (m) => {
    i() || (r?.(), s.resolve(m));
  }, p = (m) => {
    i() || (r?.(), s.reject(m));
  }, f = () => new Promise((m) => {
    r = (x) => {
      (i() || c()) && m(x);
    }, e.onPause?.();
  }).then(() => {
    r = void 0, i() || e.onContinue?.();
  }), b = () => {
    if (i())
      return;
    let m;
    const x = n === 0 ? e.initialPromise : void 0;
    try {
      m = x ?? e.fn();
    } catch (y) {
      m = Promise.reject(y);
    }
    Promise.resolve(m).then(h).catch((y) => {
      if (i())
        return;
      const g = e.retry ?? (Ue ? 0 : 3), k = e.retryDelay ?? ha, w = typeof k == "function" ? k(n, y) : k, S = g === !0 || typeof g == "number" && n < g || typeof g == "function" && g(n, y);
      if (t || !S) {
        p(y);
        return;
      }
      n++, e.onFail?.(n, y), ia(w).then(() => c() ? void 0 : f()).then(() => {
        t ? p(y) : b();
      });
    });
  };
  return {
    promise: s,
    status: () => s.status,
    cancel: a,
    continue: () => (r?.(), s),
    cancelRetry: l,
    continueRetry: u,
    canStart: d,
    start: () => (d() ? b() : f().then(b), s)
  };
}
var Rr = class {
  #t;
  destroy() {
    this.clearGcTimeout();
  }
  scheduleGc() {
    this.clearGcTimeout(), Jt(this.gcTime) && (this.#t = Le.setTimeout(() => {
      this.optionalRemove();
    }, this.gcTime));
  }
  updateGcTime(e) {
    this.gcTime = Math.max(
      this.gcTime || 0,
      e ?? (Ue ? 1 / 0 : 300 * 1e3)
    );
  }
  clearGcTimeout() {
    this.#t && (Le.clearTimeout(this.#t), this.#t = void 0);
  }
}, ma = class extends Rr {
  #t;
  #e;
  #n;
  #s;
  #r;
  #i;
  #o;
  constructor(e) {
    super(), this.#o = !1, this.#i = e.defaultOptions, this.setOptions(e.options), this.observers = [], this.#s = e.client, this.#n = this.#s.getQueryCache(), this.queryKey = e.queryKey, this.queryHash = e.queryHash, this.#t = Bn(this.options), this.state = e.state ?? this.#t, this.scheduleGc();
  }
  get meta() {
    return this.options.meta;
  }
  get promise() {
    return this.#r?.promise;
  }
  setOptions(e) {
    if (this.options = { ...this.#i, ...e }, this.updateGcTime(this.options.gcTime), this.state && this.state.data === void 0) {
      const t = Bn(this.options);
      t.data !== void 0 && (this.setState(
        Yn(t.data, t.dataUpdatedAt)
      ), this.#t = t);
    }
  }
  optionalRemove() {
    !this.observers.length && this.state.fetchStatus === "idle" && this.#n.remove(this);
  }
  setData(e, t) {
    const n = tn(this.state.data, e, this.options);
    return this.#a({
      data: n,
      type: "success",
      dataUpdatedAt: t?.updatedAt,
      manual: t?.manual
    }), n;
  }
  setState(e, t) {
    this.#a({ type: "setState", state: e, setStateOptions: t });
  }
  cancel(e) {
    const t = this.#r?.promise;
    return this.#r?.cancel(e), t ? t.then(fe).catch(fe) : Promise.resolve();
  }
  destroy() {
    super.destroy(), this.cancel({ silent: !0 });
  }
  reset() {
    this.destroy(), this.setState(this.#t);
  }
  isActive() {
    return this.observers.some(
      (e) => we(e.options.enabled, this) !== !1
    );
  }
  isDisabled() {
    return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn === wt || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
  }
  isStatic() {
    return this.getObserversCount() > 0 ? this.observers.some(
      (e) => Oe(e.options.staleTime, this) === "static"
    ) : !1;
  }
  isStale() {
    return this.getObserversCount() > 0 ? this.observers.some(
      (e) => e.getCurrentResult().isStale
    ) : this.state.data === void 0 || this.state.isInvalidated;
  }
  isStaleByTime(e = 0) {
    return this.state.data === void 0 ? !0 : e === "static" ? !1 : this.state.isInvalidated ? !0 : !_r(this.state.dataUpdatedAt, e);
  }
  onFocus() {
    this.observers.find((t) => t.shouldFetchOnWindowFocus())?.refetch({ cancelRefetch: !1 }), this.#r?.continue();
  }
  onOnline() {
    this.observers.find((t) => t.shouldFetchOnReconnect())?.refetch({ cancelRefetch: !1 }), this.#r?.continue();
  }
  addObserver(e) {
    this.observers.includes(e) || (this.observers.push(e), this.clearGcTimeout(), this.#n.notify({ type: "observerAdded", query: this, observer: e }));
  }
  removeObserver(e) {
    this.observers.includes(e) && (this.observers = this.observers.filter((t) => t !== e), this.observers.length || (this.#r && (this.#o ? this.#r.cancel({ revert: !0 }) : this.#r.cancelRetry()), this.scheduleGc()), this.#n.notify({ type: "observerRemoved", query: this, observer: e }));
  }
  getObserversCount() {
    return this.observers.length;
  }
  invalidate() {
    this.state.isInvalidated || this.#a({ type: "invalidate" });
  }
  async fetch(e, t) {
    if (this.state.fetchStatus !== "idle" && // If the promise in the retyer is already rejected, we have to definitely
    // re-start the fetch; there is a chance that the query is still in a
    // pending state when that happens
    this.#r?.status() !== "rejected") {
      if (this.state.data !== void 0 && t?.cancelRefetch)
        this.cancel({ silent: !0 });
      else if (this.#r)
        return this.#r.continueRetry(), this.#r.promise;
    }
    if (e && this.setOptions(e), !this.options.queryFn) {
      const l = this.observers.find((u) => u.options.queryFn);
      l && this.setOptions(l.options);
    }
    process.env.NODE_ENV !== "production" && (Array.isArray(this.options.queryKey) || console.error(
      "As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"
    ));
    const n = new AbortController(), r = (l) => {
      Object.defineProperty(l, "signal", {
        enumerable: !0,
        get: () => (this.#o = !0, n.signal)
      });
    }, s = () => {
      const l = Dr(this.options, t), c = (() => {
        const d = {
          client: this.#s,
          queryKey: this.queryKey,
          meta: this.meta
        };
        return r(d), d;
      })();
      return this.#o = !1, this.options.persister ? this.options.persister(
        l,
        c,
        this
      ) : l(c);
    }, a = (() => {
      const l = {
        fetchOptions: t,
        options: this.options,
        queryKey: this.queryKey,
        client: this.#s,
        state: this.state,
        fetchFn: s
      };
      return r(l), l;
    })();
    this.options.behavior?.onFetch(a, this), this.#e = this.state, (this.state.fetchStatus === "idle" || this.state.fetchMeta !== a.fetchOptions?.meta) && this.#a({ type: "fetch", meta: a.fetchOptions?.meta }), this.#r = Or({
      initialPromise: t?.initialPromise,
      fn: a.fetchFn,
      onCancel: (l) => {
        l instanceof rn && l.revert && this.setState({
          ...this.#e,
          fetchStatus: "idle"
        }), n.abort();
      },
      onFail: (l, u) => {
        this.#a({ type: "failed", failureCount: l, error: u });
      },
      onPause: () => {
        this.#a({ type: "pause" });
      },
      onContinue: () => {
        this.#a({ type: "continue" });
      },
      retry: a.options.retry,
      retryDelay: a.options.retryDelay,
      networkMode: a.options.networkMode,
      canRun: () => !0
    });
    try {
      const l = await this.#r.start();
      if (l === void 0)
        throw process.env.NODE_ENV !== "production" && console.error(
          `Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`
        ), new Error(`${this.queryHash} data is undefined`);
      return this.setData(l), this.#n.config.onSuccess?.(l, this), this.#n.config.onSettled?.(
        l,
        this.state.error,
        this
      ), l;
    } catch (l) {
      if (l instanceof rn) {
        if (l.silent)
          return this.#r.promise;
        if (l.revert) {
          if (this.state.data === void 0)
            throw l;
          return this.state.data;
        }
      }
      throw this.#a({
        type: "error",
        error: l
      }), this.#n.config.onError?.(
        l,
        this
      ), this.#n.config.onSettled?.(
        this.state.data,
        l,
        this
      ), l;
    } finally {
      this.scheduleGc();
    }
  }
  #a(e) {
    const t = (n) => {
      switch (e.type) {
        case "failed":
          return {
            ...n,
            fetchFailureCount: e.failureCount,
            fetchFailureReason: e.error
          };
        case "pause":
          return {
            ...n,
            fetchStatus: "paused"
          };
        case "continue":
          return {
            ...n,
            fetchStatus: "fetching"
          };
        case "fetch":
          return {
            ...n,
            ...Er(n.data, this.options),
            fetchMeta: e.meta ?? null
          };
        case "success":
          const r = {
            ...n,
            ...Yn(e.data, e.dataUpdatedAt),
            dataUpdateCount: n.dataUpdateCount + 1,
            ...!e.manual && {
              fetchStatus: "idle",
              fetchFailureCount: 0,
              fetchFailureReason: null
            }
          };
          return this.#e = e.manual ? r : void 0, r;
        case "error":
          const s = e.error;
          return {
            ...n,
            error: s,
            errorUpdateCount: n.errorUpdateCount + 1,
            errorUpdatedAt: Date.now(),
            fetchFailureCount: n.fetchFailureCount + 1,
            fetchFailureReason: s,
            fetchStatus: "idle",
            status: "error",
            // flag existing data as invalidated if we get a background error
            // note that "no data" always means stale so we can set unconditionally here
            isInvalidated: !0
          };
        case "invalidate":
          return {
            ...n,
            isInvalidated: !0
          };
        case "setState":
          return {
            ...n,
            ...e.state
          };
      }
    };
    this.state = t(this.state), ee.batch(() => {
      this.observers.forEach((n) => {
        n.onQueryUpdate();
      }), this.#n.notify({ query: this, type: "updated", action: e });
    });
  }
};
function Er(e, t) {
  return {
    fetchFailureCount: 0,
    fetchFailureReason: null,
    fetchStatus: $r(t.networkMode) ? "fetching" : "paused",
    ...e === void 0 && {
      error: null,
      status: "pending"
    }
  };
}
function Yn(e, t) {
  return {
    data: e,
    dataUpdatedAt: t ?? Date.now(),
    error: null,
    isInvalidated: !1,
    status: "success"
  };
}
function Bn(e) {
  const t = typeof e.initialData == "function" ? e.initialData() : e.initialData, n = t !== void 0, r = n ? typeof e.initialDataUpdatedAt == "function" ? e.initialDataUpdatedAt() : e.initialDataUpdatedAt : 0;
  return {
    data: t,
    dataUpdateCount: 0,
    dataUpdatedAt: n ? r ?? Date.now() : 0,
    error: null,
    errorUpdateCount: 0,
    errorUpdatedAt: 0,
    fetchFailureCount: 0,
    fetchFailureReason: null,
    fetchMeta: null,
    isInvalidated: !1,
    status: n ? "success" : "pending",
    fetchStatus: "idle"
  };
}
var Sn = class extends qe {
  constructor(e, t) {
    super(), this.options = t, this.#t = e, this.#a = null, this.#o = nn(), this.bindMethods(), this.setOptions(t);
  }
  #t;
  #e = void 0;
  #n = void 0;
  #s = void 0;
  #r;
  #i;
  #o;
  #a;
  #h;
  #d;
  // This property keeps track of the last query with defined data.
  // It will be used to pass the previous data and query to the placeholder function between renders.
  #f;
  #c;
  #u;
  #l;
  #p = /* @__PURE__ */ new Set();
  bindMethods() {
    this.refetch = this.refetch.bind(this);
  }
  onSubscribe() {
    this.listeners.size === 1 && (this.#e.addObserver(this), Qn(this.#e, this.options) ? this.#m() : this.updateResult(), this.#b());
  }
  onUnsubscribe() {
    this.hasListeners() || this.destroy();
  }
  shouldFetchOnReconnect() {
    return sn(
      this.#e,
      this.options,
      this.options.refetchOnReconnect
    );
  }
  shouldFetchOnWindowFocus() {
    return sn(
      this.#e,
      this.options,
      this.options.refetchOnWindowFocus
    );
  }
  destroy() {
    this.listeners = /* @__PURE__ */ new Set(), this.#v(), this.#w(), this.#e.removeObserver(this);
  }
  setOptions(e) {
    const t = this.options, n = this.#e;
    if (this.options = this.#t.defaultQueryOptions(e), this.options.enabled !== void 0 && typeof this.options.enabled != "boolean" && typeof this.options.enabled != "function" && typeof we(this.options.enabled, this.#e) != "boolean")
      throw new Error(
        "Expected enabled to be a boolean or a callback that returns a boolean"
      );
    this.#N(), this.#e.setOptions(this.options), t._defaulted && !rt(this.options, t) && this.#t.getQueryCache().notify({
      type: "observerOptionsUpdated",
      query: this.#e,
      observer: this
    });
    const r = this.hasListeners();
    r && qn(
      this.#e,
      n,
      this.options,
      t
    ) && this.#m(), this.updateResult(), r && (this.#e !== n || we(this.options.enabled, this.#e) !== we(t.enabled, this.#e) || Oe(this.options.staleTime, this.#e) !== Oe(t.staleTime, this.#e)) && this.#y();
    const s = this.#x();
    r && (this.#e !== n || we(this.options.enabled, this.#e) !== we(t.enabled, this.#e) || s !== this.#l) && this.#g(s);
  }
  getOptimisticResult(e) {
    const t = this.#t.getQueryCache().build(this.#t, e), n = this.createResult(t, e);
    return ya(this, n) && (this.#s = n, this.#i = this.options, this.#r = this.#e.state), n;
  }
  getCurrentResult() {
    return this.#s;
  }
  trackResult(e, t) {
    return new Proxy(e, {
      get: (n, r) => (this.trackProp(r), t?.(r), r === "promise" && (this.trackProp("data"), !this.options.experimental_prefetchInRender && this.#o.status === "pending" && this.#o.reject(
        new Error(
          "experimental_prefetchInRender feature flag is not enabled"
        )
      )), Reflect.get(n, r))
    });
  }
  trackProp(e) {
    this.#p.add(e);
  }
  getCurrentQuery() {
    return this.#e;
  }
  refetch({ ...e } = {}) {
    return this.fetch({
      ...e
    });
  }
  fetchOptimistic(e) {
    const t = this.#t.defaultQueryOptions(e), n = this.#t.getQueryCache().build(this.#t, t);
    return n.fetch().then(() => this.createResult(n, t));
  }
  fetch(e) {
    return this.#m({
      ...e,
      cancelRefetch: e.cancelRefetch ?? !0
    }).then(() => (this.updateResult(), this.#s));
  }
  #m(e) {
    this.#N();
    let t = this.#e.fetch(
      this.options,
      e
    );
    return e?.throwOnError || (t = t.catch(fe)), t;
  }
  #y() {
    this.#v();
    const e = Oe(
      this.options.staleTime,
      this.#e
    );
    if (Ue || this.#s.isStale || !Jt(e))
      return;
    const n = _r(this.#s.dataUpdatedAt, e) + 1;
    this.#c = Le.setTimeout(() => {
      this.#s.isStale || this.updateResult();
    }, n);
  }
  #x() {
    return (typeof this.options.refetchInterval == "function" ? this.options.refetchInterval(this.#e) : this.options.refetchInterval) ?? !1;
  }
  #g(e) {
    this.#w(), this.#l = e, !(Ue || we(this.options.enabled, this.#e) === !1 || !Jt(this.#l) || this.#l === 0) && (this.#u = Le.setInterval(() => {
      (this.options.refetchIntervalInBackground || Nn.isFocused()) && this.#m();
    }, this.#l));
  }
  #b() {
    this.#y(), this.#g(this.#x());
  }
  #v() {
    this.#c && (Le.clearTimeout(this.#c), this.#c = void 0);
  }
  #w() {
    this.#u && (Le.clearInterval(this.#u), this.#u = void 0);
  }
  createResult(e, t) {
    const n = this.#e, r = this.options, s = this.#s, i = this.#r, a = this.#i, u = e !== n ? e.state : this.#n, { state: c } = e;
    let d = { ...c }, h = !1, p;
    if (t._optimisticResults) {
      const M = this.hasListeners(), T = !M && Qn(e, t), A = M && qn(e, n, t, r);
      (T || A) && (d = {
        ...d,
        ...Er(c.data, e.options)
      }), t._optimisticResults === "isRestoring" && (d.fetchStatus = "idle");
    }
    let { error: f, errorUpdatedAt: b, status: m } = d;
    p = d.data;
    let x = !1;
    if (t.placeholderData !== void 0 && p === void 0 && m === "pending") {
      let M;
      s?.isPlaceholderData && t.placeholderData === a?.placeholderData ? (M = s.data, x = !0) : M = typeof t.placeholderData == "function" ? t.placeholderData(
        this.#f?.state.data,
        this.#f
      ) : t.placeholderData, M !== void 0 && (m = "success", p = tn(
        s?.data,
        M,
        t
      ), h = !0);
    }
    if (t.select && p !== void 0 && !x)
      if (s && p === i?.data && t.select === this.#h)
        p = this.#d;
      else
        try {
          this.#h = t.select, p = t.select(p), p = tn(s?.data, p, t), this.#d = p, this.#a = null;
        } catch (M) {
          this.#a = M;
        }
    this.#a && (f = this.#a, p = this.#d, b = Date.now(), m = "error");
    const y = d.fetchStatus === "fetching", g = m === "pending", k = m === "error", w = g && y, S = p !== void 0, F = {
      status: m,
      fetchStatus: d.fetchStatus,
      isPending: g,
      isSuccess: m === "success",
      isError: k,
      isInitialLoading: w,
      isLoading: w,
      data: p,
      dataUpdatedAt: d.dataUpdatedAt,
      error: f,
      errorUpdatedAt: b,
      failureCount: d.fetchFailureCount,
      failureReason: d.fetchFailureReason,
      errorUpdateCount: d.errorUpdateCount,
      isFetched: d.dataUpdateCount > 0 || d.errorUpdateCount > 0,
      isFetchedAfterMount: d.dataUpdateCount > u.dataUpdateCount || d.errorUpdateCount > u.errorUpdateCount,
      isFetching: y,
      isRefetching: y && !g,
      isLoadingError: k && !S,
      isPaused: d.fetchStatus === "paused",
      isPlaceholderData: h,
      isRefetchError: k && S,
      isStale: An(e, t),
      refetch: this.refetch,
      promise: this.#o,
      isEnabled: we(t.enabled, e) !== !1
    };
    if (this.options.experimental_prefetchInRender) {
      const M = (v) => {
        F.status === "error" ? v.reject(F.error) : F.data !== void 0 && v.resolve(F.data);
      }, T = () => {
        const v = this.#o = F.promise = nn();
        M(v);
      }, A = this.#o;
      switch (A.status) {
        case "pending":
          e.queryHash === n.queryHash && M(A);
          break;
        case "fulfilled":
          (F.status === "error" || F.data !== A.value) && T();
          break;
        case "rejected":
          (F.status !== "error" || F.error !== A.reason) && T();
          break;
      }
    }
    return F;
  }
  updateResult() {
    const e = this.#s, t = this.createResult(this.#e, this.options);
    if (this.#r = this.#e.state, this.#i = this.options, this.#r.data !== void 0 && (this.#f = this.#e), rt(t, e))
      return;
    this.#s = t;
    const n = () => {
      if (!e)
        return !0;
      const { notifyOnChangeProps: r } = this.options, s = typeof r == "function" ? r() : r;
      if (s === "all" || !s && !this.#p.size)
        return !0;
      const i = new Set(
        s ?? this.#p
      );
      return this.options.throwOnError && i.add("error"), Object.keys(this.#s).some((a) => {
        const l = a;
        return this.#s[l] !== e[l] && i.has(l);
      });
    };
    this.#S({ listeners: n() });
  }
  #N() {
    const e = this.#t.getQueryCache().build(this.#t, this.options);
    if (e === this.#e)
      return;
    const t = this.#e;
    this.#e = e, this.#n = e.state, this.hasListeners() && (t?.removeObserver(this), e.addObserver(this));
  }
  onQueryUpdate() {
    this.updateResult(), this.hasListeners() && this.#b();
  }
  #S(e) {
    ee.batch(() => {
      e.listeners && this.listeners.forEach((t) => {
        t(this.#s);
      }), this.#t.getQueryCache().notify({
        query: this.#e,
        type: "observerResultsUpdated"
      });
    });
  }
};
function pa(e, t) {
  return we(t.enabled, e) !== !1 && e.state.data === void 0 && !(e.state.status === "error" && t.retryOnMount === !1);
}
function Qn(e, t) {
  return pa(e, t) || e.state.data !== void 0 && sn(e, t, t.refetchOnMount);
}
function sn(e, t, n) {
  if (we(t.enabled, e) !== !1 && Oe(t.staleTime, e) !== "static") {
    const r = typeof n == "function" ? n(e) : n;
    return r === "always" || r !== !1 && An(e, t);
  }
  return !1;
}
function qn(e, t, n, r) {
  return (e !== t || we(r.enabled, e) === !1) && (!n.suspense || e.state.status !== "error") && An(e, n);
}
function An(e, t) {
  return we(t.enabled, e) !== !1 && e.isStaleByTime(Oe(t.staleTime, e));
}
function ya(e, t) {
  return !rt(e.getCurrentResult(), t);
}
function Kn(e) {
  return {
    onFetch: (t, n) => {
      const r = t.options, s = t.fetchOptions?.meta?.fetchMore?.direction, i = t.state.data?.pages || [], a = t.state.data?.pageParams || [];
      let l = { pages: [], pageParams: [] }, u = 0;
      const c = async () => {
        let d = !1;
        const h = (b) => {
          la(
            b,
            () => t.signal,
            () => d = !0
          );
        }, p = Dr(t.options, t.fetchOptions), f = async (b, m, x) => {
          if (d)
            return Promise.reject();
          if (m == null && b.pages.length)
            return Promise.resolve(b);
          const g = (() => {
            const C = {
              client: t.client,
              queryKey: t.queryKey,
              pageParam: m,
              direction: x ? "backward" : "forward",
              meta: t.options.meta
            };
            return h(C), C;
          })(), k = await p(g), { maxPages: w } = t.options, S = x ? oa : aa;
          return {
            pages: S(b.pages, k, w),
            pageParams: S(b.pageParams, m, w)
          };
        };
        if (s && i.length) {
          const b = s === "backward", m = b ? xa : Wn, x = {
            pages: i,
            pageParams: a
          }, y = m(r, x);
          l = await f(x, y, b);
        } else {
          const b = e ?? i.length;
          do {
            const m = u === 0 ? a[0] ?? r.initialPageParam : Wn(r, l);
            if (u > 0 && m == null)
              break;
            l = await f(l, m), u++;
          } while (u < b);
        }
        return l;
      };
      t.options.persister ? t.fetchFn = () => t.options.persister?.(
        c,
        {
          client: t.client,
          queryKey: t.queryKey,
          meta: t.options.meta,
          signal: t.signal
        },
        n
      ) : t.fetchFn = c;
    }
  };
}
function Wn(e, { pages: t, pageParams: n }) {
  const r = t.length - 1;
  return t.length > 0 ? e.getNextPageParam(
    t[r],
    t,
    n[r],
    n
  ) : void 0;
}
function xa(e, { pages: t, pageParams: n }) {
  return t.length > 0 ? e.getPreviousPageParam?.(t[0], t, n[0], n) : void 0;
}
var ga = class extends Rr {
  #t;
  #e;
  #n;
  #s;
  constructor(e) {
    super(), this.#t = e.client, this.mutationId = e.mutationId, this.#n = e.mutationCache, this.#e = [], this.state = e.state || Lr(), this.setOptions(e.options), this.scheduleGc();
  }
  setOptions(e) {
    this.options = e, this.updateGcTime(this.options.gcTime);
  }
  get meta() {
    return this.options.meta;
  }
  addObserver(e) {
    this.#e.includes(e) || (this.#e.push(e), this.clearGcTimeout(), this.#n.notify({
      type: "observerAdded",
      mutation: this,
      observer: e
    }));
  }
  removeObserver(e) {
    this.#e = this.#e.filter((t) => t !== e), this.scheduleGc(), this.#n.notify({
      type: "observerRemoved",
      mutation: this,
      observer: e
    });
  }
  optionalRemove() {
    this.#e.length || (this.state.status === "pending" ? this.scheduleGc() : this.#n.remove(this));
  }
  continue() {
    return this.#s?.continue() ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before
    this.execute(this.state.variables);
  }
  async execute(e) {
    const t = () => {
      this.#r({ type: "continue" });
    }, n = {
      client: this.#t,
      meta: this.options.meta,
      mutationKey: this.options.mutationKey
    };
    this.#s = Or({
      fn: () => this.options.mutationFn ? this.options.mutationFn(e, n) : Promise.reject(new Error("No mutationFn found")),
      onFail: (i, a) => {
        this.#r({ type: "failed", failureCount: i, error: a });
      },
      onPause: () => {
        this.#r({ type: "pause" });
      },
      onContinue: t,
      retry: this.options.retry ?? 0,
      retryDelay: this.options.retryDelay,
      networkMode: this.options.networkMode,
      canRun: () => this.#n.canRun(this)
    });
    const r = this.state.status === "pending", s = !this.#s.canStart();
    try {
      if (r)
        t();
      else {
        this.#r({ type: "pending", variables: e, isPaused: s }), await this.#n.config.onMutate?.(
          e,
          this,
          n
        );
        const a = await this.options.onMutate?.(
          e,
          n
        );
        a !== this.state.context && this.#r({
          type: "pending",
          context: a,
          variables: e,
          isPaused: s
        });
      }
      const i = await this.#s.start();
      return await this.#n.config.onSuccess?.(
        i,
        e,
        this.state.context,
        this,
        n
      ), await this.options.onSuccess?.(
        i,
        e,
        this.state.context,
        n
      ), await this.#n.config.onSettled?.(
        i,
        null,
        this.state.variables,
        this.state.context,
        this,
        n
      ), await this.options.onSettled?.(
        i,
        null,
        e,
        this.state.context,
        n
      ), this.#r({ type: "success", data: i }), i;
    } catch (i) {
      try {
        await this.#n.config.onError?.(
          i,
          e,
          this.state.context,
          this,
          n
        );
      } catch (a) {
        Promise.reject(a);
      }
      try {
        await this.options.onError?.(
          i,
          e,
          this.state.context,
          n
        );
      } catch (a) {
        Promise.reject(a);
      }
      try {
        await this.#n.config.onSettled?.(
          void 0,
          i,
          this.state.variables,
          this.state.context,
          this,
          n
        );
      } catch (a) {
        Promise.reject(a);
      }
      try {
        await this.options.onSettled?.(
          void 0,
          i,
          e,
          this.state.context,
          n
        );
      } catch (a) {
        Promise.reject(a);
      }
      throw this.#r({ type: "error", error: i }), i;
    } finally {
      this.#n.runNext(this);
    }
  }
  #r(e) {
    const t = (n) => {
      switch (e.type) {
        case "failed":
          return {
            ...n,
            failureCount: e.failureCount,
            failureReason: e.error
          };
        case "pause":
          return {
            ...n,
            isPaused: !0
          };
        case "continue":
          return {
            ...n,
            isPaused: !1
          };
        case "pending":
          return {
            ...n,
            context: e.context,
            data: void 0,
            failureCount: 0,
            failureReason: null,
            error: null,
            isPaused: e.isPaused,
            status: "pending",
            variables: e.variables,
            submittedAt: Date.now()
          };
        case "success":
          return {
            ...n,
            data: e.data,
            failureCount: 0,
            failureReason: null,
            error: null,
            status: "success",
            isPaused: !1
          };
        case "error":
          return {
            ...n,
            data: void 0,
            error: e.error,
            failureCount: n.failureCount + 1,
            failureReason: e.error,
            isPaused: !1,
            status: "error"
          };
      }
    };
    this.state = t(this.state), ee.batch(() => {
      this.#e.forEach((n) => {
        n.onMutationUpdate(e);
      }), this.#n.notify({
        mutation: this,
        type: "updated",
        action: e
      });
    });
  }
};
function Lr() {
  return {
    context: void 0,
    data: void 0,
    error: null,
    failureCount: 0,
    failureReason: null,
    isPaused: !1,
    status: "idle",
    variables: void 0,
    submittedAt: 0
  };
}
var ba = class extends qe {
  constructor(e = {}) {
    super(), this.config = e, this.#t = /* @__PURE__ */ new Set(), this.#e = /* @__PURE__ */ new Map(), this.#n = 0;
  }
  #t;
  #e;
  #n;
  build(e, t, n) {
    const r = new ga({
      client: e,
      mutationCache: this,
      mutationId: ++this.#n,
      options: e.defaultMutationOptions(t),
      state: n
    });
    return this.add(r), r;
  }
  add(e) {
    this.#t.add(e);
    const t = ft(e);
    if (typeof t == "string") {
      const n = this.#e.get(t);
      n ? n.push(e) : this.#e.set(t, [e]);
    }
    this.notify({ type: "added", mutation: e });
  }
  remove(e) {
    if (this.#t.delete(e)) {
      const t = ft(e);
      if (typeof t == "string") {
        const n = this.#e.get(t);
        if (n)
          if (n.length > 1) {
            const r = n.indexOf(e);
            r !== -1 && n.splice(r, 1);
          } else n[0] === e && this.#e.delete(t);
      }
    }
    this.notify({ type: "removed", mutation: e });
  }
  canRun(e) {
    const t = ft(e);
    if (typeof t == "string") {
      const r = this.#e.get(t)?.find(
        (s) => s.state.status === "pending"
      );
      return !r || r === e;
    } else
      return !0;
  }
  runNext(e) {
    const t = ft(e);
    return typeof t == "string" ? this.#e.get(t)?.find((r) => r !== e && r.state.isPaused)?.continue() ?? Promise.resolve() : Promise.resolve();
  }
  clear() {
    ee.batch(() => {
      this.#t.forEach((e) => {
        this.notify({ type: "removed", mutation: e });
      }), this.#t.clear(), this.#e.clear();
    });
  }
  getAll() {
    return Array.from(this.#t);
  }
  find(e) {
    const t = { exact: !0, ...e };
    return this.getAll().find(
      (n) => Vn(t, n)
    );
  }
  findAll(e = {}) {
    return this.getAll().filter((t) => Vn(e, t));
  }
  notify(e) {
    ee.batch(() => {
      this.listeners.forEach((t) => {
        t(e);
      });
    });
  }
  resumePausedMutations() {
    const e = this.getAll().filter((t) => t.state.isPaused);
    return ee.batch(
      () => Promise.all(
        e.map((t) => t.continue().catch(fe))
      )
    );
  }
};
function ft(e) {
  return e.options.scope?.id;
}
var va = class extends qe {
  #t;
  #e = void 0;
  #n;
  #s;
  constructor(t, n) {
    super(), this.#t = t, this.setOptions(n), this.bindMethods(), this.#r();
  }
  bindMethods() {
    this.mutate = this.mutate.bind(this), this.reset = this.reset.bind(this);
  }
  setOptions(t) {
    const n = this.options;
    this.options = this.#t.defaultMutationOptions(t), rt(this.options, n) || this.#t.getMutationCache().notify({
      type: "observerOptionsUpdated",
      mutation: this.#n,
      observer: this
    }), n?.mutationKey && this.options.mutationKey && Ye(n.mutationKey) !== Ye(this.options.mutationKey) ? this.reset() : this.#n?.state.status === "pending" && this.#n.setOptions(this.options);
  }
  onUnsubscribe() {
    this.hasListeners() || this.#n?.removeObserver(this);
  }
  onMutationUpdate(t) {
    this.#r(), this.#i(t);
  }
  getCurrentResult() {
    return this.#e;
  }
  reset() {
    this.#n?.removeObserver(this), this.#n = void 0, this.#r(), this.#i();
  }
  mutate(t, n) {
    return this.#s = n, this.#n?.removeObserver(this), this.#n = this.#t.getMutationCache().build(this.#t, this.options), this.#n.addObserver(this), this.#n.execute(t);
  }
  #r() {
    const t = this.#n?.state ?? Lr();
    this.#e = {
      ...t,
      isPending: t.status === "pending",
      isSuccess: t.status === "success",
      isError: t.status === "error",
      isIdle: t.status === "idle",
      mutate: this.mutate,
      reset: this.reset
    };
  }
  #i(t) {
    ee.batch(() => {
      if (this.#s && this.hasListeners()) {
        const n = this.#e.variables, r = this.#e.context, s = {
          client: this.#t,
          meta: this.options.meta,
          mutationKey: this.options.mutationKey
        };
        if (t?.type === "success") {
          try {
            this.#s.onSuccess?.(
              t.data,
              n,
              r,
              s
            );
          } catch (i) {
            Promise.reject(i);
          }
          try {
            this.#s.onSettled?.(
              t.data,
              null,
              n,
              r,
              s
            );
          } catch (i) {
            Promise.reject(i);
          }
        } else if (t?.type === "error") {
          try {
            this.#s.onError?.(
              t.error,
              n,
              r,
              s
            );
          } catch (i) {
            Promise.reject(i);
          }
          try {
            this.#s.onSettled?.(
              void 0,
              t.error,
              n,
              r,
              s
            );
          } catch (i) {
            Promise.reject(i);
          }
        }
      }
      this.listeners.forEach((n) => {
        n(this.#e);
      });
    });
  }
};
function Gn(e, t) {
  const n = new Set(t);
  return e.filter((r) => !n.has(r));
}
function wa(e, t, n) {
  const r = e.slice(0);
  return r[t] = n, r;
}
var Na = class extends qe {
  #t;
  #e;
  #n;
  #s;
  #r;
  #i;
  #o;
  #a;
  #h = [];
  constructor(e, t, n) {
    super(), this.#t = e, this.#s = n, this.#n = [], this.#r = [], this.#e = [], this.setQueries(t);
  }
  onSubscribe() {
    this.listeners.size === 1 && this.#r.forEach((e) => {
      e.subscribe((t) => {
        this.#u(e, t);
      });
    });
  }
  onUnsubscribe() {
    this.listeners.size || this.destroy();
  }
  destroy() {
    this.listeners = /* @__PURE__ */ new Set(), this.#r.forEach((e) => {
      e.destroy();
    });
  }
  setQueries(e, t) {
    if (this.#n = e, this.#s = t, process.env.NODE_ENV !== "production") {
      const n = e.map(
        (r) => this.#t.defaultQueryOptions(r).queryHash
      );
      new Set(n).size !== n.length && console.warn(
        "[QueriesObserver]: Duplicate Queries found. This might result in unexpected behavior."
      );
    }
    ee.batch(() => {
      const n = this.#r, r = this.#c(this.#n);
      r.forEach(
        (d) => d.observer.setOptions(d.defaultedQueryOptions)
      );
      const s = r.map((d) => d.observer), i = s.map(
        (d) => d.getCurrentResult()
      ), a = n.length !== s.length, l = s.some(
        (d, h) => d !== n[h]
      ), u = a || l, c = u ? !0 : i.some((d, h) => {
        const p = this.#e[h];
        return !p || !rt(d, p);
      });
      !u && !c || (u && (this.#h = r, this.#r = s), this.#e = i, this.hasListeners() && (u && (Gn(n, s).forEach((d) => {
        d.destroy();
      }), Gn(s, n).forEach((d) => {
        d.subscribe((h) => {
          this.#u(d, h);
        });
      })), this.#l()));
    });
  }
  getCurrentResult() {
    return this.#e;
  }
  getQueries() {
    return this.#r.map((e) => e.getCurrentQuery());
  }
  getObservers() {
    return this.#r;
  }
  getOptimisticResult(e, t) {
    const n = this.#c(e), r = n.map(
      (s) => s.observer.getOptimisticResult(s.defaultedQueryOptions)
    );
    return [
      r,
      (s) => this.#f(s ?? r, t),
      () => this.#d(r, n)
    ];
  }
  #d(e, t) {
    return t.map((n, r) => {
      const s = e[r];
      return n.defaultedQueryOptions.notifyOnChangeProps ? s : n.observer.trackResult(s, (i) => {
        t.forEach((a) => {
          a.observer.trackProp(i);
        });
      });
    });
  }
  #f(e, t) {
    return t ? ((!this.#i || this.#e !== this.#a || t !== this.#o) && (this.#o = t, this.#a = this.#e, this.#i = vt(
      this.#i,
      t(e)
    )), this.#i) : e;
  }
  #c(e) {
    const t = /* @__PURE__ */ new Map();
    this.#r.forEach((r) => {
      const s = r.options.queryHash;
      if (!s) return;
      const i = t.get(s);
      i ? i.push(r) : t.set(s, [r]);
    });
    const n = [];
    return e.forEach((r) => {
      const s = this.#t.defaultQueryOptions(r), a = t.get(s.queryHash)?.shift() ?? new Sn(this.#t, s);
      n.push({
        defaultedQueryOptions: s,
        observer: a
      });
    }), n;
  }
  #u(e, t) {
    const n = this.#r.indexOf(e);
    n !== -1 && (this.#e = wa(this.#e, n, t), this.#l());
  }
  #l() {
    if (this.hasListeners()) {
      const e = this.#i, t = this.#d(this.#e, this.#h), n = this.#f(t, this.#s?.combine);
      e !== n && ee.batch(() => {
        this.listeners.forEach((r) => {
          r(this.#e);
        });
      });
    }
  }
}, Sa = class extends qe {
  constructor(e = {}) {
    super(), this.config = e, this.#t = /* @__PURE__ */ new Map();
  }
  #t;
  build(e, t, n) {
    const r = t.queryKey, s = t.queryHash ?? vn(r, t);
    let i = this.get(s);
    return i || (i = new ma({
      client: e,
      queryKey: r,
      queryHash: s,
      options: e.defaultQueryOptions(t),
      state: n,
      defaultOptions: e.getQueryDefaults(r)
    }), this.add(i)), i;
  }
  add(e) {
    this.#t.has(e.queryHash) || (this.#t.set(e.queryHash, e), this.notify({
      type: "added",
      query: e
    }));
  }
  remove(e) {
    const t = this.#t.get(e.queryHash);
    t && (e.destroy(), t === e && this.#t.delete(e.queryHash), this.notify({ type: "removed", query: e }));
  }
  clear() {
    ee.batch(() => {
      this.getAll().forEach((e) => {
        this.remove(e);
      });
    });
  }
  get(e) {
    return this.#t.get(e);
  }
  getAll() {
    return [...this.#t.values()];
  }
  find(e) {
    const t = { exact: !0, ...e };
    return this.getAll().find(
      (n) => jn(t, n)
    );
  }
  findAll(e = {}) {
    const t = this.getAll();
    return Object.keys(e).length > 0 ? t.filter((n) => jn(e, n)) : t;
  }
  notify(e) {
    ee.batch(() => {
      this.listeners.forEach((t) => {
        t(e);
      });
    });
  }
  onFocus() {
    ee.batch(() => {
      this.getAll().forEach((e) => {
        e.onFocus();
      });
    });
  }
  onOnline() {
    ee.batch(() => {
      this.getAll().forEach((e) => {
        e.onOnline();
      });
    });
  }
}, Aa = class {
  #t;
  #e;
  #n;
  #s;
  #r;
  #i;
  #o;
  #a;
  constructor(e = {}) {
    this.#t = e.queryCache || new Sa(), this.#e = e.mutationCache || new ba(), this.#n = e.defaultOptions || {}, this.#s = /* @__PURE__ */ new Map(), this.#r = /* @__PURE__ */ new Map(), this.#i = 0;
  }
  mount() {
    this.#i++, this.#i === 1 && (this.#o = Nn.subscribe(async (e) => {
      e && (await this.resumePausedMutations(), this.#t.onFocus());
    }), this.#a = Nt.subscribe(async (e) => {
      e && (await this.resumePausedMutations(), this.#t.onOnline());
    }));
  }
  unmount() {
    this.#i--, this.#i === 0 && (this.#o?.(), this.#o = void 0, this.#a?.(), this.#a = void 0);
  }
  isFetching(e) {
    return this.#t.findAll({ ...e, fetchStatus: "fetching" }).length;
  }
  isMutating(e) {
    return this.#e.findAll({ ...e, status: "pending" }).length;
  }
  /**
   * Imperative (non-reactive) way to retrieve data for a QueryKey.
   * Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates.
   *
   * Hint: Do not use this function inside a component, because it won't receive updates.
   * Use `useQuery` to create a `QueryObserver` that subscribes to changes.
   */
  getQueryData(e) {
    const t = this.defaultQueryOptions({ queryKey: e });
    return this.#t.get(t.queryHash)?.state.data;
  }
  ensureQueryData(e) {
    const t = this.defaultQueryOptions(e), n = this.#t.build(this, t), r = n.state.data;
    return r === void 0 ? this.fetchQuery(e) : (e.revalidateIfStale && n.isStaleByTime(Oe(t.staleTime, n)) && this.prefetchQuery(t), Promise.resolve(r));
  }
  getQueriesData(e) {
    return this.#t.findAll(e).map(({ queryKey: t, state: n }) => {
      const r = n.data;
      return [t, r];
    });
  }
  setQueryData(e, t, n) {
    const r = this.defaultQueryOptions({ queryKey: e }), i = this.#t.get(
      r.queryHash
    )?.state.data, a = ra(t, i);
    if (a !== void 0)
      return this.#t.build(this, r).setData(a, { ...n, manual: !0 });
  }
  setQueriesData(e, t, n) {
    return ee.batch(
      () => this.#t.findAll(e).map(({ queryKey: r }) => [
        r,
        this.setQueryData(r, t, n)
      ])
    );
  }
  getQueryState(e) {
    const t = this.defaultQueryOptions({ queryKey: e });
    return this.#t.get(
      t.queryHash
    )?.state;
  }
  removeQueries(e) {
    const t = this.#t;
    ee.batch(() => {
      t.findAll(e).forEach((n) => {
        t.remove(n);
      });
    });
  }
  resetQueries(e, t) {
    const n = this.#t;
    return ee.batch(() => (n.findAll(e).forEach((r) => {
      r.reset();
    }), this.refetchQueries(
      {
        type: "active",
        ...e
      },
      t
    )));
  }
  cancelQueries(e, t = {}) {
    const n = { revert: !0, ...t }, r = ee.batch(
      () => this.#t.findAll(e).map((s) => s.cancel(n))
    );
    return Promise.all(r).then(fe).catch(fe);
  }
  invalidateQueries(e, t = {}) {
    return ee.batch(() => (this.#t.findAll(e).forEach((n) => {
      n.invalidate();
    }), e?.refetchType === "none" ? Promise.resolve() : this.refetchQueries(
      {
        ...e,
        type: e?.refetchType ?? e?.type ?? "active"
      },
      t
    )));
  }
  refetchQueries(e, t = {}) {
    const n = {
      ...t,
      cancelRefetch: t.cancelRefetch ?? !0
    }, r = ee.batch(
      () => this.#t.findAll(e).filter((s) => !s.isDisabled() && !s.isStatic()).map((s) => {
        let i = s.fetch(void 0, n);
        return n.throwOnError || (i = i.catch(fe)), s.state.fetchStatus === "paused" ? Promise.resolve() : i;
      })
    );
    return Promise.all(r).then(fe);
  }
  fetchQuery(e) {
    const t = this.defaultQueryOptions(e);
    t.retry === void 0 && (t.retry = !1);
    const n = this.#t.build(this, t);
    return n.isStaleByTime(
      Oe(t.staleTime, n)
    ) ? n.fetch(t) : Promise.resolve(n.state.data);
  }
  prefetchQuery(e) {
    return this.fetchQuery(e).then(fe).catch(fe);
  }
  fetchInfiniteQuery(e) {
    return e.behavior = Kn(e.pages), this.fetchQuery(e);
  }
  prefetchInfiniteQuery(e) {
    return this.fetchInfiniteQuery(e).then(fe).catch(fe);
  }
  ensureInfiniteQueryData(e) {
    return e.behavior = Kn(e.pages), this.ensureQueryData(e);
  }
  resumePausedMutations() {
    return Nt.isOnline() ? this.#e.resumePausedMutations() : Promise.resolve();
  }
  getQueryCache() {
    return this.#t;
  }
  getMutationCache() {
    return this.#e;
  }
  getDefaultOptions() {
    return this.#n;
  }
  setDefaultOptions(e) {
    this.#n = e;
  }
  setQueryDefaults(e, t) {
    this.#s.set(Ye(e), {
      queryKey: e,
      defaultOptions: t
    });
  }
  getQueryDefaults(e) {
    const t = [...this.#s.values()], n = {};
    return t.forEach((r) => {
      nt(e, r.queryKey) && Object.assign(n, r.defaultOptions);
    }), n;
  }
  setMutationDefaults(e, t) {
    this.#r.set(Ye(e), {
      mutationKey: e,
      defaultOptions: t
    });
  }
  getMutationDefaults(e) {
    const t = [...this.#r.values()], n = {};
    return t.forEach((r) => {
      nt(e, r.mutationKey) && Object.assign(n, r.defaultOptions);
    }), n;
  }
  defaultQueryOptions(e) {
    if (e._defaulted)
      return e;
    const t = {
      ...this.#n.queries,
      ...this.getQueryDefaults(e.queryKey),
      ...e,
      _defaulted: !0
    };
    return t.queryHash || (t.queryHash = vn(
      t.queryKey,
      t
    )), t.refetchOnReconnect === void 0 && (t.refetchOnReconnect = t.networkMode !== "always"), t.throwOnError === void 0 && (t.throwOnError = !!t.suspense), !t.networkMode && t.persister && (t.networkMode = "offlineFirst"), t.queryFn === wt && (t.enabled = !1), t;
  }
  defaultMutationOptions(e) {
    return e?._defaulted ? e : {
      ...this.#n.mutations,
      ...e?.mutationKey && this.getMutationDefaults(e.mutationKey),
      ...e,
      _defaulted: !0
    };
  }
  clear() {
    this.#t.clear(), this.#e.clear();
  }
}, Ir = te.createContext(
  void 0
), Pt = (e) => {
  const t = te.useContext(Ir);
  if (!t)
    throw new Error("No QueryClient set, use QueryClientProvider to set one");
  return t;
}, ka = ({
  client: e,
  children: t
}) => (te.useEffect(() => (e.mount(), () => {
  e.unmount();
}), [e]), /* @__PURE__ */ o(Ir.Provider, { value: e, children: t })), Fa = te.createContext(!1), Pr = () => te.useContext(Fa);
function Ta() {
  let e = !1;
  return {
    clearReset: () => {
      e = !1;
    },
    reset: () => {
      e = !0;
    },
    isReset: () => e
  };
}
var Ma = te.createContext(Ta()), zr = () => te.useContext(Ma), jr = (e, t, n) => {
  const r = n?.state.error && typeof e.throwOnError == "function" ? wn(e.throwOnError, [n.state.error, n]) : e.throwOnError;
  (e.suspense || e.experimental_prefetchInRender || r) && (t.isReset() || (e.retryOnMount = !1));
}, Vr = (e) => {
  te.useEffect(() => {
    e.clearReset();
  }, [e]);
}, Hr = ({
  result: e,
  errorResetBoundary: t,
  throwOnError: n,
  query: r,
  suspense: s
}) => e.isError && !t.isReset() && !e.isFetching && r && (s && e.data === void 0 || wn(n, [e.error, r])), Ur = (e) => {
  if (e.suspense) {
    const n = (s) => s === "static" ? s : Math.max(s ?? 1e3, 1e3), r = e.staleTime;
    e.staleTime = typeof r == "function" ? (...s) => n(r(...s)) : n(r), typeof e.gcTime == "number" && (e.gcTime = Math.max(
      e.gcTime,
      1e3
    ));
  }
}, Yr = (e, t) => e.isLoading && e.isFetching && !t, an = (e, t) => e?.suspense && t.isPending, St = (e, t, n) => t.fetchOptimistic(e).catch(() => {
  n.clearReset();
});
function gd({
  queries: e,
  ...t
}, n) {
  const r = Pt(), s = Pr(), i = zr(), a = te.useMemo(
    () => e.map((m) => {
      const x = r.defaultQueryOptions(
        m
      );
      return x._optimisticResults = s ? "isRestoring" : "optimistic", x;
    }),
    [e, r, s]
  );
  a.forEach((m) => {
    Ur(m);
    const x = r.getQueryCache().get(m.queryHash);
    jr(m, i, x);
  }), Vr(i);
  const [l] = te.useState(
    () => new Na(
      r,
      a,
      t
    )
  ), [u, c, d] = l.getOptimisticResult(
    a,
    t.combine
  ), h = !s && t.subscribed !== !1;
  te.useSyncExternalStore(
    te.useCallback(
      (m) => h ? l.subscribe(ee.batchCalls(m)) : fe,
      [l, h]
    ),
    () => l.getCurrentResult(),
    () => l.getCurrentResult()
  ), te.useEffect(() => {
    l.setQueries(
      a,
      t
    );
  }, [a, t, l]);
  const f = u.some(
    (m, x) => an(a[x], m)
  ) ? u.flatMap((m, x) => {
    const y = a[x];
    if (y) {
      const g = new Sn(r, y);
      if (an(y, m))
        return St(y, g, i);
      Yr(m, s) && St(y, g, i);
    }
    return [];
  }) : [];
  if (f.length > 0)
    throw Promise.all(f);
  const b = u.find(
    (m, x) => {
      const y = a[x];
      return y && Hr({
        result: m,
        errorResetBoundary: i,
        throwOnError: y.throwOnError,
        query: r.getQueryCache().get(y.queryHash),
        suspense: y.suspense
      });
    }
  );
  if (b?.error)
    throw b.error;
  return c(d());
}
function Ca(e, t, n) {
  if (process.env.NODE_ENV !== "production" && (typeof e != "object" || Array.isArray(e)))
    throw new Error(
      'Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object'
    );
  const r = Pr(), s = zr(), i = Pt(), a = i.defaultQueryOptions(e);
  i.getDefaultOptions().queries?._experimental_beforeQuery?.(
    a
  );
  const l = i.getQueryCache().get(a.queryHash);
  process.env.NODE_ENV !== "production" && (a.queryFn || console.error(
    `[${a.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`
  )), a._optimisticResults = r ? "isRestoring" : "optimistic", Ur(a), jr(a, s, l), Vr(s);
  const u = !i.getQueryCache().get(a.queryHash), [c] = te.useState(
    () => new t(
      i,
      a
    )
  ), d = c.getOptimisticResult(a), h = !r && e.subscribed !== !1;
  if (te.useSyncExternalStore(
    te.useCallback(
      (p) => {
        const f = h ? c.subscribe(ee.batchCalls(p)) : fe;
        return c.updateResult(), f;
      },
      [c, h]
    ),
    () => c.getCurrentResult(),
    () => c.getCurrentResult()
  ), te.useEffect(() => {
    c.setOptions(a);
  }, [a, c]), an(a, d))
    throw St(a, c, s);
  if (Hr({
    result: d,
    errorResetBoundary: s,
    throwOnError: a.throwOnError,
    query: l,
    suspense: a.suspense
  }))
    throw d.error;
  return i.getDefaultOptions().queries?._experimental_afterQuery?.(
    a,
    d
  ), a.experimental_prefetchInRender && !Ue && Yr(d, r) && (u ? (
    // Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
    St(a, c, s)
  ) : (
    // subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
    l?.promise
  ))?.catch(fe).finally(() => {
    c.updateResult();
  }), a.notifyOnChangeProps ? d : c.trackResult(d);
}
function _a(e, t) {
  return Ca(e, Sn);
}
function bd(e, t) {
  const n = Pt(), [r] = te.useState(
    () => new va(
      n,
      e
    )
  );
  te.useEffect(() => {
    r.setOptions(e);
  }, [r, e]);
  const s = te.useSyncExternalStore(
    te.useCallback(
      (a) => r.subscribe(ee.batchCalls(a)),
      [r]
    ),
    () => r.getCurrentResult(),
    () => r.getCurrentResult()
  ), i = te.useCallback(
    (a, l) => {
      r.mutate(a, l).catch(fe);
    },
    [r]
  );
  if (s.error && wn(r.options.throwOnError, [s.error]))
    throw s.error;
  return { ...s, mutate: i, mutateAsync: s.mutate };
}
class Da {
  apiUrl;
  headers;
  credentials;
  constructor(t, n = {}) {
    this.apiUrl = n.apiUrl || "/cubejs-api/v1", this.headers = {
      "Content-Type": "application/json",
      ...n.headers
    }, this.credentials = n.credentials ?? "include", t && (this.headers.Authorization = t);
  }
  async load(t) {
    const n = JSON.stringify(t), r = encodeURIComponent(n), s = `${this.apiUrl}/load?query=${r}`, i = await fetch(s, {
      method: "GET",
      headers: {
        // Remove Content-Type for GET request
        ...Object.fromEntries(
          Object.entries(this.headers).filter(([l]) => l !== "Content-Type")
        )
      },
      credentials: this.credentials
    });
    if (!i.ok) {
      let l = `Cube query failed: ${i.status}`;
      try {
        const u = await i.text();
        try {
          const c = JSON.parse(u);
          c.error ? l = c.error : l += ` ${u}`;
        } catch {
          l += ` ${u}`;
        }
      } catch {
      }
      throw new Error(l);
    }
    const a = await i.json();
    return new Bt(a);
  }
  async meta() {
    const t = `${this.apiUrl}/meta`, n = await fetch(t, {
      method: "GET",
      headers: this.headers,
      credentials: this.credentials
    });
    if (!n.ok)
      throw new Error(`Failed to fetch meta: ${n.status}`);
    return n.json();
  }
  async sql(t) {
    const n = encodeURIComponent(JSON.stringify(t)), r = `${this.apiUrl}/sql?query=${n}`, s = await fetch(r, {
      method: "GET",
      headers: {
        // Remove Content-Type for GET request
        ...Object.fromEntries(
          Object.entries(this.headers).filter(([i]) => i !== "Content-Type")
        )
      },
      credentials: this.credentials
    });
    if (!s.ok)
      throw new Error(`SQL generation failed: ${s.status}`);
    return s.json();
  }
  async dryRun(t) {
    const n = `${this.apiUrl}/dry-run`, r = await fetch(n, {
      method: "POST",
      headers: this.headers,
      credentials: this.credentials,
      body: JSON.stringify({ query: t })
    });
    if (!r.ok) {
      let s = `Dry run failed: ${r.status}`;
      try {
        const i = await r.text();
        try {
          const a = JSON.parse(i);
          a.error ? s = a.error : s += ` ${i}`;
        } catch {
          s += ` ${i}`;
        }
      } catch {
      }
      throw new Error(s);
    }
    return r.json();
  }
  /**
   * Execute EXPLAIN on a query to get the execution plan
   * Returns normalized plan across PostgreSQL, MySQL, and SQLite
   * Accepts standard queries, funnel queries ({ funnel: {...} }), or flow queries ({ flow: {...} })
   */
  async explain(t, n) {
    const r = `${this.apiUrl}/explain`, s = await fetch(r, {
      method: "POST",
      headers: this.headers,
      credentials: this.credentials,
      body: JSON.stringify({ query: t, options: n })
    });
    if (!s.ok) {
      let i = `Explain failed: ${s.status}`;
      try {
        const a = await s.text();
        try {
          const l = JSON.parse(a);
          l.error ? i = l.error : i += ` ${a}`;
        } catch {
          i += ` ${a}`;
        }
      } catch {
      }
      throw new Error(i);
    }
    return s.json();
  }
  /**
   * Execute multiple queries in a single batch request
   * Used by BatchCoordinator to optimize network requests
   */
  async batchLoad(t) {
    const n = `${this.apiUrl}/batch`, r = await fetch(n, {
      method: "POST",
      headers: this.headers,
      credentials: this.credentials,
      body: JSON.stringify({ queries: t })
    });
    if (!r.ok) {
      let i = `Batch query failed: ${r.status}`;
      try {
        const a = await r.text();
        try {
          const l = JSON.parse(a);
          l.error ? i = l.error : i += ` ${a}`;
        } catch {
          i += ` ${a}`;
        }
      } catch {
      }
      throw new Error(i);
    }
    return (await r.json()).results.map((i) => !i.success && i.error ? {
      ...new Bt({ data: [], annotation: {} }),
      error: i.error
    } : new Bt(i));
  }
}
class Bt {
  loadResponse;
  constructor(t) {
    this.loadResponse = t;
  }
  rawData() {
    return this.loadResponse.results && this.loadResponse.results[0] ? this.loadResponse.results[0].data || [] : this.loadResponse.data || [];
  }
  tablePivot() {
    return this.rawData();
  }
  series() {
    return this.rawData();
  }
  annotation() {
    return this.loadResponse.results && this.loadResponse.results[0] ? this.loadResponse.results[0].annotation || {} : this.loadResponse.annotation || {};
  }
  /**
   * Get cache metadata if result was served from cache
   * Returns undefined if not a cache hit
   */
  cacheInfo() {
    return this.loadResponse.results && this.loadResponse.results[0] ? this.loadResponse.results[0].cache : this.loadResponse.cache;
  }
}
function $a(e, t = {}) {
  return new Da(e, t);
}
class Oa {
  queue = [];
  flushScheduled = !1;
  batchExecutor;
  delayMs;
  constructor(t, n = 50) {
    this.batchExecutor = t, this.delayMs = n;
  }
  /**
   * Register a query to be batched. Returns a promise that resolves
   * when the batch is executed and this specific query's result is available.
   */
  register(t) {
    return new Promise((n, r) => {
      this.queue.push({ query: t, resolve: n, reject: r }), this.flushScheduled || this.scheduleFlush();
    });
  }
  /**
   * Schedule a flush after a short delay to collect multiple queries.
   * The delay allows queries from lazy-loaded portlets that become visible
   * during the same scroll action to be batched together.
   */
  scheduleFlush() {
    this.flushScheduled = !0, setTimeout(() => {
      this.flush();
    }, this.delayMs);
  }
  /**
   * Execute all queued queries as a batch and resolve individual promises
   */
  async flush() {
    this.flushScheduled = !1;
    const t = this.queue.slice();
    if (this.queue = [], t.length !== 0)
      try {
        const n = t.map((s) => s.query), r = await this.batchExecutor(n);
        t.forEach((s, i) => {
          const a = r[i];
          a && "error" in a && a.error ? s.reject(new Error(a.error)) : s.resolve(a);
        });
      } catch (n) {
        t.forEach((r) => {
          r.reject(n instanceof Error ? n : new Error(String(n)));
        });
      }
  }
  /**
   * Get current queue size (useful for debugging)
   */
  getQueueSize() {
    return this.queue.length;
  }
  /**
   * Clear the queue (useful for testing/cleanup)
   */
  clear() {
    this.queue = [], this.flushScheduled = !1;
  }
}
const Br = yn(null);
function Ra({
  apiOptions: e,
  token: t,
  options: n = {},
  enableBatching: r = !0,
  batchDelayMs: s = 50,
  children: i
}) {
  const a = q(
    () => ({ apiOptions: e, token: t }),
    [e, t]
  ), [l, u] = J(null);
  Ae(() => {
    u(null);
  }, [a]);
  const c = l ?? a, d = q(
    () => $a(c.token, c.apiOptions),
    [c.apiOptions, c.token]
  ), h = q(() => r ? new Oa((b) => d.batchLoad(b), s) : null, [r, d, s]), p = Ve((b, m) => {
    u({ apiOptions: b, token: m });
  }, []), f = q(() => ({
    cubeApi: d,
    options: n,
    updateApiConfig: p,
    batchCoordinator: h,
    enableBatching: r
  }), [d, n, p, h, r]);
  return /* @__PURE__ */ o(Br.Provider, { value: f, children: i });
}
function Qr() {
  const e = Rt(Br);
  if (!e)
    throw new Error("useCubeApi must be used within CubeApiProvider");
  return e;
}
const Xn = ["cube", "meta"];
function Ea(e) {
  const t = {};
  return e.cubes.forEach((n) => {
    n.measures.forEach((r) => {
      t[r.name] = r.title || r.shortTitle || r.name;
    }), n.dimensions.forEach((r) => {
      t[r.name] = r.title || r.shortTitle || r.name;
    }), n.segments.forEach((r) => {
      t[r.name] = r.title || r.shortTitle || r.name;
    });
  }), t;
}
function La(e = {}) {
  const { enabled: t = !0, staleTime: n = 300 * 1e3 } = e, { cubeApi: r } = Qr(), s = Pt(), i = _a({
    queryKey: Xn,
    queryFn: async () => {
      const d = await r.meta(), h = Ea(d);
      return { meta: d, labelMap: h };
    },
    enabled: t,
    staleTime: n,
    // Keep data in cache for 15 minutes after it becomes unused
    gcTime: 900 * 1e3
  }), a = i.data?.meta ?? null, l = i.data?.labelMap ?? {}, u = () => {
    s.invalidateQueries({ queryKey: Xn });
  }, c = (d) => l[d] || d;
  return {
    meta: a,
    labelMap: l,
    isLoading: i.isLoading,
    isFetching: i.isFetching,
    error: i.error,
    refetch: u,
    getFieldLabel: c
  };
}
function vd(e, t) {
  if (typeof e.dimension == "string")
    return e.dimension;
  const n = e.dimension, r = on(t);
  if (!r)
    return n[0]?.dimension || "";
  const s = n.find((i) => i.cube === r);
  return s ? s.dimension : n[0]?.dimension || "";
}
function on(e) {
  if (e.measures && e.measures.length > 0) {
    const t = e.measures[0].split(".");
    if (t.length >= 2)
      return t[0];
  }
  if (e.dimensions && e.dimensions.length > 0) {
    const t = e.dimensions[0].split(".");
    if (t.length >= 2)
      return t[0];
  }
  if (e.timeDimensions && e.timeDimensions.length > 0) {
    const t = e.timeDimensions[0].dimension.split(".");
    if (t.length >= 2)
      return t[0];
  }
  return null;
}
function wd(e, t, n, r) {
  const s = e.map((i, a) => ({
    id: `step-${a}`,
    name: n?.[a] || `Step ${a + 1}`,
    query: i,
    timeToConvert: r?.[a] || void 0
  }));
  return {
    id: `funnel-${Date.now()}`,
    name: "Funnel Analysis",
    bindingKey: t,
    steps: s,
    countUnique: !0
  };
}
function Nd(e) {
  return e.length > 0 && typeof e[0] == "object" && e[0] !== null && "__stepIndex" in e[0];
}
function Sd(e, t, n, r, s = !0) {
  const i = t.dimension, a = Ia(e, t), l = e.map((u, c) => {
    const d = {
      name: n?.[c] || `Step ${c + 1}`
    }, h = Pa(u);
    h && (d.filter = h);
    const p = r?.[c];
    return p && (d.timeToConvert = p), d;
  });
  return {
    funnel: {
      bindingKey: i,
      timeDimension: a,
      steps: l,
      includeTimeMetrics: s
    }
  };
}
function Ia(e, t) {
  if (!Array.isArray(t.dimension)) {
    for (const a of e)
      if (a.timeDimensions?.length)
        return a.timeDimensions[0].dimension;
    const i = on(e[0]);
    if (i)
      return `${i}.createdAt`;
    throw new Error("Funnel requires at least one time dimension in step queries");
  }
  const r = [], s = t.dimension;
  for (const i of s) {
    const a = e.find((l) => on(l) === i.cube);
    a?.timeDimensions?.length ? r.push({
      cube: i.cube,
      dimension: a.timeDimensions[0].dimension
    }) : r.push({
      cube: i.cube,
      dimension: `${i.cube}.createdAt`
    });
  }
  return r;
}
function Pa(e) {
  if (!e.filters?.length)
    return;
  const t = e.filters.filter((n) => "member" in n);
  if (t.length !== 0)
    return t.length === 1 ? t[0] : t;
}
function Ad(e, t) {
  return e?.length ? e.map((r, s) => ({
    // Map server fields to client format
    name: t?.[s] || r.step,
    value: r.count,
    // Convert cumulative rate to percentage
    percentage: r.cumulativeConversionRate * 100,
    // Convert step-to-step rate to percentage (null for first step)
    conversionRate: r.conversionRate !== null ? r.conversionRate * 100 : null,
    stepIndex: r.stepIndex,
    // Include time metrics for optional display
    avgSecondsToConvert: r.avgSecondsToConvert,
    medianSecondsToConvert: r.medianSecondsToConvert,
    p90SecondsToConvert: r.p90SecondsToConvert
  })) : [];
}
function Qt(e) {
  if (e == null)
    return "-";
  if (e < 60)
    return `${Math.round(e)}s`;
  if (e < 3600) {
    const n = e / 60;
    return n < 10 ? `${n.toFixed(1)}m` : `${Math.round(n)}m`;
  }
  if (e < 86400) {
    const n = e / 3600;
    return n < 10 ? `${n.toFixed(1)}h` : `${Math.round(n)}h`;
  }
  const t = e / 86400;
  return t < 10 ? `${t.toFixed(1)}d` : `${Math.round(t)}d`;
}
function At(e) {
  if (!e || typeof e != "object") return !1;
  const t = e;
  return Array.isArray(t.nodes) && Array.isArray(t.links) && (t.nodes.length === 0 || typeof t.nodes[0] == "object" && t.nodes[0] !== null && "id" in t.nodes[0]);
}
function kd(e) {
  return typeof e == "object" && e !== null && "flow" in e && typeof e.flow == "object";
}
const Fd = 0, Td = 5, qr = yn(null), za = {
  enableAI: !0,
  aiEndpoint: "/api/ai/generate",
  showSchemaDiagram: !1,
  useAnalysisBuilder: !1,
  editToolbar: "both",
  floatingToolbarPosition: "right"
};
function ja({
  features: e,
  dashboardModes: t = ["rows", "grid"],
  children: n
}) {
  const [r, s] = J(() => ({
    ...za,
    ...e
  })), i = Ve((l) => {
    s((u) => ({ ...u, ...l }));
  }, []), a = q(() => ({
    features: r,
    dashboardModes: t,
    updateFeatures: i
  }), [r, t, i]);
  return /* @__PURE__ */ o(qr.Provider, { value: a, children: n });
}
function Va() {
  const e = Rt(qr);
  if (!e)
    throw new Error("useCubeFeatures must be used within CubeFeaturesProvider");
  return e;
}
const Ha = {
  body: `<g fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
    <rect x="3" y="4" width="5" height="3" rx="0.75"/>
    <rect x="16" y="4" width="5" height="3" rx="0.75"/>
    <rect x="16" y="10.5" width="5" height="3" rx="0.75"/>
    <rect x="16" y="17" width="5" height="3" rx="0.75"/>
    <path d="M8 5.5 C11 5.5, 13 5.5, 16 5.5"/>
    <path d="M8 5.5 C10 5.5, 11 7, 12 9 C13 11, 14 12, 16 12"/>
    <path d="M8 5.5 C10 5.5, 11 10, 12 14 C13 17, 14 18.5, 16 18.5"/>
  </g>`,
  width: 24,
  height: 24
}, Ua = {
  body: `<g fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
    <rect x="2" y="3" width="20" height="4" rx="1"/>
    <rect x="4" y="10" width="16" height="4" rx="1"/>
    <rect x="6" y="17" width="12" height="4" rx="1"/>
  </g>`,
  width: 24,
  height: 24
}, Kr = {
  // Action icons
  close: { icon: Ji, category: "action" },
  add: { icon: Zi, category: "action" },
  edit: { icon: Xi, category: "action" },
  delete: { icon: Gi, category: "action" },
  refresh: { icon: Yt, category: "action" },
  copy: { icon: Wi, category: "action" },
  duplicate: { icon: Ki, category: "action" },
  settings: { icon: qi, category: "action" },
  filter: { icon: Qi, category: "action" },
  share: { icon: Bi, category: "action" },
  expand: { icon: Pn, category: "action" },
  collapse: { icon: zn, category: "action" },
  search: { icon: Yi, category: "action" },
  menu: { icon: Ui, category: "action" },
  run: { icon: Hi, category: "action" },
  check: { icon: Vi, category: "action" },
  link: { icon: ji, category: "action" },
  eye: { icon: zi, category: "action" },
  eyeOff: { icon: Pi, category: "action" },
  adjustments: { icon: Ii, category: "action" },
  desktop: { icon: Li, category: "action" },
  table: { icon: Ei, category: "action" },
  sun: { icon: Ri, category: "action" },
  moon: { icon: Oi, category: "action" },
  ellipsisHorizontal: { icon: $i, category: "action" },
  documentText: { icon: Di, category: "action" },
  bookOpen: { icon: _i, category: "action" },
  codeBracket: { icon: Ci, category: "action" },
  swatch: { icon: Mi, category: "action" },
  // Field type icons (solid for visual distinction)
  measure: { icon: Ti, category: "field" },
  dimension: { icon: Fi, category: "field" },
  timeDimension: { icon: ki, category: "field" },
  segment: { icon: Ai, category: "field" },
  // Chart type icons (Tabler - keeping existing visuals)
  chartBar: { icon: Si, category: "chart" },
  chartLine: { icon: Ni, category: "chart" },
  chartArea: { icon: wi, category: "chart" },
  chartPie: { icon: vi, category: "chart" },
  chartScatter: { icon: bi, category: "chart" },
  chartBubble: { icon: gi, category: "chart" },
  chartRadar: { icon: xi, category: "chart" },
  chartRadialBar: { icon: yi, category: "chart" },
  chartTreemap: { icon: pi, category: "chart" },
  chartTable: { icon: mi, category: "chart" },
  chartActivityGrid: { icon: hi, category: "chart" },
  chartKpiNumber: { icon: fi, category: "chart" },
  chartKpiDelta: { icon: di, category: "chart" },
  chartKpiText: { icon: ui, category: "chart" },
  chartMarkdown: { icon: ci, category: "chart" },
  chartFunnel: { icon: Ua, category: "chart" },
  chartSankey: { icon: Ha, category: "chart" },
  chartSunburst: { icon: li, category: "chart" },
  // Measure type icons (solid)
  measureCount: { icon: oi, category: "measure" },
  measureCountDistinct: { icon: ai, category: "measure" },
  measureCountDistinctApprox: { icon: ii, category: "measure" },
  measureSum: { icon: si, category: "measure" },
  measureAvg: { icon: ri, category: "measure" },
  measureMin: { icon: Ln, category: "measure" },
  measureMax: { icon: In, category: "measure" },
  measureRunningTotal: { icon: ni, category: "measure" },
  measureCalculated: { icon: ti, category: "measure" },
  measureNumber: { icon: ei, category: "measure" },
  // State icons
  success: { icon: Js, category: "state" },
  warning: { icon: Zs, category: "state" },
  error: { icon: Xs, category: "state" },
  info: { icon: bn, category: "state" },
  loading: { icon: Yt, category: "state" },
  sparkles: { icon: Gs, category: "state" },
  // Navigation icons
  chevronUp: { icon: zn, category: "navigation" },
  chevronDown: { icon: Pn, category: "navigation" },
  chevronLeft: { icon: Ws, category: "navigation" },
  chevronRight: { icon: Ks, category: "navigation" },
  chevronUpDown: { icon: qs, category: "navigation" },
  arrowUp: { icon: In, category: "navigation" },
  arrowDown: { icon: Ln, category: "navigation" },
  arrowRight: { icon: Qs, category: "navigation" },
  arrowPath: { icon: Yt, category: "navigation" }
};
let he = { ...Kr };
const st = /* @__PURE__ */ new Map();
function Md() {
  return he;
}
function zt(e) {
  const t = st.get(e);
  if (t)
    return t;
  const n = he[e];
  if (!n)
    return console.warn(`Icon "${e}" not found in registry, using fallback`), ({ className: i, ...a }) => /* @__PURE__ */ o(bt, { icon: he.info.icon, className: i, ...a });
  const r = ({ className: s, ...i }) => /* @__PURE__ */ o(bt, { icon: n.icon, className: s, ...i });
  return st.set(e, r), r;
}
function Cd(e) {
  return he[e]?.icon ?? he.info.icon;
}
function _d(e, t) {
  he[e] && (he[e] = {
    ...he[e],
    icon: t
  }, st.delete(e));
}
function Dd(e) {
  for (const [t, n] of Object.entries(e))
    if (n && t in he) {
      const r = t;
      if ("body" in n)
        he[r] = {
          ...he[r],
          icon: n
        };
      else {
        const s = n;
        he[r] = {
          ...he[r],
          ...s,
          icon: s.icon ?? he[r].icon
        };
      }
      st.delete(r);
    }
}
function $d() {
  he = { ...Kr }, st.clear();
}
function Od(e) {
  const t = {};
  for (const [n, r] of Object.entries(he))
    r.category === e && (t[n] = zt(n));
  return t;
}
function Ya(e) {
  const n = {
    count: "measureCount",
    countDistinct: "measureCountDistinct",
    countDistinctApprox: "measureCountDistinctApprox",
    sum: "measureSum",
    avg: "measureAvg",
    min: "measureMin",
    max: "measureMax",
    runningTotal: "measureRunningTotal",
    calculated: "measureCalculated",
    number: "measureNumber"
  }[e || ""] || "measureCount";
  return zt(n);
}
function ae(e) {
  const n = {
    bar: "chartBar",
    line: "chartLine",
    area: "chartArea",
    pie: "chartPie",
    scatter: "chartScatter",
    bubble: "chartBubble",
    radar: "chartRadar",
    radialBar: "chartRadialBar",
    treemap: "chartTreemap",
    table: "chartTable",
    activityGrid: "chartActivityGrid",
    kpiNumber: "chartKpiNumber",
    kpiDelta: "chartKpiDelta",
    kpiText: "chartKpiText",
    markdown: "chartMarkdown",
    funnel: "chartFunnel",
    sankey: "chartSankey",
    sunburst: "chartSunburst"
  }[e] || "chartBar";
  return zt(n);
}
function Rd(e) {
  const n = {
    measure: "measure",
    dimension: "dimension",
    timeDimension: "timeDimension",
    time: "timeDimension",
    segment: "segment"
  }[e] || "dimension";
  return zt(n);
}
const Ba = {
  sm: "h-6 w-6",
  md: "h-8 w-8",
  lg: "h-12 w-12"
};
function Zn({
  size: e = "md",
  className: t = ""
}) {
  return /* @__PURE__ */ o(
    "div",
    {
      className: `animate-spin rounded-full border-b-2 ${Ba[e]} ${t}`,
      style: { borderBottomColor: "var(--dc-primary)" },
      role: "status",
      "aria-label": "Loading"
    }
  );
}
const kn = yn(null);
function Qa({ children: e }) {
  const {
    meta: t,
    labelMap: n,
    isLoading: r,
    error: s,
    refetch: i,
    getFieldLabel: a
  } = La(), l = s ? s instanceof Error ? s.message : String(s) : null, u = Ve(() => {
    i();
  }, [i]), c = Ve((h) => a(h), [a]), d = q(() => ({
    meta: t,
    labelMap: n,
    metaLoading: r,
    metaError: l,
    getFieldLabel: c,
    refetchMeta: u
  }), [t, n, r, l, c, u]);
  return /* @__PURE__ */ o(kn.Provider, { value: d, children: e });
}
function Wr() {
  const e = Rt(kn);
  if (!e)
    throw new Error("useCubeMeta must be used within CubeMetaProvider");
  return e;
}
const qa = { apiUrl: "/cubejs-api/v1" }, Gr = () => new Aa({
  defaultOptions: {
    queries: {
      // Stale time: 5 minutes (matches existing cache duration)
      staleTime: 300 * 1e3,
      // GC time: 15 minutes
      gcTime: 900 * 1e3,
      // Retry failed queries up to 3 times
      retry: 3,
      // Don't refetch on window focus by default (can be overridden per-query)
      refetchOnWindowFocus: !1
    }
  }
});
Gr();
function Ed({
  cubeApi: e,
  // Intentionally unused - for backward compatibility
  apiOptions: t,
  token: n,
  options: r,
  features: s,
  dashboardModes: i,
  enableBatching: a,
  batchDelayMs: l,
  queryClient: u,
  children: c
}) {
  const [d] = J(() => Gr());
  return /* @__PURE__ */ o(ka, { client: u ?? d, children: /* @__PURE__ */ o(
    Ra,
    {
      apiOptions: t || qa,
      token: n,
      options: r,
      enableBatching: a,
      batchDelayMs: l,
      children: /* @__PURE__ */ o(Qa, { children: /* @__PURE__ */ o(ja, { features: s, dashboardModes: i, children: c }) })
    }
  ) });
}
function Ld() {
  const e = Qr(), t = Wr(), n = Va();
  return q(() => ({
    ...e,
    ...t,
    features: n.features,
    dashboardModes: n.dashboardModes
  }), [e, t, n]);
}
function Ka({ children: e, className: t = "" }) {
  return /* @__PURE__ */ o("h3", { className: `text-sm font-semibold text-dc-primary uppercase tracking-wide ${t}`, children: e });
}
const Wa = {
  icon: ae("bar"),
  description: "Compare values across categories",
  useCase: "Best for comparing discrete categories, showing rankings, or displaying changes over time",
  dropZones: [
    {
      key: "xAxis",
      label: "X-Axis (Categories)",
      description: "Dimensions and time dimensions for grouping",
      mandatory: !1,
      acceptTypes: ["dimension", "timeDimension"],
      emptyText: "Drop dimensions & time dimensions here"
    },
    {
      key: "yAxis",
      label: "Y-Axis (Values)",
      description: "Measures for bar heights",
      mandatory: !0,
      acceptTypes: ["measure"],
      emptyText: "Drop measures here",
      enableDualAxis: !0
    },
    {
      key: "series",
      label: "Series (Split into Multiple Series)",
      description: "Dimensions to create separate data series",
      mandatory: !1,
      acceptTypes: ["dimension"],
      emptyText: "Drop dimensions here to split data into series"
    }
  ],
  displayOptions: ["showLegend", "showGrid", "showTooltip", "hideHeader"],
  displayOptionsConfig: [
    {
      key: "stackType",
      label: "Stacking",
      type: "select",
      defaultValue: "none",
      options: [
        { value: "none", label: "None" },
        { value: "normal", label: "Stacked" },
        { value: "percent", label: "Stacked 100%" }
      ],
      description: "How to stack multiple bar series"
    },
    {
      key: "target",
      label: "Target Values",
      type: "string",
      placeholder: "e.g., 100 or 50,75 for spread",
      description: "Single value or comma-separated values to spread across X-axis"
    },
    {
      key: "leftYAxisFormat",
      label: "Left Y-Axis Format",
      type: "axisFormat",
      description: "Number formatting for left Y-axis"
    },
    {
      key: "rightYAxisFormat",
      label: "Right Y-Axis Format",
      type: "axisFormat",
      description: "Number formatting for right Y-axis"
    }
  ]
}, Id = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  barChartConfig: Wa
}, Symbol.toStringTag, { value: "Module" })), Ga = {
  icon: ae("line"),
  description: "Show trends and changes over time",
  useCase: "Best for continuous data, trends, time series, and showing relationships between multiple series",
  dropZones: [
    {
      key: "xAxis",
      label: "X-Axis (Time/Categories)",
      description: "Time dimensions or dimensions for X-axis",
      mandatory: !0,
      acceptTypes: ["dimension", "timeDimension"],
      emptyText: "Drop time dimensions or dimensions here"
    },
    {
      key: "yAxis",
      label: "Y-Axis (Values)",
      description: "Measures for line values",
      mandatory: !0,
      acceptTypes: ["measure"],
      emptyText: "Drop measures here",
      enableDualAxis: !0
    },
    {
      key: "series",
      label: "Series (Multiple Lines)",
      description: "Dimensions to create separate lines",
      mandatory: !1,
      acceptTypes: ["dimension"],
      emptyText: "Drop dimensions here for multiple lines"
    }
  ],
  displayOptions: ["showLegend", "showGrid", "showTooltip", "hideHeader"],
  displayOptionsConfig: [
    {
      key: "connectNulls",
      label: "Connect Nulls",
      type: "boolean",
      defaultValue: !1,
      description: "Draw continuous line through missing data points"
    },
    {
      key: "target",
      label: "Target Values",
      type: "string",
      placeholder: "e.g., 100 or 50,75 for spread",
      description: "Single value or comma-separated values to spread across X-axis"
    },
    {
      key: "priorPeriodStyle",
      label: "Prior Period Line Style",
      type: "select",
      defaultValue: "dashed",
      options: [
        { value: "dashed", label: "Dashed" },
        { value: "dotted", label: "Dotted" },
        { value: "solid", label: "Solid" }
      ],
      description: "Line style for prior period in comparison mode"
    },
    {
      key: "priorPeriodOpacity",
      label: "Prior Period Opacity",
      type: "number",
      defaultValue: 0.5,
      min: 0.1,
      max: 1,
      step: 0.1,
      description: "Opacity for prior period lines (0.1 to 1)"
    },
    {
      key: "leftYAxisFormat",
      label: "Left Y-Axis Format",
      type: "axisFormat",
      description: "Number formatting for left Y-axis"
    },
    {
      key: "rightYAxisFormat",
      label: "Right Y-Axis Format",
      type: "axisFormat",
      description: "Number formatting for right Y-axis"
    }
  ]
}, Pd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  lineChartConfig: Ga
}, Symbol.toStringTag, { value: "Module" })), Xa = {
  icon: ae("area"),
  description: "Emphasize magnitude of change over time",
  useCase: "Best for showing cumulative totals, volume changes, or stacked comparisons over time",
  dropZones: [
    {
      key: "xAxis",
      label: "X-Axis (Time/Categories)",
      description: "Time dimensions or dimensions for X-axis",
      mandatory: !0,
      acceptTypes: ["dimension", "timeDimension"],
      emptyText: "Drop time dimensions or dimensions here"
    },
    {
      key: "yAxis",
      label: "Y-Axis (Values)",
      description: "Measures for area values",
      mandatory: !0,
      acceptTypes: ["measure"],
      emptyText: "Drop measures here",
      enableDualAxis: !0
    },
    {
      key: "series",
      label: "Series (Stack Areas)",
      description: "Dimensions to create stacked areas",
      mandatory: !1,
      acceptTypes: ["dimension"],
      emptyText: "Drop dimensions here for stacked areas"
    }
  ],
  displayOptions: ["showLegend", "showGrid", "showTooltip", "hideHeader"],
  displayOptionsConfig: [
    {
      key: "stackType",
      label: "Stacking",
      type: "select",
      defaultValue: "none",
      options: [
        { value: "none", label: "None" },
        { value: "normal", label: "Stacked" },
        { value: "percent", label: "Stacked 100%" }
      ],
      description: "How to stack multiple area series"
    },
    {
      key: "connectNulls",
      label: "Connect Nulls",
      type: "boolean",
      defaultValue: !1,
      description: "Draw continuous line through missing data points"
    },
    {
      key: "target",
      label: "Target Values",
      type: "string",
      placeholder: "e.g., 100 or 50,75 for spread",
      description: "Single value or comma-separated values to spread across X-axis"
    },
    {
      key: "leftYAxisFormat",
      label: "Left Y-Axis Format",
      type: "axisFormat",
      description: "Number formatting for left Y-axis"
    },
    {
      key: "rightYAxisFormat",
      label: "Right Y-Axis Format",
      type: "axisFormat",
      description: "Number formatting for right Y-axis"
    }
  ]
}, zd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  areaChartConfig: Xa
}, Symbol.toStringTag, { value: "Module" })), Za = {
  icon: ae("pie"),
  description: "Show proportions of a whole",
  useCase: "Best for showing percentage distribution or composition of a total (limit to 5-7 slices)",
  dropZones: [
    {
      key: "xAxis",
      label: "Categories",
      description: "Dimension for pie slices",
      mandatory: !0,
      maxItems: 1,
      acceptTypes: ["dimension"],
      emptyText: "Drop a dimension for categories"
    },
    {
      key: "yAxis",
      label: "Values",
      description: "Measure for slice sizes",
      mandatory: !0,
      maxItems: 1,
      acceptTypes: ["measure"],
      emptyText: "Drop a measure for values"
    }
  ],
  displayOptions: ["showLegend", "showTooltip", "hideHeader"],
  displayOptionsConfig: [
    {
      key: "leftYAxisFormat",
      label: "Value Format",
      type: "axisFormat",
      description: "Number formatting for values"
    }
  ]
}, jd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  pieChartConfig: Za
}, Symbol.toStringTag, { value: "Module" })), Ja = {
  icon: ae("scatter"),
  description: "Reveal correlations between variables",
  useCase: "Best for identifying patterns, correlations, outliers, and relationships between two measures",
  dropZones: [
    {
      key: "xAxis",
      label: "X-Axis",
      description: "Measure or dimension for X position",
      mandatory: !0,
      maxItems: 1,
      acceptTypes: ["dimension", "timeDimension", "measure"],
      emptyText: "Drop a field for X-axis"
    },
    {
      key: "yAxis",
      label: "Y-Axis",
      description: "Measure for Y position",
      mandatory: !0,
      maxItems: 1,
      acceptTypes: ["measure"],
      emptyText: "Drop a measure for Y-axis"
    },
    {
      key: "series",
      label: "Series (Color Groups)",
      description: "Dimension to color points by category",
      mandatory: !1,
      maxItems: 1,
      acceptTypes: ["dimension"],
      emptyText: "Drop a dimension to color points"
    }
  ],
  displayOptions: ["showLegend", "showGrid", "showTooltip", "hideHeader"],
  displayOptionsConfig: [
    {
      key: "xAxisFormat",
      label: "X-Axis Format",
      type: "axisFormat",
      description: "Number formatting for X-axis"
    },
    {
      key: "leftYAxisFormat",
      label: "Y-Axis Format",
      type: "axisFormat",
      description: "Number formatting for Y-axis"
    }
  ]
}, Vd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  scatterChartConfig: Ja
}, Symbol.toStringTag, { value: "Module" })), eo = {
  icon: ae("bubble"),
  description: "Compare three dimensions of data",
  useCase: "Best for showing relationships between three variables (X, Y, and size), market analysis",
  dropZones: [
    {
      key: "xAxis",
      label: "X-Axis",
      description: "Horizontal axis position",
      mandatory: !0,
      maxItems: 1,
      acceptTypes: ["dimension", "timeDimension", "measure"],
      emptyText: "Drop a field for X-axis position"
    },
    {
      key: "yAxis",
      label: "Y-Axis",
      description: "Vertical axis position",
      mandatory: !0,
      maxItems: 1,
      acceptTypes: ["measure"],
      emptyText: "Drop a measure for Y-axis position"
    },
    {
      key: "sizeField",
      label: "Bubble Radius",
      description: "Size of bubbles based on this measure",
      mandatory: !0,
      maxItems: 1,
      acceptTypes: ["measure"],
      emptyText: "Drop a measure for bubble size"
    },
    {
      key: "series",
      label: "Bubble Labels",
      description: "Field to use for bubble labels and identification",
      mandatory: !0,
      maxItems: 1,
      acceptTypes: ["dimension"],
      emptyText: "Drop a dimension for bubble labels"
    },
    {
      key: "colorField",
      label: "Bubble Colour",
      description: "Color bubbles by this field (optional)",
      mandatory: !1,
      maxItems: 1,
      acceptTypes: ["dimension", "measure"],
      emptyText: "Drop a field for bubble color (optional)"
    }
  ],
  displayOptions: ["showLegend", "showGrid", "showTooltip", "minBubbleSize", "maxBubbleSize", "bubbleOpacity", "hideHeader"],
  displayOptionsConfig: [
    {
      key: "xAxisFormat",
      label: "X-Axis Format",
      type: "axisFormat",
      description: "Number formatting for X-axis"
    },
    {
      key: "leftYAxisFormat",
      label: "Y-Axis Format",
      type: "axisFormat",
      description: "Number formatting for Y-axis and values"
    }
  ]
}, Hd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  bubbleChartConfig: eo
}, Symbol.toStringTag, { value: "Module" })), to = {
  icon: ae("radar"),
  description: "Compare multiple metrics across categories",
  useCase: "Best for multivariate comparisons, performance metrics, strengths/weaknesses analysis",
  dropZones: [
    {
      key: "xAxis",
      label: "Axes (Categories)",
      description: "Dimensions for radar axes",
      mandatory: !0,
      acceptTypes: ["dimension"],
      emptyText: "Drop dimensions for radar axes"
    },
    {
      key: "yAxis",
      label: "Values",
      description: "Measures for radar values",
      mandatory: !0,
      acceptTypes: ["measure"],
      emptyText: "Drop measures for values"
    },
    {
      key: "series",
      label: "Series (Multiple Shapes)",
      description: "Dimensions to create multiple radar shapes",
      mandatory: !1,
      acceptTypes: ["dimension"],
      emptyText: "Drop dimensions for multiple shapes"
    }
  ],
  displayOptions: ["showLegend", "showGrid", "showTooltip", "hideHeader"],
  displayOptionsConfig: [
    {
      key: "leftYAxisFormat",
      label: "Value Format",
      type: "axisFormat",
      description: "Number formatting for values"
    }
  ]
}, Ud = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  radarChartConfig: to
}, Symbol.toStringTag, { value: "Module" })), no = {
  icon: ae("radialBar"),
  description: "Circular progress and KPI visualization",
  useCase: "Best for showing progress toward goals, KPIs, or comparing percentages in a compact form",
  dropZones: [
    {
      key: "xAxis",
      label: "Categories",
      description: "Dimensions for radial segments",
      mandatory: !0,
      acceptTypes: ["dimension"],
      emptyText: "Drop dimensions for categories"
    },
    {
      key: "yAxis",
      label: "Values",
      description: "Measures for radial bar lengths",
      mandatory: !0,
      maxItems: 1,
      acceptTypes: ["measure"],
      emptyText: "Drop a measure for values"
    }
  ],
  displayOptions: ["showLegend", "showTooltip", "hideHeader"],
  displayOptionsConfig: [
    {
      key: "leftYAxisFormat",
      label: "Value Format",
      type: "axisFormat",
      description: "Number formatting for values"
    }
  ]
}, Yd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  radialBarChartConfig: no
}, Symbol.toStringTag, { value: "Module" })), ro = {
  icon: ae("treemap"),
  description: "Visualize hierarchical data with nested rectangles",
  useCase: "Best for showing part-to-whole relationships in hierarchical data, disk usage, budget allocation",
  dropZones: [
    {
      key: "xAxis",
      label: "Categories",
      description: "Dimensions for treemap rectangles",
      mandatory: !0,
      acceptTypes: ["dimension"],
      emptyText: "Drop dimensions for categories"
    },
    {
      key: "yAxis",
      label: "Size",
      description: "Measure for rectangle sizes",
      mandatory: !0,
      maxItems: 1,
      acceptTypes: ["measure"],
      emptyText: "Drop a measure for size"
    },
    {
      key: "series",
      label: "Color Groups",
      description: "Dimension to color rectangles by category",
      mandatory: !1,
      maxItems: 1,
      acceptTypes: ["dimension"],
      emptyText: "Drop a dimension for color grouping"
    }
  ],
  displayOptions: ["showLegend", "showTooltip", "hideHeader"],
  displayOptionsConfig: [
    {
      key: "leftYAxisFormat",
      label: "Value Format",
      type: "axisFormat",
      description: "Number formatting for size values"
    }
  ]
}, Bd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  treemapChartConfig: ro
}, Symbol.toStringTag, { value: "Module" })), so = {
  icon: ae("table"),
  description: "Display detailed tabular data",
  useCase: "Best for precise values, detailed analysis, sortable/filterable data exploration",
  dropZones: [
    {
      key: "xAxis",
      label: "Columns",
      description: "All fields to display as columns",
      mandatory: !1,
      acceptTypes: ["dimension", "timeDimension", "measure"],
      emptyText: "Drop fields to display as columns (or leave empty for all)"
    }
  ],
  displayOptions: ["hideHeader"],
  displayOptionsConfig: [
    {
      key: "leftYAxisFormat",
      label: "Value Format",
      type: "axisFormat",
      description: "Number formatting for numeric values"
    }
  ]
}, Qd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  dataTableConfig: so
}, Symbol.toStringTag, { value: "Module" })), io = {
  icon: ae("activityGrid"),
  description: "GitHub-style activity grid showing temporal patterns across different time scales",
  useCase: "Best for visualizing activity patterns over time. Supports hour (3hr blocks × days), day (days × weeks), week (weeks × months), month (months × quarters), and quarter (quarters × years) granularities",
  dropZones: [
    {
      key: "dateField",
      label: "Time Dimension",
      description: "Time field that determines grid structure (granularity affects layout)",
      mandatory: !0,
      maxItems: 1,
      acceptTypes: ["timeDimension"],
      emptyText: "Drop a time dimension (granularity affects grid structure)"
    },
    {
      key: "valueField",
      label: "Activity Measure",
      description: "Measure used for activity intensity (color coding)",
      mandatory: !0,
      maxItems: 1,
      acceptTypes: ["measure"],
      emptyText: "Drop a measure for activity intensity"
    }
  ],
  displayOptions: ["showLabels", "showTooltip", "hideHeader"],
  displayOptionsConfig: [
    {
      key: "fitToWidth",
      label: "Fit to Width",
      type: "boolean",
      defaultValue: !1,
      description: "Automatically size blocks to fill portlet width and height while maintaining aspect ratio"
    }
  ],
  validate: (e) => {
    const { dateField: t, valueField: n } = e;
    return !t || Array.isArray(t) && t.length === 0 ? {
      isValid: !1,
      message: "Time dimension is required for activity grid"
    } : !n || Array.isArray(n) && n.length === 0 ? {
      isValid: !1,
      message: "Activity measure is required for intensity mapping"
    } : { isValid: !0 };
  }
}, qd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  activityGridChartConfig: io
}, Symbol.toStringTag, { value: "Module" })), ao = {
  icon: ae("kpiNumber"),
  description: "Display key performance indicators as large numbers",
  useCase: "Perfect for showing important metrics like revenue, user count, or other key business metrics in a prominent, easy-to-read format",
  dropZones: [
    {
      key: "yAxis",
      label: "Value",
      description: "Measure to display as KPI number",
      mandatory: !0,
      maxItems: 1,
      acceptTypes: ["measure"],
      emptyText: "Drop a measure here"
    }
  ],
  displayOptionsConfig: [
    {
      key: "target",
      label: "Target Value",
      type: "string",
      placeholder: "e.g., 100",
      description: "Target value to compare against (first value used if multiple provided)"
    },
    {
      key: "prefix",
      label: "Prefix",
      type: "string",
      placeholder: "e.g., $, €, #",
      description: "Text to display before the number"
    },
    {
      key: "suffix",
      label: "Suffix",
      type: "string",
      placeholder: "e.g., %, units, items",
      description: "Text to display after the number"
    },
    {
      key: "decimals",
      label: "Decimal Places",
      type: "number",
      defaultValue: 0,
      min: 0,
      max: 10,
      step: 1,
      description: "Number of decimal places to display"
    },
    {
      key: "valueColorIndex",
      label: "Value Color",
      type: "paletteColor",
      defaultValue: 0,
      description: "Color from the dashboard palette for the KPI value text"
    },
    {
      key: "useLastCompletePeriod",
      label: "Use Last Complete Period",
      type: "boolean",
      defaultValue: !0,
      description: "Exclude current incomplete period from aggregation (e.g., partial week/month)"
    },
    {
      key: "skipLastPeriod",
      label: "Skip Last Period",
      type: "boolean",
      defaultValue: !1,
      description: "Always exclude the last period regardless of completeness"
    }
  ],
  displayOptions: ["hideHeader"]
}, Kd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  kpiNumberConfig: ao
}, Symbol.toStringTag, { value: "Module" })), oo = {
  icon: ae("kpiDelta"),
  description: "Display change between latest and previous values with trend indicators",
  useCase: "Perfect for showing performance changes over time, such as revenue growth, user acquisition changes, or other metrics where the trend and delta are more important than the absolute value",
  dropZones: [
    {
      key: "yAxis",
      label: "Value",
      description: "Measure to track changes for",
      mandatory: !0,
      maxItems: 1,
      acceptTypes: ["measure"],
      emptyText: "Drop a measure here"
    },
    {
      key: "xAxis",
      label: "Dimension (optional)",
      description: "Dimension for ordering data (typically time)",
      mandatory: !1,
      maxItems: 1,
      acceptTypes: ["dimension", "timeDimension"],
      emptyText: "Drop a dimension for ordering"
    }
  ],
  displayOptionsConfig: [
    {
      key: "prefix",
      label: "Prefix",
      type: "string",
      placeholder: "e.g., $, €, #",
      description: "Text to display before the number"
    },
    {
      key: "suffix",
      label: "Suffix",
      type: "string",
      placeholder: "e.g., %, units, items",
      description: "Text to display after the number"
    },
    {
      key: "decimals",
      label: "Decimal Places",
      type: "number",
      defaultValue: 1,
      min: 0,
      max: 10,
      step: 1,
      description: "Number of decimal places to display"
    },
    {
      key: "positiveColorIndex",
      label: "Positive Change Color",
      type: "paletteColor",
      defaultValue: 2,
      // Typically green in most palettes
      description: "Color for positive changes (increases)"
    },
    {
      key: "negativeColorIndex",
      label: "Negative Change Color",
      type: "paletteColor",
      defaultValue: 3,
      // Typically red in most palettes
      description: "Color for negative changes (decreases)"
    },
    {
      key: "showHistogram",
      label: "Show Variance Histogram",
      type: "boolean",
      defaultValue: !0,
      description: "Display historical variance chart below the delta"
    },
    {
      key: "useLastCompletePeriod",
      label: "Use Last Complete Period",
      type: "boolean",
      defaultValue: !0,
      description: "Exclude current incomplete period from delta calculation (e.g., partial week/month)"
    },
    {
      key: "skipLastPeriod",
      label: "Skip Last Period",
      type: "boolean",
      defaultValue: !1,
      description: "Always exclude the last period regardless of completeness"
    }
  ],
  displayOptions: ["hideHeader"],
  validate: (e) => !e.yAxis || Array.isArray(e.yAxis) && e.yAxis.length === 0 ? {
    isValid: !1,
    message: "A measure is required for KPI Delta charts"
  } : { isValid: !0 }
}, Wd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  kpiDeltaConfig: oo
}, Symbol.toStringTag, { value: "Module" })), lo = {
  icon: ae("kpiText"),
  description: "Display key performance indicators as customizable text",
  useCase: "Perfect for showing metrics with custom formatting, combining multiple values, or displaying contextual KPI information using templates",
  dropZones: [
    {
      key: "yAxis",
      label: "Value",
      description: "Measure to display in the KPI text template",
      mandatory: !0,
      maxItems: 1,
      acceptTypes: ["measure"],
      emptyText: "Drop a measure here"
    }
  ],
  displayOptionsConfig: [
    {
      key: "template",
      label: "Text Template",
      type: "string",
      placeholder: "e.g., Total Revenue: ${value}",
      description: "Template for displaying the text. Use ${value} to insert the measure value."
    },
    {
      key: "decimals",
      label: "Decimal Places",
      type: "number",
      defaultValue: 0,
      min: 0,
      max: 10,
      step: 1,
      description: "Number of decimal places to display for numeric values"
    },
    {
      key: "valueColorIndex",
      label: "Value Color",
      type: "paletteColor",
      defaultValue: 0,
      description: "Color from the dashboard palette for the KPI value text"
    }
  ],
  displayOptions: ["hideHeader"]
}, Gd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  kpiTextConfig: lo
}, Symbol.toStringTag, { value: "Module" })), co = {
  icon: ae("markdown"),
  description: "Display custom markdown content with formatting",
  useCase: "Perfect for adding documentation, notes, instructions, or formatted text to dashboards",
  skipQuery: !0,
  // This chart doesn't require a valid query
  dropZones: [],
  // No drop zones needed for markdown content
  displayOptionsConfig: [
    {
      key: "content",
      label: "Markdown Content",
      type: "string",
      placeholder: `# Welcome

Add your **markdown** content here:

- Lists with bullets
- [Links](https://example.com)
- *Italic* and **bold** text`,
      description: "Enter markdown text. Supports headers (#), bold (**text**), italic (*text*), links ([text](url)), and lists (- item)."
    },
    {
      key: "accentColorIndex",
      label: "Accent Color",
      type: "paletteColor",
      defaultValue: 0,
      description: "Color from the dashboard palette for headers, bullets, and links"
    },
    {
      key: "fontSize",
      label: "Font Size",
      type: "select",
      defaultValue: "medium",
      options: [
        { value: "small", label: "Small" },
        { value: "medium", label: "Medium" },
        { value: "large", label: "Large" }
      ],
      description: "Overall text size for the markdown content"
    },
    {
      key: "alignment",
      label: "Text Alignment",
      type: "select",
      defaultValue: "left",
      options: [
        { value: "left", label: "Left" },
        { value: "center", label: "Center" },
        { value: "right", label: "Right" }
      ],
      description: "Horizontal alignment of the markdown content"
    }
  ],
  displayOptions: ["hideHeader"]
}, Xd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  markdownConfig: co
}, Symbol.toStringTag, { value: "Module" })), uo = {
  icon: ae("funnel"),
  description: "Show conversion through sequential steps",
  useCase: "Best for visualizing user journey funnels, sales pipelines, or multi-step processes",
  dropZones: [
    // Funnel charts don't use traditional drop zones since they work with
    // pre-calculated funnel data from useFunnelQuery. The steps are defined
    // in the funnel configuration, not through drag-and-drop.
    // However, we keep xAxis and yAxis for compatibility with chart system.
    {
      key: "xAxis",
      label: "Step Name",
      description: "Step names (auto-populated from funnel steps)",
      mandatory: !1,
      maxItems: 1,
      acceptTypes: ["dimension"],
      emptyText: "Steps defined in funnel config"
    },
    {
      key: "yAxis",
      label: "Step Count",
      description: "Count at each step (auto-calculated)",
      mandatory: !1,
      maxItems: 1,
      acceptTypes: ["measure"],
      emptyText: "Counts calculated from funnel execution"
    }
  ],
  displayOptions: ["hideHeader"],
  displayOptionsConfig: [
    {
      key: "funnelStyle",
      label: "Funnel Style",
      type: "buttonGroup",
      defaultValue: "bars",
      options: [
        { value: "bars", label: "Bars" },
        { value: "funnel", label: "Funnel" }
      ],
      description: "Visualization style"
    },
    {
      key: "funnelOrientation",
      label: "Orientation",
      type: "buttonGroup",
      defaultValue: "horizontal",
      options: [
        { value: "horizontal", label: "Horizontal" },
        { value: "vertical", label: "Vertical" }
      ]
    },
    {
      key: "hideSummaryFooter",
      label: "Hide Summary Footer",
      type: "boolean",
      defaultValue: !1,
      description: "Hide the summary footer showing steps count and overall conversion"
    },
    {
      key: "showFunnelConversion",
      label: "Show Conversion Rate",
      type: "boolean",
      defaultValue: !0,
      description: "Display step-to-step conversion percentage"
    },
    {
      key: "showFunnelAvgTime",
      label: "Show Avg Time",
      type: "boolean",
      defaultValue: !1,
      description: "Display average time to convert"
    },
    {
      key: "showFunnelMedianTime",
      label: "Show Median Time",
      type: "boolean",
      defaultValue: !1,
      description: "Display median time to convert"
    },
    {
      key: "showFunnelP90Time",
      label: "Show P90 Time",
      type: "boolean",
      defaultValue: !1,
      description: "Display 90th percentile time to convert"
    }
  ]
}, Zd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  funnelChartConfig: uo
}, Symbol.toStringTag, { value: "Module" })), fo = {
  icon: ae("sankey"),
  description: "Show flow between states or steps",
  useCase: "Best for visualizing user journey flows, path analysis, or state transitions",
  dropZones: [
    // Sankey charts don't use traditional drop zones since they work with
    // pre-calculated flow data from flow queries. The nodes and links are
    // generated from the flow configuration.
    {
      key: "xAxis",
      label: "Event Type",
      description: "Event dimension that categorizes flow nodes",
      mandatory: !1,
      maxItems: 1,
      acceptTypes: ["dimension"],
      emptyText: "Auto-populated from flow config"
    },
    {
      key: "yAxis",
      label: "Flow Count",
      description: "Count of entities following each path",
      mandatory: !1,
      maxItems: 1,
      acceptTypes: ["measure"],
      emptyText: "Calculated from flow execution"
    }
  ],
  displayOptions: ["hideHeader"],
  displayOptionsConfig: [
    {
      key: "linkOpacity",
      label: "Link Opacity",
      type: "buttonGroup",
      defaultValue: "0.5",
      options: [
        { value: "0.3", label: "Light" },
        { value: "0.5", label: "Medium" },
        { value: "0.7", label: "Dark" }
      ],
      description: "Opacity of flow links"
    },
    {
      key: "showNodeLabels",
      label: "Show Node Labels",
      type: "boolean",
      defaultValue: !0,
      description: "Display labels on flow nodes"
    },
    {
      key: "hideSummaryFooter",
      label: "Hide Summary Footer",
      type: "boolean",
      defaultValue: !0,
      description: "Hide the statistics footer below the chart"
    }
  ]
}, Jd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  sankeyChartConfig: fo
}, Symbol.toStringTag, { value: "Module" })), ho = {
  icon: ae("sunburst"),
  description: "Show hierarchical flow as radial rings",
  useCase: "Best for visualizing forward paths from a starting event in a compact radial layout",
  dropZones: [
    // Sunburst charts work with pre-calculated flow data like Sankey
    {
      key: "xAxis",
      label: "Event Type",
      description: "Event dimension that categorizes flow nodes",
      mandatory: !1,
      maxItems: 1,
      acceptTypes: ["dimension"],
      emptyText: "Auto-populated from flow config"
    },
    {
      key: "yAxis",
      label: "Flow Count",
      description: "Count of entities following each path",
      mandatory: !1,
      maxItems: 1,
      acceptTypes: ["measure"],
      emptyText: "Calculated from flow execution"
    }
  ],
  displayOptions: ["hideHeader"],
  displayOptionsConfig: [
    {
      key: "innerRadius",
      label: "Inner Radius",
      type: "number",
      defaultValue: 40,
      min: 0,
      max: 100,
      step: 10,
      description: "Size of the center hole (0 for full circle)"
    },
    {
      key: "hideSummaryFooter",
      label: "Hide Summary Footer",
      type: "boolean",
      defaultValue: !0,
      description: "Hide the statistics footer below the chart"
    }
  ]
}, ef = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  sunburstChartConfig: ho
}, Symbol.toStringTag, { value: "Module" }));
function kt(e) {
  return e != null && !isNaN(Number(e));
}
function Be(e) {
  if (e == null) return null;
  const t = typeof e == "string" ? parseFloat(e) : Number(e);
  return isNaN(t) ? null : t;
}
function Xr(e) {
  if (e == null) return "No data";
  const t = typeof e == "number" ? e : parseFloat(e);
  return isNaN(t) ? String(e) : Number.isInteger(t) ? t.toLocaleString() : parseFloat(t.toFixed(2)).toLocaleString();
}
function K(e, t, n) {
  if (e == null)
    return "No data";
  const r = typeof e == "number" ? e : parseFloat(String(e));
  if (isNaN(r))
    return String(e);
  if (!isFinite(r))
    return r > 0 ? "∞" : "-∞";
  const s = typeof navigator < "u" ? navigator.language : "en-US";
  if (!t)
    return Xr(e);
  const { unit: i, abbreviate: a = !0, decimals: l, customPrefix: u, customSuffix: c } = t;
  let d = r, h = "";
  if (a) {
    const f = Math.abs(r);
    f >= 1e9 ? (d = r / 1e9, h = "B") : f >= 1e6 ? (d = r / 1e6, h = "M") : f >= 1e3 && (d = r / 1e3, h = "K");
  }
  const p = l !== void 0 ? l : Number.isInteger(d) ? 0 : 2;
  switch (i) {
    case "currency": {
      const f = mo(s);
      if (a && h) {
        const b = new Intl.NumberFormat(s, {
          style: "currency",
          currency: f,
          minimumFractionDigits: p,
          maximumFractionDigits: p
        }).format(d), m = new Intl.NumberFormat(s, {
          style: "currency",
          currency: f
        }).formatToParts(d);
        return m[m.length - 1]?.type === "currency" ? b.replace(/(\s*[^\d\s]+)$/, h + "$1") : b + h;
      }
      return new Intl.NumberFormat(s, {
        style: "currency",
        currency: f,
        minimumFractionDigits: p,
        maximumFractionDigits: p
      }).format(d);
    }
    case "percent": {
      const f = Math.abs(d) <= 1 && !a ? d * 100 : d;
      return new Intl.NumberFormat(s, {
        minimumFractionDigits: p,
        maximumFractionDigits: p
      }).format(f) + h + "%";
    }
    case "custom": {
      const f = u || "", b = c || "", m = new Intl.NumberFormat(s, {
        minimumFractionDigits: p,
        maximumFractionDigits: p
      }).format(d);
      return f + m + h + b;
    }
    default:
      return new Intl.NumberFormat(s, {
        minimumFractionDigits: p,
        maximumFractionDigits: p
      }).format(d) + h;
  }
}
function mo(e) {
  const n = e.split("-")[1]?.toUpperCase();
  return {
    US: "USD",
    CA: "CAD",
    GB: "GBP",
    UK: "GBP",
    AU: "AUD",
    NZ: "NZD",
    EU: "EUR",
    DE: "EUR",
    FR: "EUR",
    IT: "EUR",
    ES: "EUR",
    NL: "EUR",
    BE: "EUR",
    AT: "EUR",
    IE: "EUR",
    PT: "EUR",
    FI: "EUR",
    JP: "JPY",
    CN: "CNY",
    KR: "KRW",
    IN: "INR",
    BR: "BRL",
    MX: "MXN",
    CH: "CHF",
    SE: "SEK",
    NO: "NOK",
    DK: "DKK",
    PL: "PLN",
    RU: "RUB",
    ZA: "ZAR",
    SG: "SGD",
    HK: "HKD",
    TW: "TWD",
    TH: "THB",
    MY: "MYR",
    PH: "PHP",
    ID: "IDR",
    VN: "VND",
    AE: "AED",
    SA: "SAR",
    IL: "ILS",
    TR: "TRY"
  }[n] || "USD";
}
function ne(e, t) {
  if (!e) return String(e || "Unknown");
  const n = String(e);
  if (n.match(/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}/)) {
    let r = n;
    n.includes(" ") && (r = n.replace(" ", "T").replace("+00", "Z").replace(/\+\d{2}:\d{2}$/, "Z")), !r.endsWith("Z") && !r.includes("+") && (r = r + "Z");
    const s = new Date(r);
    if (isNaN(s.getTime()))
      return n;
    const i = s.getUTCFullYear(), a = String(s.getUTCMonth() + 1).padStart(2, "0"), l = String(s.getUTCDate()).padStart(2, "0"), u = s.getUTCHours(), c = s.getUTCMinutes();
    if (t)
      switch (t.toLowerCase()) {
        case "year":
          return `${i}`;
        case "quarter": {
          const p = Math.floor(s.getUTCMonth() / 3) + 1;
          return `${i}-Q${p}`;
        }
        case "month":
          return `${i}-${a}`;
        case "week":
          return `${i}-${a}-${l}`;
        case "day":
          return `${i}-${a}-${l}`;
        case "hour":
          return `${i}-${a}-${l} ${String(u).padStart(2, "0")}:00`;
        case "minute":
          return `${i}-${a}-${l} ${String(u).padStart(2, "0")}:${String(c).padStart(2, "0")}`;
      }
    const d = s.getUTCSeconds(), h = s.getUTCMilliseconds();
    if (l === "01" && u === 0 && c === 0 && d === 0 && h === 0) {
      if (a === "01" || a === "04" || a === "07" || a === "10") {
        const p = Math.floor(s.getUTCMonth() / 3) + 1;
        return `${i}-Q${p}`;
      }
      return `${i}-${a}`;
    }
    return u === 0 && c === 0 && d === 0 && h === 0 ? `${i}-${a}-${l}` : c === 0 && d === 0 && h === 0 ? `${i}-${a}-${l} ${String(u).padStart(2, "0")}:00` : `${i}-${a}-${l} ${String(u).padStart(2, "0")}:${String(c).padStart(2, "0")}`;
  }
  return n;
}
function ge(e, t) {
  try {
    if (e?.timeDimensions) {
      const r = e.timeDimensions.find((s) => t === s.dimension || t.startsWith(s.dimension.replace(".", "_")) || t === `${s.dimension}_${s.granularity}`);
      if (r?.granularity)
        return r.granularity;
    }
    const n = t.match(/_([a-z]+)$/);
    if (n) {
      const r = n[1];
      if (["year", "quarter", "month", "week", "day", "hour", "minute", "second"].includes(r))
        return r;
    }
    return;
  } catch {
    return;
  }
}
function po(e, t, n, r, s = (i) => i) {
  if (!e || e.length === 0) return [];
  const i = ge(r, t);
  return e.map((a) => {
    const l = {
      name: ne(a[t], i) || a[t] || "Unknown"
    };
    return n.forEach((u) => {
      const c = s(u);
      l[c] = Be(a[u]);
    }), l;
  });
}
function ct(e, t, n, r, s, i = (a) => a) {
  if (!e || e.length === 0)
    return { data: [], seriesKeys: [], hasDimensions: !1 };
  const a = r || {}, l = [
    ...a.dimensions || [],
    ...a.timeDimensions?.map((f) => f.dimension) || []
  ], u = a.measures || [], c = n.filter((f) => u.includes(f)), d = (s || []).filter((f) => l.includes(f));
  if (d.length > 0) {
    const f = {};
    e.forEach((x) => {
      const y = ge(r, t), g = ne(x[t], y) || x[t] || "Unknown";
      f[g] || (f[g] = { name: String(g) }), c.forEach((k) => {
        const w = i(k), S = Be(x[k]);
        if (S !== null) {
          const C = f[g][w];
          f[g][w] = C == null ? S : C + S;
        } else w in f[g] || (f[g][w] = null);
      }), d.forEach((k) => {
        const w = x[k];
        if (w != null) {
          const S = String(w), C = c[0] || u.find(
            (F) => F.includes("totalCost") || F.includes("count") || F.includes("sum")
          ) || u[0];
          if (C) {
            const F = Be(x[C]);
            if (F !== null) {
              const M = f[g][S];
              f[g][S] = M == null ? F : M + F;
            } else S in f[g] || (f[g][S] = null);
          }
        }
      });
    });
    const b = Object.values(f), m = Array.from(new Set(
      e.flatMap(
        (x) => d.map((y) => {
          const g = x[y];
          return g != null ? String(g) : null;
        }).filter((y) => y !== null)
      )
    ));
    return {
      data: b,
      seriesKeys: m,
      hasDimensions: !0
    };
  }
  const h = po(e, t, n, r, i), p = n.map((f) => i(f));
  return {
    data: h,
    seriesKeys: p,
    hasDimensions: !1
  };
}
function yo() {
  const e = typeof navigator < "u" ? navigator.language : "en-US";
  return new Intl.NumberFormat(e, {
    style: "currency",
    currency: xo(e),
    currencyDisplay: "narrowSymbol"
  }).format(0).replace(/[\d.,\s]/g, "").trim() || "$";
}
function xo(e) {
  const n = e.split("-")[1]?.toUpperCase();
  return {
    US: "USD",
    CA: "CAD",
    GB: "GBP",
    UK: "GBP",
    AU: "AUD",
    NZ: "NZD",
    EU: "EUR",
    DE: "EUR",
    FR: "EUR",
    IT: "EUR",
    ES: "EUR",
    NL: "EUR",
    BE: "EUR",
    AT: "EUR",
    IE: "EUR",
    PT: "EUR",
    FI: "EUR",
    JP: "JPY",
    CN: "CNY",
    KR: "KRW",
    IN: "INR",
    BR: "BRL",
    MX: "MXN",
    CH: "CHF",
    SE: "SEK",
    NO: "NOK",
    DK: "DKK",
    PL: "PLN",
    RU: "RUB",
    ZA: "ZAR",
    SG: "SGD",
    HK: "HKD",
    TW: "TWD",
    TH: "THB",
    MY: "MYR",
    PH: "PHP",
    ID: "IDR",
    VN: "VND",
    AE: "AED",
    SA: "SAR",
    IL: "ILS",
    TR: "TRY"
  }[n] || "USD";
}
function tf({
  value: e,
  onChange: t,
  axisLabel: n,
  previewValue: r = 125e4
}) {
  const s = q(() => e || {}, [e]), i = q(() => yo(), []), a = q(() => K(r, s), [r, s]), l = (c) => {
    t({ ...s, ...c });
  }, u = [
    { value: "currency", label: i },
    { value: "percent", label: "%" },
    { value: "number", label: "#" },
    { value: "custom", label: "Custom" }
  ];
  return /* @__PURE__ */ N("div", { className: "space-y-3 pb-4", children: [
    /* @__PURE__ */ o(Ka, { children: n }),
    /* @__PURE__ */ N("div", { className: "space-y-1", children: [
      /* @__PURE__ */ o("label", { className: "text-xs text-dc-text-secondary", children: "Label" }),
      /* @__PURE__ */ o(
        "input",
        {
          type: "text",
          value: s.label || "",
          onChange: (c) => l({ label: c.target.value || void 0 }),
          placeholder: "Auto-generated label",
          className: "w-full px-2 py-1 text-sm border border-dc-border rounded-sm focus:ring-dc-accent focus:border-dc-accent bg-dc-surface text-dc-text"
        }
      )
    ] }),
    /* @__PURE__ */ N("div", { className: "space-y-1", children: [
      /* @__PURE__ */ o("label", { className: "text-xs text-dc-text-secondary", children: "Unit" }),
      /* @__PURE__ */ o("div", { className: "flex border border-dc-border rounded-sm overflow-hidden", children: u.map((c) => /* @__PURE__ */ o(
        "button",
        {
          type: "button",
          onClick: () => l({ unit: c.value }),
          className: `flex-1 px-2 py-1.5 text-sm font-medium transition-colors ${s.unit === c.value ? "bg-dc-primary text-white" : "bg-dc-surface text-dc-text hover:bg-dc-border"}`,
          children: c.label
        },
        c.value
      )) })
    ] }),
    s.unit === "custom" && /* @__PURE__ */ N("div", { className: "flex gap-2", children: [
      /* @__PURE__ */ N("div", { className: "flex-1 space-y-1", children: [
        /* @__PURE__ */ o("label", { className: "text-xs text-dc-text-secondary", children: "Prefix" }),
        /* @__PURE__ */ o(
          "input",
          {
            type: "text",
            value: s.customPrefix || "",
            onChange: (c) => l({ customPrefix: c.target.value || void 0 }),
            placeholder: "e.g., $",
            className: "w-full px-2 py-1 text-sm border border-dc-border rounded-sm focus:ring-dc-accent focus:border-dc-accent bg-dc-surface text-dc-text"
          }
        )
      ] }),
      /* @__PURE__ */ N("div", { className: "flex-1 space-y-1", children: [
        /* @__PURE__ */ o("label", { className: "text-xs text-dc-text-secondary", children: "Suffix" }),
        /* @__PURE__ */ o(
          "input",
          {
            type: "text",
            value: s.customSuffix || "",
            onChange: (c) => l({ customSuffix: c.target.value || void 0 }),
            placeholder: "e.g., units",
            className: "w-full px-2 py-1 text-sm border border-dc-border rounded-sm focus:ring-dc-accent focus:border-dc-accent bg-dc-surface text-dc-text"
          }
        )
      ] })
    ] }),
    /* @__PURE__ */ N("div", { className: "space-y-1", children: [
      /* @__PURE__ */ o("label", { className: "text-xs text-dc-text-secondary", children: "Abbreviation" }),
      /* @__PURE__ */ N("div", { className: "flex border border-dc-border rounded-sm overflow-hidden", children: [
        /* @__PURE__ */ o(
          "button",
          {
            type: "button",
            onClick: () => l({ abbreviate: !0 }),
            className: `flex-1 px-3 py-1.5 text-sm font-medium transition-colors ${s.abbreviate !== !1 ? "bg-dc-primary text-white" : "bg-dc-surface text-dc-text hover:bg-dc-border"}`,
            children: "Yes"
          }
        ),
        /* @__PURE__ */ o(
          "button",
          {
            type: "button",
            onClick: () => l({ abbreviate: !1 }),
            className: `flex-1 px-3 py-1.5 text-sm font-medium transition-colors ${s.abbreviate === !1 ? "bg-dc-primary text-white" : "bg-dc-surface text-dc-text hover:bg-dc-border"}`,
            children: "No"
          }
        )
      ] })
    ] }),
    /* @__PURE__ */ N("div", { className: "space-y-1", children: [
      /* @__PURE__ */ o("label", { className: "text-xs text-dc-text-secondary", children: "Decimals" }),
      /* @__PURE__ */ N("div", { className: "flex gap-2", children: [
        /* @__PURE__ */ o(
          "button",
          {
            type: "button",
            onClick: () => {
              const c = s.decimals ?? 2;
              c > 0 && l({ decimals: c - 1 });
            },
            disabled: (s.decimals ?? 2) <= 0,
            className: "flex-1 px-3 py-2 text-sm border border-dc-border rounded-sm bg-dc-surface text-dc-text hover:bg-dc-border disabled:opacity-40 disabled:cursor-not-allowed transition-colors",
            children: "← .0"
          }
        ),
        /* @__PURE__ */ o(
          "button",
          {
            type: "button",
            onClick: () => {
              const c = s.decimals ?? 2;
              c < 4 && l({ decimals: c + 1 });
            },
            disabled: (s.decimals ?? 2) >= 4,
            className: "flex-1 px-3 py-2 text-sm border border-dc-border rounded-sm bg-dc-surface text-dc-text hover:bg-dc-border disabled:opacity-40 disabled:cursor-not-allowed transition-colors",
            children: ".00 →"
          }
        )
      ] })
    ] }),
    /* @__PURE__ */ N("div", { className: "space-y-1", children: [
      /* @__PURE__ */ o("label", { className: "text-xs text-dc-text-secondary", children: "Preview" }),
      /* @__PURE__ */ o("div", { className: "text-sm font-mono text-dc-text", children: a })
    ] })
  ] });
}
function ke() {
  const e = Rt(kn);
  if (!e)
    throw new Error("useCubeFieldLabel must be used within CubeProvider");
  return q(() => e.getFieldLabel, [e.getFieldLabel]);
}
function nf(e) {
  return typeof window > "u" ? "" : getComputedStyle(document.documentElement).getPropertyValue(`--dc-${e}`).trim();
}
function go(e, t) {
  typeof window > "u" || document.documentElement.style.setProperty(`--dc-${e}`, t);
}
function rf(e) {
  typeof window > "u" || Object.entries(e.colors).forEach(([t, n]) => {
    if (n) {
      const r = t.replace(/[A-Z]/g, (s) => `-${s.toLowerCase()}`);
      go(r, n);
    }
  });
}
function sf() {
  if (typeof window > "u") return;
  const e = document.documentElement.style;
  Array.from(e).forEach((n) => {
    n.startsWith("--dc-") && e.removeProperty(n);
  });
}
function Ge() {
  if (typeof window > "u") return "light";
  const e = localStorage.getItem("theme");
  if (e === "dark" || e === "neon" || e === "light")
    return e;
  const t = document.documentElement.getAttribute("data-theme");
  return t === "dark" || t === "neon" ? t : document.documentElement.classList.contains("dark") || document.body.classList.contains("dark") ? "dark" : document.documentElement.classList.contains("neon") || document.body.classList.contains("neon") ? "neon" : window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
}
function bo(e) {
  typeof window > "u" || (document.documentElement.classList.remove("dark", "neon"), document.documentElement.setAttribute("data-theme", e), (e === "dark" || e === "neon") && document.documentElement.classList.add(e), localStorage.setItem("theme", e));
}
function af() {
  const e = Ge();
  return e === "dark" || e === "neon";
}
function Zr(e) {
  if (typeof window > "u") return () => {
  };
  const t = new MutationObserver(() => {
    e(Ge());
  });
  t.observe(document.documentElement, {
    attributes: !0,
    attributeFilter: ["class", "data-theme"]
  });
  const n = window.matchMedia("(prefers-color-scheme: dark)"), r = () => e(Ge());
  return n.addEventListener("change", r), () => {
    t.disconnect(), n.removeEventListener("change", r);
  };
}
const of = {
  light: {
    name: "light",
    colors: {
      surface: "#ffffff",
      surfaceSecondary: "#f9fafb",
      text: "#111827",
      textSecondary: "#374151",
      textMuted: "#6b7280",
      border: "#e5e7eb",
      primary: "#3b82f6",
      primaryHover: "#2563eb"
    }
  },
  dark: {
    name: "dark",
    colors: {
      surface: "#1e293b",
      surfaceSecondary: "#334155",
      text: "#f1f5f9",
      textSecondary: "#e2e8f0",
      textMuted: "#cbd5e1",
      border: "#475569",
      primary: "#60a5fa",
      primaryHover: "#3b82f6"
    }
  },
  neon: {
    name: "neon",
    colors: {
      surface: "#0a0118",
      surfaceSecondary: "#1a0f2e",
      surfaceTertiary: "#2a1f3e",
      text: "#ffffff",
      textSecondary: "#e0e0ff",
      textMuted: "#b0b0d0",
      border: "#ff00ff",
      borderSecondary: "#00ffff",
      primary: "#00ffff",
      primaryHover: "#00cccc",
      primaryContent: "#000000",
      success: "#00ff00",
      warning: "#ffff00",
      error: "#ff0066",
      info: "#00ffff",
      danger: "#ff1493"
    }
  }
}, yt = {
  listeners: /* @__PURE__ */ new Set(),
  subscribe(e) {
    return this.listeners.add(e), () => this.listeners.delete(e);
  },
  notify() {
    this.listeners.forEach((e) => e());
  }
};
Zr(() => {
  yt.notify();
});
function vo() {
  const e = Ts(
    yt.subscribe.bind(yt),
    Ge,
    // Client-side snapshot
    Ge
    // Server-side snapshot (SSR)
  ), t = Ve((n) => {
    bo(n), yt.notify();
  }, []);
  return { theme: e, setTheme: t };
}
const Q = [
  "#3b82f6",
  // blue
  "#10b981",
  // green
  "#f59e0b",
  // yellow
  "#ef4444",
  // red
  "#8b5cf6",
  // purple
  "#f97316",
  // orange
  "#06b6d4",
  // cyan
  "#84cc16"
  // lime
], Ie = [
  "#440154",
  // dark purple
  "#414487",
  // purple-blue
  "#2a788e",
  // teal
  "#22a884",
  // green-teal  
  "#7ad151",
  // green
  "#fde725"
  // yellow
], Jn = "#10b981", wo = "#ef4444", Xe = {
  top: 5,
  right: 30,
  left: 20,
  bottom: 5
};
function No(e, t) {
  const n = new Date(e);
  switch (t.toLowerCase()) {
    case "day":
      n.setHours(23, 59, 59, 999);
      break;
    case "week": {
      const s = 6 - n.getDay();
      n.setDate(n.getDate() + s), n.setHours(23, 59, 59, 999);
      break;
    }
    case "month":
      n.setMonth(n.getMonth() + 1, 0), n.setHours(23, 59, 59, 999);
      break;
    case "quarter": {
      const r = n.getMonth(), s = Math.floor(r / 3) * 3 + 2;
      n.setMonth(s + 1, 0), n.setHours(23, 59, 59, 999);
      break;
    }
    case "year":
      n.setMonth(11, 31), n.setHours(23, 59, 59, 999);
      break;
    default:
      n.setHours(23, 59, 59, 999);
  }
  return n;
}
function So(e, t, n) {
  if (!e || !t || !n)
    return !0;
  const r = e[t];
  if (!r)
    return !0;
  const s = new Date(r);
  return isNaN(s.getTime()) ? !0 : No(s, n) <= /* @__PURE__ */ new Date();
}
function Ao(e, t) {
  if (!e?.timeDimensions || e.timeDimensions.length === 0)
    return null;
  if (t) {
    const r = e.timeDimensions.find(
      (s) => s.dimension === t || s.dimension?.includes(t) || t?.includes(s.dimension)
    );
    if (r?.granularity)
      return r.granularity;
  }
  return e.timeDimensions[0]?.granularity || null;
}
function Jr(e, t, n, r, s = !1) {
  const i = {
    filteredData: e,
    excludedIncompletePeriod: !1,
    skippedLastPeriod: !1,
    granularity: null
  };
  if (e.length < 2)
    return i;
  const a = Ao(n, t);
  if (s)
    return {
      filteredData: e.slice(0, -1),
      excludedIncompletePeriod: !1,
      skippedLastPeriod: !0,
      granularity: a
    };
  if (!r)
    return { ...i, granularity: a };
  if (!t)
    return { ...i, granularity: a };
  if (!n?.timeDimensions || n.timeDimensions.length === 0)
    return { ...i, granularity: a };
  if (!a)
    return i;
  const l = e[e.length - 1];
  return So(l, t, a) ? { ...i, granularity: a } : {
    filteredData: e.slice(0, -1),
    excludedIncompletePeriod: !0,
    skippedLastPeriod: !1,
    granularity: a
  };
}
function ko(e) {
  if (!e) return [];
  const t = [];
  return e.dimensions && t.push(...e.dimensions), e.timeDimensions && e.timeDimensions.forEach((n) => {
    t.includes(n.dimension) || t.push(n.dimension);
  }), e.measures && t.push(...e.measures), t;
}
function Fo(e, t) {
  if (!e?.timeDimensions?.length) return null;
  const n = e.timeDimensions.find((i) => i.granularity);
  if (!n?.granularity || !e.measures?.length) return null;
  let r, s;
  if (t && t.length > 0) {
    r = t.filter((a) => !(a === n.dimension || e.measures?.includes(a)));
    const i = t.filter(
      (a) => e.measures?.includes(a)
    );
    s = i.length > 0 ? i : e.measures;
  } else
    r = e.dimensions || [], s = e.measures;
  return s.length === 0 ? null : {
    timeDimension: n.dimension,
    granularity: n.granularity,
    dimensions: r,
    measures: s
  };
}
function To(e, t, n) {
  const r = /* @__PURE__ */ new Set();
  return e.forEach((s) => {
    const i = s[t];
    if (i != null) {
      const a = ne(i, n);
      r.add(a);
    }
  }), Array.from(r).sort();
}
function Mo(e, t, n) {
  const r = [];
  return e.measures.length > 1 && r.push({
    key: "__measure__",
    label: "Measure",
    isTimeColumn: !1,
    isMeasureColumn: !0
  }), e.dimensions.forEach((s) => {
    r.push({
      key: s,
      label: n(s),
      isTimeColumn: !1
    });
  }), t.forEach((s) => {
    r.push({
      key: s,
      label: s,
      isTimeColumn: !0
    });
  }), r;
}
function Co(e, t) {
  const n = /* @__PURE__ */ new Map();
  return e.forEach((r) => {
    const s = t.dimensions.length > 0 ? t.dimensions.map((a) => String(r[a] ?? "")).join("|") : "__all__";
    n.has(s) || n.set(s, /* @__PURE__ */ new Map());
    const i = r[t.timeDimension];
    if (i != null) {
      const a = ne(i, t.granularity);
      n.get(s).set(a, r);
    }
  }), n;
}
function _o(e, t, n, r) {
  const s = Co(e, t), i = Array.from(s.keys()), a = [], l = t.measures.length, u = i.length;
  return t.measures.forEach((c) => {
    i.forEach((d, h) => {
      const p = s.get(d), f = l > 1 ? `${c}|${d}` : d, b = {}, m = d === "__all__" ? [] : d.split("|");
      t.dimensions.forEach((g, k) => {
        b[g] = m[k] ?? "";
      }), l > 1 && (b.__measure__ = r(c)), n.forEach((g) => {
        const k = p.get(g);
        b[g] = k?.[c] ?? null;
      });
      const x = h === 0, y = x && l > 1 ? u : void 0;
      a.push({
        id: f,
        measureField: c,
        values: b,
        isFirstInGroup: x,
        dimensionRowSpan: y
      });
    });
  }), a;
}
function Do(e, t, n, r) {
  if (!e || e.length === 0)
    return { isPivoted: !0, columns: [], rows: [] };
  const s = To(e, t.timeDimension, t.granularity), i = Mo(t, s, n), a = _o(e, t, s, n);
  return { isPivoted: !0, columns: i, rows: a };
}
function $o(e, t) {
  if (t?.cubes)
    for (const n of t.cubes) {
      const r = n.measures.find((s) => s.name === e);
      if (r)
        return r.type;
    }
}
function jt(e) {
  return e.length > 0 && "__periodIndex" in e[0];
}
function es(e) {
  if (!jt(e)) return [];
  const t = /* @__PURE__ */ new Set();
  for (const n of e)
    n.__period && t.add(n.__period);
  return Array.from(t);
}
function Oo(e) {
  if (!jt(e)) return [];
  const t = /* @__PURE__ */ new Set();
  for (const n of e)
    typeof n.__periodIndex == "number" && t.add(n.__periodIndex);
  return Array.from(t).sort((n, r) => n - r);
}
function xt(e, t) {
  return t === 0 ? "Current" : "Prior";
}
function Ro(e, t, n) {
  if (e.length === 0) return [];
  const r = ["__period", "__periodIndex", "__periodDayIndex"], s = e[0], i = [];
  for (const a of Object.keys(s))
    !t.includes(a) && a !== n && !r.includes(a) && i.push(a);
  return i;
}
function Eo(e, t) {
  const n = /* @__PURE__ */ new Map();
  for (const r of t)
    n.set(r, /* @__PURE__ */ new Set());
  for (const r of e)
    for (const s of t)
      r[s] !== void 0 && r[s] !== null && n.get(s).add(r[s]);
  return n;
}
function Lo(e, t, n, r) {
  if (!jt(e))
    return { data: e, seriesKeys: t, xAxisKey: n };
  const s = es(e), i = Oo(e), a = Ro(e, t, n), l = a.length > 0, u = l ? Eo(e, a) : null, c = /* @__PURE__ */ new Map();
  for (const p of e) {
    const f = p.__periodDayIndex, b = p.__periodIndex;
    c.has(f) || c.set(f, {
      __periodDayIndex: f,
      // Store the date from the first period (index 0) for reference
      __displayDate: b === 0 ? p[n] : void 0
    });
    const m = c.get(f);
    !m.__displayDate && p[n] && (m.__displayDate = p[n]);
    let x = "";
    l && (x = a.map((k) => {
      const w = p[k];
      return r ? r(String(w)) : String(w);
    }).join(" / "));
    const y = xt(s[b] || "", b);
    for (const g of t) {
      const k = r ? r(g) : g, w = x ? `${x} - ${k} (${y})` : `${k} (${y})`;
      m[w] = p[g];
    }
  }
  const d = Array.from(c.values()).sort((p, f) => p.__periodDayIndex - f.__periodDayIndex), h = [];
  if (l && u) {
    const p = Io(
      a,
      u,
      r
    );
    for (const f of p)
      for (const b of t) {
        const m = r ? r(b) : b;
        for (let x = 0; x < i.length; x++) {
          const y = xt(s[x] || "", x);
          h.push(`${f} - ${m} (${y})`);
        }
      }
  } else
    for (const p of t) {
      const f = r ? r(p) : p;
      for (let b = 0; b < i.length; b++) {
        const m = xt(s[b] || "", b);
        h.push(`${f} (${m})`);
      }
    }
  return {
    data: d,
    seriesKeys: h,
    xAxisKey: "__periodDayIndex"
  };
}
function Io(e, t, n) {
  if (e.length === 0) return [];
  if (e.length === 1) {
    const a = e[0];
    return Array.from(t.get(a) || []).map((u) => n ? n(String(u)) : String(u));
  }
  const r = [], s = e.map(
    (a) => Array.from(t.get(a) || [])
  );
  function i(a, l) {
    if (a === s.length) {
      const u = l.map(
        (c) => n ? n(String(c)) : String(c)
      );
      r.push(u.join(" / "));
      return;
    }
    for (const u of s[a])
      i(a + 1, [...l, u]);
  }
  return i(0, []), r;
}
function Po(e, t) {
  if (t.length < 2) return !1;
  for (let n = 1; n < t.length; n++) {
    const r = xt(t[n], n);
    if (e.includes(`(${r})`))
      return !0;
  }
  return e.includes("(Prior");
}
function zo(e = "dashed") {
  switch (e) {
    case "solid":
      return;
    case "dashed":
      return "5 5";
    case "dotted":
      return "2 2";
    default:
      return "5 5";
  }
}
function Re({ children: e, height: t = "100%" }) {
  const n = be(null), [r, s] = J(!1), [i, a] = J({ width: 0, height: 0 });
  xn(() => {
    let l = !0, u = null;
    const c = () => {
      if (!l || !n.current) return;
      const d = n.current.getBoundingClientRect(), h = Math.max(n.current.clientWidth, d.width), p = Math.max(n.current.clientHeight, d.height);
      h > 0 && p > 0 && (a({ width: h, height: p }), s(!0));
    };
    return u = new ResizeObserver((d) => {
      for (const h of d) {
        const { width: p, height: f } = h.contentRect;
        p > 0 && f > 0 && (a({ width: p, height: f }), r || s(!0));
      }
    }), n.current && (u.observe(n.current), c()), () => {
      l = !1, u?.disconnect();
    };
  }, [r]);
  try {
    if (t === "100%")
      return /* @__PURE__ */ o(
        "div",
        {
          ref: n,
          className: "w-full h-full flex-1 flex flex-col relative",
          style: { minHeight: "250px", minWidth: "100px", overflow: "hidden" },
          children: r && i.width > 0 && i.height > 0 ? /* @__PURE__ */ o(
            tt,
            {
              width: i.width,
              height: i.height - 16,
              debounce: 100,
              style: { marginTop: "16px" },
              children: e
            }
          ) : /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full h-full", children: /* @__PURE__ */ o(Zn, { size: "sm" }) })
        }
      );
    const l = {
      height: typeof t == "number" ? `${t}px` : t,
      width: "100%",
      minHeight: "200px",
      minWidth: "100px"
    };
    return /* @__PURE__ */ o(
      "div",
      {
        ref: n,
        className: "w-full flex flex-col relative",
        style: { ...l, overflow: "hidden" },
        children: r && i.width > 0 && i.height > 0 ? /* @__PURE__ */ o(
          tt,
          {
            width: i.width,
            height: i.height - 16,
            debounce: 100,
            style: { marginTop: "16px" },
            children: e
          }
        ) : /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full h-full", children: /* @__PURE__ */ o(Zn, { size: "sm" }) })
      }
    );
  } catch (l) {
    return /* @__PURE__ */ N(
      "div",
      {
        className: "flex flex-col items-center justify-center w-full h-full p-4 text-center border border-dashed rounded-lg",
        style: { height: t, borderColor: "var(--dc-border)", backgroundColor: "var(--dc-surface)" },
        children: [
          /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1 text-dc-text-muted", children: "Unable to display chart" }),
          /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: l instanceof Error ? l.message : "Failed to create responsive container" })
        ]
      }
    );
  }
}
const jo = (e, t) => e == null ? ["No data", t] : [Xr(e), t];
function Ke({ formatter: e, labelFormatter: t }) {
  return /* @__PURE__ */ o(
    lt,
    {
      formatter: e || jo,
      labelFormatter: t,
      contentStyle: {
        backgroundColor: "white",
        border: "1px solid #e5e7eb",
        borderRadius: "0.5rem",
        fontSize: "0.875rem",
        color: "#1f2937",
        boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",
        padding: "8px 12px"
      }
    }
  );
}
function Vt(e) {
  if (!e || typeof e != "string")
    return [];
  const t = e.trim();
  if (!t)
    return [];
  try {
    const n = t.split(",").map((r) => r.trim()).filter((r) => r !== "").map((r) => {
      const s = parseFloat(r);
      if (isNaN(s))
        throw new Error(`Invalid numeric value: ${r}`);
      return s;
    });
    return n.length > 0 ? n : [];
  } catch (n) {
    return console.warn("Failed to parse target values:", n), [];
  }
}
function Fn(e, t) {
  if (e.length === 0 || t <= 0)
    return [];
  if (e.length === 1)
    return new Array(t).fill(e[0]);
  const n = [], r = Math.floor(t / e.length), s = t % e.length;
  let i = 0;
  for (let a = 0; a < e.length; a++) {
    const l = r + (a < s ? 1 : 0);
    for (let u = 0; u < l; u++)
      n[i++] = e[a];
  }
  return n;
}
function Vo(e, t) {
  return t === 0 ? e === 0 ? 0 : e > 0 ? 100 : -100 : (e - t) / t * 100;
}
function Ho(e, t = 1) {
  return `${e >= 0 ? "+" : ""}${e.toFixed(t)}%`;
}
const Uo = ie.memo(function({
  data: t,
  chartConfig: n,
  displayConfig: r = {},
  queryObject: s,
  height: i = "100%",
  colorPalette: a
}) {
  const [l, u] = J(null), c = ke(), d = r?.stackType ?? (r?.stacked ? "normal" : "none"), h = d !== "none", p = d === "percent", f = {
    showLegend: r?.showLegend ?? !0,
    showGrid: r?.showGrid ?? !0,
    showTooltip: r?.showTooltip ?? !0
  }, b = r?.leftYAxisFormat, m = r?.rightYAxisFormat, { xAxisField: x, yAxisFields: y, seriesFields: g, configError: k } = q(() => {
    let $, I = [], z = [], j = null;
    return n?.xAxis && n?.yAxis ? ($ = Array.isArray(n.xAxis) ? n.xAxis[0] : n.xAxis, I = Array.isArray(n.yAxis) ? n.yAxis : [n.yAxis], z = n.series || []) : n?.x && n?.y ? ($ = n.x, I = Array.isArray(n.y) ? n.y : [n.y]) : j = "Invalid or missing chart axis configuration", !j && (!$ || !I || I.length === 0) && (j = "Missing required X-axis or Y-axis fields"), { xAxisField: $, yAxisFields: I, seriesFields: z, configError: j };
  }, [n]), { data: w, seriesKeys: S } = q(() => k || !t || t.length === 0 || !x ? { data: [], seriesKeys: [] } : ct(
    t,
    x,
    y,
    s,
    g,
    c
  ), [t, x, y, s, g, c, k]), C = q(
    () => n?.yAxisAssignment || {},
    [n?.yAxisAssignment]
  ), F = q(() => {
    const $ = {};
    return y.forEach((I) => {
      const z = c(I);
      $[z] = I;
    }), $;
  }, [y, c]), M = y.some(($) => C[$] === "right"), T = y.filter(($) => (C[$] || "left") === "left"), A = y.filter(($) => C[$] === "right"), { chartData: v, skippedCount: O } = q(() => {
    if (w.length === 0 || S.length === 0)
      return { chartData: [], skippedCount: 0 };
    const $ = w.filter((z) => S.some((j) => kt(z[j]))), I = w.length - $.length;
    return { chartData: $, skippedCount: I };
  }, [w, S]);
  try {
    if (!t || t.length === 0)
      return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
        /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
        /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in bar chart" })
      ] }) });
    if (k)
      return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
        /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
        /* @__PURE__ */ o("div", { className: "text-xs", children: k })
      ] }) });
    const $ = h && !M, I = p && !M, z = I ? "expand" : void 0, j = S.length === 1 && v.some((D) => {
      const Y = D[S[0]];
      return typeof Y == "number" && Y < 0;
    }), G = f.showLegend, _ = {
      ...Xe,
      left: 40,
      // Space for left Y-axis label
      right: M ? 40 : 20
      // Extra space for right Y-axis label if needed
    }, L = Vt(r?.target || ""), B = Fn(L, v.length);
    let E = v;
    return B.length > 0 && (E = v.map((D, Y) => ({
      ...D,
      __target: B[Y] || null
    }))), !v || v.length === 0 ? /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
      /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
      /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No valid data points for bar chart after transformation" })
    ] }) }) : /* @__PURE__ */ N("div", { className: "relative w-full", style: { height: i }, children: [
      /* @__PURE__ */ o(Re, { height: O > 0 ? "calc(100% - 20px)" : "100%", children: /* @__PURE__ */ N(Cr, { data: E, margin: _, stackOffset: z, children: [
        f.showGrid && /* @__PURE__ */ o(Et, { strokeDasharray: "3 3" }),
        /* @__PURE__ */ o(
          Lt,
          {
            dataKey: "name",
            tick: { fontSize: 12 },
            angle: -45,
            textAnchor: "end",
            height: 60
          }
        ),
        /* @__PURE__ */ o(
          He,
          {
            yAxisId: "left",
            orientation: "left",
            tick: { fontSize: 12 },
            tickFormatter: I ? (D) => `${(D * 100).toFixed(0)}%` : b ? (D) => K(D, b) : void 0,
            domain: I ? [0, 1] : void 0,
            label: I ? void 0 : T.length > 0 ? {
              value: b?.label || c(T[0]),
              angle: -90,
              position: "left",
              style: { textAnchor: "middle", fontSize: "12px" }
            } : void 0
          }
        ),
        M && /* @__PURE__ */ o(
          He,
          {
            yAxisId: "right",
            orientation: "right",
            tick: { fontSize: 12 },
            tickFormatter: m ? (D) => K(D, m) : void 0,
            label: A.length > 0 ? {
              value: m?.label || c(A[0]),
              angle: 90,
              position: "right",
              style: { textAnchor: "middle", fontSize: "12px" }
            } : void 0
          }
        ),
        f.showTooltip && /* @__PURE__ */ o(
          Ke,
          {
            formatter: (D, Y) => {
              if (D == null)
                return ["No data", Y];
              if (Y === "Target")
                return [K(D, b), "Target Value"];
              if (I && typeof D == "number")
                return [`${(D * 100).toFixed(1)}%`, Y];
              const V = F[Y], re = (V && C[V] === "right" ? "right" : "left") === "right" ? m : b;
              return [K(D, re), Y];
            }
          }
        ),
        G && /* @__PURE__ */ o(
          Qe,
          {
            wrapperStyle: { fontSize: "12px", paddingTop: "25px" },
            iconType: "rect",
            iconSize: 8,
            layout: "horizontal",
            align: "center",
            verticalAlign: "bottom",
            onMouseEnter: (D) => u(String(D.dataKey || "")),
            onMouseLeave: () => u(null)
          }
        ),
        S.map((D, Y) => {
          const V = F[D], W = V && C[V] === "right" ? "right" : "left";
          return /* @__PURE__ */ o(
            Ms,
            {
              dataKey: D,
              yAxisId: W,
              stackId: $ ? "stack" : void 0,
              fill: j ? Jn : a?.colors && a.colors[Y % a.colors.length] || Q[Y % Q.length],
              fillOpacity: l ? l === D ? 1 : 0.3 : 1,
              children: j && v.map((re, pe) => {
                const ye = re[D], Fe = typeof ye == "number" && ye < 0 ? wo : Jn;
                return /* @__PURE__ */ o(
                  It,
                  {
                    fill: Fe,
                    fillOpacity: l ? l === D ? 1 : 0.3 : 1
                  },
                  `cell-${pe}`
                );
              })
            },
            D
          );
        }),
        B.length > 0 && /* @__PURE__ */ N(gn, { children: [
          /* @__PURE__ */ o(
            ze,
            {
              type: "monotone",
              dataKey: "__target",
              yAxisId: "left",
              stroke: "#ffffff",
              strokeWidth: 2,
              dot: !1,
              activeDot: !1,
              connectNulls: !1
            }
          ),
          /* @__PURE__ */ o(
            ze,
            {
              type: "monotone",
              dataKey: "__target",
              yAxisId: "left",
              name: "Target",
              stroke: "#8B5CF6",
              strokeWidth: 2,
              strokeDasharray: "2 3",
              dot: !1,
              activeDot: !1,
              connectNulls: !1
            }
          )
        ] })
      ] }) }),
      O > 0 && /* @__PURE__ */ N("div", { className: "text-xs text-dc-text-muted text-center mt-1", children: [
        O,
        " data point",
        O !== 1 ? "s" : "",
        " with no values hidden"
      ] })
    ] });
  } catch ($) {
    return /* @__PURE__ */ o("div", { className: "flex flex-col items-center justify-center w-full text-dc-error p-4", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
      /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Bar Chart Error" }),
      /* @__PURE__ */ o("div", { className: "text-xs mb-2", children: $ instanceof Error ? $.message : "Unknown rendering error" }),
      /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
    ] }) });
  }
}), lf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: Uo
}, Symbol.toStringTag, { value: "Module" })), Yo = ie.memo(function({
  data: t,
  chartConfig: n,
  displayConfig: r = {},
  queryObject: s,
  height: i = "100%",
  colorPalette: a
}) {
  const [l, u] = J(null), c = ke(), d = q(() => n?.yAxis ? Array.isArray(n.yAxis) ? n.yAxis : [n.yAxis] : n?.y ? Array.isArray(n.y) ? n.y : [n.y] : [], [n?.yAxis, n?.y]), h = q(
    () => n?.yAxisAssignment || {},
    [n?.yAxisAssignment]
  ), p = q(() => {
    const f = {};
    return d.forEach((b) => {
      const m = c(b);
      f[m] = b;
    }), f;
  }, [d, c]);
  try {
    const f = {
      showLegend: r?.showLegend ?? !0,
      showGrid: r?.showGrid ?? !0,
      showTooltip: r?.showTooltip ?? !0,
      connectNulls: r?.connectNulls ?? !1
    }, b = r?.leftYAxisFormat, m = r?.rightYAxisFormat;
    if (!t || t.length === 0)
      return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
        /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
        /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in line chart" })
      ] }) });
    let x, y = [];
    if (n?.xAxis && n?.yAxis)
      x = Array.isArray(n.xAxis) ? n.xAxis[0] : n.xAxis, y = n.series || [];
    else if (n?.x && n?.y)
      x = n.x;
    else
      return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
        /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
        /* @__PURE__ */ o("div", { className: "text-xs", children: "Invalid or missing chart axis configuration" })
      ] }) });
    if (!x || d.length === 0)
      return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
        /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
        /* @__PURE__ */ o("div", { className: "text-xs", children: "Missing required X-axis or Y-axis fields" })
      ] }) });
    const g = jt(t), k = r?.priorPeriodStyle || "dashed", w = r?.priorPeriodOpacity ?? 0.5, S = g ? es(t) : [];
    let C, F, M = "name";
    if (g) {
      const _ = Lo(t, d, x, c);
      C = _.data, F = _.seriesKeys, M = "__periodDayIndex";
    } else {
      const _ = ct(
        t,
        x,
        d,
        s,
        y,
        c
      );
      C = _.data, F = _.seriesKeys;
    }
    const T = (_) => {
      if (p[_])
        return p[_];
      const B = _.replace(/\s*\((Current|Prior)\)$/, "").split(" - "), E = B[B.length - 1];
      return p[E];
    }, A = d.some((_) => h[_] === "right"), v = d.filter((_) => (h[_] || "left") === "left"), O = d.filter((_) => h[_] === "right"), $ = f.showLegend, I = {
      ...Xe,
      left: 40,
      // Space for left Y-axis label
      right: A ? 40 : 20
      // Extra space for right Y-axis label if needed
    }, z = Vt(r?.target || ""), j = Fn(z, C.length);
    let G = C;
    return j.length > 0 && (G = C.map((_, L) => ({
      ..._,
      __target: j[L] || null
    }))), !C || C.length === 0 ? /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
      /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
      /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No valid data points for line chart after transformation" })
    ] }) }) : /* @__PURE__ */ o(Re, { height: i, children: /* @__PURE__ */ N(Cs, { data: G, margin: I, children: [
      f.showGrid && /* @__PURE__ */ o(Et, { strokeDasharray: "3 3" }),
      /* @__PURE__ */ o(
        Lt,
        {
          dataKey: M,
          tick: { fontSize: 12 },
          angle: -45,
          textAnchor: "end",
          height: 60,
          tickFormatter: g ? (_, L) => {
            const B = C[L];
            if (B?.__displayDate) {
              const E = ge(s, x);
              return ne(B.__displayDate, E);
            }
            return `Period ${_ + 1}`;
          } : void 0
        }
      ),
      /* @__PURE__ */ o(
        He,
        {
          yAxisId: "left",
          orientation: "left",
          tick: { fontSize: 12 },
          tickFormatter: b ? (_) => K(_, b) : void 0,
          label: v.length > 0 ? {
            value: b?.label || c(v[0]),
            angle: -90,
            position: "left",
            style: { textAnchor: "middle", fontSize: "12px" }
          } : void 0
        }
      ),
      A && /* @__PURE__ */ o(
        He,
        {
          yAxisId: "right",
          orientation: "right",
          tick: { fontSize: 12 },
          tickFormatter: m ? (_) => K(_, m) : void 0,
          label: O.length > 0 ? {
            value: m?.label || c(O[0]),
            angle: 90,
            position: "right",
            style: { textAnchor: "middle", fontSize: "12px" }
          } : void 0
        }
      ),
      f.showTooltip && /* @__PURE__ */ o(
        Ke,
        {
          formatter: (_, L) => {
            if (_ == null)
              return ["No data", L];
            if (L === "Target")
              return [K(_, b), "Target Value"];
            const B = T(L), D = (B && h[B] === "right" ? "right" : "left") === "right" ? m : b;
            return [K(_, D), L];
          },
          labelFormatter: g ? (_, L) => {
            if (L && L.length > 0) {
              const B = L[0]?.payload;
              if (B?.__displayDate) {
                const E = ge(s, x);
                return ne(B.__displayDate, E);
              }
            }
            return `Period ${Number(_) + 1}`;
          } : void 0
        }
      ),
      $ && /* @__PURE__ */ o(
        Qe,
        {
          wrapperStyle: { fontSize: "12px", paddingTop: "25px" },
          iconType: "line",
          iconSize: 8,
          layout: "horizontal",
          align: "center",
          verticalAlign: "bottom",
          onMouseEnter: (_) => u(String(_.dataKey || "")),
          onMouseLeave: () => u(null)
        }
      ),
      F.map((_, L) => {
        const B = T(_), E = B && h[B] === "right" ? "right" : "left", D = g && Po(_, S), Y = D ? zo(k) : void 0, V = D ? w : 1;
        return /* @__PURE__ */ o(
          ze,
          {
            type: "monotone",
            dataKey: _,
            yAxisId: E,
            stroke: a?.colors && a.colors[L % a.colors.length] || Q[L % Q.length],
            strokeWidth: D ? 1.5 : 2,
            strokeDasharray: Y,
            dot: D ? !1 : { r: 3 },
            activeDot: D ? !1 : { r: 5 },
            strokeOpacity: l ? l === _ ? 1 : 0.3 : V,
            connectNulls: f.connectNulls
          },
          _
        );
      }),
      j.length > 0 && /* @__PURE__ */ N(gn, { children: [
        /* @__PURE__ */ o(
          ze,
          {
            type: "monotone",
            dataKey: "__target",
            yAxisId: "left",
            stroke: "#ffffff",
            strokeWidth: 2,
            dot: !1,
            activeDot: !1,
            connectNulls: !1
          }
        ),
        /* @__PURE__ */ o(
          ze,
          {
            type: "monotone",
            dataKey: "__target",
            yAxisId: "left",
            name: "Target",
            stroke: "#8B5CF6",
            strokeWidth: 2,
            strokeDasharray: "2 3",
            dot: !1,
            activeDot: !1,
            connectNulls: !1
          }
        )
      ] })
    ] }) });
  } catch (f) {
    return /* @__PURE__ */ o("div", { className: "flex flex-col items-center justify-center w-full text-dc-error p-4", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
      /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Line Chart Error" }),
      /* @__PURE__ */ o("div", { className: "text-xs mb-2", children: f instanceof Error ? f.message : "Unknown rendering error" }),
      /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
    ] }) });
  }
}), cf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: Yo
}, Symbol.toStringTag, { value: "Module" })), Bo = ie.memo(function({
  data: t,
  chartConfig: n,
  displayConfig: r = {},
  queryObject: s,
  height: i = "100%",
  colorPalette: a
}) {
  const [l, u] = J(null), c = ke();
  try {
    const d = r?.stackType ?? (r?.stacked ? "normal" : "none"), h = d !== "none", p = d === "percent", f = {
      showLegend: r?.showLegend ?? !0,
      showGrid: r?.showGrid ?? !0,
      showTooltip: r?.showTooltip ?? !0,
      connectNulls: r?.connectNulls ?? !1
    }, b = r?.leftYAxisFormat, m = r?.rightYAxisFormat;
    if (!t || t.length === 0)
      return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
        /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
        /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in area chart" })
      ] }) });
    let x, y, g = [];
    if (n?.xAxis && n?.yAxis)
      x = Array.isArray(n.xAxis) ? n.xAxis[0] : n.xAxis, y = Array.isArray(n.yAxis) ? n.yAxis : [n.yAxis], g = n.series || [];
    else if (n?.x && n?.y)
      x = n.x, y = Array.isArray(n.y) ? n.y : [n.y];
    else
      return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
        /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
        /* @__PURE__ */ o("div", { className: "text-xs", children: "Invalid or missing chart axis configuration" })
      ] }) });
    if (!x || !y || y.length === 0)
      return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
        /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
        /* @__PURE__ */ o("div", { className: "text-xs", children: "Missing required X-axis or Y-axis fields" })
      ] }) });
    const { data: k, seriesKeys: w } = ct(
      t,
      x,
      y,
      s,
      g,
      c
    ), S = n?.yAxisAssignment || {}, C = {};
    y.forEach((_) => {
      const L = c(_);
      C[L] = _;
    });
    const F = y.some((_) => S[_] === "right"), M = y.filter((_) => (S[_] || "left") === "left"), T = y.filter((_) => S[_] === "right"), A = h && !F, v = p && !F, O = f.showLegend, $ = {
      ...Xe,
      left: 40,
      // Space for left Y-axis label
      right: F ? 40 : 20
      // Extra space for right Y-axis label if needed
    }, I = Vt(r?.target || ""), z = Fn(I, k.length);
    let j = k;
    return z.length > 0 && (j = k.map((_, L) => ({
      ..._,
      __target: z[L] || null
    }))), !k || k.length === 0 ? /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
      /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
      /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No valid data points for area chart after transformation" })
    ] }) }) : /* @__PURE__ */ o(Re, { height: i, children: /* @__PURE__ */ N(Cr, { data: j, margin: $, stackOffset: v ? "expand" : void 0, children: [
      f.showGrid && /* @__PURE__ */ o(Et, { strokeDasharray: "3 3" }),
      /* @__PURE__ */ o(Lt, { dataKey: "name", tick: { fontSize: 12 }, angle: -45, textAnchor: "end", height: 60 }),
      /* @__PURE__ */ o(
        He,
        {
          yAxisId: "left",
          orientation: "left",
          tick: { fontSize: 12 },
          tickFormatter: v ? (_) => `${(_ * 100).toFixed(0)}%` : b ? (_) => K(_, b) : void 0,
          domain: v ? [0, 1] : void 0,
          label: v ? void 0 : M.length > 0 ? {
            value: b?.label || c(M[0]),
            angle: -90,
            position: "left",
            style: { textAnchor: "middle", fontSize: "12px" }
          } : void 0
        }
      ),
      F && /* @__PURE__ */ o(
        He,
        {
          yAxisId: "right",
          orientation: "right",
          tick: { fontSize: 12 },
          tickFormatter: m ? (_) => K(_, m) : void 0,
          label: T.length > 0 ? {
            value: m?.label || c(T[0]),
            angle: 90,
            position: "right",
            style: { textAnchor: "middle", fontSize: "12px" }
          } : void 0
        }
      ),
      f.showTooltip && /* @__PURE__ */ o(
        Ke,
        {
          formatter: (_, L) => {
            if (_ == null)
              return ["No data", L];
            if (L === "Target")
              return [K(_, b), "Target Value"];
            if (v && typeof _ == "number")
              return [`${(_ * 100).toFixed(1)}%`, L];
            const B = C[L], D = (B && S[B] === "right" ? "right" : "left") === "right" ? m : b;
            return [K(_, D), L];
          }
        }
      ),
      O && /* @__PURE__ */ o(
        Qe,
        {
          wrapperStyle: { fontSize: "12px", paddingTop: "10px" },
          iconType: "rect",
          iconSize: 8,
          layout: "horizontal",
          align: "center",
          verticalAlign: "bottom",
          onMouseEnter: (_) => u(String(_.dataKey || "")),
          onMouseLeave: () => u(null)
        }
      ),
      w.map((_, L) => {
        const B = C[_], E = B && S[B] === "right" ? "right" : "left";
        return /* @__PURE__ */ o(
          _s,
          {
            type: "monotone",
            dataKey: _,
            yAxisId: E,
            stackId: A ? "stack" : void 0,
            stroke: a?.colors && a.colors[L % a.colors.length] || Q[L % Q.length],
            fill: a?.colors && a.colors[L % a.colors.length] || Q[L % Q.length],
            fillOpacity: l ? l === _ ? 0.6 : 0.1 : 0.3,
            strokeWidth: 2,
            strokeOpacity: l ? l === _ ? 1 : 0.3 : 1,
            connectNulls: f.connectNulls
          },
          _
        );
      }),
      z.length > 0 && /* @__PURE__ */ N(gn, { children: [
        /* @__PURE__ */ o(
          ze,
          {
            type: "monotone",
            dataKey: "__target",
            yAxisId: "left",
            stroke: "#ffffff",
            strokeWidth: 2,
            dot: !1,
            activeDot: !1,
            connectNulls: !1
          }
        ),
        /* @__PURE__ */ o(
          ze,
          {
            type: "monotone",
            dataKey: "__target",
            yAxisId: "left",
            name: "Target",
            stroke: "#8B5CF6",
            strokeWidth: 2,
            strokeDasharray: "2 3",
            dot: !1,
            activeDot: !1,
            connectNulls: !1
          }
        )
      ] })
    ] }) });
  } catch (d) {
    return /* @__PURE__ */ o("div", { className: "flex flex-col items-center justify-center w-full text-dc-error p-4", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
      /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Area Chart Error" }),
      /* @__PURE__ */ o("div", { className: "text-xs mb-2", children: d instanceof Error ? d.message : "Unknown rendering error" }),
      /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
    ] }) });
  }
}), uf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: Bo
}, Symbol.toStringTag, { value: "Module" })), Qo = ie.memo(function({
  data: t,
  chartConfig: n,
  displayConfig: r = {},
  queryObject: s,
  height: i = "100%",
  colorPalette: a
}) {
  const [l, u] = J(null), c = ke();
  try {
    const d = {
      showLegend: r?.showLegend ?? !0,
      showTooltip: r?.showTooltip ?? !0,
      leftYAxisFormat: r?.leftYAxisFormat
    };
    if (!t || t.length === 0)
      return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
        /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
        /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in pie chart" })
      ] }) });
    let h, p, f, b = [];
    if (n?.xAxis && n?.yAxis)
      p = Array.isArray(n.xAxis) ? n.xAxis[0] : n.xAxis, f = Array.isArray(n.yAxis) ? n.yAxis : [n.yAxis], b = n.series || [];
    else if (n?.x && n?.y)
      p = n.x, f = Array.isArray(n.y) ? n.y : [n.y];
    else
      return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
        /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
        /* @__PURE__ */ o("div", { className: "text-xs", children: "chartConfig.x/y or chartConfig.xAxis/yAxis required for pie chart" })
      ] }) });
    if (!p || !f || f.length === 0)
      return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
        /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
        /* @__PURE__ */ o("div", { className: "text-xs", children: "Missing required X-axis or Y-axis fields" })
      ] }) });
    if (b.length > 0) {
      const { data: x } = ct(
        t,
        p,
        f,
        s,
        b,
        c
      );
      if (h = [], x.length > 0) {
        const y = x[0];
        Object.keys(y).forEach((g) => {
          g !== "name" && typeof y[g] == "number" && h.push({
            name: String(g),
            value: y[g]
          });
        });
      }
    } else {
      const x = ge(s, p);
      h = t.map((y) => {
        let g = ne(y[p], x) || String(y[p]) || "Unknown";
        return typeof y[p] == "boolean" ? g = y[p] ? "Active" : "Inactive" : (g === "true" || g === "false") && (g = g === "true" ? "Active" : "Inactive"), {
          name: g,
          value: typeof y[f[0]] == "string" ? parseFloat(y[f[0]]) : y[f[0]] || 0
        };
      });
    }
    const m = h.length;
    return h = h.filter(
      (x) => x.value != null && !isNaN(x.value) && x.value !== 0 && x.value > 0
    ), h.length === 0 ? /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
      /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
      /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: m > 0 ? `Filtered out ${m} data points (zero or invalid values)` : "No data points to display in pie chart" })
    ] }) }) : /* @__PURE__ */ o(Re, { height: i, children: /* @__PURE__ */ N(Ds, { children: [
      /* @__PURE__ */ o(
        $s,
        {
          data: h,
          cx: "50%",
          cy: "50%",
          outerRadius: "70%",
          dataKey: "value",
          label: d.showLegend ? void 0 : ({ name: x, percent: y }) => `${x} ${((y || 0) * 100).toFixed(0)}%`,
          children: h.map((x, y) => /* @__PURE__ */ o(
            It,
            {
              fill: a?.colors && a.colors[y % a.colors.length] || Q[y % Q.length],
              fillOpacity: l ? l === h[y].name ? 1 : 0.3 : 1
            },
            `cell-${y}`
          ))
        }
      ),
      d.showTooltip && /* @__PURE__ */ o(
        Ke,
        {
          formatter: d.leftYAxisFormat ? (x, y) => [K(x, d.leftYAxisFormat), y] : void 0
        }
      ),
      d.showLegend && /* @__PURE__ */ o(
        Qe,
        {
          wrapperStyle: { fontSize: "12px", paddingTop: "10px" },
          iconType: "circle",
          iconSize: 8,
          layout: "horizontal",
          align: "center",
          verticalAlign: "bottom",
          onMouseEnter: (x) => u(String(x.value || "")),
          onMouseLeave: () => u(null)
        }
      )
    ] }) });
  } catch (d) {
    return /* @__PURE__ */ o("div", { className: "flex flex-col items-center justify-center w-full text-dc-error p-4", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
      /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Pie Chart Error" }),
      /* @__PURE__ */ o("div", { className: "text-xs mb-2", children: d instanceof Error ? d.message : "Unknown rendering error" }),
      /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
    ] }) });
  }
}), df = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: Qo
}, Symbol.toStringTag, { value: "Module" })), qo = ie.memo(function({
  data: t,
  chartConfig: n,
  displayConfig: r = {},
  queryObject: s,
  height: i = "100%",
  colorPalette: a
}) {
  const [l, u] = J(null), c = ke();
  try {
    const d = {
      showLegend: r?.showLegend ?? !0,
      showGrid: r?.showGrid ?? !0,
      showTooltip: r?.showTooltip ?? !0
    }, h = r?.xAxisFormat, p = r?.leftYAxisFormat;
    if (!t || t.length === 0)
      return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
        /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
        /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in scatter chart" })
      ] }) });
    let f, b, m = [];
    if (n?.xAxis && n?.yAxis) {
      f = Array.isArray(n.xAxis) ? n.xAxis[0] : n.xAxis, b = Array.isArray(n.yAxis) ? n.yAxis[0] : n.yAxis;
      const T = n.series;
      m = T ? Array.isArray(T) ? T : [T] : [];
    } else if (n?.x && n?.y)
      f = n.x, b = Array.isArray(n.y) ? n.y[0] : n.y;
    else
      return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
        /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
        /* @__PURE__ */ o("div", { className: "text-xs", children: "Invalid or missing chart axis configuration" })
      ] }) });
    if (!f || !b)
      return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
        /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
        /* @__PURE__ */ o("div", { className: "text-xs", children: "Missing required X-axis or Y-axis fields" })
      ] }) });
    const y = (s?.timeDimensions || []).map((T) => T.dimension);
    let g, k = {};
    if (m.length > 0) {
      const T = m[0];
      t.forEach((v) => {
        const O = String(v[T] || "Default");
        k[O] || (k[O] = []);
        const $ = ge(s, f), I = ne(v[f], $) || v[f], z = Be(v[b]), j = typeof I == "string" ? parseFloat(I) : I;
        if (kt(j) && z !== null) {
          const G = {};
          y.forEach((_) => {
            if (v[_]) {
              const L = ge(s, _);
              G[_] = ne(v[_], L);
            }
          }), k[O].push({
            x: j,
            y: z,
            name: O,
            timeValues: G,
            originalItem: v
          });
        }
      }), g = Object.keys(k).flatMap((v) => k[v]);
    } else {
      const T = ge(s, f);
      g = t.map((A) => {
        const v = ne(A[f], T) || A[f], O = Be(A[b]), $ = typeof v == "string" ? parseFloat(v) : v, I = {};
        return y.forEach((z) => {
          if (A[z]) {
            const j = ge(s, z);
            I[z] = ne(A[z], j);
          }
        }), {
          x: $,
          y: O,
          name: "Point",
          timeValues: I,
          originalItem: A,
          isValid: kt($) && O !== null
        };
      }).filter((A) => A.isValid);
    }
    if (!g || g.length === 0)
      return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
        /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
        /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No valid data points for scatter chart after transformation" })
      ] }) });
    const w = Object.keys(k), C = w.length > 1 && w.length <= 20, F = d.showLegend && C, M = {
      ...Xe,
      left: 40
      // Increased from 20 to 40 for Y-axis label space
    };
    return /* @__PURE__ */ o(Re, { height: i, children: /* @__PURE__ */ N(Os, { margin: M, children: [
      d.showGrid && /* @__PURE__ */ o(Et, { strokeDasharray: "3 3" }),
      /* @__PURE__ */ o(
        Lt,
        {
          type: "number",
          dataKey: "x",
          name: h?.label || c(f),
          tick: { fontSize: 12 },
          tickFormatter: h ? (T) => K(T, h) : void 0
        }
      ),
      /* @__PURE__ */ o(
        He,
        {
          type: "number",
          dataKey: "y",
          name: p?.label || c(b),
          tick: { fontSize: 12 },
          tickFormatter: p ? (T) => K(T, p) : void 0,
          label: { value: p?.label || c(b), angle: -90, position: "left", style: { textAnchor: "middle", fontSize: "12px" } }
        }
      ),
      d.showTooltip && /* @__PURE__ */ o(
        lt,
        {
          cursor: { strokeDasharray: "3 3" },
          content: ({ active: T, payload: A }) => {
            if (!T || !A || A.length === 0) return null;
            const v = A[0]?.payload;
            return v ? /* @__PURE__ */ N("div", { style: {
              backgroundColor: "white",
              border: "1px solid #e5e7eb",
              borderRadius: "0.5rem",
              fontSize: "0.875rem",
              color: "#1f2937",
              boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1)",
              padding: "8px 12px"
            }, children: [
              /* @__PURE__ */ o("div", { style: { fontWeight: 600, marginBottom: "4px" }, children: v.name }),
              v.timeValues && Object.keys(v.timeValues).length > 0 && /* @__PURE__ */ o("div", { style: { marginBottom: "4px", color: "#6b7280" }, children: Object.entries(v.timeValues).map(([O, $]) => /* @__PURE__ */ N("div", { children: [
                c(O),
                ": ",
                $
              ] }, O)) }),
              /* @__PURE__ */ N("div", { children: [
                h?.label || c(f),
                ": ",
                K(v.x, h)
              ] }),
              /* @__PURE__ */ N("div", { children: [
                p?.label || c(b),
                ": ",
                K(v.y, p)
              ] })
            ] }) : null;
          }
        }
      ),
      F && /* @__PURE__ */ o(
        Qe,
        {
          wrapperStyle: { fontSize: "12px", paddingTop: "10px" },
          iconType: "circle",
          iconSize: 8,
          layout: "horizontal",
          align: "center",
          verticalAlign: "bottom",
          onMouseEnter: (T) => u(String(T.dataKey || "")),
          onMouseLeave: () => u(null)
        }
      ),
      C ? (
        // Multiple series
        w.map((T, A) => /* @__PURE__ */ o(
          Rn,
          {
            name: T,
            data: k[T],
            fill: a?.colors && a.colors[A % a.colors.length] || Q[A % Q.length],
            fillOpacity: l ? l === T ? 1 : 0.3 : 1
          },
          T
        ))
      ) : (
        // Single series
        /* @__PURE__ */ o(
          Rn,
          {
            name: "Data",
            data: g,
            fill: a?.colors && a.colors[0] || Q[0]
          }
        )
      )
    ] }) });
  } catch (d) {
    return /* @__PURE__ */ o("div", { className: "flex flex-col items-center justify-center w-full text-dc-error p-4", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
      /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Scatter Chart Error" }),
      /* @__PURE__ */ o("div", { className: "text-xs mb-2", children: d instanceof Error ? d.message : "Unknown rendering error" }),
      /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
    ] }) });
  }
}), ff = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: qo
}, Symbol.toStringTag, { value: "Module" })), Ko = ie.memo(function({
  data: t,
  chartConfig: n,
  displayConfig: r = {},
  queryObject: s,
  height: i = "100%",
  colorPalette: a
}) {
  const [l, u] = J(null);
  try {
    const c = {
      showLegend: r?.showLegend ?? !0,
      showTooltip: r?.showTooltip ?? !0,
      showGrid: r?.showGrid ?? !0,
      leftYAxisFormat: r?.leftYAxisFormat
    };
    if (!t || t.length === 0)
      return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
        /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
        /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in radar chart" })
      ] }) });
    let d, h = [];
    if (n?.xAxis && n?.yAxis) {
      const p = Array.isArray(n.xAxis) ? n.xAxis[0] : n.xAxis, f = Array.isArray(n.yAxis) ? n.yAxis : [n.yAxis], b = n.series || [], { data: m, seriesKeys: x } = ct(
        t,
        p,
        f,
        s,
        b
      );
      d = m, h = x;
    } else {
      const p = t[0], f = Object.keys(p), b = f.find(
        (x) => typeof p[x] == "string" || x.toLowerCase().includes("subject") || x.toLowerCase().includes("name") || x.toLowerCase().includes("category")
      ) || f[0], m = f.filter(
        (x) => typeof p[x] == "number" && x !== b
      );
      if (m.length === 0)
        return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
          /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
          /* @__PURE__ */ o("div", { className: "text-xs", children: "No numeric fields found for radar chart values" })
        ] }) });
      if (b) {
        const x = ge(s, b);
        d = t.map((y) => {
          const g = {
            name: ne(y[b], x) || String(y[b]) || "Unknown"
          };
          return m.forEach((k) => {
            const w = k.split(".").pop() || k;
            g[w] = typeof y[k] == "string" ? parseFloat(y[k]) : y[k] || 0;
          }), g;
        }), h = m.map((y) => y.split(".").pop() || y);
      } else
        d = t.map((x) => ({
          name: String(x[f[0]] || "Unknown"),
          value: typeof x[m[0]] == "string" ? parseFloat(x[m[0]]) : x[m[0]] || 0
        })), h = ["value"];
    }
    return !d || d.length === 0 ? /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
      /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
      /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No valid data points for radar chart after transformation" })
    ] }) }) : /* @__PURE__ */ o(Re, { height: i, children: /* @__PURE__ */ N(Rs, { data: d, margin: { top: 20, right: 80, bottom: 20, left: 80 }, children: [
      c.showGrid && /* @__PURE__ */ o(Es, {}),
      /* @__PURE__ */ o(
        Ls,
        {
          dataKey: "name",
          tick: { fontSize: 12 },
          className: "text-dc-text-muted"
        }
      ),
      /* @__PURE__ */ o(
        Is,
        {
          tick: { fontSize: 10 },
          className: "text-dc-text-muted",
          tickFormatter: c.leftYAxisFormat ? (p) => K(p, c.leftYAxisFormat) : void 0
        }
      ),
      c.showTooltip && /* @__PURE__ */ o(
        Ke,
        {
          formatter: c.leftYAxisFormat ? (p, f) => [K(p, c.leftYAxisFormat), f] : void 0
        }
      ),
      c.showLegend && h.length > 1 && /* @__PURE__ */ o(
        Qe,
        {
          wrapperStyle: { fontSize: "12px", paddingTop: "10px" },
          iconType: "rect",
          iconSize: 8,
          layout: "horizontal",
          align: "center",
          verticalAlign: "bottom",
          onMouseEnter: (p) => u(String(p.dataKey || "")),
          onMouseLeave: () => u(null)
        }
      ),
      h.map((p, f) => /* @__PURE__ */ o(
        Ps,
        {
          name: p,
          dataKey: p,
          stroke: a?.colors && a.colors[f % a.colors.length] || Q[f % Q.length],
          fill: a?.colors && a.colors[f % a.colors.length] || Q[f % Q.length],
          fillOpacity: l ? l === p ? 0.6 : 0.1 : 0.3,
          strokeOpacity: l ? l === p ? 1 : 0.3 : 1,
          strokeWidth: 2
        },
        p
      ))
    ] }) });
  } catch (c) {
    return /* @__PURE__ */ o("div", { className: "flex flex-col items-center justify-center w-full text-dc-error p-4", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
      /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Radar Chart Error" }),
      /* @__PURE__ */ o("div", { className: "text-xs mb-2", children: c instanceof Error ? c.message : "Unknown rendering error" }),
      /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
    ] }) });
  }
}), hf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: Ko
}, Symbol.toStringTag, { value: "Module" })), Wo = ie.memo(function({
  data: t,
  chartConfig: n,
  displayConfig: r = {},
  queryObject: s,
  height: i = "100%",
  colorPalette: a
}) {
  const [l, u] = J(null);
  try {
    const c = {
      showLegend: r?.showLegend ?? !0,
      showTooltip: r?.showTooltip ?? !0,
      leftYAxisFormat: r?.leftYAxisFormat
    };
    if (!t || t.length === 0)
      return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
        /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
        /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in radial bar chart" })
      ] }) });
    let d;
    if (n?.xAxis && n?.yAxis) {
      const h = Array.isArray(n.xAxis) ? n.xAxis[0] : n.xAxis, p = Array.isArray(n.yAxis) ? n.yAxis[0] : n.yAxis, f = ge(s, h);
      d = t.map((b, m) => ({
        name: ne(b[h], f) || String(b[h]) || "Unknown",
        value: typeof b[p] == "string" ? parseFloat(b[p]) : b[p] || 0,
        fill: a?.colors && a.colors[m % a.colors.length] || Q[m % Q.length]
      }));
    } else {
      const h = t[0], p = Object.keys(h), f = p.find(
        (m) => typeof h[m] == "string" || m.toLowerCase().includes("name") || m.toLowerCase().includes("label") || m.toLowerCase().includes("category")
      ) || p[0], b = p.find(
        (m) => typeof h[m] == "number" && m !== f
      ) || p[1];
      if (!b)
        return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
          /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
          /* @__PURE__ */ o("div", { className: "text-xs", children: "No numeric field found for radial bar chart values" })
        ] }) });
      d = t.map((m, x) => {
        let y = m[f];
        return typeof y == "boolean" ? y = y ? "Active" : "Inactive" : y === "true" || y === "false" ? y = y === "true" ? "Active" : "Inactive" : y = String(y), {
          name: y,
          value: typeof m[b] == "string" ? parseFloat(m[b]) : m[b] || 0,
          fill: a?.colors && a.colors[x % a.colors.length] || Q[x % Q.length]
        };
      });
    }
    return d = d.filter((h) => h.value != null && h.value !== 0), d.length === 0 ? /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
      /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
      /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No valid data points for radial bar chart after transformation" })
    ] }) }) : /* @__PURE__ */ o(Re, { height: i, children: /* @__PURE__ */ N(
      zs,
      {
        data: d,
        innerRadius: "10%",
        outerRadius: "80%",
        margin: { top: 20, right: 30, bottom: 20, left: 30 },
        children: [
          c.showTooltip && /* @__PURE__ */ o(
            Ke,
            {
              formatter: c.leftYAxisFormat ? (h, p) => [K(h, c.leftYAxisFormat), p] : void 0
            }
          ),
          c.showLegend && /* @__PURE__ */ o(
            Qe,
            {
              wrapperStyle: { fontSize: "12px", paddingTop: "10px" },
              iconType: "circle",
              iconSize: 8,
              layout: "horizontal",
              align: "center",
              verticalAlign: "bottom",
              onMouseEnter: (h) => u(String(h.value || "")),
              onMouseLeave: () => u(null)
            }
          ),
          /* @__PURE__ */ o(
            js,
            {
              dataKey: "value",
              cornerRadius: 4,
              label: {
                position: "insideStart",
                fill: "#fff",
                fontSize: 12,
                formatter: c.leftYAxisFormat ? (h) => K(h, c.leftYAxisFormat) : void 0
              },
              children: d.map((h, p) => /* @__PURE__ */ o(
                It,
                {
                  fill: h.fill,
                  fillOpacity: l ? l === h.name ? 1 : 0.3 : 1
                },
                `cell-${p}`
              ))
            }
          )
        ]
      }
    ) });
  } catch (c) {
    return /* @__PURE__ */ o("div", { className: "flex flex-col items-center justify-center w-full text-dc-error p-4", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
      /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Radial Bar Chart Error" }),
      /* @__PURE__ */ o("div", { className: "text-xs mb-2", children: c instanceof Error ? c.message : "Unknown rendering error" }),
      /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
    ] }) });
  }
}), mf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: Wo
}, Symbol.toStringTag, { value: "Module" }));
function gt(e, t) {
  return e == null || t == null ? NaN : e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN;
}
function Go(e, t) {
  return e == null || t == null ? NaN : t < e ? -1 : t > e ? 1 : t >= e ? 0 : NaN;
}
function ts(e) {
  let t, n, r;
  e.length !== 2 ? (t = gt, n = (l, u) => gt(e(l), u), r = (l, u) => e(l) - u) : (t = e === gt || e === Go ? e : Xo, n = e, r = e);
  function s(l, u, c = 0, d = l.length) {
    if (c < d) {
      if (t(u, u) !== 0) return d;
      do {
        const h = c + d >>> 1;
        n(l[h], u) < 0 ? c = h + 1 : d = h;
      } while (c < d);
    }
    return c;
  }
  function i(l, u, c = 0, d = l.length) {
    if (c < d) {
      if (t(u, u) !== 0) return d;
      do {
        const h = c + d >>> 1;
        n(l[h], u) <= 0 ? c = h + 1 : d = h;
      } while (c < d);
    }
    return c;
  }
  function a(l, u, c = 0, d = l.length) {
    const h = s(l, u, c, d - 1);
    return h > c && r(l[h - 1], u) > -r(l[h], u) ? h - 1 : h;
  }
  return { left: s, center: a, right: i };
}
function Xo() {
  return 0;
}
function Zo(e) {
  return e === null ? NaN : +e;
}
const Jo = ts(gt), ns = Jo.right;
ts(Zo).center;
function er(e, t) {
  let n, r;
  if (t === void 0)
    for (const s of e)
      s != null && (n === void 0 ? s >= s && (n = r = s) : (n > s && (n = s), r < s && (r = s)));
  else {
    let s = -1;
    for (let i of e)
      (i = t(i, ++s, e)) != null && (n === void 0 ? i >= i && (n = r = i) : (n > i && (n = i), r < i && (r = i)));
  }
  return [n, r];
}
class tr extends Map {
  constructor(t, n = nl) {
    if (super(), Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: n } }), t != null) for (const [r, s] of t) this.set(r, s);
  }
  get(t) {
    return super.get(nr(this, t));
  }
  has(t) {
    return super.has(nr(this, t));
  }
  set(t, n) {
    return super.set(el(this, t), n);
  }
  delete(t) {
    return super.delete(tl(this, t));
  }
}
function nr({ _intern: e, _key: t }, n) {
  const r = t(n);
  return e.has(r) ? e.get(r) : n;
}
function el({ _intern: e, _key: t }, n) {
  const r = t(n);
  return e.has(r) ? e.get(r) : (e.set(r, n), n);
}
function tl({ _intern: e, _key: t }, n) {
  const r = t(n);
  return e.has(r) && (n = e.get(r), e.delete(r)), n;
}
function nl(e) {
  return e !== null && typeof e == "object" ? e.valueOf() : e;
}
const rl = Math.sqrt(50), sl = Math.sqrt(10), il = Math.sqrt(2);
function Ft(e, t, n) {
  const r = (t - e) / Math.max(0, n), s = Math.floor(Math.log10(r)), i = r / Math.pow(10, s), a = i >= rl ? 10 : i >= sl ? 5 : i >= il ? 2 : 1;
  let l, u, c;
  return s < 0 ? (c = Math.pow(10, -s) / a, l = Math.round(e * c), u = Math.round(t * c), l / c < e && ++l, u / c > t && --u, c = -c) : (c = Math.pow(10, s) * a, l = Math.round(e / c), u = Math.round(t / c), l * c < e && ++l, u * c > t && --u), u < l && 0.5 <= n && n < 2 ? Ft(e, t, n * 2) : [l, u, c];
}
function al(e, t, n) {
  if (t = +t, e = +e, n = +n, !(n > 0)) return [];
  if (e === t) return [e];
  const r = t < e, [s, i, a] = r ? Ft(t, e, n) : Ft(e, t, n);
  if (!(i >= s)) return [];
  const l = i - s + 1, u = new Array(l);
  if (r)
    if (a < 0) for (let c = 0; c < l; ++c) u[c] = (i - c) / -a;
    else for (let c = 0; c < l; ++c) u[c] = (i - c) * a;
  else if (a < 0) for (let c = 0; c < l; ++c) u[c] = (s + c) / -a;
  else for (let c = 0; c < l; ++c) u[c] = (s + c) * a;
  return u;
}
function ln(e, t, n) {
  return t = +t, e = +e, n = +n, Ft(e, t, n)[2];
}
function ol(e, t, n) {
  t = +t, e = +e, n = +n;
  const r = t < e, s = r ? ln(t, e, n) : ln(e, t, n);
  return (r ? -1 : 1) * (s < 0 ? 1 / -s : s);
}
function cn(e, t) {
  let n;
  if (t === void 0)
    for (const r of e)
      r != null && (n < r || n === void 0 && r >= r) && (n = r);
  else {
    let r = -1;
    for (let s of e)
      (s = t(s, ++r, e)) != null && (n < s || n === void 0 && s >= s) && (n = s);
  }
  return n;
}
function rr(e, t) {
  let n;
  if (t === void 0)
    for (const r of e)
      r != null && (n > r || n === void 0 && r >= r) && (n = r);
  else {
    let r = -1;
    for (let s of e)
      (s = t(s, ++r, e)) != null && (n > s || n === void 0 && s >= s) && (n = s);
  }
  return n;
}
function ll(e) {
  return e;
}
var qt = 1, Kt = 2, un = 3, et = 4, sr = 1e-6;
function cl(e) {
  return "translate(" + e + ",0)";
}
function ul(e) {
  return "translate(0," + e + ")";
}
function dl(e) {
  return (t) => +e(t);
}
function fl(e, t) {
  return t = Math.max(0, e.bandwidth() - t * 2) / 2, e.round() && (t = Math.round(t)), (n) => +e(n) + t;
}
function hl() {
  return !this.__axis;
}
function rs(e, t) {
  var n = [], r = null, s = null, i = 6, a = 6, l = 3, u = typeof window < "u" && window.devicePixelRatio > 1 ? 0 : 0.5, c = e === qt || e === et ? -1 : 1, d = e === et || e === Kt ? "x" : "y", h = e === qt || e === un ? cl : ul;
  function p(f) {
    var b = r ?? (t.ticks ? t.ticks.apply(t, n) : t.domain()), m = s ?? (t.tickFormat ? t.tickFormat.apply(t, n) : ll), x = Math.max(i, 0) + l, y = t.range(), g = +y[0] + u, k = +y[y.length - 1] + u, w = (t.bandwidth ? fl : dl)(t.copy(), u), S = f.selection ? f.selection() : f, C = S.selectAll(".domain").data([null]), F = S.selectAll(".tick").data(b, t).order(), M = F.exit(), T = F.enter().append("g").attr("class", "tick"), A = F.select("line"), v = F.select("text");
    C = C.merge(C.enter().insert("path", ".tick").attr("class", "domain").attr("stroke", "currentColor")), F = F.merge(T), A = A.merge(T.append("line").attr("stroke", "currentColor").attr(d + "2", c * i)), v = v.merge(T.append("text").attr("fill", "currentColor").attr(d, c * x).attr("dy", e === qt ? "0em" : e === un ? "0.71em" : "0.32em")), f !== S && (C = C.transition(f), F = F.transition(f), A = A.transition(f), v = v.transition(f), M = M.transition(f).attr("opacity", sr).attr("transform", function(O) {
      return isFinite(O = w(O)) ? h(O + u) : this.getAttribute("transform");
    }), T.attr("opacity", sr).attr("transform", function(O) {
      var $ = this.parentNode.__axis;
      return h(($ && isFinite($ = $(O)) ? $ : w(O)) + u);
    })), M.remove(), C.attr("d", e === et || e === Kt ? a ? "M" + c * a + "," + g + "H" + u + "V" + k + "H" + c * a : "M" + u + "," + g + "V" + k : a ? "M" + g + "," + c * a + "V" + u + "H" + k + "V" + c * a : "M" + g + "," + u + "H" + k), F.attr("opacity", 1).attr("transform", function(O) {
      return h(w(O) + u);
    }), A.attr(d + "2", c * i), v.attr(d, c * x).text(m), S.filter(hl).attr("fill", "none").attr("font-size", 10).attr("font-family", "sans-serif").attr("text-anchor", e === Kt ? "start" : e === et ? "end" : "middle"), S.each(function() {
      this.__axis = w;
    });
  }
  return p.scale = function(f) {
    return arguments.length ? (t = f, p) : t;
  }, p.ticks = function() {
    return n = Array.from(arguments), p;
  }, p.tickArguments = function(f) {
    return arguments.length ? (n = f == null ? [] : Array.from(f), p) : n.slice();
  }, p.tickValues = function(f) {
    return arguments.length ? (r = f == null ? null : Array.from(f), p) : r && r.slice();
  }, p.tickFormat = function(f) {
    return arguments.length ? (s = f, p) : s;
  }, p.tickSize = function(f) {
    return arguments.length ? (i = a = +f, p) : i;
  }, p.tickSizeInner = function(f) {
    return arguments.length ? (i = +f, p) : i;
  }, p.tickSizeOuter = function(f) {
    return arguments.length ? (a = +f, p) : a;
  }, p.tickPadding = function(f) {
    return arguments.length ? (l = +f, p) : l;
  }, p.offset = function(f) {
    return arguments.length ? (u = +f, p) : u;
  }, p;
}
function ir(e) {
  return rs(un, e);
}
function ar(e) {
  return rs(et, e);
}
var dn = "http://www.w3.org/1999/xhtml";
const or = {
  svg: "http://www.w3.org/2000/svg",
  xhtml: dn,
  xlink: "http://www.w3.org/1999/xlink",
  xml: "http://www.w3.org/XML/1998/namespace",
  xmlns: "http://www.w3.org/2000/xmlns/"
};
function ss(e) {
  var t = e += "", n = t.indexOf(":");
  return n >= 0 && (t = e.slice(0, n)) !== "xmlns" && (e = e.slice(n + 1)), or.hasOwnProperty(t) ? { space: or[t], local: e } : e;
}
function ml(e) {
  return function() {
    var t = this.ownerDocument, n = this.namespaceURI;
    return n === dn && t.documentElement.namespaceURI === dn ? t.createElement(e) : t.createElementNS(n, e);
  };
}
function pl(e) {
  return function() {
    return this.ownerDocument.createElementNS(e.space, e.local);
  };
}
function is(e) {
  var t = ss(e);
  return (t.local ? pl : ml)(t);
}
function yl() {
}
function as(e) {
  return e == null ? yl : function() {
    return this.querySelector(e);
  };
}
function xl(e) {
  typeof e != "function" && (e = as(e));
  for (var t = this._groups, n = t.length, r = new Array(n), s = 0; s < n; ++s)
    for (var i = t[s], a = i.length, l = r[s] = new Array(a), u, c, d = 0; d < a; ++d)
      (u = i[d]) && (c = e.call(u, u.__data__, d, i)) && ("__data__" in u && (c.__data__ = u.__data__), l[d] = c);
  return new Ne(r, this._parents);
}
function gl(e) {
  return e == null ? [] : Array.isArray(e) ? e : Array.from(e);
}
function bl() {
  return [];
}
function vl(e) {
  return e == null ? bl : function() {
    return this.querySelectorAll(e);
  };
}
function wl(e) {
  return function() {
    return gl(e.apply(this, arguments));
  };
}
function Nl(e) {
  typeof e == "function" ? e = wl(e) : e = vl(e);
  for (var t = this._groups, n = t.length, r = [], s = [], i = 0; i < n; ++i)
    for (var a = t[i], l = a.length, u, c = 0; c < l; ++c)
      (u = a[c]) && (r.push(e.call(u, u.__data__, c, a)), s.push(u));
  return new Ne(r, s);
}
function Sl(e) {
  return function() {
    return this.matches(e);
  };
}
function os(e) {
  return function(t) {
    return t.matches(e);
  };
}
var Al = Array.prototype.find;
function kl(e) {
  return function() {
    return Al.call(this.children, e);
  };
}
function Fl() {
  return this.firstElementChild;
}
function Tl(e) {
  return this.select(e == null ? Fl : kl(typeof e == "function" ? e : os(e)));
}
var Ml = Array.prototype.filter;
function Cl() {
  return Array.from(this.children);
}
function _l(e) {
  return function() {
    return Ml.call(this.children, e);
  };
}
function Dl(e) {
  return this.selectAll(e == null ? Cl : _l(typeof e == "function" ? e : os(e)));
}
function $l(e) {
  typeof e != "function" && (e = Sl(e));
  for (var t = this._groups, n = t.length, r = new Array(n), s = 0; s < n; ++s)
    for (var i = t[s], a = i.length, l = r[s] = [], u, c = 0; c < a; ++c)
      (u = i[c]) && e.call(u, u.__data__, c, i) && l.push(u);
  return new Ne(r, this._parents);
}
function ls(e) {
  return new Array(e.length);
}
function Ol() {
  return new Ne(this._enter || this._groups.map(ls), this._parents);
}
function Tt(e, t) {
  this.ownerDocument = e.ownerDocument, this.namespaceURI = e.namespaceURI, this._next = null, this._parent = e, this.__data__ = t;
}
Tt.prototype = {
  constructor: Tt,
  appendChild: function(e) {
    return this._parent.insertBefore(e, this._next);
  },
  insertBefore: function(e, t) {
    return this._parent.insertBefore(e, t);
  },
  querySelector: function(e) {
    return this._parent.querySelector(e);
  },
  querySelectorAll: function(e) {
    return this._parent.querySelectorAll(e);
  }
};
function Rl(e) {
  return function() {
    return e;
  };
}
function El(e, t, n, r, s, i) {
  for (var a = 0, l, u = t.length, c = i.length; a < c; ++a)
    (l = t[a]) ? (l.__data__ = i[a], r[a] = l) : n[a] = new Tt(e, i[a]);
  for (; a < u; ++a)
    (l = t[a]) && (s[a] = l);
}
function Ll(e, t, n, r, s, i, a) {
  var l, u, c = /* @__PURE__ */ new Map(), d = t.length, h = i.length, p = new Array(d), f;
  for (l = 0; l < d; ++l)
    (u = t[l]) && (p[l] = f = a.call(u, u.__data__, l, t) + "", c.has(f) ? s[l] = u : c.set(f, u));
  for (l = 0; l < h; ++l)
    f = a.call(e, i[l], l, i) + "", (u = c.get(f)) ? (r[l] = u, u.__data__ = i[l], c.delete(f)) : n[l] = new Tt(e, i[l]);
  for (l = 0; l < d; ++l)
    (u = t[l]) && c.get(p[l]) === u && (s[l] = u);
}
function Il(e) {
  return e.__data__;
}
function Pl(e, t) {
  if (!arguments.length) return Array.from(this, Il);
  var n = t ? Ll : El, r = this._parents, s = this._groups;
  typeof e != "function" && (e = Rl(e));
  for (var i = s.length, a = new Array(i), l = new Array(i), u = new Array(i), c = 0; c < i; ++c) {
    var d = r[c], h = s[c], p = h.length, f = zl(e.call(d, d && d.__data__, c, r)), b = f.length, m = l[c] = new Array(b), x = a[c] = new Array(b), y = u[c] = new Array(p);
    n(d, h, m, x, y, f, t);
    for (var g = 0, k = 0, w, S; g < b; ++g)
      if (w = m[g]) {
        for (g >= k && (k = g + 1); !(S = x[k]) && ++k < b; ) ;
        w._next = S || null;
      }
  }
  return a = new Ne(a, r), a._enter = l, a._exit = u, a;
}
function zl(e) {
  return typeof e == "object" && "length" in e ? e : Array.from(e);
}
function jl() {
  return new Ne(this._exit || this._groups.map(ls), this._parents);
}
function Vl(e, t, n) {
  var r = this.enter(), s = this, i = this.exit();
  return typeof e == "function" ? (r = e(r), r && (r = r.selection())) : r = r.append(e + ""), t != null && (s = t(s), s && (s = s.selection())), n == null ? i.remove() : n(i), r && s ? r.merge(s).order() : s;
}
function Hl(e) {
  for (var t = e.selection ? e.selection() : e, n = this._groups, r = t._groups, s = n.length, i = r.length, a = Math.min(s, i), l = new Array(s), u = 0; u < a; ++u)
    for (var c = n[u], d = r[u], h = c.length, p = l[u] = new Array(h), f, b = 0; b < h; ++b)
      (f = c[b] || d[b]) && (p[b] = f);
  for (; u < s; ++u)
    l[u] = n[u];
  return new Ne(l, this._parents);
}
function Ul() {
  for (var e = this._groups, t = -1, n = e.length; ++t < n; )
    for (var r = e[t], s = r.length - 1, i = r[s], a; --s >= 0; )
      (a = r[s]) && (i && a.compareDocumentPosition(i) ^ 4 && i.parentNode.insertBefore(a, i), i = a);
  return this;
}
function Yl(e) {
  e || (e = Bl);
  function t(h, p) {
    return h && p ? e(h.__data__, p.__data__) : !h - !p;
  }
  for (var n = this._groups, r = n.length, s = new Array(r), i = 0; i < r; ++i) {
    for (var a = n[i], l = a.length, u = s[i] = new Array(l), c, d = 0; d < l; ++d)
      (c = a[d]) && (u[d] = c);
    u.sort(t);
  }
  return new Ne(s, this._parents).order();
}
function Bl(e, t) {
  return e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN;
}
function Ql() {
  var e = arguments[0];
  return arguments[0] = this, e.apply(null, arguments), this;
}
function ql() {
  return Array.from(this);
}
function Kl() {
  for (var e = this._groups, t = 0, n = e.length; t < n; ++t)
    for (var r = e[t], s = 0, i = r.length; s < i; ++s) {
      var a = r[s];
      if (a) return a;
    }
  return null;
}
function Wl() {
  let e = 0;
  for (const t of this) ++e;
  return e;
}
function Gl() {
  return !this.node();
}
function Xl(e) {
  for (var t = this._groups, n = 0, r = t.length; n < r; ++n)
    for (var s = t[n], i = 0, a = s.length, l; i < a; ++i)
      (l = s[i]) && e.call(l, l.__data__, i, s);
  return this;
}
function Zl(e) {
  return function() {
    this.removeAttribute(e);
  };
}
function Jl(e) {
  return function() {
    this.removeAttributeNS(e.space, e.local);
  };
}
function ec(e, t) {
  return function() {
    this.setAttribute(e, t);
  };
}
function tc(e, t) {
  return function() {
    this.setAttributeNS(e.space, e.local, t);
  };
}
function nc(e, t) {
  return function() {
    var n = t.apply(this, arguments);
    n == null ? this.removeAttribute(e) : this.setAttribute(e, n);
  };
}
function rc(e, t) {
  return function() {
    var n = t.apply(this, arguments);
    n == null ? this.removeAttributeNS(e.space, e.local) : this.setAttributeNS(e.space, e.local, n);
  };
}
function sc(e, t) {
  var n = ss(e);
  if (arguments.length < 2) {
    var r = this.node();
    return n.local ? r.getAttributeNS(n.space, n.local) : r.getAttribute(n);
  }
  return this.each((t == null ? n.local ? Jl : Zl : typeof t == "function" ? n.local ? rc : nc : n.local ? tc : ec)(n, t));
}
function cs(e) {
  return e.ownerDocument && e.ownerDocument.defaultView || e.document && e || e.defaultView;
}
function ic(e) {
  return function() {
    this.style.removeProperty(e);
  };
}
function ac(e, t, n) {
  return function() {
    this.style.setProperty(e, t, n);
  };
}
function oc(e, t, n) {
  return function() {
    var r = t.apply(this, arguments);
    r == null ? this.style.removeProperty(e) : this.style.setProperty(e, r, n);
  };
}
function lc(e, t, n) {
  return arguments.length > 1 ? this.each((t == null ? ic : typeof t == "function" ? oc : ac)(e, t, n ?? "")) : cc(this.node(), e);
}
function cc(e, t) {
  return e.style.getPropertyValue(t) || cs(e).getComputedStyle(e, null).getPropertyValue(t);
}
function uc(e) {
  return function() {
    delete this[e];
  };
}
function dc(e, t) {
  return function() {
    this[e] = t;
  };
}
function fc(e, t) {
  return function() {
    var n = t.apply(this, arguments);
    n == null ? delete this[e] : this[e] = n;
  };
}
function hc(e, t) {
  return arguments.length > 1 ? this.each((t == null ? uc : typeof t == "function" ? fc : dc)(e, t)) : this.node()[e];
}
function us(e) {
  return e.trim().split(/^|\s+/);
}
function Tn(e) {
  return e.classList || new ds(e);
}
function ds(e) {
  this._node = e, this._names = us(e.getAttribute("class") || "");
}
ds.prototype = {
  add: function(e) {
    var t = this._names.indexOf(e);
    t < 0 && (this._names.push(e), this._node.setAttribute("class", this._names.join(" ")));
  },
  remove: function(e) {
    var t = this._names.indexOf(e);
    t >= 0 && (this._names.splice(t, 1), this._node.setAttribute("class", this._names.join(" ")));
  },
  contains: function(e) {
    return this._names.indexOf(e) >= 0;
  }
};
function fs(e, t) {
  for (var n = Tn(e), r = -1, s = t.length; ++r < s; ) n.add(t[r]);
}
function hs(e, t) {
  for (var n = Tn(e), r = -1, s = t.length; ++r < s; ) n.remove(t[r]);
}
function mc(e) {
  return function() {
    fs(this, e);
  };
}
function pc(e) {
  return function() {
    hs(this, e);
  };
}
function yc(e, t) {
  return function() {
    (t.apply(this, arguments) ? fs : hs)(this, e);
  };
}
function xc(e, t) {
  var n = us(e + "");
  if (arguments.length < 2) {
    for (var r = Tn(this.node()), s = -1, i = n.length; ++s < i; ) if (!r.contains(n[s])) return !1;
    return !0;
  }
  return this.each((typeof t == "function" ? yc : t ? mc : pc)(n, t));
}
function gc() {
  this.textContent = "";
}
function bc(e) {
  return function() {
    this.textContent = e;
  };
}
function vc(e) {
  return function() {
    var t = e.apply(this, arguments);
    this.textContent = t ?? "";
  };
}
function wc(e) {
  return arguments.length ? this.each(e == null ? gc : (typeof e == "function" ? vc : bc)(e)) : this.node().textContent;
}
function Nc() {
  this.innerHTML = "";
}
function Sc(e) {
  return function() {
    this.innerHTML = e;
  };
}
function Ac(e) {
  return function() {
    var t = e.apply(this, arguments);
    this.innerHTML = t ?? "";
  };
}
function kc(e) {
  return arguments.length ? this.each(e == null ? Nc : (typeof e == "function" ? Ac : Sc)(e)) : this.node().innerHTML;
}
function Fc() {
  this.nextSibling && this.parentNode.appendChild(this);
}
function Tc() {
  return this.each(Fc);
}
function Mc() {
  this.previousSibling && this.parentNode.insertBefore(this, this.parentNode.firstChild);
}
function Cc() {
  return this.each(Mc);
}
function _c(e) {
  var t = typeof e == "function" ? e : is(e);
  return this.select(function() {
    return this.appendChild(t.apply(this, arguments));
  });
}
function Dc() {
  return null;
}
function $c(e, t) {
  var n = typeof e == "function" ? e : is(e), r = t == null ? Dc : typeof t == "function" ? t : as(t);
  return this.select(function() {
    return this.insertBefore(n.apply(this, arguments), r.apply(this, arguments) || null);
  });
}
function Oc() {
  var e = this.parentNode;
  e && e.removeChild(this);
}
function Rc() {
  return this.each(Oc);
}
function Ec() {
  var e = this.cloneNode(!1), t = this.parentNode;
  return t ? t.insertBefore(e, this.nextSibling) : e;
}
function Lc() {
  var e = this.cloneNode(!0), t = this.parentNode;
  return t ? t.insertBefore(e, this.nextSibling) : e;
}
function Ic(e) {
  return this.select(e ? Lc : Ec);
}
function Pc(e) {
  return arguments.length ? this.property("__data__", e) : this.node().__data__;
}
function zc(e) {
  return function(t) {
    e.call(this, t, this.__data__);
  };
}
function jc(e) {
  return e.trim().split(/^|\s+/).map(function(t) {
    var n = "", r = t.indexOf(".");
    return r >= 0 && (n = t.slice(r + 1), t = t.slice(0, r)), { type: t, name: n };
  });
}
function Vc(e) {
  return function() {
    var t = this.__on;
    if (t) {
      for (var n = 0, r = -1, s = t.length, i; n < s; ++n)
        i = t[n], (!e.type || i.type === e.type) && i.name === e.name ? this.removeEventListener(i.type, i.listener, i.options) : t[++r] = i;
      ++r ? t.length = r : delete this.__on;
    }
  };
}
function Hc(e, t, n) {
  return function() {
    var r = this.__on, s, i = zc(t);
    if (r) {
      for (var a = 0, l = r.length; a < l; ++a)
        if ((s = r[a]).type === e.type && s.name === e.name) {
          this.removeEventListener(s.type, s.listener, s.options), this.addEventListener(s.type, s.listener = i, s.options = n), s.value = t;
          return;
        }
    }
    this.addEventListener(e.type, i, n), s = { type: e.type, name: e.name, value: t, listener: i, options: n }, r ? r.push(s) : this.__on = [s];
  };
}
function Uc(e, t, n) {
  var r = jc(e + ""), s, i = r.length, a;
  if (arguments.length < 2) {
    var l = this.node().__on;
    if (l) {
      for (var u = 0, c = l.length, d; u < c; ++u)
        for (s = 0, d = l[u]; s < i; ++s)
          if ((a = r[s]).type === d.type && a.name === d.name)
            return d.value;
    }
    return;
  }
  for (l = t ? Hc : Vc, s = 0; s < i; ++s) this.each(l(r[s], t, n));
  return this;
}
function ms(e, t, n) {
  var r = cs(e), s = r.CustomEvent;
  typeof s == "function" ? s = new s(t, n) : (s = r.document.createEvent("Event"), n ? (s.initEvent(t, n.bubbles, n.cancelable), s.detail = n.detail) : s.initEvent(t, !1, !1)), e.dispatchEvent(s);
}
function Yc(e, t) {
  return function() {
    return ms(this, e, t);
  };
}
function Bc(e, t) {
  return function() {
    return ms(this, e, t.apply(this, arguments));
  };
}
function Qc(e, t) {
  return this.each((typeof t == "function" ? Bc : Yc)(e, t));
}
function* qc() {
  for (var e = this._groups, t = 0, n = e.length; t < n; ++t)
    for (var r = e[t], s = 0, i = r.length, a; s < i; ++s)
      (a = r[s]) && (yield a);
}
var Kc = [null];
function Ne(e, t) {
  this._groups = e, this._parents = t;
}
function Wc() {
  return this;
}
Ne.prototype = {
  constructor: Ne,
  select: xl,
  selectAll: Nl,
  selectChild: Tl,
  selectChildren: Dl,
  filter: $l,
  data: Pl,
  enter: Ol,
  exit: jl,
  join: Vl,
  merge: Hl,
  selection: Wc,
  order: Ul,
  sort: Yl,
  call: Ql,
  nodes: ql,
  node: Kl,
  size: Wl,
  empty: Gl,
  each: Xl,
  attr: sc,
  style: lc,
  property: hc,
  classed: xc,
  text: wc,
  html: kc,
  raise: Tc,
  lower: Cc,
  append: _c,
  insert: $c,
  remove: Rc,
  clone: Ic,
  datum: Pc,
  on: Uc,
  dispatch: Qc,
  [Symbol.iterator]: qc
};
function Me(e) {
  return typeof e == "string" ? new Ne([[document.querySelector(e)]], [document.documentElement]) : new Ne([[e]], Kc);
}
function Mn(e, t, n) {
  e.prototype = t.prototype = n, n.constructor = e;
}
function ps(e, t) {
  var n = Object.create(e.prototype);
  for (var r in t) n[r] = t[r];
  return n;
}
function ut() {
}
var it = 0.7, Mt = 1 / it, We = "\\s*([+-]?\\d+)\\s*", at = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", _e = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", Gc = /^#([0-9a-f]{3,8})$/, Xc = new RegExp(`^rgb\\(${We},${We},${We}\\)$`), Zc = new RegExp(`^rgb\\(${_e},${_e},${_e}\\)$`), Jc = new RegExp(`^rgba\\(${We},${We},${We},${at}\\)$`), eu = new RegExp(`^rgba\\(${_e},${_e},${_e},${at}\\)$`), tu = new RegExp(`^hsl\\(${at},${_e},${_e}\\)$`), nu = new RegExp(`^hsla\\(${at},${_e},${_e},${at}\\)$`), lr = {
  aliceblue: 15792383,
  antiquewhite: 16444375,
  aqua: 65535,
  aquamarine: 8388564,
  azure: 15794175,
  beige: 16119260,
  bisque: 16770244,
  black: 0,
  blanchedalmond: 16772045,
  blue: 255,
  blueviolet: 9055202,
  brown: 10824234,
  burlywood: 14596231,
  cadetblue: 6266528,
  chartreuse: 8388352,
  chocolate: 13789470,
  coral: 16744272,
  cornflowerblue: 6591981,
  cornsilk: 16775388,
  crimson: 14423100,
  cyan: 65535,
  darkblue: 139,
  darkcyan: 35723,
  darkgoldenrod: 12092939,
  darkgray: 11119017,
  darkgreen: 25600,
  darkgrey: 11119017,
  darkkhaki: 12433259,
  darkmagenta: 9109643,
  darkolivegreen: 5597999,
  darkorange: 16747520,
  darkorchid: 10040012,
  darkred: 9109504,
  darksalmon: 15308410,
  darkseagreen: 9419919,
  darkslateblue: 4734347,
  darkslategray: 3100495,
  darkslategrey: 3100495,
  darkturquoise: 52945,
  darkviolet: 9699539,
  deeppink: 16716947,
  deepskyblue: 49151,
  dimgray: 6908265,
  dimgrey: 6908265,
  dodgerblue: 2003199,
  firebrick: 11674146,
  floralwhite: 16775920,
  forestgreen: 2263842,
  fuchsia: 16711935,
  gainsboro: 14474460,
  ghostwhite: 16316671,
  gold: 16766720,
  goldenrod: 14329120,
  gray: 8421504,
  green: 32768,
  greenyellow: 11403055,
  grey: 8421504,
  honeydew: 15794160,
  hotpink: 16738740,
  indianred: 13458524,
  indigo: 4915330,
  ivory: 16777200,
  khaki: 15787660,
  lavender: 15132410,
  lavenderblush: 16773365,
  lawngreen: 8190976,
  lemonchiffon: 16775885,
  lightblue: 11393254,
  lightcoral: 15761536,
  lightcyan: 14745599,
  lightgoldenrodyellow: 16448210,
  lightgray: 13882323,
  lightgreen: 9498256,
  lightgrey: 13882323,
  lightpink: 16758465,
  lightsalmon: 16752762,
  lightseagreen: 2142890,
  lightskyblue: 8900346,
  lightslategray: 7833753,
  lightslategrey: 7833753,
  lightsteelblue: 11584734,
  lightyellow: 16777184,
  lime: 65280,
  limegreen: 3329330,
  linen: 16445670,
  magenta: 16711935,
  maroon: 8388608,
  mediumaquamarine: 6737322,
  mediumblue: 205,
  mediumorchid: 12211667,
  mediumpurple: 9662683,
  mediumseagreen: 3978097,
  mediumslateblue: 8087790,
  mediumspringgreen: 64154,
  mediumturquoise: 4772300,
  mediumvioletred: 13047173,
  midnightblue: 1644912,
  mintcream: 16121850,
  mistyrose: 16770273,
  moccasin: 16770229,
  navajowhite: 16768685,
  navy: 128,
  oldlace: 16643558,
  olive: 8421376,
  olivedrab: 7048739,
  orange: 16753920,
  orangered: 16729344,
  orchid: 14315734,
  palegoldenrod: 15657130,
  palegreen: 10025880,
  paleturquoise: 11529966,
  palevioletred: 14381203,
  papayawhip: 16773077,
  peachpuff: 16767673,
  peru: 13468991,
  pink: 16761035,
  plum: 14524637,
  powderblue: 11591910,
  purple: 8388736,
  rebeccapurple: 6697881,
  red: 16711680,
  rosybrown: 12357519,
  royalblue: 4286945,
  saddlebrown: 9127187,
  salmon: 16416882,
  sandybrown: 16032864,
  seagreen: 3050327,
  seashell: 16774638,
  sienna: 10506797,
  silver: 12632256,
  skyblue: 8900331,
  slateblue: 6970061,
  slategray: 7372944,
  slategrey: 7372944,
  snow: 16775930,
  springgreen: 65407,
  steelblue: 4620980,
  tan: 13808780,
  teal: 32896,
  thistle: 14204888,
  tomato: 16737095,
  turquoise: 4251856,
  violet: 15631086,
  wheat: 16113331,
  white: 16777215,
  whitesmoke: 16119285,
  yellow: 16776960,
  yellowgreen: 10145074
};
Mn(ut, ot, {
  copy(e) {
    return Object.assign(new this.constructor(), this, e);
  },
  displayable() {
    return this.rgb().displayable();
  },
  hex: cr,
  // Deprecated! Use color.formatHex.
  formatHex: cr,
  formatHex8: ru,
  formatHsl: su,
  formatRgb: ur,
  toString: ur
});
function cr() {
  return this.rgb().formatHex();
}
function ru() {
  return this.rgb().formatHex8();
}
function su() {
  return ys(this).formatHsl();
}
function ur() {
  return this.rgb().formatRgb();
}
function ot(e) {
  var t, n;
  return e = (e + "").trim().toLowerCase(), (t = Gc.exec(e)) ? (n = t[1].length, t = parseInt(t[1], 16), n === 6 ? dr(t) : n === 3 ? new xe(t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | t & 240, (t & 15) << 4 | t & 15, 1) : n === 8 ? ht(t >> 24 & 255, t >> 16 & 255, t >> 8 & 255, (t & 255) / 255) : n === 4 ? ht(t >> 12 & 15 | t >> 8 & 240, t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | t & 240, ((t & 15) << 4 | t & 15) / 255) : null) : (t = Xc.exec(e)) ? new xe(t[1], t[2], t[3], 1) : (t = Zc.exec(e)) ? new xe(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, 1) : (t = Jc.exec(e)) ? ht(t[1], t[2], t[3], t[4]) : (t = eu.exec(e)) ? ht(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, t[4]) : (t = tu.exec(e)) ? mr(t[1], t[2] / 100, t[3] / 100, 1) : (t = nu.exec(e)) ? mr(t[1], t[2] / 100, t[3] / 100, t[4]) : lr.hasOwnProperty(e) ? dr(lr[e]) : e === "transparent" ? new xe(NaN, NaN, NaN, 0) : null;
}
function dr(e) {
  return new xe(e >> 16 & 255, e >> 8 & 255, e & 255, 1);
}
function ht(e, t, n, r) {
  return r <= 0 && (e = t = n = NaN), new xe(e, t, n, r);
}
function iu(e) {
  return e instanceof ut || (e = ot(e)), e ? (e = e.rgb(), new xe(e.r, e.g, e.b, e.opacity)) : new xe();
}
function fn(e, t, n, r) {
  return arguments.length === 1 ? iu(e) : new xe(e, t, n, r ?? 1);
}
function xe(e, t, n, r) {
  this.r = +e, this.g = +t, this.b = +n, this.opacity = +r;
}
Mn(xe, fn, ps(ut, {
  brighter(e) {
    return e = e == null ? Mt : Math.pow(Mt, e), new xe(this.r * e, this.g * e, this.b * e, this.opacity);
  },
  darker(e) {
    return e = e == null ? it : Math.pow(it, e), new xe(this.r * e, this.g * e, this.b * e, this.opacity);
  },
  rgb() {
    return this;
  },
  clamp() {
    return new xe(je(this.r), je(this.g), je(this.b), Ct(this.opacity));
  },
  displayable() {
    return -0.5 <= this.r && this.r < 255.5 && -0.5 <= this.g && this.g < 255.5 && -0.5 <= this.b && this.b < 255.5 && 0 <= this.opacity && this.opacity <= 1;
  },
  hex: fr,
  // Deprecated! Use color.formatHex.
  formatHex: fr,
  formatHex8: au,
  formatRgb: hr,
  toString: hr
}));
function fr() {
  return `#${Pe(this.r)}${Pe(this.g)}${Pe(this.b)}`;
}
function au() {
  return `#${Pe(this.r)}${Pe(this.g)}${Pe(this.b)}${Pe((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
}
function hr() {
  const e = Ct(this.opacity);
  return `${e === 1 ? "rgb(" : "rgba("}${je(this.r)}, ${je(this.g)}, ${je(this.b)}${e === 1 ? ")" : `, ${e})`}`;
}
function Ct(e) {
  return isNaN(e) ? 1 : Math.max(0, Math.min(1, e));
}
function je(e) {
  return Math.max(0, Math.min(255, Math.round(e) || 0));
}
function Pe(e) {
  return e = je(e), (e < 16 ? "0" : "") + e.toString(16);
}
function mr(e, t, n, r) {
  return r <= 0 ? e = t = n = NaN : n <= 0 || n >= 1 ? e = t = NaN : t <= 0 && (e = NaN), new Se(e, t, n, r);
}
function ys(e) {
  if (e instanceof Se) return new Se(e.h, e.s, e.l, e.opacity);
  if (e instanceof ut || (e = ot(e)), !e) return new Se();
  if (e instanceof Se) return e;
  e = e.rgb();
  var t = e.r / 255, n = e.g / 255, r = e.b / 255, s = Math.min(t, n, r), i = Math.max(t, n, r), a = NaN, l = i - s, u = (i + s) / 2;
  return l ? (t === i ? a = (n - r) / l + (n < r) * 6 : n === i ? a = (r - t) / l + 2 : a = (t - n) / l + 4, l /= u < 0.5 ? i + s : 2 - i - s, a *= 60) : l = u > 0 && u < 1 ? 0 : a, new Se(a, l, u, e.opacity);
}
function ou(e, t, n, r) {
  return arguments.length === 1 ? ys(e) : new Se(e, t, n, r ?? 1);
}
function Se(e, t, n, r) {
  this.h = +e, this.s = +t, this.l = +n, this.opacity = +r;
}
Mn(Se, ou, ps(ut, {
  brighter(e) {
    return e = e == null ? Mt : Math.pow(Mt, e), new Se(this.h, this.s, this.l * e, this.opacity);
  },
  darker(e) {
    return e = e == null ? it : Math.pow(it, e), new Se(this.h, this.s, this.l * e, this.opacity);
  },
  rgb() {
    var e = this.h % 360 + (this.h < 0) * 360, t = isNaN(e) || isNaN(this.s) ? 0 : this.s, n = this.l, r = n + (n < 0.5 ? n : 1 - n) * t, s = 2 * n - r;
    return new xe(
      Wt(e >= 240 ? e - 240 : e + 120, s, r),
      Wt(e, s, r),
      Wt(e < 120 ? e + 240 : e - 120, s, r),
      this.opacity
    );
  },
  clamp() {
    return new Se(pr(this.h), mt(this.s), mt(this.l), Ct(this.opacity));
  },
  displayable() {
    return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && 0 <= this.l && this.l <= 1 && 0 <= this.opacity && this.opacity <= 1;
  },
  formatHsl() {
    const e = Ct(this.opacity);
    return `${e === 1 ? "hsl(" : "hsla("}${pr(this.h)}, ${mt(this.s) * 100}%, ${mt(this.l) * 100}%${e === 1 ? ")" : `, ${e})`}`;
  }
}));
function pr(e) {
  return e = (e || 0) % 360, e < 0 ? e + 360 : e;
}
function mt(e) {
  return Math.max(0, Math.min(1, e || 0));
}
function Wt(e, t, n) {
  return (e < 60 ? t + (n - t) * e / 60 : e < 180 ? n : e < 240 ? t + (n - t) * (240 - e) / 60 : t) * 255;
}
const Cn = (e) => () => e;
function lu(e, t) {
  return function(n) {
    return e + n * t;
  };
}
function cu(e, t, n) {
  return e = Math.pow(e, n), t = Math.pow(t, n) - e, n = 1 / n, function(r) {
    return Math.pow(e + r * t, n);
  };
}
function uu(e) {
  return (e = +e) == 1 ? xs : function(t, n) {
    return n - t ? cu(t, n, e) : Cn(isNaN(t) ? n : t);
  };
}
function xs(e, t) {
  var n = t - e;
  return n ? lu(e, n) : Cn(isNaN(e) ? t : e);
}
const yr = (function e(t) {
  var n = uu(t);
  function r(s, i) {
    var a = n((s = fn(s)).r, (i = fn(i)).r), l = n(s.g, i.g), u = n(s.b, i.b), c = xs(s.opacity, i.opacity);
    return function(d) {
      return s.r = a(d), s.g = l(d), s.b = u(d), s.opacity = c(d), s + "";
    };
  }
  return r.gamma = e, r;
})(1);
function du(e, t) {
  t || (t = []);
  var n = e ? Math.min(t.length, e.length) : 0, r = t.slice(), s;
  return function(i) {
    for (s = 0; s < n; ++s) r[s] = e[s] * (1 - i) + t[s] * i;
    return r;
  };
}
function fu(e) {
  return ArrayBuffer.isView(e) && !(e instanceof DataView);
}
function hu(e, t) {
  var n = t ? t.length : 0, r = e ? Math.min(n, e.length) : 0, s = new Array(r), i = new Array(n), a;
  for (a = 0; a < r; ++a) s[a] = _n(e[a], t[a]);
  for (; a < n; ++a) i[a] = t[a];
  return function(l) {
    for (a = 0; a < r; ++a) i[a] = s[a](l);
    return i;
  };
}
function mu(e, t) {
  var n = /* @__PURE__ */ new Date();
  return e = +e, t = +t, function(r) {
    return n.setTime(e * (1 - r) + t * r), n;
  };
}
function _t(e, t) {
  return e = +e, t = +t, function(n) {
    return e * (1 - n) + t * n;
  };
}
function pu(e, t) {
  var n = {}, r = {}, s;
  (e === null || typeof e != "object") && (e = {}), (t === null || typeof t != "object") && (t = {});
  for (s in t)
    s in e ? n[s] = _n(e[s], t[s]) : r[s] = t[s];
  return function(i) {
    for (s in n) r[s] = n[s](i);
    return r;
  };
}
var hn = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, Gt = new RegExp(hn.source, "g");
function yu(e) {
  return function() {
    return e;
  };
}
function xu(e) {
  return function(t) {
    return e(t) + "";
  };
}
function gu(e, t) {
  var n = hn.lastIndex = Gt.lastIndex = 0, r, s, i, a = -1, l = [], u = [];
  for (e = e + "", t = t + ""; (r = hn.exec(e)) && (s = Gt.exec(t)); )
    (i = s.index) > n && (i = t.slice(n, i), l[a] ? l[a] += i : l[++a] = i), (r = r[0]) === (s = s[0]) ? l[a] ? l[a] += s : l[++a] = s : (l[++a] = null, u.push({ i: a, x: _t(r, s) })), n = Gt.lastIndex;
  return n < t.length && (i = t.slice(n), l[a] ? l[a] += i : l[++a] = i), l.length < 2 ? u[0] ? xu(u[0].x) : yu(t) : (t = u.length, function(c) {
    for (var d = 0, h; d < t; ++d) l[(h = u[d]).i] = h.x(c);
    return l.join("");
  });
}
function _n(e, t) {
  var n = typeof t, r;
  return t == null || n === "boolean" ? Cn(t) : (n === "number" ? _t : n === "string" ? (r = ot(t)) ? (t = r, yr) : gu : t instanceof ot ? yr : t instanceof Date ? mu : fu(t) ? du : Array.isArray(t) ? hu : typeof t.valueOf != "function" && typeof t.toString != "function" || isNaN(t) ? pu : _t)(e, t);
}
function bu(e, t) {
  return e = +e, t = +t, function(n) {
    return Math.round(e * (1 - n) + t * n);
  };
}
function vu(e) {
  return Math.abs(e = Math.round(e)) >= 1e21 ? e.toLocaleString("en").replace(/,/g, "") : e.toString(10);
}
function Dt(e, t) {
  if ((n = (e = t ? e.toExponential(t - 1) : e.toExponential()).indexOf("e")) < 0) return null;
  var n, r = e.slice(0, n);
  return [
    r.length > 1 ? r[0] + r.slice(2) : r,
    +e.slice(n + 1)
  ];
}
function Ze(e) {
  return e = Dt(Math.abs(e)), e ? e[1] : NaN;
}
function wu(e, t) {
  return function(n, r) {
    for (var s = n.length, i = [], a = 0, l = e[0], u = 0; s > 0 && l > 0 && (u + l + 1 > r && (l = Math.max(1, r - u)), i.push(n.substring(s -= l, s + l)), !((u += l + 1) > r)); )
      l = e[a = (a + 1) % e.length];
    return i.reverse().join(t);
  };
}
function Nu(e) {
  return function(t) {
    return t.replace(/[0-9]/g, function(n) {
      return e[+n];
    });
  };
}
var Su = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
function $t(e) {
  if (!(t = Su.exec(e))) throw new Error("invalid format: " + e);
  var t;
  return new Dn({
    fill: t[1],
    align: t[2],
    sign: t[3],
    symbol: t[4],
    zero: t[5],
    width: t[6],
    comma: t[7],
    precision: t[8] && t[8].slice(1),
    trim: t[9],
    type: t[10]
  });
}
$t.prototype = Dn.prototype;
function Dn(e) {
  this.fill = e.fill === void 0 ? " " : e.fill + "", this.align = e.align === void 0 ? ">" : e.align + "", this.sign = e.sign === void 0 ? "-" : e.sign + "", this.symbol = e.symbol === void 0 ? "" : e.symbol + "", this.zero = !!e.zero, this.width = e.width === void 0 ? void 0 : +e.width, this.comma = !!e.comma, this.precision = e.precision === void 0 ? void 0 : +e.precision, this.trim = !!e.trim, this.type = e.type === void 0 ? "" : e.type + "";
}
Dn.prototype.toString = function() {
  return this.fill + this.align + this.sign + this.symbol + (this.zero ? "0" : "") + (this.width === void 0 ? "" : Math.max(1, this.width | 0)) + (this.comma ? "," : "") + (this.precision === void 0 ? "" : "." + Math.max(0, this.precision | 0)) + (this.trim ? "~" : "") + this.type;
};
function Au(e) {
  e: for (var t = e.length, n = 1, r = -1, s; n < t; ++n)
    switch (e[n]) {
      case ".":
        r = s = n;
        break;
      case "0":
        r === 0 && (r = n), s = n;
        break;
      default:
        if (!+e[n]) break e;
        r > 0 && (r = 0);
        break;
    }
  return r > 0 ? e.slice(0, r) + e.slice(s + 1) : e;
}
var gs;
function ku(e, t) {
  var n = Dt(e, t);
  if (!n) return e + "";
  var r = n[0], s = n[1], i = s - (gs = Math.max(-8, Math.min(8, Math.floor(s / 3))) * 3) + 1, a = r.length;
  return i === a ? r : i > a ? r + new Array(i - a + 1).join("0") : i > 0 ? r.slice(0, i) + "." + r.slice(i) : "0." + new Array(1 - i).join("0") + Dt(e, Math.max(0, t + i - 1))[0];
}
function xr(e, t) {
  var n = Dt(e, t);
  if (!n) return e + "";
  var r = n[0], s = n[1];
  return s < 0 ? "0." + new Array(-s).join("0") + r : r.length > s + 1 ? r.slice(0, s + 1) + "." + r.slice(s + 1) : r + new Array(s - r.length + 2).join("0");
}
const gr = {
  "%": (e, t) => (e * 100).toFixed(t),
  b: (e) => Math.round(e).toString(2),
  c: (e) => e + "",
  d: vu,
  e: (e, t) => e.toExponential(t),
  f: (e, t) => e.toFixed(t),
  g: (e, t) => e.toPrecision(t),
  o: (e) => Math.round(e).toString(8),
  p: (e, t) => xr(e * 100, t),
  r: xr,
  s: ku,
  X: (e) => Math.round(e).toString(16).toUpperCase(),
  x: (e) => Math.round(e).toString(16)
};
function br(e) {
  return e;
}
var vr = Array.prototype.map, wr = ["y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];
function Fu(e) {
  var t = e.grouping === void 0 || e.thousands === void 0 ? br : wu(vr.call(e.grouping, Number), e.thousands + ""), n = e.currency === void 0 ? "" : e.currency[0] + "", r = e.currency === void 0 ? "" : e.currency[1] + "", s = e.decimal === void 0 ? "." : e.decimal + "", i = e.numerals === void 0 ? br : Nu(vr.call(e.numerals, String)), a = e.percent === void 0 ? "%" : e.percent + "", l = e.minus === void 0 ? "−" : e.minus + "", u = e.nan === void 0 ? "NaN" : e.nan + "";
  function c(h) {
    h = $t(h);
    var p = h.fill, f = h.align, b = h.sign, m = h.symbol, x = h.zero, y = h.width, g = h.comma, k = h.precision, w = h.trim, S = h.type;
    S === "n" ? (g = !0, S = "g") : gr[S] || (k === void 0 && (k = 12), w = !0, S = "g"), (x || p === "0" && f === "=") && (x = !0, p = "0", f = "=");
    var C = m === "$" ? n : m === "#" && /[boxX]/.test(S) ? "0" + S.toLowerCase() : "", F = m === "$" ? r : /[%p]/.test(S) ? a : "", M = gr[S], T = /[defgprs%]/.test(S);
    k = k === void 0 ? 6 : /[gprs]/.test(S) ? Math.max(1, Math.min(21, k)) : Math.max(0, Math.min(20, k));
    function A(v) {
      var O = C, $ = F, I, z, j;
      if (S === "c")
        $ = M(v) + $, v = "";
      else {
        v = +v;
        var G = v < 0 || 1 / v < 0;
        if (v = isNaN(v) ? u : M(Math.abs(v), k), w && (v = Au(v)), G && +v == 0 && b !== "+" && (G = !1), O = (G ? b === "(" ? b : l : b === "-" || b === "(" ? "" : b) + O, $ = (S === "s" ? wr[8 + gs / 3] : "") + $ + (G && b === "(" ? ")" : ""), T) {
          for (I = -1, z = v.length; ++I < z; )
            if (j = v.charCodeAt(I), 48 > j || j > 57) {
              $ = (j === 46 ? s + v.slice(I + 1) : v.slice(I)) + $, v = v.slice(0, I);
              break;
            }
        }
      }
      g && !x && (v = t(v, 1 / 0));
      var _ = O.length + v.length + $.length, L = _ < y ? new Array(y - _ + 1).join(p) : "";
      switch (g && x && (v = t(L + v, L.length ? y - $.length : 1 / 0), L = ""), f) {
        case "<":
          v = O + v + $ + L;
          break;
        case "=":
          v = O + L + v + $;
          break;
        case "^":
          v = L.slice(0, _ = L.length >> 1) + O + v + $ + L.slice(_);
          break;
        default:
          v = L + O + v + $;
          break;
      }
      return i(v);
    }
    return A.toString = function() {
      return h + "";
    }, A;
  }
  function d(h, p) {
    var f = c((h = $t(h), h.type = "f", h)), b = Math.max(-8, Math.min(8, Math.floor(Ze(p) / 3))) * 3, m = Math.pow(10, -b), x = wr[8 + b / 3];
    return function(y) {
      return f(m * y) + x;
    };
  }
  return {
    format: c,
    formatPrefix: d
  };
}
var pt, bs, vs;
Tu({
  thousands: ",",
  grouping: [3],
  currency: ["$", ""]
});
function Tu(e) {
  return pt = Fu(e), bs = pt.format, vs = pt.formatPrefix, pt;
}
function Mu(e) {
  return Math.max(0, -Ze(Math.abs(e)));
}
function Cu(e, t) {
  return Math.max(0, Math.max(-8, Math.min(8, Math.floor(Ze(t) / 3))) * 3 - Ze(Math.abs(e)));
}
function _u(e, t) {
  return e = Math.abs(e), t = Math.abs(t) - e, Math.max(0, Ze(t) - Ze(e)) + 1;
}
function Ht(e, t) {
  switch (arguments.length) {
    case 0:
      break;
    case 1:
      this.range(e);
      break;
    default:
      this.range(t).domain(e);
      break;
  }
  return this;
}
const Nr = /* @__PURE__ */ Symbol("implicit");
function Ot() {
  var e = new tr(), t = [], n = [], r = Nr;
  function s(i) {
    let a = e.get(i);
    if (a === void 0) {
      if (r !== Nr) return r;
      e.set(i, a = t.push(i) - 1);
    }
    return n[a % n.length];
  }
  return s.domain = function(i) {
    if (!arguments.length) return t.slice();
    t = [], e = new tr();
    for (const a of i)
      e.has(a) || e.set(a, t.push(a) - 1);
    return s;
  }, s.range = function(i) {
    return arguments.length ? (n = Array.from(i), s) : n.slice();
  }, s.unknown = function(i) {
    return arguments.length ? (r = i, s) : r;
  }, s.copy = function() {
    return Ot(t, n).unknown(r);
  }, Ht.apply(s, arguments), s;
}
function Du(e) {
  return function() {
    return e;
  };
}
function $u(e) {
  return +e;
}
var Sr = [0, 1];
function Ce(e) {
  return e;
}
function mn(e, t) {
  return (t -= e = +e) ? function(n) {
    return (n - e) / t;
  } : Du(isNaN(t) ? NaN : 0.5);
}
function Ou(e, t) {
  var n;
  return e > t && (n = e, e = t, t = n), function(r) {
    return Math.max(e, Math.min(t, r));
  };
}
function Ru(e, t, n) {
  var r = e[0], s = e[1], i = t[0], a = t[1];
  return s < r ? (r = mn(s, r), i = n(a, i)) : (r = mn(r, s), i = n(i, a)), function(l) {
    return i(r(l));
  };
}
function Eu(e, t, n) {
  var r = Math.min(e.length, t.length) - 1, s = new Array(r), i = new Array(r), a = -1;
  for (e[r] < e[0] && (e = e.slice().reverse(), t = t.slice().reverse()); ++a < r; )
    s[a] = mn(e[a], e[a + 1]), i[a] = n(t[a], t[a + 1]);
  return function(l) {
    var u = ns(e, l, 1, r) - 1;
    return i[u](s[u](l));
  };
}
function ws(e, t) {
  return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown());
}
function Ns() {
  var e = Sr, t = Sr, n = _n, r, s, i, a = Ce, l, u, c;
  function d() {
    var p = Math.min(e.length, t.length);
    return a !== Ce && (a = Ou(e[0], e[p - 1])), l = p > 2 ? Eu : Ru, u = c = null, h;
  }
  function h(p) {
    return p == null || isNaN(p = +p) ? i : (u || (u = l(e.map(r), t, n)))(r(a(p)));
  }
  return h.invert = function(p) {
    return a(s((c || (c = l(t, e.map(r), _t)))(p)));
  }, h.domain = function(p) {
    return arguments.length ? (e = Array.from(p, $u), d()) : e.slice();
  }, h.range = function(p) {
    return arguments.length ? (t = Array.from(p), d()) : t.slice();
  }, h.rangeRound = function(p) {
    return t = Array.from(p), n = bu, d();
  }, h.clamp = function(p) {
    return arguments.length ? (a = p ? !0 : Ce, d()) : a !== Ce;
  }, h.interpolate = function(p) {
    return arguments.length ? (n = p, d()) : n;
  }, h.unknown = function(p) {
    return arguments.length ? (i = p, h) : i;
  }, function(p, f) {
    return r = p, s = f, d();
  };
}
function Lu() {
  return Ns()(Ce, Ce);
}
function Iu(e, t, n, r) {
  var s = ol(e, t, n), i;
  switch (r = $t(r ?? ",f"), r.type) {
    case "s": {
      var a = Math.max(Math.abs(e), Math.abs(t));
      return r.precision == null && !isNaN(i = Cu(s, a)) && (r.precision = i), vs(r, a);
    }
    case "":
    case "e":
    case "g":
    case "p":
    case "r": {
      r.precision == null && !isNaN(i = _u(s, Math.max(Math.abs(e), Math.abs(t)))) && (r.precision = i - (r.type === "e"));
      break;
    }
    case "f":
    case "%": {
      r.precision == null && !isNaN(i = Mu(s)) && (r.precision = i - (r.type === "%") * 2);
      break;
    }
  }
  return bs(r);
}
function $n(e) {
  var t = e.domain;
  return e.ticks = function(n) {
    var r = t();
    return al(r[0], r[r.length - 1], n ?? 10);
  }, e.tickFormat = function(n, r) {
    var s = t();
    return Iu(s[0], s[s.length - 1], n ?? 10, r);
  }, e.nice = function(n) {
    n == null && (n = 10);
    var r = t(), s = 0, i = r.length - 1, a = r[s], l = r[i], u, c, d = 10;
    for (l < a && (c = a, a = l, l = c, c = s, s = i, i = c); d-- > 0; ) {
      if (c = ln(a, l, n), c === u)
        return r[s] = a, r[i] = l, t(r);
      if (c > 0)
        a = Math.floor(a / c) * c, l = Math.ceil(l / c) * c;
      else if (c < 0)
        a = Math.ceil(a * c) / c, l = Math.floor(l * c) / c;
      else
        break;
      u = c;
    }
    return e;
  }, e;
}
function pn() {
  var e = Lu();
  return e.copy = function() {
    return ws(e, pn());
  }, Ht.apply(e, arguments), $n(e);
}
function Ar(e) {
  return function(t) {
    return t < 0 ? -Math.pow(-t, e) : Math.pow(t, e);
  };
}
function Pu(e) {
  return e < 0 ? -Math.sqrt(-e) : Math.sqrt(e);
}
function zu(e) {
  return e < 0 ? -e * e : e * e;
}
function ju(e) {
  var t = e(Ce, Ce), n = 1;
  function r() {
    return n === 1 ? e(Ce, Ce) : n === 0.5 ? e(Pu, zu) : e(Ar(n), Ar(1 / n));
  }
  return t.exponent = function(s) {
    return arguments.length ? (n = +s, r()) : n;
  }, $n(t);
}
function Ss() {
  var e = ju(Ns());
  return e.copy = function() {
    return ws(e, Ss()).exponent(e.exponent());
  }, Ht.apply(e, arguments), e;
}
function Vu() {
  return Ss.apply(null, arguments).exponent(0.5);
}
function Ut() {
  var e = 0, t = 1, n = 1, r = [0.5], s = [0, 1], i;
  function a(u) {
    return u != null && u <= u ? s[ns(r, u, 0, n)] : i;
  }
  function l() {
    var u = -1;
    for (r = new Array(n); ++u < n; ) r[u] = ((u + 1) * t - (u - n) * e) / (n + 1);
    return a;
  }
  return a.domain = function(u) {
    return arguments.length ? ([e, t] = u, e = +e, t = +t, l()) : [e, t];
  }, a.range = function(u) {
    return arguments.length ? (n = (s = Array.from(u)).length - 1, l()) : s.slice();
  }, a.invertExtent = function(u) {
    var c = s.indexOf(u);
    return c < 0 ? [NaN, NaN] : c < 1 ? [e, r[0]] : c >= n ? [r[n - 1], t] : [r[c - 1], r[c]];
  }, a.unknown = function(u) {
    return arguments.length && (i = u), a;
  }, a.thresholds = function() {
    return r.slice();
  }, a.copy = function() {
    return Ut().domain([e, t]).range(s).unknown(i);
  }, Ht.apply($n(a), arguments);
}
const Hu = ie.memo(function({
  data: t,
  chartConfig: n,
  displayConfig: r = {},
  queryObject: s,
  height: i = "100%",
  colorPalette: a
}) {
  const [l, u] = J(null), c = ke();
  try {
    const d = {
      showTooltip: r?.showTooltip ?? !0,
      showLegend: r?.showLegend ?? !0,
      leftYAxisFormat: r?.leftYAxisFormat
    };
    if (!t || t.length === 0)
      return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
        /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
        /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in treemap chart" })
      ] }) });
    let h, p = !1, f;
    if (n?.xAxis && n?.yAxis) {
      const w = Array.isArray(n.xAxis) ? n.xAxis[0] : n.xAxis, S = Array.isArray(n.yAxis) ? n.yAxis[0] : n.yAxis;
      f = Array.isArray(n.series) ? n.series[0] : n.series;
      const C = ge(s, w);
      if (f) {
        const F = t.map((M) => {
          const T = M[f];
          return typeof T == "string" ? parseFloat(T) : T;
        }).filter((M) => !isNaN(M));
        if (p = F.length === t.length && F.every((M) => typeof M == "number"), p) {
          const M = Math.min(...F), T = Math.max(...F), A = Ut().domain([M, T]).range(Ie);
          h = t.map((v) => {
            const O = typeof v[f] == "string" ? parseFloat(v[f]) : v[f], $ = A(O);
            return {
              name: ne(v[w], C) || String(v[w]) || "Unknown",
              size: typeof v[S] == "string" ? parseFloat(v[S]) : v[S] || 0,
              fill: $,
              series: String(v[f])
            };
          });
        } else {
          const M = [...new Set(t.map((A) => String(A[f])))], T = Ot().domain(M).range(a?.colors || Q);
          h = t.map((A) => ({
            name: ne(A[w], C) || String(A[w]) || "Unknown",
            size: typeof A[S] == "string" ? parseFloat(A[S]) : A[S] || 0,
            fill: T(String(A[f])),
            series: String(A[f])
          }));
        }
      } else
        h = t.map((F, M) => ({
          name: ne(F[w], C) || String(F[w]) || "Unknown",
          size: typeof F[S] == "string" ? parseFloat(F[S]) : F[S] || 0,
          fill: a?.colors && a.colors[M % a.colors.length] || Q[M % Q.length]
        }));
    } else {
      const w = t[0], S = Object.keys(w), C = S.find(
        (M) => typeof w[M] == "string" || M.toLowerCase().includes("name") || M.toLowerCase().includes("label") || M.toLowerCase().includes("category")
      ) || S[0], F = S.find((M) => M.toLowerCase().includes("size")) || S.find(
        (M) => typeof w[M] == "number" && M !== C
      ) || S[1];
      if (!F)
        return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
          /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
          /* @__PURE__ */ o("div", { className: "text-xs", children: "No numeric field found for treemap chart size" })
        ] }) });
      h = t.map((M, T) => {
        let A = M[C];
        return typeof A == "boolean" ? A = A ? "Active" : "Inactive" : A === "true" || A === "false" ? A = A === "true" ? "Active" : "Inactive" : A = String(A), {
          name: A,
          size: typeof M[F] == "string" ? parseFloat(M[F]) : M[F] || 0,
          fill: a?.colors && a.colors[T % a.colors.length] || Q[T % Q.length]
        };
      });
    }
    if (h = h.filter((w) => w.size != null && w.size > 0), h.length === 0)
      return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
        /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
        /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No valid data points for treemap chart after transformation" })
      ] }) });
    const b = (w) => {
      const { x: S, y: C, width: F, height: M, index: T, name: A, size: v } = w;
      return F < 20 || M < 20 ? null : /* @__PURE__ */ N("g", { children: [
        /* @__PURE__ */ o(
          "rect",
          {
            x: S,
            y: C,
            width: F,
            height: M,
            style: {
              fill: h[T]?.fill || a?.colors && a.colors[T % a.colors.length] || Q[T % Q.length],
              fillOpacity: l !== null ? l === T ? 1 : 0.6 : 0.8,
              stroke: "#fff",
              strokeWidth: 2,
              cursor: "pointer"
            },
            onMouseEnter: () => u(T),
            onMouseLeave: () => u(null)
          }
        ),
        /* @__PURE__ */ o(
          "foreignObject",
          {
            x: S,
            y: C,
            width: F,
            height: M,
            style: { pointerEvents: "none", overflow: "visible" },
            children: /* @__PURE__ */ N(
              "div",
              {
                style: {
                  width: "100%",
                  height: "100%",
                  display: "flex",
                  flexDirection: "column",
                  alignItems: "center",
                  justifyContent: "center",
                  padding: "4px",
                  boxSizing: "border-box",
                  color: "#ffffff",
                  textShadow: "0 1px 2px rgba(0,0,0,0.8)",
                  fontFamily: "system-ui, -apple-system, sans-serif",
                  overflow: "hidden"
                },
                children: [
                  F > 40 && M > 30 && /* @__PURE__ */ o(
                    "div",
                    {
                      style: {
                        fontSize: `${Math.max(10, Math.min(F / 8, M / 8, 16))}px`,
                        fontWeight: "600",
                        textAlign: "center",
                        lineHeight: "1.2",
                        marginBottom: F > 60 && M > 45 ? "4px" : "0",
                        wordBreak: "break-word",
                        hyphens: "auto"
                      },
                      children: A
                    }
                  ),
                  F > 60 && M > 45 && /* @__PURE__ */ o(
                    "div",
                    {
                      style: {
                        fontSize: `${Math.max(8, Math.min(F / 10, M / 10, 14))}px`,
                        textAlign: "center",
                        opacity: 0.9
                      },
                      children: d.leftYAxisFormat ? K(v, d.leftYAxisFormat) : typeof v == "number" ? v.toLocaleString() : v
                    }
                  )
                ]
              }
            )
          }
        )
      ] });
    }, x = h.some((w) => "series" in w) ? [...new Set(h.map((w) => w.series).filter(Boolean))] : [];
    let y = [];
    if (d.showLegend && f)
      if (p) {
        const w = Math.min(...t.map((C) => {
          const F = C[f];
          return typeof F == "string" ? parseFloat(F) : F;
        })), S = Math.max(...t.map((C) => {
          const F = C[f];
          return typeof F == "string" ? parseFloat(F) : F;
        }));
        y = Ie.map((C, F) => {
          const M = F / (Ie.length - 1), T = w + (S - w) * M;
          return {
            value: d.leftYAxisFormat ? K(T, d.leftYAxisFormat) : T.toFixed(2),
            type: "rect",
            color: C
          };
        });
      } else x.length > 1 && (y = x.map((w, S) => ({
        value: w,
        type: "rect",
        color: Q[S % Q.length]
      })));
    const g = d.showLegend && y.length > 0, k = g ? typeof i == "string" && i.includes("%") ? i : typeof i == "number" ? i + 60 : `calc(${i} + 60px)` : i;
    return /* @__PURE__ */ N("div", { className: "w-full", style: { height: k }, children: [
      /* @__PURE__ */ o(Re, { height: g ? "calc(100% - 50px)" : "100%", children: /* @__PURE__ */ o(
        Vs,
        {
          data: h,
          dataKey: "size",
          aspectRatio: 4 / 3,
          stroke: "#fff",
          content: /* @__PURE__ */ o(b, {}),
          children: d.showTooltip && /* @__PURE__ */ o(
            Ke,
            {
              formatter: d.leftYAxisFormat ? (w, S) => [K(w, d.leftYAxisFormat), S] : void 0
            }
          )
        }
      ) }),
      g && /* @__PURE__ */ o("div", { className: "flex justify-center items-center mt-4 pb-2", children: p ? (
        // Gradient legend for numeric series
        /* @__PURE__ */ N("div", { className: "flex flex-col items-center", children: [
          /* @__PURE__ */ o("div", { className: "text-xs font-semibold text-dc-text-primary mb-2", children: f ? c(f) : "" }),
          /* @__PURE__ */ N("div", { className: "flex items-center gap-2", children: [
            /* @__PURE__ */ o("span", { className: "text-xs text-dc-text-muted", children: d.leftYAxisFormat ? K(Math.min(...t.map((w) => {
              const S = w[f];
              return typeof S == "string" ? parseFloat(S) : S;
            })), d.leftYAxisFormat) : Math.min(...t.map((w) => {
              const S = w[f];
              return typeof S == "string" ? parseFloat(S) : S;
            })).toFixed(2) }),
            /* @__PURE__ */ o(
              "div",
              {
                className: "h-4 rounded-sm",
                style: {
                  width: "200px",
                  background: `linear-gradient(to right, ${Ie.join(", ")})`
                }
              }
            ),
            /* @__PURE__ */ o("span", { className: "text-xs text-dc-text-muted", children: d.leftYAxisFormat ? K(Math.max(...t.map((w) => {
              const S = w[f];
              return typeof S == "string" ? parseFloat(S) : S;
            })), d.leftYAxisFormat) : Math.max(...t.map((w) => {
              const S = w[f];
              return typeof S == "string" ? parseFloat(S) : S;
            })).toFixed(2) })
          ] })
        ] })
      ) : (
        // Discrete legend for categorical series
        /* @__PURE__ */ o("div", { className: "flex flex-wrap justify-center gap-4", children: y.map((w, S) => /* @__PURE__ */ N("div", { className: "flex items-center gap-2", children: [
          /* @__PURE__ */ o(
            "div",
            {
              className: "w-3 h-3 rounded-xs",
              style: { backgroundColor: w.color }
            }
          ),
          /* @__PURE__ */ o("span", { className: "text-xs text-dc-text-muted", children: w.value })
        ] }, S)) })
      ) })
    ] });
  } catch (d) {
    return /* @__PURE__ */ o("div", { className: "flex flex-col items-center justify-center w-full text-dc-error p-4", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
      /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "TreeMap Chart Error" }),
      /* @__PURE__ */ o("div", { className: "text-xs mb-2", children: d instanceof Error ? d.message : "Unknown rendering error" }),
      /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
    ] }) });
  }
}), pf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: Hu
}, Symbol.toStringTag, { value: "Module" })), Uu = ie.memo(function({
  data: t,
  chartConfig: n,
  displayConfig: r = {},
  queryObject: s,
  height: i = "100%",
  colorPalette: a
}) {
  const l = be(null), u = be(null), [c, d] = J({ width: 0, height: 0 }), [h, p] = J(!1), { theme: f } = vo(), b = ke(), m = q(() => ({
    showLegend: r?.showLegend ?? !0,
    showGrid: r?.showGrid ?? !0,
    showTooltip: r?.showTooltip ?? !0,
    minBubbleSize: r?.minBubbleSize ?? 5,
    maxBubbleSize: r?.maxBubbleSize ?? 50,
    bubbleOpacity: r?.bubbleOpacity ?? 0.7,
    xAxisFormat: r?.xAxisFormat,
    leftYAxisFormat: r?.leftYAxisFormat
  }), [
    r?.showLegend,
    r?.showGrid,
    r?.showTooltip,
    r?.minBubbleSize,
    r?.maxBubbleSize,
    r?.bubbleOpacity,
    r?.xAxisFormat,
    r?.leftYAxisFormat
  ]);
  return xn(() => {
    let y = 0;
    const g = 10;
    let k, w;
    const S = () => {
      if (u.current) {
        const { width: F, height: M } = u.current.getBoundingClientRect();
        if (F > 0 && M > 0)
          return d({ width: F, height: M }), p(!0), !0;
      }
      return !1;
    };
    if (!S() && y < g) {
      const F = () => {
        !S() && y < g && (y++, w = setTimeout(() => {
          k = requestAnimationFrame(F);
        }, 50 * y));
      };
      k = requestAnimationFrame(F);
    }
    return () => {
      k && cancelAnimationFrame(k), w && clearTimeout(w);
    };
  }, []), Ae(() => {
    let y = null;
    const g = () => {
      if (u.current) {
        const { width: k, height: w } = u.current.getBoundingClientRect();
        k > 0 && w > 0 && (d({ width: k, height: w }), h || p(!0));
      }
    };
    return u.current && (y = new ResizeObserver((k) => {
      for (const w of k) {
        const { width: S, height: C } = w.contentRect;
        S > 0 && C > 0 && (d({ width: S, height: C }), h || p(!0));
      }
    }), y.observe(u.current), g()), window.addEventListener("resize", g), () => {
      y && y.disconnect(), window.removeEventListener("resize", g);
    };
  }, [h]), Ae(() => {
    if (!t || t.length === 0 || !l.current || !h || c.width === 0 || (Me(l.current).selectAll("*").remove(), !n?.xAxis || !n?.yAxis || !n?.series))
      return;
    const y = Array.isArray(n.xAxis) ? n.xAxis[0] : n.xAxis, g = Array.isArray(n.yAxis) ? n.yAxis[0] : n.yAxis, k = Array.isArray(n.series) ? n.series[0] : n.series, w = Array.isArray(n.sizeField) ? n.sizeField[0] : n.sizeField || g, S = Array.isArray(n.colorField) ? n.colorField[0] : n.colorField;
    if (!y || !g || !k || !w)
      return;
    const C = ge(s, y), F = s?.timeDimensions?.some(
      (R) => R.dimension === y
    ) || !1, M = t.map((R) => {
      const P = R[y];
      let X, oe;
      if (F && P) {
        const se = String(P);
        let me;
        if (se.match(/^\d{4}-\d{2}-\d{2}[T ]/)) {
          let Te = se;
          se.includes(" ") && (Te = se.replace(" ", "T").replace("+00", "Z").replace(/\+\d{2}:\d{2}$/, "Z")), !Te.endsWith("Z") && !Te.includes("+") && (Te = Te + "Z"), me = new Date(Te);
        } else
          me = new Date(se);
        X = isNaN(me.getTime()) ? parseFloat(se) : me.getTime(), oe = ne(P, C);
      } else {
        const se = ne(P, C) || P;
        X = typeof se == "string" ? parseFloat(se) : se, oe = String(se);
      }
      const le = Be(R[g]), ve = Be(R[w]), ue = R[k];
      return {
        x: X,
        xLabel: oe,
        // Store formatted label for tooltip display
        y: le,
        // Type assertion: filter below ensures this is never null
        size: ve !== null ? Math.abs(ve) : 0,
        // Ensure positive size
        color: S ? R[S] : ue,
        series: ue,
        label: `${ue || "Unknown"}`,
        isValid: kt(X) && le !== null && ve !== null && ve > 0
      };
    }).filter((R) => R.isValid && R.size > 0);
    if (M.length === 0) return;
    const T = {
      ...Xe,
      left: Xe.left + 30,
      // Add extra 30px left margin for Y-axis label
      bottom: m.showLegend && S ? 100 : 40
      // Add extra space for legend
    }, A = c.width - T.left - T.right, v = c.height - T.top - T.bottom, O = Me(l.current).attr("width", c.width).attr("height", c.height), $ = O.append("g").attr("transform", `translate(${T.left},${T.top})`), I = pn().domain(er(M, (R) => R.x)).range([0, A]).nice(), z = pn().domain(er(M, (R) => R.y)).range([v, 0]).nice(), j = Vu().domain([0, cn(M, (R) => R.size)]).range([m.minBubbleSize, m.maxBubbleSize]);
    let G, _ = !1, L = [];
    if (S && M.length > 0) {
      const R = M.map((P) => {
        const X = P.color;
        return typeof X == "string" ? parseFloat(X) : X;
      }).filter((P) => !isNaN(P));
      if (_ = R.length === M.length && R.every((P) => typeof P == "number"), _) {
        const P = Math.min(...R), X = Math.max(...R);
        G = Ut().domain([P, X]).range(a?.gradient || Ie);
      } else
        L = [...new Set(M.map((P) => String(P.color)))], G = Ot().domain(L).range(a?.colors || Q);
    } else
      G = Ot().domain(["default"]).range([Q[0]]);
    const B = (R, P) => getComputedStyle(document.documentElement).getPropertyValue(R).trim() || P, E = f !== "light", D = E ? B("--dc-text-muted", "#cbd5e1") : B("--dc-text-secondary", "#374151"), Y = E ? B("--dc-border", "#475569") : "#9ca3af";
    if (m.showGrid) {
      const R = $.append("g").attr("class", "grid").attr("transform", `translate(0,${v})`).call(
        ir(I).tickSize(-v).tickFormat(() => "")
      );
      R.selectAll("line").style("stroke", Y).style("stroke-dasharray", "3,3").style("opacity", 0.3), R.select(".domain").style("stroke", "none");
      const P = $.append("g").attr("class", "grid").call(
        ar(z).tickSize(-A).tickFormat(() => "")
      );
      P.selectAll("line").style("stroke", Y).style("stroke-dasharray", "3,3").style("opacity", 0.3), P.select(".domain").style("stroke", "none");
    }
    const V = ir(I);
    F ? V.tickFormat((R) => {
      const P = new Date(R);
      if (isNaN(P.getTime())) return String(R);
      switch (C?.toLowerCase()) {
        case "year":
          return String(P.getUTCFullYear());
        case "quarter": {
          const X = Math.floor(P.getUTCMonth() / 3) + 1;
          return `${P.getUTCFullYear()}-Q${X}`;
        }
        case "month":
          return `${P.getUTCFullYear()}-${String(P.getUTCMonth() + 1).padStart(2, "0")}`;
        case "week":
        case "day":
          return `${P.getUTCFullYear()}-${String(P.getUTCMonth() + 1).padStart(2, "0")}-${String(P.getUTCDate()).padStart(2, "0")}`;
        case "hour":
          return `${String(P.getUTCMonth() + 1).padStart(2, "0")}-${String(P.getUTCDate()).padStart(2, "0")} ${String(P.getUTCHours()).padStart(2, "0")}:00`;
        default:
          return `${P.getUTCFullYear()}-${String(P.getUTCMonth() + 1).padStart(2, "0")}`;
      }
    }) : m.xAxisFormat && V.tickFormat((R) => K(R, m.xAxisFormat));
    const W = $.append("g").attr("transform", `translate(0,${v})`).call(V);
    W.selectAll("text").style("fill", D), W.selectAll("line, path").style("stroke", Y), W.append("text").attr("x", A / 2).attr("y", 35).attr("fill", D).style("text-anchor", "middle").style("font-size", "12px").text(m.xAxisFormat?.label || b(y));
    const re = ar(z);
    m.leftYAxisFormat && re.tickFormat((R) => K(R, m.leftYAxisFormat));
    const pe = $.append("g").call(re);
    pe.selectAll("text").style("fill", D), pe.selectAll("line, path").style("stroke", Y), pe.append("text").attr("transform", "rotate(-90)").attr("y", -35).attr("x", -v / 2).attr("fill", D).style("text-anchor", "middle").style("font-size", "12px").text(m.leftYAxisFormat?.label || b(g));
    const ye = Me("body").append("div").attr("class", "bubble-chart-tooltip").style("position", "absolute").style("padding", "8px").style("background", "rgba(0, 0, 0, 0.8)").style("color", "white").style("border-radius", "4px").style("font-size", "12px").style("pointer-events", "none").style("opacity", 0).style("z-index", 1e3), Fe = $.selectAll(".bubble").data(M).enter().append("circle").attr("class", "bubble").attr("cx", (R) => I(R.x)).attr("cy", (R) => z(R.y)).attr("r", (R) => j(R.size)).style("fill", (R) => S && R.color !== void 0 ? G(_ ? R.color : String(R.color)) : Q[0]).style("opacity", m.bubbleOpacity).style("stroke", "#fff").style("stroke-width", 1).style("cursor", "pointer");
    if (m.showTooltip && Fe.on("mouseover", function(R, P) {
      Me(this).transition().duration(200).style("opacity", 1).attr("r", j(P.size) * 1.1);
      const X = [
        `<strong>${P.series || "Unknown"}</strong>`,
        `${b(y)}: ${P.xLabel || (m.xAxisFormat ? K(P.x, m.xAxisFormat) : P.x)}`,
        `${b(g)}: ${m.leftYAxisFormat ? K(P.y, m.leftYAxisFormat) : P.y}`,
        `${b(w)}: ${m.leftYAxisFormat ? K(P.size, m.leftYAxisFormat) : P.size}`,
        S && P.color ? `${b(S)}: ${P.color}` : ""
      ].filter(Boolean).join("<br>");
      ye.html(X).style("left", R.pageX + 10 + "px").style("top", R.pageY - 10 + "px").transition().duration(200).style("opacity", 1);
    }).on("mousemove", function(R) {
      ye.style("left", R.pageX + 10 + "px").style("top", R.pageY - 10 + "px");
    }).on("mouseout", function(R, P) {
      Me(this).transition().duration(200).style("opacity", m.bubbleOpacity).attr("r", j(P.size)), ye.transition().duration(200).style("opacity", 0);
    }), m.showLegend && S)
      if (_) {
        const X = Math.min(...M.map((me) => me.color)), oe = Math.max(...M.map((me) => me.color)), le = $.append("g").attr("class", "color-legend").attr("transform", `translate(${A / 2 - 200 / 2}, ${v + 60})`), ue = O.append("defs").append("linearGradient").attr("id", "color-scale-gradient").attr("x1", "0%").attr("y1", "0%").attr("x2", "100%").attr("y2", "0%"), se = a?.gradient || Ie;
        se.forEach((me, Te) => {
          ue.append("stop").attr("offset", `${Te / (se.length - 1) * 100}%`).attr("stop-color", me);
        }), le.append("rect").attr("width", 200).attr("height", 20).style("fill", "url(#color-scale-gradient)").style("stroke", "#ccc").style("stroke-width", 1), le.append("text").attr("x", 0).attr("y", 35).attr("text-anchor", "start").style("font-size", "11px").style("fill", D).text(m.leftYAxisFormat ? K(X, m.leftYAxisFormat) : X.toFixed(2)), le.append("text").attr("x", 200).attr("y", 35).attr("text-anchor", "end").style("font-size", "11px").style("fill", D).text(m.leftYAxisFormat ? K(oe, m.leftYAxisFormat) : oe.toFixed(2)), le.append("text").attr("x", 200 / 2).attr("y", -5).attr("text-anchor", "middle").style("font-size", "12px").style("font-weight", "bold").style("fill", D).text(b(S));
      } else {
        const R = L;
        if (R.length > 0) {
          const X = $.append("g").attr("class", "legend").attr("transform", `translate(${A / 2 - R.length * 80 / 2}, ${v + 60})`).selectAll(".legend-item").data(R).enter().append("g").attr("class", "legend-item").attr("transform", (oe, le) => `translate(${le * 80}, 0)`).style("cursor", "pointer");
          X.append("circle").attr("cx", 5).attr("cy", 5).attr("r", 5).style("fill", (oe) => G(oe)).style("opacity", m.bubbleOpacity), X.append("text").attr("x", 15).attr("y", 5).attr("dy", ".35em").style("font-size", "11px").style("fill", D).text((oe) => String(oe)), X.on("mouseover", function(oe, le) {
            Fe.transition().duration(200).style("opacity", (ve) => S && String(ve.color) === le ? 1 : 0.2);
          }).on("mouseout", function() {
            Fe.transition().duration(200).style("opacity", m.bubbleOpacity);
          });
        }
      }
    return () => {
      ye.remove();
    };
  }, [t, n, m, s, c, h, a, f, b]), !t || t.length === 0 ? /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
    /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
    /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in bubble chart" })
  ] }) }) : n?.xAxis && n?.yAxis && n?.series ? /* @__PURE__ */ o("div", { className: "w-full flex-1 flex flex-col relative", style: { height: i, minHeight: "250px", overflow: "hidden" }, children: /* @__PURE__ */ N("div", { ref: u, className: "w-full h-full relative", children: [
    /* @__PURE__ */ o("svg", { ref: l, className: "w-full h-full" }),
    !h && /* @__PURE__ */ o("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ o("div", { className: "text-dc-text-muted text-sm", children: "Measuring chart dimensions..." }) })
  ] }) }) : /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: i }, children: /* @__PURE__ */ N("div", { className: "text-center", children: [
    /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Required" }),
    /* @__PURE__ */ o("div", { className: "text-xs", children: "Bubble chart requires xAxis, yAxis, series, and sizeField dimensions" }),
    /* @__PURE__ */ o("div", { className: "text-xs mt-1", children: "Optional: colorField for bubble coloring" })
  ] }) });
}), yf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: Uu
}, Symbol.toStringTag, { value: "Module" })), Yu = ie.memo(function({
  data: t,
  chartConfig: n,
  displayConfig: r = {},
  queryObject: s,
  height: i = 300
}) {
  const { getFieldLabel: a, meta: l } = Wr(), u = q(
    () => Fo(s, n?.xAxis),
    [s, n?.xAxis]
  ), c = r?.pivotTimeDimension !== !1, d = q(() => !u || !c ? null : Do(t, u, a), [t, u, c, a, l]);
  return !t || t.length === 0 ? /* @__PURE__ */ o(
    "div",
    {
      className: "flex items-center justify-center w-full",
      style: { height: i },
      children: /* @__PURE__ */ N("div", { className: "text-center text-dc-text-muted", children: [
        /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
        /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No data to display in table" })
      ] })
    }
  ) : d?.isPivoted && d.columns.length > 0 ? /* @__PURE__ */ o(
    Bu,
    {
      pivotedData: d,
      height: i,
      meta: l,
      leftYAxisFormat: r?.leftYAxisFormat
    }
  ) : /* @__PURE__ */ o(
    qu,
    {
      data: t,
      chartConfig: n,
      queryObject: s,
      height: i,
      getFieldLabel: a,
      leftYAxisFormat: r?.leftYAxisFormat
    }
  );
});
function Bu({
  pivotedData: e,
  height: t,
  meta: n,
  leftYAxisFormat: r
}) {
  const { columns: s, rows: i } = e;
  return s.length === 0 || i.length === 0 ? /* @__PURE__ */ o(
    "div",
    {
      className: "flex items-center justify-center w-full",
      style: { height: t },
      children: /* @__PURE__ */ N("div", { className: "text-center text-dc-text-muted", children: [
        /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
        /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No data to display in table" })
      ] })
    }
  ) : /* @__PURE__ */ o("div", { className: "w-full overflow-auto", style: { height: t }, children: /* @__PURE__ */ N("table", { className: "min-w-full divide-y border-dc-border", children: [
    /* @__PURE__ */ o("thead", { className: "bg-dc-surface-secondary sticky top-0", children: /* @__PURE__ */ o("tr", { children: s.map((a) => /* @__PURE__ */ o(
      "th",
      {
        className: `px-3 py-2 text-xs font-medium text-dc-text-muted uppercase tracking-wider whitespace-nowrap ${a.isTimeColumn ? "text-right" : "text-left"}`,
        children: a.label
      },
      a.key
    )) }) }),
    /* @__PURE__ */ o("tbody", { className: "bg-dc-surface divide-y border-dc-border", children: i.map((a) => /* @__PURE__ */ o(
      Qu,
      {
        row: a,
        columns: s,
        meta: n,
        leftYAxisFormat: r
      },
      a.id
    )) })
  ] }) });
}
function Qu({
  row: e,
  columns: t,
  meta: n,
  leftYAxisFormat: r
}) {
  const s = $o(e.measureField, n), i = Ya(s);
  return /* @__PURE__ */ o("tr", { className: "hover:bg-dc-surface-secondary", children: t.map((a) => {
    const l = e.values[a.key];
    return a.isMeasureColumn ? e.isFirstInGroup === !1 ? null : /* @__PURE__ */ o(
      "td",
      {
        className: "px-3 py-2 whitespace-nowrap text-sm text-dc-text align-top",
        rowSpan: e.dimensionRowSpan,
        children: /* @__PURE__ */ N("div", { className: "flex items-center", children: [
          /* @__PURE__ */ o(i, { className: "w-3.5 h-3.5 mr-1.5 text-dc-text-muted shrink-0" }),
          /* @__PURE__ */ o("span", { children: l })
        ] })
      },
      a.key
    ) : a.isTimeColumn ? /* @__PURE__ */ o(
      "td",
      {
        className: "px-3 py-2 whitespace-nowrap text-sm text-right text-dc-text",
        children: kr(l, r)
      },
      a.key
    ) : /* @__PURE__ */ o(
      "td",
      {
        className: "px-3 py-2 whitespace-nowrap text-sm text-dc-text",
        children: kr(l)
      },
      a.key
    );
  }) });
}
function kr(e, t) {
  return e == null ? "-" : typeof e == "number" ? t ? K(e, t) : Number.isInteger(e) ? e.toLocaleString() : parseFloat(e.toFixed(2)).toLocaleString() : typeof e == "boolean" ? e ? "Yes" : "No" : String(e);
}
function qu({
  data: e,
  chartConfig: t,
  queryObject: n,
  height: r,
  getFieldLabel: s,
  leftYAxisFormat: i
}) {
  const a = Object.keys(e[0] || {}), l = q(() => {
    if (t?.xAxis && t.xAxis.length > 0)
      return t.xAxis.filter((c) => a.includes(c));
    const u = ko(n);
    if (u.length > 0) {
      const c = u.filter((h) => a.includes(h)), d = a.filter((h) => !c.includes(h));
      return [...c, ...d];
    }
    return a;
  }, [t?.xAxis, n, a]);
  return l.length === 0 ? /* @__PURE__ */ o(
    "div",
    {
      className: "flex items-center justify-center w-full",
      style: { height: r },
      children: /* @__PURE__ */ N("div", { className: "text-center text-dc-text-muted", children: [
        /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No columns available" }),
        /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "Data structure is invalid" })
      ] })
    }
  ) : /* @__PURE__ */ o("div", { className: "w-full overflow-auto", style: { height: r }, children: /* @__PURE__ */ N("table", { className: "min-w-full divide-y border-dc-border", children: [
    /* @__PURE__ */ o("thead", { className: "bg-dc-surface-secondary sticky top-0", children: /* @__PURE__ */ o("tr", { children: l.map((u) => /* @__PURE__ */ o(
      "th",
      {
        className: "px-3 py-2 text-left text-xs font-medium text-dc-text-muted uppercase tracking-wider",
        children: s(u)
      },
      u
    )) }) }),
    /* @__PURE__ */ o("tbody", { className: "bg-dc-surface divide-y border-dc-border", children: e.map((u, c) => /* @__PURE__ */ o("tr", { className: "hover:bg-dc-surface-secondary", children: l.map((d) => /* @__PURE__ */ o(
      "td",
      {
        className: "px-3 py-2 whitespace-nowrap text-sm text-dc-text",
        children: Ku(u[d], i)
      },
      d
    )) }, c)) })
  ] }) });
}
function Ku(e, t) {
  return e == null ? "" : typeof e == "number" ? t ? K(e, t) : e.toLocaleString() : typeof e == "boolean" ? e ? "Yes" : "No" : String(e);
}
const xf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: Yu
}, Symbol.toStringTag, { value: "Module" })), Wu = ie.memo(function({
  data: t,
  chartConfig: n,
  displayConfig: r = {},
  queryObject: s,
  height: i = "100%",
  colorPalette: a
}) {
  const l = be(null), u = be(null), [c, d] = J({ width: 0, height: 0 }), [h, p] = J(!1), [f, b] = J("light"), m = ke();
  Ae(() => (b(Ge()), Zr((A) => {
    b(A);
  })), []);
  const x = q(() => ({
    showTooltip: r?.showTooltip ?? !0,
    showLabels: r?.showLabels ?? !0,
    fitToWidth: r?.fitToWidth ?? !1
  }), [r?.showTooltip, r?.showLabels, r?.fitToWidth]);
  xn(() => {
    let T = 0;
    const A = 10;
    let v, O;
    const $ = () => {
      if (u.current) {
        const { width: z, height: j } = u.current.getBoundingClientRect();
        if (z > 0 && j > 0)
          return d({ width: z, height: j }), p(!0), !0;
      }
      return !1;
    };
    if (!$() && T < A) {
      const z = () => {
        !$() && T < A && (T++, O = setTimeout(() => {
          v = requestAnimationFrame(z);
        }, 50 * T));
      };
      v = requestAnimationFrame(z);
    }
    return () => {
      v && cancelAnimationFrame(v), O && clearTimeout(O);
    };
  }, []), Ae(() => {
    let T = null;
    const A = () => {
      if (u.current) {
        const { width: v, height: O } = u.current.getBoundingClientRect();
        v > 0 && O > 0 && (d({ width: v, height: O }), h || p(!0));
      }
    };
    return u.current && (T = new ResizeObserver(() => A()), T.observe(u.current), A()), window.addEventListener("resize", A), () => {
      T && T.disconnect(), window.removeEventListener("resize", A);
    };
  }, [h]);
  const y = (T) => Math.floor(T.getMonth() / 3) + 1, g = (T) => T.getMonth() % 3 + 1, k = (T) => {
    const A = T.getDate();
    return Math.floor((A - 1) / 7) + 1;
  }, w = Ve((T) => {
    switch (T?.toLowerCase()) {
      case "year":
        return null;
      case "quarter":
        return {
          extractX: (A) => A.getFullYear(),
          extractY: (A) => y(A) - 1,
          // 0-3 for indexing
          xLabels: [],
          // Will be determined from data
          yLabels: ["Q1", "Q2", "Q3", "Q4"],
          xFormat: (A) => `'${A.toString().slice(-2)}`,
          // '24 instead of 2024
          yFormat: (A) => ["Q1", "Q2", "Q3", "Q4"][A] || "",
          cellWidth: 16,
          cellHeight: 16
        };
      case "month":
        return {
          extractX: (A) => {
            const v = A.getFullYear(), O = y(A);
            return v * 10 + O;
          },
          extractY: (A) => g(A) - 1,
          // 0-2 for indexing
          xLabels: [],
          // Will be determined from data
          yLabels: ["Month 1", "Month 2", "Month 3"],
          xFormat: (A) => `Q${A % 10}`,
          yFormat: (A) => ["Month 1", "Month 2", "Month 3"][A] || "",
          cellWidth: 16,
          cellHeight: 16,
          hasHierarchicalLabels: !0,
          // Flag to indicate we need special handling
          getYearFromX: (A) => Math.floor(A / 10)
          // Helper to get year for grouping
        };
      case "week":
        return {
          extractX: (A) => {
            const v = A.getFullYear(), O = A.getMonth() + 1;
            return v * 100 + O;
          },
          extractY: (A) => k(A) - 1,
          // 0-5 for indexing
          xLabels: [],
          // Will be determined from data
          yLabels: ["Week 1", "Week 2", "Week 3", "Week 4", "Week 5"],
          xFormat: (A) => {
            const v = A % 100;
            return ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"][v - 1] || "";
          },
          yFormat: (A) => ["Week 1", "Week 2", "Week 3", "Week 4", "Week 5"][A] || "",
          cellWidth: 16,
          cellHeight: 16,
          hasHierarchicalLabels: !0,
          // Add hierarchical labels like month view
          getYearFromX: (A) => Math.floor(A / 100)
          // Helper to get year for grouping
        };
      case "day":
        return {
          extractX: (A) => {
            const { year: v, week: O } = S(A);
            return v * 100 + O;
          },
          extractY: (A) => A.getDay(),
          // 0-6 (Sun-Sat)
          xLabels: [],
          // Will be determined from data
          yLabels: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
          xFormat: (A) => `${A % 100}`,
          yFormat: (A) => ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"][A] || "",
          cellWidth: 16,
          cellHeight: 16,
          hasHierarchicalLabels: !0,
          // Add hierarchical labels
          getYearFromX: (A) => Math.floor(A / 100)
          // Helper to get year for grouping
        };
      case "hour":
        return {
          extractX: (A) => {
            const v = A.getFullYear(), O = A.getMonth() + 1, $ = A.getDate();
            return v * 1e4 + O * 100 + $;
          },
          extractY: (A) => Math.floor(A.getHours() / 3),
          // 0-7 for 8 three-hour blocks
          xLabels: [],
          // Will be determined from data
          yLabels: ["00-03", "03-06", "06-09", "09-12", "12-15", "15-18", "18-21", "21-00"],
          xFormat: (A) => `${A % 100}`,
          yFormat: (A) => ["00-03", "03-06", "06-09", "09-12", "12-15", "15-18", "18-21", "21-00"][A] || "",
          cellWidth: 16,
          cellHeight: 16,
          hasHierarchicalLabels: !0,
          // Show year/month grouping above
          getYearFromX: (A) => Math.floor(A / 100)
          // Extract YYYYMM for month grouping
        };
      default:
        return null;
    }
  }, []), S = (T) => {
    const A = new Date(Date.UTC(T.getFullYear(), T.getMonth(), T.getDate())), v = A.getUTCDay() || 7;
    A.setUTCDate(A.getUTCDate() + 4 - v);
    const O = A.getUTCFullYear(), $ = new Date(Date.UTC(O, 0, 1)), I = Math.ceil(((A.getTime() - $.getTime()) / 864e5 + 1) / 7);
    return { year: O, week: I };
  };
  if (Ae(() => {
    if (!t || t.length === 0 || !l.current || !h || c.width === 0 || (Me(l.current).selectAll("*").remove(), !n?.dateField || !n?.valueField))
      return;
    const T = Array.isArray(n.dateField) ? n.dateField[0] : n.dateField, A = Array.isArray(n.valueField) ? n.valueField[0] : n.valueField;
    if (!T || !A)
      return;
    const O = (() => {
      if (!s?.timeDimensions || s.timeDimensions.length === 0)
        return "day";
      const H = s.timeDimensions.find(
        (Z) => Z.dimension === T || Z.dimension.includes(T)
      );
      if (H && H.granularity)
        return H.granularity;
      const U = s.timeDimensions[0];
      return U && U.granularity ? U.granularity : "day";
    })(), $ = w(O);
    if (!$)
      return;
    const I = t.map((H) => {
      const U = H[T], Z = typeof H[A] == "string" ? parseFloat(H[A]) : H[A] || 0;
      let ce;
      if (typeof U == "string") {
        let de = U;
        U.includes(" ") && (de = U.replace(" ", "T").replace("+00", "Z").replace(/\+\d{2}:\d{2}$/, "Z")), !de.endsWith("Z") && !de.includes("+") && (de = de + "Z"), ce = new Date(de);
      } else
        ce = new Date(U);
      if (isNaN(ce.getTime()))
        return null;
      const De = $.extractX(ce), $e = $.extractY(ce);
      return {
        x: De,
        y: $e,
        value: Z,
        date: ce,
        label: ne(U, O)
      };
    }).filter((H) => H !== null);
    if (I.length === 0) return;
    const z = cn(I, (H) => H.y) || 0, j = rr(I, (H) => H.y) || 0, _ = (() => {
      const H = [...new Set(I.map((U) => U.x))].sort();
      return H;
    })(), L = _.length * $.cellWidth + (_.length - 1) * 4, B = (z - j + 1) * $.cellHeight + (z - j) * 4, E = {
      left: 60,
      // Space for Y-axis labels
      bottom: 10,
      // Reduced since labels are at top
      top: $.hasHierarchicalLabels ? 40 : 25,
      // Extra space for hierarchical labels
      right: 10
    }, D = c.width - E.left - E.right, Y = c.height - E.top - E.bottom;
    let V, W;
    if (x.fitToWidth) {
      const H = D / L, U = Y / B, Z = Math.min(H, U);
      V = $.cellWidth * Z, W = $.cellHeight * Z;
    } else {
      const U = { width: 16, height: 16 }, Z = 24, ce = D / L, De = Y / B, $e = Math.min(ce, De);
      V = Math.max(U.width, Math.min(Z, $.cellWidth * $e)), W = Math.max(U.height, Math.min(Z, $.cellHeight * $e)), O === "week" && V < U.width && (V = U.width);
    }
    const re = _.length * V + (_.length - 1) * 4, ye = re > D ? re + E.left + E.right : c.width, R = Me(l.current).attr("width", ye).attr("height", c.height).append("g").attr("transform", `translate(${E.left},${E.top})`), P = I.map((H) => H.value), X = rr(P) || 0, oe = cn(P) || 1, le = Ut().domain([X, oe]).range(a?.gradient || Ie), ve = /* @__PURE__ */ new Map();
    I.forEach((H) => {
      const U = `${H.x}-${H.y}`;
      ve.set(U, H);
    });
    const ue = (H, U) => getComputedStyle(document.documentElement).getPropertyValue(H).trim() || U, se = f !== "light", me = se ? ue("--dc-text-muted", "#cbd5e1") : ue("--dc-text-secondary", "#374151"), Te = ue("--dc-border", "#e5e7eb"), ks = se ? ue("--dc-bg-secondary", "#1e293b") : ue("--dc-bg-secondary", "#f3f4f6"), On = se ? ue("--dc-border", "#334155") : ue("--dc-bg", "#ffffff"), dt = Me("body").append("div").attr("class", "activity-grid-tooltip").style("position", "absolute").style("padding", "8px").style("background", "rgba(0, 0, 0, 0.8)").style("color", "white").style("border-radius", "4px").style("font-size", "12px").style("pointer-events", "none").style("opacity", 0).style("z-index", 1e3), Je = /* @__PURE__ */ new Map();
    _.forEach((H, U) => {
      Je.set(H, U);
    });
    for (const H of _)
      for (let U = j; U <= z; U++) {
        const Z = `${H}-${U}`, ce = ve.get(Z), De = Je.get(H) || 0, $e = R.append("rect").attr("x", De * (V + 4)).attr("y", (U - j) * (W + 4)).attr("width", V).attr("height", W).attr("rx", 2).attr("ry", 2).style("fill", ce ? le(ce.value) : ks).style("stroke", On).style("stroke-width", 1);
        x.showTooltip && $e.style("cursor", "pointer").on("mouseover", function(de) {
          if (Me(this).style("stroke", "#000").style("stroke-width", 2), ce) {
            const Ee = [
              `<strong>${ce.label}</strong>`,
              `${m(A)}: ${ce.value}`
            ].join("<br>");
            dt.html(Ee).style("left", de.pageX + 10 + "px").style("top", de.pageY - 10 + "px").transition().duration(200).style("opacity", 1);
          }
        }).on("mousemove", function(de) {
          dt.style("left", de.pageX + 10 + "px").style("top", de.pageY - 10 + "px");
        }).on("mouseout", function() {
          Me(this).style("stroke", On).style("stroke-width", 1), dt.transition().duration(200).style("opacity", 0);
        });
      }
    if (x.showLabels) {
      if ($.hasHierarchicalLabels && $.getYearFromX) {
        const H = /* @__PURE__ */ new Map();
        for (const U of _) {
          const Z = $.getYearFromX(U);
          H.has(Z) || H.set(Z, []), H.get(Z).push(U);
        }
        for (const U of _) {
          const Z = Je.get(U) || 0;
          R.append("text").attr("x", Z * (V + 4) + V / 2).attr("y", -8).attr("text-anchor", "middle").style("font-size", "10px").style("fill", me).text($.xFormat(U));
        }
        for (const [U, Z] of H)
          if (Z.length > 0) {
            const ce = Math.min(...Z.map((Ee) => Je.get(Ee) || 0)), De = Math.max(...Z.map((Ee) => Je.get(Ee) || 0)), $e = (ce + De) / 2;
            let de = "";
            if (U > 9999) {
              const Ee = Math.floor(U / 100), Fs = U % 100;
              de = `${["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][Fs - 1]} '${Ee.toString().slice(-2)}`;
            } else
              de = `'${U.toString().slice(-2)}`;
            R.append("text").attr("x", $e * (V + 4) + V / 2).attr("y", -25).attr("text-anchor", "middle").style("font-size", "12px").style("font-weight", "bold").style("fill", me).text(de), Z.length > 1 && R.append("line").attr("x1", ce * (V + 4)).attr("x2", De * (V + 4) + V).attr("y1", -20).attr("y2", -20).style("stroke", Te).style("stroke-width", 1).style("opacity", 0.3);
          }
      } else {
        const H = Math.max(1, Math.floor(_.length / 10));
        for (let U = 0; U < _.length; U += H) {
          const Z = _[U];
          R.append("text").attr("x", U * (V + 4) + V / 2).attr("y", -8).attr("text-anchor", "middle").style("font-size", "10px").style("fill", me).text($.xFormat(Z));
        }
      }
      for (let H = j; H <= z; H++)
        R.append("text").attr("x", -8).attr("y", (H - j) * (W + 4) + W / 2).attr("text-anchor", "end").attr("dy", ".35em").style("font-size", "10px").style("fill", me).text($.yFormat(H));
    }
    return () => {
      dt.remove();
    };
  }, [t, n, r, s, c, h, x, a, f, m, w]), !t || t.length === 0)
    return /* @__PURE__ */ o(
      "div",
      {
        className: "flex items-center justify-center w-full",
        style: { height: i },
        children: /* @__PURE__ */ N("div", { className: "text-center text-dc-text-muted", children: [
          /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
          /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in activity grid" })
        ] })
      }
    );
  if (!(n?.dateField && n?.valueField))
    return /* @__PURE__ */ o(
      "div",
      {
        className: "flex items-center justify-center w-full",
        style: { height: i },
        children: /* @__PURE__ */ N("div", { className: "text-center text-dc-text-muted", children: [
          /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Required" }),
          /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "Activity grid requires a time dimension and a measure" })
        ] })
      }
    );
  const F = Array.isArray(n.dateField) ? n.dateField[0] : n.dateField;
  return (s?.timeDimensions?.find(
    (T) => T.dimension === F || T.dimension.includes(F)
  )?.granularity || "day")?.toLowerCase() === "year" ? /* @__PURE__ */ o(
    "div",
    {
      className: "flex items-center justify-center w-full",
      style: { height: i },
      children: /* @__PURE__ */ N("div", { className: "text-center text-dc-text-muted", children: [
        /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Granularity Too High" }),
        /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "Activity grids work best with hour, day, week, month, or quarter granularity" }),
        /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary mt-1", children: "Please choose a lower granularity for your time dimension" })
      ] })
    }
  ) : /* @__PURE__ */ o("div", { className: "w-full flex flex-col relative", style: { height: i, minHeight: "250px", overflow: "hidden", width: "100%" }, children: /* @__PURE__ */ N("div", { ref: u, className: "w-full h-full relative overflow-x-auto", style: { width: "100%" }, children: [
    /* @__PURE__ */ o("svg", { ref: l, className: "h-full" }),
    !h && /* @__PURE__ */ o("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ o("div", { className: "text-dc-text-muted text-sm", children: "Measuring chart dimensions..." }) })
  ] }) });
}), gf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: Wu
}, Symbol.toStringTag, { value: "Module" }));
function As({
  values: e,
  min: t,
  max: n,
  color: r = "#1f2937",
  bucketCount: s = 12,
  height: i = 32,
  formatValue: a = (d) => d.toString(),
  width: l,
  showAverageIndicator: u = !0,
  targetValue: c
}) {
  const d = new Array(s).fill(0), h = n - t;
  e.forEach((x) => {
    if (h === 0)
      d[Math.floor(s / 2)]++;
    else {
      let y = Math.floor((x - t) / h * (s - 1));
      y = Math.max(0, Math.min(s - 1, y)), d[y]++;
    }
  });
  const p = Math.max(...d), f = e.reduce((x, y) => x + y, 0) / e.length, b = h === 0 ? 50 : (f - t) / h * 100, m = c !== void 0 && h > 0 ? (c - t) / h * 100 : null;
  return /* @__PURE__ */ N("div", { className: "flex flex-col items-center", children: [
    /* @__PURE__ */ N(
      "div",
      {
        className: "relative flex items-end justify-center space-x-0.5",
        style: {
          height: `${i}px`,
          width: l ? `${l}px` : "200px",
          minWidth: "200px"
        },
        children: [
          d.map((x, y) => {
            const g = p > 0 ? x / p : 0, k = 0.1, w = x > 0 ? Math.max(k, g) : k;
            return /* @__PURE__ */ o(
              "div",
              {
                className: "flex-1 rounded-t-sm transition-all duration-300 ease-out",
                style: {
                  height: `${w * i}px`,
                  backgroundColor: r,
                  opacity: x > 0 ? 0.7 + g * 0.3 : 0.2
                  // higher opacity for buckets with data
                },
                title: `${x} values in this range`
              },
              y
            );
          }),
          u && /* @__PURE__ */ o(
            "div",
            {
              className: "absolute top-0 bottom-0 pointer-events-none",
              style: {
                left: `${b}%`,
                transform: "translateX(-50%)",
                width: "2px",
                backgroundColor: "#ef4444",
                opacity: 0.8,
                zIndex: 10
              },
              title: `Average: ${a(f)}`,
              children: /* @__PURE__ */ o(
                "div",
                {
                  className: "absolute -top-1",
                  style: {
                    left: "50%",
                    transform: "translateX(-50%)",
                    width: "0",
                    height: "0",
                    borderLeft: "4px solid transparent",
                    borderRight: "4px solid transparent",
                    borderTop: "6px solid #ef4444"
                  }
                }
              )
            }
          ),
          m !== null && c !== void 0 && /* @__PURE__ */ o(
            "div",
            {
              className: "absolute top-0 bottom-0 pointer-events-none",
              style: {
                left: `${Math.max(0, Math.min(100, m))}%`,
                transform: "translateX(-50%)",
                width: "2px",
                backgroundColor: "#10b981",
                opacity: 0.8,
                zIndex: 11
              },
              title: `Target: ${a(c)}`,
              children: /* @__PURE__ */ o(
                "div",
                {
                  className: "absolute -top-1",
                  style: {
                    left: "50%",
                    transform: "translateX(-50%)",
                    width: "0",
                    height: "0",
                    borderLeft: "4px solid transparent",
                    borderRight: "4px solid transparent",
                    borderTop: "6px solid #10b981"
                  }
                }
              )
            }
          )
        ]
      }
    ),
    /* @__PURE__ */ N(
      "div",
      {
        className: "flex justify-between mt-2 text-xs text-dc-text-muted",
        style: {
          width: l ? `${l}px` : "200px",
          minWidth: "200px"
        },
        children: [
          /* @__PURE__ */ o("span", { children: a(t) }),
          /* @__PURE__ */ o("span", { children: a(n) })
        ]
      }
    ),
    /* @__PURE__ */ N("div", { className: "text-center mt-1 text-xs text-dc-text-muted", children: [
      "Average of ",
      e.length,
      " values"
    ] })
  ] });
}
const Gu = ie.memo(function({
  data: t,
  chartConfig: n,
  displayConfig: r = {},
  queryObject: s,
  height: i = "100%",
  colorPalette: a
}) {
  const [l, u] = J(32), [c, d] = J(250), h = be(null), p = be(null), f = ke(), b = q(() => n?.yAxis ? typeof n.yAxis == "string" ? [n.yAxis] : Array.isArray(n.yAxis) ? n.yAxis : [] : [], [n?.yAxis]), m = b[0] || "", x = s?.timeDimensions?.[0]?.dimension || void 0, y = q(() => {
    if (!t || t.length === 0) return [];
    let E = [...t];
    return x && (E = E.sort((D, Y) => {
      const V = D[x], W = Y[x];
      return V < W ? -1 : V > W ? 1 : 0;
    })), E;
  }, [t, x]), { useLastCompletePeriod: g = !0, skipLastPeriod: k = !1 } = r, {
    filteredData: w,
    excludedIncompletePeriod: S,
    skippedLastPeriod: C,
    granularity: F
  } = q(() => y.length === 0 ? { filteredData: [], excludedIncompletePeriod: !1, skippedLastPeriod: !1, granularity: void 0 } : Jr(y, x, s, g, k), [y, x, s, g, k]), M = w, T = q(() => !m || M.length === 0 ? [] : M.map((D) => {
    if (D[m] !== void 0)
      return D[m];
    const Y = Object.keys(D).filter(
      (V) => typeof D[V] == "number" && !isNaN(D[V])
    );
    if (Y.length > 0)
      return D[Y[0]];
  }).filter((D) => D != null && !isNaN(Number(D))).map((D) => Number(D)), [M, m]), { avg: A, min: v, max: O } = q(() => {
    if (T.length === 0) return { avg: 0, min: 0, max: 0 };
    const D = T.reduce((W, re) => W + re, 0) / T.length, Y = Math.min(...T), V = Math.max(...T);
    return { avg: D, min: Y, max: V };
  }, [T]), $ = Ve((E) => {
    if (r.formatValue)
      return r.formatValue(E);
    if (E == null)
      return "—";
    const D = r.decimals ?? 0, Y = r.prefix ?? "";
    let V;
    return Math.abs(E) >= 1e9 ? V = (E / 1e9).toFixed(D) + "B" : Math.abs(E) >= 1e6 ? V = (E / 1e6).toFixed(D) + "M" : Math.abs(E) >= 1e3 ? V = (E / 1e3).toFixed(D) + "K" : V = E.toFixed(D), Y + V;
  }, [r]), I = T.length === 1 ? T[0] : A, z = T.length > 1, j = q(() => {
    if (r.valueColorIndex !== void 0 && a?.colors) {
      const E = r.valueColorIndex;
      if (E >= 0 && E < a.colors.length)
        return a.colors[E];
    }
    return a?.colors?.[0] || "#1f2937";
  }, [r.valueColorIndex, a?.colors]), G = q(() => Vt(r?.target || ""), [r?.target]), _ = G.length > 0 ? G[0] : null, L = _ !== null && T.length > 0 ? Vo(I, _) : null, B = q(() => {
    if (L === null) return "#6B7280";
    if (L >= 0) {
      const E = r.positiveColorIndex ?? 1;
      return a?.colors?.[E] || "#10B981";
    } else {
      const E = r.negativeColorIndex ?? 7;
      return a?.colors?.[E] || "#EF4444";
    }
  }, [L, r.positiveColorIndex, r.negativeColorIndex, a?.colors]);
  return Ae(() => {
    const E = () => {
      if (h.current) {
        const W = h.current.getBoundingClientRect(), re = W.width, pe = W.height;
        if (re > 0 && pe > 0) {
          const ye = re / 5, Fe = pe / 4, R = Math.min(ye, Fe), P = Math.max(24, Math.min(R, 120));
          u(P), setTimeout(() => {
            if (p.current) {
              const oe = p.current.getBoundingClientRect().width, le = Math.max(oe, Math.min(re * 0.6, 300));
              d(le);
            }
          }, 10);
        }
      }
    }, D = setTimeout(E, 50), Y = new ResizeObserver(() => {
      setTimeout(E, 10);
    });
    return h.current && Y.observe(h.current), () => {
      clearTimeout(D), Y.disconnect();
    };
  }, [t, n]), !t || t.length === 0 ? /* @__PURE__ */ o(
    "div",
    {
      className: "flex items-center justify-center w-full h-full",
      style: {
        height: i === "100%" ? "100%" : i,
        minHeight: i === "100%" ? "200px" : void 0
      },
      children: /* @__PURE__ */ N("div", { className: "text-center text-dc-text-muted", children: [
        /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
        /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display" })
      ] })
    }
  ) : b.length === 0 ? /* @__PURE__ */ o(
    "div",
    {
      className: "flex items-center justify-center w-full h-full",
      style: {
        height: i === "100%" ? "100%" : i,
        minHeight: i === "100%" ? "200px" : void 0,
        backgroundColor: "var(--dc-danger-bg)",
        color: "var(--dc-danger)",
        borderColor: "var(--dc-danger-border)"
      },
      children: /* @__PURE__ */ N("div", { className: "text-center", children: [
        /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
        /* @__PURE__ */ o("div", { className: "text-xs", children: "No measure fields configured" })
      ] })
    }
  ) : T.length === 0 ? /* @__PURE__ */ N(
    "div",
    {
      ref: h,
      className: "flex flex-col items-center justify-center w-full h-full p-4",
      style: {
        height: i === "100%" ? "100%" : i,
        minHeight: i === "100%" ? "200px" : void 0
      },
      children: [
        /* @__PURE__ */ o(
          "div",
          {
            className: "text-dc-text-secondary font-bold text-center mb-3",
            style: {
              fontSize: "14px",
              lineHeight: "1.2"
            },
            children: f(m)
          }
        ),
        /* @__PURE__ */ o(
          "div",
          {
            className: "font-bold leading-none text-dc-text-muted",
            style: {
              fontSize: `${l}px`
            },
            children: "—"
          }
        ),
        /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-muted mt-2", children: "No data" })
      ]
    }
  ) : /* @__PURE__ */ N(
    "div",
    {
      ref: h,
      className: "flex flex-col items-center justify-center w-full h-full p-4",
      style: {
        height: i === "100%" ? "100%" : i,
        minHeight: i === "100%" ? "200px" : void 0
      },
      children: [
        /* @__PURE__ */ N(
          "div",
          {
            className: "text-dc-text-secondary font-bold text-center mb-3 flex items-center justify-center gap-1",
            style: {
              fontSize: "14px",
              lineHeight: "1.2"
            },
            children: [
              /* @__PURE__ */ o("span", { children: (() => {
                const E = f(m);
                return E && E.length > 1 ? E : m;
              })() }),
              (S || C) && /* @__PURE__ */ o(
                "span",
                {
                  title: C ? `Excludes last ${F || "period"}` : `Excludes current incomplete ${F}`,
                  className: "cursor-help",
                  children: /* @__PURE__ */ o(bt, { icon: bn, className: "w-4 h-4 text-dc-text-muted opacity-70" })
                }
              )
            ]
          }
        ),
        /* @__PURE__ */ N("div", { className: "flex items-center justify-center gap-4 mb-3", children: [
          /* @__PURE__ */ o(
            "div",
            {
              ref: p,
              className: "font-bold leading-none",
              style: {
                fontSize: `${l}px`,
                color: j
              },
              children: $(I)
            }
          ),
          _ !== null && L !== null && /* @__PURE__ */ N("div", { className: "flex flex-col items-start", children: [
            /* @__PURE__ */ o(
              "div",
              {
                className: "font-semibold",
                style: {
                  fontSize: `${Math.max(12, l * 0.3)}px`,
                  color: B,
                  lineHeight: "1.2"
                },
                children: Ho(L, 1)
              }
            ),
            /* @__PURE__ */ N(
              "div",
              {
                className: "text-dc-text-muted text-xs",
                style: {
                  opacity: 0.7,
                  fontSize: `${Math.max(10, l * 0.2)}px`
                },
                children: [
                  "vs ",
                  $(_)
                ]
              }
            )
          ] })
        ] }),
        r.suffix && !r.formatValue && /* @__PURE__ */ o(
          "div",
          {
            className: "text-dc-text-muted text-center",
            style: {
              fontSize: "14px",
              lineHeight: "1.2",
              opacity: 0.8
            },
            children: r.suffix
          }
        ),
        z && /* @__PURE__ */ o("div", { className: "mt-4", children: /* @__PURE__ */ o(
          As,
          {
            values: T,
            min: v,
            max: O,
            color: j,
            formatValue: $,
            height: 24,
            width: c,
            targetValue: _ || void 0
          }
        ) })
      ]
    }
  );
}), bf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: Gu
}, Symbol.toStringTag, { value: "Module" }));
function Xu({
  values: e,
  lastValue: t,
  positiveColor: n,
  negativeColor: r,
  formatValue: s,
  width: i,
  height: a
}) {
  const l = Math.max(10, Math.floor(i / 10)), u = e.length > l ? e.slice(-l) : e, c = u.map((g) => g - t), d = Math.min(...c, 0), h = Math.max(...c, 0);
  if (Math.max(Math.abs(d), Math.abs(h)) === 0 || c.length === 0)
    return /* @__PURE__ */ o(
      "div",
      {
        className: "flex items-center justify-center bg-dc-bg-secondary rounded-sm border border-dc-border",
        style: { width: `${i}px`, height: `${a}px` },
        children: /* @__PURE__ */ o("span", { className: "text-xs text-dc-text-muted", children: "No variance data" })
      }
    );
  const f = 2, b = i - (u.length - 1) * f, m = Math.max(4, b / u.length), x = h - d, y = x > 0 ? h / x * 100 : 50;
  return /* @__PURE__ */ N("div", { className: "flex items-center space-x-2", children: [
    /* @__PURE__ */ N(
      "div",
      {
        className: "relative",
        style: {
          width: `${i}px`,
          height: `${a}px`
        },
        children: [
          /* @__PURE__ */ o(
            "div",
            {
              className: "absolute left-0 right-0",
              style: {
                height: "1px",
                top: `${y}%`,
                backgroundColor: "var(--dc-border)",
                zIndex: 1
              }
            }
          ),
          c.map((g, k) => {
            const w = Math.abs(g) / x, S = Math.max(2, w * (a - 4)), C = g >= 0, F = k === u.length - 1, M = C ? n : r, T = k * (m + f);
            return /* @__PURE__ */ o(
              "div",
              {
                className: "absolute rounded-xs",
                style: {
                  left: `${T}px`,
                  width: `${m}px`,
                  height: `${S}px`,
                  backgroundColor: M,
                  opacity: F ? 1 : 0.6,
                  // Position bar relative to zero line
                  ...C ? { bottom: `${100 - y}%` } : { top: `${y}%` },
                  zIndex: 2
                },
                title: `${s(u[k])}: ${g >= 0 ? "+" : ""}${s(g)} vs current`
              },
              k
            );
          })
        ]
      }
    ),
    /* @__PURE__ */ N(
      "div",
      {
        className: "flex flex-col justify-between text-xs text-dc-text-muted",
        style: { height: `${a}px` },
        children: [
          /* @__PURE__ */ N("span", { children: [
            "+",
            s(h)
          ] }),
          /* @__PURE__ */ N("span", { children: [
            (d < 0, ""),
            s(d)
          ] })
        ]
      }
    )
  ] });
}
const Zu = ie.memo(function({
  data: t,
  chartConfig: n,
  displayConfig: r = {},
  queryObject: s,
  height: i = "100%",
  colorPalette: a
}) {
  const [l, u] = J(32), [c, d] = J(250), h = be(null), p = be(null), f = ke();
  if (Ae(() => {
    const D = () => {
      if (h.current) {
        const re = h.current.getBoundingClientRect(), pe = re.width, ye = re.height;
        if (pe > 0 && ye > 0) {
          const Fe = pe / 4, R = ye / 4, P = Math.min(Fe, R), X = Math.max(28, Math.min(P, 140));
          u(X), setTimeout(() => {
            if (p.current) {
              const le = p.current.getBoundingClientRect().width, ve = pe - 100, ue = Math.max(
                le,
                Math.min(ve, pe * 0.7)
              );
              d(Math.max(100, ue));
            }
          }, 10);
        }
      }
    }, Y = setTimeout(D, 50), V = new ResizeObserver(() => {
      setTimeout(D, 10);
    });
    return h.current && V.observe(h.current), () => {
      clearTimeout(Y), V.disconnect();
    };
  }, [t, n]), !t || t.length === 0)
    return /* @__PURE__ */ o(
      "div",
      {
        className: "flex items-center justify-center w-full h-full",
        style: {
          height: i === "100%" ? "100%" : i,
          minHeight: i === "100%" ? "200px" : void 0
        },
        children: /* @__PURE__ */ N("div", { className: "text-center text-dc-text-muted", children: [
          /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
          /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display" })
        ] })
      }
    );
  let b = [], m = [];
  if (n?.yAxis && (b = Array.isArray(n.yAxis) ? n.yAxis : [n.yAxis]), n?.xAxis && (m = Array.isArray(n.xAxis) ? n.xAxis : [n.xAxis]), b.length === 0)
    return /* @__PURE__ */ o(
      "div",
      {
        className: "flex items-center justify-center w-full h-full",
        style: {
          height: i === "100%" ? "100%" : i,
          minHeight: i === "100%" ? "200px" : void 0,
          backgroundColor: "var(--dc-danger-bg)",
          color: "var(--dc-danger)",
          borderColor: "var(--dc-danger-border)"
        },
        children: /* @__PURE__ */ N("div", { className: "text-center", children: [
          /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
          /* @__PURE__ */ o("div", { className: "text-xs", children: "No measure field configured" })
        ] })
      }
    );
  const x = b[0], y = m[0];
  let g = [...t];
  y && (g = g.sort((D, Y) => {
    const V = D[y], W = Y[y];
    return V < W ? -1 : V > W ? 1 : 0;
  }));
  const { useLastCompletePeriod: k = !0, skipLastPeriod: w = !1 } = r, {
    filteredData: S,
    excludedIncompletePeriod: C,
    skippedLastPeriod: F,
    granularity: M
  } = Jr(
    g,
    y,
    s,
    k,
    w
  ), A = S.map((D) => D[x]).filter((D) => D != null && !isNaN(Number(D))).map((D) => Number(D));
  if (A.length < 2)
    return /* @__PURE__ */ o(
      "div",
      {
        className: "flex items-center justify-center w-full h-full",
        style: {
          height: i === "100%" ? "100%" : i,
          minHeight: i === "100%" ? "200px" : void 0,
          backgroundColor: "var(--dc-warning-bg)",
          color: "var(--dc-warning)",
          borderColor: "var(--dc-warning-border)"
        },
        children: /* @__PURE__ */ N("div", { className: "text-center", children: [
          /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Insufficient Data" }),
          /* @__PURE__ */ o("div", { className: "text-xs", children: "Delta calculation requires at least 2 data points" }),
          /* @__PURE__ */ N("div", { className: "text-xs", children: [
            "Current data points: ",
            A.length
          ] })
        ] })
      }
    );
  const v = A[A.length - 1], O = A[A.length - 2], $ = v - O, I = O !== 0 ? $ / Math.abs(O) * 100 : 0, z = $ >= 0, j = (D) => {
    if (r.formatValue)
      return r.formatValue(D);
    if (D == null)
      return "—";
    const Y = r.decimals ?? 0, V = r.prefix ?? "";
    let W;
    return Math.abs(D) >= 1e9 ? W = (D / 1e9).toFixed(Y) + "B" : Math.abs(D) >= 1e6 ? W = (D / 1e6).toFixed(Y) + "M" : Math.abs(D) >= 1e3 ? W = (D / 1e3).toFixed(Y) + "K" : W = D.toFixed(Y), V + W;
  }, G = () => {
    if (r.positiveColorIndex !== void 0 && a?.colors) {
      const D = r.positiveColorIndex;
      if (D >= 0 && D < a.colors.length)
        return a.colors[D];
    }
    return "#10b981";
  }, _ = () => {
    if (r.negativeColorIndex !== void 0 && a?.colors) {
      const D = r.negativeColorIndex;
      if (D >= 0 && D < a.colors.length)
        return a.colors[D];
    }
    return "#ef4444";
  }, L = G(), B = _(), E = z ? L : B;
  return /* @__PURE__ */ N(
    "div",
    {
      ref: h,
      className: "flex flex-col items-center justify-center w-full h-full p-4",
      style: {
        height: i === "100%" ? "100%" : i,
        minHeight: i === "100%" ? "200px" : void 0
      },
      children: [
        /* @__PURE__ */ N(
          "div",
          {
            className: "text-dc-text-secondary font-bold text-center mb-2 flex items-center justify-center gap-1",
            style: {
              fontSize: "14px",
              lineHeight: "1.2"
            },
            children: [
              /* @__PURE__ */ o("span", { children: (() => {
                const D = f(x);
                return D && D.length > 1 ? D : x;
              })() }),
              (C || F) && /* @__PURE__ */ o(
                "span",
                {
                  title: F ? `Excludes last ${M || "period"}` : `Excludes current incomplete ${M}`,
                  className: "cursor-help",
                  children: /* @__PURE__ */ o(
                    bt,
                    {
                      icon: bn,
                      className: "w-4 h-4 text-dc-text-muted opacity-70"
                    }
                  )
                }
              )
            ]
          }
        ),
        /* @__PURE__ */ N("div", { className: "flex items-center justify-center space-x-4 mb-2", children: [
          /* @__PURE__ */ o(
            "div",
            {
              ref: p,
              className: "font-bold leading-none",
              style: {
                fontSize: `${l}px`,
                color: "var(--dc-text)"
                // Keep main value neutral
              },
              children: j(v)
            }
          ),
          /* @__PURE__ */ N("div", { className: "flex items-center space-x-1", children: [
            /* @__PURE__ */ o(
              "div",
              {
                className: "font-bold",
                style: {
                  color: E,
                  fontSize: `${l * 0.35}px`
                },
                children: z ? "▲" : "▼"
              }
            ),
            /* @__PURE__ */ N("div", { className: "text-left", children: [
              /* @__PURE__ */ N(
                "div",
                {
                  className: "font-bold leading-tight",
                  style: {
                    fontSize: `${l * 0.35}px`,
                    color: E
                  },
                  children: [
                    z ? "+" : "",
                    j($)
                  ]
                }
              ),
              /* @__PURE__ */ N(
                "div",
                {
                  className: "font-semibold leading-tight",
                  style: {
                    fontSize: `${l * 0.28}px`,
                    color: E,
                    opacity: 0.8
                  },
                  children: [
                    z ? "+" : "",
                    I.toFixed(1),
                    "%"
                  ]
                }
              )
            ] })
          ] })
        ] }),
        r.suffix && !r.formatValue && /* @__PURE__ */ o(
          "div",
          {
            className: "text-dc-text-muted text-center mb-3",
            style: {
              fontSize: "14px",
              lineHeight: "1.2",
              opacity: 0.8
            },
            children: r.suffix
          }
        ),
        r.showHistogram !== !1 && A.length > 2 && /* @__PURE__ */ o("div", { className: "mt-2 w-full flex justify-center overflow-hidden", children: /* @__PURE__ */ o(
          Xu,
          {
            values: A,
            lastValue: v,
            positiveColor: L,
            negativeColor: B,
            formatValue: j,
            width: c,
            height: 64
          }
        ) })
      ]
    }
  );
}), vf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: Zu
}, Symbol.toStringTag, { value: "Module" })), Ju = ie.memo(function({
  data: t,
  chartConfig: n,
  displayConfig: r = {},
  height: s = "100%",
  colorPalette: i
}) {
  const [a, l] = J(28), [u, c] = J(0), d = be(null), h = be(null), p = ke();
  if (Ae(() => {
    const v = () => {
      if (d.current) {
        const z = d.current.getBoundingClientRect(), j = z.width, G = z.height;
        if (j > 0 && G > 0) {
          const _ = j / 8, L = G / 5, B = Math.min(_, L), E = Math.max(18, Math.min(B, 80));
          l(E);
        }
      }
      if (h.current) {
        const I = h.current.getBoundingClientRect();
        c(I.width);
      }
    }, O = setTimeout(v, 100), $ = new ResizeObserver(() => {
      clearTimeout(O), setTimeout(v, 50);
    });
    return d.current && $.observe(d.current), () => {
      clearTimeout(O), $.disconnect();
    };
  }, [t, n]), !t || t.length === 0)
    return /* @__PURE__ */ o(
      "div",
      {
        className: "flex items-center justify-center w-full h-full",
        style: {
          height: s === "100%" ? "100%" : s,
          minHeight: s === "100%" ? "200px" : void 0
        },
        children: /* @__PURE__ */ N("div", { className: "text-center text-dc-text-muted", children: [
          /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
          /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display" })
        ] })
      }
    );
  let f = [];
  if (n?.yAxis && (typeof n.yAxis == "string" ? f = [n.yAxis] : Array.isArray(n.yAxis) && (f = n.yAxis)), f.length === 0)
    return /* @__PURE__ */ o(
      "div",
      {
        className: "flex items-center justify-center w-full h-full",
        style: {
          height: s === "100%" ? "100%" : s,
          minHeight: s === "100%" ? "200px" : void 0,
          backgroundColor: "var(--dc-danger-bg)",
          color: "var(--dc-danger)",
          borderColor: "var(--dc-danger-border)"
        },
        children: /* @__PURE__ */ N("div", { className: "text-center", children: [
          /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
          /* @__PURE__ */ o("div", { className: "text-xs", children: "No measure fields configured" })
        ] })
      }
    );
  const b = f[0], m = t.map((v) => {
    if (v[b] !== void 0)
      return v[b];
    const O = Object.keys(v);
    if (O.length > 0)
      return v[O[0]];
  }).filter((v) => v != null);
  if (m.length === 0)
    return /* @__PURE__ */ o(
      "div",
      {
        className: "flex items-center justify-center w-full h-full",
        style: {
          height: s === "100%" ? "100%" : s,
          minHeight: s === "100%" ? "200px" : void 0,
          backgroundColor: "var(--dc-warning-bg)",
          color: "var(--dc-warning)",
          borderColor: "var(--dc-warning-border)"
        },
        children: /* @__PURE__ */ N("div", { className: "text-center", children: [
          /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
          /* @__PURE__ */ o("div", { className: "text-xs", children: "All values are null or invalid" })
        ] })
      }
    );
  const x = m.map((v) => Number(v)).filter((v) => !isNaN(v));
  let y, g = null, k = null, w = !1;
  x.length > 0 ? m.length === 1 ? y = m[0] : (y = x.reduce(($, I) => $ + I, 0) / x.length, g = Math.min(...x), k = Math.max(...x), w = !0) : y = m.length === 1 ? m[0] : m.join(", ");
  const S = (v) => {
    if (r.formatValue)
      return r.formatValue(v);
    if (v == null)
      return "—";
    const O = r.decimals ?? 2;
    return Math.abs(v) >= 1e9 ? (v / 1e9).toFixed(O) + "B" : Math.abs(v) >= 1e6 ? (v / 1e6).toFixed(O) + "M" : Math.abs(v) >= 1e3 ? (v / 1e3).toFixed(O) + "K" : v.toFixed(O);
  }, C = (v, O) => {
    try {
      const $ = {
        value: typeof O == "number" ? S(O) : String(O),
        rawValue: O,
        field: b,
        fieldLabel: p(b),
        min: g !== null ? S(g) : "",
        max: k !== null ? S(k) : "",
        count: m.length
      };
      return v.replace(/\$\{(\w+)\}/g, (I, z) => z in $ ? String($[z]) : I);
    } catch {
      return String(O);
    }
  }, F = r.template || "${fieldLabel}: ${value}", M = C(F, y), A = (() => {
    if (r.valueColorIndex !== void 0 && i?.colors) {
      const v = r.valueColorIndex;
      if (v >= 0 && v < i.colors.length)
        return i.colors[v];
    }
    return i?.colors?.[0] || "#1f2937";
  })();
  return /* @__PURE__ */ N(
    "div",
    {
      ref: d,
      className: "flex flex-col items-center justify-center w-full h-full p-4",
      style: {
        height: s === "100%" ? "100%" : s,
        minHeight: s === "100%" ? "200px" : void 0
      },
      children: [
        /* @__PURE__ */ o(
          "div",
          {
            ref: h,
            className: "font-bold leading-tight text-center",
            style: {
              fontSize: `${a}px`,
              color: A
            },
            children: M
          }
        ),
        w && g !== null && k !== null && /* @__PURE__ */ o("div", { className: "mt-4", children: /* @__PURE__ */ o(
          As,
          {
            values: m,
            min: g,
            max: k,
            color: A,
            formatValue: S,
            height: 24,
            width: u || 200
          }
        ) })
      ]
    }
  );
}), wf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: Ju
}, Symbol.toStringTag, { value: "Module" })), ed = ie.memo(function({
  displayConfig: t = {},
  height: n = "100%",
  colorPalette: r
}) {
  const s = t.content || "", i = t.accentColorIndex ?? 0, a = t.fontSize || "medium", l = t.alignment || "left", c = r?.colors && i < r.colors.length ? r.colors[i] : "#8884d8", d = {
    small: "text-sm",
    medium: "text-lg",
    large: "text-xl"
  }, h = {
    left: "text-left",
    center: "text-center",
    right: "text-right"
  }, p = (y) => {
    const g = y.split(`
`), k = [];
    let w = null;
    for (let S = 0; S < g.length; S++) {
      const C = g[S].trim();
      if (!C) {
        w && (k.push(w), w = null), k.push({ type: "break" });
        continue;
      }
      const F = C.match(/^(#{1,3})\s+(.*)$/);
      if (F) {
        w && (k.push(w), w = null), k.push({
          type: "header",
          level: F[1].length,
          content: F[2]
        });
        continue;
      }
      const M = C.match(/^[-*+]\s+(.*)$/);
      if (M) {
        (!w || w.ordered) && (w && k.push(w), w = { type: "list", ordered: !1, children: [] }), w.children.push({
          type: "listItem",
          children: f(M[1]),
          parentOrdered: !1
        });
        continue;
      }
      const T = C.match(/^\d+\.\s+(.*)$/);
      if (T) {
        (!w || !w.ordered) && (w && k.push(w), w = { type: "list", ordered: !0, children: [] }), w.children.push({
          type: "listItem",
          children: f(T[1]),
          parentOrdered: !0
        });
        continue;
      }
      w && (k.push(w), w = null), k.push({
        type: "paragraph",
        children: f(C)
      });
    }
    return w && k.push(w), k;
  }, f = (y) => {
    const g = [];
    let k = y;
    for (; k; ) {
      const w = k.match(/^(.*?)\[([^\]]+)\]\(([^)]+)\)(.*)$/);
      if (w) {
        const [, S, C, F, M] = w;
        S && g.push(...b(S)), g.push({
          type: "link",
          content: C,
          url: F
        }), k = M;
        continue;
      }
      g.push(...b(k));
      break;
    }
    return g;
  }, b = (y) => {
    const g = [];
    let k = y;
    for (; k; ) {
      const w = k.match(/^(.*?)\*\*([^*]+)\*\*(.*)$/);
      if (w) {
        const [, C, F, M] = w;
        C && g.push({ type: "text", content: C }), g.push({ type: "bold", content: F }), k = M;
        continue;
      }
      const S = k.match(/^(.*?)\*([^*]+)\*(.*)$/);
      if (S) {
        const [, C, F, M] = S;
        C && g.push({ type: "text", content: C }), g.push({ type: "italic", content: F }), k = M;
        continue;
      }
      g.push({ type: "text", content: k });
      break;
    }
    return g;
  }, m = (y, g, k) => {
    switch (y.type) {
      case "text":
        return /* @__PURE__ */ o("span", { className: "text-dc-text", children: y.content }, g);
      case "bold":
        return /* @__PURE__ */ o("strong", { className: "font-bold text-dc-text", children: y.content }, g);
      case "italic":
        return /* @__PURE__ */ o("em", { className: "italic text-dc-text", children: y.content }, g);
      case "link":
        return /* @__PURE__ */ o(
          "a",
          {
            href: y.url,
            target: "_blank",
            rel: "nofollow noopener noreferrer",
            className: "hover:underline transition-colors",
            style: { color: c },
            children: y.content
          },
          g
        );
      case "header": {
        const w = (C, F) => {
          const M = "font-bold", T = {
            1: "mb-4",
            2: "mb-3",
            3: "mb-2"
          };
          let A = "";
          return F === "small" ? A = { 1: "text-lg", 2: "text-base", 3: "text-sm" }[C] || "text-sm" : F === "large" ? A = { 1: "text-5xl", 2: "text-4xl", 3: "text-3xl" }[C] || "text-3xl" : A = { 1: "text-3xl", 2: "text-2xl", 3: "text-xl" }[C] || "text-xl", `${M} ${A} ${T[C]}`;
        }, S = `h${y.level}`;
        return /* @__PURE__ */ o(
          S,
          {
            className: w(y.level, a),
            style: { color: c },
            children: y.content
          },
          g
        );
      }
      case "paragraph":
        return /* @__PURE__ */ o("p", { className: "mb-3 leading-relaxed", children: y.children?.map((w, S) => m(w, S)) }, g);
      case "list": {
        const w = y.ordered ? "ol" : "ul";
        let S = "mb-3";
        return l === "center" ? S += " list-none flex flex-col items-center" : l === "right" ? S += " list-none ml-auto max-w-max" : S += " list-none ml-6", /* @__PURE__ */ o(w, { className: S, children: y.children?.map((C, F) => m(C, F, y.ordered ? F + 1 : void 0)) }, g);
      }
      case "listItem":
        if (y.children) {
          if (y.parentOrdered && k !== void 0) {
            const w = d[a];
            return l === "center" ? /* @__PURE__ */ N("li", { className: "mb-1 flex items-center justify-center", children: [
              /* @__PURE__ */ N(
                "span",
                {
                  className: `inline-block mr-2 shrink-0 ${w} font-medium`,
                  style: { color: c },
                  children: [
                    k,
                    "."
                  ]
                }
              ),
              /* @__PURE__ */ o("span", { className: "text-center", children: y.children.map((S, C) => m(S, C)) })
            ] }, g) : l === "right" ? /* @__PURE__ */ N("li", { className: "mb-1 flex items-start justify-end", children: [
              /* @__PURE__ */ o("span", { className: "text-right", children: y.children.map((S, C) => m(S, C)) }),
              /* @__PURE__ */ N(
                "span",
                {
                  className: `inline-block ml-2 shrink-0 ${w} font-medium`,
                  style: { color: c },
                  children: [
                    k,
                    "."
                  ]
                }
              )
            ] }, g) : /* @__PURE__ */ N("li", { className: "mb-1 flex items-start", children: [
              /* @__PURE__ */ N(
                "span",
                {
                  className: `inline-block mr-3 shrink-0 ${w} font-medium`,
                  style: { color: c },
                  children: [
                    k,
                    "."
                  ]
                }
              ),
              /* @__PURE__ */ o("span", { className: "flex-1", children: y.children.map((S, C) => m(S, C)) })
            ] }, g);
          }
          return l === "center" ? /* @__PURE__ */ N("li", { className: "mb-1 flex items-center justify-center", children: [
            /* @__PURE__ */ o(
              "span",
              {
                className: "inline-block w-2 h-2 rounded-full mr-2 shrink-0",
                style: { backgroundColor: c }
              }
            ),
            /* @__PURE__ */ o("span", { className: "text-center", children: y.children.map((w, S) => m(w, S)) })
          ] }, g) : l === "right" ? /* @__PURE__ */ N("li", { className: "mb-1 flex items-start justify-end", children: [
            /* @__PURE__ */ o("span", { className: "text-right", children: y.children.map((w, S) => m(w, S)) }),
            /* @__PURE__ */ o(
              "span",
              {
                className: "inline-block w-2 h-2 rounded-full ml-2 mt-2 shrink-0",
                style: { backgroundColor: c }
              }
            )
          ] }, g) : /* @__PURE__ */ N("li", { className: "mb-1 flex items-start", children: [
            /* @__PURE__ */ o(
              "span",
              {
                className: "inline-block w-2 h-2 rounded-full mr-3 mt-2 shrink-0",
                style: { backgroundColor: c }
              }
            ),
            /* @__PURE__ */ o("span", { className: "flex-1", children: y.children.map((w, S) => m(w, S)) })
          ] }, g);
        }
        return null;
      case "break":
        return /* @__PURE__ */ o("br", {}, g);
      default:
        return null;
    }
  };
  if (!s.trim())
    return /* @__PURE__ */ o(
      "div",
      {
        className: "flex items-center justify-center w-full h-full",
        style: {
          height: n === "100%" ? "100%" : n,
          minHeight: n === "100%" ? "200px" : void 0
        },
        children: /* @__PURE__ */ N("div", { className: "text-center text-dc-text-muted", children: [
          /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No content" }),
          /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "Add markdown content in the chart configuration" })
        ] })
      }
    );
  const x = p(s);
  return /* @__PURE__ */ o(
    "div",
    {
      className: `p-4 w-full h-full overflow-auto ${d[a]} ${h[l]}`,
      style: {
        height: n === "100%" ? "100%" : n,
        minHeight: n === "100%" ? "200px" : void 0
      },
      children: x.map((y, g) => m(y, g))
    }
  );
}), Nf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: ed
}, Symbol.toStringTag, { value: "Module" })), td = [
  "#3B82F6",
  // blue-500
  "#60A5FA",
  // blue-400
  "#93C5FD",
  // blue-300
  "#BFDBFE",
  // blue-200
  "#DBEAFE"
  // blue-100
];
function Xt(e, t) {
  const n = t || td;
  return n[e % n.length];
}
function nd(e) {
  if (!e || e.length === 0) return !1;
  const t = e[0];
  return typeof t == "object" && t !== null && "name" in t && "value" in t && "percentage" in t;
}
function Fr(e, t, n, r) {
  const s = [];
  return t && e.avgSecondsToConvert != null && s.push(`Avg: ${Qt(e.avgSecondsToConvert)}`), n && e.medianSecondsToConvert != null && s.push(`Med: ${Qt(e.medianSecondsToConvert)}`), r && e.p90SecondsToConvert != null && s.push(`P90: ${Qt(e.p90SecondsToConvert)}`), s;
}
const rd = ie.memo(function({
  data: t,
  height: n = "100%",
  colorPalette: r,
  displayConfig: s
}) {
  const i = s?.funnelStepLabels, l = (s?.funnelOrientation || "horizontal") === "vertical", u = s?.funnelStyle ?? "bars", c = s?.showFunnelConversion ?? !0, d = s?.showFunnelAvgTime ?? s?.showFunnelTimeMetrics ?? !1, h = s?.showFunnelMedianTime ?? !1, p = s?.showFunnelP90Time ?? !1, f = q(() => !t || t.length === 0 ? [] : nd(t) ? t : t.map((x, y) => {
    const g = x, k = Object.keys(g).find(
      (v) => v.toLowerCase().includes("step") || v.toLowerCase().includes("name") || v === "__stepName"
    ), w = k ? String(g[k]) : `Step ${y + 1}`, S = Object.keys(g).find(
      (v) => v.toLowerCase().includes("count") || v.toLowerCase().includes("value") || v === "__count"
    ), C = S && Number(g[S]) || 0, F = Object.keys(g).find(
      (v) => v.toLowerCase().includes("percent") || v === "__percentage"
    ), M = F && Number(g[F]) || 0, T = Object.keys(g).find(
      (v) => v.toLowerCase().includes("conversion") || v === "__conversionRate"
    ), A = T && Number(g[T]) || null;
    return {
      name: w,
      value: C,
      percentage: M,
      conversionRate: A,
      stepIndex: y
    };
  }), [t]), b = f[0]?.value || 0;
  if (!t || t.length === 0 || f.length === 0)
    return /* @__PURE__ */ o(
      "div",
      {
        className: "flex items-center justify-center w-full text-dc-text-muted",
        style: { height: n },
        children: /* @__PURE__ */ N("div", { className: "text-center", children: [
          /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No funnel data" }),
          /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "Configure a funnel with at least 2 steps and a binding key" })
        ] })
      }
    );
  const m = r?.colors || Q;
  return u === "funnel" ? /* @__PURE__ */ N("div", { className: "relative w-full h-full flex flex-col", style: { height: n }, children: [
    /* @__PURE__ */ o("div", { className: "flex-1", children: /* @__PURE__ */ o(tt, { width: "100%", height: "100%", children: /* @__PURE__ */ N(Hs, { layout: l ? "horizontal" : "vertical", children: [
      /* @__PURE__ */ o(
        lt,
        {
          formatter: (y) => typeof y == "number" ? y.toLocaleString() : String(y),
          contentStyle: {
            backgroundColor: "var(--dc-surface)",
            border: "1px solid var(--dc-border)",
            borderRadius: "4px"
          }
        }
      ),
      /* @__PURE__ */ N(
        Us,
        {
          dataKey: "value",
          nameKey: "name",
          data: f,
          isAnimationActive: !0,
          children: [
            f.map((y, g) => /* @__PURE__ */ o(It, { fill: Xt(g, m) }, `cell-${g}`)),
            /* @__PURE__ */ o(
              En,
              {
                position: "right",
                dataKey: "name",
                fill: "var(--dc-text)",
                style: { fontSize: "12px" }
              }
            ),
            /* @__PURE__ */ o(
              En,
              {
                position: "center",
                dataKey: "percentage",
                formatter: (y) => typeof y == "number" ? `${y.toFixed(1)}%` : String(y),
                fill: "#fff",
                style: { fontSize: "11px", fontWeight: 500 }
              }
            )
          ]
        }
      )
    ] }) }) }),
    !s?.hideSummaryFooter && /* @__PURE__ */ o("div", { className: "flex-shrink-0 px-4 py-2 border-t border-dc-border bg-dc-surface-secondary", children: /* @__PURE__ */ N("div", { className: "flex items-center justify-between text-sm", children: [
      /* @__PURE__ */ N("div", { className: "text-dc-text-muted", children: [
        /* @__PURE__ */ o("span", { className: "font-medium", children: f.length }),
        " steps"
      ] }),
      /* @__PURE__ */ N("div", { className: "text-dc-text", children: [
        /* @__PURE__ */ o("span", { className: "text-dc-text-muted", children: "Overall:" }),
        " ",
        /* @__PURE__ */ o("span", { className: "font-medium", children: b > 0 ? `${((f[f.length - 1]?.value || 0) / b * 100).toFixed(1)}%` : "0%" })
      ] }),
      /* @__PURE__ */ N("div", { className: "text-dc-text-muted", children: [
        f[f.length - 1]?.value.toLocaleString() || 0,
        " / ",
        b.toLocaleString(),
        " completed"
      ] })
    ] }) })
  ] }) : l ? /* @__PURE__ */ N("div", { className: "relative w-full h-full flex flex-col", style: { height: n }, children: [
    /* @__PURE__ */ o("div", { className: "flex-1 flex items-end justify-center gap-4 px-4 py-3 overflow-hidden", children: f.map((x, y) => {
      const g = b > 0 ? x.value / b * 100 : 0, k = y > 0 ? f[y - 1] : null, w = k && k.value > 0 ? x.value / k.value * 100 : null, S = i?.[y] || x.name, C = Fr(x, d, h, p), F = C.length;
      return /* @__PURE__ */ N("div", { className: "flex flex-col items-center gap-2 flex-1 max-w-32 h-full", children: [
        /* @__PURE__ */ o("div", { className: `${F > 0 ? F > 1 ? "min-h-16" : "min-h-10" : "h-5"} flex-shrink-0 text-center`, children: w !== null ? /* @__PURE__ */ N("div", { className: "text-xs text-dc-text-secondary", children: [
          c && /* @__PURE__ */ N("span", { children: [
            "→ ",
            w.toFixed(1),
            "%"
          ] }),
          F > 0 && /* @__PURE__ */ o("div", { className: "text-dc-text-muted mt-0.5 space-y-0.5", children: C.map((M, T) => /* @__PURE__ */ N("div", { children: [
            "⏱ ",
            M
          ] }, T)) })
        ] }) : /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-muted", children: "—" }) }),
        /* @__PURE__ */ N("div", { className: "flex-1 w-full relative min-h-12", children: [
          /* @__PURE__ */ o("div", { className: "absolute inset-0 bg-dc-surface-secondary rounded-sm" }),
          /* @__PURE__ */ o(
            "div",
            {
              className: "absolute bottom-0 left-0 right-0 rounded-sm transition-all duration-300",
              style: {
                height: `${Math.max(g, 5)}%`,
                backgroundColor: Xt(y, m)
              }
            }
          ),
          /* @__PURE__ */ o(
            "div",
            {
              className: "absolute bottom-0 left-0 right-0 flex items-end justify-center pb-1 pointer-events-none",
              style: { height: `${Math.max(g, 20)}%` },
              children: /* @__PURE__ */ N("span", { className: "text-xs font-medium text-white drop-shadow-sm", children: [
                x.percentage?.toFixed(1) ?? g.toFixed(1),
                "%"
              ] })
            }
          )
        ] }),
        /* @__PURE__ */ N("div", { className: "flex-shrink-0 text-center", children: [
          /* @__PURE__ */ o("div", { className: "text-sm font-medium text-dc-text truncate", title: S, children: S }),
          /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-muted", children: x.value.toLocaleString() })
        ] })
      ] }, x.name);
    }) }),
    !s?.hideSummaryFooter && /* @__PURE__ */ o("div", { className: "flex-shrink-0 px-4 py-2 border-t border-dc-border bg-dc-surface-secondary", children: /* @__PURE__ */ N("div", { className: "flex items-center justify-between text-sm", children: [
      /* @__PURE__ */ N("div", { className: "text-dc-text-muted", children: [
        /* @__PURE__ */ o("span", { className: "font-medium", children: f.length }),
        " steps"
      ] }),
      /* @__PURE__ */ N("div", { className: "text-dc-text", children: [
        /* @__PURE__ */ o("span", { className: "text-dc-text-muted", children: "Overall:" }),
        " ",
        /* @__PURE__ */ o("span", { className: "font-medium", children: b > 0 ? `${((f[f.length - 1]?.value || 0) / b * 100).toFixed(1)}%` : "0%" })
      ] }),
      /* @__PURE__ */ N("div", { className: "text-dc-text-muted", children: [
        f[f.length - 1]?.value.toLocaleString() || 0,
        " / ",
        b.toLocaleString(),
        " completed"
      ] })
    ] }) })
  ] }) : /* @__PURE__ */ N("div", { className: "relative w-full h-full flex flex-col", style: { height: n }, children: [
    /* @__PURE__ */ o("div", { className: "flex-1 flex flex-col justify-center gap-2 px-4 py-3 overflow-hidden", children: f.map((x, y) => {
      const g = b > 0 ? x.value / b * 100 : 0, k = y > 0 ? f[y - 1] : null, w = k && k.value > 0 ? x.value / k.value * 100 : null, S = i?.[y] || x.name, C = Fr(x, d, h, p), F = C.length;
      return /* @__PURE__ */ N("div", { className: "flex items-center gap-3", children: [
        /* @__PURE__ */ N("div", { className: "w-24 flex-shrink-0 text-right", children: [
          /* @__PURE__ */ o("div", { className: "text-sm font-medium text-dc-text truncate", title: S, children: S }),
          /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-muted", children: x.value.toLocaleString() })
        ] }),
        /* @__PURE__ */ N("div", { className: "flex-1 relative", children: [
          /* @__PURE__ */ o("div", { className: "w-full h-8 bg-dc-surface-secondary rounded-sm" }),
          /* @__PURE__ */ o(
            "div",
            {
              className: "absolute top-0 left-0 h-8 rounded-sm transition-all duration-300",
              style: {
                width: `${Math.max(g, 2)}%`,
                backgroundColor: Xt(y, m)
              }
            }
          ),
          /* @__PURE__ */ o(
            "div",
            {
              className: "absolute top-0 left-0 h-8 flex items-center px-2 pointer-events-none",
              style: { width: `${Math.max(g, 20)}%` },
              children: /* @__PURE__ */ N("span", { className: "text-xs font-medium text-white drop-shadow-sm", children: [
                x.percentage?.toFixed(1) ?? g.toFixed(1),
                "%"
              ] })
            }
          )
        ] }),
        /* @__PURE__ */ o("div", { className: `${F > 0 ? F > 1 ? "w-36" : "w-28" : "w-16"} flex-shrink-0 text-left`, children: w !== null ? /* @__PURE__ */ N("div", { className: "text-xs text-dc-text-secondary", children: [
          c && /* @__PURE__ */ N("span", { children: [
            "↓ ",
            w.toFixed(1),
            "%"
          ] }),
          F > 0 && /* @__PURE__ */ o("div", { className: "text-dc-text-muted mt-0.5 space-y-0.5", children: C.map((M, T) => /* @__PURE__ */ N("div", { children: [
            "⏱ ",
            M
          ] }, T)) })
        ] }) : /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-muted", children: "—" }) })
      ] }, x.name);
    }) }),
    !s?.hideSummaryFooter && /* @__PURE__ */ o("div", { className: "flex-shrink-0 px-4 py-2 border-t border-dc-border bg-dc-surface-secondary", children: /* @__PURE__ */ N("div", { className: "flex items-center justify-between text-sm", children: [
      /* @__PURE__ */ N("div", { className: "text-dc-text-muted", children: [
        /* @__PURE__ */ o("span", { className: "font-medium", children: f.length }),
        " steps"
      ] }),
      /* @__PURE__ */ N("div", { className: "text-dc-text", children: [
        /* @__PURE__ */ o("span", { className: "text-dc-text-muted", children: "Overall:" }),
        " ",
        /* @__PURE__ */ o("span", { className: "font-medium", children: b > 0 ? `${((f[f.length - 1]?.value || 0) / b * 100).toFixed(1)}%` : "0%" })
      ] }),
      /* @__PURE__ */ N("div", { className: "text-dc-text-muted", children: [
        f[f.length - 1]?.value.toLocaleString() || 0,
        " / ",
        b.toLocaleString(),
        " completed"
      ] })
    ] }) })
  ] });
}), Sf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: rd
}, Symbol.toStringTag, { value: "Module" })), Zt = {
  before: "#F97316",
  // orange-500 - for steps before
  start: "#3B82F6",
  // blue-500 - for starting step
  after: "#10B981"
  // emerald-500 - for steps after
};
function sd(e, t) {
  if (t && t.length > 0) {
    const n = Math.abs(e);
    return t[n % t.length];
  }
  return e < 0 ? Zt.before : e === 0 ? Zt.start : Zt.after;
}
function id(e, t) {
  if (!e.nodes || e.nodes.length === 0) return null;
  const n = /* @__PURE__ */ new Map();
  e.nodes.forEach((i, a) => {
    n.set(i.id, a);
  });
  const r = e.nodes.map((i) => ({
    name: i.name,
    fill: sd(i.layer, t),
    layer: i.layer,
    value: i.value
  })), s = e.links.map((i) => {
    const a = n.get(i.source), l = n.get(i.target);
    return a === void 0 || l === void 0 ? (console.warn(`Sankey: Could not resolve link ${i.source} -> ${i.target}`), null) : {
      source: a,
      target: l,
      value: i.value
    };
  }).filter((i) => i !== null);
  return { nodes: r, links: s };
}
function Tr(e) {
  if (!e || e.length === 0) return null;
  if (At(e[0]))
    return e[0];
  if (At(e))
    return e;
  const t = e;
  return t.nodes && t.links ? t : null;
}
function ad({
  x: e,
  y: t,
  width: n,
  height: r,
  payload: s,
  containerWidth: i,
  showLabels: a = !0
}) {
  const l = e > i / 2, u = l ? e - 6 : e + n + 6, c = l ? "end" : "start";
  return /* @__PURE__ */ N("g", { children: [
    /* @__PURE__ */ o(
      "rect",
      {
        x: e,
        y: t,
        width: n,
        height: r,
        fill: s.fill,
        rx: 2,
        ry: 2
      }
    ),
    a && /* @__PURE__ */ N(
      "text",
      {
        x: u,
        y: t + r / 2,
        textAnchor: c,
        dominantBaseline: "middle",
        className: "text-xs fill-dc-text",
        style: { fontSize: 11 },
        children: [
          s.name,
          s.value !== void 0 && /* @__PURE__ */ N("tspan", { className: "fill-dc-text-secondary", dx: 4, children: [
            "(",
            s.value.toLocaleString(),
            ")"
          ] })
        ]
      }
    )
  ] });
}
function od({ active: e, payload: t }) {
  if (!e || !t || t.length === 0) return null;
  const n = t[0].payload;
  return n.source && n.target ? /* @__PURE__ */ N("div", { className: "bg-dc-surface border border-dc-border rounded-md px-3 py-2 shadow-lg text-sm", children: [
    /* @__PURE__ */ N("div", { className: "font-medium text-dc-text", children: [
      n.source.name,
      " → ",
      n.target.name
    ] }),
    /* @__PURE__ */ N("div", { className: "text-dc-text-secondary mt-1", children: [
      /* @__PURE__ */ o("span", { className: "font-medium", children: n.value.toLocaleString() }),
      " entities"
    ] })
  ] }) : /* @__PURE__ */ N("div", { className: "bg-dc-surface border border-dc-border rounded-md px-3 py-2 shadow-lg text-sm", children: [
    /* @__PURE__ */ o("div", { className: "font-medium text-dc-text", children: n.name }),
    n.value !== void 0 && /* @__PURE__ */ N("div", { className: "text-dc-text-secondary mt-1", children: [
      /* @__PURE__ */ o("span", { className: "font-medium", children: n.value.toLocaleString() }),
      " entities"
    ] })
  ] });
}
const ld = ie.memo(function({
  data: t,
  height: n = "100%",
  colorPalette: r,
  displayConfig: s
}) {
  const i = be(null), [a, l] = J(800);
  Ae(() => {
    const m = () => {
      i.current && l(i.current.offsetWidth);
    };
    return m(), window.addEventListener("resize", m), () => window.removeEventListener("resize", m);
  }, []);
  const u = s, c = parseFloat(String(u?.linkOpacity || "0.5")), d = u?.nodeWidth ?? 10, h = u?.nodePadding ?? 50, p = u?.showNodeLabels !== !1, f = q(() => {
    const m = Tr(t || []);
    return m ? id(m, r?.colors || Q) : null;
  }, [t, r]), b = q(() => {
    const m = Tr(t || []);
    if (!m) return null;
    const x = m.nodes.filter((g) => g.layer === 0).reduce((g, k) => g + (k.value || 0), 0), y = m.links.reduce((g, k) => g + k.value, 0);
    return {
      nodeCount: m.nodes.length,
      linkCount: m.links.length,
      totalEntities: x,
      totalPaths: y
    };
  }, [t]);
  return !t || t.length === 0 || !f || f.nodes.length === 0 ? /* @__PURE__ */ o(
    "div",
    {
      className: "flex items-center justify-center w-full text-dc-text-muted",
      style: { height: n },
      children: /* @__PURE__ */ N("div", { className: "text-center", children: [
        /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No flow data" }),
        /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "Configure a flow analysis with a starting step and event dimension" })
      ] })
    }
  ) : /* @__PURE__ */ N("div", { ref: i, className: "relative w-full h-full flex flex-col", style: { height: n }, children: [
    /* @__PURE__ */ o("div", { className: "flex-1 min-h-0", children: /* @__PURE__ */ o(tt, { width: "100%", height: "100%", children: /* @__PURE__ */ o(
      Ys,
      {
        data: f,
        nodeWidth: d,
        nodePadding: h,
        margin: { top: 20, right: 20, bottom: 20, left: 20 },
        link: {
          stroke: "var(--dc-border)",
          strokeOpacity: c
        },
        node: (m) => /* @__PURE__ */ o(ad, { ...m, containerWidth: a, showLabels: p }),
        children: /* @__PURE__ */ o(lt, { content: /* @__PURE__ */ o(od, {}) })
      }
    ) }) }),
    !u?.hideSummaryFooter && b && /* @__PURE__ */ o("div", { className: "flex-shrink-0 px-4 py-2 border-t border-dc-border bg-dc-surface-secondary", children: /* @__PURE__ */ N("div", { className: "flex items-center justify-between text-sm", children: [
      /* @__PURE__ */ N("div", { className: "text-dc-text-muted", children: [
        /* @__PURE__ */ o("span", { className: "font-medium", children: b.nodeCount }),
        " events"
      ] }),
      /* @__PURE__ */ N("div", { className: "text-dc-text", children: [
        /* @__PURE__ */ o("span", { className: "text-dc-text-muted", children: "Paths:" }),
        " ",
        /* @__PURE__ */ o("span", { className: "font-medium", children: b.linkCount })
      ] }),
      /* @__PURE__ */ N("div", { className: "text-dc-text-muted", children: [
        /* @__PURE__ */ o("span", { className: "font-medium", children: b.totalEntities.toLocaleString() }),
        " starting entities"
      ] })
    ] }) })
  ] });
}), Af = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: ld
}, Symbol.toStringTag, { value: "Module" }));
function Mr(e) {
  if (!e || e.length === 0) return null;
  if (At(e[0]))
    return e[0];
  if (At(e))
    return e;
  const t = e;
  return t.nodes && t.links ? t : null;
}
function cd(e, t) {
  const { nodes: n, links: r } = e;
  if (!n || n.length === 0) return null;
  const s = n.filter((m) => m.layer >= 0);
  if (s.length === 0) return null;
  const i = t || Q, a = [...new Set(s.map((m) => m.name))], l = /* @__PURE__ */ new Map();
  a.forEach((m, x) => {
    l.set(m, i[x % i.length]);
  });
  const u = /* @__PURE__ */ new Map();
  s.forEach((m) => u.set(m.id, m));
  const c = /* @__PURE__ */ new Map();
  r.forEach((m) => {
    if (!u.has(m.source)) return;
    const x = c.get(m.source) || [];
    x.push(m), c.set(m.source, x);
  });
  const d = Math.max(...s.map((m) => m.layer));
  let h = 0;
  function p(m, x, y) {
    if (x >= d) return [];
    const g = c.get(m) || [];
    if (g.length === 0) return [];
    const k = [];
    for (const w of g) {
      const S = u.get(w.target);
      if (!S || S.layer !== x + 1) continue;
      h++;
      const C = `${S.name}_${h}`, F = p(w.target, x + 1), M = {
        name: C,
        originalName: S.name,
        value: w.value,
        fill: l.get(S.name) || i[0]
      };
      F.length > 0 && (M.children = F), k.push(M);
    }
    return k;
  }
  const f = s.filter((m) => m.layer === 0);
  if (f.length === 0) return null;
  if (f.length === 1) {
    const m = f[0], x = p(m.id, 0), y = {
      name: m.name,
      originalName: m.name,
      value: m.value || x.reduce((g, k) => g + (k.value || 0), 0),
      fill: l.get(m.name) || i[0]
    };
    return x.length > 0 && (y.children = x), y;
  }
  return {
    name: "Start",
    originalName: "Start",
    children: f.map((m, x) => {
      h++;
      const y = p(m.id, 0), g = {
        name: `${m.name}_root_${x}`,
        originalName: m.name,
        value: m.value || y.reduce((k, w) => k + (w.value || 0), 0),
        fill: l.get(m.name) || i[0]
      };
      return y.length > 0 && (g.children = y), g;
    })
  };
}
function ud({
  active: e,
  payload: t
}) {
  if (!e || !t || t.length === 0) return null;
  const n = t[0].payload, r = n.originalName || n.name;
  return /* @__PURE__ */ N("div", { className: "bg-dc-surface border border-dc-border rounded-md px-3 py-2 shadow-lg text-sm", children: [
    /* @__PURE__ */ o("div", { className: "font-medium text-dc-text", children: r }),
    n.value !== void 0 && /* @__PURE__ */ N("div", { className: "text-dc-text-secondary mt-1", children: [
      /* @__PURE__ */ o("span", { className: "font-medium", children: n.value.toLocaleString() }),
      " entities"
    ] })
  ] });
}
const dd = ie.memo(function({
  data: t,
  height: n = "100%",
  colorPalette: r,
  displayConfig: s
}) {
  const i = be(null), [a, l] = J({ width: 400, height: 400 });
  Ae(() => {
    const x = () => {
      i.current && l({
        width: i.current.offsetWidth,
        height: i.current.offsetHeight
      });
    };
    x(), window.addEventListener("resize", x);
    const y = new ResizeObserver(x);
    return i.current && y.observe(i.current), () => {
      window.removeEventListener("resize", x), y.disconnect();
    };
  }, []);
  const u = s, c = u?.innerRadius ?? 40, d = q(() => {
    const x = Mr(t || []);
    return x ? cd(x, r?.colors || Q) : null;
  }, [t, r]), h = q(() => {
    const x = Mr(t || []);
    if (!x) return null;
    const y = x.nodes.filter((w) => w.layer >= 0), g = x.links.filter((w) => {
      const S = x.nodes.find((C) => C.id === w.source);
      return S && S.layer >= 0;
    }), k = x.nodes.filter((w) => w.layer === 0).reduce((w, S) => w + (S.value || 0), 0);
    return {
      nodeCount: y.length,
      linkCount: g.length,
      totalEntities: k
    };
  }, [t]);
  if (!t || t.length === 0 || !d)
    return /* @__PURE__ */ o(
      "div",
      {
        className: "flex items-center justify-center w-full text-dc-text-muted",
        style: { height: n },
        children: /* @__PURE__ */ N("div", { className: "text-center", children: [
          /* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No flow data" }),
          /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "Configure a flow analysis with a starting step and event dimension" })
        ] })
      }
    );
  const p = Math.min(a.width, a.height), f = Math.max(p / 2 - 40, 100), b = d.originalName || d.name, m = d.value;
  return /* @__PURE__ */ N("div", { className: "relative w-full h-full flex flex-col", style: { height: n }, children: [
    /* @__PURE__ */ N("div", { ref: i, className: "flex-1 min-h-0 relative", children: [
      /* @__PURE__ */ o(tt, { width: "100%", height: "100%", children: /* @__PURE__ */ o(
        Bs,
        {
          data: d,
          dataKey: "value",
          innerRadius: c,
          outerRadius: f,
          stroke: "var(--dc-bg)",
          children: /* @__PURE__ */ o(lt, { content: /* @__PURE__ */ o(ud, {}) })
        }
      ) }),
      c > 0 && /* @__PURE__ */ o(
        "div",
        {
          className: "absolute inset-0 flex items-center justify-center pointer-events-none",
          style: { zIndex: 10 },
          children: /* @__PURE__ */ N("div", { className: "text-center", children: [
            /* @__PURE__ */ o("div", { className: "text-sm font-semibold text-dc-text", children: b }),
            m !== void 0 && /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: m.toLocaleString() })
          ] })
        }
      )
    ] }),
    !u?.hideSummaryFooter && h && /* @__PURE__ */ o("div", { className: "flex-shrink-0 px-4 py-2 border-t border-dc-border bg-dc-surface-secondary", children: /* @__PURE__ */ N("div", { className: "flex items-center justify-between text-sm", children: [
      /* @__PURE__ */ N("div", { className: "text-dc-text-muted", children: [
        /* @__PURE__ */ o("span", { className: "font-medium", children: h.nodeCount }),
        " events (after)"
      ] }),
      /* @__PURE__ */ N("div", { className: "text-dc-text", children: [
        /* @__PURE__ */ o("span", { className: "text-dc-text-muted", children: "Paths:" }),
        " ",
        /* @__PURE__ */ o("span", { className: "font-medium", children: h.linkCount })
      ] }),
      /* @__PURE__ */ N("div", { className: "text-dc-text-muted", children: [
        /* @__PURE__ */ o("span", { className: "font-medium", children: h.totalEntities.toLocaleString() }),
        " ",
        "starting entities"
      ] })
    ] }) })
  ] });
}), kf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: dd
}, Symbol.toStringTag, { value: "Module" }));
export {
  _a as $,
  Cd as A,
  _d as B,
  Ed as C,
  Dd as D,
  $d as E,
  Md as F,
  Od as G,
  Ya as H,
  ae as I,
  Rd as J,
  Kr as K,
  Zn as L,
  Uo as M,
  Yo as N,
  Bo as O,
  Qo as P,
  Wo as Q,
  Ko as R,
  qo as S,
  of as T,
  Hu as U,
  Yu as V,
  Q as W,
  Jn as X,
  wo as Y,
  Xe as Z,
  Pt as _,
  Qr as a,
  gd as a0,
  bd as a1,
  Fd as a2,
  Td as a3,
  Ka as a4,
  ho as a5,
  fo as a6,
  uo as a7,
  co as a8,
  lo as a9,
  Wd as aA,
  Gd as aB,
  Xd as aC,
  Zd as aD,
  Jd as aE,
  ef as aF,
  lf as aG,
  cf as aH,
  uf as aI,
  df as aJ,
  ff as aK,
  hf as aL,
  mf as aM,
  pf as aN,
  yf as aO,
  xf as aP,
  gf as aQ,
  bf as aR,
  vf as aS,
  wf as aT,
  Nf as aU,
  Sf as aV,
  Af as aW,
  kf as aX,
  oo as aa,
  ao as ab,
  io as ac,
  so as ad,
  ro as ae,
  no as af,
  to as ag,
  eo as ah,
  Ja as ai,
  Za as aj,
  Xa as ak,
  Ga as al,
  Wa as am,
  tf as an,
  Id as ao,
  Pd as ap,
  zd as aq,
  jd as ar,
  Vd as as,
  Hd as at,
  Ud as au,
  Yd as av,
  Bd as aw,
  Qd as ax,
  qd as ay,
  Kd as az,
  Wr as b,
  Va as c,
  ke as d,
  $a as e,
  La as f,
  vo as g,
  At as h,
  kd as i,
  vd as j,
  on as k,
  Qt as l,
  Sd as m,
  Nd as n,
  wd as o,
  nf as p,
  rf as q,
  sf as r,
  go as s,
  Ad as t,
  Ld as u,
  Ge as v,
  bo as w,
  af as x,
  Zr as y,
  zt as z
};
//# sourceMappingURL=charts-DzHumCCp.js.map