var si = Object.defineProperty;
var ni = (t, A, e) => A in t ? si(t, A, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[A] = e;
var q = (t, A, e) => (ni(t, typeof A != "symbol" ? A + "" : A, e), e);
import { EditFormModel as ii, ViewType as iA, AppEntityModel as Er, UnsupportedModelError as Gs, DefectModelError as xr, getModelService as ai, ModelUtil as Bi } from "@ibiz-template/model";
import { ViewMode as Ns, UIActionHandler as oi, safeRedirect as Vs, PluginStaticResource as ci } from "@ibiz-template/runtime";
import { useWFStepTraceViewController as li, usePropsWatch as Ps, useNamespace as yA, useViewController as vr, getUploadProps as ui, getEditorEmits as ks, getGridUploadProps as Hr, getGridEditorEmits as _s, useClickOutside as gi, useEventListener as wi, getDataPickerProps as fi } from "@ibiz-template/vue-util";
import { defineComponent as hA, getCurrentInstance as Ut, ref as O, onMounted as Qi, h as x, watch as QA, computed as Xs, toRefs as mr } from "vue";
import { createUUID as it, getCookie as hi, isNilOrEmpty as Ci, ascSort as Mr, descSort as di } from "qx-util";
import { WFDynaEditView3Controller as Ui, EditView3Controller as Fi, WFStepTraceViewController as pi, UploadEditorController as Js, PickerEditorController as Ei } from "@ibiz-template/controller";
import { HttpError as Ws, isImage as vi, uploadFile as Hi, RuntimeError as ZA, HttpResponse as J } from "@ibiz-template/core";
import { isEmpty as eA, isNil as uA, clone as HA, equals as kA, where as we } from "ramda";
import { WorkFlowService as mi, EntityService as Ii } from "@ibiz-template/service";
const Ys = hA({
  name: "WFStepTraceGrid",
  props: {
    context: Object,
    params: {
      type: Object
    },
    modelPath: {
      type: String,
      required: !0
    },
    modal: {
      type: Object
    },
    deName: {
      type: String,
      required: !0
    },
    modelData: {
      type: ii,
      required: !0
    }
  },
  setup(t) {
    const {
      proxy: A
    } = Ut(), e = li(A, t.modelPath);
    Ps(A, "deName", e.setDeName.bind(e));
    const r = yA("wf-step-trace-grid"), s = O([]), n = O([]), i = O([{
      title: "序号",
      key: "index",
      width: 60,
      resizable: !0,
      render: (B, o) => s.value.findIndex((l) => l.id === o.row.id) === -1 ? null : B("span", {
        style: {
          textAlign: "center"
        }
      }, o.index + 1)
    }, {
      title: "审批人",
      key: "personName",
      width: 180,
      tree: !0,
      resizable: !0
    }, {
      title: "审批部门",
      key: "deptName",
      width: 180,
      resizable: !0
    }, {
      title: "处理环节",
      key: "nodeName",
      width: 200,
      resizable: !0,
      className: "clhj"
    }, {
      title: "审批(递交时间)",
      key: "time",
      width: 170,
      resizable: !0
    }, {
      title: "审批动作",
      key: "content",
      width: 150,
      resizable: !0
    }, {
      title: "审批意见",
      key: "comment",
      minWidth: 100
    }]);
    Qi(() => {
      var o, c;
      const B = (c = (o = t.modelData) == null ? void 0 : o.source.getPSControlParam()) == null ? void 0 : c.ctrlParams;
      if (B && B.SHOWCOLUMNS)
        try {
          n.value = JSON.parse(B.SHOWCOLUMNS);
        } catch (l) {
          console.log("WFStepTraceGrid部件参数配置错误", l);
        }
      if (n.value.length > 0) {
        const l = i.value.filter((u) => n.value.includes(u.title));
        i.value = l;
      }
    });
    const a = (B, o, c = !1) => {
      B.comments.length > 0 && B.comments.forEach((l) => {
        var u, f, g;
        c && l.type === "启动流程" || o.push({
          id: it(),
          nodeName: B.userTaskName,
          personName: (u = l.authorName) == null ? void 0 : u.replace(/\([^)]*\)[^(]*$/, ""),
          deptName: ((g = (f = l.authorName) == null ? void 0 : f.match(/.*\(([^)]*)\)[^(]*$/)) == null ? void 0 : g[1]) || "",
          time: l.time,
          content: l.type,
          comment: l.fullMessage && l.fullMessage !== "null" ? l.fullMessage : ""
        });
      });
    };
    return e.nerve.self.evt.on("mounted", () => {
      var B;
      e.data && ((B = e.data.usertasks) == null || B.forEach((o) => {
        if (o.usertasks && o.usertasks.length > 0) {
          if (o.usertasks.length === 1)
            return;
          const c = [];
          o.usertasks.forEach((l) => {
            a(l, c, !0);
          }), s.value.push({
            id: it(),
            nodeName: `${o.userTaskName}`,
            personName: "",
            deptName: "",
            time: "",
            content: "",
            comment: "",
            children: c,
            _showChildren: !0
          });
        } else
          a(o, s.value);
      }), s.value.sort((o, c) => Date.parse(o.time) - Date.parse(c.time)));
    }), {
      c: e,
      ns: r,
      gridData: s,
      columns: i
    };
  },
  render() {
    return x("div", {
      class: this.ns.b()
    }, [x("div", {
      class: this.ns.e("title")
    }, [x("span", {
      class: this.ns.e("caption")
    }, ["审批记录"])]), x("div", {
      class: this.ns.e("grid-container")
    }, [x("i-table", {
      class: this.ns.e("grid"),
      attrs: {
        columns: this.columns,
        data: this.gridData,
        "row-key": "id"
      }
    })])]);
  }
});
class yi extends Ui {
  constructor() {
    super(...arguments);
    /**
     * 分页数据
     *
     * @type {{
     *     [key: string]: {
     *       context: IContext;
     *       params: IParams;
     *       key: string;
     *     };
     *   }}
     * @memberof SyWFDynaEditView3Controller
     */
    q(this, "drPages", {});
  }
  async calcWfToolbar() {
    await super.calcWfToolbar(), this.isEditable && this.wfLinks.unshift({
      sequenceFlowName: "保存",
      type: "FORM_SAVE"
    });
  }
  async onLinkClick(e) {
    e.type === "FORM_SAVE" ? await this.save() : super.onLinkClick(e);
  }
  /**
   * 格式化脚本
   *
   * @protected
   * @param {string} scriptCode
   * @param {IData} options
   * @return {*}  {string}
   * @memberof SyWFDynaEditView3Controller
   */
  formatCode(e, r) {
    let s = e;
    return r.singleRowReturn && (s = `return (${s})`), r.isAsync && (s = `return (async function() { ${s}; } )();`), s;
  }
  /**
   * 初始化
   *
   * @protected
   * @return {*}  {Promise<void>}
   * @memberof SyWFDynaEditView3Controller
   */
  async onInit() {
    var s, n, i;
    await super.onInit();
    const e = this.model.source.M.getPSAppViewLogics;
    (e == null ? void 0 : e.find((a) => a.logicType === "SCRIPT" && a.eventNames === "onLoaded")) && ((s = this.model.drTab) != null && s.pages.length) ? this.model.drTab.pages.forEach((a) => {
      Object.assign(this.drPages[a.source.name], { visible: !1 });
    }) : (i = (n = this.model.drTab) == null ? void 0 : n.pages) == null || i.forEach((a) => {
      Object.assign(this.drPages[a.source.name], { visible: !0 });
    });
  }
  /**
   * 加载
   *
   * @return {*}  {Promise<IData>}
   * @memberof SyWFDynaEditView3Controller
   */
  async load() {
    const e = await super.load(), r = this.model.source.M.getPSAppViewLogics, s = r == null ? void 0 : r.find((n) => n.logicType === "SCRIPT" && n.eventNames === "onLoaded");
    if (s) {
      const { scriptCode: n } = s, i = this.formatCode(n, { isAsync: !0 }), a = ["view", "context", "params", "data"];
      new Function(...a, i).apply({}, [this, this.context, this.params, e]);
    }
    return this.force(), e;
  }
}
const Li = hA({
  props: {
    context: Object,
    params: {
      type: Object
    },
    modelPath: {
      type: String,
      required: !0
    },
    modal: {
      type: Object
    }
  },
  setup(t) {
    const {
      proxy: A
    } = Ut(), e = vr(A, (i, a) => new yi(t.modelPath, i, a)), r = yA(`view-${iA.DE_WF_DYNA_EDIT_VIEW3}`.toLowerCase()), s = O(["mainForm"]);
    return {
      c: e,
      ns: r,
      onTabClick: (i) => {
        s.value.includes(i) || s.value.push(i);
      },
      lazyList: s
    };
  },
  render(t) {
    const A = [];
    if (this.c.complete) {
      const {
        activeForm: e
      } = this.c;
      e && this.c.providers[e.name] && A.push(t(this.c.providers[e.name].component, {
        props: {
          modelData: e,
          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 e = this.c.model.drTab.pages[0], r = this.c.drPages[e.source.name];
      A.push(t(Ys, {
        attrs: {
          context: r.context,
          params: r.params,
          deName: this.c.model.appEntity.source.codeName,
          modal: this.modal,
          modelPath: e.embedView.source.modelPath,
          modelData: this.c.model.form
        }
      }));
    }
    return t("view-base", {
      attrs: {
        controller: this.c
      },
      scopedSlots: {
        toolbar: () => this.c.complete ? [this.c.wfLinks.length > 0 && t("wf-toolbar", {
          attrs: {
            wfLinks: this.c.wfLinks
          },
          on: {
            "wf-link-click": (e) => {
              this.c.onLinkClick(e);
            }
          }
        })] : null
      }
    }, [this.c.complete && t("i-tabs", {
      class: [this.ns.be("", "tab")],
      attrs: {
        name: this.c.model.drTab.source.name
      },
      on: {
        "on-click": this.onTabClick
      }
    }, [t("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((e) => {
      const r = this.c.drPages[e.source.name];
      if (!(!r || !r.visible))
        return t("i-tab-pane", {
          class: this.ns.be("", "tab-item"),
          attrs: {
            tab: this.c.model.drTab.source.name,
            disabled: this.c.isNewData,
            label: e.source.caption,
            name: e.source.name
          }
        }, [!this.c.isNewData && this.lazyList.includes(e.source.name) && t("ViewShell", {
          attrs: {
            context: r.context,
            params: r.params,
            modal: {
              mode: Ns.EMBED
            },
            modelPath: e.embedView.source.modelPath,
            // 流程跟踪视图用
            deName: this.c.model.appEntity.source.codeName
          },
          on: {
            neuronInit: this.c.nerve.onNeuronInit(e.source.name)
          },
          key: r.key
        })]);
    })])]);
  }
});
class bi {
  constructor() {
    q(this, "component", Li);
  }
}
class Ki extends Fi {
  constructor() {
    super(...arguments);
    q(this, "drPages", {});
  }
  /**
   * 格式化脚本
   *
   * @protected
   * @param {string} scriptCode
   * @param {IData} options
   * @return {*}  {string}
   * @memberof DynamicVisibleTabController
   */
  formatCode(e, r) {
    let s = e;
    return r.singleRowReturn && (s = `return (${s})`), r.isAsync && (s = `return (async function() { ${s}; } )();`), s;
  }
  /**
   * 初始化
   *
   * @protected
   * @return {*}  {Promise<void>}
   * @memberof DynamicVisibleTabController
   */
  async onInit() {
    var s, n, i;
    await super.onInit();
    const e = this.model.source.M.getPSAppViewLogics;
    (e == null ? void 0 : e.find((a) => a.logicType === "SCRIPT" && a.eventNames === "onLoaded")) && ((s = this.model.drTab) != null && s.pages.length) ? this.model.drTab.pages.forEach((a) => {
      Object.assign(this.drPages[a.source.name], { visible: !1 });
    }) : (i = (n = this.model.drTab) == null ? void 0 : n.pages) == null || i.forEach((a) => {
      Object.assign(this.drPages[a.source.name], { visible: !0 });
    });
  }
  async load() {
    const e = await super.load(), r = this.model.source.M.getPSAppViewLogics, s = r == null ? void 0 : r.find((n) => n.logicType === "SCRIPT" && n.eventNames === "onLoaded");
    if (s) {
      const { scriptCode: n } = s, i = this.formatCode(n, { isAsync: !0 }), a = ["view", "context", "params", "data"];
      new Function(...a, i).apply({}, [this, this.context, this.params, e]);
    }
    return this.force(), e;
  }
}
const Di = hA({
  name: "SyEditView3",
  props: {
    context: Object,
    params: {
      type: Object
    },
    modelPath: {
      type: String,
      required: !0
    },
    modal: {
      type: Object
    }
  },
  setup(t) {
    const {
      proxy: A
    } = Ut(), e = vr(A, (i, a) => new Ki(t.modelPath, i, a)), r = yA("view-deeditview3"), s = O(["mainForm"]);
    return {
      c: e,
      ns: r,
      onTabClick: (i) => {
        s.value.includes(i) || s.value.push(i);
      },
      lazyList: s
    };
  },
  render(t) {
    return t("view-base", {
      attrs: {
        controller: this.c
      }
    }, [this.c.complete && t("i-tabs", {
      class: [this.ns.be("", "tab")],
      attrs: {
        name: this.c.model.drTab.source.name
      },
      on: {
        "on-click": this.onTabClick
      }
    }, [t("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"
      }
    }, [t("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)
      }
    }), t(Ys, {
      attrs: {
        modelData: this.c.model.form,
        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 e = this.c.drPages[A.source.name];
      if (!(!e || !e.visible))
        return t("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) && t("ViewShell", {
          attrs: {
            context: e.context,
            params: e.params,
            modal: {
              mode: Ns.EMBED
            },
            modelPath: A.embedView.source.modelPath,
            // 流程跟踪视图用
            deName: this.c.model.appEntity.source.codeName
          },
          on: {
            neuronInit: this.c.nerve.onNeuronInit(A.source.name)
          },
          key: e.key
        })]);
    })])]);
  }
});
class Si {
  constructor() {
    q(this, "component", Di);
  }
}
/*!
 * 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 Ar = function(t, A) {
  return Ar = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, r) {
    e.__proto__ = r;
  } || function(e, r) {
    for (var s in r)
      Object.prototype.hasOwnProperty.call(r, s) && (e[s] = r[s]);
  }, Ar(t, A);
};
function gA(t, A) {
  if (typeof A != "function" && A !== null)
    throw new TypeError("Class extends value " + String(A) + " is not a constructor or null");
  Ar(t, A);
  function e() {
    this.constructor = t;
  }
  t.prototype = A === null ? Object.create(A) : (e.prototype = A.prototype, new e());
}
var er = function() {
  return er = Object.assign || function(A) {
    for (var e, r = 1, s = arguments.length; r < s; r++) {
      e = arguments[r];
      for (var n in e)
        Object.prototype.hasOwnProperty.call(e, n) && (A[n] = e[n]);
    }
    return A;
  }, er.apply(this, arguments);
};
function AA(t, A, e, r) {
  function s(n) {
    return n instanceof e ? n : new e(function(i) {
      i(n);
    });
  }
  return new (e || (e = Promise))(function(n, i) {
    function a(c) {
      try {
        o(r.next(c));
      } catch (l) {
        i(l);
      }
    }
    function B(c) {
      try {
        o(r.throw(c));
      } catch (l) {
        i(l);
      }
    }
    function o(c) {
      c.done ? n(c.value) : s(c.value).then(a, B);
    }
    o((r = r.apply(t, A || [])).next());
  });
}
function $(t, A) {
  var e = { label: 0, sent: function() {
    if (n[0] & 1)
      throw n[1];
    return n[1];
  }, trys: [], ops: [] }, r, s, n, i;
  return i = { next: a(0), throw: a(1), return: a(2) }, typeof Symbol == "function" && (i[Symbol.iterator] = function() {
    return this;
  }), i;
  function a(o) {
    return function(c) {
      return B([o, c]);
    };
  }
  function B(o) {
    if (r)
      throw new TypeError("Generator is already executing.");
    for (; e; )
      try {
        if (r = 1, s && (n = o[0] & 2 ? s.return : o[0] ? s.throw || ((n = s.return) && n.call(s), 0) : s.next) && !(n = n.call(s, o[1])).done)
          return n;
        switch (s = 0, n && (o = [o[0] & 2, n.value]), o[0]) {
          case 0:
          case 1:
            n = o;
            break;
          case 4:
            return e.label++, { value: o[1], done: !1 };
          case 5:
            e.label++, s = o[1], o = [0];
            continue;
          case 7:
            o = e.ops.pop(), e.trys.pop();
            continue;
          default:
            if (n = e.trys, !(n = n.length > 0 && n[n.length - 1]) && (o[0] === 6 || o[0] === 2)) {
              e = 0;
              continue;
            }
            if (o[0] === 3 && (!n || o[1] > n[0] && o[1] < n[3])) {
              e.label = o[1];
              break;
            }
            if (o[0] === 6 && e.label < n[1]) {
              e.label = n[1], n = o;
              break;
            }
            if (n && e.label < n[2]) {
              e.label = n[2], e.ops.push(o);
              break;
            }
            n[2] && e.ops.pop(), e.trys.pop();
            continue;
        }
        o = A.call(t, e);
      } catch (c) {
        o = [6, c], s = 0;
      } finally {
        r = n = 0;
      }
    if (o[0] & 5)
      throw o[1];
    return { value: o[0] ? o[1] : void 0, done: !0 };
  }
}
function Se(t, A, e) {
  if (e || arguments.length === 2)
    for (var r = 0, s = A.length, n; r < s; r++)
      (n || !(r in A)) && (n || (n = Array.prototype.slice.call(A, 0, r)), n[r] = A[r]);
  return t.concat(n || A);
}
var IA = (
  /** @class */
  function() {
    function t(A, e, r, s) {
      this.left = A, this.top = e, this.width = r, this.height = s;
    }
    return t.prototype.add = function(A, e, r, s) {
      return new t(this.left + A, this.top + e, this.width + r, this.height + s);
    }, t.fromClientRect = function(A, e) {
      return new t(e.left + A.windowBounds.left, e.top + A.windowBounds.top, e.width, e.height);
    }, t.fromDOMRectList = function(A, e) {
      var r = Array.from(e).find(function(s) {
        return s.width !== 0;
      });
      return r ? new t(r.left + A.windowBounds.left, r.top + A.windowBounds.top, r.width, r.height) : t.EMPTY;
    }, t.EMPTY = new t(0, 0, 0, 0), t;
  }()
), Ft = function(t, A) {
  return IA.fromClientRect(t, A.getBoundingClientRect());
}, Ti = function(t) {
  var A = t.body, e = t.documentElement;
  if (!A || !e)
    throw new Error("Unable to get document size");
  var r = Math.max(Math.max(A.scrollWidth, e.scrollWidth), Math.max(A.offsetWidth, e.offsetWidth), Math.max(A.clientWidth, e.clientWidth)), s = Math.max(Math.max(A.scrollHeight, e.scrollHeight), Math.max(A.offsetHeight, e.offsetHeight), Math.max(A.clientHeight, e.clientHeight));
  return new IA(0, 0, r, s);
}, pt = function(t) {
  for (var A = [], e = 0, r = t.length; e < r; ) {
    var s = t.charCodeAt(e++);
    if (s >= 55296 && s <= 56319 && e < r) {
      var n = t.charCodeAt(e++);
      (n & 64512) === 56320 ? A.push(((s & 1023) << 10) + (n & 1023) + 65536) : (A.push(s), e--);
    } else
      A.push(s);
  }
  return A;
}, P = function() {
  for (var t = [], A = 0; A < arguments.length; A++)
    t[A] = arguments[A];
  if (String.fromCodePoint)
    return String.fromCodePoint.apply(String, t);
  var e = t.length;
  if (!e)
    return "";
  for (var r = [], s = -1, n = ""; ++s < e; ) {
    var i = t[s];
    i <= 65535 ? r.push(i) : (i -= 65536, r.push((i >> 10) + 55296, i % 1024 + 56320)), (s + 1 === e || r.length > 16384) && (n += String.fromCharCode.apply(String, r), r.length = 0);
  }
  return n;
}, Or = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", xi = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
for (var Te = 0; Te < Or.length; Te++)
  xi[Or.charCodeAt(Te)] = Te;
var Rr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", fe = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
for (var xe = 0; xe < Rr.length; xe++)
  fe[Rr.charCodeAt(xe)] = xe;
