var gi = Object.defineProperty;
var wi = (r, A, e) => A in r ? gi(r, A, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[A] = e;
var q = (r, A, e) => (wi(r, typeof A != "symbol" ? A + "" : A, e), e);
import { EditFormModel as fi, ViewType as sA, AppEntityModel as Hr, UnsupportedModelError as _s, DefectModelError as Rr, getModelService as Qi, ModelUtil as hi } from "@ibiz-template/model";
import { ViewMode as Xs, UIActionHandler as Ci, safeRedirect as Js, PluginStaticResource as di } from "@ibiz-template/runtime";
import { useWFStepTraceViewController as Ui, usePropsWatch as Ws, useNamespace as LA, useViewController as yr, getUploadProps as Fi, getEditorEmits as Ys, getGridUploadProps as Ir, getGridEditorEmits as Zs, useClickOutside as pi, useEventListener as Ei, getDataPickerProps as vi } from "@ibiz-template/vue-util";
import { defineComponent as CA, getCurrentInstance as Ft, ref as O, onMounted as mi, h as x, watch as QA, computed as zs, toRefs as Lr } from "vue";
import { createUUID as at, getCookie as Hi, isNilOrEmpty as yi, ascSort as Gr, descSort as Ii } from "qx-util";
import { WFDynaEditView3Controller as Li, EditView3Controller as bi, WFStepTraceViewController as Ki, UploadEditorController as $s, PickerEditorController as Di } from "@ibiz-template/controller";
import { HttpError as js, isImage as Si, uploadFile as Ti, RuntimeError as hA, HttpResponse as S } from "@ibiz-template/core";
import { isEmpty as _, isNil as lA, clone as HA, equals as XA, where as fe } from "ramda";
import { WorkFlowService as xi, EntityService as Mi } from "@ibiz-template/service";
const qs = CA({
  name: "WFStepTraceGrid",
  props: {
    context: Object,
    params: {
      type: Object
    },
    modelPath: {
      type: String,
      required: !0
    },
    modal: {
      type: Object
    },
    deName: {
      type: String,
      required: !0
    },
    modelData: {
      type: fi,
      required: !0
    }
  },
  setup(r) {
    const {
      proxy: A
    } = Ft(), e = Ui(A, r.modelPath);
    Ws(A, "deName", e.setDeName.bind(e));
    const t = LA("wf-step-trace-grid"), s = O([]), n = O([]), i = O([{
      title: "序号",
      key: "index",
      width: 60,
      resizable: !0,
      render: (o, B) => s.value.findIndex((l) => l.id === B.row.id) === -1 ? null : o("span", {
        style: {
          textAlign: "center"
        }
      }, B.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
    }]);
    mi(() => {
      var B, c;
      const o = (c = (B = r.modelData) == null ? void 0 : B.source.getPSControlParam()) == null ? void 0 : c.ctrlParams;
      if (o && o.SHOWCOLUMNS)
        try {
          n.value = JSON.parse(o.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 = (o, B, c = !1) => {
      o.comments.length > 0 && o.comments.forEach((l) => {
        var u, Q, g;
        c && l.type === "启动流程" || B.push({
          id: at(),
          nodeName: o.userTaskName,
          personName: (u = l.authorName) == null ? void 0 : u.replace(/\([^)]*\)[^(]*$/, ""),
          deptName: ((g = (Q = l.authorName) == null ? void 0 : Q.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 o;
      e.data && ((o = e.data.usertasks) == null || o.forEach((B) => {
        if (B.usertasks && B.usertasks.length > 0) {
          if (B.usertasks.length === 1)
            return;
          const c = [];
          B.usertasks.forEach((l) => {
            a(l, c, !0);
          }), s.value.push({
            id: at(),
            nodeName: `${B.userTaskName}`,
            personName: "",
            deptName: "",
            time: "",
            content: "",
            comment: "",
            children: c,
            _showChildren: !0
          });
        } else
          a(B, s.value);
      }), s.value.sort((B, c) => Date.parse(B.time) - Date.parse(c.time)));
    }), {
      c: e,
      ns: t,
      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 Oi extends Li {
  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, t) {
    let s = e;
    return t.singleRowReturn && (s = `return (${s})`), t.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(), t = this.model.source.M.getPSAppViewLogics, s = t == null ? void 0 : t.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 Ni = CA({
  props: {
    context: Object,
    params: {
      type: Object
    },
    modelPath: {
      type: String,
      required: !0
    },
    modal: {
      type: Object
    }
  },
  setup(r) {
    const {
      proxy: A
    } = Ft(), e = yr(A, (i, a) => new Oi(r.modelPath, i, a)), t = LA(`view-${sA.DE_WF_DYNA_EDIT_VIEW3}`.toLowerCase()), s = O(["mainForm"]);
    return {
      c: e,
      ns: t,
      onTabClick: (i) => {
        s.value.includes(i) || s.value.push(i);
      },
      lazyList: s
    };
  },
  render(r) {
    const A = [];
    if (this.c.complete) {
      const {
        activeForm: e
      } = this.c;
      e && this.c.providers[e.name] && A.push(r(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], t = this.c.drPages[e.source.name];
      A.push(r(qs, {
        attrs: {
          context: t.context,
          params: t.params,
          deName: this.c.model.appEntity.source.codeName,
          modal: this.modal,
          modelPath: e.embedView.source.modelPath,
          modelData: this.c.model.form
        }
      }));
    }
    return r("view-base", {
      attrs: {
        controller: this.c
      },
      scopedSlots: {
        toolbar: () => this.c.complete ? [this.c.wfLinks.length > 0 && r("wf-toolbar", {
          attrs: {
            wfLinks: this.c.wfLinks
          },
          on: {
            "wf-link-click": (e) => {
              this.c.onLinkClick(e);
            }
          }
        })] : null
      }
    }, [this.c.complete && r("i-tabs", {
      class: [this.ns.be("", "tab")],
      attrs: {
        name: this.c.model.drTab.source.name
      },
      on: {
        "on-click": this.onTabClick
      }
    }, [r("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 t = this.c.drPages[e.source.name];
      if (!(!t || !t.visible))
        return r("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) && r("ViewShell", {
          attrs: {
            context: t.context,
            params: t.params,
            modal: {
              mode: Xs.EMBED
            },
            modelPath: e.embedView.source.modelPath,
            // 流程跟踪视图用
            deName: this.c.model.appEntity.source.codeName
          },
          on: {
            neuronInit: this.c.nerve.onNeuronInit(e.source.name)
          },
          key: t.key
        })]);
    })])]);
  }
});
class Ri {
  constructor() {
    q(this, "component", Ni);
  }
}
class Gi extends bi {
  constructor() {
    super(...arguments);
    q(this, "drPages", {});
  }
  /**
   * 格式化脚本
   *
   * @protected
   * @param {string} scriptCode
   * @param {IData} options
   * @return {*}  {string}
   * @memberof DynamicVisibleTabController
   */
  formatCode(e, t) {
    let s = e;
    return t.singleRowReturn && (s = `return (${s})`), t.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(), t = this.model.source.M.getPSAppViewLogics, s = t == null ? void 0 : t.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 Vi = CA({
  name: "SyEditView3",
  props: {
    context: Object,
    params: {
      type: Object
    },
    modelPath: {
      type: String,
      required: !0
    },
    modal: {
      type: Object
    }
  },
  setup(r) {
    const {
      proxy: A
    } = Ft(), e = yr(A, (i, a) => new Gi(r.modelPath, i, a)), t = LA("view-deeditview3"), s = O(["mainForm"]);
    return {
      c: e,
      ns: t,
      onTabClick: (i) => {
        s.value.includes(i) || s.value.push(i);
      },
      lazyList: s
    };
  },
  render(r) {
    return r("view-base", {
      attrs: {
        controller: this.c
      }
    }, [this.c.complete && r("i-tabs", {
      class: [this.ns.be("", "tab")],
      attrs: {
        name: this.c.model.drTab.source.name
      },
      on: {
        "on-click": this.onTabClick
      }
    }, [r("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"
      }
    }, [r("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)
      }
    }), r(qs, {
      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 r("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) && r("ViewShell", {
          attrs: {
            context: e.context,
            params: e.params,
            modal: {
              mode: Xs.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 Pi {
  constructor() {
    q(this, "component", Vi);
  }
}
/*!
 * html2canvas 1.4.1 <https://html2canvas.hertzen.com>
 * Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
 * Released under MIT License
 */
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

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

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var rr = function(r, A) {
  return rr = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, t) {
    e.__proto__ = t;
  } || function(e, t) {
    for (var s in t)
      Object.prototype.hasOwnProperty.call(t, s) && (e[s] = t[s]);
  }, rr(r, A);
};
function uA(r, A) {
  if (typeof A != "function" && A !== null)
    throw new TypeError("Class extends value " + String(A) + " is not a constructor or null");
  rr(r, A);
  function e() {
    this.constructor = r;
  }
  r.prototype = A === null ? Object.create(A) : (e.prototype = A.prototype, new e());
}
var sr = function() {
  return sr = Object.assign || function(A) {
    for (var e, t = 1, s = arguments.length; t < s; t++) {
      e = arguments[t];
      for (var n in e)
        Object.prototype.hasOwnProperty.call(e, n) && (A[n] = e[n]);
    }
    return A;
  }, sr.apply(this, arguments);
};
function AA(r, A, e, t) {
  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 {
        B(t.next(c));
      } catch (l) {
        i(l);
      }
    }
    function o(c) {
      try {
        B(t.throw(c));
      } catch (l) {
        i(l);
      }
    }
    function B(c) {
      c.done ? n(c.value) : s(c.value).then(a, o);
    }
    B((t = t.apply(r, A || [])).next());
  });
}
function z(r, A) {
  var e = { label: 0, sent: function() {
    if (n[0] & 1)
      throw n[1];
    return n[1];
  }, trys: [], ops: [] }, t, 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(B) {
    return function(c) {
      return o([B, c]);
    };
  }
  function o(B) {
    if (t)
      throw new TypeError("Generator is already executing.");
    for (; e; )
      try {
        if (t = 1, s && (n = B[0] & 2 ? s.return : B[0] ? s.throw || ((n = s.return) && n.call(s), 0) : s.next) && !(n = n.call(s, B[1])).done)
          return n;
        switch (s = 0, n && (B = [B[0] & 2, n.value]), B[0]) {
          case 0:
          case 1:
            n = B;
            break;
          case 4:
            return e.label++, { value: B[1], done: !1 };
          case 5:
            e.label++, s = B[1], B = [0];
            continue;
          case 7:
            B = e.ops.pop(), e.trys.pop();
            continue;
          default:
            if (n = e.trys, !(n = n.length > 0 && n[n.length - 1]) && (B[0] === 6 || B[0] === 2)) {
              e = 0;
              continue;
            }
            if (B[0] === 3 && (!n || B[1] > n[0] && B[1] < n[3])) {
              e.label = B[1];
              break;
            }
            if (B[0] === 6 && e.label < n[1]) {
              e.label = n[1], n = B;
              break;
            }
            if (n && e.label < n[2]) {
              e.label = n[2], e.ops.push(B);
              break;
            }
            n[2] && e.ops.pop(), e.trys.pop();
            continue;
        }
        B = A.call(r, e);
      } catch (c) {
        B = [6, c], s = 0;
      } finally {
        t = n = 0;
      }
    if (B[0] & 5)
      throw B[1];
    return { value: B[0] ? B[1] : void 0, done: !0 };
  }
}
function Te(r, A, e) {
  if (e || arguments.length === 2)
    for (var t = 0, s = A.length, n; t < s; t++)
      (n || !(t in A)) && (n || (n = Array.prototype.slice.call(A, 0, t)), n[t] = A[t]);
  return r.concat(n || A);
}
var IA = (
  /** @class */
  function() {
    function r(A, e, t, s) {
      this.left = A, this.top = e, this.width = t, this.height = s;
    }
    return r.prototype.add = function(A, e, t, s) {
      return new r(this.left + A, this.top + e, this.width + t, this.height + s);
    }, r.fromClientRect = function(A, e) {
      return new r(e.left + A.windowBounds.left, e.top + A.windowBounds.top, e.width, e.height);
    }, r.fromDOMRectList = function(A, e) {
      var t = Array.from(e).find(function(s) {
        return s.width !== 0;
      });
      return t ? new r(t.left + A.windowBounds.left, t.top + A.windowBounds.top, t.width, t.height) : r.EMPTY;
    }, r.EMPTY = new r(0, 0, 0, 0), r;
  }()
), pt = function(r, A) {
  return IA.fromClientRect(r, A.getBoundingClientRect());
}, ki = function(r) {
  var A = r.body, e = r.documentElement;
  if (!A || !e)
    throw new Error("Unable to get document size");
  var t = 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, t, s);
}, Et = function(r) {
  for (var A = [], e = 0, t = r.length; e < t; ) {
    var s = r.charCodeAt(e++);
    if (s >= 55296 && s <= 56319 && e < t) {
      var n = r.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 r = [], A = 0; A < arguments.length; A++)
    r[A] = arguments[A];
  if (String.fromCodePoint)
    return String.fromCodePoint.apply(String, r);
  var e = r.length;
  if (!e)
    return "";
  for (var t = [], s = -1, n = ""; ++s < e; ) {
    var i = r[s];
    i <= 65535 ? t.push(i) : (i -= 65536, t.push((i >> 10) + 55296, i % 1024 + 56320)), (s + 1 === e || t.length > 16384) && (n += String.fromCharCode.apply(String, t), t.length = 0);
  }
  return n;
}, Vr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", _i = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
for (var xe = 0; xe < Vr.length; xe++)
  _i[Vr.charCodeAt(xe)] = xe;
var Pr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Qe = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
for (var Me = 0; Me < Pr.length; Me++)
  Qe[Pr.charCodeAt(Me)] = Me;
var Xi = function(r) {
  var A = r.length * 0.75, e = r.length, t, s = 0, n, i, a, o;
  r[r.length - 1] === "=" && (A--, r[r.length - 2] === "=" && A--);
  var B = typeof ArrayBuffer < "u" && typeof Uint8Array < "u" && typeof Uint8Array.prototype.slice < "u" ? new ArrayBuffer(A) : new Array(A), c = Array.isArray(B) ? B : new Uint8Array(B);
  for (t = 0; t < e; t += 4)
    n = Qe[r.charCodeAt(t)], i = Qe[r.charCodeAt(t + 1)], a = Qe[r.charCodeAt(t + 2)], o = Qe[r.charCodeAt(t + 3)], c[s++] = n << 2 | i >> 4, c[s++] = (i & 15) << 4 | a >> 2, c[s++] = (a & 3) << 6 | o & 63;
  return B;
}, Ji = function(r) {
  for (var A = r.length, e = [], t = 0; t < A; t += 2)
    e.push(r[t + 1] << 8 | r[t]);
  return e;
}, Wi = function(r) {
  for (var A = r.length, e = [], t = 0; t < A; t += 4)
    e.push(r[t + 3] << 24 | r[t + 2] << 16 | r[t + 1] << 8 | r[t]);
  return e;
}, YA = 5, br = 6 + 5, xt = 2, Yi = br - YA, An = 65536 >> YA, Zi = 1 << YA, Mt = Zi - 1, zi = 1024 >> YA, $i = An + zi, ji = $i, qi = 32, Aa = ji + qi, ea = 65536 >> br, ta = 1 << Yi, ra = ta - 1, kr = function(r, A, e) {
  return r.slice ? r.slice(A, e) : new Uint16Array(Array.prototype.slice.call(r, A, e));
}, sa = function(r, A, e) {
  return r.slice ? r.slice(A, e) : new Uint32Array(Array.prototype.slice.call(r, A, e));
}, na = function(r, A) {
  var e = Xi(r), t = Array.isArray(e) ? Wi(e) : new Uint32Array(e), s = Array.isArray(e) ? Ji(e) : new Uint16Array(e), n = 24, i = kr(s, n / 2, t[4] / 2), a = t[5] === 2 ? kr(s, (n + t[4]) / 2) : sa(t, Math.ceil((n + t[4]) / 4));
  return new ia(t[0], t[1], t[2], t[3], i, a);
}, ia = (
  /** @class */
  function() {
    function r(A, e, t, s, n, i) {
      this.initialValue = A, this.errorValue = e, this.highStart = t, this.highValueIndex = s, this.index = n, this.data = i;
    }
    return r.prototype.get = function(A) {
      var e;
      if (A >= 0) {
        if (A < 55296 || A > 56319 && A <= 65535)
          return e = this.index[A >> YA], e = (e << xt) + (A & Mt), this.data[e];
        if (A <= 65535)
          return e = this.index[An + (A - 55296 >> YA)], e = (e << xt) + (A & Mt), this.data[e];
        if (A < this.highStart)
          return e = Aa - ea + (A >> br), e = this.index[e], e += A >> YA & ra, e = this.index[e], e = (e << xt) + (A & Mt), this.data[e];
        if (A <= 1114111)
          return this.data[this.highValueIndex];
      }
      return this.errorValue;
    }, r;
  }()
), _r = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", aa = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
for (var Oe = 0; Oe < _r.length; Oe++)
  aa[_r.charCodeAt(Oe)] = Oe;
var oa = " ", Xr = 50, Ba = 1, en = 2, tn = 3, ca = 4, la = 5, Jr = 7, rn = 8, Wr = 9, TA = 10, nr = 11, Yr = 12, ir = 13, ua = 14, he = 15, ar = 16, Ne = 17, le = 18, ga = 19, Zr = 20, or = 21, ue = 22, Ot = 23, $A = 24, rA = 25, Ce = 26, de = 27, jA = 28, wa = 29, JA = 30, fa = 31, Re = 32, Ge = 33, Br = 34, cr = 35, lr = 36, Le = 37, ur = 38, rt = 39, st = 40, Nt = 41, sn = 42, Qa = 43, ha = [9001, 65288], nn = "!", K = "×", Ve = "÷", gr = na(oa), EA = [JA, lr], wr = [Ba, en, tn, la], an = [TA, rn], zr = [de, Ce], Ca = wr.concat(an), $r = [ur, rt, st, Br, cr], da = [he, ir], Ua = function(r, A) {
  A === void 0 && (A = "strict");
  var e = [], t = [], s = [];
  return r.forEach(function(n, i) {
    var a = gr.get(n);
    if (a > Xr ? (s.push(!0), a -= Xr) : s.push(!1), ["normal", "auto", "loose"].indexOf(A) !== -1 && [8208, 8211, 12316, 12448].indexOf(n) !== -1)
      return t.push(i), e.push(ar);
    if (a === ca || a === nr) {
      if (i === 0)
        return t.push(i), e.push(JA);
      var o = e[i - 1];
      return Ca.indexOf(o) === -1 ? (t.push(t[i - 1]), e.push(o)) : (t.push(i), e.push(JA));
    }
    if (t.push(i), a === fa)
      return e.push(A === "strict" ? or : Le);
    if (a === sn || a === wa)
      return e.push(JA);
    if (a === Qa)
      return n >= 131072 && n <= 196605 || n >= 196608 && n <= 262141 ? e.push(Le) : e.push(JA);
    e.push(a);
  }), [t, e, s];
}, Rt = function(r, A, e, t) {
  var s = t[e];
  if (Array.isArray(r) ? r.indexOf(s) !== -1 : r === s)
    for (var n = e; n <= t.length; ) {
      n++;
      var i = t[n];
      if (i === A)
        return !0;
      if (i !== TA)
        break;
    }
  if (s === TA)
    for (var n = e; n > 0; ) {
      n--;
      var a = t[n];
      if (Array.isArray(r) ? r.indexOf(a) !== -1 : r === a)
        for (var o = e; o <= t.length; ) {
          o++;
          var i = t[o];
          if (i === A)
            return !0;
          if (i !== TA)
            break;
        }
      if (a !== TA)
        break;
    }
  return !1;
}, jr = function(r, A) {
  for (var e = r; e >= 0; ) {
    var t = A[e];
    if (t === TA)
      e--;
    else
      return t;
  }
  return 0;
}, Fa = function(r, A, e, t, s) {
  if (e[t] === 0)
    return K;
  var n = t - 1;
  if (Array.isArray(s) && s[n] === !0)
    return K;
  var i = n - 1, a = n + 1, o = A[n], B = i >= 0 ? A[i] : 0, c = A[a];
  if (o === en && c === tn)
    return K;
  if (wr.indexOf(o) !== -1)
    return nn;
  if (wr.indexOf(c) !== -1 || an.indexOf(c) !== -1)
    return K;
  if (jr(n, A) === rn)
    return Ve;
  if (gr.get(r[n]) === nr || (o === Re || o === Ge) && gr.get(r[a]) === nr || o === Jr || c === Jr || o === Wr || [TA, ir, he].indexOf(o) === -1 && c === Wr || [Ne, le, ga, $A, jA].indexOf(c) !== -1 || jr(n, A) === ue || Rt(Ot, ue, n, A) || Rt([Ne, le], or, n, A) || Rt(Yr, Yr, n, A))
    return K;
  if (o === TA)
    return Ve;
  if (o === Ot || c === Ot)
    return K;
  if (c === ar || o === ar)
    return Ve;
  if ([ir, he, or].indexOf(c) !== -1 || o === ua || B === lr && da.indexOf(o) !== -1 || o === jA && c === lr || c === Zr || EA.indexOf(c) !== -1 && o === rA || EA.indexOf(o) !== -1 && c === rA || o === de && [Le, Re, Ge].indexOf(c) !== -1 || [Le, Re, Ge].indexOf(o) !== -1 && c === Ce || EA.indexOf(o) !== -1 && zr.indexOf(c) !== -1 || zr.indexOf(o) !== -1 && EA.indexOf(c) !== -1 || // (PR | PO) × ( OP | HY )? NU
  [de, Ce].indexOf(o) !== -1 && (c === rA || [ue, he].indexOf(c) !== -1 && A[a + 1] === rA) || // ( OP | HY ) × NU
  [ue, he].indexOf(o) !== -1 && c === rA || // NU ×	(NU | SY | IS)
  o === rA && [rA, jA, $A].indexOf(c) !== -1)
    return K;
  if ([rA, jA, $A, Ne, le].indexOf(c) !== -1)
    for (var l = n; l >= 0; ) {
      var u = A[l];
      if (u === rA)
        return K;
      if ([jA, $A].indexOf(u) !== -1)
        l--;
      else
        break;
    }
  if ([de, Ce].indexOf(c) !== -1)
    for (var l = [Ne, le].indexOf(o) !== -1 ? i : n; l >= 0; ) {
      var u = A[l];
      if (u === rA)
        return K;
      if ([jA, $A].indexOf(u) !== -1)
        l--;
      else
        break;
    }
  if (ur === o && [ur, rt, Br, cr].indexOf(c) !== -1 || [rt, Br].indexOf(o) !== -1 && [rt, st].indexOf(c) !== -1 || [st, cr].indexOf(o) !== -1 && c === st || $r.indexOf(o) !== -1 && [Zr, Ce].indexOf(c) !== -1 || $r.indexOf(c) !== -1 && o === de || EA.indexOf(o) !== -1 && EA.indexOf(c) !== -1 || o === $A && EA.indexOf(c) !== -1 || EA.concat(rA).indexOf(o) !== -1 && c === ue && ha.indexOf(r[a]) === -1 || EA.concat(rA).indexOf(c) !== -1 && o === le)
    return K;
  if (o === Nt && c === Nt) {
    for (var Q = e[n], g = 1; Q > 0 && (Q--, A[Q] === Nt); )
      g++;
    if (g % 2 !== 0)
      return K;
  }
  return o === Re && c === Ge ? K : Ve;
}, pa = function(r, A) {
  A || (A = { lineBreak: "normal", wordBreak: "normal" });
  var e = Ua(r, A.lineBreak), t = e[0], s = e[1], n = e[2];
  (A.wordBreak === "break-all" || A.wordBreak === "break-word") && (s = s.map(function(a) {
    return [rA, JA, sn].indexOf(a) !== -1 ? Le : a;
  }));
  var i = A.wordBreak === "keep-all" ? n.map(function(a, o) {
    return a && r[o] >= 19968 && r[o] <= 40959;
  }) : void 0;
  return [t, s, i];
}, Ea = (
  /** @class */
  function() {
    function r(A, e, t, s) {
      this.codePoints = A, this.required = e === nn, this.start = t, this.end = s;
    }
    return r.prototype.slice = function() {
      return P.apply(void 0, this.codePoints.slice(this.start, this.end));
    }, r;
  }()
), va = function(r, A) {
  var e = Et(r), t = pa(e, A), s = t[0], n = t[1], i = t[2], a = e.length, o = 0, B = 0;
  return {
    next: function() {
      if (B >= a)
        return { done: !0, value: null };
      for (var c = K; B < a && (c = Fa(e, n, s, ++B, i)) === K; )
        ;
      if (c !== K || B === a) {
        var l = new Ea(e, c, o, B);
        return o = B, { value: l, done: !1 };
      }
      return { done: !0, value: null };
    }
  };
}, ma = 1 << 0, Ha = 1 << 1, De = 1 << 2, qr = 1 << 3, ot = 10, As = 47, ve = 92, ya = 9, Ia = 32, Pe = 34, ge = 61, La = 35, ba = 36, Ka = 37, ke = 39, _e = 40, we = 41, Da = 95, tA = 45, Sa = 33, Ta = 60, xa = 62, Ma = 64, Oa = 91, Na = 93, Ra = 61, Ga = 123, Xe = 63, Va = 125, es = 124, Pa = 126, ka = 128, ts = 65533, Gt = 42, WA = 43, _a = 44, Xa = 58, Ja = 59, be = 46, Wa = 0, Ya = 8, Za = 11, za = 14, $a = 31, ja = 127, wA = -1, on = 48, Bn = 97, cn = 101, qa = 102, Ao = 117, eo = 122, ln = 65, un = 69, gn = 70, to = 85, ro = 90, $ = function(r) {
  return r >= on && r <= 57;
}, so = function(r) {
  return r >= 55296 && r <= 57343;
}, qA = function(r) {
  return $(r) || r >= ln && r <= gn || r >= Bn && r <= qa;
}, no = function(r) {
  return r >= Bn && r <= eo;
}, io = function(r) {
  return r >= ln && r <= ro;
}, ao = function(r) {
  return no(r) || io(r);
}, oo = function(r) {
  return r >= ka;
}, Je = function(r) {
  return r === ot || r === ya || r === Ia;
}, Bt = function(r) {
  return ao(r) || oo(r) || r === Da;
}, rs = function(r) {
  return Bt(r) || $(r) || r === tA;
}, Bo = function(r) {
  return r >= Wa && r <= Ya || r === Za || r >= za && r <= $a || r === ja;
}, SA = function(r, A) {
  return r !== ve ? !1 : A !== ot;
}, We = function(r, A, e) {
  return r === tA ? Bt(A) || SA(A, e) : Bt(r) ? !0 : !!(r === ve && SA(r, A));
}, Vt = function(r, A, e) {
  return r === WA || r === tA ? $(A) ? !0 : A === be && $(e) : $(r === be ? A : r);
}, co = function(r) {
  var A = 0, e = 1;
  (r[A] === WA || r[A] === tA) && (r[A] === tA && (e = -1), A++);
  for (var t = []; $(r[A]); )
    t.push(r[A++]);
  var s = t.length ? parseInt(P.apply(void 0, t), 10) : 0;
  r[A] === be && A++;
  for (var n = []; $(r[A]); )
    n.push(r[A++]);
  var i = n.length, a = i ? parseInt(P.apply(void 0, n), 10) : 0;
  (r[A] === un || r[A] === cn) && A++;
  var o = 1;
  (r[A] === WA || r[A] === tA) && (r[A] === tA && (o = -1), A++);
  for (var B = []; $(r[A]); )
    B.push(r[A++]);
  var c = B.length ? parseInt(P.apply(void 0, B), 10) : 0;
  return e * (s + a * Math.pow(10, -i)) * Math.pow(10, o * c);
}, lo = {
  type: 2
  /* LEFT_PARENTHESIS_TOKEN */
}, uo = {
  type: 3
  /* RIGHT_PARENTHESIS_TOKEN */
}, go = {
  type: 4
  /* COMMA_TOKEN */
}, wo = {
  type: 13
  /* SUFFIX_MATCH_TOKEN */
}, fo = {
  type: 8
  /* PREFIX_MATCH_TOKEN */
}, Qo = {
  type: 21
  /* COLUMN_TOKEN */
}, ho = {
  type: 9
  /* DASH_MATCH_TOKEN */
}, Co = {
  type: 10
  /* INCLUDE_MATCH_TOKEN */
}, Uo = {
  type: 11
  /* LEFT_CURLY_BRACKET_TOKEN */
}, Fo = {
  type: 12
  /* RIGHT_CURLY_BRACKET_TOKEN */
}, po = {
  type: 14
  /* SUBSTRING_MATCH_TOKEN */
}, Ye = {
  type: 23
  /* BAD_URL_TOKEN */
}, Eo = {
  type: 1
  /* BAD_STRING_TOKEN */
}, vo = {
  type: 25
  /* CDO_TOKEN */
}, mo = {
  type: 24
  /* CDC_TOKEN */
}, Ho = {
  type: 26
  /* COLON_TOKEN */
}, yo = {
  type: 27
  /* SEMICOLON_TOKEN */
}, Io = {
  type: 28
  /* LEFT_SQUARE_BRACKET_TOKEN */
}, Lo = {
  type: 29
  /* RIGHT_SQUARE_BRACKET_TOKEN */
}, bo = {
  type: 31
  /* WHITESPACE_TOKEN */
}, fr = {
  type: 32
  /* EOF_TOKEN */
}, wn = (
  /** @class */
  function() {
    function r() {
      this._value = [];
    }
    return r.prototype.write = function(A) {
      this._value = this._value.concat(Et(A));
    }, r.prototype.read = function() {
      for (var A = [], e = this.consumeToken(); e !== fr; )
        A.push(e), e = this.consumeToken();
      return A;
    }, r.prototype.consumeToken = function() {
      var A = this.consumeCodePoint();
      switch (A) {
        case Pe:
          return this.consumeStringToken(Pe);
        case La:
          var e = this.peekCodePoint(0), t = this.peekCodePoint(1), s = this.peekCodePoint(2);
          if (rs(e) || SA(t, s)) {
            var n = We(e, t, s) ? Ha : ma, i = this.consumeName();
            return { type: 5, value: i, flags: n };
          }
          break;
        case ba:
          if (this.peekCodePoint(0) === ge)
            return this.consumeCodePoint(), wo;
          break;
        case ke:
          return this.consumeStringToken(ke);
        case _e:
          return lo;
        case we:
          return uo;
        case Gt:
          if (this.peekCodePoint(0) === ge)
            return this.consumeCodePoint(), po;
          break;
        case WA:
          if (Vt(A, this.peekCodePoint(0), this.peekCodePoint(1)))
            return this.reconsumeCodePoint(A), this.consumeNumericToken();
          break;
        case _a:
          return go;
        case tA:
          var a = A, o = this.peekCodePoint(0), B = this.peekCodePoint(1);
          if (Vt(a, o, B))
            return this.reconsumeCodePoint(A), this.consumeNumericToken();
          if (We(a, o, B))
            return this.reconsumeCodePoint(A), this.consumeIdentLikeToken();
          if (o === tA && B === xa)
            return this.consumeCodePoint(), this.consumeCodePoint(), mo;
          break;
        case be:
          if (Vt(A, this.peekCodePoint(0), this.peekCodePoint(1)))
            return this.reconsumeCodePoint(A), this.consumeNumericToken();
          break;
        case As:
          if (this.peekCodePoint(0) === Gt)
            for (this.consumeCodePoint(); ; ) {
              var c = this.consumeCodePoint();
              if (c === Gt && (c = this.consumeCodePoint(), c === As))
                return this.consumeToken();
              if (c === wA)
                return this.consumeToken();
            }
          break;
        case Xa:
          return Ho;
        case Ja:
          return yo;
        case Ta:
          if (this.peekCodePoint(0) === Sa && this.peekCodePoint(1) === tA && this.peekCodePoint(2) === tA)
            return this.consumeCodePoint(), this.consumeCodePoint(), vo;
          break;
        case Ma:
          var l = this.peekCodePoint(0), u = this.peekCodePoint(1), Q = this.peekCodePoint(2);
          if (We(l, u, Q)) {
            var i = this.consumeName();
            return { type: 7, value: i };
          }
          break;
        case Oa:
          return Io;
        case ve:
          if (SA(A, this.peekCodePoint(0)))
            return this.reconsumeCodePoint(A), this.consumeIdentLikeToken();
          break;
        case Na:
          return Lo;
        case Ra:
          if (this.peekCodePoint(0) === ge)
            return this.consumeCodePoint(), fo;
          break;
        case Ga:
          return Uo;
        case Va:
          return Fo;
        case Ao:
        case to:
          var g = this.peekCodePoint(0), f = this.peekCodePoint(1);
          return g === WA && (qA(f) || f === Xe) && (this.consumeCodePoint(), this.consumeUnicodeRangeToken()), this.reconsumeCodePoint(A), this.consumeIdentLikeToken();
        case es:
          if (this.peekCodePoint(0) === ge)
            return this.consumeCodePoint(), ho;
          if (this.peekCodePoint(0) === es)
            return this.consumeCodePoint(), Qo;
          break;
        case Pa:
          if (this.peekCodePoint(0) === ge)
            return this.consumeCodePoint(), Co;
          break;
        case wA:
          return fr;
      }
      return Je(A) ? (this.consumeWhiteSpace(), bo) : $(A) ? (this.reconsumeCodePoint(A), this.consumeNumericToken()) : Bt(A) ? (this.reconsumeCodePoint(A), this.consumeIdentLikeToken()) : { type: 6, value: P(A) };
    }, r.prototype.consumeCodePoint = function() {
      var A = this._value.shift();
      return typeof A > "u" ? -1 : A;
    }, r.prototype.reconsumeCodePoint = function(A) {
      this._value.unshift(A);
    }, r.prototype.peekCodePoint = function(A) {
      return A >= this._value.length ? -1 : this._value[A];
    }, r.prototype.consumeUnicodeRangeToken = function() {
      for (var A = [], e = this.consumeCodePoint(); qA(e) && A.length < 6; )
        A.push(e), e = this.consumeCodePoint();
      for (var t = !1; e === Xe && A.length < 6; )
        A.push(e), e = this.consumeCodePoint(), t = !0;
      if (t) {
        var s = parseInt(P.apply(void 0, A.map(function(o) {
          return o === Xe ? on : o;
        })), 16), n = parseInt(P.apply(void 0, A.map(function(o) {
          return o === Xe ? gn : o;
        })), 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 };
    }, r.prototype.consumeIdentLikeToken = function() {
      var A = this.consumeName();
      return A.toLowerCase() === "url" && this.peekCodePoint(0) === _e ? (this.consumeCodePoint(), this.consumeUrlToken()) : this.peekCodePoint(0) === _e ? (this.consumeCodePoint(), { type: 19, value: A }) : { type: 20, value: A };
    }, r.prototype.consumeUrlToken = function() {
      var A = [];
      if (this.consumeWhiteSpace(), this.peekCodePoint(0) === wA)
        return { type: 22, value: "" };
      var e = this.peekCodePoint(0);
      if (e === ke || e === Pe) {
        var t = this.consumeStringToken(this.consumeCodePoint());
        return t.type === 0 && (this.consumeWhiteSpace(), this.peekCodePoint(0) === wA || this.peekCodePoint(0) === we) ? (this.consumeCodePoint(), { type: 22, value: t.value }) : (this.consumeBadUrlRemnants(), Ye);
      }
      for (; ; ) {
        var s = this.consumeCodePoint();
        if (s === wA || s === we)
          return { type: 22, value: P.apply(void 0, A) };
        if (Je(s))
          return this.consumeWhiteSpace(), this.peekCodePoint(0) === wA || this.peekCodePoint(0) === we ? (this.consumeCodePoint(), { type: 22, value: P.apply(void 0, A) }) : (this.consumeBadUrlRemnants(), Ye);
        if (s === Pe || s === ke || s === _e || Bo(s))
          return this.consumeBadUrlRemnants(), Ye;
        if (s === ve)
          if (SA(s, this.peekCodePoint(0)))
            A.push(this.consumeEscapedCodePoint());
          else
            return this.consumeBadUrlRemnants(), Ye;
        else
          A.push(s);
      }
    }, r.prototype.consumeWhiteSpace = function() {
      for (; Je(this.peekCodePoint(0)); )
        this.consumeCodePoint();
    }, r.prototype.consumeBadUrlRemnants = function() {
      for (; ; ) {
        var A = this.consumeCodePoint();
        if (A === we || A === wA)
          return;
        SA(A, this.peekCodePoint(0)) && this.consumeEscapedCodePoint();
      }
    }, r.prototype.consumeStringSlice = function(A) {
      for (var e = 5e4, t = ""; A > 0; ) {
        var s = Math.min(e, A);
        t += P.apply(void 0, this._value.splice(0, s)), A -= s;
      }
      return this._value.shift(), t;
    }, r.prototype.consumeStringToken = function(A) {
      var e = "", t = 0;
      do {
        var s = this._value[t];
        if (s === wA || s === void 0 || s === A)
          return e += this.consumeStringSlice(t), { type: 0, value: e };
        if (s === ot)
          return this._value.splice(0, t), Eo;
        if (s === ve) {
          var n = this._value[t + 1];
          n !== wA && n !== void 0 && (n === ot ? (e += this.consumeStringSlice(t), t = -1, this._value.shift()) : SA(s, n) && (e += this.consumeStringSlice(t), e += P(this.consumeEscapedCodePoint()), t = -1));
        }
        t++;
      } while (!0);
    }, r.prototype.consumeNumber = function() {
      var A = [], e = De, t = this.peekCodePoint(0);
      for ((t === WA || t === tA) && A.push(this.consumeCodePoint()); $(this.peekCodePoint(0)); )
        A.push(this.consumeCodePoint());
      t = this.peekCodePoint(0);
      var s = this.peekCodePoint(1);
      if (t === be && $(s))
        for (A.push(this.consumeCodePoint(), this.consumeCodePoint()), e = qr; $(this.peekCodePoint(0)); )
          A.push(this.consumeCodePoint());
      t = this.peekCodePoint(0), s = this.peekCodePoint(1);
      var n = this.peekCodePoint(2);
      if ((t === un || t === cn) && ((s === WA || s === tA) && $(n) || $(s)))
        for (A.push(this.consumeCodePoint(), this.consumeCodePoint()), e = qr; $(this.peekCodePoint(0)); )
          A.push(this.consumeCodePoint());
      return [co(A), e];
    }, r.prototype.consumeNumericToken = function() {
      var A = this.consumeNumber(), e = A[0], t = A[1], s = this.peekCodePoint(0), n = this.peekCodePoint(1), i = this.peekCodePoint(2);
      if (We(s, n, i)) {
        var a = this.consumeName();
        return { type: 15, number: e, flags: t, unit: a };
      }
      return s === Ka ? (this.consumeCodePoint(), { type: 16, number: e, flags: t }) : { type: 17, number: e, flags: t };
    }, r.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());
        Je(this.peekCodePoint(0)) && this.consumeCodePoint();
        var t = parseInt(e, 16);
        return t === 0 || so(t) || t > 1114111 ? ts : t;
      }
      return A === wA ? ts : A;
    }, r.prototype.consumeName = function() {
      for (var A = ""; ; ) {
        var e = this.consumeCodePoint();
        if (rs(e))
          A += P(e);
        else if (SA(e, this.peekCodePoint(0)))
          A += P(this.consumeEscapedCodePoint());
        else
          return this.reconsumeCodePoint(e), A;
      }
    }, r;
  }()
), fn = (
  /** @class */
  function() {
    function r(A) {
      this._tokens = A;
    }
    return r.create = function(A) {
      var e = new wn();
      return e.write(A), new r(e.read());
    }, r.parseValue = function(A) {
      return r.create(A).parseComponentValue();
    }, r.parseValues = function(A) {
      return r.create(A).parseComponentValues();
    }, r.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");
    }, r.prototype.parseComponentValues = function() {
      for (var A = []; ; ) {
        var e = this.consumeComponentValue();
        if (e.type === 32)
          return A;
        A.push(e), A.push();
      }
    }, r.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;
    }, r.prototype.consumeSimpleBlock = function(A) {
      for (var e = { type: A, values: [] }, t = this.consumeToken(); ; ) {
        if (t.type === 32 || Do(t, A))
          return e;
        this.reconsumeToken(t), e.values.push(this.consumeComponentValue()), t = this.consumeToken();
      }
    }, r.prototype.consumeFunction = function(A) {
      for (var e = {
        name: A.value,
        values: [],
        type: 18
        /* FUNCTION */
      }; ; ) {
        var t = this.consumeToken();
        if (t.type === 32 || t.type === 3)
          return e;
        this.reconsumeToken(t), e.values.push(this.consumeComponentValue());
      }
    }, r.prototype.consumeToken = function() {
      var A = this._tokens.shift();
      return typeof A > "u" ? fr : A;
    }, r.prototype.reconsumeToken = function(A) {
      this._tokens.unshift(A);
    }, r;
  }()
), Se = function(r) {
  return r.type === 15;
}, Be = function(r) {
  return r.type === 17;
}, M = function(r) {
  return r.type === 20;
}, Ko = function(r) {
  return r.type === 0;
}, Qr = function(r, A) {
  return M(r) && r.value === A;
}, Qn = function(r) {
  return r.type !== 31;
}, ae = function(r) {
  return r.type !== 31 && r.type !== 4;
}, dA = function(r) {
  var A = [], e = [];
  return r.forEach(function(t) {
    if (t.type === 4) {
      if (e.length === 0)
        throw new Error("Error parsing function args, zero tokens for arg");
      A.push(e), e = [];
      return;
    }
    t.type !== 31 && e.push(t);
  }), e.length && A.push(e), A;
}, Do = function(r, A) {
  return A === 11 && r.type === 12 || A === 28 && r.type === 29 ? !0 : A === 2 && r.type === 3;
}, GA = function(r) {
  return r.type === 17 || r.type === 15;
}, k = function(r) {
  return r.type === 16 || GA(r);
}, hn = function(r) {
  return r.length > 1 ? [r[0], r[1]] : [r[0]];
}, Y = {
  type: 17,
  number: 0,
  flags: De
}, Kr = {
  type: 16,
  number: 50,
  flags: De
}, xA = {
  type: 16,
  number: 100,
  flags: De
}, Ue = function(r, A, e) {
  var t = r[0], s = r[1];
  return [N(t, A), N(typeof s < "u" ? s : t, e)];
}, N = function(r, A) {
  if (r.type === 16)
    return r.number / 100 * A;
  if (Se(r))
    switch (r.unit) {
      case "rem":
      case "em":
        return 16 * r.number;
      case "px":
      default:
        return r.number;
    }
  return r.number;
}, Cn = "deg", dn = "grad", Un = "rad", Fn = "turn", vt = {
  name: "angle",
  parse: function(r, A) {
    if (A.type === 15)
      switch (A.unit) {
        case Cn:
          return Math.PI * A.number / 180;
        case dn:
          return Math.PI / 200 * A.number;
        case Un:
          return A.number;
        case Fn:
          return Math.PI * 2 * A.number;
      }
    throw new Error("Unsupported angle type");
  }
}, pn = function(r) {
  return r.type === 15 && (r.unit === Cn || r.unit === dn || r.unit === Un || r.unit === Fn);
}, En = function(r) {
  var A = r.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 [Y, Y];
    case "to top":
    case "bottom":
      return aA(0);
    case "to bottom left":
    case "to left bottom":
    case "right top":
    case "top right":
      return [Y, xA];
    case "to right":
    case "left":
      return aA(90);
    case "to top left":
    case "to left top":
    case "right bottom":
    case "bottom right":
      return [xA, xA];
    case "to bottom":
    case "top":
      return aA(180);
    case "to top right":
    case "to right top":
    case "left bottom":
    case "bottom left":
      return [xA, Y];
    case "to left":
    case "right":
      return aA(270);
  }
  return 0;
}, aA = function(r) {
  return Math.PI * r / 180;
}, OA = {
  name: "color",
  parse: function(r, A) {
    if (A.type === 18) {
      var e = So[A.name];
      if (typeof e > "u")
        throw new Error('Attempting to parse an unsupported color function "' + A.name + '"');
      return e(r, A.values);
    }
    if (A.type === 5) {
      if (A.value.length === 3) {
        var t = A.value.substring(0, 1), s = A.value.substring(1, 2), n = A.value.substring(2, 3);
        return MA(parseInt(t + t, 16), parseInt(s + s, 16), parseInt(n + n, 16), 1);
      }
      if (A.value.length === 4) {
        var t = A.value.substring(0, 1), s = A.value.substring(1, 2), n = A.value.substring(2, 3), i = A.value.substring(3, 4);
        return MA(parseInt(t + t, 16), parseInt(s + s, 16), parseInt(n + n, 16), parseInt(i + i, 16) / 255);
      }
      if (A.value.length === 6) {
        var t = A.value.substring(0, 2), s = A.value.substring(2, 4), n = A.value.substring(4, 6);
        return MA(parseInt(t, 16), parseInt(s, 16), parseInt(n, 16), 1);
      }
      if (A.value.length === 8) {
        var t = A.value.substring(0, 2), s = A.value.substring(2, 4), n = A.value.substring(4, 6), i = A.value.substring(6, 8);
        return MA(parseInt(t, 16), parseInt(s, 16), parseInt(n, 16), parseInt(i, 16) / 255);
      }
    }
    if (A.type === 20) {
      var a = yA[A.value.toUpperCase()];
      if (typeof a < "u")
        return a;
    }
    return yA.TRANSPARENT;
  }
}, NA = function(r) {
  return (255 & r) === 0;
}, J = function(r) {
  var A = 255 & r, e = 255 & r >> 8, t = 255 & r >> 16, s = 255 & r >> 24;
  return A < 255 ? "rgba(" + s + "," + t + "," + e + "," + A / 255 + ")" : "rgb(" + s + "," + t + "," + e + ")";
}, MA = function(r, A, e, t) {
  return (r << 24 | A << 16 | e << 8 | Math.round(t * 255) << 0) >>> 0;
}, ss = function(r, A) {
  if (r.type === 17)
    return r.number;
  if (r.type === 16) {
    var e = A === 3 ? 1 : 255;
    return A === 3 ? r.number / 100 * e : Math.round(r.number / 100 * e);
  }
  return 0;
}, ns = function(r, A) {
  var e = A.filter(ae);
  if (e.length === 3) {
    var t = e.map(ss), s = t[0], n = t[1], i = t[2];
    return MA(s, n, i, 1);
  }
  if (e.length === 4) {
    var a = e.map(ss), s = a[0], n = a[1], i = a[2], o = a[3];
    return MA(s, n, i, o);
  }
  return 0;
};
function Pt(r, A, e) {
  return e < 0 && (e += 1), e >= 1 && (e -= 1), e < 1 / 6 ? (A - r) * e * 6 + r : e < 1 / 2 ? A : e < 2 / 3 ? (A - r) * 6 * (2 / 3 - e) + r : r;
}
var is = function(r, A) {
  var e = A.filter(ae), t = e[0], s = e[1], n = e[2], i = e[3], a = (t.type === 17 ? aA(t.number) : vt.parse(r, t)) / (Math.PI * 2), o = k(s) ? s.number / 100 : 0, B = k(n) ? n.number / 100 : 0, c = typeof i < "u" && k(i) ? N(i, 1) : 1;
  if (o === 0)
    return MA(B * 255, B * 255, B * 255, 1);
  var l = B <= 0.5 ? B * (o + 1) : B + o - B * o, u = B * 2 - l, Q = Pt(u, l, a + 1 / 3), g = Pt(u, l, a), f = Pt(u, l, a - 1 / 3);
  return MA(Q * 255, g * 255, f * 255, c);
}, So = {
  hsl: is,
  hsla: is,
  rgb: ns,
  rgba: ns
}, me = function(r, A) {
  return OA.parse(r, fn.create(A).parseComponentValue());
}, yA = {
  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
}, To = {
  name: "background-clip",
  initialValue: "border-box",
  prefix: !1,
  type: 1,
  parse: function(r, A) {
    return A.map(function(e) {
      if (M(e))
        switch (e.value) {
          case "padding-box":
            return 1;
          case "content-box":
            return 2;
        }
      return 0;
    });
  }
}, xo = {
  name: "background-color",
  initialValue: "transparent",
  prefix: !1,
  type: 3,
  format: "color"
}, mt = function(r, A) {
  var e = OA.parse(r, A[0]), t = A[1];
  return t && k(t) ? { color: e, stop: t } : { color: e, stop: null };
}, as = function(r, A) {
  var e = r[0], t = r[r.length - 1];
  e.stop === null && (e.stop = Y), t.stop === null && (t.stop = xA);
  for (var s = [], n = 0, i = 0; i < r.length; i++) {
    var a = r[i].stop;
    if (a !== null) {
      var o = N(a, A);
      o > n ? s.push(o) : s.push(n), n = o;
    } else
      s.push(null);
  }
  for (var B = null, i = 0; i < s.length; i++) {
    var c = s[i];
    if (c === null)
      B === null && (B = i);
    else if (B !== null) {
      for (var l = i - B, u = s[B - 1], Q = (c - u) / (l + 1), g = 1; g <= l; g++)
        s[B + g - 1] = Q * g;
      B = null;
    }
  }
  return r.map(function(f, U) {
    var w = f.color;
    return { color: w, stop: Math.max(Math.min(1, s[U] / A), 0) };
  });
}, Mo = function(r, A, e) {
  var t = A / 2, s = e / 2, n = N(r[0], A) - t, i = s - N(r[1], e);
  return (Math.atan2(i, n) + Math.PI * 2) % (Math.PI * 2);
}, Oo = function(r, A, e) {
  var t = typeof r == "number" ? r : Mo(r, A, e), s = Math.abs(A * Math.sin(t)) + Math.abs(e * Math.cos(t)), n = A / 2, i = e / 2, a = s / 2, o = Math.sin(t - Math.PI / 2) * a, B = Math.cos(t - Math.PI / 2) * a;
  return [s, n - B, n + B, i - o, i + o];
}, cA = function(r, A) {
  return Math.sqrt(r * r + A * A);
}, os = function(r, A, e, t, s) {
  var n = [
    [0, 0],
    [0, A],
    [r, 0],
    [r, A]
  ];
  return n.reduce(function(i, a) {
    var o = a[0], B = a[1], c = cA(e - o, t - B);
    return (s ? c < i.optimumDistance : c > i.optimumDistance) ? {
      optimumCorner: a,
      optimumDistance: c
    } : i;
  }, {
    optimumDistance: s ? 1 / 0 : -1 / 0,
    optimumCorner: null
  }).optimumCorner;
}, No = function(r, A, e, t, s) {
  var n = 0, i = 0;
  switch (r.size) {
    case 0:
      r.shape === 0 ? n = i = Math.min(Math.abs(A), Math.abs(A - t), Math.abs(e), Math.abs(e - s)) : r.shape === 1 && (n = Math.min(Math.abs(A), Math.abs(A - t)), i = Math.min(Math.abs(e), Math.abs(e - s)));
      break;
    case 2:
      if (r.shape === 0)
        n = i = Math.min(cA(A, e), cA(A, e - s), cA(A - t, e), cA(A - t, e - s));
      else if (r.shape === 1) {
        var a = Math.min(Math.abs(e), Math.abs(e - s)) / Math.min(Math.abs(A), Math.abs(A - t)), o = os(t, s, A, e, !0), B = o[0], c = o[1];
        n = cA(B - A, (c - e) / a), i = a * n;
      }
      break;
    case 1:
      r.shape === 0 ? n = i = Math.max(Math.abs(A), Math.abs(A - t), Math.abs(e), Math.abs(e - s)) : r.shape === 1 && (n = Math.max(Math.abs(A), Math.abs(A - t)), i = Math.max(Math.abs(e), Math.abs(e - s)));
      break;
    case 3:
      if (r.shape === 0)
        n = i = Math.max(cA(A, e), cA(A, e - s), cA(A - t, e), cA(A - t, e - s));
      else if (r.shape === 1) {
        var a = Math.max(Math.abs(e), Math.abs(e - s)) / Math.max(Math.abs(A), Math.abs(A - t)), l = os(t, s, A, e, !1), B = l[0], c = l[1];
        n = cA(B - A, (c - e) / a), i = a * n;
      }
      break;
  }
  return Array.isArray(r.size) && (n = N(r.size[0], t), i = r.size.length === 2 ? N(r.size[1], s) : n), [n, i];
}, Ro = function(r, A) {
  var e = aA(180), t = [];
  return dA(A).forEach(function(s, n) {
    if (n === 0) {
      var i = s[0];
      if (i.type === 20 && i.value === "to") {
        e = En(s);
        return;
      } else if (pn(i)) {
        e = vt.parse(r, i);
        return;
      }
    }
    var a = mt(r, s);
    t.push(a);
  }), {
    angle: e,
    stops: t,
    type: 1
    /* LINEAR_GRADIENT */
  };
}, Ze = function(r, A) {
  var e = aA(180), t = [];
  return dA(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 = En(s);
        return;
      } else if (pn(i)) {
        e = (vt.parse(r, i) + aA(270)) % aA(360);
        return;
      }
    }
    var a = mt(r, s);
    t.push(a);
  }), {
    angle: e,
    stops: t,
    type: 1
    /* LINEAR_GRADIENT */
  };
}, Go = function(r, A) {
  var e = aA(180), t = [], s = 1, n = 0, i = 3, a = [];
  return dA(A).forEach(function(o, B) {
    var c = o[0];
    if (B === 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 = OA.parse(r, c.values[0]);
        t.push({ stop: Y, color: l });
      } else if (c.name === "to") {
        var l = OA.parse(r, c.values[0]);
        t.push({ stop: xA, color: l });
      } else if (c.name === "color-stop") {
        var u = c.values.filter(ae);
        if (u.length === 2) {
          var l = OA.parse(r, u[1]), Q = u[0];
          Be(Q) && t.push({
            stop: { type: 16, number: Q.number * 100, flags: Q.flags },
            color: l
          });
        }
      }
    }
  }), s === 1 ? {
    angle: (e + aA(180)) % aA(360),
    stops: t,
    type: s
  } : { size: i, shape: n, stops: t, position: a, type: s };
}, vn = "closest-side", mn = "farthest-side", Hn = "closest-corner", yn = "farthest-corner", In = "circle", Ln = "ellipse", bn = "cover", Kn = "contain", Vo = function(r, A) {
  var e = 0, t = 3, s = [], n = [];
  return dA(A).forEach(function(i, a) {
    var o = !0;
    if (a === 0) {
      var B = !1;
      o = i.reduce(function(l, u) {
        if (B)
          if (M(u))
            switch (u.value) {
              case "center":
                return n.push(Kr), l;
              case "top":
              case "left":
                return n.push(Y), l;
              case "right":
              case "bottom":
                return n.push(xA), l;
            }
          else
            (k(u) || GA(u)) && n.push(u);
        else if (M(u))
          switch (u.value) {
            case In:
              return e = 0, !1;
            case Ln:
              return e = 1, !1;
            case "at":
              return B = !0, !1;
            case vn:
              return t = 0, !1;
            case bn:
            case mn:
              return t = 1, !1;
            case Kn:
            case Hn:
              return t = 2, !1;
            case yn:
              return t = 3, !1;
          }
        else if (GA(u) || k(u))
          return Array.isArray(t) || (t = []), t.push(u), !1;
        return l;
      }, o);
    }
    if (o) {
      var c = mt(r, i);
      s.push(c);
    }
  }), {
    size: t,
    shape: e,
    stops: s,
    position: n,
    type: 2
    /* RADIAL_GRADIENT */
  };
}, ze = function(r, A) {
  var e = 0, t = 3, s = [], n = [];
  return dA(A).forEach(function(i, a) {
    var o = !0;
    if (a === 0 ? o = i.reduce(function(c, l) {
      if (M(l))
        switch (l.value) {
          case "center":
            return n.push(Kr), !1;
          case "top":
          case "left":
            return n.push(Y), !1;
          case "right":
          case "bottom":
            return n.push(xA), !1;
        }
      else if (k(l) || GA(l))
        return n.push(l), !1;
      return c;
    }, o) : a === 1 && (o = i.reduce(function(c, l) {
      if (M(l))
        switch (l.value) {
          case In:
            return e = 0, !1;
          case Ln:
            return e = 1, !1;
          case Kn:
          case vn:
            return t = 0, !1;
          case mn:
            return t = 1, !1;
          case Hn:
            return t = 2, !1;
          case bn:
          case yn:
            return t = 3, !1;
        }
      else if (GA(l) || k(l))
        return Array.isArray(t) || (t = []), t.push(l), !1;
      return c;
    }, o)), o) {
      var B = mt(r, i);
      s.push(B);
    }
  }), {
    size: t,
    shape: e,
    stops: s,
    position: n,
    type: 2
    /* RADIAL_GRADIENT */
  };
}, Po = function(r) {
  return r.type === 1;
}, ko = function(r) {
  return r.type === 2;
}, Dr = {
  name: "image",
  parse: function(r, A) {
    if (A.type === 22) {
      var e = {
        url: A.value,
        type: 0
        /* URL */
      };
      return r.cache.addImage(A.value), e;
    }
    if (A.type === 18) {
      var t = Dn[A.name];
      if (typeof t > "u")
        throw new Error('Attempting to parse an unsupported image function "' + A.name + '"');
      return t(r, A.values);
    }
    throw new Error("Unsupported image type " + A.type);
  }
};
function _o(r) {
  return !(r.type === 20 && r.value === "none") && (r.type !== 18 || !!Dn[r.name]);
}
var Dn = {
  "linear-gradient": Ro,
  "-moz-linear-gradient": Ze,
  "-ms-linear-gradient": Ze,
  "-o-linear-gradient": Ze,
  "-webkit-linear-gradient": Ze,
  "radial-gradient": Vo,
  "-moz-radial-gradient": ze,
  "-ms-radial-gradient": ze,
  "-o-radial-gradient": ze,
  "-webkit-radial-gradient": ze,
  "-webkit-gradient": Go
}, Xo = {
  name: "background-image",
  initialValue: "none",
  type: 1,
  prefix: !1,
  parse: function(r, A) {
    if (A.length === 0)
      return [];
    var e = A[0];
    return e.type === 20 && e.value === "none" ? [] : A.filter(function(t) {
      return ae(t) && _o(t);
    }).map(function(t) {
      return Dr.parse(r, t);
    });
  }
}, Jo = {
  name: "background-origin",
  initialValue: "border-box",
  prefix: !1,
  type: 1,
  parse: function(r, A) {
    return A.map(function(e) {
      if (M(e))
        switch (e.value) {
          case "padding-box":
            return 1;
          case "content-box":
            return 2;
        }
      return 0;
    });
  }
}, Wo = {
  name: "background-position",
  initialValue: "0% 0%",
  type: 1,
  prefix: !1,
  parse: function(r, A) {
    return dA(A).map(function(e) {
      return e.filter(k);
    }).map(hn);
  }
}, Yo = {
  name: "background-repeat",
  initialValue: "repeat",
  prefix: !1,
  type: 1,
  parse: function(r, A) {
    return dA(A).map(function(e) {
      return e.filter(M).map(function(t) {
        return t.value;
      }).join(" ");
    }).map(Zo);
  }
}, Zo = function(r) {
  switch (r) {
    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(r) {
  r.AUTO = "auto", r.CONTAIN = "contain", r.COVER = "cover";
})(ie || (ie = {}));
var zo = {
  name: "background-size",
  initialValue: "0",
  prefix: !1,
  type: 1,
  parse: function(r, A) {
    return dA(A).map(function(e) {
      return e.filter($o);
    });
  }
}, $o = function(r) {
  return M(r) || k(r);
}, Ht = function(r) {
  return {
    name: "border-" + r + "-color",
    initialValue: "transparent",
    prefix: !1,
    type: 3,
    format: "color"
  };
}, jo = Ht("top"), qo = Ht("right"), AB = Ht("bottom"), eB = Ht("left"), yt = function(r) {
  return {
    name: "border-radius-" + r,
    initialValue: "0 0",
    prefix: !1,
    type: 1,
    parse: function(A, e) {
      return hn(e.filter(k));
    }
  };
}, tB = yt("top-left"), rB = yt("top-right"), sB = yt("bottom-right"), nB = yt("bottom-left"), It = function(r) {
  return {
    name: "border-" + r + "-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;
    }
  };
}, iB = It("top"), aB = It("right"), oB = It("bottom"), BB = It("left"), Lt = function(r) {
  return {
    name: "border-" + r + "-width",
    initialValue: "0",
    type: 0,
    prefix: !1,
    parse: function(A, e) {
      return Se(e) ? e.number : 0;
    }
  };
}, cB = Lt("top"), lB = Lt("right"), uB = Lt("bottom"), gB = Lt("left"), wB = {
  name: "color",
  initialValue: "transparent",
  prefix: !1,
  type: 3,
  format: "color"
}, fB = {
  name: "direction",
  initialValue: "ltr",
  prefix: !1,
  type: 2,
  parse: function(r, A) {
    switch (A) {
      case "rtl":
        return 1;
      case "ltr":
      default:
        return 0;
    }
  }
}, QB = {
  name: "display",
  initialValue: "inline-block",
  prefix: !1,
  type: 1,
  parse: function(r, A) {
    return A.filter(M).reduce(
      function(e, t) {
        return e | hB(t.value);
      },
      0
      /* NONE */
    );
  }
}, hB = function(r) {
  switch (r) {
    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;
}, CB = {
  name: "float",
  initialValue: "none",
  prefix: !1,
  type: 2,
  parse: function(r, A) {
    switch (A) {
      case "left":
        return 1;
      case "right":
        return 2;
      case "inline-start":
        return 3;
      case "inline-end":
        return 4;
    }
    return 0;
  }
}, dB = {
  name: "letter-spacing",
  initialValue: "0",
  prefix: !1,
  type: 0,
  parse: function(r, A) {
    return A.type === 20 && A.value === "normal" ? 0 : A.type === 17 || A.type === 15 ? A.number : 0;
  }
}, ct;
(function(r) {
  r.NORMAL = "normal", r.STRICT = "strict";
})(ct || (ct = {}));
var UB = {
  name: "line-break",
  initialValue: "normal",
  prefix: !1,
  type: 2,
  parse: function(r, A) {
    switch (A) {
      case "strict":
        return ct.STRICT;
      case "normal":
      default:
        return ct.NORMAL;
    }
  }
}, FB = {
  name: "line-height",
  initialValue: "normal",
  prefix: !1,
  type: 4
  /* TOKEN_VALUE */
}, Bs = function(r, A) {
  return M(r) && r.value === "normal" ? 1.2 * A : r.type === 17 ? A * r.number : k(r) ? N(r, A) : A;
}, pB = {
  name: "list-style-image",
  initialValue: "none",
  type: 0,
  prefix: !1,
  parse: function(r, A) {
    return A.type === 20 && A.value === "none" ? null : Dr.parse(r, A);
  }
}, EB = {
  name: "list-style-position",
  initialValue: "outside",
  prefix: !1,
  type: 2,
  parse: function(r, A) {
    switch (A) {
      case "inside":
        return 0;
      case "outside":
      default:
        return 1;
    }
  }
}, hr = {
  name: "list-style-type",
  initialValue: "none",
  prefix: !1,
  type: 2,
  parse: function(r, 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;
    }
  }
}, bt = function(r) {
  return {
    name: "margin-" + r,
    initialValue: "0",
    prefix: !1,
    type: 4
    /* TOKEN_VALUE */
  };
}, vB = bt("top"), mB = bt("right"), HB = bt("bottom"), yB = bt("left"), IB = {
  name: "overflow",
  initialValue: "visible",
  prefix: !1,
  type: 1,
  parse: function(r, 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;
      }
    });
  }
}, LB = {
  name: "overflow-wrap",
  initialValue: "normal",
  prefix: !1,
  type: 2,
  parse: function(r, A) {
    switch (A) {
      case "break-word":
        return "break-word";
      case "normal":
      default:
        return "normal";
    }
  }
}, Kt = function(r) {
  return {
    name: "padding-" + r,
    initialValue: "0",
    prefix: !1,
    type: 3,
    format: "length-percentage"
  };
}, bB = Kt("top"), KB = Kt("right"), DB = Kt("bottom"), SB = Kt("left"), TB = {
  name: "text-align",
  initialValue: "left",
  prefix: !1,
  type: 2,
  parse: function(r, A) {
    switch (A) {
      case "right":
        return 2;
      case "center":
      case "justify":
        return 1;
      case "left":
      default:
        return 0;
    }
  }
}, xB = {
  name: "position",
  initialValue: "static",
  prefix: !1,
  type: 2,
  parse: function(r, A) {
    switch (A) {
      case "relative":
        return 1;
      case "absolute":
        return 2;
      case "fixed":
        return 3;
      case "sticky":
        return 4;
    }
    return 0;
  }
}, MB = {
  name: "text-shadow",
  initialValue: "none",
  type: 1,
  prefix: !1,
  parse: function(r, A) {
    return A.length === 1 && Qr(A[0], "none") ? [] : dA(A).map(function(e) {
      for (var t = {
        color: yA.TRANSPARENT,
        offsetX: Y,
        offsetY: Y,
        blur: Y
      }, s = 0, n = 0; n < e.length; n++) {
        var i = e[n];
        GA(i) ? (s === 0 ? t.offsetX = i : s === 1 ? t.offsetY = i : t.blur = i, s++) : t.color = OA.parse(r, i);
      }
      return t;
    });
  }
}, OB = {
  name: "text-transform",
  initialValue: "none",
  prefix: !1,
  type: 2,
  parse: function(r, A) {
    switch (A) {
      case "uppercase":
        return 2;
      case "lowercase":
        return 1;
      case "capitalize":
        return 3;
    }
    return 0;
  }
}, NB = {
  name: "transform",
  initialValue: "none",
  prefix: !0,
  type: 0,
  parse: function(r, A) {
    if (A.type === 20 && A.value === "none")
      return null;
    if (A.type === 18) {
      var e = VB[A.name];
      if (typeof e > "u")
        throw new Error('Attempting to parse an unsupported transform function "' + A.name + '"');
      return e(A.values);
    }
    return null;
  }
}, RB = function(r) {
  var A = r.filter(function(e) {
    return e.type === 17;
  }).map(function(e) {
    return e.number;
  });
  return A.length === 6 ? A : null;
}, GB = function(r) {
  var A = r.filter(function(o) {
    return o.type === 17;
  }).map(function(o) {
    return o.number;
  }), e = A[0], t = 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, t, s, n, i, a] : null;
}, VB = {
  matrix: RB,
  matrix3d: GB
}, cs = {
  type: 16,
  number: 50,
  flags: De
}, PB = [cs, cs], kB = {
  name: "transform-origin",
  initialValue: "50% 50%",
  prefix: !0,
  type: 1,
  parse: function(r, A) {
    var e = A.filter(k);
    return e.length !== 2 ? PB : [e[0], e[1]];
  }
}, _B = {
  name: "visible",
  initialValue: "none",
  prefix: !1,
  type: 2,
  parse: function(r, A) {
    switch (A) {
      case "hidden":
        return 1;
      case "collapse":
        return 2;
      case "visible":
      default:
        return 0;
    }
  }
}, He;
(function(r) {
  r.NORMAL = "normal", r.BREAK_ALL = "break-all", r.KEEP_ALL = "keep-all";
})(He || (He = {}));
var XB = {
  name: "word-break",
  initialValue: "normal",
  prefix: !1,
  type: 2,
  parse: function(r, A) {
    switch (A) {
      case "break-all":
        return He.BREAK_ALL;
      case "keep-all":
        return He.KEEP_ALL;
      case "normal":
      default:
        return He.NORMAL;
    }
  }
}, JB = {
  name: "z-index",
  initialValue: "auto",
  prefix: !1,
  type: 0,
  parse: function(r, 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");
  }
}, Sn = {
  name: "time",
  parse: function(r, 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");
  }
}, WB = {
  name: "opacity",
  initialValue: "1",
  type: 0,
  prefix: !1,
  parse: function(r, A) {
    return Be(A) ? A.number : 1;
  }
}, YB = {
  name: "text-decoration-color",
  initialValue: "transparent",
  prefix: !1,
  type: 3,
  format: "color"
}, ZB = {
  name: "text-decoration-line",
  initialValue: "none",
  prefix: !1,
  type: 1,
  parse: function(r, 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;
    });
  }
}, zB = {
  name: "font-family",
  initialValue: "",
  prefix: !1,
  type: 1,
  parse: function(r, A) {
    var e = [], t = [];
    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:
          t.push(e.join(" ")), e.length = 0;
          break;
      }
    }), e.length && t.push(e.join(" ")), t.map(function(s) {
      return s.indexOf(" ") === -1 ? s : "'" + s + "'";
    });
  }
}, $B = {
  name: "font-size",
  initialValue: "0",
  prefix: !1,
  type: 3,
  format: "length"
}, jB = {
  name: "font-weight",
  initialValue: "normal",
  type: 0,
  prefix: !1,
  parse: function(r, A) {
    if (Be(A))
      return A.number;
    if (M(A))
      switch (A.value) {
        case "bold":
          return 700;
        case "normal":
        default:
          return 400;
      }
    return 400;
  }
}, qB = {
  name: "font-variant",
  initialValue: "none",
  type: 1,
  prefix: !1,
  parse: function(r, A) {
    return A.filter(M).map(function(e) {
      return e.value;
    });
  }
}, Ac = {
  name: "font-style",
  initialValue: "normal",
  prefix: !1,
  type: 2,
  parse: function(r, A) {
    switch (A) {
      case "oblique":
        return "oblique";
      case "italic":
        return "italic";
      case "normal":
      default:
        return "normal";
    }
  }
}, X = function(r, A) {
  return (r & A) !== 0;
}, ec = {
  name: "content",
  initialValue: "none",
  type: 1,
  prefix: !1,
  parse: function(r, A) {
    if (A.length === 0)
      return [];
    var e = A[0];
    return e.type === 20 && e.value === "none" ? [] : A;
  }
}, tc = {
  name: "counter-increment",
  initialValue: "none",
  prefix: !0,
  type: 1,
  parse: function(r, A) {
    if (A.length === 0)
      return null;
    var e = A[0];
    if (e.type === 20 && e.value === "none")
      return null;
    for (var t = [], s = A.filter(Qn), n = 0; n < s.length; n++) {
      var i = s[n], a = s[n + 1];
      if (i.type === 20) {
        var o = a && Be(a) ? a.number : 1;
        t.push({ counter: i.value, increment: o });
      }
    }
    return t;
  }
}, rc = {
  name: "counter-reset",
  initialValue: "none",
  prefix: !0,
  type: 1,
  parse: function(r, A) {
    if (A.length === 0)
      return [];
    for (var e = [], t = A.filter(Qn), s = 0; s < t.length; s++) {
      var n = t[s], i = t[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;
  }
}, sc = {
  name: "duration",
  initialValue: "0s",
  prefix: !1,
  type: 1,
  parse: function(r, A) {
    return A.filter(Se).map(function(e) {
      return Sn.parse(r, e);
    });
  }
}, nc = {
  name: "quotes",
  initialValue: "none",
  prefix: !0,
  type: 1,
  parse: function(r, A) {
    if (A.length === 0)
      return null;
    var e = A[0];
    if (e.type === 20 && e.value === "none")
      return null;
    var t = [], s = A.filter(Ko);
    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;
      t.push({ open: i, close: a });
    }
    return t;
  }
}, ls = function(r, A, e) {
  if (!r)
    return "";
  var t = r[Math.min(A, r.length - 1)];
  return t ? e ? t.open : t.close : "";
}, ic = {
  name: "box-shadow",
  initialValue: "none",
  type: 1,
  prefix: !1,
  parse: function(r, A) {
    return A.length === 1 && Qr(A[0], "none") ? [] : dA(A).map(function(e) {
      for (var t = {
        color: 255,
        offsetX: Y,
        offsetY: Y,
        blur: Y,
        spread: Y,
        inset: !1
      }, s = 0, n = 0; n < e.length; n++) {
        var i = e[n];
        Qr(i, "inset") ? t.inset = !0 : GA(i) ? (s === 0 ? t.offsetX = i : s === 1 ? t.offsetY = i : s === 2 ? t.blur = i : t.spread = i, s++) : t.color = OA.parse(r, i);
      }
      return t;
    });
  }
}, ac = {
  name: "paint-order",
  initialValue: "normal",
  prefix: !1,
  type: 1,
  parse: function(r, A) {
    var e = [
      0,
      1,
      2
      /* MARKERS */
    ], t = [];
    return A.filter(M).forEach(function(s) {
      switch (s.value) {
        case "stroke":
          t.push(
            1
            /* STROKE */
          );
          break;
        case "fill":
          t.push(
            0
            /* FILL */
          );
          break;
        case "markers":
          t.push(
            2
            /* MARKERS */
          );
          break;
      }
    }), e.forEach(function(s) {
      t.indexOf(s) === -1 && t.push(s);
    }), t;
  }
}, oc = {
  name: "-webkit-text-stroke-color",
  initialValue: "currentcolor",
  prefix: !1,
  type: 3,
  format: "color"
}, Bc = {
  name: "-webkit-text-stroke-width",
  initialValue: "0",
  type: 0,
  prefix: !1,
  parse: function(r, A) {
    return Se(A) ? A.number : 0;
  }
}, cc = (
  /** @class */
  function() {
    function r(A, e) {
      var t, s;
      this.animationDuration = p(A, sc, e.animationDuration), this.backgroundClip = p(A, To, e.backgroundClip), this.backgroundColor = p(A, xo, e.backgroundColor), this.backgroundImage = p(A, Xo, e.backgroundImage), this.backgroundOrigin = p(A, Jo, e.backgroundOrigin), this.backgroundPosition = p(A, Wo, e.backgroundPosition), this.backgroundRepeat = p(A, Yo, e.backgroundRepeat), this.backgroundSize = p(A, zo, e.backgroundSize), this.borderTopColor = p(A, jo, e.borderTopColor), this.borderRightColor = p(A, qo, e.borderRightColor), this.borderBottomColor = p(A, AB, e.borderBottomColor), this.borderLeftColor = p(A, eB, e.borderLeftColor), this.borderTopLeftRadius = p(A, tB, e.borderTopLeftRadius), this.borderTopRightRadius = p(A, rB, e.borderTopRightRadius), this.borderBottomRightRadius = p(A, sB, e.borderBottomRightRadius), this.borderBottomLeftRadius = p(A, nB, e.borderBottomLeftRadius), this.borderTopStyle = p(A, iB, e.borderTopStyle), this.borderRightStyle = p(A, aB, e.borderRightStyle), this.borderBottomStyle = p(A, oB, e.borderBottomStyle), this.borderLeftStyle = p(A, BB, e.borderLeftStyle), this.borderTopWidth = p(A, cB, e.borderTopWidth), this.borderRightWidth = p(A, lB, e.borderRightWidth), this.borderBottomWidth = p(A, uB, e.borderBottomWidth), this.borderLeftWidth = p(A, gB, e.borderLeftWidth), this.boxShadow = p(A, ic, e.boxShadow), this.color = p(A, wB, e.color), this.direction = p(A, fB, e.direction), this.display = p(A, QB, e.display), this.float = p(A, CB, e.cssFloat), this.fontFamily = p(A, zB, e.fontFamily), this.fontSize = p(A, $B, e.fontSize), this.fontStyle = p(A, Ac, e.fontStyle), this.fontVariant = p(A, qB, e.fontVariant), this.fontWeight = p(A, jB, e.fontWeight), this.letterSpacing = p(A, dB, e.letterSpacing), this.lineBreak = p(A, UB, e.lineBreak), this.lineHeight = p(A, FB, e.lineHeight), this.listStyleImage = p(A, pB, e.listStyleImage), this.listStylePosition = p(A, EB, e.listStylePosition), this.listStyleType = p(A, hr, e.listStyleType), this.marginTop = p(A, vB, e.marginTop), this.marginRight = p(A, mB, e.marginRight), this.marginBottom = p(A, HB, e.marginBottom), this.marginLeft = p(A, yB, e.marginLeft), this.opacity = p(A, WB, e.opacity);
      var n = p(A, IB, e.overflow);
      this.overflowX = n[0], this.overflowY = n[n.length > 1 ? 1 : 0], this.overflowWrap = p(A, LB, e.overflowWrap), this.paddingTop = p(A, bB, e.paddingTop), this.paddingRight = p(A, KB, e.paddingRight), this.paddingBottom = p(A, DB, e.paddingBottom), this.paddingLeft = p(A, SB, e.paddingLeft), this.paintOrder = p(A, ac, e.paintOrder), this.position = p(A, xB, e.position), this.textAlign = p(A, TB, e.textAlign), this.textDecorationColor = p(A, YB, (t = e.textDecorationColor) !== null && t !== void 0 ? t : e.color), this.textDecorationLine = p(A, ZB, (s = e.textDecorationLine) !== null && s !== void 0 ? s : e.textDecoration), this.textShadow = p(A, MB, e.textShadow), this.textTransform = p(A, OB, e.textTransform), this.transform = p(A, NB, e.transform), this.transformOrigin = p(A, kB, e.transformOrigin), this.visibility = p(A, _B, e.visibility), this.webkitTextStrokeColor = p(A, oc, e.webkitTextStrokeColor), this.webkitTextStrokeWidth = p(A, Bc, e.webkitTextStrokeWidth), this.wordBreak = p(A, XB, e.wordBreak), this.zIndex = p(A, JB, e.zIndex);
    }
    return r.prototype.isVisible = function() {
      return this.display > 0 && this.opacity > 0 && this.visibility === 0;
    }, r.prototype.isTransparent = function() {
      return NA(this.backgroundColor);
    }, r.prototype.isTransformed = function() {
      return this.transform !== null;
    }, r.prototype.isPositioned = function() {
      return this.position !== 0;
    }, r.prototype.isPositionedWithZIndex = function() {
      return this.isPositioned() && !this.zIndex.auto;
    }, r.prototype.isFloating = function() {
      return this.float !== 0;
    }, r.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 */
      );
    }, r;
  }()
), lc = (
  /** @class */
  function() {
    function r(A, e) {
      this.content = p(A, ec, e.content), this.quotes = p(A, nc, e.quotes);
    }
    return r;
  }()
), us = (
  /** @class */
  function() {
    function r(A, e) {
      this.counterIncrement = p(A, tc, e.counterIncrement), this.counterReset = p(A, rc, e.counterReset);
    }
    return r;
  }()
), p = function(r, A, e) {
  var t = new wn(), s = e !== null && typeof e < "u" ? e.toString() : A.initialValue;
  t.write(s);
  var n = new fn(t.read());
  switch (A.type) {
    case 2:
      var i = n.parseComponentValue();
      return A.parse(r, M(i) ? i.value : A.initialValue);
    case 0:
      return A.parse(r, n.parseComponentValue());
    case 1:
      return A.parse(r, n.parseComponentValues());
    case 4:
      return n.parseComponentValue();
    case 3:
      switch (A.format) {
        case "angle":
          return vt.parse(r, n.parseComponentValue());
        case "color":
          return OA.parse(r, n.parseComponentValue());
        case "image":
          return Dr.parse(r, n.parseComponentValue());
        case "length":
          var a = n.parseComponentValue();
          return GA(a) ? a : Y;
        case "length-percentage":
          var o = n.parseComponentValue();
          return k(o) ? o : Y;
        case "time":
          return Sn.parse(r, n.parseComponentValue());
      }
      break;
  }
}, uc = "data-html2canvas-debug", gc = function(r) {
  var A = r.getAttribute(uc);
  switch (A) {
    case "all":
      return 1;
    case "clone":
      return 2;
    case "parse":
      return 3;
    case "render":
      return 4;
    default:
      return 0;
  }
}, Cr = function(r, A) {
  var e = gc(r);
  return e === 1 || A === e;
}, UA = (
  /** @class */
  function() {
    function r(A, e) {
      if (this.context = A, this.textNodes = [], this.elements = [], this.flags = 0, Cr(
        e,
        3
        /* PARSE */
      ))
        debugger;
      this.styles = new cc(A, window.getComputedStyle(e, null)), Fr(e) && (this.styles.animationDuration.some(function(t) {
        return t > 0;
      }) && (e.style.animationDuration = "0s"), this.styles.transform !== null && (e.style.transform = "none")), this.bounds = pt(this.context, e), Cr(
        e,
        4
        /* RENDER */
      ) && (this.flags |= 16);
    }
    return r;
  }()
), wc = " ", gs = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Fe = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
for (var $e = 0; $e < gs.length; $e++)
  Fe[gs.charCodeAt($e)] = $e;
var fc = function(r) {
  var A = r.length * 0.75, e = r.length, t, s = 0, n, i, a, o;
  r[r.length - 1] === "=" && (A--, r[r.length - 2] === "=" && A--);
  var B = typeof ArrayBuffer < "u" && typeof Uint8Array < "u" && typeof Uint8Array.prototype.slice < "u" ? new ArrayBuffer(A) : new Array(A), c = Array.isArray(B) ? B : new Uint8Array(B);
  for (t = 0; t < e; t += 4)
    n = Fe[r.charCodeAt(t)], i = Fe[r.charCodeAt(t + 1)], a = Fe[r.charCodeAt(t + 2)], o = Fe[r.charCodeAt(t + 3)], c[s++] = n << 2 | i >> 4, c[s++] = (i & 15) << 4 | a >> 2, c[s++] = (a & 3) << 6 | o & 63;
  return B;
}, Qc = function(r) {
  for (var A = r.length, e = [], t = 0; t < A; t += 2)
    e.push(r[t + 1] << 8 | r[t]);
  return e;
}, hc = function(r) {
  for (var A = r.length, e = [], t = 0; t < A; t += 4)
    e.push(r[t + 3] << 24 | r[t + 2] << 16 | r[t + 1] << 8 | r[t]);
  return e;
}, ZA = 5, Sr = 6 + 5, kt = 2, Cc = Sr - ZA, Tn = 65536 >> ZA, dc = 1 << ZA, _t = dc - 1, Uc = 1024 >> ZA, Fc = Tn + Uc, pc = Fc, Ec = 32, vc = pc + Ec, mc = 65536 >> Sr, Hc = 1 << Cc, yc = Hc - 1, ws = function(r, A, e) {
  return r.slice ? r.slice(A, e) : new Uint16Array(Array.prototype.slice.call(r, A, e));
}, Ic = function(r, A, e) {
  return r.slice ? r.slice(A, e) : new Uint32Array(Array.prototype.slice.call(r, A, e));
}, Lc = function(r, A) {
  var e = fc(r), t = Array.isArray(e) ? hc(e) : new Uint32Array(e), s = Array.isArray(e) ? Qc(e) : new Uint16Array(e), n = 24, i = ws(s, n / 2, t[4] / 2), a = t[5] === 2 ? ws(s, (n + t[4]) / 2) : Ic(t, Math.ceil((n + t[4]) / 4));
  return new bc(t[0], t[1], t[2], t[3], i, a);
}, bc = (
  /** @class */
  function() {
    function r(A, e, t, s, n, i) {
      this.initialValue = A, this.errorValue = e, this.highStart = t, this.highValueIndex = s, this.index = n, this.data = i;
    }
    return r.prototype.get = function(A) {
      var e;
      if (A >= 0) {
        if (A < 55296 || A > 56319 && A <= 65535)
          return e = this.index[A >> ZA], e = (e << kt) + (A & _t), this.data[e];
        if (A <= 65535)
          return e = this.index[Tn + (A - 55296 >> ZA)], e = (e << kt) + (A & _t), this.data[e];
        if (A < this.highStart)
          return e = vc - mc + (A >> Sr), e = this.index[e], e += A >> ZA & yc, e = this.index[e], e = (e << kt) + (A & _t), this.data[e];
        if (A <= 1114111)
          return this.data[this.highValueIndex];
      }
      return this.errorValue;
    }, r;
  }()
), fs = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Kc = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
for (var je = 0; je < fs.length; je++)
  Kc[fs.charCodeAt(je)] = je;
var Dc = 1, Xt = 2, Jt = 3, Qs = 4, hs = 5, Sc = 7, Cs = 8, Wt = 9, Yt = 10, ds = 11, Us = 12, Fs = 13, ps = 14, Zt = 15, Tc = function(r) {
  for (var A = [], e = 0, t = r.length; e < t; ) {
    var s = r.charCodeAt(e++);
    if (s >= 55296 && s <= 56319 && e < t) {
      var n = r.charCodeAt(e++);
      (n & 64512) === 56320 ? A.push(((s & 1023) << 10) + (n & 1023) + 65536) : (A.push(s), e--);
    } else
      A.push(s);
  }
  return A;
}, xc = function() {
  for (var r = [], A = 0; A < arguments.length; A++)
    r[A] = arguments[A];
  if (String.fromCodePoint)
    return String.fromCodePoint.apply(String, r);
  var e = r.length;
  if (!e)
    return "";
  for (var t = [], s = -1, n = ""; ++s < e; ) {
    var i = r[s];
    i <= 65535 ? t.push(i) : (i -= 65536, t.push((i >> 10) + 55296, i % 1024 + 56320)), (s + 1 === e || t.length > 16384) && (n += String.fromCharCode.apply(String, t), t.length = 0);
  }
  return n;
}, Mc = Lc(wc), nA = "×", zt = "÷", Oc = function(r) {
  return Mc.get(r);
}, Nc = function(r, A, e) {
  var t = e - 2, s = A[t], n = A[e - 1], i = A[e];
  if (n === Xt && i === Jt)
    return nA;
  if (n === Xt || n === Jt || n === Qs || i === Xt || i === Jt || i === Qs)
    return zt;
  if (n === Cs && [Cs, Wt, ds, Us].indexOf(i) !== -1 || (n === ds || n === Wt) && (i === Wt || i === Yt) || (n === Us || n === Yt) && i === Yt || i === Fs || i === hs || i === Sc || n === Dc)
    return nA;
  if (n === Fs && i === ps) {
    for (; s === hs; )
      s = A[--t];
    if (s === ps)
      return nA;
  }
  if (n === Zt && i === Zt) {
    for (var a = 0; s === Zt; )
      a++, s = A[--t];
    if (a % 2 === 0)
      return nA;
  }
  return zt;
}, Rc = function(r) {
  var A = Tc(r), e = A.length, t = 0, s = 0, n = A.map(Oc);
  return {
    next: function() {
      if (t >= e)
        return { done: !0, value: null };
      for (var i = nA; t < e && (i = Nc(A, n, ++t)) === nA; )
        ;
      if (i !== nA || t === e) {
        var a = xc.apply(null, A.slice(s, t));
        return s = t, { value: a, done: !1 };
      }
      return { done: !0, value: null };
    }
  };
}, Gc = function(r) {
  for (var A = Rc(r), e = [], t; !(t = A.next()).done; )
    t.value && e.push(t.value.slice());
  return e;
}, Vc = function(r) {
  var A = 123;
  if (r.createRange) {
    var e = r.createRange();
    if (e.getBoundingClientRect) {
      var t = r.createElement("boundtest");
      t.style.height = A + "px", t.style.display = "block", r.body.appendChild(t), e.selectNode(t);
      var s = e.getBoundingClientRect(), n = Math.round(s.height);
      if (r.body.removeChild(t), n === A)
        return !0;
    }
  }
  return !1;
}, Pc = function(r) {
  var A = r.createElement("boundtest");
  A.style.width = "50px", A.style.display = "block", A.style.fontSize = "12px", A.style.letterSpacing = "0px", A.style.wordSpacing = "0px", r.body.appendChild(A);
  var e = r.createRange();
  A.innerHTML = typeof "".repeat == "function" ? "&#128104;".repeat(10) : "";
  var t = A.firstChild, s = Et(t.data).map(function(o) {
    return P(o);
  }), n = 0, i = {}, a = s.every(function(o, B) {
    e.setStart(t, n), e.setEnd(t, n + o.length);
    var c = e.getBoundingClientRect();
    n += o.length;
    var l = c.x > i.x || c.y > i.y;
    return i = c, B === 0 ? !0 : l;
  });
  return r.body.removeChild(A), a;
}, kc = function() {
  return typeof new Image().crossOrigin < "u";
}, _c = function() {
  return typeof new XMLHttpRequest().responseType == "string";
}, Xc = function(r) {
  var A = new Image(), e = r.createElement("canvas"), t = e.getContext("2d");
  if (!t)
    return !1;
  A.src = "data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>";
  try {
    t.drawImage(A, 0, 0), e.toDataURL();
  } catch (s) {
    return !1;
  }
  return !0;
}, Es = function(r) {
  return r[0] === 0 && r[1] === 255 && r[2] === 0 && r[3] === 255;
}, Jc = function(r) {
  var A = r.createElement("canvas"), e = 100;
  A.width = e, A.height = e;
  var t = A.getContext("2d");
  if (!t)
    return Promise.reject(!1);
  t.fillStyle = "rgb(0, 255, 0)", t.fillRect(0, 0, e, e);
  var s = new Image(), n = A.toDataURL();
  s.src = n;
  var i = dr(e, e, 0, 0, s);
  return t.fillStyle = "red", t.fillRect(0, 0, e, e), vs(i).then(function(a) {
    t.drawImage(a, 0, 0);
    var o = t.getImageData(0, 0, e, e).data;
    t.fillStyle = "red", t.fillRect(0, 0, e, e);
    var B = r.createElement("div");
    return B.style.backgroundImage = "url(" + n + ")", B.style.height = e + "px", Es(o) ? vs(dr(e, e, 0, 0, B)) : Promise.reject(!1);
  }).then(function(a) {
    return t.drawImage(a, 0, 0), Es(t.getImageData(0, 0, e, e).data);
  }).catch(function() {
    return !1;
  });
}, dr = function(r, A, e, t, s) {
  var n = "http://www.w3.org/2000/svg", i = document.createElementNS(n, "svg"), a = document.createElementNS(n, "foreignObject");
  return i.setAttributeNS(null, "width", r.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", t.toString()), a.setAttributeNS(null, "externalResourcesRequired", "true"), i.appendChild(a), a.appendChild(s), i;
}, vs = function(r) {
  return new Promise(function(A, e) {
    var t = new Image();
    t.onload = function() {
      return A(t);
    }, t.onerror = e, t.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(new XMLSerializer().serializeToString(r));
  });
}, W = {
  get SUPPORT_RANGE_BOUNDS() {
    var r = Vc(document);
    return Object.defineProperty(W, "SUPPORT_RANGE_BOUNDS", { value: r }), r;
  },
  get SUPPORT_WORD_BREAKING() {
    var r = W.SUPPORT_RANGE_BOUNDS && Pc(document);
    return Object.defineProperty(W, "SUPPORT_WORD_BREAKING", { value: r }), r;
  },
  get SUPPORT_SVG_DRAWING() {
    var r = Xc(document);
    return Object.defineProperty(W, "SUPPORT_SVG_DRAWING", { value: r }), r;
  },
  get SUPPORT_FOREIGNOBJECT_DRAWING() {
    var r = typeof Array.from == "function" && typeof window.fetch == "function" ? Jc(document) : Promise.resolve(!1);
    return Object.defineProperty(W, "SUPPORT_FOREIGNOBJECT_DRAWING", { value: r }), r;
  },
  get SUPPORT_CORS_IMAGES() {
    var r = kc();
    return Object.defineProperty(W, "SUPPORT_CORS_IMAGES", { value: r }), r;
  },
  get SUPPORT_RESPONSE_TYPE() {
    var r = _c();
    return Object.defineProperty(W, "SUPPORT_RESPONSE_TYPE", { value: r }), r;
  },
  get SUPPORT_CORS_XHR() {
    var r = "withCredentials" in new XMLHttpRequest();
    return Object.defineProperty(W, "SUPPORT_CORS_XHR", { value: r }), r;
  },
  get SUPPORT_NATIVE_TEXT_SEGMENTATION() {
    var r = !!(typeof Intl < "u" && Intl.Segmenter);
    return Object.defineProperty(W, "SUPPORT_NATIVE_TEXT_SEGMENTATION", { value: r }), r;
  }
}, ye = (
  /** @class */
  function() {
    function r(A, e) {
      this.text = A, this.bounds = e;
    }
    return r;
  }()
), Wc = function(r, A, e, t) {
  var s = zc(A, e), n = [], i = 0;
  return s.forEach(function(a) {
    if (e.textDecorationLine.length || a.trim().length > 0)
      if (W.SUPPORT_RANGE_BOUNDS) {
        var o = ms(t, i, a.length).getClientRects();
        if (o.length > 1) {
          var B = Tr(a), c = 0;
          B.forEach(function(u) {
            n.push(new ye(u, IA.fromDOMRectList(r, ms(t, c + i, u.length).getClientRects()))), c += u.length;
          });
        } else
          n.push(new ye(a, IA.fromDOMRectList(r, o)));
      } else {
        var l = t.splitText(a.length);
        n.push(new ye(a, Yc(r, t))), t = l;
      }
    else
      W.SUPPORT_RANGE_BOUNDS || (t = t.splitText(a.length));
    i += a.length;
  }), n;
}, Yc = function(r, A) {
  var e = A.ownerDocument;
  if (e) {
    var t = e.createElement("html2canvaswrapper");
    t.appendChild(A.cloneNode(!0));
    var s = A.parentNode;
    if (s) {
      s.replaceChild(t, A);
      var n = pt(r, t);
      return t.firstChild && s.replaceChild(t.firstChild, t), n;
    }
  }
  return IA.EMPTY;
}, ms = function(r, A, e) {
  var t = r.ownerDocument;
  if (!t)
    throw new Error("Node has no owner document");
  var s = t.createRange();
  return s.setStart(r, A), s.setEnd(r, A + e), s;
}, Tr = function(r) {
  if (W.SUPPORT_NATIVE_TEXT_SEGMENTATION) {
    var A = new Intl.Segmenter(void 0, { granularity: "grapheme" });
    return Array.from(A.segment(r)).map(function(e) {
      return e.segment;
    });
  }
  return Gc(r);
}, Zc = function(r, A) {
  if (W.SUPPORT_NATIVE_TEXT_SEGMENTATION) {
    var e = new Intl.Segmenter(void 0, {
      granularity: "word"
    });
    return Array.from(e.segment(r)).map(function(t) {
      return t.segment;
    });
  }
  return jc(r, A);
}, zc = function(r, A) {
  return A.letterSpacing !== 0 ? Tr(r) : Zc(r, A);
}, $c = [32, 160, 4961, 65792, 65793, 4153, 4241], jc = function(r, A) {
  for (var e = va(r, {
    lineBreak: A.lineBreak,
    wordBreak: A.overflowWrap === "break-word" ? "break-word" : A.wordBreak
  }), t = [], s, n = function() {
    if (s.value) {
      var i = s.value.slice(), a = Et(i), o = "";
      a.forEach(function(B) {
        $c.indexOf(B) === -1 ? o += P(B) : (o.length && t.push(o), t.push(P(B)), o = "");
      }), o.length && t.push(o);
    }
  }; !(s = e.next()).done; )
    n();
  return t;
}, qc = (
  /** @class */
  function() {
    function r(A, e, t) {
      this.text = Al(e.data, t.textTransform), this.textBounds = Wc(A, this.text, t, e);
    }
    return r;
  }()
), Al = function(r, A) {
  switch (A) {
    case 1:
      return r.toLowerCase();
    case 3:
      return r.replace(el, tl);
    case 2:
      return r.toUpperCase();
    default:
      return r;
  }
}, el = /(^|\s|:|-|\(|\))([a-z])/g, tl = function(r, A, e) {
  return r.length > 0 ? A + e.toUpperCase() : r;
}, xn = (
  /** @class */
  function(r) {
    uA(A, r);
    function A(e, t) {
      var s = r.call(this, e, t) || this;
      return s.src = t.currentSrc || t.src, s.intrinsicWidth = t.naturalWidth, s.intrinsicHeight = t.naturalHeight, s.context.cache.addImage(s.src), s;
    }
    return A;
  }(UA)
), Mn = (
  /** @class */
  function(r) {
    uA(A, r);
    function A(e, t) {
      var s = r.call(this, e, t) || this;
      return s.canvas = t, s.intrinsicWidth = t.width, s.intrinsicHeight = t.height, s;
    }
    return A;
  }(UA)
), On = (
  /** @class */
  function(r) {
    uA(A, r);
    function A(e, t) {
      var s = r.call(this, e, t) || this, n = new XMLSerializer(), i = pt(e, t);
      return t.setAttribute("width", i.width + "px"), t.setAttribute("height", i.height + "px"), s.svg = "data:image/svg+xml," + encodeURIComponent(n.serializeToString(t)), s.intrinsicWidth = t.width.baseVal.value, s.intrinsicHeight = t.height.baseVal.value, s.context.cache.addImage(s.svg), s;
    }
    return A;
  }(UA)
), Nn = (
  /** @class */
  function(r) {
    uA(A, r);
    function A(e, t) {
      var s = r.call(this, e, t) || this;
      return s.value = t.value, s;
    }
    return A;
  }(UA)
), Ur = (
  /** @class */
  function(r) {
    uA(A, r);
    function A(e, t) {
      var s = r.call(this, e, t) || this;
      return s.start = t.start, s.reversed = typeof t.reversed == "boolean" && t.reversed === !0, s;
    }
    return A;
  }(UA)
), rl = [
  {
    type: 15,
    flags: 0,
    unit: "px",
    number: 3
  }
], sl = [
  {
    type: 16,
    flags: 0,
    number: 50
  }
], nl = function(r) {
  return r.width > r.height ? new IA(r.left + (r.width - r.height) / 2, r.top, r.height, r.height) : r.width < r.height ? new IA(r.left, r.top + (r.height - r.width) / 2, r.width, r.width) : r;
}, il = function(r) {
  var A = r.type === al ? new Array(r.value.length + 1).join("•") : r.value;
  return A.length === 0 ? r.placeholder || "" : A;
}, lt = "checkbox", ut = "radio", al = "password", Hs = 707406591, xr = (
  /** @class */
  function(r) {
    uA(A, r);
    function A(e, t) {
      var s = r.call(this, e, t) || this;
      switch (s.type = t.type.toLowerCase(), s.checked = t.checked, s.value = il(t), (s.type === lt || s.type === ut) && (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 = nl(s.bounds)), s.type) {
        case lt:
          s.styles.borderTopRightRadius = s.styles.borderTopLeftRadius = s.styles.borderBottomRightRadius = s.styles.borderBottomLeftRadius = rl;
          break;
        case ut:
          s.styles.borderTopRightRadius = s.styles.borderTopLeftRadius = s.styles.borderBottomRightRadius = s.styles.borderBottomLeftRadius = sl;
          break;
      }
      return s;
    }
    return A;
  }(UA)
), Rn = (
  /** @class */
  function(r) {
    uA(A, r);
    function A(e, t) {
      var s = r.call(this, e, t) || this, n = t.options[t.selectedIndex || 0];
      return s.value = n && n.text || "", s;
    }
    return A;
  }(UA)
), Gn = (
  /** @class */
  function(r) {
    uA(A, r);
    function A(e, t) {
      var s = r.call(this, e, t) || this;
      return s.value = t.value, s;
    }
    return A;
  }(UA)
), Vn = (
  /** @class */
  function(r) {
    uA(A, r);
    function A(e, t) {
      var s = r.call(this, e, t) || this;
      s.src = t.src, s.width = parseInt(t.width, 10) || 0, s.height = parseInt(t.height, 10) || 0, s.backgroundColor = s.styles.backgroundColor;
      try {
        if (t.contentWindow && t.contentWindow.document && t.contentWindow.document.documentElement) {
          s.tree = kn(e, t.contentWindow.document.documentElement);
          var n = t.contentWindow.document.documentElement ? me(e, getComputedStyle(t.contentWindow.document.documentElement).backgroundColor) : yA.TRANSPARENT, i = t.contentWindow.document.body ? me(e, getComputedStyle(t.contentWindow.document.body).backgroundColor) : yA.TRANSPARENT;
          s.backgroundColor = NA(n) ? NA(i) ? s.styles.backgroundColor : i : n;
        }
      } catch (a) {
      }
      return s;
    }
    return A;
  }(UA)
), ol = ["OL", "UL", "MENU"], nt = function(r, A, e, t) {
  for (var s = A.firstChild, n = void 0; s; s = n)
    if (n = s.nextSibling, _n(s) && s.data.trim().length > 0)
      e.textNodes.push(new qc(r, s, e.styles));
    else if (ne(s))
      if (Yn(s) && s.assignedNodes)
        s.assignedNodes().forEach(function(a) {
          return nt(r, a, e, t);
        });
      else {
        var i = Pn(r, s);
        i.styles.isVisible() && (Bl(s, i, t) ? i.flags |= 4 : cl(i.styles) && (i.flags |= 2), ol.indexOf(s.tagName) !== -1 && (i.flags |= 8), e.elements.push(i), s.slot, s.shadowRoot ? nt(r, s.shadowRoot, i, t) : !gt(s) && !Xn(s) && !wt(s) && nt(r, s, i, t));
      }
}, Pn = function(r, A) {
  return pr(A) ? new xn(r, A) : Jn(A) ? new Mn(r, A) : Xn(A) ? new On(r, A) : ll(A) ? new Nn(r, A) : ul(A) ? new Ur(r, A) : gl(A) ? new xr(r, A) : wt(A) ? new Rn(r, A) : gt(A) ? new Gn(r, A) : Wn(A) ? new Vn(r, A) : new UA(r, A);
}, kn = function(r, A) {
  var e = Pn(r, A);
  return e.flags |= 4, nt(r, A, e, e), e;
}, Bl = function(r, A, e) {
  return A.styles.isPositionedWithZIndex() || A.styles.opacity < 1 || A.styles.isTransformed() || Mr(r) && e.styles.isTransparent();
}, cl = function(r) {
  return r.isPositioned() || r.isFloating();
}, _n = function(r) {
  return r.nodeType === Node.TEXT_NODE;
}, ne = function(r) {
  return r.nodeType === Node.ELEMENT_NODE;
}, Fr = function(r) {
  return ne(r) && typeof r.style < "u" && !it(r);
}, it = function(r) {
  return typeof r.className == "object";
}, ll = function(r) {
  return r.tagName === "LI";
}, ul = function(r) {
  return r.tagName === "OL";
}, gl = function(r) {
  return r.tagName === "INPUT";
}, wl = function(r) {
  return r.tagName === "HTML";
}, Xn = function(r) {
  return r.tagName === "svg";
}, Mr = function(r) {
  return r.tagName === "BODY";
}, Jn = function(r) {
  return r.tagName === "CANVAS";
}, ys = function(r) {
  return r.tagName === "VIDEO";
}, pr = function(r) {
  return r.tagName === "IMG";
}, Wn = function(r) {
  return r.tagName === "IFRAME";
}, Is = function(r) {
  return r.tagName === "STYLE";
}, fl = function(r) {
  return r.tagName === "SCRIPT";
}, gt = function(r) {
  return r.tagName === "TEXTAREA";
}, wt = function(r) {
  return r.tagName === "SELECT";
}, Yn = function(r) {
  return r.tagName === "SLOT";
}, Ls = function(r) {
  return r.tagName.indexOf("-") > 0;
}, Ql = (
  /** @class */
  function() {
    function r() {
      this.counters = {};
    }
    return r.prototype.getCounterValue = function(A) {
      var e = this.counters[A];
      return e && e.length ? e[e.length - 1] : 1;
    }, r.prototype.getCounterValues = function(A) {
      var e = this.counters[A];
      return e || [];
    }, r.prototype.pop = function(A) {
      var e = this;
      A.forEach(function(t) {
        return e.counters[t].pop();
      });
    }, r.prototype.parse = function(A) {
      var e = this, t = A.counterIncrement, s = A.counterReset, n = !0;
      t !== null && t.forEach(function(a) {
        var o = e.counters[a.counter];
        o && a.increment !== 0 && (n = !1, o.length || o.push(1), o[Math.max(0, o.length - 1)] += a.increment);
      });
      var i = [];
      return n && s.forEach(function(a) {
        var o = e.counters[a.counter];
        i.push(a.counter), o || (o = e.counters[a.counter] = []), o.push(a.reset);
      }), i;
    }, r;
  }()
), bs = {
  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"]
}, Ks = {
  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: [
    "Ք",
    "Փ",
    "Ւ",
    "Ց",
    "Ր",
    "Տ",
    "Վ",
    "Ս",
    "Ռ",
    "Ջ",
    "Պ",
    "Չ",
    "Ո",
    "Շ",
    "Ն",
    "Յ",
    "Մ",
    "Ճ",
    "Ղ",
    "Ձ",
    "Հ",
    "Կ",
    "Ծ",
    "Խ",
    "Լ",
    "Ի",
    "Ժ",
    "Թ",
    "Ը",
    "Է",
    "Զ",
    "Ե",
    "Դ",
    "Գ",
    "Բ",
    "Ա"
  ]
}, hl = {
  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: [
    "י׳",
    "ט׳",
    "ח׳",
    "ז׳",
    "ו׳",
    "ה׳",
    "ד׳",
    "ג׳",
    "ב׳",
    "א׳",
    "ת",
    "ש",
    "ר",
    "ק",
    "צ",
    "פ",
    "ע",
    "ס",
    "נ",
    "מ",
    "ל",
    "כ",
    "יט",
    "יח",
    "יז",
    "טז",
    "טו",
    "י",
    "ט",
    "ח",
    "ז",
    "ו",
    "ה",
    "ד",
    "ג",
    "ב",
    "א"
  ]
}, Cl = {
  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(r, A, e, t, s, n) {
  return r < A || r > e ? Ke(r, s, n.length > 0) : t.integers.reduce(function(i, a, o) {
    for (; r >= a; )
      r -= a, i += t.values[o];
    return i;
  }, "") + n;
}, Zn = function(r, A, e, t) {
  var s = "";
  do
    e || r--, s = t(r) + s, r /= A;
  while (r * A >= A);
  return s;
}, V = function(r, A, e, t, s) {
  var n = e - A + 1;
  return (r < 0 ? "-" : "") + (Zn(Math.abs(r), n, t, function(i) {
    return P(Math.floor(i % n) + A);
  }) + s);
}, _A = function(r, A, e) {
  e === void 0 && (e = ". ");
  var t = A.length;
  return Zn(Math.abs(r), t, !1, function(s) {
    return A[Math.floor(s % t)];
  }) + e;
}, re = 1 << 0, KA = 1 << 1, DA = 1 << 2, pe = 1 << 3, vA = function(r, A, e, t, s, n) {
  if (r < -9999 || r > 9999)
    return Ke(r, 4, s.length > 0);
  var i = Math.abs(r), a = s;
  if (i === 0)
    return A[0] + a;
  for (var o = 0; i > 0 && o <= 4; o++) {
    var B = i % 10;
    B === 0 && X(n, re) && a !== "" ? a = A[B] + a : B > 1 || B === 1 && o === 0 || B === 1 && o === 1 && X(n, KA) || B === 1 && o === 1 && X(n, DA) && r > 100 || B === 1 && o > 1 && X(n, pe) ? a = A[B] + (o > 0 ? e[o - 1] : "") + a : B === 1 && o > 0 && (a = e[o - 1] + a), i = Math.floor(i / 10);
  }
  return (r < 0 ? t : "") + a;
}, Ds = "十百千萬", Ss = "拾佰仟萬", Ts = "マイナス", $t = "마이너스", Ke = function(r, A, e) {
  var t = 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(r, 48, 57, !0, t);
      return a.length < 4 ? "0" + a : a;
    case 4:
      return _A(r, "〇一二三四五六七八九", s);
    case 6:
      return Ae(r, 1, 3999, bs, 3, t).toLowerCase();
    case 7:
      return Ae(r, 1, 3999, bs, 3, t);
    case 8:
      return V(r, 945, 969, !1, t);
    case 9:
      return V(r, 97, 122, !1, t);
    case 10:
      return V(r, 65, 90, !1, t);
    case 11:
      return V(r, 1632, 1641, !0, t);
    case 12:
    case 49:
      return Ae(r, 1, 9999, Ks, 3, t);
    case 35:
      return Ae(r, 1, 9999, Ks, 3, t).toLowerCase();
    case 13:
      return V(r, 2534, 2543, !0, t);
    case 14:
    case 30:
      return V(r, 6112, 6121, !0, t);
    case 15:
      return _A(r, "子丑寅卯辰巳午未申酉戌亥", s);
    case 16:
      return _A(r, "甲乙丙丁戊己庚辛壬癸", s);
    case 17:
    case 48:
      return vA(r, "零一二三四五六七八九", Ds, "負", s, KA | DA | pe);
    case 47:
      return vA(r, "零壹貳參肆伍陸柒捌玖", Ss, "負", s, re | KA | DA | pe);
    case 42:
      return vA(r, "零一二三四五六七八九", Ds, "负", s, KA | DA | pe);
    case 41:
      return vA(r, "零壹贰叁肆伍陆柒捌玖", Ss, "负", s, re | KA | DA | pe);
    case 26:
      return vA(r, "〇一二三四五六七八九", "十百千万", Ts, s, 0);
    case 25:
      return vA(r, "零壱弐参四伍六七八九", "拾百千万", Ts, s, re | KA | DA);
    case 31:
      return vA(r, "영일이삼사오육칠팔구", "십백천만", $t, n, re | KA | DA);
    case 33:
      return vA(r, "零一二三四五六七八九", "十百千萬", $t, n, 0);
    case 32:
      return vA(r, "零壹貳參四五六七八九", "拾百千", $t, n, re | KA | DA);
    case 18:
      return V(r, 2406, 2415, !0, t);
    case 20:
      return Ae(r, 1, 19999, Cl, 3, t);
    case 21:
      return V(r, 2790, 2799, !0, t);
    case 22:
      return V(r, 2662, 2671, !0, t);
    case 22:
      return Ae(r, 1, 10999, hl, 3, t);
    case 23:
      return _A(r, "あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん");
    case 24:
      return _A(r, "いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす");
    case 27:
      return V(r, 3302, 3311, !0, t);
    case 28:
      return _A(r, "アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン", s);
    case 29:
      return _A(r, "イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス", s);
    case 34:
      return V(r, 3792, 3801, !0, t);
    case 37:
      return V(r, 6160, 6169, !0, t);
    case 38:
      return V(r, 4160, 4169, !0, t);
    case 39:
      return V(r, 2918, 2927, !0, t);
    case 40:
      return V(r, 1776, 1785, !0, t);
    case 43:
      return V(r, 3046, 3055, !0, t);
    case 44:
      return V(r, 3174, 3183, !0, t);
    case 45:
      return V(r, 3664, 3673, !0, t);
    case 46:
      return V(r, 3872, 3881, !0, t);
    case 3:
    default:
      return V(r, 48, 57, !0, t);
  }
}, zn = "data-html2canvas-ignore", xs = (
  /** @class */
  function() {
    function r(A, e, t) {
      if (this.context = A, this.options = t, this.scrolledElements = [], this.referenceElement = e, this.counters = new Ql(), 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 r.prototype.toIFrame = function(A, e) {
      var t = this, s = dl(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, o = a.document, B = pl(s).then(function() {
        return AA(t, void 0, void 0, function() {
          var c, l;
          return z(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")] : o.fonts && o.fonts.ready ? [4, o.fonts.ready] : [3, 2];
              case 1:
                u.sent(), u.label = 2;
              case 2:
                return /(AppleWebKit)/g.test(navigator.userAgent) ? [4, Fl(o)] : [3, 4];
              case 3:
                u.sent(), u.label = 4;
              case 4:
                return typeof c == "function" ? [2, Promise.resolve().then(function() {
                  return c(o, l);
                }).then(function() {
                  return s;
                })] : [2, s];
            }
          });
        });
      });
      return o.open(), o.write(vl(document.doctype) + "<html></html>"), ml(this.referenceElement.ownerDocument, n, i), o.replaceChild(o.adoptNode(this.documentElement), o.documentElement), o.close(), B;
    }, r.prototype.createElementClone = function(A) {
      if (Cr(
        A,
        2
        /* CLONE */
      ))
        debugger;
      if (Jn(A))
        return this.createCanvasClone(A);
      if (ys(A))
        return this.createVideoClone(A);
      if (Is(A))
        return this.createStyleClone(A);
      var e = A.cloneNode(!1);
      return pr(e) && (pr(A) && A.currentSrc && A.currentSrc !== A.src && (e.src = A.currentSrc, e.srcset = ""), e.loading === "lazy" && (e.loading = "eager")), Ls(e) ? this.createCustomElementClone(e) : e;
    }, r.prototype.createCustomElementClone = function(A) {
      var e = document.createElement("html2canvascustomelement");
      return jt(A.style, e), e;
    }, r.prototype.createStyleClone = function(A) {
      try {
        var e = A.sheet;
        if (e && e.cssRules) {
          var t = [].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 = t, s;
        }
      } catch (n) {
        if (this.context.logger.error("Unable to access cssRules property", n), n.name !== "SecurityError")
          throw n;
      }
      return A.cloneNode(!1);
    }, r.prototype.createCanvasClone = function(A) {
      var e;
      if (this.options.inlineImages && A.ownerDocument) {
        var t = A.ownerDocument.createElement("img");
        try {
          return t.src = A.toDataURL(), t;
        } catch (B) {
          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 o = a.getContextAttributes();
              (o == null ? void 0 : o.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 (B) {
        this.context.logger.info("Unable to clone canvas as it is tainted", A);
      }
      return s;
    }, r.prototype.createVideoClone = function(A) {
      var e = A.ownerDocument.createElement("canvas");
      e.width = A.offsetWidth, e.height = A.offsetHeight;
      var t = e.getContext("2d");
      try {
        return t && (t.drawImage(A, 0, 0, e.width, e.height), this.options.allowTaint || t.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;
    }, r.prototype.appendChildNode = function(A, e, t) {
      (!ne(e) || !fl(e) && !e.hasAttribute(zn) && (typeof this.options.ignoreElements != "function" || !this.options.ignoreElements(e))) && (!this.options.copyStyles || !ne(e) || !Is(e)) && A.appendChild(this.cloneNode(e, t));
    }, r.prototype.cloneChildNodes = function(A, e, t) {
      for (var s = this, n = A.shadowRoot ? A.shadowRoot.firstChild : A.firstChild; n; n = n.nextSibling)
        if (ne(n) && Yn(n) && typeof n.assignedNodes == "function") {
          var i = n.assignedNodes();
          i.length && i.forEach(function(a) {
            return s.appendChildNode(e, a, t);
          });
        } else
          this.appendChildNode(e, n, t);
    }, r.prototype.cloneNode = function(A, e) {
      if (_n(A))
        return document.createTextNode(A.data);
      if (!A.ownerDocument)
        return A.cloneNode(!1);
      var t = A.ownerDocument.defaultView;
      if (t && ne(A) && (Fr(A) || it(A))) {
        var s = this.createElementClone(A);
        s.style.transitionProperty = "none";
        var n = t.getComputedStyle(A), i = t.getComputedStyle(A, ":before"), a = t.getComputedStyle(A, ":after");
        this.referenceElement === A && Fr(s) && (this.clonedReferenceElement = s), Mr(s) && Ll(s);
        var o = this.counters.parse(new us(this.context, n)), B = this.resolvePseudoContent(A, s, i, Ie.BEFORE);
        Ls(A) && (e = !0), ys(A) || this.cloneChildNodes(A, s, e), B && s.insertBefore(B, s.firstChild);
        var c = this.resolvePseudoContent(A, s, a, Ie.AFTER);
        return c && s.appendChild(c), this.counters.pop(o), (n && (this.options.copyStyles || it(A)) && !Wn(A) || e) && jt(n, s), (A.scrollTop !== 0 || A.scrollLeft !== 0) && this.scrolledElements.push([s, A.scrollLeft, A.scrollTop]), (gt(A) || wt(A)) && (gt(s) || wt(s)) && (s.value = A.value), s;
      }
      return A.cloneNode(!1);
    }, r.prototype.resolvePseudoContent = function(A, e, t, s) {
      var n = this;
      if (t) {
        var i = t.content, a = e.ownerDocument;
        if (!(!a || !i || i === "none" || i === "-moz-alt-content" || t.display === "none")) {
          this.counters.parse(new us(this.context, t));
          var o = new lc(this.context, t), B = a.createElement("html2canvaspseudoelement");
          jt(t, B), o.content.forEach(function(l) {
            if (l.type === 0)
              B.appendChild(a.createTextNode(l.value));
            else if (l.type === 22) {
              var u = a.createElement("img");
              u.src = l.value, u.style.opacity = "1", B.appendChild(u);
            } else if (l.type === 18) {
              if (l.name === "attr") {
                var Q = l.values.filter(M);
                Q.length && B.appendChild(a.createTextNode(A.getAttribute(Q[0].value) || ""));
              } else if (l.name === "counter") {
                var g = l.values.filter(ae), f = g[0], U = g[1];
                if (f && M(f)) {
                  var w = n.counters.getCounterValue(f.value), h = U && M(U) ? hr.parse(n.context, U.value) : 3;
                  B.appendChild(a.createTextNode(Ke(w, h, !1)));
                }
              } else if (l.name === "counters") {
                var v = l.values.filter(ae), f = v[0], m = v[1], U = v[2];
                if (f && M(f)) {
                  var H = n.counters.getCounterValues(f.value), d = U && M(U) ? hr.parse(n.context, U.value) : 3, L = m && m.type === 0 ? m.value : "", b = H.map(function(I) {
                    return Ke(I, d, !1);
                  }).join(L);
                  B.appendChild(a.createTextNode(b));
                }
              }
            } else if (l.type === 20)
              switch (l.value) {
                case "open-quote":
                  B.appendChild(a.createTextNode(ls(o.quotes, n.quoteDepth++, !0)));
                  break;
                case "close-quote":
                  B.appendChild(a.createTextNode(ls(o.quotes, --n.quoteDepth, !1)));
                  break;
                default:
                  B.appendChild(a.createTextNode(l.value));
              }
          }), B.className = Er + " " + vr;
          var c = s === Ie.BEFORE ? " " + Er : " " + vr;
          return it(e) ? e.className.baseValue += c : e.className += c, B;
        }
      }
    }, r.destroy = function(A) {
      return A.parentNode ? (A.parentNode.removeChild(A), !0) : !1;
    }, r;
  }()
), Ie;
(function(r) {
  r[r.BEFORE = 0] = "BEFORE", r[r.AFTER = 1] = "AFTER";
})(Ie || (Ie = {}));
var dl = function(r, A) {
  var e = r.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(zn, "true"), r.body.appendChild(e), e;
}, Ul = function(r) {
  return new Promise(function(A) {
    if (r.complete) {
      A();
      return;
    }
    if (!r.src) {
      A();
      return;
    }
    r.onload = A, r.onerror = A;
  });
}, Fl = function(r) {
  return Promise.all([].slice.call(r.images, 0).map(Ul));
}, pl = function(r) {
  return new Promise(function(A, e) {
    var t = r.contentWindow;
    if (!t)
      return e("No window assigned for iframe");
    var s = t.document;
    t.onload = r.onload = function() {
      t.onload = r.onload = null;
      var n = setInterval(function() {
        s.body.childNodes.length > 0 && s.readyState === "complete" && (clearInterval(n), A(r));
      }, 50);
    };
  });
}, El = [
  "all",
  "d",
  "content"
  // Safari shows pseudoelements if content is set
], jt = function(r, A) {
  for (var e = r.length - 1; e >= 0; e--) {
    var t = r.item(e);
    El.indexOf(t) === -1 && A.style.setProperty(t, r.getPropertyValue(t));
  }
  return A;
}, vl = function(r) {
  var A = "";
  return r && (A += "<!DOCTYPE ", r.name && (A += r.name), r.internalSubset && (A += r.internalSubset), r.publicId && (A += '"' + r.publicId + '"'), r.systemId && (A += '"' + r.systemId + '"'), A += ">"), A;
}, ml = function(r, A, e) {
  r && r.defaultView && (A !== r.defaultView.pageXOffset || e !== r.defaultView.pageYOffset) && r.defaultView.scrollTo(A, e);
}, Hl = function(r) {
  var A = r[0], e = r[1], t = r[2];
  A.scrollLeft = e, A.scrollTop = t;
}, yl = ":before", Il = ":after", Er = "___html2canvas___pseudoelement_before", vr = "___html2canvas___pseudoelement_after", Ms = `{
    content: "" !important;
    display: none !important;
}`, Ll = function(r) {
  bl(r, "." + Er + yl + Ms + `
         .` + vr + Il + Ms);
}, bl = function(r, A) {
  var e = r.ownerDocument;
  if (e) {
    var t = e.createElement("style");
    t.textContent = A, r.appendChild(t);
  }
}, $n = (
  /** @class */
  function() {
    function r() {
    }
    return r.getOrigin = function(A) {
      var e = r._link;
      return e ? (e.href = A, e.href = e.href, e.protocol + e.hostname + e.port) : "about:blank";
    }, r.isSameOrigin = function(A) {
      return r.getOrigin(A) === r._origin;
    }, r.setContext = function(A) {
      r._link = A.document.createElement("a"), r._origin = r.getOrigin(A.location.href);
    }, r._origin = "about:blank", r;
  }()
), Kl = (
  /** @class */
  function() {
    function r(A, e) {
      this.context = A, this._options = e, this._cache = {};
    }
    return r.prototype.addImage = function(A) {
      var e = Promise.resolve();
      return this.has(A) || (Ar(A) || xl(A)) && (this._cache[A] = this.loadImage(A)).catch(function() {
      }), e;
    }, r.prototype.match = function(A) {
      return this._cache[A];
    }, r.prototype.loadImage = function(A) {
      return AA(this, void 0, void 0, function() {
        var e, t, s, n, i = this;
        return z(this, function(a) {
          switch (a.label) {
            case 0:
              return e = $n.isSameOrigin(A), t = !qt(A) && this._options.useCORS === !0 && W.SUPPORT_CORS_IMAGES && !e, s = !qt(A) && !e && !Ar(A) && typeof this._options.proxy == "string" && W.SUPPORT_CORS_XHR && !t, !e && this._options.allowTaint === !1 && !qt(A) && !Ar(A) && !s && !t ? [
                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(o, B) {
                var c = new Image();
                c.onload = function() {
                  return o(c);
                }, c.onerror = B, (Ml(n) || t) && (c.crossOrigin = "anonymous"), c.src = n, c.complete === !0 && setTimeout(function() {
                  return o(c);
                }, 500), i._options.imageTimeout > 0 && setTimeout(function() {
                  return B("Timed out (" + i._options.imageTimeout + "ms) loading image");
                }, i._options.imageTimeout);
              })];
            case 3:
              return [2, a.sent()];
          }
        });
      });
    }, r.prototype.has = function(A) {
      return typeof this._cache[A] < "u";
    }, r.prototype.keys = function() {
      return Promise.resolve(Object.keys(this._cache));
    }, r.prototype.proxy = function(A) {
      var e = this, t = this._options.proxy;
      if (!t)
        throw new Error("No proxy defined");
      var s = A.substring(0, 256);
      return new Promise(function(n, i) {
        var a = W.SUPPORT_RESPONSE_TYPE ? "blob" : "text", o = new XMLHttpRequest();
        o.onload = function() {
          if (o.status === 200)
            if (a === "text")
              n(o.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(o.response);
            }
          else
            i("Failed to proxy resource " + s + " with status code " + o.status);
        }, o.onerror = i;
        var B = t.indexOf("?") > -1 ? "&" : "?";
        if (o.open("GET", "" + t + B + "url=" + encodeURIComponent(A) + "&responseType=" + a), a !== "text" && o instanceof XMLHttpRequest && (o.responseType = a), e._options.imageTimeout) {
          var c = e._options.imageTimeout;
          o.timeout = c, o.ontimeout = function() {
            return i("Timed out (" + c + "ms) proxying " + s);
          };
        }
        o.send();
      });
    }, r;
  }()
), Dl = /^data:image\/svg\+xml/i, Sl = /^data:image\/.*;base64,/i, Tl = /^data:image\/.*/i, xl = function(r) {
  return W.SUPPORT_SVG_DRAWING || !Ol(r);
}, qt = function(r) {
  return Tl.test(r);
}, Ml = function(r) {
  return Sl.test(r);
}, Ar = function(r) {
  return r.substr(0, 4) === "blob";
}, Ol = function(r) {
  return r.substr(-3).toLowerCase() === "svg" || Dl.test(r);
}, F = (
  /** @class */
  function() {
    function r(A, e) {
      this.type = 0, this.x = A, this.y = e;
    }
    return r.prototype.add = function(A, e) {
      return new r(this.x + A, this.y + e);
    }, r;
  }()
), ee = function(r, A, e) {
  return new F(r.x + (A.x - r.x) * e, r.y + (A.y - r.y) * e);
}, qe = (
  /** @class */
  function() {
    function r(A, e, t, s) {
      this.type = 1, this.start = A, this.startControl = e, this.endControl = t, this.end = s;
    }
    return r.prototype.subdivide = function(A, e) {
      var t = ee(this.start, this.startControl, A), s = ee(this.startControl, this.endControl, A), n = ee(this.endControl, this.end, A), i = ee(t, s, A), a = ee(s, n, A), o = ee(i, a, A);
      return e ? new r(this.start, t, i, o) : new r(o, a, n, this.end);
    }, r.prototype.add = function(A, e) {
      return new r(this.start.add(A, e), this.startControl.add(A, e), this.endControl.add(A, e), this.end.add(A, e));
    }, r.prototype.reverse = function() {
      return new r(this.end, this.endControl, this.startControl, this.start);
    }, r;
  }()
), iA = function(r) {
  return r.type === 1;
}, Nl = (
  /** @class */
  function() {
    function r(A) {
      var e = A.styles, t = A.bounds, s = Ue(e.borderTopLeftRadius, t.width, t.height), n = s[0], i = s[1], a = Ue(e.borderTopRightRadius, t.width, t.height), o = a[0], B = a[1], c = Ue(e.borderBottomRightRadius, t.width, t.height), l = c[0], u = c[1], Q = Ue(e.borderBottomLeftRadius, t.width, t.height), g = Q[0], f = Q[1], U = [];
      U.push((n + o) / t.width), U.push((g + l) / t.width), U.push((i + f) / t.height), U.push((B + u) / t.height);
      var w = Math.max.apply(Math, U);
      w > 1 && (n /= w, i /= w, o /= w, B /= w, l /= w, u /= w, g /= w, f /= w);
      var h = t.width - o, v = t.height - u, m = t.width - l, H = t.height - f, d = e.borderTopWidth, L = e.borderRightWidth, b = e.borderBottomWidth, C = e.borderLeftWidth, E = N(e.paddingTop, A.bounds.width), I = N(e.paddingRight, A.bounds.width), D = N(e.paddingBottom, A.bounds.width), y = N(e.paddingLeft, A.bounds.width);
      this.topLeftBorderDoubleOuterBox = n > 0 || i > 0 ? R(t.left + C / 3, t.top + d / 3, n - C / 3, i - d / 3, T.TOP_LEFT) : new F(t.left + C / 3, t.top + d / 3), this.topRightBorderDoubleOuterBox = n > 0 || i > 0 ? R(t.left + h, t.top + d / 3, o - L / 3, B - d / 3, T.TOP_RIGHT) : new F(t.left + t.width - L / 3, t.top + d / 3), this.bottomRightBorderDoubleOuterBox = l > 0 || u > 0 ? R(t.left + m, t.top + v, l - L / 3, u - b / 3, T.BOTTOM_RIGHT) : new F(t.left + t.width - L / 3, t.top + t.height - b / 3), this.bottomLeftBorderDoubleOuterBox = g > 0 || f > 0 ? R(t.left + C / 3, t.top + H, g - C / 3, f - b / 3, T.BOTTOM_LEFT) : new F(t.left + C / 3, t.top + t.height - b / 3), this.topLeftBorderDoubleInnerBox = n > 0 || i > 0 ? R(t.left + C * 2 / 3, t.top + d * 2 / 3, n - C * 2 / 3, i - d * 2 / 3, T.TOP_LEFT) : new F(t.left + C * 2 / 3, t.top + d * 2 / 3), this.topRightBorderDoubleInnerBox = n > 0 || i > 0 ? R(t.left + h, t.top + d * 2 / 3, o - L * 2 / 3, B - d * 2 / 3, T.TOP_RIGHT) : new F(t.left + t.width - L * 2 / 3, t.top + d * 2 / 3), this.bottomRightBorderDoubleInnerBox = l > 0 || u > 0 ? R(t.left + m, t.top + v, l - L * 2 / 3, u - b * 2 / 3, T.BOTTOM_RIGHT) : new F(t.left + t.width - L * 2 / 3, t.top + t.height - b * 2 / 3), this.bottomLeftBorderDoubleInnerBox = g > 0 || f > 0 ? R(t.left + C * 2 / 3, t.top + H, g - C * 2 / 3, f - b * 2 / 3, T.BOTTOM_LEFT) : new F(t.left + C * 2 / 3, t.top + t.height - b * 2 / 3), this.topLeftBorderStroke = n > 0 || i > 0 ? R(t.left + C / 2, t.top + d / 2, n - C / 2, i - d / 2, T.TOP_LEFT) : new F(t.left + C / 2, t.top + d / 2), this.topRightBorderStroke = n > 0 || i > 0 ? R(t.left + h, t.top + d / 2, o - L / 2, B - d / 2, T.TOP_RIGHT) : new F(t.left + t.width - L / 2, t.top + d / 2), this.bottomRightBorderStroke = l > 0 || u > 0 ? R(t.left + m, t.top + v, l - L / 2, u - b / 2, T.BOTTOM_RIGHT) : new F(t.left + t.width - L / 2, t.top + t.height - b / 2), this.bottomLeftBorderStroke = g > 0 || f > 0 ? R(t.left + C / 2, t.top + H, g - C / 2, f - b / 2, T.BOTTOM_LEFT) : new F(t.left + C / 2, t.top + t.height - b / 2), this.topLeftBorderBox = n > 0 || i > 0 ? R(t.left, t.top, n, i, T.TOP_LEFT) : new F(t.left, t.top), this.topRightBorderBox = o > 0 || B > 0 ? R(t.left + h, t.top, o, B, T.TOP_RIGHT) : new F(t.left + t.width, t.top), this.bottomRightBorderBox = l > 0 || u > 0 ? R(t.left + m, t.top + v, l, u, T.BOTTOM_RIGHT) : new F(t.left + t.width, t.top + t.height), this.bottomLeftBorderBox = g > 0 || f > 0 ? R(t.left, t.top + H, g, f, T.BOTTOM_LEFT) : new F(t.left, t.top + t.height), this.topLeftPaddingBox = n > 0 || i > 0 ? R(t.left + C, t.top + d, Math.max(0, n - C), Math.max(0, i - d), T.TOP_LEFT) : new F(t.left + C, t.top + d), this.topRightPaddingBox = o > 0 || B > 0 ? R(t.left + Math.min(h, t.width - L), t.top + d, h > t.width + L ? 0 : Math.max(0, o - L), Math.max(0, B - d), T.TOP_RIGHT) : new F(t.left + t.width - L, t.top + d), this.bottomRightPaddingBox = l > 0 || u > 0 ? R(t.left + Math.min(m, t.width - C), t.top + Math.min(v, t.height - b), Math.max(0, l - L), Math.max(0, u - b), T.BOTTOM_RIGHT) : new F(t.left + t.width - L, t.top + t.height - b), this.bottomLeftPaddingBox = g > 0 || f > 0 ? R(t.left + C, t.top + Math.min(H, t.height - b), Math.max(0, g - C), Math.max(0, f - b), T.BOTTOM_LEFT) : new F(t.left + C, t.top + t.height - b), this.topLeftContentBox = n > 0 || i > 0 ? R(t.left + C + y, t.top + d + E, Math.max(0, n - (C + y)), Math.max(0, i - (d + E)), T.TOP_LEFT) : new F(t.left + C + y, t.top + d + E), this.topRightContentBox = o > 0 || B > 0 ? R(t.left + Math.min(h, t.width + C + y), t.top + d + E, h > t.width + C + y ? 0 : o - C + y, B - (d + E), T.TOP_RIGHT) : new F(t.left + t.width - (L + I), t.top + d + E), this.bottomRightContentBox = l > 0 || u > 0 ? R(t.left + Math.min(m, t.width - (C + y)), t.top + Math.min(v, t.height + d + E), Math.max(0, l - (L + I)), u - (b + D), T.BOTTOM_RIGHT) : new F(t.left + t.width - (L + I), t.top + t.height - (b + D)), this.bottomLeftContentBox = g > 0 || f > 0 ? R(t.left + C + y, t.top + H, Math.max(0, g - (C + y)), f - (b + D), T.BOTTOM_LEFT) : new F(t.left + C + y, t.top + t.height - (b + D));
    }
    return r;
  }()
), T;
(function(r) {
  r[r.TOP_LEFT = 0] = "TOP_LEFT", r[r.TOP_RIGHT = 1] = "TOP_RIGHT", r[r.BOTTOM_RIGHT = 2] = "BOTTOM_RIGHT", r[r.BOTTOM_LEFT = 3] = "BOTTOM_LEFT";
})(T || (T = {}));
var R = function(r, A, e, t, s) {
  var n = 4 * ((Math.sqrt(2) - 1) / 3), i = e * n, a = t * n, o = r + e, B = A + t;
  switch (s) {
    case T.TOP_LEFT:
      return new qe(new F(r, B), new F(r, B - a), new F(o - i, A), new F(o, A));
    case T.TOP_RIGHT:
      return new qe(new F(r, A), new F(r + i, A), new F(o, B - a), new F(o, B));
    case T.BOTTOM_RIGHT:
      return new qe(new F(o, A), new F(o, A + a), new F(r + i, B), new F(r, B));
    case T.BOTTOM_LEFT:
    default:
      return new qe(new F(o, B), new F(o - i, B), new F(r, A + a), new F(r, A));
  }
}, ft = function(r) {
  return [r.topLeftBorderBox, r.topRightBorderBox, r.bottomRightBorderBox, r.bottomLeftBorderBox];
}, Rl = function(r) {
  return [
    r.topLeftContentBox,
    r.topRightContentBox,
    r.bottomRightContentBox,
    r.bottomLeftContentBox
  ];
}, Qt = function(r) {
  return [
    r.topLeftPaddingBox,
    r.topRightPaddingBox,
    r.bottomRightPaddingBox,
    r.bottomLeftPaddingBox
  ];
}, Gl = (
  /** @class */
  function() {
    function r(A, e, t) {
      this.offsetX = A, this.offsetY = e, this.matrix = t, this.type = 0, this.target = 6;
    }
    return r;
  }()
), At = (
  /** @class */
  function() {
    function r(A, e) {
      this.path = A, this.target = e, this.type = 1;
    }
    return r;
  }()
), Vl = (
  /** @class */
  function() {
    function r(A) {
      this.opacity = A, this.type = 2, this.target = 6;
    }
    return r;
  }()
), Pl = function(r) {
  return r.type === 0;
}, jn = function(r) {
  return r.type === 1;
}, kl = function(r) {
  return r.type === 2;
}, Os = function(r, A) {
  return r.length === A.length ? r.some(function(e, t) {
    return e === A[t];
  }) : !1;
}, _l = function(r, A, e, t, s) {
  return r.map(function(n, i) {
    switch (i) {
      case 0:
        return n.add(A, e);
      case 1:
        return n.add(A + t, e);
      case 2:
        return n.add(A + t, e + s);
      case 3:
        return n.add(A, e + s);
    }
    return n;
  });
}, qn = (
  /** @class */
  function() {
    function r(A) {
      this.element = A, this.inlineLevel = [], this.nonInlineLevel = [], this.negativeZIndex = [], this.zeroOrAutoZIndexOrTransformedOrOpacity = [], this.positiveZIndex = [], this.nonPositionedFloats = [], this.nonPositionedInlineLevel = [];
    }
    return r;
  }()
), Ai = (
  /** @class */
  function() {
    function r(A, e) {
      if (this.container = A, this.parent = e, this.effects = [], this.curves = new Nl(this.container), this.container.styles.opacity < 1 && this.effects.push(new Vl(this.container.styles.opacity)), this.container.styles.transform !== null) {
        var t = 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 Gl(t, s, n));
      }
      if (this.container.styles.overflowX !== 0) {
        var i = ft(this.curves), a = Qt(this.curves);
        Os(i, a) ? this.effects.push(new At(
          i,
          6
          /* CONTENT */
        )) : (this.effects.push(new At(
          i,
          2
          /* BACKGROUND_BORDERS */
        )), this.effects.push(new At(
          a,
          4
          /* CONTENT */
        )));
      }
    }
    return r.prototype.getEffects = function(A) {
      for (var e = [
        2,
        3
        /* FIXED */
      ].indexOf(this.container.styles.position) === -1, t = this.parent, s = this.effects.slice(0); t; ) {
        var n = t.effects.filter(function(o) {
          return !jn(o);
        });
        if (e || t.container.styles.position !== 0 || !t.parent) {
          if (s.unshift.apply(s, n), e = [
            2,
            3
            /* FIXED */
          ].indexOf(t.container.styles.position) === -1, t.container.styles.overflowX !== 0) {
            var i = ft(t.curves), a = Qt(t.curves);
            Os(i, a) || s.unshift(new At(
              a,
              6
              /* CONTENT */
            ));
          }
        } else
          s.unshift.apply(s, n);
        t = t.parent;
      }
      return s.filter(function(o) {
        return X(o.target, A);
      });
    }, r;
  }()
), mr = function(r, A, e, t) {
  r.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 Ai(s, r);
    X(
      s.styles.display,
      2048
      /* LIST_ITEM */
    ) && t.push(a);
    var o = X(
      s.flags,
      8
      /* IS_LIST_OWNER */
    ) ? [] : t;
    if (n || i) {
      var B = n || s.styles.isPositioned() ? e : A, c = new qn(a);
      if (s.styles.isPositioned() || s.styles.opacity < 1 || s.styles.isTransformed()) {
        var l = s.styles.zIndex.order;
        if (l < 0) {
          var u = 0;
          B.negativeZIndex.some(function(g, f) {
            return l > g.element.container.styles.zIndex.order ? (u = f, !1) : u > 0;
          }), B.negativeZIndex.splice(u, 0, c);
        } else if (l > 0) {
          var Q = 0;
          B.positiveZIndex.some(function(g, f) {
            return l >= g.element.container.styles.zIndex.order ? (Q = f + 1, !1) : Q > 0;
          }), B.positiveZIndex.splice(Q, 0, c);
        } else
          B.zeroOrAutoZIndexOrTransformedOrOpacity.push(c);
      } else
        s.styles.isFloating() ? B.nonPositionedFloats.push(c) : B.nonPositionedInlineLevel.push(c);
      mr(a, c, n ? c : e, o);
    } else
      s.styles.isInlineLevel() ? A.inlineLevel.push(a) : A.nonInlineLevel.push(a), mr(a, A, e, o);
    X(
      s.flags,
      8
      /* IS_LIST_OWNER */
    ) && ei(s, o);
  });
}, ei = function(r, A) {
  for (var e = r instanceof Ur ? r.start : 1, t = r instanceof Ur ? r.reversed : !1, s = 0; s < A.length; s++) {
    var n = A[s];
    n.container instanceof Nn && typeof n.container.value == "number" && n.container.value !== 0 && (e = n.container.value), n.listValue = Ke(e, n.container.styles.listStyleType, !0), e += t ? -1 : 1;
  }
}, Xl = function(r) {
  var A = new Ai(r, null), e = new qn(A), t = [];
  return mr(A, e, e, t), ei(A.container, t), e;
}, Ns = function(r, A) {
  switch (A) {
    case 0:
      return oA(r.topLeftBorderBox, r.topLeftPaddingBox, r.topRightBorderBox, r.topRightPaddingBox);
    case 1:
      return oA(r.topRightBorderBox, r.topRightPaddingBox, r.bottomRightBorderBox, r.bottomRightPaddingBox);
    case 2:
      return oA(r.bottomRightBorderBox, r.bottomRightPaddingBox, r.bottomLeftBorderBox, r.bottomLeftPaddingBox);
    case 3:
    default:
      return oA(r.bottomLeftBorderBox, r.bottomLeftPaddingBox, r.topLeftBorderBox, r.topLeftPaddingBox);
  }
}, Jl = function(r, A) {
  switch (A) {
    case 0:
      return oA(r.topLeftBorderBox, r.topLeftBorderDoubleOuterBox, r.topRightBorderBox, r.topRightBorderDoubleOuterBox);
    case 1:
      return oA(r.topRightBorderBox, r.topRightBorderDoubleOuterBox, r.bottomRightBorderBox, r.bottomRightBorderDoubleOuterBox);
    case 2:
      return oA(r.bottomRightBorderBox, r.bottomRightBorderDoubleOuterBox, r.bottomLeftBorderBox, r.bottomLeftBorderDoubleOuterBox);
    case 3:
    default:
      return oA(r.bottomLeftBorderBox, r.bottomLeftBorderDoubleOuterBox, r.topLeftBorderBox, r.topLeftBorderDoubleOuterBox);
  }
}, Wl = function(r, A) {
  switch (A) {
    case 0:
      return oA(r.topLeftBorderDoubleInnerBox, r.topLeftPaddingBox, r.topRightBorderDoubleInnerBox, r.topRightPaddingBox);
    case 1:
      return oA(r.topRightBorderDoubleInnerBox, r.topRightPaddingBox, r.bottomRightBorderDoubleInnerBox, r.bottomRightPaddingBox);
    case 2:
      return oA(r.bottomRightBorderDoubleInnerBox, r.bottomRightPaddingBox, r.bottomLeftBorderDoubleInnerBox, r.bottomLeftPaddingBox);
    case 3:
    default:
      return oA(r.bottomLeftBorderDoubleInnerBox, r.bottomLeftPaddingBox, r.topLeftBorderDoubleInnerBox, r.topLeftPaddingBox);
  }
}, Yl = function(r, A) {
  switch (A) {
    case 0:
      return et(r.topLeftBorderStroke, r.topRightBorderStroke);
    case 1:
      return et(r.topRightBorderStroke, r.bottomRightBorderStroke);
    case 2:
      return et(r.bottomRightBorderStroke, r.bottomLeftBorderStroke);
    case 3:
    default:
      return et(r.bottomLeftBorderStroke, r.topLeftBorderStroke);
  }
}, et = function(r, A) {
  var e = [];
  return iA(r) ? e.push(r.subdivide(0.5, !1)) : e.push(r), iA(A) ? e.push(A.subdivide(0.5, !0)) : e.push(A), e;
}, oA = function(r, A, e, t) {
  var s = [];
  return iA(r) ? s.push(r.subdivide(0.5, !1)) : s.push(r), iA(e) ? s.push(e.subdivide(0.5, !0)) : s.push(e), iA(t) ? s.push(t.subdivide(0.5, !0).reverse()) : s.push(t), iA(A) ? s.push(A.subdivide(0.5, !1).reverse()) : s.push(A), s;
}, ti = function(r) {
  var A = r.bounds, e = r.styles;
  return A.add(e.borderLeftWidth, e.borderTopWidth, -(e.borderRightWidth + e.borderLeftWidth), -(e.borderTopWidth + e.borderBottomWidth));
}, ht = function(r) {
  var A = r.styles, e = r.bounds, t = N(A.paddingLeft, e.width), s = N(A.paddingRight, e.width), n = N(A.paddingTop, e.width), i = N(A.paddingBottom, e.width);
  return e.add(t + A.borderLeftWidth, n + A.borderTopWidth, -(A.borderRightWidth + A.borderLeftWidth + t + s), -(A.borderTopWidth + A.borderBottomWidth + n + i));
}, Zl = function(r, A) {
  return r === 0 ? A.bounds : r === 2 ? ht(A) : ti(A);
}, zl = function(r, A) {
  return r === 0 ? A.bounds : r === 2 ? ht(A) : ti(A);
}, er = function(r, A, e) {
  var t = Zl(se(r.styles.backgroundOrigin, A), r), s = zl(se(r.styles.backgroundClip, A), r), n = $l(se(r.styles.backgroundSize, A), e, t), i = n[0], a = n[1], o = Ue(se(r.styles.backgroundPosition, A), t.width - i, t.height - a), B = jl(se(r.styles.backgroundRepeat, A), o, n, t, s), c = Math.round(t.left + o[0]), l = Math.round(t.top + o[1]);
  return [B, c, l, i, a];
}, te = function(r) {
  return M(r) && r.value === ie.AUTO;
}, tt = function(r) {
  return typeof r == "number";
}, $l = function(r, A, e) {
  var t = A[0], s = A[1], n = A[2], i = r[0], a = r[1];
  if (!i)
    return [0, 0];
  if (k(i) && a && k(a))
    return [N(i, e.width), N(a, e.height)];
  var o = tt(n);
  if (M(i) && (i.value === ie.CONTAIN || i.value === ie.COVER)) {
    if (tt(n)) {
      var B = e.width / e.height;
      return B < n != (i.value === ie.COVER) ? [e.width, e.width / n] : [e.height * n, e.height];
    }
    return [e.width, e.height];
  }
  var c = tt(t), l = tt(s), u = c || l;
  if (te(i) && (!a || te(a))) {
    if (c && l)
      return [t, s];
    if (!o && !u)
      return [e.width, e.height];
    if (u && o) {
      var Q = c ? t : s * n, g = l ? s : t / n;
      return [Q, g];
    }
    var f = c ? t : e.width, U = l ? s : e.height;
    return [f, U];
  }
  if (o) {
    var w = 0, h = 0;
    return k(i) ? w = N(i, e.width) : k(a) && (h = N(a, e.height)), te(i) ? w = h * n : (!a || te(a)) && (h = w / n), [w, h];
  }
  var v = null, m = null;
  if (k(i) ? v = N(i, e.width) : a && k(a) && (m = N(a, e.height)), v !== null && (!a || te(a)) && (m = c && l ? v / t * s : e.height), m !== null && te(i) && (v = c && l ? m / s * t : e.width), v !== null && m !== null)
    return [v, m];
  throw new Error("Unable to calculate background-size for element");
}, se = function(r, A) {
  var e = r[A];
  return typeof e > "u" ? r[0] : e;
}, jl = function(r, A, e, t, s) {
  var n = A[0], i = A[1], a = e[0], o = e[1];
  switch (r) {
    case 2:
      return [
        new F(Math.round(t.left), Math.round(t.top + i)),
        new F(Math.round(t.left + t.width), Math.round(t.top + i)),
        new F(Math.round(t.left + t.width), Math.round(o + t.top + i)),
        new F(Math.round(t.left), Math.round(o + t.top + i))
      ];
    case 3:
      return [
        new F(Math.round(t.left + n), Math.round(t.top)),
        new F(Math.round(t.left + n + a), Math.round(t.top)),
        new F(Math.round(t.left + n + a), Math.round(t.height + t.top)),
        new F(Math.round(t.left + n), Math.round(t.height + t.top))
      ];
    case 1:
      return [
        new F(Math.round(t.left + n), Math.round(t.top + i)),
        new F(Math.round(t.left + n + a), Math.round(t.top + i)),
        new F(Math.round(t.left + n + a), Math.round(t.top + i + o)),
        new F(Math.round(t.left + n), Math.round(t.top + i + o))
      ];
    default:
      return [
        new F(Math.round(s.left), Math.round(s.top)),
        new F(Math.round(s.left + s.width), Math.round(s.top)),
        new F(Math.round(s.left + s.width), Math.round(s.height + s.top)),
        new F(Math.round(s.left), Math.round(s.height + s.top))
      ];
  }
}, ql = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7", Rs = "Hidden Text", Au = (
  /** @class */
  function() {
    function r(A) {
      this._data = {}, this._document = A;
    }
    return r.prototype.parseMetrics = function(A, e) {
      var t = this._document.createElement("div"), s = this._document.createElement("img"), n = this._document.createElement("span"), i = this._document.body;
      t.style.visibility = "hidden", t.style.fontFamily = A, t.style.fontSize = e, t.style.margin = "0", t.style.padding = "0", t.style.whiteSpace = "nowrap", i.appendChild(t), s.src = ql, 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(Rs)), t.appendChild(n), t.appendChild(s);
      var a = s.offsetTop - n.offsetTop + 2;
      t.removeChild(n), t.appendChild(this._document.createTextNode(Rs)), t.style.lineHeight = "normal", s.style.verticalAlign = "super";
      var o = s.offsetTop - t.offsetTop + 2;
      return i.removeChild(t), { baseline: a, middle: o };
    }, r.prototype.getMetrics = function(A, e) {
      var t = A + " " + e;
      return typeof this._data[t] > "u" && (this._data[t] = this.parseMetrics(A, e)), this._data[t];
    }, r;
  }()
), ri = (
  /** @class */
  function() {
    function r(A, e) {
      this.context = A, this.options = e;
    }
    return r;
  }()
), eu = 1e4, tu = (
  /** @class */
  function(r) {
    uA(A, r);
    function A(e, t) {
      var s = r.call(this, e, t) || this;
      return s._activeEffects = [], s.canvas = t.canvas ? t.canvas : document.createElement("canvas"), s.ctx = s.canvas.getContext("2d"), t.canvas || (s.canvas.width = Math.floor(t.width * t.scale), s.canvas.height = Math.floor(t.height * t.scale), s.canvas.style.width = t.width + "px", s.canvas.style.height = t.height + "px"), s.fontMetrics = new Au(document), s.ctx.scale(s.options.scale, s.options.scale), s.ctx.translate(-t.x, -t.y), s.ctx.textBaseline = "bottom", s._activeEffects = [], s.context.logger.debug("Canvas renderer initialized (" + t.width + "x" + t.height + ") with scale " + t.scale), s;
    }
    return A.prototype.applyEffects = function(e) {
      for (var t = this; this._activeEffects.length; )
        this.popEffect();
      e.forEach(function(s) {
        return t.applyEffect(s);
      });
    }, A.prototype.applyEffect = function(e) {
      this.ctx.save(), kl(e) && (this.ctx.globalAlpha = e.opacity), Pl(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)), jn(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 t;
        return z(this, function(s) {
          switch (s.label) {
            case 0:
              return t = e.element.container.styles, t.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 z(this, function(t) {
          switch (t.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 t.sent(), [4, this.renderNodeContent(e)];
            case 2:
              t.sent(), t.label = 3;
            case 3:
              return [
                2
                /*return*/
              ];
          }
        });
      });
    }, A.prototype.renderTextWithLetterSpacing = function(e, t, s) {
      var n = this;
      if (t === 0)
        this.ctx.fillText(e.text, e.bounds.left, e.bounds.top + s);
      else {
        var i = Tr(e.text);
        i.reduce(function(a, o) {
          return n.ctx.fillText(o, a, e.bounds.top + s), a + n.ctx.measureText(o).width;
        }, e.bounds.left);
      }
    }, A.prototype.createFontStyle = function(e) {
      var t = e.fontVariant.filter(function(i) {
        return i === "normal" || i === "small-caps";
      }).join(""), s = au(e.fontFamily).join(", "), n = Se(e.fontSize) ? "" + e.fontSize.number + e.fontSize.unit : e.fontSize.number + "px";
      return [
        [e.fontStyle, t, e.fontWeight, n, s].join(" "),
        s,
        n
      ];
    }, A.prototype.renderTextNode = function(e, t) {
      return AA(this, void 0, void 0, function() {
        var s, n, i, a, o, B, c, l, u = this;
        return z(this, function(Q) {
          return s = this.createFontStyle(t), n = s[0], i = s[1], a = s[2], this.ctx.font = n, this.ctx.direction = t.direction === 1 ? "rtl" : "ltr", this.ctx.textAlign = "left", this.ctx.textBaseline = "alphabetic", o = this.fontMetrics.getMetrics(i, a), B = o.baseline, c = o.middle, l = t.paintOrder, e.textBounds.forEach(function(g) {
            l.forEach(function(f) {
              switch (f) {
                case 0:
                  u.ctx.fillStyle = J(t.color), u.renderTextWithLetterSpacing(g, t.letterSpacing, B);
                  var U = t.textShadow;
                  U.length && g.text.trim().length && (U.slice(0).reverse().forEach(function(w) {
                    u.ctx.shadowColor = J(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, t.letterSpacing, B);
                  }), u.ctx.shadowColor = "", u.ctx.shadowOffsetX = 0, u.ctx.shadowOffsetY = 0, u.ctx.shadowBlur = 0), t.textDecorationLine.length && (u.ctx.fillStyle = J(t.textDecorationColor || t.color), t.textDecorationLine.forEach(function(w) {
                    switch (w) {
                      case 1:
                        u.ctx.fillRect(g.bounds.left, Math.round(g.bounds.top + B), 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:
                  t.webkitTextStrokeWidth && g.text.trim().length && (u.ctx.strokeStyle = J(t.webkitTextStrokeColor), u.ctx.lineWidth = t.webkitTextStrokeWidth, u.ctx.lineJoin = window.chrome ? "miter" : "round", u.ctx.strokeText(g.text, g.bounds.left, g.bounds.top + B)), u.ctx.strokeStyle = "", u.ctx.lineWidth = 0, u.ctx.lineJoin = "miter";
                  break;
              }
            });
          }), [
            2
            /*return*/
          ];
        });
      });
    }, A.prototype.renderReplacedElement = function(e, t, s) {
      if (s && e.intrinsicWidth > 0 && e.intrinsicHeight > 0) {
        var n = ht(e), i = Qt(t);
        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 t, s, n, i, a, o, h, h, B, c, l, u, m, Q, g, H, f, U, w, h, v, m, H;
        return z(this, function(d) {
          switch (d.label) {
            case 0:
              this.applyEffects(e.getEffects(
                4
                /* CONTENT */
              )), t = e.container, s = e.curves, n = t.styles, i = 0, a = t.textNodes, d.label = 1;
            case 1:
              return i < a.length ? (o = a[i], [4, this.renderTextNode(o, n)]) : [3, 4];
            case 2:
              d.sent(), d.label = 3;
            case 3:
              return i++, [3, 1];
            case 4:
              if (!(t instanceof xn))
                return [3, 8];
              d.label = 5;
            case 5:
              return d.trys.push([5, 7, , 8]), [4, this.context.cache.match(t.src)];
            case 6:
              return h = d.sent(), this.renderReplacedElement(t, s, h), [3, 8];
            case 7:
              return d.sent(), this.context.logger.error("Error loading image " + t.src), [3, 8];
            case 8:
              if (t instanceof Mn && this.renderReplacedElement(t, s, t.canvas), !(t instanceof On))
                return [3, 12];
              d.label = 9;
            case 9:
              return d.trys.push([9, 11, , 12]), [4, this.context.cache.match(t.svg)];
            case 10:
              return h = d.sent(), this.renderReplacedElement(t, s, h), [3, 12];
            case 11:
              return d.sent(), this.context.logger.error("Error loading svg " + t.svg.substring(0, 255)), [3, 12];
            case 12:
              return t instanceof Vn && t.tree ? (B = new A(this.context, {
                scale: this.options.scale,
                backgroundColor: t.backgroundColor,
                x: 0,
                y: 0,
                width: t.width,
                height: t.height
              }), [4, B.render(t.tree)]) : [3, 14];
            case 13:
              c = d.sent(), t.width && t.height && this.ctx.drawImage(c, 0, 0, t.width, t.height, t.bounds.left, t.bounds.top, t.bounds.width, t.bounds.height), d.label = 14;
            case 14:
              if (t instanceof xr && (l = Math.min(t.bounds.width, t.bounds.height), t.type === lt ? t.checked && (this.ctx.save(), this.path([
                new F(t.bounds.left + l * 0.39363, t.bounds.top + l * 0.79),
                new F(t.bounds.left + l * 0.16, t.bounds.top + l * 0.5549),
                new F(t.bounds.left + l * 0.27347, t.bounds.top + l * 0.44071),
                new F(t.bounds.left + l * 0.39694, t.bounds.top + l * 0.5649),
                new F(t.bounds.left + l * 0.72983, t.bounds.top + l * 0.23),
                new F(t.bounds.left + l * 0.84, t.bounds.top + l * 0.34085),
                new F(t.bounds.left + l * 0.39363, t.bounds.top + l * 0.79)
              ]), this.ctx.fillStyle = J(Hs), this.ctx.fill(), this.ctx.restore()) : t.type === ut && t.checked && (this.ctx.save(), this.ctx.beginPath(), this.ctx.arc(t.bounds.left + l / 2, t.bounds.top + l / 2, l / 4, 0, Math.PI * 2, !0), this.ctx.fillStyle = J(Hs), this.ctx.fill(), this.ctx.restore())), ru(t) && t.value.length) {
                switch (u = this.createFontStyle(n), m = u[0], Q = u[1], g = this.fontMetrics.getMetrics(m, Q).baseline, this.ctx.font = m, this.ctx.fillStyle = J(n.color), this.ctx.textBaseline = "alphabetic", this.ctx.textAlign = nu(t.styles.textAlign), H = ht(t), f = 0, t.styles.textAlign) {
                  case 1:
                    f += H.width / 2;
                    break;
                  case 2:
                    f += H.width;
                    break;
                }
                U = H.add(f, 0, 0, -H.height / 2 + 1), this.ctx.save(), this.path([
                  new F(H.left, H.top),
                  new F(H.left + H.width, H.top),
                  new F(H.left + H.width, H.top + H.height),
                  new F(H.left, H.top + H.height)
                ]), this.ctx.clip(), this.renderTextWithLetterSpacing(new ye(t.value, U), n.letterSpacing, g), this.ctx.restore(), this.ctx.textBaseline = "alphabetic", this.ctx.textAlign = "left";
              }
              if (!X(
                t.styles.display,
                2048
                /* LIST_ITEM */
              ))
                return [3, 20];
              if (t.styles.listStyleImage === null)
                return [3, 19];
              if (w = t.styles.listStyleImage, w.type !== 0)
                return [3, 18];
              h = void 0, v = w.url, d.label = 15;
            case 15:
              return d.trys.push([15, 17, , 18]), [4, this.context.cache.match(v)];
            case 16:
              return h = d.sent(), this.ctx.drawImage(h, t.bounds.left - (h.width + 10), t.bounds.top), [3, 18];
            case 17:
              return d.sent(), this.context.logger.error("Error loading list-style-image " + v), [3, 18];
            case 18:
              return [3, 20];
            case 19:
              e.listValue && t.styles.listStyleType !== -1 && (m = this.createFontStyle(n)[0], this.ctx.font = m, this.ctx.fillStyle = J(n.color), this.ctx.textBaseline = "middle", this.ctx.textAlign = "right", H = new IA(t.bounds.left, t.bounds.top + N(t.styles.paddingTop, t.bounds.width), t.bounds.width, Bs(n.lineHeight, n.fontSize.number) / 2 + 1), this.renderTextWithLetterSpacing(new ye(e.listValue, H), n.letterSpacing, Bs(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 t, s, w, n, i, w, a, o, w, B, c, w, l, u, w, Q, g, w, f, U, w;
        return z(this, function(h) {
          switch (h.label) {
            case 0:
              if (X(
                e.element.container.flags,
                16
                /* DEBUG_RENDER */
              ))
                debugger;
              return [4, this.renderNodeBackgroundAndBorders(e.element)];
            case 1:
              h.sent(), t = 0, s = e.negativeZIndex, h.label = 2;
            case 2:
              return t < s.length ? (w = s[t], [4, this.renderStack(w)]) : [3, 5];
            case 3:
              h.sent(), h.label = 4;
            case 4:
              return t++, [3, 2];
            case 5:
              return [4, this.renderNodeContent(e.element)];
            case 6:
              h.sent(), n = 0, i = e.nonInlineLevel, h.label = 7;
            case 7:
              return n < i.length ? (w = i[n], [4, this.renderNode(w)]) : [3, 10];
            case 8:
              h.sent(), h.label = 9;
            case 9:
              return n++, [3, 7];
            case 10:
              a = 0, o = e.nonPositionedFloats, h.label = 11;
            case 11:
              return a < o.length ? (w = o[a], [4, this.renderStack(w)]) : [3, 14];
            case 12:
              h.sent(), h.label = 13;
            case 13:
              return a++, [3, 11];
            case 14:
              B = 0, c = e.nonPositionedInlineLevel, h.label = 15;
            case 15:
              return B < c.length ? (w = c[B], [4, this.renderStack(w)]) : [3, 18];
            case 16:
              h.sent(), h.label = 17;
            case 17:
              return B++, [3, 15];
            case 18:
              l = 0, u = e.inlineLevel, h.label = 19;
            case 19:
              return l < u.length ? (w = u[l], [4, this.renderNode(w)]) : [3, 22];
            case 20:
              h.sent(), h.label = 21;
            case 21:
              return l++, [3, 19];
            case 22:
              Q = 0, g = e.zeroOrAutoZIndexOrTransformedOrOpacity, h.label = 23;
            case 23:
              return Q < g.length ? (w = g[Q], [4, this.renderStack(w)]) : [3, 26];
            case 24:
              h.sent(), h.label = 25;
            case 25:
              return Q++, [3, 23];
            case 26:
              f = 0, U = e.positiveZIndex, h.label = 27;
            case 27:
              return f < U.length ? (w = U[f], [4, this.renderStack(w)]) : [3, 30];
            case 28:
              h.sent(), h.label = 29;
            case 29:
              return f++, [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 t = this;
      e.forEach(function(s, n) {
        var i = iA(s) ? s.start : s;
        n === 0 ? t.ctx.moveTo(i.x, i.y) : t.ctx.lineTo(i.x, i.y), iA(s) && t.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, t, s, n) {
      this.path(e), this.ctx.fillStyle = t, this.ctx.translate(s, n), this.ctx.fill(), this.ctx.translate(-s, -n);
    }, A.prototype.resizeImage = function(e, t, s) {
      var n;
      if (e.width === t && 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, t), a.height = Math.max(1, s);
      var o = a.getContext("2d");
      return o.drawImage(e, 0, 0, e.width, e.height, 0, 0, t, s), a;
    }, A.prototype.renderBackgroundImage = function(e) {
      return AA(this, void 0, void 0, function() {
        var t, s, n, i, a, o;
        return z(this, function(B) {
          switch (B.label) {
            case 0:
              t = e.styles.backgroundImage.length - 1, s = function(c) {
                var l, u, Q, E, j, Z, y, G, b, g, E, j, Z, y, G, f, U, w, h, v, m, H, d, L, b, C, E, I, D, y, G, eA, j, Z, BA, gA, bA, VA, PA, FA, kA, pA;
                return z(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 && (Q = er(e, t, [
                        l.width,
                        l.height,
                        l.width / l.height
                      ]), E = Q[0], j = Q[1], Z = Q[2], y = Q[3], G = Q[4], b = n.ctx.createPattern(n.resizeImage(l, y, G), "repeat"), n.renderRepeat(E, b, j, Z)), [3, 6];
                    case 5:
                      Po(c) ? (g = er(e, t, [null, null, null]), E = g[0], j = g[1], Z = g[2], y = g[3], G = g[4], f = Oo(c.angle, y, G), U = f[0], w = f[1], h = f[2], v = f[3], m = f[4], H = document.createElement("canvas"), H.width = y, H.height = G, d = H.getContext("2d"), L = d.createLinearGradient(w, v, h, m), as(c.stops, U).forEach(function(ce) {
                        return L.addColorStop(ce.stop, J(ce.color));
                      }), d.fillStyle = L, d.fillRect(0, 0, y, G), y > 0 && G > 0 && (b = n.ctx.createPattern(H, "repeat"), n.renderRepeat(E, b, j, Z))) : ko(c) && (C = er(e, t, [
                        null,
                        null,
                        null
                      ]), E = C[0], I = C[1], D = C[2], y = C[3], G = C[4], eA = c.position.length === 0 ? [Kr] : c.position, j = N(eA[0], y), Z = N(eA[eA.length - 1], G), BA = No(c, j, Z, y, G), gA = BA[0], bA = BA[1], gA > 0 && bA > 0 && (VA = n.ctx.createRadialGradient(I + j, D + Z, 0, I + j, D + Z, gA), as(c.stops, gA * 2).forEach(function(ce) {
                        return VA.addColorStop(ce.stop, J(ce.color));
                      }), n.path(E), n.ctx.fillStyle = VA, gA !== bA ? (PA = e.bounds.left + 0.5 * e.bounds.width, FA = e.bounds.top + 0.5 * e.bounds.height, kA = bA / gA, pA = 1 / kA, n.ctx.save(), n.ctx.translate(PA, FA), n.ctx.transform(1, 0, 0, kA, 0, 0), n.ctx.translate(-PA, -FA), n.ctx.fillRect(I, pA * (D - FA) + FA, y, G * pA), n.ctx.restore()) : n.ctx.fill())), zA.label = 6;
                    case 6:
                      return t--, [
                        2
                        /*return*/
                      ];
                  }
                });
              }, n = this, i = 0, a = e.styles.backgroundImage.slice(0).reverse(), B.label = 1;
            case 1:
              return i < a.length ? (o = a[i], [5, s(o)]) : [3, 4];
            case 2:
              B.sent(), B.label = 3;
            case 3:
              return i++, [3, 1];
            case 4:
              return [
                2
                /*return*/
              ];
          }
        });
      });
    }, A.prototype.renderSolidBorder = function(e, t, s) {
      return AA(this, void 0, void 0, function() {
        return z(this, function(n) {
          return this.path(Ns(s, t)), this.ctx.fillStyle = J(e), this.ctx.fill(), [
            2
            /*return*/
          ];
        });
      });
    }, A.prototype.renderDoubleBorder = function(e, t, s, n) {
      return AA(this, void 0, void 0, function() {
        var i, a;
        return z(this, function(o) {
          switch (o.label) {
            case 0:
              return t < 3 ? [4, this.renderSolidBorder(e, s, n)] : [3, 2];
            case 1:
              return o.sent(), [
                2
                /*return*/
              ];
            case 2:
              return i = Jl(n, s), this.path(i), this.ctx.fillStyle = J(e), this.ctx.fill(), a = Wl(n, s), this.path(a), this.ctx.fill(), [
                2
                /*return*/
              ];
          }
        });
      });
    }, A.prototype.renderNodeBackgroundAndBorders = function(e) {
      return AA(this, void 0, void 0, function() {
        var t, s, n, i, a, o, B, c, l = this;
        return z(this, function(u) {
          switch (u.label) {
            case 0:
              return this.applyEffects(e.getEffects(
                2
                /* BACKGROUND_BORDERS */
              )), t = e.container.styles, s = !NA(t.backgroundColor) || t.backgroundImage.length, n = [
                { style: t.borderTopStyle, color: t.borderTopColor, width: t.borderTopWidth },
                { style: t.borderRightStyle, color: t.borderRightColor, width: t.borderRightWidth },
                { style: t.borderBottomStyle, color: t.borderBottomColor, width: t.borderBottomWidth },
                { style: t.borderLeftStyle, color: t.borderLeftColor, width: t.borderLeftWidth }
              ], i = su(se(t.backgroundClip, 0), e.curves), s || t.boxShadow.length ? (this.ctx.save(), this.path(i), this.ctx.clip(), NA(t.backgroundColor) || (this.ctx.fillStyle = J(t.backgroundColor), this.ctx.fill()), [4, this.renderBackgroundImage(e.container)]) : [3, 2];
            case 1:
              u.sent(), this.ctx.restore(), t.boxShadow.slice(0).reverse().forEach(function(Q) {
                l.ctx.save();
                var g = ft(e.curves), f = Q.inset ? 0 : eu, U = _l(g, -f + (Q.inset ? 1 : -1) * Q.spread.number, (Q.inset ? 1 : -1) * Q.spread.number, Q.spread.number * (Q.inset ? -2 : 2), Q.spread.number * (Q.inset ? -2 : 2));
                Q.inset ? (l.path(g), l.ctx.clip(), l.mask(U)) : (l.mask(g), l.ctx.clip(), l.path(U)), l.ctx.shadowOffsetX = Q.offsetX.number + f, l.ctx.shadowOffsetY = Q.offsetY.number, l.ctx.shadowColor = J(Q.color), l.ctx.shadowBlur = Q.blur.number, l.ctx.fillStyle = Q.inset ? J(Q.color) : "rgba(0,0,0,1)", l.ctx.fill(), l.ctx.restore();
              }), u.label = 2;
            case 2:
              a = 0, o = 0, B = n, u.label = 3;
            case 3:
              return o < B.length ? (c = B[o], c.style !== 0 && !NA(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 o++, [3, 3];
            case 13:
              return [
                2
                /*return*/
              ];
          }
        });
      });
    }, A.prototype.renderDashedDottedBorder = function(e, t, s, n, i) {
      return AA(this, void 0, void 0, function() {
        var a, o, B, c, l, u, Q, g, f, U, w, h, v, m, H, d, H, d;
        return z(this, function(L) {
          return this.ctx.save(), a = Yl(n, s), o = Ns(n, s), i === 2 && (this.path(o), this.ctx.clip()), iA(o[0]) ? (B = o[0].start.x, c = o[0].start.y) : (B = o[0].x, c = o[0].y), iA(o[1]) ? (l = o[1].end.x, u = o[1].end.y) : (l = o[1].x, u = o[1].y), s === 0 || s === 2 ? Q = Math.abs(B - l) : Q = Math.abs(c - u), this.ctx.beginPath(), i === 3 ? this.formatPath(a) : this.formatPath(o.slice(0, 2)), g = t < 3 ? t * 3 : t * 2, f = t < 3 ? t * 2 : t, i === 3 && (g = t, f = t), U = !0, Q <= g * 2 ? U = !1 : Q <= g * 2 + f ? (w = Q / (2 * g + f), g *= w, f *= w) : (h = Math.floor((Q + f) / (g + f)), v = (Q - h * g) / (h - 1), m = (Q - (h + 1) * g) / h, f = m <= 0 || Math.abs(f - v) < Math.abs(f - m) ? v : m), U && (i === 3 ? this.ctx.setLineDash([0, g + f]) : this.ctx.setLineDash([g, f])), i === 3 ? (this.ctx.lineCap = "round", this.ctx.lineWidth = t) : this.ctx.lineWidth = t * 2 + 1.1, this.ctx.strokeStyle = J(e), this.ctx.stroke(), this.ctx.setLineDash([]), i === 2 && (iA(o[0]) && (H = o[3], d = o[0], this.ctx.beginPath(), this.formatPath([new F(H.end.x, H.end.y), new F(d.start.x, d.start.y)]), this.ctx.stroke()), iA(o[1]) && (H = o[1], d = o[2], this.ctx.beginPath(), this.formatPath([new F(H.end.x, H.end.y), new F(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 t;
        return z(this, function(s) {
          switch (s.label) {
            case 0:
              return this.options.backgroundColor && (this.ctx.fillStyle = J(this.options.backgroundColor), this.ctx.fillRect(this.options.x, this.options.y, this.options.width, this.options.height)), t = Xl(e), [4, this.renderStack(t)];
            case 1:
              return s.sent(), this.applyEffects([]), [2, this.canvas];
          }
        });
      });
    }, A;
  }(ri)
), ru = function(r) {
  return r instanceof Gn || r instanceof Rn ? !0 : r instanceof xr && r.type !== ut && r.type !== lt;
}, su = function(r, A) {
  switch (r) {
    case 0:
      return ft(A);
    case 2:
      return Rl(A);
    case 1:
    default:
      return Qt(A);
  }
}, nu = function(r) {
  switch (r) {
    case 1:
      return "center";
    case 2:
      return "right";
    case 0:
    default:
      return "left";
  }
}, iu = ["-apple-system", "system-ui"], au = function(r) {
  return /iPhone OS 15_(0|1)/.test(window.navigator.userAgent) ? r.filter(function(A) {
    return iu.indexOf(A) === -1;
  }) : r;
}, ou = (
  /** @class */
  function(r) {
    uA(A, r);
    function A(e, t) {
      var s = r.call(this, e, t) || this;
      return s.canvas = t.canvas ? t.canvas : document.createElement("canvas"), s.ctx = s.canvas.getContext("2d"), s.options = t, s.canvas.width = Math.floor(t.width * t.scale), s.canvas.height = Math.floor(t.height * t.scale), s.canvas.style.width = t.width + "px", s.canvas.style.height = t.height + "px", s.ctx.scale(s.options.scale, s.options.scale), s.ctx.translate(-t.x, -t.y), s.context.logger.debug("EXPERIMENTAL ForeignObject renderer initialized (" + t.width + "x" + t.height + " at " + t.x + "," + t.y + ") with scale " + t.scale), s;
    }
    return A.prototype.render = function(e) {
      return AA(this, void 0, void 0, function() {
        var t, s;
        return z(this, function(n) {
          switch (n.label) {
            case 0:
              return t = dr(this.options.width * this.options.scale, this.options.height * this.options.scale, this.options.scale, this.options.scale, e), [4, Bu(t)];
            case 1:
              return s = n.sent(), this.options.backgroundColor && (this.ctx.fillStyle = J(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;
  }(ri)
), Bu = function(r) {
  return new Promise(function(A, e) {
    var t = new Image();
    t.onload = function() {
      A(t);
    }, t.onerror = e, t.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(new XMLSerializer().serializeToString(r));
  });
}, cu = (
  /** @class */
  function() {
    function r(A) {
      var e = A.id, t = A.enabled;
      this.id = e, this.enabled = t, this.start = Date.now();
    }
    return r.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, Te([this.id, this.getTime() + "ms"], A)) : this.info.apply(this, A));
    }, r.prototype.getTime = function() {
      return Date.now() - this.start;
    }, r.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, Te([this.id, this.getTime() + "ms"], A));
    }, r.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, Te([this.id, this.getTime() + "ms"], A)) : this.info.apply(this, A));
    }, r.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, Te([this.id, this.getTime() + "ms"], A)) : this.info.apply(this, A));
    }, r.instances = {}, r;
  }()
), lu = (
  /** @class */
  function() {
    function r(A, e) {
      var t;
      this.windowBounds = e, this.instanceName = "#" + r.instanceCount++, this.logger = new cu({ id: this.instanceName, enabled: A.logging }), this.cache = (t = A.cache) !== null && t !== void 0 ? t : new Kl(this, A);
    }
    return r.instanceCount = 1, r;
  }()
), uu = function(r, A) {
  return A === void 0 && (A = {}), gu(r, A);
};
typeof window < "u" && $n.setContext(window);
var gu = function(r, A) {
  return AA(void 0, void 0, void 0, function() {
    var e, t, s, n, i, a, o, B, c, l, u, Q, g, f, U, w, h, v, m, H, L, d, L, b, C, E, I, D, y, G, eA, j, Z, BA, gA, bA, VA, PA, FA, kA;
    return z(this, function(pA) {
      switch (pA.label) {
        case 0:
          if (!r || typeof r != "object")
            return [2, Promise.reject("Invalid element provided as first argument")];
          if (e = r.ownerDocument, !e)
            throw new Error("Element is not attached to a Document");
          if (t = e.defaultView, !t)
            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: (E = A.useCORS) !== null && E !== void 0 ? E : !1
          }, n = sr({ logging: (I = A.logging) !== null && I !== void 0 ? I : !0, cache: A.cache }, s), i = {
            windowWidth: (D = A.windowWidth) !== null && D !== void 0 ? D : t.innerWidth,
            windowHeight: (y = A.windowHeight) !== null && y !== void 0 ? y : t.innerHeight,
            scrollX: (G = A.scrollX) !== null && G !== void 0 ? G : t.pageXOffset,
            scrollY: (eA = A.scrollY) !== null && eA !== void 0 ? eA : t.pageYOffset
          }, a = new IA(i.scrollX, i.scrollY, i.windowWidth, i.windowHeight), o = new lu(n, a), B = (j = A.foreignObjectRendering) !== null && j !== void 0 ? j : !1, c = {
            allowTaint: (Z = A.allowTaint) !== null && Z !== void 0 ? Z : !1,
            onclone: A.onclone,
            ignoreElements: A.ignoreElements,
            inlineImages: B,
            copyStyles: B
          }, o.logger.debug("Starting document clone with size " + a.width + "x" + a.height + " scrolled to " + -a.left + "," + -a.top), l = new xs(o, r, c), u = l.clonedReferenceElement, u ? [4, l.toIFrame(e, a)] : [2, Promise.reject("Unable to find element in cloned iframe")];
        case 1:
          return Q = pA.sent(), g = Mr(u) || wl(u) ? ki(u.ownerDocument) : pt(o, u), f = g.width, U = g.height, w = g.left, h = g.top, v = wu(o, u, A.backgroundColor), m = {
            canvas: A.canvas,
            backgroundColor: v,
            scale: (gA = (BA = A.scale) !== null && BA !== void 0 ? BA : t.devicePixelRatio) !== null && gA !== void 0 ? gA : 1,
            x: ((bA = A.x) !== null && bA !== void 0 ? bA : 0) + w,
            y: ((VA = A.y) !== null && VA !== void 0 ? VA : 0) + h,
            width: (PA = A.width) !== null && PA !== void 0 ? PA : Math.ceil(f),
            height: (FA = A.height) !== null && FA !== void 0 ? FA : Math.ceil(U)
          }, B ? (o.logger.debug("Document cloned, using foreign object rendering"), L = new ou(o, m), [4, L.render(u)]) : [3, 3];
        case 2:
          return H = pA.sent(), [3, 5];
        case 3:
          return o.logger.debug("Document cloned, element located at " + w + "," + h + " with size " + f + "x" + U + " using computed rendering"), o.logger.debug("Starting DOM parsing"), d = kn(o, u), v === d.styles.backgroundColor && (d.styles.backgroundColor = yA.TRANSPARENT), o.logger.debug("Starting renderer for element at " + m.x + "," + m.y + " with size " + m.width + "x" + m.height), L = new tu(o, m), [4, L.render(d)];
        case 4:
          H = pA.sent(), pA.label = 5;
        case 5:
          return (!((kA = A.removeContainer) !== null && kA !== void 0) || kA) && (xs.destroy(Q) || o.logger.error("Cannot detach cloned iframe as it is not in the DOM anymore")), o.logger.debug("Finished rendering"), [2, H];
      }
    });
  });
}, wu = function(r, A, e) {
  var t = A.ownerDocument, s = t.documentElement ? me(r, getComputedStyle(t.documentElement).backgroundColor) : yA.TRANSPARENT, n = t.body ? me(r, getComputedStyle(t.body).backgroundColor) : yA.TRANSPARENT, i = typeof e == "string" ? me(r, e) : e === null ? yA.TRANSPARENT : 4294967295;
  return A === t.documentElement ? NA(s) ? NA(n) ? i : n : s : i;
};
class fu extends Ci {
  async execAction(A, e, t, s, n) {
    try {
      this.exportImg(t);
    } catch (i) {
      ibiz.log.error(i);
    }
    return {
      refresh: !1,
      closeView: !1
    };
  }
  exportImg(A) {
    const e = document.querySelector(
      ".ibiz-view.ibiz-view-deeditview3"
    ), t = document.querySelector(".ivu-tabs-tabpane");
    if (e && t) {
      const s = e.scrollHeight + t.scrollHeight - t.offsetHeight;
      uu(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 o = "downLoad.png";
        A && A[0] && (o = `${A[0].srfmajortext}.png`), a.download = o, a.click();
      });
    }
  }
}
class Qu {
  constructor() {
    q(this, "handler");
  }
  async getHandler() {
    return this.handler || (this.handler = new fu()), this.handler;
  }
}
class hu extends Ki {
  constructor() {
    super(...arguments);
    /**
     * 流程图url
     *
     * @type {string}
     * @memberof PresetWFChartViewController
     */
    q(this, "imgSrc");
  }
  async getUIData() {
    const e = Object.assign(this.context.clone(), this.params), t = await this.entityService.wf.getWFProcessDiagram(e), s = new Blob([t.data], {
      type: "image/svg+xml"
    });
    this.imgSrc = URL.createObjectURL(s);
  }
}
const Cu = CA({
  name: "PresetWFChartView",
  props: {
    context: Object,
    params: {
      type: Object
    },
    modelPath: {
      type: String,
      required: !0
    },
    modal: {
      type: Object
    },
    deName: {
      type: String,
      required: !0
    }
  },
  setup(r) {
    const A = LA("preset-wf-chart-view"), {
      proxy: e
    } = Ft(), t = yr(e, (s, n) => new hu(r.modelPath, s, n));
    return Ws(e, "deName", t.setDeName.bind(t)), {
      c: t,
      ns: A
    };
  },
  render() {
    return x("div", {
      class: this.ns.b()
    }, [x("img", {
      attrs: {
        src: this.c.imgSrc
      }
    })]);
  }
}), du = typeof btoa == "function", Or = typeof Buffer == "function";
typeof TextDecoder == "function" && new TextDecoder();
const Gs = typeof TextEncoder == "function" ? new TextEncoder() : void 0, Uu = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", Ee = Array.prototype.slice.call(Uu);
((r) => {
  let A = {};
  return r.forEach((e, t) => A[e] = t), A;
})(Ee);
const fA = String.fromCharCode.bind(String);
typeof Uint8Array.from == "function" && Uint8Array.from.bind(Uint8Array);
const Fu = (r) => r.replace(/=/g, "").replace(/[+\/]/g, (A) => A == "+" ? "-" : "_"), pu = (r) => {
  let A, e, t, s, n = "";
  const i = r.length % 3;
  for (let a = 0; a < r.length; ) {
    if ((e = r.charCodeAt(a++)) > 255 || (t = r.charCodeAt(a++)) > 255 || (s = r.charCodeAt(a++)) > 255)
      throw new TypeError("invalid character found");
    A = e << 16 | t << 8 | s, n += Ee[A >> 18 & 63] + Ee[A >> 12 & 63] + Ee[A >> 6 & 63] + Ee[A & 63];
  }
  return i ? n.slice(0, i - 3) + "===".substring(i) : n;
}, si = du ? (r) => btoa(r) : Or ? (r) => Buffer.from(r, "binary").toString("base64") : pu, Eu = Or ? (r) => Buffer.from(r).toString("base64") : (r) => {
  let e = [];
  for (let t = 0, s = r.length; t < s; t += 4096)
    e.push(fA.apply(null, r.subarray(t, t + 4096)));
  return si(e.join(""));
}, vu = (r) => {
  if (r.length < 2) {
    var A = r.charCodeAt(0);
    return A < 128 ? r : 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 + (r.charCodeAt(0) - 55296) * 1024 + (r.charCodeAt(1) - 56320);
    return fA(240 | A >>> 18 & 7) + fA(128 | A >>> 12 & 63) + fA(128 | A >>> 6 & 63) + fA(128 | A & 63);
  }
}, mu = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g, Hu = (r) => r.replace(mu, vu), Vs = Or ? (r) => Buffer.from(r, "utf8").toString("base64") : Gs ? (r) => Eu(Gs.encode(r)) : (r) => si(Hu(r)), Ct = (r, A = !1) => A ? Fu(Vs(r)) : Vs(r);
function yu(r, A, e) {
  var L, b;
  const t = O([]), s = O({
    Authorization: `Bearer ${Hi("access_token")}`
  }), n = O(""), i = O(""), a = {
    count: 0,
    cacheFiles: []
    // iview上传过程中不能改default-file-list,所以需要缓存
  }, o = (L = e.editorParams) == null ? void 0 : L.blackList;
  let B = [];
  o && typeof o == "string" && (B = o.split(","));
  const c = (b = e.editorParams) == null ? void 0 : b.previewList;
  let l = [];
  c && typeof c == "string" && (l = c.split(",")), QA(
    () => r.value,
    (C) => {
      t.value = C ? JSON.parse(C) : [];
    },
    { immediate: !0 }
  ), QA(
    () => r.data,
    (C) => {
      if (C) {
        const E = e.calcBaseUrl(C);
        n.value = E.uploadUrl, i.value = E.downloadUrl;
      }
    },
    { immediate: !0, deep: !0 }
  ), QA(
    t,
    (C) => {
      C != null && C.length && i.value && C.forEach((E) => {
        E.url = E.url || i.value.replace("%fileId%", E.id);
      }), Array.isArray(C) && C.forEach((E) => {
        E.name || (E.isPreview = !1);
        const I = E.name.trim().toLowerCase();
        E.isPreview = l.some(
          (D) => I.endsWith(`.${D}`)
        );
      });
    },
    { immediate: !0 }
  ), QA(
    i,
    (C) => {
      C && t.value.length && t.value.forEach((E) => {
        E.url = i.value.replace("%fileId%", E.id);
      });
    },
    { immediate: !0 }
  );
  const u = () => {
    const C = [...t.value, ...a.cacheFiles], E = C.length > 0 ? JSON.stringify(C.map((I) => ({ name: I.name, id: I.id }))) : null;
    a.cacheFiles = [], A(E);
  }, Q = (C) => {
    const E = C.name.trim().toLowerCase();
    if (B.some((D) => E.endsWith(`.${D}`)))
      return ibiz.message.error(`不可上传 ${B.join("、")}类型的文件！`), !1;
    a.count += 1;
  }, g = (C) => {
    C && (a.cacheFiles.push({
      name: C.filename,
      id: C.fileid
    }), a.count -= 1, a.count === 0 && u());
  }, f = (C, E) => {
    throw a.count -= 1, new js({
      response: { data: E, status: C.status }
      // eslint-disable-next-line @typescript-eslint/no-explicit-any
    });
  }, U = (C) => {
    if (r.disabled)
      return;
    const E = t.value.findIndex((I) => I.id === C.id);
    E !== -1 && t.value.splice(E, 1), u();
  }, w = (C) => {
    const I = (e.parent.form || e.parent.grid).model.appEntity.deName, D = `${C.id}|${I}|${r.data.srfkey}|${e.context.srfpersonid || e.context.srfuserid}`, y = C.url || i.value.replace("%fileId%", C.id);
    e.fileDownload({
      url: `${y}?key=${window.btoa(D)}${Math.floor(
        1e3 + Math.random() * 9e3
      )}`,
      name: C.name
    });
  }, h = O(!1), v = O(""), m = O("");
  return {
    uploadUrl: n,
    downloadUrl: i,
    headers: s,
    files: t,
    onDownload: w,
    onError: f,
    onRemove: U,
    onSuccess: g,
    beforeUpload: Q,
    showModal: h,
    modalTitle: v,
    iframeUrl: m,
    onModalCancel: () => {
      h.value = !1, v.value = "", m.value = "";
    },
    previewFile: (C) => {
      if (!C.isPreview)
        return;
      v.value = C.name;
      const E = window.Environment.previewFileUrl;
      if (E) {
        const I = encodeURIComponent(
          Ct(
            `${window.location.origin}${C.url}?fullfilename=${Ct(
              C.name
            )}`
          )
        );
        m.value = `${E}/onlinePreview?url=${I}`, Js(m.value, { type: "_blank" });
      }
    }
  };
}
const Iu = CA({
  name: "SyFileUpload",
  props: Fi(),
  emits: Ys(),
  setup(r, {
    emit: A
  }) {
    const e = LA("sy-file-upload"), t = r.controller, {
      uploadUrl: s,
      headers: n,
      files: i,
      onDownload: a,
      onError: o,
      onRemove: B,
      onSuccess: c,
      beforeUpload: l,
      showModal: u,
      modalTitle: Q,
      iframeUrl: g,
      onModalCancel: f,
      previewFile: U
    } = yu(r, (v) => {
      A("change", v);
    }, t), w = zs(() => t.editorParams.showPreview ? t.editorParams.showPreview === "true" : window.Environment.kkviewon);
    return {
      ns: e,
      c: t,
      uploadUrl: s,
      headers: n,
      files: i,
      onDownload: a,
      onError: o,
      onRemove: B,
      onSuccess: c,
      beforeUpload: l,
      showModal: u,
      modalTitle: Q,
      iframeUrl: g,
      onModalCancel: f,
      onPreview: (v) => {
        w.value && U(v);
      },
      showPreview: w
    };
  },
  render(r) {
    return r("div", {
      class: [this.ns.b(), this.disabled ? this.ns.m("disabled") : "", this.readonly ? this.ns.m("readonly") : ""]
    }, [r("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 ? r("div", {
      class: this.ns.bm("box", "drag")
    }, [r("i-icon", {
      attrs: {
        type: "md-cloud-upload"
      }
    }), r("div", {
      class: this.ns.be("box", "title")
    }, [r("span", ["将文件拖到此处，或"]), r("span", ["点击上传"])])]) : r("i-button", {
      class: this.ns.bm("box", "select")
    }, [r("svg", {
      attrs: {
        xmlns: "http://www.w3.org/2000/svg",
        viewBox: "0 0 1024 1024"
      }
    }, [r("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"
      }
    })]), r("span", ["上传文件"])]), this.c.uploadDescription && !this.readonly && r("div", {
      class: this.ns.b("accept-description")
    }, [this.c.uploadDescription])]), r("div", {
      class: this.ns.b("file-list")
    }, [this.files.map((A) => r("div", {
      class: this.ns.b("file-item"),
      key: A.id
    }, [r("div", {
      class: this.ns.b("file-item-right")
    }, [r("div", {
      class: this.ns.b("file-item-right-icon")
    }, [r("svg", {
      attrs: {
        viewBox: "0 0 16 16",
        version: "1.1"
      }
    }, [r("g", {
      attrs: {
        id: "基础组件",
        stroke: "none",
        "stroke-width": "1",
        fill: "none",
        "fill-rule": "evenodd"
      }
    }, [r("g", {
      attrs: {
        id: "Upload上传",
        transform: "translate(-128.000000, -1899.000000)",
        "fill-rule": "nonzero"
      }
    }, [r("g", {
      attrs: {
        id: "关联",
        transform: "translate(128.000000, 1899.000000)"
      }
    }, [r("rect", {
      attrs: {
        id: "矩形备份-20",
        x: "0",
        y: "0",
        width: "16",
        height: "16"
      }
    }), r("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) "
      }
    })])])])])]), r("div", {
      class: this.ns.b("file-item-right-title"),
      on: {
        click: () => this.onPreview(A)
      }
    }, [A.name]), r("div", {
      class: this.ns.b("file-item-right-action")
    }, [r("span", {
      class: this.ns.e("icon-download"),
      on: {
        click: () => this.onDownload(A)
      }
    }, [r("svg", {
      attrs: {
        width: "16px",
        height: "16px",
        viewBox: "0 0 16 16",
        version: "1.1",
        fill: "currentColor"
      }
    }, [r("g", {
      attrs: {
        id: "icon",
        stroke: "none",
        "stroke-width": "1",
        "fill-rule": "evenodd"
      }
    }, [r("g", {
      attrs: {
        id: "编组"
      }
    }, [r("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"
      }
    }), r("rect", {
      attrs: {
        id: "矩形",
        fill: "#000000",
        "fill-rule": "nonzero",
        opacity: "0",
        x: "0",
        y: "0",
        width: "16",
        height: "16"
      }
    })])])])]), this.showPreview ? r("span", {
      class: this.ns.e("icon-preview"),
      on: {
        click: () => this.onPreview(A)
      }
    }, [r("svg", {
      attrs: {
        width: "16px",
        height: "17px",
        viewBox: "0 0 16 17",
        version: "1.1",
        fill: "currentColor",
        xmlns: "http://www.w3.org/2000/svg"
      }
    }, [r("g", {
      attrs: {
        id: "icon",
        stroke: "none",
        "stroke-width": "1",
        fill: "none",
        "fill-rule": "evenodd"
      }
    }, [r("g", {
      attrs: {
        id: "eye",
        transform: "translate(-7.9982, -7.6008)",
        fill: "currentColor"
      }
    }, [r("g", {
      attrs: {
        transform: "translate(8, 8)",
        id: "编组"
      }
    }, [r("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"
      }
    }), r("rect", {
      attrs: {
        id: "矩形",
        "fill-rule": "nonzero",
        opacity: "0",
        x: "0",
        y: "0",
        width: "16",
        height: "16"
      }
    })])])])])]) : null, this.disabled || this.readonly ? null : r("span", {
      class: this.ns.e("icon-remove"),
      on: {
        click: () => this.onRemove(A)
      }
    }, [r("svg", {
      attrs: {
        width: "16px",
        height: "16px",
        viewBox: "0 0 16 16",
        version: "1.1",
        fill: "currentColor"
      }
    }, [r("g", {
      attrs: {
        id: "基础组件",
        stroke: "none",
        "stroke-width": "1",
        fill: "none",
        "fill-rule": "evenodd"
      }
    }, [r("g", {
      attrs: {
        id: "Upload上传",
        transform: "translate(-544.000000, -930.000000)",
        "fill-rule": "nonzero"
      }
    }, [r("g", {
      attrs: {
        id: "删除",
        transform: "translate(544.000000, 930.000000)"
      }
    }, [r("rect", {
      attrs: {
        id: "矩形备份-12",
        x: "0",
        y: "0",
        width: "16",
        height: "16"
      }
    }), r("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"
      }
    })])])])])])])])]))]), r("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
      }
    }, [r("iframe", {
      class: this.ns.b("iframe"),
      attrs: {
        src: this.iframeUrl
      }
    })])]);
  }
});
function dt(r, A, e) {
  if (r.url = A.replace("%fileId%", r.id), r.status || (r.status = "finished"), !r.fileName) {
    const t = r.name.lastIndexOf(".");
    r.fileName = r.name.substring(0, t), r.fileExt = r.name.substring(t), r.isImage = Si(r.name);
  }
  if (!e)
    r.isPreview = !1;
  else {
    r.name || (r.isPreview = !1);
    const t = r.name.trim().toLowerCase();
    r.isPreview = e.some((s) => t.endsWith(`.${s}`));
  }
  return r;
}
function ni(r) {
  const A = O(""), e = O(""), t = O([]);
  return QA(
    r.data,
    (s) => {
      if (s) {
        const n = r.controller.value.calcBaseUrl(s);
        A.value = n.uploadUrl, e.value = n.downloadUrl;
      }
    },
    { immediate: !0, deep: !0 }
  ), QA(
    r.value,
    (s) => {
      t.value = s ? JSON.parse(s) : [], t.value.length && e.value && t.value.forEach((n) => {
        dt(n, e.value);
      });
    },
    { immediate: !0 }
  ), QA(
    e,
    (s) => {
      s && t.value.length && t.value.forEach((n) => {
        dt(n, s);
      });
    },
    { immediate: !0 }
  ), {
    downloadUrl: e,
    uploadUrl: A,
    valueList: t
  };
}
function ii(r) {
  var d, L, b, C;
  const A = O("undo"), e = O([]), { downloadUrl: t, value: s, uploadUrl: n, controller: i } = r, a = (L = (d = i == null ? void 0 : i.value) == null ? void 0 : d.editorParams) == null ? void 0 : L.blackList;
  let o = [];
  a && typeof a == "string" && (o = a.split(","));
  const B = (C = (b = i == null ? void 0 : i.value) == null ? void 0 : b.editorParams) == null ? void 0 : C.previewList;
  let c = [];
  B && typeof B == "string" && (c = B.split(",")), QA(
    s,
    (E) => {
      E.length > 0 && (e.value = [], E.forEach((I) => {
        e.value.push(
          dt(I, t.value, c)
        );
      }));
    },
    {
      immediate: !0,
      deep: !0
    }
  );
  const l = (E, I) => {
    const D = [];
    return I.forEach((y, G) => {
      const eA = y.name.trim().toLowerCase();
      if (o.some((BA) => eA.endsWith(`.${BA}`))) {
        D.push(G);
        return;
      }
      const Z = c.some((BA) => eA.endsWith(`.${BA}`));
      e.value.push({
        name: y.name,
        status: y.status,
        percentage: y.percentage,
        id: y.uid,
        url: "",
        isPreview: Z
      });
    }), D.length === I.length ? (ibiz.message.error(`不可上传 ${o.join("、")}类型的文件！`), !1) : (D.length && (D.forEach((y) => {
      E.splice(y, 1), I.splice(y, 1);
    }), ibiz.message.error(`不可上传 ${o.join("、")}类型的文件！`)), !0);
  }, u = (E) => {
    E.forEach((I) => {
      e.value.find((D) => D.id === I.uid ? (D.percentage = I.percentage, !0) : !1);
    });
  }, Q = (E, I) => {
    E.forEach((D) => {
      e.value.find((y) => y.id === D.uid ? (y.status = D.status, y.id = I.data.fileid, y.name = I.data.filename, dt(y, t.value, c), !0) : !1);
    });
  }, g = (E, I) => {
    var y;
    E.forEach((G) => {
      e.value.find((eA) => eA.id === G.uid ? (eA.status = G.status, !0) : !1);
    });
    const D = new js(I);
    ibiz.notification.error({
      title: (y = D.status) == null ? void 0 : y.toString(),
      desc: D.message,
      duration: 10
    });
  }, f = (E) => {
    e.value = e.value.filter((I) => I.status === "finished"), A.value = "done";
  }, U = () => {
    Ti({
      multiple: r.multiple,
      accept: r.accept,
      uploadUrl: n.value,
      beforeUpload: l,
      progress: u,
      success: Q,
      error: g,
      finish: f
    });
  }, w = O(!1), h = O(""), v = O("");
  return {
    selectFile: U,
    fileList: e,
    uploadState: A,
    showModal: w,
    modalTitle: h,
    iframeUrl: v,
    onModalCancel: () => {
      w.value = !1, h.value = "", v.value = "";
    },
    previewFile: (E) => {
      if (!E.isPreview)
        return;
      h.value = E.name;
      const I = window.Environment.previewFileUrl;
      if (I) {
        const D = encodeURIComponent(
          Ct(
            `${window.location.origin}${E.url}?fullfilename=${Ct(
              E.name
            )}`
          )
        );
        v.value = `${I}/onlinePreview?url=${D}`, Js(v.value, { type: "_blank" });
      }
    }
  };
}
const Lu = CA({
  name: "SyGridFileUpload",
  props: Ir(),
  setup(r) {
    const A = LA("sy-grid-file-upload"), {
      value: e,
      data: t,
      controller: s
    } = Lr(r), {
      downloadUrl: n,
      uploadUrl: i,
      valueList: a
    } = ni({
      value: e,
      data: t,
      controller: s
    }), {
      fileList: o,
      showModal: B,
      modalTitle: c,
      iframeUrl: l,
      previewFile: u,
      onModalCancel: Q
    } = ii({
      downloadUrl: n,
      uploadUrl: i,
      value: a,
      controller: s
    }), g = (U) => {
      const w = r.controller, v = w.parent.grid.model.appEntity.deName, m = `${U.id}|${v}|${t.value.srfkey}|${w.context.srfpersonid || w.context.srfuserid}`, H = U.url || n.value.replace("%fileId%", U.id);
      w.fileDownload({
        url: `${H}?key=${window.btoa(m)}${Math.floor(1e3 + Math.random() * 9e3)}`,
        name: U.name
      });
    }, f = zs(() => r.controller.editorParams.showPreview ? r.controller.editorParams.showPreview === "true" : window.Environment.kkviewon);
    return {
      ns: A,
      fileList: o,
      showModal: B,
      modalTitle: c,
      iframeUrl: l,
      showPreview: f,
      downloadFile: g,
      previewFile: u,
      onModalCancel: Q
    };
  },
  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((r) => x("div", {
      class: this.ns.b("file-item"),
      key: r.id
    }, [x("div", {
      class: this.ns.b("file-item-title"),
      on: {
        click: () => this.downloadFile(r)
      }
    }, [r.name]), x("div", {
      class: this.ns.b("file-item-action")
    }, [this.showPreview && r.isPreview ? x("i-icon", {
      attrs: {
        type: "md-eye"
      },
      on: {
        click: () => this.previewFile(r)
      }
    }) : 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
      }
    })])]);
  }
}), bu = CA({
  name: "SyGridFileUploadContainer",
  props: Ir(),
  emits: Zs(),
  render(r) {
    return this.disabled || this.readonly ? r("SyGridFileUpload", {
      props: {
        ...this.$props
      }
    }) : r("SyEditGridFileUpload", {
      props: {
        ...this.$props
      },
      on: {
        change: (A, e) => {
          this.$emit("change", A, e);
        },
        rowSave: () => {
          this.$emit("rowSave");
        }
      }
    });
  }
});
const Ku = CA({
  name: "SyEditGridFileUploadPopover",
  props: {
    uploadUrl: {
      type: String,
      required: !0
    },
    downloadUrl: {
      type: String,
      required: !0
    },
    value: {
      type: Array,
      required: !0
    },
    controller: {
      type: $s,
      required: !0
    },
    data: {
      type: Object,
      required: !0
    }
  },
  emits: {
    close: (r) => !0
  },
  setup(r, {
    emit: A
  }) {
    const e = LA("sy-edit-grid-file-upload-popover"), {
      downloadUrl: t,
      value: s,
      uploadUrl: n,
      controller: i
    } = Lr(r), {
      fileList: a,
      uploadState: o,
      selectFile: B
    } = ii({
      downloadUrl: t,
      value: s,
      uploadUrl: n,
      controller: i
    }), c = O(), l = O(!1), u = pi(c, async (f) => {
      A("close", {
        isModified: l.value,
        resultFiles: a.value
      });
    });
    return QA(o, (f) => {
      f === "done" ? (l.value = !0, u.proceed()) : f === "loading" && u.pause();
    }), {
      ns: e,
      componentRef: c,
      fileList: a,
      deleteFile: (f) => {
        const U = a.value.findIndex((w) => w.id === f.id);
        a.value.splice(U, 1), l.value = !0;
      },
      selectFile: B,
      downloadFile: (f) => {
        const U = r.controller, h = U.parent.grid.model.appEntity.deName, v = `${f.id}|${h}|${r.data.srfkey}|${U.context.srfpersonid || U.context.srfuserid}`, m = f.url || t.value.replace("%fileId%", f.id);
        U.fileDownload({
          url: `${m}?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((r) => x("div", {
      class: this.ns.b("file-item"),
      key: r.id
    }, [x("div", {
      class: this.ns.b("file-item-title"),
      on: {
        click: () => this.downloadFile(r)
      }
    }, [r.name]), x("div", {
      class: this.ns.b("file-item-action")
    }, [x("i-icon", {
      attrs: {
        type: "md-close"
      },
      on: {
        click: () => this.deleteFile(r)
      }
    })])]))]), 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 Du = CA({
  name: "SyEditGridFileUpload",
  props: Ir(),
  emits: Zs(),
  setup(r, {
    emit: A
  }) {
    const e = LA("sy-edit-grid-file-upload"), {
      value: t,
      data: s,
      controller: n
    } = Lr(r), {
      downloadUrl: i,
      uploadUrl: a,
      valueList: o
    } = ni({
      value: t,
      data: s,
      controller: n
    }), B = O(), c = async () => {
      if (!B.value)
        throw new hA("容器元素不存在");
      const l = B.value.$el, u = l.offsetHeight, Q = ibiz.overlay.createPopover((U) => U(Ku, {
        props: {
          value: o.value,
          data: s.value,
          uploadUrl: a.value,
          downloadUrl: i.value,
          controller: n.value
        },
        on: {
          close: (w) => {
            Q.dismiss(w);
          }
        }
      }), void 0, {
        noArrow: !0,
        placement: "bottom-start",
        offsetOpts: {
          mainAxis: -u,
          crossAxis: 0
        }
      });
      await Q.present(l);
      const {
        isModified: g,
        resultFiles: f
      } = await Q.onWillDismiss();
      if (g) {
        const U = f.length > 0 ? JSON.stringify(f.map((w) => ({
          name: w.name,
          id: w.id
        }))) : null;
        A("change", U), A("rowSave");
      }
    };
    return Ei(B, "click", (l) => {
      r.disabled || c();
    }), {
      ns: e,
      valueList: o,
      componentRef: B
    };
  },
  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((r) => x("div", {
      class: this.ns.b("file-item"),
      key: r.id
    }, [x("div", {
      class: this.ns.b("file-item-title")
    }, [r.name])]))])]);
  }
});
function Su(r, A) {
  function e() {
    const t = window.navigator.userAgent;
    return t.indexOf("MSIE ") > 0 || t.indexOf("Trident/") > 0;
  }
  return e() ? A ? A() : null : r();
}
const Tu = CA({
  name: "CustomSelectItem",
  props: vi(),
  emits: Ys(),
  setup(r, {
    emit: A
  }) {
    const e = LA("picker"), t = r.controller, s = O(""), n = O([]), i = O(!0), a = O();
    QA(() => r.value, (w) => {
      if (w || w === null) {
        s.value = w, w === null && (s.value = "");
        const h = r.data[t.valueItem];
        if (n.value.findIndex((m) => Object.is(m[t.keyName], h)) !== -1)
          return;
        n.value = [], !_(w) && !_(h) && n.value.push({
          [t.textName]: w,
          [t.keyName]: h
        });
      }
    }, {
      immediate: !0
    });
    const o = async (w) => {
      const h = await t.calcFillDataItems(w);
      h.length && h.forEach((v) => {
        A("change", v.value, v.name);
      }), t.valueItem && A("change", w[t.keyName], t.valueItem), A("change", w[t.textName]);
    }, B = async () => {
      const w = await t.openPickUpView(r.data);
      w && w[0] && await o(w[0]);
    }, c = async () => {
      await t.openLinkView(r.data);
    }, l = async (w) => {
      var h, v, m;
      a.value && (w[t.textName] === s.value && (a.value.currentValue = s.value), (m = (v = (h = a.value.$refs) == null ? void 0 : h.select) == null ? void 0 : v.hideMenu) == null || m.call(v)), await o(w), i.value = !0, A("operate", !1);
    }, u = async (w) => {
      if (t.model.appDataEntity) {
        const h = await t.getServiceData(w, r.data);
        h && (n.value = h.data);
      }
    }, Q = () => {
      var h;
      const w = (h = t.model.deACMode) == null ? void 0 : h.dataItems;
      w != null && w.length && w.forEach((v) => {
        A("change", null, v.name);
      }), t.valueItem && A("change", null, t.valueItem), A("change", null);
    }, g = (w) => {
      A("operate", !0);
      const h = i.value ? "" : w.target.value;
      u(h);
    }, f = () => {
      A("operate", !1);
    }, U = (t.linkView ? 1 : 0) + (t.pickupView ? 1 : 0);
    return {
      ns: e,
      c: t,
      curValue: s,
      items: n,
      autocomplete: a,
      openPickUpView: B,
      openLinkView: c,
      onACSelect: l,
      onSearch: u,
      onClear: Q,
      onFocus: g,
      closeCircle: U,
      onBlur: f
    };
  },
  render(r) {
    return this.readonly ? r("div", {
      class: (this.ns.b(), this.ns.m("readonly"))
    }, [this.value]) : r("div", {
      class: [this.ns.b(), this.disabled ? this.ns.m("disabled") : ""]
    }, [[this.c.noAC && r("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 && r("i-button", {
      key: "ios-search",
      attrs: {
        icon: "ios-search"
      },
      on: {
        click: this.openPickUpView
      }
    }), !this.$slots.append && this.c.linkView && r("i-button", {
      key: "ios-search-outline",
      attrs: {
        icon: "ios-search-outline"
      },
      on: {
        click: "openLinkView"
      }
    })]), !this.c.noAC && r("div", {
      class: [this.ns.e("autocomplete"), this.ns.m(this.closeCircle.toString())]
    }, [[r("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) => r("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 : ""}` : ""]))]), r("div", {
      class: this.ns.e("buns-position")
    }, [r("div", {
      class: this.ns.e("btns")
    }, [this.c.pickupView ? r("i-button", {
      attrs: {
        icon: "ios-search",
        type: "text"
      },
      on: {
        click: this.openPickUpView
      }
    }) : null, this.c.linkView ? r("i-button", {
      on: {
        click: this.openLinkView
      },
      attrs: {
        type: "text"
      },
      class: this.ns.e("link")
    }, [Su(() => r("ion-icon", {
      attrs: {
        src: "./assets/img/link.svg"
      }
    }))]) : null])])]])]]);
  }
});
class xu {
  constructor() {
    q(this, "component", Cu);
  }
}
class Mu {
  constructor() {
    q(this, "formEditor", "SyFileUpload");
    q(this, "gridEditor", "SyGridFileUploadContainer");
  }
  async createController(A, e) {
    const t = new $s(A, e);
    return await t.init(), t;
  }
}
class Ou {
  constructor() {
    q(this, "formEditor", "CustomSelectItem");
    q(this, "gridEditor", "IBizGridPicker");
  }
  async createController(A, e) {
    const t = new Di(A, e);
    return await t.init(), t;
  }
}
const Nu = new di(import.meta.url);
class Ru {
  constructor() {
    this.psModelGroupCondBase = null;
  }
  /**
   * 解析条件
   *
   * @param {IData[]} obj
   * @memberof PSModelCondEngineBase
   */
  parse(A) {
    if (A instanceof Array) {
      const e = this.createPSModelGroupCond();
      e.parse(A), this.psModelGroupCondBase = e;
    }
  }
  /**
   * 测试项
   *
   * @protected
   * @param {string} strCondOp
   * @param {*} objValue
   * @param {*} objCondValue
   * @return {*}  {boolean}
   * @memberof PSModelCondEngineBase
   */
  testSingleCond(A, e, t) {
    try {
      if (A === "ISNULL")
        return e == null;
      if (A === "ISNOTNULL")
        return e != null;
      if (A === "EQ" || A === "ABSEQ" || A === "GT" || A === "GTANDEQ" || A === "LT" || A === "LTANDEQ" || A === "NOTEQ") {
        let s = -1;
        if (e == t ? s = 0 : e > t && (s = 1), A === "EQ" || A === "ABSEQ")
          return s === 0;
        if (A === "GT")
          return s > 0;
        if (A === "GTANDEQ")
          return s >= 0;
        if (A === "LT")
          return s < 0;
        if (A === "LTANDEQ")
          return s <= 0;
        if (A === "NOTEQ")
          return s !== 0;
      }
      if (A === "LIKE")
        return e != null && t != null ? e.toString().toUpperCase().indexOf(t.toString().toUpperCase()) !== -1 : !1;
      if (A === "LEFTLIKE")
        return e != null && t != null ? e.toString().toUpperCase().indexOf(t.toString().toUpperCase()) === 0 : !1;
    } catch (s) {
      ibiz.log.error(s);
    }
    return !1;
  }
  /**
   * 获取根分组条件
   *
   * @return {*}  {PSModelGroupCondBase}
   * @memberof PSModelCondEngineBase
   */
  getPSModelGroupCondBase() {
    return this.psModelGroupCondBase;
  }
}
class ai {
  constructor() {
    this.strCondOp = null;
  }
  getCondOp() {
    return this.strCondOp;
  }
  setCondOp(A) {
    this.strCondOp = A;
  }
}
class Nr extends ai {
  /**
   * 编译条件
   *
   * @author chitanda
   * @date 2022-08-17 23:08:35
   * @param {unknown[]} arr
   */
  parse(A) {
    const e = A.length;
    let t = !0, s = !1, n = !1;
    for (let i = 0; i < e; i++) {
      if (t) {
        const a = A[i];
        this.setCondOp(a), t = !1, s = !0;
        continue;
      }
      if (s) {
        const a = A[i];
        this.setParam(a), s = !1, n = !0;
        continue;
      }
      if (n) {
        const a = A[i];
        if (a instanceof Object && !(a instanceof Array)) {
          const o = a;
          o.type != null && this.setValueType(o.type.toString()), o.value != null && this.setValue(o.value.toString());
        } else
          this.setValue(a);
        break;
      }
    }
  }
  getValueType() {
    return this.strValueType;
  }
  setValueType(A) {
    this.strValueType = A;
  }
  getValue() {
    return this.strValue;
  }
  setValue(A) {
    this.strValue = A;
  }
  getParamType() {
    return this.strParamType;
  }
  setParamType(A) {
    this.strParamType = A;
  }
  getParam() {
    return this.strParam;
  }
  setParam(A) {
    this.strParam = A;
  }
}
class Dt extends ai {
  constructor() {
    super(...arguments), this.childCondList = [], this.bNotMode = !1;
  }
  /**
   * 解析分组条件
   *
   * @param {unknown[]} arr
   * @memberof PSModelGroupCondBase
   */
  parse(A) {
    const e = A.length;
    let t = !0, s = !0, n = !1;
    for (let i = 0; i < e; i++) {
      if (t && s && A[i] === "!") {
        this.setNotMode(!0), t = !1;
        continue;
      }
      if (s) {
        const a = A[i];
        this.setCondOp(a), s = !1, t = !1, n = !0;
        continue;
      }
      if (n) {
        const a = A[i];
        if (a instanceof Array)
          a.forEach((o) => {
            if (o.length > 0) {
              const B = o[0].toString();
              if (B === "!" || B === "OR" || B === "AND") {
                const c = new Dt();
                c.parse(o), this.childCondList.push(c);
              } else {
                const c = new Nr();
                c.parse(o), this.childCondList.push(c);
              }
            }
          });
        else
          throw new Error("值必须为数组");
      }
    }
  }
  setNotMode(A) {
    this.bNotMode = A;
  }
  isNotMode() {
    return this.bNotMode;
  }
  getChildPSModelCondBases() {
    return this.childCondList;
  }
}
class Gu extends Dt {
}
class Vu extends Nr {
}
class oe extends Ru {
  /**
   * 测试
   *
   * @param {IData} data 检测的数据
   * @param {SearchFilter} filter 过滤条件
   * @return {*}  {boolean}
   * @memberof PSDEDQCondEngine
   */
  test(A, e) {
    return this.testCond(this.getPSModelGroupCondBase(), A, e);
  }
  /**
   * 查询条件判断
   *
   * @author chitanda
   * @date 2022-08-17 23:08:11
   * @protected
   * @param {PSModelCondBase} cond
   * @param {IData} data
   * @param {SearchFilter} filter
   * @return {*}  {boolean}
   */
  testCond(A, e, t) {
    if (A instanceof Dt) {
      const s = A.getChildPSModelCondBases();
      if (s == null || _(s))
        return !A.isNotMode();
      const n = A.getCondOp() === "AND";
      let i = n;
      for (let a = 0; a < s.length; a++) {
        const o = s[a];
        if (this.testCond(o, e, t)) {
          if (!n) {
            i = !0;
            break;
          }
        } else if (n) {
          i = !1;
          break;
        }
      }
      return A.isNotMode() ? !i : i;
    }
    if (A instanceof Nr) {
      _(A.getParam()) && ibiz.log.warn("没有指定属性名称", A);
      const s = e[A.getParam().toLowerCase()];
      let n = null;
      const i = A.getValueType(), a = A.getValue();
      return i != null && !_(i) ? (_(a) && ibiz.log.warn("没有指定上下文参数名称"), oe.PARAMTYPE_WEBCONTEXT === i ? n = t.data[a.toLowerCase()] : oe.PARAMTYPE_DATACONTEXT === i && (n = t.getValue(a.toLowerCase()))) : n = A.getValue(), this.testSingleCond(A.getCondOp(), s, n);
    }
    return ibiz.log.warn("无法识别的条件对象", A), !1;
  }
  createPSModelSingleCond() {
    return new Vu();
  }
  createPSModelGroupCond() {
    return new Gu();
  }
}
oe.PARAMTYPE_DATACONTEXT = "DATACONTEXT";
oe.PARAMTYPE_WEBCONTEXT = "WEBCONTEXT";
class oi {
  /**
   * 根据数据查询获取查询
   *
   * @author chitanda
   * @date 2022-08-25 17:08:04
   * @static
   * @param {IPSAppDEDataSet} dataSet
   * @return {*}  {PSDEDQCondEngine}
   */
  static getCond(A) {
    if (this.map.has(A))
      return this.map.get(A);
    const e = A.getPSDEDQGroupConditions();
    if (e) {
      const t = new oe();
      return e.length === 1 ? t.parse(this.calcCond(e)[0]) : e.length > 1 && t.parse(["AND", this.calcCond(e)][0]), this.map.set(A, t), t;
    }
    return null;
  }
  /**
   * 计算查询条件
   *
   * @author chitanda
   * @date 2022-08-25 17:08:39
   * @protected
   * @static
   * @param {IPSDEDQCondition[]} items
   * @return {*}  {unknown[]}
   */
  static calcCond(A) {
    const e = [];
    return A.forEach((t) => {
      const s = [];
      if (t.condType === "GROUP") {
        const n = t;
        n.notMode && s.push("!"), s.push(t.condOp);
        const i = n.getPSDEDQConditions();
        if (i) {
          const a = this.calcCond(i);
          s.push(a);
        }
      } else if (t.condType === "SINGLE") {
        const n = t;
        if (s.push(n.condOp), s.push(n.fieldName), n.condValue)
          if (n.getPSVARTypeId()) {
            const i = {
              type: n.getPSVARTypeId(),
              value: n.condValue
            };
            n.ignoreEmpty && Object.assign(i, { ignoreEmpty: n.ignoreEmpty }), s.push(i);
          } else
            s.push(n.condValue);
        else
          s.push("");
      } else
        throw new Error(`暂未支持的查询条件类型: ${t.condType}`);
      e.push(s);
    }), e;
  }
}
oi.map = /* @__PURE__ */ new WeakMap();
function Ps(r, A) {
  if (A != null) {
    const { srfkey: e } = A;
    if (!lA(e) && !_(e))
      return !0;
  }
  throw new hA(`执行「${r}」不存在「srfkey」无法处理`);
}
function mA(r, A) {
  const { srfsessionid: e } = A;
  if (!lA(e) && !_(e))
    return !0;
  throw new hA(`执行「${r}」不存在「srfsessionid」无法处理`);
}
class Pu {
  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 mA("add", A), (lA(e.srfkey) || _(e.srfkey)) && (e.srfkey = at()), e.srftempdate = (/* @__PURE__ */ new Date()).getTime(), this.getCacheByTag(A).set(e.srfkey, HA(e)), ibiz.log.warn("add", e.srfkey, e), e;
    } catch (t) {
      return ibiz.log.error(t), null;
    }
  }
  /**
   * 查找数据
   *
   * @param {*} context
   * @param {string} srfKey
   * @return {*}  {Entity}
   * @memberof EntityCache
   */
  get(A, e) {
    try {
      mA("get", A);
      const s = this.getCacheByTag(A).get(e);
      return ibiz.log.warn("get", e, s), HA(s);
    } catch (t) {
      return ibiz.log.error(t), null;
    }
  }
  /**
   * 更新数据
   *
   * @param {IContext} context
   * @param {Entity} entity
   * @return {*}  {Entity}
   * @memberof EntityCache
   */
  update(A, e) {
    try {
      mA("update", A), Ps("update", e), e.srftempdate = (/* @__PURE__ */ new Date()).getTime();
      const t = this.getCacheByTag(A), s = t.get(e.srfkey);
      if (s)
        return s.assign(e), t.set(e.srfkey, s), ibiz.log.warn("update", e.srfkey, e), HA(s);
      throw new Error("数据不存在，无法更新!");
    } catch (t) {
      return ibiz.log.error(t), null;
    }
  }
  /**
   * 删除数据
   *
   * @param {IContext} context
   * @param {string} srfKey
   * @return {*}  {(Entity | null)}
   * @memberof EntityCache
   */
  delete(A, e) {
    try {
      mA("delete", A);
      const t = this.getCacheByTag(A), s = e;
      if (t.has(s)) {
        const n = t.get(s);
        return n.srftempdate = (/* @__PURE__ */ new Date()).getTime(), t.delete(s), ibiz.log.warn("delete", s), n;
      }
      return null;
    } catch (t) {
      return ibiz.log.error(t), null;
    }
  }
  /**
   * 批量创建临时数据
   *
   * @author chitanda
   * @date 2022-03-23 11:03:52
   * @param {IContext} context
   * @param {Entity[]} entities
   * @return {*}  {Entity[]}
   */
  createBatch(A, e) {
    try {
      mA("add", A);
      const t = this.getCacheByTag(A);
      for (let s = 0; s < e.length; s++) {
        const n = e[s];
        (lA(n.srfkey) || _(n.srfkey)) && (n.srfkey = at()), n.srftempdate = (/* @__PURE__ */ new Date()).getTime();
        const i = HA(n);
        t.set(n.srfkey, i), e[s] = i, ibiz.log.warn("add", n.srfkey, n);
      }
      return e;
    } catch (t) {
      ibiz.log.error(t);
    }
    return [];
  }
  /**
   * 批量更新数据
   *
   * @author chitanda
   * @date 2022-03-23 10:03:17
   * @param {IContext} context
   * @param {Entity[]} entities
   * @return {*}  {Entity[]}
   */
  updateBatch(A, e) {
    try {
      mA("update", A);
      const t = this.getCacheByTag(A);
      for (let s = 0; s < e.length; s++) {
        const n = e[s];
        Ps("update", n), n.srftempdate = (/* @__PURE__ */ new Date()).getTime();
        const i = t.get(n.srfkey);
        if (i)
          i.assign(n), t.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 (t) {
      return ibiz.log.error(t), null;
    }
  }
  /**
   * 批量删除数据
   *
   * @author chitanda
   * @date 2022-03-23 10:03:40
   * @param {IContext} context 上下文
   * @param {string[]} srfKeys 需要删除的数据主键
   * @return {*}  {string[]} 未能删除的数据主键
   */
  deleteBatch(A, e) {
    try {
      mA("delete", A);
    } catch (n) {
      return ibiz.log.error(n), e;
    }
    const t = this.getCacheByTag(A), s = [];
    for (let n = 0; n < e.length; n++) {
      const i = e[n];
      t.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];
      t.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 {
      mA("getList", A);
      const e = this.getCacheByTag(A);
      if (!e)
        return [];
      const t = e.values();
      return Array.from(t);
    } catch (e) {
      return ibiz.log.error(e), [];
    }
  }
  /**
   * 根据条件查找数据条数
   *
   * @author fzh
   * @date 2024-01-11 18:08:56
   * @param {IContext} context
   * @return {*}  number
   */
  getTotal(A) {
    try {
      mA("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 = XA(A.srfkey)), delete A.srfkey;
    for (const t in A)
      if (Object.prototype.hasOwnProperty.call(A, t)) {
        const s = A[t];
        e[t] = XA(s);
      }
    return fe(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 (!lA(e.page) && !_(e.page) && (this.page = e.page), !lA(e.size) && !_(e.size) && (this.size = e.size), !lA(e.query) && !_(e.query) && (this.query = e.query), !lA(e.sort) && !_(e.sort)) {
        const t = e.sort.split(",");
        t.length >= 1 && ([this.sortField] = t), t.length >= 2 && (this.sortMode = t[1].toUpperCase());
      }
      !lA(e.srfparentkey) && !_(e.srfparentkey) && (this.srfparentkey = e.srfparentkey), !lA(e.srfparentdename) && !_(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 Bi(r, A) {
  let e = [];
  A.forEach((s) => {
    let n = [];
    for (let i = 0; i < s.length - 1; i++) {
      const a = s[i], o = r[a.name];
      o ? (n.push(a.plural), n.push(o)) : n = [];
    }
    e.push(n);
  }), e = e.sort((s, n) => n.length - s.length);
  const [t] = e;
  return t ? `${t.length > 1 ? "/" : ""}${t.join("/")}` : "";
}
sA.DE_GRID_VIEW, sA.DE_GRID_EXP_VIEW, sA.DE_LIST_VIEW, sA.DE_LIST_EXP_VIEW, sA.DE_DATA_VIEW, sA.DE_DATAVIEW_EXP_VIEW, sA.DE_CALENDAR_VIEW, sA.DE_CALENDAR_EXP_VIEW, sA.DE_CHART_VIEW, sA.DE_CHART_EXP_VIEW, sA.DE_KANBAN_VIEW;
var _u = globalThis && globalThis.__rest || function(r, A) {
  var e = {};
  for (var t in r)
    Object.prototype.hasOwnProperty.call(r, t) && A.indexOf(t) < 0 && (e[t] = r[t]);
  if (r != null && typeof Object.getOwnPropertySymbols == "function")
    for (var s = 0, t = Object.getOwnPropertySymbols(r); s < t.length; s++)
      A.indexOf(t[s]) < 0 && Object.prototype.propertyIsEnumerable.call(r, t[s]) && (e[t[s]] = r[t[s]]);
  return e;
};
class Xu {
  /**
   * 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: t } = A, s = _u(A, ["processDefinitionKey", "taskDefinitionKey"]);
    return ibiz.net.get(`${this.getBaseUrl()}/process-definitions/${e}/usertasks/${t}`, 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 t = A[this.model.deName], { taskDefinitionKey: s } = A;
    return ibiz.net.post(`${this.getBaseUrl()}/${t}/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 t = "alls";
    return !ibiz.env.enableWfAllHistory && A.srfprocessinstanceid && (t = A.srfprocessinstanceid), ibiz.net.get(`${this.getBaseUrl()}/${e}/process-instances/${t}/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, t) {
    return ibiz.net.post(`${this.getBaseUrl()}/${A[this.model.deName]}/process-instances`, Object.assign(Object.assign({}, e), { activedata: this.getActiveData(t, 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, t) {
    return ibiz.net.post(`${this.getBaseUrl()}/${A[this.model.deName]}/tasks/${e.taskId}`, Object.assign(Object.assign({}, e), { activedata: this.getActiveData(t, 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, t) {
    return ibiz.net.post(`${this.getBaseUrl()}/${A[this.model.deName]}/tasks/${e.taskId}/withdraw`, Object.assign(Object.assign({}, e), { activedata: this.getActiveData(t, 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, t) {
    return ibiz.net.post(`${this.getBaseUrl()}/${A[this.model.deName]}/tasks/${e.taskId}/transfer`, Object.assign(Object.assign({}, e), { activedata: this.getActiveData(t, 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, t) {
    return ibiz.net.post(`${this.getBaseUrl()}/${A[this.model.deName]}/tasks/${e.taskId}/aftersign`, Object.assign(Object.assign({}, e), { activedata: this.getActiveData(t, 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, t) {
    return ibiz.net.post(`${this.getBaseUrl()}/${A[this.model.deName]}/tasks/${e.taskId}/beforesign`, Object.assign(Object.assign({}, e), { activedata: this.getActiveData(t, 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, t) {
    return ibiz.net.post(`${this.getBaseUrl()}/${A[this.model.deName]}/tasks/${e.taskId}/sendback`, Object.assign(Object.assign({}, e), { activedata: this.getActiveData(t, 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, t) {
    return ibiz.net.post(`${this.getBaseUrl()}/${A[this.model.deName]}/tasks/${e.taskId}/sendcopy`, Object.assign(Object.assign({}, e), { activedata: this.getActiveData(t, 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, t = {}, s = {}) {
    switch (A) {
      case "WFSTART":
        return this.wfStart(e, t, s);
      case "WFSUBMIT":
        return this.wfSubmit(e, t, s);
      case "reassign":
        return this.wfReassign(e, t, s);
      case "addstepbefore":
        return this.wfAddStepBefore(e, t, s);
      case "addstepafter":
        return this.wfAddStepAfter(e, t, s);
      case "sendback":
        return this.wfSendBack(e, t, s);
      case "sendcopy":
        return this.wfSendCopy(e, t, s);
      default:
        throw new hA(`「${A}」未实现`);
    }
  }
}
var Ut;
(function(r) {
  r[r.CREATE = 0] = "CREATE", r[r.UPDATE = 1] = "UPDATE";
})(Ut || (Ut = {}));
class RA {
  get srfuf() {
    return this.srfkey ? Ut.UPDATE : Ut.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 RA ? HA(e.data) : HA(e)
    });
    const t = A.getKeyPSAppDEField().codeName.toLowerCase();
    if (!A.getMajorPSAppDEField())
      throw new hA(`${A.codeName}缺少主信息属性`);
    const s = A.getMajorPSAppDEField().codeName.toLowerCase();
    Object.defineProperty(this, "srfdename", {
      get() {
        return A.codeName;
      }
    }), Object.defineProperty(this, "srfkey", {
      set(n) {
        this.data[t] = n;
      },
      get() {
        return this.data[t];
      }
    }), 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 RA(this.entity, this.data);
  }
  /**
   * 合并参数
   *
   * @author chitanda
   * @date 2022-10-19 11:10:25
   * @param {(IData | Entity)} data
   * @return {*}  {Entity}
   */
  assign(A) {
    return A instanceof RA ? Object.assign(this.data, A.data) : Object.assign(this.data, A), this;
  }
}
class St {
  get entity() {
    var A;
    return this._entity || (this._entity = new Hr((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.presetFields = ["srfactionparam"], 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, t = !1) {
    const s = {};
    for (let i = 0; i < this.fields.length; i++) {
      const a = this.fields[i], o = a.codeName.toLowerCase();
      switch (a.type) {
        case "SIMPLE":
        case "SIMPLES":
        case "DTO": {
          const B = e[o];
          yi(B) ? s[o] = null : s[o] = B;
          break;
        }
        case "DTOS": {
          if (e[o] !== void 0 && t === !1) {
            s[o] = e[o];
            break;
          }
          const B = await this.getFieldDto(a), c = a.getRefPSAppDataEntity();
          if (!c) {
            s[o] = e[o];
            break;
          }
          const l = await ibiz.entityService.getService(c.codeName, A);
          let u = [];
          const { getRefPSAppDEDataSet: Q, getRefPickupPSAppDEField: g } = a.M;
          if (Q && Q.id) {
            const f = {};
            g && g.codeName && this.entity.source.getKeyPSAppDEField() && e[this.entity.source.getKeyPSAppDEField().codeName.toLowerCase()] && (f.srfaddconditions = !0, f[g.codeName.toLowerCase()] = e[this.entity.source.getKeyPSAppDEField().codeName.toLowerCase()]);
            const U = await l.exec(Q.id, A, f);
            U.ok && U.data && (u = U.data);
          } else
            u = l.local.getList(A);
          if (u) {
            const f = [];
            for (let U = 0; U < u.length; U++)
              f.push(await B.get(A, u[U], !0));
            s[o] = f;
          }
          break;
        }
        default:
          throw new _s(a, `未支持的应用实体方法输入属性类型: ${a.type}`);
      }
    }
    const n = {};
    return this.presetFields.forEach((i) => {
      e[i] && (n[i] = e[i]);
    }), Object.assign(Object.assign({}, n), s);
  }
  /**
   * 设置本地 DTO 存储
   *
   * @author chitanda
   * @date 2022-10-10 23:10:50
   * @param {IContext} context
   * @param {IData[]} data
   * @return {*}  {Promise<Entity[]>}
   */
  async sets(A, e) {
    const t = await ibiz.entityService.getService(this.entity.codeName);
    return Promise.all(e.map(async (s) => {
      const n = this.fields.filter((a) => a.type === "DTOS" && a.M.getRefPSAppDataEntity).map(async (a) => {
        const o = a.codeName.toLowerCase(), B = await this.getFieldDto(a), c = s[o];
        c ? await B.sets(A, c) : await B.sets(A, []);
      });
      for (let a = 0; a < n.length; a++)
        await n[a];
      const i = new RA(this.entity.source, s);
      return this.isLocalMode && await t.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 t = new St(!0, A.getRefPSAppDEMethodDTO());
    return this.dtoMap.set(A.codeName, t), t;
  }
}
function Tt(r, A) {
  return A.source.userTag === "enableTempDataFront" || r.actionType === "BUILTIN" || r.dataSetType === "DATAQUERY";
}
class Ju {
  get isLocalMode() {
    return Tt(this.method, this.entity);
  }
  /**
   * 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 t = e.getPSAppDEMethodInput(), s = t == null ? void 0 : t.getPSAppDEMethodDTO();
    s && (this.dto = new St(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 Wu {
  get isLocalMode() {
    return Tt(this.method, this.entity);
  }
  /**
   * 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 t = e.getPSAppDEMethodReturn(), s = t == null ? void 0 : t.getPSAppDEMethodDTO();
    s && (this.dto = new St(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 ? (ibiz.entityService.clearTempCache(A), (await this.dto.sets(A, [e]))[0]) : new RA(this.entity.source, e);
  }
}
class ci {
  /**
   * 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, t) {
    this.entity = A, this.method = e, this.paths = t, this.input = new Ju(A, e), this.result = new Wu(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, t, 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}`, t, s);
        break;
      case "GET":
        a = await ibiz.net.get(`${A}/${i}`, t, s);
        break;
      case "PUT":
        a = await ibiz.net.put(`${A}/${i}`, t, s);
        break;
      case "DELETE":
        a = await ibiz.net.delete(`${A}/${i}`, t, s);
        break;
      default:
        throw n ? new Rr(this.method, `未支持的请求方式: ${n}`) : new Rr(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 Bi(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 RA(this.entity.source, A);
  }
}
class Yu {
  /**
   * Creates an instance of DELogic.
   * @author lxm
   * @date 2023-02-08 17:02:26
   * @param {IAppDELogic} model
   */
  constructor(A) {
    if (this.model = A, A.customCode) {
      if (!A.scriptCode)
        throw new hA("实体处理逻辑没有脚本代码发生异常");
      const e = `return (async function() { 
 ${A.scriptCode} 
} )();`;
      this.scriptFn = new Function("context", "params", "data", e);
    } else
      throw new hA("实体处理逻辑暂未支持非脚本类型");
  }
  /**
   * 执行逻辑
   *
   * @author lxm
   * @date 2023-02-08 21:02:09
   * @param {IContext} context
   * @param {IData} data
   * @param {IParams} [opt]
   * @return {*}  {Promise<IData>}
   */
  async exec(A, e, t) {
    return this.scriptFn ? this.scriptFn(A, t, e) : null;
  }
}
const tr = /* @__PURE__ */ new Map();
async function li(r, A, e, t, s = {}) {
  if (t) {
    if (Array.isArray(t)) {
      await Promise.all(t.map((n) => ks(r, A, e, n, s)));
      return;
    }
    return ks(r, A, e, t, s);
  }
}
async function ks(r, A, e, t, s) {
  const n = Zu(r, A);
  n.length && (await Promise.all(n.map((a) => ui(a, e, t, s)))).forEach((a) => {
    Object.assign(t, a);
  });
}
function Zu(r, A) {
  var e, t;
  const s = [];
  return (e = r.getAllPSAppDEFields()) === null || e === void 0 || e.forEach((n) => {
    var i;
    A === "compute" && (!((i = n.M.getComputePSAppDEFLogic) === null || i === void 0) && i.id) && s.push(n.M.getComputePSAppDEFLogic.id);
  }), ((t = r.M.getAllPSAppDELogics) === null || t === void 0 ? void 0 : t.filter((n) => s.includes(n.codeName))) || [];
}
async function ui(r, A, e = {}, t = {}) {
  tr.has(r) || tr.set(r, new Yu(r)), ibiz.log.debug("开始执行逻辑");
  const n = await tr.get(r).exec(A, e, t);
  return ibiz.log.debug("结束执行逻辑"), n;
}
class zu extends ci {
  /**
   * 是否为本地模式
   *
   * @author chitanda
   * @date 2023-04-19 16:04:46
   * @readonly
   * @protected
   * @type {boolean}
   */
  get isLocalMode() {
    return Tt(this.method, this.entity);
  }
  async exec(A, e, t) {
    if (this.isLocalMode || (Array.isArray(e) ? e = await Promise.all(e.map((i) => this.input.handle(A, i))) : e = await this.input.handle(A, e)), this.method.actionType === "DELOGIC") {
      const { getPSAppDELogic: i } = this.method.M;
      if (i && i.id) {
        const a = this.entity.source.findPSAppDELogic(i.id);
        if (a) {
          const o = await ui(a, A, e, t);
          return new S(o);
        }
      }
      throw new hA(`实体处理逻辑类型行为未找到标识为[${i.id}]实体处理逻辑`);
    }
    let s = this.calcPath(A);
    this.method.needResourceKey && (s = `${s}/${A[this.entity.deName]}`);
    let n;
    if (this.method.beforeCode) {
      const i = {
        context: A,
        params: t,
        data: e
      }, a = `return (async function() { ${this.method.beforeCode}} )();`;
      await new Function(...Object.keys(i), a).apply({}, Object.values(i));
    }
    switch (this.method.codeName) {
      case "Create":
        n = await this.create(A, e, t);
        break;
      case "Get":
        n = await this.get(A, e);
        break;
      case "GetDraft":
        n = await this.getDraft(A, e);
        break;
      case "Remove":
        n = await this.remove(A, e);
        break;
      case "Update":
        n = await this.update(A, e, t);
        break;
      case "CreateTemp":
        n = await this.createTemp(A, e);
        break;
      case "GetTemp":
        n = await this.getTemp(A, e);
        break;
      case "GetDraftTemp":
        n = await this.getDraftTemp(A, e);
        break;
      case "RemoveTemp":
        n = await this.removeTemp(A, e);
        break;
      case "UpdateTemp":
        n = await this.updateTemp(A, e);
        break;
      default:
        n = await this.request(s, A, e, t), n.data = await this.result.handle(A, n.data);
    }
    if (this.method.afterCode) {
      const i = {
        context: A,
        params: t,
        data: e
      }, a = `return (async function() { ${this.method.afterCode}} )();`;
      await new Function(...Object.keys(i), a).apply({}, Object.values(i));
    }
    return n && n.data && await li(this.entity.source, "compute", A, n.data, t), 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, t) {
    if (this.isLocalMode)
      return this.createTemp(A, e);
    const s = this.calcPath(A), n = await ibiz.net.post(s, e, t);
    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 t = this.calcPath(A);
    return await ibiz.net.delete(`${t}/${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, t = {}) {
    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, t);
    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 t = this.calcPath(A), s = await ibiz.net.get(`${t}/${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 t = this.calcPath(A), s = await ibiz.net.get(`${t}/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 t = await this.getService();
      if (Array.isArray(e)) {
        const i = e.map((o) => {
          const B = this.createEntity(o);
          return t.local.add(A, this.attach(A, B));
        }), a = await Promise.all(i);
        return new S(a);
      }
      const s = this.createEntity(e), n = await t.local.add(A, this.attach(A, s));
      return new S(n);
    } catch (t) {
      return new S(t, 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 t = this.createEntity({});
      return t ? new S(t) : new S(t, 500);
    } catch (t) {
      return new S(t, 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 t = null;
      e && (t = e[this.entity.keyName]), !t && A && (t = A[this.entity.deName]);
      const n = (await this.getService()).local.delete(A, t);
      return n ? new S(n) : new S(n, 500);
    } catch (t) {
      return new S(t, 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 t = await this.getService(), s = this.createEntity(e), n = t.local.update(A, this.attach(A, s));
      return n ? new S(n) : new S(n, 500);
    } catch (t) {
      return new S(t, 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 t = null;
      e && (t = e[this.entity.keyName]), !t && A && (t = A[this.entity.deName]);
      const n = (await this.getService()).local.get(A, t);
      return n ? new S(n) : new S(n, 500);
    } catch (t) {
      return new S(t, 500);
    }
  }
  /**
   * 批量删除本地数据
   *
   * @param {IContext} context
   * @param {IParams} [params]
   * @return {*}  {Promise<IHttpResponse>}
   */
  async removeBatchTemp(A, e) {
    if (e) {
      const t = e[this.entity.keyName];
      if (t)
        try {
          await (await this.getService()).local.deleteBatch(A, t);
        } catch (s) {
          return new S(s, 500);
        }
    }
    return new S(!0);
  }
  /**
   * @description 在新建、更新时，根据界面域下的关系，自动填充相关父属性
   * @protected
   * @param {IContext} context
   * @param {Entity} data
   * @returns {*}  {Entity}
   * @memberof DEActionMethod
   */
  attach(A, e) {
    const { minorDERss: t } = this.entity;
    return t.forEach((s) => {
      const n = s.getParentPSAppDEField();
      if (n) {
        const i = n.codeName.toLowerCase(), a = s.majorDECodeName.toLowerCase(), o = A[a];
        !e[i] && o && (e[i] = o);
      }
    }), e;
  }
}
class $u extends ci {
  /**
   * 是否为本地模式
   *
   * @author chitanda
   * @date 2023-04-19 16:04:46
   * @readonly
   * @protected
   * @type {boolean}
   */
  get isLocalMode() {
    return Tt(this.method, this.entity);
  }
  async exec(A, e, t) {
    let s;
    if (this.isLocalMode) {
      const n = oi.getCond(this.method), i = await this.searchLocal(n, new ku(A, e));
      s = new S(i, 200);
    } else {
      const n = this.calcPath(A);
      s = await this.request(n, A, e, t);
      const i = s.data || [];
      s.data = i.map((a) => this.createEntity(a));
    }
    return s.data && await li(this.entity.source, "compute", A, s.data, t), s;
  }
  /**
   * 查询本地数据，根据属性
   *
   * @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 = Gr(s, "srfordervalue");
    const n = {}, i = {}, a = {}, o = {};
    e.srfkey && (n.srfkey = XA(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] = XA(null), a[c] = XA(void 0), o[c] = XA("")) : n[c] = XA(l);
      }
    if (!_(n)) {
      const c = fe(n), l = fe(i), u = fe(a), Q = fe(o);
      s = s.filter((g) => {
        if (_(i)) {
          if (c(g))
            return !0;
        } else if (c(g) && (l(g) || u(g) || Q(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, t = this.entity.quickSearchKeys) {
    const s = await this.getService();
    let n = [];
    if (A)
      n = s.local.getList(e.context), n.length > 0 && (n = n.filter((l) => A.test(l, e)));
    else {
      if (e.data && e.data.srfaddconditions) {
        const l = Object.assign({}, e.data);
        delete l.srfaddconditions, n = await this.selectLocal(e.context, l);
      } else
        n = await this.selectLocal(e.context);
      n.length > 0 && e.query && e.query !== "" && t && (n = n.filter((l) => {
        const u = new RegExp(e.query);
        for (let Q = 0; Q < t.length; Q += 1) {
          const g = t[Q], f = l[g];
          if (u.test(f))
            return !0;
        }
        return !1;
      }));
    }
    !lA(e.sortField) && !_(e.sortField) && (e.sortMode === "DESC" ? n = Ii(n, e.sortField) : n = Gr(n, e.sortField));
    const { page: i, size: a } = e, o = i * a, B = (i + 1) * a - 1;
    return n.slice(o, B).map((l) => HA(l));
  }
}
class ju {
  /**
   * 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, t, s) {
    const i = `${Bi(t, this.paths)}/${this.model.deNamePlural}/exportdata/${e.toLowerCase()}/?srfexporttag=${A.codeName}`;
    return ibiz.net.request(i, {
      method: "post",
      data: s,
      responseType: "blob"
    });
  }
}
class qu {
  /**
   * 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 Pu(), this.wf = new Xu(A), this.file = new ju(A, e);
  }
  /**
   * 创建实体数据
   *
   * @protected
   * @param {(IData | Entity)} data
   * @return {*}  {Entity}
   * @memberof EntityService
   */
  createEntity(A) {
    return new RA(this.model.source, A);
  }
  /**
   * 获取实体服务方法实例
   *
   * @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 t = null;
    switch (e.methodType) {
      case "DEACTION":
        t = new zu(this.model, e, this.paths);
        break;
      case "FETCH":
      case "FETCHTEMP":
        t = new $u(this.model, e, this.paths);
        break;
      default:
        throw new _s(e, `未支持的服务方法类型: ${e.methodType}`);
    }
    return this.methodMap.set(A, t), t;
  }
  /**
   * 执行服务方法
   *
   * @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, t = {}, s = {}) {
    const n = this.getMethod(A);
    if (n)
      return n.exec(e, t, s);
    throw new hA(`${this.model.deName}未支持「${A}」方法`);
  }
  getTotal(A) {
    return this.local.getTotal(A) || 0;
  }
  getPath(A, e, t = {}, s = {}) {
    const n = this.getMethod(A);
    if (n)
      return n.exec(e, t, s);
    throw new hA(`${this.model.deName}未支持「${A}」方法`);
  }
  /**
   * 新建临时数据
   *
   * @param {IContext} context
   * @param {(IData | IData[])} entity 创建的数据
   * @return {*}  {Promise<IHttpResponse<Entity>>}
   * @memberof EntityService
   */
  async createTemp(A, e) {
    try {
      if (Array.isArray(e)) {
        const s = e.map((i) => this.local.add(A, this.createEntity(i))), n = await Promise.all(s);
        return new S(n);
      }
      const t = await this.local.add(A, this.createEntity(e));
      return new S(t);
    } catch (t) {
      return new S(t, 500);
    }
  }
  /**
   * 获取临时数据
   *
   * @param {IContext} context
   * @param {IParams} [params]
   * @return {*}
   * @memberof EntityService
   */
  async getTemp(A, e) {
    try {
      let t = null;
      e && (t = e[this.model.keyName]), !t && A && (t = A[this.model.deName]);
      const s = this.local.get(A, t);
      return s ? new S(s) : new S(s, 500);
    } catch (t) {
      return new S(t, 500);
    }
  }
  /**
   * 获取临时数据默认值
   *
   * @param {IContext} _context
   * @param {IParams} [_params]
   * @return {*}  {Promise<IHttpResponse<Entity>>}
   * @memberof EntityService
   */
  async getDraftTemp(A, e) {
    try {
      const t = this.createEntity({});
      return t ? new S(t) : new S(t, 500);
    } catch (t) {
      return new S(t, 500);
    }
  }
  /**
   * 删除临时数据
   *
   * @param {IContext} context
   * @param {IParams} [params]
   * @return {*}  {Promise<IHttpResponse<Entity>>}
   * @memberof EntityService
   */
  async removeTemp(A, e) {
    try {
      let t = null;
      e && (t = e[this.model.keyName]), !t && A && (t = A[this.model.deName]);
      const s = this.local.delete(A, t);
      return s ? new S(s) : new S(s, 500);
    } catch (t) {
      return new S(t, 500);
    }
  }
  /**
   * 更新临时数据
   *
   * @param {IContext} context
   * @param {IData} entity 需要更新的数据
   * @return {*}  {Promise<IHttpResponse<Entity>>}
   * @memberof EntityService
   */
  async updateTemp(A, e) {
    try {
      const t = this.local.update(A, this.createEntity(e));
      return t ? new S(t) : new S(t, 500);
    } catch (t) {
      return new S(t, 500);
    }
  }
}
class Ag {
  constructor() {
    this.cache = /* @__PURE__ */ new Map(), this.creatingCache = /* @__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 Qi(A)).app.getAllPSAppDataEntities() || []).forEach((s) => {
      const n = s.isFill ? s.codeName : s.refM.codeName;
      this.allEntities.set(n, s);
    });
  }
  async createServiceInstance(A, e) {
    await this.initAllEntities(e);
    const t = this.allEntities.get(A);
    if (!t)
      throw new Error(`找不到实体[${A}]模型`);
    await t.fill(!0);
    const s = new Hr(t);
    await s.init();
    const n = ibiz.resourcePathUtil.calcPaths(e || {}, A);
    return new qu(s, n);
  }
  /**
   * 根据实体标识获取实体服务
   *
   * @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)) {
      let t;
      if (this.creatingCache.has(A))
        t = await this.creatingCache.get(A);
      else {
        const s = this.createServiceInstance(A, e);
        this.creatingCache.set(A, s), t = await s, this.creatingCache.delete(A);
      }
      this.cache.set(A, t);
    }
    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 eg extends xi {
  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 t = ibiz.appData.context;
    this.SyWFHistoryBase = `/wfcoreex/${t.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 t = e[this.model.deName];
    let s = "alls";
    return !ibiz.env.enableWfAllHistory && e.srfprocessinstanceid && (s = e.srfprocessinstanceid), ibiz.net.get(
      `${this.SyWFHistoryBase}/${t}/process-instances/${s}/history`
    );
  }
}
class tg extends Mi {
  /**
   * Creates an instance of EntityService.
   *
   * @author chitanda
   * @date 2022-08-24 18:08:44
   * @param {AppEntityModel} model 应用实体模型
   * @param {ServicePathItem[][]} paths 计算出的资源关系路径
   */
  constructor(e, t) {
    super(e, t);
    /**
     * 工作流相关服务
     *
     * @author lxm
     * @date 2022-09-29 11:09:28
     * @type {WorkFlowService}
     */
    q(this, "wf");
    this.model = e, this.paths = t, this.wf = new eg(e);
  }
}
class rg extends Ag {
  /**
   * 根据实体标识获取实体服务
   *
   * @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 t = this.allEntities.get(A);
      if (!t)
        throw new Error(`找不到实体[${A}]模型`);
      await t.fill(!0);
      const s = new Hr(t);
      await s.init();
      const n = ibiz.resourcePathUtil.calcPaths(
        e || {},
        A
      ), i = await new tg(s, n);
      this.cache.set(A, i);
    }
    return this.cache.get(A);
  }
}
function sg() {
  ibiz.entityService = new rg();
}
const fg = {
  mateUrl: import.meta.url,
  // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
  install(r) {
    hi.getModelService().then((A) => {
      var t;
      const e = A.app;
      e && e.userParams && e.userParams.autoWidth === "true" && ((t = document.getElementsByClassName("app")[0]) == null || t.classList.add("auto-width"));
    }), Nu.loadStyle(["/style.css"]), sg(), ibiz.register.view.register(
      "VIEW_CUSTOM_SyWfDynaEditView3",
      new Ri()
    ), ibiz.register.view.register(
      "VIEW_CUSTOM_SyEditView3",
      new Pi()
    ), ibiz.register.uiAction.register(
      "DEUIACTION_ExportAsImagePlugin",
      new Qu()
    ), ibiz.register.view.register(
      "VIEW_CUSTOM_PresetWFChartView",
      new xu()
    ), r.component("SyFileUpload", Iu), r.component("SyGridFileUpload", Lu), r.component("SyEditGridFileUpload", Du), r.component("SyGridFileUploadContainer", bu), ibiz.register.editor.register(
      "EDITOR_CUSTOMSTYLE_SyFileUpload",
      new Mu()
    ), r.component("CustomSelectItem", Tu), ibiz.register.editor.register(
      "EDITOR_CUSTOMSTYLE_CUSTOM_SELECT_ITEM",
      new Ou()
    );
  }
};
export {
  fg as default
};
