import { e as i, g as l, f as n, h as o, D as d, i as u, M as s } from "./apply-styled-options-to-query-BzMAmDnD.js";
class m extends d {
  constructor(e, t) {
    var r;
    super((r = e.jaql.title) !== null && r !== void 0 ? r : "", t), this.__serializable = "JaqlElement", this.expression = e.jaql.dim || e.jaql.formula, this.metadataItem = e, e.jaql.agg ? this.aggregation = e.jaql.agg : delete this.aggregation, e.jaql.formula ? this.formula = e.jaql.formula : delete this.formula, e.jaql.sort ? this.sortType = u(e.jaql.sort) : delete this.sortType, this.skipValidation = !0;
  }
  get id() {
    return this.expression;
  }
  jaql(e) {
    return e === !0 ? this.metadataItem.jaql : this.metadataItem;
  }
  /**
   * Gets a serializable representation of the element
   */
  serialize() {
    const e = super.serialize();
    return e.metadataItem = this.metadataItem, e.type = this.type, e;
  }
}
const c = {
  text: s.TextAttribute,
  numeric: s.NumericAttribute,
  datetime: s.DateLevel
}, h = (a) => a && a.__serializable === "JaqlElement";
function p(a) {
  var e;
  return new m(a, (e = c[a.jaql.datatype]) !== null && e !== void 0 ? e : "numeric");
}
function y(a) {
  const { jaql: e } = a;
  if (e.formula)
    return i(e);
  const t = l(e);
  return "agg" in e && e.dim && e.datatype ? n({
    expression: e.dim,
    dataType: e.datatype,
    agg: e.agg || "",
    granularity: t,
    format: void 0,
    sort: e.sort,
    title: e.title,
    dataSource: e.datasource
  }) : e.dim && e.datatype ? o({
    expression: e.dim,
    dataType: e.datatype,
    granularity: t,
    sort: e.sort,
    title: e.title,
    panel: a.panel,
    dataSource: e.datasource
  }) : p(a);
}
const q = {
  jaql: { datasource: { title: "", type: "elasticube" }, metadata: [] },
  queryTitle: "",
  chartRecommendations: {}
}, f = {
  model: "",
  metadata: [],
  chart: {},
  queryTitle: ""
}, E = (a) => "widgetProps" in a, j = (a) => "dashboardOid" in a && "widgetOid" in a, b = (a) => "dashboardProps" in a, T = (a) => "dashboardOid" in a;
export {
  f as E,
  m as J,
  T as a,
  q as b,
  y as c,
  E as d,
  b as e,
  h as f,
  j as i
};