var Mi = function(t) {
  var A = t.length * 0.75, e = t.length, r, s = 0, n, i, a, B;
  t[t.length - 1] === "=" && (A--, t[t.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 (r = 0; r < e; r += 4)
    n = fe[t.charCodeAt(r)], i = fe[t.charCodeAt(r + 1)], a = fe[t.charCodeAt(r + 2)], B = fe[t.charCodeAt(r + 3)], c[s++] = n << 2 | i >> 4, c[s++] = (i & 15) << 4 | a >> 2, c[s++] = (a & 3) << 6 | B & 63;
  return o;
}, Oi = function(t) {
  for (var A = t.length, e = [], r = 0; r < A; r += 2)
    e.push(t[r + 1] << 8 | t[r]);
  return e;
}, Ri = function(t) {
  for (var A = t.length, e = [], r = 0; r < A; r += 4)
    e.push(t[r + 3] << 24 | t[r + 2] << 16 | t[r + 1] << 8 | t[r]);
  return e;
}, JA = 5, Ir = 6 + 5, St = 2, Gi = Ir - JA, Zs = 65536 >> JA, Ni = 1 << JA, Tt = Ni - 1, Vi = 1024 >> JA, Pi = Zs + Vi, ki = Pi, _i = 32, Xi = ki + _i, Ji = 65536 >> Ir, Wi = 1 << Gi, Yi = Wi - 1, Gr = function(t, A, e) {
  return t.slice ? t.slice(A, e) : new Uint16Array(Array.prototype.slice.call(t, A, e));
}, Zi = function(t, A, e) {
  return t.slice ? t.slice(A, e) : new Uint32Array(Array.prototype.slice.call(t, A, e));
}, zi = function(t, A) {
  var e = Mi(t), r = Array.isArray(e) ? Ri(e) : new Uint32Array(e), s = Array.isArray(e) ? Oi(e) : new Uint16Array(e), n = 24, i = Gr(s, n / 2, r[4] / 2), a = r[5] === 2 ? Gr(s, (n + r[4]) / 2) : Zi(r, Math.ceil((n + r[4]) / 4));
  return new $i(r[0], r[1], r[2], r[3], i, a);
}, $i = (
  /** @class */
  function() {
    function t(A, e, r, s, n, i) {
      this.initialValue = A, this.errorValue = e, this.highStart = r, this.highValueIndex = s, this.index = n, this.data = i;
    }
    return t.prototype.get = function(A) {
      var e;
      if (A >= 0) {
        if (A < 55296 || A > 56319 && A <= 65535)
          return e = this.index[A >> JA], e = (e << St) + (A & Tt), this.data[e];
        if (A <= 65535)
          return e = this.index[Zs + (A - 55296 >> JA)], e = (e << St) + (A & Tt), this.data[e];
        if (A < this.highStart)
          return e = Xi - Ji + (A >> Ir), e = this.index[e], e += A >> JA & Yi, e = this.index[e], e = (e << St) + (A & Tt), this.data[e];
        if (A <= 1114111)
          return this.data[this.highValueIndex];
      }
      return this.errorValue;
    }, t;
  }()
), Nr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", ji = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
for (var Me = 0; Me < Nr.length; Me++)
  ji[Nr.charCodeAt(Me)] = Me;
var qi = "[encoded data, 52888 characters]", Vr = 50, Aa = 1, zs = 2, $s = 3, ea = 4, ta = 5, Pr = 7, js = 8, kr = 9, SA = 10, tr = 11, _r = 12, rr = 13, ra = 14, Qe = 15, sr = 16, Oe = 17, ce = 18, sa = 19, Xr = 20, nr = 21, le = 22, xt = 23, $A = 24, rA = 25, he = 26, Ce = 27, jA = 28, na = 29, _A = 30, ia = 31, Re = 32, Ge = 33, ir = 34, ar = 35, Br = 36, ye = 37, or = 38, tt = 39, rt = 40, Mt = 41, qs = 42, aa = 43, Ba = [9001, 65288], An = "!", D = "×", Ne = "÷", cr = zi(qi), pA = [_A, Br], lr = [Aa, zs, $s, ta], en = [SA, js], Jr = [Ce, he], oa = lr.concat(en), Wr = [or, tt, rt, ir, ar], ca = [Qe, rr], la = function(t, A) {
  A === void 0 && (A = "strict");
  var e = [], r = [], s = [];
  return t.forEach(function(n, i) {
    var a = cr.get(n);
    if (a > Vr ? (s.push(!0), a -= Vr) : s.push(!1), ["normal", "auto", "loose"].indexOf(A) !== -1 && [8208, 8211, 12316, 12448].indexOf(n) !== -1)
      return r.push(i), e.push(sr);
    if (a === ea || a === tr) {
      if (i === 0)
        return r.push(i), e.push(_A);
      var B = e[i - 1];
      return oa.indexOf(B) === -1 ? (r.push(r[i - 1]), e.push(B)) : (r.push(i), e.push(_A));
    }
    if (r.push(i), a === ia)
      return e.push(A === "strict" ? nr : ye);
    if (a === qs || a === na)
      return e.push(_A);
    if (a === aa)
      return n >= 131072 && n <= 196605 || n >= 196608 && n <= 262141 ? e.push(ye) : e.push(_A);
    e.push(a);
  }), [r, e, s];
}, Ot = function(t, A, e, r) {
  var s = r[e];
  if (Array.isArray(t) ? t.indexOf(s) !== -1 : t === s)
    for (var n = e; n <= r.length; ) {
      n++;
      var i = r[n];
      if (i === A)
        return !0;
      if (i !== SA)
        break;
    }
  if (s === SA)
    for (var n = e; n > 0; ) {
      n--;
      var a = r[n];
      if (Array.isArray(t) ? t.indexOf(a) !== -1 : t === a)
        for (var B = e; B <= r.length; ) {
          B++;
          var i = r[B];
          if (i === A)
            return !0;
          if (i !== SA)
            break;
        }
      if (a !== SA)
        break;
    }
  return !1;
}, Yr = function(t, A) {
  for (var e = t; e >= 0; ) {
    var r = A[e];
    if (r === SA)
      e--;
    else
      return r;
  }
  return 0;
}, ua = function(t, A, e, r, s) {
  if (e[r] === 0)
    return D;
  var n = r - 1;
  if (Array.isArray(s) && s[n] === !0)
    return D;
  var i = n - 1, a = n + 1, B = A[n], o = i >= 0 ? A[i] : 0, c = A[a];
  if (B === zs && c === $s)
    return D;
  if (lr.indexOf(B) !== -1)
    return An;
  if (lr.indexOf(c) !== -1 || en.indexOf(c) !== -1)
    return D;
  if (Yr(n, A) === js)
    return Ne;
  if (cr.get(t[n]) === tr || (B === Re || B === Ge) && cr.get(t[a]) === tr || B === Pr || c === Pr || B === kr || [SA, rr, Qe].indexOf(B) === -1 && c === kr || [Oe, ce, sa, $A, jA].indexOf(c) !== -1 || Yr(n, A) === le || Ot(xt, le, n, A) || Ot([Oe, ce], nr, n, A) || Ot(_r, _r, n, A))
    return D;
  if (B === SA)
    return Ne;
  if (B === xt || c === xt)
    return D;
  if (c === sr || B === sr)
    return Ne;
  if ([rr, Qe, nr].indexOf(c) !== -1 || B === ra || o === Br && ca.indexOf(B) !== -1 || B === jA && c === Br || c === Xr || pA.indexOf(c) !== -1 && B === rA || pA.indexOf(B) !== -1 && c === rA || B === Ce && [ye, Re, Ge].indexOf(c) !== -1 || [ye, Re, Ge].indexOf(B) !== -1 && c === he || pA.indexOf(B) !== -1 && Jr.indexOf(c) !== -1 || Jr.indexOf(B) !== -1 && pA.indexOf(c) !== -1 || // (PR | PO) × ( OP | HY )? NU
  [Ce, he].indexOf(B) !== -1 && (c === rA || [le, Qe].indexOf(c) !== -1 && A[a + 1] === rA) || // ( OP | HY ) × NU
  [le, Qe].indexOf(B) !== -1 && c === rA || // NU ×	(NU | SY | IS)
  B === rA && [rA, jA, $A].indexOf(c) !== -1)
    return D;
  if ([rA, jA, $A, Oe, ce].indexOf(c) !== -1)
    for (var l = n; l >= 0; ) {
      var u = A[l];
      if (u === rA)
        return D;
      if ([jA, $A].indexOf(u) !== -1)
        l--;
      else
        break;
    }
  if ([Ce, he].indexOf(c) !== -1)
    for (var l = [Oe, ce].indexOf(B) !== -1 ? i : n; l >= 0; ) {
      var u = A[l];
      if (u === rA)
        return D;
      if ([jA, $A].indexOf(u) !== -1)
        l--;
      else
        break;
    }
  if (or === B && [or, tt, ir, ar].indexOf(c) !== -1 || [tt, ir].indexOf(B) !== -1 && [tt, rt].indexOf(c) !== -1 || [rt, ar].indexOf(B) !== -1 && c === rt || Wr.indexOf(B) !== -1 && [Xr, he].indexOf(c) !== -1 || Wr.indexOf(c) !== -1 && B === Ce || pA.indexOf(B) !== -1 && pA.indexOf(c) !== -1 || B === $A && pA.indexOf(c) !== -1 || pA.concat(rA).indexOf(B) !== -1 && c === le && Ba.indexOf(t[a]) === -1 || pA.concat(rA).indexOf(c) !== -1 && B === ce)
    return D;
  if (B === Mt && c === Mt) {
    for (var f = e[n], g = 1; f > 0 && (f--, A[f] === Mt); )
      g++;
    if (g % 2 !== 0)
      return D;
  }
  return B === Re && c === Ge ? D : Ne;
}, ga = function(t, A) {
  A || (A = { lineBreak: "normal", wordBreak: "normal" });
  var e = la(t, A.lineBreak), r = e[0], s = e[1], n = e[2];
  (A.wordBreak === "break-all" || A.wordBreak === "break-word") && (s = s.map(function(a) {
    return [rA, _A, qs].indexOf(a) !== -1 ? ye : a;
  }));
  var i = A.wordBreak === "keep-all" ? n.map(function(a, B) {
    return a && t[B] >= 19968 && t[B] <= 40959;
  }) : void 0;
  return [r, s, i];
}, wa = (
  /** @class */
  function() {
    function t(A, e, r, s) {
      this.codePoints = A, this.required = e === An, this.start = r, this.end = s;
    }
    return t.prototype.slice = function() {
      return P.apply(void 0, this.codePoints.slice(this.start, this.end));
    }, t;
  }()
), fa = function(t, A) {
  var e = pt(t), r = ga(e, A), s = r[0], n = r[1], i = r[2], a = e.length, B = 0, o = 0;
  return {
    next: function() {
      if (o >= a)
        return { done: !0, value: null };
      for (var c = D; o < a && (c = ua(e, n, s, ++o, i)) === D; )
        ;
      if (c !== D || o === a) {
        var l = new wa(e, c, B, o);
        return B = o, { value: l, done: !1 };
      }
      return { done: !0, value: null };
    }
  };
}, Qa = 1 << 0, ha = 1 << 1, Ke = 1 << 2, Zr = 1 << 3, at = 10, zr = 47, Ee = 92, Ca = 9, da = 32, Ve = 34, ue = 61, Ua = 35, Fa = 36, pa = 37, Pe = 39, ke = 40, ge = 41, Ea = 95, tA = 45, va = 33, Ha = 60, ma = 62, Ia = 64, ya = 91, La = 93, ba = 61, Ka = 123, _e = 63, Da = 125, $r = 124, Sa = 126, Ta = 128, jr = 65533, Rt = 42, XA = 43, xa = 44, Ma = 58, Oa = 59, Le = 46, Ra = 0, Ga = 8, Na = 11, Va = 14, Pa = 31, ka = 127, wA = -1, tn = 48, rn = 97, sn = 101, _a = 102, Xa = 117, Ja = 122, nn = 65, an = 69, Bn = 70, Wa = 85, Ya = 90, j = function(t) {
  return t >= tn && t <= 57;
}, Za = function(t) {
  return t >= 55296 && t <= 57343;
}, qA = function(t) {
  return j(t) || t >= nn && t <= Bn || t >= rn && t <= _a;
}, za = function(t) {
  return t >= rn && t <= Ja;
}, $a = function(t) {
  return t >= nn && t <= Ya;
}, ja = function(t) {
  return za(t) || $a(t);
}, qa = function(t) {
  return t >= Ta;
}, Xe = function(t) {
  return t === at || t === Ca || t === da;
}, Bt = function(t) {
  return ja(t) || qa(t) || t === Ea;
}, qr = function(t) {
  return Bt(t) || j(t) || t === tA;
}, AB = function(t) {
  return t >= Ra && t <= Ga || t === Na || t >= Va && t <= Pa || t === ka;
}, DA = function(t, A) {
  return t !== Ee ? !1 : A !== at;
}, Je = function(t, A, e) {
  return t === tA ? Bt(A) || DA(A, e) : Bt(t) ? !0 : !!(t === Ee && DA(t, A));
}, Gt = function(t, A, e) {
  return t === XA || t === tA ? j(A) ? !0 : A === Le && j(e) : j(t === Le ? A : t);
}, eB = function(t) {
  var A = 0, e = 1;
  (t[A] === XA || t[A] === tA) && (t[A] === tA && (e = -1), A++);
  for (var r = []; j(t[A]); )
    r.push(t[A++]);
  var s = r.length ? parseInt(P.apply(void 0, r), 10) : 0;
  t[A] === Le && A++;
  for (var n = []; j(t[A]); )
    n.push(t[A++]);
  var i = n.length, a = i ? parseInt(P.apply(void 0, n), 10) : 0;
  (t[A] === an || t[A] === sn) && A++;
  var B = 1;
  (t[A] === XA || t[A] === tA) && (t[A] === tA && (B = -1), A++);
  for (var o = []; j(t[A]); )
    o.push(t[A++]);
  var c = o.length ? parseInt(P.apply(void 0, o), 10) : 0;
  return e * (s + a * Math.pow(10, -i)) * Math.pow(10, B * c);
}, tB = {
  type: 2
  /* LEFT_PARENTHESIS_TOKEN */
}, rB = {
  type: 3
  /* RIGHT_PARENTHESIS_TOKEN */
}, sB = {
  type: 4
  /* COMMA_TOKEN */
}, nB = {
  type: 13
  /* SUFFIX_MATCH_TOKEN */
}, iB = {
  type: 8
  /* PREFIX_MATCH_TOKEN */
}, aB = {
  type: 21
  /* COLUMN_TOKEN */
}, BB = {
  type: 9
  /* DASH_MATCH_TOKEN */
}, oB = {
  type: 10
  /* INCLUDE_MATCH_TOKEN */
}, cB = {
  type: 11
  /* LEFT_CURLY_BRACKET_TOKEN */
}, lB = {
  type: 12
  /* RIGHT_CURLY_BRACKET_TOKEN */
}, uB = {
  type: 14
  /* SUBSTRING_MATCH_TOKEN */
}, We = {
  type: 23
  /* BAD_URL_TOKEN */
}, gB = {
  type: 1
  /* BAD_STRING_TOKEN */
}, wB = {
  type: 25
  /* CDO_TOKEN */
}, fB = {
  type: 24
  /* CDC_TOKEN */
}, QB = {
  type: 26
  /* COLON_TOKEN */
}, hB = {
  type: 27
  /* SEMICOLON_TOKEN */
}, CB = {
  type: 28
  /* LEFT_SQUARE_BRACKET_TOKEN */
}, dB = {
  type: 29
  /* RIGHT_SQUARE_BRACKET_TOKEN */
}, UB = {
  type: 31
  /* WHITESPACE_TOKEN */
}, ur = {
  type: 32
  /* EOF_TOKEN */
}, on = (
  /** @class */
  function() {
    function t() {
      this._value = [];
    }
    return t.prototype.write = function(A) {
      this._value = this._value.concat(pt(A));
    }, t.prototype.read = function() {
      for (var A = [], e = this.consumeToken(); e !== ur; )
        A.push(e), e = this.consumeToken();
      return A;
    }, t.prototype.consumeToken = function() {
      var A = this.consumeCodePoint();
      switch (A) {
        case Ve:
          return this.consumeStringToken(Ve);
        case Ua:
          var e = this.peekCodePoint(0), r = this.peekCodePoint(1), s = this.peekCodePoint(2);
          if (qr(e) || DA(r, s)) {
            var n = Je(e, r, s) ? ha : Qa, i = this.consumeName();
            return { type: 5, value: i, flags: n };
          }
          break;
        case Fa:
          if (this.peekCodePoint(0) === ue)
            return this.consumeCodePoint(), nB;
          break;
        case Pe:
          return this.consumeStringToken(Pe);
        case ke:
          return tB;
        case ge:
          return rB;
        case Rt:
          if (this.peekCodePoint(0) === ue)
            return this.consumeCodePoint(), uB;
          break;
        case XA:
          if (Gt(A, this.peekCodePoint(0), this.peekCodePoint(1)))
            return this.reconsumeCodePoint(A), this.consumeNumericToken();
          break;
        case xa:
          return sB;
        case tA:
          var a = A, B = this.peekCodePoint(0), o = this.peekCodePoint(1);
          if (Gt(a, B, o))
            return this.reconsumeCodePoint(A), this.consumeNumericToken();
          if (Je(a, B, o))
            return this.reconsumeCodePoint(A), this.consumeIdentLikeToken();
          if (B === tA && o === ma)
            return this.consumeCodePoint(), this.consumeCodePoint(), fB;
          break;
        case Le:
          if (Gt(A, this.peekCodePoint(0), this.peekCodePoint(1)))
            return this.reconsumeCodePoint(A), this.consumeNumericToken();
          break;
        case zr:
          if (this.peekCodePoint(0) === Rt)
            for (this.consumeCodePoint(); ; ) {
              var c = this.consumeCodePoint();
              if (c === Rt && (c = this.consumeCodePoint(), c === zr))
                return this.consumeToken();
              if (c === wA)
                return this.consumeToken();
            }
          break;
        case Ma:
          return QB;
        case Oa:
          return hB;
        case Ha:
          if (this.peekCodePoint(0) === va && this.peekCodePoint(1) === tA && this.peekCodePoint(2) === tA)
            return this.consumeCodePoint(), this.consumeCodePoint(), wB;
          break;
        case Ia:
          var l = this.peekCodePoint(0), u = this.peekCodePoint(1), f = this.peekCodePoint(2);
          if (Je(l, u, f)) {
            var i = this.consumeName();
            return { type: 7, value: i };
          }
          break;
        case ya:
          return CB;
        case Ee:
          if (DA(A, this.peekCodePoint(0)))
            return this.reconsumeCodePoint(A), this.consumeIdentLikeToken();
          break;
        case La:
          return dB;
        case ba:
          if (this.peekCodePoint(0) === ue)
            return this.consumeCodePoint(), iB;
          break;
        case Ka:
          return cB;
        case Da:
          return lB;
        case Xa:
        case Wa:
          var g = this.peekCodePoint(0), h = this.peekCodePoint(1);
          return g === XA && (qA(h) || h === _e) && (this.consumeCodePoint(), this.consumeUnicodeRangeToken()), this.reconsumeCodePoint(A), this.consumeIdentLikeToken();
        case $r:
          if (this.peekCodePoint(0) === ue)
            return this.consumeCodePoint(), BB;
          if (this.peekCodePoint(0) === $r)
            return this.consumeCodePoint(), aB;
          break;
        case Sa:
          if (this.peekCodePoint(0) === ue)
            return this.consumeCodePoint(), oB;
          break;
        case wA:
          return ur;
      }
      return Xe(A) ? (this.consumeWhiteSpace(), UB) : j(A) ? (this.reconsumeCodePoint(A), this.consumeNumericToken()) : Bt(A) ? (this.reconsumeCodePoint(A), this.consumeIdentLikeToken()) : { type: 6, value: P(A) };
    }, t.prototype.consumeCodePoint = function() {
      var A = this._value.shift();
      return typeof A > "u" ? -1 : A;
    }, t.prototype.reconsumeCodePoint = function(A) {
      this._value.unshift(A);
    }, t.prototype.peekCodePoint = function(A) {
      return A >= this._value.length ? -1 : this._value[A];
    }, t.prototype.consumeUnicodeRangeToken = function() {
      for (var A = [], e = this.consumeCodePoint(); qA(e) && A.length < 6; )
        A.push(e), e = this.consumeCodePoint();
      for (var r = !1; e === _e && A.length < 6; )
        A.push(e), e = this.consumeCodePoint(), r = !0;
      if (r) {
        var s = parseInt(P.apply(void 0, A.map(function(B) {
          return B === _e ? tn : B;
        })), 16), n = parseInt(P.apply(void 0, A.map(function(B) {
          return B === _e ? Bn : B;
        })), 16);
        return { type: 30, start: s, end: n };
      }
      var i = parseInt(P.apply(void 0, A), 16);
      if (this.peekCodePoint(0) === tA && qA(this.peekCodePoint(1))) {
        this.consumeCodePoint(), e = this.consumeCodePoint();
        for (var a = []; qA(e) && a.length < 6; )
          a.push(e), e = this.consumeCodePoint();
        var n = parseInt(P.apply(void 0, a), 16);
        return { type: 30, start: i, end: n };
      } else
        return { type: 30, start: i, end: i };
    }, t.prototype.consumeIdentLikeToken = function() {
      var A = this.consumeName();
      return A.toLowerCase() === "url" && this.peekCodePoint(0) === ke ? (this.consumeCodePoint(), this.consumeUrlToken()) : this.peekCodePoint(0) === ke ? (this.consumeCodePoint(), { type: 19, value: A }) : { type: 20, value: A };
    }, t.prototype.consumeUrlToken = function() {
      var A = [];
      if (this.consumeWhiteSpace(), this.peekCodePoint(0) === wA)
        return { type: 22, value: "" };
      var e = this.peekCodePoint(0);
      if (e === Pe || e === Ve) {
        var r = this.consumeStringToken(this.consumeCodePoint());
        return r.type === 0 && (this.consumeWhiteSpace(), this.peekCodePoint(0) === wA || this.peekCodePoint(0) === ge) ? (this.consumeCodePoint(), { type: 22, value: r.value }) : (this.consumeBadUrlRemnants(), We);
      }
      for (; ; ) {
        var s = this.consumeCodePoint();
        if (s === wA || s === ge)
          return { type: 22, value: P.apply(void 0, A) };
        if (Xe(s))
          return this.consumeWhiteSpace(), this.peekCodePoint(0) === wA || this.peekCodePoint(0) === ge ? (this.consumeCodePoint(), { type: 22, value: P.apply(void 0, A) }) : (this.consumeBadUrlRemnants(), We);
        if (s === Ve || s === Pe || s === ke || AB(s))
          return this.consumeBadUrlRemnants(), We;
        if (s === Ee)
          if (DA(s, this.peekCodePoint(0)))
            A.push(this.consumeEscapedCodePoint());
          else
            return this.consumeBadUrlRemnants(), We;
        else
          A.push(s);
      }
    }, t.prototype.consumeWhiteSpace = function() {
      for (; Xe(this.peekCodePoint(0)); )
        this.consumeCodePoint();
    }, t.prototype.consumeBadUrlRemnants = function() {
      for (; ; ) {
        var A = this.consumeCodePoint();
        if (A === ge || A === wA)
          return;
        DA(A, this.peekCodePoint(0)) && this.consumeEscapedCodePoint();
      }
    }, t.prototype.consumeStringSlice = function(A) {
      for (var e = 5e4, r = ""; A > 0; ) {
        var s = Math.min(e, A);
        r += P.apply(void 0, this._value.splice(0, s)), A -= s;
      }
      return this._value.shift(), r;
    }, t.prototype.consumeStringToken = function(A) {
      var e = "", r = 0;
      do {
        var s = this._value[r];
        if (s === wA || s === void 0 || s === A)
          return e += this.consumeStringSlice(r), { type: 0, value: e };
        if (s === at)
          return this._value.splice(0, r), gB;
        if (s === Ee) {
          var n = this._value[r + 1];
          n !== wA && n !== void 0 && (n === at ? (e += this.consumeStringSlice(r), r = -1, this._value.shift()) : DA(s, n) && (e += this.consumeStringSlice(r), e += P(this.consumeEscapedCodePoint()), r = -1));
        }
        r++;
      } while (!0);
    }, t.prototype.consumeNumber = function() {
      var A = [], e = Ke, r = this.peekCodePoint(0);
      for ((r === XA || r === tA) && A.push(this.consumeCodePoint()); j(this.peekCodePoint(0)); )
        A.push(this.consumeCodePoint());
      r = this.peekCodePoint(0);
      var s = this.peekCodePoint(1);
      if (r === Le && j(s))
        for (A.push(this.consumeCodePoint(), this.consumeCodePoint()), e = Zr; j(this.peekCodePoint(0)); )
          A.push(this.consumeCodePoint());
      r = this.peekCodePoint(0), s = this.peekCodePoint(1);
      var n = this.peekCodePoint(2);
      if ((r === an || r === sn) && ((s === XA || s === tA) && j(n) || j(s)))
        for (A.push(this.consumeCodePoint(), this.consumeCodePoint()), e = Zr; j(this.peekCodePoint(0)); )
          A.push(this.consumeCodePoint());
      return [eB(A), e];
    }, t.prototype.consumeNumericToken = function() {
      var A = this.consumeNumber(), e = A[0], r = A[1], s = this.peekCodePoint(0), n = this.peekCodePoint(1), i = this.peekCodePoint(2);
      if (Je(s, n, i)) {
        var a = this.consumeName();
        return { type: 15, number: e, flags: r, unit: a };
      }
      return s === pa ? (this.consumeCodePoint(), { type: 16, number: e, flags: r }) : { type: 17, number: e, flags: r };
    }, t.prototype.consumeEscapedCodePoint = function() {
      var A = this.consumeCodePoint();
      if (qA(A)) {
        for (var e = P(A); qA(this.peekCodePoint(0)) && e.length < 6; )
          e += P(this.consumeCodePoint());
        Xe(this.peekCodePoint(0)) && this.consumeCodePoint();
        var r = parseInt(e, 16);
        return r === 0 || Za(r) || r > 1114111 ? jr : r;
      }
      return A === wA ? jr : A;
    }, t.prototype.consumeName = function() {
      for (var A = ""; ; ) {
        var e = this.consumeCodePoint();
        if (qr(e))
          A += P(e);
        else if (DA(e, this.peekCodePoint(0)))
          A += P(this.consumeEscapedCodePoint());
        else
          return this.reconsumeCodePoint(e), A;
      }
    }, t;
  }()
), cn = (
  /** @class */
  function() {
    function t(A) {
      this._tokens = A;
    }
    return t.create = function(A) {
      var e = new on();
      return e.write(A), new t(e.read());
    }, t.parseValue = function(A) {
      return t.create(A).parseComponentValue();
    }, t.parseValues = function(A) {
      return t.create(A).parseComponentValues();
    }, t.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 e = this.consumeComponentValue();
      do
        A = this.consumeToken();
      while (A.type === 31);
      if (A.type === 32)
        return e;
      throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one");
    }, t.prototype.parseComponentValues = function() {
      for (var A = []; ; ) {
        var e = this.consumeComponentValue();
        if (e.type === 32)
          return A;
        A.push(e), A.push();
      }
    }, t.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;
    }, t.prototype.consumeSimpleBlock = function(A) {
      for (var e = { type: A, values: [] }, r = this.consumeToken(); ; ) {
        if (r.type === 32 || pB(r, A))
          return e;
        this.reconsumeToken(r), e.values.push(this.consumeComponentValue()), r = this.consumeToken();
      }
    }, t.prototype.consumeFunction = function(A) {
      for (var e = {
        name: A.value,
        values: [],
        type: 18
        /* FUNCTION */
      }; ; ) {
        var r = this.consumeToken();
        if (r.type === 32 || r.type === 3)
          return e;
        this.reconsumeToken(r), e.values.push(this.consumeComponentValue());
      }
    }, t.prototype.consumeToken = function() {
      var A = this._tokens.shift();
      return typeof A > "u" ? ur : A;
    }, t.prototype.reconsumeToken = function(A) {
      this._tokens.unshift(A);
    }, t;
  }()
), De = function(t) {
  return t.type === 15;
}, Be = function(t) {
  return t.type === 17;
}, M = function(t) {
  return t.type === 20;
}, FB = function(t) {
  return t.type === 0;
}, gr = function(t, A) {
  return M(t) && t.value === A;
}, ln = function(t) {
  return t.type !== 31;
}, ae = function(t) {
  return t.type !== 31 && t.type !== 4;
}, CA = function(t) {
  var A = [], e = [];
  return t.forEach(function(r) {
    if (r.type === 4) {
      if (e.length === 0)
        throw new Error("Error parsing function args, zero tokens for arg");
      A.push(e), e = [];
      return;
    }
    r.type !== 31 && e.push(r);
  }), e.length && A.push(e), A;
}, pB = function(t, A) {
  return A === 11 && t.type === 12 || A === 28 && t.type === 29 ? !0 : A === 2 && t.type === 3;
}, RA = function(t) {
  return t.type === 17 || t.type === 15;
}, k = function(t) {
  return t.type === 16 || RA(t);
}, un = function(t) {
  return t.length > 1 ? [t[0], t[1]] : [t[0]];
}, z = {
  type: 17,
  number: 0,
  flags: Ke
}, yr = {
  type: 16,
  number: 50,
  flags: Ke
}, TA = {
  type: 16,
  number: 100,
  flags: Ke
}, de = function(t, A, e) {
  var r = t[0], s = t[1];
  return [R(r, A), R(typeof s < "u" ? s : r, e)];
}, R = function(t, A) {
  if (t.type === 16)
    return t.number / 100 * A;
  if (De(t))
    switch (t.unit) {
      case "rem":
      case "em":
        return 16 * t.number;
      case "px":
      default:
        return t.number;
    }
  return t.number;
}, gn = "deg", wn = "grad", fn = "rad", Qn = "turn", Et = {
  name: "angle",
  parse: function(t, A) {
    if (A.type === 15)
      switch (A.unit) {
        case gn:
          return Math.PI * A.number / 180;
        case wn:
          return Math.PI / 200 * A.number;
        case fn:
          return A.number;
        case Qn:
          return Math.PI * 2 * A.number;
      }
    throw new Error("Unsupported angle type");
  }
}, hn = function(t) {
  return t.type === 15 && (t.unit === gn || t.unit === wn || t.unit === fn || t.unit === Qn);
}, Cn = function(t) {
  var A = t.filter(M).map(function(e) {
    return e.value;
  }).join(" ");
  switch (A) {
    case "to bottom right":
    case "to right bottom":
    case "left top":
    case "top left":
      return [z, z];
    case "to top":
    case "bottom":
      return oA(0);
    case "to bottom left":
    case "to left bottom":
    case "right top":
    case "top right":
      return [z, TA];
    case "to right":
    case "left":
      return oA(90);
    case "to top left":
    case "to left top":
    case "right bottom":
    case "bottom right":
      return [TA, TA];
    case "to bottom":
    case "top":
      return oA(180);
    case "to top right":
    case "to right top":
    case "left bottom":
    case "bottom left":
      return [TA, z];
    case "to left":
    case "right":
      return oA(270);
  }
  return 0;
}, oA = function(t) {
  return Math.PI * t / 180;
}, MA = {
  name: "color",
  parse: function(t, A) {
    if (A.type === 18) {
      var e = EB[A.name];
      if (typeof e > "u")
        throw new Error('Attempting to parse an unsupported color function "' + A.name + '"');
      return e(t, A.values);
    }
    if (A.type === 5) {
      if (A.value.length === 3) {
        var r = A.value.substring(0, 1), s = A.value.substring(1, 2), n = A.value.substring(2, 3);
        return xA(parseInt(r + r, 16), parseInt(s + s, 16), parseInt(n + n, 16), 1);
      }
      if (A.value.length === 4) {
        var r = A.value.substring(0, 1), s = A.value.substring(1, 2), n = A.value.substring(2, 3), i = A.value.substring(3, 4);
        return xA(parseInt(r + r, 16), parseInt(s + s, 16), parseInt(n + n, 16), parseInt(i + i, 16) / 255);
      }
      if (A.value.length === 6) {
        var r = A.value.substring(0, 2), s = A.value.substring(2, 4), n = A.value.substring(4, 6);
        return xA(parseInt(r, 16), parseInt(s, 16), parseInt(n, 16), 1);
      }
      if (A.value.length === 8) {
        var r = A.value.substring(0, 2), s = A.value.substring(2, 4), n = A.value.substring(4, 6), i = A.value.substring(6, 8);
        return xA(parseInt(r, 16), parseInt(s, 16), parseInt(n, 16), parseInt(i, 16) / 255);
      }
    }
    if (A.type === 20) {
      var a = mA[A.value.toUpperCase()];
      if (typeof a < "u")
        return a;
    }
    return mA.TRANSPARENT;
  }
}, OA = function(t) {
  return (255 & t) === 0;
}, W = function(t) {
  var A = 255 & t, e = 255 & t >> 8, r = 255 & t >> 16, s = 255 & t >> 24;
  return A < 255 ? "rgba(" + s + "," + r + "," + e + "," + A / 255 + ")" : "rgb(" + s + "," + r + "," + e + ")";
}, xA = function(t, A, e, r) {
  return (t << 24 | A << 16 | e << 8 | Math.round(r * 255) << 0) >>> 0;
}, As = function(t, A) {
  if (t.type === 17)
    return t.number;
  if (t.type === 16) {
    var e = A === 3 ? 1 : 255;
    return A === 3 ? t.number / 100 * e : Math.round(t.number / 100 * e);
  }
  return 0;
}, es = function(t, A) {
  var e = A.filter(ae);
  if (e.length === 3) {
    var r = e.map(As), s = r[0], n = r[1], i = r[2];
    return xA(s, n, i, 1);
  }
  if (e.length === 4) {
    var a = e.map(As), s = a[0], n = a[1], i = a[2], B = a[3];
    return xA(s, n, i, B);
  }
  return 0;
};
function Nt(t, A, e) {
  return e < 0 && (e += 1), e >= 1 && (e -= 1), e < 1 / 6 ? (A - t) * e * 6 + t : e < 1 / 2 ? A : e < 2 / 3 ? (A - t) * 6 * (2 / 3 - e) + t : t;
}
var ts = function(t, A) {
  var e = A.filter(ae), r = e[0], s = e[1], n = e[2], i = e[3], a = (r.type === 17 ? oA(r.number) : Et.parse(t, r)) / (Math.PI * 2), B = k(s) ? s.number / 100 : 0, o = k(n) ? n.number / 100 : 0, c = typeof i < "u" && k(i) ? R(i, 1) : 1;
  if (B === 0)
    return xA(o * 255, o * 255, o * 255, 1);
  var l = o <= 0.5 ? o * (B + 1) : o + B - o * B, u = o * 2 - l, f = Nt(u, l, a + 1 / 3), g = Nt(u, l, a), h = Nt(u, l, a - 1 / 3);
  return xA(f * 255, g * 255, h * 255, c);
}, EB = {
  hsl: ts,
  hsla: ts,
  rgb: es,
  rgba: es
}, ve = function(t, A) {
  return MA.parse(t, cn.create(A).parseComponentValue());
}, mA = {
  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
}, vB = {
  name: "background-clip",
  initialValue: "border-box",
  prefix: !1,
  type: 1,
  parse: function(t, A) {
    return A.map(function(e) {
      if (M(e))
        switch (e.value) {
          case "padding-box":
            return 1;
          case "content-box":
            return 2;
        }
      return 0;
    });
  }
}, HB = {
  name: "background-color",
  initialValue: "transparent",
  prefix: !1,
  type: 3,
  format: "color"
}, vt = function(t, A) {
  var e = MA.parse(t, A[0]), r = A[1];
  return r && k(r) ? { color: e, stop: r } : { color: e, stop: null };
}, rs = function(t, A) {
  var e = t[0], r = t[t.length - 1];
  e.stop === null && (e.stop = z), r.stop === null && (r.stop = TA);
  for (var s = [], n = 0, i = 0; i < t.length; i++) {
    var a = t[i].stop;
    if (a !== null) {
      var B = R(a, A);
      B > n ? s.push(B) : s.push(n), n = B;
    } else
      s.push(null);
  }
  for (var o = null, i = 0; i < s.length; i++) {
    var c = s[i];
    if (c === null)
      o === null && (o = i);
    else if (o !== null) {
      for (var l = i - o, u = s[o - 1], f = (c - u) / (l + 1), g = 1; g <= l; g++)
        s[o + g - 1] = f * g;
      o = null;
    }
  }
  return t.map(function(h, F) {
    var w = h.color;
    return { color: w, stop: Math.max(Math.min(1, s[F] / A), 0) };
  });
}, mB = function(t, A, e) {
  var r = A / 2, s = e / 2, n = R(t[0], A) - r, i = s - R(t[1], e);
  return (Math.atan2(i, n) + Math.PI * 2) % (Math.PI * 2);
}, IB = function(t, A, e) {
  var r = typeof t == "number" ? t : mB(t, A, e), s = Math.abs(A * Math.sin(r)) + Math.abs(e * Math.cos(r)), n = A / 2, i = e / 2, a = s / 2, B = Math.sin(r - Math.PI / 2) * a, o = Math.cos(r - Math.PI / 2) * a;
  return [s, n - o, n + o, i - B, i + B];
}, lA = function(t, A) {
  return Math.sqrt(t * t + A * A);
}, ss = function(t, A, e, r, s) {
  var n = [
    [0, 0],
    [0, A],
    [t, 0],
    [t, A]
  ];
  return n.reduce(function(i, a) {
    var B = a[0], o = a[1], c = lA(e - B, r - o);
    return (s ? c < i.optimumDistance : c > i.optimumDistance) ? {
      optimumCorner: a,
      optimumDistance: c
    } : i;
  }, {
    optimumDistance: s ? 1 / 0 : -1 / 0,
    optimumCorner: null
  }).optimumCorner;
}, yB = function(t, A, e, r, s) {
  var n = 0, i = 0;
  switch (t.size) {
    case 0:
      t.shape === 0 ? n = i = Math.min(Math.abs(A), Math.abs(A - r), Math.abs(e), Math.abs(e - s)) : t.shape === 1 && (n = Math.min(Math.abs(A), Math.abs(A - r)), i = Math.min(Math.abs(e), Math.abs(e - s)));
      break;
    case 2:
      if (t.shape === 0)
        n = i = Math.min(lA(A, e), lA(A, e - s), lA(A - r, e), lA(A - r, e - s));
      else if (t.shape === 1) {
        var a = Math.min(Math.abs(e), Math.abs(e - s)) / Math.min(Math.abs(A), Math.abs(A - r)), B = ss(r, s, A, e, !0), o = B[0], c = B[1];
        n = lA(o - A, (c - e) / a), i = a * n;
      }
      break;
    case 1:
      t.shape === 0 ? n = i = Math.max(Math.abs(A), Math.abs(A - r), Math.abs(e), Math.abs(e - s)) : t.shape === 1 && (n = Math.max(Math.abs(A), Math.abs(A - r)), i = Math.max(Math.abs(e), Math.abs(e - s)));
      break;
    case 3:
      if (t.shape === 0)
        n = i = Math.max(lA(A, e), lA(A, e - s), lA(A - r, e), lA(A - r, e - s));
      else if (t.shape === 1) {
        var a = Math.max(Math.abs(e), Math.abs(e - s)) / Math.max(Math.abs(A), Math.abs(A - r)), l = ss(r, s, A, e, !1), o = l[0], c = l[1];
        n = lA(o - A, (c - e) / a), i = a * n;
      }
      break;
  }
  return Array.isArray(t.size) && (n = R(t.size[0], r), i = t.size.length === 2 ? R(t.size[1], s) : n), [n, i];
}, LB = function(t, A) {
  var e = oA(180), r = [];
  return CA(A).forEach(function(s, n) {
    if (n === 0) {
      var i = s[0];
      if (i.type === 20 && i.value === "to") {
        e = Cn(s);
        return;
      } else if (hn(i)) {
        e = Et.parse(t, i);
        return;
      }
    }
    var a = vt(t, s);
    r.push(a);
  }), {
    angle: e,
    stops: r,
    type: 1
    /* LINEAR_GRADIENT */
  };
}, Ye = function(t, A) {
  var e = oA(180), r = [];
  return CA(A).forEach(function(s, n) {
    if (n === 0) {
      var i = s[0];
      if (i.type === 20 && ["top", "left", "right", "bottom"].indexOf(i.value) !== -1) {
        e = Cn(s);
        return;
      } else if (hn(i)) {
        e = (Et.parse(t, i) + oA(270)) % oA(360);
        return;
      }
    }
    var a = vt(t, s);
    r.push(a);
  }), {
    angle: e,
    stops: r,
    type: 1
    /* LINEAR_GRADIENT */
  };
}, bB = function(t, A) {
  var e = oA(180), r = [], s = 1, n = 0, i = 3, a = [];
  return CA(A).forEach(function(B, o) {
    var c = B[0];
    if (o === 0) {
      if (M(c) && c.value === "linear") {
        s = 1;
        return;
      } else if (M(c) && c.value === "radial") {
        s = 2;
        return;
      }
    }
    if (c.type === 18) {
      if (c.name === "from") {
        var l = MA.parse(t, c.values[0]);
        r.push({ stop: z, color: l });
      } else if (c.name === "to") {
        var l = MA.parse(t, c.values[0]);
        r.push({ stop: TA, color: l });
      } else if (c.name === "color-stop") {
        var u = c.values.filter(ae);
        if (u.length === 2) {
          var l = MA.parse(t, u[1]), f = u[0];
          Be(f) && r.push({
            stop: { type: 16, number: f.number * 100, flags: f.flags },
            color: l
          });
        }
      }
    }
  }), s === 1 ? {
    angle: (e + oA(180)) % oA(360),
    stops: r,
    type: s
  } : { size: i, shape: n, stops: r, position: a, type: s };
}, dn = "closest-side", Un = "farthest-side", Fn = "closest-corner", pn = "farthest-corner", En = "circle", vn = "ellipse", Hn = "cover", mn = "contain", KB = function(t, A) {
  var e = 0, r = 3, s = [], n = [];
  return CA(A).forEach(function(i, a) {
    var B = !0;
    if (a === 0) {
      var o = !1;
      B = i.reduce(function(l, u) {
        if (o)
          if (M(u))
            switch (u.value) {
              case "center":
                return n.push(yr), l;
              case "top":
              case "left":
                return n.push(z), l;
              case "right":
              case "bottom":
                return n.push(TA), l;
            }
          else
            (k(u) || RA(u)) && n.push(u);
        else if (M(u))
          switch (u.value) {
            case En:
              return e = 0, !1;
            case vn:
              return e = 1, !1;
            case "at":
              return o = !0, !1;
            case dn:
              return r = 0, !1;
            case Hn:
            case Un:
              return r = 1, !1;
            case mn:
            case Fn:
              return r = 2, !1;
            case pn:
              return r = 3, !1;
          }
        else if (RA(u) || k(u))
          return Array.isArray(r) || (r = []), r.push(u), !1;
        return l;
      }, B);
    }
    if (B) {
      var c = vt(t, i);
      s.push(c);
    }
  }), {
    size: r,
    shape: e,
    stops: s,
    position: n,
    type: 2
    /* RADIAL_GRADIENT */
  };
}, Ze = function(t, A) {
  var e = 0, r = 3, s = [], n = [];
  return CA(A).forEach(function(i, a) {
    var B = !0;
    if (a === 0 ? B = i.reduce(function(c, l) {
      if (M(l))
        switch (l.value) {
          case "center":
            return n.push(yr), !1;
          case "top":
          case "left":
            return n.push(z), !1;
          case "right":
          case "bottom":
            return n.push(TA), !1;
        }
      else if (k(l) || RA(l))
        return n.push(l), !1;
      return c;
    }, B) : a === 1 && (B = i.reduce(function(c, l) {
      if (M(l))
        switch (l.value) {
          case En:
            return e = 0, !1;
          case vn:
            return e = 1, !1;
          case mn:
          case dn:
            return r = 0, !1;
          case Un:
            return r = 1, !1;
          case Fn:
            return r = 2, !1;
          case Hn:
          case pn:
            return r = 3, !1;
        }
      else if (RA(l) || k(l))
        return Array.isArray(r) || (r = []), r.push(l), !1;
      return c;
    }, B)), B) {
      var o = vt(t, i);
      s.push(o);
    }
  }), {
    size: r,
    shape: e,
    stops: s,
    position: n,
    type: 2
    /* RADIAL_GRADIENT */
  };
}, DB = function(t) {
  return t.type === 1;
}, SB = function(t) {
  return t.type === 2;
}, Lr = {
  name: "image",
  parse: function(t, A) {
    if (A.type === 22) {
      var e = {
        url: A.value,
        type: 0
        /* URL */
      };
      return t.cache.addImage(A.value), e;
    }
    if (A.type === 18) {
      var r = In[A.name];
      if (typeof r > "u")
        throw new Error('Attempting to parse an unsupported image function "' + A.name + '"');
      return r(t, A.values);
    }
    throw new Error("Unsupported image type " + A.type);
  }
};
function TB(t) {
  return !(t.type === 20 && t.value === "none") && (t.type !== 18 || !!In[t.name]);
}
var In = {
  "linear-gradient": LB,
  "-moz-linear-gradient": Ye,
  "-ms-linear-gradient": Ye,
  "-o-linear-gradient": Ye,
  "-webkit-linear-gradient": Ye,
  "radial-gradient": KB,
  "-moz-radial-gradient": Ze,
  "-ms-radial-gradient": Ze,
  "-o-radial-gradient": Ze,
  "-webkit-radial-gradient": Ze,
  "-webkit-gradient": bB
}, xB = {
  name: "background-image",
  initialValue: "none",
  type: 1,
  prefix: !1,
  parse: function(t, A) {
    if (A.length === 0)
      return [];
    var e = A[0];
    return e.type === 20 && e.value === "none" ? [] : A.filter(function(r) {
      return ae(r) && TB(r);
    }).map(function(r) {
      return Lr.parse(t, r);
    });
  }
}, MB = {
  name: "background-origin",
  initialValue: "border-box",
  prefix: !1,
  type: 1,
  parse: function(t, A) {
    return A.map(function(e) {
      if (M(e))
        switch (e.value) {
          case "padding-box":
            return 1;
          case "content-box":
            return 2;
        }
      return 0;
    });
  }
}, OB = {
  name: "background-position",
  initialValue: "0% 0%",
  type: 1,
  prefix: !1,
  parse: function(t, A) {
    return CA(A).map(function(e) {
      return e.filter(k);
    }).map(un);
  }
}, RB = {
  name: "background-repeat",
  initialValue: "repeat",
  prefix: !1,
  type: 1,
  parse: function(t, A) {
    return CA(A).map(function(e) {
      return e.filter(M).map(function(r) {
        return r.value;
      }).join(" ");
    }).map(GB);
  }
}, GB = function(t) {
  switch (t) {
    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;
  }
}, ie;
(function(t) {
  t.AUTO = "auto", t.CONTAIN = "contain", t.COVER = "cover";
})(ie || (ie = {}));
var NB = {
  name: "background-size",
  initialValue: "0",
  prefix: !1,
  type: 1,
  parse: function(t, A) {
    return CA(A).map(function(e) {
      return e.filter(VB);
    });
  }
}, VB = function(t) {
  return M(t) || k(t);
}, Ht = function(t) {
  return {
    name: "border-" + t + "-color",
    initialValue: "transparent",
    prefix: !1,
    type: 3,
    format: "color"
  };
}, PB = Ht("top"), kB = Ht("right"), _B = Ht("bottom"), XB = Ht("left"), mt = function(t) {
  return {
    name: "border-radius-" + t,
    initialValue: "0 0",
    prefix: !1,
    type: 1,
    parse: function(A, e) {
      return un(e.filter(k));
    }
  };
}, JB = mt("top-left"), WB = mt("top-right"), YB = mt("bottom-right"), ZB = mt("bottom-left"), It = function(t) {
  return {
    name: "border-" + t + "-style",
    initialValue: "solid",
    prefix: !1,
    type: 2,
    parse: function(A, e) {
      switch (e) {
        case "none":
          return 0;
        case "dashed":
          return 2;
        case "dotted":
          return 3;
        case "double":
          return 4;
      }
      return 1;
    }
  };
}, zB = It("top"), $B = It("right"), jB = It("bottom"), qB = It("left"), yt = function(t) {
  return {
    name: "border-" + t + "-width",
    initialValue: "0",
    type: 0,
    prefix: !1,
    parse: function(A, e) {
      return De(e) ? e.number : 0;
    }
  };
}, Ao = yt("top"), eo = yt("right"), to = yt("bottom"), ro = yt("left"), so = {
  name: "color",
  initialValue: "transparent",
  prefix: !1,
  type: 3,
  format: "color"
}, no = {
  name: "direction",
  initialValue: "ltr",
  prefix: !1,
  type: 2,
  parse: function(t, A) {
    switch (A) {
      case "rtl":
        return 1;
      case "ltr":
      default:
        return 0;
    }
  }
}, io = {
  name: "display",
  initialValue: "inline-block",
  prefix: !1,
  type: 1,
  parse: function(t, A) {
    return A.filter(M).reduce(
      function(e, r) {
        return e | ao(r.value);
      },
      0
      /* NONE */
    );
  }
}, ao = function(t) {
  switch (t) {
    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;
}, Bo = {
  name: "float",
  initialValue: "none",
  prefix: !1,
  type: 2,
  parse: function(t, A) {
    switch (A) {
      case "left":
        return 1;
      case "right":
        return 2;
      case "inline-start":
        return 3;
      case "inline-end":
        return 4;
    }
    return 0;
  }
}, oo = {
  name: "letter-spacing",
  initialValue: "0",
  prefix: !1,
  type: 0,
  parse: function(t, A) {
    return A.type === 20 && A.value === "normal" ? 0 : A.type === 17 || A.type === 15 ? A.number : 0;
  }
}, ot;
(function(t) {
  t.NORMAL = "normal", t.STRICT = "strict";
})(ot || (ot = {}));
var co = {
  name: "line-break",
  initialValue: "normal",
  prefix: !1,
  type: 2,
  parse: function(t, A) {
    switch (A) {
      case "strict":
        return ot.STRICT;
      case "normal":
      default:
        return ot.NORMAL;
    }
  }
}, lo = {
  name: "line-height",
  initialValue: "normal",
  prefix: !1,
  type: 4
  /* TOKEN_VALUE */
}, ns = function(t, A) {
  return M(t) && t.value === "normal" ? 1.2 * A : t.type === 17 ? A * t.number : k(t) ? R(t, A) : A;
}, uo = {
  name: "list-style-image",
  initialValue: "none",
  type: 0,
  prefix: !1,
  parse: function(t, A) {
    return A.type === 20 && A.value === "none" ? null : Lr.parse(t, A);
  }
}, go = {
  name: "list-style-position",
  initialValue: "outside",
  prefix: !1,
  type: 2,
  parse: function(t, A) {
    switch (A) {
      case "inside":
        return 0;
      case "outside":
      default:
        return 1;
    }
  }
}, wr = {
  name: "list-style-type",
  initialValue: "none",
  prefix: !1,
  type: 2,
  parse: function(t, 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;
    }
  }
}, Lt = function(t) {
  return {
    name: "margin-" + t,
    initialValue: "0",
    prefix: !1,
    type: 4
    /* TOKEN_VALUE */
  };
}, wo = Lt("top"), fo = Lt("right"), Qo = Lt("bottom"), ho = Lt("left"), Co = {
  name: "overflow",
  initialValue: "visible",
  prefix: !1,
  type: 1,
  parse: function(t, A) {
    return A.filter(M).map(function(e) {
      switch (e.value) {
        case "hidden":
          return 1;
        case "scroll":
          return 2;
        case "clip":
          return 3;
        case "auto":
          return 4;
        case "visible":
        default:
          return 0;
      }
    });
  }
}, Uo = {
  name: "overflow-wrap",
  initialValue: "normal",
  prefix: !1,
  type: 2,
  parse: function(t, A) {
    switch (A) {
      case "break-word":
        return "break-word";
      case "normal":
      default:
        return "normal";
    }
  }
}, bt = function(t) {
  return {
    name: "padding-" + t,
    initialValue: "0",
    prefix: !1,
    type: 3,
    format: "length-percentage"
  };
}, Fo = bt("top"), po = bt("right"), Eo = bt("bottom"), vo = bt("left"), Ho = {
  name: "text-align",
  initialValue: "left",
  prefix: !1,
  type: 2,
  parse: function(t, A) {
    switch (A) {
      case "right":
        return 2;
      case "center":
      case "justify":
        return 1;
      case "left":
      default:
        return 0;
    }
  }
}, mo = {
  name: "position",
  initialValue: "static",
  prefix: !1,
  type: 2,
  parse: function(t, A) {
    switch (A) {
      case "relative":
        return 1;
      case "absolute":
        return 2;
      case "fixed":
        return 3;
      case "sticky":
        return 4;
    }
    return 0;
  }
}, Io = {
  name: "text-shadow",
  initialValue: "none",
  type: 1,
  prefix: !1,
  parse: function(t, A) {
    return A.length === 1 && gr(A[0], "none") ? [] : CA(A).map(function(e) {
      for (var r = {
        color: mA.TRANSPARENT,
        offsetX: z,
        offsetY: z,
        blur: z
      }, s = 0, n = 0; n < e.length; n++) {
        var i = e[n];
        RA(i) ? (s === 0 ? r.offsetX = i : s === 1 ? r.offsetY = i : r.blur = i, s++) : r.color = MA.parse(t, i);
      }
      return r;
    });
  }
}, yo = {
  name: "text-transform",
  initialValue: "none",
  prefix: !1,
  type: 2,
  parse: function(t, A) {
    switch (A) {
      case "uppercase":
        return 2;
      case "lowercase":
        return 1;
      case "capitalize":
        return 3;
    }
    return 0;
  }
}, Lo = {
  name: "transform",
  initialValue: "none",
  prefix: !0,
  type: 0,
  parse: function(t, A) {
    if (A.type === 20 && A.value === "none")
      return null;
    if (A.type === 18) {
      var e = Do[A.name];
      if (typeof e > "u")
        throw new Error('Attempting to parse an unsupported transform function "' + A.name + '"');
      return e(A.values);
    }
    return null;
  }
}, bo = function(t) {
  var A = t.filter(function(e) {
    return e.type === 17;
  }).map(function(e) {
    return e.number;
  });
  return A.length === 6 ? A : null;
}, Ko = function(t) {
  var A = t.filter(function(B) {
    return B.type === 17;
  }).map(function(B) {
    return B.number;
  }), e = A[0], r = A[1];
  A[2], A[3];
  var s = A[4], n = A[5];
  A[6], A[7], A[8], A[9], A[10], A[11];
  var i = A[12], a = A[13];
  return A[14], A[15], A.length === 16 ? [e, r, s, n, i, a] : null;
}, Do = {
  matrix: bo,
  matrix3d: Ko
}, is = {
  type: 16,
  number: 50,
  flags: Ke
}, So = [is, is], To = {
  name: "transform-origin",
  initialValue: "50% 50%",
  prefix: !0,
  type: 1,
  parse: function(t, A) {
    var e = A.filter(k);
    return e.length !== 2 ? So : [e[0], e[1]];
  }
}, xo = {
  name: "visible",
  initialValue: "none",
  prefix: !1,
  type: 2,
  parse: function(t, A) {
    switch (A) {
      case "hidden":
        return 1;
      case "collapse":
        return 2;
      case "visible":
      default:
        return 0;
    }
  }
}, He;
(function(t) {
  t.NORMAL = "normal", t.BREAK_ALL = "break-all", t.KEEP_ALL = "keep-all";
})(He || (He = {}));
var Mo = {
  name: "word-break",
  initialValue: "normal",
  prefix: !1,
  type: 2,
  parse: function(t, A) {
    switch (A) {
      case "break-all":
        return He.BREAK_ALL;
      case "keep-all":
        return He.KEEP_ALL;
      case "normal":
      default:
        return He.NORMAL;
    }
  }
}, Oo = {
  name: "z-index",
  initialValue: "auto",
  prefix: !1,
  type: 0,
  parse: function(t, A) {
    if (A.type === 20)
      return { auto: !0, order: 0 };
    if (Be(A))
      return { auto: !1, order: A.number };
    throw new Error("Invalid z-index number parsed");
  }
}, yn = {
  name: "time",
  parse: function(t, 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");
  }
}, Ro = {
  name: "opacity",
  initialValue: "1",
  type: 0,
  prefix: !1,
  parse: function(t, A) {
    return Be(A) ? A.number : 1;
  }
}, Go = {
  name: "text-decoration-color",
  initialValue: "transparent",
  prefix: !1,
  type: 3,
  format: "color"
}, No = {
  name: "text-decoration-line",
  initialValue: "none",
  prefix: !1,
  type: 1,
  parse: function(t, A) {
    return A.filter(M).map(function(e) {
      switch (e.value) {
        case "underline":
          return 1;
        case "overline":
          return 2;
        case "line-through":
          return 3;
        case "none":
          return 4;
      }
      return 0;
    }).filter(function(e) {
      return e !== 0;
    });
  }
}, Vo = {
  name: "font-family",
  initialValue: "",
  prefix: !1,
  type: 1,
  parse: function(t, A) {
    var e = [], r = [];
    return A.forEach(function(s) {
      switch (s.type) {
        case 20:
        case 0:
          e.push(s.value);
          break;
        case 17:
          e.push(s.number.toString());
          break;
        case 4:
          r.push(e.join(" ")), e.length = 0;
          break;
      }
    }), e.length && r.push(e.join(" ")), r.map(function(s) {
      return s.indexOf(" ") === -1 ? s : "'" + s + "'";
    });
  }
}, Po = {
  name: "font-size",
  initialValue: "0",
  prefix: !1,
  type: 3,
  format: "length"
}, ko = {
  name: "font-weight",
  initialValue: "normal",
  type: 0,
  prefix: !1,
  parse: function(t, A) {
    if (Be(A))
      return A.number;
    if (M(A))
      switch (A.value) {
        case "bold":
          return 700;
        case "normal":
        default:
          return 400;
      }
    return 400;
  }
}, _o = {
  name: "font-variant",
  initialValue: "none",
  type: 1,
  prefix: !1,
  parse: function(t, A) {
    return A.filter(M).map(function(e) {
      return e.value;
    });
  }
}, Xo = {
  name: "font-style",
  initialValue: "normal",
  prefix: !1,
  type: 2,
  parse: function(t, A) {
    switch (A) {
      case "oblique":
        return "oblique";
      case "italic":
        return "italic";
      case "normal":
      default:
        return "normal";
    }
  }
}, X = function(t, A) {
  return (t & A) !== 0;
}, Jo = {
  name: "content",
  initialValue: "none",
  type: 1,
  prefix: !1,
  parse: function(t, A) {
    if (A.length === 0)
      return [];
    var e = A[0];
    return e.type === 20 && e.value === "none" ? [] : A;
  }
}, Wo = {
  name: "counter-increment",
  initialValue: "none",
  prefix: !0,
  type: 1,
  parse: function(t, A) {
    if (A.length === 0)
      return null;
    var e = A[0];
    if (e.type === 20 && e.value === "none")
      return null;
    for (var r = [], s = A.filter(ln), n = 0; n < s.length; n++) {
      var i = s[n], a = s[n + 1];
      if (i.type === 20) {
        var B = a && Be(a) ? a.number : 1;
        r.push({ counter: i.value, increment: B });
      }
    }
    return r;
  }
}, Yo = {
  name: "counter-reset",
  initialValue: "none",
  prefix: !0,
  type: 1,
  parse: function(t, A) {
    if (A.length === 0)
      return [];
    for (var e = [], r = A.filter(ln), s = 0; s < r.length; s++) {
      var n = r[s], i = r[s + 1];
      if (M(n) && n.value !== "none") {
        var a = i && Be(i) ? i.number : 0;
        e.push({ counter: n.value, reset: a });
      }
    }
    return e;
  }
}, Zo = {
  name: "duration",
  initialValue: "0s",
  prefix: !1,
  type: 1,
  parse: function(t, A) {
    return A.filter(De).map(function(e) {
      return yn.parse(t, e);
    });
  }
}, zo = {
  name: "quotes",
  initialValue: "none",
  prefix: !0,
  type: 1,
  parse: function(t, A) {
    if (A.length === 0)
      return null;
    var e = A[0];
    if (e.type === 20 && e.value === "none")
      return null;
    var r = [], s = A.filter(FB);
    if (s.length % 2 !== 0)
      return null;
    for (var n = 0; n < s.length; n += 2) {
      var i = s[n].value, a = s[n + 1].value;
      r.push({ open: i, close: a });
    }
    return r;
  }
}, as = function(t, A, e) {
  if (!t)
    return "";
  var r = t[Math.min(A, t.length - 1)];
  return r ? e ? r.open : r.close : "";
}, $o = {
  name: "box-shadow",
  initialValue: "none",
  type: 1,
  prefix: !1,
  parse: function(t, A) {
    return A.length === 1 && gr(A[0], "none") ? [] : CA(A).map(function(e) {
      for (var r = {
        color: 255,
        offsetX: z,
        offsetY: z,
        blur: z,
        spread: z,
        inset: !1
      }, s = 0, n = 0; n < e.length; n++) {
        var i = e[n];
        gr(i, "inset") ? r.inset = !0 : RA(i) ? (s === 0 ? r.offsetX = i : s === 1 ? r.offsetY = i : s === 2 ? r.blur = i : r.spread = i, s++) : r.color = MA.parse(t, i);
      }
      return r;
    });
  }
}, jo = {
  name: "paint-order",
  initialValue: "normal",
  prefix: !1,
  type: 1,
  parse: function(t, A) {
    var e = [
      0,
      1,
      2
      /* MARKERS */
    ], r = [];
    return A.filter(M).forEach(function(s) {
      switch (s.value) {
        case "stroke":
          r.push(
            1
            /* STROKE */
          );
          break;
        case "fill":
          r.push(
            0
            /* FILL */
          );
          break;
        case "markers":
          r.push(
            2
            /* MARKERS */
          );
          break;
      }
    }), e.forEach(function(s) {
      r.indexOf(s) === -1 && r.push(s);
    }), r;
  }
}, qo = {
  name: "-webkit-text-stroke-color",
  initialValue: "currentcolor",
  prefix: !1,
  type: 3,
  format: "color"
}, Ac = {
  name: "-webkit-text-stroke-width",
  initialValue: "0",
  type: 0,
  prefix: !1,
  parse: function(t, A) {
    return De(A) ? A.number : 0;
  }
}, ec = (
  /** @class */
  function() {
    function t(A, e) {
      var r, s;
      this.animationDuration = p(A, Zo, e.animationDuration), this.backgroundClip = p(A, vB, e.backgroundClip), this.backgroundColor = p(A, HB, e.backgroundColor), this.backgroundImage = p(A, xB, e.backgroundImage), this.backgroundOrigin = p(A, MB, e.backgroundOrigin), this.backgroundPosition = p(A, OB, e.backgroundPosition), this.backgroundRepeat = p(A, RB, e.backgroundRepeat), this.backgroundSize = p(A, NB, e.backgroundSize), this.borderTopColor = p(A, PB, e.borderTopColor), this.borderRightColor = p(A, kB, e.borderRightColor), this.borderBottomColor = p(A, _B, e.borderBottomColor), this.borderLeftColor = p(A, XB, e.borderLeftColor), this.borderTopLeftRadius = p(A, JB, e.borderTopLeftRadius), this.borderTopRightRadius = p(A, WB, e.borderTopRightRadius), this.borderBottomRightRadius = p(A, YB, e.borderBottomRightRadius), this.borderBottomLeftRadius = p(A, ZB, e.borderBottomLeftRadius), this.borderTopStyle = p(A, zB, e.borderTopStyle), this.borderRightStyle = p(A, $B, e.borderRightStyle), this.borderBottomStyle = p(A, jB, e.borderBottomStyle), this.borderLeftStyle = p(A, qB, e.borderLeftStyle), this.borderTopWidth = p(A, Ao, e.borderTopWidth), this.borderRightWidth = p(A, eo, e.borderRightWidth), this.borderBottomWidth = p(A, to, e.borderBottomWidth), this.borderLeftWidth = p(A, ro, e.borderLeftWidth), this.boxShadow = p(A, $o, e.boxShadow), this.color = p(A, so, e.color), this.direction = p(A, no, e.direction), this.display = p(A, io, e.display), this.float = p(A, Bo, e.cssFloat), this.fontFamily = p(A, Vo, e.fontFamily), this.fontSize = p(A, Po, e.fontSize), this.fontStyle = p(A, Xo, e.fontStyle), this.fontVariant = p(A, _o, e.fontVariant), this.fontWeight = p(A, ko, e.fontWeight), this.letterSpacing = p(A, oo, e.letterSpacing), this.lineBreak = p(A, co, e.lineBreak), this.lineHeight = p(A, lo, e.lineHeight), this.listStyleImage = p(A, uo, e.listStyleImage), this.listStylePosition = p(A, go, e.listStylePosition), this.listStyleType = p(A, wr, e.listStyleType), this.marginTop = p(A, wo, e.marginTop), this.marginRight = p(A, fo, e.marginRight), this.marginBottom = p(A, Qo, e.marginBottom), this.marginLeft = p(A, ho, e.marginLeft), this.opacity = p(A, Ro, e.opacity);
      var n = p(A, Co, e.overflow);
      this.overflowX = n[0], this.overflowY = n[n.length > 1 ? 1 : 0], this.overflowWrap = p(A, Uo, e.overflowWrap), this.paddingTop = p(A, Fo, e.paddingTop), this.paddingRight = p(A, po, e.paddingRight), this.paddingBottom = p(A, Eo, e.paddingBottom), this.paddingLeft = p(A, vo, e.paddingLeft), this.paintOrder = p(A, jo, e.paintOrder), this.position = p(A, mo, e.position), this.textAlign = p(A, Ho, e.textAlign), this.textDecorationColor = p(A, Go, (r = e.textDecorationColor) !== null && r !== void 0 ? r : e.color), this.textDecorationLine = p(A, No, (s = e.textDecorationLine) !== null && s !== void 0 ? s : e.textDecoration), this.textShadow = p(A, Io, e.textShadow), this.textTransform = p(A, yo, e.textTransform), this.transform = p(A, Lo, e.transform), this.transformOrigin = p(A, To, e.transformOrigin), this.visibility = p(A, xo, e.visibility), this.webkitTextStrokeColor = p(A, qo, e.webkitTextStrokeColor), this.webkitTextStrokeWidth = p(A, Ac, e.webkitTextStrokeWidth), this.wordBreak = p(A, Mo, e.wordBreak), this.zIndex = p(A, Oo, e.zIndex);
    }
    return t.prototype.isVisible = function() {
      return this.display > 0 && this.opacity > 0 && this.visibility === 0;
    }, t.prototype.isTransparent = function() {
      return OA(this.backgroundColor);
    }, t.prototype.isTransformed = function() {
      return this.transform !== null;
    }, t.prototype.isPositioned = function() {
      return this.position !== 0;
    }, t.prototype.isPositionedWithZIndex = function() {
      return this.isPositioned() && !this.zIndex.auto;
    }, t.prototype.isFloating = function() {
      return this.float !== 0;
    }, t.prototype.isInlineLevel = function() {
      return X(
        this.display,
        4
        /* INLINE */
      ) || X(
        this.display,
        33554432
        /* INLINE_BLOCK */
      ) || X(
        this.display,
        268435456
        /* INLINE_FLEX */
      ) || X(
        this.display,
        536870912
        /* INLINE_GRID */
      ) || X(
        this.display,
        67108864
        /* INLINE_LIST_ITEM */
      ) || X(
        this.display,
        134217728
        /* INLINE_TABLE */
      );
    }, t;
  }()
), tc = (
  /** @class */
  function() {
    function t(A, e) {
      this.content = p(A, Jo, e.content), this.quotes = p(A, zo, e.quotes);
    }
    return t;
  }()
), Bs = (
  /** @class */
  function() {
    function t(A, e) {
      this.counterIncrement = p(A, Wo, e.counterIncrement), this.counterReset = p(A, Yo, e.counterReset);
    }
    return t;
  }()
), p = function(t, A, e) {
  var r = new on(), s = e !== null && typeof e < "u" ? e.toString() : A.initialValue;
  r.write(s);
  var n = new cn(r.read());
  switch (A.type) {
    case 2:
      var i = n.parseComponentValue();
      return A.parse(t, M(i) ? i.value : A.initialValue);
    case 0:
      return A.parse(t, n.parseComponentValue());
    case 1:
      return A.parse(t, n.parseComponentValues());
    case 4:
      return n.parseComponentValue();
    case 3:
      switch (A.format) {
        case "angle":
          return Et.parse(t, n.parseComponentValue());
        case "color":
          return MA.parse(t, n.parseComponentValue());
        case "image":
          return Lr.parse(t, n.parseComponentValue());
        case "length":
          var a = n.parseComponentValue();
          return RA(a) ? a : z;
        case "length-percentage":
          var B = n.parseComponentValue();
          return k(B) ? B : z;
        case "time":
          return yn.parse(t, n.parseComponentValue());
      }
      break;
  }
}, rc = "data-html2canvas-debug", sc = function(t) {
  var A = t.getAttribute(rc);
  switch (A) {
    case "all":
      return 1;
    case "clone":
      return 2;
    case "parse":
      return 3;
    case "render":
      return 4;
    default:
      return 0;
  }
}, fr = function(t, A) {
  var e = sc(t);
  return e === 1 || A === e;
}, dA = (
  /** @class */
  function() {
    function t(A, e) {
      if (this.context = A, this.textNodes = [], this.elements = [], this.flags = 0, fr(
        e,
        3
        /* PARSE */
      ))
        debugger;
      this.styles = new ec(A, window.getComputedStyle(e, null)), Cr(e) && (this.styles.animationDuration.some(function(r) {
        return r > 0;
      }) && (e.style.animationDuration = "0s"), this.styles.transform !== null && (e.style.transform = "none")), this.bounds = Ft(this.context, e), fr(
        e,
        4
        /* RENDER */
      ) && (this.flags |= 16);
    }
    return t;
  }()
), nc = "[encoded data, 26156 characters]", os = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Ue = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
for (var ze = 0; ze < os.length; ze++)
  Ue[os.charCodeAt(ze)] = ze;
