import { E as F, a7 as V, z as O, _ as f, e as S, a8 as H, a9 as z, aa as D, a as W, ab as N, f as U, ac as x, ad as I, ae as J, M as q, s as G, c as w, g as K, af as j, ag as Q, ah as $, ai as Y, C as Z, x as T } from "./am-chart.H2jnOzFc.js";
import { P as tt } from "./Picture.YSPC0l0Q.js";
let L;
function et() {
  return f(this, void 0, void 0, function* () {
    let h = yield Promise.all([
      import(
        /* webpackChunkName: "pdfmake" */
        "./pdfmake.Bs7cMDH0.js"
      ).then((i) => i.p),
      import(
        /* webpackChunkName: "pdfmake" */
        "./vfs_fonts.VJpdcrR6.js"
      )
    ]), t = h[0].default, e = h[1].default;
    const s = window;
    return s.pdfMake = s.pdfMake || {}, s.pdfMake.vfs = e, t.vfs = e, t;
  });
}
class P extends F {
  //public extraImages: Array<Root | IExportingImageSource> = [];
  //public dataSources: any[] = [];
  _afterNew() {
    super._afterNew(), this._setRawDefault("filePrefix", "chart"), this._setRawDefault("charset", "utf-8"), this._setRawDefault("numericFields", []), this._setRawDefault("dateFields", []), this._setRawDefault("durationFields", []), this._setRawDefault("extraImages", []), this._setRawDefault("pngOptions", { quality: 1, maintainPixelRatio: !1 }), this._setRawDefault("jpgOptions", { quality: 0.8, maintainPixelRatio: !1 }), this._setRawDefault("printOptions", { quality: 1, maintainPixelRatio: !1, delay: 500, printMethod: "iframe", imageFormat: "png" }), this._setRawDefault("jsonOptions", { indent: 2, renameFields: !0 }), this._setRawDefault("csvOptions", { separator: ",", addColumnNames: !0, emptyAs: "", addBOM: !0 }), this._setRawDefault("htmlOptions", { emptyAs: "-", addColumnNames: !0 }), this._setRawDefault("xlsxOptions", { emptyAs: "", addColumnNames: !0 }), this._setRawDefault("pdfOptions", { fontSize: 14, imageFormat: "png", align: "left", addURL: !0 }), this._setRawDefault("pdfdataOptions", { emptyAs: "", addColumnNames: !0 }), this._root.addDisposer(this);
  }
  _beforeChanged() {
    if (super._beforeChanged(), this.isDirty("menu")) {
      const t = this.get("menu");
      t && (t.set("exporting", this), this._disposers.push(t));
    }
  }
  _getFormatOptions(t, e) {
    const s = V(this.get(t + "Options", {}));
    return e && O(e, (i, n) => {
      s[i] = n;
    }), s;
  }
  /**
   * Triggers a download of the chart/data in specific format.
   *
   * @param  format         Format
   * @param  customOptions  Format options
   */
  download(t, e) {
    return f(this, void 0, void 0, function* () {
      const s = t == "pdfdata" ? "pdf" : t, i = this.get("filePrefix", "chart") + "." + s, n = this._getFormatOptions(t, e);
      this.events.dispatch("downloadstarted", {
        type: "downloadstarted",
        format: t,
        options: n,
        fileName: i,
        target: this
      });
      const o = yield this.export(t, n);
      this.streamFile(o, i, n && n.addBOM);
    });
  }
  /**
   * Triggers print of the chart.
   *
   * @param  customOptions  Print options
   */
  print(t) {
    return f(this, void 0, void 0, function* () {
      const e = this._getFormatOptions("print", t);
      this.events.dispatch("printstarted", {
        type: "printstarted",
        format: "print",
        options: e,
        target: this
      });
      const s = yield this.export(e.imageFormat || "png", e);
      this.initiatePrint(s, e, this.get("title"));
    });
  }
  /**
   * Returns data uri of the chart/data in specific format.
   *
   * @param          format  Format
   * @param   customOptions  Format options
   * @return                 Promise
   */
  export(t, e) {
    return f(this, void 0, void 0, function* () {
      const s = this._getFormatOptions(t, e);
      this.events.dispatch("exportstarted", {
        type: "exportstarted",
        format: t,
        options: s,
        target: this
      });
      let i = "";
      switch (t) {
        case "png":
        case "jpg":
          this._root._runTickerNow(), i = this.exportImage(t, s);
          break;
        case "json":
          i = this.exportJSON(s);
          break;
        case "csv":
          i = this.exportCSV(s);
          break;
        case "html":
          i = this.exportHTML(s);
          break;
        case "xlsx":
          i = this.exportXLSX(s);
          break;
        case "pdf":
          this._root._runTickerNow(), i = this.exportPDF(s);
          break;
        case "pdfdata":
          i = this.exportPDFData(s);
          break;
      }
      return this.events.dispatch("exportfinished", {
        type: "exportfinished",
        format: t,
        options: s,
        target: this
      }), i;
    });
  }
  /**
   * ==========================================================================
   * Images
   * ==========================================================================
   */
  /**
   * Returns chart image as a data:uri.
   *
   * @param   format         Image format
   * @param   customOptions  Format options
   * @return                 Promise
   */
  exportImage(t, e) {
    return f(this, void 0, void 0, function* () {
      const s = this._getFormatOptions(t, e), i = yield this.getCanvas(s), n = i.toDataURL(this.getContentType(t), s.quality || 1);
      return this.disposeCanvas(i), n;
    });
  }
  /**
   * Returns canvas data.
   *
   * @param   customOptions  Image options
   * @return                 Promise
   */
  exportCanvas(t) {
    return f(this, void 0, void 0, function* () {
      const e = this._getFormatOptions("canvas", t), s = yield this.getCanvas(e), i = s.toDataURL(this.getContentType("canvas"), e.quality || 1);
      return this.disposeCanvas(s), i;
    });
  }
  /**
   * Returns a `<canvas>` element with snapshot of the chart.
   *
   * @param   options  Image options
   * @return           Promise
   */
  getCanvas(t) {
    return f(this, void 0, void 0, function* () {
      const e = this._root._renderer.getCanvas(this._root._rootContainer._display, t), s = this.get("extraImages", []);
      let i = 0, n = 0, o = e.width, a = e.height, p = 0, l = 0;
      const r = [];
      S(s, (m) => {
        let g;
        m instanceof H ? g = {
          source: m,
          position: "bottom"
        } : g = m, g.position = g.position || "bottom", g.marginTop = g.marginTop || 0, g.marginRight = g.marginRight || 0, g.marginBottom = g.marginBottom || 0, g.marginLeft = g.marginLeft || 0;
        const A = g.source._renderer.getCanvas(g.source._rootContainer._display, t), k = A.width + g.marginLeft + g.marginRight, R = A.height + g.marginTop + g.marginBottom;
        g.position == "top" ? (o = g.crop ? a : Math.max(o, k), n += R) : g.position == "right" ? (a = g.crop ? a : Math.max(a, R), p += k) : g.position == "left" ? (a = g.crop ? a : Math.max(a, R), i += k) : g.position === "bottom" && (o = g.crop ? a : Math.max(o, k), l += R), r.push({
          canvas: A,
          position: g.position,
          left: g.marginLeft,
          top: g.marginTop,
          width: k,
          height: R
        });
      });
      const d = this.getDisposableCanvas();
      d.width = i + o + p, d.height = n + a + l;
      const u = d.getContext("2d"), _ = this.get("backgroundColor", this.findBackgroundColor(this._root.dom)), b = this.get("backgroundOpacity", 1);
      _ && (u.fillStyle = _.toCSS(b), u.fillRect(0, 0, d.width, d.height));
      let v = i, C = n, c = v + o, y = C + a;
      return S(r, (m) => {
        m.position == "top" ? (C -= m.height, u.drawImage(m.canvas, i + m.left, C + m.top)) : m.position == "right" ? (u.drawImage(m.canvas, c + m.left, n + m.top), c += m.width) : m.position == "left" ? (v -= m.width, u.drawImage(m.canvas, v + m.left, n + m.top)) : m.position === "bottom" && (u.drawImage(m.canvas, i + m.left, y + m.top), y += m.height);
      }), u.drawImage(e, i, n), d;
    });
  }
  /**
   * ==========================================================================
   * JSON
   * ==========================================================================
   */
  /**
   * Returns a data:uri representation of a JSON file with chart data.
   *
   * @param   customOptions  Format options
   * @return                 Promise
   */
  exportJSON(t) {
    return f(this, void 0, void 0, function* () {
      return "data:" + this.getContentType("json") + ";" + this.get("charset", "utf-8") + "," + encodeURIComponent(yield this.getJSON(t));
    });
  }
  /**
   * Returns data in JSON format.
   *
   * @param   customOptions  Format options
   * @return                 Promise
   */
  getJSON(t) {
    return f(this, void 0, void 0, function* () {
      const e = this._getFormatOptions("json", t);
      return JSON.stringify(this.getData("json", t, e.renameFields), (s, i) => (z(i) && O(i, (n, o) => {
        i[n] = this.convertToSpecialFormat(n, o, e);
      }), i), e.indent);
    });
  }
  /**
   * ==========================================================================
   * CSV
   * ==========================================================================
   */
  /**
   * Returns a data:uri representation of a CSV file with chart data.
   *
   * @param   customOptions  Format options
   * @return                 Promise
   */
  exportCSV(t) {
    return f(this, void 0, void 0, function* () {
      return "data:" + this.getContentType("csv") + ";" + this.get("charset", "utf-8") + "," + encodeURIComponent(yield this.getCSV(t));
    });
  }
  /**
   * Returns a CSV with export data.
   *
   * @param   customOptions  CSV options
   * @return                 Promise
   */
  getCSV(t) {
    return f(this, void 0, void 0, function* () {
      const e = this._getFormatOptions("csv", t);
      let s = "", i = "";
      const n = this.getData("csv", e), o = this.getDataFields(n);
      if (e.pivot) {
        const a = this.get("dataFieldsOrder", []);
        D(o, (p, l) => {
          let r = [];
          e.addColumnNames && r.push(l);
          for (let d = n.length, u = 0; u < d; u++) {
            let _ = n[u][p];
            r.push(this.convertToSpecialFormat(p, _, e, !0));
          }
          s += i + this.getCSVRow(r, e, void 0, !0), i = `
`;
        }, (p, l) => {
          let r = a.indexOf(p), d = a.indexOf(l);
          return r > d ? -1 : r < d ? 1 : 0;
        });
      } else {
        for (let a = n.length, p = 0; p < a; p++) {
          let l = this.getCSVRow(n[p], e, o);
          e.reverse ? s = l + i + s : s += i + l, i = `
`;
        }
        e.addColumnNames && (s = this.getCSVRow(o, e, void 0, !0) + i + s);
      }
      return s;
    });
  }
  /**
   * @ignore
   */
  getCSVRow(t, e, s, i = !1) {
    let n = e.separator || ",", o = [];
    s || (s = {}, O(t, (p, l) => {
      s[p] = l;
    }));
    const a = this.get("dataFieldsOrder", []);
    return D(s, (p, l) => {
      let r = this.convertEmptyValue(p, t[p], e), d = i ? r : this.convertToSpecialFormat(p, r, e);
      d = "" + d, d = d.replace(/"/g, '""'), (e.forceQuotes || d.search(new RegExp(`"|
|` + n, "g")) >= 0) && (d = '"' + d + '"'), o.push(d);
    }, (p, l) => {
      let r = a.indexOf(p), d = a.indexOf(l);
      return r > d ? 1 : r < d ? -1 : 0;
    }), o.join(n);
  }
  /**
   * ==========================================================================
   * HTML
   * ==========================================================================
   */
  /**
   * Returns a data:uri representation of an HTML file with chart data.
   *
   * @param   customOptions  Format options
   * @return                 Promise
   */
  exportHTML(t) {
    return f(this, void 0, void 0, function* () {
      return "data:" + this.getContentType("html") + ";" + this.get("charset", "utf-8") + "," + encodeURIComponent(yield this.getHTML(t));
    });
  }
  /**
   * Returns an HTML with a table with export data.
   *
   * @param   customOptions  HTML options
   * @return                 Promise
   */
  getHTML(t) {
    return f(this, void 0, void 0, function* () {
      const e = this._getFormatOptions("html", t);
      let s = "<table>";
      e.tableClass && (s = '<table class="' + e.tableClass + '">');
      const i = this.getData("html", e), n = this.getDataFields(i);
      if (e.pivot) {
        const o = this.get("dataFieldsOrder", []);
        s += `
<tbody>`, D(n, (a, p) => {
          let l = [];
          e.addColumnNames && l.push(p);
          for (let r = i.length, d = 0; d < r; d++) {
            let u = i[d][a];
            l.push(this.convertToSpecialFormat(a, u, e, !0));
          }
          s += `
` + this.getHTMLRow(l, e, void 0, !0);
        }, (a, p) => {
          let l = o.indexOf(a), r = o.indexOf(p);
          return l > r ? -1 : l < r ? 1 : 0;
        }), s += `
</tbody>`;
      } else {
        e.addColumnNames && (s += `
<thead>
` + this.getHTMLRow(n, e, void 0, !0, !0) + `
</thead>`), s += `
<tbody>`;
        for (let o = i.length, a = 0; a < o; a++)
          s += `
` + this.getHTMLRow(i[a], e, n);
        s += `
</tbody>`;
      }
      return s += `
</table>`, s;
    });
  }
  /**
   * @ignore
   */
  getHTMLRow(t, e, s, i = !1, n = !1) {
    let o = "	<tr>";
    e.rowClass && (o = '	<tr class="' + e.rowClass + '">'), s || (s = t);
    const a = this.get("dataFieldsOrder", []), p = n ? "th" : "td";
    let l = !0;
    return D(s, (r, d) => {
      let u = this.convertEmptyValue(r, t[r], e), _ = i ? u : this.convertToSpecialFormat(r, u, e);
      _ = "" + _, _ = _.replace(/[\u00A0-\u9999<>\&]/gim, function(v) {
        return "&#" + v.charCodeAt(0) + ";";
      });
      let b = p;
      e.pivot && l && (b = "th"), e.cellClass ? o += `
		<` + b + ' class="' + e.cellClass + '">' + _ + "</" + b + ">" : o += `
		<` + b + ">" + _ + "</" + b + ">", l = !1;
    }, (r, d) => {
      let u = a.indexOf(r), _ = a.indexOf(d);
      return u > _ ? 1 : u < _ ? -1 : 0;
    }), o += `
	</tr>`, o;
  }
  /**
   * ==========================================================================
   * XLSX
   * ==========================================================================
   */
  /**
   * Returns a data:uri representation of an XLSX file with chart data.
   *
   * @param   customOptions  Format options
   * @return                 Promise
   */
  exportXLSX(t) {
    return f(this, void 0, void 0, function* () {
      return "data:" + this.getContentType("xlsx") + ";" + this.get("charset", "utf-8") + "," + encodeURIComponent(yield this.getXLSX(t));
    });
  }
  /**
   * Returns a data:uri of XLSX data.
   *
   * @param  customOptions  Format options
   * @return                Promise
   */
  getXLSX(t) {
    return f(this, void 0, void 0, function* () {
      const e = this._getFormatOptions("xlsx", t);
      let s = yield this.getXLSXLib(), i = {
        bookType: "xlsx",
        bookSST: !1,
        type: "base64"
        //dateNF: 'yyyy-mm-dd'
      }, n = this._normalizeExcelSheetName(this.get("title", this._t("Data"))), o = {
        SheetNames: [n],
        Sheets: {}
      }, a = [];
      const p = this.getData("html", e), l = this.getDataFields(p);
      if (e.pivot) {
        const r = this.get("dataFieldsOrder", []);
        D(l, (d, u) => {
          let _ = [];
          e.addColumnNames && _.push(u);
          for (let b = p.length, v = 0; v < b; v++) {
            let C = p[v][d];
            _.push(this.convertToSpecialFormat(d, C, e, !0));
          }
          a.push(this.getXLSXRow(_, e, void 0, !0));
        }, (d, u) => {
          let _ = r.indexOf(d), b = r.indexOf(u);
          return _ > b ? 1 : _ < b ? -1 : 0;
        });
      } else {
        e.addColumnNames && a.push(this.getXLSXRow(l, e, void 0, !0));
        for (let r = p.length, d = 0; d < r; d++)
          a.push(this.getXLSXRow(p[d], e, l));
      }
      return o.Sheets[n] = s.utils.aoa_to_sheet(a), this.events.dispatch("workbookready", {
        type: "workbookready",
        format: "xlsx",
        options: e,
        workbook: o,
        workbookOptions: i,
        xlsx: s,
        target: this
      }), s.write(o, i);
    });
  }
  _normalizeExcelSheetName(t) {
    return t = t.replace(/([:\\\/?*\[\]]+)/g, " "), t.length > 30 ? t.substr(0, 30) + "..." : t;
  }
  /**
   * @ignore
   */
  getXLSXRow(t, e, s, i = !1) {
    let n = [];
    s || (s = t);
    const o = this.get("dataFieldsOrder", []);
    return D(s, (a, p) => {
      let l = this.convertEmptyValue(a, t[a], e), r = i ? l : this.convertToSpecialFormat(a, l, e, !0);
      n.push(r);
    }, (a, p) => {
      let l = o.indexOf(a), r = o.indexOf(p);
      return l > r ? 1 : l < r ? -1 : 0;
    }), n;
  }
  /**
   * @ignore
   */
  _xlsx() {
    return f(this, void 0, void 0, function* () {
      return yield import(
        /* webpackChunkName: "xlsx" */
        "./xlsx.v-qkA-dg.js"
      );
    });
  }
  /**
   * @ignore
   */
  getXLSXLib() {
    return this._xlsx();
  }
  /**
   * ==========================================================================
   * PDF
   * ==========================================================================
   */
  /**
   * Returns a data:uri representation of a PDF file with chart image.
   *
   * @param   customOptions  Format options
   * @return                 Promise
   */
  exportPDF(t) {
    return f(this, void 0, void 0, function* () {
      return "data:" + this.getContentType("pdf") + ";" + this.get("charset", "utf-8") + "," + encodeURIComponent(yield this.getPDF(t, !0));
    });
  }
  /**
   * Returns a data:uri representation of a PDF file with chart data.
   *
   * @param   customOptions  Format options
   * @return                 Promise
   */
  exportPDFData(t) {
    return f(this, void 0, void 0, function* () {
      return "data:" + this.getContentType("pdf") + ";" + this.get("charset", "utf-8") + "," + encodeURIComponent(yield this.getPDF(t, !1, !0));
    });
  }
  /**
   * Returns Base64-encoded binary data for a PDF file.
   * @param   customOptions  PDF options
   * @param   includeImage   Include chart snapshot
   * @param   includeData    Include data
   * @return                 Promise
   */
  getPDF(t, e = !0, s = !1) {
    return f(this, void 0, void 0, function* () {
      const i = this._getFormatOptions("pdf", t), n = this._getFormatOptions("pdfdata", t), o = i.pageOrientation || "portrait";
      let a;
      const p = {
        width: 0,
        height: 0
      };
      if (e) {
        const c = i.imageFormat || "png", y = this._getFormatOptions(c, i), m = yield this.getCanvas(y);
        p.width = m.clientWidth, p.height = m.clientHeight, a = m.toDataURL(this.getContentType(c), i.quality || 1), this.disposeCanvas(m);
      }
      const l = yield this.getPdfmake(), r = [30, 30, 30, 30];
      let d = {
        pageSize: i.pageSize || "A4",
        pageOrientation: o,
        pageMargins: i.pageMargins || r,
        defaultStyle: {
          font: i.font ? i.font.name : void 0
        },
        //header: <any>[],
        content: []
      };
      const u = this.get("title");
      let _ = 0;
      if (u && (d.content.push({
        text: u,
        fontSize: i.fontSize || 14,
        bold: !0,
        margin: [0, 0, 0, 15]
      }), _ += 50), i.addURL && (d.content.push({
        text: this._t("Saved from") + ": " + document.location.href,
        fontSize: i.fontSize,
        margin: [0, 0, 0, 15]
      }), _ += 50), e && a) {
        const c = this.getPageSizeFit(d.pageSize, d.pageMargins, _, o);
        p.width > c[0] || p.height > c[1] ? d.content.push({
          image: a,
          alignment: i.align || "left",
          fit: c
        }) : d.content.push({
          image: a,
          alignment: i.align || "left"
        });
      }
      (s || i.includeData) && this.hasData() && d.content.push({
        table: yield this.getPDFData(n),
        fontSize: i.fontSize || 14
      });
      let b = null, v = null;
      function C(c) {
        const y = {};
        y.normal = c.normal.path, v[c.normal.path] = c.normal.bytes, c.bold ? (y.bold = c.bold.path, v[c.bold.path] = c.bold.bytes) : y.bold = c.normal.path, c.italics ? (y.italics = c.italics.path, v[c.italics.path] = c.italics.bytes) : y.italics = c.normal.path, c.bolditalics ? (y.bolditalics = c.bolditalics.path, v[c.bolditalics.path] = c.bolditalics.bytes) : y.bolditalics = c.normal.path, b[c.name] = y;
      }
      return i.font && (b = {}, v = {}, C(i.font), i.extraFonts && S(i.extraFonts, C)), this.events.dispatch("pdfdocready", {
        type: "pdfdocready",
        format: "pdf",
        options: i,
        doc: d,
        target: this
      }), new Promise((c, y) => {
        l.createPdf(d, null, b, v).getBase64((m) => {
          c(m);
        });
      });
    });
  }
  /**
   * @ignore
   */
  getPDFData(t) {
    return f(this, void 0, void 0, function* () {
      const e = this._getFormatOptions("pdfdata", t);
      let s = {
        body: []
      };
      const i = this.getData("html", e), n = this.getDataFields(i);
      if (e.pivot) {
        const o = this.get("dataFieldsOrder", []);
        D(n, (a, p) => {
          let l = [];
          e.addColumnNames && l.push(p);
          for (let r = i.length, d = 0; d < r; d++) {
            let u = i[d][a];
            l.push(this.convertToSpecialFormat(a, u, e, !0));
          }
          s.body.push(this.getPDFDataRow(l, e, void 0, !0));
        }, (a, p) => {
          let l = o.indexOf(a), r = o.indexOf(p);
          return l > r ? 1 : l < r ? -1 : 0;
        });
      } else {
        e.addColumnNames && (s.body.push(this.getPDFDataRow(n, e, void 0, !0)), s.headerRows = 1);
        for (let o = i.length, a = 0; a < o; a++)
          s.body.push(this.getPDFDataRow(i[a], e, n));
      }
      return s;
    });
  }
  /**
   * @ignore
   */
  getPDFDataRow(t, e, s, i = !1) {
    let n = [];
    s || (s = t);
    const o = this.get("dataFieldsOrder", []);
    return D(s, (a, p) => {
      let l = this.convertEmptyValue(a, t[a], e), r = i ? l : this.convertToSpecialFormat(a, l, e);
      r = "" + r, n.push(r);
    }, (a, p) => {
      let l = o.indexOf(a), r = o.indexOf(p);
      return l > r ? 1 : l < r ? -1 : 0;
    }), n;
  }
  /**
   * Returns pdfmake instance.
   *
   * @ignore
   * @return Instance of pdfmake
   */
  getPdfmake() {
    return L === void 0 && (L = et()), L;
  }
  /**
   * @ignore
   */
  getPageSizeFit(t, e, s = 0, i = "portrait") {
    let n = [0, 0, 0, 0];
    W(e) ? n = [e, e, e, e] : e.length == 2 ? n = [e[0], e[1], e[0], e[1]] : e.length == 4 && (n = e);
    let a = {
      "4A0": [4767.87, 6740.79],
      "2A0": [3370.39, 4767.87],
      A0: [2383.94, 3370.39],
      A1: [1683.78, 2383.94],
      A2: [1190.55, 1683.78],
      A3: [841.89, 1190.55],
      A4: [595.28, 841.89],
      A5: [419.53, 595.28],
      A6: [297.64, 419.53],
      A7: [209.76, 297.64],
      A8: [147.4, 209.76],
      A9: [104.88, 147.4],
      A10: [73.7, 104.88],
      B0: [2834.65, 4008.19],
      B1: [2004.09, 2834.65],
      B2: [1417.32, 2004.09],
      B3: [1000.63, 1417.32],
      B4: [708.66, 1000.63],
      B5: [498.9, 708.66],
      B6: [354.33, 498.9],
      B7: [249.45, 354.33],
      B8: [175.75, 249.45],
      B9: [124.72, 175.75],
      B10: [87.87, 124.72],
      C0: [2599.37, 3676.54],
      C1: [1836.85, 2599.37],
      C2: [1298.27, 1836.85],
      C3: [918.43, 1298.27],
      C4: [649.13, 918.43],
      C5: [459.21, 649.13],
      C6: [323.15, 459.21],
      C7: [229.61, 323.15],
      C8: [161.57, 229.61],
      C9: [113.39, 161.57],
      C10: [79.37, 113.39],
      RA0: [2437.8, 3458.27],
      RA1: [1729.13, 2437.8],
      RA2: [1218.9, 1729.13],
      RA3: [864.57, 1218.9],
      RA4: [609.45, 864.57],
      SRA0: [2551.18, 3628.35],
      SRA1: [1814.17, 2551.18],
      SRA2: [1275.59, 1814.17],
      SRA3: [907.09, 1275.59],
      SRA4: [637.8, 907.09],
      EXECUTIVE: [521.86, 756],
      FOLIO: [612, 936],
      LEGAL: [612, 1008],
      LETTER: [612, 792],
      TABLOID: [792, 1224]
    }[t];
    return i == "landscape" && a.reverse(), a[0] -= n[0] + n[2], a[1] -= n[1] + n[3] + s, a;
  }
  /**
   * ==========================================================================
   * Data
   * ==========================================================================
   */
  /**
      * Returns `true` if `dataSource` is set, and the contents are proper
      * data (array).
      *
      * @return Has data?
      */
  hasData() {
    const t = this.get("dataSource");
    return !!(N(t) && t.length);
  }
  /**
   * Returns processed data according to format options.
   *
   * @param   format         Format
   * @param   customOptions  Format options
   * @param   renameFields   Should fields be renamed?
   * @return                 Processed data
   */
  getData(t, e, s = !1) {
    const i = this._getFormatOptions(t, e), n = this.get("dataSource", []);
    let o = n;
    const a = this.get("dataFields");
    a && N(n) && (o = [], S(n, (l) => {
      if (z(l)) {
        const r = {};
        O(a, (d, u) => {
          a[d] != null && (r[s ? u : d] = this.convertToSpecialFormat(d, l[d], i));
        }), o.push(r);
      }
    }));
    const p = {
      type: "dataprocessed",
      format: t,
      options: i,
      data: o,
      target: this
    };
    return this.events.dispatch("dataprocessed", p), p.data;
  }
  /**
   * @ignore
   */
  getDataFields(t) {
    let e = this.get("dataFields");
    return e || (e = {}, N(t) && t.length && S(t, (s) => {
      O(s, (i, n) => {
        e[i] == null && (e[i] = i);
      });
    })), e;
  }
  /**
   * @ignore
   */
  convertEmptyValue(t, e, s) {
    return e ?? s.emptyAs;
  }
  /**
   * @ignore
   */
  convertToSpecialFormat(t, e, s, i) {
    if (typeof e == "number")
      if (this.isDateField(t))
        e = new Date(e);
      else {
        if (this.isNumericField(t) && this.get("numberFormat"))
          return this._root.numberFormatter.format(e, this.get("numberFormat"));
        if (this.isDurationField(t))
          return this._root.durationFormatter.format(e, this.get("durationFormat"), this.get("durationUnit"));
      }
    return e instanceof Date && (s.useTimestamps ? e = e.getTime() : s.useLocale ? i || (e = e.toLocaleString()) : e = this._root.dateFormatter.format(e, this.get("dateFormat"))), e;
  }
  /**
   * @ignore
   */
  isDateField(t) {
    return this.get("dateFields").indexOf(t) !== -1;
  }
  /**
   * @ignore
   */
  isNumericField(t) {
    return this.get("numericFields").indexOf(t) !== -1;
  }
  /**
   * @ignore
   */
  isDurationField(t) {
    return this.get("durationFields").indexOf(t) !== -1;
  }
  /**
   * @ignore
   */
  getContentType(t) {
    let e = "";
    switch (t) {
      case "png":
        e = "image/" + t;
        break;
      case "jpg":
        e = "image/jpeg";
        break;
      case "csv":
        e = "text/csv";
        break;
      case "json":
        e = "application/json";
        break;
      case "html":
        e = "text/html";
        break;
      case "pdf":
      case "pdfdata":
        e = "application/pdf";
        break;
      case "xlsx":
        e = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
        break;
      default:
        e = "application/octet-stream";
    }
    return e;
  }
  getDisposableCanvas() {
    let t = document.createElement("canvas");
    return t.style.position = "fixed", t.style.top = "-10000px", this._root.dom.appendChild(t), t;
  }
  disposeCanvas(t) {
    this._root.dom.removeChild(t);
  }
  /**
   * @ignore
   */
  findBackgroundColor(t) {
    let e = 1, s = getComputedStyle(t, "background-color").getPropertyValue("background-color");
    if ((s.match(/[^,]*,[^,]*,[^,]*,[ ]?0/) || s == "transparent") && (e = 0), e == 0) {
      let i = t.parentElement;
      return i ? this.findBackgroundColor(i) : U.fromHex(16777215);
    } else
      return U.fromCSS(s);
  }
  /**
   * Triggers download of the file.
   *
   * @param   uri       data:uri with file content
   * @param   fileName  File name
   * @param   addBOM    Should download include byte order mark?
   * @return            Promise
   */
  streamFile(t, e, s = !1) {
    if (this.blobDownloadSupport()) {
      let i = document.createElement("a");
      i.download = e, document.body.appendChild(i);
      let n = t.split(";"), o = n.shift().replace(/data:/, "");
      if (t = decodeURIComponent(n.join(";").replace(/^[^,]*,/, "")), ["image/svg+xml", "application/json", "text/csv", "text/html"].indexOf(o) == -1)
        try {
          t = atob(t);
        } catch {
          return !1;
        }
      else {
        s && (t = "\uFEFF" + t);
        let r = new Blob([t], { type: o }), d = window.URL.createObjectURL(r);
        return i.href = d, i.download = e, i.click(), setTimeout(() => {
          document.body.removeChild(i), window.URL.revokeObjectURL(d);
        }, 100), !0;
      }
      let a = new Array(t.length);
      for (let r = 0; r < t.length; ++r) {
        let d = t.charCodeAt(r);
        a[r] = d;
      }
      s && (a = [239, 187, 191].concat(a));
      let p = new Blob([new Uint8Array(a)], { type: o }), l = window.URL.createObjectURL(p);
      i.href = l, i.download = e, document.body.appendChild(i), i.click(), document.body.removeChild(i), setTimeout(() => {
        window.URL.revokeObjectURL(l);
      }, 100);
    } else if (this.linkDownloadSupport()) {
      let i = document.createElement("a");
      i.download = e, i.href = t, document.body.appendChild(i), i.click(), document.body.removeChild(i);
    } else
      window.location.href = t;
    return !0;
  }
  /**
   * @ignore
   */
  downloadSupport() {
    return this.linkDownloadSupport();
  }
  /**
   * @ignore
   */
  linkDownloadSupport() {
    return typeof document.createElement("a").download < "u";
  }
  /**
   * @ignore
   */
  blobDownloadSupport() {
    return window.Blob != null;
  }
  /**
   * ==========================================================================
   * Print
   * ==========================================================================
   */
  /**
   * Initiates print of the chart.
   *
   * @param   data     data:uri for the image
   * @param   options  Options
   * @param   title    Optional title to use (uses window's title by default)
   * @return           Promise
   */
  initiatePrint(t, e, s) {
    const i = this._getFormatOptions("print", e);
    i.printMethod == "css" ? this._printViaCSS(t, i, s) : this._printViaIframe(t, i, s);
  }
  _printViaCSS(t, e, s) {
    let n = this._getFormatOptions("print", e).delay || 500, o = document.documentElement.scrollTop || document.body.scrollTop, a = new x(I(this._root.dom), "body > *", {
      display: "none",
      position: "fixed",
      visibility: "hidden",
      opacity: "0",
      clipPath: "polygon(0px 0px,0px 0px,0px 0px,0px 0px);"
    }, this._root.nonce), p = new x(I(this._root.dom), "body", {
      padding: "0",
      margin: "0"
    }, this._root.nonce), l;
    s && document && document.title && (l = document.title, document.title = s);
    let r = new Image();
    r.src = t, r.style.maxWidth = "100%", r.style.display = "block", r.style.position = "relative", r.style.visibility = "visible", r.style.opacity = "1", r.style.clipPath = "none", document.body.appendChild(r), this.setTimeout(() => {
      window.print();
    }, 50), /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream && n < 1e3 ? n = 1e3 : n < 100 && (n = 100), this.setTimeout(() => {
      document.body.removeChild(r), a.dispose(), p.dispose(), l && (document.title = document.title), document.documentElement.scrollTop = document.body.scrollTop = o;
    }, n || 500);
  }
  _printViaIframe(t, e, s) {
    let n = this._getFormatOptions("print", e).delay || 500;
    const o = document.createElement("iframe");
    o.style.visibility = "hidden", document.body.appendChild(o), o.contentWindow.document.open(), o.contentWindow.document.close();
    let a = new Image();
    a.src = t, a.style.maxWidth = "100%", a.style.height = "auto", s && (o.contentWindow.document.title = s), o.contentWindow.document.body.appendChild(a), o.load = function() {
      o.contentWindow.document.body.appendChild(a);
    }, this.setTimeout(() => {
      try {
        o.contentWindow.document.execCommand("print", !1, null) || o.contentWindow.print();
      } catch {
        o.contentWindow.print();
      }
    }, n || 50), /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream && n < 1e3 ? n = 1e3 : n < 100 && (n = 100), this.setTimeout(() => {
      document.body.removeChild(o);
    }, n + 50 || 100);
  }
  /**
   * Returns a list of formats that can be exported in current browser.
   *
   * @return Formats
   */
  supportedFormats() {
    const t = [], e = this.hasData(), s = this.downloadSupport();
    return S(["png", "jpg", "canvas", "pdf", "xlsx", "csv", "json", "html", "pdfdata", "print"], (i) => {
      this._getFormatOptions(i).disabled !== !0 && (["xlsx", "csv", "json", "html", "pdfdata"].indexOf(i) == -1 || e && s) && t.push(i);
    }), t;
  }
  /**
   * Returns a list of supported export types: image or print.
   *
   * @return Supported types
   */
  supportedExportTypes() {
    const t = ["image", "print"];
    return this.downloadSupport() && this.hasData() && t.push("data"), t;
  }
}
P.className = "Exporting";
P.classNames = F.classNames.concat([P.className]);
function X(h, t) {
  const e = t.interfaceColors;
  return new q([
    new x(h, ".am5exporting-menu", {
      color: e.get("secondaryButtonText").toCSS(),
      "font-size": "0.8em"
    }, t.nonce),
    new x(h, ".am5exporting-menu *", {
      "box-sizing": "border-box",
      transition: "all 100ms ease-in-out"
    }, t.nonce),
    new x(h, ".am5exporting-menu a", {
      display: "block",
      cursor: "pointer"
    }, t.nonce),
    new x(h, ".am5exporting-type-separator", {
      color: e.get("disabled").toCSS(),
      "border-bottom": "1px solid " + e.get("secondaryButtonDown").toCSS()
    }, t.nonce),
    new x(h, ".am5exporting-label-alt", {
      color: e.get("disabled").toCSS(),
      "font-size": "0.8em"
    }, t.nonce),
    new x(h, ".am5exporting-menu .am5exporting-type-separator a", {
      cursor: "default"
    }, t.nonce),
    new x(h, ".am5exporting-menu .am5exporting-type-separator a:hover", {
      background: "initial"
    }, t.nonce),
    new x(h, ".am5exporting-menu", {
      position: "absolute",
      "z-index": "10"
    }, t.nonce),
    new x(h, ".am5exporting-icon", {
      width: "30px",
      height: "26px",
      position: "absolute",
      margin: "5px",
      padding: "3px 5px",
      "border-radius": "3px",
      opacity: "0.5",
      background: "rgba(255, 255, 255, 0.001)",
      "background-opacity": "0"
    }, t.nonce),
    new x(h, ".am5exporting-icon:focus, .am5exporting-icon:hover, .am5exporting-menu-open .am5exporting-icon", {
      background: e.get("secondaryButtonHover").toCSS(),
      opacity: "1"
    }, t.nonce),
    new x(h, ".am5exporting-menu path", {
      fill: e.get("secondaryButtonText").toCSS()
    }, t.nonce),
    new x(h, ".am5exporting-list", {
      display: "none",
      "list-style": "none",
      "list-style-type": "none",
      margin: "5px",
      background: e.get("secondaryButton").toCSS(),
      padding: "5px 0",
      border: "1px solid " + e.get("secondaryButtonStroke").toCSS(),
      "border-radius": "3px"
    }, t.nonce),
    new x(h, ".am5exporting-menu-open .am5exporting-list", {
      display: "block"
    }, t.nonce),
    new x(h, ".am5exporting-item", {}, t.nonce),
    new x(h, ".am5exporting-item a", {
      padding: "3px 15px"
    }, t.nonce),
    new x(h, ".am5exporting-item a:hover, .am5exporting-item a.am5exporting-item-active", {
      background: e.get("secondaryButtonHover").toCSS()
    }, t.nonce),
    new x(h, ".am5exporting-menu.am5exporting-align-left, .am5exporting-icon.am5exporting-align-left, .am5exporting-list.am5exporting-align-left", {
      left: "0"
    }, t.nonce),
    new x(h, ".am5exporting-menu.am5exporting-align-right, .am5exporting-icon.am5exporting-align-right, .am5exporting-list.am5exporting-align-right", {
      right: "0"
    }, t.nonce),
    new x(h, ".am5exporting-menu.am5exporting-valign-top, .am5exporting-icon.am5exporting-valign-top, .am5exporting-list.am5exporting-align-top", {
      top: "0"
    }, t.nonce),
    new x(h, ".am5exporting-menu.am5exporting-valign-bottom, .am5exporting-icon.am5exporting-valign-bottom, .am5exporting-list.am5exporting-align-bottom", {
      bottom: "0"
    }, t.nonce),
    new x(h, ".am5exporting-list.am5exporting-align-left", {
      "margin-left": "40px"
    }, t.nonce),
    new x(h, ".am5exporting-list.am5exporting-align-right", {
      "margin-right": "40px"
    }, t.nonce)
    // new StyleRule(element, ".${newPrefix}-menu-level-0", {
    // 	"position": "absolute",
    // 	"top": "5px",
    // 	"right": "5px",
    // })
  ]);
}
let E;
function it(h, t, e) {
  if (h == null) {
    if (!E) {
      const s = X(h, t);
      E = new J(() => {
        E = void 0, s.dispose();
      });
    }
    return E.increment();
  } else
    return X(h, t);
}
class M extends F {
  constructor() {
    super(...arguments), this._itemElements = [], this._itemDisposers = [], this.isOpen = !1, this._isOver = !1;
  }
  _afterNew() {
    super._afterNew(), this._setRawDefault("container", this._root._inner), this._setRawDefault("align", "right"), this._setRawDefault("valign", "top"), this._setRawDefault("useDefaultCSS", !0), this._setRawDefault("autoClose", !0), this._setRawDefault("deactivateRoot", !0), this._setRawDefault("items", [{
      type: "separator",
      label: this._t("Export")
    }, {
      type: "format",
      format: "png",
      exportType: "image",
      label: this._t("PNG"),
      sublabel: this._t("Image")
    }, {
      type: "format",
      format: "jpg",
      exportType: "image",
      label: this._t("JPG"),
      sublabel: this._t("Image")
    }, {
      type: "format",
      format: "pdf",
      exportType: "image",
      label: this._t("PDF"),
      sublabel: this._t("Image")
    }, {
      type: "separator",
      exportType: "data"
      //label: this._t("Data")
    }, {
      type: "format",
      format: "json",
      exportType: "data",
      label: this._t("JSON"),
      sublabel: this._t("Data")
    }, {
      type: "format",
      format: "csv",
      exportType: "data",
      label: this._t("CSV"),
      sublabel: this._t("Data")
    }, {
      type: "format",
      format: "xlsx",
      exportType: "data",
      label: this._t("XLSX"),
      sublabel: this._t("Data")
    }, {
      type: "format",
      format: "pdfdata",
      exportType: "data",
      label: this._t("PDF"),
      sublabel: this._t("Data")
    }, {
      type: "format",
      format: "html",
      exportType: "data",
      label: this._t("HTML"),
      sublabel: this._t("Data")
    }, {
      type: "separator"
    }, {
      type: "format",
      format: "print",
      exportType: "print",
      label: this._t("Print")
    }]);
    const t = document.createElement("div");
    this._menuElement = t, this.setPrivate("menuElement", this._menuElement);
    const e = document.createElement("a");
    this._iconElement = e, this._listElement = document.createElement("ul"), this._listElement.setAttribute("role", "menu"), this.setPrivate("listElement", this._listElement), this._applyClassNames(), e.innerHTML = '<svg fill="none" height="20" width="20" xmlns="http://www.w3.org/2000/svg"><path d="M6 10a2 2 0 11-4 0 2 2 0 014 0zM12 10a2 2 0 11-4 0 2 2 0 014 0zM16 12a2 2 0 100-4 2 2 0 000 4z"/></svg>', e.setAttribute("tabindex", this._root.tabindex.toString()), e.setAttribute("aria-label", this.get("ariaLabel", this._t("Export") + "; " + this._t("Press ENTER to open"))), e.setAttribute("role", "button"), G("keyboardevents") && this._disposers.push(w(document, "keydown", (i) => {
      const n = K(i);
      if (document.activeElement == this._iconElement || this.isOpen) {
        if (n == "Escape")
          this.close();
        else if (n == "Enter")
          this._activeItem ? this._handleClick(this._activeItem) : this.toggle();
        else if (n == "ArrowUp" || n == "ArrowDown") {
          const o = this.get("items", []);
          let a = o.indexOf(this._activeItem);
          this.get("valign") == "top" && a == -1 && (a = o.length);
          const p = n == "ArrowUp" ? -1 : 1;
          let l = a + p, r;
          do
            l < 0 ? l = o.length - 1 : l > o.length - 1 && (l = 0), o[l].type == "separator" ? l += p : r = o[l];
          while (!r);
          r && this._handleItemFocus(r);
        }
      }
    })), this._disposers.push(w(e, "click", (i) => {
      i.stopImmediatePropagation(), this.toggle();
    })), t.appendChild(this._iconElement), t.appendChild(this._listElement);
    const s = this.get("container", this._root._inner);
    s.appendChild(this._menuElement), this._disposers.push(w(t, j("pointerover"), (i) => {
      this._isOver = !0, this.get("deactivateRoot") && (this._root._renderer.interactionsEnabled = !1);
    })), this._disposers.push(w(t, j("pointerout"), (i) => {
      this.get("deactivateRoot") && (this.isOpen || this._isOver) && (this._root._renderer.interactionsEnabled = !0), this._isOver = !1;
    })), this._disposers.push(new Q(() => {
      this._menuElement && s.removeChild(this._menuElement);
    })), this._disposers.push(w(document, "click", (i) => {
      this.isOpen && !this._isOver && this.close();
    })), this.loadDefaultCSS(), this._root.addDisposer(this), this.events.dispatch("menucreated", {
      type: "menucreated",
      target: this
    });
  }
  _afterChanged() {
    if (super._afterChanged(), this._itemElements.length == 0 && this.createItems(), this.isDirty("useDefaultCSS") && (this.get("useDefaultCSS") ? this.loadDefaultCSS() : this._cssDisposer && this._cssDisposer.dispose()), this.isDirty("exporting") && this.get("exporting") && this.createItems(), (this.isDirty("align") || this.isDirty("valign")) && this._applyClassNames(), this.isDirty("container")) {
      const t = this.get("container");
      t && t.appendChild(this._menuElement);
    }
  }
  _dispose() {
    super._dispose(), S(this._itemDisposers, (t) => {
      t.dispose();
    });
  }
  _applyClassNames() {
    const t = this.get("align", "right"), e = this.get("valign", "top"), s = this.isOpen ? "am5exporting-menu-open" : "am5exporting-menu-closed";
    this._menuElement.className = "am5exporting am5exporting-menu am5exporting-align-" + t + " am5exporting-valign-" + e + " " + s, this._iconElement.className = "am5exporting am5exporting-icon am5exporting-align-" + t + " am5exporting-valign-" + e, this._listElement.className = "am5exporting am5exporting-list am5exporting-align-" + t + " am5exporting-valign-" + e;
  }
  /**
   * @ignore
   */
  createItems() {
    const t = this.get("exporting");
    if (!t)
      return;
    this._listElement.innerHTML = "", this._itemElements = [];
    const e = this.get("items", []), s = t.supportedFormats(), i = t.supportedExportTypes();
    S(this._itemDisposers, (n) => {
      n.dispose();
    }), this._itemDisposers.length = 0, S(e, (n) => {
      if (n.format && s.indexOf(n.format) == -1 || n.exportType && i.indexOf(n.exportType) == -1)
        return;
      const o = document.createElement("li");
      o.setAttribute("role", "menuitem"), o.className = "am5exporting am5exporting-item am5exporting-type-" + n.type, n.format && (o.className += " am5exporting-format-" + n.format);
      const a = document.createElement("a");
      let p = this._t("Export ");
      n.label && (a.innerHTML = n.label, p += " " + n.label), n.sublabel && (a.innerHTML += ' <span class="am5exporting-label-alt">' + n.sublabel + "</span>", p += " (" + n.sublabel + ")"), n.callback ? (this._itemDisposers.push(w(a, "click", (l) => {
        n.callback.call(n.callbackTarget || this);
      })), a.setAttribute("tabindex", this._root.tabindex.toString())) : n.format && t && (this._itemDisposers.push(w(a, "click", (l) => {
        this._handleClick(n);
      })), this._itemDisposers.push(w(a, "focus", (l) => {
        this._handleItemFocus(n);
      })), this._itemDisposers.push(w(a, "blur", (l) => {
        this._handleItemBlur(n);
      })), a.setAttribute("tabindex", this._root.tabindex.toString()), a.setAttribute("aria-label", p)), n.element = a, o.appendChild(a), this._listElement.appendChild(o), this._itemElements.push(o);
    });
  }
  _handleClick(t) {
    const e = this.get("exporting");
    this.get("autoClose") && this.close(), t.format == "print" ? e.print() : e.download(t.format);
  }
  _handleItemFocus(t) {
    t != this._activeItem && (this._activeItem && (this._activeItem.element.className = ""), this._activeItem = t, t.element.className = "am5exporting-item-active", t.element.focus());
  }
  _handleItemBlur(t) {
    t.element.className = "", t == this._activeItem && (this._activeItem = void 0), this.setTimeout(() => {
      (!document.activeElement || !$(this.get("container"), document.activeElement)) && this.close();
    }, 10);
  }
  /**
   * Loads the default CSS.
   *
   * @ignore Exclude from docs
   */
  loadDefaultCSS() {
    const t = it(I(this._root.dom), this._root);
    this._disposers.push(t), this._cssDisposer = t;
  }
  /**
   * Opens menu.
   */
  open() {
    this.setTimeout(() => {
      this.isOpen = !0, this.get("deactivateRoot") && (this._root._renderer.interactionsEnabled = !1), this._applyClassNames(), this.events.dispatch("menuopened", {
        type: "menuopened",
        target: this
      });
    }, 1);
  }
  /**
   * Closes menu.
   */
  close() {
    this.isOpen = !1, this.get("deactivateRoot") && (this._root._renderer.interactionsEnabled = !0), Y(), this._applyClassNames(), this.events.dispatch("menuclosed", {
      type: "menuclosed",
      target: this
    });
  }
  /**
   * Toggles menu open and close.
   */
  toggle() {
    this.isOpen ? this.close() : this.open();
  }
}
M.className = "ExportingMenu";
M.classNames = F.classNames.concat([M.className]);
class B extends F {
  constructor() {
    super(...arguments), this._skipRender = !1;
  }
  //public extraImages: Array<Root | IAnnotatorImageSource> = [];
  //public dataSources: any[] = [];
  _afterNew() {
    super._afterNew(), this._setRawDefault("layer", 1e3), this._root.addDisposer(this);
  }
  _beforeChanged() {
    super._beforeChanged(), this.isDirty("markerState") && this._renderState();
  }
  /**
   * Triggers annotation mode on the chart. This will display UI toolbars and
   * disable all interactions on the chart itself.
   */
  open() {
    return f(this, void 0, void 0, function* () {
      this.setTimeout(() => {
        this._root._renderer.interactionsEnabled = !1;
      }, 100);
      const t = yield this.getMarkerArea();
      t.show(), this._picture.hide(0), this.get("markerState") && t.restoreState(this.get("markerState"));
    });
  }
  _renderState() {
    return f(this, void 0, void 0, function* () {
      const t = yield this.getMarkerArea();
      this.get("markerState") && (this._skipRender = !0, t.renderState(this.get("markerState")));
    });
  }
  /**
   * Exists from annotation mode. All annotations remain visible on the chart.
   */
  close() {
    return f(this, void 0, void 0, function* () {
      (yield this.getMarkerArea()).close(), this._markerArea = void 0;
    });
  }
  /**
   * Exits from annotation mode. Any changes made during last session of the
   * annotation editing are cancelled.
   */
  cancel() {
    return f(this, void 0, void 0, function* () {
      this._root._renderer.interactionsEnabled = !0;
      const t = yield this.getMarkerArea();
      this._picture.show(0), t.close(), this._markerArea = void 0;
    });
  }
  /**
   * All annotations are removed.
   */
  clear() {
    this.set("markerState", void 0), this._picture && this._picture.set("src", "");
  }
  toggle() {
    return f(this, void 0, void 0, function* () {
      (yield this.getMarkerArea()).isOpen ? this.close() : this.open();
    });
  }
  _dispose() {
    super._dispose(), this._markerArea && this._markerArea.isOpen && this._markerArea.close();
  }
  _maybeInit() {
    return f(this, void 0, void 0, function* () {
      if (this._container || (this._container = this._root.container.children.push(Z.new(this._root, {
        width: T,
        height: T,
        layer: this.get("layer"),
        interactiveChildren: !1
      })), this._picture = this._container.children.push(tt.new(this._root, {
        width: T,
        height: T
      }))), !this._markerArea) {
        const t = yield this._getMarkerJS(), e = this._container._display.getCanvas(), s = new t.MarkerArea(e);
        s.uiStyleSettings.logoPosition = "right", s.uiStyleSettings.zIndex = 20, s.targetRoot = e.parentElement;
        const i = this.get("markerSettings", {});
        O(i, (o, a) => {
          s.settings[o] = a;
        });
        const n = this.get("markerStyleSettings", {});
        O(n, (o, a) => {
          s.uiStyleSettings[o] = a;
        }), this._disposers.push(w(s, "close", () => {
          this._root._renderer.interactionsEnabled = !0, this._picture.show(0), this._markerArea = void 0;
        })), this._disposers.push(w(s, "render", (o) => {
          this._picture.set("src", o.dataUrl), this._skipRender || this.set("markerState", o.state), this._skipRender = !1;
        })), this._markerArea = s;
      }
    });
  }
  /**
   * @ignore
   */
  _getMarkerJS() {
    return f(this, void 0, void 0, function* () {
      return yield import(
        /* webpackChunkName: "markerjs2" */
        "./markerjs2.esm.B_9kjmye.js"
      );
    });
  }
  /**
   * An instance of MarkerJS's [[MarkerArea]].
   *
   * @see {@link https://markerjs.com/docs/getting-started} for more info
   * @return MarkerArea
   */
  getMarkerArea() {
    return f(this, void 0, void 0, function* () {
      return yield this._maybeInit(), this._markerArea;
    });
  }
}
B.className = "Annotator";
B.classNames = F.classNames.concat([B.className]);
export {
  B as Annotator,
  P as Exporting,
  M as ExportingMenu
};
