var Ts = Object.defineProperty;
var Os = (e, A, r) => A in e ? Ts(e, A, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[A] = r;
var pA = (e, A, r) => (Os(e, typeof A != "symbol" ? A + "" : A, r), r);
import { ViewMode as dn, UIActionHandler as Ms, PluginStaticResource as Gs } from "@ibiz-template/runtime";
import { useWFStepTraceViewController as Rs, usePropsWatch as pn, useNamespace as DA, useViewController as En, useEditView3Controller as Vs, getUploadProps as Ns, getEditorEmits as Ps, getGridUploadProps as at, getGridEditorEmits as Hn, useClickOutside as _s, useEventListener as Xs } from "@ibiz-template/vue-util";
import { defineComponent as hA, getCurrentInstance as ir, ref as R, h as T, watch as CA, toRefs as ot } from "vue";
import { ViewType as ks } from "@ibiz-template/model";
import { createUUID as Ut, getCookie as Js } from "qx-util";
import { WFDynaEditView3Controller as Ws, WFStepTraceViewController as Ys, UploadEditorController as vn } from "@ibiz-template/controller";
import { HttpError as In, isImage as Zs, uploadFile as qs, RuntimeError as zs } from "@ibiz-template/core";
const mn = hA({
  name: "WFStepTraceGrid",
  props: {
    context: Object,
    params: {
      type: Object
    },
    modelPath: {
      type: String,
      required: !0
    },
    modal: {
      type: Object
    },
    deName: {
      type: String,
      required: !0
    }
  },
  setup(e) {
    const {
      proxy: A
    } = ir(), r = Rs(A, e.modelPath);
    pn(A, "deName", r.setDeName.bind(r));
    const t = DA("wf-step-trace-grid"), n = R([]), s = (i, a, o = !1) => {
      i.comments.length > 0 && i.comments.forEach((c) => {
        o && c.type === "启动流程" || a.push({
          id: Ut(),
          nodeName: i.userTaskName,
          personName: c.authorName,
          time: c.time,
          content: c.type,
          comment: c.fullMessage
        });
      });
    };
    r.nerve.self.evt.on("mounted", () => {
      var i;
      r.data && ((i = r.data.usertasks) == null || i.forEach((a) => {
        if (a.usertasks && a.usertasks.length > 0) {
          if (a.usertasks.length === 1)
            return;
          const o = [];
          a.usertasks.forEach((c) => {
            s(c, o, !0);
          }), n.value.push({
            id: Ut(),
            nodeName: `${a.userTaskName}`,
            personName: "",
            time: "",
            content: "",
            comment: "",
            children: o,
            _showChildren: !0
          });
        } else
          s(a, n.value);
      }), n.value.sort((a, o) => Date.parse(a.time) - Date.parse(o.time)));
    });
    const B = R([{
      title: "处理环节",
      key: "nodeName",
      width: 250,
      resizable: !0,
      tree: !0,
      className: "clhj"
    }, {
      title: "处理人",
      key: "personName",
      width: 150,
      resizable: !0
    }, {
      title: "处理时间",
      key: "time",
      width: 180,
      resizable: !0
    }, {
      title: "处理内容",
      key: "content",
      width: 150,
      resizable: !0
    }, {
      title: "处理意见",
      key: "comment"
    }]);
    return {
      c: r,
      ns: t,
      gridData: n,
      columns: B
    };
  },
  render() {
    return T("div", {
      class: this.ns.b()
    }, [T("div", {
      class: this.ns.e("title")
    }, [T("span", {
      class: this.ns.e("caption")
    }, ["审批信息"])]), T("i-table", {
      attrs: {
        "disabled-hover": !0,
        columns: this.columns,
        data: this.gridData,
        "row-key": "id"
      },
      class: this.ns.e("grid")
    })]);
  }
});
class js extends Ws {
  async calcWfToolbar() {
    await super.calcWfToolbar(), this.isEditable && this.wfLinks.unshift({
      sequenceFlowName: "保存",
      type: "FORM_SAVE"
    });
  }
  async onLinkClick(A) {
    A.type === "FORM_SAVE" ? await this.save() : super.onLinkClick(A);
  }
}
const $s = hA({
  props: {
    context: Object,
    params: {
      type: Object
    },
    modelPath: {
      type: String,
      required: !0
    },
    modal: {
      type: Object
    }
  },
  setup(e) {
    const {
      proxy: A
    } = ir(), r = En(A, (B, i) => new js(e.modelPath, B, i)), t = DA(`view-${ks.DE_WF_DYNA_EDIT_VIEW3}`.toLowerCase()), n = R(["mainForm"]);
    return {
      c: r,
      ns: t,
      onTabClick: (B) => {
        n.value.includes(B) || n.value.push(B);
      },
      lazyList: n
    };
  },
  render(e) {
    const A = [];
    if (this.c.complete) {
      const {
        activeForm: r
      } = this.c;
      r && this.c.providers[r.name] && A.push(e(this.c.providers[r.name].component, {
        props: {
          modelData: r,
          context: this.c.context,
          params: this.c.params
        },
        style: {
          height: "auto"
        },
        on: {
          neuronInit: this.c.nerve.onNeuronInit("form")
        }
      }));
    }
    if (this.c.complete && this.c.model.drTab.pages[0]) {
      const r = this.c.model.drTab.pages[0], t = this.c.drPages[r.source.name];
      A.push(e(mn, {
        attrs: {
          context: t.context,
          params: t.params,
          deName: this.c.model.appEntity.source.codeName,
          modal: this.modal,
          modelPath: r.embedView.source.modelPath
        }
      }));
    }
    return e("view-base", {
      attrs: {
        controller: this.c
      },
      scopedSlots: {
        toolbar: () => this.c.complete ? [this.c.wfLinks.length > 0 && e("wf-toolbar", {
          attrs: {
            wfLinks: this.c.wfLinks
          },
          on: {
            "wf-link-click": (r) => {
              this.c.onLinkClick(r);
            }
          }
        })] : null
      }
    }, [this.c.complete && e("i-tabs", {
      class: [this.ns.be("", "tab")],
      attrs: {
        name: this.c.model.drTab.source.name
      },
      on: {
        "on-click": this.onTabClick
      }
    }, [e("i-tab-pane", {
      class: this.ns.be("", "tab-item"),
      attrs: {
        tab: this.c.model.drTab.source.name,
        label: this.c.model.drTab.source.editItemCaption,
        name: "mainForm"
      }
    }, [A]), this.c.model.drTab.pages.map((r) => {
      const t = this.c.drPages[r.source.name];
      return e("i-tab-pane", {
        class: this.ns.be("", "tab-item"),
        attrs: {
          tab: this.c.model.drTab.source.name,
          disabled: this.c.isNewData,
          label: r.source.caption,
          name: r.source.name
        }
      }, [!this.c.isNewData && this.lazyList.includes(r.source.name) && e("ViewShell", {
        attrs: {
          context: t.context,
          params: t.params,
          modal: {
            mode: dn.EMBED
          },
          modelPath: r.embedView.source.modelPath,
          // 流程跟踪视图用
          deName: this.c.model.appEntity.source.codeName
        },
        on: {
          neuronInit: this.c.nerve.onNeuronInit(r.source.name)
        },
        key: t.key
      })]);
    })])]);
  }
});
class AB {
  constructor() {
    pA(this, "component", $s);
  }
}
const eB = hA({
  name: "SyEditView3",
  props: {
    context: Object,
    params: {
      type: Object
    },
    modelPath: {
      type: String,
      required: !0
    },
    modal: {
      type: Object
    }
  },
  setup(e) {
    const {
      proxy: A
    } = ir(), r = Vs(A, e.modelPath), t = DA("view-deeditview3"), n = R(["mainForm"]);
    return {
      c: r,
      ns: t,
      onTabClick: (B) => {
        n.value.includes(B) || n.value.push(B);
      },
      lazyList: n
    };
  },
  render(e) {
    return e("view-base", {
      attrs: {
        controller: this.c
      }
    }, [this.c.complete && e("i-tabs", {
      class: [this.ns.be("", "tab")],
      attrs: {
        name: this.c.model.drTab.source.name
      },
      on: {
        "on-click": this.onTabClick
      }
    }, [e("i-tab-pane", {
      class: this.ns.be("", "tab-item"),
      attrs: {
        tab: this.c.model.drTab.source.name,
        label: this.c.model.drTab.source.editItemCaption,
        name: "mainForm"
      }
    }, [e("edit-form-control", {
      attrs: {
        modelData: this.c.model.form,
        context: this.c.context,
        params: this.c.params
      },
      style: {
        height: "auto"
      },
      on: {
        neuronInit: this.c.nerve.onNeuronInit(this.c.model.form.source.name)
      }
    }), e(mn, {
      attrs: {
        context: this.c.drPages[this.c.model.drTab.pages[0].source.name].context,
        params: this.c.drPages[this.c.model.drTab.pages[0].source.name].params,
        deName: this.c.model.appEntity.source.codeName,
        modal: this.modal,
        modelPath: this.c.model.drTab.pages[0].embedView.source.modelPath
      }
    })]), this.c.model.drTab.pages.map((A) => {
      const r = this.c.drPages[A.source.name];
      if (r)
        return e("i-tab-pane", {
          class: this.ns.be("", "tab-item"),
          attrs: {
            tab: this.c.model.drTab.source.name,
            disabled: this.c.isNewData,
            label: A.source.caption,
            name: A.source.name
          }
        }, [!this.c.isNewData && this.lazyList.includes(A.source.name) && e("ViewShell", {
          attrs: {
            context: r.context,
            params: r.params,
            modal: {
              mode: dn.EMBED
            },
            modelPath: A.embedView.source.modelPath,
            // 流程跟踪视图用
            deName: this.c.model.appEntity.source.codeName
          },
          on: {
            neuronInit: this.c.nerve.onNeuronInit(A.source.name)
          },
          key: r.key
        })]);
    })])]);
  }
});
class rB {
  constructor() {
    pA(this, "component", eB);
  }
}
/*!
 * html2canvas 1.4.1 <https://html2canvas.hertzen.com>
 * Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
 * Released under MIT License
 */
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var Rr = function(e, A) {
  return Rr = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(r, t) {
    r.__proto__ = t;
  } || function(r, t) {
    for (var n in t)
      Object.prototype.hasOwnProperty.call(t, n) && (r[n] = t[n]);
  }, Rr(e, A);
};
function iA(e, A) {
  if (typeof A != "function" && A !== null)
    throw new TypeError("Class extends value " + String(A) + " is not a constructor or null");
  Rr(e, A);
  function r() {
    this.constructor = e;
  }
  e.prototype = A === null ? Object.create(A) : (r.prototype = A.prototype, new r());
}
var Vr = function() {
  return Vr = Object.assign || function(A) {
    for (var r, t = 1, n = arguments.length; t < n; t++) {
      r = arguments[t];
      for (var s in r)
        Object.prototype.hasOwnProperty.call(r, s) && (A[s] = r[s]);
    }
    return A;
  }, Vr.apply(this, arguments);
};
function z(e, A, r, t) {
  function n(s) {
    return s instanceof r ? s : new r(function(B) {
      B(s);
    });
  }
  return new (r || (r = Promise))(function(s, B) {
    function i(c) {
      try {
        o(t.next(c));
      } catch (l) {
        B(l);
      }
    }
    function a(c) {
      try {
        o(t.throw(c));
      } catch (l) {
        B(l);
      }
    }
    function o(c) {
      c.done ? s(c.value) : n(c.value).then(i, a);
    }
    o((t = t.apply(e, A || [])).next());
  });
}
function Y(e, A) {
  var r = { label: 0, sent: function() {
    if (s[0] & 1)
      throw s[1];
    return s[1];
  }, trys: [], ops: [] }, t, n, s, B;
  return B = { next: i(0), throw: i(1), return: i(2) }, typeof Symbol == "function" && (B[Symbol.iterator] = function() {
    return this;
  }), B;
  function i(o) {
    return function(c) {
      return a([o, c]);
    };
  }
  function a(o) {
    if (t)
      throw new TypeError("Generator is already executing.");
    for (; r; )
      try {
        if (t = 1, n && (s = o[0] & 2 ? n.return : o[0] ? n.throw || ((s = n.return) && s.call(n), 0) : n.next) && !(s = s.call(n, o[1])).done)
          return s;
        switch (n = 0, s && (o = [o[0] & 2, s.value]), o[0]) {
          case 0:
          case 1:
            s = o;
            break;
          case 4:
            return r.label++, { value: o[1], done: !1 };
          case 5:
            r.label++, n = o[1], o = [0];
            continue;
          case 7:
            o = r.ops.pop(), r.trys.pop();
            continue;
          default:
            if (s = r.trys, !(s = s.length > 0 && s[s.length - 1]) && (o[0] === 6 || o[0] === 2)) {
              r = 0;
              continue;
            }
            if (o[0] === 3 && (!s || o[1] > s[0] && o[1] < s[3])) {
              r.label = o[1];
              break;
            }
            if (o[0] === 6 && r.label < s[1]) {
              r.label = s[1], s = o;
              break;
            }
            if (s && r.label < s[2]) {
              r.label = s[2], r.ops.push(o);
              break;
            }
            s[2] && r.ops.pop(), r.trys.pop();
            continue;
        }
        o = A.call(e, r);
      } catch (c) {
        o = [6, c], n = 0;
      } finally {
        t = s = 0;
      }
    if (o[0] & 5)
      throw o[1];
    return { value: o[0] ? o[1] : void 0, done: !0 };
  }
}
function Ee(e, A, r) {
  if (r || arguments.length === 2)
    for (var t = 0, n = A.length, s; t < n; t++)
      (s || !(t in A)) && (s || (s = Array.prototype.slice.call(A, 0, t)), s[t] = A[t]);
  return e.concat(s || A);
}
var FA = (
  /** @class */
  function() {
    function e(A, r, t, n) {
      this.left = A, this.top = r, this.width = t, this.height = n;
    }
    return e.prototype.add = function(A, r, t, n) {
      return new e(this.left + A, this.top + r, this.width + t, this.height + n);
    }, e.fromClientRect = function(A, r) {
      return new e(r.left + A.windowBounds.left, r.top + A.windowBounds.top, r.width, r.height);
    }, e.fromDOMRectList = function(A, r) {
      var t = Array.from(r).find(function(n) {
        return n.width !== 0;
      });
      return t ? new e(t.left + A.windowBounds.left, t.top + A.windowBounds.top, t.width, t.height) : e.EMPTY;
    }, e.EMPTY = new e(0, 0, 0, 0), e;
  }()
), ar = function(e, A) {
  return FA.fromClientRect(e, A.getBoundingClientRect());
}, tB = function(e) {
  var A = e.body, r = e.documentElement;
  if (!A || !r)
    throw new Error("Unable to get document size");
  var t = Math.max(Math.max(A.scrollWidth, r.scrollWidth), Math.max(A.offsetWidth, r.offsetWidth), Math.max(A.clientWidth, r.clientWidth)), n = Math.max(Math.max(A.scrollHeight, r.scrollHeight), Math.max(A.offsetHeight, r.offsetHeight), Math.max(A.clientHeight, r.clientHeight));
  return new FA(0, 0, t, n);
}, or = function(e) {
  for (var A = [], r = 0, t = e.length; r < t; ) {
    var n = e.charCodeAt(r++);
    if (n >= 55296 && n <= 56319 && r < t) {
      var s = e.charCodeAt(r++);
      (s & 64512) === 56320 ? A.push(((n & 1023) << 10) + (s & 1023) + 65536) : (A.push(n), r--);
    } else
      A.push(n);
  }
  return A;
}, N = function() {
  for (var e = [], A = 0; A < arguments.length; A++)
    e[A] = arguments[A];
  if (String.fromCodePoint)
    return String.fromCodePoint.apply(String, e);
  var r = e.length;
  if (!r)
    return "";
  for (var t = [], n = -1, s = ""; ++n < r; ) {
    var B = e[n];
    B <= 65535 ? t.push(B) : (B -= 65536, t.push((B >> 10) + 55296, B % 1024 + 56320)), (n + 1 === r || t.length > 16384) && (s += String.fromCharCode.apply(String, t), t.length = 0);
  }
  return s;
}, Ft = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", nB = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
for (var He = 0; He < Ft.length; He++)
  nB[Ft.charCodeAt(He)] = He;
var ht = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", se = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
for (var ve = 0; ve < ht.length; ve++)
  se[ht.charCodeAt(ve)] = ve;
var sB = function(e) {
  var A = e.length * 0.75, r = e.length, t, n = 0, s, B, i, a;
  e[e.length - 1] === "=" && (A--, e[e.length - 2] === "=" && A--);
  var o = typeof ArrayBuffer < "u" && typeof Uint8Array < "u" && typeof Uint8Array.prototype.slice < "u" ? new ArrayBuffer(A) : new Array(A), c = Array.isArray(o) ? o : new Uint8Array(o);
  for (t = 0; t < r; t += 4)
    s = se[e.charCodeAt(t)], B = se[e.charCodeAt(t + 1)], i = se[e.charCodeAt(t + 2)], a = se[e.charCodeAt(t + 3)], c[n++] = s << 2 | B >> 4, c[n++] = (B & 15) << 4 | i >> 2, c[n++] = (i & 3) << 6 | a & 63;
  return o;
}, BB = function(e) {
  for (var A = e.length, r = [], t = 0; t < A; t += 2)
    r.push(e[t + 1] << 8 | e[t]);
  return r;
}, iB = function(e) {
  for (var A = e.length, r = [], t = 0; t < A; t += 4)
    r.push(e[t + 3] << 24 | e[t + 2] << 16 | e[t + 1] << 8 | e[t]);
  return r;
}, RA = 5, ct = 6 + 5, Ur = 2, aB = ct - RA, yn = 65536 >> RA, oB = 1 << RA, Fr = oB - 1, cB = 1024 >> RA, lB = yn + cB, QB = lB, gB = 32, wB = QB + gB, uB = 65536 >> ct, fB = 1 << aB, CB = fB - 1, dt = function(e, A, r) {
  return e.slice ? e.slice(A, r) : new Uint16Array(Array.prototype.slice.call(e, A, r));
}, UB = function(e, A, r) {
  return e.slice ? e.slice(A, r) : new Uint32Array(Array.prototype.slice.call(e, A, r));
}, FB = function(e, A) {
  var r = sB(e), t = Array.isArray(r) ? iB(r) : new Uint32Array(r), n = Array.isArray(r) ? BB(r) : new Uint16Array(r), s = 24, B = dt(n, s / 2, t[4] / 2), i = t[5] === 2 ? dt(n, (s + t[4]) / 2) : UB(t, Math.ceil((s + t[4]) / 4));
  return new hB(t[0], t[1], t[2], t[3], B, i);
}, hB = (
  /** @class */
  function() {
    function e(A, r, t, n, s, B) {
      this.initialValue = A, this.errorValue = r, this.highStart = t, this.highValueIndex = n, this.index = s, this.data = B;
    }
    return e.prototype.get = function(A) {
      var r;
      if (A >= 0) {
        if (A < 55296 || A > 56319 && A <= 65535)
          return r = this.index[A >> RA], r = (r << Ur) + (A & Fr), this.data[r];
        if (A <= 65535)
          return r = this.index[yn + (A - 55296 >> RA)], r = (r << Ur) + (A & Fr), this.data[r];
        if (A < this.highStart)
          return r = wB - uB + (A >> ct), r = this.index[r], r += A >> RA & CB, r = this.index[r], r = (r << Ur) + (A & Fr), this.data[r];
        if (A <= 1114111)
          return this.data[this.highValueIndex];
      }
      return this.errorValue;
    }, e;
  }()
), pt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", dB = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
for (var Ie = 0; Ie < pt.length; Ie++)
  dB[pt.charCodeAt(Ie)] = Ie;
var pB = " ", Et = 50, EB = 1, Kn = 2, Ln = 3, HB = 4, vB = 5, Ht = 7, bn = 8, vt = 9, IA = 10, Nr = 11, It = 12, Pr = 13, IB = 14, Be = 15, _r = 16, me = 17, ee = 18, mB = 19, mt = 20, Xr = 21, re = 22, hr = 23, PA = 24, AA = 25, ie = 26, ae = 27, _A = 28, yB = 29, MA = 30, KB = 31, ye = 32, Ke = 33, kr = 34, Jr = 35, Wr = 36, Ue = 37, Yr = 38, Je = 39, We = 40, dr = 41, Dn = 42, LB = 43, bB = [9001, 65288], xn = "!", b = "×", Le = "÷", Zr = FB(pB), uA = [MA, Wr], qr = [EB, Kn, Ln, vB], Sn = [IA, bn], yt = [ae, ie], DB = qr.concat(Sn), Kt = [Yr, Je, We, kr, Jr], xB = [Be, Pr], SB = function(e, A) {
  A === void 0 && (A = "strict");
  var r = [], t = [], n = [];
  return e.forEach(function(s, B) {
    var i = Zr.get(s);
    if (i > Et ? (n.push(!0), i -= Et) : n.push(!1), ["normal", "auto", "loose"].indexOf(A) !== -1 && [8208, 8211, 12316, 12448].indexOf(s) !== -1)
      return t.push(B), r.push(_r);
    if (i === HB || i === Nr) {
      if (B === 0)
        return t.push(B), r.push(MA);
      var a = r[B - 1];
      return DB.indexOf(a) === -1 ? (t.push(t[B - 1]), r.push(a)) : (t.push(B), r.push(MA));
    }
    if (t.push(B), i === KB)
      return r.push(A === "strict" ? Xr : Ue);
    if (i === Dn || i === yB)
      return r.push(MA);
    if (i === LB)
      return s >= 131072 && s <= 196605 || s >= 196608 && s <= 262141 ? r.push(Ue) : r.push(MA);
    r.push(i);
  }), [t, r, n];
}, pr = function(e, A, r, t) {
  var n = t[r];
  if (Array.isArray(e) ? e.indexOf(n) !== -1 : e === n)
    for (var s = r; s <= t.length; ) {
      s++;
      var B = t[s];
      if (B === A)
        return !0;
      if (B !== IA)
        break;
    }
  if (n === IA)
    for (var s = r; s > 0; ) {
      s--;
      var i = t[s];
      if (Array.isArray(e) ? e.indexOf(i) !== -1 : e === i)
        for (var a = r; a <= t.length; ) {
          a++;
          var B = t[a];
          if (B === A)
            return !0;
          if (B !== IA)
            break;
        }
      if (i !== IA)
        break;
    }
  return !1;
}, Lt = function(e, A) {
  for (var r = e; r >= 0; ) {
    var t = A[r];
    if (t === IA)
      r--;
    else
      return t;
  }
  return 0;
}, TB = function(e, A, r, t, n) {
  if (r[t] === 0)
    return b;
  var s = t - 1;
  if (Array.isArray(n) && n[s] === !0)
    return b;
  var B = s - 1, i = s + 1, a = A[s], o = B >= 0 ? A[B] : 0, c = A[i];
  if (a === Kn && c === Ln)
    return b;
  if (qr.indexOf(a) !== -1)
    return xn;
  if (qr.indexOf(c) !== -1 || Sn.indexOf(c) !== -1)
    return b;
  if (Lt(s, A) === bn)
    return Le;
  if (Zr.get(e[s]) === Nr || (a === ye || a === Ke) && Zr.get(e[i]) === Nr || a === Ht || c === Ht || a === vt || [IA, Pr, Be].indexOf(a) === -1 && c === vt || [me, ee, mB, PA, _A].indexOf(c) !== -1 || Lt(s, A) === re || pr(hr, re, s, A) || pr([me, ee], Xr, s, A) || pr(It, It, s, A))
    return b;
  if (a === IA)
    return Le;
  if (a === hr || c === hr)
    return b;
  if (c === _r || a === _r)
    return Le;
  if ([Pr, Be, Xr].indexOf(c) !== -1 || a === IB || o === Wr && xB.indexOf(a) !== -1 || a === _A && c === Wr || c === mt || uA.indexOf(c) !== -1 && a === AA || uA.indexOf(a) !== -1 && c === AA || a === ae && [Ue, ye, Ke].indexOf(c) !== -1 || [Ue, ye, Ke].indexOf(a) !== -1 && c === ie || uA.indexOf(a) !== -1 && yt.indexOf(c) !== -1 || yt.indexOf(a) !== -1 && uA.indexOf(c) !== -1 || // (PR | PO) × ( OP | HY )? NU
  [ae, ie].indexOf(a) !== -1 && (c === AA || [re, Be].indexOf(c) !== -1 && A[i + 1] === AA) || // ( OP | HY ) × NU
  [re, Be].indexOf(a) !== -1 && c === AA || // NU ×	(NU | SY | IS)
  a === AA && [AA, _A, PA].indexOf(c) !== -1)
    return b;
  if ([AA, _A, PA, me, ee].indexOf(c) !== -1)
    for (var l = s; l >= 0; ) {
      var Q = A[l];
      if (Q === AA)
        return b;
      if ([_A, PA].indexOf(Q) !== -1)
        l--;
      else
        break;
    }
  if ([ae, ie].indexOf(c) !== -1)
    for (var l = [me, ee].indexOf(a) !== -1 ? B : s; l >= 0; ) {
      var Q = A[l];
      if (Q === AA)
        return b;
      if ([_A, PA].indexOf(Q) !== -1)
        l--;
      else
        break;
    }
  if (Yr === a && [Yr, Je, kr, Jr].indexOf(c) !== -1 || [Je, kr].indexOf(a) !== -1 && [Je, We].indexOf(c) !== -1 || [We, Jr].indexOf(a) !== -1 && c === We || Kt.indexOf(a) !== -1 && [mt, ie].indexOf(c) !== -1 || Kt.indexOf(c) !== -1 && a === ae || uA.indexOf(a) !== -1 && uA.indexOf(c) !== -1 || a === PA && uA.indexOf(c) !== -1 || uA.concat(AA).indexOf(a) !== -1 && c === re && bB.indexOf(e[i]) === -1 || uA.concat(AA).indexOf(c) !== -1 && a === ee)
    return b;
  if (a === dr && c === dr) {
    for (var f = r[s], g = 1; f > 0 && (f--, A[f] === dr); )
      g++;
    if (g % 2 !== 0)
      return b;
  }
  return a === ye && c === Ke ? b : Le;
}, OB = function(e, A) {
  A || (A = { lineBreak: "normal", wordBreak: "normal" });
  var r = SB(e, A.lineBreak), t = r[0], n = r[1], s = r[2];
  (A.wordBreak === "break-all" || A.wordBreak === "break-word") && (n = n.map(function(i) {
    return [AA, MA, Dn].indexOf(i) !== -1 ? Ue : i;
  }));
  var B = A.wordBreak === "keep-all" ? s.map(function(i, a) {
    return i && e[a] >= 19968 && e[a] <= 40959;
  }) : void 0;
  return [t, n, B];
}, MB = (
  /** @class */
  function() {
    function e(A, r, t, n) {
      this.codePoints = A, this.required = r === xn, this.start = t, this.end = n;
    }
    return e.prototype.slice = function() {
      return N.apply(void 0, this.codePoints.slice(this.start, this.end));
    }, e;
  }()
), GB = function(e, A) {
  var r = or(e), t = OB(r, A), n = t[0], s = t[1], B = t[2], i = r.length, a = 0, o = 0;
  return {
    next: function() {
      if (o >= i)
        return { done: !0, value: null };
      for (var c = b; o < i && (c = TB(r, s, n, ++o, B)) === b; )
        ;
      if (c !== b || o === i) {
        var l = new MB(r, c, a, o);
        return a = o, { value: l, done: !1 };
      }
      return { done: !0, value: null };
    }
  };
}, RB = 1 << 0, VB = 1 << 1, de = 1 << 2, bt = 1 << 3, qe = 10, Dt = 47, ge = 92, NB = 9, PB = 32, be = 34, te = 61, _B = 35, XB = 36, kB = 37, De = 39, xe = 40, ne = 41, JB = 95, $ = 45, WB = 33, YB = 60, ZB = 62, qB = 64, zB = 91, jB = 93, $B = 61, Ai = 123, Se = 63, ei = 125, xt = 124, ri = 126, ti = 128, St = 65533, Er = 42, GA = 43, ni = 44, si = 58, Bi = 59, Fe = 46, ii = 0, ai = 8, oi = 11, ci = 14, li = 31, Qi = 127, oA = -1, Tn = 48, On = 97, Mn = 101, gi = 102, wi = 117, ui = 122, Gn = 65, Rn = 69, Vn = 70, fi = 85, Ci = 90, Z = function(e) {
  return e >= Tn && e <= 57;
}, Ui = function(e) {
  return e >= 55296 && e <= 57343;
}, XA = function(e) {
  return Z(e) || e >= Gn && e <= Vn || e >= On && e <= gi;
}, Fi = function(e) {
  return e >= On && e <= ui;
}, hi = function(e) {
  return e >= Gn && e <= Ci;
}, di = function(e) {
  return Fi(e) || hi(e);
}, pi = function(e) {
  return e >= ti;
}, Te = function(e) {
  return e === qe || e === NB || e === PB;
}, ze = function(e) {
  return di(e) || pi(e) || e === JB;
}, Tt = function(e) {
  return ze(e) || Z(e) || e === $;
}, Ei = function(e) {
  return e >= ii && e <= ai || e === oi || e >= ci && e <= li || e === Qi;
}, vA = function(e, A) {
  return e !== ge ? !1 : A !== qe;
}, Oe = function(e, A, r) {
  return e === $ ? ze(A) || vA(A, r) : ze(e) ? !0 : !!(e === ge && vA(e, A));
}, Hr = function(e, A, r) {
  return e === GA || e === $ ? Z(A) ? !0 : A === Fe && Z(r) : Z(e === Fe ? A : e);
}, Hi = function(e) {
  var A = 0, r = 1;
  (e[A] === GA || e[A] === $) && (e[A] === $ && (r = -1), A++);
  for (var t = []; Z(e[A]); )
    t.push(e[A++]);
  var n = t.length ? parseInt(N.apply(void 0, t), 10) : 0;
  e[A] === Fe && A++;
  for (var s = []; Z(e[A]); )
    s.push(e[A++]);
  var B = s.length, i = B ? parseInt(N.apply(void 0, s), 10) : 0;
  (e[A] === Rn || e[A] === Mn) && A++;
  var a = 1;
  (e[A] === GA || e[A] === $) && (e[A] === $ && (a = -1), A++);
  for (var o = []; Z(e[A]); )
    o.push(e[A++]);
  var c = o.length ? parseInt(N.apply(void 0, o), 10) : 0;
  return r * (n + i * Math.pow(10, -B)) * Math.pow(10, a * c);
}, vi = {
  type: 2
  /* LEFT_PARENTHESIS_TOKEN */
}, Ii = {
  type: 3
  /* RIGHT_PARENTHESIS_TOKEN */
}, mi = {
  type: 4
  /* COMMA_TOKEN */
}, yi = {
  type: 13
  /* SUFFIX_MATCH_TOKEN */
}, Ki = {
  type: 8
  /* PREFIX_MATCH_TOKEN */
}, Li = {
  type: 21
  /* COLUMN_TOKEN */
}, bi = {
  type: 9
  /* DASH_MATCH_TOKEN */
}, Di = {
  type: 10
  /* INCLUDE_MATCH_TOKEN */
}, xi = {
  type: 11
  /* LEFT_CURLY_BRACKET_TOKEN */
}, Si = {
  type: 12
  /* RIGHT_CURLY_BRACKET_TOKEN */
}, Ti = {
  type: 14
  /* SUBSTRING_MATCH_TOKEN */
}, Me = {
  type: 23
  /* BAD_URL_TOKEN */
}, Oi = {
  type: 1
  /* BAD_STRING_TOKEN */
}, Mi = {
  type: 25
  /* CDO_TOKEN */
}, Gi = {
  type: 24
  /* CDC_TOKEN */
}, Ri = {
  type: 26
  /* COLON_TOKEN */
}, Vi = {
  type: 27
  /* SEMICOLON_TOKEN */
}, Ni = {
  type: 28
  /* LEFT_SQUARE_BRACKET_TOKEN */
}, Pi = {
  type: 29
  /* RIGHT_SQUARE_BRACKET_TOKEN */
}, _i = {
  type: 31
  /* WHITESPACE_TOKEN */
}, zr = {
  type: 32
  /* EOF_TOKEN */
}, Nn = (
  /** @class */
  function() {
    function e() {
      this._value = [];
    }
    return e.prototype.write = function(A) {
      this._value = this._value.concat(or(A));
    }, e.prototype.read = function() {
      for (var A = [], r = this.consumeToken(); r !== zr; )
        A.push(r), r = this.consumeToken();
      return A;
    }, e.prototype.consumeToken = function() {
      var A = this.consumeCodePoint();
      switch (A) {
        case be:
          return this.consumeStringToken(be);
        case _B:
          var r = this.peekCodePoint(0), t = this.peekCodePoint(1), n = this.peekCodePoint(2);
          if (Tt(r) || vA(t, n)) {
            var s = Oe(r, t, n) ? VB : RB, B = this.consumeName();
            return { type: 5, value: B, flags: s };
          }
          break;
        case XB:
          if (this.peekCodePoint(0) === te)
            return this.consumeCodePoint(), yi;
          break;
        case De:
          return this.consumeStringToken(De);
        case xe:
          return vi;
        case ne:
          return Ii;
        case Er:
          if (this.peekCodePoint(0) === te)
            return this.consumeCodePoint(), Ti;
          break;
        case GA:
          if (Hr(A, this.peekCodePoint(0), this.peekCodePoint(1)))
            return this.reconsumeCodePoint(A), this.consumeNumericToken();
          break;
        case ni:
          return mi;
        case $:
          var i = A, a = this.peekCodePoint(0), o = this.peekCodePoint(1);
          if (Hr(i, a, o))
            return this.reconsumeCodePoint(A), this.consumeNumericToken();
          if (Oe(i, a, o))
            return this.reconsumeCodePoint(A), this.consumeIdentLikeToken();
          if (a === $ && o === ZB)
            return this.consumeCodePoint(), this.consumeCodePoint(), Gi;
          break;
        case Fe:
          if (Hr(A, this.peekCodePoint(0), this.peekCodePoint(1)))
            return this.reconsumeCodePoint(A), this.consumeNumericToken();
          break;
        case Dt:
          if (this.peekCodePoint(0) === Er)
            for (this.consumeCodePoint(); ; ) {
              var c = this.consumeCodePoint();
              if (c === Er && (c = this.consumeCodePoint(), c === Dt))
                return this.consumeToken();
              if (c === oA)
                return this.consumeToken();
            }
          break;
        case si:
          return Ri;
        case Bi:
          return Vi;
        case YB:
          if (this.peekCodePoint(0) === WB && this.peekCodePoint(1) === $ && this.peekCodePoint(2) === $)
            return this.consumeCodePoint(), this.consumeCodePoint(), Mi;
          break;
        case qB:
          var l = this.peekCodePoint(0), Q = this.peekCodePoint(1), f = this.peekCodePoint(2);
          if (Oe(l, Q, f)) {
            var B = this.consumeName();
            return { type: 7, value: B };
          }
          break;
        case zB:
          return Ni;
        case ge:
          if (vA(A, this.peekCodePoint(0)))
            return this.reconsumeCodePoint(A), this.consumeIdentLikeToken();
          break;
        case jB:
          return Pi;
        case $B:
          if (this.peekCodePoint(0) === te)
            return this.consumeCodePoint(), Ki;
          break;
        case Ai:
          return xi;
        case ei:
          return Si;
        case wi:
        case fi:
          var g = this.peekCodePoint(0), w = this.peekCodePoint(1);
          return g === GA && (XA(w) || w === Se) && (this.consumeCodePoint(), this.consumeUnicodeRangeToken()), this.reconsumeCodePoint(A), this.consumeIdentLikeToken();
        case xt:
          if (this.peekCodePoint(0) === te)
            return this.consumeCodePoint(), bi;
          if (this.peekCodePoint(0) === xt)
            return this.consumeCodePoint(), Li;
          break;
        case ri:
          if (this.peekCodePoint(0) === te)
            return this.consumeCodePoint(), Di;
          break;
        case oA:
          return zr;
      }
      return Te(A) ? (this.consumeWhiteSpace(), _i) : Z(A) ? (this.reconsumeCodePoint(A), this.consumeNumericToken()) : ze(A) ? (this.reconsumeCodePoint(A), this.consumeIdentLikeToken()) : { type: 6, value: N(A) };
    }, e.prototype.consumeCodePoint = function() {
      var A = this._value.shift();
      return typeof A > "u" ? -1 : A;
    }, e.prototype.reconsumeCodePoint = function(A) {
      this._value.unshift(A);
    }, e.prototype.peekCodePoint = function(A) {
      return A >= this._value.length ? -1 : this._value[A];
    }, e.prototype.consumeUnicodeRangeToken = function() {
      for (var A = [], r = this.consumeCodePoint(); XA(r) && A.length < 6; )
        A.push(r), r = this.consumeCodePoint();
      for (var t = !1; r === Se && A.length < 6; )
        A.push(r), r = this.consumeCodePoint(), t = !0;
      if (t) {
        var n = parseInt(N.apply(void 0, A.map(function(a) {
          return a === Se ? Tn : a;
        })), 16), s = parseInt(N.apply(void 0, A.map(function(a) {
          return a === Se ? Vn : a;
        })), 16);
        return { type: 30, start: n, end: s };
      }
      var B = parseInt(N.apply(void 0, A), 16);
      if (this.peekCodePoint(0) === $ && XA(this.peekCodePoint(1))) {
        this.consumeCodePoint(), r = this.consumeCodePoint();
        for (var i = []; XA(r) && i.length < 6; )
          i.push(r), r = this.consumeCodePoint();
        var s = parseInt(N.apply(void 0, i), 16);
        return { type: 30, start: B, end: s };
      } else
        return { type: 30, start: B, end: B };
    }, e.prototype.consumeIdentLikeToken = function() {
      var A = this.consumeName();
      return A.toLowerCase() === "url" && this.peekCodePoint(0) === xe ? (this.consumeCodePoint(), this.consumeUrlToken()) : this.peekCodePoint(0) === xe ? (this.consumeCodePoint(), { type: 19, value: A }) : { type: 20, value: A };
    }, e.prototype.consumeUrlToken = function() {
      var A = [];
      if (this.consumeWhiteSpace(), this.peekCodePoint(0) === oA)
        return { type: 22, value: "" };
      var r = this.peekCodePoint(0);
      if (r === De || r === be) {
        var t = this.consumeStringToken(this.consumeCodePoint());
        return t.type === 0 && (this.consumeWhiteSpace(), this.peekCodePoint(0) === oA || this.peekCodePoint(0) === ne) ? (this.consumeCodePoint(), { type: 22, value: t.value }) : (this.consumeBadUrlRemnants(), Me);
      }
      for (; ; ) {
        var n = this.consumeCodePoint();
        if (n === oA || n === ne)
          return { type: 22, value: N.apply(void 0, A) };
        if (Te(n))
          return this.consumeWhiteSpace(), this.peekCodePoint(0) === oA || this.peekCodePoint(0) === ne ? (this.consumeCodePoint(), { type: 22, value: N.apply(void 0, A) }) : (this.consumeBadUrlRemnants(), Me);
        if (n === be || n === De || n === xe || Ei(n))
          return this.consumeBadUrlRemnants(), Me;
        if (n === ge)
          if (vA(n, this.peekCodePoint(0)))
            A.push(this.consumeEscapedCodePoint());
          else
            return this.consumeBadUrlRemnants(), Me;
        else
          A.push(n);
      }
    }, e.prototype.consumeWhiteSpace = function() {
      for (; Te(this.peekCodePoint(0)); )
        this.consumeCodePoint();
    }, e.prototype.consumeBadUrlRemnants = function() {
      for (; ; ) {
        var A = this.consumeCodePoint();
        if (A === ne || A === oA)
          return;
        vA(A, this.peekCodePoint(0)) && this.consumeEscapedCodePoint();
      }
    }, e.prototype.consumeStringSlice = function(A) {
      for (var r = 5e4, t = ""; A > 0; ) {
        var n = Math.min(r, A);
        t += N.apply(void 0, this._value.splice(0, n)), A -= n;
      }
      return this._value.shift(), t;
    }, e.prototype.consumeStringToken = function(A) {
      var r = "", t = 0;
      do {
        var n = this._value[t];
        if (n === oA || n === void 0 || n === A)
          return r += this.consumeStringSlice(t), { type: 0, value: r };
        if (n === qe)
          return this._value.splice(0, t), Oi;
        if (n === ge) {
          var s = this._value[t + 1];
          s !== oA && s !== void 0 && (s === qe ? (r += this.consumeStringSlice(t), t = -1, this._value.shift()) : vA(n, s) && (r += this.consumeStringSlice(t), r += N(this.consumeEscapedCodePoint()), t = -1));
        }
        t++;
      } while (!0);
    }, e.prototype.consumeNumber = function() {
      var A = [], r = de, t = this.peekCodePoint(0);
      for ((t === GA || t === $) && A.push(this.consumeCodePoint()); Z(this.peekCodePoint(0)); )
        A.push(this.consumeCodePoint());
      t = this.peekCodePoint(0);
      var n = this.peekCodePoint(1);
      if (t === Fe && Z(n))
        for (A.push(this.consumeCodePoint(), this.consumeCodePoint()), r = bt; Z(this.peekCodePoint(0)); )
          A.push(this.consumeCodePoint());
      t = this.peekCodePoint(0), n = this.peekCodePoint(1);
      var s = this.peekCodePoint(2);
      if ((t === Rn || t === Mn) && ((n === GA || n === $) && Z(s) || Z(n)))
        for (A.push(this.consumeCodePoint(), this.consumeCodePoint()), r = bt; Z(this.peekCodePoint(0)); )
          A.push(this.consumeCodePoint());
      return [Hi(A), r];
    }, e.prototype.consumeNumericToken = function() {
      var A = this.consumeNumber(), r = A[0], t = A[1], n = this.peekCodePoint(0), s = this.peekCodePoint(1), B = this.peekCodePoint(2);
      if (Oe(n, s, B)) {
        var i = this.consumeName();
        return { type: 15, number: r, flags: t, unit: i };
      }
      return n === kB ? (this.consumeCodePoint(), { type: 16, number: r, flags: t }) : { type: 17, number: r, flags: t };
    }, e.prototype.consumeEscapedCodePoint = function() {
      var A = this.consumeCodePoint();
      if (XA(A)) {
        for (var r = N(A); XA(this.peekCodePoint(0)) && r.length < 6; )
          r += N(this.consumeCodePoint());
        Te(this.peekCodePoint(0)) && this.consumeCodePoint();
        var t = parseInt(r, 16);
        return t === 0 || Ui(t) || t > 1114111 ? St : t;
      }
      return A === oA ? St : A;
    }, e.prototype.consumeName = function() {
      for (var A = ""; ; ) {
        var r = this.consumeCodePoint();
        if (Tt(r))
          A += N(r);
        else if (vA(r, this.peekCodePoint(0)))
          A += N(this.consumeEscapedCodePoint());
        else
          return this.reconsumeCodePoint(r), A;
      }
    }, e;
  }()
), Pn = (
  /** @class */
  function() {
    function e(A) {
      this._tokens = A;
    }
    return e.create = function(A) {
      var r = new Nn();
      return r.write(A), new e(r.read());
    }, e.parseValue = function(A) {
      return e.create(A).parseComponentValue();
    }, e.parseValues = function(A) {
      return e.create(A).parseComponentValues();
    }, e.prototype.parseComponentValue = function() {
      for (var A = this.consumeToken(); A.type === 31; )
        A = this.consumeToken();
      if (A.type === 32)
        throw new SyntaxError("Error parsing CSS component value, unexpected EOF");
      this.reconsumeToken(A);
      var r = this.consumeComponentValue();
      do
        A = this.consumeToken();
      while (A.type === 31);
      if (A.type === 32)
        return r;
      throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one");
    }, e.prototype.parseComponentValues = function() {
      for (var A = []; ; ) {
        var r = this.consumeComponentValue();
        if (r.type === 32)
          return A;
        A.push(r), A.push();
      }
    }, e.prototype.consumeComponentValue = function() {
      var A = this.consumeToken();
      switch (A.type) {
        case 11:
        case 28:
        case 2:
          return this.consumeSimpleBlock(A.type);
        case 19:
          return this.consumeFunction(A);
      }
      return A;
    }, e.prototype.consumeSimpleBlock = function(A) {
      for (var r = { type: A, values: [] }, t = this.consumeToken(); ; ) {
        if (t.type === 32 || ki(t, A))
          return r;
        this.reconsumeToken(t), r.values.push(this.consumeComponentValue()), t = this.consumeToken();
      }
    }, e.prototype.consumeFunction = function(A) {
      for (var r = {
        name: A.value,
        values: [],
        type: 18
        /* FUNCTION */
      }; ; ) {
        var t = this.consumeToken();
        if (t.type === 32 || t.type === 3)
          return r;
        this.reconsumeToken(t), r.values.push(this.consumeComponentValue());
      }
    }, e.prototype.consumeToken = function() {
      var A = this._tokens.shift();
      return typeof A > "u" ? zr : A;
    }, e.prototype.reconsumeToken = function(A) {
      this._tokens.unshift(A);
    }, e;
  }()
), pe = function(e) {
  return e.type === 15;
}, $A = function(e) {
  return e.type === 17;
}, S = function(e) {
  return e.type === 20;
}, Xi = function(e) {
  return e.type === 0;
}, jr = function(e, A) {
  return S(e) && e.value === A;
}, _n = function(e) {
  return e.type !== 31;
}, jA = function(e) {
  return e.type !== 31 && e.type !== 4;
}, lA = function(e) {
  var A = [], r = [];
  return e.forEach(function(t) {
    if (t.type === 4) {
      if (r.length === 0)
        throw new Error("Error parsing function args, zero tokens for arg");
      A.push(r), r = [];
      return;
    }
    t.type !== 31 && r.push(t);
  }), r.length && A.push(r), A;
}, ki = function(e, A) {
  return A === 11 && e.type === 12 || A === 28 && e.type === 29 ? !0 : A === 2 && e.type === 3;
}, bA = function(e) {
  return e.type === 17 || e.type === 15;
}, P = function(e) {
  return e.type === 16 || bA(e);
}, Xn = function(e) {
  return e.length > 1 ? [e[0], e[1]] : [e[0]];
}, J = {
  type: 17,
  number: 0,
  flags: de
}, lt = {
  type: 16,
  number: 50,
  flags: de
}, mA = {
  type: 16,
  number: 100,
  flags: de
}, oe = function(e, A, r) {
  var t = e[0], n = e[1];
  return [O(t, A), O(typeof n < "u" ? n : t, r)];
}, O = function(e, A) {
  if (e.type === 16)
    return e.number / 100 * A;
  if (pe(e))
    switch (e.unit) {
      case "rem":
      case "em":
        return 16 * e.number;
      case "px":
      default:
        return e.number;
    }
  return e.number;
}, kn = "deg", Jn = "grad", Wn = "rad", Yn = "turn", cr = {
  name: "angle",
  parse: function(e, A) {
    if (A.type === 15)
      switch (A.unit) {
        case kn:
          return Math.PI * A.number / 180;
        case Jn:
          return Math.PI / 200 * A.number;
        case Wn:
          return A.number;
        case Yn:
          return Math.PI * 2 * A.number;
      }
    throw new Error("Unsupported angle type");
  }
}, Zn = function(e) {
  return e.type === 15 && (e.unit === kn || e.unit === Jn || e.unit === Wn || e.unit === Yn);
}, qn = function(e) {
  var A = e.filter(S).map(function(r) {
    return r.value;
  }).join(" ");
  switch (A) {
    case "to bottom right":
    case "to right bottom":
    case "left top":
    case "top left":
      return [J, J];
    case "to top":
    case "bottom":
      return tA(0);
    case "to bottom left":
    case "to left bottom":
    case "right top":
    case "top right":
      return [J, mA];
    case "to right":
    case "left":
      return tA(90);
    case "to top left":
    case "to left top":
    case "right bottom":
    case "bottom right":
      return [mA, mA];
    case "to bottom":
    case "top":
      return tA(180);
    case "to top right":
    case "to right top":
    case "left bottom":
    case "bottom left":
      return [mA, J];
    case "to left":
    case "right":
      return tA(270);
  }
  return 0;
}, tA = function(e) {
  return Math.PI * e / 180;
}, KA = {
  name: "color",
  parse: function(e, A) {
    if (A.type === 18) {
      var r = Ji[A.name];
      if (typeof r > "u")
        throw new Error('Attempting to parse an unsupported color function "' + A.name + '"');
      return r(e, A.values);
    }
    if (A.type === 5) {
      if (A.value.length === 3) {
        var t = A.value.substring(0, 1), n = A.value.substring(1, 2), s = A.value.substring(2, 3);
        return yA(parseInt(t + t, 16), parseInt(n + n, 16), parseInt(s + s, 16), 1);
      }
      if (A.value.length === 4) {
        var t = A.value.substring(0, 1), n = A.value.substring(1, 2), s = A.value.substring(2, 3), B = A.value.substring(3, 4);
        return yA(parseInt(t + t, 16), parseInt(n + n, 16), parseInt(s + s, 16), parseInt(B + B, 16) / 255);
      }
      if (A.value.length === 6) {
        var t = A.value.substring(0, 2), n = A.value.substring(2, 4), s = A.value.substring(4, 6);
        return yA(parseInt(t, 16), parseInt(n, 16), parseInt(s, 16), 1);
      }
      if (A.value.length === 8) {
        var t = A.value.substring(0, 2), n = A.value.substring(2, 4), s = A.value.substring(4, 6), B = A.value.substring(6, 8);
        return yA(parseInt(t, 16), parseInt(n, 16), parseInt(s, 16), parseInt(B, 16) / 255);
      }
    }
    if (A.type === 20) {
      var i = UA[A.value.toUpperCase()];
      if (typeof i < "u")
        return i;
    }
    return UA.TRANSPARENT;
  }
}, LA = function(e) {
  return (255 & e) === 0;
}, X = function(e) {
  var A = 255 & e, r = 255 & e >> 8, t = 255 & e >> 16, n = 255 & e >> 24;
  return A < 255 ? "rgba(" + n + "," + t + "," + r + "," + A / 255 + ")" : "rgb(" + n + "," + t + "," + r + ")";
}, yA = function(e, A, r, t) {
  return (e << 24 | A << 16 | r << 8 | Math.round(t * 255) << 0) >>> 0;
}, Ot = function(e, A) {
  if (e.type === 17)
    return e.number;
  if (e.type === 16) {
    var r = A === 3 ? 1 : 255;
    return A === 3 ? e.number / 100 * r : Math.round(e.number / 100 * r);
  }
  return 0;
}, Mt = function(e, A) {
  var r = A.filter(jA);
  if (r.length === 3) {
    var t = r.map(Ot), n = t[0], s = t[1], B = t[2];
    return yA(n, s, B, 1);
  }
  if (r.length === 4) {
    var i = r.map(Ot), n = i[0], s = i[1], B = i[2], a = i[3];
    return yA(n, s, B, a);
  }
  return 0;
};
function vr(e, A, r) {
  return r < 0 && (r += 1), r >= 1 && (r -= 1), r < 1 / 6 ? (A - e) * r * 6 + e : r < 1 / 2 ? A : r < 2 / 3 ? (A - e) * 6 * (2 / 3 - r) + e : e;
}
var Gt = function(e, A) {
  var r = A.filter(jA), t = r[0], n = r[1], s = r[2], B = r[3], i = (t.type === 17 ? tA(t.number) : cr.parse(e, t)) / (Math.PI * 2), a = P(n) ? n.number / 100 : 0, o = P(s) ? s.number / 100 : 0, c = typeof B < "u" && P(B) ? O(B, 1) : 1;
  if (a === 0)
    return yA(o * 255, o * 255, o * 255, 1);
  var l = o <= 0.5 ? o * (a + 1) : o + a - o * a, Q = o * 2 - l, f = vr(Q, l, i + 1 / 3), g = vr(Q, l, i), w = vr(Q, l, i - 1 / 3);
  return yA(f * 255, g * 255, w * 255, c);
}, Ji = {
  hsl: Gt,
  hsla: Gt,
  rgb: Mt,
  rgba: Mt
}, we = function(e, A) {
  return KA.parse(e, Pn.create(A).parseComponentValue());
}, UA = {
  ALICEBLUE: 4042850303,
  ANTIQUEWHITE: 4209760255,
  AQUA: 16777215,
  AQUAMARINE: 2147472639,
  AZURE: 4043309055,
  BEIGE: 4126530815,
  BISQUE: 4293182719,
  BLACK: 255,
  BLANCHEDALMOND: 4293643775,
  BLUE: 65535,
  BLUEVIOLET: 2318131967,
  BROWN: 2771004159,
  BURLYWOOD: 3736635391,
  CADETBLUE: 1604231423,
  CHARTREUSE: 2147418367,
  CHOCOLATE: 3530104575,
  CORAL: 4286533887,
  CORNFLOWERBLUE: 1687547391,
  CORNSILK: 4294499583,
  CRIMSON: 3692313855,
  CYAN: 16777215,
  DARKBLUE: 35839,
  DARKCYAN: 9145343,
  DARKGOLDENROD: 3095837695,
  DARKGRAY: 2846468607,
  DARKGREEN: 6553855,
  DARKGREY: 2846468607,
  DARKKHAKI: 3182914559,
  DARKMAGENTA: 2332068863,
  DARKOLIVEGREEN: 1433087999,
  DARKORANGE: 4287365375,
  DARKORCHID: 2570243327,
  DARKRED: 2332033279,
  DARKSALMON: 3918953215,
  DARKSEAGREEN: 2411499519,
  DARKSLATEBLUE: 1211993087,
  DARKSLATEGRAY: 793726975,
  DARKSLATEGREY: 793726975,
  DARKTURQUOISE: 13554175,
  DARKVIOLET: 2483082239,
  DEEPPINK: 4279538687,
  DEEPSKYBLUE: 12582911,
  DIMGRAY: 1768516095,
  DIMGREY: 1768516095,
  DODGERBLUE: 512819199,
  FIREBRICK: 2988581631,
  FLORALWHITE: 4294635775,
  FORESTGREEN: 579543807,
  FUCHSIA: 4278255615,
  GAINSBORO: 3705462015,
  GHOSTWHITE: 4177068031,
  GOLD: 4292280575,
  GOLDENROD: 3668254975,
  GRAY: 2155905279,
  GREEN: 8388863,
  GREENYELLOW: 2919182335,
  GREY: 2155905279,
  HONEYDEW: 4043305215,
  HOTPINK: 4285117695,
  INDIANRED: 3445382399,
  INDIGO: 1258324735,
  IVORY: 4294963455,
  KHAKI: 4041641215,
  LAVENDER: 3873897215,
  LAVENDERBLUSH: 4293981695,
  LAWNGREEN: 2096890111,
  LEMONCHIFFON: 4294626815,
  LIGHTBLUE: 2916673279,
  LIGHTCORAL: 4034953471,
  LIGHTCYAN: 3774873599,
  LIGHTGOLDENRODYELLOW: 4210742015,
  LIGHTGRAY: 3553874943,
  LIGHTGREEN: 2431553791,
  LIGHTGREY: 3553874943,
  LIGHTPINK: 4290167295,
  LIGHTSALMON: 4288707327,
  LIGHTSEAGREEN: 548580095,
  LIGHTSKYBLUE: 2278488831,
  LIGHTSLATEGRAY: 2005441023,
  LIGHTSLATEGREY: 2005441023,
  LIGHTSTEELBLUE: 2965692159,
  LIGHTYELLOW: 4294959359,
  LIME: 16711935,
  LIMEGREEN: 852308735,
  LINEN: 4210091775,
  MAGENTA: 4278255615,
  MAROON: 2147483903,
  MEDIUMAQUAMARINE: 1724754687,
  MEDIUMBLUE: 52735,
  MEDIUMORCHID: 3126187007,
  MEDIUMPURPLE: 2473647103,
  MEDIUMSEAGREEN: 1018393087,
  MEDIUMSLATEBLUE: 2070474495,
  MEDIUMSPRINGGREEN: 16423679,
  MEDIUMTURQUOISE: 1221709055,
  MEDIUMVIOLETRED: 3340076543,
  MIDNIGHTBLUE: 421097727,
  MINTCREAM: 4127193855,
  MISTYROSE: 4293190143,
  MOCCASIN: 4293178879,
  NAVAJOWHITE: 4292783615,
  NAVY: 33023,
  OLDLACE: 4260751103,
  OLIVE: 2155872511,
  OLIVEDRAB: 1804477439,
  ORANGE: 4289003775,
  ORANGERED: 4282712319,
  ORCHID: 3664828159,
  PALEGOLDENROD: 4008225535,
  PALEGREEN: 2566625535,
  PALETURQUOISE: 2951671551,
  PALEVIOLETRED: 3681588223,
  PAPAYAWHIP: 4293907967,
  PEACHPUFF: 4292524543,
  PERU: 3448061951,
  PINK: 4290825215,
  PLUM: 3718307327,
  POWDERBLUE: 2967529215,
  PURPLE: 2147516671,
  REBECCAPURPLE: 1714657791,
  RED: 4278190335,
  ROSYBROWN: 3163525119,
  ROYALBLUE: 1097458175,
  SADDLEBROWN: 2336560127,
  SALMON: 4202722047,
  SANDYBROWN: 4104413439,
  SEAGREEN: 780883967,
  SEASHELL: 4294307583,
  SIENNA: 2689740287,
  SILVER: 3233857791,
  SKYBLUE: 2278484991,
  SLATEBLUE: 1784335871,
  SLATEGRAY: 1887473919,
  SLATEGREY: 1887473919,
  SNOW: 4294638335,
  SPRINGGREEN: 16744447,
  STEELBLUE: 1182971135,
  TAN: 3535047935,
  TEAL: 8421631,
  THISTLE: 3636451583,
  TOMATO: 4284696575,
  TRANSPARENT: 0,
  TURQUOISE: 1088475391,
  VIOLET: 4001558271,
  WHEAT: 4125012991,
  WHITE: 4294967295,
  WHITESMOKE: 4126537215,
  YELLOW: 4294902015,
  YELLOWGREEN: 2597139199
}, Wi = {
  name: "background-clip",
  initialValue: "border-box",
  prefix: !1,
  type: 1,
  parse: function(e, A) {
    return A.map(function(r) {
      if (S(r))
        switch (r.value) {
          case "padding-box":
            return 1;
          case "content-box":
            return 2;
        }
      return 0;
    });
  }
}, Yi = {
  name: "background-color",
  initialValue: "transparent",
  prefix: !1,
  type: 3,
  format: "color"
}, lr = function(e, A) {
  var r = KA.parse(e, A[0]), t = A[1];
  return t && P(t) ? { color: r, stop: t } : { color: r, stop: null };
}, Rt = function(e, A) {
  var r = e[0], t = e[e.length - 1];
  r.stop === null && (r.stop = J), t.stop === null && (t.stop = mA);
  for (var n = [], s = 0, B = 0; B < e.length; B++) {
    var i = e[B].stop;
    if (i !== null) {
      var a = O(i, A);
      a > s ? n.push(a) : n.push(s), s = a;
    } else
      n.push(null);
  }
  for (var o = null, B = 0; B < n.length; B++) {
    var c = n[B];
    if (c === null)
      o === null && (o = B);
    else if (o !== null) {
      for (var l = B - o, Q = n[o - 1], f = (c - Q) / (l + 1), g = 1; g <= l; g++)
        n[o + g - 1] = f * g;
      o = null;
    }
  }
  return e.map(function(w, E) {
    var C = w.color;
    return { color: C, stop: Math.max(Math.min(1, n[E] / A), 0) };
  });
}, Zi = function(e, A, r) {
  var t = A / 2, n = r / 2, s = O(e[0], A) - t, B = n - O(e[1], r);
  return (Math.atan2(B, s) + Math.PI * 2) % (Math.PI * 2);
}, qi = function(e, A, r) {
  var t = typeof e == "number" ? e : Zi(e, A, r), n = Math.abs(A * Math.sin(t)) + Math.abs(r * Math.cos(t)), s = A / 2, B = r / 2, i = n / 2, a = Math.sin(t - Math.PI / 2) * i, o = Math.cos(t - Math.PI / 2) * i;
  return [n, s - o, s + o, B - a, B + a];
}, BA = function(e, A) {
  return Math.sqrt(e * e + A * A);
}, Vt = function(e, A, r, t, n) {
  var s = [
    [0, 0],
    [0, A],
    [e, 0],
    [e, A]
  ];
  return s.reduce(function(B, i) {
    var a = i[0], o = i[1], c = BA(r - a, t - o);
    return (n ? c < B.optimumDistance : c > B.optimumDistance) ? {
      optimumCorner: i,
      optimumDistance: c
    } : B;
  }, {
    optimumDistance: n ? 1 / 0 : -1 / 0,
    optimumCorner: null
  }).optimumCorner;
}, zi = function(e, A, r, t, n) {
  var s = 0, B = 0;
  switch (e.size) {
    case 0:
      e.shape === 0 ? s = B = Math.min(Math.abs(A), Math.abs(A - t), Math.abs(r), Math.abs(r - n)) : e.shape === 1 && (s = Math.min(Math.abs(A), Math.abs(A - t)), B = Math.min(Math.abs(r), Math.abs(r - n)));
      break;
    case 2:
      if (e.shape === 0)
        s = B = Math.min(BA(A, r), BA(A, r - n), BA(A - t, r), BA(A - t, r - n));
      else if (e.shape === 1) {
        var i = Math.min(Math.abs(r), Math.abs(r - n)) / Math.min(Math.abs(A), Math.abs(A - t)), a = Vt(t, n, A, r, !0), o = a[0], c = a[1];
        s = BA(o - A, (c - r) / i), B = i * s;
      }
      break;
    case 1:
      e.shape === 0 ? s = B = Math.max(Math.abs(A), Math.abs(A - t), Math.abs(r), Math.abs(r - n)) : e.shape === 1 && (s = Math.max(Math.abs(A), Math.abs(A - t)), B = Math.max(Math.abs(r), Math.abs(r - n)));
      break;
    case 3:
      if (e.shape === 0)
        s = B = Math.max(BA(A, r), BA(A, r - n), BA(A - t, r), BA(A - t, r - n));
      else if (e.shape === 1) {
        var i = Math.max(Math.abs(r), Math.abs(r - n)) / Math.max(Math.abs(A), Math.abs(A - t)), l = Vt(t, n, A, r, !1), o = l[0], c = l[1];
        s = BA(o - A, (c - r) / i), B = i * s;
      }
      break;
  }
  return Array.isArray(e.size) && (s = O(e.size[0], t), B = e.size.length === 2 ? O(e.size[1], n) : s), [s, B];
}, ji = function(e, A) {
  var r = tA(180), t = [];
  return lA(A).forEach(function(n, s) {
    if (s === 0) {
      var B = n[0];
      if (B.type === 20 && B.value === "to") {
        r = qn(n);
        return;
      } else if (Zn(B)) {
        r = cr.parse(e, B);
        return;
      }
    }
    var i = lr(e, n);
    t.push(i);
  }), {
    angle: r,
    stops: t,
    type: 1
    /* LINEAR_GRADIENT */
  };
}, Ge = function(e, A) {
  var r = tA(180), t = [];
  return lA(A).forEach(function(n, s) {
    if (s === 0) {
      var B = n[0];
      if (B.type === 20 && ["top", "left", "right", "bottom"].indexOf(B.value) !== -1) {
        r = qn(n);
        return;
      } else if (Zn(B)) {
        r = (cr.parse(e, B) + tA(270)) % tA(360);
        return;
      }
    }
    var i = lr(e, n);
    t.push(i);
  }), {
    angle: r,
    stops: t,
    type: 1
    /* LINEAR_GRADIENT */
  };
}, $i = function(e, A) {
  var r = tA(180), t = [], n = 1, s = 0, B = 3, i = [];
  return lA(A).forEach(function(a, o) {
    var c = a[0];
    if (o === 0) {
      if (S(c) && c.value === "linear") {
        n = 1;
        return;
      } else if (S(c) && c.value === "radial") {
        n = 2;
        return;
      }
    }
    if (c.type === 18) {
      if (c.name === "from") {
        var l = KA.parse(e, c.values[0]);
        t.push({ stop: J, color: l });
      } else if (c.name === "to") {
        var l = KA.parse(e, c.values[0]);
        t.push({ stop: mA, color: l });
      } else if (c.name === "color-stop") {
        var Q = c.values.filter(jA);
        if (Q.length === 2) {
          var l = KA.parse(e, Q[1]), f = Q[0];
          $A(f) && t.push({
            stop: { type: 16, number: f.number * 100, flags: f.flags },
            color: l
          });
        }
      }
    }
  }), n === 1 ? {
    angle: (r + tA(180)) % tA(360),
    stops: t,
    type: n
  } : { size: B, shape: s, stops: t, position: i, type: n };
}, zn = "closest-side", jn = "farthest-side", $n = "closest-corner", As = "farthest-corner", es = "circle", rs = "ellipse", ts = "cover", ns = "contain", Aa = function(e, A) {
  var r = 0, t = 3, n = [], s = [];
  return lA(A).forEach(function(B, i) {
    var a = !0;
    if (i === 0) {
      var o = !1;
      a = B.reduce(function(l, Q) {
        if (o)
          if (S(Q))
            switch (Q.value) {
              case "center":
                return s.push(lt), l;
              case "top":
              case "left":
                return s.push(J), l;
              case "right":
              case "bottom":
                return s.push(mA), l;
            }
          else
            (P(Q) || bA(Q)) && s.push(Q);
        else if (S(Q))
          switch (Q.value) {
            case es:
              return r = 0, !1;
            case rs:
              return r = 1, !1;
            case "at":
              return o = !0, !1;
            case zn:
              return t = 0, !1;
            case ts:
            case jn:
              return t = 1, !1;
            case ns:
            case $n:
              return t = 2, !1;
            case As:
              return t = 3, !1;
          }
        else if (bA(Q) || P(Q))
          return Array.isArray(t) || (t = []), t.push(Q), !1;
        return l;
      }, a);
    }
    if (a) {
      var c = lr(e, B);
      n.push(c);
    }
  }), {
    size: t,
    shape: r,
    stops: n,
    position: s,
    type: 2
    /* RADIAL_GRADIENT */
  };
}, Re = function(e, A) {
  var r = 0, t = 3, n = [], s = [];
  return lA(A).forEach(function(B, i) {
    var a = !0;
    if (i === 0 ? a = B.reduce(function(c, l) {
      if (S(l))
        switch (l.value) {
          case "center":
            return s.push(lt), !1;
          case "top":
          case "left":
            return s.push(J), !1;
          case "right":
          case "bottom":
            return s.push(mA), !1;
        }
      else if (P(l) || bA(l))
        return s.push(l), !1;
      return c;
    }, a) : i === 1 && (a = B.reduce(function(c, l) {
      if (S(l))
        switch (l.value) {
          case es:
            return r = 0, !1;
          case rs:
            return r = 1, !1;
          case ns:
          case zn:
            return t = 0, !1;
          case jn:
            return t = 1, !1;
          case $n:
            return t = 2, !1;
          case ts:
          case As:
            return t = 3, !1;
        }
      else if (bA(l) || P(l))
        return Array.isArray(t) || (t = []), t.push(l), !1;
      return c;
    }, a)), a) {
      var o = lr(e, B);
      n.push(o);
    }
  }), {
    size: t,
    shape: r,
    stops: n,
    position: s,
    type: 2
    /* RADIAL_GRADIENT */
  };
}, ea = function(e) {
  return e.type === 1;
}, ra = function(e) {
  return e.type === 2;
}, Qt = {
  name: "image",
  parse: function(e, A) {
    if (A.type === 22) {
      var r = {
        url: A.value,
        type: 0
        /* URL */
      };
      return e.cache.addImage(A.value), r;
    }
    if (A.type === 18) {
      var t = ss[A.name];
      if (typeof t > "u")
        throw new Error('Attempting to parse an unsupported image function "' + A.name + '"');
      return t(e, A.values);
    }
    throw new Error("Unsupported image type " + A.type);
  }
};
function ta(e) {
  return !(e.type === 20 && e.value === "none") && (e.type !== 18 || !!ss[e.name]);
}
var ss = {
  "linear-gradient": ji,
  "-moz-linear-gradient": Ge,
  "-ms-linear-gradient": Ge,
  "-o-linear-gradient": Ge,
  "-webkit-linear-gradient": Ge,
  "radial-gradient": Aa,
  "-moz-radial-gradient": Re,
  "-ms-radial-gradient": Re,
  "-o-radial-gradient": Re,
  "-webkit-radial-gradient": Re,
  "-webkit-gradient": $i
}, na = {
  name: "background-image",
  initialValue: "none",
  type: 1,
  prefix: !1,
  parse: function(e, A) {
    if (A.length === 0)
      return [];
    var r = A[0];
    return r.type === 20 && r.value === "none" ? [] : A.filter(function(t) {
      return jA(t) && ta(t);
    }).map(function(t) {
      return Qt.parse(e, t);
    });
  }
}, sa = {
  name: "background-origin",
  initialValue: "border-box",
  prefix: !1,
  type: 1,
  parse: function(e, A) {
    return A.map(function(r) {
      if (S(r))
        switch (r.value) {
          case "padding-box":
            return 1;
          case "content-box":
            return 2;
        }
      return 0;
    });
  }
}, Ba = {
  name: "background-position",
  initialValue: "0% 0%",
  type: 1,
  prefix: !1,
  parse: function(e, A) {
    return lA(A).map(function(r) {
      return r.filter(P);
    }).map(Xn);
  }
}, ia = {
  name: "background-repeat",
  initialValue: "repeat",
  prefix: !1,
  type: 1,
  parse: function(e, A) {
    return lA(A).map(function(r) {
      return r.filter(S).map(function(t) {
        return t.value;
      }).join(" ");
    }).map(aa);
  }
}, aa = function(e) {
  switch (e) {
    case "no-repeat":
      return 1;
    case "repeat-x":
    case "repeat no-repeat":
      return 2;
    case "repeat-y":
    case "no-repeat repeat":
      return 3;
    case "repeat":
    default:
      return 0;
  }
}, zA;
(function(e) {
  e.AUTO = "auto", e.CONTAIN = "contain", e.COVER = "cover";
})(zA || (zA = {}));
var oa = {
  name: "background-size",
  initialValue: "0",
  prefix: !1,
  type: 1,
  parse: function(e, A) {
    return lA(A).map(function(r) {
      return r.filter(ca);
    });
  }
}, ca = function(e) {
  return S(e) || P(e);
}, Qr = function(e) {
  return {
    name: "border-" + e + "-color",
    initialValue: "transparent",
    prefix: !1,
    type: 3,
    format: "color"
  };
}, la = Qr("top"), Qa = Qr("right"), ga = Qr("bottom"), wa = Qr("left"), gr = function(e) {
  return {
    name: "border-radius-" + e,
    initialValue: "0 0",
    prefix: !1,
    type: 1,
    parse: function(A, r) {
      return Xn(r.filter(P));
    }
  };
}, ua = gr("top-left"), fa = gr("top-right"), Ca = gr("bottom-right"), Ua = gr("bottom-left"), wr = function(e) {
  return {
    name: "border-" + e + "-style",
    initialValue: "solid",
    prefix: !1,
    type: 2,
    parse: function(A, r) {
      switch (r) {
        case "none":
          return 0;
        case "dashed":
          return 2;
        case "dotted":
          return 3;
        case "double":
          return 4;
      }
      return 1;
    }
  };
}, Fa = wr("top"), ha = wr("right"), da = wr("bottom"), pa = wr("left"), ur = function(e) {
  return {
    name: "border-" + e + "-width",
    initialValue: "0",
    type: 0,
    prefix: !1,
    parse: function(A, r) {
      return pe(r) ? r.number : 0;
    }
  };
}, Ea = ur("top"), Ha = ur("right"), va = ur("bottom"), Ia = ur("left"), ma = {
  name: "color",
  initialValue: "transparent",
  prefix: !1,
  type: 3,
  format: "color"
}, ya = {
  name: "direction",
  initialValue: "ltr",
  prefix: !1,
  type: 2,
  parse: function(e, A) {
    switch (A) {
      case "rtl":
        return 1;
      case "ltr":
      default:
        return 0;
    }
  }
}, Ka = {
  name: "display",
  initialValue: "inline-block",
  prefix: !1,
  type: 1,
  parse: function(e, A) {
    return A.filter(S).reduce(
      function(r, t) {
        return r | La(t.value);
      },
      0
      /* NONE */
    );
  }
}, La = function(e) {
  switch (e) {
    case "block":
    case "-webkit-box":
      return 2;
    case "inline":
      return 4;
    case "run-in":
      return 8;
    case "flow":
      return 16;
    case "flow-root":
      return 32;
    case "table":
      return 64;
    case "flex":
    case "-webkit-flex":
      return 128;
    case "grid":
    case "-ms-grid":
      return 256;
    case "ruby":
      return 512;
    case "subgrid":
      return 1024;
    case "list-item":
      return 2048;
    case "table-row-group":
      return 4096;
    case "table-header-group":
      return 8192;
    case "table-footer-group":
      return 16384;
    case "table-row":
      return 32768;
    case "table-cell":
      return 65536;
    case "table-column-group":
      return 131072;
    case "table-column":
      return 262144;
    case "table-caption":
      return 524288;
    case "ruby-base":
      return 1048576;
    case "ruby-text":
      return 2097152;
    case "ruby-base-container":
      return 4194304;
    case "ruby-text-container":
      return 8388608;
    case "contents":
      return 16777216;
    case "inline-block":
      return 33554432;
    case "inline-list-item":
      return 67108864;
    case "inline-table":
      return 134217728;
    case "inline-flex":
      return 268435456;
    case "inline-grid":
      return 536870912;
  }
  return 0;
}, ba = {
  name: "float",
  initialValue: "none",
  prefix: !1,
  type: 2,
  parse: function(e, A) {
    switch (A) {
      case "left":
        return 1;
      case "right":
        return 2;
      case "inline-start":
        return 3;
      case "inline-end":
        return 4;
    }
    return 0;
  }
}, Da = {
  name: "letter-spacing",
  initialValue: "0",
  prefix: !1,
  type: 0,
  parse: function(e, A) {
    return A.type === 20 && A.value === "normal" ? 0 : A.type === 17 || A.type === 15 ? A.number : 0;
  }
}, je;
(function(e) {
  e.NORMAL = "normal", e.STRICT = "strict";
})(je || (je = {}));
var xa = {
  name: "line-break",
  initialValue: "normal",
  prefix: !1,
  type: 2,
  parse: function(e, A) {
    switch (A) {
      case "strict":
        return je.STRICT;
      case "normal":
      default:
        return je.NORMAL;
    }
  }
}, Sa = {
  name: "line-height",
  initialValue: "normal",
  prefix: !1,
  type: 4
  /* TOKEN_VALUE */
}, Nt = function(e, A) {
  return S(e) && e.value === "normal" ? 1.2 * A : e.type === 17 ? A * e.number : P(e) ? O(e, A) : A;
}, Ta = {
  name: "list-style-image",
  initialValue: "none",
  type: 0,
  prefix: !1,
  parse: function(e, A) {
    return A.type === 20 && A.value === "none" ? null : Qt.parse(e, A);
  }
}, Oa = {
  name: "list-style-position",
  initialValue: "outside",
  prefix: !1,
  type: 2,
  parse: function(e, A) {
    switch (A) {
      case "inside":
        return 0;
      case "outside":
      default:
        return 1;
    }
  }
}, $r = {
  name: "list-style-type",
  initialValue: "none",
  prefix: !1,
  type: 2,
  parse: function(e, A) {
    switch (A) {
      case "disc":
        return 0;
      case "circle":
        return 1;
      case "square":
        return 2;
      case "decimal":
        return 3;
      case "cjk-decimal":
        return 4;
      case "decimal-leading-zero":
        return 5;
      case "lower-roman":
        return 6;
      case "upper-roman":
        return 7;
      case "lower-greek":
        return 8;
      case "lower-alpha":
        return 9;
      case "upper-alpha":
        return 10;
      case "arabic-indic":
        return 11;
      case "armenian":
        return 12;
      case "bengali":
        return 13;
      case "cambodian":
        return 14;
      case "cjk-earthly-branch":
        return 15;
      case "cjk-heavenly-stem":
        return 16;
      case "cjk-ideographic":
        return 17;
      case "devanagari":
        return 18;
      case "ethiopic-numeric":
        return 19;
      case "georgian":
        return 20;
      case "gujarati":
        return 21;
      case "gurmukhi":
        return 22;
      case "hebrew":
        return 22;
      case "hiragana":
        return 23;
      case "hiragana-iroha":
        return 24;
      case "japanese-formal":
        return 25;
      case "japanese-informal":
        return 26;
      case "kannada":
        return 27;
      case "katakana":
        return 28;
      case "katakana-iroha":
        return 29;
      case "khmer":
        return 30;
      case "korean-hangul-formal":
        return 31;
      case "korean-hanja-formal":
        return 32;
      case "korean-hanja-informal":
        return 33;
      case "lao":
        return 34;
      case "lower-armenian":
        return 35;
      case "malayalam":
        return 36;
      case "mongolian":
        return 37;
      case "myanmar":
        return 38;
      case "oriya":
        return 39;
      case "persian":
        return 40;
      case "simp-chinese-formal":
        return 41;
      case "simp-chinese-informal":
        return 42;
      case "tamil":
        return 43;
      case "telugu":
        return 44;
      case "thai":
        return 45;
      case "tibetan":
        return 46;
      case "trad-chinese-formal":
        return 47;
      case "trad-chinese-informal":
        return 48;
      case "upper-armenian":
        return 49;
      case "disclosure-open":
        return 50;
      case "disclosure-closed":
        return 51;
      case "none":
      default:
        return -1;
    }
  }
}, fr = function(e) {
  return {
    name: "margin-" + e,
    initialValue: "0",
    prefix: !1,
    type: 4
    /* TOKEN_VALUE */
  };
}, Ma = fr("top"), Ga = fr("right"), Ra = fr("bottom"), Va = fr("left"), Na = {
  name: "overflow",
  initialValue: "visible",
  prefix: !1,
  type: 1,
  parse: function(e, A) {
    return A.filter(S).map(function(r) {
      switch (r.value) {
        case "hidden":
          return 1;
        case "scroll":
          return 2;
        case "clip":
          return 3;
        case "auto":
          return 4;
        case "visible":
        default:
          return 0;
      }
    });
  }
}, Pa = {
  name: "overflow-wrap",
  initialValue: "normal",
  prefix: !1,
  type: 2,
  parse: function(e, A) {
    switch (A) {
      case "break-word":
        return "break-word";
      case "normal":
      default:
        return "normal";
    }
  }
}, Cr = function(e) {
  return {
    name: "padding-" + e,
    initialValue: "0",
    prefix: !1,
    type: 3,
    format: "length-percentage"
  };
}, _a = Cr("top"), Xa = Cr("right"), ka = Cr("bottom"), Ja = Cr("left"), Wa = {
  name: "text-align",
  initialValue: "left",
  prefix: !1,
  type: 2,
  parse: function(e, A) {
    switch (A) {
      case "right":
        return 2;
      case "center":
      case "justify":
        return 1;
      case "left":
      default:
        return 0;
    }
  }
}, Ya = {
  name: "position",
  initialValue: "static",
  prefix: !1,
  type: 2,
  parse: function(e, A) {
    switch (A) {
      case "relative":
        return 1;
      case "absolute":
        return 2;
      case "fixed":
        return 3;
      case "sticky":
        return 4;
    }
    return 0;
  }
}, Za = {
  name: "text-shadow",
  initialValue: "none",
  type: 1,
  prefix: !1,
  parse: function(e, A) {
    return A.length === 1 && jr(A[0], "none") ? [] : lA(A).map(function(r) {
      for (var t = {
        color: UA.TRANSPARENT,
        offsetX: J,
        offsetY: J,
        blur: J
      }, n = 0, s = 0; s < r.length; s++) {
        var B = r[s];
        bA(B) ? (n === 0 ? t.offsetX = B : n === 1 ? t.offsetY = B : t.blur = B, n++) : t.color = KA.parse(e, B);
      }
      return t;
    });
  }
}, qa = {
  name: "text-transform",
  initialValue: "none",
  prefix: !1,
  type: 2,
  parse: function(e, A) {
    switch (A) {
      case "uppercase":
        return 2;
      case "lowercase":
        return 1;
      case "capitalize":
        return 3;
    }
    return 0;
  }
}, za = {
  name: "transform",
  initialValue: "none",
  prefix: !0,
  type: 0,
  parse: function(e, A) {
    if (A.type === 20 && A.value === "none")
      return null;
    if (A.type === 18) {
      var r = Ao[A.name];
      if (typeof r > "u")
        throw new Error('Attempting to parse an unsupported transform function "' + A.name + '"');
      return r(A.values);
    }
    return null;
  }
}, ja = function(e) {
  var A = e.filter(function(r) {
    return r.type === 17;
  }).map(function(r) {
    return r.number;
  });
  return A.length === 6 ? A : null;
}, $a = function(e) {
  var A = e.filter(function(a) {
    return a.type === 17;
  }).map(function(a) {
    return a.number;
  }), r = A[0], t = A[1];
  A[2], A[3];
  var n = A[4], s = A[5];
  A[6], A[7], A[8], A[9], A[10], A[11];
  var B = A[12], i = A[13];
  return A[14], A[15], A.length === 16 ? [r, t, n, s, B, i] : null;
}, Ao = {
  matrix: ja,
  matrix3d: $a
}, Pt = {
  type: 16,
  number: 50,
  flags: de
}, eo = [Pt, Pt], ro = {
  name: "transform-origin",
  initialValue: "50% 50%",
  prefix: !0,
  type: 1,
  parse: function(e, A) {
    var r = A.filter(P);
    return r.length !== 2 ? eo : [r[0], r[1]];
  }
}, to = {
  name: "visible",
  initialValue: "none",
  prefix: !1,
  type: 2,
  parse: function(e, A) {
    switch (A) {
      case "hidden":
        return 1;
      case "collapse":
        return 2;
      case "visible":
      default:
        return 0;
    }
  }
}, ue;
(function(e) {
  e.NORMAL = "normal", e.BREAK_ALL = "break-all", e.KEEP_ALL = "keep-all";
})(ue || (ue = {}));
var no = {
  name: "word-break",
  initialValue: "normal",
  prefix: !1,
  type: 2,
  parse: function(e, A) {
    switch (A) {
      case "break-all":
        return ue.BREAK_ALL;
      case "keep-all":
        return ue.KEEP_ALL;
      case "normal":
      default:
        return ue.NORMAL;
    }
  }
}, so = {
  name: "z-index",
  initialValue: "auto",
  prefix: !1,
  type: 0,
  parse: function(e, A) {
    if (A.type === 20)
      return { auto: !0, order: 0 };
    if ($A(A))
      return { auto: !1, order: A.number };
    throw new Error("Invalid z-index number parsed");
  }
}, Bs = {
  name: "time",
  parse: function(e, A) {
    if (A.type === 15)
      switch (A.unit.toLowerCase()) {
        case "s":
          return 1e3 * A.number;
        case "ms":
          return A.number;
      }
    throw new Error("Unsupported time type");
  }
}, Bo = {
  name: "opacity",
  initialValue: "1",
  type: 0,
  prefix: !1,
  parse: function(e, A) {
    return $A(A) ? A.number : 1;
  }
}, io = {
  name: "text-decoration-color",
  initialValue: "transparent",
  prefix: !1,
  type: 3,
  format: "color"
}, ao = {
  name: "text-decoration-line",
  initialValue: "none",
  prefix: !1,
  type: 1,
  parse: function(e, A) {
    return A.filter(S).map(function(r) {
      switch (r.value) {
        case "underline":
          return 1;
        case "overline":
          return 2;
        case "line-through":
          return 3;
        case "none":
          return 4;
      }
      return 0;
    }).filter(function(r) {
      return r !== 0;
    });
  }
}, oo = {
  name: "font-family",
  initialValue: "",
  prefix: !1,
  type: 1,
  parse: function(e, A) {
    var r = [], t = [];
    return A.forEach(function(n) {
      switch (n.type) {
        case 20:
        case 0:
          r.push(n.value);
          break;
        case 17:
          r.push(n.number.toString());
          break;
        case 4:
          t.push(r.join(" ")), r.length = 0;
          break;
      }
    }), r.length && t.push(r.join(" ")), t.map(function(n) {
      return n.indexOf(" ") === -1 ? n : "'" + n + "'";
    });
  }
}, co = {
  name: "font-size",
  initialValue: "0",
  prefix: !1,
  type: 3,
  format: "length"
}, lo = {
  name: "font-weight",
  initialValue: "normal",
  type: 0,
  prefix: !1,
  parse: function(e, A) {
    if ($A(A))
      return A.number;
    if (S(A))
      switch (A.value) {
        case "bold":
          return 700;
        case "normal":
        default:
          return 400;
      }
    return 400;
  }
}, Qo = {
  name: "font-variant",
  initialValue: "none",
  type: 1,
  prefix: !1,
  parse: function(e, A) {
    return A.filter(S).map(function(r) {
      return r.value;
    });
  }
}, go = {
  name: "font-style",
  initialValue: "normal",
  prefix: !1,
  type: 2,
  parse: function(e, A) {
    switch (A) {
      case "oblique":
        return "oblique";
      case "italic":
        return "italic";
      case "normal":
      default:
        return "normal";
    }
  }
}, _ = function(e, A) {
  return (e & A) !== 0;
}, wo = {
  name: "content",
  initialValue: "none",
  type: 1,
  prefix: !1,
  parse: function(e, A) {
    if (A.length === 0)
      return [];
    var r = A[0];
    return r.type === 20 && r.value === "none" ? [] : A;
  }
}, uo = {
  name: "counter-increment",
  initialValue: "none",
  prefix: !0,
  type: 1,
  parse: function(e, A) {
    if (A.length === 0)
      return null;
    var r = A[0];
    if (r.type === 20 && r.value === "none")
      return null;
    for (var t = [], n = A.filter(_n), s = 0; s < n.length; s++) {
      var B = n[s], i = n[s + 1];
      if (B.type === 20) {
        var a = i && $A(i) ? i.number : 1;
        t.push({ counter: B.value, increment: a });
      }
    }
    return t;
  }
}, fo = {
  name: "counter-reset",
  initialValue: "none",
  prefix: !0,
  type: 1,
  parse: function(e, A) {
    if (A.length === 0)
      return [];
    for (var r = [], t = A.filter(_n), n = 0; n < t.length; n++) {
      var s = t[n], B = t[n + 1];
      if (S(s) && s.value !== "none") {
        var i = B && $A(B) ? B.number : 0;
        r.push({ counter: s.value, reset: i });
      }
    }
    return r;
  }
}, Co = {
  name: "duration",
  initialValue: "0s",
  prefix: !1,
  type: 1,
  parse: function(e, A) {
    return A.filter(pe).map(function(r) {
      return Bs.parse(e, r);
    });
  }
}, Uo = {
  name: "quotes",
  initialValue: "none",
  prefix: !0,
  type: 1,
  parse: function(e, A) {
    if (A.length === 0)
      return null;
    var r = A[0];
    if (r.type === 20 && r.value === "none")
      return null;
    var t = [], n = A.filter(Xi);
    if (n.length % 2 !== 0)
      return null;
    for (var s = 0; s < n.length; s += 2) {
      var B = n[s].value, i = n[s + 1].value;
      t.push({ open: B, close: i });
    }
    return t;
  }
}, _t = function(e, A, r) {
  if (!e)
    return "";
  var t = e[Math.min(A, e.length - 1)];
  return t ? r ? t.open : t.close : "";
}, Fo = {
  name: "box-shadow",
  initialValue: "none",
  type: 1,
  prefix: !1,
  parse: function(e, A) {
    return A.length === 1 && jr(A[0], "none") ? [] : lA(A).map(function(r) {
      for (var t = {
        color: 255,
        offsetX: J,
        offsetY: J,
        blur: J,
        spread: J,
        inset: !1
      }, n = 0, s = 0; s < r.length; s++) {
        var B = r[s];
        jr(B, "inset") ? t.inset = !0 : bA(B) ? (n === 0 ? t.offsetX = B : n === 1 ? t.offsetY = B : n === 2 ? t.blur = B : t.spread = B, n++) : t.color = KA.parse(e, B);
      }
      return t;
    });
  }
}, ho = {
  name: "paint-order",
  initialValue: "normal",
  prefix: !1,
  type: 1,
  parse: function(e, A) {
    var r = [
      0,
      1,
      2
      /* MARKERS */
    ], t = [];
    return A.filter(S).forEach(function(n) {
      switch (n.value) {
        case "stroke":
          t.push(
            1
            /* STROKE */
          );
          break;
        case "fill":
          t.push(
            0
            /* FILL */
          );
          break;
        case "markers":
          t.push(
            2
            /* MARKERS */
          );
          break;
      }
    }), r.forEach(function(n) {
      t.indexOf(n) === -1 && t.push(n);
    }), t;
  }
}, po = {
  name: "-webkit-text-stroke-color",
  initialValue: "currentcolor",
  prefix: !1,
  type: 3,
  format: "color"
}, Eo = {
  name: "-webkit-text-stroke-width",
  initialValue: "0",
  type: 0,
  prefix: !1,
  parse: function(e, A) {
    return pe(A) ? A.number : 0;
  }
}, Ho = (
  /** @class */
  function() {
    function e(A, r) {
      var t, n;
      this.animationDuration = d(A, Co, r.animationDuration), this.backgroundClip = d(A, Wi, r.backgroundClip), this.backgroundColor = d(A, Yi, r.backgroundColor), this.backgroundImage = d(A, na, r.backgroundImage), this.backgroundOrigin = d(A, sa, r.backgroundOrigin), this.backgroundPosition = d(A, Ba, r.backgroundPosition), this.backgroundRepeat = d(A, ia, r.backgroundRepeat), this.backgroundSize = d(A, oa, r.backgroundSize), this.borderTopColor = d(A, la, r.borderTopColor), this.borderRightColor = d(A, Qa, r.borderRightColor), this.borderBottomColor = d(A, ga, r.borderBottomColor), this.borderLeftColor = d(A, wa, r.borderLeftColor), this.borderTopLeftRadius = d(A, ua, r.borderTopLeftRadius), this.borderTopRightRadius = d(A, fa, r.borderTopRightRadius), this.borderBottomRightRadius = d(A, Ca, r.borderBottomRightRadius), this.borderBottomLeftRadius = d(A, Ua, r.borderBottomLeftRadius), this.borderTopStyle = d(A, Fa, r.borderTopStyle), this.borderRightStyle = d(A, ha, r.borderRightStyle), this.borderBottomStyle = d(A, da, r.borderBottomStyle), this.borderLeftStyle = d(A, pa, r.borderLeftStyle), this.borderTopWidth = d(A, Ea, r.borderTopWidth), this.borderRightWidth = d(A, Ha, r.borderRightWidth), this.borderBottomWidth = d(A, va, r.borderBottomWidth), this.borderLeftWidth = d(A, Ia, r.borderLeftWidth), this.boxShadow = d(A, Fo, r.boxShadow), this.color = d(A, ma, r.color), this.direction = d(A, ya, r.direction), this.display = d(A, Ka, r.display), this.float = d(A, ba, r.cssFloat), this.fontFamily = d(A, oo, r.fontFamily), this.fontSize = d(A, co, r.fontSize), this.fontStyle = d(A, go, r.fontStyle), this.fontVariant = d(A, Qo, r.fontVariant), this.fontWeight = d(A, lo, r.fontWeight), this.letterSpacing = d(A, Da, r.letterSpacing), this.lineBreak = d(A, xa, r.lineBreak), this.lineHeight = d(A, Sa, r.lineHeight), this.listStyleImage = d(A, Ta, r.listStyleImage), this.listStylePosition = d(A, Oa, r.listStylePosition), this.listStyleType = d(A, $r, r.listStyleType), this.marginTop = d(A, Ma, r.marginTop), this.marginRight = d(A, Ga, r.marginRight), this.marginBottom = d(A, Ra, r.marginBottom), this.marginLeft = d(A, Va, r.marginLeft), this.opacity = d(A, Bo, r.opacity);
      var s = d(A, Na, r.overflow);
      this.overflowX = s[0], this.overflowY = s[s.length > 1 ? 1 : 0], this.overflowWrap = d(A, Pa, r.overflowWrap), this.paddingTop = d(A, _a, r.paddingTop), this.paddingRight = d(A, Xa, r.paddingRight), this.paddingBottom = d(A, ka, r.paddingBottom), this.paddingLeft = d(A, Ja, r.paddingLeft), this.paintOrder = d(A, ho, r.paintOrder), this.position = d(A, Ya, r.position), this.textAlign = d(A, Wa, r.textAlign), this.textDecorationColor = d(A, io, (t = r.textDecorationColor) !== null && t !== void 0 ? t : r.color), this.textDecorationLine = d(A, ao, (n = r.textDecorationLine) !== null && n !== void 0 ? n : r.textDecoration), this.textShadow = d(A, Za, r.textShadow), this.textTransform = d(A, qa, r.textTransform), this.transform = d(A, za, r.transform), this.transformOrigin = d(A, ro, r.transformOrigin), this.visibility = d(A, to, r.visibility), this.webkitTextStrokeColor = d(A, po, r.webkitTextStrokeColor), this.webkitTextStrokeWidth = d(A, Eo, r.webkitTextStrokeWidth), this.wordBreak = d(A, no, r.wordBreak), this.zIndex = d(A, so, r.zIndex);
    }
    return e.prototype.isVisible = function() {
      return this.display > 0 && this.opacity > 0 && this.visibility === 0;
    }, e.prototype.isTransparent = function() {
      return LA(this.backgroundColor);
    }, e.prototype.isTransformed = function() {
      return this.transform !== null;
    }, e.prototype.isPositioned = function() {
      return this.position !== 0;
    }, e.prototype.isPositionedWithZIndex = function() {
      return this.isPositioned() && !this.zIndex.auto;
    }, e.prototype.isFloating = function() {
      return this.float !== 0;
    }, e.prototype.isInlineLevel = function() {
      return _(
        this.display,
        4
        /* INLINE */
      ) || _(
        this.display,
        33554432
        /* INLINE_BLOCK */
      ) || _(
        this.display,
        268435456
        /* INLINE_FLEX */
      ) || _(
        this.display,
        536870912
        /* INLINE_GRID */
      ) || _(
        this.display,
        67108864
        /* INLINE_LIST_ITEM */
      ) || _(
        this.display,
        134217728
        /* INLINE_TABLE */
      );
    }, e;
  }()
), vo = (
  /** @class */
  function() {
    function e(A, r) {
      this.content = d(A, wo, r.content), this.quotes = d(A, Uo, r.quotes);
    }
    return e;
  }()
), Xt = (
  /** @class */
  function() {
    function e(A, r) {
      this.counterIncrement = d(A, uo, r.counterIncrement), this.counterReset = d(A, fo, r.counterReset);
    }
    return e;
  }()
), d = function(e, A, r) {
  var t = new Nn(), n = r !== null && typeof r < "u" ? r.toString() : A.initialValue;
  t.write(n);
  var s = new Pn(t.read());
  switch (A.type) {
    case 2:
      var B = s.parseComponentValue();
      return A.parse(e, S(B) ? B.value : A.initialValue);
    case 0:
      return A.parse(e, s.parseComponentValue());
    case 1:
      return A.parse(e, s.parseComponentValues());
    case 4:
      return s.parseComponentValue();
    case 3:
      switch (A.format) {
        case "angle":
          return cr.parse(e, s.parseComponentValue());
        case "color":
          return KA.parse(e, s.parseComponentValue());
        case "image":
          return Qt.parse(e, s.parseComponentValue());
        case "length":
          var i = s.parseComponentValue();
          return bA(i) ? i : J;
        case "length-percentage":
          var a = s.parseComponentValue();
          return P(a) ? a : J;
        case "time":
          return Bs.parse(e, s.parseComponentValue());
      }
      break;
  }
}, Io = "data-html2canvas-debug", mo = function(e) {
  var A = e.getAttribute(Io);
  switch (A) {
    case "all":
      return 1;
    case "clone":
      return 2;
    case "parse":
      return 3;
    case "render":
      return 4;
    default:
      return 0;
  }
}, At = function(e, A) {
  var r = mo(e);
  return r === 1 || A === r;
}, QA = (
  /** @class */
  function() {
    function e(A, r) {
      if (this.context = A, this.textNodes = [], this.elements = [], this.flags = 0, At(
        r,
        3
        /* PARSE */
      ))
        debugger;
      this.styles = new Ho(A, window.getComputedStyle(r, null)), tt(r) && (this.styles.animationDuration.some(function(t) {
        return t > 0;
      }) && (r.style.animationDuration = "0s"), this.styles.transform !== null && (r.style.transform = "none")), this.bounds = ar(this.context, r), At(
        r,
        4
        /* RENDER */
      ) && (this.flags |= 16);
    }
    return e;
  }()
), yo = " ", kt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", ce = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
for (var Ve = 0; Ve < kt.length; Ve++)
  ce[kt.charCodeAt(Ve)] = Ve;
var Ko = function(e) {
  var A = e.length * 0.75, r = e.length, t, n = 0, s, B, i, a;
  e[e.length - 1] === "=" && (A--, e[e.length - 2] === "=" && A--);
  var o = typeof ArrayBuffer < "u" && typeof Uint8Array < "u" && typeof Uint8Array.prototype.slice < "u" ? new ArrayBuffer(A) : new Array(A), c = Array.isArray(o) ? o : new Uint8Array(o);
  for (t = 0; t < r; t += 4)
    s = ce[e.charCodeAt(t)], B = ce[e.charCodeAt(t + 1)], i = ce[e.charCodeAt(t + 2)], a = ce[e.charCodeAt(t + 3)], c[n++] = s << 2 | B >> 4, c[n++] = (B & 15) << 4 | i >> 2, c[n++] = (i & 3) << 6 | a & 63;
  return o;
}, Lo = function(e) {
  for (var A = e.length, r = [], t = 0; t < A; t += 2)
    r.push(e[t + 1] << 8 | e[t]);
  return r;
}, bo = function(e) {
  for (var A = e.length, r = [], t = 0; t < A; t += 4)
    r.push(e[t + 3] << 24 | e[t + 2] << 16 | e[t + 1] << 8 | e[t]);
  return r;
}, VA = 5, gt = 6 + 5, Ir = 2, Do = gt - VA, is = 65536 >> VA, xo = 1 << VA, mr = xo - 1, So = 1024 >> VA, To = is + So, Oo = To, Mo = 32, Go = Oo + Mo, Ro = 65536 >> gt, Vo = 1 << Do, No = Vo - 1, Jt = function(e, A, r) {
  return e.slice ? e.slice(A, r) : new Uint16Array(Array.prototype.slice.call(e, A, r));
}, Po = function(e, A, r) {
  return e.slice ? e.slice(A, r) : new Uint32Array(Array.prototype.slice.call(e, A, r));
}, _o = function(e, A) {
  var r = Ko(e), t = Array.isArray(r) ? bo(r) : new Uint32Array(r), n = Array.isArray(r) ? Lo(r) : new Uint16Array(r), s = 24, B = Jt(n, s / 2, t[4] / 2), i = t[5] === 2 ? Jt(n, (s + t[4]) / 2) : Po(t, Math.ceil((s + t[4]) / 4));
  return new Xo(t[0], t[1], t[2], t[3], B, i);
}, Xo = (
  /** @class */
  function() {
    function e(A, r, t, n, s, B) {
      this.initialValue = A, this.errorValue = r, this.highStart = t, this.highValueIndex = n, this.index = s, this.data = B;
    }
    return e.prototype.get = function(A) {
      var r;
      if (A >= 0) {
        if (A < 55296 || A > 56319 && A <= 65535)
          return r = this.index[A >> VA], r = (r << Ir) + (A & mr), this.data[r];
        if (A <= 65535)
          return r = this.index[is + (A - 55296 >> VA)], r = (r << Ir) + (A & mr), this.data[r];
        if (A < this.highStart)
          return r = Go - Ro + (A >> gt), r = this.index[r], r += A >> VA & No, r = this.index[r], r = (r << Ir) + (A & mr), this.data[r];
        if (A <= 1114111)
          return this.data[this.highValueIndex];
      }
      return this.errorValue;
    }, e;
  }()
), Wt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", ko = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
for (var Ne = 0; Ne < Wt.length; Ne++)
  ko[Wt.charCodeAt(Ne)] = Ne;
var Jo = 1, yr = 2, Kr = 3, Yt = 4, Zt = 5, Wo = 7, qt = 8, Lr = 9, br = 10, zt = 11, jt = 12, $t = 13, An = 14, Dr = 15, Yo = function(e) {
  for (var A = [], r = 0, t = e.length; r < t; ) {
    var n = e.charCodeAt(r++);
    if (n >= 55296 && n <= 56319 && r < t) {
      var s = e.charCodeAt(r++);
      (s & 64512) === 56320 ? A.push(((n & 1023) << 10) + (s & 1023) + 65536) : (A.push(n), r--);
    } else
      A.push(n);
  }
  return A;
}, Zo = function() {
  for (var e = [], A = 0; A < arguments.length; A++)
    e[A] = arguments[A];
  if (String.fromCodePoint)
    return String.fromCodePoint.apply(String, e);
  var r = e.length;
  if (!r)
    return "";
  for (var t = [], n = -1, s = ""; ++n < r; ) {
    var B = e[n];
    B <= 65535 ? t.push(B) : (B -= 65536, t.push((B >> 10) + 55296, B % 1024 + 56320)), (n + 1 === r || t.length > 16384) && (s += String.fromCharCode.apply(String, t), t.length = 0);
  }
  return s;
}, qo = _o(yo), eA = "×", xr = "÷", zo = function(e) {
  return qo.get(e);
}, jo = function(e, A, r) {
  var t = r - 2, n = A[t], s = A[r - 1], B = A[r];
  if (s === yr && B === Kr)
    return eA;
  if (s === yr || s === Kr || s === Yt || B === yr || B === Kr || B === Yt)
    return xr;
  if (s === qt && [qt, Lr, zt, jt].indexOf(B) !== -1 || (s === zt || s === Lr) && (B === Lr || B === br) || (s === jt || s === br) && B === br || B === $t || B === Zt || B === Wo || s === Jo)
    return eA;
  if (s === $t && B === An) {
    for (; n === Zt; )
      n = A[--t];
    if (n === An)
      return eA;
  }
  if (s === Dr && B === Dr) {
    for (var i = 0; n === Dr; )
      i++, n = A[--t];
    if (i % 2 === 0)
      return eA;
  }
  return xr;
}, $o = function(e) {
  var A = Yo(e), r = A.length, t = 0, n = 0, s = A.map(zo);
  return {
    next: function() {
      if (t >= r)
        return { done: !0, value: null };
      for (var B = eA; t < r && (B = jo(A, s, ++t)) === eA; )
        ;
      if (B !== eA || t === r) {
        var i = Zo.apply(null, A.slice(n, t));
        return n = t, { value: i, done: !1 };
      }
      return { done: !0, value: null };
    }
  };
}, Ac = function(e) {
  for (var A = $o(e), r = [], t; !(t = A.next()).done; )
    t.value && r.push(t.value.slice());
  return r;
}, ec = function(e) {
  var A = 123;
  if (e.createRange) {
    var r = e.createRange();
    if (r.getBoundingClientRect) {
      var t = e.createElement("boundtest");
      t.style.height = A + "px", t.style.display = "block", e.body.appendChild(t), r.selectNode(t);
      var n = r.getBoundingClientRect(), s = Math.round(n.height);
      if (e.body.removeChild(t), s === A)
        return !0;
    }
  }
  return !1;
}, rc = function(e) {
  var A = e.createElement("boundtest");
  A.style.width = "50px", A.style.display = "block", A.style.fontSize = "12px", A.style.letterSpacing = "0px", A.style.wordSpacing = "0px", e.body.appendChild(A);
  var r = e.createRange();
  A.innerHTML = typeof "".repeat == "function" ? "&#128104;".repeat(10) : "";
  var t = A.firstChild, n = or(t.data).map(function(a) {
    return N(a);
  }), s = 0, B = {}, i = n.every(function(a, o) {
    r.setStart(t, s), r.setEnd(t, s + a.length);
    var c = r.getBoundingClientRect();
    s += a.length;
    var l = c.x > B.x || c.y > B.y;
    return B = c, o === 0 ? !0 : l;
  });
  return e.body.removeChild(A), i;
}, tc = function() {
  return typeof new Image().crossOrigin < "u";
}, nc = function() {
  return typeof new XMLHttpRequest().responseType == "string";
}, sc = function(e) {
  var A = new Image(), r = e.createElement("canvas"), t = r.getContext("2d");
  if (!t)
    return !1;
  A.src = "data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>";
  try {
    t.drawImage(A, 0, 0), r.toDataURL();
  } catch (n) {
    return !1;
  }
  return !0;
}, en = function(e) {
  return e[0] === 0 && e[1] === 255 && e[2] === 0 && e[3] === 255;
}, Bc = function(e) {
  var A = e.createElement("canvas"), r = 100;
  A.width = r, A.height = r;
  var t = A.getContext("2d");
  if (!t)
    return Promise.reject(!1);
  t.fillStyle = "rgb(0, 255, 0)", t.fillRect(0, 0, r, r);
  var n = new Image(), s = A.toDataURL();
  n.src = s;
  var B = et(r, r, 0, 0, n);
  return t.fillStyle = "red", t.fillRect(0, 0, r, r), rn(B).then(function(i) {
    t.drawImage(i, 0, 0);
    var a = t.getImageData(0, 0, r, r).data;
    t.fillStyle = "red", t.fillRect(0, 0, r, r);
    var o = e.createElement("div");
    return o.style.backgroundImage = "url(" + s + ")", o.style.height = r + "px", en(a) ? rn(et(r, r, 0, 0, o)) : Promise.reject(!1);
  }).then(function(i) {
    return t.drawImage(i, 0, 0), en(t.getImageData(0, 0, r, r).data);
  }).catch(function() {
    return !1;
  });
}, et = function(e, A, r, t, n) {
  var s = "http://www.w3.org/2000/svg", B = document.createElementNS(s, "svg"), i = document.createElementNS(s, "foreignObject");
  return B.setAttributeNS(null, "width", e.toString()), B.setAttributeNS(null, "height", A.toString()), i.setAttributeNS(null, "width", "100%"), i.setAttributeNS(null, "height", "100%"), i.setAttributeNS(null, "x", r.toString()), i.setAttributeNS(null, "y", t.toString()), i.setAttributeNS(null, "externalResourcesRequired", "true"), B.appendChild(i), i.appendChild(n), B;
}, rn = function(e) {
  return new Promise(function(A, r) {
    var t = new Image();
    t.onload = function() {
      return A(t);
    }, t.onerror = r, t.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(new XMLSerializer().serializeToString(e));
  });
}, k = {
  get SUPPORT_RANGE_BOUNDS() {
    var e = ec(document);
    return Object.defineProperty(k, "SUPPORT_RANGE_BOUNDS", { value: e }), e;
  },
  get SUPPORT_WORD_BREAKING() {
    var e = k.SUPPORT_RANGE_BOUNDS && rc(document);
    return Object.defineProperty(k, "SUPPORT_WORD_BREAKING", { value: e }), e;
  },
  get SUPPORT_SVG_DRAWING() {
    var e = sc(document);
    return Object.defineProperty(k, "SUPPORT_SVG_DRAWING", { value: e }), e;
  },
  get SUPPORT_FOREIGNOBJECT_DRAWING() {
    var e = typeof Array.from == "function" && typeof window.fetch == "function" ? Bc(document) : Promise.resolve(!1);
    return Object.defineProperty(k, "SUPPORT_FOREIGNOBJECT_DRAWING", { value: e }), e;
  },
  get SUPPORT_CORS_IMAGES() {
    var e = tc();
    return Object.defineProperty(k, "SUPPORT_CORS_IMAGES", { value: e }), e;
  },
  get SUPPORT_RESPONSE_TYPE() {
    var e = nc();
    return Object.defineProperty(k, "SUPPORT_RESPONSE_TYPE", { value: e }), e;
  },
  get SUPPORT_CORS_XHR() {
    var e = "withCredentials" in new XMLHttpRequest();
    return Object.defineProperty(k, "SUPPORT_CORS_XHR", { value: e }), e;
  },
  get SUPPORT_NATIVE_TEXT_SEGMENTATION() {
    var e = !!(typeof Intl < "u" && Intl.Segmenter);
    return Object.defineProperty(k, "SUPPORT_NATIVE_TEXT_SEGMENTATION", { value: e }), e;
  }
}, fe = (
  /** @class */
  function() {
    function e(A, r) {
      this.text = A, this.bounds = r;
    }
    return e;
  }()
), ic = function(e, A, r, t) {
  var n = cc(A, r), s = [], B = 0;
  return n.forEach(function(i) {
    if (r.textDecorationLine.length || i.trim().length > 0)
      if (k.SUPPORT_RANGE_BOUNDS) {
        var a = tn(t, B, i.length).getClientRects();
        if (a.length > 1) {
          var o = wt(i), c = 0;
          o.forEach(function(Q) {
            s.push(new fe(Q, FA.fromDOMRectList(e, tn(t, c + B, Q.length).getClientRects()))), c += Q.length;
          });
        } else
          s.push(new fe(i, FA.fromDOMRectList(e, a)));
      } else {
        var l = t.splitText(i.length);
        s.push(new fe(i, ac(e, t))), t = l;
      }
    else
      k.SUPPORT_RANGE_BOUNDS || (t = t.splitText(i.length));
    B += i.length;
  }), s;
}, ac = function(e, A) {
  var r = A.ownerDocument;
  if (r) {
    var t = r.createElement("html2canvaswrapper");
    t.appendChild(A.cloneNode(!0));
    var n = A.parentNode;
    if (n) {
      n.replaceChild(t, A);
      var s = ar(e, t);
      return t.firstChild && n.replaceChild(t.firstChild, t), s;
    }
  }
  return FA.EMPTY;
}, tn = function(e, A, r) {
  var t = e.ownerDocument;
  if (!t)
    throw new Error("Node has no owner document");
  var n = t.createRange();
  return n.setStart(e, A), n.setEnd(e, A + r), n;
}, wt = function(e) {
  if (k.SUPPORT_NATIVE_TEXT_SEGMENTATION) {
    var A = new Intl.Segmenter(void 0, { granularity: "grapheme" });
    return Array.from(A.segment(e)).map(function(r) {
      return r.segment;
    });
  }
  return Ac(e);
}, oc = function(e, A) {
  if (k.SUPPORT_NATIVE_TEXT_SEGMENTATION) {
    var r = new Intl.Segmenter(void 0, {
      granularity: "word"
    });
    return Array.from(r.segment(e)).map(function(t) {
      return t.segment;
    });
  }
  return Qc(e, A);
}, cc = function(e, A) {
  return A.letterSpacing !== 0 ? wt(e) : oc(e, A);
}, lc = [32, 160, 4961, 65792, 65793, 4153, 4241], Qc = function(e, A) {
  for (var r = GB(e, {
    lineBreak: A.lineBreak,
    wordBreak: A.overflowWrap === "break-word" ? "break-word" : A.wordBreak
  }), t = [], n, s = function() {
    if (n.value) {
      var B = n.value.slice(), i = or(B), a = "";
      i.forEach(function(o) {
        lc.indexOf(o) === -1 ? a += N(o) : (a.length && t.push(a), t.push(N(o)), a = "");
      }), a.length && t.push(a);
    }
  }; !(n = r.next()).done; )
    s();
  return t;
}, gc = (
  /** @class */
  function() {
    function e(A, r, t) {
      this.text = wc(r.data, t.textTransform), this.textBounds = ic(A, this.text, t, r);
    }
    return e;
  }()
), wc = function(e, A) {
  switch (A) {
    case 1:
      return e.toLowerCase();
    case 3:
      return e.replace(uc, fc);
    case 2:
      return e.toUpperCase();
    default:
      return e;
  }
}, uc = /(^|\s|:|-|\(|\))([a-z])/g, fc = function(e, A, r) {
  return e.length > 0 ? A + r.toUpperCase() : e;
}, as = (
  /** @class */
  function(e) {
    iA(A, e);
    function A(r, t) {
      var n = e.call(this, r, t) || this;
      return n.src = t.currentSrc || t.src, n.intrinsicWidth = t.naturalWidth, n.intrinsicHeight = t.naturalHeight, n.context.cache.addImage(n.src), n;
    }
    return A;
  }(QA)
), os = (
  /** @class */
  function(e) {
    iA(A, e);
    function A(r, t) {
      var n = e.call(this, r, t) || this;
      return n.canvas = t, n.intrinsicWidth = t.width, n.intrinsicHeight = t.height, n;
    }
    return A;
  }(QA)
), cs = (
  /** @class */
  function(e) {
    iA(A, e);
    function A(r, t) {
      var n = e.call(this, r, t) || this, s = new XMLSerializer(), B = ar(r, t);
      return t.setAttribute("width", B.width + "px"), t.setAttribute("height", B.height + "px"), n.svg = "data:image/svg+xml," + encodeURIComponent(s.serializeToString(t)), n.intrinsicWidth = t.width.baseVal.value, n.intrinsicHeight = t.height.baseVal.value, n.context.cache.addImage(n.svg), n;
    }
    return A;
  }(QA)
), ls = (
  /** @class */
  function(e) {
    iA(A, e);
    function A(r, t) {
      var n = e.call(this, r, t) || this;
      return n.value = t.value, n;
    }
    return A;
  }(QA)
), rt = (
  /** @class */
  function(e) {
    iA(A, e);
    function A(r, t) {
      var n = e.call(this, r, t) || this;
      return n.start = t.start, n.reversed = typeof t.reversed == "boolean" && t.reversed === !0, n;
    }
    return A;
  }(QA)
), Cc = [
  {
    type: 15,
    flags: 0,
    unit: "px",
    number: 3
  }
], Uc = [
  {
    type: 16,
    flags: 0,
    number: 50
  }
], Fc = function(e) {
  return e.width > e.height ? new FA(e.left + (e.width - e.height) / 2, e.top, e.height, e.height) : e.width < e.height ? new FA(e.left, e.top + (e.height - e.width) / 2, e.width, e.width) : e;
}, hc = function(e) {
  var A = e.type === dc ? new Array(e.value.length + 1).join("•") : e.value;
  return A.length === 0 ? e.placeholder || "" : A;
}, $e = "checkbox", Ar = "radio", dc = "password", nn = 707406591, ut = (
  /** @class */
  function(e) {
    iA(A, e);
    function A(r, t) {
      var n = e.call(this, r, t) || this;
      switch (n.type = t.type.toLowerCase(), n.checked = t.checked, n.value = hc(t), (n.type === $e || n.type === Ar) && (n.styles.backgroundColor = 3739148031, n.styles.borderTopColor = n.styles.borderRightColor = n.styles.borderBottomColor = n.styles.borderLeftColor = 2779096575, n.styles.borderTopWidth = n.styles.borderRightWidth = n.styles.borderBottomWidth = n.styles.borderLeftWidth = 1, n.styles.borderTopStyle = n.styles.borderRightStyle = n.styles.borderBottomStyle = n.styles.borderLeftStyle = 1, n.styles.backgroundClip = [
        0
        /* BORDER_BOX */
      ], n.styles.backgroundOrigin = [
        0
        /* BORDER_BOX */
      ], n.bounds = Fc(n.bounds)), n.type) {
        case $e:
          n.styles.borderTopRightRadius = n.styles.borderTopLeftRadius = n.styles.borderBottomRightRadius = n.styles.borderBottomLeftRadius = Cc;
          break;
        case Ar:
          n.styles.borderTopRightRadius = n.styles.borderTopLeftRadius = n.styles.borderBottomRightRadius = n.styles.borderBottomLeftRadius = Uc;
          break;
      }
      return n;
    }
    return A;
  }(QA)
), Qs = (
  /** @class */
  function(e) {
    iA(A, e);
    function A(r, t) {
      var n = e.call(this, r, t) || this, s = t.options[t.selectedIndex || 0];
      return n.value = s && s.text || "", n;
    }
    return A;
  }(QA)
), gs = (
  /** @class */
  function(e) {
    iA(A, e);
    function A(r, t) {
      var n = e.call(this, r, t) || this;
      return n.value = t.value, n;
    }
    return A;
  }(QA)
), ws = (
  /** @class */
  function(e) {
    iA(A, e);
    function A(r, t) {
      var n = e.call(this, r, t) || this;
      n.src = t.src, n.width = parseInt(t.width, 10) || 0, n.height = parseInt(t.height, 10) || 0, n.backgroundColor = n.styles.backgroundColor;
      try {
        if (t.contentWindow && t.contentWindow.document && t.contentWindow.document.documentElement) {
          n.tree = fs(r, t.contentWindow.document.documentElement);
          var s = t.contentWindow.document.documentElement ? we(r, getComputedStyle(t.contentWindow.document.documentElement).backgroundColor) : UA.TRANSPARENT, B = t.contentWindow.document.body ? we(r, getComputedStyle(t.contentWindow.document.body).backgroundColor) : UA.TRANSPARENT;
          n.backgroundColor = LA(s) ? LA(B) ? n.styles.backgroundColor : B : s;
        }
      } catch (i) {
      }
      return n;
    }
    return A;
  }(QA)
), pc = ["OL", "UL", "MENU"], Ye = function(e, A, r, t) {
  for (var n = A.firstChild, s = void 0; n; n = s)
    if (s = n.nextSibling, Cs(n) && n.data.trim().length > 0)
      r.textNodes.push(new gc(e, n, r.styles));
    else if (qA(n))
      if (ds(n) && n.assignedNodes)
        n.assignedNodes().forEach(function(i) {
          return Ye(e, i, r, t);
        });
      else {
        var B = us(e, n);
        B.styles.isVisible() && (Ec(n, B, t) ? B.flags |= 4 : Hc(B.styles) && (B.flags |= 2), pc.indexOf(n.tagName) !== -1 && (B.flags |= 8), r.elements.push(B), n.slot, n.shadowRoot ? Ye(e, n.shadowRoot, B, t) : !er(n) && !Us(n) && !rr(n) && Ye(e, n, B, t));
      }
}, us = function(e, A) {
  return nt(A) ? new as(e, A) : Fs(A) ? new os(e, A) : Us(A) ? new cs(e, A) : vc(A) ? new ls(e, A) : Ic(A) ? new rt(e, A) : mc(A) ? new ut(e, A) : rr(A) ? new Qs(e, A) : er(A) ? new gs(e, A) : hs(A) ? new ws(e, A) : new QA(e, A);
}, fs = function(e, A) {
  var r = us(e, A);
  return r.flags |= 4, Ye(e, A, r, r), r;
}, Ec = function(e, A, r) {
  return A.styles.isPositionedWithZIndex() || A.styles.opacity < 1 || A.styles.isTransformed() || ft(e) && r.styles.isTransparent();
}, Hc = function(e) {
  return e.isPositioned() || e.isFloating();
}, Cs = function(e) {
  return e.nodeType === Node.TEXT_NODE;
}, qA = function(e) {
  return e.nodeType === Node.ELEMENT_NODE;
}, tt = function(e) {
  return qA(e) && typeof e.style < "u" && !Ze(e);
}, Ze = function(e) {
  return typeof e.className == "object";
}, vc = function(e) {
  return e.tagName === "LI";
}, Ic = function(e) {
  return e.tagName === "OL";
}, mc = function(e) {
  return e.tagName === "INPUT";
}, yc = function(e) {
  return e.tagName === "HTML";
}, Us = function(e) {
  return e.tagName === "svg";
}, ft = function(e) {
  return e.tagName === "BODY";
}, Fs = function(e) {
  return e.tagName === "CANVAS";
}, sn = function(e) {
  return e.tagName === "VIDEO";
}, nt = function(e) {
  return e.tagName === "IMG";
}, hs = function(e) {
  return e.tagName === "IFRAME";
}, Bn = function(e) {
  return e.tagName === "STYLE";
}, Kc = function(e) {
  return e.tagName === "SCRIPT";
}, er = function(e) {
  return e.tagName === "TEXTAREA";
}, rr = function(e) {
  return e.tagName === "SELECT";
}, ds = function(e) {
  return e.tagName === "SLOT";
}, an = function(e) {
  return e.tagName.indexOf("-") > 0;
}, Lc = (
  /** @class */
  function() {
    function e() {
      this.counters = {};
    }
    return e.prototype.getCounterValue = function(A) {
      var r = this.counters[A];
      return r && r.length ? r[r.length - 1] : 1;
    }, e.prototype.getCounterValues = function(A) {
      var r = this.counters[A];
      return r || [];
    }, e.prototype.pop = function(A) {
      var r = this;
      A.forEach(function(t) {
        return r.counters[t].pop();
      });
    }, e.prototype.parse = function(A) {
      var r = this, t = A.counterIncrement, n = A.counterReset, s = !0;
      t !== null && t.forEach(function(i) {
        var a = r.counters[i.counter];
        a && i.increment !== 0 && (s = !1, a.length || a.push(1), a[Math.max(0, a.length - 1)] += i.increment);
      });
      var B = [];
      return s && n.forEach(function(i) {
        var a = r.counters[i.counter];
        B.push(i.counter), a || (a = r.counters[i.counter] = []), a.push(i.reset);
      }), B;
    }, e;
  }()
), on = {
  integers: [1e3, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1],
  values: ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"]
}, cn = {
  integers: [
    9e3,
    8e3,
    7e3,
    6e3,
    5e3,
    4e3,
    3e3,
    2e3,
    1e3,
    900,
    800,
    700,
    600,
    500,
    400,
    300,
    200,
    100,
    90,
    80,
    70,
    60,
    50,
    40,
    30,
    20,
    10,
    9,
    8,
    7,
    6,
    5,
    4,
    3,
    2,
    1
  ],
  values: [
    "Ք",
    "Փ",
    "Ւ",
    "Ց",
    "Ր",
    "Տ",
    "Վ",
    "Ս",
    "Ռ",
    "Ջ",
    "Պ",
    "Չ",
    "Ո",
    "Շ",
    "Ն",
    "Յ",
    "Մ",
    "Ճ",
    "Ղ",
    "Ձ",
    "Հ",
    "Կ",
    "Ծ",
    "Խ",
    "Լ",
    "Ի",
    "Ժ",
    "Թ",
    "Ը",
    "Է",
    "Զ",
    "Ե",
    "Դ",
    "Գ",
    "Բ",
    "Ա"
  ]
}, bc = {
  integers: [
    1e4,
    9e3,
    8e3,
    7e3,
    6e3,
    5e3,
    4e3,
    3e3,
    2e3,
    1e3,
    400,
    300,
    200,
    100,
    90,
    80,
    70,
    60,
    50,
    40,
    30,
    20,
    19,
    18,
    17,
    16,
    15,
    10,
    9,
    8,
    7,
    6,
    5,
    4,
    3,
    2,
    1
  ],
  values: [
    "י׳",
    "ט׳",
    "ח׳",
    "ז׳",
    "ו׳",
    "ה׳",
    "ד׳",
    "ג׳",
    "ב׳",
    "א׳",
    "ת",
    "ש",
    "ר",
    "ק",
    "צ",
    "פ",
    "ע",
    "ס",
    "נ",
    "מ",
    "ל",
    "כ",
    "יט",
    "יח",
    "יז",
    "טז",
    "טו",
    "י",
    "ט",
    "ח",
    "ז",
    "ו",
    "ה",
    "ד",
    "ג",
    "ב",
    "א"
  ]
}, Dc = {
  integers: [
    1e4,
    9e3,
    8e3,
    7e3,
    6e3,
    5e3,
    4e3,
    3e3,
    2e3,
    1e3,
    900,
    800,
    700,
    600,
    500,
    400,
    300,
    200,
    100,
    90,
    80,
    70,
    60,
    50,
    40,
    30,
    20,
    10,
    9,
    8,
    7,
    6,
    5,
    4,
    3,
    2,
    1
  ],
  values: [
    "ჵ",
    "ჰ",
    "ჯ",
    "ჴ",
    "ხ",
    "ჭ",
    "წ",
    "ძ",
    "ც",
    "ჩ",
    "შ",
    "ყ",
    "ღ",
    "ქ",
    "ფ",
    "ჳ",
    "ტ",
    "ს",
    "რ",
    "ჟ",
    "პ",
    "ო",
    "ჲ",
    "ნ",
    "მ",
    "ლ",
    "კ",
    "ი",
    "თ",
    "ჱ",
    "ზ",
    "ვ",
    "ე",
    "დ",
    "გ",
    "ბ",
    "ა"
  ]
}, kA = function(e, A, r, t, n, s) {
  return e < A || e > r ? he(e, n, s.length > 0) : t.integers.reduce(function(B, i, a) {
    for (; e >= i; )
      e -= i, B += t.values[a];
    return B;
  }, "") + s;
}, ps = function(e, A, r, t) {
  var n = "";
  do
    r || e--, n = t(e) + n, e /= A;
  while (e * A >= A);
  return n;
}, V = function(e, A, r, t, n) {
  var s = r - A + 1;
  return (e < 0 ? "-" : "") + (ps(Math.abs(e), s, t, function(B) {
    return N(Math.floor(B % s) + A);
  }) + n);
}, OA = function(e, A, r) {
  r === void 0 && (r = ". ");
  var t = A.length;
  return ps(Math.abs(e), t, !1, function(n) {
    return A[Math.floor(n % t)];
  }) + r;
}, YA = 1 << 0, EA = 1 << 1, HA = 1 << 2, le = 1 << 3, fA = function(e, A, r, t, n, s) {
  if (e < -9999 || e > 9999)
    return he(e, 4, n.length > 0);
  var B = Math.abs(e), i = n;
  if (B === 0)
    return A[0] + i;
  for (var a = 0; B > 0 && a <= 4; a++) {
    var o = B % 10;
    o === 0 && _(s, YA) && i !== "" ? i = A[o] + i : o > 1 || o === 1 && a === 0 || o === 1 && a === 1 && _(s, EA) || o === 1 && a === 1 && _(s, HA) && e > 100 || o === 1 && a > 1 && _(s, le) ? i = A[o] + (a > 0 ? r[a - 1] : "") + i : o === 1 && a > 0 && (i = r[a - 1] + i), B = Math.floor(B / 10);
  }
  return (e < 0 ? t : "") + i;
}, ln = "十百千萬", Qn = "拾佰仟萬", gn = "マイナス", Sr = "마이너스", he = function(e, A, r) {
  var t = r ? ". " : "", n = r ? "、" : "", s = r ? ", " : "", B = r ? " " : "";
  switch (A) {
    case 0:
      return "•" + B;
    case 1:
      return "◦" + B;
    case 2:
      return "◾" + B;
    case 5:
      var i = V(e, 48, 57, !0, t);
      return i.length < 4 ? "0" + i : i;
    case 4:
      return OA(e, "〇一二三四五六七八九", n);
    case 6:
      return kA(e, 1, 3999, on, 3, t).toLowerCase();
    case 7:
      return kA(e, 1, 3999, on, 3, t);
    case 8:
      return V(e, 945, 969, !1, t);
    case 9:
      return V(e, 97, 122, !1, t);
    case 10:
      return V(e, 65, 90, !1, t);
    case 11:
      return V(e, 1632, 1641, !0, t);
    case 12:
    case 49:
      return kA(e, 1, 9999, cn, 3, t);
    case 35:
      return kA(e, 1, 9999, cn, 3, t).toLowerCase();
    case 13:
      return V(e, 2534, 2543, !0, t);
    case 14:
    case 30:
      return V(e, 6112, 6121, !0, t);
    case 15:
      return OA(e, "子丑寅卯辰巳午未申酉戌亥", n);
    case 16:
      return OA(e, "甲乙丙丁戊己庚辛壬癸", n);
    case 17:
    case 48:
      return fA(e, "零一二三四五六七八九", ln, "負", n, EA | HA | le);
    case 47:
      return fA(e, "零壹貳參肆伍陸柒捌玖", Qn, "負", n, YA | EA | HA | le);
    case 42:
      return fA(e, "零一二三四五六七八九", ln, "负", n, EA | HA | le);
    case 41:
      return fA(e, "零壹贰叁肆伍陆柒捌玖", Qn, "负", n, YA | EA | HA | le);
    case 26:
      return fA(e, "〇一二三四五六七八九", "十百千万", gn, n, 0);
    case 25:
      return fA(e, "零壱弐参四伍六七八九", "拾百千万", gn, n, YA | EA | HA);
    case 31:
      return fA(e, "영일이삼사오육칠팔구", "십백천만", Sr, s, YA | EA | HA);
    case 33:
      return fA(e, "零一二三四五六七八九", "十百千萬", Sr, s, 0);
    case 32:
      return fA(e, "零壹貳參四五六七八九", "拾百千", Sr, s, YA | EA | HA);
    case 18:
      return V(e, 2406, 2415, !0, t);
    case 20:
      return kA(e, 1, 19999, Dc, 3, t);
    case 21:
      return V(e, 2790, 2799, !0, t);
    case 22:
      return V(e, 2662, 2671, !0, t);
    case 22:
      return kA(e, 1, 10999, bc, 3, t);
    case 23:
      return OA(e, "あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん");
    case 24:
      return OA(e, "いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす");
    case 27:
      return V(e, 3302, 3311, !0, t);
    case 28:
      return OA(e, "アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン", n);
    case 29:
      return OA(e, "イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス", n);
    case 34:
      return V(e, 3792, 3801, !0, t);
    case 37:
      return V(e, 6160, 6169, !0, t);
    case 38:
      return V(e, 4160, 4169, !0, t);
    case 39:
      return V(e, 2918, 2927, !0, t);
    case 40:
      return V(e, 1776, 1785, !0, t);
    case 43:
      return V(e, 3046, 3055, !0, t);
    case 44:
      return V(e, 3174, 3183, !0, t);
    case 45:
      return V(e, 3664, 3673, !0, t);
    case 46:
      return V(e, 3872, 3881, !0, t);
    case 3:
    default:
      return V(e, 48, 57, !0, t);
  }
}, Es = "data-html2canvas-ignore", wn = (
  /** @class */
  function() {
    function e(A, r, t) {
      if (this.context = A, this.options = t, this.scrolledElements = [], this.referenceElement = r, this.counters = new Lc(), this.quoteDepth = 0, !r.ownerDocument)
        throw new Error("Cloned element does not have an owner document");
      this.documentElement = this.cloneNode(r.ownerDocument.documentElement, !1);
    }
    return e.prototype.toIFrame = function(A, r) {
      var t = this, n = xc(A, r);
      if (!n.contentWindow)
        return Promise.reject("Unable to find iframe window");
      var s = A.defaultView.pageXOffset, B = A.defaultView.pageYOffset, i = n.contentWindow, a = i.document, o = Oc(n).then(function() {
        return z(t, void 0, void 0, function() {
          var c, l;
          return Y(this, function(Q) {
            switch (Q.label) {
              case 0:
                return this.scrolledElements.forEach(Vc), i && (i.scrollTo(r.left, r.top), /(iPad|iPhone|iPod)/g.test(navigator.userAgent) && (i.scrollY !== r.top || i.scrollX !== r.left) && (this.context.logger.warn("Unable to restore scroll position for cloned document"), this.context.windowBounds = this.context.windowBounds.add(i.scrollX - r.left, i.scrollY - r.top, 0, 0))), c = this.options.onclone, l = this.clonedReferenceElement, typeof l > "u" ? [2, Promise.reject("Error finding the " + this.referenceElement.nodeName + " in the cloned document")] : a.fonts && a.fonts.ready ? [4, a.fonts.ready] : [3, 2];
              case 1:
                Q.sent(), Q.label = 2;
              case 2:
                return /(AppleWebKit)/g.test(navigator.userAgent) ? [4, Tc(a)] : [3, 4];
              case 3:
                Q.sent(), Q.label = 4;
              case 4:
                return typeof c == "function" ? [2, Promise.resolve().then(function() {
                  return c(a, l);
                }).then(function() {
                  return n;
                })] : [2, n];
            }
          });
        });
      });
      return a.open(), a.write(Gc(document.doctype) + "<html></html>"), Rc(this.referenceElement.ownerDocument, s, B), a.replaceChild(a.adoptNode(this.documentElement), a.documentElement), a.close(), o;
    }, e.prototype.createElementClone = function(A) {
      if (At(
        A,
        2
        /* CLONE */
      ))
        debugger;
      if (Fs(A))
        return this.createCanvasClone(A);
      if (sn(A))
        return this.createVideoClone(A);
      if (Bn(A))
        return this.createStyleClone(A);
      var r = A.cloneNode(!1);
      return nt(r) && (nt(A) && A.currentSrc && A.currentSrc !== A.src && (r.src = A.currentSrc, r.srcset = ""), r.loading === "lazy" && (r.loading = "eager")), an(r) ? this.createCustomElementClone(r) : r;
    }, e.prototype.createCustomElementClone = function(A) {
      var r = document.createElement("html2canvascustomelement");
      return Tr(A.style, r), r;
    }, e.prototype.createStyleClone = function(A) {
      try {
        var r = A.sheet;
        if (r && r.cssRules) {
          var t = [].slice.call(r.cssRules, 0).reduce(function(s, B) {
            return B && typeof B.cssText == "string" ? s + B.cssText : s;
          }, ""), n = A.cloneNode(!1);
          return n.textContent = t, n;
        }
      } catch (s) {
        if (this.context.logger.error("Unable to access cssRules property", s), s.name !== "SecurityError")
          throw s;
      }
      return A.cloneNode(!1);
    }, e.prototype.createCanvasClone = function(A) {
      var r;
      if (this.options.inlineImages && A.ownerDocument) {
        var t = A.ownerDocument.createElement("img");
        try {
          return t.src = A.toDataURL(), t;
        } catch (o) {
          this.context.logger.info("Unable to inline canvas contents, canvas is tainted", A);
        }
      }
      var n = A.cloneNode(!1);
      try {
        n.width = A.width, n.height = A.height;
        var s = A.getContext("2d"), B = n.getContext("2d");
        if (B)
          if (!this.options.allowTaint && s)
            B.putImageData(s.getImageData(0, 0, A.width, A.height), 0, 0);
          else {
            var i = (r = A.getContext("webgl2")) !== null && r !== void 0 ? r : A.getContext("webgl");
            if (i) {
              var a = i.getContextAttributes();
              (a == null ? void 0 : a.preserveDrawingBuffer) === !1 && this.context.logger.warn("Unable to clone WebGL context as it has preserveDrawingBuffer=false", A);
            }
            B.drawImage(A, 0, 0);
          }
        return n;
      } catch (o) {
        this.context.logger.info("Unable to clone canvas as it is tainted", A);
      }
      return n;
    }, e.prototype.createVideoClone = function(A) {
      var r = A.ownerDocument.createElement("canvas");
      r.width = A.offsetWidth, r.height = A.offsetHeight;
      var t = r.getContext("2d");
      try {
        return t && (t.drawImage(A, 0, 0, r.width, r.height), this.options.allowTaint || t.getImageData(0, 0, r.width, r.height)), r;
      } catch (s) {
        this.context.logger.info("Unable to clone video as it is tainted", A);
      }
      var n = A.ownerDocument.createElement("canvas");
      return n.width = A.offsetWidth, n.height = A.offsetHeight, n;
    }, e.prototype.appendChildNode = function(A, r, t) {
      (!qA(r) || !Kc(r) && !r.hasAttribute(Es) && (typeof this.options.ignoreElements != "function" || !this.options.ignoreElements(r))) && (!this.options.copyStyles || !qA(r) || !Bn(r)) && A.appendChild(this.cloneNode(r, t));
    }, e.prototype.cloneChildNodes = function(A, r, t) {
      for (var n = this, s = A.shadowRoot ? A.shadowRoot.firstChild : A.firstChild; s; s = s.nextSibling)
        if (qA(s) && ds(s) && typeof s.assignedNodes == "function") {
          var B = s.assignedNodes();
          B.length && B.forEach(function(i) {
            return n.appendChildNode(r, i, t);
          });
        } else
          this.appendChildNode(r, s, t);
    }, e.prototype.cloneNode = function(A, r) {
      if (Cs(A))
        return document.createTextNode(A.data);
      if (!A.ownerDocument)
        return A.cloneNode(!1);
      var t = A.ownerDocument.defaultView;
      if (t && qA(A) && (tt(A) || Ze(A))) {
        var n = this.createElementClone(A);
        n.style.transitionProperty = "none";
        var s = t.getComputedStyle(A), B = t.getComputedStyle(A, ":before"), i = t.getComputedStyle(A, ":after");
        this.referenceElement === A && tt(n) && (this.clonedReferenceElement = n), ft(n) && _c(n);
        var a = this.counters.parse(new Xt(this.context, s)), o = this.resolvePseudoContent(A, n, B, Ce.BEFORE);
        an(A) && (r = !0), sn(A) || this.cloneChildNodes(A, n, r), o && n.insertBefore(o, n.firstChild);
        var c = this.resolvePseudoContent(A, n, i, Ce.AFTER);
        return c && n.appendChild(c), this.counters.pop(a), (s && (this.options.copyStyles || Ze(A)) && !hs(A) || r) && Tr(s, n), (A.scrollTop !== 0 || A.scrollLeft !== 0) && this.scrolledElements.push([n, A.scrollLeft, A.scrollTop]), (er(A) || rr(A)) && (er(n) || rr(n)) && (n.value = A.value), n;
      }
      return A.cloneNode(!1);
    }, e.prototype.resolvePseudoContent = function(A, r, t, n) {
      var s = this;
      if (t) {
        var B = t.content, i = r.ownerDocument;
        if (!(!i || !B || B === "none" || B === "-moz-alt-content" || t.display === "none")) {
          this.counters.parse(new Xt(this.context, t));
          var a = new vo(this.context, t), o = i.createElement("html2canvaspseudoelement");
          Tr(t, o), a.content.forEach(function(l) {
            if (l.type === 0)
              o.appendChild(i.createTextNode(l.value));
            else if (l.type === 22) {
              var Q = i.createElement("img");
              Q.src = l.value, Q.style.opacity = "1", o.appendChild(Q);
            } else if (l.type === 18) {
              if (l.name === "attr") {
                var f = l.values.filter(S);
                f.length && o.appendChild(i.createTextNode(A.getAttribute(f[0].value) || ""));
              } else if (l.name === "counter") {
                var g = l.values.filter(jA), w = g[0], E = g[1];
                if (w && S(w)) {
                  var C = s.counters.getCounterValue(w.value), h = E && S(E) ? $r.parse(s.context, E.value) : 3;
                  o.appendChild(i.createTextNode(he(C, h, !1)));
                }
              } else if (l.name === "counters") {
                var y = l.values.filter(jA), w = y[0], v = y[1], E = y[2];
                if (w && S(w)) {
                  var H = s.counters.getCounterValues(w.value), U = E && S(E) ? $r.parse(s.context, E.value) : 3, K = v && v.type === 0 ? v.value : "", L = H.map(function(m) {
                    return he(m, U, !1);
                  }).join(K);
                  o.appendChild(i.createTextNode(L));
                }
              }
            } else if (l.type === 20)
              switch (l.value) {
                case "open-quote":
                  o.appendChild(i.createTextNode(_t(a.quotes, s.quoteDepth++, !0)));
                  break;
                case "close-quote":
                  o.appendChild(i.createTextNode(_t(a.quotes, --s.quoteDepth, !1)));
                  break;
                default:
                  o.appendChild(i.createTextNode(l.value));
              }
          }), o.className = st + " " + Bt;
          var c = n === Ce.BEFORE ? " " + st : " " + Bt;
          return Ze(r) ? r.className.baseValue += c : r.className += c, o;
        }
      }
    }, e.destroy = function(A) {
      return A.parentNode ? (A.parentNode.removeChild(A), !0) : !1;
    }, e;
  }()
), Ce;
(function(e) {
  e[e.BEFORE = 0] = "BEFORE", e[e.AFTER = 1] = "AFTER";
})(Ce || (Ce = {}));
var xc = function(e, A) {
  var r = e.createElement("iframe");
  return r.className = "html2canvas-container", r.style.visibility = "hidden", r.style.position = "fixed", r.style.left = "-10000px", r.style.top = "0px", r.style.border = "0", r.width = A.width.toString(), r.height = A.height.toString(), r.scrolling = "no", r.setAttribute(Es, "true"), e.body.appendChild(r), r;
}, Sc = function(e) {
  return new Promise(function(A) {
    if (e.complete) {
      A();
      return;
    }
    if (!e.src) {
      A();
      return;
    }
    e.onload = A, e.onerror = A;
  });
}, Tc = function(e) {
  return Promise.all([].slice.call(e.images, 0).map(Sc));
}, Oc = function(e) {
  return new Promise(function(A, r) {
    var t = e.contentWindow;
    if (!t)
      return r("No window assigned for iframe");
    var n = t.document;
    t.onload = e.onload = function() {
      t.onload = e.onload = null;
      var s = setInterval(function() {
        n.body.childNodes.length > 0 && n.readyState === "complete" && (clearInterval(s), A(e));
      }, 50);
    };
  });
}, Mc = [
  "all",
  "d",
  "content"
  // Safari shows pseudoelements if content is set
], Tr = function(e, A) {
  for (var r = e.length - 1; r >= 0; r--) {
    var t = e.item(r);
    Mc.indexOf(t) === -1 && A.style.setProperty(t, e.getPropertyValue(t));
  }
  return A;
}, Gc = function(e) {
  var A = "";
  return e && (A += "<!DOCTYPE ", e.name && (A += e.name), e.internalSubset && (A += e.internalSubset), e.publicId && (A += '"' + e.publicId + '"'), e.systemId && (A += '"' + e.systemId + '"'), A += ">"), A;
}, Rc = function(e, A, r) {
  e && e.defaultView && (A !== e.defaultView.pageXOffset || r !== e.defaultView.pageYOffset) && e.defaultView.scrollTo(A, r);
}, Vc = function(e) {
  var A = e[0], r = e[1], t = e[2];
  A.scrollLeft = r, A.scrollTop = t;
}, Nc = ":before", Pc = ":after", st = "___html2canvas___pseudoelement_before", Bt = "___html2canvas___pseudoelement_after", un = `{
    content: "" !important;
    display: none !important;
}`, _c = function(e) {
  Xc(e, "." + st + Nc + un + `
         .` + Bt + Pc + un);
}, Xc = function(e, A) {
  var r = e.ownerDocument;
  if (r) {
    var t = r.createElement("style");
    t.textContent = A, e.appendChild(t);
  }
}, Hs = (
  /** @class */
  function() {
    function e() {
    }
    return e.getOrigin = function(A) {
      var r = e._link;
      return r ? (r.href = A, r.href = r.href, r.protocol + r.hostname + r.port) : "about:blank";
    }, e.isSameOrigin = function(A) {
      return e.getOrigin(A) === e._origin;
    }, e.setContext = function(A) {
      e._link = A.document.createElement("a"), e._origin = e.getOrigin(A.location.href);
    }, e._origin = "about:blank", e;
  }()
), kc = (
  /** @class */
  function() {
    function e(A, r) {
      this.context = A, this._options = r, this._cache = {};
    }
    return e.prototype.addImage = function(A) {
      var r = Promise.resolve();
      return this.has(A) || (Mr(A) || Zc(A)) && (this._cache[A] = this.loadImage(A)).catch(function() {
      }), r;
    }, e.prototype.match = function(A) {
      return this._cache[A];
    }, e.prototype.loadImage = function(A) {
      return z(this, void 0, void 0, function() {
        var r, t, n, s, B = this;
        return Y(this, function(i) {
          switch (i.label) {
            case 0:
              return r = Hs.isSameOrigin(A), t = !Or(A) && this._options.useCORS === !0 && k.SUPPORT_CORS_IMAGES && !r, n = !Or(A) && !r && !Mr(A) && typeof this._options.proxy == "string" && k.SUPPORT_CORS_XHR && !t, !r && this._options.allowTaint === !1 && !Or(A) && !Mr(A) && !n && !t ? [
                2
                /*return*/
              ] : (s = A, n ? [4, this.proxy(s)] : [3, 2]);
            case 1:
              s = i.sent(), i.label = 2;
            case 2:
              return this.context.logger.debug("Added image " + A.substring(0, 256)), [4, new Promise(function(a, o) {
                var c = new Image();
                c.onload = function() {
                  return a(c);
                }, c.onerror = o, (qc(s) || t) && (c.crossOrigin = "anonymous"), c.src = s, c.complete === !0 && setTimeout(function() {
                  return a(c);
                }, 500), B._options.imageTimeout > 0 && setTimeout(function() {
                  return o("Timed out (" + B._options.imageTimeout + "ms) loading image");
                }, B._options.imageTimeout);
              })];
            case 3:
              return [2, i.sent()];
          }
        });
      });
    }, e.prototype.has = function(A) {
      return typeof this._cache[A] < "u";
    }, e.prototype.keys = function() {
      return Promise.resolve(Object.keys(this._cache));
    }, e.prototype.proxy = function(A) {
      var r = this, t = this._options.proxy;
      if (!t)
        throw new Error("No proxy defined");
      var n = A.substring(0, 256);
      return new Promise(function(s, B) {
        var i = k.SUPPORT_RESPONSE_TYPE ? "blob" : "text", a = new XMLHttpRequest();
        a.onload = function() {
          if (a.status === 200)
            if (i === "text")
              s(a.response);
            else {
              var l = new FileReader();
              l.addEventListener("load", function() {
                return s(l.result);
              }, !1), l.addEventListener("error", function(Q) {
                return B(Q);
              }, !1), l.readAsDataURL(a.response);
            }
          else
            B("Failed to proxy resource " + n + " with status code " + a.status);
        }, a.onerror = B;
        var o = t.indexOf("?") > -1 ? "&" : "?";
        if (a.open("GET", "" + t + o + "url=" + encodeURIComponent(A) + "&responseType=" + i), i !== "text" && a instanceof XMLHttpRequest && (a.responseType = i), r._options.imageTimeout) {
          var c = r._options.imageTimeout;
          a.timeout = c, a.ontimeout = function() {
            return B("Timed out (" + c + "ms) proxying " + n);
          };
        }
        a.send();
      });
    }, e;
  }()
), Jc = /^data:image\/svg\+xml/i, Wc = /^data:image\/.*;base64,/i, Yc = /^data:image\/.*/i, Zc = function(e) {
  return k.SUPPORT_SVG_DRAWING || !zc(e);
}, Or = function(e) {
  return Yc.test(e);
}, qc = function(e) {
  return Wc.test(e);
}, Mr = function(e) {
  return e.substr(0, 4) === "blob";
}, zc = function(e) {
  return e.substr(-3).toLowerCase() === "svg" || Jc.test(e);
}, F = (
  /** @class */
  function() {
    function e(A, r) {
      this.type = 0, this.x = A, this.y = r;
    }
    return e.prototype.add = function(A, r) {
      return new e(this.x + A, this.y + r);
    }, e;
  }()
), JA = function(e, A, r) {
  return new F(e.x + (A.x - e.x) * r, e.y + (A.y - e.y) * r);
}, Pe = (
  /** @class */
  function() {
    function e(A, r, t, n) {
      this.type = 1, this.start = A, this.startControl = r, this.endControl = t, this.end = n;
    }
    return e.prototype.subdivide = function(A, r) {
      var t = JA(this.start, this.startControl, A), n = JA(this.startControl, this.endControl, A), s = JA(this.endControl, this.end, A), B = JA(t, n, A), i = JA(n, s, A), a = JA(B, i, A);
      return r ? new e(this.start, t, B, a) : new e(a, i, s, this.end);
    }, e.prototype.add = function(A, r) {
      return new e(this.start.add(A, r), this.startControl.add(A, r), this.endControl.add(A, r), this.end.add(A, r));
    }, e.prototype.reverse = function() {
      return new e(this.end, this.endControl, this.startControl, this.start);
    }, e;
  }()
), rA = function(e) {
  return e.type === 1;
}, jc = (
  /** @class */
  function() {
    function e(A) {
      var r = A.styles, t = A.bounds, n = oe(r.borderTopLeftRadius, t.width, t.height), s = n[0], B = n[1], i = oe(r.borderTopRightRadius, t.width, t.height), a = i[0], o = i[1], c = oe(r.borderBottomRightRadius, t.width, t.height), l = c[0], Q = c[1], f = oe(r.borderBottomLeftRadius, t.width, t.height), g = f[0], w = f[1], E = [];
      E.push((s + a) / t.width), E.push((g + l) / t.width), E.push((B + w) / t.height), E.push((o + Q) / t.height);
      var C = Math.max.apply(Math, E);
      C > 1 && (s /= C, B /= C, a /= C, o /= C, l /= C, Q /= C, g /= C, w /= C);
      var h = t.width - a, y = t.height - Q, v = t.width - l, H = t.height - w, U = r.borderTopWidth, K = r.borderRightWidth, L = r.borderBottomWidth, u = r.borderLeftWidth, p = O(r.paddingTop, A.bounds.width), m = O(r.paddingRight, A.bounds.width), D = O(r.paddingBottom, A.bounds.width), I = O(r.paddingLeft, A.bounds.width);
      this.topLeftBorderDoubleOuterBox = s > 0 || B > 0 ? M(t.left + u / 3, t.top + U / 3, s - u / 3, B - U / 3, x.TOP_LEFT) : new F(t.left + u / 3, t.top + U / 3), this.topRightBorderDoubleOuterBox = s > 0 || B > 0 ? M(t.left + h, t.top + U / 3, a - K / 3, o - U / 3, x.TOP_RIGHT) : new F(t.left + t.width - K / 3, t.top + U / 3), this.bottomRightBorderDoubleOuterBox = l > 0 || Q > 0 ? M(t.left + v, t.top + y, l - K / 3, Q - L / 3, x.BOTTOM_RIGHT) : new F(t.left + t.width - K / 3, t.top + t.height - L / 3), this.bottomLeftBorderDoubleOuterBox = g > 0 || w > 0 ? M(t.left + u / 3, t.top + H, g - u / 3, w - L / 3, x.BOTTOM_LEFT) : new F(t.left + u / 3, t.top + t.height - L / 3), this.topLeftBorderDoubleInnerBox = s > 0 || B > 0 ? M(t.left + u * 2 / 3, t.top + U * 2 / 3, s - u * 2 / 3, B - U * 2 / 3, x.TOP_LEFT) : new F(t.left + u * 2 / 3, t.top + U * 2 / 3), this.topRightBorderDoubleInnerBox = s > 0 || B > 0 ? M(t.left + h, t.top + U * 2 / 3, a - K * 2 / 3, o - U * 2 / 3, x.TOP_RIGHT) : new F(t.left + t.width - K * 2 / 3, t.top + U * 2 / 3), this.bottomRightBorderDoubleInnerBox = l > 0 || Q > 0 ? M(t.left + v, t.top + y, l - K * 2 / 3, Q - L * 2 / 3, x.BOTTOM_RIGHT) : new F(t.left + t.width - K * 2 / 3, t.top + t.height - L * 2 / 3), this.bottomLeftBorderDoubleInnerBox = g > 0 || w > 0 ? M(t.left + u * 2 / 3, t.top + H, g - u * 2 / 3, w - L * 2 / 3, x.BOTTOM_LEFT) : new F(t.left + u * 2 / 3, t.top + t.height - L * 2 / 3), this.topLeftBorderStroke = s > 0 || B > 0 ? M(t.left + u / 2, t.top + U / 2, s - u / 2, B - U / 2, x.TOP_LEFT) : new F(t.left + u / 2, t.top + U / 2), this.topRightBorderStroke = s > 0 || B > 0 ? M(t.left + h, t.top + U / 2, a - K / 2, o - U / 2, x.TOP_RIGHT) : new F(t.left + t.width - K / 2, t.top + U / 2), this.bottomRightBorderStroke = l > 0 || Q > 0 ? M(t.left + v, t.top + y, l - K / 2, Q - L / 2, x.BOTTOM_RIGHT) : new F(t.left + t.width - K / 2, t.top + t.height - L / 2), this.bottomLeftBorderStroke = g > 0 || w > 0 ? M(t.left + u / 2, t.top + H, g - u / 2, w - L / 2, x.BOTTOM_LEFT) : new F(t.left + u / 2, t.top + t.height - L / 2), this.topLeftBorderBox = s > 0 || B > 0 ? M(t.left, t.top, s, B, x.TOP_LEFT) : new F(t.left, t.top), this.topRightBorderBox = a > 0 || o > 0 ? M(t.left + h, t.top, a, o, x.TOP_RIGHT) : new F(t.left + t.width, t.top), this.bottomRightBorderBox = l > 0 || Q > 0 ? M(t.left + v, t.top + y, l, Q, x.BOTTOM_RIGHT) : new F(t.left + t.width, t.top + t.height), this.bottomLeftBorderBox = g > 0 || w > 0 ? M(t.left, t.top + H, g, w, x.BOTTOM_LEFT) : new F(t.left, t.top + t.height), this.topLeftPaddingBox = s > 0 || B > 0 ? M(t.left + u, t.top + U, Math.max(0, s - u), Math.max(0, B - U), x.TOP_LEFT) : new F(t.left + u, t.top + U), this.topRightPaddingBox = a > 0 || o > 0 ? M(t.left + Math.min(h, t.width - K), t.top + U, h > t.width + K ? 0 : Math.max(0, a - K), Math.max(0, o - U), x.TOP_RIGHT) : new F(t.left + t.width - K, t.top + U), this.bottomRightPaddingBox = l > 0 || Q > 0 ? M(t.left + Math.min(v, t.width - u), t.top + Math.min(y, t.height - L), Math.max(0, l - K), Math.max(0, Q - L), x.BOTTOM_RIGHT) : new F(t.left + t.width - K, t.top + t.height - L), this.bottomLeftPaddingBox = g > 0 || w > 0 ? M(t.left + u, t.top + Math.min(H, t.height - L), Math.max(0, g - u), Math.max(0, w - L), x.BOTTOM_LEFT) : new F(t.left + u, t.top + t.height - L), this.topLeftContentBox = s > 0 || B > 0 ? M(t.left + u + I, t.top + U + p, Math.max(0, s - (u + I)), Math.max(0, B - (U + p)), x.TOP_LEFT) : new F(t.left + u + I, t.top + U + p), this.topRightContentBox = a > 0 || o > 0 ? M(t.left + Math.min(h, t.width + u + I), t.top + U + p, h > t.width + u + I ? 0 : a - u + I, o - (U + p), x.TOP_RIGHT) : new F(t.left + t.width - (K + m), t.top + U + p), this.bottomRightContentBox = l > 0 || Q > 0 ? M(t.left + Math.min(v, t.width - (u + I)), t.top + Math.min(y, t.height + U + p), Math.max(0, l - (K + m)), Q - (L + D), x.BOTTOM_RIGHT) : new F(t.left + t.width - (K + m), t.top + t.height - (L + D)), this.bottomLeftContentBox = g > 0 || w > 0 ? M(t.left + u + I, t.top + H, Math.max(0, g - (u + I)), w - (L + D), x.BOTTOM_LEFT) : new F(t.left + u + I, t.top + t.height - (L + D));
    }
    return e;
  }()
), x;
(function(e) {
  e[e.TOP_LEFT = 0] = "TOP_LEFT", e[e.TOP_RIGHT = 1] = "TOP_RIGHT", e[e.BOTTOM_RIGHT = 2] = "BOTTOM_RIGHT", e[e.BOTTOM_LEFT = 3] = "BOTTOM_LEFT";
})(x || (x = {}));
var M = function(e, A, r, t, n) {
  var s = 4 * ((Math.sqrt(2) - 1) / 3), B = r * s, i = t * s, a = e + r, o = A + t;
  switch (n) {
    case x.TOP_LEFT:
      return new Pe(new F(e, o), new F(e, o - i), new F(a - B, A), new F(a, A));
    case x.TOP_RIGHT:
      return new Pe(new F(e, A), new F(e + B, A), new F(a, o - i), new F(a, o));
    case x.BOTTOM_RIGHT:
      return new Pe(new F(a, A), new F(a, A + i), new F(e + B, o), new F(e, o));
    case x.BOTTOM_LEFT:
    default:
      return new Pe(new F(a, o), new F(a - B, o), new F(e, A + i), new F(e, A));
  }
}, tr = function(e) {
  return [e.topLeftBorderBox, e.topRightBorderBox, e.bottomRightBorderBox, e.bottomLeftBorderBox];
}, $c = function(e) {
  return [
    e.topLeftContentBox,
    e.topRightContentBox,
    e.bottomRightContentBox,
    e.bottomLeftContentBox
  ];
}, nr = function(e) {
  return [
    e.topLeftPaddingBox,
    e.topRightPaddingBox,
    e.bottomRightPaddingBox,
    e.bottomLeftPaddingBox
  ];
}, Al = (
  /** @class */
  function() {
    function e(A, r, t) {
      this.offsetX = A, this.offsetY = r, this.matrix = t, this.type = 0, this.target = 6;
    }
    return e;
  }()
), _e = (
  /** @class */
  function() {
    function e(A, r) {
      this.path = A, this.target = r, this.type = 1;
    }
    return e;
  }()
), el = (
  /** @class */
  function() {
    function e(A) {
      this.opacity = A, this.type = 2, this.target = 6;
    }
    return e;
  }()
), rl = function(e) {
  return e.type === 0;
}, vs = function(e) {
  return e.type === 1;
}, tl = function(e) {
  return e.type === 2;
}, fn = function(e, A) {
  return e.length === A.length ? e.some(function(r, t) {
    return r === A[t];
  }) : !1;
}, nl = function(e, A, r, t, n) {
  return e.map(function(s, B) {
    switch (B) {
      case 0:
        return s.add(A, r);
      case 1:
        return s.add(A + t, r);
      case 2:
        return s.add(A + t, r + n);
      case 3:
        return s.add(A, r + n);
    }
    return s;
  });
}, Is = (
  /** @class */
  function() {
    function e(A) {
      this.element = A, this.inlineLevel = [], this.nonInlineLevel = [], this.negativeZIndex = [], this.zeroOrAutoZIndexOrTransformedOrOpacity = [], this.positiveZIndex = [], this.nonPositionedFloats = [], this.nonPositionedInlineLevel = [];
    }
    return e;
  }()
), ms = (
  /** @class */
  function() {
    function e(A, r) {
      if (this.container = A, this.parent = r, this.effects = [], this.curves = new jc(this.container), this.container.styles.opacity < 1 && this.effects.push(new el(this.container.styles.opacity)), this.container.styles.transform !== null) {
        var t = this.container.bounds.left + this.container.styles.transformOrigin[0].number, n = this.container.bounds.top + this.container.styles.transformOrigin[1].number, s = this.container.styles.transform;
        this.effects.push(new Al(t, n, s));
      }
      if (this.container.styles.overflowX !== 0) {
        var B = tr(this.curves), i = nr(this.curves);
        fn(B, i) ? this.effects.push(new _e(
          B,
          6
          /* CONTENT */
        )) : (this.effects.push(new _e(
          B,
          2
          /* BACKGROUND_BORDERS */
        )), this.effects.push(new _e(
          i,
          4
          /* CONTENT */
        )));
      }
    }
    return e.prototype.getEffects = function(A) {
      for (var r = [
        2,
        3
        /* FIXED */
      ].indexOf(this.container.styles.position) === -1, t = this.parent, n = this.effects.slice(0); t; ) {
        var s = t.effects.filter(function(a) {
          return !vs(a);
        });
        if (r || t.container.styles.position !== 0 || !t.parent) {
          if (n.unshift.apply(n, s), r = [
            2,
            3
            /* FIXED */
          ].indexOf(t.container.styles.position) === -1, t.container.styles.overflowX !== 0) {
            var B = tr(t.curves), i = nr(t.curves);
            fn(B, i) || n.unshift(new _e(
              i,
              6
              /* CONTENT */
            ));
          }
        } else
          n.unshift.apply(n, s);
        t = t.parent;
      }
      return n.filter(function(a) {
        return _(a.target, A);
      });
    }, e;
  }()
), it = function(e, A, r, t) {
  e.container.elements.forEach(function(n) {
    var s = _(
      n.flags,
      4
      /* CREATES_REAL_STACKING_CONTEXT */
    ), B = _(
      n.flags,
      2
      /* CREATES_STACKING_CONTEXT */
    ), i = new ms(n, e);
    _(
      n.styles.display,
      2048
      /* LIST_ITEM */
    ) && t.push(i);
    var a = _(
      n.flags,
      8
      /* IS_LIST_OWNER */
    ) ? [] : t;
    if (s || B) {
      var o = s || n.styles.isPositioned() ? r : A, c = new Is(i);
      if (n.styles.isPositioned() || n.styles.opacity < 1 || n.styles.isTransformed()) {
        var l = n.styles.zIndex.order;
        if (l < 0) {
          var Q = 0;
          o.negativeZIndex.some(function(g, w) {
            return l > g.element.container.styles.zIndex.order ? (Q = w, !1) : Q > 0;
          }), o.negativeZIndex.splice(Q, 0, c);
        } else if (l > 0) {
          var f = 0;
          o.positiveZIndex.some(function(g, w) {
            return l >= g.element.container.styles.zIndex.order ? (f = w + 1, !1) : f > 0;
          }), o.positiveZIndex.splice(f, 0, c);
        } else
          o.zeroOrAutoZIndexOrTransformedOrOpacity.push(c);
      } else
        n.styles.isFloating() ? o.nonPositionedFloats.push(c) : o.nonPositionedInlineLevel.push(c);
      it(i, c, s ? c : r, a);
    } else
      n.styles.isInlineLevel() ? A.inlineLevel.push(i) : A.nonInlineLevel.push(i), it(i, A, r, a);
    _(
      n.flags,
      8
      /* IS_LIST_OWNER */
    ) && ys(n, a);
  });
}, ys = function(e, A) {
  for (var r = e instanceof rt ? e.start : 1, t = e instanceof rt ? e.reversed : !1, n = 0; n < A.length; n++) {
    var s = A[n];
    s.container instanceof ls && typeof s.container.value == "number" && s.container.value !== 0 && (r = s.container.value), s.listValue = he(r, s.container.styles.listStyleType, !0), r += t ? -1 : 1;
  }
}, sl = function(e) {
  var A = new ms(e, null), r = new Is(A), t = [];
  return it(A, r, r, t), ys(A.container, t), r;
}, Cn = function(e, A) {
  switch (A) {
    case 0:
      return nA(e.topLeftBorderBox, e.topLeftPaddingBox, e.topRightBorderBox, e.topRightPaddingBox);
    case 1:
      return nA(e.topRightBorderBox, e.topRightPaddingBox, e.bottomRightBorderBox, e.bottomRightPaddingBox);
    case 2:
      return nA(e.bottomRightBorderBox, e.bottomRightPaddingBox, e.bottomLeftBorderBox, e.bottomLeftPaddingBox);
    case 3:
    default:
      return nA(e.bottomLeftBorderBox, e.bottomLeftPaddingBox, e.topLeftBorderBox, e.topLeftPaddingBox);
  }
}, Bl = function(e, A) {
  switch (A) {
    case 0:
      return nA(e.topLeftBorderBox, e.topLeftBorderDoubleOuterBox, e.topRightBorderBox, e.topRightBorderDoubleOuterBox);
    case 1:
      return nA(e.topRightBorderBox, e.topRightBorderDoubleOuterBox, e.bottomRightBorderBox, e.bottomRightBorderDoubleOuterBox);
    case 2:
      return nA(e.bottomRightBorderBox, e.bottomRightBorderDoubleOuterBox, e.bottomLeftBorderBox, e.bottomLeftBorderDoubleOuterBox);
    case 3:
    default:
      return nA(e.bottomLeftBorderBox, e.bottomLeftBorderDoubleOuterBox, e.topLeftBorderBox, e.topLeftBorderDoubleOuterBox);
  }
}, il = function(e, A) {
  switch (A) {
    case 0:
      return nA(e.topLeftBorderDoubleInnerBox, e.topLeftPaddingBox, e.topRightBorderDoubleInnerBox, e.topRightPaddingBox);
    case 1:
      return nA(e.topRightBorderDoubleInnerBox, e.topRightPaddingBox, e.bottomRightBorderDoubleInnerBox, e.bottomRightPaddingBox);
    case 2:
      return nA(e.bottomRightBorderDoubleInnerBox, e.bottomRightPaddingBox, e.bottomLeftBorderDoubleInnerBox, e.bottomLeftPaddingBox);
    case 3:
    default:
      return nA(e.bottomLeftBorderDoubleInnerBox, e.bottomLeftPaddingBox, e.topLeftBorderDoubleInnerBox, e.topLeftPaddingBox);
  }
}, al = function(e, A) {
  switch (A) {
    case 0:
      return Xe(e.topLeftBorderStroke, e.topRightBorderStroke);
    case 1:
      return Xe(e.topRightBorderStroke, e.bottomRightBorderStroke);
    case 2:
      return Xe(e.bottomRightBorderStroke, e.bottomLeftBorderStroke);
    case 3:
    default:
      return Xe(e.bottomLeftBorderStroke, e.topLeftBorderStroke);
  }
}, Xe = function(e, A) {
  var r = [];
  return rA(e) ? r.push(e.subdivide(0.5, !1)) : r.push(e), rA(A) ? r.push(A.subdivide(0.5, !0)) : r.push(A), r;
}, nA = function(e, A, r, t) {
  var n = [];
  return rA(e) ? n.push(e.subdivide(0.5, !1)) : n.push(e), rA(r) ? n.push(r.subdivide(0.5, !0)) : n.push(r), rA(t) ? n.push(t.subdivide(0.5, !0).reverse()) : n.push(t), rA(A) ? n.push(A.subdivide(0.5, !1).reverse()) : n.push(A), n;
}, Ks = function(e) {
  var A = e.bounds, r = e.styles;
  return A.add(r.borderLeftWidth, r.borderTopWidth, -(r.borderRightWidth + r.borderLeftWidth), -(r.borderTopWidth + r.borderBottomWidth));
}, sr = function(e) {
  var A = e.styles, r = e.bounds, t = O(A.paddingLeft, r.width), n = O(A.paddingRight, r.width), s = O(A.paddingTop, r.width), B = O(A.paddingBottom, r.width);
  return r.add(t + A.borderLeftWidth, s + A.borderTopWidth, -(A.borderRightWidth + A.borderLeftWidth + t + n), -(A.borderTopWidth + A.borderBottomWidth + s + B));
}, ol = function(e, A) {
  return e === 0 ? A.bounds : e === 2 ? sr(A) : Ks(A);
}, cl = function(e, A) {
  return e === 0 ? A.bounds : e === 2 ? sr(A) : Ks(A);
}, Gr = function(e, A, r) {
  var t = ol(ZA(e.styles.backgroundOrigin, A), e), n = cl(ZA(e.styles.backgroundClip, A), e), s = ll(ZA(e.styles.backgroundSize, A), r, t), B = s[0], i = s[1], a = oe(ZA(e.styles.backgroundPosition, A), t.width - B, t.height - i), o = Ql(ZA(e.styles.backgroundRepeat, A), a, s, t, n), c = Math.round(t.left + a[0]), l = Math.round(t.top + a[1]);
  return [o, c, l, B, i];
}, WA = function(e) {
  return S(e) && e.value === zA.AUTO;
}, ke = function(e) {
  return typeof e == "number";
}, ll = function(e, A, r) {
  var t = A[0], n = A[1], s = A[2], B = e[0], i = e[1];
  if (!B)
    return [0, 0];
  if (P(B) && i && P(i))
    return [O(B, r.width), O(i, r.height)];
  var a = ke(s);
  if (S(B) && (B.value === zA.CONTAIN || B.value === zA.COVER)) {
    if (ke(s)) {
      var o = r.width / r.height;
      return o < s != (B.value === zA.COVER) ? [r.width, r.width / s] : [r.height * s, r.height];
    }
    return [r.width, r.height];
  }
  var c = ke(t), l = ke(n), Q = c || l;
  if (WA(B) && (!i || WA(i))) {
    if (c && l)
      return [t, n];
    if (!a && !Q)
      return [r.width, r.height];
    if (Q && a) {
      var f = c ? t : n * s, g = l ? n : t / s;
      return [f, g];
    }
    var w = c ? t : r.width, E = l ? n : r.height;
    return [w, E];
  }
  if (a) {
    var C = 0, h = 0;
    return P(B) ? C = O(B, r.width) : P(i) && (h = O(i, r.height)), WA(B) ? C = h * s : (!i || WA(i)) && (h = C / s), [C, h];
  }
  var y = null, v = null;
  if (P(B) ? y = O(B, r.width) : i && P(i) && (v = O(i, r.height)), y !== null && (!i || WA(i)) && (v = c && l ? y / t * n : r.height), v !== null && WA(B) && (y = c && l ? v / n * t : r.width), y !== null && v !== null)
    return [y, v];
  throw new Error("Unable to calculate background-size for element");
}, ZA = function(e, A) {
  var r = e[A];
  return typeof r > "u" ? e[0] : r;
}, Ql = function(e, A, r, t, n) {
  var s = A[0], B = A[1], i = r[0], a = r[1];
  switch (e) {
    case 2:
      return [
        new F(Math.round(t.left), Math.round(t.top + B)),
        new F(Math.round(t.left + t.width), Math.round(t.top + B)),
        new F(Math.round(t.left + t.width), Math.round(a + t.top + B)),
        new F(Math.round(t.left), Math.round(a + t.top + B))
      ];
    case 3:
      return [
        new F(Math.round(t.left + s), Math.round(t.top)),
        new F(Math.round(t.left + s + i), Math.round(t.top)),
        new F(Math.round(t.left + s + i), Math.round(t.height + t.top)),
        new F(Math.round(t.left + s), Math.round(t.height + t.top))
      ];
    case 1:
      return [
        new F(Math.round(t.left + s), Math.round(t.top + B)),
        new F(Math.round(t.left + s + i), Math.round(t.top + B)),
        new F(Math.round(t.left + s + i), Math.round(t.top + B + a)),
        new F(Math.round(t.left + s), Math.round(t.top + B + a))
      ];
    default:
      return [
        new F(Math.round(n.left), Math.round(n.top)),
        new F(Math.round(n.left + n.width), Math.round(n.top)),
        new F(Math.round(n.left + n.width), Math.round(n.height + n.top)),
        new F(Math.round(n.left), Math.round(n.height + n.top))
      ];
  }
}, gl = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7", Un = "Hidden Text", wl = (
  /** @class */
  function() {
    function e(A) {
      this._data = {}, this._document = A;
    }
    return e.prototype.parseMetrics = function(A, r) {
      var t = this._document.createElement("div"), n = this._document.createElement("img"), s = this._document.createElement("span"), B = this._document.body;
      t.style.visibility = "hidden", t.style.fontFamily = A, t.style.fontSize = r, t.style.margin = "0", t.style.padding = "0", t.style.whiteSpace = "nowrap", B.appendChild(t), n.src = gl, n.width = 1, n.height = 1, n.style.margin = "0", n.style.padding = "0", n.style.verticalAlign = "baseline", s.style.fontFamily = A, s.style.fontSize = r, s.style.margin = "0", s.style.padding = "0", s.appendChild(this._document.createTextNode(Un)), t.appendChild(s), t.appendChild(n);
      var i = n.offsetTop - s.offsetTop + 2;
      t.removeChild(s), t.appendChild(this._document.createTextNode(Un)), t.style.lineHeight = "normal", n.style.verticalAlign = "super";
      var a = n.offsetTop - t.offsetTop + 2;
      return B.removeChild(t), { baseline: i, middle: a };
    }, e.prototype.getMetrics = function(A, r) {
      var t = A + " " + r;
      return typeof this._data[t] > "u" && (this._data[t] = this.parseMetrics(A, r)), this._data[t];
    }, e;
  }()
), Ls = (
  /** @class */
  function() {
    function e(A, r) {
      this.context = A, this.options = r;
    }
    return e;
  }()
), ul = 1e4, fl = (
  /** @class */
  function(e) {
    iA(A, e);
    function A(r, t) {
      var n = e.call(this, r, t) || this;
      return n._activeEffects = [], n.canvas = t.canvas ? t.canvas : document.createElement("canvas"), n.ctx = n.canvas.getContext("2d"), t.canvas || (n.canvas.width = Math.floor(t.width * t.scale), n.canvas.height = Math.floor(t.height * t.scale), n.canvas.style.width = t.width + "px", n.canvas.style.height = t.height + "px"), n.fontMetrics = new wl(document), n.ctx.scale(n.options.scale, n.options.scale), n.ctx.translate(-t.x, -t.y), n.ctx.textBaseline = "bottom", n._activeEffects = [], n.context.logger.debug("Canvas renderer initialized (" + t.width + "x" + t.height + ") with scale " + t.scale), n;
    }
    return A.prototype.applyEffects = function(r) {
      for (var t = this; this._activeEffects.length; )
        this.popEffect();
      r.forEach(function(n) {
        return t.applyEffect(n);
      });
    }, A.prototype.applyEffect = function(r) {
      this.ctx.save(), tl(r) && (this.ctx.globalAlpha = r.opacity), rl(r) && (this.ctx.translate(r.offsetX, r.offsetY), this.ctx.transform(r.matrix[0], r.matrix[1], r.matrix[2], r.matrix[3], r.matrix[4], r.matrix[5]), this.ctx.translate(-r.offsetX, -r.offsetY)), vs(r) && (this.path(r.path), this.ctx.clip()), this._activeEffects.push(r);
    }, A.prototype.popEffect = function() {
      this._activeEffects.pop(), this.ctx.restore();
    }, A.prototype.renderStack = function(r) {
      return z(this, void 0, void 0, function() {
        var t;
        return Y(this, function(n) {
          switch (n.label) {
            case 0:
              return t = r.element.container.styles, t.isVisible() ? [4, this.renderStackContent(r)] : [3, 2];
            case 1:
              n.sent(), n.label = 2;
            case 2:
              return [
                2
                /*return*/
              ];
          }
        });
      });
    }, A.prototype.renderNode = function(r) {
      return z(this, void 0, void 0, function() {
        return Y(this, function(t) {
          switch (t.label) {
            case 0:
              if (_(
                r.container.flags,
                16
                /* DEBUG_RENDER */
              ))
                debugger;
              return r.container.styles.isVisible() ? [4, this.renderNodeBackgroundAndBorders(r)] : [3, 3];
            case 1:
              return t.sent(), [4, this.renderNodeContent(r)];
            case 2:
              t.sent(), t.label = 3;
            case 3:
              return [
                2
                /*return*/
              ];
          }
        });
      });
    }, A.prototype.renderTextWithLetterSpacing = function(r, t, n) {
      var s = this;
      if (t === 0)
        this.ctx.fillText(r.text, r.bounds.left, r.bounds.top + n);
      else {
        var B = wt(r.text);
        B.reduce(function(i, a) {
          return s.ctx.fillText(a, i, r.bounds.top + n), i + s.ctx.measureText(a).width;
        }, r.bounds.left);
      }
    }, A.prototype.createFontStyle = function(r) {
      var t = r.fontVariant.filter(function(B) {
        return B === "normal" || B === "small-caps";
      }).join(""), n = dl(r.fontFamily).join(", "), s = pe(r.fontSize) ? "" + r.fontSize.number + r.fontSize.unit : r.fontSize.number + "px";
      return [
        [r.fontStyle, t, r.fontWeight, s, n].join(" "),
        n,
        s
      ];
    }, A.prototype.renderTextNode = function(r, t) {
      return z(this, void 0, void 0, function() {
        var n, s, B, i, a, o, c, l, Q = this;
        return Y(this, function(f) {
          return n = this.createFontStyle(t), s = n[0], B = n[1], i = n[2], this.ctx.font = s, this.ctx.direction = t.direction === 1 ? "rtl" : "ltr", this.ctx.textAlign = "left", this.ctx.textBaseline = "alphabetic", a = this.fontMetrics.getMetrics(B, i), o = a.baseline, c = a.middle, l = t.paintOrder, r.textBounds.forEach(function(g) {
            l.forEach(function(w) {
              switch (w) {
                case 0:
                  Q.ctx.fillStyle = X(t.color), Q.renderTextWithLetterSpacing(g, t.letterSpacing, o);
                  var E = t.textShadow;
                  E.length && g.text.trim().length && (E.slice(0).reverse().forEach(function(C) {
                    Q.ctx.shadowColor = X(C.color), Q.ctx.shadowOffsetX = C.offsetX.number * Q.options.scale, Q.ctx.shadowOffsetY = C.offsetY.number * Q.options.scale, Q.ctx.shadowBlur = C.blur.number, Q.renderTextWithLetterSpacing(g, t.letterSpacing, o);
                  }), Q.ctx.shadowColor = "", Q.ctx.shadowOffsetX = 0, Q.ctx.shadowOffsetY = 0, Q.ctx.shadowBlur = 0), t.textDecorationLine.length && (Q.ctx.fillStyle = X(t.textDecorationColor || t.color), t.textDecorationLine.forEach(function(C) {
                    switch (C) {
                      case 1:
                        Q.ctx.fillRect(g.bounds.left, Math.round(g.bounds.top + o), g.bounds.width, 1);
                        break;
                      case 2:
                        Q.ctx.fillRect(g.bounds.left, Math.round(g.bounds.top), g.bounds.width, 1);
                        break;
                      case 3:
                        Q.ctx.fillRect(g.bounds.left, Math.ceil(g.bounds.top + c), g.bounds.width, 1);
                        break;
                    }
                  }));
                  break;
                case 1:
                  t.webkitTextStrokeWidth && g.text.trim().length && (Q.ctx.strokeStyle = X(t.webkitTextStrokeColor), Q.ctx.lineWidth = t.webkitTextStrokeWidth, Q.ctx.lineJoin = window.chrome ? "miter" : "round", Q.ctx.strokeText(g.text, g.bounds.left, g.bounds.top + o)), Q.ctx.strokeStyle = "", Q.ctx.lineWidth = 0, Q.ctx.lineJoin = "miter";
                  break;
              }
            });
          }), [
            2
            /*return*/
          ];
        });
      });
    }, A.prototype.renderReplacedElement = function(r, t, n) {
      if (n && r.intrinsicWidth > 0 && r.intrinsicHeight > 0) {
        var s = sr(r), B = nr(t);
        this.path(B), this.ctx.save(), this.ctx.clip(), this.ctx.drawImage(n, 0, 0, r.intrinsicWidth, r.intrinsicHeight, s.left, s.top, s.width, s.height), this.ctx.restore();
      }
    }, A.prototype.renderNodeContent = function(r) {
      return z(this, void 0, void 0, function() {
        var t, n, s, B, i, a, h, h, o, c, l, Q, v, f, g, H, w, E, C, h, y, v, H;
        return Y(this, function(U) {
          switch (U.label) {
            case 0:
              this.applyEffects(r.getEffects(
                4
                /* CONTENT */
              )), t = r.container, n = r.curves, s = t.styles, B = 0, i = t.textNodes, U.label = 1;
            case 1:
              return B < i.length ? (a = i[B], [4, this.renderTextNode(a, s)]) : [3, 4];
            case 2:
              U.sent(), U.label = 3;
            case 3:
              return B++, [3, 1];
            case 4:
              if (!(t instanceof as))
                return [3, 8];
              U.label = 5;
            case 5:
              return U.trys.push([5, 7, , 8]), [4, this.context.cache.match(t.src)];
            case 6:
              return h = U.sent(), this.renderReplacedElement(t, n, h), [3, 8];
            case 7:
              return U.sent(), this.context.logger.error("Error loading image " + t.src), [3, 8];
            case 8:
              if (t instanceof os && this.renderReplacedElement(t, n, t.canvas), !(t instanceof cs))
                return [3, 12];
              U.label = 9;
            case 9:
              return U.trys.push([9, 11, , 12]), [4, this.context.cache.match(t.svg)];
            case 10:
              return h = U.sent(), this.renderReplacedElement(t, n, h), [3, 12];
            case 11:
              return U.sent(), this.context.logger.error("Error loading svg " + t.svg.substring(0, 255)), [3, 12];
            case 12:
              return t instanceof ws && t.tree ? (o = new A(this.context, {
                scale: this.options.scale,
                backgroundColor: t.backgroundColor,
                x: 0,
                y: 0,
                width: t.width,
                height: t.height
              }), [4, o.render(t.tree)]) : [3, 14];
            case 13:
              c = U.sent(), t.width && t.height && this.ctx.drawImage(c, 0, 0, t.width, t.height, t.bounds.left, t.bounds.top, t.bounds.width, t.bounds.height), U.label = 14;
            case 14:
              if (t instanceof ut && (l = Math.min(t.bounds.width, t.bounds.height), t.type === $e ? t.checked && (this.ctx.save(), this.path([
                new F(t.bounds.left + l * 0.39363, t.bounds.top + l * 0.79),
                new F(t.bounds.left + l * 0.16, t.bounds.top + l * 0.5549),
                new F(t.bounds.left + l * 0.27347, t.bounds.top + l * 0.44071),
                new F(t.bounds.left + l * 0.39694, t.bounds.top + l * 0.5649),
                new F(t.bounds.left + l * 0.72983, t.bounds.top + l * 0.23),
                new F(t.bounds.left + l * 0.84, t.bounds.top + l * 0.34085),
                new F(t.bounds.left + l * 0.39363, t.bounds.top + l * 0.79)
              ]), this.ctx.fillStyle = X(nn), this.ctx.fill(), this.ctx.restore()) : t.type === Ar && t.checked && (this.ctx.save(), this.ctx.beginPath(), this.ctx.arc(t.bounds.left + l / 2, t.bounds.top + l / 2, l / 4, 0, Math.PI * 2, !0), this.ctx.fillStyle = X(nn), this.ctx.fill(), this.ctx.restore())), Cl(t) && t.value.length) {
                switch (Q = this.createFontStyle(s), v = Q[0], f = Q[1], g = this.fontMetrics.getMetrics(v, f).baseline, this.ctx.font = v, this.ctx.fillStyle = X(s.color), this.ctx.textBaseline = "alphabetic", this.ctx.textAlign = Fl(t.styles.textAlign), H = sr(t), w = 0, t.styles.textAlign) {
                  case 1:
                    w += H.width / 2;
                    break;
                  case 2:
                    w += H.width;
                    break;
                }
                E = H.add(w, 0, 0, -H.height / 2 + 1), this.ctx.save(), this.path([
                  new F(H.left, H.top),
                  new F(H.left + H.width, H.top),
                  new F(H.left + H.width, H.top + H.height),
                  new F(H.left, H.top + H.height)
                ]), this.ctx.clip(), this.renderTextWithLetterSpacing(new fe(t.value, E), s.letterSpacing, g), this.ctx.restore(), this.ctx.textBaseline = "alphabetic", this.ctx.textAlign = "left";
              }
              if (!_(
                t.styles.display,
                2048
                /* LIST_ITEM */
              ))
                return [3, 20];
              if (t.styles.listStyleImage === null)
                return [3, 19];
              if (C = t.styles.listStyleImage, C.type !== 0)
                return [3, 18];
              h = void 0, y = C.url, U.label = 15;
            case 15:
              return U.trys.push([15, 17, , 18]), [4, this.context.cache.match(y)];
            case 16:
              return h = U.sent(), this.ctx.drawImage(h, t.bounds.left - (h.width + 10), t.bounds.top), [3, 18];
            case 17:
              return U.sent(), this.context.logger.error("Error loading list-style-image " + y), [3, 18];
            case 18:
              return [3, 20];
            case 19:
              r.listValue && t.styles.listStyleType !== -1 && (v = this.createFontStyle(s)[0], this.ctx.font = v, this.ctx.fillStyle = X(s.color), this.ctx.textBaseline = "middle", this.ctx.textAlign = "right", H = new FA(t.bounds.left, t.bounds.top + O(t.styles.paddingTop, t.bounds.width), t.bounds.width, Nt(s.lineHeight, s.fontSize.number) / 2 + 1), this.renderTextWithLetterSpacing(new fe(r.listValue, H), s.letterSpacing, Nt(s.lineHeight, s.fontSize.number) / 2 + 2), this.ctx.textBaseline = "bottom", this.ctx.textAlign = "left"), U.label = 20;
            case 20:
              return [
                2
                /*return*/
              ];
          }
        });
      });
    }, A.prototype.renderStackContent = function(r) {
      return z(this, void 0, void 0, function() {
        var t, n, C, s, B, C, i, a, C, o, c, C, l, Q, C, f, g, C, w, E, C;
        return Y(this, function(h) {
          switch (h.label) {
            case 0:
              if (_(
                r.element.container.flags,
                16
                /* DEBUG_RENDER */
              ))
                debugger;
              return [4, this.renderNodeBackgroundAndBorders(r.element)];
            case 1:
              h.sent(), t = 0, n = r.negativeZIndex, h.label = 2;
            case 2:
              return t < n.length ? (C = n[t], [4, this.renderStack(C)]) : [3, 5];
            case 3:
              h.sent(), h.label = 4;
            case 4:
              return t++, [3, 2];
            case 5:
              return [4, this.renderNodeContent(r.element)];
            case 6:
              h.sent(), s = 0, B = r.nonInlineLevel, h.label = 7;
            case 7:
              return s < B.length ? (C = B[s], [4, this.renderNode(C)]) : [3, 10];
            case 8:
              h.sent(), h.label = 9;
            case 9:
              return s++, [3, 7];
            case 10:
              i = 0, a = r.nonPositionedFloats, h.label = 11;
            case 11:
              return i < a.length ? (C = a[i], [4, this.renderStack(C)]) : [3, 14];
            case 12:
              h.sent(), h.label = 13;
            case 13:
              return i++, [3, 11];
            case 14:
              o = 0, c = r.nonPositionedInlineLevel, h.label = 15;
            case 15:
              return o < c.length ? (C = c[o], [4, this.renderStack(C)]) : [3, 18];
            case 16:
              h.sent(), h.label = 17;
            case 17:
              return o++, [3, 15];
            case 18:
              l = 0, Q = r.inlineLevel, h.label = 19;
            case 19:
              return l < Q.length ? (C = Q[l], [4, this.renderNode(C)]) : [3, 22];
            case 20:
              h.sent(), h.label = 21;
            case 21:
              return l++, [3, 19];
            case 22:
              f = 0, g = r.zeroOrAutoZIndexOrTransformedOrOpacity, h.label = 23;
            case 23:
              return f < g.length ? (C = g[f], [4, this.renderStack(C)]) : [3, 26];
            case 24:
              h.sent(), h.label = 25;
            case 25:
              return f++, [3, 23];
            case 26:
              w = 0, E = r.positiveZIndex, h.label = 27;
            case 27:
              return w < E.length ? (C = E[w], [4, this.renderStack(C)]) : [3, 30];
            case 28:
              h.sent(), h.label = 29;
            case 29:
              return w++, [3, 27];
            case 30:
              return [
                2
                /*return*/
              ];
          }
        });
      });
    }, A.prototype.mask = function(r) {
      this.ctx.beginPath(), this.ctx.moveTo(0, 0), this.ctx.lineTo(this.canvas.width, 0), this.ctx.lineTo(this.canvas.width, this.canvas.height), this.ctx.lineTo(0, this.canvas.height), this.ctx.lineTo(0, 0), this.formatPath(r.slice(0).reverse()), this.ctx.closePath();
    }, A.prototype.path = function(r) {
      this.ctx.beginPath(), this.formatPath(r), this.ctx.closePath();
    }, A.prototype.formatPath = function(r) {
      var t = this;
      r.forEach(function(n, s) {
        var B = rA(n) ? n.start : n;
        s === 0 ? t.ctx.moveTo(B.x, B.y) : t.ctx.lineTo(B.x, B.y), rA(n) && t.ctx.bezierCurveTo(n.startControl.x, n.startControl.y, n.endControl.x, n.endControl.y, n.end.x, n.end.y);
      });
    }, A.prototype.renderRepeat = function(r, t, n, s) {
      this.path(r), this.ctx.fillStyle = t, this.ctx.translate(n, s), this.ctx.fill(), this.ctx.translate(-n, -s);
    }, A.prototype.resizeImage = function(r, t, n) {
      var s;
      if (r.width === t && r.height === n)
        return r;
      var B = (s = this.canvas.ownerDocument) !== null && s !== void 0 ? s : document, i = B.createElement("canvas");
      i.width = Math.max(1, t), i.height = Math.max(1, n);
      var a = i.getContext("2d");
      return a.drawImage(r, 0, 0, r.width, r.height, 0, 0, t, n), i;
    }, A.prototype.renderBackgroundImage = function(r) {
      return z(this, void 0, void 0, function() {
        var t, n, s, B, i, a;
        return Y(this, function(o) {
          switch (o.label) {
            case 0:
              t = r.styles.backgroundImage.length - 1, n = function(c) {
                var l, Q, f, p, q, W, I, G, L, g, p, q, W, I, G, w, E, C, h, y, v, H, U, K, L, u, p, m, D, I, G, j, q, W, sA, aA, dA, xA, SA, gA, TA, wA;
                return Y(this, function(NA) {
                  switch (NA.label) {
                    case 0:
                      if (c.type !== 0)
                        return [3, 5];
                      l = void 0, Q = c.url, NA.label = 1;
                    case 1:
                      return NA.trys.push([1, 3, , 4]), [4, s.context.cache.match(Q)];
                    case 2:
                      return l = NA.sent(), [3, 4];
                    case 3:
                      return NA.sent(), s.context.logger.error("Error loading background-image " + Q), [3, 4];
                    case 4:
                      return l && (f = Gr(r, t, [
                        l.width,
                        l.height,
                        l.width / l.height
                      ]), p = f[0], q = f[1], W = f[2], I = f[3], G = f[4], L = s.ctx.createPattern(s.resizeImage(l, I, G), "repeat"), s.renderRepeat(p, L, q, W)), [3, 6];
                    case 5:
                      ea(c) ? (g = Gr(r, t, [null, null, null]), p = g[0], q = g[1], W = g[2], I = g[3], G = g[4], w = qi(c.angle, I, G), E = w[0], C = w[1], h = w[2], y = w[3], v = w[4], H = document.createElement("canvas"), H.width = I, H.height = G, U = H.getContext("2d"), K = U.createLinearGradient(C, y, h, v), Rt(c.stops, E).forEach(function(Ae) {
                        return K.addColorStop(Ae.stop, X(Ae.color));
                      }), U.fillStyle = K, U.fillRect(0, 0, I, G), I > 0 && G > 0 && (L = s.ctx.createPattern(H, "repeat"), s.renderRepeat(p, L, q, W))) : ra(c) && (u = Gr(r, t, [
                        null,
                        null,
                        null
                      ]), p = u[0], m = u[1], D = u[2], I = u[3], G = u[4], j = c.position.length === 0 ? [lt] : c.position, q = O(j[0], I), W = O(j[j.length - 1], G), sA = zi(c, q, W, I, G), aA = sA[0], dA = sA[1], aA > 0 && dA > 0 && (xA = s.ctx.createRadialGradient(m + q, D + W, 0, m + q, D + W, aA), Rt(c.stops, aA * 2).forEach(function(Ae) {
                        return xA.addColorStop(Ae.stop, X(Ae.color));
                      }), s.path(p), s.ctx.fillStyle = xA, aA !== dA ? (SA = r.bounds.left + 0.5 * r.bounds.width, gA = r.bounds.top + 0.5 * r.bounds.height, TA = dA / aA, wA = 1 / TA, s.ctx.save(), s.ctx.translate(SA, gA), s.ctx.transform(1, 0, 0, TA, 0, 0), s.ctx.translate(-SA, -gA), s.ctx.fillRect(m, wA * (D - gA) + gA, I, G * wA), s.ctx.restore()) : s.ctx.fill())), NA.label = 6;
                    case 6:
                      return t--, [
                        2
                        /*return*/
                      ];
                  }
                });
              }, s = this, B = 0, i = r.styles.backgroundImage.slice(0).reverse(), o.label = 1;
            case 1:
              return B < i.length ? (a = i[B], [5, n(a)]) : [3, 4];
            case 2:
              o.sent(), o.label = 3;
            case 3:
              return B++, [3, 1];
            case 4:
              return [
                2
                /*return*/
              ];
          }
        });
      });
    }, A.prototype.renderSolidBorder = function(r, t, n) {
      return z(this, void 0, void 0, function() {
        return Y(this, function(s) {
          return this.path(Cn(n, t)), this.ctx.fillStyle = X(r), this.ctx.fill(), [
            2
            /*return*/
          ];
        });
      });
    }, A.prototype.renderDoubleBorder = function(r, t, n, s) {
      return z(this, void 0, void 0, function() {
        var B, i;
        return Y(this, function(a) {
          switch (a.label) {
            case 0:
              return t < 3 ? [4, this.renderSolidBorder(r, n, s)] : [3, 2];
            case 1:
              return a.sent(), [
                2
                /*return*/
              ];
            case 2:
              return B = Bl(s, n), this.path(B), this.ctx.fillStyle = X(r), this.ctx.fill(), i = il(s, n), this.path(i), this.ctx.fill(), [
                2
                /*return*/
              ];
          }
        });
      });
    }, A.prototype.renderNodeBackgroundAndBorders = function(r) {
      return z(this, void 0, void 0, function() {
        var t, n, s, B, i, a, o, c, l = this;
        return Y(this, function(Q) {
          switch (Q.label) {
            case 0:
              return this.applyEffects(r.getEffects(
                2
                /* BACKGROUND_BORDERS */
              )), t = r.container.styles, n = !LA(t.backgroundColor) || t.backgroundImage.length, s = [
                { style: t.borderTopStyle, color: t.borderTopColor, width: t.borderTopWidth },
                { style: t.borderRightStyle, color: t.borderRightColor, width: t.borderRightWidth },
                { style: t.borderBottomStyle, color: t.borderBottomColor, width: t.borderBottomWidth },
                { style: t.borderLeftStyle, color: t.borderLeftColor, width: t.borderLeftWidth }
              ], B = Ul(ZA(t.backgroundClip, 0), r.curves), n || t.boxShadow.length ? (this.ctx.save(), this.path(B), this.ctx.clip(), LA(t.backgroundColor) || (this.ctx.fillStyle = X(t.backgroundColor), this.ctx.fill()), [4, this.renderBackgroundImage(r.container)]) : [3, 2];
            case 1:
              Q.sent(), this.ctx.restore(), t.boxShadow.slice(0).reverse().forEach(function(f) {
                l.ctx.save();
                var g = tr(r.curves), w = f.inset ? 0 : ul, E = nl(g, -w + (f.inset ? 1 : -1) * f.spread.number, (f.inset ? 1 : -1) * f.spread.number, f.spread.number * (f.inset ? -2 : 2), f.spread.number * (f.inset ? -2 : 2));
                f.inset ? (l.path(g), l.ctx.clip(), l.mask(E)) : (l.mask(g), l.ctx.clip(), l.path(E)), l.ctx.shadowOffsetX = f.offsetX.number + w, l.ctx.shadowOffsetY = f.offsetY.number, l.ctx.shadowColor = X(f.color), l.ctx.shadowBlur = f.blur.number, l.ctx.fillStyle = f.inset ? X(f.color) : "rgba(0,0,0,1)", l.ctx.fill(), l.ctx.restore();
              }), Q.label = 2;
            case 2:
              i = 0, a = 0, o = s, Q.label = 3;
            case 3:
              return a < o.length ? (c = o[a], c.style !== 0 && !LA(c.color) && c.width > 0 ? c.style !== 2 ? [3, 5] : [4, this.renderDashedDottedBorder(
                c.color,
                c.width,
                i,
                r.curves,
                2
                /* DASHED */
              )] : [3, 11]) : [3, 13];
            case 4:
              return Q.sent(), [3, 11];
            case 5:
              return c.style !== 3 ? [3, 7] : [4, this.renderDashedDottedBorder(
                c.color,
                c.width,
                i,
                r.curves,
                3
                /* DOTTED */
              )];
            case 6:
              return Q.sent(), [3, 11];
            case 7:
              return c.style !== 4 ? [3, 9] : [4, this.renderDoubleBorder(c.color, c.width, i, r.curves)];
            case 8:
              return Q.sent(), [3, 11];
            case 9:
              return [4, this.renderSolidBorder(c.color, i, r.curves)];
            case 10:
              Q.sent(), Q.label = 11;
            case 11:
              i++, Q.label = 12;
            case 12:
              return a++, [3, 3];
            case 13:
              return [
                2
                /*return*/
              ];
          }
        });
      });
    }, A.prototype.renderDashedDottedBorder = function(r, t, n, s, B) {
      return z(this, void 0, void 0, function() {
        var i, a, o, c, l, Q, f, g, w, E, C, h, y, v, H, U, H, U;
        return Y(this, function(K) {
          return this.ctx.save(), i = al(s, n), a = Cn(s, n), B === 2 && (this.path(a), this.ctx.clip()), rA(a[0]) ? (o = a[0].start.x, c = a[0].start.y) : (o = a[0].x, c = a[0].y), rA(a[1]) ? (l = a[1].end.x, Q = a[1].end.y) : (l = a[1].x, Q = a[1].y), n === 0 || n === 2 ? f = Math.abs(o - l) : f = Math.abs(c - Q), this.ctx.beginPath(), B === 3 ? this.formatPath(i) : this.formatPath(a.slice(0, 2)), g = t < 3 ? t * 3 : t * 2, w = t < 3 ? t * 2 : t, B === 3 && (g = t, w = t), E = !0, f <= g * 2 ? E = !1 : f <= g * 2 + w ? (C = f / (2 * g + w), g *= C, w *= C) : (h = Math.floor((f + w) / (g + w)), y = (f - h * g) / (h - 1), v = (f - (h + 1) * g) / h, w = v <= 0 || Math.abs(w - y) < Math.abs(w - v) ? y : v), E && (B === 3 ? this.ctx.setLineDash([0, g + w]) : this.ctx.setLineDash([g, w])), B === 3 ? (this.ctx.lineCap = "round", this.ctx.lineWidth = t) : this.ctx.lineWidth = t * 2 + 1.1, this.ctx.strokeStyle = X(r), this.ctx.stroke(), this.ctx.setLineDash([]), B === 2 && (rA(a[0]) && (H = a[3], U = a[0], this.ctx.beginPath(), this.formatPath([new F(H.end.x, H.end.y), new F(U.start.x, U.start.y)]), this.ctx.stroke()), rA(a[1]) && (H = a[1], U = a[2], this.ctx.beginPath(), this.formatPath([new F(H.end.x, H.end.y), new F(U.start.x, U.start.y)]), this.ctx.stroke())), this.ctx.restore(), [
            2
            /*return*/
          ];
        });
      });
    }, A.prototype.render = function(r) {
      return z(this, void 0, void 0, function() {
        var t;
        return Y(this, function(n) {
          switch (n.label) {
            case 0:
              return this.options.backgroundColor && (this.ctx.fillStyle = X(this.options.backgroundColor), this.ctx.fillRect(this.options.x, this.options.y, this.options.width, this.options.height)), t = sl(r), [4, this.renderStack(t)];
            case 1:
              return n.sent(), this.applyEffects([]), [2, this.canvas];
          }
        });
      });
    }, A;
  }(Ls)
), Cl = function(e) {
  return e instanceof gs || e instanceof Qs ? !0 : e instanceof ut && e.type !== Ar && e.type !== $e;
}, Ul = function(e, A) {
  switch (e) {
    case 0:
      return tr(A);
    case 2:
      return $c(A);
    case 1:
    default:
      return nr(A);
  }
}, Fl = function(e) {
  switch (e) {
    case 1:
      return "center";
    case 2:
      return "right";
    case 0:
    default:
      return "left";
  }
}, hl = ["-apple-system", "system-ui"], dl = function(e) {
  return /iPhone OS 15_(0|1)/.test(window.navigator.userAgent) ? e.filter(function(A) {
    return hl.indexOf(A) === -1;
  }) : e;
}, pl = (
  /** @class */
  function(e) {
    iA(A, e);
    function A(r, t) {
      var n = e.call(this, r, t) || this;
      return n.canvas = t.canvas ? t.canvas : document.createElement("canvas"), n.ctx = n.canvas.getContext("2d"), n.options = t, n.canvas.width = Math.floor(t.width * t.scale), n.canvas.height = Math.floor(t.height * t.scale), n.canvas.style.width = t.width + "px", n.canvas.style.height = t.height + "px", n.ctx.scale(n.options.scale, n.options.scale), n.ctx.translate(-t.x, -t.y), n.context.logger.debug("EXPERIMENTAL ForeignObject renderer initialized (" + t.width + "x" + t.height + " at " + t.x + "," + t.y + ") with scale " + t.scale), n;
    }
    return A.prototype.render = function(r) {
      return z(this, void 0, void 0, function() {
        var t, n;
        return Y(this, function(s) {
          switch (s.label) {
            case 0:
              return t = et(this.options.width * this.options.scale, this.options.height * this.options.scale, this.options.scale, this.options.scale, r), [4, El(t)];
            case 1:
              return n = s.sent(), this.options.backgroundColor && (this.ctx.fillStyle = X(this.options.backgroundColor), this.ctx.fillRect(0, 0, this.options.width * this.options.scale, this.options.height * this.options.scale)), this.ctx.drawImage(n, -this.options.x * this.options.scale, -this.options.y * this.options.scale), [2, this.canvas];
          }
        });
      });
    }, A;
  }(Ls)
), El = function(e) {
  return new Promise(function(A, r) {
    var t = new Image();
    t.onload = function() {
      A(t);
    }, t.onerror = r, t.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(new XMLSerializer().serializeToString(e));
  });
}, Hl = (
  /** @class */
  function() {
    function e(A) {
      var r = A.id, t = A.enabled;
      this.id = r, this.enabled = t, this.start = Date.now();
    }
    return e.prototype.debug = function() {
      for (var A = [], r = 0; r < arguments.length; r++)
        A[r] = arguments[r];
      this.enabled && (typeof window < "u" && window.console && typeof console.debug == "function" ? console.debug.apply(console, Ee([this.id, this.getTime() + "ms"], A)) : this.info.apply(this, A));
    }, e.prototype.getTime = function() {
      return Date.now() - this.start;
    }, e.prototype.info = function() {
      for (var A = [], r = 0; r < arguments.length; r++)
        A[r] = arguments[r];
      this.enabled && typeof window < "u" && window.console && typeof console.info == "function" && console.info.apply(console, Ee([this.id, this.getTime() + "ms"], A));
    }, e.prototype.warn = function() {
      for (var A = [], r = 0; r < arguments.length; r++)
        A[r] = arguments[r];
      this.enabled && (typeof window < "u" && window.console && typeof console.warn == "function" ? console.warn.apply(console, Ee([this.id, this.getTime() + "ms"], A)) : this.info.apply(this, A));
    }, e.prototype.error = function() {
      for (var A = [], r = 0; r < arguments.length; r++)
        A[r] = arguments[r];
      this.enabled && (typeof window < "u" && window.console && typeof console.error == "function" ? console.error.apply(console, Ee([this.id, this.getTime() + "ms"], A)) : this.info.apply(this, A));
    }, e.instances = {}, e;
  }()
), vl = (
  /** @class */
  function() {
    function e(A, r) {
      var t;
      this.windowBounds = r, this.instanceName = "#" + e.instanceCount++, this.logger = new Hl({ id: this.instanceName, enabled: A.logging }), this.cache = (t = A.cache) !== null && t !== void 0 ? t : new kc(this, A);
    }
    return e.instanceCount = 1, e;
  }()
), Il = function(e, A) {
  return A === void 0 && (A = {}), ml(e, A);
};
typeof window < "u" && Hs.setContext(window);
var ml = function(e, A) {
  return z(void 0, void 0, void 0, function() {
    var r, t, n, s, B, i, a, o, c, l, Q, f, g, w, E, C, h, y, v, H, K, U, K, L, u, p, m, D, I, G, j, q, W, sA, aA, dA, xA, SA, gA, TA;
    return Y(this, function(wA) {
      switch (wA.label) {
        case 0:
          if (!e || typeof e != "object")
            return [2, Promise.reject("Invalid element provided as first argument")];
          if (r = e.ownerDocument, !r)
            throw new Error("Element is not attached to a Document");
          if (t = r.defaultView, !t)
            throw new Error("Document is not attached to a Window");
          return n = {
            allowTaint: (L = A.allowTaint) !== null && L !== void 0 ? L : !1,
            imageTimeout: (u = A.imageTimeout) !== null && u !== void 0 ? u : 15e3,
            proxy: A.proxy,
            useCORS: (p = A.useCORS) !== null && p !== void 0 ? p : !1
          }, s = Vr({ logging: (m = A.logging) !== null && m !== void 0 ? m : !0, cache: A.cache }, n), B = {
            windowWidth: (D = A.windowWidth) !== null && D !== void 0 ? D : t.innerWidth,
            windowHeight: (I = A.windowHeight) !== null && I !== void 0 ? I : t.innerHeight,
            scrollX: (G = A.scrollX) !== null && G !== void 0 ? G : t.pageXOffset,
            scrollY: (j = A.scrollY) !== null && j !== void 0 ? j : t.pageYOffset
          }, i = new FA(B.scrollX, B.scrollY, B.windowWidth, B.windowHeight), a = new vl(s, i), o = (q = A.foreignObjectRendering) !== null && q !== void 0 ? q : !1, c = {
            allowTaint: (W = A.allowTaint) !== null && W !== void 0 ? W : !1,
            onclone: A.onclone,
            ignoreElements: A.ignoreElements,
            inlineImages: o,
            copyStyles: o
          }, a.logger.debug("Starting document clone with size " + i.width + "x" + i.height + " scrolled to " + -i.left + "," + -i.top), l = new wn(a, e, c), Q = l.clonedReferenceElement, Q ? [4, l.toIFrame(r, i)] : [2, Promise.reject("Unable to find element in cloned iframe")];
        case 1:
          return f = wA.sent(), g = ft(Q) || yc(Q) ? tB(Q.ownerDocument) : ar(a, Q), w = g.width, E = g.height, C = g.left, h = g.top, y = yl(a, Q, A.backgroundColor), v = {
            canvas: A.canvas,
            backgroundColor: y,
            scale: (aA = (sA = A.scale) !== null && sA !== void 0 ? sA : t.devicePixelRatio) !== null && aA !== void 0 ? aA : 1,
            x: ((dA = A.x) !== null && dA !== void 0 ? dA : 0) + C,
            y: ((xA = A.y) !== null && xA !== void 0 ? xA : 0) + h,
            width: (SA = A.width) !== null && SA !== void 0 ? SA : Math.ceil(w),
            height: (gA = A.height) !== null && gA !== void 0 ? gA : Math.ceil(E)
          }, o ? (a.logger.debug("Document cloned, using foreign object rendering"), K = new pl(a, v), [4, K.render(Q)]) : [3, 3];
        case 2:
          return H = wA.sent(), [3, 5];
        case 3:
          return a.logger.debug("Document cloned, element located at " + C + "," + h + " with size " + w + "x" + E + " using computed rendering"), a.logger.debug("Starting DOM parsing"), U = fs(a, Q), y === U.styles.backgroundColor && (U.styles.backgroundColor = UA.TRANSPARENT), a.logger.debug("Starting renderer for element at " + v.x + "," + v.y + " with size " + v.width + "x" + v.height), K = new fl(a, v), [4, K.render(U)];
        case 4:
          H = wA.sent(), wA.label = 5;
        case 5:
          return (!((TA = A.removeContainer) !== null && TA !== void 0) || TA) && (wn.destroy(f) || a.logger.error("Cannot detach cloned iframe as it is not in the DOM anymore")), a.logger.debug("Finished rendering"), [2, H];
      }
    });
  });
}, yl = function(e, A, r) {
  var t = A.ownerDocument, n = t.documentElement ? we(e, getComputedStyle(t.documentElement).backgroundColor) : UA.TRANSPARENT, s = t.body ? we(e, getComputedStyle(t.body).backgroundColor) : UA.TRANSPARENT, B = typeof r == "string" ? we(e, r) : r === null ? UA.TRANSPARENT : 4294967295;
  return A === t.documentElement ? LA(n) ? LA(s) ? B : s : n : B;
};
class Kl extends Ms {
  async execAction(A, r, t, n, s) {
    try {
      this.exportImg(t);
    } catch (B) {
      ibiz.log.error(B);
    }
    return {
      refresh: !1,
      closeView: !1
    };
  }
  exportImg(A) {
    const r = document.querySelector(
      ".ibiz-view.ibiz-view-deeditview3"
    ), t = document.querySelector(".ivu-tabs-tabpane");
    if (r && t) {
      const n = r.scrollHeight + t.scrollHeight - t.offsetHeight;
      Il(r, {
        useCORS: !0,
        allowTaint: !0,
        // 这两个属性都是图片跨域相关属性
        height: n,
        windowHeight: n * 2,
        scale: window.devicePixelRatio
      }).then(function(s) {
        const B = s.toDataURL("image/png").replace("image/png", "image/octet-stream"), i = document.createElement("a");
        i.href = B;
        let a = "downLoad.png";
        A && A[0] && (a = `${A[0].srfmajortext}.png`), i.download = a, i.click();
      });
    }
  }
}
class Ll {
  constructor() {
    pA(this, "handler");
  }
  async getHandler() {
    return this.handler || (this.handler = new Kl()), this.handler;
  }
}
class bl extends Ys {
  constructor() {
    super(...arguments);
    /**
     * 流程图url
     *
     * @type {string}
     * @memberof PresetWFChartViewController
     */
    pA(this, "imgSrc");
  }
  async getUIData() {
    const r = Object.assign(this.context.clone(), this.params), t = await this.entityService.wf.getWFProcessDiagram(r), n = new Blob([t.data], {
      type: "image/svg+xml"
    });
    this.imgSrc = URL.createObjectURL(n);
  }
}
const Dl = hA({
  name: "PresetWFChartView",
  props: {
    context: Object,
    params: {
      type: Object
    },
    modelPath: {
      type: String,
      required: !0
    },
    modal: {
      type: Object
    },
    deName: {
      type: String,
      required: !0
    }
  },
  setup(e) {
    const A = DA("preset-wf-chart-view"), {
      proxy: r
    } = ir(), t = En(r, (n, s) => new bl(e.modelPath, n, s));
    return pn(r, "deName", t.setDeName.bind(t)), {
      c: t,
      ns: A
    };
  },
  render() {
    return T("div", {
      class: this.ns.b()
    }, [T("img", {
      attrs: {
        src: this.c.imgSrc
      }
    })]);
  }
}), xl = typeof btoa == "function", Ct = typeof Buffer == "function";
typeof TextDecoder == "function" && new TextDecoder();
const Fn = typeof TextEncoder == "function" ? new TextEncoder() : void 0, Sl = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", Qe = Array.prototype.slice.call(Sl);
((e) => {
  let A = {};
  return e.forEach((r, t) => A[r] = t), A;
})(Qe);
const cA = String.fromCharCode.bind(String);
typeof Uint8Array.from == "function" && Uint8Array.from.bind(Uint8Array);
const Tl = (e) => e.replace(/=/g, "").replace(/[+\/]/g, (A) => A == "+" ? "-" : "_"), Ol = (e) => {
  let A, r, t, n, s = "";
  const B = e.length % 3;
  for (let i = 0; i < e.length; ) {
    if ((r = e.charCodeAt(i++)) > 255 || (t = e.charCodeAt(i++)) > 255 || (n = e.charCodeAt(i++)) > 255)
      throw new TypeError("invalid character found");
    A = r << 16 | t << 8 | n, s += Qe[A >> 18 & 63] + Qe[A >> 12 & 63] + Qe[A >> 6 & 63] + Qe[A & 63];
  }
  return B ? s.slice(0, B - 3) + "===".substring(B) : s;
}, bs = xl ? (e) => btoa(e) : Ct ? (e) => Buffer.from(e, "binary").toString("base64") : Ol, Ml = Ct ? (e) => Buffer.from(e).toString("base64") : (e) => {
  let r = [];
  for (let t = 0, n = e.length; t < n; t += 4096)
    r.push(cA.apply(null, e.subarray(t, t + 4096)));
  return bs(r.join(""));
}, Gl = (e) => {
  if (e.length < 2) {
    var A = e.charCodeAt(0);
    return A < 128 ? e : A < 2048 ? cA(192 | A >>> 6) + cA(128 | A & 63) : cA(224 | A >>> 12 & 15) + cA(128 | A >>> 6 & 63) + cA(128 | A & 63);
  } else {
    var A = 65536 + (e.charCodeAt(0) - 55296) * 1024 + (e.charCodeAt(1) - 56320);
    return cA(240 | A >>> 18 & 7) + cA(128 | A >>> 12 & 63) + cA(128 | A >>> 6 & 63) + cA(128 | A & 63);
  }
}, Rl = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g, Vl = (e) => e.replace(Rl, Gl), hn = Ct ? (e) => Buffer.from(e, "utf8").toString("base64") : Fn ? (e) => Ml(Fn.encode(e)) : (e) => bs(Vl(e)), Ds = (e, A = !1) => A ? Tl(hn(e)) : hn(e);
function Nl(e, A, r) {
  var K, L;
  const t = R([]), n = R({
    Authorization: `Bearer ${Js("access_token")}`
  }), s = R(""), B = R(""), i = {
    count: 0,
    cacheFiles: []
    // iview上传过程中不能改default-file-list,所以需要缓存
  }, a = (K = r.editorParams) == null ? void 0 : K.blackList;
  let o = [];
  a && typeof a == "string" && (o = a.split(","));
  const c = (L = r.editorParams) == null ? void 0 : L.previewList;
  let l = [];
  c && typeof c == "string" && (l = c.split(",")), CA(
    () => e.value,
    (u) => {
      t.value = u ? JSON.parse(u) : [];
    },
    { immediate: !0 }
  ), CA(
    () => e.data,
    (u) => {
      if (u) {
        const p = r.calcBaseUrl(u);
        s.value = p.uploadUrl, B.value = p.downloadUrl;
      }
    },
    { immediate: !0, deep: !0 }
  ), CA(
    t,
    (u) => {
      u != null && u.length && B.value && u.forEach((p) => {
        p.url = p.url || B.value.replace("%fileId%", p.id);
      }), Array.isArray(u) && u.forEach((p) => {
        p.name || (p.isPreview = !1);
        const m = p.name.trim().toLowerCase();
        p.isPreview = l.some(
          (D) => m.endsWith(`.${D}`)
        );
      });
    },
    { immediate: !0 }
  ), CA(
    B,
    (u) => {
      u && t.value.length && t.value.forEach((p) => {
        p.url = B.value.replace("%fileId%", p.id);
      });
    },
    { immediate: !0 }
  );
  const Q = () => {
    const u = [...t.value, ...i.cacheFiles], p = u.length > 0 ? JSON.stringify(u.map((m) => ({ name: m.name, id: m.id }))) : null;
    i.cacheFiles = [], A(p);
  }, f = (u) => {
    const p = u.name.trim().toLowerCase();
    if (o.some((D) => p.endsWith(`.${D}`)))
      return ibiz.message.error(`不可上传 ${o.join("、")}类型的文件！`), !1;
    i.count += 1;
  }, g = (u) => {
    u && (i.cacheFiles.push({
      name: u.filename,
      id: u.fileid
    }), i.count -= 1, i.count === 0 && Q());
  }, w = (u, p) => {
    throw i.count -= 1, new In({
      response: { data: p, status: u.status }
      // eslint-disable-next-line @typescript-eslint/no-explicit-any
    });
  }, E = (u) => {
    if (e.disabled)
      return;
    const p = t.value.findIndex((m) => m.id === u.id);
    p !== -1 && t.value.splice(p, 1), Q();
  }, C = (u) => {
    const p = u.url || B.value.replace("%fileId%", u.id);
    r.fileDownload({ url: p, name: u.name });
  }, h = R(!1), y = R(""), v = R("");
  return {
    uploadUrl: s,
    downloadUrl: B,
    headers: n,
    files: t,
    onDownload: C,
    onError: w,
    onRemove: E,
    onSuccess: g,
    beforeUpload: f,
    showModal: h,
    modalTitle: y,
    iframeUrl: v,
    onModalCancel: () => {
      h.value = !1, y.value = "", v.value = "";
    },
    previewFile: (u) => {
      if (!u.isPreview)
        return;
      y.value = u.name;
      const p = window.Environment.previewFileUrl;
      if (p) {
        const m = encodeURIComponent(
          Ds(
            `${window.location.origin}${u.url}?fullfilename=${u.name}`
          )
        );
        v.value = `${p}/onlinePreview?url=${m}`, window.open(v.value, "_blank");
      }
    }
  };
}
const Pl = hA({
  name: "SyFileUpload",
  props: Ns(),
  emits: Ps(),
  setup(e, {
    emit: A
  }) {
    const r = DA("sy-file-upload"), t = e.controller, {
      uploadUrl: n,
      headers: s,
      files: B,
      onDownload: i,
      onError: a,
      onRemove: o,
      onSuccess: c,
      beforeUpload: l,
      showModal: Q,
      modalTitle: f,
      iframeUrl: g,
      onModalCancel: w,
      previewFile: E
    } = Nl(e, (C) => {
      A("change", C);
    }, t);
    return {
      ns: r,
      c: t,
      uploadUrl: n,
      headers: s,
      files: B,
      onDownload: i,
      onError: a,
      onRemove: o,
      onSuccess: c,
      beforeUpload: l,
      showModal: Q,
      modalTitle: f,
      iframeUrl: g,
      onModalCancel: w,
      previewFile: E
    };
  },
  render(e) {
    return e("div", {
      class: [this.ns.b(), this.disabled ? this.ns.m("disabled") : "", this.readonly ? this.ns.m("readonly") : ""]
    }, [e("IUpload", {
      ref: "fileUpload",
      props: {
        action: this.uploadUrl,
        headers: this.headers,
        disabled: this.disabled,
        "default-file-list": this.files,
        multiple: this.c.model.multiple,
        type: this.c.model.isDrag ? "drag" : "select",
        accept: this.c.model.accept,
        "before-upload": this.beforeUpload,
        "on-success": this.onSuccess,
        "on-error": this.onError,
        "on-remove": this.onRemove,
        "on-preview": this.onDownload,
        "show-upload-list": !1
      }
    }, [this.c.model.isDrag ? e("div", {
      class: this.ns.bm("box", "drag")
    }, [e("i-icon", {
      attrs: {
        type: "md-cloud-upload"
      }
    }), e("div", {
      class: this.ns.be("box", "title")
    }, [e("span", ["将文件拖到此处，或"]), e("span", ["点击上传"])])]) : e("i-button", {
      attrs: {
        icon: "ios-cloud-upload-outline"
      },
      class: this.ns.bm("box", "select")
    }, ["上传文件"])]), e("div", {
      class: this.ns.b("file-list")
    }, [this.files.map((A) => e("div", {
      class: this.ns.b("file-item"),
      key: A.id
    }, [e("div", {
      class: this.ns.b("file-item-right")
    }, [e("div", {
      class: this.ns.b("file-item-right-title"),
      on: {
        click: () => this.previewFile(A)
      }
    }, [A.name]), e("div", {
      class: this.ns.b("file-item-right-action")
    }, [e("i-icon", {
      attrs: {
        type: "md-download"
      },
      on: {
        click: () => this.onDownload(A)
      }
    }), A.isPreview ? e("i-icon", {
      attrs: {
        type: "md-eye"
      },
      on: {
        click: () => this.previewFile(A)
      }
    }) : null, this.disabled || this.readonly ? null : e("i-icon", {
      attrs: {
        type: "md-close"
      },
      on: {
        click: () => this.onRemove(A)
      }
    })])])]))]), e("i-modal", {
      attrs: {
        value: this.showModal,
        title: this.modalTitle,
        "class-name": this.ns.b("modal"),
        width: "70%",
        transfer: !1,
        "footer-hide": !0
      },
      on: {
        "on-cancel": this.onModalCancel
      }
    }, [e("iframe", {
      class: this.ns.b("iframe"),
      attrs: {
        src: this.iframeUrl
      }
    })])]);
  }
});
function Br(e, A, r) {
  if (e.url = A.replace("%fileId%", e.id), e.status || (e.status = "finished"), !e.fileName) {
    const t = e.name.lastIndexOf(".");
    e.fileName = e.name.substring(0, t), e.fileExt = e.name.substring(t), e.isImage = Zs(e.name);
  }
  if (!r)
    e.isPreview = !1;
  else {
    e.name || (e.isPreview = !1);
    const t = e.name.trim().toLowerCase();
    e.isPreview = r.some((n) => t.endsWith(`.${n}`));
  }
  return e;
}
function xs(e) {
  const A = R(""), r = R(""), t = R([]);
  return CA(
    e.data,
    (n) => {
      if (n) {
        const s = e.controller.value.calcBaseUrl(n);
        A.value = s.uploadUrl, r.value = s.downloadUrl;
      }
    },
    { immediate: !0, deep: !0 }
  ), CA(
    e.value,
    (n) => {
      t.value = n ? JSON.parse(n) : [], t.value.length && r.value && t.value.forEach((s) => {
        Br(s, r.value);
      });
    },
    { immediate: !0 }
  ), CA(
    r,
    (n) => {
      n && t.value.length && t.value.forEach((s) => {
        Br(s, n);
      });
    },
    { immediate: !0 }
  ), {
    downloadUrl: r,
    uploadUrl: A,
    valueList: t
  };
}
function Ss(e) {
  var U, K, L, u;
  const A = R("undo"), r = R([]), { downloadUrl: t, value: n, uploadUrl: s, controller: B } = e, i = (K = (U = B == null ? void 0 : B.value) == null ? void 0 : U.editorParams) == null ? void 0 : K.blackList;
  let a = [];
  i && typeof i == "string" && (a = i.split(","));
  const o = (u = (L = B == null ? void 0 : B.value) == null ? void 0 : L.editorParams) == null ? void 0 : u.previewList;
  let c = [];
  o && typeof o == "string" && (c = o.split(",")), CA(
    n,
    (p) => {
      p.length > 0 && (r.value = [], p.forEach((m) => {
        r.value.push(
          Br(m, t.value, c)
        );
      }));
    },
    {
      immediate: !0,
      deep: !0
    }
  );
  const l = (p, m) => {
    const D = [];
    return m.forEach((I, G) => {
      const j = I.name.trim().toLowerCase();
      if (a.some((sA) => j.endsWith(`.${sA}`))) {
        D.push(G);
        return;
      }
      const W = c.some((sA) => j.endsWith(`.${sA}`));
      r.value.push({
        name: I.name,
        status: I.status,
        percentage: I.percentage,
        id: I.uid,
        url: "",
        isPreview: W
      });
    }), D.length === m.length ? (ibiz.message.error(`不可上传 ${a.join("、")}类型的文件！`), !1) : (D.length && (D.forEach((I) => {
      p.splice(I, 1), m.splice(I, 1);
    }), ibiz.message.error(`不可上传 ${a.join("、")}类型的文件！`)), !0);
  }, Q = (p) => {
    p.forEach((m) => {
      r.value.find((D) => D.id === m.uid ? (D.percentage = m.percentage, !0) : !1);
    });
  }, f = (p, m) => {
    p.forEach((D) => {
      r.value.find((I) => I.id === D.uid ? (I.status = D.status, I.id = m.data.fileid, I.name = m.data.filename, Br(I, t.value, c), !0) : !1);
    });
  }, g = (p, m) => {
    var I;
    p.forEach((G) => {
      r.value.find((j) => j.id === G.uid ? (j.status = G.status, !0) : !1);
    });
    const D = new In(m);
    ibiz.notification.error({
      title: (I = D.status) == null ? void 0 : I.toString(),
      desc: D.message,
      duration: 10
    });
  }, w = (p) => {
    r.value = r.value.filter((m) => m.status === "finished"), A.value = "done";
  }, E = () => {
    qs({
      multiple: e.multiple,
      accept: e.accept,
      uploadUrl: s.value,
      beforeUpload: l,
      progress: Q,
      success: f,
      error: g,
      finish: w
    });
  }, C = R(!1), h = R(""), y = R("");
  return {
    selectFile: E,
    fileList: r,
    uploadState: A,
    showModal: C,
    modalTitle: h,
    iframeUrl: y,
    onModalCancel: () => {
      C.value = !1, h.value = "", y.value = "";
    },
    previewFile: (p) => {
      if (!p.isPreview)
        return;
      h.value = p.name;
      const m = window.Environment.previewFileUrl;
      if (m) {
        const D = encodeURIComponent(
          Ds(
            `${window.location.origin}${p.url}?fullfilename=${p.name}`
          )
        );
        y.value = `${m}/onlinePreview?url=${D}`, window.open(y.value, "_blank");
      }
    }
  };
}
const _l = hA({
  name: "SyGridFileUpload",
  props: at(),
  setup(e) {
    const A = DA("sy-grid-file-upload"), {
      value: r,
      data: t,
      controller: n
    } = ot(e), {
      downloadUrl: s,
      uploadUrl: B,
      valueList: i
    } = xs({
      value: r,
      data: t,
      controller: n
    }), {
      fileList: a,
      showModal: o,
      modalTitle: c,
      iframeUrl: l,
      previewFile: Q,
      onModalCancel: f
    } = Ss({
      downloadUrl: s,
      uploadUrl: B,
      value: i
    });
    return {
      ns: A,
      fileList: a,
      showModal: o,
      modalTitle: c,
      iframeUrl: l,
      downloadFile: (w) => {
        e.controller.fileDownload(w);
      },
      previewFile: Q,
      onModalCancel: f
    };
  },
  render() {
    return T("grid-editor", {
      attrs: {
        disabled: this.disabled,
        readonly: this.readonly
      },
      class: [this.ns.b(), this.disabled ? this.ns.m("disabled") : "", this.readonly ? this.ns.m("readonly") : ""]
    }, [T("div", {
      class: this.ns.b("file-list")
    }, [this.fileList.map((e) => T("div", {
      class: this.ns.b("file-item"),
      key: e.id
    }, [T("div", {
      class: this.ns.b("file-item-title"),
      on: {
        click: () => this.previewFile(e)
      }
    }, [e.name]), T("div", {
      class: this.ns.b("file-item-action")
    }, [T("i-icon", {
      attrs: {
        type: "md-download"
      },
      on: {
        click: () => this.downloadFile(e)
      }
    }), e.isPreview ? T("i-icon", {
      attrs: {
        type: "md-eye"
      },
      on: {
        click: () => this.previewFile(e)
      }
    }) : null])]))]), T("i-modal", {
      attrs: {
        value: this.showModal,
        title: this.modalTitle,
        "class-name": this.ns.b("modal"),
        width: "70%",
        transfer: !1,
        "footer-hide": !0
      },
      on: {
        "on-cancel": this.onModalCancel
      }
    }, [T("iframe", {
      class: this.ns.b("iframe"),
      attrs: {
        src: this.iframeUrl
      }
    })])]);
  }
}), Xl = hA({
  name: "SyGridFileUploadContainer",
  props: at(),
  emits: Hn(),
  render(e) {
    return this.disabled || this.readonly ? e("SyGridFileUpload", {
      props: {
        ...this.$props
      }
    }) : e("SyEditGridFileUpload", {
      props: {
        ...this.$props
      },
      on: {
        change: (A, r) => {
          this.$emit("change", A, r);
        },
        rowSave: () => {
          this.$emit("rowSave");
        }
      }
    });
  }
});
const kl = hA({
  name: "SyEditGridFileUploadPopover",
  props: {
    uploadUrl: {
      type: String,
      required: !0
    },
    downloadUrl: {
      type: String,
      required: !0
    },
    value: {
      type: Array,
      required: !0
    },
    controller: {
      type: vn,
      required: !0
    }
  },
  emits: {
    close: (e) => !0
  },
  setup(e, {
    emit: A
  }) {
    const r = DA("sy-edit-grid-file-upload-popover"), {
      downloadUrl: t,
      value: n,
      uploadUrl: s,
      controller: B
    } = ot(e), {
      fileList: i,
      uploadState: a,
      selectFile: o
    } = Ss({
      downloadUrl: t,
      value: n,
      uploadUrl: s,
      controller: B
    }), c = R(), l = R(!1), Q = _s(c, async (w) => {
      A("close", {
        isModified: l.value,
        resultFiles: i.value
      });
    });
    return CA(a, (w) => {
      w === "done" ? (l.value = !0, Q.proceed()) : w === "loading" && Q.pause();
    }), {
      ns: r,
      componentRef: c,
      fileList: i,
      deleteFile: (w) => {
        const E = i.value.findIndex((C) => C.id === w.id);
        i.value.splice(E, 1), l.value = !0;
      },
      selectFile: o,
      downloadFile: (w) => {
        e.controller.fileDownload(w);
      }
    };
  },
  render() {
    return T("div", {
      ref: "componentRef",
      style: "width:300px",
      class: this.ns.b()
    }, [T("div", {
      class: this.ns.b("file-list")
    }, [this.fileList.map((e) => T("div", {
      class: this.ns.b("file-item"),
      key: e.id
    }, [T("div", {
      class: this.ns.b("file-item-title"),
      on: {
        click: () => this.downloadFile(e)
      }
    }, [e.name]), T("div", {
      class: this.ns.b("file-item-action")
    }, [T("i-icon", {
      attrs: {
        type: "md-close"
      },
      on: {
        click: () => this.deleteFile(e)
      }
    })])]))]), T("div", {
      on: {
        click: () => this.selectFile()
      },
      class: this.ns.e("button")
    }, [T("i-icon", {
      attrs: {
        type: "md-add"
      }
    }), "添加文件"])]);
  }
});
const Jl = hA({
  name: "SyEditGridFileUpload",
  props: at(),
  emits: Hn(),
  setup(e, {
    emit: A
  }) {
    const r = DA("sy-edit-grid-file-upload"), {
      value: t,
      data: n,
      controller: s
    } = ot(e), {
      downloadUrl: B,
      uploadUrl: i,
      valueList: a
    } = xs({
      value: t,
      data: n,
      controller: s
    }), o = R(), c = async () => {
      if (!o.value)
        throw new zs("容器元素不存在");
      const l = o.value.$el, Q = l.offsetHeight, f = ibiz.overlay.createPopover((E) => E(kl, {
        props: {
          value: a.value,
          uploadUrl: i.value,
          downloadUrl: B.value,
          controller: s.value
        },
        on: {
          close: (C) => {
            f.dismiss(C);
          }
        }
      }), void 0, {
        noArrow: !0,
        placement: "bottom-start",
        offsetOpts: {
          mainAxis: -Q,
          crossAxis: 0
        }
      });
      await f.present(l);
      const {
        isModified: g,
        resultFiles: w
      } = await f.onWillDismiss();
      if (g) {
        const E = w.length > 0 ? JSON.stringify(w.map((C) => ({
          name: C.name,
          id: C.id
        }))) : null;
        A("change", E), A("rowSave");
      }
    };
    return Xs(o, "click", (l) => {
      e.disabled || c();
    }), {
      ns: r,
      valueList: a,
      componentRef: o
    };
  },
  render() {
    return T("grid-editor", {
      attrs: {
        disabled: this.disabled,
        readonly: this.readonly
      },
      ref: "componentRef",
      class: this.ns.b()
    }, [T("div", {
      class: this.ns.b("file-list")
    }, [this.valueList.map((e) => T("div", {
      class: this.ns.b("file-item"),
      key: e.id
    }, [T("div", {
      class: this.ns.b("file-item-title")
    }, [e.name])]))])]);
  }
});
class Wl {
  constructor() {
    pA(this, "component", Dl);
  }
}
class Yl {
  constructor() {
    pA(this, "formEditor", "SyFileUpload");
    pA(this, "gridEditor", "SyGridFileUploadContainer");
  }
  async createController(A, r) {
    const t = new vn(A, r);
    return await t.init(), t;
  }
}
const Zl = new Gs(import.meta.url), nQ = {
  mateUrl: import.meta.url,
  // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
  install(e) {
    Zl.loadStyle(["/style.css"]), ibiz.register.view.register(
      "VIEW_CUSTOM_SyWfDynaEditView3",
      new AB()
    ), ibiz.register.view.register(
      "VIEW_CUSTOM_SyEditView3",
      new rB()
    ), ibiz.register.uiAction.register(
      "DEUIACTION_ExportAsImagePlugin",
      new Ll()
    ), ibiz.register.view.register(
      "VIEW_CUSTOM_PresetWFChartView",
      new Wl()
    ), e.component("SyFileUpload", Pl), e.component("SyGridFileUpload", _l), e.component("SyEditGridFileUpload", Jl), e.component("SyGridFileUploadContainer", Xl), ibiz.register.editor.register(
      "EDITOR_CUSTOMSTYLE_SyFileUpload",
      new Yl()
    );
  }
};
export {
  nQ as default
};