var ic = function(t) {
  var A = t.length * 0.75, e = t.length, r, s = 0, n, i, a, B;
  t[t.length - 1] === "=" && (A--, t[t.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 (r = 0; r < e; r += 4)
    n = Ue[t.charCodeAt(r)], i = Ue[t.charCodeAt(r + 1)], a = Ue[t.charCodeAt(r + 2)], B = Ue[t.charCodeAt(r + 3)], c[s++] = n << 2 | i >> 4, c[s++] = (i & 15) << 4 | a >> 2, c[s++] = (a & 3) << 6 | B & 63;
  return o;
}, ac = function(t) {
  for (var A = t.length, e = [], r = 0; r < A; r += 2)
    e.push(t[r + 1] << 8 | t[r]);
  return e;
}, Bc = function(t) {
  for (var A = t.length, e = [], r = 0; r < A; r += 4)
    e.push(t[r + 3] << 24 | t[r + 2] << 16 | t[r + 1] << 8 | t[r]);
  return e;
}, WA = 5, br = 6 + 5, Vt = 2, oc = br - WA, Ln = 65536 >> WA, cc = 1 << WA, Pt = cc - 1, lc = 1024 >> WA, uc = Ln + lc, gc = uc, wc = 32, fc = gc + wc, Qc = 65536 >> br, hc = 1 << oc, Cc = hc - 1, cs = function(t, A, e) {
  return t.slice ? t.slice(A, e) : new Uint16Array(Array.prototype.slice.call(t, A, e));
}, dc = function(t, A, e) {
  return t.slice ? t.slice(A, e) : new Uint32Array(Array.prototype.slice.call(t, A, e));
}, Uc = function(t, A) {
  var e = ic(t), r = Array.isArray(e) ? Bc(e) : new Uint32Array(e), s = Array.isArray(e) ? ac(e) : new Uint16Array(e), n = 24, i = cs(s, n / 2, r[4] / 2), a = r[5] === 2 ? cs(s, (n + r[4]) / 2) : dc(r, Math.ceil((n + r[4]) / 4));
  return new Fc(r[0], r[1], r[2], r[3], i, a);
}, Fc = (
  /** @class */
  function() {
    function t(A, e, r, s, n, i) {
      this.initialValue = A, this.errorValue = e, this.highStart = r, this.highValueIndex = s, this.index = n, this.data = i;
    }
    return t.prototype.get = function(A) {
      var e;
      if (A >= 0) {
        if (A < 55296 || A > 56319 && A <= 65535)
          return e = this.index[A >> WA], e = (e << Vt) + (A & Pt), this.data[e];
        if (A <= 65535)
          return e = this.index[Ln + (A - 55296 >> WA)], e = (e << Vt) + (A & Pt), this.data[e];
        if (A < this.highStart)
          return e = fc - Qc + (A >> br), e = this.index[e], e += A >> WA & Cc, e = this.index[e], e = (e << Vt) + (A & Pt), this.data[e];
        if (A <= 1114111)
          return this.data[this.highValueIndex];
      }
      return this.errorValue;
    }, t;
  }()
), ls = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", pc = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
for (var $e = 0; $e < ls.length; $e++)
  pc[ls.charCodeAt($e)] = $e;
var Ec = 1, kt = 2, _t = 3, us = 4, gs = 5, vc = 7, ws = 8, Xt = 9, Jt = 10, fs = 11, Qs = 12, hs = 13, Cs = 14, Wt = 15, Hc = function(t) {
  for (var A = [], e = 0, r = t.length; e < r; ) {
    var s = t.charCodeAt(e++);
    if (s >= 55296 && s <= 56319 && e < r) {
      var n = t.charCodeAt(e++);
      (n & 64512) === 56320 ? A.push(((s & 1023) << 10) + (n & 1023) + 65536) : (A.push(s), e--);
    } else
      A.push(s);
  }
  return A;
}, mc = function() {
  for (var t = [], A = 0; A < arguments.length; A++)
    t[A] = arguments[A];
  if (String.fromCodePoint)
    return String.fromCodePoint.apply(String, t);
  var e = t.length;
  if (!e)
    return "";
  for (var r = [], s = -1, n = ""; ++s < e; ) {
    var i = t[s];
    i <= 65535 ? r.push(i) : (i -= 65536, r.push((i >> 10) + 55296, i % 1024 + 56320)), (s + 1 === e || r.length > 16384) && (n += String.fromCharCode.apply(String, r), r.length = 0);
  }
  return n;
}, Ic = Uc(nc), aA = "×", Yt = "÷", yc = function(t) {
  return Ic.get(t);
}, Lc = function(t, A, e) {
  var r = e - 2, s = A[r], n = A[e - 1], i = A[e];
  if (n === kt && i === _t)
    return aA;
  if (n === kt || n === _t || n === us || i === kt || i === _t || i === us)
    return Yt;
  if (n === ws && [ws, Xt, fs, Qs].indexOf(i) !== -1 || (n === fs || n === Xt) && (i === Xt || i === Jt) || (n === Qs || n === Jt) && i === Jt || i === hs || i === gs || i === vc || n === Ec)
    return aA;
  if (n === hs && i === Cs) {
    for (; s === gs; )
      s = A[--r];
    if (s === Cs)
      return aA;
  }
  if (n === Wt && i === Wt) {
    for (var a = 0; s === Wt; )
      a++, s = A[--r];
    if (a % 2 === 0)
      return aA;
  }
  return Yt;
}, bc = function(t) {
  var A = Hc(t), e = A.length, r = 0, s = 0, n = A.map(yc);
  return {
    next: function() {
      if (r >= e)
        return { done: !0, value: null };
      for (var i = aA; r < e && (i = Lc(A, n, ++r)) === aA; )
        ;
      if (i !== aA || r === e) {
        var a = mc.apply(null, A.slice(s, r));
        return s = r, { value: a, done: !1 };
      }
      return { done: !0, value: null };
    }
  };
}, Kc = function(t) {
  for (var A = bc(t), e = [], r; !(r = A.next()).done; )
    r.value && e.push(r.value.slice());
  return e;
}, Dc = function(t) {
  var A = 123;
  if (t.createRange) {
    var e = t.createRange();
    if (e.getBoundingClientRect) {
      var r = t.createElement("boundtest");
      r.style.height = A + "px", r.style.display = "block", t.body.appendChild(r), e.selectNode(r);
      var s = e.getBoundingClientRect(), n = Math.round(s.height);
      if (t.body.removeChild(r), n === A)
        return !0;
    }
  }
  return !1;
}, Sc = function(t) {
  var A = t.createElement("boundtest");
  A.style.width = "50px", A.style.display = "block", A.style.fontSize = "12px", A.style.letterSpacing = "0px", A.style.wordSpacing = "0px", t.body.appendChild(A);
  var e = t.createRange();
  A.innerHTML = typeof "".repeat == "function" ? "&#128104;".repeat(10) : "";
  var r = A.firstChild, s = pt(r.data).map(function(B) {
    return P(B);
  }), n = 0, i = {}, a = s.every(function(B, o) {
    e.setStart(r, n), e.setEnd(r, n + B.length);
    var c = e.getBoundingClientRect();
    n += B.length;
    var l = c.x > i.x || c.y > i.y;
    return i = c, o === 0 ? !0 : l;
  });
  return t.body.removeChild(A), a;
}, Tc = function() {
  return typeof new Image().crossOrigin < "u";
}, xc = function() {
  return typeof new XMLHttpRequest().responseType == "string";
}, Mc = function(t) {
  var A = new Image(), e = t.createElement("canvas"), r = e.getContext("2d");
  if (!r)
    return !1;
  A.src = "data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>";
  try {
    r.drawImage(A, 0, 0), e.toDataURL();
  } catch (s) {
    return !1;
  }
  return !0;
}, ds = function(t) {
  return t[0] === 0 && t[1] === 255 && t[2] === 0 && t[3] === 255;
}, Oc = function(t) {
  var A = t.createElement("canvas"), e = 100;
  A.width = e, A.height = e;
  var r = A.getContext("2d");
  if (!r)
    return Promise.reject(!1);
  r.fillStyle = "rgb(0, 255, 0)", r.fillRect(0, 0, e, e);
  var s = new Image(), n = A.toDataURL();
  s.src = n;
  var i = Qr(e, e, 0, 0, s);
  return r.fillStyle = "red", r.fillRect(0, 0, e, e), Us(i).then(function(a) {
    r.drawImage(a, 0, 0);
    var B = r.getImageData(0, 0, e, e).data;
    r.fillStyle = "red", r.fillRect(0, 0, e, e);
    var o = t.createElement("div");
    return o.style.backgroundImage = "url(" + n + ")", o.style.height = e + "px", ds(B) ? Us(Qr(e, e, 0, 0, o)) : Promise.reject(!1);
  }).then(function(a) {
    return r.drawImage(a, 0, 0), ds(r.getImageData(0, 0, e, e).data);
  }).catch(function() {
    return !1;
  });
}, Qr = function(t, A, e, r, s) {
  var n = "http://www.w3.org/2000/svg", i = document.createElementNS(n, "svg"), a = document.createElementNS(n, "foreignObject");
  return i.setAttributeNS(null, "width", t.toString()), i.setAttributeNS(null, "height", A.toString()), a.setAttributeNS(null, "width", "100%"), a.setAttributeNS(null, "height", "100%"), a.setAttributeNS(null, "x", e.toString()), a.setAttributeNS(null, "y", r.toString()), a.setAttributeNS(null, "externalResourcesRequired", "true"), i.appendChild(a), a.appendChild(s), i;
}, Us = function(t) {
  return new Promise(function(A, e) {
    var r = new Image();
    r.onload = function() {
      return A(r);
    }, r.onerror = e, r.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(new XMLSerializer().serializeToString(t));
  });
}, Z = {
  get SUPPORT_RANGE_BOUNDS() {
    var t = Dc(document);
    return Object.defineProperty(Z, "SUPPORT_RANGE_BOUNDS", { value: t }), t;
  },
  get SUPPORT_WORD_BREAKING() {
    var t = Z.SUPPORT_RANGE_BOUNDS && Sc(document);
    return Object.defineProperty(Z, "SUPPORT_WORD_BREAKING", { value: t }), t;
  },
  get SUPPORT_SVG_DRAWING() {
    var t = Mc(document);
    return Object.defineProperty(Z, "SUPPORT_SVG_DRAWING", { value: t }), t;
  },
  get SUPPORT_FOREIGNOBJECT_DRAWING() {
    var t = typeof Array.from == "function" && typeof window.fetch == "function" ? Oc(document) : Promise.resolve(!1);
    return Object.defineProperty(Z, "SUPPORT_FOREIGNOBJECT_DRAWING", { value: t }), t;
  },
  get SUPPORT_CORS_IMAGES() {
    var t = Tc();
    return Object.defineProperty(Z, "SUPPORT_CORS_IMAGES", { value: t }), t;
  },
  get SUPPORT_RESPONSE_TYPE() {
    var t = xc();
    return Object.defineProperty(Z, "SUPPORT_RESPONSE_TYPE", { value: t }), t;
  },
  get SUPPORT_CORS_XHR() {
    var t = "withCredentials" in new XMLHttpRequest();
    return Object.defineProperty(Z, "SUPPORT_CORS_XHR", { value: t }), t;
  },
  get SUPPORT_NATIVE_TEXT_SEGMENTATION() {
    var t = !!(typeof Intl < "u" && Intl.Segmenter);
    return Object.defineProperty(Z, "SUPPORT_NATIVE_TEXT_SEGMENTATION", { value: t }), t;
  }
}, me = (
  /** @class */
  function() {
    function t(A, e) {
      this.text = A, this.bounds = e;
    }
    return t;
  }()
), Rc = function(t, A, e, r) {
  var s = Vc(A, e), n = [], i = 0;
  return s.forEach(function(a) {
    if (e.textDecorationLine.length || a.trim().length > 0)
      if (Z.SUPPORT_RANGE_BOUNDS) {
        var B = Fs(r, i, a.length).getClientRects();
        if (B.length > 1) {
          var o = Kr(a), c = 0;
          o.forEach(function(u) {
            n.push(new me(u, IA.fromDOMRectList(t, Fs(r, c + i, u.length).getClientRects()))), c += u.length;
          });
        } else
          n.push(new me(a, IA.fromDOMRectList(t, B)));
      } else {
        var l = r.splitText(a.length);
        n.push(new me(a, Gc(t, r))), r = l;
      }
    else
      Z.SUPPORT_RANGE_BOUNDS || (r = r.splitText(a.length));
    i += a.length;
  }), n;
}, Gc = function(t, A) {
  var e = A.ownerDocument;
  if (e) {
    var r = e.createElement("html2canvaswrapper");
    r.appendChild(A.cloneNode(!0));
    var s = A.parentNode;
    if (s) {
      s.replaceChild(r, A);
      var n = Ft(t, r);
      return r.firstChild && s.replaceChild(r.firstChild, r), n;
    }
  }
  return IA.EMPTY;
}, Fs = function(t, A, e) {
  var r = t.ownerDocument;
  if (!r)
    throw new Error("Node has no owner document");
  var s = r.createRange();
  return s.setStart(t, A), s.setEnd(t, A + e), s;
}, Kr = function(t) {
  if (Z.SUPPORT_NATIVE_TEXT_SEGMENTATION) {
    var A = new Intl.Segmenter(void 0, { granularity: "grapheme" });
    return Array.from(A.segment(t)).map(function(e) {
      return e.segment;
    });
  }
  return Kc(t);
}, Nc = function(t, A) {
  if (Z.SUPPORT_NATIVE_TEXT_SEGMENTATION) {
    var e = new Intl.Segmenter(void 0, {
      granularity: "word"
    });
    return Array.from(e.segment(t)).map(function(r) {
      return r.segment;
    });
  }
  return kc(t, A);
}, Vc = function(t, A) {
  return A.letterSpacing !== 0 ? Kr(t) : Nc(t, A);
}, Pc = [32, 160, 4961, 65792, 65793, 4153, 4241], kc = function(t, A) {
  for (var e = fa(t, {
    lineBreak: A.lineBreak,
    wordBreak: A.overflowWrap === "break-word" ? "break-word" : A.wordBreak
  }), r = [], s, n = function() {
    if (s.value) {
      var i = s.value.slice(), a = pt(i), B = "";
      a.forEach(function(o) {
        Pc.indexOf(o) === -1 ? B += P(o) : (B.length && r.push(B), r.push(P(o)), B = "");
      }), B.length && r.push(B);
    }
  }; !(s = e.next()).done; )
    n();
  return r;
}, _c = (
  /** @class */
  function() {
    function t(A, e, r) {
      this.text = Xc(e.data, r.textTransform), this.textBounds = Rc(A, this.text, r, e);
    }
    return t;
  }()
), Xc = function(t, A) {
  switch (A) {
    case 1:
      return t.toLowerCase();
    case 3:
      return t.replace(Jc, Wc);
    case 2:
      return t.toUpperCase();
    default:
      return t;
  }
}, Jc = /(^|\s|:|-|\(|\))([a-z])/g, Wc = function(t, A, e) {
  return t.length > 0 ? A + e.toUpperCase() : t;
}, bn = (
  /** @class */
  function(t) {
    gA(A, t);
    function A(e, r) {
      var s = t.call(this, e, r) || this;
      return s.src = r.currentSrc || r.src, s.intrinsicWidth = r.naturalWidth, s.intrinsicHeight = r.naturalHeight, s.context.cache.addImage(s.src), s;
    }
    return A;
  }(dA)
), Kn = (
  /** @class */
  function(t) {
    gA(A, t);
    function A(e, r) {
      var s = t.call(this, e, r) || this;
      return s.canvas = r, s.intrinsicWidth = r.width, s.intrinsicHeight = r.height, s;
    }
    return A;
  }(dA)
), Dn = (
  /** @class */
  function(t) {
    gA(A, t);
    function A(e, r) {
      var s = t.call(this, e, r) || this, n = new XMLSerializer(), i = Ft(e, r);
      return r.setAttribute("width", i.width + "px"), r.setAttribute("height", i.height + "px"), s.svg = "data:image/svg+xml," + encodeURIComponent(n.serializeToString(r)), s.intrinsicWidth = r.width.baseVal.value, s.intrinsicHeight = r.height.baseVal.value, s.context.cache.addImage(s.svg), s;
    }
    return A;
  }(dA)
), Sn = (
  /** @class */
  function(t) {
    gA(A, t);
    function A(e, r) {
      var s = t.call(this, e, r) || this;
      return s.value = r.value, s;
    }
    return A;
  }(dA)
), hr = (
  /** @class */
  function(t) {
    gA(A, t);
    function A(e, r) {
      var s = t.call(this, e, r) || this;
      return s.start = r.start, s.reversed = typeof r.reversed == "boolean" && r.reversed === !0, s;
    }
    return A;
  }(dA)
), Yc = [
  {
    type: 15,
    flags: 0,
    unit: "px",
    number: 3
  }
], Zc = [
  {
    type: 16,
    flags: 0,
    number: 50
  }
], zc = function(t) {
  return t.width > t.height ? new IA(t.left + (t.width - t.height) / 2, t.top, t.height, t.height) : t.width < t.height ? new IA(t.left, t.top + (t.height - t.width) / 2, t.width, t.width) : t;
}, $c = function(t) {
  var A = t.type === jc ? new Array(t.value.length + 1).join("•") : t.value;
  return A.length === 0 ? t.placeholder || "" : A;
}, ct = "checkbox", lt = "radio", jc = "password", ps = 707406591, Dr = (
  /** @class */
  function(t) {
    gA(A, t);
    function A(e, r) {
      var s = t.call(this, e, r) || this;
      switch (s.type = r.type.toLowerCase(), s.checked = r.checked, s.value = $c(r), (s.type === ct || s.type === lt) && (s.styles.backgroundColor = 3739148031, s.styles.borderTopColor = s.styles.borderRightColor = s.styles.borderBottomColor = s.styles.borderLeftColor = 2779096575, s.styles.borderTopWidth = s.styles.borderRightWidth = s.styles.borderBottomWidth = s.styles.borderLeftWidth = 1, s.styles.borderTopStyle = s.styles.borderRightStyle = s.styles.borderBottomStyle = s.styles.borderLeftStyle = 1, s.styles.backgroundClip = [
        0
        /* BORDER_BOX */
      ], s.styles.backgroundOrigin = [
        0
        /* BORDER_BOX */
      ], s.bounds = zc(s.bounds)), s.type) {
        case ct:
          s.styles.borderTopRightRadius = s.styles.borderTopLeftRadius = s.styles.borderBottomRightRadius = s.styles.borderBottomLeftRadius = Yc;
          break;
        case lt:
          s.styles.borderTopRightRadius = s.styles.borderTopLeftRadius = s.styles.borderBottomRightRadius = s.styles.borderBottomLeftRadius = Zc;
          break;
      }
      return s;
    }
    return A;
  }(dA)
), Tn = (
  /** @class */
  function(t) {
    gA(A, t);
    function A(e, r) {
      var s = t.call(this, e, r) || this, n = r.options[r.selectedIndex || 0];
      return s.value = n && n.text || "", s;
    }
    return A;
  }(dA)
), xn = (
  /** @class */
  function(t) {
    gA(A, t);
    function A(e, r) {
      var s = t.call(this, e, r) || this;
      return s.value = r.value, s;
    }
    return A;
  }(dA)
), Mn = (
  /** @class */
  function(t) {
    gA(A, t);
    function A(e, r) {
      var s = t.call(this, e, r) || this;
      s.src = r.src, s.width = parseInt(r.width, 10) || 0, s.height = parseInt(r.height, 10) || 0, s.backgroundColor = s.styles.backgroundColor;
      try {
        if (r.contentWindow && r.contentWindow.document && r.contentWindow.document.documentElement) {
          s.tree = Rn(e, r.contentWindow.document.documentElement);
          var n = r.contentWindow.document.documentElement ? ve(e, getComputedStyle(r.contentWindow.document.documentElement).backgroundColor) : mA.TRANSPARENT, i = r.contentWindow.document.body ? ve(e, getComputedStyle(r.contentWindow.document.body).backgroundColor) : mA.TRANSPARENT;
          s.backgroundColor = OA(n) ? OA(i) ? s.styles.backgroundColor : i : n;
        }
      } catch (a) {
      }
      return s;
    }
    return A;
  }(dA)
), qc = ["OL", "UL", "MENU"], st = function(t, A, e, r) {
  for (var s = A.firstChild, n = void 0; s; s = n)
    if (n = s.nextSibling, Gn(s) && s.data.trim().length > 0)
      e.textNodes.push(new _c(t, s, e.styles));
    else if (ne(s))
      if (kn(s) && s.assignedNodes)
        s.assignedNodes().forEach(function(a) {
          return st(t, a, e, r);
        });
      else {
        var i = On(t, s);
        i.styles.isVisible() && (Al(s, i, r) ? i.flags |= 4 : el(i.styles) && (i.flags |= 2), qc.indexOf(s.tagName) !== -1 && (i.flags |= 8), e.elements.push(i), s.slot, s.shadowRoot ? st(t, s.shadowRoot, i, r) : !ut(s) && !Nn(s) && !gt(s) && st(t, s, i, r));
      }
}, On = function(t, A) {
  return dr(A) ? new bn(t, A) : Vn(A) ? new Kn(t, A) : Nn(A) ? new Dn(t, A) : tl(A) ? new Sn(t, A) : rl(A) ? new hr(t, A) : sl(A) ? new Dr(t, A) : gt(A) ? new Tn(t, A) : ut(A) ? new xn(t, A) : Pn(A) ? new Mn(t, A) : new dA(t, A);
}, Rn = function(t, A) {
  var e = On(t, A);
  return e.flags |= 4, st(t, A, e, e), e;
}, Al = function(t, A, e) {
  return A.styles.isPositionedWithZIndex() || A.styles.opacity < 1 || A.styles.isTransformed() || Sr(t) && e.styles.isTransparent();
}, el = function(t) {
  return t.isPositioned() || t.isFloating();
}, Gn = function(t) {
  return t.nodeType === Node.TEXT_NODE;
}, ne = function(t) {
  return t.nodeType === Node.ELEMENT_NODE;
}, Cr = function(t) {
  return ne(t) && typeof t.style < "u" && !nt(t);
}, nt = function(t) {
  return typeof t.className == "object";
}, tl = function(t) {
  return t.tagName === "LI";
}, rl = function(t) {
  return t.tagName === "OL";
}, sl = function(t) {
  return t.tagName === "INPUT";
}, nl = function(t) {
  return t.tagName === "HTML";
}, Nn = function(t) {
  return t.tagName === "svg";
}, Sr = function(t) {
  return t.tagName === "BODY";
}, Vn = function(t) {
  return t.tagName === "CANVAS";
}, Es = function(t) {
  return t.tagName === "VIDEO";
}, dr = function(t) {
  return t.tagName === "IMG";
}, Pn = function(t) {
  return t.tagName === "IFRAME";
}, vs = function(t) {
  return t.tagName === "STYLE";
}, il = function(t) {
  return t.tagName === "SCRIPT";
}, ut = function(t) {
  return t.tagName === "TEXTAREA";
}, gt = function(t) {
  return t.tagName === "SELECT";
}, kn = function(t) {
  return t.tagName === "SLOT";
}, Hs = function(t) {
  return t.tagName.indexOf("-") > 0;
}, al = (
  /** @class */
  function() {
    function t() {
      this.counters = {};
    }
    return t.prototype.getCounterValue = function(A) {
      var e = this.counters[A];
      return e && e.length ? e[e.length - 1] : 1;
    }, t.prototype.getCounterValues = function(A) {
      var e = this.counters[A];
      return e || [];
    }, t.prototype.pop = function(A) {
      var e = this;
      A.forEach(function(r) {
        return e.counters[r].pop();
      });
    }, t.prototype.parse = function(A) {
      var e = this, r = A.counterIncrement, s = A.counterReset, n = !0;
      r !== null && r.forEach(function(a) {
        var B = e.counters[a.counter];
        B && a.increment !== 0 && (n = !1, B.length || B.push(1), B[Math.max(0, B.length - 1)] += a.increment);
      });
      var i = [];
      return n && s.forEach(function(a) {
        var B = e.counters[a.counter];
        i.push(a.counter), B || (B = e.counters[a.counter] = []), B.push(a.reset);
      }), i;
    }, t;
  }()
), ms = {
  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"]
}, Is = {
  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: [
    "Ք",
    "Փ",
    "Ւ",
    "Ց",
    "Ր",
    "Տ",
    "Վ",
    "Ս",
    "Ռ",
    "Ջ",
    "Պ",
    "Չ",
    "Ո",
    "Շ",
    "Ն",
    "Յ",
    "Մ",
    "Ճ",
    "Ղ",
    "Ձ",
    "Հ",
    "Կ",
    "Ծ",
    "Խ",
    "Լ",
    "Ի",
    "Ժ",
    "Թ",
    "Ը",
    "Է",
    "Զ",
    "Ե",
    "Դ",
    "Գ",
    "Բ",
    "Ա"
  ]
}, Bl = {
  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: [
    "י׳",
    "ט׳",
    "ח׳",
    "ז׳",
    "ו׳",
    "ה׳",
    "ד׳",
    "ג׳",
    "ב׳",
    "א׳",
    "ת",
    "ש",
    "ר",
    "ק",
    "צ",
    "פ",
    "ע",
    "ס",
    "נ",
    "מ",
    "ל",
    "כ",
    "יט",
    "יח",
    "יז",
    "טז",
    "טו",
    "י",
    "ט",
    "ח",
    "ז",
    "ו",
    "ה",
    "ד",
    "ג",
    "ב",
    "א"
  ]
}, ol = {
  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: [
    "ჵ",
    "ჰ",
    "ჯ",
    "ჴ",
    "ხ",
    "ჭ",
    "წ",
    "ძ",
    "ც",
    "ჩ",
    "შ",
    "ყ",
    "ღ",
    "ქ",
    "ფ",
    "ჳ",
    "ტ",
    "ს",
    "რ",
    "ჟ",
    "პ",
    "ო",
    "ჲ",
    "ნ",
    "მ",
    "ლ",
    "კ",
    "ი",
    "თ",
    "ჱ",
    "ზ",
    "ვ",
    "ე",
    "დ",
    "გ",
    "ბ",
    "ა"
  ]
}, Ae = function(t, A, e, r, s, n) {
  return t < A || t > e ? be(t, s, n.length > 0) : r.integers.reduce(function(i, a, B) {
    for (; t >= a; )
      t -= a, i += r.values[B];
    return i;
  }, "") + n;
}, _n = function(t, A, e, r) {
  var s = "";
  do
    e || t--, s = r(t) + s, t /= A;
  while (t * A >= A);
  return s;
}, V = function(t, A, e, r, s) {
  var n = e - A + 1;
  return (t < 0 ? "-" : "") + (_n(Math.abs(t), n, r, function(i) {
    return P(Math.floor(i % n) + A);
  }) + s);
}, PA = function(t, A, e) {
  e === void 0 && (e = ". ");
  var r = A.length;
  return _n(Math.abs(t), r, !1, function(s) {
    return A[Math.floor(s % r)];
  }) + e;
}, re = 1 << 0, bA = 1 << 1, KA = 1 << 2, Fe = 1 << 3, EA = function(t, A, e, r, s, n) {
  if (t < -9999 || t > 9999)
    return be(t, 4, s.length > 0);
  var i = Math.abs(t), a = s;
  if (i === 0)
    return A[0] + a;
  for (var B = 0; i > 0 && B <= 4; B++) {
    var o = i % 10;
    o === 0 && X(n, re) && a !== "" ? a = A[o] + a : o > 1 || o === 1 && B === 0 || o === 1 && B === 1 && X(n, bA) || o === 1 && B === 1 && X(n, KA) && t > 100 || o === 1 && B > 1 && X(n, Fe) ? a = A[o] + (B > 0 ? e[B - 1] : "") + a : o === 1 && B > 0 && (a = e[B - 1] + a), i = Math.floor(i / 10);
  }
  return (t < 0 ? r : "") + a;
}, ys = "十百千萬", Ls = "拾佰仟萬", bs = "マイナス", Zt = "마이너스", be = function(t, A, e) {
  var r = e ? ". " : "", s = e ? "、" : "", n = e ? ", " : "", i = e ? " " : "";
  switch (A) {
    case 0:
      return "•" + i;
    case 1:
      return "◦" + i;
    case 2:
      return "◾" + i;
    case 5:
      var a = V(t, 48, 57, !0, r);
      return a.length < 4 ? "0" + a : a;
    case 4:
      return PA(t, "〇一二三四五六七八九", s);
    case 6:
      return Ae(t, 1, 3999, ms, 3, r).toLowerCase();
    case 7:
      return Ae(t, 1, 3999, ms, 3, r);
    case 8:
      return V(t, 945, 969, !1, r);
    case 9:
      return V(t, 97, 122, !1, r);
    case 10:
      return V(t, 65, 90, !1, r);
    case 11:
      return V(t, 1632, 1641, !0, r);
    case 12:
    case 49:
      return Ae(t, 1, 9999, Is, 3, r);
    case 35:
      return Ae(t, 1, 9999, Is, 3, r).toLowerCase();
    case 13:
      return V(t, 2534, 2543, !0, r);
    case 14:
    case 30:
      return V(t, 6112, 6121, !0, r);
    case 15:
      return PA(t, "子丑寅卯辰巳午未申酉戌亥", s);
    case 16:
      return PA(t, "甲乙丙丁戊己庚辛壬癸", s);
    case 17:
    case 48:
      return EA(t, "零一二三四五六七八九", ys, "負", s, bA | KA | Fe);
    case 47:
      return EA(t, "零壹貳參肆伍陸柒捌玖", Ls, "負", s, re | bA | KA | Fe);
    case 42:
      return EA(t, "零一二三四五六七八九", ys, "负", s, bA | KA | Fe);
    case 41:
      return EA(t, "零壹贰叁肆伍陆柒捌玖", Ls, "负", s, re | bA | KA | Fe);
    case 26:
      return EA(t, "〇一二三四五六七八九", "十百千万", bs, s, 0);
    case 25:
      return EA(t, "零壱弐参四伍六七八九", "拾百千万", bs, s, re | bA | KA);
    case 31:
      return EA(t, "영일이삼사오육칠팔구", "십백천만", Zt, n, re | bA | KA);
    case 33:
      return EA(t, "零一二三四五六七八九", "十百千萬", Zt, n, 0);
    case 32:
      return EA(t, "零壹貳參四五六七八九", "拾百千", Zt, n, re | bA | KA);
    case 18:
      return V(t, 2406, 2415, !0, r);
    case 20:
      return Ae(t, 1, 19999, ol, 3, r);
    case 21:
      return V(t, 2790, 2799, !0, r);
    case 22:
      return V(t, 2662, 2671, !0, r);
    case 22:
      return Ae(t, 1, 10999, Bl, 3, r);
    case 23:
      return PA(t, "あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん");
    case 24:
      return PA(t, "いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす");
    case 27:
      return V(t, 3302, 3311, !0, r);
    case 28:
      return PA(t, "アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン", s);
    case 29:
      return PA(t, "イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス", s);
    case 34:
      return V(t, 3792, 3801, !0, r);
    case 37:
      return V(t, 6160, 6169, !0, r);
    case 38:
      return V(t, 4160, 4169, !0, r);
    case 39:
      return V(t, 2918, 2927, !0, r);
    case 40:
      return V(t, 1776, 1785, !0, r);
    case 43:
      return V(t, 3046, 3055, !0, r);
    case 44:
      return V(t, 3174, 3183, !0, r);
    case 45:
      return V(t, 3664, 3673, !0, r);
    case 46:
      return V(t, 3872, 3881, !0, r);
    case 3:
    default:
      return V(t, 48, 57, !0, r);
  }
}, Xn = "data-html2canvas-ignore", Ks = (
  /** @class */
  function() {
    function t(A, e, r) {
      if (this.context = A, this.options = r, this.scrolledElements = [], this.referenceElement = e, this.counters = new al(), this.quoteDepth = 0, !e.ownerDocument)
        throw new Error("Cloned element does not have an owner document");
      this.documentElement = this.cloneNode(e.ownerDocument.documentElement, !1);
    }
    return t.prototype.toIFrame = function(A, e) {
      var r = this, s = cl(A, e);
      if (!s.contentWindow)
        return Promise.reject("Unable to find iframe window");
      var n = A.defaultView.pageXOffset, i = A.defaultView.pageYOffset, a = s.contentWindow, B = a.document, o = gl(s).then(function() {
        return AA(r, void 0, void 0, function() {
          var c, l;
          return $(this, function(u) {
            switch (u.label) {
              case 0:
                return this.scrolledElements.forEach(hl), a && (a.scrollTo(e.left, e.top), /(iPad|iPhone|iPod)/g.test(navigator.userAgent) && (a.scrollY !== e.top || a.scrollX !== e.left) && (this.context.logger.warn("Unable to restore scroll position for cloned document"), this.context.windowBounds = this.context.windowBounds.add(a.scrollX - e.left, a.scrollY - e.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")] : B.fonts && B.fonts.ready ? [4, B.fonts.ready] : [3, 2];
              case 1:
                u.sent(), u.label = 2;
              case 2:
                return /(AppleWebKit)/g.test(navigator.userAgent) ? [4, ul(B)] : [3, 4];
              case 3:
                u.sent(), u.label = 4;
              case 4:
                return typeof c == "function" ? [2, Promise.resolve().then(function() {
                  return c(B, l);
                }).then(function() {
                  return s;
                })] : [2, s];
            }
          });
        });
      });
      return B.open(), B.write(fl(document.doctype) + "<html></html>"), Ql(this.referenceElement.ownerDocument, n, i), B.replaceChild(B.adoptNode(this.documentElement), B.documentElement), B.close(), o;
    }, t.prototype.createElementClone = function(A) {
      if (fr(
        A,
        2
        /* CLONE */
      ))
        debugger;
      if (Vn(A))
        return this.createCanvasClone(A);
      if (Es(A))
        return this.createVideoClone(A);
      if (vs(A))
        return this.createStyleClone(A);
      var e = A.cloneNode(!1);
      return dr(e) && (dr(A) && A.currentSrc && A.currentSrc !== A.src && (e.src = A.currentSrc, e.srcset = ""), e.loading === "lazy" && (e.loading = "eager")), Hs(e) ? this.createCustomElementClone(e) : e;
    }, t.prototype.createCustomElementClone = function(A) {
      var e = document.createElement("html2canvascustomelement");
      return zt(A.style, e), e;
    }, t.prototype.createStyleClone = function(A) {
      try {
        var e = A.sheet;
        if (e && e.cssRules) {
          var r = [].slice.call(e.cssRules, 0).reduce(function(n, i) {
            return i && typeof i.cssText == "string" ? n + i.cssText : n;
          }, ""), s = A.cloneNode(!1);
          return s.textContent = r, s;
        }
      } catch (n) {
        if (this.context.logger.error("Unable to access cssRules property", n), n.name !== "SecurityError")
          throw n;
      }
      return A.cloneNode(!1);
    }, t.prototype.createCanvasClone = function(A) {
      var e;
      if (this.options.inlineImages && A.ownerDocument) {
        var r = A.ownerDocument.createElement("img");
        try {
          return r.src = A.toDataURL(), r;
        } catch (o) {
          this.context.logger.info("Unable to inline canvas contents, canvas is tainted", A);
        }
      }
      var s = A.cloneNode(!1);
      try {
        s.width = A.width, s.height = A.height;
        var n = A.getContext("2d"), i = s.getContext("2d");
        if (i)
          if (!this.options.allowTaint && n)
            i.putImageData(n.getImageData(0, 0, A.width, A.height), 0, 0);
          else {
            var a = (e = A.getContext("webgl2")) !== null && e !== void 0 ? e : A.getContext("webgl");
            if (a) {
              var B = a.getContextAttributes();
              (B == null ? void 0 : B.preserveDrawingBuffer) === !1 && this.context.logger.warn("Unable to clone WebGL context as it has preserveDrawingBuffer=false", A);
            }
            i.drawImage(A, 0, 0);
          }
        return s;
      } catch (o) {
        this.context.logger.info("Unable to clone canvas as it is tainted", A);
      }
      return s;
    }, t.prototype.createVideoClone = function(A) {
      var e = A.ownerDocument.createElement("canvas");
      e.width = A.offsetWidth, e.height = A.offsetHeight;
      var r = e.getContext("2d");
      try {
        return r && (r.drawImage(A, 0, 0, e.width, e.height), this.options.allowTaint || r.getImageData(0, 0, e.width, e.height)), e;
      } catch (n) {
        this.context.logger.info("Unable to clone video as it is tainted", A);
      }
      var s = A.ownerDocument.createElement("canvas");
      return s.width = A.offsetWidth, s.height = A.offsetHeight, s;
    }, t.prototype.appendChildNode = function(A, e, r) {
      (!ne(e) || !il(e) && !e.hasAttribute(Xn) && (typeof this.options.ignoreElements != "function" || !this.options.ignoreElements(e))) && (!this.options.copyStyles || !ne(e) || !vs(e)) && A.appendChild(this.cloneNode(e, r));
    }, t.prototype.cloneChildNodes = function(A, e, r) {
      for (var s = this, n = A.shadowRoot ? A.shadowRoot.firstChild : A.firstChild; n; n = n.nextSibling)
        if (ne(n) && kn(n) && typeof n.assignedNodes == "function") {
          var i = n.assignedNodes();
          i.length && i.forEach(function(a) {
            return s.appendChildNode(e, a, r);
          });
        } else
          this.appendChildNode(e, n, r);
    }, t.prototype.cloneNode = function(A, e) {
      if (Gn(A))
        return document.createTextNode(A.data);
      if (!A.ownerDocument)
        return A.cloneNode(!1);
      var r = A.ownerDocument.defaultView;
      if (r && ne(A) && (Cr(A) || nt(A))) {
        var s = this.createElementClone(A);
        s.style.transitionProperty = "none";
        var n = r.getComputedStyle(A), i = r.getComputedStyle(A, ":before"), a = r.getComputedStyle(A, ":after");
        this.referenceElement === A && Cr(s) && (this.clonedReferenceElement = s), Sr(s) && Ul(s);
        var B = this.counters.parse(new Bs(this.context, n)), o = this.resolvePseudoContent(A, s, i, Ie.BEFORE);
        Hs(A) && (e = !0), Es(A) || this.cloneChildNodes(A, s, e), o && s.insertBefore(o, s.firstChild);
        var c = this.resolvePseudoContent(A, s, a, Ie.AFTER);
        return c && s.appendChild(c), this.counters.pop(B), (n && (this.options.copyStyles || nt(A)) && !Pn(A) || e) && zt(n, s), (A.scrollTop !== 0 || A.scrollLeft !== 0) && this.scrolledElements.push([s, A.scrollLeft, A.scrollTop]), (ut(A) || gt(A)) && (ut(s) || gt(s)) && (s.value = A.value), s;
      }
      return A.cloneNode(!1);
    }, t.prototype.resolvePseudoContent = function(A, e, r, s) {
      var n = this;
      if (r) {
        var i = r.content, a = e.ownerDocument;
        if (!(!a || !i || i === "none" || i === "-moz-alt-content" || r.display === "none")) {
          this.counters.parse(new Bs(this.context, r));
          var B = new tc(this.context, r), o = a.createElement("html2canvaspseudoelement");
          zt(r, o), B.content.forEach(function(l) {
            if (l.type === 0)
              o.appendChild(a.createTextNode(l.value));
            else if (l.type === 22) {
              var u = a.createElement("img");
              u.src = l.value, u.style.opacity = "1", o.appendChild(u);
            } else if (l.type === 18) {
              if (l.name === "attr") {
                var f = l.values.filter(M);
                f.length && o.appendChild(a.createTextNode(A.getAttribute(f[0].value) || ""));
              } else if (l.name === "counter") {
                var g = l.values.filter(ae), h = g[0], F = g[1];
                if (h && M(h)) {
                  var w = n.counters.getCounterValue(h.value), Q = F && M(F) ? wr.parse(n.context, F.value) : 3;
                  o.appendChild(a.createTextNode(be(w, Q, !1)));
                }
              } else if (l.name === "counters") {
                var E = l.values.filter(ae), h = E[0], v = E[1], F = E[2];
                if (h && M(h)) {
                  var H = n.counters.getCounterValues(h.value), d = F && M(F) ? wr.parse(n.context, F.value) : 3, L = v && v.type === 0 ? v.value : "", b = H.map(function(y) {
                    return be(y, d, !1);
                  }).join(L);
                  o.appendChild(a.createTextNode(b));
                }
              }
            } else if (l.type === 20)
              switch (l.value) {
                case "open-quote":
                  o.appendChild(a.createTextNode(as(B.quotes, n.quoteDepth++, !0)));
                  break;
                case "close-quote":
                  o.appendChild(a.createTextNode(as(B.quotes, --n.quoteDepth, !1)));
                  break;
                default:
                  o.appendChild(a.createTextNode(l.value));
              }
          }), o.className = Ur + " " + Fr;
          var c = s === Ie.BEFORE ? " " + Ur : " " + Fr;
          return nt(e) ? e.className.baseValue += c : e.className += c, o;
        }
      }
    }, t.destroy = function(A) {
      return A.parentNode ? (A.parentNode.removeChild(A), !0) : !1;
    }, t;
  }()
), Ie;
(function(t) {
  t[t.BEFORE = 0] = "BEFORE", t[t.AFTER = 1] = "AFTER";
})(Ie || (Ie = {}));
var cl = function(t, A) {
  var e = t.createElement("iframe");
  return e.className = "html2canvas-container", e.style.visibility = "hidden", e.style.position = "fixed", e.style.left = "-10000px", e.style.top = "0px", e.style.border = "0", e.width = A.width.toString(), e.height = A.height.toString(), e.scrolling = "no", e.setAttribute(Xn, "true"), t.body.appendChild(e), e;
}, ll = function(t) {
  return new Promise(function(A) {
    if (t.complete) {
      A();
      return;
    }
    if (!t.src) {
      A();
      return;
    }
    t.onload = A, t.onerror = A;
  });
}, ul = function(t) {
  return Promise.all([].slice.call(t.images, 0).map(ll));
}, gl = function(t) {
  return new Promise(function(A, e) {
    var r = t.contentWindow;
    if (!r)
      return e("No window assigned for iframe");
    var s = r.document;
    r.onload = t.onload = function() {
      r.onload = t.onload = null;
      var n = setInterval(function() {
        s.body.childNodes.length > 0 && s.readyState === "complete" && (clearInterval(n), A(t));
      }, 50);
    };
  });
}, wl = [
  "all",
  "d",
  "content"
  // Safari shows pseudoelements if content is set
], zt = function(t, A) {
  for (var e = t.length - 1; e >= 0; e--) {
    var r = t.item(e);
    wl.indexOf(r) === -1 && A.style.setProperty(r, t.getPropertyValue(r));
  }
  return A;
}, fl = function(t) {
  var A = "";
  return t && (A += "<!DOCTYPE ", t.name && (A += t.name), t.internalSubset && (A += t.internalSubset), t.publicId && (A += '"' + t.publicId + '"'), t.systemId && (A += '"' + t.systemId + '"'), A += ">"), A;
}, Ql = function(t, A, e) {
  t && t.defaultView && (A !== t.defaultView.pageXOffset || e !== t.defaultView.pageYOffset) && t.defaultView.scrollTo(A, e);
}, hl = function(t) {
  var A = t[0], e = t[1], r = t[2];
  A.scrollLeft = e, A.scrollTop = r;
}, Cl = ":before", dl = ":after", Ur = "___html2canvas___pseudoelement_before", Fr = "___html2canvas___pseudoelement_after", Ds = `{
    content: "" !important;
    display: none !important;
}`, Ul = function(t) {
  Fl(t, "." + Ur + Cl + Ds + `
         .` + Fr + dl + Ds);
}, Fl = function(t, A) {
  var e = t.ownerDocument;
  if (e) {
    var r = e.createElement("style");
    r.textContent = A, t.appendChild(r);
  }
}, Jn = (
  /** @class */
  function() {
    function t() {
    }
    return t.getOrigin = function(A) {
      var e = t._link;
      return e ? (e.href = A, e.href = e.href, e.protocol + e.hostname + e.port) : "about:blank";
    }, t.isSameOrigin = function(A) {
      return t.getOrigin(A) === t._origin;
    }, t.setContext = function(A) {
      t._link = A.document.createElement("a"), t._origin = t.getOrigin(A.location.href);
    }, t._origin = "about:blank", t;
  }()
), pl = (
  /** @class */
  function() {
    function t(A, e) {
      this.context = A, this._options = e, this._cache = {};
    }
    return t.prototype.addImage = function(A) {
      var e = Promise.resolve();
      return this.has(A) || (jt(A) || ml(A)) && (this._cache[A] = this.loadImage(A)).catch(function() {
      }), e;
    }, t.prototype.match = function(A) {
      return this._cache[A];
    }, t.prototype.loadImage = function(A) {
      return AA(this, void 0, void 0, function() {
        var e, r, s, n, i = this;
        return $(this, function(a) {
          switch (a.label) {
            case 0:
              return e = Jn.isSameOrigin(A), r = !$t(A) && this._options.useCORS === !0 && Z.SUPPORT_CORS_IMAGES && !e, s = !$t(A) && !e && !jt(A) && typeof this._options.proxy == "string" && Z.SUPPORT_CORS_XHR && !r, !e && this._options.allowTaint === !1 && !$t(A) && !jt(A) && !s && !r ? [
                2
                /*return*/
              ] : (n = A, s ? [4, this.proxy(n)] : [3, 2]);
            case 1:
              n = a.sent(), a.label = 2;
            case 2:
              return this.context.logger.debug("Added image " + A.substring(0, 256)), [4, new Promise(function(B, o) {
                var c = new Image();
                c.onload = function() {
                  return B(c);
                }, c.onerror = o, (Il(n) || r) && (c.crossOrigin = "anonymous"), c.src = n, c.complete === !0 && setTimeout(function() {
                  return B(c);
                }, 500), i._options.imageTimeout > 0 && setTimeout(function() {
                  return o("Timed out (" + i._options.imageTimeout + "ms) loading image");
                }, i._options.imageTimeout);
              })];
            case 3:
              return [2, a.sent()];
          }
        });
      });
    }, t.prototype.has = function(A) {
      return typeof this._cache[A] < "u";
    }, t.prototype.keys = function() {
      return Promise.resolve(Object.keys(this._cache));
    }, t.prototype.proxy = function(A) {
      var e = this, r = this._options.proxy;
      if (!r)
        throw new Error("No proxy defined");
      var s = A.substring(0, 256);
      return new Promise(function(n, i) {
        var a = Z.SUPPORT_RESPONSE_TYPE ? "blob" : "text", B = new XMLHttpRequest();
        B.onload = function() {
          if (B.status === 200)
            if (a === "text")
              n(B.response);
            else {
              var l = new FileReader();
              l.addEventListener("load", function() {
                return n(l.result);
              }, !1), l.addEventListener("error", function(u) {
                return i(u);
              }, !1), l.readAsDataURL(B.response);
            }
          else
            i("Failed to proxy resource " + s + " with status code " + B.status);
        }, B.onerror = i;
        var o = r.indexOf("?") > -1 ? "&" : "?";
        if (B.open("GET", "" + r + o + "url=" + encodeURIComponent(A) + "&responseType=" + a), a !== "text" && B instanceof XMLHttpRequest && (B.responseType = a), e._options.imageTimeout) {
          var c = e._options.imageTimeout;
          B.timeout = c, B.ontimeout = function() {
            return i("Timed out (" + c + "ms) proxying " + s);
          };
        }
        B.send();
      });
    }, t;
  }()
), El = /^data:image\/svg\+xml/i, vl = /^data:image\/.*;base64,/i, Hl = /^data:image\/.*/i, ml = function(t) {
  return Z.SUPPORT_SVG_DRAWING || !yl(t);
}, $t = function(t) {
  return Hl.test(t);
}, Il = function(t) {
  return vl.test(t);
}, jt = function(t) {
  return t.substr(0, 4) === "blob";
}, yl = function(t) {
  return t.substr(-3).toLowerCase() === "svg" || El.test(t);
}, U = (
  /** @class */
  function() {
    function t(A, e) {
      this.type = 0, this.x = A, this.y = e;
    }
    return t.prototype.add = function(A, e) {
      return new t(this.x + A, this.y + e);
    }, t;
  }()
), ee = function(t, A, e) {
  return new U(t.x + (A.x - t.x) * e, t.y + (A.y - t.y) * e);
}, je = (
  /** @class */
  function() {
    function t(A, e, r, s) {
      this.type = 1, this.start = A, this.startControl = e, this.endControl = r, this.end = s;
    }
    return t.prototype.subdivide = function(A, e) {
      var r = ee(this.start, this.startControl, A), s = ee(this.startControl, this.endControl, A), n = ee(this.endControl, this.end, A), i = ee(r, s, A), a = ee(s, n, A), B = ee(i, a, A);
      return e ? new t(this.start, r, i, B) : new t(B, a, n, this.end);
    }, t.prototype.add = function(A, e) {
      return new t(this.start.add(A, e), this.startControl.add(A, e), this.endControl.add(A, e), this.end.add(A, e));
    }, t.prototype.reverse = function() {
      return new t(this.end, this.endControl, this.startControl, this.start);
    }, t;
  }()
), BA = function(t) {
  return t.type === 1;
}, Ll = (
  /** @class */
  function() {
    function t(A) {
      var e = A.styles, r = A.bounds, s = de(e.borderTopLeftRadius, r.width, r.height), n = s[0], i = s[1], a = de(e.borderTopRightRadius, r.width, r.height), B = a[0], o = a[1], c = de(e.borderBottomRightRadius, r.width, r.height), l = c[0], u = c[1], f = de(e.borderBottomLeftRadius, r.width, r.height), g = f[0], h = f[1], F = [];
      F.push((n + B) / r.width), F.push((g + l) / r.width), F.push((i + h) / r.height), F.push((o + u) / r.height);
      var w = Math.max.apply(Math, F);
      w > 1 && (n /= w, i /= w, B /= w, o /= w, l /= w, u /= w, g /= w, h /= w);
      var Q = r.width - B, E = r.height - u, v = r.width - l, H = r.height - h, d = e.borderTopWidth, L = e.borderRightWidth, b = e.borderBottomWidth, C = e.borderLeftWidth, m = R(e.paddingTop, A.bounds.width), y = R(e.paddingRight, A.bounds.width), K = R(e.paddingBottom, A.bounds.width), I = R(e.paddingLeft, A.bounds.width);
      this.topLeftBorderDoubleOuterBox = n > 0 || i > 0 ? N(r.left + C / 3, r.top + d / 3, n - C / 3, i - d / 3, T.TOP_LEFT) : new U(r.left + C / 3, r.top + d / 3), this.topRightBorderDoubleOuterBox = n > 0 || i > 0 ? N(r.left + Q, r.top + d / 3, B - L / 3, o - d / 3, T.TOP_RIGHT) : new U(r.left + r.width - L / 3, r.top + d / 3), this.bottomRightBorderDoubleOuterBox = l > 0 || u > 0 ? N(r.left + v, r.top + E, l - L / 3, u - b / 3, T.BOTTOM_RIGHT) : new U(r.left + r.width - L / 3, r.top + r.height - b / 3), this.bottomLeftBorderDoubleOuterBox = g > 0 || h > 0 ? N(r.left + C / 3, r.top + H, g - C / 3, h - b / 3, T.BOTTOM_LEFT) : new U(r.left + C / 3, r.top + r.height - b / 3), this.topLeftBorderDoubleInnerBox = n > 0 || i > 0 ? N(r.left + C * 2 / 3, r.top + d * 2 / 3, n - C * 2 / 3, i - d * 2 / 3, T.TOP_LEFT) : new U(r.left + C * 2 / 3, r.top + d * 2 / 3), this.topRightBorderDoubleInnerBox = n > 0 || i > 0 ? N(r.left + Q, r.top + d * 2 / 3, B - L * 2 / 3, o - d * 2 / 3, T.TOP_RIGHT) : new U(r.left + r.width - L * 2 / 3, r.top + d * 2 / 3), this.bottomRightBorderDoubleInnerBox = l > 0 || u > 0 ? N(r.left + v, r.top + E, l - L * 2 / 3, u - b * 2 / 3, T.BOTTOM_RIGHT) : new U(r.left + r.width - L * 2 / 3, r.top + r.height - b * 2 / 3), this.bottomLeftBorderDoubleInnerBox = g > 0 || h > 0 ? N(r.left + C * 2 / 3, r.top + H, g - C * 2 / 3, h - b * 2 / 3, T.BOTTOM_LEFT) : new U(r.left + C * 2 / 3, r.top + r.height - b * 2 / 3), this.topLeftBorderStroke = n > 0 || i > 0 ? N(r.left + C / 2, r.top + d / 2, n - C / 2, i - d / 2, T.TOP_LEFT) : new U(r.left + C / 2, r.top + d / 2), this.topRightBorderStroke = n > 0 || i > 0 ? N(r.left + Q, r.top + d / 2, B - L / 2, o - d / 2, T.TOP_RIGHT) : new U(r.left + r.width - L / 2, r.top + d / 2), this.bottomRightBorderStroke = l > 0 || u > 0 ? N(r.left + v, r.top + E, l - L / 2, u - b / 2, T.BOTTOM_RIGHT) : new U(r.left + r.width - L / 2, r.top + r.height - b / 2), this.bottomLeftBorderStroke = g > 0 || h > 0 ? N(r.left + C / 2, r.top + H, g - C / 2, h - b / 2, T.BOTTOM_LEFT) : new U(r.left + C / 2, r.top + r.height - b / 2), this.topLeftBorderBox = n > 0 || i > 0 ? N(r.left, r.top, n, i, T.TOP_LEFT) : new U(r.left, r.top), this.topRightBorderBox = B > 0 || o > 0 ? N(r.left + Q, r.top, B, o, T.TOP_RIGHT) : new U(r.left + r.width, r.top), this.bottomRightBorderBox = l > 0 || u > 0 ? N(r.left + v, r.top + E, l, u, T.BOTTOM_RIGHT) : new U(r.left + r.width, r.top + r.height), this.bottomLeftBorderBox = g > 0 || h > 0 ? N(r.left, r.top + H, g, h, T.BOTTOM_LEFT) : new U(r.left, r.top + r.height), this.topLeftPaddingBox = n > 0 || i > 0 ? N(r.left + C, r.top + d, Math.max(0, n - C), Math.max(0, i - d), T.TOP_LEFT) : new U(r.left + C, r.top + d), this.topRightPaddingBox = B > 0 || o > 0 ? N(r.left + Math.min(Q, r.width - L), r.top + d, Q > r.width + L ? 0 : Math.max(0, B - L), Math.max(0, o - d), T.TOP_RIGHT) : new U(r.left + r.width - L, r.top + d), this.bottomRightPaddingBox = l > 0 || u > 0 ? N(r.left + Math.min(v, r.width - C), r.top + Math.min(E, r.height - b), Math.max(0, l - L), Math.max(0, u - b), T.BOTTOM_RIGHT) : new U(r.left + r.width - L, r.top + r.height - b), this.bottomLeftPaddingBox = g > 0 || h > 0 ? N(r.left + C, r.top + Math.min(H, r.height - b), Math.max(0, g - C), Math.max(0, h - b), T.BOTTOM_LEFT) : new U(r.left + C, r.top + r.height - b), this.topLeftContentBox = n > 0 || i > 0 ? N(r.left + C + I, r.top + d + m, Math.max(0, n - (C + I)), Math.max(0, i - (d + m)), T.TOP_LEFT) : new U(r.left + C + I, r.top + d + m), this.topRightContentBox = B > 0 || o > 0 ? N(r.left + Math.min(Q, r.width + C + I), r.top + d + m, Q > r.width + C + I ? 0 : B - C + I, o - (d + m), T.TOP_RIGHT) : new U(r.left + r.width - (L + y), r.top + d + m), this.bottomRightContentBox = l > 0 || u > 0 ? N(r.left + Math.min(v, r.width - (C + I)), r.top + Math.min(E, r.height + d + m), Math.max(0, l - (L + y)), u - (b + K), T.BOTTOM_RIGHT) : new U(r.left + r.width - (L + y), r.top + r.height - (b + K)), this.bottomLeftContentBox = g > 0 || h > 0 ? N(r.left + C + I, r.top + H, Math.max(0, g - (C + I)), h - (b + K), T.BOTTOM_LEFT) : new U(r.left + C + I, r.top + r.height - (b + K));
    }
    return t;
  }()
), T;
(function(t) {
  t[t.TOP_LEFT = 0] = "TOP_LEFT", t[t.TOP_RIGHT = 1] = "TOP_RIGHT", t[t.BOTTOM_RIGHT = 2] = "BOTTOM_RIGHT", t[t.BOTTOM_LEFT = 3] = "BOTTOM_LEFT";
})(T || (T = {}));
var N = function(t, A, e, r, s) {
  var n = 4 * ((Math.sqrt(2) - 1) / 3), i = e * n, a = r * n, B = t + e, o = A + r;
  switch (s) {
    case T.TOP_LEFT:
      return new je(new U(t, o), new U(t, o - a), new U(B - i, A), new U(B, A));
    case T.TOP_RIGHT:
      return new je(new U(t, A), new U(t + i, A), new U(B, o - a), new U(B, o));
    case T.BOTTOM_RIGHT:
      return new je(new U(B, A), new U(B, A + a), new U(t + i, o), new U(t, o));
    case T.BOTTOM_LEFT:
    default:
      return new je(new U(B, o), new U(B - i, o), new U(t, A + a), new U(t, A));
  }
}, wt = function(t) {
  return [t.topLeftBorderBox, t.topRightBorderBox, t.bottomRightBorderBox, t.bottomLeftBorderBox];
}, bl = function(t) {
  return [
    t.topLeftContentBox,
    t.topRightContentBox,
    t.bottomRightContentBox,
    t.bottomLeftContentBox
  ];
}, ft = function(t) {
  return [
    t.topLeftPaddingBox,
    t.topRightPaddingBox,
    t.bottomRightPaddingBox,
    t.bottomLeftPaddingBox
  ];
}, Kl = (
  /** @class */
  function() {
    function t(A, e, r) {
      this.offsetX = A, this.offsetY = e, this.matrix = r, this.type = 0, this.target = 6;
    }
    return t;
  }()
), qe = (
  /** @class */
  function() {
    function t(A, e) {
      this.path = A, this.target = e, this.type = 1;
    }
    return t;
  }()
), Dl = (
  /** @class */
  function() {
    function t(A) {
      this.opacity = A, this.type = 2, this.target = 6;
    }
    return t;
  }()
), Sl = function(t) {
  return t.type === 0;
}, Wn = function(t) {
  return t.type === 1;
}, Tl = function(t) {
  return t.type === 2;
}, Ss = function(t, A) {
  return t.length === A.length ? t.some(function(e, r) {
    return e === A[r];
  }) : !1;
}, xl = function(t, A, e, r, s) {
  return t.map(function(n, i) {
    switch (i) {
      case 0:
        return n.add(A, e);
      case 1:
        return n.add(A + r, e);
      case 2:
        return n.add(A + r, e + s);
      case 3:
        return n.add(A, e + s);
    }
    return n;
  });
}, Yn = (
  /** @class */
  function() {
    function t(A) {
      this.element = A, this.inlineLevel = [], this.nonInlineLevel = [], this.negativeZIndex = [], this.zeroOrAutoZIndexOrTransformedOrOpacity = [], this.positiveZIndex = [], this.nonPositionedFloats = [], this.nonPositionedInlineLevel = [];
    }
    return t;
  }()
), Zn = (
  /** @class */
  function() {
    function t(A, e) {
      if (this.container = A, this.parent = e, this.effects = [], this.curves = new Ll(this.container), this.container.styles.opacity < 1 && this.effects.push(new Dl(this.container.styles.opacity)), this.container.styles.transform !== null) {
        var r = this.container.bounds.left + this.container.styles.transformOrigin[0].number, s = this.container.bounds.top + this.container.styles.transformOrigin[1].number, n = this.container.styles.transform;
        this.effects.push(new Kl(r, s, n));
      }
      if (this.container.styles.overflowX !== 0) {
        var i = wt(this.curves), a = ft(this.curves);
        Ss(i, a) ? this.effects.push(new qe(
          i,
          6
          /* CONTENT */
        )) : (this.effects.push(new qe(
          i,
          2
          /* BACKGROUND_BORDERS */
        )), this.effects.push(new qe(
          a,
          4
          /* CONTENT */
        )));
      }
    }
    return t.prototype.getEffects = function(A) {
      for (var e = [
        2,
        3
        /* FIXED */
      ].indexOf(this.container.styles.position) === -1, r = this.parent, s = this.effects.slice(0); r; ) {
        var n = r.effects.filter(function(B) {
          return !Wn(B);
        });
        if (e || r.container.styles.position !== 0 || !r.parent) {
          if (s.unshift.apply(s, n), e = [
            2,
            3
            /* FIXED */
          ].indexOf(r.container.styles.position) === -1, r.container.styles.overflowX !== 0) {
            var i = wt(r.curves), a = ft(r.curves);
            Ss(i, a) || s.unshift(new qe(
              a,
              6
              /* CONTENT */
            ));
          }
        } else
          s.unshift.apply(s, n);
        r = r.parent;
      }
      return s.filter(function(B) {
        return X(B.target, A);
      });
    }, t;
  }()
), pr = function(t, A, e, r) {
  t.container.elements.forEach(function(s) {
    var n = X(
      s.flags,
      4
      /* CREATES_REAL_STACKING_CONTEXT */
    ), i = X(
      s.flags,
      2
      /* CREATES_STACKING_CONTEXT */
    ), a = new Zn(s, t);
    X(
      s.styles.display,
      2048
      /* LIST_ITEM */
    ) && r.push(a);
    var B = X(
      s.flags,
      8
      /* IS_LIST_OWNER */
    ) ? [] : r;
    if (n || i) {
      var o = n || s.styles.isPositioned() ? e : A, c = new Yn(a);
      if (s.styles.isPositioned() || s.styles.opacity < 1 || s.styles.isTransformed()) {
        var l = s.styles.zIndex.order;
        if (l < 0) {
          var u = 0;
          o.negativeZIndex.some(function(g, h) {
            return l > g.element.container.styles.zIndex.order ? (u = h, !1) : u > 0;
          }), o.negativeZIndex.splice(u, 0, c);
        } else if (l > 0) {
          var f = 0;
          o.positiveZIndex.some(function(g, h) {
            return l >= g.element.container.styles.zIndex.order ? (f = h + 1, !1) : f > 0;
          }), o.positiveZIndex.splice(f, 0, c);
        } else
          o.zeroOrAutoZIndexOrTransformedOrOpacity.push(c);
      } else
        s.styles.isFloating() ? o.nonPositionedFloats.push(c) : o.nonPositionedInlineLevel.push(c);
      pr(a, c, n ? c : e, B);
    } else
      s.styles.isInlineLevel() ? A.inlineLevel.push(a) : A.nonInlineLevel.push(a), pr(a, A, e, B);
    X(
      s.flags,
      8
      /* IS_LIST_OWNER */
    ) && zn(s, B);
  });
}, zn = function(t, A) {
  for (var e = t instanceof hr ? t.start : 1, r = t instanceof hr ? t.reversed : !1, s = 0; s < A.length; s++) {
    var n = A[s];
    n.container instanceof Sn && typeof n.container.value == "number" && n.container.value !== 0 && (e = n.container.value), n.listValue = be(e, n.container.styles.listStyleType, !0), e += r ? -1 : 1;
  }
}, Ml = function(t) {
  var A = new Zn(t, null), e = new Yn(A), r = [];
  return pr(A, e, e, r), zn(A.container, r), e;
}, Ts = function(t, A) {
  switch (A) {
    case 0:
      return cA(t.topLeftBorderBox, t.topLeftPaddingBox, t.topRightBorderBox, t.topRightPaddingBox);
    case 1:
      return cA(t.topRightBorderBox, t.topRightPaddingBox, t.bottomRightBorderBox, t.bottomRightPaddingBox);
    case 2:
      return cA(t.bottomRightBorderBox, t.bottomRightPaddingBox, t.bottomLeftBorderBox, t.bottomLeftPaddingBox);
    case 3:
    default:
      return cA(t.bottomLeftBorderBox, t.bottomLeftPaddingBox, t.topLeftBorderBox, t.topLeftPaddingBox);
  }
}, Ol = function(t, A) {
  switch (A) {
    case 0:
      return cA(t.topLeftBorderBox, t.topLeftBorderDoubleOuterBox, t.topRightBorderBox, t.topRightBorderDoubleOuterBox);
    case 1:
      return cA(t.topRightBorderBox, t.topRightBorderDoubleOuterBox, t.bottomRightBorderBox, t.bottomRightBorderDoubleOuterBox);
    case 2:
      return cA(t.bottomRightBorderBox, t.bottomRightBorderDoubleOuterBox, t.bottomLeftBorderBox, t.bottomLeftBorderDoubleOuterBox);
    case 3:
    default:
      return cA(t.bottomLeftBorderBox, t.bottomLeftBorderDoubleOuterBox, t.topLeftBorderBox, t.topLeftBorderDoubleOuterBox);
  }
}, Rl = function(t, A) {
  switch (A) {
    case 0:
      return cA(t.topLeftBorderDoubleInnerBox, t.topLeftPaddingBox, t.topRightBorderDoubleInnerBox, t.topRightPaddingBox);
    case 1:
      return cA(t.topRightBorderDoubleInnerBox, t.topRightPaddingBox, t.bottomRightBorderDoubleInnerBox, t.bottomRightPaddingBox);
    case 2:
      return cA(t.bottomRightBorderDoubleInnerBox, t.bottomRightPaddingBox, t.bottomLeftBorderDoubleInnerBox, t.bottomLeftPaddingBox);
    case 3:
    default:
      return cA(t.bottomLeftBorderDoubleInnerBox, t.bottomLeftPaddingBox, t.topLeftBorderDoubleInnerBox, t.topLeftPaddingBox);
  }
}, Gl = function(t, A) {
  switch (A) {
    case 0:
      return At(t.topLeftBorderStroke, t.topRightBorderStroke);
    case 1:
      return At(t.topRightBorderStroke, t.bottomRightBorderStroke);
    case 2:
      return At(t.bottomRightBorderStroke, t.bottomLeftBorderStroke);
    case 3:
    default:
      return At(t.bottomLeftBorderStroke, t.topLeftBorderStroke);
  }
}, At = function(t, A) {
  var e = [];
  return BA(t) ? e.push(t.subdivide(0.5, !1)) : e.push(t), BA(A) ? e.push(A.subdivide(0.5, !0)) : e.push(A), e;
}, cA = function(t, A, e, r) {
  var s = [];
  return BA(t) ? s.push(t.subdivide(0.5, !1)) : s.push(t), BA(e) ? s.push(e.subdivide(0.5, !0)) : s.push(e), BA(r) ? s.push(r.subdivide(0.5, !0).reverse()) : s.push(r), BA(A) ? s.push(A.subdivide(0.5, !1).reverse()) : s.push(A), s;
}, $n = function(t) {
  var A = t.bounds, e = t.styles;
  return A.add(e.borderLeftWidth, e.borderTopWidth, -(e.borderRightWidth + e.borderLeftWidth), -(e.borderTopWidth + e.borderBottomWidth));
}, Qt = function(t) {
  var A = t.styles, e = t.bounds, r = R(A.paddingLeft, e.width), s = R(A.paddingRight, e.width), n = R(A.paddingTop, e.width), i = R(A.paddingBottom, e.width);
  return e.add(r + A.borderLeftWidth, n + A.borderTopWidth, -(A.borderRightWidth + A.borderLeftWidth + r + s), -(A.borderTopWidth + A.borderBottomWidth + n + i));
}, Nl = function(t, A) {
  return t === 0 ? A.bounds : t === 2 ? Qt(A) : $n(A);
}, Vl = function(t, A) {
  return t === 0 ? A.bounds : t === 2 ? Qt(A) : $n(A);
}, qt = function(t, A, e) {
  var r = Nl(se(t.styles.backgroundOrigin, A), t), s = Vl(se(t.styles.backgroundClip, A), t), n = Pl(se(t.styles.backgroundSize, A), e, r), i = n[0], a = n[1], B = de(se(t.styles.backgroundPosition, A), r.width - i, r.height - a), o = kl(se(t.styles.backgroundRepeat, A), B, n, r, s), c = Math.round(r.left + B[0]), l = Math.round(r.top + B[1]);
  return [o, c, l, i, a];
}, te = function(t) {
  return M(t) && t.value === ie.AUTO;
}, et = function(t) {
  return typeof t == "number";
}, Pl = function(t, A, e) {
  var r = A[0], s = A[1], n = A[2], i = t[0], a = t[1];
  if (!i)
    return [0, 0];
  if (k(i) && a && k(a))
    return [R(i, e.width), R(a, e.height)];
  var B = et(n);
  if (M(i) && (i.value === ie.CONTAIN || i.value === ie.COVER)) {
    if (et(n)) {
      var o = e.width / e.height;
      return o < n != (i.value === ie.COVER) ? [e.width, e.width / n] : [e.height * n, e.height];
    }
    return [e.width, e.height];
  }
  var c = et(r), l = et(s), u = c || l;
  if (te(i) && (!a || te(a))) {
    if (c && l)
      return [r, s];
    if (!B && !u)
      return [e.width, e.height];
    if (u && B) {
      var f = c ? r : s * n, g = l ? s : r / n;
      return [f, g];
    }
    var h = c ? r : e.width, F = l ? s : e.height;
    return [h, F];
  }
  if (B) {
    var w = 0, Q = 0;
    return k(i) ? w = R(i, e.width) : k(a) && (Q = R(a, e.height)), te(i) ? w = Q * n : (!a || te(a)) && (Q = w / n), [w, Q];
  }
  var E = null, v = null;
  if (k(i) ? E = R(i, e.width) : a && k(a) && (v = R(a, e.height)), E !== null && (!a || te(a)) && (v = c && l ? E / r * s : e.height), v !== null && te(i) && (E = c && l ? v / s * r : e.width), E !== null && v !== null)
    return [E, v];
  throw new Error("Unable to calculate background-size for element");
}, se = function(t, A) {
  var e = t[A];
  return typeof e > "u" ? t[0] : e;
}, kl = function(t, A, e, r, s) {
  var n = A[0], i = A[1], a = e[0], B = e[1];
  switch (t) {
    case 2:
      return [
        new U(Math.round(r.left), Math.round(r.top + i)),
        new U(Math.round(r.left + r.width), Math.round(r.top + i)),
        new U(Math.round(r.left + r.width), Math.round(B + r.top + i)),
        new U(Math.round(r.left), Math.round(B + r.top + i))
      ];
    case 3:
      return [
        new U(Math.round(r.left + n), Math.round(r.top)),
        new U(Math.round(r.left + n + a), Math.round(r.top)),
        new U(Math.round(r.left + n + a), Math.round(r.height + r.top)),
        new U(Math.round(r.left + n), Math.round(r.height + r.top))
      ];
    case 1:
      return [
        new U(Math.round(r.left + n), Math.round(r.top + i)),
        new U(Math.round(r.left + n + a), Math.round(r.top + i)),
        new U(Math.round(r.left + n + a), Math.round(r.top + i + B)),
        new U(Math.round(r.left + n), Math.round(r.top + i + B))
      ];
    default:
      return [
        new U(Math.round(s.left), Math.round(s.top)),
        new U(Math.round(s.left + s.width), Math.round(s.top)),
        new U(Math.round(s.left + s.width), Math.round(s.height + s.top)),
        new U(Math.round(s.left), Math.round(s.height + s.top))
      ];
  }
}, _l = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7", xs = "Hidden Text", Xl = (
  /** @class */
  function() {
    function t(A) {
      this._data = {}, this._document = A;
    }
    return t.prototype.parseMetrics = function(A, e) {
      var r = this._document.createElement("div"), s = this._document.createElement("img"), n = this._document.createElement("span"), i = this._document.body;
      r.style.visibility = "hidden", r.style.fontFamily = A, r.style.fontSize = e, r.style.margin = "0", r.style.padding = "0", r.style.whiteSpace = "nowrap", i.appendChild(r), s.src = _l, s.width = 1, s.height = 1, s.style.margin = "0", s.style.padding = "0", s.style.verticalAlign = "baseline", n.style.fontFamily = A, n.style.fontSize = e, n.style.margin = "0", n.style.padding = "0", n.appendChild(this._document.createTextNode(xs)), r.appendChild(n), r.appendChild(s);
      var a = s.offsetTop - n.offsetTop + 2;
      r.removeChild(n), r.appendChild(this._document.createTextNode(xs)), r.style.lineHeight = "normal", s.style.verticalAlign = "super";
      var B = s.offsetTop - r.offsetTop + 2;
      return i.removeChild(r), { baseline: a, middle: B };
    }, t.prototype.getMetrics = function(A, e) {
      var r = A + " " + e;
      return typeof this._data[r] > "u" && (this._data[r] = this.parseMetrics(A, e)), this._data[r];
    }, t;
  }()
), jn = (
  /** @class */
  function() {
    function t(A, e) {
      this.context = A, this.options = e;
    }
    return t;
  }()
), Jl = 1e4, Wl = (
  /** @class */
  function(t) {
    gA(A, t);
    function A(e, r) {
      var s = t.call(this, e, r) || this;
      return s._activeEffects = [], s.canvas = r.canvas ? r.canvas : document.createElement("canvas"), s.ctx = s.canvas.getContext("2d"), r.canvas || (s.canvas.width = Math.floor(r.width * r.scale), s.canvas.height = Math.floor(r.height * r.scale), s.canvas.style.width = r.width + "px", s.canvas.style.height = r.height + "px"), s.fontMetrics = new Xl(document), s.ctx.scale(s.options.scale, s.options.scale), s.ctx.translate(-r.x, -r.y), s.ctx.textBaseline = "bottom", s._activeEffects = [], s.context.logger.debug("Canvas renderer initialized (" + r.width + "x" + r.height + ") with scale " + r.scale), s;
    }
    return A.prototype.applyEffects = function(e) {
      for (var r = this; this._activeEffects.length; )
        this.popEffect();
      e.forEach(function(s) {
        return r.applyEffect(s);
      });
    }, A.prototype.applyEffect = function(e) {
      this.ctx.save(), Tl(e) && (this.ctx.globalAlpha = e.opacity), Sl(e) && (this.ctx.translate(e.offsetX, e.offsetY), this.ctx.transform(e.matrix[0], e.matrix[1], e.matrix[2], e.matrix[3], e.matrix[4], e.matrix[5]), this.ctx.translate(-e.offsetX, -e.offsetY)), Wn(e) && (this.path(e.path), this.ctx.clip()), this._activeEffects.push(e);
    }, A.prototype.popEffect = function() {
      this._activeEffects.pop(), this.ctx.restore();
    }, A.prototype.renderStack = function(e) {
      return AA(this, void 0, void 0, function() {
        var r;
        return $(this, function(s) {
          switch (s.label) {
            case 0:
              return r = e.element.container.styles, r.isVisible() ? [4, this.renderStackContent(e)] : [3, 2];
            case 1:
              s.sent(), s.label = 2;
            case 2:
              return [
                2
                /*return*/
              ];
          }
        });
      });
    }, A.prototype.renderNode = function(e) {
      return AA(this, void 0, void 0, function() {
        return $(this, function(r) {
          switch (r.label) {
            case 0:
              if (X(
                e.container.flags,
                16
                /* DEBUG_RENDER */
              ))
                debugger;
              return e.container.styles.isVisible() ? [4, this.renderNodeBackgroundAndBorders(e)] : [3, 3];
            case 1:
              return r.sent(), [4, this.renderNodeContent(e)];
            case 2:
              r.sent(), r.label = 3;
            case 3:
              return [
                2
                /*return*/
              ];
          }
        });
      });
    }, A.prototype.renderTextWithLetterSpacing = function(e, r, s) {
      var n = this;
      if (r === 0)
        this.ctx.fillText(e.text, e.bounds.left, e.bounds.top + s);
      else {
        var i = Kr(e.text);
        i.reduce(function(a, B) {
          return n.ctx.fillText(B, a, e.bounds.top + s), a + n.ctx.measureText(B).width;
        }, e.bounds.left);
      }
    }, A.prototype.createFontStyle = function(e) {
      var r = e.fontVariant.filter(function(i) {
        return i === "normal" || i === "small-caps";
      }).join(""), s = jl(e.fontFamily).join(", "), n = De(e.fontSize) ? "" + e.fontSize.number + e.fontSize.unit : e.fontSize.number + "px";
      return [
        [e.fontStyle, r, e.fontWeight, n, s].join(" "),
        s,
        n
      ];
    }, A.prototype.renderTextNode = function(e, r) {
      return AA(this, void 0, void 0, function() {
        var s, n, i, a, B, o, c, l, u = this;
        return $(this, function(f) {
          return s = this.createFontStyle(r), n = s[0], i = s[1], a = s[2], this.ctx.font = n, this.ctx.direction = r.direction === 1 ? "rtl" : "ltr", this.ctx.textAlign = "left", this.ctx.textBaseline = "alphabetic", B = this.fontMetrics.getMetrics(i, a), o = B.baseline, c = B.middle, l = r.paintOrder, e.textBounds.forEach(function(g) {
            l.forEach(function(h) {
              switch (h) {
                case 0:
                  u.ctx.fillStyle = W(r.color), u.renderTextWithLetterSpacing(g, r.letterSpacing, o);
                  var F = r.textShadow;
                  F.length && g.text.trim().length && (F.slice(0).reverse().forEach(function(w) {
                    u.ctx.shadowColor = W(w.color), u.ctx.shadowOffsetX = w.offsetX.number * u.options.scale, u.ctx.shadowOffsetY = w.offsetY.number * u.options.scale, u.ctx.shadowBlur = w.blur.number, u.renderTextWithLetterSpacing(g, r.letterSpacing, o);
                  }), u.ctx.shadowColor = "", u.ctx.shadowOffsetX = 0, u.ctx.shadowOffsetY = 0, u.ctx.shadowBlur = 0), r.textDecorationLine.length && (u.ctx.fillStyle = W(r.textDecorationColor || r.color), r.textDecorationLine.forEach(function(w) {
                    switch (w) {
                      case 1:
                        u.ctx.fillRect(g.bounds.left, Math.round(g.bounds.top + o), g.bounds.width, 1);
                        break;
                      case 2:
                        u.ctx.fillRect(g.bounds.left, Math.round(g.bounds.top), g.bounds.width, 1);
                        break;
                      case 3:
                        u.ctx.fillRect(g.bounds.left, Math.ceil(g.bounds.top + c), g.bounds.width, 1);
                        break;
                    }
                  }));
                  break;
                case 1:
                  r.webkitTextStrokeWidth && g.text.trim().length && (u.ctx.strokeStyle = W(r.webkitTextStrokeColor), u.ctx.lineWidth = r.webkitTextStrokeWidth, u.ctx.lineJoin = window.chrome ? "miter" : "round", u.ctx.strokeText(g.text, g.bounds.left, g.bounds.top + o)), u.ctx.strokeStyle = "", u.ctx.lineWidth = 0, u.ctx.lineJoin = "miter";
                  break;
              }
            });
          }), [
            2
            /*return*/
          ];
        });
      });
    }, A.prototype.renderReplacedElement = function(e, r, s) {
      if (s && e.intrinsicWidth > 0 && e.intrinsicHeight > 0) {
        var n = Qt(e), i = ft(r);
        this.path(i), this.ctx.save(), this.ctx.clip(), this.ctx.drawImage(s, 0, 0, e.intrinsicWidth, e.intrinsicHeight, n.left, n.top, n.width, n.height), this.ctx.restore();
      }
    }, A.prototype.renderNodeContent = function(e) {
      return AA(this, void 0, void 0, function() {
        var r, s, n, i, a, B, Q, Q, o, c, l, u, v, f, g, H, h, F, w, Q, E, v, H;
        return $(this, function(d) {
          switch (d.label) {
            case 0:
              this.applyEffects(e.getEffects(
                4
                /* CONTENT */
              )), r = e.container, s = e.curves, n = r.styles, i = 0, a = r.textNodes, d.label = 1;
            case 1:
              return i < a.length ? (B = a[i], [4, this.renderTextNode(B, n)]) : [3, 4];
            case 2:
              d.sent(), d.label = 3;
            case 3:
              return i++, [3, 1];
            case 4:
              if (!(r instanceof bn))
                return [3, 8];
              d.label = 5;
            case 5:
              return d.trys.push([5, 7, , 8]), [4, this.context.cache.match(r.src)];
            case 6:
              return Q = d.sent(), this.renderReplacedElement(r, s, Q), [3, 8];
            case 7:
              return d.sent(), this.context.logger.error("Error loading image " + r.src), [3, 8];
            case 8:
              if (r instanceof Kn && this.renderReplacedElement(r, s, r.canvas), !(r instanceof Dn))
                return [3, 12];
              d.label = 9;
            case 9:
              return d.trys.push([9, 11, , 12]), [4, this.context.cache.match(r.svg)];
            case 10:
              return Q = d.sent(), this.renderReplacedElement(r, s, Q), [3, 12];
            case 11:
              return d.sent(), this.context.logger.error("Error loading svg " + r.svg.substring(0, 255)), [3, 12];
            case 12:
              return r instanceof Mn && r.tree ? (o = new A(this.context, {
                scale: this.options.scale,
                backgroundColor: r.backgroundColor,
                x: 0,
                y: 0,
                width: r.width,
                height: r.height
              }), [4, o.render(r.tree)]) : [3, 14];
            case 13:
              c = d.sent(), r.width && r.height && this.ctx.drawImage(c, 0, 0, r.width, r.height, r.bounds.left, r.bounds.top, r.bounds.width, r.bounds.height), d.label = 14;
            case 14:
              if (r instanceof Dr && (l = Math.min(r.bounds.width, r.bounds.height), r.type === ct ? r.checked && (this.ctx.save(), this.path([
                new U(r.bounds.left + l * 0.39363, r.bounds.top + l * 0.79),
                new U(r.bounds.left + l * 0.16, r.bounds.top + l * 0.5549),
                new U(r.bounds.left + l * 0.27347, r.bounds.top + l * 0.44071),
                new U(r.bounds.left + l * 0.39694, r.bounds.top + l * 0.5649),
                new U(r.bounds.left + l * 0.72983, r.bounds.top + l * 0.23),
                new U(r.bounds.left + l * 0.84, r.bounds.top + l * 0.34085),
                new U(r.bounds.left + l * 0.39363, r.bounds.top + l * 0.79)
              ]), this.ctx.fillStyle = W(ps), this.ctx.fill(), this.ctx.restore()) : r.type === lt && r.checked && (this.ctx.save(), this.ctx.beginPath(), this.ctx.arc(r.bounds.left + l / 2, r.bounds.top + l / 2, l / 4, 0, Math.PI * 2, !0), this.ctx.fillStyle = W(ps), this.ctx.fill(), this.ctx.restore())), Yl(r) && r.value.length) {
                switch (u = this.createFontStyle(n), v = u[0], f = u[1], g = this.fontMetrics.getMetrics(v, f).baseline, this.ctx.font = v, this.ctx.fillStyle = W(n.color), this.ctx.textBaseline = "alphabetic", this.ctx.textAlign = zl(r.styles.textAlign), H = Qt(r), h = 0, r.styles.textAlign) {
                  case 1:
                    h += H.width / 2;
                    break;
                  case 2:
                    h += H.width;
                    break;
                }
                F = H.add(h, 0, 0, -H.height / 2 + 1), this.ctx.save(), this.path([
                  new U(H.left, H.top),
                  new U(H.left + H.width, H.top),
                  new U(H.left + H.width, H.top + H.height),
                  new U(H.left, H.top + H.height)
                ]), this.ctx.clip(), this.renderTextWithLetterSpacing(new me(r.value, F), n.letterSpacing, g), this.ctx.restore(), this.ctx.textBaseline = "alphabetic", this.ctx.textAlign = "left";
              }
              if (!X(
                r.styles.display,
                2048
                /* LIST_ITEM */
              ))
                return [3, 20];
              if (r.styles.listStyleImage === null)
                return [3, 19];
              if (w = r.styles.listStyleImage, w.type !== 0)
                return [3, 18];
              Q = void 0, E = w.url, d.label = 15;
            case 15:
              return d.trys.push([15, 17, , 18]), [4, this.context.cache.match(E)];
            case 16:
              return Q = d.sent(), this.ctx.drawImage(Q, r.bounds.left - (Q.width + 10), r.bounds.top), [3, 18];
            case 17:
              return d.sent(), this.context.logger.error("Error loading list-style-image " + E), [3, 18];
            case 18:
              return [3, 20];
            case 19:
              e.listValue && r.styles.listStyleType !== -1 && (v = this.createFontStyle(n)[0], this.ctx.font = v, this.ctx.fillStyle = W(n.color), this.ctx.textBaseline = "middle", this.ctx.textAlign = "right", H = new IA(r.bounds.left, r.bounds.top + R(r.styles.paddingTop, r.bounds.width), r.bounds.width, ns(n.lineHeight, n.fontSize.number) / 2 + 1), this.renderTextWithLetterSpacing(new me(e.listValue, H), n.letterSpacing, ns(n.lineHeight, n.fontSize.number) / 2 + 2), this.ctx.textBaseline = "bottom", this.ctx.textAlign = "left"), d.label = 20;
            case 20:
              return [
                2
                /*return*/
              ];
          }
        });
      });
    }, A.prototype.renderStackContent = function(e) {
      return AA(this, void 0, void 0, function() {
        var r, s, w, n, i, w, a, B, w, o, c, w, l, u, w, f, g, w, h, F, w;
        return $(this, function(Q) {
          switch (Q.label) {
            case 0:
              if (X(
                e.element.container.flags,
                16
                /* DEBUG_RENDER */
              ))
                debugger;
              return [4, this.renderNodeBackgroundAndBorders(e.element)];
            case 1:
              Q.sent(), r = 0, s = e.negativeZIndex, Q.label = 2;
            case 2:
              return r < s.length ? (w = s[r], [4, this.renderStack(w)]) : [3, 5];
            case 3:
              Q.sent(), Q.label = 4;
            case 4:
              return r++, [3, 2];
            case 5:
              return [4, this.renderNodeContent(e.element)];
            case 6:
              Q.sent(), n = 0, i = e.nonInlineLevel, Q.label = 7;
            case 7:
              return n < i.length ? (w = i[n], [4, this.renderNode(w)]) : [3, 10];
            case 8:
              Q.sent(), Q.label = 9;
            case 9:
              return n++, [3, 7];
            case 10:
              a = 0, B = e.nonPositionedFloats, Q.label = 11;
            case 11:
              return a < B.length ? (w = B[a], [4, this.renderStack(w)]) : [3, 14];
            case 12:
              Q.sent(), Q.label = 13;
            case 13:
              return a++, [3, 11];
            case 14:
              o = 0, c = e.nonPositionedInlineLevel, Q.label = 15;
            case 15:
              return o < c.length ? (w = c[o], [4, this.renderStack(w)]) : [3, 18];
            case 16:
              Q.sent(), Q.label = 17;
            case 17:
              return o++, [3, 15];
            case 18:
              l = 0, u = e.inlineLevel, Q.label = 19;
            case 19:
              return l < u.length ? (w = u[l], [4, this.renderNode(w)]) : [3, 22];
            case 20:
              Q.sent(), Q.label = 21;
            case 21:
              return l++, [3, 19];
            case 22:
              f = 0, g = e.zeroOrAutoZIndexOrTransformedOrOpacity, Q.label = 23;
            case 23:
              return f < g.length ? (w = g[f], [4, this.renderStack(w)]) : [3, 26];
            case 24:
              Q.sent(), Q.label = 25;
            case 25:
              return f++, [3, 23];
            case 26:
              h = 0, F = e.positiveZIndex, Q.label = 27;
            case 27:
              return h < F.length ? (w = F[h], [4, this.renderStack(w)]) : [3, 30];
            case 28:
              Q.sent(), Q.label = 29;
            case 29:
              return h++, [3, 27];
            case 30:
              return [
                2
                /*return*/
              ];
          }
        });
      });
    }, A.prototype.mask = function(e) {
      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(e.slice(0).reverse()), this.ctx.closePath();
    }, A.prototype.path = function(e) {
      this.ctx.beginPath(), this.formatPath(e), this.ctx.closePath();
    }, A.prototype.formatPath = function(e) {
      var r = this;
      e.forEach(function(s, n) {
        var i = BA(s) ? s.start : s;
        n === 0 ? r.ctx.moveTo(i.x, i.y) : r.ctx.lineTo(i.x, i.y), BA(s) && r.ctx.bezierCurveTo(s.startControl.x, s.startControl.y, s.endControl.x, s.endControl.y, s.end.x, s.end.y);
      });
    }, A.prototype.renderRepeat = function(e, r, s, n) {
      this.path(e), this.ctx.fillStyle = r, this.ctx.translate(s, n), this.ctx.fill(), this.ctx.translate(-s, -n);
    }, A.prototype.resizeImage = function(e, r, s) {
      var n;
      if (e.width === r && e.height === s)
        return e;
      var i = (n = this.canvas.ownerDocument) !== null && n !== void 0 ? n : document, a = i.createElement("canvas");
      a.width = Math.max(1, r), a.height = Math.max(1, s);
      var B = a.getContext("2d");
      return B.drawImage(e, 0, 0, e.width, e.height, 0, 0, r, s), a;
    }, A.prototype.renderBackgroundImage = function(e) {
      return AA(this, void 0, void 0, function() {
        var r, s, n, i, a, B;
        return $(this, function(o) {
          switch (o.label) {
            case 0:
              r = e.styles.backgroundImage.length - 1, s = function(c) {
                var l, u, f, m, _, Y, I, S, b, g, m, _, Y, I, S, h, F, w, Q, E, v, H, d, L, b, C, m, y, K, I, S, G, _, Y, LA, sA, nA, GA, NA, UA, VA, FA;
                return $(this, function(zA) {
                  switch (zA.label) {
                    case 0:
                      if (c.type !== 0)
                        return [3, 5];
                      l = void 0, u = c.url, zA.label = 1;
                    case 1:
                      return zA.trys.push([1, 3, , 4]), [4, n.context.cache.match(u)];
                    case 2:
                      return l = zA.sent(), [3, 4];
                    case 3:
                      return zA.sent(), n.context.logger.error("Error loading background-image " + u), [3, 4];
                    case 4:
                      return l && (f = qt(e, r, [
                        l.width,
                        l.height,
                        l.width / l.height
                      ]), m = f[0], _ = f[1], Y = f[2], I = f[3], S = f[4], b = n.ctx.createPattern(n.resizeImage(l, I, S), "repeat"), n.renderRepeat(m, b, _, Y)), [3, 6];
                    case 5:
                      DB(c) ? (g = qt(e, r, [null, null, null]), m = g[0], _ = g[1], Y = g[2], I = g[3], S = g[4], h = IB(c.angle, I, S), F = h[0], w = h[1], Q = h[2], E = h[3], v = h[4], H = document.createElement("canvas"), H.width = I, H.height = S, d = H.getContext("2d"), L = d.createLinearGradient(w, E, Q, v), rs(c.stops, F).forEach(function(oe) {
                        return L.addColorStop(oe.stop, W(oe.color));
                      }), d.fillStyle = L, d.fillRect(0, 0, I, S), I > 0 && S > 0 && (b = n.ctx.createPattern(H, "repeat"), n.renderRepeat(m, b, _, Y))) : SB(c) && (C = qt(e, r, [
                        null,
                        null,
                        null
                      ]), m = C[0], y = C[1], K = C[2], I = C[3], S = C[4], G = c.position.length === 0 ? [yr] : c.position, _ = R(G[0], I), Y = R(G[G.length - 1], S), LA = yB(c, _, Y, I, S), sA = LA[0], nA = LA[1], sA > 0 && nA > 0 && (GA = n.ctx.createRadialGradient(y + _, K + Y, 0, y + _, K + Y, sA), rs(c.stops, sA * 2).forEach(function(oe) {
                        return GA.addColorStop(oe.stop, W(oe.color));
                      }), n.path(m), n.ctx.fillStyle = GA, sA !== nA ? (NA = e.bounds.left + 0.5 * e.bounds.width, UA = e.bounds.top + 0.5 * e.bounds.height, VA = nA / sA, FA = 1 / VA, n.ctx.save(), n.ctx.translate(NA, UA), n.ctx.transform(1, 0, 0, VA, 0, 0), n.ctx.translate(-NA, -UA), n.ctx.fillRect(y, FA * (K - UA) + UA, I, S * FA), n.ctx.restore()) : n.ctx.fill())), zA.label = 6;
                    case 6:
                      return r--, [
                        2
                        /*return*/
                      ];
                  }
                });
              }, n = this, i = 0, a = e.styles.backgroundImage.slice(0).reverse(), o.label = 1;
            case 1:
              return i < a.length ? (B = a[i], [5, s(B)]) : [3, 4];
            case 2:
              o.sent(), o.label = 3;
            case 3:
              return i++, [3, 1];
            case 4:
              return [
                2
                /*return*/
              ];
          }
        });
      });
    }, A.prototype.renderSolidBorder = function(e, r, s) {
      return AA(this, void 0, void 0, function() {
        return $(this, function(n) {
          return this.path(Ts(s, r)), this.ctx.fillStyle = W(e), this.ctx.fill(), [
            2
            /*return*/
          ];
        });
      });
    }, A.prototype.renderDoubleBorder = function(e, r, s, n) {
      return AA(this, void 0, void 0, function() {
        var i, a;
        return $(this, function(B) {
          switch (B.label) {
            case 0:
              return r < 3 ? [4, this.renderSolidBorder(e, s, n)] : [3, 2];
            case 1:
              return B.sent(), [
                2
                /*return*/
              ];
            case 2:
              return i = Ol(n, s), this.path(i), this.ctx.fillStyle = W(e), this.ctx.fill(), a = Rl(n, s), this.path(a), this.ctx.fill(), [
                2
                /*return*/
              ];
          }
        });
      });
    }, A.prototype.renderNodeBackgroundAndBorders = function(e) {
      return AA(this, void 0, void 0, function() {
        var r, s, n, i, a, B, o, c, l = this;
        return $(this, function(u) {
          switch (u.label) {
            case 0:
              return this.applyEffects(e.getEffects(
                2
                /* BACKGROUND_BORDERS */
              )), r = e.container.styles, s = !OA(r.backgroundColor) || r.backgroundImage.length, n = [
                { style: r.borderTopStyle, color: r.borderTopColor, width: r.borderTopWidth },
                { style: r.borderRightStyle, color: r.borderRightColor, width: r.borderRightWidth },
                { style: r.borderBottomStyle, color: r.borderBottomColor, width: r.borderBottomWidth },
                { style: r.borderLeftStyle, color: r.borderLeftColor, width: r.borderLeftWidth }
              ], i = Zl(se(r.backgroundClip, 0), e.curves), s || r.boxShadow.length ? (this.ctx.save(), this.path(i), this.ctx.clip(), OA(r.backgroundColor) || (this.ctx.fillStyle = W(r.backgroundColor), this.ctx.fill()), [4, this.renderBackgroundImage(e.container)]) : [3, 2];
            case 1:
              u.sent(), this.ctx.restore(), r.boxShadow.slice(0).reverse().forEach(function(f) {
                l.ctx.save();
                var g = wt(e.curves), h = f.inset ? 0 : Jl, F = xl(g, -h + (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(F)) : (l.mask(g), l.ctx.clip(), l.path(F)), l.ctx.shadowOffsetX = f.offsetX.number + h, l.ctx.shadowOffsetY = f.offsetY.number, l.ctx.shadowColor = W(f.color), l.ctx.shadowBlur = f.blur.number, l.ctx.fillStyle = f.inset ? W(f.color) : "rgba(0,0,0,1)", l.ctx.fill(), l.ctx.restore();
              }), u.label = 2;
            case 2:
              a = 0, B = 0, o = n, u.label = 3;
            case 3:
              return B < o.length ? (c = o[B], c.style !== 0 && !OA(c.color) && c.width > 0 ? c.style !== 2 ? [3, 5] : [4, this.renderDashedDottedBorder(
                c.color,
                c.width,
                a,
                e.curves,
                2
                /* DASHED */
              )] : [3, 11]) : [3, 13];
            case 4:
              return u.sent(), [3, 11];
            case 5:
              return c.style !== 3 ? [3, 7] : [4, this.renderDashedDottedBorder(
                c.color,
                c.width,
                a,
                e.curves,
                3
                /* DOTTED */
              )];
            case 6:
              return u.sent(), [3, 11];
            case 7:
              return c.style !== 4 ? [3, 9] : [4, this.renderDoubleBorder(c.color, c.width, a, e.curves)];
            case 8:
              return u.sent(), [3, 11];
            case 9:
              return [4, this.renderSolidBorder(c.color, a, e.curves)];
            case 10:
              u.sent(), u.label = 11;
            case 11:
              a++, u.label = 12;
            case 12:
              return B++, [3, 3];
            case 13:
              return [
                2
                /*return*/
              ];
          }
        });
      });
    }, A.prototype.renderDashedDottedBorder = function(e, r, s, n, i) {
      return AA(this, void 0, void 0, function() {
        var a, B, o, c, l, u, f, g, h, F, w, Q, E, v, H, d, H, d;
        return $(this, function(L) {
          return this.ctx.save(), a = Gl(n, s), B = Ts(n, s), i === 2 && (this.path(B), this.ctx.clip()), BA(B[0]) ? (o = B[0].start.x, c = B[0].start.y) : (o = B[0].x, c = B[0].y), BA(B[1]) ? (l = B[1].end.x, u = B[1].end.y) : (l = B[1].x, u = B[1].y), s === 0 || s === 2 ? f = Math.abs(o - l) : f = Math.abs(c - u), this.ctx.beginPath(), i === 3 ? this.formatPath(a) : this.formatPath(B.slice(0, 2)), g = r < 3 ? r * 3 : r * 2, h = r < 3 ? r * 2 : r, i === 3 && (g = r, h = r), F = !0, f <= g * 2 ? F = !1 : f <= g * 2 + h ? (w = f / (2 * g + h), g *= w, h *= w) : (Q = Math.floor((f + h) / (g + h)), E = (f - Q * g) / (Q - 1), v = (f - (Q + 1) * g) / Q, h = v <= 0 || Math.abs(h - E) < Math.abs(h - v) ? E : v), F && (i === 3 ? this.ctx.setLineDash([0, g + h]) : this.ctx.setLineDash([g, h])), i === 3 ? (this.ctx.lineCap = "round", this.ctx.lineWidth = r) : this.ctx.lineWidth = r * 2 + 1.1, this.ctx.strokeStyle = W(e), this.ctx.stroke(), this.ctx.setLineDash([]), i === 2 && (BA(B[0]) && (H = B[3], d = B[0], this.ctx.beginPath(), this.formatPath([new U(H.end.x, H.end.y), new U(d.start.x, d.start.y)]), this.ctx.stroke()), BA(B[1]) && (H = B[1], d = B[2], this.ctx.beginPath(), this.formatPath([new U(H.end.x, H.end.y), new U(d.start.x, d.start.y)]), this.ctx.stroke())), this.ctx.restore(), [
            2
            /*return*/
          ];
        });
      });
    }, A.prototype.render = function(e) {
      return AA(this, void 0, void 0, function() {
        var r;
        return $(this, function(s) {
          switch (s.label) {
            case 0:
              return this.options.backgroundColor && (this.ctx.fillStyle = W(this.options.backgroundColor), this.ctx.fillRect(this.options.x, this.options.y, this.options.width, this.options.height)), r = Ml(e), [4, this.renderStack(r)];
            case 1:
              return s.sent(), this.applyEffects([]), [2, this.canvas];
          }
        });
      });
    }, A;
  }(jn)
), Yl = function(t) {
  return t instanceof xn || t instanceof Tn ? !0 : t instanceof Dr && t.type !== lt && t.type !== ct;
}, Zl = function(t, A) {
  switch (t) {
    case 0:
      return wt(A);
    case 2:
      return bl(A);
    case 1:
    default:
      return ft(A);
  }
}, zl = function(t) {
  switch (t) {
    case 1:
      return "center";
    case 2:
      return "right";
    case 0:
    default:
      return "left";
  }
}, $l = ["-apple-system", "system-ui"], jl = function(t) {
  return /iPhone OS 15_(0|1)/.test(window.navigator.userAgent) ? t.filter(function(A) {
    return $l.indexOf(A) === -1;
  }) : t;
}, ql = (
  /** @class */
  function(t) {
    gA(A, t);
    function A(e, r) {
      var s = t.call(this, e, r) || this;
      return s.canvas = r.canvas ? r.canvas : document.createElement("canvas"), s.ctx = s.canvas.getContext("2d"), s.options = r, s.canvas.width = Math.floor(r.width * r.scale), s.canvas.height = Math.floor(r.height * r.scale), s.canvas.style.width = r.width + "px", s.canvas.style.height = r.height + "px", s.ctx.scale(s.options.scale, s.options.scale), s.ctx.translate(-r.x, -r.y), s.context.logger.debug("EXPERIMENTAL ForeignObject renderer initialized (" + r.width + "x" + r.height + " at " + r.x + "," + r.y + ") with scale " + r.scale), s;
    }
    return A.prototype.render = function(e) {
      return AA(this, void 0, void 0, function() {
        var r, s;
        return $(this, function(n) {
          switch (n.label) {
            case 0:
              return r = Qr(this.options.width * this.options.scale, this.options.height * this.options.scale, this.options.scale, this.options.scale, e), [4, Au(r)];
            case 1:
              return s = n.sent(), this.options.backgroundColor && (this.ctx.fillStyle = W(this.options.backgroundColor), this.ctx.fillRect(0, 0, this.options.width * this.options.scale, this.options.height * this.options.scale)), this.ctx.drawImage(s, -this.options.x * this.options.scale, -this.options.y * this.options.scale), [2, this.canvas];
          }
        });
      });
    }, A;
  }(jn)
), Au = function(t) {
  return new Promise(function(A, e) {
    var r = new Image();
    r.onload = function() {
      A(r);
    }, r.onerror = e, r.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(new XMLSerializer().serializeToString(t));
  });
}, eu = (
  /** @class */
  function() {
    function t(A) {
      var e = A.id, r = A.enabled;
      this.id = e, this.enabled = r, this.start = Date.now();
    }
    return t.prototype.debug = function() {
      for (var A = [], e = 0; e < arguments.length; e++)
        A[e] = arguments[e];
      this.enabled && (typeof window < "u" && window.console && typeof console.debug == "function" ? console.debug.apply(console, Se([this.id, this.getTime() + "ms"], A)) : this.info.apply(this, A));
    }, t.prototype.getTime = function() {
      return Date.now() - this.start;
    }, t.prototype.info = function() {
      for (var A = [], e = 0; e < arguments.length; e++)
        A[e] = arguments[e];
      this.enabled && typeof window < "u" && window.console && typeof console.info == "function" && console.info.apply(console, Se([this.id, this.getTime() + "ms"], A));
    }, t.prototype.warn = function() {
      for (var A = [], e = 0; e < arguments.length; e++)
        A[e] = arguments[e];
      this.enabled && (typeof window < "u" && window.console && typeof console.warn == "function" ? console.warn.apply(console, Se([this.id, this.getTime() + "ms"], A)) : this.info.apply(this, A));
    }, t.prototype.error = function() {
      for (var A = [], e = 0; e < arguments.length; e++)
        A[e] = arguments[e];
      this.enabled && (typeof window < "u" && window.console && typeof console.error == "function" ? console.error.apply(console, Se([this.id, this.getTime() + "ms"], A)) : this.info.apply(this, A));
    }, t.instances = {}, t;
  }()
), tu = (
  /** @class */
  function() {
    function t(A, e) {
      var r;
      this.windowBounds = e, this.instanceName = "#" + t.instanceCount++, this.logger = new eu({ id: this.instanceName, enabled: A.logging }), this.cache = (r = A.cache) !== null && r !== void 0 ? r : new pl(this, A);
    }
    return t.instanceCount = 1, t;
  }()
), ru = function(t, A) {
  return A === void 0 && (A = {}), su(t, A);
};
typeof window < "u" && Jn.setContext(window);
var su = function(t, A) {
  return AA(void 0, void 0, void 0, function() {
    var e, r, s, n, i, a, B, o, c, l, u, f, g, h, F, w, Q, E, v, H, L, d, L, b, C, m, y, K, I, S, G, _, Y, LA, sA, nA, GA, NA, UA, VA;
    return $(this, function(FA) {
      switch (FA.label) {
        case 0:
          if (!t || typeof t != "object")
            return [2, Promise.reject("Invalid element provided as first argument")];
          if (e = t.ownerDocument, !e)
            throw new Error("Element is not attached to a Document");
          if (r = e.defaultView, !r)
            throw new Error("Document is not attached to a Window");
          return s = {
            allowTaint: (b = A.allowTaint) !== null && b !== void 0 ? b : !1,
            imageTimeout: (C = A.imageTimeout) !== null && C !== void 0 ? C : 15e3,
            proxy: A.proxy,
            useCORS: (m = A.useCORS) !== null && m !== void 0 ? m : !1
          }, n = er({ logging: (y = A.logging) !== null && y !== void 0 ? y : !0, cache: A.cache }, s), i = {
            windowWidth: (K = A.windowWidth) !== null && K !== void 0 ? K : r.innerWidth,
            windowHeight: (I = A.windowHeight) !== null && I !== void 0 ? I : r.innerHeight,
            scrollX: (S = A.scrollX) !== null && S !== void 0 ? S : r.pageXOffset,
            scrollY: (G = A.scrollY) !== null && G !== void 0 ? G : r.pageYOffset
          }, a = new IA(i.scrollX, i.scrollY, i.windowWidth, i.windowHeight), B = new tu(n, a), o = (_ = A.foreignObjectRendering) !== null && _ !== void 0 ? _ : !1, c = {
            allowTaint: (Y = A.allowTaint) !== null && Y !== void 0 ? Y : !1,
            onclone: A.onclone,
            ignoreElements: A.ignoreElements,
            inlineImages: o,
            copyStyles: o
          }, B.logger.debug("Starting document clone with size " + a.width + "x" + a.height + " scrolled to " + -a.left + "," + -a.top), l = new Ks(B, t, c), u = l.clonedReferenceElement, u ? [4, l.toIFrame(e, a)] : [2, Promise.reject("Unable to find element in cloned iframe")];
        case 1:
          return f = FA.sent(), g = Sr(u) || nl(u) ? Ti(u.ownerDocument) : Ft(B, u), h = g.width, F = g.height, w = g.left, Q = g.top, E = nu(B, u, A.backgroundColor), v = {
            canvas: A.canvas,
            backgroundColor: E,
            scale: (sA = (LA = A.scale) !== null && LA !== void 0 ? LA : r.devicePixelRatio) !== null && sA !== void 0 ? sA : 1,
            x: ((nA = A.x) !== null && nA !== void 0 ? nA : 0) + w,
            y: ((GA = A.y) !== null && GA !== void 0 ? GA : 0) + Q,
            width: (NA = A.width) !== null && NA !== void 0 ? NA : Math.ceil(h),
            height: (UA = A.height) !== null && UA !== void 0 ? UA : Math.ceil(F)
          }, o ? (B.logger.debug("Document cloned, using foreign object rendering"), L = new ql(B, v), [4, L.render(u)]) : [3, 3];
        case 2:
          return H = FA.sent(), [3, 5];
        case 3:
          return B.logger.debug("Document cloned, element located at " + w + "," + Q + " with size " + h + "x" + F + " using computed rendering"), B.logger.debug("Starting DOM parsing"), d = Rn(B, u), E === d.styles.backgroundColor && (d.styles.backgroundColor = mA.TRANSPARENT), B.logger.debug("Starting renderer for element at " + v.x + "," + v.y + " with size " + v.width + "x" + v.height), L = new Wl(B, v), [4, L.render(d)];
        case 4:
          H = FA.sent(), FA.label = 5;
        case 5:
          return (!((VA = A.removeContainer) !== null && VA !== void 0) || VA) && (Ks.destroy(f) || B.logger.error("Cannot detach cloned iframe as it is not in the DOM anymore")), B.logger.debug("Finished rendering"), [2, H];
      }
    });
  });
}, nu = function(t, A, e) {
  var r = A.ownerDocument, s = r.documentElement ? ve(t, getComputedStyle(r.documentElement).backgroundColor) : mA.TRANSPARENT, n = r.body ? ve(t, getComputedStyle(r.body).backgroundColor) : mA.TRANSPARENT, i = typeof e == "string" ? ve(t, e) : e === null ? mA.TRANSPARENT : 4294967295;
  return A === r.documentElement ? OA(s) ? OA(n) ? i : n : s : i;
};
class iu extends oi {
  async execAction(A, e, r, s, n) {
    try {
      this.exportImg(r);
    } catch (i) {
      ibiz.log.error(i);
    }
    return {
      refresh: !1,
      closeView: !1
    };
  }
  exportImg(A) {
    const e = document.querySelector(
      ".ibiz-view.ibiz-view-deeditview3"
    ), r = document.querySelector(".ivu-tabs-tabpane");
    if (e && r) {
      const s = e.scrollHeight + r.scrollHeight - r.offsetHeight;
      ru(e, {
        useCORS: !0,
        allowTaint: !0,
        // 这两个属性都是图片跨域相关属性
        height: s,
        windowHeight: s * 2,
        scale: window.devicePixelRatio
      }).then(function(n) {
        const i = n.toDataURL("image/png").replace("image/png", "image/octet-stream"), a = document.createElement("a");
        a.href = i;
        let B = "downLoad.png";
        A && A[0] && (B = `${A[0].srfmajortext}.png`), a.download = B, a.click();
      });
    }
  }
}
class au {
  constructor() {
    q(this, "handler");
  }
  async getHandler() {
    return this.handler || (this.handler = new iu()), this.handler;
  }
}
class Bu extends pi {
  constructor() {
    super(...arguments);
    /**
     * 流程图url
     *
     * @type {string}
     * @memberof PresetWFChartViewController
     */
    q(this, "imgSrc");
  }
  async getUIData() {
    const e = Object.assign(this.context.clone(), this.params), r = await this.entityService.wf.getWFProcessDiagram(e), s = new Blob([r.data], {
      type: "image/svg+xml"
    });
    this.imgSrc = URL.createObjectURL(s);
  }
}
const ou = hA({
  name: "PresetWFChartView",
  props: {
    context: Object,
    params: {
      type: Object
    },
    modelPath: {
      type: String,
      required: !0
    },
    modal: {
      type: Object
    },
    deName: {
      type: String,
      required: !0
    }
  },
  setup(t) {
    const A = yA("preset-wf-chart-view"), {
      proxy: e
    } = Ut(), r = vr(e, (s, n) => new Bu(t.modelPath, s, n));
    return Ps(e, "deName", r.setDeName.bind(r)), {
      c: r,
      ns: A
    };
  },
  render() {
    return x("div", {
      class: this.ns.b()
    }, [x("img", {
      attrs: {
        src: this.c.imgSrc
      }
    })]);
  }
}), cu = typeof btoa == "function", Tr = typeof Buffer == "function";
typeof TextDecoder == "function" && new TextDecoder();
const Ms = typeof TextEncoder == "function" ? new TextEncoder() : void 0, lu = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", pe = Array.prototype.slice.call(lu);
((t) => {
  let A = {};
  return t.forEach((e, r) => A[e] = r), A;
})(pe);
const fA = String.fromCharCode.bind(String);
typeof Uint8Array.from == "function" && Uint8Array.from.bind(Uint8Array);
const uu = (t) => t.replace(/=/g, "").replace(/[+\/]/g, (A) => A == "+" ? "-" : "_"), gu = (t) => {
  let A, e, r, s, n = "";
  const i = t.length % 3;
  for (let a = 0; a < t.length; ) {
    if ((e = t.charCodeAt(a++)) > 255 || (r = t.charCodeAt(a++)) > 255 || (s = t.charCodeAt(a++)) > 255)
      throw new TypeError("invalid character found");
    A = e << 16 | r << 8 | s, n += pe[A >> 18 & 63] + pe[A >> 12 & 63] + pe[A >> 6 & 63] + pe[A & 63];
  }
  return i ? n.slice(0, i - 3) + "===".substring(i) : n;
}, qn = cu ? (t) => btoa(t) : Tr ? (t) => Buffer.from(t, "binary").toString("base64") : gu, wu = Tr ? (t) => Buffer.from(t).toString("base64") : (t) => {
  let e = [];
  for (let r = 0, s = t.length; r < s; r += 4096)
    e.push(fA.apply(null, t.subarray(r, r + 4096)));
  return qn(e.join(""));
}, fu = (t) => {
  if (t.length < 2) {
    var A = t.charCodeAt(0);
    return A < 128 ? t : A < 2048 ? fA(192 | A >>> 6) + fA(128 | A & 63) : fA(224 | A >>> 12 & 15) + fA(128 | A >>> 6 & 63) + fA(128 | A & 63);
  } else {
    var A = 65536 + (t.charCodeAt(0) - 55296) * 1024 + (t.charCodeAt(1) - 56320);
    return fA(240 | A >>> 18 & 7) + fA(128 | A >>> 12 & 63) + fA(128 | A >>> 6 & 63) + fA(128 | A & 63);
  }
}, Qu = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g, hu = (t) => t.replace(Qu, fu), Os = Tr ? (t) => Buffer.from(t, "utf8").toString("base64") : Ms ? (t) => wu(Ms.encode(t)) : (t) => qn(hu(t)), ht = (t, A = !1) => A ? uu(Os(t)) : Os(t);
function Cu(t, A, e) {
  var L, b;
  const r = O([]), s = O({
    Authorization: `Bearer ${hi("access_token")}`
  }), n = O(""), i = O(""), a = {
    count: 0,
    cacheFiles: []
    // iview上传过程中不能改default-file-list,所以需要缓存
  }, B = (L = e.editorParams) == null ? void 0 : L.blackList;
  let o = [];
  B && typeof B == "string" && (o = B.split(","));
  const c = (b = e.editorParams) == null ? void 0 : b.previewList;
  let l = [];
  c && typeof c == "string" && (l = c.split(",")), QA(
    () => t.value,
    (C) => {
      r.value = C ? JSON.parse(C) : [];
    },
    { immediate: !0 }
  ), QA(
    () => t.data,
    (C) => {
      if (C) {
        const m = e.calcBaseUrl(C);
        n.value = m.uploadUrl, i.value = m.downloadUrl;
      }
    },
    { immediate: !0, deep: !0 }
  ), QA(
    r,
    (C) => {
      C != null && C.length && i.value && C.forEach((m) => {
        m.url = m.url || i.value.replace("%fileId%", m.id);
      }), Array.isArray(C) && C.forEach((m) => {
        m.name || (m.isPreview = !1);
        const y = m.name.trim().toLowerCase();
        m.isPreview = l.some(
          (K) => y.endsWith(`.${K}`)
        );
      });
    },
    { immediate: !0 }
  ), QA(
    i,
    (C) => {
      C && r.value.length && r.value.forEach((m) => {
        m.url = i.value.replace("%fileId%", m.id);
      });
    },
    { immediate: !0 }
  );
  const u = () => {
    const C = [...r.value, ...a.cacheFiles], m = C.length > 0 ? JSON.stringify(C.map((y) => ({ name: y.name, id: y.id }))) : null;
    a.cacheFiles = [], A(m);
  }, f = (C) => {
    const m = C.name.trim().toLowerCase(), y = o.some((I) => m.endsWith(`.${I}`)), K = e.whiteList.some(
      (I) => m.endsWith(`.${I}`)
    );
    if (e.whiteList && e.whiteList.length > 0 && !K)
      return ibiz.message.error(`${C.name} 文件格式不正确`, 2.5, !0), !1;
    if (C.size > e.defaultSize * 1024 * 1024)
      return ibiz.message.error(
        `${C.name} 超出限制，请选择小于${e.defaultSize}MB的文件`,
        2.5,
        !0
      ), !1;
    if (y && !K)
      return ibiz.message.error(`不可上传 ${o.join("、")}类型的文件！`), !1;
    a.count += 1;
  }, g = (C) => {
    C && (a.cacheFiles.push({
      name: C.filename,
      id: C.fileid
    }), a.count -= 1, a.count === 0 && u());
  }, h = (C, m) => {
    throw a.count -= 1, new Ws({
      response: { data: m, status: C.status }
      // eslint-disable-next-line @typescript-eslint/no-explicit-any
    });
  }, F = (C) => {
    if (t.disabled)
      return;
    const m = r.value.findIndex((y) => y.id === C.id);
    m !== -1 && r.value.splice(m, 1), u();
  }, w = (C) => {
    const y = (e.parent.form || e.parent.grid).model.appEntity.deName, K = `${C.id}|${y}|${t.data.srfkey}|${e.context.srfpersonid || e.context.srfuserid}`, I = C.url || i.value.replace("%fileId%", C.id);
    e.fileDownload({
      url: `${I}?key=${window.btoa(K)}${Math.floor(
        1e3 + Math.random() * 9e3
      )}`,
      name: C.name
    });
  }, Q = O(!1), E = O(""), v = O("");
  return {
    uploadUrl: n,
    downloadUrl: i,
    headers: s,
    files: r,
    onDownload: w,
    onError: h,
    onRemove: F,
    onSuccess: g,
    beforeUpload: f,
    showModal: Q,
    modalTitle: E,
    iframeUrl: v,
    onModalCancel: () => {
      Q.value = !1, E.value = "", v.value = "";
    },
    previewFile: (C) => {
      if (!C.isPreview)
        return;
      E.value = C.name;
      const m = window.Environment.previewFileUrl;
      if (m) {
        const y = encodeURIComponent(
          ht(
            `${window.location.origin}${C.url}?fullfilename=${ht(
              C.name
            )}`
          )
        );
        v.value = `${m}/onlinePreview?url=${y}`, Vs(v.value, { type: "_blank" });
      }
    }
  };
}
const du = hA({
  name: "SyFileUpload",
  props: ui(),
  emits: ks(),
  setup(t, {
    emit: A
  }) {
    const e = yA("sy-file-upload"), r = t.controller, {
      uploadUrl: s,
      headers: n,
      files: i,
      onDownload: a,
      onError: B,
      onRemove: o,
      onSuccess: c,
      beforeUpload: l,
      showModal: u,
      modalTitle: f,
      iframeUrl: g,
      onModalCancel: h,
      previewFile: F
    } = Cu(t, (E) => {
      A("change", E);
    }, r), w = Xs(() => r.editorParams.showPreview ? r.editorParams.showPreview === "true" : window.Environment.kkviewon);
    return {
      ns: e,
      c: r,
      uploadUrl: s,
      headers: n,
      files: i,
      onDownload: a,
      onError: B,
      onRemove: o,
      onSuccess: c,
      beforeUpload: l,
      showModal: u,
      modalTitle: f,
      iframeUrl: g,
      onModalCancel: h,
      onPreview: (E) => {
        w.value && F(E);
      },
      showPreview: w
    };
  },
  render(t) {
    return t("div", {
      class: [this.ns.b(), this.disabled ? this.ns.m("disabled") : "", this.readonly ? this.ns.m("readonly") : ""]
    }, [t("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 ? t("div", {
      class: this.ns.bm("box", "drag")
    }, [t("i-icon", {
      attrs: {
        type: "md-cloud-upload"
      }
    }), t("div", {
      class: this.ns.be("box", "title")
    }, [t("span", ["将文件拖到此处，或"]), t("span", ["点击上传"])])]) : t("i-button", {
      class: this.ns.bm("box", "select")
    }, [t("svg", {
      attrs: {
        xmlns: "http://www.w3.org/2000/svg",
        viewBox: "0 0 1024 1024"
      }
    }, [t("path", {
      attrs: {
        fill: "currentColor",
        d: "M160 832h704a32 32 0 1 1 0 64H160a32 32 0 1 1 0-64m384-578.304V704h-64V247.296L237.248 490.048 192 444.8 508.8 128l316.8 316.8-45.312 45.248z"
      }
    })]), t("span", ["上传文件"])]), this.c.uploadDescription && !this.readonly && t("div", {
      class: this.ns.b("accept-description")
    }, [this.c.uploadDescription])]), t("div", {
      class: this.ns.b("file-list")
    }, [this.files.map((A) => t("div", {
      class: this.ns.b("file-item"),
      key: A.id
    }, [t("div", {
      class: this.ns.b("file-item-right")
    }, [t("div", {
      class: this.ns.b("file-item-right-icon")
    }, [t("svg", {
      attrs: {
        viewBox: "0 0 16 16",
        version: "1.1"
      }
    }, [t("g", {
      attrs: {
        id: "基础组件",
        stroke: "none",
        "stroke-width": "1",
        fill: "none",
        "fill-rule": "evenodd"
      }
    }, [t("g", {
      attrs: {
        id: "Upload上传",
        transform: "translate(-128.000000, -1899.000000)",
        "fill-rule": "nonzero"
      }
    }, [t("g", {
      attrs: {
        id: "关联",
        transform: "translate(128.000000, 1899.000000)"
      }
    }, [t("rect", {
      attrs: {
        id: "矩形备份-20",
        x: "0",
        y: "0",
        width: "16",
        height: "16"
      }
    }), t("path", {
      attrs: {
        d: "M8,6.25590375 C9.72432306,6.25590375 11.1277921,7.62964308 11.175675,9.34238963 L11.1769379,9.43284162 L11.1769379,12.7456325 C11.1769379,14.5002069 9.75457434,15.9225704 8,15.9225704 C6.27567694,15.9225704 4.8722079,14.5488311 4.824325,12.8360845 L4.82306213,12.7456325 L4.82306213,10.7559037 C4.82306213,10.4797614 5.04691975,10.2559037 5.32306213,10.2559037 C5.58296083,10.2559037 5.79654502,10.4541998 5.82077327,10.7077504 L5.82306213,10.7559037 L5.82306213,12.7456325 C5.82306213,13.9479221 6.79771041,14.9225704 8,14.9225704 C9.17615286,14.9225704 10.1344543,13.9898375 10.1755637,12.8237123 L10.1769379,12.7456325 L10.1769379,9.43284162 C10.1769379,8.23055203 9.20228959,7.25590375 8,7.25590375 C7.72385763,7.25590375 7.5,7.03204612 7.5,6.75590375 C7.5,6.47976137 7.72385763,6.25590375 8,6.25590375 Z M8,0.0774295852 C9.72432306,0.0774295852 11.1277921,1.45116892 11.175675,3.16391546 L11.1769379,3.25436746 L11.1769379,5.24409625 C11.1769379,5.52023863 10.9530802,5.74409625 10.6769379,5.74409625 C10.4170392,5.74409625 10.203455,5.54580022 10.1792267,5.29224959 L10.1769379,5.24409625 L10.1769379,3.25436746 C10.1769379,2.05207787 9.20228959,1.07742959 8,1.07742959 C6.82384714,1.07742959 5.86554572,2.01016247 5.82443628,3.17628769 L5.82306213,3.25436746 L5.82306213,6.56715838 C5.82306213,7.76944797 6.79771041,8.74409625 8,8.74409625 C8.27614237,8.74409625 8.5,8.96795388 8.5,9.24409625 C8.5,9.52023863 8.27614237,9.74409625 8,9.74409625 C6.27567694,9.74409625 4.8722079,8.37035692 4.824325,6.65761037 L4.82306213,6.56715838 L4.82306213,3.25436746 C4.82306213,1.49979312 6.24542566,0.0774295852 8,0.0774295852 Z",
        id: "形状结合",
        fill: "currentColor",
        transform: "translate(8.000000, 8.000000) rotate(-315.000000) translate(-8.000000, -8.000000) "
      }
    })])])])])]), t("div", {
      class: this.ns.b("file-item-right-title"),
      on: {
        click: () => this.onPreview(A)
      }
    }, [A.name]), t("div", {
      class: this.ns.b("file-item-right-action")
    }, [t("span", {
      class: this.ns.e("icon-download"),
      on: {
        click: () => this.onDownload(A)
      }
    }, [t("svg", {
      attrs: {
        width: "16px",
        height: "16px",
        viewBox: "0 0 16 16",
        version: "1.1",
        fill: "currentColor"
      }
    }, [t("g", {
      attrs: {
        id: "icon",
        stroke: "none",
        "stroke-width": "1",
        "fill-rule": "evenodd"
      }
    }, [t("g", {
      attrs: {
        id: "编组"
      }
    }, [t("path", {
      attrs: {
        d: "M7.33333333,8.77086667 L7.33333333,1.66666667 L8.66666667,1.66666667 L8.66666667,8.7716 L10.5526333,6.88563333 L11.4954333,7.82843333 L8.00036667,11.3235333 L4.50526667,7.82843333 L5.44806667,6.88563333 L7.33333333,8.77086667 Z M2,13 L2,14.3333333 L14,14.3333333 L14,13 L2,13 Z",
        id: "形状",
        fill: "currentColor",
        "fill-rule": "nonzero"
      }
    }), t("rect", {
      attrs: {
        id: "矩形",
        fill: "#000000",
        "fill-rule": "nonzero",
        opacity: "0",
        x: "0",
        y: "0",
        width: "16",
        height: "16"
      }
    })])])])]), this.showPreview ? t("span", {
      class: this.ns.e("icon-preview"),
      on: {
        click: () => this.onPreview(A)
      }
    }, [t("svg", {
      attrs: {
        width: "16px",
        height: "17px",
        viewBox: "0 0 16 17",
        version: "1.1",
        fill: "currentColor",
        xmlns: "http://www.w3.org/2000/svg"
      }
    }, [t("g", {
      attrs: {
        id: "icon",
        stroke: "none",
        "stroke-width": "1",
        fill: "none",
        "fill-rule": "evenodd"
      }
    }, [t("g", {
      attrs: {
        id: "eye",
        transform: "translate(-7.9982, -7.6008)",
        fill: "currentColor"
      }
    }, [t("g", {
      attrs: {
        transform: "translate(8, 8)",
        id: "编组"
      }
    }, [t("path", {
      attrs: {
        d: "M1.43340667,7.64873333 C3.27632667,4.67586667 5.45346667,3 8.00003333,3 C10.5466,3 12.7237333,4.67586667 14.5666667,7.64873333 L14.7844,8 L14.5666667,8.35126667 C12.7237333,11.3241333 10.5466,13 8.00003333,13 C5.45346667,13 3.27632667,11.3241333 1.43340667,8.35126667 L1.21565667,8 L1.43340667,7.64873333 Z M2.79026333,8 C4.4615,10.5552333 6.2084,11.6666667 8.00003333,11.6666667 C9.79166667,11.6666667 11.5385667,10.5552333 13.2098,8 C11.5385667,5.44476667 9.79166667,4.33333333 8.00003333,4.33333333 C6.2084,4.33333333 4.4615,5.44476667 2.79026333,8 Z M8.00003333,7 C7.44773333,7 7.00003333,7.4477 7.00003333,8 C7.00003333,8.5523 7.44773333,9 8.00003333,9 C8.5523,9 9.00003333,8.5523 9.00003333,8 C9.00003333,7.4477 8.5523,7 8.00003333,7 Z M5.6667,8 C5.6667,6.71133333 6.71136667,5.66666667 8.00003333,5.66666667 C9.2887,5.66666667 10.3333667,6.71133333 10.3333667,8 C10.3333667,9.28866667 9.2887,10.3333333 8.00003333,10.3333333 C6.71136667,10.3333333 5.6667,9.28866667 5.6667,8 Z",
        id: "形状",
        "fill-rule": "nonzero"
      }
    }), t("rect", {
      attrs: {
        id: "矩形",
        "fill-rule": "nonzero",
        opacity: "0",
        x: "0",
        y: "0",
        width: "16",
        height: "16"
      }
    })])])])])]) : null, this.disabled || this.readonly ? null : t("span", {
      class: this.ns.e("icon-remove"),
      on: {
        click: () => this.onRemove(A)
      }
    }, [t("svg", {
      attrs: {
        width: "16px",
        height: "16px",
        viewBox: "0 0 16 16",
        version: "1.1",
        fill: "currentColor"
      }
    }, [t("g", {
      attrs: {
        id: "基础组件",
        stroke: "none",
        "stroke-width": "1",
        fill: "none",
        "fill-rule": "evenodd"
      }
    }, [t("g", {
      attrs: {
        id: "Upload上传",
        transform: "translate(-544.000000, -930.000000)",
        "fill-rule": "nonzero"
      }
    }, [t("g", {
      attrs: {
        id: "删除",
        transform: "translate(544.000000, 930.000000)"
      }
    }, [t("rect", {
      attrs: {
        id: "矩形备份-12",
        x: "0",
        y: "0",
        width: "16",
        height: "16"
      }
    }), t("path", {
      attrs: {
        d: "M14.484375,2.84895833 C14.7609375,2.84895833 14.984375,3.07239583 14.984375,3.34895833 C14.984375,3.62552083 14.7609375,3.84895833 14.484375,3.84895833 L13,3.84895833 L13,14.1822917 C13,14.5504815 12.7015232,14.8489583 12.3333333,14.8489583 L3.66666667,14.8489583 C3.29847683,14.8489583 3,14.5504815 3,14.1822917 L3,3.84895833 L3,3.84895833 L1.5,3.84895833 C1.2234375,3.84895833 1,3.62552083 1,3.34895833 C1,3.07239583 1.2234375,2.84895833 1.5,2.84895833 L14.484375,2.84895833 Z M12,3.84895833 L4,3.84895833 L4,13.8489583 L12,13.8489583 L12,3.84895833 Z M6.5,5.84895833 C6.7765625,5.84895833 7,6.07239583 7,6.34895833 L7,11.3458333 C7,11.6223958 6.775,11.8458333 6.5,11.8458333 C6.2234375,11.8458333 6,11.6223958 6,11.3458333 L6,6.34895833 C6,6.07239583 6.2234375,5.84895833 6.5,5.84895833 Z M9.5,5.84895833 C9.7765625,5.84895833 10,6.07239583 10,6.34895833 L10,11.3458333 C10,11.6223958 9.775,11.8458333 9.5,11.8458333 C9.2234375,11.8458333 9,11.6223958 9,11.3458333 L9,6.34895833 C9,6.07239583 9.2234375,5.84895833 9.5,5.84895833 Z M10.5,0.847395833 C10.7765625,0.847395833 11,1.07083333 11,1.34739583 C11,1.62395833 10.7765625,1.84739583 10.5,1.84739583 L5.484375,1.84739583 C5.2078125,1.84739583 4.984375,1.62395833 4.984375,1.34739583 C4.984375,1.07083333 5.2078125,0.847395833 5.484375,0.847395833 L10.5,0.847395833 Z",
        id: "形状结合",
        fill: "currentColor"
      }
    })])])])])])])])]))]), 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
      }
    })])]);
  }
});
function Ct(t, A, e, r, s) {
  var a, B;
  const n = A.replace("%fileId%", t.id), i = ((a = e.parent) == null ? void 0 : a.form) || ((B = e.parent) == null ? void 0 : B.grid);
  if (i) {
    const o = i.model.appEntity.deName, c = `${t.id}|${o}|${r.srfkey}|${e.context.srfpersonid || e.context.srfuserid}`;
    t.url = `${n}?key=${window.btoa(c)}${Math.floor(
      1e3 + Math.random() * 9e3
    )}`;
  }
  if (t.status || (t.status = "finished"), !t.fileName) {
    const o = t.name.lastIndexOf(".");
    t.fileName = t.name.substring(0, o), t.fileExt = t.name.substring(o), t.isImage = vi(t.name);
  }
  if (!s)
    t.isPreview = !1;
  else {
    t.name || (t.isPreview = !1);
    const o = t.name.trim().toLowerCase();
    t.isPreview = s.some((c) => o.endsWith(`.${c}`));
  }
  return t;
}
function Ai(t) {
  const A = O(""), e = O(""), r = O([]);
  return QA(
    t.data,
    (s) => {
      if (s) {
        const n = t.controller.value.calcBaseUrl(s);
        A.value = n.uploadUrl, e.value = n.downloadUrl;
      }
    },
    { immediate: !0, deep: !0 }
  ), QA(
    t.value,
    (s) => {
      r.value = s ? JSON.parse(s) : [], r.value.length && e.value && r.value.forEach((n) => {
        Ct(
          n,
          e.value,
          t.controller.value,
          t.data.value
        );
      });
    },
    { immediate: !0 }
  ), QA(
    e,
    (s) => {
      s && r.value.length && r.value.forEach((n) => {
        Ct(
          n,
          s,
          t.controller.value,
          t.data.value
        );
      });
    },
    { immediate: !0 }
  ), {
    downloadUrl: e,
    uploadUrl: A,
    valueList: r
  };
}
function ei(t) {
  var L, b, C, m;
  const A = O("undo"), e = O([]), { downloadUrl: r, value: s, uploadUrl: n, controller: i, data: a } = t, B = (b = (L = i == null ? void 0 : i.value) == null ? void 0 : L.editorParams) == null ? void 0 : b.blackList;
  let o = [];
  B && typeof B == "string" && (o = B.split(","));
  const c = (m = (C = i == null ? void 0 : i.value) == null ? void 0 : C.editorParams) == null ? void 0 : m.previewList;
  let l = [];
  c && typeof c == "string" && (l = c.split(",")), QA(
    s,
    (y) => {
      y.length > 0 && (e.value = [], y.forEach((K) => {
        e.value.push(
          Ct(
            K,
            r.value,
            i.value,
            a.value,
            l
          )
        );
      }));
    },
    {
      immediate: !0,
      deep: !0
    }
  );
  const u = (y, K) => {
    if (y.some((G) => G.size > i.value.defaultSize * 1024 * 1024 ? (ibiz.message.error(
      `${G.name} 超出限制，请选择小于${i.value.defaultSize}MB的文件`,
      2.5,
      !0
    ), !0) : i.value.whiteList && i.value.whiteList.length > 0 && !i.value.whiteList.includes(G.name) ? (ibiz.message.error(`${G.name} 文件格式不正确`, 2.5, !0), !0) : !1))
      return !1;
    const S = [];
    return K.forEach((G, _) => {
      const Y = G.name.trim().toLowerCase();
      if (o.some((nA) => Y.endsWith(`.${nA}`))) {
        S.push(_);
        return;
      }
      const sA = l.some((nA) => Y.endsWith(`.${nA}`));
      e.value.push({
        name: G.name,
        status: G.status,
        percentage: G.percentage,
        id: G.uid,
        url: "",
        isPreview: sA
      });
    }), S.length === K.length ? (ibiz.message.error(`不可上传 ${o.join("、")}类型的文件！`), !1) : (S.length && (S.forEach((G) => {
      y.splice(G, 1), K.splice(G, 1);
    }), ibiz.message.error(`不可上传 ${o.join("、")}类型的文件！`)), !0);
  }, f = (y) => {
    y.forEach((K) => {
      e.value.find((I) => I.id === K.uid ? (I.percentage = K.percentage, !0) : !1);
    });
  }, g = (y, K) => {
    y.forEach((I) => {
      e.value.find((S) => S.id === I.uid ? (S.status = I.status, S.id = K.data.fileid, S.name = K.data.filename, Ct(
        S,
        r.value,
        i.value,
        a.value,
        l
      ), !0) : !1);
    });
  }, h = (y, K) => {
    var S;
    y.forEach((G) => {
      e.value.find((_) => _.id === G.uid ? (_.status = G.status, !0) : !1);
    });
    const I = new Ws(K);
    ibiz.notification.error({
      title: (S = I.status) == null ? void 0 : S.toString(),
      desc: I.message,
      duration: 10
    });
  }, F = (y) => {
    e.value = e.value.filter((K) => K.status === "finished"), A.value = "done";
  }, w = () => {
    Hi({
      multiple: t.multiple,
      accept: t.accept,
      uploadUrl: n.value,
      beforeUpload: u,
      progress: f,
      success: g,
      error: h,
      finish: F
    });
  }, Q = O(!1), E = O(""), v = O("");
  return {
    selectFile: w,
    fileList: e,
    uploadState: A,
    showModal: Q,
    modalTitle: E,
    iframeUrl: v,
    onModalCancel: () => {
      Q.value = !1, E.value = "", v.value = "";
    },
    previewFile: (y) => {
      if (!y.isPreview)
        return;
      E.value = y.name;
      const K = window.Environment.previewFileUrl;
      if (K) {
        const I = encodeURIComponent(
          ht(
            `${window.location.origin}${y.url}?fullfilename=${ht(
              y.name
            )}`
          )
        );
        v.value = `${K}/onlinePreview?url=${I}`, Vs(v.value, { type: "_blank" });
      }
    }
  };
}
const Uu = hA({
  name: "SyGridFileUpload",
  props: Hr(),
  setup(t) {
    const A = yA("sy-grid-file-upload"), {
      value: e,
      data: r,
      controller: s
    } = mr(t), {
      downloadUrl: n,
      uploadUrl: i,
      valueList: a
    } = Ai({
      value: e,
      data: r,
      controller: s
    }), {
      fileList: B,
      showModal: o,
      modalTitle: c,
      iframeUrl: l,
      previewFile: u,
      onModalCancel: f
    } = ei({
      downloadUrl: n,
      uploadUrl: i,
      value: a,
      controller: s,
      data: r
    }), g = (F) => {
      const w = t.controller, E = w.parent.grid.model.appEntity.deName, v = `${F.id}|${E}|${r.value.srfkey}|${w.context.srfpersonid || w.context.srfuserid}`, H = F.url || n.value.replace("%fileId%", F.id);
      w.fileDownload({
        url: `${H}?key=${window.btoa(v)}${Math.floor(1e3 + Math.random() * 9e3)}`,
        name: F.name
      });
    }, h = Xs(() => t.controller.editorParams.showPreview ? t.controller.editorParams.showPreview === "true" : window.Environment.kkviewon);
    return {
      ns: A,
      fileList: B,
      showModal: o,
      modalTitle: c,
      iframeUrl: l,
      showPreview: h,
      downloadFile: g,
      previewFile: u,
      onModalCancel: f
    };
  },
  render() {
    return x("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") : ""]
    }, [x("div", {
      class: this.ns.b("file-list")
    }, [this.fileList.map((t) => x("div", {
      class: this.ns.b("file-item"),
      key: t.id
    }, [x("div", {
      class: this.ns.b("file-item-title"),
      on: {
        click: () => this.downloadFile(t)
      }
    }, [t.name]), x("div", {
      class: this.ns.b("file-item-action")
    }, [this.showPreview && t.isPreview ? x("i-icon", {
      attrs: {
        type: "md-eye"
      },
      on: {
        click: () => this.previewFile(t)
      }
    }) : null])]))]), x("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
      }
    }, [x("iframe", {
      class: this.ns.b("iframe"),
      attrs: {
        src: this.iframeUrl
      }
    })])]);
  }
}), Fu = hA({
  name: "SyGridFileUploadContainer",
  props: Hr(),
  emits: _s(),
  render(t) {
    return this.disabled || this.readonly ? t("SyGridFileUpload", {
      props: {
        ...this.$props
      }
    }) : t("SyEditGridFileUpload", {
      props: {
        ...this.$props
      },
      on: {
        change: (A, e) => {
          this.$emit("change", A, e);
        },
        rowSave: () => {
          this.$emit("rowSave");
        }
      }
    });
  }
});
const pu = hA({
  name: "SyEditGridFileUploadPopover",
  props: {
    uploadUrl: {
      type: String,
      required: !0
    },
    downloadUrl: {
      type: String,
      required: !0
    },
    value: {
      type: Array,
      required: !0
    },
    controller: {
      type: Js,
      required: !0
    },
    data: {
      type: Object,
      required: !0
    }
  },
  emits: {
    close: (t) => !0
  },
  setup(t, {
    emit: A
  }) {
    const e = yA("sy-edit-grid-file-upload-popover"), {
      downloadUrl: r,
      value: s,
      uploadUrl: n,
      controller: i,
      data: a
    } = mr(t), {
      fileList: B,
      uploadState: o,
      selectFile: c
    } = ei({
      downloadUrl: r,
      value: s,
      uploadUrl: n,
      controller: i,
      data: a
    }), l = O(), u = O(!1), f = gi(l, async (F) => {
      A("close", {
        isModified: u.value,
        resultFiles: B.value
      });
    });
    return QA(o, (F) => {
      F === "done" ? (u.value = !0, f.proceed()) : F === "loading" && f.pause();
    }), {
      ns: e,
      componentRef: l,
      fileList: B,
      deleteFile: (F) => {
        const w = B.value.findIndex((Q) => Q.id === F.id);
        B.value.splice(w, 1), u.value = !0;
      },
      selectFile: c,
      downloadFile: (F) => {
        const w = t.controller, E = w.parent.grid.model.appEntity.deName, v = `${F.id}|${E}|${t.data.srfkey}|${w.context.srfpersonid || w.context.srfuserid}`, H = F.url || r.value.replace("%fileId%", F.id);
        w.fileDownload({
          url: `${H}?key=${window.btoa(v)}${Math.floor(1e3 + Math.random() * 9e3)}`,
          name: F.name
        });
      }
    };
  },
  render() {
    return x("div", {
      ref: "componentRef",
      style: "width:300px",
      class: this.ns.b()
    }, [x("div", {
      class: this.ns.b("file-list")
    }, [this.fileList.map((t) => x("div", {
      class: this.ns.b("file-item"),
      key: t.id
    }, [x("div", {
      class: this.ns.b("file-item-title"),
      on: {
        click: () => this.downloadFile(t)
      }
    }, [t.name]), x("div", {
      class: this.ns.b("file-item-action")
    }, [x("i-icon", {
      attrs: {
        type: "md-close"
      },
      on: {
        click: () => this.deleteFile(t)
      }
    })])]))]), x("div", {
      on: {
        click: () => this.selectFile()
      },
      class: this.ns.e("button")
    }, [x("i-icon", {
      attrs: {
        type: "md-add"
      }
    }), "添加文件"]), x("div", {
      class: this.ns.e("description")
    }, [this.controller.uploadDescription])]);
  }
});
const Eu = hA({
  name: "SyEditGridFileUpload",
  props: Hr(),
  emits: _s(),
  setup(t, {
    emit: A
  }) {
    const e = yA("sy-edit-grid-file-upload"), {
      value: r,
      data: s,
      controller: n
    } = mr(t), {
      downloadUrl: i,
      uploadUrl: a,
      valueList: B
    } = Ai({
      value: r,
      data: s,
      controller: n
    }), o = O(), c = async () => {
      if (!o.value)
        throw new ZA("容器元素不存在");
      const l = o.value.$el, u = l.offsetHeight, f = ibiz.overlay.createPopover((F) => F(pu, {
        props: {
          value: B.value,
          data: s.value,
          uploadUrl: a.value,
          downloadUrl: i.value,
          controller: n.value
        },
        on: {
          close: (w) => {
            f.dismiss(w);
          }
        }
      }), void 0, {
        noArrow: !0,
        placement: "bottom-start",
        offsetOpts: {
          mainAxis: -u,
          crossAxis: 0
        }
      });
      await f.present(l);
      const {
        isModified: g,
        resultFiles: h
      } = await f.onWillDismiss();
      if (g) {
        const F = h.length > 0 ? JSON.stringify(h.map((w) => ({
          name: w.name,
          id: w.id
        }))) : null;
        A("change", F), A("rowSave");
      }
    };
    return wi(o, "click", (l) => {
      !t.disabled && !t.readonly && c();
    }), {
      ns: e,
      valueList: B,
      componentRef: o
    };
  },
  render() {
    return x("grid-editor", {
      attrs: {
        disabled: this.disabled,
        readonly: this.readonly
      },
      ref: "componentRef",
      class: this.ns.b()
    }, [x("div", {
      class: this.ns.b("file-list")
    }, [this.valueList.map((t) => x("div", {
      class: this.ns.b("file-item"),
      key: t.id
    }, [x("div", {
      class: this.ns.b("file-item-title")
    }, [t.name])]))])]);
  }
});
function vu(t, A) {
  function e() {
    const r = window.navigator.userAgent;
    return r.indexOf("MSIE ") > 0 || r.indexOf("Trident/") > 0;
  }
  return e() ? A ? A() : null : t();
}
const Hu = hA({
  name: "CustomSelectItem",
  props: fi(),
  emits: ks(),
  setup(t, {
    emit: A
  }) {
    const e = yA("picker"), r = t.controller, s = O(""), n = O([]), i = O(!0), a = O();
    QA(() => t.value, (w) => {
      if (w || w === null) {
        s.value = w, w === null && (s.value = "");
        const Q = t.data[r.valueItem];
        if (n.value.findIndex((v) => Object.is(v[r.keyName], Q)) !== -1)
          return;
        n.value = [], !eA(w) && !eA(Q) && n.value.push({
          [r.textName]: w,
          [r.keyName]: Q
        });
      }
    }, {
      immediate: !0
    });
    const B = async (w) => {
      const Q = await r.calcFillDataItems(w);
      Q.length && Q.forEach((E) => {
        A("change", E.value, E.name);
      }), r.valueItem && A("change", w[r.keyName], r.valueItem), A("change", w[r.textName]);
    }, o = async () => {
      const w = await r.openPickUpView(t.data);
      w && w[0] && await B(w[0]);
    }, c = async () => {
      await r.openLinkView(t.data);
    }, l = async (w) => {
      var Q, E, v;
      a.value && (w[r.textName] === s.value && (a.value.currentValue = s.value), (v = (E = (Q = a.value.$refs) == null ? void 0 : Q.select) == null ? void 0 : E.hideMenu) == null || v.call(E)), await B(w), i.value = !0, A("operate", !1);
    }, u = async (w) => {
      if (r.model.appDataEntity) {
        const Q = await r.getServiceData(w, t.data);
        Q && (n.value = Q.data);
      }
    }, f = () => {
      var Q;
      const w = (Q = r.model.deACMode) == null ? void 0 : Q.dataItems;
      w != null && w.length && w.forEach((E) => {
        A("change", null, E.name);
      }), r.valueItem && A("change", null, r.valueItem), A("change", null);
    }, g = (w) => {
      A("operate", !0);
      const Q = i.value ? "" : w.target.value;
      u(Q);
    }, h = () => {
      A("operate", !1);
    }, F = (r.linkView ? 1 : 0) + (r.pickupView ? 1 : 0);
    return {
      ns: e,
      c: r,
      curValue: s,
      items: n,
      autocomplete: a,
      openPickUpView: o,
      openLinkView: c,
      onACSelect: l,
      onSearch: u,
      onClear: f,
      onFocus: g,
      closeCircle: F,
      onBlur: h
    };
  },
  render(t) {
    return this.readonly ? t("div", {
      class: (this.ns.b(), this.ns.m("readonly"))
    }, [this.value]) : t("div", {
      class: [this.ns.b(), this.disabled ? this.ns.m("disabled") : ""]
    }, [[this.c.noAC && t("IInput", {
      props: {
        ...this.c.customProps,
        value: this.curValue,
        clearable: !0,
        placeholder: this.c.placeHolder,
        disabled: this.disabled
      },
      on: {
        "on-clear": this.onClear
      }
    }, [this.$slots.append, !this.$slots.append && this.c.pickupView && t("i-button", {
      key: "ios-search",
      attrs: {
        icon: "ios-search"
      },
      on: {
        click: this.openPickUpView
      }
    }), !this.$slots.append && this.c.linkView && t("i-button", {
      key: "ios-search-outline",
      attrs: {
        icon: "ios-search-outline"
      },
      on: {
        click: "openLinkView"
      }
    })]), !this.c.noAC && t("div", {
      class: [this.ns.e("autocomplete"), this.ns.m(this.closeCircle.toString())]
    }, [[t("IAutoComplete", {
      ref: "autocomplete",
      props: {
        ...this.c.customProps,
        value: this.curValue,
        placeholder: this.c.placeHolder,
        placement: "bottom",
        clearable: !0,
        transferClassName: this.ns.e("transfer"),
        disabled: this.disabled
      },
      on: {
        "on-focus": this.onFocus,
        "on-search": this.onSearch,
        "on-clear": this.onClear,
        "on-blur": this.onBlur
      }
    }, [this.items.map((A) => t("div", {
      class: this.ns.e("transfer-item"),
      on: {
        click: () => {
          this.onACSelect(A);
        }
      }
    }, [A[this.c.textName] || A.usercode || A.mdeptname ? `${A[this.c.textName] ? A[this.c.textName] : ""}${A.usercode ? `(${A.usercode})-` : ""}${A.mdeptname ? A.mdeptname : ""}` : ""]))]), t("div", {
      class: this.ns.e("buns-position")
    }, [t("div", {
      class: this.ns.e("btns")
    }, [this.c.pickupView ? t("i-button", {
      attrs: {
        icon: "ios-search",
        type: "text"
      },
      on: {
        click: this.openPickUpView
      }
    }) : null, this.c.linkView ? t("i-button", {
      on: {
        click: this.openLinkView
      },
      attrs: {
        type: "text"
      },
      class: this.ns.e("link")
    }, [vu(() => t("ion-icon", {
      attrs: {
        src: "./assets/img/link.svg"
      }
    }))]) : null])])]])]]);
  }
});
class mu {
  constructor() {
    q(this, "component", ou);
  }
}
class Iu {
  constructor() {
    q(this, "formEditor", "SyFileUpload");
    q(this, "gridEditor", "SyGridFileUploadContainer");
  }
  async createController(A, e) {
    const r = new Js(A, e);
    return await r.init(), r;
  }
}
class yu {
  constructor() {
    q(this, "formEditor", "CustomSelectItem");
    q(this, "gridEditor", "IBizGridPicker");
  }
  async createController(A, e) {
    const r = new Ei(A, e);
    return await r.init(), r;
  }
}
const Lu = new ci(import.meta.url);
function Rs(t, A) {
  if (A != null) {
    const { srfkey: e } = A;
    if (!uA(e) && !eA(e))
      return !0;
  }
  throw new ZA(`执行「${t}」不存在「srfkey」无法处理`);
}
function vA(t, A) {
  const { srfsessionid: e } = A;
  if (!uA(e) && !eA(e))
    return !0;
  throw new ZA(`执行「${t}」不存在「srfsessionid」无法处理`);
}
class bu {
  constructor() {
    this.cacheMap = /* @__PURE__ */ new Map();
  }
  /**
   * 强制设置数据，忽略其他逻辑
   *
   * @author chitanda
   * @date 2022-05-10 17:05:45
   * @param {IContext} context
   * @param {Entity} entity
   */
  forceAdd(A, e) {
    const s = this.getCacheByTag(A).get(e.srfkey);
    s && (s.assign(e), ibiz.log.warn("forceAdd", e.srfkey, e));
  }
  /**
   * 强制更新数据，非合并，忽略其他逻辑
   *
   * @author chitanda
   * @date 2022-05-10 17:05:27
   * @param {IContext} context
   * @param {Entity} entity
   */
  forceUpdate(A, e) {
    this.getCacheByTag(A).set(e.srfkey, HA(e)), ibiz.log.warn("forceUpdate", e.srfkey, e);
  }
  /**
   * 强制删除数据，忽略其他逻辑
   *
   * @author chitanda
   * @date 2022-05-10 17:05:08
   * @param {IContext} context
   * @param {string} srfKey
   */
  forceDelete(A, e) {
    this.getCacheByTag(A).delete(e), ibiz.log.warn("forceDelete", e);
  }
  /**
   * 新增数据
   *
   * @param {*} context
   * @param {Entity} entity
   * @return {*}  {boolean}
   * @memberof EntityCache
   */
  add(A, e) {
    try {
      return vA("add", A), (uA(e.srfkey) || eA(e.srfkey)) && (e.srfkey = it()), e.srftempdate = (/* @__PURE__ */ new Date()).getTime(), this.getCacheByTag(A).set(e.srfkey, HA(e)), ibiz.log.warn("add", e.srfkey, e), e;
    } catch (r) {
      return ibiz.log.error(r), null;
    }
  }
  /**
   * 查找数据
   *
   * @param {*} context
   * @param {string} srfKey
   * @return {*}  {Entity}
   * @memberof EntityCache
   */
  get(A, e) {
    try {
      vA("get", A);
      const s = this.getCacheByTag(A).get(e);
      return ibiz.log.warn("get", e, s), HA(s);
    } catch (r) {
      return ibiz.log.error(r), null;
    }
  }
  /**
   * 更新数据
   *
   * @param {IContext} context
   * @param {Entity} entity
   * @return {*}  {Entity}
   * @memberof EntityCache
   */
  update(A, e) {
    try {
      vA("update", A), Rs("update", e), e.srftempdate = (/* @__PURE__ */ new Date()).getTime();
      const r = this.getCacheByTag(A), s = r.get(e.srfkey);
      if (s)
        return s.assign(e), r.set(e.srfkey, s), ibiz.log.warn("update", e.srfkey, e), HA(s);
      throw new Error("数据不存在，无法更新!");
    } catch (r) {
      return ibiz.log.error(r), null;
    }
  }
  /**
   * 删除数据
   *
   * @param {IContext} context
   * @param {string} srfKey
   * @return {*}  {(Entity | null)}
   * @memberof EntityCache
   */
  delete(A, e) {
    try {
      vA("delete", A);
      const r = this.getCacheByTag(A), s = e;
      if (r.has(s)) {
        const n = r.get(s);
        return n.srftempdate = (/* @__PURE__ */ new Date()).getTime(), r.delete(s), ibiz.log.warn("delete", s), n;
      }
      return null;
    } catch (r) {
      return ibiz.log.error(r), null;
    }
  }
  /**
   * 批量创建临时数据
   *
   * @author chitanda
   * @date 2022-03-23 11:03:52
   * @param {IContext} context
   * @param {Entity[]} entities
   * @return {*}  {Entity[]}
   */
  createBatch(A, e) {
    try {
      vA("add", A);
      const r = this.getCacheByTag(A);
      for (let s = 0; s < e.length; s++) {
        const n = e[s];
        (uA(n.srfkey) || eA(n.srfkey)) && (n.srfkey = it()), n.srftempdate = (/* @__PURE__ */ new Date()).getTime();
        const i = HA(n);
        r.set(n.srfkey, i), e[s] = i, ibiz.log.warn("add", n.srfkey, n);
      }
      return e;
    } catch (r) {
      ibiz.log.error(r);
    }
    return [];
  }
  /**
   * 批量更新数据
   *
   * @author chitanda
   * @date 2022-03-23 10:03:17
   * @param {IContext} context
   * @param {Entity[]} entities
   * @return {*}  {Entity[]}
   */
  updateBatch(A, e) {
    try {
      vA("update", A);
      const r = this.getCacheByTag(A);
      for (let s = 0; s < e.length; s++) {
        const n = e[s];
        Rs("update", n), n.srftempdate = (/* @__PURE__ */ new Date()).getTime();
        const i = r.get(n.srfkey);
        if (i)
          i.assign(n), r.set(n.srfkey, i), ibiz.log.warn("update", n.srfkey, n), e[s] = HA(i);
        else
          throw new Error(`数据[${n.srfdename}-${n.srfmajortext}(${n.srfkey})]不存在，无法更新!`);
      }
      return e;
    } catch (r) {
      return ibiz.log.error(r), null;
    }
  }
  /**
   * 批量删除数据
   *
   * @author chitanda
   * @date 2022-03-23 10:03:40
   * @param {IContext} context 上下文
   * @param {string[]} srfKeys 需要删除的数据主键
   * @return {*}  {string[]} 未能删除的数据主键
   */
  deleteBatch(A, e) {
    try {
      vA("delete", A);
    } catch (n) {
      return ibiz.log.error(n), e;
    }
    const r = this.getCacheByTag(A), s = [];
    for (let n = 0; n < e.length; n++) {
      const i = e[n];
      r.has(i) || s.push(i);
    }
    if (s.length > 0)
      throw new Error(`未找到以下数据「${s.join("、")}」，无法删除!`);
    for (let n = 0; n < e.length; n++) {
      const i = e[n];
      r.delete(i), ibiz.log.warn("delete", i);
    }
    return [];
  }
  /**
   * 检查数据是否已经存在
   *
   * @author chitanda
   * @date 2022-08-17 23:08:06
   * @param {IContext} context
   * @param {string} srfkey
   * @return {*}  {boolean}
   */
  checkData(A, e) {
    return this.getList(A).findIndex((n) => n.srfkey === e) !== -1;
  }
  /**
   * 根据条件查找数据，未设置条件默认返回全部
   *
   * @author chitanda
   * @date 2022-08-17 23:08:56
   * @param {IContext} context
   * @return {*}  {Entity[]}
   */
  getList(A) {
    try {
      vA("getList", A);
      const e = this.getCacheByTag(A);
      if (!e)
        return [];
      const r = e.values();
      return Array.from(r);
    } catch (e) {
      return ibiz.log.error(e), [];
    }
  }
  /**
   * 根据条件查找数据条数
   *
   * @author fzh
   * @date 2024-01-11 18:08:56
   * @param {IContext} context
   * @return {*}  number
   */
  getTotal(A) {
    try {
      vA("getList", A);
      const e = this.getCacheByTag(A);
      return e ? e.size : 0;
    } catch (e) {
      return ibiz.log.error(e), 0;
    }
  }
  /**
   * 根据条件生成查询
   *
   * @author chitanda
   * @date 2022-08-17 23:08:33
   * @param {IParams} [params={}]
   * @return {*}  {<U>(testObj: U) => boolean}
   */
  generatePred(A = {}) {
    const e = {};
    A.srfkey && (e.srfkey = kA(A.srfkey)), delete A.srfkey;
    for (const r in A)
      if (Object.prototype.hasOwnProperty.call(A, r)) {
        const s = A[r];
        e[r] = kA(s);
      }
    return we(e);
  }
  /**
   * 清除缓存
   *
   * @author chitanda
   * @date 2022-08-17 23:08:54
   * @param {IContext} context
   */
  clear(A) {
    const e = A.srfsessionid;
    this.cacheMap.size > 0 && this.cacheMap.delete(e);
  }
  /**
   * 根据标识获取map组
   *
   * @author chitanda
   * @date 2022-08-17 23:08:47
   * @private
   * @param {IContext} context
   * @return {*}  {Map<string, Entity>}
   */
  getCacheByTag(A) {
    const e = A.srfsessionid;
    return this.cacheMap.has(e) || this.cacheMap.set(e, /* @__PURE__ */ new Map()), this.cacheMap.get(e);
  }
}
class Ku {
  /**
   * Creates an instance of SearchFilter.
   *
   * @param {*} context
   * @param {*} [data]
   * @memberof SearchFilter
   */
  constructor(A, e) {
    if (this.page = 0, this.size = 1e3, this.data = {}, this.sortField = "srfordervalue", this.sortMode = "ASC", this.context = A, e) {
      if (!uA(e.page) && !eA(e.page) && (this.page = e.page), !uA(e.size) && !eA(e.size) && (this.size = e.size), !uA(e.query) && !eA(e.query) && (this.query = e.query), !uA(e.sort) && !eA(e.sort)) {
        const r = e.sort.split(",");
        r.length >= 1 && ([this.sortField] = r), r.length >= 2 && (this.sortMode = r[1].toUpperCase());
      }
      !uA(e.srfparentkey) && !eA(e.srfparentkey) && (this.srfparentkey = e.srfparentkey), !uA(e.srfparentdename) && !eA(e.srfparentdename) && (this.srfparentdename = e.srfparentdename), this.data = Object.assign({}, e), delete this.data.page, delete this.data.size, delete this.data.query, delete this.data.sort, delete this.data.srfparentkey, delete this.data.srfparentdename;
    }
  }
  /**
   * 获取条件值
   *
   * @author chitanda
   * @date 2022-08-17 22:08:11
   * @param {string} key
   * @return {*}  {unknown}
   */
  getValue(A) {
    return this.data[A] ? this.data[A] : this.context[A];
  }
}
function ti(t, A) {
  let e = [];
  A.forEach((s) => {
    let n = [];
    for (let i = 0; i < s.length - 1; i++) {
      const a = s[i], B = t[a.name];
      B ? (n.push(a.plural), n.push(B)) : n = [];
    }
    e.push(n);
  }), e = e.sort((s, n) => n.length - s.length);
  const [r] = e;
  return r ? `${r.length > 1 ? "/" : ""}${r.join("/")}` : "";
}
iA.DE_GRID_VIEW, iA.DE_GRID_EXP_VIEW, iA.DE_LIST_VIEW, iA.DE_LIST_EXP_VIEW, iA.DE_DATA_VIEW, iA.DE_DATAVIEW_EXP_VIEW, iA.DE_CALENDAR_VIEW, iA.DE_CALENDAR_EXP_VIEW, iA.DE_CHART_VIEW, iA.DE_CHART_EXP_VIEW, iA.DE_KANBAN_VIEW;
var Du = globalThis && globalThis.__rest || function(t, A) {
  var e = {};
  for (var r in t)
    Object.prototype.hasOwnProperty.call(t, r) && A.indexOf(r) < 0 && (e[r] = t[r]);
  if (t != null && typeof Object.getOwnPropertySymbols == "function")
    for (var s = 0, r = Object.getOwnPropertySymbols(t); s < r.length; s++)
      A.indexOf(r[s]) < 0 && Object.prototype.propertyIsEnumerable.call(t, r[s]) && (e[r[s]] = t[r[s]]);
  return e;
};
class Su {
  /**
   * Creates an instance of WorkFlowService.
   * @author lxm
   * @date 2022-09-29 11:09:54
   * @param {AppEntityModel} model 应用实体
   */
  constructor(A) {
    this.model = A, this.app = A.source.getPSModelService().app;
    const e = ibiz.appData.context;
    this.commonBaseUrl = `/wfcore/${e.srfsystemid}-app-${this.app.codeName.toLowerCase()}/${this.model.source.name.toLowerCase()}`;
  }
  /**
   * 获取基础路径
   *
   * @author lxm
   * @date 2022-09-29 14:09:40
   * @private
   * @returns {*}
   */
  getBaseUrl() {
    return this.commonBaseUrl;
  }
  /**
   * 获取activeData
   *
   * @private
   * @param {IData} data
   * @param {IParams} context
   * @returns {*}
   * @memberof WorkFlowService
   */
  getActiveData(A, e) {
    return e.srfprocessinstanceid && (A.srfprocessinstanceid = e.srfprocessinstanceid), A;
  }
  /**
   * 根据当前步骤和任务获取工作流步骤数据（如：流程表单等）
   *
   * @author lxm
   * @date 2022-09-29 14:09:45
   * @param {IParams} context
   * @returns {*}  {Promise<IHttpResponse<IData>>}
   */
  async getWFStep(A) {
    const { processDefinitionKey: e, taskDefinitionKey: r } = A, s = Du(A, ["processDefinitionKey", "taskDefinitionKey"]);
    return ibiz.net.get(`${this.getBaseUrl()}/process-definitions/${e}/usertasks/${r}`, s);
  }
  /**
   * 根据业务主键和当前步骤获取操作路径
   *
   * @author lxm
   * @date 2022-09-29 14:09:52
   * @param {IParams} context 路径参数
   * @param {IData} data 数据
   * @returns {*}  {Promise<IHttpResponse<IData>>}
   */
  async getWFLink(A, e) {
    const r = A[this.model.deName], { taskDefinitionKey: s } = A;
    return ibiz.net.post(`${this.getBaseUrl()}/${r}/usertasks/${s}/ways`, { activedata: this.getActiveData(e, A) });
  }
  /**
   * 根据业务主键获取工作流程进度
   *
   * @author lxm
   * @date 2022-09-29 14:09:45
   * @param {IContext} context
   * @returns {*}  {Promise<IHttpResponse<IData>>}
   */
  async getWFHistory(A) {
    const e = A[this.model.deName];
    let r = "alls";
    return !ibiz.env.enableWfAllHistory && A.srfprocessinstanceid && (r = A.srfprocessinstanceid), ibiz.net.get(`${this.getBaseUrl()}/${e}/process-instances/${r}/history`);
  }
  /**
   * 根据业务主键获取工作流流程图片
   *
   * @author lxm
   * @date 2022-10-27 16:10:13
   * @param {IContext} context
   * @returns {*}  {Promise<IHttpResponse<IData>>}
   */
  async getWFProcessDiagram(A) {
    const e = A[this.model.deName];
    return ibiz.net.request(`${this.getBaseUrl()}/${e}/process-instances/alls/processdiagram`, {
      method: "post",
      data: {},
      responseType: "blob"
    });
  }
  /**
   * 获取标准工作流版本信息
   *
   * @author lxm
   * @date 2022-09-29 14:09:45
   * @returns {*}  {Promise<IHttpResponse<IData>>}
   */
  async getWFVersion() {
    return ibiz.net.get(`${this.getBaseUrl()}/process-definitions2`);
  }
  /**
   * 启动工作流
   *
   * @author lxm
   * @date 2022-09-30 17:09:51
   * @param {IContext} context 路径参数
   * @param {IParams} params 请求参数
   * @param {IData} data 数据
   * @returns {*}  {Promise<IHttpResponse<IData>>}
   */
  async wfStart(A, e, r) {
    return ibiz.net.post(`${this.getBaseUrl()}/${A[this.model.deName]}/process-instances`, Object.assign(Object.assign({}, e), { activedata: this.getActiveData(r, A) }));
  }
  /**
   * 提交工作流
   *
   * @author lxm
   * @date 2022-09-30 17:09:51
   * @param {IContext} context 路径参数
   * @param {IParams} params 请求参数
   * @param {IData} data 数据
   * @returns {*}  {Promise<IHttpResponse<IData>>}
   */
  async wfSubmit(A, e, r) {
    return ibiz.net.post(`${this.getBaseUrl()}/${A[this.model.deName]}/tasks/${e.taskId}`, Object.assign(Object.assign({}, e), { activedata: this.getActiveData(r, A) }));
  }
  /**
   * 回撤
   *
   * @author lxm
   * @date 2022-09-30 17:09:51
   * @param {IContext} context 路径参数
   * @param {IParams} params 请求参数
   * @param {IData} data 数据
   * @returns {*}  {Promise<IHttpResponse<IData>>}
   */
  async wfWithdraw(A, e, r) {
    return ibiz.net.post(`${this.getBaseUrl()}/${A[this.model.deName]}/tasks/${e.taskId}/withdraw`, Object.assign(Object.assign({}, e), { activedata: this.getActiveData(r, A) }));
  }
  /**
   * 转办
   *
   * @author lxm
   * @date 2022-09-30 17:09:51
   * @param {IContext} context 路径参数
   * @param {IParams} params 请求参数
   * @param {IData} data 数据
   * @returns {*}  {Promise<IHttpResponse<IData>>}
   */
  async wfReassign(A, e, r) {
    return ibiz.net.post(`${this.getBaseUrl()}/${A[this.model.deName]}/tasks/${e.taskId}/transfer`, Object.assign(Object.assign({}, e), { activedata: this.getActiveData(r, A) }));
  }
  /**
   * 后加签
   *
   * @author lxm
   * @date 2022-09-30 17:09:51
   * @param {IContext} context 路径参数
   * @param {IParams} params 请求参数
   * @param {IData} data 数据
   * @returns {*}  {Promise<IHttpResponse<IData>>}
   */
  async wfAddStepAfter(A, e, r) {
    return ibiz.net.post(`${this.getBaseUrl()}/${A[this.model.deName]}/tasks/${e.taskId}/aftersign`, Object.assign(Object.assign({}, e), { activedata: this.getActiveData(r, A) }));
  }
  /**
   * 前加签
   *
   * @author lxm
   * @date 2022-09-30 17:09:51
   * @param {IContext} context 路径参数
   * @param {IParams} params 请求参数
   * @param {IData} data 数据
   * @returns {*}  {Promise<IHttpResponse<IData>>}
   */
  async wfAddStepBefore(A, e, r) {
    return ibiz.net.post(`${this.getBaseUrl()}/${A[this.model.deName]}/tasks/${e.taskId}/beforesign`, Object.assign(Object.assign({}, e), { activedata: this.getActiveData(r, A) }));
  }
  /**
   * 回退
   *
   * @author lxm
   * @date 2022-09-30 17:09:51
   * @param {IContext} context 路径参数
   * @param {IParams} params 请求参数
   * @param {IData} data 数据
   * @returns {*}  {Promise<IHttpResponse<IData>>}
   */
  async wfSendBack(A, e, r) {
    return ibiz.net.post(`${this.getBaseUrl()}/${A[this.model.deName]}/tasks/${e.taskId}/sendback`, Object.assign(Object.assign({}, e), { activedata: this.getActiveData(r, A) }));
  }
  /**
   * 抄送
   *
   * @author lxm
   * @date 2022-09-30 17:09:51
   * @param {IContext} context 路径参数
   * @param {IParams} params 请求参数
   * @param {IData} data 数据
   * @returns {*}  {Promise<IHttpResponse<IData>>}
   */
  async wfSendCopy(A, e, r) {
    return ibiz.net.post(`${this.getBaseUrl()}/${A[this.model.deName]}/tasks/${e.taskId}/sendcopy`, Object.assign(Object.assign({}, e), { activedata: this.getActiveData(r, A) }));
  }
  /**
   * 调用工作流接口
   *
   * @author lxm
   * @date 2022-09-30 17:09:38
   * @param {string} methodName 接口名称
   * @param {IContext} context 路径参数
   * @param {IParams} [params={}] 查询参数
   * @param {IData} [data={}] 主数据数据
   * @returns {*}  {Promise<IHttpResponse<IData>>}
   */
  async exec(A, e, r = {}, s = {}) {
    switch (A) {
      case "WFSTART":
        return this.wfStart(e, r, s);
      case "WFSUBMIT":
        return this.wfSubmit(e, r, s);
      case "reassign":
        return this.wfReassign(e, r, s);
      case "addstepbefore":
        return this.wfAddStepBefore(e, r, s);
      case "addstepafter":
        return this.wfAddStepAfter(e, r, s);
      case "sendback":
        return this.wfSendBack(e, r, s);
      case "sendcopy":
        return this.wfSendCopy(e, r, s);
      default:
        throw new ZA(`「${A}」未实现`);
    }
  }
}
var dt;
(function(t) {
  t[t.CREATE = 0] = "CREATE", t[t.UPDATE = 1] = "UPDATE";
})(dt || (dt = {}));
class YA {
  get srfuf() {
    return this.srfkey ? dt.UPDATE : dt.CREATE;
  }
  /**
   * Creates an instance of Entity.
   *
   * @author chitanda
   * @date 2022-10-11 21:10:21
   * @param {IPSAppDataEntity} entity
   * @param {(IData | Entity)} data
   */
  constructor(A, e) {
    Object.defineProperty(this, "entity", {
      enumerable: !1,
      value: A
    }), Object.defineProperty(this, "data", {
      enumerable: !1,
      value: e instanceof YA ? HA(e.data) : HA(e)
    });
    const r = A.getKeyPSAppDEField().codeName.toLowerCase();
    if (!A.getMajorPSAppDEField())
      throw new ZA(`${A.codeName}缺少主信息属性`);
    const s = A.getMajorPSAppDEField().codeName.toLowerCase();
    Object.defineProperty(this, "srfdename", {
      get() {
        return A.codeName;
      }
    }), Object.defineProperty(this, "srfkey", {
      set(n) {
        this.data[r] = n;
      },
      get() {
        return this.data[r];
      }
    }), Object.defineProperty(this, "srfmajortext", {
      set(n) {
        this.data[s] = n;
      },
      get() {
        return this.data[s];
      }
    }), this.defineProperties();
  }
  /**
   * 代理实际数据
   *
   * @author chitanda
   * @date 2022-10-11 22:10:55
   * @protected
   */
  defineProperties() {
    const { data: A } = this, e = {};
    (this.entity.getAllPSAppDEFields() || []).forEach((s) => {
      const n = s.codeName.toLowerCase();
      e[n] = {
        enumerable: !0,
        set(i) {
          A[n] = i;
        },
        get() {
          return A[n];
        }
      };
    }), A && Object.keys(A).length > 0 && Object.keys(A).forEach((s) => {
      e.hasOwnProperty(s) || (e[s] = {
        enumerable: !0,
        set(n) {
          A[s] = n;
        },
        get() {
          return A[s];
        }
      });
    }), Object.defineProperties(this, e);
  }
  /**
   * 克隆数据
   *
   * @author chitanda
   * @date 2022-10-11 00:10:15
   * @return {*}  {Entity}
   */
  clone() {
    return new YA(this.entity, this.data);
  }
  /**
   * 合并参数
   *
   * @author chitanda
   * @date 2022-10-19 11:10:25
   * @param {(IData | Entity)} data
   * @return {*}  {Entity}
   */
  assign(A) {
    return A instanceof YA ? Object.assign(this.data, A.data) : Object.assign(this.data, A), this;
  }
}
class Kt {
  get entity() {
    var A;
    return this._entity || (this._entity = new Er((A = this.dto) === null || A === void 0 ? void 0 : A.getParentPSModelObject("app.dataentity.IPSAppDataEntity"))), this._entity;
  }
  /**
   * Creates an instance of MethodDto.
   *
   * @author chitanda
   * @date 2023-09-07 16:09:48
   * @param {IPSAppDEMethodDTO} [dto]
   * @param {boolean} [isLocalMode]
   */
  constructor(A, e) {
    this.isLocalMode = A, this.dto = e, this.dtoMap = /* @__PURE__ */ new Map(), this.fields = (e == null ? void 0 : e.getPSAppDEMethodDTOFields()) || [];
  }
  /**
   * 请求参数组合 DTO
   *
   * @author chitanda
   * @date 2022-10-10 23:10:33
   * @param {IContext} context
   * @param {IData} data
   * @return {*}  {Promise<IData>}
   */
  async get(A, e) {
    const r = {};
    for (let s = 0; s < this.fields.length; s++) {
      const n = this.fields[s], i = n.codeName.toLowerCase();
      switch (n.type) {
        case "SIMPLE": {
          const a = e[i];
          Ci(a) ? r[i] = null : r[i] = a;
          break;
        }
        case "DTOS": {
          const a = await this.getFieldDto(n), B = n.getRefPSAppDataEntity();
          if (!B)
            break;
          const c = (await ibiz.entityService.getService(B.codeName, A)).local.getList(A);
          if (c) {
            const l = [];
            for (let u = 0; u < c.length; u++)
              l.push(await a.get(A, c[u]));
            r[i] = l;
          }
          break;
        }
        default:
          throw new Gs(n, `未支持的应用实体方法输入属性类型: ${n.type}`);
      }
    }
    return r;
  }
  /**
   * 设置本地 DTO 存储
   *
   * @author chitanda
   * @date 2022-10-10 23:10:50
   * @param {IContext} context
   * @param {IData[]} data
   * @return {*}  {Promise<Entity[]>}
   */
  async sets(A, e) {
    const r = await ibiz.entityService.getService(this.entity.codeName);
    return r.local.clear(A), Promise.all(e.map(async (s) => {
      const n = this.fields.filter((a) => a.type === "DTOS").map(async (a) => {
        const B = a.codeName.toLowerCase(), o = await this.getFieldDto(a), c = s[B];
        c ? await o.sets(A, c) : await o.sets(A, []);
      });
      for (let a = 0; a < n.length; a++)
        await n[a];
      const i = new YA(this.entity.source, s);
      return this.isLocalMode && await r.local.add(A, i), i;
    }));
  }
  /**
   * 获取子属性 DTO
   *
   * @author chitanda
   * @date 2022-10-17 16:10:47
   * @protected
   * @param {IPSAppDEMethodDTOField} field
   * @return {*}  {Promise<MethodDto>}
   */
  async getFieldDto(A) {
    var e;
    if (this.dtoMap.has(A.codeName))
      return this.dtoMap.get(A.codeName);
    await ((e = A.getRefPSAppDataEntity()) === null || e === void 0 ? void 0 : e.fill(!0));
    const r = new Kt(!0, A.getRefPSAppDEMethodDTO());
    return this.dtoMap.set(A.codeName, r), r;
  }
}
function Dt(t) {
  return t.actionType === "BUILTIN" || t.dataSetType === "DATAQUERY";
}
class Tu {
  get isLocalMode() {
    return Dt(this.method);
  }
  /**
   * Creates an instance of MethodInput.
   *
   * @author chitanda
   * @date 2022-10-11 17:10:59
   * @param {AppEntityModel} entity
   * @param {IPSAppDEMethodInput} [input]
   */
  constructor(A, e) {
    this.entity = A, this.method = e;
    const r = e.getPSAppDEMethodInput(), s = r == null ? void 0 : r.getPSAppDEMethodDTO();
    s && (this.dto = new Kt(this.isLocalMode, s));
  }
  /**
   * 处理请求发送参数
   *
   * @author chitanda
   * @date 2022-10-11 14:10:22
   * @param {IContext} context
   * @param {IData} data
   * @return {*}  {Promise<IData>}
   */
  async handle(A, e) {
    return this.dto ? e instanceof Array ? await Promise.all(e.map((s) => this.dto.get(A, s))) : this.dto.get(A, e) : e;
  }
}
class xu {
  get isLocalMode() {
    return Dt(this.method);
  }
  /**
   * Creates an instance of MethodReturn.
   *
   * @author chitanda
   * @date 2022-10-11 17:10:47
   * @param {AppEntityModel} entity
   * @param {IPSAppDEMethodReturn} [output]
   */
  constructor(A, e) {
    this.entity = A, this.method = e;
    const r = e.getPSAppDEMethodReturn(), s = r == null ? void 0 : r.getPSAppDEMethodDTO();
    s && (this.dto = new Kt(this.isLocalMode, s));
  }
  /**
   * 处理请求返回参数
   *
   * @author chitanda
   * @date 2022-10-19 21:10:06
   * @param {IContext} context
   * @param {IData} data
   * @return {*}  {Promise<Entity>}
   */
  async handle(A, e) {
    return this.dto ? (await this.dto.sets(A, [e]))[0] : new YA(this.entity.source, e);
  }
}
class ri {
  /**
   * Creates an instance of Method.
   *
   * @author chitanda
   * @date 2022-10-10 14:10:19
   * @param {AppEntityModel} entity
   * @param {IAppDEMethod} method
   * @param {ServicePathItem[][]} paths
   */
  constructor(A, e, r) {
    this.entity = A, this.method = e, this.paths = r, this.input = new Tu(A, e), this.result = new xu(A, e);
  }
  /**
   * 发送请求
   *
   * @author chitanda
   * @date 2022-10-10 17:10:44
   * @protected
   * @param {string} path
   * @param {IParams} context
   * @param {IData} data
   * @param {IParams} params
   * @return {*}  {Promise<HttpResponse<any>>}
   */
  async request(A, e, r, s) {
    const n = this.method.requestMethod, i = this.method.codeName.toLowerCase();
    let a = null;
    switch (n) {
      case "POST":
        a = await ibiz.net.post(`${A}/${i}`, r, s);
        break;
      case "GET":
        a = await ibiz.net.get(`${A}/${i}`, r, s);
        break;
      case "PUT":
        a = await ibiz.net.put(`${A}/${i}`, r, s);
        break;
      case "DELETE":
        a = await ibiz.net.delete(`${A}/${i}`, r, s);
        break;
      default:
        throw n ? new xr(this.method, `未支持的请求方式: ${n}`) : new xr(this.method, "未配置请求方式");
    }
    return a;
  }
  /**
   * 根据上下文计算当前请求路径
   *
   * @author chitanda
   * @date 2022-08-24 18:08:46
   * @protected
   * @param {IParams} context
   * @return {*}  {string} 拼接结果说明: /祖父实体/祖父实体主键/爷爷实体/爷爷实体主键/父实体/父实体主键/当前实体
   */
  calcPath(A) {
    const e = `/${this.entity.deNamePlural}`;
    return ti(A, this.paths) + e;
  }
  /**
   * 获取当前实体服务
   *
   * @author chitanda
   * @date 2022-10-11 21:10:12
   * @protected
   * @return {*}  {Promise<EntityService>}
   */
  async getService() {
    return this.service || (this.service = await ibiz.entityService.getService(this.entity.codeName)), this.service;
  }
  /**
   * 创建实体
   *
   * @author chitanda
   * @date 2022-10-11 22:10:05
   * @protected
   * @param {(IData | Entity)} data
   * @return {*}  {Entity}
   */
  createEntity(A) {
    return new YA(this.entity.source, A);
  }
}
class Mu extends ri {
  /**
   * 是否为本地模式
   *
   * @author chitanda
   * @date 2023-04-19 16:04:46
   * @readonly
   * @protected
   * @type {boolean}
   */
  get isLocalMode() {
    return Dt(this.method);
  }
  async exec(A, e, r) {
    this.isLocalMode || (Array.isArray(e) ? e = await Promise.all(e.map((n) => this.input.handle(A, n))) : e = await this.input.handle(A, e));
    let s = this.calcPath(A);
    switch (this.method.needResourceKey && (s = `${s}/${A[this.entity.deName]}`), this.method.codeName) {
      case "Create":
        return this.create(A, e, r);
      case "Get":
        return this.get(A, e);
      case "GetDraft":
        return this.getDraft(A, e);
      case "Remove":
        return this.remove(A, e);
      case "Update":
        return this.update(A, e, r);
      case "CreateTemp":
        return this.createTemp(A, e);
      case "GetTemp":
        return this.getTemp(A, e);
      case "GetDraftTemp":
        return this.getDraftTemp(A, e);
      case "RemoveTemp":
        return this.removeTemp(A, e);
      case "UpdateTemp":
        return this.updateTemp(A, e);
      default: {
        const n = await this.request(s, A, e, r);
        return n.data = await this.result.handle(A, n.data), n;
      }
    }
  }
  /**
   * 创建数据
   *
   * @author chitanda
   * @date 2023-09-07 17:09:19
   * @param {IContext} context
   * @param {(IData | IData[])} data
   * @param {IParams} params
   * @return {*}  {Promise<IHttpResponse<Entity>>}
   */
  async create(A, e, r) {
    if (this.isLocalMode)
      return this.createTemp(A, e);
    const s = this.calcPath(A), n = await ibiz.net.post(s, e, r);
    return n.data = await this.result.handle(A, n.data), n;
  }
  /**
   * 删除数据
   *
   * @author chitanda
   * @date 2022-08-24 20:08:56
   * @param {IContext} context
   * @param {IParams} [params]
   * @return {*}  {Promise<IHttpResponse<Entity>>}
   */
  async remove(A, e) {
    if (this.isLocalMode)
      return this.removeTemp(A, e);
    const r = this.calcPath(A);
    return await ibiz.net.delete(`${r}/${A[this.entity.deName]}`, e);
  }
  /**
   * 更新数据
   *
   * @author chitanda
   * @date 2022-09-13 19:09:39
   * @param {IContext} context
   * @param {(IData | Entity)} data
   * @param {IParams} [params={}]
   * @return {*}  {Promise<IHttpResponse<Entity>>}
   */
  async update(A, e, r = {}) {
    if (this.isLocalMode)
      return this.updateTemp(A, this.createEntity(e));
    const s = this.calcPath(A), n = await ibiz.net.put(`${s}/${A[this.entity.deName]}`, e, r);
    return n.data = await this.result.handle(A, n.data), n;
  }
  /**
   * 获取数据
   *
   * @author chitanda
   * @date 2022-08-24 20:08:07
   * @param {IContext} context
   * @param {IParams} [params]
   * @return {*}  {Promise<IHttpResponse<Entity>>}
   */
  async get(A, e = {}) {
    if (this.isLocalMode)
      return this.getTemp(A, e);
    const r = this.calcPath(A), s = await ibiz.net.get(`${r}/${A[this.entity.deName]}`, e);
    return s.data = await this.result.handle(A, s.data), s;
  }
  /**
   * 获取默认数据
   *
   * @author chitanda
   * @date 2022-08-24 20:08:26
   * @param {IContext} context
   * @param {IParams} [params]
   * @return {*}  {Promise<IHttpResponse<IData>>}
   */
  async getDraft(A, e) {
    if (this.isLocalMode)
      return this.getDraftTemp(A, e);
    if (e)
      for (const n in e)
        Object.prototype.hasOwnProperty.call(e, n) && typeof e[n] == "object" && (e[n] = void 0);
    const r = this.calcPath(A), s = await ibiz.net.get(`${r}/getdraft`, e);
    return s.data = await this.result.handle(A, s.data), s;
  }
  /**
   * 新建临时数据
   *
   * @author chitanda
   * @date 2023-09-07 17:09:58
   * @param {IContext} context
   * @param {(IData | IData[])} entity
   * @return {*}  {Promise<IHttpResponse<Entity>>}
   */
  async createTemp(A, e) {
    try {
      const r = await this.getService();
      if (Array.isArray(e)) {
        const n = e.map((a) => r.local.add(A, this.createEntity(a))), i = await Promise.all(n);
        return new J(i);
      }
      const s = await r.local.add(A, this.createEntity(e));
      return new J(s);
    } catch (r) {
      return new J(r, 500);
    }
  }
  /**
   * 获取临时数据默认值
   *
   * @author chitanda
   * @date 2022-08-21 17:08:56
   * @param {IContext} context
   * @param {IParams} [params]
   * @return {*}  {Promise<IHttpResponse<Entity>>}
   */
  async getDraftTemp(A, e) {
    try {
      const r = this.createEntity({});
      return r ? new J(r) : new J(r, 500);
    } catch (r) {
      return new J(r, 500);
    }
  }
  /**
   * 删除临时数据
   *
   * @author chitanda
   * @date 2022-08-21 17:08:11
   * @param {IContext} context
   * @param {IParams} [params]
   * @return {*}  {Promise<IHttpResponse<Entity>>}
   */
  async removeTemp(A, e) {
    try {
      let r = null;
      e && (r = e[this.entity.keyName]), !r && A && (r = A[this.entity.deName]);
      const n = (await this.getService()).local.delete(A, r);
      return n ? new J(n) : new J(n, 500);
    } catch (r) {
      return new J(r, 500);
    }
  }
  /**
   * 更新临时数据
   *
   * @author chitanda
   * @date 2022-08-21 17:08:17
   * @param {IContext} context
   * @param {IData} entity
   * @return {*}  {Promise<IHttpResponse<Entity>>}
   */
  async updateTemp(A, e) {
    try {
      const s = (await this.getService()).local.update(A, this.createEntity(e));
      return s ? new J(s) : new J(s, 500);
    } catch (r) {
      return new J(r, 500);
    }
  }
  /**
   * 获取临时数据
   *
   * @author chitanda
   * @date 2022-08-21 17:08:23
   * @param {IContext} context
   * @param {IParams} [params]
   * @return {*}  {Promise<IHttpResponse<Entity>>}
   */
  async getTemp(A, e) {
    try {
      let r = null;
      e && (r = e[this.entity.keyName]), !r && A && (r = A[this.entity.deName]);
      const n = (await this.getService()).local.get(A, r);
      return n ? new J(n) : new J(n, 500);
    } catch (r) {
      return new J(r, 500);
    }
  }
  /**
   * 批量删除本地数据
   *
   * @param {IContext} context
   * @param {IParams} [params]
   * @return {*}  {Promise<IHttpResponse>}
   */
  async removeBatchTemp(A, e) {
    if (e) {
      const r = e[this.entity.keyName];
      if (r)
        try {
          await (await this.getService()).local.deleteBatch(A, r);
        } catch (s) {
          return new J(s, 500);
        }
    }
    return new J(!0);
  }
}
class Ou extends ri {
  /**
   * 是否为本地模式
   *
   * @author chitanda
   * @date 2023-04-19 16:04:46
   * @readonly
   * @protected
   * @type {boolean}
   */
  get isLocalMode() {
    return Dt(this.method);
  }
  async exec(A, e, r) {
    if (this.isLocalMode) {
      const a = await this.searchLocal(null, new Ku(A, e));
      return new J(a, 200);
    }
    const s = this.calcPath(A), n = await this.request(s, A, e, r), i = n.data || [];
    return n.data = i.map((a) => this.createEntity(a)), n;
  }
  /**
   * 查询本地数据，根据属性
   *
   * @param {IContext} context
   * @param {IParams} params 根据多实体属性查找，例：{ name: '张三', age: 18, parent: null }
   * @return {*}  {Promise<Entity[]>}
   */
  async selectLocal(A, e = {}) {
    let s = (await this.getService()).local.getList(A);
    s = Mr(s, "srfordervalue");
    const n = {}, i = {}, a = {}, B = {};
    e.srfkey && (n.srfkey = kA(e.srfkey), delete e.srfkey);
    for (const c in e)
      if (Object.prototype.hasOwnProperty.call(e, c)) {
        const l = e[c];
        l == null ? (i[c] = kA(null), a[c] = kA(void 0), B[c] = kA("")) : n[c] = kA(l);
      }
    if (!eA(n)) {
      const c = we(n), l = we(i), u = we(a), f = we(B);
      s = s.filter((g) => {
        if (eA(i)) {
          if (c(g))
            return !0;
        } else if (c(g) && (l(g) || u(g) || f(g)))
          return !0;
        return !1;
      });
    }
    return s.map((c) => c.clone());
  }
  /**
   * 搜索本地数据
   *
   * @protected
   * @param {PSDEDQCondEngine | null} cond 查询实例
   * @param {SearchFilter} filter 过滤对象
   * @param {string[]} [queryParamKeys=this.entity.quickSearchKeys] 当前实体支持快速搜索的属性
   * @return {*}  {Promise<Entity[]>}
   */
  async searchLocal(A, e, r = this.entity.quickSearchKeys) {
    const s = await this.getService();
    let n = [];
    A ? (n = s.local.getList(e.context), n.length > 0 && (n = n.filter((l) => A.test(l, e)))) : (n = await this.selectLocal(e.context), n.length > 0 && e.query && e.query !== "" && r && (n = n.filter((l) => {
      const u = new RegExp(e.query);
      for (let f = 0; f < r.length; f += 1) {
        const g = r[f], h = l[g];
        if (u.test(h))
          return !0;
      }
      return !1;
    }))), !uA(e.sortField) && !eA(e.sortField) && (e.sortMode === "DESC" ? n = di(n, e.sortField) : n = Mr(n, e.sortField));
    const { page: i, size: a } = e, B = i * a, o = (i + 1) * a - 1;
    return n.slice(B, o).map((l) => HA(l));
  }
}
class Ru {
  /**
   * Creates an instance of FileService.
   * @author lxm
   * @date 2022-11-25 13:11:49
   * @param {AppEntityModel} model 应用实体
   * @param {ServicePathItem[][]} paths 计算出的资源关系路径
   */
  constructor(A, e) {
    this.model = A, this.paths = e;
  }
  /**
   * 后台导出数据，返回文件流
   *
   * @author lxm
   * @date 2022-11-25 14:11:53
   * @param {IPSDEDataExport} dataExport 导出模型
   * @param {string} fetchAction 查询方法
   * @param {IParams} context 上下文
   * @param {IParams} params 请求参数
   * @returns {*}  {Promise<IHttpResponse<Blob>>}
   */
  exportData(A, e, r, s) {
    const i = `${ti(r, this.paths)}/${this.model.deNamePlural}/exportdata/${e.toLowerCase()}/?srfexporttag=${A.codeName}`;
    return ibiz.net.request(i, {
      method: "post",
      data: s,
      responseType: "blob"
    });
  }
}
class Gu {
  /**
   * Creates an instance of EntityService.
   *
   * @author chitanda
   * @date 2022-08-24 18:08:44
   * @param {AppEntityModel} model 应用实体模型
   * @param {ServicePathItem[][]} paths 计算出的资源关系路径
   */
  constructor(A, e) {
    this.model = A, this.paths = e, this.methodMap = /* @__PURE__ */ new Map(), this.local = new bu(), this.wf = new Su(A), this.file = new Ru(A, e);
  }
  /**
   * 获取实体服务方法实例
   *
   * @author chitanda
   * @date 2022-10-10 14:10:53
   * @protected
   * @param {string} methodName
   * @return {*}  {Method}
   */
  getMethod(A) {
    if (this.methodMap.has(A))
      return this.methodMap.get(A);
    const e = this.model.findPSAppDeMethod(A);
    let r = null;
    switch (e.methodType) {
      case "DEACTION":
        r = new Mu(this.model, e, this.paths);
        break;
      case "FETCH":
      case "FETCHTEMP":
        r = new Ou(this.model, e, this.paths);
        break;
      default:
        throw new Gs(e, `未支持的服务方法类型: ${e.methodType}`);
    }
    return this.methodMap.set(A, r), r;
  }
  /**
   * 执行服务方法
   *
   * @author chitanda
   * @date 2022-09-13 19:09:55
   * @param {string} methodName
   * @param {IParams} context
   * @param {IData} [params={}] 请求参数
   * @param {IParams} [params2={}] 查询参数
   * @return {*}  {Promise<IHttpResponse>}
   */
  exec(A, e, r = {}, s = {}) {
    const n = this.getMethod(A);
    if (n)
      return n.exec(e, r, s);
    throw new ZA(`${this.model.deName}未支持「${A}」方法`);
  }
  getTotal(A) {
    return this.local.getTotal(A) || 0;
  }
  getPath(A, e, r = {}, s = {}) {
    const n = this.getMethod(A);
    if (n)
      return n.exec(e, r, s);
    throw new ZA(`${this.model.deName}未支持「${A}」方法`);
  }
}
class Nu {
  constructor() {
    this.cache = /* @__PURE__ */ new Map(), this.allEntities = /* @__PURE__ */ new Map();
  }
  /**
   * 初始化实体缓存
   *
   * @author chitanda
   * @date 2022-08-18 22:08:56
   * @protected
   * @param {IParams} [context]
   * @return {*}  {Promise<void>}
   */
  async initAllEntities(A) {
    if (this.allEntities.size !== 0)
      return;
    ((await ai(A)).app.getAllPSAppDataEntities() || []).forEach((s) => {
      const n = s.isFill ? s.codeName : s.refM.codeName;
      this.allEntities.set(n, s);
    });
  }
  /**
   * 根据实体标识获取实体服务
   *
   * @author chitanda
   * @date 2022-08-17 23:08:20
   * @param {string} entityCodeName 实体标识
   * @param {IParams} [context] 上下文,用于计算模型所属沙箱环境
   * @return {*}  {Promise<EntityService>}
   */
  async getService(A, e) {
    if (!this.cache.has(A)) {
      await this.initAllEntities(e);
      const r = this.allEntities.get(A);
      if (!r)
        throw new Error(`找不到实体[${A}]模型`);
      await r.fill(!0);
      const s = new Er(r);
      await s.init();
      const n = ibiz.resourcePathUtil.calcPaths(e || {}, A), i = await new Gu(s, n);
      this.cache.set(A, i);
    }
    return this.cache.get(A);
  }
  /**
   * 清理所有服务, 当前临时域下的所有临时数据缓存
   *
   * @description 根据 srfsessionid 作为临时数据域
   * @author chitanda
   * @date 2022-08-18 14:08:48
   * @param {IContext} context
   */
  clearTempCache(A) {
    this.cache.forEach((e) => {
      e.local.clear(A);
    });
  }
}
class Vu extends mi {
  constructor(e) {
    super(e);
    q(this, "SyWFHistoryBase");
    /**
     * 应用的模型
     *
     * @author lxm
     * @date 2022-09-29 14:09:39
     * @private
     * @type {IPSApplication}
     */
    q(this, "appSy");
    this.model = e, this.appSy = e.source.getPSModelService().app;
    const r = ibiz.appData.context;
    this.SyWFHistoryBase = `/wfcoreex/${r.srfsystemid}-app-${this.appSy.codeName.toLowerCase()}/${this.model.source.name.toLowerCase()}`;
  }
  /**
   * 根据业务主键获取工作流程进度
   *
   * @author lxm
   * @date 2022-09-29 14:09:45
   * @param {IContext} context
   * @returns {*}  {Promise<IHttpResponse<IData>>}
   */
  async getWFHistory(e) {
    const r = e[this.model.deName];
    let s = "alls";
    return !ibiz.env.enableWfAllHistory && e.srfprocessinstanceid && (s = e.srfprocessinstanceid), ibiz.net.get(
      `${this.SyWFHistoryBase}/${r}/process-instances/${s}/history`
    );
  }
}
class Pu extends Ii {
  /**
   * Creates an instance of EntityService.
   *
   * @author chitanda
   * @date 2022-08-24 18:08:44
   * @param {AppEntityModel} model 应用实体模型
   * @param {ServicePathItem[][]} paths 计算出的资源关系路径
   */
  constructor(e, r) {
    super(e, r);
    /**
     * 工作流相关服务
     *
     * @author lxm
     * @date 2022-09-29 11:09:28
     * @type {WorkFlowService}
     */
    q(this, "wf");
    this.model = e, this.paths = r, this.wf = new Vu(e);
  }
}
class ku extends Nu {
  /**
   * 根据实体标识获取实体服务
   *
   * @author chitanda
   * @date 2022-08-17 23:08:20
   * @param {string} entityCodeName 实体标识
   * @param {IParams} [context] 上下文,用于计算模型所属沙箱环境
   * @return {*}  {Promise<EntityService>}
   */
  async getService(A, e) {
    if (!this.cache.has(A)) {
      await this.initAllEntities(e);
      const r = this.allEntities.get(A);
      if (!r)
        throw new Error(`找不到实体[${A}]模型`);
      await r.fill(!0);
      const s = new Er(r);
      await s.init();
      const n = ibiz.resourcePathUtil.calcPaths(
        e || {},
        A
      ), i = await new Pu(s, n);
      this.cache.set(A, i);
    }
    return this.cache.get(A);
  }
}
function _u() {
  ibiz.entityService = new ku();
}
const eg = {
  mateUrl: import.meta.url,
  // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
  install(t) {
    Bi.getModelService().then((A) => {
      var r;
      const e = A.app;
      e && e.userParams && e.userParams.autoWidth === "true" && ((r = document.getElementsByClassName("app")[0]) == null || r.classList.add("auto-width"));
    }), Lu.loadStyle(["/style.css"]), _u(), ibiz.register.view.register(
      "VIEW_CUSTOM_SyWfDynaEditView3",
      new bi()
    ), ibiz.register.view.register(
      "VIEW_CUSTOM_SyEditView3",
      new Si()
    ), ibiz.register.uiAction.register(
      "DEUIACTION_ExportAsImagePlugin",
      new au()
    ), ibiz.register.view.register(
      "VIEW_CUSTOM_PresetWFChartView",
      new mu()
    ), t.component("SyFileUpload", du), t.component("SyGridFileUpload", Uu), t.component("SyEditGridFileUpload", Eu), t.component("SyGridFileUploadContainer", Fu), ibiz.register.editor.register(
      "EDITOR_CUSTOMSTYLE_SyFileUpload",
      new Iu()
    ), t.component("CustomSelectItem", Hu), ibiz.register.editor.register(
      "EDITOR_CUSTOMSTYLE_CUSTOM_SELECT_ITEM",
      new yu()
    );
  }
};
export {
  eg as default
};
